linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Paul Walmsley <paul.walmsley@sifive.com>
Cc: "kstewart@linuxfoundation.org" <kstewart@linuxfoundation.org>,
	"pgaikwad@nvidia.com" <pgaikwad@nvidia.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"geert+renesas@glider.be" <geert+renesas@glider.be>,
	"chunhui.dai@mediatek.com" <chunhui.dai@mediatek.com>,
	Yangtao Li <tiny.windzz@gmail.com>,
	"mturquette@baylibre.com" <mturquette@baylibre.com>,
	"miquel.raynal@bootlin.com" <miquel.raynal@bootlin.com>,
	"nsekhar@ti.com" <nsekhar@ti.com>,
	"tomasz.figa@gmail.com" <tomasz.figa@gmail.com>,
	"rfontana@redhat.com" <rfontana@redhat.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	"weiyongjun1@huawei.com" <weiyongjun1@huawei.com>,
	"krzk@kernel.org" <krzk@kernel.org>,
	"s.nawrocki@samsung.com" <s.nawrocki@samsung.com>,
	"manivannan.sadhasivam@linaro.org"
	<manivannan.sadhasivam@linaro.org>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	Leonard Crestez <leonard.crestez@nxp.com>,
	"festevam@gmail.com" <festevam@gmail.com>,
	"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
	"robh@kernel.org" <robh@kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	"emilio@elopez.com.ar" <emilio@elopez.com.ar>,
	"linux-realtek-soc@lists.infradead.org"
	<linux-realtek-soc@lists.infradead.org>,
	"allison@lohutok.net" <allison@lohutok.net>,
	Fabien DESSENNE <fabien.dessenne@st.com>,
	"jonathanh@nvidia.com" <jonathanh@nvidia.com>,
	"cw00.choi@samsung.com" <cw00.choi@samsung.com>,
	"wens@csie.org" <wens@csie.org>,
	"agross@kernel.org" <agross@kernel.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	dl-linux-imx <linux-imx@nxp.com>,
	"Eugeniy.Paltsev@synopsys.com" <Eugeniy.Paltsev@synopsys.com>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"swinslow@gmail.com" <swinslow@gmail.com>,
	"john@phrozen.org" <john@phrozen.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Aisheng Dong <aisheng.dong@nxp.com>,
	Paul Walmsley <paul@pwsan.com>, James Tai <james.tai@realtek.com>,
	Cheng-Yu Lee <cylee12@realtek.com>,
	"jcmvbkbc@gmail.com" <jcmvbkbc@gmail.com>,
	"sboyd@kernel.org" <sboyd@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"pdeschrijver@nvidia.com" <pdeschrijver@nvidia.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"t-kristo@ti.com" <t-kristo@ti.com>,
	"dinguyen@kernel.org" <dinguyen@kernel.org>,
	"kgene@kernel.org" <kgene@kernel.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"wangyan.wang@mediatek.com" <wangyan.wang@mediatek.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>
Subject: Re: [PATCH 08/17] clk: imx: convert to devm_platform_ioremap_resource
Date: Thu, 12 Dec 2019 06:38:31 +0100	[thread overview]
Message-ID: <1a415db0-9313-72c3-e02c-0f3b8e0e5da0@suse.de> (raw)
In-Reply-To: <alpine.DEB.2.21.9999.1912111411120.73923@viisi.sifive.com>

Am 11.12.19 um 23:49 schrieb Paul Walmsley:
> On Wed, 11 Dec 2019, Andreas Färber wrote:
> 
>> Blocks do have names, but they don't always group registers of the same
>> kind, as Linux expects it
> 
> Linux does not expect that all of the registers in the same IP block are 
> of the same kind.  That's part of the reason why Linux frameworks exist.  
> To consider clocks as the present example, you're welcome to register 
> local IP block clock control registers in the local IP block driver via 
> the clock framework.  There's no need for a separate clock driver with an 
> overlapping address range, or anything like that.

If I throw random code into drivers/mfd/ it will not get proper review.

We rely on clk drivers going into drivers/clk/, even if I could
theoretically register clks also from other parts of the code base -
which will then require complex Kconfig dependencies or #ifdef'ery, not
to mention the nightmares of collecting Acks and figuring out through
whose tree which patches go.

> 
> This is nothing new with Realtek.

As this NXP patch proves. :)

>  IP blocks that contain many different 
> kinds of registers have had Linux driver support without requiring 
> overlapping register address ranges long before Realtek ARM SoCs 
> appeared.

