[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z73yt4r0iDFwbty2@Asurada-Nvidia>
Date: Tue, 25 Feb 2025 08:41:27 -0800
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: Pranjal Shrivastava <praan@...gle.com>, <kevin.tian@...el.com>,
<corbet@....net>, <will@...nel.org>, <joro@...tes.org>,
<suravee.suthikulpanit@....com>, <robin.murphy@....com>,
<dwmw2@...radead.org>, <baolu.lu@...ux.intel.com>, <shuah@...nel.org>,
<linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kselftest@...r.kernel.org>,
<linux-doc@...r.kernel.org>, <eric.auger@...hat.com>,
<jean-philippe@...aro.org>, <mdf@...nel.org>, <mshavit@...gle.com>,
<shameerali.kolothum.thodi@...wei.com>, <smostafa@...gle.com>,
<ddutile@...hat.com>, <yi.l.liu@...el.com>, <patches@...ts.linux.dev>
Subject: Re: [PATCH v7 12/14] iommu/arm-smmu-v3: Introduce struct
arm_smmu_vmaster
On Tue, Feb 25, 2025 at 12:02:25PM -0400, Jason Gunthorpe wrote:
> On Mon, Feb 24, 2025 at 03:45:33PM -0800, Nicolin Chen wrote:
>
> > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
> > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
> > @@ -95,8 +95,6 @@ int arm_smmu_attach_prepare_vmaster(struct arm_smmu_attach_state *state,
> >
> > iommu_group_mutex_assert(state->master->dev);
> >
> > - if (domain->type != IOMMU_DOMAIN_NESTED)
> > - return 0;
> > nested_domain = to_smmu_nested_domain(domain);
> >
> > /* Skip invalid vSTE */
> > @@ -122,19 +120,9 @@ void arm_smmu_attach_commit_vmaster(struct arm_smmu_attach_state *state)
> > {
> > struct arm_smmu_master *master = state->master;
> >
> > - mutex_lock(&master->smmu->streams_mutex);
> > - if (state->vmaster != master->vmaster) {
> > - kfree(master->vmaster);
> > - master->vmaster = state->vmaster;
> > - }
> > - mutex_unlock(&master->smmu->streams_mutex);
> > -}
> > -
> > -void arm_smmu_master_clear_vmaster(struct arm_smmu_master *master)
> > -{
> > mutex_lock(&master->smmu->streams_mutex);
> > kfree(master->vmaster);
> > - master->vmaster = NULL;
> > + master->vmaster = state->vmaster;
> > mutex_unlock(&master->smmu->streams_mutex);
> > }
>
> I'd leave the clear_vmaster just for clarity. Commit should not be
> unpaired with prepare in the other functions.
>
> It looks fine with this on top too
>
> Reviewed-by: Jason Gunthorpe <jgg@...dia.com>
Ack. I added it back and a #ifdef to the vmaster:
+void arm_smmu_master_clear_vmaster(struct arm_smmu_master *master)
+{
+ struct arm_smmu_attach_state state = { .master = master };
+
+ arm_smmu_attach_commit_vmaster(&state);
+}
[...]
@@ -824,6 +829,9 @@ struct arm_smmu_master {
struct arm_smmu_device *smmu;
struct device *dev;
struct arm_smmu_stream *streams;
+#ifdef CONFIG_ARM_SMMU_V3_IOMMUFD
+ struct arm_smmu_vmaster *vmaster; /* use smmu->streams_mutex */
+#endif
/* Locked by the iommu core using the group mutex */
struct arm_smmu_ctx_desc_cfg cd_table;
unsigned int num_streams;
@@ -972,6 +980,9 @@ struct arm_smmu_attach_state {
bool disable_ats;
ioasid_t ssid;
/* Resulting state */
+#ifdef CONFIG_ARM_SMMU_V3_IOMMUFD
+ struct arm_smmu_vmaster *vmaster;
+#endif
bool ats_enabled;
};
Thanks
Nicolin
Powered by blists - more mailing lists