Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp613998rdb; Thu, 15 Feb 2024 09:47:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXm37BmukZVwiNNNyFLeDw0U50kSe3UNoeNnUfGDk7u9U5kdRnL/DqEUZgG809RE0Ry9ZM06q2ckSNZSAIy9vl2nhkWaWsHAO3kN5NEVw== X-Google-Smtp-Source: AGHT+IG8TaW7rPKb0tfkxlpT1eYjvt8v8SR0pxW0n3xvHzTzP00+Hb+B+EEvYvB/nBBoVxTGCGAW X-Received: by 2002:aa7:c346:0:b0:561:2fd1:99e4 with SMTP id j6-20020aa7c346000000b005612fd199e4mr1729385edr.26.1708019272143; Thu, 15 Feb 2024 09:47:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708019272; cv=pass; d=google.com; s=arc-20160816; b=ZMKPdm8dvYYzak435f0U5Xw+JktFihRxQg68LAcj/8fE9mWS+tCWuFlhegtVmCHL4K fwXvAG2rhShgT2HIYBv0xigZi9y/RMyUOBaJOcaAG2uLcSqPFCPa73OimJKLxDYfEqDh e9P5ID/uBvgpaHwRjcan2iv2KXhYwyiuQYxv76zqO6iQqojekr8b02XbU0sVmDn4kWak hZgLV5iLQKnTXnVfkpMa88+XlRqVi3mmR+qwruc2p2J2y8xZOEMQ19CXmguRsuqiZnfc SOtU6LikeewV4MRfUcllanN9MY4lfcmkmVAgen7vgYj9dZr5o+H/LPAAa/vKF3NQrTUf tN0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=qGFi4nYhTSGzwEyDxOa4rN/Cn5B1c0Et6UQeZJ6o04k=; fh=l5Dz96DZegfXnhIRA9+k0uAIO4g52E4h5je6T1Jpz+0=; b=aLMM2xUo8FuNdUhghZ3jqfOgaldzLbSURyfGCFgiBmW6BZazz2s8tIdcvy04SIZW4T aUYgfCHg80d0VRNw5/Bz49hi+SHmbgTNvPTacDeCDzpQq/D57v+/e8hA0aQEJwlNHgtn ZHwGhFTLKDJwd4hELNgn+hgx9S0DSoE3J7tns6Uav2Zxh09Z6Ft/YVTOMk/ly/CuB4Sz NyTzN8a7pfCltR6DTtM89BynBV41G42NWdncP1+DfMZLXxW8BZeQu17bQa9XFx6fg666 oD6vxPKadjjrzPJ4G080Kjrt72kzf2PhuKf8noeIDwF48Ri9eMM8iUK5J7MY6iY1LgwG lBUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w30JlcnJ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-67433-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67433-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dg12-20020a0564021d0c00b00561860930easi817017edb.87.2024.02.15.09.47.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 09:47:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67433-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w30JlcnJ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-67433-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67433-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B5D241F21BB6 for ; Thu, 15 Feb 2024 17:47:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E071138493; Thu, 15 Feb 2024 17:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="w30JlcnJ" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 32699137C57 for ; Thu, 15 Feb 2024 17:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708019223; cv=none; b=djvHfXn9ABA8T7CalHuFpprgzX+rFUnUx+pi3XO88hTXrBGLZMI/5Ox5791rls3O/JhScnYp0nKdX0iUCIiA+pa+yDcKAwAQXjJ2iKtUjBwwNuttfpMV0A59nQ4Z2iKcSFGgRR1CwP05+5ua4PV4YWRw+PQ0qO4arjG9eeVKv1s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708019223; c=relaxed/simple; bh=6iHjAnqtb6WKmS553f33Msu3R11CMKdhBEB4L24+Blg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=belxnzFSR9az5FXROOdocBz4q7NWYCHM8qPy7XtnKOh1ILb4hZHB5LsyYqOKNpQwQQ+FBovh9clcX0wPgfomevtENhIMA+jNTTo1+fbKKf/1S8Sf9xaR8L6JnJfiEvZtaMWUNZ5xQhlKAkGWEmT3ijWX5CnC7tXbAH7RF3Y04a8= 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=w30JlcnJ; arc=none smtp.client-ip=209.85.208.43 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 Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-563a772606aso1326124a12.0 for ; Thu, 15 Feb 2024 09:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708019219; x=1708624019; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=qGFi4nYhTSGzwEyDxOa4rN/Cn5B1c0Et6UQeZJ6o04k=; b=w30JlcnJCYta1W/T7gBC1rd4XdIHQVh6h53ZftOKenD+xEGkFhdFPL1f9Z/4VaTvB9 wkZEAon7YdXQWa26HzgQagx18E09v1MZvQ5KFz402+ew0g40DhR6hkav2/j3pP44+RZA IiNcQU+K/fXUs5s9LZh9fCPalrzLOhvcRjhfmKIstPach83jXUaIMWoKBWJWSl+4cpq8 8EArTaeOoxh620zP0vRs0MXo9tVztVrWPtYrYYOvecc/7A/a5FL4LkfTkxzlo16Y8Um0 UiQOyutmLcnGiX1dTHBYIW26HJdgFG3PR0jpbIqAwfGHrulIsLEV0y7eo8bHTJ9+oDx7 Skqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708019219; x=1708624019; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qGFi4nYhTSGzwEyDxOa4rN/Cn5B1c0Et6UQeZJ6o04k=; b=lO7yOp/8DRtTpYV5K3w72BYiORt2RgxeguNmxmruyyCFBzn4xF0Eb6w1T7hIGfgbD3 KzSpFgq/i3wpXuuokXmeuj4BsAEH+yPXdLV0kvY3p0O2rsUvHI9BS4QoCQClNh/m3e0m xPBRPEvyR4k2wvb8tHzoPjKo/t1gWtSG+LjBwp3C0Hdbfduml254bVufyhr8GLR64Td/ J5x7VHpNFenvG7IgZsU5wEjKSzZ3h1tDl42rkMByo2C0bJW4gEFSmonZXsjEqfDOm5IJ V9xMq5GpOFGLz7VA9eQTnfxTrOcJCoSJqhyfhBUVcinLWo0458H7KRhh28nK7Z3cYwb5 kcLw== X-Forwarded-Encrypted: i=1; AJvYcCUKJuHq0QseuIUkALS5PIYUgeaSEk5uuMNC9ovjw+3QQQs4ddDDxFEg2+ImJem4EhoAaobSNDLKNdU7tF8t2wS5WJo8pe+d0eLgVdbp X-Gm-Message-State: AOJu0YzLoHInaWgG11hn2ePUBpmkJL6OZDYkHZKfOEqhxOnPlRFFr4mX GqJ/BhYei5dRIOa2ie14d32pGiO+M4WgY01t8/VWqTzaZ6xesgqfZ7xAnNicfSg= X-Received: by 2002:aa7:d594:0:b0:562:d88:adca with SMTP id r20-20020aa7d594000000b005620d88adcamr2205053edq.17.1708019219334; Thu, 15 Feb 2024 09:46:59 -0800 (PST) Received: from [192.168.192.135] (078088045141.garwolin.vectranet.pl. [78.88.45.141]) by smtp.gmail.com with ESMTPSA id r1-20020a50d681000000b005638f04c122sm790193edi.14.2024.02.15.09.46.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Feb 2024 09:46:58 -0800 (PST) Message-ID: Date: Thu, 15 Feb 2024 18:46:55 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] PCI: dwc: Use the correct sleep function in wait_for_link To: Bjorn Helgaas , Alexander Lobakin Cc: Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Marijn Suijten , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold References: <20240215170258.GA1292702@bhelgaas> Content-Language: en-US From: Konrad Dybcio Autocrypt: addr=konrad.dybcio@linaro.org; keydata= xsFNBF9ALYUBEADWAhxdTBWrwAgDQQzc1O/bJ5O7b6cXYxwbBd9xKP7MICh5YA0DcCjJSOum BB/OmIWU6X+LZW6P88ZmHe+KeyABLMP5s1tJNK1j4ntT7mECcWZDzafPWF4F6m4WJOG27kTJ HGWdmtO+RvadOVi6CoUDqALsmfS3MUG5Pj2Ne9+0jRg4hEnB92AyF9rW2G3qisFcwPgvatt7 TXD5E38mLyOPOUyXNj9XpDbt1hNwKQfiidmPh5e7VNAWRnW1iCMMoKqzM1Anzq7e5Afyeifz zRcQPLaqrPjnKqZGL2BKQSZDh6NkI5ZLRhhHQf61fkWcUpTp1oDC6jWVfT7hwRVIQLrrNj9G MpPzrlN4YuAqKeIer1FMt8cq64ifgTzxHzXsMcUdclzq2LTk2RXaPl6Jg/IXWqUClJHbamSk t1bfif3SnmhA6TiNvEpDKPiT3IDs42THU6ygslrBxyROQPWLI9IL1y8S6RtEh8H+NZQWZNzm UQ3imZirlPjxZtvz1BtnnBWS06e7x/UEAguj7VHCuymVgpl2Za17d1jj81YN5Rp5L9GXxkV1 aUEwONM3eCI3qcYm5JNc5X+JthZOWsbIPSC1Rhxz3JmWIwP1udr5E3oNRe9u2LIEq+wH/toH kpPDhTeMkvt4KfE5m5ercid9+ZXAqoaYLUL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RJErbdRHsalwQCrtq/1ewQpMpsRxXzAjgfRN jc4tgxRWmI+aVTzSRpywNahzZBT695hMz81cVZJoZzaV0KaMTlSnBkrviPz1nIGHYCHJxF9r cIu0GSIyUjZ/7xslxdvjpLth16H27JCWDzDqIQMtg61063gNyEyWgt1qRSaK14JIH/DoYRfn jfFQSC8bffFjat7BQGFz4ZpRavkMUFuDirn5Tf28oc5ebe2cIHp4/kajTx/7JOxWZ80U70mA cBgEeYSrYYnX+UJsSxpzLc/0sT1eRJDEhI4XIQM4ClIzpsCIN5HnVF76UQXh3a9zpwh3dk8i bhN/URmCOTH+LHNJYN/MxY8wuukq877DWB7k86pBs5IDLAXmW8v3gIDWyIcgYqb2v8QO2Mqx YMqL7UZxVLul4/JbllsQB8F/fNI8AfttmAQL9cwo6C8yDTXKdho920W4WUR9k8NT/OBqWSyk bGqMHex48FVZhexNPYOd58EY9/7mL5u0sJmo+jTeb4JBgIbFPJCFyng4HwbniWgQJZ1WqaUC nas9J77uICis2WH7N8Bs9jy0wQYezNzqS+FxoNXmDQg2jetX8en4bO2Di7Pmx0jXA4TOb9TM izWDgYvmBE8= In-Reply-To: <20240215170258.GA1292702@bhelgaas> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 15.02.2024 18:02, Bjorn Helgaas wrote: > On Thu, Feb 15, 2024 at 02:35:13PM +0100, Alexander Lobakin wrote: >> From: Konrad Dybcio >> Date: Thu, 15 Feb 2024 11:39:31 +0100 >> >>> According to [1], msleep should be used for large sleeps, such as the >>> 100-ish ms one in this function. Comply with the guide and use it. >>> >>> [1] https://www.kernel.org/doc/Documentation/timers/timers-howto.txt >>> >>> Signed-off-by: Konrad Dybcio >>> --- >>> Tested on Qualcomm SC8280XP CRD >>> --- >>> drivers/pci/controller/dwc/pcie-designware.c | 2 +- >>> drivers/pci/controller/dwc/pcie-designware.h | 3 +-- >>> 2 files changed, 2 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c >>> index 250cf7f40b85..abce6afceb91 100644 >>> --- a/drivers/pci/controller/dwc/pcie-designware.c >>> +++ b/drivers/pci/controller/dwc/pcie-designware.c >>> @@ -655,7 +655,7 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci) >>> if (dw_pcie_link_up(pci)) >>> break; >>> >>> - usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX); >>> + msleep(LINK_WAIT_MSLEEP_MAX); >> >> Just use fsleep(LINK_WAIT_USLEEP_MAX) and let the kernel decide which >> function to pick. IMO, fsleep only makes sense when the argument is variable.. This way, we can save on bothering the compiler or adding an unnecessary branch > > Odd. > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/timers/timers-howto.rst?id=v6.7#n114 > mentions fsleep() (with no real guidance about when to use it), but > https://www.kernel.org/doc/Documentation/timers/timers-howto.txt > seems to be a stale copy from 2017, before fsleep() was added. I > emailed helpdesk@kernel.org to see if the stale content can be > removed. > > I do think fsleep() should be more widely used. > >>> /* Parameters for the waiting for link up routine */ >>> #define LINK_WAIT_MAX_RETRIES 10 >>> -#define LINK_WAIT_USLEEP_MIN 90000 >>> -#define LINK_WAIT_USLEEP_MAX 100000 >>> +#define LINK_WAIT_MSLEEP_MAX 100 > > Since you're touching this anyway, it would be helpful to include the > units on the timeout. > > USLEEP/MSLEEP is definitely a hint, but I think the "SLEEP" part > suggests something about atomic/non-atomic context and isn't relevant > to the time interval itself, and something like "TIMEOUT" would be > better. > > I think an explicit "_US" or "_MS" would better indicate the units. > > This is turning into a long tangent, but I'm not a huge fan of the > LINK_WAIT_* pattern where I have to look up the code that uses > LINK_WAIT_MAX_RETRIES and LINK_WAIT_USLEEP_MAX and do the math to see > what the actual timeout is. Obviously not fodder for *this* patch. Might as well do that indeed Konrad