Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1672853lql; Wed, 13 Mar 2024 05:17:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUYMlY90lS9mg4YjLc8iA4NUHpKVGnKoL/NH6CiWnGtXdgJBcZKiyzelzaZ95TyJjhFj88ugVgNLq3BtlNBJBnINiFCwRYamHhA0KUZ1w== X-Google-Smtp-Source: AGHT+IHM4k2mPrFCMLx0Rh57Uv4oWf6H2ygdLJ/TjDN1rAKG1WX6r9VQiqaIz9t59TYbQKdQ2hkd X-Received: by 2002:a17:907:6d07:b0:a46:22a3:479f with SMTP id sa7-20020a1709076d0700b00a4622a3479fmr7513479ejc.21.1710332245538; Wed, 13 Mar 2024 05:17:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710332245; cv=pass; d=google.com; s=arc-20160816; b=oSqdHh3Efp3vNWRll3BvQwi3LzZq7WEy3JqF/3nE/eoRhqKYPmWstshkqj5Wch2wDV Pli5nnK4qBsO2cHkOPebk+//n9uFGjplE6p0v0kKHDZ1oc2V5DvhzHqHfXdpndDxs2GU cjNpd/97Z7YMyZBbXH6RPoeHopoMcL6ElK7zFu8Op1pFyyI/IsOnpf1WAVmUDd1xTGoO WLk+0J7ujNNZkfd567oeFfokBgpNvFcDaG8eoRR5wvE9OVrR1qc8E+mazn7ff4o/HjOn NOahLrLJk2iKDc8I/wHrzmju2SNmuhBKJBcU3v8Ta159upxq0Tkyie935L9pP2Vt1gYb IUAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=fkFrCRZ7REzYM7HPzWkHOB/qAAg9L6SN2KGBi6tV2U8=; fh=8GJ9z26jo3Hfw9IUZ3mNrh02DqSULMvbw08YU0NvlC4=; b=fdvilI6NGxar4rUH9g9nCoYVttHAuRQGebnPR9bZ3fRRREbhKcvPOXo7c3ekZMS/MK cJMt+81ChTmQyF8IeFxMwjfNcDBvo7O6PCLVmKg83ifl3Y91Tbsbl+WdsxhdMfKjJELH Uh0mQ64aZ/i9Ndhsq+IzbMIEcHeMFJUq5oGER3OsS/6HMh3zrTQxZiKFWaDprMqU8wNF dfWVuWoUqdU9AWSBtzIyLBzGe+hp0esM8KAp18QYBb9TvvvT1LHGuk3UIsBSDPgwdy+Z qMn/HTeY7OFZBY45y4weKVIK5FHs3D9vJd8nagthRSdef4r6upOhkHUHLJWLVIJQKZxI 9LYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dH8hHJWQ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-101458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qk9-20020a170906d9c900b00a462ff997d7si2419788ejb.890.2024.03.13.05.17.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 05:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dH8hHJWQ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-101458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C10DA1F24320 for ; Wed, 13 Mar 2024 12:09:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A02833FB04; Wed, 13 Mar 2024 12:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dH8hHJWQ" Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C83D73FB0F for ; Wed, 13 Mar 2024 12:09:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710331774; cv=none; b=McGxtpkoT8htIHKdd46wB6TrZzyVSNw3BOsEvhBal+l4rpyoPO4ZOv9mey382PZ62k9wlPtqU2bWLnHecRYa6JnlNDzV5gSvhBE54eiaNvm3Fg1roPsjntKnk7sihpfrxzMfUL39mxn+t3aoogERlyVGH0D2y2VznMByLAl2HDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710331774; c=relaxed/simple; bh=PaWJKUsVlyLQ/OT+v64+m7jQDF3xuZkRa2uz3Sn7OxQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=p32w/lsgmOUp2Dj9pOpbGvedxCai+nzTkIunAU32AcpgqSPTFkrZKdDtMiD4VcdL7vATj0qWmGJ6Em8vTCbVZQrupIRplOR+R+i781vWEHkA+d4nMQRCvkb4NQPoBOnJnBV74vdcCjyt8E/+B7FYGQL4f7SkYI6U38baUHooX+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=dH8hHJWQ; arc=none smtp.client-ip=209.85.160.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-42a029c8e62so41993671cf.1 for ; Wed, 13 Mar 2024 05:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710331771; x=1710936571; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=fkFrCRZ7REzYM7HPzWkHOB/qAAg9L6SN2KGBi6tV2U8=; b=dH8hHJWQTphkmvll8n04qLSgOH6UD1A5rEMG3lCbztiAMf2NJpUQZEDQQc8B+pxuic R+M/ufkF2CUg0aF+M4bcBDrcmt3ll3+gZR8sdE8CrhwoNN7LYdaMXiZiNnViHMtCJIcg V6YKE8gfIrN066Z5NGlovIfT8RuBmg7F++Qu5uVRBawQEW5XSRQ8ad5qQVoDW0nMuoeS U48jQ5odB/8jqDEFh8rrahQfNGnT3IzOXWP8YypdlRv2qFLhVB/KMBLKurRT+xAkfE+4 rg3flKBVb4+D/5KzE5Y0oSWuM+ceJSgI0GMqy73GznzYvvs8tCG2SNNjq2YAcYQyLa7W usWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710331771; x=1710936571; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fkFrCRZ7REzYM7HPzWkHOB/qAAg9L6SN2KGBi6tV2U8=; b=rt/LE9zabSSWgLd5UFhihx+x6tp03odzDQLAftF3GMTAg7NU6pUBX13+WZUrWnfxm2 4bLUFRGJPb6DHNxGdnBD3Qq2HSKgNKAEFbdlo4iUUuBUXnNih1ZUWU43eqM5YH+9AcH0 p3ezedh/mUgjM+0KmtT/xX/ju4Ygt2NpZ5WmdGFFHo5p47WUaiF8IzcxPFbCovfi1ofu L+BcC6GeqzAL2JfY+OLvu54EaqONNjCaUWUYwiaLra2+Rata15wd5UB5MND5FPkZieDR d3XQSbLJeicmE65YfKLJYVYgbpow3qp7fUmZmGBChafVwbhN2NEMn9ImbjxTwbHtlrJT F/Yg== X-Forwarded-Encrypted: i=1; AJvYcCUXonDTCkZhh9lbzbgvunBxWw802OQ/JPjA+Zbr8gUXtJSfuVWy4Wj3FdY9Y1nCdtczhdYFulwoSyGp1suyn6Gr0n2KEQPf0lJLDNjj X-Gm-Message-State: AOJu0Yy+MHeiZG+zfSrwFyT73z1AB3xspiSrdYyYSPOGV60pq6Ld5S96 ZMsZ5hwowsYRfkk47g68fSu71i+eC/4uWFnyrf501iCr32MODn+FPK+yOEhbsQ== X-Received: by 2002:ac8:5d93:0:b0:42d:ff64:edf with SMTP id d19-20020ac85d93000000b0042dff640edfmr16590169qtx.7.1710331771443; Wed, 13 Mar 2024 05:09:31 -0700 (PDT) Received: from [127.0.1.1] ([117.213.99.94]) by smtp.gmail.com with ESMTPSA id c19-20020ac85193000000b0042f3098f410sm4773377qtn.48.2024.03.13.05.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 05:09:30 -0700 (PDT) From: Manivannan Sadhasivam Date: Wed, 13 Mar 2024 17:39:22 +0530 Subject: [PATCH] PCI: qcom: Implement shutdown() callback to properly reset the endpoint devices Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240313-pci-qcom-shutdown-v1-1-fb1515334bfa@linaro.org> X-B4-Tracking: v=1; b=H4sIAHGX8WUC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDY0Nj3YLkTN3C5Pxc3eKM0pKU/PI83RQLMyNLC0MLM1MzAyWgvoKi1LT MCrCZ0bG1tQDplwVAYwAAAA== To: Bjorn Andersson , Konrad Dybcio , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2023; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=PaWJKUsVlyLQ/OT+v64+m7jQDF3xuZkRa2uz3Sn7OxQ=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBl8Zd3NreNMGV1X4mPgyzeV4pVF/YH7jniwvnhZ kUQ7Nmn8cWJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZfGXdwAKCRBVnxHm/pHO 9ZmjB/9LYaEXk/pWFVtsJAONhGfusM3PQ5aJyKzT/pwsoVwdaoJXRCI4mphSKlEr+AXmTPTsEfK nVupmE5l1DMclwJEbhWgKGVE3EOs7tHWIjxkzX+Yc/ldJS9L8weqyoW4g3fDlljKxow0q9nT2V5 Vc8vPomJhwh2EEEmxftxXx7CiUycP8W5IDuB60PclK6tGa0TLWYSSuIdpEje3yGa0FRvVlC4yuy qC1vgkeJpDR2J6/AbrNJxyTrP7by4Zu6PJjdjzk4EVlJOkn+rirka15APc4p01Au7jNqffSjdMG yaiP7ssFZwRxuYohCAgmKMP/f5NDVhVV0yJ1VtQprVRrve9F X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 PCIe host controller drivers are supposed to properly reset the endpoint devices during host shutdown/reboot. Currently, Qcom driver doesn't do anything during host shutdown/reboot, resulting in both PERST# and refclk getting disabled at the same time. This prevents the endpoint device firmware to properly reset the state machine. Because, if the refclk is cutoff immediately along with PERST#, access to device specific registers within the endpoint will result in a firmware crash. To address this issue, let's call qcom_pcie_host_deinit() inside the shutdown callback, that asserts PERST# and then cuts off the refclk with a delay of 1ms, thus allowing the endpoint device firmware to properly cleanup the state machine. Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-qcom.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 2ce2a3bd932b..41434bc4761a 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -1618,6 +1618,13 @@ static int qcom_pcie_resume_noirq(struct device *dev) return 0; } +static void qcom_pcie_shutdown(struct platform_device *pdev) +{ + struct qcom_pcie *pcie = platform_get_drvdata(pdev); + + qcom_pcie_host_deinit(&pcie->pci->pp); +} + static const struct of_device_id qcom_pcie_match[] = { { .compatible = "qcom,pcie-apq8064", .data = &cfg_2_1_0 }, { .compatible = "qcom,pcie-apq8084", .data = &cfg_1_0_0 }, @@ -1670,5 +1677,6 @@ static struct platform_driver qcom_pcie_driver = { .pm = &qcom_pcie_pm_ops, .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, + .shutdown = qcom_pcie_shutdown, }; builtin_platform_driver(qcom_pcie_driver); --- base-commit: 51459eb30f88651d3688b9e95fed0f97767ececb change-id: 20240313-pci-qcom-shutdown-d86298186560 Best regards, -- Manivannan Sadhasivam