arcmsr: Support Areca new SATA Raid Adapter ARC1214/1224/1264/1284
PATCH 1/1 arcmsr: Support Areca new SATA Raid Adapter ARC1214/1224/1264/1284
From: Ching <[email protected]>
Support Areca new SATA Raid Adapter ARC1214/1224/1264/1284 Modify maximum outstanding command number.
Notify command complete with auto request sense data.
Fix bug of updating adapter firmware through ioctl(ARCHTTP) interface. Fix coding style warning.
Fix compiling warning.
Fix ARC188x hardware reset.
Fix indent coding.
This patch is for arcmsr source code in kernel tree. The following path code is also available in attached file.
---
drivers/scsi/arcmsr/arcmsr_attr.c +149 -112
@@ -59,64 +59,87 @@struct device_attribute *arcmsr_host_attrs[]; -static ssize_t arcmsr_sysfs_iop_message_read (struct file *filp, -struct kobject *kobj, -struct bin_attribute *bin, -char *buf,loff_t off, -size_t count) +static ssize_t +arcmsr_sysfs_iop_message_read (struct file *filp, +struct kobject *kobj, +struct bin_attribute *bin, +char *buf,loff_t off, +size_t count) { - struct device *dev = container_of(kobj,struct device,kobj); + struct device *dev = container_of(kobj, struct device, kobj);struct Scsi_Host *host =class_to_shost (dev); -struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; +struct AdapterControlBlock *acb = + (struct AdapterControlBlock *)host->hostdata;uint8_t *pQbuffer,*ptmpQbuffer;int32_t allxfer_len =0 ; +unsigned long flags;if (!capable (CAP_SYS_ADMIN ))return -EACCES ;/* do message unit read. */ ptmpQbuffer = (uint8_t *)buf; -while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex) - && (allxfer_len <1031 )) { +spin_lock_irqsave (&acb->rqbuffer_lock, flags); +if (acb->rqbuf_firstindex != acb->rqbuf_lastindex) { pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex]; -memcpy (ptmpQbuffer, pQbuffer,1 ); - acb->rqbuf_firstindex++; - acb->rqbuf_firstindex %=ARCMSR_MAX_QBUFFER ; - ptmpQbuffer++; - allxfer_len++; +if (acb->rqbuf_firstindex > acb->rqbuf_lastindex) { +if ((ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex) >=1032 ) { +memcpy ((void *)ptmpQbuffer, (const void *)pQbuffer,1032 ); + acb->rqbuf_firstindex +=1032 ; + acb->rqbuf_firstindex %=ARCMSR_MAX_QBUFFER ; + allxfer_len =1032 ; + }else { +if (((ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex) + acb->rqbuf_lastindex) >1032 ) { +memcpy ((void *)ptmpQbuffer, (const void *)pQbuffer,ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex); + ptmpQbuffer +=ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex; +memcpy ((void *)ptmpQbuffer, (const void *)acb->rqbuffer,1032 - (ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex)); + acb->rqbuf_firstindex =1032 - (ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex); + allxfer_len =1032 ; + }else { +memcpy ((void *)ptmpQbuffer, (const void *)pQbuffer,ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex); + ptmpQbuffer +=ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex; +memcpy ((void *)ptmpQbuffer, (const void *)acb->rqbuffer, acb->rqbuf_lastindex); + allxfer_len =ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex + acb->rqbuf_lastindex; + acb->rqbuf_firstindex = acb->rqbuf_lastindex; + } + } + }else { +if ((acb->rqbuf_lastindex - acb->rqbuf_firstindex) >1032 ) { +memcpy ((void *)ptmpQbuffer, (const void *)pQbuffer,1032 ); + acb->rqbuf_firstindex +=1032 ; + allxfer_len =1032 ; + }else { +memcpy ((void *)ptmpQbuffer, (const void *)pQbuffer, acb->rqbuf_lastindex - acb->rqbuf_firstindex); + allxfer_len = acb->rqbuf_lastindex - acb->rqbuf_firstindex; + acb->rqbuf_firstindex = acb->rqbuf_lastindex; + } + } }if (acb->acb_flags &ACB_F_IOPDATA_OVERFLOW ) {struct QBUFFER __iomem *prbuffer; -uint8_t __iomem *iop_data; -int32_t iop_len; - acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW ; prbuffer =arcmsr_get_iop_rqbuffer (acb); - iop_data = prbuffer->data; - iop_len =readl (&prbuffer->data_len); -while (iop_len >0 ) { - acb->rqbuffer[acb->rqbuf_lastindex] =readb (iop_data); - acb->rqbuf_lastindex++; - acb->rqbuf_lastindex %=ARCMSR_MAX_QBUFFER ; - iop_data++; - iop_len--; - } -arcmsr_iop_message_read (acb); +if (arcmsr_Read_iop_rqbuffer_data (acb, prbuffer) ==0 ) + acb->acb_flags |=ACB_F_IOPDATA_OVERFLOW ; } -return (allxfer_len); +spin_unlock_irqrestore (&acb->rqbuffer_lock, flags); +return allxfer_len; } -static ssize_t arcmsr_sysfs_iop_message_write (struct file *filp, -struct kobject *kobj, -struct bin_attribute *bin, -char *buf,loff_t off, -size_t count) +static ssize_t +arcmsr_sysfs_iop_message_write (struct file *filp, +struct kobject *kobj, +struct bin_attribute *bin, +char *buf,loff_t off, +size_t count) { - struct device *dev = container_of(kobj,struct device,kobj); + struct device *dev = container_of(kobj, struct device, kobj);struct Scsi_Host *host =class_to_shost (dev); -struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; +struct AdapterControlBlock *acb = + (struct AdapterControlBlock *)host->hostdata;int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex;uint8_t *pQbuffer, *ptmpuserbuffer; +unsigned long flags;if (!capable (CAP_SYS_ADMIN ))return -EACCES ;
@@ -125,62 +148,69 @@ static ssize_t arcmsr_sysfs_iop_message_/* do message unit write. */ ptmpuserbuffer = (uint8_t *)buf; user_len = (int32_t )count; +spin_lock_irqsave (&acb->wqbuffer_lock, flags); wqbuf_lastindex = acb->wqbuf_lastindex; wqbuf_firstindex = acb->wqbuf_firstindex;if (wqbuf_lastindex != wqbuf_firstindex) { -arcmsr_post_ioctldata2iop (acb); +arcmsr_write_ioctldata2iop (acb); +spin_unlock_irqrestore (&acb->wqbuffer_lock, flags);return 0 ;/*need retry*/ }else { my_empty_len = (wqbuf_firstindex-wqbuf_lastindex -1 ) - &(ARCMSR_MAX_QBUFFER -1 ); + &(ARCMSR_MAX_QBUFFER -1 );if (my_empty_len >= user_len) {while (user_len >0 ) { - pQbuffer = - &acb->wqbuffer[acb->wqbuf_lastindex]; -memcpy (pQbuffer, ptmpuserbuffer,1 ); + pQbuffer = &acb->wqbuffer[acb->wqbuf_lastindex]; +memcpy ((void *)pQbuffer, (const void *)ptmpuserbuffer,1 ); acb->wqbuf_lastindex++; acb->wqbuf_lastindex %=ARCMSR_MAX_QBUFFER ; ptmpuserbuffer++; user_len--; } -if (acb->acb_flags &ACB_F_MESSAGE_WQBUFFER_CLEARED ) { - acb->acb_flags &= - ~ACB_F_MESSAGE_WQBUFFER_CLEARED ; -arcmsr_post_ioctldata2iop (acb); +if (acb->acb_flags & +ACB_F_MESSAGE_WQBUFFER_CLEARED ) { + acb->acb_flags &= ~ACB_F_MESSAGE_WQBUFFER_CLEARED ; +arcmsr_write_ioctldata2iop (acb); } +spin_unlock_irqrestore (&acb->wqbuffer_lock, flags);return count; }else { +spin_unlock_irqrestore (&acb->wqbuffer_lock, flags);return 0 ;/*need retry*/ } } } -static ssize_t arcmsr_sysfs_iop_message_clear (struct file *filp, -struct kobject *kobj, -struct bin_attribute *bin, -char *buf,loff_t off, -size_t count) +static ssize_t +arcmsr_sysfs_iop_message_clear (struct file *filp, +struct kobject *kobj, +struct bin_attribute *bin, +char *buf,loff_t off, +size_t count) { - struct device *dev = container_of(kobj,struct device,kobj); + struct device *dev = container_of(kobj, struct device, kobj);struct Scsi_Host *host =class_to_shost (dev); -struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; +struct AdapterControlBlock *acb = + (struct AdapterControlBlock *)host->hostdata;uint8_t *pQbuffer; +unsigned long flags;if (!capable (CAP_SYS_ADMIN ))return -EACCES ; -if (acb->acb_flags &ACB_F_IOPDATA_OVERFLOW ) { - acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW ; -arcmsr_iop_message_read (acb); - } +arcmsr_clear_iop2drv_rqueue_buffer (acb); acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |ACB_F_MESSAGE_RQBUFFER_CLEARED |ACB_F_MESSAGE_WQBUFFER_READED ); +spin_lock_irqsave (&acb->rqbuffer_lock, flags); acb->rqbuf_firstindex =0 ; acb->rqbuf_lastindex =0 ; +spin_unlock_irqrestore (&acb->rqbuffer_lock, flags); +spin_lock_irqsave (&acb->wqbuffer_lock, flags); acb->wqbuf_firstindex =0 ; acb->wqbuf_lastindex =0 ; +spin_unlock_irqrestore (&acb->wqbuffer_lock, flags); pQbuffer = acb->rqbuffer;memset (pQbuffer,0 ,sizeof (struct QBUFFER )); pQbuffer = acb->wqbuffer;
@@ -215,31 +245,37 @@ static struct bin_attribute arcmsr_sysfs .write = arcmsr_sysfs_iop_message_clear, }; -int arcmsr_alloc_sysfs_attr (struct AdapterControlBlock *acb) +int +arcmsr_alloc_sysfs_attr (struct AdapterControlBlock *acb) {struct Scsi_Host *host = acb->host;int error; - error =sysfs_create_bin_file (&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); + error =sysfs_create_bin_file (&host->shost_dev.kobj, + &arcmsr_sysfs_message_read_attr);if (error) { -printk (KERN_ERR "arcmsr: alloc sysfs mu_read failed\n" ); +pr_err ("arcmsr: alloc sysfs mu_read failed\n" ); goto error_bin_file_message_read; } - error =sysfs_create_bin_file (&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); + error =sysfs_create_bin_file (&host->shost_dev.kobj, + &arcmsr_sysfs_message_write_attr);if (error) { -printk (KERN_ERR "arcmsr: alloc sysfs mu_write failed\n" ); +pr_err ("arcmsr: alloc sysfs mu_write failed\n" ); goto error_bin_file_message_write; } - error =sysfs_create_bin_file (&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); + error =sysfs_create_bin_file (&host->shost_dev.kobj, + &arcmsr_sysfs_message_clear_attr);if (error) { -printk (KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n" ); +pr_err ("arcmsr: alloc sysfs mu_clear failed\n" ); goto error_bin_file_message_clear; }return 0 ; error_bin_file_message_clear: -sysfs_remove_bin_file (&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); +sysfs_remove_bin_file (&host->shost_dev.kobj, + &arcmsr_sysfs_message_write_attr); error_bin_file_message_write: -sysfs_remove_bin_file (&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); +sysfs_remove_bin_file (&host->shost_dev.kobj, + &arcmsr_sysfs_message_read_attr); error_bin_file_message_read:return error; }
@@ -248,30 +284,30 @@ void arcmsr_free_sysfs_attr(struct Adapt {struct Scsi_Host *host = acb->host; -sysfs_remove_bin_file (&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); -sysfs_remove_bin_file (&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); -sysfs_remove_bin_file (&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); +sysfs_remove_bin_file (&host->shost_dev.kobj, + &arcmsr_sysfs_message_clear_attr); +sysfs_remove_bin_file (&host->shost_dev.kobj, + &arcmsr_sysfs_message_write_attr); +sysfs_remove_bin_file (&host->shost_dev.kobj, + &arcmsr_sysfs_message_read_attr); } -static ssize_t arcmsr_attr_host_driver_version (struct device *dev, -struct device_attribute *attr,char *buf) +struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE , -"%s\n" , +return snprintf (buf,PAGE_SIZE ,"%s\n" ,ARCMSR_DRIVER_VERSION ); }static ssize_t arcmsr_attr_host_driver_posted_cmd (struct device *dev, -struct device_attribute *attr,char *buf) +struct device_attribute *attr,char *buf) {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; -return snprintf (buf,PAGE_SIZE , -"%4d\n" , + (struct AdapterControlBlock *)host->hostdata; +return snprintf (buf,PAGE_SIZE ,"%4d\n" ,atomic_read (&acb->ccboutstandingcount)); }
@@ -281,9 +317,8 @@ arcmsr_attr_host_driver_reset(struct dev {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; -return snprintf (buf,PAGE_SIZE , -"%4d\n" , + (struct AdapterControlBlock *)host->hostdata; +return snprintf (buf,PAGE_SIZE ,"%4d\n" , acb->num_resets); }
@@ -293,21 +328,19 @@ arcmsr_attr_host_driver_abort(struct dev {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; -return snprintf (buf,PAGE_SIZE , -"%4d\n" , + (struct AdapterControlBlock *)host->hostdata; +return snprintf (buf,PAGE_SIZE ,"%4d\n" , acb->num_aborts); }static ssize_t -arcmsr_attr_host_fw_model (struct device *dev,struct device_attribute *attr, -char *buf) +arcmsr_attr_host_fw_model (struct device *dev, +struct device_attribute *attr,char *buf) {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; -return snprintf (buf,PAGE_SIZE , -"%s\n" , + (struct AdapterControlBlock *)host->hostdata; +return snprintf (buf,PAGE_SIZE ,"%s\n" , acb->firm_model); }
@@ -317,10 +350,8 @@ arcmsr_attr_host_fw_version(struct devic {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; - -return snprintf (buf,PAGE_SIZE , -"%s\n" , + (struct AdapterControlBlock *)host->hostdata; +return snprintf (buf,PAGE_SIZE ,"%s\n" , acb->firm_version); }
@@ -330,10 +361,9 @@ arcmsr_attr_host_fw_request_len(struct d {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; + (struct AdapterControlBlock *)host->hostdata; -return snprintf (buf,PAGE_SIZE , -"%4d\n" , +return snprintf (buf,PAGE_SIZE ,"%4d\n" , acb->firm_request_len); }
@@ -343,10 +373,9 @@ arcmsr_attr_host_fw_numbers_queue(struct {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; + (struct AdapterControlBlock *)host->hostdata; -return snprintf (buf,PAGE_SIZE , -"%4d\n" , +return snprintf (buf,PAGE_SIZE ,"%4d\n" , acb->firm_numbers_queue); }
@@ -356,10 +385,9 @@ arcmsr_attr_host_fw_sdram_size(struct de {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; + (struct AdapterControlBlock *)host->hostdata; -return snprintf (buf,PAGE_SIZE , -"%4d\n" , +return snprintf (buf,PAGE_SIZE ,"%4d\n" , acb->firm_sdram_size); }
@@ -369,23 +397,32 @@ arcmsr_attr_host_fw_hd_channels(struct d {struct Scsi_Host *host =class_to_shost (dev);struct AdapterControlBlock *acb = - (struct AdapterControlBlock *) host->hostdata; + (struct AdapterControlBlock *)host->hostdata; -return snprintf (buf,PAGE_SIZE , -"%4d\n" , +return snprintf (buf,PAGE_SIZE ,"%4d\n" , acb->firm_hd_channels); } -static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); -static DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL); -static DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL); -static DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL); -static DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL); -static DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL); -static DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL); -static DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL); -static DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL); -static DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL); +static DEVICE_ATTR(host_driver_version, S_IRUGO, + arcmsr_attr_host_driver_version, NULL); +static DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, + arcmsr_attr_host_driver_posted_cmd, NULL); +static DEVICE_ATTR(host_driver_reset, S_IRUGO, + arcmsr_attr_host_driver_reset, NULL); +static DEVICE_ATTR(host_driver_abort, S_IRUGO, + arcmsr_attr_host_driver_abort, NULL); +static DEVICE_ATTR(host_fw_model, S_IRUGO, + arcmsr_attr_host_fw_model, NULL); +static DEVICE_ATTR(host_fw_version, S_IRUGO, + arcmsr_attr_host_fw_version, NULL); +static DEVICE_ATTR(host_fw_request_len, S_IRUGO, + arcmsr_attr_host_fw_request_len, NULL); +static DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, + arcmsr_attr_host_fw_numbers_queue, NULL); +static DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, + arcmsr_attr_host_fw_sdram_size, NULL); +static DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, + arcmsr_attr_host_fw_hd_channels, NULL);struct device_attribute *arcmsr_host_attrs[] = { &dev_attr_host_driver_version,
drivers/scsi/arcmsr/arcmsr.h +526 -412
1,148 lines not on this page · raw message
drivers/scsi/arcmsr/arcmsr_hba.c +2730 -1246
1,423 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
drivers/scsi/arcmsr/arcmsr_attr.c +149 -112
261 lines not on this page · raw message
drivers/scsi/arcmsr/arcmsr.h +526 -412
938 lines not on this page · raw message
drivers/scsi/arcmsr/arcmsr_hba.c +2730 -1246
3,976 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 10 lines · Ching
From: Ching <[email protected]>
Support Areca new SATA Raid Adapter ARC1214/1224/1264/1284 Modify maximum outstanding command number.
Notify command complete with auto request sense data.
Fix bug of updating adapter firmware through ioctl(ARCHTTP) interface. Fix coding style warning.
Fix compiling warning.
Fix ARC188x hardware reset.
Fix indent coding.
Hi again Ching.
I think it would be better to separate the coding style warning and indent coding patches from the fixes and send each line entry above as an individual patch.
Quoted 1 line
Singed-off-by Ching <[email protected]>
Typo here
Signed-off-by: