Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pci-v5.17-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull pci fixes from Bjorn Helgaas:

- Restructure j721e_pcie_probe() so we don't dereference a NULL pointer
(Bjorn Helgaas)

- Add a kirin_pcie_data struct to identify different Kirin variants to
fix probe failure for controllers with an internal PHY (Bjorn
Helgaas)

* tag 'pci-v5.17-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
PCI: kirin: Add dev struct for of_device_get_match_data()
PCI: j721e: Initialize pcie->cdns_pcie before using it

+60 -56
+42 -43
drivers/pci/controller/cadence/pci-j721e.c
··· 356 356 const struct j721e_pcie_data *data; 357 357 struct cdns_pcie *cdns_pcie; 358 358 struct j721e_pcie *pcie; 359 - struct cdns_pcie_rc *rc; 360 - struct cdns_pcie_ep *ep; 359 + struct cdns_pcie_rc *rc = NULL; 360 + struct cdns_pcie_ep *ep = NULL; 361 361 struct gpio_desc *gpiod; 362 362 void __iomem *base; 363 363 struct clk *clk; ··· 375 375 pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); 376 376 if (!pcie) 377 377 return -ENOMEM; 378 + 379 + switch (mode) { 380 + case PCI_MODE_RC: 381 + if (!IS_ENABLED(CONFIG_PCIE_CADENCE_HOST)) 382 + return -ENODEV; 383 + 384 + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rc)); 385 + if (!bridge) 386 + return -ENOMEM; 387 + 388 + if (!data->byte_access_allowed) 389 + bridge->ops = &cdns_ti_pcie_host_ops; 390 + rc = pci_host_bridge_priv(bridge); 391 + rc->quirk_retrain_flag = data->quirk_retrain_flag; 392 + rc->quirk_detect_quiet_flag = data->quirk_detect_quiet_flag; 393 + 394 + cdns_pcie = &rc->pcie; 395 + cdns_pcie->dev = dev; 396 + cdns_pcie->ops = &j721e_pcie_ops; 397 + pcie->cdns_pcie = cdns_pcie; 398 + break; 399 + case PCI_MODE_EP: 400 + if (!IS_ENABLED(CONFIG_PCIE_CADENCE_EP)) 401 + return -ENODEV; 402 + 403 + ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL); 404 + if (!ep) 405 + return -ENOMEM; 406 + 407 + ep->quirk_detect_quiet_flag = data->quirk_detect_quiet_flag; 408 + 409 + cdns_pcie = &ep->pcie; 410 + cdns_pcie->dev = dev; 411 + cdns_pcie->ops = &j721e_pcie_ops; 412 + pcie->cdns_pcie = cdns_pcie; 413 + break; 414 + default: 415 + dev_err(dev, "INVALID device type %d\n", mode); 416 + return 0; 417 + } 378 418 379 419 pcie->mode = mode; 380 420 pcie->linkdown_irq_regfield = data->linkdown_irq_regfield; ··· 466 426 467 427 switch (mode) { 468 428 case PCI_MODE_RC: 469 - if (!IS_ENABLED(CONFIG_PCIE_CADENCE_HOST)) { 470 - ret = -ENODEV; 471 - goto err_get_sync; 472 - } 473 - 474 - bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rc)); 475 - if (!bridge) { 476 - ret = -ENOMEM; 477 - goto err_get_sync; 478 - } 479 - 480 - if (!data->byte_access_allowed) 481 - bridge->ops = &cdns_ti_pcie_host_ops; 482 - rc = pci_host_bridge_priv(bridge); 483 - rc->quirk_retrain_flag = data->quirk_retrain_flag; 484 - rc->quirk_detect_quiet_flag = data->quirk_detect_quiet_flag; 485 - 486 - cdns_pcie = &rc->pcie; 487 - cdns_pcie->dev = dev; 488 - cdns_pcie->ops = &j721e_pcie_ops; 489 - pcie->cdns_pcie = cdns_pcie; 490 - 491 429 gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); 492 430 if (IS_ERR(gpiod)) { 493 431 ret = PTR_ERR(gpiod); ··· 515 497 516 498 break; 517 499 case PCI_MODE_EP: 518 - if (!IS_ENABLED(CONFIG_PCIE_CADENCE_EP)) { 519 - ret = -ENODEV; 520 - goto err_get_sync; 521 - } 522 - 523 - ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL); 524 - if (!ep) { 525 - ret = -ENOMEM; 526 - goto err_get_sync; 527 - } 528 - ep->quirk_detect_quiet_flag = data->quirk_detect_quiet_flag; 529 - 530 - cdns_pcie = &ep->pcie; 531 - cdns_pcie->dev = dev; 532 - cdns_pcie->ops = &j721e_pcie_ops; 533 - pcie->cdns_pcie = cdns_pcie; 534 - 535 500 ret = cdns_pcie_init_phy(dev, cdns_pcie); 536 501 if (ret) { 537 502 dev_err(dev, "Failed to init phy\n"); ··· 526 525 goto err_pcie_setup; 527 526 528 527 break; 529 - default: 530 - dev_err(dev, "INVALID device type %d\n", mode); 531 528 } 532 529 533 530 return 0;
+18 -13
drivers/pci/controller/dwc/pcie-kirin.c
··· 756 756 return 0; 757 757 } 758 758 759 + struct kirin_pcie_data { 760 + enum pcie_kirin_phy_type phy_type; 761 + }; 762 + 763 + static const struct kirin_pcie_data kirin_960_data = { 764 + .phy_type = PCIE_KIRIN_INTERNAL_PHY, 765 + }; 766 + 767 + static const struct kirin_pcie_data kirin_970_data = { 768 + .phy_type = PCIE_KIRIN_EXTERNAL_PHY, 769 + }; 770 + 759 771 static const struct of_device_id kirin_pcie_match[] = { 760 - { 761 - .compatible = "hisilicon,kirin960-pcie", 762 - .data = (void *)PCIE_KIRIN_INTERNAL_PHY 763 - }, 764 - { 765 - .compatible = "hisilicon,kirin970-pcie", 766 - .data = (void *)PCIE_KIRIN_EXTERNAL_PHY 767 - }, 772 + { .compatible = "hisilicon,kirin960-pcie", .data = &kirin_960_data }, 773 + { .compatible = "hisilicon,kirin970-pcie", .data = &kirin_970_data }, 768 774 {}, 769 775 }; 770 776 771 777 static int kirin_pcie_probe(struct platform_device *pdev) 772 778 { 773 - enum pcie_kirin_phy_type phy_type; 774 779 struct device *dev = &pdev->dev; 780 + const struct kirin_pcie_data *data; 775 781 struct kirin_pcie *kirin_pcie; 776 782 struct dw_pcie *pci; 777 783 int ret; ··· 787 781 return -EINVAL; 788 782 } 789 783 790 - phy_type = (long)of_device_get_match_data(dev); 791 - if (!phy_type) { 784 + data = of_device_get_match_data(dev); 785 + if (!data) { 792 786 dev_err(dev, "OF data missing\n"); 793 787 return -EINVAL; 794 788 } 795 - 796 789 797 790 kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); 798 791 if (!kirin_pcie) ··· 805 800 pci->ops = &kirin_dw_pcie_ops; 806 801 pci->pp.ops = &kirin_pcie_host_ops; 807 802 kirin_pcie->pci = pci; 808 - kirin_pcie->type = phy_type; 803 + kirin_pcie->type = data->phy_type; 809 804 810 805 ret = kirin_pcie_get_resource(kirin_pcie, pdev); 811 806 if (ret)