enable irq wake是如何起作用的

2021-06-21 01:27:58 字數 2006 閱讀 7137

enable_irq_wake是如何起作用的

在linux kernel中,呼叫enable_irq_wake函式,可以將乙個irq具有喚醒系統的功能,即把系統從低功耗模式中喚醒,如從suspend to ram中喚醒。

enable_irq_wake具體如何起作用的呢,今天來學習學習。

先從函式enable_irq_wake開始,實現很簡單:

static inline int enable_irq_wake(unsigned int irq)

函式irq_set_irq_wake的實現也不是很複雜,並且有注釋說明,容易理解:

/**

* irq_set_irq_wake - control irq power management wakeup

* @irq: interrupt to control

* @on: enable/disable power management wakeup

* * enable/disable power management wakeup mode, which is

* disabled by default. enables and disables must match,

* just as they match for non-wakeup mode support.

* * wakeup mode lets this irq wake the system from sleep

* states like "suspend to ram".

*/int irq_set_irq_wake(unsigned int irq, unsigned int on)

} else else if (--desc->wake_depth == 0)

} irq_put_desc_busunlock(desc, flags);

return ret;

}

其中關鍵的**是計數:desc->wake_depth++, 以及呼叫函式set_irq_wake_real。

set_irq_wake_real函式呼叫到了具體cpu相關的**:

static int set_irq_wake_real(unsigned int irq, unsigned int on)

irq_set_wake為cpu相關**。

例如,*** cpu對應的arch\arm\mach-***\irq.c檔案中,***_init_irq函式中有如下語句:

desc->irq_data.chip->irq_set_wake = ***_gic_irq_set_wake;

***_gic_irq_set_wake的實現將irq mask,結果儲存在乙個陣列中gpc_wake_irq。

cpu在做power on/off時會使用到該陣列。

如mach-***\system.c中的函式***_cpu_lp_set中有如下**:

gpc_set_wakeup(gpc_wake_irq);

函式gpc_set_wakeup的實現:

void gpc_set_wakeup(unsigned int irq[4])

將irq mask設定到了cpu中。

中cpu的suspend enter函式中,會呼叫***_cpu_lp_set函式。

如***_suspend_enter函式中有如下**:

switch (state)

至此,流程基本清晰了。

enable_irq_wake函式會將irq mask到乙個陣列。

在進入suspend時,會將irq mask寫入到cpu。

也就是告訴cpu哪些irq可以將其從睡眠中喚醒。

enable irq wake是如何起作用的

enable irq wake是如何起作用的 在linux kernel中,呼叫enable irq wake函式,可以將乙個irq具有喚醒系統的功能,即把系統從低功耗模式中喚醒,如從suspend to ram中喚醒。enable irq wake具體如何起作用的呢,今天來學習學習。先從函式ena...

如切如磋,如琢如磨

有點難受的一天,以為幹了好多事情,晚上來機房補題,機房4個人,三個大佬乙個我。大佬們說的題和演算法我根本聽不懂,很挫敗。bgm my songs know what you did in the dark light em up string 我也不知道這首歌歌名為什麼沒有右括號 兩年了,我還是什麼...

RPM索引在Artifactory中是如何工作

rpm是用於儲存和管理rpm軟體包的倉庫。我們在rhel和centos系統上常用的yum安裝就是安裝的rpm軟體包,而yum的源就是乙個rpm軟體包的倉庫。jfrog artifactory是成熟的rpm和yum儲存庫管理器。jfrog的官方wiki頁面提供有關artifactory rpm儲存庫的...