From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BDE13B635A for ; Wed, 22 Jul 2026 23:16:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784762167; cv=none; b=i3F4XOZcoYyr4jDu7QEg9VBgohAgpHiJrbxAEcUs2jNfYIgw2kAUw8BC4QuskRB6XAxrmps2NEMQoYGiPbOLB2ntIbNWMAzo2iK2pKMNZFxdPQhAKYRIXXIajOlR0hEd4p9FnobHlRfpAFHR4ezK586aj6I4B1PgUZluvTP6vHA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784762167; c=relaxed/simple; bh=WBNkpjYp7Rou85GCTMeWgm+HUcD0wtM7gf3sX1bxa0A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mFxbZMGwGGvuoEPiMiLGXwbQ9j2tg2zV6upbAbGwaQeCywXAZfzqH2O/C9qtV49WjMDepWD/ru1gpaSoKZaJYJfdr6bmJBYRWVWSgC1D5jpEBrJIjm7cwQezEieOYcdmBGslZkvgZHvUPfG+IQXaHvx5UTyH95kWJ4HrObBd4d8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=KY3ns+0o; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KY3ns+0o" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-38e08baf860so12910a91.2 for ; Wed, 22 Jul 2026 16:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1784762165; x=1785366965; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=lInBjANtH4BjEEGmffn+p/zkomTeab76R8MrFSqGh90=; b=KY3ns+0o8CqCxqFRpDt/n4wgZKWJ403uGyx2hQKOWgwgRbmzx1IXaLDyWOZFkvfnLw +OqArm95zuhAGk23xJWlXy60PthOGZzYTDvFZU3nW+YfqSEWZhElzvcB2gvozkzci/kZ ZOWEaWMUHJnwdJFjO0s806wycIh2smBBqoVCU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784762165; x=1785366965; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=lInBjANtH4BjEEGmffn+p/zkomTeab76R8MrFSqGh90=; b=AQt54yM6DR3qrNXbCMEZUt6eGbau1BI45UmjlCq5e4TOf2oXR5TJWFI61mQ/nDtZEB FIrkGxFvBLaGPCML6jwGp5neA7OfpnyPsGkKo9aTzDqXo9/askfCVyfGXri6+m58BTR2 Ra1FNjjXnUTZRc7o/7g6uJ4iFnURZtPcTSS3x+dNeGKUhL7wG77c2sW22KQY4TMg9jpB xRHSBqLYvXrENNsZJzBjFCyeuN8SaSkevZrOvA13ElVQHuoV1XMEx+a75Ev6Gy/lAHPX jji1pcwisaNNCbiVLWbPeL1ifL3DnBU4ULmK6//xhdpv8q+cnthegkNAw4+4TtrajJ4T vV1Q== X-Forwarded-Encrypted: i=1; AHgh+RpRMeBgAE7MN28WvW4hwVzHENc8OSFUqieWJegBvoHPpV9ULeNyUgLg0e38BhB1xaI2U83VR3ITqnS8ch8=@vger.kernel.org X-Gm-Message-State: AOJu0YwUX4KH9eCqIm2wrCzJMODijCNaarTk2wtjs2A4CHbRxF8SdAKJ F+C0ElX/S1Sl2g5pfnLdZ/oemLrnXR174BwwYH4Khw4qB5Zw267Yi5NSPy+r+7PioA== X-Gm-Gg: AR+sD12Y/cwjNzPutOnrmL/u2hEhInG8vkB9Jx6AILwvr/Mzx6+l4zUR7DgavIEvwbb Twvo1T4OvXCD6i0qW/z2oFB1Iwj2EJ5rfDaRNajYgrL+ER/kIEX4VqZ85ry7hflblJOJs/H4EI4 t6wjII7kqr0h9qlGOukWimLp9rC+Xv/rZ6fj4I2enZk2+8tG6DmGI1e5lz+rIcCFPQcFZ0uU1i8 6ECodtR77YhAynLQUuZ8tavABilr4Y/WJ3Hlr+WLQGXjTZCZNmUjJukFfPefhvxAk8uT1BH2na5 i5yQIWn6IdmWvznqep/GBYNbrVxRC3A2ZjZVFZk3tUJvwp/jqiRGoBSU+n85mEoNfMyDia5MjXf muLsuiJ/GmFnsXbH4PjilsbqoU5Z3Trw5nrhO9JdZ00jlMpnmVNMpq19rlp+OtoYxF7CaXBOL4X j5F3oRn8lNrOoXEOtFnkkvEmaDSMTs08kgJu0aWPgP X-Received: by 2002:a17:90b:52d0:b0:38e:9e9e:ec57 with SMTP id 98e67ed59e1d1-38ec667a731mr659784a91.43.1784762165505; Wed, 22 Jul 2026 16:16:05 -0700 (PDT) Received: from localhost ([2a00:79e0:2e7c:8:f3fd:a899:78ad:64d4]) by smtp.gmail.com with UTF8SMTPSA id a92af1059eb24-13d130158c0sm9903256c88.6.2026.07.22.16.16.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2026 16:16:04 -0700 (PDT) Date: Wed, 22 Jul 2026 16:16:03 -0700 From: Brian Norris To: Bjorn Helgaas Cc: Lukas Wunner , linux-kernel@vger.kernel.org, Manivannan Sadhasivam , linux-pci@vger.kernel.org, David Matlack Subject: Re: [PATCH v2] PCI/portdrv: Allow probing even without child services Message-ID: References: <20260720204419.GA426578@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Lukas, Bjorn, On Mon, Jul 20, 2026 at 05:25:56PM -0700, Brian Norris wrote: > On Mon, Jul 20, 2026 at 03:44:19PM -0500, Bjorn Helgaas wrote: > > On Fri, Jul 17, 2026 at 10:26:53AM +0200, Lukas Wunner wrote: > > > On Thu, Jul 16, 2026 at 12:26:41PM -0500, Bjorn Helgaas wrote: > > > > On Mon, Feb 09, 2026 at 05:15:35PM -0800, Brian Norris wrote: > > > > > The PCIe port driver fails to probe if it finds no child services, > > > > > presumably under the assumption that the driver is not useful in that > > > > > case. However, the driver *can* still be useful for power management > > > > > support -- namely, it still configures the port for runtime PM / D3, > > > > > which may be important for allowing a bridge to enter low power modes. > > > > > > > > > > Thus, allow probe to succeed even if no IRQs and no child services are > > > > > available. This also mirrors existing behavior for ports that have no > > > > > PCIe capabilities, where we'd also probe successfully. > > > > > > > > > > This change is a bit more important after commit f5cd8a929c82 ("PCI: > > > > > dwc: Remove MSI/MSIX capability for Root Port if iMSI-RX is used as MSI > > > > > controller"), because it's common for some DWC-based systems to: > > > > > > > > > > 1. have only have the "aer" and "pcie_pme" port services available and > > > > > 2. not define legacy INTx interrupts properly in their device tree. > > > > > > > > > > After commit f5cd8a929c82, such systems may fail > > > > > pcie_init_service_irqs() and so exit with -ENODEV. > > > > > > > > > > Link: https://lore.kernel.org/all/nyada24tqwlkzdceyoxbzitzygvp4elvj5oajnqdwb33xkcdwk@76vnrx45fsfd/ > > > > > Signed-off-by: Brian Norris > > > > > > > > Applied to pci/portdrv for v7.3, thank you! > > > > > > Some thoughts on the version now applied to pci/portdrv: > > > > > > * After this patch, the return value of pcie_device_init() is no longer > > > evaluated, so that function should be changed to return void as part > > > of this patch. > > Yes, seems reasonable. > > But then, possibly negated below. Not done in v4, since we now use the return code differently. > > > * If no port services are initalized, e.g. because pcie_device_init() > > > failed for all of them, the allocated IRQ vectors are not freed. > > > They're hogged, which may be a problem on systems which only support > > > very few IRQ vectors such as Sophgo SG2042: > > > > > > https://lore.kernel.org/r/0f42afefd9322779af5463b696c55b08d2296ea8.camel@iscas.ac.cn > > > > Seems like a good idea to free IRQ vectors we don't use. It *looks* > > like it should be safe to call pci_free_irq_vectors() here and then > > again in pcie_port_device_remove() if a port is removed, but Brian > > wasn't sure, and I didn't look any deeper than pci_disable_msix() and > > pci_disable_msi(). > > I think everything in pci_free_irq_vectors() is written such that it can > safely be called twice. I'll see if I can verify that better and submit > an update. I was just unsure at the moment of review, especially > considering you had other real double-cleanup bugs in your proposal. > > > I guess if we did this we'd need to retain the pcie_device_init(). > > Ack. Done in v4. > > > * It might be clearer to call pci_clear_master() directly in the > > > if-block which is amended to "goto out". Then the "goto out" > > > can be changed to a "return 0". It seems "if (!capabilities)" > > > cannot happen through any other code path, so it's unclear why > > > the "out" label is necessary. > > > > It does look nicer that way. > > Hmm, yes. I may have rewritten it enough times that it was never clear > how many error paths we were going to have. As soon as you get more than > 1 error path, it gets tricky to do this. > > I'll revisit this one along with the previous suggestions. The additional "free IRQs" suggestion means we again have 2 paths that need the same cleanup, so I chose to keep the 'goto'. There are other creative ways to avoid the 'goto', but I felt like "creative" often doesn't help readability and maintainability. > > > * There's a duplicate "have" in the commit message ("have only have"). > > > > I fixed this on pci/portdrv. > > Commit message looks good, thanks. > > > What do you think, Brian? > > I'll give the above a shot. I suppose that would work best as a v4 > (pretending your pci/portdrv is only a reference, and not a patch-basis > target). Submitted v4: https://lore.kernel.org/all/20260722160942.v4.1.I5fd5d83f518681b3949d8ab2f16ba8244fd3e774@changeid/ Brian