lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 20 Jul 2020 18:21:45 -0600
From:   Rob Herring <robh+dt@...nel.org>
To:     Jiaxun Yang <jiaxun.yang@...goat.com>
Cc:     "open list:MIPS" <linux-mips@...r.kernel.org>,
        Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
        Huacai Chen <chenhc@...ote.com>,
        Frank Rowand <frowand.list@...il.com>,
        Paul Burton <paulburton@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Arnd Bergmann <arnd@...db.de>, devicetree@...r.kernel.org,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/5] of_address: Add bus type match for pci ranges parser

On Mon, Jul 20, 2020 at 1:49 AM Jiaxun Yang <jiaxun.yang@...goat.com> wrote:
>
> So the parser can be used to parse range property of different bus
> types, such as ISA bus.

Regular MMIO buses are actually already supported, but not ISA.

>
> As they're all using PCI-like method of range property, there is no need
> start a new parser.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@...goat.com>
> ---
>  drivers/of/address.c       | 15 +++++++++++----
>  include/linux/of_address.h |  3 +++
>  2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/of/address.c b/drivers/of/address.c
> index 8eea3f6e29a4..250c91767648 100644
> --- a/drivers/of/address.c
> +++ b/drivers/of/address.c
> @@ -702,6 +702,10 @@ static int parser_init(struct of_pci_range_parser *parser,
>         parser->ns = of_bus_n_size_cells(node);
>         parser->dma = !strcmp(name, "dma-ranges");
>
> +       parser->bus = of_match_bus(node);
> +       if (!parser->bus)
> +               return -ENOENT;

You'll hit BUG() before you get here, so you can assume success.

> +
>         parser->range = of_get_property(node, name, &rlen);
>         if (parser->range == NULL)
>                 return -ENOENT;
> @@ -732,6 +736,7 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
>         int na = parser->na;
>         int ns = parser->ns;
>         int np = parser->pna + na + ns;
> +       int bus_na = 0;
>
>         if (!range)
>                 return NULL;
> @@ -739,8 +744,10 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
>         if (!parser->range || parser->range + np > parser->end)
>                 return NULL;
>
> -       if (parser->na == 3)
> -               range->flags = of_bus_pci_get_flags(parser->range);
> +       parser->bus->count_cells(parser->node, &bus_na, NULL);
> +
> +       if (parser->na == bus_na)
> +               range->flags = parser->bus->get_flags(parser->range);

I think you can just unconditionally call this and drop the else. For
plain MMIO bus, we'd just return IORESOURCE_MEM, but I think the flags
are ignored in that case.

>         else
>                 range->flags = 0;
>
> @@ -761,8 +768,8 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
>                 u32 flags = 0;
>                 u64 pci_addr, cpu_addr, size;
>
> -               if (parser->na == 3)
> -                       flags = of_bus_pci_get_flags(parser->range);
> +               if (parser->na == bus_na)

This too can be unconditional.

> +                       flags = parser->bus->get_flags(parser->range);
>                 pci_addr = of_read_number(parser->range, na);

Perhaps rename pci_addr to child_addr and cpu_addr to parent_addr.

>                 if (parser->dma)
>                         cpu_addr = of_translate_dma_address(parser->node,
> diff --git a/include/linux/of_address.h b/include/linux/of_address.h
> index 763022ed3456..3929b4637033 100644
> --- a/include/linux/of_address.h
> +++ b/include/linux/of_address.h
> @@ -6,8 +6,11 @@
>  #include <linux/of.h>
>  #include <linux/io.h>
>
> +struct of_bus;
> +
>  struct of_pci_range_parser {
>         struct device_node *node;
> +       struct of_bus *bus;
>         const __be32 *range;
>         const __be32 *end;
>         int na;
> --
> 2.28.0.rc1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