]> git.karo-electronics.de Git - linux-beck.git/commit
iommu/amd: Fix the left value check of cmd buffer
authorHuang Rui <ray.huang@amd.com>
Mon, 12 Dec 2016 12:28:26 +0000 (07:28 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2017 10:39:28 +0000 (11:39 +0100)
commit2148835de3c2410bfb6c64037187a1b72f6d6488
treecb929b33d9bf15d38d28508ff176a693e7627b10
parent48ffae87e91346382790af10d793cba4d2e1d341
iommu/amd: Fix the left value check of cmd buffer

commit 432abf68a79332282329286d190e21fe3ac02a31 upstream.

The generic command buffer entry is 128 bits (16 bytes), so the offset
of tail and head pointer should be 16 bytes aligned and increased with
0x10 per command.

When cmd buf is full, head = (tail + 0x10) % CMD_BUFFER_SIZE.

So when left space of cmd buf should be able to store only two
command, we should be issued one COMPLETE_WAIT additionally to wait
all older commands completed. Then the left space should be increased
after IOMMU fetching from cmd buf.

So left check value should be left <= 0x20 (two commands).

Signed-off-by: Huang Rui <ray.huang@amd.com>
Fixes: ac0ea6e92b222 ('x86/amd-iommu: Improve handling of full command buffer')
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iommu/amd_iommu.c