From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2ADFC433EF for ; Thu, 4 Nov 2021 17:04:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B34B761186 for ; Thu, 4 Nov 2021 17:04:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B34B761186 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vCig1N9bxFz54sX/aLSQjZXgr7jahyapQBjvrosmKxY=; b=zK+fiZKz5x/GPN jqj+lD3yHS6jkfgZS/fS3cG3UQ/Wf5gLGDawlm10ZGzjBlD232gnZxEOboEMYDGnH2G1t49uPhxDm Z4gatMCgb1ZZZi2kdu2KZuAx+HC6jkQqZjBM2225kPkkWuoeq6UC7HcQaQUGJ90dx65BE7uW+oClz XzjLR1pfMx1qdvKznJsAyO+ZMMe6B5KMtTc2q+H7hnTEWIHQYOFzNsiEezX3wesTzfBlXarwK5vpv llICoOVvbQhVcuZyLGhDxFH1+O161FjA9F4wGQFELP+mu83u+DnAz58oI7vBrFfBL4FyacRMcoevk 4+G5NHtXDmNcBVDHMoIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mig8M-009Zsy-1u; Thu, 04 Nov 2021 17:02:38 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mig8I-009ZrU-DI for linux-arm-kernel@lists.infradead.org; Thu, 04 Nov 2021 17:02:36 +0000 Received: by mail-pf1-x435.google.com with SMTP id h74so6484949pfe.0 for ; Thu, 04 Nov 2021 10:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kyrDUfuVkXm+XYvJWKWEhg86DR2JDBASsY+NzkY4H5M=; b=FyM3fY5C+tQ/SrtcxhYUoh4Yf4COR8b9eQliX++1pz8SkK90IMEieuA2EQzrzRJa0T uykM6vcEUoc6MCroY9fmR9lJBAWDELZ7BP1qnWzMcpwuN4Q0gtAnpb8ok+/2JFy+fs7+ PDcKfowhz5rc6IQjGT9jolEBgUb+z3rY8MisEeJX/SM3hgsD/lhs2UrapTcSDQgOvIM+ YSfFDhmT4ZZDHeuxNozcoUtg5E2VQea269+x+iMf1YiVbHruxKHFJtGIiJeHfF8y9Zg1 s4qq8h9xOjiPAj18g+6ON90taHVQ4s137lCi4Q7SyZoTvJe80an/gMhaQe9tlI0l+vT1 N1NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kyrDUfuVkXm+XYvJWKWEhg86DR2JDBASsY+NzkY4H5M=; b=t8ctXqJsW4xb5FP7Yvk08+9cMmowP/28bVcYbBpeS3N7A0Re/e8goYcNGtirl1COyO eKz6KW7JggDb8GOWBEGJlZ8ooEnTasZPyKDgmzf6Q7rjfGGs8CEQ9xs6ThyyCnjBWsAk 1bLEO8F2/rbDVLO5MN7I47LGHCM8YAR2Aa3X2WriqmkZKvLLeNoXmg1D5UeME8WViV5H e6+x6s3l/B5JqF4Ib+tWFuF8DydtIsVXffm4PplVWNdcs1D8VK6/g4e49LjVZWU0/9Rv pp93bKqT6IJvk370Jp/qzvL22oVOowrxBajnUPyJayPonFPHvpWBrQoFgjQntAHiKlBg Apvw== X-Gm-Message-State: AOAM533UXUahylzRiFHhylOFQHTy7NCFqPNCSS/ApDtWUYguTN8k9+c2 QJ9syh/54C5AbJZMywvnnxn0Jw== X-Google-Smtp-Source: ABdhPJzm+gz3+BU+45kA+pAFzkwjDU4S1W55FonrLk4cJP2ws02a+5SqS34Q3gMI106h6N8dqsFZQg== X-Received: by 2002:a05:6a00:2405:b0:3e1:9f65:9703 with SMTP id z5-20020a056a00240500b003e19f659703mr54051327pfh.6.1636045349432; Thu, 04 Nov 2021 10:02:29 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id p3sm5267413pfb.205.2021.11.04.10.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Nov 2021 10:02:26 -0700 (PDT) Date: Thu, 4 Nov 2021 11:02:24 -0600 From: Mathieu Poirier To: Jinlong Cc: Tao Zhang , Suzuki K Poulose , Alexander Shishkin , Mike Leach , Leo Yan , Greg Kroah-Hartman , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei Zhang , Yuanfang Zhang , Trilok Soni Subject: Re: [PATCH 04/10] Coresight: Enable BC and GPR for TPDM driver Message-ID: <20211104170224.GC491267@p14s> References: <1634801936-15080-1-git-send-email-quic_taozha@quicinc.com> <1634801936-15080-5-git-send-email-quic_taozha@quicinc.com> <20211103194300.GA383984@p14s> <20211104111323.GA14135@jinlmao-gv.ap.qualcomm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211104111323.GA14135@jinlmao-gv.ap.qualcomm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211104_100234_488579_850C4113 X-CRM114-Status: GOOD ( 30.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [...] > > > + > > > +static ssize_t reset_store(struct device *dev, > > > + struct device_attribute *attr, > > > + const char *buf, > > > + size_t size) > > > +{ > > > + int ret = 0; > > > + unsigned long val; > > > + struct mcmb_dataset *mcmb_temp = NULL; > > > + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); > > > + > > > + ret = kstrtoul(buf, 10, &val); > > > > The coresight subsystem normally uses the hexadecimal base. > > > > We will address you comments. > > > > + if (ret) > > > + return ret; > > > > Shouldn't this be "if (!ret)" ? > > > > When ret is not 0, it need to return. I would expect something like this: $ echo 1 > /sys/path/to/tpdm/device/reset and not $ echo 0 > /sys/path/to/tpdm/device/reset The latter is what the code does. Thanks, Mathieu > > > > + > > > + mutex_lock(&drvdata->lock); > > > + /* Reset all datasets to ZERO */ > > > + if (drvdata->gpr != NULL) > > > + memset(drvdata->gpr, 0, sizeof(struct gpr_dataset)); > > > + > > > + if (drvdata->bc != NULL) > > > + memset(drvdata->bc, 0, sizeof(struct bc_dataset)); > > > + > > > + if (drvdata->tc != NULL) > > > + memset(drvdata->tc, 0, sizeof(struct tc_dataset)); > > > + > > > + if (drvdata->dsb != NULL) > > > + memset(drvdata->dsb, 0, sizeof(struct dsb_dataset)); > > > + > > > + if (drvdata->cmb != NULL) { > > > + if (drvdata->cmb->mcmb != NULL) { > > > + mcmb_temp = drvdata->cmb->mcmb; > > > + memset(drvdata->cmb->mcmb, 0, > > > + sizeof(struct mcmb_dataset)); > > > + } > > > + > > > + memset(drvdata->cmb, 0, sizeof(struct cmb_dataset)); > > > + drvdata->cmb->mcmb = mcmb_temp; > > > + } > > > + /* Init the default data */ > > > + tpdm_init_default_data(drvdata); > > > + > > > + mutex_unlock(&drvdata->lock); > > > + > > > + /* Disable tpdm if enabled */ > > > + if (drvdata->enable) > > > + coresight_disable(drvdata->csdev); > > > > Why is this done out of the lock? > > > > When call coresight_disable, tpdm_disable will be called. There is lock in tpdm_disable. > If add it into the lock, there will be dead lock. > > > > + > > > + return size; > > > +} > > > +static DEVICE_ATTR_WO(reset); > > > + > > > +static ssize_t integration_test_store(struct device *dev, > > > + struct device_attribute *attr, > > > + const char *buf, > > > + size_t size) > > > +{ > > > + int i, ret = 0; > > > + unsigned long val; > > > + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); > > > + > > > + ret = kstrtoul(buf, 10, &val); > > > + if (ret) > > > + return ret; > > > + > > > + if (val != 1 && val != 2) > > > + return -EINVAL; > > > + > > > + if (!drvdata->enable) > > > + return -EINVAL; > > > + > > > + if (val == 1) > > > + val = ATBCNTRL_VAL_64; > > > + else > > > + val = ATBCNTRL_VAL_32; > > > + TPDM_UNLOCK(drvdata); > > > + tpdm_writel(drvdata, 0x1, TPDM_ITCNTRL); > > > + > > > + for (i = 1; i < 5; i++) > > > + tpdm_writel(drvdata, val, TPDM_ITATBCNTRL); > > > + > > > + tpdm_writel(drvdata, 0, TPDM_ITCNTRL); > > > + TPDM_LOCK(drvdata); > > > + return size; > > > +} > > > +static DEVICE_ATTR_WO(integration_test); > > > > Integration test interface should be conditional to a compile time option. Have > > a look at what was done for CTIs. > > > > We will check and update. > > > > + > > > +static ssize_t gp_regs_show(struct device *dev, > > > + struct device_attribute *attr, > > > + char *buf) > > > +{ > > > + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); > > > + ssize_t size = 0; > > > + int i = 0; > > > + > > > + if (!test_bit(TPDM_DS_GPR, drvdata->datasets)) > > > + return -EPERM; > > > > return -EINVAL; > > > > > + > > > + mutex_lock(&drvdata->lock); > > > + for (i = 0; i < TPDM_GPR_REGS_MAX; i++) { > > > + if (!test_bit(i, drvdata->gpr->gpr_dirty)) > > > + continue; > > > + size += scnprintf(buf + size, PAGE_SIZE - size, > > > + "Index: 0x%x Value: 0x%x\n", i, > > > + drvdata->gpr->gp_regs[i]); > > > > This should not be - the sysfs interface requires outputs of a single line. > > > > We will check and update. > > > > + } > > > + mutex_unlock(&drvdata->lock); > > > + return size; > > > +} > > > + > > > +static ssize_t gp_regs_store(struct device *dev, > > > + struct device_attribute *attr, > > > + const char *buf, > > > + size_t size) > > > +{ > > > + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); > > > + unsigned long index, val; > > > + > > > + if (sscanf(buf, "%lx %lx", &index, &val) != 2) > > > + return -EINVAL; > > > + if (!test_bit(TPDM_DS_GPR, drvdata->datasets) || > > > + index >= TPDM_GPR_REGS_MAX) > > > + return -EPERM; > > > + > > > + mutex_lock(&drvdata->lock); > > > + drvdata->gpr->gp_regs[index] = val; > > > + __set_bit(index, drvdata->gpr->gpr_dirty); > > > + mutex_unlock(&drvdata->lock); > > > + return size; > > > +} > > > +static DEVICE_ATTR_RW(gp_regs); > > > + > > > +static struct attribute *tpdm_attrs[] = { > > > + &dev_attr_available_datasets.attr, > > > + &dev_attr_enable_datasets.attr, > > > + &dev_attr_reset.attr, > > > + &dev_attr_integration_test.attr, > > > + &dev_attr_gp_regs.attr, > > > + NULL, > > > +}; > > > > All new sysfs interface need to be documented. See here: > > > > Documentation/ABI/testing/sysfs-bus-coresight-devices-xyz > > > > More comments to come... > > > > We will add the comments. > > > Thanks, > > Mathieu > > > > > + > > > +static struct attribute_group tpdm_attr_grp = { > > > + .attrs = tpdm_attrs, > > > +}; > > > +static const struct attribute_group *tpdm_attr_grps[] = { > > > + &tpdm_attr_grp, > > > + NULL, > > > +}; > > > + > > > static int tpdm_datasets_alloc(struct tpdm_drvdata *drvdata) > > > { > > > if (test_bit(TPDM_DS_GPR, drvdata->datasets)) { > > > @@ -513,6 +846,7 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id) > > > desc.ops = &tpdm_cs_ops; > > > desc.pdata = adev->dev.platform_data; > > > desc.dev = &adev->dev; > > > + desc.groups = tpdm_attr_grps; > > > drvdata->csdev = coresight_register(&desc); > > > if (IS_ERR(drvdata->csdev)) > > > return PTR_ERR(drvdata->csdev); > > > -- > > > 2.17.1 > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel