Code Monkey home page Code Monkey logo

Comments (7)

rockowitz avatar rockowitz commented on July 3, 2024

That message is, I'm afraid, meant to be hard to ignore. It's an internal debug message that's emitted unconditionally. I'm sorry it tripped you up, but I'm glad that it got your attention and you reported it.

For background, see issue #282. The problem arises if the nvidia driver (or more precisely the portion that is rebuilt for each kernel, e.g. by DKMS, is built with a copy of i2c in which symbol I2C_M_DMA_SAFE is undefined. The problem was reported by a single user, and while the report enabled me to identify how the error arose, I've never been able to find a copy of i2c.h in which the symbol is undefined.

Possibly TMI for you, but in case you're curious, I2C_M_DMA_SAFE is used internally by driver i2c-dev to tell the video driver that it's safe to use DMA. It does not require that DMA be used. Normally, the Nvidia driver can be called with this bit set, but it doesn't make any use of the bit. However, if the driver is built with a copy of i2c.h in which the bit is undefined, a call into the driver with the bit set fails as having an invalid argument.

Which leads to the following questions:

  • What is your distribution?
  • How is the recompiled portion of the Nvidia driver being built (e.g. DKMS) or us it being downloaded from somewhere?
  • What copies of i2c.h exist on your system, and are there any in which I2C_M_DMA_SAFE is undefined? If so, please submit a copy of the file.

Thank you.

from ddcutil.

gadefox avatar gadefox commented on July 3, 2024

Thanks.. Well, I'm using Debian Trixie and yes, the proprietary NVIDIA driver (legacy 340.108) is built by dkms. The i2c.h contains the following definition. I hope this helps..

#define I2C_M_DMA_SAFE          0x0200  /* use only in kernel space */

Btw. I have to use --use-file-io option otherwise the ddcutil doesn't change the settings..

from ddcutil.

rockowitz avatar rockowitz commented on July 3, 2024

Can you send me a copy of file nv-i2c.c from the driver source that DKMS is compiling?

Option --use-file-io applies only to the current ddcutil invocation. The need to use file type io is not remembered from one execution to the next. Or are you saying that the is_nvidia_einval_bug message occurs multiple times per invocation?

from ddcutil.

gadefox avatar gadefox commented on July 3, 2024

I'm not getting the error message (is_nvidia_einval_bug) with --use-file-io option..
nv.tar.gz

from ddcutil.

rockowitz avatar rockowitz commented on July 3, 2024

My focus on i2c.h was incomplete. Function nv_i2c_algo_master_xfer() in current versions of nv-i2c.c rejects valid calls from i2c-dev if nv-i2c-c was compiled with some copy of i2c.h in which I2C_M_DMA_SAFE is not defined. But I was puzzled because I could never find such a copy of i2c.h in the wild.

You reported that you are using legacy nvidia driver version 340.108. In the copy of nv-i2c.h. which you sent, function nv_2c_algo_xfer() fails any call in which any flag bit other than I2C_M_READ (e.g. I2C_M_DMA_SAFE) is set. So the problem is that an old version of the nvidia driver rejects calls from current versions of i2c-dev. This is a much more plausible reason for why this error is seen.

Is there a hardware reason you're running the legacy driver? If so, then --use-file-io is the proper solution.

Thank you for your help in diagnosing this obscure problem.

from ddcutil.

gadefox avatar gadefox commented on July 3, 2024

It's the old laptop. Anyway, it seems the issue is solved.
I can find the following definitions in i2c.h:

#define I2C_M_RD                0x0001  /* guaranteed to be 0x0001! */
#define I2C_M_TEN               0x0010  /* use only if I2C_FUNC_10BIT_ADDR */
#define I2C_M_DMA_SAFE          0x0200  /* use only in kernel space */
#define I2C_M_RECV_LEN          0x0400  /* use only if I2C_FUNC_SMBUS_READ_BLOCK_DATA */
#define I2C_M_NO_RD_ACK         0x0800  /* use only if I2C_FUNC_PROTOCOL_MANGLING */
#define I2C_M_IGNORE_NAK        0x1000  /* use only if I2C_FUNC_PROTOCOL_MANGLING */
#define I2C_M_REV_DIR_ADDR      0x2000  /* use only if I2C_FUNC_PROTOCOL_MANGLING */
#define I2C_M_NOSTART           0x4000  /* use only if I2C_FUNC_NOSTART */
#define I2C_M_STOP              0x8000  /* use only if I2C_FUNC_PROTOCOL_MANGLING */

I changed the nvidia driver's code (fn. nv_i2c_algo_master_xfer) so the condition looks like this:

        /* we don't support I2C_FUNC_10BIT_ADDR, I2C_FUNC_PROTOCOL_MANGLING */
        if (msgs[i].flags & (I2C_M_TEN | I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK | I2C_M_REV_DIR_ADDR | I2C_M_STOP))
        {
            rc = -EINVAL;
            rmStatus = RM_ERR_INVALID_ARGUMENT;
        }
        else
        {
            rmStatus = rm_i2c_transfer(sp, nv, (void *)adap,
                                       (msgs[i].flags & I2C_M_RD) ?
                                           NV_I2C_CMD_READ : NV_I2C_CMD_WRITE,
                                       (NvU8)(msgs[i].addr & 0x7f), 0,
                                       (NvU32)(msgs[i].len & 0xffffUL),
                                       (NvU8 *)msgs[i].buf);
        }

Now I don't need to use --use-file-io option or I'm not getting the error message (is_nvidia_einval_bug). Thanks..

from ddcutil.

gadefox avatar gadefox commented on July 3, 2024

Btw. the safest change is to extend I2C_M_DMA_SAFE bit only.
from

if (msgs[i].flags & ~I2C_M_RD)

to

if (msgs[i].flags & ~(I2C_M_RD | I2C_M_DMA_SAFE))

from ddcutil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.