summaryrefslogtreecommitdiff
path: root/wiki/Chat_log/20160914-mm-chatlog
blob: c8ce095134040c34466544f5eed9054b86ed783e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
Multimedia-chat-meeting-2016-09-14

10:08 < pinchartl> topics for the day
10:08 < pinchartl> Topic 1. Status check for the multimedia tasks
10:08 < pinchartl> Topic 2. Additional tasks for Q4 2016
10:08 < pinchartl> Topic 3. Status update for Renesas on the multimedia todo list
10:08 < pinchartl> anything else ?
10:09 < pinchartl> maybe
10:09 < neg> yes a quick question about what work to aim to include for renesas-drivers releases
10:09 < pinchartl> Topic 4. Agenda for the multimedia face to face meeting in Berlin
10:09 < pinchartl> ok
10:10 < pinchartl> - Topic 1. Status check for the multimedia tasks
10:11 < pinchartl> in real alphabetical order today
10:11 < pinchartl> Kieran, you're first
10:11 < kbingham> hehe I feel privilidged :D
10:11 < pinchartl> (in the usual "what did I do, what do I plan to do, what problems do I have" format)
10:13 < kbingham> Since last meetinng, I have worked on VSP Partitioning Algorithm, now submitted and next plan a short task to assist geertu, as he has had to drop FDP1 from his tree. No particular problems at the moment.
10:14 < kbingham> Oh - actually - I do have a small problem.
10:14 < kbingham> Current tests still aren't running clean for me on the VSP. - So I'll see what that is  first.
10:15 < pinchartl> nice work on the VSP
10:15 < pinchartl> regarding the FDP, I've posted a v3 of the patches which you have reviewed (thanks for that)
10:15 < pinchartl> now that everything is in order I'll push my branch and will ask Geert to merge it
10:16 < pinchartl> so there's no need for you to get bothered with that
10:16 < kbingham> That's a good solution to assist Geert :D
10:16 < pinchartl> if you're now bored I have new tasks for you for Q4 which you could get started with :-)
10:16 < pinchartl> let's discuss them as part of the second topic
10:16 < kbingham> ;)
10:17 < pinchartl> regarding the VSP tests, which one(s) are failing for you ?
10:17 -!- morimoto [~user@relprex3.renesas.com] has joined #periperi
10:17 < pinchartl> hello Morimoto-san !
10:17 < kbingham> Test 1, 2, "yuv_to_rgbpnm: bad format"
10:17 < pinchartl> Geert was wondering if you were busy working on a new son :-D
10:18 < morimoto> sorry for my late
10:18 < morimoto> pinchartl: hehe :)
10:19 < pinchartl> kbingham: could you try to update raw2rgbpnm to the latest version ?
10:19 < kbingham> pinchartl: did something change there?
10:20 < pinchartl> "Add support for missing YUV 4:1:1, 4:2:0, 4:2:2 and 4:4:4 planar formats"
10:20 < pinchartl> that's not very recent though
10:20 < pinchartl> we can discuss this after the meeting
10:21 < kbingham> Yes, I dno't think this is topic for this meeting.
10:21 < pinchartl> and regarding your plan for the next two weeks, I assume you'll also write the VSP image partitioning task report for Jinzai, right ? :-)
10:21 < kbingham> Ah yes :)
10:21  * kbingham whistles loudly pretending he hadn't forgotten about that.
10:22 < pinchartl> thanks for the report
10:22 < pinchartl> next, me
10:22 < pinchartl> Since last meeting:
10:22 < pinchartl> - Posted v3 of the FDP driver
10:22 < pinchartl> - VSP image partitioning support
10:22 < pinchartl> - DU and VSP integration on H3
10:23 < pinchartl> For the next two weeks:
10:23 < pinchartl> - Continue working on the FDP driver to get it merged upstream
10:23 < pinchartl> - VIN and HDMI output patch review
10:23 < pinchartl> ah, I forgot to mention, I've also worked on
10:23 < pinchartl> - Rebased VSP HGO and HGT support
10:24 < kbingham> And ROT/FLIP
10:24 < pinchartl> yes, that's part of image partitioning, but it's worth mentioning it explicitly
10:25 < pinchartl> and, just for the fun of it, reverse-engineered the VSP RGB to HSV transformation to include emulation code in the test suite :-)
10:26 < pinchartl> morimoto: I forgot to reply to your e-mail, but less than 24h after you've told Niklas and me that the hardware team couldn't share the information because it was confidential, we managed to understand how it worked
10:26 < morimoto> pinchartl: we are sorry about that
10:27 < morimoto> Is it needed for test program, correct ?
10:28 < pinchartl> yes
10:28 < pinchartl> but it's fine now
10:28 < morimoto> OK
10:28 < pinchartl> we have fixed the problem, we know how it works
10:28 < pinchartl> we will have a similar issue with the UDS though:
10:28 < pinchartl> Issues and Blockers:
10:28 < pinchartl> - VSP test suite generates false positives in UDS testing
10:28 < pinchartl> This is caused by the emulation code scaling images with a method very different from the one used by the UDS, resulting in a need for a fuzzy comparison between the hardware output and the expected results with a too high threshold.
10:30 < pinchartl> in the next two weeks, I will also continue working on VSP HGO and HGT, as Mauro isn't convinced by the API proposal
10:30 < morimoto> About your "Issues and Blockers", do you need HW team help ?
10:31 < pinchartl> it would be nice to get more information about how the scaler operates, but I expect the same "this is confidential" answer :-/
10:31 < pinchartl> but it's worth asking
10:31 < pinchartl> this will likely be a task for the second half of Q4
10:31 < morimoto> OK, I will try, no expectation
10:32 < pinchartl> arigatō gozaimasu
10:32 < morimoto> Can you please add detail background on meeting report ?
10:32 < pinchartl> yes I will
10:32 < pinchartl> next, Morimoto-san
10:32 < morimoto> arigato
10:32 < morimoto> OK
10:33 < morimoto> I'm posting ALSA SoC patches to ML, but it seems Maintenor is focus to next kernel ?
10:33 < morimoto> so, nothing happen on my patches
10:33 < morimoto> I negotiated to Lars and Mark to discuss about ALSA SoC framework cleanup
10:34 < morimoto> and for new style ALSA SoC. I can talk it on ELCE timing
10:34 < morimoto> And BSP team is now focusing about Audio-DMAC power
10:34 < morimoto> As I asked on PeriPeriML, it is related to DMAEngine behavior
10:35 < pinchartl> please let me know if you would like me to join the discussion during ELCE
10:35 < morimoto> Thank. I'm happy if you can join to it.
10:35 < morimoto> it will be 2nd day, lunch timing
10:35 < morimoto> after Lars's presentation
10:36 < pinchartl> that works for me
10:36 < morimoto> About DMAEngine, rcar-dmac will power ON for Audio-DMAC when sound driver requests DMA channel
10:36 < morimoto> and power OFF when sound driver release it.
10:36 < morimoto> In my driver, it requests channel when .probe timing
10:37 < morimoto> this means, Audio DMAC is always ON
10:37 < pinchartl> right, I've seen your e-mail
10:37 < morimoto> which is correct approach
10:37 < morimoto> ?
10:37 < pinchartl> that's more of a core topic
10:37 < morimoto> Oops
10:37 < pinchartl> but in a nutshell, I think it would be good to optimize power consumption
10:37 < pinchartl> and only keep the hardware powered on when needed
10:38 < pinchartl> the issue there is that you need to call pm_runtime_get_sync() to power the hardware on
10:38 < pinchartl> which can't be called in atomic context
10:38 < pinchartl> and dma_async_issue_pending() needs to be callable in atomic context
10:38 < pinchartl> so to fix this we would likely need to extend the DMA engine API
10:39 < pinchartl> but to get sucha  change accepted
10:39 < pinchartl> we need to provide power consumption numbers
10:39 < morimoto> It is not Renesas specific issue, correct ?
10:39 < pinchartl> so we need to measure the extra power consumption caused by keeping the DMA engine powered on while not in use
10:39 < pinchartl> correct
10:40 < morimoto> Actually, I already created above patches. it request/release each times
10:40 < pinchartl> is that changes for the DMA engine driver or for the ALSA driver ?
10:40 < morimoto> Do you think I should post it to ML ? or keep it in my pocket ?
10:40 < morimoto> ALSA driver side only
10:40 < pinchartl> that's the second idea I was going to propose
10:41 < pinchartl> keep powering the DMA engine on in dma_request_channel()
10:41 < pinchartl> (or rather device_alloc_chan_resources())
10:41 < pinchartl> but move the dma_request_channel() from ALSA driver .probe() to a later point
10:41 < pinchartl> I think those patches would be sense to be posted
10:42 < morimoto> OK
10:42 < morimoto> This means, request/release happen many times. is this correct ?
10:43 < pinchartl> yes
10:43 < pinchartl> well, more than currently at leas
10:43 < pinchartl> t
10:43 < morimoto> OK. nice to know. I can be your father if you want :)
10:43 < pinchartl> I don't think my current father would be happy about that :-)
10:43 < morimoto> hehe :)
10:43 < morimoto> That's it from me
10:44 < pinchartl> what's your plan for the next two weeks ?
10:45 < morimoto> About patches, it is based on Maintenor.
10:45 < morimoto> I need to post more patches, but these are based on current patches.
10:45 < morimoto> If no update on ML, I will do Renesas side task
10:45 < pinchartl> ok
10:46 < pinchartl> thank you
10:46 < pinchartl> next, Niklas
10:46 < neg> a) Posted HGT patches, I see minimal work left to keep them up to date until they can be picked up
10:46 < neg> b) Start to work on VIN for M3 and rebase VIN Gen3 patches
10:46 < neg> c) No review on VIN Gen3 patches
10:47 < neg> also if there is time update the vsp-tests tool to take overlaping HGT hue areas in to account
10:47 < pinchartl> for the HGT, let's sync up on that after the meeting, I'll take your patches in my tree
10:47 < neg> ok
10:47 < pinchartl> I have done so already, probably a slightly different version, that's why we need to sync up
10:48 < pinchartl> regarding the VIN Gen3 patches, they were on my todo list after last meeting, but I had to focus on the VSP :-/
10:48 < pinchartl> I'll really try to get to them ASAP
10:48 < pinchartl> you had a quick question about what work to aim to include for renesas-drivers releases ?
10:49 < neg> np :-)
10:49 < neg> I have tried to keep the VIN Gen3 patches ready for renesas-drivers but have not always sucseeded in keeping them up to date. And since they seems to be a long way from beeing pickedup I was wondering if I should drop them from the patches I try to get in to renesas-drivers so Geert don't have to deal with any conflicts that series cause. If you see value in having them in renesas-drivers I will rejuvenate
10:49 < neg> my effort to keep them up to date at all times.
10:50 < pinchartl> geertu: any opinion on that ?
10:53 < pinchartl> renesas-drivers is a -next tree that is a bit more agressive than -next. it serves as a way to catch integration (as in merging multiple development branches) issues early
10:53 < pinchartl> including Gen3 VIN support in renesas-drivers is thus useful when you post a new version of the patch series
10:53 < pinchartl> but after that, if it starts generating painful conflicts, it likely means a new version of the series will be needed anyway
10:54 < pinchartl> so I wouldn't insist in keeping the code in renesas-drivers at all times
10:55 < neg> ok, I will continue to try and keep them up to date and included in renesas-drivers then
10:55 < pinchartl> please submit them for inclusion when you post a new version of the patches
10:55 < pinchartl> but don't spend an unnecessary large amount of time keeping them up-to-date between two versions
10:56 < neg> make sens
10:57 < pinchartl> thanks
10:57 < pinchartl> next, uli___ 
10:58 < uli___> a)
10:58 < uli___> - kept the salvator hdmi out alive (build failure; want to convert it to soc_device_match() before sending a new revision)
10:59 < uli___> - checked if it works without the funky cma reservation patch (it does, it's sufficient to increase the cma size)
10:59 < uli___> - started looking into gen2 vin integration in earnest (see c) )
10:59 < uli___> b) finish gen2 vin integration
10:59 < uli___> c) i don't have hardware docs for the gose board
10:59 < uli___> can somebody set me up with those?
10:59 < uli___> [that's it]
11:00 < pinchartl> do you regarding Gen2 VIN integration, that's due for the 18th, so I assume you'll finish it before two weeks ? :-)
11:00 < pinchartl> s/do you //
11:00 < uli___> yes
11:01 < pinchartl> thanks
11:02 < pinchartl> what's the status of DU,v4.9,public,ulrich,EDID generation support for the HDMI loopback test setup ?
11:02 < uli___> that's part of the hdmi in series, i'll send that out with gose support added before the due date
11:03 < pinchartl> perfect, thanks
11:03 < uli___> provided somebody can get me the docs...
11:03 < uli___> morimoto: HINT
11:03 < pinchartl> do you mean the schematics ?
11:03 < uli___> yes
11:03 < pinchartl> do you have a GPG key ?
11:03 < uli___> afraid not
11:04 < pinchartl> can you create one ? :-)
11:04 < uli___> is there an alternative? [i have no clue about that]
11:04 < pinchartl> morimoto: can I send the Gose schematics to Ulrich by e-mail without encryption ?
11:05 < morimoto> Hmm..
11:05 < morimoto> Now, it is under your NDA or export side issue
11:05 < morimoto> (I wonder why you have it ?)
11:05 < pinchartl> let's assume I don't have it :-)
11:05 < morimoto> Hehe :)
11:05 < morimoto> uli___: I will ask to Renesas guy
11:06 < uli___> thank you
11:06 < morimoto> but few availability
11:06 < pinchartl> availability of the schematics ?
11:07 < morimoto> maybe
11:07 < pinchartl> we're not asking for a board to be sent, just a document :-)
11:07 < morimoto> Hehe, OK
11:08 < pinchartl> thanks
11:08 < pinchartl> that's it for the status update
11:08 < pinchartl> Topic 2. Additional tasks for Q4 2016
11:09 < pinchartl> here are the additional tasks that will very likely be assigned to all of you for Q4
11:09 -!- Irssi: Pasting 7 lines to #periperi. Press Ctrl-K if you wish to do this or Ctrl-C to cancel.
11:09 < pinchartl> Laurent:
11:09 < pinchartl> - M3-W DU support (5 days)
11:09 < pinchartl> - LVDS mode selection for DU (5 days)
11:09 < pinchartl> Kieran:
11:09 < pinchartl> - DU write-back V4L2 prototype (10 days)
11:09 < pinchartl> - VSP image partitioning performance optimization (5 days)
11:10 -!- Irssi: Pasting 6 lines to #periperi. Press Ctrl-K if you wish to do this or Ctrl-C to cancel.
11:10 < pinchartl> Niklas:
11:10 < pinchartl> - M3-W VIN prototype support (5 days)
11:10 < pinchartl> Ulrich:
11:10 < pinchartl> - Audio loopback test program to test sampling rate and L-R issues (10 days)
11:10 < pinchartl> - DU Gen3 HDMI output upstream preparation (Channel 0 only) (5 days)
11:10 < pinchartl> I'll reach out to everybody with more detailed descriptions
11:10 < pinchartl> but if you already have questions, please go ahead
11:10 < morimoto> Is it updated version from Magnus ?
11:10 < pinchartl> (that's for the first half of Q4 only, the second half will follow later)
11:11 < morimoto> (I talked it with him, this morning)
11:11 < pinchartl> yes, that's from the e-mail he sent me a few hours ago
11:11 < morimoto> OK, nice to know
11:12 < morimoto> pinchartl: can you please add these tasks into peripelist todo list ?
11:12 < pinchartl> I will first write the detailed descriptions and get them approved, and I'll then add them to the todo list, sure
11:13 < morimoto> Thanks.
11:13 < pinchartl> Topic 3. Status update for Renesas on the multimedia todo list
11:14 < pinchartl> Morimoto-san told me that Renesas would like a status update on the following
11:14 -!- Irssi: Pasting 8 lines to #periperi. Press Ctrl-K if you wish to do this or Ctrl-C to cancel.
11:14 < pinchartl> DU,2016-12-31,request,?,M3
11:14 < pinchartl> DU,2016-06-30,request,ulrich,HDMI out ES1.1 support
11:14 < pinchartl> VSP,2016-06-30,request,laurent,solve UDS scaling regression for Gen3 
11:14 < pinchartl> VSP,2016-06-30,request,laurent,give information to Renesas about rotation status 
11:14 < pinchartl> VSP,2016-06-30,request,laurent,give information to Renesas about write-back feature plan
11:14 < pinchartl> VSP,2016-06-30,request,laurent,ES2.0 / M3 update
11:14 < pinchartl> VSP,2016-06-30,request,laurent,update request API on renesas-driver 
11:14 < pinchartl> VSP,2016-06-30,request,laurent,vsp1_pm_suspend() bugfix
11:14 < pinchartl> VSP,2016-10-30,request,laurent,VSP cache less support for BSP team
11:15 < morimoto> Yes, thanks. I will remove these if it was in todo list
11:15 < pinchartl> - DU,2016-12-31,request,?,M3
11:15 < pinchartl> there's an additional task for the first half of Q4
11:15 < pinchartl> - DU,2016-06-30,request,ulrich,HDMI out ES1.1 support
11:16 < pinchartl> Ulrich, any information about that ?
11:16 < uli___> not really. morimoto gave me info on how to implement that quite a while ago, but it does not seem to help
11:16 < uli___> morimoto: right?
11:16 < morimoto> Oops ?
11:17 < uli___> i mean, it still doesn't work on es1.1, right?
11:17 < morimoto> Ah, sorry, it was different story
11:17 < morimoto> My issue which was few weeks ago was my side fault
11:17 < morimoto> It was firmware issue.
11:18 < morimoto> So please forget it.
11:18 < uli___> that's good news :)
11:18 < morimoto> So, missing is only ES1.1 handling
11:18 -!- khiemnguyen [d2a0fca8@gateway/web/cgi-irc/kiwiirc.com/ip.210.160.252.168] has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
11:19 < morimoto> But it is related to Geert's ES handling magic ?
11:19 -!- khiemnguyen [d2a0fca8@gateway/web/cgi-irc/kiwiirc.com/ip.210.160.252.168] has joined #periperi
11:19 < uli___> yes, i'll look into that
11:19 < morimoto> OK. I will keep it under request file until next step
11:20 < pinchartl> uli___: do you think you can address that as part of either your base contract or the new "DU Gen3 HDMI output upstream preparation" task for Q4 ?
11:20 < uli___> yes, i think so
11:20 < morimoto> Nice to know !
11:20 < pinchartl> thank you
11:20 < pinchartl> - VSP,2016-06-30,request,laurent,solve UDS scaling regression for Gen3 
11:21 < pinchartl> - VSP,2016-06-30,request,laurent,give information to Renesas about rotation status
11:21 < pinchartl> this depends on image partitioning support that is now public
11:21 < pinchartl> both have been tested and are working
11:21 < pinchartl> - VSP,2016-06-30,request,laurent,give information to Renesas about write-back feature plan
11:21 < morimoto> OK. nice. I will remove these. But I can't find "UDS" word on todo list
11:22 < pinchartl> that's because there was nothing UDS-specific that had to be done
11:22 < pinchartl> implementing image partitioning fixed it
11:22 < morimoto> OK
11:22 < pinchartl> - VSP,2016-06-30,request,laurent,give information to Renesas about write-back feature plan
11:22 < pinchartl> will be assigned to Kieran as an additional task for the first half of Q4
11:23 < pinchartl> - VSP,2016-06-30,request,laurent,ES2.0 / M3 update
11:23 < pinchartl> will be handled as part of the DU M3 integration, assigned to me as an additional task for the first half of Q4
11:23 < pinchartl> - VSP,2016-06-30,request,laurent,update request API on renesas-driver
11:23 < morimoto> About, Write-back, it is next Kieran's task ?
11:23 < morimoto> I can remove it if todo list has it
11:23 < morimoto> correct ?
11:24 < pinchartl> please wait until the task get officially approved :-)
11:24 < morimoto> :) OK
11:24 < pinchartl> I'll then move it from the request file to the todo file
11:24 < pinchartl> - VSP,2016-06-30,request,laurent,update request API on renesas-driver
11:25 < pinchartl> I'll update the patch series before ELCE and send a pull request to Geert for renesas-drivers
11:25 < morimoto> you can handle only todo list, Renesas side will update request file
11:25 < pinchartl> (ok)
11:25 < pinchartl> my plan is to do so before kernel recipes, which is in two weeks in Paris
11:26 < pinchartl> but it might overflow to the week before ELCE
11:26 < pinchartl> at the latest it will be done before ELCE
11:26 < pinchartl> - VSP,2016-06-30,request,laurent,vsp1_pm_suspend() bugfix
11:26 < morimoto> Request API do you mean ?
11:26 < pinchartl> (yes)
11:26 < pinchartl> this has been proposed as an additional task for Q4, but Magnus told me that it needs to be discussed internally in Renesas first
11:26 < pinchartl> - VSP,2016-10-30,request,laurent,VSP cache less support for BSP team
11:27 < pinchartl> this has also been proposed as an additional task for Q4, and will possibly be accepted for the second batch
11:27 < pinchartl> it will be discussed face to face in Berlin first
11:27 < pinchartl> as it's not clear yet how to proceed
11:27 < morimoto> What is the problem about VSP1 PM suspen d?
11:27 < pinchartl> it doesn't work :-)
11:27 < pinchartl> suspend/resume is broken
11:27 < morimoto> Ahh OK
11:28 < pinchartl> it might even crash the kernel, I don't remember exactly
11:28 < morimoto> OK, thanks
11:28 < morimoto> And, I think I sent request about mising format something.
11:28 < morimoto> BSP team created local patch, do you remember ?
11:29 < pinchartl> here's the description of the problem I sent to Magnus
11:29 < pinchartl> The VSP suspend/resume code is known to be broken and needs to be fixed. This is further complicated by the fact that the VSP memory accesses are served by the FCP on Gen3, creating a suspend/resume dependency between the two devices.
11:29 < pinchartl> The VSP suspend/resume problem should be self-contained, but the FCP dependency would require dependencies support in the PM core. Work is ongoing in that area, and I believe we should take a more active role there. This isn't very suitable for additional tasks as they exist today as no deliverable can be guaranteed in a fixed amount of time.
11:29 < pinchartl> It might be possible to work around the problem by using the early/late suspend/resume handlers in the VSP and FCP drivers. I can't guarantee this at the moment without a more detailed and thus time-consuming analysis, hence the prototype status of this task.
11:30 < pinchartl> regarding the missing format
11:30 < pinchartl> was it the tri-planar formats for the DU ?
11:30 < morimoto> Maybe, I forgot detail
11:30 < pinchartl> so did I :-)
11:31 < pinchartl> but triplanar formats support has been merged
11:31 < morimoto> OK, nice
11:31 < pinchartl> any other question regarding the requests ?
11:32 < morimoto> nothing from me. Thanks
11:32 < pinchartl> you're welcome
11:32 < pinchartl> Topic 4. Agenda for the multimedia face to face meeting in Berlin
11:32 < pinchartl> we need to start drafting the agenda
11:32 < pinchartl> I'd like everybody to propose topics by e-mail in response to the chat report I will send
11:32 < pinchartl> and you can start now if you already have ideas in mind
11:33 < morimoto> I created Wiki page.
11:33 < morimoto> https://osdr.renesas.com/projects/linux-kernel-development/wiki/Miniperi-2016-10
11:33 < pinchartl> thank you
11:33 < kbingham> morimoto: Could I get an account to OSDR please?
11:34 < morimoto> Oopd, I will try. Please wait
11:34 < kbingham> np.
11:34 < morimoto> Maybe it will be after tomorrow
11:34 < pinchartl> morimoto: I think you can remove "What is the current status of "Rotation + ImagePertition" ?" and "Z-order" from the wiki page
11:34 < pinchartl> Z-order has been merged
11:34 < pinchartl> and patches for rotation + image partition have been posted yesterday
11:34 < morimoto> OK, but BSP team want to check it. keep it and set "finish" is help for me
11:35 < pinchartl> ok
11:35 < morimoto> s/help/helpful
11:35 < pinchartl> Topic 5. Next meeting
11:35 < neg> If possible I would like to talk about more pad aware v4l2 operations to you and Hans duinrg the mini multimedia summit (and to whom ever else is interessted ofc), but for periperi multimedia I think we talked about it in Tokyo
11:36 < pinchartl> neg: that's a good idea. could you propose that by e-mail to Hans ?
11:36 < neg> will do
11:37 < pinchartl> thanks
11:37 < pinchartl> I will attend Kernel Recipes in Paris in two weeks
11:37 < pinchartl> so I won't be available Wednesday-Friday
11:37 < pinchartl> and neither will I be available on Monday that week
11:38 < pinchartl> we could move the meeting to Tuesday, but that would conflict with the core meeting
11:38 < pinchartl> unless we move it one hour earlier, and keep it short
11:38 < pinchartl> another option is to hold the meeting on Wednesday without me
11:38 < pinchartl> thoughts ?
11:39 < morimoto> Wednesday = 28th ?
11:39 < pinchartl> yes
11:39 < neg> short meeting before core works for me, I think you should be in the meeting if possible
11:40 < pinchartl> given that it will be the last one before Berlin, I'd like to attend it, yes
11:40 < pinchartl> we'll keep the status update very short
11:40 < pinchartl> and focus on the agenda for the Berlin meeting
11:41 < pinchartl> so that would be 2016-09-27 at 08:00 BST / 09:00 CEST / 10:00 
11:41 < pinchartl> EEST / 16:00 JST
11:42 < neg> works for me
11:42 < morimoto> I booked
11:42 < uli___> ok
11:44 < pinchartl> thank you
11:44 < pinchartl> that's it for today
11:44 < pinchartl> thank you all for joinin
1161' href='#n1161'>1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796
/**************************************************************************
 *
 * Copyright (c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 **************************************************************************/
