Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1221080iog; Thu, 30 Jun 2022 20:41:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t2BsW69XIImDqjH9V9OT56NZVsH2x/g7YH4kSC2FRDzXuR5iJJ5yF69MXWIp/rAwbZGMFL X-Received: by 2002:a05:6402:5288:b0:435:ccbb:2a3a with SMTP id en8-20020a056402528800b00435ccbb2a3amr16297756edb.382.1656646883502; Thu, 30 Jun 2022 20:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656646883; cv=none; d=google.com; s=arc-20160816; b=a94ira7l7oSfP2mQKsZ/mx+17GFYF1jdWkByKzauy+AsE2ZUVr3vyv4jPHt1phg2jt VgtkVWOxKlSRdEgxzie0yUAWbCYOVKLUuhUkndM3tHZQbTJ0PJT/zXjrFYxZPbcfotZx Md75wiBYOxC5DwcoxoLfXG1yQQUhk5Oeke/HWyBa/S2xRjp+KuLdzKWvv1R8WKgihEAF QcnxZoaZo03WgZ7BGc3Jn5eSeq/krM/0j05QQiea7JIT82dIzqs+v9iLogUvlOnKtAJa Hjgj1nR6RF8Z0wYyX+W1O3GnXjuIwazddPFJX5JjNp2A7PR6k9oCQX6NWaMl05Vd7bw5 A+XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=ykiJtrtlfXJcqHci8qzknRVLYII8uhKZ9NIYh5Huxro=; b=ENXy33pQzwO6S/vJDdTluLOscAvA7m1RF+gaDV/EkYQzGFeAmfhRUhXDsSCFYgqPh7 lAqRJvx61akBZlaMt74gSsUmt+TcEf/QERdQoLMuOx/W91XnrTVDOztw/77HWuV6Hhwp RvyQ3ziDLWfo7AqiF4cdeUWmyeFvvdLJJ0tBtaq/xDcvOtAGkCpVJ14I4TK3kgR0ZaN+ 2WVkWK8Hd4rpoGsa6k1ELGwgzbZvh5JTdFflONCr/bKqE734MU2o10E8QvNoMlfIvFxq 0ntFr5j3ffpSK3WXFHW+yeLbB/vz4KEQJgNQoo/rEVyBU1883xhnxz871w1R+cE7iEWu th6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Aqba9e8B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jr2-20020a170906a98200b007277dd43476si9527500ejb.347.2022.06.30.20.40.58; Thu, 30 Jun 2022 20:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Aqba9e8B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233981AbiGADRf (ORCPT + 99 others); Thu, 30 Jun 2022 23:17:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234099AbiGADRd (ORCPT ); Thu, 30 Jun 2022 23:17:33 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8841764D51 for ; Thu, 30 Jun 2022 20:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656645452; x=1688181452; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=X7KG6YEkiVYtWl6cE7h9dCi+akN1ajBggBxEmd4Yg2I=; b=Aqba9e8BDGmOCeDqCSNshmmvVatgn6GTZJrGm03BNQ0GwwqLGbInS/zn l0rb48Lztv3U3YEQM9rPXFB7ALKk8s7zv0iKLgWYCu/FmFNTxUzn4xtrE oiQ2LSIWXlzlzn6Uu6VXhunUigr9Ek89xB4CJH/ynwdhmZuZxKUh/wsZi XAd4atDXa1rWlAfJDrvptkZHtwPeIzxG5BPifIzEKzf8Mk+PMNEzqnBYl d2zoXRTaFnYagBFIOINhEqZY3cZPscNdMipZPwWIDUwOWhd9zaH7PgwbU 90gzhJQhCGaUmY061eusdCgWD+9eacwMEfF1vMfimHQLhEApkqOxdqRSk w==; X-IronPort-AV: E=McAfee;i="6400,9594,10394"; a="368856262" X-IronPort-AV: E=Sophos;i="5.92,236,1650956400"; d="scan'208";a="368856262" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2022 20:17:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,236,1650956400"; d="scan'208";a="589066578" Received: from allen-box.sh.intel.com (HELO [10.239.159.48]) ([10.239.159.48]) by orsmga007.jf.intel.com with ESMTP; 30 Jun 2022 20:17:24 -0700 Message-ID: <239cfd97-b381-f523-f149-e127f44a0780@linux.intel.com> Date: Fri, 1 Jul 2022 11:13:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cc: baolu.lu@linux.intel.com, David Woodhouse , Jerry Snitselaar , Mike Travis , Dimitri Sivanich , "Anderson, Russ" , "iommu@lists.linux.dev" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v1 4/6] iommu/vt-d: Add VTD_FLAG_IOMMU_PROBED flag Content-Language: en-US To: "Tian, Kevin" , Joerg Roedel , Steve Wahl References: <20220625125204.2199437-1-baolu.lu@linux.intel.com> <20220625125204.2199437-5-baolu.lu@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/30/22 4:29 PM, Tian, Kevin wrote: >> From: Lu Baolu >> Sent: Saturday, June 25, 2022 8:52 PM >> >> In the IOMMU hot-add path, there's a need to check whether an IOMMU >> has been probed. Instead of checking the IOMMU pointer in the global >> list, it's better to allocate a flag bit in iommu->flags for this >> purpose. > > Sorry I didn't get the point of original check. This is the hotplug path > hence the caller of this function should already figure out it's a new > iommu before reaching this point? > Either did I. It was added by below commit without any comments about this check. commit ffebeb46dd34736c90ffbca1ccb0bef8f4827c44 Author: Jiang Liu Date: Sun Nov 9 22:48:02 2014 +0800 iommu/vt-d: Enhance intel-iommu driver to support DMAR unit hotplug Implement required callback functions for intel-iommu driver to support DMAR unit hotplug. Signed-off-by: Jiang Liu Reviewed-by: Yijing Wang Signed-off-by: Joerg Roedel I went through the whole hot-add process and found this check seemed to be duplicate. Hot-add process starts from dmar_device_hotplug(), it uses a rwlock to synchronize the hot-add paths. 2386 down_write(&dmar_global_lock); 2387 if (insert) 2388 ret = dmar_hotplug_insert(tmp); 2389 else 2390 ret = dmar_hotplug_remove(tmp); 2391 up_write(&dmar_global_lock); dmar_device_hotplug() ->dmar_hotplug_insert() -->dmar_parse_one_drhd() /* the added intel_iommu is allocated here*/ -->dmar_hp_add_drhd() /* the intel_iommu is about to bring up */ --->intel_iommu_add() The duplicate check here: if (g_iommus[iommu->seq_id]) return 0; All the iommu units are allocated and then initialized in the same synchronized path. There is no need to check a duplicate initialization. I would like to remove this check if no objection. Best regards, baolu