[PATCH v2 5/5] iommu/arm-smmu: Convert to domain_alloc_paging()
Jason Gunthorpe
jgg at nvidia.com
Wed Dec 13 05:32:51 PST 2023
On Wed, Dec 13, 2023 at 01:27:01PM +0000, Will Deacon wrote:
> On Tue, Dec 12, 2023 at 02:10:23PM +0000, Will Deacon wrote:
> > On Tue, Dec 12, 2023 at 10:03:07AM -0400, Jason Gunthorpe wrote:
> > > On Tue, Dec 12, 2023 at 01:26:51PM +0000, Will Deacon wrote:
> > > > Why do we need to handle the 'dev && !cfg' case here, instead g
> > > > returning NULL?
> > >
> > > dev && !cfg is impossible these days, so we can shuffle the if and
> > > then just crash on that case like the other drivers do.
> >
> > Thanks, that would simplify it a little.
>
> Folded in the diff below.
>
> Will
>
> --->8
>
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 536e47e3a65a..b0a6b367d8a2 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -861,7 +861,6 @@ static void arm_smmu_destroy_domain_context(struct arm_smmu_domain *smmu_domain)
>
> static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
> {
> - struct arm_smmu_master_cfg *cfg = NULL;
> struct arm_smmu_domain *smmu_domain;
>
> /*
> @@ -876,13 +875,10 @@ static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
> mutex_init(&smmu_domain->init_mutex);
> spin_lock_init(&smmu_domain->cb_lock);
>
> - if (dev)
> - cfg = dev_iommu_priv_get(dev);
> - if (cfg) {
> - int ret;
> + if (dev) {
> + struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev);
>
> - ret = arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev);
> - if (ret) {
> + if (arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev)) {
> kfree(smmu_domain);
> return NULL;
> }
Looks good, thanks
Jason
More information about the linux-arm-kernel
mailing list