Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp83361pxb; Mon, 8 Nov 2021 10:07:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCYdmChhHRwprO6ZaIWmRMj+rbrhRn5BKU7lRwhM2rb8ai43XfrzIHm5vW6kL4N3RbCjeg X-Received: by 2002:a92:ce02:: with SMTP id b2mr738740ilo.210.1636394839776; Mon, 08 Nov 2021 10:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636394839; cv=none; d=google.com; s=arc-20160816; b=xvNzzV12kTILWkNcz8zRHW71PTAYWoM5wJwocoxbvTsYzVaTJlyIMHdUxjYSqusHel PLUMI8fk8sBG3jNZyIup2HjIn4d3jGX1ChaiIBbEvostuwTnBDClkeIED7p0Y4CfSY9u bMl+mPW0e12FFMNiRO1BkGH1cAWW+/FgJ9oyUiN710SQWW2dRPJca75DUscZ6Rwb8hvj kE4LGgjuJPO7QmQsnpRxrScoeOfrb4TmTKutdyTUdKwmOjB+lobaaq7D6NhrnmDi0Qy3 a5Cgp9FhHC7yQ9ZwrK6Kd2nJc/UEX3/SGWDq4z95Ql/ShFBQyLZ61HfFbbgO7u7HydEo tayw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date; bh=fi+0sD688MDwk2S0vguSaUsFY3NYlGNbMj5GHlqfgL4=; b=E3n+TR9YbwBszs65VGpJbxZcZ1bNFZjvil90RXfgMmIgybQe0QGE6B4kI3IxW7Zs9q 8Tuf4BsWb17b2MKI4ndLyNXuWNhOHCl3gfHR7K312EvxSe90CdBOYJMXjiEUp9JiZ31q AFZClypqJZ0EITqeZZwmsXMhaTnMR2grdIS8ITwQnBggbxmFQBeIkCSpAopXMT3hcoKr wO7QclcivDH1vE8o8H69ANBYyI0Am9laP+qRmgNkD/YkP6m9oFF24BNmljy/7SzCXVm8 +Wa8jJ1P4O4xOvv9o6fWHoMPjgk7VAoCj8aKroutVMrhG3/QQdD4Y7ZXPxYHMoKI/pnU LsEg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si35620546ila.81.2021.11.08.10.07.02; Mon, 08 Nov 2021 10:07:19 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238312AbhKHMYF convert rfc822-to-8bit (ORCPT + 99 others); Mon, 8 Nov 2021 07:24:05 -0500 Received: from aposti.net ([89.234.176.197]:51830 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237354AbhKHMYE (ORCPT ); Mon, 8 Nov 2021 07:24:04 -0500 Date: Mon, 08 Nov 2021 12:20:59 +0000 From: Paul Cercueil Subject: Re: [PATCH v5 2/7] drm/ingenic: Add support for JZ4780 and HDMI output To: "H. Nikolaus Schaller" Cc: Rob Herring , Mark Rutland , Thomas Bogendoerfer , Geert Uytterhoeven , Kees Cook , "Eric W. Biederman" , Miquel Raynal , David Airlie , Daniel Vetter , Neil Armstrong , Robert Foss , Laurent Pinchart , Jernej Skrabec , Harry Wentland , Sam Ravnborg , Maxime Ripard , Hans Verkuil , Liam Girdwood , Mark Brown , Paul Boddie , OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS , linux-mips , linux-kernel , Discussions about the Letux Kernel , Jonas Karlman , dri-devel Message-Id: In-Reply-To: <2E32F572-72D0-44E7-A700-AF8A2D37BFDA@goldelico.com> References: <2c7d0aa7d3ef480ebb996d37c27cbaa6f722728b.1633436959.git.hns@goldelico.com> <7CEBB741-2218-40A7-9800-B3A154895274@goldelico.com> <229EBE4C-6555-41DE-962F-D82798AEC650@goldelico.com> <2E32F572-72D0-44E7-A700-AF8A2D37BFDA@goldelico.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le lun., nov. 8 2021 at 11:52:20 +0100, H. Nikolaus Schaller a ?crit : > Hi Paul, > >>> Am 08.11.2021 um 10:37 schrieb Paul Cercueil >>> : >>> >>> Well, it was atomic: "add jz4780+hdmi functionality" or not. Now >>> we separate into "preparation for adding jz4780" and "really >>> adding". Yes, you can split atoms into quarks... >> >> And that's how it should be done. Lots of small atomic patches are >> much easier to review than a few big patches. > > I doubt that in this case especially as it has nothing to do with > jz4780... It has nothing to do with JZ4780 and that's exactly why it should be a separate patch. > But I have a proposal for a better solution at the end of this mail. > >>>> Note that you can do even better, set the .max_register field >>>> according to the memory resource you get from DTS. Have a look at >>>> the pinctrl driver which does exactly this. >>> That is an interesting idea. Although I don't see where >>> >>> https://elixir.bootlin.com/linux/latest/source/drivers/pinctrl/pinctrl-ingenic.c#L4171 >>> does make use of the memory resource from DTS. It just reads two >>> values from the ingenic_chip_info instead of one I do read from >>> soc_info. >> >> It overrides the .max_register from a static regmap_config instance. > > To be precise: it overrides .max_register of a copy of a static > regmap_config instance (which has .max_register = 0). > >> You can do the same, > > We already do the same... > >> calculating the .max_register from the memory resource you get from >> DT. > > I can't see any code in pinctrl-ingenic.c getting the memory resource > that from DT. It calculates it from the ingenic_chip_info tables > inside the driver code but not DT. > >> I'm sure you guys can figure it out. > > Ah, we have to figure out. You are not sure yourself how to do it? > And it is *not* exactly like the pinctrl driver (already) does? > Please give precise directions in reviews and not vague research > homework. Our time is also valuable. Sorry if I review your reviews... > > Anyways I think you roughly intend (untested): > > struct resource *r; > > r = platform_get_resource(pdev, IORESOURCE_MEM, 0); > regmap_config.max_register = r.end - r.start; Replace the "devm_platform_ioremap_resource" with "devm_platform_get_and_ioremap_resource" to get a pointer to the resource. Then the .max_register should be (r.end - r.start - 4) I think. And lose the aggressivity. It's not going to get you anywhere, especially since I'm the one who decides whether or not I should merge your patches. You want your code upstream, that's great, but it's your responsability to get it to shape so that it's eventually accepted. > > But I wonder how that could work at all (despite adding code > execution time) with: Code execution time? ... > e.g. jz4770.dtsi: > > lcd: lcd-controller@13050000 { > compatible = "ingenic,jz4770-lcd"; > reg = <0x13050000 0x300>; > > or jz4725b.dtsi: > > lcd: lcd-controller@13050000 { > compatible = "ingenic,jz4725b-lcd"; > reg = <0x13050000 0x1000>; > > So max_register becomes 0x300 or 0x1000 but not > > #define JZ_REG_LCD_SIZE1 0x12c > .max_reg = JZ_REG_LCD_SIZE1, > > And therefore wastes a lot of regmap memory. "regmap memory"? ... > Do you want this? DTS should not be reduced (DTS should be kept as > stable as possible), since the reg property describes address mapping > - not how many bytes are really used by registers or how big a cache > should be allocated (cache allocation size requirements are not > hardware description). The DTS should list the address and size of the register area. If your last register is at address 0x12c and there's nothing above, then the size in DTS should be 0x130. > But here are good news: > > I have a simpler and less invasive proposal. We keep the > devm_regmap_init_mmio code as is and just increase its .max_register > from JZ_REG_LCD_SIZE1 to JZ_REG_LCD_PCFG when introducing the jz4780. > This wastes a handful bytes for all non-jz4780 chips but less than > using the DTS memory region size. And is less code (no entry in > soc_info tables, no modifyable copy) and faster code execution than > all other proposals. > > This is then just a single-line change when introducing the jz4780. > And no "preparation for adding jz4780" patch is needed at all. No > patch to split out for separate review. > > Let's go this way to get it eventually finalized. Ok? No. Cheers, -Paul