/*
 * Authors: Thomas Hellstrm <thomas-at-tungstengraphics-dot-com>
 */

#include "drmP.h"

/*
 * Locking may look a bit complicated but isn't really:
 *
 * The buffer usage atomic_t needs to be protected by dev->struct_mutex
 * when there is a chance that it can be zero before or after the operation.
 *
 * dev->struct_mutex also protects all lists and list heads,
 * Hash tables and hash heads.
 *
 * bo->mutex protects the buffer object itself excluding the usage field.
 * bo->mutex does also protect the buffer list heads, so to manipulate those,
 * we need both the bo->mutex and the dev->struct_mutex.
 *
 * Locking order is bo->mutex, dev->struct_mutex. Therefore list traversal
 * is a bit complicated. When dev->struct_mutex is released to grab bo->mutex,
 * the list traversal will, in general, need to be restarted.
 *
 */

static void drm_bo_destroy_locked(struct drm_buffer_object *bo);
static int drm_bo_setup_vm_locked(struct drm_buffer_object *bo);
static void drm_bo_takedown_vm_locked(struct drm_buffer_object *bo);
static void drm_bo_unmap_virtual(struct drm_buffer_object *bo);

static inline uint64_t drm_bo_type_flags(unsigned type)
{
	return (1ULL << (24 + type));
}

