forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/scsi/aic7xxx/aic79xx_osm.c
....@@ -700,9 +700,6 @@
700700 static int
701701 ahd_linux_slave_configure(struct scsi_device *sdev)
702702 {
703
- struct ahd_softc *ahd;
704
-
705
- ahd = *((struct ahd_softc **)sdev->host->hostdata);
706703 if (bootverbose)
707704 sdev_printk(KERN_INFO, sdev, "Slave Configure\n");
708705
....@@ -723,24 +720,17 @@
723720 ahd_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev,
724721 sector_t capacity, int geom[])
725722 {
726
- uint8_t *bh;
727723 int heads;
728724 int sectors;
729725 int cylinders;
730
- int ret;
731726 int extended;
732727 struct ahd_softc *ahd;
733728
734729 ahd = *((struct ahd_softc **)sdev->host->hostdata);
735730
736
- bh = scsi_bios_ptable(bdev);
737
- if (bh) {
738
- ret = scsi_partsize(bh, capacity,
739
- &geom[2], &geom[0], &geom[1]);
740
- kfree(bh);
741
- if (ret != -1)
742
- return (ret);
743
- }
731
+ if (scsi_partsize(bdev, capacity, geom))
732
+ return 0;
733
+
744734 heads = 64;
745735 sectors = 32;
746736 cylinders = aic_sector_div(capacity, heads, sectors);
....@@ -785,16 +775,13 @@
785775 struct scb *reset_scb;
786776 u_int cdb_byte;
787777 int retval = SUCCESS;
788
- int paused;
789
- int wait;
790778 struct ahd_initiator_tinfo *tinfo;
791779 struct ahd_tmode_tstate *tstate;
792780 unsigned long flags;
793781 DECLARE_COMPLETION_ONSTACK(done);
794782
795783 reset_scb = NULL;
796
- paused = FALSE;
797
- wait = FALSE;
784
+
798785 ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
799786
800787 scmd_printk(KERN_INFO, cmd,
....@@ -920,7 +907,6 @@
920907 .this_id = -1,
921908 .max_sectors = 8192,
922909 .cmd_per_lun = 2,
923
- .use_clustering = ENABLE_CLUSTERING,
924910 .slave_alloc = ahd_linux_slave_alloc,
925911 .slave_configure = ahd_linux_slave_configure,
926912 .target_alloc = ahd_linux_target_alloc,
....@@ -966,8 +952,8 @@
966952 ahd_dmamem_alloc(struct ahd_softc *ahd, bus_dma_tag_t dmat, void** vaddr,
967953 int flags, bus_dmamap_t *mapp)
968954 {
969
- *vaddr = pci_alloc_consistent(ahd->dev_softc,
970
- dmat->maxsize, mapp);
955
+ *vaddr = dma_alloc_coherent(&ahd->dev_softc->dev, dmat->maxsize, mapp,
956
+ GFP_ATOMIC);
971957 if (*vaddr == NULL)
972958 return (ENOMEM);
973959 return(0);
....@@ -977,8 +963,7 @@
977963 ahd_dmamem_free(struct ahd_softc *ahd, bus_dma_tag_t dmat,
978964 void* vaddr, bus_dmamap_t map)
979965 {
980
- pci_free_consistent(ahd->dev_softc, dmat->maxsize,
981
- vaddr, map);
966
+ dma_free_coherent(&ahd->dev_softc->dev, dmat->maxsize, vaddr, map);
982967 }
983968
984969 int
....@@ -1801,10 +1786,12 @@
18011786 */
18021787 cmd->sense_buffer[0] = 0;
18031788 if (ahd_get_transaction_status(scb) == CAM_REQ_INPROG) {
1789
+#ifdef AHD_REPORT_UNDERFLOWS
18041790 uint32_t amount_xferred;
18051791
18061792 amount_xferred =
18071793 ahd_get_transfer_length(scb) - ahd_get_residual(scb);
1794
+#endif
18081795 if ((scb->flags & SCB_TRANSMISSION_ERROR) != 0) {
18091796 #ifdef AHD_DEBUG
18101797 if ((ahd_debug & AHD_SHOW_MISC) != 0) {
....@@ -2047,7 +2034,7 @@
20472034 break;
20482035 case CAM_AUTOSENSE_FAIL:
20492036 new_status = DID_ERROR;
2050
- /* Fallthrough */
2037
+ fallthrough;
20512038 case CAM_SCSI_STATUS_ERROR:
20522039 scsi_status = ahd_cmd_get_scsi_status(cmd);
20532040
....@@ -2155,7 +2142,7 @@
21552142 u_int last_phase;
21562143 u_int saved_scsiid;
21572144 u_int cdb_byte;
2158
- int retval;
2145
+ int retval = SUCCESS;
21592146 int was_paused;
21602147 int paused;
21612148 int wait;
....@@ -2193,8 +2180,7 @@
21932180 * so we must not still own the command.
21942181 */
21952182 scmd_printk(KERN_INFO, cmd, "Is not an active device\n");
2196
- retval = SUCCESS;
2197
- goto no_cmd;
2183
+ goto done;
21982184 }
21992185
22002186 /*
....@@ -2207,7 +2193,7 @@
22072193
22082194 if (pending_scb == NULL) {
22092195 scmd_printk(KERN_INFO, cmd, "Command not found\n");
2210
- goto no_cmd;
2196
+ goto done;
22112197 }
22122198
22132199 if ((pending_scb->flags & SCB_RECOVERY_SCB) != 0) {
....@@ -2215,7 +2201,7 @@
22152201 * We can't queue two recovery actions using the same SCB
22162202 */
22172203 retval = FAILED;
2218
- goto done;
2204
+ goto done;
22192205 }
22202206
22212207 /*
....@@ -2230,7 +2216,7 @@
22302216
22312217 if ((pending_scb->flags & SCB_ACTIVE) == 0) {
22322218 scmd_printk(KERN_INFO, cmd, "Command already completed\n");
2233
- goto no_cmd;
2219
+ goto done;
22342220 }
22352221
22362222 printk("%s: At time of recovery, card was %spaused\n",
....@@ -2247,7 +2233,6 @@
22472233 printk("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
22482234 ahd_name(ahd), cmd->device->channel,
22492235 cmd->device->id, (u8)cmd->device->lun);
2250
- retval = SUCCESS;
22512236 goto done;
22522237 }
22532238
....@@ -2344,17 +2329,10 @@
23442329 } else {
23452330 scmd_printk(KERN_INFO, cmd, "Unable to deliver message\n");
23462331 retval = FAILED;
2347
- goto done;
23482332 }
23492333
2350
-no_cmd:
2351
- /*
2352
- * Our assumption is that if we don't have the command, no
2353
- * recovery action was required, so we return success. Again,
2354
- * the semantics of the mid-layer recovery engine are not
2355
- * well defined, so this may change in time.
2356
- */
2357
- retval = SUCCESS;
2334
+
2335
+ ahd_restore_modes(ahd, saved_modes);
23582336 done:
23592337 if (paused)
23602338 ahd_unpause(ahd);