Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1556739pxb; Tue, 8 Feb 2022 22:10:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqkR3bQd7Y23qjmAXAqKoy2Iz3rTx88SIZ9YjI0Iop602qy1pJsFnoWNXzkAaAVj8owaUx X-Received: by 2002:a63:ed58:: with SMTP id m24mr697182pgk.33.1644387053022; Tue, 08 Feb 2022 22:10:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644387053; cv=none; d=google.com; s=arc-20160816; b=p2tncprI2OW81aa2ebXltyVsRlIQ78+QOFE6e9qYkNMqs4VsatF6J/lje9lYelWH50 TZVVAnxpIiBGs+WFVxyCM8VF1k5hdis45wWktSyBp77xICvoYKavlEbml7O+6fFABRoa ayPc75/J9idTWAzd61E4noThoEB0/N7mnAWDrkNS3dvlI62rhhUZlyHXEbK946zHvfCN hRQ5m6Fh70EAThdR8eJezDhuwL6Vy9R6TreN2Hi0sPtdlg2VlbPkDj4E7KDyLqf6TE6x aOzyJhQ95fQ33TKT9v2rRITKDwnkegQfAlY6L3YHu3pMB54kN2vN/0YA5HZe9wQx9hUL Ln4Q== 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 :mime-version:user-agent:date:message-id:from:references:to:subject :cc; bh=7zloHtvOZr+piCmYJUyMFAwaQ5jKppQLa2HPO8ZGm9E=; b=K6iw/piXTO2rmgCkbM3pEcOoXYTlLIYyzuqed8jjXieaw9BVD55U0o9uQpmUHtkjwB NHBThwnOwMKt0Dg5fvT+865ufITCraOgyfxVZiHxXUlLE139jultqk6DGYZH5dDjQfUf qAgY+4A0aY0YC+lBrnhQk/2TPzvjRx/5hllOh8S3SyN9LmV5O+y/1rRDdhC1tJbhRVMm JxKAzjeBnJ7NBTe9NHVk5c6AVFkJnyhb7aYf4FUufpw0NJguD4AmsKCyuw36vehrwMPC E2PmnumAJIW1B6LU+yUdpomU6082qyK60ZTaGZ+XSfoyWnwl50wNsOHgCYdCKSu/cWU2 XhQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u16si1775433plg.209.2022.02.08.22.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:10:53 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8A69ADF28AF3; Tue, 8 Feb 2022 21:55:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347883AbiBHHJD (ORCPT + 99 others); Tue, 8 Feb 2022 02:09:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230332AbiBHHJB (ORCPT ); Tue, 8 Feb 2022 02:09:01 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A8E9C0401F1; Mon, 7 Feb 2022 23:08:58 -0800 (PST) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4JtDXX4dRZz1FD31; Tue, 8 Feb 2022 15:04:44 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 8 Feb 2022 15:08:55 +0800 CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v3 4/8] hisi_ptt: Add tune function support for HiSilicon PCIe Tune and Trace device To: Jonathan Cameron , Yicong Yang References: <20220124131118.17887-1-yangyicong@hisilicon.com> <20220124131118.17887-5-yangyicong@hisilicon.com> <20220207114911.0000127e@Huawei.com> From: Yicong Yang Message-ID: <15ebb616-bc5a-f589-a435-c8322202661a@huawei.com> Date: Tue, 8 Feb 2022 15:08:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20220207114911.0000127e@Huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 2022/2/7 19:49, Jonathan Cameron wrote: > On Mon, 24 Jan 2022 21:11:14 +0800 > Yicong Yang wrote: > >> Add tune function for the HiSilicon Tune and Trace device. The interface >> of tune is exposed through sysfs attributes of PTT PMU device. >> >> Signed-off-by: Yicong Yang > > A few trivial things inline, but looks good in general to me. > With those tidied up > Reviewed-by: Jonathan Cameron > Thanks for the comments. > >> --- >> drivers/hwtracing/ptt/hisi_ptt.c | 154 +++++++++++++++++++++++++++++++ >> drivers/hwtracing/ptt/hisi_ptt.h | 19 ++++ >> 2 files changed, 173 insertions(+) >> >> diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c >> index 2994354e690b..b11e702eb506 100644 >> --- a/drivers/hwtracing/ptt/hisi_ptt.c >> +++ b/drivers/hwtracing/ptt/hisi_ptt.c >> @@ -21,6 +21,159 @@ >> >> #include "hisi_ptt.h" >> >> +static int hisi_ptt_wait_tuning_finish(struct hisi_ptt *hisi_ptt) >> +{ >> + u32 val; >> + >> + return readl_poll_timeout(hisi_ptt->iobase + HISI_PTT_TUNING_INT_STAT, >> + val, !(val & HISI_PTT_TUNING_INT_STAT_MASK), >> + HISI_PTT_WAIT_POLL_INTERVAL_US, >> + HISI_PTT_WAIT_TIMEOUT_US); >> +} >> + >> +static int hisi_ptt_tune_data_get(struct hisi_ptt *hisi_ptt, >> + u32 event, u16 *data) >> +{ >> + u32 reg; >> + >> + reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); >> + reg &= ~(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB); >> + reg |= FIELD_PREP(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB, >> + event); >> + writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); >> + >> + /* Write all 1 to indicates it's the read process */ >> + writel(~0UL, hisi_ptt->iobase + HISI_PTT_TUNING_DATA); > > Just to check, this is includes the bits above the DATA_VAL_MASK? > Fine if so, just seems odd to define a field but then write > parts of the register that aren't part of that field. > yes. The valid data field is [0,15]. But all 1 is used here to indicate that it's a read process rather than a write process. >> + >> + if (hisi_ptt_wait_tuning_finish(hisi_ptt)) >> + return -ETIMEDOUT; >> + >> + reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_DATA); >> + reg &= HISI_PTT_TUNING_DATA_VAL_MASK; >> + *data = (u16)reg; > > As below, prefer a FIELD_GET() for this. > sure. will use field ops here and below. Thanks. >> + >> + return 0; >> +} >> + >> +static int hisi_ptt_tune_data_set(struct hisi_ptt *hisi_ptt, >> + u32 event, u16 data) >> +{ >> + u32 reg; >> + >> + reg = readl(hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); >> + reg &= ~(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB); >> + reg |= FIELD_PREP(HISI_PTT_TUNING_CTRL_CODE | HISI_PTT_TUNING_CTRL_SUB, >> + event); >> + writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_CTRL); >> + >> + reg = data; > Given you defined HISI_PTT_TUNING_DATA_VAL_MASK why not use it here > > writel(FIELD_PREP(..), ...)? > >> + writel(reg, hisi_ptt->iobase + HISI_PTT_TUNING_DATA); >> + >> + if (hisi_ptt_wait_tuning_finish(hisi_ptt)) >> + return -ETIMEDOUT; >> + >> + return 0; >> +} >> + > > > . >