From patchwork Thu Aug 31 09:32:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67257C83F10 for ; Thu, 31 Aug 2023 09:34:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbe3n-0006Xz-CI; Thu, 31 Aug 2023 05:33:55 -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 1qbe3l-0006Tk-VW for qemu-devel@nongnu.org; Thu, 31 Aug 2023 05:33:53 -0400 Received: from mail-bn8nam12on2062a.outbound.protection.outlook.com ([2a01:111:f400:fe5b::62a] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbe3j-0005EH-1L for qemu-devel@nongnu.org; Thu, 31 Aug 2023 05:33:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QwdBHpikxg+u6vtMqlUrgQsxp7wZqkQYDGekSDzmr78zxQk/+QJt/dI+jcGuGIz6ubdvy3KaktWHUUGDJUvAQ/zFiEtzCj+uZXzSaRBIDNtIkQheWJWyjPXUJ6+BPPsLR722zthgbx4S899YW6Rue1fi9ackUt1gzZugLUoYsdjQuojF1sxGGl0UgY9uRw85Jq/gbB+Lqxg2t0lfJA+A3DKGmqTt+VtshlwI2qKuE+Bu3wk7vMjvdOv13I5Wk9TbspwkxIoUDXDZA7mmUUT8b8JVl6zM6LdW6+T8urtkeWjomnKQDabz6PoU6l+19MoMjibPPe9VWtGCh2L/pka9Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rHy1UnKuYteMitn9Vk2LwqyNhuJGyfSsajh1mjfyeBw=; b=Tgy+UduxNkkARnYG6rDOZ+gEVXVpWfjqMZmE83Xi2KEhRiloZDaxv9yZ/8bWymQM92Uz3fb8sEQUD/ah7e+an4htlwCW/ySCUfJvK/frq0OSXTJ5aEJV2yheVQpy961wWQtDcohZHgakK9jr9ofbNgsBYKEJgUv+EZXHvqqxjaRyhrp05GdtwEH9VS31qXILq6r3lge+YcMcm4Jgzi6M/8T7aROhrFXOJYfFk3qeSNlBLm5fgoQZ8gy0YN8thHrnFeOggiETGW3ZxKm7i0h4s9V85GMhUfvkufHNhVjEWW4oBcKtTptFAZ6nxlOYhzrMhRaLsOfbIXeeUjLpuSPAqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rHy1UnKuYteMitn9Vk2LwqyNhuJGyfSsajh1mjfyeBw=; b=39yVksiDQviA5sHuwbueLZmZYBQMvgRcUxrCQkbjcA17QmOdpFDY+bdiWTQtuph7RjAMvRyovAHCr5NRKEzwypA8LKjiULqS6gLZuDv6d3dPkSlKs5Ny5zGoPzX18c2FsEOnszJxWg5QQ/0ZAmUJrEMvYgfBesJ87gtglgXO+L4= Received: from MW4PR04CA0300.namprd04.prod.outlook.com (2603:10b6:303:89::35) by MW3PR12MB4362.namprd12.prod.outlook.com (2603:10b6:303:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21; Thu, 31 Aug 2023 09:33:46 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:303:89:cafe::1a) by MW4PR04CA0300.outlook.office365.com (2603:10b6:303:89::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.23 via Frontend Transport; Thu, 31 Aug 2023 09:33:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:33:46 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:33:39 -0500 From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Emmanouil Pitsidianakis , Huang Rui Subject: [QEMU PATCH v4 04/13] virtio-gpu: blob prep Date: Thu, 31 Aug 2023 17:32:43 +0800 Message-ID: <20230831093252.2461282-5-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EA:EE_|MW3PR12MB4362:EE_ X-MS-Office365-Filtering-Correlation-Id: 37def332-56e8-4a92-8515-08dbaa056037 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ypX+zPPIP7BDXemVD5Igaq8W6nOq03cx/+RqbqaF8EtCLjlqHZFmsA/VC5RJWNSlBFZh9fY6Lki+8ZcJ7Q3741BH7FW5Wrcq26SlO7Ttd8fAYtdgxwVr+O+9Jx0pS9qp1vAWuNYGtknsiLoPT+rLxzzJOQ8cX6SSq6kaLVQ2cb8fiRx0gj8YV7m83b1QZwG43Y2eiwBwjMzvBOGXKfdLUwGwDAkNyxOhi8523YuGqd0zLCCDRDwab+He7WsRGfy+tJPn++cpxIT/CS1N9nWnBxt7y0REmy9XXkB84J/MGQZ/F2NDOxbgEd1nN8P7x9JM1+oEk/hs/PSw8IkBqHLYoEW0HFeAm+dPSYiPN4ks/e+qpP4bGlI/7VmzhBGFIHdYoAQFXgCSQEEKiPOqH1v+RKvD4oFJhJjQUs2sYTfRY2pXzm/6g+ec+3b8WMw2NZAdSfsgq9VGeinH1fPcvrFhzUdBLqqHu1zE80UElPu2ZCQjzkdxTFkcccdH//ksVmdbidIprodVByFsNyiYACPpm4tI2imolXLggRj+uo/mirSu7OxVQzSJ3RgCjo0XfSYeIjJg95PpTC7MTUSxd9OzY2yYwmgoMjbRl/2P1seobBkO+8DqBUbv0GkTV6molg74WQBK/NX875ZeIiiKXNQkrmwtntCtRvSHUebg8grvge3+pjNhMVX/CSyXq+aHKrwGd9v7q5YlmJITGmrJKE4lGtGsUVSZMGg7iM2tMSJRWzuQBUkGfSMr7qEVZVUK9xw5AxWDFB0fRfpyADoktiky7O3v/DW/8L/2Ua3coSr3ABE= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(376002)(39860400002)(346002)(396003)(1800799009)(82310400011)(451199024)(186009)(36840700001)(40470700004)(46966006)(356005)(921005)(81166007)(7696005)(82740400003)(6666004)(40460700003)(36756003)(86362001)(36860700001)(40480700001)(47076005)(1076003)(2616005)(2906002)(336012)(426003)(26005)(16526019)(83380400001)(478600001)(41300700001)(110136005)(70586007)(70206006)(4326008)(8936002)(5660300002)(8676002)(7416002)(54906003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:33:46.7304 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37def332-56e8-4a92-8515-08dbaa056037 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4362 Received-SPF: softfail client-ip=2a01:111:f400:fe5b::62a; envelope-from=Ray.Huang@amd.com; helo=NAM12-BN8-obe.outbound.protection.outlook.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, SPF_HELO_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 Signed-off-by: Huang Rui --- This patch is already under review as part of the "rutabaga_gfx + gfxstream" series (already in v13) and has been included here because of dependency. 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 @@ #define VIRTIO_GPU_VM_VERSION 1 -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); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -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); } -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 = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-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); } +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);