You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/28 05:39:57 UTC
(nuttx) 02/02: QemuEPC multi function verify for pci
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 786dabfb1368fcfb61ada3abd942fa6a61f9285e
Author: yezhonghui <ye...@xiaomi.com>
AuthorDate: Fri Aug 9 16:17:05 2024 +0800
QemuEPC multi function verify for pci
Signed-off-by: yezhonghui <ye...@xiaomi.com>
---
drivers/pci/pci_epf_test.c | 51 ++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 17 deletions(-)
diff --git a/drivers/pci/pci_epf_test.c b/drivers/pci/pci_epf_test.c
index 1ffad35254..169f5b26fd 100644
--- a/drivers/pci/pci_epf_test.c
+++ b/drivers/pci/pci_epf_test.c
@@ -41,6 +41,8 @@
* Pre-processor Definitions
****************************************************************************/
+#define PCI_EPF_TEST_FUNCTIONS 2
+
#define PCI_EPF_TEST_IRQ_TYPE_LEGACY 0
#define PCI_EPF_TEST_IRQ_TYPE_MSI 1
#define PCI_EPF_TEST_IRQ_TYPE_MSIX 2
@@ -64,9 +66,6 @@
#define PCI_EPF_TEST_WORK_PERIOD MSEC2TICK(10)
-#define ALIGN_UP(x, m) (((x) + ((m) - 1)) \
- & ~((uintptr_t)(m) - 1))
-
/****************************************************************************
* Private Types
****************************************************************************/
@@ -118,10 +117,17 @@ static const struct pci_epf_ops_s g_pci_epf_test_ops =
static const struct pci_epf_device_id_s g_pci_epf_test_id_table[] =
{
- {.name = "pci_epf_test", },
+ {.name = "pci_epf_test_0", },
+ {.name = "pci_epf_test_1", },
{}
};
+static FAR const char *g_pci_epf_test_name[] =
+{
+ "pci_epf_test_0",
+ "pci_epf_test_1",
+};
+
static struct pci_epf_driver_s g_pci_epf_test_driver =
{
.id_table = g_pci_epf_test_id_table,
@@ -649,7 +655,7 @@ static int pci_epf_test_bind(FAR struct pci_epf_device_s *epf)
ret = pci_epc_start(epf->epc);
if (ret < 0)
{
- pcierr("start error %d\n", ret);
+ pcierr("epc control start error\n");
return ret;
}
@@ -674,7 +680,7 @@ static int pci_epf_test_probe(FAR struct pci_epf_device_s *epf)
test->header.vendorid = 0x104c;
test->header.deviceid = 0xb500;
test->header.baseclass_code = PCI_CLASS_OTHERS;
- test->header.interrupt_pin = PCI_INTERRUPT_INTA;
+ test->header.interrupt_pin = PCI_INTERRUPT_INTA + epf->funcno;
test->bar_size[0] = 1024;
test->bar_size[1] = 512;
test->bar_size[2] = 1024;
@@ -706,30 +712,41 @@ int pci_register_epf_test_device(FAR const char *epc_name)
{
FAR struct pci_epf_device_s *epf;
int ret;
+ int i;
- epf = kmm_zalloc(sizeof(*epf));
+ epf = kmm_zalloc(sizeof(*epf) * PCI_EPF_TEST_FUNCTIONS);
if (NULL == epf)
{
pcierr("create epf error\n");
return -ENOMEM;
}
- epf->name = "pci_epf_test";
- epf->epc_name = epc_name;
- epf->msi_interrupts = 1;
- epf->msix_interrupts = 32;
- nxmutex_init(&epf->lock);
- ret = pci_epf_device_register(epf);
- if (ret < 0)
+ for (i = 0; i < PCI_EPF_TEST_FUNCTIONS; i++)
{
- pcierr("link error");
- goto err;
+ epf[i].name = g_pci_epf_test_name[i];
+ epf[i].epc_name = epc_name;
+ epf[i].msi_interrupts = 1;
+ epf[i].msix_interrupts = 32;
+ epf[i].funcno = i;
+ nxmutex_init(&epf[i].lock);
+ ret = pci_epf_device_register(&epf[i]);
+ if (ret < 0)
+ {
+ pcierr("func %d link error\n", i);
+ goto err;
+ }
}
return 0;
err:
- nxmutex_destroy(&epf->lock);
+ nxmutex_destroy(&epf[i].lock);
+ while (i-- > 0)
+ {
+ pci_epf_device_unregister(&epf[i]);
+ nxmutex_destroy(&epf[i].lock);
+ }
+
kmm_free(epf);
return ret;
}