Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758588AbcK3RcI (ORCPT ); Wed, 30 Nov 2016 12:32:08 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:16837 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758396AbcK3RcA (ORCPT ); Wed, 30 Nov 2016 12:32:00 -0500 Subject: Re: [PATCH 1/6] net: ethernet: ti: netcp: add support of cpts To: Richard Cochran References: <20161128230428.6872-1-grygorii.strashko@ti.com> <20161128230428.6872-2-grygorii.strashko@ti.com> <20161130094441.GB28680@localhost.localdomain> CC: "David S. Miller" , , Mugunthan V N , Sekhar Nori , , , Rob Herring , , Murali Karicheri , Wingman Kwok From: Grygorii Strashko Message-ID: <4d69aff4-70a0-e6b8-38b0-8e95cfea7601@ti.com> Date: Wed, 30 Nov 2016 11:31:56 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161130094441.GB28680@localhost.localdomain> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [128.247.83.173] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1359 Lines: 59 On 11/30/2016 03:44 AM, Richard Cochran wrote: > 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. > ok. Seems my assumption that ndo_open/ndo_close serialized by rtnl_lock is incorrect. Right? net_device_ops.ndo_open -> netcp_ndo_open gbe_open gbe_register_cpts -- regards, -grygorii