From patchwork Tue Mar 14 04:46:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 69283 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1566707wrd; Mon, 13 Mar 2023 21:58:46 -0700 (PDT) X-Google-Smtp-Source: AK7set9OuNlmBMsdv6oV3clLc98or832uE615io8HnDeqICK6HoUAtx8ZaTD8oBNnr4HGA8un9lY X-Received: by 2002:a05:6a20:4da8:b0:d4:4ec9:ac42 with SMTP id gj40-20020a056a204da800b000d44ec9ac42mr5474981pzb.40.1678769926436; Mon, 13 Mar 2023 21:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678769926; cv=none; d=google.com; s=arc-20160816; b=RwtE78J9lFlwXABYWXCv/bpAGqwO2UB7ewC/ga1MokLMQdZgyUDq1bvHMMgT65Mvrf TZZxbf3c5eKZjlamjiAGdexgsY2kLQyX+xqBrBtsEJAblHyuSNFLEjSrW3qno0LFNK3y vQvWtm40b8fisjXiF6XA5jVcHX4T9taespst98EIGlaGNZVVbYLgjmLJdwWYfZpMC7a6 LlCrpDmnMEOHSv+qusvzxogmaVH8BRcirVv4Rq3WU6GjwcIQ/0eNXeEp3NXQqivxyK5f NvTLfWLjEx5cDJnOP82dMdzKckgzeN4WxOUhS0TnYRDohx0p4levPxBe91zf5NeyXzDT ASEQ== 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=MJgDTGPG3O7w69/b8j6+Tmk/A5SbbomMgk7rRHGZCSE=; b=j+DAyk/8KgtV7MIPewX0I1+Runz5ACP6nYDZzJ3kCqG3dSwRYNNmTfwxD3JZLSUXFz np2eZdb5gryV2jkKfXaaOhYR6U8F4G12s0dSBwmxpU5IpqNzxkSQCjt2x3veZR9Y3xeo ZvuUjUqk4SsqwP2NjpnMKceGUFg2G0JH6YmsWaErjgBu/MVE3SbMTjdwVeZmZA6cw7Vf 91hfP1K5DQ/VK7/DfTJ+KQD4RQetUvoBPgvSFZ2q3b2V3XcmIHgoxjr4UXhX1BSId0ZW RDWAL1cWkMMU1cFvFYyaVBNIYRq9K/uZ8qt7scq5nsVn944xSuJGrn35THSZWrfvyKN8 wOHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JZRz39Xh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a63f216000000b00502d794102asi1348521pgh.588.2023.03.13.21.58.33; Mon, 13 Mar 2023 21:58:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JZRz39Xh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S229836AbjCNErA (ORCPT + 99 others); Tue, 14 Mar 2023 00:47:00 -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-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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760317854546185371?= X-GMAIL-MSGID: =?utf-8?q?1760317854546185371?= 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); }; /**