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
=== modified file 'src/platforms/android/server/android_buffer_allocator.cpp'
--- src/platforms/android/server/android_buffer_allocator.cpp 2015-08-07 15:55:22 +0000
+++ src/platforms/android/server/android_buffer_allocator.cpp 2015-11-25 12:59:55 +0000
@@ -25,6 +25,7 @@
25#include "android_graphic_buffer_allocator.h"25#include "android_graphic_buffer_allocator.h"
26#include "android_alloc_adaptor.h"26#include "android_alloc_adaptor.h"
27#include "buffer.h"27#include "buffer.h"
28#include "device_quirks.h"
2829
29#include <boost/throw_exception.hpp>30#include <boost/throw_exception.hpp>
3031
@@ -36,14 +37,17 @@
3637
37namespace38namespace
38{39{
39struct AllocDevDeleter40
40{41void alloc_dev_deleter(alloc_device_t* t)
41 void operator()(alloc_device_t* t)42{
42 {43 /* android takes care of delete for us */
43 /* android takes care of delete for us */44 t->common.close((hw_device_t*)t);
44 t->common.close((hw_device_t*)t);45}
45 }46
46};47void null_alloc_dev_deleter(alloc_device_t*)
48{
49}
50
47}51}
4852
49mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks)53mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks)
@@ -63,8 +67,9 @@
63 /* note for future use: at this point, the hardware module should be filled with vendor information67 /* note for future use: at this point, the hardware module should be filled with vendor information
64 that we can determine different courses of action based upon */68 that we can determine different courses of action based upon */
6569
66 AllocDevDeleter del;70 std::shared_ptr<struct alloc_device_t> alloc_dev_ptr(
67 std::shared_ptr<struct alloc_device_t> alloc_dev_ptr(alloc_dev, del);71 alloc_dev,
72 quirks->gralloc_cannot_be_closed_safely() ? null_alloc_dev_deleter : alloc_dev_deleter);
68 alloc_device = std::shared_ptr<mga::GraphicAllocAdaptor>(new AndroidAllocAdaptor(alloc_dev_ptr, quirks));73 alloc_device = std::shared_ptr<mga::GraphicAllocAdaptor>(new AndroidAllocAdaptor(alloc_dev_ptr, quirks));
69}74}
7075
7176
=== modified file 'src/platforms/android/server/device_quirks.cpp'
--- src/platforms/android/server/device_quirks.cpp 2015-06-24 11:33:02 +0000
+++ src/platforms/android/server/device_quirks.cpp 2015-11-25 12:59:55 +0000
@@ -35,7 +35,7 @@
35namespace35namespace
36{36{
37char const* const num_framebuffers_opt = "enable-num-framebuffers-quirk";37char const* const num_framebuffers_opt = "enable-num-framebuffers-quirk";
38char const* const single_gralloc_instance_opt = "enable-single-gralloc-instance-quirk";38char const* const gralloc_cannot_be_closed_safely_opt = "enable-gralloc-cannot-be-closed-safely-quirk";
39char const* const width_alignment_opt = "enable-width-alignment-quirk";39char const* const width_alignment_opt = "enable-width-alignment-quirk";
4040
41std::string determine_device_name(mga::PropertiesWrapper const& properties)41std::string determine_device_name(mga::PropertiesWrapper const& properties)
@@ -55,16 +55,16 @@
55 return 2;55 return 2;
56}56}
5757
58unsigned int gralloc_reopenable_after_close_for(std::string const& device_name, bool quirk_enabled)58bool gralloc_cannot_be_closed_safely_for(std::string const& device_name, bool quirk_enabled)
59{59{
60 return !(quirk_enabled && device_name == std::string{"krillin"});60 return quirk_enabled && device_name == std::string{"krillin"};
61}61}
62}62}
6363
64mga::DeviceQuirks::DeviceQuirks(PropertiesWrapper const& properties)64mga::DeviceQuirks::DeviceQuirks(PropertiesWrapper const& properties)
65 : device_name(determine_device_name(properties)),65 : device_name(determine_device_name(properties)),
66 num_framebuffers_(num_framebuffers_for(device_name, true)),66 num_framebuffers_(num_framebuffers_for(device_name, true)),
67 gralloc_reopenable_after_close_(gralloc_reopenable_after_close_for(device_name, true)),67 gralloc_cannot_be_closed_safely_(gralloc_cannot_be_closed_safely_for(device_name, true)),
68 enable_width_alignment_quirk{true}68 enable_width_alignment_quirk{true}
69{69{
70}70}
@@ -72,7 +72,7 @@
72mga::DeviceQuirks::DeviceQuirks(PropertiesWrapper const& properties, mo::Option const& options)72mga::DeviceQuirks::DeviceQuirks(PropertiesWrapper const& properties, mo::Option const& options)
73 : device_name(determine_device_name(properties)),73 : device_name(determine_device_name(properties)),
74 num_framebuffers_(num_framebuffers_for(device_name, options.get(num_framebuffers_opt, true))),74 num_framebuffers_(num_framebuffers_for(device_name, options.get(num_framebuffers_opt, true))),
75 gralloc_reopenable_after_close_(gralloc_reopenable_after_close_for(device_name, options.get(single_gralloc_instance_opt, true))),75 gralloc_cannot_be_closed_safely_(gralloc_cannot_be_closed_safely_for(device_name, options.get(gralloc_cannot_be_closed_safely_opt, true))),
76 enable_width_alignment_quirk(options.get(width_alignment_opt, true))76 enable_width_alignment_quirk(options.get(width_alignment_opt, true))
77{77{
78}78}
@@ -82,9 +82,9 @@
82 return num_framebuffers_;82 return num_framebuffers_;
83}83}
8484
85bool mga::DeviceQuirks::gralloc_reopenable_after_close() const85bool mga::DeviceQuirks::gralloc_cannot_be_closed_safely() const
86{86{
87 return gralloc_reopenable_after_close_;87 return gralloc_cannot_be_closed_safely_;
88}88}
8989
90int mga::DeviceQuirks::aligned_width(int width) const90int mga::DeviceQuirks::aligned_width(int width) const
@@ -100,9 +100,9 @@
100 (num_framebuffers_opt,100 (num_framebuffers_opt,
101 boost::program_options::value<bool>()->default_value(true),101 boost::program_options::value<bool>()->default_value(true),
102 "[platform-specific] Enable allocating 3 framebuffers (MX3 quirk) [{true,false}]")102 "[platform-specific] Enable allocating 3 framebuffers (MX3 quirk) [{true,false}]")
103 (single_gralloc_instance_opt,103 (gralloc_cannot_be_closed_safely_opt,
104 boost::program_options::value<bool>()->default_value(true),104 boost::program_options::value<bool>()->default_value(true),
105 "[platform-specific] Allocate a single gralloc instance (krillin quirk) [{true,false}]")105 "[platform-specific] Only close gralloc if it is safe to do so (krillin quirk) [{true,false}]")
106 (width_alignment_opt,106 (width_alignment_opt,
107 boost::program_options::value<bool>()->default_value(true),107 boost::program_options::value<bool>()->default_value(true),
108 "[platform-specific] Enable width alignment (vegetahd quirk) [{true,false}]");108 "[platform-specific] Enable width alignment (vegetahd quirk) [{true,false}]");
109109
=== modified file 'src/platforms/android/server/device_quirks.h'
--- src/platforms/android/server/device_quirks.h 2015-06-24 11:33:02 +0000
+++ src/platforms/android/server/device_quirks.h 2015-11-25 12:59:55 +0000
@@ -61,7 +61,7 @@
61 DeviceQuirks(PropertiesWrapper const& properties, mir::options::Option const& options);61 DeviceQuirks(PropertiesWrapper const& properties, mir::options::Option const& options);
6262
63 unsigned int num_framebuffers() const;63 unsigned int num_framebuffers() const;
64 bool gralloc_reopenable_after_close() const;64 bool gralloc_cannot_be_closed_safely() const;
65 int aligned_width(int width) const;65 int aligned_width(int width) const;
6666
67 static void add_options(boost::program_options::options_description& config);67 static void add_options(boost::program_options::options_description& config);
@@ -71,7 +71,7 @@
71 DeviceQuirks & operator=(DeviceQuirks const&) = delete;71 DeviceQuirks & operator=(DeviceQuirks const&) = delete;
72 std::string const device_name;72 std::string const device_name;
73 unsigned int const num_framebuffers_;73 unsigned int const num_framebuffers_;
74 bool const gralloc_reopenable_after_close_;74 bool const gralloc_cannot_be_closed_safely_;
75 bool const enable_width_alignment_quirk;75 bool const enable_width_alignment_quirk;
76};76};
77}77}
7878
=== modified file 'tests/unit-tests/graphics/android/test_device_detection.cpp'
--- tests/unit-tests/graphics/android/test_device_detection.cpp 2015-06-24 11:33:02 +0000
+++ tests/unit-tests/graphics/android/test_device_detection.cpp 2015-11-25 12:59:55 +0000
@@ -75,7 +75,7 @@
75}75}
7676
77//LP: 1371619, 137055577//LP: 1371619, 1370555
78TEST(DeviceDetection, reports_gralloc_reopenable_after_close_by_default)78TEST(DeviceDetection, reports_gralloc_can_be_closed_safely_by_default)
79{79{
80 using namespace testing;80 using namespace testing;
81 char const default_str[] = "";81 char const default_str[] = "";
@@ -91,10 +91,10 @@
91 }));91 }));
9292
93 mga::DeviceQuirks quirks(mock_ops);93 mga::DeviceQuirks quirks(mock_ops);
94 EXPECT_TRUE(quirks.gralloc_reopenable_after_close());94 EXPECT_FALSE(quirks.gralloc_cannot_be_closed_safely());
95}95}
9696
97TEST(DeviceDetection, reports_gralloc_not_reopenable_after_close_on_krillin)97TEST(DeviceDetection, reports_gralloc_cannot_be_closed_safely_on_krillin)
98{98{
99 using namespace testing;99 using namespace testing;
100 char const default_str[] = "";100 char const default_str[] = "";
@@ -110,7 +110,7 @@
110 }));110 }));
111111
112 mga::DeviceQuirks quirks(mock_ops);112 mga::DeviceQuirks quirks(mock_ops);
113 EXPECT_FALSE(quirks.gralloc_reopenable_after_close());113 EXPECT_TRUE(quirks.gralloc_cannot_be_closed_safely());
114}114}
115115
116TEST(DeviceDetection, aligns_width_on_vegetahd)116TEST(DeviceDetection, aligns_width_on_vegetahd)
@@ -150,12 +150,12 @@
150 options.parse_arguments(desc, argc, argv);150 options.parse_arguments(desc, argc, argv);
151 }151 }
152152
153 void disable_single_gralloc_instance_quirk()153 void disable_gralloc_cannot_be_closed_safely_quirk()
154 {154 {
155 int const argc = 2;155 int const argc = 2;
156 char const* argv[argc] = {156 char const* argv[argc] = {
157 __PRETTY_FUNCTION__,157 __PRETTY_FUNCTION__,
158 "--enable-single-gralloc-instance-quirk=false"158 "--enable-gralloc-cannot-be-closed-safely-quirk=false"
159 };159 };
160160
161 options.parse_arguments(desc, argc, argv);161 options.parse_arguments(desc, argc, argv);
@@ -197,7 +197,7 @@
197 EXPECT_THAT(quirks.num_framebuffers(), Ne(3));197 EXPECT_THAT(quirks.num_framebuffers(), Ne(3));
198}198}
199199
200TEST_F(DeviceQuirks, single_gralloc_instance_quirk_can_be_disabled)200TEST_F(DeviceQuirks, gralloc_cannot_be_closed_safely_quirk_can_be_disabled)
201{201{
202 using namespace testing;202 using namespace testing;
203 char const default_str[] = "";203 char const default_str[] = "";
@@ -212,9 +212,9 @@
212 return 0;212 return 0;
213 }));213 }));
214214
215 disable_single_gralloc_instance_quirk();215 disable_gralloc_cannot_be_closed_safely_quirk();
216 mga::DeviceQuirks quirks(mock_ops, options);216 mga::DeviceQuirks quirks(mock_ops, options);
217 EXPECT_TRUE(quirks.gralloc_reopenable_after_close());217 EXPECT_FALSE(quirks.gralloc_cannot_be_closed_safely());
218}218}
219219
220TEST_F(DeviceQuirks, width_alignment_quirk_can_be_disabled)220TEST_F(DeviceQuirks, width_alignment_quirk_can_be_disabled)

Subscribers

People subscribed via source and target branches