From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gw2.atmark-techno.com (gw2.atmark-techno.com [35.74.137.57]) (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 80B821AC453 for ; Thu, 2 Jan 2025 12:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.74.137.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735820643; cv=none; b=V/vzvhWeaZPYpVhfOMnr+8t8j9dn4ubc4SBae2Zd0uQjIs+SVpG410Qk1Nofc+BUpQ8CVe2NdOg2MyjlcSWGqhJcvd4K90VLSkpi7vd5V7g+IxDEXa0Zann/3V+4H/TrFAXW+Pa5cyd/yiNAIZ1zJVt1i6NNOGV9PIQjJDUheFk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735820643; c=relaxed/simple; bh=HnTcnogDqeujixqIMKbpLEdH6ZlUWDMKWY40COTOu8M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tNAfPTvwmuQvy5EF4I2mYqjDWFBWwiN7E6qKXMOwkYM09iqlOQi0v4lrWMNPMMACexQ2YO9+eNq2s/vWxpZndC70uyk6o18E0CpzzDVXQPjTC1U84UDO9H0UQ85ePSij6CfTZj3pIPGsXy0LYLtileaLNb+mXBcPKGwyjJCz4p0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=atmark-techno.com; spf=pass smtp.mailfrom=atmark-techno.com; dkim=pass (2048-bit key) header.d=atmark-techno.com header.i=@atmark-techno.com header.b=ZU1Kors3; arc=none smtp.client-ip=35.74.137.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=atmark-techno.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atmark-techno.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=atmark-techno.com header.i=@atmark-techno.com header.b="ZU1Kors3" Authentication-Results: gw2.atmark-techno.com; dkim=pass (2048-bit key; unprotected) header.d=atmark-techno.com header.i=@atmark-techno.com header.a=rsa-sha256 header.s=google header.b=ZU1Kors3; dkim-atps=neutral Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by gw2.atmark-techno.com (Postfix) with ESMTPS id EE4D77CA for ; Thu, 2 Jan 2025 21:15:28 +0900 (JST) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2164861e1feso153363705ad.1 for ; Thu, 02 Jan 2025 04:15:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atmark-techno.com; s=google; t=1735820128; x=1736424928; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=VTzFh6mOLAUyFzWnsbUpsLcgbQjPe9ChhHIlcORLX8o=; b=ZU1Kors3CT2NUG4NU24A4JPmwCJ2FoBcRsQ4c9yij+eiM91rORfenYz0vu7Pu+NVZ8 MSHeJo5Ie1OyKBj0riD0z2R42NY6HxieSS7UaDQyFdCh4/LoPByKq6gBAyaHiY+32QzT NUPKWsP4RgdqJAwpjkW6ule6KGrquqhUKgDwYzk1q8i9htsrIfLqn/5RpD+jj2v59gYi etf1yxm8HKwURhqFWSNzvIUKH9lyJkc16PftoRcXWSZpXC+YgoqXbDPi3bGwLZvkEDYs jX8v7Hl6W2dtTTmZSNkQ4Z7N68FCbjobR4DmFZ6QD7/EHIJxSOMaZCyJ0BOF/8VK2F3F s2ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735820128; x=1736424928; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VTzFh6mOLAUyFzWnsbUpsLcgbQjPe9ChhHIlcORLX8o=; b=Ix3S29yh65HkTbkw++MJpBhYu8hPtMD0506UX7PS7ZVtuy5capAs6VlEQQyClspGhn Iudkl3KzL14uaL1rt9zZqD/rV5L1TTVJn5ixOiNGEF05ylv9BWtLAjhyjG+KB7S18KFp cnLF9MBX7MvTAJhgncauF11fEi91v3Mn5DM52nUzO4WtDvMPfSekUQ+a8+lGHsnZT0g+ kjB4HRDSSA5rnuGzRzufY0+runcLZNpDbq93DcIRayqyl/yJNFs0H8UrsbIBz/+QrQI9 VAFDxQYQIWeHM/tgNxbX5O4sv7GUNaIvfHW9lx2OkTRS/MsHzLJur3sl9jfzHKCdVPl/ MAfQ== X-Forwarded-Encrypted: i=1; AJvYcCWiYhBgovktFg+i7oHhVpyI3fN1tindC+P3XJlprvXF9WQKvBW8je91hGcJGjNf7NKFux4BdS1mfgq69U0=@vger.kernel.org X-Gm-Message-State: AOJu0YwrMeDP3A3Qw+WuyZVRXq77mVgYXGl6b/by/CNZ2Urm50zyvPOZ s16CBGofU6KLSVfzT9E0bcAZiAQ7ByiDrHBdQZ5axYJim6GiZlczpiM/WiRPK1iSSQlIfKoX57X Q5VMLLK118H+5SA/BSXWiX1zt4aLcymaENuXPWa4fVkmQ6Epf8uv3we4ehahxo+E= X-Gm-Gg: ASbGnctVsjZkBJxps/Fj0I87fMJoMy7KXpP5b3bdreShk4oG7G9oL/EfRUnLszoQlHP 1rrtikDRS4E0NPaQssiBkIgtXDQ7a3hvbZU+HFjzoRcwLXvSp+267ooETVY5VSEtt3fe4hUdrnn nuQSWIyruGYGdP2mxfEdbFxsxW6m4kvXjRiSAjVYJpCx64S5NBJVkX/SILZ+5NMAmKvF3pfZGV1 OUVijBqmL52ILJZrk6pJ7bUswPEuWmz69SJwlLx3AkZYvgRmYueRGFANT1gm1SHzXHEGCaNWQcj tbWCMZXX2EoQkqNvvp5wnNERbUX5ottGHXM4OFj8 X-Received: by 2002:a17:903:2287:b0:216:682f:175 with SMTP id d9443c01a7336-219e6f42c4dmr696065995ad.49.1735820127894; Thu, 02 Jan 2025 04:15:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDA3nTKKup+vDsYPR9sNeg0JJRyQkLrOaR8YBNRhc6maeovamqK8tKHJzktnrurwWOp713YA== X-Received: by 2002:a17:903:2287:b0:216:682f:175 with SMTP id d9443c01a7336-219e6f42c4dmr696065655ad.49.1735820127534; Thu, 02 Jan 2025 04:15:27 -0800 (PST) Received: from localhost (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc96e764sm226324465ad.62.2025.01.02.04.15.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jan 2025 04:15:26 -0800 (PST) Date: Thu, 2 Jan 2025 21:15:15 +0900 From: Dominique Martinet To: Adam Ford Cc: Pei Xiao , geert@linux-m68k.org, aford@beaconembedded.com, arnd@arndb.de, frieder.schrempf@kontron.de, kishon@kernel.org, l.stach@pengutronix.de, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, m.felsch@pengutronix.de, sandor.yu@nxp.com, u.kleine-koenig@baylibre.com, vkoul@kernel.org Subject: Re: [PATCH] phy: freescale: fsl-samsung-hdmi: fix build error in fsl_samsung_hdmi_phy_configure_pll_lock_det Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Adam Ford wrote on Mon, Dec 30, 2024 at 08:11:16PM -0600: > > index 5eac70a1e858..3e4d1a5160ea 100644 > > --- a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c > > +++ b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c > > @@ -341,7 +341,7 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy, > > break; > > } > > > > - writeb(FIELD_PREP(REG12_CK_DIV_MASK, div), phy->regs + PHY_REG(12)); > > + writeb(FIELD_PREP(REG12_CK_DIV_MASK, div == 4 ? div - 1 : div), phy->regs + PHY_REG(12)); > > The for-loop above this line states: for (div = 0; div < 4; div++) > How could this ever reach 4? If it did reach 4, the calculation for > int_pllclk would need to be recalculated since int_pllclk = pclk / (1 > << div); But... for (div = 0; div < 4; div++) does reach 4, if the break condition didn't match, which is something the compiler cannot ensure here. The old code would just fall out of any of the switch cases and fallback to div = 1 if pixclk > 297000000, which is likely incorrect, so in that sense just padding this through `& 3` and pretending it will never happen is probably acceptable, but this ought to have a better comment than what Pei just sent. (this was correct with the old lookup tables, I'm not sure if we can't compute any higher frequencies now?) My preference would be to actually check and handle this somehow since I don't think this part of the code is that performance critical that we can't afford an extra instruction, e.g. something like that: if (WARN_ONCE(div == 4, "pixclk %u out of range", pclk)) (appropriate fallback or return?) but I haven't spent the time to actually check so will leave that up to you. Thank you both, -- Dominique