From d4bb64720dff6a76cf24720d1fe6b76af6ac4f94 Mon Sep 17 00:00:00 2001 From: Mao Jinlong Date: Tue, 1 Aug 2023 15:56:25 +0800 Subject: [PATCH] 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 --- drivers/hwtracing/coresight/coresight-byte-cntr.c | 4 ++-- drivers/hwtracing/coresight/coresight-tmc-etr.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-byte-cntr.c b/drivers/hwtracing/coresight/coresight-byte-cntr.c index 9c500245b4e2..d85b769ea9ce 100644 --- a/drivers/hwtracing/coresight/coresight-byte-cntr.c +++ b/drivers/hwtracing/coresight/coresight-byte-cntr.c @@ -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; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 323971401cb6..d2a71501bf0d 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -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.