Received: by 10.223.185.116 with SMTP id b49csp2490936wrg; Thu, 22 Feb 2018 14:55:31 -0800 (PST) X-Google-Smtp-Source: AH8x227q+FodqPJl6dxckpXJdlkjMBo8UhOrDzbnk4bAUq5FC1yu7Qpi3AWXwu2aR8+4xKmlwDsW X-Received: by 10.99.116.22 with SMTP id p22mr7000876pgc.132.1519340131251; Thu, 22 Feb 2018 14:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519340131; cv=none; d=google.com; s=arc-20160816; b=hxIhwUtMJjjpTMw1yB3ugbN65qCIBI/57KKU2uld3SslHsM8+vkYXQsyJ4VGiVGMP/ j3KjbTTQGHujS3RqNseLj7mNMnaMU3+BRDe8qPZsbOVrbWiY+yz9T0bpPlPd2YbTXi31 n8+bx+/Oty9erIpI52S6B30CLayl2WztuS7Qg+D0OWUcWy2xPeulmWZoL6PbCpuHKUAN Q2S3TAe++h41H6IddMVQfwWLWiRcMG81Pq8LqWlWP9MVVdUMskczC2ulbZ/yK5nQ8ThB HK6dGsHKHFnXkZSFjzp9JLpBsBOUIZHPohqzgWuOtloCfyYaPTngtxiSCy2cYfyObHSM aYNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=PEy9ICgWRj9TLxW2sURhFxfFBHbbEFIfiWGmSGgRlWU=; b=K8FTjPlU13Xx3LPUMZQ0qCuUAv6UbFsM/HEvpfw4TSUje0p7HHsjmpZS2TrDA1ZKqV uW0CDC0I3eec9uF6jYHYQerJZWNkkzcovwe07cjdtZrrzO+TbraS35cY8BkC+7gD5Fwd cixPPZ+7aBaZ4qxatTJjIdmOMU7ETXcrMX+xBmMmrMd86EMVmeA68HYfv7F32XcdJvm0 ufK3fLjQidpxiG3ESyNWFCGAvBdlWoc7k8GTd9+NEf6K+KqOXX02JhwAUd/1BID84kOU ZrGSql9UP/jdfMBfwzwjkyDphYCeWZoZ+qQijq/gSG+tMrplPtAY9N7bGaVrngMzDT4o b7tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cWYPJXME; 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=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 d5si733680pfl.224.2018.02.22.14.55.15; Thu, 22 Feb 2018 14:55:31 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=cWYPJXME; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751849AbeBVWye (ORCPT + 99 others); Thu, 22 Feb 2018 17:54:34 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:53077 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbeBVWyb (ORCPT ); Thu, 22 Feb 2018 17:54:31 -0500 Received: by mail-wm0-f67.google.com with SMTP id t3so1328726wmc.2; Thu, 22 Feb 2018 14:54:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PEy9ICgWRj9TLxW2sURhFxfFBHbbEFIfiWGmSGgRlWU=; b=cWYPJXMEgjaXAGHjdzXniREbzZOXizsx4/8yZBVmvj63EgfYNQ+JBwy2wcfthFSI2n Q4mfAC8zuM7fIokcIUS4iTZCgnDOmN1QN4aDhaguQ0zBK4R3wYQ30saKnrqbAj5Qfb2P Syvj5dJzA95WB6LXTJEmayJt3pmJok5Fj8Qw8d/HpBGaCI9shz7ZzCJhPKiZslNZmY4R 2NY50I4q/bDiKkOVY2/i7AorKv0+kJfF2a1Qz213x6/b54UQzGAd9Y2T+hB6KDgxbweB RprOatIzHBWGd91NvZJwvfpilZvDo+R7LRIsksY4ykbClgDZ8lUXxdSUwrv4JQhdZ9yP u+Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PEy9ICgWRj9TLxW2sURhFxfFBHbbEFIfiWGmSGgRlWU=; b=qU34ghuIO/wFLICXieGrgwd2G1Wy9r5bi8AxK3IIg2ygEGZASAm1LJ7COwAUnWP5sC Z+B6QN0H0BKt4kBNIsc8LV8FeDv6irWZTXUrbOxd9tYHG3hrr02ss+TSOMl+yMqgIlYE QZggMeXcwh0xX3ffAc8vCzqz+GKVkAlSvrtnyHBscyu4m0Vly54TZVIg+8I+1tDKyqMA 90YdOYTqk6bVnWn6UTLcWmlx0KId++F/DGPDxmvezqUm+VnDiuh0AyF/ka7rew7Z5X4I R10MgMPd2xK9i472aTyvPUzDhDvXhVsxH6KXcVdWxt4ZbP/1qd/R+SwxbUmGJ5JX2IJL 1d+A== X-Gm-Message-State: APf1xPAaCMTx3WZADMkFmYJzQmWar+MS3vtgPTZk9aAHYzMrYaX2tRUF 8U7l4z88EbGl/UBcsQiKLIU= X-Received: by 10.28.87.20 with SMTP id l20mr45333wmb.48.1519340069644; Thu, 22 Feb 2018 14:54:29 -0800 (PST) Received: from casa ([2a01:c50e:5126:7a00:ecf0:524b:baa1:5bb6]) by smtp.gmail.com with ESMTPSA id r188sm513710wmb.40.2018.02.22.14.54.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Feb 2018 14:54:28 -0800 (PST) Date: Thu, 22 Feb 2018 23:54:26 +0100 From: Rodrigo Rivas Costa To: Cameron Gutman Cc: Jiri Kosina , Benjamin Tissoires , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH v2 1/3] HID: add driver for Valve Steam Controller Message-ID: <20180222225426.GA3726@casa> References: <20180220193306.28748-1-rodrigorivascosta@gmail.com> <20180220193306.28748-2-rodrigorivascosta@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 20, 2018 at 09:32:08PM -0800, Cameron Gutman wrote: > On 02/20/2018 11:33 AM, Rodrigo Rivas Costa wrote: > > +static void steam_work_connect_cb(struct work_struct *work) > > +{ > > + struct steam_device *steam = container_of(work, struct steam_device, > > + work_connect); > > + unsigned long flags; > > + bool connected; > > + int ret; > > + > > + spin_lock_irqsave(&steam->lock, flags); > > + connected = steam->connected; > > + spin_unlock_irqrestore(&steam->lock, flags); > > + > > + if (connected) { > > + if (steam->input) { > > + dbg_hid("%s: already connected\n", __func__); > > + return; > > + } > > + ret = steam_register(steam); > > + if (ret) { > > + hid_err(steam->hdev, > > + "%s:steam_register failed with error %d\n", > > + __func__, ret); > > + return; > > + } > > + } else { > > + steam_unregister(steam); > > I think you need synchronization here. You don't want to be in the middle of > processing a HID event or power supply update and have your device freed out > from underneath you. > > xpad uses RCU to avoid this race. Ah, I see, if we get an input message just after the "disconnect" packet, (unlikely) it could file. I'll don't know RCU very will but I'll try and do my best. Please, stay tuned for v3. Thanks. Rodrigo