@@ -1301,52 +1301,57 @@ static void sci_dma_tx_complete(void *arg)
1301
1301
}
1302
1302
1303
1303
/* Locking: called with port lock held */
1304
- static int sci_dma_rx_push (struct sci_port * s , size_t count )
1304
+ static int sci_dma_rx_push (struct sci_port * s , struct scatterlist * sg ,
1305
+ size_t count )
1305
1306
{
1306
1307
struct uart_port * port = & s -> port ;
1307
1308
struct tty_port * tport = & port -> state -> port ;
1308
- int i , active , room ;
1309
+ int i , room ;
1309
1310
1310
1311
room = tty_buffer_request_room (tport , count );
1311
1312
1312
- if (s -> active_rx == s -> cookie_rx [0 ]) {
1313
- active = 0 ;
1314
- } else if (s -> active_rx == s -> cookie_rx [1 ]) {
1315
- active = 1 ;
1316
- } else {
1317
- dev_err (port -> dev , "%s: Rx cookie %d not found!\n" , __func__ ,
1318
- s -> active_rx );
1319
- return 0 ;
1320
- }
1321
-
1322
1313
if (room < count )
1323
1314
dev_warn (port -> dev , "Rx overrun: dropping %zu bytes\n" ,
1324
1315
count - room );
1325
1316
if (!room )
1326
1317
return room ;
1327
1318
1328
1319
for (i = 0 ; i < room ; i ++ )
1329
- tty_insert_flip_char (tport , ((u8 * )sg_virt (& s -> sg_rx [active ]))[i ],
1330
- TTY_NORMAL );
1320
+ tty_insert_flip_char (tport , ((u8 * )sg_virt (sg ))[i ], TTY_NORMAL );
1331
1321
1332
1322
port -> icount .rx += room ;
1333
1323
1334
1324
return room ;
1335
1325
}
1336
1326
1327
+ static int sci_dma_rx_find_active (struct sci_port * s )
1328
+ {
1329
+ unsigned int i ;
1330
+
1331
+ for (i = 0 ; i < ARRAY_SIZE (s -> cookie_rx ); i ++ )
1332
+ if (s -> active_rx == s -> cookie_rx [i ])
1333
+ return i ;
1334
+
1335
+ dev_err (s -> port .dev , "%s: Rx cookie %d not found!\n" , __func__ ,
1336
+ s -> active_rx );
1337
+ return -1 ;
1338
+ }
1339
+
1337
1340
static void sci_dma_rx_complete (void * arg )
1338
1341
{
1339
1342
struct sci_port * s = arg ;
1340
1343
struct uart_port * port = & s -> port ;
1341
1344
unsigned long flags ;
1342
- int count ;
1345
+ int active , count = 0 ;
1343
1346
1344
1347
dev_dbg (port -> dev , "%s(%d) active cookie %d\n" , __func__ , port -> line ,
1345
1348
s -> active_rx );
1346
1349
1347
1350
spin_lock_irqsave (& port -> lock , flags );
1348
1351
1349
- count = sci_dma_rx_push (s , s -> buf_len_rx );
1352
+ active = sci_dma_rx_find_active (s );
1353
+ if (active >= 0 )
1354
+ count = sci_dma_rx_push (s , & s -> sg_rx [active ], s -> buf_len_rx );
1350
1355
1351
1356
mod_timer (& s -> rx_timer , jiffies + s -> rx_timeout );
1352
1357
@@ -1445,13 +1450,8 @@ static void work_fn_rx(struct work_struct *work)
1445
1450
int new ;
1446
1451
1447
1452
spin_lock_irqsave (& port -> lock , flags );
1448
- if (s -> active_rx == s -> cookie_rx [0 ]) {
1449
- new = 0 ;
1450
- } else if (s -> active_rx == s -> cookie_rx [1 ]) {
1451
- new = 1 ;
1452
- } else {
1453
- dev_err (port -> dev , "%s: Rx cookie %d not found!\n" , __func__ ,
1454
- s -> active_rx );
1453
+ new = sci_dma_rx_find_active (s );
1454
+ if (new < 0 ) {
1455
1455
spin_unlock_irqrestore (& port -> lock , flags );
1456
1456
return ;
1457
1457
}
@@ -1468,7 +1468,7 @@ static void work_fn_rx(struct work_struct *work)
1468
1468
dev_dbg (port -> dev , "Read %u bytes with cookie %d\n" , read ,
1469
1469
s -> active_rx );
1470
1470
1471
- count = sci_dma_rx_push (s , read );
1471
+ count = sci_dma_rx_push (s , & s -> sg_rx [ new ], read );
1472
1472
1473
1473
if (count )
1474
1474
tty_flip_buffer_push (& port -> state -> port );
0 commit comments