Module: xenomai-forge
Branch: next
Commit: 30266978489e59ff9c31951f3d7ff84440b1f4d7
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=30266978489e59ff9c31951f3d7ff84440b1f4d7

Author: Jorge Ramirez-Ortiz <j...@xenomai.org>
Date:   Tue Jul  1 10:46:15 2014 -0400

drivers/analogy/testing: clarify apparent error during cmd_write operation

    This change helps the user understand the following use case.

    1. The user loads the fake driver and requests reading from subd 3. By
    default, cmd_read attempts to read 100 triggered scans; the call will
    run until all the data has been received.

            $ ./cmd_read -d analogy0 -s 3

    2. The user, on a separate thread, writes to subd 2; since subd2 and
    subd3 implement a loop device, a write to subd2 will be copied on to
    the async buffer of subd3.

        $./cmd_write -v -d analogy0 -s 2 -i file.txt

    When file.txt is much larger than 100 scans, the cmd_write function will
    end up failing in one of the block transfers. This is not an error but
    due to the fact that the cmd_read completion on subd3 also cancels any
    on going requests on subd2 (note: use wf_generate to create the
    samples in file.txt).

    If you enabled ftrace, this should look like this:

    [root@xenobot xenomai]# cat /proc/analogy/00-analogy_fake
    --  Subdevices --

    | idx | type
    |  00 | Analog input subdevice
    |  01 | Digital input/output subdevice
    |  02 | Analog output subdevice
    |  03 | Analog input subdevice

    [root@xenobot xenomai]# cat /sys/kernel/debug/tracing/trace
            modprobe-1856  [000] ....   158.289528: a4l_register_drv:  
name=analogy_fake
            modprobe-1856  [000] ....   158.289540: a4l_lct_drv:  
name=analogy_fake
      analogy_config-1858  [000] ....   159.566561: a4l_lct_drv:  
name=analogy_fake
      analogy_config-1858  [000] ....   159.566568: test_attach: analogy_fake: 
starting attach procedure...
      analogy_config-1858  [000] ....   159.566571: test_attach: analogy_fake:  
AI subdev registered
      analogy_config-1858  [000] ....   159.566574: test_attach: analogy_fake:  
DIO subdev registered
      analogy_config-1858  [000] ....   159.566577: test_attach: analogy_fake:  
AO subdev registered
      analogy_config-1858  [000] ....   159.566580: test_attach: analogy_fake:  
AI2 subdev registered
      analogy_config-1858  [000] ....   159.570938: test_attach: analogy_fake: 
attach procedure completed: adiv = 1, qcount = 1
      analogy_config-1858  [000] ....   159.570943: a4l_setup_transfer:  
nb_subd=4
            cmd_read-1870  [000] ....   164.521176: a4l_fill_cmddesc:  desc dump
            cmd_read-1870  [000] ....   164.521190: a4l_fill_cmddesc:       
->idx_subd=3
            cmd_read-1870  [000] ....   164.521199: a4l_fill_cmddesc:       
->flags=0
            cmd_read-1870  [000] ....   164.521208: a4l_fill_cmddesc:       
->nb_chan=4
            cmd_read-1870  [000] ....   164.521216: a4l_fill_cmddesc:       
->chan_descs=0x0
            cmd_read-1870  [000] ....   164.521245: a4l_fill_cmddesc:       
->data_len=0
            cmd_read-1870  [000] ....   164.521254: a4l_fill_cmddesc:       
->pdata=0x          (null)
            cmd_read-1870  [000] ....   164.521264: a4l_ioctl_cmd:  1st cmd 
checks passed
            cmd_read-1870  [000] ....   164.521272: a4l_ioctl_cmd:  driver's 
cmd checks passed
            cmd_read-1870  [000] ....   164.521282: a4l_setup_buffer:  
end_count=800
            cmd_read-1870  [000] ....   164.521292: ai2_cmd: analogy_fake:  
(subd=3)
            cmd_read-1870  [000] ....   164.521460: a4l_read_buffer: 
a4l_buffer=0xffff88007a501a00, p=0xffffc9000008f000
            cmd_read-1870  [000] ....   164.521470: a4l_read_buffer: 
end=000800, prd=000000, cns=000000, tmp=000000
           cmd_write-1905  [000] ....   200.797349: a4l_fill_cmddesc:  desc dump
           cmd_write-1905  [000] ....   200.797356: a4l_fill_cmddesc:       
