[PATCH 3/4] i3c: mipi-i3c-hci: Use physical device pointer with DMA API

Frank Li Frank.li at nxp.com
Tue Aug 5 08:57:53 PDT 2025


On Mon, Aug 04, 2025 at 05:34:39PM +0300, Jarkko Nikula wrote:
> On 8/1/25 7:03 PM, Frank Li wrote:
> > On Thu, Jul 31, 2025 at 05:14:19PM +0300, Jarkko Nikula wrote:
> > > @@ -194,11 +196,23 @@ static int hci_dma_init(struct i3c_hci *hci)
> > >   {
> > >   	struct hci_rings_data *rings;
> > >   	struct hci_rh_data *rh;
> > > +	struct device *sysdev;
> > >   	u32 regval;
> > >   	unsigned int i, nr_rings, xfers_sz, resps_sz;
> > >   	unsigned int ibi_status_ring_sz, ibi_data_ring_sz;
> > >   	int ret;
> > >
> > > +	/*
> > > +	 * Set pointer to a physical device that does DMA and has IOMMU setup
> > > +	 * done for it in case of enabled IOMMU and use it with the DMA API.
> > > +	 * Here such device is either
> > > +	 * "mipi-i3c-hci" platform device (OF/ACPI enumeration) parent or
> > > +	 * grandparent (PCI enumeration).
> > > +	 */
> > > +	sysdev = hci->master.dev.parent;
> > > +	if (sysdev->parent && dev_is_pci(sysdev->parent))
> > > +		sysdev = sysdev->parent;
> > > +
> >
> > I am not clear about how i3c master controller device create in your
> > platform. If use DT, i3c master controller should direct refer to a iommu
> >
> > i3c-master at 123456 {
> > 	...
> > 	iommu = <&smmu id>;
> > }
> >
> > Is it children device of a PCIe devices?
> >
> The master.dev is a "virtual" device object created by i3c_master_register()
> and for that there is no IOMMU link obviously. Only this IOMMU exercise
> revealed we were wrongly using the master.dev with DMA API.
>
> For the OF/ACPI enumeration the physical device is in pdev->dev in
> drivers/i3c/master/mipi-i3c-hci/core.c: i3c_hci_probe() and that is passed
> to the i3c_master_register() and can be references via
> hci->master.dev.parent here.
>
> PCI code needs it's own module mipi-i3c-hci-pci.c due to each module can
> have only one module_driver(), i.e. module_platform_driver() and
> module_pci_driver() cannot reside in the same module.
>
> mipi_i3c_hci_pci_probe() creates a "mipi-i3c-hci" platform device and sets
> physical device pointer pci->dev as its parent. So in PCI case the
> i3c_hci_probe() don't have the physical device pointer in its pdev->dev like
> OF/ACPI cases have but as a parent of it.
>
> Not very clear but that's how drivers with multiple enumeration need to cope
> with.

Okay for here, idealy framework should auto search parent for suitable iommu.

Frank

>
> --
> linux-i3c mailing list
> linux-i3c at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c



More information about the linux-i3c mailing list