[PATCH 2/3] LEON3 SMP: support static interrupt affinity

Daniel Hellstrom daniel at gaisler.com
Tue Oct 7 14:29:53 UTC 2014


On 10/07/2014 03:51 PM, Gedare Bloom wrote:
> On Tue, Oct 7, 2014 at 5:10 AM, Daniel Hellstrom <daniel at gaisler.com> wrote:
>> ---
>>   c/src/lib/libbsp/sparc/leon3/include/bsp.h     |   11 +++++++
>>   c/src/lib/libbsp/sparc/shared/irq/irq-shared.c |   38 ++++++++++++++++++++----
>>   2 files changed, 43 insertions(+), 6 deletions(-)
>>
>> diff --git a/c/src/lib/libbsp/sparc/leon3/include/bsp.h b/c/src/lib/libbsp/sparc/leon3/include/bsp.h
>> index a4a4a6f..f398499 100644
>> --- a/c/src/lib/libbsp/sparc/leon3/include/bsp.h
>> +++ b/c/src/lib/libbsp/sparc/leon3/include/bsp.h
>> @@ -222,6 +222,17 @@ extern void BSP_shared_interrupt_mask(int irq);
>>    */
>>   extern unsigned char LEON3_mp_irq;
>>
>> +#ifdef RTEMS_SMP
>> +/* Weak table used to implement static interrupt CPU affinity in a SMP
>> + * configuration. The array index is the interrupt to be looked up, and
>> + * the array[INTERRUPT] content is the CPU number relative to boot CPU
>> + * index that will be servicing the interrupts from the IRQ source. The
>> + * default is to let the first CPU (the boot cpu) to handle all
>> + * interrupts (all zeros).
>> + */
>> +extern unsigned char bsp_irq2cpu[32];
> The bsp_ namespace probably should be considered reserved for "shared"
> bsp stuff. I'd prefer something more like sparc_irq_to_cpu[].

I will update the patch, thanks

DanielH


>
> -Gedare
>
>> +#endif
>> +
>>   #ifdef __cplusplus
>>   }
>>   #endif
>> diff --git a/c/src/lib/libbsp/sparc/shared/irq/irq-shared.c b/c/src/lib/libbsp/sparc/shared/irq/irq-shared.c
>> index b49621f..af1ce44 100644
>> --- a/c/src/lib/libbsp/sparc/shared/irq/irq-shared.c
>> +++ b/c/src/lib/libbsp/sparc/shared/irq/irq-shared.c
>> @@ -2,6 +2,30 @@
>>   #include <bsp.h>
>>   #include <bsp/irq-generic.h>
>>
>> +#if defined(RTEMS_SMP) && defined(LEON3)
>> +/* Interrupt to CPU map. Default to CPU0 since in BSS. */
>> +unsigned char bsp_irq2cpu[32] __attribute__((weak));
>> +
>> +/* On SMP use map table above relative to SMP Boot CPU (normally CPU0) */
>> +static inline int bsp_irq_cpu(int irq)
>> +{
>> +  /* protect from bad user configuration, default to boot cpu */
>> +  if (rtems_configuration_get_maximum_processors() <= bsp_irq2cpu[irq])
>> +    bsp_irq2cpu[irq] = 0;
>> +  return LEON3_Cpu_Index + bsp_irq2cpu[irq];
>> +}
>> +#else
>> +/* when not SMP the local CPU is returned */
>> +static inline int bsp_irq_cpu(int irq)
>> +{
>> +#ifdef LEON3
>> +  return _LEON3_Get_current_processor();
>> +#else
>> +  return 0;
>> +#endif
>> +}
>> +#endif
>> +
>>   static inline void bsp_dispatch_irq(int irq)
>>   {
>>          bsp_interrupt_handler_entry *e =
>> @@ -54,26 +78,28 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
>>
>>   rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
>>   {
>> -       BSP_Unmask_interrupt((int)vector);
>> +  int irq = (int)vector;
>> +  BSP_Cpu_Unmask_interrupt(irq, bsp_irq_cpu(irq));
>>
>> -       return RTEMS_SUCCESSFUL;
>> +  return RTEMS_SUCCESSFUL;
>>   }
>>
>>   rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
>>   {
>> -       BSP_Mask_interrupt((int)vector);
>> +  int irq = (int)vector;
>> +  BSP_Cpu_Mask_interrupt(irq, bsp_irq_cpu(irq));
>>
>> -       return RTEMS_SUCCESSFUL;
>> +  return RTEMS_SUCCESSFUL;
>>   }
>>
>>   void BSP_shared_interrupt_mask(int irq)
>>   {
>> -       BSP_Mask_interrupt(irq);
>> +  BSP_Cpu_Mask_interrupt(irq, bsp_irq_cpu(irq));
>>   }
>>
>>   void BSP_shared_interrupt_unmask(int irq)
>>   {
>> -       BSP_Unmask_interrupt(irq);
>> +  BSP_Cpu_Unmask_interrupt(irq, bsp_irq_cpu(irq));
>>   }
>>
>>   void BSP_shared_interrupt_clear(int irq)
>> --
>> 1.7.0.4
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel




More information about the devel mailing list