From patchwork Thu Mar 17 08:18:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12783670 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 4C724C433EF for ; Thu, 17 Mar 2022 08:18:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E594910EFFF; Thu, 17 Mar 2022 08:18:39 +0000 (UTC) Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D25310F003 for ; Thu, 17 Mar 2022 08:18:38 +0000 (UTC) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:f500:58f9:d953:424b]) by albert.telenet-ops.be with bizsmtp id 7LJa2700e0M4NNo06LJbff; Thu, 17 Mar 2022 09:18:36 +0100 Received: from rox.of.borg ([192.168.97.57] helo=rox) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nUlL8-004vCB-BF; Thu, 17 Mar 2022 09:18:34 +0100 Received: from geert by rox with local (Exim 4.93) (envelope-from ) id 1nUlL7-0055A6-CG; Thu, 17 Mar 2022 09:18:33 +0100 From: Geert Uytterhoeven To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Javier Martinez Canillas , =?utf-8?q?Noralf_Tr=C3=B8nne?= =?utf-8?q?s?= Subject: [PATCH v2 5/5] drm/repaper: Reduce temporary buffer size in repaper_fb_dirty() Date: Thu, 17 Mar 2022 09:18:30 +0100 Message-Id: <20220317081830.1211400-6-geert@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220317081830.1211400-1-geert@linux-m68k.org> References: <20220317081830.1211400-1-geert@linux-m68k.org> 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: , Cc: Andy Shevchenko , Geert Uytterhoeven , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As the temporary buffer is no longer used to store 8-bit grayscale data, its size can be reduced to the size needed to store the monochrome bitmap data. Fixes: 24c6bedefbe71de9 ("drm/repaper: Use format helper for xrgb8888 to monochrome conversion") Signed-off-by: Geert Uytterhoeven Reviewed-by: Javier Martinez Canillas --- v2: - Add Reviewed-by. Untested due to lack of hardware. I replaced kmalloc_array() by kmalloc() to match size calculations in other locations in this driver. There is no point in handling a possible multiplication overflow only here. --- drivers/gpu/drm/tiny/repaper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c index a096fb8b83e99dc8..7738b87f370ad147 100644 --- a/drivers/gpu/drm/tiny/repaper.c +++ b/drivers/gpu/drm/tiny/repaper.c @@ -530,7 +530,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb) DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id, epd->factored_stage_time); - buf = kmalloc_array(fb->width, fb->height, GFP_KERNEL); + buf = kmalloc(fb->width * fb->height / 8, GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto out_exit;