/* * PCI Backend - Handle special overlays for broken devices. * * Author: Ryan Wilson * Author: Chris Bookholt */ #include #include #include "pciback.h" #include "conf_space.h" #include "conf_space_quirks.h" LIST_HEAD(xen_pcibk_quirks); static inline const struct pci_device_id * match_one_device(const struct pci_device_id *id, const struct pci_dev *dev) { if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) && (id->device == PCI_ANY_ID || id->device == dev->device) && (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) && (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) && !((id->class ^ dev->class) & id->class_mask)) return id; return NULL; } static struct xen_pcibk_config_quirk *xen_pcibk_find_quirk(struct pci_dev *dev) { struct xen_pcibk_config_quirk *tmp_quirk; list_for_each_entry(tmp_quirk, &xen_pcibk_quirks, quirks_list) if (match_one_device(&tmp_quirk->devid, dev) != NULL) goto out; tmp_quirk = NULL; printk(KERN_DEBUG DRV_NAME ": quirk didn't match any device known\n"); out: return tmp_quirk; } static inline void register_quirk(struct xen_pcibk_config_quirk *quirk) { list_add_tail(&quirk->quirks_list, &xen_pcibk_quirks); } int xen_pcibk_field_is_dup(struct pci_dev *dev, unsigned int reg) { int ret = 0; struct xen_pcibk_dev_data *dev_data = pci_get_drvdata(dev); struct config_field_entry *cfg_entry; list_for_each_entry(cfg_entry, &dev_data->config_fields, list) { if (OFFSET(cfg_entry) == reg) { ret = 1; break; } } return ret; } int xen_pcibk_config_quirks_add_field(struct pci_dev *dev, struct config_field *field) { int err = 0; switch (field->size) { case 1: field->u.b.read = xen_pcibk_read_config_byte; field->u.b.write = xen_pcibk_write_config_byte; break; case 2: field->u.w.read = xen_pcibk_read_config_word; field->u.w.write = xen_pcibk_write_config_word; break; case 4: field->u.dw.read = xen_pcibk_read_config_dword; field->u.dw.write = xen_pcibk_write_config_dword; break; default: err = -EINVAL; goto out; } xen_pcibk_config_add_field(dev, field); out: return err; } int xen_pcibk_config_quirks_init(struct pci_dev *dev) { struct xen_pcibk_config_quirk *quirk; int ret = 0; quirk = kzalloc(sizeof(*quirk), GFP_ATOMIC); if (!quirk) { ret = -ENOMEM; goto out; } quirk->devid.vendor = dev->vendor; quirk->devid.device = dev->device; quirk->devid.subvendor = dev->subsystem_vendor; quirk->devid.subdevice = dev->subsystem_device; quirk->devid.class = 0; quirk->devid.class_mask = 0; quirk->devid.driver_data = 0UL; quirk->pdev = dev; register_quirk(quirk); out: return ret; } void xen_pcibk_config_field_free(struct config_field *field) { kfree(field); } int xen_pcibk_config_quirk_release(struct pci_dev *dev) { struct xen_pcibk_config_quirk *quirk; int ret = 0; quirk = xen_pcibk_find_quirk(dev); if (!quirk) { ret = -ENXIO; goto out; } list_del(&quirk->quirks_list); kfree(quirk); out: return ret; } cgi/linux/net-next.git/commit/sound/aoa/soundbus/core.c?id=c8f325a59cfc718d13a50fbc746ed9b415c25e92'>core.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2017-02-01 17:45:02 +0000
committerIngo Molnar <mingo@kernel.org>2017-02-01 21:17:49 +0100
commitc8f325a59cfc718d13a50fbc746ed9b415c25e92 (patch)
treed53fbdac9d0781e39a13b2ac6b2bd258cf3b4140 /sound/aoa/soundbus/core.c
parentbf29bddf0417a4783da3b24e8c9e017ac649326f (diff)
efi/fdt: Avoid FDT manipulation after ExitBootServices()
Some AArch64 UEFI implementations disable the MMU in ExitBootServices(), after which unaligned accesses to RAM are no longer supported. Commit: abfb7b686a3e ("efi/libstub/arm*: Pass latest memory map to the kernel") fixed an issue in the memory map handling of the stub FDT code, but inadvertently created an issue with such firmware, by moving some of the FDT manipulation to after the invocation of ExitBootServices(). Given that the stub's libfdt implementation uses the ordinary, accelerated string functions, which rely on hardware handling of unaligned accesses, manipulating the FDT with the MMU off may result in alignment faults. So fix the situation by moving the update_fdt_memmap() call into the callback function invoked by efi_exit_boot_services() right before it calls the ExitBootServices() UEFI service (which is arguably a better place for it anyway) Note that disabling the MMU in ExitBootServices() is not compliant with the UEFI spec, and carries great risk due to the fact that switching from cached to uncached memory accesses halfway through compiler generated code (i.e., involving a stack) can never be done in a way that is architecturally safe. Fixes: abfb7b686a3e ("efi/libstub/arm*: Pass latest memory map to the kernel") Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Riku Voipio <riku.voipio@linaro.org> Cc: <stable@vger.kernel.org> Cc: mark.rutland@arm.com Cc: linux-efi@vger.kernel.org Cc: matt@codeblueprint.co.uk Cc: leif.lindholm@linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1485971102-23330-2-git-send-email-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'sound/aoa/soundbus/core.c')