linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Stefan Eichenberger <eichest@gmail.com>,
	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: imx@lists.linux.dev, linux-kernel@vger.kernel.org,
	Stefan Eichenberger <stefan.eichenberger@toradex.com>,
	linux-i2c@vger.kernel.org,  francesco.dolcini@toradex.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 1/4] i2c: imx: only poll for bus busy in multi master mode
Date: Wed, 02 Oct 2024 16:40:32 +0200	[thread overview]
Message-ID: <6378933c8d30bec2c3084e41c83b9d129d0d40d1.camel@pengutronix.de> (raw)
In-Reply-To: <20241002112020.23913-2-eichest@gmail.com>

Am Mittwoch, dem 02.10.2024 um 13:19 +0200 schrieb Stefan Eichenberger:
> From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> 
> According to the i.MX8M Mini reference manual chapter "16.1.4.2
> Generation of Start" 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.
> 
This is a backward incompatible change, as far as I can see. Until now
the driver would properly handle a multi-mastered bus, without any
specific configuration. Now it requires the new multi-master DT
property to be set, which isn't even documented in the binding to be
understood by this driver.

Are you sure that every single instance of a i.MX i2c bus is only
single mastered?

If this is a worthwhile performance improvement I guess you need to
flip the logic around by adding a new single-master DT property (or
something along those lines), which should go through proper DT binding
review. You can then use this property for boards/busses to opt into
skipping the arbitration lost check.

Regards,
Lucas

> Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  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 98539313cbc97..fbacdfaf6b28e 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,


  reply	other threads:[~2024-10-02 14:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 11:19 [PATCH v4 0/4] i2c: imx: prevent rescheduling in non-dma mode Stefan Eichenberger
2024-10-02 11:19 ` [PATCH v4 1/4] i2c: imx: only poll for bus busy in multi master mode Stefan Eichenberger
2024-10-02 14:40   ` Lucas Stach [this message]
2024-10-02 14:56     ` Stefan Eichenberger
2024-10-02 15:16       ` Lucas Stach
2024-10-02 11:19 ` [PATCH v4 2/4] i2c: imx: separate atomic, dma and non-dma use case Stefan Eichenberger
2024-10-02 11:19 ` [PATCH v4 3/4] i2c: imx: use readb_relaxed and writeb_relaxed Stefan Eichenberger
2024-10-02 11:51   ` Arnd Bergmann
2024-10-02 13:08     ` Stefan Eichenberger
2024-10-02 13:36       ` Arnd Bergmann
2024-10-02 14:36         ` Stefan Eichenberger
2024-10-02 11:19 ` [PATCH v4 4/4] i2c: imx: prevent rescheduling in non dma mode Stefan Eichenberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6378933c8d30bec2c3084e41c83b9d129d0d40d1.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=Frank.Li@nxp.com \
    --cc=andi.shyti@kernel.org \
    --cc=eichest@gmail.com \
    --cc=festevam@gmail.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=stefan.eichenberger@toradex.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).