From patchwork Thu Jun 1 14:57:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 101994 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp394246vqr; Thu, 1 Jun 2023 08:01:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49EMrytbc0JHfmxIEjsrYcKkEFi30z08hCCPEyUvtA7Q1fuYV37mJZ5CxjxNA7yiXyc2jf X-Received: by 2002:a17:90a:4bca:b0:258:b676:59 with SMTP id u10-20020a17090a4bca00b00258b6760059mr923532pjl.19.1685631707582; Thu, 01 Jun 2023 08:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685631707; cv=none; d=google.com; s=arc-20160816; b=1Lb/Yi+wxGXao6g+hnS+Xs//RZEYLYaYuPjGaAKmrclQfd1t4KFeZo0RtUKzfeF4nL 8CHWfQqVnL+vVYIxI/OPQpR05F17U58LbPudwfFtRCLys/1KVywwC6qbV1UJ8OQc20rk dwhh3qsGivRrB40mkZgynZSDg2YyoqC5ONXQfnv9IhYwtGlj97g2u2wftYSP8oSYVbhT 39Ij7ZzcD2ET5So1xKwxPjCz/BmVjwl5SYVZl8F6+coWXG1wPYFskbHwFX8VKyiysa/Q 8lHB2n4WORJsWVaRQNtpQd9mrCYAg4NqiOHjJ3+mgJ57FBHSxnZTnS3qKJJXXQ0UVyCY oZEg== 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=lBzylD7cdU3tkih4EXKd83zW4wFIROl9zHibc1KZ1dVPOakKmMq6ex8xrMqiqQFDol kOv0/19CmO3vG8f/fRZWZi/4m2Gf6IwiSsTJjfnrwGp80FhUO0ZgPOHJBrKBhR19zgcZ A2hY8q20stD20VkqyQxHphDm4goKj0j4i6GG8G9pXDa44QOPDvDeUSDi+CIV7XP0Lsgu x4ARii8vxYp9wj0j3t0WSpCWpaeuWvghIO6jDNlfDyVfWcQmkMdlJ+XBTDGpLGJ7RLMQ zSFOlXLRtZdh+hDCDtIHy9rSu+ahw/4UJDkg+tBqU1iUN9LsqYprzoloO8xoWBo4KEuc r0jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j5mIwVNr; 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 gm7-20020a17090b100700b002473e331f90si1252286pjb.46.2023.06.01.08.01.30; Thu, 01 Jun 2023 08:01:47 -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=j5mIwVNr; 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 S234642AbjFAO6Z (ORCPT + 99 others); Thu, 1 Jun 2023 10:58:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234638AbjFAO6H (ORCPT ); Thu, 1 Jun 2023 10:58:07 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9102E68 for ; Thu, 1 Jun 2023 07:57:56 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1b021cddb74so4235065ad.0 for ; Thu, 01 Jun 2023 07:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685631476; x=1688223476; 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=j5mIwVNrkXB9e7PwH734RzlKBbt7G/OPSrTpfn+YG5/gW3gE8LQlxcexz/pWQkJDGW dd5UZgfyiqYh+j6mJ2q1oIfBlxZkbfA6S+rL1yrAyyye1r50ztVeDGyKcj5b7fg7yRUT ZBLlj2dF/dl8jtxHXJGUTfQyn5R/VrYw4UkdbHf+LEcgYNAfpIZkghccJJ4S4r7xPoTA 5nCft0CkjHflVSQjhaob+lnN/89X9SLro9rKDuDVJE82voOwD51IFzzNN2U2b0HvxYlY ecGsLyrNSONOkDcyPLJC39qPptYwA4nEuAcBIUAAC1XiOeOhV5K373fGmrp23FEkxYnO f3Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631476; x=1688223476; 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=jusAp91zaekWrU7w9vejuaXVvUKuqixq4y7V5m5UhjNDc/UfyOesy54083kvc9HMUS x8FjgGg6bWGkT5nXyM3cCyZLabIjoQB1JBXZ5KIAtvaJBqhPI513BLyZ3K89rZ91nAjf yUSKAUV5lY9G/dtTpc+1O3CigCC78h/D2UQEKPYnc/zSYKyj8l9cQB2o8VtzeEMziafi Oo9Qw1jgRCuw908xxIUeU08ejnKfvNr/4ZmAWCQdAGuOveBTmmoJbMKekmSdlMN+phU5 0Vu12o+vAVqQwStByJHgrFO60arGnbDq5OvrdGPVyIaIH6NbGpGuyxNVP/lnpgU9Uwx1 TuHw== X-Gm-Message-State: AC+VfDxpwhiTPQLlprsfm2Lt653OUAVgkRfNIwInu+xihh9MPFfT6fgi OUlGFmb0Vljt4lPNpWRoO5JM X-Received: by 2002:a17:902:7049:b0:1b0:34c6:3be2 with SMTP id h9-20020a170902704900b001b034c63be2mr6474782plt.1.1685631476098; Thu, 01 Jun 2023 07:57:56 -0700 (PDT) Received: from localhost.localdomain ([117.217.186.123]) by smtp.gmail.com with ESMTPSA id o17-20020a170902d4d100b001b0603829a0sm3577826plg.199.2023.06.01.07.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 07:57:55 -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 v5 6/9] PCI: endpoint: Add BME notifier support Date: Thu, 1 Jun 2023 20:27:15 +0530 Message-Id: <20230601145718.12204-7-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230601145718.12204-1-manivannan.sadhasivam@linaro.org> References: <20230601145718.12204-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?1767512953000996509?= X-GMAIL-MSGID: =?utf-8?q?1767512953000996509?= 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 Reviewed-by: Damien Le Moal --- 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); }; /**