From patchwork Fri May 19 14:42:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 96469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1291800vqo; Fri, 19 May 2023 07:48:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ65aVVBKt+yDh94eenvnbUEe4ttRPyzgEKN1RYk2Ni6V+6vKu3S0ui+9fZ4n3FEmI56a8b0 X-Received: by 2002:a05:6a20:c88d:b0:104:1016:dd4d with SMTP id hb13-20020a056a20c88d00b001041016dd4dmr1844875pzb.57.1684507738594; Fri, 19 May 2023 07:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684507738; cv=none; d=google.com; s=arc-20160816; b=jPr0wB4xFJNj1z2w6AR/cm9QHmkNj1qmkHNgaClbCU+1VrT/AXLQ+Q4ggM0tQ7RTC6 9p1xVFgS4RAoCwdP5CILnVaElmXIS0olFnSYXqCqT0BdRQH0sjwnoyUxx8pw0VJ4N5Dp CH6F9mCUoyIKB/hyzrcdDtFC2p9S+YeKFfcgfbeHXGNHj8viv9l+EehjKLo0eJQM5UEo 3cNY9LmJEFLRCfvxxhppGD6vChafswymIpVMZzcDin4wke2Bn/GuOj7/JTN2d+EV+O4y ZGcOA3nK0p/wKvdEmpuzXJlkHrxiZx6iHhByDf2aGw96+f3zQ0CvkYwTy26L19McUVrT ITww== 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=Y0Nj6xvTZCRiBBoVUykKLMC0GwPG51XjYBpupCLgLXc=; b=Lr0AY9yWdi/WAmVU9T9FMV06Kov3cDqmjvB64tupPP5fvfd3XxBWNFgsJmHMiUYuiE zxMHWaKT90oV3X7PeuFEnXfKM7kpED35Y9qW8bJ+UGQnkEYyZxJaHBSewxZQrKeZEzSr 9mDpuvFrxdK2Ga5kM1PpIrQJXttuvB23syTtzkrznDoBa99ukvsJyFVhMjdTp/AfL7mw RYgogJvYvRupgsYZqvGTB9ppulN+oVM6QJgX99MKZmwOWvhqe6Bt7xjvpOJOzVGSX+Ov huaiq3paZl6zaINsB5gkNr4Nmkhe9i77FobLn4RtzzQOZdvazWJ2q59tehphgoVCYD5G rb8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K0kt2N60; 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 b200-20020a621bd1000000b0063f2827e1dasi3501889pfb.184.2023.05.19.07.48.46; Fri, 19 May 2023 07:48:58 -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=K0kt2N60; 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 S232068AbjESOms (ORCPT + 99 others); Fri, 19 May 2023 10:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232199AbjESOmh (ORCPT ); Fri, 19 May 2023 10:42:37 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29024E66 for ; Fri, 19 May 2023 07:42:33 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-64d341bdedcso513409b3a.3 for ; Fri, 19 May 2023 07:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684507352; x=1687099352; 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=Y0Nj6xvTZCRiBBoVUykKLMC0GwPG51XjYBpupCLgLXc=; b=K0kt2N60Z5EDo3wlxaZ+oVBbfd+uUCkPvW1R1/lUWTEfqNhl4hXOQl+eW5E17/oMzS PCFqiVb9r7Wc8jfJPdYYoCrOrRd7N9A7gL8M8pCMZiEDZoEpViZrxMnnarTT8rdRG9C0 OmqfRHLljypcQupS9qtAXGgsgSbvLrscESECEJW/Gp6ulvgJHgx8ET5l24XhuBMpV7eI W98QthDpRI7f4JQLIsbiEXclk3yXVSZo/klSfGgPXIs2ZLZU/vn2kJyQIHXxnX7WbaX5 /9Uoqq3aavtqMySbigMN9X1fffeMCDoE3uIgzXL6TPNf46cmtyBMJFD0QKCLO6qiwH8c nlDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684507352; x=1687099352; 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=Y0Nj6xvTZCRiBBoVUykKLMC0GwPG51XjYBpupCLgLXc=; b=JDUwcwoNUC/uPBGIZN7UKagqqpzZ9u2Go4pTlF0oK2NbsPrXYt0pwkic2OwzVTwopB B0vWd/Ou5EfZLGlQYcloQ3DLu1xqZJSk1XGMbggE6KuzD8FSGVjwOUYRu9lfRSelGcWL VNjNuRm9s12bY3EKO7+RVN7eF+3QWi9QSO9gJCD9jFZwORS/d9066iMFUzUqMMxNxUf+ csVfeD8Q4bHCmuJXIvrgQK3wGRkXJ1AoB2/Z3Mgpuwf3gDwaL93PfsTzPgn0F8b6tprt CejHuZ/MChkJzqcdrE6wwZowLmdZOAemLaLMes5mATZEJK54BFXzdjcQn6uy/PzYpGcz 2TNA== X-Gm-Message-State: AC+VfDw80pd5DSh2o2H3uoVRnG6NtQJ2juLHtF0kjC0D4fM2Uh2FkupD Rc+0wVoWvqhu7LSzpCjs5pB8 X-Received: by 2002:a05:6a00:13a2:b0:64d:2487:5b20 with SMTP id t34-20020a056a0013a200b0064d24875b20mr3440157pfg.9.1684507352390; Fri, 19 May 2023 07:42:32 -0700 (PDT) Received: from localhost.localdomain ([117.202.184.13]) by smtp.gmail.com with ESMTPSA id v11-20020aa7808b000000b005d22639b577sm3089611pff.165.2023.05.19.07.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 07:42:32 -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 v4 3/7] PCI: endpoint: Add linkdown notifier support Date: Fri, 19 May 2023 20:12:11 +0530 Message-Id: <20230519144215.25167-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519144215.25167-1-manivannan.sadhasivam@linaro.org> References: <20230519144215.25167-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,URIBL_BLOCKED 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?1766334386414429460?= X-GMAIL-MSGID: =?utf-8?q?1766334386414429460?= Add support to notify the EPF device about the linkdown event from the EPC device. 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 46c9a5c3ca14..1ecbe2b1d3bd 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -706,6 +706,32 @@ void pci_epc_linkup(struct pci_epc *epc) } EXPORT_SYMBOL_GPL(pci_epc_linkup); +/** + * pci_epc_linkdown() - Notify the EPF device that EPC device has dropped the + * connection with the Root Complex. + * @epc: the EPC device which has dropped the link with the host + * + * Invoke to Notify the EPF device that the EPC device has dropped the + * connection with the Root Complex. + */ +void pci_epc_linkdown(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->link_down) + epf->event_ops->link_down(epf); + mutex_unlock(&epf->lock); + } + mutex_unlock(&epc->list_lock); +} +EXPORT_SYMBOL_GPL(pci_epc_linkdown); + /** * pci_epc_init_notify() - Notify the EPF device that EPC device's core * initialization is completed. diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index 301bb0e53707..63a6cc5e5282 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -203,6 +203,7 @@ void pci_epc_destroy(struct pci_epc *epc); int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf, enum pci_epc_interface_type type); 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_remove_epf(struct pci_epc *epc, struct pci_epf *epf, enum pci_epc_interface_type type); diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index bc613f0df7e3..f8e5a63d0c83 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -71,10 +71,12 @@ struct pci_epf_ops { * struct pci_epf_event_ops - Callbacks for capturing the EPC events * @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 */ 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); }; /**