Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp184302rwr; Wed, 26 Apr 2023 23:04:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IViVCmaazJUPDzmf9b3fzqjo1HzUWBQw8G3D3GV71Unh/sHrh7nLrT9cR19yfDeAf7nIs X-Received: by 2002:a05:6a21:9991:b0:f6:7bb8:c8d5 with SMTP id ve17-20020a056a21999100b000f67bb8c8d5mr618921pzb.4.1682575493872; Wed, 26 Apr 2023 23:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682575493; cv=none; d=google.com; s=arc-20160816; b=Rc70QKpyglpC9iBuL+4pkw+HYIte4f3ADWU5wSiM97QwUhIabzprv9j374vqm+am1n Wo9fAVZPuPJdX1RH6xAcQ+72AZ5SycI5lLqtomUfCZLtRR8l1QFjLD8KOuOj8HHV0zno +ZPijg/YoKr9V9Bd3FzGqeteUN85Hk5OvgsgeEEHjQ2EQxhE1anz//gVb3ndlrg0ImQ1 Pcn1K2XlKg8/Ju7rY3cglMvLtCFt3yym+8YDYT1WXC380QXTgmlLmCQ87dQS38SBQPsq oWRmECCOULZ2C7/SggtlZeQGHcbnO4mKiA1PQQsoqSecoLlyzfeJXlXPQbzAftJfaAqg QnmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=vN0o6Qy8i7AvnSzuzZtY3HpAEYkElnyWEyBF4fVyl5k=; b=AH72j4smEiU/IDMKAsJzgzn7HFW4FohjRh0IjM7WYNIfJTWdl4YTMV3ekwLHOFxkXd R6LGmDiQTUKvc+nICEByL//vpFDsD8Sc74pTRxl+GkJbo3l9Qr4qn92UnRrZDBvr8Zpo h6H3YJFwEDSXCrOagiBx8h9ItnT7cdfzAceZdVdmfynhYDhCd1dQACPjY6vF7mseVKpZ qoNzxUt35C984roO08PdJNtQRABqm96/uDpp1FPslj9oGce2kPAN4sZF24gCbDFJqnif HI/rhJFSJexKe6i1EMvWd51XXI1Y1Jmi1hAJc5SEGGmYuYKsuS2O2tzWAL/VAAcUeJ7Q 3kWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nOdTsTLK; 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 s191-20020a632cc8000000b0052868eb9742si6636463pgs.77.2023.04.26.23.04.42; Wed, 26 Apr 2023 23:04:53 -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=nOdTsTLK; 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 S242907AbjD0GBD (ORCPT + 99 others); Thu, 27 Apr 2023 02:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242693AbjD0GBB (ORCPT ); Thu, 27 Apr 2023 02:01:01 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CE291FEF; Wed, 26 Apr 2023 23:01:00 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33R5jd8H019935; Thu, 27 Apr 2023 06:00:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=vN0o6Qy8i7AvnSzuzZtY3HpAEYkElnyWEyBF4fVyl5k=; b=nOdTsTLKdQQ8qWOUbUUI6O6+2XA839iYzOvWWbYO8shuZi9+zRgjP7I0IeD4OjzHvf+Q hu6sF1+dpdkGZgvNWSS4cCqLUVc4c8VxoX5NQ1Lz1laji7YuNzXDGwF/mZaB/hi6U92B iMrhkUZKIaYdbgl7odfY2/t0jTJTyj5XZgBQ7chMOw+XR/xEt7l6MWzt0ThiwFuEeKbw a8Fid4AkiR03VwDPxNBdacTmCWSF03eixCivYF0pb9AcImkX4frwxnWkZ3yZS/NnfVmI hCMD6CP3cSVlrrV7F5dfaAE8TclmlQ7YkMSp6AhAS6XRSlKPkAht6ozcPAbp+7Mw3LuY YA== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q72jfa5c2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Apr 2023 06:00:31 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 33R60V0R014751 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Apr 2023 06:00:31 GMT Received: from stor-berry.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 26 Apr 2023 23:00:30 -0700 From: "Bao D. Nguyen" To: , , , , , , , , CC: , "Bao D. Nguyen" , Alim Akhtar , "James E.J. Bottomley" , Alice Chao , open list Subject: [PATCH v1 1/1] scsi: ufs: core: correct utp_transfer_cmd_desc size Date: Wed, 26 Apr 2023 22:59:41 -0700 Message-ID: <4b778dbcfd1fc40140292166834f13e8d5b8e4d2.1682575115.git.quic_nguyenb@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 8OUEKGPbBBS1PxHznBnaa10TH2FEZqZZ X-Proofpoint-ORIG-GUID: 8OUEKGPbBBS1PxHznBnaa10TH2FEZqZZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-27_03,2023-04-26_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 bulkscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304270054 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 When allocating memory for the UTP Command Descriptor hba->ucdl_base_addr in ufshcd_memory_alloc(), the macro sizeof_utp_transfer_cmd_desc() is used to calculate the size of the memory allocation. This macro includes the prd_table as part of the UTP Command Descriptor memory. However, when freeing this memory in the ufshcd_release_sdb_queue(), the sizeof(struct utp_transfer_cmd_desc) is used, and it does not include the prd_table size for the memory to be freed. This results in a mismatch of memory size allocated/freed. Similarly, the ufshcd_mcq_get_tag() incorrectly uses the sizeof(struct utp_transfer_cmd_desc) to find the tag number. This results in failing to probe. Signed-off-by: Bao D. Nguyen --- drivers/ufs/core/ufs-mcq.c | 2 +- drivers/ufs/core/ufshcd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 202ff71..b7c5f39 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -265,7 +265,7 @@ static int ufshcd_mcq_get_tag(struct ufs_hba *hba, addr = (le64_to_cpu(cqe->command_desc_base_addr) & CQE_UCD_BA) - hba->ucdl_dma_addr; - return div_u64(addr, sizeof(struct utp_transfer_cmd_desc)); + return div_u64(addr, sizeof_utp_transfer_cmd_desc(hba)); } static void ufshcd_mcq_process_cqe(struct ufs_hba *hba, diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 9434328..b009e55 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8444,7 +8444,7 @@ static void ufshcd_release_sdb_queue(struct ufs_hba *hba, int nutrs) { size_t ucdl_size, utrdl_size; - ucdl_size = sizeof(struct utp_transfer_cmd_desc) * nutrs; + ucdl_size = sizeof_utp_transfer_cmd_desc(hba) * nutrs; dmam_free_coherent(hba->dev, ucdl_size, hba->ucdl_base_addr, hba->ucdl_dma_addr); -- 2.7.4