Linux-PCI Archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: 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: Wed, 13 May 2026 18:20:55 -0700	[thread overview]
Message-ID: <110e9a0d-bc91-4959-8a7b-1a055d0b49f7@roeck-us.net> (raw)
In-Reply-To: <20260514004055.1BBCAC19425@smtp.kernel.org>

On 5/13/26 17:40, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] The Kconfig dependency `depends on USB_XHCI_PCI=y` completely disables PROM21 support for systems where the core driver is built as a module.
> - [Low] Signed integer overflow when calculating the auxiliary device ID.
> --
> 
> commit 20f4e35b2f88ebe2b8988b4f07fe7cc28199096b
> Author: Jihong Min <hurryman2212@gmail.com>
> Subject: usb: xhci-pci: add AMD Promontory 21 PCI glue
> 
> This commit adds a small PCI glue driver for AMD Promontory 21 xHCI
> controllers. It binds the controllers, delegates USB host operation to
> the common xHCI PCI core, and creates an auxiliary device for optional
> temperature sensor support.
> 
>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> --- a/drivers/usb/host/Kconfig
>> +++ b/drivers/usb/host/Kconfig
> 
> [ ... ]
> 
>> @@ -42,6 +42,26 @@ config USB_XHCI_PCI
>>   	depends on USB_PCI
>>   	default y
>>   
>> +config USB_XHCI_PCI_PROM21
>> +	bool "AMD Promontory 21 xHCI PCI support"
>> +	depends on X86
>> +	depends on USB_XHCI_PCI=y
> 
> Does depending strictly on USB_XHCI_PCI=y cause a configuration regression
> for most distributions where the core driver is configured as a module?
> 
> The driver source appears fully capable of being built as a module, using
> module-related macros and module_pci_driver().
> 
> If the intent is to prevent an early boot mismatch where xhci-pci is
> built-in but the PROM21 glue is a module, could this instead be a tristate
> option using depends on USB_XHCI_PCI and depends on !(USB_XHCI_PCI=y && m)?
> This would enforce the boot constraint while preserving support for modular
> kernel builds.
> 

That makes sense to me. That would be stronger than using default (which
was my idea of dealing with the problem). Restricting the code to USB_XHCI_PCI=y
seems to be a bit extreme.

> [ ... ]
> 
>> diff --git a/drivers/usb/host/xhci-pci-prom21.c b/drivers/usb/host/xhci-pci-prom21.c
>> --- /dev/null
>> +++ b/drivers/usb/host/xhci-pci-prom21.c
> 
> [ ... ]
> 
>> +static int prom21_xhci_create_auxdev(struct pci_dev *pdev)
>> +{
>> +	struct prom21_xhci_auxdev *prom21_auxdev;
>> +	struct usb_hcd *hcd = pci_get_drvdata(pdev);
> 
> [ ... ]
> 
>> +	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


  reply	other threads:[~2026-05-14  1:20 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 [this message]
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
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=110e9a0d-bc91-4959-8a7b-1a055d0b49f7@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=hurryman2212@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --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).