s390x: register I/O adapters per ISC during init

The I/O adapters should exist as soon as the bus/infrastructure
exists, and not only when the guest is actually trying to do something
with them. While the lazy allocation was not wrong, allocating at init
time is cleaner, both for the architecture and the code. Let's adjust
this by having each device type (currently for PCI and virtio-ccw)
register the adapters for each ISC (as now we don't know which ISC the
guest will use) as soon as it initializes.

Use a two-dimensional array io_adapters[type][isc] to store adapters
in ChannelSubSys, so that we can conveniently get the adapter id by
the helper function css_get_adapter_id(type, isc).

Signed-off-by: Fei Li <sherrylf@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
This commit is contained in:
Fei Li 2016-11-24 11:10:39 +01:00 committed by Cornelia Huck
parent bc66d6cbca
commit dde522bbc5
6 changed files with 74 additions and 47 deletions

View file

@ -23,6 +23,8 @@
#define MAX_CSSID 255
#define MAX_CHPID 255
#define MAX_ISC 7
#define MAX_CIWS 62
#define VIRTUAL_CSSID 0xfe
@ -130,8 +132,9 @@ typedef enum {
CSS_IO_ADAPTER_TYPE_NUMS,
} CssIoAdapterType;
int css_register_io_adapter(CssIoAdapterType type, uint8_t isc, bool swap,
bool maskable, uint32_t *id);
uint32_t css_get_adapter_id(CssIoAdapterType type, uint8_t isc);
void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maskable,
Error **errp);
#ifndef CONFIG_USER_ONLY
SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid,