RE: [EXT] Re: [RFC PATCH 1/4] bus: fsl-mc: add custom .dma_configure implementation
> -Original Message- > From: Lorenzo Pieralisi > Sent: Tuesday, April 14, 2020 8:02 PM > To: Laurentiu Tudor > Cc: linux-ker...@vger.kernel.org; iommu@lists.linux-foundation.org; linux-arm- > ker...@lists.infradead.org; linux-a...@vger.kernel.org; > robin.mur...@arm.com; ard.biesheu...@linaro.org; Ioana Ciornei > ; Diana Madalina Craciun (OSS) > ; m...@kernel.org; j...@solid-run.com; Pankaj > Bansal ; Makarand Pawagi > ; Calvin Johnson ; > Varun Sethi ; Cristi Sovaiala ; > stuart.yo...@arm.com; jeremy.lin...@arm.com; j...@8bytes.org; > t...@linutronix.de; ja...@lakedaemon.net > Subject: [EXT] Re: [RFC PATCH 1/4] bus: fsl-mc: add custom .dma_configure > implementation > > Caution: EXT Email > > On Wed, Mar 25, 2020 at 06:48:55PM +0200, Laurentiu Tudor wrote: > > Hi Lorenzo, > > > > On 3/25/2020 2:51 PM, Lorenzo Pieralisi wrote: > > > On Thu, Feb 27, 2020 at 12:05:39PM +0200, laurentiu.tu...@nxp.com wrote: > > >> From: Laurentiu Tudor > > >> > > >> The devices on this bus are not discovered by way of device tree > > >> but by queries to the firmware. It makes little sense to trick the > > >> generic of layer into thinking that these devices are of related so > > >> that we can get our dma configuration. Instead of doing that, add > > >> our custom dma configuration implementation. > > >> > > >> Signed-off-by: Laurentiu Tudor > > >> --- > > >> drivers/bus/fsl-mc/fsl-mc-bus.c | 31 > > >> ++- > > >> 1 file changed, 30 insertions(+), 1 deletion(-) > > >> > > >> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c > > >> b/drivers/bus/fsl-mc/fsl-mc-bus.c index 36eb25f82c8e..eafaa0e0b906 > > >> 100644 > > >> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c > > >> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c > > >> @@ -132,11 +132,40 @@ static int fsl_mc_bus_uevent(struct device > > >> *dev, struct kobj_uevent_env *env) static int > > >> fsl_mc_dma_configure(struct device *dev) { > > >>struct device *dma_dev = dev; > > >> + struct iommu_fwspec *fwspec; > > >> + const struct iommu_ops *iommu_ops; struct fsl_mc_device *mc_dev > > >> + = to_fsl_mc_device(dev); int ret; > > >> + u32 icid; > > >> > > >>while (dev_is_fsl_mc(dma_dev)) > > >>dma_dev = dma_dev->parent; > > >> > > >> - return of_dma_configure(dev, dma_dev->of_node, 0); > > >> + fwspec = dev_iommu_fwspec_get(dma_dev); if (!fwspec) > > >> + return -ENODEV; > > >> + iommu_ops = iommu_ops_from_fwnode(fwspec->iommu_fwnode); > > >> + if (!iommu_ops) > > >> + return -ENODEV; > > >> + > > >> + ret = iommu_fwspec_init(dev, fwspec->iommu_fwnode, iommu_ops); > > >> + if (ret) > > >> + return ret; > > >> + > > >> + icid = mc_dev->icid; > > >> + ret = iommu_fwspec_add_ids(dev, , 1); > > > > > > I see. So with this patch we would use the MC named component only > > > to retrieve the iommu_ops > > > > Right. I'd also add that the implementation tries to follow the > > existing standard .dma_configure implementations, e.g. > > of_dma_configure + of_iommu_configure. I'd also note that similarly to > > the ACPI case, this MC FW device is probed as a platform device in the > > DT scenario, binding here [1]. > > A similar approach is used for the retrieval of the msi irq domain, > > see following patch. > > > > > - the streamid are injected directly here bypassing OF/IORT bindings > translations altogether. > > > > Actually I've submitted a v2 [2] that calls into .of_xlate() to allow > > the smmu driver to do some processing on the raw streamid coming from > > the firmware. I have not yet tested this with ACPI but expect it to > > work, however, it's debatable how valid is this approach in the > > context of ACPI. > > Actually, what I think you need is of_map_rid() (and an IORT equivalent, that > I > am going to write - generalizing iort_msi_map_rid()). > That would help. > Would that be enough to enable IORT "normal" mappings in the MC bus named > components ? > But still the question remain unanswered that how we are going to represent MC? As Platform device with single ID mapping flag? > Thanks, > Lorenzo ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
RE: [EXT] Re: [RFC PATCH 1/4] bus: fsl-mc: add custom .dma_configure implementation
> -Original Message- > From: Robin Murphy > Sent: Wednesday, April 15, 2020 11:02 PM > To: Laurentiu Tudor ; Lorenzo Pieralisi > > Cc: linux-ker...@vger.kernel.org; iommu@lists.linux-foundation.org; linux-arm- > ker...@lists.infradead.org; linux-a...@vger.kernel.org; > ard.biesheu...@linaro.org; Ioana Ciornei ; Diana > Madalina Craciun (OSS) ; m...@kernel.org; > j...@solid-run.com; Pankaj Bansal ; Makarand > Pawagi ; Calvin Johnson > ; Varun Sethi ; Cristi Sovaiala > ; stuart.yo...@arm.com; jeremy.lin...@arm.com; > j...@8bytes.org; t...@linutronix.de; ja...@lakedaemon.net > Subject: [EXT] Re: [RFC PATCH 1/4] bus: fsl-mc: add custom .dma_configure > implementation > > Caution: EXT Email > > On 2020-04-15 4:44 pm, Laurentiu Tudor wrote: > > > > > > On 4/14/2020 5:32 PM, Lorenzo Pieralisi wrote: > >> On Wed, Mar 25, 2020 at 06:48:55PM +0200, Laurentiu Tudor wrote: > >>> Hi Lorenzo, > >>> > >>> On 3/25/2020 2:51 PM, Lorenzo Pieralisi wrote: > >>>> On Thu, Feb 27, 2020 at 12:05:39PM +0200, laurentiu.tu...@nxp.com > wrote: > >>>>> From: Laurentiu Tudor > >>>>> > >>>>> The devices on this bus are not discovered by way of device tree > >>>>> but by queries to the firmware. It makes little sense to trick the > >>>>> generic of layer into thinking that these devices are of related > >>>>> so that we can get our dma configuration. Instead of doing that, > >>>>> add our custom dma configuration implementation. > >>>>> > >>>>> Signed-off-by: Laurentiu Tudor > >>>>> --- > >>>>> drivers/bus/fsl-mc/fsl-mc-bus.c | 31 > ++- > >>>>> 1 file changed, 30 insertions(+), 1 deletion(-) > >>>>> > >>>>> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>>> b/drivers/bus/fsl-mc/fsl-mc-bus.c index 36eb25f82c8e..eafaa0e0b906 > >>>>> 100644 > >>>>> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>>> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>>> @@ -132,11 +132,40 @@ static int fsl_mc_bus_uevent(struct device > *dev, struct kobj_uevent_env *env) > >>>>> static int fsl_mc_dma_configure(struct device *dev) > >>>>> { > >>>>> struct device *dma_dev = dev; > >>>>> + struct iommu_fwspec *fwspec; > >>>>> + const struct iommu_ops *iommu_ops; struct fsl_mc_device *mc_dev > >>>>> + = to_fsl_mc_device(dev); int ret; > >>>>> + u32 icid; > >>>>> > >>>>> while (dev_is_fsl_mc(dma_dev)) > >>>>> dma_dev = dma_dev->parent; > >>>>> > >>>>> - return of_dma_configure(dev, dma_dev->of_node, 0); > >>>>> + fwspec = dev_iommu_fwspec_get(dma_dev); if (!fwspec) > >>>>> + return -ENODEV; > >>>>> + iommu_ops = iommu_ops_from_fwnode(fwspec->iommu_fwnode); > >>>>> + if (!iommu_ops) > >>>>> + return -ENODEV; > >>>>> + > >>>>> + ret = iommu_fwspec_init(dev, fwspec->iommu_fwnode, iommu_ops); > >>>>> + if (ret) > >>>>> + return ret; > >>>>> + > >>>>> + icid = mc_dev->icid; > >>>>> + ret = iommu_fwspec_add_ids(dev, , 1); > >>>> > >>>> I see. So with this patch we would use the MC named component only > >>>> to retrieve the iommu_ops > >>> > >>> Right. I'd also add that the implementation tries to follow the > >>> existing standard .dma_configure implementations, e.g. > >>> of_dma_configure + of_iommu_configure. I'd also note that similarly > >>> to the ACPI case, this MC FW device is probed as a platform device > >>> in the DT scenario, binding here [1]. > >>> A similar approach is used for the retrieval of the msi irq domain, > >>> see following patch. > >>> > >>>> - the streamid are injected directly here bypassing OF/IORT bindings > translations altogether. > >>> > >>> Actually I've submitted a v2 [2] that calls into .of_xlate() to > >>> allow the smmu driver to do some processing on the raw streamid > >>> coming from the firmware. I have not yet tested this with ACPI but > >>> expect it to work, however, it's de
RE: [PATCH 12/12] bus: fsl-mc: Add ACPI support for fsl-mc
Hi Lorenzo, > -Original Message- > From: Laurentiu Tudor > Sent: Thursday, May 21, 2020 8:33 PM > To: Lorenzo Pieralisi ; linux-arm- > ker...@lists.infradead.org > Cc: Diana Madalina Craciun (OSS) ; Makarand > Pawagi ; iommu@lists.linux-foundation.org; > linux-a...@vger.kernel.org; devicet...@vger.kernel.org; linux- > p...@vger.kernel.org; Rob Herring ; Rafael J. Wysocki > ; Joerg Roedel ; Hanjun Guo > ; Bjorn Helgaas ; Sudeep > Holla ; Robin Murphy ; > Catalin Marinas ; Will Deacon ; > Marc Zyngier > Subject: Re: [PATCH 12/12] bus: fsl-mc: Add ACPI support for fsl-mc > > Hi Lorenzo, > > On 5/21/2020 4:00 PM, Lorenzo Pieralisi wrote: > > From: Diana Craciun > > > > Add ACPI support in the fsl-mc driver. Driver parses MC DSDT table to > > extract memory and other resources. > > > > Interrupt (GIC ITS) information is extracted from the MADT table by > > drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c. > > > > IORT table is parsed to configure DMA. > > > > Signed-off-by: Makarand Pawagi > > Signed-off-by: Diana Craciun > > Signed-off-by: Laurentiu Tudor > > --- > > The author of this patch should be Makarand. I think I accidentaly broke it > when > we exchanged the patches. Very sorry about it. > Will you be able to correct this or should I post another patch? > --- > Best Regards, Laurentiu > > > > drivers/bus/fsl-mc/fsl-mc-bus.c | 73 +++- > > drivers/bus/fsl-mc/fsl-mc-msi.c | 37 +- > > drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c | 75 > > - > > 3 files changed, 150 insertions(+), 35 deletions(-) > > > > diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c > > b/drivers/bus/fsl-mc/fsl-mc-bus.c index 824ff77bbe86..324d49d6df89 > > 100644 > > --- a/drivers/bus/fsl-mc/fsl-mc-bus.c > > +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c > > @@ -18,6 +18,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > > > #include "fsl-mc-private.h" > > > > @@ -38,6 +40,7 @@ struct fsl_mc { > > struct fsl_mc_device *root_mc_bus_dev; > > u8 num_translation_ranges; > > struct fsl_mc_addr_translation_range *translation_ranges; > > + void *fsl_mc_regs; > > }; > > > > /** > > @@ -56,6 +59,10 @@ struct fsl_mc_addr_translation_range { > > phys_addr_t start_phys_addr; > > }; > > > > +#define FSL_MC_FAPR0x28 > > +#define MC_FAPR_PL BIT(18) > > +#define MC_FAPR_BMTBIT(17) > > + > > /** > > * fsl_mc_bus_match - device to driver matching callback > > * @dev: the fsl-mc device to match against @@ -124,7 +131,10 @@ > > static int fsl_mc_dma_configure(struct device *dev) > > while (dev_is_fsl_mc(dma_dev)) > > dma_dev = dma_dev->parent; > > > > - return of_dma_configure_id(dev, dma_dev->of_node, 0, _id); > > + if (dev_of_node(dma_dev)) > > + return of_dma_configure_id(dev, dma_dev->of_node, 0, > _id); > > + > > + return acpi_dma_configure_id(dev, DEV_DMA_COHERENT, _id); > > } > > > > static ssize_t modalias_show(struct device *dev, struct > > device_attribute *attr, @@ -865,8 +875,11 @@ static int > fsl_mc_bus_probe(struct platform_device *pdev) > > struct fsl_mc_io *mc_io = NULL; > > int container_id; > > phys_addr_t mc_portal_phys_addr; > > - u32 mc_portal_size; > > - struct resource res; > > + u32 mc_portal_size, mc_stream_id; > > + struct resource *plat_res; > > + > > + if (!iommu_present(_mc_bus_type)) > > + return -EPROBE_DEFER; > > > > mc = devm_kzalloc(>dev, sizeof(*mc), GFP_KERNEL); > > if (!mc) > > @@ -874,19 +887,33 @@ static int fsl_mc_bus_probe(struct > > platform_device *pdev) > > > > platform_set_drvdata(pdev, mc); > > > > + plat_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); > > + mc->fsl_mc_regs = devm_ioremap_resource(>dev, plat_res); > > + if (IS_ERR(mc->fsl_mc_regs)) > > + return PTR_ERR(mc->fsl_mc_regs); > > + > > + if (IS_ENABLED(CONFIG_ACPI) && !dev_of_node(>dev)) { > > + mc_stream_id = readl(mc->fsl_mc_regs + FSL_MC_FAPR); > > + /* > > +* HW ORs the PL and BMT bit, places the result in bit 15 of > > +* the StreamID and ORs in the ICID. Calculate it accordingly. > > +*/ > > + mc_stream_id = (mc_strea
RE: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for fsl-mc
> -Original Message- > From: Diana Madalina Craciun (OSS) > Sent: Thursday, July 9, 2020 4:17 PM > To: Makarand Pawagi ; Laurentiu Tudor > ; Lorenzo Pieralisi > Cc: linux-arm-ker...@lists.infradead.org; iommu@lists.linux-foundation.org; > linux-a...@vger.kernel.org; devicet...@vger.kernel.org; linux- > p...@vger.kernel.org; Rob Herring ; Rafael J. Wysocki > ; Joerg Roedel ; Hanjun Guo > ; Bjorn Helgaas ; Sudeep > Holla ; Robin Murphy ; > Catalin Marinas ; Will Deacon ; > Marc Zyngier > Subject: Re: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for > fsl-mc > > On 7/9/2020 1:37 PM, Makarand Pawagi wrote: > > > >> -Original Message- > >> From: Laurentiu Tudor > >> Sent: Thursday, July 9, 2020 3:45 PM > >> To: Makarand Pawagi ; Lorenzo Pieralisi > >> > >> Cc: linux-arm-ker...@lists.infradead.org; Diana Madalina Craciun > >> (OSS) ; iommu@lists.linux-foundation.org; > >> linux- a...@vger.kernel.org; devicet...@vger.kernel.org; > >> linux-...@vger.kernel.org; Rob Herring ; Rafael > >> J. Wysocki ; Joerg Roedel ; > >> Hanjun Guo ; Bjorn Helgaas > >> ; Sudeep Holla ; Robin > >> Murphy ; Catalin Marinas > >> ; Will Deacon ; Marc > >> Zyngier > >> Subject: Re: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support > >> for fsl-mc > >> > >> > >> > >> On 7/9/2020 12:26 PM, Makarand Pawagi wrote: > >>> > >>>> -Original Message- > >>>> From: Lorenzo Pieralisi > >>>> Sent: Thursday, July 9, 2020 2:50 PM > >>>> To: Laurentiu Tudor > >>>> Cc: linux-arm-ker...@lists.infradead.org; Makarand Pawagi > >>>> ; Diana Madalina Craciun (OSS) > >>>> ; iommu@lists.linux-foundation.org; > >>>> linux- a...@vger.kernel.org; devicet...@vger.kernel.org; > >>>> linux-...@vger.kernel.org; Rob Herring ; Rafael > >>>> J. Wysocki ; Joerg Roedel ; > >>>> Hanjun Guo ; Bjorn Helgaas > >>>> ; Sudeep Holla ; Robin > >>>> Murphy ; Catalin Marinas > >>>> ; Will Deacon ; Marc > >>>> Zyngier > >>>> Subject: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support > >>>> for fsl-mc > >>>> > >>>> Caution: EXT Email > >>>> > >>>> On Wed, Jul 01, 2020 at 07:55:28PM +0300, Laurentiu Tudor wrote: > >>>>> > >>>>> On 6/19/2020 11:20 AM, Lorenzo Pieralisi wrote: > >>>>>> From: Makarand Pawagi > >>>>>> > >>>>>> Add ACPI support in the fsl-mc driver. Driver parses MC DSDT > >>>>>> table to extract memory and other resources. > >>>>>> > >>>>>> Interrupt (GIC ITS) information is extracted from the MADT table > >>>>>> by drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c. > >>>>>> > >>>>>> IORT table is parsed to configure DMA. > >>>>>> > >>>>>> Signed-off-by: Makarand Pawagi > >>>>>> Signed-off-by: Diana Craciun > >>>>>> Signed-off-by: Laurentiu Tudor > >>>>>> --- > >>>>>> drivers/bus/fsl-mc/fsl-mc-bus.c | 73 > >>>>>> drivers/bus/fsl-mc/fsl-mc-msi.c | 37 + > >>>>>> drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c | 92 > >>>>>> - > >>>>>> 3 files changed, 150 insertions(+), 52 deletions(-) > >>>>>> > >>>>>> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>>>> b/drivers/bus/fsl-mc/fsl-mc-bus.c index > >>>>>> 824ff77bbe86..324d49d6df89 > >>>>>> 100644 > >>>>>> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>>>> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>>>> @@ -18,6 +18,8 @@ > >>>>>> #include > >>>>>> #include > >>>>>> #include > >>>>>> +#include > >>>>>> +#include > >>>>>> > >>>>>> #include "fsl-mc-private.h" > >>>>>> > >>>>>> @@ -38,6 +40,7 @@ struct fsl_mc { > >>>>>> struct fsl_mc_device *root_mc_bus_dev; > >>>>>> u8 num_translation_rang
RE: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for fsl-mc
> -Original Message- > From: Laurentiu Tudor > Sent: Thursday, July 9, 2020 3:45 PM > To: Makarand Pawagi ; Lorenzo Pieralisi > > Cc: linux-arm-ker...@lists.infradead.org; Diana Madalina Craciun (OSS) > ; iommu@lists.linux-foundation.org; linux- > a...@vger.kernel.org; devicet...@vger.kernel.org; linux-...@vger.kernel.org; > Rob Herring ; Rafael J. Wysocki ; > Joerg Roedel ; Hanjun Guo ; Bjorn > Helgaas ; Sudeep Holla ; > Robin Murphy ; Catalin Marinas > ; Will Deacon ; Marc Zyngier > > Subject: Re: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for > fsl-mc > > > > On 7/9/2020 12:26 PM, Makarand Pawagi wrote: > > > > > >> -Original Message- > >> From: Lorenzo Pieralisi > >> Sent: Thursday, July 9, 2020 2:50 PM > >> To: Laurentiu Tudor > >> Cc: linux-arm-ker...@lists.infradead.org; Makarand Pawagi > >> ; Diana Madalina Craciun (OSS) > >> ; iommu@lists.linux-foundation.org; linux- > >> a...@vger.kernel.org; devicet...@vger.kernel.org; > >> linux-...@vger.kernel.org; Rob Herring ; Rafael > >> J. Wysocki ; Joerg Roedel ; > >> Hanjun Guo ; Bjorn Helgaas > >> ; Sudeep Holla ; Robin > >> Murphy ; Catalin Marinas > >> ; Will Deacon ; Marc > >> Zyngier > >> Subject: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for > >> fsl-mc > >> > >> Caution: EXT Email > >> > >> On Wed, Jul 01, 2020 at 07:55:28PM +0300, Laurentiu Tudor wrote: > >>> > >>> > >>> On 6/19/2020 11:20 AM, Lorenzo Pieralisi wrote: > >>>> From: Makarand Pawagi > >>>> > >>>> Add ACPI support in the fsl-mc driver. Driver parses MC DSDT table > >>>> to extract memory and other resources. > >>>> > >>>> Interrupt (GIC ITS) information is extracted from the MADT table by > >>>> drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c. > >>>> > >>>> IORT table is parsed to configure DMA. > >>>> > >>>> Signed-off-by: Makarand Pawagi > >>>> Signed-off-by: Diana Craciun > >>>> Signed-off-by: Laurentiu Tudor > >>>> --- > >>>> drivers/bus/fsl-mc/fsl-mc-bus.c | 73 > >>>> drivers/bus/fsl-mc/fsl-mc-msi.c | 37 + > >>>> drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c | 92 > >>>> - > >>>> 3 files changed, 150 insertions(+), 52 deletions(-) > >>>> > >>>> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>> b/drivers/bus/fsl-mc/fsl-mc-bus.c index 824ff77bbe86..324d49d6df89 > >>>> 100644 > >>>> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c > >>>> @@ -18,6 +18,8 @@ > >>>> #include > >>>> #include > >>>> #include > >>>> +#include > >>>> +#include > >>>> > >>>> #include "fsl-mc-private.h" > >>>> > >>>> @@ -38,6 +40,7 @@ struct fsl_mc { > >>>> struct fsl_mc_device *root_mc_bus_dev; > >>>> u8 num_translation_ranges; > >>>> struct fsl_mc_addr_translation_range *translation_ranges; > >>>> + void *fsl_mc_regs; > >>>> }; > >>>> > >>>> /** > >>>> @@ -56,6 +59,10 @@ struct fsl_mc_addr_translation_range { > >>>> phys_addr_t start_phys_addr; > >>>> }; > >>>> > >>>> +#define FSL_MC_FAPR0x28 > >>>> +#define MC_FAPR_PL BIT(18) > >>>> +#define MC_FAPR_BMTBIT(17) > >>>> + > >>>> /** > >>>> * fsl_mc_bus_match - device to driver matching callback > >>>> * @dev: the fsl-mc device to match against @@ -124,7 +131,10 @@ > >>>> static int fsl_mc_dma_configure(struct device *dev) > >>>> while (dev_is_fsl_mc(dma_dev)) > >>>> dma_dev = dma_dev->parent; > >>>> > >>>> - return of_dma_configure_id(dev, dma_dev->of_node, 0, _id); > >>>> + if (dev_of_node(dma_dev)) > >>>> + return of_dma_configure_id(dev, dma_dev->of_node, 0, > >>>> + _id); > >>>> + > >>>> + return acpi_dma_configure_id(dev, DEV_DMA_COHERENT, _id); >
RE: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for fsl-mc
> -Original Message- > From: Lorenzo Pieralisi > Sent: Thursday, July 9, 2020 2:50 PM > To: Laurentiu Tudor > Cc: linux-arm-ker...@lists.infradead.org; Makarand Pawagi > ; Diana Madalina Craciun (OSS) > ; iommu@lists.linux-foundation.org; linux- > a...@vger.kernel.org; devicet...@vger.kernel.org; linux-...@vger.kernel.org; > Rob Herring ; Rafael J. Wysocki ; > Joerg Roedel ; Hanjun Guo ; Bjorn > Helgaas ; Sudeep Holla ; > Robin Murphy ; Catalin Marinas > ; Will Deacon ; Marc Zyngier > > Subject: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for fsl-mc > > Caution: EXT Email > > On Wed, Jul 01, 2020 at 07:55:28PM +0300, Laurentiu Tudor wrote: > > > > > > On 6/19/2020 11:20 AM, Lorenzo Pieralisi wrote: > > > From: Makarand Pawagi > > > > > > Add ACPI support in the fsl-mc driver. Driver parses MC DSDT table > > > to extract memory and other resources. > > > > > > Interrupt (GIC ITS) information is extracted from the MADT table by > > > drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c. > > > > > > IORT table is parsed to configure DMA. > > > > > > Signed-off-by: Makarand Pawagi > > > Signed-off-by: Diana Craciun > > > Signed-off-by: Laurentiu Tudor > > > --- > > > drivers/bus/fsl-mc/fsl-mc-bus.c | 73 > > > drivers/bus/fsl-mc/fsl-mc-msi.c | 37 + > > > drivers/irqchip/irq-gic-v3-its-fsl-mc-msi.c | 92 > > > - > > > 3 files changed, 150 insertions(+), 52 deletions(-) > > > > > > diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c > > > b/drivers/bus/fsl-mc/fsl-mc-bus.c index 824ff77bbe86..324d49d6df89 > > > 100644 > > > --- a/drivers/bus/fsl-mc/fsl-mc-bus.c > > > +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c > > > @@ -18,6 +18,8 @@ > > > #include > > > #include > > > #include > > > +#include > > > +#include > > > > > > #include "fsl-mc-private.h" > > > > > > @@ -38,6 +40,7 @@ struct fsl_mc { > > > struct fsl_mc_device *root_mc_bus_dev; > > > u8 num_translation_ranges; > > > struct fsl_mc_addr_translation_range *translation_ranges; > > > + void *fsl_mc_regs; > > > }; > > > > > > /** > > > @@ -56,6 +59,10 @@ struct fsl_mc_addr_translation_range { > > > phys_addr_t start_phys_addr; > > > }; > > > > > > +#define FSL_MC_FAPR0x28 > > > +#define MC_FAPR_PL BIT(18) > > > +#define MC_FAPR_BMTBIT(17) > > > + > > > /** > > > * fsl_mc_bus_match - device to driver matching callback > > > * @dev: the fsl-mc device to match against @@ -124,7 +131,10 @@ > > > static int fsl_mc_dma_configure(struct device *dev) > > > while (dev_is_fsl_mc(dma_dev)) > > > dma_dev = dma_dev->parent; > > > > > > - return of_dma_configure_id(dev, dma_dev->of_node, 0, _id); > > > + if (dev_of_node(dma_dev)) > > > + return of_dma_configure_id(dev, dma_dev->of_node, 0, > > > + _id); > > > + > > > + return acpi_dma_configure_id(dev, DEV_DMA_COHERENT, _id); > > > } > > > > > > static ssize_t modalias_show(struct device *dev, struct > > > device_attribute *attr, @@ -865,8 +875,11 @@ static int > fsl_mc_bus_probe(struct platform_device *pdev) > > > struct fsl_mc_io *mc_io = NULL; > > > int container_id; > > > phys_addr_t mc_portal_phys_addr; > > > - u32 mc_portal_size; > > > - struct resource res; > > > + u32 mc_portal_size, mc_stream_id; > > > + struct resource *plat_res; > > > + > > > + if (!iommu_present(_mc_bus_type)) > > > + return -EPROBE_DEFER; > > > > > > mc = devm_kzalloc(>dev, sizeof(*mc), GFP_KERNEL); > > > if (!mc) > > > @@ -874,19 +887,33 @@ static int fsl_mc_bus_probe(struct > > > platform_device *pdev) > > > > > > platform_set_drvdata(pdev, mc); > > > > > > + plat_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); > > > + mc->fsl_mc_regs = devm_ioremap_resource(>dev, plat_res); > > > + if (IS_ERR(mc->fsl_mc_regs)) > > > + return PTR_ERR(mc->fsl_mc_regs); > > > + > > > + if (IS_ENABLED(CONFIG_ACPI) && !dev_of_node(>dev)) { > > > + mc_stream_id = r
RE: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for fsl-mc
> -Original Message- > From: Lorenzo Pieralisi > Sent: Wednesday, July 15, 2020 3:37 PM > To: Makarand Pawagi > Cc: Diana Madalina Craciun (OSS) ; Laurentiu > Tudor ; linux-arm-ker...@lists.infradead.org; > iommu@lists.linux-foundation.org; linux-a...@vger.kernel.org; > devicet...@vger.kernel.org; linux-...@vger.kernel.org; Rob Herring > ; Rafael J. Wysocki ; Joerg Roedel > ; Hanjun Guo ; Bjorn Helgaas > ; Sudeep Holla ; Robin > Murphy ; Catalin Marinas > ; Will Deacon ; Marc Zyngier > > Subject: Re: [EXT] Re: [PATCH v2 12/12] bus: fsl-mc: Add ACPI support for > fsl-mc > > Caution: EXT Email > > On Thu, Jul 09, 2020 at 10:52:52AM +, Makarand Pawagi wrote: > > [...] > > > > >>>> fsl_mc_bus_probe(struct platform_device *pdev) > > > >>>>>> struct fsl_mc_io *mc_io = NULL; > > > >>>>>> int container_id; > > > >>>>>> phys_addr_t mc_portal_phys_addr; > > > >>>>>> - u32 mc_portal_size; > > > >>>>>> - struct resource res; > > > >>>>>> + u32 mc_portal_size, mc_stream_id; > > > >>>>>> + struct resource *plat_res; > > > >>>>>> + > > > >>>>>> + if (!iommu_present(_mc_bus_type)) > > > >>>>>> + return -EPROBE_DEFER; > > > >>>>>> > > > >>>>>> mc = devm_kzalloc(>dev, sizeof(*mc), GFP_KERNEL); > > > >>>>>> if (!mc) > > > >>>>>> @@ -874,19 +887,33 @@ static int fsl_mc_bus_probe(struct > > > >>>>>> platform_device *pdev) > > > >>>>>> > > > >>>>>> platform_set_drvdata(pdev, mc); > > > >>>>>> > > > >>>>>> + plat_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); > > > >>>>>> + mc->fsl_mc_regs = devm_ioremap_resource(>dev, > plat_res); > > > >>>>>> + if (IS_ERR(mc->fsl_mc_regs)) > > > >>>>>> + return PTR_ERR(mc->fsl_mc_regs); > > > >>>>>> + > > > >>>>>> + if (IS_ENABLED(CONFIG_ACPI) && !dev_of_node(>dev)) { > > > >>>>>> + mc_stream_id = readl(mc->fsl_mc_regs + FSL_MC_FAPR); > > > >>>>>> + /* > > > >>>>>> +* HW ORs the PL and BMT bit, places the result in bit > > > >>>>>> 15 of > > > >>>>>> +* the StreamID and ORs in the ICID. Calculate it > > > >>>>>> accordingly. > > > >>>>>> +*/ > > > >>>>>> + mc_stream_id = (mc_stream_id & 0x) | > > > >>>>>> + ((mc_stream_id & (MC_FAPR_PL | > > > >>>>>> MC_FAPR_BMT)) ? > > > >>>>>> + 0x4000 : 0); > > > >>>>>> + error = acpi_dma_configure_id(>dev, > > > DEV_DMA_COHERENT, > > > >>>>>> + _stream_id); > > > >>>>>> + if (error) > > > >>>>>> + dev_warn(>dev, "failed to configure dma: > > > >>>>>> %d.\n", > > > >>>>>> +error); > > > >>>>>> + } > > > >>>>>> + > > > >>>>>> /* > > > >>>>>> * Get physical address of MC portal for the root DPRC: > > > >>>>>> */ > > > >>>>>> - error = of_address_to_resource(pdev->dev.of_node, 0, ); > > > >>>>>> - if (error < 0) { > > > >>>>>> - dev_err(>dev, > > > >>>>>> - "of_address_to_resource() failed for %pOF\n", > > > >>>>>> - pdev->dev.of_node); > > > >>>>>> - return error; > > > >>>>>> - } > > > >>>>>> - > > > >>>>>> - mc_portal_phys_addr = res.start; > > > >>>>>> - mc_portal_size
RE: [EXT] Re: [PATCH v2 03/12] ACPI/IORT: Make iort_msi_map_rid() PCI agnostic
> -Original Message- > From: Bjorn Helgaas > Sent: Tuesday, July 21, 2020 8:29 PM > To: Lorenzo Pieralisi > Cc: linux-arm-ker...@lists.infradead.org; Will Deacon ; > Hanjun Guo ; Bjorn Helgaas > ; Sudeep Holla ; Catalin > Marinas ; Robin Murphy ; > Rafael J. Wysocki ; iommu@lists.linux-foundation.org; > linux-a...@vger.kernel.org; devicet...@vger.kernel.org; linux- > p...@vger.kernel.org; Rob Herring ; Joerg Roedel > ; Marc Zyngier ; Makarand Pawagi > ; Diana Madalina Craciun (OSS) > ; Laurentiu Tudor > Subject: [EXT] Re: [PATCH v2 03/12] ACPI/IORT: Make iort_msi_map_rid() PCI > agnostic > > Caution: EXT Email > > On Fri, Jun 19, 2020 at 09:20:04AM +0100, Lorenzo Pieralisi wrote: > > There is nothing PCI specific in iort_msi_map_rid(). > > > > Rename the function using a bus protocol agnostic name, > > iort_msi_map_id(), and convert current callers to it. > > > > Signed-off-by: Lorenzo Pieralisi > > Cc: Will Deacon > > Cc: Hanjun Guo > > Cc: Bjorn Helgaas > > Cc: Sudeep Holla > > Cc: Catalin Marinas > > Cc: Robin Murphy > > Cc: "Rafael J. Wysocki" > > Acked-by: Bjorn Helgaas > > Sorry I missed this! [Makarand Pawagi] Thanks Bjorn, Hi Rafael can you also finalize your review? > > > --- > > drivers/acpi/arm64/iort.c | 12 ++-- > > drivers/pci/msi.c | 2 +- > > include/linux/acpi_iort.h | 6 +++--- > > 3 files changed, 10 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > > index 902e2aaca946..53f9ef515089 100644 > > --- a/drivers/acpi/arm64/iort.c > > +++ b/drivers/acpi/arm64/iort.c > > @@ -568,22 +568,22 @@ static struct acpi_iort_node > > *iort_find_dev_node(struct device *dev) } > > > > /** > > - * iort_msi_map_rid() - Map a MSI requester ID for a device > > + * iort_msi_map_id() - Map a MSI input ID for a device > > * @dev: The device for which the mapping is to be done. > > - * @req_id: The device requester ID. > > + * @input_id: The device input ID. > > * > > - * Returns: mapped MSI RID on success, input requester ID otherwise > > + * Returns: mapped MSI ID on success, input ID otherwise > > */ > > -u32 iort_msi_map_rid(struct device *dev, u32 req_id) > > +u32 iort_msi_map_id(struct device *dev, u32 input_id) > > { > > struct acpi_iort_node *node; > > u32 dev_id; > > > > node = iort_find_dev_node(dev); > > if (!node) > > - return req_id; > > + return input_id; > > > > - iort_node_map_id(node, req_id, _id, IORT_MSI_TYPE); > > + iort_node_map_id(node, input_id, _id, IORT_MSI_TYPE); > > return dev_id; > > } > > > > diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index > > 74a91f52ecc0..77f48b95e277 100644 > > --- a/drivers/pci/msi.c > > +++ b/drivers/pci/msi.c > > @@ -1536,7 +1536,7 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain > > *domain, struct pci_dev *pdev) > > > > of_node = irq_domain_get_of_node(domain); > > rid = of_node ? of_msi_map_rid(>dev, of_node, rid) : > > - iort_msi_map_rid(>dev, rid); > > + iort_msi_map_id(>dev, rid); > > > > return rid; > > } > > diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h > > index 08ec6bd2297f..e51425e083da 100644 > > --- a/include/linux/acpi_iort.h > > +++ b/include/linux/acpi_iort.h > > @@ -28,7 +28,7 @@ void iort_deregister_domain_token(int trans_id); > > struct fwnode_handle *iort_find_domain_token(int trans_id); #ifdef > > CONFIG_ACPI_IORT void acpi_iort_init(void); > > -u32 iort_msi_map_rid(struct device *dev, u32 req_id); > > +u32 iort_msi_map_id(struct device *dev, u32 id); > > struct irq_domain *iort_get_device_domain(struct device *dev, u32 id, > > enum irq_domain_bus_token > > bus_token); void acpi_configure_pmsi_domain(struct device *dev); @@ > > -39,8 +39,8 @@ const struct iommu_ops *iort_iommu_configure(struct > > device *dev); int iort_iommu_msi_get_resv_regions(struct device *dev, > > struct list_head *head); #else static inline void > > acpi_iort_init(void) { } -static inline u32 iort_msi_map_rid(struct > > device *dev, u32 req_id) -{ return req_id; } > > +static inline u32 iort_msi_map_id(struct device *dev, u32 id) { > > +return id; } > > static inline struct irq_domain *iort_get_device_domain( > > struct device *dev, u32 id, enum irq_domain_bus_token bus_token) > > { return NULL; } > > -- > > 2.26.1 > > ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
RE: [EXT] Re: [PATCH v2 00/12] ACPI/OF: Upgrade MSI/IOMMU ID mapping APIs
> -Original Message- > From: Lorenzo Pieralisi > Sent: Monday, July 20, 2020 10:25 PM > To: linux-arm-ker...@lists.infradead.org; Rob Herring ; > Rafael J. Wysocki ; Bjorn Helgaas ; > Catalin Marinas ; Will Deacon ; > j...@8bytes.org > Cc: Hanjun Guo ; Sudeep Holla > ; Robin Murphy ; Marc > Zyngier ; iommu@lists.linux-foundation.org; linux- > a...@vger.kernel.org; devicet...@vger.kernel.org; linux-...@vger.kernel.org; > Makarand Pawagi ; Diana Madalina Craciun (OSS) > ; Laurentiu Tudor > Subject: [EXT] Re: [PATCH v2 00/12] ACPI/OF: Upgrade MSI/IOMMU ID mapping > APIs > > Caution: EXT Email > > On Fri, Jun 19, 2020 at 09:20:01AM +0100, Lorenzo Pieralisi wrote: > > This series is a v2 of a previous posting: > > > > v1 -> v2 > > > > - Removed _rid() wrappers > > - Fixed !CONFIG_ACPI compilation issue > > - Converted of_pci_iommu_init() to use of_iommu_configure_dev_id() > > > > v1: > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore > > .kernel.org%2Flinux-arm-kernel%2F20200521130008.8266-1-lorenzo.pierali > > > si%40arm.com%2Fdata=02%7C01%7Cmakarand.pawagi%40nxp.com%7C > da7bade > > > c592846a1478808d82ccd9eb1%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0% > 7C1%7 > > > C637308608924853281sdata=ZoP3e2Q5Ijkz%2FtsGfgu9MYkmKXSHQExs5 > J64Sb > > h51YA%3Dreserved=0 > > > > Original cover letter > > - > > > > Firmware bindings provided in the ACPI IORT table[1] and device tree > > bindings define rules to carry out input/output ID mappings - ie > > retrieving an IOMMU/MSI controller input ID for a device with a given > > ID. > > > > At the moment these firmware bindings are used exclusively for PCI > > devices and their requester ID to IOMMU/MSI id mapping but there is > > nothing PCI specific in the ACPI and devicetree bindings that prevent > > the firmware and kernel from using the firmware bindings to traslate > > device IDs for any bus that requires its devices to carry out > > input/output id translations. > > > > The Freescale FSL bus is an example whereby the input/output ID > > translation kernel code put in place for PCI can be reused for devices > > attached to the bus that are not PCI devices. > > > > This series updates the kernel code to make the MSI/IOMMU input/output > > ID translation PCI agnostic and apply the resulting changes to the > > device ID space provided by the Freescale FSL bus. > > > > [1] > > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Finfoc > > > enter.arm.com%2Fhelp%2Ftopic%2Fcom.arm.doc.den0049d%2FDEN0049D_IO_ > Rema > > > pping_Table.pdfdata=02%7C01%7Cmakarand.pawagi%40nxp.com%7Cda > 7bade > > > c592846a1478808d82ccd9eb1%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0% > 7C1%7 > > > C637308608924853281sdata=RzpIo4AfAFsi2pdEuY%2FbnPAyase5cSmFIr5 > 2SX > > aOrTg%3Dreserved=0 > > > > Cc: Rob Herring > > Cc: "Rafael J. Wysocki" > > Cc: "Joerg Roedel > > Cc: Hanjun Guo > > Cc: Bjorn Helgaas > > Cc: Sudeep Holla > > Cc: Robin Murphy > > Cc: Catalin Marinas > > Cc: Will Deacon > > Cc: Marc Zyngier > > > > Diana Craciun (2): > > of/irq: make of_msi_map_get_device_domain() bus agnostic > > bus/fsl-mc: Refactor the MSI domain creation in the DPRC driver > > > > Laurentiu Tudor (1): > > dt-bindings: arm: fsl: Add msi-map device-tree binding for fsl-mc > > bus > > > > Lorenzo Pieralisi (8): > > ACPI/IORT: Make iort_match_node_callback walk the ACPI namespace for > > NC > > ACPI/IORT: Make iort_get_device_domain IRQ domain agnostic > > ACPI/IORT: Make iort_msi_map_rid() PCI agnostic > > ACPI/IORT: Remove useless PCI bus walk > > ACPI/IORT: Add an input ID to acpi_dma_configure() > > of/iommu: Make of_map_rid() PCI agnostic > > of/device: Add input id to of_dma_configure() > > of/irq: Make of_msi_map_rid() PCI bus agnostic > > > > Makarand Pawagi (1): > > bus: fsl-mc: Add ACPI support for fsl-mc > > > > .../devicetree/bindings/misc/fsl,qoriq-mc.txt | 50 +++- > > drivers/acpi/arm64/iort.c | 108 -- > > drivers/acpi/scan.c | 8 +- > > drivers/bus/fsl-mc/dprc-driver.c | 31 ++--- > > drivers/bus/fsl-mc/fsl-mc-bus.c | 79 + > > drivers/bus/fsl-mc/fsl-mc-msi.c | 36 -- > > drivers/bus/fsl-mc/fsl-mc-private.h | 6 +- > > drive