diff options
author | Steven Whitehouse <steve@men-an-tol.chygwyn.com> | 2006-02-23 04:49:43 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-02-23 04:49:43 -0500 |
commit | d35462b4bb847b68321c55e95c926aa485aecce2 (patch) | |
tree | b08e18bf6e672633402871ee763102fdb5e63229 /drivers/infiniband/hw | |
parent | 91ffd7db71e7451f89941a8f428b4daa2a7c1e38 (diff) | |
parent | 9e956c2dac9bec602ed1ba29181b45ba6d2b6448 (diff) |
Merge branch 'master'
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_av.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_cmd.c | 51 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_dev.h | 12 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_main.c | 10 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_mcg.c | 20 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_memfree.c | 36 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_memfree.h | 7 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.c | 6 |
8 files changed, 71 insertions, 73 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c index a14eed08a0fc..a19e0ed03d7c 100644 --- a/drivers/infiniband/hw/mthca/mthca_av.c +++ b/drivers/infiniband/hw/mthca/mthca_av.c | |||
@@ -184,7 +184,7 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, | |||
184 | ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff); | 184 | ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff); |
185 | ib_get_cached_gid(&dev->ib_dev, | 185 | ib_get_cached_gid(&dev->ib_dev, |
186 | be32_to_cpu(ah->av->port_pd) >> 24, | 186 | be32_to_cpu(ah->av->port_pd) >> 24, |
187 | ah->av->gid_index, | 187 | ah->av->gid_index % dev->limits.gid_table_len, |
188 | &header->grh.source_gid); | 188 | &header->grh.source_gid); |
189 | memcpy(header->grh.destination_gid.raw, | 189 | memcpy(header->grh.destination_gid.raw, |
190 | ah->av->dgid, 16); | 190 | ah->av->dgid, 16); |
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index be1791be627b..2825615ce81c 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c | |||
@@ -199,8 +199,7 @@ static int mthca_cmd_post(struct mthca_dev *dev, | |||
199 | { | 199 | { |
200 | int err = 0; | 200 | int err = 0; |
201 | 201 | ||
202 | if (down_interruptible(&dev->cmd.hcr_sem)) | 202 | mutex_lock(&dev->cmd.hcr_mutex); |
203 | return -EINTR; | ||
204 | 203 | ||
205 | if (event) { | 204 | if (event) { |
206 | unsigned long end = jiffies + GO_BIT_TIMEOUT; | 205 | unsigned long end = jiffies + GO_BIT_TIMEOUT; |
@@ -238,7 +237,7 @@ static int mthca_cmd_post(struct mthca_dev *dev, | |||
238 | op), dev->hcr + 6 * 4); | 237 | op), dev->hcr + 6 * 4); |
239 | 238 | ||
240 | out: | 239 | out: |
241 | up(&dev->cmd.hcr_sem); | 240 | mutex_unlock(&dev->cmd.hcr_mutex); |
242 | return err; | 241 | return err; |
243 | } | 242 | } |
244 | 243 | ||
@@ -255,8 +254,7 @@ static int mthca_cmd_poll(struct mthca_dev *dev, | |||
255 | int err = 0; | 254 | int err = 0; |
256 | unsigned long end; | 255 | unsigned long end; |
257 | 256 | ||
258 | if (down_interruptible(&dev->cmd.poll_sem)) | 257 | down(&dev->cmd.poll_sem); |
259 | return -EINTR; | ||
260 | 258 | ||
261 | err = mthca_cmd_post(dev, in_param, | 259 | err = mthca_cmd_post(dev, in_param, |
262 | out_param ? *out_param : 0, | 260 | out_param ? *out_param : 0, |
@@ -333,8 +331,7 @@ static int mthca_cmd_wait(struct mthca_dev *dev, | |||
333 | int err = 0; | 331 | int err = 0; |
334 | struct mthca_cmd_context *context; | 332 | struct mthca_cmd_context *context; |
335 | 333 | ||
336 | if (down_interruptible(&dev->cmd.event_sem)) | 334 | down(&dev->cmd.event_sem); |
337 | return -EINTR; | ||
338 | 335 | ||
339 | spin_lock(&dev->cmd.context_lock); | 336 | spin_lock(&dev->cmd.context_lock); |
340 | BUG_ON(dev->cmd.free_head < 0); | 337 | BUG_ON(dev->cmd.free_head < 0); |
@@ -438,7 +435,7 @@ static int mthca_cmd_imm(struct mthca_dev *dev, | |||
438 | 435 | ||
439 | int mthca_cmd_init(struct mthca_dev *dev) | 436 | int mthca_cmd_init(struct mthca_dev *dev) |
440 | { | 437 | { |
441 | sema_init(&dev->cmd.hcr_sem, 1); | 438 | mutex_init(&dev->cmd.hcr_mutex); |
442 | sema_init(&dev->cmd.poll_sem, 1); | 439 | sema_init(&dev->cmd.poll_sem, 1); |
443 | dev->cmd.use_events = 0; | 440 | dev->cmd.use_events = 0; |
444 | 441 | ||
@@ -1032,25 +1029,6 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev, | |||
1032 | MTHCA_GET(size, outbox, QUERY_DEV_LIM_UAR_ENTRY_SZ_OFFSET); | 1029 | MTHCA_GET(size, outbox, QUERY_DEV_LIM_UAR_ENTRY_SZ_OFFSET); |
1033 | dev_lim->uar_scratch_entry_sz = size; | 1030 | dev_lim->uar_scratch_entry_sz = size; |
1034 | 1031 | ||
1035 | mthca_dbg(dev, "Max QPs: %d, reserved QPs: %d, entry size: %d\n", | ||
1036 | dev_lim->max_qps, dev_lim->reserved_qps, dev_lim->qpc_entry_sz); | ||
1037 | mthca_dbg(dev, "Max SRQs: %d, reserved SRQs: %d, entry size: %d\n", | ||
1038 | dev_lim->max_srqs, dev_lim->reserved_srqs, dev_lim->srq_entry_sz); | ||
1039 | mthca_dbg(dev, "Max CQs: %d, reserved CQs: %d, entry size: %d\n", | ||
1040 | dev_lim->max_cqs, dev_lim->reserved_cqs, dev_lim->cqc_entry_sz); | ||
1041 | mthca_dbg(dev, "Max EQs: %d, reserved EQs: %d, entry size: %d\n", | ||
1042 | dev_lim->max_eqs, dev_lim->reserved_eqs, dev_lim->eqc_entry_sz); | ||
1043 | mthca_dbg(dev, "reserved MPTs: %d, reserved MTTs: %d\n", | ||
1044 | dev_lim->reserved_mrws, dev_lim->reserved_mtts); | ||
1045 | mthca_dbg(dev, "Max PDs: %d, reserved PDs: %d, reserved UARs: %d\n", | ||
1046 | dev_lim->max_pds, dev_lim->reserved_pds, dev_lim->reserved_uars); | ||
1047 | mthca_dbg(dev, "Max QP/MCG: %d, reserved MGMs: %d\n", | ||
1048 | dev_lim->max_pds, dev_lim->reserved_mgms); | ||
1049 | mthca_dbg(dev, "Max CQEs: %d, max WQEs: %d, max SRQ WQEs: %d\n", | ||
1050 | dev_lim->max_cq_sz, dev_lim->max_qp_sz, dev_lim->max_srq_sz); | ||
1051 | |||
1052 | mthca_dbg(dev, "Flags: %08x\n", dev_lim->flags); | ||
1053 | |||
1054 | if (mthca_is_memfree(dev)) { | 1032 | if (mthca_is_memfree(dev)) { |
1055 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET); | 1033 | MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET); |
1056 | dev_lim->max_srq_sz = 1 << field; | 1034 | dev_lim->max_srq_sz = 1 << field; |
@@ -1096,6 +1074,25 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev, | |||
1096 | dev_lim->mpt_entry_sz = MTHCA_MPT_ENTRY_SIZE; | 1074 | dev_lim->mpt_entry_sz = MTHCA_MPT_ENTRY_SIZE; |
1097 | } | 1075 | } |
1098 | 1076 | ||
1077 | mthca_dbg(dev, "Max QPs: %d, reserved QPs: %d, entry size: %d\n", | ||
1078 | dev_lim->max_qps, dev_lim->reserved_qps, dev_lim->qpc_entry_sz); | ||
1079 | mthca_dbg(dev, "Max SRQs: %d, reserved SRQs: %d, entry size: %d\n", | ||
1080 | dev_lim->max_srqs, dev_lim->reserved_srqs, dev_lim->srq_entry_sz); | ||
1081 | mthca_dbg(dev, "Max CQs: %d, reserved CQs: %d, entry size: %d\n", | ||
1082 | dev_lim->max_cqs, dev_lim->reserved_cqs, dev_lim->cqc_entry_sz); | ||
1083 | mthca_dbg(dev, "Max EQs: %d, reserved EQs: %d, entry size: %d\n", | ||
1084 | dev_lim->max_eqs, dev_lim->reserved_eqs, dev_lim->eqc_entry_sz); | ||
1085 | mthca_dbg(dev, "reserved MPTs: %d, reserved MTTs: %d\n", | ||
1086 | dev_lim->reserved_mrws, dev_lim->reserved_mtts); | ||
1087 | mthca_dbg(dev, "Max PDs: %d, reserved PDs: %d, reserved UARs: %d\n", | ||
1088 | dev_lim->max_pds, dev_lim->reserved_pds, dev_lim->reserved_uars); | ||
1089 | mthca_dbg(dev, "Max QP/MCG: %d, reserved MGMs: %d\n", | ||
1090 | dev_lim->max_pds, dev_lim->reserved_mgms); | ||
1091 | mthca_dbg(dev, "Max CQEs: %d, max WQEs: %d, max SRQ WQEs: %d\n", | ||
1092 | dev_lim->max_cq_sz, dev_lim->max_qp_sz, dev_lim->max_srq_sz); | ||
1093 | |||
1094 | mthca_dbg(dev, "Flags: %08x\n", dev_lim->flags); | ||
1095 | |||
1099 | out: | 1096 | out: |
1100 | mthca_free_mailbox(dev, mailbox); | 1097 | mthca_free_mailbox(dev, mailbox); |
1101 | return err; | 1098 | return err; |
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index a104ab041ea3..e481037288d6 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h | |||
@@ -44,6 +44,8 @@ | |||
44 | #include <linux/pci.h> | 44 | #include <linux/pci.h> |
45 | #include <linux/dma-mapping.h> | 45 | #include <linux/dma-mapping.h> |
46 | #include <linux/timer.h> | 46 | #include <linux/timer.h> |
47 | #include <linux/mutex.h> | ||
48 | |||
47 | #include <asm/semaphore.h> | 49 | #include <asm/semaphore.h> |
48 | 50 | ||
49 | #include "mthca_provider.h" | 51 | #include "mthca_provider.h" |
@@ -51,8 +53,8 @@ | |||
51 | 53 | ||
52 | #define DRV_NAME "ib_mthca" | 54 | #define DRV_NAME "ib_mthca" |
53 | #define PFX DRV_NAME ": " | 55 | #define PFX DRV_NAME ": " |
54 | #define DRV_VERSION "0.06" | 56 | #define DRV_VERSION "0.07" |
55 | #define DRV_RELDATE "June 23, 2005" | 57 | #define DRV_RELDATE "February 13, 2006" |
56 | 58 | ||
57 | enum { | 59 | enum { |
58 | MTHCA_FLAG_DDR_HIDDEN = 1 << 1, | 60 | MTHCA_FLAG_DDR_HIDDEN = 1 << 1, |
@@ -111,7 +113,7 @@ enum { | |||
111 | struct mthca_cmd { | 113 | struct mthca_cmd { |
112 | struct pci_pool *pool; | 114 | struct pci_pool *pool; |
113 | int use_events; | 115 | int use_events; |
114 | struct semaphore hcr_sem; | 116 | struct mutex hcr_mutex; |
115 | struct semaphore poll_sem; | 117 | struct semaphore poll_sem; |
116 | struct semaphore event_sem; | 118 | struct semaphore event_sem; |
117 | int max_cmds; | 119 | int max_cmds; |
@@ -256,7 +258,7 @@ struct mthca_av_table { | |||
256 | }; | 258 | }; |
257 | 259 | ||
258 | struct mthca_mcg_table { | 260 | struct mthca_mcg_table { |
259 | struct semaphore sem; | 261 | struct mutex mutex; |
260 | struct mthca_alloc alloc; | 262 | struct mthca_alloc alloc; |
261 | struct mthca_icm_table *table; | 263 | struct mthca_icm_table *table; |
262 | }; | 264 | }; |
@@ -301,7 +303,7 @@ struct mthca_dev { | |||
301 | u64 ddr_end; | 303 | u64 ddr_end; |
302 | 304 | ||
303 | MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock) | 305 | MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock) |
304 | struct semaphore cap_mask_mutex; | 306 | struct mutex cap_mask_mutex; |
305 | 307 | ||
306 | void __iomem *hcr; | 308 | void __iomem *hcr; |
307 | void __iomem *kar; | 309 | void __iomem *kar; |
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 8b00d9a0f6f4..9c849d27b06e 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c | |||
@@ -155,6 +155,13 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim | |||
155 | return -ENODEV; | 155 | return -ENODEV; |
156 | } | 156 | } |
157 | 157 | ||
158 | if (dev_lim->uar_size > pci_resource_len(mdev->pdev, 2)) { | ||
159 | mthca_err(mdev, "HCA reported UAR size of 0x%x bigger than " | ||
160 | "PCI resource 2 size of 0x%lx, aborting.\n", | ||
161 | dev_lim->uar_size, pci_resource_len(mdev->pdev, 2)); | ||
162 | return -ENODEV; | ||
163 | } | ||
164 | |||
158 | mdev->limits.num_ports = dev_lim->num_ports; | 165 | mdev->limits.num_ports = dev_lim->num_ports; |
159 | mdev->limits.vl_cap = dev_lim->max_vl; | 166 | mdev->limits.vl_cap = dev_lim->max_vl; |
160 | mdev->limits.mtu_cap = dev_lim->max_mtu; | 167 | mdev->limits.mtu_cap = dev_lim->max_mtu; |
@@ -976,8 +983,7 @@ static int __devinit mthca_init_one(struct pci_dev *pdev, | |||
976 | err = -ENODEV; | 983 | err = -ENODEV; |
977 | goto err_disable_pdev; | 984 | goto err_disable_pdev; |
978 | } | 985 | } |
979 | if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM) || | 986 | if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) { |
980 | pci_resource_len(pdev, 2) != 1 << 23) { | ||
981 | dev_err(&pdev->dev, "Missing UAR, aborting.\n"); | 987 | dev_err(&pdev->dev, "Missing UAR, aborting.\n"); |
982 | err = -ENODEV; | 988 | err = -ENODEV; |
983 | goto err_disable_pdev; | 989 | goto err_disable_pdev; |
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c index 77bc6c746f43..321f11e707f2 100644 --- a/drivers/infiniband/hw/mthca/mthca_mcg.c +++ b/drivers/infiniband/hw/mthca/mthca_mcg.c | |||
@@ -154,10 +154,7 @@ int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | |||
154 | return PTR_ERR(mailbox); | 154 | return PTR_ERR(mailbox); |
155 | mgm = mailbox->buf; | 155 | mgm = mailbox->buf; |
156 | 156 | ||
157 | if (down_interruptible(&dev->mcg_table.sem)) { | 157 | mutex_lock(&dev->mcg_table.mutex); |
158 | err = -EINTR; | ||
159 | goto err_sem; | ||
160 | } | ||
161 | 158 | ||
162 | err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index); | 159 | err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index); |
163 | if (err) | 160 | if (err) |
@@ -241,8 +238,8 @@ int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | |||
241 | BUG_ON(index < dev->limits.num_mgms); | 238 | BUG_ON(index < dev->limits.num_mgms); |
242 | mthca_free(&dev->mcg_table.alloc, index); | 239 | mthca_free(&dev->mcg_table.alloc, index); |
243 | } | 240 | } |
244 | up(&dev->mcg_table.sem); | 241 | mutex_unlock(&dev->mcg_table.mutex); |
245 | err_sem: | 242 | |
246 | mthca_free_mailbox(dev, mailbox); | 243 | mthca_free_mailbox(dev, mailbox); |
247 | return err; | 244 | return err; |
248 | } | 245 | } |
@@ -263,10 +260,7 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | |||
263 | return PTR_ERR(mailbox); | 260 | return PTR_ERR(mailbox); |
264 | mgm = mailbox->buf; | 261 | mgm = mailbox->buf; |
265 | 262 | ||
266 | if (down_interruptible(&dev->mcg_table.sem)) { | 263 | mutex_lock(&dev->mcg_table.mutex); |
267 | err = -EINTR; | ||
268 | goto err_sem; | ||
269 | } | ||
270 | 264 | ||
271 | err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index); | 265 | err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index); |
272 | if (err) | 266 | if (err) |
@@ -371,8 +365,8 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) | |||
371 | } | 365 | } |
372 | 366 | ||
373 | out: | 367 | out: |
374 | up(&dev->mcg_table.sem); | 368 | mutex_unlock(&dev->mcg_table.mutex); |
375 | err_sem: | 369 | |
376 | mthca_free_mailbox(dev, mailbox); | 370 | mthca_free_mailbox(dev, mailbox); |
377 | return err; | 371 | return err; |
378 | } | 372 | } |
@@ -389,7 +383,7 @@ int __devinit mthca_init_mcg_table(struct mthca_dev *dev) | |||
389 | if (err) | 383 | if (err) |
390 | return err; | 384 | return err; |
391 | 385 | ||
392 | init_MUTEX(&dev->mcg_table.sem); | 386 | mutex_init(&dev->mcg_table.mutex); |
393 | 387 | ||
394 | return 0; | 388 | return 0; |
395 | } | 389 | } |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 9fb985a016e9..d709cb162a72 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
@@ -50,7 +50,7 @@ enum { | |||
50 | }; | 50 | }; |
51 | 51 | ||
52 | struct mthca_user_db_table { | 52 | struct mthca_user_db_table { |
53 | struct semaphore mutex; | 53 | struct mutex mutex; |
54 | struct { | 54 | struct { |
55 | u64 uvirt; | 55 | u64 uvirt; |
56 | struct scatterlist mem; | 56 | struct scatterlist mem; |
@@ -158,7 +158,7 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob | |||
158 | int ret = 0; | 158 | int ret = 0; |
159 | u8 status; | 159 | u8 status; |
160 | 160 | ||
161 | down(&table->mutex); | 161 | mutex_lock(&table->mutex); |
162 | 162 | ||
163 | if (table->icm[i]) { | 163 | if (table->icm[i]) { |
164 | ++table->icm[i]->refcount; | 164 | ++table->icm[i]->refcount; |
@@ -184,7 +184,7 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob | |||
184 | ++table->icm[i]->refcount; | 184 | ++table->icm[i]->refcount; |
185 | 185 | ||
186 | out: | 186 | out: |
187 | up(&table->mutex); | 187 | mutex_unlock(&table->mutex); |
188 | return ret; | 188 | return ret; |
189 | } | 189 | } |
190 | 190 | ||
@@ -198,7 +198,7 @@ void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int o | |||
198 | 198 | ||
199 | i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE; | 199 | i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE; |
200 | 200 | ||
201 | down(&table->mutex); | 201 | mutex_lock(&table->mutex); |
202 | 202 | ||
203 | if (--table->icm[i]->refcount == 0) { | 203 | if (--table->icm[i]->refcount == 0) { |
204 | mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, | 204 | mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, |
@@ -207,7 +207,7 @@ void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int o | |||
207 | table->icm[i] = NULL; | 207 | table->icm[i] = NULL; |
208 | } | 208 | } |
209 | 209 | ||
210 | up(&table->mutex); | 210 | mutex_unlock(&table->mutex); |
211 | } | 211 | } |
212 | 212 | ||
213 | void *mthca_table_find(struct mthca_icm_table *table, int obj) | 213 | void *mthca_table_find(struct mthca_icm_table *table, int obj) |
@@ -220,7 +220,7 @@ void *mthca_table_find(struct mthca_icm_table *table, int obj) | |||
220 | if (!table->lowmem) | 220 | if (!table->lowmem) |
221 | return NULL; | 221 | return NULL; |
222 | 222 | ||
223 | down(&table->mutex); | 223 | mutex_lock(&table->mutex); |
224 | 224 | ||
225 | idx = (obj & (table->num_obj - 1)) * table->obj_size; | 225 | idx = (obj & (table->num_obj - 1)) * table->obj_size; |
226 | icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE]; | 226 | icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE]; |
@@ -240,7 +240,7 @@ void *mthca_table_find(struct mthca_icm_table *table, int obj) | |||
240 | } | 240 | } |
241 | 241 | ||
242 | out: | 242 | out: |
243 | up(&table->mutex); | 243 | mutex_unlock(&table->mutex); |
244 | return page ? lowmem_page_address(page) + offset : NULL; | 244 | return page ? lowmem_page_address(page) + offset : NULL; |
245 | } | 245 | } |
246 | 246 | ||
@@ -301,7 +301,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, | |||
301 | table->num_obj = nobj; | 301 | table->num_obj = nobj; |
302 | table->obj_size = obj_size; | 302 | table->obj_size = obj_size; |
303 | table->lowmem = use_lowmem; | 303 | table->lowmem = use_lowmem; |
304 | init_MUTEX(&table->mutex); | 304 | mutex_init(&table->mutex); |
305 | 305 | ||
306 | for (i = 0; i < num_icm; ++i) | 306 | for (i = 0; i < num_icm; ++i) |
307 | table->icm[i] = NULL; | 307 | table->icm[i] = NULL; |
@@ -380,7 +380,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | |||
380 | if (index < 0 || index > dev->uar_table.uarc_size / 8) | 380 | if (index < 0 || index > dev->uar_table.uarc_size / 8) |
381 | return -EINVAL; | 381 | return -EINVAL; |
382 | 382 | ||
383 | down(&db_tab->mutex); | 383 | mutex_lock(&db_tab->mutex); |
384 | 384 | ||
385 | i = index / MTHCA_DB_REC_PER_PAGE; | 385 | i = index / MTHCA_DB_REC_PER_PAGE; |
386 | 386 | ||
@@ -424,7 +424,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | |||
424 | db_tab->page[i].refcount = 1; | 424 | db_tab->page[i].refcount = 1; |
425 | 425 | ||
426 | out: | 426 | out: |
427 | up(&db_tab->mutex); | 427 | mutex_unlock(&db_tab->mutex); |
428 | return ret; | 428 | return ret; |
429 | } | 429 | } |
430 | 430 | ||
@@ -439,11 +439,11 @@ void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | |||
439 | * pages until we clean up the whole db table. | 439 | * pages until we clean up the whole db table. |
440 | */ | 440 | */ |
441 | 441 | ||
442 | down(&db_tab->mutex); | 442 | mutex_lock(&db_tab->mutex); |
443 | 443 | ||
444 | --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount; | 444 | --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount; |
445 | 445 | ||
446 | up(&db_tab->mutex); | 446 | mutex_unlock(&db_tab->mutex); |
447 | } | 447 | } |
448 | 448 | ||
449 | struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev) | 449 | struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev) |
@@ -460,7 +460,7 @@ struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev) | |||
460 | if (!db_tab) | 460 | if (!db_tab) |
461 | return ERR_PTR(-ENOMEM); | 461 | return ERR_PTR(-ENOMEM); |
462 | 462 | ||
463 | init_MUTEX(&db_tab->mutex); | 463 | mutex_init(&db_tab->mutex); |
464 | for (i = 0; i < npages; ++i) { | 464 | for (i = 0; i < npages; ++i) { |
465 | db_tab->page[i].refcount = 0; | 465 | db_tab->page[i].refcount = 0; |
466 | db_tab->page[i].uvirt = 0; | 466 | db_tab->page[i].uvirt = 0; |
@@ -499,7 +499,7 @@ int mthca_alloc_db(struct mthca_dev *dev, enum mthca_db_type type, | |||
499 | int ret = 0; | 499 | int ret = 0; |
500 | u8 status; | 500 | u8 status; |
501 | 501 | ||
502 | down(&dev->db_tab->mutex); | 502 | mutex_lock(&dev->db_tab->mutex); |
503 | 503 | ||
504 | switch (type) { | 504 | switch (type) { |
505 | case MTHCA_DB_TYPE_CQ_ARM: | 505 | case MTHCA_DB_TYPE_CQ_ARM: |
@@ -585,7 +585,7 @@ found: | |||
585 | *db = (__be32 *) &page->db_rec[j]; | 585 | *db = (__be32 *) &page->db_rec[j]; |
586 | 586 | ||
587 | out: | 587 | out: |
588 | up(&dev->db_tab->mutex); | 588 | mutex_unlock(&dev->db_tab->mutex); |
589 | 589 | ||
590 | return ret; | 590 | return ret; |
591 | } | 591 | } |
@@ -601,7 +601,7 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index) | |||
601 | 601 | ||
602 | page = dev->db_tab->page + i; | 602 | page = dev->db_tab->page + i; |
603 | 603 | ||
604 | down(&dev->db_tab->mutex); | 604 | mutex_lock(&dev->db_tab->mutex); |
605 | 605 | ||
606 | page->db_rec[j] = 0; | 606 | page->db_rec[j] = 0; |
607 | if (i >= dev->db_tab->min_group2) | 607 | if (i >= dev->db_tab->min_group2) |
@@ -624,7 +624,7 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index) | |||
624 | ++dev->db_tab->min_group2; | 624 | ++dev->db_tab->min_group2; |
625 | } | 625 | } |
626 | 626 | ||
627 | up(&dev->db_tab->mutex); | 627 | mutex_unlock(&dev->db_tab->mutex); |
628 | } | 628 | } |
629 | 629 | ||
630 | int mthca_init_db_tab(struct mthca_dev *dev) | 630 | int mthca_init_db_tab(struct mthca_dev *dev) |
@@ -638,7 +638,7 @@ int mthca_init_db_tab(struct mthca_dev *dev) | |||
638 | if (!dev->db_tab) | 638 | if (!dev->db_tab) |
639 | return -ENOMEM; | 639 | return -ENOMEM; |
640 | 640 | ||
641 | init_MUTEX(&dev->db_tab->mutex); | 641 | mutex_init(&dev->db_tab->mutex); |
642 | 642 | ||
643 | dev->db_tab->npages = dev->uar_table.uarc_size / 4096; | 643 | dev->db_tab->npages = dev->uar_table.uarc_size / 4096; |
644 | dev->db_tab->max_group1 = 0; | 644 | dev->db_tab->max_group1 = 0; |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h index 4fdca26eea85..36f1141a08aa 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.h +++ b/drivers/infiniband/hw/mthca/mthca_memfree.h | |||
@@ -39,8 +39,7 @@ | |||
39 | 39 | ||
40 | #include <linux/list.h> | 40 | #include <linux/list.h> |
41 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
42 | 42 | #include <linux/mutex.h> | |
43 | #include <asm/semaphore.h> | ||
44 | 43 | ||
45 | #define MTHCA_ICM_CHUNK_LEN \ | 44 | #define MTHCA_ICM_CHUNK_LEN \ |
46 | ((256 - sizeof (struct list_head) - 2 * sizeof (int)) / \ | 45 | ((256 - sizeof (struct list_head) - 2 * sizeof (int)) / \ |
@@ -64,7 +63,7 @@ struct mthca_icm_table { | |||
64 | int num_obj; | 63 | int num_obj; |
65 | int obj_size; | 64 | int obj_size; |
66 | int lowmem; | 65 | int lowmem; |
67 | struct semaphore mutex; | 66 | struct mutex mutex; |
68 | struct mthca_icm *icm[0]; | 67 | struct mthca_icm *icm[0]; |
69 | }; | 68 | }; |
70 | 69 | ||
@@ -147,7 +146,7 @@ struct mthca_db_table { | |||
147 | int max_group1; | 146 | int max_group1; |
148 | int min_group2; | 147 | int min_group2; |
149 | struct mthca_db_page *page; | 148 | struct mthca_db_page *page; |
150 | struct semaphore mutex; | 149 | struct mutex mutex; |
151 | }; | 150 | }; |
152 | 151 | ||
153 | enum mthca_db_type { | 152 | enum mthca_db_type { |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 484a7e6b7f8c..e88e39aef85a 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -185,7 +185,7 @@ static int mthca_modify_port(struct ib_device *ibdev, | |||
185 | int err; | 185 | int err; |
186 | u8 status; | 186 | u8 status; |
187 | 187 | ||
188 | if (down_interruptible(&to_mdev(ibdev)->cap_mask_mutex)) | 188 | if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex)) |
189 | return -ERESTARTSYS; | 189 | return -ERESTARTSYS; |
190 | 190 | ||
191 | err = mthca_query_port(ibdev, port, &attr); | 191 | err = mthca_query_port(ibdev, port, &attr); |
@@ -207,7 +207,7 @@ static int mthca_modify_port(struct ib_device *ibdev, | |||
207 | } | 207 | } |
208 | 208 | ||
209 | out: | 209 | out: |
210 | up(&to_mdev(ibdev)->cap_mask_mutex); | 210 | mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex); |
211 | return err; | 211 | return err; |
212 | } | 212 | } |
213 | 213 | ||
@@ -1185,7 +1185,7 @@ int mthca_register_device(struct mthca_dev *dev) | |||
1185 | dev->ib_dev.post_recv = mthca_tavor_post_receive; | 1185 | dev->ib_dev.post_recv = mthca_tavor_post_receive; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | init_MUTEX(&dev->cap_mask_mutex); | 1188 | mutex_init(&dev->cap_mask_mutex); |
1189 | 1189 | ||
1190 | ret = ib_register_device(&dev->ib_dev); | 1190 | ret = ib_register_device(&dev->ib_dev); |
1191 | if (ret) | 1191 | if (ret) |