From patchwork Wed Jun 16 11:59:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 461395 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp550096jae; Wed, 16 Jun 2021 05:00:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh3fzjfoa+3nOa+5m2YfW8i3E7sVyLg3QjJaUxzJuZ68um8DWJT4Ul7g4ztDxuRbTaDPBT X-Received: by 2002:a17:907:2628:: with SMTP id aq8mr5022267ejc.354.1623844807703; Wed, 16 Jun 2021 05:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623844807; cv=none; d=google.com; s=arc-20160816; b=sAl24ga584L6JcVnwyJWXNZ+4UJwUi2Ue9BbX+QrhFt1ZBABi7vbAUS6v5RKXJmqgC 8FLycLYnvKfXFnnaoH7xY4lFJhmI7V5+rHrhpANuS6+ogxutL2XARP+OicnEbz1JJGt3 SfbYKgyLNi3iXZmLQ3w1eaNO75Rx2bkP3TkKiVeXjtqqfOyBRLl5NybJG7FQKul0aS69 hY86uhSBb/n33E7wTCf0XsM0QD9UBPQUJUNij4kC7NRMQ8BMoSX+lWwRn961g8pSLuVW FODBUp3hXPLYXj9cFLE/6IRdZhUf93I29lNpTxMIt6CCswLa0Rey8gKn99IRGvHR8bJZ /d1Q== 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; bh=npWguGF+sv+TNIJk7vE0aKrt2xI11hFGoDM/Lo6gWeI=; b=PCJUNaUPVqsbmhzzAL4rP0utsBOhMBbm/IwOqhg/e2s5NZFtb7PjtTs6XuW9gFkiHb 2TvOrg5JssnbClgChTnLNxw5HgnR89T48cIzAjbYNpfO/vbDBTHIVfR/lG9oyW9FhU+h FzMQkCbFWRewrhvF7NJGC2G8DIkHsdP1jFOGw0EZGcjUsIgDa8GrSlVcwbStoLwL2IVO A5epm3ZqoTmJJunzXZndOWiIBKgNpZxK1EEympC+7uUx1kHMZPlz9zgt7VfznFgoCRsH UdZ4RqvctmRjPLX8BIexAiu/SUZeX/kWTXl8jVs4zqfZ4gr16tpsIgwr88d9vsi37fsW 8bdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ts5HvtOb; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t27si2067325ejd.372.2021.06.16.05.00.07; Wed, 16 Jun 2021 05:00:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=@linaro.org header.s=google header.b=ts5HvtOb; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232747AbhFPMCJ (ORCPT + 17 others); Wed, 16 Jun 2021 08:02:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232744AbhFPMCI (ORCPT ); Wed, 16 Jun 2021 08:02:08 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E7A3C061768 for ; Wed, 16 Jun 2021 04:59:58 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id h12so999808plf.4 for ; Wed, 16 Jun 2021 04:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=npWguGF+sv+TNIJk7vE0aKrt2xI11hFGoDM/Lo6gWeI=; b=ts5HvtOb7Wrv0uits8CEe7ZZvcqKznlaG53XWIDeJR6mx67o9nm07NJMq6mpKkNVsz w5Hy51TD80CTlRo4fznDWh98W6g+pYqeSrd0g6nEQ/v3jm6duyK8G1IP4TL4lxfGIMz0 COOeUrHnts0K+d56B28v9c3z3cVUx/b3fMGZ1fZyjpKkpp24+4/WeAT8mPwSgwpqx2Aa ozu7XXKBzm+hjrhXDFrD7m280NQJz2TbSNzgE3WQ0PvEX5gzbEysnjNAuZpBMF8yoIji HScaeMw6lLujqkAurwkA0uQUII5c9TPPzCwtBgtks9zr6RIOVuAHd/gN5jlRZIijJDjW NDEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=npWguGF+sv+TNIJk7vE0aKrt2xI11hFGoDM/Lo6gWeI=; b=iYsC7IvMMVoCYcxDVNeXEME9HNjw/p49RGfHZumXDuratusmccqdT4MZSu0ip2F889 xycFYb6auV6yuxIv9YpdMTIXn+IctvrjkuKmn5564mTnKASsz85tLf5KLIcaJHGpju1T 9NMLWnUzaNDebbL9KxI4KcFi3D3MFU2lq7DA+ipDQy9C2H7mXNNC8QGyxpC2Hrb4IaL5 J0Ysbclg89R53wJpZQrn5ewzl4qjdNOGfWFcYfiFkxcapa649tkNlSs8RjkovxfDtJDG M6jGLLASOi5TmFo6wyRSIcy2aowXMJRb1PJhW/nNKW/GlQTj4qbvYIsHEBbI7SZaihNV wIDw== X-Gm-Message-State: AOAM53189Ck5kvz92gIIjVwsTMmEk9QJMu+a4+zHEZW9HZ8g2vu3lVSH 1ZJ6vV8hvqPmTj4LW3LH9Cjw X-Received: by 2002:a17:90a:e2c6:: with SMTP id fr6mr10415047pjb.198.1623844798144; Wed, 16 Jun 2021 04:59:58 -0700 (PDT) Received: from localhost.localdomain ([2409:4072:280:c67a:95b5:d877:b175:798e]) by smtp.gmail.com with ESMTPSA id m1sm2307646pjk.35.2021.06.16.04.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 04:59:57 -0700 (PDT) From: Manivannan Sadhasivam To: kishon@ti.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, hemantk@codeaurora.org, smohanad@codeaurora.org, Manivannan Sadhasivam Subject: [PATCH 3/5] PCI: endpoint: Add PME notifier support Date: Wed, 16 Jun 2021 17:29:11 +0530 Message-Id: <20210616115913.138778-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616115913.138778-1-manivannan.sadhasivam@linaro.org> References: <20210616115913.138778-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add support to notify the EPF device about the Power Management Event (PME) received by the EPC device from the Root complex. Usage: -- 2.25.1 ====== EPC --- ``` static irqreturn_t pcie_ep_irq(int irq, void *data) { ... case PCIE_EP_INT_PM_TURNOFF: pci_epc_pme_notify(epc, PCIE_EP_PM_TURNOFF); break; ... } ``` EPF --- ``` static int pci_epf_notifier(struct notifier_block *nb, unsigned long val, void *data) { ... case PME: pm_state = data; if (pm_state == PCIE_EP_PM_TURNOFF) /* Handle PM Turnoff event */ break; ... } ``` Signed-off-by: Manivannan Sadhasivam --- drivers/pci/endpoint/pci-epc-core.c | 18 ++++++++++++++++++ include/linux/pci-epc.h | 1 + include/linux/pci-epf.h | 1 + 3 files changed, 20 insertions(+) diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 7e42a83a4877..63fe90dbbba2 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -692,6 +692,24 @@ void pci_epc_bme_notify(struct pci_epc *epc) } EXPORT_SYMBOL_GPL(pci_epc_bme_notify); +/** + * pci_epc_pme_notify() - Notify the EPF device that the EPC device has received + * the PME from the Root complex + * @epc: the EPC device that received the PME + * @data: Data for the PME notifier + * + * Invoke to Notify the EPF device that the EPC device has received the Power + * Management Event (PME) from the Root complex + */ +void pci_epc_pme_notify(struct pci_epc *epc, void *data) +{ + if (!epc || IS_ERR(epc)) + return; + + atomic_notifier_call_chain(&epc->notifier, PME, data); +} +EXPORT_SYMBOL_GPL(pci_epc_pme_notify); + /** * pci_epc_destroy() - destroy the EPC device * @epc: the EPC device that has to be destroyed diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index 6c2cff33f670..37dbcade1780 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -205,6 +205,7 @@ void pci_epc_linkup(struct pci_epc *epc); void pci_epc_linkdown(struct pci_epc *epc); void pci_epc_init_notify(struct pci_epc *epc); void pci_epc_bme_notify(struct pci_epc *epc); +void pci_epc_pme_notify(struct pci_epc *epc, void *data); void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf, enum pci_epc_interface_type type); int pci_epc_write_header(struct pci_epc *epc, u8 func_no, diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 063a59a58e3c..c162a73eb836 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -22,6 +22,7 @@ enum pci_notify_event { LINK_UP, LINK_DOWN, BME, + PME, }; enum pci_barno {