On 05/08/13 15:05, Archit Taneja wrote: > On Monday 05 August 2013 02:41 PM, Tomi Valkeinen wrote: >> There's quite a bit of code in these dump functions, and they are always >> called. I'm sure getting that data is good for debugging, but I presume >> they are quite useless for normal use. So I think they should be >> compiled in only if some Kconfig option is selected. > > Won't pr_debug() functions actually print something only when > CONFIG_DYNAMIC_DEBUG is selected or if the DEBUG is defined? They will If DEBUG is defined, they are always printed. If dynamic debug is in use, the user has to enable debug prints for VPE for the dumps to be printed. > still consume a lot of code, but it would just end up in dummy printk > calls, right? Yes. Well, I don't know VPE, so I can't really say how much those prints are needed or not. They just looked very verbose to me. I think we should have "normal" level debugging messages compiled in by default, and for "verbose" there should be a separate compile options. With verbose I mean something that may be useful if you are changing the code and want to verify it or debugging some very odd bug. I.e. for the developer of the driver. And with normal something that would be used when, say, somebody uses VPE for in his app, but things don't seem to be quite right, and there's need to get some info on what is going on. I.e. for "normal" user. But that's just my opinion, and it's obviously difficult to define those clearly =). To be honest, I don't know how much overhead very verbose kernel debug prints even cause. Maybe it's negligible. >>> +/* >>> + * data transfer descriptor >>> + * >>> + * All fields are 32 bits to make them endian neutral >> >> What does that mean? Why would 32bit fields make it endian neutral? > > > Each 32 bit field describes one word of the data descriptor. Each > descriptor has a number of parameters. > > If we look at the word 'xfer_length_height'. It's composed of height > (from bits 15:0) and width(from bits 31:16). If the word was expressed > using bit fields, we can describe the word(in big endian) as: > > struct vpdma_dtd { > ... > unsigned int xfer_width:16; > unsigned int xfer_height:16; > ... > ... > }; > > and in little endian as: > > struct vpdma_dtd { > ... > unsigned int xfer_height:16; > unsigned int xfer_width:16; > ... > ... > }; > > So this representation makes it endian dependent. Maybe the comment > should be improved saying that usage of u32 words instead of bit fields > prevents endian issues. No, I don't think that's correct. Endianness is about bytes, not 16 bit words. The above text doesn't make much sense to me. I haven't really worked with endiannes issues, but maybe __le32 and others should be used in the struct, if that struct is read by the HW. And use cpu_to_le32() & others to write those. But googling will probably give more info (I should read also =). >>> + */ >>> +struct vpdma_dtd { >>> + u32 type_ctl_stride; >>> + union { >>> + u32 xfer_length_height; >>> + u32 w1; >>> + }; >>> + dma_addr_t start_addr; >>> + u32 pkt_ctl; >>> + union { >>> + u32 frame_width_height; /* inbound */ >>> + dma_addr_t desc_write_addr; /* outbound */ >> >> Are you sure dma_addr_t is always 32 bit? > > I am not sure about this. Is this struct directly read by the HW, or written to HW? If so, I believe using dma_addr_t is very wrong here. Having a typedef like dma_addr_t hides the actual type used for it. So even if it currently would always be 32bit, there's no guarantee. >> >>> + }; >>> + union { >>> + u32 start_h_v; /* inbound */ >>> + u32 max_width_height; /* outbound */ >>> + }; >>> + u32 client_attr0; >>> + u32 client_attr1; >>> +}; >> >> I'm not sure if I understand the struct right, but presuming this one >> struct is used for both writing and reading, and certain set of fields >> is used for writes and other set for reads, would it make sense to have >> two different structs, instead of using unions? Although they do have >> many common fields, and the unions are a bit scattered there, so I don't >> know if that would be cleaner... > > It helps in a having a common debug function, I don't see much benefit > apart from that. I'll see if it's better to have them as separate structs. Ok. Does the struct have any bit or such that tells us if the current data is inbound or outbound? Tomi
Attachment:
signature.asc
Description: OpenPGP digital signature