From patchwork Sun Jul 16 06:42:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 107862 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3051765qge; Sat, 15 Jul 2017 23:42:12 -0700 (PDT) X-Received: by 10.84.232.8 with SMTP id h8mr5268283plk.189.1500187332324; Sat, 15 Jul 2017 23:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500187332; cv=none; d=google.com; s=arc-20160816; b=OtwCg/Ur4Ryl/K2zgLZnr4n4l2Cf8DDZcx0PsiDf5m+hG2/QwXUnMkUrohebkG9/v3 pG6Z4ePn0xu4kPffnhxLAuoEeUQV3CZ8zkJV+smPrI6fElv2ak2Q14Xlkw9Ss7L2k8dz wiH33Rfs4t3c5j4np4BEwJhnkOhpeAaZKULPUBn8mLGV4D9CLsH4LdCTi6FYgTAazJrG a3z288bH0I3bzb9w/se7Jxy3y93Ee5sKI+bkExj3gWhRuSZnozdQ7NJT6MY+bGuwv1oC ailQSfiV+fd8wHkV+tWjniJqwtMy5Gm1NvoHwouGIo+Gd9db2BBnWkdKoW+pSZaoakVH SYUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=lZqzV6/1Jujy3zBv9MHdS3T5STeiZroe+wReN7LHpF4=; b=REWfJBwPk1h4xu8Qp5VGhS5CLFHFf1Yo6D72wEWl6WUq8Sz1oxIPynAkp1F+MynmW1 /z2jPIKS3nYZ2dq7rgx9CCDXfR4RFHE2R35i8b8M/cOEhoYxxe+a42QIAZ/A6P8fRiFh hwm+JDNFMZ8qmiQ2mohGU1ky22BYOyc8vI4U8ksgy5to23NIOPhMkC3whtp/jelKw6yS hdkUIuNZqVyvbr8n8iO/Aj3lwPR7m5IWemXSaPv1sEev68rht4UGJkvuesCFeU3uE6HX HCVtGY7/1hG9EhCNBdyIwjSnmEk5phnsG4RES9fHQTL/Sx8u3t5tnjSMOeXMNOrV/XwJ r+PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=ck4Vv+lq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si2489675pli.540.2017.07.15.23.42.12; Sat, 15 Jul 2017 23:42:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=ck4Vv+lq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751290AbdGPGmJ (ORCPT + 25 others); Sun, 16 Jul 2017 02:42:09 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:34313 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751274AbdGPGmH (ORCPT ); Sun, 16 Jul 2017 02:42:07 -0400 Received: by mail-pg0-f54.google.com with SMTP id t186so64335161pgb.1 for ; Sat, 15 Jul 2017 23:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lZqzV6/1Jujy3zBv9MHdS3T5STeiZroe+wReN7LHpF4=; b=ck4Vv+lqRAQk8VWX3KpvIN6VeEGNjLRdxfHaHHf7wRx+v/0HBW7KucvcCg8mLCGrIN xf1FrjqjXKrk3apk7qOLEw4uLq3ZBwro0I/WU8VELOLZHnn0ABTu9f4qfKnCL/YopfFd VcCBnxb+f+8dKyIADWBstjeDIO44ocqxfoEws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lZqzV6/1Jujy3zBv9MHdS3T5STeiZroe+wReN7LHpF4=; b=bww47VNBM4EQogCU9qJbmTIlpI6w7MTvUn8XieSHSxjCtQfL0/DIF7RTs7wVa1G/Yb WjZy3NqIWhWUJfVB8Tx9elQihAmREtE7ltlgprq3JddupIPUjLQtUnVmB388aFSS69B3 GFxGGp3r8ftDUm+OkAiLuGVMIUiLtRLued0d8SEQ5tSMgn33FLtIg8ArEhu8DGmP0drd nknZr2EUX6Gz8vw/PWci3IG+GJD0LBhdJDmJE5WtvYzjTSmaM8+hs+CHaEQ4lQMpu1gq YPtU2Fd2ALoB9PBFosL53pBzUC6HOdsE8UfB4/CDGSFCLMpkEgl/uZr8QnoD6mlr6G1B /FgA== X-Gm-Message-State: AIVw113C3p+rfdhpShdq/iEN1zO5li3ll0Yzz40VmyftuV8XixrGd2Ji JLlP6/FnlJO8U25g1VmX8w== X-Received: by 10.99.62.65 with SMTP id l62mr12889186pga.220.1500187326739; Sat, 15 Jul 2017 23:42:06 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id q19sm7629790pgq.51.2017.07.15.23.42.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Jul 2017 23:42:06 -0700 (PDT) From: Bjorn Andersson To: Stanimir Varbanov , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] PCI: qcom: Allow post_init to fail Date: Sat, 15 Jul 2017 23:42:03 -0700 Message-Id: <20170716064203.3406-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org host_init should detect and propagate errors from post_init. In addition, by acknowleding that post_init can fail we must disable the post_init resources in a step separate from the deinit, so that we don't try to disable the post_init resources a second time. Signed-off-by: Bjorn Andersson --- drivers/pci/dwc/pcie-qcom.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) -- 2.12.0 Acked-by: Stanimir Varbanov diff --git a/drivers/pci/dwc/pcie-qcom.c b/drivers/pci/dwc/pcie-qcom.c index 7b703741a3fd..26e84a957c35 100644 --- a/drivers/pci/dwc/pcie-qcom.c +++ b/drivers/pci/dwc/pcie-qcom.c @@ -124,6 +124,7 @@ struct qcom_pcie_ops { int (*init)(struct qcom_pcie *pcie); int (*post_init)(struct qcom_pcie *pcie); void (*deinit)(struct qcom_pcie *pcie); + void (*post_deinit)(struct qcom_pcie *pcie); void (*ltssm_enable)(struct qcom_pcie *pcie); }; @@ -517,13 +518,19 @@ static void qcom_pcie_deinit_v2(struct qcom_pcie *pcie) { struct qcom_pcie_resources_v2 *res = &pcie->res.v2; - clk_disable_unprepare(res->pipe_clk); clk_disable_unprepare(res->slave_clk); clk_disable_unprepare(res->master_clk); clk_disable_unprepare(res->cfg_clk); clk_disable_unprepare(res->aux_clk); } +static void qcom_pcie_post_deinit_v2(struct qcom_pcie *pcie) +{ + struct qcom_pcie_resources_v2 *res = &pcie->res.v2; + + clk_disable_unprepare(res->pipe_clk); +} + static int qcom_pcie_init_v2(struct qcom_pcie *pcie) { struct qcom_pcie_resources_v2 *res = &pcie->res.v2; @@ -907,8 +914,11 @@ static int qcom_pcie_host_init(struct pcie_port *pp) if (ret) goto err_deinit; - if (pcie->ops->post_init) - pcie->ops->post_init(pcie); + if (pcie->ops->post_init) { + ret = pcie->ops->post_init(pcie); + if (ret) + goto err_disable_phy; + } dw_pcie_setup_rc(pp); @@ -924,6 +934,9 @@ static int qcom_pcie_host_init(struct pcie_port *pp) return 0; err: qcom_ep_reset_assert(pcie); + if (pcie->ops->post_deinit) + pcie->ops->post_deinit(pcie); +err_disable_phy: phy_power_off(pcie->phy); err_deinit: pcie->ops->deinit(pcie); @@ -971,6 +984,7 @@ static const struct qcom_pcie_ops ops_v2 = { .init = qcom_pcie_init_v2, .post_init = qcom_pcie_post_init_v2, .deinit = qcom_pcie_deinit_v2, + .post_deinit = qcom_pcie_post_deinit_v2, .ltssm_enable = qcom_pcie_v2_ltssm_enable, };