Mir

Merge lp:~afrantzis/mir/android-gralloc-can-be-safely-closed-quirk into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 3124
Proposed branch: lp:~afrantzis/mir/android-gralloc-can-be-safely-closed-quirk
Merge into: lp:mir
Diff against target: 208 lines (+35/-30)
4 files modified
src/platforms/android/server/android_buffer_allocator.cpp (+15/-10)
src/platforms/android/server/device_quirks.cpp (+9/-9)
src/platforms/android/server/device_quirks.h (+2/-2)
tests/unit-tests/graphics/android/test_device_detection.cpp (+9/-9)
To merge this branch: bzr merge lp:~afrantzis/mir/android-gralloc-can-be-safely-closed-quirk
Reviewer Review Type Date Requested Status
Andreas Pokorny (community) Approve
Kevin DuBois (community) Approve
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+278563@code.launchpad.net

Commit message

android: Don't close gralloc if it's not safe to do so on particular devices

Description of the change

android: Don't close gralloc if it's not safe to do so on particular devices

Based on the success of the experimental branch [1], this branch applies the same workaround (don't close gralloc) as a quirk for krillin.

[1] See https://code.launchpad.net/~afrantzis/mir/ci-failure-experiment-1/+merge/278344
and also additional manually triggered runs of the test runner which were all successful: https://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7508/
https://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7509/
https://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7510/

To post a comment you must log in.
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: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I'd prefer more optimistic phrasing than "gralloc_can_be_safely_closed()". Vis: "gralloc_cannot_be_closed_safely()" but if it works...

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

I'm ambivalent about the name. Its unfortunate we need a quirk like this, but barring support from the driver vendor, its the best we can do.

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

no strong opinion on either of the names (negation vs api-intentions)

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

> Vis: "gralloc_cannot_be_closed_safely()" but if it works...

Renamed.

I also scheduled some manual runner jobs, which were successful:

https://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7513/
https://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7514/
https://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7515/

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

I wonder if well need this on vegetahd as well...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/android/server/android_buffer_allocator.cpp'
2--- src/platforms/android/server/android_buffer_allocator.cpp 2015-08-07 15:55:22 +0000
3+++ src/platforms/android/server/android_buffer_allocator.cpp 2015-11-25 12:59:55 +0000
4@@ -25,6 +25,7 @@
5 #include "android_graphic_buffer_allocator.h"
6 #include "android_alloc_adaptor.h"
7 #include "buffer.h"
8+#include "device_quirks.h"
9
10 #include <boost/throw_exception.hpp>
11
12@@ -36,14 +37,17 @@
13
14 namespace
15 {
16-struct AllocDevDeleter
17-{
18- void operator()(alloc_device_t* t)
19- {
20- /* android takes care of delete for us */
21- t->common.close((hw_device_t*)t);
22- }
23-};
24+
25+void alloc_dev_deleter(alloc_device_t* t)
26+{
27+ /* android takes care of delete for us */
28+ t->common.close((hw_device_t*)t);
29+}
30+
31+void null_alloc_dev_deleter(alloc_device_t*)
32+{
33+}
34+
35 }
36
37 mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks)
38@@ -63,8 +67,9 @@
39 /* note for future use: at this point, the hardware module should be filled with vendor information
40 that we can determine different courses of action based upon */
41
42- AllocDevDeleter del;
43- std::shared_ptr<struct alloc_device_t> alloc_dev_ptr(alloc_dev, del);
44+ std::shared_ptr<struct alloc_device_t> alloc_dev_ptr(
45+ alloc_dev,
46+ quirks->gralloc_cannot_be_closed_safely() ? null_alloc_dev_deleter : alloc_dev_deleter);
47 alloc_device = std::shared_ptr<mga::GraphicAllocAdaptor>(new AndroidAllocAdaptor(alloc_dev_ptr, quirks));
48 }
49
50
51=== modified file 'src/platforms/android/server/device_quirks.cpp'
52--- src/platforms/android/server/device_quirks.cpp 2015-06-24 11:33:02 +0000
53+++ src/platforms/android/server/device_quirks.cpp 2015-11-25 12:59:55 +0000
54@@ -35,7 +35,7 @@
55 namespace
56 {
57 char const* const num_framebuffers_opt = "enable-num-framebuffers-quirk";
58-char const* const single_gralloc_instance_opt = "enable-single-gralloc-instance-quirk";
59+char const* const gralloc_cannot_be_closed_safely_opt = "enable-gralloc-cannot-be-closed-safely-quirk";
60 char const* const width_alignment_opt = "enable-width-alignment-quirk";
61
62 std::string determine_device_name(mga::PropertiesWrapper const& properties)
63@@ -55,16 +55,16 @@
64 return 2;
65 }
66
67-unsigned int gralloc_reopenable_after_close_for(std::string const& device_name, bool quirk_enabled)
68+bool gralloc_cannot_be_closed_safely_for(std::string const& device_name, bool quirk_enabled)
69 {
70- return !(quirk_enabled && device_name == std::string{"krillin"});
71+ return quirk_enabled && device_name == std::string{"krillin"};
72 }
73 }
74
75 mga::DeviceQuirks::DeviceQuirks(PropertiesWrapper const& properties)
76 : device_name(determine_device_name(properties)),
77 num_framebuffers_(num_framebuffers_for(device_name, true)),
78- gralloc_reopenable_after_close_(gralloc_reopenable_after_close_for(device_name, true)),
79+ gralloc_cannot_be_closed_safely_(gralloc_cannot_be_closed_safely_for(device_name, true)),
80 enable_width_alignment_quirk{true}
81 {
82 }
83@@ -72,7 +72,7 @@
84 mga::DeviceQuirks::DeviceQuirks(PropertiesWrapper const& properties, mo::Option const& options)
85 : device_name(determine_device_name(properties)),
86 num_framebuffers_(num_framebuffers_for(device_name, options.get(num_framebuffers_opt, true))),
87- gralloc_reopenable_after_close_(gralloc_reopenable_after_close_for(device_name, options.get(single_gralloc_instance_opt, true))),
88+ gralloc_cannot_be_closed_safely_(gralloc_cannot_be_closed_safely_for(device_name, options.get(gralloc_cannot_be_closed_safely_opt, true))),
89 enable_width_alignment_quirk(options.get(width_alignment_opt, true))
90 {
91 }
92@@ -82,9 +82,9 @@
93 return num_framebuffers_;
94 }
95
96-bool mga::DeviceQuirks::gralloc_reopenable_after_close() const
97+bool mga::DeviceQuirks::gralloc_cannot_be_closed_safely() const
98 {
99- return gralloc_reopenable_after_close_;
100+ return gralloc_cannot_be_closed_safely_;
101 }
102
103 int mga::DeviceQuirks::aligned_width(int width) const
104@@ -100,9 +100,9 @@
105 (num_framebuffers_opt,
106 boost::program_options::value<bool>()->default_value(true),
107 "[platform-specific] Enable allocating 3 framebuffers (MX3 quirk) [{true,false}]")
108- (single_gralloc_instance_opt,
109+ (gralloc_cannot_be_closed_safely_opt,
110 boost::program_options::value<bool>()->default_value(true),
111- "[platform-specific] Allocate a single gralloc instance (krillin quirk) [{true,false}]")
112+ "[platform-specific] Only close gralloc if it is safe to do so (krillin quirk) [{true,false}]")
113 (width_alignment_opt,
114 boost::program_options::value<bool>()->default_value(true),
115 "[platform-specific] Enable width alignment (vegetahd quirk) [{true,false}]");
116
117=== modified file 'src/platforms/android/server/device_quirks.h'
118--- src/platforms/android/server/device_quirks.h 2015-06-24 11:33:02 +0000
119+++ src/platforms/android/server/device_quirks.h 2015-11-25 12:59:55 +0000
120@@ -61,7 +61,7 @@
121 DeviceQuirks(PropertiesWrapper const& properties, mir::options::Option const& options);
122
123 unsigned int num_framebuffers() const;
124- bool gralloc_reopenable_after_close() const;
125+ bool gralloc_cannot_be_closed_safely() const;
126 int aligned_width(int width) const;
127
128 static void add_options(boost::program_options::options_description& config);
129@@ -71,7 +71,7 @@
130 DeviceQuirks & operator=(DeviceQuirks const&) = delete;
131 std::string const device_name;
132 unsigned int const num_framebuffers_;
133- bool const gralloc_reopenable_after_close_;
134+ bool const gralloc_cannot_be_closed_safely_;
135 bool const enable_width_alignment_quirk;
136 };
137 }
138
139=== modified file 'tests/unit-tests/graphics/android/test_device_detection.cpp'
140--- tests/unit-tests/graphics/android/test_device_detection.cpp 2015-06-24 11:33:02 +0000
141+++ tests/unit-tests/graphics/android/test_device_detection.cpp 2015-11-25 12:59:55 +0000
142@@ -75,7 +75,7 @@
143 }
144
145 //LP: 1371619, 1370555
146-TEST(DeviceDetection, reports_gralloc_reopenable_after_close_by_default)
147+TEST(DeviceDetection, reports_gralloc_can_be_closed_safely_by_default)
148 {
149 using namespace testing;
150 char const default_str[] = "";
151@@ -91,10 +91,10 @@
152 }));
153
154 mga::DeviceQuirks quirks(mock_ops);
155- EXPECT_TRUE(quirks.gralloc_reopenable_after_close());
156+ EXPECT_FALSE(quirks.gralloc_cannot_be_closed_safely());
157 }
158
159-TEST(DeviceDetection, reports_gralloc_not_reopenable_after_close_on_krillin)
160+TEST(DeviceDetection, reports_gralloc_cannot_be_closed_safely_on_krillin)
161 {
162 using namespace testing;
163 char const default_str[] = "";
164@@ -110,7 +110,7 @@
165 }));
166
167 mga::DeviceQuirks quirks(mock_ops);
168- EXPECT_FALSE(quirks.gralloc_reopenable_after_close());
169+ EXPECT_TRUE(quirks.gralloc_cannot_be_closed_safely());
170 }
171
172 TEST(DeviceDetection, aligns_width_on_vegetahd)
173@@ -150,12 +150,12 @@
174 options.parse_arguments(desc, argc, argv);
175 }
176
177- void disable_single_gralloc_instance_quirk()
178+ void disable_gralloc_cannot_be_closed_safely_quirk()
179 {
180 int const argc = 2;
181 char const* argv[argc] = {
182 __PRETTY_FUNCTION__,
183- "--enable-single-gralloc-instance-quirk=false"
184+ "--enable-gralloc-cannot-be-closed-safely-quirk=false"
185 };
186
187 options.parse_arguments(desc, argc, argv);
188@@ -197,7 +197,7 @@
189 EXPECT_THAT(quirks.num_framebuffers(), Ne(3));
190 }
191
192-TEST_F(DeviceQuirks, single_gralloc_instance_quirk_can_be_disabled)
193+TEST_F(DeviceQuirks, gralloc_cannot_be_closed_safely_quirk_can_be_disabled)
194 {
195 using namespace testing;
196 char const default_str[] = "";
197@@ -212,9 +212,9 @@
198 return 0;
199 }));
200
201- disable_single_gralloc_instance_quirk();
202+ disable_gralloc_cannot_be_closed_safely_quirk();
203 mga::DeviceQuirks quirks(mock_ops, options);
204- EXPECT_TRUE(quirks.gralloc_reopenable_after_close());
205+ EXPECT_FALSE(quirks.gralloc_cannot_be_closed_safely());
206 }
207
208 TEST_F(DeviceQuirks, width_alignment_quirk_can_be_disabled)

Subscribers

People subscribed via source and target branches