All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: "jgg@nvidia.com" <jgg@nvidia.com>,
	"will@kernel.org" <will@kernel.org>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"ddutile@redhat.com" <ddutile@redhat.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"jsnitsel@redhat.com" <jsnitsel@redhat.com>,
	"praan@google.com" <praan@google.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"patches@lists.linux.dev" <patches@lists.linux.dev>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>
Subject: Re: [PATCH v1 07/12] iommu/arm-smmu-v3: Implement arm_smmu_get_viommu_size and arm_vsmmu_init
Date: Thu, 12 Jun 2025 10:18:18 -0700	[thread overview]
Message-ID: <aEsL2mxfO0x3isog@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB52764E40612C1293699E43F98C74A@BN9PR11MB5276.namprd11.prod.outlook.com>

On Thu, Jun 12, 2025 at 08:20:30AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc@nvidia.com>
> > Sent: Tuesday, June 10, 2025 1:14 AM
> > 
> > +int arm_smmu_get_viommu_size(enum iommu_viommu_type
> > viommu_type,
> > +			     struct device *dev, size_t *viommu_size)
> > +{
> > +	struct arm_smmu_master *master = dev_iommu_priv_get(dev);
> > +	struct arm_smmu_device *smmu = master->smmu;
> > +
> > +	if (!(smmu->features & ARM_SMMU_FEAT_NESTING))
> > +		return -EOPNOTSUPP;
> > +
> > +	/*
> > +	 * FORCE_SYNC is not set with FEAT_NESTING. Some study of the
> > exact HW
> > +	 * defect is needed to determine if arm_vsmmu_cache_invalidate()
> > needs
> > +	 * any change to remove this.
> > +	 */
> > +	if (WARN_ON(smmu->options &
> > ARM_SMMU_OPT_CMDQ_FORCE_SYNC))
> > +		return -EOPNOTSUPP;
> > +
> > +	/*
> > +	 * Must support some way to prevent the VM from bypassing the
> > cache
> > +	 * because VFIO currently does not do any cache maintenance.
> > canwbs
> > +	 * indicates the device is fully coherent and no cache maintenance is
> > +	 * ever required, even for PCI No-Snoop. S2FWB means the S1 can't
> > make
> > +	 * things non-coherent using the memattr, but No-Snoop behavior is
> > not
> > +	 * effected.
> > +	 */
> > +	if (!arm_smmu_master_canwbs(master) &&
> > +	    !(smmu->features & ARM_SMMU_FEAT_S2FWB))
> > +		return -EOPNOTSUPP;
> > +
> > +	if (viommu_type != IOMMU_VIOMMU_TYPE_ARM_SMMUV3)
> > +		return -EOPNOTSUPP;
> 
> it's more intuitive to check it first.

Agreed. But I kinda intentionally left it here. The SMMU driver
will have something like an impl_op->get_viommu_size in the HW
queue series. That can simply insert a piece:
===============================================================
@@ -415,6 +415,12 @@ int arm_smmu_get_viommu_size(enum iommu_viommu_type viommu_type,
            !(smmu->features & ARM_SMMU_FEAT_S2FWB))
                return -EOPNOTSUPP;

+       if (smmu->impl_ops && smmu->impl_ops->vsmmu_size &&
+           viommu_type == smmu->impl_ops->vsmmu_type) {
+               *viommu_size = smmu->impl_ops->vsmmu_size;
+               return 0;
+       }
+
        if (viommu_type != IOMMU_VIOMMU_TYPE_ARM_SMMUV3)
                return -EOPNOTSUPP;

===============================================================

Otherwise, this following patch has to move the type check again.

> btw does it make sense to also add below here?
> 	if (s2_parent->smmu != master->smmu)
> 		return ERR_PTR(-EINVAL);

I can't find a legit reason to forward the s2_parent to run this
sanity. "struct device *" is forwarded since the driver needs to
know the smmu pointer: A for the compatibility checks; b for the
smmu->impl_ops mentioned above.

Thanks
Nicolin


  reply	other threads:[~2025-06-12 19:47 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09 17:13 [PATCH v1 00/12] iommufd: Repare for IOMMUFD_OBJ_HW_QUEUE Nicolin Chen
2025-06-09 17:13 ` [PATCH v1 01/12] iommufd: Apply obvious cosmetic fixes Nicolin Chen
2025-06-09 17:13 ` [PATCH v1 02/12] iommufd: Drop unused ictx in struct iommufd_vdevice Nicolin Chen
2025-06-12  8:06   ` Tian, Kevin
2025-06-13 13:36   ` Jason Gunthorpe
2025-06-09 17:13 ` [PATCH v1 03/12] iommufd: Use enum iommu_viommu_type for type in struct iommufd_viommu Nicolin Chen
2025-06-12  8:06   ` Tian, Kevin
2025-06-13 13:36   ` Jason Gunthorpe
2025-06-09 17:13 ` [PATCH v1 04/12] iommufd: Use enum iommu_veventq_type for type in struct iommufd_veventq Nicolin Chen
2025-06-12  8:07   ` Tian, Kevin
2025-06-13 13:36   ` Jason Gunthorpe
2025-06-09 17:13 ` [PATCH v1 05/12] iommu: Introduce get_viommu_size and viommu_init ops Nicolin Chen
2025-06-12  8:12   ` Tian, Kevin
2025-06-12 17:06     ` Nicolin Chen
2025-06-13  7:33       ` Tian, Kevin
2025-06-13 13:41   ` Jason Gunthorpe
2025-06-13 20:45     ` Nicolin Chen
2025-06-09 17:13 ` [PATCH v1 06/12] iommufd/selftest: Implement mock_get_viommu_size and mock_viommu_init Nicolin Chen
2025-06-12  8:17   ` Tian, Kevin
2025-06-12 17:12     ` Nicolin Chen
2025-06-13  7:34       ` Tian, Kevin
2025-06-13 13:45   ` Jason Gunthorpe
2025-06-13 20:19     ` Nicolin Chen
2025-06-13 23:23       ` Jason Gunthorpe
2025-06-13 23:37         ` Nicolin Chen
2025-06-09 17:13 ` [PATCH v1 07/12] iommu/arm-smmu-v3: Implement arm_smmu_get_viommu_size and arm_vsmmu_init Nicolin Chen
2025-06-12  8:20   ` Tian, Kevin
2025-06-12 17:18     ` Nicolin Chen [this message]
2025-06-13  7:36       ` Tian, Kevin
2025-06-09 17:13 ` [PATCH v1 08/12] iommufd/viommu: Replace ops->viommu_alloc with ops->viommu_init Nicolin Chen
2025-06-10  5:55   ` Baolu Lu
2025-06-10  6:19     ` Nicolin Chen
2025-06-12  8:22       ` Tian, Kevin
2025-06-12 17:35         ` Nicolin Chen
2025-06-12  8:27   ` Tian, Kevin
2025-06-12 17:24     ` Nicolin Chen
2025-06-09 17:13 ` [PATCH v1 09/12] iommu: Deprecate viommu_alloc op Nicolin Chen
2025-06-12  8:23   ` Tian, Kevin
2025-06-09 17:13 ` [PATCH v1 10/12] iommufd: Move _iommufd_object_alloc out of driver.c Nicolin Chen
2025-06-12  8:23   ` Tian, Kevin
2025-06-13 13:46   ` Jason Gunthorpe
2025-06-09 17:13 ` [PATCH v1 11/12] iommufd: Introduce iommufd_object_alloc_ucmd helper Nicolin Chen
2025-06-13 13:58   ` Jason Gunthorpe
2025-06-13 23:17     ` Nicolin Chen
2025-06-09 17:13 ` [PATCH v1 12/12] iommufd: Apply the new " Nicolin Chen
2025-06-10 18:32 ` [PATCH v1 00/12] iommufd: Repare for IOMMUFD_OBJ_HW_QUEUE Nicolin Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aEsL2mxfO0x3isog@nvidia.com \
    --to=nicolinc@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=ddutile@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=jsnitsel@redhat.com \
    --cc=kevin.tian@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=praan@google.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.