Re: Patch for stack/DMA problems in Cinergy T2 drivers (2)
Johannes Stezenbach wrote: There is a fair amount of code duplication. A better aproach would be to allocate buffers once in cinergyt2_fe_attach() (add them to struct cinergyt2_fe_state). Yes, but first I have to investigate why tuning is still quite unreliable (ie, more unreliable than in 2.6.29). Am I really the only one who has those problems with the Cinergy T2 driver in 2.6.30? -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Patch for stack/DMA problems in Cinergy T2 drivers (2)
I've found another bug in the Cinergy T2 driver: originally (ie, e.g. in kernel 2.6.23), the structure containing struct dvbt_set_parameters_msg param was allocated with kzalloc, now struct dvbt_set_parameters_msg param lives on the stack. However, the flags member of that structure is not initialized to zero (as was done by kzalloc)! -emagick -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Patch for stack/DMA problems in Cinergy T2 drivers (2)
Johannes Stezenbach wrote: There is a fair amount of code duplication. A better aproach would be to allocate buffers once in cinergyt2_fe_attach() (add them to struct cinergyt2_fe_state). That's how it was done in the old cinergyT2 driver. Does the code in DVB frontend code assure that the frontend ops are entered by only one thread at a time? -emagick -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Cinergy T2 stopped working with kernel 2.6.30
I've added dummy 32-bit variables to dvb_frontend_swzigzag_autotune() to change the frame size. Here are the results for mythweb (can tune/cannot tune): #variables i486 i586 0 ok failure 1 failureok 2 ok ok 3 failurefailure 4 failureok 5 ok ok 6 ok ok 7 ok ok 8 ok failure 9 failureok 10 ok ok 11 ok failure 12 failureok 13 ok ok 14 ok ok 15 ok ok 16 ok ok 17 ok ok 18 ok failure 19 ok failure 20 failureok There's a pattern with some exceptions. Could be an alignment-related problem. Anyone listening? -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Cinergy T2 stopped working with kernel 2.6.30
I think I've found the problem: static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) { struct cinergyt2_fe_state *state = fe-demodulator_priv; struct dvbt_set_parameters_msg param; char result[2]; int err; param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; param.tps = cpu_to_le16(compute_tps(fep)); param.freq = cpu_to_le32(fep-frequency / 1000); param.bandwidth = 8 - fep-u.ofdm.bandwidth - BANDWIDTH_8_MHZ; err = dvb_usb_generic_rw(state-d, (char *)param, sizeof(param), result, sizeof(result), 0); As dvbt_set_parameters_msg is declared with __attribute__((packed)), its alignment is 8 bits. In fact, cinergyt2_fe_set_frontend()'s param variable is not aligned on a 32-bit boundary. Note that param is passed to usb_bulk_msg(). This seems to cause DMA problems on my hardware (Atom N270 + 945GSE + ICH7M). I hope that I'm not talking to a black hole. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Patch for stack/DMA problems in Cinergy T2 drivers
There might be a more elegant solution, but this seems to work for me: --- drivers/media/dvb/dvb-usb/cinergyT2-fe.c2009-06-10 05:05:27.0 +0200 +++ drivers/media/dvb/dvb-usb/cinergyT2-fe.c2009-07-31 22:02:48.0 +0200 @@ -146,66 +146,103 @@ fe_status_t *status) { struct cinergyt2_fe_state *state = fe-demodulator_priv; - struct dvbt_get_status_msg result; - u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; + struct dvbt_get_status_msg *result; + static const u8 cmd0[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; +u8 *cmd; int ret; - ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd), (u8 *)result, - sizeof(result), 0); - if (ret 0) +cmd = kmalloc(sizeof(cmd0), GFP_KERNEL); +if (!cmd) return -ENOMEM; +memcpy(cmd, cmd0, sizeof(cmd0)); +result = kmalloc(sizeof(*result), GFP_KERNEL); +if (!result) { +kfree(cmd); +return -ENOMEM; +} + ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd0), (u8 *)result, + sizeof(*result), 0); +kfree(cmd); + if (ret 0) { +kfree(result); return ret; +} *status = 0; - if (0x - le16_to_cpu(result.gain) 30) + if (0x - le16_to_cpu(result-gain) 30) *status |= FE_HAS_SIGNAL; - if (result.lock_bits (1 6)) + if (result-lock_bits (1 6)) *status |= FE_HAS_LOCK; - if (result.lock_bits (1 5)) + if (result-lock_bits (1 5)) *status |= FE_HAS_SYNC; - if (result.lock_bits (1 4)) + if (result-lock_bits (1 4)) *status |= FE_HAS_CARRIER; - if (result.lock_bits (1 1)) + if (result-lock_bits (1 1)) *status |= FE_HAS_VITERBI; if ((*status (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) != (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) *status = ~FE_HAS_LOCK; +kfree(result); return 0; } static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber) { struct cinergyt2_fe_state *state = fe-demodulator_priv; - struct dvbt_get_status_msg status; - char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; + struct dvbt_get_status_msg *status; + static const u8 cmd0[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; +u8 *cmd; int ret; - ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd), (char *)status, - sizeof(status), 0); - if (ret 0) +cmd = kmalloc(sizeof(cmd0), GFP_KERNEL); +if (!cmd) return -ENOMEM; +memcpy(cmd, cmd0, sizeof(cmd0)); +status = kmalloc(sizeof(*status), GFP_KERNEL); +if (!status) { +kfree(cmd); +return -ENOMEM; +} + ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd0), (char *)status, + sizeof(*status), 0); +kfree(cmd); + if (ret 0) { +kfree(status); return ret; - - *ber = le32_to_cpu(status.viterbi_error_rate); +} + *ber = le32_to_cpu(status-viterbi_error_rate); +kfree(status); return 0; } static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc) { struct cinergyt2_fe_state *state = fe-demodulator_priv; - struct dvbt_get_status_msg status; - u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; + struct dvbt_get_status_msg *status; + static const u8 cmd0[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; +u8 *cmd; int ret; - ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd), (u8 *)status, - sizeof(status), 0); +cmd = kmalloc(sizeof(cmd0), GFP_KERNEL); +if (!cmd) return -ENOMEM; +memcpy(cmd, cmd0, sizeof(cmd0)); +status = kmalloc(sizeof(*status), GFP_KERNEL); +if (!status) { +kfree(cmd); +return -ENOMEM; +} + ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd0), (u8 *)status, + sizeof(*status), 0); +kfree(cmd); if (ret 0) { +kfree(status); err(cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n, ret); return ret; } - *unc = le32_to_cpu(status.uncorrected_block_count); + *unc = le32_to_cpu(status-uncorrected_block_count); +kfree(status); return 0; } @@ -213,35 +250,59 @@ u16 *strength) { struct cinergyt2_fe_state *state = fe-demodulator_priv; - struct dvbt_get_status_msg status; - char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; + struct dvbt_get_status_msg *status; + static
Re: Patch for stack/DMA problems in Cinergy T2 drivers
The patch I sent is incomplete, there are more instances of the same problem in cinergyT2-core.c. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Patch for stack/DMA problems in Cinergy T2 drivers (2)
Here's a patch for cinergyT2-core.c: --- a/drivers/media/dvb/dvb-usb/cinergyT2-fe.c 2009-06-10 05:05:27.0 +0200 +++ b/drivers/media/dvb/dvb-usb/cinergyT2-fe.c 2009-07-31 22:02:48.0 +0200 @@ -146,66 +146,103 @@ fe_status_t *status) { struct cinergyt2_fe_state *state = fe-demodulator_priv; - struct dvbt_get_status_msg result; - u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; + struct dvbt_get_status_msg *result; + static const u8 cmd0[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; +u8 *cmd; int ret; - ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd), (u8 *)result, - sizeof(result), 0); - if (ret 0) +cmd = kmalloc(sizeof(cmd0), GFP_KERNEL); +if (!cmd) return -ENOMEM; +memcpy(cmd, cmd0, sizeof(cmd0)); +result = kmalloc(sizeof(*result), GFP_KERNEL); +if (!result) { +kfree(cmd); +return -ENOMEM; +} + ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd0), (u8 *)result, + sizeof(*result), 0); +kfree(cmd); + if (ret 0) { +kfree(result); return ret; +} *status = 0; - if (0x - le16_to_cpu(result.gain) 30) + if (0x - le16_to_cpu(result-gain) 30) *status |= FE_HAS_SIGNAL; - if (result.lock_bits (1 6)) + if (result-lock_bits (1 6)) *status |= FE_HAS_LOCK; - if (result.lock_bits (1 5)) + if (result-lock_bits (1 5)) *status |= FE_HAS_SYNC; - if (result.lock_bits (1 4)) + if (result-lock_bits (1 4)) *status |= FE_HAS_CARRIER; - if (result.lock_bits (1 1)) + if (result-lock_bits (1 1)) *status |= FE_HAS_VITERBI; if ((*status (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) != (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) *status = ~FE_HAS_LOCK; +kfree(result); return 0; } static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber) { struct cinergyt2_fe_state *state = fe-demodulator_priv; - struct dvbt_get_status_msg status; - char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; + struct dvbt_get_status_msg *status; + static const u8 cmd0[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; +u8 *cmd; int ret; - ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd), (char *)status, - sizeof(status), 0); - if (ret 0) +cmd = kmalloc(sizeof(cmd0), GFP_KERNEL); +if (!cmd) return -ENOMEM; +memcpy(cmd, cmd0, sizeof(cmd0)); +status = kmalloc(sizeof(*status), GFP_KERNEL); +if (!status) { +kfree(cmd); +return -ENOMEM; +} + ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd0), (char *)status, + sizeof(*status), 0); +kfree(cmd); + if (ret 0) { +kfree(status); return ret; - - *ber = le32_to_cpu(status.viterbi_error_rate); +} + *ber = le32_to_cpu(status-viterbi_error_rate); +kfree(status); return 0; } static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc) { struct cinergyt2_fe_state *state = fe-demodulator_priv; - struct dvbt_get_status_msg status; - u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; + struct dvbt_get_status_msg *status; + static const u8 cmd0[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; +u8 *cmd; int ret; - ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd), (u8 *)status, - sizeof(status), 0); +cmd = kmalloc(sizeof(cmd0), GFP_KERNEL); +if (!cmd) return -ENOMEM; +memcpy(cmd, cmd0, sizeof(cmd0)); +status = kmalloc(sizeof(*status), GFP_KERNEL); +if (!status) { +kfree(cmd); +return -ENOMEM; +} + ret = dvb_usb_generic_rw(state-d, cmd, sizeof(cmd0), (u8 *)status, + sizeof(*status), 0); +kfree(cmd); if (ret 0) { +kfree(status); err(cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n, ret); return ret; } - *unc = le32_to_cpu(status.uncorrected_block_count); + *unc = le32_to_cpu(status-uncorrected_block_count); +kfree(status); return 0; } @@ -213,35 +250,59 @@ u16 *strength) { struct cinergyt2_fe_state *state = fe-demodulator_priv; - struct dvbt_get_status_msg status; - char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; + struct dvbt_get_status_msg *status; + static const u8 cmd0[] = {
Re: Cinergy T2 stopped working with kernel 2.6.30
The more I look into this problem the stranger it becomes. I've compiled the kernel for different CPUs: |mplayer mythtv -+ CONFIG_M486 |works works CONFIG_M586 |works cannot tune CONFIG_MCORE2|cannot tune cannot tune These results are for my Atom N270 board. On my Core2 board, the Cinergy T2 works all the time. By applying -march=i486 and -march=i586 to individual source files, I found out that dvb_frontend.c is the culprit. By editing the assembly output for dvb_frontend.c, I found out that only dvb_frontend_swzigzag_autotune() needs to be compiled with CONFIG_M486 to make the Cinergy T2 work, everything else can be compiled with CONFIG_M586. Both compiled versions of dvb_frontend_swzigzag_autotune() look OK (but I haven't yet strictly verified the assembly code). Anyway, nothing in that code should make a difference on N270 vs. Core, except for timing. Adding NOPs doesn't seem to make a difference. Any ideas? Could this be a CPU bug? -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Cinergy T2 stopped working with kernel 2.6.30
I've now compared the generated assembly code for dvb_frontend_swzigzag_autotune() built with CONFIG_M486 vs. CONFIG_M586. Both versions are correct, but the one compiled with -march=i586 (for which tuning does not work) uses more stack space (one 32-bit word). Does this ring any bells? -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Cinergy T2 stopped working with kernel 2.6.30
There are two new discoveries about my Cinergy T2 problem: - the Cinergy T2 works when attached to an Intel Core2 board, but doesn't work when attached to an Intel Atom N270 board (tuning times out) - git bisect of the Linux kernel points to a bad merge of commit 60db56422043aaa455ac7f858ce23c273220f9d9 (good) and commit be0ea69674ed95e1e98cb3687a241badc756d228 (good) yielding commit 6e15cf04860074ad032e88c306bea656bbdd0f22 (bad). So, the problem is probably interrupt-related, not dvb-usb-related. Any idea on how to continue from here? -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Cinergy T2 stopped working with kernel 2.6.30
My Cinergy T2 (T²) doesn't work with kernels 2.6.30, 2.6.30.1, and 2.6.31-rc3, but it works with kernel 2.6.29. The kernel logs dvb-usb: recv bulk message failed: -110 and the application (I've tried mythtv and mplayer) trying to access the DVB receiver times out when trying to tune to a channel. Is there anyone for whom dvb_usb_cinergyT2 of kernel 2.6.30 or later does work? -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html