Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16219254rwd; Mon, 26 Jun 2023 07:16:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7F4NeBaBrA917vdo3JLhe55wF69kvV3UiZFmWKFOeceY7RdZflmqfoP0ypa774GMfHMU6x X-Received: by 2002:a05:6a00:1804:b0:667:e17e:85bc with SMTP id y4-20020a056a00180400b00667e17e85bcmr35722990pfa.0.1687788998150; Mon, 26 Jun 2023 07:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687788998; cv=none; d=google.com; s=arc-20160816; b=PYXo/i+wNAIYspgwl0KrrRo1KUwAao4crF1PbjUq5mwTb23hXDRcL/ZXYjoQBYit9Q 4nZtDJVjzskFYuZPaVF+KZuNziyDaZoYQwGl/HhiMKirGMpc12uoBo4IKqBQpjih37/v nuaFLNjvlumPaStUheKZ4L552APhnJYbuj366fANXibnYB2JboL8HfOm1uPogc+qK2Ot 9hM4BBddNV9uFezYefwBwRf/HC7DDVxIVC+P2v+xfY3TlGm7L77L2nU6IhNjm6mwsj2w 2VE9nIl/3U0xlHvEyKFynB1V7foKZqDtQpDxHhfAjK7xVAlmfoKRm6hU9LcOy5bv8VHZ xVkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=6+8OkCZArvWYY6PhcQbzx178eTb3rVs046GAiayFmOU=; fh=qvh1ilU/ZPCoVnWitROpUQiGtFTkBR5Gun43FcJj5yA=; b=m425DQAHI/XILw/e+1ggKA/mccdZJgscGhtCakXckkq0KbZXYMhGpYmd+alAi5bbXS CwhU+qRtX0ROMn5eLRNOhLwIinVwPdYAZiETLQl0tM7fBXz/QfgClKWiFGYYC+0KdULv ZdYqiuqCkiZRtOpQiHAmkuvnxrFYS6fHRwXorTL+owU7ux/EX4NlWLjO0+El2Y9zU971 JThfSIJtGzONnzs1J07HnlTnNRSpKo1rdUdI4K8OZyIWGVq+8teY/QtU4XoG1UkURUBh 0OmnwK4QLctKgos7CKty00BgUUAVKUtr4sJAsNZjUNES1Rtz8UBZsOeky/AcCH7NFYwG 4afw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Uv2zscYY; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t4-20020a63f344000000b005579aeca72asi4051686pgj.457.2023.06.26.07.16.24; Mon, 26 Jun 2023 07:16:38 -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=Uv2zscYY; 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 S230156AbjFZNtH (ORCPT + 99 others); Mon, 26 Jun 2023 09:49:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjFZNtF (ORCPT ); Mon, 26 Jun 2023 09:49:05 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE30C97; Mon, 26 Jun 2023 06:49:04 -0700 (PDT) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35QDj0DM002113; Mon, 26 Jun 2023 13:48:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=6+8OkCZArvWYY6PhcQbzx178eTb3rVs046GAiayFmOU=; b=Uv2zscYYo9wfGgq89yDjx56OjQB+Hd7H1njVHbIwCEzWMw0aesNn4wiU0amJWeGBhCYA GYlgOjv5uRZ4LkoS7ZOBn10mytRiNvzjkSUP+UvEva+n+mw0xaM5vhVw9r71sE5j+37p AZrZBplYrF+0Wo1TbS+/tdidEHQbbPO3WrRmrPbJVmaVObICvw5QxqGaVcSJmXYGLaul 9tKrMIRbSOeOoexHEbQntfgEieDiKLjUI30Ho8l0gAU1t/UoGYKD4La0U31YVFcybBg2 9yz9I3oeiTccONz4LpvEw+XB5QjObbFvkXNz8fVVRTcvGPt1LCeGWhrlSMFQMJ60F62Q MQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rfarq85km-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jun 2023 13:48:58 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35QDmv1n032139 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Jun 2023 13:48:57 GMT Received: from [10.216.43.155] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Mon, 26 Jun 2023 06:48:53 -0700 Message-ID: <1b41ba64-51e2-7c66-104d-bc60ac131a0f@quicinc.com> Date: Mon, 26 Jun 2023 19:18:49 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH RFC v1 3/3] PCI: qcom: ep: Add wake up host op to dw_pcie_ep_ops Content-Language: en-US To: Manivannan Sadhasivam CC: , , , , , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Rob Herring , Bjorn Helgaas , "open list:PCIE ENDPOINT DRIVER FOR QUALCOMM" , open list References: <1686754850-29817-1-git-send-email-quic_krichai@quicinc.com> <1686754850-29817-4-git-send-email-quic_krichai@quicinc.com> <20230623061839.GC5611@thinkpad> From: Krishna Chaitanya Chundru In-Reply-To: <20230623061839.GC5611@thinkpad> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: cN8LgCwLLlNyvNwXqGPg8g7u7iu9bXxj X-Proofpoint-GUID: cN8LgCwLLlNyvNwXqGPg8g7u7iu9bXxj 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-26_11,2023-06-26_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306260123 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 6/23/2023 11:48 AM, Manivannan Sadhasivam wrote: > On Wed, Jun 14, 2023 at 08:30:49PM +0530, Krishna chaitanya chundru wrote: >> Add wakeup host op to dw_pcie_ep_ops to wake up host from D3cold >> or D3hot. >> > Commit message should describe how the wakeup is implemented in the driver. I will correct this in next series. > >> Signed-off-by: Krishna chaitanya chundru >> --- >> drivers/pci/controller/dwc/pcie-qcom-ep.c | 34 +++++++++++++++++++++++++++++++ >> 1 file changed, 34 insertions(+) >> >> diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c >> index 5d146ec..916a138 100644 >> --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c >> +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c >> @@ -91,6 +91,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 */ >> @@ -794,10 +795,43 @@ 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) >> +{ >> + 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 perst, dstate, val; >> + >> + perst = gpiod_get_value(pcie_ep->reset); >> + /* Toggle wake GPIO when device is in D3 cold */ >> + if (perst) { >> + dev_info(dev, "Device is in D3 cold toggling wake\n"); > dev_dbg(). "Waking up the host by toggling WAKE#" > >> + gpiod_set_value_cansleep(pcie_ep->wake, 1); > Waking a device from D3cold requires power-on sequence by the host and in the > presence of Vaux, the EPF should be prepared for that. In that case, the mode of > wakeup should be decided by the EPF driver. So the wakeup API should have an > argument to decide whether the wakeup is through PME or sideband WAKE#. > > Also note that as per PCIe Spec 3.0, the devices can support PME generation from > D3cold provided that the Vaux is supplied to the device. I do not know if that > is supported by Qcom devices but API should honor the spec. So the wakeup > control should come from EPF driver as I suggested above. I aggre with you, but how will EPF know the PCI device state is in D3cold or D3hot. And how the EPF knows whether Vaux is supported or not in D3cold? If there is any existing mechanism can you please point me that. FYI Qcom does not support vaux power in D3 cold. >> + usleep_range(WAKE_DELAY_US, WAKE_DELAY_US + 500); >> + gpiod_set_value_cansleep(pcie_ep->wake, 0); >> + return 0; >> + } >> + >> + dstate = dw_pcie_readl_dbi(pci, DBI_CON_STATUS) & >> + DBI_CON_STATUS_POWER_STATE_MASK; >> + if (dstate == 3) { >> + dev_info(dev, "Device is in D3 hot sending inband PME\n"); > dev_dbg(). As I said, the device can sent PME from D3cold also. So the log could > be "Waking up the host using PME". > >> + 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 -EPERM; > -ENOTSUPP > > - Mani > >> + } >> + >> + 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) >> -- >> 2.7.4 >>