Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp179905pxa; Tue, 4 Aug 2020 02:51:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpURNFXgCYHVCd5gCdeaZV8SU42ST1O/r0n1OsWYOWjY42yba7SzRonaUHmVMQw1kiEe14 X-Received: by 2002:aa7:ce0b:: with SMTP id d11mr19018101edv.357.1596534674449; Tue, 04 Aug 2020 02:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596534674; cv=none; d=google.com; s=arc-20160816; b=aaRjMww+uyp+M+Eq7xiaMkkdHMrWXgKp6sXavHNK2IehQngtxl2bZeRBiLpK3T5NOl XicW41ZtcseFO05ZqVYk15JxspbKYa0BusMLrNowxg8ySXEB0/YiErcVA264nievudFO FIW00D7Q2FQshuUlcC9fWhgGD9ztJhzDODLkU1anMaF8wLOU/cS03qDW3RN3Mnt4w0P5 7wCXSGXJLVPdb8CDVgTm0cIwq2BRmi6Wq+vx2ikPyYCOnneVgIwcnNu5XWGO0C2iikbG 26edTcZwjf5O724XarSTLQa98csfkR5cyhL0DoIMbn0MViyPShV8ArX5XFV30KjZk5Fj CWrw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=hcaiIBVvz+t5tjPa8J1nzlhNNPcd8aGAwKidtPfuVfk=; b=YpGgB2M2X0+lXMobI6I6vb98mavlKGvG0x6FvFPUtGIdp0GvgkPZhCnhhFaXRui1AA VVdFwhSUO6TcLFbaF+jTawcJaBtj7QuJeo/u/FX3EgByK2mwk0XLOBuVH6WeRGBKDqwt UWBavorXwFcEp9JLT+uExXXj2P1+C/DD5TZlMwaxGLLEyWIe+48VNLIUZ7b4qYM6wIcy U2ycYzSCFmCFnal5PBSUMjSk4rhmvfp/YG/mTgBpNgjHaR0ACXCEWvB5FaBps587xOOf 8DETgQOqbir8LWdcXidA40oR04zsIwRcAaww3qvK7tRiArkXoM+RUHdE9HB+n3HvHpnW 4PVw== ARC-Authentication-Results: i=1; mx.google.com; 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 df7si11677618edb.553.2020.08.04.02.50.52; Tue, 04 Aug 2020 02:51:14 -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; 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 S1729061AbgHDJsk (ORCPT + 99 others); Tue, 4 Aug 2020 05:48:40 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2565 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726844AbgHDJsk (ORCPT ); Tue, 4 Aug 2020 05:48:40 -0400 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id A7CEA2CFDA64335D3338; Tue, 4 Aug 2020 10:48:38 +0100 (IST) Received: from localhost (10.52.124.224) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1913.5; Tue, 4 Aug 2020 10:48:38 +0100 Date: Tue, 4 Aug 2020 10:47:13 +0100 From: Jonathan Cameron To: Jay Fang CC: Sean V Kelley , , , , , , , , Qiuxu Zhuo Subject: Re: [RFC PATCH 8/9] PCI/PME: Add RCEC PME handling Message-ID: <20200804104713.0000767f@Huawei.com> In-Reply-To: References: <20200724172223.145608-1-sean.v.kelley@intel.com> <20200724172223.145608-9-sean.v.kelley@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.52.124.224] X-ClientProxiedBy: lhreml701-chm.china.huawei.com (10.201.108.50) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 4 Aug 2020 16:35:59 +0800 Jay Fang wrote: > ?? 2020/7/25 1:22, Sean V Kelley ะด??: > > The Root Complex Event Collectors(RCEC) appear as peers of Root Ports > > and also have the PME capability. So add RCEC support to the current PME > > service driver and attach the PME service driver to the RCEC device. > > > > Co-developed-by: Qiuxu Zhuo > > Signed-off-by: Sean V Kelley > > Signed-off-by: Qiuxu Zhuo > > --- > > drivers/pci/pcie/pme.c | 15 +++++++++++---- > > 1 file changed, 11 insertions(+), 4 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, > Maybe we can use port_type for driver matching. There is no need > to check the type of port in pcie_pme_probe function. > I walked into the same hole for the AER case. port_type is effectively an enum so there is no way of specifying several types unless you want to register different instances of pcie_port_service_driver and that isn't currently possible. The PCIE_ANY_PORT is a special case value. https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/pci_regs.h#L477 https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci-driver.c#L1651 So odd corner case, but I think this is the right solution. Anything better would require a lot more code to change. Jonathan > > Jay > > > .service = PCIE_PORT_SERVICE_PME, > > > > .probe = pcie_pme_probe, > >