mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Daniel Glöckner" <dg@emlix.com>
Cc: Barebox List <barebox@lists.infradead.org>,
	Edmund Henniges <eh@emlix.com>
Subject: Re: [PATCH 15/19] fastboot net: implement fastboot over UDP
Date: Thu, 18 Jun 2020 13:59:40 +0200	[thread overview]
Message-ID: <20200618115940.GH11869@pengutronix.de> (raw)
In-Reply-To: <946b4a56-1c05-6dbd-32d1-c100d6681065@emlix.com>

On Wed, Jun 17, 2020 at 09:32:45PM +0200, Daniel Glöckner wrote:
> Hello Sascha,
> 
> Am 17.06.20 um 10:11 schrieb Sascha Hauer:
> 
> > +	ret = fastboot_net_wait_may_send(fbn);
> > +	if (ret)
> > +		return ret;
> 
> Where is the part that aborts the session on timeout?

Ok, will add it (back)

> 
> > +static void fastboot_start_download_net(struct fastboot *fb)
> > +{
> > +	struct fastboot_net *fbn = container_of(fb, struct fastboot_net,
> > +						fastboot);
> > +
> > +	fastboot_start_download_generic(fb);
> > +	fbn->active_download = true;
> > +}
> 
> You didn't base v4 on v3, did you?

No, you sent v3 while I had different changes in my version already.

> If FASTBOOT_INIT is received before active_download is set to true, nobody
> will close fb->download_fd.

Ok, I'll add a fastboot_abort() function like you did in v3.

