From patchwork Thu Jun 1 15:00:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 102012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp409216vqr; Thu, 1 Jun 2023 08:19:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59Skllp0thFcsV0XsnxkTTcDynntumqmGlpVhOfh5RxNTerwvkpoGdvOf0uQCjmCnZZDz5 X-Received: by 2002:a05:6a00:134e:b0:64f:49ee:1a61 with SMTP id k14-20020a056a00134e00b0064f49ee1a61mr8397674pfu.34.1685632743025; Thu, 01 Jun 2023 08:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685632743; cv=none; d=google.com; s=arc-20160816; b=x9N5Al5hqQIK/QgmgDGRGxjF+j3p9A49N3pTwfUCic+dhDAdKdyLRP786bgfHw/704 UbTTtKvV0u/93/HHEY1nLf+8H6bCEFYnHmKaoJLMiBsp0ibg4pXFDj8PscxyLQWyebKp SVSVe547RW3Xls8nTJQfryfaNNLmI1iQuwHpZ93Di4EY4qHu60yBCIK8vIsp4ISnJpQs SY7tpuKUD6a1wWO3RRgvKHeXcozp6OVzFdnTrkk063AW+cE/9n9/yV60Rdz0qVSxDUJO AbBR8uvJlHb8CGnuWCZynOYmY1mwgJ+Q1x34ptvrmZ70ANEbtL+9Tg0NXFuVU0S6fujI 890w== 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=VhNik2H+uO+Q16HqIS1xj7FIQ3fy5k7mBkKyNDoBImY=; b=mfHds4KOG4oBAiyeTRSmfSpmOmD5chpVI4YUeAsphoZjZUhRN1rRPcB3BLSgSNuyeM wmalrqOcevJezR/4jWW9QSoadc8dTkJPYgEctF0jJb3m3lzrHFrxB7HWkMsAi5lxXZ0N HJ4rh2uyTvsIU387HtH87NoOLK10qsoYSYEFmnxuPYF+2ypHaizDTbcsQvgP3w8jpEk6 VuiLU0K8mjr6E0p90xYrT6Ad2heJGqmKn2jAPRQrLMSrvpWKR4rdqJzQdoViD9j0gc6J nC/T5c1ulbilxgkIAgadWsIGpzsyOJ9PBoGArQdh5fiehtees10Y9SHVMC/JGP3rqhEl I6Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WKzaDxUt; 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 71-20020a63004a000000b0053ef0ac79c8si100232pga.263.2023.06.01.08.18.48; Thu, 01 Jun 2023 08:19:03 -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=WKzaDxUt; 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 S233694AbjFAPFn (ORCPT + 99 others); Thu, 1 Jun 2023 11:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbjFAPEl (ORCPT ); Thu, 1 Jun 2023 11:04:41 -0400 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A341E13E for ; Thu, 1 Jun 2023 08:03:30 -0700 (PDT) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1b04782fe07so4312165ad.3 for ; Thu, 01 Jun 2023 08:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685631693; x=1688223693; 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=VhNik2H+uO+Q16HqIS1xj7FIQ3fy5k7mBkKyNDoBImY=; b=WKzaDxUtNpoIhHJsiP+Qn1HVUMwainlhhT58gioDLsTG3F5oJDLYr56PVfjOW8bSuh 3C2H5dsdDF/YpNxOsgFU4WTOAUS3pYneV2bPxPyB50lSb344UVF9PGblfrdlsqDgs9Bs 6nufHzFWlZeoFysVB0ISdLsiJXG2trxiYRDnv1qafV1BolGAaPx0uX7UvT07+FB18QvF cT7jPAJGzNhbzUY0KPRgq79V3qfonU9rt5pTgNSYXzj/GeniOfA8jg0ccrgwIjjyDJsO Okjt6MHdeDJGoLZODDRmPxXOFyYEEVUsvC8IHBZYI38wFvDCaMyDxjADpmR3nt5I04BB W9iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631693; x=1688223693; 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=VhNik2H+uO+Q16HqIS1xj7FIQ3fy5k7mBkKyNDoBImY=; b=XXvMirKIRMWTBxKuoUE0UK6oNknlat2dmcYae+41uw/pM2uXQWfd/8mduuXkrlWOuH iiUDCDAQfdp8BKYhhs6X8SGM+p+5NaYiN8aIDitmRNFUszYkGCOFWzmfqHdB5ZSyGXER WE8eGGXytQGRFIFoJPuJFkqK+vKqek9xfaqSzl9UshiX7JiMkFIEDmLUHk+tEcpUKOuX UPAWqQuuJT1WoXwzAedMP99zzsxPvtK7sNRxYAUFQFg6Xn69hKVCWj3SDIbpoZXNsChc YGJcFQ6Kbmrbyq9AThHtPmVkitfZwMy6UsSecuQB0gochDM0QNLQQax8JEHj3bKplNEH S3nQ== X-Gm-Message-State: AC+VfDzKQEfCiD9/DgMH70LBpQ3v3CxETJtF78M/ey96FXcn3CRFV9tp Dnqs40CVLE7rQi9MzXBhOVXuloJPSh9KwUtgFg== X-Received: by 2002:a17:902:ea12:b0:1b0:66b6:6ae5 with SMTP id s18-20020a170902ea1200b001b066b66ae5mr6653102plg.61.1685631692871; Thu, 01 Jun 2023 08:01:32 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 08:01: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: [RESEND PATCH v5 4/9] PCI: endpoint: Add linkdown notifier support Date: Thu, 1 Jun 2023 20:30:58 +0530 Message-Id: <20230601150103.12755-5-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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?1767514039095127682?= X-GMAIL-MSGID: =?utf-8?q?1767514039095127682?= 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 0cf602c83d4a..e0570b52698d 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); }; /**