coresight: Fix duplicate and abnormal stop issues of PCIE sw path

Compare with sysfs buffer size instead of drvdata size to avoid the
duplicate data issue. Need to compare with the actual data size as
the data size could be smaller than the PCIE block size.

Change-Id: I45175b57a9154cbfb96946d424b8474a6a69213f
Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
This commit is contained in:
Mao Jinlong 2023-08-01 15:56:25 +08:00 • committed by Jinlong Mao
commit d4bb64720d
2 changed files with 4 additions and 3 deletions

View file

@ -785,7 +785,7 @@ static void etr_pcie_write_work_fn(struct work_struct *work)
req->snd_cmpl = 1;
bytes_to_write = mhi_dev_write_channel(req);
if (bytes_to_write != PCIE_BLK_SIZE) {
if (bytes_to_write != actual) {
dev_err(&tmcdrvdata->csdev->dev, "Write error %d\n",
bytes_to_write);
@ -795,7 +795,7 @@ static void etr_pcie_write_work_fn(struct work_struct *work)
}
mutex_lock(&byte_cntr_data->byte_cntr_lock);
if (byte_cntr_data->offset + actual >= tmcdrvdata->size)
if (byte_cntr_data->offset + actual >= tmcdrvdata->sysfs_buf->size)
byte_cntr_data->offset = 0;
else
byte_cntr_data->offset += actual;

View file

@ -1171,7 +1171,8 @@ static void __tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
{
CS_UNLOCK(drvdata->base);
tmc_flush_and_stop(drvdata);
if (drvdata->out_mode != TMC_ETR_OUT_MODE_PCIE)
tmc_flush_and_stop(drvdata);
/*
* When operating in sysFS mode the content of the buffer needs to be
* read before the TMC is disabled.