Skip to content

Commit 7cd0c65

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/riscv: Allow RISC_VIOMMU to COMPILE_TEST
This driver used to use a lot of page table constants from the architecture code which prevented COMPILE_TEST on other architectures. Now that iommupt provides all of the constants internally there are only two small bumps preventing COMPILE_TEST. - Use the generic functions for the riscv specific phys_to_pfn() and pfn_to_phys() - Use CONFIG_MMIOWB to block off the mmiowb() barrier - Require 64 bit because of writeq use failing compilation on 32 bit Tested-by: Vincent Chen <vincent.chen@sifive.com> Acked-by: Paul Walmsley <pjw@kernel.org> # arch/riscv Reviewed-by: Tomasz Jeznach <tjeznach@rivosinc.com> Tested-by: Tomasz Jeznach <tjeznach@rivosinc.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent c70d20b commit 7cd0c65

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/iommu/riscv/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
config RISCV_IOMMU
55
bool "RISC-V IOMMU Support"
6-
depends on RISCV && 64BIT
6+
default RISCV
77
depends on GENERIC_MSI_IRQ
8-
default y
8+
depends on (RISCV || COMPILE_TEST) && 64BIT
99
select IOMMU_API
1010
select GENERIC_PT
1111
select IOMMU_PT

drivers/iommu/riscv/iommu-bits.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/types.h>
1818
#include <linux/bitfield.h>
1919
#include <linux/bits.h>
20+
#include <asm/page.h>
2021

2122
/*
2223
* Chapter 5: Memory Mapped register interface
@@ -718,7 +719,8 @@ static inline void riscv_iommu_cmd_inval_vma(struct riscv_iommu_command *cmd)
718719
static inline void riscv_iommu_cmd_inval_set_addr(struct riscv_iommu_command *cmd,
719720
u64 addr)
720721
{
721-
cmd->dword1 = FIELD_PREP(RISCV_IOMMU_CMD_IOTINVAL_ADDR, phys_to_pfn(addr));
722+
cmd->dword1 =
723+
FIELD_PREP(RISCV_IOMMU_CMD_IOTINVAL_ADDR, PHYS_PFN(addr));
722724
cmd->dword0 |= RISCV_IOMMU_CMD_IOTINVAL_AV;
723725
}
724726

drivers/iommu/riscv/iommu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static int riscv_iommu_queue_alloc(struct riscv_iommu_device *iommu,
160160
if (FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb)) {
161161
const size_t queue_size = entry_size << (logsz + 1);
162162

163-
queue->phys = pfn_to_phys(FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb));
163+
queue->phys = PFN_PHYS(FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb));
164164
queue->base = devm_ioremap(iommu->dev, queue->phys, queue_size);
165165
} else {
166166
do {
@@ -436,7 +436,9 @@ static unsigned int riscv_iommu_queue_send(struct riscv_iommu_queue *queue,
436436
* 6. Make sure the doorbell write to the device has finished before updating
437437
* the shadow tail index in normal memory. 'fence o, w'
438438
*/
439+
#ifdef CONFIG_MMIOWB
439440
mmiowb();
441+
#endif
440442
atomic_inc(&queue->tail);
441443

442444
/* 7. Complete submission and restore local interrupts */

0 commit comments

Comments
 (0)