Skip to content

Commit 5b76ffd

Browse files
Christoph HellwigLinus Torvalds
authored andcommitted
[PATCH] DAC960: add support for Mylex AcceleRAID 4/5/600
This patch adds support for a new class of DAC960 controllers. It's based on the GPLed idac320 driver from IBM for Linux 2.4.18. That driver is a fork of the 2.4.18 version of DAC960 that adds support for this new type of controllers (internally called "GEM Series"), that differ from other DAC960 V2 firmware controllers only in the register offsets and removes support for all others. This patch instead integrates support for these controllers into the DAC960 driver. Thanks to Anders Norrbring for pointing me to the idac320 driver and testing this patch. No Signed-Off: line because all code is either copy & pasted from IBM's idac320 driver or support for other controllers in the 2.6 DAC960 driver. Note: the really odd formating matches the rest of the DAC960 driver. Cc: Dave Olien <dmo@osdl.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent c835a38 commit 5b76ffd

3 files changed

Lines changed: 449 additions & 1 deletion

File tree

‎drivers/block/DAC960.c‎

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Linux Driver for Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers
44
55
Copyright 1998-2001 by Leonard N. Zubkoff <lnz@dandelion.com>
6+
Portions Copyright 2002 by Mylex (An IBM Business Unit)
67
78
This program is free software; you may redistribute and/or modify it under
89
the terms of the GNU General Public License Version 2 as published by the
@@ -532,6 +533,34 @@ static void DAC960_WaitForCommand(DAC960_Controller_T *Controller)
532533
spin_lock_irq(&Controller->queue_lock);
533534
}
534535

536+
/*
537+
DAC960_GEM_QueueCommand queues Command for DAC960 GEM Series Controllers.
538+
*/
539+
540+
static void DAC960_GEM_QueueCommand(DAC960_Command_T *Command)
541+
{
542+
DAC960_Controller_T *Controller = Command->Controller;
543+
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
544+
DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
545+
DAC960_V2_CommandMailbox_T *NextCommandMailbox =
546+
Controller->V2.NextCommandMailbox;
547+
548+
CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
549+
DAC960_GEM_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
550+
551+
if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
552+
Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
553+
DAC960_GEM_MemoryMailboxNewCommand(ControllerBaseAddress);
554+
555+
Controller->V2.PreviousCommandMailbox2 =
556+
Controller->V2.PreviousCommandMailbox1;
557+
Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
558+
559+
if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
560+
NextCommandMailbox = Controller->V2.FirstCommandMailbox;
561+
562+
Controller->V2.NextCommandMailbox = NextCommandMailbox;
563+
}
535564

