Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp663005rwr; Fri, 5 May 2023 03:11:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5iZ5C7GW9Kqy5r1aTzfn39JeOrt0LNiWeQEesURBa5ge6bIXy9QsfKLZGblu6xJ5+c6uzJ X-Received: by 2002:a17:90b:3807:b0:24d:d7fd:86c3 with SMTP id mq7-20020a17090b380700b0024dd7fd86c3mr912987pjb.16.1683281475106; Fri, 05 May 2023 03:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683281475; cv=none; d=google.com; s=arc-20160816; b=jYmbBh4LMer+AD0mfTl6IHrSi+HZ2bvaPMdXniv3ey3qyVUUvEH4GBSYqdO6TOsS8j 6so0bkeeOwwbxq4FHOSa0YQ5LuPVSYvI+aGcl/bSmXzLy4VPjj76et0Mz1PkCu0G+zM+ Yz2UCO1W3VgEpWiG52sVV62m6KHdXZWExUpawr+THfTQhS1/Y7eIKdph4ZZNOoQvBrqB Znb9MGNgS0Sk6ExdvIttkYwq2kekCMGyTV8Kk+8vjQg7jelvfQIlhh/z9mkHbn7A0rrh LFiYPyM11FgxN9+8Q9abwKJMlERE/oQ9y3CZn3O4t3C0gawjze0SQJsn5ELk0MGBEg7J LMbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tG3khmz+PbUqtRe6nuzCK18UTDQxmqQ5JyV5eU/cEaQ=; b=pZrtLGC3g3BrHrjcJoYGPuEKrHGeFkBDPF2BYTliTETRy4deBmE7nPjupHCTqNS57B KGTsup5mL67D1cq2cdoynuRd3hQsJNr2Kl70PEgugeZq4o6qhP+9dp1HC+y4PfnK/wTq H7Z6UdJMUwhTrMTk8uETaAgBXsJu99xCWA7E6zUA9Ddzcf919Ywq/01TtUpPPU21bvwU Xww+wBRNKhsBez44HuDaGQjHQ5sM+XibAN/lUV+/av8ACUljufkfUY0rgqwttYItJFsu y5GcWGY+OZWEBVhLQyjLA0SQ1fucjeO51uj6OIKb/tQqDRdQUF76dMfibX4gZXitnRcG UJlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YaN4DPMt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v184-20020a6389c1000000b0051394ccd19csi1716074pgd.55.2023.05.05.03.10.59; Fri, 05 May 2023 03:11:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YaN4DPMt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbjEEJ2P (ORCPT + 99 others); Fri, 5 May 2023 05:28:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbjEEJ16 (ORCPT ); Fri, 5 May 2023 05:27:58 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F8C83C20 for ; Fri, 5 May 2023 02:27:56 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f315712406so91350595e9.0 for ; Fri, 05 May 2023 02:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683278875; x=1685870875; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tG3khmz+PbUqtRe6nuzCK18UTDQxmqQ5JyV5eU/cEaQ=; b=YaN4DPMt6ugogOGME6oBtigy2j0IIygV1eXqyQJlKk5EkXDxHAqItp5sSFTyStNqZl wbGTdjhP1/WE5EJSY4j4KzW3Tp999avbCpV0TRuC4/BrqR/rlBFoZn4us30/0hxiVzCL p77mhMNm8NxGD8iZIj1UvsgpY8s25thExh5qE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683278875; x=1685870875; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tG3khmz+PbUqtRe6nuzCK18UTDQxmqQ5JyV5eU/cEaQ=; b=ViePpqNF/PbhUTZyAZGEoSBcG6q4m/BNUuZOio2CJJ2a1Cjzld09lmKn1aIUliyd0N UFu6F+RC/HZeVQcx6DJ2pcSrzekeclJzdQ5o2BZZJM0zk6DSahWN5oxHnQpc8T3EOZ8o ZA7WMaddPAxdZErbF0Zf5dM0E83XdTCBlQjATXZvyebzAlf7DgI4Re4x736UYnYU0vic 8rMaOTrbDr08KGg9YQfIhLuTmmUBm9lz+zYLrRbcTIMpxw5c1CpBrU448PaoGbzPwYpA y/nly0lA6LG3bPAPx9T6uX5EI9uipP7VtdQEO7FtOJoYIrqmzQKrQLwbdGhFRhx0i3Xq zyZQ== X-Gm-Message-State: AC+VfDwxQytfYNJl1q2adoqdlewKJol03fktYSDKzhsCfdNa9B1MeHVx bgLSRJHDdjxwbeG2FH8Q9r0pz0gnHxsERiBLTZY= X-Received: by 2002:a5d:5689:0:b0:304:7bbf:7c1e with SMTP id f9-20020a5d5689000000b003047bbf7c1emr4240011wrv.4.1683278874844; Fri, 05 May 2023 02:27:54 -0700 (PDT) Received: from google.com ([37.228.205.50]) by smtp.gmail.com with ESMTPSA id s7-20020a1cf207000000b003f1733feb3dsm7491394wmc.0.2023.05.05.02.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 02:27:54 -0700 (PDT) Date: Fri, 5 May 2023 09:27:52 +0000 From: Fabio Baltieri To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: hid-stadiaff: add support for Stadia force feedback Message-ID: References: <20230403103324.1746758-1-fabiobaltieri@chromium.org> <20230413160033.buwdbysbbc2hgu6o@mail.corp.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230413160033.buwdbysbbc2hgu6o@mail.corp.redhat.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, Apr 13, 2023 at 06:00:33PM +0200, Benjamin Tissoires wrote: > > drivers/hid/Kconfig | 7 ++ > > drivers/hid/Makefile | 1 + > > drivers/hid/hid-ids.h | 1 + > > drivers/hid/hid-stadiaff.c | 132 +++++++++++++++++++++++++++++++++++++ > > Mind renaming this hid-google-stadiaff.c? > It's hard to know that stadia is from Google otherwise. Sure thing. > > +static int stadiaff_play(struct input_dev *dev, void *data, > > + struct ff_effect *effect) > > +{ > > + struct hid_device *hid = input_get_drvdata(dev); > > + struct stadiaff_device *stadiaff = hid_get_drvdata(hid); > > + struct hid_field *rumble_field = stadiaff->report->field[0]; > > + > > + rumble_field->value[0] = effect->u.rumble.strong_magnitude; > > + rumble_field->value[1] = effect->u.rumble.weak_magnitude; > > + > > + schedule_work(&stadiaff->work); > > It seems weird that you don't have any locking in place here. > What if you are sending a report (in stadiaff_work) while having your > _play() function called at the same time? Yeah you are right, I somehow missed the whole locking story, sending a v2 with that added. > > +static void stadia_remove(struct hid_device *hid) > > +{ > > + struct stadiaff_device *stadiaff = hid_get_drvdata(hid); > > + > > + cancel_work_sync(&stadiaff->work); > > What if you have a ff play event scheduled right here? Don't you need > some way of forcing the work to not be scheduled once again? Good point, adding that as well for v2, took the pattern from other existing drivers. Thanks for the review, Fabio -- Fabio Baltieri