Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756356AbcK3JpA (ORCPT ); Wed, 30 Nov 2016 04:45:00 -0500 Received: from mail-wj0-f193.google.com ([209.85.210.193]:34307 "EHLO mail-wj0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754190AbcK3Jos (ORCPT ); Wed, 30 Nov 2016 04:44:48 -0500 Date: Wed, 30 Nov 2016 10:44:41 +0100 From: Richard Cochran To: Grygorii Strashko Cc: "David S. Miller" , netdev@vger.kernel.org, Mugunthan V N , Sekhar Nori , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, Murali Karicheri , Wingman Kwok Subject: Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts Message-ID: <20161130094441.GB28680@localhost.localdomain> References: <20161128230428.6872-1-grygorii.strashko@ti.com> <20161128230428.6872-2-grygorii.strashko@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161128230428.6872-2-grygorii.strashko@ti.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1080 Lines: 49 On Mon, Nov 28, 2016 at 05:04:23PM -0600, Grygorii Strashko wrote: > @@ -678,6 +744,9 @@ struct gbe_priv { > int num_et_stats; > /* Lock for updating the hwstats */ > spinlock_t hw_stats_lock; > + > + int cpts_registered; The usage of this counter is racy. > + struct cpts *cpts; > }; This ++ and -- business ... > +static void gbe_register_cpts(struct gbe_priv *gbe_dev) > +{ > + if (!gbe_dev->cpts) > + return; > + > + if (gbe_dev->cpts_registered > 0) > + goto done; > + > + if (cpts_register(gbe_dev->cpts)) { > + dev_err(gbe_dev->dev, "error registering cpts device\n"); > + return; > + } > + > +done: > + ++gbe_dev->cpts_registered; > +} > + > +static void gbe_unregister_cpts(struct gbe_priv *gbe_dev) > +{ > + if (!gbe_dev->cpts || (gbe_dev->cpts_registered <= 0)) > + return; > + > + if (--gbe_dev->cpts_registered) > + return; > + > + cpts_unregister(gbe_dev->cpts); > +} is invoked from your open() and close() methods, but those methods are not serialized among multiple ports. Thanks, Richard