* [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not
@ 2010-05-11 20:43 Gerd Hoffmann
2010-05-11 20:43 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2010-05-11 20:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ioport.c | 5 +++++
ioport.h | 1 +
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/ioport.c b/ioport.c
index 53dd87a..b718047 100644
--- a/ioport.c
+++ b/ioport.c
@@ -190,6 +190,11 @@ void isa_unassign_ioport(pio_addr_t start, int length)
}
}
+int is_ioport_assigned(pio_addr_t addr)
+{
+ return ioport_opaque[addr] != NULL;
+}
+
/***********************************************************/
void cpu_outb(pio_addr_t addr, uint8_t val)
diff --git a/ioport.h b/ioport.h
index 3d3c8a3..46fbfa8 100644
--- a/ioport.h
+++ b/ioport.h
@@ -41,6 +41,7 @@ int register_ioport_read(pio_addr_t start, int length, int size,
int register_ioport_write(pio_addr_t start, int length, int size,
IOPortWriteFunc *func, void *opaque);
void isa_unassign_ioport(pio_addr_t start, int length);
+int is_ioport_assigned(pio_addr_t addr);
void cpu_outb(pio_addr_t addr, uint8_t val);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-11 20:43 [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Gerd Hoffmann
@ 2010-05-11 20:43 ` Gerd Hoffmann
2010-05-12 18:59 ` Blue Swirl
2010-05-18 12:33 ` Markus Armbruster
0 siblings, 2 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2010-05-11 20:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Try to pci hotplug a vga card, watch qemu die with hw_error().
This patch fixes it.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/cirrus_vga.c | 3 +++
hw/vga-pci.c | 3 +++
hw/vmware_vga.c | 3 +++
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 9f61a01..2f50e86 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3189,6 +3189,9 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
uint8_t *pci_conf = d->dev.config;
int device_id = CIRRUS_ID_CLGD5446;
+ if (is_ioport_assigned(0x3c0))
+ return -1;
+
/* setup VGA */
vga_common_init(&s->vga, VGA_RAM_SIZE);
cirrus_init_common(s, device_id, 1);
diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index c8d260c..2ef3278 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -79,6 +79,9 @@ static int pci_vga_initfn(PCIDevice *dev)
VGACommonState *s = &d->vga;
uint8_t *pci_conf = d->dev.config;
+ if (is_ioport_assigned(0x3c0))
+ return -1;
+
// vga + console init
vga_common_init(s, VGA_RAM_SIZE);
vga_init(s);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 4e7a75d..cd0eb57 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1232,6 +1232,9 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
struct pci_vmsvga_state_s *s =
DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
+ if (is_ioport_assigned(0x3c0))
+ return -1;
+
pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
s->card.config[PCI_COMMAND] = PCI_COMMAND_IO |
--
1.6.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-11 20:43 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
@ 2010-05-12 18:59 ` Blue Swirl
2010-05-18 12:33 ` Markus Armbruster
1 sibling, 0 replies; 7+ messages in thread
From: Blue Swirl @ 2010-05-12 18:59 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
On 5/11/10, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Try to pci hotplug a vga card, watch qemu die with hw_error().
> This patch fixes it.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/cirrus_vga.c | 3 +++
> hw/vga-pci.c | 3 +++
> hw/vmware_vga.c | 3 +++
> 3 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
> index 9f61a01..2f50e86 100644
> --- a/hw/cirrus_vga.c
> +++ b/hw/cirrus_vga.c
> @@ -3189,6 +3189,9 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
> uint8_t *pci_conf = d->dev.config;
> int device_id = CIRRUS_ID_CLGD5446;
>
> + if (is_ioport_assigned(0x3c0))
> + return -1;
> +
-ECODING_STYLE.
> /* setup VGA */
> vga_common_init(&s->vga, VGA_RAM_SIZE);
> cirrus_init_common(s, device_id, 1);
> diff --git a/hw/vga-pci.c b/hw/vga-pci.c
> index c8d260c..2ef3278 100644
> --- a/hw/vga-pci.c
> +++ b/hw/vga-pci.c
> @@ -79,6 +79,9 @@ static int pci_vga_initfn(PCIDevice *dev)
> VGACommonState *s = &d->vga;
> uint8_t *pci_conf = d->dev.config;
>
> + if (is_ioport_assigned(0x3c0))
> + return -1;
> +
> // vga + console init
> vga_common_init(s, VGA_RAM_SIZE);
> vga_init(s);
> diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
> index 4e7a75d..cd0eb57 100644
> --- a/hw/vmware_vga.c
> +++ b/hw/vmware_vga.c
> @@ -1232,6 +1232,9 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
> struct pci_vmsvga_state_s *s =
> DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
>
> + if (is_ioport_assigned(0x3c0))
> + return -1;
> +
> pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
> pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
> s->card.config[PCI_COMMAND] = PCI_COMMAND_IO |
>
> --
> 1.6.6.1
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-11 20:43 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
2010-05-12 18:59 ` Blue Swirl
@ 2010-05-18 12:33 ` Markus Armbruster
2010-05-18 12:45 ` Gerd Hoffmann
1 sibling, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2010-05-18 12:33 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Gerd Hoffmann <kraxel@redhat.com> writes:
> Try to pci hotplug a vga card, watch qemu die with hw_error().
> This patch fixes it.
Looks good.
Are there any other hot-pluggable devices that acquire single-use
resources such as fixed I/O ports?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-18 12:33 ` Markus Armbruster
@ 2010-05-18 12:45 ` Gerd Hoffmann
2010-05-18 14:06 ` Markus Armbruster
0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2010-05-18 12:45 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
On 05/18/10 14:33, Markus Armbruster wrote:
> Gerd Hoffmann<kraxel@redhat.com> writes:
>
>> Try to pci hotplug a vga card, watch qemu die with hw_error().
>> This patch fixes it.
>
> Looks good.
>
> Are there any other hot-pluggable devices that acquire single-use
> resources such as fixed I/O ports?
Any PCI device doing ISA compatibility stuff I'd guess, which makes IDE
a candidate. Checking ...
Yes (hw/ide/piix.c):
ide_init_ioport(&d->bus[0], 0x1f0, 0x3f6);
ide_init_ioport(&d->bus[1], 0x170, 0x376);
Those are tagged with "no-user" though due to being hard-coded in pc.c,
so any attempt to hot-plug one of those should fail way before it
attempts to grab the I/O ports.
cheers,
Gerd
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-18 12:45 ` Gerd Hoffmann
@ 2010-05-18 14:06 ` Markus Armbruster
0 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2010-05-18 14:06 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Gerd Hoffmann <kraxel@redhat.com> writes:
> On 05/18/10 14:33, Markus Armbruster wrote:
>> Gerd Hoffmann<kraxel@redhat.com> writes:
>>
>>> Try to pci hotplug a vga card, watch qemu die with hw_error().
>>> This patch fixes it.
>>
>> Looks good.
>>
>> Are there any other hot-pluggable devices that acquire single-use
>> resources such as fixed I/O ports?
>
> Any PCI device doing ISA compatibility stuff I'd guess, which makes
> IDE a candidate. Checking ...
>
> Yes (hw/ide/piix.c):
>
> ide_init_ioport(&d->bus[0], 0x1f0, 0x3f6);
> ide_init_ioport(&d->bus[1], 0x170, 0x376);
>
> Those are tagged with "no-user" though due to being hard-coded in
> pc.c, so any attempt to hot-plug one of those should fail way before
> it attempts to grab the I/O ports.
So a more general mechanism than you ad hoc is_ioport_assigned() check
doesn't seem to be justified.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-19 9:54 [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Gerd Hoffmann
@ 2010-05-19 9:54 ` Gerd Hoffmann
0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2010-05-19 9:54 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Try to pci hotplug a vga card, watch qemu die with hw_error().
This patch fixes it.
[v2: code style fixes]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/cirrus_vga.c | 4 ++++
hw/vga-pci.c | 4 ++++
hw/vmware_vga.c | 4 ++++
3 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 9f61a01..977abd2 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3189,6 +3189,10 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
uint8_t *pci_conf = d->dev.config;
int device_id = CIRRUS_ID_CLGD5446;
+ if (is_ioport_assigned(0x3c0)) {
+ return -1;
+ }
+
/* setup VGA */
vga_common_init(&s->vga, VGA_RAM_SIZE);
cirrus_init_common(s, device_id, 1);
diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index c8d260c..9fa0bfb 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -79,6 +79,10 @@ static int pci_vga_initfn(PCIDevice *dev)
VGACommonState *s = &d->vga;
uint8_t *pci_conf = d->dev.config;
+ if (is_ioport_assigned(0x3c0)) {
+ return -1;
+ }
+
// vga + console init
vga_common_init(s, VGA_RAM_SIZE);
vga_init(s);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 4e7a75d..7a8cec0 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1232,6 +1232,10 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
struct pci_vmsvga_state_s *s =
DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
+ if (is_ioport_assigned(0x3c0)) {
+ return -1;
+ }
+
pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
s->card.config[PCI_COMMAND] = PCI_COMMAND_IO |
--
1.6.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-05-19 9:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-11 20:43 [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Gerd Hoffmann
2010-05-11 20:43 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
2010-05-12 18:59 ` Blue Swirl
2010-05-18 12:33 ` Markus Armbruster
2010-05-18 12:45 ` Gerd Hoffmann
2010-05-18 14:06 ` Markus Armbruster
-- strict thread matches above, loose matches on Subject: below --
2010-05-19 9:54 [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Gerd Hoffmann
2010-05-19 9:54 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
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.