Re: recent commits break via 8235 ata

From: John Baldwin <jhb_at_freebsd.org>
Date: Tue, 10 Apr 2007 19:16:59 -0400
On Friday 06 April 2007 18:22, Giorgos Keramidas wrote:
> On 2007-04-07 00:12, Giorgos Keramidas <keramida_at_freebsd.org> wrote:
> > On 2007-03-27 12:27, John Baldwin <jhb_at_freebsd.org> wrote:
> > > If that is the case it's because code was using
> > > rman_get_bus(handle|tag) on a resource that wasn't activated yet which
> > > wouldn't have worked before the nexus changes either.  Well, the bus
> > > tag might have been right, but the handle for SYS_RES_MEMORY would
> > > have been wrong.
> > 
> > This is the change which stops snd_hda from working here:
> > 
> > %   Revision  Changes    Path
> > %   1.233     +39 -55    src/sys/dev/acpica/acpi.c
> 
> There's only one place in the sound/pci/hda/* source tree where
> rman_get_bus(handle|tag)() calls are used:
> 
> keramida_at_kobe:/home/keramida/hg/freebsd/src/sys/dev/sound/pci/hda$ grep -n 'rman_get_bus\(handle\|tag\)' *
> hdac.c:1301:    mem->mem_tag = rman_get_bustag(mem->mem_res);
> hdac.c:1302:    mem->mem_handle = rman_get_bushandle(mem->mem_res);
> keramida_at_kobe:/home/keramida/hg/freebsd/src/sys/dev/sound/pci/hda$
> 
> [...]
> 
> 1281 /****************************************************************************
> 1282  * int hdac_mem_alloc(struct hdac_softc *)
> 1283  *
> 1284  * Allocate all the bus resources necessary to speak with the physical
> 1285  * controller.
> 1286  ****************************************************************************/
> 1287 static int
> 1288 hdac_mem_alloc(struct hdac_softc *sc)
> 1289 {
> 1290         struct hdac_mem *mem;
> 1291
> 1292         mem = &sc->mem;
> 1293         mem->mem_rid = PCIR_BAR(0);
> 1294         mem->mem_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY,
> 1295             &mem->mem_rid, RF_ACTIVE);
> 1296         if (mem->mem_res == NULL) {
> 1297                 device_printf(sc->dev,
> 1298                     "%s: Unable to allocate memory resource\n", __func__);
> 1299                 return (ENOMEM);
> 1300         }
> 1301         mem->mem_tag = rman_get_bustag(mem->mem_res);
> 1302         mem->mem_handle = rman_get_bushandle(mem->mem_res);
> 1303
> 1304         return (0);
> 1305 }
> 
> I'm not very familiar with the rman_get_xxx() functions, but is
> there a better way to write the hdac_mem_alloc() function so that
> it works with the recent acpi.c versions?

This is fine, you just have to use them after activating the resource
either via bus_activate_resource() or passing RF_ACTIVE to
bus_alloc_resource() which the above does.

-- 
John Baldwin
Received on Tue Apr 10 2007 - 21:22:21 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:08 UTC