diff options
Diffstat (limited to 'drivers/pci/endpoint/functions/pci-epf-test.c')
-rw-r--r-- | drivers/pci/endpoint/functions/pci-epf-test.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index f9308c2f22e6..64d8a17f8094 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c | |||
@@ -1,20 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /** | 2 | /** |
2 | * Test driver to test endpoint functionality | 3 | * Test driver to test endpoint functionality |
3 | * | 4 | * |
4 | * Copyright (C) 2017 Texas Instruments | 5 | * Copyright (C) 2017 Texas Instruments |
5 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 7 | */ |
19 | 8 | ||
20 | #include <linux/crc32.h> | 9 | #include <linux/crc32.h> |
@@ -104,7 +93,8 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) | |||
104 | goto err; | 93 | goto err; |
105 | } | 94 | } |
106 | 95 | ||
107 | ret = pci_epc_map_addr(epc, src_phys_addr, reg->src_addr, reg->size); | 96 | ret = pci_epc_map_addr(epc, epf->func_no, src_phys_addr, reg->src_addr, |
97 | reg->size); | ||
108 | if (ret) { | 98 | if (ret) { |
109 | dev_err(dev, "failed to map source address\n"); | 99 | dev_err(dev, "failed to map source address\n"); |
110 | reg->status = STATUS_SRC_ADDR_INVALID; | 100 | reg->status = STATUS_SRC_ADDR_INVALID; |
@@ -119,7 +109,8 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) | |||
119 | goto err_src_map_addr; | 109 | goto err_src_map_addr; |
120 | } | 110 | } |
121 | 111 | ||
122 | ret = pci_epc_map_addr(epc, dst_phys_addr, reg->dst_addr, reg->size); | 112 | ret = pci_epc_map_addr(epc, epf->func_no, dst_phys_addr, reg->dst_addr, |
113 | reg->size); | ||
123 | if (ret) { | 114 | if (ret) { |
124 | dev_err(dev, "failed to map destination address\n"); | 115 | dev_err(dev, "failed to map destination address\n"); |
125 | reg->status = STATUS_DST_ADDR_INVALID; | 116 | reg->status = STATUS_DST_ADDR_INVALID; |
@@ -128,13 +119,13 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) | |||
128 | 119 | ||
129 | memcpy(dst_addr, src_addr, reg->size); | 120 | memcpy(dst_addr, src_addr, reg->size); |
130 | 121 | ||
131 | pci_epc_unmap_addr(epc, dst_phys_addr); | 122 | pci_epc_unmap_addr(epc, epf->func_no, dst_phys_addr); |
132 | 123 | ||
133 | err_dst_addr: | 124 | err_dst_addr: |
134 | pci_epc_mem_free_addr(epc, dst_phys_addr, dst_addr, reg->size); | 125 | pci_epc_mem_free_addr(epc, dst_phys_addr, dst_addr, reg->size); |
135 | 126 | ||
136 | err_src_map_addr: | 127 | err_src_map_addr: |
137 | pci_epc_unmap_addr(epc, src_phys_addr); | 128 | pci_epc_unmap_addr(epc, epf->func_no, src_phys_addr); |
138 | 129 | ||
139 | err_src_addr: | 130 | err_src_addr: |
140 | pci_epc_mem_free_addr(epc, src_phys_addr, src_addr, reg->size); | 131 | pci_epc_mem_free_addr(epc, src_phys_addr, src_addr, reg->size); |
@@ -164,7 +155,8 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) | |||
164 | goto err; | 155 | goto err; |
165 | } | 156 | } |
166 | 157 | ||
167 | ret = pci_epc_map_addr(epc, phys_addr, reg->src_addr, reg->size); | 158 | ret = pci_epc_map_addr(epc, epf->func_no, phys_addr, reg->src_addr, |
159 | reg->size); | ||
168 | if (ret) { | 160 | if (ret) { |
169 | dev_err(dev, "failed to map address\n"); | 161 | dev_err(dev, "failed to map address\n"); |
170 | reg->status = STATUS_SRC_ADDR_INVALID; | 162 | reg->status = STATUS_SRC_ADDR_INVALID; |
@@ -186,7 +178,7 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) | |||
186 | kfree(buf); | 178 | kfree(buf); |
187 | 179 | ||
188 | err_map_addr: | 180 | err_map_addr: |
189 | pci_epc_unmap_addr(epc, phys_addr); | 181 | pci_epc_unmap_addr(epc, epf->func_no, phys_addr); |
190 | 182 | ||
191 | err_addr: | 183 | err_addr: |
192 | pci_epc_mem_free_addr(epc, phys_addr, src_addr, reg->size); | 184 | pci_epc_mem_free_addr(epc, phys_addr, src_addr, reg->size); |
@@ -215,7 +207,8 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) | |||
215 | goto err; | 207 | goto err; |
216 | } | 208 | } |
217 | 209 | ||
218 | ret = pci_epc_map_addr(epc, phys_addr, reg->dst_addr, reg->size); | 210 | ret = pci_epc_map_addr(epc, epf->func_no, phys_addr, reg->dst_addr, |
211 | reg->size); | ||
219 | if (ret) { | 212 | if (ret) { |
220 | dev_err(dev, "failed to map address\n"); | 213 | dev_err(dev, "failed to map address\n"); |
221 | reg->status = STATUS_DST_ADDR_INVALID; | 214 | reg->status = STATUS_DST_ADDR_INVALID; |
@@ -242,7 +235,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) | |||
242 | kfree(buf); | 235 | kfree(buf); |
243 | 236 | ||
244 | err_map_addr: | 237 | err_map_addr: |
245 | pci_epc_unmap_addr(epc, phys_addr); | 238 | pci_epc_unmap_addr(epc, epf->func_no, phys_addr); |
246 | 239 | ||
247 | err_addr: | 240 | err_addr: |
248 | pci_epc_mem_free_addr(epc, phys_addr, dst_addr, reg->size); | 241 | pci_epc_mem_free_addr(epc, phys_addr, dst_addr, reg->size); |
@@ -260,11 +253,11 @@ static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, u8 irq) | |||
260 | struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; | 253 | struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; |
261 | 254 | ||
262 | reg->status |= STATUS_IRQ_RAISED; | 255 | reg->status |= STATUS_IRQ_RAISED; |
263 | msi_count = pci_epc_get_msi(epc); | 256 | msi_count = pci_epc_get_msi(epc, epf->func_no); |
264 | if (irq > msi_count || msi_count <= 0) | 257 | if (irq > msi_count || msi_count <= 0) |
265 | pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); | 258 | pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_LEGACY, 0); |
266 | else | 259 | else |
267 | pci_epc_raise_irq(epc, PCI_EPC_IRQ_MSI, irq); | 260 | pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_MSI, irq); |
268 | } | 261 | } |
269 | 262 | ||
270 | static void pci_epf_test_cmd_handler(struct work_struct *work) | 263 | static void pci_epf_test_cmd_handler(struct work_struct *work) |
@@ -291,7 +284,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) | |||
291 | 284 | ||
292 | if (command & COMMAND_RAISE_LEGACY_IRQ) { | 285 | if (command & COMMAND_RAISE_LEGACY_IRQ) { |
293 | reg->status = STATUS_IRQ_RAISED; | 286 | reg->status = STATUS_IRQ_RAISED; |
294 | pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); | 287 | pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_LEGACY, 0); |
295 | goto reset_handler; | 288 | goto reset_handler; |
296 | } | 289 | } |
297 | 290 | ||
@@ -326,11 +319,11 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) | |||
326 | } | 319 | } |
327 | 320 | ||
328 | if (command & COMMAND_RAISE_MSI_IRQ) { | 321 | if (command & COMMAND_RAISE_MSI_IRQ) { |
329 | msi_count = pci_epc_get_msi(epc); | 322 | msi_count = pci_epc_get_msi(epc, epf->func_no); |
330 | if (irq > msi_count || msi_count <= 0) | 323 | if (irq > msi_count || msi_count <= 0) |
331 | goto reset_handler; | 324 | goto reset_handler; |
332 | reg->status = STATUS_IRQ_RAISED; | 325 | reg->status = STATUS_IRQ_RAISED; |
333 | pci_epc_raise_irq(epc, PCI_EPC_IRQ_MSI, irq); | 326 | pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_MSI, irq); |
334 | goto reset_handler; | 327 | goto reset_handler; |
335 | } | 328 | } |
336 | 329 | ||
@@ -358,7 +351,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf) | |||
358 | for (bar = BAR_0; bar <= BAR_5; bar++) { | 351 | for (bar = BAR_0; bar <= BAR_5; bar++) { |
359 | if (epf_test->reg[bar]) { | 352 | if (epf_test->reg[bar]) { |
360 | pci_epf_free_space(epf, epf_test->reg[bar], bar); | 353 | pci_epf_free_space(epf, epf_test->reg[bar], bar); |
361 | pci_epc_clear_bar(epc, bar); | 354 | pci_epc_clear_bar(epc, epf->func_no, bar); |
362 | } | 355 | } |
363 | } | 356 | } |
364 | } | 357 | } |
@@ -380,7 +373,8 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) | |||
380 | 373 | ||
381 | for (bar = BAR_0; bar <= BAR_5; bar++) { | 374 | for (bar = BAR_0; bar <= BAR_5; bar++) { |
382 | epf_bar = &epf->bar[bar]; | 375 | epf_bar = &epf->bar[bar]; |
383 | ret = pci_epc_set_bar(epc, bar, epf_bar->phys_addr, | 376 | ret = pci_epc_set_bar(epc, epf->func_no, bar, |
377 | epf_bar->phys_addr, | ||
384 | epf_bar->size, flags); | 378 | epf_bar->size, flags); |
385 | if (ret) { | 379 | if (ret) { |
386 | pci_epf_free_space(epf, epf_test->reg[bar], bar); | 380 | pci_epf_free_space(epf, epf_test->reg[bar], bar); |
@@ -433,7 +427,7 @@ static int pci_epf_test_bind(struct pci_epf *epf) | |||
433 | if (WARN_ON_ONCE(!epc)) | 427 | if (WARN_ON_ONCE(!epc)) |
434 | return -EINVAL; | 428 | return -EINVAL; |
435 | 429 | ||
436 | ret = pci_epc_write_header(epc, header); | 430 | ret = pci_epc_write_header(epc, epf->func_no, header); |
437 | if (ret) { | 431 | if (ret) { |
438 | dev_err(dev, "configuration header write failed\n"); | 432 | dev_err(dev, "configuration header write failed\n"); |
439 | return ret; | 433 | return ret; |
@@ -447,7 +441,7 @@ static int pci_epf_test_bind(struct pci_epf *epf) | |||
447 | if (ret) | 441 | if (ret) |
448 | return ret; | 442 | return ret; |
449 | 443 | ||
450 | ret = pci_epc_set_msi(epc, epf->msi_interrupts); | 444 | ret = pci_epc_set_msi(epc, epf->func_no, epf->msi_interrupts); |
451 | if (ret) | 445 | if (ret) |
452 | return ret; | 446 | return ret; |
453 | 447 | ||