From patchwork Thu Feb 13 15:49:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Lopez X-Patchwork-Id: 13973509 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 136E7C0219D for ; Thu, 13 Feb 2025 15:50:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7840110E418; Thu, 13 Feb 2025 15:50:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="RSOnD7uK"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id D090C10E418 for ; Thu, 13 Feb 2025 15:50:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739461832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1fVXikV8P1LkgFcbRBlcEvzt5syfU3+P/BigpIdLnzk=; b=RSOnD7uKANVHPPjQqwmUBr8bpaER8Mm8fCHqu9L/Ewk2q0P2gSjHlM1DpLwhgSiTDK9Y/R RHSuD4SGgftE3TGllouOHmPeb+JWjQssVVkM3MLqwoF/OYX75X3Chu82YQKDJQ/MSrppzU rY2w5/kNOBejivbfrhEftamaa2K0584= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-J6oyb48CNzyxvZ0MBGqsig-1; Thu, 13 Feb 2025 10:50:27 -0500 X-MC-Unique: J6oyb48CNzyxvZ0MBGqsig-1 X-Mimecast-MFC-AGG-ID: J6oyb48CNzyxvZ0MBGqsig_1739461825 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0E8BB1801A10; Thu, 13 Feb 2025 15:50:25 +0000 (UTC) Received: from [127.0.1.1] (unknown [10.44.33.58]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 772DC1800360; Thu, 13 Feb 2025 15:50:18 +0000 (UTC) From: Sergio Lopez Date: Thu, 13 Feb 2025 16:49:15 +0100 Subject: [PATCH RFC 1/5] virtio_config: add page_size field to virtio_shm_region MIME-Version: 1.0 Message-Id: <20250213-virtio-shm-page-size-v1-1-5ee1f9984350@redhat.com> References: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> In-Reply-To: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> To: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , Rob Clark , Dmitry Osipenko , fnkl.kernel@gmail.com Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sergio Lopez X-Developer-Signature: v=1; a=openpgp-sha256; l=1763; i=slp@redhat.com; h=from:subject:message-id; bh=+qQii47gVXmTejLfeLZU+l1N1V1AmJTe9gWUPiChZlk=; b=owEBbQKS/ZANAwAIAfRpJ40vDAI1AcsmYgBnrhSshG64fW01+xhzuZqXCMLC7NXEfn5yLipGi IaFlLqd0BSJAjMEAAEIAB0WIQS+1fz3US2GgJFC6KL0aSeNLwwCNQUCZ64UrAAKCRD0aSeNLwwC NbXfD/9qFc2tvGOvmLc1hX9AToxwFuJLODy+wh/JCKJ0kVlIFFawHMAuv7YgbNDQy8TaKg4SqYb 2l4J66ckcb+K8r5LScEQQ5h5LuCFPrl9vMg5KRXqpAJDHGmSh5R1v0wZg+1bJLQ97cIl5HnokjR 7CDf1ixnq+TBit7ow8qqwXUM5gSYnr4CUmElqLa8Iuhoc7PO52Qq4Wi3L9bLyrUxowu4evOvG9o /lAiFt2lgcWobvolGEet7TF61vsM1WrgwZTMOJhHUw3gXYFumykNve7r2xsDfeyn1NjIeN1U+rO 49ExshVLhu9aYwqs/d9/PIZsGZcdxBAu2qhW7v8WBQ6nK+tc7/c64gME11wPCDWYFG1BhOgF+Di gl3TbTEeIgWnfLlPfh9l1xESbAuJ7g9neaJjt3kyFd4AhsqHLnk0+v/9VQtd9cZH9cFG78qCgMB QVraengJqP/e7MyUDG48qaZjpXY4lLU0qVjKBiazMJ9ULgXwKMRpynKZ2jyHmTyBDpxvED0jwY9 k5es/7dEPsLKgLwem7D3bvevy3vUdraHeHjxW0Tj3S+ow4L0m7Pov1nMVzeIoEMX21T4dVVXF10 vPJvo7erwJyeMkD4GTHVq2wA6glxZHtHekYcjCJ2QLn83LMNKkW1VfPe4ON8gr/OSrl7tFFSAxM VTT2zDaCu+V1hyg== X-Developer-Key: i=slp@redhat.com; a=openpgp; fpr=BED5FCF7512D86809142E8A2F469278D2F0C0235 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a page_size field to virtio_shm_region to store page size supported by the device. This is required to support running VMs with a page size smaller than the host, among other potential scenarios. Signed-off-by: Sergio Lopez --- drivers/virtio/virtio_mmio.c | 2 ++ drivers/virtio/virtio_pci_modern.c | 1 + include/linux/virtio_config.h | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index 5d78c2d572abfcfe2b84cdd82df622320fe97d5d..cd0a0407659517e6a318b117ba67258c59f1f983 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -560,6 +560,8 @@ static bool vm_get_shm_region(struct virtio_device *vdev, region->addr = addr; + region->page_size = 4096 >> 12; + return true; } diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index 5eaade7578606e4b02af0d66447417ad6aa11064..4e6c28aacd1b5dfc117337a689a25d668805e334 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -862,6 +862,7 @@ static bool vp_get_shm_region(struct virtio_device *vdev, region->len = len; region->addr = (u64) phys_addr + offset; + region->page_size = 4096 >> 12; return true; } diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 169c7d367facb36dcabf9596068580ea8b8516c7..21ada8fcdf655894bb725045f54c9db3a1492b13 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -14,6 +14,7 @@ struct irq_affinity; struct virtio_shm_region { u64 addr; u64 len; + u16 page_size; /* PAGE_SIZE >> 12 */ }; typedef void vq_callback_t(struct virtqueue *); From patchwork Thu Feb 13 15:49:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Lopez X-Patchwork-Id: 13973510 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 96221C0219D for ; Thu, 13 Feb 2025 15:50:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C3A310EB12; Thu, 13 Feb 2025 15:50:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="DgACdXV6"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 818D610EB12 for ; Thu, 13 Feb 2025 15:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739461841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6TQz/AuXSm/jcXE77n/JSiGUw0PfjU842fJdja2/VcI=; b=DgACdXV6zHZQ4V0Zvyz+DTYN2wmrAcQzd+W339B+tn8KWKcg+mV4+byOt3FYf1queOnt5Z gkMZ9KDuJcaZjde2OQtFwHSOZphxVt2+hSitSNqPiBeHw2ku1YLgttzJ5IrHblPIKskLpv Fv0kZhUJzr23SUqOQVwaiWyFszpHAtM= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-52usUm0fP0qRHnq_Qf1pew-1; Thu, 13 Feb 2025 10:50:33 -0500 X-MC-Unique: 52usUm0fP0qRHnq_Qf1pew-1 X-Mimecast-MFC-AGG-ID: 52usUm0fP0qRHnq_Qf1pew_1739461831 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4AD4818004A7; Thu, 13 Feb 2025 15:50:31 +0000 (UTC) Received: from [127.0.1.1] (unknown [10.44.33.58]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 93C9B1800365; Thu, 13 Feb 2025 15:50:25 +0000 (UTC) From: Sergio Lopez Date: Thu, 13 Feb 2025 16:49:16 +0100 Subject: [PATCH RFC 2/5] virtio: introduce VIRTIO_F_SHM_PAGE_SIZE MIME-Version: 1.0 Message-Id: <20250213-virtio-shm-page-size-v1-2-5ee1f9984350@redhat.com> References: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> In-Reply-To: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> To: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , Rob Clark , Dmitry Osipenko , fnkl.kernel@gmail.com Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sergio Lopez X-Developer-Signature: v=1; a=openpgp-sha256; l=2345; i=slp@redhat.com; h=from:subject:message-id; bh=QFdyFSfT3/4SWG9ZxXlf5iQzWwyJCONhEMZSH8OxQDM=; b=owEBbQKS/ZANAwAIAfRpJ40vDAI1AcsmYgBnrhStylNLMTT77Zr70CH3mC0kJqxktuN3LCCsg tnCFcVTa3yJAjMEAAEIAB0WIQS+1fz3US2GgJFC6KL0aSeNLwwCNQUCZ64UrQAKCRD0aSeNLwwC NZqmD/9DXwIcQu7/ILLvZOWvdxn9+Ye3CGeCADk5JnxPU0Z81fskxGRGa5lTCHCY87Gl6QFEQvG UINwli3B85/HdKrWo022BePUxPTQLp5FozatRSG+T0//2+1gw0lolaTesnkIjXxfCgXGxh5s4gD gon6X0A+PtUWkum0UJokqKyxVxoIHg1SeQGpSYZwBzKNuTx8gNz4CVmaIZIx3lEFL8/UjduIzY6 aYA+EwkVMrmxdpdNPHRoWvl/qnurDh2eLUqHeHt61PzwaxUmoSZZgxhjxc9/44WZUI4PIJdQtZe xFZlFVIGMrMPlEHk98UIIdgre9Np2XB3mhuntMoP+7LEDp8EYOBxvMPxWWQkTL/M/8s0BqAjKjG ja3grjYBvXaEPT8F8MJmsRnDKCJb57A2Wi6mQE+YBQ6TKLR0lKp0GzbLm05FuQWigxRhQnDa/qA Yztgpc4cpiZRsgqBs37g/+/S4c6sv8EcKtD/M0Wy7SA0yQtKPHVJglGxTwgguF89CqM7rW3Ozg4 QslBotsRTVlGACVi9qQwHmSKL1Rb/AWw8sz9OviHsYVkGwWpR8J81ToeFq4Zvd8luCRQhlD73kW YpvG7lyZEUdPEhyAkRDZaQ4IP4BQlHcQTm4Wu7fedAfdWYWFB1tJYWPx1lonn8AbXvZxppC4Qf3 TkqlXm2Fs5sykTQ== X-Developer-Key: i=slp@redhat.com; a=openpgp; fpr=BED5FCF7512D86809142E8A2F469278D2F0C0235 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce VIRTIO_F_SHM_PAGE_SIZE, a feature bit which indicates that the transport provides the page size for SHM regions. Signed-off-by: Sergio Lopez --- drivers/virtio/virtio_pci_modern.c | 3 +++ drivers/virtio/virtio_ring.c | 2 ++ include/uapi/linux/virtio_config.h | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index 4e6c28aacd1b5dfc117337a689a25d668805e334..79616ce5057bf3b2b88cae7e8fb7729efa9dd632 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -367,6 +367,9 @@ static void vp_transport_features(struct virtio_device *vdev, u64 features) if (features & BIT_ULL(VIRTIO_F_ADMIN_VQ)) __virtio_set_bit(vdev, VIRTIO_F_ADMIN_VQ); + + if (features & BIT_ULL(VIRTIO_F_SHM_PAGE_SIZE)) + __virtio_set_bit(vdev, VIRTIO_F_SHM_PAGE_SIZE); } static int __vp_check_common_size_one_feature(struct virtio_device *vdev, u32 fbit, diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index fdd2d2b07b5a2aca864bc917306536685afb66a6..d853d5cf7e553be8bbe0ff461dc7312b258c6e58 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -2983,6 +2983,8 @@ void vring_transport_features(struct virtio_device *vdev) break; case VIRTIO_F_NOTIFICATION_DATA: break; + case VIRTIO_F_SHM_PAGE_SIZE: + break; default: /* We don't understand this bit. */ __virtio_clear_bit(vdev, i); diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h index 2445f365bce74b4e926c6929322b269252ab6830..3171e3792263c2cd472ac09da18e593ab400751d 100644 --- a/include/uapi/linux/virtio_config.h +++ b/include/uapi/linux/virtio_config.h @@ -52,7 +52,7 @@ * rest are per-device feature bits. */ #define VIRTIO_TRANSPORT_F_START 28 -#define VIRTIO_TRANSPORT_F_END 42 +#define VIRTIO_TRANSPORT_F_END 43 #ifndef VIRTIO_CONFIG_NO_LEGACY /* Do we get callbacks when the ring is completely used, even if we've @@ -120,4 +120,9 @@ */ #define VIRTIO_F_ADMIN_VQ 41 +/* + * This feature indicates that the transport provides the SHM page size. + */ +#define VIRTIO_F_SHM_PAGE_SIZE 42 + #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ From patchwork Thu Feb 13 15:49:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Lopez X-Patchwork-Id: 13973511 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 0D58AC021A0 for ; Thu, 13 Feb 2025 15:50:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F5C510EB14; Thu, 13 Feb 2025 15:50:47 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="f+9V9dI0"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id C192110EB14 for ; Thu, 13 Feb 2025 15:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739461845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xk1Yohdv6xG1LIYdCE6weZxWdHnGQzZeQusGiNbS4YE=; b=f+9V9dI0nul2b20g6a50ORvMOrETMO7sLgbBFmk8Z2Lqx23JF2Z10ayTogk9uW/PGXIu3g nFe86bwuXpzhyQ3phLfBZFWvdwLcnklY6XRcNRVA/305DY8IeLDfgVKp7pepvyodQ1t44s 4/JVsvFgFS/S4qWCtE4jh9rJmbG/DOQ= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-369-xQRG1M1ZOk2Exaus-VHC1w-1; Thu, 13 Feb 2025 10:50:40 -0500 X-MC-Unique: xQRG1M1ZOk2Exaus-VHC1w-1 X-Mimecast-MFC-AGG-ID: xQRG1M1ZOk2Exaus-VHC1w Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 95E9A1801A1A; Thu, 13 Feb 2025 15:50:38 +0000 (UTC) Received: from [127.0.1.1] (unknown [10.44.33.58]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D250E1800365; Thu, 13 Feb 2025 15:50:31 +0000 (UTC) From: Sergio Lopez Date: Thu, 13 Feb 2025 16:49:17 +0100 Subject: [PATCH RFC 3/5] virtio-pci: extend virtio_pci_cap to hold page_size MIME-Version: 1.0 Message-Id: <20250213-virtio-shm-page-size-v1-3-5ee1f9984350@redhat.com> References: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> In-Reply-To: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> To: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , Rob Clark , Dmitry Osipenko , fnkl.kernel@gmail.com Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sergio Lopez X-Developer-Signature: v=1; a=openpgp-sha256; l=3726; i=slp@redhat.com; h=from:subject:message-id; bh=th8ICZQzwvAj4jti147i6LTZteZNR2JRdjJgrinPxuc=; b=kA0DAAgB9GknjS8MAjUByyZiAGeuFK6g0IYF5gNoVdDWEYIgYw+KDGgrgUaUt6Ss3HnaKn8f5 okCMwQAAQgAHRYhBL7V/PdRLYaAkULoovRpJ40vDAI1BQJnrhSuAAoJEPRpJ40vDAI12zkP/iYs PuEmv6T8Yt/q5MJgGj+Z3qujU/ygCd+imitAs8P6jGFZsAI82+UupJ+bTmoQpp9gsV7yR+5sLmT ik8o0shqm97DkSwU26UmT4Ny7pHoeo4fOxmMw+7KIxIbIsIUk/zDfT0xGGygXkKKfOy6l9BDL6j pyYQ8cG8JUfoCauMj/dwTcAUg+t3S9xq6+artRq85AS38zrlte2kgQqwZwajyjd9Z9+XFZW+cLf mbllQF7x8RlU+ibEnds0qwScmLx47kZi6G/K8FlcUpe197W3LlUZkHYmQINMvHeGtN5qUJgDRK+ Ks8xl0mD2q52Rn0vRnbWElGjQ16fvg/opYjr5uBie3u5W4xbRxovh7xjZbAXM1wyycaNllgLUfv JyvrzCpRa2K/R8HNgwySlpZqlf7ybsSHK+Swy6Yl3K3qtqJuS0NhbAh8OhN1xda92SBtflPibBw ZlHWC1q89oEjcAORxPJOrHUslXx1NJbuprjTNJntzJwNBmSZmcypQgc0GfYeF0OxLNKUd8X9z+z M3F/grb33qsAgdcVRnOhEM5RIQf/LH+DDBYdryYWRgAYK5QHWRuYrhcgDRH7BS1t6SJk8VpSdGV 4bzh2p+K0TvpZ39fD1Vjwpij0LncXAWsMEJ54MDZxZUYAhvUL79Y+50S2Zjs4C9SC6hDYIgeeeh HcTcN X-Developer-Key: i=slp@redhat.com; a=openpgp; fpr=BED5FCF7512D86809142E8A2F469278D2F0C0235 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Turn the 16 bit padding into a page_size field to allow the device to pass its required page size with format PAGE_SIZE >> 12. Signed-off-by: Sergio Lopez --- drivers/virtio/virtio_pci_modern.c | 29 +++++++++++++++++++++++++---- include/uapi/linux/virtio_pci.h | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index 79616ce5057bf3b2b88cae7e8fb7729efa9dd632..26e9cd5148c0f10209c34d12e65d64490a855d75 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -770,14 +770,16 @@ static void del_vq(struct virtio_pci_vq_info *info) vring_del_virtqueue(vq); } -static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id, - u8 *bar, u64 *offset, u64 *len) +static int virtio_pci_find_shm_cap(struct virtio_device *vdev, struct pci_dev *dev, + u8 required_id, u8 *bar, u64 *offset, u64 *len, + u16 *page_size) { int pos; for (pos = pci_find_capability(dev, PCI_CAP_ID_VNDR); pos > 0; pos = pci_find_next_capability(dev, pos, PCI_CAP_ID_VNDR)) { u8 type, cap_len, id, res_bar; + u16 res_psize = 0; u32 tmp32; u64 res_offset, res_length; @@ -808,6 +810,23 @@ static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id, * Looks good. */ + if (__virtio_test_bit(vdev, VIRTIO_F_SHM_PAGE_SIZE)) { + pci_read_config_word(dev, pos + offsetof(struct virtio_pci_cap, + page_size), &res_psize); + if (!res_psize) { + dev_err(&dev->dev, "%s: shm cap with invalid page size on " + "a device with VIRTIO_F_SHM_PAGE_SIZE feature\n", + __func__); + res_psize = 4096 >> 12; + } + } + + /* For backwards compatibility, if the device didn't specify a + * page size, assume it to be 4096. + */ + if (!res_psize) + res_psize = 4096 >> 12; + /* Read the lower 32bit of length and offset */ pci_read_config_dword(dev, pos + offsetof(struct virtio_pci_cap, offset), &tmp32); @@ -829,6 +848,7 @@ static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id, *bar = res_bar; *offset = res_offset; *len = res_length; + *page_size = res_psize; return pos; } @@ -841,11 +861,12 @@ static bool vp_get_shm_region(struct virtio_device *vdev, struct virtio_pci_device *vp_dev = to_vp_device(vdev); struct pci_dev *pci_dev = vp_dev->pci_dev; u8 bar; + u16 page_size; u64 offset, len; phys_addr_t phys_addr; size_t bar_len; - if (!virtio_pci_find_shm_cap(pci_dev, id, &bar, &offset, &len)) + if (!virtio_pci_find_shm_cap(vdev, pci_dev, id, &bar, &offset, &len, &page_size)) return false; phys_addr = pci_resource_start(pci_dev, bar); @@ -865,7 +886,7 @@ static bool vp_get_shm_region(struct virtio_device *vdev, region->len = len; region->addr = (u64) phys_addr + offset; - region->page_size = 4096 >> 12; + region->page_size = page_size; return true; } diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h index 8549d4571257142ac6c9dad5c01369923791a85a..fb0ccb7a125d8178c1f78333c4d2f43540e1764b 100644 --- a/include/uapi/linux/virtio_pci.h +++ b/include/uapi/linux/virtio_pci.h @@ -127,7 +127,7 @@ struct virtio_pci_cap { __u8 cfg_type; /* Identifies the structure. */ __u8 bar; /* Where to find it. */ __u8 id; /* Multiple capabilities of the same type */ - __u8 padding[2]; /* Pad to full dword. */ + __u16 page_size; /* Device page size (PAGE_SIZE >> 12). */ __le32 offset; /* Offset within bar. */ __le32 length; /* Length of the structure, in bytes. */ }; From patchwork Thu Feb 13 15:49:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Lopez X-Patchwork-Id: 13973512 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 35DFBC021A4 for ; Thu, 13 Feb 2025 15:50:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7DEE10E468; Thu, 13 Feb 2025 15:50:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="ZmaAZsf3"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6B43910E468 for ; Thu, 13 Feb 2025 15:50:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739461851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CPDMwS7WtZbaodmU1wGmDq5U/O9YW9budAUbZ3K875k=; b=ZmaAZsf3BnyjX42m2BiOBWXd5n4PHSky2DcFBpDSIdEenv6mQ/Je5qiExONI596iVnmXtX 1HSTo8vsWcypGBOHemI3vOOvcHwmhAyYsR8s2xlfIi1kh/7YiJ/lt/mJ7l0SMK/sGJMDCM vxpqWtn5WKZrJZWmk0U+UdoAYtXiUI8= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-_FzdwdRkNT2W6LkuU2I1vA-1; Thu, 13 Feb 2025 10:50:47 -0500 X-MC-Unique: _FzdwdRkNT2W6LkuU2I1vA-1 X-Mimecast-MFC-AGG-ID: _FzdwdRkNT2W6LkuU2I1vA Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 41D03180087A; Thu, 13 Feb 2025 15:50:45 +0000 (UTC) Received: from [127.0.1.1] (unknown [10.44.33.58]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 399FD1800365; Thu, 13 Feb 2025 15:50:38 +0000 (UTC) From: Sergio Lopez Date: Thu, 13 Feb 2025 16:49:18 +0100 Subject: [PATCH RFC 4/5] virtio-mmio: read shm region page size MIME-Version: 1.0 Message-Id: <20250213-virtio-shm-page-size-v1-4-5ee1f9984350@redhat.com> References: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> In-Reply-To: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> To: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , Rob Clark , Dmitry Osipenko , fnkl.kernel@gmail.com Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sergio Lopez X-Developer-Signature: v=1; a=openpgp-sha256; l=2018; i=slp@redhat.com; h=from:subject:message-id; bh=4BHYqTf3/QJ4WE/gAmQswAKbmL+cD4+SAvyJx3zmY/M=; b=owEBbQKS/ZANAwAIAfRpJ40vDAI1AcsmYgBnrhSvDxI+WiTFN3JL/Qzuc2xiWNP3Mq2/qlssR XCntYrlp4eJAjMEAAEIAB0WIQS+1fz3US2GgJFC6KL0aSeNLwwCNQUCZ64UrwAKCRD0aSeNLwwC NcgyEACLL8igsV/fv85sL628B2GV9AZjCunwvzxWR2iisluQIOSnZCHY+0QygQbUzoiTicAsuDm pc1Lt/w68Q2kicl2BPqt00LuLWEJW+dqD6KHg1QL8y81xwyr0o/9TJtcTGMTKpnVKCNUt78FELL 3p57CcqBHqx1XnB4zA6g55eXVRCLgeFcDQTU+To18nWO/TGBA9tqZ7LGwUQ4xoS9QLnfLTdxKDw 4uxV2jlWwcM7aF/b9ppSvaysZmSz7u9CRjE1Yj2a2+fuMuIJ0e23kh7Vswkq5XVYKfpRrxqt5S9 K0BiVzJfXX8tnsw03vVv6O1BoNoLtpCmJF/5tk8XklLuLWl/TPX3vMhTgrPwVWfMHp4wDgyOe92 ApmaolMa0EFOSkFnBKQChdy8mVndj199Lv6m5VVn84Os8FjryN5U56IxiK1d7BW3spvROFbDSDc JHZEDzzTlDwWvBdXaflKCl91v4TEbM/+DCClnJog/We9b7Lc2IjhZOogQByvtLYzuA7gJilev7/ R4upFNDmmJyR/R0s5BCDFtsD84ksi+zIVGSAfAuWsGhMtH+FgX4QM4YYLwR7VzszydWHVWcraSZ wZpZscSrkW3Y58y80OkSFnAEmy1fROyRuNV2eFZJnQsfaWKvEQ7qIYoQgBhEq6K94FZBN13SQkB 3SflZNBJcWr/tvQ== X-Developer-Key: i=slp@redhat.com; a=openpgp; fpr=BED5FCF7512D86809142E8A2F469278D2F0C0235 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the newly introduced SHM_PAGE_SIZE register to read the page size and store it into virtio_shm_region. Signed-off-by: Sergio Lopez --- drivers/virtio/virtio_mmio.c | 13 ++++++++++++- include/uapi/linux/virtio_mmio.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index cd0a0407659517e6a318b117ba67258c59f1f983..92590c77901bee453d8c1a1ac60ad9cca90d1b59 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -537,6 +537,7 @@ static bool vm_get_shm_region(struct virtio_device *vdev, struct virtio_shm_region *region, u8 id) { struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev); + u16 page_size = 0; u64 len, addr; /* Select the region we're interested in */ @@ -560,7 +561,17 @@ static bool vm_get_shm_region(struct virtio_device *vdev, region->addr = addr; - region->page_size = 4096 >> 12; + /* If supported by the device transport, read the region page size */ + if (__virtio_test_bit(vdev, VIRTIO_F_SHM_PAGE_SIZE)) + page_size = (u16) readl(vm_dev->base + VIRTIO_MMIO_SHM_PAGE_SIZE); + + /* For backwards compatibility, if the device didn't specify a + * page size, assume it to be 4096. + */ + if (page_size == 0) + page_size = 4096 >> 12; + + region->page_size = page_size; return true; } diff --git a/include/uapi/linux/virtio_mmio.h b/include/uapi/linux/virtio_mmio.h index 0650f91bea6c70f935764070d825d181a2379afb..c5a1cdad5a1c9bc954d7facfd8c05e2acbb28e96 100644 --- a/include/uapi/linux/virtio_mmio.h +++ b/include/uapi/linux/virtio_mmio.h @@ -133,6 +133,9 @@ #define VIRTIO_MMIO_SHM_BASE_LOW 0x0b8 #define VIRTIO_MMIO_SHM_BASE_HIGH 0x0bc +/* Shared memory region page size, in format PAGE_SIZE >> 12 */ +#define VIRTIO_MMIO_SHM_PAGE_SIZE 0x0c4 + /* Configuration atomicity value */ #define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc From patchwork Thu Feb 13 15:49:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Lopez X-Patchwork-Id: 13973513 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 3D88EC021A4 for ; Thu, 13 Feb 2025 15:51:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B901D10EB15; Thu, 13 Feb 2025 15:51:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Grc/TklO"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62AD610EB15 for ; Thu, 13 Feb 2025 15:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739461858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PjmfsPFlVVF5AWgzzAtVJttyvI0k7JVXMhFtVMQApJc=; b=Grc/TklOlm7jeIK20gL4KiSrCYRar2vLZrxgAM6Lioz8lfzGFZH4V23Dk3diyKDydowSsf jBJe8GfrR+ah2l0YTidtGabe4+qqp5tc/y8jom6MOGJ2d2Nw/Ud501mFIlSZntLLA6bUfU BAHM7MPBDp+87I37NxqJ31VKXj1/7Tw= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-fWiTjEI6PDuewe8qZoXD2A-1; Thu, 13 Feb 2025 10:50:54 -0500 X-MC-Unique: fWiTjEI6PDuewe8qZoXD2A-1 X-Mimecast-MFC-AGG-ID: fWiTjEI6PDuewe8qZoXD2A_1739461852 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EC8641800873; Thu, 13 Feb 2025 15:50:51 +0000 (UTC) Received: from [127.0.1.1] (unknown [10.44.33.58]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 005321800360; Thu, 13 Feb 2025 15:50:45 +0000 (UTC) From: Sergio Lopez Date: Thu, 13 Feb 2025 16:49:19 +0100 Subject: [PATCH RFC 5/5] drm/virtio: add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE to params MIME-Version: 1.0 Message-Id: <20250213-virtio-shm-page-size-v1-5-5ee1f9984350@redhat.com> References: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> In-Reply-To: <20250213-virtio-shm-page-size-v1-0-5ee1f9984350@redhat.com> To: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , Rob Clark , Dmitry Osipenko , fnkl.kernel@gmail.com Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sergio Lopez X-Developer-Signature: v=1; a=openpgp-sha256; l=1826; i=slp@redhat.com; h=from:subject:message-id; bh=/aoLSKIJznnbsjZ5Jh4GqZ88soBWly62WzaVs9lwiik=; b=owEBbQKS/ZANAwAIAfRpJ40vDAI1AcsmYgBnrhSwhjgi2huewIbD11jfJzeBM0pBvdx+QXdjZ 3DYvQQ1INGJAjMEAAEIAB0WIQS+1fz3US2GgJFC6KL0aSeNLwwCNQUCZ64UsAAKCRD0aSeNLwwC NYbtD/9ctHlsRxX0qc3/D6Bh638ZBZMa+fSdL8lFea6UYOw7mU4npndqsYsJPx/wr7U7n83Vaxr tUcKqrDkgaw8ya+Vm/2cD1JWs4+37Bf1qUBHArqwpTPzeNuBPJk4Z624Bma7rYalRNE9BHYmttg ImMXqognhOLVo3GvnG5GKufzxW6Q56ta8LMoQi3/otB0Lp4bwE/tevyOgBJRInuGjoj1MmKTNR8 pcEbm65Nhdy1yhGxL1iJKVJCBaofqq2g1oNS8uq/mSaT9onuqhHdr3COGV9tlM5LoTJXN/kuNnk nChP1pIDBub/qUL495/Jxj90CDmmCxth/VET+s8B49dpCFNGj3SNzcVwjqj4bikjlObwuPv8NXA 0FBpGgpFLq3OdCDvd6e3TlrZMZ9MZp1U923btfwXJ7m65WU9MqRf67O4q2Vdw3/bzU1b6hUMR2x fULusPSIv6m+k7thSDqtWNrwAFSRQ3x4mrBCJDX2KryPkldQ3Qtj4NZOlnVCYAT+fL/XB7yfY5o c8YEStKGghk9W8RXB+Wfcvz2+uA9yPrpx3lZc6kG4W7YwSfciZm4c1upgMPktnF+HT68I65/Ksu fcvqVqY/pWDtFQgTriHjX6Xwbu3Uz+sAUwRcmODokFmPENr6xR4zb+qq8y8HB+1OVBvazTtTTej b1Xw9a5umUDKO/A== X-Developer-Key: i=slp@redhat.com; a=openpgp; fpr=BED5FCF7512D86809142E8A2F469278D2F0C0235 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE as a param that can be read with VIRTGPU_GETPARAM by userspace applications running in the guest to obtain the host's page size and find out the right alignment to be used in shared memory allocations. Signed-off-by: Sergio Lopez --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 5 +++++ include/uapi/drm/virtgpu_drm.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index c33c057365f85a2ace536f91655c903036827312..4b49635b4fe1d4256f219823341cef8e5fa8f029 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -117,6 +117,11 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, case VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME: value = vgdev->has_context_init ? 1 : 0; break; + case VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE: + if (!vgdev->has_host_visible) + return -EINVAL; + value = vgdev->host_visible_region.page_size; + break; default: return -EINVAL; } diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index c2ce71987e9bb816d13a300679336cb756f1cbcf..72db6b3339e0dcaf550acbf5ac4381a6e5c2216d 100644 --- a/include/uapi/drm/virtgpu_drm.h +++ b/include/uapi/drm/virtgpu_drm.h @@ -98,6 +98,7 @@ struct drm_virtgpu_execbuffer { #define VIRTGPU_PARAM_CONTEXT_INIT 6 /* DRM_VIRTGPU_CONTEXT_INIT */ #define VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs 7 /* Bitmask of supported capability set ids */ #define VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME 8 /* Ability to set debug name from userspace */ +#define VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE 9 /* Host SHM page size, with format PAGE_SIZE >> 12 */ struct drm_virtgpu_getparam { __u64 param;