lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 8 Jan 2021 21:53:04 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Marc Kleine-Budde' <mkl@...gutronix.de>,
        Jakub Kicinski <kuba@...nel.org>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "linux-can@...r.kernel.org" <linux-can@...r.kernel.org>,
        "kernel@...gutronix.de" <kernel@...gutronix.de>,
        Dan Murphy <dmurphy@...com>, Sean Nyekjaer <sean@...nix.com>
Subject: RE: [net-next 15/19] can: tcan4x5x: rework SPI access

From: Marc Kleine-Budde
> Sent: 07 January 2021 21:17
> 
> On 1/7/21 8:06 PM, Jakub Kicinski wrote:
> > On Thu, 7 Jan 2021 11:00:35 -0800 Jakub Kicinski wrote:
> >> On Thu,  7 Jan 2021 10:48:56 +0100 Marc Kleine-Budde wrote:
> >>> +struct __packed tcan4x5x_map_buf {
> >>> +	struct tcan4x5x_buf_cmd cmd;
> >>> +	u8 data[256 * sizeof(u32)];
> >>> +} ____cacheline_aligned;
> >>
> >> Interesting attribute combo, I must say.
> >
> > Looking at the rest of the patch I don't really see a reason for
> > __packed.  Perhaps it can be dropped?
> 
> It's the stream of bytes send via SPI to the chip. Here are both structs for
> reference:
> 
> > +struct __packed tcan4x5x_buf_cmd {
> > +	u8 cmd;
> > +	__be16 addr;
> > +	u8 len;
> > +};
> 
> This has to be packed, as I assume the compiler would add some space after the
> "u8 cmd" to align the __be16 naturally.

Why not generate a series of 32bit words to be sent over the SPI bus.
Slightly less faffing in the code.
Then have a #define (or inline function) to merge the cmd+addr+len
into a single 32bit word.

Also if the length is in 32bit units, then the data[] field
ought to be u32[].

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