Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp870356lqp; Sun, 14 Apr 2024 03:33:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWj4xmyT/1mVbYXr7qYCOSdjrd8MA0OQ2DIWbxa/HV/wVdv923bXt/iGoYZPEHizWv3QbV0lcyt1jCkdZAoTHPUXXW/z+W0Fw7RLglDdQ== X-Google-Smtp-Source: AGHT+IF8BoKnL8Nud+URobA7OxzIJfEq+HBK5pvcEkfNc8qZhvmsILSVDmYmO8CN3ogsg6m5Mnc1 X-Received: by 2002:a17:907:97c1:b0:a51:cdfd:8ef7 with SMTP id js1-20020a17090797c100b00a51cdfd8ef7mr5515585ejc.39.1713090794055; Sun, 14 Apr 2024 03:33:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713090794; cv=pass; d=google.com; s=arc-20160816; b=rWEqKLx6kjWBfTOJc12hS742E9u2H4C9EJRll9UgBTFRZgAUSpb6UuyCXkfAXJnSOP fGFrThW3apbUnmTIj3uT2UbfvFY3ONDVkUduDkzORqr1/79Rnu9MVjsyR+0F2+X6Df0G R1jgoV1qptBXZ1vVn8oPigjQ5OiXkbm+AEPeJP/c9wbsBMj3emEPGg1ig58nfhS0Qt8B aSdyhN0/pU/zAeuUH2lsF/3A8vvushzeI8VNRlTO2RBdnukviy/X+fzrvgJIQJ4nxr6r 6ORTeEAqse7EkdAkC9RakqNj1X2K2FPLmXJ0aR/rHE/Y7ILI5ddOXqDoa335Zg4n8dUs JTIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ezWv8Uk8r0iZzTSx1VI+aatOFO9g5HSxqsWTUv27XdY=; fh=UlNYTPnhm9h++scREX7CYx8z5Sy6vXAQKJeNqeydKlg=; b=pjVfC3MNETfpEqYdOv3TnARA23RgzfHUS51V47I32rRumThMPK/vutufGuf5EnZ5s2 D91eHGnATPsUVWvWTDecH7pVeoHr7zQ4QniZEj/RHvKWCWdshLzK/4gmlQyN74MQZoSY ZYJXXRI1gk02NQl7EtaVheAP8hFCRQoBrh+M3ys3KzSWuK2bXKVXPCTGWaYj23lGdk00 BtLsvppGVlEtCoLfsQWBgUa5jfrzn1JIa5kUd78+ppLBF+BMnzWZp0Mb5MCKpmB65OsQ 4U0UVvqjYVRrsS3hteCCBHvh9UNVo/7wK6839IsNS/m7ae/BJ9JJBhKM4XkhlUXwjMYg bKPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xT07n4fN; 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-144104-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144104-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 hs39-20020a1709073ea700b00a523b5c7e99si2210041ejc.467.2024.04.14.03.33.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 03:33:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144104-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=xT07n4fN; 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-144104-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144104-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 941D91F21420 for ; Sun, 14 Apr 2024 10:33:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91E052E647; Sun, 14 Apr 2024 10:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xT07n4fN" Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (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 2CA521AACB for ; Sun, 14 Apr 2024 10:33:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713090784; cv=none; b=pFt/MMUGJBLo16NI5WS+dVqrxBIxDXXsuZGImnT1btItz4hpAFD3Tjpmb4YeXEt0GmXwlce0T905NRdBeUzR2+LNaCwNfE0Kdx9/P8UJTCGTICSbPpu2yVkISv45jcqx4lonVW5OehZR65TcOVrbVu0425/04k0VW+p9AnyNy0g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713090784; c=relaxed/simple; bh=GD2VZJ/Qqsxp3zuRDLUSfSvzp4vBjYYUvZyBFHVrN0s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J4rs7utUFy3Vtbhu5zLfoStWdMg385obfweiOBXDV7bjWStsXqYPwfc4N+QrcsHEFH9AShHuo4ejmghQOn5NaWHUZ4657j0QN3A8JjrOiG5576amQsWiP9kQc8N8kCbRiz3TAkdPyMQGWoIsH164FHRqvx59oaQkAsTt7BJedcQ= 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=xT07n4fN; arc=none smtp.client-ip=209.85.160.48 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-oa1-f48.google.com with SMTP id 586e51a60fabf-23333ef4a02so1722409fac.1 for ; Sun, 14 Apr 2024 03:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713090781; x=1713695581; darn=vger.kernel.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=ezWv8Uk8r0iZzTSx1VI+aatOFO9g5HSxqsWTUv27XdY=; b=xT07n4fN2MXFmrGmyS6NquXlcu85iBt+fCszcf7oYJAyZittCaFBKXk5fb/XHlucQ8 VD1frCRZknnC1V8pNk6YrfRB9oXGTi4AVxPvtTVogvD4bTL3NJjSOQMu0VDpUhCj+9Zx KXr8hfPmTfMT50fvft6EikXQzea7UudlqB+zW4gTfhSiiy1FiaN59dqcm0oRz85ZmgT4 x6+6UxB/JRUsvh9d3PiN3alj4oOJcl+qPaKalwITnYsKXRjSWYSOzOM4xmIj3iyWfXu6 +wUIYGWtIXe8mnrrFpQQBEEsn/vINEju6PLW0xTwRbZ8dtdbAIPpiPvi7W+a+EUHxsjc DF9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713090781; x=1713695581; 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=ezWv8Uk8r0iZzTSx1VI+aatOFO9g5HSxqsWTUv27XdY=; b=b+KrOgetZnromIyuEC2L69aNk8e3uNTa5MRwxd8fHtcUucGvA+kCifsNOklZb6eLCZ 414K1zvqrXQHufXlhzffXKY/28kjpiaKbc9Z1djNEmmhK8wbSblt2nPYzazUu43HLOBM Lt3AdR/EyvJsaVzyhJinPVA/WmfGA6ydpYGBXfPqX/wmw91+E+BW3hzKSfcQV4ByVFC0 DktVFj0cszcq83eKm2ICW+K6yZpJYVFxRwVY6NzAQj42JRNUNXJJ+G9M5PmshCaUA/1L S71jXTVfIcuVVzTjN5di6zSeZWxD1PEK/MBvMC4IoE/C7tQL5OiINZpJyAwIkv66hAWX iDuw== X-Forwarded-Encrypted: i=1; AJvYcCVABbtVrtypdo8I2Mu+ObSKgEAOw5+IAcElEeQYLUBFtumaqxsZEVdm06d8S98sQxY/yLWT97GE0QWGAJWAmtk/aVzOi+RAQJ4dMKU9 X-Gm-Message-State: AOJu0YyOy5FRKzrAjRvn+bO+1NvQkBNWilzprYhf0X7FReCwCcQO7TiU ciWctBhfEGjrTMK8gnObOooMfw4WFxvuFf6Li2jmPJCYUtY1CcO5RdTNbsirQQ== X-Received: by 2002:a05:6871:60f:b0:229:87f6:ee8a with SMTP id w15-20020a056871060f00b0022987f6ee8amr8649408oan.30.1713090781146; Sun, 14 Apr 2024 03:33:01 -0700 (PDT) Received: from thinkpad ([120.60.136.171]) by smtp.gmail.com with ESMTPSA id 1-20020a056a00072100b006ed045e3a70sm5391418pfm.25.2024.04.14.03.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 03:33:00 -0700 (PDT) Date: Sun, 14 Apr 2024 16:02:56 +0530 From: Manivannan Sadhasivam To: Frank Li Cc: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v5 5/5] PCI: dwc: Add common send PME_Turn_Off message method Message-ID: <20240414103256.GB2294@thinkpad> References: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> <20240319-pme_msg-v5-5-af9ffe57f432@nxp.com> <20240405062426.GB2953@thinkpad> <20240406040131.GC2678@thinkpad> <20240412170548.GB19020@thinkpad> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Apr 12, 2024 at 05:08:33PM -0400, Frank Li wrote: > On Fri, Apr 12, 2024 at 10:35:48PM +0530, Manivannan Sadhasivam wrote: > > On Mon, Apr 08, 2024 at 11:11:11AM -0400, Frank Li wrote: > > > On Sat, Apr 06, 2024 at 09:31:31AM +0530, Manivannan Sadhasivam wrote: > > > > On Fri, Apr 05, 2024 at 10:31:16AM -0400, Frank Li wrote: > > > > > On Fri, Apr 05, 2024 at 11:54:26AM +0530, Manivannan Sadhasivam wrote: > > > > > > On Tue, Mar 19, 2024 at 12:07:15PM -0400, Frank Li wrote: > > > > > > > > > > > > PCI: dwc: Add generic MSG TLP support for sending PME_Turn_Off during system suspend > > > > > > > > > > > > > Reserve space at end of first IORESOURCE_MEM window as message TLP MMIO > > > > > > > window. This space's size is 'region_align'. > > > > > > > > > > > > > > Set outbound ATU map memory write to send PCI message. So one MMIO write > > > > > > > can trigger a PCI message, such as PME_Turn_Off. > > > > > > > > > > > > > > Add common dwc_pme_turn_off() function. > > > > > > > > > > > > > > Call dwc_pme_turn_off() to send out PME_Turn_Off message in general > > > > > > > dw_pcie_suspend_noirq() if there are not platform callback pme_turn_off() > > > > > > > exist. > > > > > > > > > > > > > > > > > > > How about: > > > > > > > > > > > > "Instead of relying on the vendor specific implementations to send the > > > > > > PME_Turn_Off message, let's introduce a generic way of sending the message using > > > > > > the MSG TLP. > > > > > > > > > > > > This is achieved by reserving a region for MSG TLP of size 'pci->region_align', > > > > > > at the end of the first IORESOURCE_MEM window of the host bridge. And then > > > > > > sending the PME_Turn_Off message during system suspend with the help of iATU. > > > > > > > > > > > > It should be noted that this generic implementation is optional for the glue > > > > > > drivers and can be overridden by a custom 'pme_turn_off' callback." > > > > > > > > > > > > > Signed-off-by: Frank Li > > > > > > > --- > > > > > > > drivers/pci/controller/dwc/pcie-designware-host.c | 94 ++++++++++++++++++++++- > > > > > > > drivers/pci/controller/dwc/pcie-designware.h | 3 + > > > > > > > 2 files changed, 93 insertions(+), 4 deletions(-) > > > > > > > > > > > > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c > > > > > > > index 267687ab33cbc..d5723fce7a894 100644 > > > > > > > --- a/drivers/pci/controller/dwc/pcie-designware-host.c > > > > > > > +++ b/drivers/pci/controller/dwc/pcie-designware-host.c > > > > > > > @@ -393,6 +393,31 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) > > > > > > > return 0; > > > > > > > } > > > > > > > > > > > > > > +static void dw_pcie_host_request_msg_tlp_res(struct dw_pcie_rp *pp) > > > > > > > +{ > > > > > > > + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); > > > > > > > + struct resource_entry *win; > > > > > > > + struct resource *res; > > > > > > > + > > > > > > > + win = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM); > > > > > > > + if (win) { > > > > > > > + res = devm_kzalloc(pci->dev, sizeof(*res), GFP_KERNEL); > > > > > > > + if (!res) > > > > > > > + return; > > > > > > > + > > > > > > > + /* Reserve last region_align block as message TLP space */ > > > > > > > + res->start = win->res->end - pci->region_align + 1; > > > > > > > + res->end = win->res->end; > > > > > > > > > > > > Don't you need to adjust the host bridge window size and end address? > > > > > > > > > > Needn't. request_resource will reserve it from bridge window. Like malloc, > > > > > if you malloc to get a region of memory, which will never get by malloc > > > > > again utill you call free. > > > > > > > > > > > > > Hmm, will that modify the window->res->end address and size? > > > > > > No. This windows already reported to pci system before this function. It is > > > not good to modify window-res-end. It just add child resource like below. > > > > > > windows is root resource, which will create may child when call > > > request_resource. > > > bridge -> windows > > > child1 -> msg > > > child2 -> pci ep1 > > > child3 -> pci_ep2. > > > ... > > > > > > Although you see whole bridge window, 'msg' already used and put under root > > > resource, new pci devices will never use 'msg' resource. > > > > > > If change windows->res->end here, I worry about it may broken resource > > > tree. > > > > > > > Hmm, I think your argument is fair. I was worrying that if someone try to > > map separately by referencing win->res->end, then they will see access > > violation. > > It should be wrong if use it without request resource. > > > > > But why can't you just allocate the resource using 'alloc_resource()' API > > instead of always allocating at the end? > > Alloc will start from windows (for example: 0x8000_0000). > 0x8000_0000 -> 0x8001_0000 will be allocated to 'msg'. > > If ep1 want to get 1MB windows, 0x8010_0000 will return. There is a big > hole between 0x8001_0000 to 0x8010_0000. > > I just want to reduce impact to existed system. So PCIe memory layout will > be kept the same w/o this patch. > > There are not big difference between allocate resource and reserve resource > for 'msg'. Just little better friendly for exist system. > Ok. This sounds fine to me. Please add this information as a comment so that everyone will be aware of the reasoning. - Mani > Frank > > > > > - Mani > > > > > > > > > > > > > > > > > > > + res->name = "msg"; > > > > > > > + res->flags = win->res->flags | IORESOURCE_BUSY; > > > > > > > + > > > > > > > > > > > > Shouldn't this resource be added back to the host bridge? > > > > > > > > > > No, this resource will reserver for msg only for whole bridge life cycle. > > > > > Genenally alloc resource only happen at PCI devices probe. All pci space > > > > > will be fixed after system probe. > > > > > > > > > > > > > I don't think so. This resource still belongs to the host bridge, so we should > > > > add it back. > > > > > > When add back? It was reserved at bridge probe. When bridge remove, all > > > resource will released. > > > > > > > > > > > - Mani > > > > > > > > -- > > > > மணிவண்ணன் சதாசிவம் > > > > -- > > மணிவண்ணன் சதாசிவம் -- மணிவண்ணன் சதாசிவம்