Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1262231pxb; Fri, 21 Jan 2022 13:43:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTZ+JTFAuPRmN3Wxi3v9+dvxYQidYFWMKx7y9k1r2etsHJf0A8CqhsE+JgnytLEM7KFZ91 X-Received: by 2002:a05:6a00:190a:b0:4c4:7273:6aed with SMTP id y10-20020a056a00190a00b004c472736aedmr5196217pfi.33.1642801416414; Fri, 21 Jan 2022 13:43:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642801416; cv=none; d=google.com; s=arc-20160816; b=aF7NmJNPlVMFEeWuhDHMsaDUnLX3e+a9Mlv2CwumLgQqYkhV8ttp2XVQHS4oKPpKmX PFYIL3ZvHwB+2/VQQDK155mbupK6Cg6A4bulGqindGL8Z7f8z1/DQKpIOHwEDcG7uC1N +IPZLDV4zdsTzZqwWerH4/ZHhoNLAHnLTWcAXJdEncbXllkUmmGAvWQ3kYTiLfWO2qlu YshvJTD+/LX14IbhILfMQdwAA+8JzGiOq9UTMxBkzR2ZktfqG0duCBDZ2McRfGPSotOQ f7rk1GF6YWFl7TNr5t1Atbt4TJ3ChmWy8ZAOgDSJ0J20f3sqmKdHT7pYkq9xExdyUEHx R9bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kaKXoS/ZUXkPQw5+HCkljIklLBaX5aq1QO7I9hILOMA=; b=WhP8OO6tDXO9o++1e2PfJDE5SJKO6AZInK7dmybQKRjepz8G9muXCRLrrEg2UFb03E MkhHPWFireZbWdEEYoX00VC7JeDDXZILinGHgogEjKvVlkQGS7v6NW0mhJFGZuNL5u4/ qba/3J//p0+jXAULTECPJSTkf7Y3M6iam+WSi8KFS0sLSE9wXAz5QMdXqgzYYb6DnW9C pFS7vMDXxUjrOwL5GhJ+HdfHNlwMAfoiVe+p3NR8xhQDNpo8/EUQnsBF/nKyk/PYrjDS v+RcMDVPP6Fhfyep2o9IM2HWcqoQAetsSEpqGwdxF57AmC2XOSgApmxxZZPLBLT3jOXr VC4g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si3060799pfo.306.2022.01.21.13.43.24; Fri, 21 Jan 2022 13:43:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231574AbiATLbD (ORCPT + 99 others); Thu, 20 Jan 2022 06:31:03 -0500 Received: from foss.arm.com ([217.140.110.172]:34304 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231479AbiATLbC (ORCPT ); Thu, 20 Jan 2022 06:31:02 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7CE47101E; Thu, 20 Jan 2022 03:31:02 -0800 (PST) Received: from e121896.arm.com (unknown [10.57.37.233]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9CCD63F774; Thu, 20 Jan 2022 03:31:00 -0800 (PST) From: James Clark To: mathieu.poirier@linaro.org, coresight@lists.linaro.org, mike.leach@linaro.org Cc: suzuki.poulose@arm.com, leo.yan@linaro.com, James Clark , Leo Yan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/1] coresight: Fix TRCCONFIGR.QE sysfs interface Date: Thu, 20 Jan 2022 11:30:47 +0000 Message-Id: <20220120113047.2839622-2-james.clark@arm.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20220120113047.2839622-1-james.clark@arm.com> References: <20220120113047.2839622-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's impossible to program a valid value for TRCCONFIGR.QE when TRCIDR0.QSUPP==0b10. In that case the following is true: Q element support is implemented, and only supports Q elements without instruction counts. TRCCONFIGR.QE can only take the values 0b00 or 0b11. Currently the low bit of QSUPP is checked to see if the low bit of QE can be written to, but as you can see when QSUPP==0b10 the low bit is cleared making it impossible to ever write the only valid value of 0b11 to QE. 0b10 would be written instead, which is a reserved QE value even for all values of QSUPP. The fix is to allow writing the low bit of QE for any non zero value of QSUPP. This change also ensures that the low bit is always set, even when the user attempts to only set the high bit. Signed-off-by: James Clark Reviewed-by: Mike Leach --- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c index a0640fa5c55b..57e94424a8d6 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c @@ -367,8 +367,12 @@ static ssize_t mode_store(struct device *dev, mode = ETM_MODE_QELEM(config->mode); /* start by clearing QE bits */ config->cfg &= ~(BIT(13) | BIT(14)); - /* if supported, Q elements with instruction counts are enabled */ - if ((mode & BIT(0)) && (drvdata->q_support & BIT(0))) + /* + * if supported, Q elements with instruction counts are enabled. + * Always set the low bit for any requested mode. Valid combos are + * 0b00, 0b01 and 0b11. + */ + if (mode && drvdata->q_support) config->cfg |= BIT(13); /* * if supported, Q elements with and without instruction -- 2.28.0