From c70df0960d1f275a0186279ca6cd033471a4e76b Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Thu, 18 Jan 2018 12:30:43 +0900 Subject: [PATCH] arch/arm/src/lc823450: Assign I2S IRQ handling to CPU0 Previous commit assumed that the caller is running on CPU0. However, the caller sometimes runs at CPU1. This patch will assign the caller to CPU0 explicitly. Signed-off-by: Masayuki Ishikawa --- arch/arm/src/lc823450/lc823450_i2s.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arm/src/lc823450/lc823450_i2s.c b/arch/arm/src/lc823450/lc823450_i2s.c index 3eced5cb4f..fb9efa28df 100644 --- a/arch/arm/src/lc823450/lc823450_i2s.c +++ b/arch/arm/src/lc823450/lc823450_i2s.c @@ -51,6 +51,10 @@ #include #include +#ifdef CONFIG_SMP +# include +#endif + #include "up_arch.h" #include "lc823450_dma.h" #include "lc823450_i2s.h" @@ -460,8 +464,32 @@ FAR struct i2s_dev_s *lc823450_i2sdev_initialize(void) nxsem_init(&_sem_txdma, 0, 0); nxsem_init(&_sem_buf_under, 0, 0); +#ifdef CONFIG_SMP + cpu_set_t cpuset0; + cpu_set_t cpuset1; + + CPU_ZERO(&cpuset1); + CPU_SET(0, &cpuset1); + + /* Backup the current affinity */ + + sched_getaffinity(getpid(), sizeof(cpuset0), &cpuset0); + + /* Set the new affinity which assigns to CPU0 */ + + sched_setaffinity(getpid(), sizeof(cpuset1), &cpuset1); + nxsig_usleep(10 * 1000); +#endif + irq_attach(LC823450_IRQ_AUDIOBUF0, _i2s_isr, NULL); +#ifdef CONFIG_SMP + /* Restore the original affinity */ + + sched_setaffinity(getpid(), sizeof(cpuset0), &cpuset0); + nxsig_usleep(10 * 1000); +#endif + /* Enable IRQ for Audio Buffer */ up_enable_irq(LC823450_IRQ_AUDIOBUF0);