diff mbox series

[kvm-unit-tests,v2,3/9] s390x: irq: make IRQ handler weak

Message ID 1574945167-29677-4-git-send-email-pmorel@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390x: Testing the Channel Subsystem I/O | expand

Commit Message

Pierre Morel Nov. 28, 2019, 12:46 p.m. UTC
Having a weak function allows the tests programm to declare its own
IRQ handler.
This is helpfull for I/O tests to have the I/O IRQ handler having
its special work to do.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 lib/s390x/interrupt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Hildenbrand Nov. 29, 2019, 12:01 p.m. UTC | #1
On 28.11.19 13:46, Pierre Morel wrote:
> Having a weak function allows the tests programm to declare its own
> IRQ handler.
> This is helpfull for I/O tests to have the I/O IRQ handler having
> its special work to do.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> ---
>  lib/s390x/interrupt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
> index 3e07867..d70fde3 100644
> --- a/lib/s390x/interrupt.c
> +++ b/lib/s390x/interrupt.c
> @@ -140,7 +140,7 @@ void handle_mcck_int(void)
>  		     lc->mcck_old_psw.addr);
>  }
>  
> -void handle_io_int(void)
> +__attribute__((weak)) void handle_io_int(void)
>  {
>  	report_abort("Unexpected io interrupt: at %#lx",
>  		     lc->io_old_psw.addr);
> 

The clear alternative would be a way to register a callback function.
That way you can modify the callback during the tests. As long as not
registered, wrong I/Os can be caught easily here. @Thomas?
Thomas Huth Dec. 2, 2019, 10:41 a.m. UTC | #2
On 29/11/2019 13.01, David Hildenbrand wrote:
> On 28.11.19 13:46, Pierre Morel wrote:
>> Having a weak function allows the tests programm to declare its own
>> IRQ handler.
>> This is helpfull for I/O tests to have the I/O IRQ handler having
>> its special work to do.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>> ---
>>  lib/s390x/interrupt.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
>> index 3e07867..d70fde3 100644
>> --- a/lib/s390x/interrupt.c
>> +++ b/lib/s390x/interrupt.c
>> @@ -140,7 +140,7 @@ void handle_mcck_int(void)
>>  		     lc->mcck_old_psw.addr);
>>  }
>>  
>> -void handle_io_int(void)
>> +__attribute__((weak)) void handle_io_int(void)
>>  {
>>  	report_abort("Unexpected io interrupt: at %#lx",
>>  		     lc->io_old_psw.addr);
>>
> 
> The clear alternative would be a way to register a callback function.
> That way you can modify the callback during the tests. As long as not
> registered, wrong I/Os can be caught easily here. @Thomas?

I don't mind too much, but I think I'd also slightly prefer a registered
callback function here instead.

 Thomas
Pierre Morel Dec. 2, 2019, 4:55 p.m. UTC | #3
On 2019-12-02 11:41, Thomas Huth wrote:
> On 29/11/2019 13.01, David Hildenbrand wrote:
>> On 28.11.19 13:46, Pierre Morel wrote:
>>> Having a weak function allows the tests programm to declare its own
>>> IRQ handler.
>>> This is helpfull for I/O tests to have the I/O IRQ handler having
>>> its special work to do.
>>>
>>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>>   lib/s390x/interrupt.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
>>> index 3e07867..d70fde3 100644
>>> --- a/lib/s390x/interrupt.c
>>> +++ b/lib/s390x/interrupt.c
>>> @@ -140,7 +140,7 @@ void handle_mcck_int(void)
>>>   		     lc->mcck_old_psw.addr);
>>>   }
>>>   
>>> -void handle_io_int(void)
>>> +__attribute__((weak)) void handle_io_int(void)
>>>   {
>>>   	report_abort("Unexpected io interrupt: at %#lx",
>>>   		     lc->io_old_psw.addr);
>>>
>>
>> The clear alternative would be a way to register a callback function.
>> That way you can modify the callback during the tests. As long as not
>> registered, wrong I/Os can be caught easily here. @Thomas?
> 
> I don't mind too much, but I think I'd also slightly prefer a registered
> callback function here instead.
> 
>   Thomas
> 

As you like but I wonder why you prefer the complicated solution.
The kvm-unit-test is single task, if a test really need something 
complicated it can be done in the test not in the common code.

Anyway I do like you want.
diff mbox series

Patch

diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
index 3e07867..d70fde3 100644
--- a/lib/s390x/interrupt.c
+++ b/lib/s390x/interrupt.c
@@ -140,7 +140,7 @@  void handle_mcck_int(void)
 		     lc->mcck_old_psw.addr);
 }
 
-void handle_io_int(void)
+__attribute__((weak)) void handle_io_int(void)
 {
 	report_abort("Unexpected io interrupt: at %#lx",
 		     lc->io_old_psw.addr);