Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Mar 2009 09:04:38 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Warner Losh <imp@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r189619 - head/sys/dev/cardbus
Message-ID:  <200903100904.38679.jhb@freebsd.org>
In-Reply-To: <200903101210.n2ACApQ0061838@svn.freebsd.org>
References:  <200903101210.n2ACApQ0061838@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 10 March 2009 8:10:50 am Warner Losh wrote:
> Author: imp
> Date: Tue Mar 10 12:10:50 2009
> New Revision: 189619
> URL: http://svn.freebsd.org/changeset/base/189619
> 
> Log:
>   When freeing all the resources of the card, it is better to turn off
>   the PORTEN and MEMEN bits in the command register than to zero the
>   bars.
>   
> Modified:
>   head/sys/dev/cardbus/cardbus.c
> 
> Modified: head/sys/dev/cardbus/cardbus.c
> 
==============================================================================
> --- head/sys/dev/cardbus/cardbus.c	Tue Mar 10 11:46:41 2009	(r189618)
> +++ head/sys/dev/cardbus/cardbus.c	Tue Mar 10 12:10:50 2009	(r189619)
> @@ -287,6 +289,7 @@ static void
>  cardbus_release_all_resources(device_t cbdev, struct cardbus_devinfo 
*dinfo)
>  {
>  	struct resource_list_entry *rle;
> +	device_t dev;
>  
>  	/* Free all allocated resources */
>  	STAILQ_FOREACH(rle, &dinfo->pci.resources, link) {
> @@ -294,15 +297,14 @@ cardbus_release_all_resources(device_t c
>  			BUS_RELEASE_RESOURCE(device_get_parent(cbdev),
>  			    cbdev, rle->type, rle->rid, rle->res);
>  			rle->res = NULL;
> -			/*
> -			 * zero out config so the card won't acknowledge
> -			 * access to the space anymore. XXX doesn't handle
> -			 * 64-bit bars.
> -			 */
> -			pci_write_config(dinfo->pci.cfg.dev, rle->rid, 0, 4);
>  		}
>  	}
>  	resource_list_free(&dinfo->pci.resources);
> +	/* turn off the card's decoding now that the resources are done */
> +	dev = dinfo->pci.cfg.dev;
> +	pci_write_config(dev, PCIR_COMMAND,
> +	    pci_read_config(dev, PCIR_COMMAND, 2) &
> +	    ~(PCIM_CMD_MEMEN | PCIM_CMD_PORTEN), 2);
>  }

It might be best to do this before releasing the resources rather than 
afterwards.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903100904.38679.jhb>