Commit 0a055f61 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Remove unnecessary dma_sync_sg_

parent 628a0bcc
...@@ -32,6 +32,10 @@ ...@@ -32,6 +32,10 @@
#define PROP_NAME_CLB_OFFS "clb_offs" #define PROP_NAME_CLB_OFFS "clb_offs"
#define PROP_NAME_FB_OFFS "fb_offs" #define PROP_NAME_FB_OFFS "fb_offs"
bool crash_drv = false;
module_param(crash_drv, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(sh_drv, "Set or reset crash driver flag");
static struct ata_port_operations ahci_elphel_ops; static struct ata_port_operations ahci_elphel_ops;
static const struct ata_port_info ahci_elphel_port_info; static const struct ata_port_info ahci_elphel_port_info;
static struct scsi_host_template ahci_platform_sht; static struct scsi_host_template ahci_platform_sht;
...@@ -55,6 +59,7 @@ static int elphel_port_start(struct ata_port *ap) ...@@ -55,6 +59,7 @@ static int elphel_port_start(struct ata_port *ap)
const struct elphel_ahci_priv *dpriv = hpriv->plat_data; const struct elphel_ahci_priv *dpriv = hpriv->plat_data;
libahci_debug_init(ap->host); libahci_debug_init(ap->host);
libahci_debug_crash_set(crash_drv);
dev_dbg(dev, "starting port %d", ap->port_no); dev_dbg(dev, "starting port %d", ap->port_no);
#ifdef DEBUG_EVENT_ELPHEL #ifdef DEBUG_EVENT_ELPHEL
...@@ -234,12 +239,6 @@ static void elphel_qc_prep(struct ata_queued_cmd *qc) ...@@ -234,12 +239,6 @@ static void elphel_qc_prep(struct ata_queued_cmd *qc)
ahci_sg[n_elem].addr_hi = cpu_to_le32((addr >> 16) >> 16); ahci_sg[n_elem].addr_hi = cpu_to_le32((addr >> 16) >> 16);
ahci_sg[n_elem].flags_size = cpu_to_le32(sg_len - 1); ahci_sg[n_elem].flags_size = cpu_to_le32(sg_len - 1);
} }
if (qc->dma_dir == DMA_TO_DEVICE) {
dma_sync_sg_for_device(&qc->dev->tdev, qc->sg, qc->n_elem, qc->dma_dir);
} else if (qc->dma_dir == DMA_FROM_DEVICE) {
dma_sync_sg_for_cpu(&qc->dev->tdev, qc->sg, qc->n_elem, qc->dma_dir);
}
} }
/* /*
......
...@@ -2058,7 +2058,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc) ...@@ -2058,7 +2058,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
*/ */
// Elphel; Need to wrap with dma_sync_single_for_cpu / dma_sync_single_for_device, move to in ahci_elphel.c // Elphel; Need to wrap with dma_sync_single_for_cpu / dma_sync_single_for_device, move to in ahci_elphel.c
dma_sync_single_for_cpu(qc->dev, pp->cmd_tbl_dma, AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE); dma_sync_single_for_cpu(&qc->dev->tdev, pp->cmd_tbl_dma, AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE);
cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ; cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl); ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl);
...@@ -2097,7 +2097,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc) ...@@ -2097,7 +2097,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
//ahci_fill_cmd_slot(pp, tag, opts); //ahci_fill_cmd_slot(pp, tag, opts);
// Elphel move to ahci_elphel.c. See if the SG dma should also be handed to dma here // Elphel move to ahci_elphel.c. See if the SG dma should also be handed to dma here
dma_sync_single_for_device(qc->dev, pp->cmd_tbl_dma, AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE); dma_sync_single_for_device(&qc->dev->tdev, pp->cmd_tbl_dma, AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE);
WARN_ON (qc->tag); WARN_ON (qc->tag);
} }
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#include <asm/outercache.h> #include <asm/outercache.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <elphel/elphel393-mem.h> #include <elphel/elphel393-mem.h>
#include <linux/jiffies.h>
#include "libahci_debug.h" #include "libahci_debug.h"
#include <asm/io.h> // ioremap(), copy_fromio #include <asm/io.h> // ioremap(), copy_fromio
#include <linux/jiffies.h>
/* /*
struct elphel_buf_t struct elphel_buf_t
{ {
...@@ -31,6 +31,7 @@ static struct dentry *debug_root = NULL; ...@@ -31,6 +31,7 @@ static struct dentry *debug_root = NULL;
static struct libahci_debug_list debug_list = {.debug = 0}; static struct libahci_debug_list debug_list = {.debug = 0};
static struct ahci_cmd cmd; static struct ahci_cmd cmd;
static bool load_flag = false; static bool load_flag = false;
static bool error_flag = false;
const size_t maxigp1_start = 0x80000000; // start of MAXIGP1 physical address range const size_t maxigp1_start = 0x80000000; // start of MAXIGP1 physical address range
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
...@@ -692,6 +693,36 @@ static ssize_t libahci_debug_load(struct file *f, const char __user *buff, size_ ...@@ -692,6 +693,36 @@ static ssize_t libahci_debug_load(struct file *f, const char __user *buff, size_
return buff_sz; return buff_sz;
} }
static ssize_t libahci_debug_crash_write(struct file *f, const char __user *buff, size_t buff_sz, loff_t *ppos)
{
if (buff[0] == '1') {
error_flag = true;
} else {
error_flag = false;
}
return buff_sz;
}
static ssize_t libahci_debug_crash_read(struct file *f, char __user *buff, size_t buff_sz, loff_t *ppos)
{
char *tmp = error_flag ? "1" : "0";
copy_to_user(buff, tmp, 2);
return 2;
}
void libahci_debug_crash_here(void)
{
BUG_ON(error_flag == true);
}
EXPORT_SYMBOL_GPL(libahci_debug_crash_here);
void libahci_debug_crash_set(bool val)
{
error_flag = (val == 0) ? false : true;
}
EXPORT_SYMBOL_GPL(libahci_debug_crash_set);
/* /*
* This function waits until the loading flag is set through debugfs file. * This function waits until the loading flag is set through debugfs file.
* The state of the flag is checked every 100ms. * The state of the flag is checked every 100ms.
...@@ -881,6 +912,11 @@ static const struct file_operations libahci_debug_load_ops= { ...@@ -881,6 +912,11 @@ static const struct file_operations libahci_debug_load_ops= {
.write = libahci_debug_load, .write = libahci_debug_load,
}; };
static const struct file_operations libahci_debug_error_ops= {
.write = libahci_debug_crash_write,
.read = libahci_debug_crash_read,
};
static int libahci_debug_init_sg(void) static int libahci_debug_init_sg(void)
{ {
cmd.sg_buff = kzalloc(CMD_DMA_BUFSZ, GFP_KERNEL); cmd.sg_buff = kzalloc(CMD_DMA_BUFSZ, GFP_KERNEL);
...@@ -922,6 +958,8 @@ int libahci_debug_init(struct ata_host *host) ...@@ -922,6 +958,8 @@ int libahci_debug_init(struct ata_host *host)
debug_root, host, &libahci_debug_host_ops); debug_root, host, &libahci_debug_host_ops);
debugfs_create_file("loading", 0222, debugfs_create_file("loading", 0222,
debug_root, host, &libahci_debug_load_ops); debug_root, host, &libahci_debug_load_ops);
debugfs_create_file("crash_on_error", 0644,
debug_root, host, &libahci_debug_error_ops);
/* Create subdir for each port and add there several files: /* Create subdir for each port and add there several files:
* one for port registers, one for port events log and * one for port registers, one for port events log and
......
...@@ -130,5 +130,8 @@ void libahci_debug_exec_cmd(struct ata_port *ap); ...@@ -130,5 +130,8 @@ void libahci_debug_exec_cmd(struct ata_port *ap);
void libahci_debug_wait_flag(void); 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);
void libahci_debug_crash_here(void);
void libahci_debug_crash_set(bool val);
void libahci_debug_timestamp(cycles_t start_c, cycles_t end_c, unsigned long start_j, unsigned long end_j, u32 id);
#endif /* _LIBAHCI_DEBUG_H_ */ #endif /* _LIBAHCI_DEBUG_H_ */
...@@ -1564,6 +1564,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, ...@@ -1564,6 +1564,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
unsigned long flags; unsigned long flags;
unsigned int err_mask; unsigned int err_mask;
int rc; int rc;
dev_dbg(ap->host->dev, "libata-core.c:ata_exec_internal_sg() ap->pflags = 0x%x, link->eh_info.action=0x%08x\n",ap->pflags,link->eh_info.action); dev_dbg(ap->host->dev, "libata-core.c:ata_exec_internal_sg() ap->pflags = 0x%x, link->eh_info.action=0x%08x\n",ap->pflags,link->eh_info.action);
spin_lock_irqsave(ap->lock, flags); spin_lock_irqsave(ap->lock, flags);
...@@ -4894,15 +4895,6 @@ void ata_qc_complete(struct ata_queued_cmd *qc) ...@@ -4894,15 +4895,6 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
* taken care of. * taken care of.
*/ */
dev_dbg(&qc->dev->tdev, "%s: qc->dma_dir: %d", __func__, qc->dma_dir);
if (qc->dma_dir == DMA_TO_DEVICE) {
dev_dbg(&qc->dev->tdev, "%s: dma_sync_sg_for_device, qc->dma_dir: %d", __func__, qc->dma_dir);
dma_sync_sg_for_device(&qc->dev->tdev, qc->sg, qc->n_elem, qc->dma_dir);
} else if (qc->dma_dir == DMA_FROM_DEVICE) {
dev_dbg(&qc->dev->tdev, "%s: dma_sync_sg_for_cpu, qc->dma_dir: %d", __func__, qc->dma_dir);
dma_sync_sg_for_cpu(&qc->dev->tdev, qc->sg, qc->n_elem, qc->dma_dir);
}
if (ap->ops->error_handler) { if (ap->ops->error_handler) {
struct ata_device *dev = qc->dev; struct ata_device *dev = qc->dev;
struct ata_eh_info *ehi = &dev->link->eh_info; struct ata_eh_info *ehi = &dev->link->eh_info;
......
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
#include "libata.h" #include "libata.h"
#include "libahci_debug.h"
enum { enum {
/* speed down verdicts */ /* speed down verdicts */
ATA_EH_SPDN_NCQ_OFF = (1 << 0), ATA_EH_SPDN_NCQ_OFF = (1 << 0),
...@@ -2556,6 +2558,9 @@ static void ata_eh_link_report(struct ata_link *link) ...@@ -2556,6 +2558,9 @@ static void ata_eh_link_report(struct ata_link *link)
res->device, qc->err_mask, ata_err_string(qc->err_mask), res->device, qc->err_mask, ata_err_string(qc->err_mask),
qc->err_mask & AC_ERR_NCQ ? " <F>" : ""); qc->err_mask & AC_ERR_NCQ ? " <F>" : "");
// elphel test: crash driver here to stop its execution and preserve memory state
libahci_debug_crash_here();
#ifdef CONFIG_ATA_VERBOSE_ERROR #ifdef CONFIG_ATA_VERBOSE_ERROR
if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ |
ATA_ERR)) { ATA_ERR)) {
......
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