From: Milan Broz <gmazyland@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net,
linux-scsi@vger.kernel.org, gregkh@linuxfoundation.org,
oneukum@suse.com
Subject: Re: [PATCH v4] usb-storage,uas: use host helper to generate driver info
Date: Mon, 30 Oct 2023 19:16:27 +0100 [thread overview]
Message-ID: <db9dbd1f-2d49-4d31-9214-a4a2437f0fc7@gmail.com> (raw)
In-Reply-To: <f6b275d9-eeeb-47ee-bc0e-3fd491e62791@rowland.harvard.edu>
On 10/30/23 18:40, Alan Stern wrote:
> On Sat, Oct 28, 2023 at 07:41:45PM +0200, Milan Broz wrote:
>> The USB mass storage quirks flags can be stored in driver_info in
>> a 32-bit integer (unsigned long on 32-bit platforms).
>> As this attribute cannot be enlarged, we need to use some form
>> of translation of 64-bit quirk bits.
>>
>> This problem was discussed on the USB list
>> https://lore.kernel.org/linux-usb/f9e8acb5-32d5-4a30-859f-d4336a86b31a@gmail.com/
>>
>> The initial solution to use a static array extensively increased the size
>> of the kernel module, so I decided to try the second suggested solution:
>> generate a table by host-compiled program and use bit 31 to indicate
>> that the value is an index, not the actual value.
>>
>> This patch adds a host-compiled program that processes unusual_devs.h
>> (and unusual_uas.h) and generates files usb-ids.c and usb-ids-uas.c
>> (for pre-processed USB device table with 32-bit device info).
>> These files also contain a generated translation table for driver_info
>> to 64-bit values.
>>
>> The translation function is used only in usb-storage and uas modules; all
>> other USB storage modules store flags directly, using only 32-bit flags.
>>
>> For 64-bit platforms, where unsigned long is 64-bit, we do not need to
>> convert quirk flags to 32-bit index; the translation function there uses
>> flags directly.
>>
>> Signed-off-by: Milan Broz <gmazyland@gmail.com>
>> ---
>
>> diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
>> index 46635fa4a340..b8c5daeb8ff3 100644
>> --- a/drivers/usb/storage/Makefile
>> +++ b/drivers/usb/storage/Makefile
>> @@ -45,3 +45,34 @@ ums-realtek-y := realtek_cr.o
>> ums-sddr09-y := sddr09.o
>> ums-sddr55-y := sddr55.o
>> ums-usbat-y := shuttle_usbat.o
>> +
>> +# The mkflags host-compiled generator produces usb-ids.c (usb-storage)
>> +# and usb-ids-uas.c (uas) with USB device tables.
>> +# These tables include pre-computed 32-bit values, as USB driver_info
>> +# (where the value is stored) can be only 32-bit.
>> +# The most significant bit means it is index to 64-bit pre-computed table
>> +# generated by mkflags host-compiled program.
>> +# Currently used only by mass-storage and uas driver.
>> +
>> +$(obj)/usual-tables.o: $(obj)/usb-ids.c
>> +$(obj)/uas.o: $(obj)/usb-ids-uas.c
>
> Quick test: After those two lines were commented out from the Makefile,
> the compiler still knew to rebuild unusual-tables.o and uas.o when
> usb-ids.c and usb-ids-uas.c were changed. So these lines aren't needed.
ok, thx, this is perhaps relict of some previous try (I tried different
approaches) - will remove it.
> Apart from this, I tried running the patch through checkpatch.pl, and it
> flagged a bunch of issues. Some of them were false positives, but
> others really should be changed to match the kernel's style:
>
> The SPDX license line in .c files is supposed to be a
> C++-style comment, i.e., use // instead of /* ... */.
Perhaps just copied from header file, it is different format there.
(And my bad, I forget to run checkpatch after many last changes...)
>
> We aren't supposed to add new typedefs. Instead of writing:
>
> typedef enum {...} dev_type;
>
> write:
>
> enum dev_type {...};
>
> and the same for dev_flags_set.
>
> checkpatch would like the FLAGS_END macro value to be enclosed
> in parentheses, since it's a complex expression. Same for the
> HI32 macro. These don't really matter, but you may as well do
> it just to get rid of the warnings.
>
> Quoted strings (line 117 in mkflags.c) aren't supposed to be
> broken across lines. It should just be one very long line.
>
> Contrariwise, some other lines are longer than checkpatch likes
> to see (its maximum is 100 columns). They should be wrapped.
>
> These issues ought to be fixed. But it's all stylistic stuff; I don't
> see any actual errors or things to improve in the patch.
ok, I'll send next version once I have time to do it.
Thanks,
Milan
next prev parent reply other threads:[~2023-10-30 18:16 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 12:54 [RFC PATCH 0/6] usb-storage,uas,scsi: Support OPAL commands on USB attached devices Milan Broz
2023-10-06 12:54 ` [RFC PATCH 1/6] usb-storage: remove UNUSUAL_VENDOR_INTF macro Milan Broz
2023-10-06 17:16 ` Alan Stern
2023-10-08 10:28 ` Milan Broz
2023-10-06 12:54 ` [RFC PATCH 2/6] usb-storage: make internal quirks flags 64bit Milan Broz
2023-10-06 17:26 ` Alan Stern
2023-10-06 12:54 ` [RFC PATCH 3/6] usb-storage: use fflags index only in usb-storage driver Milan Broz
2023-10-06 17:35 ` Alan Stern
2023-10-06 12:54 ` [RFC PATCH 4/6] usb-storage,uas: use host helper to generate driver info Milan Broz
2023-10-06 18:44 ` Alan Stern
2023-10-08 10:41 ` Milan Broz
2023-10-08 13:15 ` Alan Stern
2023-10-06 12:54 ` [RFC PATCH 5/6] usb-storage,uas,scsi: allow to pass through security commands (OPAL) Milan Broz
2023-10-06 18:53 ` Alan Stern
2023-10-06 12:54 ` [RFC PATCH 6/6] usb-storage,uas: Disable security commands (OPAL) for RT9210 chip family Milan Broz
2023-10-06 18:57 ` Alan Stern
2023-10-08 10:54 ` Milan Broz
2023-10-16 7:25 ` [PATCH 0/7] usb-storage,uas: Support OPAL commands on USB attached devices Milan Broz
2023-10-16 7:25 ` [PATCH 1/7] usb-storage: remove UNUSUAL_VENDOR_INTF macro Milan Broz
2023-10-16 7:25 ` [PATCH 2/7] usb-storage,uas: make internal quirks flags 64bit Milan Broz
2023-10-21 10:19 ` Greg KH
2023-10-16 7:26 ` [PATCH 3/7] usb-storage: use fflags index only in usb-storage driver Milan Broz
2023-10-21 10:21 ` Greg KH
2023-10-26 10:27 ` Milan Broz
2023-10-16 7:26 ` [PATCH 4/7] usb-storage,uas: use host helper to generate driver info Milan Broz
2023-10-16 18:49 ` Alan Stern
2023-10-26 10:24 ` Milan Broz
2023-10-26 10:16 ` [PATCH v3] " Milan Broz
2023-10-27 15:45 ` Alan Stern
2023-10-28 17:41 ` [PATCH v4] " Milan Broz
2023-10-30 17:40 ` Alan Stern
2023-10-30 18:16 ` Milan Broz [this message]
2023-11-03 20:17 ` [PATCH v5] " Milan Broz
2023-11-03 20:30 ` Alan Stern
2023-11-04 8:01 ` Milan Broz
2023-11-04 14:12 ` Alan Stern
2023-11-05 18:20 ` [PATCH v6] " Milan Broz
2024-01-28 1:50 ` Greg KH
2024-01-29 12:15 ` Milan Broz
2023-10-16 7:26 ` [PATCH 5/7] usb-storage,uas: do not convert device_info for 64-bit platforms Milan Broz
2023-10-21 10:21 ` Greg KH
2023-10-21 10:22 ` Greg KH
2023-10-16 7:26 ` [PATCH 6/7] usb-storage,uas: enable security commands for USB-attached storage Milan Broz
2023-10-16 7:26 ` [PATCH 7/7] usb-storage,uas: disable security commands (OPAL) for RT9210 chip family Milan Broz
2023-10-16 17:33 ` [PATCH 0/7] usb-storage,uas: Support OPAL commands on USB attached devices Alan Stern
2023-10-16 17:48 ` Milan Broz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db9dbd1f-2d49-4d31-9214-a4a2437f0fc7@gmail.com \
--to=gmazyland@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).