From patchwork Thu Jun 1 15:00:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 102014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp410050vqr; Thu, 1 Jun 2023 08:20:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FRS7ChpZJEeQ3GLWemWgVU2juhGZE/zp09iQ6vbH5vu8NK2kMZyGv8I2cnoTKyXFfUuQI X-Received: by 2002:a05:6a00:2d84:b0:62d:d045:392 with SMTP id fb4-20020a056a002d8400b0062dd0450392mr12141328pfb.32.1685632808409; Thu, 01 Jun 2023 08:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685632808; cv=none; d=google.com; s=arc-20160816; b=DiYrXjmoTjY2FR92rC23R0iMmWW2ZOvDpUCSbf0GW5dpN6ed2MOsYoHQxt2xUA+YYo E1rn1vtgGnZJihGT3BjgQQqCMQjkXxXA6w263v2NPAHXgZ4BKGP30o3F47u817npAlP2 t46v07cHeRefGRxgINwDhlG9uDAWXFOYdLn8DpzlLxdgdF9NS9hj+BfwdfNdCbGRNTBb 3WBIeV/plM8MktYCBUMJAC+PFSXTlLSRFY+hTAqUdvC1iVKyukV/R9P81snrzHEFqfOL Cbc0USh3e8r7mQz9IWTatgm15JluV4alE36Un1362DAd3b+Ip0RDoQEuHraxjME0ICWm /I1Q== 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=hYZvtGezswvgwNKpdFwjsrVB2tlNlkIcg9dibR8Jyd4=; b=Lcxc2pL/t2NlP/HuttzCVYSB/UuZATB8+fgInXRBc+Ia1VbIHY80oJfNSOodhP9tTe 4IheaXkEtq+JAak8HvBbv7xuLIJ8TElAPwyOSUS3NCWfdDedYp1xjUyo/uBfDQX7Rbio pg9M/q3h/MFn9Fchj/tp5KfrXVn78dPWBJTVqN0xQ/ckgsYh8VLsRXslPGT7e/QeITII u01e+bX2hMZs5CGMQbcrOvmwfkcjJT/vaOUCvauRc1oKMb8Z6SI4Z0QbA3IklvMeeWnk tJ6U+OangBMxxOhT+541xkvoqqVLRj4V/HkRU5Iswx/tqVJdnZBtoLEAw2/qz+65NLBp Zw8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yWfa1cfs; 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 h13-20020a056a00000d00b0064d5c5d72c5si5540607pfk.330.2023.06.01.08.19.53; Thu, 01 Jun 2023 08:20:08 -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=yWfa1cfs; 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 S234610AbjFAPEo (ORCPT + 99 others); Thu, 1 Jun 2023 11:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233637AbjFAPEK (ORCPT ); Thu, 1 Jun 2023 11:04:10 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ED4F1700 for ; Thu, 1 Jun 2023 08:03:11 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1b01d912924so8846255ad.1 for ; Thu, 01 Jun 2023 08:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685631696; x=1688223696; 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=hYZvtGezswvgwNKpdFwjsrVB2tlNlkIcg9dibR8Jyd4=; b=yWfa1cfsbNuv8SL7i0k37kcW+rev8gxSikZmYhFIW5TZlc5nLt/soh558LQsSCrCPQ 2PJw+jVJOPLWH3zLAS04Y5iKpReBZQWWy3VabC3iEFV+Bcb003y/bRIHBoYm06ZDIcL5 BqB2JvBVg556zdAzKG+D+o6p5mseda+6gfiSiqD9mm9eBNjpNA0qKoXK+9ycp5OB3aGT nkr5tmiwYpCSRAmcbSNu1eIOEJuxjXCR5J7LYamuMVkQoxTH9KAoiNgE0SRzmkFP4KlJ G9xjm3vWeagD6NoMpM1dBmBxONM+RUVeEr+WXg5VWhwY0T18z6Fh3UNBrXZAQ5UhqRuF jkkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631696; x=1688223696; 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=hYZvtGezswvgwNKpdFwjsrVB2tlNlkIcg9dibR8Jyd4=; b=B4Xc6UsUD/RpFUhgvVoK+R6b3wHZ9/J+FFV5olZhNmlzRhP99ziLVICcl4quvUjUkK +ts5GhO0tbeYIQyV4gebWhCaEkvjr4JyvU5Dn1FdLnfUjC8qQ32Qc+3KEir4LTWePT5s bXNLN5ND5Y2Pqbu3n/rq2rUwd6Vq0kz7pzWcvh6uA52b/GyJst19jFHVaIcMtgHsQi+L PFHYjNISMCCKLeQE65MHG05zbCCSFUaCyAbJMkghscfl2wmDTmCcWahhKYBOOdKAv51I wqvmiKYHkL4WY4r9wI6KY0rhUYgdD+c+lrzVdcnKY3RMGJoJStSEJpLHSeI0gZ2EZWpo ex/Q== X-Gm-Message-State: AC+VfDynCIntHokrQHcRMDDqHqs5wsNpFer8pDiK+y9BFShFs9fvwPlR gj0PJi+472ce0snqPLNuEvsH X-Received: by 2002:a17:902:6b8a:b0:1b1:80ba:39d0 with SMTP id p10-20020a1709026b8a00b001b180ba39d0mr4411729plk.30.1685631696116; Thu, 01 Jun 2023 08:01:36 -0700 (PDT) Received: from localhost.localdomain ([117.217.186.123]) by smtp.gmail.com with ESMTPSA id q7-20020a170902dac700b001b0499bee11sm3595480plx.240.2023.06.01.08.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 08:01:35 -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: [RESEND PATCH v5 5/9] PCI: endpoint: Add BME notifier support Date: Thu, 1 Jun 2023 20:30:59 +0530 Message-Id: <20230601150103.12755-6-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230601150103.12755-1-manivannan.sadhasivam@linaro.org> References: <20230601150103.12755-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,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1767514107344658955?= X-GMAIL-MSGID: =?utf-8?q?1767514107344658955?= Add support to notify the EPF device about the Bus Master Enable (BME) event received by the EPC device from the Root complex. Reviewed-by: Kishon Vijay Abraham I 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 e0570b52698d..6c54fa5684d2 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); }; /**