@@ -128,7 +128,6 @@ struct context {
128
128
int total_allocation ;
129
129
u32 current_bus ;
130
130
bool running ;
131
- bool flushing ;
132
131
133
132
/*
134
133
* List of page-sized buffers for storing DMA descriptors.
@@ -157,8 +156,12 @@ struct context {
157
156
int prev_z ;
158
157
159
158
descriptor_callback_t callback ;
159
+ };
160
160
161
+ struct at_context {
162
+ struct context context ;
161
163
struct work_struct work ;
164
+ bool flushing ;
162
165
};
163
166
164
167
struct iso_context {
@@ -204,8 +207,8 @@ struct fw_ohci {
204
207
205
208
struct ar_context ar_request_ctx ;
206
209
struct ar_context ar_response_ctx ;
207
- struct context at_request_ctx ;
208
- struct context at_response_ctx ;
210
+ struct at_context at_request_ctx ;
211
+ struct at_context at_response_ctx ;
209
212
210
213
u32 it_context_support ;
211
214
u32 it_context_mask ; /* unoccupied IT contexts */
@@ -1178,9 +1181,9 @@ static void context_retire_descriptors(struct context *ctx)
1178
1181
1179
1182
static void ohci_at_context_work (struct work_struct * work )
1180
1183
{
1181
- struct context * ctx = from_work (ctx , work , work );
1184
+ struct at_context * ctx = from_work (ctx , work , work );
1182
1185
1183
- context_retire_descriptors (ctx );
1186
+ context_retire_descriptors (& ctx -> context );
1184
1187
}
1185
1188
1186
1189
static void ohci_isoc_context_work (struct work_struct * work )
@@ -1382,17 +1385,17 @@ struct driver_data {
1382
1385
* Must always be called with the ochi->lock held to ensure proper
1383
1386
* generation handling and locking around packet queue manipulation.
1384
1387
*/
1385
- static int at_context_queue_packet (struct context * ctx ,
1386
- struct fw_packet * packet )
1388
+ static int at_context_queue_packet (struct at_context * ctx , struct fw_packet * packet )
1387
1389
{
1388
- struct fw_ohci * ohci = ctx -> ohci ;
1390
+ struct context * context = & ctx -> context ;
1391
+ struct fw_ohci * ohci = context -> ohci ;
1389
1392
dma_addr_t d_bus , payload_bus ;
1390
1393
struct driver_data * driver_data ;
1391
1394
struct descriptor * d , * last ;
1392
1395
__le32 * header ;
1393
1396
int z , tcode ;
1394
1397
1395
- d = context_get_descriptors (ctx , 4 , & d_bus );
1398
+ d = context_get_descriptors (context , 4 , & d_bus );
1396
1399
if (d == NULL ) {
1397
1400
packet -> ack = RCODE_SEND_ERROR ;
1398
1401
return -1 ;
@@ -1422,7 +1425,7 @@ static int at_context_queue_packet(struct context *ctx,
1422
1425
ohci1394_at_data_set_destination_id (header ,
1423
1426
async_header_get_destination (packet -> header ));
1424
1427
1425
- if (ctx == & ctx -> ohci -> at_response_ctx ) {
1428
+ if (ctx == & ohci -> at_response_ctx ) {
1426
1429
ohci1394_at_data_set_rcode (header , async_header_get_rcode (packet -> header ));
1427
1430
} else {
1428
1431
ohci1394_at_data_set_destination_offset (header ,
@@ -1511,17 +1514,17 @@ static int at_context_queue_packet(struct context *ctx,
1511
1514
return -1 ;
1512
1515
}
1513
1516
1514
- context_append (ctx , d , z , 4 - z );
1517
+ context_append (context , d , z , 4 - z );
1515
1518
1516
- if (ctx -> running )
1517
- reg_write (ohci , CONTROL_SET (ctx -> regs ), CONTEXT_WAKE );
1519
+ if (context -> running )
1520
+ reg_write (ohci , CONTROL_SET (context -> regs ), CONTEXT_WAKE );
1518
1521
else
1519
- context_run (ctx , 0 );
1522
+ context_run (context , 0 );
1520
1523
1521
1524
return 0 ;
1522
1525
}
1523
1526
1524
- static void at_context_flush (struct context * ctx )
1527
+ static void at_context_flush (struct at_context * ctx )
1525
1528
{
1526
1529
// Avoid dead lock due to programming mistake.
1527
1530
if (WARN_ON_ONCE (current_work () == & ctx -> work ))
@@ -1540,12 +1543,13 @@ static int handle_at_packet(struct context *context,
1540
1543
struct descriptor * d ,
1541
1544
struct descriptor * last )
1542
1545
{
1546
+ struct at_context * ctx = container_of (context , struct at_context , context );
1547
+ struct fw_ohci * ohci = ctx -> context .ohci ;
1543
1548
struct driver_data * driver_data ;
1544
1549
struct fw_packet * packet ;
1545
- struct fw_ohci * ohci = context -> ohci ;
1546
1550
int evt ;
1547
1551
1548
- if (last -> transfer_status == 0 && !READ_ONCE (context -> flushing ))
1552
+ if (last -> transfer_status == 0 && !READ_ONCE (ctx -> flushing ))
1549
1553
/* This descriptor isn't done yet, stop iteration. */
1550
1554
return 0 ;
1551
1555
@@ -1579,7 +1583,7 @@ static int handle_at_packet(struct context *context,
1579
1583
break ;
1580
1584
1581
1585
case OHCI1394_evt_missing_ack :
1582
- if (READ_ONCE (context -> flushing ))
1586
+ if (READ_ONCE (ctx -> flushing ))
1583
1587
packet -> ack = RCODE_GENERATION ;
1584
1588
else {
1585
1589
/*
@@ -1601,7 +1605,7 @@ static int handle_at_packet(struct context *context,
1601
1605
break ;
1602
1606
1603
1607
case OHCI1394_evt_no_status :
1604
- if (READ_ONCE (context -> flushing )) {
1608
+ if (READ_ONCE (ctx -> flushing )) {
1605
1609
packet -> ack = RCODE_GENERATION ;
1606
1610
break ;
1607
1611
}
@@ -1698,68 +1702,70 @@ static void handle_local_lock(struct fw_ohci *ohci,
1698
1702
fw_core_handle_response (& ohci -> card , & response );
1699
1703
}
1700
1704
1701
- static void handle_local_request (struct context * ctx , struct fw_packet * packet )
1705
+ static void handle_local_request (struct at_context * ctx , struct fw_packet * packet )
1702
1706
{
1707
+ struct fw_ohci * ohci = ctx -> context .ohci ;
1703
1708
u64 offset , csr ;
1704
1709
1705
- if (ctx == & ctx -> ohci -> at_request_ctx ) {
1710
+ if (ctx == & ohci -> at_request_ctx ) {
1706
1711
packet -> ack = ACK_PENDING ;
1707
- packet -> callback (packet , & ctx -> ohci -> card , packet -> ack );
1712
+ packet -> callback (packet , & ohci -> card , packet -> ack );
1708
1713
}
1709
1714
1710
1715
offset = async_header_get_offset (packet -> header );
1711
1716
csr = offset - CSR_REGISTER_BASE ;
1712
1717
1713
1718
/* Handle config rom reads. */
1714
1719
if (csr >= CSR_CONFIG_ROM && csr < CSR_CONFIG_ROM_END )
1715
- handle_local_rom (ctx -> ohci , packet , csr );
1720
+ handle_local_rom (ohci , packet , csr );
1716
1721
else switch (csr ) {
1717
1722
case CSR_BUS_MANAGER_ID :
1718
1723
case CSR_BANDWIDTH_AVAILABLE :
1719
1724
case CSR_CHANNELS_AVAILABLE_HI :
1720
1725
case CSR_CHANNELS_AVAILABLE_LO :
1721
- handle_local_lock (ctx -> ohci , packet , csr );
1726
+ handle_local_lock (ohci , packet , csr );
1722
1727
break ;
1723
1728
default :
1724
- if (ctx == & ctx -> ohci -> at_request_ctx )
1725
- fw_core_handle_request (& ctx -> ohci -> card , packet );
1729
+ if (ctx == & ohci -> at_request_ctx )
1730
+ fw_core_handle_request (& ohci -> card , packet );
1726
1731
else
1727
- fw_core_handle_response (& ctx -> ohci -> card , packet );
1732
+ fw_core_handle_response (& ohci -> card , packet );
1728
1733
break ;
1729
1734
}
1730
1735
1731
- if (ctx == & ctx -> ohci -> at_response_ctx ) {
1736
+ if (ctx == & ohci -> at_response_ctx ) {
1732
1737
packet -> ack = ACK_COMPLETE ;
1733
- packet -> callback (packet , & ctx -> ohci -> card , packet -> ack );
1738
+ packet -> callback (packet , & ohci -> card , packet -> ack );
1734
1739
}
1735
1740
}
1736
1741
1737
- static void at_context_transmit (struct context * ctx , struct fw_packet * packet )
1742
+ static void at_context_transmit (struct at_context * ctx , struct fw_packet * packet )
1738
1743
{
1744
+ struct fw_ohci * ohci = ctx -> context .ohci ;
1739
1745
unsigned long flags ;
1740
1746
int ret ;
1741
1747
1742
- spin_lock_irqsave (& ctx -> ohci -> lock , flags );
1748
+ spin_lock_irqsave (& ohci -> lock , flags );
1743
1749
1744
- if (async_header_get_destination (packet -> header ) == ctx -> ohci -> node_id &&
1745
- ctx -> ohci -> generation == packet -> generation ) {
1746
- spin_unlock_irqrestore (& ctx -> ohci -> lock , flags );
1750
+ if (async_header_get_destination (packet -> header ) == ohci -> node_id &&
1751
+ ohci -> generation == packet -> generation ) {
1752
+ spin_unlock_irqrestore (& ohci -> lock , flags );
1747
1753
1748
1754
// Timestamping on behalf of the hardware.
1749
- packet -> timestamp = cycle_time_to_ohci_tstamp (get_cycle_time (ctx -> ohci ));
1755
+ packet -> timestamp = cycle_time_to_ohci_tstamp (get_cycle_time (ohci ));
1750
1756
1751
1757
handle_local_request (ctx , packet );
1752
1758
return ;
1753
1759
}
1754
1760
1755
1761
ret = at_context_queue_packet (ctx , packet );
1756
- spin_unlock_irqrestore (& ctx -> ohci -> lock , flags );
1762
+ spin_unlock_irqrestore (& ohci -> lock , flags );
1757
1763
1758
1764
if (ret < 0 ) {
1759
1765
// Timestamping on behalf of the hardware.
1760
- packet -> timestamp = cycle_time_to_ohci_tstamp (get_cycle_time (ctx -> ohci ));
1766
+ packet -> timestamp = cycle_time_to_ohci_tstamp (get_cycle_time (ohci ));
1761
1767
1762
- packet -> callback (packet , & ctx -> ohci -> card , packet -> ack );
1768
+ packet -> callback (packet , & ohci -> card , packet -> ack );
1763
1769
}
1764
1770
}
1765
1771
@@ -2138,8 +2144,8 @@ static void bus_reset_work(struct work_struct *work)
2138
2144
// FIXME: Document how the locking works.
2139
2145
scoped_guard (spinlock_irq , & ohci -> lock ) {
2140
2146
ohci -> generation = -1 ; // prevent AT packet queueing
2141
- context_stop (& ohci -> at_request_ctx );
2142
- context_stop (& ohci -> at_response_ctx );
2147
+ context_stop (& ohci -> at_request_ctx . context );
2148
+ context_stop (& ohci -> at_response_ctx . context );
2143
2149
}
2144
2150
2145
2151
/*
@@ -2683,7 +2689,7 @@ static void ohci_send_response(struct fw_card *card, struct fw_packet *packet)
2683
2689
static int ohci_cancel_packet (struct fw_card * card , struct fw_packet * packet )
2684
2690
{
2685
2691
struct fw_ohci * ohci = fw_ohci (card );
2686
- struct context * ctx = & ohci -> at_request_ctx ;
2692
+ struct at_context * ctx = & ohci -> at_request_ctx ;
2687
2693
struct driver_data * driver_data = packet -> driver_data ;
2688
2694
int ret = - ENOENT ;
2689
2695
@@ -3767,13 +3773,13 @@ static int pci_probe(struct pci_dev *dev,
3767
3773
if (err < 0 )
3768
3774
return err ;
3769
3775
3770
- err = context_init (& ohci -> at_request_ctx , ohci ,
3776
+ err = context_init (& ohci -> at_request_ctx . context , ohci ,
3771
3777
OHCI1394_AsReqTrContextControlSet , handle_at_packet );
3772
3778
if (err < 0 )
3773
3779
return err ;
3774
3780
INIT_WORK (& ohci -> at_request_ctx .work , ohci_at_context_work );
3775
3781
3776
- err = context_init (& ohci -> at_response_ctx , ohci ,
3782
+ err = context_init (& ohci -> at_response_ctx . context , ohci ,
3777
3783
OHCI1394_AsRspTrContextControlSet , handle_at_packet );
3778
3784
if (err < 0 )
3779
3785
return err ;
0 commit comments