Loading src/drivers/ata/ahci_elphel.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -96,8 +96,8 @@ static int elphel_port_start(struct ata_port *ap) // libahci_debug_state_dump(ap); // libahci_debug_state_dump(ap); // libahci_debug_state_dump(ap); // libahci_debug_state_dump(ap); libahci_debug_saxigp1_save(ap, 0x3000); //libahci_debug_saxigp1_save(ap, 0x3000); libahci_debug_saxigp1_save(ap, 0x3000); //libahci_debug_saxigp1_save(ap, 0x3000); return ahci_port_resume(ap); return ahci_port_resume(ap); Loading src/drivers/ata/libahci_debug.c +62 −16 Original line number Original line Diff line number Diff line Loading @@ -34,8 +34,13 @@ const size_t maxigp1_start = 0x80000000; // start of MAXIGP1 physical address ra const size_t maxigp1_size = 0x3000; // size of register memory to save const size_t maxigp1_size = 0x3000; // size of register memory to save const size_t buffer_offset = 0x40000; // start of dumping area (0xxxx, 1xxxx and 2xxxx are used for dma buffers const size_t buffer_offset = 0x40000; // start of dumping area (0xxxx, 1xxxx and 2xxxx are used for dma buffers const size_t counter_offset = 0x3fff8; // save page counter and page size with this offset in the buffer const size_t counter_offset = 0x3fff8; // save page counter and page size with this offset in the buffer const size_t fsm_state_offset = 0xffc; static void * ioptr = 0; // keep iomemory mapped forever static void * ioptr = 0; // keep iomemory mapped forever char *early_buff; static inline u32 libahci_debug_get_fsm_state(void); //static struct mem_buffer mem_buff; //static struct mem_buffer mem_buff; /* /* Loading Loading @@ -462,6 +467,7 @@ void libahci_debug_event(const struct ata_port *port, char *msg, size_t msg_sz) { { int len; int len; int i; int i; u32 tmp; char *format_msg = NULL; char *format_msg = NULL; unsigned long flags; unsigned long flags; unsigned int port_index = (port == NULL) ? 0 : port->port_no; unsigned int port_index = (port == NULL) ? 0 : port->port_no; Loading @@ -480,8 +486,11 @@ void libahci_debug_event(const struct ata_port *port, char *msg, size_t msg_sz) if (pos != NULL) { if (pos != NULL) { //i = libahci_debug_state_dump(port); //i = libahci_debug_state_dump(port); i = libahci_debug_saxigp1_save(port, 0x3000); tmp = libahci_debug_get_fsm_state(); len = snprintf(format_msg, LIBAHCI_DEBUG_BUFSZ, "%s [%08u; fsm: 0x%08x] %s\n", EVT_MARKER, i, tmp, msg); spin_lock_irqsave(&pos->debug_list_lock, flags); spin_lock_irqsave(&pos->debug_list_lock, flags); len = snprintf(format_msg, LIBAHCI_DEBUG_BUFSZ, "%s [%08u] %s\n", EVT_MARKER, i, msg); for (i = 0; i < len; i++) { for (i = 0; i < len; i++) { pos->libahci_debug_buf[(pos->tail+ i) % LIBAHCI_DEBUG_BUFSZ] = format_msg[i]; pos->libahci_debug_buf[(pos->tail+ i) % LIBAHCI_DEBUG_BUFSZ] = format_msg[i]; } } Loading @@ -495,6 +504,10 @@ void libahci_debug_event(const struct ata_port *port, char *msg, size_t msg_sz) } } kfree(format_msg); kfree(format_msg); } } } else { if (early_buff) { } } } } } EXPORT_SYMBOL_GPL(libahci_debug_event); EXPORT_SYMBOL_GPL(libahci_debug_event); Loading Loading @@ -761,8 +774,16 @@ EXPORT_SYMBOL_GPL(libahci_debug_state_dump); unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size) unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size) { { struct device *dev = ap->dev; struct device *dev; u32 * counter_save; u32 * counter_save; void *current_ptr; static size_t bytes_copied; const size_t end = 0x1000000; u32 *start_ptr; // ap pointer is not initialized on early loading stages, skip debug output if (ap) { dev = ap->dev; if (!ioptr) { if (!ioptr) { dev_err(dev, "saxigp1 memory is not mapped"); dev_err(dev, "saxigp1 memory is not mapped"); return 0; // should be non-zero when error, 0 is OK usually return 0; // should be non-zero when error, 0 is OK usually Loading @@ -771,19 +792,27 @@ unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size) dev_err(dev, "elphel_buf has not been allocated"); dev_err(dev, "elphel_buf has not been allocated"); return 0; // should be non-zero when error, 0 is OK usually return 0; // should be non-zero when error, 0 is OK usually } } } //if (bytes_copied < pElphel_buf->size * PAGE_SIZE - dump_size) { if (bytes_copied < end) { counter_save = (u32*) (pElphel_buf->vaddr + counter_offset); counter_save = (u32*) (pElphel_buf->vaddr + counter_offset); dev_err(dev, "Copying 0x%x bytes of data from saxigp1 to memory",dump_size); start_ptr = (u32 *)(pElphel_buf->vaddr + buffer_offset + (page_cntr * dump_size)); //dev_err(dev, "Copying 0x%x bytes of data from saxigp1 to memory",dump_size); memcpy_fromio(pElphel_buf->vaddr + buffer_offset + (page_cntr * dump_size), ioptr, dump_size); memcpy_fromio(pElphel_buf->vaddr + buffer_offset + (page_cntr * dump_size), ioptr, dump_size); counter_save[0] = page_cntr; counter_save[0] = page_cntr; counter_save[1] = dump_size; counter_save[1] = dump_size; page_cntr++; page_cntr++; bytes_copied += dump_size; } else { page_cntr = 0; } return page_cntr; return page_cntr; } } EXPORT_SYMBOL_GPL(libahci_debug_saxigp1_save); EXPORT_SYMBOL_GPL(libahci_debug_saxigp1_save); static void libahci_debug_buff_init(struct device *dev) static void libahci_debug_buff_init(struct device *dev) { { dev_info(dev, "Nothing to allocate - using elphel_buf allocated at startup"); dev_info(dev, "Nothing to allocate - using elphel_buf allocated at startup"); Loading @@ -803,6 +832,11 @@ static void libahci_debug_buff_init(struct device *dev) page_cntr = 0; page_cntr = 0; } } static inline u32 libahci_debug_get_fsm_state(void) { return ioread32(ioptr + fsm_state_offset); } static const struct file_operations libahci_debug_host_ops = { static const struct file_operations libahci_debug_host_ops = { .open = libahci_debug_host_open, .open = libahci_debug_host_open, .read = seq_read, .read = seq_read, Loading Loading @@ -856,6 +890,17 @@ static int libahci_debug_init_sg(void) return 0; return 0; } } int libahci_debug_init_early(struct device *dev) { early_buff = kzalloc(LIBAHCI_DEBUG_BUFSZ, GFP_KERNEL); if (!early_buff) { dev_err(dev, "unable to allocate mem for early buffer"); return -ENOMEM; } else { dev_info(dev, "early buffer allocated"); } } int libahci_debug_init(struct ata_host *host) int libahci_debug_init(struct ata_host *host) { { int i; int i; Loading Loading @@ -907,6 +952,7 @@ EXPORT_SYMBOL_GPL(libahci_debug_init); void libahci_debug_exit(void) void libahci_debug_exit(void) { { kfree(cmd.sg_buff); kfree(cmd.sg_buff); kfree(early_buff); debugfs_remove_recursive(debug_root); debugfs_remove_recursive(debug_root); } } EXPORT_SYMBOL_GPL(libahci_debug_exit); EXPORT_SYMBOL_GPL(libahci_debug_exit); Loading src/drivers/ata/libahci_debug.h +0 −1 Original line number Original line Diff line number Diff line Loading @@ -131,5 +131,4 @@ void libahci_debug_wait_flag(void); unsigned int libahci_debug_state_dump(struct ata_port *ap); unsigned int libahci_debug_state_dump(struct ata_port *ap); unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size); unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size); #endif /* _LIBAHCI_DEBUG_H_ */ #endif /* _LIBAHCI_DEBUG_H_ */ Loading
src/drivers/ata/ahci_elphel.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -96,8 +96,8 @@ static int elphel_port_start(struct ata_port *ap) // libahci_debug_state_dump(ap); // libahci_debug_state_dump(ap); // libahci_debug_state_dump(ap); // libahci_debug_state_dump(ap); libahci_debug_saxigp1_save(ap, 0x3000); //libahci_debug_saxigp1_save(ap, 0x3000); libahci_debug_saxigp1_save(ap, 0x3000); //libahci_debug_saxigp1_save(ap, 0x3000); return ahci_port_resume(ap); return ahci_port_resume(ap); Loading
src/drivers/ata/libahci_debug.c +62 −16 Original line number Original line Diff line number Diff line Loading @@ -34,8 +34,13 @@ const size_t maxigp1_start = 0x80000000; // start of MAXIGP1 physical address ra const size_t maxigp1_size = 0x3000; // size of register memory to save const size_t maxigp1_size = 0x3000; // size of register memory to save const size_t buffer_offset = 0x40000; // start of dumping area (0xxxx, 1xxxx and 2xxxx are used for dma buffers const size_t buffer_offset = 0x40000; // start of dumping area (0xxxx, 1xxxx and 2xxxx are used for dma buffers const size_t counter_offset = 0x3fff8; // save page counter and page size with this offset in the buffer const size_t counter_offset = 0x3fff8; // save page counter and page size with this offset in the buffer const size_t fsm_state_offset = 0xffc; static void * ioptr = 0; // keep iomemory mapped forever static void * ioptr = 0; // keep iomemory mapped forever char *early_buff; static inline u32 libahci_debug_get_fsm_state(void); //static struct mem_buffer mem_buff; //static struct mem_buffer mem_buff; /* /* Loading Loading @@ -462,6 +467,7 @@ void libahci_debug_event(const struct ata_port *port, char *msg, size_t msg_sz) { { int len; int len; int i; int i; u32 tmp; char *format_msg = NULL; char *format_msg = NULL; unsigned long flags; unsigned long flags; unsigned int port_index = (port == NULL) ? 0 : port->port_no; unsigned int port_index = (port == NULL) ? 0 : port->port_no; Loading @@ -480,8 +486,11 @@ void libahci_debug_event(const struct ata_port *port, char *msg, size_t msg_sz) if (pos != NULL) { if (pos != NULL) { //i = libahci_debug_state_dump(port); //i = libahci_debug_state_dump(port); i = libahci_debug_saxigp1_save(port, 0x3000); tmp = libahci_debug_get_fsm_state(); len = snprintf(format_msg, LIBAHCI_DEBUG_BUFSZ, "%s [%08u; fsm: 0x%08x] %s\n", EVT_MARKER, i, tmp, msg); spin_lock_irqsave(&pos->debug_list_lock, flags); spin_lock_irqsave(&pos->debug_list_lock, flags); len = snprintf(format_msg, LIBAHCI_DEBUG_BUFSZ, "%s [%08u] %s\n", EVT_MARKER, i, msg); for (i = 0; i < len; i++) { for (i = 0; i < len; i++) { pos->libahci_debug_buf[(pos->tail+ i) % LIBAHCI_DEBUG_BUFSZ] = format_msg[i]; pos->libahci_debug_buf[(pos->tail+ i) % LIBAHCI_DEBUG_BUFSZ] = format_msg[i]; } } Loading @@ -495,6 +504,10 @@ void libahci_debug_event(const struct ata_port *port, char *msg, size_t msg_sz) } } kfree(format_msg); kfree(format_msg); } } } else { if (early_buff) { } } } } } EXPORT_SYMBOL_GPL(libahci_debug_event); EXPORT_SYMBOL_GPL(libahci_debug_event); Loading Loading @@ -761,8 +774,16 @@ EXPORT_SYMBOL_GPL(libahci_debug_state_dump); unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size) unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size) { { struct device *dev = ap->dev; struct device *dev; u32 * counter_save; u32 * counter_save; void *current_ptr; static size_t bytes_copied; const size_t end = 0x1000000; u32 *start_ptr; // ap pointer is not initialized on early loading stages, skip debug output if (ap) { dev = ap->dev; if (!ioptr) { if (!ioptr) { dev_err(dev, "saxigp1 memory is not mapped"); dev_err(dev, "saxigp1 memory is not mapped"); return 0; // should be non-zero when error, 0 is OK usually return 0; // should be non-zero when error, 0 is OK usually Loading @@ -771,19 +792,27 @@ unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size) dev_err(dev, "elphel_buf has not been allocated"); dev_err(dev, "elphel_buf has not been allocated"); return 0; // should be non-zero when error, 0 is OK usually return 0; // should be non-zero when error, 0 is OK usually } } } //if (bytes_copied < pElphel_buf->size * PAGE_SIZE - dump_size) { if (bytes_copied < end) { counter_save = (u32*) (pElphel_buf->vaddr + counter_offset); counter_save = (u32*) (pElphel_buf->vaddr + counter_offset); dev_err(dev, "Copying 0x%x bytes of data from saxigp1 to memory",dump_size); start_ptr = (u32 *)(pElphel_buf->vaddr + buffer_offset + (page_cntr * dump_size)); //dev_err(dev, "Copying 0x%x bytes of data from saxigp1 to memory",dump_size); memcpy_fromio(pElphel_buf->vaddr + buffer_offset + (page_cntr * dump_size), ioptr, dump_size); memcpy_fromio(pElphel_buf->vaddr + buffer_offset + (page_cntr * dump_size), ioptr, dump_size); counter_save[0] = page_cntr; counter_save[0] = page_cntr; counter_save[1] = dump_size; counter_save[1] = dump_size; page_cntr++; page_cntr++; bytes_copied += dump_size; } else { page_cntr = 0; } return page_cntr; return page_cntr; } } EXPORT_SYMBOL_GPL(libahci_debug_saxigp1_save); EXPORT_SYMBOL_GPL(libahci_debug_saxigp1_save); static void libahci_debug_buff_init(struct device *dev) static void libahci_debug_buff_init(struct device *dev) { { dev_info(dev, "Nothing to allocate - using elphel_buf allocated at startup"); dev_info(dev, "Nothing to allocate - using elphel_buf allocated at startup"); Loading @@ -803,6 +832,11 @@ static void libahci_debug_buff_init(struct device *dev) page_cntr = 0; page_cntr = 0; } } static inline u32 libahci_debug_get_fsm_state(void) { return ioread32(ioptr + fsm_state_offset); } static const struct file_operations libahci_debug_host_ops = { static const struct file_operations libahci_debug_host_ops = { .open = libahci_debug_host_open, .open = libahci_debug_host_open, .read = seq_read, .read = seq_read, Loading Loading @@ -856,6 +890,17 @@ static int libahci_debug_init_sg(void) return 0; return 0; } } int libahci_debug_init_early(struct device *dev) { early_buff = kzalloc(LIBAHCI_DEBUG_BUFSZ, GFP_KERNEL); if (!early_buff) { dev_err(dev, "unable to allocate mem for early buffer"); return -ENOMEM; } else { dev_info(dev, "early buffer allocated"); } } int libahci_debug_init(struct ata_host *host) int libahci_debug_init(struct ata_host *host) { { int i; int i; Loading Loading @@ -907,6 +952,7 @@ EXPORT_SYMBOL_GPL(libahci_debug_init); void libahci_debug_exit(void) void libahci_debug_exit(void) { { kfree(cmd.sg_buff); kfree(cmd.sg_buff); kfree(early_buff); debugfs_remove_recursive(debug_root); debugfs_remove_recursive(debug_root); } } EXPORT_SYMBOL_GPL(libahci_debug_exit); EXPORT_SYMBOL_GPL(libahci_debug_exit); Loading
src/drivers/ata/libahci_debug.h +0 −1 Original line number Original line Diff line number Diff line Loading @@ -131,5 +131,4 @@ void libahci_debug_wait_flag(void); unsigned int libahci_debug_state_dump(struct ata_port *ap); unsigned int libahci_debug_state_dump(struct ata_port *ap); unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size); unsigned int libahci_debug_saxigp1_save(struct ata_port *ap, size_t dump_size); #endif /* _LIBAHCI_DEBUG_H_ */ #endif /* _LIBAHCI_DEBUG_H_ */