forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/scsi/3w-9xxx.c
....@@ -143,7 +143,9 @@
143143 static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal);
144144 static int twa_reset_device_extension(TW_Device_Extension *tw_dev);
145145 static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset);
146
-static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg);
146
+static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
147
+ unsigned char *cdb, int use_sg,
148
+ TW_SG_Entry *sglistarg);
147149 static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id);
148150 static char *twa_string_lookup(twa_message_type *table, unsigned int aen_code);
149151
....@@ -278,7 +280,7 @@
278280 static int twa_aen_drain_queue(TW_Device_Extension *tw_dev, int no_check_reset)
279281 {
280282 int request_id = 0;
281
- char cdb[TW_MAX_CDB_LEN];
283
+ unsigned char cdb[TW_MAX_CDB_LEN];
282284 TW_SG_Entry sglist[1];
283285 int finished = 0, count = 0;
284286 TW_Command_Full *full_command_packet;
....@@ -423,7 +425,7 @@
423425 /* This function will read the aen queue from the isr */
424426 static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id)
425427 {
426
- char cdb[TW_MAX_CDB_LEN];
428
+ unsigned char cdb[TW_MAX_CDB_LEN];
427429 TW_SG_Entry sglist[1];
428430 TW_Command_Full *full_command_packet;
429431 int retval = 1;
....@@ -518,7 +520,8 @@
518520 unsigned long *cpu_addr;
519521 int retval = 1;
520522
521
- cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle);
523
+ cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev,
524
+ size * TW_Q_LENGTH, &dma_handle, GFP_KERNEL);
522525 if (!cpu_addr) {
523526 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
524527 goto out;
....@@ -526,7 +529,8 @@
526529
527530 if ((unsigned long)cpu_addr % (TW_ALIGNMENT_9000)) {
528531 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x6, "Failed to allocate correctly aligned memory");
529
- pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle);
532
+ dma_free_coherent(&tw_dev->tw_pci_dev->dev, size * TW_Q_LENGTH,
533
+ cpu_addr, dma_handle);
530534 goto out;
531535 }
532536
....@@ -1027,16 +1031,16 @@
10271031 static void twa_free_device_extension(TW_Device_Extension *tw_dev)
10281032 {
10291033 if (tw_dev->command_packet_virt[0])
1030
- pci_free_consistent(tw_dev->tw_pci_dev,
1031
- sizeof(TW_Command_Full)*TW_Q_LENGTH,
1032
- tw_dev->command_packet_virt[0],
1033
- tw_dev->command_packet_phys[0]);
1034
+ dma_free_coherent(&tw_dev->tw_pci_dev->dev,
1035
+ sizeof(TW_Command_Full) * TW_Q_LENGTH,
1036
+ tw_dev->command_packet_virt[0],
1037
+ tw_dev->command_packet_phys[0]);
10341038
10351039 if (tw_dev->generic_buffer_virt[0])
1036
- pci_free_consistent(tw_dev->tw_pci_dev,
1037
- TW_SECTOR_SIZE*TW_Q_LENGTH,
1038
- tw_dev->generic_buffer_virt[0],
1039
- tw_dev->generic_buffer_phys[0]);
1040
+ dma_free_coherent(&tw_dev->tw_pci_dev->dev,
1041
+ TW_SECTOR_SIZE * TW_Q_LENGTH,
1042
+ tw_dev->generic_buffer_virt[0],
1043
+ tw_dev->generic_buffer_phys[0]);
10401044
10411045 kfree(tw_dev->event_queue[0]);
10421046 } /* End twa_free_device_extension() */
....@@ -1796,7 +1800,9 @@
17961800 static DEF_SCSI_QCMD(twa_scsi_queue)
17971801
17981802 /* This function hands scsi cdb's to the firmware */
1799
-static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg)
1803
+static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
1804
+ unsigned char *cdb, int use_sg,
1805
+ TW_SG_Entry *sglistarg)
18001806 {
18011807 TW_Command_Full *full_command_packet;
18021808 TW_Command_Apache *command_packet;
....@@ -1992,7 +1998,6 @@
19921998 .sg_tablesize = TW_APACHE_MAX_SGL_LENGTH,
19931999 .max_sectors = TW_MAX_SECTORS,
19942000 .cmd_per_lun = TW_MAX_CMDS_PER_LUN,
1995
- .use_clustering = ENABLE_CLUSTERING,
19962001 .shost_attrs = twa_host_attrs,
19972002 .emulated = 1,
19982003 .no_write_same = 1,
....@@ -2004,25 +2009,25 @@
20042009 struct Scsi_Host *host = NULL;
20052010 TW_Device_Extension *tw_dev;
20062011 unsigned long mem_addr, mem_len;
2007
- int retval = -ENODEV;
2012
+ int retval;
20082013
20092014 retval = pci_enable_device(pdev);
20102015 if (retval) {
20112016 TW_PRINTK(host, TW_DRIVER, 0x34, "Failed to enable pci device");
2012
- goto out_disable_device;
2017
+ return -ENODEV;
20132018 }
20142019
20152020 pci_set_master(pdev);
20162021 pci_try_set_mwi(pdev);
20172022
2018
- if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
2019
- || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
2020
- if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
2021
- || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
2022
- TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
2023
- retval = -ENODEV;
2024
- goto out_disable_device;
2025
- }
2023
+ retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
2024
+ if (retval)
2025
+ retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
2026
+ if (retval) {
2027
+ TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
2028
+ retval = -ENODEV;
2029
+ goto out_disable_device;
2030
+ }
20262031
20272032 host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
20282033 if (!host) {
....@@ -2237,14 +2242,14 @@
22372242 pci_set_master(pdev);
22382243 pci_try_set_mwi(pdev);
22392244
2240
- if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
2241
- || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
2242
- if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
2243
- || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
2244
- TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
2245
- retval = -ENODEV;
2246
- goto out_disable_device;
2247
- }
2245
+ retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
2246
+ if (retval)
2247
+ retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
2248
+ if (retval) {
2249
+ TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
2250
+ retval = -ENODEV;
2251
+ goto out_disable_device;
2252
+ }
22482253
22492254 /* Initialize the card */
22502255 if (twa_reset_sequence(tw_dev, 0)) {