U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Romain Gantois <romain.gantois@bootlin.com>
To: u-boot@lists.denx.de, Mattijs Korpershoek <mkorpershoek@kernel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Tom Rini <trini@konsulko.com>, Lukasz Majewski <lukma@denx.de>,
	Marek Vasut <marex@denx.de>,
	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Kever Yang <kever.yang@rock-chips.com>,
	Peter Robinson <pbrobinson@gmail.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	George Chan <gchan9527@gmail.com>,
	Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>,
	Herve Codina <herve.codina@bootlin.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Ralph Siemsen <ralph.siemsen@linaro.org>,
	Simon Glass <sjg@chromium.org>, Peng Fan <peng.fan@nxp.com>,
	Kory Maincent <kory.maincent@bootlin.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Kuan-Wei Chiu <visitorckw@gmail.com>,
	Raymond Mao <raymond.mao@riscstar.com>,
	 Stefan Roese <stefan.roese@mailbox.org>,
	Philip Molloy <philip.molloy@analog.com>,
	Jerome Forissier <jerome.forissier@arm.com>,
	David Lechner <dlechner@baylibre.com>,
	Julien Stephan <jstephan@baylibre.com>,
	Johan Jonker <jbx6244@gmail.com>,
	Bastien Curutchet <bastien.curutchet@bootlin.com>
Subject: Re: [PATCH v3 2/2] usb: gadget: Add Renesas RZ/N1 USBF controller support
Date: Mon, 30 Nov 2026 15:04:01 +0100	[thread overview]
Message-ID: <XKCBUSYiSyGyDlLeGqTUNA@bootlin.com> (raw)
In-Reply-To: <875x0yo0w2.fsf@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 2659 bytes --]

Hi Mattijs,

On Tuesday, 25 August 2026 14:11:41 CET Mattijs Korpershoek wrote:
...
> > 
> >> > +static void usbf_ahb_epc_irq(struct usbf_udc *udc)
> >> > +{
> >> > +	unsigned long flags;
> >> > +	struct usbf_ep *epn;
> >> > +	u32 sysbint, sysben;
> >> > +	void (*ep_action)(struct usbf_ep *epn);
> >> > +	int i;
> >> > +
> >> > +	spin_lock_irqsave(&udc->lock, flags);
> >> > +
> >> > +	/* Read and ack interrupts */
> >> > +	sysbint = usbf_reg_readl(udc, USBF_REG_AHBBINT);
> >> > +	sysben = usbf_reg_readl(udc, USBF_REG_AHBBINTEN);
> >> > +	sysbint &= sysben;
> >> 
> >> In the linux driver, we don't read USBF_REG_AHBBINTEN. Can you explain
> >> why this is needed here?
> > 
> > This is due to the fact that U-Boot calls this handler in a polling
> > manner. In Linux, when we disable bridge interrupts e.g. during DMA
> > transfer operations, we can be sure that the handler won't get called,
> > since the AHBBINTEN register masks interrupts.
> > 
> > However in U-Boot, the contents of AHBBINTEN do not prevent the handler
> > from being called since we're continuously calling it in polling mode.
> > We've actually ran into bugs because of this while testing initial
> > versions of the driver port. Therefore, we mask AHBBINT with the contents
> > of AHBBINTEN to prevent bridge events from being serviced when we don't
> > want them to.
> Ok, since this is a deliberate (and necessary) change because we operate
> in polling mode, can we please document this in a comment in the driver?
> That will make it more clear when others read/diff the code against linux.
> 

ACK, I'll add a comment in v4.

> >> > +	usbf_reg_writel(udc, USBF_REG_AHBBINT, sysbint);
> >> > +
> >> > +	if ((sysbint & USBF_SYS_VBUS_INT) == USBF_SYS_VBUS_INT) {
> >> > +		if (usbf_reg_readl(udc, USBF_REG_EPCTR) & USBF_SYS_VBUS_LEVEL)
> > 
> > {
> > 
> >> > +			g_dnl_clear_detach();
> >> 
> >> Why do we need to depend on g_dnl_*() ?
> >> This is the only gadget driver that does this. It seems wrong (g_dnl* is
> >> usually called from higher up (in u-boot commands or function drivers)
> > 
> > The purpose of this is to signal to function drivers that the VBUS status
> > has changed (presumably because of a cable removal) and that they should
> > stop polling the UDC interrupt handler and exit cleanly. This seems like
> > a correct use of this mechanism to me, but indeed I don't know why other
> > UDC drivers don't use it this way.
> 
> I see. Why can't we implement the .vbus_session operation then?
> See at91_udc.c for example.

I'll have a look, thanks for the tip!

Thanks,

-- 
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2026-11-30 14:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  9:09 [PATCH v3 0/2] usb: gadget: Add Renesas RZ/N1 USBF driver Romain Gantois via U-Boot
2026-07-23  9:09 ` [PATCH v3 1/2] linux/list.h: Add list_is_first() Romain Gantois via U-Boot
2026-07-23  9:09 ` [PATCH v3 2/2] usb: gadget: Add Renesas RZ/N1 USBF controller support Romain Gantois via U-Boot
2026-07-23 19:53   ` Marek Vasut via U-Boot
2026-07-24  5:15     ` Romain Gantois via U-Boot
2026-07-24 15:19       ` Marek Vasut via U-Boot
2026-11-30 13:52         ` Romain Gantois
2026-11-30 14:39           ` Marek Vasut
2026-07-24  7:46   ` Mattijs Korpershoek
     [not found] ` <K-c4utCyTiG30qpq3vvx3A@bootlin.com>
     [not found]   ` <875x0yo0w2.fsf@kernel.org>
2026-11-30 14:04     ` Romain Gantois [this message]

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=XKCBUSYiSyGyDlLeGqTUNA@bootlin.com \
    --to=romain.gantois@bootlin.com \
    --cc=balaji.selvanathan@oss.qualcomm.com \
    --cc=bastien.curutchet@bootlin.com \
    --cc=dlechner@baylibre.com \
    --cc=gchan9527@gmail.com \
    --cc=herve.codina@bootlin.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=iwamatsu@nigauri.org \
    --cc=jbx6244@gmail.com \
    --cc=jerome.forissier@arm.com \
    --cc=jonas@kwiboo.se \
    --cc=jstephan@baylibre.com \
    --cc=kever.yang@rock-chips.com \
    --cc=kory.maincent@bootlin.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=mkorpershoek@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=pbrobinson@gmail.com \
    --cc=peng.fan@nxp.com \
    --cc=philip.molloy@analog.com \
    --cc=quentin.schulz@cherry.de \
    --cc=ralph.siemsen@linaro.org \
    --cc=raymond.mao@riscstar.com \
    --cc=sjg@chromium.org \
    --cc=stefan.roese@mailbox.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=visitorckw@gmail.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