From: Jules Maselbas <jmaselbas@kalray.eu>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/3] usb: gadget: dfu: Progressive erase if file is a mtd
Date: Thu, 26 Mar 2020 10:08:31 +0100 [thread overview]
Message-ID: <20200326090831.jsudgkjc4mjjraau@tellis.lin.mbt.kalray.eu> (raw)
In-Reply-To: <20200326060311.GI27288@pengutronix.de>
Hi Sascha,
On Thu, Mar 26, 2020 at 07:03:11AM +0100, Sascha Hauer wrote:
> Hi Jules,
>
> >
> > @@ -132,6 +134,10 @@ struct file_list_entry *dfu_file_entry;
> > static int dfufd = -EINVAL;
> > static struct file_list *dfu_files;
> > static int dfudetach;
> > +static struct mtd_info_user dfu_mtdinfo;
> > +static loff_t dfu_written;
> > +static loff_t dfu_erased;
> > +static int prog_erase;
>
> These are not initialized, this works for the first file updated via
> DFU, but what about the following ones?
Good point, this initialization is be required between to file.
I don't think cleaning this in unbind will be sufficient, I will
try to update multiple files.
>
> >
> > /* USB DFU functional descriptor */
> > static struct usb_dfu_func_descriptor usb_dfu_func = {
> > @@ -327,8 +333,16 @@ static void dfu_cleanup(struct f_dfu *dfu)
> > static void dn_complete(struct usb_ep *ep, struct usb_request *req)
> > {
> > struct f_dfu *dfu = req->context;
> > + loff_t size;
> > int ret;
> >
> > + if (prog_erase && (dfu_written + req->length) > dfu_erased) {
> > + size = roundup(req->length, dfu_mtdinfo.erasesize);
> > + erase(dfufd, size, dfu_erased);
>
> You should check the return value here.
Right
> > + dfu_erased += size;
> > + }
> > +
> > + dfu_written += req->length;
> > ret = write(dfufd, req->buf, req->length);
> > if (ret < (int)req->length) {
> > perror("write");
> > @@ -493,7 +507,12 @@ static int dfu_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
> > }
> >
> > if (!(dfu_file_entry->flags & FILE_LIST_FLAG_SAFE)) {
> > - ret = erase(dfufd, ERASE_SIZE_ALL, 0);
> > + ret = ioctl(dfufd, MEMGETINFO, &dfu_mtdinfo);
> > + if (ret) /* not a mtd */
> > + ret = erase(dfufd, ERASE_SIZE_ALL, 0);
> > + else
> > + prog_erase = 1;
>
> I am not aware of any non mtd devices that need erase. I think you can
> drop the full erase here.
OK
Thanks for the review,
Jules
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-03-26 9:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 15:46 [PATCH 0/3] usb: gadget: dfu: Fix timeout on erase when using big partition Jules Maselbas
2020-03-24 15:46 ` [PATCH 1/3] usb: gadget: dfu: Add manifestation phase Jules Maselbas
2020-03-24 15:46 ` [PATCH 2/3] usb: gadget: dfu: Progressive erase if file is a mtd Jules Maselbas
2020-03-26 6:03 ` Sascha Hauer
2020-03-26 9:08 ` Jules Maselbas [this message]
2020-03-24 15:46 ` [PATCH 3/3] usb: gadget: dfu: Reset global variables on unbind Jules Maselbas
2020-03-26 6:09 ` 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=20200326090831.jsudgkjc4mjjraau@tellis.lin.mbt.kalray.eu \
--to=jmaselbas@kalray.eu \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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