
* Update to QEMU v9.0.0 --------- Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Ido Plat <ido.plat@ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Gregory Price <gregory.price@memverge.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Lorenz Brun <lorenz@brun.one> Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Sven Schnelle <svens@stackframe.org> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> Signed-off-by: Avihai Horon <avihaih@nvidia.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Joonas Kankaala <joonas.a.kankaala@gmail.com> Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Glenn Miles <milesg@linux.ibm.com> Signed-off-by: Oleg Sviridov <oleg.sviridov@red-soft.ru> Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Signed-off-by: Yajun Wu <yajunw@nvidia.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Pierre-Clément Tosi <ptosi@google.com> Signed-off-by: Lei Wang <lei4.wang@intel.com> Signed-off-by: Wei Wang <wei.w.wang@intel.com> Signed-off-by: Martin Hundebøll <martin@geanix.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Wafer <wafer@jaguarmicro.com> Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com> Signed-off-by: Zack Buhman <zack@buhman.org> Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Yuquan Wang wangyuquan1236@phytium.com.cn Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Signed-off-by: Cindy Lu <lulu@redhat.com> Co-authored-by: Peter Maydell <peter.maydell@linaro.org> Co-authored-by: Fabiano Rosas <farosas@suse.de> Co-authored-by: Peter Xu <peterx@redhat.com> Co-authored-by: Thomas Huth <thuth@redhat.com> Co-authored-by: Cédric Le Goater <clg@redhat.com> Co-authored-by: Zheyu Ma <zheyuma97@gmail.com> Co-authored-by: Ido Plat <ido.plat@ibm.com> Co-authored-by: Ilya Leoshkevich <iii@linux.ibm.com> Co-authored-by: Markus Armbruster <armbru@redhat.com> Co-authored-by: Marc-André Lureau <marcandre.lureau@redhat.com> Co-authored-by: Paolo Bonzini <pbonzini@redhat.com> Co-authored-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Co-authored-by: David Hildenbrand <david@redhat.com> Co-authored-by: Kevin Wolf <kwolf@redhat.com> Co-authored-by: Stefan Reiter <s.reiter@proxmox.com> Co-authored-by: Fiona Ebner <f.ebner@proxmox.com> Co-authored-by: Gregory Price <gregory.price@memverge.com> Co-authored-by: Lorenz Brun <lorenz@brun.one> Co-authored-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> Co-authored-by: Philippe Mathieu-Daudé <philmd@linaro.org> Co-authored-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> Co-authored-by: BALATON Zoltan <balaton@eik.bme.hu> Co-authored-by: Igor Mammedov <imammedo@redhat.com> Co-authored-by: Akihiko Odaki <akihiko.odaki@daynix.com> Co-authored-by: Richard Henderson <richard.henderson@linaro.org> Co-authored-by: Sven Schnelle <svens@stackframe.org> Co-authored-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Co-authored-by: Helge Deller <deller@kernel.org> Co-authored-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Co-authored-by: Benjamin Gray <bgray@linux.ibm.com> Co-authored-by: Nicholas Piggin <npiggin@gmail.com> Co-authored-by: Avihai Horon <avihaih@nvidia.com> Co-authored-by: Michael Tokarev <mjt@tls.msk.ru> Co-authored-by: Joonas Kankaala <joonas.a.kankaala@gmail.com> Co-authored-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> Co-authored-by: Stefan Weil <sw@weilnetz.de> Co-authored-by: Dayu Liu <liu.dayu@zte.com.cn> Co-authored-by: Zhao Liu <zhao1.liu@intel.com> Co-authored-by: Glenn Miles <milesg@linux.vnet.ibm.com> Co-authored-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Co-authored-by: Yajun Wu <yajunw@nvidia.com> Co-authored-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Co-authored-by: Pierre-Clément Tosi <ptosi@google.com> Co-authored-by: Wei Wang <wei.w.wang@intel.com> Co-authored-by: Martin Hundebøll <martin@geanix.com> Co-authored-by: Michael S. Tsirkin <mst@redhat.com> Co-authored-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Co-authored-by: Wafer <wafer@jaguarmicro.com> Co-authored-by: lyx634449800 <yuxue.liu@jaguarmicro.com> Co-authored-by: Gerd Hoffmann <kraxel@redhat.com> Co-authored-by: Nguyen Dinh Phi <phind.uet@gmail.com> Co-authored-by: Zack Buhman <zack@buhman.org> Co-authored-by: Keith Packard <keithp@keithp.com> Co-authored-by: Yuquan Wang <wangyuquan1236@phytium.com.cn> Co-authored-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Co-authored-by: Cindy Lu <lulu@redhat.com>
205 lines
5.2 KiB
C
205 lines
5.2 KiB
C
/*
|
|
* s390 CCW Assignment Support
|
|
*
|
|
* Copyright 2017 IBM Corp
|
|
* Author(s): Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
|
|
* Xiao Feng Ren <renxiaof@linux.vnet.ibm.com>
|
|
* Pierre Morel <pmorel@linux.vnet.ibm.com>
|
|
*
|
|
* 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 <libgen.h>
|
|
#include "qapi/error.h"
|
|
#include "qemu/module.h"
|
|
#include "hw/s390x/css.h"
|
|
#include "hw/s390x/css-bridge.h"
|
|
#include "hw/s390x/s390-ccw.h"
|
|
#include "sysemu/sysemu.h"
|
|
|
|
IOInstEnding s390_ccw_cmd_request(SubchDev *sch)
|
|
{
|
|
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(sch->driver_data);
|
|
|
|
if (!cdc->handle_request) {
|
|
return IOINST_CC_STATUS_PRESENT;
|
|
}
|
|
return cdc->handle_request(sch);
|
|
}
|
|
|
|
int s390_ccw_halt(SubchDev *sch)
|
|
{
|
|
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(sch->driver_data);
|
|
|
|
if (!cdc->handle_halt) {
|
|
return -ENOSYS;
|
|
}
|
|
return cdc->handle_halt(sch);
|
|
}
|
|
|
|
int s390_ccw_clear(SubchDev *sch)
|
|
{
|
|
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(sch->driver_data);
|
|
|
|
if (!cdc->handle_clear) {
|
|
return -ENOSYS;
|
|
}
|
|
return cdc->handle_clear(sch);
|
|
}
|
|
|
|
IOInstEnding s390_ccw_store(SubchDev *sch)
|
|
{
|
|
S390CCWDeviceClass *cdc = NULL;
|
|
int ret = IOINST_CC_EXPECTED;
|
|
|
|
/*
|
|
* This code is called for both virtual and passthrough devices,
|
|
* but only applies to the latter. This ugly check makes that
|
|
* distinction for us.
|
|
*/
|
|
if (object_dynamic_cast(OBJECT(sch->driver_data), TYPE_S390_CCW)) {
|
|
cdc = S390_CCW_DEVICE_GET_CLASS(sch->driver_data);
|
|
}
|
|
|
|
if (cdc && cdc->handle_store) {
|
|
ret = cdc->handle_store(sch);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void s390_ccw_get_dev_info(S390CCWDevice *cdev,
|
|
char *sysfsdev,
|
|
Error **errp)
|
|
{
|
|
unsigned int cssid, ssid, devid;
|
|
char dev_path[PATH_MAX] = {0};
|
|
g_autofree char *tmp_dir = NULL;
|
|
g_autofree char *tmp = NULL;
|
|
|
|
if (!sysfsdev) {
|
|
error_setg(errp, "No host device provided");
|
|
error_append_hint(errp,
|
|
"Use -device vfio-ccw,sysfsdev=PATH_TO_DEVICE\n");
|
|
return;
|
|
}
|
|
|
|
if (!realpath(sysfsdev, dev_path)) {
|
|
error_setg_errno(errp, errno, "Host device '%s' not found", sysfsdev);
|
|
return;
|
|
}
|
|
|
|
cdev->mdevid = g_path_get_basename(dev_path);
|
|
|
|
tmp_dir = g_path_get_dirname(dev_path);
|
|
tmp = g_path_get_basename(tmp_dir);
|
|
if (sscanf(tmp, "%2x.%1x.%4x", &cssid, &ssid, &devid) != 3) {
|
|
error_setg_errno(errp, errno, "Failed to read %s", tmp);
|
|
return;
|
|
}
|
|
|
|
cdev->hostid.cssid = cssid;
|
|
cdev->hostid.ssid = ssid;
|
|
cdev->hostid.devid = devid;
|
|
cdev->hostid.valid = true;
|
|
}
|
|
|
|
static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
|
|
{
|
|
CcwDevice *ccw_dev = CCW_DEVICE(cdev);
|
|
CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev);
|
|
DeviceState *parent = DEVICE(ccw_dev);
|
|
SubchDev *sch;
|
|
int ret;
|
|
Error *err = NULL;
|
|
|
|
s390_ccw_get_dev_info(cdev, sysfsdev, &err);
|
|
if (err) {
|
|
goto out_err_propagate;
|
|
}
|
|
|
|
sch = css_create_sch(ccw_dev->devno, &err);
|
|
if (!sch) {
|
|
goto out_mdevid_free;
|
|
}
|
|
sch->driver_data = cdev;
|
|
sch->do_subchannel_work = do_subchannel_work_passthrough;
|
|
sch->irb_cb = build_irb_passthrough;
|
|
|
|
ccw_dev->sch = sch;
|
|
ret = css_sch_build_schib(sch, &cdev->hostid);
|
|
if (ret) {
|
|
error_setg_errno(&err, -ret, "%s: Failed to build initial schib",
|
|
__func__);
|
|
goto out_err;
|
|
}
|
|
|
|
ck->realize(ccw_dev, &err);
|
|
if (err) {
|
|
goto out_err;
|
|
}
|
|
|
|
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
|
|
parent->hotplugged, 1);
|
|
return;
|
|
|
|
out_err:
|
|
css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
|
|
ccw_dev->sch = NULL;
|
|
g_free(sch);
|
|
out_mdevid_free:
|
|
g_free(cdev->mdevid);
|
|
out_err_propagate:
|
|
error_propagate(errp, err);
|
|
}
|
|
|
|
static void s390_ccw_unrealize(S390CCWDevice *cdev)
|
|
{
|
|
CcwDevice *ccw_dev = CCW_DEVICE(cdev);
|
|
SubchDev *sch = ccw_dev->sch;
|
|
|
|
if (sch) {
|
|
css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);
|
|
g_free(sch);
|
|
ccw_dev->sch = NULL;
|
|
}
|
|
|
|
g_free(cdev->mdevid);
|
|
}
|
|
|
|
static void s390_ccw_instance_init(Object *obj)
|
|
{
|
|
S390CCWDevice *dev = S390_CCW_DEVICE(obj);
|
|
|
|
device_add_bootindex_property(obj, &dev->bootindex, "bootindex",
|
|
"/disk@0,0", DEVICE(obj));
|
|
}
|
|
|
|
static void s390_ccw_class_init(ObjectClass *klass, void *data)
|
|
{
|
|
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_CLASS(klass);
|
|
|
|
cdc->realize = s390_ccw_realize;
|
|
cdc->unrealize = s390_ccw_unrealize;
|
|
}
|
|
|
|
static const TypeInfo s390_ccw_info = {
|
|
.name = TYPE_S390_CCW,
|
|
.parent = TYPE_CCW_DEVICE,
|
|
.instance_init = s390_ccw_instance_init,
|
|
.instance_size = sizeof(S390CCWDevice),
|
|
.class_size = sizeof(S390CCWDeviceClass),
|
|
.class_init = s390_ccw_class_init,
|
|
.abstract = true,
|
|
};
|
|
|
|
static void register_s390_ccw_type(void)
|
|
{
|
|
type_register_static(&s390_ccw_info);
|
|
}
|
|
|
|
type_init(register_s390_ccw_type)
|