Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3747652pxt; Tue, 10 Aug 2021 10:21:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmyb18eJw6+ShvNZJ0pq3tG5bX5Pi4SbAfC6DlV/8GiZN+M7bRk3zb3jkqYjL6qKbpwUhN X-Received: by 2002:a92:c266:: with SMTP id h6mr57118ild.273.1628616116754; Tue, 10 Aug 2021 10:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628616116; cv=none; d=google.com; s=arc-20160816; b=osX4mDfmsap77RvsTNceZFrdQslCn6dveAypkq50MgWR9yjtpqLxtEhVvWjmXHdowG QEggJDt0ngxIJsVIUughgyyCwN9Oy9rHLPPY3FZFVbABqQBVQHNMSPvOsqc2P0xTogBe a4W+Yz8e8GTcTUI210oSeoe+WgQg+xbUi1f78CQctEqtCpGO8XuNxwIVV8LFO15MSsZb zKEze3FYXFm4Yh4cbuQq7UdAKWa1Aty5oah+Q3bV5XFplvse+J6fE+kTnFgpgtyQUUU9 flFc2KuODoeUc1vlZvYXYGJp6nCm8Mrl29YtBoW3c5ze7sY+zhoWqcu8Z7pnYOOGEtqv ZwWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a5nBantSJ1Is1ztAZTSQavM2GNoVkLoWkGoxDh+artA=; b=f4C7NE8cFimCx/g5fagvqP/W7AXlDMfRjhpOZ/87KCfxVctY0nfViCRj6llDAqha2A hx5Au+asTlqeaDBIJ2pGlEh9JtQXb/C6yy4bbu2PxaRQhi6vdigdVZR9CeS6dTjyCofP GLPMbJEF0rS8Vpt3LQUg70ZI/dbWo4+xp1Km+3eWO+cc0CRfIezMmN7JokOa7DiJaJIT USG9RIcNNDavfuW4JyeA1S+dpNCk8/rY9M6YfUcspJeui7PyXsEPPYt0P7+wF3OeUuUq KQnSx+3kwaLdOAuQU5Iap5wgn7cdFMG/Y30a7AlC97bbJuOn0dN9zzZ7U34dWQVMIqBD bYiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=goRCDJKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si13855643iob.65.2021.08.10.10.21.44; Tue, 10 Aug 2021 10:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=goRCDJKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239464AbhHJJ4w (ORCPT + 99 others); Tue, 10 Aug 2021 05:56:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:42978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239292AbhHJJ4K (ORCPT ); Tue, 10 Aug 2021 05:56:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C29D61163; Tue, 10 Aug 2021 09:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628589349; bh=sV+bbSB/ojGgth+jvILzvzxrJl5qHKm76Hwybjb+ZWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=goRCDJKOwPnTUeJZEGOin6pq5ASpAvbfWsjKUhK6GTi6y9iM8f8hZ2A/ntLbImFdS 2tPhIE0lmpDf9amN+EzxOep+WfIlE+PoNNV7JWI6fD6yBWr0AUiIqzgy8KGLIb1oSv kxOfQBL78lRpqt1WV/8SdaWVq/GP8y14E7Gby270GiLXywYHJPndiqBEyitHYS0c2D 2CXTkOJCD9wPbxv8MzvgOWZ3EmcX9D9LgxYiQprlHqSsOgmo12X+i3ndMsX/oPX/v/ 6kChbf4VKMO09r9V1+JrqRTlSN6Yb1VekIo8cY2IYv2kZNcGNgTdv1dahz84ZYbWnV PJ+uEnalduqJg== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mDOU6-00AcGB-3M; Tue, 10 Aug 2021 11:55:46 +0200 From: Mauro Carvalho Chehab To: Vinod Koul , Bjorn Helgaas Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Binghui Wang , Lorenzo Pieralisi , Rob Herring , Xiaowei Song , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v10 10/11] PCI: kirin: fix poweroff sequence Date: Tue, 10 Aug 2021 11:55:41 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver currently doesn't call dw_pcie_host_deinit() at the .remove() callback. This can cause an OOPS if the driver is unbound. While here, add a poweroff function, in order to abstract between the internal and external PHY logic. Signed-off-by: Mauro Carvalho Chehab --- drivers/pci/controller/dwc/pcie-kirin.c | 30 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index 21453d21ebad..5535605ab1e7 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -678,6 +678,23 @@ static const struct dw_pcie_host_ops kirin_pcie_host_ops = { .host_init = kirin_pcie_host_init, }; +static int kirin_pcie_power_off(struct kirin_pcie *kirin_pcie) +{ + int i; + + if (kirin_pcie->type == PCIE_KIRIN_INTERNAL_PHY) + return hi3660_pcie_phy_power_off(kirin_pcie); + + for (i = 0; i < kirin_pcie->n_gpio_clkreq; i++) { + gpio_direction_output(kirin_pcie->gpio_id_clkreq[i], 1); + } + + phy_power_off(kirin_pcie->phy); + phy_exit(kirin_pcie->phy); + + return 0; +} + static int kirin_pcie_power_on(struct platform_device *pdev, struct kirin_pcie *kirin_pcie) { @@ -723,12 +740,7 @@ static int kirin_pcie_power_on(struct platform_device *pdev, return 0; err: - if (kirin_pcie->type == PCIE_KIRIN_INTERNAL_PHY) { - hi3660_pcie_phy_power_off(kirin_pcie); - } else { - phy_power_off(kirin_pcie->phy); - phy_exit(kirin_pcie->phy); - } + kirin_pcie_power_off(kirin_pcie); return ret; } @@ -737,11 +749,9 @@ static int __exit kirin_pcie_remove(struct platform_device *pdev) { struct kirin_pcie *kirin_pcie = platform_get_drvdata(pdev); - if (kirin_pcie->type == PCIE_KIRIN_INTERNAL_PHY) - return hi3660_pcie_phy_power_off(kirin_pcie); + dw_pcie_host_deinit(&kirin_pcie->pci->pp); - phy_power_off(kirin_pcie->phy); - phy_exit(kirin_pcie->phy); + kirin_pcie_power_off(kirin_pcie); return 0; } -- 2.31.1