From nobody Tue Nov 4 00:09:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505226472910781.5409895268957; Tue, 12 Sep 2017 07:27:52 -0700 (PDT) Received: from localhost ([::1]:36203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drmAJ-0001F0-0n for importer@patchew.org; Tue, 12 Sep 2017 10:27:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drm95-0000Qx-To for qemu-devel@nongnu.org; Tue, 12 Sep 2017 10:26:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drm90-0003hP-27 for qemu-devel@nongnu.org; Tue, 12 Sep 2017 10:26:35 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40087) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drm8z-0003h5-QC for qemu-devel@nongnu.org; Tue, 12 Sep 2017 10:26:29 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8CEQFpa138023 for ; Tue, 12 Sep 2017 10:26:28 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cxaumxus6-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 12 Sep 2017 10:26:28 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Sep 2017 08:26:27 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 12 Sep 2017 08:26:25 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8CEQOIC31916180; Tue, 12 Sep 2017 07:26:24 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A73F6A041; Tue, 12 Sep 2017 08:26:24 -0600 (MDT) Received: from alifm-ThinkPad-W540.pok.ibm.com (unknown [9.56.58.110]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTPS id 967036A03F; Tue, 12 Sep 2017 08:26:23 -0600 (MDT) From: Farhan Ali To: qemu-devel@nongnu.org Date: Tue, 12 Sep 2017 10:26:20 -0400 X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-TM-AS-GCONF: 00 x-cbid: 17091214-8235-0000-0000-00000C42509C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007711; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000227; SDB=6.00915972; UDB=6.00459921; IPR=6.00696203; BA=6.00005587; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017126; XFM=3.00000015; UTC=2017-09-12 14:26:26 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17091214-8236-0000-0000-00003D9D7B76 Message-Id: <0a156f413f67b1bf55c5516d8263a15db3ec42c3.1505225353.git.alifm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-12_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709120202 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v1 1/2] virtio_gpu: Handle endian conversion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: borntraeger@de.ibm.com, thuth@redhat.com, cohuck@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Virtio GPU code currently only supports litte endian format, and so using the Virtio GPU device on a big endian machine does not work. Let's fix it by supporting the correct host cpu byte order. Signed-off-by: Farhan Ali --- hw/display/virtio-gpu.c | 53 ++++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 6aae147..36e2414 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -236,8 +236,8 @@ virtio_gpu_fill_display_info(VirtIOGPU *g, for (i =3D 0; i < g->conf.max_outputs; i++) { if (g->enabled_output_bitmask & (1 << i)) { dpy_info->pmodes[i].enabled =3D 1; - dpy_info->pmodes[i].r.width =3D g->req_state[i].width; - dpy_info->pmodes[i].r.height =3D g->req_state[i].height; + dpy_info->pmodes[i].r.width =3D cpu_to_le32(g->req_state[i].wi= dth); + dpy_info->pmodes[i].r.height =3D cpu_to_le32(g->req_state[i].h= eight); } } } @@ -287,6 +287,12 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g, struct virtio_gpu_resource_create_2d c2d; =20 VIRTIO_GPU_FILL_CMD(c2d); + + c2d.resource_id =3D le32_to_cpu(c2d.resource_id); + c2d.format =3D le32_to_cpu(c2d.format); + c2d.width =3D le32_to_cpu(c2d.width); + c2d.height =3D le32_to_cpu(c2d.height); + trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format, c2d.width, c2d.height); =20 @@ -383,6 +389,14 @@ static void virtio_gpu_transfer_to_host_2d(VirtIOGPU *= g, struct virtio_gpu_transfer_to_host_2d t2d; =20 VIRTIO_GPU_FILL_CMD(t2d); + + t2d.r.x =3D le32_to_cpu(t2d.r.x); + t2d.r.y =3D le32_to_cpu(t2d.r.y); + t2d.r.width =3D le32_to_cpu(t2d.r.width); + t2d.r.height =3D le32_to_cpu(t2d.r.height); + t2d.resource_id =3D le32_to_cpu(t2d.resource_id); + t2d.offset =3D le64_to_cpu(t2d.offset); + trace_virtio_gpu_cmd_res_xfer_toh_2d(t2d.resource_id); =20 res =3D virtio_gpu_find_resource(g, t2d.resource_id); @@ -439,6 +453,13 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, int i; =20 VIRTIO_GPU_FILL_CMD(rf); + + rf.resource_id =3D le32_to_cpu(rf.resource_id); + rf.r.width =3D le32_to_cpu(rf.r.width); + rf.r.height =3D le32_to_cpu(rf.r.height); + rf.r.x =3D le32_to_cpu(rf.r.x); + rf.r.y =3D le32_to_cpu(rf.r.y); + trace_virtio_gpu_cmd_res_flush(rf.resource_id, rf.r.width, rf.r.height, rf.r.x, rf.r.y= ); =20 @@ -511,6 +532,14 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g, struct virtio_gpu_set_scanout ss; =20 VIRTIO_GPU_FILL_CMD(ss); + + ss.scanout_id =3D le32_to_cpu(ss.scanout_id); + ss.resource_id =3D le32_to_cpu(ss.resource_id); + ss.r.width =3D le32_to_cpu(ss.r.width); + ss.r.height =3D le32_to_cpu(ss.r.height); + ss.r.x =3D le32_to_cpu(ss.r.x); + ss.r.y =3D le32_to_cpu(ss.r.y); + trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id, ss.r.width, ss.r.height, ss.r.x, ss.r= .y); =20 @@ -633,13 +662,15 @@ int virtio_gpu_create_mapping_iov(struct virtio_gpu_r= esource_attach_backing *ab, *addr =3D g_malloc0(sizeof(uint64_t) * ab->nr_entries); } for (i =3D 0; i < ab->nr_entries; i++) { - hwaddr len =3D ents[i].length; - (*iov)[i].iov_len =3D ents[i].length; - (*iov)[i].iov_base =3D cpu_physical_memory_map(ents[i].addr, &len,= 1); + uint64_t a =3D le64_to_cpu(ents[i].addr); + uint32_t l =3D le32_to_cpu(ents[i].length); + hwaddr len =3D l; + (*iov)[i].iov_len =3D l; + (*iov)[i].iov_base =3D cpu_physical_memory_map(a, &len, 1); if (addr) { - (*addr)[i] =3D ents[i].addr; + (*addr)[i] =3D a; } - if (!(*iov)[i].iov_base || len !=3D ents[i].length) { + if (!(*iov)[i].iov_base || len !=3D l) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map MMIO memory = for" " resource %d element %d\n", __func__, ab->resource_id, i); @@ -686,6 +717,10 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g, int ret; =20 VIRTIO_GPU_FILL_CMD(ab); + + ab.resource_id =3D le32_to_cpu(ab.resource_id); + ab.nr_entries =3D le32_to_cpu(ab.nr_entries); + trace_virtio_gpu_cmd_res_back_attach(ab.resource_id); =20 res =3D virtio_gpu_find_resource(g, ab.resource_id); @@ -735,7 +770,7 @@ static void virtio_gpu_simple_process_cmd(VirtIOGPU *g, { VIRTIO_GPU_FILL_CMD(cmd->cmd_hdr); =20 - switch (cmd->cmd_hdr.type) { + switch (le32_to_cpu(cmd->cmd_hdr.type)) { case VIRTIO_GPU_CMD_GET_DISPLAY_INFO: virtio_gpu_get_display_info(g, cmd); break; @@ -1135,7 +1170,7 @@ static void virtio_gpu_device_realize(DeviceState *qd= ev, Error **errp) } =20 g->config_size =3D sizeof(struct virtio_gpu_config); - g->virtio_config.num_scanouts =3D g->conf.max_outputs; + g->virtio_config.num_scanouts =3D cpu_to_le32(g->conf.max_outputs); virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, g->config_size); =20 --=20 1.9.1 From nobody Tue Nov 4 00:09:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505226562226429.42765363672754; Tue, 12 Sep 2017 07:29:22 -0700 (PDT) Received: from localhost ([::1]:36207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drmBl-0002Mq-GE for importer@patchew.org; Tue, 12 Sep 2017 10:29:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drm92-0000OC-Uw for qemu-devel@nongnu.org; Tue, 12 Sep 2017 10:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drm8z-0003hF-Gb for qemu-devel@nongnu.org; Tue, 12 Sep 2017 10:26:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48170 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drm8z-0003gz-BX for qemu-devel@nongnu.org; Tue, 12 Sep 2017 10:26:29 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8CEOeGI041730 for ; Tue, 12 Sep 2017 10:26:28 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cxfq7x193-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 12 Sep 2017 10:26:28 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Sep 2017 08:26:27 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 12 Sep 2017 08:26:26 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8CEQQEF65273862; Tue, 12 Sep 2017 07:26:26 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6D146A03D; Tue, 12 Sep 2017 08:26:25 -0600 (MDT) Received: from alifm-ThinkPad-W540.pok.ibm.com (unknown [9.56.58.110]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTPS id 587CE6A03C; Tue, 12 Sep 2017 08:26:25 -0600 (MDT) From: Farhan Ali To: qemu-devel@nongnu.org Date: Tue, 12 Sep 2017 10:26:21 -0400 X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-TM-AS-GCONF: 00 x-cbid: 17091214-8235-0000-0000-00000C42509D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007711; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000227; SDB=6.00915972; UDB=6.00459921; IPR=6.00696203; BA=6.00005587; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017126; XFM=3.00000015; UTC=2017-09-12 14:26:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17091214-8236-0000-0000-00003D9D7B7B Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-12_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709120202 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v1 2/2] virtio-gpu-ccw: Create a virtio gpu device for the ccw bus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: borntraeger@de.ibm.com, thuth@redhat.com, cohuck@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Wire up the virtio-gpu device for the CCW bus. The virtio-gpu is a virtio-1 device, so disable revision 0. Signed-off-by: Farhan Ali Acked-by: Christian Borntraeger Reviewed-by: Halil Pasic --- hw/s390x/virtio-ccw.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/s390x/virtio-ccw.h | 10 ++++++++++ 2 files changed, 64 insertions(+) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index b1976fd..3078bf0 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1007,6 +1007,20 @@ static void virtio_ccw_crypto_realize(VirtioCcwDevic= e *ccw_dev, Error **errp) NULL); } =20 +static void virtio_ccw_gpu_realize(VirtioCcwDevice *ccw_dev, Error **errp) +{ + VirtIOGPUCcw *dev =3D VIRTIO_GPU_CCW(ccw_dev); + DeviceState *vdev =3D DEVICE(&dev->vdev); + Error *err =3D NULL; + + qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); + object_property_set_bool(OBJECT(vdev), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } +} + /* DeviceState to VirtioCcwDevice. Note: used on datapath, * be careful and test performance if you change this. */ @@ -1616,6 +1630,45 @@ static const TypeInfo virtio_ccw_crypto =3D { .class_init =3D virtio_ccw_crypto_class_init, }; =20 +static Property virtio_ccw_gpu_properties[] =3D { + DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, + VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), + DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, + VIRTIO_CCW_MAX_REV), + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_ccw_gpu_instance_init(Object *obj) +{ + VirtIOGPUCcw *dev =3D VIRTIO_GPU_CCW(obj); + VirtioCcwDevice *ccw_dev =3D VIRTIO_CCW_DEVICE(obj); + + ccw_dev->force_revision_1 =3D true; + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VIRTIO_GPU); +} + +static void virtio_ccw_gpu_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtIOCCWDeviceClass *k =3D VIRTIO_CCW_DEVICE_CLASS(klass); + + k->realize =3D virtio_ccw_gpu_realize; + k->exit =3D virtio_ccw_exit; + dc->reset =3D virtio_ccw_reset; + dc->props =3D virtio_ccw_gpu_properties; + dc->hotpluggable =3D false; + set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); +} + +static const TypeInfo virtio_ccw_gpu =3D { + .name =3D TYPE_VIRTIO_GPU_CCW, + .parent =3D TYPE_VIRTIO_CCW_DEVICE, + .instance_size =3D sizeof(VirtIOGPUCcw), + .instance_init =3D virtio_ccw_gpu_instance_init, + .class_init =3D virtio_ccw_gpu_class_init, +}; + static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp) { VirtioCcwDevice *_dev =3D (VirtioCcwDevice *)dev; @@ -1815,6 +1868,7 @@ static void virtio_ccw_register(void) type_register_static(&vhost_vsock_ccw_info); #endif type_register_static(&virtio_ccw_crypto); + type_register_static(&virtio_ccw_gpu); } =20 type_init(virtio_ccw_register) diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h index 41d4010..541fdd2 100644 --- a/hw/s390x/virtio-ccw.h +++ b/hw/s390x/virtio-ccw.h @@ -27,6 +27,7 @@ #ifdef CONFIG_VHOST_VSOCK #include "hw/virtio/vhost-vsock.h" #endif /* CONFIG_VHOST_VSOCK */ +#include "hw/virtio/virtio-gpu.h" =20 #include "hw/s390x/s390_flic.h" #include "hw/s390x/css.h" @@ -223,4 +224,13 @@ typedef struct VHostVSockCCWState { =20 #endif /* CONFIG_VHOST_VSOCK */ =20 +#define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw" +#define VIRTIO_GPU_CCW(obj) \ + OBJECT_CHECK(VirtIOGPUCcw, (obj), TYPE_VIRTIO_GPU_CCW) + +typedef struct VirtIOGPUCcw { + VirtioCcwDevice parent_obj; + VirtIOGPU vdev; +} VirtIOGPUCcw; + #endif --=20 1.9.1