Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BF1EC74A44 for ; Tue, 14 Mar 2023 04:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229551AbjCNErC (ORCPT ); Tue, 14 Mar 2023 00:47:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229854AbjCNEqx (ORCPT ); Tue, 14 Mar 2023 00:46:53 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B8592713 for ; Mon, 13 Mar 2023 21:46:46 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so13929192pjp.2 for ; Mon, 13 Mar 2023 21:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678769206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MJgDTGPG3O7w69/b8j6+Tmk/A5SbbomMgk7rRHGZCSE=; b=JZRz39XhSL3phM1H74eCCcgQqHj7mBExgBLkqlGYoV8sX2n8D+AiX98ge8+6xWWEgN QLfDDheoo4YFcM06PX8lEfL+BitAhYUAqh3Ps7Wk8uX1SkBB0J2xoKcHzfMd3jPExDij O6hJFKO27C/zbT5FCbzmVWxVmPXGZQLuU0IiT19pPzTQPaGBiXTUTq88QZOFgp7e1kQw kBx8QdJPpemRFKUb6Hylzx8du4Hfhq26dJOAo9hgh5JRHFQkShS4UwhYjP42Nhq0JMEA r2Xhwy7hVrWklOraLN72k7wVIoAryqWoV6m8Z5uEXpB6+cAzwTpyauQwh++MwoDxUe6X 2l3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678769206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MJgDTGPG3O7w69/b8j6+Tmk/A5SbbomMgk7rRHGZCSE=; b=7MQ04GiVJYW/2E4ldKPcqS2EPDm/4nvNyTCvB/UnTOmP2Qy2PZ0DsYOEk7+Dk055Xb 9qCMOwcoHbwagBF+MwhiGs/kucnCPuI33WMwxRtbYv1494IyiEewSBzsTUyY4zJICCmy 0k+h7zdd82QEVvlN4ReRnRovC6WEa1eX6J1JQwpHoniFwJLt0eMeVFFHuqh8RdZ/UtVG JaR3dIDhxSQWD4IlvhgmKN3JGIZAqjaXLJB+/Bb09+JDCB6lXLSYbr12FWxSCfeoXFw8 8SFSYt5hIKl1h6wOBLx3vBOdKxvI8m6O8XoznI3uQy+0su5O34r06gzx89ESlDxBuLUC DvVA== X-Gm-Message-State: AO0yUKVdrFUZvoPwd29EjNnC7jcBnVz1lLqTDCm0iznba+JlYz6EqLlI Yg44N5MFVN6xBpv5cL2zIUQx X-Google-Smtp-Source: AK7set8AT/udUzTtm9cpz2YW+ku0NrdQL0nka+Vf0k2ObTgXHMMUceLO6ZGZDeL+YQlGGgBj7YBJlA== X-Received: by 2002:a17:902:db04:b0:19f:3e9b:7527 with SMTP id m4-20020a170902db0400b0019f3e9b7527mr8716245plx.61.1678769206058; Mon, 13 Mar 2023 21:46:46 -0700 (PDT) Received: from localhost.localdomain ([117.217.177.49]) by smtp.gmail.com with ESMTPSA id lh13-20020a170903290d00b0019c2b1c4ad4sm690125plb.6.2023.03.13.21.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 21:46:45 -0700 (PDT) From: Manivannan Sadhasivam To: lpieralisi@kernel.org, kw@linux.com Cc: kishon@kernel.org, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v3 4/7] PCI: endpoint: Add BME notifier support Date: Tue, 14 Mar 2023 10:16:20 +0530 Message-Id: <20230314044623.10254-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230314044623.10254-1-manivannan.sadhasivam@linaro.org> References: <20230314044623.10254-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Signed-off-by: Manivannan Sadhasivam --- drivers/pci/endpoint/pci-epc-core.c | 26 ++++++++++++++++++++++++++ include/linux/pci-epc.h | 1 + include/linux/pci-epf.h | 2 ++ 3 files changed, 29 insertions(+) diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index e3a6b5554c1c..11bd873a7997 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -758,6 +758,32 @@ 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) +{ + struct pci_epf *epf; + + if (!epc || IS_ERR(epc)) + return; + + mutex_lock(&epc->list_lock); + list_for_each_entry(epf, &epc->pci_epf, list) { + mutex_lock(&epf->lock); + if (epf->event_ops && epf->event_ops->bme) + epf->event_ops->bme(epf); + mutex_unlock(&epf->lock); + } + mutex_unlock(&epc->list_lock); +} +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 63a6cc5e5282..5cb694031072 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -205,6 +205,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, u8 vfunc_no, diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index f8e5a63d0c83..f34b3b32a0e7 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -72,11 +72,13 @@ struct pci_epf_ops { * @core_init: Callback for the EPC initialization complete event * @link_up: Callback for the EPC link up event * @link_down: Callback for the EPC link down event + * @bme: Callback for the EPC BME (Bus Master Enable) event */ struct pci_epc_event_ops { int (*core_init)(struct pci_epf *epf); int (*link_up)(struct pci_epf *epf); int (*link_down)(struct pci_epf *epf); + int (*bme)(struct pci_epf *epf); }; /** -- 2.25.1