V4L/DVB (13777): [Mantis] Use a Write wait queue for Write events
authorManu Abraham <abraham.manu@gmail.com>
Fri, 4 Dec 2009 08:29:48 +0000 (05:29 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 17 Jan 2010 13:55:40 +0000 (11:55 -0200)
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/mantis/mantis_hif.c
drivers/media/dvb/mantis/mantis_link.h

index a2359f7e14656d3f62ede2f5b1d3fcefdf58d83c..dc50fac0d1556433d6c7549b60a12aa97fa3b2b1 100644 (file)
@@ -57,6 +57,35 @@ static int mantis_hif_sbuf_opdone_wait(struct mantis_ca *ca)
        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,
+                              msecs_to_jiffies(500)) == -ERESTARTSYS) {
+
+               dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): Write ACK timed out !", mantis->num);
+               rc = -EREMOTEIO;
+       }
+       dprintk(verbose, MANTIS_DEBUG, 1, "Write Acknowledged");
+       mantis->gpif_status &= ~MANTIS_GPIF_WRACK;
+       while (!opdone) {
+               opdone = (mmread(MANTIS_GPIF_STATUS) & MANTIS_SBUF_OPDONE);
+               udelay(500);
+               timeout++;
+               if (timeout > 100) {
+                       dprintk(verbose, MANTIS_ERROR, 1, "Adater(%d) Slot(0): Write operation timed out!", mantis->num);
+                       rc = -ETIMEDOUT;
+                       break;
+               }
+       }
+       dprintk(verbose, MANTIS_DEBUG, 1, "HIF Write success");
+       return rc;
+}
+
 
 int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr)
 {
@@ -100,7 +129,7 @@ int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data)
        mmwrite(hif_addr | MANTIS_HIF_STATUS, MANTIS_GPIF_ADDR);
        mmwrite(data, MANTIS_GPIF_DOUT);
 
-       if (mantis_hif_sbuf_opdone_wait(ca) != 0) {
+       if (mantis_hif_write_wait(ca) != 0) {
                dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
                return -EREMOTEIO;
        }
@@ -147,7 +176,7 @@ int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data)
        mmwrite(hif_addr | MANTIS_HIF_STATUS, MANTIS_GPIF_ADDR);
        mmwrite(data, MANTIS_GPIF_DOUT);
 
-       if (mantis_hif_sbuf_opdone_wait(ca) != 0) {
+       if (mantis_hif_write_wait(ca) != 0) {
                dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num);
                return -EREMOTEIO;
        }
@@ -167,6 +196,7 @@ int mantis_hif_init(struct mantis_ca *ca)
        dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Initializing Mantis Host Interface", mantis->num);
        init_waitqueue_head(&ca->hif_data_wq);
        init_waitqueue_head(&ca->hif_opdone_wq);
+       init_waitqueue_head(&ca->hif_write_wq);
 
        irqcfg = mmread(MANTIS_GPIF_IRQCFG);
        irqcfg = MANTIS_MASK_BRRDY      |
index a85f502152661f873a3df6052d5d7570d39ed0b1..599ff1b57e489a753061396766538e5104806f79 100644 (file)
@@ -51,6 +51,7 @@ struct mantis_ca {
        wait_queue_head_t               hif_opdone_wq;
        wait_queue_head_t               hif_brrdyw_wq;
        wait_queue_head_t               hif_data_wq;
+       wait_queue_head_t               hif_write_wq; /* HIF Write op */
 
        enum mantis_sbuf_status         sbuf_status;