Hey, you're the one that's trying to pin this on Realtek, not me!
STM32 RCC is another example I know, also Allwinner, etc. My point was
precisely that this is - for good or bad - a rather common scenario that
we need to deal with.

>> Just please accept that hardware does not always allow for unique 
>> contiguous memory reservations
> 
> Hardware designs do in fact mandate unique contiguous memory reservations,
> otherwise address decoding would be indeterministic.

Are you not understanding what I'm saying or intentionally gas-lighting?
A contiguous memory _reservation_ is a range of memory like <0xdead0000
0x100> that the kernel (software!) blocks other drivers (software!) from
reserving. This has _nothing_ to do with hardware address line decoding.
It's still about devm_platform_ioremap_resource() and related APIs. Do a
`cat /proc/iomem` to see, e.g., "98007800-9800781f : serial" reservation
in successful case; as mentioned by Leonard, an unsuccessful reservation
usually causes the driver to fail to probe and thus be unavailable.

>  What they don't 
> mandate is that all of the registers in that region be all of one kind. 
> It's certainly possible to have an SoC with one giant IP block with all 
> registers mixed together.  Even in that case, it is still incorrect to 
> have multiple DT entries with overlapping register address ranges.

Says who? Since when? Can we maybe agree that incorrect != invalid?

> It sounds like you're thinking of the difficulties of figuring out how to 
> structure the software driver support for those mixed IP block as a Linux 
> driver:

Yes, these are Linux kernel mailing lists and patches after all... I
don't design hardware, that's why I said we need to live with the flawed
reality of the actual hardware we get.

> where it would fit in the tree, what frameworks it would need to 
> register with, and who would maintain it.  Those issues certainly merit 
> careful thought and consideration.  They aren't related to multiple 
> overlapping address ranges.

Oh they are. Overlapping address ranges of DT nodes are a _result_ of
unexpected hardware design involving blocks not clearly separated the
same way as Linux subsystems (to distinguish from "frameworks") are.

The DT should describe the hardware blocks as they were designed, but on
the other hand, we need to describe it in a way that Linux drivers can
actually bind against the relevant parts and that those drivers can
operate efficiently. There is no ioremap-all-regs helper that I'm aware
of, for instance, as that would result in __iomem base addresses to be
stored per reg entry; compare that to just one for an overlapping range.

Example:

clk@f00 {
	reg = <0xf00 0x100>;
}

reset@f0f {
	reg = <0xf0c 0x4>;
};

This should be a valid DT example today, as long as the clk driver
doesn't mess with the reset register embedded within its range. In this
case they can't both reserve their ranges as they would mutually cause
each other to fail to probe, depending on probe order.

As I wrote, turning this into

clk@f00 {
	reg = <0xf00 0xc>, <0xf10 0xe0>;
};

reset@f0f {
	reg = <0xf0c 0x4>;
};

is helping no one and makes things much more complex, especially when
the number of carve-outs grows or is not predetermined, as I noted about
some of my cases. Thus I disagree with you about the overlapping ranges.

DT needs to be designed forward-looking rather than just around the
handful of registers we might read/write today, not just to relieve Rob
from excessive reviews.

My solution was to do

syscon@f00 {
	reg = <0xf00 0x100>;
	ranges = ...;

	clk@0 {
		reg = <0x0 0x100>;
	};

	reset@c {
		reg = <0xc 0x4>;
	};
};

https://patchwork.kernel.org/cover/11269453/
https://patchwork.kernel.org/cover/11269971/ (and more in my tree)

which clearly models the blocks and shares a syscon for most children,
other than pre-existing 8250 UART, I²C, etc. drivers using platform
helpers such as the one discussed here.

What we lose with syscon is reservations, i.e. /proc/iomem neither
showing the full syscon nor the drivers using parts of it, unless we
explicitly reserve the memory (syscon does the ioremap for us, so no
need for this devm_platform_ioremap_resource helper there).

Also please keep in mind that we actually want to get to the point where
new systems are booting and usable. At least in the Arm world we do have
hardware at plenty to boot Linux. Dying in DT-beauty then is
counter-productive; we also need to come to timely compromises for not
blocking other work. clk drivers don't need to be platform_drivers like
here and thus can coexist easier with other drivers (e.g., syscon
without child), but I clearly contradict the generality in which you
appear to rule out overlapping memory ranges, be it for siblings or for
parent/child.

