~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/scsi/aic7xxx/aic79xx_core.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
289
289
         || ahd->dst_mode == AHD_MODE_UNKNOWN)
290
290
                panic("Setting mode prior to saving it.\n");
291
291
        if ((ahd_debug & AHD_SHOW_MODEPTR) != 0)
292
 
                printf("%s: Setting mode 0x%x\n", ahd_name(ahd),
 
292
                printk("%s: Setting mode 0x%x\n", ahd_name(ahd),
293
293
                       ahd_build_mode_state(ahd, src, dst));
294
294
#endif
295
295
        ahd_outb(ahd, MODE_PTR, ahd_build_mode_state(ahd, src, dst));
307
307
        mode_ptr = ahd_inb(ahd, MODE_PTR);
308
308
#ifdef AHD_DEBUG
309
309
        if ((ahd_debug & AHD_SHOW_MODEPTR) != 0)
310
 
                printf("Reading mode 0x%x\n", mode_ptr);
 
310
                printk("Reading mode 0x%x\n", mode_ptr);
311
311
#endif
312
312
        ahd_extract_mode_state(ahd, mode_ptr, &src, &dst);
313
313
        ahd_known_modes(ahd, src, dst);
877
877
                uint64_t host_dataptr;
878
878
 
879
879
                host_dataptr = ahd_le64toh(scb->hscb->dataptr);
880
 
                printf("%s: Queueing SCB %d:0x%x bus addr 0x%x - 0x%x%x/0x%x\n",
 
880
                printk("%s: Queueing SCB %d:0x%x bus addr 0x%x - 0x%x%x/0x%x\n",
881
881
                       ahd_name(ahd),
882
882
                       SCB_GET_TAG(scb), scb->hscb->scsiid,
883
883
                       ahd_le32toh(scb->hscb->hscb_busaddr),
1174
1174
 
1175
1175
#ifdef AHD_DEBUG
1176
1176
        if ((ahd_debug & AHD_SHOW_FIFOS) != 0)
1177
 
                printf("%s: Clearing FIFO %d\n", ahd_name(ahd), fifo);
 
1177
                printk("%s: Clearing FIFO %d\n", ahd_name(ahd), fifo);
1178
1178
#endif
1179
1179
        saved_modes = ahd_save_modes(ahd);
1180
1180
        ahd_set_modes(ahd, fifo, fifo);
1215
1215
                scbid = ahd_inw(ahd, GSFIFO);
1216
1216
                scb = ahd_lookup_scb(ahd, scbid);
1217
1217
                if (scb == NULL) {
1218
 
                        printf("%s: Warning - GSFIFO SCB %d invalid\n",
 
1218
                        printk("%s: Warning - GSFIFO SCB %d invalid\n",
1219
1219
                               ahd_name(ahd), scbid);
1220
1220
                        continue;
1221
1221
                }
1339
1339
                next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
1340
1340
                scb = ahd_lookup_scb(ahd, scbid);
1341
1341
                if (scb == NULL) {
1342
 
                        printf("%s: Warning - DMA-up and complete "
 
1342
                        printk("%s: Warning - DMA-up and complete "
1343
1343
                               "SCB %d invalid\n", ahd_name(ahd), scbid);
1344
1344
                        continue;
1345
1345
                }
1360
1360
                next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
1361
1361
                scb = ahd_lookup_scb(ahd, scbid);
1362
1362
                if (scb == NULL) {
1363
 
                        printf("%s: Warning - Complete Qfrz SCB %d invalid\n",
 
1363
                        printk("%s: Warning - Complete Qfrz SCB %d invalid\n",
1364
1364
                               ahd_name(ahd), scbid);
1365
1365
                        continue;
1366
1366
                }
1377
1377
                next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
1378
1378
                scb = ahd_lookup_scb(ahd, scbid);
1379
1379
                if (scb == NULL) {
1380
 
                        printf("%s: Warning - Complete SCB %d invalid\n",
 
1380
                        printk("%s: Warning - Complete SCB %d invalid\n",
1381
1381
                               ahd_name(ahd), scbid);
1382
1382
                        continue;
1383
1383
                }
1682
1682
                scb_index = ahd_le16toh(completion->tag);
1683
1683
                scb = ahd_lookup_scb(ahd, scb_index);
1684
1684
                if (scb == NULL) {
1685
 
                        printf("%s: WARNING no command for scb %d "
 
1685
                        printk("%s: WARNING no command for scb %d "
1686
1686
                               "(cmdcmplt)\nQOUTPOS = %d\n",
1687
1687
                               ahd_name(ahd), scb_index,
1688
1688
                               ahd->qoutfifonext);
1714
1714
        error = ahd_inb(ahd, ERROR);
1715
1715
        for (i = 0; i < num_errors; i++) {
1716
1716
                if ((error & ahd_hard_errors[i].errno) != 0)
1717
 
                        printf("%s: hwerrint, %s\n",
 
1717
                        printk("%s: hwerrint, %s\n",
1718
1718
                               ahd_name(ahd), ahd_hard_errors[i].errmesg);
1719
1719
        }
1720
1720
 
1747
1747
 
1748
1748
                                addr = ahd_le64toh(sg_list[i].addr);
1749
1749
                                len = ahd_le32toh(sg_list[i].len);
1750
 
                                printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
 
1750
                                printk("sg[%d] - Addr 0x%x%x : Length %d%s\n",
1751
1751
                                       i,
1752
1752
                                       (uint32_t)((addr >> 32) & 0xFFFFFFFF),
1753
1753
                                       (uint32_t)(addr & 0xFFFFFFFF),
1763
1763
                                uint32_t len;
1764
1764
 
1765
1765
                                len = ahd_le32toh(sg_list[i].len);
1766
 
                                printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
 
1766
                                printk("sg[%d] - Addr 0x%x%x : Length %d%s\n",
1767
1767
                                       i,
1768
1768
                                       (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
1769
1769
                                       ahd_le32toh(sg_list[i].addr),
1802
1802
        ahd_update_modes(ahd);
1803
1803
#ifdef AHD_DEBUG
1804
1804
        if ((ahd_debug & AHD_SHOW_MISC) != 0)
1805
 
                printf("%s: Handle Seqint Called for code %d\n",
 
1805
                printk("%s: Handle Seqint Called for code %d\n",
1806
1806
                       ahd_name(ahd), seqintcode);
1807
1807
#endif
1808
1808
        switch (seqintcode) {
1836
1836
                         */
1837
1837
#ifdef AHD_DEBUG
1838
1838
                        if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
1839
 
                                printf("%s: Assuming LQIPHASE_NLQ with "
 
1839
                                printk("%s: Assuming LQIPHASE_NLQ with "
1840
1840
                                       "P0 assertion\n", ahd_name(ahd));
1841
1841
#endif
1842
1842
                }
1843
1843
#ifdef AHD_DEBUG
1844
1844
                if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
1845
 
                        printf("%s: Entering NONPACK\n", ahd_name(ahd));
 
1845
                        printk("%s: Entering NONPACK\n", ahd_name(ahd));
1846
1846
#endif
1847
1847
                break;
1848
1848
        }
1849
1849
        case INVALID_SEQINT:
1850
 
                printf("%s: Invalid Sequencer interrupt occurred, "
 
1850
                printk("%s: Invalid Sequencer interrupt occurred, "
1851
1851
                       "resetting channel.\n",
1852
1852
                       ahd_name(ahd));
1853
1853
#ifdef AHD_DEBUG
1866
1866
                if (scb != NULL)
1867
1867
                        ahd_print_path(ahd, scb);
1868
1868
                else
1869
 
                        printf("%s: ", ahd_name(ahd));
1870
 
                printf("SCB %d Packetized Status Overrun", scbid);
 
1869
                        printk("%s: ", ahd_name(ahd));
 
1870
                printk("SCB %d Packetized Status Overrun", scbid);
1871
1871
                ahd_dump_card_state(ahd);
1872
1872
                ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
1873
1873
                break;
1881
1881
                scb = ahd_lookup_scb(ahd, scbid);
1882
1882
                if (scb == NULL) {
1883
1883
                        ahd_dump_card_state(ahd);
1884
 
                        printf("CFG4ISTAT: Free SCB %d referenced", scbid);
 
1884
                        printk("CFG4ISTAT: Free SCB %d referenced", scbid);
1885
1885
                        panic("For safety");
1886
1886
                }
1887
1887
                ahd_outq(ahd, HADDR, scb->sense_busaddr);
1896
1896
                u_int bus_phase;
1897
1897
 
1898
1898
                bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
1899
 
                printf("%s: ILLEGAL_PHASE 0x%x\n",
 
1899
                printk("%s: ILLEGAL_PHASE 0x%x\n",
1900
1900
                       ahd_name(ahd), bus_phase);
1901
1901
 
1902
1902
                switch (bus_phase) {
1908
1908
                case P_STATUS:
1909
1909
                case P_MESGIN:
1910
1910
                        ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
1911
 
                        printf("%s: Issued Bus Reset.\n", ahd_name(ahd));
 
1911
                        printk("%s: Issued Bus Reset.\n", ahd_name(ahd));
1912
1912
                        break;
1913
1913
                case P_COMMAND:
1914
1914
                {
1933
1933
                        scbid = ahd_get_scbptr(ahd);
1934
1934
                        scb = ahd_lookup_scb(ahd, scbid);
1935
1935
                        if (scb == NULL) {
1936
 
                                printf("Invalid phase with no valid SCB.  "
 
1936
                                printk("Invalid phase with no valid SCB.  "
1937
1937
                                       "Resetting bus.\n");
1938
1938
                                ahd_reset_channel(ahd, 'A',
1939
1939
                                                  /*Initiate Reset*/TRUE);
1997
1997
#ifdef AHD_DEBUG
1998
1998
                        if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
1999
1999
                                ahd_print_path(ahd, scb);
2000
 
                                printf("Unexpected command phase from "
 
2000
                                printk("Unexpected command phase from "
2001
2001
                                       "packetized target\n");
2002
2002
                        }
2003
2003
#endif
2013
2013
                
2014
2014
#ifdef AHD_DEBUG
2015
2015
                if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
2016
 
                        printf("%s: CFG4OVERRUN mode = %x\n", ahd_name(ahd),
 
2016
                        printk("%s: CFG4OVERRUN mode = %x\n", ahd_name(ahd),
2017
2017
                               ahd_inb(ahd, MODE_PTR));
2018
2018
                }
2019
2019
#endif
2049
2049
        {
2050
2050
#ifdef AHD_DEBUG
2051
2051
                if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
2052
 
                        printf("%s: PDATA_REINIT - DFCNTRL = 0x%x "
 
2052
                        printk("%s: PDATA_REINIT - DFCNTRL = 0x%x "
2053
2053
                               "SG_CACHE_SHADOW = 0x%x\n",
2054
2054
                               ahd_name(ahd), ahd_inb(ahd, DFCNTRL),
2055
2055
                               ahd_inb(ahd, SG_CACHE_SHADOW));
2082
2082
                        bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
2083
2083
                        if (bus_phase != P_MESGIN
2084
2084
                         && bus_phase != P_MESGOUT) {
2085
 
                                printf("ahd_intr: HOST_MSG_LOOP bad "
 
2085
                                printk("ahd_intr: HOST_MSG_LOOP bad "
2086
2086
                                       "phase 0x%x\n", bus_phase);
2087
2087
                                /*
2088
2088
                                 * Probably transitioned to bus free before
2131
2131
                AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
2132
2132
                ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
2133
2133
 
2134
 
                printf("%s:%c:%d: no active SCB for reconnecting "
 
2134
                printk("%s:%c:%d: no active SCB for reconnecting "
2135
2135
                       "target - issuing BUS DEVICE RESET\n",
2136
2136
                       ahd_name(ahd), 'A', ahd_inb(ahd, SELID) >> 4);
2137
 
                printf("SAVED_SCSIID == 0x%x, SAVED_LUN == 0x%x, "
 
2137
                printk("SAVED_SCSIID == 0x%x, SAVED_LUN == 0x%x, "
2138
2138
                       "REG0 == 0x%x ACCUM = 0x%x\n",
2139
2139
                       ahd_inb(ahd, SAVED_SCSIID), ahd_inb(ahd, SAVED_LUN),
2140
2140
                       ahd_inw(ahd, REG0), ahd_inb(ahd, ACCUM));
2141
 
                printf("SEQ_FLAGS == 0x%x, SCBPTR == 0x%x, BTT == 0x%x, "
 
2141
                printk("SEQ_FLAGS == 0x%x, SCBPTR == 0x%x, BTT == 0x%x, "
2142
2142
                       "SINDEX == 0x%x\n",
2143
2143
                       ahd_inb(ahd, SEQ_FLAGS), ahd_get_scbptr(ahd),
2144
2144
                       ahd_find_busy_tcl(ahd,
2145
2145
                                         BUILD_TCL(ahd_inb(ahd, SAVED_SCSIID),
2146
2146
                                                   ahd_inb(ahd, SAVED_LUN))),
2147
2147
                       ahd_inw(ahd, SINDEX));
2148
 
                printf("SELID == 0x%x, SCB_SCSIID == 0x%x, SCB_LUN == 0x%x, "
 
2148
                printk("SELID == 0x%x, SCB_SCSIID == 0x%x, SCB_LUN == 0x%x, "
2149
2149
                       "SCB_CONTROL == 0x%x\n",
2150
2150
                       ahd_inb(ahd, SELID), ahd_inb_scbram(ahd, SCB_SCSIID),
2151
2151
                       ahd_inb_scbram(ahd, SCB_LUN),
2152
2152
                       ahd_inb_scbram(ahd, SCB_CONTROL));
2153
 
                printf("SCSIBUS[0] == 0x%x, SCSISIGI == 0x%x\n",
 
2153
                printk("SCSIBUS[0] == 0x%x, SCSISIGI == 0x%x\n",
2154
2154
                       ahd_inb(ahd, SCSIBUS), ahd_inb(ahd, SCSISIGI));
2155
 
                printf("SXFRCTL0 == 0x%x\n", ahd_inb(ahd, SXFRCTL0));
2156
 
                printf("SEQCTL0 == 0x%x\n", ahd_inb(ahd, SEQCTL0));
 
2155
                printk("SXFRCTL0 == 0x%x\n", ahd_inb(ahd, SXFRCTL0));
 
2156
                printk("SEQCTL0 == 0x%x\n", ahd_inb(ahd, SEQCTL0));
2157
2157
                ahd_dump_card_state(ahd);
2158
2158
                ahd->msgout_buf[0] = MSG_BUS_DEV_RESET;
2159
2159
                ahd->msgout_len = 1;
2181
2181
                u_int lastphase;
2182
2182
 
2183
2183
                lastphase = ahd_inb(ahd, LASTPHASE);
2184
 
                printf("%s:%c:%d: unknown scsi bus phase %x, "
 
2184
                printk("%s:%c:%d: unknown scsi bus phase %x, "
2185
2185
                       "lastphase = 0x%x.  Attempting to continue\n",
2186
2186
                       ahd_name(ahd), 'A',
2187
2187
                       SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
2193
2193
                u_int lastphase;
2194
2194
 
2195
2195
                lastphase = ahd_inb(ahd, LASTPHASE);
2196
 
                printf("%s:%c:%d: Missed busfree. "
 
2196
                printk("%s:%c:%d: Missed busfree. "
2197
2197
                       "Lastphase = 0x%x, Curphase = 0x%x\n",
2198
2198
                       ahd_name(ahd), 'A',
2199
2199
                       SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
2223
2223
                lastphase = ahd_inb(ahd, LASTPHASE);
2224
2224
                if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
2225
2225
                        ahd_print_path(ahd, scb);
2226
 
                        printf("data overrun detected %s.  Tag == 0x%x.\n",
 
2226
                        printk("data overrun detected %s.  Tag == 0x%x.\n",
2227
2227
                               ahd_lookup_phase_entry(lastphase)->phasemsg,
2228
2228
                               SCB_GET_TAG(scb));
2229
2229
                        ahd_print_path(ahd, scb);
2230
 
                        printf("%s seen Data Phase.  Length = %ld.  "
 
2230
                        printk("%s seen Data Phase.  Length = %ld.  "
2231
2231
                               "NumSGs = %d.\n",
2232
2232
                               ahd_inb(ahd, SEQ_FLAGS) & DPHASE
2233
2233
                               ? "Have" : "Haven't",
2252
2252
                u_int scbid;
2253
2253
 
2254
2254
                ahd_fetch_devinfo(ahd, &devinfo);
2255
 
                printf("%s:%c:%d:%d: Attempt to issue message failed\n",
 
2255
                printk("%s:%c:%d:%d: Attempt to issue message failed\n",
2256
2256
                       ahd_name(ahd), devinfo.channel, devinfo.target,
2257
2257
                       devinfo.lun);
2258
2258
                scbid = ahd_get_scbptr(ahd);
2285
2285
                        cam_status error;
2286
2286
 
2287
2287
                        ahd_print_path(ahd, scb);
2288
 
                        printf("Task Management Func 0x%x Complete\n",
 
2288
                        printk("Task Management Func 0x%x Complete\n",
2289
2289
                               scb->hscb->task_management);
2290
2290
                        lun = CAM_LUN_WILDCARD;
2291
2291
                        tag = SCB_LIST_NULL;
2341
2341
                         * the QINFIFO if it is still there.
2342
2342
                         */
2343
2343
                        ahd_print_path(ahd, scb);
2344
 
                        printf("SCB completes before TMF\n");
 
2344
                        printk("SCB completes before TMF\n");
2345
2345
                        /*
2346
2346
                         * Handle losing the race.  Wait until any
2347
2347
                         * current selection completes.  We will then
2366
2366
        case TRACEPOINT1:
2367
2367
        case TRACEPOINT2:
2368
2368
        case TRACEPOINT3:
2369
 
                printf("%s: Tracepoint %d\n", ahd_name(ahd),
 
2369
                printk("%s: Tracepoint %d\n", ahd_name(ahd),
2370
2370
                       seqintcode - TRACEPOINT0);
2371
2371
                break;
2372
2372
        case NO_SEQINT:
2375
2375
                ahd_handle_hwerrint(ahd);
2376
2376
                break;
2377
2377
        default:
2378
 
                printf("%s: Unexpected SEQINTCODE %d\n", ahd_name(ahd),
 
2378
                printk("%s: Unexpected SEQINTCODE %d\n", ahd_name(ahd),
2379
2379
                       seqintcode);
2380
2380
                break;
2381
2381
        }
2440
2440
                u_int now_lvd;
2441
2441
 
2442
2442
                now_lvd = ahd_inb(ahd, SBLKCTL) & ENAB40;
2443
 
                printf("%s: Transceiver State Has Changed to %s mode\n",
 
2443
                printk("%s: Transceiver State Has Changed to %s mode\n",
2444
2444
                       ahd_name(ahd), now_lvd ? "LVD" : "SE");
2445
2445
                ahd_outb(ahd, CLRSINT0, CLRIOERR);
2446
2446
                /*
2452
2452
                ahd_unpause(ahd);
2453
2453
        } else if ((status0 & OVERRUN) != 0) {
2454
2454
 
2455
 
                printf("%s: SCSI offset overrun detected.  Resetting bus.\n",
 
2455
                printk("%s: SCSI offset overrun detected.  Resetting bus.\n",
2456
2456
                       ahd_name(ahd));
2457
2457
                ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
2458
2458
        } else if ((status & SCSIRSTI) != 0) {
2459
2459
 
2460
 
                printf("%s: Someone reset channel A\n", ahd_name(ahd));
 
2460
                printk("%s: Someone reset channel A\n", ahd_name(ahd));
2461
2461
                ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE);
2462
2462
        } else if ((status & SCSIPERR) != 0) {
2463
2463
 
2467
2467
                ahd_handle_transmission_error(ahd);
2468
2468
        } else if (lqostat0 != 0) {
2469
2469
 
2470
 
                printf("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0);
 
2470
                printk("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0);
2471
2471
                ahd_outb(ahd, CLRLQOINT0, lqostat0);
2472
2472
                if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
2473
2473
                        ahd_outb(ahd, CLRLQOINT1, 0);
2487
2487
                /*
2488
2488
                 * Although the driver does not care about the
2489
2489
                 * 'Selection in Progress' status bit, the busy
2490
 
                 * LED does.  SELINGO is only cleared by a sucessfull
 
2490
                 * LED does.  SELINGO is only cleared by a successfull
2491
2491
                 * selection, so we must manually clear it to insure
2492
2492
                 * the LED turns off just incase no future successful
2493
2493
                 * selections occur (e.g. no devices on the bus).
2497
2497
                scbid = ahd_inw(ahd, WAITING_TID_HEAD);
2498
2498
                scb = ahd_lookup_scb(ahd, scbid);
2499
2499
                if (scb == NULL) {
2500
 
                        printf("%s: ahd_intr - referenced scb not "
 
2500
                        printk("%s: ahd_intr - referenced scb not "
2501
2501
                               "valid during SELTO scb(0x%x)\n",
2502
2502
                               ahd_name(ahd), scbid);
2503
2503
                        ahd_dump_card_state(ahd);
2506
2506
#ifdef AHD_DEBUG
2507
2507
                        if ((ahd_debug & AHD_SHOW_SELTO) != 0) {
2508
2508
                                ahd_print_path(ahd, scb);
2509
 
                                printf("Saw Selection Timeout for SCB 0x%x\n",
 
2509
                                printk("Saw Selection Timeout for SCB 0x%x\n",
2510
2510
                                       scbid);
2511
2511
                        }
2512
2512
#endif
2534
2534
                ahd_iocell_first_selection(ahd);
2535
2535
                ahd_unpause(ahd);
2536
2536
        } else if (status3 != 0) {
2537
 
                printf("%s: SCSI Cell parity error SSTAT3 == 0x%x\n",
 
2537
                printk("%s: SCSI Cell parity error SSTAT3 == 0x%x\n",
2538
2538
                       ahd_name(ahd), status3);
2539
2539
                ahd_outb(ahd, CLRSINT3, status3);
2540
2540
        } else if ((lqistat1 & (LQIPHASE_LQ|LQIPHASE_NLQ)) != 0) {
2587
2587
                        scbid = ahd_get_scbptr(ahd);
2588
2588
                        scb = ahd_lookup_scb(ahd, scbid);
2589
2589
                        if (scb == NULL) {
2590
 
                                printf("%s: Invalid SCB %d in DFF%d "
 
2590
                                printk("%s: Invalid SCB %d in DFF%d "
2591
2591
                                       "during unexpected busfree\n",
2592
2592
                                       ahd_name(ahd), scbid, mode);
2593
2593
                                packetized = 0;
2620
2620
 
2621
2621
#ifdef AHD_DEBUG
2622
2622
                if ((ahd_debug & AHD_SHOW_MISC) != 0)
2623
 
                        printf("Saw Busfree.  Busfreetime = 0x%x.\n",
 
2623
                        printk("Saw Busfree.  Busfreetime = 0x%x.\n",
2624
2624
                               busfreetime);
2625
2625
#endif
2626
2626
                /*
2661
2661
                        ahd_unpause(ahd);
2662
2662
                }
2663
2663
        } else {
2664
 
                printf("%s: Missing case in ahd_handle_scsiint. status = %x\n",
 
2664
                printk("%s: Missing case in ahd_handle_scsiint. status = %x\n",
2665
2665
                       ahd_name(ahd), status);
2666
2666
                ahd_dump_card_state(ahd);
2667
2667
                ahd_clear_intstat(ahd);
2697
2697
                 || (lqistate == 0x29)) {
2698
2698
#ifdef AHD_DEBUG
2699
2699
                        if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
2700
 
                                printf("%s: NLQCRC found via LQISTATE\n",
 
2700
                                printk("%s: NLQCRC found via LQISTATE\n",
2701
2701
                                       ahd_name(ahd));
2702
2702
                        }
2703
2703
#endif
2729
2729
 
2730
2730
        cur_col = 0;
2731
2731
        if (silent == FALSE) {
2732
 
                printf("%s: Transmission error detected\n", ahd_name(ahd));
 
2732
                printk("%s: Transmission error detected\n", ahd_name(ahd));
2733
2733
                ahd_lqistat1_print(lqistat1, &cur_col, 50);
2734
2734
                ahd_lastphase_print(lastphase, &cur_col, 50);
2735
2735
                ahd_scsisigi_print(curphase, &cur_col, 50);
2736
2736
                ahd_perrdiag_print(perrdiag, &cur_col, 50);
2737
 
                printf("\n");
 
2737
                printk("\n");
2738
2738
                ahd_dump_card_state(ahd);
2739
2739
        }
2740
2740
 
2741
2741
        if ((lqistat1 & (LQIOVERI_LQ|LQIOVERI_NLQ)) != 0) {
2742
2742
                if (silent == FALSE) {
2743
 
                        printf("%s: Gross protocol error during incoming "
 
2743
                        printk("%s: Gross protocol error during incoming "
2744
2744
                               "packet.  lqistat1 == 0x%x.  Resetting bus.\n",
2745
2745
                               ahd_name(ahd), lqistat1);
2746
2746
                }
2769
2769
                 * (SPI4R09 10.7.3.3.3)
2770
2770
                 */
2771
2771
                ahd_outb(ahd, LQCTL2, LQIRETRY);
2772
 
                printf("LQIRetry for LQICRCI_LQ to release ACK\n");
 
2772
                printk("LQIRetry for LQICRCI_LQ to release ACK\n");
2773
2773
        } else if ((lqistat1 & LQICRCI_NLQ) != 0) {
2774
2774
                /*
2775
2775
                 * We detected a CRC error in a NON-LQ packet.
2817
2817
                 * Busfree detection is enabled.
2818
2818
                 */
2819
2819
                if (silent == FALSE)
2820
 
                        printf("LQICRC_NLQ\n");
 
2820
                        printk("LQICRC_NLQ\n");
2821
2821
                if (scb == NULL) {
2822
 
                        printf("%s: No SCB valid for LQICRC_NLQ.  "
 
2822
                        printk("%s: No SCB valid for LQICRC_NLQ.  "
2823
2823
                               "Resetting bus\n", ahd_name(ahd));
2824
2824
                        ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
2825
2825
                        return;
2826
2826
                }
2827
2827
        } else if ((lqistat1 & LQIBADLQI) != 0) {
2828
 
                printf("Need to handle BADLQI!\n");
 
2828
                printk("Need to handle BADLQI!\n");
2829
2829
                ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
2830
2830
                return;
2831
2831
        } else if ((perrdiag & (PARITYERR|PREVPHASE)) == PARITYERR) {
2832
2832
                if ((curphase & ~P_DATAIN_DT) != 0) {
2833
2833
                        /* Ack the byte.  So we can continue. */
2834
2834
                        if (silent == FALSE)
2835
 
                                printf("Acking %s to clear perror\n",
 
2835
                                printk("Acking %s to clear perror\n",
2836
2836
                                    ahd_lookup_phase_entry(curphase)->phasemsg);
2837
2837
                        ahd_inb(ahd, SCSIDAT);
2838
2838
                }
2877
2877
        if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0
2878
2878
         && (ahd_inb(ahd, MDFFSTAT) & DLZERO) != 0) {
2879
2879
                if ((lqistat1 & LQIPHASE_LQ) != 0) {
2880
 
                        printf("LQIRETRY for LQIPHASE_LQ\n");
 
2880
                        printk("LQIRETRY for LQIPHASE_LQ\n");
2881
2881
                        ahd_outb(ahd, LQCTL2, LQIRETRY);
2882
2882
                } else if ((lqistat1 & LQIPHASE_NLQ) != 0) {
2883
 
                        printf("LQIRETRY for LQIPHASE_NLQ\n");
 
2883
                        printk("LQIRETRY for LQIPHASE_NLQ\n");
2884
2884
                        ahd_outb(ahd, LQCTL2, LQIRETRY);
2885
2885
                } else
2886
2886
                        panic("ahd_handle_lqiphase_error: No phase errors\n");
2888
2888
                ahd_outb(ahd, CLRINT, CLRSCSIINT);
2889
2889
                ahd_unpause(ahd);
2890
2890
        } else {
2891
 
                printf("Reseting Channel for LQI Phase error\n");
 
2891
                printk("Reseting Channel for LQI Phase error\n");
2892
2892
                ahd_dump_card_state(ahd);
2893
2893
                ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
2894
2894
        }
2976
2976
                if (scb->crc_retry_count < AHD_MAX_LQ_CRC_ERRORS) {
2977
2977
                        if (SCB_IS_SILENT(scb) == FALSE) {
2978
2978
                                ahd_print_path(ahd, scb);
2979
 
                                printf("Probable outgoing LQ CRC error.  "
 
2979
                                printk("Probable outgoing LQ CRC error.  "
2980
2980
                                       "Retrying command\n");
2981
2981
                        }
2982
2982
                        scb->crc_retry_count++;
2998
2998
                ahd_outb(ahd, CLRSINT1, CLRSCSIPERR|CLRBUSFREE);
2999
2999
#ifdef AHD_DEBUG
3000
3000
                if ((ahd_debug & AHD_SHOW_MASKED_ERRORS) != 0)
3001
 
                        printf("%s: Parity on last REQ detected "
 
3001
                        printk("%s: Parity on last REQ detected "
3002
3002
                               "during busfree phase.\n",
3003
3003
                               ahd_name(ahd));
3004
3004
#endif
3012
3012
                scbid = ahd_get_scbptr(ahd);
3013
3013
                scb = ahd_lookup_scb(ahd, scbid);
3014
3014
                ahd_print_path(ahd, scb);
3015
 
                printf("Unexpected PKT busfree condition\n");
 
3015
                printk("Unexpected PKT busfree condition\n");
3016
3016
                ahd_dump_card_state(ahd);
3017
3017
                ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A',
3018
3018
                               SCB_GET_LUN(scb), SCB_GET_TAG(scb),
3021
3021
                /* Return restarting the sequencer. */
3022
3022
                return (1);
3023
3023
        }
3024
 
        printf("%s: Unexpected PKT busfree condition\n", ahd_name(ahd));
 
3024
        printk("%s: Unexpected PKT busfree condition\n", ahd_name(ahd));
3025
3025
        ahd_dump_card_state(ahd);
3026
3026
        /* Restart the sequencer. */
3027
3027
        return (1);
3076
3076
 
3077
3077
                        if (scb == NULL) {
3078
3078
                                ahd_print_devinfo(ahd, &devinfo);
3079
 
                                printf("Abort for unidentified "
 
3079
                                printk("Abort for unidentified "
3080
3080
                                       "connection completed.\n");
3081
3081
                                /* restart the sequencer. */
3082
3082
                                return (1);
3083
3083
                        }
3084
3084
                        sent_msg = ahd->msgout_buf[ahd->msgout_index - 1];
3085
3085
                        ahd_print_path(ahd, scb);
3086
 
                        printf("SCB %d - Abort%s Completed.\n",
 
3086
                        printk("SCB %d - Abort%s Completed.\n",
3087
3087
                               SCB_GET_TAG(scb),
3088
3088
                               sent_msg == MSG_ABORT_TAG ? "" : " Tag");
3089
3089
 
3109
3109
                        found = ahd_abort_scbs(ahd, target, 'A', saved_lun,
3110
3110
                                               tag, ROLE_INITIATOR,
3111
3111
                                               CAM_REQ_ABORTED);
3112
 
                        printf("found == 0x%x\n", found);
 
3112
                        printk("found == 0x%x\n", found);
3113
3113
                        printerror = 0;
3114
3114
                } else if (ahd_sent_msg(ahd, AHDMSG_1B,
3115
3115
                                        MSG_BUS_DEV_RESET, TRUE)) {
3147
3147
                         */
3148
3148
#ifdef AHD_DEBUG
3149
3149
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
3150
 
                                printf("PPR negotiation rejected busfree.\n");
 
3150
                                printk("PPR negotiation rejected busfree.\n");
3151
3151
#endif
3152
3152
                        tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
3153
3153
                                                    devinfo.our_scsiid,
3171
3171
                                tinfo->curr.transport_version = 2;
3172
3172
                                tinfo->goal.transport_version = 2;
3173
3173
                                tinfo->goal.ppr_options = 0;
3174
 
                                /*
3175
 
                                 * Remove any SCBs in the waiting for selection
3176
 
                                 * queue that may also be for this target so
3177
 
                                 * that command ordering is preserved.
3178
 
                                 */
3179
 
                                ahd_freeze_devq(ahd, scb);
3180
 
                                ahd_qinfifo_requeue_tail(ahd, scb);
 
3174
                                if (scb != NULL) {
 
3175
                                        /*
 
3176
                                         * Remove any SCBs in the waiting
 
3177
                                         * for selection queue that may
 
3178
                                         * also be for this target so that
 
3179
                                         * command ordering is preserved.
 
3180
                                         */
 
3181
                                        ahd_freeze_devq(ahd, scb);
 
3182
                                        ahd_qinfifo_requeue_tail(ahd, scb);
 
3183
                                }
3181
3184
                                printerror = 0;
3182
3185
                        }
3183
3186
                } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, FALSE)
3188
3191
                         */
3189
3192
#ifdef AHD_DEBUG
3190
3193
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
3191
 
                                printf("WDTR negotiation rejected busfree.\n");
 
3194
                                printk("WDTR negotiation rejected busfree.\n");
3192
3195
#endif
3193
3196
                        ahd_set_width(ahd, &devinfo,
3194
3197
                                      MSG_EXT_WDTR_BUS_8_BIT,
3195
3198
                                      AHD_TRANS_CUR|AHD_TRANS_GOAL,
3196
3199
                                      /*paused*/TRUE);
3197
 
                        /*
3198
 
                         * Remove any SCBs in the waiting for selection
3199
 
                         * queue that may also be for this target so that
3200
 
                         * command ordering is preserved.
3201
 
                         */
3202
 
                        ahd_freeze_devq(ahd, scb);
3203
 
                        ahd_qinfifo_requeue_tail(ahd, scb);
 
3200
                        if (scb != NULL) {
 
3201
                                /*
 
3202
                                 * Remove any SCBs in the waiting for
 
3203
                                 * selection queue that may also be for
 
3204
                                 * this target so that command ordering
 
3205
                                 * is preserved.
 
3206
                                 */
 
3207
                                ahd_freeze_devq(ahd, scb);
 
3208
                                ahd_qinfifo_requeue_tail(ahd, scb);
 
3209
                        }
3204
3210
                        printerror = 0;
3205
3211
                } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, FALSE)
3206
3212
                        && ppr_busfree == 0) {
3210
3216
                         */
3211
3217
#ifdef AHD_DEBUG
3212
3218
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
3213
 
                                printf("SDTR negotiation rejected busfree.\n");
 
3219
                                printk("SDTR negotiation rejected busfree.\n");
3214
3220
#endif
3215
3221
                        ahd_set_syncrate(ahd, &devinfo,
3216
3222
                                        /*period*/0, /*offset*/0,
3217
3223
                                        /*ppr_options*/0,
3218
3224
                                        AHD_TRANS_CUR|AHD_TRANS_GOAL,
3219
3225
                                        /*paused*/TRUE);
3220
 
                        /*
3221
 
                         * Remove any SCBs in the waiting for selection
3222
 
                         * queue that may also be for this target so that
3223
 
                         * command ordering is preserved.
3224
 
                         */
3225
 
                        ahd_freeze_devq(ahd, scb);
3226
 
                        ahd_qinfifo_requeue_tail(ahd, scb);
 
3226
                        if (scb != NULL) {
 
3227
                                /*
 
3228
                                 * Remove any SCBs in the waiting for
 
3229
                                 * selection queue that may also be for
 
3230
                                 * this target so that command ordering
 
3231
                                 * is preserved.
 
3232
                                 */
 
3233
                                ahd_freeze_devq(ahd, scb);
 
3234
                                ahd_qinfifo_requeue_tail(ahd, scb);
 
3235
                        }
3227
3236
                        printerror = 0;
3228
3237
                } else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0
3229
3238
                        && ahd_sent_msg(ahd, AHDMSG_1B,
3231
3240
 
3232
3241
#ifdef AHD_DEBUG
3233
3242
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
3234
 
                                printf("Expected IDE Busfree\n");
 
3243
                                printk("Expected IDE Busfree\n");
3235
3244
#endif
3236
3245
                        printerror = 0;
3237
3246
                } else if ((ahd->msg_flags & MSG_FLAG_EXPECT_QASREJ_BUSFREE)
3240
3249
 
3241
3250
#ifdef AHD_DEBUG
3242
3251
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
3243
 
                                printf("Expected QAS Reject Busfree\n");
 
3252
                                printk("Expected QAS Reject Busfree\n");
3244
3253
#endif
3245
3254
                        printerror = 0;
3246
3255
                }
3251
3260
         * the message phases.  We check it last in case we
3252
3261
         * had to send some other message that caused a busfree.
3253
3262
         */
3254
 
        if (printerror != 0
 
3263
        if (scb != NULL && printerror != 0
3255
3264
         && (lastphase == P_MESGIN || lastphase == P_MESGOUT)
3256
3265
         && ((ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0)) {
3257
3266
 
3266
3275
                } else {
3267
3276
#ifdef AHD_DEBUG
3268
3277
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
3269
 
                                printf("PPR Negotiation Busfree.\n");
 
3278
                                printk("PPR Negotiation Busfree.\n");
3270
3279
#endif
3271
3280
                        ahd_done(ahd, scb);
3272
3281
                }
3293
3302
                         * We had not fully identified this connection,
3294
3303
                         * so we cannot abort anything.
3295
3304
                         */
3296
 
                        printf("%s: ", ahd_name(ahd));
 
3305
                        printk("%s: ", ahd_name(ahd));
3297
3306
                }
3298
 
                printf("Unexpected busfree %s, %d SCBs aborted, "
 
3307
                printk("Unexpected busfree %s, %d SCBs aborted, "
3299
3308
                       "PRGMCNT == 0x%x\n",
3300
3309
                       ahd_lookup_phase_entry(lastphase)->phasemsg,
3301
3310
                       aborted,
3333
3342
                 * to match.
3334
3343
                 */
3335
3344
                ahd_print_devinfo(ahd, &devinfo);
3336
 
                printf("Target did not send an IDENTIFY message. "
 
3345
                printk("Target did not send an IDENTIFY message. "
3337
3346
                       "LASTPHASE = 0x%x.\n", lastphase);
3338
3347
                scb = NULL;
3339
3348
        } else if (scb == NULL) {
3342
3351
                 * transaction.  Print an error and reset the bus.
3343
3352
                 */
3344
3353
                ahd_print_devinfo(ahd, &devinfo);
3345
 
                printf("No SCB found during protocol violation\n");
 
3354
                printk("No SCB found during protocol violation\n");
3346
3355
                goto proto_violation_reset;
3347
3356
        } else {
3348
3357
                ahd_set_transaction_status(scb, CAM_SEQUENCE_FAIL);
3349
3358
                if ((seq_flags & NO_CDB_SENT) != 0) {
3350
3359
                        ahd_print_path(ahd, scb);
3351
 
                        printf("No or incomplete CDB sent to device.\n");
 
3360
                        printk("No or incomplete CDB sent to device.\n");
3352
3361
                } else if ((ahd_inb_scbram(ahd, SCB_CONTROL)
3353
3362
                          & STATUS_RCVD) == 0) {
3354
3363
                        /*
3359
3368
                         * message.
3360
3369
                         */
3361
3370
                        ahd_print_path(ahd, scb);
3362
 
                        printf("Completed command without status.\n");
 
3371
                        printk("Completed command without status.\n");
3363
3372
                } else {
3364
3373
                        ahd_print_path(ahd, scb);
3365
 
                        printf("Unknown protocol violation.\n");
 
3374
                        printk("Unknown protocol violation.\n");
3366
3375
                        ahd_dump_card_state(ahd);
3367
3376
                }
3368
3377
        }
3376
3385
                 * it away with a bus reset.
3377
3386
                 */
3378
3387
                found = ahd_reset_channel(ahd, 'A', TRUE);
3379
 
                printf("%s: Issued Channel %c Bus Reset. "
 
3388
                printk("%s: Issued Channel %c Bus Reset. "
3380
3389
                       "%d SCBs aborted\n", ahd_name(ahd), 'A', found);
3381
3390
        } else {
3382
3391
                /*
3398
3407
                        ahd_print_path(ahd, scb);
3399
3408
                        scb->flags |= SCB_ABORT;
3400
3409
                }
3401
 
                printf("Protocol violation %s.  Attempting to abort.\n",
 
3410
                printk("Protocol violation %s.  Attempting to abort.\n",
3402
3411
                       ahd_lookup_phase_entry(curphase)->phasemsg);
3403
3412
        }
3404
3413
}
3416
3425
#ifdef AHD_DEBUG
3417
3426
        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
3418
3427
                ahd_print_devinfo(ahd, devinfo);
3419
 
                printf("Forcing renegotiation\n");
 
3428
                printk("Forcing renegotiation\n");
3420
3429
        }
3421
3430
#endif
3422
3431
        targ_info = ahd_fetch_transinfo(ahd,
3477
3486
                        break;
3478
3487
 
3479
3488
                if (steps > AHD_MAX_STEPS) {
3480
 
                        printf("%s: Infinite loop in critical section\n"
 
3489
                        printk("%s: Infinite loop in critical section\n"
3481
3490
                               "%s: First Instruction 0x%x now 0x%x\n",
3482
3491
                               ahd_name(ahd), ahd_name(ahd), first_instr,
3483
3492
                               seqaddr);
3488
3497
                steps++;
3489
3498
#ifdef AHD_DEBUG
3490
3499
                if ((ahd_debug & AHD_SHOW_MISC) != 0)
3491
 
                        printf("%s: Single stepping at 0x%x\n", ahd_name(ahd),
 
3500
                        printk("%s: Single stepping at 0x%x\n", ahd_name(ahd),
3492
3501
                               seqaddr);
3493
3502
#endif
3494
3503
                if (stepping == FALSE) {
3592
3601
        int i;
3593
3602
 
3594
3603
        hscb = scb->hscb;
3595
 
        printf("scb:%p control:0x%x scsiid:0x%x lun:%d cdb_len:%d\n",
 
3604
        printk("scb:%p control:0x%x scsiid:0x%x lun:%d cdb_len:%d\n",
3596
3605
               (void *)scb,
3597
3606
               hscb->control,
3598
3607
               hscb->scsiid,
3599
3608
               hscb->lun,
3600
3609
               hscb->cdb_len);
3601
 
        printf("Shared Data: ");
 
3610
        printk("Shared Data: ");
3602
3611
        for (i = 0; i < sizeof(hscb->shared_data.idata.cdb); i++)
3603
 
                printf("%#02x", hscb->shared_data.idata.cdb[i]);
3604
 
        printf("        dataptr:%#x%x datacnt:%#x sgptr:%#x tag:%#x\n",
 
3612
                printk("%#02x", hscb->shared_data.idata.cdb[i]);
 
3613
        printk("        dataptr:%#x%x datacnt:%#x sgptr:%#x tag:%#x\n",
3605
3614
               (uint32_t)((ahd_le64toh(hscb->dataptr) >> 32) & 0xFFFFFFFF),
3606
3615
               (uint32_t)(ahd_le64toh(hscb->dataptr) & 0xFFFFFFFF),
3607
3616
               ahd_le32toh(hscb->datacnt),
3628
3637
         && ahd->enabled_targets[scsi_id] != master_tstate)
3629
3638
                panic("%s: ahd_alloc_tstate - Target already allocated",
3630
3639
                      ahd_name(ahd));
3631
 
        tstate = malloc(sizeof(*tstate), M_DEVBUF, M_NOWAIT);
 
3640
        tstate = kmalloc(sizeof(*tstate), GFP_ATOMIC);
3632
3641
        if (tstate == NULL)
3633
3642
                return (NULL);
3634
3643
 
3673
3682
 
3674
3683
        tstate = ahd->enabled_targets[scsi_id];
3675
3684
        if (tstate != NULL)
3676
 
                free(tstate, M_DEVBUF);
 
3685
                kfree(tstate);
3677
3686
        ahd->enabled_targets[scsi_id] = NULL;
3678
3687
}
3679
3688
#endif
3933
3942
                        if (offset != 0) {
3934
3943
                                int options;
3935
3944
 
3936
 
                                printf("%s: target %d synchronous with "
 
3945
                                printk("%s: target %d synchronous with "
3937
3946
                                       "period = 0x%x, offset = 0x%x",
3938
3947
                                       ahd_name(ahd), devinfo->target,
3939
3948
                                       period, offset);
3940
3949
                                options = 0;
3941
3950
                                if ((ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
3942
 
                                        printf("(RDSTRM");
 
3951
                                        printk("(RDSTRM");
3943
3952
                                        options++;
3944
3953
                                }
3945
3954
                                if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
3946
 
                                        printf("%s", options ? "|DT" : "(DT");
 
3955
                                        printk("%s", options ? "|DT" : "(DT");
3947
3956
                                        options++;
3948
3957
                                }
3949
3958
                                if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
3950
 
                                        printf("%s", options ? "|IU" : "(IU");
 
3959
                                        printk("%s", options ? "|IU" : "(IU");
3951
3960
                                        options++;
3952
3961
                                }
3953
3962
                                if ((ppr_options & MSG_EXT_PPR_RTI) != 0) {
3954
 
                                        printf("%s", options ? "|RTI" : "(RTI");
 
3963
                                        printk("%s", options ? "|RTI" : "(RTI");
3955
3964
                                        options++;
3956
3965
                                }
3957
3966
                                if ((ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
3958
 
                                        printf("%s", options ? "|QAS" : "(QAS");
 
3967
                                        printk("%s", options ? "|QAS" : "(QAS");
3959
3968
                                        options++;
3960
3969
                                }
3961
3970
                                if (options != 0)
3962
 
                                        printf(")\n");
 
3971
                                        printk(")\n");
3963
3972
                                else
3964
 
                                        printf("\n");
 
3973
                                        printk("\n");
3965
3974
                        } else {
3966
 
                                printf("%s: target %d using "
 
3975
                                printk("%s: target %d using "
3967
3976
                                       "asynchronous transfers%s\n",
3968
3977
                                       ahd_name(ahd), devinfo->target,
3969
3978
                                       (ppr_options & MSG_EXT_PPR_QAS_REQ) != 0
3991
4000
#ifdef AHD_DEBUG
3992
4001
                                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
3993
4002
                                        ahd_print_devinfo(ahd, devinfo);
3994
 
                                        printf("Expecting IU Change busfree\n");
 
4003
                                        printk("Expecting IU Change busfree\n");
3995
4004
                                }
3996
4005
#endif
3997
4006
                                ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
4000
4009
                        if ((old_ppr & MSG_EXT_PPR_IU_REQ) != 0) {
4001
4010
#ifdef AHD_DEBUG
4002
4011
                                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
4003
 
                                        printf("PPR with IU_REQ outstanding\n");
 
4012
                                        printk("PPR with IU_REQ outstanding\n");
4004
4013
#endif
4005
4014
                                ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE;
4006
4015
                        }
4052
4061
                ahd_send_async(ahd, devinfo->channel, devinfo->target,
4053
4062
                               CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
4054
4063
                if (bootverbose) {
4055
 
                        printf("%s: target %d using %dbit transfers\n",
 
4064
                        printk("%s: target %d using %dbit transfers\n",
4056
4065
                               ahd_name(ahd), devinfo->target,
4057
4066
                               8 * (0x01 << width));
4058
4067
                }
4328
4337
void
4329
4338
ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
4330
4339
{
4331
 
        printf("%s:%c:%d:%d: ", ahd_name(ahd), 'A',
 
4340
        printk("%s:%c:%d:%d: ", ahd_name(ahd), 'A',
4332
4341
               devinfo->target, devinfo->lun);
4333
4342
}
4334
4343
 
4410
4419
                ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
4411
4420
#ifdef AHD_DEBUG
4412
4421
                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
4413
 
                        printf("Setting up for Parity Error delivery\n");
 
4422
                        printk("Setting up for Parity Error delivery\n");
4414
4423
#endif
4415
4424
                return;
4416
4425
        } else if (scb == NULL) {
4417
 
                printf("%s: WARNING. No pending message for "
 
4426
                printk("%s: WARNING. No pending message for "
4418
4427
                       "I_T msgin.  Issuing NO-OP\n", ahd_name(ahd));
4419
4428
                ahd->msgout_buf[ahd->msgout_index++] = MSG_NOOP;
4420
4429
                ahd->msgout_len++;
4445
4454
                ahd->msgout_buf[ahd->msgout_index++] = MSG_BUS_DEV_RESET;
4446
4455
                ahd->msgout_len++;
4447
4456
                ahd_print_path(ahd, scb);
4448
 
                printf("Bus Device Reset Message Sent\n");
 
4457
                printk("Bus Device Reset Message Sent\n");
4449
4458
                /*
4450
4459
                 * Clear our selection hardware in advance of
4451
4460
                 * the busfree.  We may have an entry in the waiting
4463
4472
                }
4464
4473
                ahd->msgout_len++;
4465
4474
                ahd_print_path(ahd, scb);
4466
 
                printf("Abort%s Message Sent\n",
 
4475
                printk("Abort%s Message Sent\n",
4467
4476
                       (scb->hscb->control & TAG_ENB) != 0 ? " Tag" : "");
4468
4477
                /*
4469
4478
                 * Clear our selection hardware in advance of
4484
4493
                 */
4485
4494
                ahd_outb(ahd, SCSISEQ0, 0);
4486
4495
        } else {
4487
 
                printf("ahd_intr: AWAITING_MSG for an SCB that "
 
4496
                printk("ahd_intr: AWAITING_MSG for an SCB that "
4488
4497
                       "does not have a waiting message\n");
4489
 
                printf("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid,
 
4498
                printk("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid,
4490
4499
                       devinfo->target_mask);
4491
4500
                panic("SCB = %d, SCB Control = %x:%x, MSG_OUT = %x "
4492
4501
                      "SCB flags = %x", SCB_GET_TAG(scb), scb->hscb->control,
4568
4577
 
4569
4578
                if (bootverbose) {
4570
4579
                        ahd_print_devinfo(ahd, devinfo);
4571
 
                        printf("Ensuring async\n");
 
4580
                        printk("Ensuring async\n");
4572
4581
                }
4573
4582
        }
4574
4583
        /* Target initiated PPR is not allowed in the SCSI spec */
4615
4624
                        ahd->msgout_buf + ahd->msgout_index, period, offset);
4616
4625
        ahd->msgout_len += 5;
4617
4626
        if (bootverbose) {
4618
 
                printf("(%s:%c:%d:%d): Sending SDTR period %x, offset %x\n",
 
4627
                printk("(%s:%c:%d:%d): Sending SDTR period %x, offset %x\n",
4619
4628
                       ahd_name(ahd), devinfo->channel, devinfo->target,
4620
4629
                       devinfo->lun, period, offset);
4621
4630
        }
4633
4642
                        ahd->msgout_buf + ahd->msgout_index, bus_width);
4634
4643
        ahd->msgout_len += 4;
4635
4644
        if (bootverbose) {
4636
 
                printf("(%s:%c:%d:%d): Sending WDTR %x\n",
 
4645
                printk("(%s:%c:%d:%d): Sending WDTR %x\n",
4637
4646
                       ahd_name(ahd), devinfo->channel, devinfo->target,
4638
4647
                       devinfo->lun, bus_width);
4639
4648
        }
4662
4671
                        bus_width, ppr_options);
4663
4672
        ahd->msgout_len += 8;
4664
4673
        if (bootverbose) {
4665
 
                printf("(%s:%c:%d:%d): Sending PPR bus_width %x, period %x, "
 
4674
                printk("(%s:%c:%d:%d): Sending PPR bus_width %x, period %x, "
4666
4675
                       "offset %x, ppr_options %x\n", ahd_name(ahd),
4667
4676
                       devinfo->channel, devinfo->target, devinfo->lun,
4668
4677
                       bus_width, period, offset, ppr_options);
4712
4721
        bus_phase = ahd_inb(ahd, LASTPHASE);
4713
4722
 
4714
4723
        if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0) {
4715
 
                printf("LQIRETRY for LQIPHASE_OUTPKT\n");
 
4724
                printk("LQIRETRY for LQIPHASE_OUTPKT\n");
4716
4725
                ahd_outb(ahd, LQCTL2, LQIRETRY);
4717
4726
        }
4718
4727
reswitch:
4729
4738
#ifdef AHD_DEBUG
4730
4739
                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
4731
4740
                        ahd_print_devinfo(ahd, &devinfo);
4732
 
                        printf("INITIATOR_MSG_OUT");
 
4741
                        printk("INITIATOR_MSG_OUT");
4733
4742
                }
4734
4743
#endif
4735
4744
                phasemis = bus_phase != P_MESGOUT;
4736
4745
                if (phasemis) {
4737
4746
#ifdef AHD_DEBUG
4738
4747
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
4739
 
                                printf(" PHASEMIS %s\n",
 
4748
                                printk(" PHASEMIS %s\n",
4740
4749
                                       ahd_lookup_phase_entry(bus_phase)
4741
4750
                                                             ->phasemsg);
4742
4751
                        }
4763
4772
                        ahd_outb(ahd, CLRSINT1, CLRREQINIT);
4764
4773
#ifdef AHD_DEBUG
4765
4774
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
4766
 
                                printf(" byte 0x%x\n", ahd->send_msg_perror);
 
4775
                                printk(" byte 0x%x\n", ahd->send_msg_perror);
4767
4776
#endif
4768
4777
                        /*
4769
4778
                         * If we are notifying the target of a CRC error
4804
4813
                ahd_outb(ahd, CLRSINT1, CLRREQINIT);
4805
4814
#ifdef AHD_DEBUG
4806
4815
                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
4807
 
                        printf(" byte 0x%x\n",
 
4816
                        printk(" byte 0x%x\n",
4808
4817
                               ahd->msgout_buf[ahd->msgout_index]);
4809
4818
#endif
4810
4819
                ahd_outb(ahd, RETURN_2, ahd->msgout_buf[ahd->msgout_index++]);
4819
4828
#ifdef AHD_DEBUG
4820
4829
                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
4821
4830
                        ahd_print_devinfo(ahd, &devinfo);
4822
 
                        printf("INITIATOR_MSG_IN");
 
4831
                        printk("INITIATOR_MSG_IN");
4823
4832
                }
4824
4833
#endif
4825
4834
                phasemis = bus_phase != P_MESGIN;
4826
4835
                if (phasemis) {
4827
4836
#ifdef AHD_DEBUG
4828
4837
                        if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
4829
 
                                printf(" PHASEMIS %s\n",
 
4838
                                printk(" PHASEMIS %s\n",
4830
4839
                                       ahd_lookup_phase_entry(bus_phase)
4831
4840
                                                             ->phasemsg);
4832
4841
                        }
4847
4856
                ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIBUS);
4848
4857
#ifdef AHD_DEBUG
4849
4858
                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
4850
 
                        printf(" byte 0x%x\n",
 
4859
                        printk(" byte 0x%x\n",
4851
4860
                               ahd->msgin_buf[ahd->msgin_index]);
4852
4861
#endif
4853
4862
 
4869
4878
#ifdef AHD_DEBUG
4870
4879
                                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
4871
4880
                                        ahd_print_devinfo(ahd, &devinfo);
4872
 
                                        printf("Asserting ATN for response\n");
 
4881
                                        printk("Asserting ATN for response\n");
4873
4882
                                }
4874
4883
#endif
4875
4884
                                ahd_assert_atn(ahd);
5017
5026
 
5018
5027
        if (end_session) {
5019
5028
                if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0) {
5020
 
                        printf("%s: Returning to Idle Loop\n",
 
5029
                        printk("%s: Returning to Idle Loop\n",
5021
5030
                               ahd_name(ahd));
5022
5031
                        ahd_clear_msg_state(ahd);
5023
5032
 
5169
5178
                        ahd_validate_offset(ahd, tinfo, period, &offset,
5170
5179
                                            tinfo->curr.width, devinfo->role);
5171
5180
                        if (bootverbose) {
5172
 
                                printf("(%s:%c:%d:%d): Received "
 
5181
                                printk("(%s:%c:%d:%d): Received "
5173
5182
                                       "SDTR period %x, offset %x\n\t"
5174
5183
                                       "Filtered to period %x, offset %x\n",
5175
5184
                                       ahd_name(ahd), devinfo->channel,
5199
5208
                                 */
5200
5209
                                if (bootverbose
5201
5210
                                 && devinfo->role == ROLE_INITIATOR) {
5202
 
                                        printf("(%s:%c:%d:%d): Target "
 
5211
                                        printk("(%s:%c:%d:%d): Target "
5203
5212
                                               "Initiated SDTR\n",
5204
5213
                                               ahd_name(ahd), devinfo->channel,
5205
5214
                                               devinfo->target, devinfo->lun);
5241
5250
                        ahd_validate_width(ahd, tinfo, &bus_width,
5242
5251
                                           devinfo->role);
5243
5252
                        if (bootverbose) {
5244
 
                                printf("(%s:%c:%d:%d): Received WDTR "
 
5253
                                printk("(%s:%c:%d:%d): Received WDTR "
5245
5254
                                       "%x filtered to %x\n",
5246
5255
                                       ahd_name(ahd), devinfo->channel,
5247
5256
                                       devinfo->target, devinfo->lun,
5257
5266
                                 */
5258
5267
                                if (saved_width > bus_width) {
5259
5268
                                        reject = TRUE;
5260
 
                                        printf("(%s:%c:%d:%d): requested %dBit "
 
5269
                                        printk("(%s:%c:%d:%d): requested %dBit "
5261
5270
                                               "transfers.  Rejecting...\n",
5262
5271
                                               ahd_name(ahd), devinfo->channel,
5263
5272
                                               devinfo->target, devinfo->lun,
5270
5279
                                 */
5271
5280
                                if (bootverbose
5272
5281
                                 && devinfo->role == ROLE_INITIATOR) {
5273
 
                                        printf("(%s:%c:%d:%d): Target "
 
5282
                                        printk("(%s:%c:%d:%d): Target "
5274
5283
                                               "Initiated WDTR\n",
5275
5284
                                               ahd_name(ahd), devinfo->channel,
5276
5285
                                               devinfo->target, devinfo->lun);
5382
5391
                                }
5383
5392
                        } else {
5384
5393
                                if (devinfo->role != ROLE_TARGET)
5385
 
                                        printf("(%s:%c:%d:%d): Target "
 
5394
                                        printk("(%s:%c:%d:%d): Target "
5386
5395
                                               "Initiated PPR\n",
5387
5396
                                               ahd_name(ahd), devinfo->channel,
5388
5397
                                               devinfo->target, devinfo->lun);
5389
5398
                                else
5390
 
                                        printf("(%s:%c:%d:%d): Initiator "
 
5399
                                        printk("(%s:%c:%d:%d): Initiator "
5391
5400
                                               "Initiated PPR\n",
5392
5401
                                               ahd_name(ahd), devinfo->channel,
5393
5402
                                               devinfo->target, devinfo->lun);
5399
5408
                                response = TRUE;
5400
5409
                        }
5401
5410
                        if (bootverbose) {
5402
 
                                printf("(%s:%c:%d:%d): Received PPR width %x, "
 
5411
                                printk("(%s:%c:%d:%d): Received PPR width %x, "
5403
5412
                                       "period %x, offset %x,options %x\n"
5404
5413
                                       "\tFiltered to width %x, period %x, "
5405
5414
                                       "offset %x, options %x\n",
5475
5484
        case MSG_QAS_REQUEST:
5476
5485
#ifdef AHD_DEBUG
5477
5486
                if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
5478
 
                        printf("%s: QAS request.  SCSISIGI == 0x%x\n",
 
5487
                        printk("%s: QAS request.  SCSISIGI == 0x%x\n",
5479
5488
                               ahd_name(ahd), ahd_inb(ahd, SCSISIGI));
5480
5489
#endif
5481
5490
                ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE;
5540
5549
                         * off these options.
5541
5550
                         */
5542
5551
                        if (bootverbose) {
5543
 
                                printf("(%s:%c:%d:%d): PPR Rejected. "
 
5552
                                printk("(%s:%c:%d:%d): PPR Rejected. "
5544
5553
                                       "Trying simple U160 PPR\n",
5545
5554
                                       ahd_name(ahd), devinfo->channel,
5546
5555
                                       devinfo->target, devinfo->lun);
5555
5564
                         * Attempt to negotiate SPI-2 style.
5556
5565
                         */
5557
5566
                        if (bootverbose) {
5558
 
                                printf("(%s:%c:%d:%d): PPR Rejected. "
 
5567
                                printk("(%s:%c:%d:%d): PPR Rejected. "
5559
5568
                                       "Trying WDTR/SDTR\n",
5560
5569
                                       ahd_name(ahd), devinfo->channel,
5561
5570
                                       devinfo->target, devinfo->lun);
5572
5581
        } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, /*full*/FALSE)) {
5573
5582
 
5574
5583
                /* note 8bit xfers */
5575
 
                printf("(%s:%c:%d:%d): refuses WIDE negotiation.  Using "
 
5584
                printk("(%s:%c:%d:%d): refuses WIDE negotiation.  Using "
5576
5585
                       "8bit transfers\n", ahd_name(ahd),
5577
5586
                       devinfo->channel, devinfo->target, devinfo->lun);
5578
5587
                ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
5600
5609
                                 /*offset*/0, /*ppr_options*/0,
5601
5610
                                 AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
5602
5611
                                 /*paused*/TRUE);
5603
 
                printf("(%s:%c:%d:%d): refuses synchronous negotiation. "
 
5612
                printk("(%s:%c:%d:%d): refuses synchronous negotiation. "
5604
5613
                       "Using asynchronous transfers\n",
5605
5614
                       ahd_name(ahd), devinfo->channel,
5606
5615
                       devinfo->target, devinfo->lun);
5611
5620
                tag_type = (scb->hscb->control & MSG_SIMPLE_TASK);
5612
5621
 
5613
5622
                if (tag_type == MSG_SIMPLE_TASK) {
5614
 
                        printf("(%s:%c:%d:%d): refuses tagged commands.  "
 
5623
                        printk("(%s:%c:%d:%d): refuses tagged commands.  "
5615
5624
                               "Performing non-tagged I/O\n", ahd_name(ahd),
5616
5625
                               devinfo->channel, devinfo->target, devinfo->lun);
5617
5626
                        ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_NONE);
5618
5627
                        mask = ~0x23;
5619
5628
                } else {
5620
 
                        printf("(%s:%c:%d:%d): refuses %s tagged commands.  "
 
5629
                        printk("(%s:%c:%d:%d): refuses %s tagged commands.  "
5621
5630
                               "Performing simple queue tagged I/O only\n",
5622
5631
                               ahd_name(ahd), devinfo->channel, devinfo->target,
5623
5632
                               devinfo->lun, tag_type == MSG_ORDERED_TASK
5668
5677
                /*
5669
5678
                 * Otherwise, we ignore it.
5670
5679
                 */
5671
 
                printf("%s:%c:%d: Message reject for %x -- ignored\n",
 
5680
                printk("%s:%c:%d: Message reject for %x -- ignored\n",
5672
5681
                       ahd_name(ahd), devinfo->channel, devinfo->target,
5673
5682
                       last_msg);
5674
5683
        }
5855
5864
                ahd_delay(100);
5856
5865
        if (wait == 0) {
5857
5866
                ahd_print_path(ahd, scb);
5858
 
                printf("ahd_reinitialize_dataptrs: Forcing FIFO free.\n");
 
5867
                printk("ahd_reinitialize_dataptrs: Forcing FIFO free.\n");
5859
5868
                ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
5860
5869
        }
5861
5870
        saved_modes = ahd_save_modes(ahd);
5969
5978
                               CAM_LUN_WILDCARD, AC_SENT_BDR);
5970
5979
 
5971
5980
        if (message != NULL && bootverbose)
5972
 
                printf("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd),
 
5981
                printk("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd),
5973
5982
                       message, devinfo->channel, devinfo->target, found);
5974
5983
}
5975
5984
 
6065
6074
        struct  ahd_softc *ahd;
6066
6075
 
6067
6076
#ifndef __FreeBSD__
6068
 
        ahd = malloc(sizeof(*ahd), M_DEVBUF, M_NOWAIT);
 
6077
        ahd = kmalloc(sizeof(*ahd), GFP_ATOMIC);
6069
6078
        if (!ahd) {
6070
 
                printf("aic7xxx: cannot malloc softc!\n");
6071
 
                free(name, M_DEVBUF);
 
6079
                printk("aic7xxx: cannot malloc softc!\n");
 
6080
                kfree(name);
6072
6081
                return NULL;
6073
6082
        }
6074
6083
#else
6075
6084
        ahd = device_get_softc((device_t)platform_arg);
6076
6085
#endif
6077
6086
        memset(ahd, 0, sizeof(*ahd));
6078
 
        ahd->seep_config = malloc(sizeof(*ahd->seep_config),
6079
 
                                  M_DEVBUF, M_NOWAIT);
 
6087
        ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC);
6080
6088
        if (ahd->seep_config == NULL) {
6081
6089
#ifndef __FreeBSD__
6082
 
                free(ahd, M_DEVBUF);
 
6090
                kfree(ahd);
6083
6091
#endif
6084
 
                free(name, M_DEVBUF);
 
6092
                kfree(name);
6085
6093
                return (NULL);
6086
6094
        }
6087
6095
        LIST_INIT(&ahd->pending_scbs);
6111
6119
        }
6112
6120
#ifdef AHD_DEBUG
6113
6121
        if ((ahd_debug & AHD_SHOW_MEMORY) != 0) {
6114
 
                printf("%s: scb size = 0x%x, hscb size = 0x%x\n",
 
6122
                printk("%s: scb size = 0x%x, hscb size = 0x%x\n",
6115
6123
                       ahd_name(ahd), (u_int)sizeof(struct scb),
6116
6124
                       (u_int)sizeof(struct hardware_scb));
6117
6125
        }
6138
6146
ahd_set_name(struct ahd_softc *ahd, char *name)
6139
6147
{
6140
6148
        if (ahd->name != NULL)
6141
 
                free(ahd->name, M_DEVBUF);
 
6149
                kfree(ahd->name);
6142
6150
        ahd->name = name;
6143
6151
}
6144
6152
 
6192
6200
                                lstate = tstate->enabled_luns[j];
6193
6201
                                if (lstate != NULL) {
6194
6202
                                        xpt_free_path(lstate->path);
6195
 
                                        free(lstate, M_DEVBUF);
 
6203
                                        kfree(lstate);
6196
6204
                                }
6197
6205
                        }
6198
6206
#endif
6199
 
                        free(tstate, M_DEVBUF);
 
6207
                        kfree(tstate);
6200
6208
                }
6201
6209
        }
6202
6210
#ifdef AHD_TARGET_MODE
6203
6211
        if (ahd->black_hole != NULL) {
6204
6212
                xpt_free_path(ahd->black_hole->path);
6205
 
                free(ahd->black_hole, M_DEVBUF);
 
6213
                kfree(ahd->black_hole);
6206
6214
        }
6207
6215
#endif
6208
6216
        if (ahd->name != NULL)
6209
 
                free(ahd->name, M_DEVBUF);
 
6217
                kfree(ahd->name);
6210
6218
        if (ahd->seep_config != NULL)
6211
 
                free(ahd->seep_config, M_DEVBUF);
 
6219
                kfree(ahd->seep_config);
6212
6220
        if (ahd->saved_stack != NULL)
6213
 
                free(ahd->saved_stack, M_DEVBUF);
 
6221
                kfree(ahd->saved_stack);
6214
6222
#ifndef __FreeBSD__
6215
 
        free(ahd, M_DEVBUF);
 
6223
        kfree(ahd);
6216
6224
#endif
6217
6225
        return;
6218
6226
}
6291
6299
        } while (--wait && !(ahd_inb(ahd, HCNTRL) & CHIPRSTACK));
6292
6300
 
6293
6301
        if (wait == 0) {
6294
 
                printf("%s: WARNING - Failed chip reset!  "
 
6302
                printk("%s: WARNING - Failed chip reset!  "
6295
6303
                       "Trying to initialize anyway.\n", ahd_name(ahd));
6296
6304
        }
6297
6305
        ahd_outb(ahd, HCNTRL, ahd->pause);
6413
6421
        /* Determine the number of hardware SCBs and initialize them */
6414
6422
        scb_data->maxhscbs = ahd_probe_scbs(ahd);
6415
6423
        if (scb_data->maxhscbs == 0) {
6416
 
                printf("%s: No SCB space found\n", ahd_name(ahd));
 
6424
                printk("%s: No SCB space found\n", ahd_name(ahd));
6417
6425
                return (ENXIO);
6418
6426
        }
6419
6427
 
6456
6464
        }
6457
6465
#ifdef AHD_DEBUG
6458
6466
        if ((ahd_debug & AHD_SHOW_MEMORY) != 0)
6459
 
                printf("%s: ahd_sglist_allocsize = 0x%x\n", ahd_name(ahd),
 
6467
                printk("%s: ahd_sglist_allocsize = 0x%x\n", ahd_name(ahd),
6460
6468
                       ahd_sglist_allocsize(ahd));
6461
6469
#endif
6462
6470
 
6480
6488
        ahd_alloc_scbs(ahd);
6481
6489
 
6482
6490
        if (scb_data->numscbs == 0) {
6483
 
                printf("%s: ahd_init_scbdata - "
 
6491
                printk("%s: ahd_init_scbdata - "
6484
6492
                       "Unable to allocate initial scbs\n",
6485
6493
                       ahd_name(ahd));
6486
6494
                goto error_exit;
6555
6563
                                          sns_map->dmamap);
6556
6564
                        ahd_dmamem_free(ahd, scb_data->sense_dmat,
6557
6565
                                        sns_map->vaddr, sns_map->dmamap);
6558
 
                        free(sns_map, M_DEVBUF);
 
6566
                        kfree(sns_map);
6559
6567
                }
6560
6568
                ahd_dma_tag_destroy(ahd, scb_data->sense_dmat);
6561
6569
                /* FALLTHROUGH */
6570
6578
                                          sg_map->dmamap);
6571
6579
                        ahd_dmamem_free(ahd, scb_data->sg_dmat,
6572
6580
                                        sg_map->vaddr, sg_map->dmamap);
6573
 
                        free(sg_map, M_DEVBUF);
 
6581
                        kfree(sg_map);
6574
6582
                }
6575
6583
                ahd_dma_tag_destroy(ahd, scb_data->sg_dmat);
6576
6584
                /* FALLTHROUGH */
6585
6593
                                          hscb_map->dmamap);
6586
6594
                        ahd_dmamem_free(ahd, scb_data->hscb_dmat,
6587
6595
                                        hscb_map->vaddr, hscb_map->dmamap);
6588
 
                        free(hscb_map, M_DEVBUF);
 
6596
                        kfree(hscb_map);
6589
6597
                }
6590
6598
                ahd_dma_tag_destroy(ahd, scb_data->hscb_dmat);
6591
6599
                /* FALLTHROUGH */
6615
6623
        ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) | (ENSELDO|ENSELDI));
6616
6624
#ifdef AHD_DEBUG
6617
6625
        if ((ahd_debug & AHD_SHOW_MISC) != 0)
6618
 
                printf("%s: Setting up iocell workaround\n", ahd_name(ahd));
 
6626
                printk("%s: Setting up iocell workaround\n", ahd_name(ahd));
6619
6627
#endif
6620
6628
        ahd_restore_modes(ahd, saved_modes);
6621
6629
        ahd->flags &= ~AHD_HAD_FIRST_SEL;
6635
6643
        ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
6636
6644
#ifdef AHD_DEBUG
6637
6645
        if ((ahd_debug & AHD_SHOW_MISC) != 0)
6638
 
                printf("%s: iocell first selection\n", ahd_name(ahd));
 
6646
                printk("%s: iocell first selection\n", ahd_name(ahd));
6639
6647
#endif
6640
6648
        if ((sblkctl & ENAB40) != 0) {
6641
6649
                ahd_outb(ahd, DSPDATACTL,
6642
6650
                         ahd_inb(ahd, DSPDATACTL) & ~BYPASSENAB);
6643
6651
#ifdef AHD_DEBUG
6644
6652
                if ((ahd_debug & AHD_SHOW_MISC) != 0)
6645
 
                        printf("%s: BYPASS now disabled\n", ahd_name(ahd));
 
6653
                        printk("%s: BYPASS now disabled\n", ahd_name(ahd));
6646
6654
#endif
6647
6655
        }
6648
6656
        ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) & ~(ENSELDO|ENSELDI));
6824
6832
                hscb = &((struct hardware_scb *)hscb_map->vaddr)[offset];
6825
6833
                hscb_busaddr = hscb_map->physaddr + (offset * sizeof(*hscb));
6826
6834
        } else {
6827
 
                hscb_map = malloc(sizeof(*hscb_map), M_DEVBUF, M_NOWAIT);
 
6835
                hscb_map = kmalloc(sizeof(*hscb_map), GFP_ATOMIC);
6828
6836
 
6829
6837
                if (hscb_map == NULL)
6830
6838
                        return;
6833
6841
                if (ahd_dmamem_alloc(ahd, scb_data->hscb_dmat,
6834
6842
                                     (void **)&hscb_map->vaddr,
6835
6843
                                     BUS_DMA_NOWAIT, &hscb_map->dmamap) != 0) {
6836
 
                        free(hscb_map, M_DEVBUF);
 
6844
                        kfree(hscb_map);
6837
6845
                        return;
6838
6846
                }
6839
6847
 
6857
6865
                segs = sg_map->vaddr + offset;
6858
6866
                sg_busaddr = sg_map->physaddr + offset;
6859
6867
        } else {
6860
 
                sg_map = malloc(sizeof(*sg_map), M_DEVBUF, M_NOWAIT);
 
6868
                sg_map = kmalloc(sizeof(*sg_map), GFP_ATOMIC);
6861
6869
 
6862
6870
                if (sg_map == NULL)
6863
6871
                        return;
6866
6874
                if (ahd_dmamem_alloc(ahd, scb_data->sg_dmat,
6867
6875
                                     (void **)&sg_map->vaddr,
6868
6876
                                     BUS_DMA_NOWAIT, &sg_map->dmamap) != 0) {
6869
 
                        free(sg_map, M_DEVBUF);
 
6877
                        kfree(sg_map);
6870
6878
                        return;
6871
6879
                }
6872
6880
 
6882
6890
                    ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd);
6883
6891
#ifdef AHD_DEBUG
6884
6892
                if (ahd_debug & AHD_SHOW_MEMORY)
6885
 
                        printf("Mapped SG data\n");
 
6893
                        printk("Mapped SG data\n");
6886
6894
#endif
6887
6895
        }
6888
6896
 
6894
6902
                sense_data = sense_map->vaddr + offset;
6895
6903
                sense_busaddr = sense_map->physaddr + offset;
6896
6904
        } else {
6897
 
                sense_map = malloc(sizeof(*sense_map), M_DEVBUF, M_NOWAIT);
 
6905
                sense_map = kmalloc(sizeof(*sense_map), GFP_ATOMIC);
6898
6906
 
6899
6907
                if (sense_map == NULL)
6900
6908
                        return;
6903
6911
                if (ahd_dmamem_alloc(ahd, scb_data->sense_dmat,
6904
6912
                                     (void **)&sense_map->vaddr,
6905
6913
                                     BUS_DMA_NOWAIT, &sense_map->dmamap) != 0) {
6906
 
                        free(sense_map, M_DEVBUF);
 
6914
                        kfree(sense_map);
6907
6915
                        return;
6908
6916
                }
6909
6917
 
6918
6926
                scb_data->sense_left = PAGE_SIZE / AHD_SENSE_BUFSIZE;
6919
6927
#ifdef AHD_DEBUG
6920
6928
                if (ahd_debug & AHD_SHOW_MEMORY)
6921
 
                        printf("Mapped sense data\n");
 
6929
                        printk("Mapped sense data\n");
6922
6930
#endif
6923
6931
        }
6924
6932
 
6932
6940
                int error;
6933
6941
#endif
6934
6942
 
6935
 
                next_scb = (struct scb *)malloc(sizeof(*next_scb),
6936
 
                                                M_DEVBUF, M_NOWAIT);
 
6943
                next_scb = kmalloc(sizeof(*next_scb), GFP_ATOMIC);
6937
6944
                if (next_scb == NULL)
6938
6945
                        break;
6939
6946
 
6940
 
                pdata = (struct scb_platform_data *)malloc(sizeof(*pdata),
6941
 
                                                           M_DEVBUF, M_NOWAIT);
 
6947
                pdata = kmalloc(sizeof(*pdata), GFP_ATOMIC);
6942
6948
                if (pdata == NULL) {
6943
 
                        free(next_scb, M_DEVBUF);
 
6949
                        kfree(next_scb);
6944
6950
                        break;
6945
6951
                }
6946
6952
                next_scb->platform_data = pdata;
6970
6976
                error = ahd_dmamap_create(ahd, ahd->buffer_dmat, /*flags*/0,
6971
6977
                                          &next_scb->dmamap);
6972
6978
                if (error != 0) {
6973
 
                        free(next_scb, M_DEVBUF);
6974
 
                        free(pdata, M_DEVBUF);
 
6979
                        kfree(next_scb);
 
6980
                        kfree(pdata);
6975
6981
                        break;
6976
6982
                }
6977
6983
#endif
7068
7074
        AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
7069
7075
 
7070
7076
        ahd->stack_size = ahd_probe_stack_size(ahd);
7071
 
        ahd->saved_stack = malloc(ahd->stack_size * sizeof(uint16_t),
7072
 
                                  M_DEVBUF, M_NOWAIT);
 
7077
        ahd->saved_stack = kmalloc(ahd->stack_size * sizeof(uint16_t), GFP_ATOMIC);
7073
7078
        if (ahd->saved_stack == NULL)
7074
7079
                return (ENOMEM);
7075
7080
 
7215
7220
        error = ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL,
7216
7221
                                   CURSENSE_ENB);
7217
7222
        if (error != 0) {
7218
 
                printf("%s: current sensing timeout 1\n", ahd_name(ahd));
 
7223
                printk("%s: current sensing timeout 1\n", ahd_name(ahd));
7219
7224
                goto init_done;
7220
7225
        }
7221
7226
        for (i = 20, fstat = FLX_FSTAT_BUSY;
7222
7227
             (fstat & FLX_FSTAT_BUSY) != 0 && i; i--) {
7223
7228
                error = ahd_read_flexport(ahd, FLXADDR_FLEXSTAT, &fstat);
7224
7229
                if (error != 0) {
7225
 
                        printf("%s: current sensing timeout 2\n",
 
7230
                        printk("%s: current sensing timeout 2\n",
7226
7231
                               ahd_name(ahd));
7227
7232
                        goto init_done;
7228
7233
                }
7229
7234
        }
7230
7235
        if (i == 0) {
7231
 
                printf("%s: Timedout during current-sensing test\n",
 
7236
                printk("%s: Timedout during current-sensing test\n",
7232
7237
                       ahd_name(ahd));
7233
7238
                goto init_done;
7234
7239
        }
7236
7241
        /* Latch Current Sensing status. */
7237
7242
        error = ahd_read_flexport(ahd, FLXADDR_CURRENT_STAT, &current_sensing);
7238
7243
        if (error != 0) {
7239
 
                printf("%s: current sensing timeout 3\n", ahd_name(ahd));
 
7244
                printk("%s: current sensing timeout 3\n", ahd_name(ahd));
7240
7245
                goto init_done;
7241
7246
        }
7242
7247
 
7245
7250
 
7246
7251
#ifdef AHD_DEBUG
7247
7252
        if ((ahd_debug & AHD_SHOW_TERMCTL) != 0) {
7248
 
                printf("%s: current_sensing == 0x%x\n",
 
7253
                printk("%s: current_sensing == 0x%x\n",
7249
7254
                       ahd_name(ahd), current_sensing);
7250
7255
        }
7251
7256
#endif
7262
7267
                case FLX_CSTAT_OKAY:
7263
7268
                        if (warn_user == 0 && bootverbose == 0)
7264
7269
                                break;
7265
 
                        printf("%s: %s Channel %s\n", ahd_name(ahd),
 
7270
                        printk("%s: %s Channel %s\n", ahd_name(ahd),
7266
7271
                               channel_strings[i], termstat_strings[term_stat]);
7267
7272
                        break;
7268
7273
                }
7269
7274
        }
7270
7275
        if (warn_user) {
7271
 
                printf("%s: WARNING. Termination is not configured correctly.\n"
 
7276
                printk("%s: WARNING. Termination is not configured correctly.\n"
7272
7277
                       "%s: WARNING. SCSI bus operations may FAIL.\n",
7273
7278
                       ahd_name(ahd), ahd_name(ahd));
7274
7279
        }
7384
7389
                }
7385
7390
#ifdef AHD_DEBUG
7386
7391
                if ((ahd_debug & AHD_SHOW_MISC) != 0)
7387
 
                        printf("%s: WRTBIASCTL now 0x%x\n", ahd_name(ahd),
 
7392
                        printk("%s: WRTBIASCTL now 0x%x\n", ahd_name(ahd),
7388
7393
                               WRTBIASCTL_HP_DEFAULT);
7389
7394
#endif
7390
7395
        }
7613
7618
                ahd_outb(ahd, NEGCONOPTS, negodat3);
7614
7619
                negodat3 = ahd_inb(ahd, NEGCONOPTS);
7615
7620
                if (!(negodat3 & ENSLOWCRC))
7616
 
                        printf("aic79xx: failed to set the SLOWCRC bit\n");
 
7621
                        printk("aic79xx: failed to set the SLOWCRC bit\n");
7617
7622
                else
7618
 
                        printf("aic79xx: SLOWCRC bit set\n");
 
7623
                        printk("aic79xx: SLOWCRC bit set\n");
7619
7624
        }
7620
7625
}
7621
7626
 
7637
7642
         * data for any target mode initiator.
7638
7643
         */
7639
7644
        if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
7640
 
                printf("%s: unable to allocate ahd_tmode_tstate.  "
 
7645
                printk("%s: unable to allocate ahd_tmode_tstate.  "
7641
7646
                       "Failing attach\n", ahd_name(ahd));
7642
7647
                return (ENOMEM);
7643
7648
        }
7716
7721
         * data for any target mode initiator.
7717
7722
         */
7718
7723
        if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
7719
 
                printf("%s: unable to allocate ahd_tmode_tstate.  "
 
7724
                printk("%s: unable to allocate ahd_tmode_tstate.  "
7720
7725
                       "Failing attach\n", ahd_name(ahd));
7721
7726
                return (ENOMEM);
7722
7727
        }
7786
7791
                        user_tinfo->width = MSG_EXT_WDTR_BUS_8_BIT;
7787
7792
#ifdef AHD_DEBUG
7788
7793
                if ((ahd_debug & AHD_SHOW_MISC) != 0)
7789
 
                        printf("(%d): %x:%x:%x:%x\n", targ, user_tinfo->width,
 
7794
                        printk("(%d): %x:%x:%x:%x\n", targ, user_tinfo->width,
7790
7795
                               user_tinfo->period, user_tinfo->offset,
7791
7796
                               user_tinfo->ppr_options);
7792
7797
#endif
7942
7947
               || (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0));
7943
7948
 
7944
7949
        if (maxloops == 0) {
7945
 
                printf("Infinite interrupt loop, INTSTAT = %x",
 
7950
                printk("Infinite interrupt loop, INTSTAT = %x",
7946
7951
                      ahd_inb(ahd, INTSTAT));
7947
7952
        }
7948
7953
        ahd->qfreeze_cnt++;
8232
8237
        prev_scb = NULL;
8233
8238
 
8234
8239
        if (action == SEARCH_PRINT) {
8235
 
                printf("qinstart = %d qinfifonext = %d\nQINFIFO:",
 
8240
                printk("qinstart = %d qinfifonext = %d\nQINFIFO:",
8236
8241
                       qinstart, ahd->qinfifonext);
8237
8242
        }
8238
8243
 
8247
8252
        while (qinpos != qintail) {
8248
8253
                scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]);
8249
8254
                if (scb == NULL) {
8250
 
                        printf("qinpos = %d, SCB index = %d\n",
 
8255
                        printk("qinpos = %d, SCB index = %d\n",
8251
8256
                                qinpos, ahd->qinfifo[qinpos]);
8252
8257
                        panic("Loop 1\n");
8253
8258
                }
8260
8265
                        switch (action) {
8261
8266
                        case SEARCH_COMPLETE:
8262
8267
                                if ((scb->flags & SCB_ACTIVE) == 0)
8263
 
                                        printf("Inactive SCB in qinfifo\n");
 
8268
                                        printk("Inactive SCB in qinfifo\n");
8264
8269
                                ahd_done_with_status(ahd, scb, status);
8265
8270
                                /* FALLTHROUGH */
8266
8271
                        case SEARCH_REMOVE:
8267
8272
                                break;
8268
8273
                        case SEARCH_PRINT:
8269
 
                                printf(" 0x%x", ahd->qinfifo[qinpos]);
 
8274
                                printk(" 0x%x", ahd->qinfifo[qinpos]);
8270
8275
                                /* FALLTHROUGH */
8271
8276
                        case SEARCH_COUNT:
8272
8277
                                ahd_qinfifo_requeue(ahd, prev_scb, scb);
8283
8288
        ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
8284
8289
 
8285
8290
        if (action == SEARCH_PRINT)
8286
 
                printf("\nWAITING_TID_QUEUES:\n");
 
8291
                printk("\nWAITING_TID_QUEUES:\n");
8287
8292
 
8288
8293
        /*
8289
8294
         * Search waiting for selection lists.  We traverse the
8311
8316
                        panic("TID LIST LOOP");
8312
8317
 
8313
8318
                if (scbid >= ahd->scb_data.numscbs) {
8314
 
                        printf("%s: Waiting TID List inconsistency. "
 
8319
                        printk("%s: Waiting TID List inconsistency. "
8315
8320
                               "SCB index == 0x%x, yet numscbs == 0x%x.",
8316
8321
                               ahd_name(ahd), scbid, ahd->scb_data.numscbs);
8317
8322
                        ahd_dump_card_state(ahd);
8319
8324
                }
8320
8325
                scb = ahd_lookup_scb(ahd, scbid);
8321
8326
                if (scb == NULL) {
8322
 
                        printf("%s: SCB = 0x%x Not Active!\n",
 
8327
                        printk("%s: SCB = 0x%x Not Active!\n",
8323
8328
                               ahd_name(ahd), scbid);
8324
8329
                        panic("Waiting TID List traversal\n");
8325
8330
                }
8335
8340
                 * We found a list of scbs that needs to be searched.
8336
8341
                 */
8337
8342
                if (action == SEARCH_PRINT)
8338
 
                        printf("       %d ( ", SCB_GET_TARGET(ahd, scb));
 
8343
                        printk("       %d ( ", SCB_GET_TARGET(ahd, scb));
8339
8344
                tid_head = scbid;
8340
8345
                found += ahd_search_scb_list(ahd, target, channel,
8341
8346
                                             lun, tag, role, status,
8356
8361
                        switch (action) {
8357
8362
                        case SEARCH_COMPLETE:
8358
8363
                                if ((mk_msg_scb->flags & SCB_ACTIVE) == 0)
8359
 
                                        printf("Inactive SCB pending MK_MSG\n");
 
8364
                                        printk("Inactive SCB pending MK_MSG\n");
8360
8365
                                ahd_done_with_status(ahd, mk_msg_scb, status);
8361
8366
                                /* FALLTHROUGH */
8362
8367
                        case SEARCH_REMOVE:
8363
8368
                        {
8364
8369
                                u_int tail_offset;
8365
8370
 
8366
 
                                printf("Removing MK_MSG scb\n");
 
8371
                                printk("Removing MK_MSG scb\n");
8367
8372
 
8368
8373
                                /*
8369
8374
                                 * Reset our tail to the tail of the
8381
8386
                                break;
8382
8387
                        }
8383
8388
                        case SEARCH_PRINT:
8384
 
                                printf(" 0x%x", SCB_GET_TAG(scb));
 
8389
                                printk(" 0x%x", SCB_GET_TAG(scb));
8385
8390
                                /* FALLTHROUGH */
8386
8391
                        case SEARCH_COUNT:
8387
8392
                                break;
8398
8403
                         * queue with a pending MK_MESSAGE scb, we
8399
8404
                         * must queue the MK_MESSAGE scb.
8400
8405
                         */
8401
 
                        printf("Queueing mk_msg_scb\n");
 
8406
                        printk("Queueing mk_msg_scb\n");
8402
8407
                        tid_head = ahd_inw(ahd, MK_MESSAGE_SCB);
8403
8408
                        seq_flags2 &= ~PENDING_MK_MESSAGE;
8404
8409
                        ahd_outb(ahd, SEQ_FLAGS2, seq_flags2);
8409
8414
                if (!SCBID_IS_NULL(tid_head))
8410
8415
                        tid_prev = tid_head;
8411
8416
                if (action == SEARCH_PRINT)
8412
 
                        printf(")\n");
 
8417
                        printk(")\n");
8413
8418
        }
8414
8419
 
8415
8420
        /* Restore saved state. */
8437
8442
        *list_tail = SCB_LIST_NULL;
8438
8443
        for (scbid = next; !SCBID_IS_NULL(scbid); scbid = next) {
8439
8444
                if (scbid >= ahd->scb_data.numscbs) {
8440
 
                        printf("%s:SCB List inconsistency. "
 
8445
                        printk("%s:SCB List inconsistency. "
8441
8446
                               "SCB == 0x%x, yet numscbs == 0x%x.",
8442
8447
                               ahd_name(ahd), scbid, ahd->scb_data.numscbs);
8443
8448
                        ahd_dump_card_state(ahd);
8445
8450
                }
8446
8451
                scb = ahd_lookup_scb(ahd, scbid);
8447
8452
                if (scb == NULL) {
8448
 
                        printf("%s: SCB = %d Not Active!\n",
 
8453
                        printk("%s: SCB = %d Not Active!\n",
8449
8454
                               ahd_name(ahd), scbid);
8450
8455
                        panic("Waiting List traversal\n");
8451
8456
                }
8461
8466
                switch (action) {
8462
8467
                case SEARCH_COMPLETE:
8463
8468
                        if ((scb->flags & SCB_ACTIVE) == 0)
8464
 
                                printf("Inactive SCB in Waiting List\n");
 
8469
                                printk("Inactive SCB in Waiting List\n");
8465
8470
                        ahd_done_with_status(ahd, scb, status);
8466
8471
                        /* FALLTHROUGH */
8467
8472
                case SEARCH_REMOVE:
8471
8476
                                *list_head = next;
8472
8477
                        break;
8473
8478
                case SEARCH_PRINT:
8474
 
                        printf("0x%x ", scbid);
 
8479
                        printk("0x%x ", scbid);
8475
8480
                case SEARCH_COUNT:
8476
8481
                        prev = scbid;
8477
8482
                        break;
8659
8664
                        if (ahd_get_transaction_status(scbp) != CAM_REQ_CMP)
8660
8665
                                ahd_freeze_scb(scbp);
8661
8666
                        if ((scbp->flags & SCB_ACTIVE) == 0)
8662
 
                                printf("Inactive SCB on pending list\n");
 
8667
                                printk("Inactive SCB on pending list\n");
8663
8668
                        ahd_done(ahd, scbp);
8664
8669
                        found++;
8665
8670
                }
8716
8721
         * Check if the last bus reset is cleared
8717
8722
         */
8718
8723
        if (ahd->flags & AHD_BUS_RESET_ACTIVE) {
8719
 
                printf("%s: bus reset still active\n",
 
8724
                printk("%s: bus reset still active\n",
8720
8725
                       ahd_name(ahd));
8721
8726
                return 0;
8722
8727
        }
8891
8896
                ahd_enable_coalescing(ahd, enint_coal);
8892
8897
#ifdef AHD_DEBUG
8893
8898
                if ((ahd_debug & AHD_SHOW_INT_COALESCING) != 0)
8894
 
                        printf("%s: Interrupt coalescing "
 
8899
                        printk("%s: Interrupt coalescing "
8895
8900
                               "now %sabled. Cmds %d\n",
8896
8901
                               ahd_name(ahd),
8897
8902
                               (enint_coal & ENINT_COALESCE) ? "en" : "dis",
8966
8971
#ifdef AHD_DEBUG
8967
8972
                if ((ahd_debug & AHD_SHOW_SENSE) != 0) {
8968
8973
                        ahd_print_path(ahd, scb);
8969
 
                        printf("SCB 0x%x Received PKT Status of 0x%x\n",
 
8974
                        printk("SCB 0x%x Received PKT Status of 0x%x\n",
8970
8975
                               SCB_GET_TAG(scb), siu->status);
8971
 
                        printf("\tflags = 0x%x, sense len = 0x%x, "
 
8976
                        printk("\tflags = 0x%x, sense len = 0x%x, "
8972
8977
                               "pktfail = 0x%x\n",
8973
8978
                               siu->flags, scsi_4btoul(siu->sense_length),
8974
8979
                               scsi_4btoul(siu->pkt_failures_length));
8977
8982
                if ((siu->flags & SIU_RSPVALID) != 0) {
8978
8983
                        ahd_print_path(ahd, scb);
8979
8984
                        if (scsi_4btoul(siu->pkt_failures_length) < 4) {
8980
 
                                printf("Unable to parse pkt_failures\n");
 
8985
                                printk("Unable to parse pkt_failures\n");
8981
8986
                        } else {
8982
8987
 
8983
8988
                                switch (SIU_PKTFAIL_CODE(siu)) {
8984
8989
                                case SIU_PFC_NONE:
8985
 
                                        printf("No packet failure found\n");
 
8990
                                        printk("No packet failure found\n");
8986
8991
                                        break;
8987
8992
                                case SIU_PFC_CIU_FIELDS_INVALID:
8988
 
                                        printf("Invalid Command IU Field\n");
 
8993
                                        printk("Invalid Command IU Field\n");
8989
8994
                                        break;
8990
8995
                                case SIU_PFC_TMF_NOT_SUPPORTED:
8991
 
                                        printf("TMF not supportd\n");
 
8996
                                        printk("TMF not supportd\n");
8992
8997
                                        break;
8993
8998
                                case SIU_PFC_TMF_FAILED:
8994
 
                                        printf("TMF failed\n");
 
8999
                                        printk("TMF failed\n");
8995
9000
                                        break;
8996
9001
                                case SIU_PFC_INVALID_TYPE_CODE:
8997
 
                                        printf("Invalid L_Q Type code\n");
 
9002
                                        printk("Invalid L_Q Type code\n");
8998
9003
                                        break;
8999
9004
                                case SIU_PFC_ILLEGAL_REQUEST:
9000
 
                                        printf("Illegal request\n");
 
9005
                                        printk("Illegal request\n");
9001
9006
                                default:
9002
9007
                                        break;
9003
9008
                                }
9010
9015
                        scb->flags |= SCB_PKT_SENSE;
9011
9016
#ifdef AHD_DEBUG
9012
9017
                        if ((ahd_debug & AHD_SHOW_SENSE) != 0)
9013
 
                                printf("Sense data available\n");
 
9018
                                printk("Sense data available\n");
9014
9019
#endif
9015
9020
                }
9016
9021
                ahd_done(ahd, scb);
9028
9033
#ifdef AHD_DEBUG
9029
9034
                if (ahd_debug & AHD_SHOW_SENSE) {
9030
9035
                        ahd_print_path(ahd, scb);
9031
 
                        printf("SCB %d: requests Check Status\n",
 
9036
                        printk("SCB %d: requests Check Status\n",
9032
9037
                               SCB_GET_TAG(scb));
9033
9038
                }
9034
9039
#endif
9056
9061
#ifdef AHD_DEBUG
9057
9062
                if (ahd_debug & AHD_SHOW_SENSE) {
9058
9063
                        ahd_print_path(ahd, scb);
9059
 
                        printf("Sending Sense\n");
 
9064
                        printk("Sending Sense\n");
9060
9065
                }
9061
9066
#endif
9062
9067
                scb->sg_count = 0;
9108
9113
                break;
9109
9114
        }
9110
9115
        case SCSI_STATUS_OK:
9111
 
                printf("%s: Interrupted for staus of 0???\n",
 
9116
                printk("%s: Interrupted for staus of 0???\n",
9112
9117
                       ahd_name(ahd));
9113
9118
                /* FALLTHROUGH */
9114
9119
        default:
9183
9188
                return;
9184
9189
        } else if ((resid_sgptr & SG_OVERRUN_RESID) != 0) {
9185
9190
                ahd_print_path(ahd, scb);
9186
 
                printf("data overrun detected Tag == 0x%x.\n",
 
9191
                printk("data overrun detected Tag == 0x%x.\n",
9187
9192
                       SCB_GET_TAG(scb));
9188
9193
                ahd_freeze_devq(ahd, scb);
9189
9194
                ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
9223
9228
#ifdef AHD_DEBUG
9224
9229
        if ((ahd_debug & AHD_SHOW_MISC) != 0) {
9225
9230
                ahd_print_path(ahd, scb);
9226
 
                printf("Handled %sResidual of %d bytes\n",
 
9231
                printk("Handled %sResidual of %d bytes\n",
9227
9232
                       (scb->flags & SCB_SENSE) ? "Sense " : "", resid);
9228
9233
        }
9229
9234
#endif
9263
9268
 
9264
9269
        if (pending == AHD_TMODE_EVENT_BUFFER_SIZE) {
9265
9270
                xpt_print_path(lstate->path);
9266
 
                printf("immediate event %x:%x lost\n",
 
9271
                printk("immediate event %x:%x lost\n",
9267
9272
                       lstate->event_buffer[lstate->event_r_idx].event_type,
9268
9273
                       lstate->event_buffer[lstate->event_r_idx].event_arg);
9269
9274
                lstate->event_r_idx++;
9335
9340
                uint8_t ins_bytes[4];
9336
9341
 
9337
9342
                ahd_insb(ahd, SEQRAM, ins_bytes, 4);
9338
 
                printf("0x%08x\n", ins_bytes[0] << 24
 
9343
                printk("0x%08x\n", ins_bytes[0] << 24
9339
9344
                                 | ins_bytes[1] << 16
9340
9345
                                 | ins_bytes[2] << 8
9341
9346
                                 | ins_bytes[3]);
9363
9368
        uint8_t download_consts[DOWNLOAD_CONST_COUNT];
9364
9369
 
9365
9370
        if (bootverbose)
9366
 
                printf("%s: Downloading Sequencer Program...",
 
9371
                printk("%s: Downloading Sequencer Program...",
9367
9372
                       ahd_name(ahd));
9368
9373
 
9369
9374
#if DOWNLOAD_CONST_COUNT != 8
9489
9494
        if (cs_count != 0) {
9490
9495
 
9491
9496
                cs_count *= sizeof(struct cs);
9492
 
                ahd->critical_sections = malloc(cs_count, M_DEVBUF, M_NOWAIT);
 
9497
                ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
9493
9498
                if (ahd->critical_sections == NULL)
9494
9499
                        panic("ahd_loadseq: Could not malloc");
9495
9500
                memcpy(ahd->critical_sections, cs_table, cs_count);
9497
9502
        ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
9498
9503
 
9499
9504
        if (bootverbose) {
9500
 
                printf(" %d instructions downloaded\n", downloaded);
9501
 
                printf("%s: Features 0x%x, Bugs 0x%x, Flags 0x%x\n",
 
9505
                printk(" %d instructions downloaded\n", downloaded);
 
9506
                printk("%s: Features 0x%x, Bugs 0x%x, Flags 0x%x\n",
9502
9507
                       ahd_name(ahd), ahd->features, ahd->bugs, ahd->flags);
9503
9508
        }
9504
9509
}
9681
9686
        u_int   printed_mask;
9682
9687
 
9683
9688
        if (cur_column != NULL && *cur_column >= wrap_point) {
9684
 
                printf("\n");
 
9689
                printk("\n");
9685
9690
                *cur_column = 0;
9686
9691
        }
9687
 
        printed = printf("%s[0x%x]", name, value);
 
9692
        printed = printk("%s[0x%x]", name, value);
9688
9693
        if (table == NULL) {
9689
 
                printed += printf(" ");
 
9694
                printed += printk(" ");
9690
9695
                *cur_column += printed;
9691
9696
                return (printed);
9692
9697
        }
9701
9706
                          == table[entry].mask))
9702
9707
                                continue;
9703
9708
 
9704
 
                        printed += printf("%s%s",
 
9709
                        printed += printk("%s%s",
9705
9710
                                          printed_mask == 0 ? ":(" : "|",
9706
9711
                                          table[entry].name);
9707
9712
                        printed_mask |= table[entry].mask;
9712
9717
                        break;
9713
9718
        }
9714
9719
        if (printed_mask != 0)
9715
 
                printed += printf(") ");
 
9720
                printed += printk(") ");
9716
9721
        else
9717
 
                printed += printf(" ");
 
9722
                printed += printk(" ");
9718
9723
        if (cur_column != NULL)
9719
9724
                *cur_column += printed;
9720
9725
        return (printed);
9740
9745
        }
9741
9746
        saved_modes = ahd_save_modes(ahd);
9742
9747
        ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
9743
 
        printf(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n"
 
9748
        printk(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n"
9744
9749
               "%s: Dumping Card State at program address 0x%x Mode 0x%x\n",
9745
9750
               ahd_name(ahd), 
9746
9751
               ahd_inw(ahd, CURADDR),
9747
9752
               ahd_build_mode_state(ahd, ahd->saved_src_mode,
9748
9753
                                    ahd->saved_dst_mode));
9749
9754
        if (paused)
9750
 
                printf("Card was paused\n");
 
9755
                printk("Card was paused\n");
9751
9756
 
9752
9757
        if (ahd_check_cmdcmpltqueues(ahd))
9753
 
                printf("Completions are pending\n");
 
9758
                printk("Completions are pending\n");
9754
9759
 
9755
9760
        /*
9756
9761
         * Mode independent registers.
9792
9797
        ahd_lqostat0_print(ahd_inb(ahd, LQOSTAT0), &cur_col, 50);
9793
9798
        ahd_lqostat1_print(ahd_inb(ahd, LQOSTAT1), &cur_col, 50);
9794
9799
        ahd_lqostat2_print(ahd_inb(ahd, LQOSTAT2), &cur_col, 50);
9795
 
        printf("\n");
9796
 
        printf("\nSCB Count = %d CMDS_PENDING = %d LASTSCB 0x%x "
 
9800
        printk("\n");
 
9801
        printk("\nSCB Count = %d CMDS_PENDING = %d LASTSCB 0x%x "
9797
9802
               "CURRSCB 0x%x NEXTSCB 0x%x\n",
9798
9803
               ahd->scb_data.numscbs, ahd_inw(ahd, CMDS_PENDING),
9799
9804
               ahd_inw(ahd, LASTSCB), ahd_inw(ahd, CURRSCB),
9804
9809
                           CAM_LUN_WILDCARD, SCB_LIST_NULL,
9805
9810
                           ROLE_UNKNOWN, /*status*/0, SEARCH_PRINT);
9806
9811
        saved_scb_index = ahd_get_scbptr(ahd);
9807
 
        printf("Pending list:");
 
9812
        printk("Pending list:");
9808
9813
        i = 0;
9809
9814
        LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
9810
9815
                if (i++ > AHD_SCB_MAX)
9811
9816
                        break;
9812
 
                cur_col = printf("\n%3d FIFO_USE[0x%x] ", SCB_GET_TAG(scb),
 
9817
                cur_col = printk("\n%3d FIFO_USE[0x%x] ", SCB_GET_TAG(scb),
9813
9818
                                 ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT));
9814
9819
                ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
9815
9820
                ahd_scb_control_print(ahd_inb_scbram(ahd, SCB_CONTROL),
9817
9822
                ahd_scb_scsiid_print(ahd_inb_scbram(ahd, SCB_SCSIID),
9818
9823
                                     &cur_col, 60);
9819
9824
        }
9820
 
        printf("\nTotal %d\n", i);
 
9825
        printk("\nTotal %d\n", i);
9821
9826
 
9822
 
        printf("Kernel Free SCB list: ");
 
9827
        printk("Kernel Free SCB list: ");
9823
9828
        i = 0;
9824
9829
        TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
9825
9830
                struct scb *list_scb;
9826
9831
 
9827
9832
                list_scb = scb;
9828
9833
                do {
9829
 
                        printf("%d ", SCB_GET_TAG(list_scb));
 
9834
                        printk("%d ", SCB_GET_TAG(list_scb));
9830
9835
                        list_scb = LIST_NEXT(list_scb, collision_links);
9831
9836
                } while (list_scb && i++ < AHD_SCB_MAX);
9832
9837
        }
9834
9839
        LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
9835
9840
                if (i++ > AHD_SCB_MAX)
9836
9841
                        break;
9837
 
                printf("%d ", SCB_GET_TAG(scb));
 
9842
                printk("%d ", SCB_GET_TAG(scb));
9838
9843
        }
9839
 
        printf("\n");
 
9844
        printk("\n");
9840
9845
 
9841
 
        printf("Sequencer Complete DMA-inprog list: ");
 
9846
        printk("Sequencer Complete DMA-inprog list: ");
9842
9847
        scb_index = ahd_inw(ahd, COMPLETE_SCB_DMAINPROG_HEAD);
9843
9848
        i = 0;
9844
9849
        while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
9845
9850
                ahd_set_scbptr(ahd, scb_index);
9846
 
                printf("%d ", scb_index);
 
9851
                printk("%d ", scb_index);
9847
9852
                scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
9848
9853
        }
9849
 
        printf("\n");
 
9854
        printk("\n");
9850
9855
 
9851
 
        printf("Sequencer Complete list: ");
 
9856
        printk("Sequencer Complete list: ");
9852
9857
        scb_index = ahd_inw(ahd, COMPLETE_SCB_HEAD);
9853
9858
        i = 0;
9854
9859
        while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
9855
9860
                ahd_set_scbptr(ahd, scb_index);
9856
 
                printf("%d ", scb_index);
 
9861
                printk("%d ", scb_index);
9857
9862
                scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
9858
9863
        }
9859
 
        printf("\n");
 
9864
        printk("\n");
9860
9865
 
9861
9866
        
9862
 
        printf("Sequencer DMA-Up and Complete list: ");
 
9867
        printk("Sequencer DMA-Up and Complete list: ");
9863
9868
        scb_index = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
9864
9869
        i = 0;
9865
9870
        while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
9866
9871
                ahd_set_scbptr(ahd, scb_index);
9867
 
                printf("%d ", scb_index);
 
9872
                printk("%d ", scb_index);
9868
9873
                scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
9869
9874
        }
9870
 
        printf("\n");
9871
 
        printf("Sequencer On QFreeze and Complete list: ");
 
9875
        printk("\n");
 
9876
        printk("Sequencer On QFreeze and Complete list: ");
9872
9877
        scb_index = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD);
9873
9878
        i = 0;
9874
9879
        while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
9875
9880
                ahd_set_scbptr(ahd, scb_index);
9876
 
                printf("%d ", scb_index);
 
9881
                printk("%d ", scb_index);
9877
9882
                scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
9878
9883
        }
9879
 
        printf("\n");
 
9884
        printk("\n");
9880
9885
        ahd_set_scbptr(ahd, saved_scb_index);
9881
9886
        dffstat = ahd_inb(ahd, DFFSTAT);
9882
9887
        for (i = 0; i < 2; i++) {
9887
9892
 
9888
9893
                ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
9889
9894
                fifo_scbptr = ahd_get_scbptr(ahd);
9890
 
                printf("\n\n%s: FIFO%d %s, LONGJMP == 0x%x, SCB 0x%x\n",
 
9895
                printk("\n\n%s: FIFO%d %s, LONGJMP == 0x%x, SCB 0x%x\n",
9891
9896
                       ahd_name(ahd), i,
9892
9897
                       (dffstat & (FIFO0FREE << i)) ? "Free" : "Active",
9893
9898
                       ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr);
9903
9908
                ahd_soffcnt_print(ahd_inb(ahd, SOFFCNT), &cur_col, 50);
9904
9909
                ahd_mdffstat_print(ahd_inb(ahd, MDFFSTAT), &cur_col, 50);
9905
9910
                if (cur_col > 50) {
9906
 
                        printf("\n");
 
9911
                        printk("\n");
9907
9912
                        cur_col = 0;
9908
9913
                }
9909
 
                cur_col += printf("SHADDR = 0x%x%x, SHCNT = 0x%x ",
 
9914
                cur_col += printk("SHADDR = 0x%x%x, SHCNT = 0x%x ",
9910
9915
                                  ahd_inl(ahd, SHADDR+4),
9911
9916
                                  ahd_inl(ahd, SHADDR),
9912
9917
                                  (ahd_inb(ahd, SHCNT)
9913
9918
                                | (ahd_inb(ahd, SHCNT + 1) << 8)
9914
9919
                                | (ahd_inb(ahd, SHCNT + 2) << 16)));
9915
9920
                if (cur_col > 50) {
9916
 
                        printf("\n");
 
9921
                        printk("\n");
9917
9922
                        cur_col = 0;
9918
9923
                }
9919
 
                cur_col += printf("HADDR = 0x%x%x, HCNT = 0x%x ",
 
9924
                cur_col += printk("HADDR = 0x%x%x, HCNT = 0x%x ",
9920
9925
                                  ahd_inl(ahd, HADDR+4),
9921
9926
                                  ahd_inl(ahd, HADDR),
9922
9927
                                  (ahd_inb(ahd, HCNT)
9931
9936
                }
9932
9937
#endif
9933
9938
        }
9934
 
        printf("\nLQIN: ");
 
9939
        printk("\nLQIN: ");
9935
9940
        for (i = 0; i < 20; i++)
9936
 
                printf("0x%x ", ahd_inb(ahd, LQIN + i));
9937
 
        printf("\n");
 
9941
                printk("0x%x ", ahd_inb(ahd, LQIN + i));
 
9942
        printk("\n");
9938
9943
        ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
9939
 
        printf("%s: LQISTATE = 0x%x, LQOSTATE = 0x%x, OPTIONMODE = 0x%x\n",
 
9944
        printk("%s: LQISTATE = 0x%x, LQOSTATE = 0x%x, OPTIONMODE = 0x%x\n",
9940
9945
               ahd_name(ahd), ahd_inb(ahd, LQISTATE), ahd_inb(ahd, LQOSTATE),
9941
9946
               ahd_inb(ahd, OPTIONMODE));
9942
 
        printf("%s: OS_SPACE_CNT = 0x%x MAXCMDCNT = 0x%x\n",
 
9947
        printk("%s: OS_SPACE_CNT = 0x%x MAXCMDCNT = 0x%x\n",
9943
9948
               ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT),
9944
9949
               ahd_inb(ahd, MAXCMDCNT));
9945
 
        printf("%s: SAVED_SCSIID = 0x%x SAVED_LUN = 0x%x\n",
 
9950
        printk("%s: SAVED_SCSIID = 0x%x SAVED_LUN = 0x%x\n",
9946
9951
               ahd_name(ahd), ahd_inb(ahd, SAVED_SCSIID),
9947
9952
               ahd_inb(ahd, SAVED_LUN));
9948
9953
        ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50);
9949
 
        printf("\n");
 
9954
        printk("\n");
9950
9955
        ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
9951
9956
        cur_col = 0;
9952
9957
        ahd_ccscbctl_print(ahd_inb(ahd, CCSCBCTL), &cur_col, 50);
9953
 
        printf("\n");
 
9958
        printk("\n");
9954
9959
        ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
9955
 
        printf("%s: REG0 == 0x%x, SINDEX = 0x%x, DINDEX = 0x%x\n",
 
9960
        printk("%s: REG0 == 0x%x, SINDEX = 0x%x, DINDEX = 0x%x\n",
9956
9961
               ahd_name(ahd), ahd_inw(ahd, REG0), ahd_inw(ahd, SINDEX),
9957
9962
               ahd_inw(ahd, DINDEX));
9958
 
        printf("%s: SCBPTR == 0x%x, SCB_NEXT == 0x%x, SCB_NEXT2 == 0x%x\n",
 
9963
        printk("%s: SCBPTR == 0x%x, SCB_NEXT == 0x%x, SCB_NEXT2 == 0x%x\n",
9959
9964
               ahd_name(ahd), ahd_get_scbptr(ahd),
9960
9965
               ahd_inw_scbram(ahd, SCB_NEXT),
9961
9966
               ahd_inw_scbram(ahd, SCB_NEXT2));
9962
 
        printf("CDB %x %x %x %x %x %x\n",
 
9967
        printk("CDB %x %x %x %x %x %x\n",
9963
9968
               ahd_inb_scbram(ahd, SCB_CDB_STORE),
9964
9969
               ahd_inb_scbram(ahd, SCB_CDB_STORE+1),
9965
9970
               ahd_inb_scbram(ahd, SCB_CDB_STORE+2),
9966
9971
               ahd_inb_scbram(ahd, SCB_CDB_STORE+3),
9967
9972
               ahd_inb_scbram(ahd, SCB_CDB_STORE+4),
9968
9973
               ahd_inb_scbram(ahd, SCB_CDB_STORE+5));
9969
 
        printf("STACK:");
 
9974
        printk("STACK:");
9970
9975
        for (i = 0; i < ahd->stack_size; i++) {
9971
9976
                ahd->saved_stack[i] =
9972
9977
                    ahd_inb(ahd, STACK)|(ahd_inb(ahd, STACK) << 8);
9973
 
                printf(" 0x%x", ahd->saved_stack[i]);
 
9978
                printk(" 0x%x", ahd->saved_stack[i]);
9974
9979
        }
9975
9980
        for (i = ahd->stack_size-1; i >= 0; i--) {
9976
9981
                ahd_outb(ahd, STACK, ahd->saved_stack[i] & 0xFF);
9977
9982
                ahd_outb(ahd, STACK, (ahd->saved_stack[i] >> 8) & 0xFF);
9978
9983
        }
9979
 
        printf("\n<<<<<<<<<<<<<<<<< Dump Card State Ends >>>>>>>>>>>>>>>>>>\n");
 
9984
        printk("\n<<<<<<<<<<<<<<<<< Dump Card State Ends >>>>>>>>>>>>>>>>>>\n");
9980
9985
        ahd_restore_modes(ahd, saved_modes);
9981
9986
        if (paused == 0)
9982
9987
                ahd_unpause(ahd);
9995
10000
        saved_scb_index = ahd_get_scbptr(ahd);
9996
10001
        for (i = 0; i < AHD_SCB_MAX; i++) {
9997
10002
                ahd_set_scbptr(ahd, i);
9998
 
                printf("%3d", i);
9999
 
                printf("(CTRL 0x%x ID 0x%x N 0x%x N2 0x%x SG 0x%x, RSG 0x%x)\n",
 
10003
                printk("%3d", i);
 
10004
                printk("(CTRL 0x%x ID 0x%x N 0x%x N2 0x%x SG 0x%x, RSG 0x%x)\n",
10000
10005
                       ahd_inb_scbram(ahd, SCB_CONTROL),
10001
10006
                       ahd_inb_scbram(ahd, SCB_SCSIID),
10002
10007
                       ahd_inw_scbram(ahd, SCB_NEXT),
10004
10009
                       ahd_inl_scbram(ahd, SCB_SGPTR),
10005
10010
                       ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR));
10006
10011
        }
10007
 
        printf("\n");
 
10012
        printk("\n");
10008
10013
        ahd_set_scbptr(ahd, saved_scb_index);
10009
10014
        ahd_restore_modes(ahd, saved_modes);
10010
10015
}
10374
10379
         && ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
10375
10380
                u_long  s;
10376
10381
 
10377
 
                printf("Configuring Target Mode\n");
 
10382
                printk("Configuring Target Mode\n");
10378
10383
                ahd_lock(ahd, &s);
10379
10384
                if (LIST_FIRST(&ahd->pending_scbs) != NULL) {
10380
10385
                        ccb->ccb_h.status = CAM_BUSY;
10403
10408
                /* Are we already enabled?? */
10404
10409
                if (lstate != NULL) {
10405
10410
                        xpt_print_path(ccb->ccb_h.path);
10406
 
                        printf("Lun already enabled\n");
 
10411
                        printk("Lun already enabled\n");
10407
10412
                        ccb->ccb_h.status = CAM_LUN_ALRDY_ENA;
10408
10413
                        return;
10409
10414
                }
10415
10420
                         * specific commands.
10416
10421
                         */
10417
10422
                        ccb->ccb_h.status = CAM_REQ_INVALID;
10418
 
                        printf("Non-zero Group Codes\n");
 
10423
                        printk("Non-zero Group Codes\n");
10419
10424
                        return;
10420
10425
                }
10421
10426
 
10427
10432
                        tstate = ahd_alloc_tstate(ahd, target, channel);
10428
10433
                        if (tstate == NULL) {
10429
10434
                                xpt_print_path(ccb->ccb_h.path);
10430
 
                                printf("Couldn't allocate tstate\n");
 
10435
                                printk("Couldn't allocate tstate\n");
10431
10436
                                ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
10432
10437
                                return;
10433
10438
                        }
10434
10439
                }
10435
 
                lstate = malloc(sizeof(*lstate), M_DEVBUF, M_NOWAIT);
 
10440
                lstate = kmalloc(sizeof(*lstate), GFP_ATOMIC);
10436
10441
                if (lstate == NULL) {
10437
10442
                        xpt_print_path(ccb->ccb_h.path);
10438
 
                        printf("Couldn't allocate lstate\n");
 
10443
                        printk("Couldn't allocate lstate\n");
10439
10444
                        ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
10440
10445
                        return;
10441
10446
                }
10445
10450
                                         xpt_path_target_id(ccb->ccb_h.path),
10446
10451
                                         xpt_path_lun_id(ccb->ccb_h.path));
10447
10452
                if (status != CAM_REQ_CMP) {
10448
 
                        free(lstate, M_DEVBUF);
 
10453
                        kfree(lstate);
10449
10454
                        xpt_print_path(ccb->ccb_h.path);
10450
 
                        printf("Couldn't allocate path\n");
 
10455
                        printk("Couldn't allocate path\n");
10451
10456
                        ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
10452
10457
                        return;
10453
10458
                }
10515
10520
                ahd_unlock(ahd, &s);
10516
10521
                ccb->ccb_h.status = CAM_REQ_CMP;
10517
10522
                xpt_print_path(ccb->ccb_h.path);
10518
 
                printf("Lun now enabled for target mode\n");
 
10523
                printk("Lun now enabled for target mode\n");
10519
10524
        } else {
10520
10525
                struct scb *scb;
10521
10526
                int i, empty;
10534
10539
                        ccbh = &scb->io_ctx->ccb_h;
10535
10540
                        if (ccbh->func_code == XPT_CONT_TARGET_IO
10536
10541
                         && !xpt_path_comp(ccbh->path, ccb->ccb_h.path)){
10537
 
                                printf("CTIO pending\n");
 
10542
                                printk("CTIO pending\n");
10538
10543
                                ccb->ccb_h.status = CAM_REQ_INVALID;
10539
10544
                                ahd_unlock(ahd, &s);
10540
10545
                                return;
10542
10547
                }
10543
10548
 
10544
10549
                if (SLIST_FIRST(&lstate->accept_tios) != NULL) {
10545
 
                        printf("ATIOs pending\n");
 
10550
                        printk("ATIOs pending\n");
10546
10551
                        ccb->ccb_h.status = CAM_REQ_INVALID;
10547
10552
                }
10548
10553
 
10549
10554
                if (SLIST_FIRST(&lstate->immed_notifies) != NULL) {
10550
 
                        printf("INOTs pending\n");
 
10555
                        printk("INOTs pending\n");
10551
10556
                        ccb->ccb_h.status = CAM_REQ_INVALID;
10552
10557
                }
10553
10558
 
10557
10562
                }
10558
10563
 
10559
10564
                xpt_print_path(ccb->ccb_h.path);
10560
 
                printf("Target mode disabled\n");
 
10565
                printk("Target mode disabled\n");
10561
10566
                xpt_free_path(lstate->path);
10562
 
                free(lstate, M_DEVBUF);
 
10567
                kfree(lstate);
10563
10568
 
10564
10569
                ahd_pause(ahd);
10565
10570
                /* Can we clean up the target too? */
10606
10611
                        ahd_outb(ahd, SCSISEQ1, scsiseq1);
10607
10612
 
10608
10613
                        if ((ahd->features & AHD_MULTIROLE) == 0) {
10609
 
                                printf("Configuring Initiator Mode\n");
 
10614
                                printk("Configuring Initiator Mode\n");
10610
10615
                                ahd->flags &= ~AHD_TARGETROLE;
10611
10616
                                ahd->flags |= AHD_INITIATORROLE;
10612
10617
                                ahd_pause(ahd);
10740
10745
                ahd->flags &= ~AHD_TQINFIFO_BLOCKED;
10741
10746
#ifdef AHD_DEBUG
10742
10747
        if ((ahd_debug & AHD_SHOW_TQIN) != 0)
10743
 
                printf("Incoming command from %d for %d:%d%s\n",
 
10748
                printk("Incoming command from %d for %d:%d%s\n",
10744
10749
                       initiator, target, lun,
10745
10750
                       lstate == ahd->black_hole ? "(Black Holed)" : "");
10746
10751
#endif
10787
10792
        default:
10788
10793
                /* Only copy the opcode. */
10789
10794
                atio->cdb_len = 1;
10790
 
                printf("Reserved or VU command code type encountered\n");
 
10795
                printk("Reserved or VU command code type encountered\n");
10791
10796
                break;
10792
10797
        }
10793
10798
        
10804
10809
                 */
10805
10810
#ifdef AHD_DEBUG
10806
10811
                if ((ahd_debug & AHD_SHOW_TQIN) != 0)
10807
 
                        printf("Received Immediate Command %d:%d:%d - %p\n",
 
10812
                        printk("Received Immediate Command %d:%d:%d - %p\n",
10808
10813
                               initiator, target, lun, ahd->pending_device);
10809
10814
#endif
10810
10815
                ahd->pending_device = lstate;