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 4E595606A322 for ; Fri, 4 Dec 2026 06:08:15 +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=eGo2ecr/; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=MZP3yH4x 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: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:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=7sSs+wS6J2Ar2MI+Mvwa47xlfH8qNZdM3U6PZZpUQGQ=; b=eGo2ecr/U5G6ynIlBBi8lYItZ0 nJ73+RRfwCSXTObs9MIN2DAzsQmvagUynJcGEddsVQwBXADtTWfk5WnLInUYBeuKVvduahlEWc1OH H7qKuWDqMIzLBvMqczaXERuf+YnDMEwIXl6WT5pq4XgZPbPh08jPa9MyXEL8YO0nYYSwrXpzTQLEV /KB37200YcPrYvkgxlUM5JLK2SPuPNJI3GgLFyZfE7H8wZUhPwTnsqjTZTldjFG9eVu8rU/PF43n9 uAzN/7R1bgYuyliMl6FjC35CTRkVhFP9M0Dzj966XwnLgfrZZwGtMpXlJKKZUbZ/prrLMP1MIXlDB QEJTQwbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZMSe-0000000Gl7j-0lcX; Fri, 04 Dec 2026 06:08:01 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZMSa-0000000Gl73-0VEV for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 06:07:57 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-8c6c06b3321so207702b3a.3 for ; Thu, 03 Dec 2026 22:07:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796364475; x=1796969275; darn=lists.infradead.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7sSs+wS6J2Ar2MI+Mvwa47xlfH8qNZdM3U6PZZpUQGQ=; b=MZP3yH4xTBwkiHLPPUS5aJj/GqGP/VCDJtZXT4BPGB1e0FYpTWDRro31pXN+6dFW7K okBCPPS+DvVYSWuiPDA77deiwr/eAXlHQG8npPC4Tv0wnSJhRydH175zcLo+BP2AIiQM pdZl5ZigCmvBuFwZIq5Jd/KgoTS0OcxmNjAQkPgMr4RFE5OJh81Bf/+FyB8Sb7JCJ5ev jFcCut24KMLsw/l6Uh/unvmdwVnjjtksmP1lwZ0bB4B+8GJctVI9ntxJQEoZ0YpqPg5D dREIX+JOoH59akgNY9Gi+U4bADEQYX4imqsmv/valLQofz8on6/bK8HZREetCY9i77WE Tx9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796364475; x=1796969275; h=content-transfer-encoding:content-type:mime-version: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=7sSs+wS6J2Ar2MI+Mvwa47xlfH8qNZdM3U6PZZ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rYDKWALt3C4NA8b4BhE7FzmKsFvXOOl+ECKwDgg4XylANry2g63xqObY IQxKXuLUyXwrfCL7qBdN8gewiyge+SRxygn+1tzXxfBYlWrAcvNTucLfb4JmL07P0LeGh7zVL65 3v9ViKGMLpEy7fAmg58XY1seNHLg5XIhy5yp0az3d+StXEghCK8CD0wBCxOa/5GHe+zfg/rClSF 4VjfPSXNQB6VEmBRXkwofeNZZvjKCvwJYlZ+pzqfUB622bn6h9Pq3szbKEHd44qGMLKrOEC9GFn GrDQ== X-Received: by 2002:a17:90b:4987:b0:3b0:ab34:afc8 with SMTP id 98e67ed59e1d1-3b5e0649e55mr739496a91.20.1796364474735; Thu, 03 Dec 2026 22:07:54 -0800 (PST) Received: from ryzen.lan ([2601:644:8000:37f::e34]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5e2569e3esm890616a91.7.2026.12.03.22.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 22:07:54 -0800 (PST) From: Rosen Penev To: linux-pci@vger.kernel.org Cc: Thomas Petazzoni , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org (moderated list:PCI DRIVER FOR MVEBU (Marvell Armada 370 and Ar...)) Subject: [PATCH] PCI: mvebu: Reset Root Ports with PERST# Date: Thu, 3 Dec 2026 22:07:51 -0800 Message-ID: <20261204060752.1243189-1-rosenp@gmail.com> X-Mailer: git-send-email 2.56.1 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-20261203_220756_164686_FB47193B X-CRM114-Status: GOOD ( 20.25 ) 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. 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 00b88b859dfd..6dcecbdba377 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 @@ -1356,6 +1357,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 @@ -1370,15 +1381,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; @@ -1395,6 +1401,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 @@ -1615,6 +1658,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