> 
> > +static void fastboot_handle_type_fastboot(struct fastboot_net *fbn,
> > +					  struct fastboot_header header,
> > +					  char *fastboot_data,
> > +					  unsigned int fastboot_data_len)
> > +{
> > +	fbn->response_header = header;
> > +	fbn->host_waits_since = get_time_ns();
> > +	fbn->may_send = true;
> 
> No MAY_SEND_ACK and MAY_SEND_MESSAGE? So you choose to ignore protocol
> violations?

Will add it back.

> 
> > +	if (fbn->active_download) {
> > +		if (!fastboot_data_len && fbn->fastboot.download_bytes
> > +					   == fbn->fastboot.download_size) {
> > +			fastboot_download_finished(&fbn->fastboot);
> 
> Now I see why you dropped that fastboot_tx_print in the previous patch.
> 
> > +		} else {
> > +			fastboot_data_download(fbn, fastboot_data,
> > +					       fastboot_data_len);
> > +		}
> > +	} else {
> 
> Fastboot does not allow to queue multiple commands. A command must have
> finished before the host may send the next one. That's why there was
> an "else if (!fbn->command[0])".

Ah, I see. This would be !list_empty(&fbn->wq.work) now.

> 
> > +		if (fastboot_data_len >= FASTBOOT_MAX_CMD_LEN) {
> 
> Off-by-one error: if (fastboot_data_len > FASTBOOT_MAX_CMD_LEN) {

Ok.

> 
> > +		} else if (fastboot_data_len) {
> > +			struct fastboot_work *w;
> > +
> > +			w = xzalloc(sizeof(*w));
> 
> Why can't we embed struct fastboot_work in struct fastboot_net?
> As I wrote above it is impossible to queue multiple commands.

We could do that, but I prefer to keep it allocated. It makes the
lifetime of the work item clearer.

> 
> > +			w->fbn = fbn;
> > +			memcpy(w->command, fastboot_data, fastboot_data_len);
> > +			w->command[fastboot_data_len] = 0;
> > +
> > +			wq_queue_work(&fbn->wq, &w->work);
> > +		}
> > +	}
> > +
> > +	if (!fbn->fastboot.active)
> > +		fbn->active_download = false;
> 
> These two lines were gone in v3.

Ok, will drop them.

> 
> > +static void fastboot_send_keep_alive(struct poller_struct *poller)
> > +{
> > +	struct fastboot_net *fbn = container_of(poller, struct fastboot_net,
> > +					       keep_alive_poller);
> > +
> > +	if (!fbn->send_keep_alive)
> > +		return;
> > +
> > +	if (!is_timeout_non_interruptible(fbn->host_waits_since,
> > +					 30ULL * NSEC_PER_SEC))
> > +		return;
> > +
> > +	if (!fbn->may_send)
> > +		return;
> > +
> > +	fastboot_tx_print(&fbn->fastboot, FASTBOOT_MSG_INFO, "still busy");
> > +
> > +	fbn->host_waits_since = get_time_ns();
> 
> Why do we need this line?
> host_waits_since is assigned get_time_ns() when may_send is set to true.

It is needed to reinitialize the timeout when we sent the message once.
Without this we would send the "still busy" message every few ms after
we've sent it for the first time.

Regards,
  Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-06-18 11:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  8:11 [PATCH v4 00/19] Slices and " Sascha Hauer
2020-06-17  8:11 ` [PATCH 01/19] Introduce slices Sascha Hauer
2020-06-17  8:11 ` [PATCH 02/19] Add workqueues Sascha Hauer
2020-06-17 18:30   ` Daniel Glöckner
2020-06-17 19:56     ` Sascha Hauer
2020-06-17  8:11 ` [PATCH 03/19] ratp: Switch to workqueues Sascha Hauer
2020-06-17  8:11 ` [PATCH 04/19] net: Add a slice to struct eth_device Sascha Hauer
2020-06-17  8:11 ` [PATCH 05/19] net: mdiobus: Add slice Sascha Hauer
2020-06-17  8:11 ` [PATCH 06/19] usb: Add a slice to usb host controllers Sascha Hauer
2020-06-17  8:11 ` [PATCH 07/19] usbnet: Add slice Sascha Hauer
2020-06-17  8:11 ` [PATCH 08/19] net: Call net_poll() in a poller Sascha Hauer
2020-06-17  8:11 ` [PATCH 09/19] net: reply to ping requests Sascha Hauer
2020-06-17  8:11 ` [PATCH 10/19] usbnet: Be more friendly in the receive path Sascha Hauer
2020-06-17  8:11 ` [PATCH 11/19] defconfigs: update renamed fastboot options Sascha Hauer
2020-06-17  8:11 ` [PATCH 12/19] globalvar: Add helper for deprecated variable names Sascha Hauer
2020-06-17  8:11 ` [PATCH 13/19] fastboot: rename usbgadget.fastboot_* variables to fastboot.* Sascha Hauer
2020-06-17  8:11 ` [PATCH 14/19] fastboot: remove double print Sascha Hauer
2020-06-17 18:24   ` Daniel Glöckner
2020-06-17 19:54     ` Sascha Hauer
2020-06-18 19:08       ` Daniel Glöckner
2020-06-19  7:01         ` Sascha Hauer
2020-06-17  8:11 ` [PATCH 15/19] fastboot net: implement fastboot over UDP Sascha Hauer
2020-06-17 19:32   ` Daniel Glöckner
2020-06-18 11:59     ` Sascha Hauer [this message]
2020-06-18 18:33       ` Daniel Glöckner
2020-06-19  7:38         ` Sascha Hauer
2020-06-17  8:11 ` [PATCH 16/19] usb: fastboot: execute commands in command context Sascha Hauer
2020-06-17 19:40   ` Daniel Glöckner
2020-06-18  7:26     ` Sascha Hauer
2020-06-17  8:11 ` [PATCH 17/19] Add WARN_ONCE() macro Sascha Hauer
2020-06-17  8:11 ` [PATCH 18/19] fs: Warn when filesystem operations are called from a poller Sascha Hauer
2020-06-17  8:11 ` [PATCH 19/19] Documentation: Add document for parallel execution in barebox Sascha Hauer

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=20200618115940.GH11869@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=dg@emlix.com \
    --cc=eh@emlix.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