From: Jan Kiszka <jan.kiszka@siemens.com>
To: Bernhard Kohl <bernhard.kohl@nsn.com>
Cc: alex.williamson@redhat.com, Thomas Ostler <thomas.ostler@nsn.com>,
kvm <kvm@vger.kernel.org>, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] device-assignment: register a reset function
Date: Mon, 15 Nov 2010 13:08:44 +0100 [thread overview]
Message-ID: <4CE122CC.6050700@siemens.com> (raw)
In-Reply-To: <1289820837-24254-1-git-send-email-bernhard.kohl@nsn.com>
[Wrong list, it's not upstream yet. I'm migrating the thread to kvm.]
Am 15.11.2010 12:33, Bernhard Kohl wrote:
> This is necessary because during reboot of a VM the assigned devices
> continue DMA transfers which causes memory corruption.
>
> Signed-off-by: Thomas Ostler <thomas.ostler@nsn.com>
> Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
> ---
> Sorry for for the long delay. Finally we added Alex' suggestions
> and rebased the patch.
>
> Thanks
> Bernhard
> ---
> hw/device-assignment.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index 5f5bde1..3f8de66 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -1434,6 +1434,17 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
> dev->msix_table_page = NULL;
> }
>
> +static void reset_assigned_device(DeviceState *dev)
> +{
> + PCIDevice *d = DO_UPCAST(PCIDevice, qdev, dev);
> + uint32_t conf;
> +
> + /* reset the bus master bit to avoid further DMA transfers */
> + conf = assigned_dev_pci_read_config(d, PCI_COMMAND, 2);
> + conf &= ~PCI_COMMAND_MASTER;
> + assigned_dev_pci_write_config(d, PCI_COMMAND, conf, 2);
What about writing to /sys/bus/pci/devices/$DEVICE/reset? You probably
still need to put the command word into the reset state (ie. no RMW in
any case, just write 0), but the hardware should receive a reset as well
- if it is capable of doing a function-level reset, but we should at
least try.
> +}
> +
> static int assigned_initfn(struct PCIDevice *pci_dev)
> {
> AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
> @@ -1544,6 +1555,7 @@ static PCIDeviceInfo assign_info = {
> .qdev.name = "pci-assign",
> .qdev.desc = "pass through host pci devices to the guest",
> .qdev.size = sizeof(AssignedDevice),
> + .qdev.reset = reset_assigned_device,
> .init = assigned_initfn,
> .exit = assigned_exitfn,
> .config_read = assigned_dev_pci_read_config,
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Bernhard Kohl <bernhard.kohl@nsn.com>
Cc: alex.williamson@redhat.com, Thomas Ostler <thomas.ostler@nsn.com>,
kvm <kvm@vger.kernel.org>, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] Re: [PATCH] device-assignment: register a reset function
Date: Mon, 15 Nov 2010 13:08:44 +0100 [thread overview]
Message-ID: <4CE122CC.6050700@siemens.com> (raw)
In-Reply-To: <1289820837-24254-1-git-send-email-bernhard.kohl@nsn.com>
[Wrong list, it's not upstream yet. I'm migrating the thread to kvm.]
Am 15.11.2010 12:33, Bernhard Kohl wrote:
> This is necessary because during reboot of a VM the assigned devices
> continue DMA transfers which causes memory corruption.
>
> Signed-off-by: Thomas Ostler <thomas.ostler@nsn.com>
> Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
> ---
> Sorry for for the long delay. Finally we added Alex' suggestions
> and rebased the patch.
>
> Thanks
> Bernhard
> ---
> hw/device-assignment.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index 5f5bde1..3f8de66 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -1434,6 +1434,17 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
> dev->msix_table_page = NULL;
> }
>
> +static void reset_assigned_device(DeviceState *dev)
> +{
> + PCIDevice *d = DO_UPCAST(PCIDevice, qdev, dev);
> + uint32_t conf;
> +
> + /* reset the bus master bit to avoid further DMA transfers */
> + conf = assigned_dev_pci_read_config(d, PCI_COMMAND, 2);
> + conf &= ~PCI_COMMAND_MASTER;
> + assigned_dev_pci_write_config(d, PCI_COMMAND, conf, 2);
What about writing to /sys/bus/pci/devices/$DEVICE/reset? You probably
still need to put the command word into the reset state (ie. no RMW in
any case, just write 0), but the hardware should receive a reset as well
- if it is capable of doing a function-level reset, but we should at
least try.
> +}
> +
> static int assigned_initfn(struct PCIDevice *pci_dev)
> {
> AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
> @@ -1544,6 +1555,7 @@ static PCIDeviceInfo assign_info = {
> .qdev.name = "pci-assign",
> .qdev.desc = "pass through host pci devices to the guest",
> .qdev.size = sizeof(AssignedDevice),
> + .qdev.reset = reset_assigned_device,
> .init = assigned_initfn,
> .exit = assigned_exitfn,
> .config_read = assigned_dev_pci_read_config,
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2010-11-15 12:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-14 15:04 [PATCH] device-assignment: register a reset function Bernhard Kohl
2010-09-16 15:48 ` Alex Williamson
2010-09-17 14:14 ` Bernhard Kohl
2010-09-17 15:27 ` Bernhard Kohl
2010-09-17 16:16 ` Alex Williamson
2010-09-21 14:01 ` Bernhard Kohl
2010-11-15 11:33 ` [Qemu-devel] " Bernhard Kohl
2010-11-15 12:08 ` Jan Kiszka [this message]
2010-11-15 12:08 ` [Qemu-devel] " Jan Kiszka
2010-11-15 20:38 ` Alex Williamson
2010-11-15 21:58 ` Jan Kiszka
2010-11-16 11:39 ` Bernhard Kohl
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=4CE122CC.6050700@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=alex.williamson@redhat.com \
--cc=bernhard.kohl@nsn.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=thomas.ostler@nsn.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 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.