From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"Liu, Yi L" <yi.l.liu@intel.com>,
"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
"will@kernel.org" <will@kernel.org>,
"joro@8bytes.org" <joro@8bytes.org>,
"shameerali.kolothum.thodi@huawei.com"
<shameerali.kolothum.thodi@huawei.com>,
"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC v2 0/3] Add set_dev_data and unset_dev_data support
Date: Fri, 21 Apr 2023 11:19:20 -0700 [thread overview]
Message-ID: <ZELTqCK4lcAkf/ti@Asurada-Nvidia> (raw)
In-Reply-To: <ZELPCTOEgU8XlhFh@nvidia.com>
On Fri, Apr 21, 2023 at 02:59:37PM -0300, Jason Gunthorpe wrote:
> On Fri, Apr 21, 2023 at 10:37:22AM -0700, Nicolin Chen wrote:
>
> > How about the following piece? Needs a test with QEMU though..
> >
> > static const size_t iommufd_device_data_size[] = {
> > [IOMMU_HW_INFO_TYPE_NONE] = 0,
> > [IOMMU_HW_INFO_TYPE_INTEL_VTD] = 0,
> > [IOMMU_HW_INFO_TYPE_ARM_SMMUV3] =
> > sizeof(struct iommu_device_data_arm_smmuv3),
> > };
>
> If we need more than one of these things we'll need a better
> solution..
How about adding ops->device_data_size to store the value?
And, since we have a few size arrays in hw_pagetable.c too,
perhaps a new structure in ops packing all these sizes can
clean up a bit things too? For example,
static struct iommu_user_data_size arm_smmu_user_data_size = {
.device_data_size = sizeof(iommu_device_data_arm_smmuv3),
.hwpt_alloc_data_size = sizeof(iommu_hwpt_alloc_arm_smmuv3),
.hwpt_invalidate_data_size = sizeof(iommu_hwpt_invalidate_arm_smmuv3),
}
The hwpt_xxx_data_size might be in form of arrays for multi-
HWPT_TYPE support.
> > rc = ops->set_dev_data_user(idev->dev, data);
>
> Where will the iommu driver store the vsid to sid xarray from these
> arguments?
The ARM structure packs a vsid. For example:
static int arm_smmu_set_data(struct device *dev, const void *user_data)
{
const struct iommufd_device_data_arm_smmuv3 *data = user_data;
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
struct arm_smmu_stream *stream = &master->streams[0];
struct arm_smmu_device *smmu = master->smmu;
u32 sid_user = data->sid;
int ret = 0;
if (!sid_user)
return -EINVAL;
ret = xa_alloc(&smmu->streams_user, &sid_user, stream,
XA_LIMIT(sid_user, sid_user), GFP_KERNEL_ACCOUNT);
if (ret)
return ret;
stream->id_user = sid_user;
return 0;
}
Thanks
Nic
next prev parent reply other threads:[~2023-04-21 18:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 7:47 [PATCH RFC v2 0/3] Add set_dev_data and unset_dev_data support Nicolin Chen
2023-04-20 7:47 ` [PATCH RFC v2 1/3] iommu: Add set/unset_dev_data_user ops Nicolin Chen
2023-04-20 7:47 ` [PATCH RFC v2 2/3] iommufd: Add iommufd_device_set_data and iommufd_device_unset_data APIs Nicolin Chen
2023-04-20 7:47 ` [PATCH RFC v2 3/3] vfio: Add dev_data_len/uptr in struct vfio_device_bind_iommufd Nicolin Chen
2023-04-21 7:35 ` [PATCH RFC v2 0/3] Add set_dev_data and unset_dev_data support Tian, Kevin
2023-04-21 7:41 ` Nicolin Chen
2023-04-21 7:47 ` Tian, Kevin
2023-04-21 7:56 ` Nicolin Chen
2023-04-21 8:07 ` Tian, Kevin
2023-04-21 8:20 ` Nicolin Chen
2023-04-21 13:09 ` Jason Gunthorpe
2023-04-21 17:37 ` Nicolin Chen
2023-04-21 17:59 ` Jason Gunthorpe
2023-04-21 18:19 ` Nicolin Chen [this message]
2023-04-23 7:44 ` 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=ZELTqCK4lcAkf/ti@Asurada-Nvidia \
--to=nicolinc@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=baolu.lu@linux.intel.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox