From patchwork Tue Jan 9 19:23:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10153213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E77C601A1 for ; Tue, 9 Jan 2018 19:23:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EE851FE8D for ; Tue, 9 Jan 2018 19:23:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83AA71FF29; Tue, 9 Jan 2018 19:23:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF0CF1FE8D for ; Tue, 9 Jan 2018 19:23:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935417AbeAITXl (ORCPT ); Tue, 9 Jan 2018 14:23:41 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:7909 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933847AbeAITXk (ORCPT ); Tue, 9 Jan 2018 14:23:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1515526612; x=1547062612; h=from:to:cc:subject:date:message-id; bh=nSFMgLniDcDR6Cxs+k71rKuOZcYT2VxgWu4FrTqbRFo=; b=iPa61jh8UbHfk/5x1nJ2+mG/x11neI3+zV1zK0KmrBOZ85/c5Ilud0GN KSjm4wfM4zrAL/Kob8xiIyXBcrkYZRBNL39mEdgV39+AlYkP+8SdSBFa2 wx2phTlRjzrlQwmesmipyxMUXCAfmC1dktHrKw3hCWRN0/pFHWULQCwPu 6D+VvESl+pWGixNJXHZf9m6Rh6qZb+BzsZPl8DSMqRzS2iEwClnAI68nN FoMvOOfRHE0hbEVZiiWnsEGEEWhCuwVPVONTg9uch/+aAmpNrx44ju8sD ZHppyDs60D7kn65Yseuxq/jPlEmGeVCaR4E8OSpEZVLvi5/QLu0UNaDh0 A==; X-IronPort-AV: E=Sophos;i="5.46,336,1511798400"; d="scan'208";a="164642193" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Jan 2018 03:36:51 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 09 Jan 2018 11:19:14 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip01.wdc.com with ESMTP; 09 Jan 2018 11:23:40 -0800 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , Moni Shoua , stable@vger.kernel.org Subject: [PATCH] RDMA/rxe: Fix a race condition related to the QP error state Date: Tue, 9 Jan 2018 11:23:40 -0800 Message-Id: <20180109192340.25702-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The following sequence: * Change queue pair state into IB_QPS_ERR. * Post a work request on the queue pair. Triggers the following race condition in the rdma_rxe driver: * rxe_qp_error() triggers an asynchronous call of rxe_completer(), the function that examines the QP send queue. * rxe_post_send() posts a work request on the QP send queue. Avoid that this race causes a work request to be ignored by scheduling an rxe_completer() call from rxe_post_send() for queues that are in the error state. Signed-off-by: Bart Van Assche Cc: Moni Shoua Cc: # v4.8 --- drivers/infiniband/sw/rxe/rxe_verbs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index a6fbed48db8a..8f631d64c192 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -814,6 +814,8 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, struct ib_send_wr *wr, (queue_count(qp->sq.queue) > 1); rxe_run_task(&qp->req.task, must_sched); + if (unlikely(qp->req.state == QP_STATE_ERROR)) + rxe_run_task(&qp->comp.task, 1); return err; }