devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Gerlando Falauto
	<gerlando.falauto-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
Cc: "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Thomas Petazzoni
	<thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: address translation for PCIe-to-localbus bridge
Date: Thu, 7 Nov 2013 10:01:47 -0700	[thread overview]
Message-ID: <20131107170147.GA1057@obsidianresearch.com> (raw)
In-Reply-To: <527B5835.3060906-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>

On Thu, Nov 07, 2013 at 10:07:01AM +0100, Gerlando Falauto wrote:
> On 11/06/2013 09:07 PM, Jason Gunthorpe wrote:
> >On Wed, Nov 06, 2013 at 08:38:33PM +0100, Gerlando Falauto wrote:
> >
> [...]
> >Each translation represents something concrete:
> >  0x8 -> 0x82000000 0x00000000 0x00000008
> >     This is the BAR 0 decoder of the PCI device
> >  0x82000000 0x00000000 0x00000008 -> 0x82000000 0x1 8
> >     This is the PCI bridge's memory window decoder
> >   0x82000000 0x1 8 -> MBUS_ID(0x04, 0xe8) 8
> >     This is the MBUS window associated with the PEX
> >  MBUS_ID(0x04, 0xe8) 8 -> 0xe0000008
> >     This is the physical CPU BUS address associated with the MBUS
> >     window
> 
> Uhm, OK, sounds good. Except you must know the whole mapping in
> advance. Fair enough.
> Would that work without the whole mbus driver (I guess Ezequiel's)?
> I'm dealing with 3.10.

Yes, I am using this in 3.10. On 3.10 the ranges at the mbus level has
to match the hardwired address mapping in Linux.

> Where does the 0x82000000 come from?
> What about the 0x1 (second cell)?

0x82000000 is part of the OF PCI spec, it indicates the address space
is memory (vs io, vs prefetchable memory, etc)

The 0x1 is an arbitary unique value that matches the next ranges. It
would probably have been clearer if it was MBUS_ID(0x04, 0xe8)
instead...

> >   ranges = <0x00000000  0x82000000 0x00000000 0x08000000  0x8000000>;
> >
> >It is possible as well to do this in code in the FPGA driver.
> 
> Uhm... why? And how? You mean dynamically upgrading the ranges window?

If you can't predict where your BAR will be assigned when you create
the DT then you could update the ranges value at runtime in your pci
driver before probing the children. A bit hacky.

> >
> >>How would you also deal with a second (let's say identical) device on BAR1?
> >
> >   ranges = <0x00000000  0x82000000 0x00000000 0x08000000  0x8000000  //  BAR 0
> >             0x10000000  0x82000000 0x00000000 0x08000000  0x8000000> // BAR 1
> 
> Aren't in this case the two regions aliased? Shouldn't the fourth
> column on either row be 0x00000000? Like:

Yes, you are right!

>     ranges = <0x00000000  0x82000000 0x00000000 0x00000000
> 0x8000000 //  BAR 0
>               0x10000000  0x82000000 0x00000000 0x08000000
> 0x8000000> // BAR 1
> 
> >Use reg <0x10000abc xxx> to refer to the 2nd BAR. There are other ways
> >to organize things.
>
> Now I completely lost you. According to the above description (BTW,
> I like the double space to separate groups -- it makes this whole
> mess a little messy!) the child address should have a single cell.
> Why use two then?

0x10000abc is the address, xxxx is the size, reg always has address +
size

Jason
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2013-11-07 17:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-06 10:27 address translation for PCIe-to-localbus bridge Gerlando Falauto
     [not found] ` <527A1983.6020603-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
2013-11-06 12:23   ` Thierry Reding
     [not found]     ` <20131106122317.GA8806-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2013-11-06 12:50       ` Gerlando Falauto
2013-11-06 17:36   ` Jason Gunthorpe
     [not found]     ` <20131106173649.GA25515-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-11-06 18:03       ` Thomas Petazzoni
2013-11-06 18:24         ` Jason Gunthorpe
     [not found]           ` <20131106182457.GA25879-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-11-06 19:00             ` Thomas Petazzoni
2013-11-11 15:50             ` Grant Likely
     [not found]               ` <20131111155050.96290C41ABB-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-12  7:05                 ` Thomas Petazzoni
2013-11-12  8:11                   ` Gerlando Falauto
     [not found]                     ` <5281E2B5.3080701-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
2013-11-12  8:16                       ` Thomas Petazzoni
2013-11-12  8:26                         ` Gerlando Falauto
2013-11-13  6:26                       ` Grant Likely
2013-11-12  8:51                   ` Grant Likely
2013-11-06 18:33         ` Pantelis Antoniou
     [not found]           ` <334037D0-02FB-459F-9E40-129EC830AF65-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-11-06 18:56             ` Jason Gunthorpe
     [not found]               ` <20131106185658.GC25879-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-11-06 19:16                 ` Pantelis Antoniou
     [not found]                   ` <20246965-EEE8-4EF0-A632-0633774A572A-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2013-11-06 19:50                     ` Jason Gunthorpe
2013-11-06 19:38       ` Gerlando Falauto
     [not found]         ` <527A9AB9.2050903-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
2013-11-06 20:07           ` Jason Gunthorpe
     [not found]             ` <20131106200709.GB26881-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-11-07  9:07               ` Gerlando Falauto
     [not found]                 ` <527B5835.3060906-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
2013-11-07 17:01                   ` Jason Gunthorpe [this message]

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=20131107170147.GA1057@obsidianresearch.com \
    --to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=gerlando.falauto-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.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).