Received: by 10.192.165.148 with SMTP id m20csp2462402imm; Sun, 22 Apr 2018 07:32:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/LcLYvu7jxbEZ+CNSRx9X8q6Hg0GQEsUtWW0sVZTeUTJIPPIqBAUJGTudnrN9lX1qgla9J X-Received: by 10.99.112.29 with SMTP id l29mr14091288pgc.299.1524407570473; Sun, 22 Apr 2018 07:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524407570; cv=none; d=google.com; s=arc-20160816; b=uWVAepjEH4iqU9T3+1kxdb6Uxsji5toRDJ7RAj7gJoCUk0AlpkPJwlpUuKAJU4VTth Vmc4GbnP4l2V0hnJ6eIuZoIszfMEgu9au42ibY9S1dJ+wvHz9NFjEFGxD/LEFJdj7PMr u3DF5trQJU/Tp790PCutLcP58pNt4bWy4ws3dR9+DH5bVXdBUXlXhXekfC+LORp4bIg5 NZaMMtMNa5jmAnaApXqWTkGjw6wE1ia/zqyhU/cVKt8a5mo0FqxOLuh5k4ZQjKzSnLPJ sUNs/ZTxNJqVNWRAFQ399IP/S6rWSEK2pJ8MjZLhRASPKrTWImMlBvlKqerZqfYi9E1p qQsA== 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=U8G01TGY6rvvSvad/OJYNmSdfNgdgZw3bzzEXyskFpc=; b=Ib93sHK8IWsOjkvzhRDgFwugqK/efsSPia7F9NO2jTL5nNls1WyfvUDQdABUFkaTHF ae3Ikyj2sXDOvF2lpwuL70uOPdXWgTBGY+jwlEAsXL88wLiH8PaNPMyymhhRqWtvuETf TCbV94TjE24Q8RABQOQ7nTHzODAlYZkIruNtlYwf0Fp/7OluwTqVWpxF1YlhAdp5pHIF Jz45cQOOAH8+99Vd/lKXwlC3NhbB8OC8n4zJl1RWZhIqDavJqh+xiO7ZBuQG/ibV3izQ ALcaL+h9f2JjUr9NwBfh++SDPEcJW52kmlMt6UF2lBo/mB8lNT8wLxThxb4HzdcsPIYT oHow== 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 v196si8396380pgb.460.2018.04.22.07.32.36; Sun, 22 Apr 2018 07:32:50 -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 S932513AbeDVObC (ORCPT + 99 others); Sun, 22 Apr 2018 10:31:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60474 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757422AbeDVOUc (ORCPT ); Sun, 22 Apr 2018 10:20:32 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 64779486; Sun, 22 Apr 2018 14:20:31 +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 3.18 04/52] s390/qdio: dont merge ERROR output buffers Date: Sun, 22 Apr 2018 15:53:37 +0200 Message-Id: <20180422135315.430171671@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135315.254787616@linuxfoundation.org> References: <20180422135315.254787616@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 3.18-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;