Commit 0b091fb3 authored by Mitko Haralanov's avatar Mitko Haralanov Committed by Doug Ledford

staging/hfi1: Enable TID caching feature

This commit "flips the switch" on the TID caching feature
implemented in this patch series.

As well as enabling the new feature by tying the new function
with the PSM API, it also cleans up the old unneeded code,
data structure members, and variables.

Due to difference in operation and information, the tracing
functions related to expected receives had to be changed. This
patch include these changes.

The tracing function changes could not be split into a separate
commit without including both tracing variants at the same time.
This would have caused other complications and ugliness.
Signed-off-by: default avatarMitko Haralanov <mitko.haralanov@intel.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 7e7a436e
This diff is collapsed.
......@@ -240,18 +240,6 @@ struct hfi1_ctxtdata {
u32 expected_count;
/* index of first expected TID entry. */
u32 expected_base;
/* cursor into the exp group sets */
atomic_t tidcursor;
/* number of exp TID groups assigned to the ctxt */
u16 numtidgroups;
/* size of exp TID group fields in tidusemap */
u16 tidmapcnt;
/* exp TID group usage bitfield array */
unsigned long *tidusemap;
/* pinned pages for exp sends, allocated at open */
struct page **tid_pg_list;
/* dma handles for exp tid pages */
dma_addr_t *physshadow;
struct exp_tid_set tid_group_list;
struct exp_tid_set tid_used_list;
......@@ -1660,8 +1648,6 @@ int get_platform_config_field(struct hfi1_devdata *dd,
enum platform_config_table_type_encoding table_type,
int table_index, int field_index, u32 *data, u32 len);
dma_addr_t hfi1_map_page(struct pci_dev *, struct page *, unsigned long,
size_t, int);
const char *get_unit_name(int unit);
/*
......
......@@ -962,13 +962,10 @@ void hfi1_free_ctxtdata(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd)
kfree(rcd->egrbufs.buffers);
sc_free(rcd->sc);
vfree(rcd->physshadow);
vfree(rcd->tid_pg_list);
vfree(rcd->user_event_mask);
vfree(rcd->subctxt_uregbase);
vfree(rcd->subctxt_rcvegrbuf);
vfree(rcd->subctxt_rcvhdr_base);
kfree(rcd->tidusemap);
kfree(rcd->opstats);
kfree(rcd);
}
......
......@@ -153,92 +153,130 @@ TRACE_EVENT(hfi1_receive_interrupt,
)
);
const char *print_u64_array(struct trace_seq *, u64 *, int);
TRACE_EVENT(hfi1_exp_tid_reg,
TP_PROTO(unsigned ctxt, u16 subctxt, u32 rarr,
u32 npages, unsigned long va, unsigned long pa,
dma_addr_t dma),
TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma),
TP_STRUCT__entry(
__field(unsigned, ctxt)
__field(u16, subctxt)
__field(u32, rarr)
__field(u32, npages)
__field(unsigned long, va)
__field(unsigned long, pa)
__field(dma_addr_t, dma)
),
TP_fast_assign(
__entry->ctxt = ctxt;
__entry->subctxt = subctxt;
__entry->rarr = rarr;
__entry->npages = npages;
__entry->va = va;
__entry->pa = pa;
__entry->dma = dma;
),
TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx, va:0x%lx dma:0x%llx",
__entry->ctxt,
__entry->subctxt,
__entry->rarr,
__entry->npages,
__entry->pa,
__entry->va,
__entry->dma
)
);
TRACE_EVENT(hfi1_exp_tid_map,
TP_PROTO(unsigned ctxt, u16 subctxt, int dir,
unsigned long *maps, u16 count),
TP_ARGS(ctxt, subctxt, dir, maps, count),
TRACE_EVENT(hfi1_exp_tid_unreg,
TP_PROTO(unsigned ctxt, u16 subctxt, u32 rarr, u32 npages,
unsigned long va, unsigned long pa, dma_addr_t dma),
TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma),
TP_STRUCT__entry(
__field(unsigned, ctxt)
__field(u16, subctxt)
__field(int, dir)
__field(u16, count)
__dynamic_array(unsigned long, maps, sizeof(*maps) * count)
__field(u32, rarr)
__field(u32, npages)
__field(unsigned long, va)
__field(unsigned long, pa)
__field(dma_addr_t, dma)
),
TP_fast_assign(
__entry->ctxt = ctxt;
__entry->subctxt = subctxt;
__entry->dir = dir;
__entry->count = count;
memcpy(__get_dynamic_array(maps), maps,
sizeof(*maps) * count);
__entry->rarr = rarr;
__entry->npages = npages;
__entry->va = va;
__entry->pa = pa;
__entry->dma = dma;
),
TP_printk("[%3u:%02u] %s tidmaps %s",
TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx, va:0x%lx dma:0x%llx",
__entry->ctxt,
__entry->subctxt,
(__entry->dir ? ">" : "<"),
print_u64_array(p, __get_dynamic_array(maps),
__entry->count)
__entry->rarr,
__entry->npages,
__entry->pa,
__entry->va,
__entry->dma
)
);
TRACE_EVENT(hfi1_exp_rcv_set,
TP_PROTO(unsigned ctxt, u16 subctxt, u32 tid,
unsigned long vaddr, u64 phys_addr, void *page),
TP_ARGS(ctxt, subctxt, tid, vaddr, phys_addr, page),
TRACE_EVENT(hfi1_exp_tid_inval,
TP_PROTO(unsigned ctxt, u16 subctxt, unsigned long va, u32 rarr,
u32 npages, dma_addr_t dma),
TP_ARGS(ctxt, subctxt, va, rarr, npages, dma),
TP_STRUCT__entry(
__field(unsigned, ctxt)
__field(u16, subctxt)
__field(u32, tid)
__field(unsigned long, vaddr)
__field(u64, phys_addr)
__field(void *, page)
__field(unsigned long, va)
__field(u32, rarr)
__field(u32, npages)
__field(dma_addr_t, dma)
),
TP_fast_assign(
__entry->ctxt = ctxt;
__entry->subctxt = subctxt;
__entry->tid = tid;
__entry->vaddr = vaddr;
__entry->phys_addr = phys_addr;
__entry->page = page;
__entry->va = va;
__entry->rarr = rarr;
__entry->npages = npages;
__entry->dma = dma;
),
TP_printk("[%u:%u] TID %u, vaddrs 0x%lx, physaddr 0x%llx, pgp %p",
TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx dma: 0x%llx",
__entry->ctxt,
__entry->subctxt,
__entry->tid,
__entry->vaddr,
__entry->phys_addr,
__entry->page
__entry->rarr,
__entry->npages,
__entry->va,
__entry->dma
)
);
TRACE_EVENT(hfi1_exp_rcv_free,
TP_PROTO(unsigned ctxt, u16 subctxt, u32 tid,
unsigned long phys, void *page),
TP_ARGS(ctxt, subctxt, tid, phys, page),
TRACE_EVENT(hfi1_mmu_invalidate,
TP_PROTO(unsigned ctxt, u16 subctxt, const char *type,
unsigned long start, unsigned long end),
TP_ARGS(ctxt, subctxt, type, start, end),
TP_STRUCT__entry(
__field(unsigned, ctxt)
__field(u16, subctxt)
__field(u32, tid)
__field(unsigned long, phys)
__field(void *, page)
__string(type, type)
__field(unsigned long, start)
__field(unsigned long, end)
),
TP_fast_assign(
__entry->ctxt = ctxt;
__entry->subctxt = subctxt;
__entry->tid = tid;
__entry->phys = phys;
__entry->page = page;
__assign_str(type, type);
__entry->start = start;
__entry->end = end;
),
TP_printk("[%u:%u] freeing TID %u, 0x%lx, pgp %p",
TP_printk("[%3u:%02u] MMU Invalidate (%s) 0x%lx - 0x%lx",
__entry->ctxt,
__entry->subctxt,
__entry->tid,
__entry->phys,
__entry->page
__get_str(type),
__entry->start,
__entry->end
)
);
#undef TRACE_SYSTEM
#define TRACE_SYSTEM hfi1_tx
......
......@@ -902,6 +902,8 @@ static int set_rcvarray_entry(struct file *fp, unsigned long vaddr,
return -EFAULT;
}
hfi1_put_tid(dd, rcventry, PT_EXPECTED, phys, ilog2(npages) + 1);
trace_hfi1_exp_tid_reg(uctxt->ctxt, fd->subctxt, rcventry,
npages, node->virt, node->phys, phys);
return 0;
}
......@@ -947,6 +949,10 @@ static void clear_tid_node(struct hfi1_filedata *fd, u16 subctxt,
struct hfi1_ctxtdata *uctxt = fd->uctxt;
struct hfi1_devdata *dd = uctxt->dd;
trace_hfi1_exp_tid_unreg(uctxt->ctxt, fd->subctxt, node->rcventry,
node->npages, node->virt, node->phys,
node->dma_addr);
hfi1_put_tid(dd, node->rcventry, PT_INVALID, 0, 0);
/*
* Make sure device has seen the write before we unpin the
......@@ -1023,6 +1029,9 @@ static void mmu_notifier_mem_invalidate(struct mmu_notifier *mn,
struct mmu_rb_node *node;
unsigned long addr = start;
trace_hfi1_mmu_invalidate(uctxt->ctxt, fd->subctxt, mmu_types[type],
start, end);
spin_lock(&fd->rb_lock);
while (addr < end) {
node = mmu_rb_search_by_addr(root, addr);
......@@ -1049,6 +1058,9 @@ static void mmu_notifier_mem_invalidate(struct mmu_notifier *mn,
if (node->freed)
continue;
trace_hfi1_exp_tid_inval(uctxt->ctxt, fd->subctxt, node->virt,
node->rcventry, node->npages,
node->dma_addr);
node->freed = true;
spin_lock(&fd->invalid_lock);
......
......@@ -54,20 +54,6 @@
#include "hfi.h"
/**
* hfi1_map_page - a safety wrapper around pci_map_page()
*
*/
dma_addr_t hfi1_map_page(struct pci_dev *hwdev, struct page *page,
unsigned long offset, size_t size, int direction)
{
dma_addr_t phys;
phys = pci_map_page(hwdev, page, offset, size, direction);
return phys;
}
int hfi1_acquire_user_pages(unsigned long vaddr, size_t npages, bool writable,
struct page **pages)
{
......
......@@ -66,7 +66,7 @@
* The major version changes when data structures change in an incompatible
* way. The driver must be the same for initialization to succeed.
*/
#define HFI1_USER_SWMAJOR 4
#define HFI1_USER_SWMAJOR 5
/*
* Minor version differences are always compatible
......@@ -241,11 +241,6 @@ struct hfi1_tid_info {
__u32 tidcnt;
/* length of transfer buffer programmed by this request */
__u32 length;
/*
* pointer to bitmap of TIDs used for this call;
* checked for being large enough at open
*/
__u64 tidmap;
};
struct hfi1_cmd {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment