From patchwork Wed Oct 2 11:19:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13819669 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 7A9D0CF31B4 for ; Wed, 2 Oct 2024 11:22:08 +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=yQ6x4zObDyJ43omHbKWsYVs2kFPS4sw0rkU3gO4im2g=; b=UaZAT3XQgUG+WIfYNfVcExkHaS zvSpfX+m6YdnBycwiPhdN20zKkj/3eE64iTwTsS2z7zIPCGk/yg5K5cKkzX+0MKA4xSSU/oz04xPL 3HcGoaYNGzr/zty4kt+0xNN2JR1wMud4e83oq8ziuL8qR/F2PFEis+x+mmWXy96jdW4hdvx4HkU3H g5tIksuiR99Db+kbE7lzKT4oksIFbq+XSW6ml6cL15EYw/KgnsHdbETyW0OLPwG9K6pp83736pL4F +6cnbjzJA5CKHSjSlADkhNf7+iNjsZdwHSkdBVXLFpWf4t6yZW519w9IGTSjdDhiRbUJSZ+Rf1iii nHtJO1Jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svxQc-00000005def-3SkN; Wed, 02 Oct 2024 11:21:58 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svxP6-00000005d6J-0DvF for linux-arm-kernel@lists.infradead.org; Wed, 02 Oct 2024 11:20:25 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42e7b7bef42so53983675e9.3 for ; Wed, 02 Oct 2024 04:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727868022; x=1728472822; 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=yQ6x4zObDyJ43omHbKWsYVs2kFPS4sw0rkU3gO4im2g=; b=V/rALoTAqoEaMkN35yXW1GtC0N9fmmZJN62PJW9BkCoW4T+fm9wL6zIWMmyAYhh+cb mUnSOgfLWStbswRpKyGNGQ+gqSuvW7adopNnGHlVINM2rWGfItCr/Nna3GPo/hnZXNs4 q/Ty16anvdvewliORaGJggMp3o7ZDjxgwCXaVp6j/uu8haL5lbx46y6vOq4CjIfP8BLs eZ/T4TSCA4WkZHvgWPh5Ldo2myA6lBeUTTlkLvjIw2uvIs6A1JDDV8HdkJA+doHRZVeg t/3jFicm3ta2rTbylZBIafwo8o3liOF7P/BNqGHAOAUxcNQ8RCnaEKovBuCktRzV8gXc ax1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727868022; x=1728472822; 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=yQ6x4zObDyJ43omHbKWsYVs2kFPS4sw0rkU3gO4im2g=; b=j6+fqgTbAnQtxhtkjk9XYAVUFGiseLjt8Ax5VQQkR62L5PhEeOoU6UoJSK7TvhRDDb rCap+YU7r7Fm+dUOfNs67ZJBXcYw5hZAyomliE7DmaGzCcdUmgIcU2TKkmSTz3B5eZvP wLtD4daGBiDFP2PnrW5VHfMCNch3Sx7R+jh69XWhzZmGMOOVE2H4FDH+LNjCNnfpzK4N xXSxoEHXcHROYMbADc3A8NCAZ23PM0sSrCrgMaQAJjrbyI5migi7/m2Tvf5r2pShQfrm ofbFw2joSjQlxbckazKLelgq+4OjRdRUOeVtH0p2JjI50uU2uvosEIWKw95lECYypG2c V69w== X-Forwarded-Encrypted: i=1; AJvYcCVIVcpXHmLY4F1vYvXqAUrhftk4bQ/8rS5k7760GKI9PYHwHsI/qS285yG8XCPPCjns32EJ7Ww0ifh8S0o55A8l@lists.infradead.org X-Gm-Message-State: AOJu0YxDGG9jvl8dDEZ8r+0zjgRCZoNT2dWn9SQzw29RM11mX2LG7x2b kS8j9z3MGLSRZOonYuWAIe9dl6fIKKddPmOfeWOIUNkiT0V/hdqp X-Google-Smtp-Source: AGHT+IFr/46f/cbDZz1FoAo51AuLN5PJHXEunpu05Lqv3Z5yVZrxyifxONPvmsJa38GK+xLCRjfi4w== X-Received: by 2002:a05:600c:511d:b0:42c:a72a:e8f4 with SMTP id 5b1f17b1804b1-42f777b798bmr21423495e9.14.1727868021592; Wed, 02 Oct 2024 04:20:21 -0700 (PDT) Received: from eichest-laptop.corp.toradex.com (31-10-206-125.static.upc.ch. [31.10.206.125]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f771a1209sm23530685e9.0.2024.10.02.04.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 04:20:21 -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, 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, francesco.dolcini@toradex.com Subject: [PATCH v4 0/4] i2c: imx: prevent rescheduling in non-dma mode Date: Wed, 2 Oct 2024 13:19:38 +0200 Message-ID: <20241002112020.23913-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-20241002_042024_119260_07F8AF15 X-CRM114-Status: GOOD ( 18.38 ) 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 v3: - Fixed style issues with checkpatch.pl --strict (Andi) - Add comments to explain the code (Andi) 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 | 369 ++++++++++++++++++++++++++++++----- 1 file changed, 317 insertions(+), 52 deletions(-)