baron · 3月26日 · 四川

[ARM异常]-SPIs(共享中断)routing到指定CPU的方法

快速连接

👉👉👉【精选】ARMv8/ARMv9架构入门到精通-目录 👈👈👈


 title=

原理介绍:

废话不多说,看图,看懂的给赞!
在这里插入图片描述

内核没有提供指定SPIs中断到特定cpu的接口。那代码我们就胡乱的看一下吧

static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
                            bool force)
{
        unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask);
        struct irq_desc *desc = container_of(d, struct irq_desc, irq_data);
        void __iomem *reg;
        int enabled;
        u64 val;

        if (cpu >= nr_cpu_ids)
                return -EINVAL;

        if (gic_irq_in_rdist(d))
                return -EINVAL;

        /* If interrupt was enabled, disable it first */
        enabled = gic_peek_irq(d, GICD_ISENABLER);
        if (enabled)
                gic_mask_irq(d);

        reg = gic_dist_base(d) + GICD_IROUTER + (gic_irq(d) * 8);
        val = gic_mpidr_to_affinity(cpu_logical_map(cpu));

        gic_write_irouter(val, reg);

        /*
         * If the interrupt was enabled, enabled it again. Otherwise,
         * just wait for the distributor to have digested our changes.
         */
        if (enabled)
                gic_unmask_irq(d);
        else
                gic_dist_wait_for_rwp();

        return IRQ_SET_MASK_OK;
}
  • val = gic_mpidr_to_affinity(cpu_logical_map(cpu)); //读出cpu的id值
  • gic_write_irouter(val, reg); //将这个值,写入到GICD寄存器

    关注"Arm精选"公众号,备注进ARM交流讨论区。
    图片1.png

推荐阅读
关注数
9438
内容数
191
以易懂、渐进、有序的方式,深入探讨ARMv8/ARMv9架构的核心概念。我们将从基础知识开始,逐步深入,覆盖最新的架构,不再纠缠于过时技术。本系列内容包含但不限于ARM基础、SOC芯片基础、Trustzone、gic、异常和中断、AMBA、Cache、MMU等内容,并将持续更新。
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息