mirror of https://gitee.com/openkylin/qemu.git
PPC: spapr: iommu: rework traces
This converts old style fprintf to traces. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> [agraf: change patch subject] Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
59760f2dba
commit
7e472264e9
|
@ -22,13 +22,12 @@
|
||||||
#include "kvm_ppc.h"
|
#include "kvm_ppc.h"
|
||||||
#include "sysemu/dma.h"
|
#include "sysemu/dma.h"
|
||||||
#include "exec/address-spaces.h"
|
#include "exec/address-spaces.h"
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
#include "hw/ppc/spapr.h"
|
#include "hw/ppc/spapr.h"
|
||||||
|
|
||||||
#include <libfdt.h>
|
#include <libfdt.h>
|
||||||
|
|
||||||
/* #define DEBUG_TCE */
|
|
||||||
|
|
||||||
enum sPAPRTCEAccess {
|
enum sPAPRTCEAccess {
|
||||||
SPAPR_TCE_FAULT = 0,
|
SPAPR_TCE_FAULT = 0,
|
||||||
SPAPR_TCE_RO = 1,
|
SPAPR_TCE_RO = 1,
|
||||||
|
@ -61,44 +60,28 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
|
||||||
{
|
{
|
||||||
sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu);
|
sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu);
|
||||||
uint64_t tce;
|
uint64_t tce;
|
||||||
|
IOMMUTLBEntry ret = {
|
||||||
#ifdef DEBUG_TCE
|
.target_as = &address_space_memory,
|
||||||
fprintf(stderr, "spapr_tce_translate liobn=0x%" PRIx32 " addr=0x"
|
.iova = 0,
|
||||||
DMA_ADDR_FMT "\n", tcet->liobn, addr);
|
.translated_addr = 0,
|
||||||
#endif
|
.addr_mask = ~(hwaddr)0,
|
||||||
|
.perm = IOMMU_NONE,
|
||||||
|
};
|
||||||
|
|
||||||
if (tcet->bypass) {
|
if (tcet->bypass) {
|
||||||
return (IOMMUTLBEntry) {
|
ret.perm = IOMMU_RW;
|
||||||
.target_as = &address_space_memory,
|
} else if (addr < tcet->window_size) {
|
||||||
.iova = 0,
|
/* Check if we are in bound */
|
||||||
.translated_addr = 0,
|
tce = tcet->table[addr >> SPAPR_TCE_PAGE_SHIFT];
|
||||||
.addr_mask = ~(hwaddr)0,
|
ret.iova = addr & ~SPAPR_TCE_PAGE_MASK;
|
||||||
.perm = IOMMU_RW,
|
ret.translated_addr = tce & ~SPAPR_TCE_PAGE_MASK;
|
||||||
};
|
ret.addr_mask = SPAPR_TCE_PAGE_MASK;
|
||||||
|
ret.perm = tce;
|
||||||
}
|
}
|
||||||
|
trace_spapr_iommu_xlate(tcet->liobn, addr, ret.iova, ret.perm,
|
||||||
|
ret.addr_mask);
|
||||||
|
|
||||||
/* Check if we are in bound */
|
return ret;
|
||||||
if (addr >= tcet->window_size) {
|
|
||||||
#ifdef DEBUG_TCE
|
|
||||||
fprintf(stderr, "spapr_tce_translate out of bounds\n");
|
|
||||||
#endif
|
|
||||||
return (IOMMUTLBEntry) { .perm = IOMMU_NONE };
|
|
||||||
}
|
|
||||||
|
|
||||||
tce = tcet->table[addr >> SPAPR_TCE_PAGE_SHIFT];
|
|
||||||
|
|
||||||
#ifdef DEBUG_TCE
|
|
||||||
fprintf(stderr, " -> *paddr=0x%llx, *len=0x%llx\n",
|
|
||||||
(tce & ~SPAPR_TCE_PAGE_MASK), SPAPR_TCE_PAGE_MASK + 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (IOMMUTLBEntry) {
|
|
||||||
.target_as = &address_space_memory,
|
|
||||||
.iova = addr & ~SPAPR_TCE_PAGE_MASK,
|
|
||||||
.translated_addr = tce & ~SPAPR_TCE_PAGE_MASK,
|
|
||||||
.addr_mask = SPAPR_TCE_PAGE_MASK,
|
|
||||||
.perm = tce,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spapr_tce_table_pre_load(void *opaque)
|
static int spapr_tce_table_pre_load(void *opaque)
|
||||||
|
@ -150,10 +133,7 @@ static int spapr_tce_table_realize(DeviceState *dev)
|
||||||
}
|
}
|
||||||
tcet->nb_table = tcet->window_size >> SPAPR_TCE_PAGE_SHIFT;
|
tcet->nb_table = tcet->window_size >> SPAPR_TCE_PAGE_SHIFT;
|
||||||
|
|
||||||
#ifdef DEBUG_TCE
|
trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd);
|
||||||
fprintf(stderr, "spapr_iommu: New TCE table @ %p, liobn=0x%x, "
|
|
||||||
"table @ %p, fd=%d\n", tcet, liobn, tcet->table, tcet->fd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops,
|
memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops,
|
||||||
"iommu-spapr", UINT64_MAX);
|
"iommu-spapr", UINT64_MAX);
|
||||||
|
@ -250,20 +230,17 @@ static target_ulong h_put_tce(PowerPCCPU *cpu, sPAPREnvironment *spapr,
|
||||||
target_ulong liobn = args[0];
|
target_ulong liobn = args[0];
|
||||||
target_ulong ioba = args[1];
|
target_ulong ioba = args[1];
|
||||||
target_ulong tce = args[2];
|
target_ulong tce = args[2];
|
||||||
|
target_ulong ret = H_PARAMETER;
|
||||||
sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn);
|
sPAPRTCETable *tcet = spapr_tce_find_by_liobn(liobn);
|
||||||
|
|
||||||
ioba &= ~(SPAPR_TCE_PAGE_SIZE - 1);
|
ioba &= ~(SPAPR_TCE_PAGE_SIZE - 1);
|
||||||
|
|
||||||
if (tcet) {
|
if (tcet) {
|
||||||
return put_tce_emu(tcet, ioba, tce);
|
ret = put_tce_emu(tcet, ioba, tce);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_TCE
|
trace_spapr_iommu_put(liobn, ioba, tce, ret);
|
||||||
fprintf(stderr, "%s on liobn=" TARGET_FMT_lx /*%s*/
|
|
||||||
" ioba 0x" TARGET_FMT_lx " TCE 0x" TARGET_FMT_lx "\n",
|
|
||||||
__func__, liobn, /*dev->qdev.id, */ioba, tce);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return H_PARAMETER;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spapr_dma_dt(void *fdt, int node_off, const char *propname,
|
int spapr_dma_dt(void *fdt, int node_off, const char *propname,
|
||||||
|
|
|
@ -1133,6 +1133,11 @@ xics_ics_write_xive(int nr, int srcno, int server, uint8_t priority) "ics_write_
|
||||||
xics_ics_reject(int nr, int srcno) "reject irq %#x [src %d]"
|
xics_ics_reject(int nr, int srcno) "reject irq %#x [src %d]"
|
||||||
xics_ics_eoi(int nr) "ics_eoi: irq %#x"
|
xics_ics_eoi(int nr) "ics_eoi: irq %#x"
|
||||||
|
|
||||||
|
# hw/ppc/spapr_iommu.c
|
||||||
|
spapr_iommu_put(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" tce=0x%"PRIx64" ret=%"PRId64
|
||||||
|
spapr_iommu_xlate(uint64_t liobn, uint64_t ioba, uint64_t tce, unsigned perm, unsigned pgsize) "liobn=%"PRIx64" 0x%"PRIx64" -> 0x%"PRIx64" perm=%u mask=%x"
|
||||||
|
spapr_iommu_new_table(uint64_t liobn, void *tcet, void *table, int fd) "liobn=%"PRIx64" tcet=%p table=%p fd=%d"
|
||||||
|
|
||||||
# util/hbitmap.c
|
# util/hbitmap.c
|
||||||
hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned long cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx"
|
hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned long cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx"
|
||||||
hbitmap_reset(void *hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64
|
hbitmap_reset(void *hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64
|
||||||
|
|
Loading…
Reference in New Issue