Commit 17e10646 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB/core: Cut down single member ib_cache structure

Given that ib_cache structure has only single member now, merge the cache
lock directly in the ib_device.

Link: https://lore.kernel.org/r/20191212113024.336702-4-leon@kernel.orgSigned-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 6b57cea9
...@@ -1033,7 +1033,7 @@ int ib_get_cached_pkey(struct ib_device *device, ...@@ -1033,7 +1033,7 @@ int ib_get_cached_pkey(struct ib_device *device,
if (!rdma_is_port_valid(device, port_num)) if (!rdma_is_port_valid(device, port_num))
return -EINVAL; return -EINVAL;
read_lock_irqsave(&device->cache.lock, flags); read_lock_irqsave(&device->cache_lock, flags);
cache = device->port_data[port_num].cache.pkey; cache = device->port_data[port_num].cache.pkey;
...@@ -1042,7 +1042,7 @@ int ib_get_cached_pkey(struct ib_device *device, ...@@ -1042,7 +1042,7 @@ int ib_get_cached_pkey(struct ib_device *device,
else else
*pkey = cache->table[index]; *pkey = cache->table[index];
read_unlock_irqrestore(&device->cache.lock, flags); read_unlock_irqrestore(&device->cache_lock, flags);
return ret; return ret;
} }
...@@ -1057,9 +1057,9 @@ int ib_get_cached_subnet_prefix(struct ib_device *device, ...@@ -1057,9 +1057,9 @@ int ib_get_cached_subnet_prefix(struct ib_device *device,
if (!rdma_is_port_valid(device, port_num)) if (!rdma_is_port_valid(device, port_num))
return -EINVAL; return -EINVAL;
read_lock_irqsave(&device->cache.lock, flags); read_lock_irqsave(&device->cache_lock, flags);
*sn_pfx = device->port_data[port_num].cache.subnet_prefix; *sn_pfx = device->port_data[port_num].cache.subnet_prefix;
read_unlock_irqrestore(&device->cache.lock, flags); read_unlock_irqrestore(&device->cache_lock, flags);
return 0; return 0;
} }
...@@ -1079,7 +1079,7 @@ int ib_find_cached_pkey(struct ib_device *device, ...@@ -1079,7 +1079,7 @@ int ib_find_cached_pkey(struct ib_device *device,
if (!rdma_is_port_valid(device, port_num)) if (!rdma_is_port_valid(device, port_num))
return -EINVAL; return -EINVAL;
read_lock_irqsave(&device->cache.lock, flags); read_lock_irqsave(&device->cache_lock, flags);
cache = device->port_data[port_num].cache.pkey; cache = device->port_data[port_num].cache.pkey;
...@@ -1100,7 +1100,7 @@ int ib_find_cached_pkey(struct ib_device *device, ...@@ -1100,7 +1100,7 @@ int ib_find_cached_pkey(struct ib_device *device,
ret = 0; ret = 0;
} }
read_unlock_irqrestore(&device->cache.lock, flags); read_unlock_irqrestore(&device->cache_lock, flags);
return ret; return ret;
} }
...@@ -1119,7 +1119,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device, ...@@ -1119,7 +1119,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
if (!rdma_is_port_valid(device, port_num)) if (!rdma_is_port_valid(device, port_num))
return -EINVAL; return -EINVAL;
read_lock_irqsave(&device->cache.lock, flags); read_lock_irqsave(&device->cache_lock, flags);
cache = device->port_data[port_num].cache.pkey; cache = device->port_data[port_num].cache.pkey;
...@@ -1132,7 +1132,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device, ...@@ -1132,7 +1132,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
break; break;
} }
read_unlock_irqrestore(&device->cache.lock, flags); read_unlock_irqrestore(&device->cache_lock, flags);
return ret; return ret;
} }
...@@ -1148,9 +1148,9 @@ int ib_get_cached_lmc(struct ib_device *device, ...@@ -1148,9 +1148,9 @@ int ib_get_cached_lmc(struct ib_device *device,
if (!rdma_is_port_valid(device, port_num)) if (!rdma_is_port_valid(device, port_num))
return -EINVAL; return -EINVAL;
read_lock_irqsave(&device->cache.lock, flags); read_lock_irqsave(&device->cache_lock, flags);
*lmc = device->port_data[port_num].cache.lmc; *lmc = device->port_data[port_num].cache.lmc;
read_unlock_irqrestore(&device->cache.lock, flags); read_unlock_irqrestore(&device->cache_lock, flags);
return ret; return ret;
} }
...@@ -1166,9 +1166,9 @@ int ib_get_cached_port_state(struct ib_device *device, ...@@ -1166,9 +1166,9 @@ int ib_get_cached_port_state(struct ib_device *device,
if (!rdma_is_port_valid(device, port_num)) if (!rdma_is_port_valid(device, port_num))
return -EINVAL; return -EINVAL;
read_lock_irqsave(&device->cache.lock, flags); read_lock_irqsave(&device->cache_lock, flags);
*port_state = device->port_data[port_num].cache.port_state; *port_state = device->port_data[port_num].cache.port_state;
read_unlock_irqrestore(&device->cache.lock, flags); read_unlock_irqrestore(&device->cache_lock, flags);
return ret; return ret;
} }
...@@ -1428,7 +1428,7 @@ ib_cache_update(struct ib_device *device, u8 port, bool enforce_security) ...@@ -1428,7 +1428,7 @@ ib_cache_update(struct ib_device *device, u8 port, bool enforce_security)
} }
} }
write_lock_irq(&device->cache.lock); write_lock_irq(&device->cache_lock);
old_pkey_cache = device->port_data[port].cache.pkey; old_pkey_cache = device->port_data[port].cache.pkey;
...@@ -1437,7 +1437,7 @@ ib_cache_update(struct ib_device *device, u8 port, bool enforce_security) ...@@ -1437,7 +1437,7 @@ ib_cache_update(struct ib_device *device, u8 port, bool enforce_security)
device->port_data[port].cache.port_state = tprops->state; device->port_data[port].cache.port_state = tprops->state;
device->port_data[port].cache.subnet_prefix = tprops->subnet_prefix; device->port_data[port].cache.subnet_prefix = tprops->subnet_prefix;
write_unlock_irq(&device->cache.lock); write_unlock_irq(&device->cache_lock);
if (enforce_security) if (enforce_security)
ib_security_cache_change(device, ib_security_cache_change(device,
...@@ -1530,7 +1530,7 @@ int ib_cache_setup_one(struct ib_device *device) ...@@ -1530,7 +1530,7 @@ int ib_cache_setup_one(struct ib_device *device)
unsigned int p; unsigned int p;
int err; int err;
rwlock_init(&device->cache.lock); rwlock_init(&device->cache_lock);
err = gid_table_setup_one(device); err = gid_table_setup_one(device);
if (err) if (err)
......
...@@ -2152,10 +2152,6 @@ struct ib_port_cache { ...@@ -2152,10 +2152,6 @@ struct ib_port_cache {
enum ib_port_state port_state; enum ib_port_state port_state;
}; };
struct ib_cache {
rwlock_t lock;
};
struct ib_port_immutable { struct ib_port_immutable {
int pkey_tbl_len; int pkey_tbl_len;
int gid_tbl_len; int gid_tbl_len;
...@@ -2641,7 +2637,8 @@ struct ib_device { ...@@ -2641,7 +2637,8 @@ struct ib_device {
struct xarray client_data; struct xarray client_data;
struct mutex unregistration_lock; struct mutex unregistration_lock;
struct ib_cache cache; /* Synchronize GID, Pkey cache entries, subnet prefix, LMC */
rwlock_t cache_lock;
/** /**
* port_data is indexed by port number * port_data is indexed by port number
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment