From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759857AbdAENwL (ORCPT ); Thu, 5 Jan 2017 08:52:11 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:52563 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751328AbdAENwJ (ORCPT ); Thu, 5 Jan 2017 08:52:09 -0500 Subject: Re: [PATCH 01/12] mfd: Eberspaecher Flexcard PMC II Carrier Board support To: Arnd Bergmann References: <1481674313-30378-1-git-send-email-dengler@linutronix.de> <1481674313-30378-2-git-send-email-dengler@linutronix.de> <15584607.P8pE8oSqpO@wuerfel> Cc: Lee Jones , Greg Kroah-Hartman , Vinod Koul , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, Thomas Gleixner , Sebastian Siewior , Juergen Bubeck , Peter Mahler , Benedikt Spranger From: Holger Dengler Organization: linutronix GmbH Message-ID: <9a37f05f-3e6f-5419-410f-f49c7e27d12b@linutronix.de> Date: Thu, 5 Jan 2017 14:52:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.5.1 MIME-Version: 1.0 In-Reply-To: <15584607.P8pE8oSqpO@wuerfel> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="USGHckAxK4a3AI6PvTatA93oMGm2Lta2g" X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --USGHckAxK4a3AI6PvTatA93oMGm2Lta2g Content-Type: multipart/mixed; boundary="THhtUtc37HBBK4MtVEdf4E9XuH9Oft7vo"; protected-headers="v1" From: Holger Dengler To: Arnd Bergmann Cc: Lee Jones , Greg Kroah-Hartman , Vinod Koul , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, Thomas Gleixner , Sebastian Siewior , Juergen Bubeck , Peter Mahler , Benedikt Spranger Message-ID: <9a37f05f-3e6f-5419-410f-f49c7e27d12b@linutronix.de> Subject: Re: [PATCH 01/12] mfd: Eberspaecher Flexcard PMC II Carrier Board support References: <1481674313-30378-1-git-send-email-dengler@linutronix.de> <1481674313-30378-2-git-send-email-dengler@linutronix.de> <15584607.P8pE8oSqpO@wuerfel> In-Reply-To: <15584607.P8pE8oSqpO@wuerfel> --THhtUtc37HBBK4MtVEdf4E9XuH9Oft7vo Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 12/14/2016 09:38 AM, Arnd Bergmann wrote: > On Wednesday, December 14, 2016 1:11:42 AM CET Holger Dengler wrote: >> >> diff --git a/include/uapi/linux/flexcard.h b/include/uapi/linux/flexca= rd.h >> new file mode 100644 >> index 0000000..4e9f07b4 >> --- /dev/null >> +++ b/include/uapi/linux/flexcard.h >> @@ -0,0 +1,64 @@ >=20 > Why is this exported to user space? The registers of bar0 can be accessed from userspace via mmap and the str= uctures in this header file describe the register layout in bar0. >> + >> +#include >> + >> +struct fc_version { >> + __u8 dev; >> + __u8 min; >> + __u8 maj; >> + __u8 reserved; >> +} __packed; >=20 > The __packed attribute is redundant here as all members > are just one byte anyway. Both structures (struct fc_version and struct fc_bar0_conf) describe the = layout of the registers in bar0. Therefore it must be guaranteed (on all = architectures) that the compiler don't insert any spare-parts in the stru= ctures. My current understanding is, that the __packed attribute has to b= e used exactly for such a case. But I will check this again and if it is = not required, I'll remove it. >=20 >> +/* PCI BAR 0: Flexcard configuration */ >> +struct fc_bar0_conf { >> + __u32 r1; /* 000 */ >> + struct fc_version fc_fw_ver; /* 004 */ >> + struct fc_version fc_hw_ver; /* 008 */ >> + __u32 r2[3]; /* 00c */ >> + __u64 fc_sn; /* 018 */ >> + __u32 fc_uid; /* 020 */ >> + __u32 r3[7]; /* 024 */ >> + __u32 fc_lic[6]; /* 040 */ >> + __u32 fc_slic[6]; /* 058 */ >> + __u32 trig_ctrl1; /* 070 */ >> + __u32 r4; /* 074 */ >> + __u32 trig_ctrl2; /* 078 */ >> + __u32 r5[22]; /* 07c */ >> + __u32 amreg; /* 0d4 */ >> + __u32 tiny_stat; /* 0d8 */ >> + __u32 r6[5]; /* 0dc */ >> + __u32 can_dat_cnt; /* 0f0 */ >> + __u32 can_err_cnt; /* 0f4 */ >> + __u32 fc_data_cnt; /* 0f8 */ >> + __u32 r7; /* 0fc */ >> + __u32 fc_rocr; /* 100 */ >> + __u32 r8; /* 104 */ >> + __u32 pg_ctrl; /* 108 */ >> + __u32 pg_term; /* 10c */ >> + __u32 r9; /* 110 */ >> + __u32 irs; /* 114 */ >> + __u32 fr_tx_cnt; /* 118 */ >> + __u32 irc; /* 11c */ >> + __u64 pcnt; /* 120 */ >> + __u32 r10; /* 128 */ >> + __u32 nmv_cnt; /* 12c */ >> + __u32 info_cnt; /* 130 */ >> + __u32 stat_trg_cnt; /* 134 */ >> + __u32 r11; /* 138 */ >> + __u32 fr_rx_cnt; /* 13c */ >> +} __packed; >=20 > Here the __packed attribute is probably harmful, it prevents you > from accessing the members using 32-bit sized accesses and forces > bytewise accesses on some architectures, which tends to do the > wrong thing on MMIO. Is this also true, if the base address for this struct is always 32bit-al= ligned (because it is the base address of bar0)? >=20 > Arnd >=20 --=20 Gru=DF, Holger Dengler -- phone: +49 7556 25 999 14; fax: +49 7556 25 999 99 --THhtUtc37HBBK4MtVEdf4E9XuH9Oft7vo-- --USGHckAxK4a3AI6PvTatA93oMGm2Lta2g Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEd8XkGiROGgl9zmI3ZBVNtyqIjvkFAlhuT4QACgkQZBVNtyqI jvm3hg//fquCmIobY9RJKkLy5i61pjBUWTilo5mfCVJ52LegF66sPhXIuvokeOIH 5M4C1R+XPh6WKf8YxxqDtcL57PEZ/tVr143x4jOvfzrh6mfuIXCjF8BJQKEDe5v9 pGL2h+X3+ZF4lqDQlaLynyeIqMEn1I7UBzWhcGmj+fKjXV28UCbUdM4fJB2AmHSw hJqAKGKiKApGevvW1w++Io+SCte3P5SGp/OfCV9wQ7q9Nkq/gthbaFO+b4PpsE2w 0MnkFnpfwllfo7P4Vmd0U6fmThYD5mbTMQtl8fyd+k9Qfb3ca0xsZiuWDtygw120 rL58mHc3gdU2DQnPo/1eh9d30lwxHtgBPKh8TT1GWOWHJxH49AwVtNQ+X1QYFNMv Rvhu1rrLHwdUbvgAD6npRLvl4qcoBa/CBsqFlv5ReGnsZzqdul1Agz8AC0PTF3eZ DyvpGg3UbhRxOng6z9xsDWXxI5lcFQ0Kop2WN0Ysq/JIJhM5kyBu4dazRVCQGR6K 3e/BFDFlJkwwJlD2x/pHIVadT2BclqDkvsi4EnYnmqwR3mCZeNBbpyPHDZX4t4q+ v9/dmgE7QIKAsdzgGPwJq05689LpdWjV95LXZvSboUB06ULNOrOYeoo/X9+mj+tp u9m+hEhIeuZloxKU8kvCn0pXWjSO1kmxiB7PynsipD85nKnKGt4= =FSnt -----END PGP SIGNATURE----- --USGHckAxK4a3AI6PvTatA93oMGm2Lta2g--