On Mon, Sep 19, 2011 at 03:27:38AM -0400, Amos Kong wrote:
Only func 0 is registered to guest driver (we can only found func 0 in slot->funcs list of driver), the other functions could not be cleaned when hot-removing the whole slot. This patch adds device per function in ACPI DSDT tables.
You can't unplug a single function. Guest surely knows that.
Have tested with linux/winxp/win7, hot-adding/hot-remving, single/multiple function device, they are all fine.
What was not fine before?
Have you looked at real HW that supports PCI hot plug DSDT? Does it looks the same?
new acpi-dst.hex(332K): http://amos-kong.rhcloud.com/pub/acpi-dsdt.hex
Signed-off-by: Amos Kong akong@redhat.com
src/acpi-dsdt.dsl | 31 +++++++++++++++++++++++++------ 1 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/src/acpi-dsdt.dsl b/src/acpi-dsdt.dsl index 08412e2..d1426ec 100644 --- a/src/acpi-dsdt.dsl +++ b/src/acpi-dsdt.dsl @@ -128,9 +128,9 @@ DefinitionBlock ( PCRM, 32, }
-#define hotplug_slot(name, nr) \
Device (S##name) { \
Name (_ADR, nr##0000) \
+#define hotplug_func(name, nr, adr, fn) \
Device (S##name##fn) { \
Name (_ADR, adr) \ Method (_EJ0,1) { \ Store(ShiftLeft(1, nr), B0EJ) \ Return (0x0) \
@@ -138,6 +138,16 @@ DefinitionBlock ( Name (_SUN, name) \ }
+#define hotplug_slot(name, nr) \
hotplug_func(name, nr, nr##0000, 0) \
hotplug_func(name, nr, nr##0001, 1) \
hotplug_func(name, nr, nr##0002, 2) \
hotplug_func(name, nr, nr##0003, 3) \
hotplug_func(name, nr, nr##0004, 4) \
hotplug_func(name, nr, nr##0005, 5) \
hotplug_func(name, nr, nr##0006, 6) \
hotplug_func(name, nr, nr##0007, 7)
hotplug_slot(1, 0x0001) hotplug_slot(2, 0x0002) hotplug_slot(3, 0x0003)
@@ -842,13 +852,22 @@ DefinitionBlock ( Return(0x01) }
-#define gen_pci_hotplug(nr) \ +#define gen_pci_hotplug_func(nr, fn) \ If (And(_SB.PCI0.PCIU, ShiftLeft(1, nr))) { \
Notify(\_SB.PCI0.S##nr, 1) \
Notify(\_SB.PCI0.S##nr##fn, 1) \ } \ If (And(\_SB.PCI0.PCID, ShiftLeft(1, nr))) { \
Notify(\_SB.PCI0.S##nr, 3) \
Notify(\_SB.PCI0.S##nr##fn, 3) \ }
+#define gen_pci_hotplug(nr) \
gen_pci_hotplug_func(nr, 0) \
gen_pci_hotplug_func(nr, 1) \
gen_pci_hotplug_func(nr, 2) \
gen_pci_hotplug_func(nr, 3) \
gen_pci_hotplug_func(nr, 4) \
gen_pci_hotplug_func(nr, 5) \
gen_pci_hotplug_func(nr, 6) \
gen_pci_hotplug_func(nr, 7) Method(_L01) { gen_pci_hotplug(1)
-- 1.7.6.1
SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios
-- Gleb.
On Mon, Sep 19, 2011 at 12:57:33PM +0300, Gleb Natapov wrote:
On Mon, Sep 19, 2011 at 03:27:38AM -0400, Amos Kong wrote:
Only func 0 is registered to guest driver (we can only found func 0 in slot->funcs list of driver), the other functions could not be cleaned when hot-removing the whole slot. This patch adds device per function in ACPI DSDT tables.
You can't unplug a single function. Guest surely knows that.
Looking at guest code, it's clear that at least a Linux guest doesn't know that.
Have tested with linux/winxp/win7, hot-adding/hot-remving, single/multiple function device, they are all fine.
What was not fine before?
Have you looked at real HW that supports PCI hot plug DSDT? Does it looks the same?
I recall I saw some examples like this on the net.
new acpi-dst.hex(332K): http://amos-kong.rhcloud.com/pub/acpi-dsdt.hex
Signed-off-by: Amos Kong akong@redhat.com
On Mon, Sep 19, 2011 at 01:02:59PM +0300, Michael S. Tsirkin wrote:
On Mon, Sep 19, 2011 at 12:57:33PM +0300, Gleb Natapov wrote:
On Mon, Sep 19, 2011 at 03:27:38AM -0400, Amos Kong wrote:
Only func 0 is registered to guest driver (we can only found func 0 in slot->funcs list of driver), the other functions could not be cleaned when hot-removing the whole slot. This patch adds device per function in ACPI DSDT tables.
You can't unplug a single function. Guest surely knows that.
Looking at guest code, it's clear that at least a Linux guest doesn't know that.
Have you asked relevant maintainers why is it so? Does Windows do the same? (Obviously you can't check Windows code, but you can see if removing function zero removes other functions from the device manager, or you can even try to access other function).
If I am not mistaken, with this new DSDT you will see more then one eject options in Windows GUI from each multi-function device. Is it so?
Have tested with linux/winxp/win7, hot-adding/hot-remving, single/multiple function device, they are all fine.
What was not fine before?
Have you looked at real HW that supports PCI hot plug DSDT? Does it looks the same?
I recall I saw some examples like this on the net.
Checking real HW DSDT will validate that we are doing a right thing here.
-- Gleb.
On Mon, Sep 19, 2011 at 01:12:30PM +0300, Gleb Natapov wrote:
On Mon, Sep 19, 2011 at 01:02:59PM +0300, Michael S. Tsirkin wrote:
On Mon, Sep 19, 2011 at 12:57:33PM +0300, Gleb Natapov wrote:
On Mon, Sep 19, 2011 at 03:27:38AM -0400, Amos Kong wrote:
Only func 0 is registered to guest driver (we can only found func 0 in slot->funcs list of driver), the other functions could not be cleaned when hot-removing the whole slot. This patch adds device per function in ACPI DSDT tables.
You can't unplug a single function. Guest surely knows that.
Looking at guest code, it's clear that at least a Linux guest doesn't know that.
Have you asked relevant maintainers why is it so? Does Windows do the same? (Obviously you can't check Windows code, but you can see if removing function zero removes other functions from the device manager, or you can even try to access other function).
If I am not mistaken, with this new DSDT you will see more then one eject options in Windows GUI from each multi-function device. Is it so?
Have tested with linux/winxp/win7, hot-adding/hot-remving, single/multiple function device, they are all fine.
What was not fine before?
Have you looked at real HW that supports PCI hot plug DSDT? Does it looks the same?
I recall I saw some examples like this on the net.
Checking real HW DSDT will validate that we are doing a right thing here.
According to Microsoft own documentation they want _EJ0 for each function: http://www.microsoft.com/china/whdc/system/pnppwr/hotadd/hotplugpci.mspx
-- Gleb.
On Mon, Sep 19, 2011 at 01:32:48PM +0300, Gleb Natapov wrote:
I recall I saw some examples like this on the net.
Checking real HW DSDT will validate that we are doing a right thing here.
According to Microsoft own documentation they want _EJ0 for each function: http://www.microsoft.com/china/whdc/system/pnppwr/hotadd/hotplugpci.mspx
Right, this is the link I was thinking of.
On Mon, Sep 19, 2011 at 01:02:59PM +0300, Michael S. Tsirkin wrote:
On Mon, Sep 19, 2011 at 12:57:33PM +0300, Gleb Natapov wrote:
On Mon, Sep 19, 2011 at 03:27:38AM -0400, Amos Kong wrote:
Only func 0 is registered to guest driver (we can only found func 0 in slot->funcs list of driver), the other functions could not be cleaned when hot-removing the whole slot. This patch adds device per function in ACPI DSDT tables.
You can't unplug a single function. Guest surely knows that.
Looking at guest code, it's clear that at least a Linux guest doesn't know that.
acpiphp_disable_slot function appears to eject all functions.
Have tested with linux/winxp/win7, hot-adding/hot-remving, single/multiple function device, they are all fine.
Does not work for me (FC12 guest). As mentioned previously, Linux driver looks for function 0 when injection request is seen (see enable_device function in acpiphp_glue.c).
What was not fine before?
Have you looked at real HW that supports PCI hot plug DSDT? Does it looks the same?
I recall I saw some examples like this on the net.
new acpi-dst.hex(332K): http://amos-kong.rhcloud.com/pub/acpi-dsdt.hex
Signed-off-by: Amos Kong akong@redhat.com
On Mon, Sep 19, 2011 at 01:27:25PM -0300, Marcelo Tosatti wrote:
On Mon, Sep 19, 2011 at 01:02:59PM +0300, Michael S. Tsirkin wrote:
On Mon, Sep 19, 2011 at 12:57:33PM +0300, Gleb Natapov wrote:
On Mon, Sep 19, 2011 at 03:27:38AM -0400, Amos Kong wrote:
Only func 0 is registered to guest driver (we can only found func 0 in slot->funcs list of driver), the other functions could not be cleaned when hot-removing the whole slot. This patch adds device per function in ACPI DSDT tables.
You can't unplug a single function. Guest surely knows that.
Looking at guest code, it's clear that at least a Linux guest doesn't know that.
acpiphp_disable_slot function appears to eject all functions.
Yes but the siblings list seems to be populated from the ACPI tables, but by probing PCI functions. So we need to, at a minimum, have Device tables for all functions.
Have tested with linux/winxp/win7, hot-adding/hot-remving, single/multiple function device, they are all fine.
Does not work for me (FC12 guest). As mentioned previously, Linux driver looks for function 0 when injection request is seen (see enable_device function in acpiphp_glue.c).
What exactly are you trying to do? ATM the idea is to add all functions, add function 0 as the last one.
What was not fine before?
Have you looked at real HW that supports PCI hot plug DSDT? Does it looks the same?
I recall I saw some examples like this on the net.
new acpi-dst.hex(332K): http://amos-kong.rhcloud.com/pub/acpi-dsdt.hex
Signed-off-by: Amos Kong akong@redhat.com
From 48ea1c9188334b89a60b4f9e853e86fc04fda4a5 Mon Sep 17 00:00:00 2001
From: Amos Kong akong@redhat.com Date: Tue, 20 Sep 2011 15:38:43 +0800 Subject: [SeaBIOS PATCH v2] hotplug: Add device per func in ACPI DSDT tables
Only func 0 is registered to guest driver (we can only found func 0 in slot->funcs list of driver), the other functions could not be cleaned when hot-removing the whole slot. This patch adds device per function in ACPI DSDT tables.
Have tested with linux/winxp/win7, hot-adding/hot-remving, single/multiple function device, they are all fine. --- Changes from v1: - cleanup the macros, bios.bin gets back to 128K - notify only when func0 is added and removed
Signed-off-by: Amos Kong akong@redhat.com Signed-off-by: Michael S. Tsirkin mst@redhat.com --- src/acpi-dsdt.dsl | 106 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 61 insertions(+), 45 deletions(-)
diff --git a/src/acpi-dsdt.dsl b/src/acpi-dsdt.dsl index 08412e2..707c3d6 100644 --- a/src/acpi-dsdt.dsl +++ b/src/acpi-dsdt.dsl @@ -128,9 +128,9 @@ DefinitionBlock ( PCRM, 32, }
-#define hotplug_slot(name, nr) \ - Device (S##name) { \ - Name (_ADR, nr##0000) \ +#define hotplug_func(name, nr, adr, fn) \ + Device (S##name##fn) { \ + Name (_ADR, adr) \ Method (_EJ0,1) { \ Store(ShiftLeft(1, nr), B0EJ) \ Return (0x0) \ @@ -138,6 +138,16 @@ DefinitionBlock ( Name (_SUN, name) \ }
+#define hotplug_slot(name, nr) \ + hotplug_func(name, nr, nr##0000, 0) \ + hotplug_func(name, nr, nr##0001, 1) \ + hotplug_func(name, nr, nr##0002, 2) \ + hotplug_func(name, nr, nr##0003, 3) \ + hotplug_func(name, nr, nr##0004, 4) \ + hotplug_func(name, nr, nr##0005, 5) \ + hotplug_func(name, nr, nr##0006, 6) \ + hotplug_func(name, nr, nr##0007, 7) + hotplug_slot(1, 0x0001) hotplug_slot(2, 0x0002) hotplug_slot(3, 0x0003) @@ -460,7 +470,7 @@ DefinitionBlock ( } }
-#define gen_pci_device(name, nr) \ +#define gen_pci_device(name, nr) \ Device(SL##name) { \ Name (_ADR, nr##0000) \ Method (_RMV) { \ @@ -502,6 +512,52 @@ DefinitionBlock ( gen_pci_device(29, 0x001d) gen_pci_device(30, 0x001e) gen_pci_device(31, 0x001f) + +#define gen_pci_hotplug(nr) \ + If (And(PCIU, ShiftLeft(1, nr))) { \ + Notify(S##nr##0, 1) \ + } \ + If (And(PCID, ShiftLeft(1, nr))) { \ + Notify(S##nr##0, 3) \ + } + + Method(HPLG) { + gen_pci_hotplug(1) + gen_pci_hotplug(2) + gen_pci_hotplug(3) + gen_pci_hotplug(4) + gen_pci_hotplug(5) + gen_pci_hotplug(6) + gen_pci_hotplug(7) + gen_pci_hotplug(8) + gen_pci_hotplug(9) + gen_pci_hotplug(10) + gen_pci_hotplug(11) + gen_pci_hotplug(12) + gen_pci_hotplug(13) + gen_pci_hotplug(14) + gen_pci_hotplug(15) + gen_pci_hotplug(16) + gen_pci_hotplug(17) + gen_pci_hotplug(18) + gen_pci_hotplug(19) + gen_pci_hotplug(20) + gen_pci_hotplug(21) + gen_pci_hotplug(22) + gen_pci_hotplug(23) + gen_pci_hotplug(24) + gen_pci_hotplug(25) + gen_pci_hotplug(26) + gen_pci_hotplug(27) + gen_pci_hotplug(28) + gen_pci_hotplug(29) + gen_pci_hotplug(30) + gen_pci_hotplug(31) + + Return (0x01) + } + + }
/* PCI IRQs */ @@ -842,49 +898,9 @@ DefinitionBlock ( Return(0x01) }
-#define gen_pci_hotplug(nr) \ - If (And(_SB.PCI0.PCIU, ShiftLeft(1, nr))) { \ - Notify(_SB.PCI0.S##nr, 1) \ - } \ - If (And(_SB.PCI0.PCID, ShiftLeft(1, nr))) { \ - Notify(_SB.PCI0.S##nr, 3) \ - } - Method(_L01) { - gen_pci_hotplug(1) - gen_pci_hotplug(2) - gen_pci_hotplug(3) - gen_pci_hotplug(4) - gen_pci_hotplug(5) - gen_pci_hotplug(6) - gen_pci_hotplug(7) - gen_pci_hotplug(8) - gen_pci_hotplug(9) - gen_pci_hotplug(10) - gen_pci_hotplug(11) - gen_pci_hotplug(12) - gen_pci_hotplug(13) - gen_pci_hotplug(14) - gen_pci_hotplug(15) - gen_pci_hotplug(16) - gen_pci_hotplug(17) - gen_pci_hotplug(18) - gen_pci_hotplug(19) - gen_pci_hotplug(20) - gen_pci_hotplug(21) - gen_pci_hotplug(22) - gen_pci_hotplug(23) - gen_pci_hotplug(24) - gen_pci_hotplug(25) - gen_pci_hotplug(26) - gen_pci_hotplug(27) - gen_pci_hotplug(28) - gen_pci_hotplug(29) - gen_pci_hotplug(30) - gen_pci_hotplug(31) - + _SB.PCI0.HPLG() Return (0x01) - } Method(_L02) { // CPU hotplug event
----- Original Message -----
On Mon, Sep 19, 2011 at 01:02:59PM +0300, Michael S. Tsirkin wrote:
On Mon, Sep 19, 2011 at 12:57:33PM +0300, Gleb Natapov wrote:
On Mon, Sep 19, 2011 at 03:27:38AM -0400, Amos Kong wrote:
Only func 0 is registered to guest driver (we can only found func 0 in slot->funcs list of driver), the other functions could not be cleaned when hot-removing the whole slot. This patch adds device per function in ACPI DSDT tables.
You can't unplug a single function. Guest surely knows that.
Looking at guest code, it's clear that at least a Linux guest doesn't know that.
acpiphp_disable_slot function appears to eject all functions.
Have tested with linux/winxp/win7, hot-adding/hot-remving, single/multiple function device, they are all fine.
Does not work for me (FC12 guest).
what's your problem? only func 0 can be added? I hotplug/hot-remove device by this script(add func 1~7, then add func 0):
j=6 for i in `seq 1 7` 0;do qemu-img create /tmp/resize$j$i.qcow2 10M -f qcow2 echo drive_add 0x$j.$i id=drv$j$i,if=none,file=/tmp/resize$j$i.qcow2 | nc -U /tmp/a echo device_add virtio-blk-pci,id=dev$j$i,drive=drv$j$i,addr=0x$j.$i,multifunction=on | nc -U /tmp/monitor done sleep 5; echo device_del dev60 | nc -U /tmp/monitor
As mentioned previously, Linux driver looks for function 0 when injection request is seen (see enable_device function in acpiphp_glue.c).
What was not fine before?
When hot-removing multifunc device, only func 0 can be removed from guest.
Have you looked at real HW that supports PCI hot plug DSDT? Does it looks the same?
I recall I saw some examples like this on the net.
new acpi-dst.hex(332K): http://amos-kong.rhcloud.com/pub/acpi-dsdt.hex
Signed-off-by: Amos Kong akong@redhat.com