/*
 * bo locked. dev->struct_mutex locked.
 */

void drm_bo_add_to_pinned_lru(struct drm_buffer_object *bo)
{
	struct drm_mem_type_manager *man;

	DRM_ASSERT_LOCKED(&bo->dev->struct_mutex);
	DRM_ASSERT_LOCKED(&bo->mutex);

	man = &bo->dev->bm.man[bo->pinned_mem_type];
	list_add_tail(&bo->pinned_lru, &man->pinned);
}

void drm_bo_add_to_lru(struct drm_buffer_object *bo)
{
	struct drm_mem_type_manager *man;

	DRM_ASSERT_LOCKED(&bo->dev->struct_mutex);

	if (!(bo->mem.proposed_flags & (DRM_BO_FLAG_NO_MOVE | DRM_BO_FLAG_NO_EVICT))
	    || bo->mem.mem_type != bo->pinned_mem_type) {
		man = &bo->dev->bm.man[bo->mem.mem_type];
		list_add_tail(&bo->lru, &man->lru);
	} else {
		INIT_LIST_HEAD(&bo->lru);
	}
}

static int drm_bo_vm_pre_move(struct drm_buffer_object *bo, int old_is_pci)
{
#ifdef DRM_ODD_MM_COMPAT
	int ret;

	if (!bo->map_list.map)
		return 0;

	ret = drm_bo_lock_kmm(bo);
	if (ret)
		return ret;
	drm_bo_unmap_virtual(bo);
	if (old_is_pci)
		drm_bo_finish_unmap(bo);
#else
	if (!bo->map_list.map)
		return 0;

	drm_bo_unmap_virtual(bo);
#endif
	return 0;
}

