From patchwork Wed Dec 5 15:14:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Wise X-Patchwork-Id: 10714747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5160C17D5 for ; Wed, 5 Dec 2018 18:51:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43C682E1C6 for ; Wed, 5 Dec 2018 18:51:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37A3B2E1CF; Wed, 5 Dec 2018 18:51:47 +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.3 required=2.0 tests=BAYES_00,DATE_IN_PAST_03_06, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 C6C022E1CA for ; Wed, 5 Dec 2018 18:51:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbeLESvq (ORCPT ); Wed, 5 Dec 2018 13:51:46 -0500 Received: from opengridcomputing.com ([72.48.214.68]:51410 "EHLO smtp.opengridcomputing.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727297AbeLESvq (ORCPT ); Wed, 5 Dec 2018 13:51:46 -0500 Received: by smtp.opengridcomputing.com (Postfix, from userid 503) id C296A227AF; Wed, 5 Dec 2018 12:51:45 -0600 (CST) Message-Id: In-Reply-To: References: From: Steve Wise Date: Wed, 5 Dec 2018 07:14:17 -0800 Subject: [PATCH v6 2/4] rdma_rxe: schedule rxe_net_remove() To: dledford@redhat.com, jgg@mellanox.com Cc: linux-rdma@vger.kernel.org, BMT@zurich.ibm.com, leon@kernel.org, markb@mellanox.com, yanjun.zhu@oracle.com 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 Schedule rxe_net_remove() to run in a workqueue context to avoid a deadlock when processing NETDEV_UNREGISTER events. Signed-off-by: Steve Wise --- drivers/infiniband/sw/rxe/rxe.c | 1 + drivers/infiniband/sw/rxe/rxe_net.c | 12 +++++++++++- drivers/infiniband/sw/rxe/rxe_net.h | 1 + drivers/infiniband/sw/rxe/rxe_verbs.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c index 971f0862cefe..19d8e522b72b 100644 --- a/drivers/infiniband/sw/rxe/rxe.c +++ b/drivers/infiniband/sw/rxe/rxe.c @@ -280,6 +280,7 @@ static int rxe_init(struct rxe_dev *rxe) spin_lock_init(&rxe->pending_lock); INIT_LIST_HEAD(&rxe->pending_mmaps); INIT_LIST_HEAD(&rxe->list); + INIT_WORK(&rxe->net_remove_work, rxe_process_net_remove); mutex_init(&rxe->usdev_lock); diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 6dc1a5b20e31..f1b559d728b6 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -643,6 +643,15 @@ void rxe_port_down(struct rxe_dev *rxe) dev_info(&rxe->ib_dev.dev, "set down\n"); } +void rxe_process_net_remove(struct work_struct *work) +{ + struct rxe_dev *rxe; + + rxe = container_of(work, struct rxe_dev, net_remove_work); + rxe_net_remove(rxe); + rxe_dev_put(rxe); +} + static int rxe_notify(struct notifier_block *not_blk, unsigned long event, void *arg) @@ -655,7 +664,8 @@ static int rxe_notify(struct notifier_block *not_blk, switch (event) { case NETDEV_UNREGISTER: - rxe_net_remove(rxe); + kref_get(&rxe->ref_cnt); + schedule_work(&rxe->net_remove_work); break; case NETDEV_UP: rxe_port_up(rxe); diff --git a/drivers/infiniband/sw/rxe/rxe_net.h b/drivers/infiniband/sw/rxe/rxe_net.h index 222234a8d525..feb1d715468c 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.h +++ b/drivers/infiniband/sw/rxe/rxe_net.h @@ -48,5 +48,6 @@ struct rxe_recv_sockets { int rxe_net_init(void); void rxe_net_exit(void); +void rxe_process_net_remove(struct work_struct *work); #endif /* RXE_NET_H */ diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index 831381b7788d..32c8ecb707d1 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -414,6 +414,7 @@ struct rxe_dev { struct rxe_port port; struct list_head list; struct crypto_shash *tfm; + struct work_struct net_remove_work; }; static inline void rxe_counter_inc(struct rxe_dev *rxe, enum rxe_counters cnt)