[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200316175515.GP304669@myrica>
Date: Mon, 16 Mar 2020 18:55:15 +0100
From: Jean-Philippe Brucker <jean-philippe@...aro.org>
To: Joerg Roedel <joro@...tes.org>
Cc: iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org,
linux-arm-msm@...r.kernel.org, linux-mediatek@...ts.infradead.org,
virtualization@...ts.linux-foundation.org,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Hanjun Guo <guohanjun@...wei.com>,
Sudeep Holla <sudeep.holla@....com>,
Rob Clark <robdclark@...il.com>, Sean Paul <sean@...rly.run>,
Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>,
Matthias Brugger <matthias.bgg@...il.com>,
Thierry Reding <thierry.reding@...il.com>,
Andy Gross <agross@...nel.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Joerg Roedel <jroedel@...e.de>
Subject: Re: [PATCH 10/15] iommu/arm-smmu: Use accessor functions for iommu
private data
On Tue, Mar 10, 2020 at 10:12:24AM +0100, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@...e.de>
>
> Make use of dev_iommu_priv_set/get() functions and simplify the code
> where possible with this change.
>
> Tested-by: Will Deacon <will@...nel.org> # arm-smmu
> Signed-off-by: Joerg Roedel <jroedel@...e.de>
> ---
[...]
> @@ -1467,7 +1470,7 @@ static void arm_smmu_remove_device(struct device *dev)
> if (!fwspec || fwspec->ops != &arm_smmu_ops)
> return;
>
> - cfg = fwspec->iommu_priv;
> + cfg = dev_iommu_priv_get(dev);
> smmu = cfg->smmu;
>
> ret = arm_smmu_rpm_get(smmu);
> @@ -1475,23 +1478,22 @@ static void arm_smmu_remove_device(struct device *dev)
> return;
>
> iommu_device_unlink(&smmu->iommu, dev);
> - arm_smmu_master_free_smes(fwspec);
> + arm_smmu_master_free_smes(dev);
>
> arm_smmu_rpm_put(smmu);
>
> iommu_group_remove_device(dev);
> - kfree(fwspec->iommu_priv);
> iommu_fwspec_free(dev);
> + kfree(cfg);
nit: cfg is allocated after fwspec so it might be cleaner to free cfg
before fwspec.
But more importantly, should we clear the private data here and in the
other drivers, by calling dev_iommu_priv_set(dev, NULL) from
remove_device()? We are leaving stale pointers in dev->iommu and I think
some of the drivers could end up reusing them.
Thanks,
Jean
Powered by blists - more mailing lists