mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Farhan Ali <alifm@linux.ibm.com>
To: Matthew Rosato <mjrosato@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org
Cc: helgaas@kernel.org, lukas@wunner.de, alex@shazbot.org,
	clg@redhat.com, kbusch@kernel.org, schnelle@linux.ibm.com
Subject: Re: [PATCH v12 5/7] vfio-pci/zdev: Add a device feature for error information
Date: Tue, 31 Mar 2026 12:27:05 -0700	[thread overview]
Message-ID: <c66f25ac-6fe6-4d3c-8005-0e09c94613b8@linux.ibm.com> (raw)
In-Reply-To: <e17202d6-8ec8-433f-ac45-77c1744bc92c@linux.ibm.com>


On 3/31/2026 10:42 AM, Matthew Rosato wrote:
> On 3/30/26 1:40 PM, Farhan Ali wrote:
>> For zPCI devices, we have platform specific error information. The platform
>> firmware provides this error information to the operating system in an
>> architecture specific mechanism. To enable recovery from userspace for
>> these devices, we want to expose this error information to userspace. Add a
>> new device feature to expose this information.
>>
>> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
>
> Nits and a questions below
>
>
>> +int vfio_pci_zdev_feature_err(struct vfio_device *device, u32 flags,
>> +			      void __user *arg, size_t argsz)
>> +{
>> +	struct vfio_device_feature_zpci_err err = {};
>> +	struct vfio_pci_core_device *vdev;
>> +	struct zpci_dev *zdev;
>> +	int head = 0;
>> +	int ret;
>> +
>> +	vdev = container_of(device, struct vfio_pci_core_device, vdev);
>> +	zdev = to_zpci(vdev->pdev);
>> +	if (!zdev)
>> +		return -ENODEV;
>> +
>> +	ret = vfio_check_feature(flags, argsz, VFIO_DEVICE_FEATURE_GET,
>> +				 sizeof(err));
>> +	if (ret != 1)
>> +		return ret;
>> +
>> +	mutex_lock(&zdev->pending_errs_lock);
>> +	if (zdev->pending_errs.count) {
>> +		head = zdev->pending_errs.head % ZPCI_ERR_PENDING_MAX;
>> +		err.pec = zdev->pending_errs.err[head].pec;
>> +		zdev->pending_errs.head++;
>> +		zdev->pending_errs.count--;
>> +		err.pending_errors = zdev->pending_errs.count;
>> +	}
>> +	mutex_unlock(&zdev->pending_errs_lock);
>> +
> Question: intentionally dropping so we don't hold over the copy_to_user?
>   That makes sense to me; but if not then may as well use guard(mutex)
> here too.  Does not affect my review tag.

Yes, exactly. I didn't see a need to hold the lock over copy_to_user().

Thanks

Farhan

>
>> +	err.version = 1;
>> +	if (copy_to_user(arg, &err, sizeof(err)))
>> +		return -EFAULT;
>> +
>> +	return 0;
>> +}
>> +
>>   int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
>>   {
>>   	struct zpci_dev *zdev = to_zpci(vdev->pdev);
>> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
>> index bb7b89330d35..2552eef42000 100644
>> --- a/include/uapi/linux/vfio.h
>> +++ b/include/uapi/linux/vfio.h
>> @@ -1510,6 +1510,24 @@ struct vfio_device_feature_dma_buf {
>>   	struct vfio_region_dma_range dma_ranges[] __counted_by(nr_ranges);
>>   };
>>   
>> +/**
>> + * VFIO_DEVICE_FEATURE_ZPCI_ERROR feature provides PCI error information to
>> + * userspace for vfio-pci devices on s390x. On s390x PCI error recovery
> 'On s390x, PCI error...' (suggest comma)
>
>> + * involves platform firmware and notification to operating system is done
>> + * by architecture specific mechanism. Exposing this information to
>> + * userspace allows userspace to take appropriate actions to handle an
> 'userspace allows it to take...' (reduce repetition of the word userspace)
>
>> + * error on the device. The pending_errors provide any additional errors
>> + * pending for the device, and userspace should read until zero.
>> + */
>> +
>> +struct vfio_device_feature_zpci_err {
>> +	__u8 version;
>> +	__u8 pending_errors;
>> +	__u16 pec;
>> +};
>> +
>> +#define VFIO_DEVICE_FEATURE_ZPCI_ERROR 12
>> +
>>   /* -------- API for Type1 VFIO IOMMU -------- */
>>   
>>   /**

  reply	other threads:[~2026-03-31 19:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 17:40 [PATCH v12 0/7] Error recovery for vfio-pci devices on s390x Farhan Ali
2026-03-30 17:40 ` [PATCH v12 1/7] PCI: Allow per function PCI slots to fix slot reset on s390 Farhan Ali
2026-03-30 17:40 ` [PATCH v12 2/7] PCI: Avoid saving config space state if inaccessible Farhan Ali
2026-04-07 19:56   ` Bjorn Helgaas
2026-04-07 21:17     ` Farhan Ali
2026-04-07 21:32       ` Bjorn Helgaas
2026-04-07 22:02         ` Farhan Ali
2026-03-30 17:40 ` [PATCH v12 3/7] PCI: Fail FLR when config space is inaccessible Farhan Ali
2026-03-30 17:40 ` [PATCH v12 4/7] s390/pci: Store PCI error information for passthrough devices Farhan Ali
2026-03-31 17:41   ` Matthew Rosato
2026-03-31 19:23     ` Farhan Ali
2026-03-31 19:29       ` Matthew Rosato
2026-04-07 15:38   ` Alex Williamson
2026-04-07 18:00     ` Farhan Ali
2026-04-07 18:23       ` Alex Williamson
2026-03-30 17:40 ` [PATCH v12 5/7] vfio-pci/zdev: Add a device feature for error information Farhan Ali
2026-03-31 17:42   ` Matthew Rosato
2026-03-31 19:27     ` Farhan Ali [this message]
2026-04-07 15:53   ` Alex Williamson
2026-04-07 18:13     ` Farhan Ali
2026-04-07 18:27       ` Alex Williamson
2026-03-30 17:40 ` [PATCH v12 6/7] vfio/pci: Add a reset_done callback for vfio-pci driver Farhan Ali
2026-03-31 17:43   ` Matthew Rosato
2026-03-30 17:40 ` [PATCH v12 7/7] vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX Farhan Ali
2026-04-07 15:58   ` Alex Williamson
2026-04-06 17:23 ` [PATCH v12 0/7] Error recovery for vfio-pci devices on s390x Farhan Ali

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=c66f25ac-6fe6-4d3c-8005-0e09c94613b8@linux.ibm.com \
    --to=alifm@linux.ibm.com \
    --cc=alex@shazbot.org \
    --cc=clg@redhat.com \
    --cc=helgaas@kernel.org \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mjrosato@linux.ibm.com \
    --cc=schnelle@linux.ibm.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

all inboxes | Powered by JetHome®