Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp594134pxb; Wed, 27 Jan 2021 16:09:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvxm/rjezqAgxtHDO82Iyg+GP0l4rLBlEPoARK+h4nsXZVQpH+I6i9VH7hM1n2Ps4zNWmh X-Received: by 2002:a17:906:3146:: with SMTP id e6mr8331132eje.363.1611792569922; Wed, 27 Jan 2021 16:09:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792569; cv=none; d=google.com; s=arc-20160816; b=K0Qujr5nJJKjsKTXQgNgTaOxxxnYGK01Pmy2fgdu49Qz/Zw0MlsIdnEIe5rXl7BxW2 EtkXIA2+aqzN4IGsA0XTT13gYUsKxwl/QAMhw6eEj5iYBHN9HkkeMTQ5aEuPD7Pw47RP FYB6APQFtRCZCRIvMg1HqkyquLMrOZolKmhEaIB79jRUiI3r9l4pMnG/sRPpiD6oh8QX rqrxqnHsQFr0hopoWALM3rzppE3n5+cE7trdU/jLd4Z7p2ETGQINQN+4Y8TqAv/3X4Ek weYN+oJrfdJ0SEWkGeUkniROCnTPYKaOJBQkMuThhZyajRUhcs8mIYwqEk5LfpGvK/nh A+gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7sj7pim5IetR456CHcvRdOi+mjzmrDoe/hWhqa9Dot0=; b=U2skAt9N882CZgcVkQ7Hl11XbWx/R70INhOKj2UOyDIlqBssYaZK18k5Rj+WITcSoK OHOoQA6qgL26ijz9di0acFKLUmJvpJWFAXNPAUimmmiUEHXvO2coiw/yWv5zwDPNhEvt /+gSaU0eV/Wsh+z5LmoB7tbVaWy+LqLpHAdb6A378f+/FCfq3d5XJIcf6f4N5rrxgkT7 qsyJK+qYTpfRxnHIkCXojJaelnTlSOg+hroAabs4MrKGEGSs60uN5B5Ia54Xa1hUwPGE NYZsGUpGcAsk4GAqxihj9t2jplxygYECPOLtLgyAQ5h9fKHePdhvOX5PfleOSyhmWRfJ tUPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nZn951up; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r2si1727066edv.308.2021.01.27.16.09.05; Wed, 27 Jan 2021 16:09:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nZn951up; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236395AbhA0Ro6 (ORCPT + 99 others); Wed, 27 Jan 2021 12:44:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344109AbhA0RoX (ORCPT ); Wed, 27 Jan 2021 12:44:23 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C62C06174A for ; Wed, 27 Jan 2021 09:43:43 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id t29so1647630pfg.11 for ; Wed, 27 Jan 2021 09:43:43 -0800 (PST) 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=7sj7pim5IetR456CHcvRdOi+mjzmrDoe/hWhqa9Dot0=; b=nZn951upXHINIYPKAhqqnA0gSx9fm6BFVM/jP6hftSq00DD9x0fQ79puVIjzJIf+Wy iz9lW1hiLD0uRu0nh13kS4yHg7O3hEcaW0s59nyCqYBxc053a/nqV04OX2KJSn7J44g+ V8moEFcNU3aSxiW1iWkOW/VanCas20nn/jHn9FJLLkkkc2maImUnd6Ldl7xHRe4sU/lS GjaY2uNfKEAvsh2J9AP/NRQp/iqK17FHew7+NCrz1GulAxqmMrqdpVNtJk6QyHIP20U6 NiRec482FiU3hQ8fIjjs06E1pqCY2G3DBMZqGbJBGe6TmcSLPnjcz+EIwl7eQWVhT1ll 84cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7sj7pim5IetR456CHcvRdOi+mjzmrDoe/hWhqa9Dot0=; b=ptDzJNXM2m3AMnOFVcE55tTs270x45Q0g63OH3jhpbs+ItlgBrrq+e0U44IDhfuGxn dya6HoWEg4YQxN1eTEpvAUjWt0HfO2DiORlt78whn7cdHA42NwVDyzJsKHyV8F3nbhdD jznwpsobCIrELcy7++SLBf/NjHMYPKhpcCdyUdVmgS7b6UlcZAHF5re07zguCy+o9tyV lH53wN4ekr7uMvun9vir/GercQAuetf1j82ztZ3mp2Ug+y6yIjzUYDFb2awUG9Bw9AK+ cyxoKO0S7mHNMLoNtsZFw0GnbO+WLPE9RPkID7q8mC8Y1qlABX3rvDd1gwu/pwhmMFVI go6A== X-Gm-Message-State: AOAM532vFYiHj/byIsKnRH0d933WDrRJnG6hSy5NljEnVll5xC94iP2R XCBPfnP5qcfAgmkMjvuKPlpUdQ== X-Received: by 2002:a05:6a00:2286:b029:1ae:6c7f:31ce with SMTP id f6-20020a056a002286b02901ae6c7f31cemr11645761pfe.6.1611769423153; Wed, 27 Jan 2021 09:43:43 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 6sm2918057pfz.34.2021.01.27.09.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jan 2021 09:43:42 -0800 (PST) Date: Wed, 27 Jan 2021 10:43:40 -0700 From: Mathieu Poirier To: Suzuki K Poulose Cc: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Leo Yan , Mike Leach Subject: Re: [PATCH v2] coresight: etm4x: Handle accesses to TRCSTALLCTLR Message-ID: <20210127174340.GA1162729@xps15> References: <20210126145614.3607093-1-suzuki.poulose@arm.com> <20210127120032.3611851-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210127120032.3611851-1-suzuki.poulose@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Good day, On Wed, Jan 27, 2021 at 12:00:32PM +0000, Suzuki K Poulose wrote: > TRCSTALLCTLR register is only implemented if > > TRCIDR3.STALLCTL == 0b1 > > Make sure the driver touches the register only it is implemented. > > Cc: stable@vger.kernel.org > Cc: Mathieu Poirier > Cc: Leo Yan > Cc: Mike Leach > Signed-off-by: Suzuki K Poulose > --- > Changes since v1: > - No change to the patch, fixed the stable email address and > added usual reviewers. > --- > drivers/hwtracing/coresight/coresight-etm4x-core.c | 9 ++++++--- > drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 3 +++ > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index b40e3c2bf818..814b49dae0c7 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -367,7 +367,8 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata) > etm4x_relaxed_write32(csa, 0x0, TRCAUXCTLR); > etm4x_relaxed_write32(csa, config->eventctrl0, TRCEVENTCTL0R); > etm4x_relaxed_write32(csa, config->eventctrl1, TRCEVENTCTL1R); > - etm4x_relaxed_write32(csa, config->stall_ctrl, TRCSTALLCTLR); > + if (drvdata->stallctl) > + etm4x_relaxed_write32(csa, config->stall_ctrl, TRCSTALLCTLR); > etm4x_relaxed_write32(csa, config->ts_ctrl, TRCTSCTLR); > etm4x_relaxed_write32(csa, config->syncfreq, TRCSYNCPR); > etm4x_relaxed_write32(csa, config->ccctlr, TRCCCCTLR); > @@ -1545,7 +1546,8 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) > state->trcauxctlr = etm4x_read32(csa, TRCAUXCTLR); > state->trceventctl0r = etm4x_read32(csa, TRCEVENTCTL0R); > state->trceventctl1r = etm4x_read32(csa, TRCEVENTCTL1R); > - state->trcstallctlr = etm4x_read32(csa, TRCSTALLCTLR); > + if (drvdata->stallctl) > + state->trcstallctlr = etm4x_read32(csa, TRCSTALLCTLR); > state->trctsctlr = etm4x_read32(csa, TRCTSCTLR); > state->trcsyncpr = etm4x_read32(csa, TRCSYNCPR); > state->trcccctlr = etm4x_read32(csa, TRCCCCTLR); > @@ -1657,7 +1659,8 @@ static void etm4_cpu_restore(struct etmv4_drvdata *drvdata) > etm4x_relaxed_write32(csa, state->trcauxctlr, TRCAUXCTLR); > etm4x_relaxed_write32(csa, state->trceventctl0r, TRCEVENTCTL0R); > etm4x_relaxed_write32(csa, state->trceventctl1r, TRCEVENTCTL1R); > - etm4x_relaxed_write32(csa, state->trcstallctlr, TRCSTALLCTLR); > + if (drvdata->stallctl) > + etm4x_relaxed_write32(csa, state->trcstallctlr, TRCSTALLCTLR); > etm4x_relaxed_write32(csa, state->trctsctlr, TRCTSCTLR); > etm4x_relaxed_write32(csa, state->trcsyncpr, TRCSYNCPR); > etm4x_relaxed_write32(csa, state->trcccctlr, TRCCCCTLR); > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c > index 1c490bcef3ad..cd9249fbf913 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c > @@ -296,6 +296,9 @@ static ssize_t mode_store(struct device *dev, > if (kstrtoul(buf, 16, &val)) > return -EINVAL; > > + if ((val & ETM_MODE_ISTALL_EN) && !drvdata->stallctl) > + return -EINVAL; > + We have two choices here: 1) Follow what is already done in this function for implementation define options like ETM_MODE_BB, ETMv4_MODE_CTXID, ETM_MODE_RETURNSTACK and others. In that case we would have: /* bit[8], Instruction stall bit */ if ((config->mode & ETM_MODE_ISTALL_EN) && drvdata->stallctl == true)) config->stall_ctrl |= BIT(8); else config->stall_ctrl &= ~BIT(8); 2) Return -EINVAL when something is not supported, like you have above. In that case we'd have to enact the same behavior for all the options, which has the potential of breaking user space. I think option 1 is best. Thanks, Mathieu > spin_lock(&drvdata->spinlock); > config->mode = val & ETMv4_MODE_ALL; > > -- > 2.24.1 >