Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp597688rdg; Thu, 12 Oct 2023 15:18:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwBv7rzhUvyzRQcuLnpXXaawb8X0lMUN5/S1FbDKjL4cTEa7QhomplXnAyuLZb1ePya0+v X-Received: by 2002:a17:902:e847:b0:1c3:dad8:bb99 with SMTP id t7-20020a170902e84700b001c3dad8bb99mr24023903plg.64.1697149102417; Thu, 12 Oct 2023 15:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697149102; cv=none; d=google.com; s=arc-20160816; b=uZIb2U6W+9JBmPe3S6lKERuNfnFZQBxfXR6k8DAi2Ytd/lcuHDfu7UadqLUU88/+Eu 9e0B9WfVW7JkmnvvX8kTMYBpwp4ZAFI7lijjn0Uce3IORVEHZi1vy7OSAr3ql9hDV2xT wXWM+vzxUCVpgjhsbkqIEJJaQa6/2/Puobn1Uu4V+gpJIA8AA0Nmy/VbQAk1BORi2iSV ZxhN0SzxnNQKsGdBbUXN0y1RwZPL/0VZiUGem3BNIyuc4a+bRJGxZyr9z8aB9fJerfZT pP2nzasvJUarSgMxw6yKSrVh/HPQCynTuq9I14lhDUs0mPfQW+luAWrzu7VF39pK6me3 dU4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=MkFIP/rIrBl6Dva+63tYTX/XHBtxWUMdKUNt4WrzRkI=; fh=jQMCI/mOmhw+JYAXv6qw9Vam76rS90uLOPqipTLzGWk=; b=jFy2y1/4My+n/NxTj9vzip9I79E5iTDXU1bHuI5HLflNA+o49+ZbH6sT3yM+Pdz0aA UF20zKCYKWT1QdDCU45BVTTGW5SQv5LRAROjiQLIJ2MQhRkBHAiCla3CPlSMgGozvo6B Gmb9c/PSR8v5i/gHrsPi6tX5QYXD9ewU9sPmY2uuPixk8Bo1xSg7wo8aIhUV3K0VIpj4 UULJsAguLvTqwxo9UnRF84pWjNGEsArnON60eOGXHluosQVRhDG/pMNZdyz2tAHD5IVz dXzyRPK26l8avBk82oeA7/H2KkKPrlAfwPtbhY/1dfCl2xxTVPVLqu+X9YqvxReeO3aw Zq2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a10-20020a170902ecca00b001c474ff2fdesi3493506plh.378.2023.10.12.15.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 15:18:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5A0A482EBE4B; Thu, 12 Oct 2023 15:18:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442997AbjJLWST (ORCPT + 99 others); Thu, 12 Oct 2023 18:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442960AbjJLWST (ORCPT ); Thu, 12 Oct 2023 18:18:19 -0400 X-Greylist: delayed 999 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 12 Oct 2023 15:18:17 PDT Received: from stcim.de (stcim.de [IPv6:2a01:4f8:151:40c4::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B72BB8; Thu, 12 Oct 2023 15:18:17 -0700 (PDT) Received: from stc by stcim with local (Exim 4.92) (envelope-from ) id 1qr3kF-0007rM-Hb; Fri, 13 Oct 2023 00:01:27 +0200 Date: Fri, 13 Oct 2023 00:01:27 +0200 From: Stefan Lengfeld To: Krzysztof =?utf-8?Q?Ha=C5=82asa?= Cc: linux-media , lkml , Dave Stevenson , Oleksij Rempel , Pengutronix Kernel Team , Shawn Guo , Sascha Hauer , Fabio Estevam , NXP Linux Team , linux-i2c@vger.kernel.org Subject: Re: Sony IMX290/462 image sensors I2C xfer peculiarity Message-ID: <20231012220127.GB27838@stcim.de> References: <20231011101553.we3r73xejvqdql5j@porty> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 15:18:21 -0700 (PDT) Hi Chris, > > My understand is that an ordinary I2C device would just use normal (and > > sleepable) I2C transfers while the device is in use. > > You are spot-on here :-) Now I use IMX 290 and 462. > > OTOH I wonder if such issues are limited to those sensors only. Hmm, yes. I know no other I2C device that has these timeout issues. (*) > The problem is I use Sony IMX290 and IMX462 image sensors, and they have > an apparently hard-coded timeout of about 2^18 their master clock cycles > (= ca. 7 ms with my setup). After the timeout they simply disconnect > from the I2C bus. Of course, this isn't mentioned in the docs. hmm. I have no idea about this sensor and your setup. So I can just give hints: This timeout seems strange. If this 7 ms timeout is required, it would mean that I2C masters require to fullfill real-time/deadline requirements. For "small" I2C master in microcontrolles this seems ok-ish, but for general operating systems real-time requirements are hard. The real-time patches for linux just landed recently and it still requires fine tuning the system for the required deadlines. Maybe you just hit a corner case or a bug, that can be avoid, in the I2C device. Maybe check with the manufacturer directly? > Unfortunately, "normal" I2C accesses take frequently more than those > 7 ms (mostly due to scheduling when all CPU cores are in use). Yes, correctly. There are multiple cases in which I2C transactions to the same device can be preempted/delayed: A busy system, as you said, or when some other driver in the kernel accesses another I2C device on the same bus. This will lock the bus/I2C adapter for the duration of its transfer. Do you know the I2C repeated start feature [1]? This allows to batch together multiple I2C read/writes in a single transfer. And in the best case, this transfer is executed in one go without a delay in between. At least in the kernel it's guaranteed that no other driver can go in between with another transfer. Kind regards, Stefan [1]: https://www.i2c-bus.org/repeated-start-condition/ (*) Fun answer: Actually external watchdogs have timeouts. But the timeout duration is in the range of seconds, not milliseconds. And timeout expiration is expected (in error cases ;-).