• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修订版b62a23e61bfd99080e8dc172a632e1aa9dfc2964 (tree)
时间2016-09-29 12:28:58
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

ueventd: defer modules loading if explicitly listed

The patch extends the syntax of /etc/modules.blacklist.
The modules marked as deferred in this file will be loaded
after all other modules are loaded at coldboot stage.

更改概述

差异

--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -111,6 +111,7 @@ struct module_alias_node {
111111
112112 struct module_blacklist_node {
113113 char *name;
114+ bool deferred;
114115 struct listnode list;
115116 };
116117
@@ -767,7 +768,7 @@ static void handle_generic_device_event(struct uevent *uevent)
767768 uevent->major, uevent->minor, links);
768769 }
769770
770-static int is_module_blacklisted(const char *name)
771+static int is_module_blacklisted_or_deferred(const char *name, bool need_deferred)
771772 {
772773 struct listnode *blklst_node;
773774 struct module_blacklist_node *blacklist;
@@ -782,7 +783,7 @@ static int is_module_blacklisted(const char *name)
782783 list);
783784 if (!strcmp(name, blacklist->name)) {
784785 INFO("modules %s is blacklisted\n", name);
785- ret = 1;
786+ ret = blacklist->deferred ? (need_deferred ? 2 : 0) : 1;
786787 goto out;
787788 }
788789 }
@@ -791,7 +792,7 @@ out:
791792 return ret;
792793 }
793794
794-static int load_module_by_device_modalias(const char *id)
795+static int load_module_by_device_modalias(const char *id, bool need_deferred)
795796 {
796797 struct listnode *alias_node;
797798 struct module_alias_node *alias;
@@ -804,8 +805,9 @@ static int load_module_by_device_modalias(const char *id)
804805 if (fnmatch(alias->pattern, id, 0) == 0) {
805806 INFO("trying to load module %s due to uevents\n", alias->name);
806807
807- if (!is_module_blacklisted(alias->name)) {
808- if (insmod_by_dep(alias->name, "", NULL, 0, NULL)) {
808+ ret = is_module_blacklisted_or_deferred(alias->name, need_deferred);
809+ if (ret == 0) {
810+ if ((ret = insmod_by_dep(alias->name, "", NULL, 0, NULL))) {
809811 /* cannot load module. try another one since
810812 * there may be another match.
811813 */
@@ -814,8 +816,9 @@ static int load_module_by_device_modalias(const char *id)
814816 } else {
815817 /* loading was successful */
816818 INFO("loaded module %s due to uevents\n", alias->name);
817- ret = 0;
818819 }
820+ } else {
821+ NOTICE("blacklisted module %s: %d\n", alias->name, ret);
819822 }
820823 }
821824 }
@@ -839,7 +842,7 @@ static void handle_deferred_module_loading()
839842
840843 if (alias && alias->pattern) {
841844 INFO("deferred loading of module for %s\n", alias->pattern);
842- load_module_by_device_modalias(alias->pattern);
845+ load_module_by_device_modalias(alias->pattern, false);
843846 free(alias->pattern);
844847 list_remove(node);
845848 free(alias);
@@ -857,7 +860,12 @@ int module_probe(const char *modalias)
857860 return -1;
858861 }
859862
860- return modalias ? load_module_by_device_modalias(modalias) : -1;
863+ return modalias ? load_module_by_device_modalias(modalias, false) : -1;
864+}
865+
866+static int is_booting(void)
867+{
868+ return access("/dev/.booting", F_OK) == 0;
861869 }
862870
863871 static void handle_module_loading(const char *modalias)
@@ -870,13 +878,13 @@ static void handle_module_loading(const char *modalias)
870878 if (list_empty(&modules_aliases_map)) {
871879 if (read_modules_aliases() == 0) {
872880 read_modules_blacklist();
873- handle_deferred_module_loading();
874881 }
875882 }
876883
877884 if (!modalias) return;
878885
879- if (list_empty(&modules_aliases_map)) {
886+ if (list_empty(&modules_aliases_map) ||
887+ load_module_by_device_modalias(modalias, is_booting()) == 2) {
880888 /* if module alias mapping is empty,
881889 * queue it for loading later
882890 */
@@ -893,8 +901,6 @@ static void handle_module_loading(const char *modalias)
893901 } else {
894902 ERROR("failed to allocate memory to store device id for deferred module loading.\n");
895903 }
896- } else {
897- load_module_by_device_modalias(modalias);
898904 }
899905
900906 }
@@ -955,11 +961,6 @@ static int load_firmware(int fw_fd, int loading_fd, int data_fd)
955961 return ret;
956962 }
957963
958-static int is_booting(void)
959-{
960- return access("/dev/.booting", F_OK) == 0;
961-}
962-
963964 static void process_firmware_event(struct uevent *uevent)
964965 {
965966 char *root, *loading, *data;
@@ -1077,6 +1078,7 @@ static void parse_line_module_alias(struct parse_state *state, int nargs, char *
10771078 static void parse_line_module_blacklist(struct parse_state *state, int nargs, char **args)
10781079 {
10791080 struct module_blacklist_node *node;
1081+ bool deferred;
10801082
10811083 if (!args ||
10821084 (nargs != 2) ||
@@ -1085,8 +1087,13 @@ static void parse_line_module_blacklist(struct parse_state *state, int nargs, ch
10851087 return;
10861088 }
10871089
1088- /* this line does not being with "blacklist" */
1089- if (strncmp(args[0], "blacklist", 9)) return;
1090+ /* this line should be with "blacklist" or "deferred" */
1091+ if (!strncmp(args[0], "blacklist", 9))
1092+ deferred = false;
1093+ else if (!strncmp(args[0], "deferred", 8))
1094+ deferred = true;
1095+ else
1096+ return;
10901097
10911098 node = (module_blacklist_node *) calloc(1, sizeof(*node));
10921099 if (!node) return;
@@ -1096,6 +1103,7 @@ static void parse_line_module_blacklist(struct parse_state *state, int nargs, ch
10961103 free(node);
10971104 return;
10981105 }
1106+ node->deferred = deferred;
10991107
11001108 list_add_tail(&modules_blacklist, &node->list);
11011109 }
@@ -1293,6 +1301,7 @@ void device_init(bool child)
12931301 coldboot("/sys/class");
12941302 coldboot("/sys/block");
12951303 coldboot("/sys/devices");
1304+ handle_deferred_module_loading();
12961305 close(open(COLDBOOT_DONE, O_WRONLY|O_CREAT|O_CLOEXEC, 0000));
12971306 NOTICE("Coldboot took %.2fs.\n", t.duration());
12981307 }