Re: [PATCH ath-next v3 4/8] wifi: ath12k: add device DP stats reset support via debugfs
Jeff Johnson <[email protected]>
| Newsgroups | org.infradead.lists.ath12k,org.kernel.vger.linux-wireless |
|---|---|
| Message-ID | <[email protected]> |
On 8/10/2026 7:44 AM, Pardeep Kaur wrote: > From: Hariharan Ramanathan <[email protected]> > > There is no way to reset device DP stats counters without reloading > the driver, making it difficult to isolate issues to a specific time > window during debugging. > > Add a write handler to the device_dp_stats debugfs file so that > writing 'reset' clears all device DP stats counters. Change the file > mode from 0400 to 0600 to allow write access. Use > simple_write_to_buffer() to correctly handle partial writes and > non-zero ppos, consistent with ath12k_write_simulate_fw_crash() in > the same file. Return -EINVAL on unrecognised input. > > No lock is taken around the memset since the counters are updated > locklessly in the datapath; taking dp_lock would be misleading as it > does not protect device_stats updates. > > Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6.r1-00402-QCAHKSWPL_SILICONZ-1 > > Signed-off-by: Hariharan Ramanathan <[email protected]> > Co-developed-by: Pardeep Kaur <[email protected]> > Signed-off-by: Pardeep Kaur <[email protected]> > --- > drivers/net/wireless/ath/ath12k/debugfs.c | 36 ++++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/ath/ath12k/debugfs.c b/drivers/net/wireless/ath/ath12k/debugfs.c > index ec49692107a8..cbda754d8656 100644 > --- a/drivers/net/wireless/ath/ath12k/debugfs.c > +++ b/drivers/net/wireless/ath/ath12k/debugfs.c > @@ -1220,8 +1220,42 @@ static ssize_t ath12k_debugfs_dump_device_dp_stats(struct file *file, > return ret; > } > > +static ssize_t > +ath12k_debugfs_write_device_dp_stats(struct file *file, > + const char __user *user_buf, > + size_t count, loff_t *ppos) > +{ > + struct ath12k_base *ab = file->private_data; > + struct ath12k_dp *dp = ath12k_ab_to_dp(ab); > + struct ath12k_device_dp_stats *device_stats = &dp->device_stats; > + char buf[20] = {}; > + int ret; > + > + /* filter partial writes and invalid commands */ > + if (*ppos != 0 || count >= sizeof(buf) || count == 0) > + return -EINVAL; > + > + ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); > + if (ret < 0) > + return ret; > + > + /* drop the possible '\n' from the end */ > + if (buf[*ppos - 1] == '\n') > + buf[*ppos - 1] = '\0'; > + > + if (!strcmp(buf, "reset")) { > + memset(device_stats, 0, sizeof(*device_stats)); > + return count; > + } > + > + ath12k_warn(ab, "unsupported command: %s\n", buf); drop this. ath12k_warn() is used to warn about inconsistent state, not user input. The -EINVAL return is already the correct user-facing mechanism for returning status. Note all the other .write() functions silently return -EINVAL on an invalid argument. > + > + return -EINVAL; > +} > + > static const struct file_operations fops_device_dp_stats = { > .read = ath12k_debugfs_dump_device_dp_stats, > + .write = ath12k_debugfs_write_device_dp_stats, > .open = simple_open, > .owner = THIS_MODULE, > .llseek = default_llseek, > @@ -1232,7 +1266,7 @@ void ath12k_debugfs_pdev_create(struct ath12k_base *ab) > debugfs_create_file("simulate_fw_crash", 0600, ab->debugfs_soc, ab, > &fops_simulate_fw_crash); > > - debugfs_create_file("device_dp_stats", 0400, ab->debugfs_soc, ab, > + debugfs_create_file("device_dp_stats", 0600, ab->debugfs_soc, ab, > &fops_device_dp_stats); > } >