From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Shuai Xue <xueshuai@linux.alibaba.com>
Cc: Robin Murphy <robin.murphy@arm.com>, <helgaas@kernel.org>,
<yangyicong@huawei.com>, <will@kernel.org>,
<baolin.wang@linux.alibaba.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-pci@vger.kernel.org>,
<rdunlap@infradead.org>, <mark.rutland@arm.com>,
<zhuo.song@linux.alibaba.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v3 2/3] drivers/perf: add DesignWare PCIe PMU driver
Date: Tue, 16 May 2023 16:03:04 +0100 [thread overview]
Message-ID: <20230516160304.00000544@Huawei.com> (raw)
In-Reply-To: <7aec4dbd-91d5-2a14-8779-f239a58cbbae@linux.alibaba.com>
PCI folks, Question below directed at you. Please take a look.
+CC linux-cxl because a similar question is going to bite us shortly
if we want CXL PMUs to work well on RP or Switch ports.
> >> +static int dwc_pcie_ras_des_discover(struct dwc_pcie_pmu_priv *priv)
> >> +{
> >> + int index = 0;
> >> + struct pci_dev *pdev = NULL;
> >> + struct dwc_pcie_rp_info *rp_info;
> >> +
> >> + INIT_LIST_HEAD(&priv->rp_infos);
> >> +
> >> + /* Match the rootport with VSEC_RAS_DES_ID */
> >> + for_each_pci_dev(pdev) {
> >
> > Does the PCI layer not offer a more robust mechanism for this? (PCI fixups come to mind, but I don't actually know whether that would be a viable approach or not.)
>
> I am afraid not yet. Jonathan try to add a PMU service but it is not merged into mainline.
I wouldn't read much into that 'failure'. We never persisted with that driver because it was for an old
generation of hardware. Mostly the aim with that was to explore the area of PCIe PMU in general
rather than to get the support upstream. Some of the counters on that hardware were too small to
be of much use anyway :)
Grabbing just relevant functions..
Bjorn, we need to figure out a way forwards for this sort of case and I'd
appreciate your input on the broad brush question of 'how should it be done'?
This is a case where a PCIe port (RP here) correctly has the PCIe class code
so binds to the pcie_port driver, but has a VSEC (others examples use DOE, or DVSEC)
that provides extended functionality. The referred to PCIe PMU from our older Hisilicon
platforms did it by adding another service driver - that probably doesn't extend well.
The approach used here is to separately walk the PCI topology and register the devices.
It can 'maybe' get away with that because no interrupts and I assume resets have no
nasty impacts on it because the device is fairly simple. In general that's not going
to work. CXL does a similar trick (which I don't much like, but too late now),
but we've also run into the problem of how to get interrupts if not the main driver.
So what approach should we look at to solve this in general?
Jonathan
> +static int dwc_pcie_ras_des_discover(struct dwc_pcie_pmu_priv *priv)
> +{
> + int index = 0;
> + struct pci_dev *pdev = NULL;
> + struct dwc_pcie_rp_info *rp_info;
> +
> + INIT_LIST_HEAD(&priv->rp_infos);
> +
> + /* Match the rootport with VSEC_RAS_DES_ID */
> + for_each_pci_dev(pdev) {
> + u16 vsec;
> + u32 val;
> +
> + if (!pci_dev_is_rootport(pdev))
> + continue;
> +
> + rp_info = devm_kzalloc(&pdev->dev, sizeof(*rp_info), GFP_KERNEL);
> + if (!rp_info)
> + return -ENOMEM;
> +
> + rp_info->bdf = PCI_DEVID(pdev->bus->number, pdev->devfn);
> + rp_info->pdev = pdev;
> +
> + vsec = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_ALIBABA,
> + DWC_PCIE_VSEC_RAS_DES_ID);
> + if (!vsec)
> + continue;
> +
> + pci_read_config_dword(pdev, vsec + PCI_VNDR_HEADER, &val);
> + if (PCI_VNDR_HEADER_REV(val) != 0x04 ||
> + PCI_VNDR_HEADER_LEN(val) != 0x100)
> + continue;
> + pci_dbg(pdev,
> + "Detected PCIe Vendor-Specific Extended Capability RAS DES\n");
> +
> + rp_info->ras_des = vsec;
> + rp_info->num_lanes = pcie_get_width_cap(pdev);
> +
> + list_add(&rp_info->rp_node, &priv->rp_infos);
> + index++;
> + }
> +
> + if (!index)
> + return -ENODEV;
> +
> + priv->pcie_ctrl_num = index;
> +
> + return 0;
> +}
> +static int dwc_pcie_pmu_probe(struct platform_device *pdev)
> +{
> + int ret;
> + struct dwc_pcie_pmu_priv *priv;
> + struct dwc_pcie_rp_info *rp_info;
> +
> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->dev = &pdev->dev;
> + platform_set_drvdata(pdev, priv);
> +
> + /* If RAS_DES PMU is not supported on current platform, keep silent */
> + ret = dwc_pcie_ras_des_discover(priv);
> + if (ret)
> + return ret;
> +
> + list_for_each_entry(rp_info, &priv->rp_infos, rp_node) {
> + struct pci_dev *rp = rp_info->pdev;
> +
> + ret = __dwc_pcie_pmu_probe(priv, rp_info);
> + if (ret) {
> + dev_err(&rp->dev, "PCIe PMU probe fail\n");
> + goto pmu_unregister;
> + }
> + }
> +
> + return 0;
> +
> +pmu_unregister:
> + dwc_pcie_pmu_remove(pdev);
> +
> + return ret;
> +}
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Shuai Xue <xueshuai@linux.alibaba.com>
Cc: Robin Murphy <robin.murphy@arm.com>, <helgaas@kernel.org>,
<yangyicong@huawei.com>, <will@kernel.org>,
<baolin.wang@linux.alibaba.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-pci@vger.kernel.org>,
<rdunlap@infradead.org>, <mark.rutland@arm.com>,
<zhuo.song@linux.alibaba.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v3 2/3] drivers/perf: add DesignWare PCIe PMU driver
Date: Tue, 16 May 2023 16:03:04 +0100 [thread overview]
Message-ID: <20230516160304.00000544@Huawei.com> (raw)
In-Reply-To: <7aec4dbd-91d5-2a14-8779-f239a58cbbae@linux.alibaba.com>
PCI folks, Question below directed at you. Please take a look.
+CC linux-cxl because a similar question is going to bite us shortly
if we want CXL PMUs to work well on RP or Switch ports.
> >> +static int dwc_pcie_ras_des_discover(struct dwc_pcie_pmu_priv *priv)
> >> +{
> >> + int index = 0;
> >> + struct pci_dev *pdev = NULL;
> >> + struct dwc_pcie_rp_info *rp_info;
> >> +
> >> + INIT_LIST_HEAD(&priv->rp_infos);
> >> +
> >> + /* Match the rootport with VSEC_RAS_DES_ID */
> >> + for_each_pci_dev(pdev) {
> >
> > Does the PCI layer not offer a more robust mechanism for this? (PCI fixups come to mind, but I don't actually know whether that would be a viable approach or not.)
>
> I am afraid not yet. Jonathan try to add a PMU service but it is not merged into mainline.
I wouldn't read much into that 'failure'. We never persisted with that driver because it was for an old
generation of hardware. Mostly the aim with that was to explore the area of PCIe PMU in general
rather than to get the support upstream. Some of the counters on that hardware were too small to
be of much use anyway :)
Grabbing just relevant functions..
Bjorn, we need to figure out a way forwards for this sort of case and I'd
appreciate your input on the broad brush question of 'how should it be done'?
This is a case where a PCIe port (RP here) correctly has the PCIe class code
so binds to the pcie_port driver, but has a VSEC (others examples use DOE, or DVSEC)
that provides extended functionality. The referred to PCIe PMU from our older Hisilicon
platforms did it by adding another service driver - that probably doesn't extend well.
The approach used here is to separately walk the PCI topology and register the devices.
It can 'maybe' get away with that because no interrupts and I assume resets have no
nasty impacts on it because the device is fairly simple. In general that's not going
to work. CXL does a similar trick (which I don't much like, but too late now),
but we've also run into the problem of how to get interrupts if not the main driver.
So what approach should we look at to solve this in general?
Jonathan
> +static int dwc_pcie_ras_des_discover(struct dwc_pcie_pmu_priv *priv)
> +{
> + int index = 0;
> + struct pci_dev *pdev = NULL;
> + struct dwc_pcie_rp_info *rp_info;
> +
> + INIT_LIST_HEAD(&priv->rp_infos);
> +
> + /* Match the rootport with VSEC_RAS_DES_ID */
> + for_each_pci_dev(pdev) {
> + u16 vsec;
> + u32 val;
> +
> + if (!pci_dev_is_rootport(pdev))
> + continue;
> +
> + rp_info = devm_kzalloc(&pdev->dev, sizeof(*rp_info), GFP_KERNEL);
> + if (!rp_info)
> + return -ENOMEM;
> +
> + rp_info->bdf = PCI_DEVID(pdev->bus->number, pdev->devfn);
> + rp_info->pdev = pdev;
> +
> + vsec = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_ALIBABA,
> + DWC_PCIE_VSEC_RAS_DES_ID);
> + if (!vsec)
> + continue;
> +
> + pci_read_config_dword(pdev, vsec + PCI_VNDR_HEADER, &val);
> + if (PCI_VNDR_HEADER_REV(val) != 0x04 ||
> + PCI_VNDR_HEADER_LEN(val) != 0x100)
> + continue;
> + pci_dbg(pdev,
> + "Detected PCIe Vendor-Specific Extended Capability RAS DES\n");
> +
> + rp_info->ras_des = vsec;
> + rp_info->num_lanes = pcie_get_width_cap(pdev);
> +
> + list_add(&rp_info->rp_node, &priv->rp_infos);
> + index++;
> + }
> +
> + if (!index)
> + return -ENODEV;
> +
> + priv->pcie_ctrl_num = index;
> +
> + return 0;
> +}
> +static int dwc_pcie_pmu_probe(struct platform_device *pdev)
> +{
> + int ret;
> + struct dwc_pcie_pmu_priv *priv;
> + struct dwc_pcie_rp_info *rp_info;
> +
> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->dev = &pdev->dev;
> + platform_set_drvdata(pdev, priv);
> +
> + /* If RAS_DES PMU is not supported on current platform, keep silent */
> + ret = dwc_pcie_ras_des_discover(priv);
> + if (ret)
> + return ret;
> +
> + list_for_each_entry(rp_info, &priv->rp_infos, rp_node) {
> + struct pci_dev *rp = rp_info->pdev;
> +
> + ret = __dwc_pcie_pmu_probe(priv, rp_info);
> + if (ret) {
> + dev_err(&rp->dev, "PCIe PMU probe fail\n");
> + goto pmu_unregister;
> + }
> + }
> +
> + return 0;
> +
> +pmu_unregister:
> + dwc_pcie_pmu_remove(pdev);
> +
> + return ret;
> +}
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-05-16 15:03 UTC|newest]
Thread overview: 158+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-17 12:10 [PATCH v1 0/3] drivers/perf: add Synopsys DesignWare PCIe PMU driver support Shuai Xue
2022-09-17 12:10 ` Shuai Xue
2022-09-17 12:10 ` [PATCH v1 1/3] docs: perf: Add description for Synopsys DesignWare PCIe PMU driver Shuai Xue
2022-09-17 12:10 ` Shuai Xue
2022-09-22 13:25 ` Will Deacon
2022-09-22 13:25 ` Will Deacon
2022-09-23 13:51 ` Shuai Xue
2022-09-23 13:51 ` Shuai Xue
2022-11-07 15:28 ` Will Deacon
2022-11-07 15:28 ` Will Deacon
2022-09-23 1:27 ` Yicong Yang
2022-09-23 1:27 ` Yicong Yang
2022-09-23 14:47 ` Shuai Xue
2022-09-23 14:47 ` Shuai Xue
2022-09-17 12:10 ` [PATCH v1 2/3] drivers/perf: add " Shuai Xue
2022-09-17 12:10 ` Shuai Xue
2022-09-22 15:58 ` Jonathan Cameron
2022-09-22 15:58 ` Jonathan Cameron
2022-09-22 17:32 ` Bjorn Helgaas
2022-09-22 17:32 ` Bjorn Helgaas
2022-09-23 3:35 ` Yicong Yang
2022-09-23 3:35 ` Yicong Yang
2022-09-23 10:56 ` Jonathan Cameron
2022-09-23 10:56 ` Jonathan Cameron
2022-09-23 13:45 ` Shuai Xue
2022-09-23 13:45 ` Shuai Xue
2022-09-23 15:54 ` Jonathan Cameron
2022-09-23 15:54 ` Jonathan Cameron
2022-09-26 13:31 ` Shuai Xue
2022-09-26 13:31 ` Shuai Xue
2022-09-26 14:32 ` Robin Murphy
2022-09-26 14:32 ` Robin Murphy
2022-09-26 17:18 ` Bjorn Helgaas
2022-09-26 17:18 ` Bjorn Helgaas
2022-09-27 5:13 ` Shuai Xue
2022-09-27 5:13 ` Shuai Xue
2022-09-27 10:04 ` Jonathan Cameron
2022-09-27 10:04 ` Jonathan Cameron
2022-09-27 10:14 ` Robin Murphy
2022-09-27 10:14 ` Robin Murphy
2022-09-27 12:49 ` Shuai Xue
2022-09-27 12:49 ` Shuai Xue
2022-09-27 13:39 ` Jonathan Cameron
2022-09-27 13:39 ` Jonathan Cameron
2022-09-27 12:29 ` Shuai Xue
2022-09-27 12:29 ` Shuai Xue
2022-09-27 10:03 ` Jonathan Cameron
2022-09-27 10:03 ` Jonathan Cameron
2022-09-22 17:36 ` Bjorn Helgaas
2022-09-22 17:36 ` Bjorn Helgaas
2022-09-23 14:46 ` Shuai Xue
2022-09-23 14:46 ` Shuai Xue
2022-09-23 18:51 ` Bjorn Helgaas
2022-09-23 18:51 ` Bjorn Helgaas
2022-09-27 6:01 ` Shuai Xue
2022-09-27 6:01 ` Shuai Xue
2022-09-23 3:30 ` Yicong Yang
2022-09-23 3:30 ` Yicong Yang
2022-09-23 15:43 ` Shuai Xue
2022-09-23 15:43 ` Shuai Xue
2022-09-24 8:00 ` Yicong Yang
2022-09-24 8:00 ` Yicong Yang
2022-09-26 11:39 ` Shuai Xue
2022-09-26 11:39 ` Shuai Xue
2022-09-17 12:10 ` [PATCH v1 3/3] MAINTAINERS: add maintainers for " Shuai Xue
2022-09-17 12:10 ` Shuai Xue
2023-04-10 3:16 ` [PATCH v2 0/3] drivers/perf: add Synopsys DesignWare PCIe PMU driver support Shuai Xue
2023-04-10 3:16 ` Shuai Xue
2023-04-10 3:17 ` [PATCH v2 1/3] docs: perf: Add description for Synopsys DesignWare PCIe PMU driver Shuai Xue
2023-04-10 3:17 ` Shuai Xue
2023-04-10 3:17 ` [PATCH v2 2/3] drivers/perf: add " Shuai Xue
2023-04-10 3:17 ` Shuai Xue
2023-04-10 7:25 ` kernel test robot
2023-04-10 7:25 ` kernel test robot
2023-04-11 3:17 ` Baolin Wang
2023-04-11 3:17 ` Baolin Wang
2023-04-17 1:16 ` Shuai Xue
2023-04-17 1:16 ` Shuai Xue
2023-04-18 1:51 ` Baolin Wang
2023-04-18 1:51 ` Baolin Wang
2023-04-19 1:39 ` Shuai Xue
2023-04-19 1:39 ` Shuai Xue
2023-04-10 3:17 ` [PATCH v2 3/3] MAINTAINERS: add maintainers for " Shuai Xue
2023-04-10 3:17 ` Shuai Xue
2023-04-17 6:17 ` [PATCH v3 0/3] drivers/perf: add Synopsys DesignWare PCIe PMU driver support Shuai Xue
2023-04-17 6:17 ` Shuai Xue
2023-04-17 6:17 ` [PATCH v3 1/3] docs: perf: Add description for Synopsys DesignWare PCIe PMU driver Shuai Xue
2023-04-17 6:17 ` Shuai Xue
2023-05-16 14:32 ` Jonathan Cameron
2023-05-16 14:32 ` Jonathan Cameron
2023-05-17 1:27 ` Shuai Xue
2023-05-17 1:27 ` Shuai Xue
2023-04-17 6:17 ` [PATCH v3 2/3] drivers/perf: add " Shuai Xue
2023-04-17 6:17 ` Shuai Xue
2023-04-18 23:30 ` Robin Murphy
2023-04-18 23:30 ` Robin Murphy
2023-04-27 6:33 ` Shuai Xue
2023-04-27 6:33 ` Shuai Xue
2023-05-09 2:02 ` Shuai Xue
2023-05-16 15:03 ` Jonathan Cameron [this message]
2023-05-16 15:03 ` Jonathan Cameron
2023-05-16 19:17 ` Bjorn Helgaas
2023-05-16 19:17 ` Bjorn Helgaas
2023-05-17 9:54 ` Jonathan Cameron
2023-05-17 9:54 ` Jonathan Cameron
2023-05-17 16:27 ` Bjorn Helgaas
2023-05-17 16:27 ` Bjorn Helgaas
2023-05-19 10:08 ` Shuai Xue
2023-05-19 10:08 ` Shuai Xue
2023-04-17 6:17 ` [PATCH v3 3/3] MAINTAINERS: add maintainers for " Shuai Xue
2023-04-17 6:17 ` Shuai Xue
2023-05-16 13:01 ` [PATCH v4 0/4] drivers/perf: add Synopsys DesignWare PCIe PMU driver support Shuai Xue
2023-05-16 13:01 ` Shuai Xue
2023-05-16 13:01 ` [PATCH v4 1/4] docs: perf: Add description for Synopsys DesignWare PCIe PMU driver Shuai Xue
2023-05-16 13:01 ` Shuai Xue
2023-05-16 13:01 ` [PATCH v4 2/4] PCI: move Alibaba Vendor ID linux/pci_ids.h Shuai Xue
2023-05-16 13:01 ` Shuai Xue
2023-05-16 13:01 ` [PATCH v4 3/4] drivers/perf: add DesignWare PCIe PMU driver Shuai Xue
2023-05-16 13:01 ` Shuai Xue
2023-05-16 19:19 ` Bjorn Helgaas
2023-05-16 19:19 ` Bjorn Helgaas
2023-05-17 2:35 ` Shuai Xue
2023-05-17 2:35 ` Shuai Xue
2023-05-16 23:21 ` kernel test robot
2023-05-17 3:37 ` Shuai Xue
2023-05-17 3:37 ` Shuai Xue
2023-05-16 13:01 ` [PATCH v4 4/4] MAINTAINERS: add maintainers for " Shuai Xue
2023-05-16 13:01 ` Shuai Xue
2023-05-22 3:54 ` [PATCH v5 0/4] drivers/perf: add Synopsys DesignWare PCIe PMU driver support Shuai Xue
2023-05-22 3:54 ` Shuai Xue
2023-05-22 14:28 ` Jonathan Cameron
2023-05-22 14:28 ` Jonathan Cameron
2023-05-23 2:57 ` Shuai Xue
2023-05-23 2:57 ` Shuai Xue
2023-05-22 3:54 ` [PATCH v5 1/4] docs: perf: Add description for Synopsys DesignWare PCIe PMU driver Shuai Xue
2023-05-22 3:54 ` Shuai Xue
2023-05-29 3:45 ` Baolin Wang
2023-05-29 3:45 ` Baolin Wang
2023-05-29 6:31 ` Shuai Xue
2023-05-29 6:31 ` Shuai Xue
2023-05-22 3:54 ` [PATCH v5 2/4] PCI: move Alibaba Vendor ID linux/pci_ids.h Shuai Xue
2023-05-22 3:54 ` Shuai Xue
2023-05-22 16:04 ` Bjorn Helgaas
2023-05-22 16:04 ` Bjorn Helgaas
2023-05-23 3:22 ` Shuai Xue
2023-05-23 3:22 ` Shuai Xue
2023-05-23 11:54 ` Bjorn Helgaas
2023-05-23 11:54 ` Bjorn Helgaas
2023-05-23 12:49 ` Shuai Xue
2023-05-23 12:49 ` Shuai Xue
2023-05-22 3:54 ` [PATCH v5 3/4] drivers/perf: add DesignWare PCIe PMU driver Shuai Xue
2023-05-22 3:54 ` Shuai Xue
2023-05-29 6:13 ` Baolin Wang
2023-05-29 6:13 ` Baolin Wang
2023-05-29 6:33 ` Shuai Xue
2023-05-29 6:33 ` Shuai Xue
2023-05-22 3:54 ` [PATCH v5 4/4] MAINTAINERS: add maintainers for " Shuai Xue
2023-05-22 3:54 ` Shuai Xue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230516160304.00000544@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=helgaas@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rdunlap@infradead.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=xueshuai@linux.alibaba.com \
--cc=yangyicong@huawei.com \
--cc=zhuo.song@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.