Commit 54daaca7 authored by Julian Wiedmann's avatar Julian Wiedmann Committed by David S. Miller

s390/qeth: cancel cmd on early error

When sending cmds via qeth_send_control_data(), qeth puts the request
on the IO channel and then blocks on the reply object until the response
has been received.

If the IO completes with error, there will never be a response and we
block until the reply-wait hits its timeout. For this case, connect the
request buffer to its reply object, so that we can immediately cancel
the wait.
Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0951c6ba
...@@ -595,6 +595,7 @@ struct qeth_channel; ...@@ -595,6 +595,7 @@ struct qeth_channel;
struct qeth_cmd_buffer { struct qeth_cmd_buffer {
enum qeth_cmd_buffer_state state; enum qeth_cmd_buffer_state state;
struct qeth_channel *channel; struct qeth_channel *channel;
struct qeth_reply *reply;
unsigned char *data; unsigned char *data;
int rc; int rc;
void (*callback)(struct qeth_card *card, struct qeth_channel *channel, void (*callback)(struct qeth_card *card, struct qeth_channel *channel,
......
...@@ -743,6 +743,10 @@ void qeth_release_buffer(struct qeth_channel *channel, ...@@ -743,6 +743,10 @@ void qeth_release_buffer(struct qeth_channel *channel,
spin_lock_irqsave(&channel->iob_lock, flags); spin_lock_irqsave(&channel->iob_lock, flags);
iob->state = BUF_STATE_FREE; iob->state = BUF_STATE_FREE;
iob->callback = qeth_send_control_data_cb; iob->callback = qeth_send_control_data_cb;
if (iob->reply) {
qeth_put_reply(iob->reply);
iob->reply = NULL;
}
iob->rc = 0; iob->rc = 0;
spin_unlock_irqrestore(&channel->iob_lock, flags); spin_unlock_irqrestore(&channel->iob_lock, flags);
wake_up(&channel->wait_q); wake_up(&channel->wait_q);
...@@ -756,6 +760,17 @@ static void qeth_release_buffer_cb(struct qeth_card *card, ...@@ -756,6 +760,17 @@ static void qeth_release_buffer_cb(struct qeth_card *card,
qeth_release_buffer(channel, iob); qeth_release_buffer(channel, iob);
} }
static void qeth_cancel_cmd(struct qeth_cmd_buffer *iob, int rc)
{
struct qeth_reply *reply = iob->reply;
if (reply) {
reply->rc = rc;
qeth_notify_reply(reply);
}
qeth_release_buffer(iob->channel, iob);
}
static struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *channel) static struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *channel)
{ {
struct qeth_cmd_buffer *buffer = NULL; struct qeth_cmd_buffer *buffer = NULL;
...@@ -990,9 +1005,8 @@ static int qeth_get_problem(struct qeth_card *card, struct ccw_device *cdev, ...@@ -990,9 +1005,8 @@ static int qeth_get_problem(struct qeth_card *card, struct ccw_device *cdev,
return 0; return 0;
} }
static long qeth_check_irb_error(struct qeth_card *card, static int qeth_check_irb_error(struct qeth_card *card, struct ccw_device *cdev,
struct ccw_device *cdev, unsigned long intparm, unsigned long intparm, struct irb *irb)
struct irb *irb)
{ {
if (!IS_ERR(irb)) if (!IS_ERR(irb))
return 0; return 0;
...@@ -1003,7 +1017,7 @@ static long qeth_check_irb_error(struct qeth_card *card, ...@@ -1003,7 +1017,7 @@ static long qeth_check_irb_error(struct qeth_card *card,
CCW_DEVID(cdev)); CCW_DEVID(cdev));
QETH_CARD_TEXT(card, 2, "ckirberr"); QETH_CARD_TEXT(card, 2, "ckirberr");
QETH_CARD_TEXT_(card, 2, " rc%d", -EIO); QETH_CARD_TEXT_(card, 2, " rc%d", -EIO);
break; return -EIO;
case -ETIMEDOUT: case -ETIMEDOUT:
dev_warn(&cdev->dev, "A hardware operation timed out" dev_warn(&cdev->dev, "A hardware operation timed out"
" on the device\n"); " on the device\n");
...@@ -1015,14 +1029,14 @@ static long qeth_check_irb_error(struct qeth_card *card, ...@@ -1015,14 +1029,14 @@ static long qeth_check_irb_error(struct qeth_card *card,
wake_up(&card->wait_q); wake_up(&card->wait_q);
} }
} }
break; return -ETIMEDOUT;
default: default:
QETH_DBF_MESSAGE(2, "unknown error %ld on channel %x\n", QETH_DBF_MESSAGE(2, "unknown error %ld on channel %x\n",
PTR_ERR(irb), CCW_DEVID(cdev)); PTR_ERR(irb), CCW_DEVID(cdev));
QETH_CARD_TEXT(card, 2, "ckirberr"); QETH_CARD_TEXT(card, 2, "ckirberr");
QETH_CARD_TEXT(card, 2, " rc???"); QETH_CARD_TEXT(card, 2, " rc???");
}
return PTR_ERR(irb); return PTR_ERR(irb);
}
} }
static void qeth_irq(struct ccw_device *cdev, unsigned long intparm, static void qeth_irq(struct ccw_device *cdev, unsigned long intparm,
...@@ -1057,10 +1071,11 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm, ...@@ -1057,10 +1071,11 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm,
if (qeth_intparm_is_iob(intparm)) if (qeth_intparm_is_iob(intparm))
iob = (struct qeth_cmd_buffer *) __va((addr_t)intparm); iob = (struct qeth_cmd_buffer *) __va((addr_t)intparm);
if (qeth_check_irb_error(card, cdev, intparm, irb)) { rc = qeth_check_irb_error(card, cdev, intparm, irb);
if (rc) {
/* IO was terminated, free its resources. */ /* IO was terminated, free its resources. */
if (iob) if (iob)
qeth_release_buffer(iob->channel, iob); qeth_cancel_cmd(iob, rc);
atomic_set(&channel->irq_pending, 0); atomic_set(&channel->irq_pending, 0);
wake_up(&card->wait_q); wake_up(&card->wait_q);
return; return;
...@@ -1116,7 +1131,7 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm, ...@@ -1116,7 +1131,7 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm,
if (rc) { if (rc) {
card->read_or_write_problem = 1; card->read_or_write_problem = 1;
if (iob) if (iob)
qeth_release_buffer(iob->channel, iob); qeth_cancel_cmd(iob, rc);
qeth_clear_ipacmd_list(card); qeth_clear_ipacmd_list(card);
qeth_schedule_recovery(card); qeth_schedule_recovery(card);
goto out; goto out;
...@@ -2061,6 +2076,10 @@ static int qeth_send_control_data(struct qeth_card *card, int len, ...@@ -2061,6 +2076,10 @@ static int qeth_send_control_data(struct qeth_card *card, int len,
reply->callback = reply_cb; reply->callback = reply_cb;
reply->param = reply_param; reply->param = reply_param;
/* pairs with qeth_release_buffer(): */
qeth_get_reply(reply);
iob->reply = reply;
while (atomic_cmpxchg(&channel->irq_pending, 0, 1)) ; while (atomic_cmpxchg(&channel->irq_pending, 0, 1)) ;
if (IS_IPA(iob->data)) { if (IS_IPA(iob->data)) {
......
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