aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/advansys.c
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-10-02 21:55:37 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:53:48 -0400
commit98d41c29a4b38c5b5e8ce5e13c4f3ac852615e0b (patch)
tree85f3d692de0b25f05febacb0f1985b3ade73181f /drivers/scsi/advansys.c
parentafbb68c35f4bdf0964d88e9e005e6f62ba57d134 (diff)
[SCSI] advansys: Move a couple of fields from struct board to struct adv_dvc
board->carrp is a duplicate of asc_dvc->carrier_buf, so cut out the middle-man and assign directly to carrier_buf. Move orig_reqp to adv_dvc too, since it's wide-board specific. Also eliminate an unnecessary BUG_ON (we'll never get there with a NULL carrier_buf, and will crash if we do). The bulk of this patch is rearranging structures so everything's declared in the right order. Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/advansys.c')
-rw-r--r--drivers/scsi/advansys.c193
1 files changed, 92 insertions, 101 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 93b1a47ebaf8..0459c85b74b8 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -983,15 +983,14 @@ typedef struct asc_mc_saved {
983 * elements. Allow each command to have at least one ADV_SG_BLOCK structure. 983 * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
984 * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK 984 * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
985 * structures or 255 scatter-gather elements. 985 * structures or 255 scatter-gather elements.
986 *
987 */ 986 */
988#define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG 987#define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
989 988
990/* 989/*
991 * Define Adv Library required maximum number of scatter-gather 990 * Define maximum number of scatter-gather elements per request.
992 * elements per request.
993 */ 991 */
994#define ADV_MAX_SG_LIST 255 992#define ADV_MAX_SG_LIST 255
993#define NO_OF_SG_PER_BLOCK 15
995 994
996/* Number of SG blocks needed. */ 995/* Number of SG blocks needed. */
997#define ADV_NUM_SG_BLOCK \ 996#define ADV_NUM_SG_BLOCK \
@@ -1839,55 +1838,6 @@ typedef struct adv_dvc_cfg {
1839struct adv_dvc_var; 1838struct adv_dvc_var;
1840struct adv_scsi_req_q; 1839struct adv_scsi_req_q;
1841 1840
1842/*
1843 * Adapter operation variable structure.
1844 *
1845 * One structure is required per host adapter.
1846 *
1847 * Field naming convention:
1848 *
1849 * *_able indicates both whether a feature should be enabled or disabled
1850 * and whether a device isi capable of the feature. At initialization
1851 * this field may be set, but later if a device is found to be incapable
1852 * of the feature, the field is cleared.
1853 */
1854typedef struct adv_dvc_var {
1855 AdvPortAddr iop_base; /* I/O port address */
1856 ushort err_code; /* fatal error code */
1857 ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
1858 ushort wdtr_able; /* try WDTR for a device */
1859 ushort sdtr_able; /* try SDTR for a device */
1860 ushort ultra_able; /* try SDTR Ultra speed for a device */
1861 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
1862 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
1863 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
1864 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
1865 ushort tagqng_able; /* try tagged queuing with a device */
1866 ushort ppr_able; /* PPR message capable per TID bitmask. */
1867 uchar max_dvc_qng; /* maximum number of tagged commands per device */
1868 ushort start_motor; /* start motor command allowed */
1869 uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
1870 uchar chip_no; /* should be assigned by caller */
1871 uchar max_host_qng; /* maximum number of Q'ed command allowed */
1872 ushort no_scam; /* scam_tolerant of EEPROM */
1873 struct asc_board *drv_ptr; /* driver pointer to private structure */
1874 uchar chip_scsi_id; /* chip SCSI target ID */
1875 uchar chip_type;
1876 uchar bist_err_code;
1877 ADV_CARR_T *carrier_buf;
1878 ADV_CARR_T *carr_freelist; /* Carrier free list. */
1879 ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
1880 ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
1881 ushort carr_pending_cnt; /* Count of pending carriers. */
1882 /*
1883 * Note: The following fields will not be used after initialization. The
1884 * driver may discard the buffer after initialization is done.
1885 */
1886 ADV_DVC_CFG *cfg; /* temporary configuration structure */
1887} ADV_DVC_VAR;
1888
1889#define NO_OF_SG_PER_BLOCK 15
1890
1891typedef struct asc_sg_block { 1841typedef struct asc_sg_block {
1892 uchar reserved1; 1842 uchar reserved1;
1893 uchar reserved2; 1843 uchar reserved2;
@@ -1946,6 +1896,83 @@ typedef struct adv_scsi_req_q {
1946} ADV_SCSI_REQ_Q; 1896} ADV_SCSI_REQ_Q;
1947 1897
1948/* 1898/*
1899 * The following two structures are used to process Wide Board requests.
1900 *
1901 * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
1902 * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
1903 * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
1904 * Mid-Level SCSI request structure.
1905 *
1906 * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
1907 * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
1908 * up to 255 scatter-gather elements may be used per request or
1909 * ADV_SCSI_REQ_Q.
1910 *
1911 * Both structures must be 32 byte aligned.
1912 */
1913typedef struct adv_sgblk {
1914 ADV_SG_BLOCK sg_block; /* Sgblock structure. */
1915 uchar align[32]; /* Sgblock structure padding. */
1916 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
1917} adv_sgblk_t;
1918
1919typedef struct adv_req {
1920 ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
1921 uchar align[32]; /* Request structure padding. */
1922 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
1923 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
1924 struct adv_req *next_reqp; /* Next Request Structure. */
1925} adv_req_t;
1926
1927/*
1928 * Adapter operation variable structure.
1929 *
1930 * One structure is required per host adapter.
1931 *
1932 * Field naming convention:
1933 *
1934 * *_able indicates both whether a feature should be enabled or disabled
1935 * and whether a device isi capable of the feature. At initialization
1936 * this field may be set, but later if a device is found to be incapable
1937 * of the feature, the field is cleared.
1938 */
1939typedef struct adv_dvc_var {
1940 AdvPortAddr iop_base; /* I/O port address */
1941 ushort err_code; /* fatal error code */
1942 ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
1943 ushort wdtr_able; /* try WDTR for a device */
1944 ushort sdtr_able; /* try SDTR for a device */
1945 ushort ultra_able; /* try SDTR Ultra speed for a device */
1946 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
1947 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
1948 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
1949 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
1950 ushort tagqng_able; /* try tagged queuing with a device */
1951 ushort ppr_able; /* PPR message capable per TID bitmask. */
1952 uchar max_dvc_qng; /* maximum number of tagged commands per device */
1953 ushort start_motor; /* start motor command allowed */
1954 uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
1955 uchar chip_no; /* should be assigned by caller */
1956 uchar max_host_qng; /* maximum number of Q'ed command allowed */
1957 ushort no_scam; /* scam_tolerant of EEPROM */
1958 struct asc_board *drv_ptr; /* driver pointer to private structure */
1959 uchar chip_scsi_id; /* chip SCSI target ID */
1960 uchar chip_type;
1961 uchar bist_err_code;
1962 ADV_CARR_T *carrier_buf;
1963 ADV_CARR_T *carr_freelist; /* Carrier free list. */
1964 ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
1965 ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
1966 ushort carr_pending_cnt; /* Count of pending carriers. */
1967 struct adv_req *orig_reqp; /* adv_req_t memory block. */
1968 /*
1969 * Note: The following fields will not be used after initialization. The
1970 * driver may discard the buffer after initialization is done.
1971 */
1972 ADV_DVC_CFG *cfg; /* temporary configuration structure */
1973} ADV_DVC_VAR;
1974
1975/*
1949 * Microcode idle loop commands 1976 * Microcode idle loop commands
1950 */ 1977 */
1951#define IDLE_CMD_COMPLETED 0 1978#define IDLE_CMD_COMPLETED 0
@@ -2362,37 +2389,6 @@ struct asc_stats {
2362#endif /* ADVANSYS_STATS */ 2389#endif /* ADVANSYS_STATS */
2363 2390
2364/* 2391/*
2365 * Adv Library Request Structures
2366 *
2367 * The following two structures are used to process Wide Board requests.
2368 *
2369 * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
2370 * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
2371 * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
2372 * Mid-Level SCSI request structure.
2373 *
2374 * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
2375 * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
2376 * up to 255 scatter-gather elements may be used per request or
2377 * ADV_SCSI_REQ_Q.
2378 *
2379 * Both structures must be 32 byte aligned.
2380 */
2381typedef struct adv_sgblk {
2382 ADV_SG_BLOCK sg_block; /* Sgblock structure. */
2383 uchar align[32]; /* Sgblock structure padding. */
2384 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
2385} adv_sgblk_t;
2386
2387typedef struct adv_req {
2388 ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
2389 uchar align[32]; /* Request structure padding. */
2390 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
2391 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
2392 struct adv_req *next_reqp; /* Next Request Structure. */
2393} adv_req_t;
2394
2395/*
2396 * Structure allocated for each board. 2392 * Structure allocated for each board.
2397 * 2393 *
2398 * This structure is allocated by scsi_host_alloc() at the end 2394 * This structure is allocated by scsi_host_alloc() at the end
@@ -2437,8 +2433,6 @@ struct asc_board {
2437 */ 2433 */
2438 void __iomem *ioremap_addr; /* I/O Memory remap address. */ 2434 void __iomem *ioremap_addr; /* I/O Memory remap address. */
2439 ushort ioport; /* I/O Port address. */ 2435 ushort ioport; /* I/O Port address. */
2440 ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
2441 adv_req_t *orig_reqp; /* adv_req_t memory block. */
2442 adv_req_t *adv_reqp; /* Request structures. */ 2436 adv_req_t *adv_reqp; /* Request structures. */
2443 adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */ 2437 adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
2444 ushort bios_signature; /* BIOS Signature. */ 2438 ushort bios_signature; /* BIOS Signature. */
@@ -6518,8 +6512,6 @@ static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
6518 ADV_SDCNT buf_size; 6512 ADV_SDCNT buf_size;
6519 ADV_PADDR carr_paddr; 6513 ADV_PADDR carr_paddr;
6520 6514
6521 BUG_ON(!asc_dvc->carrier_buf);
6522
6523 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf); 6515 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
6524 asc_dvc->carr_freelist = NULL; 6516 asc_dvc->carr_freelist = NULL;
6525 if (carrp == asc_dvc->carrier_buf) { 6517 if (carrp == asc_dvc->carrier_buf) {
@@ -13442,10 +13434,10 @@ static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
13442 * Allocate buffer carrier structures. The total size 13434 * Allocate buffer carrier structures. The total size
13443 * is about 4 KB, so allocate all at once. 13435 * is about 4 KB, so allocate all at once.
13444 */ 13436 */
13445 board->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL); 13437 adv_dvc->carrier_buf = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
13446 ASC_DBG(1, "carrp 0x%p\n", board->carrp); 13438 ASC_DBG(1, "carrier_buf 0x%p\n", adv_dvc->carrier_buf);
13447 13439
13448 if (!board->carrp) 13440 if (!adv_dvc->carrier_buf)
13449 goto kmalloc_failed; 13441 goto kmalloc_failed;
13450 13442
13451 /* 13443 /*
@@ -13466,7 +13458,7 @@ static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
13466 if (!reqp) 13458 if (!reqp)
13467 goto kmalloc_failed; 13459 goto kmalloc_failed;
13468 13460
13469 board->orig_reqp = reqp; 13461 adv_dvc->orig_reqp = reqp;
13470 13462
13471 /* 13463 /*
13472 * Allocate up to ADV_TOT_SG_BLOCK request structures for 13464 * Allocate up to ADV_TOT_SG_BLOCK request structures for
@@ -13490,8 +13482,6 @@ static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
13490 if (!board->adv_sgblkp) 13482 if (!board->adv_sgblkp)
13491 goto kmalloc_failed; 13483 goto kmalloc_failed;
13492 13484
13493 adv_dvc->carrier_buf = board->carrp;
13494
13495 /* 13485 /*
13496 * Point 'adv_reqp' to the request structures and 13486 * Point 'adv_reqp' to the request structures and
13497 * link them together. 13487 * link them together.
@@ -13529,15 +13519,16 @@ static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
13529 return err_code; 13519 return err_code;
13530} 13520}
13531 13521
13532static void advansys_wide_free_mem(struct asc_board *boardp) 13522static void advansys_wide_free_mem(struct asc_board *board)
13533{ 13523{
13534 kfree(boardp->carrp); 13524 struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
13535 boardp->carrp = NULL; 13525 kfree(adv_dvc->carrier_buf);
13536 kfree(boardp->orig_reqp); 13526 adv_dvc->carrier_buf = NULL;
13537 boardp->orig_reqp = boardp->adv_reqp = NULL; 13527 kfree(adv_dvc->orig_reqp);
13538 while (boardp->adv_sgblkp) { 13528 adv_dvc->orig_reqp = board->adv_reqp = NULL;
13539 adv_sgblk_t *sgp = boardp->adv_sgblkp; 13529 while (board->adv_sgblkp) {
13540 boardp->adv_sgblkp = sgp->next_sgblkp; 13530 adv_sgblk_t *sgp = board->adv_sgblkp;
13531 board->adv_sgblkp = sgp->next_sgblkp;
13541 kfree(sgp); 13532 kfree(sgp);
13542 } 13533 }
13543} 13534}