From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 3CD5C3B4E9E for ; Wed, 8 Apr 2026 11:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649515; cv=none; b=kRpkCDbNShLvMa+Nh/qWWPry3HOVm0SAZExpDX7d5rh5Utiiik87wKF310V93Tz4031Qd5aT+K0tBe9US+lZCRix+HhdFeHG+ZcXFlYL6gt1wghelTZilyGRb1KHbjKLd+3vZph0TuL5FlJFelX1Vo00B27lLSIkxYei8tpNkyc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649515; c=relaxed/simple; bh=WR4DGvfWQ9vg+1TnVPPV/BSBM4+13udBc144kk/FGoQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kxMXI1qIZg5hFUUVnIAbl+l4xsaMozoMoqX/YoeO+Lt5jfjlBvw/TnIkb+2QDpMLFkXu9mSoJcu/oypWMPw32niVkDev98ZZCtjcZxvDG1mX9bctRT4WKNpWQRAM7EZgoZ/LvKNGycBx0gigsXoNadAM1ugjtmxi2fqu8YahKqE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YmXfd9iy; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YmXfd9iy" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-488a29e6110so43010425e9.3 for ; Wed, 08 Apr 2026 04:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649513; x=1776254313; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=k40FHMst7ZYaUpavfz/biELRzCmoNJ4RIF78KxcSSeg=; b=YmXfd9iypGV2CumeGJ1C94Y5vNJGyqW9wa9wr7V209vRUiQ5b+PzwyGY2VCpkepj2h d2jJg8k6fSJee0j7mgUhUtkNRGto94VMZRJCVsuHXRcfn1/RM060s6ZhDhLhurl/VXzN +3YQODU4u6j4zUTo66PNPvZEZGLCfcGDSmZNQC202/vUA6bI2jVza4fLsxeRYOD/vwx9 ARKBqgpI8b0uCGmpg7FgDlAEyhPtsmEshrXsOKK7UBwJaWFuvVjDA19Kx/1OMhOb12/J ZSe+/dmc0vbasCtut3sBoaQzsBQzjBu6m5r+SoRhEGl02sj5W0b0uKDG68RxcO1JiwlR 7Nrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649513; x=1776254313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=k40FHMst7ZYaUpavfz/biELRzCmoNJ4RIF78KxcSSeg=; b=Jgg0xUBV5b/jnTAPtybsI5gfLATji99K3de0A5Mmq4qxMgeyaJfavgNMh3KT/DIW55 lwA8XW7QLnfxtMP0QlNWQ3qJXWbZFpcvdjVeKbjzMkqLlmxaejASU7O4VCjJD+BHOSTQ mEmbg2x+a1lP0GkK2QN8i40WRNew/PJv/TxsZJrNyPtTxUA899ybltI6Lr6V39/J0Bj9 InEdPTWJDNCQtA8gK2R6nCdM6FtJEG3XA5dBedrvJa7y/addW3wDZBhye8F0VqpFm9CY K7gCfApi2yPkL+DQlLm+p10w6529eCRbjhn+ZmC6jXkU4sxKiRCePgK5GHyTV1jKnzjd vXLw== X-Forwarded-Encrypted: i=1; AJvYcCVNSEUFmSMmd6pN+MkRqJFmTXE3cHRWFS8VWkhYgMtdxsi37uyAu/sHWmpfMbdma2VnwcvwxhSWBR3fpN8=@vger.kernel.org X-Gm-Message-State: AOJu0YwYMbR3yfnpU3e/HHhCkxPvOdFNIIJwSqeQpaeD+60Ms+NlYZ67 rjyugi5ncuSYAJjCks5J59T37irVGnWXyqVFbH9DdOlNPSKIsf6wwiwI X-Gm-Gg: AeBDietGUirSGk0CWIm/vLu0YEc4VSAGHtqMprhVxZ/WZCwAqiIpKrbb715PYJxAdtX PLCUefSILsTxus9SdpDNjNdISe54MFYciTEfvXxFfnqvSxOEXBpygICD6RGqHNePkdYSR+oUuhv 4GRNye8d5+QA6ycIy41DWdDZZ9sserLMeqW4z5BTYJZuNpheIzaXEPtinsDXbUHPJms/fk3tZoC X1OLzGKml+r5NXukgSF/KGHw+J8+m1r1dB78h0AovvQ72ACyXkLKSNhfEwN6ZZscFxF8mmBOKF3 yw+DzMZyfGPp+XHt8EHb7zeBpTBAfFCWw0X/6Czl0Rs4V4R5IErod1hV8cEGpGat62l3bAcknaB vXxNDXURGIaopXFwTIpc9Jxq02iqBlhe6yDVNX/NsINpzihM7cLFenFaZe46z24OQkWCNd8NSq1 LJZV4ca9d+XwkS5X+VEgpD3tiKpIRJoHQ8uXqK/VlTvYAeQXQZn7BwVI7k900gKN0C X-Received: by 2002:a05:600c:3549:b0:471:700:f281 with SMTP id 5b1f17b1804b1-488997d5e5bmr274362495e9.25.1775649512422; Wed, 08 Apr 2026 04:58:32 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887e80a616sm1178015225e9.2.2026.04.08.04.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 04:58:31 -0700 (PDT) Date: Wed, 8 Apr 2026 12:58:27 +0100 From: David Laight To: Manikanta Maddireddy Cc: , , , , , , , , , , , , , , , , , , <18255117159@163.com>, , , , kernel test robot Subject: Re: [PATCH 1/1] PCI: tegra194: fix min() signedness when capping ASPM L1 entrance latency Message-ID: <20260408125827.7063fd83@pumpkin> In-Reply-To: <20260407145749.130753-1-mmaddireddy@nvidia.com> References: <20260407145749.130753-1-mmaddireddy@nvidia.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 7 Apr 2026 20:27:49 +0530 Manikanta Maddireddy wrote: > The DT property "aspm-l1-entry-delay-ns" is converted to microseconds, > then encoded for the L1 entrance latency register field as ilog2(us) + 1, > clamped to the hardware maximum of 7. > > ilog2() returns int type, while the upper bound is 7U (unsigned int). > The min() macro is implemented with __careful_cmp(), which rejects mixed > signed and unsigned operands at compile time via BUILD_BUG_ON_MSG in > minmax.h; that check trips on this pair, notably when building with W=1. > > This combination fails to build (e.g. parisc allyesconfig, GCC 15, as > reported by the 0-day bot). > > Use min_t(u32, ilog2(us) + 1U, 7U) so both sides of the comparison are > unsigned and consistent with aspm_l1_enter_lat. Adding 1U (rather than 1) is enough to make everything signed. Alternatively change the 7U to 7 and it will all be fine regardless of whether ilog2() returns a signed or unsigned result. Remember min_t(u32, x, y) is min((u32)x, (u32)y) and you wouldn't put in casts like that for any other arithmetic operation. Note that for the compile to fail there has to be a code path where ilog2(us) isn't known to generate a non-negative value. ilog2(us) (probably) ends up as 'fls(us) - 1'. If that is implemented using a compiler builtin (because there is a single instruction) then gcc knows that the input can't be zero (from the max()), so knows that fls() can't return 0 (which it does for 0), so knows it is never negative and the checks in min() pass. parisc may be one of the architectures that ends up with a real function for fls() so the compiler doesn't know the result of ilog2() is non-negative. Just delete the U. David > > Fixes: 4a44cd65c9dd ("PCI: tegra194: Use aspm-l1-entry-delay-ns DT property for L1 entrance latency") > Signed-off-by: Manikanta Maddireddy > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-kbuild-all/202604051407.AODe3ddZ-lkp@intel.com/ > --- > drivers/pci/controller/dwc/pcie-tegra194.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c > index 393f75ce3df3..93d3452ac117 100644 > --- a/drivers/pci/controller/dwc/pcie-tegra194.c > +++ b/drivers/pci/controller/dwc/pcie-tegra194.c > @@ -1147,7 +1147,7 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie) > if (!ret) { > u32 us = max(val / 1000, 1U); > > - pcie->aspm_l1_enter_lat = min(ilog2(us) + 1, 7U); > + pcie->aspm_l1_enter_lat = min_t(u32, ilog2(us) + 1U, 7U); > } > > ret = of_property_read_u32(np, "num-lanes", &pcie->num_lanes);