config RISCV_IOMMU
bool "RISC-V IOMMU Support"
- depends on RISCV && 64BIT
+ default RISCV
depends on GENERIC_MSI_IRQ
- default y
+ depends on (RISCV || COMPILE_TEST) && 64BIT
select IOMMU_API
select GENERIC_PT
select IOMMU_PT
#include <linux/types.h>
#include <linux/bitfield.h>
#include <linux/bits.h>
+#include <asm/page.h>
/*
* Chapter 5: Memory Mapped register interface
static inline void riscv_iommu_cmd_inval_set_addr(struct riscv_iommu_command *cmd,
u64 addr)
{
- cmd->dword1 = FIELD_PREP(RISCV_IOMMU_CMD_IOTINVAL_ADDR, phys_to_pfn(addr));
+ cmd->dword1 =
+ FIELD_PREP(RISCV_IOMMU_CMD_IOTINVAL_ADDR, PHYS_PFN(addr));
cmd->dword0 |= RISCV_IOMMU_CMD_IOTINVAL_AV;
}
if (FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb)) {
const size_t queue_size = entry_size << (logsz + 1);
- queue->phys = pfn_to_phys(FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb));
+ queue->phys = PFN_PHYS(FIELD_GET(RISCV_IOMMU_PPN_FIELD, qb));
queue->base = devm_ioremap(iommu->dev, queue->phys, queue_size);
} else {
do {
* 6. Make sure the doorbell write to the device has finished before updating
* the shadow tail index in normal memory. 'fence o, w'
*/
+#ifdef CONFIG_MMIOWB
mmiowb();
+#endif
atomic_inc(&queue->tail);
/* 7. Complete submission and restore local interrupts */