bcm27xx: add linux 5.4 support
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0384-pcie-brcmstb-Eliminate-arch_dma_ops-error-message.patch
1 From 27cf0ad95cdf30f52a5fc6c69014a0d7bf5a1222 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Wed, 8 Jan 2020 17:21:09 +0000
4 Subject: [PATCH] pcie-brcmstb: Eliminate arch_dma_ops error message
5
6 The driver attempts to set the dma_ops for the root complex, but doing
7 so causes an error message and only the end points need it. Fix the
8 error by making the code specific to the end point case.
9
10 Also copy some cosmetic tidy-ups from 5.5.y.
11
12 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
13 ---
14 drivers/pci/controller/pcie-brcmstb.c | 43 ++++++++++++++-------------
15 1 file changed, 22 insertions(+), 21 deletions(-)
16
17 --- a/drivers/pci/controller/pcie-brcmstb.c
18 +++ b/drivers/pci/controller/pcie-brcmstb.c
19 @@ -633,16 +633,17 @@ static int brcmstb_platform_notifier(str
20
21 switch (event) {
22 case BUS_NOTIFY_ADD_DEVICE:
23 - if (max_pfn > (bounce_threshold/PAGE_SIZE) &&
24 - strcmp(dev->kobj.name, rc_name)) {
25 -
26 - ret = brcm_pcie_bounce_register_dev(dev);
27 - if (ret) {
28 - dev_err(dev,
29 - "brcm_pcie_bounce_register_dev() failed: %d\n",
30 - ret);
31 - return ret;
32 + if (strcmp(dev->kobj.name, rc_name)) {
33 + if (max_pfn > (bounce_threshold/PAGE_SIZE)) {
34 + ret = brcm_pcie_bounce_register_dev(dev);
35 + if (ret) {
36 + dev_err(dev,
37 + "brcm_pcie_bounce_register_dev() failed: %d\n",
38 + ret);
39 + return ret;
40 + }
41 }
42 + brcm_set_dma_ops(dev);
43 } else if (IS_ENABLED(CONFIG_ARM64)) {
44 ret = of_dma_configure(dev, dev->of_node, true);
45 if (ret) {
46 @@ -650,7 +651,6 @@ static int brcmstb_platform_notifier(str
47 return ret;
48 }
49 }
50 - brcm_set_dma_ops(dev);
51 return NOTIFY_OK;
52
53 case BUS_NOTIFY_DEL_DEVICE:
54 @@ -1685,7 +1685,8 @@ MODULE_DEVICE_TABLE(of, brcm_pcie_match)
55
56 static int brcm_pcie_probe(struct platform_device *pdev)
57 {
58 - struct device_node *dn = pdev->dev.of_node, *msi_dn;
59 + struct device *dev = &pdev->dev;
60 + struct device_node *dn = dev->of_node, *msi_dn;
61 const struct of_device_id *of_id;
62 const struct pcie_cfg_data *data;
63 int ret;
64 @@ -1696,7 +1697,7 @@ static int brcm_pcie_probe(struct platfo
65 struct pci_bus *child;
66 extern unsigned long max_pfn;
67
68 - bridge = devm_pci_alloc_host_bridge(&pdev->dev, sizeof(*pcie));
69 + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
70 if (!bridge)
71 return -ENOMEM;
72
73 @@ -1705,7 +1706,7 @@ static int brcm_pcie_probe(struct platfo
74
75 of_id = of_match_node(brcm_pcie_match, dn);
76 if (!of_id) {
77 - dev_err(&pdev->dev, "failed to look up compatible string\n");
78 + dev_err(dev, "failed to look up compatible string\n");
79 return -EINVAL;
80 }
81
82 @@ -1715,7 +1716,7 @@ static int brcm_pcie_probe(struct platfo
83 pcie->max_burst_size = data->max_burst_size;
84 pcie->type = data->type;
85 pcie->dn = dn;
86 - pcie->dev = &pdev->dev;
87 + pcie->dev = dev;
88
89 /* We use the domain number as our controller number */
90 pcie->id = of_get_pci_domain_nr(dn);
91 @@ -1726,18 +1727,18 @@ static int brcm_pcie_probe(struct platfo
92 if (!res)
93 return -EINVAL;
94
95 - base = devm_ioremap_resource(&pdev->dev, res);
96 + base = devm_ioremap_resource(dev, res);
97 if (IS_ERR(base))
98 return PTR_ERR(base);
99
100 /* To Do: Add hardware check if this ever gets fixed */
101 if (max_pfn > (bounce_threshold/PAGE_SIZE)) {
102 int ret;
103 - ret = brcm_pcie_bounce_init(&pdev->dev, bounce_buffer,
104 + ret = brcm_pcie_bounce_init(dev, bounce_buffer,
105 (dma_addr_t)bounce_threshold);
106 if (ret) {
107 if (ret != -EPROBE_DEFER)
108 - dev_err(&pdev->dev,
109 + dev_err(dev,
110 "could not init bounce buffers: %d\n",
111 ret);
112 return ret;
113 @@ -1746,7 +1747,7 @@ static int brcm_pcie_probe(struct platfo
114
115 pcie->clk = of_clk_get_by_name(dn, "sw_pcie");
116 if (IS_ERR(pcie->clk)) {
117 - dev_warn(&pdev->dev, "could not get clock\n");
118 + dev_warn(dev, "could not get clock\n");
119 pcie->clk = NULL;
120 }
121 pcie->base = base;
122 @@ -1756,7 +1757,7 @@ static int brcm_pcie_probe(struct platfo
123
124 pcie->ssc = of_property_read_bool(dn, "brcm,enable-ssc");
125
126 - ret = irq_of_parse_and_map(pdev->dev.of_node, 0);
127 + ret = irq_of_parse_and_map(dev->of_node, 0);
128 if (ret == 0)
129 /* keep going, as we don't use this intr yet */
130 dev_warn(pcie->dev, "cannot get PCIe interrupt\n");
131 @@ -1770,7 +1771,7 @@ static int brcm_pcie_probe(struct platfo
132 ret = clk_prepare_enable(pcie->clk);
133 if (ret) {
134 if (ret != -EPROBE_DEFER)
135 - dev_err(&pdev->dev, "could not enable clock\n");
136 + dev_err(dev, "could not enable clock\n");
137 return ret;
138 }
139
140 @@ -1797,7 +1798,7 @@ static int brcm_pcie_probe(struct platfo
141 }
142
143 list_splice_init(&pcie->resources, &bridge->windows);
144 - bridge->dev.parent = &pdev->dev;
145 + bridge->dev.parent = dev;
146 bridge->busnr = 0;
147 bridge->ops = &brcm_pcie_ops;
148 bridge->sysdata = pcie;