Various fixes, hacks and patches for Mantis CA support.
PATCH 1/1 Various fixes, hacks and patches for Mantis CA support.
Hi,
I was asked to break up my large patch into several smaller, Signed-off-by-marked changes. I've rebased against linux-2.6 master and done some today; note that since not all of these changes are originally by me, you will probably have to consider each one separately for inclusion (although they largely make sense independently of each other).
My interest in this project is, unfortunately, waning, since it appears there is no hardware documentation and very little active maintenance of the driver, which means that getting it the final step of the way is going to be hard (and probably not worth it). However, hopefully someone else will find the patch set useful nevertheless.
/* Steinar */
Signature · 1 line
Homepage: http://www.sesse.net/
PATCH 1/11 Don't reset IRQ0 if it's not already set.
From: "Steinar H. Gunderson" <[email protected]>
By Marko Ristola; see http://patchwork.linuxtv.org/patch/8776/ .
--- drivers/media/dvb/mantis/mantis_cards.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/media/dvb/mantis/mantis_cards.c +10 -11
@@ -73,7 +73,7 @@ static char *label[10] = {static irqreturn_t mantis_irq_handler (int irq,void *dev_id) { -u32 stat =0 , mask =0 , lstat =0 ; +u32 stat =0 , mask =0 ;u32 rst_stat =0 , rst_mask =0 ;struct mantis_pci *mantis;
@@ -88,19 +88,9 @@ static irqreturn_t mantis_irq_handler(int irq, void *dev_id) stat =mmread (MANTIS_INT_STAT ); mask =mmread (MANTIS_INT_MASK ); - lstat = stat & ~MANTIS_INT_RISCSTAT ;if (!(stat & mask))return IRQ_NONE ; - rst_mask =MANTIS_GPIF_WRACK | -MANTIS_GPIF_OTHERR | -MANTIS_SBUF_WSTO | -MANTIS_GPIF_EXTIRQ ; - - rst_stat =mmread (MANTIS_GPIF_STATUS ); - rst_stat &= rst_mask; -mmwrite (rst_stat,MANTIS_GPIF_STATUS ); - mantis->mantis_int_stat = stat; mantis->mantis_int_mask = mask;dprintk (MANTIS_DEBUG ,0 ,"\n-- Stat=<%02x> Mask=<%02x> --" , stat, mask);
@@ -109,6 +99,15 @@ static irqreturn_t mantis_irq_handler(int irq, void *dev_id) }if (stat &MANTIS_INT_IRQ0 ) {dprintk (MANTIS_DEBUG ,0 ,"<%s>" , label[1 ]); + + rst_mask =MANTIS_GPIF_WRACK | +MANTIS_GPIF_OTHERR | +MANTIS_SBUF_WSTO | +MANTIS_GPIF_EXTIRQ ; + + rst_stat =mmread (MANTIS_GPIF_STATUS ); +mmwrite (rst_stat & rst_mask,MANTIS_GPIF_STATUS ); + mantis->gpif_status = rst_stat;wake_up (&ca->hif_write_wq);schedule_work (&ca->hif_evm_work);
Signature · 1 line
1.7.9.5
PATCH 2/11 Clear out MANTIS_INT_RISCSTAT when printing status bits.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
Clear out MANTIS_INT_RISCSTAT for debugging, so that status words from the RISC do not show up as "Unknown" bits in the debug display.
--- drivers/media/dvb/mantis/mantis_cards.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/dvb/mantis/mantis_cards.c +2 -1
@@ -141,7 +141,8 @@ static irqreturn_t mantis_irq_handler(int irq, void *dev_id)wake_up (&mantis->i2c_wq); }mmwrite (stat,MANTIS_INT_STAT ); - stat &= ~(MANTIS_INT_RISCEN | MANTIS_INT_I2CDONE | + stat &= ~(MANTIS_INT_RISCSTAT | + MANTIS_INT_RISCEN | MANTIS_INT_I2CDONE | MANTIS_INT_I2CRACK | MANTIS_INT_PCMCIA7 | MANTIS_INT_PCMCIA6 | MANTIS_INT_PCMCIA5 | MANTIS_INT_PCMCIA4 | MANTIS_INT_PCMCIA3 |
Signature · 1 line
1.7.9.5
PATCH 3/11 Hack to fix a mutex issue in the DVB layer.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
dvb_usercopy(), which is called on all ioctls, not only copies data to and from userspace, but also takes a lock on the file descriptor, which means that only one ioctl can run at a time. This means that if one thread of mumudvb is busy trying to get, say, the SNR from the frontend (which can hang due to the issue above), the CAM thread's ioctl(fd, CA_GET_SLOT_INFO, ...) will hang, even though it doesn't need to communicate with the hardware at all. This obviously requires a better fix, but I don't know the generic DVB layer well enough to say what it is. Maybe it's some sort of remnant of from when all ioctl()s took the BKL. Note that on UMP kernels without preemption, mutex_lock is to the best of my knowledge a no-op, so these delay issues would not show up on non-SMP.
--- drivers/media/dvb/dvb-core/dvbdev.c | 2 -- 1 file changed, 2 deletions(-)
drivers/media/dvb/dvb-core/dvbdev.c +0 -2
@@ -417,10 +417,8 @@ int dvb_usercopy(struct file *file, }/* call driver */ -mutex_lock (&dvbdev_mutex);if ((err =func (file, cmd, parg)) == -ENOIOCTLCMD ) err = -EINVAL ; -mutex_unlock (&dvbdev_mutex);if (err <0 ) goto out;
Signature · 1 line
1.7.9.5
Re: [PATCH 03/11] Hack to fix a mutex issue in the DVB layer.
Em 01-04-2012 12:53, Steinar H. Gunderson escreveu:
Quoted 23 lines
From: "Steinar H. Gunderson" <[email protected]>
dvb_usercopy(), which is called on all ioctls, not only copies data to and from userspace, but also takes a lock on the file descriptor, which means that only one ioctl can run at a time. This means that if one thread of mumudvb is busy trying to get, say, the SNR from the frontend (which can hang due to the issue above), the CAM thread'sioctl(fd, CA_GET_SLOT_INFO, ...)will hang, even though it doesn't need to communicate with the hardware at all. This obviously requires a better fix, but I don't know the generic DVB layer well enough to say what it is. Maybe it's some sort of remnant of from when all ioctl()s took the BKL. Note that on UMP kernels without preemption,mutex_lockis to the best of my knowledge a no-op, so these delay issues would not show up on non-SMP.Signed-off-by Steinar H. Gunderson <[email protected]>--- drivers/media/dvb/dvb-core/dvbdev.c | 2 -- 1 file changed, 2 deletions(-)drivers/media/dvb/dvb-core/dvbdev.c +0
-0
drivers/media/dvb/dvb-core/dvbdev.c int dvb_usercopy(struct file *file, · line 423
Quoted 7 lines
drivers/media/dvb/dvb-core/dvbdev.c +0
-2@@ -417,10 +417,8 @@ int dvb_usercopy(struct file *file, }/* call driver */ -mutex_lock (&dvbdev_mutex);if ((err =func (file, cmd, parg)) == -ENOIOCTLCMD ) err = -EINVAL ; -mutex_unlock (&dvbdev_mutex);
As-is, this would be too risky, as it may break random drivers.
A change like that would require to push down the mutex lock into each caller for dvb_user_copy:
drivers/media/dvb/dvb-core/dmxdev.c: return dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);drivers/media/dvb/dvb-core/dmxdev.c: return dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);drivers/media/dvb/dvb-core/dvb_ca_en50221.c: return dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);drivers/media/dvb/dvb-core/dvb_net.c: return dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);drivers/media/dvb/dvb-core/dvbdev.c: return dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
drivers/media/dvb/dvb-core/dvbdev.c:int dvb_usercopy(struct file *file, drivers/media/dvb/dvb-core/dvbdev.h:we simply define out own dvb_usercopy(), which will hopefully become drivers/media/dvb/dvb-core/dvbdev.h:extern int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
$ git grep kernel_ioctl drivers/media/dvb/ drivers/media/dvb/dvb-core/dvb_frontend.c: .kernel_ioctl = dvb_frontend_ioctl drivers/media/dvb/dvb-core/dvbdev.c: if (!dvbdev->kernel_ioctl) drivers/media/dvb/dvb-core/dvbdev.c: return dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl); drivers/media/dvb/dvb-core/dvbdev.h: int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg); drivers/media/dvb/firewire/firedtv-ci.c: .kernel_ioctl = fdtv_ca_ioctl, drivers/media/dvb/ttpci/av7110.c: .kernel_ioctl = dvb_osd_ioctl, drivers/media/dvb/ttpci/av7110_av.c: .kernel_ioctl = dvb_video_ioctl, drivers/media/dvb/ttpci/av7110_av.c: .kernel_ioctl = dvb_audio_ioctl, drivers/media/dvb/ttpci/av7110_ca.c: .kernel_ioctl = dvb_ca_ioctl,
And optimize the code there to avoid uneeded locks.
Quoted 3 lines
drivers/media/dvb/dvb-core/dvbdev.c +0
-0if (err <0 ) goto out;
PATCH 4/11 Show timeouts on I2C transfers.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
On I2C reads and writes, show if we had any timeouts in the debug output.
--- drivers/media/dvb/mantis/mantis_i2c.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/media/dvb/mantis/mantis_i2c.c +24 -2
@@ -38,6 +38,7 @@static int mantis_i2c_read (struct mantis_pci *mantis,const struct i2c_msg *msg) {u32 rxd, i, stat, trials; +u32 timeouts =0 ;dprintk (MANTIS_INFO ,0 ," %s: Address=[0x%02x] <R>[ " , __func__, msg->addr);
@@ -60,6 +61,9 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)if (stat &MANTIS_INT_I2CDONE )break ; } +if (trials ==TRIALS ) { + ++timeouts; + }dprintk (MANTIS_TMG ,0 ,"I2CDONE: trials=%d\n" , trials);
@@ -69,6 +73,9 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)if (stat &MANTIS_INT_I2CRACK )break ; } +if (trials ==TRIALS ) { + ++timeouts; + }dprintk (MANTIS_TMG ,0 ,"I2CRACK: trials=%d\n" , trials);
@@ -76,7 +83,11 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg) msg->buf[i] = (u8)((rxd >>8 ) &0xFF );dprintk (MANTIS_INFO ,0 ,"%02x " , msg->buf[i]); } -dprintk (MANTIS_INFO ,0 ,"]\n" ); +if (timeouts) { +dprintk (MANTIS_INFO ,0 ,"] %d timeouts\n" , timeouts); + }else { +dprintk (MANTIS_INFO ,0 ,"]\n" ); + }return 0 ; }
@@ -85,6 +96,7 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg {int i;u32 txd =0 , stat, trials; +u32 timeouts =0 ;dprintk (MANTIS_INFO ,0 ," %s: Address=[0x%02x] <W>[ " , __func__, msg->addr);
@@ -108,6 +120,9 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msgif (stat &MANTIS_INT_I2CDONE )break ; } +if (trials ==TRIALS ) { + ++timeouts; + }dprintk (MANTIS_TMG ,0 ,"I2CDONE: trials=%d\n" , trials);
@@ -117,10 +132,17 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msgif (stat &MANTIS_INT_I2CRACK )break ; } +if (trials ==TRIALS ) { + ++timeouts; + }dprintk (MANTIS_TMG ,0 ,"I2CRACK: trials=%d\n" , trials); } -dprintk (MANTIS_INFO ,0 ,"]\n" ); +if (timeouts) { +dprintk (MANTIS_INFO ,0 ,"] %d timeouts\n" , timeouts); + }else { +dprintk (MANTIS_INFO ,0 ,"]\n" ); + }return 0 ; }
Signature · 1 line
1.7.9.5
Re: [PATCH 04/11] Show timeouts on I2C transfers.
I had a plan to rework I2C handling a lot more,
than log the changes.
I wrote a patch that uses I2C IRQ.
I had a feeling that it worked well (with old single CPU desktop computer):
framerate with HDTV was low, but it was glitchless.
Do you want to have the patch to be sent for you?
I think that I solved in the patch "robust I2C command + exact IRQ response for that command", so that those two will not get out of sync.
I tried to rework the patch to make a bit smaller patch, but I couldn't test the new one: hardware is too broken.
Regards,
Marko
01.04.2012 18:53, Steinar H. Gunderson kirjoitti:
Quoted 91 lines
From: "Steinar H. Gunderson" <[email protected]>
On I2C reads and writes, show if we had any timeouts in the debug output.
Signed-off-by Steinar H. Gunderson <[email protected]>--- drivers/media/dvb/mantis/mantis_i2c.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)drivers/media/dvb/mantis/mantis_i2c.c +24
-2@@ -38,6 +38,7 @@static int mantis_i2c_read (struct mantis_pci *mantis,const struct i2c_msg *msg) {u32 rxd, i, stat, trials; +u32 timeouts =0 ;dprintk (MANTIS_INFO ,0 ," %s: Address=[0x%02x] <R>[ " , __func__, msg->addr);@@ -60,6 +61,9 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)if (stat &MANTIS_INT_I2CDONE )break ; } +if (trials ==TRIALS ) { + ++timeouts; + }dprintk (MANTIS_TMG ,0 ,"I2CDONE: trials=%d\n" , trials);@@ -69,6 +73,9 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)if (stat &MANTIS_INT_I2CRACK )break ; } +if (trials ==TRIALS ) { + ++timeouts; + }dprintk (MANTIS_TMG ,0 ,"I2CRACK: trials=%d\n" , trials);@@ -76,7 +83,11 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg) msg->buf[i] = (u8)((rxd >>8 ) &0xFF );dprintk (MANTIS_INFO ,0 ,"%02x " , msg->buf[i]); } -dprintk (MANTIS_INFO ,0 ,"]\n" ); +if (timeouts) { +dprintk (MANTIS_INFO ,0 ,"] %d timeouts\n" , timeouts); + }else { +dprintk (MANTIS_INFO ,0 ,"]\n" ); + }return 0 ; }@@ -85,6 +96,7 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg {int i;u32 txd =0 , stat, trials; +u32 timeouts =0 ;dprintk (MANTIS_INFO ,0 ," %s: Address=[0x%02x] <W>[ " , __func__, msg->addr);@@ -108,6 +120,9 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msgif (stat &MANTIS_INT_I2CDONE )break ; } +if (trials ==TRIALS ) { + ++timeouts; + }dprintk (MANTIS_TMG ,0 ,"I2CDONE: trials=%d\n" , trials);@@ -117,10 +132,17 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msgif (stat &MANTIS_INT_I2CRACK )break ; } +if (trials ==TRIALS ) { + ++timeouts; + }dprintk (MANTIS_TMG ,0 ,"I2CRACK: trials=%d\n" , trials); } -dprintk (MANTIS_INFO ,0 ,"]\n" ); +if (timeouts) { +dprintk (MANTIS_INFO ,0 ,"] %d timeouts\n" , timeouts); + }else { +dprintk (MANTIS_INFO ,0 ,"]\n" ); + }return 0 ; }
Re: [PATCH 04/11] Show timeouts on I2C transfers.
Quoted 5 lines · Marko Ristola
I wrote a patch that uses I2C IRQ.
I had a feeling that it worked well (with old single CPU desktop computer):
framerate with HDTV was low, but it was glitchless.Do you want to have the patch to be sent for you?
Sure, send it if you want to.
/* Steinar */
Signature · 1 line
Homepage: http://www.sesse.net/
PATCH 5/11 Slightly more friendly debugging output.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
Say what address we read/write from/to. This is useful when trying to trace where the debug output comes from, and which accesses fail, if any.
--- drivers/media/dvb/mantis/mantis_hif.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/dvb/mantis/mantis_hif.c +5 -4
@@ -91,8 +91,9 @@ int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)struct mantis_pci *mantis = ca->ca_priv;u32 hif_addr =0 , data, count =4 ; -dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF Mem Read" , mantis->num); +dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF Mem Read of 0x%x" , mantis->num, addr);mutex_lock (&ca->ca_lock); + hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr &= ~MANTIS_GPIF_PCMCIAIOM ; hif_addr |=MANTIS_HIF_STATUS ;
@@ -110,7 +111,7 @@ int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr) } data =mmread (MANTIS_GPIF_DIN );mutex_unlock (&ca->ca_lock); -dprintk (MANTIS_DEBUG ,1 ,"Mem Read: 0x%02x" , data); +dprintk (MANTIS_DEBUG ,1 ,"Mem Read: 0x%02x from 0x%02x" , data, addr);return (data >>24 ) &0xff ; }
@@ -148,7 +149,7 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)struct mantis_pci *mantis = ca->ca_priv;u32 data, hif_addr =0 ; -dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF I/O Read" , mantis->num); +dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF I/O Read of 0x%x" , mantis->num, addr);mutex_lock (&ca->ca_lock); hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr |=MANTIS_GPIF_PCMCIAIOM ;
@@ -166,7 +167,7 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)return -EREMOTEIO ; } data =mmread (MANTIS_GPIF_DIN ); -dprintk (MANTIS_DEBUG ,1 ,"I/O Read: 0x%02x" , data); +dprintk (MANTIS_DEBUG ,1 ,"I/O Read: 0x%02x from 0x%02x" , data, addr);udelay (50 );mutex_unlock (&ca->ca_lock);
Signature · 1 line
1.7.9.5
PATCH 6/11 Replace ca_lock by a slightly more general int_stat_lock.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
This lock is ideally held when banging on MANTIS_INT_STAT. (I have no hardware documentation, so I'm afraid I don't really know the specifics here.)
--- drivers/media/dvb/mantis/mantis_ca.c | 2 -- drivers/media/dvb/mantis/mantis_cards.c | 1 + drivers/media/dvb/mantis/mantis_common.h | 1 + drivers/media/dvb/mantis/mantis_hif.c | 32 +++++++++++++++--------------- drivers/media/dvb/mantis/mantis_i2c.c | 4 ++++ drivers/media/dvb/mantis/mantis_link.h | 1 - 6 files changed, 22 insertions(+), 19 deletions(-)
drivers/media/dvb/mantis/mantis_ca.c +0 -2
@@ -172,8 +172,6 @@ int mantis_ca_init(struct mantis_pci *mantis) ca->en50221.poll_slot_status = mantis_slot_status; ca->en50221.data = ca; -mutex_init (&ca->ca_lock); -init_waitqueue_head (&ca->hif_data_wq);init_waitqueue_head (&ca->hif_opdone_wq);init_waitqueue_head (&ca->hif_write_wq);
drivers/media/dvb/mantis/mantis_cards.c +1 -0
@@ -179,6 +179,7 @@ static int __devinit mantis_pci_probe(struct pci_dev *pdev, const struct pci_dev config = (struct mantis_hwconfig *) pci_id->driver_data; config->irq_handler = &mantis_irq_handler; mantis->hwconfig = config; +mutex_init (&mantis->int_stat_lock); err =mantis_pci_init (mantis);if (err) {
drivers/media/dvb/mantis/mantis_common.h +1 -0
@@ -164,6 +164,7 @@ struct mantis_pci {u32 gpif_status;struct mantis_ca *mantis_ca; +struct mutex int_stat_lock;wait_queue_head_t uart_wq;struct work_struct uart_work;
drivers/media/dvb/mantis/mantis_hif.c +16 -16
@@ -92,7 +92,7 @@ int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)u32 hif_addr =0 , data, count =4 ;dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF Mem Read of 0x%x" , mantis->num, addr); -mutex_lock (&ca->ca_lock); +mutex_lock (&mantis->int_stat_lock); hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr &= ~MANTIS_GPIF_PCMCIAIOM ;
@@ -106,11 +106,11 @@ int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)if (mantis_hif_sbuf_opdone_wait (ca) !=0 ) {dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): GPIF Smart Buffer operation failed" , mantis->num); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);return -EREMOTEIO ; } data =mmread (MANTIS_GPIF_DIN ); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);dprintk (MANTIS_DEBUG ,1 ,"Mem Read: 0x%02x from 0x%02x" , data, addr);return (data >>24 ) &0xff ; }
@@ -122,7 +122,7 @@ int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)u32 hif_addr =0 ;dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF Mem Write" , mantis->num); -mutex_lock (&ca->ca_lock); +mutex_lock (&mantis->int_stat_lock); hif_addr &= ~MANTIS_GPIF_HIFRDWRN ; hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr &= ~MANTIS_GPIF_PCMCIAIOM ;
@@ -135,11 +135,11 @@ int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)if (mantis_hif_write_wait (ca) !=0 ) {dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): HIF Smart Buffer operation failed" , mantis->num); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);return -EREMOTEIO ; }dprintk (MANTIS_DEBUG ,1 ,"Mem Write: (0x%02x to 0x%02x)" , data, addr); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);return 0 ; }
@@ -150,7 +150,7 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)u32 data, hif_addr =0 ;dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF I/O Read of 0x%x" , mantis->num, addr); -mutex_lock (&ca->ca_lock); +mutex_lock (&mantis->int_stat_lock); hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr |=MANTIS_GPIF_PCMCIAIOM ; hif_addr |=MANTIS_HIF_STATUS ;
@@ -163,13 +163,13 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)if (mantis_hif_sbuf_opdone_wait (ca) !=0 ) {dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): HIF Smart Buffer operation failed" , mantis->num); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);return -EREMOTEIO ; } data =mmread (MANTIS_GPIF_DIN );dprintk (MANTIS_DEBUG ,1 ,"I/O Read: 0x%02x from 0x%02x" , data, addr);udelay (50 ); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);return (u8 ) data; }
@@ -180,7 +180,7 @@ int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data)u32 hif_addr =0 ;dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF I/O Write" , mantis->num); -mutex_lock (&ca->ca_lock); +mutex_lock (&mantis->int_stat_lock); hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr &= ~MANTIS_GPIF_HIFRDWRN ; hif_addr |=MANTIS_GPIF_PCMCIAIOM ;
@@ -192,11 +192,11 @@ int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data)if (mantis_hif_write_wait (ca) !=0 ) {dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): HIF Smart Buffer operation failed" , mantis->num); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);return -EREMOTEIO ; }dprintk (MANTIS_DEBUG ,1 ,"I/O Write: (0x%02x to 0x%02x)" , data, addr); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);udelay (50 );return 0 ;
@@ -211,7 +211,7 @@ int mantis_hif_init(struct mantis_ca *ca) slot[0 ].slave_cfg =0x70773028 ;dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Initializing Mantis Host Interface" , mantis->num); -mutex_lock (&ca->ca_lock); +mutex_lock (&mantis->int_stat_lock); irqcfg =mmread (MANTIS_GPIF_IRQCFG ); irqcfg =MANTIS_MASK_BRRDY | MANTIS_MASK_WRACK |
@@ -221,7 +221,7 @@ int mantis_hif_init(struct mantis_ca *ca)MANTIS_MASK_OVFLW ;mmwrite (irqcfg,MANTIS_GPIF_IRQCFG ); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock);return 0 ; }
@@ -232,9 +232,9 @@ void mantis_hif_exit(struct mantis_ca *ca)u32 irqcfg;dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Exiting Mantis Host Interface" , mantis->num); -mutex_lock (&ca->ca_lock); +mutex_lock (&mantis->int_stat_lock); irqcfg =mmread (MANTIS_GPIF_IRQCFG ); irqcfg &= ~MANTIS_MASK_BRRDY ;mmwrite (irqcfg,MANTIS_GPIF_IRQCFG ); -mutex_unlock (&ca->ca_lock); +mutex_unlock (&mantis->int_stat_lock); }
drivers/media/dvb/mantis/mantis_i2c.c +4 -0
@@ -263,12 +263,14 @@ int __devinit mantis_i2c_init(struct mantis_pci *mantis)dprintk (MANTIS_DEBUG ,1 ,"Initializing I2C .." ); +mutex_lock (&mantis->int_stat_lock); intstat =mmread (MANTIS_INT_STAT ); intmask =mmread (MANTIS_INT_MASK );mmwrite (intstat,MANTIS_INT_STAT );dprintk (MANTIS_DEBUG ,1 ,"Disabling I2C interrupt" ); intmask =mmread (MANTIS_INT_MASK );mmwrite ((intmask & ~MANTIS_INT_I2CDONE ),MANTIS_INT_MASK ); +mutex_unlock (&mantis->int_stat_lock);return 0 ; }
@@ -279,8 +281,10 @@ int mantis_i2c_exit(struct mantis_pci *mantis)u32 intmask;dprintk (MANTIS_DEBUG ,1 ,"Disabling I2C interrupt" ); +mutex_lock (&mantis->int_stat_lock); intmask =mmread (MANTIS_INT_MASK );mmwrite ((intmask & ~MANTIS_INT_I2CDONE ),MANTIS_INT_MASK ); +mutex_unlock (&mantis->int_stat_lock);dprintk (MANTIS_DEBUG ,1 ,"Removing I2C adapter" );return i2c_del_adapter (&mantis->adapter);
drivers/media/dvb/mantis/mantis_link.h +0 -1
@@ -61,7 +61,6 @@ struct mantis_ca {void *ca_priv;struct dvb_ca_en50221 en50221; -struct mutex ca_lock; };/* CA */
Signature · 1 line
1.7.9.5
PATCH 7/11 Fix a ton of SMP-unsafe accesses.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
Basically a lot of the members of mantis_ca were accessed from several threads without a mutex, which is a big no-no; I've mostly changed to using atomic operations here, although I also added some locks were it made sense (e.g. when resetting the CAM).
--- drivers/media/dvb/mantis/mantis_ca.c | 14 ++++++++++++++ drivers/media/dvb/mantis/mantis_common.h | 2 +- drivers/media/dvb/mantis/mantis_evm.c | 9 +++++++-- drivers/media/dvb/mantis/mantis_hif.c | 25 ++++++++++++++++++++----- drivers/media/dvb/mantis/mantis_link.h | 2 +- drivers/media/dvb/mantis/mantis_reg.h | 6 ++++-- 6 files changed, 47 insertions(+), 11 deletions(-)
drivers/media/dvb/mantis/mantis_ca.c +14 -0
@@ -95,11 +95,25 @@ static int mantis_ca_slot_reset(struct dvb_ca_en50221 *en50221, int slot)struct mantis_pci *mantis = ca->ca_priv;dprintk (MANTIS_DEBUG ,1 ,"Slot(%d): Slot RESET" , slot); +mutex_lock (&mantis->int_stat_lock); +if (test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event)) { +dprintk (MANTIS_NOTICE ,1 ,"Slot(%d): Reset operation done before it started!" , slot); + }udelay (500 );/* Wait.. */ mmwrite (0xda ,MANTIS_PCMCIA_RESET );/* Leading edge assert */ udelay (500 );mmwrite (0x00 ,MANTIS_PCMCIA_RESET );/* Trailing edge deassert */ msleep (1000 ); + +if (wait_event_timeout (ca->hif_opdone_wq, +test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event), +msecs_to_jiffies (500 )) == -ERESTARTSYS ) { + +dprintk (MANTIS_ERROR ,1 ,"Slot(%d): Reset timeout!" , slot); + }else { +dprintk (MANTIS_DEBUG ,1 ,"Slot(%d): Reset complete" , slot); + } +mutex_unlock (&mantis->int_stat_lock);dvb_ca_en50221_camready_irq (&ca->en50221,0 );return 0 ;
drivers/media/dvb/mantis/mantis_common.h +1 -1
@@ -161,7 +161,7 @@ struct mantis_pci {/* A12 A13 A14 */ u32 gpio_status; -u32 gpif_status; +volatile unsigned long gpif_status;struct mantis_ca *mantis_ca;struct mutex int_stat_lock;
drivers/media/dvb/mantis/mantis_evm.c +7 -2
@@ -20,6 +20,7 @@#include <linux/kernel.h> +#include <linux/atomic.h> #include <linux/signal.h> #include <linux/sched.h> #include <linux/interrupt.h>
@@ -87,10 +88,14 @@ static void mantis_hifevm_work(struct work_struct *work)if (gpif_stat &MANTIS_SBUF_EMPTY )dprintk (MANTIS_DEBUG ,1 ,"Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty" , mantis->num); -if (gpif_stat &MANTIS_SBUF_OPDONE ) { +if (gpif_stat &MANTIS_SBUF_OPDONE )dprintk (MANTIS_DEBUG ,1 ,"Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete" , mantis->num); + +if (gpif_stat &MANTIS_SBUF_OPDONE ) { ca->sbuf_status =MANTIS_SBUF_DATA_AVAIL ; - ca->hif_event =MANTIS_SBUF_OPDONE ; +if (test_and_set_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event)) { +dprintk (MANTIS_NOTICE ,1 ,"Operation done, but SBUF_OPDONE bit was already set!" ); + }wake_up (&ca->hif_opdone_wq); } }
drivers/media/dvb/mantis/mantis_hif.c +20 -5
@@ -22,6 +22,7 @@#include <linux/signal.h> #include <linux/sched.h> +#include <linux/atomic.h> #include <linux/interrupt.h> #include <asm/io.h>
@@ -45,25 +46,23 @@ static int mantis_hif_sbuf_opdone_wait(struct mantis_ca *ca)int rc =0 ;if (wait_event_timeout (ca->hif_opdone_wq, - ca->hif_event &MANTIS_SBUF_OPDONE , +test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event),msecs_to_jiffies (500 )) == -ERESTARTSYS ) {dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): Smart buffer operation timeout !" , mantis->num); rc = -EREMOTEIO ; }dprintk (MANTIS_DEBUG ,1 ,"Smart Buffer Operation complete" ); - ca->hif_event &= ~MANTIS_SBUF_OPDONE ;return rc; }static int mantis_hif_write_wait (struct mantis_ca *ca) {struct mantis_pci *mantis = ca->ca_priv; -u32 opdone =0 , timeout =0 ;int rc =0 ;if (wait_event_timeout (ca->hif_write_wq, - mantis->gpif_status &MANTIS_GPIF_WRACK , +test_and_clear_bit (MANTIS_GPIF_WRACK_BIT , &mantis->gpif_status),msecs_to_jiffies (500 )) == -ERESTARTSYS ) {dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): Write ACK timed out !" , mantis->num);
@@ -81,7 +80,10 @@ static int mantis_hif_write_wait(struct mantis_ca *ca)break ; } } -dprintk (MANTIS_DEBUG ,1 ,"HIF Write success" ); +if (mantis_hif_sbuf_opdone_wait (ca) !=0 ) { +dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): Write operation timeout !" , mantis->num); + rc = -ETIMEDOUT ; + }return rc; }
@@ -94,6 +96,10 @@ int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF Mem Read of 0x%x" , mantis->num, addr);mutex_lock (&mantis->int_stat_lock); +if (test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event)) { +dprintk (MANTIS_NOTICE ,1 ,"Adapter(%d) Slot(0): Read operation done before it started!" , mantis->num); + } + hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr &= ~MANTIS_GPIF_PCMCIAIOM ; hif_addr |=MANTIS_HIF_STATUS ;
@@ -123,6 +129,9 @@ int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF Mem Write" , mantis->num);mutex_lock (&mantis->int_stat_lock); +if (test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event)) { +dprintk (MANTIS_NOTICE ,1 ,"Adapter(%d) Slot(0): Write operation done before it started!" , mantis->num); + } hif_addr &= ~MANTIS_GPIF_HIFRDWRN ; hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr &= ~MANTIS_GPIF_PCMCIAIOM ;
@@ -151,6 +160,9 @@ int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr)dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF I/O Read of 0x%x" , mantis->num, addr);mutex_lock (&mantis->int_stat_lock); +if (test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event)) { +dprintk (MANTIS_NOTICE ,1 ,"Adapter(%d) Slot(0): I/O read operation done before it started!" , mantis->num); + } hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr |=MANTIS_GPIF_PCMCIAIOM ; hif_addr |=MANTIS_HIF_STATUS ;
@@ -181,6 +193,9 @@ int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data)dprintk (MANTIS_DEBUG ,1 ,"Adapter(%d) Slot(0): Request HIF I/O Write" , mantis->num);mutex_lock (&mantis->int_stat_lock); +if (test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event)) { +dprintk (MANTIS_NOTICE ,1 ,"Adapter(%d) Slot(0): I/O write operation done before it started!" , mantis->num); + } hif_addr &= ~MANTIS_GPIF_PCMCIAREG ; hif_addr &= ~MANTIS_GPIF_HIFRDWRN ; hif_addr |=MANTIS_GPIF_PCMCIAIOM ;
drivers/media/dvb/mantis/mantis_link.h +1 -1
@@ -48,7 +48,7 @@ struct mantis_ca {struct work_struct hif_evm_work; -u32 hif_event; +volatile unsigned long hif_event;wait_queue_head_t hif_opdone_wq;wait_queue_head_t hif_brrdyw_wq;wait_queue_head_t hif_data_wq;
drivers/media/dvb/mantis/mantis_reg.h +4 -2
@@ -152,11 +152,13 @@#define MANTIS_GPIF_STATUS 0x9c#define MANTIS_SBUF_KILLOP (0x01 << 15) -#define MANTIS_SBUF_OPDONE (0x01 << 14) +#define MANTIS_SBUF_OPDONE_BIT 14 +#define MANTIS_SBUF_OPDONE (0x01 << MANTIS_SBUF_OPDONE_BIT)#define MANTIS_SBUF_EMPTY (0x01 << 13)#define MANTIS_GPIF_DETSTAT (0x01 << 9)#define MANTIS_GPIF_INTSTAT (0x01 << 8) -#define MANTIS_GPIF_WRACK (0x01 << 7) +#define MANTIS_GPIF_WRACK_BIT 7 +#define MANTIS_GPIF_WRACK (0x01 << MANTIS_GPIF_WRACK_BIT)#define MANTIS_GPIF_BRRDY (0x01 << 6)#define MANTIS_SBUF_OVFLW (0x01 << 5)#define MANTIS_GPIF_OTHERR (0x01 << 4)
Signature · 1 line
1.7.9.5
PATCH 8/11 Remove some unused structure members.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
--- drivers/media/dvb/mantis/mantis_evm.c | 12 ++++-------- drivers/media/dvb/mantis/mantis_link.h | 8 -------- 2 files changed, 4 insertions(+), 16 deletions(-)
drivers/media/dvb/mantis/mantis_evm.c +4 -8
@@ -42,10 +42,7 @@ static void mantis_hifevm_work(struct work_struct *work) struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);struct mantis_pci *mantis = ca->ca_priv; -u32 gpif_stat, gpif_mask; - - gpif_stat =mmread (MANTIS_GPIF_STATUS ); - gpif_mask =mmread (MANTIS_GPIF_IRQCFG ); +u32 gpif_stat =mmread (MANTIS_GPIF_STATUS );if (gpif_stat &MANTIS_GPIF_DETSTAT ) {if (gpif_stat &MANTIS_CARD_PLUGIN ) {
@@ -67,13 +64,13 @@ static void mantis_hifevm_work(struct work_struct *work) } } -if (mantis->gpif_status &MANTIS_GPIF_EXTIRQ ) +if (gpif_stat &MANTIS_GPIF_EXTIRQ )dprintk (MANTIS_DEBUG ,1 ,"Event Mgr: Adapter(%d) Slot(0): Ext IRQ" , mantis->num); -if (mantis->gpif_status &MANTIS_SBUF_WSTO ) +if (gpif_stat &MANTIS_SBUF_WSTO )dprintk (MANTIS_DEBUG ,1 ,"Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout" , mantis->num); -if (mantis->gpif_status &MANTIS_GPIF_OTHERR ) +if (gpif_stat &MANTIS_GPIF_OTHERR )dprintk (MANTIS_DEBUG ,1 ,"Event Mgr: Adapter(%d) Slot(0): Alignment Error" , mantis->num);if (gpif_stat &MANTIS_SBUF_OVFLW )
@@ -92,7 +89,6 @@ static void mantis_hifevm_work(struct work_struct *work)dprintk (MANTIS_DEBUG ,1 ,"Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete" , mantis->num);if (gpif_stat &MANTIS_SBUF_OPDONE ) { - ca->sbuf_status =MANTIS_SBUF_DATA_AVAIL ;if (test_and_set_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event)) {dprintk (MANTIS_NOTICE ,1 ,"Operation done, but SBUF_OPDONE bit was already set!" ); }
drivers/media/dvb/mantis/mantis_link.h +0 -8
@@ -25,12 +25,6 @@#include <linux/workqueue.h> #include "dvb_ca_en50221.h" -enum mantis_sbuf_status { -MANTIS_SBUF_DATA_AVAIL =1 , -MANTIS_SBUF_DATA_EMPTY =2 , -MANTIS_SBUF_DATA_OVFLW =3 -}; -struct mantis_slot {u32 timeout;u32 slave_cfg;
@@ -54,8 +48,6 @@ struct mantis_ca {wait_queue_head_t hif_data_wq;wait_queue_head_t hif_write_wq;/* HIF Write op */ -enum mantis_sbuf_status sbuf_status; -enum mantis_slot_state slot_state;void *ca_priv;
Signature · 1 line
1.7.9.5
PATCH 9/11 Correct wait_event_timeout error return check.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
wait_event_timeout() returns 0 on timeout, not -ERESTARTSYS. Note that since this actually causes timeouts to be handled, it makes the CA situation a lot worse without the next patch in the series.
--- drivers/media/dvb/mantis/mantis_hif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/dvb/mantis/mantis_hif.c +2 -2
@@ -47,7 +47,7 @@ static int mantis_hif_sbuf_opdone_wait(struct mantis_ca *ca)if (wait_event_timeout (ca->hif_opdone_wq,test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event), -msecs_to_jiffies (500 )) == -ERESTARTSYS ) { +msecs_to_jiffies (500 )) ==0 ) {dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): Smart buffer operation timeout !" , mantis->num); rc = -EREMOTEIO ;
@@ -63,7 +63,7 @@ static int mantis_hif_write_wait(struct mantis_ca *ca)if (wait_event_timeout (ca->hif_write_wq,test_and_clear_bit (MANTIS_GPIF_WRACK_BIT , &mantis->gpif_status), -msecs_to_jiffies (500 )) == -ERESTARTSYS ) { +msecs_to_jiffies (500 )) ==0 ) {dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): Write ACK timed out !" , mantis->num); rc = -EREMOTEIO ;
Signature · 1 line
1.7.9.5
PATCH 10/11 Ignore timeouts waiting for the IRQ0 flag.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
As others have noticed, sometimes, especially during DMA transfers, the IRQ0 flag is never properly set and thus reads never return. (The typical case for this is when we've just done a write and the en50221 thread is waiting for the CAM status word to signal STATUSREG_DA; if this doesn't happen in a reasonable amount of time, the upstream libdvben50221.so will report errors back to mumudvb.)
I have no idea why this happens more often on SMP systems than on UMP systems, but they really seem to do. I haven't found any reasonable workaround for reliable polling either, so I'm making a hack -- if there's nothing returned in two milliseconds, the read is simply assumed to have completed.
This is an unfortunate hack, but in practice it's identical to earlier behavior except with a shorter timeout.
--- drivers/media/dvb/mantis/mantis_hif.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/media/dvb/mantis/mantis_hif.c +10 -2
@@ -45,11 +45,19 @@ static int mantis_hif_sbuf_opdone_wait(struct mantis_ca *ca)struct mantis_pci *mantis = ca->ca_priv;int rc =0 ; +/* +* HACK: Sometimes, especially during DMA transfers, and especially on +* SMP systems (!), the IRQ-0 flag is never set, or at least we don't get it +* (could it be that we're clearing it?). Thus, simply wait for 2 ms and then +* assume we got an answer even if we didn't. This works around lots of CA +* timeouts. The code with 500 ms wait and -EREMOTEIO is technically the +* correct one, though. +*/ if (wait_event_timeout (ca->hif_opdone_wq,test_and_clear_bit (MANTIS_SBUF_OPDONE_BIT , &ca->hif_event), -msecs_to_jiffies (500 )) ==0 ) { +msecs_to_jiffies (2 )) ==0 ) { -dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): Smart buffer operation timeout !" , mantis->num); +dprintk (MANTIS_ERROR ,1 ,"Adapter(%d) Slot(0): Smart buffer operation timeout ! (ignoring)" , mantis->num); rc = -EREMOTEIO ; }dprintk (MANTIS_DEBUG ,1 ,"Smart Buffer Operation complete" );
Signature · 1 line
1.7.9.5
PATCH 11/11 Enable Mantis CA support.
In reply to Steinar H. GundersonFrom: "Steinar H. Gunderson" <[email protected]>
Not my patch originally; picked up from verbal descriptions on the linux-media list, and fixed up slightly.
--- drivers/media/dvb/mantis/mantis_ca.c | 4 +++- drivers/media/dvb/mantis/mantis_core.c | 20 -------------------- drivers/media/dvb/mantis/mantis_dvb.c | 4 +++- drivers/media/dvb/mantis/mantis_pci.c | 23 +++++++++++++++++++++++ drivers/media/dvb/mantis/mantis_pci.h | 2 ++ 5 files changed, 31 insertions(+), 22 deletions(-)
drivers/media/dvb/mantis/mantis_ca.c +3 -1
@@ -34,6 +34,7 @@#include "mantis_link.h" #include "mantis_hif.h" #include "mantis_reg.h" +#include "mantis_pci.h" #include "mantis_ca.h"
@@ -125,6 +126,7 @@ static int mantis_ca_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot)struct mantis_pci *mantis = ca->ca_priv;dprintk (MANTIS_DEBUG ,1 ,"Slot(%d): Slot shutdown" , slot); +mantis_set_direction (mantis,0 );/* Disable TS through CAM */ return 0 ; }
@@ -135,7 +137,7 @@ static int mantis_ts_control(struct dvb_ca_en50221 *en50221, int slot)struct mantis_pci *mantis = ca->ca_priv;dprintk (MANTIS_DEBUG ,1 ,"Slot(%d): TS control" , slot); -/* mantis_set_direction(mantis, 1); */ /* Enable TS through CAM */ +mantis_set_direction (mantis,1 );/* Enable TS through CAM */ return 0 ; }
drivers/media/dvb/mantis/mantis_core.c +0 -20
@@ -213,23 +213,3 @@ void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value)udelay (100 ); } -/* direction = 0 , no CI passthrough ; 1 , CI passthrough */ -void mantis_set_direction (struct mantis_pci *mantis,int direction) -{ -u32 reg; - - reg =mmread (0x28 ); -dprintk (verbose,MANTIS_DEBUG ,1 ,"TS direction setup" ); -if (direction ==0x01 ) { -/* to CI */ - reg |=0x04 ; -mmwrite (reg,0x28 ); - reg &=0xff -0x04 ; -mmwrite (reg,0x28 ); - }else { - reg &=0xff -0x04 ; -mmwrite (reg,0x28 ); - reg |=0x04 ; -mmwrite (reg,0x28 ); - } -}
drivers/media/dvb/mantis/mantis_dvb.c +3 -1
@@ -239,6 +239,8 @@ int __devinit mantis_dvb_init(struct mantis_pci *mantis) mantis->fe =NULL ; goto err5; } + +mantis_ca_init (mantis); } }
@@ -274,7 +276,6 @@ int __devexit mantis_dvb_exit(struct mantis_pci *mantis)int err;if (mantis->fe) { -/* mantis_ca_exit(mantis); */ err =mantis_frontend_shutdown (mantis);if (err !=0 )dprintk (MANTIS_ERROR ,1 ,"Frontend exit while POWER ON! <%d>" , err);
@@ -282,6 +283,7 @@ int __devexit mantis_dvb_exit(struct mantis_pci *mantis)dvb_frontend_detach (mantis->fe); } +mantis_ca_exit (mantis);tasklet_kill (&mantis->tasklet);dvb_net_release (&mantis->dvbnet);
drivers/media/dvb/mantis/mantis_pci.c +23 -0
@@ -97,6 +97,7 @@ int __devinit mantis_pci_init(struct mantis_pci *mantis)pci_read_config_byte (pdev,PCI_LATENCY_TIMER , &latency); mantis->latency = latency; mantis->revision = pdev->revision; +mantis_set_direction (mantis,0 ); dprintk(MANTIS_ERROR, 0, " Mantis Rev %d [%04x:%04x], ", mantis->revision,
@@ -110,6 +111,7 @@ int __devinit mantis_pci_init(struct mantis_pci *mantis) mantis->mantis_addr, mantis->mmio); +mmwrite (0x00 ,MANTIS_INT_MASK ); err = request_irq(pdev->irq, config->irq_handler, IRQF_SHARED,
@@ -165,6 +167,27 @@ void mantis_pci_exit(struct mantis_pci *mantis) }EXPORT_SYMBOL_GPL (mantis_pci_exit); +/* direction = 0 , no CI passthrough ; 1 , CI passthrough */ +void mantis_set_direction (struct mantis_pci *mantis,int direction) +{ +u32 reg; + + reg =mmread (0x28 ); +dprintk (MANTIS_DEBUG ,1 ,"TS direction setup" ); +if (direction ==0x01 ) { +/* to CI */ + reg |=0x04 ; +mmwrite (reg,0x28 ); + reg &=0xff -0x04 ; +mmwrite (reg,0x28 ); + }else { + reg &=0xff -0x04 ; +mmwrite (reg,0x28 ); + reg |=0x04 ; +mmwrite (reg,0x28 ); + } +} +MODULE_DESCRIPTION ("Mantis PCI DTV bridge driver" );MODULE_AUTHOR ("Manu Abraham" );MODULE_LICENSE ("GPL" );
drivers/media/dvb/mantis/mantis_pci.h +2 -0
@@ -24,4 +24,6 @@extern int mantis_pci_init (struct mantis_pci *mantis);extern void mantis_pci_exit (struct mantis_pci *mantis); +void mantis_set_direction (struct mantis_pci *mantis,int direction); +#endif /* __MANTIS_PCI_H */
Signature · 1 line
1.7.9.5
Hi,
sorry for the late response. Unfortunately my Skystar HD2 died on me and it looks like i get an other card in exchange. Anyway, as far I could test, the patches were ok to me. I can still put my marks, but I'm not sure which ones I should use or I'm allowed to use.
Regards,
Manuel
Am 01.04.2012 17:53, schrieb Steinar H. Gunderson:
Quoted 15 lines
Hi,
I was asked to break up my large patch into several smaller, Signed-off-by-marked changes. I've rebased against linux-2.6 master and done some today; note that since not all of these changes are originally by me, you will probably have to consider each one separately for inclusion (although they largely make sense independently of each other).
My interest in this project is, unfortunately, waning, since it appears there is no hardware documentation and very little active maintenance of the driver, which means that getting it the final step of the way is going to be hard (and probably not worth it). However, hopefully someone else will find the patch set useful nevertheless.
/* Steinar */
Quoted 5 lines · Ninja
sorry for the late response. Unfortunately my Skystar HD2 died on me and it looks like i get an other card in exchange. Anyway, as far I could test, the patches were ok to me. I can still put my marks, but I'm not sure which ones I should use or I'm allowed to use.
All except 01 (IRQ0 handling) and 11 (enable CA) are written by me. 01 should probably be safe (it's already pending review here); 11 is more unclear. Anyway, I'm sure 11 is pretty trivial once it's cleaned up, so someone should just rewrite it without the part that moves a function around, and I'm sure it can go in.
02, 04 and 06 are fixes for debugging output only. They should be safe.
03 (dvbdev mutex) should probably be fixed in a more general way, by someone more knowledgeable of the DVB subsystem.
06 and 08 are general cleanups. They should be pretty safe.
07 (atomic accesses) contains important SMP fixes. Should definitely go in.
09 and 10 contain fixes for IRQ0 timeouts on SMP. They should go in, but only as a pair; if you do 09 without 10, you will unmask a lot of the timeouts that are there. (09 doesn't introduce any new timeouts, it just makes userspace see them properly, and as an end result, things get worse.)
So, as a start, pull 01, 02, and 04 through 10? We'll still be without CA support, but as a whole the Mantis driver will be better.
/* Steinar */
Signature · 1 line
Homepage: http://www.sesse.net/