Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
8ef4b795
Commit
8ef4b795
authored
Aug 21, 2004
by
James Bottomley
Committed by
James Bottomley
Aug 21, 2004
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
78357e74
030c7a99
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
434 additions
and
334 deletions
+434
-334
Documentation/scsi/ChangeLog.megaraid
Documentation/scsi/ChangeLog.megaraid
+122
-1
Documentation/scsi/megaraid.txt
Documentation/scsi/megaraid.txt
+1
-1
drivers/scsi/megaraid/Kconfig.megaraid
drivers/scsi/megaraid/Kconfig.megaraid
+3
-7
drivers/scsi/megaraid/mega_common.h
drivers/scsi/megaraid/mega_common.h
+0
-15
drivers/scsi/megaraid/megaraid_ioctl.h
drivers/scsi/megaraid/megaraid_ioctl.h
+2
-2
drivers/scsi/megaraid/megaraid_mbox.c
drivers/scsi/megaraid/megaraid_mbox.c
+167
-197
drivers/scsi/megaraid/megaraid_mbox.h
drivers/scsi/megaraid/megaraid_mbox.h
+9
-3
drivers/scsi/megaraid/megaraid_mm.c
drivers/scsi/megaraid/megaraid_mm.c
+127
-71
drivers/scsi/megaraid/megaraid_mm.h
drivers/scsi/megaraid/megaraid_mm.h
+3
-37
No files found.
Documentation/scsi/ChangeLog.megaraid
View file @
8ef4b795
Release Date : Thu Aug 19 09:58:33 EDT 2004 - Atul Mukker <atulm@lsil.com>
Current Version : 2.20.3.0 (scsi module), 2.20.2.0 (cmm module)
Older Version : 2.20.2.0 (scsi module), 2.20.1.0 (cmm module)
i. When copying the mailbox packets, copy only first 14 bytes (for 32-bit
mailboxes) and only first 22 bytes (for 64-bit mailboxes). This is to
avoid getting the stale values for busy bit. We want to set the busy
bit just before issuing command to the FW.
ii. In the reset handling, if the reseted command is not owned by the
driver, do not (wrongly) print information for the "attached" driver
packet.
iii. Have extended wait when issuing command in synchronous mode. This is
required for the cases where the option ROM is disabled and there is
no BIOS to start the controller. The FW starts to boot after receiving
the first command from the driver. The current driver has 1 second
timeout for the synchronous commands, which is far less than what is
actually required. We now wait up to MBOX_RESET_TIME (180 seconds) for
FW boot process.
iv. In megaraid_mbox_product_info, clear the mailbox contents completely
before preparing the command for inquiry3. This is to ensure that the
FW does not get junk values in the command.
v. Do away with the redundant LSI_CONFIG_COMPAT redefinition for
CONFIG_COMPAT. Replace <asm/ioctl32.h> with <linux/ioctl32.h>
- James Bottomley <James.Bottomley@SteelEye.com>, 08.17.2004
linux-scsi mailing list
vi. Add support for 64-bit applications. Current drivers assume only
32-bit applications, even on 64-bit platforms. Use the "data" and
"buffer" fields of the mimd_t structure, instead of embedded 32-bit
addresses in application mailbox and passthru structures.
vii. Move the function declarations for the management module from
megaraid_mm.h to megaraid_mm.c
- Andrew Morton <akpm@osdl.org>, 08.19.2004
linux-scsi mailing list
viii. Change default values for MEGARAID_NEWGEN, MEGARAID_MM, and
MEGARAID_MAILBOX to 'n' in Kconfig.megaraid
- Andrew Morton <akpm@osdl.org>, 08.19.2004
linux-scsi mailing list
ix. replace udelay with msleep
x. Typos corrected in comments and whitespace adjustments, explicit
grouping of expressions.
Release Date : Fri Jul 23 15:22:07 EDT 2004 - Atul Mukker <atulm@lsil.com>
Current Version : 2.20.2.0 (scsi module), 2.20.1.0 (cmm module)
Older Version : 2.20.1.0 (scsi module), 2.20.0.0 (cmm module)
i. Add PCI ids for Acer ROMB 2E solution
ii. Add PCI ids for I4
iii. Typo corrected for subsys id for megaraid sata 300-4x
iv. Remove yield() while mailbox handshake in synchronous commands
"My other main gripe is things like this:
+ // wait for maximum 1 second for status to post
+ for (i = 0; i < 40000; i++) {
+ if (mbox->numstatus != 0xFF) break;
+ udelay(25); yield();
+ }
which litter the driver. Use of yield() in drivers is deprecated."
- James Bottomley <James.Bottomley@SteelEye.com>, 07.14.2004
linux-scsi mailing list
v. Remove redundant __megaraid_busywait_mbox routine
vi. Fix bug in the managment module, which causes a system lockup when the
IO module is loaded and then unloaded, followed by executing any
management utility. The current version of management module does not
handle the adapter unregister properly.
Specifically, it still keeps a reference to the unregistered
controllers. To avoid this, the static array adapters has been
replaced by a dynamic list, which gets updated every time an adapter
is added or removed.
Also, during unregistration of the IO module, the resources are
now released in the exact reverse order of the allocation time
sequence.
Release Date : Fri Jun 25 18:58:43 EDT 2004 - Atul Mukker <atulm@lsil.com>
Current Version : 2.20.1.0
Older Version : megaraid 2.20.0.1
i. Stale list pointer in adapter causes kernel panic when module
megaraid_mbox is unloaded
Release Date : Thu Jun 24 20:37:11 EDT 2004 - Atul Mukker <atulm@lsil.com>
Current Version : 2.20.0.1
Older Version : megaraid 2.20.0.00
i. Modules are not 'y' by default, but depend on current definition of
SCSI & PCI.
ii. Redundant structure mraid_driver_t removed.
iii. Miscellaneous indentation and goto/label fixes.
- Christoph Hellwig <hch@infradead.org>, 06.24.2004 linux-scsi
iv. scsi_host_put(), do just before completing HBA shutdown.
Release Date : Mon Jun 21 19:53:54 EDT 2004 - Atul Mukker <atulm@lsil.com>
Current Version : 2.20.0.0
Older Version : megaraid 2.20.0.rc2 and 2.00.3
...
...
@@ -55,5 +176,5 @@ ix. Better implementation of error handling and recovery. Driver now
performs extended errors recovery for instances like scsi cable pull.
x. Disassociate the management commands with an overlaid scsi command.
Driver now treats the mangement packets as special packets and has a
Driver now treats the man
a
gement packets as special packets and has a
dedicated callback routine.
Documentation/scsi/megaraid.txt
View file @
8ef4b795
...
...
@@ -61,7 +61,7 @@ uioc_t. The management module converts the older ioctl packets from the older
applications into uioc_t. After driver handles the uioc_t, the common module
will convert that back into the old format before returning to applications.
As new applications evolve and replace the old ones, the old packet format
As new applications evolve and replace the old ones, the old packet format
will be retired.
Common module dedicates one uioc_t packet to each controller registered. This
...
...
drivers/scsi/megaraid/Kconfig.megaraid
View file @
8ef4b795
config MEGARAID_NEWGEN
bool "LSI Logic New Generation RAID Device Drivers"
depends on PCI && SCSI
default y
help
LSI Logic RAID Device Drivers
config MEGARAID_MM
tristate "LSI Logic Management Module (New Driver)"
depends on PCI && SCSI && MEGARAID_NEWGEN
default m
help
Management Module provides ioctl, sysfs support for LSI Logic
RAID controllers.
...
...
@@ -19,7 +17,6 @@ config MEGARAID_MM
config MEGARAID_MAILBOX
tristate "LSI Logic MegaRAID Driver (New Driver)"
depends on PCI && SCSI && MEGARAID_MM
default $MEGARAID_MM
help
List of supported controllers
...
...
@@ -48,11 +45,10 @@ config MEGARAID_MAILBOX
LSI MegaRAID SCSI 320-4X 1000:0407:1000:0531
LSI MegaRAID SCSI 320-1E 1000:0408:1000:0001
LSI MegaRAID SCSI 320-2E 1000:0408:1000:0002
LSI MegaRAID SATA 150-2 1095:3112:1000:0534
LSI MegaRAID SATA 150-4 1000:1960:1000:4523
LSI MegaRAID SATA 150-6 1000:1960:1000:0523
LSI MegaRAID SATA
150-4X 1000:0409:1000:15
04
LSI MegaRAID SATA
150-8X 1000:0409:1000:15
08
LSI MegaRAID SATA
300-4X 1000:0409:1000:30
04
LSI MegaRAID SATA
300-8X 1000:0409:1000:30
08
INTEL RAID Controller SRCU42X 1000:0407:8086:0532
INTEL RAID Controller SRCS16 1000:1960:8086:0523
INTEL RAID Controller SRCU42E 1000:0408:8086:0002
...
...
@@ -62,6 +58,7 @@ config MEGARAID_MAILBOX
INTEL RAID Controller SROMBU42E 1000:0408:8086:3499
INTEL RAID Controller SRCU51L 1000:1960:8086:0520
FSC MegaRAID PCI Express ROMB 1000:0408:1734:1065
ACER MegaRAID ROMB-2E 1000:0408:1025:004D
To compile this driver as a module, choose M here: the
module will be called megaraid_mbox
...
...
@@ -70,7 +67,6 @@ if MEGARAID_NEWGEN=n
config MEGARAID_LEGACY
tristate "LSI Logic Legacy MegaRAID Driver"
depends on PCI && SCSI
default m
help
This driver supports the LSI MegaRAID 418, 428, 438, 466, 762, 490
and 467 SCSI host adapters. This driver also support the all U320
...
...
drivers/scsi/megaraid/mega_common.h
View file @
8ef4b795
...
...
@@ -113,7 +113,6 @@ typedef struct {
* @param max_channel : maximum channel number supported - inclusive
* @param max_target : max target supported - inclusive
* @param max_lun : max lun supported - inclusive
* @param list : list of megaraid host structures
* @param unique_id : unique identifier for each adapter
* @param irq : IRQ for this adapter
* @param ito : internal timeout value, (-1) means no timeout
...
...
@@ -171,7 +170,6 @@ typedef struct {
uint16_t
max_target
;
uint8_t
max_lun
;
struct
list_head
list
;
uint32_t
unique_id
;
uint8_t
irq
;
uint8_t
ito
;
...
...
@@ -244,19 +242,6 @@ typedef struct {
[SCP2TARGET(scp)] & 0xFF); \
}
/**
* struct mraid_driver_t - global driver data
* @param driver_version : driver version
* @param device_list : list of adapter_t structures
*
* mraid_driver_t contains information which is global to the driver.
*/
typedef
struct
{
uint8_t
driver_version
[
8
];
struct
list_head
device_list
;
}
mraid_driver_t
;
/*
* ### Helper routines ###
*/
...
...
drivers/scsi/megaraid/megaraid_ioctl.h
View file @
8ef4b795
...
...
@@ -64,8 +64,6 @@
#define GET_STATS 0x50000
#define GET_IOCTL_VERSION 0x01
#define MAX_LSI_CMN_ADAPS 16
#define EXT_IOCTL_SIGN_SZ 16
#define EXT_IOCTL_SIGN "$$_EXTD_IOCTL_$$"
...
...
@@ -249,6 +247,7 @@ typedef struct mm_dmapool {
* @pdev : pci dev; used for allocating dma'ble memory
* @issue_uioc : Driver supplied routine to issue uioc_t commands
* : issue_uioc(drvr_data, kioc, ISSUE/ABORT, uioc_done)
* @list : attach with the global list of adapters
* @kioc_list : block of mem for @max_kioc number of kiocs
* @kioc_pool : pool of free kiocs
* @kioc_pool_lock : protection for free pool
...
...
@@ -274,6 +273,7 @@ typedef struct mraid_mmadp {
/* Maintained by common module */
struct
list_head
list
;
uioc_t
*
kioc_list
;
struct
list_head
kioc_pool
;
spinlock_t
kioc_pool_lock
;
...
...
drivers/scsi/megaraid/megaraid_mbox.c
View file @
8ef4b795
...
...
@@ -10,7 +10,7 @@
* 2 of the License, or (at your option) any later version.
*
* FILE : megaraid.c
* Version : v2.20.
0.0 (June 23
2004)
* Version : v2.20.
2.0 (July 22
2004)
*
* Authors:
* Atul Mukker <Atul.Mukker@lsil.com>
...
...
@@ -46,11 +46,10 @@
* LSI MegaRAID SCSI 320-4X 1000 0407 1000 0531
* LSI MegaRAID SCSI 320-1E 1000 0408 1000 0001
* LSI MegaRAID SCSI 320-2E 1000 0408 1000 0002
* LSI MegaRAID SATA 150-2 1095 3112 1000 0534
* LSI MegaRAID SATA 150-4 1000 1960 1000 4523
* LSI MegaRAID SATA 150-6 1000 1960 1000 0523
* LSI MegaRAID SATA
150-4X 1000 0409 1000 15
04
* LSI MegaRAID SATA
150-8X 1000 0409 1000 15
08
* LSI MegaRAID SATA
300-4X 1000 0409 1000 30
04
* LSI MegaRAID SATA
300-8X 1000 0409 1000 30
08
*
* INTEL RAID Controller SRCU42X 1000 0407 8086 0532
* INTEL RAID Controller SRCS16 1000 1960 8086 0523
...
...
@@ -65,7 +64,10 @@
* FSC MegaRAID PCI Express ROMB 1000 0408 1734 1065
*
*
* For history of changes, see changelog.megaraid
* ACER MegaRAID ROMB-2E 1000 0408 1025 004D
*
*
* For history of changes, see Documentation/ChangeLog.megaraid
*/
#include "megaraid_mbox.h"
...
...
@@ -128,7 +130,6 @@ static irqreturn_t megaraid_isr(int, void *, struct pt_regs *);
static
inline
int
megaraid_ack_sequence
(
adapter_t
*
);
static
inline
int
megaraid_busywait_mbox
(
mraid_device_t
*
);
static
inline
int
__megaraid_busywait_mbox
(
mraid_device_t
*
);
static
int
megaraid_cmm_register
(
adapter_t
*
);
static
int
megaraid_cmm_unregister
(
adapter_t
*
);
...
...
@@ -205,9 +206,8 @@ MODULE_PARM_DESC(debug_level, "Debug level for driver (default=0)");
/*
* ### global data ###
*/
mraid_driver_t
mraid_driver_g
=
{
.
driver_version
=
{
0x02
,
0x20
,
0x00
,
0x00
,
6
,
21
,
20
,
4
},
};
static
uint8_t
megaraid_mbox_version
[
8
]
=
{
0x02
,
0x20
,
0x02
,
0x00
,
7
,
22
,
20
,
4
};
/*
...
...
@@ -352,6 +352,12 @@ static struct pci_device_id pci_id_table_g[] = {
PCI_VENDOR_ID_LSI_LOGIC
,
PCI_SUBSYS_ID_MEGARAID_SCSI_320_2E
,
},
{
PCI_VENDOR_ID_LSI_LOGIC
,
PCI_DEVICE_ID_MEGARAID_I4_133_RAID
,
PCI_VENDOR_ID_LSI_LOGIC
,
PCI_SUBSYS_ID_MEGARAID_I4_133_RAID
,
},
{
PCI_VENDOR_ID_LSI_LOGIC
,
PCI_DEVICE_ID_MEGARAID_SATA_150_4
,
...
...
@@ -430,6 +436,12 @@ static struct pci_device_id pci_id_table_g[] = {
PCI_SUBSYS_ID_FSC
,
PCI_SUBSYS_ID_FSC_MEGARAID_PCI_EXPRESS_ROMB
,
},
{
PCI_VENDOR_ID_LSI_LOGIC
,
PCI_DEVICE_ID_MEGARAID_ACER_ROMB_2E
,
PCI_VENDOR_ID_AI
,
PCI_SUBSYS_ID_MEGARAID_ACER_ROMB_2E
,
},
{
0
}
/* Terminating entry */
};
MODULE_DEVICE_TABLE
(
pci
,
pci_id_table_g
);
...
...
@@ -450,15 +462,15 @@ static struct pci_driver megaraid_pci_driver_g = {
* Scsi host template for megaraid unified driver
*/
static
struct
scsi_host_template
megaraid_template_g
=
{
.
module
=
THIS_MODULE
,
.
name
=
"LSI Logic MegaRAID driver"
,
.
proc_name
=
"megaraid"
,
.
queuecommand
=
megaraid_queue_command
,
.
eh_abort_handler
=
megaraid_abort_handler
,
.
eh_device_reset_handler
=
megaraid_reset_handler
,
.
eh_bus_reset_handler
=
megaraid_reset_handler
,
.
eh_host_reset_handler
=
megaraid_reset_handler
,
.
use_clustering
=
ENABLE_CLUSTERING
,
.
module
=
THIS_MODULE
,
.
name
=
"LSI Logic MegaRAID driver"
,
.
proc_name
=
"megaraid"
,
.
queuecommand
=
megaraid_queue_command
,
.
eh_abort_handler
=
megaraid_abort_handler
,
.
eh_device_reset_handler
=
megaraid_reset_handler
,
.
eh_bus_reset_handler
=
megaraid_reset_handler
,
.
eh_host_reset_handler
=
megaraid_reset_handler
,
.
use_clustering
=
ENABLE_CLUSTERING
,
};
...
...
@@ -471,7 +483,7 @@ static struct scsi_host_template megaraid_template_g = {
static
int
__init
megaraid_init
(
void
)
{
int
rval
;
int
rval
;
// Announce the driver version
con_log
(
CL_ANN
,
(
KERN_INFO
"megaraid: %s %s
\n
"
,
MEGARAID_VERSION
,
...
...
@@ -488,11 +500,6 @@ megaraid_init(void)
}
/*
* Setup the driver global data structures
*/
INIT_LIST_HEAD
(
&
mraid_driver_g
.
device_list
);
// register as a PCI hot-plug driver module
if
((
rval
=
pci_module_init
(
&
megaraid_pci_driver_g
)))
{
con_log
(
CL_ANN
,
(
KERN_WARNING
...
...
@@ -516,9 +523,6 @@ megaraid_exit(void)
// unregister as PCI hotplug driver
pci_unregister_driver
(
&
megaraid_pci_driver_g
);
// All adapters must be detached by now
ASSERT
(
list_empty
(
&
mraid_driver_g
.
device_list
));
return
;
}
...
...
@@ -535,10 +539,6 @@ static int __devinit
megaraid_probe_one
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
id
)
{
adapter_t
*
adapter
;
uint8_t
alloc_adapter_f
=
0
;
uint8_t
init_mbox_f
=
0
;
uint8_t
cmm_reg_f
=
0
;
uint8_t
io_attach_f
=
0
;
// detected a new controller
...
...
@@ -567,9 +567,8 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: out of memory, %s %d.
\n
"
,
__FUNCTION__
,
__LINE__
));
goto
fail
_probe_one
;
goto
out
_probe_one
;
}
alloc_adapter_f
=
1
;
memset
(
adapter
,
0
,
sizeof
(
adapter_t
));
...
...
@@ -587,7 +586,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: pci_set_dma_mask failed:%d
\n
"
,
__LINE__
));
goto
fail_probe_one
;
goto
out_free_adapter
;
}
...
...
@@ -613,9 +612,8 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: maibox adapter did not initialize
\n
"
));
goto
fail_probe_one
;
goto
out_free_adapter
;
}
init_mbox_f
=
1
;
// Register with LSI Common Management Module
if
(
megaraid_cmm_register
(
adapter
)
!=
0
)
{
...
...
@@ -623,45 +621,30 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: could not register with management module
\n
"
));
goto
fail_probe_one
;
goto
out_fini_mbox
;
}
cmm_reg_f
=
1
;
// setup adapter handle in PCI soft state
pci_set_drvdata
(
pdev
,
adapter
);
// attach with scsi mid-layer
if
(
megaraid_io_attach
(
adapter
)
!=
0
)
{
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: io attach failed
\n
"
));
goto
fail_probe_one
;
}
io_attach_f
=
1
;
// Adapter setup complete, put it in the global list of controllers
list_add_tail
(
&
adapter
->
list
,
&
mraid_driver_g
.
device_list
);
return
0
;
fail_probe_one:
if
(
io_attach_f
)
{
megaraid_io_detach
(
adapter
);
pci_set_drvdata
(
pdev
,
NULL
);
}
if
(
cmm_reg_f
)
{
megaraid_cmm_unregister
(
adapter
);
}
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: io attach failed
\n
"
));
if
(
init_mbox_f
)
{
megaraid_fini_mbox
(
adapter
);
goto
out_cmm_unreg
;
}
if
(
alloc_adapter_f
)
{
kfree
(
adapter
);
}
return
0
;
out_cmm_unreg:
pci_set_drvdata
(
pdev
,
NULL
);
megaraid_cmm_unregister
(
adapter
);
out_fini_mbox:
megaraid_fini_mbox
(
adapter
);
out_free_adapter:
kfree
(
adapter
);
out_probe_one:
pci_disable_device
(
pdev
);
return
-
ENODEV
;
...
...
@@ -682,7 +665,8 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
static
void
megaraid_detach_one
(
struct
pci_dev
*
pdev
)
{
adapter_t
*
adapter
;
adapter_t
*
adapter
;
struct
Scsi_Host
*
host
;
// Start a rollback on this adapter
...
...
@@ -704,15 +688,14 @@ megaraid_detach_one(struct pci_dev *pdev)
}
host
=
adapter
->
host
;
// do not allow any more requests from the management module for this
// adapter.
// FIXME: How do we account for the request which might still be
// pending with us?
atomic_set
(
&
adapter
->
being_detached
,
1
);
// remove the adapter from the global list of our controllers
list_del_init
(
&
adapter
->
list
);
// detach from the IO sub-system
megaraid_io_detach
(
adapter
);
...
...
@@ -732,6 +715,8 @@ megaraid_detach_one(struct pci_dev *pdev)
kfree
(
adapter
);
scsi_host_put
(
host
);
pci_disable_device
(
pdev
);
return
;
...
...
@@ -839,8 +824,6 @@ megaraid_io_detach(adapter_t *adapter)
scsi_remove_host
(
host
);
scsi_host_put
(
host
);
return
;
}
...
...
@@ -866,14 +849,11 @@ megaraid_init_mbox(adapter_t *adapter)
{
struct
pci_dev
*
pdev
;
mraid_device_t
*
raid_dev
;
uint8_t
mem_region_f
=
0
;
uint8_t
alloc_cmds_f
=
0
;
uint8_t
irq_f
=
0
;
int
i
;
adapter
->
ito
=
MBOX_TIMEOUT
;
pdev
=
adapter
->
pdev
;
adapter
->
ito
=
MBOX_TIMEOUT
;
pdev
=
adapter
->
pdev
;
/*
* Allocate and initialize the init data structure for mailbox
...
...
@@ -899,7 +879,7 @@ megaraid_init_mbox(adapter_t *adapter)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: mem region busy
\n
"
));
goto
fail_init
;
goto
out_free_raid_dev
;
}
raid_dev
->
baseaddr
=
(
unsigned
long
)
...
...
@@ -910,11 +890,8 @@ megaraid_init_mbox(adapter_t *adapter)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: could not map hba memory
\n
"
)
);
pci_release_regions
(
pdev
);
goto
fail_init
;
goto
out_release_regions
;
}
mem_region_f
=
1
;
//
// Setup the rest of the soft state using the library of FW routines
...
...
@@ -927,24 +904,21 @@ megaraid_init_mbox(adapter_t *adapter)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: Couldn't register IRQ %d!
\n
"
,
adapter
->
irq
));
goto
fail_init
;
goto
out_iounmap
;
}
irq_f
=
1
;
// initialize the mutual exclusion lock for the mailbox
spin_lock_init
(
&
raid_dev
->
mailbox_lock
);
// allocate memory required for commands
if
(
megaraid_alloc_cmd_packets
(
adapter
)
!=
0
)
{
goto
fail_init
;
goto
out_free_irq
;
}
alloc_cmds_f
=
1
;
// Product info
if
(
megaraid_mbox_product_info
(
adapter
)
!=
0
)
{
goto
fail_init
;
goto
out_alloc_cmds
;
}
// Do we support extended CDBs
...
...
@@ -1015,7 +989,7 @@ megaraid_init_mbox(adapter_t *adapter)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: could not set DMA mask for 64-bit.
\n
"
));
goto
fail_init
;
goto
out_alloc_cmds
;
}
// setup tasklet for DPC
...
...
@@ -1027,18 +1001,15 @@ megaraid_init_mbox(adapter_t *adapter)
return
0
;
fail_init:
if
(
alloc_cmds_f
)
{
megaraid_free_cmd_packets
(
adapter
);
}
if
(
irq_f
)
{
free_irq
(
adapter
->
irq
,
adapter
);
}
if
(
mem_region_f
)
{
iounmap
((
caddr_t
)
raid_dev
->
baseaddr
);
pci_release_regions
(
adapter
->
pdev
);
}
out_alloc_cmds:
megaraid_free_cmd_packets
(
adapter
);
out_free_irq:
free_irq
(
adapter
->
irq
,
adapter
);
out_iounmap:
iounmap
((
caddr_t
)
raid_dev
->
baseaddr
);
out_release_regions:
pci_release_regions
(
pdev
);
out_free_raid_dev:
kfree
(
raid_dev
);
return
-
1
;
...
...
@@ -1093,10 +1064,6 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
struct
mraid_pci_blk
*
epthru_pci_blk
;
struct
mraid_pci_blk
*
sg_pci_blk
;
struct
mraid_pci_blk
*
mbox_pci_blk
;
uint8_t
alloc_ibuf_f
=
0
;
uint8_t
alloc_common_mbox_f
=
0
;
uint8_t
alloc_scb_f
=
0
;
uint8_t
dma_pools_f
=
0
;
int
i
;
pdev
=
adapter
->
pdev
;
...
...
@@ -1116,7 +1083,6 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
return
-
1
;
}
memset
(
raid_dev
->
una_mbox64
,
0
,
sizeof
(
mbox64_t
));
alloc_common_mbox_f
=
1
;
/*
* Align the mailbox at 16-byte boundary
...
...
@@ -1143,9 +1109,8 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
"megaraid: out of memory, %s %d
\n
"
,
__FUNCTION__
,
__LINE__
));
goto
fail_alloc_cmds
;
goto
out_free_common_mbox
;
}
alloc_ibuf_f
=
1
;
memset
(
adapter
->
ibuf
,
0
,
MBOX_IBUF_SIZE
);
// Allocate memory for our SCSI Command Blocks and their associated
...
...
@@ -1166,9 +1131,8 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: out of memory, %s %d
\n
"
,
__FUNCTION__
,
__LINE__
));
goto
fail_alloc_cmds
;
goto
out_free_ibuf
;
}
alloc_scb_f
=
1
;
memset
(
adapter
->
kscb_list
,
0
,
sizeof
(
scb_t
)
*
MBOX_MAX_SCSI_CMDS
);
// memory allocation for our command packets
...
...
@@ -1176,9 +1140,8 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid: out of memory, %s %d
\n
"
,
__FUNCTION__
,
__LINE__
));
goto
fail_alloc_cmds
;
goto
out_free_scb_list
;
}
dma_pools_f
=
1
;
// Adjust the scb pointers and link in the free pool
epthru_pci_blk
=
raid_dev
->
epthru_pool
;
...
...
@@ -1199,7 +1162,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
con_log
(
CL_ANN
,
(
KERN_CRIT
"megaraid mbox: not aligned on 16-bytes
\n
"
));
goto
fail_alloc_cmd
s
;
goto
out_teardown_dma_pool
s
;
}
ccb
->
epthru
=
(
mraid_epassthru_t
*
)
...
...
@@ -1231,23 +1194,16 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
return
0
;
fail_alloc_cmds:
if
(
dma_pools_f
)
{
megaraid_mbox_teardown_dma_pools
(
adapter
);
}
if
(
alloc_scb_f
)
kfree
(
adapter
->
kscb_list
);
if
(
alloc_ibuf_f
)
{
pci_free_consistent
(
pdev
,
MBOX_IBUF_SIZE
,
(
void
*
)
adapter
->
ibuf
,
adapter
->
ibuf_dma_h
);
}
if
(
alloc_common_mbox_f
)
{
pci_free_consistent
(
adapter
->
pdev
,
sizeof
(
mbox64_t
),
(
caddr_t
)
raid_dev
->
una_mbox64
,
raid_dev
->
una_mbox64_dma
);
}
out_teardown_dma_pools:
megaraid_mbox_teardown_dma_pools
(
adapter
);
out_free_scb_list:
kfree
(
adapter
->
kscb_list
);
out_free_ibuf:
pci_free_consistent
(
pdev
,
MBOX_IBUF_SIZE
,
(
void
*
)
adapter
->
ibuf
,
adapter
->
ibuf_dma_h
);
out_free_common_mbox:
pci_free_consistent
(
adapter
->
pdev
,
sizeof
(
mbox64_t
),
(
caddr_t
)
raid_dev
->
una_mbox64
,
raid_dev
->
una_mbox64_dma
);
return
-
1
;
}
...
...
@@ -1425,8 +1381,7 @@ megaraid_mbox_teardown_dma_pools(adapter_t *adapter)
* @scp : pointer to the scsi command to be executed
* @done : callback routine to be called after the cmd has be completed
*
* Queue entry point for mailbox based controllers. This entry point is common
* for memory and IO based controllers
* Queue entry point for mailbox based controllers.
*/
static
int
megaraid_queue_command
(
struct
scsi_cmnd
*
scp
,
void
(
*
done
)(
struct
scsi_cmnd
*
))
...
...
@@ -1842,6 +1797,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
}
return
scb
;
}
// NOT REACHED
}
...
...
@@ -2197,7 +2154,7 @@ mbox_post_cmd(adapter_t *adapter, scb_t *scb)
// Copy this command's mailbox data into "adapter's" mailbox
memcpy
((
caddr_t
)
mbox64
,
(
caddr_t
)
ccb
->
mbox64
,
2
4
);
memcpy
((
caddr_t
)
mbox64
,
(
caddr_t
)
ccb
->
mbox64
,
2
2
);
mbox
->
cmdid
=
scb
->
sno
;
adapter
->
outstanding_cmds
++
;
...
...
@@ -2769,9 +2726,8 @@ megaraid_abort_handler(struct scsi_cmnd *scp)
if
(
!
found
)
{
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid abort: %ld:%d[%d:%d], do now own
\n
"
,
scp
->
serial_number
,
scb
->
sno
,
scb
->
dev_channel
,
scb
->
dev_target
));
"megaraid abort: scsi cmd:%ld, do now own
\n
"
,
scp
->
serial_number
));
// FIXME: Should there be a callback for this command?
return
SUCCESS
;
...
...
@@ -2807,7 +2763,6 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
int
recovery_window
;
int
recovering
;
int
i
;
DECLARE_WAIT_QUEUE_HEAD
(
wq
);
adapter
=
SCP2ADAPTER
(
scp
);
raid_dev
=
ADAP2RAIDDEV
(
adapter
);
...
...
@@ -2825,7 +2780,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
// Under exceptional conditions, FW can take up to 3 minutes to
// complete command processing. Wait for additional
3
minutes for the
// complete command processing. Wait for additional
2
minutes for the
// pending commands counter to go down to 0. If it doesn't, let the
// controller be marked offline
// Also, reset all the commands currently owned by the driver
...
...
@@ -2876,8 +2831,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
break
;
}
//msleep(1000);
sleep_on_timeout
(
&
wq
,
HZ
);
msleep
(
1000
);
}
spin_lock
(
adapter
->
host_lock
);
...
...
@@ -2967,45 +2921,76 @@ mbox_post_sync_cmd(adapter_t *adapter, uint8_t raw_mbox[])
wmb
();
WRINDOOR
(
raid_dev
,
raid_dev
->
mbox_dma
|
0x1
);
// wait for maximum 1 second for status to post
for
(
i
=
0
;
i
<
40000
;
i
++
)
{
if
(
mbox
->
numstatus
!=
0xFF
)
break
;
udelay
(
25
);
yield
();
}
if
(
i
==
40000
)
{
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid mailbox: status not available
\n
"
));
return
-
1
;
// wait for maximum 1 second for status to post. If the status is not
// available within 1 second, assume FW is initializing and wait
// for an extended amount of time
if
(
mbox
->
numstatus
==
0xFF
)
{
// status not yet available
udelay
(
25
);;
for
(
i
=
0
;
mbox
->
numstatus
==
0xFF
&&
i
<
1000
;
i
++
)
{
rmb
();
msleep
(
1
);
}
if
(
i
==
1000
)
{
con_log
(
CL_ANN
,
(
KERN_NOTICE
"megaraid mailbox: wait for FW to boot."
));
for
(
i
=
0
;
(
mbox
->
numstatus
==
0xFF
)
&&
(
i
<
MBOX_RESET_WAIT
);
i
++
)
{
rmb
();
con_log
(
CL_ANN
,
(
"."
));
msleep
(
1000
);
}
if
(
i
==
MBOX_RESET_WAIT
)
{
con_log
(
CL_ANN
,
(
KERN_WARNING
"
\n
megaraid mailbox: status not available
\n
"
));
return
-
1
;
}
con_log
(
CL_ANN
,
(
"[ok]
\n
"
));
}
}
// wait for maximum 1 second for poll semaphore
for
(
i
=
0
;
i
<
40000
;
i
++
)
{
if
(
mbox
->
poll
==
0x77
)
break
;
udelay
(
25
);
yield
();
}
if
(
i
==
40000
)
{
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid mailbox: could not get poll semaphore
\n
"
));
return
-
1
;
if
(
mbox
->
poll
!=
0x77
)
{
udelay
(
25
);
for
(
i
=
0
;
(
mbox
->
poll
!=
0x77
)
&&
(
i
<
1000
);
i
++
)
{
rmb
();
msleep
(
1
);
}
if
(
i
==
1000
)
{
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid mailbox: could not get poll semaphore
\n
"
));
return
-
1
;
}
}
WRINDOOR
(
raid_dev
,
raid_dev
->
mbox_dma
|
0x2
);
wmb
();
// wait for maximum 1 second for acknowledgement
for
(
i
=
0
;
i
<
40000
;
i
++
)
{
if
((
RDINDOOR
(
raid_dev
)
&
0x2
)
==
0
)
{
mbox
->
poll
=
0
;
mbox
->
ack
=
0x77
;
break
;
if
(
RDINDOOR
(
raid_dev
)
&
0x2
)
{
udelay
(
25
);
for
(
i
=
0
;
(
RDINDOOR
(
raid_dev
)
&
0x2
)
&&
(
i
<
1000
);
i
++
)
{
rmb
();
msleep
(
1
);
}
if
(
i
==
1000
)
{
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid mailbox: could not acknowledge
\n
"
));
return
-
1
;
}
udelay
(
25
);
yield
();
}
if
(
i
==
40000
)
{
con_log
(
CL_ANN
,
(
KERN_WARNING
"megaraid mailbox: could not acknowledge
\n
"
));
return
-
1
;
}
mbox
->
poll
=
0
;
mbox
->
ack
=
0x77
;
status
=
mbox
->
status
;
...
...
@@ -3049,7 +3034,7 @@ mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[])
if
(
mbox
->
busy
)
return
-
1
;
// Copy mailbox data into host structure
memcpy
((
caddr_t
)
mbox
,
(
caddr_t
)
raw_mbox
,
1
6
);
memcpy
((
caddr_t
)
mbox
,
(
caddr_t
)
raw_mbox
,
1
4
);
mbox
->
cmdid
=
0xFE
;
mbox
->
busy
=
1
;
mbox
->
poll
=
0
;
...
...
@@ -3082,41 +3067,23 @@ mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[])
* @raid_dev - RAID device (HBA) soft state
*
* wait until the controller's mailbox is available to accept more commands.
* wait for at most 1 second
*/
static
inline
int
megaraid_busywait_mbox
(
mraid_device_t
*
raid_dev
)
{
mbox_t
*
mbox
=
raid_dev
->
mbox
;
int
i
=
0
;
if
(
mbox
->
busy
)
return
__megaraid_busywait_mbox
(
raid_dev
);
return
0
;
}
/**
* __megaraid_busywait_mbox() - Wait until controller's mailbox is available
* @raid_dev - mailbox data structures
*
* wait until the controller's mailbox is available to accept more commands.
*/
static
inline
int
__megaraid_busywait_mbox
(
mraid_device_t
*
raid_dev
)
{
mbox_t
*
mbox
=
raid_dev
->
mbox
;
unsigned
long
counter
;
for
(
counter
=
0
;
counter
<
10000
;
counter
++
)
{
if
(
!
mbox
->
busy
)
return
0
;
udelay
(
100
);
yield
();
if
(
mbox
->
busy
)
{
udelay
(
25
);
for
(
i
=
0
;
mbox
->
busy
&&
i
<
1000
;
i
++
)
msleep
(
1
);
}
return
-
1
;
// give up after 1 second
}
if
(
i
<
1000
)
return
0
;
else
return
-
1
;
}
/**
...
...
@@ -3138,6 +3105,7 @@ megaraid_mbox_product_info(adapter_t *adapter)
int
i
;
memset
((
caddr_t
)
raw_mbox
,
0
,
sizeof
(
raw_mbox
));
mbox
=
(
mbox_t
*
)
raw_mbox
;
/*
...
...
@@ -3818,7 +3786,6 @@ wait_till_fw_empty(adapter_t *adapter)
unsigned
long
flags
=
0
;
int
i
;
DECLARE_WAIT_QUEUE_HEAD
(
wq
);
/*
* Set the quiescent flag to stop issuing cmds to FW.
...
...
@@ -3836,8 +3803,7 @@ wait_till_fw_empty(adapter_t *adapter)
"megaraid: FW has %d pending commands
\n
"
,
adapter
->
outstanding_cmds
));
//msleep(1000);
sleep_on_timeout
(
&
wq
,
HZ
);
msleep
(
1000
);
}
return
adapter
->
outstanding_cmds
;
...
...
@@ -3864,7 +3830,7 @@ megaraid_mbox_mm_done(adapter_t *adapter, scb_t *scb)
kioc
->
status
=
0
;
mbox64
=
(
mbox64_t
*
)(
unsigned
long
)
kioc
->
cmdbuf
;
mbox64
->
mbox32
.
status
=
scb
->
status
;
raw_mbox
=
(
uint8_t
*
)
&
mbox64
->
mbox32
;
raw_mbox
=
(
uint8_t
*
)
&
mbox64
->
mbox32
;
// put scb in the free pool
...
...
@@ -3900,6 +3866,10 @@ megaraid_mbox_mm_done(adapter_t *adapter, scb_t *scb)
static
int
gather_hbainfo
(
adapter_t
*
adapter
,
mraid_hba_info_t
*
hinfo
)
{
uint8_t
dmajor
;
dmajor
=
megaraid_mbox_version
[
0
];
hinfo
->
pci_vendor_id
=
adapter
->
pdev
->
vendor
;
hinfo
->
pci_device_id
=
adapter
->
pdev
->
device
;
hinfo
->
subsys_vendor_id
=
adapter
->
pdev
->
subsystem_vendor
;
...
...
drivers/scsi/megaraid/megaraid_mbox.h
View file @
8ef4b795
...
...
@@ -21,8 +21,8 @@
#include "megaraid_ioctl.h"
#define MEGARAID_VERSION "2.20.
0
.0"
#define MEGARAID_EXT_VERSION "(Release Date:
Wed Jun 23 11:38:38
EDT 2004)"
#define MEGARAID_VERSION "2.20.
3
.0"
#define MEGARAID_EXT_VERSION "(Release Date:
Thu Aug 19 09:58:33
EDT 2004)"
/*
...
...
@@ -88,6 +88,9 @@
#define PCI_DEVICE_ID_MEGARAID_SCSI_320_2E 0x0408
#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_2E 0x0002
#define PCI_DEVICE_ID_MEGARAID_I4_133_RAID 0x1960
#define PCI_SUBSYS_ID_MEGARAID_I4_133_RAID 0x0522
#define PCI_DEVICE_ID_MEGARAID_SATA_150_4 0x1960
#define PCI_SUBSYS_ID_MEGARAID_SATA_150_4 0x4523
...
...
@@ -95,7 +98,7 @@
#define PCI_SUBSYS_ID_MEGARAID_SATA_150_6 0x0523
#define PCI_DEVICE_ID_MEGARAID_SATA_300_4x 0x0409
#define PCI_SUBSYS_ID_MEGARAID_SATA_300_4x 0x300
8
#define PCI_SUBSYS_ID_MEGARAID_SATA_300_4x 0x300
4
#define PCI_DEVICE_ID_MEGARAID_SATA_300_8x 0x0409
#define PCI_SUBSYS_ID_MEGARAID_SATA_300_8x 0x3008
...
...
@@ -127,6 +130,9 @@
#define PCI_DEVICE_ID_FSC_MEGARAID_PCI_EXPRESS_ROMB 0x0408
#define PCI_SUBSYS_ID_FSC_MEGARAID_PCI_EXPRESS_ROMB 0x1065
#define PCI_DEVICE_ID_MEGARAID_ACER_ROMB_2E 0x0408
#define PCI_SUBSYS_ID_MEGARAID_ACER_ROMB_2E 0x004D
#define PCI_SUBSYS_ID_PERC3_QC 0x0471
#define PCI_SUBSYS_ID_PERC3_DC 0x0493
#define PCI_SUBSYS_ID_PERC3_SC 0x0475
...
...
drivers/scsi/megaraid/megaraid_mm.c
View file @
8ef4b795
...
...
@@ -10,13 +10,46 @@
* 2 of the License, or (at your option) any later version.
*
* FILE : megaraid_mm.c
* Version : v2.20.
0.0 (June
23 2004)
* Version : v2.20.
1.0 (July
23 2004)
*
* Common management module
*/
#include "megaraid_mm.h"
// Entry points for char node driver
static
int
mraid_mm_open
(
struct
inode
*
,
struct
file
*
);
static
int
mraid_mm_ioctl
(
struct
inode
*
,
struct
file
*
,
uint
,
unsigned
long
);
// routines to convert to and from the old the format
static
int
mimd_to_kioc
(
mimd_t
*
,
mraid_mmadp_t
*
,
uioc_t
*
);
static
int
kioc_to_mimd
(
uioc_t
*
,
mimd_t
*
);
// Helper functions
static
int
handle_drvrcmd
(
unsigned
long
,
uint8_t
,
int
*
);
static
int
lld_ioctl
(
mraid_mmadp_t
*
,
uioc_t
*
);
static
void
ioctl_done
(
uioc_t
*
);
static
void
lld_timedout
(
unsigned
long
);
static
void
hinfo_to_cinfo
(
mraid_hba_info_t
*
,
mcontroller_t
*
);
static
mraid_mmadp_t
*
mraid_mm_get_adapter
(
mimd_t
*
,
int
*
);
static
uioc_t
*
mraid_mm_alloc_kioc
(
mraid_mmadp_t
*
);
static
void
mraid_mm_dealloc_kioc
(
mraid_mmadp_t
*
,
uioc_t
*
);
static
int
mraid_mm_attach_buf
(
mraid_mmadp_t
*
,
uioc_t
*
,
int
);
static
int
mraid_mm_setup_dma_pools
(
mraid_mmadp_t
*
);
static
void
mraid_mm_free_adp_resources
(
mraid_mmadp_t
*
);
static
void
mraid_mm_teardown_dma_pools
(
mraid_mmadp_t
*
);
#ifdef CONFIG_COMPAT
static
int
mraid_mm_compat_ioctl
(
unsigned
int
,
unsigned
int
,
unsigned
long
,
struct
file
*
);
#else
#define register_ioctl32_conversion(a,b) do{}while(0)
#define unregister_ioctl32_conversion(a) do{}while(0)
#endif
MODULE_AUTHOR
(
"LSI Logic Corporation"
);
MODULE_DESCRIPTION
(
"LSI Logic Management Module"
);
MODULE_LICENSE
(
"GPL"
);
...
...
@@ -30,10 +63,10 @@ EXPORT_SYMBOL(mraid_mm_register_adp);
EXPORT_SYMBOL
(
mraid_mm_unregister_adp
);
static
int
majorno
;
static
uint32_t
drvr_ver
=
0x0
10000
00
;
static
uint32_t
drvr_ver
=
0x0
22001
00
;
static
int
slots_inuse
=
0
;
static
mraid_mmadp_t
adparr
[
MAX_LSI_CMN_ADAPS
]
;
static
int
adapters_count_g
;
static
struct
list_head
adapters_list_g
;
wait_queue_head_t
wait_q
;
...
...
@@ -76,7 +109,6 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
char
signature
[
EXT_IOCTL_SIGN_SZ
]
=
{
0
};
int
rval
;
mraid_mmadp_t
*
adp
;
int
adp_index
;
uint8_t
old_ioctl
;
int
drvrcmd_rval
;
...
...
@@ -120,12 +152,11 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
else
if
(
rval
==
0
)
return
drvrcmd_rval
;
if
((
rval
=
mraid_mm_get_adpindex
((
mimd_t
*
)
arg
,
&
adp_index
)))
{
rval
=
0
;
if
((
adp
=
mraid_mm_get_adapter
((
mimd_t
*
)
arg
,
&
rval
))
==
NULL
)
{
return
rval
;
}
adp
=
&
adparr
[
adp_index
];
/*
* The following call will block till a kioc is available
*/
...
...
@@ -164,29 +195,44 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
/**
* mraid_mm_get_ad
pindex - Returns adp number from mimd_t user
packet
* mraid_mm_get_ad
apter - Returns corresponding adapters for the mimd
packet
* @umimd : User space mimd_t ioctl packet
* @ad
p_index : Contains adp number if success
* @ad
apter : pointer to the adapter (OUT)
*/
static
int
mraid_mm_get_ad
pindex
(
mimd_t
*
umimd
,
int
*
adp_index
)
static
mraid_mmadp_t
*
mraid_mm_get_ad
apter
(
mimd_t
*
umimd
,
int
*
rval
)
{
mraid_mmadp_t
*
adapter
;
mimd_t
mimd
;
uint32_t
adapno
;
int
iterator
;
*
adp_index
=
-
1
;
if
(
copy_from_user
(
&
mimd
,
umimd
,
sizeof
(
mimd_t
)))
return
(
-
EFAULT
);
if
(
copy_from_user
(
&
mimd
,
umimd
,
sizeof
(
mimd_t
)))
{
*
rval
=
-
EFAULT
;
return
NULL
;
}
adapno
=
GETADAP
(
mimd
.
ui
.
fcs
.
adapno
);
if
(
adapno
>=
slots_inuse
)
return
(
-
ENODEV
);
if
(
adapno
>=
adapters_count_g
)
{
*
rval
=
-
ENODEV
;
return
NULL
;
}
*
adp_index
=
adapno
;
adapter
=
NULL
;
iterator
=
0
;
return
0
;
list_for_each_entry
(
adapter
,
&
adapters_list_g
,
list
)
{
if
(
iterator
++
==
adapno
)
break
;
}
if
(
!
adapter
)
{
*
rval
=
-
ENODEV
;
return
NULL
;
}
return
adapter
;
}
/*
...
...
@@ -240,9 +286,10 @@ handle_drvrcmd(unsigned long arg, uint8_t old_ioctl, int *rval)
case
MEGAIOC_QNADAP
:
*
rval
=
slots_inuse
;
*
rval
=
adapters_count_g
;
if
(
copy_to_user
(
kmimd
.
data
,
&
slots_inuse
,
sizeof
(
uint32_t
)))
if
(
copy_to_user
(
kmimd
.
data
,
&
adapters_count_g
,
sizeof
(
uint32_t
)))
return
(
-
EFAULT
);
return
0
;
...
...
@@ -271,6 +318,7 @@ static int
mimd_to_kioc
(
mimd_t
*
umimd
,
mraid_mmadp_t
*
adp
,
uioc_t
*
kioc
)
{
mbox64_t
*
mbox64
;
mbox_t
*
mbox
;
mraid_passthru_t
*
pthru32
;
uint32_t
adapno
;
uint8_t
opcode
;
...
...
@@ -291,7 +339,7 @@ mimd_to_kioc(mimd_t *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
subopcode
=
mimd
.
ui
.
fcs
.
subopcode
;
adapno
=
GETADAP
(
mimd
.
ui
.
fcs
.
adapno
);
if
(
adapno
>=
slots_inuse
)
if
(
adapno
>=
adapters_count_g
)
return
(
-
ENODEV
);
kioc
->
adapno
=
adapno
;
...
...
@@ -321,8 +369,10 @@ mimd_to_kioc(mimd_t *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
case
0x81
:
kioc
->
opcode
=
MBOX_CMD
;
kioc
->
xferlen
=
mimd
.
ui
.
fcs
.
length
;
kioc
->
opcode
=
MBOX_CMD
;
kioc
->
xferlen
=
mimd
.
ui
.
fcs
.
length
;
kioc
->
user_data_len
=
kioc
->
xferlen
;
kioc
->
user_data
=
mimd
.
ui
.
fcs
.
buffer
;
if
(
mraid_mm_attach_buf
(
adp
,
kioc
,
kioc
->
xferlen
))
return
(
-
ENOMEM
);
...
...
@@ -334,9 +384,11 @@ mimd_to_kioc(mimd_t *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
case
0x80
:
kioc
->
opcode
=
MBOX_CMD
;
kioc
->
xferlen
=
(
mimd
.
outlen
>
mimd
.
inlen
)
?
mimd
.
outlen
:
mimd
.
inlen
;
kioc
->
opcode
=
MBOX_CMD
;
kioc
->
xferlen
=
(
mimd
.
outlen
>
mimd
.
inlen
)
?
mimd
.
outlen
:
mimd
.
inlen
;
kioc
->
user_data_len
=
kioc
->
xferlen
;
kioc
->
user_data
=
mimd
.
data
;
if
(
mraid_mm_attach_buf
(
adp
,
kioc
,
kioc
->
xferlen
))
return
(
-
ENOMEM
);
...
...
@@ -359,19 +411,13 @@ mimd_to_kioc(mimd_t *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
/*
* This is a mailbox cmd; copy the mailbox from mimd
*/
mbox64
=
(
mbox64_t
*
)((
unsigned
long
)
kioc
->
cmdbuf
);
memcpy
(
&
(
mbox64
->
mbox32
),
mimd
.
mbox
,
18
);
mbox64
=
(
mbox64_t
*
)((
unsigned
long
)
kioc
->
cmdbuf
);
mbox
=
&
mbox64
->
mbox32
;
memcpy
(
mbox
,
mimd
.
mbox
,
14
);
mbox64
->
xferaddr_lo
=
mbox64
->
mbox32
.
xferaddr
;
mbox64
->
xferaddr_hi
=
0
;
mbox64
->
mbox32
.
xferaddr
=
0xffffffff
;
if
(
mbox
->
cmd
!=
MBOXCMD_PASSTHRU
)
{
// regular DCMD
if
(
mbox64
->
mbox32
.
cmd
!=
MBOXCMD_PASSTHRU
)
{
// regular DCMD
kioc
->
user_data
=
(
caddr_t
)(
unsigned
long
)
mbox64
->
xferaddr_lo
;
kioc
->
user_data_len
=
kioc
->
xferlen
;
mbox64
->
xferaddr_lo
=
(
unsigned
long
)
kioc
->
buf_paddr
;
mbox
->
xferaddr
=
(
uint32_t
)
kioc
->
buf_paddr
;
if
(
kioc
->
data_dir
&
UIOC_WR
)
{
if
(
copy_from_user
(
kioc
->
buf_vaddr
,
kioc
->
user_data
,
...
...
@@ -389,23 +435,16 @@ mimd_to_kioc(mimd_t *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
* a mailbox. The passthru will begin at next 1K boundary. And the
* data will start 1K after that.
*/
mbox64
->
mbox32
.
cmd
=
MBOXCMD_PASSTHRU
;
pthru32
=
kioc
->
pthru32
;
kioc
->
user_pthru
=
(
mraid_passthru_t
*
)(
unsigned
long
)
mbox64
->
xferaddr_lo
;
mbox64
->
xferaddr_lo
=
kioc
->
pthru32_h
;
kioc
->
user_pthru
=
&
umimd
->
pthru
;
mbox
->
xferaddr
=
(
uint32_t
)
kioc
->
pthru32_h
;
if
(
copy_from_user
(
pthru32
,
(
caddr_t
)
kioc
->
user_pthru
,
sizeof
(
mraid_passthru_t
)))
{
return
(
-
EFAULT
);
}
kioc
->
user_data
=
(
caddr_t
)(
unsigned
long
)
pthru32
->
dataxferaddr
;
pthru32
->
dataxferaddr
=
kioc
->
buf_paddr
;
kioc
->
user_data_len
=
pthru32
->
dataxferlen
;
if
(
kioc
->
data_dir
&
UIOC_WR
)
{
if
(
copy_from_user
(
kioc
->
buf_vaddr
,
kioc
->
user_data
,
pthru32
->
dataxferlen
))
{
...
...
@@ -592,7 +631,7 @@ mraid_mm_dealloc_kioc(mraid_mmadp_t *adp, uioc_t *kioc)
/**
* lld_ioctl - Routine to issue ioctl to low level drvr
*
* @adp : The adapter
entry in adparr
* @adp : The adapter
handle
* @kioc : The ioctl packet with kernel addresses
*/
static
int
...
...
@@ -696,7 +735,7 @@ kioc_to_mimd(uioc_t *kioc, mimd_t *mimd)
mraid_hba_info_t
*
hinfo
;
if
(
copy_from_user
(
&
kmimd
,
mimd
,
sizeof
(
mimd_t
)))
if
(
copy_from_user
(
&
kmimd
,
mimd
,
sizeof
(
mimd_t
)))
return
(
-
EFAULT
);
opcode
=
kmimd
.
ui
.
fcs
.
opcode
;
...
...
@@ -707,9 +746,10 @@ kioc_to_mimd(uioc_t *kioc, mimd_t *mimd)
case
MEGAIOC_QADAPINFO
:
hinfo
=
(
mraid_hba_info_t
*
)(
unsigned
long
)
hinfo
=
(
mraid_hba_info_t
*
)(
unsigned
long
)
kioc
->
buf_vaddr
;
hinfo_to_cinfo
(
hinfo
,
&
cinfo
);
hinfo_to_cinfo
(
hinfo
,
&
cinfo
);
if
(
copy_to_user
(
kmimd
.
data
,
&
cinfo
,
sizeof
(
cinfo
)))
return
(
-
EFAULT
);
...
...
@@ -723,15 +763,15 @@ kioc_to_mimd(uioc_t *kioc, mimd_t *mimd)
return
0
;
}
mbox64
=
(
mbox64_t
*
)(
unsigned
long
)
kioc
->
cmdbuf
;
mbox64
=
(
mbox64_t
*
)(
unsigned
long
)
kioc
->
cmdbuf
;
if
(
kioc
->
user_pthru
)
{
upthru32
=
kioc
->
user_pthru
;
kpthru32
=
kioc
->
pthru32
;
if
(
copy_to_user
((
void
*
)
&
(
upthru32
->
scsistatus
)
,
(
void
*
)
&
(
kpthru32
->
scsistatus
)
,
if
(
copy_to_user
((
void
*
)
&
upthru32
->
scsistatus
,
(
void
*
)
&
kpthru32
->
scsistatus
,
sizeof
(
uint8_t
)))
{
return
(
-
EFAULT
);
}
...
...
@@ -744,8 +784,8 @@ kioc_to_mimd(uioc_t *kioc, mimd_t *mimd)
}
}
if
(
copy_to_user
((
void
*
)
&
mimd
->
mbox
[
17
],
(
void
*
)
&
mbox64
->
mbox32
.
status
,
sizeof
(
uint8_t
)))
{
if
(
copy_to_user
((
void
*
)
&
mimd
->
mbox
[
17
]
,
(
void
*
)
&
mbox64
->
mbox32
.
status
,
sizeof
(
uint8_t
)))
{
return
(
-
EFAULT
);
}
...
...
@@ -796,7 +836,13 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
if
(
lld_adp
->
drvr_type
!=
DRVRTYPE_MBOX
)
return
(
-
EINVAL
);
adapter
=
&
adparr
[
slots_inuse
];
adapter
=
kmalloc
(
sizeof
(
mraid_mmadp_t
),
GFP_KERNEL
);
if
(
!
adapter
)
{
rval
=
-
ENOMEM
;
goto
memalloc_error
;
}
memset
(
adapter
,
0
,
sizeof
(
mraid_mmadp_t
));
adapter
->
unique_id
=
lld_adp
->
unique_id
;
...
...
@@ -867,7 +913,10 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
goto
dma_pool_error
;
}
slots_inuse
++
;
list_add_tail
(
&
adapter
->
list
,
&
adapters_list_g
);
adapters_count_g
++
;
return
0
;
dma_pool_error:
...
...
@@ -894,6 +943,9 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
if
(
adapter
->
pthru_dma_pool
)
pci_pool_destroy
(
adapter
->
pthru_dma_pool
);
if
(
adapter
)
kfree
(
adapter
);
return
rval
;
}
...
...
@@ -961,15 +1013,21 @@ mraid_mm_setup_dma_pools(mraid_mmadp_t *adp)
int
mraid_mm_unregister_adp
(
uint32_t
unique_id
)
{
int
i
;
mraid_mmadp_t
*
adapter
;
mraid_mmadp_t
*
tmp
;
for
(
i
=
0
;
i
<
MAX_LSI_CMN_ADAPS
;
i
++
)
{
list_for_each_entry_safe
(
adapter
,
tmp
,
&
adapters_list_g
,
list
)
{
if
(
adparr
[
i
].
unique_id
==
unique_id
)
{
mraid_mm_free_adp_resources
(
&
adparr
[
i
]);
if
(
adapter
->
unique_id
==
unique_id
)
{
memset
(
&
adparr
[
i
],
0
,
sizeof
(
mraid_mmadp_t
));
adapters_count_g
--
;
list_del_init
(
&
adapter
->
list
);
mraid_mm_free_adp_resources
(
adapter
);
kfree
(
adapter
);
con_log
(
CL_ANN
,
(
"megaraid cmm: Unregistered one adapter:%#x
\n
"
,
...
...
@@ -993,11 +1051,7 @@ mraid_mm_free_adp_resources(mraid_mmadp_t *adp)
uioc_t
*
kioc
;
int
i
;
INIT_LIST_HEAD
(
&
adp
->
kioc_pool
);
kfree
(
adp
->
kioc_list
);
kfree
(
adp
->
mbox_list
);
mraid_mm_teardown_dma_pools
(
adp
);
for
(
i
=
0
;
i
<
adp
->
max_kioc
;
i
++
)
{
...
...
@@ -1007,9 +1061,12 @@ mraid_mm_free_adp_resources(mraid_mmadp_t *adp)
kioc
->
pthru32_h
);
}
kfree
(
adp
->
kioc_list
);
kfree
(
adp
->
mbox_list
);
pci_pool_destroy
(
adp
->
pthru_dma_pool
);
mraid_mm_teardown_dma_pools
(
adp
);
return
;
}
...
...
@@ -1062,9 +1119,8 @@ mraid_mm_init(void)
}
init_waitqueue_head
(
&
wait_q
);
memset
(
adparr
,
0
,
sizeof
(
mraid_mmadp_t
)
*
MAX_LSI_CMN_ADAPS
);
slots_inuse
=
0
;
INIT_LIST_HEAD
(
&
adapters_list_g
)
;
#ifdef CONFIG_COMPAT
register_ioctl32_conversion
(
MEGAIOCCMD
,
mraid_mm_compat_ioctl
);
...
...
drivers/scsi/megaraid/megaraid_mm.h
View file @
8ef4b795
...
...
@@ -23,14 +23,15 @@
#include <linux/moduleparam.h>
#include <linux/pci.h>
#include <linux/list.h>
#include <linux/ioctl32.h>
#include "mbox_defs.h"
#include "megaraid_ioctl.h"
#define LSI_COMMON_MOD_VERSION "2.20.
0
.0"
#define LSI_COMMON_MOD_VERSION "2.20.
2
.0"
#define LSI_COMMON_MOD_EXT_VERSION \
"(Release Date:
Wed Jun 23 11:38:38
EDT 2004)"
"(Release Date:
Thu Aug 19 09:58:33
EDT 2004)"
#define LSI_DBGLVL dbglevel
...
...
@@ -38,11 +39,6 @@
// The smallest dma pool
#define MRAID_MM_INIT_BUFF_SIZE 4096
/*
* Localizing ioctl32 differences
*/
#include <linux/ioctl32.h>
/**
* mimd_t : Old style ioctl packet structure (deprecated)
*
...
...
@@ -101,36 +97,6 @@ typedef struct mimd {
}
__attribute__
((
packed
))
mimd_t
;
// Entry points for char node driver
static
int
mraid_mm_open
(
struct
inode
*
,
struct
file
*
);
static
int
mraid_mm_ioctl
(
struct
inode
*
,
struct
file
*
,
uint
,
unsigned
long
);
// routines to convert to and from the old the format
static
int
mimd_to_kioc
(
mimd_t
*
,
mraid_mmadp_t
*
,
uioc_t
*
);
static
int
kioc_to_mimd
(
uioc_t
*
,
mimd_t
*
);
// Helper functions
static
int
handle_drvrcmd
(
unsigned
long
,
uint8_t
,
int
*
);
static
int
lld_ioctl
(
mraid_mmadp_t
*
,
uioc_t
*
);
static
void
ioctl_done
(
uioc_t
*
);
static
void
lld_timedout
(
unsigned
long
);
static
void
hinfo_to_cinfo
(
mraid_hba_info_t
*
,
mcontroller_t
*
);
static
int
mraid_mm_get_adpindex
(
mimd_t
*
,
int
*
);
static
uioc_t
*
mraid_mm_alloc_kioc
(
mraid_mmadp_t
*
);
static
void
mraid_mm_dealloc_kioc
(
mraid_mmadp_t
*
,
uioc_t
*
);
static
int
mraid_mm_attach_buf
(
mraid_mmadp_t
*
,
uioc_t
*
,
int
);
static
int
mraid_mm_setup_dma_pools
(
mraid_mmadp_t
*
);
static
void
mraid_mm_free_adp_resources
(
mraid_mmadp_t
*
);
static
void
mraid_mm_teardown_dma_pools
(
mraid_mmadp_t
*
);
#ifdef CONFIG_COMPAT
static
int
mraid_mm_compat_ioctl
(
unsigned
int
,
unsigned
int
,
unsigned
long
,
struct
file
*
);
#endif
#endif // MEGARAID_MM_H
// vi: set ts=8 sw=8 tw=78:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment