From patchwork Fri Jun 30 10:52:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna chaitanya chundru X-Patchwork-Id: 114687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10282389vqr; Fri, 30 Jun 2023 04:25:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5deM0EqOOned67KVhawtFhU4SM/3oKdl8lrRXZ7m/AFFqUkVjpSrfSzgPNUKWDhxiololV X-Received: by 2002:a17:902:cecb:b0:1b7:dfbd:4dd3 with SMTP id d11-20020a170902cecb00b001b7dfbd4dd3mr10936833plg.9.1688124354145; Fri, 30 Jun 2023 04:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688124354; cv=none; d=google.com; s=arc-20160816; b=mmkY6aLijSAnw/mPLReBuFuN+BWncHhU9Vv7c3rzXuSjcxOcwxCX4MWkhoH4iJrQ2M ft3CnvHi09JjhhTOLjdsnr4FX+PVQa1POv9ot7f1sae0lfFOh+VldMR2wDIlxJBjtO2W bgnx4cqMHKbEBhNox8BH/NfyCzJgMNiHwqJwinHDzBisvhSdWMoWJE36jmcc/3DD3bVg 1gE7DgALQtXEp35aL6hPDTseuWHOsH9xWTedWLWboWI7/ezOcV5XQBosHVie/N9ukR2K yir+x/7DEwVVGwXKPLLwGY8n1fmKVGugyB7gqXCuMRyXi/PVEd28j2ascurd3Y42+P1u p55A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=qSBCqNr7HThrO5qc+qjL+xE0BVneevTd9s/gLlHxryg=; fh=YzUQilZnDF2FepjsIytqaikrwPfLwZwyJvTItUsxXE4=; b=kcEy3TwTZf6DxUR8MqRgFLQrGmKecmz8+sU2t5J8p1M8SUu4xnPPs+oVbgk2GDZCT+ VrcAx4olFHF/i/Li22lhZy8iaGh1UzdlCZ7WkP+E3YGuMCUGa4ybSVgHeqTZ6dVMQG+Y mrwaBK3R9LnHnBUPWNQF+FDnjg17sMDdEYB9MErTTxObmXCVonnGhybhNnDvOQ3x5+g+ 2SbppPiULAaDpyULwRa7HJh4Rjc9b0jRt7mp51uC2ymTW1CsqSPrKswkMcWs1D3ngKhh oAOgK7x9k+5z1FUmj8QbuLKh9ZS2d25F0XFv8JaaZZDuuLhjTeqqGWcf5IgmNrkaIjyG e+ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=euhuaAwb; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020a170902cecf00b001b86dd825f0si1351440plg.155.2023.06.30.04.25.39; Fri, 30 Jun 2023 04:25:54 -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=@quicinc.com header.s=qcppdkim1 header.b=euhuaAwb; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232590AbjF3KxF (ORCPT + 99 others); Fri, 30 Jun 2023 06:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbjF3Kw5 (ORCPT ); Fri, 30 Jun 2023 06:52:57 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0E40358A; Fri, 30 Jun 2023 03:52:56 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35UAMUMk021002; Fri, 30 Jun 2023 10:52:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=qSBCqNr7HThrO5qc+qjL+xE0BVneevTd9s/gLlHxryg=; b=euhuaAwbByL1i4WX75FucNX1MhNhLRQmcg1CIjKuKkefKGmyNJTH3JBX6UcXqXy68qQu 52xY1LUvmr8xtLOETNyL+l6DsOkVXqI12cp5PA63/rM+CsK6ZDna5HKcbFGY0EoH5n0I 2a3Dp5hPF2Ks3OagLdXHr8JpATU7Fj0sJqvMthw4n0uK/hTTOrJGPXv+Ke8uiA8u4yOg ygt3rMLsFxbZ0hqGrLqhP8fX04WMFZV0xdX9fWB6PnWWbMAMyc8Z/1YM0GkFVRluqQ39 vSSZENh6upHd1/74KljiLxAxOckyxTQPEJUYyQjUJr/eJwXyQaGGpqH93m15uVZgJdCt iQ== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rhgpgsfsv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:48 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqD3C004632; Fri, 30 Jun 2023 10:52:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:13 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqD8I004615; Fri, 30 Jun 2023 10:52:13 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqCKw004608; Fri, 30 Jun 2023 10:52:13 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id 6572F4AC1; Fri, 30 Jun 2023 16:22:12 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas , Jonathan Corbet , linux-doc@vger.kernel.org (open list:DOCUMENTATION) Subject: [PATCH v2 1/8] PCI: endpoint: Add dstate change notifier support Date: Fri, 30 Jun 2023 16:22:04 +0530 Message-Id: <1688122331-25478-2-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: m1pEml9JmOHLsp6VdZM8Vr4ehwpZcudg X-Proofpoint-ORIG-GUID: m1pEml9JmOHLsp6VdZM8Vr4ehwpZcudg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=830 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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?1770126683151474013?= X-GMAIL-MSGID: =?utf-8?q?1770126683151474013?= Add support to notify the EPF device about the D-state change event from the EPC device. Signed-off-by: Krishna chaitanya chundru --- Documentation/PCI/endpoint/pci-endpoint.rst | 5 +++++ drivers/pci/endpoint/pci-epc-core.c | 27 +++++++++++++++++++++++++++ include/linux/pci-epc.h | 1 + include/linux/pci-epf.h | 1 + 4 files changed, 34 insertions(+) diff --git a/Documentation/PCI/endpoint/pci-endpoint.rst b/Documentation/PCI/endpoint/pci-endpoint.rst index 4f5622a..0538cdc 100644 --- a/Documentation/PCI/endpoint/pci-endpoint.rst +++ b/Documentation/PCI/endpoint/pci-endpoint.rst @@ -78,6 +78,11 @@ by the PCI controller driver. Cleanup the pci_epc_mem structure allocated during pci_epc_mem_init(). +* pci_epc_dstate_change() + + In order to notify all the function devices that the EPC device has + changed its D-state. + EPC APIs for the PCI Endpoint Function Driver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 6c54fa5..cad360f 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -785,6 +785,33 @@ void pci_epc_bme_notify(struct pci_epc *epc) EXPORT_SYMBOL_GPL(pci_epc_bme_notify); /** + * pci_epc_dstate_change() - Notify the EPF device that EPC device D-state + * has changed + * @epc: the EPC device which has change in D-state + * @state: the changed D-state + * + * Invoke to Notify the EPF device that the EPC device has D-state has + * changed. + */ +void pci_epc_dstate_change(struct pci_epc *epc, pci_power_t state) +{ + 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->dstate_change) + epf->event_ops->dstate_change(epf, state); + mutex_unlock(&epf->lock); + } + mutex_unlock(&epc->list_lock); +} +EXPORT_SYMBOL_GPL(pci_epc_dstate_change); + +/** * 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 5cb6940..26a1108 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -251,4 +251,5 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc, phys_addr_t *phys_addr, size_t size); void pci_epc_mem_free_addr(struct pci_epc *epc, phys_addr_t phys_addr, void __iomem *virt_addr, size_t size); +void pci_epc_dstate_change(struct pci_epc *epc, pci_power_t state); #endif /* __LINUX_PCI_EPC_H */ diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 4b52807..1d3c2a2 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -79,6 +79,7 @@ struct pci_epc_event_ops { int (*link_up)(struct pci_epf *epf); int (*link_down)(struct pci_epf *epf); int (*bme)(struct pci_epf *epf); + int (*dstate_change)(struct pci_epf *epf, pci_power_t state); }; /** From patchwork Fri Jun 30 10:52:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna chaitanya chundru X-Patchwork-Id: 114677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10269073vqr; Fri, 30 Jun 2023 04:04:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlHvNAQM4IupdDtpgW5BNWh0N9rfAvDW7fRwU0Zw9cvhZiccQIUidZnyqJYaczfHSGSWHsmp X-Received: by 2002:a05:6a00:189f:b0:675:ef91:7922 with SMTP id x31-20020a056a00189f00b00675ef917922mr2971219pfh.4.1688123070370; Fri, 30 Jun 2023 04:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688123070; cv=none; d=google.com; s=arc-20160816; b=EceQ4QfjjeZXLY3ykaJuneuXgLdzxZkF8b6/sSUeyqse5pI8VQI+O7OARATOH2+SuD vdad40LdRIoqFViBFzNGDsxS1fUlwVpJmS7eaG+HuJ0IRwOq8mjcnomi1czIWthiZuI7 EoALHTzz2i4rAJPpditOm9BazsdDkT9vSxhoOrj+ee1oYFmsW2MLxTp984vqxf7L+uKP S11j293RpE+nAMZdNRR2g7DHOZtjg1Kuz21ZjjdvSEIh5LdXAh09nVK6hgBTHEOlR7JR tjJ+mqS362gP3Ks84uhX0bC4yCph4Wxb13cyH45egAWJ0/Ye99evALmWKP3v4y8oqHvw 3PCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=fnIhTCp+MlvMAwkxciT/Qbgxin4Zzhi8x3rzJuJvxXg=; fh=rZg3lIvN0abm+bcKRxTVDozxw/bYHp1ZLDp2JcSIm88=; b=DCZ8wM4GU9IckPUNOQ188INbMMCNMXveKTYEhOEL0IyVMlsUvAH4MT0QsjdZssBU6K OkgqDf1acNkobMq8ywVsqZ1M4eod9zsuKBZzk/F4Ll6Et8GtSRjSAQ36Tje1nkfc/BpG lXZtuKSd7jMyz2Mf/Sbpmg0jphdWoOhMhVoWCVlraD66roDKApdO7Hd8W3cx3Dlfx9Im 1oVgUsm1LSeMFmCgWtPjnYiwsLpwu5aBWLm1A2JmbBPN4UyDd2dVArNoGm+MwX6QkRhX rZEIKh96gy59nK3PQV0lXRB5WkV9IfIXtJsl/mco2V8Z+08dTj0l7+/IHYRtvwWmlKDn xMog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZOtVHruu; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020aa7958b000000b0068269b1ebcbsi171961pfj.394.2023.06.30.04.04.15; Fri, 30 Jun 2023 04:04:30 -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=@quicinc.com header.s=qcppdkim1 header.b=ZOtVHruu; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232301AbjF3Kwe (ORCPT + 99 others); Fri, 30 Jun 2023 06:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232267AbjF3Kw2 (ORCPT ); Fri, 30 Jun 2023 06:52:28 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7F8E2D56; Fri, 30 Jun 2023 03:52:25 -0700 (PDT) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35U8b8Fl032143; Fri, 30 Jun 2023 10:52:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=fnIhTCp+MlvMAwkxciT/Qbgxin4Zzhi8x3rzJuJvxXg=; b=ZOtVHruumekKQmxP0dR/i64+a6CL1wUvyFmuK/WIVLdJ3tviGFvtEqDFxyyPOkAzS+DQ ntQ/fnUh/zixKRb2L6rKSxrqlMq685ipJ4MH5Kes1q602LDyxxCVxZruM/Ll5OmYXasI o4grDS6L//+iOLMypFXWcuc+3Cc/wUFd7Q6jYZ8LMM2hVse77691OJ/z0lEUG1LO9Oi8 tFfetbO3onsMnqw1RhRe1mJLNTDJwUhPT0nBqjuQhJxpBm+bImyDeJ5Sgrt/TJaBFEfv UuovxC0hdNl2gBNSS3h1Yew0CdDC03LbPhIi5QIuA55ZmGlhLGkLb4QxCpZ49Q6ZVcZG EA== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rh7s2tsee-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:17 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqDK0004625; Fri, 30 Jun 2023 10:52:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:13 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqDA1004618; Fri, 30 Jun 2023 10:52:13 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqCND004609; Fri, 30 Jun 2023 10:52:13 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id 9582E4AC3; Fri, 30 Jun 2023 16:22:12 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Subject: [PATCH v2 2/8] PCI: qcom-ep: Add support for D-state change notification Date: Fri, 30 Jun 2023 16:22:05 +0530 Message-Id: <1688122331-25478-3-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: csYUlFRARr1i_fKnLHIs8lTJRR9WcS2A X-Proofpoint-ORIG-GUID: csYUlFRARr1i_fKnLHIs8lTJRR9WcS2A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=924 impostorscore=0 mlxscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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?1770125336384138989?= X-GMAIL-MSGID: =?utf-8?q?1770125336384138989?= Add support to pass D-state change notification to Endpoint function driver. Signed-off-by: Krishna chaitanya chundru --- drivers/pci/controller/dwc/pcie-qcom-ep.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c index 1435f51..e75aec4 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -561,6 +561,7 @@ static irqreturn_t qcom_pcie_ep_global_irq_thread(int irq, void *data) struct device *dev = pci->dev; u32 status = readl_relaxed(pcie_ep->parf + PARF_INT_ALL_STATUS); u32 mask = readl_relaxed(pcie_ep->parf + PARF_INT_ALL_MASK); + pci_power_t state; u32 dstate, val; writel_relaxed(status, pcie_ep->parf + PARF_INT_ALL_CLEAR); @@ -583,11 +584,16 @@ static irqreturn_t qcom_pcie_ep_global_irq_thread(int irq, void *data) dstate = dw_pcie_readl_dbi(pci, DBI_CON_STATUS) & DBI_CON_STATUS_POWER_STATE_MASK; dev_dbg(dev, "Received D%d state event\n", dstate); + state = dstate; if (dstate == 3) { val = readl_relaxed(pcie_ep->parf + PARF_PM_CTRL); val |= PARF_PM_CTRL_REQ_EXIT_L1; writel_relaxed(val, pcie_ep->parf + PARF_PM_CTRL); + state = PCI_D3hot; + if (gpiod_get_value(pcie_ep->reset)) + state = PCI_D3cold; } + pci_epc_dstate_change(pci->ep.epc, state); } else if (FIELD_GET(PARF_INT_ALL_LINK_UP, status)) { dev_dbg(dev, "Received Linkup event. Enumeration complete!\n"); dw_pcie_ep_linkup(&pci->ep); From patchwork Fri Jun 30 10:52:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna chaitanya chundru X-Patchwork-Id: 114674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10268020vqr; Fri, 30 Jun 2023 04:03:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlH1GgLvxKRsd1klODKmztp4G9XwZ3VlZjN0x2AkPrEqjyPfH4m7vA9VilI7+ZXDMBEIyrn+ X-Received: by 2002:a05:6871:285:b0:1b0:1b2b:7e0b with SMTP id i5-20020a056871028500b001b01b2b7e0bmr3162181oae.30.1688122993915; Fri, 30 Jun 2023 04:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688122993; cv=none; d=google.com; s=arc-20160816; b=PMms5bJlyukJcJsYRZMu27rIoqIeA8NJZEp5sN2NFrCw7Gu69EyHPL771jpwWIahfI lhTWRHLoU8QVOJBldbB5Zbv3TbDKdMJnUK4FCC5N4LrJlt+D1mPxjNBK3YPSd3IFy8Ix 6z6XkCFoDudYrfkKq9QOz6SVSMAzGD09a3WEIYQZE6mVCoV284m6Gok+P2o170xLB3Be xQVwBOfKZpRIkwVeCIksuVcfXZ5zITr61b0gzeK5+q+mfjkkCV3u4XG9OYU/rhYHzcdy dNoBKaExZqDbrY3uGiowNtAoxjt6canWboOH/MAJxll0owiBJnEBH68dD3AYGbB+rSn4 e9Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ObrpDR83B5T8R4MOPeTiDctjyi9fARr5Vy/kSmnAfvg=; fh=4i/B3x3le/AfVlLWsD1+Ff1S96/Wq0aAZ83+KG3/gJI=; b=eWlf19rilLJ7q/t0QZYrPMWrI+UbRcDtjR2Dy00Jj+qSVVUxTaILNg7EbVvBXhAreL uEgX/GdoGK5DH4Ahcgs/AW7IgWT2UOlpqSh6YJL1hz8efWKrbMbJ/XRKdOF2gUlhsKn9 wL9qqiB2TtVL0n7Nakha8tgbJxC7rTqzpBkazipCwxfwjskbvOkXjtMHeME98Ra3dQYz tdFQ5aGvTpg0UjjMkIAqP+UL9dOv/jlKwnFlvWnAfu+WfYlxgUNS+rb7w2C8WoY/6H1i Upjdt02yQhzULsGMKHv37s82siyd+GYi1I/p1RpU3FXDLYVKga+l+UPRF7af25ZVpnkT x02A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ooW2HMSW; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n127-20020a632785000000b00543ef0f981asi12623827pgn.631.2023.06.30.04.02.59; Fri, 30 Jun 2023 04:03:13 -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=@quicinc.com header.s=qcppdkim1 header.b=ooW2HMSW; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbjF3Kw5 (ORCPT + 99 others); Fri, 30 Jun 2023 06:52:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232486AbjF3Kwj (ORCPT ); Fri, 30 Jun 2023 06:52:39 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94F302D56; Fri, 30 Jun 2023 03:52:38 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35UAgGb0031013; Fri, 30 Jun 2023 10:52:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=ObrpDR83B5T8R4MOPeTiDctjyi9fARr5Vy/kSmnAfvg=; b=ooW2HMSWu6YVUNtL+kWOpr2ar376XDZRjK+WjwW2eWnAvEk2RMNbLoe0Yyd+0YEMQeJH kLFAyClNxyJuX7qoj75ak1AVVmdhBH3u3GdxhSGb+fMwAu7tkxpOlrVhtXMHufuE8NH2 MqNaXmQ+mq7ZiKKCg4G2vM/ylxJx7YKmpOdhYKQKy/sP8v0XF9SuNGddZdlz8Vosj1H8 CkDM3wQTMITo5MtVOnfufqFSBoTDuf7sR9PNn0/JJFBSRTA2tsFmx3NsTUUUO/m0QA+T yc4wki29GNCHy5pe6M5cUkap7l+QTqCmYJ9Mg+yJKqU3TAbXB2Auv+q/qUhdsvz3iyOA Uw== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rhsycrgcm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:27 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqG0E004719; Fri, 30 Jun 2023 10:52:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf27-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:16 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqGkG004712; Fri, 30 Jun 2023 10:52:16 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqGd5004711; Fri, 30 Jun 2023 10:52:16 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id 8D4984ABD; Fri, 30 Jun 2023 16:22:15 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Jeffrey Hugo , mhi@lists.linux.dev (open list:MHI BUS) Subject: [PATCH v2 3/8] PCI: epf-mhi: Add dtate change op Date: Fri, 30 Jun 2023 16:22:06 +0530 Message-Id: <1688122331-25478-4-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: qQ40MSSsWiwx5_hluyyQV80aWTNa3Fzv X-Proofpoint-GUID: qQ40MSSsWiwx5_hluyyQV80aWTNa3Fzv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=650 impostorscore=0 priorityscore=1501 spamscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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?1770125256264078319?= X-GMAIL-MSGID: =?utf-8?q?1770125256264078319?= Add dstate host op for MHI EPF. Signed-off-by: Krishna chaitanya chundru --- drivers/pci/endpoint/functions/pci-epf-mhi.c | 13 +++++++++++++ include/linux/mhi_ep.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c index 9c1f5a1..64ff37d 100644 --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c @@ -339,6 +339,18 @@ static int pci_epf_mhi_bme(struct pci_epf *epf) return 0; } +static int pci_epf_mhi_dstate_change(struct pci_epf *epf, pci_power_t state) +{ + struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf); + struct mhi_ep_cntrl *mhi_cntrl = &epf_mhi->mhi_cntrl; + struct device *dev = &epf->dev; + + mhi_cntrl->dstate = state; + dev_info(dev, "D-state changeg to %s\n", pci_power_name(state)); + + return 0; +} + static int pci_epf_mhi_bind(struct pci_epf *epf) { struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf); @@ -394,6 +406,7 @@ static struct pci_epc_event_ops pci_epf_mhi_event_ops = { .link_up = pci_epf_mhi_link_up, .link_down = pci_epf_mhi_link_down, .bme = pci_epf_mhi_bme, + .dstate_change = pci_epf_mhi_dstate_change, }; static int pci_epf_mhi_probe(struct pci_epf *epf, diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h index f198a8a..c3a0685 100644 --- a/include/linux/mhi_ep.h +++ b/include/linux/mhi_ep.h @@ -8,6 +8,7 @@ #include #include +#include #define MHI_EP_DEFAULT_MTU 0x8000 @@ -139,6 +140,8 @@ struct mhi_ep_cntrl { enum mhi_state mhi_state; + pci_power_t dstate; + u32 max_chan; u32 mru; u32 event_rings; From patchwork Fri Jun 30 10:52:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna chaitanya chundru X-Patchwork-Id: 114671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10264907vqr; Fri, 30 Jun 2023 03:58:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlEkizEwTnJFo31Vzb/FThxWt70G9KLdxm1bgvZxshF9JSzrX4rfSTG8DE8UzLZzqc80ExK+ X-Received: by 2002:a05:620a:1787:b0:765:39a0:f402 with SMTP id ay7-20020a05620a178700b0076539a0f402mr2129395qkb.71.1688122732209; Fri, 30 Jun 2023 03:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688122732; cv=none; d=google.com; s=arc-20160816; b=jsFPpu3NROsrFW6y8lhED40HcPL+N0/Lw95CRVDCsO2foqXBpXae4U8ec0GhyLs3Nw eBf8KLwOHva7R/GBxB7smiq+4/Sa6kcRjwzqdd6BSLCOuTxftOj3PO8LaDOLNXaHH1gB N8m9hjkRK47UzgZhFou3BhAfgQ3Ty9cSm6L7UZxzOGfWKntlqNjxIETRNaCFi+lMwlN7 fZBA2At219f7UoRmTqPoDVWP56qcJCzrzJAjmHno9KJlXKl5fCyM75swYBetSeqS3cf1 2aapk8crTzEzRZ6h+l7URuSpnX13O0uIdSscnNwjYR6jufDmMxkWYu+XJlguECdVqRQV GX9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=C/tWvUhyoGZ9KG+p19ulVMp5oPF6w56GtV4iQykrBow=; fh=YzUQilZnDF2FepjsIytqaikrwPfLwZwyJvTItUsxXE4=; b=Op95YvQUXKiLS706ahv+WMuaPLAe/wbY3pktOyWMLuQdLlb14fFkiZJ+9ap+hK0jqy L5rBvuJr+aNvtDaK6zT7BDlEgADv9O8pUfGpu5NXlqRfpAVp7vcGcyOAklDrxpF5txUC ZOStqYZzFN1/79DpdQHrOdqJ/ZOh6rn6xRM47rkfZ9+qTQbTXEKaYWwgsb+akna90mjc v0eOkZ+w/t29FEM7hNdUl+CohUMigR+cS1WS7INoOV2A1iGeveEDbrGsSwBlkubB3NG8 moJQYwuK4qcZit+Y1bU+L4NHKtYo6H3Wmw8lShGD0aklEMFOeWBmSC73edTLDb1Eng0/ Dgyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=gEndRCtv; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br12-20020a056a00440c00b0063b8a054e06si10885587pfb.259.2023.06.30.03.58.37; Fri, 30 Jun 2023 03:58:52 -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=@quicinc.com header.s=qcppdkim1 header.b=gEndRCtv; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232460AbjF3Kwh (ORCPT + 99 others); Fri, 30 Jun 2023 06:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232345AbjF3Kwa (ORCPT ); Fri, 30 Jun 2023 06:52:30 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73703358A; Fri, 30 Jun 2023 03:52:29 -0700 (PDT) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35U7JUBC019147; Fri, 30 Jun 2023 10:52:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=C/tWvUhyoGZ9KG+p19ulVMp5oPF6w56GtV4iQykrBow=; b=gEndRCtvmMgoES9NAKc6pzj0UMvP005yPV2aaDPmgaDpun9GGr86S+bgqdkSu2mTD2JA YBVT2S2CzpL4z23D63jEBF0Zp37Joem77nYEYDyv4o2eA5DH8yRqPFu5tjFs6TzV6X+7 IeYxjOIjlY3AqGO83AZsMgKxcUlaGHKhNrIbt1iBk4NlUR+mjS66/pVRRqBErvq3lOOY /2r4A3n3iNnZuQ2405UzyN0mqwZpteSA8OlBVH+daJaIFZoKYaCBJ8hqn0VF+onyNba+ dYC6T9F7FDimboM+U65bTbkLQnXGOIg1Ks4D8BGbw/z6/9qZ1BZADBktV8Lg6gf6mYiO Rw== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rh7s2tsef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:20 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqHwb004735; Fri, 30 Jun 2023 10:52:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:17 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqGiX004720; Fri, 30 Jun 2023 10:52:16 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqGc3004717; Fri, 30 Jun 2023 10:52:16 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id EB8604AC1; Fri, 30 Jun 2023 16:22:15 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas , Jonathan Corbet , linux-doc@vger.kernel.org (open list:DOCUMENTATION) Subject: [PATCH v2 4/8] PCI: endpoint: Add wakeup host API to EPC core Date: Fri, 30 Jun 2023 16:22:07 +0530 Message-Id: <1688122331-25478-5-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: fEjr_cOgbfJpMWMKOKE5EZMP-Ob0-iTE X-Proofpoint-ORIG-GUID: fEjr_cOgbfJpMWMKOKE5EZMP-Ob0-iTE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=710 impostorscore=0 mlxscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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?1770124981941891877?= X-GMAIL-MSGID: =?utf-8?q?1770124981941891877?= Endpoint cannot send any data/MSI when the D-state is in D3cold or D3hot. Endpoint needs to bring the host back to D0 to send any kind of data. Endpoint can toggle wake signal when the D-state is in D3cold and vaux is not supplied or can send inband PME. To support this adding wake up host to epc core. Signed-off-by: Krishna chaitanya chundru --- Documentation/PCI/endpoint/pci-endpoint.rst | 6 ++++++ drivers/pci/endpoint/pci-epc-core.c | 31 +++++++++++++++++++++++++++++ include/linux/pci-epc.h | 11 ++++++++++ 3 files changed, 48 insertions(+) diff --git a/Documentation/PCI/endpoint/pci-endpoint.rst b/Documentation/PCI/endpoint/pci-endpoint.rst index 0538cdc..186ce3b 100644 --- a/Documentation/PCI/endpoint/pci-endpoint.rst +++ b/Documentation/PCI/endpoint/pci-endpoint.rst @@ -53,6 +53,7 @@ by the PCI controller driver. * raise_irq: ops to raise a legacy, MSI or MSI-X interrupt * start: ops to start the PCI link * stop: ops to stop the PCI link + * wakeup_host: ops to wake host The PCI controller driver can then create a new EPC device by invoking devm_pci_epc_create()/pci_epc_create(). @@ -122,6 +123,11 @@ by the PCI endpoint function driver. The PCI endpoint function driver should use pci_epc_mem_free_addr() to free the memory space allocated using pci_epc_mem_alloc_addr(). +* pci_epc_wakeup_host() + + The PCI endpoint function driver should use pci_epc_wakeup_host() to wake + host. + Other EPC APIs ~~~~~~~~~~~~~~ diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index cad360f..23599b8 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -167,6 +167,37 @@ const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc, EXPORT_SYMBOL_GPL(pci_epc_get_features); /** + * pci_epc_wakeup_host() - Wakeup the host + * @epc: the EPC device which has to wake the host + * @func_no: the physical endpoint function number in the EPC device + * @vfunc_no: the virtual endpoint function number in the physical function + * @type: specify the type of wakeup: WAKEUP_FROM_D3COLD, WAKEUP_FROM_D3HOT + * + * Invoke to wakeup host + */ +int pci_epc_wakeup_host(struct pci_epc *epc, u8 func_no, u8 vfunc_no, + enum pci_epc_wakeup_host_type type) +{ + int ret; + + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) + return -EINVAL; + + if (vfunc_no > 0 && (!epc->max_vfs || vfunc_no > epc->max_vfs[func_no])) + return -EINVAL; + + if (!epc->ops->wakeup_host) + return 0; + + mutex_lock(&epc->lock); + ret = epc->ops->wakeup_host(epc, func_no, vfunc_no, type); + mutex_unlock(&epc->lock); + + return ret; +} +EXPORT_SYMBOL_GPL(pci_epc_wakeup_host); + +/** * pci_epc_stop() - stop the PCI link * @epc: the link of the EPC device that has to be stopped * diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index 26a1108..2323a10 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -26,6 +26,12 @@ enum pci_epc_irq_type { PCI_EPC_IRQ_MSIX, }; +enum pci_epc_wakeup_host_type { + PCI_WAKEUP_UNKNOWN, + PCI_WAKEUP_SEND_PME, + PCI_WAKEUP_TOGGLE_WAKE, +}; + static inline const char * pci_epc_interface_string(enum pci_epc_interface_type type) { @@ -59,6 +65,7 @@ pci_epc_interface_string(enum pci_epc_interface_type type) * @start: ops to start the PCI link * @stop: ops to stop the PCI link * @get_features: ops to get the features supported by the EPC + * @wakeup_host: ops to wakeup the host * @owner: the module owner containing the ops */ struct pci_epc_ops { @@ -88,6 +95,8 @@ struct pci_epc_ops { void (*stop)(struct pci_epc *epc); const struct pci_epc_features* (*get_features)(struct pci_epc *epc, u8 func_no, u8 vfunc_no); + int (*wakeup_host)(struct pci_epc *epc, u8 func_no, u8 vfunc_no, + enum pci_epc_wakeup_host_type type); struct module *owner; }; @@ -234,6 +243,8 @@ int pci_epc_start(struct pci_epc *epc); void pci_epc_stop(struct pci_epc *epc); const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc, u8 func_no, u8 vfunc_no); +int pci_epc_wakeup_host(struct pci_epc *epc, u8 func_no, u8 vfunc_no, + enum pci_epc_wakeup_host_type type); enum pci_barno pci_epc_get_first_free_bar(const struct pci_epc_features *epc_features); enum pci_barno pci_epc_get_next_free_bar(const struct pci_epc_features From patchwork Fri Jun 30 10:52:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna chaitanya chundru X-Patchwork-Id: 114672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10264917vqr; Fri, 30 Jun 2023 03:58:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlFrqdNfGCHB/+Uk9UXoLcLotPbCXLl95yvl/Mn4O9eTswDvjWa5Aomms9d7IkCYqgcM5WWe X-Received: by 2002:ad4:5ec7:0:b0:635:33b0:f42e with SMTP id jm7-20020ad45ec7000000b0063533b0f42emr3355751qvb.29.1688122732875; Fri, 30 Jun 2023 03:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688122732; cv=none; d=google.com; s=arc-20160816; b=vv8z3Fqz3IBYo1gKFqkCC6T1COj61Fm4jB7W6eBnaZuU0tzjPVE7y9NKHXgsVNSRiq +BE5972RxWmMb/01WX4krWpHINmx/xVRoHJ/gZSgHF/R79k2iT/bN5PnX/nEM061rVtZ Jeb9mLqcznuiJKmz2i91rzxljVR6NyJ7P9SNWLL6zbul9L1XSrxSzB8m6Kwn7LWxCM9B 1hpctTmf2xCIHhJSGOj+JqP40r7VefgMsYBmlf9hKfph7Cxl33GrEkmbG2B7UfwRpWFx 3g92iOLpMThPDmZNYepSRAMpiApH3H4cegocNqS9Q7tdD8Iv8d5DF52wwJB9uIczkqYr AKcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=yoqAwqb4UmnZXTKQ6pQCHhmtr5plOyugizSdTRJ3bcw=; fh=Etlfrqm+UytFPhRdQVRzLAi1n8Ml9moTJga3EHGV/pU=; b=eEYbkG/+xZ/nBCUZbP3h1dUr79PSBJEUDjDzojKcX2FfyQckrQgraqwy1YXerz/lvW Ob6QxYtKupwwvo548O1GqY6+by4VIJRQWG5WThL2jeWfylvoxWwD2mqBXiAOA9/646+y O6eLG/64kk3GBHBv5giejOILF5IKnjizPGu+V74+76/xfRYSxKR9oHgTtAk48UqVGvmY 1fPvmzDrH+kcLFNWgJAOqkdEjuKYz9VncFYJdY0yVBo+8dyubcZvfNV/mXjjd+qkvGqw lMJvkkprb9Q8/ZyncZTkqbS0B4JjwzT3TCpK+B7gLxGr4GMX2nkN3mw/17z1C5zgZyCs 0cmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LhHAsm7U; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f38-20020a631f26000000b00553828de1cbsi11944364pgf.791.2023.06.30.03.58.38; Fri, 30 Jun 2023 03:58:52 -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=@quicinc.com header.s=qcppdkim1 header.b=LhHAsm7U; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232403AbjF3Kwo (ORCPT + 99 others); Fri, 30 Jun 2023 06:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232298AbjF3Kwc (ORCPT ); Fri, 30 Jun 2023 06:52:32 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2315635AF; Fri, 30 Jun 2023 03:52:31 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35U5LCB1020100; Fri, 30 Jun 2023 10:52:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=yoqAwqb4UmnZXTKQ6pQCHhmtr5plOyugizSdTRJ3bcw=; b=LhHAsm7Upcxr88RExcv0ByJoESZ+EEzkHoerfAH+Tp9C0TxVFEBFYJpRg6kRX+63TUZh rWrt027QXCv1aJgVmkn/QyedKclZR0bB4BjWLCPtADuRlmr0vFR4Se4m9FUFCWn8S/1z ccA8WEmqjJ3vGdFF6ZkFc81RV0efcoYk078b5CfpCwLnErmRdeTSzgUVMXcUgG/ZdKFN qQ3dcuERA72NLPXXfBotSlw2xYvI072Hd7fnMlJzQuhKXr7OMo61+8OToNp4DZk/AX5p X03BTYZ4C20lYvYlwGm4eAiMMETyhYJCfe4un7poVrk4wZ45k9+Z/uiAUoWpZyi/XSW9 qA== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rha8e2f2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:20 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqH2N004744; Fri, 30 Jun 2023 10:52:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf2f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:17 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqHvt004730; Fri, 30 Jun 2023 10:52:17 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqGFG004718; Fri, 30 Jun 2023 10:52:16 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id 38E374AC3; Fri, 30 Jun 2023 16:22:16 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Subject: [PATCH v2 5/8] pci: dwc: Add wakeup host op to pci_epc_ops Date: Fri, 30 Jun 2023 16:22:08 +0530 Message-Id: <1688122331-25478-6-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 7-MDDinAiM0VZ2_YoaxYJyrMpMhPC4z_ X-Proofpoint-ORIG-GUID: 7-MDDinAiM0VZ2_YoaxYJyrMpMhPC4z_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=711 clxscore=1011 impostorscore=0 priorityscore=1501 spamscore=0 mlxscore=0 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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?1770124982850227188?= X-GMAIL-MSGID: =?utf-8?q?1770124982850227188?= Add wakeup host op to wake up host from D3cold or D3hot. Signed-off-by: Krishna chaitanya chundru --- drivers/pci/controller/dwc/pcie-designware-ep.c | 12 ++++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index f9182f8..7474849 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -463,6 +463,17 @@ dw_pcie_ep_get_features(struct pci_epc *epc, u8 func_no, u8 vfunc_no) return ep->ops->get_features(ep); } +static int dw_pcie_ep_wakeup_host(struct pci_epc *epc, u8 func_no, u8 vfunc_no, + enum pci_epc_wakeup_host_type type) +{ + struct dw_pcie_ep *ep = epc_get_drvdata(epc); + + if (!ep->ops->wakeup_host) + return -EINVAL; + + return ep->ops->wakeup_host(ep, func_no, type); +} + static const struct pci_epc_ops epc_ops = { .write_header = dw_pcie_ep_write_header, .set_bar = dw_pcie_ep_set_bar, @@ -477,6 +488,7 @@ static const struct pci_epc_ops epc_ops = { .start = dw_pcie_ep_start, .stop = dw_pcie_ep_stop, .get_features = dw_pcie_ep_get_features, + .wakeup_host = dw_pcie_ep_wakeup_host, }; int dw_pcie_ep_raise_legacy_irq(struct dw_pcie_ep *ep, u8 func_no) diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 6156606..79df866 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -330,6 +330,9 @@ struct dw_pcie_ep_ops { * driver. */ unsigned int (*func_conf_select)(struct dw_pcie_ep *ep, u8 func_no); + + int (*wakeup_host)(struct dw_pcie_ep *ep, u8 func_no, + enum pci_epc_wakeup_host_type type); }; struct dw_pcie_ep_func { From patchwork Fri Jun 30 10:52:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna chaitanya chundru X-Patchwork-Id: 114680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10277283vqr; Fri, 30 Jun 2023 04:16:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4n7NR05lsSPIpSLcCeCrIZ7scUYlvef+aaECd5mfvX9VdA6+tr1CO2/1UrwFm0q95goyuv X-Received: by 2002:a05:6870:cd0d:b0:1a6:c3d3:969c with SMTP id qk13-20020a056870cd0d00b001a6c3d3969cmr2995556oab.45.1688123817207; Fri, 30 Jun 2023 04:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688123817; cv=none; d=google.com; s=arc-20160816; b=RP5xclv0fL+eEADbwpBUPr774S+zPy+8eW5huFjN9Dd4O5szd6s+xkGMayiheshCOJ SG7we+rFJ02y+jENcuqGDKURaY/q7i8NczODBgu3uYsEYslA33Ampz0HLdsdc4fPWp1Y k+CjIE4D38qIqLeDiao/LmCefk8agEJrTO3+FEAe23/LpSFWlL8UFk/vaUFK7LMOL/0/ Q1/74V4govh+BmoVTzs0iN06RfAlIZNceQuQUaGa3CHLbJkAfBtyjNXvv3ihtTfOiCEB 2xwsOZDx9492wwzI3CGuB3MoAkqDceVFHerAjJCqhe4OcTQvtEx9oo/DRxT1B+IldMO2 5bQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=FEoLul4t0glUrhhThocw3Oy4jFlcsRBbeVj0cl383hs=; fh=rZg3lIvN0abm+bcKRxTVDozxw/bYHp1ZLDp2JcSIm88=; b=0ZhbzsWyc5VF5zqtIXT5VE2rB6fuWJNFEjRF0IYvY9P0E3RWIW9BSryxMz3+1JXW0F 2L7Cb7A7A1cmKuLEQqhlwIbK3KGmYYixN99x9MBHr75Vsd/nfb4ghS0p1ZBSoxWNjDpt tuYhohdVXP88m9S6bZkJw62B+snqm4RuUKVO99b2sRO0GocdRQlD0yXGwpiUyEDJ0eo2 jiGMQCTACyhes6Hiset/fwWVD66j2IAt7/k57a0YvhZjheCdmxe2OLfpUNhNppgqOAdC ebOoQyoGLhpQE4fPApslEoiAekqoiY3babPTADTBM8ioICUyvolRjL5OFsqD9deEtrUm Yxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=QHRTC8Kk; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rm10-20020a17090b3eca00b0025bf6078049si15949870pjb.5.2023.06.30.04.16.42; Fri, 30 Jun 2023 04:16:57 -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=@quicinc.com header.s=qcppdkim1 header.b=QHRTC8Kk; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232564AbjF3KxB (ORCPT + 99 others); Fri, 30 Jun 2023 06:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbjF3Kw4 (ORCPT ); Fri, 30 Jun 2023 06:52:56 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBA393A94; Fri, 30 Jun 2023 03:52:54 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35UASUXb031403; Fri, 30 Jun 2023 10:52:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=FEoLul4t0glUrhhThocw3Oy4jFlcsRBbeVj0cl383hs=; b=QHRTC8KkKq+F/aSLDlD8+XZoGLQ9C3RtElv6OqShEH1Oc9AEeTLSXUsLraUrCuDWbZwg EsTRyxvTGZpYNl62m5iaDc0mBZWkl6nIcS4AOeHYXXTLV9TDhl5zc6PZkbI+ZFwiFQOw Flbuj7WhebhLOJSqpRc4mVfzSmL4HKrWQQ2G1BmkIc8fauUuO2Z1ng0w5bm2fdNotoQq xHXPkk4mJ5ol0Du0LDvo/iFMEeq3FBfPltMRn8dqV9UqFDVQkDTW+QjJZv418n6oQhkx 01FpiIC3gy7EuD7vDMQ4PpO5fysZ0GQ/jFCshObdouxpP4OFd4xmUejMRP2BLUSx8+K/ LQ== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rhgpgsfsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:48 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqHkk004751; Fri, 30 Jun 2023 10:52:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf2j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:17 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqHqK004736; Fri, 30 Jun 2023 10:52:17 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqHQx004729; Fri, 30 Jun 2023 10:52:17 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id 6956D4AC5; Fri, 30 Jun 2023 16:22:16 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Subject: [PATCH v2 6/8] PCI: qcom: ep: Add wake up host op to dw_pcie_ep_ops Date: Fri, 30 Jun 2023 16:22:09 +0530 Message-Id: <1688122331-25478-7-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: qykhW2nVBPsJKmkygPO8NU3Y3GbJ9mRN X-Proofpoint-ORIG-GUID: qykhW2nVBPsJKmkygPO8NU3Y3GbJ9mRN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=993 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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?1770126119642104477?= X-GMAIL-MSGID: =?utf-8?q?1770126119642104477?= Add wakeup host op to dw_pcie_ep_ops to wake up host. If the EPF asks to send PME trigger the inband PME by writing into the parf registers otherwise toggle wake signal. Signed-off-by: Krishna chaitanya chundru --- drivers/pci/controller/dwc/pcie-qcom-ep.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c index e75aec4..e382b4b 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -89,6 +89,7 @@ /* PARF_PM_CTRL register fields */ #define PARF_PM_CTRL_REQ_EXIT_L1 BIT(1) #define PARF_PM_CTRL_READY_ENTR_L23 BIT(2) +#define PARF_PM_CTRL_XMT_PME BIT(4) #define PARF_PM_CTRL_REQ_NOT_ENTR_L1 BIT(5) /* PARF_MHI_CLOCK_RESET_CTRL fields */ @@ -729,10 +730,40 @@ static void qcom_pcie_ep_init(struct dw_pcie_ep *ep) dw_pcie_ep_reset_bar(pci, bar); } +static int qcom_pcie_ep_wakeup_host(struct dw_pcie_ep *ep, u8 func_no, + enum pci_epc_wakeup_host_type type) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct qcom_pcie_ep *pcie_ep = to_pcie_ep(pci); + struct device *dev = pci->dev; + u32 val; + + if (type == PCI_WAKEUP_TOGGLE_WAKE) { + dev_dbg(dev, "Waking up the host by toggling WAKE#\n"); + gpiod_set_value_cansleep(pcie_ep->wake, 1); + usleep_range(WAKE_DELAY_US, WAKE_DELAY_US + 500); + gpiod_set_value_cansleep(pcie_ep->wake, 0); + return 0; + + } else if (type == PCI_WAKEUP_SEND_PME) { + dev_dbg(dev, "Waking up the host using PME\n"); + val = readl_relaxed(pcie_ep->parf + PARF_PM_CTRL); + val |= PARF_PM_CTRL_XMT_PME; + writel_relaxed(val, pcie_ep->parf + PARF_PM_CTRL); + + } else { + dev_err(dev, "Device is not in D3 state wakeup is not supported\n"); + return -EOPNOTSUPP; + } + + return 0; +} + static const struct dw_pcie_ep_ops pci_ep_ops = { .ep_init = qcom_pcie_ep_init, .raise_irq = qcom_pcie_ep_raise_irq, .get_features = qcom_pcie_epc_get_features, + .wakeup_host = qcom_pcie_ep_wakeup_host, }; static int qcom_pcie_ep_probe(struct platform_device *pdev) From patchwork Fri Jun 30 10:52:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna chaitanya chundru X-Patchwork-Id: 114683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10278834vqr; Fri, 30 Jun 2023 04:19:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFfos7ibuK5QO/F6hCb4mJKELcv1cIDtokcKpPqJ9o7cZh0BbGHIQKG43EhNMtjZHFBP28 X-Received: by 2002:a05:6a00:1742:b0:673:6cb4:7b0c with SMTP id j2-20020a056a00174200b006736cb47b0cmr3542574pfc.2.1688123988878; Fri, 30 Jun 2023 04:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688123988; cv=none; d=google.com; s=arc-20160816; b=PdtXHTStztp1uC2NJ6u6qsLatZpmS+tY8BLGciw3wS28m1AzF45+5bOmmDU/xy+X71 ffj4SxyMz7+6AgVrENMVShwUmxcbDDoQRlxvjEpGKIMd02eCUmPJBCA6oXuaR0gqAC1X h+6eGbrkOO9UOXVm1zdEYAxAgi5e+FAA9/2VKTl8NCj2s5+++L6kVgAtQi0H55PjzTmn FnM8FjMghEiQPm3pGGuf86Yrp0+Dq4eTOb8wL1DmLXc5xjvmRFcfLt2FmHj9Oo80zQBB P6nAzn6len83FAQq99S42W2ybbsh+/vhBrudKdIPAdIzcSAHE1ujJVUSxu37uCx9ksEg ptug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=/9TEn6p7438Y8uzn2noHx4X1roGv865uNAKBLZNOBbA=; fh=4i/B3x3le/AfVlLWsD1+Ff1S96/Wq0aAZ83+KG3/gJI=; b=fCDEUBFDPPUP8LjbwTPohOiwqZ6ZmXElU/H+vMfyz66q5++ImpliDd8/qNs4CBVL7+ p4RBOnFM1DHjV7ukw/gd99O3aPl0YA1nKbpJNlG3bscJc8OSt+5A/a4Oft3jkImaYL/g JCfCPa2ZFA1WHNL8kHmRVp5nuyy5rL3lQJOazMTbL8QdH3cavMY759ClzgLN+Inx2cRO 5skGjBYiBfAzBCRiFYEbQux6tSI+Aiy/dkUl7HpY9tcu0O4RiVXkLgyjGSgWMb+AFZuw Vs4PJ8HjdYf4811EPtRG7kbjFoKMNjWpLsxoIAGW5NEbgxpGj9pbovMjcv5EplsBrmFM KmTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="SvuwT/jG"; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd35-20020a056a002ea300b006687406605asi12991458pfb.211.2023.06.30.04.19.35; Fri, 30 Jun 2023 04:19:48 -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=@quicinc.com header.s=qcppdkim1 header.b="SvuwT/jG"; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232651AbjF3KxI (ORCPT + 99 others); Fri, 30 Jun 2023 06:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232470AbjF3Kw7 (ORCPT ); Fri, 30 Jun 2023 06:52:59 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B9E9359E; Fri, 30 Jun 2023 03:52:58 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35U8dK3t011808; Fri, 30 Jun 2023 10:52:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=/9TEn6p7438Y8uzn2noHx4X1roGv865uNAKBLZNOBbA=; b=SvuwT/jGYlf3i5sbKBdH/lqOzM8VFkwa7HkV55JZQpZ7zqKntZZEBLVOdxdJbstgKsQ/ 7D+i6GlG0Q6oaracJA5IyX+bAXsVFb0GOhEqnV7Mgr4v1E5fDIU66HLtBrJ5y+4ML8Qt 2K3KkgcIpwqv6ur5x/Yf9pRIIFVgAivXWv2lI8kFKizTXjlql6NYgr9ZDv7HTCviuR0h 1uLt2eh71TjWcfevvpEdGql4kx9/kNOGhtti+QHoCzw3OmZhdfd62JuH+EGLn5y7FKTK IB3uHBBoJ2JgRFM1zOvQs7qIHgcARVIkBKRt3cNx1PRNzD21dwHpBqtN+ow3OhTWRoKg cQ== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rhgpgsft0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:48 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqK41004775; Fri, 30 Jun 2023 10:52:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:20 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqKhY004770; Fri, 30 Jun 2023 10:52:20 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqKql004767; Fri, 30 Jun 2023 10:52:20 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id 719554ABD; Fri, 30 Jun 2023 16:22:19 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Jeffrey Hugo , mhi@lists.linux.dev (open list:MHI BUS) Subject: [PATCH v2 7/8] PCI: epf-mhi: Add wakeup host op Date: Fri, 30 Jun 2023 16:22:10 +0530 Message-Id: <1688122331-25478-8-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Bo6ds8KNAH1kV3213hJH76zuCtj7L1hK X-Proofpoint-ORIG-GUID: Bo6ds8KNAH1kV3213hJH76zuCtj7L1hK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=778 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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?1770126299850340306?= X-GMAIL-MSGID: =?utf-8?q?1770126299850340306?= Add wakeup host op for MHI EPF. If the D-state is in D3cold toggle wake signal, otherwise send PME. Signed-off-by: Krishna chaitanya chundru --- drivers/pci/endpoint/functions/pci-epf-mhi.c | 19 +++++++++++++++++++ include/linux/mhi_ep.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c index 64ff37d..deb742c 100644 --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c @@ -237,6 +237,24 @@ static int pci_epf_mhi_write_to_host(struct mhi_ep_cntrl *mhi_cntrl, return 0; } +static int pci_epf_mhi_wakeup_host(struct mhi_ep_cntrl *mhi_cntrl) +{ + struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl); + struct pci_epf *epf = epf_mhi->epf; + struct pci_epc *epc = epf->epc; + int ret; + + if (mhi_cntrl->dstate == PCI_D3cold) + ret = pci_epc_wakeup_host(epc, epf->func_no, + epf->vfunc_no, PCI_WAKEUP_TOGGLE_WAKE); + else + ret = pci_epc_wakeup_host(epc, epf->func_no, + epf->vfunc_no, PCI_WAKEUP_SEND_PME); + + return ret; + +} + static int pci_epf_mhi_core_init(struct pci_epf *epf) { struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf); @@ -293,6 +311,7 @@ static int pci_epf_mhi_link_up(struct pci_epf *epf) mhi_cntrl->unmap_free = pci_epf_mhi_unmap_free; mhi_cntrl->read_from_host = pci_epf_mhi_read_from_host; mhi_cntrl->write_to_host = pci_epf_mhi_write_to_host; + mhi_cntrl->wakeup_host = pci_epf_mhi_wakeup_host; /* Register the MHI EP controller */ ret = mhi_ep_register_controller(mhi_cntrl, info->config); diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h index c3a0685..e353c429 100644 --- a/include/linux/mhi_ep.h +++ b/include/linux/mhi_ep.h @@ -137,6 +137,7 @@ struct mhi_ep_cntrl { void __iomem *virt, size_t size); int (*read_from_host)(struct mhi_ep_cntrl *mhi_cntrl, u64 from, void *to, size_t size); int (*write_to_host)(struct mhi_ep_cntrl *mhi_cntrl, void *from, u64 to, size_t size); + int (*wakeup_host)(struct mhi_ep_cntrl *mhi_cntrl); enum mhi_state mhi_state; From patchwork Fri Jun 30 10:52:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna chaitanya chundru X-Patchwork-Id: 114676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10269057vqr; Fri, 30 Jun 2023 04:04:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEItt7oV0OMzVfMI2QKKLQ7VabRk0HaPj2+oh9LD8Yxs8U1ZZG+LqftdhO6Y2KsNAaJbKPy X-Received: by 2002:a17:90a:2dca:b0:263:4157:66de with SMTP id q10-20020a17090a2dca00b00263415766demr1284127pjm.42.1688123069162; Fri, 30 Jun 2023 04:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688123069; cv=none; d=google.com; s=arc-20160816; b=L4HJ5r8hO5Y6eSNA1ms+mbT7pi657a5s4mPaacwjKeb12PyfkE7DjzUMAu5UMeT4uz OP1v4UisGkr/ymAc85leonKoNZbW299cqASNXtsHGP/LVzkJT5uMx92l7T3JRoxig9dC c7hfDqjj+E7BngqT7dIMEepQVRXa8W+IMYhcwoknqQRyTBQQ4Sk9FImImZehMeZGB6WJ QWR05qp07v9Y8zbeDTIgqROAM7sTHHu59QMFkBhZHK/kMWS8hzGxJnxeJ/8d2ENJ/G9Z yrVZjCeSfAb2CYuDv8uXsyXhEerEnOkiHSFscuN7JuXXSMbFt++B1QyVHg+ZthoMiQMI s6oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=xzLUzIL/qxaf0TvQEPU7BTfA4oHCOh5h/B0H/DxoR8w=; fh=49Z+7XosMOZ5awNi1se1hmR7wrCkRbXik7PXU9Mjh2M=; b=MJSwprQHx8SY2IUS2MKMieLYAA6ykM6ZsI4r+AUrjnmLdA8aT98f0YJ+EtyEaYGazv +6iVOaruAVl1IxvVpaNBXEeQbQXMpnZF3sYMm9epeg8DZVF2f1LxcUwy7KlLcnvme+ig WKDnxDqxqzRFhI6NgX/SlAVtiYTm9pbqAph5uBFO5saVBrbtYIXtIrhWzowXohuwm67C o2pd4n/+1WGs8WkBI6CL7fGJBgPIAIwm38VHbdxg+LSXFNv6N2ws2ziqt5aug0tBngIk +DrgSQe4vbeNt8ZVJNwvdeJSva9gwmhLQijxWbtdju/x229AcS77iW3L3YqeszhltCSC KyrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="gOh0d/bP"; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gf16-20020a17090ac7d000b00262d9b8a137si10898433pjb.98.2023.06.30.04.04.12; Fri, 30 Jun 2023 04:04:29 -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=@quicinc.com header.s=qcppdkim1 header.b="gOh0d/bP"; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbjF3Kws (ORCPT + 99 others); Fri, 30 Jun 2023 06:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232410AbjF3Kwf (ORCPT ); Fri, 30 Jun 2023 06:52:35 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4282358A; Fri, 30 Jun 2023 03:52:34 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35U9XU80014782; Fri, 30 Jun 2023 10:52:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=xzLUzIL/qxaf0TvQEPU7BTfA4oHCOh5h/B0H/DxoR8w=; b=gOh0d/bPBhSuc0oPXlgp7ncZHB5bbWz3O+2jdYXCnSb3zTd4jR0Ns1SRo0TXpsUvVdL5 uADwYzapWUgGutMvTFse0S9VR97Zox1f7EODwFz1Xy0m3OC3ndRx0YN6WDguzPTknQ4x o8hO7efmhtXh6GlYwvgj+hGZPBE4pjRT2pps64xGRqk0j6+jnwb55GZdzOkyTWfLPiW5 TWQ0kTgk3OWIMAyQhPHicMB+ad0Gcw7Ii0CutWVuMeoHcHz3oiKz6+Q/5lOvncCpu0jw acrFyS3RK2GSDF8BV3bazho2t/wgSih28KVZPMu4rJH2RnoKt7LImz0BjTmPJG+6UDkZ Ug== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rha8e2f2e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:25 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqH2O004744; Fri, 30 Jun 2023 10:52:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf31-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:22 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqMUK004786; Fri, 30 Jun 2023 10:52:22 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqLYv004781; Fri, 30 Jun 2023 10:52:22 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id 39CD14ABD; Fri, 30 Jun 2023 16:22:21 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Manivannan Sadhasivam , Jeffrey Hugo , "Rafael J. Wysocki" , Dan Carpenter , Greg Kroah-Hartman , Bo Liu , mhi@lists.linux.dev (open list:MHI BUS) Subject: [PATCH v2 8/8] bus: mhi: ep: wake up host is the MHI state is in M3 Date: Fri, 30 Jun 2023 16:22:11 +0530 Message-Id: <1688122331-25478-9-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Skcwe1DPfFGYgtTmPP72vdU1oy6Admjq X-Proofpoint-ORIG-GUID: Skcwe1DPfFGYgtTmPP72vdU1oy6Admjq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=868 clxscore=1011 impostorscore=0 priorityscore=1501 spamscore=0 mlxscore=0 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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?1770125335194379039?= X-GMAIL-MSGID: =?utf-8?q?1770125335194379039?= If the MHI state is in M3 then the most probably the host kept the device in D3 hot or D3 cold, due to that endpoint transctions will not be read by the host, so endpoint needs to bring the host to D0 which eventually bring back the MHI state to M0. Signed-off-by: Krishna chaitanya chundru --- drivers/bus/mhi/ep/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 6008818..42d3791 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -451,12 +451,14 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb) struct mhi_ep_cntrl *mhi_cntrl = mhi_dev->mhi_cntrl; struct mhi_ep_chan *mhi_chan = mhi_dev->dl_chan; struct device *dev = &mhi_chan->mhi_dev->dev; + u32 buf_left, read_offset, count = 0; struct mhi_ring_element *el; - u32 buf_left, read_offset; struct mhi_ep_ring *ring; enum mhi_ev_ccs code; + enum mhi_state state; void *read_addr; u64 write_addr; + bool mhi_reset; size_t tr_len; u32 tre_len; int ret; @@ -464,6 +466,18 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb) buf_left = skb->len; ring = &mhi_cntrl->mhi_chan[mhi_chan->chan].ring; + if (mhi_cntrl->mhi_state == MHI_STATE_M3) { + dev_dbg(dev, "wake up by ch id %x\n", mhi_chan->chan); + mhi_cntrl->wakeup_host(mhi_cntrl); + } + + /* Wait for Host to set the M0 state */ + do { + msleep(M0_WAIT_DELAY_MS); + mhi_ep_mmio_get_mhi_state(mhi_cntrl, &state, &mhi_reset); + count++; + } while (state != MHI_STATE_M0 && count < M0_WAIT_COUNT); + mutex_lock(&mhi_chan->lock); do {