Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3055427ybi; Tue, 2 Jul 2019 01:15:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCoZv31CFM2GZbRoMk6X5lgvHBZtRI5QdqqqEzTR3eCh9wqMpWfOx2MNCJxVre1lGFeawL X-Received: by 2002:a17:902:d915:: with SMTP id c21mr34327264plz.335.1562055318994; Tue, 02 Jul 2019 01:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055318; cv=none; d=google.com; s=arc-20160816; b=gmJWenJ6F4xup9BLNks6nKuir0MaN85PmceePUPjcv0ANIFIl9Dc/S8s8U7iHNVfNF eZTQ+RHsMwkftTbORUSYnN7BHZWzLWw/e773Y24XhrdgNtNhFDgwmf4oTALdXoQaug0y EZ3cqozBwHvE6NUv0AMOSQJ4W9QTnXZkOFz1adPo/2cXVrNZQGrMbDQ+QYCbmt76LhtL wzF0XxJDXdFd6+sXbgDwEwkdPV9nFIEmHk0xeSUqpHXtPbU+3BszcdZ8D//oA2D3kT4m +hVlvQFEaYviokkCDwYuEa1sBI715iqqLkcNbV4+FuiyKBDsKFw089Ez5Sdj0PU+l979 RIUg== 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=Nm1/8dzW42J66X0r7S/c0xmONrI43k8PE8S4Wyyc3xA=; b=HQV0bYOmDYOZc2+CxG9SzV1upxmhqV6OHgUm+kgRPphFBlAj5zQzCg7NHr4QOlEO7G G6RTTkaSCmm4Rr+gloi5kgghlwRn0DXXPtkLz52/R6+sytVyR1Sk2SGRAErzZpMixxWP 1GiJuRi9H7ZSMdGYDLa54EcyLqJ9NHr4RuB+ERVz82JAPN2bRQwgn+y4gjooW1eIFW77 W2lapv5YbpOeTge7iON/ZA7CM1ZwyDVsJgO+cSbjiyeq/9XuTpl4b7rNatv4A8g3KKNu yI0O3sGMWjTP02zm/5bfHu3CTDi9KJYphUMqbkQywxZIPMO/9bLzDFoIJE4mQKihe8jc jYaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2vd1jLyN; 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 h4si1748504pje.41.2019.07.02.01.15.04; Tue, 02 Jul 2019 01:15:18 -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=2vd1jLyN; 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 S1727893AbfGBIOq (ORCPT + 99 others); Tue, 2 Jul 2019 04:14:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:52048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727531AbfGBIFt (ORCPT ); Tue, 2 Jul 2019 04:05:49 -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 301272183F; Tue, 2 Jul 2019 08:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054748; bh=KcIwiM76cBXR6HzC1v2sUfIl8HXgUi3OAHBFsnfnKyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2vd1jLyNAf7vQILnWP9W/kXR7U2eFM4bDlYqGgFDO0If8lXzT0a9NavlMEro8wyYL lDB3PoiSX00HsKFjeMm5STQLNpwlMc9rfHF7fpozMtdExb90C83s9Civmy9Y5VO6bA dRD8MWQqsMHgUg7IIyChiuYJQHy9f3Ki7EnY1S9Q= 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 , Sasha Levin Subject: [PATCH 4.19 06/72] IB/hfi1: Close PSM sdma_progress sleep window Date: Tue, 2 Jul 2019 10:01:07 +0200 Message-Id: <20190702080124.894472662@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@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 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") Ported to linux-4.19.y. 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: Sasha Levin --- drivers/infiniband/hw/hfi1/user_sdma.c | 12 ++++-------- drivers/infiniband/hw/hfi1/user_sdma.h | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c index 51831bfbf90f..cbff746d9e9d 100644 --- a/drivers/infiniband/hw/hfi1/user_sdma.c +++ b/drivers/infiniband/hw/hfi1/user_sdma.c @@ -132,25 +132,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)) iowait_queue(pkts_sent, &pq->busy, &sde->dmawait); write_sequnlock(&dev->iowait_lock); return -EBUSY; eagain: + write_sequnlock(&dev->iowait_lock); return -EAGAIN; } @@ -803,7 +800,6 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts) tx->flags = 0; tx->req = req; - tx->busycount = 0; INIT_LIST_HEAD(&tx->list); /* diff --git a/drivers/infiniband/hw/hfi1/user_sdma.h b/drivers/infiniband/hw/hfi1/user_sdma.h index 91c343f91776..2c056702d975 100644 --- a/drivers/infiniband/hw/hfi1/user_sdma.h +++ b/drivers/infiniband/hw/hfi1/user_sdma.h @@ -245,7 +245,6 @@ struct user_sdma_txreq { struct list_head list; struct user_sdma_request *req; u16 flags; - unsigned int busycount; u64 seqnum; }; -- 2.20.1