Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp343376pxk; Fri, 11 Sep 2020 08:25:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnWxkcVe7X6gSnDqePajArgILwvAVgS/2RP81/fMRHr/Gp8ScNPqGCqPk2Op2Z5I5ysQRt X-Received: by 2002:a17:906:1f08:: with SMTP id w8mr2507451ejj.181.1599837903749; Fri, 11 Sep 2020 08:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599837903; cv=none; d=google.com; s=arc-20160816; b=HzoLdrQYt7GdzU5aa84qnYrkNnrea8NOY/Ymm9JHGK+LNMi9fN/gCJBRCxtFeJKrrw DwLV1InuSqXG5kFPCxPy3owZY7LIMxJaB6uorrresMDWtXS+cCntpnr5FrKkTzFbqSi0 b5yaoAYu88dA7sS1OcMrIgmoMuyeDEl23ykaG10lGWLR4lV2p+zMPxlKQYucTczGYygl 9rQjgFvuF6Jc8+4DHlleHeWxcFU4YAamVD6/pRtVuottarUj+LP+K3BaNShug8BbKvJM 9I1mjWiljuGKY5vQp+KEFeyjqoEUfn78hK/IOhEBskE1EobUp5l7eMWukcBEJW5CLN+u RGmA== 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=/nRWFP+NiavZDvyOuK/7KUKCK2rFX7fU56LmtGZDpAQ=; b=Me7vn6QKFpwxWFpaKla5U4TXS3hPWQ7jSN1tJU9iiR5EXpT6DE59+xqaAumI/fac/m rmcfULofAW6ksMip1tKt0ILOeZOtchcuxu8sQWCUTw9Su7RLxrAIt3FGvZqg7oXH/kP1 0QtixeOdUVnTR8VQ445vSP5olDS6PmBCRxsWsvk5erqw1jGr0nmFt8+a4Pwk05e/XuJd ZrZ6H7Ey+ASDvBhk3V7rBYaaZFDwB35fvNbk5aMMgijIImvbQY6UTw0prVqT2TwHSKO5 /Fxrb7MAsJ4dRrfonCqJrJbrDv7zmMhTeiQX8eb00s5GaaWuYWUxwz/ZAnSMb8INRLNt EsDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z9q6Kea6; 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=fail (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 n23si1523040edw.337.2020.09.11.08.24.40; Fri, 11 Sep 2020 08:25:03 -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=@kernel.org header.s=default header.b=z9q6Kea6; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725869AbgIKPUs (ORCPT + 99 others); Fri, 11 Sep 2020 11:20:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:52724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbgIKPPh (ORCPT ); Fri, 11 Sep 2020 11:15:37 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 9703F2220E; Fri, 11 Sep 2020 12:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829191; bh=cQtmOpOnoutgoobVVbzdL9HIMhuV7J7M5jnbYHFYGus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z9q6Kea61bu+b3P+IYnrTOUtynVrwve/Vh9RD9EJ4lc8iGITWsl9dXY+iAeMRLi1v iMnBXPQ0aC/zrylit0Kq6HVcKpdCycTwVL0nUo62sVrT3vvtuyJIsWL5nZiIlnsbVZ 95xno4AvUemBi5L/Py6sLW7Q6BJHTC6na3bp/Ogk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.8 03/16] RDMA/cma: Simplify DEVICE_REMOVAL for internal_id Date: Fri, 11 Sep 2020 14:47:20 +0200 Message-Id: <20200911122459.754211677@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122459.585735377@linuxfoundation.org> References: <20200911122459.585735377@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: Jason Gunthorpe [ Upstream commit d54f23c09ec62670901f1a2a4712a5218522ca2b ] cma_process_remove() triggers an unconditional rdma_destroy_id() for internal_id's and skips the event deliver and transition through RDMA_CM_DEVICE_REMOVAL. This is confusing and unnecessary. internal_id always has cma_listen_handler() as the handler, have it catch the RDMA_CM_DEVICE_REMOVAL event and directly consume it and signal removal. This way the FSM sequence never skips the DEVICE_REMOVAL case and the logic in this hard to test area is simplified. Link: https://lore.kernel.org/r/20200723070707.1771101-2-leon@kernel.org Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/cma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index c30cf5307ce3e..537eeebde5f4d 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -2482,6 +2482,10 @@ static int cma_listen_handler(struct rdma_cm_id *id, { struct rdma_id_private *id_priv = id->context; + /* Listening IDs are always destroyed on removal */ + if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) + return -1; + id->context = id_priv->id.context; id->event_handler = id_priv->id.event_handler; trace_cm_event_handler(id_priv, event); @@ -4829,7 +4833,7 @@ static void cma_process_remove(struct cma_device *cma_dev) cma_id_get(id_priv); mutex_unlock(&lock); - ret = id_priv->internal_id ? 1 : cma_remove_id_dev(id_priv); + ret = cma_remove_id_dev(id_priv); cma_id_put(id_priv); if (ret) rdma_destroy_id(&id_priv->id); -- 2.25.1