From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78204C433F5 for ; Thu, 12 May 2022 18:23:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 02FF7803EE; Thu, 12 May 2022 20:23:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="cbRp62W6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1AF2280583; Thu, 12 May 2022 20:23:30 +0200 (CEST) Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 00AC6803DC for ; Thu, 12 May 2022 20:23:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x830.google.com with SMTP id k2so5140708qtp.1 for ; Thu, 12 May 2022 11:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pcTAo5yeH6kQG8+cCziiDYGGABWsyL9t1MXoK24iY1A=; b=cbRp62W6rvD8saNumQLhSBbG7VtA/xXp0ZoYn+SbVBhUtuAM8VTxLit8A3T/zNd9Qe rT3apEykjBvuxpcREPkPJtd7z9m0gQ4IMX6S0bSdSr0dOINvoP3QIYouNfuWwBn4cG62 2fLMjfjiyb07CrzaAHiID+FPymUTnrekXmCs4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pcTAo5yeH6kQG8+cCziiDYGGABWsyL9t1MXoK24iY1A=; b=Jv/36kc3nyK0UwjMc85Bg6BGz3qv9glMLvK0Bcl8X5JoH0erI29tF8y88hADynj5/4 5Hq2LJOjv4gsw9T4Btut40P88KcDEIT6nZCnyAinkafmL+zxOj/E8ZEv0lxbLjvteShV 7ry3I3fa9usmtSUZAmTCVTYe/mjw4xU4tGtbnMLj575eV5zPOygVVeEfOl2UWpIFerIf kPjL6CyhhXbh84ah0q8d51421l9huXS17/+oPkqAqPY6BskcNCHAOqFcWgr+hlFozu0+ U1AL2hp3HWv4eJjOCTrZnhRH/KMK8n69BxT/c1oD4VMT2KJKztsKgsy7x3ZxEFmU57xg rojg== X-Gm-Message-State: AOAM532GXE6tEcZ9ZFHkT28c5g91jmgZk+dJNDvqJlAeUWNRthq0eYor 3GFEFx2AfzzcEonxhnGVf0icHA== X-Google-Smtp-Source: ABdhPJwD6g3T/lj51G1Uwh8+ypkOXxwFUYT9S+X7zcirFAoLAYbF5HCZJxgsyPoh6E+Yzqc2loatoQ== X-Received: by 2002:ac8:598f:0:b0:2f3:be36:9be5 with SMTP id e15-20020ac8598f000000b002f3be369be5mr1160405qte.204.1652379805735; Thu, 12 May 2022 11:23:25 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-4500-88f1-df08-fb5b-7a50.res6.spectrum.com. [2603:6081:7b01:4500:88f1:df08:fb5b:7a50]) by smtp.gmail.com with ESMTPSA id n206-20020a37a4d7000000b006a09faf5c1asm126790qke.30.2022.05.12.11.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 11:23:24 -0700 (PDT) Date: Thu, 12 May 2022 14:23:22 -0400 From: Tom Rini To: Sean Nyekjaer Cc: Pali =?iso-8859-1?Q?Roh=E1r?= , Miquel Raynal , Joao Marcos Costa , Thomas Petazzoni , u-boot@lists.denx.de, Sean Nyekjaer Subject: Re: [PATCH] fs/squashfs: use do_div function for math Message-ID: <20220512182322.GE3901321@bill-the-cat> References: <20220505092637.1856223-1-sean@geanix.com> <20220505131500.GF3580959@bill-the-cat> <20220509150815.43d7543c@xps13> <20220512101901.egbghfpf76f23tfs@pali> <20220512102401.3zcyvcek6nytxc7d@pali> <20220512180233.vzvfnx5jlco57ck3@Seans-MBP.hadsten> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="lFRK9w0o3gensELN" Content-Disposition: inline In-Reply-To: <20220512180233.vzvfnx5jlco57ck3@Seans-MBP.hadsten> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean --lFRK9w0o3gensELN Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 12, 2022 at 08:02:33PM +0200, Sean Nyekjaer wrote: > On Thu, May 12, 2022 at 12:24:01PM +0200, Pali Roh=E1r wrote: > > On Thursday 12 May 2022 12:19:01 Pali Roh=E1r wrote: > > > On Monday 09 May 2022 15:08:15 Miquel Raynal wrote: > > > > Hello, > > > >=20 > > > > trini@konsulko.com wrote on Thu, 5 May 2022 09:15:00 -0400: > > > >=20 > > > > > On Thu, May 05, 2022 at 11:26:37AM +0200, Sean Nyekjaer wrote: > > > > >=20 > > > > > > From: Sean Nyekjaer > > > > > >=20 > > > > > > When compling for x86: > > > > > > ld.bfd: fs/squashfs/sqfs.o: in function `sqfs_read': > > > > > > u-boot/fs/squashfs/sqfs.c:1443: undefined reference to `__udivm= oddi4' > > > > > > ld.bfd: u-boot/fs/squashfs/sqfs.c:1521: undefined reference to = `__udivmoddi4' > > > > > >=20 > > > > > > Signed-off-by: Sean Nyekjaer > > > > > > --- > > > > > > fs/squashfs/sqfs.c | 5 +++-- > > > > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > >=20 > > > > > > diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c > > > > > > index 5d9c52af80..6405db4ff3 100644 > > > > > > --- a/fs/squashfs/sqfs.c > > > > > > +++ b/fs/squashfs/sqfs.c > > > > > > @@ -8,6 +8,7 @@ > > > > > > */ > > > > > > =20 > > > > > > #include > > > > > > +#include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > @@ -1440,7 +1441,7 @@ int sqfs_read(const char *filename, void = *buf, loff_t offset, loff_t len, > > > > > > } > > > > > > =20 > > > > > > for (j =3D 0; j < datablk_count; j++) { > > > > > > - start =3D data_offset / ctxt.cur_dev->blksz; > > > > > > + start =3D do_div(data_offset, ctxt.cur_dev->blksz); > > > > > > table_size =3D SQFS_BLOCK_SIZE(finfo.blk_sizes[j]); > > > > > > table_offset =3D data_offset - (start * ctxt.cur_dev->blksz); > > > > > > n_blks =3D DIV_ROUND_UP(table_size + table_offset, > > > > > > @@ -1516,7 +1517,7 @@ int sqfs_read(const char *filename, void = *buf, loff_t offset, loff_t len, > > > > > > goto out; > > > > > > } > > > > > > =20 > > > > > > - start =3D frag_entry.start / ctxt.cur_dev->blksz; > > > > > > + start =3D do_div(frag_entry.start, ctxt.cur_dev->blksz); > > > > > > table_size =3D SQFS_BLOCK_SIZE(frag_entry.size); > > > > > > table_offset =3D frag_entry.start - (start * ctxt.cur_dev->bl= ksz); > > > > > > n_blks =3D DIV_ROUND_UP(table_size + table_offset, ctxt.cur_d= ev->blksz); =20 > > > > >=20 > > > > > Adding maintainers... > > > >=20 > > > > I guess that's a correct fix, so > > > >=20 > > > > Reviewed-by: Miquel Raynal > > > >=20 > > > > Thanks, > > > > Miqu=E8l > > >=20 > > > Hello! do_div() macro modifies its first argument. It is correct? > > > Because previous code did not modify anything. > >=20 > > * The semantics of do_div() are: > > * > > * u32 do_div(u64 *n, u32 base) > > * { > > * u32 remainder =3D *n % base; > > * *n =3D *n / base; > > * return remainder; > > * } > >=20 > > And this patch replaced: > >=20 > > start =3D data_offset / ctxt.cur_dev->blksz; > >=20 > > by: > >=20 > > start =3D do_div(data_offset, ctxt.cur_dev->blksz); > >=20 > > which expands to: > >=20 > > start =3D data_offset % ctxt.cur_dev->blksz; > > data_offset =3D data_offset / ctxt.cur_dev->blksz; > >=20 > > Which is wrong as it calculates something totally different. > >=20 > > So this patch is incorrect. >=20 > Hi Pali, >=20 > Yes I agree, I got tricked by some wrong cache from Yocto :/ > I have tried lldiv(), and that works on our x86 target. >=20 > Do you have an opinion on that? > Or do you have another idea to avoid the > "undefined reference to `__udivmoddi4'" error? Please correct things to use lldiv(), thanks. --=20 Tom --lFRK9w0o3gensELN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmJ9UJcACgkQFHw5/5Y0 tyxqNwwAhiX4ZcnoyWwI+eYw1m7GHK7Sb0IsbPcONum35sc+nGJYD5YhGygP1bcX 5uBc8QSeDL2jO+d2oTz1Qm/wWp3C/OHlmqxpRUgl9wYGnl2kvS3CNPVlIxf4RFcP feDY+sjtqmG9iiEj+HBMrsrBFJbAYC9RCmXUXka0joKNmqJY8eD+mOIGUu7nDBZ0 waUUKkHzsTq8577p89goAU9OUmN/JRmckN16ImFYKIEV/mG4SzrkZ4RILt9B1NVa 4WY03bhSHTD+Ckz9sJcgomj7jAdNn7pfFxHlMM6drPADh+I/4qASmCgelOs/efe6 jJ7KXbz/lqmH9Ka/EBC4lJAhS31mnnB27hMrcrffkynk8pJjbuDWUpGi6DhSQHLv oihPLDXMZEwuQDx8jmwIXoUpzlbRC1uvztz6am8Uk32VDQDe+BKF40VPl81zVTKa x1VJztSIOO5xVgUlQDfcLC8u9pU9sz9uy0604JQOgL6L0R7HW7sfgNg1/3sNtDPn hlylytiN =GD5I -----END PGP SIGNATURE----- --lFRK9w0o3gensELN--