From patchwork Sun May 22 21:18:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: sjur.brandeland@stericsson.com X-Patchwork-Id: 96784 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 728EAB6FAC for ; Mon, 23 May 2011 07:19:19 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755401Ab1EVVTM (ORCPT ); Sun, 22 May 2011 17:19:12 -0400 Received: from sf1.isp.kq.no ([213.172.193.37]:32571 "EHLO pmx.vmail.no" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755363Ab1EVVTH (ORCPT ); Sun, 22 May 2011 17:19:07 -0400 Received: from pmx.vmail.no (localhost [127.0.0.1]) by localhost (pmx8.isp.as2116.net) with SMTP id 5937444BA5; Sun, 22 May 2011 23:19:19 +0200 (CEST) Received: from smtp.bluecom.no (smtp.bluecom.no [193.75.75.28]) by pmx.vmail.no (pmx8.isp.as2116.net) with ESMTP id 2C4EC44114; Sun, 22 May 2011 23:19:19 +0200 (CEST) Received: from localhost.localdomain (unknown [212.4.57.94]) by smtp.bluecom.no (Postfix) with ESMTP id 1DD4BD4; Sun, 22 May 2011 23:19:04 +0200 (CEST) From: =?UTF-8?q?Sjur=20Br=C3=A6ndeland?= To: "David S. Miller" , netdev@vger.kernel.org Cc: =?UTF-8?q?Sjur=20Br=C3=A6ndeland?= Subject: [PATCH 3/5] caif: Fix freezes when running CAIF loopback device Date: Sun, 22 May 2011 23:18:52 +0200 Message-Id: <1306099134-12989-3-git-send-email-sjur.brandeland@stericsson.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1306099134-12989-1-git-send-email-sjur.brandeland@stericsson.com> References: <1306099134-12989-1-git-send-email-sjur.brandeland@stericsson.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fix spinlock bugs when running out of link-ids in loopback tests and avoid allocating link-id when error is set in link-setup-response. Signed-off-by: Sjur Brændeland --- net/caif/cfctrl.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c index f8ac313..e22671b 100644 --- a/net/caif/cfctrl.c +++ b/net/caif/cfctrl.c @@ -368,7 +368,8 @@ static int cfctrl_recv(struct cflayer *layer, struct cfpkt *pkt) cfpkt_extr_head(pkt, &cmdrsp, 1); cmd = cmdrsp & CFCTRL_CMD_MASK; if (cmd != CFCTRL_CMD_LINK_ERR - && CFCTRL_RSP_BIT != (CFCTRL_RSP_BIT & cmdrsp)) { + && CFCTRL_RSP_BIT != (CFCTRL_RSP_BIT & cmdrsp) + && CFCTRL_ERR_BIT != (CFCTRL_ERR_BIT & cmdrsp)) { if (handle_loop(cfctrl, cmd, pkt) != 0) cmdrsp |= CFCTRL_ERR_BIT; } @@ -604,16 +605,16 @@ static int handle_loop(struct cfctrl *ctrl, int cmd, struct cfpkt *pkt) case CFCTRL_CMD_LINK_SETUP: spin_lock_bh(&ctrl->loop_linkid_lock); if (!dec) { - for (linkid = last_linkid + 1; linkid < 255; linkid++) + for (linkid = last_linkid + 1; linkid < 254; linkid++) if (!ctrl->loop_linkused[linkid]) goto found; } dec = 1; - for (linkid = last_linkid - 1; linkid > 0; linkid--) + for (linkid = last_linkid - 1; linkid > 1; linkid--) if (!ctrl->loop_linkused[linkid]) goto found; spin_unlock_bh(&ctrl->loop_linkid_lock); - + return -1; found: if (linkid < 10) dec = 0;