From: Tom Lyon <pugs@lyon-about.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: pugs@ieee.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, qemu-devel@nongnu.org,
chrisw@redhat.com, aafabbri@cisco.com, dwang2@cisco.com,
benve@cisco.com
Subject: Re: [PATCH] vfio: Add an ioctl to reset the device
Date: Tue, 19 Apr 2011 16:23:05 -0700 [thread overview]
Message-ID: <201104191623.06156.pugs@lyon-about.com> (raw)
In-Reply-To: <20110419203234.4254.94914.stgit@s20.home>
On Tuesday, April 19, 2011 01:32:59 pm Alex Williamson wrote:
> When using VFIO to assign a device to a guest, we want to make sure
> the device is quiesced on VM reset to stop all DMA within the guest
> mapped memory. Add an ioctl which just calls pci_reset_function()
> and returns whether it succeeds.
>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>
> We've recently needed to add this functionality for current KVM
> based device assignment, VFIO should provide a way to do this too.
> An example of it being used in the Qemu VFIO driver can be found
> here:
>
> https://github.com/awilliam/qemu-vfio/blob/vfio/hw/vfio.c
>
> drivers/vfio/vfio_main.c | 4 ++++
> include/linux/vfio.h | 3 +++
> 2 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
> index 7e427fc..b9bb692 100644
> --- a/drivers/vfio/vfio_main.c
> +++ b/drivers/vfio/vfio_main.c
> @@ -490,6 +490,10 @@ static long vfio_unl_ioctl(struct file *filep,
> ret = vfio_irq_eoi_eventfd(vdev, fd);
> break;
>
> + case VFIO_RESET_FUNCTION:
> + ret = pci_reset_function(vdev->pdev);
> + break;
> +
> default:
> return -EINVAL;
> }
> diff --git a/include/linux/vfio.h b/include/linux/vfio.h
> index f07d8fe..47d9bb9 100644
> --- a/include/linux/vfio.h
> +++ b/include/linux/vfio.h
> @@ -215,6 +215,9 @@ struct vfio_dma_map {
> /* Re-enable INTx via eventfd */
> #define VFIO_IRQ_EOI_EVENTFD _IOW(';', 110, int)
>
> +/* Reset PCI function */
> +#define VFIO_RESET_FUNCTION _IO(';', 111)
> +
> /*
> * Reads, writes, and mmaps determine which PCI BAR (or config space)
> * from the high level bits of the file offset
Applied.
WARNING: multiple messages have this Message-ID (diff)
From: Tom Lyon <pugs@lyon-about.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: chrisw@redhat.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, qemu-devel@nongnu.org,
aafabbri@cisco.com, dwang2@cisco.com, pugs@ieee.org,
benve@cisco.com
Subject: Re: [Qemu-devel] [PATCH] vfio: Add an ioctl to reset the device
Date: Tue, 19 Apr 2011 16:23:05 -0700 [thread overview]
Message-ID: <201104191623.06156.pugs@lyon-about.com> (raw)
In-Reply-To: <20110419203234.4254.94914.stgit@s20.home>
On Tuesday, April 19, 2011 01:32:59 pm Alex Williamson wrote:
> When using VFIO to assign a device to a guest, we want to make sure
> the device is quiesced on VM reset to stop all DMA within the guest
> mapped memory. Add an ioctl which just calls pci_reset_function()
> and returns whether it succeeds.
>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>
> We've recently needed to add this functionality for current KVM
> based device assignment, VFIO should provide a way to do this too.
> An example of it being used in the Qemu VFIO driver can be found
> here:
>
> https://github.com/awilliam/qemu-vfio/blob/vfio/hw/vfio.c
>
> drivers/vfio/vfio_main.c | 4 ++++
> include/linux/vfio.h | 3 +++
> 2 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
> index 7e427fc..b9bb692 100644
> --- a/drivers/vfio/vfio_main.c
> +++ b/drivers/vfio/vfio_main.c
> @@ -490,6 +490,10 @@ static long vfio_unl_ioctl(struct file *filep,
> ret = vfio_irq_eoi_eventfd(vdev, fd);
> break;
>
> + case VFIO_RESET_FUNCTION:
> + ret = pci_reset_function(vdev->pdev);
> + break;
> +
> default:
> return -EINVAL;
> }
> diff --git a/include/linux/vfio.h b/include/linux/vfio.h
> index f07d8fe..47d9bb9 100644
> --- a/include/linux/vfio.h
> +++ b/include/linux/vfio.h
> @@ -215,6 +215,9 @@ struct vfio_dma_map {
> /* Re-enable INTx via eventfd */
> #define VFIO_IRQ_EOI_EVENTFD _IOW(';', 110, int)
>
> +/* Reset PCI function */
> +#define VFIO_RESET_FUNCTION _IO(';', 111)
> +
> /*
> * Reads, writes, and mmaps determine which PCI BAR (or config space)
> * from the high level bits of the file offset
Applied.
next prev parent reply other threads:[~2011-04-19 23:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-19 20:32 [PATCH] vfio: Add an ioctl to reset the device Alex Williamson
2011-04-19 20:32 ` [Qemu-devel] " Alex Williamson
2011-04-19 21:40 ` Randy Dunlap
2011-04-19 21:40 ` [Qemu-devel] " Randy Dunlap
2011-04-19 21:43 ` Chris Wright
2011-04-19 21:43 ` [Qemu-devel] " Chris Wright
2011-04-19 22:07 ` Chris Wright
2011-04-19 22:07 ` [Qemu-devel] " Chris Wright
2011-04-19 22:22 ` Alex Williamson
2011-04-19 22:22 ` [Qemu-devel] " Alex Williamson
2011-04-19 22:26 ` Chris Wright
2011-04-19 22:26 ` [Qemu-devel] " Chris Wright
2011-04-19 22:30 ` Alex Williamson
2011-04-19 22:30 ` [Qemu-devel] " Alex Williamson
2011-04-19 22:37 ` Chris Wright
2011-04-19 22:37 ` [Qemu-devel] " Chris Wright
2011-04-19 23:23 ` Tom Lyon [this message]
2011-04-19 23:23 ` Tom Lyon
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=201104191623.06156.pugs@lyon-about.com \
--to=pugs@lyon-about.com \
--cc=aafabbri@cisco.com \
--cc=alex.williamson@redhat.com \
--cc=benve@cisco.com \
--cc=chrisw@redhat.com \
--cc=dwang2@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=pugs@ieee.org \
--cc=qemu-devel@nongnu.org \
/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.