Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp502426rdb; Thu, 15 Feb 2024 06:49:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCULZIsIL6S38kL50/Aq6QgftL10cIvxhAbDiTdcV9G1aoTvMRio4nUBw6lesH/ZQhp5A9T1LDalSMo3vLF+9jbLVkhBV0n4cjt06Jk8sg== X-Google-Smtp-Source: AGHT+IEEtXPpaWYyikShc0XrOcrQeLcyYZK3W74P0hWVD8+4tJfnotUvnCyAJJjpODd08g7wh6zo X-Received: by 2002:a05:6e02:dc4:b0:363:c2f8:fd16 with SMTP id l4-20020a056e020dc400b00363c2f8fd16mr1687604ilj.21.1708008582517; Thu, 15 Feb 2024 06:49:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708008582; cv=pass; d=google.com; s=arc-20160816; b=B6CmwP/bLXZKTIrGl9PeUnktZCEu1utq5eCOMxAwkuNGkucxkbvvg6bS4g7mrUZskK S8VGsdDHB21rtUBLbBOmwcQEWS5+IeySsKJddLXd0Ite3WsdltJS/bKMsRdEBeeQ96XL KfnWkRUtGDuCOqTn2IBgPXYzxbDJ8x3CkjQUMpx6VOMtcnVLfDTqF69LVyDg1QREgfN/ 0paMHswE0E8KiG8UmPuvIGybd4eINwLVymoBLd2tQ1mHAH2ZBoEHosHraYWD0ASA6ZCQ 5Fo8MDc+cS2Z5B7iCisVLgmMLAcmtADC3ZvFb9xdM9O92AFSWL1QWT4G0bbmS5YKo/y5 oPCA== 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:references:message-id:subject:cc :to:from:date:dkim-signature; bh=HT54JnEJDGAg08CMMVH/+M305jfI2/9H3G2UVROz1uY=; fh=R7me8cs42/RE8vATQBqZvG661bgG4aw4R8IfjKWv+Gc=; b=GnLQl1i1iyfDclmNSzl3zKnZUcVV9tS7I9ZA+ezZdvjPOw1sgpYwE5XVO5yciFb3HJ y56dp2QNJUi34o4XKxT/kO7F5a3xUOvtIgBzXmO7YgUe0B6oj2xrIcORB61dDjF9CDsL PX3GqOc1xxXZGIjIJmJqB+X/fgCf/OEdPFmjLBFjB4JN5EyGKvv3rd3De6oUSTGCdlio po5UiDHdOgdfq7HOyJKv8n2VjPjcu5EoVdUD+O/zB77X5tC/KOfnlb7sOJNVYj57/Wpv QVItFZJsd//MtUPeDZfjb1V/QElUAu8YZQycNfeWX5RVbn4LumlRV2ZRSqV5qFZ+UjVJ SngA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BPZ7w0Yh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67070-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 9-20020a630009000000b005dc962cfb75si1194694pga.40.2024.02.15.06.49.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:49:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BPZ7w0Yh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67070-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4E71BB26147 for ; Thu, 15 Feb 2024 14:17:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 012E7131E3D; Thu, 15 Feb 2024 14:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BPZ7w0Yh" Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 723EA129A73; Thu, 15 Feb 2024 14:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708006639; cv=none; b=RiJYA2eKFS8bDAo271NA0YeoICOj/tOWhWuNOAa+TFcaxWaKer8H3zPhSwKNUX4hCUcTkWt5x/dJ0a1bR1dIbu1j7S3W5eP0zlSgsK9w2Tz57hvaWGO6y33RxHr080Yhh64WnwWMHu+MpoRjx2K1SIHbZrPvLnc26LXCfVy0MpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708006639; c=relaxed/simple; bh=4H+iR8aGxxFCoMFHwf2l19pGGIJ92Ffk8H4vV2vpgOY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IVh3qsH8Qyl1+iD6bFpemnJgORvJ/rAAQI++p2rF9IRojBU3aGkxikAVJDd4ZehgyMGYOoshmn+ItEwbqm6K2B2G55IM9OHH8oit0BjBxjcg2jBiBXXadLARzRsqa1s+C3OyF9zk1sML25XuB4a+KAyFVJ07rOQuS0cCsyWaqdc= 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=BPZ7w0Yh; arc=none smtp.client-ip=209.85.208.170 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 Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d0bc402c8eso8967351fa.1; Thu, 15 Feb 2024 06:17:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708006635; x=1708611435; 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=HT54JnEJDGAg08CMMVH/+M305jfI2/9H3G2UVROz1uY=; b=BPZ7w0YhQz6C61dr+/8A9VqEfVVBCi6nn1ABmYgy0FnngET4+9ufp8lIqT2TmHu6MI 3UgJkhFZja4GfPK2kOX7lXNSfojA61S8RgMjude30cbWPKbGeA7pY0DERyW1Nu2e6R6d XRXkqcp5L2B9ruVP6aqbfC0snq/hg+Qs3Y76H079YMKUNnPfrp7eGb8j5+KnmM0CO+QS VGmqeig+bL0keZ97QqwdNlidnSXBrSRrLy5EzlNQgzHHAXLB6c0nv3JTiwrnqJ7gw+YO vEbWo2ivuJ4WDzC/5TdAKiuzqtIkuBoevKQF/r5oMDyYolwtTE5/oNhRdvXxpZONNwvJ 5iNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708006635; x=1708611435; 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=HT54JnEJDGAg08CMMVH/+M305jfI2/9H3G2UVROz1uY=; b=vfvlYasVIkHcKeFt9R0Z+jullCnwGfog0rOQibpKwaFJNM9pa1jYZJJriIDSeP1Pre Jll2TzaBIGwuMQL4x8HtGHI155H/K/3P6n1+AfgrxQlYwei+lWXhIP+h7vjSWSdMSmhA sAmk/NwvU9yS2WPCgxecsF4FvNgtW2tx2h8Lt6CvCnQPTSjdAd8TnYKMpONnGLc609QJ EJDCRtJMb9sx+W8fw02YRSrlBBH2r/Y7r1QaFx43lUDTwTOTKjs1UUGkryZ+uDTeg+go cPeqbqG/ZNTcFs58nJ0FNEKloE79bYJZkiTHn5BMNN1k4FSzI6dO7vRDta9sE1sv2QqR 31mQ== X-Forwarded-Encrypted: i=1; AJvYcCXUkBqZ1yDmxnnJNJBLRVY2dKRaBwE3Zv9PCq1LH+LyOIxt3zPvpFZ3kfY/ax2CMSzijrWhsIEyYmtyGZeG37tkOZre3TuW+PS/5XbYP0KMDUTYV0iPsDcfE8N/r3CY78K9UbpPABDH X-Gm-Message-State: AOJu0YzM5uYhdYZ0cEDHIevIiei0EU8AT5PU5yJUlFkPbEhJSRgRWbyR 2/QZElyUlP4ZfF1rDPgc1LYBvEMKkNux8GmBNaqemcmiuQAJV8QN X-Received: by 2002:a2e:9d10:0:b0:2d0:af40:7058 with SMTP id t16-20020a2e9d10000000b002d0af407058mr621746lji.14.1708006635324; Thu, 15 Feb 2024 06:17:15 -0800 (PST) Received: from mobilestation ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id t17-20020a2e7811000000b002d0d0d06fcfsm290350ljc.103.2024.02.15.06.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:17:14 -0800 (PST) Date: Thu, 15 Feb 2024 17:17:12 +0300 From: Serge Semin To: Konrad Dybcio Cc: 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: References: <20240215-topic-pci_sleep-v1-1-7ac79ac9739a@linaro.org> 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: <20240215-topic-pci_sleep-v1-1-7ac79ac9739a@linaro.org> On Thu, Feb 15, 2024 at 11:39:31AM +0100, Konrad Dybcio wrote: > 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); > } > > if (retries >= LINK_WAIT_MAX_RETRIES) { > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h > index 26dae4837462..3f145d6a8a31 100644 > --- a/drivers/pci/controller/dwc/pcie-designware.h > +++ b/drivers/pci/controller/dwc/pcie-designware.h > @@ -63,8 +63,7 @@ > > /* 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 Why do you use the _MAX suffix here? AFAICS any the timers normally ensures the lower boundary value of the wait-duration, not the upper one. So the more correct suffix would be _MIN. On the other hand, as Alexander correctly noted, using fsleep() would be more suitable at least from the maintainability point of view. Thus having a macro name like LINK_WAIT_USLEEP_MIN or just LINK_WAIT_SLEEP_US would be more appropriate. The later version is more preferable IMO. -Serge(y) > > /* Parameters for the waiting for iATU enabled routine */ > #define LINK_WAIT_MAX_IATU_RETRIES 5 > > --- > base-commit: 26d7d52b6253574d5b6fec16a93e1110d1489cef > change-id: 20240215-topic-pci_sleep-368108a1fb6f > > Best regards, > -- > Konrad Dybcio > >