From patchwork Wed Sep 5 16:20:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Douglas X-Patchwork-Id: 10589181 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1908515E9 for ; Wed, 5 Sep 2018 16:21:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F29B32A4F1 for ; Wed, 5 Sep 2018 16:21:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E63872A4FD; Wed, 5 Sep 2018 16:21:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 264B12A4F1 for ; Wed, 5 Sep 2018 16:21:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727395AbeIEUwc (ORCPT ); Wed, 5 Sep 2018 16:52:32 -0400 Received: from mail-sn1nam02on0087.outbound.protection.outlook.com ([104.47.36.87]:47264 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726463AbeIEUwc (ORCPT ); Wed, 5 Sep 2018 16:52:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OtDG64sDFKtL0Di2fX/P+rYZe1kUWapYaFONY24qR5E=; b=NYIh93RA1PD5iTtJPNJ/aUdfRV2I2jeWvKTtZZuuEtsdU13Oh86UY9wBWekG/fLbOeytHfNjuNCeWtDuZ4lFl5FhKHnZ0DJt5F3T6IybOVdQc6qwUvwfVOxQGQGPh7/3P/6xPyGavVVwHJHkfie4HFCzbJDAYmaxX1FDtscNmqc= Received: from DM5PR07CA0106.namprd07.prod.outlook.com (2603:10b6:4:ae::35) by MWHPR07MB2958.namprd07.prod.outlook.com (2603:10b6:300:1f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.15; Wed, 5 Sep 2018 16:21:35 +0000 Received: from CO1NAM05FT053.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::209) by DM5PR07CA0106.outlook.office365.com (2603:10b6:4:ae::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1101.17 via Frontend Transport; Wed, 5 Sep 2018 16:21:34 +0000 Authentication-Results: spf=softfail (sender IP is 158.140.1.28) smtp.mailfrom=cadence.com; ti.com; dkim=none (message not signed) header.d=none;ti.com; dmarc=fail action=none header.from=cadence.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning cadence.com discourages use of 158.140.1.28 as permitted sender) Received: from sjmaillnx1.cadence.com (158.140.1.28) by CO1NAM05FT053.mail.protection.outlook.com (10.152.96.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.1143.1 via Frontend Transport; Wed, 5 Sep 2018 16:21:34 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id w85GLUwt016460 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Wed, 5 Sep 2018 09:21:32 -0700 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 5 Sep 2018 18:21:39 +0200 Received: from lvloginb.cadence.com (10.165.177.11) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 5 Sep 2018 18:21:39 +0200 Received: from lvloginb.cadence.com (localhost [127.0.0.1]) by lvloginb.cadence.com (8.14.4/8.14.4) with ESMTP id w85GLT4b013292; Wed, 5 Sep 2018 17:21:29 +0100 Received: (from adouglas@localhost) by lvloginb.cadence.com (8.14.4/8.14.4/Submit) id w85GLRtJ013236; Wed, 5 Sep 2018 17:21:27 +0100 From: Alan Douglas To: CC: , , , , Alan Douglas Subject: [PATCH] pci: cadence: Correct probe behaviour when failing to get PHY Date: Wed, 5 Sep 2018 17:20:08 +0100 Message-ID: <1536164408-10959-1-git-send-email-adouglas@cadence.com> X-Mailer: git-send-email 1.9.0 MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:158.140.1.28;IPV:CAL;SCL:-1;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(136003)(39860400002)(396003)(2980300002)(36092001)(199004)(189003)(316002)(42186006)(54906003)(16586007)(26826003)(86362001)(87636003)(478600001)(36756003)(5660300001)(6666003)(6916009)(336012)(14444005)(126002)(486006)(426003)(476003)(2616005)(26005)(1857600001)(186003)(107886003)(356003)(47776003)(7636002)(305945005)(50466002)(8676002)(2906002)(106466001)(48376002)(246002)(8936002)(105596002)(50226002)(4326008)(2351001)(51416003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR07MB2958;H:sjmaillnx1.cadence.com;FPR:;SPF:SoftFail;LANG:en;PTR:corp.cadence.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;CO1NAM05FT053;1:myIpCuAkECE8RWB5OeJODL4E1rXbHrbH8E2TT49S6ELt2w1b7aGzc+2j4dalMXE3gFlrq3D0DaMvRhQYwleoyzsywxwAUQxDq9dIiQwIRqefzvoM2tpEnwAlwvwY92u2 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b2f73ae-c8dd-49c4-eede-08d6134ba5fc X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:MWHPR07MB2958; X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB2958;3:TiF/BOCiZSJawD/od2cmkQdrk1X0+mzWe3IPJCq5i5xMkkJarHjqMVmgotMEPDdOu2YPdfalx9YwqCadag4DOXi/d65x3jkn3xBA8djPT5WFm+fF2zTNXDBzUuOvu80W6ndySo5gVq9BRg5L52LBmwO4tUnBdsgyGL9//s48Eyn4cuN49TfijAMHz4Nnwr9QY1woTHH6VyeeEE7ijvYc5FZdO5fPRbSOUxJQtWPyQdATI5Wl23XaA++UQ8FScAPVEPTSNWeBxyi5PwSceRTKejeiH56YMEL4ae3L8IC11U930dBT2Hwsq6JmUtyysGy2umfZo/3pU8nPYy/1KCui7nQvgARlQBFY9RrG0FftzQk=;25:/shZjaqwyIrdI0po/XHt+Z7c60LepLbLewit1q3OoZYRFseMlX09frZkCfSR4HH5VFTnxEIB4JjLfjFS5aok8YlgIOoPEV12VLh5K4UcacKE2WLn0Tl4r6omfCmxxacJ5yhUmxVRhhOXmSfJndbZie9ECJYrHCH5TSl54C0sqcr+jq2YBK1mD90QeGtqvhLVECnm6KkuTigAo84vNxYiGat4nRmhwhOT8jIwJU/iRbOSprWqPRWDt19dsYua4g/f7c2/MyTV9TG5GHDmBHmo7yTNK5Lutb7Wyc50+0JiSVYkMbk21mTs4DF6CPik18sbwSbADAz1Fw8I742tecMMHQ== X-MS-TrafficTypeDiagnostic: MWHPR07MB2958: X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB2958;31:pDpi5uloq2HOtqJLySW+q2ZSz+pmGf7QPz1MqFzcmp2BL1vZghNSJGz+hMcl/a2haN4VtMvVWlzLVLSkw8d/irB9E2xpcCPmtBJfkKNEKecjgIOPRrmYS17JZ6lKEzXm5Rn7gh67dzzXbPfk2kwmKTsR395QueaMpskoMN4Xb7NcXllCezWuL2HgegXacVVzt445mRcWlGGzM12kP8dUN9klqpof23G+P4U+54QHHb4=;20:5btdjueOBhL64sOL5Sxpj+e8cPHZspWTrupYCAgDFBuRzsB5RnI0iHDATr8gDaHWbGACaHX3lNUTWmJ2Cm9ED/9rU50bEYCii5zhS79/SJSPTtRC9z8ik8S0bX6avuwpZvL1uI49tAL4Tj39AZ4BKw1jyszVZcJpPkVBDRT9257ShsllQ+fxIGLSe+KHT3/64Fw34SZCaF4H5Rg3h/QfDWOhfvzDBGKE9GZffh1PJaj/TAjmtHeyofCl/BtXO0dR69CuKJULnhm+jykjiKueWzt7rAPToW497q/6M5mgxWIaXQt0eg3R2on/pZ0tZk2p+qn+eXhbOw8kjy0iE6Z+NM7UeD8DGnC0eI1/YCjxruJHzDO/YvUvlksQiKROWNE81adDU4pRrD9+v+/OJF8q606397/4NSVLLfCVYMdw6jFON6dTh03BvmzfOEOcFhk9Z2Vt+c7CNoeOYVxg0ldtiv41vCGhdW+0MT1vMxeeH2A2SKnEZDRkBz9OVUj39qYi X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72806322054110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93003095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699016);SRVR:MWHPR07MB2958;BCL:0;PCL:0;RULEID:;SRVR:MWHPR07MB2958; X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB2958;4:rvV1euytc3sYjf4tNtPryMawRTFE2pqgVSQPgjE56jpfnweH8m8AbZPpCEQGo4e0mSJM45tfNdzKp6ov8xPfIeTQ9JROpVnj7T1U4T01twLsPdDfVLVgLu6AS6hQeQELKxzV9VyoTGR7uo13qhtokZeQb42jYyRJ+tACh4CVMaQyc67T0JXjAKWUwffp9L8wqoHjpBmmvTSiHa+NAacU/rBVkddGQYPjZhbqfb9iS3m9QHgil8HSztm4eFko2lKLVql/Rjcc10FhYLW7NpluMqSAg9M6cr7sJ+GJ2dKbvMlyWW2dndUynCpeiLWfngRR X-Forefront-PRVS: 078693968A X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB2958;23:XDoLZUGNzyc/Jyt+utX3/d6Au9KgwHuZz+tiJN9YfHr/ygIXEv6RZ6p4m930G6o4CgO6Fb2Cypzw7NxI9z5qeTOUYWVxuXZ63161yvCKXI5vsPbcAoVHfmRYr16w92/XUomeZRCkniCwnBnT/RK5y409VGtP918ms6fEpNm+c+4oLnZHMBhhw9uRXa7k8vt/h4QR+l/lv9AzSOsnFjr0uYcs0lawgzJ3Wc8u3x/H0wNzozM68h57xdEgti2tCC1sUcktDzST/WcPq7uT6K4wdlcBGBvUvxPVqDA598OCk9LgQgOunV7QPHUTOeO/o1ezZBLvQlKyuPrxMKT5SWjq3FWVtreCb/EpLgPqzllbHPE6cwIN4vLQa+sxjq3BmsUna7Bjeh4wM0bBKAyBVfXaDpAJYkwhE9WvmM+mrcrmE8OvhRTDDQFakq2C+YcaYAHY9T+4kjQ9+T3FUwvIBUdsYPkhCeKF9ep8sadwjB2jukOVWyMAotz3OOiQqgywNDEj2a///EriC/UvvDf/ZgxtbQxkAYvzL0HBpxoekxXxTJDoycq4R3/Qs5AS5JpmVLU+kwHfJdZW8P5OPNNQs14W8+tx8J58XjoALD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IGRERgOL4V+xrkzFhtd6A78QXDhYUkE+F6CRXCycVhD1ZLJkU7GCluI4ABHiF X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2018 16:21:34.5920 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b2f73ae-c8dd-49c4-eede-08d6134ba5fc X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[158.140.1.28];Helo=[sjmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB2958 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Test the correct value to see whether the PHY get failed. Use devm_phy_get() instead of devm_phy_optional_get(), since it is only called if phy name is given in devicetree and so should exist. If failure when getting or linking PHY, put any PHYs which were already got and unlink them. Fixes: dfb80534692ddc5b ("PCI: cadence: Add generic PHY support to host and EP drivers") Signed-off-by: Alan Douglas --- drivers/pci/controller/pcie-cadence.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pcie-cadence.c b/drivers/pci/controller/pcie-cadence.c index 86f1b00..67d2f98 100644 --- a/drivers/pci/controller/pcie-cadence.c +++ b/drivers/pci/controller/pcie-cadence.c @@ -190,14 +190,16 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie) for (i = 0; i < phy_count; i++) { of_property_read_string_index(np, "phy-names", i, &name); - phy[i] = devm_phy_optional_get(dev, name); - if (IS_ERR(phy)) - return PTR_ERR(phy); - + phy[i] = devm_phy_get(dev, name); + if (IS_ERR(phy[i])) { + ret = PTR_ERR(phy[i]); + goto err_phy; + } link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS); if (!link[i]) { + devm_phy_put(dev, phy[i]); ret = -EINVAL; - goto err_link; + goto err_phy; } } @@ -207,13 +209,15 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie) ret = cdns_pcie_enable_phy(pcie); if (ret) - goto err_link; + goto err_phy; return 0; -err_link: +err_phy: while (--i >= 0) device_link_del(link[i]); + while (--i >= 0) + devm_phy_put(dev, phy[i]); return ret; }