sys/dev/drm/i915/i915_drv.c
/* Allocate space for the MCH regs if needed, return nonzero on error */
Allocate space for the MCH regs if needed, return nonzero on error
Allocate space for the MCH regs if needed return nonzero on error
static int
intel_alloc_mchbar_resource(struct drm_device *dev)
{
	struct drm_i915_private *dev_priv = dev->dev_private;
	int reg = INTEL_INFO(dev)->gen >= 4 ? MCHBAR_I965 : MCHBAR_I915;
	u32 temp_lo, temp_hi = 0;
	u64 mchbar_addr;
	device_t vga;
	if (INTEL_INFO(dev)->gen >= 4)
		pci_read_config_dword(dev_priv->bridge_dev, reg + 4, &temp_hi);
	pci_read_config_dword(dev_priv->bridge_dev, reg, &temp_lo);
	mchbar_addr = ((u64)temp_hi << 32) | temp_lo;
#ifdef CONFIG_PNP
	if (mchbar_addr &&
	    pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE))
		return 0;
#endif
	vga = device_get_parent(dev->dev->bsddev);
	dev_priv->mch_res_rid = 0x100;
	dev_priv->mch_res = BUS_ALLOC_RESOURCE(device_get_parent(vga),
	    dev->dev->bsddev, SYS_RES_MEMORY, &dev_priv->mch_res_rid, 0, ~0UL,
	    MCHBAR_SIZE, RF_ACTIVE | RF_SHAREABLE, -1);
	if (dev_priv->mch_res == NULL) {
		DRM_ERROR("failed mchbar resource alloc\n");
		return (-ENOMEM);
	}
	if (INTEL_INFO(dev)->gen >= 4)
		pci_write_config_dword(dev_priv->bridge_dev, reg + 4,
				       upper_32_bits(rman_get_start(dev_priv->mch_res)));
	pci_write_config_dword(dev_priv->bridge_dev, reg,
			       lower_32_bits(rman_get_start(dev_priv->mch_res)));
	return 0;
}
static int intel_alloc_mchbar_resource ( struct drm_device * dev ) { struct drm_i915_private * dev_priv = dev -> dev_private ; int reg = INTEL_INFO ( dev ) -> gen >= 4 ? MCHBAR_I965 : MCHBAR_I915 ; u32 temp_lo , temp_hi = 0 ; u64 mchbar_addr ; device_t vga ; if ( INTEL_INFO ( dev ) -> gen >= 4 ) pci_read_config_dword ( dev_priv -> bridge_dev , reg + 4 , & temp_hi ) ; pci_read_config_dword ( dev_priv -> bridge_dev , reg , & temp_lo ) ; mchbar_addr = ( ( u64 ) temp_hi << 32 ) | temp_lo ; #ifdef CONFIG_PNP if ( mchbar_addr && pnp_range_reserved ( mchbar_addr , mchbar_addr + MCHBAR_SIZE ) ) return 0 ; #endif vga = device_get_parent ( dev -> dev -> bsddev ) ; dev_priv -> mch_res_rid = 0x100 ; dev_priv -> mch_res = BUS_ALLOC_RESOURCE ( device_get_parent ( vga ) , dev -> dev -> bsddev , SYS_RES_MEMORY , & dev_priv -> mch_res_rid , 0 , ~ 0UL , MCHBAR_SIZE , RF_ACTIVE | RF_SHAREABLE , -1 ) ; if ( dev_priv -> mch_res == NULL ) { DRM_ERROR ( " \n " ) ; return ( - ENOMEM ) ; } if ( INTEL_INFO ( dev ) -> gen >= 4 ) pci_write_config_dword ( dev_priv -> bridge_dev , reg + 4 , upper_32_bits ( rman_get_start ( dev_priv -> mch_res ) ) ) ; pci_write_config_dword ( dev_priv -> bridge_dev , reg , lower_32_bits ( rman_get_start ( dev_priv -> mch_res ) ) ) ; return 0 ; }
Allocate space for the MCH regs if needed, return nonzero on error
Allocate space for the MCH regs if needed return nonzero on error
/* If ACPI doesn't have it, assume we need to allocate it ourselves */ /* Get some space for it */