aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@mellanox.co.il>2006-01-30 19:22:29 -0500
committerRoland Dreier <rolandd@cisco.com>2006-01-30 19:22:29 -0500
commite3aa31c517cb6fd0a3d8b23e6a7e71a6aafc2393 (patch)
tree97c1ca504dc60a7b380be402b91af59a4a8f8e04 /drivers
parent8e9e5f4f5eb1d44ddabfd1ddea4ca4e4244a9ffb (diff)
IB/mthca: Don't cancel commands on a signal
We have run into the following problem: if a task receives a signal while in the process of e.g. destroying a resource (which could be because the relevant file was closed) mthca could bail out from trying to take a command interface semaphore without performing the appropriate command to tell hardware that the resource is being destroyed. As a result we see messages like ib_mthca 0000:04:00.0: HW2SW_CQ failed (-4) In this case, hardware could access the resource after the memory has been freed, possibly causing memory corruption. A simple solution is to replace down_interruptible() by down() in command interface activation. Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il> [ It's also not safe to bail out on multicast table operations, since they may be invoked on the cleanup path too. So use down() for mcg_table.sem too. ] Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c9
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c14
2 files changed, 7 insertions, 16 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index be1791be627b..69128fe60c53 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 down(&dev->cmd.hcr_sem);
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;
@@ -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);
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index 77bc6c746f43..55ff5e5bcfef 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 down(&dev->mcg_table.sem);
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)
@@ -242,7 +239,7 @@ int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
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 up(&dev->mcg_table.sem);
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 down(&dev->mcg_table.sem);
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)
@@ -372,7 +366,7 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
372 366
373 out: 367 out:
374 up(&dev->mcg_table.sem); 368 up(&dev->mcg_table.sem);
375 err_sem: 369
376 mthca_free_mailbox(dev, mailbox); 370 mthca_free_mailbox(dev, mailbox);
377 return err; 371 return err;
378} 372}