Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6962894rwb; Mon, 12 Dec 2022 08:24:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf54X9RqDBtp6B3nWCVfHClXEaMCIB/owQ+y47u2rdrMsDky8YBAWY62tXiGOW4xvEJMcn2G X-Received: by 2002:a05:6402:68f:b0:46f:a70d:fef2 with SMTP id f15-20020a056402068f00b0046fa70dfef2mr6616349edy.35.1670862269096; Mon, 12 Dec 2022 08:24:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670862269; cv=none; d=google.com; s=arc-20160816; b=jDnQELe8ea9WuJ/IQJuAuoiywAR0rZr7m8iGi3+J6lMVtmvKjKD/i19ZvuGkKFcugl /KQug7YDXsT77YSZRNfUy0AKgfDu9BgUD/mgdtsDZzPJ5NH9aiKyMkBI0SL5rGYb8Zl2 zaANL6eMXRHHF1cCFusm4fpy3lGbzB472FWKJu45WC0lgZFcXhN4106XJanaUl4ZRdOR GI+uAdJpmBtlXE3kqtD4RURpe1fdpt2krb6UWKd7j8AqUUHCjp6y4+4QASU1rTTfWA8z jC88nIEPMSezS3pE0G1ctLn69KVTCwG886HgqZWnVZ9DtgIG9ou2GmJQB4xwF/P0RAjW dwuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9AHrQ7N3nRBE+WOLy0Bq5g+V2hYQvIG1OHCO+pLERp0=; b=L2d+pOjHqMpZScthIBAv9Fox6U/DJ1lLtU58OL4UIm0VyPLAMIrgixj6+p6fQSxpiO NRYWpRDg81JWzz3cbvW5goFF3AcoH3VouCQTPHPKIH9uW/J0gmdfgA8janqbTlOhLTnZ C8VaRGduaI7UjOISkSb19+fBUjl3ijbHp8cp17h2tt2rIYwYEm9Zm5qEuFxdc3sRssGc gyoxfMgsC/bu/sxHbPslMtb1kRPQogOS7lQQSBid8PpfXdFzShdqolAjN8bWSEhZ1F7l 4Ht7AYzgeLU53/5qSz9AFvA6dAZJXFNNjTzixFQ72Kqyg7YyeG2trCgez1vT0bSOrrqc R4Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RmHTBIvk; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a056402518900b004588af9ea19si9815557edd.166.2022.12.12.08.24.08; Mon, 12 Dec 2022 08:24:29 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=RmHTBIvk; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232307AbiLLPZE (ORCPT + 74 others); Mon, 12 Dec 2022 10:25:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231685AbiLLPZC (ORCPT ); Mon, 12 Dec 2022 10:25:02 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45C1EDF57; Mon, 12 Dec 2022 07:25:01 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id u19so10429731ejm.8; Mon, 12 Dec 2022 07:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9AHrQ7N3nRBE+WOLy0Bq5g+V2hYQvIG1OHCO+pLERp0=; b=RmHTBIvkXbdmJ5ksl/eZVByvCarZ8CgvdstcoD39FvhfidCefGaPFxvPUURIX0sGhb TvWQyJXIDLwBVEg2XhH7AkMb/1q0XKQNBQoXxHHhSNobRK5sWwKSsAJrxiNBcoGEGVmP kwaPucHYXKh1m3LhUWSFcnFKh5oPJ1lKnlimVtpDllvumhNurl1O7rHgOWcz/4UplkcO HvwUPefHOi7uL2I0qfTLQs/Nq7B/kSZfUx42FvMhGirjlBue1fY6oJKHWTOp5lXv9YQC Cbcae0nlcsRV4cpAp+eNcunMAiVRD4Glih6kcuc8kcN3e+uKVy/QNz7tV7Zikfo21jAo 7qNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9AHrQ7N3nRBE+WOLy0Bq5g+V2hYQvIG1OHCO+pLERp0=; b=PDLIcHre0YZWKIdwCpgkrPsnSxBRzShuFjei0ynh4uEhc/J87NLKqy6WQCDh5AU4T5 3LIutxV3dpqRvkC5B9MJoUO1G+etjEmib5ou6k0NcUjIGbFxdnaLZ6fKPjB//2KSzufs 1IbOz3Fb1B+9QJ4ihCS6QgwljmubcXSLFyDXOEV0LffnJ3HUtczFrHRtbuq+4MAhYAdL xh3GGmB1EOUztNu6RqRymsdyM/49j480WxXv9aqHEjZCryzkGp+T1bfTJ7CkNSyw0b2p Q6WwxQU4gPPylOs6NmByS/yXiBFZZRNAwnNJ8xCjI6sxaOqba4EQnwD0vSCdSveTD0ap ZmGg== X-Gm-Message-State: ANoB5plnZLU0bRtwESxPp2yi6YP2Cf7aqP6hxFKctgrZi2f8OqIZdeTD do6yriIC3iCkKAdwAbNPtm28gCMvi7JrIeO5yk8= X-Received: by 2002:a17:906:4bc4:b0:78d:6325:356 with SMTP id x4-20020a1709064bc400b0078d63250356mr79921777ejv.6.1670858699756; Mon, 12 Dec 2022 07:24:59 -0800 (PST) MIME-Version: 1.0 References: <20221205210354.11846-1-andrew.smirnov@gmail.com> In-Reply-To: From: David Rheinsberg Date: Mon, 12 Dec 2022 16:24:48 +0100 Message-ID: Subject: Re: [RFC PATCH 0/2] Handling of non-numbered feature reports by hidraw To: Andrey Smirnov Cc: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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, 8 Dec 2022 at 21:59, Andrey Smirnov wrote: > > On Thu, Dec 8, 2022 at 7:46 AM David Rheinsberg > wrote: > > > > Hi > > > > On Mon, 5 Dec 2022 at 22:04, Andrey Smirnov wrote: > > > I'm working on a firmware of a device that exposes a HID interface via > > > USB and/or BLE and uses, among other things, non-numbered feature > > > reports. Included in this series are two paches I had to create in > > > order for hidraw devices created for aforementioned subsystems to > > > behave in the same way when exerciesd by the same test tool. > > > > > > I don't know if the patches are acceptable as-is WRT to not breaking > > > existing userspace, hence the RFC tag. > > > > Can you elaborate why you remove the special handling from USBHID but > > add it to UHID? They both operate logically on the same level, so > > shouldn't we simply adjust uhid to include the report-id in buf[0]? > > > > Also, you override buf[0] in UHID, so I wonder what UHID currently > > returns there? > > > > IOW, can you elaborate a bit what the current behavior of each of the > > involved modules is, and what behavior you would expect? This would > > allow to better understand what you are trying to achieve. The more > > context you can give, the easier it is to understand what happens > > there. > > > > Sorry it's not very clear, so the difference between the cases is that > in the case of UHID the report ID ends up being included as a part of > "SET_FEATURE", so BlueZ checks UHID_DEV_NUMBERED_FEATURE_REPORTS, > which is not set (correctly) and tries to send the whole payload. This > ends up as a maxlen + 1 (extra byte) write to a property that is > maxlen long, which gets rejected by device's BLE stack. > > In the case of USBHID the problem happens in "GET_FEATURE" path. When > userspace reads the expected data back it gets an extra 0 prepended to > the payload, so all of the actual payload has an offset of 1. This > doesn't happen with UHID, which I think is the correct behavior here. > > Hopefully that explains the difference, let me know if something is unclear Yes, thanks, I completely missed that. Lets continue discussion on the patches. Thanks! David