From patchwork Wed Mar 14 02:45:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 885592 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cUZJqqB2"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 401GLc2V6vz9sTT for ; Wed, 14 Mar 2018 13:45:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 54146226D6; Wed, 14 Mar 2018 02:45:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iulpqW2RoWE4; Wed, 14 Mar 2018 02:45:57 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 6BDF6226CA; Wed, 14 Mar 2018 02:45:57 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 1D2311C16D3 for ; Wed, 14 Mar 2018 02:45:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 18DBA226CA for ; Wed, 14 Mar 2018 02:45:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yWoy31dRj4FG for ; Wed, 14 Mar 2018 02:45:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-io0-f193.google.com (mail-io0-f193.google.com [209.85.223.193]) by silver.osuosl.org (Postfix) with ESMTPS id 5B79222648 for ; Wed, 14 Mar 2018 02:45:55 +0000 (UTC) Received: by mail-io0-f193.google.com with SMTP id m83so2538527ioi.8 for ; Tue, 13 Mar 2018 19:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=aRDaVzP+GKa5FEBgQocS6aioNZ6qnNwz61PmrRaFHZY=; b=cUZJqqB20ScYCSguUHbyHB2metHqjyhIcvIdfYykbNj0paHI1uBpbhRSlRRxJsWkbC DPeQSWaoE3Zp1AWL9GD+ZGmgjhfKrsP4Y1+ll+mXiP5Ak4BHUcAvmjSzhOu2bbpsizza PLUBfdTFf/7yImrLc1/U08GHPLyZu//7sWs+3ezwb0pXLjVSj3p8pgY2QDiRbp2FOHvV Ua0ckoDYlTv47EHJNhNC08LPyrJWspYCvimeVxjfIxuG78s91eZ2ybVk7Ah/PU9aPqYq pUhd5k8aCCAax13cYRqUl/d3ynIxhuNyn48Bmc0DTaXxsVTWLSUMC7CPpOx10kIMlgp2 Nv4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=aRDaVzP+GKa5FEBgQocS6aioNZ6qnNwz61PmrRaFHZY=; b=WoBnfBgkHs8MtPji9LuI5vNkPlKzpBGryG/8fOV5KLrUIF2lO8l9FkDILWyzPminV5 Z+cM+ajpmXlp2M5iuzbIiY+TW0tdy+7AubtpEnJh+wb36eiUpJ9j7KKdOanDTXGQPdHP f5wIb9jqz6xImcuP5NL7H99ugHr8sd9qXXG8erLlmrBylJTURGApM6WO3xsTvdZt7oFa 7jbickLpK+8AO0djNLg9NX17Gt0PPnAEbTsbTHmq6bKMXzr0+fXmTBtpjfWxRXdQuhwg KMUqlJJ0PUBzlqvC1nymy4YT+1PbbgKyuOemvtHbzjGQpaOJbKwpNyYRovqVBVYN8GyR k4Tw== X-Gm-Message-State: AElRT7HzMogDe1NDjyhmK76JkaqGzBltvToFHSLRWpHqee/AZPEAHiiN /Nk//CJj5f8sIYSRtsla7yJiq9Mz X-Google-Smtp-Source: AG47ELvhUb+CareQyI3z9EVeVSoN+x9aRePHUarjddg2eUUJyWjPoooPWgJiPubxXjjOMM5hMFxuFQ== X-Received: by 10.107.135.157 with SMTP id r29mr3075996ioi.248.1520995554193; Tue, 13 Mar 2018 19:45:54 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id v18sm127527ita.22.2018.03.13.19.45.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 19:45:53 -0700 (PDT) From: Alexander Duyck To: intel-wired-lan@lists.osuosl.org Date: Tue, 13 Mar 2018 19:45:52 -0700 Message-ID: <20180314024552.7086.86874.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Intel-wired-lan] [next-queue PATCH] i40evf: Reorder configure_clsflower to avoid deadlock on error X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Alexander Duyck While doing some code review I noticed that we can get into a state where we exit with the "IN_CRITICAL_TASK" bit set while notifying the PF of flower filters. This patch is meant to address that plus tweak the ordering of the while loop waiting on it slightly so that we don't wait an extra period after we have failed for the last time. Signed-off-by: Alexander Duyck Tested-by: Andrew Bowers --- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c index 52a017c42ffd..57e74f845dc4 100644 --- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c +++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c @@ -2792,14 +2792,7 @@ static int i40evf_configure_clsflower(struct i40evf_adapter *adapter, { int tc = tc_classid_to_hwtc(adapter->netdev, cls_flower->classid); struct i40evf_cloud_filter *filter = NULL; - int err = 0, count = 50; - - while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, - &adapter->crit_section)) { - udelay(1); - if (--count == 0) - return -EINVAL; - } + int err = -EINVAL, count = 50; if (tc < 0) { dev_err(&adapter->pdev->dev, "Invalid traffic class\n"); @@ -2807,10 +2800,16 @@ static int i40evf_configure_clsflower(struct i40evf_adapter *adapter, } filter = kzalloc(sizeof(*filter), GFP_KERNEL); - if (!filter) { - err = -ENOMEM; - goto clearout; + if (!filter) + return -ENOMEM; + + while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, + &adapter->crit_section)) { + if (--count == 0) + goto err; + udelay(1); } + filter->cookie = cls_flower->cookie; /* set the mask to all zeroes to begin with */ @@ -2835,7 +2834,7 @@ static int i40evf_configure_clsflower(struct i40evf_adapter *adapter, err: if (err) kfree(filter); -clearout: + clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); return err; }