Skip to contentSkip to conversation

PCI: dwc: Add pci id for LECARC pcie pmu

PATCH Superseded Braden Zhang 4 participants 12 messages Jul 13 – Jul 21

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 PCI: dwc: Add pci id for LECARC pcie pmu

From: Brett Zhou <[email protected]>

This patch adds support for the PCIe PMU found
on LECARC SoCs, which utilize the DesignWare PCIe Controller IP

---
Changes in v3:
- Update: move definition to pcie-dwc.h a
- Format: Update the subject line to follow the style of previous pcie-dwc.h changes.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Format: repalce space with tab to separate the macro name and the value.
- Link to v1: https://patch.msgid.link/[email protected]

To: Bjorn Helgaas <[email protected]>
To: Jingoo Han <[email protected]>
To: Manivannan Sadhasivam <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 include/linux/pcie-dwc.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/pcie-dwc.h +4 -0
index 8ff778e7aec0..0df5fa81b561 100644
@@ -11,6 +11,8 @@
 
 #include <linux/pci_ids.h>
 
+#define PCI_VENDOR_ID_LECARC           0x0720
+
 struct dwc_pcie_vsec_id {
 	u16 vendor_id;
 	u16 vsec_id;
@@ -32,6 +34,8 @@ static const struct dwc_pcie_vsec_id dwc_pcie_rasdes_vsec_ids[] = {
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{ .vendor_id = PCI_VENDOR_ID_SAMSUNG,
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
+	{ .vendor_id = PCI_VENDOR_ID_LECARC,
+	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{}
 };
 

---
base-commit: a635d6748234582ea287c5ffeae28b9b23f91c7e
change-id: 20260710-pcie-pmu-5ef78c56c3b6

Best regards,

Signature · 1 line
Braden Zhang <[email protected]>
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

From: Brett Zhou <[email protected]>

This patch adds support for the PCIe PMU found
on LECARC SoCs, which utilize the DesignWare PCIe Controller IP

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Braden Zhang
Quoted 5 lines · Braden Zhang

From: Brett Zhou <[email protected]>

This patch adds support for the PCIe PMU found
on LECARC SoCs, which utilize the DesignWare PCIe Controller IP

LECARC looks like a ACPI based platform. I'm wondering how you are able to make use of this patch without adding the ACPI ID support to enumerate the DWC driver.

- Mani

Quoted 53 lines

---
Changes in v3:
- Update: move definition to pcie-dwc.h a
- Format: Update the subject line to follow the style of previous pcie-dwc.h changes.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Format: repalce space with tab to separate the macro name and the value.
- Link to v1: https://patch.msgid.link/[email protected]

To: Bjorn Helgaas <[email protected]>
To: Jingoo Han <[email protected]>
To: Manivannan Sadhasivam <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 include/linux/pcie-dwc.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/pcie-dwc.h +4 -1
index 8ff778e7aec0..0df5fa81b561 100644
@@ -11,6 +11,8 @@
 
 #include <linux/pci_ids.h>
 
+#define PCI_VENDOR_ID_LECARC           0x0720
+
 struct dwc_pcie_vsec_id {
 	u16 vendor_id;
 	u16 vsec_id;
@@ -32,6 +34,8 @@ static const struct dwc_pcie_vsec_id dwc_pcie_rasdes_vsec_ids[] = {
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{ .vendor_id = PCI_VENDOR_ID_SAMSUNG,
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
+	{ .vendor_id = PCI_VENDOR_ID_LECARC,
+	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{}
 };
 
 
---

base-commit: a635d6748234582ea287c5ffeae28b9b23f91c7e
change-id: 20260710-pcie-pmu-5ef78c56c3b6

Best regards,

Signature · 1 line
Braden Zhang <[email protected]>
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#3 lore raw
Quoted 26 lines · Manivannan Sadhasivam

Date: Mon, 13 Jul 2026 07:14:25 +0200
From: Manivannan Sadhasivam <[email protected]>
To: Braden Zhang <[email protected]>
Cc: Bjorn Helgaas <[email protected]>, Jingoo Han <[email protected]>,
[email protected], [email protected], Brett Zhou <[email protected]>, Bjorn Helgaas <[email protected]>
Subject: Re: [PATCH v3 v3] PCI: dwc: Add pci id for LECARC pcie pmu

Quoted 5 lines · Braden Zhang

From: Brett Zhou <[email protected]>

This patch adds support for the PCIe PMU found
on LECARC SoCs, which utilize the DesignWare PCIe Controller IP

LECARC looks like a ACPI based platform. I'm wondering how you are able to make use of this patch without adding the ACPI ID support to enumerate the DWC driver.

- Mani

Quoted 5 lines

---

Quoted 10 lines
Quoted 8 lines

---
base-commit: a635d6748234582ea287c5ffeae28b9b23f91c7e
change-id: 20260710-pcie-pmu-5ef78c56c3b6

Best regards,

Signature · 1 line
Braden Zhang <[email protected]>

Hi Mani,

Thanks for the review.

LECARC platforms use the standard DesignWare PCIe Controller, and the existing DWC driver already handles the enumeration and basic functionality through the generic PCIe core. This patch only adds the PCI vendor ID to the vendor-specific capability (VSEC) list, which enables the standard DWC RAS/DES feature detection.

We don't require a separate PMU driver or additional ACPI ID support because the PMU functionality is already covered by the generic DWC PMU framework. The existing driver infrastructure handles the PMU features transparently once the vendor ID is recognized in the VSEC table.

Please let us know if you have any other concerns.

Best regards,
Braden Zhang

#4 lore raw
Quoted 48 lines · Braden Zhang
Quoted 26 lines · Manivannan Sadhasivam

Date: Mon, 13 Jul 2026 07:14:25 +0200
From: Manivannan Sadhasivam <[email protected]>
To: Braden Zhang <[email protected]>
Cc: Bjorn Helgaas <[email protected]>, Jingoo Han <[email protected]>,
[email protected], [email protected], Brett Zhou <[email protected]>, Bjorn Helgaas <[email protected]>
Subject: Re: [PATCH v3 v3] PCI: dwc: Add pci id for LECARC pcie pmu

Quoted 5 lines · Braden Zhang

From: Brett Zhou <[email protected]>

This patch adds support for the PCIe PMU found
on LECARC SoCs, which utilize the DesignWare PCIe Controller IP

LECARC looks like a ACPI based platform. I'm wondering how you are able to make use of this patch without adding the ACPI ID support to enumerate the DWC driver.

- Mani

Quoted 5 lines

---

Quoted 10 lines
Quoted 8 lines

---
base-commit: a635d6748234582ea287c5ffeae28b9b23f91c7e
change-id: 20260710-pcie-pmu-5ef78c56c3b6

Best regards,

Signature · 1 line
Braden Zhang <[email protected]>

Hi Mani,

Thanks for the review.

LECARC platforms use the standard DesignWare PCIe Controller, and the existing DWC driver already handles the enumeration and basic functionality through the generic PCIe core.
This patch only adds the
PCI vendor ID to the vendor-specific capability (VSEC) list, which enables the standard DWC RAS/DES feature detection.

Quoted 6 lines

We don't require a separate PMU driver or additional ACPI ID support because the PMU functionality is already covered by the generic DWC PMU framework. The existing driver infrastructure handles the PMU features transparently once the vendor ID is recognized in the VSEC table.

Ah, makes sense now. It didn't occur to me that 'dwc_pcie_rasdes_vsec_ids' struct array is used by the PMU driver also.

Please incorporate comments from Bjorn and resend.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#5 lore raw
In reply to Braden Zhang
Quoted 7 lines · Braden Zhang

From: Brett Zhou <[email protected]>

This patch adds support for the PCIe PMU found
on LECARC SoCs, which utilize the DesignWare PCIe Controller IP

I gave you some comments but did not provide a "Reviewed-by" tag, so including one here is not valid, see:

https://lore.kernel.org/linux-pci/20260710172212.GA964796@bhelgaas/
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=v7.1#n539

Also relevant:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/maintainer-tip.rst?id=v7.1#n134

In this case, you could say something like:

Add support for the PCIe PMU found on LECARC SoCs, which use the DesignWare PCIe Controller IP.

Wrap it to fill 75 columns.

In the subject line:

s/pci/PCI/
s/id/ID/
s/pcie/PCIe/
s/pmu/PMU/

since these are all initialisms, not ordinary English words.

Quoted 51 lines

---
Changes in v3:
- Update: move definition to pcie-dwc.h a
- Format: Update the subject line to follow the style of previous pcie-dwc.h changes.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Format: repalce space with tab to separate the macro name and the value.
- Link to v1: https://patch.msgid.link/[email protected]

To: Bjorn Helgaas <[email protected]>
To: Jingoo Han <[email protected]>
To: Manivannan Sadhasivam <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 include/linux/pcie-dwc.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/pcie-dwc.h +4 -1
index 8ff778e7aec0..0df5fa81b561 100644
@@ -11,6 +11,8 @@
 
 #include <linux/pci_ids.h>
 
+#define PCI_VENDOR_ID_LECARC           0x0720
+
 struct dwc_pcie_vsec_id {
 	u16 vendor_id;
 	u16 vsec_id;
@@ -32,6 +34,8 @@ static const struct dwc_pcie_vsec_id dwc_pcie_rasdes_vsec_ids[] = {
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{ .vendor_id = PCI_VENDOR_ID_SAMSUNG,
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
+	{ .vendor_id = PCI_VENDOR_ID_LECARC,
+	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{}
 };
 
 
---

base-commit: a635d6748234582ea287c5ffeae28b9b23f91c7e
change-id: 20260710-pcie-pmu-5ef78c56c3b6

Best regards,

Signature · 1 line
Braden Zhang <[email protected]>
#6 lore raw
Quoted 2 lines

I gave you some comments but did not provide a "Reviewed-by" tag, so including one here is not valid, see:

Bjorn, thanks for the review !

Sorry for mis-used the "Reviewed-by" tag.
I'm still getting familiar with the b4 tool and the patch submission workflow.
I'll go through the documentation you referenced to make sure I get the process right going forward.

For the next version (v4), I will:

Drop the invalid Reviewed-by tag.

Reword the commit message as you suggested and wrap it to 75 columns.

Fix the capitalization in the subject line (s/pci/PCI/, etc.).

Will send out v4 shortly.

Thanks,
Braden Zhang

#7 lore raw

PATCH v4 1/1 PCI: dwc: Add PCI ID for LECARC PCIe pmu

From: Brett Zhou <[email protected]>

This patch adds support for the PCIe PMU found
on LECARC SoCs.

LECARC platforms use the standard DesignWare PCIe Controller, and the existing DWC driver already handles the enumeration and basic functionality through the generic PCIe core. This patch only adds the PCI vendor ID to the vendor-specific capability (VSEC) list, which enables the standard DWC RAS/DES feature detection.

---
Changes in v4:
- Doc: Update description for the DWC RAS/DES feature detection.
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- Update: move definition to pcie-dwc.h a
- Format: Update the subject line to follow the style of previous pcie-dwc.h changes.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Format: repalce space with tab to separate the macro name and the value.
- Link to v1: https://patch.msgid.link/[email protected]

To: Bjorn Helgaas <[email protected]>
To: Jingoo Han <[email protected]>
To: Manivannan Sadhasivam <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 include/linux/pcie-dwc.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/pcie-dwc.h +4 -0
index 8ff778e7aec0..0df5fa81b561 100644
@@ -11,6 +11,8 @@
 
 #include <linux/pci_ids.h>
 
+#define PCI_VENDOR_ID_LECARC           0x0720
+
 struct dwc_pcie_vsec_id {
 	u16 vendor_id;
 	u16 vsec_id;
@@ -32,6 +34,8 @@ static const struct dwc_pcie_vsec_id dwc_pcie_rasdes_vsec_ids[] = {
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{ .vendor_id = PCI_VENDOR_ID_SAMSUNG,
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
+	{ .vendor_id = PCI_VENDOR_ID_LECARC,
+	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{}
 };
 

---
base-commit: a635d6748234582ea287c5ffeae28b9b23f91c7e
change-id: 20260710-pcie-pmu-5ef78c56c3b6

Best regards,

Signature · 1 line
Braden Zhang <[email protected]>
#8 lore raw

Re: [PATCH v4 v4] PCI: dwc: Add PCI ID for LECARC PCIe pmu

Quoted 12 lines · Braden Zhang

From: Brett Zhou <[email protected]>

This patch adds support for the PCIe PMU found
on LECARC SoCs.

LECARC platforms use the standard DesignWare PCIe Controller, and the existing DWC driver already handles the enumeration and basic functionality through the generic PCIe core. This patch only adds the PCI vendor ID to the vendor-specific capability (VSEC) list, which enables the standard DWC RAS/DES feature detection.

Quoted 2 lines

I don't know what's wrong here, but this message id ([email protected]) is not found in lore. So can't apply with b4.

- Mani

Quoted 54 lines

---
Changes in v4:
- Doc: Update description for the DWC RAS/DES feature detection.
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- Update: move definition to pcie-dwc.h a
- Format: Update the subject line to follow the style of previous pcie-dwc.h changes.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Format: repalce space with tab to separate the macro name and the value.
- Link to v1: https://patch.msgid.link/[email protected]

To: Bjorn Helgaas <[email protected]>
To: Jingoo Han <[email protected]>
To: Manivannan Sadhasivam <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 include/linux/pcie-dwc.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/pcie-dwc.h +4 -1
index 8ff778e7aec0..0df5fa81b561 100644
@@ -11,6 +11,8 @@
 
 #include <linux/pci_ids.h>
 
+#define PCI_VENDOR_ID_LECARC           0x0720
+
 struct dwc_pcie_vsec_id {
 	u16 vendor_id;
 	u16 vsec_id;
@@ -32,6 +34,8 @@ static const struct dwc_pcie_vsec_id dwc_pcie_rasdes_vsec_ids[] = {
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{ .vendor_id = PCI_VENDOR_ID_SAMSUNG,
 	  .vsec_id = 0x02, .vsec_rev = 0x4 },
+	{ .vendor_id = PCI_VENDOR_ID_LECARC,
+	  .vsec_id = 0x02, .vsec_rev = 0x4 },
 	{}
 };
 
 
---

base-commit: a635d6748234582ea287c5ffeae28b9b23f91c7e
change-id: 20260710-pcie-pmu-5ef78c56c3b6

Best regards,

Signature · 1 line
Braden Zhang <[email protected]>
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#9 lore raw

Re: [PATCH v4 v4] PCI: dwc: Add PCI ID for LECARC PCIe pmu

Hi Mani,

Thank you for your review and for pointing out the issue.

You are correct. I realized the patch was missing a PGP signature, which is why it's not being properly recognized by the mailing list and b4.

I have now added the missing PGP signature and regenerated the patch as v5. The new version should be correctly picked up by the tooling.

Best regards,
Braden Zhang

#10 lore raw

Re: [PATCH v4 v4] PCI: dwc: Add PCI ID for LECARC PCIe pmu

In reply to Manivannan Sadhasivam

Hi Mani,

Thank you for your review and for pointing out the issue.

You are correct. I realized the patch was missing a PGP signature, which is why it's not being properly recognized by the mailing list and b4.

I have now added the missing PGP signature and regenerated the patch as v5. The new version should be correctly picked up by the tooling.

Best regards,
Braden Zhang

#11 lore raw

Re: [PATCH v4 v4] PCI: dwc: Add PCI ID for LECARC PCIe pmu

In reply to Braden Zhang
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Low] The commit message claims that spaces were replaced with a tab, but the patch actually uses spaces.

Pre-existing issues:
- [High] The dwc_pcie_pmu driver caches a pointer to the PCI device (pdev) in pcie_pmu->pdev but explicitly drops the reference count. If the PCI device is removed, this leads to a Use-After-Free when the PMU driver accesses pdev. --

--- Patch [1]: [PATCH v4 v4] PCI: dwc: Add PCI ID for LECARC PCIe pmu --- commit c7438edb93a79853b55beed10ead3c56dfcc3ff6
Author: Brett Zhou <[email protected]>

PCI: dwc: Add PCI ID for LECARC PCIe pmu

This patch adds support for the PCIe PMU found on LECARC SoCs by adding the PCI vendor ID to the vendor-specific capability list. This enables the standard DWC RAS/DES feature detection.

Link to v3: https://patch.msgid.link/[email protected]

Quoted 2 lines

Changes in v2:
- Format: repalce space with tab to separate the macro name and the value.

[Severity: Low]
This isn't a bug, but there is a typo (repalce) in the changelog text.

[ ... ]

include/linux/pcie-dwc.h line 14

Quoted 9 lines
include/linux/pcie-dwc.h +1 -0
index 8ff778e7aec0e..0df5fa81b5610 100644
@@ -11,6 +11,8 @@
 
 #include <linux/pci_ids.h>
 
+#define PCI_VENDOR_ID_LECARC           0x0720

[Severity: Low]
This isn't a bug, but the v2 changelog claims spaces were replaced with a tab, while this macro definition still uses 11 spaces.

[Severity: High]
This is a pre-existing issue, but enabling the LECARC vendor ID exposes these platforms to a flaw in drivers/perf/dwc_pcie_pmu.c.

Does dwc_pcie_pmu_probe() trigger a use-after-free if the device is removed?

drivers/perf/dwc_pcie_pmu.c:dwc_pcie_pmu_probe() {
    ...
    pci_dev_put(pdev);
    ...
    pcie_pmu->pdev = pdev;
    ...
}

The driver retrieves the PCI device and increments its reference count, but explicitly drops the reference with pci_dev_put() while retaining the pointer in pcie_pmu->pdev.

If the device is hot-removed, the PCI core drops its reference and frees the device structure. If a userspace process holds an open perf event and reads from it, wouldn't callbacks like dwc_pcie_pmu_read_lane_event_counter() dereference the freed pcie_pmu->pdev pointer?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1