Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1462327pxy; Fri, 23 Apr 2021 08:35:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh9srAZaWh0N1W1abYT86nKuH5kaiY35YJ9HyeW/F6/50k6z0aT/gKC2KEbCZHPzt0eiIp X-Received: by 2002:a17:90b:3002:: with SMTP id hg2mr4966516pjb.64.1619192129203; Fri, 23 Apr 2021 08:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619192129; cv=none; d=google.com; s=arc-20160816; b=NTXVetAYvUpSCqOgQeAzxsZs3I9gQjvX0bqdPBwhPjasRZUGMkeR5vnyAZRe3Vh8tB OkRg/m+XmJLNLU4jJxTd+7mOs1MTAvHmaMm3cIn5vZROgiR+PDKgNmBvwVNgwxegvVyc DoU1klZOrmYSkejagONnreKhvZ/uJ4ApbruzMFxc0pkzEUpt9nTQrs57FKxKwkOYG9vJ hu4FpaLEwsbfdralP9OyxoE7UgKJinhKXd4RGSbdCu9R+F2elyOyjTqSTG6rBQLsC94a b9xBkSCmIl1R3MN1ANhcs9LA/AsE8Ca6rUWXH2eJjjj0mxJDy0XaQY+z55R480GGGTsS bDWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=v6yDQvtArsEsJ6F/2m0Ba80UFIEJsxdtpV+3k0/T3/E=; b=QodiYXCp4Xasd9jrlj+fcCzipgCQfTxF6G0CBW2Q19w/Im4Exuyq51DRJ3e/ep44VT og1Y+TSOsUzCIbOGerBtq067Nitt/Gu67R6B7IQMYniYjv1ZDn7rcX/en1nUkIrYlNIQ ReVbeNU7WvJStcpnLya9RNzVcF36U8wKDAM9YmkqsNXHfODdbYu/9ywSUS/Vn9THHDH8 KvHf52MNA/xNEt+FUu0Vakwm/tens0CGYjzTvwfLm/D+w+txwL4FkBoi5qs9UuGz3m/q /cYzgl5yQaGHgKK7Qtvk11tPwmGmHTgtIS50WLepV/4ScWMwA4c051foAut86AbJhUvP QDKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hfbb83yB; 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 d18si7672871pgg.144.2021.04.23.08.35.17; Fri, 23 Apr 2021 08:35:29 -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=Hfbb83yB; 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 S243028AbhDWPeb (ORCPT + 99 others); Fri, 23 Apr 2021 11:34:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:33884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242895AbhDWPe3 (ORCPT ); Fri, 23 Apr 2021 11:34:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3745361404; Fri, 23 Apr 2021 15:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619192032; bh=QOp4de/9uQQA0OFirIJW02IaDZzDc3LM6U5v+efYCMc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Hfbb83yBXNG1LPqHGrChhTYfrqMDkO0AYLoNYEUVHJSPSkiCD7gIjaLGAXvDJnNoe /LGY7+jwr83EX4BCwu80L+3R3Xqa0pYgkWhLpuvv5UAIndcLDcR6QAFjvJRXp8XrEO H4DkLsho94e33elxX/zA1xsB62CGU4Opm3/rcEkB0KAi8qlz8KXqtLSNYOPC/xzIvw 7QpjFCFP+g10A1Son5Pky6fmXg3n4mXgUQwKgWs0O/KMKXQQMnQ1PqUYlsmTXjK9br ezVSX7PDgRctWdEpLY/WK7B2hm3KqrpE2IK+XSjw2i0tar0d+I/bOC4pmI2SVuR06U B8n0Cx269qUrQ== Received: by mail-ej1-f43.google.com with SMTP id x12so53752792ejc.1; Fri, 23 Apr 2021 08:33:52 -0700 (PDT) X-Gm-Message-State: AOAM530eaY2cCYNRrl6WmySzqSYqNT0ihu+9SDzA6BTxz86pCa5EYPxM /kx6ysRPMSN1mGX8yQpbYNWQ7Id1eeI9pfQmag== X-Received: by 2002:a17:907:217b:: with SMTP id rl27mr4877151ejb.359.1619192030632; Fri, 23 Apr 2021 08:33:50 -0700 (PDT) MIME-Version: 1.0 References: <20210412123936.25555-1-pali@kernel.org> <20210415083640.ntg6kv6ayppxldgd@pali> <20210415104537.403de52e@thinkpad> <20210417144953.pznysgn5rdraxggx@pali> In-Reply-To: <20210417144953.pznysgn5rdraxggx@pali> From: Rob Herring Date: Fri, 23 Apr 2021 10:33:38 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: dts: marvell: armada-37xx: Set linux,pci-domain to zero To: =?UTF-8?Q?Pali_Roh=C3=A1r?= Cc: Marek Behun , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , linux-arm-kernel , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , PCI Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 17, 2021 at 9:49 AM Pali Roh=C3=A1r wrote: > > On Thursday 15 April 2021 10:13:17 Rob Herring wrote: > > On Thu, Apr 15, 2021 at 3:45 AM Marek Behun wrote: > > > > > > On Thu, 15 Apr 2021 10:36:40 +0200 > > > Pali Roh=C3=A1r wrote: > > > > > > > On Tuesday 13 April 2021 13:17:29 Rob Herring wrote: > > > > > On Mon, Apr 12, 2021 at 7:41 AM Pali Roh=C3=A1r = wrote: > > > > > > > > > > > > Since commit 526a76991b7b ("PCI: aardvark: Implement driver 're= move' > > > > > > function and allow to build it as module") PCIe controller driv= er for > > > > > > Armada 37xx can be dynamically loaded and unloaded at runtime. = Also driver > > > > > > allows dynamic binding and unbinding of PCIe controller device. > > > > > > > > > > > > Kernel PCI subsystem assigns by default dynamically allocated P= CI domain > > > > > > number (starting from zero) for this PCIe controller every time= when device > > > > > > is bound. So PCI domain changes after every unbind / bind opera= tion. > > > > > > > > > > PCI host bridges as a module are relatively new, so seems likely = a bug to me. > > > > > > > > Why a bug? It is there since 5.10 and it is working. > > > > I mean historically, the PCI subsystem didn't even support host > > bridges as a module. They weren't even proper drivers and it was all > > arch specific code. Most of the host bridge drivers are still built-in > > only. This seems like a small detail that was easily overlooked. > > unbind is not a well tested path. > > Ok! Just to note that during my testing I have not spotted any issue. > > > > > > > Alternative way for assigning PCI domain number is to use stati= c allocated > > > > > > numbers defined in Device Tree. This option has requirement tha= t every PCI > > > > > > controller in system must have defined PCI bus number in Device= Tree. > > > > > > > > > > That seems entirely pointless from a DT point of view with a sing= le PCI bridge. > > > > > > > > If domain id is not specified in DT then kernel uses counter and as= signs > > > > counter++. So it is not pointless if we want to have stable domain = id. > > > > > > What Rob is trying to say is that > > > - the bug is that kernel assigns counter++ > > > - device-tree should not be used to fix problems with how kernel does > > > things > > > - if a device has only one PCIe controller, it is pointless to define > > > it's pci-domain. If there were multiple controllers, then it would > > > make sense, but there is only one > > > > Yes. I think what we want here is a domain bitmap rather than a > > counter and we assign the lowest free bit. That could also allow for > > handling a mixture of fixed domain numbers and dynamically assigned > > ones. > > Currently this code is implemented in pci_bus_find_domain_nr() function. > IIRC domain number is 16bit integer, so plain bitmap would consume 8 kB > of memory. I'm not sure if it is fine or some other tree-based structure > for allocated domain numbers is needed. It's an atomic_t but then shortened (potentially) to an 'int'. Surely we don't need 8k (or 2^31) host bridges? Seems like we could start with 64 and bump it as needed. Or the idr route is another option if that works. We'd need to get the lowest free value and be able to reserve values (when specified by firmware). > > You could create scenarios where the numbers change on you, but it > > wouldn't be any different than say plugging in USB serial adapters. > > You get the same ttyUSBx device when you re-attach unless there's been > > other ttyUSBx devices attached/detached. > > This should be fine for most scenarios. Dynamically attaching / > detaching PCI domain is not such common action... > > Will you implement this new feature? Yes, after I find a DT binding co-maintainer. Rob