From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: iommu@lists.linux-foundation.org,
Bjorn Helgaas <bhelgaas@google.com>,
Robin Murphy <robin.murphy@arm.com>,
Tomasz Nowicki <tn@semihalf.com>, Joerg Roedel <joro@8bytes.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Will Deacon <will.deacon@arm.com>,
Marc Zyngier <marc.zyngier@arm.com>,
Hanjun Guo <hanjun.guo@linaro.org>, Jon Masters <jcm@redhat.com>,
Sinan Kaya <okaya@codeaurora.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH 09/11] drivers: acpi: implement acpi_dma_configure
Date: Fri, 22 Apr 2016 11:57:52 +0100 [thread overview]
Message-ID: <20160422105752.GA23100@red-moon> (raw)
In-Reply-To: <CAHp75VesfEDSnyjKunPzyJ1qUrdi8qE8Q2sOYpwo7h39ePjdow@mail.gmail.com>
Hi Andy,
On Fri, Apr 22, 2016 at 01:45:38AM +0300, Andy Shevchenko wrote:
> On Thu, Apr 14, 2016 at 8:25 PM, Lorenzo Pieralisi
> <lorenzo.pieralisi@arm.com> wrote:
> > On DT based systems, the of_dma_configure() API implements DMA configuration
> > for a given device. On ACPI systems an API equivalent to of_dma_configure()
> > is missing which implies that it is currently not possible to set-up DMA
> > operations for devices through the ACPI generic kernel layer.
> >
> > This patch fills the gap by introducing acpi_dma_configure/deconfigure()
> > calls, that carry out IOMMU configuration through IORT (on systems where
> > it is present) and call arch_setup_dma_ops(...) with the retrieved
> > parameters.
> >
> > The DMA range size passed to arch_setup_dma_ops() is sized according
> > to the device coherent_dma_mask (starting at address 0x0), mirroring the
> > DT probing path behaviour when a dma-ranges property is not provided
> > for the device being probed; this changes the current arch_setup_dma_ops()
> > call parameters in the ACPI probing case, but since arch_setup_dma_ops()
> > is a NOP on all architectures but ARM/ARM64 this patch does not change
> > the current kernel behaviour on them.
> >
> > This patch updates ACPI and PCI core code to use the newly introduced
> > acpi_dma_configure function, providing the same functionality
> > as of_dma_configure on ARM systems and leaving behaviour unchanged
> > for all other arches.
> >
>
> Nitpicks below.
Thanks for having a look.
> > --- a/drivers/acpi/iort.c
> > +++ b/drivers/acpi/iort.c
> > @@ -72,6 +72,31 @@ int iort_iommu_set_node(struct iommu_ops *ops, struct acpi_iort_node *node,
> > return 0;
> > }
> >
> > +/**
> > + * iort_iommu_get_node - Retrieve iort_iommu_node associated with an IORT node.
> > + *
> > + * @node: IORT table node to be looked-up
> > + *
> > + * Returns: iort_iommu_node pointer on success
> > + * NULL on failure
> > + */
> > +static struct iort_iommu_node *iort_iommu_get_node(struct acpi_iort_node *node)
> > +{
> > + struct iort_iommu_node *iommu_node;
> > +
> > + spin_lock(&iort_iommu_lock);
> > + list_for_each_entry(iommu_node, &iort_iommu_list, list) {
> > + if (iommu_node->node == node)
> > + goto found;
> > + }
> > +
> > + iommu_node = NULL;
> > +found:
> > + spin_unlock(&iort_iommu_lock);
> > +
> > + return iommu_node;
>
> Ouch, and why not to
>
> strut iommu_node = NULL;
>
> lock
> list for each() {
> if ()
> break;
> }
> unlock
>
> return iommu_node;
To make sure iommu_node is NULL if no node is found, but this list handling
function needs updating anyway (both locking and list handling), so I will
rework it and take your suggestion into account, I agree it is not that
readable (or safe to begin with).
> ?
>
> > +}
>
>
> > +/**
> > + * iort_iommu_configure - Set-up IOMMU configuration for a device.
> > + *
> > + * @dev: device that requires IOMMU set-up
> > + *
> > + * Returns: iommu_ops pointer on configuration success
> > + * NULL on configuration failure
> > + */
> > +struct iommu_ops *iort_iommu_configure(struct device *dev)
> > +{
> > + struct acpi_iort_node *node, *parent;
> > + struct iommu_ops *ops = NULL;
> > + struct iommu_fwspec fwspec;
> > + struct iort_iommu_node *iommu_node;
> > + u32 rid = 0, devid = 0;
> > +
> > + if (dev_is_pci(dev)) {
> > + struct pci_bus *bus = to_pci_dev(dev)->bus;
> > +
> > + pci_for_each_dma_alias(to_pci_dev(dev), __get_pci_rid,
> > + &rid);
> > +
> > + node = iort_scan_node(ACPI_IORT_NODE_PCI_ROOT_COMPLEX,
> > + iort_find_dev_callback, &bus->dev);
>
> > + } else
>
> checkpatch.pl ?
checkpatch.pl --strict does not even barf at it. I will add the braces
and go check why checkpatch.pl is quiet :)
> > + node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT,
> > + iort_find_dev_callback, dev);
> > +
> > + if (!node)
> > + return NULL;
> > +
> > + iort_dev_map_rid(node, rid, &devid, ACPI_IORT_NODE_SMMU);
> > +
> > + parent = iort_find_parent_node(node, ACPI_IORT_NODE_SMMU);
>
> > +
>
> Redundant.
Ok.
Thanks,
Lorenzo
>
> > + if (!parent)
> > + return NULL;
> > +
> > + iommu_node = iort_iommu_get_node(parent);
> > + ops = iommu_node->ops;
> > +
> > + fwspec.fwnode = iommu_node->fwnode;
> > + fwspec.param_count = 1;
> > + fwspec.param[0] = devid;
> > +
> > + if (!ops || !ops->fw_xlate || ops->fw_xlate(dev, &fwspec))
> > + return NULL;
> > +
> > + return ops;
> > +}
> > +
>
> --
> With Best Regards,
> Andy Shevchenko
>
WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 09/11] drivers: acpi: implement acpi_dma_configure
Date: Fri, 22 Apr 2016 11:57:52 +0100 [thread overview]
Message-ID: <20160422105752.GA23100@red-moon> (raw)
In-Reply-To: <CAHp75VesfEDSnyjKunPzyJ1qUrdi8qE8Q2sOYpwo7h39ePjdow@mail.gmail.com>
Hi Andy,
On Fri, Apr 22, 2016 at 01:45:38AM +0300, Andy Shevchenko wrote:
> On Thu, Apr 14, 2016 at 8:25 PM, Lorenzo Pieralisi
> <lorenzo.pieralisi@arm.com> wrote:
> > On DT based systems, the of_dma_configure() API implements DMA configuration
> > for a given device. On ACPI systems an API equivalent to of_dma_configure()
> > is missing which implies that it is currently not possible to set-up DMA
> > operations for devices through the ACPI generic kernel layer.
> >
> > This patch fills the gap by introducing acpi_dma_configure/deconfigure()
> > calls, that carry out IOMMU configuration through IORT (on systems where
> > it is present) and call arch_setup_dma_ops(...) with the retrieved
> > parameters.
> >
> > The DMA range size passed to arch_setup_dma_ops() is sized according
> > to the device coherent_dma_mask (starting at address 0x0), mirroring the
> > DT probing path behaviour when a dma-ranges property is not provided
> > for the device being probed; this changes the current arch_setup_dma_ops()
> > call parameters in the ACPI probing case, but since arch_setup_dma_ops()
> > is a NOP on all architectures but ARM/ARM64 this patch does not change
> > the current kernel behaviour on them.
> >
> > This patch updates ACPI and PCI core code to use the newly introduced
> > acpi_dma_configure function, providing the same functionality
> > as of_dma_configure on ARM systems and leaving behaviour unchanged
> > for all other arches.
> >
>
> Nitpicks below.
Thanks for having a look.
> > --- a/drivers/acpi/iort.c
> > +++ b/drivers/acpi/iort.c
> > @@ -72,6 +72,31 @@ int iort_iommu_set_node(struct iommu_ops *ops, struct acpi_iort_node *node,
> > return 0;
> > }
> >
> > +/**
> > + * iort_iommu_get_node - Retrieve iort_iommu_node associated with an IORT node.
> > + *
> > + * @node: IORT table node to be looked-up
> > + *
> > + * Returns: iort_iommu_node pointer on success
> > + * NULL on failure
> > + */
> > +static struct iort_iommu_node *iort_iommu_get_node(struct acpi_iort_node *node)
> > +{
> > + struct iort_iommu_node *iommu_node;
> > +
> > + spin_lock(&iort_iommu_lock);
> > + list_for_each_entry(iommu_node, &iort_iommu_list, list) {
> > + if (iommu_node->node == node)
> > + goto found;
> > + }
> > +
> > + iommu_node = NULL;
> > +found:
> > + spin_unlock(&iort_iommu_lock);
> > +
> > + return iommu_node;
>
> Ouch, and why not to
>
> strut iommu_node = NULL;
>
> lock
> list for each() {
> if ()
> break;
> }
> unlock
>
> return iommu_node;
To make sure iommu_node is NULL if no node is found, but this list handling
function needs updating anyway (both locking and list handling), so I will
rework it and take your suggestion into account, I agree it is not that
readable (or safe to begin with).
> ?
>
> > +}
>
>
> > +/**
> > + * iort_iommu_configure - Set-up IOMMU configuration for a device.
> > + *
> > + * @dev: device that requires IOMMU set-up
> > + *
> > + * Returns: iommu_ops pointer on configuration success
> > + * NULL on configuration failure
> > + */
> > +struct iommu_ops *iort_iommu_configure(struct device *dev)
> > +{
> > + struct acpi_iort_node *node, *parent;
> > + struct iommu_ops *ops = NULL;
> > + struct iommu_fwspec fwspec;
> > + struct iort_iommu_node *iommu_node;
> > + u32 rid = 0, devid = 0;
> > +
> > + if (dev_is_pci(dev)) {
> > + struct pci_bus *bus = to_pci_dev(dev)->bus;
> > +
> > + pci_for_each_dma_alias(to_pci_dev(dev), __get_pci_rid,
> > + &rid);
> > +
> > + node = iort_scan_node(ACPI_IORT_NODE_PCI_ROOT_COMPLEX,
> > + iort_find_dev_callback, &bus->dev);
>
> > + } else
>
> checkpatch.pl ?
checkpatch.pl --strict does not even barf at it. I will add the braces
and go check why checkpatch.pl is quiet :)
> > + node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT,
> > + iort_find_dev_callback, dev);
> > +
> > + if (!node)
> > + return NULL;
> > +
> > + iort_dev_map_rid(node, rid, &devid, ACPI_IORT_NODE_SMMU);
> > +
> > + parent = iort_find_parent_node(node, ACPI_IORT_NODE_SMMU);
>
> > +
>
> Redundant.
Ok.
Thanks,
Lorenzo
>
> > + if (!parent)
> > + return NULL;
> > +
> > + iommu_node = iort_iommu_get_node(parent);
> > + ops = iommu_node->ops;
> > +
> > + fwspec.fwnode = iommu_node->fwnode;
> > + fwspec.param_count = 1;
> > + fwspec.param[0] = devid;
> > +
> > + if (!ops || !ops->fw_xlate || ops->fw_xlate(dev, &fwspec))
> > + return NULL;
> > +
> > + return ops;
> > +}
> > +
>
> --
> With Best Regards,
> Andy Shevchenko
>
next prev parent reply other threads:[~2016-04-22 10:57 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 17:25 [RFC PATCH 00/11] ACPI IORT ARM SMMU support Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
[not found] ` <1460654743-7896-1-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2016-04-14 17:25 ` [RFC PATCH 01/11] drivers: acpi: iort: fix struct pci_dev compiler warnings Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` [RFC PATCH 02/11] drivers: acpi: iort: add support for IOMMU registration Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` [RFC PATCH 03/11] drivers: iommu: add FWNODE_IOMMU fwnode type Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` [RFC PATCH 04/11] drivers: acpi: iort: introduce linker section for IORT entries probing Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` [RFC PATCH 05/11] drivers: iommu: arm-smmu: split probe functions into DT/generic portions Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` [RFC PATCH 06/11] drivers: iommu: make of_xlate() interface DT agnostic Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
[not found] ` <1460654743-7896-7-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2016-04-19 8:28 ` Marek Szyprowski
2016-04-19 8:28 ` Marek Szyprowski
2016-04-19 8:28 ` Marek Szyprowski
2016-04-19 11:30 ` Lorenzo Pieralisi
2016-04-19 11:30 ` Lorenzo Pieralisi
2016-04-20 7:14 ` Marek Szyprowski
2016-04-20 7:14 ` Marek Szyprowski
2016-04-20 7:14 ` Marek Szyprowski
2016-04-14 17:25 ` [RFC PATCH 07/11] drivers: iommu: arm-smmu: allow ACPI based streamid translation Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` [RFC PATCH 08/11] drivers: acpi: iort: enhance mapping API Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` [RFC PATCH 09/11] drivers: acpi: implement acpi_dma_configure Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-15 16:14 ` Bjorn Helgaas
2016-04-15 16:14 ` Bjorn Helgaas
2016-04-15 16:31 ` Robin Murphy
2016-04-15 16:31 ` Robin Murphy
2016-04-15 16:31 ` Robin Murphy
2016-04-15 18:29 ` Timur Tabi
2016-04-15 18:29 ` Timur Tabi
2016-04-18 10:30 ` Lorenzo Pieralisi
2016-04-18 10:30 ` Lorenzo Pieralisi
2016-04-18 10:43 ` Robin Murphy
2016-04-18 10:43 ` Robin Murphy
2016-05-16 15:15 ` Tomasz Nowicki
2016-05-16 15:15 ` Tomasz Nowicki
[not found] ` <5739E416.6000501-nYOzD4b6Jr9Wk0Htik3J/w@public.gmane.org>
2016-05-16 15:26 ` Tomasz Nowicki
2016-05-16 15:26 ` Tomasz Nowicki
2016-05-16 15:26 ` Tomasz Nowicki
2016-04-21 22:45 ` Andy Shevchenko
2016-04-21 22:45 ` Andy Shevchenko
2016-04-22 10:57 ` Lorenzo Pieralisi [this message]
2016-04-22 10:57 ` Lorenzo Pieralisi
[not found] ` <1460654743-7896-10-git-send-email-lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
2016-05-17 8:07 ` Tomasz Nowicki
2016-05-17 8:07 ` Tomasz Nowicki
2016-05-17 8:07 ` Tomasz Nowicki
2016-05-17 8:07 ` Tomasz Nowicki
2016-05-17 12:32 ` Tomasz Nowicki
2016-05-17 12:32 ` Tomasz Nowicki
2016-05-17 12:32 ` Tomasz Nowicki
2016-04-14 17:25 ` [RFC PATCH 10/11] drivers: iommu: arm-smmu: implement ACPI probing Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` [RFC PATCH 11/11] drivers: irqchip: make struct irq_fwspec generic Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
2016-04-14 17:25 ` Lorenzo Pieralisi
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=20160422105752.GA23100@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=andy.shevchenko@gmail.com \
--cc=bhelgaas@google.com \
--cc=hanjun.guo@linaro.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jcm@redhat.com \
--cc=joro@8bytes.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=okaya@codeaurora.org \
--cc=rjw@rjwysocki.net \
--cc=robin.murphy@arm.com \
--cc=tn@semihalf.com \
--cc=will.deacon@arm.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.