From nobody Fri Oct 31 11:35:15 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=1755764573; cv=none; d=zohomail.com; s=zohoarc; b=dGFh6ro0Hh7Uzf0YniH7yZD3cJk6cAI74zn6GQ/M8oo/IJPaqZ2kJwKpS5+SCSzeHsp3CEnL4TlNdLDNxjNwq0oKHzykgXkpDaAomLPAjwP66zp7601OILnlpEh7helPvZeeM8NEMTh1T1mSPUcQYdX6V5uJPD3kFBUqGRsfGyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755764573; 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=yVHBvUqEWY7SSOjBzn+0cxFCsYI6yntDEkv6RfYBGKE=; b=EyVSyV1Klss6ybmc1DNAF1PEcc1nrM13Pl6FUuweTUUPLGulTXcfO/68xHtU4YuhY2S8wLmXD7KmKtLEfgx96dBo2vpzjBgzy7uvISJb8eT95c7p8bey8kQHeUQtCbNpOtActrs4vLYSQf9fNFLtHy7NmTZ/mQzSN2jL4OsHeKU= 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 1755764573851542.6229746663242; Thu, 21 Aug 2025 01:22:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1087933.1445811 (Exim 4.92) (envelope-from ) id 1up0ZA-0004Sy-BP; Thu, 21 Aug 2025 08:22:36 +0000 Received: by outflank-mailman (output) from mailman id 1087933.1445811; Thu, 21 Aug 2025 08:22:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1up0ZA-0004Si-7W; Thu, 21 Aug 2025 08:22:36 +0000 Received: by outflank-mailman (input) for mailman id 1087933; Thu, 21 Aug 2025 08:22:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1up0Z8-0001aA-LW for xen-devel@lists.xenproject.org; Thu, 21 Aug 2025 08:22:34 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fcf09cd4-7e67-11f0-a32b-13f23c93f187; Thu, 21 Aug 2025 10:22:34 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id F24B81F841; Thu, 21 Aug 2025 08:22:17 +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 5903413867; Thu, 21 Aug 2025 08:22:17 +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 eFGGFDnXpmhzEwAAD6G6ig (envelope-from ); Thu, 21 Aug 2025 08:22:17 +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: fcf09cd4-7e67-11f0-a32b-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1755764538; 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=yVHBvUqEWY7SSOjBzn+0cxFCsYI6yntDEkv6RfYBGKE=; b=S8h5TBtSZmwNZ2ZKpFupzT93CI4X8r4hsSwkWNMlsXXrObX6yMTMs5rGGTNBlQLT8dCA65 /JNN5S2GSVutUw0ZnO4gvyHfJKug0R1TusqEa9Utx4O7MhsWTKK30+2dE21r3G3ix0LuQN MIflpjZsadvYh1/FsR2HMyCyaRYKXFQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1755764538; 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=yVHBvUqEWY7SSOjBzn+0cxFCsYI6yntDEkv6RfYBGKE=; b=V3z3Cs1j642URp70G9srpXLIrWlkml4RNjrLcGpEDb5/9h1N0Vs/7pF8C7mnLLeRivbZJ0 HcSzj4WxGxdKP2BQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1755764538; 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=yVHBvUqEWY7SSOjBzn+0cxFCsYI6yntDEkv6RfYBGKE=; b=S8h5TBtSZmwNZ2ZKpFupzT93CI4X8r4hsSwkWNMlsXXrObX6yMTMs5rGGTNBlQLT8dCA65 /JNN5S2GSVutUw0ZnO4gvyHfJKug0R1TusqEa9Utx4O7MhsWTKK30+2dE21r3G3ix0LuQN MIflpjZsadvYh1/FsR2HMyCyaRYKXFQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1755764538; 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=yVHBvUqEWY7SSOjBzn+0cxFCsYI6yntDEkv6RfYBGKE=; b=V3z3Cs1j642URp70G9srpXLIrWlkml4RNjrLcGpEDb5/9h1N0Vs/7pF8C7mnLLeRivbZJ0 HcSzj4WxGxdKP2BQ== 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 , Philipp Zabel , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Subject: [PATCH v6 10/25] drm/imx/ipuv3: Compute dumb-buffer sizes with drm_mode_size_dumb() Date: Thu, 21 Aug 2025 10:17:17 +0200 Message-ID: <20250821081918.79786-11-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-Spamd-Result: default: False [-1.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[pengutronix.de:email,suse.de:mid,suse.de:email]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWELVE(0.00)[26]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FREEMAIL_TO(0.00)[ffwll.ch,gmail.com,kernel.org,linux.intel.com,linux-m68k.org,ideasonboard.com]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_CC(0.00)[lists.freedesktop.org,lists.infradead.org,vger.kernel.org,lists.linux.dev,lists.xenproject.org,suse.de,pengutronix.de,kernel.org,gmail.com]; FROM_HAS_DN(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Level: X-Spam-Score: -1.30 X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1755764574872124100 Content-Type: text/plain; charset="utf-8" Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and buffer size. The hardware requires the framebuffer width to be a multiple of 8. The scanline pitch has to be large enough to support this. Therefore compute the byte size of 8 pixels in the given color mode and align the pitch accordingly. v5: - fix typo in commit description Signed-off-by: Thomas Zimmermann Reviewed-by: Philipp Zabel Cc: Philipp Zabel Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam --- drivers/gpu/drm/imx/ipuv3/imx-drm-core.c | 31 ++++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c b/drivers/gpu/drm/imx= /ipuv3/imx-drm-core.c index af4a30311e18..465b5a6ad5bb 100644 --- a/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c +++ b/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c @@ -17,7 +17,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -141,19 +143,32 @@ static int imx_drm_dumb_create(struct drm_file *file_= priv, struct drm_device *drm, struct drm_mode_create_dumb *args) { - u32 width =3D args->width; + u32 fourcc; + const struct drm_format_info *info; + u64 pitch_align; 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; - - ret =3D drm_gem_dma_dumb_create_internal(file_priv, drm, args); + /* + * Hardware requires the framebuffer width to be aligned to + * multiples of 8. The mode-setting code handles this, but + * the buffer pitch has to be aligned as well. Set the pitch + * alignment accordingly, so that the each scanline fits into + * the allocated buffer. + */ + fourcc =3D drm_driver_color_mode_format(drm, args->bpp); + if (fourcc =3D=3D DRM_FORMAT_INVALID) + return -EINVAL; + info =3D drm_format_info(fourcc); + if (!info) + return -EINVAL; + pitch_align =3D drm_format_info_min_pitch(info, 0, SZ_8); + if (!pitch_align || pitch_align > U32_MAX) + return -EINVAL; + ret =3D drm_mode_size_dumb(drm, args, pitch_align, 0); if (ret) return ret; =20 - args->width =3D width; - return ret; + return drm_gem_dma_dumb_create(file_priv, drm, args); } =20 static const struct drm_driver imx_drm_driver =3D { --=20 2.50.1