Lines Matching +full:fw +full:- +full:cfg +full:- +full:mmio

2  * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
58 struct intel_gvt_device_info *info = &gvt->device_info; in expose_firmware_sysfs()
59 struct drm_i915_private *i915 = gvt->gt->i915; in expose_firmware_sysfs()
60 struct pci_dev *pdev = to_pci_dev(i915->drm.dev); in expose_firmware_sysfs()
67 size = offsetof(struct gvt_firmware_header, data) + info->mmio_size + info->cfg_space_size; in expose_firmware_sysfs()
70 return -ENOMEM; in expose_firmware_sysfs()
74 h->magic = VGT_MAGIC; in expose_firmware_sysfs()
75 h->version = FIRMWARE_VERSION; in expose_firmware_sysfs()
76 h->cfg_space_size = info->cfg_space_size; in expose_firmware_sysfs()
77 h->cfg_space_offset = offsetof(struct gvt_firmware_header, data); in expose_firmware_sysfs()
78 h->mmio_size = info->mmio_size; in expose_firmware_sysfs()
79 h->mmio_offset = h->cfg_space_offset + h->cfg_space_size; in expose_firmware_sysfs()
81 p = firmware + h->cfg_space_offset; in expose_firmware_sysfs()
83 memcpy(gvt->firmware.cfg_space, i915->vgpu.initial_cfg_space, in expose_firmware_sysfs()
84 info->cfg_space_size); in expose_firmware_sysfs()
85 memcpy(p, gvt->firmware.cfg_space, info->cfg_space_size); in expose_firmware_sysfs()
87 p = firmware + h->mmio_offset; in expose_firmware_sysfs()
89 memcpy(gvt->firmware.mmio, i915->vgpu.initial_mmio, in expose_firmware_sysfs()
90 info->mmio_size); in expose_firmware_sysfs()
92 memcpy(p, gvt->firmware.mmio, info->mmio_size); in expose_firmware_sysfs()
95 h->crc32 = crc32_le(0, firmware + crc32_start, size - crc32_start); in expose_firmware_sysfs()
100 ret = device_create_bin_file(&pdev->dev, &bin_attr_gvt_firmware); in expose_firmware_sysfs()
110 struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); in clean_firmware_sysfs()
112 device_remove_bin_file(&pdev->dev, &bin_attr_gvt_firmware); in clean_firmware_sysfs()
117 * intel_gvt_free_firmware - free GVT firmware
123 if (!gvt->firmware.firmware_loaded) in intel_gvt_free_firmware()
126 kfree(gvt->firmware.cfg_space); in intel_gvt_free_firmware()
127 vfree(gvt->firmware.mmio); in intel_gvt_free_firmware()
131 const struct firmware *fw) in verify_firmware() argument
133 struct intel_gvt_device_info *info = &gvt->device_info; in verify_firmware()
134 struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); in verify_firmware()
141 h = (struct gvt_firmware_header *)fw->data; in verify_firmware()
144 mem = fw->data + crc32_start; in verify_firmware()
152 VERIFY("magic number", h->magic, VGT_MAGIC); in verify_firmware()
153 VERIFY("version", h->version, FIRMWARE_VERSION); in verify_firmware()
154 VERIFY("crc32", h->crc32, crc32_le(0, mem, fw->size - crc32_start)); in verify_firmware()
155 VERIFY("cfg space size", h->cfg_space_size, info->cfg_space_size); in verify_firmware()
156 VERIFY("mmio size", h->mmio_size, info->mmio_size); in verify_firmware()
158 mem = (fw->data + h->cfg_space_offset); in verify_firmware()
161 VERIFY("vendor id", id, pdev->vendor); in verify_firmware()
164 VERIFY("device id", id, pdev->device); in verify_firmware()
167 VERIFY("revision id", id, pdev->revision); in verify_firmware()
175 return -EINVAL; in verify_firmware()
181 * intel_gvt_load_firmware - load GVT firmware
187 struct intel_gvt_device_info *info = &gvt->device_info; in intel_gvt_load_firmware()
188 struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); in intel_gvt_load_firmware()
189 struct intel_gvt_firmware *firmware = &gvt->firmware; in intel_gvt_load_firmware()
191 const struct firmware *fw; in intel_gvt_load_firmware() local
198 return -ENOMEM; in intel_gvt_load_firmware()
200 mem = kmalloc(info->cfg_space_size, GFP_KERNEL); in intel_gvt_load_firmware()
203 return -ENOMEM; in intel_gvt_load_firmware()
206 firmware->cfg_space = mem; in intel_gvt_load_firmware()
208 mem = vmalloc(info->mmio_size); in intel_gvt_load_firmware()
211 kfree(firmware->cfg_space); in intel_gvt_load_firmware()
212 return -ENOMEM; in intel_gvt_load_firmware()
215 firmware->mmio = mem; in intel_gvt_load_firmware()
218 GVT_FIRMWARE_PATH, pdev->vendor, pdev->device, in intel_gvt_load_firmware()
219 pdev->revision); in intel_gvt_load_firmware()
223 ret = request_firmware(&fw, path, gvt->gt->i915->drm.dev); in intel_gvt_load_firmware()
231 ret = verify_firmware(gvt, fw); in intel_gvt_load_firmware()
237 h = (struct gvt_firmware_header *)fw->data; in intel_gvt_load_firmware()
239 memcpy(firmware->cfg_space, fw->data + h->cfg_space_offset, in intel_gvt_load_firmware()
240 h->cfg_space_size); in intel_gvt_load_firmware()
241 memcpy(firmware->mmio, fw->data + h->mmio_offset, in intel_gvt_load_firmware()
242 h->mmio_size); in intel_gvt_load_firmware()
244 release_firmware(fw); in intel_gvt_load_firmware()
245 firmware->firmware_loaded = true; in intel_gvt_load_firmware()
249 release_firmware(fw); in intel_gvt_load_firmware()