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 37763606A31C for ; Mon, 30 Nov 2026 06:37:48 +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=Qz5H+98Q; dkim=fail reason="signature verification failed" (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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=w3t4nE4Bcu92WfZi5nBAi8cFEHxhbVCHIHebpCruKck=; b=Qz5H+98Qd2P20euFxdPNC79tUk 39aRa/KHiWDvwYkL6TyIfkWt3rFO2GN+IKTOylYxNclGeTbwKZMvCr6h2u/GylQeRw7X3W4M+T0Y9 nliHE2Ojt6IX9POK7JNF15Ld+TPnowt+UUS/z49o5bUhRCb8gOl4eFqlYGadCKX+g0q/HapsXBr6I vRsA8Y5mLYeIbx0yDIhpDwpAImEth+aCxIVMowxFcaMPEUccXWi9QMWtiyT816m6ZOTXSA8Fmeem/ 7aFOgan7SINgRyMXEQyBvTGVML38Cty8m2cAZdcxc4a5qxfokYmK+KB2SubKzo4U/93U+ygUZ8smL LyB08goQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXv1H-00000003S3C-3gPp; Mon, 30 Nov 2026 06:37:47 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXv0R-00000003RZl-08d9 for linux-phy@lists.infradead.org; Mon, 30 Nov 2026 06:36:56 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-3ae691283ecso4632965a91.0 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=Vomciqv5bxEANES7IwwNCT4Yn1g7YW0OfHq388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Lv5xYbDHG293VF5bDnqZUDrg56mNSXpTt/dcjWXtKywTEV NgwWvk7G1pr8pEoOBBuZd67ZG/apCEkGbxmUo8Ywt1esbBeQZWk5WLZXsUAwu0pMRNwBTIurZfg oraaffqND+Fsp08+W+7cY7pm2xs= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261129_223655_099513_06559526 X-CRM114-Status: GOOD ( 16.19 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy