Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7148227ybi; Mon, 8 Jul 2019 15:36:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnNCsR/8X4dxgVq7xBT0e2FL+6SEBYRCF8xlPFlO89KxJDrcjzn1NmVBo6OUbbhuf9sB48 X-Received: by 2002:a17:90a:d343:: with SMTP id i3mr22344899pjx.15.1562625401291; Mon, 08 Jul 2019 15:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625401; cv=none; d=google.com; s=arc-20160816; b=xXAVsuwxBopn7Ofpkl/uhZbN2itKYmBs1kgdtXgs1ku/8DHMCE24XkzvDSb/SiNQEp 41UToqi/XrZ/v0F6/LiZxWQyLdSzmvX3NzqbziwxPmI3ywOpxVF27xw0E2VtRV3fzrcx fGSe1uLMjSeco0nRCMSX8Rv6VzgPUhK7lhYhKSGYGOQS37PWSxZ4GaZjZrGh0kov5icZ M45DOoeDcOMsZDPxgQGBp62jFo6TqK1Beoi9ZcBVS0lTjxCCDxP7XP8JiqAFQTHhEIS8 BdpKpX753+4eNa4HjpVh1sV6W8zoPzI7LcJznAH0JFik+JgOT1MOhRMh4tRCulvNR1b7 ismA== 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=TuainIevpwLi2lXjWPFMG/dWLN4CYyDFtbQSZD7Xi2w=; b=ug2OKMREDuZbJcUKylFTqbR0xKsO9tl4GhdUUIlnzavCHlF1WenpxUQgLLSld6lxkQ lIHw5lH4VzmBlXTwOxTZ/xzHI5Co2Hiuj2YzzlCntWTZ2aMhTRdzucSXVsUxgaBKkeAU tpPJbpggpIdbVd3sJpZq2uyCGCuD9zmNAWeENGr/nb6cDUxkDfYe1hDWlRPjUnFCNkhf GfAJ5MzDrJlX6seeQdjcWB9W1smOZFZi91Hig+6S6UH6A7k3ugYQUE9eaQNRZWlZJm53 TwMBR+bWUncE9wHaaEa2QLqFaOzuDGLDHCqSrymoNrRGXmknVFPgDK4xCWxREHcI87BT UMFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XGKRJEEO; 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 67si9360622pfv.74.2019.07.08.15.36.26; Mon, 08 Jul 2019 15:36:41 -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=XGKRJEEO; 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 S1731213AbfGHPXB (ORCPT + 99 others); Mon, 8 Jul 2019 11:23:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388096AbfGHPW7 (ORCPT ); Mon, 8 Jul 2019 11:22:59 -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 36B662166E; Mon, 8 Jul 2019 15:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599378; bh=FG0Fd4yCVaRhYLAoDH+EcpNxQWOhdpbmj1xXw0TZ748=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XGKRJEEO2lvY81DeFLprtjV6EdeLZa/GfRq5jtnDRmgYgHcFOSG83DgX5V690y+lz Sbgj/ve2f39TQ7f2os0vZ68y91KZj2jFKK6Tz6/ExxQrJLnlPxAHlPOuQE/Wg310bU r8JWKIFSkP6o6w8ufSMighsfImSE6cv+nMFOq9uA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gary Leshner , Mike Marciniszyn , Dennis Dalessandro , Jason Gunthorpe Subject: [PATCH 4.9 099/102] IB/hfi1: Close PSM sdma_progress sleep window Date: Mon, 8 Jul 2019 17:13:32 +0200 Message-Id: <20190708150531.607648948@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150525.973820964@linuxfoundation.org> References: <20190708150525.973820964@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 From: Mike Marciniszyn commit da9de5f8527f4b9efc82f967d29a583318c034c7 upstream. The call to sdma_progress() is called outside the wait lock. In this case, there is a race condition where sdma_progress() can return false and the sdma_engine can idle. If that happens, there will be no more sdma interrupts to cause the wakeup and the user_sdma xmit will hang. Fix by moving the lock to enclose the sdma_progress() call. Also, delete busycount. The need for this was removed by: commit bcad29137a97 ("IB/hfi1: Serve the most starved iowait entry first") Cc: Fixes: 7724105686e7 ("IB/hfi1: add driver files") Reviewed-by: Gary Leshner Signed-off-by: Mike Marciniszyn Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/hfi1/user_sdma.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) --- a/drivers/infiniband/hw/hfi1/user_sdma.c +++ b/drivers/infiniband/hw/hfi1/user_sdma.c @@ -260,7 +260,6 @@ struct user_sdma_txreq { struct list_head list; struct user_sdma_request *req; u16 flags; - unsigned busycount; u64 seqnum; }; @@ -323,25 +322,22 @@ static int defer_packet_queue( struct hfi1_user_sdma_pkt_q *pq = container_of(wait, struct hfi1_user_sdma_pkt_q, busy); struct hfi1_ibdev *dev = &pq->dd->verbs_dev; - struct user_sdma_txreq *tx = - container_of(txreq, struct user_sdma_txreq, txreq); - if (sdma_progress(sde, seq, txreq)) { - if (tx->busycount++ < MAX_DEFER_RETRY_COUNT) - goto eagain; - } + write_seqlock(&dev->iowait_lock); + if (sdma_progress(sde, seq, txreq)) + goto eagain; /* * We are assuming that if the list is enqueued somewhere, it * is to the dmawait list since that is the only place where * it is supposed to be enqueued. */ xchg(&pq->state, SDMA_PKT_Q_DEFERRED); - write_seqlock(&dev->iowait_lock); if (list_empty(&pq->busy.list)) list_add_tail(&pq->busy.list, &sde->dmawait); write_sequnlock(&dev->iowait_lock); return -EBUSY; eagain: + write_sequnlock(&dev->iowait_lock); return -EAGAIN; } @@ -925,7 +921,6 @@ static int user_sdma_send_pkts(struct us tx->flags = 0; tx->req = req; - tx->busycount = 0; INIT_LIST_HEAD(&tx->list); if (req->seqnum == req->info.npkts - 1)