aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/advansys.c
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-09-09 10:56:27 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:47:29 -0400
commita9f4a59a949c5de6313dcf4ebe2f91448c008a37 (patch)
treea5d87ecb9a30af36f7a26ab48159694d95b7d929 /drivers/scsi/advansys.c
parentb8e5152bf107d7b1b982e682b00a426b515bf15f (diff)
[SCSI] advansys: Create AdvBuildCarrierFreelist
Split AdvBuildCarrierFreelist out of AdvInitAsc3550Driver, AdvInitAsc38C0800Driver and AdvInitAsc38C1600Driver. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/advansys.c')
-rw-r--r--drivers/scsi/advansys.c219
1 files changed, 53 insertions, 166 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 27b3e95c4e66..c216d6a76782 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -12881,6 +12881,56 @@ AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc)
12881 return warn_code; 12881 return warn_code;
12882} 12882}
12883 12883
12884static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
12885{
12886 ADV_CARR_T *carrp;
12887 ADV_SDCNT buf_size;
12888 ADV_PADDR carr_paddr;
12889
12890 BUG_ON(!asc_dvc->carrier_buf);
12891
12892 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
12893 asc_dvc->carr_freelist = NULL;
12894 if (carrp == asc_dvc->carrier_buf) {
12895 buf_size = ADV_CARRIER_BUFSIZE;
12896 } else {
12897 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
12898 }
12899
12900 do {
12901 /* Get physical address of the carrier 'carrp'. */
12902 ADV_DCNT contig_len = sizeof(ADV_CARR_T);
12903 carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
12904 (uchar *)carrp,
12905 (ADV_SDCNT *)&contig_len,
12906 ADV_IS_CARRIER_FLAG));
12907
12908 buf_size -= sizeof(ADV_CARR_T);
12909
12910 /*
12911 * If the current carrier is not physically contiguous, then
12912 * maybe there was a page crossing. Try the next carrier
12913 * aligned start address.
12914 */
12915 if (contig_len < sizeof(ADV_CARR_T)) {
12916 carrp++;
12917 continue;
12918 }
12919
12920 carrp->carr_pa = carr_paddr;
12921 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
12922
12923 /*
12924 * Insert the carrier at the beginning of the freelist.
12925 */
12926 carrp->next_vpa =
12927 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
12928 asc_dvc->carr_freelist = carrp;
12929
12930 carrp++;
12931 } while (buf_size > 0);
12932}
12933
12884/* 12934/*
12885 * Initialize the ASC-3550. 12935 * Initialize the ASC-3550.
12886 * 12936 *
@@ -12902,10 +12952,6 @@ static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
12902 int word; 12952 int word;
12903 int j; 12953 int j;
12904 int adv_asc3550_expanded_size; 12954 int adv_asc3550_expanded_size;
12905 ADV_CARR_T *carrp;
12906 ADV_DCNT contig_len;
12907 ADV_SDCNT buf_size;
12908 ADV_PADDR carr_paddr;
12909 int i; 12955 int i;
12910 ushort scsi_cfg1; 12956 ushort scsi_cfg1;
12911 uchar tid; 12957 uchar tid;
@@ -13307,57 +13353,7 @@ static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
13307 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK, 13353 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
13308 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); 13354 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
13309 13355
13310 /* 13356 AdvBuildCarrierFreelist(asc_dvc);
13311 * Build carrier freelist.
13312 *
13313 * Driver must have already allocated memory and set 'carrier_buf'.
13314 */
13315 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
13316
13317 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
13318 asc_dvc->carr_freelist = NULL;
13319 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
13320 buf_size = ADV_CARRIER_BUFSIZE;
13321 } else {
13322 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
13323 }
13324
13325 do {
13326 /*
13327 * Get physical address of the carrier 'carrp'.
13328 */
13329 contig_len = sizeof(ADV_CARR_T);
13330 carr_paddr =
13331 cpu_to_le32(DvcGetPhyAddr
13332 (asc_dvc, NULL, (uchar *)carrp,
13333 (ADV_SDCNT *)&contig_len,
13334 ADV_IS_CARRIER_FLAG));
13335
13336 buf_size -= sizeof(ADV_CARR_T);
13337
13338 /*
13339 * If the current carrier is not physically contiguous, then
13340 * maybe there was a page crossing. Try the next carrier aligned
13341 * start address.
13342 */
13343 if (contig_len < sizeof(ADV_CARR_T)) {
13344 carrp++;
13345 continue;
13346 }
13347
13348 carrp->carr_pa = carr_paddr;
13349 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
13350
13351 /*
13352 * Insert the carrier at the beginning of the freelist.
13353 */
13354 carrp->next_vpa =
13355 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
13356 asc_dvc->carr_freelist = carrp;
13357
13358 carrp++;
13359 }
13360 while (buf_size > 0);
13361 13357
13362 /* 13358 /*
13363 * Set-up the Host->RISC Initiator Command Queue (ICQ). 13359 * Set-up the Host->RISC Initiator Command Queue (ICQ).
@@ -13471,10 +13467,6 @@ static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
13471 int word; 13467 int word;
13472 int j; 13468 int j;
13473 int adv_asc38C0800_expanded_size; 13469 int adv_asc38C0800_expanded_size;
13474 ADV_CARR_T *carrp;
13475 ADV_DCNT contig_len;
13476 ADV_SDCNT buf_size;
13477 ADV_PADDR carr_paddr;
13478 int i; 13470 int i;
13479 ushort scsi_cfg1; 13471 ushort scsi_cfg1;
13480 uchar byte; 13472 uchar byte;
@@ -13920,57 +13912,7 @@ static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
13920 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK, 13912 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
13921 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); 13913 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
13922 13914
13923 /* 13915 AdvBuildCarrierFreelist(asc_dvc);
13924 * Build the carrier freelist.
13925 *
13926 * Driver must have already allocated memory and set 'carrier_buf'.
13927 */
13928 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
13929
13930 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
13931 asc_dvc->carr_freelist = NULL;
13932 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
13933 buf_size = ADV_CARRIER_BUFSIZE;
13934 } else {
13935 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
13936 }
13937
13938 do {
13939 /*
13940 * Get physical address for the carrier 'carrp'.
13941 */
13942 contig_len = sizeof(ADV_CARR_T);
13943 carr_paddr =
13944 cpu_to_le32(DvcGetPhyAddr
13945 (asc_dvc, NULL, (uchar *)carrp,
13946 (ADV_SDCNT *)&contig_len,
13947 ADV_IS_CARRIER_FLAG));
13948
13949 buf_size -= sizeof(ADV_CARR_T);
13950
13951 /*
13952 * If the current carrier is not physically contiguous, then
13953 * maybe there was a page crossing. Try the next carrier aligned
13954 * start address.
13955 */
13956 if (contig_len < sizeof(ADV_CARR_T)) {
13957 carrp++;
13958 continue;
13959 }
13960
13961 carrp->carr_pa = carr_paddr;
13962 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
13963
13964 /*
13965 * Insert the carrier at the beginning of the freelist.
13966 */
13967 carrp->next_vpa =
13968 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
13969 asc_dvc->carr_freelist = carrp;
13970
13971 carrp++;
13972 }
13973 while (buf_size > 0);
13974 13916
13975 /* 13917 /*
13976 * Set-up the Host->RISC Initiator Command Queue (ICQ). 13918 * Set-up the Host->RISC Initiator Command Queue (ICQ).
@@ -14087,10 +14029,6 @@ static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
14087 long word; 14029 long word;
14088 int j; 14030 int j;
14089 int adv_asc38C1600_expanded_size; 14031 int adv_asc38C1600_expanded_size;
14090 ADV_CARR_T *carrp;
14091 ADV_DCNT contig_len;
14092 ADV_SDCNT buf_size;
14093 ADV_PADDR carr_paddr;
14094 int i; 14032 int i;
14095 ushort scsi_cfg1; 14033 ushort scsi_cfg1;
14096 uchar byte; 14034 uchar byte;
@@ -14544,58 +14482,7 @@ static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
14544 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK, 14482 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
14545 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); 14483 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
14546 14484
14547 /* 14485 AdvBuildCarrierFreelist(asc_dvc);
14548 * Build the carrier freelist.
14549 *
14550 * Driver must have already allocated memory and set 'carrier_buf'.
14551 */
14552
14553 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
14554
14555 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
14556 asc_dvc->carr_freelist = NULL;
14557 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
14558 buf_size = ADV_CARRIER_BUFSIZE;
14559 } else {
14560 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
14561 }
14562
14563 do {
14564 /*
14565 * Get physical address for the carrier 'carrp'.
14566 */
14567 contig_len = sizeof(ADV_CARR_T);
14568 carr_paddr =
14569 cpu_to_le32(DvcGetPhyAddr
14570 (asc_dvc, NULL, (uchar *)carrp,
14571 (ADV_SDCNT *)&contig_len,
14572 ADV_IS_CARRIER_FLAG));
14573
14574 buf_size -= sizeof(ADV_CARR_T);
14575
14576 /*
14577 * If the current carrier is not physically contiguous, then
14578 * maybe there was a page crossing. Try the next carrier aligned
14579 * start address.
14580 */
14581 if (contig_len < sizeof(ADV_CARR_T)) {
14582 carrp++;
14583 continue;
14584 }
14585
14586 carrp->carr_pa = carr_paddr;
14587 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
14588
14589 /*
14590 * Insert the carrier at the beginning of the freelist.
14591 */
14592 carrp->next_vpa =
14593 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
14594 asc_dvc->carr_freelist = carrp;
14595
14596 carrp++;
14597 }
14598 while (buf_size > 0);
14599 14486
14600 /* 14487 /*
14601 * Set-up the Host->RISC Initiator Command Queue (ICQ). 14488 * Set-up the Host->RISC Initiator Command Queue (ICQ).