drivers/virtualization: Take advantage of pcie_bdf_lookup()
Use the new pcie_bdf_lookup() API instead of having a custom lookup function. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
d01fa56f6a
commit
935ebc0134
2 changed files with 3 additions and 43 deletions
|
@ -103,43 +103,6 @@ static const struct ivshmem_reg no_reg;
|
||||||
|
|
||||||
#endif /* CONFIG_IVSHMEM_DOORBELL */
|
#endif /* CONFIG_IVSHMEM_DOORBELL */
|
||||||
|
|
||||||
static bool ivshmem_check_on_bdf(pcie_bdf_t bdf)
|
|
||||||
{
|
|
||||||
uint32_t data;
|
|
||||||
|
|
||||||
data = pcie_conf_read(bdf, PCIE_CONF_ID);
|
|
||||||
if ((data != PCIE_ID_NONE) &&
|
|
||||||
(PCIE_ID_TO_VEND(data) == IVSHMEM_VENDOR_ID) &&
|
|
||||||
(PCIE_ID_TO_DEV(data) == IVSHMEM_DEVICE_ID)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ivshmem's BDF is not a static value that we could get from DTS,
|
|
||||||
* since the same image could run on qemu or ACRN which could set
|
|
||||||
* a different one. So instead, let's find it at runtime.
|
|
||||||
*/
|
|
||||||
static pcie_bdf_t ivshmem_bdf_lookup(void)
|
|
||||||
{
|
|
||||||
int bus, dev, func;
|
|
||||||
|
|
||||||
for (bus = 0; bus <= MAX_BUS; bus++) {
|
|
||||||
for (dev = 0; dev <= MAX_DEV; ++dev) {
|
|
||||||
for (func = 0; func <= MAX_FUNC; ++func) {
|
|
||||||
pcie_bdf_t bdf = PCIE_BDF(bus, dev, func);
|
|
||||||
|
|
||||||
if (ivshmem_check_on_bdf(bdf)) {
|
|
||||||
return bdf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ivshmem_configure(const struct device *dev)
|
static bool ivshmem_configure(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct ivshmem *data = dev->data;
|
struct ivshmem *data = dev->data;
|
||||||
|
@ -261,8 +224,9 @@ static int ivshmem_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct ivshmem *data = dev->data;
|
struct ivshmem *data = dev->data;
|
||||||
|
|
||||||
data->bdf = ivshmem_bdf_lookup();
|
data->bdf = pcie_bdf_lookup(PCIE_ID(IVSHMEM_VENDOR_ID,
|
||||||
if (data->bdf == 0) {
|
IVSHMEM_DEVICE_ID));
|
||||||
|
if (data->bdf == PCIE_BDF_NONE) {
|
||||||
LOG_WRN("ivshmem device not found");
|
LOG_WRN("ivshmem device not found");
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,6 @@
|
||||||
#define IVSHMEM_PCIE_REG_BAR_IDX 0
|
#define IVSHMEM_PCIE_REG_BAR_IDX 0
|
||||||
#define IVSHMEM_PCIE_SHMEM_BAR_IDX 2
|
#define IVSHMEM_PCIE_SHMEM_BAR_IDX 2
|
||||||
|
|
||||||
#define MAX_BUS (0xFFFFFFFF & PCIE_BDF_BUS_MASK)
|
|
||||||
#define MAX_DEV (0xFFFFFFFF & PCIE_BDF_DEV_MASK)
|
|
||||||
#define MAX_FUNC (0xFFFFFFFF & PCIE_BDF_FUNC_MASK)
|
|
||||||
|
|
||||||
struct ivshmem_param {
|
struct ivshmem_param {
|
||||||
const struct device *dev;
|
const struct device *dev;
|
||||||
struct k_poll_signal *signal;
|
struct k_poll_signal *signal;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue