Commit 2b65309b authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

env: remove spdk_pci_get_[first|next]_device



These APIs are not safe, since they do not hold the
pci device lock across calls, which can cause problems
if a device is inserted or removed while handles
returned by these APIs are being used.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I01a80f26d0a0ca4cdfc7181359932b38da8dd43a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10659


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent e123181d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,11 @@ were deprecated.

Added spdk_pci_for_each_device.

Removed spdk_pci_get_first_device and spdk_pci_get_next_device.  These APIs were unsafe, because
they did not account for PCI devices being inserted or removed while the caller was using handles
returned from these APIs.  Existing users of these APIs should switch to spdk_pci_for_each_device
instead.

## v21.10

Structure `spdk_nvmf_target_opts` has been extended with new member `discovery_filter` which allows to specify
+0 −19
Original line number Diff line number Diff line
@@ -796,25 +796,6 @@ int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb,
 */
void spdk_pci_for_each_device(void *ctx, void (*fn)(void *ctx, struct spdk_pci_device *dev));

/**
 * Begin iterating over enumerated PCI device by calling this function to get
 * the first PCI device. If there no PCI devices enumerated, return NULL
 *
 * \return a pointer to a PCI device on success, NULL otherwise.
 */
struct spdk_pci_device *spdk_pci_get_first_device(void);

/**
 * Continue iterating over enumerated PCI devices.
 * If no additional PCI devices, return NULL
 *
 * \param prev Previous PCI device returned from \ref spdk_pci_get_first_device
 * or \ref spdk_pci_get_next_device
 *
 * \return a pointer to the next PCI device on success, NULL otherwise.
 */
struct spdk_pci_device *spdk_pci_get_next_device(struct spdk_pci_device *prev);

/**
 * Map a PCI BAR in the current process.
 *
+2 −2
Original line number Diff line number Diff line
@@ -34,8 +34,8 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 7
SO_MINOR := 1
SO_VER := 8
SO_MINOR := 0

CFLAGS += $(ENV_CFLAGS)
C_SRCS = env.c memory.c pci.c init.c threads.c
+0 −12
Original line number Diff line number Diff line
@@ -774,18 +774,6 @@ spdk_pci_for_each_device(void *ctx, void (*fn)(void *ctx, struct spdk_pci_device
	pthread_mutex_unlock(&g_pci_mutex);
}

struct spdk_pci_device *
spdk_pci_get_first_device(void)
{
	return TAILQ_FIRST(&g_pci_devices);
}

struct spdk_pci_device *
spdk_pci_get_next_device(struct spdk_pci_device *prev)
{
	return TAILQ_NEXT(prev, internal.tailq);
}

int
spdk_pci_device_map_bar(struct spdk_pci_device *dev, uint32_t bar,
			void **mapped_addr, uint64_t *phys_addr, uint64_t *size)
+0 −2
Original line number Diff line number Diff line
@@ -60,8 +60,6 @@
	spdk_pci_virtio_get_driver;
	spdk_pci_enumerate;
	spdk_pci_for_each_device;
	spdk_pci_get_first_device;
	spdk_pci_get_next_device;
	spdk_pci_device_map_bar;
	spdk_pci_device_unmap_bar;
	spdk_pci_device_get_domain;