Subject: Re: autri0: can't map memory space
To: Andreas Gustafsson <gson@gson.org>
From: Jared D. McNeill <jmcneill@invisible.ca>
List: current-users
Date: 01/25/2008 07:20:56
This is a multi-part message in MIME format.
--------------080306010405080306050609
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Andreas Gustafsson wrote:
> To follow up on my own message from last month about the following
> error appearing after upgrading from 4.99.26 to 4.99.42:
> 
>>   autri0 at pci0 dev 6 function 0: Acer Labs M5451 AC-Link Controller Audio Device (rev. 0x01)
>>   autri0: can't map memory space
> 
> I figured out the problem.  The 4.99.26 kernel configuration was based
> on GENERIC_LAPTOP, but since that was removed from the tree, I had
> based the 4.99.42 configuration on GENERIC.  One of the differences
> between GENERIC_LAPTOP and GENERIC is that GENERIC_LAPTOP defined
> PCI_ADDR_FIXUP and GENERIC doesn't.
> 
> The PCI Command register for the autri0 device is initially 0x0000;
> the PCI_ADDR_FIXUP code (when enabled) changes it to 0x0007 and makes
> the attach succeed.

There's no reason that the autri driver cannot modify this register 
itself. Can you try the attached patch with a GENERIC kernel and no 
PCI_*_FIXUP options?

Cheers,
Jared

--------------080306010405080306050609
Content-Type: text/x-patch;
 name="autri.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="autri.patch"

Index: autri.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/autri.c,v
retrieving revision 1.36
diff -u -r1.36 autri.c
--- autri.c	9 Dec 2007 20:28:06 -0000	1.36
+++ autri.c	25 Jan 2008 12:21:22 -0000
@@ -517,21 +517,29 @@
 	struct autri_softc *sc;
 	struct pci_attach_args *pa;
 	pci_chipset_tag_t pc;
+	pcitag_t tag;
 	struct autri_codec_softc *codec;
 	pci_intr_handle_t ih;
 	char const *intrstr;
 	char devinfo[256];
+	pcireg_t csr;
 	int r;
 	uint32_t reg;
 
 	sc = (struct autri_softc *)self;
 	pa = (struct pci_attach_args *)aux;
 	pc = pa->pa_pc;
+	tag = pa->pa_tag;
 	aprint_naive(": Audio controller\n");
 
 	sc->sc_devid = pa->pa_id;
 	sc->sc_class = pa->pa_class;
 
+	csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
+	csr |= (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE |
+	    PCI_COMMAND_MASTER_ENABLE);
+	pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr);
+
 	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
 	sc->sc_revision = PCI_REVISION(pa->pa_class);
 	aprint_normal(": %s (rev. 0x%02x)\n", devinfo, sc->sc_revision);

--------------080306010405080306050609--