Re: [PATCH v5 16/16] usb: gadget: UMS: fix 64-bit division on ARM32
Hi Mattijs, On 02/04/2024 09:24, Mattijs Korpershoek wrote: Hi Caleb, Thank you for the patch. On jeu., mars 28, 2024 at 17:59, Caleb Connolly wrote: The patch introducing support for dynamic sector sizes changed the types used in some divisions, resulting in the compiler attempting to use libgcc helpers (__aeabi_ldivmod). Replace these divisions with calls to lldiv() to handle this correctly. Fixes: 74e56e0c5065 ("usb: gadget: UMS: support multiple sector sizes") Signed-off-by: Caleb Connolly I believe I applied this already via [1] Oh yes of course, I'm not sure quite how this patch ended up in my outbox, apologies for any confusion. I plan to send your work to Tom this week. Sorry for the delay! No problem at all. Thanks, [1] https://lore.kernel.org/r/87a5mqei67@baylibre.com --- Cc: Mattijs Korpershoek --- drivers/usb/gadget/f_mass_storage.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index d880928044f4..ef90c7ec7fb5 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -239,8 +239,9 @@ /* #define VERBOSE_DEBUG */ /* #define DUMP_MSGS */ #include +#include #include #include #include #include @@ -768,10 +769,10 @@ static int do_read(struct fsg_common *common) } /* Perform the read */ rc = ums[common->lun].read_sector(&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, + lldiv(file_offset, curlun->blksize), + lldiv(amount, curlun->blksize), (char __user *)bh->buf); if (!rc) return -EIO; @@ -942,10 +943,10 @@ static int do_write(struct fsg_common *common) amount = bh->outreq->actual; /* Perform the write */ rc = ums[common->lun].write_sector(&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, + lldiv(file_offset, curlun->blksize), + lldiv(amount, curlun->blksize), (char __user *)bh->buf); if (!rc) return -EIO; nwritten = rc * curlun->blksize; @@ -1058,10 +1059,10 @@ static int do_verify(struct fsg_common *common) } /* Perform the read */ rc = ums[common->lun].read_sector(&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, + lldiv(file_offset, curlun->blksize), + lldiv(amount, curlun->blksize), (char __user *)bh->buf); if (!rc) return -EIO; nread = rc * curlun->blksize; -- 2.44.0 -- // Caleb (they/them)
Re: [PATCH v5 16/16] usb: gadget: UMS: fix 64-bit division on ARM32
Hi Caleb, Thank you for the patch. On jeu., mars 28, 2024 at 17:59, Caleb Connolly wrote: > The patch introducing support for dynamic sector sizes changed the types > used in some divisions, resulting in the compiler attempting to use > libgcc helpers (__aeabi_ldivmod). Replace these divisions with calls to > lldiv() to handle this correctly. > > Fixes: 74e56e0c5065 ("usb: gadget: UMS: support multiple sector sizes") > Signed-off-by: Caleb Connolly I believe I applied this already via [1] I plan to send your work to Tom this week. Sorry for the delay! [1] https://lore.kernel.org/r/87a5mqei67@baylibre.com > --- > Cc: Mattijs Korpershoek > --- > drivers/usb/gadget/f_mass_storage.c | 13 +++-- > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/gadget/f_mass_storage.c > b/drivers/usb/gadget/f_mass_storage.c > index d880928044f4..ef90c7ec7fb5 100644 > --- a/drivers/usb/gadget/f_mass_storage.c > +++ b/drivers/usb/gadget/f_mass_storage.c > @@ -239,8 +239,9 @@ > /* #define VERBOSE_DEBUG */ > /* #define DUMP_MSGS */ > > #include > +#include > #include > #include > #include > #include > @@ -768,10 +769,10 @@ static int do_read(struct fsg_common *common) > } > > /* Perform the read */ > rc = ums[common->lun].read_sector(&ums[common->lun], > - file_offset / curlun->blksize, > - amount / curlun->blksize, > + lldiv(file_offset, curlun->blksize), > + lldiv(amount, curlun->blksize), > (char __user *)bh->buf); > if (!rc) > return -EIO; > > @@ -942,10 +943,10 @@ static int do_write(struct fsg_common *common) > amount = bh->outreq->actual; > > /* Perform the write */ > rc = ums[common->lun].write_sector(&ums[common->lun], > -file_offset / curlun->blksize, > -amount / curlun->blksize, > +lldiv(file_offset, > curlun->blksize), > +lldiv(amount, curlun->blksize), > (char __user *)bh->buf); > if (!rc) > return -EIO; > nwritten = rc * curlun->blksize; > @@ -1058,10 +1059,10 @@ static int do_verify(struct fsg_common *common) > } > > /* Perform the read */ > rc = ums[common->lun].read_sector(&ums[common->lun], > - file_offset / curlun->blksize, > - amount / curlun->blksize, > + lldiv(file_offset, curlun->blksize), > + lldiv(amount, curlun->blksize), > (char __user *)bh->buf); > if (!rc) > return -EIO; > nread = rc * curlun->blksize; > > -- > 2.44.0
[PATCH v5 16/16] usb: gadget: UMS: fix 64-bit division on ARM32
The patch introducing support for dynamic sector sizes changed the types used in some divisions, resulting in the compiler attempting to use libgcc helpers (__aeabi_ldivmod). Replace these divisions with calls to lldiv() to handle this correctly. Fixes: 74e56e0c5065 ("usb: gadget: UMS: support multiple sector sizes") Signed-off-by: Caleb Connolly --- Cc: Mattijs Korpershoek --- drivers/usb/gadget/f_mass_storage.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index d880928044f4..ef90c7ec7fb5 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -239,8 +239,9 @@ /* #define VERBOSE_DEBUG */ /* #define DUMP_MSGS */ #include +#include #include #include #include #include @@ -768,10 +769,10 @@ static int do_read(struct fsg_common *common) } /* Perform the read */ rc = ums[common->lun].read_sector(&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, + lldiv(file_offset, curlun->blksize), + lldiv(amount, curlun->blksize), (char __user *)bh->buf); if (!rc) return -EIO; @@ -942,10 +943,10 @@ static int do_write(struct fsg_common *common) amount = bh->outreq->actual; /* Perform the write */ rc = ums[common->lun].write_sector(&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, + lldiv(file_offset, curlun->blksize), + lldiv(amount, curlun->blksize), (char __user *)bh->buf); if (!rc) return -EIO; nwritten = rc * curlun->blksize; @@ -1058,10 +1059,10 @@ static int do_verify(struct fsg_common *common) } /* Perform the read */ rc = ums[common->lun].read_sector(&ums[common->lun], - file_offset / curlun->blksize, - amount / curlun->blksize, + lldiv(file_offset, curlun->blksize), + lldiv(amount, curlun->blksize), (char __user *)bh->buf); if (!rc) return -EIO; nread = rc * curlun->blksize; -- 2.44.0