Received: by 10.192.165.148 with SMTP id m20csp2476584imm; Sun, 22 Apr 2018 07:51:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/eVPq+kL8oNZ196yI/Lt/vWxLVz1NuHLbpC0iaRlJzV/wj52OzAYf/nYSwTQztG76OOlFE X-Received: by 10.101.102.198 with SMTP id c6mr13160716pgw.127.1524408680730; Sun, 22 Apr 2018 07:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408680; cv=none; d=google.com; s=arc-20160816; b=xGpvuyM6O/512xIB/J8KiFutUMb60PjlW+62RVqEZU8BRiv5NOUQ92LkBqTdWWQmoe 6xTQz2pFk1pWOkHPgx94FSkP18sww1ogPsrK0zm11Jc3tkJqqG1RfPEdsX+vPtBt11OG FD8yImjqcQuImNumjPAnsNAGJ180a585/w2R1HJ/nK3GweGjfxOy937yF8ANtgLTRdpB Ei7d/i6gAcHlpGwoKBoHp2Fk5aUMwwuVIZHPbm/pDShCEFy4R2pGZcwg9v7OfNn7sePP UXPXPHGGQ8j2rJnqGxkijpJlaTlu7YAWEgFFzJ8FN9kXwIQtHDsxcdfOhljkZKDigGdU RPHQ== 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=FDyAQDqBD44bvJohCxFXYt2KJRUYZZPUcdKQaLdZry8=; b=ouT10GPCM/ec89p6LShBrooIN8q90vJNTyEKzwMZgXpBYXYwHB7P93zZjVCMiomatE jpZsDERiI/xmW1jghClGro5UesrkYQgMT1SBbyUCGEL0+3oxSnpH6Gz6Bpi0MC4iojA5 +9rrY7V1tgvy7qw/d07Yau1leMwAMMhaHGETyA4RMICAaQ92R1Z0bXgmy/DVxiArbcyD pYG6S2mDYPYeDcmJ0a5HxzwowvnlFFAbQJRyU3d71/Sw2aAWt8v23OEwZA2vQqSxP+Z7 1aY/0vWoBhcfD7YA0qZnKGnBxAWZLJlKhpyzsZDgmmazPpNtHDCaCpFoORC+7pTRcIlt Cd2w== 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 r8-v6si6323035pli.119.2018.04.22.07.51.06; Sun, 22 Apr 2018 07:51:20 -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 S1757098AbeDVOPh (ORCPT + 99 others); Sun, 22 Apr 2018 10:15:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56902 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757073AbeDVOPd (ORCPT ); Sun, 22 Apr 2018 10:15:33 -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 4EC3C12; Sun, 22 Apr 2018 14:15:32 +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.4 11/97] s390/qdio: dont merge ERROR output buffers Date: Sun, 22 Apr 2018 15:52:49 +0200 Message-Id: <20180422135305.268750746@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@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.4-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;