{"id":53655,"date":"2023-06-20T05:49:16","date_gmt":"2023-06-19T21:49:16","guid":{"rendered":"http:\/\/gulass.cn\/?p=53655"},"modified":"2023-06-20T05:49:16","modified_gmt":"2023-06-19T21:49:16","slug":"kernel-realize","status":"publish","type":"post","link":"https:\/\/gulass.cn\/kernel-realize.html","title":{"rendered":"\u4ece\u6302\u8d77\u5230\u5b9e\u73b0\uff0c\u4f60\u77e5\u9053\u5185\u6838\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nLinux \u5185\u6838\u63d0\u4f9b\u4e86\u591a\u79cd\u7761\u7720\u72b6\u6001\u76ee\u524d\u603b\u5171\u6709\u56db\u79cd\u7761\u7720\u72b6\u6001\uff0c\u5206\u522b\u662f\uff1a\u6302\u8d77\u5230\u7a7a\u95f2\u52a0\u7535\u5f85\u673a\u3001\u6302\u8d77\u5230\u5185\u5b58\u548c\u6302\u8d77\u5230\u78c1\u76d8\u3002\u8fd9\u4e9b\u72b6\u6001\u5206\u522b\u5bf9\u5e94 ACPI \u7684 4 \u79cd\u72b6\u6001\uff1aS0\uff0cS1\uff0cS3 \u548c S4\u3002\u6302\u8d77\u5230\u7a7a\u95f2\u662f\u7eaf\u8f6f\u4ef6\u5b9e\u73b0\u7684\uff0c\u7528\u4e8e\u5c06 CPU \u7ef4\u6301\u5728\u5c3d\u53ef\u80fd\u6df1\u7684 idle \u72b6\u6001\u3002\u52a0\u7535\u5f85\u673a \u5219\u4f7f\u8bbe\u5907\u5904\u4e8e\u4f4e\u529f\u8017\u72b6\u6001\uff0c\u5e76\u4e14\u5173\u95ed\u6240\u6709\u975e\u5f15\u5bfc CPU\u3002\u6302\u8d77\u5230\u5185\u5b58\uff0c\u662f\u5173\u95ed\u6240\u6709 CPU \u5e76\u4e14\u8bbe\u7f6e RAM \u8fdb\u5165\u81ea\u5237\u65b0\u6a21\u5f0f\u3002\u6302\u8d77\u5230\u78c1\u76d8\u5219\u662f\u6700\u7701\u529f\u8017\u7684\u6a21\u5f0f\uff0c\u5173\u95ed\u5c3d\u53ef\u80fd\u591a\u7684\u7cfb\u7edf\u3002
\n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\u6d45\u8ff0\u5185\u6838\u4e2d\u201c\u6302\u8d77\u5230\u7a7a\u95f2\u201d\u7684\u5b9e\u73b0\"<\/p>\n

\u8fd9\u7bc7\u535a\u6587\u4e3b\u8981\u4ecb\u7ecd\u6302\u8d77\u5230\u7a7a\u95f2\uff08<\/rp>suspend to idle<\/rt>\uff09<\/rp><\/ruby>\u7684\u5b9e\u73b0\u3002\u5982\u4e0a\u6240\u8bf4\uff0c\u5b83\u4e3b\u8981\u901a\u8fc7\u8f6f\u4ef6\u5b9e\u73b0\u3002\u4e00\u822c\u5e73\u53f0\u7684\u6302\u8d77\u8fc7\u7a0b\u5305\u62ec\u51bb\u7ed3\u7528\u6237\u7a7a\u95f4\u5e76\u5c06\u5916\u56f4\u8bbe\u5907\u8c03\u81f3\u4f4e\u8017\u7535\u6a21\u5f0f\u3002\u4f46\u662f\uff0c\u7cfb\u7edf\u5e76\u4e0d\u662f\u76f4\u63a5\u5173\u95ed\u548c\u70ed\u63d2\u62d4\u6389 CPU\uff0c\u800c\u662f\u9759\u9759\u5730\u5f3a\u5236\u5c06 CPU \u8fdb\u5165\u7a7a\u95f2\uff08<\/rp>idle<\/rt>\uff09<\/rp><\/ruby>\u72b6\u6001\u3002\u968f\u7740\u5916\u56f4\u8bbe\u5907\u8fdb\u5165\u4e86\u4f4e\u8017\u7535\u6a21\u5f0f\uff0c\u9664\u4e86\u5524\u9192\u76f8\u5173\u7684\u4e2d\u65ad\u5916\u4e0d\u5e94\u6709\u5176\u4ed6\u4e2d\u65ad\u4ea7\u751f\u3002\u5524\u9192\u4e2d\u65ad\u5305\u62ec\u90a3\u4e9b\u8bbe\u7f6e\u7528\u4e8e\u5524\u9192\u7cfb\u7edf\u7684\u8ba1\u65f6\u5668\uff08\u6bd4\u5982 RTC\uff0c\u666e\u901a\u8ba1\u65f6\u5668\u7b49\uff09\u3001\u6216\u8005\u7535\u6e90\u5f00\u5173\u3001USB \u548c\u5176\u5b83\u5916\u56f4\u8bbe\u5907\u7b49\u3002<\/p>\n

\u5728\u51bb\u7ed3\u8fc7\u7a0b\u4e2d\uff0c\u5f53\u7cfb\u7edf\u8fdb\u5165\u7a7a\u95f2\u72b6\u6001\u65f6\u4f1a\u8c03\u7528\u4e00\u4e2a\u7279\u6b8a\u7684 cpu \u7a7a\u95f2\u51fd\u6570\u3002\u8fd9\u4e2a enter_freeze()\u51fd\u6570\u53ef\u4ee5\u548c\u8c03\u7528\u4f7f cpu \u7a7a\u95f2\u7684 enter() \u51fd\u6570\u4e00\u6837\u7b80\u5355\uff0c\u4e5f\u53ef\u4ee5\u590d\u6742\u5f97\u591a\u3002\u8be5\u51fd\u6570\u590d\u6742\u7684\u7a0b\u5ea6\u7531\u5c06 SoC \u7f6e\u4e3a\u4f4e\u8017\u7535\u6a21\u5f0f\u7684\u6761\u4ef6\u548c\u65b9\u6cd5\u51b3\u5b9a\u3002<\/p>\n

\u5148\u51b3\u6761\u4ef6<\/strong><\/div>\n
platform_suspend_ops<\/strong><\/span><\/div>\n

\u4e00\u822c\u60c5\u51b5\uff0c\u4e3a\u4e86\u652f\u6301 S2I\uff0c\u7cfb\u7edf\u5fc5\u987b\u5b9e\u73b0platform_suspend_ops \u5e76\u63d0\u4f9b\u6700\u4f4e\u9650\u5ea6\u7684\u6302\u8d77\u652f\u6301\u3002\u8fd9\u610f\u5473\u7740\u81f3\u5c11\u8981\u5b8c\u6210 platform_suspend_ops\u4e2d\u7684 valid() \u51fd\u6570\u3002\u5982\u679c\u6302\u8d77\u5230\u7a7a\u95f2\uff08<\/rp>suspend to idle<\/rt>\uff09<\/rp><\/ruby>\u548c\u6302\u8d77\u5230\u5185\u5b58\uff08<\/rp>suspend to ram<\/rt>\uff09<\/rp><\/ruby>\u90fd\u8981\u652f\u6301\uff0cvalid \u51fd\u6570\u4e2d\u5e94\u4f7f\u7528 suspend_valid_only_mem\u3002<\/p>\n

\u4e0d\u8fc7\uff0c\u6700\u8fd1\u5185\u6838\u589e\u52a0\u4e86\u5bf9 S2I \u7684\u81ea\u52a8\u652f\u6301\u3002Sudeep Holla \u63d0\u51fa\u4e86\u4e00\u4e2a\u53d8\u66f4\uff0c\u53ef\u4ee5\u8ba9\u7cfb\u7edf\u4e0d\u9700\u8981\u6ee1\u8db3 platform_suspend_ops \u6761\u4ef6\u4e5f\u80fd\u63d0\u4f9b S2I \u652f\u6301\u3002\u8fd9\u4e2a\u8865\u4e01\u5df2\u7ecf\u88ab\u63a5\u6536\u5e76\u5c06\u5408\u5e76\u5728 4.9 \u7248\u672c\u4e2d\uff0c\u8be5\u8865\u4e01\u53ef\u4ece\u8fd9\u91cc\u83b7\u53d6\uff1a https:\/\/lkml.org\/lkml\/2016\/8\/19\/474\u3002<\/p>\n

\u5982\u679c\u5b9a\u4e49\u4e86 suspend_ops\uff0c\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\/sys\/power\/state\u6587\u4ef6\u5f97\u77e5\u7cfb\u7edf\u5177\u4f53\u652f\u6301\u54ea\u4e9b\u6302\u8d77\u72b6\u6001\u3002\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n

# cat \/sys\/power\/state\r\nfreeze mem\r\n<\/pre>\n

\u8fd9\u4e2a\u793a\u4f8b\u7684\u7ed3\u679c\u663e\u793a\u8be5\u5e73\u53f0\u652f\u6301 S0\uff08\u6302\u8d77\u5230\u7a7a\u95f2\uff08<\/rp>suspend to idle<\/rt>\uff09<\/rp><\/ruby>\uff09\u548c S3\uff08\u6302\u8d77\u5230\u5185\u5b58\uff08<\/rp>suspend to ram<\/rt>\uff09<\/rp><\/ruby>\uff09\u3002\u6309 Sudeep \u7684\u53d8\u66f4\uff0c\u90a3\u4e9b\u6ca1\u6709\u5b9e\u73b0 platform_suspend_ops \u7684\u5e73\u53f0\u5c06\u53ea\u663e\u793a freeze \u72b6\u6001\u3002<\/p>\n

\u5524\u9192\u4e2d\u65ad<\/strong><\/span><\/div>\n

\u4e00\u65e6\u7cfb\u7edf\u5904\u4e8e\u67d0\u79cd\u7761\u7720\u72b6\u6001\uff0c\u7cfb\u7edf\u5fc5\u987b\u8981\u63a5\u6536\u67d0\u4e2a\u5524\u9192\u4e8b\u4ef6\u624d\u80fd\u6062\u590d\u7cfb\u7edf\u3002\u8fd9\u4e9b\u5524\u9192\u4e8b\u4ef6\u4e00\u822c\u7531\u7cfb\u7edf\u7684\u8bbe\u5907\u4ea7\u751f\u3002\u56e0\u6b64\u4e00\u5b9a\u8981\u786e\u4fdd\u8fd9\u4e9b\u8bbe\u5907\u9a71\u52a8\u4f7f\u7528\u5524\u9192\u4e2d\u65ad\uff0c\u5e76\u4e14\u5c06\u81ea\u8eab\u914d\u7f6e\u4e3a\u63a5\u6536\u5524\u9192\u4e2d\u65ad\u540e\u4ea7\u751f\u5524\u9192\u4e8b\u4ef6\u3002\u5982\u679c\u6ca1\u6709\u6b63\u786e\u8bc6\u522b\u5524\u9192\u8bbe\u5907\uff0c\u7cfb\u7edf\u6536\u5230\u4e2d\u65ad\u540e\u4f1a\u7ee7\u7eed\u4fdd\u6301\u7761\u7720\u72b6\u6001\u800c\u4e0d\u4f1a\u6062\u590d\u3002<\/p>\n

\u4e00\u65e6\u8bbe\u5907\u6b63\u786e\u5b9e\u73b0\u4e86\u5524\u9192\u63a5\u53e3\u7684\u8c03\u7528\uff0c\u5c31\u53ef\u7528\u6765\u751f\u6210\u5524\u9192\u4e8b\u4ef6\u3002\u8bf7\u786e\u4fdd DT \u6587\u4ef6\u6b63\u786e\u914d\u7f6e\u4e86\u5524\u9192\u6e90\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u914d\u7f6e\u5524\u9192\u6e90\u793a\u4f8b\uff0c\u8be5\u6587\u4ef6\u6765\u81ea\uff08arch\/arm\/boot\/dst\/am335x-evm.dts\uff09:<\/p>\n

\u00a0\u00a0\u00a0\u00a0gpio_keys:\u00a0volume_keys@0 {__\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0compatible = \u201cgpio-keys\u201d;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#address-cells = <1>;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#size-cells = <0>;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0autorepeat;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0switch@9 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0label = \u201cvolume-up\u201d;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0linux,code = <115>;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0wakeup-source;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0};\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0switch@10 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0label = \u201cvolume-down\u201d;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0linux,code = <114>;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0wakeup-source;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0};\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0};<\/pre>\n

\u5982\u4e0a\u6240\u793a\uff0c\u6709\u4e24\u4e2a gpio \u952e\u88ab\u914d\u7f6e\u4e3a\u5524\u9192\u6e90\uff0c\u5728\u7cfb\u7edf\u6302\u8d77\u671f\u95f4\uff0c\u5176\u4e2d\u4efb\u4f55\u4e00\u4e2a\u952e\u88ab\u6309\u4e0b\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2a\u5524\u9192\u4e8b\u4ef6\u3002<\/p>\n

\u53ef\u66ff\u4ee3 DT \u6587\u4ef6\u914d\u7f6e\u7684\u53e6\u4e00\u4e2a\u5524\u9192\u6e90\u914d\u7f6e\u5c31\u662f\u8bbe\u5907\u9a71\u52a8\uff0c\u5982\u679c\u8bbe\u5907\u9a71\u52a8\u81ea\u8eab\u5728\u4ee3\u7801\u91cc\u9762\u914d\u7f6e\u4e86\u5524\u9192\u652f\u6301\uff0c\u90a3\u4e48\u5c31\u4f1a\u4f7f\u7528\u8be5\u9ed8\u8ba4\u5524\u9192\u914d\u7f6e\u3002<\/p>\n

\u5b9e\u65bd<\/strong><\/div>\n
\u51bb\u7ed3\u529f\u80fd<\/strong><\/span><\/div>\n

\u5982\u679c\u7cfb\u7edf\u5e0c\u671b\u80fd\u591f\u5145\u5206\u4f7f\u7528\u6302\u8d77\u5230\u7a7a\u95f2\uff08<\/rp>suspend to idle<\/rt>\uff09<\/rp><\/ruby>\uff0c\u90a3\u4e48\u5e94\u8be5\u5728 CPU \u7a7a\u95f2\u9a71\u52a8\u4ee3\u7801\u4e2d\u5b9a\u4e49 enter_freeze() \u51fd\u6570\u3002enter_freeze() \u4e0e enter() \u7684\u51fd\u6570\u539f\u578b\u7565\u6709\u4e0d\u540c\u3002\u56e0\u6b64\uff0c\u4e0d\u80fd\u5c06 enter()\u540c\u65f6\u6307\u5b9a\u7ed9enter \u548c enter_freeze\u3002\u81f3\u5c11\uff0c\u7cfb\u7edf\u4f1a\u76f4\u63a5\u8c03\u7528 enter()\u3002\u5982\u679c\u6ca1\u6709\u5b9a\u4e49 enter_freeze()\uff0c\u7cfb\u7edf\u4f1a\u6302\u8d77\uff0c\u4f46\u662f\u4e0d\u4f1a\u89e6\u53d1\u90a3\u4e9b\u53ea\u6709\u5f53 enter_freeze()\u5b9a\u4e49\u4e86\u624d\u4f1a\u89e6\u53d1\u7684\u51fd\u6570\uff0c\u6bd4\u5982 tick_freeze() \u548c stop_critical_timing() \u90fd\u4e0d\u4f1a\u53d1\u751f\u3002\u8fd9\u4f1a\u5bfc\u81f4\u8ba1\u65f6\u5668\u4e2d\u65ad\u5524\u9192\u7cfb\u7edf\uff0c\u4f46\u4e0d\u4f1a\u5bfc\u81f4\u7cfb\u7edf\u6062\u590d\uff0c\u56e0\u4e3a\u7cfb\u7edf\u5904\u7406\u5b8c\u4e2d\u65ad\u540e\u4f1a\u7ee7\u7eed\u6302\u8d77\u3002<\/p>\n

\u5728\u6302\u8d77\u8fc7\u7a0b\u4e2d\uff0c\u4e2d\u65ad\u8d8a\u5c11\u8d8a\u597d\uff08\u6700\u597d\u4e00\u4e2a\u4e5f\u6ca1\u6709\uff09\u3002<\/p>\n

\u4e0b\u56fe\u663e\u793a\u4e86\u80fd\u8017\u548c\u65f6\u95f4\u7684\u5bf9\u6bd4\u3002\u56fe\u4e2d\u7684\u4e24\u4e2a\u5c16\u523a\u5206\u522b\u662f\u6302\u8d77\u548c\u6062\u590d\u3002\u6302\u8d77\u524d\u540e\u7684\u80fd\u8017\u5c16\u523a\u662f\u7cfb\u7edf\u9000\u51fa\u7a7a\u95f2\u6001\u8fdb\u884c\u8bb0\u5f55\u64cd\u4f5c\uff0c\u8fdb\u7a0b\u8c03\u5ea6\uff0c\u8ba1\u65f6\u5668\u5904\u7406\u7b49\u3002\u56e0\u5ef6\u8fdf\u7684\u7f18\u6545\uff0c\u7cfb\u7edf\u8fdb\u5165\u66f4\u6df1\u5c42\u6b21\u7a7a\u95f2\u72b6\u6001\u9700\u8981\u82b1\u8d39\u4e00\u6bb5\u65f6\u95f4\u3002<\/p>\n

\"\u6d45\u8ff0\u5185\u6838\u4e2d\u201c\u6302\u8d77\u5230\u7a7a\u95f2\u201d\u7684\u5b9e\u73b0\"<\/p>\n

\u80fd\u8017\u4f7f\u7528\u65f6\u5e8f\u56fe<\/em><\/p>\n

\u4e0b\u56fe\u4e3a ftrace \u6293\u53d6\u7684 4 \u6838 CPU \u5728\u7cfb\u7edf\u6302\u8d77\u548c\u6062\u590d\u64cd\u4f5c\u4e4b\u524d\u3001\u4e4b\u4e2d\u548c\u4e4b\u540e\u7684\u6d3b\u52a8\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u6302\u8d77\u671f\u95f4\uff0c\u6ca1\u6709\u8bf7\u6c42\u6216\u8005\u4e2d\u65ad\u88ab\u5904\u7406\u3002<\/p>\n

\"\u6d45\u8ff0\u5185\u6838\u4e2d\u201c\u6302\u8d77\u5230\u7a7a\u95f2\u201d\u7684\u5b9e\u73b0\"<\/p>\n

Ftrace \u6293\u53d6\u7684\u6302\u8d77\/\u6062\u590d\u6d3b\u52a8\u56fe<\/em><\/p>\n

\u7a7a\u95f2\u72b6\u6001<\/strong><\/span><\/div>\n

\u4f60\u5fc5\u987b\u786e\u5b9a\u54ea\u4e2a\u7a7a\u95f2\u72b6\u6001\u652f\u6301\u51bb\u7ed3\u3002\u5728\u51bb\u7ed3\u671f\u95f4\uff0c\u7535\u6e90\u76f8\u5173\u4ee3\u7801\u4f1a\u51b3\u5b9a\u7528\u54ea\u4e2a\u7a7a\u95f2\u72b6\u6001\u6765\u5b9e\u73b0\u51bb\u7ed3\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u662f\u901a\u8fc7\u5728\u6bcf\u4e2a\u7a7a\u95f2\u72b6\u6001\u4e2d\u67e5\u627e\u8c01\u5b9a\u4e49\u4e86 enter_freeze() \u6765\u51b3\u5b9a\u7684\u3002CPU \u7a7a\u95f2\u9a71\u52a8\u4ee3\u7801\u6216\u8005 SoC \u6302\u8d77\u76f8\u5173\u4ee3\u7801\u5fc5\u987b\u786e\u5b9a\u54ea\u79cd\u7a7a\u95f2\u72b6\u6001\u5b9e\u73b0\u51bb\u7ed3\u64cd\u4f5c\uff0c\u5e76\u901a\u8fc7\u7ed9\u6bcf\u4e2a CPU \u7684\u53ef\u5e94\u7528\u7a7a\u95f2\u72b6\u6001\u6307\u5b9a\u51bb\u7ed3\u529f\u80fd\u6765\u8fdb\u884c\u914d\u7f6e\u3002<\/p>\n

\u4f8b\u5982\uff0c Qualcomm \u4f1a\u5728\u5e73\u53f0\u6302\u8d77\u4ee3\u7801\u7684\u6302\u8d77\u521d\u59cb\u5316\u51fd\u6570\u5904\u5b9a\u4e49 enter_freeze \u51fd\u6570\u3002\u8fd9\u4e2a\u5de5\u4f5c\u662f\u5728 CPU \u7a7a\u95f2\u9a71\u52a8\u5df2\u7ecf\u521d\u59cb\u5316\u540e\u8fdb\u884c\uff0c\u4ee5\u4fbf\u6240\u6709\u7ed3\u6784\u5df2\u7ecf\u5b9a\u4e49\u5c31\u4f4d\u3002<\/p>\n

\u6302\u8d77\/\u6062\u590d\u76f8\u5173\u9a71\u52a8\u652f\u6301<\/strong><\/span><\/div>\n

\u4f60\u53ef\u80fd\u4f1a\u5728\u7b2c\u4e00\u6b21\u6210\u529f\u6302\u8d77\u64cd\u4f5c\u540e\u78b0\u5230\u9a71\u52a8\u76f8\u5173\u7684 bug\u3002\u5f88\u591a\u9a71\u52a8\u5f00\u53d1\u8005\u6ca1\u6709\u7cbe\u529b\u5b8c\u5168\u6d4b\u8bd5\u6302\u8d77\u548c\u6062\u590d\u76f8\u5173\u7684\u4ee3\u7801\u3002\u4f60\u751a\u81f3\u53ef\u80fd\u4f1a\u53d1\u73b0\u6302\u8d77\u64cd\u4f5c\u5e76\u6ca1\u6709\u591a\u5c11\u5de5\u4f5c\u53ef\u505a\uff0c\u56e0\u4e3a pm_runtime \u5df2\u7ecf\u505a\u4e86\u4f60\u8981\u505a\u7684\u6302\u8d77\u76f8\u5173\u7684\u4e00\u5207\u5de5\u4f5c\u3002\u7531\u4e8e\u7528\u6237\u7a7a\u95f4\u5df2\u7ecf\u88ab\u51bb\u7ed3\uff0c\u8bbe\u5907\u6b64\u65f6\u5df2\u7ecf\u5904\u4e8e\u4f11\u7720\u72b6\u6001\u5e76\u4e14 pm_runtime \u5df2\u7ecf\u88ab\u7981\u6b62\u3002<\/p>\n

\u6d4b\u8bd5\u76f8\u5173<\/strong><\/span><\/div>\n

\u6d4b\u8bd5\u6302\u8d77\u5230\u7a7a\u95f2\uff08<\/rp>suspend to idle<\/rt>\uff09<\/rp><\/ruby>\u53ef\u4ee5\u624b\u52a8\u8fdb\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u811a\u672c\/\u8fdb\u7a0b\u7b49\u5b9e\u73b0\u81ea\u52a8\u6302\u8d77\u3001\u81ea\u52a8\u7761\u7720\uff0c\u6216\u8005\u4f7f\u7528\u50cf Android \u4e2d\u7684 wakelock\u6765\u8ba9\u7cfb\u7edf\u6302\u8d77\u3002\u5982\u679c\u624b\u52a8\u6d4b\u8bd5\uff0c\u4e0b\u9762\u7684\u64cd\u4f5c\u4f1a\u5c06\u7cfb\u7edf\u51bb\u7ed3\u3002<\/p>\n

 # echo freeze > \/sys\/power\/state\r\n[ \u00a0142.580832] PM: Syncing filesystems \u2026 done.\r\n[ \u00a0142.583977] Freezing user space processes \u2026 (elapsed 0.001 seconds) done.\r\n[ \u00a0142.591164] Double checking all user space processes after OOM killer disable\u2026 (elapsed 0.000 seconds)\r\n[ \u00a0142.600444] Freezing remaining freezable tasks \u2026 (elapsed 0.001 seconds) done._\r\n_[ \u00a0142.608073] Suspending console(s) (use no_console_suspend to debug)\r\n[ \u00a0142.708787] mmc1: Reset 0x1 never completed.\r\n[ \u00a0142.710608] msm_otg 78d9000.phy: USB in low power mode\r\n[ \u00a0142.711379] PM: suspend of devices complete after 102.883 msecs\r\n[ \u00a0142.712162] PM: late suspend of devices complete after 0.773 msecs\r\n[ \u00a0142.712607] PM: noirq suspend of devices complete after 0.438 msecs\r\n< system suspended >\r\n\u2026.\r\n< wake irq triggered >\r\n[ \u00a0147.700522] PM: noirq resume of devices complete after 0.216 msecs\r\n[ \u00a0147.701004] PM: early resume of devices complete after 0.353 msecs\r\n[ \u00a0147.701636] msm_otg 78d9000.phy: USB exited from low power mode\r\n[ \u00a0147.704492] PM: resume of devices complete after 3.479 msecs\r\n[ \u00a0147.835599] Restarting tasks \u2026 done.\r\n\/ #\r\n<\/pre>\n

\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u9700\u8981\u6ce8\u610f MMC \u9a71\u52a8\u7684\u64cd\u4f5c\u5360\u4e86 102.883ms \u4e2d\u7684 100ms\u3002\u6709\u4e9b\u8bbe\u5907\u9a71\u52a8\u5728\u6302\u8d77\u7684\u65f6\u5019\u6709\u5f88\u591a\u5de5\u4f5c\u8981\u505a\uff0c\u6bd4\u5982\u5c06\u6570\u636e\u5237\u51fa\u5230\u786c\u76d8\uff0c\u6216\u8005\u5176\u4ed6\u8017\u65f6\u7684\u64cd\u4f5c\u7b49\u3002<\/p>\n

\u5982\u679c\u7cfb\u7edf\u5b9a\u4e49\u4e86\u51bb\u7ed3\uff08<\/rp>freeze<\/rt>\uff09<\/rp><\/ruby>\uff0c\u90a3\u4e48\u7cfb\u7edf\u5c06\u5c1d\u8bd5\u6302\u8d77\u64cd\u4f5c\uff0c\u5982\u679c\u6ca1\u6709\u51bb\u7ed3\u529f\u80fd\uff0c\u90a3\u4e48\u4f60\u4f1a\u770b\u5230\u4e0b\u9762\u7684\u63d0\u793a\uff1a<\/p>\n

 # echo freeze > \/sys\/power\/state&nbsp;\r\nsh: write error: Invalid argument\r\n\/ #\r\n<\/pre>\n
\u672a\u6765\u7684\u53d1\u5c55<\/strong><\/div>\n

\u76ee\u524d\u5728 ARM \u5e73\u53f0\u4e0a\u7684\u6302\u8d77\u5230\u7a7a\u95f2\uff08<\/rp>suspend to idle<\/rt>\uff09<\/rp><\/ruby>\u6709\u4e24\u65b9\u9762\u7684\u5de5\u4f5c\u9700\u8981\u505a\u3002\u7b2c\u4e00\u65b9\u9762\u5de5\u4f5c\u5728\u524d\u9762 platform_suspend_ops \u5c0f\u8282\u4e2d\u63d0\u5230\u8fc7\uff0c\u662f\u603b\u5141\u8bb8\u63a5\u53d7\u51bb\u7ed3\u72b6\u6001\u4ee5\u53ca\u5408\u5e76\u5230 4.9 \u7248\u672c\u5185\u6838\u4e2d\u7684\u5de5\u4f5c\u3002\u53e6\u4e00\u65b9\u9762\u5de5\u4f5c\u662f\u51bb\u7ed3\u529f\u80fd\u7684\u652f\u6301\u3002<\/p>\n

\u5982\u679c\u4f60\u5e0c\u671b\u8bbe\u5907\u6709\u66f4\u597d\u7684\u54cd\u5e94\u53ca\u8868\u73b0\uff0c\u90a3\u4e48\u5e94\u8be5\u7ee7\u7eed\u5b8c\u5584\u51bb\u7ed3\u529f\u80fd\u7684\u5b9e\u73b0\u3002\u7136\u800c\uff0c\u7531\u4e8e\u5f88\u591a SoC \u4f1a\u4f7f\u7528 ARM \u7684 CPU \u7a7a\u95f2\u9a71\u52a8\uff0c\u8fd9\u4f7f\u5f97 ARM \u7684 CPU \u7a7a\u95f2\u9a71\u52a8\u5b8c\u5584\u5b83\u81ea\u5df1\u7684\u901a\u7528\u51bb\u7ed3\u529f\u80fd\u7684\u5de5\u4f5c\u66f4\u6709\u610f\u4e49\u4e86\u3002\u800c\u4e8b\u5b9e\u4e0a\uff0cARM \u6b63\u5728\u5c1d\u8bd5\u6dfb\u52a0\u6b64\u901a\u7528\u652f\u6301\u3002\u5982\u679c SoC \u4f9b\u5e94\u5546\u5e0c\u671b\u5b9e\u73b0\u4ed6\u4eec\u81ea\u5df1\u7684 CPU \u7a7a\u95f2\u9a71\u52a8\u6216\u8005\u9700\u8981\u5728\u8fdb\u5165\u66f4\u6df1\u5c42\u6b21\u7684\u51bb\u7ed3\u4f11\u7720\u72b6\u6001\u65f6\u63d0\u4f9b\u989d\u5916\u7684\u652f\u6301\uff0c\u90a3\u4e48\u53ea\u6709\u5b9e\u73b0\u81ea\u5df1\u7684\u51bb\u7ed3\u529f\u80fd\u3002<\/p>\n


\n

via: http:\/\/www.linaro.org\/blog\/suspend-to-idle\/<\/a><\/p>\n

\u4f5c\u8005\uff1aAndy Gross<\/a> \u8bd1\u8005\uff1abeyondworld<\/a> \u6821\u5bf9\uff1ajasminepeng<\/a><\/p>\n

\u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n

<\/h3>\n
\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-8271-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1a http:\/\/gulass.cn\/kernel-realize.html<\/a>\u7f16\u8f91\uff1a\u4efb\u7ef4\u56fd\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

Linux \u5185\u6838\u63d0\u4f9b\u4e86\u591a\u79cd\u7761\u7720\u72b6\u6001\uff0c\u5404\u4e2a\u72b6\u6001\u901a\u8fc7\u8bbe\u7f6e\u7cfb\u7edf\u4e2d\u7684\u4e0d\u540c\u90e8\u4ef6\u8fdb\u5165\u4f4e\u8017\u7535\u6a21\u5f0f\u6765\u8282\u7ea6\u80fd\u6e90\u3002\u76ee\u524d\u603b\u5171\u6709\u56db\u79cd\u7761\u7720\u72b6\u6001\uff0c\u5206\u522b\u662f\uff1a\u6302\u8d77\u5230\u7a7a\u95f2\uff08suspend to idle\uff09\u3001\u52a0\u7535\u5f85\u673a\uff08power-on standby\uff08standby\uff09\uff09\u3001\u6302\u8d77\u5230\u5185\u5b58\uff08suspend to ram\uff09\u548c\u6302\u8d77\u5230\u78c1\u76d8\uff08suspend to disk\uff09\u3002\u8fd9\u4e9b\u72b6\u6001\u5206\u522b\u5bf9\u5e94 ACPI \u7684 4 \u79cd\u72b6\u6001\uff1aS0\uff0cS1\uff0cS3 \u548c S4\u3002\u6302\u8d77\u5230\u7a7a\u95f2\uff08suspend to idle\uff09\u662f\u7eaf\u8f6f\u4ef6\u5b9e\u73b0\u7684\uff0c\u7528\u4e8e\u5c06 CPU \u7ef4\u6301\u5728\u5c3d\u53ef\u80fd\u6df1\u7684 idle \u72b6\u6001\u3002\u52a0\u7535\u5f85\u673a\uff08power-on standby\uff08standby\uff09\uff09\u5219\u4f7f\u8bbe\u5907\u5904\u4e8e\u4f4e\u529f\u8017\u72b6\u6001\uff0c\u5e76\u4e14\u5173\u95ed\u6240\u6709\u975e\u5f15\u5bfc CPU\u3002\u6302\u8d77\u5230\u5185\u5b58\uff08suspend to ram\uff09\u5c31\u66f4\u8fdb\u4e00\u6b65\uff0c\u5173\u95ed\u6240\u6709 CPU \u5e76\u4e14\u8bbe\u7f6e RAM \u8fdb\u5165\u81ea\u5237\u65b0\u6a21\u5f0f\u3002\u6302\u8d77\u5230\u78c1\u76d8\uff08suspend to disk\uff09\u5219\u662f\u6700\u7701\u529f\u8017\u7684\u6a21\u5f0f\uff0c\u5173\u95ed\u5c3d\u53ef\u80fd\u591a\u7684\u7cfb\u7edf\uff0c\u5305\u62ec\u5173\u95ed\u5185\u5b58\u3002\u7136\u540e\u5185\u5b58\u4e2d\u7684\u5185\u5bb9\u4f1a\u88ab\u5199\u5230\u786c\u76d8\uff0c\u5f85\u5524\u9192\u8ba1\u7b97\u673a\u7684\u65f6\u5019\u5c06\u786c\u76d8\u4e2d\u7684\u5185\u5bb9\u91cd\u65b0\u6062\u590d\u5230\u5185\u5b58\u4e2d\u3002<\/p>\n","protected":false},"author":63,"featured_media":54694,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-53655","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/53655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=53655"}],"version-history":[{"count":14,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/53655\/revisions"}],"predecessor-version":[{"id":275361,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/53655\/revisions\/275361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/54694"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=53655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=53655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=53655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}