Commit 8d7a5b5d authored by Dave Jones's avatar Dave Jones

[AGPGART] Mask out the reserved bits of the agp mode register before handing them to userspace.

X munges what we hand to it, so with luck, this will lower the possibility
of it handing us something with reserved bits set.
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 1b13cadf
...@@ -289,6 +289,19 @@ int agp_num_entries(void) ...@@ -289,6 +289,19 @@ int agp_num_entries(void)
EXPORT_SYMBOL_GPL(agp_num_entries); EXPORT_SYMBOL_GPL(agp_num_entries);
static int check_bridge_mode(struct pci_dev *dev)
{
u32 agp3;
u8 cap_ptr;
cap_ptr = pci_find_capability(dev, PCI_CAP_ID_AGP);
pci_read_config_dword(dev, cap_ptr+AGPSTAT, &agp3);
if (agp3 & AGPSTAT_MODE_3_0)
return 1;
return 0;
}
/** /**
* agp_copy_info - copy bridge state information * agp_copy_info - copy bridge state information
* *
...@@ -310,7 +323,10 @@ int agp_copy_info(struct agp_kern_info *info) ...@@ -310,7 +323,10 @@ int agp_copy_info(struct agp_kern_info *info)
info->version.minor = agp_bridge->version->minor; info->version.minor = agp_bridge->version->minor;
info->chipset = agp_bridge->type; info->chipset = agp_bridge->type;
info->device = agp_bridge->dev; info->device = agp_bridge->dev;
info->mode = agp_bridge->mode; if (check_bridge_mode(agp_bridge->dev))
info->mode = agp_bridge->mode & AGP3_RESERVED_MASK;
else
info->mode = agp_bridge->mode & AGP2_RESERVED_MASK;
info->aper_base = agp_bridge->gart_bus_addr; info->aper_base = agp_bridge->gart_bus_addr;
info->aper_size = agp_return_size(); info->aper_size = agp_return_size();
info->max_memory = agp_bridge->max_memory_agp; info->max_memory = agp_bridge->max_memory_agp;
...@@ -590,19 +606,6 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ ...@@ -590,19 +606,6 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_
} }
static int check_bridge_mode(struct pci_dev *dev)
{
u32 agp3;
u8 cap_ptr;
cap_ptr = pci_find_capability(dev, PCI_CAP_ID_AGP);
pci_read_config_dword(dev, cap_ptr+AGPSTAT, &agp3);
if (agp3 & AGPSTAT_MODE_3_0)
return 1;
return 0;
}
/** /**
* agp_collect_device_status - determine correct agp_cmd from various agp_stat's * agp_collect_device_status - determine correct agp_cmd from various agp_stat's
* @bridge: an agp_bridge_data struct allocated for the AGP host bridge. * @bridge: an agp_bridge_data struct allocated for the AGP host bridge.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment