Home Home > GIT Browse > SLE12-SP4
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.cz>2019-08-08 18:57:13 +0200
committerPetr Tesarik <ptesarik@suse.cz>2019-08-08 21:17:10 +0200
commit4da951d30ba5e10cfec56e72477baaa6f5e195a0 (patch)
treed359dbc5172d30b981230c0cb4b8726bda5cb3a6
parent4f6b2c544b156a81b6bfab6636e7d080373fc1f8 (diff)
s390/qeth: simplify reply object handling (bsc#1142109
LTC#179339).
-rw-r--r--patches.fixes/s390-qeth-simplify-reply-object-handling231
-rw-r--r--series.conf1
2 files changed, 232 insertions, 0 deletions
diff --git a/patches.fixes/s390-qeth-simplify-reply-object-handling b/patches.fixes/s390-qeth-simplify-reply-object-handling
new file mode 100644
index 0000000000..0865c1617f
--- /dev/null
+++ b/patches.fixes/s390-qeth-simplify-reply-object-handling
@@ -0,0 +1,231 @@
+From: Julian Wiedmann <jwi@linux.ibm.com>
+Date: Tue, 12 Feb 2019 18:33:21 +0100
+Subject: s390/qeth: simplify reply object handling
+Git-commit: 0951c6babf49d2f2429cbfbea5cf792d427ecc6a
+Patch-mainline: v5.1-rc1
+References: bsc#1142109 LTC#179339
+
+Current code enqueues & dequeues a reply object from the waiter list
+in various places. In particular, the dequeue & enqueue in
+qeth_send_control_data_cb() looks fragile - this can cause
+qeth_clear_ipacmd_list() to skip the active object.
+Add some helpers, and boil the logic down by giving
+qeth_send_control_data() the sole responsibility to add and remove
+objects.
+
+qeth_send_control_data_cb() and qeth_clear_ipacmd_list() will now only
+notify the reply object to interrupt its wait cycle. This can cause
+a slight delay in the removal, but that's no concern.
+
+Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[ ptesarik: Replace spin_unlock_irqrestore() instead of spin_unlock_irq()
+ as an alternative to backporting ed47155bdcf38ff5a0f419b7a833dcbe49cb8abc ]
+Signed-off-by: Petr Tesarik <ptesarik@suse.com>
+---
+ drivers/s390/net/qeth_core_main.c | 118 +++++++++++++++++++-------------------
+ 1 file changed, 61 insertions(+), 57 deletions(-)
+
+--- a/drivers/s390/net/qeth_core_main.c
++++ b/drivers/s390/net/qeth_core_main.c
+@@ -585,6 +585,7 @@ static struct qeth_reply *qeth_alloc_rep
+ if (reply) {
+ atomic_set(&reply->refcnt, 1);
+ atomic_set(&reply->received, 0);
++ init_waitqueue_head(&reply->wait_q);
+ reply->card = card;
+ }
+ return reply;
+@@ -603,6 +604,26 @@ static void qeth_put_reply(struct qeth_r
+ kfree(reply);
+ }
+
++static void qeth_enqueue_reply(struct qeth_card *card, struct qeth_reply *reply)
++{
++ spin_lock_irq(&card->lock);
++ list_add_tail(&reply->list, &card->cmd_waiter_list);
++ spin_unlock_irq(&card->lock);
++}
++
++static void qeth_dequeue_reply(struct qeth_card *card, struct qeth_reply *reply)
++{
++ spin_lock_irq(&card->lock);
++ list_del(&reply->list);
++ spin_unlock_irq(&card->lock);
++}
++
++static void qeth_notify_reply(struct qeth_reply *reply)
++{
++ atomic_inc(&reply->received);
++ wake_up(&reply->wait_q);
++}
++
+ static void qeth_issue_ipa_msg(struct qeth_ipa_cmd *cmd, int rc,
+ struct qeth_card *card)
+ {
+@@ -699,19 +720,15 @@ static struct qeth_ipa_cmd *qeth_check_i
+
+ void qeth_clear_ipacmd_list(struct qeth_card *card)
+ {
+- struct qeth_reply *reply, *r;
++ struct qeth_reply *reply;
+ unsigned long flags;
+
+ QETH_CARD_TEXT(card, 4, "clipalst");
+
+ spin_lock_irqsave(&card->lock, flags);
+- list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) {
+- qeth_get_reply(reply);
++ list_for_each_entry(reply, &card->cmd_waiter_list, list) {
+ reply->rc = -EIO;
+- atomic_inc(&reply->received);
+- list_del_init(&reply->list);
+- wake_up(&reply->wait_q);
+- qeth_put_reply(reply);
++ qeth_notify_reply(reply);
+ }
+ spin_unlock_irqrestore(&card->lock, flags);
+ }
+@@ -833,10 +850,11 @@ static void qeth_send_control_data_cb(st
+ struct qeth_cmd_buffer *iob)
+ {
+ struct qeth_card *card;
+- struct qeth_reply *reply, *r;
++ struct qeth_reply *reply = NULL;
++ struct qeth_reply *r;
+ struct qeth_ipa_cmd *cmd;
+ unsigned long flags;
+- int keep_reply;
++ int keep_reply = 0;
+ int rc = 0;
+
+ card = CARD_FROM_CDEV(channel->ccwdev);
+@@ -865,44 +883,40 @@ static void qeth_send_control_data_cb(st
+ goto out;
+ }
+
++ /* match against pending cmd requests */
+ spin_lock_irqsave(&card->lock, flags);
+- list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) {
+- if ((reply->seqno == QETH_IDX_COMMAND_SEQNO) ||
+- ((cmd) && (reply->seqno == cmd->hdr.seqno))) {
++ list_for_each_entry(r, &card->cmd_waiter_list, list) {
++ if ((r->seqno == QETH_IDX_COMMAND_SEQNO) ||
++ (cmd && (r->seqno == cmd->hdr.seqno))) {
++ reply = r;
++ /* take the object outside the lock */
+ qeth_get_reply(reply);
+- list_del_init(&reply->list);
+- spin_unlock_irqrestore(&card->lock, flags);
+- keep_reply = 0;
+- if (reply->callback != NULL) {
+- if (cmd) {
+- reply->offset = (__u16)((char *)cmd -
+- (char *)iob->data);
+- keep_reply = reply->callback(card,
+- reply,
+- (unsigned long)cmd);
+- } else
+- keep_reply = reply->callback(card,
+- reply,
+- (unsigned long)iob);
+- }
+- if (cmd)
+- reply->rc = (u16) cmd->hdr.return_code;
+- else if (iob->rc)
+- reply->rc = iob->rc;
+- if (keep_reply) {
+- spin_lock_irqsave(&card->lock, flags);
+- list_add_tail(&reply->list,
+- &card->cmd_waiter_list);
+- spin_unlock_irqrestore(&card->lock, flags);
+- } else {
+- atomic_inc(&reply->received);
+- wake_up(&reply->wait_q);
+- }
+- qeth_put_reply(reply);
+- goto out;
++ break;
+ }
+ }
+ spin_unlock_irqrestore(&card->lock, flags);
++
++ if (!reply)
++ goto out;
++
++ if (reply->callback) {
++ if (cmd) {
++ reply->offset = (u16)((char *)cmd - (char *)iob->data);
++ keep_reply = reply->callback(card, reply,
++ (unsigned long)cmd);
++ } else
++ keep_reply = reply->callback(card, reply,
++ (unsigned long)iob);
++ }
++ if (cmd)
++ reply->rc = (u16) cmd->hdr.return_code;
++ else if (iob->rc)
++ reply->rc = iob->rc;
++
++ if (!keep_reply)
++ qeth_notify_reply(reply);
++ qeth_put_reply(reply);
++
+ out:
+ memcpy(&card->seqno.pdu_hdr_ack,
+ QETH_PDU_HEADER_SEQ_NO(iob->data),
+@@ -2105,8 +2119,6 @@ int qeth_send_control_data(struct qeth_c
+ reply->callback = reply_cb;
+ reply->param = reply_param;
+
+- init_waitqueue_head(&reply->wait_q);
+-
+ while (atomic_cmpxchg(&card->write.irq_pending, 0, 1)) ;
+
+ if (IS_IPA(iob->data)) {
+@@ -2120,9 +2132,7 @@ int qeth_send_control_data(struct qeth_c
+ }
+ qeth_prepare_control_data(card, len, iob);
+
+- spin_lock_irqsave(&card->lock, flags);
+- list_add_tail(&reply->list, &card->cmd_waiter_list);
+- spin_unlock_irqrestore(&card->lock, flags);
++ qeth_enqueue_reply(card, reply);
+ timeout = jiffies + event_timeout;
+
+ QETH_CARD_TEXT(card, 6, "noirqpnd");
+@@ -2134,10 +2144,8 @@ int qeth_send_control_data(struct qeth_c
+ QETH_DBF_MESSAGE(2, "qeth_send_control_data on device %x: ccw_device_start rc = %i\n",
+ CARD_DEVID(card), rc);
+ QETH_CARD_TEXT_(card, 2, " err%d", rc);
+- spin_lock_irqsave(&card->lock, flags);
+- list_del_init(&reply->list);
++ qeth_dequeue_reply(card, reply);
+ qeth_put_reply(reply);
+- spin_unlock_irqrestore(&card->lock, flags);
+ qeth_release_buffer(iob->channel, iob);
+ atomic_set(&card->write.irq_pending, 0);
+ wake_up(&card->wait_q);
+@@ -2159,19 +2167,15 @@ int qeth_send_control_data(struct qeth_c
+ }
+ }
+
++ qeth_dequeue_reply(card, reply);
+ rc = reply->rc;
+ qeth_put_reply(reply);
+ return rc;
+
+ time_err:
+- reply->rc = -ETIME;
+- spin_lock_irqsave(&reply->card->lock, flags);
+- list_del_init(&reply->list);
+- spin_unlock_irqrestore(&reply->card->lock, flags);
+- atomic_inc(&reply->received);
+- rc = reply->rc;
++ qeth_dequeue_reply(card, reply);
+ qeth_put_reply(reply);
+- return rc;
++ return -ETIME;
+ }
+ EXPORT_SYMBOL_GPL(qeth_send_control_data);
+
diff --git a/series.conf b/series.conf
index 74066a9a20..fb1749c85e 100644
--- a/series.conf
+++ b/series.conf
@@ -21557,6 +21557,7 @@
patches.drivers/iwlwifi-mvm-fix-A-MPDU-reference-assignment.patch
patches.fixes/0001-iwiwifi-fix-bad-monitor-buffer-register-addresses.patch
patches.drivers/mt7601u-bump-supported-EEPROM-version.patch
+ patches.fixes/s390-qeth-simplify-reply-object-handling
patches.fixes/0001-cxgb4vf-Few-more-link-management-changes.patch
patches.fixes/0001-cxgb4-cxgb4vf-Add-support-for-SGE-doorbell-queue-tim.patch
patches.fixes/0001-cxgb4-Add-capability-to-get-set-SGE-Doorbell-Queue-T.patch