Lines Matching +full:fw +full:- +full:cfg +full:- +full:mmio
2 * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
58 memcpy(buf, attr->private + offset, count); in gvt_firmware_read()
71 struct intel_gvt_device_info *info = &gvt->device_info; in expose_firmware_sysfs()
72 struct drm_i915_private *i915 = gvt->gt->i915; in expose_firmware_sysfs()
73 struct pci_dev *pdev = to_pci_dev(i915->drm.dev); in expose_firmware_sysfs()
80 size = sizeof(*h) + info->mmio_size + info->cfg_space_size; in expose_firmware_sysfs()
83 return -ENOMEM; in expose_firmware_sysfs()
87 h->magic = VGT_MAGIC; in expose_firmware_sysfs()
88 h->version = FIRMWARE_VERSION; in expose_firmware_sysfs()
89 h->cfg_space_size = info->cfg_space_size; in expose_firmware_sysfs()
90 h->cfg_space_offset = offsetof(struct gvt_firmware_header, data); in expose_firmware_sysfs()
91 h->mmio_size = info->mmio_size; in expose_firmware_sysfs()
92 h->mmio_offset = h->cfg_space_offset + h->cfg_space_size; in expose_firmware_sysfs()
94 p = firmware + h->cfg_space_offset; in expose_firmware_sysfs()
96 memcpy(gvt->firmware.cfg_space, i915->vgpu.initial_cfg_space, in expose_firmware_sysfs()
97 info->cfg_space_size); in expose_firmware_sysfs()
98 memcpy(p, gvt->firmware.cfg_space, info->cfg_space_size); in expose_firmware_sysfs()
100 p = firmware + h->mmio_offset; in expose_firmware_sysfs()
102 memcpy(gvt->firmware.mmio, i915->vgpu.initial_mmio, in expose_firmware_sysfs()
103 info->mmio_size); in expose_firmware_sysfs()
105 memcpy(p, gvt->firmware.mmio, info->mmio_size); in expose_firmware_sysfs()
108 h->crc32 = crc32_le(0, firmware + crc32_start, size - crc32_start); in expose_firmware_sysfs()
113 ret = device_create_bin_file(&pdev->dev, &firmware_attr); in expose_firmware_sysfs()
123 struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); in clean_firmware_sysfs()
125 device_remove_bin_file(&pdev->dev, &firmware_attr); in clean_firmware_sysfs()
130 * intel_gvt_free_firmware - free GVT firmware
136 if (!gvt->firmware.firmware_loaded) in intel_gvt_free_firmware()
139 kfree(gvt->firmware.cfg_space); in intel_gvt_free_firmware()
140 vfree(gvt->firmware.mmio); in intel_gvt_free_firmware()
144 const struct firmware *fw) in verify_firmware() argument
146 struct intel_gvt_device_info *info = &gvt->device_info; in verify_firmware()
147 struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); in verify_firmware()
154 h = (struct gvt_firmware_header *)fw->data; in verify_firmware()
157 mem = fw->data + crc32_start; in verify_firmware()
165 VERIFY("magic number", h->magic, VGT_MAGIC); in verify_firmware()
166 VERIFY("version", h->version, FIRMWARE_VERSION); in verify_firmware()
167 VERIFY("crc32", h->crc32, crc32_le(0, mem, fw->size - crc32_start)); in verify_firmware()
168 VERIFY("cfg space size", h->cfg_space_size, info->cfg_space_size); in verify_firmware()
169 VERIFY("mmio size", h->mmio_size, info->mmio_size); in verify_firmware()
171 mem = (fw->data + h->cfg_space_offset); in verify_firmware()
174 VERIFY("vender id", id, pdev->vendor); in verify_firmware()
177 VERIFY("device id", id, pdev->device); in verify_firmware()
180 VERIFY("revision id", id, pdev->revision); in verify_firmware()
188 return -EINVAL; in verify_firmware()
194 * intel_gvt_load_firmware - load GVT firmware
200 struct intel_gvt_device_info *info = &gvt->device_info; in intel_gvt_load_firmware()
201 struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); in intel_gvt_load_firmware()
202 struct intel_gvt_firmware *firmware = &gvt->firmware; in intel_gvt_load_firmware()
204 const struct firmware *fw; in intel_gvt_load_firmware() local
211 return -ENOMEM; in intel_gvt_load_firmware()
213 mem = kmalloc(info->cfg_space_size, GFP_KERNEL); in intel_gvt_load_firmware()
216 return -ENOMEM; in intel_gvt_load_firmware()
219 firmware->cfg_space = mem; in intel_gvt_load_firmware()
221 mem = vmalloc(info->mmio_size); in intel_gvt_load_firmware()
224 kfree(firmware->cfg_space); in intel_gvt_load_firmware()
225 return -ENOMEM; in intel_gvt_load_firmware()
228 firmware->mmio = mem; in intel_gvt_load_firmware()
231 GVT_FIRMWARE_PATH, pdev->vendor, pdev->device, in intel_gvt_load_firmware()
232 pdev->revision); in intel_gvt_load_firmware()
236 ret = request_firmware(&fw, path, gvt->gt->i915->drm.dev); in intel_gvt_load_firmware()
244 ret = verify_firmware(gvt, fw); in intel_gvt_load_firmware()
250 h = (struct gvt_firmware_header *)fw->data; in intel_gvt_load_firmware()
252 memcpy(firmware->cfg_space, fw->data + h->cfg_space_offset, in intel_gvt_load_firmware()
253 h->cfg_space_size); in intel_gvt_load_firmware()
254 memcpy(firmware->mmio, fw->data + h->mmio_offset, in intel_gvt_load_firmware()
255 h->mmio_size); in intel_gvt_load_firmware()
257 release_firmware(fw); in intel_gvt_load_firmware()
258 firmware->firmware_loaded = true; in intel_gvt_load_firmware()
262 release_firmware(fw); in intel_gvt_load_firmware()