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 3B4B9C433EF for ; Thu, 7 Jul 2022 01:20:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234584AbiGGBUH (ORCPT ); Wed, 6 Jul 2022 21:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbiGGBUG (ORCPT ); Wed, 6 Jul 2022 21:20:06 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43E6E2E69C; Wed, 6 Jul 2022 18:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657156805; x=1688692805; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=RlBsSE86mhkZ1VM1qqe1zDyK2s+b9dUNIdXAWa4b/3U=; b=MqFen/CH1oWMnHwrQxZifLcU/0coMdEwlj7UwSF/4Ld+8gaIAz3NGKj5 Sv1VOQV3QLtWhYfPMnNe0jpKeXAsM4gmAqyuWN9jaDkbCTBYyDD0NvqAk Judq6xeZqP81xniFm+m5FpJpFgFoqIzY5nxf+E/ddHizPxiwRYNk04UMq DGYrWnf5camVm0p4KIK0KYj81gRmmjI51j5g1MQPoa4PJ7dxBC6oR0P7s GozERMKzpmpNUdQYJk5araKAxap27nbE15V916eoMXR1/x6ADlDiuJbqq smFSfZ8Ly47fz+JBT6VLGk1ObYPWEPTffL2eoNHlKpiY3LEs92AABsxeO A==; X-IronPort-AV: E=McAfee;i="6400,9594,10400"; a="266934029" X-IronPort-AV: E=Sophos;i="5.92,251,1650956400"; d="scan'208";a="266934029" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2022 18:20:04 -0700 X-IronPort-AV: E=Sophos;i="5.92,251,1650956400"; d="scan'208";a="650909261" Received: from hualiu-mobl1.ccr.corp.intel.com (HELO [10.249.171.209]) ([10.249.171.209]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2022 18:20:01 -0700 Message-ID: <2aa8aa41-4d9f-5a0f-1ad4-e2e19cbcbe6f@linux.intel.com> Date: Thu, 7 Jul 2022 09:19:59 +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, will@kernel.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, suravee.suthikulpanit@amd.com, vasant.hegde@amd.com, mjrosato@linux.ibm.com, gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 04/15] iommu: Move bus setup to IOMMU device registration Content-Language: en-US To: Robin Murphy , joro@8bytes.org References: <5b9b608af21b3c4353af042355973bac55397962.1657034828.git.robin.murphy@arm.com> <71835610-7798-5fbe-556a-fc44dc9e168b@arm.com> From: Baolu Lu In-Reply-To: <71835610-7798-5fbe-556a-fc44dc9e168b@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/7/6 22:37, Robin Murphy wrote: > On 2022-07-06 03:35, Baolu Lu wrote: >> On 2022/7/6 01:08, Robin Murphy wrote: >>> @@ -202,12 +210,32 @@ int iommu_device_register(struct iommu_device >>> *iommu, >>>       spin_lock(&iommu_device_lock); >>>       list_add_tail(&iommu->list, &iommu_device_list); >>>       spin_unlock(&iommu_device_lock); >>> + >>> +    for (int i = 0; i < ARRAY_SIZE(iommu_buses); i++) { >>> +        struct bus_type *bus = iommu_buses[i]; >>> +        int err; >>> + >>> +        if (bus->iommu_ops && bus->iommu_ops != ops) { >>> +            err = -EBUSY; >>> +        } else { >>> +            bus->iommu_ops = ops; >>> +            err = bus_iommu_probe(bus); >>> +        } >>> +        if (err) { >>> +            iommu_device_unregister(iommu); >>> +            return err; >>> +        } >>> +    } >>> + >>>       return 0; >>>   } >>>   EXPORT_SYMBOL_GPL(iommu_device_register); >> >> With bus_set_iommu() retired, my understanding is that now we embrace >> the first-come-first-serve policy for bus->iommu_ops setting. This will >> lead to problem in different iommu_ops for different bus case. Did I >> overlook anything? > > This is just formalising the de-facto situation that we don't actually > have any combination of drivers that could load on the same system > without already attempting to claim at least one bus in common. It's > also only temporary until the bus ops are removed completely and we > fully support multiple drivers coexisting, which only actually takes a > handful more patches - I've realised I could even bring that change > *ahead* of the big job of converting iommu_domain_alloc() (I'm not > convinced that the tree-wide flag-day patch for that I currently have in > the dev branch is really viable, nor that I've actually got the correct > device at some of the callsites), although whether it's worth the > potentially-surprising behaviour that might result I'm less sure. > > If we already had systems where in-tree drivers successfully coexisted > on different buses then I'd have split this up and done something a bit > more involved to keep a vestigial bus_set_iommu() around until the final > bus ops removal, but since we don't, it seemed neatest to do all the > related work in one go. Fair enough. I've never seen a mixed system as far. It's fine for us to retire bus_set_iommu() for now and then formally support mixed IOMMU drivers later. Best regards, baolu 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56164C43334 for ; Thu, 7 Jul 2022 01:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:To:Subject:Cc: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W5sC+FvnvNLkxWzazGmNAZiZ41VLlWME84EzLSxgU+c=; b=4bRBpACDrZeRi2 QwjzX69B7+PBZd0jOoGsy/QaoPz+ezfzkDlRNt/iKOLlo4m30rk01u5b6nRpTKFT5+CuaEOWjjw98 2obswqUMXTJQLkseNnI0y7hAfRBF/FoCCZTZJOP8bYc7kmdYO9wo5376rIA1dm/pmZ2NyEWig3Bik u20S0CiHPedNe+daUOYrDhtUK9jBx+NK99DrsfCxWpK/jXVVJcDIpWlHJ4lTB2aSTXqHo2QHGwcxg s5KW6/3mIw1qNtlwanc+nkvz6zfPO0SzYy5v84BN0f/XELXHfvUor8o4JIuMyt/qX58NpPqGYd5c1 IfIoFdGJbwDihWCQunTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9GBf-00Cwt3-GB; Thu, 07 Jul 2022 01:20:11 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9GBc-00CwsG-Ur for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2022 01:20:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657156808; x=1688692808; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=RlBsSE86mhkZ1VM1qqe1zDyK2s+b9dUNIdXAWa4b/3U=; b=ZIFVYKMz7ion+JDbNqR7DHRoH0Enyk8KN5Iq9Es6TqBpPjqT9Y6gYFxs P0yxe93L+smmHx+LDZ9pazCdSjfri9YkwCrGvD2MnHGDN8797Ewdl0Vg/ uQYlcBzRUITUJCQr7tzeNZu7XoodsqoBZqzgBPntOr86KTdoMZjHZAp9P itXqxxiPGfMlmI49Jfy6gwMotqB7GPlBWy5O1/eejPlgDflmdMauLZK/M Ze9eYhuzkT/ZmWLYsVrQCIqWTUGImRhGmUzTY5P2/Di4SyTXBj5Vdl5Ps uY4TgR/HJbUqb6Wn9cRNzrc9djZQZB/shaz7LarFcJYfhN+mL07KbcjJg Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10400"; a="266934030" X-IronPort-AV: E=Sophos;i="5.92,251,1650956400"; d="scan'208";a="266934030" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2022 18:20:04 -0700 X-IronPort-AV: E=Sophos;i="5.92,251,1650956400"; d="scan'208";a="650909261" Received: from hualiu-mobl1.ccr.corp.intel.com (HELO [10.249.171.209]) ([10.249.171.209]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2022 18:20:01 -0700 Message-ID: <2aa8aa41-4d9f-5a0f-1ad4-e2e19cbcbe6f@linux.intel.com> Date: Thu, 7 Jul 2022 09:19:59 +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, will@kernel.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, suravee.suthikulpanit@amd.com, vasant.hegde@amd.com, mjrosato@linux.ibm.com, gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 04/15] iommu: Move bus setup to IOMMU device registration Content-Language: en-US To: Robin Murphy , joro@8bytes.org References: <5b9b608af21b3c4353af042355973bac55397962.1657034828.git.robin.murphy@arm.com> <71835610-7798-5fbe-556a-fc44dc9e168b@arm.com> From: Baolu Lu In-Reply-To: <71835610-7798-5fbe-556a-fc44dc9e168b@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220706_182009_077685_834FAC7F X-CRM114-Status: GOOD ( 22.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org T24gMjAyMi83LzYgMjI6MzcsIFJvYmluIE11cnBoeSB3cm90ZToKPiBPbiAyMDIyLTA3LTA2IDAz OjM1LCBCYW9sdSBMdSB3cm90ZToKPj4gT24gMjAyMi83LzYgMDE6MDgsIFJvYmluIE11cnBoeSB3 cm90ZToKPj4+IEBAIC0yMDIsMTIgKzIxMCwzMiBAQCBpbnQgaW9tbXVfZGV2aWNlX3JlZ2lzdGVy KHN0cnVjdCBpb21tdV9kZXZpY2UgCj4+PiAqaW9tbXUsCj4+PiDCoMKgwqDCoMKgIHNwaW5fbG9j aygmaW9tbXVfZGV2aWNlX2xvY2spOwo+Pj4gwqDCoMKgwqDCoCBsaXN0X2FkZF90YWlsKCZpb21t dS0+bGlzdCwgJmlvbW11X2RldmljZV9saXN0KTsKPj4+IMKgwqDCoMKgwqAgc3Bpbl91bmxvY2so JmlvbW11X2RldmljZV9sb2NrKTsKPj4+ICsKPj4+ICvCoMKgwqAgZm9yIChpbnQgaSA9IDA7IGkg PCBBUlJBWV9TSVpFKGlvbW11X2J1c2VzKTsgaSs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