From patchwork Wed Sep 23 17:37:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 54070 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 6A9B222E14 for ; Wed, 23 Sep 2015 17:38:09 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf28406855wic.1 for ; Wed, 23 Sep 2015 10:38:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=H5a4Bs0POZ+fKQZrp9lJK/tIkUOEgIQlOWWWzy/ZW+8=; b=bB/CcC4zFZGn/3gAxYhTAUPE2+aLW8FvDkKogSPuMvHr01Mwi8dTHYxATQ04FA9W+/ J/LAddFns+dT+VduK7/VuLbC+x3h2MX+ZCK8eOsyGWvlvl7p9e5yJAXVPaJvd9uBP/B9 AvXHdxEJTNHnkH+ocWsUwYssEdFUf4R8qOAB1gwN0kbvWz/zMe5QBZXo5CGrMbvHWGpV iRtfmXuCQ8+yt9pFVJRbE7HCYq+kbBj5WicNmpyFh/+8y0brojBygrEPTopezNfUiddn FKv3wFRMY8mQsoA0uRuaLamRbGGOQDkuU5KrA0OuhCs7zzRYWNlNaTWPg20Igp+SXpf9 d/xQ== X-Gm-Message-State: ALoCoQlGOHseT2exc97li2HILGeXrbtdQKpXJum2zX3Xq7JorksZVhgv+7Cm6jGFYtKfCDam4ovI X-Received: by 10.112.89.228 with SMTP id br4mr5434152lbb.3.1443029888746; Wed, 23 Sep 2015 10:38:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.155.68 with SMTP id d65ls114655lfe.85.gmail; Wed, 23 Sep 2015 10:38:08 -0700 (PDT) X-Received: by 10.112.63.67 with SMTP id e3mr11834204lbs.92.1443029888580; Wed, 23 Sep 2015 10:38:08 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id c7si2687161lbd.63.2015.09.23.10.38.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2015 10:38:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lahg1 with SMTP id g1so59846777lah.1 for ; Wed, 23 Sep 2015 10:38:08 -0700 (PDT) X-Received: by 10.152.37.135 with SMTP id y7mr12161378laj.106.1443029888300; Wed, 23 Sep 2015 10:38:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp28487lbq; Wed, 23 Sep 2015 10:38:07 -0700 (PDT) X-Received: by 10.68.196.99 with SMTP id il3mr38455726pbc.166.1443029887189; Wed, 23 Sep 2015 10:38:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rz10si12006660pab.205.2015.09.23.10.38.06; Wed, 23 Sep 2015 10:38:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756551AbbIWRiE (ORCPT + 30 others); Wed, 23 Sep 2015 13:38:04 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:32948 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756106AbbIWRg6 (ORCPT ); Wed, 23 Sep 2015 13:36:58 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id t8NHausV022352; Wed, 23 Sep 2015 12:36:56 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t8NHauBW030117; Wed, 23 Sep 2015 12:36:56 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Wed, 23 Sep 2015 12:36:56 -0500 Received: from ula0868495.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t8NHarOV021888; Wed, 23 Sep 2015 12:36:56 -0500 From: Murali Karicheri To: , , , , , CC: Subject: [PATCH 4/7] net: netcp: add error check to netcp_allocate_rx_buf() Date: Wed, 23 Sep 2015 13:37:08 -0400 Message-ID: <1443029831-22035-5-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443029831-22035-1-git-send-email-m-karicheri2@ti.com> References: <1443029831-22035-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m-karicheri2@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently, if netcp_allocate_rx_buf() fails due no descriptors in the rx free descriptor queue, inside the netcp_rxpool_refill() function the iterative loop to fill buffers doesn't terminate right away. So modify the netcp_allocate_rx_buf() to return an error code and use it break the loop when there is error. Signed-off-by: Murali Karicheri --- drivers/net/ethernet/ti/netcp_core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c index cf693de..97e2629 100644 --- a/drivers/net/ethernet/ti/netcp_core.c +++ b/drivers/net/ethernet/ti/netcp_core.c @@ -801,7 +801,7 @@ static void netcp_rxpool_free(struct netcp_intf *netcp) netcp->rx_pool = NULL; } -static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq) +static int netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq) { struct knav_dma_desc *hwdesc; unsigned int buf_len, dma_sz; @@ -815,7 +815,7 @@ static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq) hwdesc = knav_pool_desc_get(netcp->rx_pool); if (IS_ERR_OR_NULL(hwdesc)) { dev_dbg(netcp->ndev_dev, "out of rx pool desc\n"); - return; + return -ENOMEM; } if (likely(fdq == 0)) { @@ -867,25 +867,26 @@ static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq) knav_pool_desc_map(netcp->rx_pool, hwdesc, sizeof(*hwdesc), &dma, &dma_sz); knav_queue_push(netcp->rx_fdq[fdq], dma, sizeof(*hwdesc), 0); - return; + return 0; fail: knav_pool_desc_put(netcp->rx_pool, hwdesc); + return -ENOMEM; } /* Refill Rx FDQ with descriptors & attached buffers */ static void netcp_rxpool_refill(struct netcp_intf *netcp) { u32 fdq_deficit[KNAV_DMA_FDQ_PER_CHAN] = {0}; - int i; + int i, ret = 0; /* Calculate the FDQ deficit and refill */ for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN && netcp->rx_fdq[i]; i++) { fdq_deficit[i] = netcp->rx_queue_depths[i] - knav_queue_get_count(netcp->rx_fdq[i]); - while (fdq_deficit[i]--) - netcp_allocate_rx_buf(netcp, i); + while (fdq_deficit[i]-- && !ret) + ret = netcp_allocate_rx_buf(netcp, i); } /* end for fdqs */ }