From patchwork Tue Mar 7 15:14:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 65634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:570d:b0:a1:2e52:cf23 with SMTP id h13csp1967797dyk; Tue, 7 Mar 2023 07:37:21 -0800 (PST) X-Google-Smtp-Source: AK7set9K7UW3JrVCJ0yE3wxBFBictiCCffGVVw5ca5UGeHQ+o451uCuyNXer7hm9ktBlc8EXBcEW X-Received: by 2002:a17:902:eb8f:b0:19d:c9f:44f0 with SMTP id q15-20020a170902eb8f00b0019d0c9f44f0mr15709703plg.32.1678203441496; Tue, 07 Mar 2023 07:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678203441; cv=none; d=google.com; s=arc-20160816; b=M3zOjGpMMeWX887f2iYudbSj2UOcKto2nY/QGc/xY9bCr6ChexG9cLvDCaN4kQA/5A 90u6rRj4zGr1M4kBnHKApkfkLr9plammwKwro5B9vQxyhqzuDlcARFwe3GMJgwXMsy9d ipPTndbjsEdJWDyhTaE0XgtEG9O/NYxJvluwnJBu86UIVKVY5ceV4qXnR2ECki1oqpxe DOpP5Q6c0gPpc/3A0hAfjxpH0/114opgu8NVua/2Iug6bHlGPWloNLHnelLswvN3F+YA 6g9irQWQ7kDaoXbx03dP0rtn8keS5WCFvGPAQLUSqDme8gOci2a0rikU3SCTgomgzTmR +BIQ== 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=5CebAT6G7pMdHj4gkjeeBHR/+GUK4hl9hBpqAKTE774=; b=NRgpkG0sQjjoA+FdMOyi7LmR+HxvvK964XRea6xJevCZTMNuPN9yC9ar4rWNLR7pD5 7z8yT5DUPTMwtSeUkHOz49sBBf7X6ZJxzhXIuR5cnzUjYQCQotvDDm3zyBBDra7Ucpzo founKlUwyDfVNB+L7ezB4FtJBu74D8ySivCz37qp9Qt+6J+laLGF53uUQPN5nFMNT543 MLjrXhj5ZEYlFaLlzAo1/al9HAxUhqp7ORkyhb59oqyOIuSL4/5xPlqxvQUK09VykYTp 1TdQJqHdz9/hEcxW1URKd/lkAWNYcH/l8eummqLFKcr6UezjAhhav4x2GFXgwujOW8MB GjIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zyYTr4lb; 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 i30-20020a63585e000000b00503a029385csi9697718pgm.14.2023.03.07.07.37.09; Tue, 07 Mar 2023 07:37:21 -0800 (PST) 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=zyYTr4lb; 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 S230297AbjCGPSA (ORCPT + 99 others); Tue, 7 Mar 2023 10:18:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230504AbjCGPRc (ORCPT ); Tue, 7 Mar 2023 10:17:32 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3F46241C7 for ; Tue, 7 Mar 2023 07:14:35 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id n6so14418002plf.5 for ; Tue, 07 Mar 2023 07:14:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678202075; 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=5CebAT6G7pMdHj4gkjeeBHR/+GUK4hl9hBpqAKTE774=; b=zyYTr4lb+xRvb6jYHLHpDUs5fW+RUV0GC00D8v+twpYwkjn5gauDWIpVnOqvXb1+t9 YSqY8aLuzKFNUEpRbJltV8ohRDcvTMBfDAvY5Irw4aXnMSiaOpLd4wZ1wA5ZXv5y9xQv 3l9xUKx2oVPoZSCrkCuYbh4uVM6gO0aQZbR4ral4uISQlZNAWXW04XzruEz2ZPnjAf37 MAiwPb0PaFC+R5/VRYnp7Cs2K4OovLuV2FKcWg6ZrsE5lTEFgGsSTmoKIDVraxoGUsBD qMqDlEmBqQ6eK8Go/d3FvKvDKlJ/3rTekOhGUlysUiVYWZBDGh5mB/RGEOacK87GiPwd L53w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678202075; 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=5CebAT6G7pMdHj4gkjeeBHR/+GUK4hl9hBpqAKTE774=; b=R8Skqq3xstpZXhTwizd74rviyjiaYH0bd27Gbwk9+Kf/fC12ylW89mwh0Iw7IUwS+U bT5rpKb/SFa4OhICVcNjhIuB8XGsHqsxetYGh5nKMVHthzSqa+nD2s5B87gj4SoCuI/c rodYqsKu+wC/b6IjUtB0SYOZes3mVV24kygsTfQyZoTCE8AGlg+lfWjL6hsReVBLhlBY PVA0EdXhHEPapPvHfLZKPLudivXpfyAJm7EcT5wBRgMQigq6QzhH14nxuDE6H7XVqTbW HGVJEDxvdWSuscaSCP5MoN2Zdj9Q93Q0M+/8r4mu8z9URPTf5C7nGgOzjTjSdwfEUXTe EAGw== X-Gm-Message-State: AO0yUKU1W4ClDVgwxIkvxnUBXYFPKy2dvKhLCL0klUTxr4tjVEb51ob+ ziX9V0+c/BKzcW0NRaDXwG3b X-Received: by 2002:a17:902:d583:b0:19e:8264:5623 with SMTP id k3-20020a170902d58300b0019e82645623mr15839218plh.64.1678202075318; Tue, 07 Mar 2023 07:14:35 -0800 (PST) Received: from localhost.localdomain ([59.97.52.140]) by smtp.gmail.com with ESMTPSA id t8-20020a17090340c800b0019c2cf12d15sm8549332pld.116.2023.03.07.07.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 07:14:34 -0800 (PST) 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 v2 3/7] PCI: endpoint: Add linkdown notifier support Date: Tue, 7 Mar 2023 20:44:12 +0530 Message-Id: <20230307151416.176595-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230307151416.176595-1-manivannan.sadhasivam@linaro.org> References: <20230307151416.176595-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=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?1759723851679756668?= X-GMAIL-MSGID: =?utf-8?q?1759723851679756668?= Add support to notify the EPF device about the linkdown event from the EPC device. 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 9440d9811eea..e3a6b5554c1c 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); }; /**