All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huacai Chen <chenhuacai@gmail.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Huacai Chen <chenhuacai@loongson.cn>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci <linux-pci@vger.kernel.org>,
	Xuefeng Li <lixuefeng@loongson.cn>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: Re: [PATCH V8 1/5] PCI: loongson: Use correct pci config access operations
Date: Thu, 26 Aug 2021 20:00:34 +0800	[thread overview]
Message-ID: <CAAhV-H5ES+u_os-mZ1qG2zZ_p-G-5NA8J7RhFzE_=nGNjSff8w@mail.gmail.com> (raw)
In-Reply-To: <20210825173209.GA3585627@bjorn-Precision-5520>

Hi, Bjorn,

On Thu, Aug 26, 2021 at 1:32 AM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> Things like "Use correct ..." in subject lines are useless.  *Every*
> patch should do the "proper" or "correct" thing, so it should go
> without saying.  Repeating it doesn't make it more true.
>
> This doesn't apply to *all* loongson devices, so it would be useful to
> hint at the devices it *does* apply to.
>
> Maybe something like:
>
>   PCI: loongson: Use generic 8/16/32-bit config ops on LS2K/LS7A
>
> On Wed, Aug 25, 2021 at 02:07:20PM +0800, Huacai Chen wrote:
> > LS2K/LS7A support 8/16/32-bits pci config access operations via CFG1, so
> > we can disable CFG0 for them and safely use pci_generic_config_read()/
> > pci_generic_config_write() instead of pci_generic_config_read32()/pci_
> > generic_config_write32().
>
> s/pci/PCI/
>
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > ---
> >  drivers/pci/controller/pci-loongson.c | 36 +++++++++++++++++----------
> >  1 file changed, 23 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c
> > index 48169b1e3817..b2c81c762599 100644
> > --- a/drivers/pci/controller/pci-loongson.c
> > +++ b/drivers/pci/controller/pci-loongson.c
> > @@ -159,8 +159,15 @@ static int loongson_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
> >       return val;
> >  }
> >
> > -/* H/w only accept 32-bit PCI operations */
> > +/* LS2K/LS7A accept 8/16/32-bit PCI operations */
>
> *config* operations
>
> >  static struct pci_ops loongson_pci_ops = {
> > +     .map_bus = pci_loongson_map_bus,
> > +     .read   = pci_generic_config_read,
> > +     .write  = pci_generic_config_write,
> > +};
> > +
> > +/* RS780/SR5690 only accept 32-bit PCI operations */
> > +static struct pci_ops loongson_pci_ops32 = {
> >       .map_bus = pci_loongson_map_bus,
> >       .read   = pci_generic_config_read32,
> >       .write  = pci_generic_config_write32,
> > @@ -168,9 +175,9 @@ static struct pci_ops loongson_pci_ops = {
> >
> >  static const struct of_device_id loongson_pci_of_match[] = {
> >       { .compatible = "loongson,ls2k-pci",
> > -             .data = (void *)(FLAG_CFG0 | FLAG_CFG1 | FLAG_DEV_FIX), },
> > +             .data = (void *)(FLAG_CFG1 | FLAG_DEV_FIX), },
> >       { .compatible = "loongson,ls7a-pci",
> > -             .data = (void *)(FLAG_CFG0 | FLAG_CFG1 | FLAG_DEV_FIX), },
> > +             .data = (void *)(FLAG_CFG1 | FLAG_DEV_FIX), },
> >       { .compatible = "loongson,rs780e-pci",
> >               .data = (void *)(FLAG_CFG0), },
>
> It'd be nice if you used the same strategy as most other drivers,
> e.g., ".data = &loongson_ls2k_data" or similar.
>
> >       {}
> > @@ -195,17 +202,17 @@ static int loongson_pci_probe(struct platform_device *pdev)
> >       priv->pdev = pdev;
> >       priv->flags = (unsigned long)of_device_get_match_data(dev);
> >
> > -     regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -     if (!regs) {
> > -             dev_err(dev, "missing mem resources for cfg0\n");
> > -             return -EINVAL;
> > +     if (priv->flags & FLAG_CFG0) {
> > +             regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +             if (!regs)
> > +                     dev_err(dev, "missing mem resources for cfg0\n");
> > +             else {
> > +                     priv->cfg0_base = devm_pci_remap_cfg_resource(dev, regs);
> > +                     if (IS_ERR(priv->cfg0_base))
> > +                             return PTR_ERR(priv->cfg0_base);
> > +             }
> >       }
> >
> > -     priv->cfg0_base = devm_pci_remap_cfg_resource(dev, regs);
> > -     if (IS_ERR(priv->cfg0_base))
> > -             return PTR_ERR(priv->cfg0_base);
> > -
> > -     /* CFG1 is optional */
> >       if (priv->flags & FLAG_CFG1) {
> >               regs = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> >               if (!regs)
> > @@ -218,8 +225,11 @@ static int loongson_pci_probe(struct platform_device *pdev)
> >       }
> >
> >       bridge->sysdata = priv;
> > -     bridge->ops = &loongson_pci_ops;
> >       bridge->map_irq = loongson_map_irq;
> > +     if (!of_device_is_compatible(node, "loongson,rs780e-pci"))
>
> You already called of_device_get_match_data() above, which does
> essentially the same work as of_device_is_compatible().
OK, thanks, I will update this patch.

Huacai
>
> > +             bridge->ops = &loongson_pci_ops;
> > +     else
> > +             bridge->ops = &loongson_pci_ops32;
> >
> >       return pci_host_probe(bridge);
> >  }
> > --
> > 2.27.0
> >

  reply	other threads:[~2021-08-26 12:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25  6:07 [PATCH V8 0/5] PCI: Loongson pci improvements and quirks Huacai Chen
2021-08-25  6:07 ` [PATCH V8 1/5] PCI: loongson: Use correct pci config access operations Huacai Chen
2021-08-25 17:32   ` Bjorn Helgaas
2021-08-26 12:00     ` Huacai Chen [this message]
2021-08-25  6:07 ` [PATCH V8 2/5] PCI: loongson: Add ACPI init support Huacai Chen
2021-08-25  6:07 ` [PATCH V8 3/5] PCI: Improve the MRRS quirk for LS7A Huacai Chen
2021-08-25  6:07 ` [PATCH V8 4/5] PCI: Add quirk for LS7A to avoid reboot failure Huacai Chen
2021-08-25  6:07 ` [PATCH V8 5/5] PCI: Add quirk for multifunction devices of LS7A Huacai Chen

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='CAAhV-H5ES+u_os-mZ1qG2zZ_p-G-5NA8J7RhFzE_=nGNjSff8w@mail.gmail.com' \
    --to=chenhuacai@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=chenhuacai@loongson.cn \
    --cc=helgaas@kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.