Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp224659iob; Mon, 2 May 2022 17:44:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXne1DeQLV9UXzv7zXU3f+jA1GxO9F6x8QVlOUWkjVGUl+Ae30FIdPTDLO29wXM09iUSVR X-Received: by 2002:a17:902:cf0c:b0:15b:63a4:9f47 with SMTP id i12-20020a170902cf0c00b0015b63a49f47mr14299511plg.1.1651538698949; Mon, 02 May 2022 17:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651538698; cv=none; d=google.com; s=arc-20160816; b=PjB/vOfmha85RsdzFuDv4HFaAtGSEbdjoO6ttNL4+wwzw5tBLwucHH0FZeBNiwj8y5 2ysjwdmV11GUMfcSDp8tFTgeNeZ2DaxynZu+gfi2fUkKQ05VELTB7verks8MmZGULEZJ 0OV8xbem67AAfylANtXlN3F9H7ksFFwQcfdn4QYZJ+WfIm3lYX+CkC4Y55D3J4bWaIDJ xltmGoFRR5ri403KvlM6femWAhir0tnFCPGSKmUuGqpCWVu80i/bFBq0P24wd9Nl7uQA R9TsWoiHcQezDqrldW1r32OgcAAd3ZpWJddO1ojfGLu7TGFXT0Za+xz1kfDtzukuqKa9 dxkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FCmnI7t3a3qeom/hBeMnGAKZRakWYCtmHHTnr/2mAHs=; b=R3bpx0e2r1NYD8BV5YpZqSzVLFOVDhEyLMtVu5ZAu9p+BjW3KNDPAgRo+VhJZycLL1 3FU7ETmW2NLqKM1idEQhq8jxm3pdO+s6JhzB6azg5c07BeMJfnuoGMSHFJaUuevfe91e ZFYx7KKi/fxz+FYSq6/VmHvAP91FESWcWWWZjfu90kxDM4AKUtn7Yngdj5eoqodu1KLP IiplauzFAqMXrov7Ri/uLJJa3DAKmptyopqoLwdxJ6KEePrz6Qbqmvpwcwq7rtPx6dQd U5WfmYH/nW58XW3XR6+c+xrVBrcPKgommeHZ7+1agGHNzo1UHNpTWSNedyM7qV9cizfG wF/A== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d15-20020a621d0f000000b004fdb5bf7840si14618543pfd.138.2022.05.02.17.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:44:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55FBB4B1F4; Mon, 2 May 2022 17:34:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384312AbiEBJmk (ORCPT + 99 others); Mon, 2 May 2022 05:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384278AbiEBJm2 (ORCPT ); Mon, 2 May 2022 05:42:28 -0400 Received: from mail.marcansoft.com (marcansoft.com [IPv6:2a01:298:fe:f::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E9B1BE9E; Mon, 2 May 2022 02:38:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id B4F7041E96; Mon, 2 May 2022 09:38:54 +0000 (UTC) From: Hector Martin To: Marc Zyngier Cc: Hector Martin , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Bjorn Helgaas , Alyssa Rosenzweig , Sven Peter , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/3] PCI: apple: Probe all GPIOs for availability first Date: Mon, 2 May 2022 18:38:31 +0900 Message-Id: <20220502093832.32778-3-marcan@marcan.st> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220502093832.32778-1-marcan@marcan.st> References: <20220502093832.32778-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we're probing the PCI controller and some GPIOs are not available and cause a probe defer, we can end up leaving some ports initialized and not others and making a mess. Check for PERST# GPIOs for all ports first, and just return -EPROBE_DEFER if any are not ready yet, without bringing anything up. Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up") Cc: stable@vger.kernel.org Signed-off-by: Hector Martin --- drivers/pci/controller/pcie-apple.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index e0c06c0ee731..e3aa2d461739 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -507,6 +507,20 @@ static u32 apple_pcie_rid2sid_write(struct apple_pcie_port *port, return readl_relaxed(port->base + PORT_RID2SID(idx)); } +static int apple_pcie_probe_port(struct device_node *np) +{ + struct gpio_desc *gd; + + gd = gpiod_get_from_of_node(np, "reset-gpios", 0, + GPIOD_OUT_LOW, "PERST#"); + if (IS_ERR(gd)) { + return PTR_ERR(gd); + } + + gpiod_put(gd); + return 0; +} + static int apple_pcie_setup_port(struct apple_pcie *pcie, struct device_node *np) { @@ -797,8 +811,18 @@ static int apple_pcie_init(struct pci_config_window *cfg) static int apple_pcie_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; + struct device_node *of_port; int ret; + /* Check for probe dependencies for all ports first */ + for_each_child_of_node(dev->of_node, of_port) { + ret = apple_pcie_probe_port(of_port); + of_node_put(of_port); + if (ret) + return dev_err_probe(dev, ret, "Port %pOF probe fail\n", of_port); + } + ret = bus_register_notifier(&pci_bus_type, &apple_pcie_nb); if (ret) return ret; -- 2.35.1