@@ -317,15 +317,17 @@ static int gelic_card_init_chain(struct gelic_card *card,
317317
318318	/* set up the hardware pointers in each descriptor */ 
319319	for  (i  =  0 ; i  <  no ; i ++ , descr ++ ) {
320+ 		dma_addr_t  cpu_addr ;
321+ 
320322		gelic_descr_set_status (descr , GELIC_DESCR_DMA_NOT_IN_USE );
321- 		descr -> bus_addr  = 
322- 			dma_map_single (ctodev (card ), descr ,
323- 				       GELIC_DESCR_SIZE ,
324- 				       DMA_BIDIRECTIONAL );
325323
326- 		if  (!descr -> bus_addr )
324+ 		cpu_addr  =  dma_map_single (ctodev (card ), descr ,
325+ 					  GELIC_DESCR_SIZE , DMA_BIDIRECTIONAL );
326+ 
327+ 		if  (dma_mapping_error (ctodev (card ), cpu_addr ))
327328			goto iommu_error ;
328329
330+ 		descr -> bus_addr  =  cpu_to_be32 (cpu_addr );
329331		descr -> next  =  descr  +  1 ;
330332		descr -> prev  =  descr  -  1 ;
331333	}
@@ -365,26 +367,28 @@ static int gelic_card_init_chain(struct gelic_card *card,
365367 * 
366368 * allocates a new rx skb, iommu-maps it and attaches it to the descriptor. 
367369 * Activate the descriptor state-wise 
370+  * 
371+  * Gelic RX sk_buffs must be aligned to GELIC_NET_RXBUF_ALIGN and the length 
372+  * must be a multiple of GELIC_NET_RXBUF_ALIGN. 
368373 */ 
369374static  int  gelic_descr_prepare_rx (struct  gelic_card  * card ,
370375				  struct  gelic_descr  * descr )
371376{
377+ 	static  const  unsigned int   rx_skb_size  = 
378+ 		ALIGN (GELIC_NET_MAX_FRAME , GELIC_NET_RXBUF_ALIGN ) + 
379+ 		GELIC_NET_RXBUF_ALIGN  -  1 ;
380+ 	dma_addr_t  cpu_addr ;
372381	int  offset ;
373- 	unsigned int   bufsize ;
374382
375383	if  (gelic_descr_get_status (descr ) !=   GELIC_DESCR_DMA_NOT_IN_USE )
376384		dev_info (ctodev (card ), "%s: ERROR status\n" , __func__ );
377- 	/* we need to round up the buffer size to a multiple of 128 */ 
378- 	bufsize  =  ALIGN (GELIC_NET_MAX_MTU , GELIC_NET_RXBUF_ALIGN );
379385
380- 	/* and we need to have it 128 byte aligned, therefore we allocate a 
381- 	 * bit more */ 
382- 	descr -> skb  =  dev_alloc_skb (bufsize  +  GELIC_NET_RXBUF_ALIGN  -  1 );
386+ 	descr -> skb  =  netdev_alloc_skb (* card -> netdev , rx_skb_size );
383387	if  (!descr -> skb ) {
384388		descr -> buf_addr  =  0 ; /* tell DMAC don't touch memory */ 
385389		return  - ENOMEM ;
386390	}
387- 	descr -> buf_size  =  cpu_to_be32 (bufsize );
391+ 	descr -> buf_size  =  cpu_to_be32 (rx_skb_size );
388392	descr -> dmac_cmd_status  =  0 ;
389393	descr -> result_size  =  0 ;
390394	descr -> valid_size  =  0 ;
@@ -395,11 +399,10 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
395399	if  (offset )
396400		skb_reserve (descr -> skb , GELIC_NET_RXBUF_ALIGN  -  offset );
397401	/* io-mmu-map the skb */ 
398- 	descr -> buf_addr  =  cpu_to_be32 (dma_map_single (ctodev (card ),
399- 						     descr -> skb -> data ,
400- 						     GELIC_NET_MAX_MTU ,
401- 						     DMA_FROM_DEVICE ));
402- 	if  (!descr -> buf_addr ) {
402+ 	cpu_addr  =  dma_map_single (ctodev (card ), descr -> skb -> data ,
403+ 				  GELIC_NET_MAX_FRAME , DMA_FROM_DEVICE );
404+ 	descr -> buf_addr  =  cpu_to_be32 (cpu_addr );
405+ 	if  (dma_mapping_error (ctodev (card ), cpu_addr )) {
403406		dev_kfree_skb_any (descr -> skb );
404407		descr -> skb  =  NULL ;
405408		dev_info (ctodev (card ),
@@ -779,7 +782,7 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
779782
780783	buf  =  dma_map_single (ctodev (card ), skb -> data , skb -> len , DMA_TO_DEVICE );
781784
782- 	if  (! buf ) {
785+ 	if  (dma_mapping_error ( ctodev ( card ),  buf ) ) {
783786		dev_err (ctodev (card ),
784787			"dma map 2 failed (%p, %i). Dropping packet\n" ,
785788			skb -> data , skb -> len );
@@ -915,7 +918,7 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
915918	data_error  =  be32_to_cpu (descr -> data_error );
916919	/* unmap skb buffer */ 
917920	dma_unmap_single (ctodev (card ), be32_to_cpu (descr -> buf_addr ),
918- 			 GELIC_NET_MAX_MTU ,
921+ 			 GELIC_NET_MAX_FRAME ,
919922			 DMA_FROM_DEVICE );
920923
921924	skb_put (skb , be32_to_cpu (descr -> valid_size )?
0 commit comments