Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4380190pxv; Tue, 20 Jul 2021 02:22:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTUOu7o9vpyTxghZ7FVbm7HA3e9JgkgoJ/Bvz+bTFKCQNUJsAugLQHXIHJ5HwtnRLbeZeB X-Received: by 2002:a05:6402:5215:: with SMTP id s21mr40494376edd.356.1626772955454; Tue, 20 Jul 2021 02:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626772955; cv=none; d=google.com; s=arc-20160816; b=0i5lNqrPJV/bH/94wn5HJfgbxXZRfCazAzc8r2XTiQ0tI9oOsUAQW97XPUY7npuFPj GGh3vKL2nKfZvnjDVTZSZGJhA/rsahhUobTYWOzjEEJeN4namhPD3gql92kh3IJRcw0C Ogimmn0SOKb5a7OKrhTkiWE80Z3ak7BKoOjxGmbZ54f1HkjYIfnkV+nDhuianp5ByEyH oCqZoN3wwipU2VDL24fELuzsPpxI7dmPNPS5J5z+QtE5BNu8UFlb0Hij2tv4LuoTGxYn PrYGMMzYAnQE2bXz0kDY4GWWgXxeuMCZUm0/Ak+sC6y/8k61LVCR5xTE2xA6TsrsjY9k gdnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=pGK4Y9q1wNdkFd2qkEzt4SoJHeKZj51kb/6+Vc2cCrE=; b=Nha3jFYvnYHVXUquHkdSxiI7m5kss+ZbYwJ1/dP/cPiTc4xYCgFtF2Qu/GuuqyjUre zgELpHJL2Fa9xVLLH5B/NyIbN5ogNEbKI8JD+fxJFnqDx9oP+LxBCyPWCMZv6hlcHH8t l0FDmUZ0T6K+qah+hDg6PUViMfGI/0ZAPUH28IWJdvxSG2ztGh8wFM7LaLULFgzhIC0Z nSXt2tVeGjYJLBYEWCPNncZsaHMwC426AOU+os10xGFQ/YeRdNH1FctT6VOB6+Oy5mtB 81DzN5PAiAuXOuo7Cv7CbprPImPyPp0eZF7by0c9oakeHl8mzW6uw7Od/M5zr8LZ1pen Y1yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si24934712edv.339.2021.07.20.02.22.11; Tue, 20 Jul 2021 02:22:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235455AbhGTIh4 (ORCPT + 99 others); Tue, 20 Jul 2021 04:37:56 -0400 Received: from mail-vs1-f48.google.com ([209.85.217.48]:42820 "EHLO mail-vs1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbhGTIgB (ORCPT ); Tue, 20 Jul 2021 04:36:01 -0400 Received: by mail-vs1-f48.google.com with SMTP id u7so10867964vst.9; Tue, 20 Jul 2021 02:16:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pGK4Y9q1wNdkFd2qkEzt4SoJHeKZj51kb/6+Vc2cCrE=; b=HkD5FyjvnacsybfiyGgnoE3eHRIvRdfujN3HyK8qaCoRsGE3fv86T3BD3eGDe5EIPB aruLvK9JsDCSPxttsJj2L2PN8TQpIPIet8e3mJIjEPuFAX/B3HrTwa3sZ4oMgOmlRuNC mOAXdue1fcLLNF6haY5NvDMUw/GqFTFMlFP3r7NrtV0E/4oNY5Lv72+chzr2UiU4fKZm e/uLXITaAj4jSoQ03oCh+/lqWnhnJZ0tqu5oKelJivOMl1cyDG1G5sykd6vMfixR+LIK jAZjdUEpKfJCYIWk8TPPbmeB+apQ/ZwxdgmgZRcKWsfGZyO7aVFiz8T4lnL/LY26VO1b vuyg== X-Gm-Message-State: AOAM530u1jWUVA32ugMUdtiDOoPBFsUQxqp+57ZWlOS80GatYk0A1kGV f9d5zjsp0BqkZoBosdWTliGCClC+iwdi3xPTsps= X-Received: by 2002:a67:3c2:: with SMTP id 185mr27684696vsd.42.1626772598880; Tue, 20 Jul 2021 02:16:38 -0700 (PDT) MIME-Version: 1.0 References: <20210714145804.2530727-1-geert@linux-m68k.org> <20210714145804.2530727-5-geert@linux-m68k.org> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 20 Jul 2021 11:16:27 +0200 Message-ID: Subject: Re: [PATCH resend 4/5] video: fbdev: ssd1307fb: Optimize screen updates To: Sam Ravnborg Cc: David Airlie , Daniel Vetter , Maxime Ripard , Linux Fbdev development list , Linux Kernel Mailing List , DRI Development Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sam, On Tue, Jul 20, 2021 at 9:56 AM Geert Uytterhoeven wrote: > On Mon, Jul 19, 2021 at 9:21 PM Sam Ravnborg wrote: > > On Wed, Jul 14, 2021 at 04:58:03PM +0200, Geert Uytterhoeven wrote: > > > Currently, each screen update triggers an I2C transfer of all screen > > > data, up to 1 KiB of data for a 128x64 display, which takes at least 20 > > > ms in Fast mode. > > > > > > Reduce the amount of transferred data by only updating the rectangle > > > that changed. Remove the call to ssd1307fb_set_address_range() during > > > initialization, as ssd1307fb_update_rect() now takes care of that. > > > > > > Note that for now the optimized operation is only used for fillrect, > > > copyarea, and imageblit, which are used by fbcon. > > > > > > Signed-off-by: Geert Uytterhoeven > > > > --- a/drivers/video/fbdev/ssd1307fb.c > > > +++ b/drivers/video/fbdev/ssd1307fb.c > > > @@ -184,16 +184,18 @@ static int ssd1307fb_set_address_range(struct ssd1307fb_par *par, u8 col_start, > > > return ssd1307fb_write_cmd(par->client, page_end); > > > } > > > > > > -static int ssd1307fb_update_display(struct ssd1307fb_par *par) > > > +static int ssd1307fb_update_rect(struct ssd1307fb_par *par, unsigned int x, > > > + unsigned int y, unsigned int width, > > > + unsigned int height) > > > { > > > struct ssd1307fb_array *array; > > > u8 *vmem = par->info->screen_buffer; > > > unsigned int line_length = par->info->fix.line_length; > > > - unsigned int pages = DIV_ROUND_UP(par->height, 8); > > > + unsigned int pages = DIV_ROUND_UP(height + y % 8, 8); > > > > Add () like this - at least it helps me: > > > + unsigned int pages = DIV_ROUND_UP((height + y) % 8, 8); > > Thanks, that's actually a genuine bug. No it's not "(height + y) % 8" is wrong. Better if I reorder the operands like below? unsigned int pages = DIV_ROUND_UP(y % 8 + height, 8); Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds