Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp940987ybi; Fri, 2 Aug 2019 06:50:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVNFqMxSL7bBR3jL/qEqUfP4eRA41vbKysSuljrB7KaTUfitUMCZumr4dW3Q9TirPqX+XX X-Received: by 2002:a63:724b:: with SMTP id c11mr45879399pgn.30.1564753843188; Fri, 02 Aug 2019 06:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564753843; cv=none; d=google.com; s=arc-20160816; b=hFWdmCkMjwoodZwxx13o0qp0oxJijptkRB59bCUzYY7IWwiuV52Yf+9r0v2PJp+ish 1Z1QO4YCxTMtNGlJ1Eg3GNfmtMBGDfOSxewwbVY9/V/Ril6xzWqLs8FQAPoAEo0WCNXE oh84gekR26wKtfY+UMUSbWSDZ5/PyLVpi7VPxEFjrEycnSfA//vdS4t654aLT94+rFsV onP5ZSw+8dncVFkmudSDtkxAHRanakVaEvDt/VETz3W4lLRDXmlmwZMxE5peAdpAd2B4 zFkSH9SdFAO/Sqi6/AQKU9oRUEOPU5hz6d4npNHGDMa/o7318SpPcY7Tqskm6I30JB1t oEeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=s3ianRPCP2Zu9bnZaFDrTAINsaT4fxD5fOtOtR4Ftwg=; b=vEGRy09QO+48RetfdG+p0mqTEn50Nuw+pNnWdOa7PncPLAVWp0PnMeKYYsWLNpSjmB bWv8i8sXygGEDRLQmgZiOc663udDE670ghq/DZgxZPfYcIzrt4XL1/D/I9EgdK7UioeZ bJErrfqVn2sgcSFE2DjV2n5oAPLUWCWiVqi2JJZ6PjQ89w9Dv+0JJ6ra52BecHzvLtGS fW8pEG3AngGnuIPNEquAn9R5bvIg07TqFwD8Y3EqCCwtuHkmXAuS8TjPOYSMPLb98yaf ajl/faM23ykX2dcVVno7fQ5Ar3aR1WztD7/t+8l3B5/zTimb9x1LoTo/RU2ZFBbk6rGL AtZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=edKvkr2Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si12129132pgt.285.2019.08.02.06.50.27; Fri, 02 Aug 2019 06:50:43 -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; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=edKvkr2Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733191AbfHBKzN (ORCPT + 99 others); Fri, 2 Aug 2019 06:55:13 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40689 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbfHBKzN (ORCPT ); Fri, 2 Aug 2019 06:55:13 -0400 Received: by mail-pf1-f194.google.com with SMTP id p184so35851593pfp.7; Fri, 02 Aug 2019 03:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s3ianRPCP2Zu9bnZaFDrTAINsaT4fxD5fOtOtR4Ftwg=; b=edKvkr2YLIpIwx88PyQUx4RInX3evd5YZicPc5fVUrirsHVeUJEV18bp69Zsr/uwZR 7aEy0TZ09nh32GepyRrJ/2r4tgsVN4KfX4CvTzM9oCWZuVThYFYrEY86NzdIS42I3lvG W7hbLhLjK5sCECqKDZXL28jX4STloI6gjFBeF7BZaNGONsTPKTOLJHTc0zMFXRxKa/fd cIwHFYqkSOh0BkHPPorRoUVGUsANLrsYzVbkxP+hq3xNwhRy5iEsugguKukd63Q6WjEG RllZ1/urSwAAeorhM/DK5j3DUIXDFZyO8yD7wPISRGd2SLksT7PpLvUb6GiT5xRsQ9LQ kXMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s3ianRPCP2Zu9bnZaFDrTAINsaT4fxD5fOtOtR4Ftwg=; b=pdXCeDdqtjbzetim8LIsIWUIHTercEVkad/DJID66f+LsjiODvhISL3UCy3OTRzbSn 5y0RONrbZ4XaqGJBkAR2JanmRhpLWFiISZ+Cn0wXBT0B1sGiLe5TcWCjt802vnY7zwi9 Ax1LI68QR0356WnlHMZuuLqSLPsjl+7tFdREXCeIPhxCuhZIK4eowP9FityqAG4Ke5XJ U4NDz7yjzquGZUBqhpqLgcq3F93q+TGUoZsvpx8xr4WC/VQE0QiwRSZSs75gyppINh44 YMV/v75DI4Ebqj1dioZXU9olSLOD3rfaEPeyjF7KYn/UHFN3XEqJsoYS4amLzihCUNwG 1mLA== X-Gm-Message-State: APjAAAWQ25hSsDi96SksrZb1SCCj9xUOTmZRzzxZIZfbEozeyS/GK4cT uMHfREorWp5CuXV5mJdi4QQ= X-Received: by 2002:a62:874d:: with SMTP id i74mr57943418pfe.94.1564743312378; Fri, 02 Aug 2019 03:55:12 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id v7sm34909052pff.87.2019.08.02.03.55.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 03:55:11 -0700 (PDT) From: Chuhong Yuan Cc: Jeff Kirsher , "David S . Miller" , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH 2/2] ixgbe: Use refcount_t for refcount Date: Fri, 2 Aug 2019 18:55:07 +0800 Message-Id: <20190802105507.16650-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org refcount_t is better for reference counters since its implementation can prevent overflows. So convert atomic_t ref counters to refcount_t. Also convert refcount from 0-based to 1-based. This patch depends on PATCH 1/2. Signed-off-by: Chuhong Yuan --- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 6 +++--- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index 00710f43cfd2..d313d00065cd 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -773,7 +773,7 @@ int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter) fcoe->extra_ddp_buffer = buffer; fcoe->extra_ddp_buffer_dma = dma; - atomic_set(&fcoe->refcnt, 0); + refcount_set(&fcoe->refcnt, 1); /* allocate pci pool for each cpu */ for_each_possible_cpu(cpu) { @@ -837,7 +837,7 @@ int ixgbe_fcoe_enable(struct net_device *netdev) struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_fcoe *fcoe = &adapter->fcoe; - atomic_inc(&fcoe->refcnt); + refcount_inc(&fcoe->refcnt); if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE)) return -EINVAL; @@ -883,7 +883,7 @@ int ixgbe_fcoe_disable(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); - if (!atomic_dec_and_test(&adapter->fcoe.refcnt)) + if (!refcount_dec_and_test(&adapter->fcoe.refcnt)) return -EINVAL; if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h index 724f5382329f..7ace5fee6ede 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h @@ -51,7 +51,7 @@ struct ixgbe_fcoe_ddp_pool { struct ixgbe_fcoe { struct ixgbe_fcoe_ddp_pool __percpu *ddp_pool; - atomic_t refcnt; + refcount_t refcnt; spinlock_t lock; struct ixgbe_fcoe_ddp ddp[IXGBE_FCOE_DDP_MAX_X550]; void *extra_ddp_buffer; -- 2.20.1