Received: by 10.192.165.156 with SMTP id m28csp254226imm; Tue, 17 Apr 2018 09:34:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+OnTWQtf7u7kdbHQfr9tgMCCCkVrZHL3vob559pCzuuSEb30K6P9XXbjTGGTRjf7YSzYVI X-Received: by 2002:a17:902:2a43:: with SMTP id i61-v6mr2752666plb.54.1523982887489; Tue, 17 Apr 2018 09:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982887; cv=none; d=google.com; s=arc-20160816; b=TVEbMkXrEbjRkgPpUWknqs+Gd7fAjJJDoZQ3X57CCZIhK6UlvS2Hke+Mfx8b9WMnJM 5Ag0FgDoKfEUDosNTAwkCeDSbzkdOoWloYEp6b/KYI6jsS4ft8/1tPSHd4ueWEC9FjH6 iJ1vKuqYj9g+ZU9b91xn6MHtopF+IWfWfr/ksQS9VnpXIJLQkzF055GfLBzOy0AAX4Ys +KbPdswGnjRzOgM7sIQt5wDXXp9SKZn6Zaj+LiOTL2x84kvfMMg4vk1DOM3bV4Uolsj0 WQZv0rV7E4iPyVmwJ/GoEWmYTE0JfMsDl+RwTcr541qeETSCI7B/mnjB2JnBM00XKQOm BxHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dB95ZcsX0f+rfd7f8FQRTYnGgkQkN2ecJ6BenYWS9gQ=; b=0oc5N7nCyNQCVEFHg2LWY1J/OQaqfAFRkjF+91fLrJ7pmKmTiqH+w+gXFUGZfAiXUS DMWmDxAynto2NgrX21l1car8iTgG70kssjXepzWcmtnkTV3PCzYhALMlZ3vv9U7Vh3BZ HRfUquv5BgU0z5iNkqg8mBfccR5DP7h79cbFYTqPo8B7qbCayWd0n7H/6q7K6mObocbw GlCf02GrZOcrcAY6SqhpDYPiud0HNEP813eEMnhu6ReK2OpczHurTWVYDMLHsMejxfGs ZqIGz96KdfGonNw1kP6SpJlQvbsdVSkpCBXralI1j2h9UCBYs2vfR1ve4VmlWY15g9yH T6Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o128si12431191pfg.5.2018.04.17.09.34.32; Tue, 17 Apr 2018 09:34:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754371AbeDQQdL (ORCPT + 99 others); Tue, 17 Apr 2018 12:33:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35266 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754464AbeDQQHo (ORCPT ); Tue, 17 Apr 2018 12:07:44 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 35253E6C; Tue, 17 Apr 2018 16:07:43 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Wiedmann , Ursula Braun , Benjamin Block , Martin Schwidefsky Subject: [PATCH 4.14 29/49] s390/qdio: dont merge ERROR output buffers Date: Tue, 17 Apr 2018 17:59:08 +0200 Message-Id: <20180417155716.411762706@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155715.032245882@linuxfoundation.org> References: <20180417155715.032245882@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Julian Wiedmann commit 0cf1e05157b9e5530dcc3ca9fec9bf617fc93375 upstream. On an Output queue, both EMPTY and PENDING buffer states imply that the buffer is ready for completion-processing by the upper-layer drivers. So for a non-QEBSM Output queue, get_buf_states() merges mixed batches of PENDING and EMPTY buffers into one large batch of EMPTY buffers. The upper-layer driver (ie. qeth) later distuingishes PENDING from EMPTY by inspecting the slsb_state for QDIO_OUTBUF_STATE_FLAG_PENDING. But the merge logic in get_buf_states() contains a bug that causes us to erronously also merge ERROR buffers into such a batch of EMPTY buffers (ERROR is 0xaf, EMPTY is 0xa1; so ERROR & EMPTY == EMPTY). Effectively, most outbound ERROR buffers are currently discarded silently and processed as if they had succeeded. Note that this affects _all_ non-QEBSM device types, not just IQD with CQ. Fix it by explicitly spelling out the exact conditions for merging. For extracting the "get initial state" part out of the loop, this relies on the fact that get_buf_states() is never called with a count of 0. The QEBSM path already strictly requires this, and the two callers with variable 'count' make sure of it. Fixes: 104ea556ee7f ("qdio: support asynchronous delivery of storage blocks") Cc: #v3.2+ Signed-off-by: Julian Wiedmann Reviewed-by: Ursula Braun Reviewed-by: Benjamin Block Signed-off-by: Martin Schwidefsky Signed-off-by: Greg Kroah-Hartman --- drivers/s390/cio/qdio_main.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) --- a/drivers/s390/cio/qdio_main.c +++ b/drivers/s390/cio/qdio_main.c @@ -205,7 +205,10 @@ again: return 0; } -/* returns number of examined buffers and their common state in *state */ +/* + * Returns number of examined buffers and their common state in *state. + * Requested number of buffers-to-examine must be > 0. + */ static inline int get_buf_states(struct qdio_q *q, unsigned int bufnr, unsigned char *state, unsigned int count, int auto_ack, int merge_pending) @@ -216,17 +219,23 @@ static inline int get_buf_states(struct if (is_qebsm(q)) return qdio_do_eqbs(q, state, bufnr, count, auto_ack); - for (i = 0; i < count; i++) { - if (!__state) { - __state = q->slsb.val[bufnr]; - if (merge_pending && __state == SLSB_P_OUTPUT_PENDING) - __state = SLSB_P_OUTPUT_EMPTY; - } else if (merge_pending) { - if ((q->slsb.val[bufnr] & __state) != __state) - break; - } else if (q->slsb.val[bufnr] != __state) - break; + /* get initial state: */ + __state = q->slsb.val[bufnr]; + if (merge_pending && __state == SLSB_P_OUTPUT_PENDING) + __state = SLSB_P_OUTPUT_EMPTY; + + for (i = 1; i < count; i++) { bufnr = next_buf(bufnr); + + /* merge PENDING into EMPTY: */ + if (merge_pending && + q->slsb.val[bufnr] == SLSB_P_OUTPUT_PENDING && + __state == SLSB_P_OUTPUT_EMPTY) + continue; + + /* stop if next state differs from initial state: */ + if (q->slsb.val[bufnr] != __state) + break; } *state = __state; return i;