From nobody Tue Feb 10 09:24:43 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 644221922F1 for ; Wed, 18 Dec 2024 23:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734562886; cv=none; b=huxIaD2dw17YcUjc3//MKU6l94MAQOx9+slDtYjkZIfLntee7o9fH2vRpkUeSbto1BUddo5QTUx3W4i60PVn/uEs49z8lggdVDGKMQNgBFlZNp/9mYeydn5t473x9NG64Ke78k/N9SAZ/X6g1RSzVkws00ZQr9CYeBpsrkOS37k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734562886; c=relaxed/simple; bh=kcUTXhqvWZllu6NI/29SNrQy6CEzbFBel/DWY6ZnEDw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EYu6eCe4eBJG0YyDWulyY0JZMF8rMmu8RtI6gwTAmi7Xo0FXRbUI9AEcLqHz6avokb7g4Zsd5eCskGt4Ay+lUSQOF7IMp2gbLe/T9T2GDYfqtN7jW0Smw5t7/Vlv2FNNXzEYSkkHnjWkv4jcE9OQ60HF0yj36aRNQ8IKZT/ByqU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Rjn1q4t2; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Rjn1q4t2" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-385e3621518so95648f8f.1 for ; Wed, 18 Dec 2024 15:01:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734562883; x=1735167683; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S7tFLc+iUu654xr+ZEInB5+ibN3E0pOW4hXHpK7c/ao=; b=Rjn1q4t2ubY7iK/qbu5nW/uQ4FLq5CSriw0vvxrbLZXdAd1IeF6ckijvEVNffjIPuQ jPcLsWmey8MRObkGh2+Qs7zd3tqU8cY1XsLfz2u4XA6nVjfln0EVriS9TvNywJJC+QMk M3eM8R5A1pF+/xvp9lnfS/gQaAV4F2sS1lp0j3fi94+3NV7oKbevLGUi5oyGIISlBEpi c/wv+wSTp+L/AAYon4QQIkIIF9xjno/9DFDCG1uHS5rZDz8h/rAi6hHhBtssX5y3Q3jX JTJ+dQM6TcuGjdKGHgAE1RsBk1hH8FUp61jjLURS2o4g3WPBBu8TBqaNetLk5zF+5CHQ +c3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734562883; x=1735167683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S7tFLc+iUu654xr+ZEInB5+ibN3E0pOW4hXHpK7c/ao=; b=T7GMmxHflCiR7U/emF4XglwGnP9Pv4aEcNUnfnZRJS7jWIZl5SjfFSgUV9jSra0g1F BxhhVXNoKLTFaW/bLWcpP8Uj4bwwKb4+OusGnBZJVNo4YF+POilTfEIxIXRJ5JWFTqhX gfPH5P6l1GGfP9XmthGxLuzaBul7dMky017gxXC3TNOIwNlfXpXRXM0TrXS0f+SiGsWg wChbSzQADbadHHa4aafEe1L/h8np1lOv5HuyMMoz1KkU9/S3Wa1LCTd+fPzOrydQEj/F KNIzYNzhbLi75V6/8n7g0iLh0e7cr3FPqeHiPlNXkUtJErBlwSMmIRS+DyLLyPpZDi6K 2ygQ== X-Gm-Message-State: AOJu0YxbTtdkhifk9yupIkAZv7OuMGFRr1baDYmD2ADiVOAQPKjbHDwv PbGCjxf6KgrBUaCGQGmjpVpNBZ23l1w25XaH0KPJC5mOLQPFXws78VekejCcyYzNFoImxfA1uAl f X-Gm-Gg: ASbGncut4kyzT+lTucD89WjTG5bkF4M3ZbFXnRgTXumXOwZT95pugc2VkxZ0viBOpeN BD8exC/8yfoFTvR/NGtsTZwANvTUxG7/C0NZPZlxUWtHycnW/mkxFFguTkJAOEY+DAcT0J9t6QI HPgUABEReknIbpcbobvlB8m/CwmBWPqbXsCTtj5w7CsvHz+X+AyJpsP3sPZkClFxE7H1kDrzaRV s0vpkgNsSIudWqx5xvFhlJ4IKSm686vwf0rib0p+kuhHM+wxPt5bgZ797k= X-Google-Smtp-Source: AGHT+IGBekGqRLKeTUOgL5pkMylABNCwxn1vFt/8TScAu/KTnZwD5za7lopJ4KSP5x7Qv1fpeFw1Jg== X-Received: by 2002:a05:6000:4a15:b0:385:df44:12cb with SMTP id ffacd0b85a97d-388e4c93e55mr4969683f8f.0.1734562882670; Wed, 18 Dec 2024 15:01:22 -0800 (PST) Received: from linaro.org ([2a00:23c5:6829:901:7895:12a9:ae3b:17a1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b190f3sm33291835e9.32.2024.12.18.15.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 15:01:22 -0800 (PST) From: Mike Leach To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Cc: james.clark@linaro.org, mike.leach@linaro.org, suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com Subject: [PATCH v3 1/3] coresight: Update timeout functions to allow return of test register value Date: Wed, 18 Dec 2024 23:01:16 +0000 Message-Id: <20241218230118.999859-2-mike.leach@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241218230118.999859-1-mike.leach@linaro.org> References: <20241218230118.999859-1-mike.leach@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Current coresight_timeout function spins on a bit on a test register, till bit value achieved or timeout hit. Add another function to return the full value of the register being tested. Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight-core.c | 50 +++++++++++++++----- include/linux/coresight.h | 2 + 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtraci= ng/coresight/coresight-core.c index 0a9380350fb5..595f7ec0782f 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1092,32 +1092,37 @@ static void coresight_remove_conns(struct coresight= _device *csdev) } =20 /** - * coresight_timeout - loop until a bit has changed to a specific register - * state. + * coresight_timeout_retval - loop until a bit has changed to a specific r= egister + * state. Optionally return final register value * @csa: coresight device access for the device * @offset: Offset of the register from the base of the device. * @position: the position of the bit of interest. * @value: the value the bit should have. + * @rval: if not NULL, return the last read value of the register being te= sted. * * Return: 0 as soon as the bit has taken the desired state or -EAGAIN if * TIMEOUT_US has elapsed, which ever happens first. */ -int coresight_timeout(struct csdev_access *csa, u32 offset, - int position, int value) +int coresight_timeout_retval(struct csdev_access *csa, u32 offset, + int position, int value, u32 *rval) { - int i; - u32 val; + int i, rc =3D -EAGAIN; + u32 val =3D 0; =20 for (i =3D TIMEOUT_US; i > 0; i--) { val =3D csdev_access_read32(csa, offset); /* waiting on the bit to go from 0 to 1 */ if (value) { - if (val & BIT(position)) - return 0; + if (val & BIT(position)) { + rc =3D 0; + goto return_rval; + } /* waiting on the bit to go from 1 to 0 */ } else { - if (!(val & BIT(position))) - return 0; + if (!(val & BIT(position))) { + rc =3D 0; + goto return_rval; + } } =20 /* @@ -1129,7 +1134,30 @@ int coresight_timeout(struct csdev_access *csa, u32 = offset, udelay(1); } =20 - return -EAGAIN; +return_rval: + /* return the register value used when terminating the test */ + if (rval) + *rval =3D val; + + return rc; +} +EXPORT_SYMBOL_GPL(coresight_timeout_retval); + +/** + * coresight_timeout - loop until a bit has changed to a specific register + * state + * @csa: coresight device access for the device + * @offset: Offset of the register from the base of the device. + * @position: the position of the bit of interest. + * @value: the value the bit should have. + * + * Return: 0 as soon as the bit has taken the desired state or -EAGAIN if + * TIMEOUT_US has elapsed, which ever happens first. + */ +int coresight_timeout(struct csdev_access *csa, u32 offset, + int position, int value) +{ + return coresight_timeout_retval(csa, offset, position, value, NULL); } EXPORT_SYMBOL_GPL(coresight_timeout); =20 diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 17276965ff1d..cb3592d2803c 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -649,6 +649,8 @@ extern int coresight_enable_sysfs(struct coresight_devi= ce *csdev); extern void coresight_disable_sysfs(struct coresight_device *csdev); extern int coresight_timeout(struct csdev_access *csa, u32 offset, int position, int value); +extern int coresight_timeout_retval(struct csdev_access *csa, u32 offset, + int position, int value, u32 *rval); =20 extern int coresight_claim_device(struct coresight_device *csdev); extern int coresight_claim_device_unlocked(struct coresight_device *csdev); --=20 2.25.1