Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp748732pxb; Tue, 5 Apr 2022 21:37:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMLedLqQQt2mhbVji1w4rrUheGzFmkND1gTIsohhUmeoSa62nImRkyo75vhaq8ZtE/JKJ1 X-Received: by 2002:a63:656:0:b0:385:f723:5245 with SMTP id 83-20020a630656000000b00385f7235245mr5590803pgg.496.1649219839322; Tue, 05 Apr 2022 21:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649219839; cv=none; d=google.com; s=arc-20160816; b=cUw42UGEoYiihOb2NTCyzamUN4YWfqpS9Ff5K7UTyzgtDbTxaGErqwLyC9iyrMNYKz mHxrKajQ3JpJlyj/Yy7Es28uuI/M5VgkJ+l/Nk4NvQ3wr7tRZrhPKe3z/KGlVlvHJBtW 1NxPIjJCDbP6yySAXcpIDbI0Jgt6GbENT2HOcN86DCpYWpxMDA57B2HU+mi/4vn8nXQh iT1VInX2mjyY30Op7HZ8QBP2lnOpvzj6zIfTayyLH1JbZ0ceSC9WVoFts+yyRL7V34E6 yOSlCXAiMMyIDRpE2OAArTm4v1ylJQwRW1Yth64zgFGQb0bnkGW1g3Rt/ewq/pgBH/Vn jD5g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4PQiuWo+tzx62Fp598sHnlLkRLz+7HY3Shvs2LMkpaM=; b=l8nLyoFXkP7CieGSVrsNJ37XZk2bhbJwi8kkf2DZhbIQunKpDG6zDfDmoUas+ZpqB4 iA/TRVKg5g8/1Q8KQSIb115hjjYzrt2phQ6bj6CE725BPC6fDAQJFYVYjxaMGSCPfn/H IHtW7m1zUWDna2fQ8oPod3TFs12uSUtXHgZFWqLsf9VPWlDYiJF328aeh7CIOzUDhSW7 226wyCjXoaET3RPUxGpK94vypmCU3CHFCaoXSe1fYywTwr26+ppSi0ikfo7KHRhAq8Ha rFdV/va6BFQAUi2LK4bfa500u/5va+H8N/NIFLYdV9CwPht35kxE3bTEP7H8eBYhpbTa jzew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vw1YN8sS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q16-20020a056a00089000b004fe0ecc07acsi7678362pfj.106.2022.04.05.21.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 21:37:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vw1YN8sS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 321884EDEA; Tue, 5 Apr 2022 20:03:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231453AbiDEHmw (ORCPT + 99 others); Tue, 5 Apr 2022 03:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231826AbiDEHlo (ORCPT ); Tue, 5 Apr 2022 03:41:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5D34B40B; Tue, 5 Apr 2022 00:39:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B7DED61693; Tue, 5 Apr 2022 07:39:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8B0FC340EE; Tue, 5 Apr 2022 07:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144384; bh=z03uRE2H7zmi68R1Q0lvr3LCmd3ruYnHuWykD/0EvBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vw1YN8sSUMrgUEvyU7MmOgaP3FJR/SQdAtmFfqmxA4AY2ZO1OC9Ydikq/TbnxLOV9 cwDFIgQS4fBM6WyP8/QaxVyFIqGpyImcC+pBavHF7eAsv2JSGUyezAwogzzjJHVwnB sLEw6tK8U1wGtyz8OPBETO03opmzi4wO+BRY3474= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Clark , Mike Leach , Mathieu Poirier , Suzuki K Poulose Subject: [PATCH 5.17 0026/1126] coresight: Fix TRCCONFIGR.QE sysfs interface Date: Tue, 5 Apr 2022 09:12:53 +0200 Message-Id: <20220405070408.318377465@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: James Clark commit ea75a342aed5ed72c87f38fbe0df2f5df7eae374 upstream. 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 Fixes: d8c66962084f ("coresight-etm4x: Controls pertaining to the reset, mode, pe and events") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220120113047.2839622-2-james.clark@arm.com Signed-off-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- 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 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