Re: [PATCH v3 1/2] PCI: Add enable_device() and disable_device() callbacks for bridges

Marc Zyngier
2024-11-01T17:00:55Z

On Wed, 30 Oct 2024 21:00:43 +0000,
Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Thu, Oct 24, 2024 at 06:34:44PM -0400, Frank Li wrote:
> > Some PCIe host bridges require special handling when enabling or disabling
> > PCIe Endpoints. For example, the i.MX95 platform has a lookup table to map
> > Requester IDs to StreamIDs, which are used by the SMMU and MSI controller
> > to identify the source of DMA accesses.
> >
> > Without this mapping, DMA accesses may target unintended memory, which
> > would corrupt memory or read the wrong data.
> >
> > Add a host bridge .enable_device() hook the imx6 driver can use to
> > configure the Requester ID to StreamID mapping. The hardware table isn't
> > big enough to map all possible Requester IDs, so this hook may fail if no
> > table space is available. In that case, return failure from
> > pci_enable_device().
> >
> > It might make more sense to make pci_set_master() decline to enable bus
> > mastering and return failure, but it currently doesn't have a way to return
> > failure.
> >
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
>
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
>
> Merge along with the imx6 change.

It'd be good to have this on a stable branch somewhere so that I can
refer to it when posting the conversion for the Apple driver to that
infrastructure, removing the need for a bus notifier.

Otherwise, I'll just cherry-pick that patch and post the whole thing.

Thanks,

M.

--
Without deviation from the norm, progress is not possible.