From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.53]) (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 710F524466C for ; Thu, 9 Apr 2026 23:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775776829; cv=none; b=dLF9AX+BcJymqLkMrgzTdCgAGOmDZTF59l1bS7V0WQGY09Z4yqg3W/rswRzVdUcaXciX0wvJM1OQglEOVr45BNbeOa43VzQpbL7YAyFO25lmA1iKuPYokixeindqWekzOd9zJJQI3qwAiic3ZI9yPNT3Yz17Ak6dEPvRuhDeIeo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775776829; c=relaxed/simple; bh=5maPw5rOu247J95ogkhFL1Gvw11KNpgsZRmMGtsr8es=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZjvIYOoJRuGuzXnynZRjI1kJa5Q9AYptRH5fXekJjyIf38Piq4vdqQVb2YSrv8DRcg8TVrBTwDCicr4IFF/LfZgCyheEq3fwW19dxTaDsenpdGvzAB3id5DZ0TiFIx2zLpPG5xXND1f4dY8lNtyeP3aiMvuQ9mFXiox+1jlx26g= 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=Z0Coo76Q; arc=none smtp.client-ip=74.125.82.53 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="Z0Coo76Q" Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-12c080efc1eso800519c88.0 for ; Thu, 09 Apr 2026 16:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1775776828; x=1776381628; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ERkzPbjiSFF8tdP7mJxWiG00pMQx/MpjuHL9NISAD1E=; b=Z0Coo76QnvwhZxjajBmvQC8LwWtKFkzokY4XsjvecbW7ed8k/V1e0ZUiPMoTE5lTJU U/Pb/QEVeGAxvdn2jlzKY3BhDlowKxfQp5y9fSZmTsHqAcopSkfMsIKmo25OYpwMaH3v +SnCRdMhu6P2JJma9n3eGahybQVNUMI9pmf3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775776828; x=1776381628; h=in-reply-to:content-disposition: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; bh=ERkzPbjiSFF8tdP7mJxWiG00pMQx/MpjuHL9NISAD1E=; b=rQOv20okZF31YaQlRgZG9ceVYTG2bVoRbb1TlDX7qzo+ZNthOUULhxm8m5ItAUF6re /swv9n1serlfua3CPAFp5ifKvLPgnYmXKlfavF2sAqz6T/yb3aEYi1Aygl7vVqdapmqY sPZHmA4IOnr1FDSWsVamKzayjmEgS0Ky341dxsNj1Sg8Tj3RX3XpqOfE3h8diCjg3Jyw 38iHmlL33APiflDkdJv4kDx/sr+ugQPvdW7+OICJw2Oki9eQ30j1dQKJ3S8UXLAQakvb icbQi+uvWzKbpyRT9TeAlGHZznVi9pYNDU8QC0uS2VYzbtTEnbn+iRxpgxnAJ2iYsnjJ /T1A== X-Forwarded-Encrypted: i=1; AJvYcCWjH1CcDrqlplAknlUOeAu1gIGwJfjr3qocBkGwX1Tk0lWp5wF2+d8G7nahqGpfoMp5PzhkunnNPEOK9Pg=@vger.kernel.org X-Gm-Message-State: AOJu0YxGx8N04/N8KmfHbsL7Boj8PY1hL/vf6NOPVokgRcQOVRUIuFwy /NVGDoiKVLv5jBtW2wBQoGQJscdMnmzuM/tVxZD4SaH0t9oT0CyKrOTwaqwBjhgwXg== X-Gm-Gg: AeBDiet9vUImGJATKYstEbxAxcvGtoYQHbI4Ff9HKHTO4YU36OPcd/ngauzFeVsdwNs MtEA7jQbXrbLCNsWEhNhD8R76XJpX/MUT8qAY9v4c8uVgEoPUY0FScv5zJN2hIP/bkoZdWvCI/D 1XZlUmgIztf51XtzDQzgt7aHAL0wVfU52OZ02LWRJGNWOIXuTNyMqj+KT+q5Rcr6TgdUvdfocG4 M19XLjGmbfvANtlXUL0TQprUiB6V5U8GYNRiJyp+91NyI+BYceLJPUl9xCsmg88+J5t+o50JI/Z kMuQoBAkJUtGZ8Yaa2NcD+unvjGeEJ0A75Zxjg2PIG45EMPOuOdL/KmTVdcKE5IOTBQBZxya0o6 m1EDoq78M+Jig2j0+ve5ZXFfCfm5ZU+hZnpHPe60RUaDM4J9t91T6iM9QaLDICvgmibyb9YNEss bc8Dmb+GqS8l8yaGp9g+iS2e1tZUZsw7GsYANidR5BLOuxDq0SvqejeCYe41SUBw== X-Received: by 2002:a05:7022:6709:b0:12b:fd86:b443 with SMTP id a92af1059eb24-12c28bfe72bmr2644176c88.7.1775776827535; Thu, 09 Apr 2026 16:20:27 -0700 (PDT) Received: from localhost ([2a00:79e0:2e7c:8:5d1f:ad34:cf0d:7e41]) by smtp.gmail.com with UTF8SMTPSA id 5a478bee46e88-2d561cd2a4esm2175767eec.16.2026.04.09.16.20.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Apr 2026 16:20:26 -0700 (PDT) Date: Thu, 9 Apr 2026 16:20:24 -0700 From: Brian Norris To: Bjorn Helgaas Cc: Bjorn Helgaas , linux-kernel@vger.kernel.org, Lukas Wunner , Manivannan Sadhasivam , linux-pci@vger.kernel.org Subject: Re: [PATCH v2] PCI/portdrv: Allow probing even without child services Message-ID: References: <20260220164046.GA3528004@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: <20260220164046.GA3528004@bhelgaas> Hi Bjorn, Sorry, I've gotten pretty busy, so this didn't top my list of things to try to reply to for a while. But thanks for your review! See below. On Fri, Feb 20, 2026 at 10:40:46AM -0600, Bjorn Helgaas wrote: > On Thu, Feb 19, 2026 at 06:35:42PM -0800, Brian Norris wrote: > > On Thu, Feb 19, 2026 at 04:25:14PM -0600, Bjorn Helgaas wrote: > > > On Mon, Feb 09, 2026 at 05:15:35PM -0800, Brian Norris wrote: > > > > +out: > > > > + /* With no child services, we shouldn't need bus mastering. */ > > > > + if (!capabilities) > > > > + pci_clear_master(dev); > > > > > > I'm curious about this part because we pci_set_master() > > > unconditionally just above: > > > > > > pci_set_master(dev); > > > pcie_init_service_irqs(dev, irqs, capabilities); > > > for (i = 0; ...; i++) > > > pcie_device_init(dev, service, irqs[i]); > > > if (!capabilities) > > > pci_clear_master(dev); > > > > > > Bus mastering on a bridge must be enabled for DMA from downstream > > > devices to work, but I think that's done by pci_enable_bridge() when a > > > driver calls pci_enable_device() for an endpoint. > > > > > > I assume the reason we call pci_set_master() here is so MSI/MSI-X from > > > the bridge will work, even if there is no downstream device. > > > > > > I don't think either pcie_init_service_irqs() or pcie_device_init() > > > requires bus mastering, so I don't know why we enable it here. It > > > seems like we should do it when we set up MSI/MSI-X interrupts. > > > > I'm no expert here, but by code inspection, pcie_init_service_irqs() may > > call pci_msi_set_enable() which sets PCI_MSI_FLAGS_ENABLE. Could that > > confuse a device to see MSI enabled but bus mastering disabled? > > You're right that this path may set the MSI Enable bit: > > pcie_init_service_irqs > pcie_port_enable_irq_vec > pci_alloc_irq_vectors > pci_alloc_irq_vectors_affinity > __pci_enable_msi_range > msi_capability_init > __msi_capability_init > pci_msi_set_enable(1) > # set PCI_MSI_FLAGS_ENABLE > > Setting MSI Enable allows the device to use MSI when it asserts an > interrupt, but my understanding is that it doesn't enable the > interrupt source itself. The MSI Capability is an interrupt > mechanism, not itself a source -- there's no interrupt handler at this > point. > > The sources have their own interrupt enable bits, e.g, Root Control > PME Interrupt Enable, Link Control Link Bandwidth Management Interrupt > Enable, Slot Control Hot-Plug Interrupt Enable, DPC Interrupt Enable, > AER Root Error Command Error Reporting Enable bits, > > The drivers using these interrupts should be setting up their > interrupt handlers before setting their interrupt enable bit. Ack, makes sense. > Bus master is a global thing that affects all kinds of transactions > coming from the device. There's no problem setting in from various > places, but clearing it in a single place affects all of them, so we > basically need global knowledge to know that it's safe. That's why I > suggested doing a conditional bus master enable instead of the > unconditional enable followed by a conditional disable. > > But I still do think this is not quite the right place even to enable > it. I think it would make more sense to enable bus mastering in the > drivers that need the MSI/MSI-X, e.g., PME, pciehp, bwctrl, aer, etc. > At this point in pcie_port_device_register(), I don't think we can be > certain that any of those services will actually enable the interrupt. I'm not quite sure what to say. I agree that in some sense, we (portdrv) are not the ones to know who's going to use bus mastering; and so moving that decision into child services makes a little sense. But then, we punt the problem of what to do on failure or unwind -- if any child enables bus mastering, it won't know whether it's ever safe to disable it on (a) subsequent error/unwind (say, in probe()); or (b) remove(). So is pci_set_master() a one-way operation done in child services (never call pci_clear_master()), and the only clear is via pcie_portdrv_remove() -> pci_disable_device()? Brian > > > If we want to do it in pcie_port_device_register() (instead of in > > > service driver when they set up an interrupt), maybe we should drop > > > the initial pci_set_master() and do it conditionally, e.g., > > > > > > if (capabilities) > > > pci_set_master(dev);