Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2828063pxb; Mon, 1 Nov 2021 02:40:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo+v1omd6LkKL91kCYt3UHki9Kgt312BIRu8wx7oWg55zJ7dRhMpam84XxgGZ3mw6pOkM1 X-Received: by 2002:a50:bf08:: with SMTP id f8mr38351795edk.400.1635759621669; Mon, 01 Nov 2021 02:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759621; cv=none; d=google.com; s=arc-20160816; b=NHP9lpcmGc6LtQX1z946ZGdzJWPfEtnKg0dsovd9AeFnBu9cRVVHgvw+tpAxk5Ff+J xL6rUBOjhEamtV82S43fOQIPxCoYwCmDE8PT0I6M+KHV9fhZE2rGGNcLexwhYStT262I FYKUHu6uTSd/CoLIEH4TM+wSY2Wdyg3WwMtImMyeVQDKGqamwtImlgyLJZb3kLp90Yr0 2gbargapCDEAnNEscNzP2hBahkIaVe4ya95WZkGpxiHL2McgFQ59imYjCo+THJFwn9jI r/dPkoxU13k4KZbCWkTiLEWg454kiDI9H0Jx52hrDz9mYiqlBVgjCuGFrq6Snhl2aCNY ANAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pUPSAYl1EjDdm6bXpPxsLWUhXqHWGXNz0a5l4sNVPcc=; b=gtkwHUe3/D6IVhBv/jvvqiONK4lQFHcD8DnJQWnumcbJnk2/ydFDDOHPxMgWGTKqEX DfIN3id9py/ZvGIh1Dtrz3fUIHe3tKysFcEA1TPdmRG09WFSn3NuKkmQWEffWq7yxw9Q s/JHM2jcwrdvLmCTnSxxbv8WNu9inQMK/9C3lH4980200Hv0htXatrrc+csi6grMavGm QRgntr5ByioUDc3RxEyiBHs2cc6JZeddhK1hWkV0HCTghfCqvPxGeHOMMWQOqWJgz7A5 QCu87rXArPlM/00w7yxXOPowLbs1xB0muTuYWVgmf3EQW45epgOG5vm13ejmJl5Gjl6z /x1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lv1k9Gkj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di4si17222705ejc.217.2021.11.01.02.39.56; Mon, 01 Nov 2021 02:40:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lv1k9Gkj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233687AbhKAJki (ORCPT + 99 others); Mon, 1 Nov 2021 05:40:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:43674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233250AbhKAJh5 (ORCPT ); Mon, 1 Nov 2021 05:37:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AF9846135E; Mon, 1 Nov 2021 09:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758819; bh=YQrqZ+hp/Vwdu7IJKKeZURnxa8c0+4XmeibeupmRxcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lv1k9GkjttkjFHz/xKOSqdMxsC69SbxfdOUELKMGm6jzjJORLGaTApGcu4bp9nMHM ETZp/aqTyO1vbCEhfSOhMj5f00sUC7pqouHQLolydnIX6rJpV7Ir5GqOawMyINM6kS typwpANR2RTttsVyWxKjdWxzjz17YnuKTNXrOxIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Marciniszyn , TOTE Robot , Dennis Dalessandro , Jason Gunthorpe Subject: [PATCH 5.10 40/77] IB/hfi1: Fix abba locking issue with sc_disable() Date: Mon, 1 Nov 2021 10:17:28 +0100 Message-Id: <20211101082520.314026290@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082511.254155853@linuxfoundation.org> References: <20211101082511.254155853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Marciniszyn commit 13bac861952a78664907a0f927d3e874e9a59034 upstream. sc_disable() after having disabled the send context wakes up any waiters by calling hfi1_qp_wakeup() while holding the waitlock for the sc. This is contrary to the model for all other calls to hfi1_qp_wakeup() where the waitlock is dropped and a local is used to drive calls to hfi1_qp_wakeup(). Fix by moving the sc->piowait into a local list and driving the wakeup calls from the list. Fixes: 099a884ba4c0 ("IB/hfi1: Handle wakeup of orphaned QPs for pio") Link: https://lore.kernel.org/r/20211013141852.128104.2682.stgit@awfm-01.cornelisnetworks.com Signed-off-by: Mike Marciniszyn Reported-by: TOTE Robot Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/hfi1/pio.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/infiniband/hw/hfi1/pio.c +++ b/drivers/infiniband/hw/hfi1/pio.c @@ -920,6 +920,7 @@ void sc_disable(struct send_context *sc) { u64 reg; struct pio_buf *pbuf; + LIST_HEAD(wake_list); if (!sc) return; @@ -954,19 +955,21 @@ void sc_disable(struct send_context *sc) spin_unlock(&sc->release_lock); write_seqlock(&sc->waitlock); - while (!list_empty(&sc->piowait)) { + if (!list_empty(&sc->piowait)) + list_move(&sc->piowait, &wake_list); + write_sequnlock(&sc->waitlock); + while (!list_empty(&wake_list)) { struct iowait *wait; struct rvt_qp *qp; struct hfi1_qp_priv *priv; - wait = list_first_entry(&sc->piowait, struct iowait, list); + wait = list_first_entry(&wake_list, struct iowait, list); qp = iowait_to_qp(wait); priv = qp->priv; list_del_init(&priv->s_iowait.list); priv->s_iowait.lock = NULL; hfi1_qp_wakeup(qp, RVT_S_WAIT_PIO | HFI1_S_WAIT_PIO_DRAIN); } - write_sequnlock(&sc->waitlock); spin_unlock_irq(&sc->alloc_lock); }