From patchwork Fri May 17 18:48:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Forbes X-Patchwork-Id: 13667304 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 D1499C04FFE for ; Fri, 17 May 2024 18:48:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5AE010EF55; Fri, 17 May 2024 18:48:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="fwyeylmB"; dkim-atps=neutral Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id 834EA10EF55 for ; Fri, 17 May 2024 18:48:39 +0000 (UTC) Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-43df732cb05so1894071cf.0 for ; Fri, 17 May 2024 11:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1715971718; x=1716576518; darn=lists.freedesktop.org; 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=WK8N/h+/padUDmQYlb95tFDuLkFafMA6LNdNhI1W/Xw=; b=fwyeylmBhsWidG04IntgalKkyZNzNoD/Cwdcp0lvoq2JrRa2m6YaYvNnybHni+8w4G A4V/M6xu2o+oAEjlSJs8JPn/8RhCULO5O5PvsfrLONNmeoHrC62DWciHQLvzgZKPHd7h pjxz0U844FqCQ+aFt37FYGxsUfeAvT9Z06DNo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715971718; x=1716576518; 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=WK8N/h+/padUDmQYlb95tFDuLkFafMA6LNdNhI1W/Xw=; b=jiEGNQsiT94Fv2LCx/FWZKoiR8zwL0QsYoj1XcQYOtM/eHCDX3a/YqFghZkJ0s4fyR SQbdCEJeTnBFCCBnDALjnzyevZFT7sDdW0yOStZ8es2Qubdl/9YsMyBPNN3v7Q3kYVom ohwGzoSuC/V8coEviv7nEx49UW/HBDLLcwckIaNamPiYFu2Gm/u2TFW9Y94v1DjWQUSC 9lYjER4N311yoqUy2vybCQUr+ce4UNAdtSrLcdLlcs5/7nPWCdiWyZED08cwb/XSXd8u cFwXY/6DG/7Ape2zWkO6xvGLVY2/XqcPwuySf0jFZ+U3bSAvZp7N3S6EGXkHSEoZ7w9n r5Hg== X-Gm-Message-State: AOJu0YxpcQ1m5RmW2++iVhysiGcI9LiwoSOS2MHQBnq0EUsuvZsZND6y LPqgNy1pZhkHeBiQy28tRL5Q5PUCgscJClfaz6lLP/+sL9WdtW79EkxRtkmMlvLHJePGBw8X+5/ opbw9clBUnNOfK7gwm1OKDDx9ZBv6KBx5ERXkhagAnku/+L1bo5WFwaAmuF6elpAzXxpMNOGkXS TC8XKh9Bj1ktLJJdZyh+S0MIcY5Ay4h1eTwfeLOPKKSdctHC9H4Q== X-Google-Smtp-Source: AGHT+IEz/48wwE/X9agI5ibWTyO8KJJsIXiDc20mWs5K4Ouqkoa/kfoaR1iC9DkwboKy81xdQqLcVw== X-Received: by 2002:a05:622a:1391:b0:43a:f7fb:9698 with SMTP id d75a77b69052e-43dfdd1b440mr240473401cf.41.1715971718097; Fri, 17 May 2024 11:48:38 -0700 (PDT) Received: from localhost ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43df87da55bsm109515441cf.33.2024.05.17.11.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 11:48:36 -0700 (PDT) From: Ian Forbes To: dri-devel@lists.freedesktop.org Cc: bcm-kernel-feedback-list@broadcom.com, zack.rusin@broadcom.com, martin.krastev@broadcom.com, maaz.mombasawala@broadcom.com, Ian Forbes Subject: [PATCH v2 1/4] drm/vmwgfx: Filter modes which exceed graphics memory Date: Fri, 17 May 2024 13:48:08 -0500 Message-Id: <20240517184811.25807-2-ian.forbes@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517184811.25807-1-ian.forbes@broadcom.com> References: <20240517184811.25807-1-ian.forbes@broadcom.com> MIME-Version: 1.0 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" SVGA requires individual surfaces to fit within graphics memory (max_mob_pages) which means that modes with a final buffer size that would exceed graphics memory must be pruned otherwise creation will fail. Additionally llvmpipe requires its buffer height and width to be a multiple of its tile size which is 64. As a result we have to anticipate that llvmpipe will round up the mode size passed to it by the compositor when it creates buffers and filter modes where this rounding exceeds graphics memory. This fixes an issue where VMs with low graphics memory (< 64MiB) configured with high resolution mode boot to a black screen because surface creation fails. Fixes: d947d1b71deb ("drm/vmwgfx: Add and connect connector helper function") Signed-off-by: Ian Forbes --- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 43 ++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c index 2041c4d48daa..a2b5527a249d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c @@ -43,7 +43,12 @@ #define vmw_connector_to_stdu(x) \ container_of(x, struct vmw_screen_target_display_unit, base.connector) - +/** + * llvmpipe will align the width and height of its buffers to match its + * tile size. We need to keep this in mind when exposing modes to userspace + * so that this possible over-allocation will not exceed graphics memory. + */ +#define LLVM_PIPE_TILE_SIZE 64 enum stdu_content_type { SAME_AS_DISPLAY = 0, @@ -829,7 +834,41 @@ static void vmw_stdu_connector_destroy(struct drm_connector *connector) vmw_stdu_destroy(vmw_connector_to_stdu(connector)); } +static enum drm_mode_status +vmw_stdu_connector_mode_valid(struct drm_connector *connector, + struct drm_display_mode *mode) +{ + enum drm_mode_status ret; + struct drm_device *dev = connector->dev; + struct vmw_private *dev_priv = vmw_priv(dev); + u64 assumed_cpp = dev_priv->assume_16bpp ? 2 : 4; + /* Align width and height to account for llvmpipe tile over-alignment */ + u64 required_mem = ALIGN(mode->hdisplay, LLVM_PIPE_TILE_SIZE) * + ALIGN(mode->vdisplay, LLVM_PIPE_TILE_SIZE) * + assumed_cpp; + required_mem = ALIGN(required_mem, PAGE_SIZE); + + ret = drm_mode_validate_size(mode, dev_priv->stdu_max_width, + dev_priv->stdu_max_height); + if (ret != MODE_OK) + return ret; + ret = drm_mode_validate_size(mode, dev_priv->texture_max_width, + dev_priv->texture_max_height); + if (ret != MODE_OK) + return ret; + + if (required_mem > dev_priv->max_primary_mem) + return MODE_MEM; + + if (required_mem > dev_priv->max_mob_pages * PAGE_SIZE) + return MODE_MEM; + + if (required_mem > dev_priv->max_mob_size) + return MODE_MEM; + + return MODE_OK; +} static const struct drm_connector_funcs vmw_stdu_connector_funcs = { .dpms = vmw_du_connector_dpms, @@ -845,7 +884,7 @@ static const struct drm_connector_funcs vmw_stdu_connector_funcs = { static const struct drm_connector_helper_funcs vmw_stdu_connector_helper_funcs = { .get_modes = vmw_connector_get_modes, - .mode_valid = vmw_connector_mode_valid + .mode_valid = vmw_stdu_connector_mode_valid }; From patchwork Fri May 17 18:48:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Forbes X-Patchwork-Id: 13667305 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 C53C2C04FFE for ; Fri, 17 May 2024 18:48:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE29610EF57; Fri, 17 May 2024 18:48:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="UvuSdble"; dkim-atps=neutral Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6ADDD10EF57 for ; Fri, 17 May 2024 18:48:47 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-792bae4137bso93803585a.3 for ; Fri, 17 May 2024 11:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1715971726; x=1716576526; darn=lists.freedesktop.org; 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=2+V6FmkDwYv1DNx9VbF748EO2AmTbcfb/gceTTlRkQI=; b=UvuSdbleEZrFiH9P8OirS2j7iq0hfj4GXs+isqvr2enQd6lzsWYlvVJ3E0Mw76dMX5 rzfyID6/xfzwtjezadK3AwxQyjTiWfwHYQPWMfW+ugpKL8Edaedf81R5SoAZgU3n47J9 uv72tpWgW9ZqpPdKbSrwcMuSr4m+ooo6tBb4k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715971726; x=1716576526; 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=2+V6FmkDwYv1DNx9VbF748EO2AmTbcfb/gceTTlRkQI=; b=sug7gmLePWV3JIK8dADgV85JpXRYwNqUwnFDjRGgEJ9yJQ88ygAgGA6Zte4D0BYCXh buujC0JqERp4pveVe5mBmvfLg+JK7fQbfx4ktQb3kyi9YlxJr8o2BEVdUR9CFgk155y/ mO8PxCWZkPRqCbBC6ClXLayOmXCr7BVg3y7gEWFPjtHvsF+G0XeopHFv3kHTYj+ba643 0LbTOTGDsUAj0zfAcFxWBUlcfXfqsJjiqdokax3yYC18mC4SZF572i5YBPZ+RTpL8NbV JGIxauQ19u0ZFmj+X+ZBhG7iwAzI/4I88Miy423ugtfHCHjMmvpiXLbUzvzs0lTUZoa5 jjpg== X-Gm-Message-State: AOJu0Yy22JNmH3CTSDzcCAJWbJhbWVIGYzxoLXFrEAX2SyXAf6y/kzER uVx2iAXjZj9msqJe+twhS4GW7wttElt+EOMU2hgXykbclWB+BHn0FRRLQLLL2fOuqwLZIi9kAO8 dI31KtvUkYBqbbsqxaCMYwvVVWtCHDpdIvNiIHQ7ReCeEIgB8VIWoE/rN+QWpFmBPl3Askat48k R0nGMgGXtIB4YXDXccu+yKthEewWuZKU9ccGHPOxw45o87EXxM4A== X-Google-Smtp-Source: AGHT+IGcKlnXakBVlcQdpbAhmbLAAsT9DM+gleyQ+gebMsomFkzffFGqrfgNeZPuJw47fvhd0P5aAg== X-Received: by 2002:ac8:5d44:0:b0:43c:5d8c:f854 with SMTP id d75a77b69052e-43dfdac38a5mr333681521cf.11.1715971726051; Fri, 17 May 2024 11:48:46 -0700 (PDT) Received: from localhost ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43df550c10fsm113882551cf.43.2024.05.17.11.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 11:48:45 -0700 (PDT) From: Ian Forbes To: dri-devel@lists.freedesktop.org Cc: bcm-kernel-feedback-list@broadcom.com, zack.rusin@broadcom.com, martin.krastev@broadcom.com, maaz.mombasawala@broadcom.com, Ian Forbes Subject: [PATCH v2 2/4] drm/vmwgfx: 3D disabled should not effect STDU memory limits Date: Fri, 17 May 2024 13:48:09 -0500 Message-Id: <20240517184811.25807-3-ian.forbes@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517184811.25807-1-ian.forbes@broadcom.com> References: <20240517184811.25807-1-ian.forbes@broadcom.com> MIME-Version: 1.0 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" This limit became a hard cap starting with the change referenced below. Surface creation on the device will fail if the requested size is larger than this limit so altering the value arbitrarily will expose modes that are too large for the device's hard limits. Fixes: 7ebb47c9f9ab ("drm/vmwgfx: Read new register for GB memory when available") Signed-off-by: Ian Forbes --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 4bf6da2b15fe..2e1fb46bcaa3 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -959,13 +959,6 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id) vmw_read(dev_priv, SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB); - /* - * Workaround for low memory 2D VMs to compensate for the - * allocation taken by fbdev - */ - if (!(dev_priv->capabilities & SVGA_CAP_3D)) - mem_size *= 3; - dev_priv->max_mob_pages = mem_size * 1024 / PAGE_SIZE; dev_priv->max_primary_mem = vmw_read(dev_priv, SVGA_REG_MAX_PRIMARY_MEM); From patchwork Fri May 17 18:48:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Forbes X-Patchwork-Id: 13667306 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 EE79AC04FFE for ; Fri, 17 May 2024 18:48:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 139B910EF58; Fri, 17 May 2024 18:48:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="ENKhWZbf"; dkim-atps=neutral Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EC8310EF58 for ; Fri, 17 May 2024 18:48:51 +0000 (UTC) Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3c99257e0cbso332376b6e.3 for ; Fri, 17 May 2024 11:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1715971730; x=1716576530; darn=lists.freedesktop.org; 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=NwLTSzkJVjfr3yIEgVUxQAA5OYE2rQN+MHnV5J9QSpc=; b=ENKhWZbfyvY+25qL0EQ/0PdEFLlU3QzoN7H2zCy5EvG7PphNTCdKxXsOkkB05MA/dT E+K0gMPKfhLhcZnVJ4/Ot5T5mYU5LpXtr6j/41kCdE60s+gpCaOq9gR8EeoCkWqZXqyV uD+Gbz5w9+KtH1O3+TiWMbSr/an3Ely8TVV4Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715971730; x=1716576530; 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=NwLTSzkJVjfr3yIEgVUxQAA5OYE2rQN+MHnV5J9QSpc=; b=UEf1wMwmfWgt/azdZ9u/Y9ccfm8baYdmCmrzLtgv2M1PxzQvPo2mAJarAOT9KWOeDS ji6Hf6EBYDVktTW0KdRdUoNiL8573oY3K/sfstimGhLOq8AwTDHiGlVzJSOdQPaie97W SZ2oZonGCBkCAtT7l25+/UXNWP4KGlWk5MuPAH0FHvR4mjQGvWMcx/pSv8JVZuMkrm5D GWVoyqvZQU0nJoFXAL5JF+p9q2FrKnnlQRi7ShVdd2nyDn+6TMN27nj/u9+qsR8e42yq AKR+IpbK8vCl9AFbefxDs9cOUbnFUCqjoHjJ4nhw0shj3gDltfrNXUMIdRLFG5eo4v9l QEpg== X-Gm-Message-State: AOJu0YyyP92pmufxslomTL+WBQMEDGUrje+V73yKDXaCi4rs/qqcpIcr VM8WBqcMgfXzovBr2SWYVpvU/HN6po4+lhqJaBwqXJVPDqpGtSdVjiPzzQbQs4u742/gJLJPKSe mOhQaXMduAYOrGVZkTHHR1gom4xvo2P8kcKJorPCLwBbVDHcUkaSt3qGTKjoFYd+MBEBKAUjIEo 38wIcB+WOMOEck4dErZeGQVjYHuo0VI6mqjyOExMBQzdX2FyGc/Q== X-Google-Smtp-Source: AGHT+IEZg2+O3xTU3bgiSKRo5ReeZlsvz9ihcKmn6CWDhekeT7oUSXJ7InsqDoGQ5gB1RovbFnF/dg== X-Received: by 2002:a05:6808:1803:b0:3c3:d47b:e4cf with SMTP id 5614622812f47-3c9970bd1c0mr27607475b6e.39.1715971729953; Fri, 17 May 2024 11:48:49 -0700 (PDT) Received: from localhost ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-792bf2fc57asm926571085a.81.2024.05.17.11.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 11:48:49 -0700 (PDT) From: Ian Forbes To: dri-devel@lists.freedesktop.org Cc: bcm-kernel-feedback-list@broadcom.com, zack.rusin@broadcom.com, martin.krastev@broadcom.com, maaz.mombasawala@broadcom.com, Ian Forbes Subject: [PATCH v2 3/4] drm/vmwgfx: Remove STDU logic from generic mode_valid function Date: Fri, 17 May 2024 13:48:10 -0500 Message-Id: <20240517184811.25807-4-ian.forbes@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517184811.25807-1-ian.forbes@broadcom.com> References: <20240517184811.25807-1-ian.forbes@broadcom.com> MIME-Version: 1.0 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" STDU has its own mode_valid function now so this logic can be removed from the generic version. Fixes: 935f795045a6 ("drm/vmwgfx: Refactor drm connector probing for display modes") Signed-off-by: Ian Forbes --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 3 --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 26 +++++++++----------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 4ecaea0026fc..a1ce41e1c468 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -1043,9 +1043,6 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, int vmw_kms_write_svga(struct vmw_private *vmw_priv, unsigned width, unsigned height, unsigned pitch, unsigned bpp, unsigned depth); -bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, - uint32_t pitch, - uint32_t height); int vmw_kms_present(struct vmw_private *dev_priv, struct drm_file *file_priv, struct vmw_framebuffer *vfb, diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 13b2820cae51..9532258a0848 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -2171,13 +2171,12 @@ int vmw_kms_write_svga(struct vmw_private *vmw_priv, return 0; } +static bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, - uint32_t pitch, - uint32_t height) + u64 pitch, + u64 height) { - return ((u64) pitch * (u64) height) < (u64) - ((dev_priv->active_display_unit == vmw_du_screen_target) ? - dev_priv->max_primary_mem : dev_priv->vram_size); + return (pitch * height) < (u64)dev_priv->vram_size; } /** @@ -2873,25 +2872,18 @@ int vmw_du_helper_plane_update(struct vmw_du_update_plane *update) enum drm_mode_status vmw_connector_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { + enum drm_mode_status ret; struct drm_device *dev = connector->dev; struct vmw_private *dev_priv = vmw_priv(dev); - u32 max_width = dev_priv->texture_max_width; - u32 max_height = dev_priv->texture_max_height; u32 assumed_cpp = 4; if (dev_priv->assume_16bpp) assumed_cpp = 2; - if (dev_priv->active_display_unit == vmw_du_screen_target) { - max_width = min(dev_priv->stdu_max_width, max_width); - max_height = min(dev_priv->stdu_max_height, max_height); - } - - if (max_width < mode->hdisplay) - return MODE_BAD_HVALUE; - - if (max_height < mode->vdisplay) - return MODE_BAD_VVALUE; + ret = drm_mode_validate_size(mode, dev_priv->texture_max_width, + dev_priv->texture_max_height); + if (ret != MODE_OK) + return ret; if (!vmw_kms_validate_mode_vram(dev_priv, mode->hdisplay * assumed_cpp, From patchwork Fri May 17 18:48:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Forbes X-Patchwork-Id: 13667307 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 0987DC04FFE for ; Fri, 17 May 2024 18:48:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5341910EF59; Fri, 17 May 2024 18:48:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="P6rpIEza"; dkim-atps=neutral Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id CCD7610EF59 for ; Fri, 17 May 2024 18:48:54 +0000 (UTC) Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-5aa20adda1dso1134439eaf.1 for ; Fri, 17 May 2024 11:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1715971734; x=1716576534; darn=lists.freedesktop.org; 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=4UdLzMQLvTDj1SE6a0ZZa/BWZkEe+eXQUJ5pw7bGwEM=; b=P6rpIEzaKWFWhpDLH9maBbN/pvQQUz/T2JDg/XjyySg1xjgulqNNtyv9CZs8DVF7/R bQsunxtbtGFv5jxjpt3ksf+1BLlMh3s3TOM2tz2JwxVW6pH3KL6lGpNZ0oekFY8jofir W96t2/9iJhRedCGGfVur/IY1W4ZaPjxXTW/jc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715971734; x=1716576534; 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=4UdLzMQLvTDj1SE6a0ZZa/BWZkEe+eXQUJ5pw7bGwEM=; b=XZeAbTTH7eRZciGTswAiPTbEoxPzgILiU7TAMRzBgdVPLKSxgBma0GsHmaR9y5tPKY EFfpOYOz9KT4zLNI2O1qSh2CUq02jb2CiNEHGSBKcTsQCEWEdTIhQmDBUaN95UeBUq6m jXRTsvA0S8gJEiJkV1iZnNrwUUxNpQuihcLwX419dOnrRcSVfdCK6k5vPF+uMzFOsJvF CVp47sDdkHs74vIc+WH7zwvIearpebUAqjWX5ezpsaFmH9U11GDUfGW7/WehylhMq/wp 0gHtIykZChiDYtpNZzu2NuDM7+XQxYUdjiowo+X6esM+MI7kEv5Ir7Hu2k3n7mJ1CUDo nUuw== X-Gm-Message-State: AOJu0YxCxmBhoPXR6eQX+yydzrsUFspjNwKZSRa8IGe07P464ZqszWfb DCQ8tQNq20QalmYqTW7kRzWmd4U/KttRDJGq11K5ZpEo+NQldk3tFSTYg2hDgtaG4XXehb3mmxB 6yBFkcX5ky/HraRq5DLfJ06twTvy/ctA+BHgMwjNaofVXXkyTN0zgix1WT8z10boBeq9fLt5XzU bsIyfEreVFzTwrTHWW+72dIsSE1kzNa59xDxgH55TgGNnDMigh4A== X-Google-Smtp-Source: AGHT+IF0hxRupiSUZyLaJ9CLcHMF4zlopxRg1Txpxb5FG4vBEX5mUNR2MtlLh1dWJTIhev0aQ9WCDQ== X-Received: by 2002:a05:6358:5694:b0:18d:f1bc:9f80 with SMTP id e5c5f4694b2df-193baed8126mr2275935255d.0.1715971733548; Fri, 17 May 2024 11:48:53 -0700 (PDT) Received: from localhost ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43e137a737asm76461211cf.4.2024.05.17.11.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 11:48:52 -0700 (PDT) From: Ian Forbes To: dri-devel@lists.freedesktop.org Cc: bcm-kernel-feedback-list@broadcom.com, zack.rusin@broadcom.com, martin.krastev@broadcom.com, maaz.mombasawala@broadcom.com, Ian Forbes Subject: [PATCH v2 4/4] drm/vmwgfx: Standardize use of kibibytes when logging Date: Fri, 17 May 2024 13:48:11 -0500 Message-Id: <20240517184811.25807-5-ian.forbes@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240517184811.25807-1-ian.forbes@broadcom.com> References: <20240517184811.25807-1-ian.forbes@broadcom.com> MIME-Version: 1.0 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 same standard abbreviation KiB instead of incorrect variants. Signed-off-by: Ian Forbes --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 12 ++++++------ drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 2e1fb46bcaa3..e03b2e682507 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -745,7 +745,7 @@ static int vmw_setup_pci_resources(struct vmw_private *dev, dev->vram_size = pci_resource_len(pdev, 2); drm_info(&dev->drm, - "Register MMIO at 0x%pa size is %llu kiB\n", + "Register MMIO at 0x%pa size is %llu KiB\n", &rmmio_start, (uint64_t)rmmio_size / 1024); dev->rmmio = devm_ioremap(dev->drm.dev, rmmio_start, @@ -764,7 +764,7 @@ static int vmw_setup_pci_resources(struct vmw_private *dev, fifo_size = pci_resource_len(pdev, 2); drm_info(&dev->drm, - "FIFO at %pa size is %llu kiB\n", + "FIFO at %pa size is %llu KiB\n", &fifo_start, (uint64_t)fifo_size / 1024); dev->fifo_mem = devm_memremap(dev->drm.dev, fifo_start, @@ -789,7 +789,7 @@ static int vmw_setup_pci_resources(struct vmw_private *dev, * SVGA_REG_VRAM_SIZE. */ drm_info(&dev->drm, - "VRAM at %pa size is %llu kiB\n", + "VRAM at %pa size is %llu KiB\n", &dev->vram_start, (uint64_t)dev->vram_size / 1024); return 0; @@ -983,13 +983,13 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id) dev_priv->max_primary_mem = dev_priv->vram_size; } drm_info(&dev_priv->drm, - "Legacy memory limits: VRAM = %llu kB, FIFO = %llu kB, surface = %u kB\n", + "Legacy memory limits: VRAM = %llu KiB, FIFO = %llu KiB, surface = %u KiB\n", (u64)dev_priv->vram_size / 1024, (u64)dev_priv->fifo_mem_size / 1024, dev_priv->memory_size / 1024); drm_info(&dev_priv->drm, - "MOB limits: max mob size = %u kB, max mob pages = %u\n", + "MOB limits: max mob size = %u KiB, max mob pages = %u\n", dev_priv->max_mob_size / 1024, dev_priv->max_mob_pages); ret = vmw_dma_masks(dev_priv); @@ -1007,7 +1007,7 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id) (unsigned)dev_priv->max_gmr_pages); } drm_info(&dev_priv->drm, - "Maximum display memory size is %llu kiB\n", + "Maximum display memory size is %llu KiB\n", (uint64_t)dev_priv->max_primary_mem / 1024); /* Need mmio memory to check for fifo pitchlock cap. */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index a0b47c9b33f5..5bd967fbcf55 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -94,14 +94,14 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man, } else new_max_pages = gman->max_gmr_pages * 2; if (new_max_pages > gman->max_gmr_pages && new_max_pages >= gman->used_gmr_pages) { - DRM_WARN("vmwgfx: increasing guest mob limits to %u kB.\n", + DRM_WARN("vmwgfx: increasing guest mob limits to %u KiB.\n", ((new_max_pages) << (PAGE_SHIFT - 10))); gman->max_gmr_pages = new_max_pages; } else { char buf[256]; snprintf(buf, sizeof(buf), - "vmwgfx, error: guest graphics is out of memory (mob limit at: %ukB).\n", + "vmwgfx, error: guest graphics is out of memory (mob limit at: %u KiB).\n", ((gman->max_gmr_pages) << (PAGE_SHIFT - 10))); vmw_host_printf(buf); DRM_WARN("%s", buf);