From: Bjorn Helgaas <helgaas@kernel.org> To: Bartosz Golaszewski <bgolaszewski@baylibre.com> Cc: Richard Hsu <saraon640529@gmail.com>, Richard_Hsu@asmedia.com.tw, Yd_Tseng@asmedia.com.tw, Jesse1_Chang@asmedia.com.tw, Linus Walleij <linus.walleij@linaro.org>, Bjorn Helgaas <bhelgaas@google.com>, kbuild test robot <lkp@intel.com>, kbuild-all@lists.01.org, linux-gpio <linux-gpio@vger.kernel.org>, linux-pci@vger.kernel.org Subject: Re: [PATCH] gpio:asm28xx-18xx: new driver Date: Thu, 4 Jun 2020 12:55:15 -0500 [thread overview] Message-ID: <20200604175515.GA1076951@bjorn-Precision-5520> (raw) In-Reply-To: <CAMpxmJX8U-uNYJPQxmkox=YTSvXVPrWss2y5MS81_bg43Co8Lg@mail.gmail.com> On Thu, Jun 04, 2020 at 01:54:21PM +0200, Bartosz Golaszewski wrote: > czw., 4 cze 2020 o 09:33 Richard Hsu <saraon640529@gmail.com> napisał(a): > > > > Hi Linus Walleij,Bartosz Golaszewski and kbuild test robot, > > I have fixed the warnings(make W=1 ARCH=i386) by replace two functions > > with static type,and resend the patch. > > line 69: > > <<void pci_config_pm_runtime_get(struct pci_dev *pdev) > > >>static void pci_config_pm_runtime_get(struct pci_dev *pdev) > > line 91: > > <<void pci_config_pm_runtime_put(struct pci_dev *pdev) > > >>static void pci_config_pm_runtime_put(struct pci_dev *pdev) > > > > Thanks > > > > BR, > > Richard > > Signed-off-by: Richard Hsu <saraon640529@gmail.com> > > + /* We look for our device - Asmedia 28XX and 18XX Bridge > > + * I don't know about a system with two such bridges, > > + * so we can assume that there is max. one device. > > + * > > + * We can't use plain pci_driver mechanism, > > + * as the device is really a multiple function device, > > + * main driver that binds to the pci_device is an bus > > + * driver and have to find & bind to the device this way. > > + */ > > + > > + for_each_pci_dev(pdev) { > > + ent = pci_match_id(pci_tbl, pdev); > > + if (ent) { > > + /* Because GPIO Registers only work on Upstream port. */ > > + type = pci_pcie_type(pdev); > > + if (type == PCI_EXP_TYPE_UPSTREAM) { > > + dev_info(&pdev->dev, "ASMEDIA-28xx/18xx Init Upstream detected\n"); > > + goto found; > > + } > > + } > > + } > > + goto out; > > + > > Bjorn: is this approach really correct? It looks very strange to me > and even if we were to do this kind of lookup I'd expect there to be a > real pci device registered as child of pdev here so that we can have a > proper driver in place with probe() et al. No, this is pretty broken. The model is that one PCI device goes with one driver. If there are two bits of functionality associated with a single PCI device, it's up to the single PCI driver to sort that out. The comment above mentions "multiple function device," which may lead to some confusion about the terminology. In the PCI specs, the smallest addressable unit of PCI hardware is the "Function." A "Device" may consist of one or more Functions. A Device with more than one Function is referred to in the spec as a "Multi-Function Device". These PCI Functions are addressed by a (domain, bus, device, function) tuple. For example, my system has these: 0000:00:14.0 Intel USB 3.0 xHCI Controller 0000:00:14.2 Intel Thermal Subsystem These two Functions are parts of the 0000:00:14 Multi-Function Device. In Linux, a "struct pci_dev" refers to a single Function, so there's a pci_dev for 0000:00:14.0 and another for 0000:00:14.2. These are pretty much independent, and can be claimed by two separate drivers. But I think the "multiple function device" comment in *this* patch probably doesn't refer to a "Multi-Function Device" as used in the PCI specs. It probably means a single PCI Function that has two kinds of functionality. In the Linux model, that means the Function should be claimed by a single driver, and that driver is responsible for coordinating the two pieces of functionality. Bjorn
WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <helgaas@kernel.org> To: kbuild-all@lists.01.org Subject: Re: [PATCH] gpio:asm28xx-18xx: new driver Date: Thu, 04 Jun 2020 12:55:15 -0500 [thread overview] Message-ID: <20200604175515.GA1076951@bjorn-Precision-5520> (raw) In-Reply-To: <CAMpxmJX8U-uNYJPQxmkox=YTSvXVPrWss2y5MS81_bg43Co8Lg@mail.gmail.com> [-- Attachment #1: Type: text/plain, Size: 3547 bytes --] On Thu, Jun 04, 2020 at 01:54:21PM +0200, Bartosz Golaszewski wrote: > czw., 4 cze 2020 o 09:33 Richard Hsu <saraon640529@gmail.com> napisał(a): > > > > Hi Linus Walleij,Bartosz Golaszewski and kbuild test robot, > > I have fixed the warnings(make W=1 ARCH=i386) by replace two functions > > with static type,and resend the patch. > > line 69: > > <<void pci_config_pm_runtime_get(struct pci_dev *pdev) > > >>static void pci_config_pm_runtime_get(struct pci_dev *pdev) > > line 91: > > <<void pci_config_pm_runtime_put(struct pci_dev *pdev) > > >>static void pci_config_pm_runtime_put(struct pci_dev *pdev) > > > > Thanks > > > > BR, > > Richard > > Signed-off-by: Richard Hsu <saraon640529@gmail.com> > > + /* We look for our device - Asmedia 28XX and 18XX Bridge > > + * I don't know about a system with two such bridges, > > + * so we can assume that there is max. one device. > > + * > > + * We can't use plain pci_driver mechanism, > > + * as the device is really a multiple function device, > > + * main driver that binds to the pci_device is an bus > > + * driver and have to find & bind to the device this way. > > + */ > > + > > + for_each_pci_dev(pdev) { > > + ent = pci_match_id(pci_tbl, pdev); > > + if (ent) { > > + /* Because GPIO Registers only work on Upstream port. */ > > + type = pci_pcie_type(pdev); > > + if (type == PCI_EXP_TYPE_UPSTREAM) { > > + dev_info(&pdev->dev, "ASMEDIA-28xx/18xx Init Upstream detected\n"); > > + goto found; > > + } > > + } > > + } > > + goto out; > > + > > Bjorn: is this approach really correct? It looks very strange to me > and even if we were to do this kind of lookup I'd expect there to be a > real pci device registered as child of pdev here so that we can have a > proper driver in place with probe() et al. No, this is pretty broken. The model is that one PCI device goes with one driver. If there are two bits of functionality associated with a single PCI device, it's up to the single PCI driver to sort that out. The comment above mentions "multiple function device," which may lead to some confusion about the terminology. In the PCI specs, the smallest addressable unit of PCI hardware is the "Function." A "Device" may consist of one or more Functions. A Device with more than one Function is referred to in the spec as a "Multi-Function Device". These PCI Functions are addressed by a (domain, bus, device, function) tuple. For example, my system has these: 0000:00:14.0 Intel USB 3.0 xHCI Controller 0000:00:14.2 Intel Thermal Subsystem These two Functions are parts of the 0000:00:14 Multi-Function Device. In Linux, a "struct pci_dev" refers to a single Function, so there's a pci_dev for 0000:00:14.0 and another for 0000:00:14.2. These are pretty much independent, and can be claimed by two separate drivers. But I think the "multiple function device" comment in *this* patch probably doesn't refer to a "Multi-Function Device" as used in the PCI specs. It probably means a single PCI Function that has two kinds of functionality. In the Linux model, that means the Function should be claimed by a single driver, and that driver is responsible for coordinating the two pieces of functionality. Bjorn
next prev parent reply other threads:[~2020-06-04 17:55 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-04 7:32 [PATCH] gpio:asm28xx-18xx: new driver Richard Hsu 2020-06-04 11:54 ` Bartosz Golaszewski 2020-06-04 11:54 ` Bartosz Golaszewski 2020-06-04 17:55 ` Bjorn Helgaas [this message] 2020-06-04 17:55 ` Bjorn Helgaas 2020-06-05 7:55 ` Bartosz Golaszewski 2020-06-05 10:02 ` Richard Hsu(許育彰) 2020-06-05 10:13 ` Bartosz Golaszewski 2020-06-05 10:13 ` Bartosz Golaszewski -- strict thread matches above, loose matches on Subject: below -- 2020-06-01 7:36 Richard Hsu 2020-06-01 15:36 ` kbuild test robot 2020-06-01 15:36 ` kbuild test robot 2020-06-05 17:12 ` Bjorn Helgaas 2020-06-08 8:57 ` Richard Hsu(許育彰)
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=20200604175515.GA1076951@bjorn-Precision-5520 \ --to=helgaas@kernel.org \ --cc=Jesse1_Chang@asmedia.com.tw \ --cc=Richard_Hsu@asmedia.com.tw \ --cc=Yd_Tseng@asmedia.com.tw \ --cc=bgolaszewski@baylibre.com \ --cc=bhelgaas@google.com \ --cc=kbuild-all@lists.01.org \ --cc=linus.walleij@linaro.org \ --cc=linux-gpio@vger.kernel.org \ --cc=linux-pci@vger.kernel.org \ --cc=lkp@intel.com \ --cc=saraon640529@gmail.com \ /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: linkBe 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.