Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp304276ybi; Thu, 1 Aug 2019 19:28:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzydEZPZKQQZLkR7eBlk4G++881rXP9wk7cJHXuKMs36B+X2qGmewvqmo5aW+0lvB3o3VJr X-Received: by 2002:a17:902:a5c7:: with SMTP id t7mr130613454plq.288.1564712886135; Thu, 01 Aug 2019 19:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564712886; cv=none; d=google.com; s=arc-20160816; b=W2VfbIUYx4QsdKW4pHFIbmRtoSH2fCqkZVX4PHirc+9Pn5FpMrbfzZ07xVe680fGBj iXcutUG0S7P6ZR+V4DvTo8xPScQsAoPnv+DrC9EyQ/Qrt/IKERRWDzswGwFjaQLcUuFf aL0u19z/6AkLsIE21VY0O6lvNKPpd8vYskKgqY+FkxSmOigoPLvPEEPOvIUIu452lfrA 5IPOivHxlOw3NHkSCzXTivmMPalX/m6I2hvtVK8tFsWbAh49HR9ObC23YG5VpV6Bg3bM jQnQHS/0Dt0fHldeb1f9QRS/nEU6wyysi8eVyITlvRaNIauqZJvjf8TORQg3IM92nSpE yaDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=06Xjl8xwVElD8TuadDbhO8wIkDa5jiIzMLYGbCJ3IQM=; b=VymedPqcOKOpqOEKQnFQZ/vtXSkLuML8x/GgPGIbFYRwix7ZDzqljYBD7Gx99wOKnX dnH3stuW8Xqt2IG7h2R6iz941MB7j1QZ2SEtTjveKjedjCxHcWL6guVGYlz4dsuWWcmN 27RfOEQtT8W1hrtdoLt6sr73qc0PID5D9PjlGroHR9ZxAK2i1xHNRLlwuh+NLCahqyTO Q7tGkn/o/jO7Uhm2OIAxK2bk2pf9hcPyw3m7Gt822Jp19kJ9HL/Rw6uPNgyBQ8fTWbrv 5JzKM5njla6231GRguOOAI1jKimmyRbh/YkyLaIinuieB6NMtFhGkePMqCRYUEjlaHVS hJdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="F/+sle/f"; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17si39456094pfj.69.2019.08.01.19.27.51; Thu, 01 Aug 2019 19:28:06 -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=pass header.i=@broadcom.com header.s=google header.b="F/+sle/f"; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732735AbfHAXP7 (ORCPT + 99 others); Thu, 1 Aug 2019 19:15:59 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:42656 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728834AbfHAXP7 (ORCPT ); Thu, 1 Aug 2019 19:15:59 -0400 Received: by mail-yb1-f196.google.com with SMTP id f195so26272083ybg.9 for ; Thu, 01 Aug 2019 16:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=06Xjl8xwVElD8TuadDbhO8wIkDa5jiIzMLYGbCJ3IQM=; b=F/+sle/fJAUc8KeIW+463HFv2iEswCUDe0Le+Vpa4TxfuKdzpeleEYMIfoeb0K8rIc 7QXiBPPdWrJhKSTjcGREsRP60wmlUSpbHtC+/mLrsiJo9NbNtQYQmU2HJidAoxJ5K/R5 mKTHFeWOdm/MkCRoKVwdVQahn/1ZtB17tOhEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=06Xjl8xwVElD8TuadDbhO8wIkDa5jiIzMLYGbCJ3IQM=; b=hChdiZoDm7LCSLmbj30KdmvmJGZkhIGJPkPelGseIhdUynoerUmbTNmZSS+JpvHpi0 Vc795RzkhYmxzYJ4OqOPiKrygPAOuvitjTD8bCgwDeJX7BdJXo5cdJr/WstoPPC9lyMp lHQdbbQY8SMLr6yMeouMyxUK6kIHeisU1MAstk/SaxdvRo3YpRF2DrH4UgjVV+S5WNyV nCQmWRPSm8+1stnjypDCtAuHK07a//gzUfaUYXIbFwUxncUBqRA/IzqIoDQCHVwpaBtJ 5k5fd43EqenzTxcOSnqmo1Pbdybr1S8RJDa1IPX3M7bkAHvE5KMWOOcJVOP6/l4ihVoa qDug== X-Gm-Message-State: APjAAAWDbDYLRBW605/LY3qFjzpqWeiB3rOoF5t+DNiQrRIJmtqwIk+0 XKQQJGbbWc0TU6+7haX7O2bpgnB21TIdmVKqf6NOnA== X-Received: by 2002:a25:85:: with SMTP id 127mr84946065yba.186.1564701358458; Thu, 01 Aug 2019 16:15:58 -0700 (PDT) MIME-Version: 1.0 References: <20190731122224.1003-1-hslester96@gmail.com> In-Reply-To: From: Michael Chan Date: Thu, 1 Aug 2019 16:15:47 -0700 Message-ID: Subject: Re: [PATCH 2/2] cnic: Use refcount_t for refcount To: Chuhong Yuan Cc: "David S . Miller" , Netdev , open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 31, 2019 at 7:22 PM Chuhong Yuan wrote: > > Michael Chan =E4=BA=8E2019=E5=B9=B48=E6=9C=88= 1=E6=97=A5=E5=91=A8=E5=9B=9B =E4=B8=8A=E5=8D=881:58=E5=86=99=E9=81=93=EF=BC= =9A > > > > On Wed, Jul 31, 2019 at 5:22 AM Chuhong Yuan wro= te: > > > > > static void cnic_ctx_wr(struct cnic_dev *dev, u32 cid_addr, u32 off,= u32 val) > > > @@ -494,7 +494,7 @@ int cnic_register_driver(int ulp_type, struct cni= c_ulp_ops *ulp_ops) > > > } > > > read_unlock(&cnic_dev_lock); > > > > > > - atomic_set(&ulp_ops->ref_count, 0); > > > + refcount_set(&ulp_ops->ref_count, 0); > > > rcu_assign_pointer(cnic_ulp_tbl[ulp_type], ulp_ops); > > > mutex_unlock(&cnic_lock); > > > > > > > Willem's comment applies here too. The driver needs to be modified to > > count from 1 to use refcount_t. > > > > Thanks. > > I have revised this problem but find the other two refcounts - > cnic_dev::ref_count > and cnic_sock::ref_count have no set. > I am not sure where to initialize them to 1. > > Besides, should ulp_ops->ref_count be set to 0 when unregistered? I will send a patch to fix up the initialization of all the atomic ref counts. After that, you can add your patch to convert to refcount_t.