Message ID | 7-v1-720585788a7d+811b-iommu_fwspec_p1_jgg@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | IOMMU related FW parsing cleanup | expand |
On 2023/11/29 8:48, Jason Gunthorpe wrote: > Nothing needs this pointer. Return a normal error code with the usual > IOMMU semantic that ENODEV means 'there is no IOMMU driver'. > > Acked-by: Rafael J. Wysocki<rafael.j.wysocki@intel.com> > Reviewed-by: Jerry Snitselaar<jsnitsel@redhat.com> > Tested-by: Hector Martin<marcan@marcan.st> > Signed-off-by: Jason Gunthorpe<jgg@nvidia.com> > --- > drivers/acpi/scan.c | 29 +++++++++++++++++------------ > 1 file changed, 17 insertions(+), 12 deletions(-) Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Best regards, baolu
On Tue, Nov 28, 2023 at 08:48:03PM -0400, Jason Gunthorpe wrote: > Nothing needs this pointer. Return a normal error code with the usual > IOMMU semantic that ENODEV means 'there is no IOMMU driver'. > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> > Tested-by: Hector Martin <marcan@marcan.st> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > --- > drivers/acpi/scan.c | 29 +++++++++++++++++------------ > 1 file changed, 17 insertions(+), 12 deletions(-) > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 444a0b3c72f2d8..340ba720c72129 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -1562,8 +1562,7 @@ static inline const struct iommu_ops > *acpi_iommu_fwspec_ops(struct device *dev) > return fwspec ? fwspec->ops : NULL; > } > -static const struct iommu_ops *acpi_iommu_configure_id(struct device > *dev, > - const u32 *id_in) > +static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in) > { > int err; > const struct iommu_ops *ops; > @@ -1577,7 +1576,7 @@ static const struct iommu_ops > *acpi_iommu_configure_id(struct device *dev, > ops = acpi_iommu_fwspec_ops(dev); > if (ops) { > mutex_unlock(&iommu_probe_device_lock); > - return ops; > + return 0; > } > err = iort_iommu_configure_id(dev, id_in); > @@ -1594,12 +1593,14 @@ static const struct iommu_ops > *acpi_iommu_configure_id(struct device *dev, > /* Ignore all other errors apart from EPROBE_DEFER */ > if (err == -EPROBE_DEFER) { > - return ERR_PTR(err); > + return err; > } else if (err) { > dev_dbg(dev, "Adding to IOMMU failed: %d\n", err); > - return NULL; > + return -ENODEV; > } > - return acpi_iommu_fwspec_ops(dev); > + if (!acpi_iommu_fwspec_ops(dev)) > + return -ENODEV; > + return 0; > } > #else /* !CONFIG_IOMMU_API */ > @@ -1611,10 +1612,9 @@ int acpi_iommu_fwspec_init(struct device *dev, u32 > id, > return -ENODEV; > } > -static const struct iommu_ops *acpi_iommu_configure_id(struct device > *dev, > - const u32 *id_in) > +static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in) > { > - return NULL; > + return -ENODEV; > } > #endif /* !CONFIG_IOMMU_API */ > @@ -1628,7 +1628,7 @@ static const struct iommu_ops > *acpi_iommu_configure_id(struct device *dev, > int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr, > const u32 *input_id) > { > - const struct iommu_ops *iommu; > + int ret; > if (attr == DEV_DMA_NOT_SUPPORTED) { > set_dma_ops(dev, &dma_dummy_ops); > @@ -1637,10 +1637,15 @@ int acpi_dma_configure_id(struct device *dev, > enum dev_dma_attr attr, > acpi_arch_dma_setup(dev); > - iommu = acpi_iommu_configure_id(dev, input_id); > - if (PTR_ERR(iommu) == -EPROBE_DEFER) > + ret = acpi_iommu_configure_id(dev, input_id); > + if (ret == -EPROBE_DEFER) > return -EPROBE_DEFER; > + /* > + * Historically this routine doesn't fail driver probing due to errors > + * in acpi_iommu_configure_id() > + */ > + > arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT); > return 0; > -- > 2.42.0 Reviewed-by: Moritz Fischer <moritzf@google.com> Cheers, Moritz
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 444a0b3c72f2d8..340ba720c72129 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1562,8 +1562,7 @@ static inline const struct iommu_ops *acpi_iommu_fwspec_ops(struct device *dev) return fwspec ? fwspec->ops : NULL; } -static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, - const u32 *id_in) +static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in) { int err; const struct iommu_ops *ops; @@ -1577,7 +1576,7 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, ops = acpi_iommu_fwspec_ops(dev); if (ops) { mutex_unlock(&iommu_probe_device_lock); - return ops; + return 0; } err = iort_iommu_configure_id(dev, id_in); @@ -1594,12 +1593,14 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, /* Ignore all other errors apart from EPROBE_DEFER */ if (err == -EPROBE_DEFER) { - return ERR_PTR(err); + return err; } else if (err) { dev_dbg(dev, "Adding to IOMMU failed: %d\n", err); - return NULL; + return -ENODEV; } - return acpi_iommu_fwspec_ops(dev); + if (!acpi_iommu_fwspec_ops(dev)) + return -ENODEV; + return 0; } #else /* !CONFIG_IOMMU_API */ @@ -1611,10 +1612,9 @@ int acpi_iommu_fwspec_init(struct device *dev, u32 id, return -ENODEV; } -static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, - const u32 *id_in) +static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in) { - return NULL; + return -ENODEV; } #endif /* !CONFIG_IOMMU_API */ @@ -1628,7 +1628,7 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev, int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr, const u32 *input_id) { - const struct iommu_ops *iommu; + int ret; if (attr == DEV_DMA_NOT_SUPPORTED) { set_dma_ops(dev, &dma_dummy_ops); @@ -1637,10 +1637,15 @@ int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr, acpi_arch_dma_setup(dev); - iommu = acpi_iommu_configure_id(dev, input_id); - if (PTR_ERR(iommu) == -EPROBE_DEFER) + ret = acpi_iommu_configure_id(dev, input_id); + if (ret == -EPROBE_DEFER) return -EPROBE_DEFER; + /* + * Historically this routine doesn't fail driver probing due to errors + * in acpi_iommu_configure_id() + */ + arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT); return 0;