linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rich Felker <dalias@libc.org>
To: Rob Herring <robh@kernel.org>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	SH-Linux <linux-sh@vger.kernel.org>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Pawel Moll <pawel.moll@arm.com>
Subject: Re: [PATCH v3 04/12] of: add J-Core timer bindings
Date: Wed, 1 Jun 2016 21:34:07 -0400	[thread overview]
Message-ID: <20160602013407.GA12184@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAL_JsqJYyvdc06v2+R=Wnmkk-cO7ZFq=7uGOhPxXdL0UfEu-iA@mail.gmail.com>

On Wed, Jun 01, 2016 at 05:36:19PM -0500, Rob Herring wrote:
> On Wed, Jun 1, 2016 at 12:53 PM, Rich Felker <dalias@libc.org> wrote:
> > On Wed, Jun 01, 2016 at 08:58:52AM -0500, Rob Herring wrote:
> >> On Wed, May 25, 2016 at 05:43:03AM +0000, Rich Felker wrote:
> >> > Signed-off-by: Rich Felker <dalias@libc.org>
> >> > ---
> >> >  .../devicetree/bindings/timer/jcore,pit.txt        | 28 ++++++++++++++++++++++
> >> >  1 file changed, 28 insertions(+)
> >> >  create mode 100644 Documentation/devicetree/bindings/timer/jcore,pit.txt
> >> >
> >> > diff --git a/Documentation/devicetree/bindings/timer/jcore,pit.txt b/Documentation/devicetree/bindings/timer/jcore,pit.txt
> >> > new file mode 100644
> >> > index 0000000..96c6815
> >> > --- /dev/null
> >> > +++ b/Documentation/devicetree/bindings/timer/jcore,pit.txt
> >> > @@ -0,0 +1,28 @@
> >> > +J-Core Programmable Interval Timer and Clocksource
> >> > +
> >> > +Required properties:
> >> > +
> >> > +- compatible: Must be "jcore,pit".
> >> > +
> >> > +- reg: Memory region for timer/clocksource registers.
> >> > +
> >> > +- interrupts: An interrupt to assign for the timer. The actual pit
> >> > +  core is integrated with the aic and allows the timer interrupt
> >> > +  assignment to be programmed by software, but this property is
> >> > +  required in order to reserve an interrupt number that doesn't
> >> > +  conflict with other devices.
> >> > +
> >> > +Optional properties:
> >> > +
> >> > +- cpu-offset: For SMP, the per-cpu offset to the local timer
> >> > +  programming memory range.
> >> > +
> >> > +
> >> > +Example:
> >> > +
> >> > +timer@200 {
> >> > +   compatible = "jcore,pit";
> >> > +   reg = < 0x200 0x30 >;
> >> > +   cpu-offset = < 0x300 >;
> >>
> >> This is outside the reg range. Perhaps reg should include each range of
> >> per cpu registers.
> >
> > In the hardware, each timer instance is mapped independently so
> > there's no fundamental reason they need to be mapped sufficiently
> > close that it would make sense for a single virtual mapping to cover
> > them all. This doesn't matter for nommu but it would with mmu in the
> > future. In the driver I've updated it to ioremap each percpu instance
> > separately (as its own memory range) using the cpu-offset applied to
> > the range obtained from "reg". Is this acceptable (in which case I
> > suppose the binding needs to be documented that "reg" just covers the
> > cpu0 instance's range)? Do you think it would be preferable to have
> > multiple "reg" ranges indexed by cpu instead of cpu-offset?
> 
> Yes. Either reg should cover the full range of addresses or you should
> have multiple reg values with one for each cpu. I prefer the latter as
> it doesn't create a custom property for expressing register addresses.

OK, let's lean towards going with the latter then. It's more flexible
and allows any placement of the maps; the offset per cpu does not have
to be constant. It also makes the driver code simpler since of_iomap
can be used directly rather than requiring of_address_to_resource,
physical address arithmetic arithmetic, and ioremap on the results. Is
there any precedent for using multiple reg ranges for percpu register
instances like this? Anything else they've been used for?

> > In theory it would even be possible to just require a DT node per
> > cpulocal timer, but I didn't see a good way to make the bindings
> > represent the relationship to cpus or to make the driver handle irqs
> > correctly for such a setup, so I'd need a viable proposal for how that
> > could be done to even consider such an approach.
> 
> Yeah, there's not really a standard way to map per cpu blocks to cpus.
> We could, but doesn't really seem necessary here.
> 
> For the irqs, percpu irqs doesn't help you?

What I mean is that, if there were a separate device node and driver
instance per cpu, they'd all want to register the same irq just to
handle it on their own cpu, so we'd have a lot of spurious handlers
running. The right way to model this, I think, would be as a virtual
irqchip that's the irq parent of all the timer nodes, and that
multiplexes the real irq to one virq per cpu (where the current cpu id
becomes the irq number in its irq domain). But that's a lot of virtual
infrastructure just for the sake of modelling each percpu timer as its
own DT node and I don't think it makes sense to do it that way.

Rich

  reply	other threads:[~2016-06-02  1:34 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25  5:43 [PATCH v3 00/12] J-core J2 cpu and SoC peripherals support Rich Felker
2016-05-25  5:43 ` [PATCH v3 01/12] of: add vendor prefix for J-Core Rich Felker
2016-05-25 13:18   ` Rob Herring
2016-07-27  5:31     ` Rich Felker
2016-08-04 22:27       ` Rich Felker
2016-08-30 21:13         ` Rob Herring
2016-05-25  5:43 ` [PATCH v3 12/12] sh: add device tree source for J2 FPGA on Mimas v2 board Rich Felker
2016-05-25 10:33   ` Mark Rutland
2016-05-25 23:15     ` Rich Felker
2016-05-26 10:39       ` Mark Rutland
2016-05-25  5:43 ` [PATCH v3 02/12] of: add J-Core cpu bindings Rich Felker
2016-05-25 10:22   ` Mark Rutland
2016-05-25 23:04     ` Rich Felker
2016-05-26  7:54       ` Geert Uytterhoeven
2016-05-26 10:38       ` Mark Rutland
2016-05-26 15:33         ` Rich Felker
2016-05-27  9:13           ` Mark Rutland
2016-05-26 21:44       ` Rob Landley
2016-05-27 11:51         ` Afzal Mohammed
2016-05-25  5:43 ` [PATCH v3 09/12] clocksource: add J-Core timer/clocksource driver Rich Felker
2016-05-25  5:43 ` [PATCH v3 03/12] of: add J-Core interrupt controller bindings Rich Felker
2016-05-25 10:25   ` Mark Rutland
2016-05-25 23:08     ` Rich Felker
2016-05-25  5:43 ` [PATCH v3 11/12] sh: add defconfig for J-Core J2 Rich Felker
2016-05-25  5:43 ` [PATCH v3 07/12] sh: add AT_HWCAP flag for J-Core cas.l instruction Rich Felker
2016-05-25  5:43 ` [PATCH v3 10/12] spi: add driver for J-Core SPI controller Rich Felker
2016-05-25 10:17   ` Mark Brown
2016-05-27  1:16     ` Rich Felker
2016-05-27 11:27       ` Mark Brown
2016-05-25  5:43 ` [PATCH v3 04/12] of: add J-Core timer bindings Rich Felker
2016-06-01 13:58   ` Rob Herring
2016-06-01 17:53     ` Rich Felker
2016-06-01 21:53       ` Rich Felker
2016-06-01 22:36       ` Rob Herring
2016-06-02  1:34         ` Rich Felker [this message]
2016-06-02 22:44           ` Rob Herring
2016-06-23 21:16             ` Rich Felker
2016-07-14 22:18               ` Rich Felker
2016-05-25  5:43 ` [PATCH v3 05/12] of: add J-Core SPI master bindings Rich Felker
2016-05-25 19:04   ` Rob Herring
2016-05-25  5:43 ` [PATCH v3 06/12] sh: add support for J-Core J2 processor Rich Felker
2016-05-25  5:43 ` [PATCH v3 08/12] irqchip: add J-Core AIC driver Rich Felker
2016-07-15  1:27   ` Rich Felker
2016-07-15 18:19     ` Rich Felker
2016-07-15 15:35   ` Paul Gortmaker
2016-07-15 15:41     ` Rich Felker
2016-07-15 16:19   ` Jason Cooper
2016-07-15 17:02     ` Rich Felker
2016-05-25  7:22 ` [PATCH v3 00/12] J-core J2 cpu and SoC peripherals support Geert Uytterhoeven
2016-05-25  9:54 ` Mark Brown
2016-05-25 22:24   ` Rich Felker
2016-05-26  0:42     ` Mark Brown

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=20160602013407.GA12184@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh@kernel.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).