linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Krzysztof Hałasa" <khalasa@piap.pl>
To: linux-media <linux-media@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>
Subject: Re: Sony IMX290/462 image sensors I2C xfer peculiarity
Date: Tue, 10 Oct 2023 11:46:12 +0200	[thread overview]
Message-ID: <m37cnuvmhn.fsf@t19.piap.pl> (raw)
In-Reply-To: <m3o7hfx3ob.fsf@t19.piap.pl> ("Krzysztof Hałasa"'s message of "Tue, 03 Oct 2023 14:59:16 +0200")

Hi,

I'm back to IMX290 and IMX462 sensors running on i.MX8MP (and not on
some nonexistent sort of i.MX6 as I previously wrote). The timeout thing
happens at circa 2^18 + 8 or + 9 master clocks after the regular START
(not repeated START). With MCLK = 37.125 MHz this amounts to ca. 7 ms.

Using imx290.c and the i2c-imx.c I2C driver (NXP's version 5.15, but it
doesn't seem to differ significantly from mainstream):

wait_queue_head_t queue;

i2c_imx_trx_complete()
	wait_event_timeout(queue, ..., HZ / 10);

i2c_imx_master_isr()
	wake_up(&queue);

Sensor register write example, I've added a couple of obvious printk()
calls in the interrupt handler.

First adding some load to each CPU core:
for n in 1 2 3 4; do while :; do :; done & done

Then the actual sensor register write:
Sending I2C DEVSEL byte:
[86.968267] <i2c_imx_write> write slave address: addr=0x34

Completed:
[86.968306] <i2c_imx_isr> 0xA2 0xF8 <<<<<< ACK
[86.968311] <i2c_imx_master_isr> 0xA2
[86.980361] <i2c_imx_trx_complete> TRX complete

It took 12 ms to wake up, way too long for IMX462 to remain on the I2C
bus, so the following byte TX fails.

The question is: what can be done about it?
- should I make the camera control thread real time?
- or maybe the I2C driver should be modified?
- or maybe imx290 register accesses should be somehow atomic?
-- 
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa

  reply	other threads:[~2023-10-10  9:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-29 10:53 Sony IMX290/462 image sensors I2C xfer peculiarity Krzysztof Hałasa
2023-09-29 13:33 ` Dave Stevenson
2023-10-03 12:59   ` Krzysztof Hałasa
2023-10-10  9:46     ` Krzysztof Hałasa [this message]
2023-10-11  9:10       ` Krzysztof Hałasa
2023-10-11  9:50         ` Krzysztof Hałasa
2023-10-11 10:15           ` Stefan Lengfeld
2023-10-11 11:25             ` Krzysztof Hałasa
2023-10-11 11:59               ` Alexander Stein
2023-10-11 12:18                 ` Krzysztof Hałasa
2023-10-12 22:01               ` Stefan Lengfeld
2023-10-13  7:17                 ` Wolfram Sang
2023-10-13 10:39                 ` Krzysztof Hałasa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m37cnuvmhn.fsf@t19.piap.pl \
    --to=khalasa@piap.pl \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).