Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751946AbaFEQEi (ORCPT ); Thu, 5 Jun 2014 12:04:38 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:42604 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751000AbaFEQEh (ORCPT ); Thu, 5 Jun 2014 12:04:37 -0400 Date: Thu, 5 Jun 2014 12:04:35 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Marcus Nutzinger cc: Sergei Shtylyov , Felipe Balbi , Greg Kroah-Hartman , , Subject: Re: [PATCH] usb: gadget: gadgetfs: correct dev state In-Reply-To: <5A6C89E5-92AB-4908-8867-2BE783794E60@theobroma-systems.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Jun 2014, Marcus Nutzinger wrote: > Hi Sergei, > > On Jun 5, 2014, at 4:18 PM, Sergei Shtylyov wrote: > > > Please also specify that commit's summary line in parens. > > I'll resubmit the updated patch in a minute! > > >> + /* other endpoints were all decoupled from this device */ > >> + spin_lock_irq(&dev->lock); > >> + dev->state = STATE_DEV_DISABLED; > >> + spin_unlock_irq(&dev->lock); > > > > Not sure I understand why you need spinlock here... isn't the assignment atomic already? > > > Sure, an assignment might be atomic. However, following the policy of commit 7489d149 > (USB: gadgetfs cleanups) all ep0 state changes shall be protected by spinlocks. Sometimes an assignment needs to be protected by a lock, even though the assignment itself is atomic. This happens, for example, when some other code executes a lock-protected region that expects the variable not to change. I don't know if that's the case here. But this example shows that in general, one sometimes needs locks in places where you wouldn't expect them. In fact, it may even be necessary to take and release a lock, without doing anything in between! Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/