From nobody Mon Feb 9 17:59:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1618902643; cv=none; d=zohomail.com; s=zohoarc; b=QM83D95AFdE58WOeVwBzCA+50UnfWxF1ymt1whTf9dXNLREWMGCCLIxXpaMQDTzJXPgQyfz5B2L8vcihpSxpSQFSosih0WEQv8rozqtSaROrvi5ie14Dt1alKpqX8ABa54hq9x+0wnHJEDQ2ElQAuSkDKSuUhHI5Ju2cgVus4V0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618902643; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yOpIFXjfnjSDgetPdcHNY7qz+dH7qtEvCUpRbpXT3ws=; b=mP9TN41htxxSr+8/5+8s94lmkz08gUKo/T0hhwCFqipmz+6KdVJN8UV17Iwo/pb9xOxULGnOUBKmeXA++xZ8f7Su8+bEXFI2baJQ2TAOlYHze9B8QtiWc5NZjPkwnx08Tr209KyX/1INA7MIRyilMwa4hyKjjVS2eOJC5fjOo4c= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618902643916121.16793118017426; Tue, 20 Apr 2021 00:10:43 -0700 (PDT) Received: from localhost ([::1]:44582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYkWw-00021b-Qz for importer@patchew.org; Tue, 20 Apr 2021 03:10:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYkSI-0003H5-IY for qemu-devel@nongnu.org; Tue, 20 Apr 2021 03:05:54 -0400 Received: from mga17.intel.com ([192.55.52.151]:17764) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYkSG-0002pO-1B for qemu-devel@nongnu.org; Tue, 20 Apr 2021 03:05:54 -0400 Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 00:05:37 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 00:05:37 -0700 IronPort-SDR: FokhEsBFdMYN8DXqb3kGlEo5d592kvdlCd9B6da+V7Vcb7MbmumqVVlYQKL+CqGVTiOhRAWFmC ohIMr1yEt23A== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="175563727" X-IronPort-AV: E=Sophos;i="5.82,236,1613462400"; d="scan'208";a="175563727" IronPort-SDR: byU2hQUPxAfmRN/+XLu19yxe/U758pzvrEvE49Gf/2x15TfiX0w6EBpMwHT0OSenB7MFgLyrKj zLm9jhiSJCcw== X-IronPort-AV: E=Sophos;i="5.82,236,1613462400"; d="scan'208";a="420293129" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 05/12] virtio-gpu: Refactor virtio_gpu_create_mapping_iov Date: Mon, 19 Apr 2021 23:53:40 -0700 Message-Id: <20210420065347.2685768-6-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210420065347.2685768-1-vivek.kasireddy@intel.com> References: <20210420065347.2685768-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Instead of passing the attach_backing object to extract nr_entries and offset, explicitly pass these as arguments to this function. This will be helpful when adding create_blob API. Signed-off-by: Vivek Kasireddy --- hw/display/virtio-gpu-3d.c | 3 ++- hw/display/virtio-gpu.c | 22 +++++++++++----------- include/hw/virtio/virtio-gpu.h | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index d98964858e..87ca661a26 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -288,7 +288,8 @@ static void virgl_resource_attach_backing(VirtIOGPU *g, VIRTIO_GPU_FILL_CMD(att_rb); trace_virtio_gpu_cmd_res_back_attach(att_rb.resource_id); =20 - ret =3D virtio_gpu_create_mapping_iov(g, &att_rb, cmd, NULL, &res_iovs= ); + ret =3D virtio_gpu_create_mapping_iov(g, att_rb.nr_entries, sizeof(att= _rb), + cmd, NULL, &res_iovs); if (ret !=3D 0) { cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5e1152aa2a..85c8eb749d 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -659,7 +659,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g, } =20 int virtio_gpu_create_mapping_iov(VirtIOGPU *g, - struct virtio_gpu_resource_attach_backin= g *ab, + uint32_t nr_entries, uint32_t offset, struct virtio_gpu_ctrl_command *cmd, uint64_t **addr, struct iovec **iov) { @@ -667,17 +667,17 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, size_t esize, s; int i; =20 - if (ab->nr_entries > 16384) { + if (nr_entries > 16384) { qemu_log_mask(LOG_GUEST_ERROR, "%s: nr_entries is too big (%d > 16384)\n", - __func__, ab->nr_entries); + __func__, nr_entries); return -1; } =20 - esize =3D sizeof(*ents) * ab->nr_entries; + esize =3D sizeof(*ents) * nr_entries; ents =3D g_malloc(esize); s =3D iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, - sizeof(*ab), ents, esize); + offset, ents, esize); if (s !=3D esize) { qemu_log_mask(LOG_GUEST_ERROR, "%s: command data size incorrect %zu vs %zu\n", @@ -686,11 +686,11 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, return -1; } =20 - *iov =3D g_malloc0(sizeof(struct iovec) * ab->nr_entries); + *iov =3D g_malloc0(sizeof(struct iovec) * nr_entries); if (addr) { - *addr =3D g_malloc0(sizeof(uint64_t) * ab->nr_entries); + *addr =3D g_malloc0(sizeof(uint64_t) * nr_entries); } - for (i =3D 0; i < ab->nr_entries; i++) { + for (i =3D 0; i < nr_entries; i++) { uint64_t a =3D le64_to_cpu(ents[i].addr); uint32_t l =3D le32_to_cpu(ents[i].length); hwaddr len =3D l; @@ -702,8 +702,7 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, } 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); + " element %d\n", __func__, i); if ((*iov)[i].iov_base) { i++; /* cleanup the 'i'th map */ } @@ -770,7 +769,8 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g, return; } =20 - ret =3D virtio_gpu_create_mapping_iov(g, &ab, cmd, &res->addrs, &res->= iov); + ret =3D virtio_gpu_create_mapping_iov(g, ab.nr_entries, sizeof(ab), + cmd, &res->addrs, &res->iov); if (ret !=3D 0) { cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; return; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 6fd86d6b92..879f4cfff6 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -220,7 +220,7 @@ void virtio_gpu_get_display_info(VirtIOGPU *g, void virtio_gpu_get_edid(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd); int virtio_gpu_create_mapping_iov(VirtIOGPU *g, - struct virtio_gpu_resource_attach_backin= g *ab, + uint32_t nr_entries, uint32_t offset, struct virtio_gpu_ctrl_command *cmd, uint64_t **addr, struct iovec **iov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, --=20 2.26.2