Thomas Gleixner | 6b1baef | 2019-05-29 16:57:55 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 2 | /** |
| 3 | * Host side test driver to test endpoint functionality |
| 4 | * |
| 5 | * Copyright (C) 2017 Texas Instruments |
| 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/crc32.h> |
| 10 | #include <linux/delay.h> |
| 11 | #include <linux/fs.h> |
| 12 | #include <linux/io.h> |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/irq.h> |
| 15 | #include <linux/miscdevice.h> |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/mutex.h> |
| 18 | #include <linux/random.h> |
| 19 | #include <linux/slab.h> |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 20 | #include <linux/uaccess.h> |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 21 | #include <linux/pci.h> |
| 22 | #include <linux/pci_ids.h> |
| 23 | |
| 24 | #include <linux/pci_regs.h> |
| 25 | |
| 26 | #include <uapi/linux/pcitest.h> |
| 27 | |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 28 | #define DRV_MODULE_NAME "pci-endpoint-test" |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 29 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 30 | #define IRQ_TYPE_UNDEFINED -1 |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 31 | #define IRQ_TYPE_LEGACY 0 |
| 32 | #define IRQ_TYPE_MSI 1 |
Gustavo Pimentel | c2e00e3 | 2018-07-19 10:32:19 +0200 | [diff] [blame] | 33 | #define IRQ_TYPE_MSIX 2 |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 34 | |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 35 | #define PCI_ENDPOINT_TEST_MAGIC 0x0 |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 36 | |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 37 | #define PCI_ENDPOINT_TEST_COMMAND 0x4 |
| 38 | #define COMMAND_RAISE_LEGACY_IRQ BIT(0) |
| 39 | #define COMMAND_RAISE_MSI_IRQ BIT(1) |
Gustavo Pimentel | c2e00e3 | 2018-07-19 10:32:19 +0200 | [diff] [blame] | 40 | #define COMMAND_RAISE_MSIX_IRQ BIT(2) |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 41 | #define COMMAND_READ BIT(3) |
| 42 | #define COMMAND_WRITE BIT(4) |
| 43 | #define COMMAND_COPY BIT(5) |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 44 | |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 45 | #define PCI_ENDPOINT_TEST_STATUS 0x8 |
| 46 | #define STATUS_READ_SUCCESS BIT(0) |
| 47 | #define STATUS_READ_FAIL BIT(1) |
| 48 | #define STATUS_WRITE_SUCCESS BIT(2) |
| 49 | #define STATUS_WRITE_FAIL BIT(3) |
| 50 | #define STATUS_COPY_SUCCESS BIT(4) |
| 51 | #define STATUS_COPY_FAIL BIT(5) |
| 52 | #define STATUS_IRQ_RAISED BIT(6) |
| 53 | #define STATUS_SRC_ADDR_INVALID BIT(7) |
| 54 | #define STATUS_DST_ADDR_INVALID BIT(8) |
| 55 | |
| 56 | #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 57 | #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10 |
| 58 | |
| 59 | #define PCI_ENDPOINT_TEST_LOWER_DST_ADDR 0x14 |
| 60 | #define PCI_ENDPOINT_TEST_UPPER_DST_ADDR 0x18 |
| 61 | |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 62 | #define PCI_ENDPOINT_TEST_SIZE 0x1c |
| 63 | #define PCI_ENDPOINT_TEST_CHECKSUM 0x20 |
| 64 | |
| 65 | #define PCI_ENDPOINT_TEST_IRQ_TYPE 0x24 |
| 66 | #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 67 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 68 | #define PCI_ENDPOINT_TEST_FLAGS 0x2c |
| 69 | #define FLAG_USE_DMA BIT(0) |
| 70 | |
Kishon Vijay Abraham I | 5bb04b1 | 2019-03-25 15:09:46 +0530 | [diff] [blame] | 71 | #define PCI_DEVICE_ID_TI_AM654 0xb00c |
| 72 | |
| 73 | #define is_am654_pci_dev(pdev) \ |
| 74 | ((pdev)->device == PCI_DEVICE_ID_TI_AM654) |
| 75 | |
Lad Prabhakar | b03025c | 2020-05-14 23:03:29 +0100 | [diff] [blame] | 76 | #define PCI_DEVICE_ID_RENESAS_R8A774C0 0x002d |
| 77 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 78 | static DEFINE_IDA(pci_endpoint_test_ida); |
| 79 | |
| 80 | #define to_endpoint_test(priv) container_of((priv), struct pci_endpoint_test, \ |
| 81 | miscdev) |
Kishon Vijay Abraham I | 0c8a5f9 | 2017-08-18 20:28:09 +0530 | [diff] [blame] | 82 | |
| 83 | static bool no_msi; |
| 84 | module_param(no_msi, bool, 0444); |
| 85 | MODULE_PARM_DESC(no_msi, "Disable MSI interrupt in pci_endpoint_test"); |
| 86 | |
Gustavo Pimentel | 9133e39 | 2018-07-19 10:32:18 +0200 | [diff] [blame] | 87 | static int irq_type = IRQ_TYPE_MSI; |
| 88 | module_param(irq_type, int, 0444); |
Gustavo Pimentel | c2e00e3 | 2018-07-19 10:32:19 +0200 | [diff] [blame] | 89 | MODULE_PARM_DESC(irq_type, "IRQ mode selection in pci_endpoint_test (0 - Legacy, 1 - MSI, 2 - MSI-X)"); |
Gustavo Pimentel | 9133e39 | 2018-07-19 10:32:18 +0200 | [diff] [blame] | 90 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 91 | enum pci_barno { |
| 92 | BAR_0, |
| 93 | BAR_1, |
| 94 | BAR_2, |
| 95 | BAR_3, |
| 96 | BAR_4, |
| 97 | BAR_5, |
| 98 | }; |
| 99 | |
| 100 | struct pci_endpoint_test { |
| 101 | struct pci_dev *pdev; |
| 102 | void __iomem *base; |
Denis Efremov | c9c13ba | 2019-09-28 02:43:08 +0300 | [diff] [blame] | 103 | void __iomem *bar[PCI_STD_NUM_BARS]; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 104 | struct completion irq_raised; |
| 105 | int last_irq; |
Kishon Vijay Abraham I | b7636e8 | 2017-10-11 14:14:38 +0530 | [diff] [blame] | 106 | int num_irqs; |
Kishon Vijay Abraham I | b2ba922 | 2020-03-17 15:31:54 +0530 | [diff] [blame] | 107 | int irq_type; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 108 | /* mutex to protect the ioctls */ |
| 109 | struct mutex mutex; |
| 110 | struct miscdevice miscdev; |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 111 | enum pci_barno test_reg_bar; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 112 | size_t alignment; |
Kishon Vijay Abraham I | c2be14a | 2020-03-17 15:31:58 +0530 | [diff] [blame] | 113 | const char *name; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 114 | }; |
| 115 | |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 116 | struct pci_endpoint_test_data { |
| 117 | enum pci_barno test_reg_bar; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 118 | size_t alignment; |
Gustavo Pimentel | 9133e39 | 2018-07-19 10:32:18 +0200 | [diff] [blame] | 119 | int irq_type; |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 120 | }; |
| 121 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 122 | static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test, |
| 123 | u32 offset) |
| 124 | { |
| 125 | return readl(test->base + offset); |
| 126 | } |
| 127 | |
| 128 | static inline void pci_endpoint_test_writel(struct pci_endpoint_test *test, |
| 129 | u32 offset, u32 value) |
| 130 | { |
| 131 | writel(value, test->base + offset); |
| 132 | } |
| 133 | |
| 134 | static inline u32 pci_endpoint_test_bar_readl(struct pci_endpoint_test *test, |
| 135 | int bar, int offset) |
| 136 | { |
| 137 | return readl(test->bar[bar] + offset); |
| 138 | } |
| 139 | |
| 140 | static inline void pci_endpoint_test_bar_writel(struct pci_endpoint_test *test, |
| 141 | int bar, u32 offset, u32 value) |
| 142 | { |
| 143 | writel(value, test->bar[bar] + offset); |
| 144 | } |
| 145 | |
| 146 | static irqreturn_t pci_endpoint_test_irqhandler(int irq, void *dev_id) |
| 147 | { |
| 148 | struct pci_endpoint_test *test = dev_id; |
| 149 | u32 reg; |
| 150 | |
| 151 | reg = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); |
| 152 | if (reg & STATUS_IRQ_RAISED) { |
| 153 | test->last_irq = irq; |
| 154 | complete(&test->irq_raised); |
| 155 | reg &= ~STATUS_IRQ_RAISED; |
| 156 | } |
| 157 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_STATUS, |
| 158 | reg); |
| 159 | |
| 160 | return IRQ_HANDLED; |
| 161 | } |
| 162 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 163 | static void pci_endpoint_test_free_irq_vectors(struct pci_endpoint_test *test) |
| 164 | { |
| 165 | struct pci_dev *pdev = test->pdev; |
| 166 | |
| 167 | pci_free_irq_vectors(pdev); |
Kishon Vijay Abraham I | b2ba922 | 2020-03-17 15:31:54 +0530 | [diff] [blame] | 168 | test->irq_type = IRQ_TYPE_UNDEFINED; |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static bool pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *test, |
| 172 | int type) |
| 173 | { |
| 174 | int irq = -1; |
| 175 | struct pci_dev *pdev = test->pdev; |
| 176 | struct device *dev = &pdev->dev; |
| 177 | bool res = true; |
| 178 | |
| 179 | switch (type) { |
| 180 | case IRQ_TYPE_LEGACY: |
| 181 | irq = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY); |
| 182 | if (irq < 0) |
| 183 | dev_err(dev, "Failed to get Legacy interrupt\n"); |
| 184 | break; |
| 185 | case IRQ_TYPE_MSI: |
| 186 | irq = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI); |
| 187 | if (irq < 0) |
| 188 | dev_err(dev, "Failed to get MSI interrupts\n"); |
| 189 | break; |
| 190 | case IRQ_TYPE_MSIX: |
| 191 | irq = pci_alloc_irq_vectors(pdev, 1, 2048, PCI_IRQ_MSIX); |
| 192 | if (irq < 0) |
| 193 | dev_err(dev, "Failed to get MSI-X interrupts\n"); |
| 194 | break; |
| 195 | default: |
| 196 | dev_err(dev, "Invalid IRQ type selected\n"); |
| 197 | } |
| 198 | |
| 199 | if (irq < 0) { |
| 200 | irq = 0; |
| 201 | res = false; |
| 202 | } |
Kishon Vijay Abraham I | b2ba922 | 2020-03-17 15:31:54 +0530 | [diff] [blame] | 203 | |
| 204 | test->irq_type = type; |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 205 | test->num_irqs = irq; |
| 206 | |
| 207 | return res; |
| 208 | } |
| 209 | |
| 210 | static void pci_endpoint_test_release_irq(struct pci_endpoint_test *test) |
| 211 | { |
| 212 | int i; |
| 213 | struct pci_dev *pdev = test->pdev; |
| 214 | struct device *dev = &pdev->dev; |
| 215 | |
| 216 | for (i = 0; i < test->num_irqs; i++) |
| 217 | devm_free_irq(dev, pci_irq_vector(pdev, i), test); |
| 218 | |
| 219 | test->num_irqs = 0; |
| 220 | } |
| 221 | |
| 222 | static bool pci_endpoint_test_request_irq(struct pci_endpoint_test *test) |
| 223 | { |
| 224 | int i; |
| 225 | int err; |
| 226 | struct pci_dev *pdev = test->pdev; |
| 227 | struct device *dev = &pdev->dev; |
| 228 | |
| 229 | for (i = 0; i < test->num_irqs; i++) { |
| 230 | err = devm_request_irq(dev, pci_irq_vector(pdev, i), |
| 231 | pci_endpoint_test_irqhandler, |
Kishon Vijay Abraham I | c2be14a | 2020-03-17 15:31:58 +0530 | [diff] [blame] | 232 | IRQF_SHARED, test->name, test); |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 233 | if (err) |
| 234 | goto fail; |
| 235 | } |
| 236 | |
| 237 | return true; |
| 238 | |
| 239 | fail: |
| 240 | switch (irq_type) { |
| 241 | case IRQ_TYPE_LEGACY: |
| 242 | dev_err(dev, "Failed to request IRQ %d for Legacy\n", |
| 243 | pci_irq_vector(pdev, i)); |
| 244 | break; |
| 245 | case IRQ_TYPE_MSI: |
| 246 | dev_err(dev, "Failed to request IRQ %d for MSI %d\n", |
| 247 | pci_irq_vector(pdev, i), |
| 248 | i + 1); |
| 249 | break; |
| 250 | case IRQ_TYPE_MSIX: |
| 251 | dev_err(dev, "Failed to request IRQ %d for MSI-X %d\n", |
| 252 | pci_irq_vector(pdev, i), |
| 253 | i + 1); |
| 254 | break; |
| 255 | } |
| 256 | |
| 257 | return false; |
| 258 | } |
| 259 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 260 | static bool pci_endpoint_test_bar(struct pci_endpoint_test *test, |
| 261 | enum pci_barno barno) |
| 262 | { |
| 263 | int j; |
| 264 | u32 val; |
| 265 | int size; |
Kishon Vijay Abraham I | cda370e | 2017-08-18 20:28:08 +0530 | [diff] [blame] | 266 | struct pci_dev *pdev = test->pdev; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 267 | |
| 268 | if (!test->bar[barno]) |
| 269 | return false; |
| 270 | |
Kishon Vijay Abraham I | cda370e | 2017-08-18 20:28:08 +0530 | [diff] [blame] | 271 | size = pci_resource_len(pdev, barno); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 272 | |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 273 | if (barno == test->test_reg_bar) |
| 274 | size = 0x4; |
| 275 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 276 | for (j = 0; j < size; j += 4) |
| 277 | pci_endpoint_test_bar_writel(test, barno, j, 0xA0A0A0A0); |
| 278 | |
| 279 | for (j = 0; j < size; j += 4) { |
| 280 | val = pci_endpoint_test_bar_readl(test, barno, j); |
| 281 | if (val != 0xA0A0A0A0) |
| 282 | return false; |
| 283 | } |
| 284 | |
| 285 | return true; |
| 286 | } |
| 287 | |
| 288 | static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) |
| 289 | { |
| 290 | u32 val; |
| 291 | |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 292 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, |
| 293 | IRQ_TYPE_LEGACY); |
| 294 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 0); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 295 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, |
| 296 | COMMAND_RAISE_LEGACY_IRQ); |
| 297 | val = wait_for_completion_timeout(&test->irq_raised, |
| 298 | msecs_to_jiffies(1000)); |
| 299 | if (!val) |
| 300 | return false; |
| 301 | |
| 302 | return true; |
| 303 | } |
| 304 | |
| 305 | static bool pci_endpoint_test_msi_irq(struct pci_endpoint_test *test, |
Gustavo Pimentel | c2e00e3 | 2018-07-19 10:32:19 +0200 | [diff] [blame] | 306 | u16 msi_num, bool msix) |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 307 | { |
| 308 | u32 val; |
| 309 | struct pci_dev *pdev = test->pdev; |
| 310 | |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 311 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, |
Gustavo Pimentel | c2e00e3 | 2018-07-19 10:32:19 +0200 | [diff] [blame] | 312 | msix == false ? IRQ_TYPE_MSI : |
| 313 | IRQ_TYPE_MSIX); |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 314 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, msi_num); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 315 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, |
Gustavo Pimentel | c2e00e3 | 2018-07-19 10:32:19 +0200 | [diff] [blame] | 316 | msix == false ? COMMAND_RAISE_MSI_IRQ : |
| 317 | COMMAND_RAISE_MSIX_IRQ); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 318 | val = wait_for_completion_timeout(&test->irq_raised, |
| 319 | msecs_to_jiffies(1000)); |
| 320 | if (!val) |
| 321 | return false; |
| 322 | |
Gustavo Pimentel | ecc57ef | 2018-05-14 18:27:48 +0100 | [diff] [blame] | 323 | if (pci_irq_vector(pdev, msi_num - 1) == test->last_irq) |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 324 | return true; |
| 325 | |
| 326 | return false; |
| 327 | } |
| 328 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 329 | static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, |
| 330 | unsigned long arg) |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 331 | { |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 332 | struct pci_endpoint_test_xfer_param param; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 333 | bool ret = false; |
| 334 | void *src_addr; |
| 335 | void *dst_addr; |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 336 | u32 flags = 0; |
| 337 | bool use_dma; |
| 338 | size_t size; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 339 | dma_addr_t src_phys_addr; |
| 340 | dma_addr_t dst_phys_addr; |
| 341 | struct pci_dev *pdev = test->pdev; |
| 342 | struct device *dev = &pdev->dev; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 343 | void *orig_src_addr; |
| 344 | dma_addr_t orig_src_phys_addr; |
| 345 | void *orig_dst_addr; |
| 346 | dma_addr_t orig_dst_phys_addr; |
| 347 | size_t offset; |
| 348 | size_t alignment = test->alignment; |
Kishon Vijay Abraham I | b2ba922 | 2020-03-17 15:31:54 +0530 | [diff] [blame] | 349 | int irq_type = test->irq_type; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 350 | u32 src_crc32; |
| 351 | u32 dst_crc32; |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 352 | int err; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 353 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 354 | err = copy_from_user(¶m, (void __user *)arg, sizeof(param)); |
| 355 | if (err) { |
| 356 | dev_err(dev, "Failed to get transfer param\n"); |
| 357 | return false; |
| 358 | } |
| 359 | |
| 360 | size = param.size; |
Dan Carpenter | 343dc69 | 2017-09-30 11:15:52 +0300 | [diff] [blame] | 361 | if (size > SIZE_MAX - alignment) |
| 362 | goto err; |
| 363 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 364 | use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); |
| 365 | if (use_dma) |
| 366 | flags |= FLAG_USE_DMA; |
| 367 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 368 | if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { |
| 369 | dev_err(dev, "Invalid IRQ type option\n"); |
| 370 | goto err; |
| 371 | } |
| 372 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 373 | orig_src_addr = kzalloc(size + alignment, GFP_KERNEL); |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 374 | if (!orig_src_addr) { |
Gustavo Pimentel | 0e52ea6 | 2018-05-14 17:56:23 +0100 | [diff] [blame] | 375 | dev_err(dev, "Failed to allocate source buffer\n"); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 376 | ret = false; |
| 377 | goto err; |
| 378 | } |
| 379 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 380 | get_random_bytes(orig_src_addr, size + alignment); |
| 381 | orig_src_phys_addr = dma_map_single(dev, orig_src_addr, |
| 382 | size + alignment, DMA_TO_DEVICE); |
| 383 | if (dma_mapping_error(dev, orig_src_phys_addr)) { |
| 384 | dev_err(dev, "failed to map source buffer address\n"); |
| 385 | ret = false; |
| 386 | goto err_src_phys_addr; |
| 387 | } |
| 388 | |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 389 | if (alignment && !IS_ALIGNED(orig_src_phys_addr, alignment)) { |
| 390 | src_phys_addr = PTR_ALIGN(orig_src_phys_addr, alignment); |
| 391 | offset = src_phys_addr - orig_src_phys_addr; |
| 392 | src_addr = orig_src_addr + offset; |
| 393 | } else { |
| 394 | src_phys_addr = orig_src_phys_addr; |
| 395 | src_addr = orig_src_addr; |
| 396 | } |
| 397 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 398 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_LOWER_SRC_ADDR, |
| 399 | lower_32_bits(src_phys_addr)); |
| 400 | |
| 401 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_SRC_ADDR, |
| 402 | upper_32_bits(src_phys_addr)); |
| 403 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 404 | src_crc32 = crc32_le(~0, src_addr, size); |
| 405 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 406 | orig_dst_addr = kzalloc(size + alignment, GFP_KERNEL); |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 407 | if (!orig_dst_addr) { |
Gustavo Pimentel | 0e52ea6 | 2018-05-14 17:56:23 +0100 | [diff] [blame] | 408 | dev_err(dev, "Failed to allocate destination address\n"); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 409 | ret = false; |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 410 | goto err_dst_addr; |
| 411 | } |
| 412 | |
| 413 | orig_dst_phys_addr = dma_map_single(dev, orig_dst_addr, |
| 414 | size + alignment, DMA_FROM_DEVICE); |
| 415 | if (dma_mapping_error(dev, orig_dst_phys_addr)) { |
| 416 | dev_err(dev, "failed to map destination buffer address\n"); |
| 417 | ret = false; |
| 418 | goto err_dst_phys_addr; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | if (alignment && !IS_ALIGNED(orig_dst_phys_addr, alignment)) { |
| 422 | dst_phys_addr = PTR_ALIGN(orig_dst_phys_addr, alignment); |
| 423 | offset = dst_phys_addr - orig_dst_phys_addr; |
| 424 | dst_addr = orig_dst_addr + offset; |
| 425 | } else { |
| 426 | dst_phys_addr = orig_dst_phys_addr; |
| 427 | dst_addr = orig_dst_addr; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_LOWER_DST_ADDR, |
| 431 | lower_32_bits(dst_phys_addr)); |
| 432 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_DST_ADDR, |
| 433 | upper_32_bits(dst_phys_addr)); |
| 434 | |
| 435 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, |
| 436 | size); |
| 437 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 438 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_FLAGS, flags); |
Gustavo Pimentel | 9133e39 | 2018-07-19 10:32:18 +0200 | [diff] [blame] | 439 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type); |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 440 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 441 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 442 | COMMAND_COPY); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 443 | |
| 444 | wait_for_completion(&test->irq_raised); |
| 445 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 446 | dma_unmap_single(dev, orig_dst_phys_addr, size + alignment, |
| 447 | DMA_FROM_DEVICE); |
| 448 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 449 | dst_crc32 = crc32_le(~0, dst_addr, size); |
| 450 | if (dst_crc32 == src_crc32) |
| 451 | ret = true; |
| 452 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 453 | err_dst_phys_addr: |
| 454 | kfree(orig_dst_addr); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 455 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 456 | err_dst_addr: |
| 457 | dma_unmap_single(dev, orig_src_phys_addr, size + alignment, |
| 458 | DMA_TO_DEVICE); |
| 459 | |
| 460 | err_src_phys_addr: |
| 461 | kfree(orig_src_addr); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 462 | |
| 463 | err: |
| 464 | return ret; |
| 465 | } |
| 466 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 467 | static bool pci_endpoint_test_write(struct pci_endpoint_test *test, |
| 468 | unsigned long arg) |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 469 | { |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 470 | struct pci_endpoint_test_xfer_param param; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 471 | bool ret = false; |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 472 | u32 flags = 0; |
| 473 | bool use_dma; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 474 | u32 reg; |
| 475 | void *addr; |
| 476 | dma_addr_t phys_addr; |
| 477 | struct pci_dev *pdev = test->pdev; |
| 478 | struct device *dev = &pdev->dev; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 479 | void *orig_addr; |
| 480 | dma_addr_t orig_phys_addr; |
| 481 | size_t offset; |
| 482 | size_t alignment = test->alignment; |
Kishon Vijay Abraham I | b2ba922 | 2020-03-17 15:31:54 +0530 | [diff] [blame] | 483 | int irq_type = test->irq_type; |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 484 | size_t size; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 485 | u32 crc32; |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 486 | int err; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 487 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 488 | err = copy_from_user(¶m, (void __user *)arg, sizeof(param)); |
| 489 | if (err != 0) { |
| 490 | dev_err(dev, "Failed to get transfer param\n"); |
| 491 | return false; |
| 492 | } |
| 493 | |
| 494 | size = param.size; |
Dan Carpenter | 343dc69 | 2017-09-30 11:15:52 +0300 | [diff] [blame] | 495 | if (size > SIZE_MAX - alignment) |
| 496 | goto err; |
| 497 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 498 | use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); |
| 499 | if (use_dma) |
| 500 | flags |= FLAG_USE_DMA; |
| 501 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 502 | if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { |
| 503 | dev_err(dev, "Invalid IRQ type option\n"); |
| 504 | goto err; |
| 505 | } |
| 506 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 507 | orig_addr = kzalloc(size + alignment, GFP_KERNEL); |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 508 | if (!orig_addr) { |
Gustavo Pimentel | 0e52ea6 | 2018-05-14 17:56:23 +0100 | [diff] [blame] | 509 | dev_err(dev, "Failed to allocate address\n"); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 510 | ret = false; |
| 511 | goto err; |
| 512 | } |
| 513 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 514 | get_random_bytes(orig_addr, size + alignment); |
| 515 | |
| 516 | orig_phys_addr = dma_map_single(dev, orig_addr, size + alignment, |
| 517 | DMA_TO_DEVICE); |
| 518 | if (dma_mapping_error(dev, orig_phys_addr)) { |
| 519 | dev_err(dev, "failed to map source buffer address\n"); |
| 520 | ret = false; |
| 521 | goto err_phys_addr; |
| 522 | } |
| 523 | |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 524 | if (alignment && !IS_ALIGNED(orig_phys_addr, alignment)) { |
| 525 | phys_addr = PTR_ALIGN(orig_phys_addr, alignment); |
| 526 | offset = phys_addr - orig_phys_addr; |
| 527 | addr = orig_addr + offset; |
| 528 | } else { |
| 529 | phys_addr = orig_phys_addr; |
| 530 | addr = orig_addr; |
| 531 | } |
| 532 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 533 | crc32 = crc32_le(~0, addr, size); |
| 534 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_CHECKSUM, |
| 535 | crc32); |
| 536 | |
| 537 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_LOWER_SRC_ADDR, |
| 538 | lower_32_bits(phys_addr)); |
| 539 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_SRC_ADDR, |
| 540 | upper_32_bits(phys_addr)); |
| 541 | |
| 542 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, size); |
| 543 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 544 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_FLAGS, flags); |
Gustavo Pimentel | 9133e39 | 2018-07-19 10:32:18 +0200 | [diff] [blame] | 545 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type); |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 546 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 547 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 548 | COMMAND_READ); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 549 | |
| 550 | wait_for_completion(&test->irq_raised); |
| 551 | |
| 552 | reg = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); |
| 553 | if (reg & STATUS_READ_SUCCESS) |
| 554 | ret = true; |
| 555 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 556 | dma_unmap_single(dev, orig_phys_addr, size + alignment, |
| 557 | DMA_TO_DEVICE); |
| 558 | |
| 559 | err_phys_addr: |
| 560 | kfree(orig_addr); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 561 | |
| 562 | err: |
| 563 | return ret; |
| 564 | } |
| 565 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 566 | static bool pci_endpoint_test_read(struct pci_endpoint_test *test, |
| 567 | unsigned long arg) |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 568 | { |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 569 | struct pci_endpoint_test_xfer_param param; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 570 | bool ret = false; |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 571 | u32 flags = 0; |
| 572 | bool use_dma; |
| 573 | size_t size; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 574 | void *addr; |
| 575 | dma_addr_t phys_addr; |
| 576 | struct pci_dev *pdev = test->pdev; |
| 577 | struct device *dev = &pdev->dev; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 578 | void *orig_addr; |
| 579 | dma_addr_t orig_phys_addr; |
| 580 | size_t offset; |
| 581 | size_t alignment = test->alignment; |
Kishon Vijay Abraham I | b2ba922 | 2020-03-17 15:31:54 +0530 | [diff] [blame] | 582 | int irq_type = test->irq_type; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 583 | u32 crc32; |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 584 | int err; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 585 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 586 | err = copy_from_user(¶m, (void __user *)arg, sizeof(param)); |
| 587 | if (err) { |
| 588 | dev_err(dev, "Failed to get transfer param\n"); |
| 589 | return false; |
| 590 | } |
| 591 | |
| 592 | size = param.size; |
Dan Carpenter | 343dc69 | 2017-09-30 11:15:52 +0300 | [diff] [blame] | 593 | if (size > SIZE_MAX - alignment) |
| 594 | goto err; |
| 595 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 596 | use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); |
| 597 | if (use_dma) |
| 598 | flags |= FLAG_USE_DMA; |
| 599 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 600 | if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { |
| 601 | dev_err(dev, "Invalid IRQ type option\n"); |
| 602 | goto err; |
| 603 | } |
| 604 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 605 | orig_addr = kzalloc(size + alignment, GFP_KERNEL); |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 606 | if (!orig_addr) { |
Gustavo Pimentel | 0e52ea6 | 2018-05-14 17:56:23 +0100 | [diff] [blame] | 607 | dev_err(dev, "Failed to allocate destination address\n"); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 608 | ret = false; |
| 609 | goto err; |
| 610 | } |
| 611 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 612 | orig_phys_addr = dma_map_single(dev, orig_addr, size + alignment, |
| 613 | DMA_FROM_DEVICE); |
| 614 | if (dma_mapping_error(dev, orig_phys_addr)) { |
| 615 | dev_err(dev, "failed to map source buffer address\n"); |
| 616 | ret = false; |
| 617 | goto err_phys_addr; |
| 618 | } |
| 619 | |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 620 | if (alignment && !IS_ALIGNED(orig_phys_addr, alignment)) { |
| 621 | phys_addr = PTR_ALIGN(orig_phys_addr, alignment); |
| 622 | offset = phys_addr - orig_phys_addr; |
| 623 | addr = orig_addr + offset; |
| 624 | } else { |
| 625 | phys_addr = orig_phys_addr; |
| 626 | addr = orig_addr; |
| 627 | } |
| 628 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 629 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_LOWER_DST_ADDR, |
| 630 | lower_32_bits(phys_addr)); |
| 631 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_DST_ADDR, |
| 632 | upper_32_bits(phys_addr)); |
| 633 | |
| 634 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, size); |
| 635 | |
Kishon Vijay Abraham I | cf376b4 | 2020-03-16 16:54:24 +0530 | [diff] [blame] | 636 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_FLAGS, flags); |
Gustavo Pimentel | 9133e39 | 2018-07-19 10:32:18 +0200 | [diff] [blame] | 637 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type); |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 638 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 639 | pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, |
Gustavo Pimentel | e8817de | 2018-07-19 10:32:17 +0200 | [diff] [blame] | 640 | COMMAND_WRITE); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 641 | |
| 642 | wait_for_completion(&test->irq_raised); |
| 643 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 644 | dma_unmap_single(dev, orig_phys_addr, size + alignment, |
| 645 | DMA_FROM_DEVICE); |
| 646 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 647 | crc32 = crc32_le(~0, addr, size); |
| 648 | if (crc32 == pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CHECKSUM)) |
| 649 | ret = true; |
| 650 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 651 | err_phys_addr: |
| 652 | kfree(orig_addr); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 653 | err: |
| 654 | return ret; |
| 655 | } |
| 656 | |
Kishon Vijay Abraham I | 475007f | 2020-03-17 15:31:55 +0530 | [diff] [blame] | 657 | static bool pci_endpoint_test_clear_irq(struct pci_endpoint_test *test) |
| 658 | { |
| 659 | pci_endpoint_test_release_irq(test); |
| 660 | pci_endpoint_test_free_irq_vectors(test); |
| 661 | return true; |
| 662 | } |
| 663 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 664 | static bool pci_endpoint_test_set_irq(struct pci_endpoint_test *test, |
| 665 | int req_irq_type) |
| 666 | { |
| 667 | struct pci_dev *pdev = test->pdev; |
| 668 | struct device *dev = &pdev->dev; |
| 669 | |
| 670 | if (req_irq_type < IRQ_TYPE_LEGACY || req_irq_type > IRQ_TYPE_MSIX) { |
| 671 | dev_err(dev, "Invalid IRQ type option\n"); |
| 672 | return false; |
| 673 | } |
| 674 | |
Kishon Vijay Abraham I | b2ba922 | 2020-03-17 15:31:54 +0530 | [diff] [blame] | 675 | if (test->irq_type == req_irq_type) |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 676 | return true; |
| 677 | |
| 678 | pci_endpoint_test_release_irq(test); |
| 679 | pci_endpoint_test_free_irq_vectors(test); |
| 680 | |
| 681 | if (!pci_endpoint_test_alloc_irq_vectors(test, req_irq_type)) |
| 682 | goto err; |
| 683 | |
| 684 | if (!pci_endpoint_test_request_irq(test)) |
| 685 | goto err; |
| 686 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 687 | return true; |
| 688 | |
| 689 | err: |
| 690 | pci_endpoint_test_free_irq_vectors(test); |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 691 | return false; |
| 692 | } |
| 693 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 694 | static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, |
| 695 | unsigned long arg) |
| 696 | { |
| 697 | int ret = -EINVAL; |
| 698 | enum pci_barno bar; |
| 699 | struct pci_endpoint_test *test = to_endpoint_test(file->private_data); |
Kishon Vijay Abraham I | 5bb04b1 | 2019-03-25 15:09:46 +0530 | [diff] [blame] | 700 | struct pci_dev *pdev = test->pdev; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 701 | |
| 702 | mutex_lock(&test->mutex); |
| 703 | switch (cmd) { |
| 704 | case PCITEST_BAR: |
| 705 | bar = arg; |
| 706 | if (bar < 0 || bar > 5) |
| 707 | goto ret; |
Kishon Vijay Abraham I | 5bb04b1 | 2019-03-25 15:09:46 +0530 | [diff] [blame] | 708 | if (is_am654_pci_dev(pdev) && bar == BAR_0) |
| 709 | goto ret; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 710 | ret = pci_endpoint_test_bar(test, bar); |
| 711 | break; |
| 712 | case PCITEST_LEGACY_IRQ: |
| 713 | ret = pci_endpoint_test_legacy_irq(test); |
| 714 | break; |
| 715 | case PCITEST_MSI: |
Gustavo Pimentel | c2e00e3 | 2018-07-19 10:32:19 +0200 | [diff] [blame] | 716 | case PCITEST_MSIX: |
| 717 | ret = pci_endpoint_test_msi_irq(test, arg, cmd == PCITEST_MSIX); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 718 | break; |
| 719 | case PCITEST_WRITE: |
| 720 | ret = pci_endpoint_test_write(test, arg); |
| 721 | break; |
| 722 | case PCITEST_READ: |
| 723 | ret = pci_endpoint_test_read(test, arg); |
| 724 | break; |
| 725 | case PCITEST_COPY: |
| 726 | ret = pci_endpoint_test_copy(test, arg); |
| 727 | break; |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 728 | case PCITEST_SET_IRQTYPE: |
| 729 | ret = pci_endpoint_test_set_irq(test, arg); |
| 730 | break; |
| 731 | case PCITEST_GET_IRQTYPE: |
| 732 | ret = irq_type; |
| 733 | break; |
Kishon Vijay Abraham I | 475007f | 2020-03-17 15:31:55 +0530 | [diff] [blame] | 734 | case PCITEST_CLEAR_IRQ: |
| 735 | ret = pci_endpoint_test_clear_irq(test); |
| 736 | break; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | ret: |
| 740 | mutex_unlock(&test->mutex); |
| 741 | return ret; |
| 742 | } |
| 743 | |
| 744 | static const struct file_operations pci_endpoint_test_fops = { |
| 745 | .owner = THIS_MODULE, |
| 746 | .unlocked_ioctl = pci_endpoint_test_ioctl, |
| 747 | }; |
| 748 | |
| 749 | static int pci_endpoint_test_probe(struct pci_dev *pdev, |
| 750 | const struct pci_device_id *ent) |
| 751 | { |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 752 | int err; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 753 | int id; |
Kishon Vijay Abraham I | 6b443e5c | 2020-03-17 15:31:57 +0530 | [diff] [blame] | 754 | char name[24]; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 755 | enum pci_barno bar; |
| 756 | void __iomem *base; |
| 757 | struct device *dev = &pdev->dev; |
| 758 | struct pci_endpoint_test *test; |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 759 | struct pci_endpoint_test_data *data; |
| 760 | enum pci_barno test_reg_bar = BAR_0; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 761 | struct miscdevice *misc_device; |
| 762 | |
| 763 | if (pci_is_bridge(pdev)) |
| 764 | return -ENODEV; |
| 765 | |
| 766 | test = devm_kzalloc(dev, sizeof(*test), GFP_KERNEL); |
| 767 | if (!test) |
| 768 | return -ENOMEM; |
| 769 | |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 770 | test->test_reg_bar = 0; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 771 | test->alignment = 0; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 772 | test->pdev = pdev; |
Kishon Vijay Abraham I | b2ba922 | 2020-03-17 15:31:54 +0530 | [diff] [blame] | 773 | test->irq_type = IRQ_TYPE_UNDEFINED; |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 774 | |
Gustavo Pimentel | 9133e39 | 2018-07-19 10:32:18 +0200 | [diff] [blame] | 775 | if (no_msi) |
| 776 | irq_type = IRQ_TYPE_LEGACY; |
| 777 | |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 778 | data = (struct pci_endpoint_test_data *)ent->driver_data; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 779 | if (data) { |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 780 | test_reg_bar = data->test_reg_bar; |
Kishon Vijay Abraham I | 8f22066 | 2019-03-25 15:09:47 +0530 | [diff] [blame] | 781 | test->test_reg_bar = test_reg_bar; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 782 | test->alignment = data->alignment; |
Gustavo Pimentel | 9133e39 | 2018-07-19 10:32:18 +0200 | [diff] [blame] | 783 | irq_type = data->irq_type; |
Kishon Vijay Abraham I | 13107c6 | 2017-08-18 20:28:06 +0530 | [diff] [blame] | 784 | } |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 785 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 786 | init_completion(&test->irq_raised); |
| 787 | mutex_init(&test->mutex); |
| 788 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 789 | if ((dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48)) != 0) && |
| 790 | dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) { |
| 791 | dev_err(dev, "Cannot set DMA mask\n"); |
| 792 | return -EINVAL; |
| 793 | } |
| 794 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 795 | err = pci_enable_device(pdev); |
| 796 | if (err) { |
| 797 | dev_err(dev, "Cannot enable PCI device\n"); |
| 798 | return err; |
| 799 | } |
| 800 | |
| 801 | err = pci_request_regions(pdev, DRV_MODULE_NAME); |
| 802 | if (err) { |
| 803 | dev_err(dev, "Cannot obtain PCI resources\n"); |
| 804 | goto err_disable_pdev; |
| 805 | } |
| 806 | |
| 807 | pci_set_master(pdev); |
| 808 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 809 | if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type)) |
| 810 | goto err_disable_irq; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 811 | |
Denis Efremov | c9c13ba | 2019-09-28 02:43:08 +0300 | [diff] [blame] | 812 | for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { |
Niklas Cassel | 16b17ca | 2018-03-28 13:50:17 +0200 | [diff] [blame] | 813 | if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { |
| 814 | base = pci_ioremap_bar(pdev, bar); |
| 815 | if (!base) { |
Gustavo Pimentel | 0e52ea6 | 2018-05-14 17:56:23 +0100 | [diff] [blame] | 816 | dev_err(dev, "Failed to read BAR%d\n", bar); |
Niklas Cassel | 16b17ca | 2018-03-28 13:50:17 +0200 | [diff] [blame] | 817 | WARN_ON(bar == test_reg_bar); |
| 818 | } |
| 819 | test->bar[bar] = base; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 820 | } |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 821 | } |
| 822 | |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 823 | test->base = test->bar[test_reg_bar]; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 824 | if (!test->base) { |
Kishon Vijay Abraham I | 80068c9 | 2017-10-11 14:14:36 +0530 | [diff] [blame] | 825 | err = -ENOMEM; |
Kishon Vijay Abraham I | 834b905 | 2017-08-18 20:28:05 +0530 | [diff] [blame] | 826 | dev_err(dev, "Cannot perform PCI test without BAR%d\n", |
| 827 | test_reg_bar); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 828 | goto err_iounmap; |
| 829 | } |
| 830 | |
| 831 | pci_set_drvdata(pdev, test); |
| 832 | |
| 833 | id = ida_simple_get(&pci_endpoint_test_ida, 0, 0, GFP_KERNEL); |
| 834 | if (id < 0) { |
Kishon Vijay Abraham I | 80068c9 | 2017-10-11 14:14:36 +0530 | [diff] [blame] | 835 | err = id; |
Gustavo Pimentel | 0e52ea6 | 2018-05-14 17:56:23 +0100 | [diff] [blame] | 836 | dev_err(dev, "Unable to get id\n"); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 837 | goto err_iounmap; |
| 838 | } |
| 839 | |
| 840 | snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id); |
Kishon Vijay Abraham I | c2be14a | 2020-03-17 15:31:58 +0530 | [diff] [blame] | 841 | test->name = kstrdup(name, GFP_KERNEL); |
| 842 | if (!test->name) { |
| 843 | err = -ENOMEM; |
| 844 | goto err_ida_remove; |
| 845 | } |
| 846 | |
| 847 | if (!pci_endpoint_test_request_irq(test)) |
| 848 | goto err_kfree_test_name; |
| 849 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 850 | misc_device = &test->miscdev; |
| 851 | misc_device->minor = MISC_DYNAMIC_MINOR; |
Kishon Vijay Abraham I | 139838f | 2017-10-11 14:14:37 +0530 | [diff] [blame] | 852 | misc_device->name = kstrdup(name, GFP_KERNEL); |
| 853 | if (!misc_device->name) { |
| 854 | err = -ENOMEM; |
Kishon Vijay Abraham I | c2be14a | 2020-03-17 15:31:58 +0530 | [diff] [blame] | 855 | goto err_release_irq; |
Kishon Vijay Abraham I | 139838f | 2017-10-11 14:14:37 +0530 | [diff] [blame] | 856 | } |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 857 | misc_device->fops = &pci_endpoint_test_fops, |
| 858 | |
| 859 | err = misc_register(misc_device); |
| 860 | if (err) { |
Gustavo Pimentel | 0e52ea6 | 2018-05-14 17:56:23 +0100 | [diff] [blame] | 861 | dev_err(dev, "Failed to register device\n"); |
Kishon Vijay Abraham I | 139838f | 2017-10-11 14:14:37 +0530 | [diff] [blame] | 862 | goto err_kfree_name; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | return 0; |
| 866 | |
Kishon Vijay Abraham I | 139838f | 2017-10-11 14:14:37 +0530 | [diff] [blame] | 867 | err_kfree_name: |
| 868 | kfree(misc_device->name); |
| 869 | |
Kishon Vijay Abraham I | c2be14a | 2020-03-17 15:31:58 +0530 | [diff] [blame] | 870 | err_release_irq: |
| 871 | pci_endpoint_test_release_irq(test); |
| 872 | |
| 873 | err_kfree_test_name: |
| 874 | kfree(test->name); |
| 875 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 876 | err_ida_remove: |
| 877 | ida_simple_remove(&pci_endpoint_test_ida, id); |
| 878 | |
| 879 | err_iounmap: |
Denis Efremov | c9c13ba | 2019-09-28 02:43:08 +0300 | [diff] [blame] | 880 | for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 881 | if (test->bar[bar]) |
| 882 | pci_iounmap(pdev, test->bar[bar]); |
| 883 | } |
| 884 | |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 885 | err_disable_irq: |
| 886 | pci_endpoint_test_free_irq_vectors(test); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 887 | pci_release_regions(pdev); |
| 888 | |
| 889 | err_disable_pdev: |
| 890 | pci_disable_device(pdev); |
| 891 | |
| 892 | return err; |
| 893 | } |
| 894 | |
| 895 | static void pci_endpoint_test_remove(struct pci_dev *pdev) |
| 896 | { |
| 897 | int id; |
| 898 | enum pci_barno bar; |
| 899 | struct pci_endpoint_test *test = pci_get_drvdata(pdev); |
| 900 | struct miscdevice *misc_device = &test->miscdev; |
| 901 | |
| 902 | if (sscanf(misc_device->name, DRV_MODULE_NAME ".%d", &id) != 1) |
| 903 | return; |
Dan Carpenter | a2db266 | 2017-09-30 11:16:51 +0300 | [diff] [blame] | 904 | if (id < 0) |
| 905 | return; |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 906 | |
| 907 | misc_deregister(&test->miscdev); |
Kishon Vijay Abraham I | 139838f | 2017-10-11 14:14:37 +0530 | [diff] [blame] | 908 | kfree(misc_device->name); |
Kishon Vijay Abraham I | c2be14a | 2020-03-17 15:31:58 +0530 | [diff] [blame] | 909 | kfree(test->name); |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 910 | ida_simple_remove(&pci_endpoint_test_ida, id); |
Denis Efremov | c9c13ba | 2019-09-28 02:43:08 +0300 | [diff] [blame] | 911 | for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 912 | if (test->bar[bar]) |
| 913 | pci_iounmap(pdev, test->bar[bar]); |
| 914 | } |
Gustavo Pimentel | e033271 | 2018-07-19 10:32:20 +0200 | [diff] [blame] | 915 | |
| 916 | pci_endpoint_test_release_irq(test); |
| 917 | pci_endpoint_test_free_irq_vectors(test); |
| 918 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 919 | pci_release_regions(pdev); |
| 920 | pci_disable_device(pdev); |
| 921 | } |
| 922 | |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 923 | static const struct pci_endpoint_test_data default_data = { |
| 924 | .test_reg_bar = BAR_0, |
| 925 | .alignment = SZ_4K, |
| 926 | .irq_type = IRQ_TYPE_MSI, |
| 927 | }; |
| 928 | |
Kishon Vijay Abraham I | 5bb04b1 | 2019-03-25 15:09:46 +0530 | [diff] [blame] | 929 | static const struct pci_endpoint_test_data am654_data = { |
| 930 | .test_reg_bar = BAR_2, |
| 931 | .alignment = SZ_64K, |
| 932 | .irq_type = IRQ_TYPE_MSI, |
| 933 | }; |
| 934 | |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 935 | static const struct pci_device_id pci_endpoint_test_tbl[] = { |
Kishon Vijay Abraham I | 0a121f9b | 2020-03-16 16:54:22 +0530 | [diff] [blame] | 936 | { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x), |
| 937 | .driver_data = (kernel_ulong_t)&default_data, |
| 938 | }, |
| 939 | { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x), |
| 940 | .driver_data = (kernel_ulong_t)&default_data, |
| 941 | }, |
Xiaowei Bao | 85cef37 | 2019-02-21 11:16:20 +0800 | [diff] [blame] | 942 | { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, 0x81c0) }, |
Gustavo Pimentel | 1f418f4 | 2019-06-04 15:29:25 +0200 | [diff] [blame] | 943 | { PCI_DEVICE_DATA(SYNOPSYS, EDDA, NULL) }, |
Kishon Vijay Abraham I | 5bb04b1 | 2019-03-25 15:09:46 +0530 | [diff] [blame] | 944 | { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), |
| 945 | .driver_data = (kernel_ulong_t)&am654_data |
| 946 | }, |
Lad Prabhakar | b03025c | 2020-05-14 23:03:29 +0100 | [diff] [blame] | 947 | { PCI_DEVICE(PCI_VENDOR_ID_RENESAS, PCI_DEVICE_ID_RENESAS_R8A774C0), |
| 948 | }, |
Kishon Vijay Abraham I | 2c156ac | 2017-03-27 15:15:14 +0530 | [diff] [blame] | 949 | { } |
| 950 | }; |
| 951 | MODULE_DEVICE_TABLE(pci, pci_endpoint_test_tbl); |
| 952 | |
| 953 | static struct pci_driver pci_endpoint_test_driver = { |
| 954 | .name = DRV_MODULE_NAME, |
| 955 | .id_table = pci_endpoint_test_tbl, |
| 956 | .probe = pci_endpoint_test_probe, |
| 957 | .remove = pci_endpoint_test_remove, |
| 958 | }; |
| 959 | module_pci_driver(pci_endpoint_test_driver); |
| 960 | |
| 961 | MODULE_DESCRIPTION("PCI ENDPOINT TEST HOST DRIVER"); |
| 962 | MODULE_AUTHOR("Kishon Vijay Abraham I <kishon@ti.com>"); |
| 963 | MODULE_LICENSE("GPL v2"); |