Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp271418pxx; Wed, 28 Oct 2020 04:39:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDqHvl/LgjiUcXf8yEQceXbSbElY0qUFZWeBolgJNbLFVkzeymAmHEzvlLNHT0f7lJctN0 X-Received: by 2002:a17:906:4d4f:: with SMTP id b15mr6982496ejv.356.1603885168001; Wed, 28 Oct 2020 04:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603885167; cv=none; d=google.com; s=arc-20160816; b=lqdQi2KFSDY+M4Jf7l24FUFXAmoYsWHy6gPV73coGIbljuPMA4t3DVmAOKYuSLvSdk pvaI0j1OzaWcxXl5s183ht+S9k3k366uRWOuzum7DctjJSfKG0jcvG5eGlnWoC0guvy2 p54hjj4Bt5DQwCpe59X+ZAVwBslyyctFyE0OQnhxoig1KkG3V1gBiuks60ngFnikyHoO QlzUQSNbcr/p9WJG/lHNPWMzL1VLVezasbran40nbkBJDu+GvqfO7v8vArsXHQWbhG/P 4CuBTaI02u60Cus8zEz0dFHFM+5gzGJvbVW2iW6OPiMSJNUsPwcwRN5uP/7h8pU8vtvo CWbQ== 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=MaC+i3n1zIwSA3Yu1lqbHGWUf4pTIB+RUzPICuTVQ/o=; b=azz1Z6Pw95Q/nCi9LJ7NVIhUHLXNnHGInDYsEJi1g4gSFO5Q6fpi2ap2cieFJef7b0 t1iU5QJtSh0YmbKo1tVSrfNdW2dWVBeQqHrGfwOueYXs/nHj0fJjGh+wXm4q87T+pSeE 3xSSe3T43JECBk8+4R0lzivSdQ1Nor7yKOFlFnRWtwD8WzwYC7U5U5wp8FIxorF1/khq gQ76EA6SSBNFnWAmX79TJxrEIG14+sctE4FBTSYU6DdIksCl5dFqHwYKqYI0iGqK8P5V k9keQSZScptxWtdO4t0MydpUx3gzdDuEPG3m5HeBl5KlE7J0MNEAXBK70u8eHEKwOaej PK5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xSMd0zP5; 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 g1si3663191edn.100.2020.10.28.04.39.06; Wed, 28 Oct 2020 04:39:27 -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=xSMd0zP5; 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 S1794033AbgJ0PJp (ORCPT + 99 others); Tue, 27 Oct 2020 11:09:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:39552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1790947AbgJ0PE4 (ORCPT ); Tue, 27 Oct 2020 11:04:56 -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 1004720747; Tue, 27 Oct 2020 15:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811095; bh=W9QpIclGZ0WZ0Y6/YpKZ3tuzzlm414oatb6onhoQkyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xSMd0zP5Wb44Jjl68V6rgiXZr2twsmDSXFpewgOnRBL0ukMroeeMc/IvkXfAfwH53 RHcDZtZzwHXZ+l01CYPsx9xC0+UaWAqZDIoILuu4QSdQT5LirdK9cfkofYkfzQu18q 0mzqFTaI0UifBF17kHhv+8Fa24/HNG8A4/ddy7MY= 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 371/633] RDMA/cma: Combine cma_ndev_work with cma_work Date: Tue, 27 Oct 2020 14:51:54 +0100 Message-Id: <20201027135540.106537983@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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: Jason Gunthorpe [ Upstream commit 7e85bcda8bfe883f4244672ed79f81b7762a1a7e ] These are the same thing, except that cma_ndev_work doesn't have a state transition. Signal no state transition by setting old_state and new_state == 0. In all cases the handler function should not be called once rdma_destroy_id() has progressed passed setting the state. Link: https://lore.kernel.org/r/20200902081122.745412-6-leon@kernel.org Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/cma.c | 38 +++++++---------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 26de0dab60bbb..015b2fe509dca 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -363,12 +363,6 @@ struct cma_work { struct rdma_cm_event event; }; -struct cma_ndev_work { - struct work_struct work; - struct rdma_id_private *id; - struct rdma_cm_event event; -}; - struct iboe_mcast_work { struct work_struct work; struct rdma_id_private *id; @@ -2646,32 +2640,14 @@ static void cma_work_handler(struct work_struct *_work) struct rdma_id_private *id_priv = work->id; mutex_lock(&id_priv->handler_mutex); - if (!cma_comp_exch(id_priv, work->old_state, work->new_state)) + if (READ_ONCE(id_priv->state) == RDMA_CM_DESTROYING || + READ_ONCE(id_priv->state) == RDMA_CM_DEVICE_REMOVAL) goto out_unlock; - - if (cma_cm_event_handler(id_priv, &work->event)) { - cma_id_put(id_priv); - destroy_id_handler_unlock(id_priv); - goto out_free; + if (work->old_state != 0 || work->new_state != 0) { + if (!cma_comp_exch(id_priv, work->old_state, work->new_state)) + goto out_unlock; } -out_unlock: - mutex_unlock(&id_priv->handler_mutex); - cma_id_put(id_priv); -out_free: - kfree(work); -} - -static void cma_ndev_work_handler(struct work_struct *_work) -{ - struct cma_ndev_work *work = container_of(_work, struct cma_ndev_work, work); - struct rdma_id_private *id_priv = work->id; - - mutex_lock(&id_priv->handler_mutex); - if (id_priv->state == RDMA_CM_DESTROYING || - id_priv->state == RDMA_CM_DEVICE_REMOVAL) - goto out_unlock; - if (cma_cm_event_handler(id_priv, &work->event)) { cma_id_put(id_priv); destroy_id_handler_unlock(id_priv); @@ -4652,7 +4628,7 @@ EXPORT_SYMBOL(rdma_leave_multicast); static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id_priv) { struct rdma_dev_addr *dev_addr; - struct cma_ndev_work *work; + struct cma_work *work; dev_addr = &id_priv->id.route.addr.dev_addr; @@ -4665,7 +4641,7 @@ static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id if (!work) return -ENOMEM; - INIT_WORK(&work->work, cma_ndev_work_handler); + INIT_WORK(&work->work, cma_work_handler); work->id = id_priv; work->event.event = RDMA_CM_EVENT_ADDR_CHANGE; cma_id_get(id_priv); -- 2.25.1