From: Bjorn Helgaas <helgaas@kernel.org> To: Wang Xingang <wangxingang5@huawei.com> Cc: will@kernel.org, joro@8bytes.org, bhelgaas@google.com, gregkh@linuxfoundation.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, xieyingtai@huawei.com Subject: Re: [PATCH 1/1] iommu/of: Fix request and enable ACS for of_iommu_configure Date: Fri, 7 May 2021 16:14:54 -0500 [thread overview] Message-ID: <20210507211454.GA1518899@bjorn-Precision-5520> (raw) In-Reply-To: <1620391793-18744-2-git-send-email-wangxingang5@huawei.com> On Fri, May 07, 2021 at 12:49:53PM +0000, Wang Xingang wrote: > From: Xingang Wang <wangxingang5@huawei.com> > > When request ACS for PCI device in of_iommu_configure, the pci device > has already been scanned and added with 'pci_acs_enable=0'. So the > pci_request_acs() in current procedure does not work for enabling ACS. > Besides, the ACS should be enabled only if there's an IOMMU in system. > So this fix the call of pci_request_acs() and call pci_enable_acs() to > make sure ACS is enabled for the pci_device. For consistency: s/of_iommu_configure/of_iommu_configure()/ s/pci device/PCI device/ s/pci_device/PCI device/ But I'm confused about what problem this fixes. On x86, I think we *do* set pci_acs_enable=1 in this path: start_kernel mm_init mem_init pci_iommu_alloc p->detect() detect_intel_iommu # IOMMU_INIT_POST(detect_intel_iommu) pci_request_acs pci_acs_enable = 1 before enumerating any PCI devices. But you mentioned pci_host_common_probe(), which I think is mostly used on non-x86 architectures, and I'm guessing those arches detect the IOMMU differently. So my question is, can we figure out how to detect IOMMUs the same way across all arches? > Fixes: 6bf6c24720d33 ("iommu/of: Request ACS from the PCI core when > configuring IOMMU linkage") > Signed-off-by: Xingang Wang <wangxingang5@huawei.com> > --- > drivers/iommu/of_iommu.c | 10 +++++++++- > drivers/pci/pci.c | 2 +- > include/linux/pci.h | 1 + > 3 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index a9d2df001149..dc621861ae72 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -205,7 +205,6 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, > .np = master_np, > }; > > - pci_request_acs(); > err = pci_for_each_dma_alias(to_pci_dev(dev), > of_pci_iommu_init, &info); > } else { > @@ -222,6 +221,15 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, > /* The fwspec pointer changed, read it again */ > fwspec = dev_iommu_fwspec_get(dev); > ops = fwspec->ops; > + > + /* > + * If we found an IOMMU and the device is pci, > + * make sure we enable ACS. s/pci/PCI/ for consistency. > + */ > + if (dev_is_pci(dev)) { > + pci_request_acs(); > + pci_enable_acs(to_pci_dev(dev)); > + } > } > /* > * If we have reason to believe the IOMMU driver missed the initial > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index b717680377a9..4e4f98ee2870 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -926,7 +926,7 @@ static void pci_std_enable_acs(struct pci_dev *dev) > * pci_enable_acs - enable ACS if hardware support it > * @dev: the PCI device > */ > -static void pci_enable_acs(struct pci_dev *dev) > +void pci_enable_acs(struct pci_dev *dev) > { > if (!pci_acs_enable) > goto disable_acs_redir; > diff --git a/include/linux/pci.h b/include/linux/pci.h > index c20211e59a57..e6a8bfbc9c98 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -2223,6 +2223,7 @@ static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev) > } > > void pci_request_acs(void); > +void pci_enable_acs(struct pci_dev *dev); > bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); > bool pci_acs_path_enabled(struct pci_dev *start, > struct pci_dev *end, u16 acs_flags); > -- > 2.19.1 >
WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <helgaas@kernel.org> To: Wang Xingang <wangxingang5@huawei.com> Cc: xieyingtai@huawei.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, bhelgaas@google.com, will@kernel.org Subject: Re: [PATCH 1/1] iommu/of: Fix request and enable ACS for of_iommu_configure Date: Fri, 7 May 2021 16:14:54 -0500 [thread overview] Message-ID: <20210507211454.GA1518899@bjorn-Precision-5520> (raw) In-Reply-To: <1620391793-18744-2-git-send-email-wangxingang5@huawei.com> On Fri, May 07, 2021 at 12:49:53PM +0000, Wang Xingang wrote: > From: Xingang Wang <wangxingang5@huawei.com> > > When request ACS for PCI device in of_iommu_configure, the pci device > has already been scanned and added with 'pci_acs_enable=0'. So the > pci_request_acs() in current procedure does not work for enabling ACS. > Besides, the ACS should be enabled only if there's an IOMMU in system. > So this fix the call of pci_request_acs() and call pci_enable_acs() to > make sure ACS is enabled for the pci_device. For consistency: s/of_iommu_configure/of_iommu_configure()/ s/pci device/PCI device/ s/pci_device/PCI device/ But I'm confused about what problem this fixes. On x86, I think we *do* set pci_acs_enable=1 in this path: start_kernel mm_init mem_init pci_iommu_alloc p->detect() detect_intel_iommu # IOMMU_INIT_POST(detect_intel_iommu) pci_request_acs pci_acs_enable = 1 before enumerating any PCI devices. But you mentioned pci_host_common_probe(), which I think is mostly used on non-x86 architectures, and I'm guessing those arches detect the IOMMU differently. So my question is, can we figure out how to detect IOMMUs the same way across all arches? > Fixes: 6bf6c24720d33 ("iommu/of: Request ACS from the PCI core when > configuring IOMMU linkage") > Signed-off-by: Xingang Wang <wangxingang5@huawei.com> > --- > drivers/iommu/of_iommu.c | 10 +++++++++- > drivers/pci/pci.c | 2 +- > include/linux/pci.h | 1 + > 3 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index a9d2df001149..dc621861ae72 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -205,7 +205,6 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, > .np = master_np, > }; > > - pci_request_acs(); > err = pci_for_each_dma_alias(to_pci_dev(dev), > of_pci_iommu_init, &info); > } else { > @@ -222,6 +221,15 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, > /* The fwspec pointer changed, read it again */ > fwspec = dev_iommu_fwspec_get(dev); > ops = fwspec->ops; > + > + /* > + * If we found an IOMMU and the device is pci, > + * make sure we enable ACS. s/pci/PCI/ for consistency. > + */ > + if (dev_is_pci(dev)) { > + pci_request_acs(); > + pci_enable_acs(to_pci_dev(dev)); > + } > } > /* > * If we have reason to believe the IOMMU driver missed the initial > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index b717680377a9..4e4f98ee2870 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -926,7 +926,7 @@ static void pci_std_enable_acs(struct pci_dev *dev) > * pci_enable_acs - enable ACS if hardware support it > * @dev: the PCI device > */ > -static void pci_enable_acs(struct pci_dev *dev) > +void pci_enable_acs(struct pci_dev *dev) > { > if (!pci_acs_enable) > goto disable_acs_redir; > diff --git a/include/linux/pci.h b/include/linux/pci.h > index c20211e59a57..e6a8bfbc9c98 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -2223,6 +2223,7 @@ static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev) > } > > void pci_request_acs(void); > +void pci_enable_acs(struct pci_dev *dev); > bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); > bool pci_acs_path_enabled(struct pci_dev *start, > struct pci_dev *end, u16 acs_flags); > -- > 2.19.1 > _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2021-05-07 21:14 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-07 12:49 [PATCH 0/1] iommu/of: Fix request and enable ACS for of_iommu_configure Wang Xingang 2021-05-07 12:49 ` Wang Xingang 2021-05-07 12:49 ` [PATCH 1/1] " Wang Xingang 2021-05-07 12:49 ` Wang Xingang 2021-05-07 21:14 ` Bjorn Helgaas [this message] 2021-05-07 21:14 ` Bjorn Helgaas 2021-05-08 1:32 ` Xingang Wang 2021-05-08 1:32 ` Xingang Wang
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=20210507211454.GA1518899@bjorn-Precision-5520 \ --to=helgaas@kernel.org \ --cc=bhelgaas@google.com \ --cc=gregkh@linuxfoundation.org \ --cc=iommu@lists.linux-foundation.org \ --cc=joro@8bytes.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pci@vger.kernel.org \ --cc=wangxingang5@huawei.com \ --cc=will@kernel.org \ --cc=xieyingtai@huawei.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: linkBe 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.