Re: Mark dma buffer readonly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 31 Jan 2018 19:49:29 +0530, Saket Sinha said:

> As per ldd3 , Chapter 15 - "The DMA controller is a shared resource,
> and confusion could arise if more than one
> processor attempts to program it simultaneously. For that reason, the
> controller is protected by a spinlock, called dma_spin_lock. Drivers
> should not manipulate the
> lock directly;"

Yes, that way lies great pain and confusion.

> However, I am using this in kthreads and I want to protect it without
> using mutex/spilock.
> Apart from protecting it with spinlock or mutex, is their anyway to
> mark this dma buffer as read-only so that other threads(after
> concerned thread has accessed it) cannot access the dma buffer.

Basic locking theory states that if one section of code is already using one
type of locking primitive, and you want a lock on the resource, you need to
use the same type of lock, and the same instance.

In other words, you need to use a spinlock on dma_spin_lock as well, or
things *will* fail (and when it's a DMA controller in question, the failure will
almost certainly be spectacular).  So using a mutex is probably out of
the question.

Have you considered restructuring your code so a spinlock is usable?

Attachment: pgpx5_NBh5VgG.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux