Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp587162rdb; Thu, 15 Feb 2024 09:03:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVfwl8wHQ3vszMy8xEMtFi9ePnVMl+cjDvlqR3/FZbTtW/RWWcX55IMchvM0QFzjKUhLzgGhH2Mo/0QFDJSFFtRyq5iJ5RMBJgJ83+Fkw== X-Google-Smtp-Source: AGHT+IGIFXoJqS+fJq3aMxcV8aispL5BZRiBInbBwvmYA0knYJKNgbC/WpEKfpenzrdb1f2ptwtH X-Received: by 2002:a05:6358:7589:b0:17a:df09:f2ab with SMTP id x9-20020a056358758900b0017adf09f2abmr2424607rwf.23.1708016589641; Thu, 15 Feb 2024 09:03:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708016589; cv=pass; d=google.com; s=arc-20160816; b=HOofXgfOLrXVo3XBB/IzPpGSFViq5N76tmqmH1Y1ePUlyNquPzSsPtmS1NA5ySpwKr Dp45m5G+zpoUM32iS7XStPICi/ZdJECa3HfO1qgtyn1adcbeiBAmReXHgQbcVDrZQ3zl elKKjY6B3znxc8j281Vg2Lhkf4msHciZyUD3tbkYuwyDVO33IDj2kR8CNZkC+9E9RXyH mZfCQFKU/LxQcU3p1mjbu4f1AYXagOQRZLctjWHzuhJrpQ1g99V34wzZIGPHeFN7NIKU /JcB9zH6ytbHp4PhPiXqaKNUx+Y3XVRwNBVeQyUGIyGIuCu6T4+umg0pxHka1BpXrhwb wFww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=gWP8QaP1UDo96azRY8URrjnKw5rUQYTiIO8XS+3i1Pw=; fh=5bz3KfQbQvAJUo9mkYF1JAFoGnaYuo9WZVU7HsjWSkk=; b=VOs95lRNdN51fCnAGJJJmbQ/9IHWNz3zA90RoqnRfkbm5H+wJMN9+9NsWqk61kB+WU iKGTgDjc+cpT9l/hqVihJWukrQ18WOutdfFpt675t1Wc1v2W8j5C4EzbXEXZeEA462IT QNfRclQawix4k4Xxr6r2KRYOo4cvqjGcW7AAgCfqKMATZnxWx5c0Jyp7SIquXuYF/NLR 8z6szronIPUQNgowfTlgO6BoXXi3qxutIL108Dd4IdfHZ6NO9af56AGdCjp98LPJ02s/ A7tPrJlhs+4NwIVpKNVXPW0f+Rz6pOGLqn97SOTpDino3qcA3eVDu3wyyXUbbFcYUIZP 9Vqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J7HEMHyI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-67360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p22-20020ac87416000000b0042c6b42aa88si1649337qtq.653.2024.02.15.09.03.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 09:03:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J7HEMHyI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-67360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 63DAC1C215F8 for ; Thu, 15 Feb 2024 17:03:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4816A136665; Thu, 15 Feb 2024 17:03:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J7HEMHyI" 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 642AD1754B; Thu, 15 Feb 2024 17:03:00 +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=1708016580; cv=none; b=kUdKSkZTEWHQJUCoa+Ua2xQdkmXsaDI+6zWKFLUArJWm/obB5AqznJsFcEu/bpLwCZOgXhyehRmaes7qtjJiDKUTOmweDMb3leYSmeGj9/ilZG0zJ5MuvVGiHFvlk7gYCdBRL++irHxMpWTXMxW9Kve/LrFqfFjddJPkWCkf5Dc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708016580; c=relaxed/simple; bh=N1m0kPjc7D24yEHh5GCbtG5RxZ9QtaO4otDQYDmi8rE=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=d1ofM9+Zn/7QqDpBYBCY1qGMEG4rQV4SXmyyLroZpsre6MDCY/44vd2rMIYO6305vsbN+5ByzVHNxWnL1MHsqA3+dy4Op/fuOEMEF4NwQK40mlronK+8+NWJWAQnd5q3SmSb3ugfhnOBUDpF2VkE50GTTGd+ESwLwh5z9oMihiU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J7HEMHyI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E2BDC433F1; Thu, 15 Feb 2024 17:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708016579; bh=N1m0kPjc7D24yEHh5GCbtG5RxZ9QtaO4otDQYDmi8rE=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=J7HEMHyICW+lND9f9nL4zGh4EuhNKxyu1pocmvfWJJJ41LXKdStLT7I4cpsU/oGGf U1XYFWSwlYncng5/yRVzAS3VJy/k3BkLT2u75gOwk5lRhOx7r/9ezkKYPe+bLTtsJy juTBxqB3UvitOk2fmthh37dWaznvCbCKomD5X1QqoZsntIaWIjm9jgBlou1aGXLUhc uosFTdmdeekyQbJiTMg7hbChm1ZIxN0L3hiJRAH38bK2Fl5rCS8c8LUjmElxC6dQc1 nKoBWHBddKeTd6zfad9lxr0YUytYEmJ3ZbyAR2+20SyK2sPGfpewTvoyX6/ybb9dSh 8fluJ185PiChw== Date: Thu, 15 Feb 2024 11:02:58 -0600 From: Bjorn Helgaas To: Alexander Lobakin Cc: Konrad Dybcio , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Marijn Suijten , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: Re: [PATCH] PCI: dwc: Use the correct sleep function in wait_for_link Message-ID: <20240215170258.GA1292702@bhelgaas> 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-Disposition: inline In-Reply-To: <7611f6f9-a021-4bbd-bc71-5363af3d9391@intel.com> 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. 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. Bjorn