From patchwork Thu Jan 9 14:57:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13932746 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 A14D5E7719A for ; Thu, 9 Jan 2025 15:04:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CA5510EE93; Thu, 9 Jan 2025 15:03:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="S/HM/ivV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="E8uXSNXO"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="S/HM/ivV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="E8uXSNXO"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id E392210EE92; Thu, 9 Jan 2025 15:03:56 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0A54421177; Thu, 9 Jan 2025 15:03:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1736435004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dH0e4KfjnMGaRabx2kD9CiC04UroRsnN8GiYA0fiJw0=; b=S/HM/ivVw4nSHXWwwFc1+f6nfph4uCLa/EOzjJ8AX0VzALmJbWeOQtQrlwJ8vIdGc8ef5R WwBlMZ/rHwayvqcOZdMinRYW3FLhQ+YZHt4gv2GYt7m4MBbDMEwnAtXrTLbC/rYII4ZSx3 wPlmxet1HRRKthur3CeedIT3ZauxtPw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1736435004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dH0e4KfjnMGaRabx2kD9CiC04UroRsnN8GiYA0fiJw0=; b=E8uXSNXOlj3RxxjIPDmDQ3W8U8BNwXarhB68Z4U5QqKgEz5+Fyoy+Dj6Bp6XKGF3iqdqy7 dY/fo33C4Oe96zCg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="S/HM/ivV"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=E8uXSNXO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1736435004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dH0e4KfjnMGaRabx2kD9CiC04UroRsnN8GiYA0fiJw0=; b=S/HM/ivVw4nSHXWwwFc1+f6nfph4uCLa/EOzjJ8AX0VzALmJbWeOQtQrlwJ8vIdGc8ef5R WwBlMZ/rHwayvqcOZdMinRYW3FLhQ+YZHt4gv2GYt7m4MBbDMEwnAtXrTLbC/rYII4ZSx3 wPlmxet1HRRKthur3CeedIT3ZauxtPw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1736435004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dH0e4KfjnMGaRabx2kD9CiC04UroRsnN8GiYA0fiJw0=; b=E8uXSNXOlj3RxxjIPDmDQ3W8U8BNwXarhB68Z4U5QqKgEz5+Fyoy+Dj6Bp6XKGF3iqdqy7 dY/fo33C4Oe96zCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7C79D139AB; Thu, 9 Jan 2025 15:03:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0DMbHTvlf2c1awAAD6G6ig (envelope-from ); Thu, 09 Jan 2025 15:03:23 +0000 From: Thomas Zimmermann To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, linux-samsung-soc@vger.kernel.org, nouveau@lists.freedesktop.org, virtualization@lists.linux.dev, spice-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-tegra@vger.kernel.org, intel-xe@lists.freedesktop.org, xen-devel@lists.xenproject.org, Thomas Zimmermann , Dave Airlie , Gerd Hoffmann Subject: [PATCH v2 16/25] drm/qxl: Compute dumb-buffer sizes with drm_mode_size_dumb() Date: Thu, 9 Jan 2025 15:57:10 +0100 Message-ID: <20250109150310.219442-17-tzimmermann@suse.de> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150310.219442-1-tzimmermann@suse.de> References: <20250109150310.219442-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0A54421177 X-Rspamd-Action: no action X-Spamd-Result: default: False [-1.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,suse.de:mid,suse.de:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_TO(0.00)[linux.intel.com,kernel.org,gmail.com,ffwll.ch]; RCPT_COUNT_TWELVE(0.00)[21]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; R_RATELIMIT(0.00)[to(RLbwen1niosrcqbxsafh1),to_ip_from(RLqtkr6cif1ebgurukgmwdm7xc)]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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" Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and buffer size. No alignment required. Signed-off-by: Thomas Zimmermann Cc: Dave Airlie Cc: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_dumb.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c index 17df5c7ccf69..1200946767ce 100644 --- a/drivers/gpu/drm/qxl/qxl_dumb.c +++ b/drivers/gpu/drm/qxl/qxl_dumb.c @@ -23,6 +23,8 @@ * Alon Levy */ +#include + #include "qxl_drv.h" #include "qxl_object.h" @@ -35,14 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv, struct qxl_device *qdev = to_qxl(dev); struct qxl_bo *qobj; struct drm_gem_object *gobj; - uint32_t handle; int r; struct qxl_surface surf; - uint32_t pitch, format; + u32 format; - pitch = args->width * ((args->bpp + 1) / 8); - args->size = pitch * args->height; - args->size = ALIGN(args->size, PAGE_SIZE); + r = drm_mode_size_dumb(dev, args, 0, 0); + if (r) + return r; switch (args->bpp) { case 16: @@ -57,20 +58,18 @@ int qxl_mode_dumb_create(struct drm_file *file_priv, surf.width = args->width; surf.height = args->height; - surf.stride = pitch; + surf.stride = args->pitch; surf.format = format; surf.data = 0; r = qxl_gem_object_create_with_handle(qdev, file_priv, QXL_GEM_DOMAIN_CPU, args->size, &surf, &gobj, - &handle); + &args->handle); if (r) return r; qobj = gem_to_qxl_bo(gobj); qobj->is_dumb = true; drm_gem_object_put(gobj); - args->pitch = pitch; - args->handle = handle; return 0; }