static void drm_bo_vm_post_move(struct drm_buffer_object *bo)
{
#ifdef DRM_ODD_MM_COMPAT
	int ret;

	if (!bo->map_list.map)
		return;

	ret = drm_bo_remap_bound(bo);
	if (ret) {
		DRM_ERROR("Failed to remap a bound buffer object.\n"
			  "\tThis might cause a sigbus later.\n");
	}
	drm_bo_unlock_kmm(bo);
#endif
}

/*
 * Call bo->mutex locked.
 */

static int drm_bo_add_ttm(struct drm_buffer_object *bo)
{
	struct drm_device *dev = bo->dev;
	int ret = 0;
	uint32_t page_flags = 0;

	DRM_ASSERT_LOCKED(&bo->mutex);
	bo->ttm = NULL;

	if (bo->mem.proposed_flags & DRM_BO_FLAG_WRITE)
		page_flags |= DRM_TTM_PAGE_WRITE;

	switch (bo->type) {
	case drm_bo_type_device:
	case drm_bo_type_kernel:
		bo->ttm = drm_ttm_create(dev, bo->num_pages << PAGE_SHIFT, 
					 page_flags, dev->bm.dummy_read_page);
		if (!bo->ttm)
			ret = -ENOMEM;
		break;
	case drm_bo_type_user:
		bo->ttm = drm_ttm_create(dev, bo->num_pages << PAGE_SHIFT,
					 page_flags | DRM_TTM_PAGE_USER,
					 dev->bm.dummy_read_page);
		if (!bo->ttm)
			ret = -ENOMEM;

		ret = drm_ttm_set_user(bo->ttm, current,
				       bo->buffer_start,
				       bo->num_pages);
		if (ret)
			return ret;

		break;
	default:
		DRM_ERROR("Illegal buffer object type\n");
		ret = -EINVAL;
		break;
	}

	return ret;
}

