public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Christian Eggers <ceggers@arri.de>
To: <linux-bluetooth@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: struct hci_dev::quirks is running out of bits on 32-bit platforms
Date: Mon, 14 Jul 2025 19:09:10 +0200	[thread overview]
Message-ID: <22185131.4csPzL39Zc@n9w6sw14> (raw)

I just tried to introduce another quirk for Realtek Bluetooth controllers 
when I recognized that the underlying data type (unsigned long) has already
run out available bits on system where sizeof(unsigned long) == 4.
The number of entries in the (anonymous) quirks enum has already reached 34 
in the latest kernels.

My first temptation was to simply change the data type to something like __u64,
but this is not as easy as it seems. The test_bit() macro used almost everywhere
for assigning quirks is guaranteed to be atomic and my platform (ARMv7) seems
not to have support for atomic operations on __u64.

I mainly see two options:

1. Introducing a 'quirks2' member (bad)

This obviously would work, but requires another enum and will (I think)
introduce stupid bugs if the wrong quirks member is exercised.

2. Switch to using __64 with non atomic operations

About 99% of write accesses to the quirks member happen from probe() or
setup() routines which should (I hope) not allow simultaneous access from other
contexts. I found 2 exceptions (as of linux-6.12):

a. btusb_setup_qca() is called from 'struct hci_dev::open()' (maybe uncritical).
b. Two quirks (strict_duplicate_filter, simultaneous_discovery) can be toggled 
   via debugfs.

So it looks like using non atomic operations can also introduce trouble if
not well reviewed. But as the 'strict_duplicate_filter' and 
'simultaneous_discovery' quirks are only used at very few locations, maybe
these should be moved to a new member for "atomic quirks", allowing to
convert the remaining ones to non atomic.


Are there any alternatives? Anything I missed?

regards,
Christian




             reply	other threads:[~2025-07-14 17:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14 17:09 Christian Eggers [this message]
2025-07-14 18:02 ` struct hci_dev::quirks is running out of bits on 32-bit platforms Pauli Virtanen
2025-07-14 18:19   ` Luiz Augusto von Dentz

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=22185131.4csPzL39Zc@n9w6sw14 \
    --to=ceggers@arri.de \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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