netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Veena Parat <Veena.Parat@neterion.com>
Cc: netdev@vger.kernel.org, Leonid.Grossman@neterion.com,
	ramkrishna.vepa@neterion.com, santosh.rastapur@neterion.com,
	Sivakumar.Subramani@neterion.com, sreenivasa.honnur@neterion.com,
	alicia.pena@neterion.com, sriram.rapuru@neterion.com
Subject: Re: [PATCH 2.6.22 1/4]S2IO: Adding checks to check the return value of pci mapping function
Date: Mon, 02 Jul 2007 08:20:50 -0400	[thread overview]
Message-ID: <4688EDA2.8000405@garzik.org> (raw)
In-Reply-To: <Pine.GSO.4.10.10706190549470.2608-100000@guinness>

Veena Parat wrote:
> Adding checks to check the return value of pci mapping function 
> 
> Signed-off-by: Veena Parat <veena.parat@neterion.com>
> ---
> diff -urpN org/drivers/net/s2io.c patch_1/drivers/net/s2io.c
> --- org/drivers/net/s2io.c	2007-05-17 20:35:39.000000000 +0530
> +++ patch_1/drivers/net/s2io.c	2007-05-17 20:35:55.000000000 +0530
> @@ -282,6 +282,7 @@ static char ethtool_driver_stats_keys[][
>  	("lro_flush_due_to_max_pkts"),
>  	("lro_avg_aggr_pkts"),
>  	("mem_alloc_fail_cnt"),
> +	{"pci_map_fail_cnt"},
>  	("watchdog_timer_cnt"),
>  	("mem_allocated"),
>  	("mem_freed"),
> @@ -2247,10 +2248,19 @@ static int fill_rxd_3buf(struct s2io_nic
>  			(nic->pdev, skb->data, l3l4hdr_size + 4,
>  			PCI_DMA_FROMDEVICE);
>  
> +	if ((((struct RxD3*)rxdp)->Buffer1_ptr == 0) ||
> +		(((struct RxD3*)rxdp)->Buffer1_ptr == DMA_ERROR_CODE)) {
> +		nic->mac_control.stats_info->sw_stat.pci_map_fail_cnt++;
> +		return -ENOMEM;
> +	}
> +
>  	/* skb_shinfo(skb)->frag_list will have L4 data payload */
>  	skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE);
>  	if (skb_shinfo(skb)->frag_list == NULL) {
>  		nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
> +		pci_unmap_single
> +			(nic->pdev, (dma_addr_t)skb->data, l3l4hdr_size + 4,
> +			PCI_DMA_FROMDEVICE);
>  		DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name);
>  		return -ENOMEM ;
>  	}
> @@ -2267,6 +2277,11 @@ static int fill_rxd_3buf(struct s2io_nic
>  	((struct RxD3*)rxdp)->Buffer2_ptr = pci_map_single(nic->pdev,
>  				frag_list->data, dev->mtu,
>  				PCI_DMA_FROMDEVICE);
> +	if ((((struct RxD3*)rxdp)->Buffer2_ptr == 0) ||
> +		(((struct RxD3*)rxdp)->Buffer2_ptr == DMA_ERROR_CODE)) {
> +		nic->mac_control.stats_info->sw_stat.pci_map_fail_cnt++;
> +		return -ENOMEM;
> +	}
>  	rxdp->Control_2 |= SET_BUFFER1_SIZE_3(l3l4hdr_size + 4);
>  	rxdp->Control_2 |= SET_BUFFER2_SIZE_3(dev->mtu);
>  
> @@ -2399,6 +2414,16 @@ static int fill_rx_buffers(struct s2io_n
>  			((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single
>  			    (nic->pdev, skb->data, size - NET_IP_ALIGN,
>  				PCI_DMA_FROMDEVICE);
> +			if ((((struct RxD1*)rxdp)->Buffer0_ptr == 0) ||
> +				(((struct RxD1*)rxdp)->Buffer0_ptr == 
> +				DMA_ERROR_CODE)) {
> +				nic->mac_control.stats_info->sw_stat.
> +					pci_map_fail_cnt++;
> +				nic->mac_control.stats_info->sw_stat.mem_freed
> +					+= skb->truesize;
> +				dev_kfree_skb_irq(skb);
> +				return -ENOMEM;
> +			}
>  			rxdp->Control_2 = 
>  				SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN);
>  

please provide a prep patch that eliminates all these inline casts. 
Create temporary variables or whatever you need to do to convert the 
messy and unreadable "(((struct RxD1*)rxdp)->Buffer0_ptr" into 
"desc->Buffer0_ptr".

otherwise looks OK


  parent reply	other threads:[~2007-07-02 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-19  9:56 [PATCH 2.6.22 1/4]S2IO: Adding checks to check the return value of pci mapping function Veena Parat
2007-06-29  6:20 ` Sivakumar Subramani
2007-06-29 14:29   ` Jeff Garzik
2007-07-02 12:20 ` Jeff Garzik [this message]
2007-07-13  4:58   ` Sivakumar Subramani
  -- strict thread matches above, loose matches on Subject: below --
2007-07-12 10:13 Veena Parat
2007-07-13 22:19 ` Francois Romieu

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=4688EDA2.8000405@garzik.org \
    --to=jeff@garzik.org \
    --cc=Leonid.Grossman@neterion.com \
    --cc=Sivakumar.Subramani@neterion.com \
    --cc=Veena.Parat@neterion.com \
    --cc=alicia.pena@neterion.com \
    --cc=netdev@vger.kernel.org \
    --cc=ramkrishna.vepa@neterion.com \
    --cc=santosh.rastapur@neterion.com \
    --cc=sreenivasa.honnur@neterion.com \
    --cc=sriram.rapuru@neterion.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).