* [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start
@ 2026-04-14 17:25 Pradhan, Sanman
2026-04-14 17:25 ` [PATCH v2 1/2] hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start() Pradhan, Sanman
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Pradhan, Sanman @ 2026-04-14 17:25 UTC (permalink / raw)
To: yangyicong@hisilicon.com, jonathan.cameron@huawei.com
Cc: alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, yangyccccc@gmail.com, Sanman Pradhan
From: Sanman Pradhan <psanman@juniper.net>
Patch 1: Propagate the DMA reset timeout error from
hisi_ptt_wait_dma_reset_done() instead of discarding it. De-assert
the reset bit and log an error on timeout. Move ctrl->started to the
successful path so a failed start does not leave the trace marked as
active.
Patch 2: Remove the unnecessary 16 MiB memset of trace buffers in
hisi_ptt_trace_start(). The driver only copies data that hardware has
written, so the zeroing is not needed.
Changes since v1:
- Patch 1: Return bool from hisi_ptt_wait_dma_reset_done() for
consistency with the other wait helpers
- Patch 1: Add pci_err() on timeout
- Patch 1: De-assert RST before returning on timeout
- Patch 1: Move ctrl->started to the successful path
- Dropped "Use the passed buffer index in hisi_ptt_update_aux()" patch
- Patch 2 is unchanged
Sanman Pradhan (2):
hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start()
hwtracing: hisi_ptt: Remove unnecessary trace buffer zeroing in
trace_start()
drivers/hwtracing/ptt/hisi_ptt.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start()
2026-04-14 17:25 [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start Pradhan, Sanman
@ 2026-04-14 17:25 ` Pradhan, Sanman
2026-04-16 17:25 ` Yicong Yang
2026-04-14 17:25 ` [PATCH v2 2/2] hwtracing: hisi_ptt: Remove unnecessary trace buffer zeroing " Pradhan, Sanman
2026-04-17 12:45 ` [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start Jonathan Cameron
2 siblings, 1 reply; 5+ messages in thread
From: Pradhan, Sanman @ 2026-04-14 17:25 UTC (permalink / raw)
To: yangyicong@hisilicon.com, jonathan.cameron@huawei.com
Cc: alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, yangyccccc@gmail.com, Sanman Pradhan
From: Sanman Pradhan <psanman@juniper.net>
hisi_ptt_wait_dma_reset_done() discards the return value of
readl_poll_timeout_atomic(). If the DMA engine does not complete its
reset within the timeout, hisi_ptt_trace_start() proceeds to start
tracing regardless.
Return a bool from hisi_ptt_wait_dma_reset_done(), consistent with the
other wait helpers in this driver. On timeout, log an error, de-assert
the reset bit, and return -ETIMEDOUT. Move ctrl->started to the
successful path so a failed start does not leave the trace marked as
active.
Fixes: ff0de066b463 ("hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
---
v2:
- Return bool for consistency with other wait helpers
- Add pci_err() on timeout
- De-assert RST before returning on timeout
- Move ctrl->started to the successful path
drivers/hwtracing/ptt/hisi_ptt.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
index 94c371c491357..b5d851281fbf0 100644
--- a/drivers/hwtracing/ptt/hisi_ptt.c
+++ b/drivers/hwtracing/ptt/hisi_ptt.c
@@ -171,13 +171,13 @@ static bool hisi_ptt_wait_trace_hw_idle(struct hisi_ptt *hisi_ptt)
HISI_PTT_WAIT_TRACE_TIMEOUT_US);
}
-static void hisi_ptt_wait_dma_reset_done(struct hisi_ptt *hisi_ptt)
+static bool hisi_ptt_wait_dma_reset_done(struct hisi_ptt *hisi_ptt)
{
u32 val;
- readl_poll_timeout_atomic(hisi_ptt->iobase + HISI_PTT_TRACE_WR_STS,
- val, !val, HISI_PTT_RESET_POLL_INTERVAL_US,
- HISI_PTT_RESET_TIMEOUT_US);
+ return !readl_poll_timeout_atomic(hisi_ptt->iobase + HISI_PTT_TRACE_WR_STS,
+ val, !val, HISI_PTT_RESET_POLL_INTERVAL_US,
+ HISI_PTT_RESET_TIMEOUT_US);
}
static void hisi_ptt_trace_end(struct hisi_ptt *hisi_ptt)
@@ -202,14 +202,18 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
return -EBUSY;
}
- ctrl->started = true;
-
/* Reset the DMA before start tracing */
val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
val |= HISI_PTT_TRACE_CTRL_RST;
writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
- hisi_ptt_wait_dma_reset_done(hisi_ptt);
+ if (!hisi_ptt_wait_dma_reset_done(hisi_ptt)) {
+ pci_err(hisi_ptt->pdev, "timed out waiting for DMA reset\n");
+ val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
+ val &= ~HISI_PTT_TRACE_CTRL_RST;
+ writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
+ return -ETIMEDOUT;
+ }
val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
val &= ~HISI_PTT_TRACE_CTRL_RST;
@@ -234,6 +238,8 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
if (!hisi_ptt->trace_ctrl.is_port)
val |= HISI_PTT_TRACE_CTRL_FILTER_MODE;
+ ctrl->started = true;
+
/* Start the Trace */
val |= HISI_PTT_TRACE_CTRL_EN;
writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] hwtracing: hisi_ptt: Remove unnecessary trace buffer zeroing in trace_start()
2026-04-14 17:25 [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start Pradhan, Sanman
2026-04-14 17:25 ` [PATCH v2 1/2] hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start() Pradhan, Sanman
@ 2026-04-14 17:25 ` Pradhan, Sanman
2026-04-17 12:45 ` [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start Jonathan Cameron
2 siblings, 0 replies; 5+ messages in thread
From: Pradhan, Sanman @ 2026-04-14 17:25 UTC (permalink / raw)
To: yangyicong@hisilicon.com, jonathan.cameron@huawei.com
Cc: alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, yangyccccc@gmail.com, Sanman Pradhan
From: Sanman Pradhan <psanman@juniper.net>
hisi_ptt_trace_start() clears all four trace buffers before enabling
tracing.
This is unnecessary. On trace stop, hisi_ptt_update_aux() copies only
the number of bytes reported in HISI_PTT_TRACE_WR_STS. On buffer-full
interrupts, it copies a full completed buffer. In both cases the driver
only consumes data written by hardware.
Remove the buffer clearing from the trace start path.
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
Reviewed-by: Yicong Yang <yangyccccc@gmail.com>
---
v2:
- No changes
drivers/hwtracing/ptt/hisi_ptt.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
index b5d851281fbf0..a8f6986c8e1f7 100644
--- a/drivers/hwtracing/ptt/hisi_ptt.c
+++ b/drivers/hwtracing/ptt/hisi_ptt.c
@@ -194,7 +194,6 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
{
struct hisi_ptt_trace_ctrl *ctrl = &hisi_ptt->trace_ctrl;
u32 val;
- int i;
/* Check device idle before start trace */
if (!hisi_ptt_wait_trace_hw_idle(hisi_ptt)) {
@@ -222,10 +221,6 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
/* Reset the index of current buffer */
hisi_ptt->trace_ctrl.buf_index = 0;
- /* Zero the trace buffers */
- for (i = 0; i < HISI_PTT_TRACE_BUF_CNT; i++)
- memset(ctrl->trace_buf[i].addr, 0, HISI_PTT_TRACE_BUF_SIZE);
-
/* Clear the interrupt status */
writel(HISI_PTT_TRACE_INT_STAT_MASK, hisi_ptt->iobase + HISI_PTT_TRACE_INT_STAT);
writel(0, hisi_ptt->iobase + HISI_PTT_TRACE_INT_MASK);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start()
2026-04-14 17:25 ` [PATCH v2 1/2] hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start() Pradhan, Sanman
@ 2026-04-16 17:25 ` Yicong Yang
0 siblings, 0 replies; 5+ messages in thread
From: Yicong Yang @ 2026-04-16 17:25 UTC (permalink / raw)
To: Pradhan, Sanman, jonathan.cameron@huawei.com
Cc: yangyccccc, alexander.shishkin@linux.intel.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Sanman Pradhan, Suzuki K Poulose, Jie Zhan, liusizhe5
+cc Suzuki and Sizhe..
On 2026/4/15 01:25, Pradhan, Sanman wrote:
> From: Sanman Pradhan <psanman@juniper.net>
>
> hisi_ptt_wait_dma_reset_done() discards the return value of
> readl_poll_timeout_atomic(). If the DMA engine does not complete its
> reset within the timeout, hisi_ptt_trace_start() proceeds to start
> tracing regardless.
>
> Return a bool from hisi_ptt_wait_dma_reset_done(), consistent with the
> other wait helpers in this driver. On timeout, log an error, de-assert
> the reset bit, and return -ETIMEDOUT. Move ctrl->started to the
> successful path so a failed start does not leave the trace marked as
> active.
>
> Fixes: ff0de066b463 ("hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sanman Pradhan <psanman@juniper.net>
looks good to me.
Reviewed-by: Yicong Yang <yangyccccc@gmail.com>
I see the Suzuki has sent out the PR for 7.1, so this may wait after the merge window...
thanks.
> ---
> v2:
> - Return bool for consistency with other wait helpers
> - Add pci_err() on timeout
> - De-assert RST before returning on timeout
> - Move ctrl->started to the successful path
>
> drivers/hwtracing/ptt/hisi_ptt.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
> index 94c371c491357..b5d851281fbf0 100644
> --- a/drivers/hwtracing/ptt/hisi_ptt.c
> +++ b/drivers/hwtracing/ptt/hisi_ptt.c
> @@ -171,13 +171,13 @@ static bool hisi_ptt_wait_trace_hw_idle(struct hisi_ptt *hisi_ptt)
> HISI_PTT_WAIT_TRACE_TIMEOUT_US);
> }
>
> -static void hisi_ptt_wait_dma_reset_done(struct hisi_ptt *hisi_ptt)
> +static bool hisi_ptt_wait_dma_reset_done(struct hisi_ptt *hisi_ptt)
> {
> u32 val;
>
> - readl_poll_timeout_atomic(hisi_ptt->iobase + HISI_PTT_TRACE_WR_STS,
> - val, !val, HISI_PTT_RESET_POLL_INTERVAL_US,
> - HISI_PTT_RESET_TIMEOUT_US);
> + return !readl_poll_timeout_atomic(hisi_ptt->iobase + HISI_PTT_TRACE_WR_STS,
> + val, !val, HISI_PTT_RESET_POLL_INTERVAL_US,
> + HISI_PTT_RESET_TIMEOUT_US);
> }
>
> static void hisi_ptt_trace_end(struct hisi_ptt *hisi_ptt)
> @@ -202,14 +202,18 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
> return -EBUSY;
> }
>
> - ctrl->started = true;
> -
> /* Reset the DMA before start tracing */
> val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
> val |= HISI_PTT_TRACE_CTRL_RST;
> writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
>
> - hisi_ptt_wait_dma_reset_done(hisi_ptt);
> + if (!hisi_ptt_wait_dma_reset_done(hisi_ptt)) {
> + pci_err(hisi_ptt->pdev, "timed out waiting for DMA reset\n");
> + val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
> + val &= ~HISI_PTT_TRACE_CTRL_RST;
> + writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
> + return -ETIMEDOUT;
> + }
>
> val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
> val &= ~HISI_PTT_TRACE_CTRL_RST;
> @@ -234,6 +238,8 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
> if (!hisi_ptt->trace_ctrl.is_port)
> val |= HISI_PTT_TRACE_CTRL_FILTER_MODE;
>
> + ctrl->started = true;
> +
> /* Start the Trace */
> val |= HISI_PTT_TRACE_CTRL_EN;
> writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start
2026-04-14 17:25 [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start Pradhan, Sanman
2026-04-14 17:25 ` [PATCH v2 1/2] hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start() Pradhan, Sanman
2026-04-14 17:25 ` [PATCH v2 2/2] hwtracing: hisi_ptt: Remove unnecessary trace buffer zeroing " Pradhan, Sanman
@ 2026-04-17 12:45 ` Jonathan Cameron
2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-04-17 12:45 UTC (permalink / raw)
To: Pradhan, Sanman
Cc: yangyicong@hisilicon.com, alexander.shishkin@linux.intel.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
yangyccccc@gmail.com, Sanman Pradhan, Sizhe Liu
On Tue, 14 Apr 2026 17:25:03 +0000
"Pradhan, Sanman" <sanman.pradhan@hpe.com> wrote:
> From: Sanman Pradhan <psanman@juniper.net>
+CC Sizhe Liu
>
> Patch 1: Propagate the DMA reset timeout error from
> hisi_ptt_wait_dma_reset_done() instead of discarding it. De-assert
> the reset bit and log an error on timeout. Move ctrl->started to the
> successful path so a failed start does not leave the trace marked as
> active.
>
> Patch 2: Remove the unnecessary 16 MiB memset of trace buffers in
> hisi_ptt_trace_start(). The driver only copies data that hardware has
> written, so the zeroing is not needed.
>
> Changes since v1:
> - Patch 1: Return bool from hisi_ptt_wait_dma_reset_done() for
> consistency with the other wait helpers
> - Patch 1: Add pci_err() on timeout
> - Patch 1: De-assert RST before returning on timeout
> - Patch 1: Move ctrl->started to the successful path
> - Dropped "Use the passed buffer index in hisi_ptt_update_aux()" patch
> - Patch 2 is unchanged
>
> Sanman Pradhan (2):
> hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start()
> hwtracing: hisi_ptt: Remove unnecessary trace buffer zeroing in
> trace_start()
>
> drivers/hwtracing/ptt/hisi_ptt.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-17 12:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 17:25 [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start Pradhan, Sanman
2026-04-14 17:25 ` [PATCH v2 1/2] hwtracing: hisi_ptt: Propagate DMA reset timeout in trace_start() Pradhan, Sanman
2026-04-16 17:25 ` Yicong Yang
2026-04-14 17:25 ` [PATCH v2 2/2] hwtracing: hisi_ptt: Remove unnecessary trace buffer zeroing " Pradhan, Sanman
2026-04-17 12:45 ` [PATCH v2 0/2] hwtracing: hisi_ptt: Fix reset timeout handling and clean up trace start Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox