From patchwork Wed Jun 16 11:59:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 461393 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp549873jae; Wed, 16 Jun 2021 04:59:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+2+dblMH4bwg8G+bKUImcl7GJx6L4P21GSwyYCOSbqtPLhvQdxLloOkGDs5sDQpT1jOug X-Received: by 2002:aa7:db93:: with SMTP id u19mr3648743edt.227.1623844791216; Wed, 16 Jun 2021 04:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623844791; cv=none; d=google.com; s=arc-20160816; b=erjOxLki6KmNWBJpv582tjASftG/uY0Nnf5wMYHD8ArSONwxoTgi10f9xu7cogUgLY u+YOKQl+EUJEeMe8eB22oBUexNgRNMglUzFyRClXxNH5JltMZYBSXPbD2kLkOXz2fiFl oI7sFGlqW7hVwCKLz93zFNBhg9FkB4ih/lFLq/jbLgJor6UkFR+JZJ9GTdvBhvyOpzxw MOSImyktBLeQPpVNjKl015S56BwhlaHUvruDOtXlDtqS+ZtLeI5S50JJZ2EUxj7QSa3g 2FbEAoRTFTqRhXI8+VCBgC1PlOqi3KvmzK94OfQspV5prMQ2IjHa5+4f9QL4hJ1g72bY M6Zw== 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=fWWQKSCrhFCy8OkZJczZDgrXxFTkuwTV9AmNvxZeR+4=; b=iqySnFheJZlf5JcdwAZWCVnluYXQ1PHxOjXzSZxskwHtU7oJF2gt/AMI9Rw5T7NMYr yC1Cb/I2HfPL8pOisRV/nBsnXx/gTfLSEZPXamwtMVvaw+qqpczRAJ07gD6lFxFgL5v/ dnE54ruOzqKte8rMF8mlQpzCRSNlwKQHZTpI0JzBgjCUlT3oZpNdygH9Qc7+B9JsAe/I X21BBSV3vxffFriFDagjEl3wx3LFQuMV04G7IPHK/U4pp73LbVPzvybJXDX1WpM857FH oOg3iSI6Z0hqeSIv7Y6TYOnw0ievBA/hWD4s1ClU6E7/3DIjydwnhsPJ8ORywwPFUeEq mvPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VAjECfD7; 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 ar8si2108530ejc.155.2021.06.16.04.59.51; Wed, 16 Jun 2021 04:59:51 -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=VAjECfD7; 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 S232729AbhFPMBz (ORCPT + 17 others); Wed, 16 Jun 2021 08:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232716AbhFPMBy (ORCPT ); Wed, 16 Jun 2021 08:01:54 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14993C0617A6 for ; Wed, 16 Jun 2021 04:59:47 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id ei4so1564315pjb.3 for ; Wed, 16 Jun 2021 04:59:47 -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=fWWQKSCrhFCy8OkZJczZDgrXxFTkuwTV9AmNvxZeR+4=; b=VAjECfD79uJLuSVD6XDO2LgLBolmQtFVDZXfqmBa7yOVljl6MmNxRwzX96bcDpz08C tjAE4HktpC0UcnGKI2z7uPEG8lN9TeRvcEfmKx1McXbHtC94wx8RFvjOClbgQLEbI2Yr s6L1KGcm/4rfTUUA9SLowGmoTqcvAWYlkrlJfLIuSvfuYnMw5zjVhZqAjJnAeyzH8SWm nm3fU4cI4kEe4B5j6n2j8FYAL/obQQFL8Mdmwu0V+2OJBT8v5d0Wjq+gzyy+MPjGvRmz le642KxsUJPlHIbeAdEiLIOgW/D07FlBQ5LsL8hVn6U2MNkBhDl7/9XZZ7xT6mXboz9U rvcg== 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=fWWQKSCrhFCy8OkZJczZDgrXxFTkuwTV9AmNvxZeR+4=; b=NTmPxV2tZ3IFoe1iQX/13HsGMDu1g8e5LswtuMaZU7E0HqApfGDyykKibsgToOGUDw U8qyG9CPKT2xzDHeMY3sMjbo/yMvtBX9fHzyG5zfm8lK2Y5/2Hp60DTyJ0gKkO1Ob7pl gCvB4a4oWzQrC7jj1n881C0Rw8S1dfWNQWGuJojadIPWejS5bZLoVewdnWp8rqpEZqs7 Qvp+8P/Fzo0lYM9BFuFEB9k+P33D2eAXWBTNPSY+UqgnS6CJQDxje5lJEs8w805/u5Tg 8CJG0223zmHoPJYbjjbG/krvOEqYRsVlTJYBOY5ZfDuRYampWzqkCsuldK4VxQxN96Ms +SJQ== X-Gm-Message-State: AOAM531i9N9En5RMltgolzXvZ+BkaDSwX0cUYsl7vFdQmj2/qc0vn6sZ Wh2Tzt0d+4eY653GNrJyjfiq X-Received: by 2002:a17:90a:ab0c:: with SMTP id m12mr4628235pjq.179.1623844786437; Wed, 16 Jun 2021 04:59:46 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 04:59:46 -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 1/5] PCI: endpoint: Add linkdown notifier support Date: Wed, 16 Jun 2021 17:29:09 +0530 Message-Id: <20210616115913.138778-2-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 linkdown event from the EPC device. Usage: -- 2.25.1 ====== EPC --- ``` static irqreturn_t pcie_ep_irq(int irq, void *data) { ... case PCIE_EP_INT_LINK_DOWN: pci_epc_linkdown(epc); break; ... } ``` EPF --- ``` static int pci_epf_notifier(struct notifier_block *nb, unsigned long val, void *data) { ... case LINK_DOWN: /* Handle link down event */ break; ... } ``` Signed-off-by: Manivannan Sadhasivam --- drivers/pci/endpoint/pci-epc-core.c | 17 +++++++++++++++++ include/linux/pci-epc.h | 1 + include/linux/pci-epf.h | 1 + 3 files changed, 19 insertions(+) diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index adec9bee72cf..f29d78c18438 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -641,6 +641,23 @@ void pci_epc_linkup(struct pci_epc *epc) } EXPORT_SYMBOL_GPL(pci_epc_linkup); +/** + * pci_epc_linkdown() - Notify the EPF device that EPC device has dropped the + * connection with the Root Complex. + * @epc: the EPC device which has dropped the link with the host + * + * Invoke to Notify the EPF device that the EPC device has dropped the + * connection with the Root Complex. + */ +void pci_epc_linkdown(struct pci_epc *epc) +{ + if (!epc || IS_ERR(epc)) + return; + + atomic_notifier_call_chain(&epc->notifier, LINK_DOWN, NULL); +} +EXPORT_SYMBOL_GPL(pci_epc_linkdown); + /** * pci_epc_init_notify() - Notify the EPF device that EPC device's core * initialization is completed. diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index b82c9b100e97..23590efc13e7 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -202,6 +202,7 @@ void pci_epc_destroy(struct pci_epc *epc); int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf, enum pci_epc_interface_type type); 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_remove_epf(struct pci_epc *epc, struct pci_epf *epf, enum pci_epc_interface_type type); diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 6833e2160ef1..e9ad634b1575 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -20,6 +20,7 @@ enum pci_epc_interface_type; enum pci_notify_event { CORE_INIT, LINK_UP, + LINK_DOWN, }; enum pci_barno { From patchwork Wed Jun 16 11:59:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 461394 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp549908jae; Wed, 16 Jun 2021 04:59:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuCXX0iWlYoWtsZ2x6qCMB8uMge7omrgVr/ZdZd4UGpHLgse0L/EQdQpDVDawWY1iXdw0v X-Received: by 2002:a17:906:81da:: with SMTP id e26mr4809456ejx.370.1623844794325; Wed, 16 Jun 2021 04:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623844794; cv=none; d=google.com; s=arc-20160816; b=fnJvGSXAzCQU7JI+hU7bApIVr1xkNJ5J0onl1Tm93jKfikOLxLwiPk6TNvGuBvjkip OrzHlZNrZXMmCjk1y1J7of3wjw0HLGnOlb8aWgzSU9MSXZX7Wa9z/SPTYX2dSgMFBlGV OjUEVJCHAoLhu51Z4/D6PPLLNTUelhL/ZXTs7tgidzaJi1XZNUy17OLdlkIhmIUIj5ye dxhwJ8p4BKQ03C+TszVthR3XG1CnagAsz/XFdwwAcasH9x+T38rCXsMBWBIXXxAT4CIM Zp4KI8evBfDjF4XsG/P+mWP4rmMcnbtnvfJYchVcub+qw5HpSheCQ7Q42TvR17rCIFJ/ iZGA== 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=WfSzf8q0eDZEzZPtPn8LE1Enrwc2IXUI8dRvj+qdHQ8=; b=yobHxCn1nYGUJYdwEJUvQaaZ9YDBOFg239u+e93wCY+pNdRHF/V3nuDEpJ6ZZkVfuX /55aCGeSW9U6kjfgkP3MvKElXL/hxkcYkZC3xXCy8gLBasZYizL8OmynL8U1qs38+jXT XLYWETkGEsYSD9f8W+AwF0ta7HDyOR8DufOorOt6D4aUnNoJuewMILYSuOzVikZwW41U zGC0lIZUUl7r2THaiL6frZymn+EktEHKfHQUhfTXMNXd+zl41LkN2cKRSG8MyByNx9Tm ZSr6TXBAiq8XsXeQnK5j2ii6sJRnZ8ufk14tnS5DU0KN+W+RQ2KKNBNNbH+quReANjO5 dSmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SX6MbQxJ; 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 w21si1963934edt.310.2021.06.16.04.59.54; Wed, 16 Jun 2021 04:59:54 -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=SX6MbQxJ; 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 S232725AbhFPMB6 (ORCPT + 17 others); Wed, 16 Jun 2021 08:01:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232726AbhFPMB6 (ORCPT ); Wed, 16 Jun 2021 08:01:58 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C86C061767 for ; Wed, 16 Jun 2021 04:59:52 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso1615062pjp.2 for ; Wed, 16 Jun 2021 04:59:52 -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=WfSzf8q0eDZEzZPtPn8LE1Enrwc2IXUI8dRvj+qdHQ8=; b=SX6MbQxJx5bNXDC6+qbOT/3mfAikMaXeRvr8mtzXSi6Y5nk1XvlW2FSIFqRFGkhdk+ lb16UwwjM1g39AKfZTTox6tw9FqQEwswEy2CJEA7hsl+Re1jouxBGvYLl33FwhLeinLS RlWV7aL4DzGOEHg9qE6BijM0jE4SRM/TyJRoLA5LzFA+FPK1pcUrQS6aEuQziKTrg9Kb zTZNWFnixekHNIE6K2Ui/OtxeNj1eEq37lo4qTU9k+7ArbNCpvA5Vn2oQVsIZiZG2L5s 7JEpp+rWWH3Kv5G1nYpmrHl4bEMh8S9ecNy6pVkxn4c7ejSHN/pKApheynl7n6MTpO7f QC8A== 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=WfSzf8q0eDZEzZPtPn8LE1Enrwc2IXUI8dRvj+qdHQ8=; b=g1QUWX0wLC7OlsrxumNgg7r7p+JwpreJ+i9syqy+W4PagPG7kGUBgM1rOxCGGR17IJ gXUhJU+vAzR5QegnE9RqbD8zHIGE7ANJBAHPyqEiE0Dos3WbgPkCN7qtKIJegJfPJ6HE nFB2gjbcb/fI2bt3xGVX634dvJ8K3pYsS4eM6mjg4g7+9ZQ0pomJbfMYad+sSapQjc3K nF/DDP+qpUqW/+ipRilMb6UEHmXxCpyzACwS2va3azrWlQKj965Ksn1IGlO+6tJRHAjB 3mcUVf9FpoDkwKpiMqo11IWwRfoCZuMrva18/zUVrM14iT9Z7E3sBmm9Zc7niEX99O+u 3Jpw== X-Gm-Message-State: AOAM530zYyh4dSMShgR+SKmOU7peSMRBpu2YMaY27ABhDaK8Qc6Bu/SU dW94Dys2CpMDBlj+ve/bNZHm X-Received: by 2002:a17:90b:3b92:: with SMTP id pc18mr4589519pjb.100.1623844792049; Wed, 16 Jun 2021 04:59:52 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 04:59:51 -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 2/5] PCI: endpoint: Add BME notifier support Date: Wed, 16 Jun 2021 17:29:10 +0530 Message-Id: <20210616115913.138778-3-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 Bus Master Enable (BME) 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_BME: pci_epc_bme_notify(epc); break; ... } ``` EPF --- ``` static int pci_epf_notifier(struct notifier_block *nb, unsigned long val, void *data) { ... case BME: /* Handle BME event */ break; ... } ``` Signed-off-by: Manivannan Sadhasivam --- drivers/pci/endpoint/pci-epc-core.c | 17 +++++++++++++++++ include/linux/pci-epc.h | 1 + include/linux/pci-epf.h | 1 + 3 files changed, 19 insertions(+) diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index f29d78c18438..7e42a83a4877 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -675,6 +675,23 @@ void pci_epc_init_notify(struct pci_epc *epc) } EXPORT_SYMBOL_GPL(pci_epc_init_notify); +/** + * pci_epc_bme_notify() - Notify the EPF device that the EPC device has received + * the BME event from the Root complex + * @epc: the EPC device that received the BME event + * + * Invoke to Notify the EPF device that the EPC device has received the Bus + * Master Enable (BME) event from the Root complex + */ +void pci_epc_bme_notify(struct pci_epc *epc) +{ + if (!epc || IS_ERR(epc)) + return; + + atomic_notifier_call_chain(&epc->notifier, BME, NULL); +} +EXPORT_SYMBOL_GPL(pci_epc_bme_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 23590efc13e7..6c2cff33f670 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -204,6 +204,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf, 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_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 e9ad634b1575..063a59a58e3c 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -21,6 +21,7 @@ enum pci_notify_event { CORE_INIT, LINK_UP, LINK_DOWN, + BME, }; enum pci_barno { 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 { 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 { From patchwork Wed Jun 16 11:59:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 461397 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp550191jae; Wed, 16 Jun 2021 05:00:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyr26GhM0ASMx2fW6g34I51SqcsITISwSA8KYnBXxCh5sWop65nC7pb0SCysDM0Y9clNW9I X-Received: by 2002:a17:906:8345:: with SMTP id b5mr4869708ejy.14.1623844813400; Wed, 16 Jun 2021 05:00:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623844813; cv=none; d=google.com; s=arc-20160816; b=QfycMCKUWFNKnTQ3Xtd5W/1VLZ7r8ZQPWrCB/oiULtnrMvAqCtWntbDOCqBHdwR/d9 ONb0RiF294mFAzfhrXOUv/r3hyIeQTt/3WpN24OW/srB+PgzbDQnt6Lrke8MlS/vel8g xxbFewW48/VvgtczdIRABgh2dw38ixdnY0NTNImTIzUE1jAXiUrzeBubwv/IaO+wH5hx PjwdwZ6kRkf2NSRjkBHBjD+svgi72Zlo5OkgaDLxCGvQLSRUMKIOTwWrXRTuVomV0da7 +gLU2emg9tmNtjhb6N1lD3glXbev+e6fgtFdpuxRUU1kI1u8dDrUzta2ehv4bV5ax7Jb RfxQ== 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=Q6FFMNi0w8wBxpKeYDdXPwwxjU3cn3Myi2hz/ywMz+w=; b=KtvNdBXg7Mu31ZkDVIY2lCFlmz07WZalg0lKzL4o5/ZZdmVGA5sRDhGKKfqAWMQo+B FE4bgNbs8kLccA3gXtTg8fltq4ibOCXpoJibd7LLT38l/F/K29rNo/iALgz2VKtueZrg qiaX8bA5Rc18CZ6CC5ue711jZk2Ne7c5B9gKMFyBVJPZKbIqBIaHNw3NRES7diwIijTs xSmgAPl2Sw11kSFiAteDZDS4gJx+mF3YBA+agAeBHnZIvRyAhP9PeKh1VB9FFdKsmkpX 87yeyWdRJ2i/3HWxBuuLZG2yBFvsoKeQ2zXJVtoxCxvK4CUrIkTU4jYCVZPwXDXEGt9+ deQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=II+5q8Jr; 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.13; Wed, 16 Jun 2021 05:00:13 -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=II+5q8Jr; 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 S232753AbhFPMCQ (ORCPT + 17 others); Wed, 16 Jun 2021 08:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232730AbhFPMCP (ORCPT ); Wed, 16 Jun 2021 08:02:15 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDB04C06175F for ; Wed, 16 Jun 2021 05:00:08 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id g6so2046787pfq.1 for ; Wed, 16 Jun 2021 05:00:08 -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=Q6FFMNi0w8wBxpKeYDdXPwwxjU3cn3Myi2hz/ywMz+w=; b=II+5q8Jrp2elpES9k9l3CmxQr74TfDa0QaoFGUqPiHmS/vS6groglYsZx79zA1oICB f54xfCHO8ppvcApZttYBuBZCqFHeXAFlH+n1btsBQaOL7CJxmMeGKwv6WcpJukKFGSdh gkewXhTsG1UHLEmWTN6FDFGz+nkUYca20wbk/eLp6r4k5QqXtcNk+tE+QiyrG140SALh FdOibp0iFLmHgDrU9xl82BHE0JxpIAYkyLwW0HRa3JD56WgbbMwu7LIt+49ZldVGgexj AQZWuJoIWmPg0VVHO9H6ar+vB6Tf86T4tSuOHBTW7roSb49gGjsBGO2VSSlxeAAyJ4RA a6lw== 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=Q6FFMNi0w8wBxpKeYDdXPwwxjU3cn3Myi2hz/ywMz+w=; b=jNr10PHQkEkppwuW9rMIZCPpp9P7cIuzYct/7YZpV0axSh5zWuxkhhXdBpydJNroxG QAKpiWkNjEs1eo6XPvEcVXOkyWJTVVX4rgepiTbBSSMbiPN7ai1eRJD5DHtiC0D2K3v7 vDz4NHYclj+n4knLVOIUPpzwaZF2QomySvCttDUXGUtJWMHzKnKWXFgqlGX/GDxWxYrl PaP3w1Sleq1P+tEncvnrQdxaBNrNbEvKSvILqbz53xlziZcxO6zUm3p4VNu29TWTPNMG giyO57l4tQLBTYsNye/it0jcTWz+Ms8laiheuXJdiKR7gKiB4q/KAULbaV6uM7J24Mdj CT6Q== X-Gm-Message-State: AOAM531Bzq5AKDO5lvHfCkQLfU9uTqkZLH2R6hgd+ZmW7LI1bmPPzMhf bLOzo5Xz/UhN952eSrCCFwqk X-Received: by 2002:a05:6a00:d65:b029:2ec:2bfa:d0d1 with SMTP id n37-20020a056a000d65b02902ec2bfad0d1mr9278866pfv.14.1623844808273; Wed, 16 Jun 2021 05:00:08 -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.05.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 05:00:07 -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 5/5] PCI: endpoint: Add custom notifier support Date: Wed, 16 Jun 2021 17:29:13 +0530 Message-Id: <20210616115913.138778-6-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 for notifying the EPF device about the custom notifications received by the EPC device from the Root complex. These notifications are EPC/vendor specific and are shared with the specific EPF devices. For instance, the Qcom EPC device generates events such as MHI_A7, MHI_Q6, DEBUG, MMIO_WRITE, CFG_WRITE etc... These events can be passed to the EPF device using this notifier. EPC --- ``` static irqreturn_t pcie_ep_irq(int irq, void *data) { ... case PCIE_EP_INT_MHI_A7: pci_epc_custom_notify(epc, PCIE_EP_INT_MHI_A7); break; case PCIE_EP_INT_MHI_Q6: pci_epc_custom_notify(epc, PCIE_EP_INT_MHI_Q6); break; case PCIE_EP_INT_MMIO_WRITE: pci_epc_custom_notify(epc, PCIE_EP_INT_MMIO_WRITE); break; ... } ``` EPF --- ``` static int pci_epf_notifier(struct notifier_block *nb, unsigned long val, void *data) { ... case CUSTOM: cus_event = data; if (cus_event == PCIE_EP_INT_MHI_A7) /* Handle MHI A7 event */ else if (cus_event == PCIE_EP_INT_MHI_Q6) /* Handle MHI Q6 event */ else if (cus_event == PCIE_EP_INT_MMIO_WRITE) /* Handle MMIO WRITE event */ break; ... } ``` Signed-off-by: Manivannan Sadhasivam --- drivers/pci/endpoint/pci-epc-core.c | 19 +++++++++++++++++++ include/linux/pci-epc.h | 1 + include/linux/pci-epf.h | 1 + 3 files changed, 21 insertions(+) -- 2.25.1 diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index b4a7bb3caa97..b963a4aa0af4 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -728,6 +728,25 @@ void pci_epc_d_state_notify(struct pci_epc *epc, void *data) } EXPORT_SYMBOL_GPL(pci_epc_d_state_notify); +/** + * pci_epc_custom_notify() - Notify the EPF device that the EPC device has + * received the custom events from the Root complex + * @epc: EPC device that received the custom event + * @data: Data for the CUSTOM notifier + * + * Invoke to notify the EPF device that the EPC device has received the Custom + * event from the Root complex. The custom event is EPC/vendor specific and is + * shared with the EPF device. + */ +void pci_epc_custom_notify(struct pci_epc *epc, void *data) +{ + if (!epc || IS_ERR(epc)) + return; + + atomic_notifier_call_chain(&epc->notifier, CUSTOM, data); +} +EXPORT_SYMBOL_GPL(pci_epc_custom_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 94c66fae8a88..943d31a83f6e 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -207,6 +207,7 @@ 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_custom_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 ca020c080431..2fa3b90399b9 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -24,6 +24,7 @@ enum pci_notify_event { BME, PME, D_STATE, + CUSTOM, }; enum pci_barno {