linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Holger Dengler <dengler@linutronix.de>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Lee Jones <lee.jones@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Vinod Koul <vinod.koul@intel.com>,
	linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Siewior <bigeasy@linutronix.de>,
	Juergen Bubeck <bubeck@xkrug.com>,
	Peter Mahler <mahler@xkrug.com>,
	Benedikt Spranger <b.spranger@linutronix.de>
Subject: Re: [PATCH 01/12] mfd: Eberspaecher Flexcard PMC II Carrier Board support
Date: Thu, 5 Jan 2017 14:52:03 +0100	[thread overview]
Message-ID: <9a37f05f-3e6f-5419-410f-f49c7e27d12b@linutronix.de> (raw)
In-Reply-To: <15584607.P8pE8oSqpO@wuerfel>


[-- Attachment #1.1: Type: text/plain, Size: 2868 bytes --]

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/flexcard.h
>> new file mode 100644
>> index 0000000..4e9f07b4
>> --- /dev/null
>> +++ b/include/uapi/linux/flexcard.h
>> @@ -0,0 +1,64 @@
> 
> Why is this exported to user space?

The registers of bar0 can be accessed from userspace via mmap and the structures in this header file describe the register layout in bar0.

>> +
>> +#include <linux/types.h>
>> +
>> +struct fc_version {
>> +	__u8	dev;
>> +	__u8	min;
>> +	__u8	maj;
>> +	__u8	reserved;
>> +} __packed;
> 
> 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 structures. My current understanding is, that the __packed attribute has to be used exactly for such a case. But I will check this again and if it is not required, I'll remove it.

> 
>> +/* 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;
> 
> 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-alligned (because it is the base address of bar0)?

> 
> 	Arnd
> 

-- 
Gruß,
Holger Dengler
--
phone: +49 7556 25 999 14; fax: +49 7556 25 999 99


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-01-05 13:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14  0:11 [PATCH 00/12] Eberspaecher Flexcard PMC II base support Holger Dengler
2016-12-14  0:11 ` [PATCH 01/12] mfd: Eberspaecher Flexcard PMC II Carrier Board support Holger Dengler
2016-12-14  8:38   ` Arnd Bergmann
2017-01-05 13:52     ` Holger Dengler [this message]
2016-12-14  0:11 ` [PATCH 02/12] mfd: flexcard: add flexcard misc mfd-cell Holger Dengler
2016-12-14  0:11 ` [PATCH 03/12] mfd: flexcard: add posix clock mfd-cell Holger Dengler
2016-12-14  0:11 ` [PATCH 04/12] mfd: flexcard: add interrupt support Holger Dengler
2016-12-14  2:47   ` kbuild test robot
2016-12-14  3:37   ` kbuild test robot
2016-12-14  0:11 ` [PATCH 05/12] mfd: flexcard: add DMA interrupts Holger Dengler
2016-12-14  3:08   ` kbuild test robot
2016-12-14  0:11 ` [PATCH 06/12] mfd: flexcard: add DMA device Holger Dengler
2016-12-14  0:11 ` [PATCH 07/12] mfd: flexcard: add UIO IRQ devices Holger Dengler
2016-12-14  0:11 ` [PATCH 08/12] misc: Flexcard misc device support Holger Dengler
2016-12-14  8:42   ` Arnd Bergmann
2016-12-14  9:28     ` Holger Dengler
2017-01-10 16:59       ` Greg Kroah-Hartman
2016-12-14  0:11 ` [PATCH 09/12] misc: flexcard: add device attributes Holger Dengler
2016-12-14  1:33   ` kbuild test robot
2017-01-10 16:58   ` Greg Kroah-Hartman
2016-12-14  0:11 ` [PATCH 10/12] misc: Flexcard basic timestamp counter support Holger Dengler
2016-12-14  3:28   ` kbuild test robot
2016-12-14  8:46   ` Arnd Bergmann
2016-12-14  9:16     ` Thomas Gleixner
2016-12-14  0:11 ` [PATCH 11/12] misc: flexcard: Support timestamp trigger selection Holger Dengler
2016-12-14  0:11 ` [PATCH 12/12] dma: Flexcard DMA ringbuffer demux driver Holger Dengler
2016-12-14  1:54   ` kbuild test robot
2016-12-15  4:38   ` Vinod Koul
2016-12-19 10:54     ` Holger Dengler
2017-01-04  9:43 ` [PATCH 00/12] Eberspaecher Flexcard PMC II base support Lee Jones

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=9a37f05f-3e6f-5419-410f-f49c7e27d12b@linutronix.de \
    --to=dengler@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=b.spranger@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=bubeck@xkrug.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mahler@xkrug.com \
    --cc=tglx@linutronix.de \
    --cc=vinod.koul@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).