atrtc Couldn't map I/O

From: Stephane Rochoy <stephane.rochoy_at_stormshield.eu>
Date: Fri, 27 Sep 2024 11:52:45 UTC
Hi Hackers,

I have a board running 14.1 with the following warning reported by
atrtc(4):

  atrtc0: Warning: Couldn't map I/O.

It seems to comes from atrtc_attach:

  sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, 
  &sc->port_rid,
      IO_RTC, IO_RTC + 1, 2, RF_ACTIVE);
  if (sc->port_res == NULL)
    device_printf(dev, "Warning: Couldn't map I/O.\n");

What puzzle me a bit is that:
- nobody seems to use sc->port_res
- and IO_RTC (0x70) is manipulated directly via outb/inb instead
  of bus_write/bus_read, thus ignoring the failure of
  bus_alloc_resource.

But what puzzle me more is that bootverbose show that ACPI expose
an I/O port range (type 4) containing 0x70:

  pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
  pcib0: decoding 5 range 0-0xfe
  pcib0: decoding 4 range 0-0xcf7
  pcib0: decoding 4 range 0xd00-0xffff
  pcib0: decoding 3 range 0xa0000-0xbffff
  pcib0: decoding 3 range 0xe0000-0xe3fff
  pcib0: decoding 3 range 0xe4000-0xe7fff
  pcib0: decoding 3 range 0xe8000-0xebfff
  pcib0: decoding 3 range 0xec000-0xeffff
  pcib0: decoding 3 range 0xf0000-0xfffff
  pcib0: decoding 3 range 0x80000000-0xbfffffff
  pcib0: decoding 3 range 0x4000000000-0x7fffffffff

and nobody reclaim it:

  pcib0: allocated type 4 (0xefa0-0xefbf) for rid 20 of 
  pci0:0:31:4
  pcib0: allocated type 4 (0x2e-0x2f) for rid 0 of superio0
  pcib0: allocated type 4 (0x4e-0x4f) for rid 0 of superio1
  pcib0: allocated type 4 (0x2e-0x2f) for rid 0 of superio0
  pcib0: allocated type 4 (0x60-0x60) for rid 0 of atkbdc0
  pcib0: allocated type 4 (0x64-0x64) for rid 1 of atkbdc0

So what could explain bus_alloc_resource's failure then? And can
it be a real problem as atrtc stubbornly use the port.

Regards,
-- 
Stéphane Rochoy
O: Stormshield