[PATCH 2/2] misc: pci_endpoint_test: Set reserved BARs for each SoCs

Kunihiko Hayashi
2024-12-16T07:41:05Z

There are bar numbers that cannot be used on the endpoint.
So instead of SoC-specific conditions, add "reserved_bar" bar number
bitmap to the SoC data.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
drivers/misc/pci_endpoint_test.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 854480921470..e6a1a2916425 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -76,9 +76,6 @@
#define PCI_DEVICE_ID_LS1088A 0x80c0
#define PCI_DEVICE_ID_IMX8 0x0808

-#define is_am654_pci_dev(pdev) \
- ((pdev)->device == PCI_DEVICE_ID_TI_AM654)
-
#define PCI_DEVICE_ID_RENESAS_R8A774A1 0x0028
#define PCI_DEVICE_ID_RENESAS_R8A774B1 0x002b
#define PCI_DEVICE_ID_RENESAS_R8A774C0 0x002d
@@ -123,6 +120,7 @@ struct pci_endpoint_test {
struct miscdevice miscdev;
enum pci_barno test_reg_bar;
size_t alignment;
+ u32 reserved_bar;
const char *name;
};

@@ -130,6 +128,7 @@ struct pci_endpoint_test_data {
enum pci_barno test_reg_bar;
size_t alignment;
int irq_type;
+ u32 reserved_bar;
};

static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test,
@@ -753,7 +752,6 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
int ret = -EINVAL;
enum pci_barno bar;
struct pci_endpoint_test *test = to_endpoint_test(file->private_data);
- struct pci_dev *pdev = test->pdev;

mutex_lock(&test->mutex);

@@ -765,7 +763,7 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
bar = arg;
if (bar > BAR_5)
goto ret;
- if (is_am654_pci_dev(pdev) && bar == BAR_0)
+ if (BIT(bar) & test->reserved_bar)
goto ret;
ret = pci_endpoint_test_bar(test, bar);
break;
@@ -840,6 +838,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
test_reg_bar = data->test_reg_bar;
test->test_reg_bar = test_reg_bar;
test->alignment = data->alignment;
+ test->reserved_bar = data->reserved_bar;
irq_type = data->irq_type;
}

@@ -991,6 +990,7 @@ static const struct pci_endpoint_test_data am654_data = {
.test_reg_bar = BAR_2,
.alignment = SZ_64K,
.irq_type = IRQ_TYPE_MSI,
+ .reserved_bar = BIT(BAR_0),
};

static const struct pci_endpoint_test_data j721e_data = {
--
2.25.1