Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp840809ybi; Fri, 12 Jul 2019 05:32:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzO1omULTw3KVljmOh1EGD/gpMTfCDvAwU5CC+leRMs4wJBFevNQLtb0MmyH1dpVv4W5NES X-Received: by 2002:a17:902:9896:: with SMTP id s22mr10778900plp.4.1562934732891; Fri, 12 Jul 2019 05:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934732; cv=none; d=google.com; s=arc-20160816; b=XseNpBpEEQn2F3jU3Mdhw3AaLWIDht8U1HpTDTYTUn61nwh3+bO7SMR2i1ZbGXWcNp M46FeWpHAS4kCKGHLZgw/XY2Z5gn73pW6QwaLg6eG34uE/H7Q4ox0OJDRJePDgPqVcRY 51WV/KmDGWoy2jQXb21+xGUZBBYMsHXP5d9/+GuOZ3IevBGfXZF7WJGGcrnuy6SJ1Zuw 2tLxHVCijwQPKc+na/6n+kwUNfxgTxeT1wPm9suOjp8ANcponxVbWludKQApL6Ho58jF /tWHwso+pxbs4VgGnkTIthObcTRNMImGRRvvZNRfAtkJuuMZ7/JSkeKl+jVJDZc/Apga MF1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RRWbAT6+Qekw+WcuewgHnSzhPpBNG9bKG8LMMfT6GZ0=; b=gwuL8Iykwc0T7okXK7AobDJdc67Z3CjB78dXFE6Gxm5h6mob+XNbHQi4PWTRLaf7T6 7pNCzCnVxnEfg18qpK36rN1TdXpZZtSK6S0uraQVOoEEOKnZbKu8KMNMhWtkNB4iZ//0 YHDez4tQk6SHxieP6zAONU4iN4CRlfV6v4nQQqRb7lVI//HHfMK86xOB14JrnQrKENm9 iHYevDTM71S0IvL/yUAje4pxGplC73mJaiUT8lBRIO5phTYqTtx4/nMg/0iCSW0b0xzi cqg0IRtGuWPPgaPOTn28WSYwvi0g/N0DML9ruAwjhl/cYO3TUq5vajLfddtnm/5/IGCd 3mTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=degALWQo; 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 n13si7497104plp.354.2019.07.12.05.31.57; Fri, 12 Jul 2019 05:32:12 -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; dkim=pass header.i=@kernel.org header.s=default header.b=degALWQo; 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 S1729038AbfGLM3u (ORCPT + 99 others); Fri, 12 Jul 2019 08:29:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:44838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728264AbfGLM3o (ORCPT ); Fri, 12 Jul 2019 08:29:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D562521019; Fri, 12 Jul 2019 12:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934583; bh=l+gQSEoRDnqdO8m78BRffvFCVtI5c3S8E0DX7f9ql/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=degALWQoCupx3GVm7j5lFDlbu4G75iDjgKbd5G+tMt7d1sv0ca5UD9KQSMzc4oyoU J3KPiiMY2MAJHpz1KWSH6+0vOy1tv2gUyWkqw7/7k9NNf8FJ6wO2vOGdusbKZJXRvO 4oC9YmKaBveEMcMTkJ3nkMkFdq8n7qI/9YlU4QVE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Dalessandro , Mike Marciniszyn , Doug Ledford , Sasha Levin Subject: [PATCH 5.1 076/138] IB/hfi1: Handle port down properly in pio Date: Fri, 12 Jul 2019 14:19:00 +0200 Message-Id: <20190712121631.621836127@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 942a899335707fc9cfc97cb382a60734b2ff4e03 ] The call to sc_buffer_alloc currently returns NULL (no buffer) or a buffer descriptor. There is a third case when the port is down. Currently that returns NULL and this prevents the caller from properly handling the sc_buffer_alloc() failure. A verbs code link test after the call is racy so the indication needs to come from the state check inside the allocation routine to be valid. Fix by encoding the ECOMM failure like SDMA. IS_ERR_OR_NULL() tests are added at all call sites. For verbs send, this needs to treat any error by returning a completion without any MMIO copy. Fixes: 7724105686e7 ("IB/hfi1: add driver files") Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Dennis Dalessandro Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin --- drivers/infiniband/hw/hfi1/pio.c | 5 +++-- drivers/infiniband/hw/hfi1/rc.c | 2 +- drivers/infiniband/hw/hfi1/ud.c | 4 ++-- drivers/infiniband/hw/hfi1/verbs.c | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c index 1ee47838d4de..17ea224fbecb 100644 --- a/drivers/infiniband/hw/hfi1/pio.c +++ b/drivers/infiniband/hw/hfi1/pio.c @@ -1443,7 +1443,8 @@ void sc_stop(struct send_context *sc, int flag) * @cb: optional callback to call when the buffer is finished sending * @arg: argument for cb * - * Return a pointer to a PIO buffer if successful, NULL if not enough room. + * Return a pointer to a PIO buffer, NULL if not enough room, -ECOMM + * when link is down. */ struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len, pio_release_cb cb, void *arg) @@ -1459,7 +1460,7 @@ struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len, spin_lock_irqsave(&sc->alloc_lock, flags); if (!(sc->flags & SCF_ENABLED)) { spin_unlock_irqrestore(&sc->alloc_lock, flags); - goto done; + return ERR_PTR(-ECOMM); } retry: diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c index 24cbac277bf0..b7b74222eaf0 100644 --- a/drivers/infiniband/hw/hfi1/rc.c +++ b/drivers/infiniband/hw/hfi1/rc.c @@ -1434,7 +1434,7 @@ void hfi1_send_rc_ack(struct hfi1_packet *packet, bool is_fecn) pbc = create_pbc(ppd, pbc_flags, qp->srate_mbps, sc_to_vlt(ppd->dd, sc5), plen); pbuf = sc_buffer_alloc(rcd->sc, plen, NULL, NULL); - if (!pbuf) { + if (IS_ERR_OR_NULL(pbuf)) { /* * We have no room to send at the moment. Pass * responsibility for sending the ACK to the send engine diff --git a/drivers/infiniband/hw/hfi1/ud.c b/drivers/infiniband/hw/hfi1/ud.c index f88ad425664a..4cb0fce5c096 100644 --- a/drivers/infiniband/hw/hfi1/ud.c +++ b/drivers/infiniband/hw/hfi1/ud.c @@ -683,7 +683,7 @@ void return_cnp_16B(struct hfi1_ibport *ibp, struct rvt_qp *qp, pbc = create_pbc(ppd, pbc_flags, qp->srate_mbps, vl, plen); if (ctxt) { pbuf = sc_buffer_alloc(ctxt, plen, NULL, NULL); - if (pbuf) { + if (!IS_ERR_OR_NULL(pbuf)) { trace_pio_output_ibhdr(ppd->dd, &hdr, sc5); ppd->dd->pio_inline_send(ppd->dd, pbuf, pbc, &hdr, hwords); @@ -738,7 +738,7 @@ void return_cnp(struct hfi1_ibport *ibp, struct rvt_qp *qp, u32 remote_qpn, pbc = create_pbc(ppd, pbc_flags, qp->srate_mbps, vl, plen); if (ctxt) { pbuf = sc_buffer_alloc(ctxt, plen, NULL, NULL); - if (pbuf) { + if (!IS_ERR_OR_NULL(pbuf)) { trace_pio_output_ibhdr(ppd->dd, &hdr, sc5); ppd->dd->pio_inline_send(ppd->dd, pbuf, pbc, &hdr, hwords); diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c index 63d62ac7434a..117e73cd69d7 100644 --- a/drivers/infiniband/hw/hfi1/verbs.c +++ b/drivers/infiniband/hw/hfi1/verbs.c @@ -1039,10 +1039,10 @@ int hfi1_verbs_send_pio(struct rvt_qp *qp, struct hfi1_pkt_state *ps, if (cb) iowait_pio_inc(&priv->s_iowait); pbuf = sc_buffer_alloc(sc, plen, cb, qp); - if (unlikely(!pbuf)) { + if (unlikely(IS_ERR_OR_NULL(pbuf))) { if (cb) verbs_pio_complete(qp, 0); - if (ppd->host_link_state != HLS_UP_ACTIVE) { + if (IS_ERR(pbuf)) { /* * If we have filled the PIO buffers to capacity and are * not in an active state this request is not going to -- 2.20.1