From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52B03C77B73 for ; Sun, 21 May 2023 09:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbjEUJJS (ORCPT ); Sun, 21 May 2023 05:09:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjEUJJR (ORCPT ); Sun, 21 May 2023 05:09:17 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A7A7AC for ; Sun, 21 May 2023 02:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684660156; x=1716196156; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=heKkj2TnvrCjRt2R7xWsfK6yv4o+64Djjy0XBCmzP7s=; b=EMnc5i9EPgboaUwPMX5ZK9sRo6RdK6E2ItQwzqBYT09TuqMifcSR4yi8 W/5lOnrWMETAchyTa5OlS9TZpWLuo7QbyB3lBgoZsrU9cBZ3f/v3fg4Wl rfZiqDxtsSjB7amlOTNZL3HbC/EKAVEoxKKln0YeWD94DUpsN81f4Ziyz 36qsEOhPmXh03nO5dvx+IbaSeVEv41wAikkPZuNuWYS7g19h+fBe6kEhC JPombJZT50lJjUPKXU9MWOcSAAiWOAyspZMKNpb6Y/66pdEofm+YfoH7j AyQurC5IyiPbW8WBlMbmZDE8hM2CLv1uFrm07g/LP5L7v01xjhT67HrzE g==; X-IronPort-AV: E=McAfee;i="6600,9927,10716"; a="333046924" X-IronPort-AV: E=Sophos;i="6.00,181,1681196400"; d="scan'208";a="333046924" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2023 02:09:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10716"; a="768162205" X-IronPort-AV: E=Sophos;i="6.00,181,1681196400"; d="scan'208";a="768162205" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by fmsmga008.fm.intel.com with ESMTP; 21 May 2023 02:09:13 -0700 Message-ID: Date: Sun, 21 May 2023 17:08:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cc: baolu.lu@linux.intel.com, Kevin Tian , Nicolin Chen Subject: Re: [PATCH v2 04/10] iommu: Simplify the __iommu_group_remove_device() flow To: Jason Gunthorpe , David Woodhouse , iommu@lists.linux.dev, Joerg Roedel , Len Brown , linux-acpi@vger.kernel.org, "Rafael J. Wysocki" , Robin Murphy , Will Deacon References: <4-v2-3c3bb7aa6e48+1916b-iommu_probe_jgg@nvidia.com> Content-Language: en-US From: Baolu Lu In-Reply-To: <4-v2-3c3bb7aa6e48+1916b-iommu_probe_jgg@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On 5/20/23 2:42 AM, Jason Gunthorpe wrote: > Instead of returning the struct group_device and then later freeing it, do > the entire free under the group->mutex and defer only putting the > iommu_group. > > It is safe to remove the sysfs_links and free memory while holding that > mutex. > > Move the sanity assert of the group status into > __iommu_group_free_device(). > > The next patch will improve upon this and consolidate the group put and > the mutex into __iommu_group_remove_device(). > > __iommu_group_free_device() is close to being the paired undo of > iommu_group_add_device(), following patches will improve on that. > > Reviewed-by: Kevin Tian > Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu Best regards, baolu