public inbox for linux-i3c@lists.infradead.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Stanley Chu <stanley.chuys@gmail.com>
Cc: miquel.raynal@bootlin.com, alexandre.belloni@bootlin.com,
	linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
	tomer.maimon@nuvoton.com, kwliu@nuvoton.com, yschu@nuvoton.com
Subject: Re: [PATCH v1 1/2] i3c: master: svc: Receive IBI requests in interrupt context
Date: Tue, 15 Apr 2025 12:14:55 -0400	[thread overview]
Message-ID: <Z/6F/5fFLWWbfoae@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250415051808.88091-2-yschu@nuvoton.com>

On Tue, Apr 15, 2025 at 01:18:07PM +0800, Stanley Chu wrote:
> From: Stanley Chu <yschu@nuvoton.com>
>
> Moving the job from workqueue to ISR for two reasons.
>
> 1. Improve bus utilization.
> If the requests are postponed to be received in the workqueue thread,
> the SDA line remains low for a long time while the system loading is
> high. During this period, the bus is not available for other targets
> to raise requests.
>
> 2. Ensure prompt response to requests.
> For timing-critical requests, the target may encouter a failure or the
> event is missed if the request is not received in time.
>
> IBI request is short, ISR can receive the data quickly and then queue a
> work to handle it in the bottom half.
>
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/i3c/master/svc-i3c-master.c | 25 ++++++++++---------------
>  1 file changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 85e16de208d3..7ceaf3ec45bb 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -201,7 +201,6 @@ struct svc_i3c_drvdata {
>   * @addrs: Array containing the dynamic addresses of each attached device
>   * @descs: Array of descriptors, one per attached device
>   * @hj_work: Hot-join work
> - * @ibi_work: IBI work
>   * @irq: Main interrupt
>   * @pclk: System clock
>   * @fclk: Fast clock (bus)
> @@ -229,7 +228,6 @@ struct svc_i3c_master {
>  	u8 addrs[SVC_I3C_MAX_DEVS];
>  	struct i3c_dev_desc *descs[SVC_I3C_MAX_DEVS];
>  	struct work_struct hj_work;
> -	struct work_struct ibi_work;
>  	int irq;
>  	struct clk *pclk;
>  	struct clk *fclk;
> @@ -487,9 +485,8 @@ static int svc_i3c_master_handle_ibi_won(struct svc_i3c_master *master, u32 msta
>  	return ret;
>  }
>
> -static void svc_i3c_master_ibi_work(struct work_struct *work)
> +static void svc_i3c_master_ibi_isr(struct svc_i3c_master *master)
>  {
> -	struct svc_i3c_master *master = container_of(work, struct svc_i3c_master, ibi_work);
>  	struct svc_i3c_i2c_dev_data *data;
>  	unsigned int ibitype, ibiaddr;
>  	struct i3c_dev_desc *dev;
> @@ -504,7 +501,7 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)
>  	 * schedule during the whole I3C transaction, otherwise, the I3C bus timeout may happen if
>  	 * any irq or schedule happen during transaction.
>  	 */
> -	guard(spinlock_irqsave)(&master->xferqueue.lock);
> +	guard(spinlock)(&master->xferqueue.lock);
>
>  	/*
>  	 * IBIWON may be set before SVC_I3C_MCTRL_REQUEST_AUTO_IBI, causing
> @@ -530,7 +527,7 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)
>  	if (ret) {
>  		dev_err(master->dev, "Timeout when polling for IBIWON\n");
>  		svc_i3c_master_emit_stop(master);
> -		goto reenable_ibis;
> +		return;
>  	}
>
>  	status = readl(master->regs + SVC_I3C_MSTATUS);
> @@ -574,7 +571,7 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)
>
>  		svc_i3c_master_emit_stop(master);
>
> -		goto reenable_ibis;
> +		return;
>  	}
>
>  	/* Handle the non critical tasks */
> @@ -597,9 +594,6 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)
>  	default:
>  		break;
>  	}
> -
> -reenable_ibis:
> -	svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART);
>  }
>
>  static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id)
> @@ -618,10 +612,12 @@ static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id)
>  	    !SVC_I3C_MSTATUS_STATE_SLVREQ(active))
>  		return IRQ_HANDLED;
>
> -	svc_i3c_master_disable_interrupts(master);
> -
> -	/* Handle the interrupt in a non atomic context */
> -	queue_work(master->base.wq, &master->ibi_work);
> +	/*
> +	 * The SDA line remains low until the request is processed.
> +	 * Receive the request in the interrupt context to respond promptly
> +	 * and restore the bus to idle state.
> +	 */
> +	svc_i3c_master_ibi_isr(master);
>
>  	return IRQ_HANDLED;
>  }
> @@ -1947,7 +1943,6 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
>  		return ret;
>
>  	INIT_WORK(&master->hj_work, svc_i3c_master_hj_work);
> -	INIT_WORK(&master->ibi_work, svc_i3c_master_ibi_work);
>  	mutex_init(&master->lock);
>
>  	ret = devm_request_irq(dev, master->irq, svc_i3c_master_irq_handler,
> --
> 2.34.1
>

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  reply	other threads:[~2025-04-15 16:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15  5:18 [PATCH v1 0/2] svc-i3c-master: Reduce IBI transaction time Stanley Chu
2025-04-15  5:18 ` [PATCH v1 1/2] i3c: master: svc: Receive IBI requests in interrupt context Stanley Chu
2025-04-15 16:14   ` Frank Li [this message]
2025-04-15  5:18 ` [PATCH v1 2/2] i3c: master: svc: Emit STOP asap in the IBI transaction Stanley Chu
2025-04-15 16:15   ` Frank Li
2025-04-15  8:31 ` [PATCH v1 0/2] svc-i3c-master: Reduce IBI transaction time Miquel Raynal
2025-04-18  7:39   ` Stanley Chu
2025-05-15  9:54 ` Alexandre Belloni

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=Z/6F/5fFLWWbfoae@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=kwliu@nuvoton.com \
    --cc=linux-i3c@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=stanley.chuys@gmail.com \
    --cc=tomer.maimon@nuvoton.com \
    --cc=yschu@nuvoton.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