Skip to content

Commit 41e47e6

Browse files
Gordon HollingworthGordon Hollingworth
authored andcommitted
Merge branch 'debug' into rpi-patches
Conflicts: drivers/usb/host/dwc_otg/dwc_otg_cil.c drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c
2 parents 775d4ce + 18ce78d commit 41e47e6

6 files changed

Lines changed: 79 additions & 7 deletions

File tree

‎drivers/mmc/host/sdhci.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
967967
if ((cmd->data != NULL) || (cmd->flags & MMC_RSP_BUSY))
968968
mask |= SDHCI_DATA_INHIBIT;
969969

970+
// This may disable preemption for up to 5s! In real world cases we saw that preemption is stopped for ~150ms which is bad for realtime A/V streaming apps.
970971
if(host->ops->missing_status && (cmd->opcode == MMC_SEND_STATUS)) {
971972
timeout = 5000; // Really obscenely large delay to send the status, due to bug in controller
972973
// which might cause the STATUS command to get stuck when a data operation is in flow
@@ -988,7 +989,10 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
988989
return;
989990
}
990991
timeout--;
992+
preempt_enable();
993+
schedule();
991994
mdelay(1);
995+
preempt_disable();
992996
}
993997
DBG("send cmd %d - wait 0x%X irq 0x%x\n", cmd->opcode, mask,
994998
sdhci_readl(host, SDHCI_INT_STATUS));

