From: Jan Kiszka <jan.kiszka@web.de>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: linux-pci@vger.kernel.org, kvm@vger.kernel.org, avi@redhat.com,
jbarnes@virtuousgeek.org
Subject: Re: [PATCH 2/2] KVM: Use pci_store/load_saved_state() around VM device usage
Date: Fri, 15 Apr 2011 22:03:31 +0200 [thread overview]
Message-ID: <4DA8A493.8000509@web.de> (raw)
In-Reply-To: <20110415195439.2838.58928.stgit@s20.home>
[-- Attachment #1: Type: text/plain, Size: 2233 bytes --]
On 2011-04-15 21:54, Alex Williamson wrote:
> Store the device saved state so that we can reload the device back
> to the original state when it's unassigned. This has the benefit
> that the state survives across pci_reset_function() calls via
> the PCI sysfs reset interface while the VM is using the device.
>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>
> include/linux/kvm_host.h | 1 +
> virt/kvm/assigned-dev.c | 8 +++++---
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index ab42855..d8a1d18 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -513,6 +513,7 @@ struct kvm_assigned_dev_kernel {
> struct kvm *kvm;
> spinlock_t intx_lock;
> char irq_name[32];
> + void *pci_saved_state;
> };
>
> struct kvm_irq_mask_notifier {
> diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
> index ae72ae6..66c6ccd 100644
> --- a/virt/kvm/assigned-dev.c
> +++ b/virt/kvm/assigned-dev.c
> @@ -197,7 +197,9 @@ static void kvm_free_assigned_device(struct kvm *kvm,
> {
> kvm_free_assigned_irq(kvm, assigned_dev);
>
> - __pci_reset_function(assigned_dev->dev);
> + pci_reset_function(assigned_dev->dev);
> + pci_load_and_free_saved_state(assigned_dev->dev,
> + &assigned_dev->pci_saved_state);
> pci_restore_state(assigned_dev->dev);
>
> pci_release_regions(assigned_dev->dev);
> @@ -516,7 +518,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
>
> pci_reset_function(dev);
> pci_save_state(dev);
> -
> + match->pci_saved_state = pci_store_saved_state(dev);
> match->assigned_dev_id = assigned_dev->assigned_dev_id;
> match->host_segnr = assigned_dev->segnr;
> match->host_busnr = assigned_dev->busnr;
> @@ -546,7 +548,7 @@ out:
> mutex_unlock(&kvm->lock);
> return r;
> out_list_del:
> - pci_restore_state(dev);
> + pci_load_and_free_saved_state(dev, &match->pci_saved_state);
Don't you need to keep the balance, ie. load_and_free, then restore?
> list_del(&match->list);
> pci_release_regions(dev);
> out_disable:
>
Thanks for addressing the issue!
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
next prev parent reply other threads:[~2011-04-15 20:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-15 19:54 [PATCH 0/2] Store and load PCI device saved state across function resets Alex Williamson
2011-04-15 19:54 ` [PATCH 1/2] PCI: Add interfaces to store and load the device saved state Alex Williamson
2011-04-17 9:23 ` Avi Kivity
2011-04-18 19:44 ` Alex Williamson
2011-04-15 19:54 ` [PATCH 2/2] KVM: Use pci_store/load_saved_state() around VM device usage Alex Williamson
2011-04-15 20:03 ` Jan Kiszka [this message]
2011-04-15 20:13 ` Alex Williamson
2011-04-15 20:28 ` Jan Kiszka
2011-04-17 9:25 ` Avi Kivity
2011-04-18 19:43 ` Alex Williamson
2011-04-20 7:19 ` Avi Kivity
2011-04-20 15:13 ` Alex Williamson
2011-04-20 15:27 ` Avi Kivity
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=4DA8A493.8000509@web.de \
--to=jan.kiszka@web.de \
--cc=alex.williamson@redhat.com \
--cc=avi@redhat.com \
--cc=jbarnes@virtuousgeek.org \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.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 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).