Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1529082pxk; Fri, 2 Oct 2020 11:50:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze/wJ73jocqnS7Jjbh8Qm4Q5MLQNfIb5WjYv7lRS1iIF04SMqW3duW3WNV8f9E4sOpXwJM X-Received: by 2002:aa7:df14:: with SMTP id c20mr4014666edy.334.1601664642817; Fri, 02 Oct 2020 11:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601664642; cv=none; d=google.com; s=arc-20160816; b=HbLeoaBDIHZCNgApAVobekuei3uWbmAWOZJjsiyr/WSWBxRYgxl39pDH9HcvgRz4jn S8jvgkMWqGx5q+QHkl4owvk+5xRQvB/D8GggBOsRl1z3rhQBUdK1tk+hYFvrih+vgfT1 ndLoizp55kWlkGgLwwylp4lfp+2MMPjYw6Equr7DeyJq2YW1U+Lc4PaR/ZDRixqEQrTg +f45+N0wXtat23bO+Kr/c8Kcp5yf5grnaK/MuS/wcmB0yv5B6WPt0+2wa6QAUaVlyXnh yGNOnhWJltSloZKCvER92HoexS/F4x4lb3RR/GCcQr3f44Q99g//aLoVgGBsY/+2nZyo 0nkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=9mBueR5mjc2elX0S5GvL5L98HPD3F2dJX6eYncjCuDA=; b=hbR/GqJ/O8YyJafN/BT8p6xICPT34Myf4oUmf2L+YXs0u1BIA5CB4oD2kNcD6Yxa0p R18JnTo9aKBIqsoyahNZbDUxa2BLJaBPfy1qEpj13bwgT4HOfWqjKUrRE2yLKvksh/0H eAG+hO2FBCu28XyYxRdl6FfJE5743Kho9iUqt4xYm+3H9i1tCQFY3GSH4x/pE3X2jojJ yORUMRkGrcWTS1BgaEk8k03od5ocI0h47c6gmfIavJp4iAa7fx6VJoLkB/vH1eZjGOQE XeaqesCU/1VvSvYH+FNVd9+bRerecg/0yYEa1PhmrNUsWEUSuTR/sr9pzJVV0gKkru1C SKMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oregontracks.org header.s=fm1 header.b=HgMJr0sU; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=k5oMsFXW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gy13si1822981ejb.446.2020.10.02.11.50.20; Fri, 02 Oct 2020 11:50:42 -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=@oregontracks.org header.s=fm1 header.b=HgMJr0sU; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=k5oMsFXW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388483AbgJBSs3 (ORCPT + 99 others); Fri, 2 Oct 2020 14:48:29 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:37403 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388419AbgJBSsT (ORCPT ); Fri, 2 Oct 2020 14:48:19 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B4A445C0163; Fri, 2 Oct 2020 14:48:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 02 Oct 2020 14:48:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= oregontracks.org; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=fm1; bh=9mBueR5mjc2elX0S5GvL5L98HPD3F2dJX6eYncjCuDA=; b=HgMJr 0sU+KdVq83ivh2Z1ZjpUHSIUBKpQdTU2ekmYMt8xXu5xzVnogtWKah1TbiSyoJVq dKEOot0VmQAqkVBRGzTfgxUHFABvsj1Qt0+wt3r+7tOF1bvk7EwFVPQYWvOvHBbN 2skxhktMoU7skpAZ1ZI2VBxZ5rX7kLs4PFFVcUM2hyG/9hVX6Q5suc72LuEqfbIh vAaBxzvqUkwJkRWTwWRJxUjeathpwQY7LW6AKqcK7o1xCk+z4oIMWCigMn5bbvgc ufzzdyNbU04mEY/VE6uQo5OmgV6Y6bopfLG1cEt4yFoEKTyiEZbxATTA2yjJj2G7 AnN87bCypNaw87P/g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=9mBueR5mjc2elX0S5GvL5L98HPD3F2dJX6eYncjCuDA=; b=k5oMsFXW N35ccTiopYB97PRjC59zmov+ryKeAXtUcVs0oF0ewwbto8VtIuhFeY2GWsqtj5NL yYm/iCI7Iok/Pb5IpQhMJKdpTuPXfva1iE8nu+D9uTp5z+CH33fX5mvss1xoCLs7 rnChu9ZAkyeMTF2DuetSgLg30KwXEG2v8WoCP2cqvrp7TeScyNui+wKXPNCcF4a9 esM13dpGgbrFglA/yqH8wS0NQ7BsHW+2xlHDOXewa2lGGgXhMw1OfjNR9cmrMzF7 0MUTaS5r/AL+U+yzmOfad+qvlp6QGle1uFz5Qquw4IGcrFeFgVL2qrOpKUAx53tU K9/+zmPxmBci6Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrfeeigdduvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepufgvrghnucggucfmvghllhgvhicuoehsvggrnhhvkhdruggv vhesohhrvghgohhnthhrrggtkhhsrdhorhhgqeenucggtffrrghtthgvrhhnpeehkeffte eiudeiffelkeelvefftdelhfeitdeigeffleeufedvgfegvdefvedtteenucfkphepvdeg rddvtddrudegkedrgeelnecuvehluhhsthgvrhfuihiivgepuddunecurfgrrhgrmhepmh grihhlfhhrohhmpehsvggrnhhvkhdruggvvhesohhrvghgohhnthhrrggtkhhsrdhorhhg X-ME-Proxy: Received: from arch-ashland-svkelley.hsd1.or.comcast.net (c-24-20-148-49.hsd1.or.comcast.net [24.20.148.49]) by mail.messagingengine.com (Postfix) with ESMTPA id 033ED306468A; Fri, 2 Oct 2020 14:48:16 -0400 (EDT) From: Sean V Kelley To: bhelgaas@google.com, Jonathan.Cameron@huawei.com, rafael.j.wysocki@intel.com, ashok.raj@intel.com, tony.luck@intel.com, sathyanarayanan.kuppuswamy@intel.com, qiuxu.zhuo@intel.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Sean V Kelley Subject: [PATCH v8 13/14] PCI/PME: Add pcie_walk_rcec() to RCEC PME handling Date: Fri, 2 Oct 2020 11:47:34 -0700 Message-Id: <20201002184735.1229220-14-seanvk.dev@oregontracks.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201002184735.1229220-1-seanvk.dev@oregontracks.org> References: <20201002184735.1229220-1-seanvk.dev@oregontracks.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean V Kelley Root Complex Event Collectors (RCEC) appear as peers of Root Ports and also have the PME capability. As with AER, there is a need to be able to walk the RCiEPs associated with their RCEC for purposes of acting upon them with callbacks. So add RCEC support through the use of pcie_walk_rcec() to the current PME service driver and attach the PME service driver to the RCEC device. Co-developed-by: Qiuxu Zhuo Signed-off-by: Qiuxu Zhuo Signed-off-by: Sean V Kelley --- drivers/pci/pcie/pme.c | 15 +++++++++++---- drivers/pci/pcie/portdrv_core.c | 8 ++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index 6a32970bb731..87799166c96a 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c @@ -310,7 +310,10 @@ static int pcie_pme_can_wakeup(struct pci_dev *dev, void *ign) static void pcie_pme_mark_devices(struct pci_dev *port) { pcie_pme_can_wakeup(port, NULL); - if (port->subordinate) + + if (pci_pcie_type(port) == PCI_EXP_TYPE_RC_EC) + pcie_walk_rcec(port, pcie_pme_can_wakeup, NULL); + else if (port->subordinate) pci_walk_bus(port->subordinate, pcie_pme_can_wakeup, NULL); } @@ -320,10 +323,15 @@ static void pcie_pme_mark_devices(struct pci_dev *port) */ static int pcie_pme_probe(struct pcie_device *srv) { - struct pci_dev *port; + struct pci_dev *port = srv->port; struct pcie_pme_service_data *data; int ret; + /* Limit to Root Ports or Root Complex Event Collectors */ + if ((pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC) && + (pci_pcie_type(port) != PCI_EXP_TYPE_ROOT_PORT)) + return -ENODEV; + data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -333,7 +341,6 @@ static int pcie_pme_probe(struct pcie_device *srv) data->srv = srv; set_service_data(srv, data); - port = srv->port; pcie_pme_interrupt_enable(port, false); pcie_clear_root_pme_status(port); @@ -445,7 +452,7 @@ static void pcie_pme_remove(struct pcie_device *srv) static struct pcie_port_service_driver pcie_pme_driver = { .name = "pcie_pme", - .port_type = PCI_EXP_TYPE_ROOT_PORT, + .port_type = PCIE_ANY_PORT, .service = PCIE_PORT_SERVICE_PME, .probe = pcie_pme_probe, diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 50a9522ab07d..99769c636775 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -234,11 +234,11 @@ static int get_port_device_capability(struct pci_dev *dev) #endif /* - * Root ports are capable of generating PME too. Root Complex - * Event Collectors can also generate PMEs, but we don't handle - * those yet. + * Root ports and Root Complex Event Collectors are capable + * of generating PME. */ - if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT && + if ((pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT || + pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC) && (pcie_ports_native || host->native_pme)) { services |= PCIE_PORT_SERVICE_PME; -- 2.28.0