From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) (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 8DAF93314C4 for ; Tue, 29 Sep 2026 18:03:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790705014; cv=none; b=ZQelQ+qgMTF2C0MCeP6kTLf278k6J4/EpsRlD5mWquKeOyE+19wh6HW1QYYrn7gjH7xjzsFZ0UkzyGiHSvYFGM6R6rnUM6YZVXNhhO2JAklM41TTAjS4a5t//1Yb5+oJgWfxNt1L+nRL+xl6IZC0oPfFD/98DHeOt4WcF8cUd94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790705014; c=relaxed/simple; bh=t0us02vORB4Jz7dlERRWOJMbBxMt7gj0S+kDlcLt7Is=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=f2EABmkVQutFG+2i02X7YmewQpBQFeXhxWvRppdbzgzJII5y8Od/eVinCSL5s6Hiis5FNaVeABomwxRDLZkh1H0i17Gr/PeSM0LP8pQCiwQa65zWOerAJgBbXj1khc3GhFIQ9WeQ6FrJlFk9lGQxry7I4KKIRRiuscTe2/mCgzk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=P28wBM8/; arc=none smtp.client-ip=74.125.225.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="P28wBM8/" Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-4a00d8bec5aso7686825e9.2 for ; Tue, 29 Sep 2026 11:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1790705010; x=1791309810; darn=vger.kernel.org; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=t0us02vORB4Jz7dlERRWOJMbBxMt7gj0S+kDlcLt7Is=; b=P28wBM8/xUsO3wSg7/3jXmhdIyBEWuXqJBB2rU+IJpsXpHmBgP8Fa01+p8LE0T8zWV 5Bfv4g2AEx6pAs3WquG19kyWUutG/3uU1bPrloUIcBiTIr/KDF8H8ZZ/figb7g17QqJ5 zcNAKL/55oxL3zTgQ1G4x8HH1kHBzINZwJkppRvDYfBzDctMF3UwAeook/oRX1TbzBd4 OwU3IuhcVN7hFWQHsKlvX07IBaKViJKHjshkqt84H187bfk2DIU5q+j7awTviohvl9zj OMs5N/4iy2lYPSF9n70oJ5WUigQVrKivlxFIaAGoUZS4UnXCwnED2fC5C9IOGy5Oz3UH G/hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790705010; x=1791309810; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=t0us02vORB4Jz7dlERRWOJMbBxMt7gj0S+kDlcLt7Is=; b=KYMZnwIF73JNLGcaO0/9SW34sGELcEv7q6pVfRsE4CnOdHd0TnZQAtVjXItoF11EP7 e/yJMjt06tEnaaNqqhFCUWkANB6EFvfzVGqhg1+/BFet/H8dpPyFJyLg4sOLSDoBiaoQ n1RHl+rf0oUtqYsGy4X1qphAj5Y369iR3mHg7wHaATopz8pNh+JHECcvtf66k2/OTXD3 GIWj//Fgm+mhaFSunVhprt58UE/2BnPu+9oNIbourrQ8Gd5Euarr6LVo5ulU4F2Vy5t0 db5GKXa148iNW2/r1LH+23rnRJxkRC5ZvlwTuoiViBt5q529SVVFoRFWCdOB8VdwmD3R q8xg== X-Forwarded-Encrypted: i=1; AKwUvBwu7h4W6EM1s7FHOyaq/ScMu1wucCeFW3duLAcpIvhq6fcaLPOLA//W8oXFretRm5tv9EWA3uxXij9S19g=@vger.kernel.org X-Gm-Message-State: AFuF++kY2KG8cJodW5NitK8Cbfw2SVaqVCGdxi1f9dbk4XSLA0xyF2Kk wYOWZp3OfgC89v3LVzNAGmOYcYdpqTZf9LnNMyZzfRH9bSDbFnTL/pj57kFX5ObzOvQ= X-Gm-Gg: AYBFou2Ufrjv4ZGBmVRFG8yefxr5WKbMFDosVbPi8xcmr6WsurTe9JQFBtEfa8iHXpR f/lelAGG0ja6smm90nYHmJYy9TJJiZVn8XoFjXH0kFhhvSNBBzkXolYDk9buQ6Bsp/TZYLOtNL7 bXbOlfEd9wSennGEGTvOkL05dTzmcJczQ0tzdJydDSH5p9i8vtQiu9fwj9IRMVdUrdTFxYjzXYD J58ELUwaaV5NCCWS0iFEH9h+gWcwiNKyUz/aCsVC8Sf3GWSrS/Qh1hF2vYTIAxppPOgYU0vjoB4 LHu0z3JVcBrwHfFSczgSJZd9mrNwYD+/cN31RQxQGoA6RFcLj0aVMmBFBGEBPquLqB8yoRjjuyM IZiZyo2iHXpmk7XlWUUgsOZtfE2Y4OsXhluc/NcByGT0BchYa+e01AyNmZCbl3p6WjbkkkJgp4P 7SYnEAir7cxjsF7/StSTLgQqaxxMegsCT1VgjLp1VoHs100AggTKY/9E4D5syNJ/5EdBvRKbcmI 0PPst1qpWmU1c4Nxg== X-Received: by 2002:a05:600c:8b86:b0:49f:ce73:7a9 with SMTP id 5b1f17b1804b1-49fe6701ed1mr295156035e9.34.1790705009663; Tue, 29 Sep 2026 11:03:29 -0700 (PDT) Received: from localhost (82-67-6-57.subs.proxad.net. [82.67.6.57]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0148b0590sm5696925e9.2.2026.09.29.11.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 11:03:29 -0700 (PDT) From: Jerome Brunet To: Junhui Liu , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Junhui Liu , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, Troy Mitchell , Brian Masney Subject: Re: [PATCH v5 1/6] clk: correct clk_div_mask() return value for width == 32 In-Reply-To: <20260514-dr1v90-cru-v5-1-34f3021aab51@pigmoral.tech> References: <20260514-dr1v90-cru-v5-0-34f3021aab51@pigmoral.tech> <20260514-dr1v90-cru-v5-1-34f3021aab51@pigmoral.tech> Date: Tue, 29 Sep 2026 20:03:28 +0200 Message-ID: <1j7bk43pfz.fsf@starbuckisacylon.baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On jeu. 14 mai 2026 at 17:27, Junhui Liu wrote: > The macro clk_div_mask() currently wraps to zero when width is 32 due to > 1 << 32 being undefined behavior. This leads to incorrect mask generation > and prevents correct retrieval of register field values for 32-bit-wide > dividers. > > Although it is unlikely to exhaust all U32_MAX div, some clock IPs may rely > on a 32-bit val entry in their div_table to match a div, so providing a > full 32-bit mask is necessary. > > Fix this by using the standard GENMASK() macro. This safely resolves the > undefined behavior on both 32-bit and 64-bit architectures, while also > benefiting from the built-in compile-time type and bounds checking > provided by the GENMASK() macro. > > Cc: Troy Mitchell > Cc: Brian Masney > Signed-off-by: Junhui Liu > Reviewed-by: Jerome Brunet