From: Jihong Min <hurryman2212@icloud.com>
To: Guenter Roeck <linux@roeck-us.net>,
sashiko-reviews@lists.linux.dev,
Jihong Min <hurryman2212@gmail.com>
Cc: linux-hwmon@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v5 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue
Date: Thu, 14 May 2026 23:29:36 +0900 [thread overview]
Message-ID: <1173f5c5-a740-4458-8e08-2c427a704207@icloud.com> (raw)
In-Reply-To: <110e9a0d-bc91-4959-8a7b-1a055d0b49f7@roeck-us.net>
On 5/14/26 10:20, Guenter Roeck wrote:
>>> + prom21_auxdev->auxdev =
>>> + auxiliary_device_create(&pdev->dev, KBUILD_MODNAME, "hwmon",
>>> + &prom21_auxdev->pdata,
>>> + (pci_domain_nr(pdev->bus) << 16) |
>>> + pci_dev_id(pdev));
>>
>> Does left-shifting pci_domain_nr() introduce a signed integer overflow
>> regression?
>>
>> The function pci_domain_nr() returns a signed int, which can be up to
>> 0xFFFF
>> on ACPI systems. Left-shifting a value of 0x8000 or greater by 16 bits
>> alters the sign bit of a 32-bit int, resulting in undefined behavior
>> in C.
>>
>> Would casting the return value to an unsigned integer, such as
>> (u32)pci_domain_nr(pdev->bus) << 16, avoid this overflow?
>>
> FWIW, I don't think that is a real problem. auxiliary_device_create()
> takes an int as id parameter, so the result would be converted back to
> int
> anyway. Maybe use "(pci_domain_nr(pdev->bus) & 0x7fff) << 16" instead,
> but I don't know if that adds any practical value.
>
> Thanks,
> Guenter
>
For the auxiliary device id issue, after thinking about it a bit more, I
think
a simpler approach is to avoid encoding the PCI domain/BDF into the
auxiliary
id. The auxiliary id only needs to make the auxiliary device name unique;
userspace identification is already tied to the parent PCI function.
So instead of:
(pci_domain_nr(pdev->bus) << 16) | pci_dev_id(pdev)
I plan to use an IDA-allocated id:
id = ida_alloc(&prom21_xhci_auxdev_ida, GFP_KERNEL);
auxiliary_device_create(..., id);
ida_free(&prom21_xhci_auxdev_ida, id);
This avoids both the signed shift concern and PCI domain
truncation/masking.
next prev parent reply other threads:[~2026-05-14 14:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 21:39 [PATCH v5 0/2] AMD Promontory 21 xHCI temperature sensor support Jihong Min
2026-05-12 21:39 ` [PATCH v5 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue Jihong Min
2026-05-14 0:40 ` sashiko-bot
2026-05-14 1:20 ` Guenter Roeck
2026-05-14 13:38 ` Jihong Min
2026-05-14 13:44 ` Jihong Min
2026-05-15 1:49 ` Guenter Roeck
2026-05-14 14:29 ` Jihong Min [this message]
2026-05-14 19:22 ` Guenter Roeck
2026-05-12 21:39 ` [PATCH v5 2/2] hwmon: add AMD Promontory 21 xHCI temperature sensor support Jihong Min
2026-05-14 1:00 ` sashiko-bot
2026-05-14 1:13 ` Guenter Roeck
2026-05-12 21:49 ` [PATCH v5 0/2] " Jihong Min
2026-05-13 14:48 ` Mario Limonciello
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=1173f5c5-a740-4458-8e08-2c427a704207@icloud.com \
--to=hurryman2212@icloud.com \
--cc=hurryman2212@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=sashiko-reviews@lists.linux.dev \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).