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 {