repository.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * PS3 repository routines.
  4. *
  5. * Copyright (C) 2006 Sony Computer Entertainment Inc.
  6. * Copyright 2006 Sony Corp.
  7. */
  8. #include <asm/lv1call.h>
  9. #include "platform.h"
  10. enum ps3_vendor_id {
  11. PS3_VENDOR_ID_NONE = 0,
  12. PS3_VENDOR_ID_SONY = 0x8000000000000000UL,
  13. };
  14. enum ps3_lpar_id {
  15. PS3_LPAR_ID_CURRENT = 0,
  16. PS3_LPAR_ID_PME = 1,
  17. };
  18. #define dump_field(_a, _b) _dump_field(_a, _b, __func__, __LINE__)
  19. static void _dump_field(const char *hdr, u64 n, const char *func, int line)
  20. {
  21. #if defined(DEBUG)
  22. char s[16];
  23. const char *const in = (const char *)&n;
  24. unsigned int i;
  25. for (i = 0; i < 8; i++)
  26. s[i] = (in[i] <= 126 && in[i] >= 32) ? in[i] : '.';
  27. s[i] = 0;
  28. pr_devel("%s:%d: %s%016llx : %s\n", func, line, hdr, n, s);
  29. #endif
  30. }
  31. #define dump_node_name(_a, _b, _c, _d, _e) \
  32. _dump_node_name(_a, _b, _c, _d, _e, __func__, __LINE__)
  33. static void _dump_node_name(unsigned int lpar_id, u64 n1, u64 n2, u64 n3,
  34. u64 n4, const char *func, int line)
  35. {
  36. pr_devel("%s:%d: lpar: %u\n", func, line, lpar_id);
  37. _dump_field("n1: ", n1, func, line);
  38. _dump_field("n2: ", n2, func, line);
  39. _dump_field("n3: ", n3, func, line);
  40. _dump_field("n4: ", n4, func, line);
  41. }
  42. #define dump_node(_a, _b, _c, _d, _e, _f, _g) \
  43. _dump_node(_a, _b, _c, _d, _e, _f, _g, __func__, __LINE__)
  44. static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
  45. u64 v1, u64 v2, const char *func, int line)
  46. {
  47. pr_devel("%s:%d: lpar: %u\n", func, line, lpar_id);
  48. _dump_field("n1: ", n1, func, line);
  49. _dump_field("n2: ", n2, func, line);
  50. _dump_field("n3: ", n3, func, line);
  51. _dump_field("n4: ", n4, func, line);
  52. pr_devel("%s:%d: v1: %016llx\n", func, line, v1);
  53. pr_devel("%s:%d: v2: %016llx\n", func, line, v2);
  54. }
  55. /**
  56. * make_first_field - Make the first field of a repository node name.
  57. * @text: Text portion of the field.
  58. * @index: Numeric index portion of the field. Use zero for 'don't care'.
  59. *
  60. * This routine sets the vendor id to zero (non-vendor specific).
  61. * Returns field value.
  62. */
  63. static u64 make_first_field(const char *text, u64 index)
  64. {
  65. u64 n = 0;
  66. memcpy((char *)&n, text, strnlen(text, sizeof(n)));
  67. return PS3_VENDOR_ID_NONE + (n >> 32) + index;
  68. }
  69. /**
  70. * make_field - Make subsequent fields of a repository node name.
  71. * @text: Text portion of the field. Use "" for 'don't care'.
  72. * @index: Numeric index portion of the field. Use zero for 'don't care'.
  73. *
  74. * Returns field value.
  75. */
  76. static u64 make_field(const char *text, u64 index)
  77. {
  78. u64 n = 0;
  79. memcpy((char *)&n, text, strnlen(text, sizeof(n)));
  80. return n + index;
  81. }
  82. /**
  83. * read_node - Read a repository node from raw fields.
  84. * @n1: First field of node name.
  85. * @n2: Second field of node name. Use zero for 'don't care'.
  86. * @n3: Third field of node name. Use zero for 'don't care'.
  87. * @n4: Fourth field of node name. Use zero for 'don't care'.
  88. * @v1: First repository value (high word).
  89. * @v2: Second repository value (low word). Optional parameter, use zero
  90. * for 'don't care'.
  91. */
  92. static int read_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
  93. u64 *_v1, u64 *_v2)
  94. {
  95. int result;
  96. u64 v1;
  97. u64 v2;
  98. if (lpar_id == PS3_LPAR_ID_CURRENT) {
  99. u64 id;
  100. lv1_get_logical_partition_id(&id);
  101. lpar_id = id;
  102. }
  103. result = lv1_read_repository_node(lpar_id, n1, n2, n3, n4, &v1,
  104. &v2);
  105. if (result) {
  106. pr_warn("%s:%d: lv1_read_repository_node failed: %s\n",
  107. __func__, __LINE__, ps3_result(result));
  108. dump_node_name(lpar_id, n1, n2, n3, n4);
  109. return -ENOENT;
  110. }
  111. dump_node(lpar_id, n1, n2, n3, n4, v1, v2);
  112. if (_v1)
  113. *_v1 = v1;
  114. if (_v2)
  115. *_v2 = v2;
  116. if (v1 && !_v1)
  117. pr_devel("%s:%d: warning: discarding non-zero v1: %016llx\n",
  118. __func__, __LINE__, v1);
  119. if (v2 && !_v2)
  120. pr_devel("%s:%d: warning: discarding non-zero v2: %016llx\n",
  121. __func__, __LINE__, v2);
  122. return 0;
  123. }
  124. int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
  125. u64 *value)
  126. {
  127. return read_node(PS3_LPAR_ID_PME,
  128. make_first_field("bus", bus_index),
  129. make_field(bus_str, 0),
  130. 0, 0,
  131. value, NULL);
  132. }
  133. int ps3_repository_read_bus_id(unsigned int bus_index, u64 *bus_id)
  134. {
  135. return read_node(PS3_LPAR_ID_PME, make_first_field("bus", bus_index),
  136. make_field("id", 0), 0, 0, bus_id, NULL);
  137. }
  138. int ps3_repository_read_bus_type(unsigned int bus_index,
  139. enum ps3_bus_type *bus_type)
  140. {
  141. int result;
  142. u64 v1 = 0;
  143. result = read_node(PS3_LPAR_ID_PME,
  144. make_first_field("bus", bus_index),
  145. make_field("type", 0),
  146. 0, 0,
  147. &v1, NULL);
  148. *bus_type = v1;
  149. return result;
  150. }
  151. int ps3_repository_read_bus_num_dev(unsigned int bus_index,
  152. unsigned int *num_dev)
  153. {
  154. int result;
  155. u64 v1 = 0;
  156. result = read_node(PS3_LPAR_ID_PME,
  157. make_first_field("bus", bus_index),
  158. make_field("num_dev", 0),
  159. 0, 0,
  160. &v1, NULL);
  161. *num_dev = v1;
  162. return result;
  163. }
  164. int ps3_repository_read_dev_str(unsigned int bus_index,
  165. unsigned int dev_index, const char *dev_str, u64 *value)
  166. {
  167. return read_node(PS3_LPAR_ID_PME,
  168. make_first_field("bus", bus_index),
  169. make_field("dev", dev_index),
  170. make_field(dev_str, 0),
  171. 0,
  172. value, NULL);
  173. }
  174. int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
  175. u64 *dev_id)
  176. {
  177. return read_node(PS3_LPAR_ID_PME, make_first_field("bus", bus_index),
  178. make_field("dev", dev_index), make_field("id", 0), 0,
  179. dev_id, NULL);
  180. }
  181. int ps3_repository_read_dev_type(unsigned int bus_index,
  182. unsigned int dev_index, enum ps3_dev_type *dev_type)
  183. {
  184. int result;
  185. u64 v1 = 0;
  186. result = read_node(PS3_LPAR_ID_PME,
  187. make_first_field("bus", bus_index),
  188. make_field("dev", dev_index),
  189. make_field("type", 0),
  190. 0,
  191. &v1, NULL);
  192. *dev_type = v1;
  193. return result;
  194. }
  195. int ps3_repository_read_dev_intr(unsigned int bus_index,
  196. unsigned int dev_index, unsigned int intr_index,
  197. enum ps3_interrupt_type *intr_type, unsigned int *interrupt_id)
  198. {
  199. int result;
  200. u64 v1 = 0;
  201. u64 v2 = 0;
  202. result = read_node(PS3_LPAR_ID_PME,
  203. make_first_field("bus", bus_index),
  204. make_field("dev", dev_index),
  205. make_field("intr", intr_index),
  206. 0,
  207. &v1, &v2);
  208. *intr_type = v1;
  209. *interrupt_id = v2;
  210. return result;
  211. }
  212. int ps3_repository_read_dev_reg_type(unsigned int bus_index,
  213. unsigned int dev_index, unsigned int reg_index,
  214. enum ps3_reg_type *reg_type)
  215. {
  216. int result;
  217. u64 v1 = 0;
  218. result = read_node(PS3_LPAR_ID_PME,
  219. make_first_field("bus", bus_index),
  220. make_field("dev", dev_index),
  221. make_field("reg", reg_index),
  222. make_field("type", 0),
  223. &v1, NULL);
  224. *reg_type = v1;
  225. return result;
  226. }
  227. int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
  228. unsigned int dev_index, unsigned int reg_index, u64 *bus_addr, u64 *len)
  229. {
  230. return read_node(PS3_LPAR_ID_PME,
  231. make_first_field("bus", bus_index),
  232. make_field("dev", dev_index),
  233. make_field("reg", reg_index),
  234. make_field("data", 0),
  235. bus_addr, len);
  236. }
  237. int ps3_repository_read_dev_reg(unsigned int bus_index,
  238. unsigned int dev_index, unsigned int reg_index,
  239. enum ps3_reg_type *reg_type, u64 *bus_addr, u64 *len)
  240. {
  241. int result = ps3_repository_read_dev_reg_type(bus_index, dev_index,
  242. reg_index, reg_type);
  243. return result ? result
  244. : ps3_repository_read_dev_reg_addr(bus_index, dev_index,
  245. reg_index, bus_addr, len);
  246. }
  247. int ps3_repository_find_device(struct ps3_repository_device *repo)
  248. {
  249. int result;
  250. struct ps3_repository_device tmp = *repo;
  251. unsigned int num_dev;
  252. BUG_ON(repo->bus_index > 10);
  253. BUG_ON(repo->dev_index > 10);
  254. result = ps3_repository_read_bus_num_dev(tmp.bus_index, &num_dev);
  255. if (result) {
  256. pr_devel("%s:%d read_bus_num_dev failed\n", __func__, __LINE__);
  257. return result;
  258. }
  259. pr_devel("%s:%d: bus_type %u, bus_index %u, bus_id %llu, num_dev %u\n",
  260. __func__, __LINE__, tmp.bus_type, tmp.bus_index, tmp.bus_id,
  261. num_dev);
  262. if (tmp.dev_index >= num_dev) {
  263. pr_devel("%s:%d: no device found\n", __func__, __LINE__);
  264. return -ENODEV;
  265. }
  266. result = ps3_repository_read_dev_type(tmp.bus_index, tmp.dev_index,
  267. &tmp.dev_type);
  268. if (result) {
  269. pr_devel("%s:%d read_dev_type failed\n", __func__, __LINE__);
  270. return result;
  271. }
  272. result = ps3_repository_read_dev_id(tmp.bus_index, tmp.dev_index,
  273. &tmp.dev_id);
  274. if (result) {
  275. pr_devel("%s:%d ps3_repository_read_dev_id failed\n", __func__,
  276. __LINE__);
  277. return result;
  278. }
  279. pr_devel("%s:%d: found: dev_type %u, dev_index %u, dev_id %llu\n",
  280. __func__, __LINE__, tmp.dev_type, tmp.dev_index, tmp.dev_id);
  281. *repo = tmp;
  282. return 0;
  283. }
  284. int ps3_repository_find_device_by_id(struct ps3_repository_device *repo,
  285. u64 bus_id, u64 dev_id)
  286. {
  287. int result = -ENODEV;
  288. struct ps3_repository_device tmp;
  289. unsigned int num_dev;
  290. pr_devel(" -> %s:%u: find device by id %llu:%llu\n", __func__, __LINE__,
  291. bus_id, dev_id);
  292. for (tmp.bus_index = 0; tmp.bus_index < 10; tmp.bus_index++) {
  293. result = ps3_repository_read_bus_id(tmp.bus_index,
  294. &tmp.bus_id);
  295. if (result) {
  296. pr_devel("%s:%u read_bus_id(%u) failed\n", __func__,
  297. __LINE__, tmp.bus_index);
  298. return result;
  299. }
  300. if (tmp.bus_id == bus_id)
  301. goto found_bus;
  302. pr_devel("%s:%u: skip, bus_id %llu\n", __func__, __LINE__,
  303. tmp.bus_id);
  304. }
  305. pr_devel(" <- %s:%u: bus not found\n", __func__, __LINE__);
  306. return result;
  307. found_bus:
  308. result = ps3_repository_read_bus_type(tmp.bus_index, &tmp.bus_type);
  309. if (result) {
  310. pr_devel("%s:%u read_bus_type(%u) failed\n", __func__,
  311. __LINE__, tmp.bus_index);
  312. return result;
  313. }
  314. result = ps3_repository_read_bus_num_dev(tmp.bus_index, &num_dev);
  315. if (result) {
  316. pr_devel("%s:%u read_bus_num_dev failed\n", __func__,
  317. __LINE__);
  318. return result;
  319. }
  320. for (tmp.dev_index = 0; tmp.dev_index < num_dev; tmp.dev_index++) {
  321. result = ps3_repository_read_dev_id(tmp.bus_index,
  322. tmp.dev_index,
  323. &tmp.dev_id);
  324. if (result) {
  325. pr_devel("%s:%u read_dev_id(%u:%u) failed\n", __func__,
  326. __LINE__, tmp.bus_index, tmp.dev_index);
  327. return result;
  328. }
  329. if (tmp.dev_id == dev_id)
  330. goto found_dev;
  331. pr_devel("%s:%u: skip, dev_id %llu\n", __func__, __LINE__,
  332. tmp.dev_id);
  333. }
  334. pr_devel(" <- %s:%u: dev not found\n", __func__, __LINE__);
  335. return result;
  336. found_dev:
  337. result = ps3_repository_read_dev_type(tmp.bus_index, tmp.dev_index,
  338. &tmp.dev_type);
  339. if (result) {
  340. pr_devel("%s:%u read_dev_type failed\n", __func__, __LINE__);
  341. return result;
  342. }
  343. pr_devel(" <- %s:%u: found: type (%u:%u) index (%u:%u) id (%llu:%llu)\n",
  344. __func__, __LINE__, tmp.bus_type, tmp.dev_type, tmp.bus_index,
  345. tmp.dev_index, tmp.bus_id, tmp.dev_id);
  346. *repo = tmp;
  347. return 0;
  348. }
  349. int __init ps3_repository_find_devices(enum ps3_bus_type bus_type,
  350. int (*callback)(const struct ps3_repository_device *repo))
  351. {
  352. int result = 0;
  353. struct ps3_repository_device repo;
  354. pr_devel(" -> %s:%d: find bus_type %u\n", __func__, __LINE__, bus_type);
  355. repo.bus_type = bus_type;
  356. result = ps3_repository_find_bus(repo.bus_type, 0, &repo.bus_index);
  357. if (result) {
  358. pr_devel(" <- %s:%u: bus not found\n", __func__, __LINE__);
  359. return result;
  360. }
  361. result = ps3_repository_read_bus_id(repo.bus_index, &repo.bus_id);
  362. if (result) {
  363. pr_devel("%s:%d read_bus_id(%u) failed\n", __func__, __LINE__,
  364. repo.bus_index);
  365. return result;
  366. }
  367. for (repo.dev_index = 0; ; repo.dev_index++) {
  368. result = ps3_repository_find_device(&repo);
  369. if (result == -ENODEV) {
  370. result = 0;
  371. break;
  372. } else if (result)
  373. break;
  374. result = callback(&repo);
  375. if (result) {
  376. pr_devel("%s:%d: abort at callback\n", __func__,
  377. __LINE__);
  378. break;
  379. }
  380. }
  381. pr_devel(" <- %s:%d\n", __func__, __LINE__);
  382. return result;
  383. }
  384. int __init ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from,
  385. unsigned int *bus_index)
  386. {
  387. unsigned int i;
  388. enum ps3_bus_type type;
  389. int error;
  390. for (i = from; i < 10; i++) {
  391. error = ps3_repository_read_bus_type(i, &type);
  392. if (error) {
  393. pr_devel("%s:%d read_bus_type failed\n",
  394. __func__, __LINE__);
  395. *bus_index = UINT_MAX;
  396. return error;
  397. }
  398. if (type == bus_type) {
  399. *bus_index = i;
  400. return 0;
  401. }
  402. }
  403. *bus_index = UINT_MAX;
  404. return -ENODEV;
  405. }
  406. int ps3_repository_find_interrupt(const struct ps3_repository_device *repo,
  407. enum ps3_interrupt_type intr_type, unsigned int *interrupt_id)
  408. {
  409. int result = 0;
  410. unsigned int res_index;
  411. pr_devel("%s:%d: find intr_type %u\n", __func__, __LINE__, intr_type);
  412. *interrupt_id = UINT_MAX;
  413. for (res_index = 0; res_index < 10; res_index++) {
  414. enum ps3_interrupt_type t;
  415. unsigned int id;
  416. result = ps3_repository_read_dev_intr(repo->bus_index,
  417. repo->dev_index, res_index, &t, &id);
  418. if (result) {
  419. pr_devel("%s:%d read_dev_intr failed\n",
  420. __func__, __LINE__);
  421. return result;
  422. }
  423. if (t == intr_type) {
  424. *interrupt_id = id;
  425. break;
  426. }
  427. }
  428. if (res_index == 10)
  429. return -ENODEV;
  430. pr_devel("%s:%d: found intr_type %u at res_index %u\n",
  431. __func__, __LINE__, intr_type, res_index);
  432. return result;
  433. }
  434. int ps3_repository_find_reg(const struct ps3_repository_device *repo,
  435. enum ps3_reg_type reg_type, u64 *bus_addr, u64 *len)
  436. {
  437. int result = 0;
  438. unsigned int res_index;
  439. pr_devel("%s:%d: find reg_type %u\n", __func__, __LINE__, reg_type);
  440. *bus_addr = *len = 0;
  441. for (res_index = 0; res_index < 10; res_index++) {
  442. enum ps3_reg_type t;
  443. u64 a;
  444. u64 l;
  445. result = ps3_repository_read_dev_reg(repo->bus_index,
  446. repo->dev_index, res_index, &t, &a, &l);
  447. if (result) {
  448. pr_devel("%s:%d read_dev_reg failed\n",
  449. __func__, __LINE__);
  450. return result;
  451. }
  452. if (t == reg_type) {
  453. *bus_addr = a;
  454. *len = l;
  455. break;
  456. }
  457. }
  458. if (res_index == 10)
  459. return -ENODEV;
  460. pr_devel("%s:%d: found reg_type %u at res_index %u\n",
  461. __func__, __LINE__, reg_type, res_index);
  462. return result;
  463. }
  464. int ps3_repository_read_stor_dev_port(unsigned int bus_index,
  465. unsigned int dev_index, u64 *port)
  466. {
  467. return read_node(PS3_LPAR_ID_PME,
  468. make_first_field("bus", bus_index),
  469. make_field("dev", dev_index),
  470. make_field("port", 0),
  471. 0, port, NULL);
  472. }
  473. int ps3_repository_read_stor_dev_blk_size(unsigned int bus_index,
  474. unsigned int dev_index, u64 *blk_size)
  475. {
  476. return read_node(PS3_LPAR_ID_PME,
  477. make_first_field("bus", bus_index),
  478. make_field("dev", dev_index),
  479. make_field("blk_size", 0),
  480. 0, blk_size, NULL);
  481. }
  482. int ps3_repository_read_stor_dev_num_blocks(unsigned int bus_index,
  483. unsigned int dev_index, u64 *num_blocks)
  484. {
  485. return read_node(PS3_LPAR_ID_PME,
  486. make_first_field("bus", bus_index),
  487. make_field("dev", dev_index),
  488. make_field("n_blocks", 0),
  489. 0, num_blocks, NULL);
  490. }
  491. int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
  492. unsigned int dev_index, unsigned int *num_regions)
  493. {
  494. int result;
  495. u64 v1 = 0;
  496. result = read_node(PS3_LPAR_ID_PME,
  497. make_first_field("bus", bus_index),
  498. make_field("dev", dev_index),
  499. make_field("n_regs", 0),
  500. 0, &v1, NULL);
  501. *num_regions = v1;
  502. return result;
  503. }
  504. int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
  505. unsigned int dev_index, unsigned int region_index,
  506. unsigned int *region_id)
  507. {
  508. int result;
  509. u64 v1 = 0;
  510. result = read_node(PS3_LPAR_ID_PME,
  511. make_first_field("bus", bus_index),
  512. make_field("dev", dev_index),
  513. make_field("region", region_index),
  514. make_field("id", 0),
  515. &v1, NULL);
  516. *region_id = v1;
  517. return result;
  518. }
  519. int ps3_repository_read_stor_dev_region_size(unsigned int bus_index,
  520. unsigned int dev_index, unsigned int region_index, u64 *region_size)
  521. {
  522. return read_node(PS3_LPAR_ID_PME,
  523. make_first_field("bus", bus_index),
  524. make_field("dev", dev_index),
  525. make_field("region", region_index),
  526. make_field("size", 0),
  527. region_size, NULL);
  528. }
  529. int ps3_repository_read_stor_dev_region_start(unsigned int bus_index,
  530. unsigned int dev_index, unsigned int region_index, u64 *region_start)
  531. {
  532. return read_node(PS3_LPAR_ID_PME,
  533. make_first_field("bus", bus_index),
  534. make_field("dev", dev_index),
  535. make_field("region", region_index),
  536. make_field("start", 0),
  537. region_start, NULL);
  538. }
  539. int ps3_repository_read_stor_dev_info(unsigned int bus_index,
  540. unsigned int dev_index, u64 *port, u64 *blk_size,
  541. u64 *num_blocks, unsigned int *num_regions)
  542. {
  543. int result;
  544. result = ps3_repository_read_stor_dev_port(bus_index, dev_index, port);
  545. if (result)
  546. return result;
  547. result = ps3_repository_read_stor_dev_blk_size(bus_index, dev_index,
  548. blk_size);
  549. if (result)
  550. return result;
  551. result = ps3_repository_read_stor_dev_num_blocks(bus_index, dev_index,
  552. num_blocks);
  553. if (result)
  554. return result;
  555. result = ps3_repository_read_stor_dev_num_regions(bus_index, dev_index,
  556. num_regions);
  557. return result;
  558. }
  559. int ps3_repository_read_stor_dev_region(unsigned int bus_index,
  560. unsigned int dev_index, unsigned int region_index,
  561. unsigned int *region_id, u64 *region_start, u64 *region_size)
  562. {
  563. int result;
  564. result = ps3_repository_read_stor_dev_region_id(bus_index, dev_index,
  565. region_index, region_id);
  566. if (result)
  567. return result;
  568. result = ps3_repository_read_stor_dev_region_start(bus_index, dev_index,
  569. region_index, region_start);
  570. if (result)
  571. return result;
  572. result = ps3_repository_read_stor_dev_region_size(bus_index, dev_index,
  573. region_index, region_size);
  574. return result;
  575. }
  576. /**
  577. * ps3_repository_read_num_pu - Number of logical PU processors for this lpar.
  578. */
  579. int ps3_repository_read_num_pu(u64 *num_pu)
  580. {
  581. *num_pu = 0;
  582. return read_node(PS3_LPAR_ID_CURRENT,
  583. make_first_field("bi", 0),
  584. make_field("pun", 0),
  585. 0, 0,
  586. num_pu, NULL);
  587. }
  588. /**
  589. * ps3_repository_read_pu_id - Read the logical PU id.
  590. * @pu_index: Zero based index.
  591. * @pu_id: The logical PU id.
  592. */
  593. int ps3_repository_read_pu_id(unsigned int pu_index, u64 *pu_id)
  594. {
  595. return read_node(PS3_LPAR_ID_CURRENT,
  596. make_first_field("bi", 0),
  597. make_field("pu", pu_index),
  598. 0, 0,
  599. pu_id, NULL);
  600. }
  601. int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size)
  602. {
  603. return read_node(PS3_LPAR_ID_CURRENT,
  604. make_first_field("bi", 0),
  605. make_field("pu", 0),
  606. ppe_id,
  607. make_field("rm_size", 0),
  608. rm_size, NULL);
  609. }
  610. int ps3_repository_read_region_total(u64 *region_total)
  611. {
  612. return read_node(PS3_LPAR_ID_CURRENT,
  613. make_first_field("bi", 0),
  614. make_field("rgntotal", 0),
  615. 0, 0,
  616. region_total, NULL);
  617. }
  618. /**
  619. * ps3_repository_read_mm_info - Read mm info for single pu system.
  620. * @rm_base: Real mode memory base address.
  621. * @rm_size: Real mode memory size.
  622. * @region_total: Maximum memory region size.
  623. */
  624. int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size, u64 *region_total)
  625. {
  626. int result;
  627. u64 ppe_id;
  628. lv1_get_logical_ppe_id(&ppe_id);
  629. *rm_base = 0;
  630. result = ps3_repository_read_rm_size(ppe_id, rm_size);
  631. return result ? result
  632. : ps3_repository_read_region_total(region_total);
  633. }
  634. /**
  635. * ps3_repository_read_highmem_region_count - Read the number of highmem regions
  636. *
  637. * Bootloaders must arrange the repository nodes such that regions are indexed
  638. * with a region_index from 0 to region_count-1.
  639. */
  640. int ps3_repository_read_highmem_region_count(unsigned int *region_count)
  641. {
  642. int result;
  643. u64 v1 = 0;
  644. result = read_node(PS3_LPAR_ID_CURRENT,
  645. make_first_field("highmem", 0),
  646. make_field("region", 0),
  647. make_field("count", 0),
  648. 0,
  649. &v1, NULL);
  650. *region_count = v1;
  651. return result;
  652. }
  653. int ps3_repository_read_highmem_base(unsigned int region_index,
  654. u64 *highmem_base)
  655. {
  656. return read_node(PS3_LPAR_ID_CURRENT,
  657. make_first_field("highmem", 0),
  658. make_field("region", region_index),
  659. make_field("base", 0),
  660. 0,
  661. highmem_base, NULL);
  662. }
  663. int ps3_repository_read_highmem_size(unsigned int region_index,
  664. u64 *highmem_size)
  665. {
  666. return read_node(PS3_LPAR_ID_CURRENT,
  667. make_first_field("highmem", 0),
  668. make_field("region", region_index),
  669. make_field("size", 0),
  670. 0,
  671. highmem_size, NULL);
  672. }
  673. /**
  674. * ps3_repository_read_highmem_info - Read high memory region info
  675. * @region_index: Region index, {0,..,region_count-1}.
  676. * @highmem_base: High memory base address.
  677. * @highmem_size: High memory size.
  678. *
  679. * Bootloaders that preallocate highmem regions must place the
  680. * region info into the repository at these well known nodes.
  681. */
  682. int ps3_repository_read_highmem_info(unsigned int region_index,
  683. u64 *highmem_base, u64 *highmem_size)
  684. {
  685. int result;
  686. *highmem_base = 0;
  687. result = ps3_repository_read_highmem_base(region_index, highmem_base);
  688. return result ? result
  689. : ps3_repository_read_highmem_size(region_index, highmem_size);
  690. }
  691. /**
  692. * ps3_repository_read_num_spu_reserved - Number of physical spus reserved.
  693. * @num_spu: Number of physical spus.
  694. */
  695. int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved)
  696. {
  697. int result;
  698. u64 v1 = 0;
  699. result = read_node(PS3_LPAR_ID_CURRENT,
  700. make_first_field("bi", 0),
  701. make_field("spun", 0),
  702. 0, 0,
  703. &v1, NULL);
  704. *num_spu_reserved = v1;
  705. return result;
  706. }
  707. /**
  708. * ps3_repository_read_num_spu_resource_id - Number of spu resource reservations.
  709. * @num_resource_id: Number of spu resource ids.
  710. */
  711. int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id)
  712. {
  713. int result;
  714. u64 v1 = 0;
  715. result = read_node(PS3_LPAR_ID_CURRENT,
  716. make_first_field("bi", 0),
  717. make_field("spursvn", 0),
  718. 0, 0,
  719. &v1, NULL);
  720. *num_resource_id = v1;
  721. return result;
  722. }
  723. /**
  724. * ps3_repository_read_spu_resource_id - spu resource reservation id value.
  725. * @res_index: Resource reservation index.
  726. * @resource_type: Resource reservation type.
  727. * @resource_id: Resource reservation id.
  728. */
  729. int ps3_repository_read_spu_resource_id(unsigned int res_index,
  730. enum ps3_spu_resource_type *resource_type, unsigned int *resource_id)
  731. {
  732. int result;
  733. u64 v1 = 0;
  734. u64 v2 = 0;
  735. result = read_node(PS3_LPAR_ID_CURRENT,
  736. make_first_field("bi", 0),
  737. make_field("spursv", 0),
  738. res_index,
  739. 0,
  740. &v1, &v2);
  741. *resource_type = v1;
  742. *resource_id = v2;
  743. return result;
  744. }
  745. static int ps3_repository_read_boot_dat_address(u64 *address)
  746. {
  747. return read_node(PS3_LPAR_ID_CURRENT,
  748. make_first_field("bi", 0),
  749. make_field("boot_dat", 0),
  750. make_field("address", 0),
  751. 0,
  752. address, NULL);
  753. }
  754. int ps3_repository_read_boot_dat_size(unsigned int *size)
  755. {
  756. int result;
  757. u64 v1 = 0;
  758. result = read_node(PS3_LPAR_ID_CURRENT,
  759. make_first_field("bi", 0),
  760. make_field("boot_dat", 0),
  761. make_field("size", 0),
  762. 0,
  763. &v1, NULL);
  764. *size = v1;
  765. return result;
  766. }
  767. int __init ps3_repository_read_vuart_av_port(unsigned int *port)
  768. {
  769. int result;
  770. u64 v1 = 0;
  771. result = read_node(PS3_LPAR_ID_CURRENT,
  772. make_first_field("bi", 0),
  773. make_field("vir_uart", 0),
  774. make_field("port", 0),
  775. make_field("avset", 0),
  776. &v1, NULL);
  777. *port = v1;
  778. return result;
  779. }
  780. int __init ps3_repository_read_vuart_sysmgr_port(unsigned int *port)
  781. {
  782. int result;
  783. u64 v1 = 0;
  784. result = read_node(PS3_LPAR_ID_CURRENT,
  785. make_first_field("bi", 0),
  786. make_field("vir_uart", 0),
  787. make_field("port", 0),
  788. make_field("sysmgr", 0),
  789. &v1, NULL);
  790. *port = v1;
  791. return result;
  792. }
  793. /**
  794. * ps3_repository_read_boot_dat_info - Get address and size of cell_ext_os_area.
  795. * address: lpar address of cell_ext_os_area
  796. * @size: size of cell_ext_os_area
  797. */
  798. int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size)
  799. {
  800. int result;
  801. *size = 0;
  802. result = ps3_repository_read_boot_dat_address(lpar_addr);
  803. return result ? result
  804. : ps3_repository_read_boot_dat_size(size);
  805. }
  806. /**
  807. * ps3_repository_read_num_be - Number of physical BE processors in the system.
  808. */
  809. int ps3_repository_read_num_be(unsigned int *num_be)
  810. {
  811. int result;
  812. u64 v1 = 0;
  813. result = read_node(PS3_LPAR_ID_PME,
  814. make_first_field("ben", 0),
  815. 0,
  816. 0,
  817. 0,
  818. &v1, NULL);
  819. *num_be = v1;
  820. return result;
  821. }
  822. /**
  823. * ps3_repository_read_be_node_id - Read the physical BE processor node id.
  824. * @be_index: Zero based index.
  825. * @node_id: The BE processor node id.
  826. */
  827. int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id)
  828. {
  829. return read_node(PS3_LPAR_ID_PME,
  830. make_first_field("be", be_index),
  831. 0,
  832. 0,
  833. 0,
  834. node_id, NULL);
  835. }
  836. /**
  837. * ps3_repository_read_be_id - Read the physical BE processor id.
  838. * @node_id: The BE processor node id.
  839. * @be_id: The BE processor id.
  840. */
  841. int ps3_repository_read_be_id(u64 node_id, u64 *be_id)
  842. {
  843. return read_node(PS3_LPAR_ID_PME,
  844. make_first_field("be", 0),
  845. node_id,
  846. 0,
  847. 0,
  848. be_id, NULL);
  849. }
  850. int __init ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq)
  851. {
  852. return read_node(PS3_LPAR_ID_PME,
  853. make_first_field("be", 0),
  854. node_id,
  855. make_field("clock", 0),
  856. 0,
  857. tb_freq, NULL);
  858. }
  859. int __init ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq)
  860. {
  861. int result;
  862. u64 node_id;
  863. *tb_freq = 0;
  864. result = ps3_repository_read_be_node_id(be_index, &node_id);
  865. return result ? result
  866. : ps3_repository_read_tb_freq(node_id, tb_freq);
  867. }
  868. int ps3_repository_read_lpm_privileges(unsigned int be_index, u64 *lpar,
  869. u64 *rights)
  870. {
  871. int result;
  872. u64 node_id;
  873. *lpar = 0;
  874. *rights = 0;
  875. result = ps3_repository_read_be_node_id(be_index, &node_id);
  876. return result ? result
  877. : read_node(PS3_LPAR_ID_PME,
  878. make_first_field("be", 0),
  879. node_id,
  880. make_field("lpm", 0),
  881. make_field("priv", 0),
  882. lpar, rights);
  883. }
  884. #if defined(CONFIG_PS3_REPOSITORY_WRITE)
  885. static int create_node(u64 n1, u64 n2, u64 n3, u64 n4, u64 v1, u64 v2)
  886. {
  887. int result;
  888. dump_node(0, n1, n2, n3, n4, v1, v2);
  889. result = lv1_create_repository_node(n1, n2, n3, n4, v1, v2);
  890. if (result) {
  891. pr_devel("%s:%d: lv1_create_repository_node failed: %s\n",
  892. __func__, __LINE__, ps3_result(result));
  893. return -ENOENT;
  894. }
  895. return 0;
  896. }
  897. static int delete_node(u64 n1, u64 n2, u64 n3, u64 n4)
  898. {
  899. int result;
  900. dump_node(0, n1, n2, n3, n4, 0, 0);
  901. result = lv1_delete_repository_node(n1, n2, n3, n4);
  902. if (result) {
  903. pr_devel("%s:%d: lv1_delete_repository_node failed: %s\n",
  904. __func__, __LINE__, ps3_result(result));
  905. return -ENOENT;
  906. }
  907. return 0;
  908. }
  909. static int write_node(u64 n1, u64 n2, u64 n3, u64 n4, u64 v1, u64 v2)
  910. {
  911. int result;
  912. result = create_node(n1, n2, n3, n4, v1, v2);
  913. if (!result)
  914. return 0;
  915. result = lv1_write_repository_node(n1, n2, n3, n4, v1, v2);
  916. if (result) {
  917. pr_devel("%s:%d: lv1_write_repository_node failed: %s\n",
  918. __func__, __LINE__, ps3_result(result));
  919. return -ENOENT;
  920. }
  921. return 0;
  922. }
  923. int ps3_repository_write_highmem_region_count(unsigned int region_count)
  924. {
  925. int result;
  926. u64 v1 = (u64)region_count;
  927. result = write_node(
  928. make_first_field("highmem", 0),
  929. make_field("region", 0),
  930. make_field("count", 0),
  931. 0,
  932. v1, 0);
  933. return result;
  934. }
  935. int ps3_repository_write_highmem_base(unsigned int region_index,
  936. u64 highmem_base)
  937. {
  938. return write_node(
  939. make_first_field("highmem", 0),
  940. make_field("region", region_index),
  941. make_field("base", 0),
  942. 0,
  943. highmem_base, 0);
  944. }
  945. int ps3_repository_write_highmem_size(unsigned int region_index,
  946. u64 highmem_size)
  947. {
  948. return write_node(
  949. make_first_field("highmem", 0),
  950. make_field("region", region_index),
  951. make_field("size", 0),
  952. 0,
  953. highmem_size, 0);
  954. }
  955. int ps3_repository_write_highmem_info(unsigned int region_index,
  956. u64 highmem_base, u64 highmem_size)
  957. {
  958. int result;
  959. result = ps3_repository_write_highmem_base(region_index, highmem_base);
  960. return result ? result
  961. : ps3_repository_write_highmem_size(region_index, highmem_size);
  962. }
  963. static int ps3_repository_delete_highmem_base(unsigned int region_index)
  964. {
  965. return delete_node(
  966. make_first_field("highmem", 0),
  967. make_field("region", region_index),
  968. make_field("base", 0),
  969. 0);
  970. }
  971. static int ps3_repository_delete_highmem_size(unsigned int region_index)
  972. {
  973. return delete_node(
  974. make_first_field("highmem", 0),
  975. make_field("region", region_index),
  976. make_field("size", 0),
  977. 0);
  978. }
  979. int ps3_repository_delete_highmem_info(unsigned int region_index)
  980. {
  981. int result;
  982. result = ps3_repository_delete_highmem_base(region_index);
  983. result += ps3_repository_delete_highmem_size(region_index);
  984. return result ? -1 : 0;
  985. }
  986. #endif /* defined(CONFIG_PS3_REPOSITORY_WRITE) */
  987. #if defined(DEBUG)
  988. int __init ps3_repository_dump_resource_info(const struct ps3_repository_device *repo)
  989. {
  990. int result = 0;
  991. unsigned int res_index;
  992. pr_devel(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
  993. repo->bus_index, repo->dev_index);
  994. for (res_index = 0; res_index < 10; res_index++) {
  995. enum ps3_interrupt_type intr_type;
  996. unsigned int interrupt_id;
  997. result = ps3_repository_read_dev_intr(repo->bus_index,
  998. repo->dev_index, res_index, &intr_type, &interrupt_id);
  999. if (result) {
  1000. if (result != LV1_NO_ENTRY)
  1001. pr_devel("%s:%d ps3_repository_read_dev_intr"
  1002. " (%u:%u) failed\n", __func__, __LINE__,
  1003. repo->bus_index, repo->dev_index);
  1004. break;
  1005. }
  1006. pr_devel("%s:%d (%u:%u) intr_type %u, interrupt_id %u\n",
  1007. __func__, __LINE__, repo->bus_index, repo->dev_index,
  1008. intr_type, interrupt_id);
  1009. }
  1010. for (res_index = 0; res_index < 10; res_index++) {
  1011. enum ps3_reg_type reg_type;
  1012. u64 bus_addr;
  1013. u64 len;
  1014. result = ps3_repository_read_dev_reg(repo->bus_index,
  1015. repo->dev_index, res_index, &reg_type, &bus_addr, &len);
  1016. if (result) {
  1017. if (result != LV1_NO_ENTRY)
  1018. pr_devel("%s:%d ps3_repository_read_dev_reg"
  1019. " (%u:%u) failed\n", __func__, __LINE__,
  1020. repo->bus_index, repo->dev_index);
  1021. break;
  1022. }
  1023. pr_devel("%s:%d (%u:%u) reg_type %u, bus_addr %llxh, len %llxh\n",
  1024. __func__, __LINE__, repo->bus_index, repo->dev_index,
  1025. reg_type, bus_addr, len);
  1026. }
  1027. pr_devel(" <- %s:%d\n", __func__, __LINE__);
  1028. return result;
  1029. }
  1030. static int __init dump_stor_dev_info(struct ps3_repository_device *repo)
  1031. {
  1032. int result = 0;
  1033. unsigned int num_regions, region_index;
  1034. u64 port, blk_size, num_blocks;
  1035. pr_devel(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
  1036. repo->bus_index, repo->dev_index);
  1037. result = ps3_repository_read_stor_dev_info(repo->bus_index,
  1038. repo->dev_index, &port, &blk_size, &num_blocks, &num_regions);
  1039. if (result) {
  1040. pr_devel("%s:%d ps3_repository_read_stor_dev_info"
  1041. " (%u:%u) failed\n", __func__, __LINE__,
  1042. repo->bus_index, repo->dev_index);
  1043. goto out;
  1044. }
  1045. pr_devel("%s:%d (%u:%u): port %llu, blk_size %llu, num_blocks "
  1046. "%llu, num_regions %u\n",
  1047. __func__, __LINE__, repo->bus_index, repo->dev_index,
  1048. port, blk_size, num_blocks, num_regions);
  1049. for (region_index = 0; region_index < num_regions; region_index++) {
  1050. unsigned int region_id;
  1051. u64 region_start, region_size;
  1052. result = ps3_repository_read_stor_dev_region(repo->bus_index,
  1053. repo->dev_index, region_index, &region_id,
  1054. &region_start, &region_size);
  1055. if (result) {
  1056. pr_devel("%s:%d ps3_repository_read_stor_dev_region"
  1057. " (%u:%u) failed\n", __func__, __LINE__,
  1058. repo->bus_index, repo->dev_index);
  1059. break;
  1060. }
  1061. pr_devel("%s:%d (%u:%u) region_id %u, start %lxh, size %lxh\n",
  1062. __func__, __LINE__, repo->bus_index, repo->dev_index,
  1063. region_id, (unsigned long)region_start,
  1064. (unsigned long)region_size);
  1065. }
  1066. out:
  1067. pr_devel(" <- %s:%d\n", __func__, __LINE__);
  1068. return result;
  1069. }
  1070. static int __init dump_device_info(struct ps3_repository_device *repo,
  1071. unsigned int num_dev)
  1072. {
  1073. int result = 0;
  1074. pr_devel(" -> %s:%d: bus_%u\n", __func__, __LINE__, repo->bus_index);
  1075. for (repo->dev_index = 0; repo->dev_index < num_dev;
  1076. repo->dev_index++) {
  1077. result = ps3_repository_read_dev_type(repo->bus_index,
  1078. repo->dev_index, &repo->dev_type);
  1079. if (result) {
  1080. pr_devel("%s:%d ps3_repository_read_dev_type"
  1081. " (%u:%u) failed\n", __func__, __LINE__,
  1082. repo->bus_index, repo->dev_index);
  1083. break;
  1084. }
  1085. result = ps3_repository_read_dev_id(repo->bus_index,
  1086. repo->dev_index, &repo->dev_id);
  1087. if (result) {
  1088. pr_devel("%s:%d ps3_repository_read_dev_id"
  1089. " (%u:%u) failed\n", __func__, __LINE__,
  1090. repo->bus_index, repo->dev_index);
  1091. continue;
  1092. }
  1093. pr_devel("%s:%d (%u:%u): dev_type %u, dev_id %lu\n", __func__,
  1094. __LINE__, repo->bus_index, repo->dev_index,
  1095. repo->dev_type, (unsigned long)repo->dev_id);
  1096. ps3_repository_dump_resource_info(repo);
  1097. if (repo->bus_type == PS3_BUS_TYPE_STORAGE)
  1098. dump_stor_dev_info(repo);
  1099. }
  1100. pr_devel(" <- %s:%d\n", __func__, __LINE__);
  1101. return result;
  1102. }
  1103. int __init ps3_repository_dump_bus_info(void)
  1104. {
  1105. int result = 0;
  1106. struct ps3_repository_device repo;
  1107. pr_devel(" -> %s:%d\n", __func__, __LINE__);
  1108. memset(&repo, 0, sizeof(repo));
  1109. for (repo.bus_index = 0; repo.bus_index < 10; repo.bus_index++) {
  1110. unsigned int num_dev;
  1111. result = ps3_repository_read_bus_type(repo.bus_index,
  1112. &repo.bus_type);
  1113. if (result) {
  1114. pr_devel("%s:%d read_bus_type(%u) failed\n",
  1115. __func__, __LINE__, repo.bus_index);
  1116. break;
  1117. }
  1118. result = ps3_repository_read_bus_id(repo.bus_index,
  1119. &repo.bus_id);
  1120. if (result) {
  1121. pr_devel("%s:%d read_bus_id(%u) failed\n",
  1122. __func__, __LINE__, repo.bus_index);
  1123. continue;
  1124. }
  1125. if (repo.bus_index != repo.bus_id)
  1126. pr_devel("%s:%d bus_index != bus_id\n",
  1127. __func__, __LINE__);
  1128. result = ps3_repository_read_bus_num_dev(repo.bus_index,
  1129. &num_dev);
  1130. if (result) {
  1131. pr_devel("%s:%d read_bus_num_dev(%u) failed\n",
  1132. __func__, __LINE__, repo.bus_index);
  1133. continue;
  1134. }
  1135. pr_devel("%s:%d bus_%u: bus_type %u, bus_id %lu, num_dev %u\n",
  1136. __func__, __LINE__, repo.bus_index, repo.bus_type,
  1137. (unsigned long)repo.bus_id, num_dev);
  1138. dump_device_info(&repo, num_dev);
  1139. }
  1140. pr_devel(" <- %s:%d\n", __func__, __LINE__);
  1141. return result;
  1142. }
  1143. #endif /* defined(DEBUG) */