Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1023442pxb; Fri, 15 Apr 2022 18:41:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvLVY6GCuKReFqfTZhM2NNPLLyl5qnYOEhvAA7KFWoyE+doNfg57yLBM/MWCASV+HulvhR X-Received: by 2002:a17:90a:8591:b0:1b9:da10:2127 with SMTP id m17-20020a17090a859100b001b9da102127mr7028513pjn.13.1650073316068; Fri, 15 Apr 2022 18:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650073316; cv=none; d=google.com; s=arc-20160816; b=k2YUmFgga6Sl9XAQiciHWKcIBS2ObREa8gE51oQOShj7sQJkLT+BmIdB/Y+5Xqj5Ty Na4V8nNFlUWSLDFQUF5mKyWim8qZr87VtfssEUfEDNxX3u6UwHnTW0Ej5D9ypUd4Oay9 rpGEHXCWEvbmXkVIBmS4qEDQjPxsqLMBl3Xq9QqksBt7JFlXUxnkjJNYcQPL/JaqVI5O dYfRYHMbxhCmRc68TWIVQg/82abqJnUP3BRtlHwt41rgLHgAX8DYBWfEj4hMQoRGELGj K/uuASmH/J2GiVA18iI0XdgI13MnLHc9Bg1DwvR6x/G+zscP+VOND0cyZNhDkCmeHXlY ou0w== 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=I5F4Sv/E9HOwyanXdlZtCLxJ0mbN27hc0n73zq93b3smymW/IF02nrMdFao/afrdmk FQvGhP6nm6bh8lJvmnNLzXmftSWqpEq0dGqWzzJbbJukry+NkL3l2s27eQF0kvJVzXLW pRF030IKHfnhEdDNGXrmGJbOyWQSAPO4+4Vtxao44fZjXLSpb2P3S4tjj3fLWy0r4/rl WGxnhuEWSLwWgjdJnMoikUcnp6/gw2x2ohefZ/Xlb9nKf12rUyTwDjnnMyxfxf9vfokT XE0tF8W1b7a5ozPm1V1c1FuNAadUoi6jnfjSB1yQn5jNUzKI5v1mPjTBYjpzk+9q/FDm s51w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=I1bAnQx4; 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 o13-20020a17090a5b0d00b001bf0de27d60si3091899pji.77.2022.04.15.18.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:41:56 -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=I1bAnQx4; 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 ECE1DFDE05; Fri, 15 Apr 2022 18:06:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242754AbiDNNT0 (ORCPT + 99 others); Thu, 14 Apr 2022 09:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243788AbiDNNRe (ORCPT ); Thu, 14 Apr 2022 09:17:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B10BE0; Thu, 14 Apr 2022 06:15:09 -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 A1806B82910; Thu, 14 Apr 2022 13:15:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D3B7C385A1; Thu, 14 Apr 2022 13:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649942107; bh=z03uRE2H7zmi68R1Q0lvr3LCmd3ruYnHuWykD/0EvBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I1bAnQx4brpBqGL3M2+uCsRpA6DHwSMNsTtXy98gtU+OeimCBD2u969Ov3Xu9iSEY lBwwOJv6kH7PPgRUFWyMNKFLAUSIcBF/Ufd8v/BbW+oVDcWqLVNTLt2yqtRTpS7tEu nxw42bEkGDxF8dp7GqQPG6xBVIDUFe96ze8fKipQ= 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.19 018/338] coresight: Fix TRCCONFIGR.QE sysfs interface Date: Thu, 14 Apr 2022 15:08:41 +0200 Message-Id: <20220414110839.410214554@linuxfoundation.org> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220414110838.883074566@linuxfoundation.org> References: <20220414110838.883074566@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