* [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue @ 2022-02-01 21:59 Bean Huo 2022-02-02 4:00 ` kernel test robot 2022-02-02 16:26 ` Bjorn Helgaas 0 siblings, 2 replies; 7+ messages in thread From: Bean Huo @ 2022-02-01 21:59 UTC (permalink / raw) To: songxiaowei, wangbinghui, lorenzo.pieralisi, robh, kw, bhelgaas, ffclaire1224, linux-pci, linux-kernel Cc: beanhuo From: Bean Huo <beanhuo@micron.com> of_device_get_match_data() will return 'enum pcie_kirin_phy_type' type value, and most likely the return value will be PCIE_KIRIN_INTERNAL_PHY == 0. This will cause the PCI probe to fail. And of_device_get_match_data() does not require error checking on its return on devicetree based platform. So,this patch is to remove unnecessary error checking to fix kirin960-pcie probe failure issue. Fixes: a622435fbe1a ("PCI: kirin: Prefer of_device_get_match_data()") Signed-off-by: Bean Huo <beanhuo@micron.com> --- drivers/pci/controller/dwc/pcie-kirin.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index fa6886d66488..e102aa6efb7f 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -781,12 +781,7 @@ static int kirin_pcie_probe(struct platform_device *pdev) return -EINVAL; } - phy_type = (long)of_device_get_match_data(dev); - if (!phy_type) { - dev_err(dev, "OF data missing\n"); - return -EINVAL; - } - + phy_type = (enum pcie_kirin_phy_type)of_device_get_match_data(dev); kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); if (!kirin_pcie) -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue 2022-02-01 21:59 [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue Bean Huo @ 2022-02-02 4:00 ` kernel test robot 2022-02-02 16:26 ` Bjorn Helgaas 1 sibling, 0 replies; 7+ messages in thread From: kernel test robot @ 2022-02-02 4:00 UTC (permalink / raw) To: Bean Huo, songxiaowei, wangbinghui, lorenzo.pieralisi, robh, kw, bhelgaas, ffclaire1224, linux-pci, linux-kernel Cc: llvm, kbuild-all, beanhuo Hi Bean, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on helgaas-pci/next] [also build test WARNING on v5.17-rc2 next-20220201] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Bean-Huo/PCI-kirin-Fix-kirin960-pcie-probe-failure-issue/20220202-060120 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: riscv-randconfig-r001-20220130 (https://download.01.org/0day-ci/archive/20220202/202202021149.TJc443Qq-lkp@intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6b1e844b69f15bb7dffaf9365cd2b355d2eb7579) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install riscv cross compiling tool for clang build # apt-get install binutils-riscv64-linux-gnu # https://github.com/0day-ci/linux/commit/91a6cc1deb484e0590261edbf304784499ca1784 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Bean-Huo/PCI-kirin-Fix-kirin960-pcie-probe-failure-issue/20220202-060120 git checkout 91a6cc1deb484e0590261edbf304784499ca1784 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/pci/controller/dwc/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/pci/controller/dwc/pcie-kirin.c:784:13: warning: cast to smaller integer type 'enum pcie_kirin_phy_type' from 'const void *' [-Wvoid-pointer-to-enum-cast] phy_type = (enum pcie_kirin_phy_type)of_device_get_match_data(dev); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. vim +784 drivers/pci/controller/dwc/pcie-kirin.c 770 771 static int kirin_pcie_probe(struct platform_device *pdev) 772 { 773 enum pcie_kirin_phy_type phy_type; 774 struct device *dev = &pdev->dev; 775 struct kirin_pcie *kirin_pcie; 776 struct dw_pcie *pci; 777 int ret; 778 779 if (!dev->of_node) { 780 dev_err(dev, "NULL node\n"); 781 return -EINVAL; 782 } 783 > 784 phy_type = (enum pcie_kirin_phy_type)of_device_get_match_data(dev); 785 786 kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); 787 if (!kirin_pcie) 788 return -ENOMEM; 789 790 pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); 791 if (!pci) 792 return -ENOMEM; 793 794 pci->dev = dev; 795 pci->ops = &kirin_dw_pcie_ops; 796 pci->pp.ops = &kirin_pcie_host_ops; 797 kirin_pcie->pci = pci; 798 kirin_pcie->type = phy_type; 799 800 ret = kirin_pcie_get_resource(kirin_pcie, pdev); 801 if (ret) 802 return ret; 803 804 platform_set_drvdata(pdev, kirin_pcie); 805 806 ret = kirin_pcie_power_on(pdev, kirin_pcie); 807 if (ret) 808 return ret; 809 810 return dw_pcie_host_init(&pci->pp); 811 } 812 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue @ 2022-02-02 4:00 ` kernel test robot 0 siblings, 0 replies; 7+ messages in thread From: kernel test robot @ 2022-02-02 4:00 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 3587 bytes --] Hi Bean, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on helgaas-pci/next] [also build test WARNING on v5.17-rc2 next-20220201] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Bean-Huo/PCI-kirin-Fix-kirin960-pcie-probe-failure-issue/20220202-060120 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: riscv-randconfig-r001-20220130 (https://download.01.org/0day-ci/archive/20220202/202202021149.TJc443Qq-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6b1e844b69f15bb7dffaf9365cd2b355d2eb7579) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install riscv cross compiling tool for clang build # apt-get install binutils-riscv64-linux-gnu # https://github.com/0day-ci/linux/commit/91a6cc1deb484e0590261edbf304784499ca1784 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Bean-Huo/PCI-kirin-Fix-kirin960-pcie-probe-failure-issue/20220202-060120 git checkout 91a6cc1deb484e0590261edbf304784499ca1784 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/pci/controller/dwc/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/pci/controller/dwc/pcie-kirin.c:784:13: warning: cast to smaller integer type 'enum pcie_kirin_phy_type' from 'const void *' [-Wvoid-pointer-to-enum-cast] phy_type = (enum pcie_kirin_phy_type)of_device_get_match_data(dev); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. vim +784 drivers/pci/controller/dwc/pcie-kirin.c 770 771 static int kirin_pcie_probe(struct platform_device *pdev) 772 { 773 enum pcie_kirin_phy_type phy_type; 774 struct device *dev = &pdev->dev; 775 struct kirin_pcie *kirin_pcie; 776 struct dw_pcie *pci; 777 int ret; 778 779 if (!dev->of_node) { 780 dev_err(dev, "NULL node\n"); 781 return -EINVAL; 782 } 783 > 784 phy_type = (enum pcie_kirin_phy_type)of_device_get_match_data(dev); 785 786 kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); 787 if (!kirin_pcie) 788 return -ENOMEM; 789 790 pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); 791 if (!pci) 792 return -ENOMEM; 793 794 pci->dev = dev; 795 pci->ops = &kirin_dw_pcie_ops; 796 pci->pp.ops = &kirin_pcie_host_ops; 797 kirin_pcie->pci = pci; 798 kirin_pcie->type = phy_type; 799 800 ret = kirin_pcie_get_resource(kirin_pcie, pdev); 801 if (ret) 802 return ret; 803 804 platform_set_drvdata(pdev, kirin_pcie); 805 806 ret = kirin_pcie_power_on(pdev, kirin_pcie); 807 if (ret) 808 return ret; 809 810 return dw_pcie_host_init(&pci->pp); 811 } 812 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue 2022-02-01 21:59 [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue Bean Huo 2022-02-02 4:00 ` kernel test robot @ 2022-02-02 16:26 ` Bjorn Helgaas 2022-02-02 16:36 ` Bjorn Helgaas ` (2 more replies) 1 sibling, 3 replies; 7+ messages in thread From: Bjorn Helgaas @ 2022-02-02 16:26 UTC (permalink / raw) To: Bean Huo Cc: songxiaowei, wangbinghui, lorenzo.pieralisi, robh, kw, bhelgaas, ffclaire1224, linux-pci, linux-kernel, beanhuo [+cc Fan] If you're fixing a previous commit, please cc the author of that commit. I'd prefer the patch below because it avoids the casts of .data and the of_device_get_match_data() result, it doesn't silently default to PCIE_KIRIN_INTERNAL_PHY if a device without a .data is added, and it's the most common design pattern in drivers/pci/. What do you think? On Tue, Feb 01, 2022 at 10:59:41PM +0100, Bean Huo wrote: > From: Bean Huo <beanhuo@micron.com> > > of_device_get_match_data() will return 'enum pcie_kirin_phy_type' type > value, and most likely the return value will be PCIE_KIRIN_INTERNAL_PHY == 0. > This will cause the PCI probe to fail. And of_device_get_match_data() does not > require error checking on its return on devicetree based platform. > > So,this patch is to remove unnecessary error checking to fix kirin960-pcie > probe failure issue. > > Fixes: a622435fbe1a ("PCI: kirin: Prefer of_device_get_match_data()") > Signed-off-by: Bean Huo <beanhuo@micron.com> > --- > drivers/pci/controller/dwc/pcie-kirin.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c > index fa6886d66488..e102aa6efb7f 100644 > --- a/drivers/pci/controller/dwc/pcie-kirin.c > +++ b/drivers/pci/controller/dwc/pcie-kirin.c > @@ -781,12 +781,7 @@ static int kirin_pcie_probe(struct platform_device *pdev) > return -EINVAL; > } > > - phy_type = (long)of_device_get_match_data(dev); > - if (!phy_type) { > - dev_err(dev, "OF data missing\n"); > - return -EINVAL; > - } > - > + phy_type = (enum pcie_kirin_phy_type)of_device_get_match_data(dev); > > kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); > if (!kirin_pcie) commit 3e21687be135 ("PCI: kirin: Add dev struct for of_device_get_match_data()") Author: Bjorn Helgaas <bhelgaas@google.com> Date: Wed Feb 2 09:52:41 2022 -0600 PCI: kirin: Add dev struct for of_device_get_match_data() a622435fbe1a ("PCI: kirin: Prefer of_device_get_match_data()") broke kirin_pcie_probe() because it assumed match data of 0 was a failure when in fact, it meant the match data was "(void *)PCIE_KIRIN_INTERNAL_PHY". Therefore, probing of "hisilicon,kirin960-pcie" devices failed with -EINVAL and an "OF data missing" message. Add a struct kirin_pcie_data to encode the PHY type. Then the result of of_device_get_match_data() should always be a non-NULL pointer to a struct kirin_pcie_data that contains the PHY type. Fixes: a622435fbe1a ("PCI: kirin: Prefer of_device_get_match_data()") Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index fa6886d66488..0dc4e3395b37 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -756,21 +756,27 @@ static int __exit kirin_pcie_remove(struct platform_device *pdev) return 0; } +struct kirin_pcie_data { + enum pcie_kirin_phy_type phy_type; +}; + +static const struct kirin_pcie_data kirin_960_data = { + .phy_type = PCIE_KIRIN_INTERNAL_PHY; +}; + +static const struct kirin_pcie_data kirin_970_data = { + .phy_type = PCIE_KIRIN_EXTERNAL_PHY; +}; + static const struct of_device_id kirin_pcie_match[] = { - { - .compatible = "hisilicon,kirin960-pcie", - .data = (void *)PCIE_KIRIN_INTERNAL_PHY - }, - { - .compatible = "hisilicon,kirin970-pcie", - .data = (void *)PCIE_KIRIN_EXTERNAL_PHY - }, + { .compatible = "hisilicon,kirin960-pcie", .data = &kirin_960_data }, + { .compatible = "hisilicon,kirin970-pcie", .data = &kirin_970_data }, {}, }; static int kirin_pcie_probe(struct platform_device *pdev) { - enum pcie_kirin_phy_type phy_type; + struct kirin_pcie_data *data; struct device *dev = &pdev->dev; struct kirin_pcie *kirin_pcie; struct dw_pcie *pci; @@ -781,13 +787,12 @@ static int kirin_pcie_probe(struct platform_device *pdev) return -EINVAL; } - phy_type = (long)of_device_get_match_data(dev); - if (!phy_type) { + data = of_device_get_match_data(dev); + if (!data) { dev_err(dev, "OF data missing\n"); return -EINVAL; } - kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); if (!kirin_pcie) return -ENOMEM; @@ -800,7 +805,7 @@ static int kirin_pcie_probe(struct platform_device *pdev) pci->ops = &kirin_dw_pcie_ops; pci->pp.ops = &kirin_pcie_host_ops; kirin_pcie->pci = pci; - kirin_pcie->type = phy_type; + kirin_pcie->type = data->phy_type; ret = kirin_pcie_get_resource(kirin_pcie, pdev); if (ret) ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue 2022-02-02 16:26 ` Bjorn Helgaas @ 2022-02-02 16:36 ` Bjorn Helgaas 2022-02-02 17:18 ` Bean Huo 2022-02-02 21:40 ` Bjorn Helgaas 2 siblings, 0 replies; 7+ messages in thread From: Bjorn Helgaas @ 2022-02-02 16:36 UTC (permalink / raw) To: Bean Huo Cc: songxiaowei, wangbinghui, lorenzo.pieralisi, robh, kw, bhelgaas, ffclaire1224, linux-pci, linux-kernel, beanhuo On Wed, Feb 02, 2022 at 10:26:59AM -0600, Bjorn Helgaas wrote: > [+cc Fan] > > If you're fixing a previous commit, please cc the author of that > commit. Sorry, I missed the fact that you already *did* cc Fan. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue 2022-02-02 16:26 ` Bjorn Helgaas 2022-02-02 16:36 ` Bjorn Helgaas @ 2022-02-02 17:18 ` Bean Huo 2022-02-02 21:40 ` Bjorn Helgaas 2 siblings, 0 replies; 7+ messages in thread From: Bean Huo @ 2022-02-02 17:18 UTC (permalink / raw) To: Bjorn Helgaas Cc: songxiaowei, wangbinghui, lorenzo.pieralisi, robh, kw, bhelgaas, ffclaire1224, linux-pci, linux-kernel, beanhuo On Wed, 2022-02-02 at 10:26 -0600, Bjorn Helgaas wrote: > [+cc Fan] > > If you're fixing a previous commit, please cc the author of that > commit. > > I'd prefer the patch below because it avoids the casts of .data and > the of_device_get_match_data() result, it doesn't silently default to > PCIE_KIRIN_INTERNAL_PHY if a device without a .data is added, and > it's > the most common design pattern in drivers/pci/. > > What do you think? Hi Bjorn, The below change looks good to me. thanks. Bean > > On Tue, Feb 01, 2022 at 10:59:41PM +0100, Bean Huo wrote: > > From: Bean Huo <beanhuo@micron.com> > > > > of_device_get_match_data() will return 'enum pcie_kirin_phy_type' > > type > > value, and most likely the return value will be > > PCIE_KIRIN_INTERNAL_PHY == 0. > > This will cause the PCI probe to fail. And > > of_device_get_match_data() does not > > require error checking on its return on devicetree based platform. > > > > So,this patch is to remove unnecessary error checking to fix > > kirin960-pcie > > probe failure issue. > > > > Fixes: a622435fbe1a ("PCI: kirin: Prefer > > of_device_get_match_data()") > > Signed-off-by: Bean Huo <beanhuo@micron.com> > > --- > > drivers/pci/controller/dwc/pcie-kirin.c | 7 +------ > > 1 file changed, 1 insertion(+), 6 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c > > b/drivers/pci/controller/dwc/pcie-kirin.c > > index fa6886d66488..e102aa6efb7f 100644 > > --- a/drivers/pci/controller/dwc/pcie-kirin.c > > +++ b/drivers/pci/controller/dwc/pcie-kirin.c > > @@ -781,12 +781,7 @@ static int kirin_pcie_probe(struct > > platform_device *pdev) > > return -EINVAL; > > } > > > > - phy_type = (long)of_device_get_match_data(dev); > > - if (!phy_type) { > > - dev_err(dev, "OF data missing\n"); > > - return -EINVAL; > > - } > > - > > + phy_type = (enum > > pcie_kirin_phy_type)of_device_get_match_data(dev); > > > > kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), > > GFP_KERNEL); > > if (!kirin_pcie) > > commit 3e21687be135 ("PCI: kirin: Add dev struct for > of_device_get_match_data()") > Author: Bjorn Helgaas <bhelgaas@google.com> > Date: Wed Feb 2 09:52:41 2022 -0600 > > PCI: kirin: Add dev struct for of_device_get_match_data() > > a622435fbe1a ("PCI: kirin: Prefer of_device_get_match_data()") > broke > kirin_pcie_probe() because it assumed match data of 0 was a > failure when in > fact, it meant the match data was "(void > *)PCIE_KIRIN_INTERNAL_PHY". > > Therefore, probing of "hisilicon,kirin960-pcie" devices failed > with -EINVAL > and an "OF data missing" message. > > Add a struct kirin_pcie_data to encode the PHY type. Then the > result of > of_device_get_match_data() should always be a non-NULL pointer to > a struct > kirin_pcie_data that contains the PHY type. > > Fixes: a622435fbe1a ("PCI: kirin: Prefer > of_device_get_match_data()") > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> > > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c > b/drivers/pci/controller/dwc/pcie-kirin.c > index fa6886d66488..0dc4e3395b37 100644 > --- a/drivers/pci/controller/dwc/pcie-kirin.c > +++ b/drivers/pci/controller/dwc/pcie-kirin.c > @@ -756,21 +756,27 @@ static int __exit kirin_pcie_remove(struct > platform_device *pdev) > return 0; > } > > +struct kirin_pcie_data { > + enum pcie_kirin_phy_type phy_type; > +}; > + > +static const struct kirin_pcie_data kirin_960_data = { > + .phy_type = PCIE_KIRIN_INTERNAL_PHY; > +}; > + > +static const struct kirin_pcie_data kirin_970_data = { > + .phy_type = PCIE_KIRIN_EXTERNAL_PHY; > +}; > + > static const struct of_device_id kirin_pcie_match[] = { > - { > - .compatible = "hisilicon,kirin960-pcie", > - .data = (void *)PCIE_KIRIN_INTERNAL_PHY > - }, > - { > - .compatible = "hisilicon,kirin970-pcie", > - .data = (void *)PCIE_KIRIN_EXTERNAL_PHY > - }, > + { .compatible = "hisilicon,kirin960-pcie", .data = > &kirin_960_data }, > + { .compatible = "hisilicon,kirin970-pcie", .data = > &kirin_970_data }, > {}, > }; > > static int kirin_pcie_probe(struct platform_device *pdev) > { > - enum pcie_kirin_phy_type phy_type; > + struct kirin_pcie_data *data; > struct device *dev = &pdev->dev; > struct kirin_pcie *kirin_pcie; > struct dw_pcie *pci; > @@ -781,13 +787,12 @@ static int kirin_pcie_probe(struct > platform_device *pdev) > return -EINVAL; > } > > - phy_type = (long)of_device_get_match_data(dev); > - if (!phy_type) { > + data = of_device_get_match_data(dev); > + if (!data) { > dev_err(dev, "OF data missing\n"); > return -EINVAL; > } > > - > kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), > GFP_KERNEL); > if (!kirin_pcie) > return -ENOMEM; > @@ -800,7 +805,7 @@ static int kirin_pcie_probe(struct > platform_device *pdev) > pci->ops = &kirin_dw_pcie_ops; > pci->pp.ops = &kirin_pcie_host_ops; > kirin_pcie->pci = pci; > - kirin_pcie->type = phy_type; > + kirin_pcie->type = data->phy_type; > > ret = kirin_pcie_get_resource(kirin_pcie, pdev); > if (ret) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue 2022-02-02 16:26 ` Bjorn Helgaas 2022-02-02 16:36 ` Bjorn Helgaas 2022-02-02 17:18 ` Bean Huo @ 2022-02-02 21:40 ` Bjorn Helgaas 2 siblings, 0 replies; 7+ messages in thread From: Bjorn Helgaas @ 2022-02-02 21:40 UTC (permalink / raw) To: Bean Huo Cc: songxiaowei, wangbinghui, lorenzo.pieralisi, robh, kw, bhelgaas, ffclaire1224, linux-pci, linux-kernel, beanhuo On Wed, Feb 02, 2022 at 10:26:59AM -0600, Bjorn Helgaas wrote: > [+cc Fan] > > If you're fixing a previous commit, please cc the author of that > commit. > > I'd prefer the patch below because it avoids the casts of .data and > the of_device_get_match_data() result, it doesn't silently default to > PCIE_KIRIN_INTERNAL_PHY if a device without a .data is added, and it's > the most common design pattern in drivers/pci/. > > What do you think? > ... > commit 3e21687be135 ("PCI: kirin: Add dev struct for of_device_get_match_data()") > Author: Bjorn Helgaas <bhelgaas@google.com> > Date: Wed Feb 2 09:52:41 2022 -0600 > > PCI: kirin: Add dev struct for of_device_get_match_data() > > a622435fbe1a ("PCI: kirin: Prefer of_device_get_match_data()") broke > kirin_pcie_probe() because it assumed match data of 0 was a failure when in > fact, it meant the match data was "(void *)PCIE_KIRIN_INTERNAL_PHY". > > Therefore, probing of "hisilicon,kirin960-pcie" devices failed with -EINVAL > and an "OF data missing" message. > > Add a struct kirin_pcie_data to encode the PHY type. Then the result of > of_device_get_match_data() should always be a non-NULL pointer to a struct > kirin_pcie_data that contains the PHY type. > > Fixes: a622435fbe1a ("PCI: kirin: Prefer of_device_get_match_data()") > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> I applied this (with the obvious syntax fixes) to for-linus for v5.17. > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c > index fa6886d66488..0dc4e3395b37 100644 > --- a/drivers/pci/controller/dwc/pcie-kirin.c > +++ b/drivers/pci/controller/dwc/pcie-kirin.c > @@ -756,21 +756,27 @@ static int __exit kirin_pcie_remove(struct platform_device *pdev) > return 0; > } > > +struct kirin_pcie_data { > + enum pcie_kirin_phy_type phy_type; > +}; > + > +static const struct kirin_pcie_data kirin_960_data = { > + .phy_type = PCIE_KIRIN_INTERNAL_PHY; > +}; > + > +static const struct kirin_pcie_data kirin_970_data = { > + .phy_type = PCIE_KIRIN_EXTERNAL_PHY; > +}; > + > static const struct of_device_id kirin_pcie_match[] = { > - { > - .compatible = "hisilicon,kirin960-pcie", > - .data = (void *)PCIE_KIRIN_INTERNAL_PHY > - }, > - { > - .compatible = "hisilicon,kirin970-pcie", > - .data = (void *)PCIE_KIRIN_EXTERNAL_PHY > - }, > + { .compatible = "hisilicon,kirin960-pcie", .data = &kirin_960_data }, > + { .compatible = "hisilicon,kirin970-pcie", .data = &kirin_970_data }, > {}, > }; > > static int kirin_pcie_probe(struct platform_device *pdev) > { > - enum pcie_kirin_phy_type phy_type; > + struct kirin_pcie_data *data; > struct device *dev = &pdev->dev; > struct kirin_pcie *kirin_pcie; > struct dw_pcie *pci; > @@ -781,13 +787,12 @@ static int kirin_pcie_probe(struct platform_device *pdev) > return -EINVAL; > } > > - phy_type = (long)of_device_get_match_data(dev); > - if (!phy_type) { > + data = of_device_get_match_data(dev); > + if (!data) { > dev_err(dev, "OF data missing\n"); > return -EINVAL; > } > > - > kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); > if (!kirin_pcie) > return -ENOMEM; > @@ -800,7 +805,7 @@ static int kirin_pcie_probe(struct platform_device *pdev) > pci->ops = &kirin_dw_pcie_ops; > pci->pp.ops = &kirin_pcie_host_ops; > kirin_pcie->pci = pci; > - kirin_pcie->type = phy_type; > + kirin_pcie->type = data->phy_type; > > ret = kirin_pcie_get_resource(kirin_pcie, pdev); > if (ret) ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-02-02 21:40 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-02-01 21:59 [PATCH] PCI: kirin: Fix kirin960-pcie probe failure issue Bean Huo 2022-02-02 4:00 ` kernel test robot 2022-02-02 4:00 ` kernel test robot 2022-02-02 16:26 ` Bjorn Helgaas 2022-02-02 16:36 ` Bjorn Helgaas 2022-02-02 17:18 ` Bean Huo 2022-02-02 21:40 ` Bjorn Helgaas
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.