From patchwork Mon Feb 5 11:44:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David X-Patchwork-Id: 196761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp818814dyb; Mon, 5 Feb 2024 03:49:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGD16gfeMRUZxs3VuGG6A2qpC6HAl4t/avCjqGvaPP8NvLSp7uMOQuUBu/LGdJqUrBCT2ip X-Received: by 2002:ac8:5c0d:0:b0:42c:f24:1893 with SMTP id i13-20020ac85c0d000000b0042c0f241893mr6506416qti.52.1707133749971; Mon, 05 Feb 2024 03:49:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707133749; cv=pass; d=google.com; s=arc-20160816; b=NE1pRXXnuUoPq4N75fpESDqkCfICTBaggT5sRrJywAZhObts2sXPDOe/ZlEh3DGA/y V6ogvD/H0oVem2ceHcWO0Ml3rj2rYN5ZDzvK4i0diYbCp/VBo72bhVPLgvo4RDy+H3w1 4hAvCX1FrAfvgX6nUSdCR12vEQvLaOcMgfmF0C/lRoUMTpDAQMCWBd9SwsfKuwm2ICBM su13z5cU3pSLG7v4zzT8Ymb2ohKGgIfjyRQSIYtJfffZ+Czejn0AsQdXIf/EuTuk7Gk4 +zWNHLX0hDT85cOV7pf/Dj8MsCsgnX54kfnVdnRMqymSMUCOdKod092mdSHO2JFpOVrV IGUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=m7buU54YASzC4cRoxXyJbvQsKrfgiWwIk/Xc2h1dSmE=; fh=R+S/X1WbxfI2TPZ8e/hu9hEwkTHm+VOdhGTBQOWW0aE=; b=U4vdkr3HE6q+AEHFVAv659axFAixAk3JKDqd8lglvA7Jo4k+Ku+lzf4OlWUPrHnZcE bErrFBJI+xCBEGhvpqQV1+eF7qVtnuMR0TmIlIB7GWgyH0BNhXFmzHC5dEocHHotGDFo tUeJJdpIWEI2UyCJe5w+tGAaNMAQ+mN6s82Bya+Lf6Ge7SaBbhM2MpzlGPUFjCUoIS7n N/9VFkMdgOE/ycuhMlCKfRhJpWGeT/ZghcZcrmg6pmQC58VPhaN0oWtl+Uxxl24lZw1w Cp8YPbSGNsStt/TdUVdMO0tDbToNk+EFm6SsEEkK6ZwpvKO9FdnM1NiLHqrvwL4AUgLE 5Qug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=davidv.dev); spf=pass (google.com: domain of linux-kernel+bounces-52518-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52518-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCW00CaGc0YoVsDpMRaLSD/3JMlV3T+7lBZQ0ifrFrFDKzEbSnzKGiM+cCv88+XKo+JZ04crf0XngSssC5VuzjTh4nkZ/g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id os41-20020a05620a812900b00785559d1a78si7481171qkn.0.2024.02.05.03.49.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 03:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52518-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=davidv.dev); spf=pass (google.com: domain of linux-kernel+bounces-52518-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52518-ouuuleilei=gmail.com@vger.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 C142E1C226B9 for ; Mon, 5 Feb 2024 11:49:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 230801A58E; Mon, 5 Feb 2024 11:48:53 +0000 (UTC) Received: from davidv.dev (mail.davidv.dev [78.46.233.60]) (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 BD0E619474 for ; Mon, 5 Feb 2024 11:48:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.46.233.60 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707133731; cv=none; b=hO7SlYSsNOzenfUZIBWUejQn3rzLXFLQ6g+NXJfkbfY8YL/KZchRKqkP0V93e5INH8Amq8D7bzZ5fMAApGpLBcZjOGXKujaEz6Mjf8xj1LOR+h6U114TVcFecYBg9Se21KTtvycjFwY3yRRZQYw8UuwSGzFa11f9Bic0FFf47H4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707133731; c=relaxed/simple; bh=zquoTPDiDMopq79YAJN8pFBJInmPfdGsBn+pPQU1BdE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=sBl+go7O2vYG1cqiptEEmJPq0DjElHKEkl+R3sGsVUUroVW+wZDtfCG3IR27WLcjYWCUaCqrgoU99+4acqvi+yxdH22dk+jyu9qUuxJhIfX2OUG6pn/aXtEhEHvo+mLXD2pVXatJguNuqpX08L+iMiAsMdb8IAt2CgBjjTCkXnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidv.dev; spf=pass smtp.mailfrom=davidv.dev; arc=none smtp.client-ip=78.46.233.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidv.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=davidv.dev Received: from framework.labs by mail.davidv.dev (chasquid) with ESMTPSA tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (over submission+TLS, TLS-1.2, envelope from "david@davidv.dev") ; Mon, 05 Feb 2024 12:46:51 +0100 From: David Ventura To: Cc: David Ventura , Jonathan Corbet , "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Greg Kroah-Hartman , "Paul E. McKenney" , Randy Dunlap , Xiongwei Song , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] net: make driver settling time configurable Date: Mon, 5 Feb 2024 12:44:40 +0100 Message-Id: <20240205114609.440597-1-david@davidv.dev> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790059478912614454 X-GMAIL-MSGID: 1790059478912614454 During IP auto configuration, some drivers apparently need to wait a certain length of time to settle; as this is not true for all drivers, make this length of time configurable. Signed-off-by: David Ventura --- .../admin-guide/kernel-parameters.txt | 4 ++++ Documentation/admin-guide/nfs/nfsroot.rst | 3 +++ net/ipv4/ipconfig.c | 23 ++++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b47940577c10..b07a035642fa 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2291,6 +2291,10 @@ ip= [IP_PNP] See Documentation/admin-guide/nfs/nfsroot.rst. + ip.dev_wait_ms= + [IP_PNP] + See Documentation/admin-guide/nfs/nfsroot.rst. + ipcmni_extend [KNL,EARLY] Extend the maximum number of unique System V IPC identifiers from 32,768 to 16,777,216. diff --git a/Documentation/admin-guide/nfs/nfsroot.rst b/Documentation/admin-guide/nfs/nfsroot.rst index 135218f33394..f26f7a342af6 100644 --- a/Documentation/admin-guide/nfs/nfsroot.rst +++ b/Documentation/admin-guide/nfs/nfsroot.rst @@ -223,6 +223,9 @@ ip=::::::: + Set the number of milliseconds to delay after opening the network device + which will be autoconfigured. Defaults to 10 milliseconds. nfsrootdebug This parameter enables debugging messages to appear in the kernel diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index c56b6fe6f0d7..cbf35163b973 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -82,8 +82,6 @@ #define IPCONFIG_DYNAMIC #endif -/* Define the friendly delay before and after opening net devices */ -#define CONF_POST_OPEN 10 /* After opening: 10 msecs */ /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */ #define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */ @@ -101,6 +99,7 @@ /* Wait for carrier timeout default in seconds */ static unsigned int carrier_timeout = 120; +static unsigned int dev_wait_ms = 10; /* * Public IP configuration @@ -1516,7 +1515,8 @@ static int __init ip_auto_config(void) return err; /* Give drivers a chance to settle */ - msleep(CONF_POST_OPEN); + if(dev_wait_ms > 0) + msleep(dev_wait_ms); /* * If the config information is insufficient (e.g., our IP address or @@ -1849,3 +1849,20 @@ static int __init set_carrier_timeout(char *str) return 1; } __setup("carrier_timeout=", set_carrier_timeout); + + +static int __init set_dev_wait_ms(char *str) +{ + ssize_t ret; + + if (!str) + return 0; + + ret = kstrtouint(str, 0, &dev_wait_ms); + if (ret) + return 0; + + return 1; +} + +__setup("ip.dev_wait_ms=", set_dev_wait_ms);