From nobody Thu Nov 28 10:49:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=chromium.org ARC-Seal: i=1; a=rsa-sha256; t=1693269444; cv=none; d=zohomail.com; s=zohoarc; b=Hei6OTJOVY5HqpYNDPnLgBKfxgvbd9Snq1aMe2/lpon3hZliI7anAQfqZR8ceHgfDxrym1IeaR5fXk3Efnx25eJaK7UPGB9JNfmDHQb7Gwhnl+/dpHh8cH7lGHDXMkmrSU6anFzoa5Vkcm6mry00LodI3cjvnlcgVQ38a5fFM18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693269444; 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=i4auYAMkJAoT3CteyBTujoNIkKMTWEEO9PzlwutUR/M=; b=OXdULWNdsBkgS0970sjL6RcNMtduQTVOORcA/mX7Jxj6Bb+JZUf59ILXuB75FO1mDhAr0SYA4zyh6hZLoXUE/WQJVUwVbDOPrHpergrH6Kdb4zFnmzmhCCN4Sz4Bhb6uk4rCMNABDZgjpPM529n9AJl3j4iVkfVZJFi3R3sYPgE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693269444182408.9273894631136; Mon, 28 Aug 2023 17:37:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qamjJ-0007et-AH; Mon, 28 Aug 2023 20:37:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qamj6-0007dU-LX for qemu-devel@nongnu.org; Mon, 28 Aug 2023 20:37:02 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qamim-0007eb-CN for qemu-devel@nongnu.org; Mon, 28 Aug 2023 20:36:43 -0400 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3a85b9deeb3so2750711b6e.1 for ; Mon, 28 Aug 2023 17:36:38 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:a7:2:5fa1:f455:2676:5eee]) by smtp.gmail.com with ESMTPSA id c3-20020aa78c03000000b0068890c19c49sm7214782pfd.180.2023.08.28.17.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 17:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693269397; x=1693874197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i4auYAMkJAoT3CteyBTujoNIkKMTWEEO9PzlwutUR/M=; b=biUUkQoFn3iQaU0Mqc0YxikYuqkVWgA1flBfnr5JeIQYqcsIrhfjWMALU1ncbXblUU UeQKx56M6Ar0P/dBEVUh/KAoQra+BF2WoxMuOMPue7yaBuXIa8fwK1UbB/UhOlodsPLb U0DKzltd+OIYoEHN2lXCu7fNnMalBp7jP4se4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693269397; x=1693874197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i4auYAMkJAoT3CteyBTujoNIkKMTWEEO9PzlwutUR/M=; b=d3ubbznzXv+4NKEGaVb6cUHsQOYRdF8HTd0zkM9ns3LlFuKK+Esp5x6njx26FIxd3U q1SPHDh0l0tmtQk/ZzNSDJ6YbxofK0lEf+YChzIH5snpJ9TJdFt/L+KJRV/AmYGWjNUU PIJAX2VQuC3vAY/94Ct9CE0DdXoUL7u67Zmwp6iIguQskv3FflwykohiZqFqGIPM8gDs 4O0yARtEPHzbjm6gHS23fjHz4GSfggnzLNuY1FuJSsw8p6XU/d4iLU7g5FN1U82ErCEq 2GFpoY6Lj9QJNxFolAVHqrtKauT4GYTzCymDTf3PB5m5aV8puEpRvFBqpqf8tyg8XNlw jIrQ== X-Gm-Message-State: AOJu0Yzgn/rbQaiyriIpjxOgUARGpFeUWCt28UXq1c7UD4DN3CJW/d1q QhAFOF/+l4B9oYa9csOcYvpJTXlcnCVF+miW+SY= X-Google-Smtp-Source: AGHT+IGHZKIH9bNZXiiEf1OPGUFOzhuM7pRwh5TUwmPrlHTlqCYrWT5dpJoadZR07j0VxOKwxlYerw== X-Received: by 2002:a05:6808:1899:b0:3a7:4ce4:cb8e with SMTP id bi25-20020a056808189900b003a74ce4cb8emr15145477oib.42.1693269397649; Mon, 28 Aug 2023 17:36:37 -0700 (PDT) From: Gurchetan Singh To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, akihiko.odaki@gmail.com, ray.huang@amd.com, alex.bennee@linaro.org, shentey@gmail.com, hi@alyssa.is, ernunes@redhat.com, manos.pitsidianakis@linaro.org, philmd@linaro.org, mark.cave-ayland@ilande.co.uk Subject: [PATCH v13 4/9] virtio-gpu: blob prep Date: Mon, 28 Aug 2023 17:36:24 -0700 Message-Id: <20230829003629.410-5-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20230829003629.410-1-gurchetansingh@chromium.org> References: <20230829003629.410-1-gurchetansingh@chromium.org> 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=2607:f8b0:4864:20::233; envelope-from=gurchetansingh@chromium.org; helo=mail-oi1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @chromium.org) X-ZM-MESSAGEID: 1693269445663100003 Content-Type: text/plain; charset="utf-8" From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu.c | 10 +++------- include/hw/virtio/virtio-gpu-bswap.h | 15 +++++++++++++++ include/hw/virtio/virtio-gpu.h | 5 +++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 48ef0d9fad..3e658f1fef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ =20 #define VIRTIO_GPU_VM_VERSION 1 =20 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); =20 -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *= res); static void virtio_gpu_reset_bh(void *opaque); =20 void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_g= pu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } =20 -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } =20 -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *= res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov =3D NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virti= o-gpu-bswap.h index 637a0585d0..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -70,6 +70,21 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_= create_blob *cblob) le64_to_cpus(&cblob->size); } =20 +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ + virtio_gpu_ctrl_hdr_bswap(&mblob->hdr); + le32_to_cpus(&mblob->resource_id); + le64_to_cpus(&mblob->offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ + virtio_gpu_ctrl_hdr_bswap(&ublob->hdr); + le32_to_cpus(&ublob->resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); --=20 2.42.0.rc2.253.gd59a3bf2b4-goog