Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1835136rbb; Tue, 27 Feb 2024 02:44:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCViM0dCjKpGTYOHL7vAE0PyKEfuTfuB0Icpt5JFeqOKdMCPjfEbZ8bDI8xkpffQ8dSZaEIb2rivkTsj0Y5rmAwM5fGL5VyKd2b0SGjiow== X-Google-Smtp-Source: AGHT+IHkB0QRDq/y2XZYNcOKRKgKRn5OPOXcZna+sL723pVDFvRRErVjwi2oN5XnteyJg8OR7STe X-Received: by 2002:a9d:6357:0:b0:6e4:9e38:37a7 with SMTP id y23-20020a9d6357000000b006e49e3837a7mr5424479otk.23.1709030696632; Tue, 27 Feb 2024 02:44:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709030696; cv=pass; d=google.com; s=arc-20160816; b=bz/h/nVBUK+NPgUmh8zxXP8HtT8FhOCKwKUUyGy1jvPVgtlX+tOZEW9WVxUim2G2+B CWM5eSRScKf4wbezAGjX3CA+A1u9jtxd8/9Hpn7xWDzNrumJoy3AbMoehsZ38K3EGVLz 2Qs6sYXnVFpxX9EqTsUgjdIgIrnDwIyNJeEREzk+fOuQyFHaS8oeN4XNYY+P1Zk2hpxP VVa7XV/9VJYyiPakO4Tqh78nkIafFJ2arMpk2TThxeWbZt1pmeA53xhUyBUE2zy6nQ78 aqvq/rB+HqKFZ3yWV0kGmpXp/tCSWRdebXXJpzKJ2A22bLiEMZyRy9D/qLTOU0be+kak yx0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=T3vSBlEzkaGHFGN34YgOwaijg7xlCZ270ALmHFqkhwQ=; fh=rsVYZOouDbuV6kaXcbvInovsePEmI4Nwcsa8x/LtaEc=; b=pWYQt+bKlEwNWqRVlG8dYaY9KSzkrKXfAJZZOuIUHR6OfUidKjnxdSAXal4ZFmk+bH 7URBursC5NQVNOwnekFWDJqAg67i6kSgvSnpgAxVfTL4KcOHjZJhMykhui/zrmMRkw1O 4nPPCuEqq6QifwLmdTmFxbFtA/8peW346Z3XU1jD+Y8krxIghVsDR/jL7qTslV2T06bq xAfhs81ttrGAAZnapuZY8j5Mhh+J3a9s6wPfmFTPsxWB61kt6g3bsuo6+uVjg6sTvt45 +me4+TTIXNQ1/PHg2L7LWJl09BCCBdBGK/cxhdoourWuhwYp6Gh2AkPw1v+xTjpHCGhC D8Cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IHPz64Xd; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-4069-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q82-20020a632a55000000b005dc5070656csi5243169pgq.785.2024.02.27.02.44.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 02:44:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-4069-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IHPz64Xd; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-4069-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1B4292824C1 for ; Tue, 27 Feb 2024 10:44:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 988E51386BE; Tue, 27 Feb 2024 10:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="IHPz64Xd" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1DE7138480; Tue, 27 Feb 2024 10:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709030688; cv=none; b=dqz6i0sijTMvvUc+gxReIpn0aJ66bPYD4hV9CU5TI2FxqSgYhLITUPBqX5njm1kRSGqm1AQwWv+FjIeQcJQxFXN/x9a89uKOnWHoSGV+xnqwEiD4r6J093F5yEl9f7l5C/U0FZhmzjgU/W2kP9nw87361jRv8iIP5ikX8vl9G5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709030688; c=relaxed/simple; bh=Zs0enebDVUoLgccbVVbSO5ka5/eX9KcPfYfpiafBA9g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CCeCERskwm3k56eofz8bFj95HWWmdxtfGBnU7gh3qxsIZMyEV5Q/D+HjWFSOwP7g1Hx4+4v/7iZqraFtjhU+Mx8RfzI1Cqi5U6puwWw4iVytJPjWz5IBkM63WSNIWOQMMRNprwOqJU3bV0sZdYgD031zaP/5PReOLqin7npTpjo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=IHPz64Xd; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41R9aUbu002762; Tue, 27 Feb 2024 10:44:43 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 :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=T3vSBlEzkaGHFGN34YgOwaijg7xlCZ270ALmHFqkhwQ=; b=IH Pz64Xdpcf1swqBXg2Iedzy24sgkYKLb5wW2ZZLfg2aoKEDwjgGDdHJdcpdf/YpIG Hu0LbfmqndJtS69sCsKGCrAvlcd+TY//nRGR/baNlOPJnWDA59qM9j1r7zOrE93T GX13OBjFpNj5BPuZVpd3ID4Sd8j4kjXOpURMswTf6OIKWV+i2AWt8ybYoJ+fyb+8 Yj9woWAQ+ah+S9XP0LE0/NigMl52vVT8lgetRNe16ZXCDDGCTdHy2WUn/LYhedGf qZjmHtFW5JfgkWmZLpBZ8tuKDd/29eFZ39md29BB3Hkmybigc8xwRAQQ/LMUpWR6 S7PMf/5EpbdqgkDOY8LA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3whccw88je-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Feb 2024 10:44:43 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41RAigCd029219 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Feb 2024 10:44:42 GMT Received: from bqiang-SFF.qca.qualcomm.com (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.1118.40; Tue, 27 Feb 2024 02:44:40 -0800 From: Baochen Qiang To: , CC: , , , Subject: [PATCH v3 2/3] net: qrtr: support suspend/hibernation Date: Tue, 27 Feb 2024 18:44:26 +0800 Message-ID: <20240227104427.7505-3-quic_bqiang@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240227104427.7505-1-quic_bqiang@quicinc.com> References: <20240227104427.7505-1-quic_bqiang@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-GUID: Ib6_qpk8n51mHkBvFEKuDnoQtZy6q-At X-Proofpoint-ORIG-GUID: Ib6_qpk8n51mHkBvFEKuDnoQtZy6q-At X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402270083 MHI devices may not be destroyed during suspend/hibernation, so need to unprepare/prepare MHI channels throughout the transition, this is done by adding suspend/resume callbacks. The suspend callback is called in the late suspend stage, this means MHI channels are still alive at suspend stage, and that makes it possible for an MHI controller driver to communicate with others over those channels at suspend stage. While the resume callback is called in the early resume stage, for a similar reason. Also note that we won't do unprepare/prepare when MHI device is in suspend state because it's pointless if MHI is only meant to go through a suspend/resume transition, instead of a complete power cycle. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.30 Signed-off-by: Baochen Qiang --- net/qrtr/mhi.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c index 9ced13c0627a..69f53625a049 100644 --- a/net/qrtr/mhi.c +++ b/net/qrtr/mhi.c @@ -118,6 +118,51 @@ static const struct mhi_device_id qcom_mhi_qrtr_id_table[] = { }; MODULE_DEVICE_TABLE(mhi, qcom_mhi_qrtr_id_table); +static int __maybe_unused qcom_mhi_qrtr_pm_suspend_late(struct device *dev) +{ + struct mhi_device *mhi_dev = container_of(dev, struct mhi_device, dev); + enum mhi_state state; + + state = mhi_get_mhi_state(mhi_dev->mhi_cntrl); + /* + * If the device is in suspend state, then no need for the + * client driver to unprepare the channels. + */ + if (state == MHI_STATE_M3) + return 0; + + mhi_unprepare_from_transfer(mhi_dev); + + return 0; +} + +static int __maybe_unused qcom_mhi_qrtr_pm_resume_early(struct device *dev) +{ + struct mhi_device *mhi_dev = container_of(dev, struct mhi_device, dev); + enum mhi_state state; + int rc; + + state = mhi_get_mhi_state(mhi_dev->mhi_cntrl); + /* + * If the device is in suspend state, we won't unprepare channels + * in suspend callback, therefore no need to prepare channels when + * resume. + */ + if (state == MHI_STATE_M3) + return 0; + + rc = mhi_prepare_for_transfer_autoqueue(mhi_dev); + if (rc) + dev_err(dev, "failed to prepare for autoqueue transfer %d\n", rc); + + return rc; +} + +static const struct dev_pm_ops qcom_mhi_qrtr_pm_ops = { + SET_LATE_SYSTEM_SLEEP_PM_OPS(qcom_mhi_qrtr_pm_suspend_late, + qcom_mhi_qrtr_pm_resume_early) +}; + static struct mhi_driver qcom_mhi_qrtr_driver = { .probe = qcom_mhi_qrtr_probe, .remove = qcom_mhi_qrtr_remove, @@ -126,6 +171,7 @@ static struct mhi_driver qcom_mhi_qrtr_driver = { .id_table = qcom_mhi_qrtr_id_table, .driver = { .name = "qcom_mhi_qrtr", + .pm = &qcom_mhi_qrtr_pm_ops, }, }; -- 2.25.1