More s390x patches for 2.7
PATCH 3/8 s390x/ipl: Support IPL from selected SCSI device
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
If bootindex is specified for a device, we need to IPL from it. Currently it works for ccw devices, but not for SCSI. To be able to IPL from the specific device, pc-bios needs to know its address. For this reason we add special QEMU_SCSI IPL type into the IPLB structure, that contains the scsi device address.
We enhance the ipl block with a currently qemu-only parameter block that allows us to specify a concrete scsi device.
--- hw/s390x/ipl.c | 18 ++++++++++++++++++ hw/s390x/ipl.h | 13 +++++++++++++ 2 files changed, 31 insertions(+)
hw/s390x/ipl.c +18 -0
@@ -217,6 +217,8 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *)object_dynamic_cast (OBJECT (qdev_get_parent_bus (dev_st)->parent),TYPE_VIRTIO_CCW_DEVICE ); +SCSIDevice *sd = (SCSIDevice *)object_dynamic_cast (OBJECT (dev_st), +TYPE_SCSI_DEVICE );if (ccw_dev) { ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); ipl->iplb.blk0_len =
@@ -225,6 +227,22 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) ipl->iplb.ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); ipl->iplb.ccw.ssid = ccw_dev->sch->ssid &3 ;return true; + }else if (sd) { +SCSIBus *bus =scsi_bus_from_device (sd); +VirtIOSCSI *vdev =container_of (bus, VirtIOSCSI, bus); +VirtIOSCSICcw *scsi_ccw =container_of (vdev, VirtIOSCSICcw, vdev); +VirtioCcwDevice *ccw = &scsi_ccw->parent_obj; + + ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN ); + ipl->iplb.blk0_len = +cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN -S390_IPLB_HEADER_LEN ); + ipl->iplb.pbt =S390_IPL_TYPE_QEMU_SCSI ; + ipl->iplb.scsi.lun =cpu_to_be32 (sd->lun); + ipl->iplb.scsi.target =cpu_to_be16 (sd->id); + ipl->iplb.scsi.channel =cpu_to_be16 (sd->channel); + ipl->iplb.scsi.devno =cpu_to_be16 (ccw->sch->devno); + ipl->iplb.scsi.ssid = ccw->sch->ssid &3 ; +return true; } }
hw/s390x/ipl.h +13 -0
@@ -46,6 +46,16 @@ struct IplBlockFcp { }QEMU_PACKED ;typedef struct IplBlockFcp IplBlockFcp ; +struct IplBlockQemuScsi { +uint32_t lun; +uint16_t target; +uint16_t channel; +uint8_t reserved0[77 ]; +uint8_t ssid; +uint16_t devno; +}QEMU_PACKED ; +typedef struct IplBlockQemuScsi IplBlockQemuScsi ; + union IplParameterBlock { struct { uint32_t len;
@@ -59,6 +69,7 @@ union IplParameterBlock {union {IplBlockCcw ccw;IplBlockFcp fcp; +IplBlockQemuScsi scsi; }; }QEMU_PACKED ;struct {
@@ -102,10 +113,12 @@ typedef struct S390IPLState S390IPLState;#define S390_IPL_TYPE_FCP 0x00#define S390_IPL_TYPE_CCW 0x02 +#define S390_IPL_TYPE_QEMU_SCSI 0xff#define S390_IPLB_HEADER_LEN 8#define S390_IPLB_MIN_CCW_LEN 200#define S390_IPLB_MIN_FCP_LEN 384 +#define S390_IPLB_MIN_QEMU_SCSI_LEN 200static inline bool iplb_valid_len (IplParameterBlock *iplb) {
Signature · 1 line
2.9.0
PATCH 1/8 pc-bios/s390-ccw: Pass selected SCSI device to IPL
In reply to Cornelia HuckFrom: "Eugene (jno) Dvurechenski" <[email protected]>
There is ,bootindex=%d argument to specify the lookup order of boot devices.
If a bootindex assigned to the device, then IPL Parameter Info Block is created for that device when it is IPLed from.
If it is a mere SCSI device (not FCP), then IPIB is created with a special SCSI type and its fields are used to store SCSI address of the device. This new ipl block is private to qemu for now.
If the device to IPL from is specified this way, then SCSI bus lookup is bypassed and prescribed devices uses the address specified.
--- pc-bios/s390-ccw/iplb.h | 12 ++++++++++++ pc-bios/s390-ccw/main.c | 12 ++++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 11 +++++++++++ pc-bios/s390-ccw/virtio.h | 2 ++ 4 files changed, 37 insertions(+)
pc-bios/s390-ccw/iplb.h +12 -0
@@ -43,6 +43,16 @@ struct IplBlockFcp { } __attribute__ ((packed));typedef struct IplBlockFcp IplBlockFcp ; +struct IplBlockQemuScsi { +uint32_t lun; +uint16_t target; +uint16_t channel; +uint8_t reserved0[77 ]; +uint8_t ssid; +uint16_t devno; +} __attribute__ ((packed)); +typedef struct IplBlockQemuScsi IplBlockQemuScsi ; +struct IplParameterBlock {uint32_t len;uint8_t reserved0[3 ];
@@ -55,6 +65,7 @@ struct IplParameterBlock {union {IplBlockCcw ccw;IplBlockFcp fcp; +IplBlockQemuScsi scsi; }; } __attribute__ ((packed));typedef struct IplParameterBlock IplParameterBlock ;
@@ -63,6 +74,7 @@ extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));#define S390_IPL_TYPE_FCP 0x00#define S390_IPL_TYPE_CCW 0x02 +#define S390_IPL_TYPE_QEMU_SCSI 0xffstatic inline bool store_iplb (IplParameterBlock *iplb) {
pc-bios/s390-ccw/main.c +12 -0
@@ -84,6 +84,18 @@ static void virtio_setup(void)debug_print_int ("ssid " , blk_schid.ssid); found =find_dev (&schib, dev_no);break ; +case S390_IPL_TYPE_QEMU_SCSI : + { +VDev *vdev =virtio_get_device (); + + vdev->scsi_device_selected = true; + vdev->selected_scsi_device.channel = iplb.scsi.channel; + vdev->selected_scsi_device.target = iplb.scsi.target; + vdev->selected_scsi_device.lun = iplb.scsi.lun; + blk_schid.ssid = iplb.scsi.ssid &0x3 ; + found =find_dev (&schib, iplb.scsi.devno); +break ; + }default :panic ("List-directed IPL not supported yet!\n" ); }
pc-bios/s390-ccw/virtio-scsi.c +11 -0
@@ -204,6 +204,17 @@ static void virtio_scsi_locate_device(VDev *vdev)debug_print_int ("config.scsi.max_target " , vdev->config.scsi.max_target);debug_print_int ("config.scsi.max_lun " , vdev->config.scsi.max_lun); +if (vdev->scsi_device_selected) { + sdev->channel = vdev->selected_scsi_device.channel; + sdev->target = vdev->selected_scsi_device.target; + sdev->lun = vdev->selected_scsi_device.lun; + +IPL_check (sdev->channel ==0 ,"non-zero channel requested" ); +IPL_check (sdev->target <= vdev->config.scsi.max_target,"target# high" ); +IPL_check (sdev->lun <= vdev->config.scsi.max_lun,"LUN# high" ); +return ; + } +for (target =0 ; target <= vdev->config.scsi.max_target; target++) { sdev->channel = channel; sdev->target = target;/* sdev->lun will be 0 here */
pc-bios/s390-ccw/virtio.h +2 -0
@@ -274,6 +274,8 @@ struct VDev {uint64_t scsi_last_block;uint32_t scsi_dev_cyls;uint8_t scsi_dev_heads; +bool scsi_device_selected; +ScsiDevice selected_scsi_device; };typedef struct VDev VDev ;
Signature · 1 line
2.9.0
cover More s390x patches for 2.7
The following patches (and the s390x pci patches already on the list) make up the last batch of s390x patches I plan to do for 2.7 (except for bug fixes that may crop up, of course).
We have several fixes/enhancements in the boot code and a bit of refactoring in the css code that makes the future addition of device types easier.
Alexander Yarygin (1):
s390x/ipl: Support IPL from selected SCSI device
Cornelia Huck (1):
pc-bios/s390-ccw.img: rebuild image
David Hildenbrand (1):
s390x/ipl: fix reboots for migration from different bios
Eugene (jno) Dvurechenski (1):
pc-bios/s390-ccw: Pass selected SCSI device to IPL
Jing Liu (2):
s390x/css: Factor out virtual css bridge and bus s390x/css: Unplug handler of virtual css bridge
Sascha Silbe (2):
s390x/css: factor out some generic code from
virtio_ccw_device_realize()
s390x/css: use define for "virtual-css-bridge" literal
hw/s390x/Makefile.objs | 2 + hw/s390x/ccw-device.c | 27 ++++ hw/s390x/ccw-device.h | 43 +++++++ hw/s390x/css-bridge.c | 124 +++++++++++++++++++ hw/s390x/css.c | 143 ++++++++++++++++++++++ hw/s390x/ipl.c | 37 +++++- hw/s390x/ipl.h | 15 +++ hw/s390x/s390-virtio-ccw.c | 3 +- hw/s390x/virtio-ccw.c | 271 ++++++++--------------------------------- hw/s390x/virtio-ccw.h | 20 +-- include/hw/s390x/css-bridge.h | 31 +++++ include/hw/s390x/css.h | 18 +++ pc-bios/s390-ccw.img | Bin 26424 -> 26440 bytes pc-bios/s390-ccw/iplb.h | 12 ++ pc-bios/s390-ccw/main.c | 12 ++ pc-bios/s390-ccw/virtio-scsi.c | 11 ++ pc-bios/s390-ccw/virtio.h | 2 + 17 files changed, 531 insertions(+), 240 deletions(-) create mode 100644 hw/s390x/ccw-device.c create mode 100644 hw/s390x/ccw-device.h create mode 100644 hw/s390x/css-bridge.c create mode 100644 include/hw/s390x/css-bridge.h
Signature · 1 line
2.9.0
PATCH 6/8 s390x/css: use define for "virtual-css-bridge" literal
From: Sascha Silbe <[email protected]>
Introduce a TYPE_* define (like we already use for a couple of other QOM types) for the name of the virtual CSS bridge QOM type instead of sprinkling the same string literal over several source files.
--- hw/s390x/s390-virtio-ccw.c | 2 +- hw/s390x/virtio-ccw.c | 4 ++-- hw/s390x/virtio-ccw.h | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-)
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -29,7 +29,7 @@#include "hw/s390x/s390-virtio-ccw.h" static const char *const reset_dev_types[] = { -"virtual-css-bridge" , +TYPE_VIRTUAL_CSS_BRIDGE ,"s390-sclp-event-facility" ,"s390-flic" ,"diag288" ,
hw/s390x/virtio-ccw.c +2 -2
@@ -130,7 +130,7 @@ VirtualCssBus *virtual_css_bus_init(void)DeviceState *dev;/* Create bridge device */ - dev =qdev_create (NULL ,"virtual-css-bridge" ); + dev =qdev_create (NULL ,TYPE_VIRTUAL_CSS_BRIDGE );qdev_init_nofail (dev);/* Create bus on bridge device */
@@ -1626,7 +1626,7 @@ static void virtual_css_bridge_class_init(ObjectClass *klass, void *data) }static const TypeInfo virtual_css_bridge_info = { - .name ="virtual-css-bridge" , + .name =TYPE_VIRTUAL_CSS_BRIDGE , .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (SysBusDevice), .class_init = virtual_css_bridge_class_init,
hw/s390x/virtio-ccw.h +3 -0
@@ -101,6 +101,9 @@ static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)return dev->max_rev; } +/* virtual css bridge type */ +#define TYPE_VIRTUAL_CSS_BRIDGE "virtual-css-bridge" +/* virtual css bus type */ typedef struct VirtualCssBus { BusState parent_obj;
Signature · 1 line
2.9.0
PATCH 5/8 s390x/css: factor out some generic code from virtio_ccw_device_realize()
In reply to Cornelia HuckFrom: Sascha Silbe <[email protected]>
A lot of what virtio_ccw_device_realize() does isn't specific to virtio; it would apply to emulated CCW as well. Factor it out to make it easier to implement emulated CCW devices later on.
--- hw/s390x/css.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/virtio-ccw.c | 122 +++++------------------------------------ hw/s390x/virtio-ccw.h | 2 - include/hw/s390x/css.h | 18 +++++++ 4 files changed, 175 insertions(+), 110 deletions(-)
hw/s390x/css.c +143 -0
@@ -1340,6 +1340,116 @@ SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid, uint16_t schid)return channel_subsys.css[real_cssid]->sch_set[ssid]->sch[schid]; } +/** +* Return free device number in subchannel set. +* +* Return index of the first free device number in the subchannel set +* identified by @p cssid and @p ssid, beginning the search at @p +* start and wrapping around at MAX_DEVNO. Return a value exceeding +* MAX_SCHID if there are no free device numbers in the subchannel +* set. +*/ +static uint32_t css_find_free_devno (uint8_t cssid,uint8_t ssid, +uint16_t start) +{ +uint32_t round; + +for (round =0 ; round <=MAX_DEVNO ; round++) { +uint16_t devno = (start + round) %MAX_DEVNO ; + +if (!css_devno_used (cssid, ssid, devno)) { +return devno; + } + } +return MAX_DEVNO +1 ; +} + +/** +* Return first free subchannel (id) in subchannel set. +* +* Return index of the first free subchannel in the subchannel set +* identified by @p cssid and @p ssid, if there is any. Return a value +* exceeding MAX_SCHID if there are no free subchannels in the +* subchannel set. +*/ +static uint32_t css_find_free_subch (uint8_t cssid,uint8_t ssid) +{ +uint32_t schid; + +for (schid =0 ; schid <=MAX_SCHID ; schid++) { +if (!css_find_subch (1 , cssid, ssid, schid)) { +return schid; + } + } +return MAX_SCHID +1 ; +} + +/** +* Return first free subchannel (id) in subchannel set for a device number +* +* Verify the device number @p devno is not used yet in the subchannel +* set identified by @p cssid and @p ssid. Set @p schid to the index +* of the first free subchannel in the subchannel set, if there is +* any. Return true if everything succeeded and false otherwise. +*/ +static bool css_find_free_subch_for_devno (uint8_t cssid,uint8_t ssid, +uint16_t devno,uint16_t *schid, +Error **errp) +{ +uint32_t free_schid; + +assert (schid); +if (css_devno_used (cssid, ssid, devno)) { +error_setg (errp,"Device %x.%x.%04x already exists" , + cssid, ssid, devno); +return false; + } + free_schid =css_find_free_subch (cssid, ssid); +if (free_schid >MAX_SCHID ) { +error_setg (errp,"No free subchannel found for %x.%x.%04x" , + cssid, ssid, devno); +return false; + } + *schid = free_schid; +return true; +} + +/** +* Return first free subchannel (id) and device number +* +* Locate the first free subchannel and first free device number in +* any of the subchannel sets of the channel subsystem identified by +* @p cssid. Return false if no free subchannel / device number could +* be found. Otherwise set @p ssid, @p devno and @p schid to identify +* the available subchannel and device number and return true. +* +* May modify @p ssid, @p devno and / or @p schid even if no free +* subchannel / device number could be found. +*/ +static bool css_find_free_subch_and_devno (uint8_t cssid,uint8_t *ssid, +uint16_t *devno,uint16_t *schid, +Error **errp) +{ +uint32_t free_schid, free_devno; + +assert (ssid && devno && schid); +for (*ssid =0 ; *ssid <=MAX_SSID ; (*ssid)++) { + free_schid =css_find_free_subch (cssid, *ssid); +if (free_schid >MAX_SCHID ) { +continue ; + } + free_devno =css_find_free_devno (cssid, *ssid, free_schid); +if (free_devno >MAX_DEVNO ) { +continue ; + } + *schid = free_schid; + *devno = free_devno; +return true; + } +error_setg (errp,"Virtual channel subsystem is full!" ); +return false; +} +bool css_subch_visible (SubchDev *sch) {if (sch->ssid > channel_subsys.max_ssid) {
@@ -1762,3 +1872,36 @@ PropertyInfo css_devid_propinfo = { .get = get_css_devid, .set = set_css_devid, }; + +SubchDev *css_create_virtual_sch (CssDevId bus_id,Error **errp) +{ +uint16_t schid =0 ; +SubchDev *sch; + +if (bus_id.valid) { +/* Enforce use of virtual cssid. */ +if (bus_id.cssid !=VIRTUAL_CSSID ) { +error_setg (errp,"cssid %hhx not valid for virtual devices" , + bus_id.cssid); +return NULL ; + } +if (!css_find_free_subch_for_devno (bus_id.cssid, bus_id.ssid, + bus_id.devid, &schid, errp)) { +return NULL ; + } + }else { + bus_id.cssid =VIRTUAL_CSSID ; +if (!css_find_free_subch_and_devno (bus_id.cssid, &bus_id.ssid, + &bus_id.devid, &schid, errp)) { +return NULL ; + } + } + + sch =g_malloc0 (sizeof (*sch)); + sch->cssid = bus_id.cssid; + sch->ssid = bus_id.ssid; + sch->devno = bus_id.devid; + sch->schid = schid; +css_subch_assign (sch->cssid, sch->ssid, schid, sch->devno, sch); +return sch; +}
hw/s390x/virtio-ccw.c +14 -108
144 lines not on this page · raw message
hw/s390x/virtio-ccw.h +0 -2
@@ -27,8 +27,6 @@#include <hw/s390x/s390_flic.h> #include <hw/s390x/css.h> -#define VIRTUAL_CSSID 0xfe -#define VIRTIO_CCW_CU_TYPE 0x3832#define VIRTIO_CCW_CHPID_TYPE 0x32
include/hw/s390x/css.h +18 -0
@@ -17,6 +17,7 @@#include "hw/s390x/ioinst.h" /* Channel subsystem constants. */ +#define MAX_DEVNO 65535#define MAX_SCHID 65535#define MAX_SSID 3#define MAX_CSSID 254/* 255 is reserved */
@@ -24,6 +25,8 @@#define MAX_CIWS 62 +#define VIRTUAL_CSSID 0xfe + typedef struct CIW { uint8_t type; uint8_t command;
@@ -169,4 +172,19 @@ extern PropertyInfo css_devid_propinfo;#define DEFINE_PROP_CSS_DEV_ID (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, css_devid_propinfo, CssDevId) +/** +* Create a subchannel for the given bus id. +* +* If @p bus_id is valid, verify that it uses the virtual channel +* subsystem id and is not already in use, and find a free subchannel +* id for it. If @p bus_id is not valid, find a free subchannel id and +* device number across all subchannel sets. If either of the former +* actions succeed, allocate a subchannel structure, initialise it +* with the bus id, subchannel id and device number, register it with +* the CSS and return it. Otherwise return NULL. +* +* The caller becomes owner of the returned subchannel structure and +* is responsible for unregistering and freeing it. +*/ +SubchDev *css_create_virtual_sch (CssDevId bus_id,Error **errp);#endif
Signature · 1 line
2.9.0
PATCH 7/8 s390x/css: Factor out virtual css bridge and bus
In reply to Cornelia HuckFrom: Jing Liu <[email protected]>
Currently, common base layers virtual css bridge and bus are defined in hw/s390x/virtio-ccw.c(h). In order to support multiple types of devices in the virtual channel subsystem, especially non virtio-ccw, refactoring work needs to be done.
This work is just a pure code move without any functional change except dropping an empty function virtual_css_bridge_init() and virtio_ccw_busdev_unplug() changing. virtio_ccw_busdev_unplug() is specific to virtio-ccw but gets referenced from the common virtual css bridge code. To keep the functional changes to a minimum we export this function from virtio-ccw.c and continue to reference it inside virtual_css_bridge_class_init() (now living in hw/s390x/css-bridge.c). A follow-up patch will clean this up.
--- hw/s390x/Makefile.objs | 1 + hw/s390x/css-bridge.c | 89 +++++++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 1 + hw/s390x/virtio-ccw.c | 79 ++------------------------------------ hw/s390x/virtio-ccw.h | 14 +------ include/hw/s390x/css-bridge.h | 31 +++++++++++++++ 6 files changed, 127 insertions(+), 88 deletions(-) create mode 100644 hw/s390x/css-bridge.c create mode 100644 include/hw/s390x/css-bridge.h
hw/s390x/Makefile.objs +1 -0
@@ -8,6 +8,7 @@ obj-y += ipl.o obj-y += css.o obj-y += s390-virtio-ccw.o obj-y += virtio-ccw.o +obj-y += css-bridge.o obj-y += s390-pci-bus.o s390-pci-inst.o obj-y += s390-skeys.o obj-$(CONFIG_KVM) += s390-skeys-kvm.o
hw/s390x/css-bridge.c new file +89 -0
89 lines not on this page · raw message
hw/s390x/s390-virtio-ccw.c +1 -0
@@ -27,6 +27,7 @@#include "hw/compat.h" #include "ipl.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "hw/s390x/css-bridge.h" static const char *const reset_dev_types[] = {TYPE_VIRTUAL_CSS_BRIDGE ,
hw/s390x/virtio-ccw.c +3 -76
119 lines not on this page · raw message
hw/s390x/virtio-ccw.h +2 -12
@@ -101,17 +101,8 @@ static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)return dev->max_rev; } -/* virtual css bridge type */ -#define TYPE_VIRTUAL_CSS_BRIDGE "virtual-css-bridge" - -/* virtual css bus type */ -typedef struct VirtualCssBus { -BusState parent_obj; -}VirtualCssBus ; - -#define TYPE_VIRTUAL_CSS_BUS "virtual-css-bus" -#define VIRTUAL_CSS_BUS (obj) \ - OBJECT_CHECK(VirtualCssBus, (obj), TYPE_VIRTUAL_CSS_BUS) +void virtio_ccw_busdev_unplug (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);/* virtio-scsi-ccw */
@@ -192,7 +183,6 @@ typedef struct VirtIORNGCcw {VirtIORNG vdev; } VirtIORNGCcw; -VirtualCssBus *virtual_css_bus_init (void );void virtio_ccw_device_update_status (SubchDev *sch);VirtIODevice *virtio_ccw_get_vdev (SubchDev *sch);
include/hw/s390x/css-bridge.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* virtual css bridge definition +* +* Copyright 2012,2016 IBM Corp. +* Author(s): Cornelia Huck <[email protected]> +* Pierre Morel <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ + +#ifndef HW_S390X_CSS_BRIDGE_H +#define HW_S390X_CSS_BRIDGE_H +#include "qom/object.h" +#include "hw/qdev-core.h" + +/* virtual css bridge */ +#define TYPE_VIRTUAL_CSS_BRIDGE "virtual-css-bridge" + +/* virtual css bus type */ +typedef struct VirtualCssBus { +BusState parent_obj; +}VirtualCssBus ; + +#define TYPE_VIRTUAL_CSS_BUS "virtual-css-bus" +#define VIRTUAL_CSS_BUS (obj) \ + OBJECT_CHECK(VirtualCssBus, (obj), TYPE_VIRTUAL_CSS_BUS) +VirtualCssBus *virtual_css_bus_init (void ); + +#endif
Signature · 1 line
2.9.0
PATCH 2/8 pc-bios/s390-ccw.img: rebuild image
In reply to Cornelia HuckContains:
- pc-bios/s390-ccw: Pass selected SCSI device to IPL
--- pc-bios/s390-ccw.img | Bin 26424 -> 26440 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
Signature · 1 line
2.9.0
PATCH 4/8 s390x/ipl: fix reboots for migration from different bios
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
When migrating from a different QEMU version, the start_address and bios_start_address may differ. During migration these values are migrated and overwrite the values that were detected by QEMU itself.
On a reboot, QEMU will reload its own BIOS, but use the migrated start addresses, which does not work if the values differ.
Fix this by not relying on the migrated values anymore, but still provide them during migration, so existing QEMUs continue to work.
--- hw/s390x/ipl.c | 11 +++++++++-- hw/s390x/ipl.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-)
hw/s390x/ipl.c +9 -2
@@ -69,8 +69,8 @@ static const VMStateDescription vmstate_ipl = { .version_id = 0, .minimum_version_id = 0, .fields = (VMStateField []) { -VMSTATE_UINT64 (start_addr, S390IPLState), -VMSTATE_UINT64 (bios_start_addr, S390IPLState), +VMSTATE_UINT64 (compat_start_addr, S390IPLState), +VMSTATE_UINT64 (compat_bios_start_addr, S390IPLState),VMSTATE_STRUCT (iplb, S390IPLState,0 , vmstate_iplb, IplParameterBlock),VMSTATE_BOOL (iplb_valid, S390IPLState),VMSTATE_UINT8 (cssid, S390IPLState),
@@ -192,6 +192,13 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)stq_p (rom_ptr (INITRD_PARM_SIZE ), initrd_size); } } +/* +* Don't ever use the migrated values, they could come from a different +* BIOS and therefore don't work. But still migrate the values, so +* QEMUs relying on it don't break. +*/ + ipl->compat_start_addr = ipl->start_addr; + ipl->compat_bios_start_addr = ipl->bios_start_addr;qemu_register_reset (qdev_reset_all_fn, dev); error:error_propagate (errp, err);
hw/s390x/ipl.h +2 -0
@@ -93,7 +93,9 @@ struct S390IPLState {/*< private >*/ DeviceState parent_obj;uint64_t start_addr; +uint64_t compat_start_addr;uint64_t bios_start_addr; +uint64_t compat_bios_start_addr;bool enforce_bios;IplParameterBlock iplb;bool iplb_valid;
Signature · 1 line
2.9.0
PATCH 8/8 s390x/css: Unplug handler of virtual css bridge
In reply to Cornelia HuckFrom: Jing Liu <[email protected]>
The previous patch moved virtual css bridge and bus out from virtio-ccw, but kept the direct reference of virtio-ccw specific unplug function inside css-bridge.c.
To make the virtual css bus and bridge useful for non-virtio devices, this introduces a common unplug function pointer "unplug" to call specific virtio-ccw unplug parts. Thus, the tight coupling to virtio-ccw can be removed.
This unplug pointer is a member of CCWDeviceClass, which is introduced as an abstract device layer called "ccw-device". This layer is between DeviceState and specific devices which are plugged in virtual css bus, like virtio-ccw device. The specific unplug handlers should be assigned to "unplug" during initialization.
--- hw/s390x/Makefile.objs | 1 + hw/s390x/ccw-device.c | 27 ++++++++++++++++ hw/s390x/ccw-device.h | 43 +++++++++++++++++++++++++ hw/s390x/css-bridge.c | 39 +++++++++++++++++++++-- hw/s390x/ipl.c | 14 ++++---- hw/s390x/virtio-ccw.c | 86 ++++++++++++++++++++++++++------------------------ hw/s390x/virtio-ccw.h | 11 +++---- 7 files changed, 164 insertions(+), 57 deletions(-) create mode 100644 hw/s390x/ccw-device.c create mode 100644 hw/s390x/ccw-device.h
hw/s390x/Makefile.objs +1 -0
@@ -9,6 +9,7 @@ obj-y += css.o obj-y += s390-virtio-ccw.o obj-y += virtio-ccw.o obj-y += css-bridge.o +obj-y += ccw-device.o obj-y += s390-pci-bus.o s390-pci-inst.o obj-y += s390-skeys.o obj-$(CONFIG_KVM) += s390-skeys-kvm.o
hw/s390x/ccw-device.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Common device infrastructure for devices in the virtual css +* +* Copyright 2016 IBM Corp. +* Author(s): Jing Liu <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ +#include "qemu/osdep.h" +#include "ccw-device.h" + +static const TypeInfo ccw_device_info = { + .name =TYPE_CCW_DEVICE , + .parent =TYPE_DEVICE , + .instance_size =sizeof (CcwDevice), + .class_size =sizeof (CCWDeviceClass), + .abstract = true, +}; + +static void ccw_device_register (void ) +{ +type_register_static (&ccw_device_info); +} + +type_init (ccw_device_register)
hw/s390x/ccw-device.h new file +43 -0
43 lines not on this page · raw message
hw/s390x/css-bridge.c +37 -2
@@ -11,13 +11,48 @@*/ #include "qemu/osdep.h" #include "qapi/error.h" -#include "virtio-ccw.h" #include "hw/hotplug.h" #include "hw/sysbus.h" #include "qemu/bitops.h" #include "hw/s390x/css.h" +#include "ccw-device.h" #include "hw/s390x/css-bridge.h" +/* +* Invoke device-specific unplug handler, disable the subchannel +* (including sending a channel report to the guest) and remove the +* device from the virtual css bus. +*/ +static void ccw_device_unplug (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +CcwDevice *ccw_dev =CCW_DEVICE (dev); +CCWDeviceClass *k =CCW_DEVICE_GET_CLASS (ccw_dev); +SubchDev *sch = ccw_dev->sch; +Error *err =NULL ; + +if (k->unplug) { + k->unplug (hotplug_dev, dev, &err); +if (err) { +error_propagate (errp, err); +return ; + } + } + +/* +* We should arrive here only for device_del, since we don't support +* direct hot(un)plug of channels. +*/ +assert (sch !=NULL ); +/* Subchannel is now disabled and no longer valid. */ + sch->curr_status.pmcw.flags &= ~(PMCW_FLAGS_MASK_ENA | +PMCW_FLAGS_MASK_DNV ); + +css_generate_sch_crws (sch->cssid, sch->ssid, sch->schid,1 ,0 ); + +object_unparent (OBJECT (dev)); +} +static void virtual_css_bus_reset (BusState *qbus) {/* This should actually be modelled via the generic css */
@@ -65,7 +100,7 @@ static void virtual_css_bridge_class_init(ObjectClass *klass, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass); - hc->unplug = virtio_ccw_busdev_unplug; + hc->unplug = ccw_device_unplug;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); }
hw/s390x/ipl.c +8 -6
@@ -221,12 +221,14 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) dev_st =get_boot_device (0 );if (dev_st) { -VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *)object_dynamic_cast ( -OBJECT (qdev_get_parent_bus (dev_st)->parent), +VirtioCcwDevice *virtio_ccw_dev = (VirtioCcwDevice *) +object_dynamic_cast (OBJECT (qdev_get_parent_bus (dev_st)->parent),TYPE_VIRTIO_CCW_DEVICE );SCSIDevice *sd = (SCSIDevice *)object_dynamic_cast (OBJECT (dev_st),TYPE_SCSI_DEVICE ); -if (ccw_dev) { +if (virtio_ccw_dev) { +CcwDevice *ccw_dev =CCW_DEVICE (virtio_ccw_dev); + ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); ipl->iplb.blk0_len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN -S390_IPLB_HEADER_LEN );
@@ -238,7 +240,7 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)SCSIBus *bus =scsi_bus_from_device (sd);VirtIOSCSI *vdev =container_of (bus, VirtIOSCSI, bus);VirtIOSCSICcw *scsi_ccw =container_of (vdev, VirtIOSCSICcw, vdev); -VirtioCcwDevice *ccw = &scsi_ccw->parent_obj; +CcwDevice *ccw_dev =CCW_DEVICE (scsi_ccw); ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN ); ipl->iplb.blk0_len =
@@ -247,8 +249,8 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) ipl->iplb.scsi.lun =cpu_to_be32 (sd->lun); ipl->iplb.scsi.target =cpu_to_be16 (sd->id); ipl->iplb.scsi.channel =cpu_to_be16 (sd->channel); - ipl->iplb.scsi.devno =cpu_to_be16 (ccw->sch->devno); - ipl->iplb.scsi.ssid = ccw->sch->ssid &3 ; + ipl->iplb.scsi.devno =cpu_to_be16 (ccw_dev->sch->devno); + ipl->iplb.scsi.ssid = ccw_dev->sch->ssid &3 ;return true; } }
hw/s390x/virtio-ccw.c +44 -42
260 lines not on this page · raw message
hw/s390x/virtio-ccw.h +4 -7
@@ -26,6 +26,8 @@#include <hw/s390x/s390_flic.h> #include <hw/s390x/css.h> +#include "ccw-device.h" +#include "hw/s390x/css-bridge.h" #define VIRTIO_CCW_CU_TYPE 0x3832#define VIRTIO_CCW_CHPID_TYPE 0x32
@@ -65,7 +67,7 @@ typedef struct VirtioBusClass VirtioCcwBusClass;typedef struct VirtioCcwDevice VirtioCcwDevice ;typedef struct VirtIOCCWDeviceClass { -DeviceClass parent_class; +CCWDeviceClass parent_class;void (*realize)(VirtioCcwDevice *dev,Error **errp);int (*exit)(VirtioCcwDevice *dev); }VirtIOCCWDeviceClass ;
@@ -76,9 +78,7 @@ typedef struct VirtIOCCWDeviceClass {#define VIRTIO_CCW_FLAG_USE_IOEVENTFD (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT)struct VirtioCcwDevice { -DeviceState parent_obj; -SubchDev *sch; -CssDevId bus_id; +CcwDevice parent_obj;int revision;uint32_t max_rev;VirtioBusState bus;
@@ -101,9 +101,6 @@ static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)return dev->max_rev; } -void virtio_ccw_busdev_unplug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp); -/* virtio-scsi-ccw */ #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw"
Signature · 1 line
2.9.0
Re: [Qemu-devel] [PATCH for-2.7 7/8] s390x/css: Factor out virtual css bridge and bus
In reply to Cornelia HuckDear Conny,
hw/s390x/css-bridge.c line 75
Quoted 5 lines · Cornelia Huck
hw/s390x/css-bridge.c new file +5
-0+ +static const TypeInfo virtual_css_bridge_info = { + .name =TYPE_VIRTUAL_CSS_BRIDGE , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (SysBusDevice),
So we do not use VirtualCssBridge macro which includes max_queue for 2.7? Just curious that in this way, how to deal with the compat for 2.6, 2.5 ...?
Jing
Quoted 86 lines
hw/s390x/virtio-ccw.h +8
-24+ .class_init = virtual_css_bridge_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_HOTPLUG_HANDLER }, + { } + } +}; - -static const TypeInfo virtual_css_bridge_info = { - .name =TYPE_VIRTUAL_CSS_BRIDGE , - .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (SysBusDevice), - .class_init = virtual_css_bridge_class_init, - .interfaces = (InterfaceInfo []) { - {TYPE_HOTPLUG_HANDLER }, - { } - } -}; -/* virtio-ccw-bus */ -/* virtual css bridge type */ -#define TYPE_VIRTUAL_CSS_BRIDGE "virtual-css-bridge" - -/* virtual css bus type */ -typedef struct VirtualCssBus { -BusState parent_obj; -}VirtualCssBus ; - -#define TYPE_VIRTUAL_CSS_BUS "virtual-css-bus" -#define VIRTUAL_CSS_BUS (obj) \ - OBJECT_CHECK(VirtualCssBus, (obj), TYPE_VIRTUAL_CSS_BUS) +void virtio_ccw_busdev_unplug (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);/* virtio-scsi-ccw */ @@ -192,7 +183,6 @@ typedef struct VirtIORNGCcw {VirtIORNG vdev; } VirtIORNGCcw; -VirtualCssBus *virtual_css_bus_init (void );void virtio_ccw_device_update_status (SubchDev *sch);VirtIODevice *virtio_ccw_get_vdev (SubchDev *sch);include/hw/s390x/css-bridge.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* virtual css bridge definition +* +* Copyright 2012,2016 IBM Corp. +* Author(s): Cornelia Huck <[email protected]> +* Pierre Morel <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ + +#ifndef HW_S390X_CSS_BRIDGE_H +#define HW_S390X_CSS_BRIDGE_H +#include "qom/object.h" +#include "hw/qdev-core.h" + +/* virtual css bridge */ +#define TYPE_VIRTUAL_CSS_BRIDGE "virtual-css-bridge" + +/* virtual css bus type */ +typedef struct VirtualCssBus { +BusState parent_obj; +}VirtualCssBus ; + +#define TYPE_VIRTUAL_CSS_BUS "virtual-css-bus" +#define VIRTUAL_CSS_BUS (obj) \ + OBJECT_CHECK(VirtualCssBus, (obj), TYPE_VIRTUAL_CSS_BUS) +VirtualCssBus *virtual_css_bus_init (void ); + +#endif
Re: [Qemu-devel] [PATCH for-2.7 7/8] s390x/css: Factor out virtual css bridge and bus
Quoted 4 lines · On Tue, 5 Jul 2016 16:30:35 +0800 Jing Liu <[email protected]> wrote:
Dear Conny,
On 07/05/2016 03:56 PM, Cornelia Huck wrote:
Quoted 8 lines
hw/s390x/css-bridge.c line 75
Quoted 5 lines
hw/s390x/css-bridge.c new file +5
-0+ +static const TypeInfo virtual_css_bridge_info = { + .name =TYPE_VIRTUAL_CSS_BRIDGE , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (SysBusDevice),So we do not use VirtualCssBridge macro which includes
max_queuefor 2.7? Just curious that in this way, how to deal with the compat for 2.6, 2.5 ...?
We don't have to deal with compat for code I have not included for upstream yet.
(I have not yet made up my mind exactly on how we want to support the maximum number of virtqueues as other transports while keeping backwards compatibility.)