static int drm_bo_handle_move_mem(struct drm_buffer_object *bo,
				  struct drm_bo_mem_reg *mem,
				  int evict, int no_wait)
{
	struct drm_device *dev = bo->dev;
	struct drm_buffer_manager *bm = &dev->bm;
	int old_is_pci = drm_mem_reg_is_pci(dev, &bo->mem);
	int new_is_pci = drm_mem_reg_is_pci(dev, mem);
	struct drm_mem_type_manager *old_man = &bm->man[bo->mem.mem_type];
	struct drm_mem_type_manager *new_man = &bm->man[mem->mem_type];
	int ret = 0;

	if (old_is_pci || new_is_pci ||
	    ((mem->flags ^ bo->mem.flags) & DRM_BO_FLAG_CACHED))
		ret = drm_bo_vm_pre_move(bo, old_is_pci);
	if (ret)
		return ret;

	/*
	 * Create and bind a ttm if required.
	 */

	if (!(new_man->flags & _DRM_FLAG_MEMTYPE_FIXED) && (bo->ttm == NULL)) {
		ret = drm_bo_add_ttm(bo);
		if (ret)
			goto out_err;

		if (mem->mem_type != DRM_BO_MEM_LOCAL) {
			ret = drm_ttm_bind(bo->ttm, mem);
			if (ret)
				goto out_err;
		}

		if (bo->mem.mem_type == DRM_BO_MEM_LOCAL) {
			
			struct drm_bo_mem_reg *old_mem = &bo->mem;
			uint64_t save_flags = old_mem->flags;
			uint64_t save_proposed_flags = old_mem->proposed_flags;
			
			*old_mem = *mem;
			mem->mm_node = NULL;
			old_mem->proposed_flags = save_proposed_flags;
			DRM_FLAG_MASKED(save_flags, mem->flags,
					DRM_BO_MASK_MEMTYPE);
			goto moved;
		}
		
	}

	if (!(old_man->flags & _DRM_FLAG_MEMTYPE_FIXED) &&
	    !(new_man->flags & _DRM_FLAG_MEMTYPE_FIXED))		
		ret = drm_bo_move_ttm(bo, evict, no_wait, mem);
	else if (dev->driver->bo_driver->move) 
		ret = dev->driver->bo_driver->move(bo, evict, no_wait, mem);
	else
		ret = drm_bo_move_memcpy(bo, evict, no_wait, mem);

	if (ret)
		goto out_err;

moved:
	if (old_is_pci || new_is_pci)
		drm_bo_vm_post_move(bo);

	if (bo->priv_flags & _DRM_BO_FLAG_EVICTED) {
		ret =
		    dev->driver->bo_driver->invalidate_caches(dev,
							      bo->mem.flags);
		if (ret)
			DRM_ERROR("Can not flush read caches\n");
	}

	DRM_FLAG_MASKED(bo->priv_flags,
			(evict) ? _DRM_BO_FLAG_EVICTED : 0,
			_DRM_BO_FLAG_EVICTED);

	if (bo->mem.mm_node)
		bo->offset = (bo->mem.mm_node->start << PAGE_SHIFT) +
			bm->man[bo->mem.mem_type].gpu_offset;


	return 0;

out_err:
	if (old_is_pci || new_is_pci)
		drm_bo_vm_post_move(bo);

	new_man = &bm->man[bo->mem.mem_type];
	if ((new_man->flags & _DRM_FLAG_MEMTYPE_FIXED) && bo->ttm) {
		drm_ttm_unbind(bo->ttm);
		drm_ttm_destroy(bo->ttm);
		bo->ttm = NULL;
	}

	return ret;
}

/*
 * Call bo->mutex locked.
 * Returns -EBUSY if the buffer is currently rendered to or from. 0 otherwise.
 */

static int drm_bo_busy(struct drm_buffer_object *bo, int check_unfenced)
{
	struct drm_fence_object *fence = bo->fence;

	if (check_unfenced && (bo->priv_flags & _DRM_BO_FLAG_UNFENCED))
		return -EBUSY;

	if (fence) {
		if (drm_fence_object_signaled(fence, bo->fence_type)) {
			drm_fence_usage_deref_unlocked(&bo->fence);
			return 0;
		}
		drm_fence_object_flush(fence, DRM_FENCE_TYPE_EXE);
		if (drm_fence_object_signaled(fence, bo->fence_type)) {
			drm_fence_usage_deref_unlocked(&bo->fence);
			return 0;
		}
		return -EBUSY;
	}
	return 0;
}

static int drm_bo_check_unfenced(struct drm_buffer_object *bo)
{
	int ret;

	mutex_lock(&bo->mutex);
	ret = (bo->priv_flags & _DRM_BO_FLAG_UNFENCED);
	mutex_unlock(&bo->mutex);
	return ret;
}


/*
 * Call bo->mutex locked.
 * Wait until the buffer is idle.
 */

int drm_bo_wait(struct drm_buffer_object *bo, int lazy, int interruptible,
		int no_wait, int check_unfenced)
{
	int ret;

	DRM_ASSERT_LOCKED(&bo->mutex);
	while(unlikely(drm_bo_busy(bo, check_unfenced))) {
		if (no_wait)
			return -EBUSY;

		if (check_unfenced &&  (bo->priv_flags & _DRM_BO_FLAG_UNFENCED)) {
			mutex_unlock(&bo->mutex);
			wait_event(bo->event_queue, !drm_bo_check_unfenced(bo));
			mutex_lock(&bo->mutex);
			bo->priv_flags |= _DRM_BO_FLAG_UNLOCKED;
		}

		if (bo->fence) {
			struct drm_fence_object *fence;
			uint32_t fence_type = bo->fence_type;

			drm_fence_reference_unlocked(&fence, bo->fence);
			mutex_unlock(&bo->mutex);

			ret = drm_fence_object_wait(fence, lazy, !interruptible,
						    fence_type);

			drm_fence_usage_deref_unlocked(&fence);
			mutex_lock(&bo->mutex);
			bo->priv_flags |= _DRM_BO_FLAG_UNLOCKED;
			if (ret)
				return ret;
		}

	}
	return 0;
}
EXPORT_SYMBOL(drm_bo_wait);