Skip to content

Commit 9c9a3e4

Browse files
committed
[PIC] Make affinity helper interface
Signed-off-by: GuEe-GUI <[email protected]>
1 parent 1a15146 commit 9c9a3e4

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

components/drivers/include/drivers/pic.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct rt_pic
4040

4141
rt_list_t list;
4242

43-
struct rt_pic_ops *ops;
43+
const struct rt_pic_ops *ops;
4444

4545
void *priv_data;
4646
void *user_data;
@@ -91,6 +91,10 @@ struct rt_pic_isr
9191
struct rt_irq_desc action;
9292
};
9393

94+
#define RT_IRQ_AFFINITY_DECLARE(name) RT_BITMAP_DECLARE(name, RT_CPUS_NR)
95+
#define RT_IRQ_AFFINITY_SET(affinity, cpuid) rt_bitmap_set_bit(affinity, cpuid)
96+
#define RT_IRQ_AFFINITY_CLEAR(affinity, cpuid) rt_bitmap_clear_bit(affinity, cpuid)
97+
9498
#ifdef RT_USING_PIC_STATISTICS
9599
struct rt_pic_irq_statistics
96100
{
@@ -117,7 +121,7 @@ struct rt_pic_irq
117121
rt_uint32_t mode;
118122

119123
rt_uint32_t priority;
120-
RT_BITMAP_DECLARE(affinity, RT_CPUS_NR);
124+
RT_IRQ_AFFINITY_DECLARE(affinity);
121125

122126
rt_list_t list;
123127
rt_list_t children_nodes;

components/drivers/pic/pic.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,17 @@ static void config_pirq(struct rt_pic *pic, struct rt_pic_irq *pirq, int irq, in
192192
int rt_pic_config_ipi(struct rt_pic *pic, int ipi_index, int hwirq)
193193
{
194194
int ipi = ipi_index;
195+
struct rt_pic_irq *pirq;
195196

196197
if (pic && ipi < RT_ARRAY_SIZE(_ipi_hash) && hwirq >= 0 && pic->ops->irq_send_ipi)
197198
{
198-
config_pirq(pic, &_pirq_hash[ipi], ipi, hwirq);
199+
pirq = &_pirq_hash[ipi];
200+
config_pirq(pic, pirq, ipi, hwirq);
201+
202+
for (int cpuid = 0; cpuid < RT_CPUS_NR; ++cpuid)
203+
{
204+
RT_IRQ_AFFINITY_SET(pirq->affinity, cpuid);
205+
}
199206

200207
LOG_D("%s config %s %d to hwirq %d", pic->ops->name, "ipi", ipi, hwirq);
201208
}
@@ -404,7 +411,7 @@ rt_err_t rt_pic_detach_irq(int irq, void *uid)
404411
}
405412
else
406413
{
407-
struct rt_pic_isr *next_isr = rt_list_entry(isr->list.next, struct rt_pic_isr, list);
414+
struct rt_pic_isr *next_isr = rt_list_first_entry(&isr->list, struct rt_pic_isr, list);
408415

409416
rt_list_remove(&next_isr->list);
410417

@@ -518,9 +525,6 @@ rt_err_t rt_pic_handle_isr(struct rt_pic_irq *pirq)
518525
pirq->stat.current_irq_begin[rt_hw_cpu_id()] = ts.tv_sec * (1000UL * 1000 * 1000) + ts.tv_nsec;
519526
#endif
520527

521-
/* Corrected irq affinity */
522-
rt_bitmap_set_bit(pirq->affinity, rt_hw_cpu_id());
523-
524528
handler_nodes = &pirq->isr.list;
525529
action = &pirq->isr.action;
526530

0 commit comments

Comments
 (0)