From patchwork Wed Jun 16 11:59:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 461396 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp550163jae; Wed, 16 Jun 2021 05:00:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqvS13x6QATJ4lCwJ3xjRlrFIh9S2+rtpw4Ls4Q9FEf8eloIDpp/wrY6JUkhdybJyv6IeF X-Received: by 2002:a05:6402:4c:: with SMTP id f12mr3736823edu.84.1623844811526; Wed, 16 Jun 2021 05:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623844811; cv=none; d=google.com; s=arc-20160816; b=jKWF5nS8GI+UD1/iBHG0jW8cMcjCb/N0TFNCMQNVB/SscTnJIi5jnHEWxhqpdA+MAz 46h7a+dHXRbzBT4kCDZ6mOr77KTdrJGUnSSxvoUs4rK35zBfyjYVBldveA5sj1HtOdLb 4NzyJskHW+cl52Dee7/bEFgU0q8TLG4Ru2ffrkX7Gl8g9uD6eu6SmhGDhxo5TxwijAm1 +wVWegiADJOWZJo6tgpHhYc7UgIqTnrjH5UrETRKGBtwvVkAaUEMwD/HFrJPUU6bRwpz SOKoWaqAj7cjOGZdUMf7KDV9ySXjGISMyeBp28nNBA8pLUdttPCOQZcmVW7y0hyv8Xx6 Hw8g== 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=nDCCmeJMQtzprUTNJPaEV26/JKcM/RuAlK0UO9dpDaw=; b=nLG6P7saJmVW8xDRQ+JXTj43NRhGpVbGHNQ0wSCq4C+A+4Bv79Lhwh9BhSowyPYo8z DGkqS4LCQXlOb13LAzu9muaY4cxsqjOFUvjbtA8Edd+1sjOvK1HlmUqBJ7oDiHX8g5So vooOKBxQkfbvbu+iAdDNZ6it7g4F0LheA7dJvNVq4lpyxJANRgvQ1aYBW+pvqYvW1qXw oSXBCAJMxSQutiAs7FxUj6nd4ByLvUJhKjao4YECJ4z9OJj6SA4JQX6TEQGGqWurL7m9 AnLlnuSZvm/5bPR5uGyDAr3Vh/W1QIQjVVAs+/19bVkYoVgfd+Mm1MJ/Vi+89gVVxcjC ILrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tOy1eq+e; 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 bx14si1899023edb.253.2021.06.16.05.00.11; Wed, 16 Jun 2021 05:00:11 -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=tOy1eq+e; 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 S232750AbhFPMCO (ORCPT + 17 others); Wed, 16 Jun 2021 08:02:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232744AbhFPMCK (ORCPT ); Wed, 16 Jun 2021 08:02:10 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53DA3C061760 for ; Wed, 16 Jun 2021 05:00:04 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id v7so1787385pgl.2 for ; Wed, 16 Jun 2021 05:00:04 -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=nDCCmeJMQtzprUTNJPaEV26/JKcM/RuAlK0UO9dpDaw=; b=tOy1eq+e9UVCY4+voZO1PD4Gj2PIOqemKd5Jn+6KhiipXzL4rWtvbxIKXZnWrUzdiw rSbYJ8PbOIr+sKIW+lc90+kDqYg8Wcx6ImFvndEGsi9rdQyt+SAZ/48YNNhHAkfIUJgu qAZvavVINzXM3fECM+lrxL+TbEjVZpgYYCFwIr5ga672Dc8GYD2K340jBrLG/ugVbj8r 8OOay1WaQrvANz2W5ZeNmVCr6qfgSwu+xrNlbR76uMWKpU+LRv5jfdbpxXpCTR7dEzdG 5SKdfOnLxKqG58u9jHSFJv0BTnqO/CL5ow1j6Q97it4RLUYpdq8PirG6N2qLgJWfT6w4 JQIw== 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=nDCCmeJMQtzprUTNJPaEV26/JKcM/RuAlK0UO9dpDaw=; b=T1BS5+JN9N6tGnGACH2WIHl46whYYIlRu7Tc/pkBUtq6SuEQ6qKgObo3gmhzouSm5S LrOMs5iFj36GVOF0R1KMFlQVaFb9RLP/rz52ciDm9mBMCDiUlo15asJJRCEgMwx5UEDm wuIhdiw2PEQK9NhAGxeaGkmfs/+GrKjxGgCbvEhApDxfXYWr1iHNbCsuSPeCOTQBEb0g qp8Ux3twAeCPoetAtGtvZQK/1J/9YHFEZzwl3U3OnsVsdFaLOyYJnmASv3Dl4Ve0cdB/ mARUJu3U3EjDCuUa9FenptMqGSZXhL1Z4XaG8dTs1uxwpHHonAb9pE+O0O5YnHJoJrm/ hYNA== X-Gm-Message-State: AOAM533fjEXtAX9ixn6WXtZuTL9CBi6IPPdolff5XMDRbdy+WfNN+TTP PCjtOyQXE8kcB+edOs8EHw/a X-Received: by 2002:a63:d57:: with SMTP id 23mr4704623pgn.392.1623844803681; Wed, 16 Jun 2021 05:00:03 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 05:00:03 -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 4/5] PCI: endpoint: Add D_STATE notifier support Date: Wed, 16 Jun 2021 17:29:12 +0530 Message-Id: <20210616115913.138778-5-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 Device State (D_STATE) event 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_D_STATE: dstate = dw_pcie_readl_dbi(pci, DBI_CON_STATUS) & 0x3; pci_epc_d_state_notify(epc, dstate); break; ... } ``` EPF --- ``` static int pci_epf_notifier(struct notifier_block *nb, unsigned long val, void *data) { ... case D_STATE: dstate = data; if (dstate == PCIE_EP_D0) /* Handle D0 event */ else if (dstate == PCIE_EP_D3) /* Handle D3 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 63fe90dbbba2..b4a7bb3caa97 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -710,6 +710,24 @@ void pci_epc_pme_notify(struct pci_epc *epc, void *data) } EXPORT_SYMBOL_GPL(pci_epc_pme_notify); +/** + * pci_epc_d_state_notify() - Notify the EPF device that the EPC device has + * received the Device State event from Root complex + * @epc: the EPC device that received the Device State event + * @data: Data for the D_STATE notifier + * + * Invoke to notify the EPF device that the EPC device has received the Device + * State (D_STATE) event from the Root complex + */ +void pci_epc_d_state_notify(struct pci_epc *epc, void *data) +{ + if (!epc || IS_ERR(epc)) + return; + + atomic_notifier_call_chain(&epc->notifier, D_STATE, data); +} +EXPORT_SYMBOL_GPL(pci_epc_d_state_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 37dbcade1780..94c66fae8a88 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -206,6 +206,7 @@ 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_d_state_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 c162a73eb836..ca020c080431 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -23,6 +23,7 @@ enum pci_notify_event { LINK_DOWN, BME, PME, + D_STATE, }; enum pci_barno {