From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4AA8ED1A435 for ; Sat, 12 Oct 2024 04:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vB16VpCDewcAwoYN49nbK+yIU/0PlYPRJKRICrTJZE8=; b=Mzdl0ssPXRN7FWSZ7RvZyop+pr dRkVUmslmAuViN7qgDR85X+JAbw04sr8PoXyPQA2+y8k8L7FUXx7TI2c5eZ7hYS2D/UK43ev64ydH 67ELiH+WeJezvaPepNH0vyxibx29zGb7VSv+LKuOuMED/QN0d1VJMgH3vbwZ6Rc5JzGDXU+muHtRF 1zMtzCC7APSJoPEPiKwMnMZTMcx25bPLQQvonpg0PA41nURWZ9eF+w2ZRABj3OX9lc3xm186EgmLE iO9EigStNXNPJmMkN9WcbByOBSx1lzHxfpmOOBPJHdRIHA2n4zeZnmxFdyKaSDq4b0uN4bgzivdkc kPbGhEPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szTWi-00000000VXe-2IB2; Sat, 12 Oct 2024 04:14:48 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szTVL-00000000VOS-04sc for linux-arm-kernel@lists.infradead.org; Sat, 12 Oct 2024 04:13:24 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-20c8c50fdd9so14788165ad.0 for ; Fri, 11 Oct 2024 21:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728706402; x=1729311202; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=vB16VpCDewcAwoYN49nbK+yIU/0PlYPRJKRICrTJZE8=; b=a43ggwTsHvW/7ugXenTyhqSoqsBPgNLjq3o5twi2dNW5UKne16uoHa2BfAEXEhXaQk U4sk3PqzKJ8o5D+ruHHxAwWUSK/8v5+DgyCK17nfJdAvyJbSsmfCyk0G2rC9qDyzXgbn iJgZ+MGKvcior42G9nedwW0RgdedgxXmHFKt5KZHLdFYG7C+Kd9mau0cyOv1/7wOpBo5 TsQ9xbCaWe3Zh7qFldeD6RLmngaXsGs+tiHnlMKVyHN3f1tbcx6wZCwsz3iv6AEJaxAs 6M1VLjM96Mo4dafFVrd5LdwhsLkQvInLXOqBVw1UL2/kk4P1ujCtzvjB4KdIgwy0EOQP GINg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728706402; x=1729311202; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vB16VpCDewcAwoYN49nbK+yIU/0PlYPRJKRICrTJZE8=; b=f8WiexZtayw93x+Xo6GX7DYL8y4PVsFZv/0OUv6XebWfFzmopk2qjPX2zVcD6AmfDu MC92I69HvUZfju7YHa7VzxlH8YMsHjsVWR1ukVPILAHd8qz3kaZre04CWEz72ft048Qf 37tYuNdSMBf9ZZCcIe1oqvUF/wnLDOLqc2RsX8es6qmWlAF219MZMdCuA4kFu6PH6OMR srX5rGjhXN1P5dTu33RyD8B530uGU5VtlIStN0+V8CE2JJmZy1xNgZ1GWJ9XB6plmOBM Wd/c01R65sA+lzCC7wYGpu9y24vzwsY9JgDCFDB3fpYwO/2Rq+QQ9qETEsMT427Km8Lj AtjA== X-Forwarded-Encrypted: i=1; AJvYcCXQn6ne3BXFK44xnSxhTLhmezESSeGrVWmvKvlrV5iY3iMYyrOIBebcFrn2Rrogf6e2Xcebw1vJOFeU1bphqeLw@lists.infradead.org X-Gm-Message-State: AOJu0YyhNSes3hi3Va3d1YyDvvfTJpJkI+9L7UriXTkxwefMUVzsu/UU SbmjKvTYUvC8ex/QXTbyU/G73LQk5ogDCohicgsOiiTNpywWCeUosQ3Zkfmjcg== X-Google-Smtp-Source: AGHT+IEUBN4nc8fDzuF7ww7X5ksu78JTjsuqiB3sE0EdJOBGzVs3tTuontBwHvcsi4XzGJlZlVJueQ== X-Received: by 2002:a17:902:f70c:b0:20c:c482:1d72 with SMTP id d9443c01a7336-20cc4821f28mr10112675ad.20.1728706401976; Fri, 11 Oct 2024 21:13:21 -0700 (PDT) Received: from thinkpad ([36.255.17.101]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8bad32basm30934345ad.57.2024.10.11.21.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 21:13:21 -0700 (PDT) Date: Sat, 12 Oct 2024 09:43:15 +0530 From: Manivannan Sadhasivam To: Stefan Eichenberger Cc: hongxing.zhu@nxp.com, l.stach@pengutronix.de, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, francesco.dolcini@toradex.com, Frank.li@nxp.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, Stefan Eichenberger Subject: Re: [PATCH v2] PCI: imx6: Add suspend/resume support for i.MX6QDL Message-ID: <20241012041315.vtmixcxbqwb63kno@thinkpad> References: <20241009131659.29616-1-eichest@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20241009131659.29616-1-eichest@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241011_211323_091704_23F62EA0 X-CRM114-Status: GOOD ( 36.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 09, 2024 at 03:14:05PM +0200, Stefan Eichenberger wrote: > From: Stefan Eichenberger > > The suspend/resume support is broken on the i.MX6QDL platform. This You mean the 'system suspend/resume'? > patch resets the link upon resuming to recover functionality. It shares > most of the sequences with other i.MX devices but does not touch the > critical registers, which might break PCIe. This patch addresses the > same issue as the following downstream commit: > https://github.com/nxp-imx/linux-imx/commit/4e92355e1f79d225ea842511fcfd42b343b32995 > In comparison this patch will also reset the device if possible. Without > this patch suspend/resume will not work if a PCIe device is connected. > The kernel will hang on resume and print an error: > ath10k_pci 0000:01:00.0: Unable to change power state from D3hot to D0, device inaccessible Looks like the device is turned off during suspend. > 8<--- cut here --- > Unhandled fault: imprecise external abort (0x1406) at 0x0106f944 > > Signed-off-by: Stefan Eichenberger > --- > v1 -> v2: Share most code with other i.MX platforms and set suspend > support flag for i.MX6QDL. Version 1 can be found here: > https://lore.kernel.org/all/20240819090428.17349-1-eichest@gmail.com/ > > drivers/pci/controller/dwc/pci-imx6.c | 44 +++++++++++++++++++++++++-- > 1 file changed, 41 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 808d1f1054173..f33bef0aa1071 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -1238,8 +1238,23 @@ static int imx_pcie_suspend_noirq(struct device *dev) > > imx_pcie_msi_save_restore(imx_pcie, true); > imx_pcie_pm_turnoff(imx_pcie); > - imx_pcie_stop_link(imx_pcie->pci); > - imx_pcie_host_exit(pp); > + /* > + * Do not turn off the PCIe controller because of ERR003756, ERR004490, ERR005188, > + * they all document issues with LLTSSM and the PCIe controller which LTSSM But LTSSM is for the PCIe link state, not sure how it impacts controller state. Can you share the link to those erratums? > + * does not come out of reset properly. Therefore, try to keep the controller enabled > + * and only reset the link. However, the reference clock still needs to be turned off, You are resetting the *device* below, not the link. > + * else the controller will freeze on resume. > + */ Please use 80 columns for comments. Exception is for the code. > + if (imx_pcie->drvdata->variant == IMX6Q) { > + /* Reset the PCIe device */ > + gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 1); > + > + if (imx_pcie->drvdata->enable_ref_clk) > + imx_pcie->drvdata->enable_ref_clk(imx_pcie, false); > + } else { > + imx_pcie_stop_link(imx_pcie->pci); > + imx_pcie_host_exit(pp); > + } > > return 0; > } > @@ -1253,6 +1268,28 @@ static int imx_pcie_resume_noirq(struct device *dev) > if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_SUPPORTS_SUSPEND)) > return 0; > > + /* > + * Even though the i.MX6Q does not support proper suspend/resume, we > + * need to reset the link after resume or the memory mapped PCIe I/O > + * space will be inaccessible. This will cause the system to freeze. > + */ This comment is not really needed. > + if (imx_pcie->drvdata->variant == IMX6Q) { > + if (imx_pcie->drvdata->enable_ref_clk) > + imx_pcie->drvdata->enable_ref_clk(imx_pcie, true); > + > + imx_pcie_deassert_core_reset(imx_pcie); There is no corresponding imx_pcie_assert_core_reset() in suspend. > + > + /* > + * Setup the root complex again and enable msi. Without this PCIe will > + * not work in msi mode and drivers will crash if they try to access > + * the device memory area > + */ This indicates that the controller state is not preserved. I think we need a bit more understanding on what is going on during system suspend on this platform. - Mani -- மணிவண்ணன் சதாசிவம்