Received: by 10.192.165.156 with SMTP id m28csp242284imm; Tue, 17 Apr 2018 09:22:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+fFeTis4ta+IppanETPRRVrM+4QkHBaSh5lXoRdEgu22d63o9Eb1HrpRldOqQmmlEoQHAH X-Received: by 10.167.128.194 with SMTP id a2mr2579139pfn.130.1523982151246; Tue, 17 Apr 2018 09:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982151; cv=none; d=google.com; s=arc-20160816; b=mLpsl72qMS7q44ATmAtpvbgbiMf/sraRficL5a8sBXAXrQ5aix9XompKT1HCtG9X4I y+H36XEOGIf2H4HRPJFbE0G5Sve9UxiDY15ZpqcAh+YM+PHUNVo6mJV1s4wT05kOhdFs Oe+zeYkOd5encPlPWSkM5vUInQ9LTVtYYuJZsu+G7+e3GW6H8XnUSOFvbCviI4jxwVox N4x+md04AUlL0gxj6eof0YWg2SsEGqMiidouy0oZhkVlesO0OOYK6iT+ZSjSW2OKtaVn XkeDkzJNQ7XhtE/l11B+1Y0Az03YAE2dVOGhUSw8znPPWfEKLtaZgYAM5HjuOj0mn2ix +fZA== 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=wIQWCOsg85h6wMSH/xWypRz5PfQfEFwWxE9qdcOBWM0=; b=fOZgv0sxrR+ty/6zOUfnQ441TFamDzUgjcgePmNo/QAx2PMBv+bd6/QrV7pzFvIn/H gVNeFyRCoLyklqZVnE9nul8wV7kUvyPYcsgaLqXjrt6E6Ndlw8M9Wn2oMiQd4oNv6cR7 syIZzNBi4+mJt3C7AgTMpTc2r2D56JnbW4QDjtbmcWV6gppJpceU9Op60q+XMKAiwwWV Hlq9Mf0QcDSW+6zVgKkXJKPipcz4u57CKyZXw7SGI7fGT/+UsOyihkWre5zpmGtEjLJU lcEi8wOsmorVR543D9WFPyXdDfzLVB8oQXYXnI2Yjs/D4c4Nl5aWkHMlvom3qhiXX+c0 LnRw== 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 a13si12891403pfi.138.2018.04.17.09.22.17; Tue, 17 Apr 2018 09:22:31 -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 S1755838AbeDQQKZ (ORCPT + 99 others); Tue, 17 Apr 2018 12:10:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36388 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755798AbeDQQKV (ORCPT ); Tue, 17 Apr 2018 12:10:21 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7A132D0B; Tue, 17 Apr 2018 16:10:20 +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.9 56/66] s390/qdio: dont merge ERROR output buffers Date: Tue, 17 Apr 2018 17:59:29 +0200 Message-Id: <20180417155648.311568901@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@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.9-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;