From patchwork Fri Jan 19 03:22:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Zhang X-Patchwork-Id: 189380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp770134dyb; Thu, 18 Jan 2024 19:24:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAHIEzmK8Ru3k0FPwHJVFkzmGx/msS/revg+GPKgMdMJHPN6WZHXsICUqPPZqvB85SN+Pj X-Received: by 2002:a17:902:ee8a:b0:1d6:ff4a:3acc with SMTP id a10-20020a170902ee8a00b001d6ff4a3accmr1916240pld.13.1705634684226; Thu, 18 Jan 2024 19:24:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705634684; cv=pass; d=google.com; s=arc-20160816; b=Oqd3IxliKqw54CHvFsWYMTsrnMYu1yYro1sD0KtrPosCk5k6Ac5grxaaFleC0Pv04T /T7q/4HiVSjQKDQQeZCHs+JHlzAv8rNCXcJ83/RqqRC5SvEJqtykzClx1jSAJ28Ila6B mq+Kn8sEB52LmOZHLvIq4zikqhMVZl7CPs+I9Psaqe47aHC20p76efY6xYiS1dXL5jJg nVavlIwyCfXMN4WijpoodKN4WLf1yYjKsG+OBJXspIqKkDBVRNeehqrjrGDYUPhwuM6W xR3OMH3XIVtnZViGjsvyODyZdY+1vPEMJvejNwjyCuz0AuEYc6vwYSup2Za6SuO197e7 Qvkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eG0cw3V2V7bP1GdeOMsXcfVKOjDgrWaClaMQX8x+Rcc=; fh=eSQnxfYZD66NgboVDB7L9mVH46SSiFzLE3y556oFJtg=; b=dmFmTp6pskZ8/8uKB5hZgPtsLwQOXJKUmcm5AntDTpK173dY0RRwrChPo+j4hQLHYG UVCM7SjoAuTIvzBmIq4tkg+Ul5U8OOqD7X5V3tGHuBcj3Qa7WBuBrvhvYwdKInvSd08R cInG8wUATjKFoBlp28j7Mrqed37dy4W411Vd5FrbvW381IGDCEnayjQdHBSN/tNOsOwY R/+SQkPwV5eG7paPPePwW+KMSkiZ/BEr4P8ZXLKuUV+XSsInuiDSd9vAt7wK6ycCKX1N rchrBHr7Tf40xtNOpiLiTvykgITF0kZPM4BZ65pDlMxyA19seIyhZKMLciiyDoxE3brD 4uLQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=moCEPN6T; 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-kernel+bounces-30725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30725-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k9-20020a170902694900b001d6ec26ea80si2414903plt.442.2024.01.18.19.24.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 19:24:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=moCEPN6T; 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-kernel+bounces-30725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30725-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8102CB20E5F for ; Fri, 19 Jan 2024 03:24:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E43F95381; Fri, 19 Jan 2024 03:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="moCEPN6T" 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 8A668186F; Fri, 19 Jan 2024 03:23:47 +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=1705634629; cv=none; b=SKfC4Zstmz0L0LdgAahAdY3QA0rRkAXvyQj7rpk8tzxvfMWiRZRGxtqiL5n/50VWgmm6wGzgk+JT+cIB8cw/aOFqW/ffdtJIRrcxr5ENCwUxhFWucpFlGXkamZC9uW1qrrlbwPW4YkalgO7DabSKOLLj5OO2EOoGEQqjE+s9zrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705634629; c=relaxed/simple; bh=Uewh1FnrdtUjaw3IbQp5/cVxlxfhVTRPnk+3maWKx+g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=khZAeISMvl4xQQNnOce9uezdmtkkmydrbhIAJIkhIlmjvki/kjnenXNvzI8dyFhvqvwRk2EBx25RCRGQo2xRZLEcnZSKRJ8atBbouMlOp7Bsvk/egqDPdf3YsuRVBp8hJ/o/+YF3zhwWb4GH6Ij0VDGVynPJpBrLC2+8BAqT1L0= 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=moCEPN6T; 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 (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40J0f8bZ031574; Fri, 19 Jan 2024 03:23:33 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-type; s=qcppdkim1; bh=eG0cw3V2V7bP1GdeOMsX cfVKOjDgrWaClaMQX8x+Rcc=; b=moCEPN6Tu3lLFU3iTIFnjd9XAojWFiCJfjkW N+ISLLzZYSWQnUjSIwWnDkgeIrihb9EsrpMNp/I0RR8ZQa0jlLvi2rNCOyQFzDWc dfljbvPajztqrUfo7GXbLJ3f/I9Wve5yIObYX/GN6i0tgv+JgjYrY9Cz+IxPLe04 LxY61RU5ULvFVh6IBU83kk+smcPYYzs2uQ5k+2s/3rUSc/JVn1+LSjXhT2FAON5j P+6mJzlP+KDrJp8wLxBmRsgxjLDQzthu3gs0YGgDg8gajybFn1tMfSF1dhDQsonI hN26aoFjgpmYX5ESAc6fm+oeSdANIL/UkPAPPR98OSOfjcDyEg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vq403hue3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Jan 2024 03:23:33 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40J3NWCx005461 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Jan 2024 03:23:32 GMT Received: from taozha-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 18 Jan 2024 19:23:27 -0800 From: Tao Zhang To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Konrad Dybcio , Mike Leach , Rob Herring , Krzysztof Kozlowski CC: Tao Zhang , Jinlong Mao , Leo Yan , Greg Kroah-Hartman , , , , , Tingwei Zhang , Yuanfang Zhang , Trilok Soni , Song Chai , , Subject: [PATCH v4 01/10] coresight-tpdm: Optimize the store function of tpdm simple dataset Date: Fri, 19 Jan 2024 11:22:54 +0800 Message-ID: <1705634583-17631-2-git-send-email-quic_taozha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1705634583-17631-1-git-send-email-quic_taozha@quicinc.com> References: <1705634583-17631-1-git-send-email-quic_taozha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: YKVaIyHCUjWlngrNat9x1vbWd0xlDZWy X-Proofpoint-ORIG-GUID: YKVaIyHCUjWlngrNat9x1vbWd0xlDZWy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-18_12,2024-01-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=882 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401190012 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788487594320239085 X-GMAIL-MSGID: 1788487594320239085 Replace spin lock/unlock to avoid forgetting to unlock when the function exits. And refine methods for handling various conditions. Signed-off-by: Tao Zhang --- drivers/hwtracing/coresight/coresight-tpdm.c | 39 ++++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c index bd13a548375c..0427c0fc0bf3 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.c +++ b/drivers/hwtracing/coresight/coresight-tpdm.c @@ -77,51 +77,50 @@ static ssize_t tpdm_simple_dataset_store(struct device *dev, size_t size) { unsigned long val; - ssize_t ret = size; + ssize_t ret = -EINVAL; struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct tpdm_dataset_attribute *tpdm_attr = container_of(attr, struct tpdm_dataset_attribute, attr); if (kstrtoul(buf, 0, &val)) - return -EINVAL; + return ret; - spin_lock(&drvdata->spinlock); + guard(spinlock)(&drvdata->spinlock); switch (tpdm_attr->mem) { case DSB_TRIG_PATT: - if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) + if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) { drvdata->dsb->trig_patt[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; case DSB_TRIG_PATT_MASK: - if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) + if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) { drvdata->dsb->trig_patt_mask[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; case DSB_PATT: - if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) + if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) { drvdata->dsb->patt_val[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; case DSB_PATT_MASK: - if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) + if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) { drvdata->dsb->patt_mask[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; case DSB_MSR: - if (tpdm_attr->idx < drvdata->dsb_msr_num) + if (tpdm_attr->idx < drvdata->dsb_msr_num) { drvdata->dsb->msr[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; default: - ret = -EINVAL; + break; } - spin_unlock(&drvdata->spinlock); return ret; }