Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp697629rdb; Sun, 3 Sep 2023 06:41:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVa4imzw0HqGQpSSZqgB0x9KDWpLahE1Hy+O09lLRZF25NvVclvpiZ4roByewS/DnjhyVe X-Received: by 2002:a17:907:7f29:b0:9a5:ae8a:6e0b with SMTP id qf41-20020a1709077f2900b009a5ae8a6e0bmr11950793ejc.24.1693748503246; Sun, 03 Sep 2023 06:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693748503; cv=none; d=google.com; s=arc-20160816; b=hiYO7Iieky1Vbr7XjpmSN8weZ6sVmKsfVNHb0fr8B1CT8t+Sq348GkoTpR0F/oWH+O gVpk9sWLlSEqZ+TsthHoiFV5Nnv1UlWNAMfdnBvFLvObJC5yAc4Q7TdRS+sev7ZD1jJ/ Wb6bkM7FBk7+MfhNaSTiUTf+KCGeWW3bJ6YWJBKpcsqI7SuwUtuzZhoCma9mNq+pbetU oCTijaDYHuTX+1vdEhDSR7fGmm3wH3jYph9c5gEIgOnJRTVoGYVGUk9ibjFyb7gwszGk 8igTi55IL1Hu3V0RPYQfrsiKBtLkuFwEsNOB4mX/6kbgMzqKuQz3RfZ52pmzBxImxi1m vjhg== 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; bh=qa0O/6UGBlvdy+D3h3pIUUnCYPhcZ1Atv2KqwlXlhwk=; fh=qTdisJEfMqbgJskV0UcI72UIEpNP3qVHasTo27t2Qnw=; b=kD8rPwOJ8/ivT3cCcar9nIiZGY6wyuswqbBRPlQOM+lYJ2F3rG34O6NSchI81qLfll WQY4Qvid+wSftih1AeYVyMOoKgthXH1iRN6OwfE3xIjAooYTWoZQHpvSX4spGbAX1ZlB A8Sv+HnVLkaleW9Lh0kwj7Z+L7BQf6MICRbMxkTWXgCO8o9Y4CUvHBF8Qa8TpKdn/6F1 /ZOoKz2EwmmNLZm04gIV9bbQZZbrN0wquGmYSHp9c5HtMhPvcx7uCtizajlNsGmNImz0 x5Dw63PviaXQ5fNEnuuOJCNxY2ipZBCu8OD8vU2fhbpPNzOXLUQsymWPNIrjKG5/sjbC zLTw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020aa7c3ca000000b005253e998abasi5043574edr.339.2023.09.03.06.41.36; Sun, 03 Sep 2023 06:41:43 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242194AbjHaPzI (ORCPT + 28 others); Thu, 31 Aug 2023 11:55:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232289AbjHaPzH (ORCPT ); Thu, 31 Aug 2023 11:55:07 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id D6A281A3 for ; Thu, 31 Aug 2023 08:54:57 -0700 (PDT) Received: (qmail 483141 invoked by uid 1000); 31 Aug 2023 11:54:57 -0400 Date: Thu, 31 Aug 2023 11:54:57 -0400 From: Alan Stern To: Milan Broz Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, Linux Kernel Mailing List Subject: Re: usb-storage: how to extend quirks flags to 64bit? Message-ID: <6553da2f-455e-4263-a9d9-b6dc64d61e92@rowland.harvard.edu> References: <6f8b825b-bc41-4080-8128-4a6f0a43f779@rowland.harvard.edu> <34aa2eea-5417-4e46-91a0-aac1a46a84cf@gmail.com> <2d580337-eaf3-47fb-afa7-1006d9a257ea@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS, SPF_PASS autolearn=no 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 On Wed, Aug 30, 2023 at 10:39:07PM +0200, Milan Broz wrote: > On 8/27/23 20:55, Alan Stern wrote: > > ... > > > > > > Someone will need a new quirks flag in the future anyway... :) > > > > > > > > I can think of only one way to accomplish this on 32-bit systems: Change > > > > the driver_info field from a bit array to an index into a static table > > > > of 64-bit flags values. Each unusual_devs structure would have its own > > > > entry in this table. As far as I can tell, the other unusual_*.h tables > > > > could retain their current driver_info interpretations, since no new > > > > quirk bits are likely to be relevant to them. > > > > > > > > Making this change would be an awkward nuisance, but it should be > > > > doable. > > > > > > Hm, yes, thanks for the idea,that is a possible solution. > > > It will need to modify all unusual macros, though. Just I am not sure I want > > > to spent time patching all the drivers as I have not way how to test it. > > > > I don't think it will be necessary to change all those macros, just the > > ones in usual_tables.c. And to create the new table containing the > > actual flag values, of course. > > > > There will also have to be a new argument to usb_stor_probe1() > > specifying whether the id->driver_info field is standard (i.e., it > > contains the flags directly) or is one of the new indirect index values. > > > > And you'll have to figure out a comparable change to the dynamic device > > ID table mechanism. > > > > (If you want to be really fancy about it, you could design things in > > such a way that the indirect flags approach is used only on 32-bit > > systems. 64-bit systems can put the new flag bits directly into the > > driver_info field. However, it's probably best not to worry about this > > initially.) > > Hi Alan, > > So, I really tried this approach, spent more time on in than I expected, but > produced working code... that I am really not proud of :-] > (Thus avoiding to send it here, for now.) > > I pushed it to my dm-cryptsetup branch here > https://git.kernel.org/pub/scm/linux/kernel/git/mbroz/linux.git/log/?h=dm-cryptsetup I haven't had a chance to look at your changes yet, and I might not get around to it for a while. > The last patch is the reason why I need it, just for reference. > More comments in the patch headers. > > Could you please check it if it is *really* what we want? > If so, I'll rebase it for usb next tree and send as a patchset. > > But the macro magic is crazy... and I really did not find the better way. Another possibility is to create a simple pre-processor program that would read the unusual_devs files and massage the information into the form the driver will want. Such a program could do things that the C preprocessor isn't capable of. For example, with this approach you could keep the original flag bits in positions 0 - 30, and reserve bit 31 as an indicator that there are additional flags stored in an "overflow" table entry. This extra table could be relatively short, since it would need to contain only a small number of entries. I can't think of any way to get the C preprocessor to do this, but it would be easy to have a separate program do it. > Anyway, it also uncovered some problems > - some macros need to be changed a little bit, there is even old one unused It doesn't hurt to have someone with fresh eyes taking a look at this. :-) > - duplicity of entries in UAS and mass-storage are strange (and complicates > the approach). > I guess the sorting is intentionally that mass-storage is included > before UAS, so the mass-storage quirk is found as the first (for non-UAS). > (While UAS drive includes only own header.) It's a little tricky because the two drivers need to be aware, to some extent, of which devices either prefer to use UAS or can't work with UAS. > - the patch significantly increases size of module for 32bit > (64bit system use the direct flag store approach) The "overflow table" approach would help a lot with this. > - I stored a pointer to the flags array, not the index. Perhaps it should be > index only (trivial change, though). Alan Stern