env_dpdk/pci: reduce g_pci_mutex scope
The global pci tailq is no longer modified on the dpdk thread, so on the spdk thread we can access it safely without any lock. The code is slightly more readable then. This shows that cleanup_pci_devices() is always wrapped with lock/unlock. We'll put the locks inside this function in the next patch. Change-Id: Ia4d386b78a87078761df0a3b953bfc4ff44102f8 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458933 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
b941b2983a
commit
fe511d03d2
@ -358,6 +358,8 @@ spdk_pci_device_attach(struct spdk_pci_driver *driver,
|
||||
|
||||
pthread_mutex_lock(&g_pci_mutex);
|
||||
cleanup_pci_devices();
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
|
||||
TAILQ_FOREACH(dev, &g_pci_devices, internal.tailq) {
|
||||
if (spdk_pci_addr_compare(&dev->addr, pci_address) == 0) {
|
||||
break;
|
||||
@ -365,6 +367,7 @@ spdk_pci_device_attach(struct spdk_pci_driver *driver,
|
||||
}
|
||||
|
||||
if (dev != NULL && dev->internal.driver == driver) {
|
||||
pthread_mutex_lock(&g_pci_mutex);
|
||||
if (dev->internal.attached || dev->internal.pending_removal) {
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
return -1;
|
||||
@ -377,7 +380,6 @@ spdk_pci_device_attach(struct spdk_pci_driver *driver,
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
return rc;
|
||||
}
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
|
||||
if (!driver->is_registered) {
|
||||
driver->is_registered = true;
|
||||
|
Loading…
Reference in New Issue
Block a user