‎drivers/usb/host/dwc_otg/dwc_otg_cil.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,6 +2727,7 @@ void dwc_otg_hc_start_transfer(dwc_otg_core_if_t * core_if, dwc_hc_t * hc)
27272727
if (hc->do_split) {
27282728
num_packets = 1;
27292729

2730+
info_data(hc->complete_split ? info_complete_split : info_start_split);
27302731
if (hc->complete_split && !hc->ep_is_in) {
27312732
/* For CSPLIT OUT Transfer, set the size to 0 so the
27322733
* core doesn't expect any data written to the FIFO */

‎drivers/usb/host/dwc_otg/dwc_otg_dbg.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
#ifndef __DWC_OTG_DBG_H__
3131
#define __DWC_OTG_DBG_H__
3232

33+
#define info_start_split (1 << 0)
34+
#define info_complete_split (1 << 1)
35+
#define info_complete_nyet (1 << 2)
36+
#define info_process_periodic (1 << 3)
37+
#define info_frame (1 << 15)
38+
void info_data(int info);
39+
40+
3341
/** @file
3442
* This file defines debug levels.
3543
* Debugging support vanishes in non-debug builds.

‎drivers/usb/host/dwc_otg/dwc_otg_hcd.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,10 @@ static void process_periodic_channels(dwc_otg_hcd_t * hcd)
13731373
int no_queue_space = 0;
13741374
int no_fifo_space = 0;
13751375

1376+
// OK This is not being called on the right frame, even though we do get every SOF interrupt, need to see if it is
1377+
// not actually in the assigned queue at the right time...
1378+
info_data(info_process_periodic);
1379+
13761380
dwc_otg_host_global_regs_t *host_regs;
13771381
host_regs = hcd->core_if->host_if->host_global_regs;
13781382

‎drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c‎

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ static inline void track_missed_sofs(uint16_t curr_frame_number)
174174
}
175175
#endif
176176

177+
struct tracking
178+
{
179+
int frame;
180+
int next_sched;
181+
int info;
182+
} tracking_frames[16];
183+
int tracking_frames_n = 0;
184+
185+
void info_data(int info)
186+
{
187+
tracking_frames[(tracking_frames_n + 15) % 16].info |= info;
188+
}
189+
177190
/**
178191
* Handles the start-of-frame interrupt in host mode. Non-periodic
179192
* transactions may be queued to the DWC_otg controller for the current
@@ -204,18 +217,44 @@ int32_t dwc_otg_hcd_handle_sof_intr(dwc_otg_hcd_t * hcd)
204217
#ifdef DWC_TRACK_MISSED_SOFS
205218
track_missed_sofs(hcd->frame_number);
206219
#endif
220+
221+
qh_entry = DWC_LIST_FIRST(&hcd->periodic_sched_inactive);
222+
next_sched = (DWC_LIST_ENTRY(qh_entry, dwc_otg_qh_t, qh_list_entry))->sched_frame;
223+
while (qh_entry != &hcd->periodic_sched_inactive) {
224+
qh = DWC_LIST_ENTRY(qh_entry, dwc_otg_qh_t, qh_list_entry);
225+
qh_entry = qh_entry->next;
226+
if (dwc_frame_num_le(qh->sched_frame, next_sched)) {
227+
next_sched = qh->sched_frame;
228+
}
229+
}
230+
231+
tracking_frames[tracking_frames_n].frame = hcd->frame_number;
232+
tracking_frames[tracking_frames_n].next_sched = next_sched;
233+
tracking_frames[tracking_frames_n].info = 0;
234+
tracking_frames_n = (tracking_frames_n + 1) % 16;
235+
info_data(info_frame);
236+
207237
/* Determine whether any periodic QHs should be executed. */
208238
qh_entry = DWC_LIST_FIRST(&hcd->periodic_sched_inactive);
209239
while (qh_entry != &hcd->periodic_sched_inactive) {
210240
qh = DWC_LIST_ENTRY(qh_entry, dwc_otg_qh_t, qh_list_entry);
211241
qh_entry = qh_entry->next;
212242
if (dwc_frame_num_le(qh->sched_frame, hcd->frame_number)) {
213-
/*
214-
* Move QH to the ready list to be executed next
215-
* (micro)frame.
216-
*/
217-
DWC_LIST_MOVE_HEAD(&hcd->periodic_sched_ready,
218-
&qh->qh_list_entry);
243+
dwc_otg_qtd_t * qtd = DWC_CIRCLEQ_FIRST(&qh->qtd_list);
244+
if(qh->do_split && !qtd->complete_split && qh->sched_frame != hcd->frame_number) {
245+
if((qh->sched_frame & 7) != 7)
246+
printk("start split not scheduled for frame 7\n");
247+
qh->sched_frame = hcd->frame_number | 7;
248+
qh->start_split_frame = qh->sched_frame;
249+
}
250+
else {
251+
/*
252+
* Move QH to the ready list to be executed next
253+
* (micro)frame.
254+
*/
255+
DWC_LIST_MOVE_HEAD(&hcd->periodic_sched_ready,
256+
&qh->qh_list_entry);
257+
}
219258
}
220259
}
221260
tr_type = dwc_otg_hcd_select_transactions(hcd);
@@ -1480,10 +1519,23 @@ static int32_t handle_hc_nyet_intr(dwc_otg_hcd_t * hcd,
14801519

14811520
if (dwc_full_frame_num(frnum) !=
14821521
dwc_full_frame_num(hc->qh->sched_frame)) {
1522+
int i;
14831523
/*
14841524
* No longer in the same full speed frame.
14851525
* Treat this as a transaction error.
14861526
*/
1527+
printk(KERN_ERR "Dropping split complete packet, check interrupt latency, scheduled at %d.%d frame number %d.%d start_split_frame = %d.%d\n", hc->qh->sched_frame/8, hc->qh->sched_frame%8, frnum/8, frnum%8, hc->qh->start_split_frame/8, hc->qh->start_split_frame%8);
1528+
for(i = 0; i < 16; i++)
1529+
{
1530+
int info = tracking_frames[(tracking_frames_n + i)%16].info;
1531+
int frame = tracking_frames[(tracking_frames_n + i)%16].frame;
1532+
int next = tracking_frames[(tracking_frames_n + i)%16].next_sched;
1533+
char info_string[32] = "f...........pncs";
1534+
int i;
1535+
for(i = 0; i < 16; i++)
1536+
if(info & (1 << i)) info_string[15-i] = info_string[15-i] + ('A' - 'a');
1537+
printk("frame %d.%d - (%d) %s next_sched = %d.%d\n", frame/8, frame%8, info, info_string, next/8, next%8);
1538+
}
14871539
#if 0
14881540
/** @todo Fix system performance so this can
14891541
* be treated as an error. Right now complete
@@ -1501,6 +1553,8 @@ static int32_t handle_hc_nyet_intr(dwc_otg_hcd_t * hcd,
15011553
}
15021554
}
15031555

1556+
info_data(info_complete_nyet);
1557+
15041558
halt_channel(hcd, hc, qtd, DWC_OTG_HC_XFER_NYET);
15051559
goto handle_nyet_done;
15061560
}

‎drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ void dwc_otg_hcd_qh_deactivate(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh,
598598
(qh->sched_frame, frame_number)) {
599599
qh->sched_frame = frame_number;
600600
}
601-
qh->sched_frame |= 0x7;
601+
// Try to schedule on frame 0...
602+
qh->sched_frame = (qh->sched_frame + 7) & ~7;
602603
qh->start_split_frame = qh->sched_frame;
603604
}
604605
} else {

0 commit comments

Comments
 (0)