->idx_subd=2
           cmd_write-1905  [000] ....   200.797361: a4l_fill_cmddesc:       
->flags=0
           cmd_write-1905  [000] ....   200.797365: a4l_fill_cmddesc:       
->nb_chan=2
           cmd_write-1905  [000] ....   200.797368: a4l_fill_cmddesc:       
->chan_descs=0x0
           cmd_write-1905  [000] ....   200.797372: a4l_fill_cmddesc:       
->data_len=0
           cmd_write-1905  [000] ....   200.797376: a4l_fill_cmddesc:       
->pdata=0x          (null)
           cmd_write-1905  [000] ....   200.797380: a4l_ioctl_cmd:  1st cmd 
checks passed
           cmd_write-1905  [000] ....   200.797384: a4l_ioctl_cmd:  driver's 
cmd checks passed
           cmd_write-1905  [000] ....   200.797388: a4l_setup_buffer:  
end_count=0
           cmd_write-1905  [000] ....   200.797393: ao_cmd: analogy_fake:  
(subd=2)
           cmd_write-1905  [000] ....   200.804176: a4l_write_buffer: 
a4l_buffer=0xffff88007a505200, p=0xffffc90000134000
           cmd_write-1905  [000] ....   200.804184: a4l_write_buffer: 
end=000000, prd=000000, cns=000000, tmp=000000
           cmd_write-1905  [000] ....   200.804192: a4l_write_buffer: 
analogy_fake:  buf->prd_cnt=4096
           cmd_write-1905  [000] ....   200.804256: ao_trigger: analogy_fake:  
(subd=2)
            cmd_read-1870  [000] ....   200.804379: a4l_read_buffer: 
a4l_buffer=0xffff88007a501a00, p=0xffffc9000008f000
            cmd_read-1870  [000] ....   200.804385: a4l_read_buffer: 
end=000800, prd=004096, cns=000000, tmp=000000
            cmd_read-1870  [000] ....   200.804392: a4l_read_buffer: 
analogy_fake:  buf->cns_cnt=800
               <...>-1860  [001] ....   200.804438: ao_pull_values: 
analogy_fake:  4096 bytes added to private buffer from async p=ffffc90000134000
               <...>-1860  [001] ....   200.804448: ai2_push_values: 
analogy_fake:  4096 bytes added to async buffer p=ffffc9000008f000
            cmd_read-1870  [000] ....   200.805363: a4l_read_buffer: 
a4l_buffer=0xffff88007a501a00, p=0xffffc9000008f000
            cmd_read-1870  [000] ....   200.805367: a4l_read_buffer: 
end=000800, prd=004096, cns=000800, tmp=000000
            cmd_read-1870  [000] d...   200.805371: a4l_read_buffer: a4l_read: 
acquisition done - all data requested by the client was delivered
            cmd_read-1870  [000] ....   200.805375: ai2_cancel: analogy_fake:  
(subd=3)
            cmd_read-1870  [000] ....   200.805379: ai2_cancel: analogy_fake:  
subd 3 cancelling subd 2 too
           cmd_write-1905  [000] ....   200.806266: a4l_write_buffer: 
a4l_buffer=0xffff88007a505200, p=0xffffc90000134000
           cmd_write-1905  [000] ....   200.806273: a4l_write_buffer: 
end=000000, prd=004096, cns=004096, tmp=000000
           cmd_write-1905  [000] ....   200.806282: ao_cancel: analogy_fake:  
(subd=2)

---

 kernel/drivers/analogy/testing/fake.c |   30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/kernel/drivers/analogy/testing/fake.c 
b/kernel/drivers/analogy/testing/fake.c
index c91f3dc..0cb9c13 100644
--- a/kernel/drivers/analogy/testing/fake.c
+++ b/kernel/drivers/analogy/testing/fake.c
@@ -195,7 +195,9 @@ int ao_pull_values(struct a4l_subdevice *subd)
 
        }
 
-       a4l_info(subd->dev, A4L_FUNCTION " count %d \n", priv->count);
+       a4l_info(subd->dev, " %d bytes added to private buffer from async 
p=%p\n",
+               priv->count, subd->buf->buf);
+
        a4l_buf_evt(subd, 0);
 
        return 0;
@@ -215,6 +217,10 @@ int ai2_push_values(struct a4l_subdevice *subd)
                buffer, data are likely to be dropped; it is just a
                test driver so no need to implement trickier mechanism */
                err = (err == -EAGAIN) ? 0 : err;
+
+               a4l_info(subd->dev, "%d bytes added to async buffer p=%p\n",
+                       priv->count, subd->buf->buf);
+
                priv->count = 0;
                if (err < 0)
                        a4l_err(subd->dev,
@@ -238,8 +244,7 @@ static int ai_cmd(struct a4l_subdevice *subd, struct 
a4l_cmd_desc *cmd)
        ai_priv->convert_period_ns = (cmd->convert_src==TRIG_TIMER)?
                cmd->convert_arg:0;
 
-       a4l_dbg(1, drv_dbg, subd->dev, A4L_FUNCTION
-               " scan_period=%luns convert_period=%luns\n",
+       a4l_dbg(1, drv_dbg, subd->dev, "scan_period=%luns 
convert_period=%luns\n",
                ai_priv->scan_period_ns, ai_priv->convert_period_ns);
 
        ai_priv->last_ns = a4l_get_time();
@@ -287,7 +292,7 @@ static void ai_munge(struct a4l_subdevice *subd, void *buf, 
unsigned long size)
 
 int ao_cmd(struct a4l_subdevice *subd, struct a4l_cmd_desc *cmd)
 {
-       a4l_info(subd->dev, A4L_FUNCTION " (subd=%d)\n", subd->idx);
+       a4l_info(subd->dev, "(subd=%d)\n", subd->idx);
        return 0;
 }
 
@@ -295,7 +300,7 @@ int ao_trigger(struct a4l_subdevice *subd, lsampl_t trignum)
 {
        struct fake_priv *priv = (struct fake_priv *)subd->dev->priv;
 
-       a4l_info(subd->dev, A4L_FUNCTION " (subd=%d)\n", subd->idx);
+       a4l_info(subd->dev, "(subd=%d)\n", subd->idx);
        priv->ao_running = 1;
        return 0;
 }
@@ -306,7 +311,7 @@ void ao_cancel(struct a4l_subdevice *subd)
        struct ao_ai2_priv *ao_priv = (struct ao_ai2_priv *)subd->priv;
        int running;
 
-       a4l_info(subd->dev, A4L_FUNCTION " (subd=%d)\n", subd->idx);
+       a4l_info(subd->dev, "(subd=%d)\n", subd->idx);
        priv->ao_running = 0;
 
        running = priv->ai2_running;
@@ -318,6 +323,10 @@ void ao_cancel(struct a4l_subdevice *subd)
                   end of the acquisition; that is why we force it */
                priv->ai2_running = 0;
                ao_priv->count = 0;
+
+               a4l_info(subd->dev, "subd %d cancelling subd %d too \n",
+                       subd->idx, AI2_SUBD);
+
                a4l_buf_evt(ai2_subd, A4L_BUF_EOA);
        }
 }
@@ -328,7 +337,7 @@ int ai2_cmd(struct a4l_subdevice *subd, struct a4l_cmd_desc 
*cmd)
 {
        struct fake_priv *priv = (struct fake_priv *)subd->dev->priv;
 
-       a4l_info(subd->dev, A4L_FUNCTION " (subd=%d)\n", subd->idx);
+       a4l_info(subd->dev, "(subd=%d)\n", subd->idx);
        priv->ai2_running = 1;
        return 0;
 }
@@ -340,7 +349,7 @@ void ai2_cancel(struct a4l_subdevice *subd)
 
        int running;
 
-       a4l_info(subd->dev, A4L_FUNCTION " (subd=%d)\n", subd->idx);
+       a4l_info(subd->dev, "(subd=%d)\n", subd->idx);
        priv->ai2_running = 0;
 
        running = priv->ao_running;
@@ -352,8 +361,13 @@ void ai2_cancel(struct a4l_subdevice *subd)
                   end of the acquisition; that is why we force it */
                priv->ao_running = 0;
                ai2_priv->count = 0;
+
+               a4l_info(subd->dev, "subd %d cancelling subd %d too \n",
+                        subd->idx, AO_SUBD);
+
                a4l_buf_evt(ao_subd, A4L_BUF_EOA);
        }
+
 }
 
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to