i2c-dev hogs CPU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everyone,

There seems to be something busy-waiting or inappropriately
busy-polling somewhere below /dev/i2c-*

I use i2c-dev to fast control and react to changes in monitors over
their i2c connection. And despite it being peanuts data-wise it brings
the CPU to its limits.

I wrote this simple python script to expose this (below). On my setup
it pulls in 4.5kB/s of data over i2c and brings a core of some 3.3 GHz
CPU to 100%. And not just the number, its fan starts speeding up as
well.

While I have this i2c bus offered via the radeon driver which seems to
use i2c_algo_bit, a friend has the same issue even over this simulated
i2c bus from the amdgpu driver for a DisplayPort monitor (I use
HDMI/DVI).

Any input on how to isolate this problem or even remove it?

Thx,
Robert

PD: pls keep me in Cc:

#!/usr/bin/env python3
#
# script.py <bus-number> <slave-addr>
# I use it on any monitor bus with addr 0x37 or 0x50

import fcntl
import os
import sys
import time

i = os.open(f'/dev/i2c-{sys.argv[1]}', os.O_RDWR)
fcntl.ioctl(i, 0x703, int(sys.argv[2], 0))  # CPP macro: I2C_SLAVE = 0x703
while True:
    start = time.time()
    b = os.read(i, 1024)
    duration = time.time() - start
    print(len(b), 'Bytes,', len(b) / 1024 / duration, 'kBytes/s')



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux