Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1013994pxb; Wed, 6 Apr 2022 06:44:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr+yHFVEK2GiRVhahTpVUq+fullmk/iNW7M2Dc4SJe6MCICsN3Uvtm+n1Hd80oH1CehJcJ X-Received: by 2002:a17:90b:3881:b0:1c7:c02b:bcf8 with SMTP id mu1-20020a17090b388100b001c7c02bbcf8mr10168926pjb.131.1649252683468; Wed, 06 Apr 2022 06:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252683; cv=none; d=google.com; s=arc-20160816; b=y11gp0M3Ixcaoe67JekbHDACeufKDbOsPAunMndSFavxZOUAlVGtmZIYLOCSZg7YdC UvQ75QEDMLdjTxtsxtBFFXYLg8OPysnOk+IM+OOgotyAEkBmpZ6crOHBEKgIZHKv7AP5 eXgsTV/thd3waUHddwZRVMOAHkNePHKvI+J/Rm80n1LOER2Gn6XnJ7P6h93+VnqXkCaS wzkQc/TD1nID2F/LsOlpKzokw0KlX5HjX3yktJ4h74HBtZMMRYkpncCtZDQHbcOvEtex VMm59+KZXZlVJEnW0Zr9wxZi3u56F7gTXxaL3jgHqe3Qq3R3WcPJ10n5FrjRkwcCbHtB I5kQ== 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=nEU1k9iSJQ4V6v5YCzvFt2iNFMGBFs0RA62xjOP2MTI=; b=ZMk55u04u7RBTQAJW37BH5PvNGoWJvT8HFc1HbV0r7XUIX8kv2BibcGa9T0GUSUVu1 UaWd9z+zwKUVAoj6oBwn71s4+rFa3d3qQyo8grB0z1Opb5tZ01sCThD0C5vsGZIMabks HisrYHKYuguc4s4Ae2j+3sSFDlWDgqLGhmWUz08jNiXYa5g4oRM1g/iDcqSWB1NoObEe GNJUtDnxKTv9sQAkh+qIQrmluW0MW2VoOvys6/zoCiv0Isz3agPzG1ihkd1/W1rCgMgp ajLq6AczXdIJbFIQuziswpYmMyHDMkOLd34PO5g5O7f9kVdRWhshUFz+kKF3l2uPFm// jIWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zNTwFzyU; 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 d12-20020a17090ab30c00b001caa0aabc28si4963378pjr.97.2022.04.06.06.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:44:43 -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=zNTwFzyU; 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 694B3603810; Wed, 6 Apr 2022 04:32:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1842439AbiDFBbh (ORCPT + 99 others); Tue, 5 Apr 2022 21:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354637AbiDEKO5 (ORCPT ); Tue, 5 Apr 2022 06:14:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC554993C; Tue, 5 Apr 2022 03:01:53 -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 ams.source.kernel.org (Postfix) with ESMTPS id 43AEFB81B7A; Tue, 5 Apr 2022 10:01:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 821A1C385A2; Tue, 5 Apr 2022 10:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152910; bh=9bImAcmj4A53oHrgEvLh7UEsskyu85oh1R6Ve/FzEG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zNTwFzyUdTp7MGc07TaZbR5mBuvM3mulhAexXPM0i+nEW6a5AHSzFkpW72VfLPrB4 6cy2sW8XzgeDDqG0fzyYSTBheIFHV+aS4ozK6WTMqTQvHpM8ZDqbXUd27hRHhWmHIR x+82wREYBNjFoh3unUW3Fi++fUqEtvl/S4rsWfcw= 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.10 032/599] coresight: Fix TRCCONFIGR.QE sysfs interface Date: Tue, 5 Apr 2022 09:25:26 +0200 Message-Id: <20220405070259.777351752@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@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 @@ -364,8 +364,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