From patchwork Mon Sep 2 07:42:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13786868 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 97898CA0ED3 for ; Mon, 2 Sep 2024 07:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=uNCVUDNX1Tv+YX7UT89aRJAFgOTdoz7usQFFO/n4QDo=; b=PITMXm32jQZdTL/AN+ew6eKBLR emAA1uKVHjh4+If7PQZXxVUJDd/zBreG9YdzaHGqXMMvh/pmQoeQ/gPQimMrw7pIrQv5MtFuDMwc6 W8BulloJZ8msc+e3NG9JRoTDeP3PpVJzaqExYHGOzAe5KtNjg+/wo1fZzQARplEkweAOe/50kCqs6 9sUDn1Zz+FKU/KYdthGp7MCu/FSnKsgW0XHCJUwkpJ+07N2+g5ZrblN40SC/C5Hh4PNzXNAm66Dc4 ODWtCebZHvrBYLATfrJ1WUfZJJ8yGu2B2W37vEKU07gkARNLUPveMVP4u2vPjE26HsCfxnO2r5uWB NErDI+ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl1ji-0000000DM7F-2Rme; Mon, 02 Sep 2024 07:44:30 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl1io-0000000DLu8-0lym for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 07:43:35 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-53349d3071eso5153158e87.2 for ; Mon, 02 Sep 2024 00:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725263012; x=1725867812; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uNCVUDNX1Tv+YX7UT89aRJAFgOTdoz7usQFFO/n4QDo=; b=m7RwuV4RCwCx63I0gzfmfGtoxocVWBb1CWDRjmKJRFSMOJj4vYNAn6V40A6eM8fiLY RmZROEGAhpc8ZfeH9yh6LD39Jp3/7U5t3TDApZCSRYMAvjvrubRno4+0XqZg85cAEt+k kCEQAja0TFP25ElDMhUWBv4p5z3F9w9JZ+1LV8/104apv8bMCWygiNXz/DBLNN9mRvbw +XKGm4+8GbK/8TxxoVjaMT+vuto2BrCxxJHiiCVu+EPA9rmrfP4QrQ5peaooD1NIwuCn 0MfrzEvBrvk+33pNMwD0et4AHLmUfcrGPkhWCvsMQyA3UgS+3ps7xopg7Iyftc5830F3 jOCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725263012; x=1725867812; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uNCVUDNX1Tv+YX7UT89aRJAFgOTdoz7usQFFO/n4QDo=; b=jvhgPTUFdhr1eSI6hUmG9knX8alFKyEDS2SKLlgE+BW//7otaA8nTptYQRPjrHQ4aw hUT0jhx0KZzz7Gesz6n/ioVQ49RKc3Xa2y/rghtOJ+qfl+JIuDAYq6dhhSX6h/sVodbA C3i4R1yzz6WEs1fd0/nTxa2ZGzXj2Knkssg7Dp/9fF1y3ShYJi+1EEFBkLmCaC/BQArX Eat2u56+kki8S/8jkMXUUm5pAOFrgqq33Vp6VcQp/R58c06Njj/kwZnb/6iiBN8qLltf MDo8z9qaQvggAXBwKNcHEZJmoR7M3aNN1oNFrT3ycUaoTneiB13OPobf6djjn1e5lIkL xhwg== X-Forwarded-Encrypted: i=1; AJvYcCXs7W9GFZfySOqbzTF8f+QApiYewLlzF4HmPDrrCdHWID1lzm3yJvRIs3GcDH9IkI1TduJORQlxkDJrUycO8/Gy@lists.infradead.org X-Gm-Message-State: AOJu0Yxhdhxj8pRCfESZHzOPMoQuhqyj/wbgVtnNbYKHu37nemhvYBpv D81v+7cNzWj3uZOqJLUQ0+sLwAlrNpoQaeewieuQW1Ug+R1uF444 X-Google-Smtp-Source: AGHT+IHcXHMp2hddblg4Vie5l/V96lceR8sJACnCm6U91yljC/ORh+PPtQsZlU7/5QfIZ9YAggRkWQ== X-Received: by 2002:a05:6512:10d6:b0:52e:d0f8:2d30 with SMTP id 2adb3069b0e04-53546bb8cdbmr6772043e87.59.1725263011378; Mon, 02 Sep 2024 00:43:31 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:3786:cf07:4865:dc9f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c24ff04551sm1975931a12.35.2024.09.02.00.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 00:43:31 -0700 (PDT) From: Stefan Eichenberger To: o.rempel@pengutronix.de, kernel@pengutronix.de, andi.shyti@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, francesco.dolcini@toradex.com, Frank.Li@nxp.com Cc: linux-i2c@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/4] i2c: imx: prevent rescheduling in non-dma mode Date: Mon, 2 Sep 2024 09:42:00 +0200 Message-ID: <20240902074330.6349-1-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_004334_243749_AA766FA1 X-CRM114-Status: GOOD ( 18.73 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org While running tests on an i.MX8M Mini connected to a TI ADS1015 ADC, we found that the ADC would stop responding to i2c requests because it would timeout after the bus was idle for 25ms. This timeout could be traced back to the rescheduling events in the i2c-imx driver. The problem is that if the system is under heavy load, the schedule call and the wait_event_timeout may be rescheduled too late to reach the 25ms timeout. The same problem may occur with other SMBus devices. Therefore, this patchset removes the scheduling calls for non-DMA mode by handling the interrupt events directly in the ISR instead of scheduling a task to handle the events. This patch will introduce some bigger changes because the logic for handling events in the ISR had to be rewritten. Therefore we have tested the following combinations: - i.MX8M Mini with dma - i.MX8M Mini without dma - i.MX8M Plus with dma - i.MX8M Plus without dma - i.MX7D with dma - i.MX7D without dma - i.MX7D atomic mode Because we do not have any devices that use the SMBus block transfer mode, we were not able to test it. The ideas are based on the RFC: https://lore.kernel.org/all/20240531142437.74831-1-eichest@gmail.com/ However, the handling of events in the ISR is new, because further testing showed that it was not enough to simply remove the schedule call. Changes since v2: - Add Acked-by tags from Oleksij - Renamed i2c_imx_start_read to i2c_imx_prepare_read - I did not add a Fixes tag because the issues from Flavio have a different root cause and are not fixed by this patchset Changes since v1: - Add Reviewed-by tags from Frank - Add new patch to use readb_relaxed and writeb_relaxed (Frank) - Update commit message for patch 1 with some clarifications (Frank) Stefan Eichenberger (4): i2c: imx: only poll for bus busy in multi master mode i2c: imx: separate atomic, dma and non-dma use case i2c: imx: use readb_relaxed and writeb_relaxed i2c: imx: prevent rescheduling in non dma mode drivers/i2c/busses/i2c-imx.c | 357 ++++++++++++++++++++++++++++++----- 1 file changed, 305 insertions(+), 52 deletions(-)