This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Bufferclass failing, Bad Address - why?

Hello,

I am trying to use the bufferclass driver, and it mysteriously fails, even with this simple test code:

 

 

#include <bc_cat.h>

#include <stdio.h>

#include <sys/ioctl.h>

#include <fcntl.h>

#include <string.h>

#include <unistd.h>

#include <errno.h>


int main(void)

{

  bc_buf_params_t bc_params;

  int bc_fd = -1;


  bc_fd = open("/dev/bc_cat", O_RDWR | O_NDELAY);

  if (bc_fd == -1)

  {

    fprintf(stderr, "%s", "Error opening bc driver - is the bc_cat kernel module inserted?\n");

    return -1;

  }


  bc_params.count = 1;

  bc_params.width = 256;

  bc_params.height = 256;

  bc_params.fourcc = BC_PIX_FMT_UYVY;

  bc_params.type = BC_MEMORY_MMAP;


  if (ioctl(bc_fd, BCIOREQ_BUFFERS, &bc_params) != 0)

  {

    fprintf(stderr, "BCIOREQ_BUFFERS failed: %s\n", strerror(errno));

    close(bc_fd);

    return -2;

  }


  printf("Everything OK\n");

  close(bc_fd);

  return 0;

}

It fails right at the BCIOREQ_BUFFERS ioctl, with EFAULT "Bad Address". Now what is going on? &bc_params should be a valid address, should it not?
I am using Angstrom, hardware platform is an IGEPv2 RB, a Beagle Board clone. I am not using X, this is just the minimal image from Angstrom. The hardware DSP codecs work fine, OpenGLES through the SGX works fine, cmemk is loaded, using this line:
  modprobe cmemk phys_start=0x9ba00000 phys_end=0x9ca00000 pools=1x5250000,6x829440,1x345600,1x691200,1x1
Any ideas what the cause of this might be? Am I missing something?

  • The code indicates you are using an earlier version of the buffer class module - You can quickly verify where the error is coming from, using the kernel module source code at,

    <Graphics SDK Path>/GFX_Linux_KM/services4/3rdparty/bufferclass_ti/bc_cat.c

     

    And, can you please send the output of the gfx_check.sh running on the target ?

     

    https://gforge.ti.com/gf/download/docmanfileversion/203/3715/gfx_check.sh

     

     

  • I ran the gfx_check script, these are the results: 0044.gfx_check_output.txt

    In bc_cat.c, the interesting part is this:

     

     

            case _IOC_NR(BCIOREQ_BUFFERS):

            {

                bc_buf_params_t *p = (bc_buf_params_t *) arg;

     

                if (!access_ok(VERIFY_WRITE, p, sizeof(bc_buf_params_t)))

                    return -EFAULT;

     

                return BC_CreateBuffers(id, p);

                break;

            }

     

     

    I suspect access_ok() is failing, because I get zero output in dmesg and syslog. The only place where is I see a silent exit is here.

    UPDATE: I didn't load the bc_cat module when I ran the script. It didn't change anything though, except that I now get "my device id: 0" lines in dmesg. BCIOREQ_BUFFERS still fails.

    I am also thinking about moving from Angstrom to Arago. I have been using Angstrom until now since it has support for the IGEP platform out of the box, which is not the case with Arago. Would you recommend this?

  • The script shows you already have bufferclass_ti.ko loaded, this is sufficient.

    I do not think access_ok is failing. Since the SDK has the full source, I recommend doing a quick check with printk to find what point it is returning an error.

    On Angstrom vs Arago - you have not mentioned the needs for your full system (including multimedia, kernel movements, driver availability). From a Graphics perspective, I do not see an issue. Note that Arago does not support X so far.

     

  • Thanks for your answer. I will try to pinpoint the error with printk, as you suggested.

    I do not need X. I am happy with EGL + GLESv2 + ALSA + GStreamer, in raw, X-less mode. Everything is working fine except for the bufferclass part. I am not working on a real product right now, I am familiarizing myself with the platform, how to get the basic things to run etc. Therefore, I'm sorry to say I cannot give you the information specified in the Excel sheet your signature links to. However, as said, I got GLESv2 working nicely already. The last part is to get the texture streams to run ;)

    My concerns with Angstrom are that it is a bleeding edge distro, and perhaps not as tested and reviewed as Arago. Not knowing so much about the latter, I can only speculate.

  • I looked through the bc_cat code, and noticed something peculiar.

    The cmd received by bc_ioctl() is wrong. I send BCIOREQ_BUFFERCLASS, but thats not what bc_ioctl() receives. There is a switch-case block, where the default block returns -EFAULT, explaining the Bad Address result.

    However, I have no idea why the cmd is getting corrupted. The value of cmd alternates between two values, none of which are BCIOREQ_BUFFERCLASS. For example, the numeric value of BCIOREQ_BUFFERCLASS is 3221776131. Printing out the value of cmd with printk, I sometimes get 3671621824, sometimes 3682548160, but never 3221776131. I double checked, and 3221776131 is also the value bc_cat.c uses for BCIOREQ_BUFFERCLASS, so there is no mismatch.

  • Can you check if you have multiple bc_cat.h files - perhaps you are including a wrong bc_cat.h that is not compatible with the kernel module you have ?

  • I checked that, and it was definitely the right bc_cat.h file (the one right besides bc_cat.c from the kernel module).

    Furthermore, the bc_ioctl() function receives random commands, and not the one I sent it. I will rebuild everything (kernel + rootfs + modules), and see if the problem persists.