From patchwork Mon Jul 15 15:17:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13733602 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 176CFC3DA4A for ; Mon, 15 Jul 2024 15:18:58 +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=eaxYW18928fApQX7NIAaL07nRV5h6qNSI2LYfiTcfsY=; b=F6JuODyh82NI3+T2WCUtV3C96L VuvzrrkwQO0c/5VFmkiQItV4XCs0fINdUHkqRUv7pNS1d+cXLrjGE3ujgbjwR8mRFdlCpqb50HZkL cHFz4HsqTF9Xh2DHO2PMRF8cQJsFR7KZQI1FtJdOPKL12BehEds2kh+kr0Xum0C1ogp68rmbFb3lN SEBgsDkqAgHZQkYC+0FF1wXw0dfPJZjIJszFLnDlZsRfocSiAJ13zj312DR2pXQCtjpQSAolNBOY9 jLRj9ZdX9oRdIs/Dux+4DbKUs/6bWmNP0fAjgZOweAs2osdGvi0wswuJfkeo2JpFE8XxnED1534Li EO+B8ZXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNTU-00000007Vy3-00Uc; Mon, 15 Jul 2024 15:18:48 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNTA-00000007Vsv-05IO for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 15:18:29 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-36796aee597so2687993f8f.1 for ; Mon, 15 Jul 2024 08:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721056705; x=1721661505; 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=eaxYW18928fApQX7NIAaL07nRV5h6qNSI2LYfiTcfsY=; b=XiJ3dIWn9YONpOxxRhc9RCJiqzP56dZXl5NP/IglaTqOYOKWs98MdwFVJuZDEh/9bE wpupbB30thvG2kQNj3i9XgPuOyrMpdiBnWS8jGBa+nCNvsI6ogg17W4zvy99+VluQuG4 4daw1sUJ6BR4go/fyGzKs7gXzXplK7x8H5qjphxt45RpLIgfWuEawGcFiGDyAuGOVdFp RF/jWFdiGl6dX4V6hmEpthaxCGjw5RKr+MkZ/zgrR4RBhe6d7pDQ8TVwPdVNfo2coOTK 7aLwzP9ioQo6mVtr55va6nePzS+S7mNLmph/ICTh1hKQMzhms/9Wc9UnQ8WmtNwAOTju 9/5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721056705; x=1721661505; 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=eaxYW18928fApQX7NIAaL07nRV5h6qNSI2LYfiTcfsY=; b=QYmSYstiPkCtxPj77n534PgebgTG1zVPDUYeMFs/jxSssaD53V+Ha8kxX8WuyPyom3 mnsYWNgrZJAOqpshNIwjy8VvFpcl7yi8L6Ux3AwIwwTBLELXAfesHHflFIwxnLXEHgCh GSSSm2wor31EAVqzINfUjpVoiGQOo6q3YthsgXUs+AsVJ6h/PAu4WrpSHKNxP5qGDhWb xbDgqWritolGG1cS3gWWRMXCvaKQxiTWZqVUYQLcxbe11e5P9DQhLPgP2Id8hEje3yGD at6M3jFT2GV4i9m9uulxkNhTs8IkZS5cpk7gCN/4tryYnyXJ/EjSyj71vwIKXKEMCnib ntcQ== X-Forwarded-Encrypted: i=1; AJvYcCVbH26TDS8JCDzovQDZChoojqDVMrYBxyLC/XiZP981vtsfbx2RoPNVzjHRqgAf4wSIoP8V9NCNvpuKAeGGH8udDHXm4vsvgVmAAzl04pLYOV8rUwo= X-Gm-Message-State: AOJu0Ywubm4KLaPSvvK59YbmDCiR5u0yeLcGfCSulNTn/pwRjLedtl+i O1pKXH0u4zWx+SyUruBtIFR3wInRYy/V13JXCfVAjc7jGIjdQKKL X-Google-Smtp-Source: AGHT+IEhStM/DudKKCc45zVD28c8qJn9CETVW5rZ4uUz3HCOhvrgHcPsLwDzZKsocKkAt3opZvqtEQ== X-Received: by 2002:a05:6000:255:b0:367:96bd:127e with SMTP id ffacd0b85a97d-368240beb76mr22926f8f.46.1721056705292; Mon, 15 Jul 2024 08:18:25 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:564b:c18:f4fc:19ad]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbb5bsm6682609f8f.80.2024.07.15.08.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:18:24 -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, wsa+renesas@sang-engineering.com, francesco.dolcini@toradex.com, joao.goncalves@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 v1 0/3] i2c: imx: prevent rescheduling in non-dma mode Date: Mon, 15 Jul 2024 17:17:50 +0200 Message-ID: <20240715151824.90033-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-20240715_081828_079780_9D276B12 X-CRM114-Status: GOOD ( 15.68 ) 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. Stefan Eichenberger (3): i2c: imx: only poll for bus busy in multi master mode i2c: imx: separate atomic, dma and non-dma use case i2c: imx: prevent rescheduling in non dma mode drivers/i2c/busses/i2c-imx.c | 353 ++++++++++++++++++++++++++++++----- 1 file changed, 303 insertions(+), 50 deletions(-)