mirror of
https://github.com/torvalds/linux.git
synced 2026-07-30 19:21:28 +02:00
coresight: byte-cntr: Read data from current rwp offset
When enable byte-cntr, read data from current rwp offset instead of the begainning of the ETR buffer. Change-Id: I485aeea97de774055179ccb4c8eb9fe7fb6b0ab1 Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
This commit is contained in:
parent
7e1ac1f823
commit
fa43ed19f7
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#define CSR_BYTECNTVAL (0x06C)
|
||||
|
||||
static void tmc_etr_read_bytes(struct byte_cntr *byte_cntr_data, loff_t *ppos,
|
||||
static void tmc_etr_read_bytes(struct byte_cntr *byte_cntr_data, long offset,
|
||||
size_t bytes, size_t *len, char **bufp)
|
||||
{
|
||||
struct tmc_drvdata *tmcdrvdata = byte_cntr_data->tmcdrvdata;
|
||||
|
|
@ -27,12 +27,12 @@ static void tmc_etr_read_bytes(struct byte_cntr *byte_cntr_data, loff_t *ppos,
|
|||
|
||||
if (*len >= bytes)
|
||||
*len = bytes;
|
||||
else if (((uint32_t)*ppos % bytes) + *len > bytes)
|
||||
*len = bytes - ((uint32_t)*ppos % bytes);
|
||||
else if (((uint32_t)offset % bytes) + *len > bytes)
|
||||
*len = bytes - ((uint32_t)offset % bytes);
|
||||
|
||||
actual = tmc_etr_buf_get_data(etr_buf, *ppos, *len, bufp);
|
||||
actual = tmc_etr_buf_get_data(etr_buf, offset, *len, bufp);
|
||||
*len = actual;
|
||||
if (actual == bytes || (actual + (uint32_t)*ppos) % bytes == 0)
|
||||
if (actual == bytes || (actual + (uint32_t)offset) % bytes == 0)
|
||||
atomic_dec(&byte_cntr_data->irq_cnt);
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ static irqreturn_t etr_handler(int irq, void *data)
|
|||
}
|
||||
|
||||
|
||||
static long tmc_etr_flush_remaining_bytes(struct tmc_drvdata *tmcdrvdata, loff_t *ppos,
|
||||
static long tmc_etr_flush_remaining_bytes(struct tmc_drvdata *tmcdrvdata, long offset,
|
||||
char **bufpp)
|
||||
{
|
||||
long rwp_offset, req_size, actual = 0;
|
||||
|
|
@ -78,11 +78,11 @@ static long tmc_etr_flush_remaining_bytes(struct tmc_drvdata *tmcdrvdata, loff_t
|
|||
|
||||
rwp_offset = tmc_get_rwp_offset(tmcdrvdata);
|
||||
pm_runtime_put(dev->parent);
|
||||
req_size = ((rwp_offset < *ppos) ? tmcdrvdata->size : 0) +
|
||||
rwp_offset - *ppos;
|
||||
req_size = ((rwp_offset < offset) ? tmcdrvdata->size : 0) +
|
||||
rwp_offset - offset;
|
||||
|
||||
if (req_size > 0)
|
||||
actual = tmc_etr_buf_get_data(etr_buf, *ppos, req_size, bufpp);
|
||||
actual = tmc_etr_buf_get_data(etr_buf, offset, req_size, bufpp);
|
||||
|
||||
return actual;
|
||||
}
|
||||
|
|
@ -102,7 +102,8 @@ static ssize_t tmc_etr_byte_cntr_read(struct file *fp, char __user *data,
|
|||
|
||||
mutex_lock(&byte_cntr_data->byte_cntr_lock);
|
||||
if (!byte_cntr_data->read_active) {
|
||||
actual = tmc_etr_flush_remaining_bytes(tmcdrvdata, ppos, &bufp);
|
||||
actual = tmc_etr_flush_remaining_bytes(tmcdrvdata,
|
||||
byte_cntr_data->offset, &bufp);
|
||||
if (actual > 0) {
|
||||
len = actual;
|
||||
goto copy;
|
||||
|
|
@ -121,7 +122,8 @@ static ssize_t tmc_etr_byte_cntr_read(struct file *fp, char __user *data,
|
|||
return -ERESTARTSYS;
|
||||
mutex_lock(&byte_cntr_data->byte_cntr_lock);
|
||||
if (!byte_cntr_data->read_active) {
|
||||
actual = tmc_etr_flush_remaining_bytes(tmcdrvdata, ppos, &bufp);
|
||||
actual = tmc_etr_flush_remaining_bytes(tmcdrvdata,
|
||||
byte_cntr_data->offset, &bufp);
|
||||
if (actual > 0) {
|
||||
len = actual;
|
||||
goto copy;
|
||||
|
|
@ -132,11 +134,12 @@ static ssize_t tmc_etr_byte_cntr_read(struct file *fp, char __user *data,
|
|||
}
|
||||
}
|
||||
|
||||
tmc_etr_read_bytes(byte_cntr_data, ppos,
|
||||
tmc_etr_read_bytes(byte_cntr_data, byte_cntr_data->offset,
|
||||
byte_cntr_data->block_size, &len, &bufp);
|
||||
|
||||
} else {
|
||||
actual = tmc_etr_flush_remaining_bytes(tmcdrvdata, ppos, &bufp);
|
||||
actual = tmc_etr_flush_remaining_bytes(tmcdrvdata,
|
||||
byte_cntr_data->offset, &bufp);
|
||||
if (actual > 0) {
|
||||
len = actual;
|
||||
goto copy;
|
||||
|
|
@ -156,10 +159,10 @@ static ssize_t tmc_etr_byte_cntr_read(struct file *fp, char __user *data,
|
|||
|
||||
byte_cntr_data->total_size += len;
|
||||
|
||||
if (*ppos + len >= tmcdrvdata->size)
|
||||
*ppos = 0;
|
||||
if (byte_cntr_data->offset + len >= tmcdrvdata->size)
|
||||
byte_cntr_data->offset = 0;
|
||||
else
|
||||
*ppos += len;
|
||||
byte_cntr_data->offset += len;
|
||||
|
||||
goto out;
|
||||
|
||||
|
|
@ -276,6 +279,7 @@ static int tmc_etr_byte_cntr_open(struct inode *in, struct file *fp)
|
|||
byte_cntr_data->enable = true;
|
||||
byte_cntr_data->read_active = true;
|
||||
byte_cntr_data->total_size = 0;
|
||||
byte_cntr_data->offset = tmc_get_rwp_offset(tmcdrvdata);
|
||||
mutex_unlock(&byte_cntr_data->byte_cntr_lock);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user