summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdoops.c
diff options
context:
space:
mode:
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>2016-09-05 14:09:53 +0100
committerWill Deacon <will.deacon@arm.com>2016-09-16 09:34:13 +0100
commitbcfced1580c40662d1c095899af9d0dd3ed9e7bc (patch)
tree9cc92ea495ea28421da9ff31c9b96323246a4d3d /drivers/mtd/mtdoops.c
parent6070529bebd26e0a80d9b9653a6f53275086603f (diff)
downloadlinux-stable-bcfced1580c40662d1c095899af9d0dd3ed9e7bc.tar.gz
linux-stable-bcfced1580c40662d1c095899af9d0dd3ed9e7bc.tar.bz2
linux-stable-bcfced1580c40662d1c095899af9d0dd3ed9e7bc.zip
iommu/arm-smmu: Fix polling of command queue
When the SMMUv3 driver attempts to send a command, it adds an entry to the command queue. This is a circular buffer, where both the producer and consumer have a wrap bit. When producer.index == consumer.index and producer.wrap == consumer.wrap, the list is empty. When producer.index == consumer.index and producer.wrap != consumer.wrap, the list is full. If the list is full when the driver needs to add a command, it waits for the SMMU to consume one command, and advance the consumer pointer. The problem is that we currently rely on "X before Y" operation to know if entries have been consumed, which is a bit fiddly since it only makes sense when the distance between X and Y is less than or equal to the size of the queue. At the moment when the list is full, we use "Consumer before Producer + 1", which is out of range and returns a value opposite to what we expect: when the queue transitions to not full, we stay in the polling loop and time out, printing an error. Given that the actual bug was difficult to determine, simplify the polling logic by relying exclusively on queue_full and queue_empty, that don't have this range constraint. Polling the queue is now straightforward: * When we want to add a command and the list is full, wait until it isn't full and retry. * After adding a sync, wait for the list to be empty before returning. Suggested-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/mtd/mtdoops.c')
0 files changed, 0 insertions, 0 deletions