From patchwork Tue May 21 18:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Forbes X-Patchwork-Id: 13669650 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 A2136C25B74 for ; Tue, 21 May 2024 18:47:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 318B610E1CE; Tue, 21 May 2024 18:47:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="STZIQ2eW"; dkim-atps=neutral Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) by gabe.freedesktop.org (Postfix) with ESMTPS id 171CF10ED8C for ; Tue, 21 May 2024 18:47:34 +0000 (UTC) Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-3c99e6b8b1fso2863008b6e.1 for ; Tue, 21 May 2024 11:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1716317254; x=1716922054; 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=vp+K1TVMHDOLLoj51PiChvU7JPsn1elpoH4wGnkUKKc=; b=STZIQ2eWvBT1sGnwTwAK1UNkrNzrCUHHC+K3SIOGTmf5wvjpkZhYJWryuMV/4bvdYx ubgiUYj/+pjk1pGskLAkTVidTeS5aJUH5qGbXcxzdsmRT3AXUBtSCH01Ls1YVjXa6iI5 qZzTdwMElwQlPC/LFBVYyuY9Urs+lycNiGgMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716317254; x=1716922054; 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=vp+K1TVMHDOLLoj51PiChvU7JPsn1elpoH4wGnkUKKc=; b=sToRAfIG9sPrvQQzTZiC2LXz2eRhyriX1Z4xH1t4FAuz2DkkMPeFfJ8xG03Yd0AV1j 1O8zLeNBfPcWagRF144zAvn6cBYOx5nZHpBhKPGd/kScdYDxHwJA7dKozJ7jbz+pJYMt XvLRaUIkzbTp1+Di9MheTZEMEugJAFRTpns1qzy/hA7DvoCqRDTZITkjW12PvUw/pBFh 1ORrU27JQ7Tagcmgw+0yqFULXxBc/widcx7FafOnrBiLSZTyrdXJ2+BRUtMp/lVEgxi+ pDOyvc1FmhfFeWiIdMWR/9r5Nxqro8Xif3bp1CpKWIC9OoClknx6laniyaTvGbeI1Rx3 ESvw== X-Gm-Message-State: AOJu0YzexZBf0Q8aYbSz7HO3ezRqKeLXPQ+YCTqjYR6A2LsDFBsaRsMK lpZQTNV3C+gHeNNzuhXUmWrsOmWVgD6rNPp5rSzuZHrqL9bnS2356PUEZeMmYyVrszRbQSDyxM5 rCrIfQ8sBRTETumP25c3uBBBjXSju7RxlyLmyhZGjEJ3BMBUiooyZzNb5HtPIHuzDARUEkov69K bfbrr5lw55OQoM8UaGeP3nqY2HcmCjKPUp8obRXl+6vKI01YVcIA== X-Google-Smtp-Source: AGHT+IGDhuohGWRKzOaruZjnlvjqjwH6fvRuRSjjCzlFOeisd9UwufipBeQ1f7zoNe8lVFT7oFe6Zg== X-Received: by 2002:a05:6808:a89:b0:3c9:9268:9ee8 with SMTP id 5614622812f47-3c9970539e4mr38932791b6e.18.1716317253689; Tue, 21 May 2024 11:47:33 -0700 (PDT) Received: from localhost ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-792bf27584asm1315895785a.10.2024.05.21.11.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 11:47:33 -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 v3 1/4] drm/vmwgfx: Filter modes which exceed graphics memory Date: Tue, 21 May 2024 13:47:17 -0500 Message-Id: <20240521184720.767-2-ian.forbes@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240521184720.767-1-ian.forbes@broadcom.com> References: <20240521184720.767-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 | 45 ++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c index 2041c4d48daa..52e8ec3b2357 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c @@ -43,7 +43,14 @@ #define vmw_connector_to_stdu(x) \ container_of(x, struct vmw_screen_target_display_unit, base.connector) - +/* + * Some renderers such as llvmpipe will align the width and height of their + * buffers to match their 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. 64x64 pixels seems to be a reasonable upper bound for the + * tile size of current renderers. + */ +#define GPU_TILE_SIZE 64 enum stdu_content_type { SAME_AS_DISPLAY = 0, @@ -829,7 +836,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 GPU tile over-alignment */ + u64 required_mem = ALIGN(mode->hdisplay, GPU_TILE_SIZE) * + ALIGN(mode->vdisplay, GPU_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 +886,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 Tue May 21 18:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Forbes X-Patchwork-Id: 13669653 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 13AD0C25B78 for ; Tue, 21 May 2024 18:47:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AEC410EC9E; Tue, 21 May 2024 18:47:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="h2wwN/Zh"; dkim-atps=neutral Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CEB410ED8C for ; Tue, 21 May 2024 18:47:37 +0000 (UTC) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-69b5ece41dfso9071436d6.2 for ; Tue, 21 May 2024 11:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1716317256; x=1716922056; 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=h2wwN/Zh9y4uxkUN40Xld0ClrNewK8LpIZYO7GqwYgwnJd0ZZsZwQsWdICGv7vfv4L tOn7svT59hEo8aHxliDaYgqwLNOosVb+zQnw5Uwdf8E/ZXAetxyp4OSwbyw+UOZHI4pa Y9OMzPyfCAwt83h6kVYWpW2wC8BhFb3xt3cgA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716317256; x=1716922056; 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=O79j4xZeSOfvo5EFA3SvVgAphb7kzXKvtlv+yRuCOaTFtAjLSsrKD2qjvfZjpjqmMs nZe9Y5ylowfh7MS1OCEEe7DpaNmPUOzj1NENk+Q+s27BclHO8yHicNlnYjt/kVL+4NPJ 8UhF2ONxEeeBbwDY085zpBgIJA83zrvT6BzfWpxI549sxyMvb49gCRmWe08LTrv5bUVx wiYVb6STIXyNNV0Ur+KGWR1QyZVUaIz92Vz+0HAm/uPSTnezywDishNu40ZFIM6wNJzo O8WRkHB0YdUkkC/cNjeOz2zqL86ri2oqzCEH3PQsRYnKlU30NDvF1hykJBcffPurv15y BCBQ== X-Gm-Message-State: AOJu0Yz7y/TZuaHxClkrzn8SsTtxZGeuqfVAcBQGTWA+1CvyaEDauJTU 1bHH7ZcWHUFGgPt7I5kwX+oEZgGHGfsb0DDE8Ch+sqnnTpKOYAnZ5/wiylwS1zBNQZ8HbIpswCB TckLEKyin6mYlrFQRstUosG5O+T8Uk2DeJGBN+YmsG0WxZcS9At25DR/08TUyPpXLAPrT0fCxWb AisrCQT9yf7DTlvZZjwLGh1WYxdeeiDwOJSiLsVxoygg/YmP/LAA== X-Google-Smtp-Source: AGHT+IFuky5g7mfkI4pRULjttzP0jIi3tKodlPX3Dqek46QUKtQk3KgNePhQhPlRh4FkviZzaGrSmg== X-Received: by 2002:a05:6214:4b08:b0:6a9:8511:207c with SMTP id 6a1803df08f44-6a985112240mr90196126d6.6.1716317256288; Tue, 21 May 2024 11:47:36 -0700 (PDT) Received: from localhost ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6a8c2d39d7esm34170856d6.95.2024.05.21.11.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 11:47: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 v3 2/4] drm/vmwgfx: 3D disabled should not effect STDU memory limits Date: Tue, 21 May 2024 13:47:18 -0500 Message-Id: <20240521184720.767-3-ian.forbes@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240521184720.767-1-ian.forbes@broadcom.com> References: <20240521184720.767-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 Tue May 21 18:47:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Forbes X-Patchwork-Id: 13669651 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 1ED20C25B74 for ; Tue, 21 May 2024 18:47:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4EE9710E26D; Tue, 21 May 2024 18:47:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="GuY+JQ/k"; dkim-atps=neutral Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) by gabe.freedesktop.org (Postfix) with ESMTPS id A4A6710E1CE for ; Tue, 21 May 2024 18:47:39 +0000 (UTC) Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3c999556297so2807217b6e.2 for ; Tue, 21 May 2024 11:47:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1716317258; x=1716922058; 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=GuY+JQ/kzR0zMIDYcTz0HMxPZfHz4X6O1p7AcFgZGXVO1nLM3FIobgyJKtgG9W2i5F c8HAcqkhTYvF+opChzdVCUsXCUhvpqDZKtAg9AJ3h9USxrWadYPs1YHOhLspEZKfzZIX uBiMn9D0HItllYIHdmX5I54D/S5lCpVYCmyJU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716317258; x=1716922058; 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=rv9g8Z7TURnIQz3L8gxTXIWQxShRo7q8oyKB7uAudbIy9ctvcGhN9nMgOIljOez8Je J4JTcOlLui2OXj4QgGvPYdcYMpv7lxxykMcNBadBtR22Kyww6h57I7DIDwl5Y+rL+aAm vB4D1FQGYrLAvxWL7KRS8eCZWHmBFS/XFTWEN64wIuI3EF1F95+5aOy6YD335dQ5WksD uEsDjPTFwXvyVE/0zKpSZefq8NGvxXe5rb2kMl1Du7WP+aIqLDUZZ4gnhYOW+GKulwF1 lTZgGix4YpqRYnfL59JYewm9R82+sUL9sOmy23g/i0tko1vLrmjD3aBb66TclOXtAqNB QI5A== X-Gm-Message-State: AOJu0Ywkr8aqo+ApSs1ts6VWXAOi5o+CJatOcVEgTHk+eoWgv09KQe6k TsDMxepgEaHhib0WQxjb62nk59/UUcO5VC1IMbkKRcrVvFV+6HKnmZ8BhF2mAIdB+DTTbkCPfru rUybohYyFSnE5QZiheXppiw1CcQ3RXwoKwOsZ5eYneuQd9NYVJClyC657/Ukbz+Jndsb5QRtQu2 mKEoXEkbk6EEfd8l+sW75UJ56rE+JiEPauK8TVe0PtiLFKGVf/gA== X-Google-Smtp-Source: AGHT+IHfQB47vBC3i6Vt0EgnoMsnZ/YnqXB5H7PncfYE8OF2eTp8hOqVw8V1T3KrvX+f5KLAQnmSgA== X-Received: by 2002:a05:6808:4283:b0:3c6:943:e0ad with SMTP id 5614622812f47-3c9970d1ad3mr34116018b6e.51.1716317258472; Tue, 21 May 2024 11:47:38 -0700 (PDT) Received: from localhost ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-792cd466c87sm1159917385a.7.2024.05.21.11.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 11:47:38 -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 v3 3/4] drm/vmwgfx: Remove STDU logic from generic mode_valid function Date: Tue, 21 May 2024 13:47:19 -0500 Message-Id: <20240521184720.767-4-ian.forbes@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240521184720.767-1-ian.forbes@broadcom.com> References: <20240521184720.767-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 Tue May 21 18:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Forbes X-Patchwork-Id: 13669652 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 13476C25B7C for ; Tue, 21 May 2024 18:47:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E597A10E319; Tue, 21 May 2024 18:47:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="M1oGXp5z"; dkim-atps=neutral Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73C1E10E319 for ; Tue, 21 May 2024 18:47:42 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-792c7704e09so12368985a.1 for ; Tue, 21 May 2024 11:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1716317261; x=1716922061; 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=M1oGXp5zBRAYZBrWHN5yxyTsAxeSd192t7XVNlQDT12n3iJoNc0fxfGuVydOnY8xBQ lOPKi0tQhh1DBplMF/NSq2YRHXb5ciO10OeiBNtPN5Jr52BOZmPzS1cQ+OeAq0fEpiEb iOOyrf5bFjCuz2cbQNmYXlXQsRZ3Z4ENJPTRg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716317261; x=1716922061; 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=RkjaF/6cuTkYSrzEJ9nVDimlWezqvhuFQd7JhOSpiamFah9OqG6IskrICkq9JJCD+A 22f7RipMw1TeUR4+IILiU2A9oj3XL/FzU4RM98mjh0BCtE1aoMTpav1f3SlmXv9dGn49 a7kVSCurB6/f6hiHAX3jOO+hsS+YH/O0cCa5EYZvQQhTofbhtQHSRi/r1O0mlELqNp49 8qh9dH96G8HWHVLfMw9tq4zBSFWClEpIYFjmshU/cENQSyfQ8BoZQ/GaDjNzEkos73NW u3GZGriH4fxbRrhAzOQ87+uK2MfYqBcR49EMrv6T4KPc3o0lrWBjJxoFZHpJ478K8HOL Jy5Q== X-Gm-Message-State: AOJu0YwKpQyc2TudWg77KrytzGBqZtdpv/yAH0AmpyVBkIA4DNAXNYHf tKW8guIG2s7aTT5V5oLdHp1MoH7DsyyUq3zIy8ZPvAmd0nckSaDjDrVgbiqoGjZio+zTGpwpl7j DfENI4XZCdV3KjDA2C7Njy/dLTfz8yD4ZIsaY5H+VY8TW46jUeRsLJwWZFHb4vEodu8iDMVGHuP WUgs1rt3A7fAgkLKypgLZ+qSXHH9cpoRYoJBJ7nqgCTP1VCD7lBw== X-Google-Smtp-Source: AGHT+IH5pAypb8BLmrt7WE6vxW0ZAnKNV09HSY8yChrDgS9flv3kPQUyRxp/TqvfIgcgLi3m915LGg== X-Received: by 2002:a05:620a:2453:b0:793:c53:8ee5 with SMTP id af79cd13be357-79470f0c097mr1722830385a.26.1716317261217; Tue, 21 May 2024 11:47:41 -0700 (PDT) Received: from localhost ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-792bf2ffe59sm1310522185a.83.2024.05.21.11.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 11:47:40 -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 v3 4/4] drm/vmwgfx: Standardize use of kibibytes when logging Date: Tue, 21 May 2024 13:47:20 -0500 Message-Id: <20240521184720.767-5-ian.forbes@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240521184720.767-1-ian.forbes@broadcom.com> References: <20240521184720.767-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);