]> err.no Git - linux-2.6/blobdiff - drivers/scsi/aic7xxx/aic7xxx_osm.c
Pull battery into release branch
[linux-2.6] / drivers / scsi / aic7xxx / aic7xxx_osm.c
index ed85057152d5702776bbd02f7d082cfb497cf2f8..1803ab6fc21c49ac0ad158e42567b04651d52a82 100644 (file)
@@ -402,18 +402,8 @@ ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb)
 
        cmd = scb->io_ctx;
        ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE);
-       if (cmd->use_sg != 0) {
-               struct scatterlist *sg;
-
-               sg = (struct scatterlist *)cmd->request_buffer;
-               pci_unmap_sg(ahc->dev_softc, sg, cmd->use_sg,
-                            cmd->sc_data_direction);
-       } else if (cmd->request_bufflen != 0) {
-               pci_unmap_single(ahc->dev_softc,
-                                scb->platform_data->buf_busaddr,
-                                cmd->request_bufflen,
-                                cmd->sc_data_direction);
-       }
+
+       scsi_dma_unmap(cmd);
 }
 
 static __inline int
@@ -512,7 +502,6 @@ ahc_linux_target_alloc(struct scsi_target *starget)
        struct seeprom_config *sc = ahc->seep_config;
        unsigned long flags;
        struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget);
-       struct ahc_linux_target *targ = scsi_transport_target_data(starget);
        unsigned short scsirate;
        struct ahc_devinfo devinfo;
        struct ahc_initiator_tinfo *tinfo;
@@ -533,7 +522,6 @@ ahc_linux_target_alloc(struct scsi_target *starget)
        BUG_ON(*ahc_targp != NULL);
 
        *ahc_targp = starget;
-       memset(targ, 0, sizeof(*targ));
 
        if (sc) {
                int maxsync = AHC_SYNCRATE_DT;
@@ -594,14 +582,11 @@ ahc_linux_slave_alloc(struct scsi_device *sdev)
        struct  ahc_softc *ahc =
                *((struct ahc_softc **)sdev->host->hostdata);
        struct scsi_target *starget = sdev->sdev_target;
-       struct ahc_linux_target *targ = scsi_transport_target_data(starget);
        struct ahc_linux_device *dev;
 
        if (bootverbose)
                printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id);
 
-       BUG_ON(targ->sdev[sdev->lun] != NULL);
-
        dev = scsi_transport_device_data(sdev);
        memset(dev, 0, sizeof(*dev));
 
@@ -618,8 +603,6 @@ ahc_linux_slave_alloc(struct scsi_device *sdev)
         */
        dev->maxtags = 0;
        
-       targ->sdev[sdev->lun] = sdev;
-
        spi_period(starget) = 0;
 
        return 0;
@@ -644,22 +627,6 @@ ahc_linux_slave_configure(struct scsi_device *sdev)
        return 0;
 }
 
-static void
-ahc_linux_slave_destroy(struct scsi_device *sdev)
-{
-       struct  ahc_softc *ahc;
-       struct  ahc_linux_device *dev = scsi_transport_device_data(sdev);
-       struct  ahc_linux_target *targ = scsi_transport_target_data(sdev->sdev_target);
-
-       ahc = *((struct ahc_softc **)sdev->host->hostdata);
-       if (bootverbose)
-               printf("%s: Slave Destroy %d\n", ahc_name(ahc), sdev->id);
-
-       BUG_ON(dev->active);
-
-       targ->sdev[sdev->lun] = NULL;
-}
-
 #if defined(__i386__)
 /*
  * Return the disk geometry for the given SCSI device.
@@ -782,7 +749,6 @@ struct scsi_host_template aic7xxx_driver_template = {
        .use_clustering         = ENABLE_CLUSTERING,
        .slave_alloc            = ahc_linux_slave_alloc,
        .slave_configure        = ahc_linux_slave_configure,
-       .slave_destroy          = ahc_linux_slave_destroy,
        .target_alloc           = ahc_linux_target_alloc,
        .target_destroy         = ahc_linux_target_destroy,
 };
@@ -1204,21 +1170,13 @@ void
 ahc_platform_free(struct ahc_softc *ahc)
 {
        struct scsi_target *starget;
-       int i, j;
+       int i;
 
        if (ahc->platform_data != NULL) {
                /* destroy all of the device and target objects */
                for (i = 0; i < AHC_NUM_TARGETS; i++) {
                        starget = ahc->platform_data->starget[i];
                        if (starget != NULL) {
-                               for (j = 0; j < AHC_NUM_LUNS; j++) {
-                                       struct ahc_linux_target *targ =
-                                               scsi_transport_target_data(starget);
-
-                                       if (targ->sdev[j] == NULL)
-                                               continue;
-                                       targ->sdev[j] = NULL;
-                               }
                                ahc->platform_data->starget[i] = NULL;
                        }
                }
@@ -1252,24 +1210,13 @@ ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
 }
 
 void
-ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
-                     ahc_queue_alg alg)
+ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
+                     struct ahc_devinfo *devinfo, ahc_queue_alg alg)
 {
-       struct scsi_target *starget;
-       struct ahc_linux_target *targ;
        struct ahc_linux_device *dev;
-       struct scsi_device *sdev;
-       u_int target_offset;
        int was_queuing;
        int now_queuing;
 
-       target_offset = devinfo->target;
-       if (devinfo->channel != 'A')
-               target_offset += 8;
-       starget = ahc->platform_data->starget[target_offset];
-       targ = scsi_transport_target_data(starget);
-       BUG_ON(targ == NULL);
-       sdev = targ->sdev[devinfo->lun];
        if (sdev == NULL)
                return;
        dev = scsi_transport_device_data(sdev);
@@ -1402,11 +1349,15 @@ ahc_linux_device_queue_depth(struct scsi_device *sdev)
        tags = ahc_linux_user_tagdepth(ahc, &devinfo);
        if (tags != 0 && sdev->tagged_supported != 0) {
 
-               ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED);
+               ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_TAGGED);
+               ahc_send_async(ahc, devinfo.channel, devinfo.target,
+                              devinfo.lun, AC_TRANSFER_NEG);
                ahc_print_devinfo(ahc, &devinfo);
                printf("Tagged Queuing enabled.  Depth %d\n", tags);
        } else {
-               ahc_set_tags(ahc, &devinfo, AHC_QUEUE_NONE);
+               ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_NONE);
+               ahc_send_async(ahc, devinfo.channel, devinfo.target,
+                              devinfo.lun, AC_TRANSFER_NEG);
        }
 }
 
@@ -1420,6 +1371,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
        struct   ahc_tmode_tstate *tstate;
        uint16_t mask;
        struct scb_tailq *untagged_q = NULL;
+       int nseg;
 
        /*
         * Schedule us to run later.  The only reason we are not
@@ -1511,23 +1463,21 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
        ahc_set_residual(scb, 0);
        ahc_set_sense_residual(scb, 0);
        scb->sg_count = 0;
-       if (cmd->use_sg != 0) {
+
+       nseg = scsi_dma_map(cmd);
+       BUG_ON(nseg < 0);
+       if (nseg > 0) {
                struct  ahc_dma_seg *sg;
                struct  scatterlist *cur_seg;
-               struct  scatterlist *end_seg;
-               int     nseg;
+               int i;
 
-               cur_seg = (struct scatterlist *)cmd->request_buffer;
-               nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg,
-                                 cmd->sc_data_direction);
-               end_seg = cur_seg + nseg;
                /* Copy the segments into the SG list. */
                sg = scb->sg_list;
                /*
                 * The sg_count may be larger than nseg if
                 * a transfer crosses a 32bit page.
-                */ 
-               while (cur_seg < end_seg) {
+                */
+               scsi_for_each_sg(cmd, cur_seg, nseg, i) {
                        dma_addr_t addr;
                        bus_size_t len;
                        int consumed;
@@ -1538,7 +1488,6 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
                                                     sg, addr, len);
                        sg += consumed;
                        scb->sg_count += consumed;
-                       cur_seg++;
                }
                sg--;
                sg->len |= ahc_htole32(AHC_DMA_LAST_SEG);
@@ -1555,33 +1504,6 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
                 */
                scb->hscb->dataptr = scb->sg_list->addr;
                scb->hscb->datacnt = scb->sg_list->len;
-       } else if (cmd->request_bufflen != 0) {
-               struct   ahc_dma_seg *sg;
-               dma_addr_t addr;
-
-               sg = scb->sg_list;
-               addr = pci_map_single(ahc->dev_softc,
-                                     cmd->request_buffer,
-                                     cmd->request_bufflen,
-                                     cmd->sc_data_direction);
-               scb->platform_data->buf_busaddr = addr;
-               scb->sg_count = ahc_linux_map_seg(ahc, scb,
-                                                 sg, addr,
-                                                 cmd->request_bufflen);
-               sg->len |= ahc_htole32(AHC_DMA_LAST_SEG);
-
-               /*
-                * Reset the sg list pointer.
-                */
-               scb->hscb->sgptr =
-                       ahc_htole32(scb->sg_list_phys | SG_FULL_RESID);
-
-               /*
-                * Copy the first SG into the "current"
-                * data pointer area.
-                */
-               scb->hscb->dataptr = sg->addr;
-               scb->hscb->datacnt = sg->len;
        } else {
                scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL);
                scb->hscb->dataptr = 0;
@@ -1630,7 +1552,7 @@ ahc_platform_flushwork(struct ahc_softc *ahc)
 
 void
 ahc_send_async(struct ahc_softc *ahc, char channel,
-              u_int target, u_int lun, ac_code code, void *arg)
+              u_int target, u_int lun, ac_code code)
 {
        switch (code) {
        case AC_TRANSFER_NEG:
@@ -1947,7 +1869,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
                        }
                        ahc_set_transaction_status(scb, CAM_REQUEUE_REQ);
                        ahc_set_scsi_status(scb, SCSI_STATUS_OK);
-                       ahc_platform_set_tags(ahc, &devinfo,
+                       ahc_platform_set_tags(ahc, sdev, &devinfo,
                                     (dev->flags & AHC_DEV_Q_BASIC)
                                   ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
                        break;
@@ -1958,7 +1880,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
                 */
                dev->openings = 1;
                ahc_set_scsi_status(scb, SCSI_STATUS_BUSY);
-               ahc_platform_set_tags(ahc, &devinfo,
+               ahc_platform_set_tags(ahc, sdev, &devinfo,
                             (dev->flags & AHC_DEV_Q_BASIC)
                           ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
                break;
@@ -2600,8 +2522,6 @@ ahc_linux_init(void)
        if (!ahc_linux_transport_template)
                return -ENODEV;
 
-       scsi_transport_reserve_target(ahc_linux_transport_template,
-                                     sizeof(struct ahc_linux_target));
        scsi_transport_reserve_device(ahc_linux_transport_template,
                                      sizeof(struct ahc_linux_device));