powerpc iommu: rework traces
PATCH 1/1 powerpc iommu: rework traces
This converts old style fprintf to traces.
--- hw/ppc/spapr_iommu.c | 75 ++++++++++++++++++---------------------------------- trace-events | 5 ++++ 2 files changed, 31 insertions(+), 49 deletions(-)
hw/ppc/spapr_iommu.c +26 -49
@@ -22,13 +22,12 @@#include "kvm_ppc.h" #include "sysemu/dma.h" #include "exec/address-spaces.h" +#include "trace.h" #include "hw/ppc/spapr.h" #include <libfdt.h> -/* #define DEBUG_TCE */ -enum sPAPRTCEAccess {SPAPR_TCE_FAULT =0 ,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);uint64_t tce; - -#ifdef DEBUG_TCE -fprintf (stderr,"spapr_tce_translate liobn=0x%" PRIx32" addr=0x" -DMA_ADDR_FMT "\n" , tcet->liobn, addr); -#endif - -if (tcet->bypass) { -return (IOMMUTLBEntry ) { - .target_as = &address_space_memory, - .iova =0 , - .translated_addr =0 , - .addr_mask = ~(hwaddr )0 , - .perm =IOMMU_RW , - }; - } - -/* Check if we are in bound */ -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 ) { +IOMMUTLBEntry ret = { .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, + .iova =0 , + .translated_addr =0 , + .addr_mask = ~(hwaddr )0 , + .perm =IOMMU_NONE , }; + +if (tcet->bypass) { + ret.perm =IOMMU_RW ; + }else if (addr < tcet->window_size) { +/* Check if we are in bound */ + tce = tcet->table[addr >>SPAPR_TCE_PAGE_SHIFT ]; + ret.iova = addr & ~SPAPR_TCE_PAGE_MASK ; + 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); + +return ret; }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 ; -#ifdef DEBUG_TCE -fprintf (stderr,"spapr_iommu: New TCE table @ %p, liobn=0x%x, " -"table @ %p, fd=%d\n" , tcet, liobn, tcet->table, tcet->fd); -#endif +trace_spapr_iommu_new_table (tcet->liobn, tcet, tcet->table, tcet->fd);memory_region_init_iommu (&tcet->iommu,OBJECT (dev), &spapr_iommu_ops,"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 ioba = args[1 ];target_ulong tce = args[2 ]; +target_ulong ret =H_PARAMETER ;sPAPRTCETable *tcet =spapr_tce_find_by_liobn (liobn); ioba &= ~(SPAPR_TCE_PAGE_SIZE -1 );if (tcet) { -return put_tce_emu (tcet, ioba, tce); + ret =put_tce_emu (tcet, ioba, tce); } -#ifdef DEBUG_TCE -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 +trace_spapr_iommu_put (liobn, ioba, tce, ret); -return H_PARAMETER ; +return ret; } int spapr_dma_dt(void *fdt, int node_off, const char *propname,
trace-events +5 -0
@@ -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_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 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
Signature · 1 line
1.8.4.rc4
Alexander Graf
AppliedQuoted 3 lines · Alexey Kardashevskiy
This converts old style fprintf to traces.
Signed-off-by Alexey Kardashevskiy <[email protected]>
Thanks, applied with modified subject line. There are a lot more powerpc machines than sPAPR.
Alex
Quoted 8 lines · Alexander Graf
Quoted 3 lines · Alexey Kardashevskiy
This converts old style fprintf to traces.
Signed-off-by Alexey Kardashevskiy <[email protected]>Thanks, applied with modified subject line. There are a lot more powerpc machines than sPAPR.
But the patch fixes only spapr_iommu which is for spapr :-/
Signature · 1 line
Alexey
Quoted 11 lines · Alexey Kardashevskiy
Quoted 8 lines · Alexander Graf
Quoted 3 lines · Alexey Kardashevskiy
This converts old style fprintf to traces.
Signed-off-by Alexey Kardashevskiy <[email protected]>Thanks, applied with modified subject line. There are a lot more powerpc machines than sPAPR.
But the patch fixes only
spapr_iommuwhich is for spapr :-/
Exactly. And your subject line indicates that it fixes a "powerpc iommu" :). I changed it to:
PPC: spapr: iommu: rework traces
Alex
Quoted 11 lines · Alexey Kardashevskiy
Quoted 8 lines · Alexander Graf
Quoted 3 lines · Alexey Kardashevskiy
This converts old style fprintf to traces.
Signed-off-by Alexey Kardashevskiy <[email protected]>Thanks, applied with modified subject line. There are a lot more powerpc machines than sPAPR.
But the patch fixes only
spapr_iommuwhich is for spapr :-/
Ah. Understood, ignore my reply :)
Signature · 1 line
Alexey