From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE85F3D76; Wed, 30 Apr 2025 19:32:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746041567; cv=none; b=IauCc9Cc+0bm4Jev1XWBAm+LGCQZOXxrXXyRP3i+L4KTweI/Nm/x4DTMJiZMTxTOQF5BhhAEZlrfEBTUWL3ikQM/1QBg78CpyF5DXssO1Qmm45QR+eJ6HOJDhsAuC/Q17BzZ9dF4T8q06mNxC3aW5E/1rJq36YwdiqXe5nlg5+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746041567; c=relaxed/simple; bh=eto3ig9zOdbipNWtSXdSig+DyQCl3cdu9O7NHaZG3K0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=D5LJYHaCrExfezbnbGxzXF4GxWEVTgF+lgu6tnONbDQJMyge+tw6eDCTi4bpeJc76385MfgCYvt4K5MxN+X4yTHjMo4nj/306nivZPGbAUcR8G6r2U7ejmRYBm/9umiXJ/aKD86qjDeWQTl82kM3LBLitBxB+jFlh/UAmRHjCmY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M6+7VyHI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M6+7VyHI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8230EC4CEE7; Wed, 30 Apr 2025 19:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746041566; bh=eto3ig9zOdbipNWtSXdSig+DyQCl3cdu9O7NHaZG3K0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=M6+7VyHI87AqgVw6moUQ8QGECLano4KjwwKDXD57m404YDGwi/WjET4Fdoj43/6I1 HAyV8UJTWr8eQiyADBBrIZM5uhGkACd0PeDfB8y4eRDhrzruVewnE6Z2/8PRdr8QTL 1wQSc+iF/qpfnaDtKxiUi9XffgNZLjjBVzdk7E60lf3ycm/4ZcROFOsoWGSQcTqoaL osHOPIrKVrK6MR0SQDq9riZiniaeph8FavKVU1CrclIutVLYtZIqm3mtdT6otzIDbc 1MRKUo9wJB3//E+ZtxWKArBV2dujwrDQo/IZ5JbQokfPBb+OWA9e1KRAsiwmjppYgY 3W12rBy/fgTDw== Message-ID: <4bf62335-2e67-43c5-b2dc-4b0bed0521ed@kernel.org> Date: Wed, 30 Apr 2025 14:32:44 -0500 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 5/5] x86/CPU/AMD: Print the reason for the last reset To: Borislav Petkov Cc: Jean Delvare , Andi Shyti , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Jonathan Corbet , Mario Limonciello , Yazen Ghannam , Thomas Gleixner , Ingo Molnar , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H . Peter Anvin" , Shyam Sundar S K , Hans de Goede , "open list:DOCUMENTATION" , open list , "open list:I2C/SMBUS CONTROLLER DRIVERS FOR PC" , "open list:AMD PMC DRIVER" References: <20250422234830.2840784-1-superm1@kernel.org> <20250422234830.2840784-6-superm1@kernel.org> <20250430190333.GIaBJ0BWuMdZ1KNVQ7@fat_crate.local> <20250430191025.GFaBJ1oQjxCuig1vS6@fat_crate.local> <35bae46e-3b57-438a-a561-c93868120dcb@kernel.org> <20250430192538.GGaBJ5MuS4CEKa4kIX@fat_crate.local> Content-Language: en-US From: Mario Limonciello In-Reply-To: <20250430192538.GGaBJ5MuS4CEKa4kIX@fat_crate.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/30/2025 2:25 PM, Borislav Petkov wrote: > On Wed, Apr 30, 2025 at 02:17:43PM -0500, Mario Limonciello wrote: >> Well with that approach once you got a known bit set you broke the loop and >> would print a message for that known bit. But if you have two bits set you >> either need another loop or you only get one message print. > > So I gather you want to print for *each* set bit? > > If so: > > for (i = 0; i <= ARRAY_SIZE(s5_reset_reason_txt); i++) { > if (!(value & BIT(i))) > continue; > > if (s5_reset_reason_txt[i]) > pr_info(...); > } > > Still a lot easier instead of calling some function and dealing with from > which bit to start etc etc. > > This would work, but would still need to track if "no" known bits were set to emit an "unknown" message. So the loops end up being for() and check a bit or while (true) and find_next_bit() and otherwise identical. At that point does it really buy much more than the while (true) approach and find_next_bit()?