Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp654288pxb; Tue, 5 Apr 2022 17:28:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypkMzvb8qllIZEOIJ+GAc5tUQkQMv1+jmFFjCs2s3KZ/ECujcC1dgK+PUdVu2PkP4wUZKG X-Received: by 2002:a17:902:d4c1:b0:153:d493:3f1 with SMTP id o1-20020a170902d4c100b00153d49303f1mr6068464plg.102.1649204904671; Tue, 05 Apr 2022 17:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649204904; cv=none; d=google.com; s=arc-20160816; b=c6hHZLl/rz8hHDQMlotoVYrXDLpYWn42SU+zMYkd/6WjDyYswv56A1mxuanJTqvfCc 1Hk65agP/X8d9wqPT8UU+EcokPAje6yiij1V0vquNQ2PV/v01S5YB2OZpXkF5zKIqePj Xt3Y+xK30J3ewoUYBcd6n1t19q64nUbznKGal9vy1U6EuOCIM1mS7oRrXJhmu2lbNrNk kxDfr0Nr58grfxUkZwiQXxHgMQofNrjUykMqxACM2KM+CGHrfB1FB0oShq1YcBY7mRUl SYwQp1X1CvAUR0K4CKVYk8CMQv8KKQnOsdXXAjDmmnarOzOHPSzKXG9mVZlYP1lscS/Y maxw== 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=zh3uKpn+TObEh77bwawxDlOlJrlIxqVjIbWOZCNpDazNfFzveNNJ8ahGeSadEbvbrZ ubfsaCci0kz2evimSVaNfP1OeccECmJgVOGkV8/t/WjeszmThLRVUOPBHHo64WqZzVEv so7rnYrAsxRTKi0QQgYakKKJnS3KWW2TN4dJ7oJyTNZZgUk5ocGfArtJ5MntX0Az3Vdq pWOy1EPZQeqi8ghGuCPgMsAflVLHPAI2oHOklKjt5UGjrqx+k6HT/3/RJy/J4LjFGsa/ prbxwu4mJywRGMet6gc9Co7EHEeCxT/LrdkXwlKtcuWlJV0HkF7QXL26aPs6ocgGOHVx 2Lew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E5zeVMup; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id s65-20020a637744000000b0039836ee65e3si8954038pgc.664.2022.04.05.17.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 17:28:24 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E5zeVMup; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5503129BF65; Tue, 5 Apr 2022 17:14:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386816AbiDEOZx (ORCPT + 99 others); Tue, 5 Apr 2022 10:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238976AbiDEJdP (ORCPT ); Tue, 5 Apr 2022 05:33:15 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65DAF6464; Tue, 5 Apr 2022 02:21:22 -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 sin.source.kernel.org (Postfix) with ESMTPS id D7418CE1C6A; Tue, 5 Apr 2022 09:21:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEA9CC385A2; Tue, 5 Apr 2022 09:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150479; bh=z03uRE2H7zmi68R1Q0lvr3LCmd3ruYnHuWykD/0EvBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5zeVMupNafqz2+c+ynklQr8xIOZJpwP1Ts7UWd5fnMwr/3m9/aoNXNv6lMqYVn68 OTYNmgueebrGvkkSX/99v342b7Eignk1Am9FPF+5TND4NaT4J8yr25uLiyF4ogRa95 C5NOfQ/Xv7UGCmeOgtx1XYLBUXI+RJNu+ezF8i00= 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.15 043/913] coresight: Fix TRCCONFIGR.QE sysfs interface Date: Tue, 5 Apr 2022 09:18:25 +0200 Message-Id: <20220405070341.109583188@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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