forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-16 50a212ec906f7524620675f0c57357691c26c81f
kernel/drivers/scsi/aic7xxx/aic79xx_core.c
....@@ -40,16 +40,9 @@
4040 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#250 $
4141 */
4242
43
-#ifdef __linux__
4443 #include "aic79xx_osm.h"
4544 #include "aic79xx_inline.h"
4645 #include "aicasm/aicasm_insformat.h"
47
-#else
48
-#include <dev/aic7xxx/aic79xx_osm.h>
49
-#include <dev/aic7xxx/aic79xx_inline.h>
50
-#include <dev/aic7xxx/aicasm/aicasm_insformat.h>
51
-#endif
52
-
5346
5447 /***************************** Lookup Tables **********************************/
5548 static const char *const ahd_chip_names[] =
....@@ -59,7 +52,6 @@
5952 "aic7902",
6053 "aic7901A"
6154 };
62
-static const u_int num_chip_names = ARRAY_SIZE(ahd_chip_names);
6355
6456 /*
6557 * Hardware error codes.
....@@ -1743,10 +1735,8 @@
17431735 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
17441736 for (i = 0; i < scb->sg_count; i++) {
17451737 uint64_t addr;
1746
- uint32_t len;
17471738
17481739 addr = ahd_le64toh(sg_list[i].addr);
1749
- len = ahd_le32toh(sg_list[i].len);
17501740 printk("sg[%d] - Addr 0x%x%x : Length %d%s\n",
17511741 i,
17521742 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
....@@ -1914,9 +1904,6 @@
19141904 {
19151905 struct ahd_devinfo devinfo;
19161906 struct scb *scb;
1917
- struct ahd_initiator_tinfo *targ_info;
1918
- struct ahd_tmode_tstate *tstate;
1919
- struct ahd_transinfo *tinfo;
19201907 u_int scbid;
19211908
19221909 /*
....@@ -1944,12 +1931,6 @@
19441931 SCB_GET_LUN(scb),
19451932 SCB_GET_CHANNEL(ahd, scb),
19461933 ROLE_INITIATOR);
1947
- targ_info = ahd_fetch_transinfo(ahd,
1948
- devinfo.channel,
1949
- devinfo.our_scsiid,
1950
- devinfo.target,
1951
- &tstate);
1952
- tinfo = &targ_info->curr;
19531934 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
19541935 AHD_TRANS_ACTIVE, /*paused*/TRUE);
19551936 ahd_set_syncrate(ahd, &devinfo, /*period*/0,
....@@ -2293,6 +2274,7 @@
22932274 switch (scb->hscb->task_management) {
22942275 case SIU_TASKMGMT_ABORT_TASK:
22952276 tag = SCB_GET_TAG(scb);
2277
+ fallthrough;
22962278 case SIU_TASKMGMT_ABORT_TASK_SET:
22972279 case SIU_TASKMGMT_CLEAR_TASK_SET:
22982280 lun = scb->hscb->lun;
....@@ -2303,6 +2285,7 @@
23032285 break;
23042286 case SIU_TASKMGMT_LUN_RESET:
23052287 lun = scb->hscb->lun;
2288
+ fallthrough;
23062289 case SIU_TASKMGMT_TARGET_RESET:
23072290 {
23082291 struct ahd_devinfo devinfo;
....@@ -2675,7 +2658,6 @@
26752658 struct scb *scb;
26762659 u_int scbid;
26772660 u_int lqistat1;
2678
- u_int lqistat2;
26792661 u_int msg_out;
26802662 u_int curphase;
26812663 u_int lastphase;
....@@ -2686,7 +2668,7 @@
26862668 scb = NULL;
26872669 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
26882670 lqistat1 = ahd_inb(ahd, LQISTAT1) & ~(LQIPHASE_LQ|LQIPHASE_NLQ);
2689
- lqistat2 = ahd_inb(ahd, LQISTAT2);
2671
+ ahd_inb(ahd, LQISTAT2);
26902672 if ((lqistat1 & (LQICRCI_NLQ|LQICRCI_LQ)) == 0
26912673 && (ahd->bugs & AHD_NLQICRC_DELAYED_BUG) != 0) {
26922674 u_int lqistate;
....@@ -3113,19 +3095,6 @@
31133095 printerror = 0;
31143096 } else if (ahd_sent_msg(ahd, AHDMSG_1B,
31153097 MSG_BUS_DEV_RESET, TRUE)) {
3116
-#ifdef __FreeBSD__
3117
- /*
3118
- * Don't mark the user's request for this BDR
3119
- * as completing with CAM_BDR_SENT. CAM3
3120
- * specifies CAM_REQ_CMP.
3121
- */
3122
- if (scb != NULL
3123
- && scb->io_ctx->ccb_h.func_code== XPT_RESET_DEV
3124
- && ahd_match_scb(ahd, scb, target, 'A',
3125
- CAM_LUN_WILDCARD, SCB_LIST_NULL,
3126
- ROLE_INITIATOR))
3127
- ahd_set_transaction_status(scb, CAM_REQ_CMP);
3128
-#endif
31293098 ahd_handle_devreset(ahd, &devinfo, CAM_LUN_WILDCARD,
31303099 CAM_BDR_SENT, "Bus Device Reset",
31313100 /*verbose_level*/0);
....@@ -3681,8 +3650,7 @@
36813650 return;
36823651
36833652 tstate = ahd->enabled_targets[scsi_id];
3684
- if (tstate != NULL)
3685
- kfree(tstate);
3653
+ kfree(tstate);
36863654 ahd->enabled_targets[scsi_id] = NULL;
36873655 }
36883656 #endif
....@@ -3823,7 +3791,7 @@
38233791 *bus_width = MSG_EXT_WDTR_BUS_16_BIT;
38243792 break;
38253793 }
3826
- /* FALLTHROUGH */
3794
+ fallthrough;
38273795 case MSG_EXT_WDTR_BUS_8_BIT:
38283796 *bus_width = MSG_EXT_WDTR_BUS_8_BIT;
38293797 break;
....@@ -4238,13 +4206,11 @@
42384206 pending_scb_count = 0;
42394207 LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
42404208 struct ahd_devinfo devinfo;
4241
- struct ahd_initiator_tinfo *tinfo;
42424209 struct ahd_tmode_tstate *tstate;
42434210
42444211 ahd_scb_devinfo(ahd, &devinfo, pending_scb);
4245
- tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
4246
- devinfo.our_scsiid,
4247
- devinfo.target, &tstate);
4212
+ ahd_fetch_transinfo(ahd, devinfo.channel, devinfo.our_scsiid,
4213
+ devinfo.target, &tstate);
42484214 if ((tstate->auto_negotiate & devinfo.target_mask) == 0
42494215 && (pending_scb->flags & SCB_AUTO_NEGOTIATE) != 0) {
42504216 pending_scb->flags &= ~SCB_AUTO_NEGOTIATE;
....@@ -5138,7 +5104,7 @@
51385104 break;
51395105 case MSG_MESSAGE_REJECT:
51405106 response = ahd_handle_msg_reject(ahd, devinfo);
5141
- /* FALLTHROUGH */
5107
+ fallthrough;
51425108 case MSG_NOOP:
51435109 done = MSGLOOP_MSGCOMPLETE;
51445110 break;
....@@ -5488,7 +5454,7 @@
54885454 ahd_name(ahd), ahd_inb(ahd, SCSISIGI));
54895455 #endif
54905456 ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE;
5491
- /* FALLTHROUGH */
5457
+ fallthrough;
54925458 case MSG_TERM_IO_PROC:
54935459 default:
54945460 reject = TRUE;
....@@ -6073,22 +6039,16 @@
60736039 {
60746040 struct ahd_softc *ahd;
60756041
6076
-#ifndef __FreeBSD__
6077
- ahd = kmalloc(sizeof(*ahd), GFP_ATOMIC);
6042
+ ahd = kzalloc(sizeof(*ahd), GFP_ATOMIC);
60786043 if (!ahd) {
60796044 printk("aic7xxx: cannot malloc softc!\n");
60806045 kfree(name);
60816046 return NULL;
60826047 }
6083
-#else
6084
- ahd = device_get_softc((device_t)platform_arg);
6085
-#endif
6086
- memset(ahd, 0, sizeof(*ahd));
6048
+
60876049 ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC);
60886050 if (ahd->seep_config == NULL) {
6089
-#ifndef __FreeBSD__
60906051 kfree(ahd);
6091
-#endif
60926052 kfree(name);
60936053 return (NULL);
60946054 }
....@@ -6144,8 +6104,7 @@
61446104 void
61456105 ahd_set_name(struct ahd_softc *ahd, char *name)
61466106 {
6147
- if (ahd->name != NULL)
6148
- kfree(ahd->name);
6107
+ kfree(ahd->name);
61496108 ahd->name = name;
61506109 }
61516110
....@@ -6158,31 +6117,25 @@
61586117 default:
61596118 case 5:
61606119 ahd_shutdown(ahd);
6161
- /* FALLTHROUGH */
6120
+ fallthrough;
61626121 case 4:
61636122 ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
61646123 ahd->shared_data_map.dmamap);
6165
- /* FALLTHROUGH */
6124
+ fallthrough;
61666125 case 3:
61676126 ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo,
61686127 ahd->shared_data_map.dmamap);
61696128 ahd_dmamap_destroy(ahd, ahd->shared_data_dmat,
61706129 ahd->shared_data_map.dmamap);
6171
- /* FALLTHROUGH */
6130
+ fallthrough;
61726131 case 2:
61736132 ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat);
61746133 case 1:
6175
-#ifndef __linux__
6176
- ahd_dma_tag_destroy(ahd, ahd->buffer_dmat);
6177
-#endif
61786134 break;
61796135 case 0:
61806136 break;
61816137 }
61826138
6183
-#ifndef __linux__
6184
- ahd_dma_tag_destroy(ahd, ahd->parent_dmat);
6185
-#endif
61866139 ahd_platform_free(ahd);
61876140 ahd_fini_scbdata(ahd);
61886141 for (i = 0; i < AHD_NUM_TARGETS; i++) {
....@@ -6212,15 +6165,10 @@
62126165 kfree(ahd->black_hole);
62136166 }
62146167 #endif
6215
- if (ahd->name != NULL)
6216
- kfree(ahd->name);
6217
- if (ahd->seep_config != NULL)
6218
- kfree(ahd->seep_config);
6219
- if (ahd->saved_stack != NULL)
6220
- kfree(ahd->saved_stack);
6221
-#ifndef __FreeBSD__
6168
+ kfree(ahd->name);
6169
+ kfree(ahd->seep_config);
6170
+ kfree(ahd->saved_stack);
62226171 kfree(ahd);
6223
-#endif
62246172 return;
62256173 }
62266174
....@@ -6564,8 +6512,8 @@
65646512 kfree(sns_map);
65656513 }
65666514 ahd_dma_tag_destroy(ahd, scb_data->sense_dmat);
6567
- /* FALLTHROUGH */
65686515 }
6516
+ fallthrough;
65696517 case 6:
65706518 {
65716519 struct map_node *sg_map;
....@@ -6579,8 +6527,8 @@
65796527 kfree(sg_map);
65806528 }
65816529 ahd_dma_tag_destroy(ahd, scb_data->sg_dmat);
6582
- /* FALLTHROUGH */
65836530 }
6531
+ fallthrough;
65846532 case 5:
65856533 {
65866534 struct map_node *hscb_map;
....@@ -6934,9 +6882,6 @@
69346882 for (i = 0; i < newcount; i++) {
69356883 struct scb_platform_data *pdata;
69366884 u_int col_tag;
6937
-#ifndef __linux__
6938
- int error;
6939
-#endif
69406885
69416886 next_scb = kmalloc(sizeof(*next_scb), GFP_ATOMIC);
69426887 if (next_scb == NULL)
....@@ -6970,15 +6915,6 @@
69706915 next_scb->sg_list_busaddr += sizeof(struct ahd_dma_seg);
69716916 next_scb->ahd_softc = ahd;
69726917 next_scb->flags = SCB_FLAG_NONE;
6973
-#ifndef __linux__
6974
- error = ahd_dmamap_create(ahd, ahd->buffer_dmat, /*flags*/0,
6975
- &next_scb->dmamap);
6976
- if (error != 0) {
6977
- kfree(next_scb);
6978
- kfree(pdata);
6979
- break;
6980
- }
6981
-#endif
69826918 next_scb->hscb->tag = ahd_htole16(scb_data->numscbs);
69836919 col_tag = scb_data->numscbs ^ 0x100;
69846920 next_scb->col_scb = ahd_find_scb_by_tag(ahd, col_tag);
....@@ -7090,24 +7026,6 @@
70907026 */
70917027 if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0)
70927028 ahd->features &= ~AHD_TARGETMODE;
7093
-
7094
-#ifndef __linux__
7095
- /* DMA tag for mapping buffers into device visible space. */
7096
- if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
7097
- /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
7098
- /*lowaddr*/ahd->flags & AHD_39BIT_ADDRESSING
7099
- ? (dma_addr_t)0x7FFFFFFFFFULL
7100
- : BUS_SPACE_MAXADDR_32BIT,
7101
- /*highaddr*/BUS_SPACE_MAXADDR,
7102
- /*filter*/NULL, /*filterarg*/NULL,
7103
- /*maxsize*/(AHD_NSEG - 1) * PAGE_SIZE,
7104
- /*nsegments*/AHD_NSEG,
7105
- /*maxsegsz*/AHD_MAXTRANSFER_SIZE,
7106
- /*flags*/BUS_DMA_ALLOCNOW,
7107
- &ahd->buffer_dmat) != 0) {
7108
- return (ENOMEM);
7109
- }
7110
-#endif
71117029
71127030 ahd->init_level++;
71137031
....@@ -7253,6 +7171,7 @@
72537171 case FLX_CSTAT_OVER:
72547172 case FLX_CSTAT_UNDER:
72557173 warn_user++;
7174
+ fallthrough;
72567175 case FLX_CSTAT_INVALID:
72577176 case FLX_CSTAT_OKAY:
72587177 if (warn_user == 0 && bootverbose == 0)
....@@ -8256,12 +8175,12 @@
82568175 if ((scb->flags & SCB_ACTIVE) == 0)
82578176 printk("Inactive SCB in qinfifo\n");
82588177 ahd_done_with_status(ahd, scb, status);
8259
- /* FALLTHROUGH */
8178
+ fallthrough;
82608179 case SEARCH_REMOVE:
82618180 break;
82628181 case SEARCH_PRINT:
82638182 printk(" 0x%x", ahd->qinfifo[qinpos]);
8264
- /* FALLTHROUGH */
8183
+ fallthrough;
82658184 case SEARCH_COUNT:
82668185 ahd_qinfifo_requeue(ahd, prev_scb, scb);
82678186 prev_scb = scb;
....@@ -8352,7 +8271,7 @@
83528271 if ((mk_msg_scb->flags & SCB_ACTIVE) == 0)
83538272 printk("Inactive SCB pending MK_MSG\n");
83548273 ahd_done_with_status(ahd, mk_msg_scb, status);
8355
- /* FALLTHROUGH */
8274
+ fallthrough;
83568275 case SEARCH_REMOVE:
83578276 {
83588277 u_int tail_offset;
....@@ -8376,7 +8295,7 @@
83768295 }
83778296 case SEARCH_PRINT:
83788297 printk(" 0x%x", SCB_GET_TAG(scb));
8379
- /* FALLTHROUGH */
8298
+ fallthrough;
83808299 case SEARCH_COUNT:
83818300 break;
83828301 }
....@@ -8457,7 +8376,7 @@
84578376 if ((scb->flags & SCB_ACTIVE) == 0)
84588377 printk("Inactive SCB in Waiting List\n");
84598378 ahd_done_with_status(ahd, scb, status);
8460
- /* FALLTHROUGH */
8379
+ fallthrough;
84618380 case SEARCH_REMOVE:
84628381 ahd_rem_wscb(ahd, scbid, prev, next, tid);
84638382 *list_tail = prev;
....@@ -8466,6 +8385,7 @@
84668385 break;
84678386 case SEARCH_PRINT:
84688387 printk("0x%x ", scbid);
8388
+ fallthrough;
84698389 case SEARCH_COUNT:
84708390 prev = scbid;
84718391 break;
....@@ -9103,7 +9023,7 @@
91039023 case SCSI_STATUS_OK:
91049024 printk("%s: Interrupted for status of 0???\n",
91059025 ahd_name(ahd));
9106
- /* FALLTHROUGH */
9026
+ fallthrough;
91079027 default:
91089028 ahd_done(ahd, scb);
91099029 break;
....@@ -9482,10 +9402,9 @@
94829402 if (cs_count != 0) {
94839403
94849404 cs_count *= sizeof(struct cs);
9485
- ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
9405
+ ahd->critical_sections = kmemdup(cs_table, cs_count, GFP_ATOMIC);
94869406 if (ahd->critical_sections == NULL)
94879407 panic("ahd_loadseq: Could not malloc");
9488
- memcpy(ahd->critical_sections, cs_table, cs_count);
94899408 }
94909409 ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
94919410
....@@ -9591,8 +9510,8 @@
95919510 {
95929511 fmt3_ins = &instr.format3;
95939512 fmt3_ins->address = ahd_resolve_seqaddr(ahd, fmt3_ins->address);
9594
- /* FALLTHROUGH */
95959513 }
9514
+ fallthrough;
95969515 case AIC_OP_OR:
95979516 case AIC_OP_AND:
95989517 case AIC_OP_XOR:
....@@ -9603,7 +9522,7 @@
96039522 fmt1_ins->immediate = dconsts[fmt1_ins->immediate];
96049523 }
96059524 fmt1_ins->parity = 0;
9606
- /* FALLTHROUGH */
9525
+ fallthrough;
96079526 case AIC_OP_ROL:
96089527 {
96099528 int i, count;