LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pierre Morel <pmorel@linux.ibm.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: sebott@linux.vnet.ibm.com, gerald.schaefer@de.ibm.com,
pasic@linux.vnet.ibm.com, borntraeger@de.ibm.com,
walling@linux.ibm.com, linux-s390@vger.kernel.org,
iommu@lists.linux-foundation.org, joro@8bytes.org,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com
Subject: Re: [PATCH 4/4] vfio: vfio_iommu_type1: implement VFIO_IOMMU_INFO_CAPABILITIES
Date: Fri, 17 May 2019 10:17:17 +0200 [thread overview]
Message-ID: <29209ea1-be49-47bc-c258-6e87da055fac@linux.ibm.com> (raw)
In-Reply-To: <20190516124026.415bf671@x1.home>
On 16/05/2019 20:40, Alex Williamson wrote:
> On Fri, 10 May 2019 10:22:35 +0200
> Pierre Morel <pmorel@linux.ibm.com> wrote:
>
>> We implement a capability intercafe for VFIO_IOMMU_GET_INFO and add the
>> first capability: VFIO_IOMMU_INFO_CAPABILITIES.
>>
>> When calling the ioctl, the user must specify
>> VFIO_IOMMU_INFO_CAPABILITIES to retrieve the capabilities and must check
>> in the answer if capabilities are supported.
>> Older kernel will not check nor set the VFIO_IOMMU_INFO_CAPABILITIES in
>> the flags of vfio_iommu_type1_info.
>>
>> The iommu get_attr callback will be called to retrieve the specific
>> attributes and fill the capabilities, VFIO_IOMMU_INFO_CAP_QFN for the
>> PCI query function attributes and VFIO_IOMMU_INFO_CAP_QGRP for the
>> PCI query function group.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>> drivers/vfio/vfio_iommu_type1.c | 95 ++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 94 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
>> index d0f731c..f7f8120 100644
>> --- a/drivers/vfio/vfio_iommu_type1.c
>> +++ b/drivers/vfio/vfio_iommu_type1.c
>> @@ -1658,6 +1658,70 @@ static int vfio_domains_have_iommu_cache(struct vfio_iommu *iommu)
>> return ret;
>> }
>>
>> +int vfio_iommu_type1_caps(struct vfio_iommu *iommu, struct vfio_info_cap *caps,
>> + size_t size)
>> +{
>> + struct vfio_domain *d;
>> + struct vfio_iommu_type1_info_block *info_fn;
>> + struct vfio_iommu_type1_info_block *info_grp;
>> + unsigned long total_size, fn_size, grp_size;
>> + int ret;
>> +
>> + d = list_first_entry(&iommu->domain_list, struct vfio_domain, next);
>> + if (!d)
>> + return -ENODEV;
>> + /* The size of these capabilities are device dependent */
>> + fn_size = iommu_domain_get_attr(d->domain,
>> + DOMAIN_ATTR_ZPCI_FN_SIZE, NULL);
>> + if (fn_size < 0)
>> + return fn_size;
>
> What if non-Z archs want to use this? The function is architected
> specifically for this one use case, fail if any component is not there
> which means it requires a re-write to add further support. If
> ZPCI_FN_SIZE isn't support, move on to the next thing.
yes, clear.
>
>> + fn_size += sizeof(struct vfio_info_cap_header);
>> + total_size = fn_size;
>
> Here too, total_size should be initialized to zero and each section +=
> the size they'd like to add.
thanks, clear too.
>
>> +
>> + grp_size = iommu_domain_get_attr(d->domain,
>> + DOMAIN_ATTR_ZPCI_GRP_SIZE, NULL);
>> + if (grp_size < 0)
>> + return grp_size;
>> + grp_size += sizeof(struct vfio_info_cap_header);
>> + total_size += grp_size;
>> +
>> + /* Tell caller to call us with a greater buffer */
>> + if (total_size > size) {
>> + caps->size = total_size;
>> + return 0;
>> + }
>> +
>> + info_fn = kzalloc(fn_size, GFP_KERNEL);
>> + if (!info_fn)
>> + return -ENOMEM;
>
> Maybe fn_size was zero because we're not on Z.
>
>> + ret = iommu_domain_get_attr(d->domain,
>> + DOMAIN_ATTR_ZPCI_FN, &info_fn->data);
>
> Kernel internal structures != user api. Thanks,
>
> Alex
Thanks a lot Alex,
I understand the concerns, I was too focussed on Z, I will rework this
as you said:
- definition of the user API and
- take care that another architecture may want to use the interface.
Regards,
Pierre
--
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany
prev parent reply other threads:[~2019-05-17 8:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 8:22 [PATCH 0/4] Retrieving zPCI specific info with VFIO Pierre Morel
2019-05-10 8:22 ` [PATCH 1/4] s390: pci: Exporting access to CLP PCI function and PCI group Pierre Morel
2019-05-10 10:21 ` Robin Murphy
2019-05-10 14:45 ` Pierre Morel
2019-05-10 8:22 ` [PATCH 2/4] vfio: vfio_iommu_type1: Define VFIO_IOMMU_INFO_CAPABILITIES Pierre Morel
2019-05-16 14:57 ` Christian Borntraeger
2019-05-16 18:54 ` Alex Williamson
2019-05-16 18:31 ` Alex Williamson
2019-05-17 8:18 ` Pierre Morel
2019-05-10 8:22 ` [PATCH 3/4] s390: iommu: Adding get attributes for s390_iommu Pierre Morel
2019-05-10 8:22 ` [PATCH 4/4] vfio: vfio_iommu_type1: implement VFIO_IOMMU_INFO_CAPABILITIES Pierre Morel
2019-05-16 18:40 ` Alex Williamson
2019-05-17 8:17 ` Pierre Morel [this message]
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=29209ea1-be49-47bc-c258-6e87da055fac@linux.ibm.com \
--to=pmorel@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=gerald.schaefer@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.vnet.ibm.com \
--cc=schwidefsky@de.ibm.com \
--cc=sebott@linux.vnet.ibm.com \
--cc=walling@linux.ibm.com \
--subject='Re: [PATCH 4/4] vfio: vfio_iommu_type1: implement VFIO_IOMMU_INFO_CAPABILITIES' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).