From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28C3A606A32F for ; Sun, 6 Dec 2026 09:41:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=GRvT5VkU; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=sMjRqBtp DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=HmR5dw6pu5v1EGRHk4GyOLw6Ge8TqCC5aIrgni42LdU=; b=GRvT5VkUk8chMU t4vIQ2USimztgIRoobVfiVFKs8+LLOXiDDfnmKSNqsbkzKmO/YpzAvK+mh6lowQmsR9Der9ZYONon MWIBx8uUZ7kOPu4Wb8CJRHBdoS8pKTTpfAQLIUT0V48GxPAKhugveG6TMWlt47zXoIY787Jq0RDn2 5KSpgSPc3yAaNbSjqha4yXz7RwMx9De3pWqg/MjRslhZWaYkrVmKLkTxEWFiVSjSZ2omOpf4+pdRF hzbHmUud3KU9AvN9Em5eJkR9Hrm9PPEl5x4S8Nnl4wXkzHe99fODPQzk1CFI2TVg8d8vESDN9hUo0 czmBaU6mnvG/ogG90sXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xa8jr-00000003RKA-0LoL; Sun, 06 Dec 2026 09:40:59 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xa8jn-00000003RIL-3PnI for linux-arm-kernel@lists.infradead.org; Sun, 06 Dec 2026 09:40:57 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2f1a4443407so13375135ad.3 for ; Sun, 06 Dec 2026 01:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796550055; x=1797154855; darn=lists.infradead.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=HmR5dw6pu5v1EGRHk4GyOLw6Ge8TqCC5aIrgni42LdU=; b=sMjRqBtpv3r6E+DmxdT3oO05qcY1WSRnFdTJAH5DgC+tS8wxVTl/iEYV2U2C6WT9uQ 8TNuH3qNZ2juEEBgW1kPlej3oWbLmSw4WSifRnGXp3EoPX74v94kg5bckdN8Ec4OcXHG fW3Lf9tX/9JryaDrphFbMSs/cTdRqpfT4LFS3bNA0yLFLCVYwwbFA1xA8tGQosWUBwOc GxQkzlocLXP255SRz/SZVfpU+uBMZXXZji8y0E9m5C299KXiiDmy3M+EsBYIR74hSNQc KJQAUfnip2rVLhXvqaGiY/V6uqQuFEfUU+8sZhUo+rXZHm/J6aBNRk6w/5iOuoC+FgQ9 YrmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796550055; x=1797154855; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HmR5dw6pu5v1EGRHk4GyOLw6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9kvFI5K8ycP7Xu8LdHc9j/WXNEGeh8GtNFyzZh6BZIOtO50bfQqUoTZ95 2C8zYjHEtPxpJsqlahOlIkf5iiLUjpwYB7RlAOi/PSnSETvHJsW9grRm7nc0X7VIUl3MV3ZXcBg PE/solbSSRH4hp1oAkIjWXpoSZCJNRL31jAgKXzjMdPc4WIX4JmoeDEcafsG5EOpj8CkwyC3Z/L quWPpBdHq5/l9Pp4A9ostUyc+pAHi+sHYPcKba+W1QBAK4KgpYIC0FB/XknFKUraLbAYJ9RuSjw rlGg== X-Received: by 2002:a17:90b:3c09:b0:3b4:1bf1:988a with SMTP id 98e67ed59e1d1-3b5e063e237mr6274626a91.55.1796550054824; Sun, 06 Dec 2026 01:40:54 -0800 (PST) Received: from ryzen.lan ([2601:644:8000:37f::e34]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c7d10d06sm18102513a91.3.2026.12.06.01.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 01:40:54 -0800 (PST) From: Rosen Penev To: Thomas Petazzoni , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Frank Li Cc: Rob Herring , Manivannan Sadhasivam , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/3] PCI: mvebu: Reset Root Ports with PERST# Date: Sun, 6 Dec 2026 01:40:33 -0800 Message-ID: <20261206094043.971494-4-rosenp@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261206094043.971494-1-rosenp@gmail.com> References: <20261206094043.971494-1-rosenp@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261206_014055_862630_7BF54963 X-CRM114-Status: GOOD ( 21.31 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 A function reset of a device whose only reset method is "bus" ends up in pcibios_reset_secondary_bus() on its Root Port. Without a reset_root_port() callback, that triggers an in-band hot reset through the emulated bridge (PCIE_CTRL_MASTER_HOT_RESET). Some devices don't reset fully on a hot reset: the Marvell 88W8864 and 88W8964 Wi-Fi chips only return to their boot ROM on PERST# or power-on, so once their firmware has run, the driver can't be bound to them again until the board is rebooted. When the port has a reset GPIO, implement reset_root_port() by pulsing PERST# instead: assert it for 1-2 ms (more than the 100 us Tperst minimum), release it, wait the same time as at power-up (reset-delay-us, by default PCI_PM_D3COLD_WAIT), and wait up to a second for the link to come back. Ports without a reset GPIO keep the hot reset, through pci_reset_secondary_bus(). With the callback registered, pcibios_reset_secondary_bus() also restores the Root Port's config space after the reset, on every port. It saves that state right before the reset, so this restores the current PCI_COMMAND rather than the one saved at enumeration, which has memory decoding and bus mastering off. Factor the reset-delay-us lookup out of mvebu_pcie_powerup() so both use the same delay. Tested on a Linksys WRT3200ACM (two 88W8964 radios, PERST# on MPP45 and MPP46): unbinding and binding mwlwifi again, with mwlwifi calling pci_reset_function_locked() when the boot ROM doesn't answer, now reloads the firmware of either radio. Signed-off-by: Rosen Penev --- drivers/pci/controller/pci-mvebu.c | 56 ++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index 4e9544d61622..d5c874d6c2b3 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1358,6 +1359,16 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, return ret; } +/* Time to wait after releasing PERST# before the device is accessed. */ +static unsigned int mvebu_pcie_port_reset_delay_ms(struct mvebu_pcie_port *port) +{ + u32 reset_udelay = PCI_PM_D3COLD_WAIT * 1000; + + of_property_read_u32(port->dn, "reset-delay-us", &reset_udelay); + + return reset_udelay / 1000; +} + /* * Power up a PCIe port. PCIe requires the refclk to be stable for 100µs * prior to releasing PERST. See table 2-4 in section 2.6.2 AC Specifications @@ -1372,15 +1383,10 @@ static int mvebu_pcie_powerup(struct mvebu_pcie_port *port) return ret; if (port->reset_gpio) { - u32 reset_udelay = PCI_PM_D3COLD_WAIT * 1000; - - of_property_read_u32(port->dn, "reset-delay-us", - &reset_udelay); - udelay(100); gpiod_set_value_cansleep(port->reset_gpio, 0); - msleep(reset_udelay / 1000); + msleep(mvebu_pcie_port_reset_delay_ms(port)); } return 0; @@ -1397,6 +1403,43 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port) clk_disable_unprepare(port->clk); } +/* + * Reset the device below a Root Port. The in-band hot reset that + * pci_reset_secondary_bus() triggers through the emulated bridge does not + * reset every device (some only return to their boot ROM on PERST#), so + * pulse PERST# when the port has a reset GPIO. + */ +static int mvebu_pcie_reset_root_port(struct pci_host_bridge *bridge, + struct pci_dev *dev) +{ + struct mvebu_pcie *pcie = pci_host_bridge_priv(bridge); + struct mvebu_pcie_port *port; + bool up; + int ret; + + port = mvebu_pcie_find_port(pcie, dev->bus, dev->devfn); + if (!port) + return -ENODEV; + + if (!port->reset_gpio) { + pci_reset_secondary_bus(dev); + return 0; + } + + gpiod_set_value_cansleep(port->reset_gpio, 1); + /* PERST# must stay asserted for at least 100 us (Tperst) */ + usleep_range(1000, 2000); + gpiod_set_value_cansleep(port->reset_gpio, 0); + msleep(mvebu_pcie_port_reset_delay_ms(port)); + + ret = read_poll_timeout(mvebu_pcie_link_up, up, up, 1000, + USEC_PER_SEC, false, port); + if (ret) + dev_warn(&dev->dev, "link down after PERST#\n"); + + return ret; +} + /* * devm_of_pci_get_host_bridge_resources() only sets up translatable resources, * so we need extra resource setup parsing our special DT properties encoding @@ -1622,6 +1665,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev) bridge->child_ops = &mvebu_pcie_child_ops; bridge->align_resource = mvebu_pcie_align_resource; bridge->map_irq = mvebu_pcie_map_irq; + bridge->reset_root_port = mvebu_pcie_reset_root_port; return pci_host_probe(bridge); } -- 2.56.1