| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* aha152x.c -- Adaptec AHA-152x driver |
|---|
| 2 | 3 | * Author: Jürgen E. Fischer, fischer@norbit.de |
|---|
| 3 | 4 | * Copyright 1993-2004 Jürgen E. Fischer |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 7 | | - * Free Software Foundation; either version 2, or (at your option) any |
|---|
| 8 | | - * later version. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 11 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 13 | | - * General Public License for more details. |
|---|
| 14 | | - * |
|---|
| 15 | 5 | * |
|---|
| 16 | 6 | * $Id: aha152x.c,v 2.7 2004/01/24 11:42:59 fischer Exp $ |
|---|
| 17 | 7 | * |
|---|
| .. | .. |
|---|
| 228 | 218 | * Revision 0.0 1993/08/14 19:54:25 root |
|---|
| 229 | 219 | * empty function bodies; detect() works. |
|---|
| 230 | 220 | * |
|---|
| 231 | | - * |
|---|
| 232 | 221 | ************************************************************************** |
|---|
| 233 | 222 | |
|---|
| 234 | | - see Documentation/scsi/aha152x.txt for configuration details |
|---|
| 223 | + see Documentation/scsi/aha152x.rst for configuration details |
|---|
| 235 | 224 | |
|---|
| 236 | 225 | **************************************************************************/ |
|---|
| 237 | 226 | |
|---|
| .. | .. |
|---|
| 269 | 258 | /* DEFINES */ |
|---|
| 270 | 259 | |
|---|
| 271 | 260 | /* For PCMCIA cards, always use AUTOCONF */ |
|---|
| 272 | | -#if defined(PCMCIA) || defined(MODULE) |
|---|
| 261 | +#if defined(AHA152X_PCMCIA) || defined(MODULE) |
|---|
| 273 | 262 | #if !defined(AUTOCONF) |
|---|
| 274 | 263 | #define AUTOCONF |
|---|
| 275 | 264 | #endif |
|---|
| .. | .. |
|---|
| 297 | 286 | |
|---|
| 298 | 287 | #define DELAY_DEFAULT 1000 |
|---|
| 299 | 288 | |
|---|
| 300 | | -#if defined(PCMCIA) |
|---|
| 289 | +#if defined(AHA152X_PCMCIA) |
|---|
| 301 | 290 | #define IRQ_MIN 0 |
|---|
| 302 | 291 | #define IRQ_MAX 16 |
|---|
| 303 | 292 | #else |
|---|
| .. | .. |
|---|
| 328 | 317 | MODULE_DESCRIPTION(AHA152X_REVID); |
|---|
| 329 | 318 | MODULE_LICENSE("GPL"); |
|---|
| 330 | 319 | |
|---|
| 331 | | -#if !defined(PCMCIA) |
|---|
| 320 | +#if !defined(AHA152X_PCMCIA) |
|---|
| 332 | 321 | #if defined(MODULE) |
|---|
| 333 | 322 | static int io[] = {0, 0}; |
|---|
| 334 | 323 | module_param_hw_array(io, int, ioport, NULL, 0); |
|---|
| .. | .. |
|---|
| 391 | 380 | MODULE_DEVICE_TABLE(isapnp, id_table); |
|---|
| 392 | 381 | #endif /* ISAPNP */ |
|---|
| 393 | 382 | |
|---|
| 394 | | -#endif /* !PCMCIA */ |
|---|
| 383 | +#endif /* !AHA152X_PCMCIA */ |
|---|
| 395 | 384 | |
|---|
| 396 | 385 | static struct scsi_host_template aha152x_driver_template; |
|---|
| 397 | 386 | |
|---|
| .. | .. |
|---|
| 863 | 852 | if (shpnt->irq) |
|---|
| 864 | 853 | free_irq(shpnt->irq, shpnt); |
|---|
| 865 | 854 | |
|---|
| 866 | | -#if !defined(PCMCIA) |
|---|
| 855 | +#if !defined(AHA152X_PCMCIA) |
|---|
| 867 | 856 | if (shpnt->io_port) |
|---|
| 868 | 857 | release_region(shpnt->io_port, IO_RANGE); |
|---|
| 869 | 858 | #endif |
|---|
| .. | .. |
|---|
| 948 | 937 | SCp.ptr : buffer pointer |
|---|
| 949 | 938 | SCp.this_residual : buffer length |
|---|
| 950 | 939 | SCp.buffer : next buffer |
|---|
| 951 | | - SCp.buffers_residual : left buffers in list |
|---|
| 952 | 940 | SCp.phase : current state of the command */ |
|---|
| 953 | 941 | |
|---|
| 954 | 942 | if ((phase & resetting) || !scsi_sglist(SCpnt)) { |
|---|
| .. | .. |
|---|
| 956 | 944 | SCpnt->SCp.this_residual = 0; |
|---|
| 957 | 945 | scsi_set_resid(SCpnt, 0); |
|---|
| 958 | 946 | SCpnt->SCp.buffer = NULL; |
|---|
| 959 | | - SCpnt->SCp.buffers_residual = 0; |
|---|
| 960 | 947 | } else { |
|---|
| 961 | 948 | scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); |
|---|
| 962 | 949 | SCpnt->SCp.buffer = scsi_sglist(SCpnt); |
|---|
| 963 | 950 | SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer); |
|---|
| 964 | 951 | SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; |
|---|
| 965 | | - SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1; |
|---|
| 966 | 952 | } |
|---|
| 967 | 953 | |
|---|
| 968 | 954 | DO_LOCK(flags); |
|---|
| .. | .. |
|---|
| 1263 | 1249 | "aha152x: unable to verify geometry for disk with >1GB.\n" |
|---|
| 1264 | 1250 | " Using default translation. Please verify yourself.\n" |
|---|
| 1265 | 1251 | " Perhaps you need to enable extended translation in the driver.\n" |
|---|
| 1266 | | - " See Documentation/scsi/aha152x.txt for details.\n"); |
|---|
| 1252 | + " See Documentation/scsi/aha152x.rst for details.\n"); |
|---|
| 1267 | 1253 | } |
|---|
| 1268 | 1254 | } else { |
|---|
| 1269 | 1255 | info_array[0] = info[0]; |
|---|
| .. | .. |
|---|
| 2030 | 2016 | } |
|---|
| 2031 | 2017 | |
|---|
| 2032 | 2018 | if (CURRENT_SC->SCp.this_residual == 0 && |
|---|
| 2033 | | - CURRENT_SC->SCp.buffers_residual > 0) { |
|---|
| 2019 | + !sg_is_last(CURRENT_SC->SCp.buffer)) { |
|---|
| 2034 | 2020 | /* advance to next buffer */ |
|---|
| 2035 | | - CURRENT_SC->SCp.buffers_residual--; |
|---|
| 2036 | | - CURRENT_SC->SCp.buffer++; |
|---|
| 2021 | + CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer); |
|---|
| 2037 | 2022 | CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); |
|---|
| 2038 | 2023 | CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; |
|---|
| 2039 | 2024 | } |
|---|
| .. | .. |
|---|
| 2045 | 2030 | fifodata, GETPORT(FIFOSTAT)); |
|---|
| 2046 | 2031 | SETPORT(DMACNTRL0, ENDMA|_8BIT); |
|---|
| 2047 | 2032 | while(fifodata>0) { |
|---|
| 2048 | | - int data; |
|---|
| 2049 | | - data=GETPORT(DATAPORT); |
|---|
| 2033 | + GETPORT(DATAPORT); |
|---|
| 2050 | 2034 | fifodata--; |
|---|
| 2051 | 2035 | DATA_LEN++; |
|---|
| 2052 | 2036 | } |
|---|
| .. | .. |
|---|
| 2136 | 2120 | CMD_INC_RESID(CURRENT_SC, -2 * data_count); |
|---|
| 2137 | 2121 | } |
|---|
| 2138 | 2122 | |
|---|
| 2139 | | - if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { |
|---|
| 2123 | + if (CURRENT_SC->SCp.this_residual == 0 && |
|---|
| 2124 | + !sg_is_last(CURRENT_SC->SCp.buffer)) { |
|---|
| 2140 | 2125 | /* advance to next buffer */ |
|---|
| 2141 | | - CURRENT_SC->SCp.buffers_residual--; |
|---|
| 2142 | | - CURRENT_SC->SCp.buffer++; |
|---|
| 2126 | + CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer); |
|---|
| 2143 | 2127 | CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); |
|---|
| 2144 | 2128 | CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; |
|---|
| 2145 | 2129 | } |
|---|
| .. | .. |
|---|
| 2158 | 2142 | static void datao_end(struct Scsi_Host *shpnt) |
|---|
| 2159 | 2143 | { |
|---|
| 2160 | 2144 | if(TESTLO(DMASTAT, DFIFOEMP)) { |
|---|
| 2161 | | - int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - |
|---|
| 2162 | | - GETSTCNT(); |
|---|
| 2145 | + u32 datao_cnt = GETSTCNT(); |
|---|
| 2146 | + int datao_out = DATA_LEN - scsi_get_resid(CURRENT_SC); |
|---|
| 2147 | + int done; |
|---|
| 2148 | + struct scatterlist *sg = scsi_sglist(CURRENT_SC); |
|---|
| 2163 | 2149 | |
|---|
| 2164 | | - CMD_INC_RESID(CURRENT_SC, data_count); |
|---|
| 2150 | + CMD_INC_RESID(CURRENT_SC, datao_out - datao_cnt); |
|---|
| 2165 | 2151 | |
|---|
| 2166 | | - data_count -= CURRENT_SC->SCp.ptr - |
|---|
| 2167 | | - SG_ADDRESS(CURRENT_SC->SCp.buffer); |
|---|
| 2168 | | - while(data_count>0) { |
|---|
| 2169 | | - CURRENT_SC->SCp.buffer--; |
|---|
| 2170 | | - CURRENT_SC->SCp.buffers_residual++; |
|---|
| 2171 | | - data_count -= CURRENT_SC->SCp.buffer->length; |
|---|
| 2152 | + done = scsi_bufflen(CURRENT_SC) - scsi_get_resid(CURRENT_SC); |
|---|
| 2153 | + /* Locate the first SG entry not yet sent */ |
|---|
| 2154 | + while (done > 0 && !sg_is_last(sg)) { |
|---|
| 2155 | + if (done < sg->length) |
|---|
| 2156 | + break; |
|---|
| 2157 | + done -= sg->length; |
|---|
| 2158 | + sg = sg_next(sg); |
|---|
| 2172 | 2159 | } |
|---|
| 2173 | | - CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - |
|---|
| 2174 | | - data_count; |
|---|
| 2175 | | - CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + |
|---|
| 2176 | | - data_count; |
|---|
| 2160 | + |
|---|
| 2161 | + CURRENT_SC->SCp.buffer = sg; |
|---|
| 2162 | + CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) + done; |
|---|
| 2163 | + CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length - |
|---|
| 2164 | + done; |
|---|
| 2177 | 2165 | } |
|---|
| 2178 | 2166 | |
|---|
| 2179 | 2167 | SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); |
|---|
| .. | .. |
|---|
| 2501 | 2489 | |
|---|
| 2502 | 2490 | seq_printf(m, "); resid=%d; residual=%d; buffers=%d; phase |", |
|---|
| 2503 | 2491 | scsi_get_resid(ptr), ptr->SCp.this_residual, |
|---|
| 2504 | | - ptr->SCp.buffers_residual); |
|---|
| 2492 | + sg_nents(ptr->SCp.buffer) - 1); |
|---|
| 2505 | 2493 | |
|---|
| 2506 | 2494 | if (ptr->SCp.phase & not_issued) |
|---|
| 2507 | 2495 | seq_puts(m, "not issued|"); |
|---|
| .. | .. |
|---|
| 2920 | 2908 | .can_queue = 1, |
|---|
| 2921 | 2909 | .this_id = 7, |
|---|
| 2922 | 2910 | .sg_tablesize = SG_ALL, |
|---|
| 2923 | | - .use_clustering = DISABLE_CLUSTERING, |
|---|
| 2911 | + .dma_boundary = PAGE_SIZE - 1, |
|---|
| 2924 | 2912 | .slave_alloc = aha152x_adjust_queue, |
|---|
| 2925 | 2913 | }; |
|---|
| 2926 | 2914 | |
|---|
| 2927 | | -#if !defined(PCMCIA) |
|---|
| 2915 | +#if !defined(AHA152X_PCMCIA) |
|---|
| 2928 | 2916 | static int setup_count; |
|---|
| 2929 | 2917 | static struct aha152x_setup setup[2]; |
|---|
| 2930 | 2918 | |
|---|
| .. | .. |
|---|
| 3379 | 3367 | setup[setup_count].synchronous = ints[0] >= 6 ? ints[6] : 1; |
|---|
| 3380 | 3368 | setup[setup_count].delay = ints[0] >= 7 ? ints[7] : DELAY_DEFAULT; |
|---|
| 3381 | 3369 | setup[setup_count].ext_trans = ints[0] >= 8 ? ints[8] : 0; |
|---|
| 3382 | | - if (ints[0] > 8) { /*}*/ |
|---|
| 3370 | + if (ints[0] > 8) |
|---|
| 3383 | 3371 | printk(KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>" |
|---|
| 3384 | 3372 | "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n"); |
|---|
| 3385 | | - } else { |
|---|
| 3373 | + else |
|---|
| 3386 | 3374 | setup_count++; |
|---|
| 3387 | | - return 0; |
|---|
| 3388 | | - } |
|---|
| 3389 | 3375 | |
|---|
| 3390 | 3376 | return 1; |
|---|
| 3391 | 3377 | } |
|---|
| 3392 | 3378 | __setup("aha152x=", aha152x_setup); |
|---|
| 3393 | 3379 | #endif |
|---|
| 3394 | 3380 | |
|---|
| 3395 | | -#endif /* !PCMCIA */ |
|---|
| 3381 | +#endif /* !AHA152X_PCMCIA */ |
|---|