Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3522056pxb; Tue, 19 Apr 2022 04:38:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOpFPP5VTgmz0C9tLRSKYUQ9UY1R6WAUPF2aXo45cuNh1i5AxyGnfTm789wN1pvs7wu4nv X-Received: by 2002:a63:e51:0:b0:3a4:9d22:1fd5 with SMTP id 17-20020a630e51000000b003a49d221fd5mr13573135pgo.586.1650368290875; Tue, 19 Apr 2022 04:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650368290; cv=none; d=google.com; s=arc-20160816; b=aUJiteR1dLBRNDVAb13Cri1S3yOuoywB8j65hymhTzEu3hwxvnzILWgShqzwcs7MrO jI4eaiZCn43xLI9AjquyrBDy2Eg8q2xm7hGnT425xwq7ZBcp4Ctw2zKqNI3fKeRQp08P ViqYDOnyvTxGosYrWBGYhm7nCG1ImqMQcZklWN7sxb+LxjtYnufrFAMSaANZLAM6n02m iXkuVSFWIhTXUk78Oy5s3GydiIC1mecWXBWmvKfKP9VBKtygkTWvMRlhdMGiw53e91ys THw9MAxS9g33REW6bg8f2NXUx9vHhbNk5uJIa9w3idPzUkcpb3gnXWK5aX7R0CjrGwvh /Rfw== 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=dvKeoClpGSQYv0gH06YhzSTMUwuZ1rFS2OdGYPThyMs=; b=yvNDbsJ3yP+FDgDYlLRIzql8sdpFNogGflUOyIFyQpxLbYqoATKtrnc3GMraV4WhRd gm4X3xvs74dNHXHTFiamtWjztp1ikoHER1yj8YyuHWve50DJip7C160DcYl1aPxhmkxO dxPQMwkZ5E3BXEGQ6gPU8OPgdKx8ZKB4l4mjxhJo5OdUuzoWvBiNSN2xzeB9UnL2ixWt QdotnYnWsdwGBecnpDuYgJoCz7iHZB7aT1VJebUcXufDvsmba2Xkc7hW94gG/kcamsyS qNSS9nvBe8EdbaAv9xHyPnpHUGWS2wn68qWhivYz01Cje9+QqlxXAUip2rzF4SX4dOrh RYbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QpE+Q7OS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 7-20020a630207000000b003a2637c44c4si11450072pgc.767.2022.04.19.04.37.56; Tue, 19 Apr 2022 04:38:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QpE+Q7OS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243616AbiDRNeK (ORCPT + 99 others); Mon, 18 Apr 2022 09:34:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241290AbiDRNH2 (ORCPT ); Mon, 18 Apr 2022 09:07:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 763CF2A738; Mon, 18 Apr 2022 05:47:31 -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 E41F661253; Mon, 18 Apr 2022 12:47:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE3E3C385A8; Mon, 18 Apr 2022 12:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286050; bh=4bSNL2HCuVxfuFYn5tC2mBPJ2xyv9VI4fvWzI2d5KBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpE+Q7OSvEZmMfaySajf4qijKu0Avo5xLe52XCZ5dpvBUB7Zi00DUhx0XhWCGWT3+ Mw2zNRTbyEYplcxaptJvljm2QysOYXslQg1m1hiAZT6urIfXerICsVG7Bk8Rat9Q7o Jt1KGmLr2FNdaa5Bm1xoXnFbVq0dXDp6wuSbTjJA= 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 4.14 014/284] coresight: Fix TRCCONFIGR.QE sysfs interface Date: Mon, 18 Apr 2022 14:09:55 +0200 Message-Id: <20220418121211.103547244@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -379,8 +379,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