From 74a636a612b5cbcda9d2dd8642594a11835cba0f Mon Sep 17 00:00:00 2001 From: Aram Santogidis Date: Tue, 8 Aug 2017 17:07:00 +0900 Subject: [PATCH] Updated structs to use completion{} and wait_queue_head_t{} and added struct size checkes in hfi1_aio_write() --- kernel/file_ops.c | 18 ++++++++++++---- kernel/include/hfi1/hfi.h | 31 ++++----------------------- kernel/include/hfi1/ihk_hfi1_common.h | 5 +++-- kernel/include/hfi1/iowait.h | 4 ++-- kernel/include/hfi1/user_sdma.h | 2 +- 5 files changed, 24 insertions(+), 36 deletions(-) diff --git a/kernel/file_ops.c b/kernel/file_ops.c index ba0d852f..733815d3 100644 --- a/kernel/file_ops.c +++ b/kernel/file_ops.c @@ -421,6 +421,11 @@ static ssize_t hfi1_aio_write(struct kiocb *kiocb, const struct iovec *iovec, { struct hfi1_filedata *fd = kiocb->ki_filp->private_data; #else + + +#define WARN_IF_SIZE_DIFFERENT(type, size)\ + if (sizeof(type) != size) kprintf("WARNING: sizeof( %s ) = %lu != %lu (on Linux)\n", #type, sizeof(type), size) + ssize_t hfi1_aio_write(void *private_data, const struct iovec *iovec, unsigned long dim) { struct hfi1_filedata *fd = private_data; @@ -428,10 +433,15 @@ ssize_t hfi1_aio_write(void *private_data, const struct iovec *iovec, unsigned l struct hfi1_user_sdma_pkt_q *pq = fd->pq; struct hfi1_user_sdma_comp_q *cq = fd->cq; int done = 0, reqs = 0; - kprintf("sizeof(struct hfi1_filedata) = %lu\n", sizeof(struct hfi1_filedata)); - kprintf("sizeof(struct hfi1_devdata) = %lu\n", sizeof(struct hfi1_devdata)); - kprintf("sizeof(struct iowait) = %lu\n", sizeof(struct iowait)); - kprintf("sizeof(struct hfi1_user_sdma_pkt_q) = %lu\n", sizeof(struct hfi1_user_sdma_pkt_q)); + + /* Double check the sizes */ + WARN_IF_SIZE_DIFFERENT(struct hfi1_filedata, 96); + WARN_IF_SIZE_DIFFERENT(struct hfi1_devdata, 7360); + WARN_IF_SIZE_DIFFERENT(struct iowait, 240); + WARN_IF_SIZE_DIFFERENT(struct hfi1_user_sdma_pkt_q, 376); + WARN_IF_SIZE_DIFFERENT(struct sdma_engine, 1472); + WARN_IF_SIZE_DIFFERENT(struct sdma_state, 64); + return 0; hfi1_cdbg(AIOWRITE, "+"); if (!cq || !pq) diff --git a/kernel/include/hfi1/hfi.h b/kernel/include/hfi1/hfi.h index d691329c..d9dcfa71 100644 --- a/kernel/include/hfi1/hfi.h +++ b/kernel/include/hfi1/hfi.h @@ -1261,7 +1261,6 @@ struct hfi1_devdata { }; #endif /* __HFI1_ORIG__ */ -//TODO: double check the order #ifndef __HFI1_ORIG__ /* Size on Linux side is 7360 Bytes */ @@ -1319,7 +1318,7 @@ struct hfi1_devdata { /* array of vl maps */ struct sdma_vl_map __rcu *sdma_map; //struct sdma_vl_map __rc *sdma_map - char sdma_unfreeze_wq[24]; //wait_queue_head_t sdma_unfreeze_wq; + wait_queue_head_t sdma_unfreeze_wq; atomic_t sdma_unfreeze_count; u32 lcb_access_count; @@ -1538,7 +1537,7 @@ struct hfi1_devdata { char rcverr_timer[80]; //struct timer_list rcverr_timer - char event_queue[24]; //wait_queue_head_t event_queue; + wait_queue_head_t event_queue; __le64 *rcvhdrtail_dummy_kvaddr; @@ -1552,7 +1551,7 @@ struct hfi1_devdata { atomic_t user_refcount; - char user_comp[32]; //struct completion user_comp + struct completion user_comp; bool eprom_available; bool aspm_supported; bool aspm_enabled; @@ -1592,31 +1591,11 @@ struct tid_rb_node; struct mmu_rb_node; struct mmu_rb_handler; -/* Private data for file operations */ -struct hfi1_filedata { - struct hfi1_ctxtdata *uctxt; - unsigned subctxt; - struct hfi1_user_sdma_comp_q *cq; - struct hfi1_user_sdma_pkt_q *pq; - /* for cpu affinity; -1 if none */ - int rec_cpu_num; - u32 tid_n_pinned; - struct mmu_rb_handler *handler; - struct tid_rb_node **entry_to_rb; - spinlock_t tid_lock; /* protect tid_[limit,used] counters */ - u32 tid_limit; - u32 tid_used; - u32 *invalid_tids; - u32 invalid_tid_idx; - /* protect invalid_tids array and invalid_tid_idx */ - spinlock_t invalid_lock; - struct mm_struct *mm; -}; #endif /* __HFI1_ORIG__ */ -#ifndef __HFI1_ORIG__ /* Original size on linux is 96 bytes */ /* Private data for file operations */ + struct hfi1_filedata { struct hfi1_ctxtdata *uctxt; unsigned subctxt; @@ -1635,8 +1614,6 @@ struct hfi1_filedata { void *mm; //struct mm_struct *mm; }; -#endif /* __HFI1_ORIG__ */ - #ifdef __HFI1_ORIG__ extern struct list_head hfi1_dev_list; diff --git a/kernel/include/hfi1/ihk_hfi1_common.h b/kernel/include/hfi1/ihk_hfi1_common.h index 9b1aad73..06fdc701 100644 --- a/kernel/include/hfi1/ihk_hfi1_common.h +++ b/kernel/include/hfi1/ihk_hfi1_common.h @@ -113,10 +113,11 @@ struct kref { atomic_t refcount; }; -typedef struct { +struct wait_queue_head_t { spinlock_t lock; struct list_head task_list; -} wait_queue_head_t ; +}; +typedef struct wait_queue_head_t wait_queue_head_t; struct completion { unsigned int done; diff --git a/kernel/include/hfi1/iowait.h b/kernel/include/hfi1/iowait.h index 1ac60605..05b7177c 100644 --- a/kernel/include/hfi1/iowait.h +++ b/kernel/include/hfi1/iowait.h @@ -144,8 +144,8 @@ struct iowait { void (*wakeup)(struct iowait *wait, int reason); void (*sdma_drained)(struct iowait *wait); seqlock_t *lock; - char wait_dma[24]; // wait_queue_head_t wait_dma; - char wait_pio[24]; // wait_queue_head_t wait_pio; + wait_queue_head_t wait_dma; + wait_queue_head_t wait_pio; atomic_t sdma_busy; atomic_t pio_busy; u32 count; diff --git a/kernel/include/hfi1/user_sdma.h b/kernel/include/hfi1/user_sdma.h index dd2d3763..a3027abe 100644 --- a/kernel/include/hfi1/user_sdma.h +++ b/kernel/include/hfi1/user_sdma.h @@ -127,7 +127,7 @@ struct hfi1_user_sdma_pkt_q { unsigned long *req_in_use; struct iowait busy; unsigned state; - char wait[24]; //wait_queue_head_t wait; + wait_queue_head_t wait; unsigned long unpinned; void *handler; // struct mmu_rb_handler *handler; atomic_t n_locked;