Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2900950pxv; Sun, 18 Jul 2021 05:02:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrWcyR0j3+q/1hdW6wQzT8ggy7PhNZkoy+ItPOBWiikky3MA7IkXYSnObmKWIdDyTQ3jvo X-Received: by 2002:a05:6638:c4a:: with SMTP id g10mr16851116jal.21.1626609744186; Sun, 18 Jul 2021 05:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626609744; cv=none; d=google.com; s=arc-20160816; b=FRSsvEjNh87gR5MYlyVmY76dqoPZHyTDWZn3cYznIz1t+eKOZM5bpt6I3gsxMcUlFD 5rRlepNBKcbKvCXvx5dz1jhyNPOlSq9+nos0klUzMm7jxAjGiZVpnWA36Ssr9Ehwf0y0 Eut1qtPKf7Dz03oegt5IT1vRptQV6/5OJ3VcSDPkymL2ELuAWNTLAQxcjhHhsx2k15pF mFixRgW7TYwfq/O+4qbP8aGisHlQ6BweQeVxuMCz+FuhKNJHBcGX5pzzxTWVqlkNKxR2 rlYCwjcMj93JLUDyYtfNM13rfuhGLu0P4fiProP8IWO4ySuWXOiucPMDUW6k/NPMUxbY W3cQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kQLnnu7aBTVvXnCP6LqDr9rvmNK3Bj0mC/AtRZsfyfE=; b=ULsb8WiWJMfBwAWpx/rkL10z+gclrS96TRpStqcthUI+mh2udQJZfCytQeFtp1wmQl OQ0PeHA5DHcffT/q1ykSmRufGblbkjjUpuBIoR/UzsT9EjylB33BSyebyYRCK89BIU5D WcIO/LmfqXM/JMQoVh5wGyyVmueXw6S/J0PIqNbnCsLYlWm1PXRHuWgzRGlqCOUrGQCP bpt+UdWrtmsRFErOx0kIYoaYJeMvRUc9oRrOpJuc8Yl47J5BiNmEuUQhOCFSXx6KzBL3 DEQbhmvwI+fIzKNgp+40lbWYKjXnzuyYmfvQIPJwFq+aAK8b560S8TJcGWiOscIz++Qc lWAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="WRD/f373"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si7862481ilt.138.2021.07.18.05.02.12; Sun, 18 Jul 2021 05:02:24 -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=k20201202 header.b="WRD/f373"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233188AbhGRMES (ORCPT + 99 others); Sun, 18 Jul 2021 08:04:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:43820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233425AbhGRMEM (ORCPT ); Sun, 18 Jul 2021 08:04:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E8BE36113D; Sun, 18 Jul 2021 12:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626609674; bh=cAnq0DG8YTB9VFO8VFMDen4mU9E05ik62n+FRZ0hxdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WRD/f373jpVRJygvZ4rRg0bC0gxJmnpkKB1dcu9Jeu0OpvlEmA/PAD5H6LmzOjsQI +dc+G+NxpiiyJiuZyhuRx4d7dPfRQLhqkmvPeYLhmLBCm/rG0vKCaCTLIU2218LW8x HoAW7QdDUY82zwBG40J1HK6Kmvq4yGwOtAPyl4VGLPIi/gh+Cfsmlzkc3m3C4tloyr 6UUDKFLlbOZM8ddbe1Js2pylX5liv+tgtgtpyuw+IB+gTGAgvsNZo4MqQUgBNKmzJV HDrPllCREjvk+e6ABBAKEY8rCFPPOqp6ybqNeDByHgc6nDdEY1VWH+psZKfBRDGTih zmNETFw83kWxQ== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Leon Romanovsky , Adit Ranadive , Ariel Elior , Bernard Metzler , Christian Benvenuti , Dennis Dalessandro , Gal Pressman , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Michal Kalderon , Mike Marciniszyn , Mustafa Ismail , Naresh Kumar PBS , Nelson Escobar , Potnuri Bharat Teja , Selvin Xavier , Shiraz Saleem , Steve Wise , VMware PV-Drivers , Weihang Li , Wenpeng Liang , Yishai Hadas , Zhu Yanjun Subject: [PATCH rdma-next 4/9] RDMA/mlx5: Cancel pkey work before destroying device resources Date: Sun, 18 Jul 2021 15:00:54 +0300 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky In the driver release flow, we are ensuring that notifier is disabled and no new works can be added to pkey_change_handler. It means that we can cancel that handler before destroying resources to make sure that our unwind routine is symmetrical to the allocation one. Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 9b8dd7a604c9..75d5de14f80b 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -2908,6 +2908,15 @@ static void mlx5_ib_dev_res_cleanup(struct mlx5_ib_dev *dev) struct mlx5_ib_resources *devr = &dev->devr; int port; + /* + * Make sure no change P_Key work items are still executing. + * + * At this stage, the mlx5_ib_event should be unregistered + * and it ensures that no new works are added. + */ + for (port = 0; port < ARRAY_SIZE(devr->ports); ++port) + cancel_work_sync(&devr->ports[port].pkey_change_work); + mlx5_ib_destroy_srq(devr->s1, NULL); kfree(devr->s1); mlx5_ib_destroy_srq(devr->s0, NULL); @@ -2918,10 +2927,6 @@ static void mlx5_ib_dev_res_cleanup(struct mlx5_ib_dev *dev) kfree(devr->c0); mlx5_ib_dealloc_pd(devr->p0, NULL); kfree(devr->p0); - - /* Make sure no change P_Key work items are still executing */ - for (port = 0; port < ARRAY_SIZE(devr->ports); ++port) - cancel_work_sync(&devr->ports[port].pkey_change_work); } static u32 get_core_cap_flags(struct ib_device *ibdev, -- 2.31.1