Message ID | 20250225171239.19574-3-manivannan.sadhasivam@linaro.org (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Krzysztof Wilczyński |
Headers | show |
Series | PCI: dwc-debugfs: Couple of fixes | expand |
Hello, > If the platform doesn't support an event counter, enabling it using the > 'counter_enable' debugfs attribute currently will succeed. But reading the > debugfs attribute back will return 'Counter Disabled'. > > This could cause confusion to the users. So while enabling an event > counter in counter_enable_write(), always read back the status to check if > the counter is enabled or not. If not, return -EOPNOTSUPP to let the users > know that the event counter is not supported. Thank you for following up on this. Appreciated. With that... Reviewed-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Thank you! Krzysztof
diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c index 9ff4d45e80f1..1f1bd9888327 100644 --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c @@ -352,6 +352,21 @@ static ssize_t counter_enable_write(struct file *file, const char __user *buf, val |= FIELD_PREP(EVENT_COUNTER_ENABLE, PER_EVENT_OFF); dw_pcie_writel_dbi(pci, rinfo->ras_cap_offset + RAS_DES_EVENT_COUNTER_CTRL_REG, val); + + /* + * While enabling the counter, always read back the status to check if + * it is enabled or not. Return error if it is not enabled to let the + * users know that the counter is not supported on the platform. + */ + if (enable) { + val = dw_pcie_readl_dbi(pci, rinfo->ras_cap_offset + + RAS_DES_EVENT_COUNTER_CTRL_REG); + if (!FIELD_GET(EVENT_COUNTER_STATUS, val)) { + mutex_unlock(&rinfo->reg_event_lock); + return -EOPNOTSUPP; + } + } + mutex_unlock(&rinfo->reg_event_lock); return count;
If the platform doesn't support an event counter, enabling it using the 'counter_enable' debugfs attribute currently will succeed. But reading the debugfs attribute back will return 'Counter Disabled'. This could cause confusion to the users. So while enabling an event counter in counter_enable_write(), always read back the status to check if the counter is enabled or not. If not, return -EOPNOTSUPP to let the users know that the event counter is not supported. Fixes: 9f99c304c467 ("PCI: dwc: Add debugfs based Statistical Counter support for DWC") Suggested-by: Niklas Cassel <cassel@kernel.org> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> --- .../pci/controller/dwc/pcie-designware-debugfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)