From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 B1FB838F629 for ; Thu, 26 Mar 2026 18:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774550618; cv=none; b=OWtZOCn/FIfOjDbnLdSfSkhK9nGtOhRpMGVHzmYCFNemqhKo6EvpK//XUhsZwnLZrmbQ+4H4YGby2TRN4PP2APo+07inVygGmUWCXAi0z8PNssto62iw52mUxI8u4HQq3NqkwZzphNZ+s2cxCHXswHlRuH7RYDtlB+IGLgpHU84= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774550618; c=relaxed/simple; bh=InXSrhRJSMDGAdbor7H8X1jrD9DikbaAHcnldY6jQ+I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=AaRSWJVcu269WF3V8OhzI2kkht0P2cD8uz/x4xPo566hSQZhjGEKD3Ryd4wyn6OfmXdsoIylVVOBFnMxo5wnH8qQlyClKoX3enPNaiHpwy20DtE+9wnbQ/fxlIkaCaGmvT3QXxo/XKkxcB570FH2mivvIg+rk0YP7kr9hzLOfTg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=felgqF8S; arc=none smtp.client-ip=209.85.167.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="felgqF8S" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-466ec4c6846so477841b6e.3 for ; Thu, 26 Mar 2026 11:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1774550616; x=1775155416; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=eRkfsmO5ysCB/VQlJ8SAYpDp5OzoDNr1Qv+WT6tm4Os=; b=felgqF8SytzfUZUD93wAV6EirE8TL1+BB3cD5GWodwVQ7zO0E+Lte/j+6izit1/nls xnH+hdwe7dupgGPjSkS7YyU4EK3LPdOrxbK6Zk+sYCXIdbmOZRaUO8TZLyGhzHRma0wQ kn8SdlhUnxTX4CXesuGzmfLbYkzwxUdlaJjy0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774550616; x=1775155416; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eRkfsmO5ysCB/VQlJ8SAYpDp5OzoDNr1Qv+WT6tm4Os=; b=Gj7xkLXonrfxReZYJwNWzMZXdY5WtPltxIYOIzGTWoZKm8mheoj2SfiX26uTLDHZJQ pwoPVNFiMhtcDtjkrt7exCrIjw+uU7gqophDe9vCsntuCkEYQltGsWiatTmU/bZowB1+ 6uq7G+8YRzD4do7D6i8CELwLHqR7LwoqK5UFacNtIXUjpi6i+6cIchaztg9ESRfCVjlG zzUIqWqu+TUGikcIYiBVNYFs94seXjfa1Ogjv6IjTYClrCNA1IuAKASK+h87StvPQmH4 Z3qIZSDFMt3KQKQbwy19NAhF3i7SMZvhAr7eespQY42WV9HQQ4J5IspPLQvj5RGyaHuf 7zFw== X-Forwarded-Encrypted: i=1; AJvYcCULv+B7HgLUc6fG4heOjN2RDMTP6vCXldqi3q+mGz2EzsnZCMbeVbG7R3XDtpNWHYp8/zsfekeiTYLZ/is=@vger.kernel.org X-Gm-Message-State: AOJu0YwSoLmONkobtxhYmYqUZsC1IS3eMEA9cfF/JvoaN+ZI2UNNWUzg sXd33UojTK+JNHJD5f06olFlhcybD2mRka+V4AZgfaPygKwN6Nwbq1Rvx2AMCfuxZ+I= X-Gm-Gg: ATEYQzzG2msYGBBtPdlpx+3I4E3Zm45eXPs8wn6WqyZmnjbBuNc7ffXu+HA8GVafouU YJaczwwQO3QSj18+oXkeQoj9ErW0hhgQEPsx7QOll/YPUsQEP5U3jYa2DgW4jgv9MJEZ0wrR9X2 yuDmMpflt9780jti7UchnYRuUZNXrTMKYatZNfUhyAndisV9s1TioWhpr1sTZ3p32kGK0QxmtYk yMppu6JFs7EnU8xsvlxRDtGg0JWqfjHmwYgnPrbKf4Omf/bvAjHqMRN5THFW5OQqJ14MRM3IxW6 sQs49ZjGgW8YKR9HZ6M2UYWy5tXYoww/IArajDmuBqaUeUS8QEUduryuljkqdtc8hTaU4cUM8H0 z7AFjuGiEAX+1bSVmTpRdAd4GKM6QCNmRMqYyCQ+MMKh3NBBeCWabh5EzObBYcLE72H4HJwYyJg AzEbqO6t+d18kc9t88x3YrSqGsWoK9badD9hu70qzBweNvDg== X-Received: by 2002:a05:6808:1582:b0:467:14c7:a8ba with SMTP id 5614622812f47-46a5c6e70d1mr4401455b6e.32.1774550615648; Thu, 26 Mar 2026 11:43:35 -0700 (PDT) Received: from [192.168.1.14] ([38.175.187.108]) by smtp.gmail.com with ESMTPSA id 5614622812f47-46a7099df08sm2139529b6e.15.2026.03.26.11.43.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Mar 2026 11:43:35 -0700 (PDT) Message-ID: <1e974e1d-afdc-41a5-95a7-45e19e77a087@linuxfoundation.org> Date: Thu, 26 Mar 2026 12:43:33 -0600 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 v2] usbip: tools: Add usbip host driver availability check To: Greg KH , Zongmin Zhou Cc: i@zenithal.me, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, valentina.manea.m@gmail.com, Zongmin Zhou , Shuah Khan References: <29c03d8b-c73b-4393-95ff-bbf5c31df86e@linuxfoundation.org> <20260325022634.279624-1-min_halo@163.com> <2026032555-headrest-example-af16@gregkh> <1fdab10a-86f0-454a-af10-396a53169ea7@163.com> <2026032615-donated-chaps-9eac@gregkh> Content-Language: en-US From: Shuah Khan In-Reply-To: <2026032615-donated-chaps-9eac@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/26/26 02:43, Greg KH wrote: > On Thu, Mar 26, 2026 at 11:10:02AM +0800, Zongmin Zhou wrote: >> >> On 2026/3/25 16:58, Greg KH wrote: >>> On Wed, Mar 25, 2026 at 10:26:34AM +0800, Zongmin Zhou wrote: >>>> From: Zongmin Zhou >>>> >>>> Currently, usbip_generic_driver_open() doesn't verify that the required >>>> kernel module (usbip-host or usbip-vudc) is actually loaded. >>>> The function returns success even when no driver is present, >>>> leading to usbipd daemon run success without driver loaded. >>>> >>>> So add a check function to ensure usbip host driver has been loaded. >>>> >>>> Suggested-by: Shuah Khan >>>> Signed-off-by: Zongmin Zhou >>>> --- >>>> Changes in v2: >>>> - Use system calls directly instead of checking sysfs dir. >>>> >>>> tools/usb/usbip/libsrc/usbip_device_driver.c | 7 +++++-- >>>> tools/usb/usbip/libsrc/usbip_host_driver.c | 8 ++++++-- >>>> 2 files changed, 11 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c >>>> index 927a151fa9aa..45ab647ef241 100644 >>>> --- a/tools/usb/usbip/libsrc/usbip_device_driver.c >>>> +++ b/tools/usb/usbip/libsrc/usbip_device_driver.c >>>> @@ -136,10 +136,13 @@ static int usbip_device_driver_open(struct usbip_host_driver *hdriver) >>>> hdriver->ndevs = 0; >>>> INIT_LIST_HEAD(&hdriver->edev_list); >>>> - ret = usbip_generic_driver_open(hdriver); >>>> - if (ret) >>>> + if (system("/sbin/lsmod | grep -q usbip_vudc")){ >>> What happens if the module is built into the kernel? >>> >>>> err("please load " USBIP_CORE_MOD_NAME ".ko and " >>>> USBIP_DEVICE_DRV_NAME ".ko!"); >>>> + return -1; >>>> + } >>>> + >>>> + ret = usbip_generic_driver_open(hdriver); >>>> return ret; >>>> } >>>> diff --git a/tools/usb/usbip/libsrc/usbip_host_driver.c b/tools/usb/usbip/libsrc/usbip_host_driver.c >>>> index 573e73ec36bd..f0ac941d4f6e 100644 >>>> --- a/tools/usb/usbip/libsrc/usbip_host_driver.c >>>> +++ b/tools/usb/usbip/libsrc/usbip_host_driver.c >>>> @@ -31,10 +31,14 @@ static int usbip_host_driver_open(struct usbip_host_driver *hdriver) >>>> hdriver->ndevs = 0; >>>> INIT_LIST_HEAD(&hdriver->edev_list); >>>> - ret = usbip_generic_driver_open(hdriver); >>>> - if (ret) >>>> + if (system("/sbin/lsmod | grep -q usbip_host")){ >>> Same here, what happens if it is built in? >> Thank you for pointing this out. >> I apologize for not considering the built-in module case. >> >> You are right that using lsmod | grep would incorrectly fail when usbip_host >> is built into the kernel (CONFIG_USBIP_HOST=y). >> Usbip has always been built as a loadable module (.ko) by default, which led >> to this oversight. >> >> To address this issue, would the following approach be acceptable? > > Wait, what "issue" are you trying to fix here? Why can't you just check > for opening the correct device node when the host opens the file and if > that fails, report an error? Doesn't that happen today already? > The problem Zongmin is trying fix ish when usbipd starts, it looks for exported if any - if it doesn't find any it assumes there aren't any exported and doesn't detect that usbip_host driver isn't loaded. refresh_exported_devices() doesn't have the logic and it shouldn't include that logic because this hook is called periodically to refresh the list of exported devices. Starting usbipd and loading the driver are distinct steps and without any dependencies. This patch he is trying to add that detection so a message can be printed to say "load the driver". A message can be added easily to cover two cases: 1. usbip_host driver isn't loaded 2. There are no exported devices. refresh_exported_devices() will not find any devices in both of the above scenarios. It isn't an error if it can't find any exported devices. An informational message when refresh_exported_devices() when it doesn't find any devices could help users. Zongmin, Would adding a message that says "Check if usbip_host driver is loaded or export devices" solve the problem of hard to debug problem you are addressing here? thanks, -- Shuah