From patchwork Wed Feb 14 00:06:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 773225 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (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 121C47F for ; Wed, 14 Feb 2024 00:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707869223; cv=none; b=lCS4T4w2zclLEvoHSY3nNsb37MLrQjXBJen4zqa+eFRZvKNzXms2xdCgg59G96NoN5ibCQ4Fq1E8z38E2vY3VmCla5zpVYlT3r5CoVA1SgkEgNweGLMz0n/jq58gbQPS4LTKSuQpElPZ1QD0ZKw6tEbEol7Z5gsAU9V006f038o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707869223; c=relaxed/simple; bh=kRl2xvjnEqYqUWOmQ7ofjTzJ/cSkkaVkiE+7IUsfJIA=; h=Content-Type:Message-ID:Date:MIME-Version:To:Cc:From:Subject; b=Y6wKMbyBoMueyD/+KfBJ7SfmDoa7qEuPjkAl5S3WITkS9TPLH+cCN5E2cW/IYnxfMqQtL0AVQVYK0CXKYu25SqpRGE4elBi6IDcDKwSY5yDtYxXhj2jt76V7YsHjJsz42ZNgPW3YmawEefeHTvYFM6almphiWj3HYzfCs37JNak= 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=QwE61G5Q; arc=none smtp.client-ip=209.85.166.53 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="QwE61G5Q" Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-7c3d923f7cbso29479039f.0 for ; Tue, 13 Feb 2024 16:06:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1707869219; x=1708474019; darn=vger.kernel.org; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=GhnQu6FmXGPVZCi3UFjGPAyQfbh2TxR1NXwH/TlSM+w=; b=QwE61G5QxGU6+NPISDK5K/zPcZoewOWpMO53VHQQhTvAeiRApupQZRirnDOMz4Mr7D osl1qNBUquu6R7VqofaZUxuBAOZM+vsMGUPrlcPZpsXy+MOq+b4geSgiMsdhIzm4XdbJ jGIt6QuSn8rJ/KaVXEsm2qa61KPBH6zymYsU8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707869219; x=1708474019; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GhnQu6FmXGPVZCi3UFjGPAyQfbh2TxR1NXwH/TlSM+w=; b=dkc9bsiP3RqAFtd2sub4Zy+A1KjHKdsfDTvHRoGpTXZo+xU3EzB0bho8CB8rgT7yjW xoII1c/ugBKsIkFSSNrNKoPEG8/1HLZmNE2feNhz4NMlnU8KW6J8mg7FEJQP5lqq9TJV jbLNvgbxytSAeg6dLu6K6qKPqMMi/Pcz9PZTcCox7JRE+ijZR8hn4tYyUogkhWcj8ejY Q8/8lNGXk4TeXQFGNrJDFvesZwt+tGVyuKD8lPyhDHjt5rkU28j6pErnVWikyIvd6XOo LRViGaMsV5C8DQAIiIkMMlMxKYRM3pTa/MLbVeqcn5uZAFFpfySBrQemNYeMeGyScorV qrgA== X-Forwarded-Encrypted: i=1; AJvYcCWyVuhLIqMEc9NDO43ilkoqUpKAMXBeV136AD6Ik7/9wcmeYxl5SMxWqH3jPnArabAorbxH/vcJNLU7aZjeDQ+qLO58XZ25LOcnM5esH0di X-Gm-Message-State: AOJu0YyxyIfTjiXQhlxNs+7i2pHJqs8xGGY3fUeesDYvQSPysGtuP4fr uclkGD8fNpLOEyn/1BCYo99D3p0Zb6ozZM0K5iXdAVN4W6VrkozhhLVnIK3wAls= X-Google-Smtp-Source: AGHT+IHJKYRzo/PlZVd0iIErIR69DKw3o9VDIiU5d2kUn3AtE/swPSe1OtmTzjtH+2nxZIpUxXzPwQ== X-Received: by 2002:a6b:fe01:0:b0:7c4:8032:5724 with SMTP id x1-20020a6bfe01000000b007c480325724mr809467ioh.0.1707869219183; Tue, 13 Feb 2024 16:06:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXA4aTCw0RK9urTQ3ld4zkHTrIyDI62ZmJAw8XHTRnc+Cf9qmTZe9wUE4VytcuFEsKt28Assj+UwSbhwoKX1NH6EefWt9fsDYDqnZ4KSda9xxk2H3KI3oRUb0M3+TL6c7q8urMVMQgGg0aD/HORoX4GxOTZO6AUfDk6Mfy5td1nOyRw9JWXlHTE7ozVe12yoCDqpHIn574Da3TVmICHwQKIYphqF13wLv3vMRQYtn3CnJyfoUrutyZn Received: from [192.168.1.128] ([38.175.170.29]) by smtp.gmail.com with ESMTPSA id u25-20020a02cbd9000000b0047129817ee3sm2209721jaq.141.2024.02.13.16.06.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 16:06:58 -0800 (PST) Message-ID: <876716d6-f865-42cb-94d0-67e9193a96f3@linuxfoundation.org> Date: Tue, 13 Feb 2024 17:06:58 -0700 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Linus Torvalds Cc: shuah , Shuah Khan , Brendan Higgins , David Gow , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org From: Shuah Khan Subject: [GIT PULL] KUnit fixes update for Linux 6.8-rc5 Hi Linus, Please pull the following KUnit fixes update for Linux 6.8-rc5. This KUnit update for Linux 6.8-rc5 consists of one important fix to unregister kunit_bus when KUnit module is unloaded. Not doing so causes an error when KUnit module tries to re-register the bus when it gets reloaded. diff is attached. thanks, -- Shuah ---------------------------------------------------------------- The following changes since commit 1a9f2c776d1416c4ea6cb0d0b9917778c41a1a7d: Documentation: KUnit: Update the instructions on how to test static functions (2024-01-22 07:59:03 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-kunit-fixes-6.8-rc5 for you to fetch changes up to 829388b725f8d266ccec32a2f446717d8693eaba: kunit: device: Unregister the kunit_bus on shutdown (2024-02-06 17:07:37 -0700) ---------------------------------------------------------------- linux_kselftest-kunit-fixes-6.8-rc5 This KUnit update for Linux 6.8-rc5 consists of one important fix to unregister kunit_bus when KUnit module is unloaded. Not doing so causes an error when KUnit module tries to re-register the bus when it gets reloaded. ---------------------------------------------------------------- David Gow (1): kunit: device: Unregister the kunit_bus on shutdown lib/kunit/device-impl.h | 2 ++ lib/kunit/device.c | 14 ++++++++++++++ lib/kunit/test.c | 3 +++ 3 files changed, 19 insertions(+) ---------------------------------------------------------------- diff --git a/lib/kunit/device-impl.h b/lib/kunit/device-impl.h index 54bd55836405..5fcd48ff0f36 100644 --- a/lib/kunit/device-impl.h +++ b/lib/kunit/device-impl.h @@ -13,5 +13,7 @@ // For internal use only -- registers the kunit_bus. int kunit_bus_init(void); +// For internal use only -- unregisters the kunit_bus. +void kunit_bus_shutdown(void); #endif //_KUNIT_DEVICE_IMPL_H diff --git a/lib/kunit/device.c b/lib/kunit/device.c index 074c6dd2e36a..644a38a1f5b1 100644 --- a/lib/kunit/device.c +++ b/lib/kunit/device.c @@ -54,6 +54,20 @@ int kunit_bus_init(void) return error; } +/* Unregister the 'kunit_bus' in case the KUnit module is unloaded. */ +void kunit_bus_shutdown(void) +{ + /* Make sure the bus exists before we unregister it. */ + if (IS_ERR_OR_NULL(kunit_bus_device)) + return; + + bus_unregister(&kunit_bus_type); + + root_device_unregister(kunit_bus_device); + + kunit_bus_device = NULL; +} + /* Release a 'fake' KUnit device. */ static void kunit_device_release(struct device *d) { diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 31a5a992e646..1d1475578515 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -928,6 +928,9 @@ static void __exit kunit_exit(void) #ifdef CONFIG_MODULES unregister_module_notifier(&kunit_mod_nb); #endif + + kunit_bus_shutdown(); + kunit_debugfs_cleanup(); } module_exit(kunit_exit);