Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1182680rda; Mon, 23 Oct 2023 05:21:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETSGgZ3bnlhIl0F96IFp4YnTOcBgl9YpXF+wSii9o1KJy57wbzVoYIX/hoYTwId4CDBcPO X-Received: by 2002:a05:6a00:218c:b0:6bc:c242:792e with SMTP id h12-20020a056a00218c00b006bcc242792emr7498926pfi.27.1698063661510; Mon, 23 Oct 2023 05:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698063661; cv=none; d=google.com; s=arc-20160816; b=iR0s3efv3JK4QYTMAGUk/7bGTwTRVnK6PcQiS9bCnji5uSmzayQvF+tN3VGsP6A+E4 5o5K1pexXnezm6uz8QSDsdUMpNJfeCfwHnRnc7PzTZJUbQJ9dkQDcHuhNiKO8/a/irer GczLBfzpOdDVq+RrrvXC2C6+CvA8hfL1aQWBDYMAMtBtBOeQnnAnpUTQxomgmUq6Pl28 /8oDT7kSb9eOU3F1cJg4tJ4nJ4N7yxbbMbJPGHqHlGi8YRgMpfOFGeh5Gh60tmAXzUYR LaUwmb+mVro814P1kjKvDJyB+gLSpk25K+3UrXp/125omnNk2V3RdNR7hX7B8sVEzius MudQ== 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=fPgWYWEgNTIr7MA08s0K4dAYRadYOZVIYvieHNWOzyU=; fh=qm7aCuI3HwBSpNMCiKcom7l/Oel8C3ddLUCJCBWWZgc=; b=FVM4VOuk8aBBzMpDzgpoNoNKxU7DEz9GsI03Y8F+BXXBSUnvONOAQsN3W+uUVfyo9Z +HclN9sJ0rgMX3aAtR3EDHy0Iu4vwa60d5Q6HYAdIr2OTpJywsiSP0mQPmXTrOhH8KLF CmPnDIQP3xIW+0+QoZmxtmatXVrzQjWxbn0QaECOZPru92ILJ46dafrESAGs6cQSLZde bpDOwTFnuCbWsH2IUfNUo55oD5yWTgXYxWzp2ecOOOk0bcsYSvsWtpsjr78te+brTrHK L8hKX+52Tf6LqhShILqdoUILn0IeFuAvMPnSWz8O4q0XAIN3NGzppwGrGKVWLT4OC8K3 trBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IbOcEkoQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b16-20020a637150000000b0058a09ed5ca2si6382951pgn.313.2023.10.23.05.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 05:21:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IbOcEkoQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0B0CC8076664; Mon, 23 Oct 2023 05:20:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233501AbjJWMUW (ORCPT + 99 others); Mon, 23 Oct 2023 08:20:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbjJWMUV (ORCPT ); Mon, 23 Oct 2023 08:20:21 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B80FF; Mon, 23 Oct 2023 05:20:19 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39NCKHwJ025522; Mon, 23 Oct 2023 12:20:17 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=fPgWYWEgNTIr7MA08s0K4dAYRadYOZVIYvieHNWOzyU=; b=IbOcEkoQo+Wd7Q35/UVB5BHrrNK9NzWQ01Q7a6QJW3WZG2NfmaGo4udU7sUegDbVXLRD hvfSsMGzRpXKXYWT5QhJTOkKbhlY8/YwbbMFhn5x3B5fh0hw/UrxjmtvNTe3ybao61Re xi6GMQuqPlsol/iipx8e1K0M4kLNzGewC5bd8X1FsIoc22D0wiy7vI1mZ8MET/6GVF7D g0REs0ZqXRi4CBHv6WOIlO19T6iqI8deYIXV5zTayooJrWzfmBVx/VmwaTNso2stY8FX 7GnRn3AKYT+5Je/NglVt2x+hWAgS/hnS+L6Xv/bU8rDU9tIEm0cXBnk71yrl9vRRPW9S dg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tv7u3v9yj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Oct 2023 12:20:16 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39NCJLPP020266 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Oct 2023 12:19:21 GMT Received: from [10.239.132.245] (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.39; Mon, 23 Oct 2023 05:19:16 -0700 Message-ID: <1a5b2381-8987-2f92-d018-29fdbc23b826@quicinc.com> Date: Mon, 23 Oct 2023 20:19:14 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v1 3/5] soc: qcom: memory_dump: Add memory dump driver Content-Language: en-US To: Krzysztof Kozlowski , , , , , , CC: , , , , References: <1698052857-6918-1-git-send-email-quic_zhenhuah@quicinc.com> <1698052857-6918-4-git-send-email-quic_zhenhuah@quicinc.com> <5bac8188-7d27-4efe-9493-dec4393fbeb0@linaro.org> <454c4267-6bb7-456e-8dc1-cba83ffd1641@linaro.org> From: Zhenhua Huang In-Reply-To: <454c4267-6bb7-456e-8dc1-cba83ffd1641@linaro.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: XZ8igviXklMMmkRJPc5vafmYvsyioTI9 X-Proofpoint-ORIG-GUID: XZ8igviXklMMmkRJPc5vafmYvsyioTI9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-23_10,2023-10-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 mlxlogscore=907 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310170001 definitions=main-2310230108 X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 23 Oct 2023 05:20:34 -0700 (PDT) On 2023/10/23 19:46, Krzysztof Kozlowski wrote: > On 23/10/2023 13:43, Zhenhua Huang wrote: >>>> + >>>> + mem_dump_apply_offset(&dump_vaddr, &phys_addr, >>>> + size + QCOM_DUMP_DATA_SIZE); >>>> + if (phys_addr > phys_end_addr) { >>>> + dev_err_probe(dev, -ENOMEM, "Exceeding allocated region\n"); >>> >>> ENOMEM? Does not look right then. >> >> ENOMEM means the memory allocated not enough? any suggestion? Thanks. > > The error code is okay, but we rarely need to print error messages for > memory allocation failures. Core prints it already. It's not same as below case. Allocation is successful here, while the driver used more than allocated size. > >> >>> >>>> + return -ENOMEM; >>>> + } >>>> + } else { >>>> + continue; >>>> + } >>>> + } >>>> + >>>> + return ret; >>>> +} >>>> + >>>> +static int __init mem_dump_probe(struct platform_device *pdev) >>>> +{ >>>> + struct qcom_memory_dump *memdump; >>>> + struct device *dev = &pdev->dev; >>>> + struct page *page; >>>> + size_t total_size; >>>> + int ret = 0; >>>> + >>>> + memdump = devm_kzalloc(dev, sizeof(struct qcom_memory_dump), >>>> + GFP_KERNEL); >>>> + if (!memdump) >>>> + return -ENOMEM; >>>> + >>>> + dev_set_drvdata(dev, memdump); >>>> + >>>> + /* check and initiate CMA region */ >>>> + ret = mem_dump_reserve_mem(dev); >>>> + if (ret) >>>> + return ret; >>>> + >>>> + /* allocate and populate */ >>>> + page = mem_dump_alloc_mem(dev, &total_size); >>>> + if (IS_ERR(page)) { >>>> + ret = PTR_ERR(page); >>>> + dev_err_probe(dev, ret, "mem dump alloc failed\n"); >>> >>> No, the syntax is: >>> ret = dev_err_probe >>> >>> But why do you print messgaes for memory allocations? >> >> Do you think it's useless because mm codes should print error as well if >> failure ? > > We fixed this in kernel long, long, long time ago so we have even > coccicheck scripts to find misuses. > Thanks, yeah.. I know mm codes already have for example warn_alloc() to print error messages. Thanks for pointing out. > > > Best regards, > Krzysztof > Thanks, Zhenhua