From patchwork Mon Aug 19 07:19:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13768006 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 AF971C3DA4A for ; Mon, 19 Aug 2024 07:21:49 +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=QBJBMpVP1Qqp6dsvradH2JN9txbqE2dyspVTQ3WIhME=; b=s5xKN7d5Bgf/HZnclzv7bwV4BL tLg0ZZi+QOzc2CbjzS8yVWgbPoipVPsxATAUyM+NMK/EHJHdx58Z9SQzGKcjYTtnVBmH3C5qy7XB8 wzFixoyFKVi6Pb2jsWn2nwg8MpD5l0QAjXbZOGqdJXDqYopoPji3+4eHMhh83VdoXfjJf8UiDUVig 9TGPwf/wcsKm925ngvqGBjWcJHQtsvwX7yySLfKhgb8xeiblWD50VvEWKQWZ3O0EUzV8GPNGLsy0U thQMbC1d091W6Iu659CLgoVOT+2H1v2FlNm6kCwzE0LCD82K1B+LUoBYWwPzJ6Mug4yJWpvnWDwL5 RUrobFCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfwhv-00000000c1p-0rub; Mon, 19 Aug 2024 07:21:39 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfwhE-00000000bpA-1fj7 for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 07:20:58 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42819654737so30550285e9.1 for ; Mon, 19 Aug 2024 00:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724052054; x=1724656854; 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=QBJBMpVP1Qqp6dsvradH2JN9txbqE2dyspVTQ3WIhME=; b=kwDrmDf3OYNKyvS689UAwJ9N4idetRchKhIpJpF0r5Xyjm0zKBdBGvrIyOeSI/owug TrxoHSAYlvPxizHAidop0B5Ujijql+965oSMY9nuOOEo1aN3UnuJBhJYs6b10A9pFOfo xkqBg2N30hT0TfCDgmYWCGALct1ZiNFG/K/ZosZhNgyBKWE5NWhL3UumE+sag4ND5GQz cGqQn/0bpkuw6jqpYi6QErcR5iDa7HC1Uj/n/CpFOY3pI5fh2iSQmMFbMugbzBDvJgzf 1BSptRbJV2PKLFr6MBPDx2RPYrH1JRpDsgukXimRfZ44h2hgJM8EVVV116BZ+LhCyF+I sgPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724052054; x=1724656854; 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=QBJBMpVP1Qqp6dsvradH2JN9txbqE2dyspVTQ3WIhME=; b=nnSXnmHAPCNWn3lENFNr9asVwVuuH+cUgnIY8pJ7K+FckFWOhtlEv7iQHptyPc5Bxy 00dvHoSWdXSl4gTsCRS2cz4e8YfxkKxnhVAe1w/XpgbOa0LidTRZR9RWyuCisIG5/+r9 /41xQwkvJxyzKGI7V8/q6JLS9Qhcx28bukTFzIFZx+t3LxjOhSlG++gLChuf969IB8Jr Jii4oG8oClyS9grIO5Qur4A6s9/yiZyP2USihY8ZKs26r5I3yhwTqZ8Nf0BHAAMHkpet tAC2sOceFzA1obZT1GTrSh/r4wJ3fgASppmdWiHRrfLccs6kB/DR+47pM748vPMEUIGy Yiig== X-Forwarded-Encrypted: i=1; AJvYcCUsSqZLzAoxGKflFdIF7fwgj9E5pXkKl8M3WphQKPKTU8Qac5E4GH/8nQFxqN0OiMX2ZULJ3Qw/Cg1ejh+Wv3zY5djXp9Pm9SC9zSm90nxyqrt0ai4= X-Gm-Message-State: AOJu0YwkA1gov8X6REke4+us1Hb61PjMI2pdfY4KZNhupGkSThdBlsJK sWJtlyk02maOD9ywCd5gwmuUkGWYOxL08U65mq7FUKLo/VHFWDAx X-Google-Smtp-Source: AGHT+IGxcSb67STOheDAxoW59TY02P8MKyR07H01z1D1mGbC+c92uKM/LcrctGwWt4LjNXGv3QUZUQ== X-Received: by 2002:adf:c00d:0:b0:367:4e05:bb7b with SMTP id ffacd0b85a97d-371946c309bmr5852163f8f.53.1724052053868; Mon, 19 Aug 2024 00:20:53 -0700 (PDT) Received: from eichest-laptop.toradex.int ([2a02:168:af72:0:a64c:8731:e4fb:38f1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896a9csm9683734f8f.79.2024.08.19.00.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 00:20:53 -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, francesco.dolcini@toradex.com Cc: linux-i2c@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/4] i2c: imx: prevent rescheduling in non-dma mode Date: Mon, 19 Aug 2024 09:19:06 +0200 Message-ID: <20240819072052.8722-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-20240819_002056_459091_471C54C6 X-CRM114-Status: GOOD ( 17.06 ) 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 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(-)