Interesting locking in vivi driver

From: Alexey Dobriyan
Date: Sun Mar 25 2007 - 14:54:46 EST


I have some question: what's going on? How can it work?

Local spinlock _on_stack_, initialized, acquired and dropped.

drivers/media/video/vivi.c:
271 static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
272 int hmax, int line, char *timestr)
273 #else
274 static void gen_line(char *basep,int inipos,int wmax,
275 int hmax, int line, char *timestr)
276 #endif
277 {
278 int w,i,j,pos=inipos,y;
279 char *p,*s;
280 u8 chr,r,g,b,color;
281 #ifdef CONFIG_VIVI_SCATTER
282 int pgpos,oldpg;
283 char *basep;
284 struct page *pg;
285
286 unsigned long flags;
287 ===> spinlock_t spinlock; <===
288
289 ===> spin_lock_init(&spinlock); <===
290
291 /* Get first addr pointed to pixel position */
292 oldpg=get_addr_pos(pos,pages,to_addr);
293 pg=pfn_to_page(sg_dma_address(to_addr[oldpg].sg) >> PAGE_SHIFT);
294 ===> spin_lock_irqsave(&spinlock,flags); <===
295 basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
296 #endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/