Mir

Merge lp:~cemil-azizoglu/mir/more-accurate-probing into lp:mir

Proposed by Cemil Azizoglu
Status: Merged
Approved by: Cemil Azizoglu
Approved revision: no longer in the source branch.
Merged at revision: 3098
Proposed branch: lp:~cemil-azizoglu/mir/more-accurate-probing
Merge into: lp:mir
Diff against target: 140 lines (+36/-11)
5 files modified
src/platforms/mesa/server/kms/platform_symbols.cpp (+21/-3)
src/platforms/mesa/server/x11/graphics/graphics.cpp (+1/-1)
tests/unit-tests/graphics/mesa/kms/test_platform.cpp (+2/-2)
tests/unit-tests/graphics/mesa/x11/test_platform.cpp (+2/-2)
tests/unit-tests/graphics/test_platform_prober.cpp (+10/-3)
To merge this branch: bzr merge lp:~cemil-azizoglu/mir/more-accurate-probing
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andreas Pokorny (community) Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Review via email: mp+276825@code.launchpad.net

Commit message

Tighten probing rules

Description of the change

Tighten probing rules to better differentiate between mir-on-x and kms platforms by using the ability to become 'master'.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I'm not convinced that checking explicitly for an option used by a different platform scales well.

I assume checking for options not recognized by /this/ platform would give false positives by detecting options used by downstreams (I'm looking at you U8) that don't use Mir's boost.Options support.

Could we instead add a bonus to our PlatformPriority score for seeing options we recognize? (So, in this case, mesa-kms would "win" if it sees --vt.)

review: Needs Information
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> I'm not convinced that checking explicitly for an option used by a different platform scales well.
...
> Could we instead add a bonus to our PlatformPriority score for seeing options we recognize? (So, in > this case, mesa-kms would "win" if it sees --vt.)

+1

Revision history for this message
Chris Halse Rogers (raof) wrote :

Yeah, either give a boost for platforms that understand the option or have a filter at the platform load stage that only loads platforms that understand the options.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Needs Information: If the caller has insufficient rights, the call to drmSetMaster will fail.That way it would be a lot harder to lock yourself out when launching a mir_demo_server. Unless of course someone specifies the platform on command line and bypasses probing entirely.

If so I would move the drmMaster above the platform option check - or as proposed above change the early return into += x of the probing result.

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

+ const char *argv[] = {"dummy", "--vt"};
+ options.parse_arguments(po, 2, argv);

These are not needed for any of the existing tests and also skew the results since they include a platform specific argument.

TEST_F(ServerPlatformProbeMockDRM, LoadsMesaPlatformWhenDrmDevicePresent)

The test name is now misleading. This should be renamed to LoadsMesaPlatformWhenDrmMasterCanBeAcquired or similar.

review: Needs Fixing
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

yes

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/platforms/mesa/server/kms/platform_symbols.cpp'
--- src/platforms/mesa/server/kms/platform_symbols.cpp 2015-11-04 07:43:28 +0000
+++ src/platforms/mesa/server/kms/platform_symbols.cpp 2015-11-10 15:26:16 +0000
@@ -164,15 +164,33 @@
164 drm_devices.match_sysname("card[0-9]*");164 drm_devices.match_sysname("card[0-9]*");
165 drm_devices.scan_devices();165 drm_devices.scan_devices();
166166
167 if (drm_devices.begin() == drm_devices.end())
168 return mg::PlatformPriority::unsupported;
169
170 // Check for master
171 int tmp_fd = -1;
167 for (auto& device : drm_devices)172 for (auto& device : drm_devices)
168 {173 {
169 static_cast<void>(device);174 tmp_fd = open(device.devnode(), O_RDWR | O_CLOEXEC);
170 if (platform_option_used)175 if (tmp_fd >= 0)
176 break;
177 }
178
179 if (tmp_fd >= 0)
180 {
181 if (drmSetMaster(tmp_fd) >= 0)
182 {
183 drmDropMaster(tmp_fd);
184 drmClose(tmp_fd);
171 return mg::PlatformPriority::best;185 return mg::PlatformPriority::best;
186 }
172 else187 else
173 return mg::PlatformPriority::supported;188 drmClose(tmp_fd);
174 }189 }
175190
191 if (platform_option_used)
192 return mg::PlatformPriority::best;
193
176 return mg::PlatformPriority::unsupported;194 return mg::PlatformPriority::unsupported;
177}195}
178196
179197
=== modified file 'src/platforms/mesa/server/x11/graphics/graphics.cpp'
--- src/platforms/mesa/server/x11/graphics/graphics.cpp 2015-11-04 07:43:28 +0000
+++ src/platforms/mesa/server/x11/graphics/graphics.cpp 2015-11-10 15:26:16 +0000
@@ -86,7 +86,7 @@
86 drm_devices.scan_devices();86 drm_devices.scan_devices();
8787
88 if (drm_devices.begin() != drm_devices.end())88 if (drm_devices.begin() != drm_devices.end())
89 return mg::PlatformPriority::best;89 return mg::PlatformPriority::supported;
90 }90 }
91 return mg::PlatformPriority::unsupported;91 return mg::PlatformPriority::unsupported;
92}92}
9393
=== modified file 'tests/unit-tests/graphics/mesa/kms/test_platform.cpp'
--- tests/unit-tests/graphics/mesa/kms/test_platform.cpp 2015-11-09 11:13:52 +0000
+++ tests/unit-tests/graphics/mesa/kms/test_platform.cpp 2015-11-10 15:26:16 +0000
@@ -319,7 +319,7 @@
319 EXPECT_EQ(mg::PlatformPriority::unsupported, probe(options));319 EXPECT_EQ(mg::PlatformPriority::unsupported, probe(options));
320}320}
321321
322TEST_F(MesaGraphicsPlatform, probe_returns_supported_when_drm_devices_exist)322TEST_F(MesaGraphicsPlatform, probe_returns_best_when_master)
323{323{
324 mtf::UdevEnvironment udev_environment;324 mtf::UdevEnvironment udev_environment;
325 boost::program_options::options_description po;325 boost::program_options::options_description po;
@@ -329,7 +329,7 @@
329329
330 mir::SharedLibrary platform_lib{mtf::server_platform("graphics-mesa-kms")};330 mir::SharedLibrary platform_lib{mtf::server_platform("graphics-mesa-kms")};
331 auto probe = platform_lib.load_function<mg::PlatformProbe>(probe_platform);331 auto probe = platform_lib.load_function<mg::PlatformProbe>(probe_platform);
332 EXPECT_EQ(mg::PlatformPriority::supported, probe(options));332 EXPECT_EQ(mg::PlatformPriority::best, probe(options));
333}333}
334334
335TEST_F(MesaGraphicsPlatform, probe_returns_best_when_drm_devices_vt_option_exist)335TEST_F(MesaGraphicsPlatform, probe_returns_best_when_drm_devices_vt_option_exist)
336336
=== modified file 'tests/unit-tests/graphics/mesa/x11/test_platform.cpp'
--- tests/unit-tests/graphics/mesa/x11/test_platform.cpp 2015-09-30 23:50:10 +0000
+++ tests/unit-tests/graphics/mesa/x11/test_platform.cpp 2015-11-10 15:26:16 +0000
@@ -116,7 +116,7 @@
116 EXPECT_EQ(mg::PlatformPriority::unsupported, probe(options));116 EXPECT_EQ(mg::PlatformPriority::unsupported, probe(options));
117}117}
118118
119TEST_F(X11GraphicsPlatformTest, probe_returns_best_when_drm_render_nodes_exist)119TEST_F(X11GraphicsPlatformTest, probe_returns_supported_when_drm_render_nodes_exist)
120{120{
121 mtf::UdevEnvironment udev_environment;121 mtf::UdevEnvironment udev_environment;
122 mir::options::ProgramOption options;122 mir::options::ProgramOption options;
@@ -125,5 +125,5 @@
125125
126 mir::SharedLibrary platform_lib{mtf::server_platform("server-mesa-x11")};126 mir::SharedLibrary platform_lib{mtf::server_platform("server-mesa-x11")};
127 auto probe = platform_lib.load_function<mg::PlatformProbe>(probe_platform);127 auto probe = platform_lib.load_function<mg::PlatformProbe>(probe_platform);
128 EXPECT_EQ(mg::PlatformPriority::best, probe(options));128 EXPECT_EQ(mg::PlatformPriority::supported, probe(options));
129}129}
130130
=== modified file 'tests/unit-tests/graphics/test_platform_prober.cpp'
--- tests/unit-tests/graphics/test_platform_prober.cpp 2015-09-30 19:34:21 +0000
+++ tests/unit-tests/graphics/test_platform_prober.cpp 2015-11-10 15:26:16 +0000
@@ -100,6 +100,13 @@
100 return std::shared_ptr<void>{};100 return std::shared_ptr<void>{};
101#endif101#endif
102}102}
103
104class ServerPlatformProbeMockDRM : public ::testing::Test
105{
106public:
107 ::testing::NiceMock<mtd::MockDRM> mock_drm;
108};
109
103}110}
104111
105TEST(ServerPlatformProbe, ConstructingWithNoModulesIsAnError)112TEST(ServerPlatformProbe, ConstructingWithNoModulesIsAnError)
@@ -112,7 +119,7 @@
112}119}
113120
114#ifdef MIR_BUILD_PLATFORM_MESA_KMS121#ifdef MIR_BUILD_PLATFORM_MESA_KMS
115TEST(ServerPlatformProbe, LoadsMesaPlatformWhenDrmDevicePresent)122TEST_F(ServerPlatformProbeMockDRM, LoadsMesaPlatformWhenDrmMasterCanBeAcquired)
116{123{
117 using namespace testing;124 using namespace testing;
118 mir::options::ProgramOption options;125 mir::options::ProgramOption options;
@@ -183,7 +190,7 @@
183}190}
184191
185#if defined(MIR_BUILD_PLATFORM_MESA_KMS) || defined(MIR_BUILD_PLATFORM_MESA_X11) || defined(MIR_BUILD_PLATFORM_ANDROID)192#if defined(MIR_BUILD_PLATFORM_MESA_KMS) || defined(MIR_BUILD_PLATFORM_MESA_X11) || defined(MIR_BUILD_PLATFORM_ANDROID)
186TEST(ServerPlatformProbe, LoadsMesaOrAndroidInPreferenceToDummy)193TEST_F(ServerPlatformProbeMockDRM, LoadsMesaOrAndroidInPreferenceToDummy)
187{194{
188 using namespace testing;195 using namespace testing;
189 mir::options::ProgramOption options;196 mir::options::ProgramOption options;
@@ -203,7 +210,7 @@
203}210}
204#endif211#endif
205212
206TEST(ServerPlatformProbe, IgnoresNonPlatformModules)213TEST_F(ServerPlatformProbeMockDRM, IgnoresNonPlatformModules)
207{214{
208 using namespace testing;215 using namespace testing;
209 mir::options::ProgramOption options;216 mir::options::ProgramOption options;

Subscribers

People subscribed via source and target branches