Re: [PATCH 4/8] PCI: host: brcmstb: add dma-ranges for inbound traffic

2017-10-25 Thread Jim Quinlan
On Wed, Oct 25, 2017 at 5:46 AM, David Laight  wrote:
> From: Jim QuinlanPCIE_IPROC_MSI
>> Sent: 24 October 2017 19:16
>> The Broadcom STB PCIe host controller is intimately related to the
>> memory subsystem.  This close relationship adds complexity to how cpu
>> system memory is mapped to PCIe memory.  Ideally, this mapping is an
>> identity mapping, or an identity mapping off by a constant.  Not so in
>> this case.
>>
>> Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB
>> of system memory.  Here is how the PCIe controller maps the
>> system memory to PCIe memory:
>>
>>   memc0-a@[03fff] <=> pci@[03fff]
>>   memc0-b@[1...13fff] <=> pci@[ 40007fff]
>>   memc1-a@[ 40007fff] <=> pci@[ 8000bfff]
>>   memc1-b@[3...33fff] <=> pci@[ c000]
>>   memc2-a@[ 8000bfff] <=> pci@[1...13fff]
>>   memc2-b@[c...c3fff] <=> pci@[14000...17fff]
>
> I presume the first column is the 'cpu physical address'
> and the second the 'pci' address?
>
Yes.  I probably made this more difficult to read because I ordered
the rows by PCI addresses.

> ...
>
> Isn't this just the same as having an iommu that converts 'bus'
> addresses into 'physical' ones?

Pretty much, but for PCIe devices only.  This could be done by somehow
overriding the arch specific phys_to_dma() and dma_to_phys() calls.

>
> A simple table lookup of the high address bits will do the
> conversion.
True, but this table could be passed something like ARM_MAPPING_ERROR,
which may be out the table (the driver is not privy to
ARM_MAPPING_ERROR's definition).

Thanks,
Jim

>
> David
>


Re: [PATCH 4/8] PCI: host: brcmstb: add dma-ranges for inbound traffic

2017-10-25 Thread Jim Quinlan
On Wed, Oct 25, 2017 at 5:46 AM, David Laight  wrote:
> From: Jim QuinlanPCIE_IPROC_MSI
>> Sent: 24 October 2017 19:16
>> The Broadcom STB PCIe host controller is intimately related to the
>> memory subsystem.  This close relationship adds complexity to how cpu
>> system memory is mapped to PCIe memory.  Ideally, this mapping is an
>> identity mapping, or an identity mapping off by a constant.  Not so in
>> this case.
>>
>> Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB
>> of system memory.  Here is how the PCIe controller maps the
>> system memory to PCIe memory:
>>
>>   memc0-a@[03fff] <=> pci@[03fff]
>>   memc0-b@[1...13fff] <=> pci@[ 40007fff]
>>   memc1-a@[ 40007fff] <=> pci@[ 8000bfff]
>>   memc1-b@[3...33fff] <=> pci@[ c000]
>>   memc2-a@[ 8000bfff] <=> pci@[1...13fff]
>>   memc2-b@[c...c3fff] <=> pci@[14000...17fff]
>
> I presume the first column is the 'cpu physical address'
> and the second the 'pci' address?
>
Yes.  I probably made this more difficult to read because I ordered
the rows by PCI addresses.

> ...
>
> Isn't this just the same as having an iommu that converts 'bus'
> addresses into 'physical' ones?

Pretty much, but for PCIe devices only.  This could be done by somehow
overriding the arch specific phys_to_dma() and dma_to_phys() calls.

>
> A simple table lookup of the high address bits will do the
> conversion.
True, but this table could be passed something like ARM_MAPPING_ERROR,
which may be out the table (the driver is not privy to
ARM_MAPPING_ERROR's definition).

Thanks,
Jim

>
> David
>


RE: [PATCH 4/8] PCI: host: brcmstb: add dma-ranges for inbound traffic

2017-10-25 Thread David Laight
From: Jim Quinlan
> Sent: 24 October 2017 19:16
> The Broadcom STB PCIe host controller is intimately related to the
> memory subsystem.  This close relationship adds complexity to how cpu
> system memory is mapped to PCIe memory.  Ideally, this mapping is an
> identity mapping, or an identity mapping off by a constant.  Not so in
> this case.
> 
> Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB
> of system memory.  Here is how the PCIe controller maps the
> system memory to PCIe memory:
> 
>   memc0-a@[03fff] <=> pci@[03fff]
>   memc0-b@[1...13fff] <=> pci@[ 40007fff]
>   memc1-a@[ 40007fff] <=> pci@[ 8000bfff]
>   memc1-b@[3...33fff] <=> pci@[ c000]
>   memc2-a@[ 8000bfff] <=> pci@[1...13fff]
>   memc2-b@[c...c3fff] <=> pci@[14000...17fff]

I presume the first column is the 'cpu physical address'
and the second the 'pci' address?

...

Isn't this just the same as having an iommu that converts 'bus'
addresses into 'physical' ones?

A simple table lookup of the high address bits will do the
conversion.

David



RE: [PATCH 4/8] PCI: host: brcmstb: add dma-ranges for inbound traffic

2017-10-25 Thread David Laight
From: Jim Quinlan
> Sent: 24 October 2017 19:16
> The Broadcom STB PCIe host controller is intimately related to the
> memory subsystem.  This close relationship adds complexity to how cpu
> system memory is mapped to PCIe memory.  Ideally, this mapping is an
> identity mapping, or an identity mapping off by a constant.  Not so in
> this case.
> 
> Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB
> of system memory.  Here is how the PCIe controller maps the
> system memory to PCIe memory:
> 
>   memc0-a@[03fff] <=> pci@[03fff]
>   memc0-b@[1...13fff] <=> pci@[ 40007fff]
>   memc1-a@[ 40007fff] <=> pci@[ 8000bfff]
>   memc1-b@[3...33fff] <=> pci@[ c000]
>   memc2-a@[ 8000bfff] <=> pci@[1...13fff]
>   memc2-b@[c...c3fff] <=> pci@[14000...17fff]

I presume the first column is the 'cpu physical address'
and the second the 'pci' address?

...

Isn't this just the same as having an iommu that converts 'bus'
addresses into 'physical' ones?

A simple table lookup of the high address bits will do the
conversion.

David