From patchwork Mon Jul 15 15:17:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13733603 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 006C1C3DA4B for ; Mon, 15 Jul 2024 15:19:18 +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:References:In-Reply-To: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:List-Owner; bh=ce5HKGru3176tg37KzVwYW1GSZqa27PAYLpfwOr/uas=; b=L+XOyNGbP4fFEe+Bnu4ZQZ3XGj L+pCSYuu4OMisuU+xX4Bu7QFaFhB0Lm/SIJDZqiIRhgmqxwdHIfQi2U0DD34zE3/RRd9gNFbMwt1K iLH7FEZnffxUHymaUj0JdKJ/rvPFhhgCoeTGQwvzuFZOXiFOzULN5t724Tni5MlOMp5eH4L60uCbL 5Gp2JtdFPnxCNcN4jWZtoHxxObRyGvgGaHT005yV0EsEWAwX+YKkjCcZgl5iY4REPHP4CXGZptt43 eNGGjuRh+BXWzBvwUkbamPMr4Cz5AiVL6mp6lillERruSv/VhU6X8hXOwtzz6EMIS7h0hzhcbnW9U yeC4iCWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNTk-00000007W4E-1duy; Mon, 15 Jul 2024 15:19:04 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNTI-00000007Vtt-0jwn for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 15:18:37 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3679f806223so3266408f8f.0 for ; Mon, 15 Jul 2024 08:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721056715; x=1721661515; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ce5HKGru3176tg37KzVwYW1GSZqa27PAYLpfwOr/uas=; b=cjqdqxC8zwq9RhPk29OEcHh22OIFdzrx+4di5LdV+J1X4Pg9BJw/txbokAFm9/ugv7 CMkqLQ28kZUG1ECi1tNtMGhOArjnqJaOna3lYqol8/aWoD7ErEanjG3FjIh2GNiFPQQ6 grGnKWQ4NjWfX78K2z+vArF7+jn2tjHbxWIN7AG5Y+Qc5S6c55bDsYNbZAtVJAeVcdvp FV1tsgugRVHpaLnPc50Qzs+lh7A67WGyzNSTo4G0yYBS/kWNQlAhaU6kYw6VBk4T7dgG ir//04gPxq1QBkNnxXmGJDS5V1/NXUl13lp2z1ATFKNipEFiEOzlWvAAvdno3WpFGiL3 y+yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721056715; x=1721661515; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ce5HKGru3176tg37KzVwYW1GSZqa27PAYLpfwOr/uas=; b=M/VO1zilvd+I93XjJrMNwKF4SkQGFDDM1wmF98vA1CdhGLCgeEpHo4DmxeV5wlCkTZ aC+AYxS8eYOUWlfJ4tXPnG+et8vt7+FNh+pLJAjVDLQmNwVzqqr9gbgzpeI++T0WIp6o vHNMt0ueu2LDFuJfc8LqL9CJJ7HCIz5r0Qqhir0XF4+oE3518HXOqwGnGiYi+9UkyBzm LRlgUQPcI+c/AiLkulOoXuvDh+wPhknqN74GobMmgW+/aETJVoHMYohA4K7jOrGlr4nf 7q5Tnn0L+JQXoO5DjRQjYAMyhQEJvxx5Mil6tzShw8Ge2WSn9AYW6LvIpR8AYZzI3AX5 y8hQ== X-Forwarded-Encrypted: i=1; AJvYcCXTV4f15KDVWpa+XCBkBVT4a3KHjqheB3yOrUp4yGOcYLv/uwRWHgo7QYV3dilHwizYpF7j/3KxFrTwkB9jF+efKMc0+LPCkZPLo0eRY800E695poo= X-Gm-Message-State: AOJu0YzJYwUVwx7APS7alrbX6M7M6H8M79QT28C0Vxmqifd7gJMLPHkx iWPdGdxfukPT6j9LeEdkztlql9i8gKUzQEyt0aH7uJtJn9XPPVVe X-Google-Smtp-Source: AGHT+IGbuGcZ320eIDhwquWRL5r+JmXNJtzpqJAy33gfEJ4SEJlISeCaCZaCyiBiVy7I1VVyq8qHyg== X-Received: by 2002:a5d:61c7:0:b0:366:df58:1fd9 with SMTP id ffacd0b85a97d-367ff705372mr8165666f8f.24.1721056714706; Mon, 15 Jul 2024 08:18:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:18:34 -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, Stefan Eichenberger Subject: [PATCH v1 1/3] i2c: imx: only poll for bus busy in multi master mode Date: Mon, 15 Jul 2024 17:17:51 +0200 Message-ID: <20240715151824.90033-2-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240715151824.90033-1-eichest@gmail.com> References: <20240715151824.90033-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_081836_241948_BCF9DC02 X-CRM114-Status: GOOD ( 15.75 ) 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 From: Stefan Eichenberger According to the reference manual it is only necessary to poll for bus busy and arbitration lost in multi master mode. This helps to avoid rescheduling while the i2c bus is busy and avoids SMBus devices to timeout. Signed-off-by: Stefan Eichenberger Reviewed-by: Frank Li --- drivers/i2c/busses/i2c-imx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 3842e527116b7..1add946e3bc20 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -216,6 +216,8 @@ struct imx_i2c_struct { struct i2c_client *slave; enum i2c_slave_event last_slave_event; + bool multi_master; + /* For checking slave events. */ spinlock_t slave_lock; struct hrtimer slave_timer; @@ -481,6 +483,9 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy, bool a unsigned long orig_jiffies = jiffies; unsigned int temp; + if (!i2c_imx->multi_master) + return 0; + while (1) { temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); @@ -540,8 +545,8 @@ static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx, bool atomic) return -ETIMEDOUT; } - /* check for arbitration lost */ - if (i2c_imx->i2csr & I2SR_IAL) { + /* In multi-master mode check for arbitration lost */ + if (i2c_imx->multi_master && (i2c_imx->i2csr & I2SR_IAL)) { dev_dbg(&i2c_imx->adapter.dev, "<%s> Arbitration lost\n", __func__); i2c_imx_clear_irq(i2c_imx, I2SR_IAL); @@ -1468,6 +1473,8 @@ static int i2c_imx_probe(struct platform_device *pdev) goto rpm_disable; } + i2c_imx->multi_master = of_property_read_bool(pdev->dev.of_node, "multi-master"); + /* Set up clock divider */ i2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ; ret = of_property_read_u32(pdev->dev.of_node,