[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <02b6537d-97e6-c27b-7621-c5b116995a00@linux.ibm.com>
Date: Wed, 13 Jul 2022 10:39:47 +0200
From: Steffen Eiden <seiden@...ux.ibm.com>
To: Claudio Imbrenda <imbrenda@...ux.ibm.com>
Cc: Heiko Carstens <hca@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>, linux-s390@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org, nrb@...ux.ibm.com
Subject: Re: [PATCH 3/3] s390/uvdevice: autoload module based on CPU facility
On 7/12/22 18:49, Claudio Imbrenda wrote:
> On Tue, 12 Jul 2022 12:52:20 +0200
> Steffen Eiden <seiden@...ux.ibm.com> wrote:
>
>> Make sure the uvdevice driver will be automatically loaded when
>> facility 158 is available.
>>
>> Signed-off-by: Steffen Eiden <seiden@...ux.ibm.com>
>> ---
>> arch/s390/include/asm/cpufeature.h | 1 +
>> arch/s390/kernel/cpufeature.c | 1 +
>> drivers/s390/char/uvdevice.c | 5 ++---
>> 3 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/s390/include/asm/cpufeature.h b/arch/s390/include/asm/cpufeature.h
>> index aa8081dad411..4b17f876ab54 100644
>> --- a/arch/s390/include/asm/cpufeature.h
>> +++ b/arch/s390/include/asm/cpufeature.h
>> @@ -33,6 +33,7 @@ enum {
>> S390_CPU_FEATURE_NNPA,
>> S390_CPU_FEATURE_PCI_MIO,
>> S390_CPU_FEATURE_SIE,
>> + S390_CPU_FEATURE_UV,
>> MAX_CPU_FEATURES
>> };
>>
>> diff --git a/arch/s390/kernel/cpufeature.c b/arch/s390/kernel/cpufeature.c
>> index e70b29804db4..0b854d37edcb 100644
>> --- a/arch/s390/kernel/cpufeature.c
>> +++ b/arch/s390/kernel/cpufeature.c
>> @@ -42,6 +42,7 @@ static struct s390_cpu_feature s390_cpu_features[MAX_CPU_FEATURES] = {
>> [S390_CPU_FEATURE_NNPA] = {.type = TYPE_HWCAP, .num = HWCAP_NR_NNPA},
>> [S390_CPU_FEATURE_PCI_MIO] = {.type = TYPE_HWCAP, .num = HWCAP_NR_PCI_MIO},
>> [S390_CPU_FEATURE_SIE] = {.type = TYPE_HWCAP, .num = HWCAP_NR_SIE},
>> + [S390_CPU_FEATURE_UV] = {.type = TYPE_FACILITY, .num = 158},
>> };
>>
>> /*
>> diff --git a/drivers/s390/char/uvdevice.c b/drivers/s390/char/uvdevice.c
>> index 66505d7166a6..1d40457c7b10 100644
>> --- a/drivers/s390/char/uvdevice.c
>> +++ b/drivers/s390/char/uvdevice.c
>> @@ -27,6 +27,7 @@
>> #include <linux/stddef.h>
>> #include <linux/vmalloc.h>
>> #include <linux/slab.h>
>> +#include <linux/cpufeature.h>
>>
>> #include <asm/uvdevice.h>
>> #include <asm/uv.h>
>> @@ -244,12 +245,10 @@ static void __exit uvio_dev_exit(void)
>>
>> static int __init uvio_dev_init(void)
>> {
>> - if (!test_facility(158))
>> - return -ENXIO;
>> return misc_register(&uvio_dev_miscdev);
>> }
>>
>> -module_init(uvio_dev_init);
>> +module_cpu_feature_match(S390_CPU_FEATURE_UV, uvio_dev_init);
>
> does this still prevent manual loading when the feature is not present?
yes.
Have a look at the macro definition at 'include/linux/cpufeature.h':
Use module_cpu_feature_match(feature, module_init_function) to
declare that
[snip]
b) the module must not be loaded if CPU feature 'feature' is not present
(not even by manual insmod).
The test 'facility(158)' just moved to cpu_have_feature() in
'/arch/s390/kernel/cpufeature.c'.
>
>> module_exit(uvio_dev_exit);
>>
>> MODULE_AUTHOR("IBM Corporation");
>
Powered by blists - more mailing lists