mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
UPSTREAM: of/address: Fix of_pci_range_parser_one translation of DMA addresses
of_pci_range_parser_one() has a bug when parsing dma-ranges. When it translates the parent address (aka cpu address in the code), 'ranges' is always being used. This happens to work because most users are just 1:1 translation. Cc: Robin Murphy <[email protected]> Tested-by: Nicolas Saenz Julienne <[email protected]> Reviewed-by: Nicolas Saenz Julienne <[email protected]> Signed-off-by: Rob Herring <[email protected]> (cherry picked from commit 645c138636de3d6d6ed7d92edec39298fd6873d7) Signed-off-by: John Stultz <[email protected]> Change-Id: I7dacf6a346c3e79c7a68c5826b9193b19f4dd03a
This commit is contained in:
parent
c6eba55bef
commit
36ac73c589
2 changed files with 13 additions and 3 deletions
|
|
@ -243,6 +243,7 @@ static int parser_init(struct of_pci_range_parser *parser,
|
|||
parser->node = node;
|
||||
parser->pna = of_n_addr_cells(node);
|
||||
parser->np = parser->pna + na + ns;
|
||||
parser->dma = !strcmp(name, "dma-ranges");
|
||||
|
||||
parser->range = of_get_property(node, name, &rlen);
|
||||
if (parser->range == NULL)
|
||||
|
|
@ -281,7 +282,11 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
|
|||
range->pci_space = be32_to_cpup(parser->range);
|
||||
range->flags = of_bus_pci_get_flags(parser->range);
|
||||
range->pci_addr = of_read_number(parser->range + 1, ns);
|
||||
range->cpu_addr = of_translate_address(parser->node,
|
||||
if (parser->dma)
|
||||
range->cpu_addr = of_translate_dma_address(parser->node,
|
||||
parser->range + na);
|
||||
else
|
||||
range->cpu_addr = of_translate_address(parser->node,
|
||||
parser->range + na);
|
||||
range->size = of_read_number(parser->range + parser->pna + na, ns);
|
||||
|
||||
|
|
@ -294,8 +299,12 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
|
|||
|
||||
flags = of_bus_pci_get_flags(parser->range);
|
||||
pci_addr = of_read_number(parser->range + 1, ns);
|
||||
cpu_addr = of_translate_address(parser->node,
|
||||
parser->range + na);
|
||||
if (parser->dma)
|
||||
cpu_addr = of_translate_dma_address(parser->node,
|
||||
parser->range + na);
|
||||
else
|
||||
cpu_addr = of_translate_address(parser->node,
|
||||
parser->range + na);
|
||||
size = of_read_number(parser->range + parser->pna + na, ns);
|
||||
|
||||
if (flags != range->flags)
|
||||
|
|
|
|||
Loading…
Reference in a new issue