536565
/*
537566
DAC960_BA_QueueCommand queues Command for DAC960 BA Series Controllers.
@@ -1464,6 +1493,17 @@ static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
14641493
Controller->V2.FirstStatusMailboxDMA;
14651494
switch (Controller->HardwareType)
14661495
{
1496+
case DAC960_GEM_Controller:
1497+
while (DAC960_GEM_HardwareMailboxFullP(ControllerBaseAddress))
1498+
udelay(1);
1499+
DAC960_GEM_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1500+
DAC960_GEM_HardwareMailboxNewCommand(ControllerBaseAddress);
1501+
while (!DAC960_GEM_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1502+
udelay(1);
1503+
CommandStatus = DAC960_GEM_ReadCommandStatus(ControllerBaseAddress);
1504+
DAC960_GEM_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1505+
DAC960_GEM_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1506+
break;
14671507
case DAC960_BA_Controller:
14681508
while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress))
14691509
udelay(1);
@@ -2627,6 +2667,9 @@ static void DAC960_DetectCleanup(DAC960_Controller_T *Controller)
26272667
if (Controller->MemoryMappedAddress) {
26282668
switch(Controller->HardwareType)
26292669
{
2670+
case DAC960_GEM_Controller:
2671+
DAC960_GEM_DisableInterrupts(Controller->BaseAddress);
2672+
break;
26302673
case DAC960_BA_Controller:
26312674
DAC960_BA_DisableInterrupts(Controller->BaseAddress);
26322675
break;
@@ -2705,6 +2748,9 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
27052748

27062749
switch (Controller->HardwareType)
27072750
{
2751+
case DAC960_GEM_Controller:
2752+
Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2753+
break;
27082754
case DAC960_BA_Controller:
27092755
Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
27102756
break;
@@ -2756,6 +2802,36 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
27562802
BaseAddress = Controller->BaseAddress;
27572803
switch (Controller->HardwareType)
27582804
{
2805+
case DAC960_GEM_Controller:
2806+
DAC960_GEM_DisableInterrupts(BaseAddress);
2807+
DAC960_GEM_AcknowledgeHardwareMailboxStatus(BaseAddress);
2808+
udelay(1000);
2809+
while (DAC960_GEM_InitializationInProgressP(BaseAddress))
2810+
{
2811+
if (DAC960_GEM_ReadErrorStatus(BaseAddress, &ErrorStatus,
2812+
&Parameter0, &Parameter1) &&
2813+
DAC960_ReportErrorStatus(Controller, ErrorStatus,
2814+
Parameter0, Parameter1))
2815+
goto Failure;
2816+
udelay(10);
2817+
}
2818+
if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2819+
{
2820+
DAC960_Error("Unable to Enable Memory Mailbox Interface "
2821+
"for Controller at\n", Controller);
2822+
goto Failure;
2823+
}
2824+
DAC960_GEM_EnableInterrupts(BaseAddress);
2825+
Controller->QueueCommand = DAC960_GEM_QueueCommand;
2826+
Controller->ReadControllerConfiguration =
2827+
DAC960_V2_ReadControllerConfiguration;
2828+
Controller->ReadDeviceConfiguration =
2829+
DAC960_V2_ReadDeviceConfiguration;
2830+
Controller->ReportDeviceConfiguration =
2831+
DAC960_V2_ReportDeviceConfiguration;
2832+
Controller->QueueReadWriteCommand =
2833+
DAC960_V2_QueueReadWriteCommand;
2834+
break;
27592835
case DAC960_BA_Controller:
27602836
DAC960_BA_DisableInterrupts(BaseAddress);
27612837
DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress);
@@ -5189,6 +5265,47 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
51895265
wake_up(&Controller->CommandWaitQueue);
51905266
}
51915267

5268+
/*
5269+
DAC960_GEM_InterruptHandler handles hardware interrupts from DAC960 GEM Series
5270+
Controllers.
5271+
*/
5272+
5273+
static irqreturn_t DAC960_GEM_InterruptHandler(int IRQ_Channel,
5274+
void *DeviceIdentifier,
5275+
struct pt_regs *InterruptRegisters)
5276+
{
5277+
DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5278+
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5279+
DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5280+
unsigned long flags;
5281+
5282+
spin_lock_irqsave(&Controller->queue_lock, flags);
5283+
DAC960_GEM_AcknowledgeInterrupt(ControllerBaseAddress);
5284+
NextStatusMailbox = Controller->V2.NextStatusMailbox;
5285+
while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5286+
{
5287+
DAC960_V2_CommandIdentifier_T CommandIdentifier =
5288+
NextStatusMailbox->Fields.CommandIdentifier;
5289+
DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5290+
Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5291+
Command->V2.RequestSenseLength =
5292+
NextStatusMailbox->Fields.RequestSenseLength;
5293+
Command->V2.DataTransferResidue =
5294+
NextStatusMailbox->Fields.DataTransferResidue;
5295+
NextStatusMailbox->Words[0] = 0;
5296+
if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5297+
NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5298+
DAC960_V2_ProcessCompletedCommand(Command);
5299+
}
5300+
Controller->V2.NextStatusMailbox = NextStatusMailbox;
5301+
/*
5302+
Attempt to remove additional I/O Requests from the Controller's
5303+
I/O Request Queue and queue them to the Controller.
5304+
*/
5305+
DAC960_ProcessRequest(Controller);
5306+
spin_unlock_irqrestore(&Controller->queue_lock, flags);
5307+
return IRQ_HANDLED;
5308+
}
51925309

51935310
/*
51945311
DAC960_BA_InterruptHandler handles hardware interrupts from DAC960 BA Series
@@ -6962,6 +7079,14 @@ static void DAC960_gam_cleanup(void)
69627079

69637080
#endif /* DAC960_GAM_MINOR */
69647081

7082+
static struct DAC960_privdata DAC960_GEM_privdata = {
7083+
.HardwareType = DAC960_GEM_Controller,
7084+
.FirmwareType = DAC960_V2_Controller,
7085+
.InterruptHandler = DAC960_GEM_InterruptHandler,
7086+
.MemoryWindowSize = DAC960_GEM_RegisterWindowSize,
7087+
};
7088+
7089+
69657090
static struct DAC960_privdata DAC960_BA_privdata = {
69667091
.HardwareType = DAC960_BA_Controller,
69677092
.FirmwareType = DAC960_V2_Controller,
@@ -7005,6 +7130,13 @@ static struct DAC960_privdata DAC960_P_privdata = {
70057130
};
70067131

70077132
static struct pci_device_id DAC960_id_table[] = {
7133+
{
7134+
.vendor = PCI_VENDOR_ID_MYLEX,
7135+
.device = PCI_DEVICE_ID_MYLEX_DAC960_GEM,
7136+
.subvendor = PCI_ANY_ID,
7137+
.subdevice = PCI_ANY_ID,
7138+
.driver_data = (unsigned long) &DAC960_GEM_privdata,
7139+
},
70087140
{
70097141
.vendor = PCI_VENDOR_ID_MYLEX,
70107142
.device = PCI_DEVICE_ID_MYLEX_DAC960_BA,

0 commit comments

Comments
 (0)