From patchwork Tue Dec 10 07:41:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raj Kumar Bhagat X-Patchwork-Id: 849121 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 5D763234978; Tue, 10 Dec 2024 07:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733816604; cv=none; b=Ly/iwI0nZIvu3+Gls64qiY2o1nRIkBu2SmyDS46VuN43OhiSSUmJe+VP2+FOWrGctr63wJa71210u2NQFcsYAVAk9QADr7k99ir4evWEZ2k6NxbNoHtiuS2IBqHoMAQ7KAPqRT5c/B0IiCBE3wLCO5qllxV6fusoSojuMVcc06c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733816604; c=relaxed/simple; bh=46cKztNvjKVzLCcfaZpSSbCkjfmUrwT92nofQHILC1U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZFu/N2Vsw/K/8WRcv+k6gOF5JVfaPhqaxHBANt/dUSftgx+NOePo6zx5+OOa5im38zBM5oH6JRMJcyNt7h5p9i17kpp3vhUGdR4jdt0NHaEvh/a2JDsrKR3FhxyydgBuP2mEipGbH1I0nVca/KOaUlhW+gIYTdHWBJ09Gpn/8lc= 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=C6YAqc8h; arc=none smtp.client-ip=205.220.168.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="C6YAqc8h" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BA3tRl5019472; Tue, 10 Dec 2024 07:43:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= RNYCPST5Q7p+eNTy2KO0eHFwqslchPquuKid2rBAGZ4=; b=C6YAqc8heEKU1NZg PCTuqPtrz2D3h/Nh0wOFECo7DIDERDkpyUw92+Y1iBPH3Nt10/1V62SsLQCghK9h IttFPiI8ExVqnC/FQ2lyRREfIg3jD8Bon5Yh9l7U+9AGMJcZ2ZEq/VAiSl8uVb+u cvGlFJ8xWmEW8n9Fv5aVachnLtG9djlv0yTxAhIkt7hGL7IT8TBrR4BzCQcyG5pg rrD7Ol7wExiYLIWuXTxxY9zHnFT4dBIOYcmZF28Jn/mD8vGJFW8MP69cup8HEw8s JRdBGNyrVw0S7g3q7LLBh44hdyKn4OwSgrv+e7695A1yt2EM+eXut0yAkUW/onsU G8K/1Q== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43e341a8me-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Dec 2024 07:43:20 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4BA7hJi4020899 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Dec 2024 07:43:19 GMT Received: from hu-rajkbhag-blr.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 9 Dec 2024 23:43:15 -0800 From: Raj Kumar Bhagat To: CC: , Kalle Valo , "Rob Herring" , Krzysztof Kozlowski , "Conor Dooley" , Jeff Johnson , , , "Sowmiya Sree Elavalagan" , Raj Kumar Bhagat Subject: [PATCH v4 12/13] wifi: ath12k: Power down userPD Date: Tue, 10 Dec 2024 13:11:58 +0530 Message-ID: <20241210074159.2637933-13-quic_rajkbhag@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241210074159.2637933-1-quic_rajkbhag@quicinc.com> References: <20241210074159.2637933-1-quic_rajkbhag@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: yqvjmHv-ZCwhJZnC4Bc03ReaDvRFlhsO X-Proofpoint-ORIG-GUID: yqvjmHv-ZCwhJZnC4Bc03ReaDvRFlhsO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412100058 From: Sowmiya Sree Elavalagan Set the stop bit in SMEM to power down the userPD. Wait for stop-ack IRQ to indicate power down completion. Release the userPD firmware using its peripheral ID. Tested-on: IPQ5332 hw1.0 AHB WLAN.WBE.1.3.1-00130-QCAHKSWPL_SILICONZ-1 Signed-off-by: Sowmiya Sree Elavalagan Signed-off-by: Raj Kumar Bhagat --- drivers/net/wireless/ath/ath12k/ahb.c | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/wireless/ath/ath12k/ahb.c b/drivers/net/wireless/ath/ath12k/ahb.c index 74d10af6591f..1015b422e263 100644 --- a/drivers/net/wireless/ath/ath12k/ahb.c +++ b/drivers/net/wireless/ath/ath12k/ahb.c @@ -477,6 +477,34 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab) return ret; } +static void ath12k_ahb_power_down(struct ath12k_base *ab, bool is_suspend) +{ + struct ath12k_ahb *ab_ahb = ath12k_ab_to_ahb(ab); + unsigned long time_left; + u32 pasid; + int ret; + + qcom_smem_state_update_bits(ab_ahb->stop_state, BIT(ab_ahb->stop_bit), + BIT(ab_ahb->stop_bit)); + + time_left = wait_for_completion_timeout(&ab_ahb->userpd_stopped, + ATH12K_USERPD_STOP_TIMEOUT); + if (!time_left) { + ath12k_err(ab, "UserPD stop wait timed out\n"); + return; + } + + qcom_smem_state_update_bits(ab_ahb->stop_state, BIT(ab_ahb->stop_bit), 0); + + pasid = (u32_encode_bits(ab_ahb->userpd_id, ATH12K_USERPD_ID_MASK)) | + ATH12K_AHB_UPD_SWID; + /* Release the firmware */ + ret = qcom_scm_pas_shutdown(pasid); + if (ret) + ath12k_err(ab, "scm pas shutdown failed for userPD%d\n", + ab_ahb->userpd_id); +} + static void ath12k_ahb_init_qmi_ce_config(struct ath12k_base *ab) { struct ath12k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg; @@ -695,6 +723,7 @@ static const struct ath12k_hif_ops ath12k_ahb_hif_ops_ipq5332 = { .irq_disable = ath12k_ahb_ext_irq_disable, .map_service_to_pipe = ath12k_ahb_map_service_to_pipe, .power_up = ath12k_ahb_power_up, + .power_down = ath12k_ahb_power_down, }; static irqreturn_t ath12k_userpd_irq_handler(int irq, void *data) @@ -1173,6 +1202,7 @@ static void ath12k_ahb_remove(struct platform_device *pdev) struct ath12k_base *ab = platform_get_drvdata(pdev); if (test_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags)) { + ath12k_ahb_power_down(ab, false); ath12k_qmi_deinit_service(ab); goto qmi_fail; }