From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16BE0C25B76 for ; Mon, 3 Jun 2024 07:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=adOByA0oD1fcn2y6bebwirOro5qRdeyopTtgYVpml60=; b=HXxUHy2XXN1pro NqPqCN40+mRa6T/Ml4vt2Ynriuv7p/Ts0Ku0TyGJFkvLqCbL0/fR4TGzVUi/ZklOwtDrphMUSeVne /KxZShBxT08Kl1l+oFpk/vTeDv7IT7YJg2AIoxLWmVtT0RW1rMxtcu+GxIr9tn4OW/BZfBhp/PK5x OE6QLeIVXHOfEO3uN2DwacpAn4bNrQVgQdflvqo+tVU3JKMVuZZQ5eyeTwYs/lfwqzdXIEMJGb/st xC8D5ZVcac09JvNHoGJnVGP0FZhJu14+KfuD4bI64hZABeoQ9NlNfXCgXzu7CK7DvEQ3WsVIjt3xr Ljjb8nUc7qrIMvgbZ4zw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sE2Dk-0000000FuMF-31WZ; Mon, 03 Jun 2024 07:35:08 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sE2Dg-0000000FuLd-1z11 for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2024 07:35:05 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4211a86f124so34834425e9.0 for ; Mon, 03 Jun 2024 00:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717400101; x=1718004901; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dicgZOJvKn5T8RaFpyT/8hZCmr01MJ9Sp/DfGcqf1B0=; b=PHXV+LxdWvRdAoTVjQz4wEUy1ftkuBsQM1aTTXud3W4VjIaAsGFYIsCywIdlCwzIog e2ntULcC1IW+dwroDAjqinmii9ct3SoH3DzpNgDpBZxHAhDWdJKjRKXi16LHLflyxDO6 vFCYlqs8ZEG/a1c3Aboh2XKpc1XqGsaSjbZyILpsD9PfuDx6qmcuCnFIzV5IQ56zykiT QVGEqWru9jjO2o3zVIaY0FdzASZkCOxlrfIwysL3Av9dM4mIaxTFO6rzE1mf94a6jHSc He2YyUX0g+OQb+2TUfO6nGpI+i7XZhdxDno8DbwLhI5ibVbgeqgY6fN/kfF3s7BAjaWG 49Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717400101; x=1718004901; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dicgZOJvKn5T8RaFpyT/8hZCmr01MJ9Sp/DfGcqf1B0=; b=jByfBiJdDw10WBR2+ILy6XU/1V9HX9bfjHdTmp2WdORNijDQ+GBEgy+rgErEYsEMR8 SI07cSHrak3MrtajBudcgchkk0CEczLqtLtPpODufn/sb6oT/CNUPSOiA6INF96o7q5s rH/sCyqXAD7l9re0BduzbmeBX3+5+3rs8ExAVlY892a48Kf/6HgHbZLguYNReAVbQPmK E0EbLCUWK7NPVGiCfjuwp4SJq41KZMPoJ0wQ0Wb2WOxEpZBm3bUHDS9fitGsSpPcaCCX 29ndVw7NCVibNxnDz58pznBaSFNAKJhFkX+KmCgWSSuWGvj//ULU1STsiacG1LZwpz0h hDxw== X-Forwarded-Encrypted: i=1; AJvYcCX6U2D0C2l7e8+DnXN81urJLQFMVTjW0x7Wm0yNOhP4TQPaFTvXtG6XJ9qzcFxMKBu6VldfPVyil+LGQp2K4MI1SG6skHRAHa/QeE3n2i4KYc5RDmo= X-Gm-Message-State: AOJu0YyERQUmhVkCuVo415iVwZpSnImE7C+4OmNHtOE9pnY2IaZjnlHG cy1v2WlI4TR63CJxIYU2kfbYTOy8avx9NfJRKMxJcUSA08tklWn/ X-Google-Smtp-Source: AGHT+IEEgeFVnXmG6lbJKYsvkxGXa9tP597wtFh2250QbRrm/he4vpWuR6MbekVDIbwfm4OL4KByBw== X-Received: by 2002:a05:600c:45c3:b0:420:171c:3d70 with SMTP id 5b1f17b1804b1-4212e05daa7mr70827895e9.16.1717400100851; Mon, 03 Jun 2024 00:35:00 -0700 (PDT) Received: from eichest-laptop ([2a02:168:af72:0:2b03:375:843f:be9d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b8a5658sm107324345e9.34.2024.06.03.00.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 00:35:00 -0700 (PDT) Date: Mon, 3 Jun 2024 09:34:58 +0200 From: Stefan Eichenberger To: Andrew Lunn Cc: o.rempel@pengutronix.de, kernel@pengutronix.de, andi.shyti@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, jic23@kernel.org, lars@metafoo.de, nuno.sa@analog.com, andriy.shevchenko@linux.intel.com, u.kleine-koenig@pengutronix.de, marcelo.schmitt@analog.com, gnstark@salutedevices.com, francesco.dolcini@toradex.com, linux-i2c@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Stefan Eichenberger Subject: Re: [RFC PATCH] i2c: imx: avoid rescheduling when waiting for bus not busy Message-ID: References: <20240531142437.74831-1-eichest@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240603_003504_539246_A183F82A X-CRM114-Status: GOOD ( 33.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Jun 02, 2024 at 04:31:27PM +0200, Andrew Lunn wrote: > On Fri, May 31, 2024 at 04:24:37PM +0200, Stefan Eichenberger wrote: > > From: Stefan Eichenberger > > > > On our i.MX8M Mini based module we have an ADS1015 I2C ADC connected to > > the I2C bus. The ADS1015 I2C ADC will timeout after 25ms when the I2C > > bus is idle. The imx i2c driver will call schedule when waiting for the > > bus to become idle after switching to master mode. When the i2c > > controller switches to master mode it pulls SCL and SDA low, if the > > ADS1015 I2C ADC sees this for more than 25 ms without seeing SCL > > clocking, it will timeout and ignore all signals until the next start > > condition occurs (SCL and SDA low). > > Does the I2C specification say anything about this behaviour, or is it > specific to this device? > The timeouting mechanism is normally used in SMBus mode. However, for this specific device they still call it I2C which is a bit confusing. The difference between I2C and SMBus is that SMBus has a timeout while the I2C uses a recovery mechanism. Besides that the two protocols are identical. > > This rfc tries to solve the problem by using a udelay for the first 10 > > ms before calling schedule. This reduces the chance that we will > > reschedule. However, it is still theoretically possible for the problem > > to occur. To properly solve the problem, we would also need to disable > > interrupts during the transfer. > > > > After some internal discussion, we see three possible solutions: > > 1. Use udelay as shown in this rfc and also disable the interrupts > > during the transfer. This would solve the problem but disable the > > interrupts. Also, we would have to re-enable the interrupts if the > > timeout is longer than 1ms (TBD). > > 2. We use a retry mechanism in the ti-ads1015 driver. When we see a > > timeout, we try again. > > 3. We use the suggested solution and accept that there is an edge case > > where the timeout can happen. > > 2. has the advantage you fix it for any system with this device, not > just those using an IMX. Once question would be, is such a retry safe > in all conditions. Does the timeout happen before any non idempotent > operation is performed? > > If the I2C specification allows this behaviour, maybe a more generic > solution is needed, since it could affect more devices? Maybe I could add a smbus_xfer function to the i2c driver and then change the ti-ads1015 driver to use the smbus_xfer function instead of i2c. However, I would still have to disable preemption while the SMBus transfer is happening which concerns me a bit. Regards, Stefan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel