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 5D8C4606A31C for ; Mon, 30 Nov 2026 06:37:58 +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=V6jHsO30; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=V8YtLaY5 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: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=Vomciqv5bxEANES7IwwNCT4Yn1g7YW0OfHq388RF0Lw=; b=V6jHsO30ptWF3p oVPO/goa8WJR9DQxR3fVJhwGAPB8YRls/wxzMMZPSRVmfBIWbwcD4s+khiUIAx1wmR1CwBM3R1gUX PsKMRPwOTdwSG1BLaUi91W7L2NHkIzd1A6mEFKL8x/PXQmFMKMSf0avaKKDUtqE+MSHC2rSd4aD4j lyUHEJWfD2f8f2qCN7KcBzS207dIniDrkFJaxaqxUkdAw/ITdfvDB2qBSo7crpxa6S+OpPh4KGCCg 92qlFXnitpHdLkIrRIbRmgnsgEEk6xemoTITDhXKBOg0cSCBIzDvMhPMXwuciJrkrmUyDkuH6j+0e xIUC2twT9LntHwfCb2Og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXv1E-00000003S1X-2vmh; Mon, 30 Nov 2026 06:37:44 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXv0R-00000003RZk-0Hjj for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 06:36:56 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-3ac9f49b984so5560991a91.1 for ; Sun, 29 Nov 2026 22:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796020614; x=1796625414; darn=lists.infradead.org; h=content-transfer-encoding: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=Vomciqv5bxEANES7IwwNCT4Yn1g7YW0OfHq388RF0Lw=; b=V8YtLaY5/YJWol4exN5Q56Ty195pbJ124DZujkbbddzQMkXPVXnK//h0Jph4CovRw8 olxhab2YUsZbM7cuwLA5r7fN4eWWni6tq7z/GM0XHlhxksCANsT7O4llo84K5BWXWUaL pS4CB4aDkAU0tGCrTp2Q0jf47l3bMxgZ7Ag1KBQxCyH0h5za48b6t5Ae6IIygePdJUwq gNDpmhtyvTmzQTiGzOyFr3uk1gv8OUxd7YC1mSh+/YE3o9tfde25+FjUNqOQ3CtvTxs7 Dwk6qhOtKb2TT9Q/vwzA8/Vr21PJDNlBHilr8+y2ui9ewRsXPUPOzItdG292AZ1BGs+O 60Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796020614; x=1796625414; h=content-transfer-encoding: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=Vomciqv5bxEANES7IwwNCT4Yn1g7YW0OfHq388R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+aaaRm5oPivoMu8EbK3g8JV7/T8XfrPPMY1kw25W+k3Hx7b9HLgXkp XbKA+hWjK+mf2CbOk2xrSIeNB4xJKQKNldMVqvSGEz1twGwllkkvQ1pMD4rR6vfIy5fWqPYf6PK 2Jj9gppYfcNA3eDq5xhXL9p3hDo= X-Received: by 2002:a17:90a:e710:b0:39e:6c68:fd91 with SMTP id 98e67ed59e1d1-3b41c96151cmr21685560a91.38.1796020614074; Sun, 29 Nov 2026 22:36:54 -0800 (PST) Received: from localhost ([2001:19f0:8000:4ce8:5400:7ff:fe0e:e6b2]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b40a878d50sm53822836a91.11.2026.11.29.22.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 22:36:53 -0800 (PST) From: Inochi Amaoto To: Andy Shevchenko , Jonathan Corbet , Shuah Khan , Randy Dunlap , Damien Le Moal , Niklas Cassel , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Aksh Garg , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Vinod Koul , Neil Armstrong , Vladimir Oltean , Rhys Tumelty , Inochi Amaoto , Qiang Yu , Manikandan K Pillai , "vladimir.oltean@nxp.com" , Hans Zhang <18255117159@163.com>, Yao Zi Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-phy@lists.infradead.org, Yixun Lan , Longbin Li Subject: [PATCH v6 7/8] PCI: cadence: Use phy bulk data api to simplify the logic Date: Mon, 30 Nov 2026 14:36:06 +0800 Message-ID: <20261130063607.294823-8-inochiama@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130063607.294823-1-inochiama@gmail.com> References: <20261130063607.294823-1-inochiama@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261129_223655_112936_431DDF42 X-CRM114-Status: GOOD ( 17.61 ) 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=-15.8 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 According the document of cadence PCI controller, it use multiple phys for multi-lane setup, so replace the loop of phy operation with phy bulk apis. Signed-off-by: Inochi Amaoto Reviewed-by: Vladimir Oltean --- drivers/pci/controller/cadence/pcie-cadence.c | 62 +++++-------------- drivers/pci/controller/cadence/pcie-cadence.h | 2 +- 2 files changed, 16 insertions(+), 48 deletions(-) diff --git a/drivers/pci/controller/cadence/pcie-cadence.c b/drivers/pci/controller/cadence/pcie-cadence.c index 0ac980249941..8ed2a679625d 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.c +++ b/drivers/pci/controller/cadence/pcie-cadence.c @@ -179,39 +179,22 @@ EXPORT_SYMBOL_GPL(cdns_pcie_reset_outbound_region); void cdns_pcie_disable_phy(struct cdns_pcie *pcie) { - int i = pcie->phy_count; - - while (i--) { - phy_power_off(pcie->phy[i]); - phy_exit(pcie->phy[i]); - } + phy_bulk_power_off(pcie->phy_count, pcie->phy); + phy_bulk_exit(pcie->phy_count, pcie->phy); } EXPORT_SYMBOL_GPL(cdns_pcie_disable_phy); int cdns_pcie_enable_phy(struct cdns_pcie *pcie) { int ret; - int i; - for (i = 0; i < pcie->phy_count; i++) { - ret = phy_init(pcie->phy[i]); - if (ret < 0) - goto err_phy; + ret = phy_bulk_init(pcie->phy_count, pcie->phy); + if (ret) + return ret; - ret = phy_power_on(pcie->phy[i]); - if (ret < 0) { - phy_exit(pcie->phy[i]); - goto err_phy; - } - } - - return 0; - -err_phy: - while (--i >= 0) { - phy_power_off(pcie->phy[i]); - phy_exit(pcie->phy[i]); - } + ret = phy_bulk_power_on(pcie->phy_count, pcie->phy); + if (ret) + phy_bulk_exit(pcie->phy_count, pcie->phy); return ret; } @@ -221,10 +204,8 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie) { struct device_node *np = dev->of_node; int phy_count; - struct phy **phy; - int i; + struct phy_bulk_data *phy; int ret; - const char *name; phy_count = of_property_count_strings(np, "phy-names"); if (phy_count < 1) { @@ -233,31 +214,18 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie) return 0; } - phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL); - if (!phy) - return -ENOMEM; - - for (i = 0; i < phy_count; i++) { - of_property_read_string_index(np, "phy-names", i, &name); - phy[i] = devm_phy_get(dev, name); - if (IS_ERR(phy[i])) { - ret = PTR_ERR(phy[i]); - goto err_phy; - } - } + phy_count = devm_phy_bulk_get_all(dev, &phy); + if (phy_count < 0) + return phy_count; + else if (phy_count == 0) + return -ENODEV; pcie->phy_count = phy_count; pcie->phy = phy; ret = cdns_pcie_enable_phy(pcie); if (ret) - goto err_phy; - - return 0; - -err_phy: - while (--i >= 0) - devm_phy_put(dev, phy[i]); + devm_phy_bulk_put_all(dev, phy); return ret; } diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h index 4a96e1869e53..3cde29592331 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -274,7 +274,7 @@ struct cdns_pcie { bool is_rc; bool is_hpa; int phy_count; - struct phy **phy; + struct phy_bulk_data *phy; const struct cdns_pcie_ops *ops; const struct cdns_plat_pcie_of_data *cdns_pcie_reg_offsets; int max_link_speed; -- 2.56.1