nvidia-add-modulepath-support.patch 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. From c17e544b271ced65483692103d39ed1188d4ca25 Mon Sep 17 00:00:00 2001
  2. From: Hans de Goede <hdegoede@redhat.com>
  3. Date: Tue, 27 Sep 2016 14:30:10 +0200
  4. Subject: [PATCH xserver v2 5/7] xfree86: Remove redundant ServerIsNotSeat0
  5. check from xf86CallDriverProbe
  6. If foundScreen is TRUE, then all the code below the removed if
  7. will not execute until we reach the return foundScreen; at the
  8. end, so this entire if block is redundant.
  9. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  10. ---
  11. hw/xfree86/common/xf86Bus.c | 2 --
  12. 1 file changed, 2 deletions(-)
  13. diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
  14. index 5b93940..27c6b1b 100644
  15. --- a/hw/xfree86/common/xf86Bus.c
  16. +++ b/hw/xfree86/common/xf86Bus.c
  17. @@ -82,8 +82,6 @@ xf86CallDriverProbe(DriverPtr drv, Bool detect_only)
  18. if (!xf86DoConfigure && drv->platformProbe != NULL) {
  19. foundScreen = xf86platformProbeDev(drv);
  20. }
  21. - if (ServerIsNotSeat0() && foundScreen)
  22. - return foundScreen;
  23. #endif
  24. #ifdef XSERVER_LIBPCIACCESS
  25. --
  26. 2.9.3
  27. From 74bc0fff3a6ca233e56b3fb2971bca97b5a4f8b5 Mon Sep 17 00:00:00 2001
  28. From: Hans de Goede <hdegoede@redhat.com>
  29. Date: Fri, 30 Sep 2016 11:59:04 +0200
  30. Subject: [PATCH xserver v2 6/7] xfree86: Make adding unclaimed devices as GPU
  31. devices a separate step
  32. This is primarily a preparation patch for fixing the xserver exiting with
  33. a "no screens found" error even though there are supported video cards,
  34. due to the server not recognizing any card as the primary card.
  35. This also fixes the (mostly theoretical) case of a platformBus capable
  36. driver adding a device as GPUscreen before a driver which only supports
  37. the old PCI probe method gets a chance to claim it as a normal screen.
  38. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  39. ---
  40. hw/xfree86/common/xf86Bus.c | 4 ++++
  41. hw/xfree86/common/xf86platformBus.c | 15 +++++++++++++++
  42. hw/xfree86/common/xf86platformBus.h | 6 ++++++
  43. 3 files changed, 25 insertions(+)
  44. diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
  45. index 27c6b1b..a3a9898 100644
  46. --- a/hw/xfree86/common/xf86Bus.c
  47. +++ b/hw/xfree86/common/xf86Bus.c
  48. @@ -125,6 +125,10 @@ xf86BusConfig(void)
  49. xf86CallDriverProbe(xf86DriverList[i], FALSE);
  50. }
  51. + for (i = 0; i < xf86NumDrivers; i++) {
  52. + xf86platformAddGPUDevices(xf86DriverList[i]);
  53. + }
  54. +
  55. /* If nothing was detected, return now */
  56. if (xf86NumScreens == 0) {
  57. xf86Msg(X_ERROR, "No devices detected.\n");
  58. diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
  59. index 39fb1dd..8dd0d5d 100644
  60. --- a/hw/xfree86/common/xf86platformBus.c
  61. +++ b/hw/xfree86/common/xf86platformBus.c
  62. @@ -475,6 +475,21 @@ xf86platformProbeDev(DriverPtr drvp)
  63. isGPUDevice(devList[i]) ? PLATFORM_PROBE_GPU_SCREEN : 0);
  64. }
  65. + return foundScreen;
  66. +}
  67. +
  68. +int
  69. +xf86platformAddGPUDevices(DriverPtr drvp)
  70. +{
  71. + Bool foundScreen = FALSE;
  72. + GDevPtr *devList;
  73. + int j;
  74. +
  75. + if (!drvp->platformProbe)
  76. + return FALSE;
  77. +
  78. + xf86MatchDevice(drvp->driverName, &devList);
  79. +
  80. /* if autoaddgpu devices is enabled then go find any unclaimed platform
  81. * devices and add them as GPU screens */
  82. if (xf86Info.autoAddGPU) {
  83. diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h
  84. index a7335b9..0f5c0ef 100644
  85. --- a/hw/xfree86/common/xf86platformBus.h
  86. +++ b/hw/xfree86/common/xf86platformBus.h
  87. @@ -41,6 +41,7 @@ struct xf86_platform_device {
  88. #ifdef XSERVER_PLATFORM_BUS
  89. int xf86platformProbe(void);
  90. int xf86platformProbeDev(DriverPtr drvp);
  91. +int xf86platformAddGPUDevices(DriverPtr drvp);
  92. extern int xf86_num_platform_devices;
  93. extern struct xf86_platform_device *xf86_platform_devices;
  94. @@ -156,6 +157,11 @@ xf86PlatformMatchDriver(char *matches[], int nmatches);
  95. extern void xf86platformVTProbe(void);
  96. extern void xf86platformPrimary(void);
  97. +
  98. +#else
  99. +
  100. +static inline int xf86platformAddGPUDevices(DriverPtr drvp) { return FALSE; }
  101. +
  102. #endif
  103. #endif
  104. --
  105. 2.9.3
  106. From 02bcb6f189c4ad8b2e73ce99cfa3c10f0c244a88 Mon Sep 17 00:00:00 2001
  107. From: Hans de Goede <hdegoede@redhat.com>
  108. Date: Fri, 30 Sep 2016 12:29:09 +0200
  109. Subject: [PATCH xserver v2 7/7] xfree86: Try harder to find atleast 1 non GPU
  110. Screen
  111. If we did not find any non GPU Screens, try again ignoring the notion
  112. of any video devices being the primary device. This fixes Xorg exiting
  113. with a "no screens found" error when using virtio-vga in a
  114. virtual-machine and when using a device driven by simpledrm.
  115. This is a somewhat ugly solution, but it is the best I can come up with
  116. without major surgery to the bus and probe code.
  117. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  118. ---
  119. hw/xfree86/common/xf86.h | 1 +
  120. hw/xfree86/common/xf86Bus.c | 26 +++++++++++++++++++++++---
  121. hw/xfree86/common/xf86Globals.c | 1 +
  122. hw/xfree86/common/xf86pciBus.c | 4 ++++
  123. hw/xfree86/common/xf86platformBus.c | 4 ++++
  124. 5 files changed, 33 insertions(+), 3 deletions(-)
  125. diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
  126. index e54c811..f724688 100644
  127. --- a/hw/xfree86/common/xf86.h
  128. +++ b/hw/xfree86/common/xf86.h
  129. @@ -55,6 +55,7 @@
  130. extern _X_EXPORT int xf86DoConfigure;
  131. extern _X_EXPORT int xf86DoShowOptions;
  132. extern _X_EXPORT Bool xf86DoConfigurePass1;
  133. +extern _X_EXPORT Bool xf86ProbeIgnorePrimary;
  134. extern _X_EXPORT Bool xorgHWAccess;
  135. extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
  136. diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
  137. index a3a9898..9836803 100644
  138. --- a/hw/xfree86/common/xf86Bus.c
  139. +++ b/hw/xfree86/common/xf86Bus.c
  140. @@ -117,14 +117,34 @@ xf86BusConfig(void)
  141. int i, j;
  142. /*
  143. - * Now call each of the Probe functions. Each successful probe will
  144. - * result in an extra entry added to the xf86Screens[] list for each
  145. - * instance of the hardware found.
  146. + * 3 step probe to (hopefully) ensure that we always find at least 1
  147. + * (non GPU) screen:
  148. + *
  149. + * 1. Call each drivers probe function normally,
  150. + * Each successful probe will result in an extra entry added to the
  151. + * xf86Screens[] list for each instance of the hardware found.
  152. */
  153. for (i = 0; i < xf86NumDrivers; i++) {
  154. xf86CallDriverProbe(xf86DriverList[i], FALSE);
  155. }
  156. + /*
  157. + * 2. If no Screens were found, call each drivers probe function with
  158. + * ignorePrimary = TRUE, to ensure that we do actually get a
  159. + * Screen if there is atleast one supported video card.
  160. + */
  161. + if (xf86NumScreens == 0) {
  162. + xf86ProbeIgnorePrimary = TRUE;
  163. + for (i = 0; i < xf86NumDrivers && xf86NumScreens == 0; i++) {
  164. + xf86CallDriverProbe(xf86DriverList[i], FALSE);
  165. + }
  166. + xf86ProbeIgnorePrimary = FALSE;
  167. + }
  168. +
  169. + /*
  170. + * 3. Call xf86platformAddGPUDevices() to add any additional video cards as
  171. + * GPUScreens (GPUScreens are only supported by platformBus drivers).
  172. + */
  173. for (i = 0; i < xf86NumDrivers; i++) {
  174. xf86platformAddGPUDevices(xf86DriverList[i]);
  175. }
  176. diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
  177. index 07cfabf..e962b75 100644
  178. --- a/hw/xfree86/common/xf86Globals.c
  179. +++ b/hw/xfree86/common/xf86Globals.c
  180. @@ -152,6 +152,7 @@ XF86ConfigPtr xf86configptr = NULL;
  181. Bool xf86Resetting = FALSE;
  182. Bool xf86Initialising = FALSE;
  183. Bool xf86DoConfigure = FALSE;
  184. +Bool xf86ProbeIgnorePrimary = FALSE;
  185. Bool xf86DoShowOptions = FALSE;
  186. DriverPtr *xf86DriverList = NULL;
  187. int xf86NumDrivers = 0;
  188. diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
  189. index 8158c2b..9adfee5 100644
  190. --- a/hw/xfree86/common/xf86pciBus.c
  191. +++ b/hw/xfree86/common/xf86pciBus.c
  192. @@ -352,6 +352,10 @@ xf86ComparePciBusString(const char *busID, int bus, int device, int func)
  193. Bool
  194. xf86IsPrimaryPci(struct pci_device *pPci)
  195. {
  196. + /* Add max. 1 screen for the IgnorePrimary fallback path */
  197. + if (xf86ProbeIgnorePrimary && xf86NumScreens == 0)
  198. + return TRUE;
  199. +
  200. if (primaryBus.type == BUS_PCI)
  201. return pPci == primaryBus.id.pci;
  202. #ifdef XSERVER_PLATFORM_BUS
  203. diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
  204. index 8dd0d5d..063e81c 100644
  205. --- a/hw/xfree86/common/xf86platformBus.c
  206. +++ b/hw/xfree86/common/xf86platformBus.c
  207. @@ -114,6 +114,10 @@ xf86_find_platform_device_by_devnum(int major, int minor)
  208. static Bool
  209. xf86IsPrimaryPlatform(struct xf86_platform_device *plat)
  210. {
  211. + /* Add max. 1 screen for the IgnorePrimary fallback path */
  212. + if (xf86ProbeIgnorePrimary && xf86NumScreens == 0)
  213. + return TRUE;
  214. +
  215. if (primaryBus.type == BUS_PLATFORM)
  216. return plat == primaryBus.id.plat;
  217. #ifdef XSERVER_LIBPCIACCESS
  218. --
  219. 2.9.3
  220. From c57c1e53ea3d76ebba5b2a23b7260817d3e6b921 Mon Sep 17 00:00:00 2001
  221. From: Hans De Goede <hdegoede@redhat.com>
  222. Date: Mon, 12 Dec 2016 17:03:12 +0100
  223. Subject: [PATCH xserver 1/6] xfree86: Free devlist returned by xf86MatchDevice
  224. xf86MatchDevice returns a dynamically allocated list of GDevPtr-s,
  225. free this when we're done with it.
  226. Reviewed-by: Adam Jackson <ajax@redhat.com>
  227. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  228. ---
  229. hw/xfree86/common/xf86platformBus.c | 4 ++++
  230. 1 file changed, 4 insertions(+)
  231. diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
  232. index 063e81c..16d934f 100644
  233. --- a/hw/xfree86/common/xf86platformBus.c
  234. +++ b/hw/xfree86/common/xf86platformBus.c
  235. @@ -479,6 +479,8 @@ xf86platformProbeDev(DriverPtr drvp)
  236. isGPUDevice(devList[i]) ? PLATFORM_PROBE_GPU_SCREEN : 0);
  237. }
  238. + free(devList);
  239. +
  240. return foundScreen;
  241. }
  242. @@ -505,6 +507,8 @@ xf86platformAddGPUDevices(DriverPtr drvp)
  243. }
  244. }
  245. + free(devList);
  246. +
  247. return foundScreen;
  248. }
  249. --
  250. 2.9.3
  251. From 08b84d72878e43401e99059c3c926dfa42a360c3 Mon Sep 17 00:00:00 2001
  252. From: Hans De Goede <hdegoede@redhat.com>
  253. Date: Mon, 12 Dec 2016 17:03:13 +0100
  254. Subject: [PATCH xserver 2/6] xfree86: Make OutputClassMatches take a
  255. xf86_platform_device
  256. Make OutputClassMatches directly take a xf86_platform_device as argument,
  257. rather then an index into xf86_platform_devices. This makes things
  258. easier for callers which already have a xf86_platform_device pointer.
  259. Reviewed-by: Adam Jackson <ajax@redhat.com>
  260. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  261. ---
  262. hw/xfree86/common/xf86platformBus.c | 7 ++++---
  263. 1 file changed, 4 insertions(+), 3 deletions(-)
  264. diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
  265. index 16d934f..25a9040 100644
  266. --- a/hw/xfree86/common/xf86platformBus.c
  267. +++ b/hw/xfree86/common/xf86platformBus.c
  268. @@ -214,9 +214,10 @@ MatchToken(const char *value, struct xorg_list *patterns,
  269. }
  270. static Bool
  271. -OutputClassMatches(const XF86ConfOutputClassPtr oclass, int index)
  272. +OutputClassMatches(const XF86ConfOutputClassPtr oclass,
  273. + struct xf86_platform_device *dev)
  274. {
  275. - char *driver = xf86_platform_odev_attributes(index)->driver;
  276. + char *driver = dev->attribs->driver;
  277. if (!MatchToken(driver, &oclass->match_driver, strcmp))
  278. return FALSE;
  279. @@ -234,7 +235,7 @@ xf86OutputClassDriverList(int index, char *matches[], int nmatches)
  280. return 0;
  281. for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) {
  282. - if (OutputClassMatches(cl, index)) {
  283. + if (OutputClassMatches(cl, &xf86_platform_devices[index])) {
  284. char *path = xf86_platform_odev_attributes(index)->path;
  285. xf86Msg(X_INFO, "Applying OutputClass \"%s\" to %s\n",
  286. --
  287. 2.9.3
  288. From 9cd3cc75269d9196898487b5712ee47b8291e077 Mon Sep 17 00:00:00 2001
  289. From: Hans De Goede <hdegoede@redhat.com>
  290. Date: Mon, 12 Dec 2016 17:03:14 +0100
  291. Subject: [PATCH xserver 3/6] xfree86: Add options support for OutputClass
  292. Options
  293. Add support for setting options in OutputClass Sections and having these
  294. applied to any matching output devices.
  295. Reviewed-by: Adam Jackson <ajax@redhat.com>
  296. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  297. ---
  298. hw/xfree86/common/xf86Option.c | 5 ++++-
  299. hw/xfree86/common/xf86platformBus.c | 42 +++++++++++++++++++++++++++++++++++++
  300. hw/xfree86/common/xf86platformBus.h | 2 ++
  301. hw/xfree86/man/xorg.conf.man | 10 +++++++++
  302. hw/xfree86/parser/OutputClass.c | 6 ++++++
  303. hw/xfree86/parser/xf86Parser.h | 1 +
  304. 6 files changed, 65 insertions(+), 1 deletion(-)
  305. diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
  306. index 0e8bc1f..929724d 100644
  307. --- a/hw/xfree86/common/xf86Option.c
  308. +++ b/hw/xfree86/common/xf86Option.c
  309. @@ -44,6 +44,7 @@
  310. #include "xf86Xinput.h"
  311. #include "xf86Optrec.h"
  312. #include "xf86Parser.h"
  313. +#include "xf86platformBus.h" /* For OutputClass functions */
  314. #include "optionstr.h"
  315. static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options,
  316. @@ -64,7 +65,7 @@ static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options,
  317. *
  318. * The order of precedence for options is:
  319. *
  320. - * extraOpts, display, confScreen, monitor, device
  321. + * extraOpts, display, confScreen, monitor, device, outputClassOptions
  322. */
  323. void
  324. @@ -79,6 +80,8 @@ xf86CollectOptions(ScrnInfoPtr pScrn, XF86OptionPtr extraOpts)
  325. pScrn->options = NULL;
  326. for (i = pScrn->numEntities - 1; i >= 0; i--) {
  327. + xf86MergeOutputClassOptions(pScrn->entityList[i], &pScrn->options);
  328. +
  329. device = xf86GetDevFromEntity(pScrn->entityList[i],
  330. pScrn->entityInstanceList[i]);
  331. if (device && device->options) {
  332. diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
  333. index 25a9040..a698c6c 100644
  334. --- a/hw/xfree86/common/xf86platformBus.c
  335. +++ b/hw/xfree86/common/xf86platformBus.c
  336. @@ -310,6 +310,48 @@ xf86platformProbe(void)
  337. return 0;
  338. }
  339. +void
  340. +xf86MergeOutputClassOptions(int entityIndex, void **options)
  341. +{
  342. + const EntityPtr entity = xf86Entities[entityIndex];
  343. + struct xf86_platform_device *dev = NULL;
  344. + XF86ConfOutputClassPtr cl;
  345. + XF86OptionPtr classopts;
  346. + int i = 0;
  347. +
  348. + switch (entity->bus.type) {
  349. + case BUS_PLATFORM:
  350. + dev = entity->bus.id.plat;
  351. + break;
  352. + case BUS_PCI:
  353. + for (i = 0; i < xf86_num_platform_devices; i++) {
  354. + if (MATCH_PCI_DEVICES(xf86_platform_devices[i].pdev,
  355. + entity->bus.id.pci)) {
  356. + dev = &xf86_platform_devices[i];
  357. + break;
  358. + }
  359. + }
  360. + break;
  361. + default:
  362. + xf86Msg(X_DEBUG, "xf86MergeOutputClassOptions unsupported bus type %d\n",
  363. + entity->bus.type);
  364. + }
  365. +
  366. + if (!dev)
  367. + return;
  368. +
  369. + for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) {
  370. + if (!OutputClassMatches(cl, dev) || !cl->option_lst)
  371. + continue;
  372. +
  373. + xf86Msg(X_INFO, "Applying OutputClass \"%s\" options to %s\n",
  374. + cl->identifier, dev->attribs->path);
  375. +
  376. + classopts = xf86optionListDup(cl->option_lst);
  377. + *options = xf86optionListMerge(*options, classopts);
  378. + }
  379. +}
  380. +
  381. static int
  382. xf86ClaimPlatformSlot(struct xf86_platform_device * d, DriverPtr drvp,
  383. int chipset, GDevPtr dev, Bool active)
  384. diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h
  385. index 0f5c0ef..70d9ec8 100644
  386. --- a/hw/xfree86/common/xf86platformBus.h
  387. +++ b/hw/xfree86/common/xf86platformBus.h
  388. @@ -42,6 +42,7 @@ struct xf86_platform_device {
  389. int xf86platformProbe(void);
  390. int xf86platformProbeDev(DriverPtr drvp);
  391. int xf86platformAddGPUDevices(DriverPtr drvp);
  392. +void xf86MergeOutputClassOptions(int entityIndex, void **options);
  393. extern int xf86_num_platform_devices;
  394. extern struct xf86_platform_device *xf86_platform_devices;
  395. @@ -161,6 +162,7 @@ extern void xf86platformPrimary(void);
  396. #else
  397. static inline int xf86platformAddGPUDevices(DriverPtr drvp) { return FALSE; }
  398. +static inline void xf86MergeOutputClassOptions(int index, void **options) {}
  399. #endif
  400. diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
  401. index 7d0c524..8928a53 100644
  402. --- a/hw/xfree86/man/xorg.conf.man
  403. +++ b/hw/xfree86/man/xorg.conf.man
  404. @@ -1280,6 +1280,16 @@ For example:
  405. Check the case-sensitive string
  406. .RI \*q matchdriver \*q
  407. against the kernel driver of the device.
  408. +.PP
  409. +When an output device has been matched to the
  410. +.B OutputClass
  411. +section, any
  412. +.B Option
  413. +entries are applied to the device. See the
  414. +.B Device
  415. +section below for a description of the remaining
  416. +.B Option
  417. +entries.
  418. .SH "DEVICE SECTION"
  419. The config file may have multiple
  420. .B Device
  421. diff --git a/hw/xfree86/parser/OutputClass.c b/hw/xfree86/parser/OutputClass.c
  422. index 8064e0c..f813ee6 100644
  423. --- a/hw/xfree86/parser/OutputClass.c
  424. +++ b/hw/xfree86/parser/OutputClass.c
  425. @@ -36,6 +36,7 @@ static const xf86ConfigSymTabRec OutputClassTab[] = {
  426. {ENDSECTION, "endsection"},
  427. {IDENTIFIER, "identifier"},
  428. {DRIVER, "driver"},
  429. + {OPTION, "option"},
  430. {MATCH_DRIVER, "matchdriver"},
  431. {-1, ""},
  432. };
  433. @@ -60,6 +61,8 @@ xf86freeOutputClassList(XF86ConfOutputClassPtr ptr)
  434. free(group);
  435. }
  436. + xf86optionListFree(ptr->option_lst);
  437. +
  438. prev = ptr;
  439. ptr = ptr->list.next;
  440. free(prev);
  441. @@ -112,6 +115,9 @@ xf86parseOutputClassSection(void)
  442. else
  443. ptr->driver = xf86_lex_val.str;
  444. break;
  445. + case OPTION:
  446. + ptr->option_lst = xf86parseOption(ptr->option_lst);
  447. + break;
  448. case MATCH_DRIVER:
  449. if (xf86getSubToken(&(ptr->comment)) != STRING)
  450. Error(QUOTE_MSG, "MatchDriver");
  451. diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
  452. index 9c4b403..897edab 100644
  453. --- a/hw/xfree86/parser/xf86Parser.h
  454. +++ b/hw/xfree86/parser/xf86Parser.h
  455. @@ -338,6 +338,7 @@ typedef struct {
  456. char *identifier;
  457. char *driver;
  458. struct xorg_list match_driver;
  459. + XF86OptionPtr option_lst;
  460. char *comment;
  461. } XF86ConfOutputClassRec, *XF86ConfOutputClassPtr;
  462. --
  463. 2.9.3
  464. From ab1a65b7755d081b41188104b21f4d21eaa3187b Mon Sep 17 00:00:00 2001
  465. From: Hans De Goede <hdegoede@redhat.com>
  466. Date: Mon, 12 Dec 2016 17:03:15 +0100
  467. Subject: [PATCH xserver 4/6] xfree86: xf86platformProbe: split finding
  468. pci-info and setting primary GPU
  469. This is a preparation patch for allowing an OutputClass section to
  470. override the default primary GPU device selection.
  471. Reviewed-by: Adam Jackson <ajax@redhat.com>
  472. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  473. ---
  474. hw/xfree86/common/xf86platformBus.c | 23 +++++++++++++++--------
  475. 1 file changed, 15 insertions(+), 8 deletions(-)
  476. diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
  477. index a698c6c..39b3248 100644
  478. --- a/hw/xfree86/common/xf86platformBus.c
  479. +++ b/hw/xfree86/common/xf86platformBus.c
  480. @@ -145,16 +145,9 @@ platform_find_pci_info(struct xf86_platform_device *pd, char *busid)
  481. iter = pci_slot_match_iterator_create(&devmatch);
  482. info = pci_device_next(iter);
  483. - if (info) {
  484. + if (info)
  485. pd->pdev = info;
  486. - pci_device_probe(info);
  487. - if (pci_device_is_boot_vga(info)) {
  488. - primaryBus.type = BUS_PLATFORM;
  489. - primaryBus.id.plat = pd;
  490. - }
  491. - }
  492. pci_iterator_destroy(iter);
  493. -
  494. }
  495. static Bool
  496. @@ -307,6 +300,20 @@ xf86platformProbe(void)
  497. platform_find_pci_info(&xf86_platform_devices[i], busid);
  498. }
  499. }
  500. +
  501. + for (i = 0; i < xf86_num_platform_devices; i++) {
  502. + struct xf86_platform_device *dev = &xf86_platform_devices[i];
  503. +
  504. + if (!dev->pdev)
  505. + continue;
  506. +
  507. + pci_device_probe(dev->pdev);
  508. + if (pci_device_is_boot_vga(dev->pdev)) {
  509. + primaryBus.type = BUS_PLATFORM;
  510. + primaryBus.id.plat = dev;
  511. + }
  512. + }
  513. +
  514. return 0;
  515. }
  516. --
  517. 2.9.3
  518. From d75ffcdbf8c1e3c8e0d46debcd533a9f2560f0a8 Mon Sep 17 00:00:00 2001
  519. From: Hans De Goede <hdegoede@redhat.com>
  520. Date: Mon, 12 Dec 2016 17:03:16 +0100
  521. Subject: [PATCH xserver 5/6] xfree86: Allow overriding primary GPU detection
  522. from an OutputClass section
  523. Allow using:
  524. Option "PrimaryGPU" "yes"
  525. In an OutputClass section to override the default primary GPU device
  526. selection which selects the GPU used as output by the firmware.
  527. If multiple output devices match an OutputClass section with
  528. the PrimaryGPU option set, the first one enumerated becomes the
  529. primary GPU.
  530. Reviewed-by: Adam Jackson <ajax@redhat.com>
  531. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  532. ---
  533. hw/xfree86/common/xf86platformBus.c | 19 +++++++++++++++++++
  534. hw/xfree86/man/xorg.conf.man | 12 +++++++++++-
  535. 2 files changed, 30 insertions(+), 1 deletion(-)
  536. diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
  537. index 39b3248..fc17d15 100644
  538. --- a/hw/xfree86/common/xf86platformBus.c
  539. +++ b/hw/xfree86/common/xf86platformBus.c
  540. @@ -286,6 +286,7 @@ xf86platformProbe(void)
  541. {
  542. int i;
  543. Bool pci = TRUE;
  544. + XF86ConfOutputClassPtr cl;
  545. config_odev_probe(xf86PlatformDeviceProbe);
  546. @@ -301,6 +302,24 @@ xf86platformProbe(void)
  547. }
  548. }
  549. + /* First see if there is an OutputClass match marking a device as primary */
  550. + for (i = 0; i < xf86_num_platform_devices; i++) {
  551. + struct xf86_platform_device *dev = &xf86_platform_devices[i];
  552. + for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) {
  553. + if (!OutputClassMatches(cl, dev))
  554. + continue;
  555. +
  556. + if (xf86CheckBoolOption(cl->option_lst, "PrimaryGPU", FALSE)) {
  557. + xf86Msg(X_CONFIG, "OutputClass \"%s\" setting %s as PrimaryGPU\n",
  558. + cl->identifier, dev->attribs->path);
  559. + primaryBus.type = BUS_PLATFORM;
  560. + primaryBus.id.plat = dev;
  561. + return 0;
  562. + }
  563. + }
  564. + }
  565. +
  566. + /* Then check for pci_device_is_boot_vga() */
  567. for (i = 0; i < xf86_num_platform_devices; i++) {
  568. struct xf86_platform_device *dev = &xf86_platform_devices[i];
  569. diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
  570. index 8928a53..79b71a8 100644
  571. --- a/hw/xfree86/man/xorg.conf.man
  572. +++ b/hw/xfree86/man/xorg.conf.man
  573. @@ -1285,11 +1285,21 @@ When an output device has been matched to the
  574. .B OutputClass
  575. section, any
  576. .B Option
  577. -entries are applied to the device. See the
  578. +entries are applied to the device. One
  579. +.B OutputClass
  580. +specific
  581. +.B Option
  582. +is recognized. See the
  583. .B Device
  584. section below for a description of the remaining
  585. .B Option
  586. entries.
  587. +.TP 7
  588. +.BI "Option \*qPrimaryGPU\*q \*q" boolean \*q
  589. +This option specifies that the matched device should be treated as the
  590. +primary GPU, replacing the selection of the GPU used as output by the
  591. +firmware. If multiple output devices match an OutputClass section with
  592. +the PrimaryGPU option set, the first one enumerated becomes the primary GPU.
  593. .SH "DEVICE SECTION"
  594. The config file may have multiple
  595. .B Device
  596. --
  597. 2.9.3
  598. From b5dffbbac193aa640ffcfa0a431c21b862854e53 Mon Sep 17 00:00:00 2001
  599. From: Hans De Goede <hdegoede@redhat.com>
  600. Date: Mon, 12 Dec 2016 17:03:17 +0100
  601. Subject: [PATCH xserver 6/6] xfree86: Add ModulePath support for OutputClass
  602. config Sections
  603. Allow OutputClass config snippets to modify the module-path.
  604. Note that any specified ModulePaths will be pre-pended to the normal
  605. ModulePath. The idea behind this is that any output hardware specific
  606. modules should have preference over the normal modules.
  607. One use-case for this is the nvidia binary driver, this allows a
  608. config snippet like this:
  609. Section "OutputClass"
  610. MatchDriver "nvidia"
  611. Modulepath "/usr/lib64/nvidia/modules"
  612. EndSection
  613. To get the nvidia glx specific glx module loaded, but only when the
  614. nvidia kernel driver is loaded.
  615. Together with the glvnd work done recently, this allows the nouveau
  616. + mesa and nvidia-binary userspace stacks to co-exist on the same
  617. system without any ldconfig / xorg.conf tweaking and the xserver will
  618. automatically do the right thing depending on which kernel driver
  619. (nouveau or nvidia) is loaded.
  620. Reviewed-by: Adam Jackson <ajax@redhat.com>
  621. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  622. ---
  623. hw/xfree86/common/xf86platformBus.c | 23 +++++++++++++++++++++++
  624. hw/xfree86/loader/loadmod.c | 1 +
  625. hw/xfree86/man/xorg.conf.man | 16 ++++++++++++++++
  626. hw/xfree86/parser/OutputClass.c | 15 +++++++++++++++
  627. hw/xfree86/parser/xf86Parser.h | 1 +
  628. 5 files changed, 56 insertions(+)
  629. diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
  630. index fc17d15..0b5795f 100644
  631. --- a/hw/xfree86/common/xf86platformBus.c
  632. +++ b/hw/xfree86/common/xf86platformBus.c
  633. @@ -40,6 +40,7 @@
  634. #include "hotplug.h"
  635. #include "systemd-logind.h"
  636. +#include "loaderProcs.h"
  637. #include "xf86.h"
  638. #include "xf86_OSproc.h"
  639. #include "xf86Priv.h"
  640. @@ -287,6 +288,7 @@ xf86platformProbe(void)
  641. int i;
  642. Bool pci = TRUE;
  643. XF86ConfOutputClassPtr cl;
  644. + char *old_path, *path = NULL;
  645. config_odev_probe(xf86PlatformDeviceProbe);
  646. @@ -300,8 +302,29 @@ xf86platformProbe(void)
  647. if (pci && (strncmp(busid, "pci:", 4) == 0)) {
  648. platform_find_pci_info(&xf86_platform_devices[i], busid);
  649. }
  650. +
  651. + /*
  652. + * Deal with OutputClass ModulePath directives, these must be
  653. + * processed before we do any module loading.
  654. + */
  655. + for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) {
  656. + if (!OutputClassMatches(cl, &xf86_platform_devices[i]))
  657. + continue;
  658. +
  659. + if (cl->modulepath && xf86ModPathFrom != X_CMDLINE) {
  660. + old_path = path;
  661. + XNFasprintf(&path, "%s,%s", cl->modulepath,
  662. + path ? path : xf86ModulePath);
  663. + free(old_path);
  664. + xf86Msg(X_CONFIG, "OutputClass \"%s\" ModulePath extended to \"%s\"\n",
  665. + cl->identifier, path);
  666. + LoaderSetPath(path);
  667. + }
  668. + }
  669. }
  670. + free(path);
  671. +
  672. /* First see if there is an OutputClass match marking a device as primary */
  673. for (i = 0; i < xf86_num_platform_devices; i++) {
  674. struct xf86_platform_device *dev = &xf86_platform_devices[i];
  675. diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
  676. index 8bf6836..940f5fc 100644
  677. --- a/hw/xfree86/loader/loadmod.c
  678. +++ b/hw/xfree86/loader/loadmod.c
  679. @@ -184,6 +184,7 @@ LoaderSetPath(const char *path)
  680. if (!path)
  681. return;
  682. + FreeStringList(defaultPathList);
  683. defaultPathList = InitPathList(path);
  684. }
  685. diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
  686. index 79b71a8..00ebf56 100644
  687. --- a/hw/xfree86/man/xorg.conf.man
  688. +++ b/hw/xfree86/man/xorg.conf.man
  689. @@ -1300,6 +1300,22 @@ This option specifies that the matched device should be treated as the
  690. primary GPU, replacing the selection of the GPU used as output by the
  691. firmware. If multiple output devices match an OutputClass section with
  692. the PrimaryGPU option set, the first one enumerated becomes the primary GPU.
  693. +.PP
  694. +A
  695. +.B OutputClass
  696. +Section may contain
  697. +.B ModulePath
  698. +entries. When an output device matches an
  699. +.B OutputClass
  700. +section, any
  701. +.B ModulePath
  702. +entries in that
  703. +.B OutputClass
  704. +are pre-pended to the search path for loadable Xorg server modules. See
  705. +.B ModulePath
  706. +in the
  707. +.B Files
  708. +section for more info.
  709. .SH "DEVICE SECTION"
  710. The config file may have multiple
  711. .B Device
  712. diff --git a/hw/xfree86/parser/OutputClass.c b/hw/xfree86/parser/OutputClass.c
  713. index f813ee6..01b348f 100644
  714. --- a/hw/xfree86/parser/OutputClass.c
  715. +++ b/hw/xfree86/parser/OutputClass.c
  716. @@ -36,6 +36,7 @@ static const xf86ConfigSymTabRec OutputClassTab[] = {
  717. {ENDSECTION, "endsection"},
  718. {IDENTIFIER, "identifier"},
  719. {DRIVER, "driver"},
  720. + {MODULEPATH, "modulepath"},
  721. {OPTION, "option"},
  722. {MATCH_DRIVER, "matchdriver"},
  723. {-1, ""},
  724. @@ -53,6 +54,7 @@ xf86freeOutputClassList(XF86ConfOutputClassPtr ptr)
  725. TestFree(ptr->identifier);
  726. TestFree(ptr->comment);
  727. TestFree(ptr->driver);
  728. + TestFree(ptr->modulepath);
  729. xorg_list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
  730. xorg_list_del(&group->entry);
  731. @@ -115,6 +117,19 @@ xf86parseOutputClassSection(void)
  732. else
  733. ptr->driver = xf86_lex_val.str;
  734. break;
  735. + case MODULEPATH:
  736. + if (xf86getSubToken(&(ptr->comment)) != STRING)
  737. + Error(QUOTE_MSG, "ModulePath");
  738. + if (ptr->modulepath) {
  739. + char *path;
  740. + XNFasprintf(&path, "%s,%s", ptr->modulepath, xf86_lex_val.str);
  741. + free(xf86_lex_val.str);
  742. + free(ptr->modulepath);
  743. + ptr->modulepath = path;
  744. + } else {
  745. + ptr->modulepath = xf86_lex_val.str;
  746. + }
  747. + break;
  748. case OPTION:
  749. ptr->option_lst = xf86parseOption(ptr->option_lst);
  750. break;
  751. diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
  752. index 897edab..e014048 100644
  753. --- a/hw/xfree86/parser/xf86Parser.h
  754. +++ b/hw/xfree86/parser/xf86Parser.h
  755. @@ -337,6 +337,7 @@ typedef struct {
  756. GenericListRec list;
  757. char *identifier;
  758. char *driver;
  759. + char *modulepath;
  760. struct xorg_list match_driver;
  761. XF86OptionPtr option_lst;
  762. char *comment;
  763. --
  764. 2.9.3