[rtems commit] bsps/irq: Improve affinity set handling

Sebastian Huber sebh at rtems.org
Wed Mar 16 06:24:25 UTC 2022


Module:    rtems
Branch:    master
Commit:    f311caf984a46b8629f891de5904af385486fa9e
Changeset: http://git.rtems.org/rtems/commit/?id=f311caf984a46b8629f891de5904af385486fa9e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Mar 15 17:34:34 2022 +0100

bsps/irq: Improve affinity set handling

Restrict the affinity set to the set of online processors.  Make sure
the affinity set for an interrupt vector contains at least one online
processor.

Update #3269.

---

 bsps/shared/irq/irq-affinity.c    | 8 +++++++-
 cpukit/include/rtems/rtems/intr.h | 9 ++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/bsps/shared/irq/irq-affinity.c b/bsps/shared/irq/irq-affinity.c
index cce1098..c214680 100644
--- a/bsps/shared/irq/irq-affinity.c
+++ b/bsps/shared/irq/irq-affinity.c
@@ -10,7 +10,7 @@
  */
 
 /*
- * Copyright (C) 2017 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2017, 2022 embedded brains GmbH (http://www.embedded-brains.de)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -37,6 +37,7 @@
 #include <bsp/irq-generic.h>
 
 #include <rtems/score/processormask.h>
+#include <rtems/score/smpimpl.h>
 
 rtems_status_code rtems_interrupt_set_affinity(
   rtems_vector_number  vector,
@@ -60,6 +61,11 @@ rtems_status_code rtems_interrupt_set_affinity(
     return RTEMS_INVALID_NUMBER;
   }
 
+  _Processor_mask_And( &set, _SMP_Get_online_processors(), &set );
+  if ( _Processor_mask_Is_zero( &set ) ) {
+    return RTEMS_INVALID_NUMBER;
+  }
+
 #if defined(RTEMS_SMP)
   return bsp_interrupt_set_affinity( vector, &set );
 #else
diff --git a/cpukit/include/rtems/rtems/intr.h b/cpukit/include/rtems/rtems/intr.h
index 573cdf6..c53cf69 100644
--- a/cpukit/include/rtems/rtems/intr.h
+++ b/cpukit/include/rtems/rtems/intr.h
@@ -7,7 +7,7 @@
  */
 
 /*
- * Copyright (C) 2008, 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2008, 2022 embedded brains GmbH (http://www.embedded-brains.de)
  * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1759,9 +1759,16 @@ rtems_status_code rtems_interrupt_get_affinity(
  *   interrupt vector has not been satisfied.
  *
  * @par Notes
+ * @parblock
  * The rtems_interrupt_get_attributes() directive may be used to check if the
  * processor affinity of an interrupt vector can be set.
  *
+ * Only online processors of the affinity set specified by ``affinity_size``
+ * and ``affinity`` are considered by the directive.  Other processors of the
+ * set are ignored.  If the set contains no online processor, then the set is
+ * invalid and an error status is returned.
+ * @endparblock
+ *
  * @par Constraints
  * @parblock
  * The following constraints apply to this directive:



More information about the vc mailing list