Hiding overlaps in an mfd driver does not strike me as better than
openly declaring them - if the mfd components are not dynamic, then I
understood simple-mfd were the way to go, which requires some reg(s),
which then for convenience may overlap if there's no clear boundaries.

Regards,
Andreas

-- 
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer
HRB 36809 (AG Nürnberg)


  reply	other threads:[~2019-12-12  5:38 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 19:57 [PATCH 01/17] clk: sunxi: sunxi-ng: convert to devm_platform_ioremap_resource Yangtao Li
2019-12-09 19:57 ` [PATCH 02/17] clk: qcom: " Yangtao Li
2019-12-09 19:57 ` [PATCH 03/17] clk: samsung: " Yangtao Li
2019-12-10  2:10   ` Chanwoo Choi
2019-12-09 19:57 ` [PATCH 04/17] clk: mediatek: " Yangtao Li
2019-12-09 19:57 ` [PATCH 05/17] clk: hisilicon: " Yangtao Li
2019-12-09 19:57 ` [PATCH 06/17] clk: tegra: " Yangtao Li
2019-12-11  9:49   ` Peter De Schrijver
2019-12-09 19:57 ` [PATCH 07/17] clk: mvebu: " Yangtao Li
2019-12-09 19:57 ` [PATCH 08/17] clk: imx: " Yangtao Li
2019-12-09 20:44   ` Leonard Crestez
2019-12-10 13:21     ` Thierry Reding
2019-12-10 14:57       ` Andreas Färber
2019-12-10 15:10         ` mripard
2019-12-11 17:57         ` Paul Walmsley
2019-12-11 19:54           ` Andreas Färber
2019-12-11 22:49             ` Paul Walmsley
2019-12-12  5:38               ` Andreas Färber [this message]
2019-12-12  6:40                 ` Thierry Reding
2019-12-11 17:51       ` Paul Walmsley
2019-12-11 18:38         ` Leonard Crestez
2019-12-10 20:37     ` Frank Lee
2019-12-09 19:57 ` [PATCH 09/17] clk: sifive: " Yangtao Li
2019-12-09 19:57 ` [PATCH 10/17] clk: axi-clkgen: " Yangtao Li
2019-12-09 19:57 ` [PATCH 11/17] clk: milbeaut: " Yangtao Li
2019-12-09 19:57 ` [PATCH 12/17] clk: socfpga: " Yangtao Li
2019-12-16 20:20   ` Dinh Nguyen
2019-12-09 19:57 ` [PATCH 13/17] clk: gemini: " Yangtao Li
2019-12-09 19:57 ` [PATCH 14/17] clk: axm5516: " Yangtao Li
2019-12-09 19:57 ` [PATCH 15/17] clk: bm1880: " Yangtao Li
2019-12-09 19:57 ` [PATCH 16/17] clk: actions: " Yangtao Li
2019-12-09 19:57 ` [PATCH 17/17] ARC: clk: " Yangtao Li
2019-12-13  8:05 ` [PATCH 01/17] clk: sunxi: sunxi-ng: " Chen-Yu Tsai
2020-01-31  1:06 ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a415db0-9313-72c3-e02c-0f3b8e0e5da0@suse.de \
    --to=afaerber@suse.de \
    --cc=Eugeniy.Paltsev@synopsys.com \
    --cc=agross@kernel.org \
    --cc=aisheng.dong@nxp.com \
    --cc=allison@lohutok.net \
    --cc=chunhui.dai@mediatek.com \
    --cc=cw00.choi@samsung.com \
    --cc=cylee12@realtek.com \
    --cc=daniel.baluta@nxp.com \
    --cc=dinguyen@kernel.org \
    --cc=emilio@elopez.com.ar \
    --cc=fabien.dessenne@st.com \
    --cc=festevam@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=james.tai@realtek.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=john@phrozen.org \
    --cc=jonathanh@nvidia.com \
    --cc=kernel@pengutronix.de \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=leonard.crestez@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-realtek-soc@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=matthias.bgg@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mripard@kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=nsekhar@ti.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paul@pwsan.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=pgaikwad@nvidia.com \
    --cc=rfontana@redhat.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=swinslow@gmail.com \
    --cc=t-kristo@ti.com \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    --cc=tiny.windzz@gmail.com \
    --cc=tomasz.figa@gmail.com \
    --cc=wangyan.wang@mediatek.com \
    --cc=weiyongjun1@huawei.com \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).