From nobody Fri Oct 31 11:35:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1755764562; cv=none; d=zohomail.com; s=zohoarc; b=byvj03L4NsiPAPPFijAG2V2bm6h5Wr8LuNsoQNqWKxyrNXL3oTKrtPufS8yGHe/u00NRoEPIm1IEsn6shOjNMbtAQBFJK5oijsi1Bp1JbJn4M5u0fphRQeJ4AxK4gQcIXQ/sTBg729Xe6/M4/dtA7NDpkVB8b3RpPzKEJnS93vs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755764562; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4sNe9k0oQJ0ZQgQNEWxG9c9hC2Rshx1X7aHC0D51qPg=; b=llhko4tPDYiQAtLJsTYA+XEZFvh3JtZf1hZVcZfpFAUTTTYaeDqdyUINMp15SoeIQ48ud2lDzph6cdzcPSA+TNuQ/2Ibfvq25LbbKWGIiNtnhFG0+7EpGqIURWG5bRhuKoExOgLQ0KJMlETojn1Jx4J8bE3QG8vAcr1t/iGc29M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175576456212042.130468944959034; Thu, 21 Aug 2025 01:22:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1087921.1445741 (Exim 4.92) (envelope-from ) id 1up0Yv-0002Gc-20; Thu, 21 Aug 2025 08:22:21 +0000 Received: by outflank-mailman (output) from mailman id 1087921.1445741; Thu, 21 Aug 2025 08:22:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1up0Yu-0002GS-VN; Thu, 21 Aug 2025 08:22:20 +0000 Received: by outflank-mailman (input) for mailman id 1087921; Thu, 21 Aug 2025 08:22:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1up0Yt-0001aB-G7 for xen-devel@lists.xenproject.org; Thu, 21 Aug 2025 08:22:19 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f2ecfea9-7e67-11f0-b898-0df219b8e170; Thu, 21 Aug 2025 10:22:17 +0200 (CEST) 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 BFBCC22640; Thu, 21 Aug 2025 08:22:13 +0000 (UTC) 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 437BD139A8; Thu, 21 Aug 2025 08:22:13 +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 iKBKDzXXpmhzEwAAD6G6ig (envelope-from ); Thu, 21 Aug 2025 08:22:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f2ecfea9-7e67-11f0-b898-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1755764533; 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=4sNe9k0oQJ0ZQgQNEWxG9c9hC2Rshx1X7aHC0D51qPg=; b=DEYJMSZ4Ns4VRIaIjQk1litPiCJl7TdquNq4DIz839m9oFE26jquwIHsekcFbb8CQfrSb7 99Noz6ED0CVXZ65giB4fXvXQnSUE/Zw9ijttmoyPnC2b4ZtJ5xUmTMgCdn8EKunT5YRJ92 pAplwHdLf8PGB/rTLsrJ0WI509g58WY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1755764533; 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=4sNe9k0oQJ0ZQgQNEWxG9c9hC2Rshx1X7aHC0D51qPg=; b=PIOkhJvOzodhFLUDub46rJi8+F64yjJu6cTCF/ZfnFV0eiIKpFA1Q6DfhKy4LevhFwb0in Xj3K0nWqtPyn5aAw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DEYJMSZ4; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=PIOkhJvO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1755764533; 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=4sNe9k0oQJ0ZQgQNEWxG9c9hC2Rshx1X7aHC0D51qPg=; b=DEYJMSZ4Ns4VRIaIjQk1litPiCJl7TdquNq4DIz839m9oFE26jquwIHsekcFbb8CQfrSb7 99Noz6ED0CVXZ65giB4fXvXQnSUE/Zw9ijttmoyPnC2b4ZtJ5xUmTMgCdn8EKunT5YRJ92 pAplwHdLf8PGB/rTLsrJ0WI509g58WY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1755764533; 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=4sNe9k0oQJ0ZQgQNEWxG9c9hC2Rshx1X7aHC0D51qPg=; b=PIOkhJvOzodhFLUDub46rJi8+F64yjJu6cTCF/ZfnFV0eiIKpFA1Q6DfhKy4LevhFwb0in Xj3K0nWqtPyn5aAw== From: Thomas Zimmermann To: simona@ffwll.ch, airlied@gmail.com, mripard@kernel.org, maarten.lankhorst@linux.intel.com, geert@linux-m68k.org, tomi.valkeinen@ideasonboard.com 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 Subject: [PATCH v6 03/25] drm/gem-dma: Compute dumb-buffer sizes with drm_mode_size_dumb() Date: Thu, 21 Aug 2025 10:17:10 +0200 Message-ID: <20250821081918.79786-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250821081918.79786-1-tzimmermann@suse.de> References: <20250821081918.79786-1-tzimmermann@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: BFBCC22640 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_TO(0.00)[ffwll.ch,gmail.com,kernel.org,linux.intel.com,linux-m68k.org,ideasonboard.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_TWELVE(0.00)[21]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCVD_COUNT_TWO(0.00)[2]; R_RATELIMIT(0.00)[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-Spam-Score: -1.51 X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1755764564749124100 Content-Type: text/plain; charset="utf-8" Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and buffer size. Align the pitch to a multiple of 8. Push the current calculation into the only direct caller imx. Imx's hardware requires the framebuffer width to be aligned to 8. The driver's current approach is actually incorrect, as it only guarantees this implicitly and requires bpp to be a multiple of 8 already. A later commit will fix this problem by aligning the scanline pitch such that an aligned width still fits into each scanline's memory. A number of other drivers are build on top of gem-dma helpers and implement their own dumb-buffer allocation. These drivers invoke drm_gem_dma_dumb_create_internal(), which is not affected by this commit. v5: - avoid reset of arguments (Tomi) Signed-off-by: Thomas Zimmermann Reviewed-by: Tomi Valkeinen --- drivers/gpu/drm/drm_gem_dma_helper.c | 7 +++++-- drivers/gpu/drm/imx/ipuv3/imx-drm-core.c | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem= _dma_helper.c index 4f0320df858f..ab1a70b1d6f1 100644 --- a/drivers/gpu/drm/drm_gem_dma_helper.c +++ b/drivers/gpu/drm/drm_gem_dma_helper.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include =20 @@ -304,9 +305,11 @@ int drm_gem_dma_dumb_create(struct drm_file *file_priv, struct drm_mode_create_dumb *args) { struct drm_gem_dma_object *dma_obj; + int ret; =20 - args->pitch =3D DIV_ROUND_UP(args->width * args->bpp, 8); - args->size =3D args->pitch * args->height; + ret =3D drm_mode_size_dumb(drm, args, SZ_8, 0); + if (ret) + return ret; =20 dma_obj =3D drm_gem_dma_create_with_handle(file_priv, drm, args->size, &args->handle); diff --git a/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c b/drivers/gpu/drm/imx= /ipuv3/imx-drm-core.c index ec5fd9a01f1e..af4a30311e18 100644 --- a/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c +++ b/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c @@ -145,8 +145,10 @@ static int imx_drm_dumb_create(struct drm_file *file_p= riv, int ret; =20 args->width =3D ALIGN(width, 8); + args->pitch =3D DIV_ROUND_UP(args->width * args->bpp, 8); + args->size =3D args->pitch * args->height; =20 - ret =3D drm_gem_dma_dumb_create(file_priv, drm, args); + ret =3D drm_gem_dma_dumb_create_internal(file_priv, drm, args); if (ret) return ret; =20 --=20 2.50.1