From patchwork Wed Apr 2 18:14:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: P Praneesh X-Patchwork-Id: 877892 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 A6E7218B470 for ; Wed, 2 Apr 2025 18:15:07 +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=1743617709; cv=none; b=aM6OOKdHxjVY5l+ZUduGFELyFEUnr2IqdTHDswIcezohbjbBbYhQ3vOJ175mb0NhueoEVSCOwWmBKGGORJhJZ1tfterHS+9Uo8ZBVkY1laPCYmyS3lgNmTzkdZumAO6yv8BemZQ39Xn8itPCeY1UpgmkG7ZbfiFagT23wpERalM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743617709; c=relaxed/simple; bh=iH/oKptJ4Tn3npbEE4/ChGksxj7cV2GYvwg1zMRIioU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F8maGYCvAWGmydpiyuaJ7lch53wCIC3cEnfYVY+kLNHw5XdrSCF2zLThC1SGqpnmmYg5IlarZ1QX6aOFiiy94PFyANH+rxO/1qQtfu9sUlY4Es7vRlAe9THBfbse3Ztg9M8qB+eub/ytXVHJ8GdeEQ7DjN4CJ13+KTWVJdexkRk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=cEFyo/jM; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="cEFyo/jM" 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 532DJBwv024528 for ; Wed, 2 Apr 2025 18:15:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=3kH4mg/2LiL W0Qi7Za2o6tSno8k8nCOBPtgA07zpuTE=; b=cEFyo/jMAF1AYgiJZHmy3uenX+7 Ig8WKhd+cDg47p0YrSNieJGBScqiHhgDPuz0CVYIoJAlgwpj8ipVXhXQcagmQRGo advDb2IzIlWcD0U2GJMISjEzSFUrncM6j2RKA3lY1ZIiqtc8zWCj3sVhmd0KihdR V20K0P9aWY1MrhakRdCxqztybpFXrvlPrPU+b6UR1e8SJ9zIWO0yo0iFNqE4Yow4 PA+5tbzQrvU8VlnKVRHxXAAGaBXUeyYkCMcCuISfFJ6H08+02SeeJoVgoyPbtR5W GrGP+07zen6MolMe0WTacPdk8qxISfUhA2CPIdE1REJws+g77m9sQZ/X2Iw== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 45rbpywdsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 02 Apr 2025 18:15:06 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-af5268afde2so51190a12.2 for ; Wed, 02 Apr 2025 11:15:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743617706; x=1744222506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3kH4mg/2LiLW0Qi7Za2o6tSno8k8nCOBPtgA07zpuTE=; b=Du2bSrHsjKV8Ld5TJppJxZRCi+owDg3mvjESkzg/gQQPCONocEH+GzGycacv+AfN1Z OueNwkbTjBoptochc1rbDaeqjvoknMeHACPsEf1Ywq18E8AebwbJlqf8+njzs/Kn85eN XeWQq4kkRMIq+f0+2kLbCMdQOt0dQOXt/dq9EtxyhKRkvzZ43bslRd3UwUu86vZ1YiMi ZpAi/EO1x8SO68/hvwVJUVwUDtuyl5WWA3YNSXNkLIGs7xKIF8TyrfYZr+ErsjpkO4Yf CWhSIUI4lDrLHdk3HMxlBp+ji4PL91CIu1sfjpnFi8bms/qrK6MQ/eM1ESQCP87hjpSy Ue7g== X-Gm-Message-State: AOJu0Yz9afAe8ABSEK0Jsbg0HMpNqgqKCh7CoWre6p9MYkft7XBeKQ8D aoBr21OGkufMzB9I2rtIQk6uXoPR/BH3F++Ox3pI8sQrJB84IgyxnrtaiMl3IziSiSbXzegz3qj 7vReiSyM9KOeI82iuKxcN8/HTHgSVBHNyunORojt1Khngo6krWTAEQD3iiuac2HYjr2QwC/kyuw == X-Gm-Gg: ASbGncskugKpkDixOdZJkIWTSRNUTd85yVH1mdanrKHfrbK9mI3cC64wD0GvulnxjXg kAaTaz5roQrMGre6/C7R56BSelkrPMV/0xqpRjj4ycGihjP95zD8yfEKBFrrSsJOY/SjFWvOpcx VRs2nC4Vmrn/dmEui6SF8/MnSxkOhZXtVBd4XeQEk7K8zOcnqYP05UdsOOJR0E+iSkYm+pOVuIQ 6TErfiXxZUajqQnbAAFNDdEGav6QGbNVaXnv9Dguf2RUBf9OwHBlPqCa2QyxvpCEO767WyZTr7C ceaA2p2B+tGOcS5aipZaFbd7UD11MYQVHz3yvEZA7gVBZ3huYKR31J77v4dx/pE8kvPbaO0gMI2 a+xskF5snT4K5nUy8fpc3z4vCDgaAFEeF7A== X-Received: by 2002:a17:902:d551:b0:220:d439:2485 with SMTP id d9443c01a7336-2292f97a6a2mr308344445ad.29.1743617705634; Wed, 02 Apr 2025 11:15:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGU6kLX6RDMozTZywWQC1yVew2IPm1v0hcV2dhZz6bqZOPGfrrv3sEM4qDnD6A9CgD+xdoKpQ== X-Received: by 2002:a17:902:d551:b0:220:d439:2485 with SMTP id d9443c01a7336-2292f97a6a2mr308344145ad.29.1743617705198; Wed, 02 Apr 2025 11:15:05 -0700 (PDT) Received: from hu-ppranees-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1cf14csm111689675ad.137.2025.04.02.11.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 11:15:04 -0700 (PDT) From: P Praneesh To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH ath-next 1/4] wifi: ath12k: Handle error cases during extended skb allocation Date: Wed, 2 Apr 2025 23:44:51 +0530 Message-Id: <20250402181454.2699777-2-praneesh.p@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250402181454.2699777-1-praneesh.p@oss.qualcomm.com> References: <20250402181454.2699777-1-praneesh.p@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: x0gc2PXMzqvK1_6GCcmVLmJ5-JmQcuW- X-Proofpoint-ORIG-GUID: x0gc2PXMzqvK1_6GCcmVLmJ5-JmQcuW- X-Authority-Analysis: v=2.4 cv=ZNLXmW7b c=1 sm=1 tr=0 ts=67ed7eaa cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=XR8D0OoHHMoA:10 a=EUspDBNiAAAA:8 a=Qd23BeFobrpH1aaNZ9kA:9 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-02_08,2025-04-02_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 impostorscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504020115 Currently, in the case of extended skb allocation, the buffer is freed before the DMA unmap operation. This premature deletion can result in skb->data corruption, as the memory region could be re-allocated for other purposes. Fix this issue by reordering the failure cases by calling dma_unmap_single() first, then followed by the corresponding kfree_skb(). This helps avoid data corruption in case of failures in dp_tx(). Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: P Praneesh --- drivers/net/wireless/ath/ath12k/dp_tx.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/dp_tx.c b/drivers/net/wireless/ath/ath12k/dp_tx.c index 29e2715024ce..03c79becd59a 100644 --- a/drivers/net/wireless/ath/ath12k/dp_tx.c +++ b/drivers/net/wireless/ath/ath12k/dp_tx.c @@ -230,7 +230,7 @@ int ath12k_dp_tx(struct ath12k *ar, struct ath12k_link_vif *arvif, struct ath12k_skb_cb *skb_cb = ATH12K_SKB_CB(skb); struct hal_tcl_data_cmd *hal_tcl_desc; struct hal_tx_msdu_ext_desc *msg; - struct sk_buff *skb_ext_desc; + struct sk_buff *skb_ext_desc = NULL; struct hal_srng *tcl_ring; struct ieee80211_hdr *hdr = (void *)skb->data; struct ath12k_vif *ahvif = arvif->ahvif; @@ -416,18 +416,15 @@ int ath12k_dp_tx(struct ath12k *ar, struct ath12k_link_vif *arvif, if (ret < 0) { ath12k_dbg(ab, ATH12K_DBG_DP_TX, "Failed to add HTT meta data, dropping packet\n"); - kfree_skb(skb_ext_desc); - goto fail_unmap_dma; + goto fail_free_ext_skb; } } ti.paddr = dma_map_single(ab->dev, skb_ext_desc->data, skb_ext_desc->len, DMA_TO_DEVICE); ret = dma_mapping_error(ab->dev, ti.paddr); - if (ret) { - kfree_skb(skb_ext_desc); - goto fail_unmap_dma; - } + if (ret) + goto fail_free_ext_skb; ti.data_len = skb_ext_desc->len; ti.type = HAL_TCL_DESC_TYPE_EXT_DESC; @@ -463,7 +460,7 @@ int ath12k_dp_tx(struct ath12k *ar, struct ath12k_link_vif *arvif, ring_selector++; } - goto fail_unmap_dma; + goto fail_unmap_dma_ext; } ath12k_hal_tx_cmd_desc_setup(ab, hal_tcl_desc, &ti); @@ -479,13 +476,16 @@ int ath12k_dp_tx(struct ath12k *ar, struct ath12k_link_vif *arvif, return 0; -fail_unmap_dma: - dma_unmap_single(ab->dev, ti.paddr, ti.data_len, DMA_TO_DEVICE); - +fail_unmap_dma_ext: if (skb_cb->paddr_ext_desc) dma_unmap_single(ab->dev, skb_cb->paddr_ext_desc, sizeof(struct hal_tx_msdu_ext_desc), DMA_TO_DEVICE); +fail_free_ext_skb: + kfree_skb(skb_ext_desc); + +fail_unmap_dma: + dma_unmap_single(ab->dev, ti.paddr, ti.data_len, DMA_TO_DEVICE); fail_remove_tx_buf: ath12k_dp_tx_release_txbuf(dp, tx_desc, pool_id); From patchwork Wed Apr 2 18:14:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: P Praneesh X-Patchwork-Id: 878166 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 ABFD91D61A3 for ; Wed, 2 Apr 2025 18:15:09 +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=1743617711; cv=none; b=YYt++BxToPC3t7bQA7fFxvaflIFJsr9wXBH5U0PpSec5vLnU/o5GnhCKBcAQJpVbJ27PWVd3evXeSnbuKj5A/9FpZdXfiCF05w2tFRuXKzzZ7IIiUVDpsATU9Bs2P40qEBl2tAOZpVK8H584Tm8MdehuyejJlMip/hRVkPPR2VY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743617711; c=relaxed/simple; bh=2hUDyVA+wcbHwjNLQ/GHWZKE6K7qK9TSrjIKrFrGwk8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BNw5aAda2aFbPxuKMZQgo0ApyFEw9Ny5y5uCe4pfT6jmX0we9XuA/n0umQ+2pjGZBp6Dewi+9CFRSU1q+iZ3HVwgojd4JAKXe4jkgTqpSWmtKHZ3j8YmRSCLFdz5V1aJB8VsPHRNPGT7nPh2+inJmJiVD+5+bLatkAMZIhf5Go4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=hd0acpFb; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="hd0acpFb" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5329TtAc031204 for ; Wed, 2 Apr 2025 18:15:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=iDxpFyWVw/N SmbzY19vvGJFrlSTyAN/GVhMSHA7vtdI=; b=hd0acpFbvTNNWwsY2ThgglSRN1w QD2llnuTDdteOkoUqv4Yw9wTM4h/u0Q8eqvfgchnBlgjiqS3u1eNZbvW76FjOcn9 sd+UkP7cnC7ffwpu8CautwMjTwV+Zbb+1FKQu9Lhkv5Bu1wQhQKpF3kkZ/jcXdK7 Bo+vRS689lsN25KCJ5KHclKEVYdmw9Du8qmnUJTbvvNwxik1oOac4vJ8cmJxI0cc 8EfJAMbNiQRFHYRsP53TTr1eXX4AOk/D+8i3hOjAKK1EEwu/5XL/LgAovp3A9olL Ch87hX4eQBlwrbwKz4wYAzwkm97NqMRn9ZdWFOruo374T/2hvRphjqvF1uQ== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 45recpmqkk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 02 Apr 2025 18:15:08 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-223fd6e9408so12649665ad.1 for ; Wed, 02 Apr 2025 11:15:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743617707; x=1744222507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iDxpFyWVw/NSmbzY19vvGJFrlSTyAN/GVhMSHA7vtdI=; b=iCkXt3enknXRv32/IfZ2dFqGXf1G3MZO7MfIBb6RSu0IpAqbdBeabpOUxIzWeN7lbn V1o8RMgHWZZm4xJbcrUa3J4YRTlmedw/hjS8koGG1tRjDTF590HVrAuM7WGSPCTn+1GD HsL297U2rPQTOVJpRfgdFGLmz4KNcMJnMKIOFTiDxwwID/oNiKYOwd1qzHmMn5+Zcgl8 Wi1McUL3Rvzo0T+Oh//WiVS13HfFhHq3gZNQ9BoCLtfBLJv6NfAxGUzBnL76UclBy5rV NACaZAfK8pLgp9Pdoh1gPfuLpFhAG6R7wKpVpfva4Ejsmf8MKJgXEfWcBKYVa7fJRM5V s6jw== X-Gm-Message-State: AOJu0YzAt1NhCW0TtLtvfZ0zbNfY4+BE+JAmM3Gy6TUHbjQw2wIRtE75 hqrTRjhgxXaNQ4KIx8MdsF/7wgdJXtJbKwWwBEZ55JNyrZVnd9+z4pFYUPZYI6dAUzzmhy+ghfe AO7Cp7rQcCEmNmKVcxsR2353+3jJIPjUA+o9JpgTsK82Oh9FPcEKJ2uG0WjMw6dAE4s9E0A60eg == X-Gm-Gg: ASbGncsnzcRMV9t38lsPvgeJqA2RYs4psdj/dXIGP1sBxIa5Wi9AZdinR/f4Yc1+IIt 9wuwdCGwInBKvgzvvxVDNrmz5ZAvFoUlZ6roGcWq+wbNvyiEwve5ZodeQ+7YsM0WS2MEUcp6zpy OQJrwNvwTHszg2aOTplfJGSMzAOBubL7cFZ6nMaFtGTfEmprkmbQ04YB+G50plbTwKbzuK8AhFU qnA49ktMQuZPcN04vehRAm/6VJhjoq/8yfcQhmMtRgte7ka3b7sUL0AXICj/wuFsGYyVdWx+iik AeFQ/rcUiK+A8ZzARe+XM2I2RoSZ8NowiesW+SvpTvcm/Fotm2Muy9h59XnqsnQxhbcvtjIGrvS Zy5NiyPbQmMEbNcsvhzPA/igl1HF6ZXNy/A== X-Received: by 2002:a17:903:2444:b0:21f:6f33:f96 with SMTP id d9443c01a7336-229765bd1b1mr6413705ad.6.1743617707232; Wed, 02 Apr 2025 11:15:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGznKDbtnf0J5Z0Fs0/PJUPpOEL9O7Pr+bGPa/xvJXbXPkVZWz3ruNM9q0leoRIs1sXRUiJtA== X-Received: by 2002:a17:903:2444:b0:21f:6f33:f96 with SMTP id d9443c01a7336-229765bd1b1mr6413355ad.6.1743617706761; Wed, 02 Apr 2025 11:15:06 -0700 (PDT) Received: from hu-ppranees-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1cf14csm111689675ad.137.2025.04.02.11.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 11:15:06 -0700 (PDT) From: P Praneesh To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH ath-next 2/4] wifi: ath12k: Refactor tx descriptor handling in tx completion handler Date: Wed, 2 Apr 2025 23:44:52 +0530 Message-Id: <20250402181454.2699777-3-praneesh.p@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250402181454.2699777-1-praneesh.p@oss.qualcomm.com> References: <20250402181454.2699777-1-praneesh.p@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: b0kZKjPRJmFWRkTH5r1F_PM9DqtRjQwV X-Proofpoint-ORIG-GUID: b0kZKjPRJmFWRkTH5r1F_PM9DqtRjQwV X-Authority-Analysis: v=2.4 cv=J4Sq7BnS c=1 sm=1 tr=0 ts=67ed7ead cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=XR8D0OoHHMoA:10 a=EUspDBNiAAAA:8 a=DEzRtGDzSFLe7Yuc7ZwA:9 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-02_08,2025-04-02_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 bulkscore=0 mlxlogscore=987 malwarescore=0 mlxscore=0 spamscore=0 phishscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504020116 Current code uses mac_id and msdu parameters in ath12k_dp_tx_free_txbuf() and ath12k_dp_tx_process_htt_tx_complete(). Since these parameters are already encapsulated by struct ath12k_dp_tx_desc, passing them individually results in redundant arguments. Introduce struct ath12k_tx_desc_params to capture the skb, mac_id, and pass it to the corresponding functions. Refactor these functions to use struct ath12k_tx_desc_params instead, reducing the number of arguments and improving function argument handling efficiency. Additionally, use struct ath12k_tx_desc_params in ath12k_dp_tx_htt_tx_complete_buf() and ath12k_dp_tx_complete_msdu(), which will be utilized for fetching extended skb in a future patch. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: P Praneesh --- drivers/net/wireless/ath/ath12k/dp.h | 5 +++ drivers/net/wireless/ath/ath12k/dp_tx.c | 42 ++++++++++++------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/dp.h b/drivers/net/wireless/ath/ath12k/dp.h index 427a87b63dec..e26a9c3477d9 100644 --- a/drivers/net/wireless/ath/ath12k/dp.h +++ b/drivers/net/wireless/ath/ath12k/dp.h @@ -300,6 +300,11 @@ struct ath12k_tx_desc_info { u8 pool_id; }; +struct ath12k_tx_desc_params { + struct sk_buff *skb; + u8 mac_id; +}; + struct ath12k_spt_info { dma_addr_t paddr; u64 *vaddr; diff --git a/drivers/net/wireless/ath/ath12k/dp_tx.c b/drivers/net/wireless/ath/ath12k/dp_tx.c index 03c79becd59a..45f4c8bd78e6 100644 --- a/drivers/net/wireless/ath/ath12k/dp_tx.c +++ b/drivers/net/wireless/ath/ath12k/dp_tx.c @@ -496,12 +496,13 @@ int ath12k_dp_tx(struct ath12k *ar, struct ath12k_link_vif *arvif, } static void ath12k_dp_tx_free_txbuf(struct ath12k_base *ab, - struct sk_buff *msdu, u8 mac_id, - struct dp_tx_ring *tx_ring) + struct dp_tx_ring *tx_ring, + struct ath12k_tx_desc_params *desc_params) { struct ath12k *ar; + struct sk_buff *msdu = desc_params->skb; struct ath12k_skb_cb *skb_cb; - u8 pdev_id = ath12k_hw_mac_id_to_pdev_id(ab->hw_params, mac_id); + u8 pdev_id = ath12k_hw_mac_id_to_pdev_id(ab->hw_params, desc_params->mac_id); skb_cb = ATH12K_SKB_CB(msdu); ar = ab->pdevs[pdev_id].ar; @@ -519,11 +520,12 @@ static void ath12k_dp_tx_free_txbuf(struct ath12k_base *ab, static void ath12k_dp_tx_htt_tx_complete_buf(struct ath12k_base *ab, - struct sk_buff *msdu, + struct ath12k_tx_desc_params *desc_params, struct dp_tx_ring *tx_ring, struct ath12k_dp_htt_wbm_tx_status *ts) { struct ieee80211_tx_info *info; + struct sk_buff *msdu = desc_params->skb; struct ath12k_skb_cb *skb_cb; struct ath12k *ar; @@ -561,10 +563,9 @@ ath12k_dp_tx_htt_tx_complete_buf(struct ath12k_base *ab, } static void -ath12k_dp_tx_process_htt_tx_complete(struct ath12k_base *ab, - void *desc, u8 mac_id, - struct sk_buff *msdu, - struct dp_tx_ring *tx_ring) +ath12k_dp_tx_process_htt_tx_complete(struct ath12k_base *ab, void *desc, + struct dp_tx_ring *tx_ring, + struct ath12k_tx_desc_params *desc_params) { struct htt_tx_wbm_completion *status_desc; struct ath12k_dp_htt_wbm_tx_status ts = {0}; @@ -580,13 +581,13 @@ ath12k_dp_tx_process_htt_tx_complete(struct ath12k_base *ab, ts.acked = (wbm_status == HAL_WBM_REL_HTT_TX_COMP_STATUS_OK); ts.ack_rssi = le32_get_bits(status_desc->info2, HTT_TX_WBM_COMP_INFO2_ACK_RSSI); - ath12k_dp_tx_htt_tx_complete_buf(ab, msdu, tx_ring, &ts); + ath12k_dp_tx_htt_tx_complete_buf(ab, desc_params, tx_ring, &ts); break; case HAL_WBM_REL_HTT_TX_COMP_STATUS_DROP: case HAL_WBM_REL_HTT_TX_COMP_STATUS_TTL: case HAL_WBM_REL_HTT_TX_COMP_STATUS_REINJ: case HAL_WBM_REL_HTT_TX_COMP_STATUS_INSPECT: - ath12k_dp_tx_free_txbuf(ab, msdu, mac_id, tx_ring); + ath12k_dp_tx_free_txbuf(ab, tx_ring, desc_params); break; case HAL_WBM_REL_HTT_TX_COMP_STATUS_MEC_NOTIFY: /* This event is to be handled only when the driver decides to @@ -718,13 +719,14 @@ static void ath12k_dp_tx_update_txcompl(struct ath12k *ar, struct hal_tx_status } static void ath12k_dp_tx_complete_msdu(struct ath12k *ar, - struct sk_buff *msdu, + struct ath12k_tx_desc_params *desc_params, struct hal_tx_status *ts) { struct ath12k_base *ab = ar->ab; struct ath12k_hw *ah = ar->ah; struct ieee80211_tx_info *info; struct ath12k_skb_cb *skb_cb; + struct sk_buff *msdu = desc_params->skb; if (WARN_ON_ONCE(ts->buf_rel_source != HAL_WBM_REL_SRC_MODULE_TQM)) { /* Must not happen */ @@ -843,11 +845,11 @@ void ath12k_dp_tx_completion_handler(struct ath12k_base *ab, int ring_id) int hal_ring_id = dp->tx_ring[ring_id].tcl_comp_ring.ring_id; struct hal_srng *status_ring = &ab->hal.srng_list[hal_ring_id]; struct ath12k_tx_desc_info *tx_desc = NULL; - struct sk_buff *msdu; struct hal_tx_status ts = { 0 }; + struct ath12k_tx_desc_params desc_params; struct dp_tx_ring *tx_ring = &dp->tx_ring[ring_id]; struct hal_wbm_release_ring *desc; - u8 mac_id, pdev_id; + u8 pdev_id; u64 desc_va; spin_lock_bh(&status_ring->lock); @@ -901,28 +903,26 @@ void ath12k_dp_tx_completion_handler(struct ath12k_base *ab, int ring_id) continue; } - msdu = tx_desc->skb; - mac_id = tx_desc->mac_id; + desc_params.mac_id = tx_desc->mac_id; + desc_params.skb = tx_desc->skb; /* Release descriptor as soon as extracting necessary info * to reduce contention */ ath12k_dp_tx_release_txbuf(dp, tx_desc, tx_desc->pool_id); if (ts.buf_rel_source == HAL_WBM_REL_SRC_MODULE_FW) { - ath12k_dp_tx_process_htt_tx_complete(ab, - (void *)tx_status, - mac_id, msdu, - tx_ring); + ath12k_dp_tx_process_htt_tx_complete(ab, (void *)tx_status, + tx_ring, &desc_params); continue; } - pdev_id = ath12k_hw_mac_id_to_pdev_id(ab->hw_params, mac_id); + pdev_id = ath12k_hw_mac_id_to_pdev_id(ab->hw_params, desc_params.mac_id); ar = ab->pdevs[pdev_id].ar; if (atomic_dec_and_test(&ar->dp.num_tx_pending)) wake_up(&ar->dp.tx_empty_waitq); - ath12k_dp_tx_complete_msdu(ar, msdu, &ts); + ath12k_dp_tx_complete_msdu(ar, &desc_params, &ts); } } From patchwork Wed Apr 2 18:14:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: P Praneesh X-Patchwork-Id: 878165 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 6B3F21DB346 for ; Wed, 2 Apr 2025 18:15:13 +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=1743617715; cv=none; b=Ecbu/yg4agpxuO8JJdXh/4qUIGI9M0Fo2ToPHeYPXG/JOEHSTYbKSat/zYn84xwcRnugI134kla998QXQp84NbcAidyvkwxmMvdBCTc57/KpzOY/hhFAvN0nVFT58FKHc+PNGXrIfaAV+Qe8fvw11OnBFMzfXKKUbQ+pV1wc/5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743617715; c=relaxed/simple; bh=FUt/K4ZhZV51PSLWua8xfxLnRheJ77w55l4hDOYJIZY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b2MuuKumlqBK1qoivO8NlNMS0WHIQ14PI6+sxgybrFcWFuhLz4mM8XSsKpWtLgwDRMYh/OPa9M6ZQ6F0Dcv36QLZQ4u7HWwTJ48S4Zc/aW4qHpW0rquTGSE7DCXTX1CQWFNy+nWIOa40lDg4StszvkzT0vyhjQxA4ea3nJyh1Z0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=UCRmKddX; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="UCRmKddX" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 532D2pPK007649 for ; Wed, 2 Apr 2025 18:15:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=m03BhA+Eey2 Yr/TfX0IC374Y+t6keO9nkzVIy0TvCT4=; b=UCRmKddXynx9DvMBn0aTozq/4UR LKjOO5bGKd2LhpJ0YmQqzj0D/3qcUmqJzMdIz0lEMejijSOGvh4FFaZxmcD+7qoG bJwW1E4QbgJjAZexF5TX+WW/8Ty8DL+scyoKjWlTxiD+gwA9YBeqga1Vwgq+PN4s pHect1ye0Wp8zqqELA0dWrRhnu0+QuNq3SGEIdUoqKgnTscyx2I5/qRUSTjppknE 817E6BNys6JKIevR02QYZCEKlZ5R92Iwo/7G/l+54O4jkbv1ADjq3BXwThIBfiQi GFiH9t7yjEo0n0Bv/dmCPHK3kB+dwnq8/6YMAYbRHnkv8GRosFuTBxgFeSA== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 45rxb02a2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 02 Apr 2025 18:15:11 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-22403329f9eso950185ad.3 for ; Wed, 02 Apr 2025 11:15:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743617711; x=1744222511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m03BhA+Eey2Yr/TfX0IC374Y+t6keO9nkzVIy0TvCT4=; b=PX7EpvYQ1RGNJK4sAJZCNSnunH5Naph8KdSr7pXq2sdhRxkn68DSZgsy9G5WacKbHj 0oRh5uxdkh3RicRanSWUQ4rXIvBmiRbzJ85lfcdG88rJwNbE/7FqhVFzqDRgo2JNUQ1w 1EdFcZgbfRRIm0YATK1OXV73PhZNtTBLUFqJ8behzpAnw89ecegdlVXyzWNHDjm+MBZ6 BKWJZ0Be21nyMZ+2wI9G4+jUV6VwCQfy0b7C/TknXu4jjVqBwuERSVjH+ProusgCFb3C KkWLPaRaFyYZPzQp2xuMqpVMPYeZ1iushmEab7xj5i4Ss8KEXM/KmJ556QK6K0P3qtCW VPqQ== X-Gm-Message-State: AOJu0Yw8IL1pQNOav0OUCU0QTg6LuUpfGIfXV7iw711vKeItRV497Hyf Ld/hRBMr/NiWTNEPT1jA2DUrJafRsz2V4PBHM1EI7SuSDcRFd0kpvebyUQya8xCKJcMSD9+/BXu HUuy+n3LzLIsIq6o8qdyOhw2hkqeXd+Vz32EuwLCVsDPL2cwrbpT2/UawIKxBqK/KZbelnxtISw == X-Gm-Gg: ASbGnctB6QtCKWPr8kNK9uBYkGoeKTa6XtuGQaqYLsT9QssHcS+2qWhiHPWaRvDNT0z qUVxxsgWoNE46g9/XwHKta62VKwapln7GmvZ85Uh1rWNORRKz6Ot0aeLg0W0/8KbhYaqLA0f8yD ovm5sBZ7oDbkZLVOXuwu/X/k1aps0+dmp+OQ0Q51ks/rS4O7Gnue/OM3T3SqP2eKD87Ozeb+21i wobGW9Mqi15HMyJ5BDZM0RmFUfaS4uDfxGkFMwu4dlw+8pS2oK4nEAoagLqh7UAjIAfjpD+/g4l MHZtYaY9MTbhMtwSjWPJ3p0nxGh56PJ7o25Bwls49QJ+aeveVRhRwUy4SpWrCcqQMpk7EPLItZu FowMXVfnNzV4P7lSRTANi7vpS7hO/j6mktg== X-Received: by 2002:a17:903:2a8e:b0:223:4816:3e9e with SMTP id d9443c01a7336-2292f96119cmr238413905ad.13.1743617709236; Wed, 02 Apr 2025 11:15:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHE+bCar7mS11SpplOV1+I1khRJyowGdhKycatdsXZAcukRn1PzceNnpaVBBIfUKPBvLyIuxQ== X-Received: by 2002:a17:903:2a8e:b0:223:4816:3e9e with SMTP id d9443c01a7336-2292f96119cmr238413475ad.13.1743617708422; Wed, 02 Apr 2025 11:15:08 -0700 (PDT) Received: from hu-ppranees-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1cf14csm111689675ad.137.2025.04.02.11.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 11:15:08 -0700 (PDT) From: P Praneesh To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH ath-next 3/4] wifi: ath12k: Fix memory leak during extended skb allocation Date: Wed, 2 Apr 2025 23:44:53 +0530 Message-Id: <20250402181454.2699777-4-praneesh.p@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250402181454.2699777-1-praneesh.p@oss.qualcomm.com> References: <20250402181454.2699777-1-praneesh.p@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ZpfPxQ-1venp_YmLsJM75U_5sSpVa4yd X-Proofpoint-GUID: ZpfPxQ-1venp_YmLsJM75U_5sSpVa4yd X-Authority-Analysis: v=2.4 cv=BavY0qt2 c=1 sm=1 tr=0 ts=67ed7eaf cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=XR8D0OoHHMoA:10 a=EUspDBNiAAAA:8 a=iFgiq4A1vBvqtHBMXJkA:9 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-02_08,2025-04-02_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 phishscore=0 impostorscore=0 priorityscore=1501 bulkscore=1 adultscore=0 spamscore=0 malwarescore=0 lowpriorityscore=1 mlxscore=0 suspectscore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504020116 In ath12k_dp_tx(), memory allocated for extended skb is not freed properly, causing a memory leak even when the host receives tx completion for those skbs. Fix this issue by storing skb_ext_desc in the host tx descriptor and using this skb_ext_desc field during completion or during ath12k_dp_cc_cleanup(). Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: P Praneesh --- drivers/net/wireless/ath/ath12k/dp.c | 10 +++++++++- drivers/net/wireless/ath/ath12k/dp.h | 2 ++ drivers/net/wireless/ath/ath12k/dp_tx.c | 15 ++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/dp.c b/drivers/net/wireless/ath/ath12k/dp.c index b1f27c3ac723..34c72a1b5ae1 100644 --- a/drivers/net/wireless/ath/ath12k/dp.c +++ b/drivers/net/wireless/ath/ath12k/dp.c @@ -1206,11 +1206,19 @@ static void ath12k_dp_cc_cleanup(struct ath12k_base *ab) if (!skb) continue; + skb_cb = ATH12K_SKB_CB(skb); + if (skb_cb->paddr_ext_desc) { + dma_unmap_single(ab->dev, + skb_cb->paddr_ext_desc, + tx_desc_info->skb_ext_desc->len, + DMA_TO_DEVICE); + dev_kfree_skb_any(tx_desc_info->skb_ext_desc); + } + /* if we are unregistering, hw would've been destroyed and * ar is no longer valid. */ if (!(test_bit(ATH12K_FLAG_UNREGISTERING, &ab->dev_flags))) { - skb_cb = ATH12K_SKB_CB(skb); ar = skb_cb->ar; if (atomic_dec_and_test(&ar->dp.num_tx_pending)) diff --git a/drivers/net/wireless/ath/ath12k/dp.h b/drivers/net/wireless/ath/ath12k/dp.h index e26a9c3477d9..c8e0c70a4d26 100644 --- a/drivers/net/wireless/ath/ath12k/dp.h +++ b/drivers/net/wireless/ath/ath12k/dp.h @@ -295,6 +295,7 @@ struct ath12k_rx_desc_info { struct ath12k_tx_desc_info { struct list_head list; struct sk_buff *skb; + struct sk_buff *skb_ext_desc; u32 desc_id; /* Cookie */ u8 mac_id; u8 pool_id; @@ -302,6 +303,7 @@ struct ath12k_tx_desc_info { struct ath12k_tx_desc_params { struct sk_buff *skb; + struct sk_buff *skb_ext_desc; u8 mac_id; }; diff --git a/drivers/net/wireless/ath/ath12k/dp_tx.c b/drivers/net/wireless/ath/ath12k/dp_tx.c index 45f4c8bd78e6..ab359483472f 100644 --- a/drivers/net/wireless/ath/ath12k/dp_tx.c +++ b/drivers/net/wireless/ath/ath12k/dp_tx.c @@ -84,6 +84,7 @@ static void ath12k_dp_tx_release_txbuf(struct ath12k_dp *dp, u8 pool_id) { spin_lock_bh(&dp->tx_desc_lock[pool_id]); + tx_desc->skb_ext_desc = NULL; list_move_tail(&tx_desc->list, &dp->tx_desc_free_list[pool_id]); spin_unlock_bh(&dp->tx_desc_lock[pool_id]); } @@ -430,6 +431,7 @@ int ath12k_dp_tx(struct ath12k *ar, struct ath12k_link_vif *arvif, ti.type = HAL_TCL_DESC_TYPE_EXT_DESC; skb_cb->paddr_ext_desc = ti.paddr; + tx_desc->skb_ext_desc = skb_ext_desc; } hal_ring_id = tx_ring->tcl_data_ring.ring_id; @@ -508,9 +510,11 @@ static void ath12k_dp_tx_free_txbuf(struct ath12k_base *ab, ar = ab->pdevs[pdev_id].ar; dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); - if (skb_cb->paddr_ext_desc) + if (skb_cb->paddr_ext_desc) { dma_unmap_single(ab->dev, skb_cb->paddr_ext_desc, sizeof(struct hal_tx_msdu_ext_desc), DMA_TO_DEVICE); + dev_kfree_skb_any(desc_params->skb_ext_desc); + } ieee80211_free_txskb(ar->ah->hw, msdu); @@ -538,9 +542,11 @@ ath12k_dp_tx_htt_tx_complete_buf(struct ath12k_base *ab, wake_up(&ar->dp.tx_empty_waitq); dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); - if (skb_cb->paddr_ext_desc) + if (skb_cb->paddr_ext_desc) { dma_unmap_single(ab->dev, skb_cb->paddr_ext_desc, sizeof(struct hal_tx_msdu_ext_desc), DMA_TO_DEVICE); + dev_kfree_skb_any(desc_params->skb_ext_desc); + } memset(&info->status, 0, sizeof(info->status)); @@ -736,9 +742,11 @@ static void ath12k_dp_tx_complete_msdu(struct ath12k *ar, skb_cb = ATH12K_SKB_CB(msdu); dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); - if (skb_cb->paddr_ext_desc) + if (skb_cb->paddr_ext_desc) { dma_unmap_single(ab->dev, skb_cb->paddr_ext_desc, sizeof(struct hal_tx_msdu_ext_desc), DMA_TO_DEVICE); + dev_kfree_skb_any(desc_params->skb_ext_desc); + } rcu_read_lock(); @@ -905,6 +913,7 @@ void ath12k_dp_tx_completion_handler(struct ath12k_base *ab, int ring_id) desc_params.mac_id = tx_desc->mac_id; desc_params.skb = tx_desc->skb; + desc_params.skb_ext_desc = tx_desc->skb_ext_desc; /* Release descriptor as soon as extracting necessary info * to reduce contention From patchwork Wed Apr 2 18:14:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: P Praneesh X-Patchwork-Id: 877891 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 2A7BB1D61A3 for ; Wed, 2 Apr 2025 18:15:12 +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=1743617714; cv=none; b=cuO9GvVQOB8Iu+DqYTIGO+qp//3B3NHuVEOYZstDmnhdG0EZDEDIr3TeM6VWxkXi0ixA5WGNWHd+QbHIYSArJbdlNux/SupIQGZnfslOfG9YAnKV3DT6sKU0AuisyEGMcu897Rsj0a7RcXrP6x8HwzJ49oxJIwG73R5TRxh0AjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743617714; c=relaxed/simple; bh=ozsQOViJqNZgQuUtzc+HxmcKrwraFQHmMN6DAhks7mM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o7uCyfol3YjxWRlUENeO0u26YpYklo8QxRnaCNRR//3R0kuxXj8oZzuWUF8kxOnVX1qjyIF8msIEN7oELPYmPnI2nr9IyiWpWZ/e0muEF3drXe1SnAtOF0qvwKTSwQ/1uJ20p+pbD+/laPQiALf7SBEgoadpGFDNSiCNqECDMC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=mfK/No/3; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="mfK/No/3" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 532D2pT0023738 for ; Wed, 2 Apr 2025 18:15:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=BfQKh9W0ONV XpnR6TE/4zg4F3jk/hUWyS7VSMd4+DYk=; b=mfK/No/3+mWyMiV4YPZOfGrK+LM lzE50XIk+UlxxLGc2woXYY/k9AW0x4fYq24LRhp0qE+gWZ1unn95+nGNSbbpTK/t Tyfc0MOFItBUx2W+lr48qSX6lZ31+2gN07sOR6S51zwhWf7Wz3C6VkOFMiuOfPlm 04A4HX2/jDLeOkd790cFAfDfTnsKWZVbPd4MzCf+shNeq3HbOVZGu8HEfITq5B3L 2OlPnlQA0ZnMspyMdaQHZhXjYN9brBRkKP9rzPVP8rne2kCpd8wOkMBERTH5PBdL fO3tXpolCNOdvHGx/B+WQ1odB/xV4WosAGS27sHYzPXW5pnde+VsrnuzPsw== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 45rxapt9p3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 02 Apr 2025 18:15:12 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-22647ff3cf5so1105675ad.0 for ; Wed, 02 Apr 2025 11:15:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743617711; x=1744222511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BfQKh9W0ONVXpnR6TE/4zg4F3jk/hUWyS7VSMd4+DYk=; b=G+ym1rT2wkzWHmBpqZpU0/Bw3rN3C52h/W5w4RIYwkwvW9q6qfnTvpKV5IpT1DUx/t p8mUltPNQQ2Xth4hF7aYfQFbBW91E/kFsHC5cieSoCp5nlXIZXfNU5yeGhqdAIfkOdlT jxLyz+LTwKCgsOYRe3Qp2K3m46mEDO4YfBrbCbH8Ja6f9tu6h9NLc/7pVH6Yc3zYx3Wt kf755cnyKGUMrUc3fq9q4RdIhIizkyAx1biqvy2jQwbF1XsSpkMIwZAE67BcdVV78vq7 OHw1Pf4en8t64PCXIX/1DiwuBVjz7je/9uUVBy5APsbS/IRmbmb3hbavNNI26VvPhklM wlCA== X-Gm-Message-State: AOJu0YzxtbqDOo5uAxEj6nwcKINiXzu4Oa7M+/LKvgQK1FI0ZJ1ZfMw+ 1nL1ZweLG+CnC4jXXVwcoAJTRrg3L/1WSmb6ziP4e8C+gh0hGbcdoJueHQmtFaivYXQaHOXP9HM Gh8rLOvoz8QtjjOGe3uOl51idZmxX7aWCNCknszNJPvPkRM3izlkip8hLFQTlUc/qgmkVau0s9Q == X-Gm-Gg: ASbGncsRw/RPPogrZyjxXMxDrPJXseEHlRaiUWbPI4AJDQW3jbvpeNZzpmg3q6ji92x jEZAdCQUPTqvN5sloFUIMVBb4UBPqhOeKRJQct3Fs5S5ADnsPk6vsy+5IYFVdj6kj6J4IF1JMwG Sy6ZmfwckCglNDG0zYuLNVoTOkLz86iAEr1woWay5asBhDd8PpZSAY6NSssetlJvNXMUZaErZ6/ a+cOmvLsSGwjLrZh7L3IBhmq5RYgZhfIXszBoiQsTCiQOJlbVAHZn6s/G3AIAcPWvewGAwxD9dH 6VV2pvyMOaSE/7mtPVTX5dOM1sW5bAE2aZP9b3xrYqp70jB1c+WKNrQMmUx8yPIAUTNcpvcI0g6 H1yUNPjnl8yoyTe18x24TH3zn4lUUDY3xyQ== X-Received: by 2002:a17:902:e5c5:b0:223:3396:15e8 with SMTP id d9443c01a7336-2296c6821bfmr43794165ad.22.1743617710970; Wed, 02 Apr 2025 11:15:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDLD8/RfIj/Y/+RSGHKxY9YJrRooy+dzn16LPNSwmIfHzQhWbkjgZHdlZ9sKnsUrmpQ+k3cw== X-Received: by 2002:a17:902:e5c5:b0:223:3396:15e8 with SMTP id d9443c01a7336-2296c6821bfmr43793715ad.22.1743617710206; Wed, 02 Apr 2025 11:15:10 -0700 (PDT) Received: from hu-ppranees-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1cf14csm111689675ad.137.2025.04.02.11.15.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 11:15:09 -0700 (PDT) From: P Praneesh To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH ath-next 4/4] wifi: ath12k: Use skb->len for dma_unmap_single() length parameter Date: Wed, 2 Apr 2025 23:44:54 +0530 Message-Id: <20250402181454.2699777-5-praneesh.p@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250402181454.2699777-1-praneesh.p@oss.qualcomm.com> References: <20250402181454.2699777-1-praneesh.p@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Authority-Analysis: v=2.4 cv=Vbj3PEp9 c=1 sm=1 tr=0 ts=67ed7eb0 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=XR8D0OoHHMoA:10 a=EUspDBNiAAAA:8 a=HWa5UnKU9jpq--M6GMsA:9 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-ORIG-GUID: ETYHjzeYC2NexpCpdEP8Ht08JVo64lqi X-Proofpoint-GUID: ETYHjzeYC2NexpCpdEP8Ht08JVo64lqi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-02_08,2025-04-02_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 suspectscore=0 clxscore=1015 mlxscore=0 phishscore=0 bulkscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504020116 During dma_unmap_single() for extended skb, the driver currently uses sizeof() of the corresponding structure. When the allocation size changes, one of the parameters of dma_unmap_single() needs to be updated everywhere. Improve code readability by using skb->len instead of sizeof() the structure. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: P Praneesh --- drivers/net/wireless/ath/ath12k/dp_tx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/dp_tx.c b/drivers/net/wireless/ath/ath12k/dp_tx.c index ab359483472f..9e598a585020 100644 --- a/drivers/net/wireless/ath/ath12k/dp_tx.c +++ b/drivers/net/wireless/ath/ath12k/dp_tx.c @@ -481,7 +481,7 @@ int ath12k_dp_tx(struct ath12k *ar, struct ath12k_link_vif *arvif, fail_unmap_dma_ext: if (skb_cb->paddr_ext_desc) dma_unmap_single(ab->dev, skb_cb->paddr_ext_desc, - sizeof(struct hal_tx_msdu_ext_desc), + skb_ext_desc->len, DMA_TO_DEVICE); fail_free_ext_skb: kfree_skb(skb_ext_desc); @@ -512,7 +512,7 @@ static void ath12k_dp_tx_free_txbuf(struct ath12k_base *ab, dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); if (skb_cb->paddr_ext_desc) { dma_unmap_single(ab->dev, skb_cb->paddr_ext_desc, - sizeof(struct hal_tx_msdu_ext_desc), DMA_TO_DEVICE); + desc_params->skb_ext_desc->len, DMA_TO_DEVICE); dev_kfree_skb_any(desc_params->skb_ext_desc); } @@ -544,7 +544,7 @@ ath12k_dp_tx_htt_tx_complete_buf(struct ath12k_base *ab, dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); if (skb_cb->paddr_ext_desc) { dma_unmap_single(ab->dev, skb_cb->paddr_ext_desc, - sizeof(struct hal_tx_msdu_ext_desc), DMA_TO_DEVICE); + desc_params->skb_ext_desc->len, DMA_TO_DEVICE); dev_kfree_skb_any(desc_params->skb_ext_desc); } @@ -744,7 +744,7 @@ static void ath12k_dp_tx_complete_msdu(struct ath12k *ar, dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); if (skb_cb->paddr_ext_desc) { dma_unmap_single(ab->dev, skb_cb->paddr_ext_desc, - sizeof(struct hal_tx_msdu_ext_desc), DMA_TO_DEVICE); + desc_params->skb_ext_desc->len, DMA_TO_DEVICE); dev_kfree_skb_any(desc_params->skb_ext_desc); }