mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-02 03:56:39 +07:00
arcmsr: fix ioctl data read/write error for adapter type C
Rewrite ioctl entry and its relate function. This patch fix ioctl data read/write error and change data I/O access from byte to Dword. Signed-off-by: Ching Huang <ching2048@areca.com.tw> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
6e38adfc58
commit
bb263c4ecb
@ -518,6 +518,8 @@ struct AdapterControlBlock
|
|||||||
uint32_t reg_mu_acc_handle0;
|
uint32_t reg_mu_acc_handle0;
|
||||||
spinlock_t eh_lock;
|
spinlock_t eh_lock;
|
||||||
spinlock_t ccblist_lock;
|
spinlock_t ccblist_lock;
|
||||||
|
spinlock_t rqbuffer_lock;
|
||||||
|
spinlock_t wqbuffer_lock;
|
||||||
union {
|
union {
|
||||||
struct MessageUnit_A __iomem *pmuA;
|
struct MessageUnit_A __iomem *pmuA;
|
||||||
struct MessageUnit_B *pmuB;
|
struct MessageUnit_B *pmuB;
|
||||||
@ -693,8 +695,10 @@ struct SENSE_DATA
|
|||||||
#define ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE 0x01
|
#define ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE 0x01
|
||||||
#define ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE 0x1F
|
#define ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE 0x1F
|
||||||
|
|
||||||
extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *);
|
extern void arcmsr_write_ioctldata2iop(struct AdapterControlBlock *);
|
||||||
extern void arcmsr_iop_message_read(struct AdapterControlBlock *);
|
extern uint32_t arcmsr_Read_iop_rqbuffer_data(struct AdapterControlBlock *,
|
||||||
|
struct QBUFFER __iomem *);
|
||||||
|
extern void arcmsr_clear_iop2drv_rqueue_buffer(struct AdapterControlBlock *);
|
||||||
extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *);
|
extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *);
|
||||||
extern struct device_attribute *arcmsr_host_attrs[];
|
extern struct device_attribute *arcmsr_host_attrs[];
|
||||||
extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
|
extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
|
||||||
|
@ -70,40 +70,75 @@ static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp,
|
|||||||
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
|
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
|
||||||
uint8_t *pQbuffer,*ptmpQbuffer;
|
uint8_t *pQbuffer,*ptmpQbuffer;
|
||||||
int32_t allxfer_len = 0;
|
int32_t allxfer_len = 0;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
|
||||||
/* do message unit read. */
|
/* do message unit read. */
|
||||||
ptmpQbuffer = (uint8_t *)buf;
|
ptmpQbuffer = (uint8_t *)buf;
|
||||||
while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex)
|
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
|
||||||
&& (allxfer_len < 1031)) {
|
if (acb->rqbuf_firstindex != acb->rqbuf_lastindex) {
|
||||||
pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex];
|
pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex];
|
||||||
memcpy(ptmpQbuffer, pQbuffer, 1);
|
if (acb->rqbuf_firstindex > acb->rqbuf_lastindex) {
|
||||||
acb->rqbuf_firstindex++;
|
if ((ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex) >= 1032) {
|
||||||
acb->rqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
|
memcpy(ptmpQbuffer, pQbuffer, 1032);
|
||||||
ptmpQbuffer++;
|
acb->rqbuf_firstindex += 1032;
|
||||||
allxfer_len++;
|
acb->rqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
|
||||||
|
allxfer_len = 1032;
|
||||||
|
} else {
|
||||||
|
if (((ARCMSR_MAX_QBUFFER - acb->rqbuf_firstindex)
|
||||||
|
+ acb->rqbuf_lastindex) > 1032) {
|
||||||
|
memcpy(ptmpQbuffer, pQbuffer,
|
||||||
|
ARCMSR_MAX_QBUFFER
|
||||||
|
- acb->rqbuf_firstindex);
|
||||||
|
ptmpQbuffer += ARCMSR_MAX_QBUFFER
|
||||||
|
- acb->rqbuf_firstindex;
|
||||||
|
memcpy(ptmpQbuffer, acb->rqbuffer, 1032
|
||||||
|
- (ARCMSR_MAX_QBUFFER -
|
||||||
|
acb->rqbuf_firstindex));
|
||||||
|
acb->rqbuf_firstindex = 1032 -
|
||||||
|
(ARCMSR_MAX_QBUFFER -
|
||||||
|
acb->rqbuf_firstindex);
|
||||||
|
allxfer_len = 1032;
|
||||||
|
} else {
|
||||||
|
memcpy(ptmpQbuffer, pQbuffer,
|
||||||
|
ARCMSR_MAX_QBUFFER -
|
||||||
|
acb->rqbuf_firstindex);
|
||||||
|
ptmpQbuffer += ARCMSR_MAX_QBUFFER -
|
||||||
|
acb->rqbuf_firstindex;
|
||||||
|
memcpy(ptmpQbuffer, 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(ptmpQbuffer, pQbuffer, 1032);
|
||||||
|
acb->rqbuf_firstindex += 1032;
|
||||||
|
allxfer_len = 1032;
|
||||||
|
} else {
|
||||||
|
memcpy(ptmpQbuffer, 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) {
|
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
||||||
struct QBUFFER __iomem *prbuffer;
|
struct QBUFFER __iomem *prbuffer;
|
||||||
uint8_t __iomem *iop_data;
|
|
||||||
int32_t iop_len;
|
|
||||||
|
|
||||||
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
||||||
prbuffer = arcmsr_get_iop_rqbuffer(acb);
|
prbuffer = arcmsr_get_iop_rqbuffer(acb);
|
||||||
iop_data = prbuffer->data;
|
if (arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0)
|
||||||
iop_len = readl(&prbuffer->data_len);
|
acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
return (allxfer_len);
|
spin_unlock_irqrestore(&acb->rqbuffer_lock, flags);
|
||||||
|
return allxfer_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
|
static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
|
||||||
@ -117,6 +152,7 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
|
|||||||
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;
|
int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex;
|
||||||
uint8_t *pQbuffer, *ptmpuserbuffer;
|
uint8_t *pQbuffer, *ptmpuserbuffer;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
@ -125,18 +161,19 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
|
|||||||
/* do message unit write. */
|
/* do message unit write. */
|
||||||
ptmpuserbuffer = (uint8_t *)buf;
|
ptmpuserbuffer = (uint8_t *)buf;
|
||||||
user_len = (int32_t)count;
|
user_len = (int32_t)count;
|
||||||
|
spin_lock_irqsave(&acb->wqbuffer_lock, flags);
|
||||||
wqbuf_lastindex = acb->wqbuf_lastindex;
|
wqbuf_lastindex = acb->wqbuf_lastindex;
|
||||||
wqbuf_firstindex = acb->wqbuf_firstindex;
|
wqbuf_firstindex = acb->wqbuf_firstindex;
|
||||||
if (wqbuf_lastindex != 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*/
|
return 0; /*need retry*/
|
||||||
} else {
|
} else {
|
||||||
my_empty_len = (wqbuf_firstindex-wqbuf_lastindex - 1)
|
my_empty_len = (wqbuf_firstindex-wqbuf_lastindex - 1)
|
||||||
&(ARCMSR_MAX_QBUFFER - 1);
|
&(ARCMSR_MAX_QBUFFER - 1);
|
||||||
if (my_empty_len >= user_len) {
|
if (my_empty_len >= user_len) {
|
||||||
while (user_len > 0) {
|
while (user_len > 0) {
|
||||||
pQbuffer =
|
pQbuffer = &acb->wqbuffer[acb->wqbuf_lastindex];
|
||||||
&acb->wqbuffer[acb->wqbuf_lastindex];
|
|
||||||
memcpy(pQbuffer, ptmpuserbuffer, 1);
|
memcpy(pQbuffer, ptmpuserbuffer, 1);
|
||||||
acb->wqbuf_lastindex++;
|
acb->wqbuf_lastindex++;
|
||||||
acb->wqbuf_lastindex %= ARCMSR_MAX_QBUFFER;
|
acb->wqbuf_lastindex %= ARCMSR_MAX_QBUFFER;
|
||||||
@ -146,10 +183,12 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
|
|||||||
if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) {
|
if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) {
|
||||||
acb->acb_flags &=
|
acb->acb_flags &=
|
||||||
~ACB_F_MESSAGE_WQBUFFER_CLEARED;
|
~ACB_F_MESSAGE_WQBUFFER_CLEARED;
|
||||||
arcmsr_post_ioctldata2iop(acb);
|
arcmsr_write_ioctldata2iop(acb);
|
||||||
}
|
}
|
||||||
|
spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
|
||||||
return count;
|
return count;
|
||||||
} else {
|
} else {
|
||||||
|
spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
|
||||||
return 0; /*need retry*/
|
return 0; /*need retry*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,22 +204,24 @@ static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp,
|
|||||||
struct Scsi_Host *host = class_to_shost(dev);
|
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;
|
uint8_t *pQbuffer;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
|
||||||
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
arcmsr_clear_iop2drv_rqueue_buffer(acb);
|
||||||
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
|
||||||
arcmsr_iop_message_read(acb);
|
|
||||||
}
|
|
||||||
acb->acb_flags |=
|
acb->acb_flags |=
|
||||||
(ACB_F_MESSAGE_WQBUFFER_CLEARED
|
(ACB_F_MESSAGE_WQBUFFER_CLEARED
|
||||||
| ACB_F_MESSAGE_RQBUFFER_CLEARED
|
| ACB_F_MESSAGE_RQBUFFER_CLEARED
|
||||||
| ACB_F_MESSAGE_WQBUFFER_READED);
|
| ACB_F_MESSAGE_WQBUFFER_READED);
|
||||||
|
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
|
||||||
acb->rqbuf_firstindex = 0;
|
acb->rqbuf_firstindex = 0;
|
||||||
acb->rqbuf_lastindex = 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_firstindex = 0;
|
||||||
acb->wqbuf_lastindex = 0;
|
acb->wqbuf_lastindex = 0;
|
||||||
|
spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
|
||||||
pQbuffer = acb->rqbuffer;
|
pQbuffer = acb->rqbuffer;
|
||||||
memset(pQbuffer, 0, sizeof (struct QBUFFER));
|
memset(pQbuffer, 0, sizeof (struct QBUFFER));
|
||||||
pQbuffer = acb->wqbuffer;
|
pQbuffer = acb->wqbuffer;
|
||||||
|
@ -653,6 +653,8 @@ static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||||||
}
|
}
|
||||||
spin_lock_init(&acb->eh_lock);
|
spin_lock_init(&acb->eh_lock);
|
||||||
spin_lock_init(&acb->ccblist_lock);
|
spin_lock_init(&acb->ccblist_lock);
|
||||||
|
spin_lock_init(&acb->rqbuffer_lock);
|
||||||
|
spin_lock_init(&acb->wqbuffer_lock);
|
||||||
acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |
|
acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |
|
||||||
ACB_F_MESSAGE_RQBUFFER_CLEARED |
|
ACB_F_MESSAGE_RQBUFFER_CLEARED |
|
||||||
ACB_F_MESSAGE_WQBUFFER_READED);
|
ACB_F_MESSAGE_WQBUFFER_READED);
|
||||||
@ -1449,68 +1451,175 @@ static struct QBUFFER __iomem *arcmsr_get_iop_wqbuffer(struct AdapterControlBloc
|
|||||||
return pqbuffer;
|
return pqbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arcmsr_iop2drv_data_wrote_handle(struct AdapterControlBlock *acb)
|
static uint32_t
|
||||||
|
arcmsr_Read_iop_rqbuffer_in_DWORD(struct AdapterControlBlock *acb,
|
||||||
|
struct QBUFFER __iomem *prbuffer)
|
||||||
{
|
{
|
||||||
struct QBUFFER __iomem *prbuffer;
|
uint8_t *pQbuffer;
|
||||||
struct QBUFFER *pQbuffer;
|
uint8_t *buf1 = NULL;
|
||||||
uint8_t __iomem *iop_data;
|
uint32_t __iomem *iop_data;
|
||||||
int32_t my_empty_len, iop_len, rqbuf_firstindex, rqbuf_lastindex;
|
uint32_t iop_len, data_len, *buf2 = NULL;
|
||||||
rqbuf_lastindex = acb->rqbuf_lastindex;
|
|
||||||
rqbuf_firstindex = acb->rqbuf_firstindex;
|
|
||||||
prbuffer = arcmsr_get_iop_rqbuffer(acb);
|
|
||||||
iop_data = (uint8_t __iomem *)prbuffer->data;
|
|
||||||
iop_len = prbuffer->data_len;
|
|
||||||
my_empty_len = (rqbuf_firstindex - rqbuf_lastindex - 1) & (ARCMSR_MAX_QBUFFER - 1);
|
|
||||||
|
|
||||||
if (my_empty_len >= iop_len)
|
iop_data = (uint32_t __iomem *)prbuffer->data;
|
||||||
{
|
iop_len = readl(&prbuffer->data_len);
|
||||||
while (iop_len > 0) {
|
if (iop_len > 0) {
|
||||||
pQbuffer = (struct QBUFFER *)&acb->rqbuffer[rqbuf_lastindex];
|
buf1 = kmalloc(128, GFP_ATOMIC);
|
||||||
memcpy(pQbuffer, iop_data, 1);
|
buf2 = (uint32_t *)buf1;
|
||||||
rqbuf_lastindex++;
|
if (buf1 == NULL)
|
||||||
rqbuf_lastindex %= ARCMSR_MAX_QBUFFER;
|
return 0;
|
||||||
|
data_len = iop_len;
|
||||||
|
while (data_len >= 4) {
|
||||||
|
*buf2++ = readl(iop_data);
|
||||||
iop_data++;
|
iop_data++;
|
||||||
iop_len--;
|
data_len -= 4;
|
||||||
}
|
}
|
||||||
acb->rqbuf_lastindex = rqbuf_lastindex;
|
if (data_len)
|
||||||
arcmsr_iop_message_read(acb);
|
*buf2 = readl(iop_data);
|
||||||
|
buf2 = (uint32_t *)buf1;
|
||||||
}
|
}
|
||||||
|
while (iop_len > 0) {
|
||||||
else {
|
pQbuffer = &acb->rqbuffer[acb->rqbuf_lastindex];
|
||||||
acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW;
|
*pQbuffer = *buf1;
|
||||||
|
acb->rqbuf_lastindex++;
|
||||||
|
/* if last, index number set it to 0 */
|
||||||
|
acb->rqbuf_lastindex %= ARCMSR_MAX_QBUFFER;
|
||||||
|
buf1++;
|
||||||
|
iop_len--;
|
||||||
}
|
}
|
||||||
|
if (buf2)
|
||||||
|
kfree(buf2);
|
||||||
|
/* let IOP know data has been read */
|
||||||
|
arcmsr_iop_message_read(acb);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arcmsr_iop2drv_data_read_handle(struct AdapterControlBlock *acb)
|
uint32_t
|
||||||
|
arcmsr_Read_iop_rqbuffer_data(struct AdapterControlBlock *acb,
|
||||||
|
struct QBUFFER __iomem *prbuffer) {
|
||||||
|
|
||||||
|
uint8_t *pQbuffer;
|
||||||
|
uint8_t __iomem *iop_data;
|
||||||
|
uint32_t iop_len;
|
||||||
|
|
||||||
|
if (acb->adapter_type & ACB_ADAPTER_TYPE_C)
|
||||||
|
return arcmsr_Read_iop_rqbuffer_in_DWORD(acb, prbuffer);
|
||||||
|
iop_data = (uint8_t __iomem *)prbuffer->data;
|
||||||
|
iop_len = readl(&prbuffer->data_len);
|
||||||
|
while (iop_len > 0) {
|
||||||
|
pQbuffer = &acb->rqbuffer[acb->rqbuf_lastindex];
|
||||||
|
*pQbuffer = readb(iop_data);
|
||||||
|
acb->rqbuf_lastindex++;
|
||||||
|
acb->rqbuf_lastindex %= ARCMSR_MAX_QBUFFER;
|
||||||
|
iop_data++;
|
||||||
|
iop_len--;
|
||||||
|
}
|
||||||
|
arcmsr_iop_message_read(acb);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void arcmsr_iop2drv_data_wrote_handle(struct AdapterControlBlock *acb)
|
||||||
{
|
{
|
||||||
acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_READED;
|
unsigned long flags;
|
||||||
if (acb->wqbuf_firstindex != acb->wqbuf_lastindex) {
|
struct QBUFFER __iomem *prbuffer;
|
||||||
uint8_t *pQbuffer;
|
int32_t buf_empty_len;
|
||||||
struct QBUFFER __iomem *pwbuffer;
|
|
||||||
uint8_t __iomem *iop_data;
|
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
|
||||||
int32_t allxfer_len = 0;
|
prbuffer = arcmsr_get_iop_rqbuffer(acb);
|
||||||
|
buf_empty_len = (acb->rqbuf_lastindex - acb->rqbuf_firstindex - 1) &
|
||||||
|
(ARCMSR_MAX_QBUFFER - 1);
|
||||||
|
if (buf_empty_len >= readl(&prbuffer->data_len)) {
|
||||||
|
if (arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0)
|
||||||
|
acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW;
|
||||||
|
} else
|
||||||
|
acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW;
|
||||||
|
spin_unlock_irqrestore(&acb->rqbuffer_lock, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void arcmsr_write_ioctldata2iop_in_DWORD(struct AdapterControlBlock *acb)
|
||||||
|
{
|
||||||
|
uint8_t *pQbuffer;
|
||||||
|
struct QBUFFER __iomem *pwbuffer;
|
||||||
|
uint8_t *buf1 = NULL;
|
||||||
|
uint32_t __iomem *iop_data;
|
||||||
|
uint32_t allxfer_len = 0, data_len, *buf2 = NULL, data;
|
||||||
|
|
||||||
|
if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_READED) {
|
||||||
|
buf1 = kmalloc(128, GFP_ATOMIC);
|
||||||
|
buf2 = (uint32_t *)buf1;
|
||||||
|
if (buf1 == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READED);
|
acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READED);
|
||||||
pwbuffer = arcmsr_get_iop_wqbuffer(acb);
|
pwbuffer = arcmsr_get_iop_wqbuffer(acb);
|
||||||
iop_data = (uint8_t __iomem *)pwbuffer->data;
|
iop_data = (uint32_t __iomem *)pwbuffer->data;
|
||||||
|
while ((acb->wqbuf_firstindex != acb->wqbuf_lastindex)
|
||||||
while ((acb->wqbuf_firstindex != acb->wqbuf_lastindex) && \
|
&& (allxfer_len < 124)) {
|
||||||
(allxfer_len < 124)) {
|
|
||||||
pQbuffer = &acb->wqbuffer[acb->wqbuf_firstindex];
|
pQbuffer = &acb->wqbuffer[acb->wqbuf_firstindex];
|
||||||
memcpy(iop_data, pQbuffer, 1);
|
*buf1 = *pQbuffer;
|
||||||
|
acb->wqbuf_firstindex++;
|
||||||
|
acb->wqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
|
||||||
|
buf1++;
|
||||||
|
allxfer_len++;
|
||||||
|
}
|
||||||
|
data_len = allxfer_len;
|
||||||
|
buf1 = (uint8_t *)buf2;
|
||||||
|
while (data_len >= 4) {
|
||||||
|
data = *buf2++;
|
||||||
|
writel(data, iop_data);
|
||||||
|
iop_data++;
|
||||||
|
data_len -= 4;
|
||||||
|
}
|
||||||
|
if (data_len) {
|
||||||
|
data = *buf2;
|
||||||
|
writel(data, iop_data);
|
||||||
|
}
|
||||||
|
writel(allxfer_len, &pwbuffer->data_len);
|
||||||
|
kfree(buf1);
|
||||||
|
arcmsr_iop_message_wrote(acb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
arcmsr_write_ioctldata2iop(struct AdapterControlBlock *acb)
|
||||||
|
{
|
||||||
|
uint8_t *pQbuffer;
|
||||||
|
struct QBUFFER __iomem *pwbuffer;
|
||||||
|
uint8_t __iomem *iop_data;
|
||||||
|
int32_t allxfer_len = 0;
|
||||||
|
|
||||||
|
if (acb->adapter_type & ACB_ADAPTER_TYPE_C) {
|
||||||
|
arcmsr_write_ioctldata2iop_in_DWORD(acb);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_READED) {
|
||||||
|
acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READED);
|
||||||
|
pwbuffer = arcmsr_get_iop_wqbuffer(acb);
|
||||||
|
iop_data = (uint8_t __iomem *)pwbuffer->data;
|
||||||
|
while ((acb->wqbuf_firstindex != acb->wqbuf_lastindex)
|
||||||
|
&& (allxfer_len < 124)) {
|
||||||
|
pQbuffer = &acb->wqbuffer[acb->wqbuf_firstindex];
|
||||||
|
writeb(*pQbuffer, iop_data);
|
||||||
acb->wqbuf_firstindex++;
|
acb->wqbuf_firstindex++;
|
||||||
acb->wqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
|
acb->wqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
|
||||||
iop_data++;
|
iop_data++;
|
||||||
allxfer_len++;
|
allxfer_len++;
|
||||||
}
|
}
|
||||||
pwbuffer->data_len = allxfer_len;
|
writel(allxfer_len, &pwbuffer->data_len);
|
||||||
|
|
||||||
arcmsr_iop_message_wrote(acb);
|
arcmsr_iop_message_wrote(acb);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (acb->wqbuf_firstindex == acb->wqbuf_lastindex) {
|
static void arcmsr_iop2drv_data_read_handle(struct AdapterControlBlock *acb)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&acb->wqbuffer_lock, flags);
|
||||||
|
acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_READED;
|
||||||
|
if (acb->wqbuf_firstindex != acb->wqbuf_lastindex)
|
||||||
|
arcmsr_write_ioctldata2iop(acb);
|
||||||
|
if (acb->wqbuf_firstindex == acb->wqbuf_lastindex)
|
||||||
acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_CLEARED;
|
acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_CLEARED;
|
||||||
}
|
spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arcmsr_hbaA_doorbell_isr(struct AdapterControlBlock *acb)
|
static void arcmsr_hbaA_doorbell_isr(struct AdapterControlBlock *acb)
|
||||||
@ -1768,296 +1877,345 @@ static void arcmsr_iop_parking(struct AdapterControlBlock *acb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *acb)
|
|
||||||
|
void arcmsr_clear_iop2drv_rqueue_buffer(struct AdapterControlBlock *acb)
|
||||||
{
|
{
|
||||||
int32_t wqbuf_firstindex, wqbuf_lastindex;
|
uint32_t i;
|
||||||
uint8_t *pQbuffer;
|
|
||||||
struct QBUFFER __iomem *pwbuffer;
|
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
||||||
uint8_t __iomem *iop_data;
|
for (i = 0; i < 15; i++) {
|
||||||
int32_t allxfer_len = 0;
|
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
||||||
pwbuffer = arcmsr_get_iop_wqbuffer(acb);
|
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
||||||
iop_data = (uint8_t __iomem *)pwbuffer->data;
|
acb->rqbuf_firstindex = 0;
|
||||||
if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_READED) {
|
acb->rqbuf_lastindex = 0;
|
||||||
acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READED);
|
arcmsr_iop_message_read(acb);
|
||||||
wqbuf_firstindex = acb->wqbuf_firstindex;
|
mdelay(30);
|
||||||
wqbuf_lastindex = acb->wqbuf_lastindex;
|
} else if (acb->rqbuf_firstindex !=
|
||||||
while ((wqbuf_firstindex != wqbuf_lastindex) && (allxfer_len < 124)) {
|
acb->rqbuf_lastindex) {
|
||||||
pQbuffer = &acb->wqbuffer[wqbuf_firstindex];
|
acb->rqbuf_firstindex = 0;
|
||||||
memcpy(iop_data, pQbuffer, 1);
|
acb->rqbuf_lastindex = 0;
|
||||||
wqbuf_firstindex++;
|
mdelay(30);
|
||||||
wqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
|
} else
|
||||||
iop_data++;
|
break;
|
||||||
allxfer_len++;
|
|
||||||
}
|
}
|
||||||
acb->wqbuf_firstindex = wqbuf_firstindex;
|
|
||||||
pwbuffer->data_len = allxfer_len;
|
|
||||||
arcmsr_iop_message_wrote(acb);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
|
static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
|
||||||
struct scsi_cmnd *cmd)
|
struct scsi_cmnd *cmd)
|
||||||
{
|
{
|
||||||
struct CMD_MESSAGE_FIELD *pcmdmessagefld;
|
|
||||||
int retvalue = 0, transfer_len = 0;
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
unsigned short use_sg;
|
||||||
|
int retvalue = 0, transfer_len = 0;
|
||||||
|
unsigned long flags;
|
||||||
|
struct CMD_MESSAGE_FIELD *pcmdmessagefld;
|
||||||
|
uint32_t controlcode = (uint32_t)cmd->cmnd[5] << 24 |
|
||||||
|
(uint32_t)cmd->cmnd[6] << 16 |
|
||||||
|
(uint32_t)cmd->cmnd[7] << 8 |
|
||||||
|
(uint32_t)cmd->cmnd[8];
|
||||||
struct scatterlist *sg;
|
struct scatterlist *sg;
|
||||||
uint32_t controlcode = (uint32_t ) cmd->cmnd[5] << 24 |
|
|
||||||
(uint32_t ) cmd->cmnd[6] << 16 |
|
use_sg = scsi_sg_count(cmd);
|
||||||
(uint32_t ) cmd->cmnd[7] << 8 |
|
|
||||||
(uint32_t ) cmd->cmnd[8];
|
|
||||||
/* 4 bytes: Areca io control code */
|
|
||||||
sg = scsi_sglist(cmd);
|
sg = scsi_sglist(cmd);
|
||||||
buffer = kmap_atomic(sg_page(sg)) + sg->offset;
|
buffer = kmap_atomic(sg_page(sg)) + sg->offset;
|
||||||
if (scsi_sg_count(cmd) > 1) {
|
if (use_sg > 1) {
|
||||||
retvalue = ARCMSR_MESSAGE_FAIL;
|
retvalue = ARCMSR_MESSAGE_FAIL;
|
||||||
goto message_out;
|
goto message_out;
|
||||||
}
|
}
|
||||||
transfer_len += sg->length;
|
transfer_len += sg->length;
|
||||||
|
|
||||||
if (transfer_len > sizeof(struct CMD_MESSAGE_FIELD)) {
|
if (transfer_len > sizeof(struct CMD_MESSAGE_FIELD)) {
|
||||||
retvalue = ARCMSR_MESSAGE_FAIL;
|
retvalue = ARCMSR_MESSAGE_FAIL;
|
||||||
|
pr_info("%s: ARCMSR_MESSAGE_FAIL!\n", __func__);
|
||||||
goto message_out;
|
goto message_out;
|
||||||
}
|
}
|
||||||
pcmdmessagefld = (struct CMD_MESSAGE_FIELD *) buffer;
|
pcmdmessagefld = (struct CMD_MESSAGE_FIELD *)buffer;
|
||||||
switch(controlcode) {
|
switch (controlcode) {
|
||||||
|
|
||||||
case ARCMSR_MESSAGE_READ_RQBUFFER: {
|
case ARCMSR_MESSAGE_READ_RQBUFFER: {
|
||||||
unsigned char *ver_addr;
|
unsigned char *ver_addr;
|
||||||
uint8_t *pQbuffer, *ptmpQbuffer;
|
uint8_t *pQbuffer, *ptmpQbuffer;
|
||||||
int32_t allxfer_len = 0;
|
uint32_t allxfer_len = 0;
|
||||||
|
|
||||||
ver_addr = kmalloc(1032, GFP_ATOMIC);
|
ver_addr = kmalloc(1032, GFP_ATOMIC);
|
||||||
if (!ver_addr) {
|
if (!ver_addr) {
|
||||||
retvalue = ARCMSR_MESSAGE_FAIL;
|
retvalue = ARCMSR_MESSAGE_FAIL;
|
||||||
|
pr_info("%s: memory not enough!\n", __func__);
|
||||||
goto message_out;
|
goto message_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptmpQbuffer = ver_addr;
|
ptmpQbuffer = ver_addr;
|
||||||
while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex)
|
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
|
||||||
&& (allxfer_len < 1031)) {
|
if (acb->rqbuf_firstindex != acb->rqbuf_lastindex) {
|
||||||
pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex];
|
pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex];
|
||||||
memcpy(ptmpQbuffer, pQbuffer, 1);
|
if (acb->rqbuf_firstindex > acb->rqbuf_lastindex) {
|
||||||
acb->rqbuf_firstindex++;
|
if ((ARCMSR_MAX_QBUFFER -
|
||||||
acb->rqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
|
acb->rqbuf_firstindex) >= 1032) {
|
||||||
ptmpQbuffer++;
|
memcpy(ptmpQbuffer, pQbuffer, 1032);
|
||||||
allxfer_len++;
|
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(ptmpQbuffer,
|
||||||
|
pQbuffer, ARCMSR_MAX_QBUFFER
|
||||||
|
- acb->rqbuf_firstindex);
|
||||||
|
ptmpQbuffer +=
|
||||||
|
ARCMSR_MAX_QBUFFER -
|
||||||
|
acb->rqbuf_firstindex;
|
||||||
|
memcpy(ptmpQbuffer,
|
||||||
|
acb->rqbuffer, 1032 -
|
||||||
|
(ARCMSR_MAX_QBUFFER
|
||||||
|
- acb->rqbuf_firstindex));
|
||||||
|
acb->rqbuf_firstindex =
|
||||||
|
1032 - (ARCMSR_MAX_QBUFFER
|
||||||
|
- acb->rqbuf_firstindex);
|
||||||
|
allxfer_len = 1032;
|
||||||
|
} else {
|
||||||
|
memcpy(ptmpQbuffer,
|
||||||
|
pQbuffer, ARCMSR_MAX_QBUFFER
|
||||||
|
- acb->rqbuf_firstindex);
|
||||||
|
ptmpQbuffer +=
|
||||||
|
ARCMSR_MAX_QBUFFER -
|
||||||
|
acb->rqbuf_firstindex;
|
||||||
|
memcpy(ptmpQbuffer,
|
||||||
|
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(ptmpQbuffer, pQbuffer, 1032);
|
||||||
|
acb->rqbuf_firstindex += 1032;
|
||||||
|
allxfer_len = 1032;
|
||||||
|
} else {
|
||||||
|
memcpy(ptmpQbuffer, pQbuffer,
|
||||||
|
acb->rqbuf_lastindex -
|
||||||
|
acb->rqbuf_firstindex);
|
||||||
|
allxfer_len = acb->rqbuf_lastindex
|
||||||
|
- acb->rqbuf_firstindex;
|
||||||
|
acb->rqbuf_firstindex =
|
||||||
|
acb->rqbuf_lastindex;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
memcpy(pcmdmessagefld->messagedatabuffer, ver_addr,
|
||||||
|
allxfer_len);
|
||||||
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
||||||
|
|
||||||
struct QBUFFER __iomem *prbuffer;
|
struct QBUFFER __iomem *prbuffer;
|
||||||
uint8_t __iomem *iop_data;
|
|
||||||
int32_t iop_len;
|
|
||||||
|
|
||||||
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
||||||
prbuffer = arcmsr_get_iop_rqbuffer(acb);
|
prbuffer = arcmsr_get_iop_rqbuffer(acb);
|
||||||
iop_data = prbuffer->data;
|
if (arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0)
|
||||||
iop_len = readl(&prbuffer->data_len);
|
acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW;
|
||||||
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);
|
|
||||||
}
|
|
||||||
memcpy(pcmdmessagefld->messagedatabuffer, ver_addr, allxfer_len);
|
|
||||||
pcmdmessagefld->cmdmessage.Length = allxfer_len;
|
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
|
||||||
}else{
|
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK;
|
|
||||||
}
|
}
|
||||||
|
spin_unlock_irqrestore(&acb->rqbuffer_lock, flags);
|
||||||
kfree(ver_addr);
|
kfree(ver_addr);
|
||||||
}
|
pcmdmessagefld->cmdmessage.Length = allxfer_len;
|
||||||
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
|
else
|
||||||
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
|
ARCMSR_MESSAGE_RETURNCODE_OK;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ARCMSR_MESSAGE_WRITE_WQBUFFER: {
|
case ARCMSR_MESSAGE_WRITE_WQBUFFER: {
|
||||||
unsigned char *ver_addr;
|
unsigned char *ver_addr;
|
||||||
int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex;
|
int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex;
|
||||||
uint8_t *pQbuffer, *ptmpuserbuffer;
|
uint8_t *pQbuffer, *ptmpuserbuffer;
|
||||||
|
|
||||||
ver_addr = kmalloc(1032, GFP_ATOMIC);
|
ver_addr = kmalloc(1032, GFP_ATOMIC);
|
||||||
if (!ver_addr) {
|
if (!ver_addr) {
|
||||||
retvalue = ARCMSR_MESSAGE_FAIL;
|
retvalue = ARCMSR_MESSAGE_FAIL;
|
||||||
goto message_out;
|
goto message_out;
|
||||||
}
|
}
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
|
||||||
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
|
||||||
}else{
|
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
|
||||||
ARCMSR_MESSAGE_RETURNCODE_OK;
|
|
||||||
}
|
|
||||||
ptmpuserbuffer = ver_addr;
|
ptmpuserbuffer = ver_addr;
|
||||||
user_len = pcmdmessagefld->cmdmessage.Length;
|
user_len = pcmdmessagefld->cmdmessage.Length;
|
||||||
memcpy(ptmpuserbuffer, pcmdmessagefld->messagedatabuffer, user_len);
|
memcpy(ptmpuserbuffer,
|
||||||
|
pcmdmessagefld->messagedatabuffer, user_len);
|
||||||
|
spin_lock_irqsave(&acb->wqbuffer_lock, flags);
|
||||||
wqbuf_lastindex = acb->wqbuf_lastindex;
|
wqbuf_lastindex = acb->wqbuf_lastindex;
|
||||||
wqbuf_firstindex = acb->wqbuf_firstindex;
|
wqbuf_firstindex = acb->wqbuf_firstindex;
|
||||||
if (wqbuf_lastindex != wqbuf_firstindex) {
|
if (wqbuf_lastindex != wqbuf_firstindex) {
|
||||||
struct SENSE_DATA *sensebuffer =
|
struct SENSE_DATA *sensebuffer =
|
||||||
(struct SENSE_DATA *)cmd->sense_buffer;
|
(struct SENSE_DATA *)cmd->sense_buffer;
|
||||||
arcmsr_post_ioctldata2iop(acb);
|
arcmsr_write_ioctldata2iop(acb);
|
||||||
/* has error report sensedata */
|
/* has error report sensedata */
|
||||||
sensebuffer->ErrorCode = 0x70;
|
sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;
|
||||||
sensebuffer->SenseKey = ILLEGAL_REQUEST;
|
sensebuffer->SenseKey = ILLEGAL_REQUEST;
|
||||||
sensebuffer->AdditionalSenseLength = 0x0A;
|
sensebuffer->AdditionalSenseLength = 0x0A;
|
||||||
sensebuffer->AdditionalSenseCode = 0x20;
|
sensebuffer->AdditionalSenseCode = 0x20;
|
||||||
sensebuffer->Valid = 1;
|
sensebuffer->Valid = 1;
|
||||||
retvalue = ARCMSR_MESSAGE_FAIL;
|
retvalue = ARCMSR_MESSAGE_FAIL;
|
||||||
} else {
|
} else {
|
||||||
my_empty_len = (wqbuf_firstindex-wqbuf_lastindex - 1)
|
my_empty_len = (wqbuf_firstindex - wqbuf_lastindex - 1)
|
||||||
&(ARCMSR_MAX_QBUFFER - 1);
|
& (ARCMSR_MAX_QBUFFER - 1);
|
||||||
if (my_empty_len >= user_len) {
|
if (my_empty_len >= user_len) {
|
||||||
while (user_len > 0) {
|
while (user_len > 0) {
|
||||||
pQbuffer =
|
pQbuffer = &acb->wqbuffer[acb->wqbuf_lastindex];
|
||||||
&acb->wqbuffer[acb->wqbuf_lastindex];
|
if ((acb->wqbuf_lastindex + user_len)
|
||||||
memcpy(pQbuffer, ptmpuserbuffer, 1);
|
> ARCMSR_MAX_QBUFFER) {
|
||||||
acb->wqbuf_lastindex++;
|
memcpy(pQbuffer, ptmpuserbuffer,
|
||||||
acb->wqbuf_lastindex %= ARCMSR_MAX_QBUFFER;
|
ARCMSR_MAX_QBUFFER -
|
||||||
ptmpuserbuffer++;
|
acb->wqbuf_lastindex);
|
||||||
user_len--;
|
ptmpuserbuffer +=
|
||||||
|
(ARCMSR_MAX_QBUFFER
|
||||||
|
- acb->wqbuf_lastindex);
|
||||||
|
user_len -= (ARCMSR_MAX_QBUFFER
|
||||||
|
- acb->wqbuf_lastindex);
|
||||||
|
acb->wqbuf_lastindex = 0;
|
||||||
|
} else {
|
||||||
|
memcpy(pQbuffer, ptmpuserbuffer,
|
||||||
|
user_len);
|
||||||
|
acb->wqbuf_lastindex += user_len;
|
||||||
|
acb->wqbuf_lastindex %=
|
||||||
|
ARCMSR_MAX_QBUFFER;
|
||||||
|
user_len = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) {
|
if (acb->acb_flags &
|
||||||
|
ACB_F_MESSAGE_WQBUFFER_CLEARED) {
|
||||||
acb->acb_flags &=
|
acb->acb_flags &=
|
||||||
~ACB_F_MESSAGE_WQBUFFER_CLEARED;
|
~ACB_F_MESSAGE_WQBUFFER_CLEARED;
|
||||||
arcmsr_post_ioctldata2iop(acb);
|
arcmsr_write_ioctldata2iop(acb);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* has error report sensedata */
|
|
||||||
struct SENSE_DATA *sensebuffer =
|
struct SENSE_DATA *sensebuffer =
|
||||||
(struct SENSE_DATA *)cmd->sense_buffer;
|
(struct SENSE_DATA *)cmd->sense_buffer;
|
||||||
sensebuffer->ErrorCode = 0x70;
|
/* has error report sensedata */
|
||||||
|
sensebuffer->ErrorCode =
|
||||||
|
SCSI_SENSE_CURRENT_ERRORS;
|
||||||
sensebuffer->SenseKey = ILLEGAL_REQUEST;
|
sensebuffer->SenseKey = ILLEGAL_REQUEST;
|
||||||
sensebuffer->AdditionalSenseLength = 0x0A;
|
sensebuffer->AdditionalSenseLength = 0x0A;
|
||||||
sensebuffer->AdditionalSenseCode = 0x20;
|
sensebuffer->AdditionalSenseCode = 0x20;
|
||||||
sensebuffer->Valid = 1;
|
sensebuffer->Valid = 1;
|
||||||
retvalue = ARCMSR_MESSAGE_FAIL;
|
retvalue = ARCMSR_MESSAGE_FAIL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
kfree(ver_addr);
|
|
||||||
}
|
}
|
||||||
|
spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
|
||||||
|
kfree(ver_addr);
|
||||||
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
|
else
|
||||||
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
|
ARCMSR_MESSAGE_RETURNCODE_OK;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ARCMSR_MESSAGE_CLEAR_RQBUFFER: {
|
case ARCMSR_MESSAGE_CLEAR_RQBUFFER: {
|
||||||
uint8_t *pQbuffer = acb->rqbuffer;
|
uint8_t *pQbuffer = acb->rqbuffer;
|
||||||
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
|
||||||
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
arcmsr_clear_iop2drv_rqueue_buffer(acb);
|
||||||
arcmsr_iop_message_read(acb);
|
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
|
||||||
}
|
|
||||||
acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED;
|
acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED;
|
||||||
acb->rqbuf_firstindex = 0;
|
acb->rqbuf_firstindex = 0;
|
||||||
acb->rqbuf_lastindex = 0;
|
acb->rqbuf_lastindex = 0;
|
||||||
memset(pQbuffer, 0, ARCMSR_MAX_QBUFFER);
|
memset(pQbuffer, 0, ARCMSR_MAX_QBUFFER);
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
spin_unlock_irqrestore(&acb->rqbuffer_lock, flags);
|
||||||
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
}else{
|
else
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_OK;
|
ARCMSR_MESSAGE_RETURNCODE_OK;
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ARCMSR_MESSAGE_CLEAR_WQBUFFER: {
|
case ARCMSR_MESSAGE_CLEAR_WQBUFFER: {
|
||||||
uint8_t *pQbuffer = acb->wqbuffer;
|
uint8_t *pQbuffer = acb->wqbuffer;
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
spin_lock_irqsave(&acb->wqbuffer_lock, flags);
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |
|
||||||
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
ACB_F_MESSAGE_WQBUFFER_READED);
|
||||||
}else{
|
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
|
||||||
ARCMSR_MESSAGE_RETURNCODE_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
|
||||||
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
|
||||||
arcmsr_iop_message_read(acb);
|
|
||||||
}
|
|
||||||
acb->acb_flags |=
|
|
||||||
(ACB_F_MESSAGE_WQBUFFER_CLEARED |
|
|
||||||
ACB_F_MESSAGE_WQBUFFER_READED);
|
|
||||||
acb->wqbuf_firstindex = 0;
|
acb->wqbuf_firstindex = 0;
|
||||||
acb->wqbuf_lastindex = 0;
|
acb->wqbuf_lastindex = 0;
|
||||||
memset(pQbuffer, 0, ARCMSR_MAX_QBUFFER);
|
memset(pQbuffer, 0, ARCMSR_MAX_QBUFFER);
|
||||||
}
|
spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
|
||||||
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
|
else
|
||||||
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
|
ARCMSR_MESSAGE_RETURNCODE_OK;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ARCMSR_MESSAGE_CLEAR_ALLQBUFFER: {
|
case ARCMSR_MESSAGE_CLEAR_ALLQBUFFER: {
|
||||||
uint8_t *pQbuffer;
|
uint8_t *pQbuffer;
|
||||||
|
arcmsr_clear_iop2drv_rqueue_buffer(acb);
|
||||||
if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) {
|
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
|
||||||
acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW;
|
acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED;
|
||||||
arcmsr_iop_message_read(acb);
|
|
||||||
}
|
|
||||||
acb->acb_flags |=
|
|
||||||
(ACB_F_MESSAGE_WQBUFFER_CLEARED
|
|
||||||
| ACB_F_MESSAGE_RQBUFFER_CLEARED
|
|
||||||
| ACB_F_MESSAGE_WQBUFFER_READED);
|
|
||||||
acb->rqbuf_firstindex = 0;
|
acb->rqbuf_firstindex = 0;
|
||||||
acb->rqbuf_lastindex = 0;
|
acb->rqbuf_lastindex = 0;
|
||||||
acb->wqbuf_firstindex = 0;
|
|
||||||
acb->wqbuf_lastindex = 0;
|
|
||||||
pQbuffer = acb->rqbuffer;
|
pQbuffer = acb->rqbuffer;
|
||||||
memset(pQbuffer, 0, sizeof(struct QBUFFER));
|
memset(pQbuffer, 0, sizeof(struct QBUFFER));
|
||||||
|
spin_unlock_irqrestore(&acb->rqbuffer_lock, flags);
|
||||||
|
spin_lock_irqsave(&acb->wqbuffer_lock, flags);
|
||||||
|
acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |
|
||||||
|
ACB_F_MESSAGE_WQBUFFER_READED);
|
||||||
|
acb->wqbuf_firstindex = 0;
|
||||||
|
acb->wqbuf_lastindex = 0;
|
||||||
pQbuffer = acb->wqbuffer;
|
pQbuffer = acb->wqbuffer;
|
||||||
memset(pQbuffer, 0, sizeof(struct QBUFFER));
|
memset(pQbuffer, 0, sizeof(struct QBUFFER));
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
|
||||||
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
}else{
|
else
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_OK;
|
ARCMSR_MESSAGE_RETURNCODE_OK;
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ARCMSR_MESSAGE_RETURN_CODE_3F: {
|
case ARCMSR_MESSAGE_RETURN_CODE_3F: {
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
}else{
|
else
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_3F;
|
ARCMSR_MESSAGE_RETURNCODE_3F;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ARCMSR_MESSAGE_SAY_HELLO: {
|
case ARCMSR_MESSAGE_SAY_HELLO: {
|
||||||
int8_t *hello_string = "Hello! I am ARCMSR";
|
int8_t *hello_string = "Hello! I am ARCMSR";
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
}else{
|
else
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_OK;
|
ARCMSR_MESSAGE_RETURNCODE_OK;
|
||||||
}
|
memcpy(pcmdmessagefld->messagedatabuffer,
|
||||||
memcpy(pcmdmessagefld->messagedatabuffer, hello_string
|
hello_string, (int16_t)strlen(hello_string));
|
||||||
, (int16_t)strlen(hello_string));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ARCMSR_MESSAGE_SAY_GOODBYE:
|
case ARCMSR_MESSAGE_SAY_GOODBYE: {
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
}
|
else
|
||||||
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
|
ARCMSR_MESSAGE_RETURNCODE_OK;
|
||||||
arcmsr_iop_parking(acb);
|
arcmsr_iop_parking(acb);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ARCMSR_MESSAGE_FLUSH_ADAPTER_CACHE:
|
case ARCMSR_MESSAGE_FLUSH_ADAPTER_CACHE: {
|
||||||
if(acb->fw_flag == FW_DEADLOCK) {
|
if (acb->fw_flag == FW_DEADLOCK)
|
||||||
pcmdmessagefld->cmdmessage.ReturnCode =
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON;
|
||||||
}
|
else
|
||||||
|
pcmdmessagefld->cmdmessage.ReturnCode =
|
||||||
|
ARCMSR_MESSAGE_RETURNCODE_OK;
|
||||||
arcmsr_flush_adapter_cache(acb);
|
arcmsr_flush_adapter_cache(acb);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
retvalue = ARCMSR_MESSAGE_FAIL;
|
retvalue = ARCMSR_MESSAGE_FAIL;
|
||||||
|
pr_info("%s: unknown controlcode!\n", __func__);
|
||||||
|
}
|
||||||
|
message_out:
|
||||||
|
if (use_sg) {
|
||||||
|
struct scatterlist *sg = scsi_sglist(cmd);
|
||||||
|
kunmap_atomic(buffer - sg->offset);
|
||||||
}
|
}
|
||||||
message_out:
|
|
||||||
sg = scsi_sglist(cmd);
|
|
||||||
kunmap_atomic(buffer - sg->offset);
|
|
||||||
return retvalue;
|
return retvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user