aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/DAC960.c160
1 files changed, 90 insertions, 70 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 442e777bdfb2..728075214959 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -6619,43 +6619,27 @@ static void DAC960_DestroyProcEntries(DAC960_Controller_T *Controller)
6619 6619
6620#ifdef DAC960_GAM_MINOR 6620#ifdef DAC960_GAM_MINOR
6621 6621
6622/* 6622static long DAC960_gam_get_controller_info(DAC960_ControllerInfo_T __user *UserSpaceControllerInfo)
6623 * DAC960_gam_ioctl is the ioctl function for performing RAID operations.
6624*/
6625
6626static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6627 unsigned long Argument)
6628{ 6623{
6629 long ErrorCode = 0;
6630 if (!capable(CAP_SYS_ADMIN)) return -EACCES;
6631
6632 mutex_lock(&DAC960_mutex);
6633 switch (Request)
6634 {
6635 case DAC960_IOCTL_GET_CONTROLLER_COUNT:
6636 ErrorCode = DAC960_ControllerCount;
6637 break;
6638 case DAC960_IOCTL_GET_CONTROLLER_INFO:
6639 {
6640 DAC960_ControllerInfo_T __user *UserSpaceControllerInfo =
6641 (DAC960_ControllerInfo_T __user *) Argument;
6642 DAC960_ControllerInfo_T ControllerInfo; 6624 DAC960_ControllerInfo_T ControllerInfo;
6643 DAC960_Controller_T *Controller; 6625 DAC960_Controller_T *Controller;
6644 int ControllerNumber; 6626 int ControllerNumber;
6627 long ErrorCode;
6628
6645 if (UserSpaceControllerInfo == NULL) 6629 if (UserSpaceControllerInfo == NULL)
6646 ErrorCode = -EINVAL; 6630 ErrorCode = -EINVAL;
6647 else ErrorCode = get_user(ControllerNumber, 6631 else ErrorCode = get_user(ControllerNumber,
6648 &UserSpaceControllerInfo->ControllerNumber); 6632 &UserSpaceControllerInfo->ControllerNumber);
6649 if (ErrorCode != 0) 6633 if (ErrorCode != 0)
6650 break; 6634 goto out;
6651 ErrorCode = -ENXIO; 6635 ErrorCode = -ENXIO;
6652 if (ControllerNumber < 0 || 6636 if (ControllerNumber < 0 ||
6653 ControllerNumber > DAC960_ControllerCount - 1) { 6637 ControllerNumber > DAC960_ControllerCount - 1) {
6654 break; 6638 goto out;
6655 } 6639 }
6656 Controller = DAC960_Controllers[ControllerNumber]; 6640 Controller = DAC960_Controllers[ControllerNumber];
6657 if (Controller == NULL) 6641 if (Controller == NULL)
6658 break; 6642 goto out;
6659 memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T)); 6643 memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
6660 ControllerInfo.ControllerNumber = ControllerNumber; 6644 ControllerInfo.ControllerNumber = ControllerNumber;
6661 ControllerInfo.FirmwareType = Controller->FirmwareType; 6645 ControllerInfo.FirmwareType = Controller->FirmwareType;
@@ -6670,12 +6654,12 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6670 strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion); 6654 strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
6671 ErrorCode = (copy_to_user(UserSpaceControllerInfo, &ControllerInfo, 6655 ErrorCode = (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
6672 sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0); 6656 sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
6673 break; 6657out:
6674 } 6658 return ErrorCode;
6675 case DAC960_IOCTL_V1_EXECUTE_COMMAND: 6659}
6676 { 6660
6677 DAC960_V1_UserCommand_T __user *UserSpaceUserCommand = 6661static long DAC960_gam_v1_execute_command(DAC960_V1_UserCommand_T __user *UserSpaceUserCommand)
6678 (DAC960_V1_UserCommand_T __user *) Argument; 6662{
6679 DAC960_V1_UserCommand_T UserCommand; 6663 DAC960_V1_UserCommand_T UserCommand;
6680 DAC960_Controller_T *Controller; 6664 DAC960_Controller_T *Controller;
6681 DAC960_Command_T *Command = NULL; 6665 DAC960_Command_T *Command = NULL;
@@ -6688,39 +6672,41 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6688 int ControllerNumber, DataTransferLength; 6672 int ControllerNumber, DataTransferLength;
6689 unsigned char *DataTransferBuffer = NULL; 6673 unsigned char *DataTransferBuffer = NULL;
6690 dma_addr_t DataTransferBufferDMA; 6674 dma_addr_t DataTransferBufferDMA;
6675 long ErrorCode;
6676
6691 if (UserSpaceUserCommand == NULL) { 6677 if (UserSpaceUserCommand == NULL) {
6692 ErrorCode = -EINVAL; 6678 ErrorCode = -EINVAL;
6693 break; 6679 goto out;
6694 } 6680 }
6695 if (copy_from_user(&UserCommand, UserSpaceUserCommand, 6681 if (copy_from_user(&UserCommand, UserSpaceUserCommand,
6696 sizeof(DAC960_V1_UserCommand_T))) { 6682 sizeof(DAC960_V1_UserCommand_T))) {
6697 ErrorCode = -EFAULT; 6683 ErrorCode = -EFAULT;
6698 break; 6684 goto out;
6699 } 6685 }
6700 ControllerNumber = UserCommand.ControllerNumber; 6686 ControllerNumber = UserCommand.ControllerNumber;
6701 ErrorCode = -ENXIO; 6687 ErrorCode = -ENXIO;
6702 if (ControllerNumber < 0 || 6688 if (ControllerNumber < 0 ||
6703 ControllerNumber > DAC960_ControllerCount - 1) 6689 ControllerNumber > DAC960_ControllerCount - 1)
6704 break; 6690 goto out;
6705 Controller = DAC960_Controllers[ControllerNumber]; 6691 Controller = DAC960_Controllers[ControllerNumber];
6706 if (Controller == NULL) 6692 if (Controller == NULL)
6707 break; 6693 goto out;
6708 ErrorCode = -EINVAL; 6694 ErrorCode = -EINVAL;
6709 if (Controller->FirmwareType != DAC960_V1_Controller) 6695 if (Controller->FirmwareType != DAC960_V1_Controller)
6710 break; 6696 goto out;
6711 CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode; 6697 CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
6712 DataTransferLength = UserCommand.DataTransferLength; 6698 DataTransferLength = UserCommand.DataTransferLength;
6713 if (CommandOpcode & 0x80) 6699 if (CommandOpcode & 0x80)
6714 break; 6700 goto out;
6715 if (CommandOpcode == DAC960_V1_DCDB) 6701 if (CommandOpcode == DAC960_V1_DCDB)
6716 { 6702 {
6717 if (copy_from_user(&DCDB, UserCommand.DCDB, 6703 if (copy_from_user(&DCDB, UserCommand.DCDB,
6718 sizeof(DAC960_V1_DCDB_T))) { 6704 sizeof(DAC960_V1_DCDB_T))) {
6719 ErrorCode = -EFAULT; 6705 ErrorCode = -EFAULT;
6720 break; 6706 goto out;
6721 } 6707 }
6722 if (DCDB.Channel >= DAC960_V1_MaxChannels) 6708 if (DCDB.Channel >= DAC960_V1_MaxChannels)
6723 break; 6709 goto out;
6724 if (!((DataTransferLength == 0 && 6710 if (!((DataTransferLength == 0 &&
6725 DCDB.Direction 6711 DCDB.Direction
6726 == DAC960_V1_DCDB_NoDataTransfer) || 6712 == DAC960_V1_DCDB_NoDataTransfer) ||
@@ -6730,15 +6716,15 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6730 (DataTransferLength < 0 && 6716 (DataTransferLength < 0 &&
6731 DCDB.Direction 6717 DCDB.Direction
6732 == DAC960_V1_DCDB_DataTransferSystemToDevice))) 6718 == DAC960_V1_DCDB_DataTransferSystemToDevice)))
6733 break; 6719 goto out;
6734 if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength) 6720 if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
6735 != abs(DataTransferLength)) 6721 != abs(DataTransferLength))
6736 break; 6722 goto out;
6737 DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice, 6723 DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
6738 sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA); 6724 sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
6739 if (DCDB_IOBUF == NULL) { 6725 if (DCDB_IOBUF == NULL) {
6740 ErrorCode = -ENOMEM; 6726 ErrorCode = -ENOMEM;
6741 break; 6727 goto out;
6742 } 6728 }
6743 } 6729 }
6744 ErrorCode = -ENOMEM; 6730 ErrorCode = -ENOMEM;
@@ -6748,19 +6734,19 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6748 DataTransferLength, 6734 DataTransferLength,
6749 &DataTransferBufferDMA); 6735 &DataTransferBufferDMA);
6750 if (DataTransferBuffer == NULL) 6736 if (DataTransferBuffer == NULL)
6751 break; 6737 goto out;
6752 } 6738 }
6753 else if (DataTransferLength < 0) 6739 else if (DataTransferLength < 0)
6754 { 6740 {
6755 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice, 6741 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6756 -DataTransferLength, &DataTransferBufferDMA); 6742 -DataTransferLength, &DataTransferBufferDMA);
6757 if (DataTransferBuffer == NULL) 6743 if (DataTransferBuffer == NULL)
6758 break; 6744 goto out;
6759 if (copy_from_user(DataTransferBuffer, 6745 if (copy_from_user(DataTransferBuffer,
6760 UserCommand.DataTransferBuffer, 6746 UserCommand.DataTransferBuffer,
6761 -DataTransferLength)) { 6747 -DataTransferLength)) {
6762 ErrorCode = -EFAULT; 6748 ErrorCode = -EFAULT;
6763 break; 6749 goto out;
6764 } 6750 }
6765 } 6751 }
6766 if (CommandOpcode == DAC960_V1_DCDB) 6752 if (CommandOpcode == DAC960_V1_DCDB)
@@ -6837,12 +6823,12 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6837 if (DCDB_IOBUF != NULL) 6823 if (DCDB_IOBUF != NULL)
6838 pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T), 6824 pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
6839 DCDB_IOBUF, DCDB_IOBUFDMA); 6825 DCDB_IOBUF, DCDB_IOBUFDMA);
6840 break; 6826 out:
6841 } 6827 return ErrorCode;
6842 case DAC960_IOCTL_V2_EXECUTE_COMMAND: 6828}
6843 { 6829
6844 DAC960_V2_UserCommand_T __user *UserSpaceUserCommand = 6830static long DAC960_gam_v2_execute_command(DAC960_V2_UserCommand_T __user *UserSpaceUserCommand)
6845 (DAC960_V2_UserCommand_T __user *) Argument; 6831{
6846 DAC960_V2_UserCommand_T UserCommand; 6832 DAC960_V2_UserCommand_T UserCommand;
6847 DAC960_Controller_T *Controller; 6833 DAC960_Controller_T *Controller;
6848 DAC960_Command_T *Command = NULL; 6834 DAC960_Command_T *Command = NULL;
@@ -6855,26 +6841,26 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6855 dma_addr_t DataTransferBufferDMA; 6841 dma_addr_t DataTransferBufferDMA;
6856 unsigned char *RequestSenseBuffer = NULL; 6842 unsigned char *RequestSenseBuffer = NULL;
6857 dma_addr_t RequestSenseBufferDMA; 6843 dma_addr_t RequestSenseBufferDMA;
6844 long ErrorCode = -EINVAL;
6858 6845
6859 ErrorCode = -EINVAL;
6860 if (UserSpaceUserCommand == NULL) 6846 if (UserSpaceUserCommand == NULL)
6861 break; 6847 goto out;
6862 if (copy_from_user(&UserCommand, UserSpaceUserCommand, 6848 if (copy_from_user(&UserCommand, UserSpaceUserCommand,
6863 sizeof(DAC960_V2_UserCommand_T))) { 6849 sizeof(DAC960_V2_UserCommand_T))) {
6864 ErrorCode = -EFAULT; 6850 ErrorCode = -EFAULT;
6865 break; 6851 goto out;
6866 } 6852 }
6867 ErrorCode = -ENXIO; 6853 ErrorCode = -ENXIO;
6868 ControllerNumber = UserCommand.ControllerNumber; 6854 ControllerNumber = UserCommand.ControllerNumber;
6869 if (ControllerNumber < 0 || 6855 if (ControllerNumber < 0 ||
6870 ControllerNumber > DAC960_ControllerCount - 1) 6856 ControllerNumber > DAC960_ControllerCount - 1)
6871 break; 6857 goto out;
6872 Controller = DAC960_Controllers[ControllerNumber]; 6858 Controller = DAC960_Controllers[ControllerNumber];
6873 if (Controller == NULL) 6859 if (Controller == NULL)
6874 break; 6860 goto out;
6875 if (Controller->FirmwareType != DAC960_V2_Controller){ 6861 if (Controller->FirmwareType != DAC960_V2_Controller){
6876 ErrorCode = -EINVAL; 6862 ErrorCode = -EINVAL;
6877 break; 6863 goto out;
6878 } 6864 }
6879 DataTransferLength = UserCommand.DataTransferLength; 6865 DataTransferLength = UserCommand.DataTransferLength;
6880 ErrorCode = -ENOMEM; 6866 ErrorCode = -ENOMEM;
@@ -6884,14 +6870,14 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6884 DataTransferLength, 6870 DataTransferLength,
6885 &DataTransferBufferDMA); 6871 &DataTransferBufferDMA);
6886 if (DataTransferBuffer == NULL) 6872 if (DataTransferBuffer == NULL)
6887 break; 6873 goto out;
6888 } 6874 }
6889 else if (DataTransferLength < 0) 6875 else if (DataTransferLength < 0)
6890 { 6876 {
6891 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice, 6877 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6892 -DataTransferLength, &DataTransferBufferDMA); 6878 -DataTransferLength, &DataTransferBufferDMA);
6893 if (DataTransferBuffer == NULL) 6879 if (DataTransferBuffer == NULL)
6894 break; 6880 goto out;
6895 if (copy_from_user(DataTransferBuffer, 6881 if (copy_from_user(DataTransferBuffer,
6896 UserCommand.DataTransferBuffer, 6882 UserCommand.DataTransferBuffer,
6897 -DataTransferLength)) { 6883 -DataTransferLength)) {
@@ -7001,42 +6987,44 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
7001 if (RequestSenseBuffer != NULL) 6987 if (RequestSenseBuffer != NULL)
7002 pci_free_consistent(Controller->PCIDevice, RequestSenseLength, 6988 pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
7003 RequestSenseBuffer, RequestSenseBufferDMA); 6989 RequestSenseBuffer, RequestSenseBufferDMA);
7004 break; 6990out:
7005 } 6991 return ErrorCode;
7006 case DAC960_IOCTL_V2_GET_HEALTH_STATUS: 6992}
7007 { 6993
7008 DAC960_V2_GetHealthStatus_T __user *UserSpaceGetHealthStatus = 6994static long DAC960_gam_v2_get_health_status(DAC960_V2_GetHealthStatus_T __user *UserSpaceGetHealthStatus)
7009 (DAC960_V2_GetHealthStatus_T __user *) Argument; 6995{
7010 DAC960_V2_GetHealthStatus_T GetHealthStatus; 6996 DAC960_V2_GetHealthStatus_T GetHealthStatus;
7011 DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer; 6997 DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
7012 DAC960_Controller_T *Controller; 6998 DAC960_Controller_T *Controller;
7013 int ControllerNumber; 6999 int ControllerNumber;
7000 long ErrorCode;
7001
7014 if (UserSpaceGetHealthStatus == NULL) { 7002 if (UserSpaceGetHealthStatus == NULL) {
7015 ErrorCode = -EINVAL; 7003 ErrorCode = -EINVAL;
7016 break; 7004 goto out;
7017 } 7005 }
7018 if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus, 7006 if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
7019 sizeof(DAC960_V2_GetHealthStatus_T))) { 7007 sizeof(DAC960_V2_GetHealthStatus_T))) {
7020 ErrorCode = -EFAULT; 7008 ErrorCode = -EFAULT;
7021 break; 7009 goto out;
7022 } 7010 }
7023 ErrorCode = -ENXIO; 7011 ErrorCode = -ENXIO;
7024 ControllerNumber = GetHealthStatus.ControllerNumber; 7012 ControllerNumber = GetHealthStatus.ControllerNumber;
7025 if (ControllerNumber < 0 || 7013 if (ControllerNumber < 0 ||
7026 ControllerNumber > DAC960_ControllerCount - 1) 7014 ControllerNumber > DAC960_ControllerCount - 1)
7027 break; 7015 goto out;
7028 Controller = DAC960_Controllers[ControllerNumber]; 7016 Controller = DAC960_Controllers[ControllerNumber];
7029 if (Controller == NULL) 7017 if (Controller == NULL)
7030 break; 7018 goto out;
7031 if (Controller->FirmwareType != DAC960_V2_Controller) { 7019 if (Controller->FirmwareType != DAC960_V2_Controller) {
7032 ErrorCode = -EINVAL; 7020 ErrorCode = -EINVAL;
7033 break; 7021 goto out;
7034 } 7022 }
7035 if (copy_from_user(&HealthStatusBuffer, 7023 if (copy_from_user(&HealthStatusBuffer,
7036 GetHealthStatus.HealthStatusBuffer, 7024 GetHealthStatus.HealthStatusBuffer,
7037 sizeof(DAC960_V2_HealthStatusBuffer_T))) { 7025 sizeof(DAC960_V2_HealthStatusBuffer_T))) {
7038 ErrorCode = -EFAULT; 7026 ErrorCode = -EFAULT;
7039 break; 7027 goto out;
7040 } 7028 }
7041 ErrorCode = wait_event_interruptible_timeout(Controller->HealthStatusWaitQueue, 7029 ErrorCode = wait_event_interruptible_timeout(Controller->HealthStatusWaitQueue,
7042 !(Controller->V2.HealthStatusBuffer->StatusChangeCounter 7030 !(Controller->V2.HealthStatusBuffer->StatusChangeCounter
@@ -7046,7 +7034,7 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
7046 DAC960_MonitoringTimerInterval); 7034 DAC960_MonitoringTimerInterval);
7047 if (ErrorCode == -ERESTARTSYS) { 7035 if (ErrorCode == -ERESTARTSYS) {
7048 ErrorCode = -EINTR; 7036 ErrorCode = -EINTR;
7049 break; 7037 goto out;
7050 } 7038 }
7051 if (copy_to_user(GetHealthStatus.HealthStatusBuffer, 7039 if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
7052 Controller->V2.HealthStatusBuffer, 7040 Controller->V2.HealthStatusBuffer,
@@ -7054,7 +7042,39 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
7054 ErrorCode = -EFAULT; 7042 ErrorCode = -EFAULT;
7055 else 7043 else
7056 ErrorCode = 0; 7044 ErrorCode = 0;
7057 } 7045
7046out:
7047 return ErrorCode;
7048}
7049
7050/*
7051 * DAC960_gam_ioctl is the ioctl function for performing RAID operations.
7052*/
7053
7054static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
7055 unsigned long Argument)
7056{
7057 long ErrorCode = 0;
7058 void __user *argp = (void __user *)Argument;
7059 if (!capable(CAP_SYS_ADMIN)) return -EACCES;
7060
7061 mutex_lock(&DAC960_mutex);
7062 switch (Request)
7063 {
7064 case DAC960_IOCTL_GET_CONTROLLER_COUNT:
7065 ErrorCode = DAC960_ControllerCount;
7066 break;
7067 case DAC960_IOCTL_GET_CONTROLLER_INFO:
7068 ErrorCode = DAC960_gam_get_controller_info(argp);
7069 break;
7070 case DAC960_IOCTL_V1_EXECUTE_COMMAND:
7071 ErrorCode = DAC960_gam_v1_execute_command(argp);
7072 break;
7073 case DAC960_IOCTL_V2_EXECUTE_COMMAND:
7074 ErrorCode = DAC960_gam_v2_execute_command(argp);
7075 break;
7076 case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
7077 ErrorCode = DAC960_gam_v2_get_health_status(argp);
7058 break; 7078 break;
7059 default: 7079 default:
7060 ErrorCode = -ENOTTY; 7080 ErrorCode = -ENOTTY;