From patchwork Thu Jan 9 14:57:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13932778 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 66766E7719E for ; Thu, 9 Jan 2025 15:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PaRx0oRwlXoqaXC+RhDl+6RSSe3jo6OF8QWOdv68gj0=; b=qEemZolNCTcwI1 WAyodaM69ajRoE6Mv6tjXS5FTBHTLaR2XD5uCGYB3WgCjs1xOnuhYqxuAUbVk13XXQoTdq44lXp/h jGb3Pq2Itzx725UkTR56OthyrvMAU+83DebpxsE1H274cTEjbpUGLnzksldmINIGlxM+BuaoKs4UO egm/juNdx9ypraEx7Z3n+2HE7VjRJlK3ZDwlWqI8il9CUdUyLJTz/m7o6JR0SVh2LoMvnK9j2aisO 4nNJtFOJSIj2tCMyXqvqIuz5mQ+GIswT88Yy1NQ+Gsv0Sa4bN8Uc336Wx6ouy+2bhOaavK/2a1CD+ P8Q/L2LStQWNF+LfO2Uw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVu4s-0000000CNaM-1dm1; Thu, 09 Jan 2025 15:04:06 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVu4U-0000000CMpJ-1sFP; Thu, 09 Jan 2025 15:03:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=NqQRjOkhm9SJSbhxaHLS/kALWSX7OjgIi0zWzKpICPM=; b=dG7pv/bwbVyEftuAKx59R+j8tX YFZadqjikxxwsOFhPR6AsMj01ni2uIF2gbRH4svqLB+iEachPPya6bjOIAsJRcoEZZIqP/ZmkkoqY ibNVRTdarYmdNi/5ey0jG7ikPjkyy0bSiOhRyUcriBhphOmkl+MMDU6URGpvo3TKU/EMTn0hMJ6cF 1PYx4sdSMHa/+sPbAHza273zCsHT4M7xWxhvNmJNwlTJ4S0LiQaHhpBLHpk27vd8YvbQoH9v0dDLV I3aAwnwn12omhkRy941Z5YKCFUKzl+Vvww8vg+BP5LixckesEqfcgGoEWHP3rmfLlGViNiuaQwqKc ZvPPeFPA==; Received: from smtp-out1.suse.de ([195.135.223.130]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVu4A-00000009a6T-0p1i; Thu, 09 Jan 2025 15:03:36 +0000 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 E721F21171; Thu, 9 Jan 2025 15:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1736435000; 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=NqQRjOkhm9SJSbhxaHLS/kALWSX7OjgIi0zWzKpICPM=; b=QEdI2JVuAtwjaRpn1a9OFWgjqj3vZJaOLtdoeqSUYNcWQ0K6AyVe+NKAdTRqaF6xN4rwoS S+VajvQzfi8eTK2zzPVPpGspbAVlr8roJzhPrF9leDWOcqqtMReUqvg3WtmTH5NpkluLiB LTNkrCxWe2dNbcRRiiAqUZYOnoZ5SzM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1736435000; 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=NqQRjOkhm9SJSbhxaHLS/kALWSX7OjgIi0zWzKpICPM=; b=rrsFXEqv5/RIaAjhK/LJO8o69DayAQL2H8fXVM7CAdBqkRlT8d89QpRS0vSV3VCS608hTO /Bzn4WflsHwfjsCQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jZZapTnC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=lk77pFGn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1736434999; 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=NqQRjOkhm9SJSbhxaHLS/kALWSX7OjgIi0zWzKpICPM=; b=jZZapTnCAdx/tMhB9e9FyPhemBcaQ4RAHrohqqdY389CpOLMQTTOCdQX5lB3Imxmwh+NsX PZ/WqOMlY1IeD/th3PyUpFmUOY8iRO4YQ5Zm7ftZPMo2cbIWjI9dCYxVq4aie9WhZXfbDS VWB3SvqFdopGa/7hrVfP33ejnWntyWs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1736434999; 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=NqQRjOkhm9SJSbhxaHLS/kALWSX7OjgIi0zWzKpICPM=; b=lk77pFGnfUgqy1c2btVrQZ4ATtWNUyGXXQlWLRvPjL5pkBLWiohlrYrIJokVOs0r+/es+Y Oxmj8v4C7fw0aWCA== 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 50C0913A8B; Thu, 9 Jan 2025 15:03:19 +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 MFNqEjflf2c1awAAD6G6ig (envelope-from ); Thu, 09 Jan 2025 15:03:19 +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 , Xinliang Liu , Tian Tao , Xinwei Kong , Sumit Semwal , Yongqin Liu , John Stultz Subject: [PATCH v2 09/25] drm/hibmc: Compute dumb-buffer sizes with drm_mode_size_dumb() Date: Thu, 9 Jan 2025 15:57:03 +0100 Message-ID: <20250109150310.219442-10-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: E721F21171 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)[suse.de:dkim,suse.de:mid,suse.de:email,linaro.org:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; 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)[25]; 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_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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250109_150322_811837_3A064117 X-CRM114-Status: GOOD ( 17.60 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and buffer size. Align the pitch to a multiple of 128. The hibmc driver's new hibmc_dumb_create() is similar to the one in GEM VRAM helpers. The driver was the only caller of drm_gem_vram_fill_create_dumb(). Remove the now unused helper. Signed-off-by: Thomas Zimmermann Cc: Xinliang Liu Cc: Tian Tao Cc: Xinwei Kong Cc: Sumit Semwal Cc: Yongqin Liu Cc: John Stultz --- drivers/gpu/drm/drm_gem_vram_helper.c | 65 ------------------- .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 25 ++++++- include/drm/drm_gem_vram_helper.h | 6 -- 3 files changed, 24 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 15cd564cbeac..b4cf8134df6d 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -444,71 +444,6 @@ void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, } EXPORT_SYMBOL(drm_gem_vram_vunmap); -/** - * drm_gem_vram_fill_create_dumb() - Helper for implementing - * &struct drm_driver.dumb_create - * - * @file: the DRM file - * @dev: the DRM device - * @pg_align: the buffer's alignment in multiples of the page size - * @pitch_align: the scanline's alignment in powers of 2 - * @args: the arguments as provided to - * &struct drm_driver.dumb_create - * - * This helper function fills &struct drm_mode_create_dumb, which is used - * by &struct drm_driver.dumb_create. Implementations of this interface - * should forwards their arguments to this helper, plus the driver-specific - * parameters. - * - * Returns: - * 0 on success, or - * a negative error code otherwise. - */ -int drm_gem_vram_fill_create_dumb(struct drm_file *file, - struct drm_device *dev, - unsigned long pg_align, - unsigned long pitch_align, - struct drm_mode_create_dumb *args) -{ - size_t pitch, size; - struct drm_gem_vram_object *gbo; - int ret; - u32 handle; - - pitch = args->width * DIV_ROUND_UP(args->bpp, 8); - if (pitch_align) { - if (WARN_ON_ONCE(!is_power_of_2(pitch_align))) - return -EINVAL; - pitch = ALIGN(pitch, pitch_align); - } - size = pitch * args->height; - - size = roundup(size, PAGE_SIZE); - if (!size) - return -EINVAL; - - gbo = drm_gem_vram_create(dev, size, pg_align); - if (IS_ERR(gbo)) - return PTR_ERR(gbo); - - ret = drm_gem_handle_create(file, &gbo->bo.base, &handle); - if (ret) - goto err_drm_gem_object_put; - - drm_gem_object_put(&gbo->bo.base); - - args->pitch = pitch; - args->size = size; - args->handle = handle; - - return 0; - -err_drm_gem_object_put: - drm_gem_object_put(&gbo->bo.base); - return ret; -} -EXPORT_SYMBOL(drm_gem_vram_fill_create_dumb); - /* * Helpers for struct ttm_device_funcs */ diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c index e6de6d5edf6b..81768577871f 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c @@ -18,10 +18,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -54,7 +56,28 @@ static irqreturn_t hibmc_interrupt(int irq, void *arg) static int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) { - return drm_gem_vram_fill_create_dumb(file, dev, 0, 128, args); + struct drm_gem_vram_object *gbo; + int ret; + + ret = drm_mode_size_dumb(dev, args, SZ_128, 0); + if (ret) + return ret; + + gbo = drm_gem_vram_create(dev, args->size, 0); + if (IS_ERR(gbo)) + return PTR_ERR(gbo); + + ret = drm_gem_handle_create(file, &gbo->bo.base, &args->handle); + if (ret) + goto err_drm_gem_object_put; + + drm_gem_object_put(&gbo->bo.base); + + return 0; + +err_drm_gem_object_put: + drm_gem_object_put(&gbo->bo.base); + return ret; } static const struct drm_driver hibmc_driver = { diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h index 00830b49a3ff..b6e821f5dd03 100644 --- a/include/drm/drm_gem_vram_helper.h +++ b/include/drm/drm_gem_vram_helper.h @@ -100,12 +100,6 @@ int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct iosys_map *map); void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, struct iosys_map *map); -int drm_gem_vram_fill_create_dumb(struct drm_file *file, - struct drm_device *dev, - unsigned long pg_align, - unsigned long pitch_align, - struct drm_mode_create_dumb *args); - /* * Helpers for struct drm_driver */