tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Implement mode_select for atapi tape drives - round 4



On Mon, Aug 10, 2009 at 05:48:07AM +1000, matthew green wrote:
> 
>    On Mon, Aug 10, 2009 at 05:29:34AM +1000, matthew green wrote:
>    > 
>    >    > +   u_int select_len;
>    >    > +   struct select {
>    >    > +           struct scsi_mode_parameter_header_6 header;
>    >    > +           struct scsi_general_block_descriptor blk_desc;
>    >    > +           u_char sense_data[MAX_PAGE_0_SIZE];
>    >    > +   } select;
>    >    > +   struct scsipi_periph *periph = st->sc_periph;
>    >    > +
>    >    > +   select_len = sizeof(select.header) + sizeof(select.blk_desc) +
>    >    > +                st->page_0_size;
>    >    > 
>    >    > should select be __packed?
>    >    
>    >    Yes, it should probably be. I know most hardware structures are not
>    >    declared __packed in the scsipi code, we've been luky this didn't 
> cause
>    >    issues for now ...
>    > 
>    > 
>    > are these structures used heavily?  __packed will significantly
>    > slow down accesses to and from them.
>    
>    These structure is what the hardware expects or send. If the compiler
>    changes member order add paddings in order to speed up accesses, it
>    won't work. 
>    Or maybe you're talking about something else ?
> 
> 
> i mean that on alignment constrained hardware the compiler may
> emit 4 byte accesses and or them together to read in an int that
> is always going to be properly aligned.

What do you suggest to prevent the compiler from reordering or padding
the structure ? Would adding a __align to the structure (where
possible) in addition to __packed help ?

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index