From: Frank Li <Frank.li@oss.nxp.com>
To: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
Cc: "Manivannan Sadhasivam" <mani@kernel.org>,
"Jeff Hugo" <jeff.hugo@oss.qualcomm.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Frank Li" <Frank.Li@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Niklas Cassel" <cassel@kernel.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>,
"Abel Vesa" <abelvesa@kernel.org>,
mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org,
linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
linux-phy@lists.infradead.org,
"Anvita T" <anvita.t@oss.qualcomm.com>
Subject: Re: [PATCH 03/11] PCI: epf-mhi: Add MSI-X support
Date: Mon, 23 Nov 2026 10:48:07 -0600 [thread overview]
Message-ID: <awRuR7FXqXMeAVxQ@SMW015318> (raw)
In-Reply-To: <20261122-nord_ep-v1-3-6d8839ffa9aa@oss.qualcomm.com>
On Sun, Nov 22, 2026 at 08:26:16AM +0530, Krishna Chaitanya Chundru wrote:
>
> Allow the MHI endpoint function to signal interrupts using MSI-X when the
> endpoint controller supports it. On controllers whose epc_features
> advertise msix_capable, set up a dedicated MSI-X BAR (BAR_0) from a
> "msix" memory region supplied by the platform and program the MSI-X
> configuration.
>
> The "msix" resource is optional and only looked up during bind; it is
> required only when the controller reports MSI-X capability. At interrupt
> time, select PCI_IRQ_MSIX over PCI_IRQ_MSI based on whether MSI-X has
> been enabled by the host.
>
> Fetch epc_features earlier in epc_init() so the MSI-X capability can be
> checked before setting up the BARs.
>
> Signed-off-by: Anvita T <anvita.t@oss.qualcomm.com>
> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> ---
> drivers/pci/endpoint/functions/pci-epf-mhi.c | 54 +++++++++++++++++++++++++---
> 1 file changed, 49 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> index 52cfffcfd5ca..a8765beffe06 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> @@ -148,6 +148,7 @@ struct pci_epf_mhi {
> struct mutex lock;
> void __iomem *mmio;
> resource_size_t mmio_phys;
> + resource_size_t msix_phys;
> struct dma_chan *dma_chan_tx;
> struct dma_chan *dma_chan_rx;
> struct workqueue_struct *dma_wq;
> @@ -155,6 +156,7 @@ struct pci_epf_mhi {
> struct list_head dma_list;
> spinlock_t list_lock;
> u32 mmio_size;
> + u32 msix_size;
> int irq;
> };
>
> @@ -230,12 +232,16 @@ static void pci_epf_mhi_raise_irq(struct mhi_ep_cntrl *mhi_cntrl, u32 vector)
> struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
> struct pci_epf *epf = epf_mhi->epf;
> struct pci_epc *epc = epf->epc;
> + unsigned int type = PCI_IRQ_MSI;
> +
> + if (pci_epc_get_msix(epc, epf->func_no, epf->vfunc_no) > 0)
> + type = PCI_IRQ_MSIX;
>
> /*
> * MHI supplies 0 based MSI vectors but the API expects the vector
> * number to start from 1, so we need to increment the vector by 1.
> */
> - pci_epc_raise_irq(epc, epf->func_no, epf->vfunc_no, PCI_IRQ_MSI,
> + pci_epc_raise_irq(epc, epf->func_no, epf->vfunc_no, type,
> vector + 1);
> }
>
> @@ -714,11 +720,40 @@ static int pci_epf_mhi_epc_init(struct pci_epf *epf)
> {
> struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
> const struct pci_epf_mhi_ep_info *info = epf_mhi->info;
> + struct pci_epf_bar *msix_bar = &epf->bar[BAR_0];
> struct pci_epf_bar *epf_bar = &epf->bar[info->bar_num];
> struct pci_epc *epc = epf->epc;
> struct device *dev = &epf->dev;
> int ret;
>
> + epf_mhi->epc_features = pci_epc_get_features(epc, epf->func_no, epf->vfunc_no);
> + if (!epf_mhi->epc_features)
> + return -ENODATA;
> +
> + if (epf_mhi->epc_features->msix_capable) {
> + if (!epf_mhi->msix_phys) {
> + dev_err(dev, "MSI-X BAR address not configured in DT\n");
> + return -EINVAL;
> + }
> +
> + msix_bar->phys_addr = epf_mhi->msix_phys;
> + msix_bar->size = epf_mhi->msix_size;
> + msix_bar->barno = BAR_0;
> + msix_bar->flags = info->epf_flags;
> + ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, msix_bar);
> + if (ret) {
> + dev_err(dev, "Failed to set MSI-X BAR: %d\n", ret);
> + return ret;
> + }
> +
> + ret = pci_epc_set_msix(epc, epf->func_no, epf->vfunc_no,
> + info->msi_count, BAR_0, 0);
> + if (ret) {
> + dev_err(dev, "Failed to set MSI-X configuration: %d\n", ret);
> + return ret;
> + }
> + }
> +
> epf_bar->phys_addr = epf_mhi->mmio_phys;
> epf_bar->size = epf_mhi->mmio_size;
> epf_bar->barno = info->bar_num;
> @@ -743,10 +778,6 @@ static int pci_epf_mhi_epc_init(struct pci_epf *epf)
> return ret;
> }
>
> - epf_mhi->epc_features = pci_epc_get_features(epc, epf->func_no, epf->vfunc_no);
> - if (!epf_mhi->epc_features)
> - return -ENODATA;
> -
> if (info->flags & MHI_EPF_USE_DMA) {
> ret = pci_epf_mhi_dma_init(epf_mhi);
> if (ret) {
> @@ -763,6 +794,7 @@ static void pci_epf_mhi_epc_deinit(struct pci_epf *epf)
> struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
> const struct pci_epf_mhi_ep_info *info = epf_mhi->info;
> struct pci_epf_bar *epf_bar = &epf->bar[info->bar_num];
> + struct pci_epf_bar *msix_bar = &epf->bar[BAR_0];
> struct mhi_ep_cntrl *mhi_cntrl = &epf_mhi->mhi_cntrl;
> struct pci_epc *epc = epf->epc;
>
> @@ -773,6 +805,8 @@ static void pci_epf_mhi_epc_deinit(struct pci_epf *epf)
> mhi_ep_unregister_controller(mhi_cntrl);
> }
>
> + if (epf_mhi->epc_features && epf_mhi->epc_features->msix_capable)
> + pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no, msix_bar);
> pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no, epf_bar);
> }
>
> @@ -880,6 +914,13 @@ static int pci_epf_mhi_bind(struct pci_epf *epf)
> if (!epf_mhi->mmio)
> return -ENOMEM;
>
> + /* MSI-X BAR address is optional; only present on EPCs that support MSI-X */
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "msix");
> + if (res) {
> + epf_mhi->msix_phys = res->start;
> + epf_mhi->msix_size = resource_size(res);
> + }
> +
You'd better use pci_epc_aux_resource() to get such data, instead of direct
access epc's parent device.
Frank
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-11-23 16:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 2:56 [PATCH 00/11] PCI: qcom-ep: Add Nord PCIe Endpoint controller support Krishna Chaitanya Chundru
2026-11-22 2:56 ` [PATCH 01/11] PCI: epf-mhi: Pass the actual number of MSI vectors to pci_epc_set_msi() Krishna Chaitanya Chundru
2026-11-22 3:03 ` sashiko-bot
2026-11-23 10:03 ` Niklas Cassel
2026-11-22 2:56 ` [PATCH 02/11] PCI: qcom-ep: Add MSI-X support Krishna Chaitanya Chundru
2026-11-22 3:08 ` sashiko-bot
2026-11-23 16:41 ` Frank Li
2026-11-22 2:56 ` [PATCH 03/11] PCI: epf-mhi: " Krishna Chaitanya Chundru
2026-11-22 3:15 ` sashiko-bot
2026-11-23 16:48 ` Frank Li [this message]
2026-11-22 2:56 ` [PATCH 04/11] PCI: dwc: Preserve glue-provided eDMA HDMA channel separation Krishna Chaitanya Chundru
2026-11-23 16:49 ` Frank Li
2026-11-22 2:56 ` [PATCH 05/11] phy: qcom: qmp-pcie: Add PCIe endpoint mode support Krishna Chaitanya Chundru
2026-11-23 16:56 ` Frank Li
2026-11-22 2:56 ` [PATCH 06/11] phy: qcom: qmp-pcie: Add Nord endpoint mode init sequences Krishna Chaitanya Chundru
2026-11-23 16:57 ` Frank Li
2026-11-22 2:56 ` [PATCH 07/11] dt-bindings: PCI: qcom-ep: Add Nord PCIe Endpoint Krishna Chaitanya Chundru
2026-11-22 2:56 ` [PATCH 08/11] PCI: qcom-ep: Add Nord PCIe Endpoint controller support Krishna Chaitanya Chundru
2026-11-22 3:08 ` sashiko-bot
2026-11-22 2:56 ` [PATCH 09/11] PCI: epf-mhi: Add Nord endpoint support Krishna Chaitanya Chundru
2026-11-22 2:56 ` [PATCH 10/11] bus: mhi: host: pci_generic: Add support for Qualcomm Nord Krishna Chaitanya Chundru
2026-11-22 3:19 ` sashiko-bot
2026-11-22 2:56 ` [PATCH 11/11] arm64: dts: qcom: nord: Add PCIe endpoint nodes Krishna Chaitanya Chundru
2026-11-22 3:17 ` sashiko-bot
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=awRuR7FXqXMeAVxQ@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=anvita.t@oss.qualcomm.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=jingoohan1@gmail.com \
--cc=kishon@kernel.org \
--cc=konradybcio@kernel.org \
--cc=krishna.chundru@oss.qualcomm.com \
--cc=krzk+dt@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=mhi@lists.linux.dev \
--cc=neil.armstrong@linaro.org \
--cc=robh@kernel.org \
--cc=vkoul@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox