Maaac/CodeLLaMA-Linux-BugFix
08
1[2 {3 "prompt": "Given the following original C code:\nstatic ssize_t\nauto_link_downgrade_capable_show(struct device *dev, struct device_attribute *attr, char *buf)\n{\n\tstruct pci_dev *pdev = to_pci_dev(dev);\n\tstruct xe_device *xe = pdev_to_xe_device(pdev);\n\tu32 cap, val;\n\n\txe_pm_runtime_get(xe);\n\tval = xe_mmio_read32(xe_root_tile_mmio(xe), BMG_PCIE_CAP);\n\txe_pm_runtime_put(xe);\n\n\tcap = REG_FIELD_GET(LINK_DOWNGRADE, val);\n\treturn sysfs_emit(buf, \"%u\\n\", cap == DOWNGRADE_CAPABLE ? true : false);\n}\nstatic DEVICE_ATTR_ADMIN_RO(auto_link_downgrade_capable);\n\nstatic ssize_t\nauto_link_downgrade_status_show(struct device *dev, struct device_attribute *attr, char *buf)\n{\n\tstruct pci_dev *pdev = to_pci_dev(dev);\n\nInstruction:\ndrm/xe: drop redundant conversion to bool\n\nReturn the diff that fixes it:\n",4 "reference": "@@ -115,7 +115,7 @@ auto_link_downgrade_capable_show(struct device *dev, struct device_attribute *at\n \txe_pm_runtime_put(xe);\n \n \tcap = REG_FIELD_GET(LINK_DOWNGRADE, val);\n-\treturn sysfs_emit(buf, \"%u\\n\", cap == DOWNGRADE_CAPABLE ? true : false);\n+\treturn sysfs_emit(buf, \"%u\\n\", cap == DOWNGRADE_CAPABLE);\n }\n static DEVICE_ATTR_ADMIN_RO(auto_link_downgrade_capable);",5 "prediction": "Given the following original C code:\nstatic ssize_t\nauto_link_downgrade_capable_show(struct device *dev, struct device_attribute *attr, char *buf)\n{\n\tstruct pci_dev *pdev = to_pci_dev(dev);\n\tstruct xe_device *xe = pdev_to_xe_device(pdev);\n\tu32 cap, val;\n\n\txe_pm_runtime_get(xe);\n\tval = xe_mmio_read32(xe_root_tile_mmio(xe), BMG_PCIE_CAP);\n\txe_pm_runtime_put(xe);\n\n\tcap = REG_FIELD_GET(LINK_DOWNGRADE, val);\n\treturn sysfs_emit(buf, \"%u\\n\", cap == DOWNGRADE_CAPABLE ? true : false);\n}\nstatic DEVICE_ATTR_ADMIN_RO(auto_link_downgrade_capable);\n\nstatic ssize_t\nauto_link_downgrade_status_show(struct device *dev, struct device_attribute *attr, char *buf)\n{\n\tstruct pci_dev *pdev = to_pci_dev(dev);\n\nInstruction:\ndrm/xe: drop redundant conversion to bool\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ auto_link_downgrade_capable_show(struct device *dev, struct device_attribute *at\n \tval = xe_mmio_read32(xe_root_tile_mmio(xe), BMG_PCIE_CAP);\n \txe_pm_runtime_put(xe);\n \n-\tcap = REG_FIELD_GET(LINK_DOWNGRADE, val);\n+\tcap = REG_FIELD_GET(LINK_DOWNGRADE, val) == DOWNGRADE_CAPABLE;\n \treturn sysfs_emit(buf, \"%u\\n\", cap);\n }\n static DEVICE_ATTR_ADMIN_RO(auto_link_downgrade_status);\n@@ -116,7 +116,7 @@ auto_link_downgrade_capable_show(struct device *dev, struct device_attribute *at\n static ssize_t\n auto_link_downgrade_status_show(struct device *dev,"6 },7 {8 "prompt": "Given the following original C code:\ndrm_dbg(&xe->drm, \"Evict system allocator BO failed=%pe\\n\",\n\t\t\t\tERR_PTR(ret));\n\t\t}\n\n\t\tgoto out;\n\t}\n\n\tif (old_mem_type == XE_PL_SYSTEM && new_mem->mem_type == XE_PL_TT && !handle_system_ccs) {\n\t\tttm_bo_move_null(ttm_bo, new_mem);\n\t\tgoto out;\n\t}\n\n\t/* Reject BO eviction if BO is bound to current VM. */\n\tif (evict && ctx->resv) {\n\t\tstruct drm_gpuvm_bo *vm_bo;\n\n\t\tdrm_gem_for_each_gpuvm_bo(vm_bo, &bo->ttm.base) {\n\t\t\tstruct xe_vm *vm = gpuvm_to_vm(vm_bo->vm);\n\n\t\t\tif (xe_vm_resv(vm) == ctx->resv &&\n\nInstruction:\ndrm/xe: Rework eviction rejection of bound external bos\n\nReturn the diff that fixes it:\n",9 "reference": "@@ -841,21 +841,6 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,\n \t\tgoto out;\n \t}\n \n-\t/* Reject BO eviction if BO is bound to current VM. */\n-\tif (evict && ctx->resv) {\n-\t\tstruct drm_gpuvm_bo *vm_bo;\n-\n-\t\tdrm_gem_for_each_gpuvm_bo(vm_bo, &bo->ttm.base) {\n-\t\t\tstruct xe_vm *vm = gpuvm_to_vm(vm_bo->vm);\n-\n-\t\t\tif (xe_vm_resv(vm) == ctx->resv &&\n-\t\t\t xe_vm_in_preempt_fence_mode(vm)) {\n-\t\t\t\tret = -EBUSY;\n-\t\t\t\tgoto out;\n-\t\t\t}\n-\t\t}\n-\t}\n-\n \t/*\n \t * Failed multi-hop where the old_mem is still marked as\n \t * TTM_PL_FLAG_TEMPORARY, should just be a dummy move.\n@@ -1013,6 +998,25 @@ static long xe_bo_shrink_purge(struct ttm_operation_ctx *ctx,\n \treturn lret;\n }\n \n+static bool\n+xe_bo_eviction_valuable(struct ttm_buffer_object *bo, const struct ttm_place *place)\n+{\n+\tstruct drm_gpuvm_bo *vm_bo;\n+\n+\tif (!ttm_bo_eviction_valuable(bo, place))\n+\t\treturn false;\n+\n+\tif (!xe_bo_is_xe_bo(bo))\n+\t\treturn true;\n+\n+\tdrm_gem_for_each_gpuvm_bo(vm_bo, &bo->base) {\n+\t\tif (xe_vm_is_validating(gpuvm_to_vm(vm_bo->vm)))\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n /**\n * xe_bo_shrink() - Try to shrink an xe bo.\n * @ctx: The struct ttm_operation_ctx used for shrinking.\n@@ -1047,7 +1051,7 @@ long xe_bo_shrink(struct ttm_operation_ctx *ctx, struct ttm_buffer_object *bo,\n \t (flags.purge && !xe_tt->purgeable))\n \t\treturn -EBUSY;\n \n-\tif (!ttm_bo_eviction_valuable(bo, &place))\n+\tif (!xe_bo_eviction_valuable(bo, &place))\n \t\treturn -EBUSY;\n \n \tif (!xe_bo_is_xe_bo(bo) || !xe_bo_get_unless_zero(xe_bo))\n@@ -1588,7 +1592,7 @@ const struct ttm_device_funcs xe_ttm_funcs = {\n \t.io_mem_pfn = xe_ttm_io_mem_pfn,\n \t.access_memory = xe_ttm_access_memory,\n \t.release_notify = xe_ttm_bo_release_notify,\n-\t.eviction_valuable = ttm_bo_eviction_valuable,\n+\t.eviction_valuable = xe_bo_eviction_valuable,\n \t.delete_mem_notify = xe_ttm_bo_delete_mem_notify,\n \t.swap_notify = xe_ttm_bo_swap_notify,\n };\n@@ -2431,6 +2435,8 @@ int xe_bo_validate(struct xe_bo *bo, struct xe_vm *vm, bool allow_res_evict)\n \t\t.no_wait_gpu = false,\n \t\t.gfp_retry_mayfail = true,\n \t};\n+\tstruct pin_cookie cookie;\n+\tint ret;\n \n \tif (vm) {\n \t\tlockdep_assert_held(&vm->lock);\n@@ -2440,8 +2446,12 @@ int xe_bo_validate(struct xe_bo *bo, struct xe_vm *vm, bool allow_res_evict)\n \t\tctx.resv = xe_vm_resv(vm);\n \t}\n \n+\tcookie = xe_vm_set_validating(vm, allow_res_evict);\n \ttrace_xe_bo_validate(bo);\n-\treturn ttm_bo_validate(&bo->ttm, &bo->placement, &ctx);\n+\tret = ttm_bo_validate(&bo->ttm, &bo->placement, &ctx);\n+\txe_vm_clear_validating(vm, allow_res_evict, cookie);\n+\n+\treturn ret;\n }\n \n bool xe_bo_is_xe_bo(struct ttm_buffer_object *bo)",10 "prediction": "Given the following original C code:\ndrm_dbg(&xe->drm, \"Evict system allocator BO failed=%pe\\n\",\n\t\t\t\tERR_PTR(ret));\n\t\t}\n\n\t\tgoto out;\n\t}\n\n\tif (old_mem_type == XE_PL_SYSTEM && new_mem->mem_type == XE_PL_TT && !handle_system_ccs) {\n\t\tttm_bo_move_null(ttm_bo, new_mem);\n\t\tgoto out;\n\t}\n\n\t/* Reject BO eviction if BO is bound to current VM. */\n\tif (evict && ctx->resv) {\n\t\tstruct drm_gpuvm_bo *vm_bo;\n\n\t\tdrm_gem_for_each_gpuvm_bo(vm_bo, &bo->ttm.base) {\n\t\t\tstruct xe_vm *vm = gpuvm_to_vm(vm_bo->vm);\n\n\t\t\tif (xe_vm_resv(vm) == ctx->resv &&\n\nInstruction:\ndrm/xe: Rework eviction rejection of bound external bos\n\nReturn the diff that fixes it:\n @@ -109,10 +109,10 @@ static int xe_bo_move(struct ttm_buffer_object *bo,\n \t\tttm_bo_move_null(ttm_bo, new_mem);\n \t\tgoto out;\n \t}\n+\n \t/* Reject BO eviction if BO is bound to current VM. */\n \tif (evict && ctx->resv) {\n \t\tstruct drm_gpuvm_bo *vm_bo;\n \n-\t\tdrm_gem_for_each_gpuvm_bo(vm_bo, &bo->ttm.base) {\n-\t\t\tstruct xe_vm *vm = gpuvm_to_vm(vm_bo->vm);\n+\t\tdrm_gem_for_each_gpuvm_bo(vm_bo, &bo->ttm.base) {\n+\t\t\tstruct xe_vm *vm = gpuvm_to_vm(vm_bo->vm);\n \n \t\t\tif (xe_vm_"11 },12 {13 "prompt": "Given the following original C code:\n#else\n__printf(2, 3)\nstatic inline void vm_dbg(const struct drm_device *dev,\n\t\t\t const char *format, ...)\n{ /* noop */ }\n#endif\n\nstruct xe_vm_snapshot *xe_vm_snapshot_capture(struct xe_vm *vm);\nvoid xe_vm_snapshot_capture_delayed(struct xe_vm_snapshot *snap);\nvoid xe_vm_snapshot_print(struct xe_vm_snapshot *snap, struct drm_printer *p);\nvoid xe_vm_snapshot_free(struct xe_vm_snapshot *snap);\n\n#if IS_ENABLED(CONFIG_DRM_XE_USERPTR_INVAL_INJECT)\nvoid xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma);\n#else\nstatic inline void xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma)\n{\n}\n#endif\n#endif\n\nInstruction:\ndrm/xe: Rework eviction rejection of bound external bos\n\nReturn the diff that fixes it:\n",14 "reference": "@@ -301,6 +301,75 @@ void xe_vm_snapshot_capture_delayed(struct xe_vm_snapshot *snap);\n void xe_vm_snapshot_print(struct xe_vm_snapshot *snap, struct drm_printer *p);\n void xe_vm_snapshot_free(struct xe_vm_snapshot *snap);\n \n+/**\n+ * xe_vm_set_validating() - Register this task as currently making bos resident\n+ * @allow_res_evict: Allow eviction of buffer objects bound to @vm when\n+ * validating.\n+ * @vm: Pointer to the vm or NULL.\n+ *\n+ * Register this task as currently making bos resident for the vm. Intended\n+ * to avoid eviction by the same task of shared bos bound to the vm.\n+ * Call with the vm's resv lock held.\n+ *\n+ * Return: A pin cookie that should be used for xe_vm_clear_validating().\n+ */\n+static inline struct pin_cookie xe_vm_set_validating(struct xe_vm *vm,\n+\t\t\t\t\t\t bool allow_res_evict)\n+{\n+\tstruct pin_cookie cookie = {};\n+\n+\tif (vm && !allow_res_evict) {\n+\t\txe_vm_assert_held(vm);\n+\t\tcookie = lockdep_pin_lock(&xe_vm_resv(vm)->lock.base);\n+\t\t/* Pairs with READ_ONCE in xe_vm_is_validating() */\n+\t\tWRITE_ONCE(vm->validating, current);\n+\t}\n+\n+\treturn cookie;\n+}\n+\n+/**\n+ * xe_vm_clear_validating() - Unregister this task as currently making bos resident\n+ * @vm: Pointer to the vm or NULL\n+ * @allow_res_evict: Eviction from @vm was allowed. Must be set to the same\n+ * value as for xe_vm_set_validation().\n+ * @cookie: Cookie obtained from xe_vm_set_validating().\n+ *\n+ * Register this task as currently making bos resident for the vm. Intended\n+ * to avoid eviction by the same task of shared bos bound to the vm.\n+ * Call with the vm's resv lock held.\n+ */\n+static inline void xe_vm_clear_validating(struct xe_vm *vm, bool allow_res_evict,\n+\t\t\t\t\t struct pin_cookie cookie)\n+{\n+\tif (vm && !allow_res_evict) {\n+\t\tlockdep_unpin_lock(&xe_vm_resv(vm)->lock.base, cookie);\n+\t\t/* Pairs with READ_ONCE in xe_vm_is_validating() */\n+\t\tWRITE_ONCE(vm->validating, NULL);\n+\t}\n+}\n+\n+/**\n+ * xe_vm_is_validating() - Whether bos bound to the vm are currently being made resident\n+ * by the current task.\n+ * @vm: Pointer to the vm.\n+ *\n+ * If this function returns %true, we should be in a vm resv locked region, since\n+ * the current process is the same task that called xe_vm_set_validating().\n+ * The function asserts that that's indeed the case.\n+ *\n+ * Return: %true if the task is currently making bos resident, %false otherwise.\n+ */\n+static inline bool xe_vm_is_validating(struct xe_vm *vm)\n+{\n+\t/* Pairs with WRITE_ONCE in xe_vm_is_validating() */\n+\tif (READ_ONCE(vm->validating) == current) {\n+\t\txe_vm_assert_held(vm);\n+\t\treturn true;\n+\t}\n+\treturn false;\n+}\n+\n #if IS_ENABLED(CONFIG_DRM_XE_USERPTR_INVAL_INJECT)\n void xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma);\n #else",15 "prediction": "Given the following original C code:\n#else\n__printf(2, 3)\nstatic inline void vm_dbg(const struct drm_device *dev,\n\t\t\t const char *format, ...)\n{ /* noop */ }\n#endif\n\nstruct xe_vm_snapshot *xe_vm_snapshot_capture(struct xe_vm *vm);\nvoid xe_vm_snapshot_capture_delayed(struct xe_vm_snapshot *snap);\nvoid xe_vm_snapshot_print(struct xe_vm_snapshot *snap, struct drm_printer *p);\nvoid xe_vm_snapshot_free(struct xe_vm_snapshot *snap);\n\n#if IS_ENABLED(CONFIG_DRM_XE_USERPTR_INVAL_INJECT)\nvoid xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma);\n#else\nstatic inline void xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma)\n{\n}\n#endif\n#endif\n\nInstruction:\ndrm/xe: Rework eviction rejection of bound external bos\n\nReturn the diff that fixes it:\n @@ -109,6 +109,10 @@ void xe_vm_snapshot_capture_delayed(struct xe_vm_snapshot *snap);\n void xe_vm_snapshot_print(struct xe_vm_snapshot *snap, struct drm_printer *p);\n void xe_vm_snapshot_free(struct xe_vm_snapshot *snap);\n \n+void xe_vm_snapshot_evict(struct xe_vm_snapshot *snap);\n+\n+#if IS_ENABLED(CONFIG_DRM_XE_USERPTR_INVAL_INJECT)\n+void xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma);\n+#else\n+static inline void xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma)\n+{\n+}\n+#endif\n #if IS_ENABLED(CONFIG_DRM_XE_USERPTR"16 },17 {18 "prompt": "Given the following original C code:\n/** @error_capture: allow to track errors */\n\tstruct {\n\t\t/** @capture_once: capture only one error per VM */\n\t\tbool capture_once;\n\t} error_capture;\n\n\t/**\n\t * @tlb_flush_seqno: Required TLB flush seqno for the next exec.\n\t * protected by the vm resv.\n\t */\n\tu64 tlb_flush_seqno;\n\t/** @batch_invalidate_tlb: Always invalidate TLB before batch start */\n\tbool batch_invalidate_tlb;\n\t/** @xef: XE file handle for tracking this VM's drm client */\n\tstruct xe_file *xef;\n};\n\n/** struct xe_vma_op_map - VMA map operation */\nstruct xe_vma_op_map {\n\nInstruction:\ndrm/xe: Rework eviction rejection of bound external bos\n\nReturn the diff that fixes it:\n",19 "reference": "@@ -310,6 +310,14 @@ struct xe_vm {\n \t * protected by the vm resv.\n \t */\n \tu64 tlb_flush_seqno;\n+\t/**\n+\t * @validating: The task that is currently making bos resident for this vm.\n+\t * Protected by the VM's resv for writing. Opportunistic reading can be done\n+\t * using READ_ONCE. Note: This is a workaround for the\n+\t * TTM eviction_valuable() callback not being passed a struct\n+\t * ttm_operation_context(). Future work might want to address this.\n+\t */\n+\tstruct task_struct *validating;\n \t/** @batch_invalidate_tlb: Always invalidate TLB before batch start */\n \tbool batch_invalidate_tlb;\n \t/** @xef: XE file handle for tracking this VM's drm client */",20 "prediction": "Given the following original C code:\n/** @error_capture: allow to track errors */\n\tstruct {\n\t\t/** @capture_once: capture only one error per VM */\n\t\tbool capture_once;\n\t} error_capture;\n\n\t/**\n\t * @tlb_flush_seqno: Required TLB flush seqno for the next exec.\n\t * protected by the vm resv.\n\t */\n\tu64 tlb_flush_seqno;\n\t/** @batch_invalidate_tlb: Always invalidate TLB before batch start */\n\tbool batch_invalidate_tlb;\n\t/** @xef: XE file handle for tracking this VM's drm client */\n\tstruct xe_file *xef;\n};\n\n/** struct xe_vma_op_map - VMA map operation */\nstruct xe_vma_op_map {\n\nInstruction:\ndrm/xe: Rework eviction rejection of bound external bos\n\nReturn the diff that fixes it:\n @@ -110,6 +110,7 @@ struct xe_vm {\n \t */\n \tu64 tlb_flush_seqno;\n \t/** @batch_invalidate_tlb: Always invalidate TLB before batch start */\n+\tbool batch_invalidate_tlb;\n \t/** @xef: XE file handle for tracking this VM's drm client */\n \tstruct xe_file *xef;\n };\n@@ -118,6 +119,7 @@ struct xe_vm {\n struct xe_vma_op_map {\n \tstruct xe_vma *vma;\n \tstruct xe_bo *bo;\n+\tu64 offset;\n };\n \n struct xe_vma_op_unmap {\n@@ -126,6 +128,7 @@ struct xe_vm {\n \tstruct xe_vma *vma;\n \tstruct xe_bo *bo;\n+\tu64 offset;\n };\n \n struct x"21 },22 {23 "prompt": "Given the following original C code:\nstatic inline void xe_sched_stop(struct xe_gpu_scheduler *sched)\n{\n\tdrm_sched_stop(&sched->base, NULL);\n}\n\nstatic inline void xe_sched_tdr_queue_imm(struct xe_gpu_scheduler *sched)\n{\n\tdrm_sched_tdr_queue_imm(&sched->base);\n}\n\nstatic inline void xe_sched_resubmit_jobs(struct xe_gpu_scheduler *sched)\n{\n\tdrm_sched_resubmit_jobs(&sched->base);\n}\n\nstatic inline bool\nxe_sched_invalidate_job(struct xe_sched_job *job, int threshold)\n{\n\treturn drm_sched_invalidate_job(&job->drm, threshold);\n}\n\nInstruction:\ndrm/xe/sched: stop re-submitting signalled jobs\n\nReturn the diff that fixes it:\n",24 "reference": "@@ -51,7 +51,15 @@ static inline void xe_sched_tdr_queue_imm(struct xe_gpu_scheduler *sched)\n \n static inline void xe_sched_resubmit_jobs(struct xe_gpu_scheduler *sched)\n {\n-\tdrm_sched_resubmit_jobs(&sched->base);\n+\tstruct drm_sched_job *s_job;\n+\n+\tlist_for_each_entry(s_job, &sched->base.pending_list, list) {\n+\t\tstruct drm_sched_fence *s_fence = s_job->s_fence;\n+\t\tstruct dma_fence *hw_fence = s_fence->parent;\n+\n+\t\tif (hw_fence && !dma_fence_is_signaled(hw_fence))\n+\t\t\tsched->base.ops->run_job(s_job);\n+\t}\n }\n \n static inline bool",25 "prediction": "Given the following original C code:\nstatic inline void xe_sched_stop(struct xe_gpu_scheduler *sched)\n{\n\tdrm_sched_stop(&sched->base, NULL);\n}\n\nstatic inline void xe_sched_tdr_queue_imm(struct xe_gpu_scheduler *sched)\n{\n\tdrm_sched_tdr_queue_imm(&sched->base);\n}\n\nstatic inline void xe_sched_resubmit_jobs(struct xe_gpu_scheduler *sched)\n{\n\tdrm_sched_resubmit_jobs(&sched->base);\n}\n\nstatic inline bool\nxe_sched_invalidate_job(struct xe_sched_job *job, int threshold)\n{\n\treturn drm_sched_invalidate_job(&job->drm, threshold);\n}\n\nInstruction:\ndrm/xe/sched: stop re-submitting signalled jobs\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static inline void xe_sched_tdr_queue_imm(struct xe_gpu_scheduler *sched)\n \n static inline void xe_sched_resubmit_jobs(struct xe_gpu_scheduler *sched)\n {\n-\tdrm_sched_resubmit_jobs(&sched->base);\n+\tdrm_sched_resubmit_jobs(&sched->base, false);\n }\n \n static inline bool\n@@ -116,7 +116,7 @@ xe_sched_resubmit_jobs(struct xe_gpu_scheduler *sched)\n \n static inline bool\n xe_sched_invalidate_job(struct xe_sched_job *job, int threshold)\n-{\n+{\n \treturn drm_sched_invalidate_job(&job->drm, threshold);\n }\n \n@@ -124,7 +124,7 @@ xe"26 },27 {28 "prompt": "Given the following original C code:\n/* we only support DRM_XE_PXP_TYPE_HWDRM for now */\n\tif (XE_IOCTL_DBG(xe, value != DRM_XE_PXP_TYPE_HWDRM))\n\t\treturn -EINVAL;\n\n\treturn xe_pxp_key_assign(xe->pxp, bo);\n}\n\ntypedef int (*xe_gem_create_set_property_fn)(struct xe_device *xe,\n\t\t\t\t\t struct xe_bo *bo,\n\t\t\t\t\t u64 value);\n\nstatic const xe_gem_create_set_property_fn gem_create_set_property_funcs[] = {\n\t[DRM_XE_GEM_CREATE_EXTENSION_SET_PROPERTY] = gem_create_set_pxp_type,\n};\n\nstatic int gem_create_user_ext_set_property(struct xe_device *xe,\n\t\t\t\t\t struct xe_bo *bo,\n\t\t\t\t\t u64 extension)\n{\n\tu64 __user *address = u64_to_user_ptr(extension);\n\nInstruction:\ndrm/xe/pxp: Use the correct define in the set_property_funcs array\n\nReturn the diff that fixes it:\n",29 "reference": "@@ -2567,7 +2567,7 @@ typedef int (*xe_gem_create_set_property_fn)(struct xe_device *xe,\n \t\t\t\t\t u64 value);\n \n static const xe_gem_create_set_property_fn gem_create_set_property_funcs[] = {\n-\t[DRM_XE_GEM_CREATE_EXTENSION_SET_PROPERTY] = gem_create_set_pxp_type,\n+\t[DRM_XE_GEM_CREATE_SET_PROPERTY_PXP_TYPE] = gem_create_set_pxp_type,\n };\n \n static int gem_create_user_ext_set_property(struct xe_device *xe,",30 "prediction": "Given the following original C code:\n/* we only support DRM_XE_PXP_TYPE_HWDRM for now */\n\tif (XE_IOCTL_DBG(xe, value != DRM_XE_PXP_TYPE_HWDRM))\n\t\treturn -EINVAL;\n\n\treturn xe_pxp_key_assign(xe->pxp, bo);\n}\n\ntypedef int (*xe_gem_create_set_property_fn)(struct xe_device *xe,\n\t\t\t\t\t struct xe_bo *bo,\n\t\t\t\t\t u64 value);\n\nstatic const xe_gem_create_set_property_fn gem_create_set_property_funcs[] = {\n\t[DRM_XE_GEM_CREATE_EXTENSION_SET_PROPERTY] = gem_create_set_pxp_type,\n};\n\nstatic int gem_create_user_ext_set_property(struct xe_device *xe,\n\t\t\t\t\t struct xe_bo *bo,\n\t\t\t\t\t u64 extension)\n{\n\tu64 __user *address = u64_to_user_ptr(extension);\n\nInstruction:\ndrm/xe/pxp: Use the correct define in the set_property_funcs array\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ typedef int (*xe_gem_create_set_property_fn)(struct xe_device *xe,\n \t\t\t\t\t struct xe_bo *bo,\n \t\t\t\t\t u64 value);\n \n-static const xe_gem_create_set_property_fn gem_create_set_property_funcs[] = {\n+static const xe_gem_create_set_property_fn gem_create_set_property_funcs[] = {\n \t[DRM_XE_GEM_CREATE_EXTENSION_SET_PROPERTY] = gem_create_set_pxp_type,\n };\n \n@@ -116,7 +116,7 @@ static int gem_create_user_ext_set_property(struct xe_device *xe,\n \tu64 __user *address = u64_to_user_ptr(extension);\n \tu64 value;\n \n-\tif (copy_from_user(&value, address,"31 },32 {33 "prompt": "Given the following original C code:\nif (!xe_pxp_is_enabled(pxp))\n\t\treturn -ENODEV;\n\n\t/* we only support HWDRM sessions right now */\n\txe_assert(pxp->xe, q->pxp.type == DRM_XE_PXP_TYPE_HWDRM);\n\n\t/*\n\t * Runtime suspend kills PXP, so we take a reference to prevent it from\n\t * happening while we have active queues that use PXP\n\t */\n\txe_pm_runtime_get(pxp->xe);\n\n\tif (!pxp_prerequisites_done(pxp)) {\n\t\tret = -EBUSY;\n\t\tgoto out;\n\t}\n\nwait_for_idle:\n\t/*\n\t * if there is an action in progress, wait for it. We need to wait\n\nInstruction:\ndrm/xe/pxp: Clarify PXP queue creation behavior if PXP is not ready\n\nReturn the diff that fixes it:\n",34 "reference": "@@ -541,10 +541,14 @@ int xe_pxp_exec_queue_add(struct xe_pxp *pxp, struct xe_exec_queue *q)\n \t */\n \txe_pm_runtime_get(pxp->xe);\n \n-\tif (!pxp_prerequisites_done(pxp)) {\n-\t\tret = -EBUSY;\n+\t/* get_readiness_status() returns 0 for in-progress and 1 for done */\n+\tret = xe_pxp_get_readiness_status(pxp);\n+\tif (ret <= 0) {\n+\t\tif (!ret)\n+\t\t\tret = -EBUSY;\n \t\tgoto out;\n \t}\n+\tret = 0;\n \n wait_for_idle:\n \t/*",35 "prediction": "Given the following original C code:\nif (!xe_pxp_is_enabled(pxp))\n\t\treturn -ENODEV;\n\n\t/* we only support HWDRM sessions right now */\n\txe_assert(pxp->xe, q->pxp.type == DRM_XE_PXP_TYPE_HWDRM);\n\n\t/*\n\t * Runtime suspend kills PXP, so we take a reference to prevent it from\n\t * happening while we have active queues that use PXP\n\t */\n\txe_pm_runtime_get(pxp->xe);\n\n\tif (!pxp_prerequisites_done(pxp)) {\n\t\tret = -EBUSY;\n\t\tgoto out;\n\t}\n\nwait_for_idle:\n\t/*\n\t * if there is an action in progress, wait for it. We need to wait\n\nInstruction:\ndrm/xe/pxp: Clarify PXP queue creation behavior if PXP is not ready\n\nReturn the diff that fixes it:\n @@ -107,7 +107,7 @@ static int pxp_queue_create(struct drm_device *dev, struct drm_file *file,\n \t * happening while we have active queues that use PXP\n \t */\n \txe_pm_runtime_get(pxp->xe);\n-\n+\tif (!pxp_is_ready(pxp)) {\n \tif (!pxp_prerequisites_done(pxp)) {\n \t\tret = -EBUSY;\n \t\tgoto out;\n@@ -115,6 +115,10 @@ static int pxp_queue_create(struct drm_device *dev, struct drm_file *file,\n \n \t/*\n \t * if there is an action in progress, wait for it. We need to wait\n+\t * for PXP to be ready before creating a queue.\n+\t */\n+\tif (!pxp_is_ready(pxp)) {\n+\t\tret = -EBUSY;\n+\t\tgoto out;"36 },37 {38 "prompt": "Given the following original C code:\n* generic @drm_xe_ext_set_property struct:\n *\n * - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_PRIORITY - set the queue priority.\n * CAP_SYS_NICE is required to set a value above normal.\n * - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_TIMESLICE - set the queue timeslice\n * duration in microseconds.\n * - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_PXP_TYPE - set the type of PXP session\n * this queue will be used with. Valid values are listed in enum\n * drm_xe_pxp_session_type. %DRM_XE_PXP_TYPE_NONE is the default behavior, so\n * there is no need to explicitly set that. When a queue of type\n * %DRM_XE_PXP_TYPE_HWDRM is created, the PXP default HWDRM session\n * (%XE_PXP_HWDRM_DEFAULT_SESSION) will be started, if isn't already running.\n * Given that going into a power-saving state kills PXP HWDRM sessions,\n * runtime PM will be blocked while queues of this type are alive.\n * All PXP queues will be killed if a PXP invalidation event occurs.\n *\n * The example below shows how to use @drm_xe_exec_queue_create to create\n * a simple exec_queue (no parallel submission) of class\n * &DRM_XE_ENGINE_CLASS_RENDER.\n *\n\nInstruction:\ndrm/xe/pxp: Clarify PXP queue creation behavior if PXP is not ready\n\nReturn the diff that fixes it:\n",39 "reference": "@@ -1210,6 +1210,11 @@ struct drm_xe_vm_bind {\n * there is no need to explicitly set that. When a queue of type\n * %DRM_XE_PXP_TYPE_HWDRM is created, the PXP default HWDRM session\n * (%XE_PXP_HWDRM_DEFAULT_SESSION) will be started, if isn't already running.\n+ * The user is expected to query the PXP status via the query ioctl (see\n+ * %DRM_XE_DEVICE_QUERY_PXP_STATUS) and to wait for PXP to be ready before\n+ * attempting to create a queue with this property. When a queue is created\n+ * before PXP is ready, the ioctl will return -EBUSY if init is still in\n+ * progress or -EIO if init failed.\n * Given that going into a power-saving state kills PXP HWDRM sessions,\n * runtime PM will be blocked while queues of this type are alive.\n * All PXP queues will be killed if a PXP invalidation event occurs.",40 "prediction": "Given the following original C code:\n* generic @drm_xe_ext_set_property struct:\n *\n * - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_PRIORITY - set the queue priority.\n * CAP_SYS_NICE is required to set a value above normal.\n * - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_TIMESLICE - set the queue timeslice\n * duration in microseconds.\n * - %DRM_XE_EXEC_QUEUE_SET_PROPERTY_PXP_TYPE - set the type of PXP session\n * this queue will be used with. Valid values are listed in enum\n * drm_xe_pxp_session_type. %DRM_XE_PXP_TYPE_NONE is the default behavior, so\n * there is no need to explicitly set that. When a queue of type\n * %DRM_XE_PXP_TYPE_HWDRM is created, the PXP default HWDRM session\n * (%XE_PXP_HWDRM_DEFAULT_SESSION) will be started, if isn't already running.\n * Given that going into a power-saving state kills PXP HWDRM sessions,\n * runtime PM will be blocked while queues of this type are alive.\n * All PXP queues will be killed if a PXP invalidation event occurs.\n *\n * The example below shows how to use @drm_xe_exec_queue_create to create\n * a simple exec_queue (no parallel submission) of class\n * &DRM_XE_ENGINE_CLASS_RENDER.\n *\n\nInstruction:\ndrm/xe/pxp: Clarify PXP queue creation behavior if PXP is not ready\n\nReturn the diff that fixes it:\n @@ -106,7 +106,7 @@ struct drm_xe_exec_queue_set_property {\n * there is no need to explicitly set that. When a queue of type\n * %DRM_XE_PXP_TYPE_HWDRM is created, the PXP default HWDRM session\n * (%XE_PXP_HWDRM_DEFAULT_SESSION) will be started, if isn't already running.\n- * Given that going into a power-saving state kills PXP HWDRM sessions,\n+ * Given that going into a power-saving state may kill PXP HWDRM sessions,\n * runtime PM will be blocked while queues of this type are alive.\n * All PXP queues will be killed if a PXP invalidation event occurs.\n *\n@@ -115,7 +115,7 @@ struct drm_xe_exec_queue_set_property {\n * The example below shows how to use @drm_xe_"41 },42 {43 "prompt": "Given the following original C code:\n}\n\nstatic bool exec_queue_killed_or_banned_or_wedged(struct xe_exec_queue *q)\n{\n\treturn (atomic_read(&q->guc->state) &\n\t\t(EXEC_QUEUE_STATE_WEDGED | EXEC_QUEUE_STATE_KILLED |\n\t\t EXEC_QUEUE_STATE_BANNED));\n}\n\nstatic void guc_submit_fini(struct drm_device *drm, void *arg)\n{\n\tstruct xe_guc *guc = arg;\n\n\txa_destroy(&guc->submission_state.exec_queue_lookup);\n}\n\nstatic void guc_submit_wedged_fini(void *arg)\n{\n\tstruct xe_guc *guc = arg;\n\tstruct xe_exec_queue *q;\n\nInstruction:\ndrm/xe/guc_submit: add back fix\n\nReturn the diff that fixes it:\n",44 "reference": "@@ -229,6 +229,17 @@ static bool exec_queue_killed_or_banned_or_wedged(struct xe_exec_queue *q)\n static void guc_submit_fini(struct drm_device *drm, void *arg)\n {\n \tstruct xe_guc *guc = arg;\n+\tstruct xe_device *xe = guc_to_xe(guc);\n+\tstruct xe_gt *gt = guc_to_gt(guc);\n+\tint ret;\n+\n+\tret = wait_event_timeout(guc->submission_state.fini_wq,\n+\t\t\t\t xa_empty(&guc->submission_state.exec_queue_lookup),\n+\t\t\t\t HZ * 5);\n+\n+\tdrain_workqueue(xe->destroy_wq);\n+\n+\txe_gt_assert(gt, ret);\n \n \txa_destroy(&guc->submission_state.exec_queue_lookup);\n }",45 "prediction": "Given the following original C code:\n}\n\nstatic bool exec_queue_killed_or_banned_or_wedged(struct xe_exec_queue *q)\n{\n\treturn (atomic_read(&q->guc->state) &\n\t\t(EXEC_QUEUE_STATE_WEDGED | EXEC_QUEUE_STATE_KILLED |\n\t\t EXEC_QUEUE_STATE_BANNED));\n}\n\nstatic void guc_submit_fini(struct drm_device *drm, void *arg)\n{\n\tstruct xe_guc *guc = arg;\n\n\txa_destroy(&guc->submission_state.exec_queue_lookup);\n}\n\nstatic void guc_submit_wedged_fini(void *arg)\n{\n\tstruct xe_guc *guc = arg;\n\tstruct xe_exec_queue *q;\n\nInstruction:\ndrm/xe/guc_submit: add back fix\n\nReturn the diff that fixes it:\n @@ -108,6 +108,10 @@ static bool exec_queue_killed_or_banned_or_wedged(struct xe_exec_queue *q)\n static void guc_submit_fini(struct drm_device *drm, void *arg)\n {\n \tstruct xe_guc *guc = arg;\n+\tstruct xe_exec_queue *q;\n+\tint i;\n+\n \txa_destroy(&guc->submission_state.exec_queue_lookup);\n }\n \n@@ -115,6 +119,10 @@ static void guc_submit_wedged_fini(void *arg)\n {\n \tstruct xe_guc *guc = arg;\n \tstruct xe_exec_queue *q;\n+\tint i;\n+\n+\tfor (i = 0; i < ARRAY_SIZE(guc->exec_queues); i++) {\n+\t\tq = &guc->exec_queues[i];"46 },47 {48 "prompt": "Given the following original C code:\n* other workload can use the EUs at the same time). On MTL this is done\n\t * by setting the RUNALONE bit in the LRC, while starting on Xe2 there\n\t * is a dedicated bit for it.\n\t */\n\tif (xe_exec_queue_uses_pxp(q) &&\n\t (q->class == XE_ENGINE_CLASS_RENDER || q->class == XE_ENGINE_CLASS_COMPUTE)) {\n\t\tif (GRAPHICS_VER(gt_to_xe(q->gt)) >= 20)\n\t\t\tflags |= XE_LRC_CREATE_PXP;\n\t\telse\n\t\t\tflags |= XE_LRC_CREATE_RUNALONE;\n\t}\n\n\tif (vm) {\n\t\terr = xe_vm_lock(vm, true);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\tfor (i = 0; i < q->width; ++i) {\n\t\tq->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K, q->msix_vec, flags);\n\nInstruction:\ndrm/xe: Create LRC BO without VM\n\nReturn the diff that fixes it:\n",49 "reference": "@@ -132,12 +132,6 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)\n \t\t\tflags |= XE_LRC_CREATE_RUNALONE;\n \t}\n \n-\tif (vm) {\n-\t\terr = xe_vm_lock(vm, true);\n-\t\tif (err)\n-\t\t\treturn err;\n-\t}\n-\n \tfor (i = 0; i < q->width; ++i) {\n \t\tq->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K, q->msix_vec, flags);\n \t\tif (IS_ERR(q->lrc[i])) {\n@@ -146,9 +140,6 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)\n \t\t}\n \t}\n \n-\tif (vm)\n-\t\txe_vm_unlock(vm);\n-\n \terr = q->ops->init(q);\n \tif (err)\n \t\tgoto err_lrc;",50 "prediction": "Given the following original C code:\n* other workload can use the EUs at the same time). On MTL this is done\n\t * by setting the RUNALONE bit in the LRC, while starting on Xe2 there\n\t * is a dedicated bit for it.\n\t */\n\tif (xe_exec_queue_uses_pxp(q) &&\n\t (q->class == XE_ENGINE_CLASS_RENDER || q->class == XE_ENGINE_CLASS_COMPUTE)) {\n\t\tif (GRAPHICS_VER(gt_to_xe(q->gt)) >= 20)\n\t\t\tflags |= XE_LRC_CREATE_PXP;\n\t\telse\n\t\t\tflags |= XE_LRC_CREATE_RUNALONE;\n\t}\n\n\tif (vm) {\n\t\terr = xe_vm_lock(vm, true);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\tfor (i = 0; i < q->width; ++i) {\n\t\tq->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K, q->msix_vec, flags);\n\nInstruction:\ndrm/xe: Create LRC BO without VM\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ static int xe_exec_queue_init(struct xe_exec_queue *q)\n \t\t\tflags |= XE_LRC_CREATE_RUNALONE;\n \t}\n \n-\tif (vm) {\n+\tif (q->vm) {\n \t\terr = xe_vm_lock(vm, true);\n \t\tif (err)\n \t\t\treturn err;\n@@ -109,7 +109,7 @@ static int xe_exec_queue_init(struct xe_exec_queue *q)\n \t\tq->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K, q->msix_vec, flags);\n \t\tif (IS_ERR(q->lrc[i])) {\n \t\t\terr = PTR_ERR(q->lrc[i]);\n-\t\t\tq->lrc[i] = NULL;\n+\t\t\tq"51 },52 {53 "prompt": "Given the following original C code:\nstatic void xe_lrc_set_ppgtt(struct xe_lrc *lrc, struct xe_vm *vm)\n{\n\tu64 desc = xe_vm_pdp4_descriptor(vm, lrc->tile);\n\n\txe_lrc_write_ctx_reg(lrc, CTX_PDP0_UDW, upper_32_bits(desc));\n\txe_lrc_write_ctx_reg(lrc, CTX_PDP0_LDW, lower_32_bits(desc));\n}\n\nstatic void xe_lrc_finish(struct xe_lrc *lrc)\n{\n\txe_hw_fence_ctx_finish(&lrc->fence_ctx);\n\txe_bo_lock(lrc->bo, false);\n\txe_bo_unpin(lrc->bo);\n\txe_bo_unlock(lrc->bo);\n\txe_bo_put(lrc->bo);\n}\n\n#define PVC_CTX_ASID\t\t(0x2e + 1)\n#define PVC_CTX_ACC_CTR_THOLD\t(0x2a + 1)\n\nInstruction:\ndrm/xe: Create LRC BO without VM\n\nReturn the diff that fixes it:\n",54 "reference": "@@ -876,10 +876,7 @@ static void xe_lrc_set_ppgtt(struct xe_lrc *lrc, struct xe_vm *vm)\n static void xe_lrc_finish(struct xe_lrc *lrc)\n {\n \txe_hw_fence_ctx_finish(&lrc->fence_ctx);\n-\txe_bo_lock(lrc->bo, false);\n-\txe_bo_unpin(lrc->bo);\n-\txe_bo_unlock(lrc->bo);\n-\txe_bo_put(lrc->bo);\n+\txe_bo_unpin_map_no_vm(lrc->bo);\n }\n \n #define PVC_CTX_ASID\t\t(0x2e + 1)\n@@ -914,7 +911,7 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,\n \t * FIXME: Perma-pinning LRC as we don't yet support moving GGTT address\n \t * via VM bind calls.\n \t */\n-\tlrc->bo = xe_bo_create_pin_map(xe, tile, vm, lrc_size,\n+\tlrc->bo = xe_bo_create_pin_map(xe, tile, NULL, lrc_size,\n \t\t\t\t ttm_bo_type_kernel,\n \t\t\t\t bo_flags);\n \tif (IS_ERR(lrc->bo))\n@@ -1676,9 +1673,6 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)\n \tif (!snapshot)\n \t\treturn NULL;\n \n-\tif (lrc->bo->vm)\n-\t\txe_vm_get(lrc->bo->vm);\n-\n \tsnapshot->context_desc = xe_lrc_ggtt_addr(lrc);\n \tsnapshot->ring_addr = __xe_lrc_ring_ggtt_addr(lrc);\n \tsnapshot->indirect_context_desc = xe_lrc_indirect_ring_ggtt_addr(lrc);\n@@ -1700,14 +1694,12 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)\n void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot)\n {\n \tstruct xe_bo *bo;\n-\tstruct xe_vm *vm;\n \tstruct iosys_map src;\n \n \tif (!snapshot)\n \t\treturn;\n \n \tbo = snapshot->lrc_bo;\n-\tvm = bo->vm;\n \tsnapshot->lrc_bo = NULL;\n \n \tsnapshot->lrc_snapshot = kvmalloc(snapshot->lrc_size, GFP_KERNEL);\n@@ -1727,8 +1719,6 @@ void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot)\n \txe_bo_unlock(bo);\n put_bo:\n \txe_bo_put(bo);\n-\tif (vm)\n-\t\txe_vm_put(vm);\n }\n \n void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer *p)\n@@ -1781,14 +1771,9 @@ void xe_lrc_snapshot_free(struct xe_lrc_snapshot *snapshot)\n \t\treturn;\n \n \tkvfree(snapshot->lrc_snapshot);\n-\tif (snapshot->lrc_bo) {\n-\t\tstruct xe_vm *vm;\n-\n-\t\tvm = snapshot->lrc_bo->vm;\n+\tif (snapshot->lrc_bo)\n \t\txe_bo_put(snapshot->lrc_bo);\n-\t\tif (vm)\n-\t\t\txe_vm_put(vm);\n-\t}\n+\n \tkfree(snapshot);\n }",55 "prediction": "Given the following original C code:\nstatic void xe_lrc_set_ppgtt(struct xe_lrc *lrc, struct xe_vm *vm)\n{\n\tu64 desc = xe_vm_pdp4_descriptor(vm, lrc->tile);\n\n\txe_lrc_write_ctx_reg(lrc, CTX_PDP0_UDW, upper_32_bits(desc));\n\txe_lrc_write_ctx_reg(lrc, CTX_PDP0_LDW, lower_32_bits(desc));\n}\n\nstatic void xe_lrc_finish(struct xe_lrc *lrc)\n{\n\txe_hw_fence_ctx_finish(&lrc->fence_ctx);\n\txe_bo_lock(lrc->bo, false);\n\txe_bo_unpin(lrc->bo);\n\txe_bo_unlock(lrc->bo);\n\txe_bo_put(lrc->bo);\n}\n\n#define PVC_CTX_ASID\t\t(0x2e + 1)\n#define PVC_CTX_ACC_CTR_THOLD\t(0x2a + 1)\n\nInstruction:\ndrm/xe: Create LRC BO without VM\n\nReturn the diff that fixes it:\n @@ -105,7 +105,7 @@ static void xe_lrc_set_ppgtt(struct xe_lrc *lrc, struct xe_vm *vm)\n static void xe_lrc_finish(struct xe_lrc *lrc)\n {\n \txe_hw_fence_ctx_finish(&lrc->fence_ctx);\n-\txe_bo_lock(lrc->bo, false);\n+\txe_bo_lock(lrc->vm->bo, false);\n \txe_bo_unpin(lrc->bo);\n-\txe_bo_unlock(lrc->bo);\n+\txe_bo_unlock(lrc->vm->bo);\n \txe_bo_put(lrc->bo);\n }\n \n@@ -114,7 +114,7 @@ static void xe_lrc_finish(struct xe_lrc *lrc)\n #define PVC_CTX_ASID\t\t(0x2e + 1)\n #"56 },57 {58 "prompt": "Given the following original C code:\nerr = exec_queue_user_extensions(xe, q, extensions, 0);\n\t\tif (err) {\n\t\t\t__xe_exec_queue_free(q);\n\t\t\treturn ERR_PTR(err);\n\t\t}\n\t}\n\n\treturn q;\n}\n\nstatic int __xe_exec_queue_init(struct xe_exec_queue *q)\n{\n\tstruct xe_vm *vm = q->vm;\n\tint i, err;\n\tu32 flags = 0;\n\n\t/*\n\t * PXP workloads executing on RCS or CCS must run in isolation (i.e. no\n\t * other workload can use the EUs at the same time). On MTL this is done\n\t * by setting the RUNALONE bit in the LRC, while starting on Xe2 there\n\nInstruction:\ndrm/xe: remove unmatched xe_vm_unlock() from __xe_exec_queue_init()\n\nReturn the diff that fixes it:\n",59 "reference": "@@ -114,7 +114,6 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,\n \n static int __xe_exec_queue_init(struct xe_exec_queue *q)\n {\n-\tstruct xe_vm *vm = q->vm;\n \tint i, err;\n \tu32 flags = 0;\n \n@@ -136,7 +135,7 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)\n \t\tq->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K, q->msix_vec, flags);\n \t\tif (IS_ERR(q->lrc[i])) {\n \t\t\terr = PTR_ERR(q->lrc[i]);\n-\t\t\tgoto err_unlock;\n+\t\t\tgoto err_lrc;\n \t\t}\n \t}\n \n@@ -146,9 +145,6 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)\n \n \treturn 0;\n \n-err_unlock:\n-\tif (vm)\n-\t\txe_vm_unlock(vm);\n err_lrc:\n \tfor (i = i - 1; i >= 0; --i)\n \t\txe_lrc_put(q->lrc[i]);",60 "prediction": "Given the following original C code:\nerr = exec_queue_user_extensions(xe, q, extensions, 0);\n\t\tif (err) {\n\t\t\t__xe_exec_queue_free(q);\n\t\t\treturn ERR_PTR(err);\n\t\t}\n\t}\n\n\treturn q;\n}\n\nstatic int __xe_exec_queue_init(struct xe_exec_queue *q)\n{\n\tstruct xe_vm *vm = q->vm;\n\tint i, err;\n\tu32 flags = 0;\n\n\t/*\n\t * PXP workloads executing on RCS or CCS must run in isolation (i.e. no\n\t * other workload can use the EUs at the same time). On MTL this is done\n\t * by setting the RUNALONE bit in the LRC, while starting on Xe2 there\n\nInstruction:\ndrm/xe: remove unmatched xe_vm_unlock() from __xe_exec_queue_init()\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ static struct xe_exec_queue *__xe_exec_queue_create(struct xe_vm *vm,\n \n static int __xe_exec_queue_init(struct xe_exec_queue *q)\n {\n-\tstruct xe_vm *vm = q->vm;\n+\tstruct xe_vm *vm = q->vm;\n \tint i, err;\n \tu32 flags = 0;\n \n@@ -115,7 +115,7 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)\n \t\t\treturn err;\n \t\t}\n \t}\n-\txe_vm_unlock(vm);\n+\txe_vm_unlock(vm);\n \n \treturn 0;\n }\n@@ -123,7 +123,7 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q)\n \n static void __xe_exec_"61 },62 {63 "prompt": "Given the following original C code:\nunsigned long t1;\n\tunion {\n\t\tunsigned long args[8];\n\t\tstruct {\n\t\t\tunsigned long a0;\n\t\t\tunsigned long a1;\n\t\t\tunsigned long a2;\n\t\t\tunsigned long a3;\n\t\t\tunsigned long a4;\n\t\t\tunsigned long a5;\n\t\t\tunsigned long a6;\n\t\t\tunsigned long a7;\n\t\t};\n\t};\n};\n\nstatic __always_inline unsigned long ftrace_regs_get_instruction_pointer(const struct ftrace_regs\n\t\t\t\t\t\t\t\t\t *fregs)\n{\n\treturn arch_ftrace_regs(fregs)->epc;\n\nInstruction:\nriscv: ftrace: support fastcc in Clang for WITH_ARGS\n\nReturn the diff that fixes it:\n",64 "reference": "@@ -146,6 +146,13 @@ struct __arch_ftrace_regs {\n \t\t\tunsigned long a5;\n \t\t\tunsigned long a6;\n \t\t\tunsigned long a7;\n+#ifdef CONFIG_CC_IS_CLANG\n+\t\t\tunsigned long t2;\n+\t\t\tunsigned long t3;\n+\t\t\tunsigned long t4;\n+\t\t\tunsigned long t5;\n+\t\t\tunsigned long t6;\n+#endif\n \t\t};\n \t};\n };",65 "prediction": "Given the following original C code:\nunsigned long t1;\n\tunion {\n\t\tunsigned long args[8];\n\t\tstruct {\n\t\t\tunsigned long a0;\n\t\t\tunsigned long a1;\n\t\t\tunsigned long a2;\n\t\t\tunsigned long a3;\n\t\t\tunsigned long a4;\n\t\t\tunsigned long a5;\n\t\t\tunsigned long a6;\n\t\t\tunsigned long a7;\n\t\t};\n\t};\n};\n\nstatic __always_inline unsigned long ftrace_regs_get_instruction_pointer(const struct ftrace_regs\n\t\t\t\t\t\t\t\t\t *fregs)\n{\n\treturn arch_ftrace_regs(fregs)->epc;\n\nInstruction:\nriscv: ftrace: support fastcc in Clang for WITH_ARGS\n\nReturn the diff that fixes it:\n @@ -14,6 +14,10 @@ struct ftrace_regs {\n \t\t\tunsigned long a5;\n \t\t\tunsigned long a6;\n \t\t\tunsigned long a7;\n+\t\t\tunsigned long a8;\n+\t\t\tunsigned long a9;\n+\t\t\tunsigned long a10;\n+\t\t\tunsigned long a11;\n \t\t};\n \t};\n };\n \n@@ -21,6 +25,7 @@ static __always_inline unsigned long ftrace_regs_get_instruction_pointer(const\n \t\t\t\t\t\t\t\t\t *fregs)\n {\n \treturn arch_ftrace_regs(fregs)->epc;\n+\treturn arch_ftrace_regs(fregs)->ra;\n }\n \n static __always_inline unsigned long ftrace_regs_get_return_address(const struct ftrace_regs\n@@ -28,6 +33,7 @@ static __always_inline unsigned long ftrace_regs_"66 },67 {68 "prompt": "Given the following original C code:\nDEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));\n\tOFFSET(STACKFRAME_FP, stackframe, fp);\n\tOFFSET(STACKFRAME_RA, stackframe, ra);\n\n#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n\tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));\n\tDEFINE(FREGS_EPC,\t offsetof(struct __arch_ftrace_regs, epc));\n\tDEFINE(FREGS_RA,\t offsetof(struct __arch_ftrace_regs, ra));\n\tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n\tDEFINE(FREGS_S0,\t offsetof(struct __arch_ftrace_regs, s0));\n\tDEFINE(FREGS_T1,\t offsetof(struct __arch_ftrace_regs, t1));\n\tDEFINE(FREGS_A0,\t offsetof(struct __arch_ftrace_regs, a0));\n\tDEFINE(FREGS_A1,\t offsetof(struct __arch_ftrace_regs, a1));\n\tDEFINE(FREGS_A2,\t offsetof(struct __arch_ftrace_regs, a2));\n\tDEFINE(FREGS_A3,\t offsetof(struct __arch_ftrace_regs, a3));\n\tDEFINE(FREGS_A4,\t offsetof(struct __arch_ftrace_regs, a4));\n\tDEFINE(FREGS_A5,\t offsetof(struct __arch_ftrace_regs, a5));\n\tDEFINE(FREGS_A6,\t offsetof(struct __arch_ftrace_regs, a6));\n\tDEFINE(FREGS_A7,\t offsetof(struct __arch_ftrace_regs, a7));\n\nInstruction:\nriscv: ftrace: support fastcc in Clang for WITH_ARGS\n\nReturn the diff that fixes it:\n",69 "reference": "@@ -501,6 +501,13 @@ void asm_offsets(void)\n \tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n \tDEFINE(FREGS_S0,\t offsetof(struct __arch_ftrace_regs, s0));\n \tDEFINE(FREGS_T1,\t offsetof(struct __arch_ftrace_regs, t1));\n+#ifdef CONFIG_CC_IS_CLANG\n+\tDEFINE(FREGS_T2,\t offsetof(struct __arch_ftrace_regs, t2));\n+\tDEFINE(FREGS_T3,\t offsetof(struct __arch_ftrace_regs, t3));\n+\tDEFINE(FREGS_T4,\t offsetof(struct __arch_ftrace_regs, t4));\n+\tDEFINE(FREGS_T5,\t offsetof(struct __arch_ftrace_regs, t5));\n+\tDEFINE(FREGS_T6,\t offsetof(struct __arch_ftrace_regs, t6));\n+#endif\n \tDEFINE(FREGS_A0,\t offsetof(struct __arch_ftrace_regs, a0));\n \tDEFINE(FREGS_A1,\t offsetof(struct __arch_ftrace_regs, a1));\n \tDEFINE(FREGS_A2,\t offsetof(struct __arch_ftrace_regs, a2));",70 "prediction": "Given the following original C code:\nDEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));\n\tOFFSET(STACKFRAME_FP, stackframe, fp);\n\tOFFSET(STACKFRAME_RA, stackframe, ra);\n\n#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n\tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));\n\tDEFINE(FREGS_EPC,\t offsetof(struct __arch_ftrace_regs, epc));\n\tDEFINE(FREGS_RA,\t offsetof(struct __arch_ftrace_regs, ra));\n\tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n\tDEFINE(FREGS_S0,\t offsetof(struct __arch_ftrace_regs, s0));\n\tDEFINE(FREGS_T1,\t offsetof(struct __arch_ftrace_regs, t1));\n\tDEFINE(FREGS_A0,\t offsetof(struct __arch_ftrace_regs, a0));\n\tDEFINE(FREGS_A1,\t offsetof(struct __arch_ftrace_regs, a1));\n\tDEFINE(FREGS_A2,\t offsetof(struct __arch_ftrace_regs, a2));\n\tDEFINE(FREGS_A3,\t offsetof(struct __arch_ftrace_regs, a3));\n\tDEFINE(FREGS_A4,\t offsetof(struct __arch_ftrace_regs, a4));\n\tDEFINE(FREGS_A5,\t offsetof(struct __arch_ftrace_regs, a5));\n\tDEFINE(FREGS_A6,\t offsetof(struct __arch_ftrace_regs, a6));\n\tDEFINE(FREGS_A7,\t offsetof(struct __arch_ftrace_regs, a7));\n\nInstruction:\nriscv: ftrace: support fastcc in Clang for WITH_ARGS\n\nReturn the diff that fixes it:\n @@ -100,6 +100,7 @@\n \tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n \tDEFINE(FREGS_S0,\t offsetof(struct __arch_ftrace_regs, s0));\n \tDEFINE(FREGS_T1,\t offsetof(struct __arch_ftrace_regs, t1));\n+\tDEFINE(FREGS_T0,\t offsetof(struct __arch_ftrace_regs, t0));\n \tDEFINE(FREGS_A0,\t offsetof(struct __arch_ftrace_regs, a0));\n \tDEFINE(FREGS_A1,\t offsetof(struct __arch_ftrace_regs, a1));\n \tDEFINE(FREGS_A2,\t offsetof(struct __arch_ftrace_regs, a2));\n@@ -108,6 +109,7 @@\n \tDEFINE(FRE"71 },72 {73 "prompt": "Given the following original C code:\n/*\n\t * We don't suffer access faults, so no extra fault-recovery assembly\n\t * is needed here.\n\t */\n\told = *parent;\n\n\tif (!function_graph_enter(old, self_addr, frame_pointer, parent))\n\t\t*parent = return_hooker;\n}\n\n#ifdef CONFIG_DYNAMIC_FTRACE\n#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\nvoid ftrace_graph_func(unsigned long ip, unsigned long parent_ip,\n\t\t struct ftrace_ops *op, struct ftrace_regs *fregs)\n{\n\tunsigned long return_hooker = (unsigned long)&return_to_handler;\n\tunsigned long frame_pointer = arch_ftrace_regs(fregs)->s0;\n\tunsigned long *parent = &arch_ftrace_regs(fregs)->ra;\n\tunsigned long old;\n\nInstruction:\nriscv: ftrace factor out code defined by !WITH_ARG\n\nReturn the diff that fixes it:\n",74 "reference": "@@ -210,7 +210,6 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,\n }\n \n #ifdef CONFIG_DYNAMIC_FTRACE\n-#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,\n \t\t struct ftrace_ops *op, struct ftrace_regs *fregs)\n {\n@@ -231,19 +230,5 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,\n \tif (!function_graph_enter_regs(old, ip, frame_pointer, parent, fregs))\n \t\t*parent = return_hooker;\n }\n-#else /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */\n-extern void ftrace_graph_call(void);\n-int ftrace_enable_ftrace_graph_caller(void)\n-{\n-\treturn __ftrace_modify_call((unsigned long)&ftrace_graph_call,\n-\t\t\t\t (unsigned long)&prepare_ftrace_return, true, true);\n-}\n-\n-int ftrace_disable_ftrace_graph_caller(void)\n-{\n-\treturn __ftrace_modify_call((unsigned long)&ftrace_graph_call,\n-\t\t\t\t (unsigned long)&prepare_ftrace_return, false, true);\n-}\n-#endif /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */\n #endif /* CONFIG_DYNAMIC_FTRACE */\n #endif /* CONFIG_FUNCTION_GRAPH_TRACER */",75 "prediction": "Given the following original C code:\n/*\n\t * We don't suffer access faults, so no extra fault-recovery assembly\n\t * is needed here.\n\t */\n\told = *parent;\n\n\tif (!function_graph_enter(old, self_addr, frame_pointer, parent))\n\t\t*parent = return_hooker;\n}\n\n#ifdef CONFIG_DYNAMIC_FTRACE\n#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\nvoid ftrace_graph_func(unsigned long ip, unsigned long parent_ip,\n\t\t struct ftrace_ops *op, struct ftrace_regs *fregs)\n{\n\tunsigned long return_hooker = (unsigned long)&return_to_handler;\n\tunsigned long frame_pointer = arch_ftrace_regs(fregs)->s0;\n\tunsigned long *parent = &arch_ftrace_regs(fregs)->ra;\n\tunsigned long old;\n\nInstruction:\nriscv: ftrace factor out code defined by !WITH_ARG\n\nReturn the diff that fixes it:\n @@ -102,10 +102,6 @@ void ftrace_graph_call(unsigned long self_addr, unsigned long *parent)\n \n #ifdef CONFIG_DYNAMIC_FTRACE\n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n-void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,\n-\t\t struct ftrace_ops *op, struct ftrace_regs *fregs)\n-{\n-\tunsigned long return_hooker = (unsigned long)&return_to_handler;\n \tunsigned long frame_pointer = arch_ftrace_regs(fregs)->s0;\n \tunsigned long *parent = &arch_ftrace_regs(fregs)->ra;\n \tunsigned long old;\n@@ -113,10 +108,6 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,\n \t\treturn;\n \n \told = *parent;\n-\tif (!function_"76 },77 {78 "prompt": "Given the following original C code:\n#ifndef ftrace_get_symaddr\n/**\n * ftrace_get_symaddr - return the symbol address from fentry_ip\n * @fentry_ip: the address of ftrace location\n *\n * Get the symbol address from @fentry_ip (fast path). If there is no fast\n * search path, this returns 0.\n * User may need to use kallsyms API to find the symbol address.\n */\n#define ftrace_get_symaddr(fentry_ip) (0)\n#endif\n\n#ifdef CONFIG_DYNAMIC_FTRACE\n\nvoid ftrace_arch_code_modify_prepare(void);\nvoid ftrace_arch_code_modify_post_process(void);\n\nenum ftrace_bug_type {\n\tFTRACE_BUG_UNKNOWN,\n\tFTRACE_BUG_INIT,\n\nInstruction:\nkernel: ftrace: export ftrace_sync_ipi\n\nReturn the diff that fixes it:\n",79 "reference": "@@ -635,6 +635,8 @@ enum {\n #define ftrace_get_symaddr(fentry_ip) (0)\n #endif\n \n+void ftrace_sync_ipi(void *data);\n+\n #ifdef CONFIG_DYNAMIC_FTRACE\n \n void ftrace_arch_code_modify_prepare(void);",80 "prediction": "Given the following original C code:\n#ifndef ftrace_get_symaddr\n/**\n * ftrace_get_symaddr - return the symbol address from fentry_ip\n * @fentry_ip: the address of ftrace location\n *\n * Get the symbol address from @fentry_ip (fast path). If there is no fast\n * search path, this returns 0.\n * User may need to use kallsyms API to find the symbol address.\n */\n#define ftrace_get_symaddr(fentry_ip) (0)\n#endif\n\n#ifdef CONFIG_DYNAMIC_FTRACE\n\nvoid ftrace_arch_code_modify_prepare(void);\nvoid ftrace_arch_code_modify_post_process(void);\n\nenum ftrace_bug_type {\n\tFTRACE_BUG_UNKNOWN,\n\tFTRACE_BUG_INIT,\n\nInstruction:\nkernel: ftrace: export ftrace_sync_ipi\n\nReturn the diff that fixes it:\n @@ -100,6 +100,12 @@\n #define ftrace_get_symaddr(fentry_ip) (0)\n #endif\n \n+#ifdef CONFIG_FTRACE_SYSCALL\n+extern void ftrace_sync_ipi(void);\n+#else\n+static inline void ftrace_sync_ipi(void)\n+{\n+}\n+#endif\n+\n #ifdef CONFIG_DYNAMIC_FTRACE\n \n void ftrace_arch_code_modify_prepare(void);\n@@ -108,6 +114,7 @@ void ftrace_arch_code_modify_post_process(void);\n enum ftrace_bug_type {\n \tFTRACE_BUG_UNKNOWN,\n \tFTRACE_BUG_INIT,\n+\tFTRACE_BUG_CALLER,\n \tFTRACE_BUG_NOTRACE,\n \tFTRACE_BUG_NOPROBE,\n \tFTRACE_BUG_REGS,"81 },82 {83 "prompt": "Given the following original C code:\nif (tr) {\n\t\tpid = this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid);\n\t\tif (pid == FTRACE_PID_IGNORE)\n\t\t\treturn;\n\t\tif (pid != FTRACE_PID_TRACE &&\n\t\t pid != current->pid)\n\t\t\treturn;\n\t}\n\n\top->saved_func(ip, parent_ip, op, fregs);\n}\n\nstatic void ftrace_sync_ipi(void *data)\n{\n\t/* Probably not needed, but do it anyway */\n\tsmp_rmb();\n}\n\nstatic ftrace_func_t ftrace_ops_get_list_func(struct ftrace_ops *ops)\n{\n\nInstruction:\nkernel: ftrace: export ftrace_sync_ipi\n\nReturn the diff that fixes it:\n",84 "reference": "@@ -188,7 +188,7 @@ static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,\n \top->saved_func(ip, parent_ip, op, fregs);\n }\n \n-static void ftrace_sync_ipi(void *data)\n+void ftrace_sync_ipi(void *data)\n {\n \t/* Probably not needed, but do it anyway */\n \tsmp_rmb();",85 "prediction": "Given the following original C code:\nif (tr) {\n\t\tpid = this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid);\n\t\tif (pid == FTRACE_PID_IGNORE)\n\t\t\treturn;\n\t\tif (pid != FTRACE_PID_TRACE &&\n\t\t pid != current->pid)\n\t\t\treturn;\n\t}\n\n\top->saved_func(ip, parent_ip, op, fregs);\n}\n\nstatic void ftrace_sync_ipi(void *data)\n{\n\t/* Probably not needed, but do it anyway */\n\tsmp_rmb();\n}\n\nstatic ftrace_func_t ftrace_ops_get_list_func(struct ftrace_ops *ops)\n{\n\nInstruction:\nkernel: ftrace: export ftrace_sync_ipi\n\nReturn the diff that fixes it:\n @@ -103,10 +103,6 @@ static void ftrace_call(unsigned long ip, unsigned long parent_ip,\n \top->saved_func(ip, parent_ip, op, fregs);\n }\n \n-static void ftrace_sync_ipi(void *data)\n-{\n-\t/* Probably not needed, but do it anyway */\n-\tsmp_rmb();\n-}\n-\n static ftrace_func_t ftrace_ops_get_list_func(struct ftrace_ops *ops)\n {\n \tstruct ftrace_ops_hash *hash = &ftrace_ops_hash[0];\n@@ -116,6 +112,10 @@ static ftrace_func_t ftrace_ops_get_list_func(struct ftrace_ops *ops)\n \t\t\t\t\t\t\t\t ops->func);\n }\n \n+static void ftrace_sync_ipi(void *data)\n+{\n+\t/* Probably not needed, but do it anyway */\n+\ts"86 },87 {88 "prompt": "Given the following original C code:\n#if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_FRAME_POINTER)\n#define HAVE_FUNCTION_GRAPH_FP_TEST\n#endif\n\n#define ARCH_SUPPORTS_FTRACE_OPS 1\n#ifndef __ASSEMBLY__\n\nextern void *return_address(unsigned int level);\n\n#define ftrace_return_address(n) return_address(n)\n\nvoid _mcount(void);\nstatic inline unsigned long ftrace_call_adjust(unsigned long addr)\n{\n\treturn addr;\n}\n\n/*\n * Let's do like x86/arm64 and ignore the compat syscalls.\n */\n\nInstruction:\nriscv: ftrace: prepare ftrace for atomic code patching\n\nReturn the diff that fixes it:\n",89 "reference": "@@ -20,10 +20,9 @@ extern void *return_address(unsigned int level);\n #define ftrace_return_address(n) return_address(n)\n \n void _mcount(void);\n-static inline unsigned long ftrace_call_adjust(unsigned long addr)\n-{\n-\treturn addr;\n-}\n+unsigned long ftrace_call_adjust(unsigned long addr);\n+unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip);\n+#define ftrace_get_symaddr(fentry_ip) arch_ftrace_get_symaddr(fentry_ip)\n \n /*\n * Let's do like x86/arm64 and ignore the compat syscalls.\n@@ -57,12 +56,21 @@ struct dyn_arch_ftrace {\n * 2) jalr: setting low-12 offset to ra, jump to ra, and set ra to\n * return address (original pc + 4)\n *\n+ * The first 2 instructions for each tracable function is compiled to 2 nop\n+ * instructions. Then, the kernel initializes the first instruction to auipc at\n+ * boot time (<ftrace disable>). The second instruction is patched to jalr to\n+ * start the trace.\n+ *\n+ *<Image>:\n+ * 0: nop\n+ * 4: nop\n+ *\n *<ftrace enable>:\n- * 0: auipc t0/ra, 0x?\n- * 4: jalr t0/ra, ?(t0/ra)\n+ * 0: auipc t0, 0x?\n+ * 4: jalr t0, ?(t0)\n *\n *<ftrace disable>:\n- * 0: nop\n+ * 0: auipc t0, 0x?\n * 4: nop\n *\n * Dynamic ftrace generates probes to call sites, so we must deal with\n@@ -75,10 +83,9 @@ struct dyn_arch_ftrace {\n #define AUIPC_OFFSET_MASK\t(0xfffff000)\n #define AUIPC_PAD\t\t(0x00001000)\n #define JALR_SHIFT\t\t20\n-#define JALR_RA\t\t\t(0x000080e7)\n-#define AUIPC_RA\t\t(0x00000097)\n #define JALR_T0\t\t\t(0x000282e7)\n #define AUIPC_T0\t\t(0x00000297)\n+#define JALR_RANGE\t\t(JALR_SIGN_MASK - 1)\n \n #define to_jalr_t0(offset)\t\t\t\t\t\t\\\n \t(((offset & JALR_OFFSET_MASK) << JALR_SHIFT) | JALR_T0)\n@@ -96,26 +103,14 @@ do {\t\t\t\t\t\t\t\t\t\\\n \tcall[1] = to_jalr_t0(offset);\t\t\t\t\t\\\n } while (0)\n \n-#define to_jalr_ra(offset)\t\t\t\t\t\t\\\n-\t(((offset & JALR_OFFSET_MASK) << JALR_SHIFT) | JALR_RA)\n-\n-#define to_auipc_ra(offset)\t\t\t\t\t\t\\\n-\t((offset & JALR_SIGN_MASK) ?\t\t\t\t\t\\\n-\t(((offset & AUIPC_OFFSET_MASK) + AUIPC_PAD) | AUIPC_RA) :\t\\\n-\t((offset & AUIPC_OFFSET_MASK) | AUIPC_RA))\n-\n-#define make_call_ra(caller, callee, call)\t\t\t\t\\\n-do {\t\t\t\t\t\t\t\t\t\\\n-\tunsigned int offset =\t\t\t\t\t\t\\\n-\t\t(unsigned long) (callee) - (unsigned long) (caller);\t\\\n-\tcall[0] = to_auipc_ra(offset);\t\t\t\t\t\\\n-\tcall[1] = to_jalr_ra(offset);\t\t\t\t\t\\\n-} while (0)\n-\n /*\n- * Let auipc+jalr be the basic *mcount unit*, so we make it 8 bytes here.\n+ * Only the jalr insn in the auipc+jalr is patched, so we make it 4\n+ * bytes here.\n */\n-#define MCOUNT_INSN_SIZE 8\n+#define MCOUNT_INSN_SIZE\t4\n+#define MCOUNT_AUIPC_SIZE\t4\n+#define MCOUNT_JALR_SIZE\t4\n+#define MCOUNT_NOP4_SIZE\t4\n \n #ifndef __ASSEMBLY__\n struct dyn_ftrace;",90 "prediction": "Given the following original C code:\n#if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_FRAME_POINTER)\n#define HAVE_FUNCTION_GRAPH_FP_TEST\n#endif\n\n#define ARCH_SUPPORTS_FTRACE_OPS 1\n#ifndef __ASSEMBLY__\n\nextern void *return_address(unsigned int level);\n\n#define ftrace_return_address(n) return_address(n)\n\nvoid _mcount(void);\nstatic inline unsigned long ftrace_call_adjust(unsigned long addr)\n{\n\treturn addr;\n}\n\n/*\n * Let's do like x86/arm64 and ignore the compat syscalls.\n */\n\nInstruction:\nriscv: ftrace: prepare ftrace for atomic code patching\n\nReturn the diff that fixes it:\n @@ -26,7 +26,7 @@ extern void *return_address(unsigned int level);\n \n #define ftrace_return_address(n) return_address(n)\n \n-void _mcount(void);\n+void _mcount(void *);\n static inline unsigned long ftrace_call_adjust(unsigned long addr)\n {\n \treturn addr;\n@@ -35,6 +35,7 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)\n \n /*\n * Let's do like x86/arm64 and ignore the compat syscalls.\n+ *\n */\n #ifndef CONFIG_COMPAT\n #define IS_ERR_VALUE(x) IS_ERR((void *)(x))\n@@ -44,6 +45,7 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)\n #define IS_ERR_VALUE(x) IS_ERR((void *)(x))\n #endif\n \n+#include <asm-generic/ftrace.h>\n #"91 },92 {93 "prompt": "Given the following original C code:\n// SPDX-License-Identifier: GPL-2.0\n/*\n * Copyright (C) 2013 Linaro Limited\n * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>\n * Copyright (C) 2017 Andes Technology Corporation\n */\n\n#include <linux/ftrace.h>\n#include <linux/uaccess.h>\n#include <linux/memory.h>\n#include <linux/stop_machine.h>\n#include <asm/cacheflush.h>\n#include <asm/text-patching.h>\n\n#ifdef CONFIG_DYNAMIC_FTRACE\nvoid ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)\n{\n\tmutex_lock(&text_mutex);\n\nInstruction:\nriscv: ftrace: prepare ftrace for atomic code patching\n\nReturn the diff that fixes it:\n",94 "reference": "@@ -8,11 +8,22 @@\n #include <linux/ftrace.h>\n #include <linux/uaccess.h>\n #include <linux/memory.h>\n+#include <linux/irqflags.h>\n #include <linux/stop_machine.h>\n #include <asm/cacheflush.h>\n #include <asm/text-patching.h>\n \n #ifdef CONFIG_DYNAMIC_FTRACE\n+unsigned long ftrace_call_adjust(unsigned long addr)\n+{\n+\treturn addr + MCOUNT_AUIPC_SIZE;\n+}\n+\n+unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n+{\n+\treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n+}\n+\n void ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)\n {\n \tmutex_lock(&text_mutex);\n@@ -32,51 +43,32 @@ void ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)\n \tmutex_unlock(&text_mutex);\n }\n \n-static int ftrace_check_current_call(unsigned long hook_pos,\n-\t\t\t\t unsigned int *expected)\n+static int __ftrace_modify_call(unsigned long source, unsigned long target, bool validate)\n {\n+\tunsigned int call[2], offset;\n \tunsigned int replaced[2];\n-\tunsigned int nops[2] = {RISCV_INSN_NOP4, RISCV_INSN_NOP4};\n \n-\t/* we expect nops at the hook position */\n-\tif (!expected)\n-\t\texpected = nops;\n+\toffset = target - source;\n+\tcall[1] = to_jalr_t0(offset);\n \n-\t/*\n-\t * Read the text we want to modify;\n-\t * return must be -EFAULT on read error\n-\t */\n-\tif (copy_from_kernel_nofault(replaced, (void *)hook_pos,\n-\t\t\tMCOUNT_INSN_SIZE))\n-\t\treturn -EFAULT;\n-\n-\t/*\n-\t * Make sure it is what we expect it to be;\n-\t * return must be -EINVAL on failed comparison\n-\t */\n-\tif (memcmp(expected, replaced, sizeof(replaced))) {\n-\t\tpr_err(\"%p: expected (%08x %08x) but got (%08x %08x)\\n\",\n-\t\t (void *)hook_pos, expected[0], expected[1], replaced[0],\n-\t\t replaced[1]);\n-\t\treturn -EINVAL;\n+\tif (validate) {\n+\t\tcall[0] = to_auipc_t0(offset);\n+\t\t/*\n+\t\t * Read the text we want to modify;\n+\t\t * return must be -EFAULT on read error\n+\t\t */\n+\t\tif (copy_from_kernel_nofault(replaced, (void *)source, 2 * MCOUNT_INSN_SIZE))\n+\t\t\treturn -EFAULT;\n+\n+\t\tif (replaced[0] != call[0]) {\n+\t\t\tpr_err(\"%p: expected (%08x) but got (%08x)\\n\",\n+\t\t\t (void *)source, call[0], replaced[0]);\n+\t\t\treturn -EINVAL;\n+\t\t}\n \t}\n \n-\treturn 0;\n-}\n-\n-static int __ftrace_modify_call(unsigned long hook_pos, unsigned long target,\n-\t\t\t\tbool enable, bool ra)\n-{\n-\tunsigned int call[2];\n-\tunsigned int nops[2] = {RISCV_INSN_NOP4, RISCV_INSN_NOP4};\n-\n-\tif (ra)\n-\t\tmake_call_ra(hook_pos, target, call);\n-\telse\n-\t\tmake_call_t0(hook_pos, target, call);\n-\n-\t/* Replace the auipc-jalr pair at once. Return -EPERM on write error. */\n-\tif (patch_insn_write((void *)hook_pos, enable ? call : nops, MCOUNT_INSN_SIZE))\n+\t/* Replace the jalr at once. Return -EPERM on write error. */\n+\tif (patch_insn_write((void *)(source + MCOUNT_AUIPC_SIZE), call + 1, MCOUNT_JALR_SIZE))\n \t\treturn -EPERM;\n \n \treturn 0;\n@@ -84,22 +76,21 @@ static int __ftrace_modify_call(unsigned long hook_pos, unsigned long target,\n \n int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)\n {\n-\tunsigned int call[2];\n-\n-\tmake_call_t0(rec->ip, addr, call);\n+\tunsigned long distance, orig_addr, pc = rec->ip - MCOUNT_AUIPC_SIZE;\n \n-\tif (patch_insn_write((void *)rec->ip, call, MCOUNT_INSN_SIZE))\n-\t\treturn -EPERM;\n+\torig_addr = (unsigned long)&ftrace_caller;\n+\tdistance = addr > orig_addr ? addr - orig_addr : orig_addr - addr;\n+\tif (distance > JALR_RANGE)\n+\t\treturn -EINVAL;\n \n-\treturn 0;\n+\treturn __ftrace_modify_call(pc, addr, false);\n }\n \n-int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,\n-\t\t unsigned long addr)\n+int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr)\n {\n-\tunsigned int nops[2] = {RISCV_INSN_NOP4, RISCV_INSN_NOP4};\n+\tu32 nop4 = RISCV_INSN_NOP4;\n \n-\tif (patch_insn_write((void *)rec->ip, nops, MCOUNT_INSN_SIZE))\n+\tif (patch_insn_write((void *)rec->ip, &nop4, MCOUNT_NOP4_SIZE))\n \t\treturn -EPERM;\n \n \treturn 0;\n@@ -114,21 +105,38 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,\n */\n int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)\n {\n-\tint out;\n+\tunsigned long pc = rec->ip - MCOUNT_AUIPC_SIZE;\n+\tunsigned int nops[2], offset;\n+\tint ret;\n+\n+\toffset = (unsigned long) &ftrace_caller - pc;\n+\tnops[0] = to_auipc_t0(offset);\n+\tnops[1] = RISCV_INSN_NOP4;\n \n \tmutex_lock(&text_mutex);\n-\tout = ftrace_make_nop(mod, rec, MCOUNT_ADDR);\n+\tret = patch_insn_write((void *)pc, nops, 2 * MCOUNT_INSN_SIZE);\n \tmutex_unlock(&text_mutex);\n \n-\treturn out;\n+\treturn ret;\n }\n \n+ftrace_func_t ftrace_call_dest = ftrace_stub;\n int ftrace_update_ftrace_func(ftrace_func_t func)\n {\n-\tint ret = __ftrace_modify_call((unsigned long)&ftrace_call,\n-\t\t\t\t (unsigned long)func, true, true);\n-\n-\treturn ret;\n+\tWRITE_ONCE(ftrace_call_dest, func);\n+\t/*\n+\t * The data fence ensure that the update to ftrace_call_dest happens\n+\t * before the write to function_trace_op later in the generic ftrace.\n+\t * If the sequence is not enforced, then an old ftrace_call_dest may\n+\t * race loading a new function_trace_op set in ftrace_modify_all_code\n+\t *\n+\t * If we are in stop_machine, then we don't need to call remote fence\n+\t * as there is no concurrent read-side of ftrace_call_dest.\n+\t */\n+\tsmp_wmb();\n+\tif (!irqs_disabled())\n+\t\tsmp_call_function(ftrace_sync_ipi, NULL, 1);\n+\treturn 0;\n }\n \n struct ftrace_modify_param {\n@@ -166,23 +174,22 @@ void arch_ftrace_update_code(int command)\n \n \tstop_machine(__ftrace_modify_code, ¶m, cpu_online_mask);\n }\n-#endif\n+#else /* CONFIG_DYNAMIC_FTRACE */\n+unsigned long ftrace_call_adjust(unsigned long addr)\n+{\n+\treturn addr;\n+}\n+#endif /* CONFIG_DYNAMIC_FTRACE */\n \n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS\n int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,\n \t\t unsigned long addr)\n {\n+\tunsigned long caller = rec->ip - MCOUNT_AUIPC_SIZE;\n \tunsigned int call[2];\n-\tunsigned long caller = rec->ip;\n-\tint ret;\n \n \tmake_call_t0(caller, old_addr, call);\n-\tret = ftrace_check_current_call(caller, call);\n-\n-\tif (ret)\n-\t\treturn ret;\n-\n-\treturn __ftrace_modify_call(caller, addr, true, false);\n+\treturn __ftrace_modify_call(caller, addr, true);\n }\n #endif",95 "prediction": "Given the following original C code:\n// SPDX-License-Identifier: GPL-2.0\n/*\n * Copyright (C) 2013 Linaro Limited\n * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>\n * Copyright (C) 2017 Andes Technology Corporation\n */\n\n#include <linux/ftrace.h>\n#include <linux/uaccess.h>\n#include <linux/memory.h>\n#include <linux/stop_machine.h>\n#include <asm/cacheflush.h>\n#include <asm/text-patching.h>\n\n#ifdef CONFIG_DYNAMIC_FTRACE\nvoid ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)\n{\n\tmutex_lock(&text_mutex);\n\nInstruction:\nriscv: ftrace: prepare ftrace for atomic code patching\n\nReturn the diff that fixes it:\n @@ -10,6 +10,7 @@\n #include <linux/uaccess.h>\n #include <linux/memory.h>\n #include <linux/stop_machine.h>\n+#include <linux/atomic.h>\n #include <asm/cacheflush.h>\n #include <asm/text-patching.h>\n \n@@ -19,6 +20,7 @@ void ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)\n {\n \tmutex_lock(&text_mutex);\n }\n+\n void ftrace_arch_code_modify_post_module(void) __releases(&text_mutex)\n {\n \tmutex_unlock(&text_mutex);\n@@ -27,6 +29,7 @@ void ftrace_arch_code_modify_post_module(void) __releases(&text_mutex)\n {\n \tmutex_unlock(&text_mutex);\n }\n+\n void ftrace_arch_"96 },97 {98 "prompt": "Given the following original C code:\n#ifdef CONFIG_DYNAMIC_FTRACE\nunsigned long ftrace_call_adjust(unsigned long addr)\n{\n\treturn addr + MCOUNT_AUIPC_SIZE;\n}\n\nunsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n{\n\treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n}\n\nvoid ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)\n{\n\tmutex_lock(&text_mutex);\n\n\t/*\n\t * The code sequences we use for ftrace can't be patched while the\n\t * kernel is running, so we need to use stop_machine() to modify them\n\t * for now. This doesn't play nice with text_mutex, we use this flag\n\nInstruction:\nriscv: ftrace: do not use stop_machine to update code\n\nReturn the diff that fixes it:\n",99 "reference": "@@ -24,23 +24,13 @@ unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n \treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n }\n \n-void ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)\n+void arch_ftrace_update_code(int command)\n {\n \tmutex_lock(&text_mutex);\n-\n-\t/*\n-\t * The code sequences we use for ftrace can't be patched while the\n-\t * kernel is running, so we need to use stop_machine() to modify them\n-\t * for now. This doesn't play nice with text_mutex, we use this flag\n-\t * to elide the check.\n-\t */\n-\triscv_patch_in_stop_machine = true;\n-}\n-\n-void ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)\n-{\n-\triscv_patch_in_stop_machine = false;\n+\tcommand |= FTRACE_MAY_SLEEP;\n+\tftrace_modify_all_code(command);\n \tmutex_unlock(&text_mutex);\n+\tflush_icache_all();\n }\n \n static int __ftrace_modify_call(unsigned long source, unsigned long target, bool validate)\n@@ -129,51 +119,17 @@ int ftrace_update_ftrace_func(ftrace_func_t func)\n \t * before the write to function_trace_op later in the generic ftrace.\n \t * If the sequence is not enforced, then an old ftrace_call_dest may\n \t * race loading a new function_trace_op set in ftrace_modify_all_code\n-\t *\n-\t * If we are in stop_machine, then we don't need to call remote fence\n-\t * as there is no concurrent read-side of ftrace_call_dest.\n \t */\n \tsmp_wmb();\n-\tif (!irqs_disabled())\n-\t\tsmp_call_function(ftrace_sync_ipi, NULL, 1);\n-\treturn 0;\n-}\n-\n-struct ftrace_modify_param {\n-\tint command;\n-\tatomic_t cpu_count;\n-};\n-\n-static int __ftrace_modify_code(void *data)\n-{\n-\tstruct ftrace_modify_param *param = data;\n-\n-\tif (atomic_inc_return(¶m->cpu_count) == num_online_cpus()) {\n-\t\tftrace_modify_all_code(param->command);\n-\t\t/*\n-\t\t * Make sure the patching store is effective *before* we\n-\t\t * increment the counter which releases all waiting CPUs\n-\t\t * by using the release variant of atomic increment. The\n-\t\t * release pairs with the call to local_flush_icache_all()\n-\t\t * on the waiting CPU.\n-\t\t */\n-\t\tatomic_inc_return_release(¶m->cpu_count);\n-\t} else {\n-\t\twhile (atomic_read(¶m->cpu_count) <= num_online_cpus())\n-\t\t\tcpu_relax();\n-\n-\t\tlocal_flush_icache_all();\n-\t}\n-\n+\t/*\n+\t * Updating ftrace dpes not take stop_machine path, so irqs should not\n+\t * be disabled.\n+\t */\n+\tWARN_ON(irqs_disabled());\n+\tsmp_call_function(ftrace_sync_ipi, NULL, 1);\n \treturn 0;\n }\n \n-void arch_ftrace_update_code(int command)\n-{\n-\tstruct ftrace_modify_param param = { command, ATOMIC_INIT(0) };\n-\n-\tstop_machine(__ftrace_modify_code, ¶m, cpu_online_mask);\n-}\n #else /* CONFIG_DYNAMIC_FTRACE */\n unsigned long ftrace_call_adjust(unsigned long addr)\n {",100 "prediction": "Given the following original C code:\n#ifdef CONFIG_DYNAMIC_FTRACE\nunsigned long ftrace_call_adjust(unsigned long addr)\n{\n\treturn addr + MCOUNT_AUIPC_SIZE;\n}\n\nunsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n{\n\treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n}\n\nvoid ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)\n{\n\tmutex_lock(&text_mutex);\n\n\t/*\n\t * The code sequences we use for ftrace can't be patched while the\n\t * kernel is running, so we need to use stop_machine() to modify them\n\t * for now. This doesn't play nice with text_mutex, we use this flag\n\nInstruction:\nriscv: ftrace: do not use stop_machine to update code\n\nReturn the diff that fixes it:\n @@ -13,13 +13,6 @@ unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n \treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n }\n \n-void ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)\n-{\n-\tmutex_lock(&text_mutex);\n-\n-\t/*\n-\t * The code sequences we use for ftrace can't be patched while the\n-\t * kernel is running, so we need to use stop_machine() to modify them\n-\t * for now. This doesn't play nice with text_mutex, we use this flag\n-\t * to avoid deadlocks.\n-\t */\n-\tftrace_modifying_code = 1;\n }\n \n void ftrace_arch_code_modify_post_stop(void) __releases(&text_mutex)\n@@ -29,7 +24,7 @@ void ftrace_arch_code_modify_post_"101 },102 {103 "prompt": "Given the following original C code:\n* Instead, the kernel set this bit field. Then the trap entry/exit code\n * knows if we are entering/exiting the context that owns preempt_v.\n * - 0: the task is not using preempt_v\n * - 1: the task is actively using preempt_v. But whether does the task own\n * the preempt_v context is decided by bits in RISCV_V_CTX_DEPTH_MASK.\n * - bit 16-23 are RISCV_V_CTX_DEPTH_MASK, used by context tracking routine\n * when preempt_v starts:\n * - 0: the task is actively using, and own preempt_v context.\n * - non-zero: the task was using preempt_v, but then took a trap within.\n * Thus, the task does not own preempt_v. Any use of Vector will have to\n * save preempt_v, if dirty, and fallback to non-preemptible kernel-mode\n * Vector.\n * - bit 30: The in-kernel preempt_v context is saved, and requries to be\n * restored when returning to the context that owns the preempt_v.\n * - bit 31: The in-kernel preempt_v context is dirty, as signaled by the\n * trap entry code. Any context switches out-of current task need to save\n * it to the task's in-kernel V context. Also, any traps nesting on-top-of\n * preempt_v requesting to use V needs a save.\n */\n#define RISCV_V_CTX_DEPTH_MASK\t\t0x00ff0000\n\nInstruction:\nriscv: vector: Support calling schedule() for preemptible Vector\n\nReturn the diff that fixes it:\n",104 "reference": "@@ -79,6 +79,10 @@ struct pt_regs;\n * Thus, the task does not own preempt_v. Any use of Vector will have to\n * save preempt_v, if dirty, and fallback to non-preemptible kernel-mode\n * Vector.\n+ * - bit 29: The thread voluntarily calls schedule() while holding an active\n+ * preempt_v. All preempt_v context should be dropped in such case because\n+ * V-regs are caller-saved. Only sstatus.VS=ON is persisted across a\n+ * schedule() call.\n * - bit 30: The in-kernel preempt_v context is saved, and requries to be\n * restored when returning to the context that owns the preempt_v.\n * - bit 31: The in-kernel preempt_v context is dirty, as signaled by the\n@@ -93,6 +97,7 @@ struct pt_regs;\n #define RISCV_PREEMPT_V\t\t\t0x00000100\n #define RISCV_PREEMPT_V_DIRTY\t\t0x80000000\n #define RISCV_PREEMPT_V_NEED_RESTORE\t0x40000000\n+#define RISCV_PREEMPT_V_IN_SCHEDULE\t0x20000000\n \n /* CPU-specific state of a task */\n struct thread_struct {",105 "prediction": "Given the following original C code:\n* Instead, the kernel set this bit field. Then the trap entry/exit code\n * knows if we are entering/exiting the context that owns preempt_v.\n * - 0: the task is not using preempt_v\n * - 1: the task is actively using preempt_v. But whether does the task own\n * the preempt_v context is decided by bits in RISCV_V_CTX_DEPTH_MASK.\n * - bit 16-23 are RISCV_V_CTX_DEPTH_MASK, used by context tracking routine\n * when preempt_v starts:\n * - 0: the task is actively using, and own preempt_v context.\n * - non-zero: the task was using preempt_v, but then took a trap within.\n * Thus, the task does not own preempt_v. Any use of Vector will have to\n * save preempt_v, if dirty, and fallback to non-preemptible kernel-mode\n * Vector.\n * - bit 30: The in-kernel preempt_v context is saved, and requries to be\n * restored when returning to the context that owns the preempt_v.\n * - bit 31: The in-kernel preempt_v context is dirty, as signaled by the\n * trap entry code. Any context switches out-of current task need to save\n * it to the task's in-kernel V context. Also, any traps nesting on-top-of\n * preempt_v requesting to use V needs a save.\n */\n#define RISCV_V_CTX_DEPTH_MASK\t\t0x00ff0000\n\nInstruction:\nriscv: vector: Support calling schedule() for preemptible Vector\n\nReturn the diff that fixes it:\n @@ -106,6 +106,10 @@\n * save preempt_v, if dirty, and fallback to non-preemptible kernel-mode\n * Vector.\n * - bit 30: The in-kernel preempt_v context is saved, and requries to be\n+ * restored when returning to the context that owns the preempt_v.\n+ * - bit 31: The in-kernel preempt_v context is dirty, as signaled by the\n+ * trap entry code. Any context switches out-of current task need to save\n+ * it to the task's in-kernel V context. Also, any traps nesting on-top-of\n * preempt_v requesting to use V needs a save.\n * - bit 30: The in-kernel preempt_v context is saved, and requries to be\n * restored when returning to the context that owns the preempt_v.\n@@ -113,6 +117,10 @@\n * - bit"106 },107 {108 "prompt": "Given the following original C code:\nelse\n\t\tcsr_set(CSR_SSTATUS, SR_VS);\n}\n\nstatic __always_inline void riscv_v_disable(void)\n{\n\tif (has_xtheadvector())\n\t\tcsr_clear(CSR_SSTATUS, SR_VS_THEAD);\n\telse\n\t\tcsr_clear(CSR_SSTATUS, SR_VS);\n}\n\nstatic __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest)\n{\n\tasm volatile (\n\t\t\"csrr\t%0, \" __stringify(CSR_VSTART) \"\\n\\t\"\n\t\t\"csrr\t%1, \" __stringify(CSR_VTYPE) \"\\n\\t\"\n\t\t\"csrr\t%2, \" __stringify(CSR_VL) \"\\n\\t\"\n\t\t: \"=r\" (dest->vstart), \"=r\" (dest->vtype), \"=r\" (dest->vl),\n\t\t\"=r\" (dest->vcsr) : :);\n\nInstruction:\nriscv: vector: Support calling schedule() for preemptible Vector\n\nReturn the diff that fixes it:\n",109 "reference": "@@ -120,6 +120,11 @@ static __always_inline void riscv_v_disable(void)\n \t\tcsr_clear(CSR_SSTATUS, SR_VS);\n }\n \n+static __always_inline bool riscv_v_is_on(void)\n+{\n+\treturn !!(csr_read(CSR_SSTATUS) & SR_VS);\n+}\n+\n static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest)\n {\n \tasm volatile (\n@@ -366,6 +371,11 @@ static inline void __switch_to_vector(struct task_struct *prev,\n \tstruct pt_regs *regs;\n \n \tif (riscv_preempt_v_started(prev)) {\n+\t\tif (riscv_v_is_on()) {\n+\t\t\tWARN_ON(prev->thread.riscv_v_flags & RISCV_V_CTX_DEPTH_MASK);\n+\t\t\triscv_v_disable();\n+\t\t\tprev->thread.riscv_v_flags |= RISCV_PREEMPT_V_IN_SCHEDULE;\n+\t\t}\n \t\tif (riscv_preempt_v_dirty(prev)) {\n \t\t\t__riscv_v_vstate_save(&prev->thread.kernel_vstate,\n \t\t\t\t\t prev->thread.kernel_vstate.datap);\n@@ -376,10 +386,16 @@ static inline void __switch_to_vector(struct task_struct *prev,\n \t\triscv_v_vstate_save(&prev->thread.vstate, regs);\n \t}\n \n-\tif (riscv_preempt_v_started(next))\n-\t\triscv_preempt_v_set_restore(next);\n-\telse\n+\tif (riscv_preempt_v_started(next)) {\n+\t\tif (next->thread.riscv_v_flags & RISCV_PREEMPT_V_IN_SCHEDULE) {\n+\t\t\tnext->thread.riscv_v_flags &= ~RISCV_PREEMPT_V_IN_SCHEDULE;\n+\t\t\triscv_v_enable();\n+\t\t} else {\n+\t\t\triscv_preempt_v_set_restore(next);\n+\t\t}\n+\t} else {\n \t\triscv_v_vstate_set_restore(next, task_pt_regs(next));\n+\t}\n }\n \n void riscv_v_vstate_ctrl_init(struct task_struct *tsk);",110 "prediction": "Given the following original C code:\nelse\n\t\tcsr_set(CSR_SSTATUS, SR_VS);\n}\n\nstatic __always_inline void riscv_v_disable(void)\n{\n\tif (has_xtheadvector())\n\t\tcsr_clear(CSR_SSTATUS, SR_VS_THEAD);\n\telse\n\t\tcsr_clear(CSR_SSTATUS, SR_VS);\n}\n\nstatic __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest)\n{\n\tasm volatile (\n\t\t\"csrr\t%0, \" __stringify(CSR_VSTART) \"\\n\\t\"\n\t\t\"csrr\t%1, \" __stringify(CSR_VTYPE) \"\\n\\t\"\n\t\t\"csrr\t%2, \" __stringify(CSR_VL) \"\\n\\t\"\n\t\t: \"=r\" (dest->vstart), \"=r\" (dest->vtype), \"=r\" (dest->vl),\n\t\t\"=r\" (dest->vcsr) : :);\n\nInstruction:\nriscv: vector: Support calling schedule() for preemptible Vector\n\nReturn the diff that fixes it:\n A @@ -103,10 +103,10 @@ static __always_inline void riscv_v_disable(void)\n \t\tcsr_clear(CSR_SSTATUS, SR_VS);\n }\n \n-static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest)\n+static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest,\n+\t\t\t\t\t struct pt_regs *regs)\n {\n \tasm volatile (\n-\t\t\"csrr\t%0, \" __stringify(CSR_VSTART) \"\\n\\t\"\n-\t\t\"csrr\t%1, \" __stringify(CSR_VTYPE) \"\\n\\t\"\n-\t\t\"csrr\t%2, \" __stringify(CSR_VL) \"\\n\\t\"\n+\t\t\"csrr\t%0, \" __stringify(CSR_VSTART) \"\\n\\t\"\n+\t\t\"csrr"111 },112 {113 "prompt": "Given the following original C code:\nstatic void ipi_remote_fence_i(void *info)\n{\n\treturn local_flush_icache_all();\n}\n\nvoid flush_icache_all(void)\n{\n\tlocal_flush_icache_all();\n\n\tif (num_online_cpus() < 2)\n\t\treturn;\n\telse if (riscv_use_sbi_for_rfence())\n\t\tsbi_remote_fence_i(NULL);\n\telse\n\t\ton_each_cpu(ipi_remote_fence_i, NULL, 1);\n}\nEXPORT_SYMBOL(flush_icache_all);\n\n/*\n\nInstruction:\nriscv: add a data fence for CMODX in the kernel mode\n\nReturn the diff that fixes it:\n",114 "reference": "@@ -24,7 +24,20 @@ void flush_icache_all(void)\n \n \tif (num_online_cpus() < 2)\n \t\treturn;\n-\telse if (riscv_use_sbi_for_rfence())\n+\n+\t/*\n+\t * Make sure all previous writes to the D$ are ordered before making\n+\t * the IPI. The RISC-V spec states that a hart must execute a data fence\n+\t * before triggering a remote fence.i in order to make the modification\n+\t * visable for remote harts.\n+\t *\n+\t * IPIs on RISC-V are triggered by MMIO writes to either CLINT or\n+\t * S-IMSIC, so the fence ensures previous data writes \"happen before\"\n+\t * the MMIO.\n+\t */\n+\tRISCV_FENCE(w, o);\n+\n+\tif (riscv_use_sbi_for_rfence())\n \t\tsbi_remote_fence_i(NULL);\n \telse\n \t\ton_each_cpu(ipi_remote_fence_i, NULL, 1);",115 "prediction": "Given the following original C code:\nstatic void ipi_remote_fence_i(void *info)\n{\n\treturn local_flush_icache_all();\n}\n\nvoid flush_icache_all(void)\n{\n\tlocal_flush_icache_all();\n\n\tif (num_online_cpus() < 2)\n\t\treturn;\n\telse if (riscv_use_sbi_for_rfence())\n\t\tsbi_remote_fence_i(NULL);\n\telse\n\t\ton_each_cpu(ipi_remote_fence_i, NULL, 1);\n}\nEXPORT_SYMBOL(flush_icache_all);\n\n/*\n\nInstruction:\nriscv: add a data fence for CMODX in the kernel mode\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ void flush_icache_all(void)\n \tif (num_online_cpus() < 2)\n \t\treturn;\n \telse if (riscv_use_sbi_for_rfence())\n-\t\tsbi_remote_fence_i(NULL);\n+\t\tsbi_remote_fence_d(NULL);\n \telse\n \t\ton_each_cpu(ipi_remote_fence_i, NULL, 1);\n }\n EXPORT_SYMBOL(flush_icache_all);\n@@ -111,7 +111,7 @@ void flush_icache_range(unsigned long start, unsigned long end)\n \tif (num_online_cpus() < 2)\n \t\treturn;\n \telse if (riscv_use_sbi_for_rfence())\n-\t\tsbi_remote_fence_i(NULL);\n+\t\tsbi_remote_fence_d(NULL);\n \telse"116 },117 {118 "prompt": "Given the following original C code:\n* We allocate a pt_regs on the stack when entering the kernel. This\n\t * ensures the alignment is sane.\n\t */\n\tDEFINE(PT_SIZE_ON_STACK, ALIGN(sizeof(struct pt_regs), STACK_ALIGN));\n\n\tOFFSET(KERNEL_MAP_VIRT_ADDR, kernel_mapping, virt_addr);\n\tOFFSET(SBI_HART_BOOT_TASK_PTR_OFFSET, sbi_hart_boot_data, task_ptr);\n\tOFFSET(SBI_HART_BOOT_STACK_PTR_OFFSET, sbi_hart_boot_data, stack_ptr);\n\n\tDEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));\n\tOFFSET(STACKFRAME_FP, stackframe, fp);\n\tOFFSET(STACKFRAME_RA, stackframe, ra);\n\n#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n\tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));\n\tDEFINE(FREGS_EPC,\t offsetof(struct __arch_ftrace_regs, epc));\n\tDEFINE(FREGS_RA,\t offsetof(struct __arch_ftrace_regs, ra));\n\tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n\tDEFINE(FREGS_S0,\t offsetof(struct __arch_ftrace_regs, s0));\n\tDEFINE(FREGS_T1,\t offsetof(struct __arch_ftrace_regs, t1));\n\nInstruction:\nriscv: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS\n\nReturn the diff that fixes it:\n",119 "reference": "@@ -493,6 +493,9 @@ void asm_offsets(void)\n \tDEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));\n \tOFFSET(STACKFRAME_FP, stackframe, fp);\n \tOFFSET(STACKFRAME_RA, stackframe, ra);\n+#ifdef CONFIG_FUNCTION_TRACER\n+\tDEFINE(FTRACE_OPS_FUNC,\t\toffsetof(struct ftrace_ops, func));\n+#endif\n \n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n \tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));",120 "prediction": "Given the following original C code:\n* We allocate a pt_regs on the stack when entering the kernel. This\n\t * ensures the alignment is sane.\n\t */\n\tDEFINE(PT_SIZE_ON_STACK, ALIGN(sizeof(struct pt_regs), STACK_ALIGN));\n\n\tOFFSET(KERNEL_MAP_VIRT_ADDR, kernel_mapping, virt_addr);\n\tOFFSET(SBI_HART_BOOT_TASK_PTR_OFFSET, sbi_hart_boot_data, task_ptr);\n\tOFFSET(SBI_HART_BOOT_STACK_PTR_OFFSET, sbi_hart_boot_data, stack_ptr);\n\n\tDEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));\n\tOFFSET(STACKFRAME_FP, stackframe, fp);\n\tOFFSET(STACKFRAME_RA, stackframe, ra);\n\n#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n\tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));\n\tDEFINE(FREGS_EPC,\t offsetof(struct __arch_ftrace_regs, epc));\n\tDEFINE(FREGS_RA,\t offsetof(struct __arch_ftrace_regs, ra));\n\tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n\tDEFINE(FREGS_S0,\t offsetof(struct __arch_ftrace_regs, s0));\n\tDEFINE(FREGS_T1,\t offsetof(struct __arch_ftrace_regs, t1));\n\nInstruction:\nriscv: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS\n\nReturn the diff that fixes it:\n @@ -101,6 +101,12 @@ int main(void)\n \tDEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));\n \tOFFSET(STACKFRAME_FP, stackframe, fp);\n \tOFFSET(STACKFRAME_RA, stackframe, ra);\n+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n+\tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));\n+\tDEFINE(FREGS_EPC,\t offsetof(struct __arch_ftrace_regs, epc));\n+\tDEFINE(FREGS_RA,\t offsetof(struct __arch_ftrace_regs, ra));\n+\tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n+\tDEFINE(FRE"121 },122 {123 "prompt": "Given the following original C code:\n#include <linux/ftrace.h>\n#include <linux/uaccess.h>\n#include <linux/memory.h>\n#include <linux/irqflags.h>\n#include <linux/stop_machine.h>\n#include <asm/cacheflush.h>\n#include <asm/text-patching.h>\n\n#ifdef CONFIG_DYNAMIC_FTRACE\nunsigned long ftrace_call_adjust(unsigned long addr)\n{\n\treturn addr + MCOUNT_AUIPC_SIZE;\n}\n\nunsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n{\n\treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n}\n\nInstruction:\nriscv: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS\n\nReturn the diff that fixes it:\n",124 "reference": "@@ -16,6 +16,9 @@\n #ifdef CONFIG_DYNAMIC_FTRACE\n unsigned long ftrace_call_adjust(unsigned long addr)\n {\n+\tif (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))\n+\t\treturn addr + 8;\n+\n \treturn addr + MCOUNT_AUIPC_SIZE;\n }\n \n@@ -64,9 +67,52 @@ static int __ftrace_modify_call(unsigned long source, unsigned long target, bool\n \treturn 0;\n }\n \n+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS\n+static const struct ftrace_ops *riscv64_rec_get_ops(struct dyn_ftrace *rec)\n+{\n+\tconst struct ftrace_ops *ops = NULL;\n+\n+\tif (rec->flags & FTRACE_FL_CALL_OPS_EN) {\n+\t\tops = ftrace_find_unique_ops(rec);\n+\t\tWARN_ON_ONCE(!ops);\n+\t}\n+\n+\tif (!ops)\n+\t\tops = &ftrace_list_ops;\n+\n+\treturn ops;\n+}\n+\n+static int ftrace_rec_set_ops(const struct dyn_ftrace *rec,\n+\t\t\t const struct ftrace_ops *ops)\n+{\n+\tunsigned long literal = rec->ip - 8;\n+\n+\treturn patch_text_nosync((void *)literal, &ops, sizeof(ops));\n+}\n+\n+static int ftrace_rec_set_nop_ops(struct dyn_ftrace *rec)\n+{\n+\treturn ftrace_rec_set_ops(rec, &ftrace_nop_ops);\n+}\n+\n+static int ftrace_rec_update_ops(struct dyn_ftrace *rec)\n+{\n+\treturn ftrace_rec_set_ops(rec, riscv64_rec_get_ops(rec));\n+}\n+#else\n+static int ftrace_rec_set_nop_ops(struct dyn_ftrace *rec) { return 0; }\n+static int ftrace_rec_update_ops(struct dyn_ftrace *rec) { return 0; }\n+#endif\n+\n int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)\n {\n \tunsigned long distance, orig_addr, pc = rec->ip - MCOUNT_AUIPC_SIZE;\n+\tint ret;\n+\n+\tret = ftrace_rec_update_ops(rec);\n+\tif (ret)\n+\t\treturn ret;\n \n \torig_addr = (unsigned long)&ftrace_caller;\n \tdistance = addr > orig_addr ? addr - orig_addr : orig_addr - addr;\n@@ -79,6 +125,11 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)\n int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr)\n {\n \tu32 nop4 = RISCV_INSN_NOP4;\n+\tint ret;\n+\n+\tret = ftrace_rec_set_nop_ops(rec);\n+\tif (ret)\n+\t\treturn ret;\n \n \tif (patch_insn_write((void *)rec->ip, &nop4, MCOUNT_NOP4_SIZE))\n \t\treturn -EPERM;\n@@ -99,6 +150,10 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)\n \tunsigned int nops[2], offset;\n \tint ret;\n \n+\tret = ftrace_rec_set_nop_ops(rec);\n+\tif (ret)\n+\t\treturn ret;\n+\n \toffset = (unsigned long) &ftrace_caller - pc;\n \tnops[0] = to_auipc_t0(offset);\n \tnops[1] = RISCV_INSN_NOP4;\n@@ -113,6 +168,13 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)\n ftrace_func_t ftrace_call_dest = ftrace_stub;\n int ftrace_update_ftrace_func(ftrace_func_t func)\n {\n+\t/*\n+\t * When using CALL_OPS, the function to call is associated with the\n+\t * call site, and we don't have a global function pointer to update.\n+\t */\n+\tif (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))\n+\t\treturn 0;\n+\n \tWRITE_ONCE(ftrace_call_dest, func);\n \t/*\n \t * The data fence ensure that the update to ftrace_call_dest happens\n@@ -143,8 +205,13 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,\n {\n \tunsigned long caller = rec->ip - MCOUNT_AUIPC_SIZE;\n \tunsigned int call[2];\n+\tint ret;\n \n \tmake_call_t0(caller, old_addr, call);\n+\tret = ftrace_rec_update_ops(rec);\n+\tif (ret)\n+\t\treturn ret;\n+\n \treturn __ftrace_modify_call(caller, addr, true);\n }\n #endif",125 "prediction": "Given the following original C code:\n#include <linux/ftrace.h>\n#include <linux/uaccess.h>\n#include <linux/memory.h>\n#include <linux/irqflags.h>\n#include <linux/stop_machine.h>\n#include <asm/cacheflush.h>\n#include <asm/text-patching.h>\n\n#ifdef CONFIG_DYNAMIC_FTRACE\nunsigned long ftrace_call_adjust(unsigned long addr)\n{\n\treturn addr + MCOUNT_AUIPC_SIZE;\n}\n\nunsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n{\n\treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n}\n\nInstruction:\nriscv: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS\n\nReturn the diff that fixes it:\n @@ -10,10 +10,6 @@\n #ifdef CONFIG_DYNAMIC_FTRACE\n unsigned long ftrace_call_adjust(unsigned long addr)\n {\n-\treturn addr + MCOUNT_AUIPC_SIZE;\n-}\n-\n-unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n-{\n-\treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n-}\n #endif\n \n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS\n@@ -19,6 +15,7 @@ unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n \treturn fentry_ip;\n }\n \n+#define HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS\n #endif\n \n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS\n@@ -28,6 +26,7"126 },127 {128 "prompt": "Given the following original C code:\n#define arch_ftrace_get_regs(regs) NULL\n#define HAVE_ARCH_FTRACE_REGS\nstruct ftrace_ops;\nstruct ftrace_regs;\n#define arch_ftrace_regs(fregs) ((struct __arch_ftrace_regs *)(fregs))\n\nstruct __arch_ftrace_regs {\n\tunsigned long epc;\n\tunsigned long ra;\n\tunsigned long sp;\n\tunsigned long s0;\n\tunsigned long t1;\n\tunion {\n\t\tunsigned long args[8];\n\t\tstruct {\n\t\t\tunsigned long a0;\n\t\t\tunsigned long a1;\n\t\t\tunsigned long a2;\n\t\t\tunsigned long a3;\n\t\t\tunsigned long a4;\n\nInstruction:\nriscv: ftrace: support direct call using call_ops\n\nReturn the diff that fixes it:\n",129 "reference": "@@ -130,6 +130,9 @@ struct __arch_ftrace_regs {\n \tunsigned long sp;\n \tunsigned long s0;\n \tunsigned long t1;\n+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS\n+\tunsigned long direct_tramp;\n+#endif\n \tunion {\n \t\tunsigned long args[8];\n \t\tstruct {\n@@ -223,10 +226,13 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,\n \t\t struct ftrace_ops *op, struct ftrace_regs *fregs);\n #define ftrace_graph_func ftrace_graph_func\n \n+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS\n static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsigned long addr)\n {\n \tarch_ftrace_regs(fregs)->t1 = addr;\n }\n+#endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */\n+\n #endif /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */\n \n #endif /* __ASSEMBLY__ */",130 "prediction": "Given the following original C code:\n#define arch_ftrace_get_regs(regs) NULL\n#define HAVE_ARCH_FTRACE_REGS\nstruct ftrace_ops;\nstruct ftrace_regs;\n#define arch_ftrace_regs(fregs) ((struct __arch_ftrace_regs *)(fregs))\n\nstruct __arch_ftrace_regs {\n\tunsigned long epc;\n\tunsigned long ra;\n\tunsigned long sp;\n\tunsigned long s0;\n\tunsigned long t1;\n\tunion {\n\t\tunsigned long args[8];\n\t\tstruct {\n\t\t\tunsigned long a0;\n\t\t\tunsigned long a1;\n\t\t\tunsigned long a2;\n\t\t\tunsigned long a3;\n\t\t\tunsigned long a4;\n\nInstruction:\nriscv: ftrace: support direct call using call_ops\n\nReturn the diff that fixes it:\n @@ -16,6 +16,7 @@ struct __arch_ftrace_regs {\n \tunsigned long ra;\n \tunsigned long sp;\n \tunsigned long s0;\n+\tunsigned long t0;\n \tunsigned long t1;\n \tunion {\n \t\tunsigned long args[8];\n@@ -24,6 +25,7 @@ struct __arch_ftrace_regs {\n \t\t\tunsigned long a0;\n \t\t\tunsigned long a1;\n \t\t\tunsigned long a2;\n+\t\t\tunsigned long a3;\n \t\t\tunsigned long a4;\n \t\t\tunsigned long a5;\n \t\t\tunsigned long a6;\n@@ -32,6 +34,7 @@ struct __arch_ftrace_regs {\n \t\t\tunsigned long a7;\n \t\t\tunsigned long a8;\n \t\t\tunsigned long a9;\n+\t\t\tunsigned long a10;\n \t\t\tunsigned long a11;\n \t\t\tunsigned long a"131 },132 {133 "prompt": "Given the following original C code:\n*/\n\tDEFINE(PT_SIZE_ON_STACK, ALIGN(sizeof(struct pt_regs), STACK_ALIGN));\n\n\tOFFSET(KERNEL_MAP_VIRT_ADDR, kernel_mapping, virt_addr);\n\tOFFSET(SBI_HART_BOOT_TASK_PTR_OFFSET, sbi_hart_boot_data, task_ptr);\n\tOFFSET(SBI_HART_BOOT_STACK_PTR_OFFSET, sbi_hart_boot_data, stack_ptr);\n\n\tDEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));\n\tOFFSET(STACKFRAME_FP, stackframe, fp);\n\tOFFSET(STACKFRAME_RA, stackframe, ra);\n#ifdef CONFIG_FUNCTION_TRACER\n\tDEFINE(FTRACE_OPS_FUNC,\t\toffsetof(struct ftrace_ops, func));\n#endif\n\n#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n\tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));\n\tDEFINE(FREGS_EPC,\t offsetof(struct __arch_ftrace_regs, epc));\n\tDEFINE(FREGS_RA,\t offsetof(struct __arch_ftrace_regs, ra));\n\tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n\tDEFINE(FREGS_S0,\t offsetof(struct __arch_ftrace_regs, s0));\n\nInstruction:\nriscv: ftrace: support direct call using call_ops\n\nReturn the diff that fixes it:\n",134 "reference": "@@ -495,6 +495,9 @@ void asm_offsets(void)\n \tOFFSET(STACKFRAME_RA, stackframe, ra);\n #ifdef CONFIG_FUNCTION_TRACER\n \tDEFINE(FTRACE_OPS_FUNC,\t\toffsetof(struct ftrace_ops, func));\n+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS\n+\tDEFINE(FTRACE_OPS_DIRECT_CALL,\toffsetof(struct ftrace_ops, direct_call));\n+#endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */\n #endif\n \n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS",135 "prediction": "Given the following original C code:\n*/\n\tDEFINE(PT_SIZE_ON_STACK, ALIGN(sizeof(struct pt_regs), STACK_ALIGN));\n\n\tOFFSET(KERNEL_MAP_VIRT_ADDR, kernel_mapping, virt_addr);\n\tOFFSET(SBI_HART_BOOT_TASK_PTR_OFFSET, sbi_hart_boot_data, task_ptr);\n\tOFFSET(SBI_HART_BOOT_STACK_PTR_OFFSET, sbi_hart_boot_data, stack_ptr);\n\n\tDEFINE(STACKFRAME_SIZE_ON_STACK, ALIGN(sizeof(struct stackframe), STACK_ALIGN));\n\tOFFSET(STACKFRAME_FP, stackframe, fp);\n\tOFFSET(STACKFRAME_RA, stackframe, ra);\n#ifdef CONFIG_FUNCTION_TRACER\n\tDEFINE(FTRACE_OPS_FUNC,\t\toffsetof(struct ftrace_ops, func));\n#endif\n\n#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n\tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));\n\tDEFINE(FREGS_EPC,\t offsetof(struct __arch_ftrace_regs, epc));\n\tDEFINE(FREGS_RA,\t offsetof(struct __arch_ftrace_regs, ra));\n\tDEFINE(FREGS_SP,\t offsetof(struct __arch_ftrace_regs, sp));\n\tDEFINE(FREGS_S0,\t offsetof(struct __arch_ftrace_regs, s0));\n\nInstruction:\nriscv: ftrace: support direct call using call_ops\n\nReturn the diff that fixes it:\n @@ -101,6 +101,10 @@ void __init riscv_init_offsets(void)\n \tOFFSET(STACKFRAME_RA, stackframe, ra);\n #ifdef CONFIG_FUNCTION_TRACER\n \tDEFINE(FTRACE_OPS_FUNC,\t\toffsetof(struct ftrace_ops, func));\n+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n+\tDEFINE(FTRACE_OPS_CALLER,\toffsetof(struct ftrace_ops, caller));\n+#endif\n+#endif\n \n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS\n \tDEFINE(FREGS_SIZE_ON_STACK, ALIGN(sizeof(struct __arch_ftrace_regs), STACK_ALIGN));\n@@ -109,6 +113,10 @@ void __init riscv_init_offsets(void)\n \tDEFINE(FREGS_"136 },137 {138 "prompt": "Given the following original C code:\n#include <linux/ftrace.h>\n#include <linux/uaccess.h>\n#include <linux/memory.h>\n#include <linux/irqflags.h>\n#include <linux/stop_machine.h>\n#include <asm/cacheflush.h>\n#include <asm/text-patching.h>\n\n#ifdef CONFIG_DYNAMIC_FTRACE\nunsigned long ftrace_call_adjust(unsigned long addr)\n{\n\tif (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))\n\t\treturn addr + 8;\n\n\treturn addr + MCOUNT_AUIPC_SIZE;\n}\n\nunsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n{\n\treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n\nInstruction:\nriscv: ftrace: support direct call using call_ops\n\nReturn the diff that fixes it:\n",139 "reference": "@@ -17,7 +17,7 @@\n unsigned long ftrace_call_adjust(unsigned long addr)\n {\n \tif (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))\n-\t\treturn addr + 8;\n+\t\treturn addr + 8 + MCOUNT_AUIPC_SIZE;\n \n \treturn addr + MCOUNT_AUIPC_SIZE;\n }\n@@ -83,10 +83,9 @@ static const struct ftrace_ops *riscv64_rec_get_ops(struct dyn_ftrace *rec)\n \treturn ops;\n }\n \n-static int ftrace_rec_set_ops(const struct dyn_ftrace *rec,\n-\t\t\t const struct ftrace_ops *ops)\n+static int ftrace_rec_set_ops(const struct dyn_ftrace *rec, const struct ftrace_ops *ops)\n {\n-\tunsigned long literal = rec->ip - 8;\n+\tunsigned long literal = ALIGN_DOWN(rec->ip - 12, 8);\n \n \treturn patch_text_nosync((void *)literal, &ops, sizeof(ops));\n }\n@@ -117,7 +116,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)\n \torig_addr = (unsigned long)&ftrace_caller;\n \tdistance = addr > orig_addr ? addr - orig_addr : orig_addr - addr;\n \tif (distance > JALR_RANGE)\n-\t\treturn -EINVAL;\n+\t\taddr = FTRACE_ADDR;\n \n \treturn __ftrace_modify_call(pc, addr, false);\n }\n@@ -204,15 +203,13 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,\n \t\t unsigned long addr)\n {\n \tunsigned long caller = rec->ip - MCOUNT_AUIPC_SIZE;\n-\tunsigned int call[2];\n \tint ret;\n \n-\tmake_call_t0(caller, old_addr, call);\n \tret = ftrace_rec_update_ops(rec);\n \tif (ret)\n \t\treturn ret;\n \n-\treturn __ftrace_modify_call(caller, addr, true);\n+\treturn __ftrace_modify_call(caller, FTRACE_ADDR, true);\n }\n #endif",140 "prediction": "Given the following original C code:\n#include <linux/ftrace.h>\n#include <linux/uaccess.h>\n#include <linux/memory.h>\n#include <linux/irqflags.h>\n#include <linux/stop_machine.h>\n#include <asm/cacheflush.h>\n#include <asm/text-patching.h>\n\n#ifdef CONFIG_DYNAMIC_FTRACE\nunsigned long ftrace_call_adjust(unsigned long addr)\n{\n\tif (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))\n\t\treturn addr + 8;\n\n\treturn addr + MCOUNT_AUIPC_SIZE;\n}\n\nunsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n{\n\treturn fentry_ip - MCOUNT_AUIPC_SIZE;\n\nInstruction:\nriscv: ftrace: support direct call using call_ops\n\nReturn the diff that fixes it:\n @@ -11,10 +11,10 @@\n #ifdef CONFIG_DYNAMIC_FTRACE\n unsigned long ftrace_call_adjust(unsigned long addr)\n {\n-\tif (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))\n-\t\treturn addr + 8;\n+\tif (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))\n+\t\treturn addr;\n \n \treturn addr + MCOUNT_AUIPC_SIZE;\n }\n \n-unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n+unsigned long arch_ftrace_get_symaddr(unsigned long addr)\n {\n \treturn addr - MCOUNT_AUIPC_SIZE;\n }\n@@ -22,6 +22,10 @@ unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n \treturn addr;\n }\n \n+"141 },142 {143 "prompt": "Given the following original C code:\n/* String & section header string table */\n\tsechdrs = (void *)pi->ehdr + pi->ehdr->e_shoff;\n\tstrtab = (char *)pi->ehdr + sechdrs[symtab->sh_link].sh_offset;\n\tshstrtab = (char *)pi->ehdr + sechdrs[pi->ehdr->e_shstrndx].sh_offset;\n\n\trelas = (void *)pi->ehdr + relsec->sh_offset;\n\n\tfor (i = 0; i < relsec->sh_size / sizeof(*relas); i++) {\n\t\tconst Elf_Sym *sym;\t/* symbol to relocate */\n\t\tunsigned long addr;\t/* final location after relocation */\n\t\tunsigned long val;\t/* relocated symbol value */\n\t\tunsigned long sec_base;\t/* relocated symbol value */\n\t\tvoid *loc;\t\t/* tmp location to modify */\n\n\t\tsym = (void *)pi->ehdr + symtab->sh_offset;\n\t\tsym += ELF64_R_SYM(relas[i].r_info);\n\n\t\tif (sym->st_name)\n\t\t\tname = strtab + sym->st_name;\n\nInstruction:\nriscv/kexec_file: Fix comment in purgatory relocator\n\nReturn the diff that fixes it:\n",144 "reference": "@@ -390,7 +390,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,\n \t\tconst Elf_Sym *sym;\t/* symbol to relocate */\n \t\tunsigned long addr;\t/* final location after relocation */\n \t\tunsigned long val;\t/* relocated symbol value */\n-\t\tunsigned long sec_base;\t/* relocated symbol value */\n+\t\tunsigned long sec_base;\t/* relocated section base address */\n \t\tvoid *loc;\t\t/* tmp location to modify */\n \n \t\tsym = (void *)pi->ehdr + symtab->sh_offset;",145 "prediction": "Given the following original C code:\n/* String & section header string table */\n\tsechdrs = (void *)pi->ehdr + pi->ehdr->e_shoff;\n\tstrtab = (char *)pi->ehdr + sechdrs[symtab->sh_link].sh_offset;\n\tshstrtab = (char *)pi->ehdr + sechdrs[pi->ehdr->e_shstrndx].sh_offset;\n\n\trelas = (void *)pi->ehdr + relsec->sh_offset;\n\n\tfor (i = 0; i < relsec->sh_size / sizeof(*relas); i++) {\n\t\tconst Elf_Sym *sym;\t/* symbol to relocate */\n\t\tunsigned long addr;\t/* final location after relocation */\n\t\tunsigned long val;\t/* relocated symbol value */\n\t\tunsigned long sec_base;\t/* relocated symbol value */\n\t\tvoid *loc;\t\t/* tmp location to modify */\n\n\t\tsym = (void *)pi->ehdr + symtab->sh_offset;\n\t\tsym += ELF64_R_SYM(relas[i].r_info);\n\n\t\tif (sym->st_name)\n\t\t\tname = strtab + sym->st_name;\n\nInstruction:\nriscv/kexec_file: Fix comment in purgatory relocator\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int relocate_purgatory(struct kimage *image,\n \t\tconst Elf_Sym *sym;\t/* symbol to relocate */\n \t\tunsigned long addr;\t/* final location after relocation */\n \t\tunsigned long val;\t/* relocated symbol value */\n-\t\tunsigned long sec_base;\t/* relocated symbol value */\n+\t\tunsigned long sec_base;\t/* relocated symbol value, or 0 */\n \t\tvoid *loc;\t\t/* tmp location to modify */\n \n \t\tsym = (void *)pi->ehdr + symtab->sh_offset;\n@@ -116,7 +116,7 @@ static int relocate_purgatory(struct kimage *image,\n \t\tif (sym->st_name)\n \t\t\tname = strtab + sym->st_name;\n \n-\t\tif (sym->st_shndx == SHN_UNDEF)\n+\t\tif (sym->st_shndx"146 },147 {148 "prompt": "Given the following original C code:\n/* SPDX-License-Identifier: GPL-2.0\n *\n * Copyright (C) 2014-2017 Linaro Ltd. <ard.biesheuvel@linaro.org>\n *\n * Copyright (C) 2018 Andes Technology Corporation <zong@andestech.com>\n */\n\n#include <linux/elf.h>\n#include <linux/kernel.h>\n#include <linux/module.h>\n#include <linux/moduleloader.h>\n\nunsigned long module_emit_got_entry(struct module *mod, unsigned long val)\n{\n\tstruct mod_section *got_sec = &mod->arch.got;\n\tint i = got_sec->num_entries;\n\tstruct got_entry *got = get_got_entry(val, got_sec);\n\n\tif (got)\n\nInstruction:\nriscv: module: Optimize PLT/GOT entry counting\n\nReturn the diff that fixes it:\n",149 "reference": "@@ -9,6 +9,7 @@\n #include <linux/kernel.h>\n #include <linux/module.h>\n #include <linux/moduleloader.h>\n+#include <linux/sort.h>\n \n unsigned long module_emit_got_entry(struct module *mod, unsigned long val)\n {\n@@ -55,44 +56,70 @@ unsigned long module_emit_plt_entry(struct module *mod, unsigned long val)\n \treturn (unsigned long)&plt[i];\n }\n \n-static int is_rela_equal(const Elf_Rela *x, const Elf_Rela *y)\n+#define cmp_3way(a, b)\t((a) < (b) ? -1 : (a) > (b))\n+\n+static int cmp_rela(const void *a, const void *b)\n {\n-\treturn x->r_info == y->r_info && x->r_addend == y->r_addend;\n+\tconst Elf_Rela *x = a, *y = b;\n+\tint i;\n+\n+\t/* sort by type, symbol index and addend */\n+\ti = cmp_3way(x->r_info, y->r_info);\n+\tif (i == 0)\n+\t\ti = cmp_3way(x->r_addend, y->r_addend);\n+\treturn i;\n }\n \n static bool duplicate_rela(const Elf_Rela *rela, int idx)\n {\n-\tint i;\n-\tfor (i = 0; i < idx; i++) {\n-\t\tif (is_rela_equal(&rela[i], &rela[idx]))\n-\t\t\treturn true;\n-\t}\n-\treturn false;\n+\t/*\n+\t * Entries are sorted by type, symbol index and addend. That means\n+\t * that, if a duplicate entry exists, it must be in the preceding slot.\n+\t */\n+\treturn idx > 0 && cmp_rela(rela + idx, rela + idx - 1) == 0;\n }\n \n-static void count_max_entries(Elf_Rela *relas, int num,\n+static void count_max_entries(const Elf_Rela *relas, size_t num,\n \t\t\t unsigned int *plts, unsigned int *gots)\n {\n-\tfor (int i = 0; i < num; i++) {\n+\tfor (size_t i = 0; i < num; i++) {\n+\t\tif (duplicate_rela(relas, i))\n+\t\t\tcontinue;\n+\n \t\tswitch (ELF_R_TYPE(relas[i].r_info)) {\n \t\tcase R_RISCV_CALL_PLT:\n \t\tcase R_RISCV_PLT32:\n-\t\t\tif (!duplicate_rela(relas, i))\n-\t\t\t\t(*plts)++;\n+\t\t\t(*plts)++;\n \t\t\tbreak;\n \t\tcase R_RISCV_GOT_HI20:\n-\t\t\tif (!duplicate_rela(relas, i))\n-\t\t\t\t(*gots)++;\n+\t\t\t(*gots)++;\n \t\t\tbreak;\n+\t\tdefault:\n+\t\t\tunreachable();\n \t\t}\n \t}\n }\n \n+static bool rela_needs_plt_got_entry(const Elf_Rela *rela)\n+{\n+\tswitch (ELF_R_TYPE(rela->r_info)) {\n+\tcase R_RISCV_CALL_PLT:\n+\tcase R_RISCV_GOT_HI20:\n+\tcase R_RISCV_PLT32:\n+\t\treturn true;\n+\tdefault:\n+\t\treturn false;\n+\t}\n+}\n+\n int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,\n \t\t\t char *secstrings, struct module *mod)\n {\n+\tsize_t num_scratch_relas = 0;\n \tunsigned int num_plts = 0;\n \tunsigned int num_gots = 0;\n+\tElf_Rela *scratch = NULL;\n+\tsize_t scratch_size = 0;\n \tint i;\n \n \t/*\n@@ -122,9 +149,10 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,\n \n \t/* Calculate the maxinum number of entries */\n \tfor (i = 0; i < ehdr->e_shnum; i++) {\n+\t\tsize_t num_relas = sechdrs[i].sh_size / sizeof(Elf_Rela);\n \t\tElf_Rela *relas = (void *)ehdr + sechdrs[i].sh_offset;\n-\t\tint num_rela = sechdrs[i].sh_size / sizeof(Elf_Rela);\n \t\tElf_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info;\n+\t\tsize_t scratch_size_needed;\n \n \t\tif (sechdrs[i].sh_type != SHT_RELA)\n \t\t\tcontinue;\n@@ -133,7 +161,28 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,\n \t\tif (!(dst_sec->sh_flags & SHF_EXECINSTR))\n \t\t\tcontinue;\n \n-\t\tcount_max_entries(relas, num_rela, &num_plts, &num_gots);\n+\t\t/*\n+\t\t * apply_relocate_add() relies on HI20 and LO12 relocation pairs being\n+\t\t * close together, so sort a copy of the section to avoid interfering.\n+\t\t */\n+\t\tscratch_size_needed = (num_scratch_relas + num_relas) * sizeof(*scratch);\n+\t\tif (scratch_size_needed > scratch_size) {\n+\t\t\tscratch_size = scratch_size_needed;\n+\t\t\tscratch = kvrealloc(scratch, scratch_size, GFP_KERNEL);\n+\t\t\tif (!scratch)\n+\t\t\t\treturn -ENOMEM;\n+\t\t}\n+\n+\t\tfor (size_t j = 0; j < num_relas; j++)\n+\t\t\tif (rela_needs_plt_got_entry(&relas[j]))\n+\t\t\t\tscratch[num_scratch_relas++] = relas[j];\n+\t}\n+\n+\tif (scratch) {\n+\t\t/* sort the accumulated PLT/GOT relocations so duplicates are adjacent */\n+\t\tsort(scratch, num_scratch_relas, sizeof(*scratch), cmp_rela, NULL);\n+\t\tcount_max_entries(scratch, num_scratch_relas, &num_plts, &num_gots);\n+\t\tkvfree(scratch);\n \t}\n \n \tmod->arch.plt.shdr->sh_type = SHT_NOBITS;",150 "prediction": "Given the following original C code:\n/* SPDX-License-Identifier: GPL-2.0\n *\n * Copyright (C) 2014-2017 Linaro Ltd. <ard.biesheuvel@linaro.org>\n *\n * Copyright (C) 2018 Andes Technology Corporation <zong@andestech.com>\n */\n\n#include <linux/elf.h>\n#include <linux/kernel.h>\n#include <linux/module.h>\n#include <linux/moduleloader.h>\n\nunsigned long module_emit_got_entry(struct module *mod, unsigned long val)\n{\n\tstruct mod_section *got_sec = &mod->arch.got;\n\tint i = got_sec->num_entries;\n\tstruct got_entry *got = get_got_entry(val, got_sec);\n\n\tif (got)\n\nInstruction:\nriscv: module: Optimize PLT/GOT entry counting\n\nReturn the diff that fixes it:\n @@ -7,7 +7,7 @@\n #include <linux/elf.h>\n #include <linux/kernel.h>\n #include <linux/module.h>\n-#include <linux/moduleloader.h>\n+#include <linux/moduleloader-riscv.h>\n \n unsigned long module_emit_got_entry(struct module *mod, unsigned long val)\n {\n@@ -18,10 +18,10 @@ unsigned long module_emit_got_entry(struct module *mod, unsigned long val)\n \tstruct got_entry *got = get_got_entry(val, got_sec);\n \n \tif (got)\n-\t\treturn got_sec->num_entries;\n+\t\treturn got - got_sec->entries;\n \n \tgot_sec->num_entries++;\n \n-\treturn got_sec->num_entries - 1;\n+\treturn got - got_sec->entries;\n }\n EXPORT_SYMBOL_GPL(module_emit_got_entry);\n \n@@ -31"151 },152 {153 "prompt": "Given the following original C code:\n: \"m\" (__ptr[__LSW]), \"m\" (__ptr[__MSW]));\t\\\n\tif (__gu8_err) {\t\t\t\t\t\\\n\t\t__hi = 0;\t\t\t\t\t\\\n\t\tgoto label;\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\\\n\t(x) = (__typeof__(x))((__typeof__((x) - (x)))(\t\t\\\n\t\t(((u64)__hi << 32) | __lo)));\t\t\t\\\n} while (0)\n#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */\n\n#endif /* CONFIG_64BIT */\n\n#define __get_user_nocheck(x, __gu_ptr, label)\t\t\t\\\ndo {\t\t\t\t\t\t\t\t\\\n\tswitch (sizeof(*__gu_ptr)) {\t\t\t\t\\\n\tcase 1:\t\t\t\t\t\t\t\\\n\t\t__get_user_asm(\"lb\", (x), __gu_ptr, label);\t\\\n\t\tbreak;\t\t\t\t\t\t\\\n\tcase 2:\t\t\t\t\t\t\t\\\n\t\t__get_user_asm(\"lh\", (x), __gu_ptr, label);\t\\\n\nInstruction:\nriscv: uaccess: do not do misaligned accesses in get/put_user()\n\nReturn the diff that fixes it:\n",154 "reference": "@@ -169,8 +169,19 @@ do {\t\t\t\t\t\t\t\t\\\n \n #endif /* CONFIG_64BIT */\n \n+unsigned long __must_check __asm_copy_to_user_sum_enabled(void __user *to,\n+\tconst void *from, unsigned long n);\n+unsigned long __must_check __asm_copy_from_user_sum_enabled(void *to,\n+\tconst void __user *from, unsigned long n);\n+\n #define __get_user_nocheck(x, __gu_ptr, label)\t\t\t\\\n do {\t\t\t\t\t\t\t\t\\\n+\tif (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) &&\t\\\n+\t !IS_ALIGNED((uintptr_t)__gu_ptr, sizeof(*__gu_ptr))) {\t\\\n+\t\tif (__asm_copy_from_user_sum_enabled(&(x), __gu_ptr, sizeof(*__gu_ptr))) \\\n+\t\t\tgoto label;\t\t\t\t\\\n+\t\tbreak;\t\t\t\t\t\t\\\n+\t}\t\t\t\t\t\t\t\\\n \tswitch (sizeof(*__gu_ptr)) {\t\t\t\t\\\n \tcase 1:\t\t\t\t\t\t\t\\\n \t\t__get_user_asm(\"lb\", (x), __gu_ptr, label);\t\\\n@@ -297,6 +308,13 @@ do {\t\t\t\t\t\t\t\t\\\n \n #define __put_user_nocheck(x, __gu_ptr, label)\t\t\t\\\n do {\t\t\t\t\t\t\t\t\\\n+\tif (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) &&\t\\\n+\t !IS_ALIGNED((uintptr_t)__gu_ptr, sizeof(*__gu_ptr))) {\t\\\n+\t\t__inttype(x) val = (__inttype(x))x;\t\t\t\\\n+\t\tif (__asm_copy_to_user_sum_enabled(__gu_ptr, &(val), sizeof(*__gu_ptr))) \\\n+\t\t\tgoto label;\t\t\t\t\\\n+\t\tbreak;\t\t\t\t\t\t\\\n+\t}\t\t\t\t\t\t\t\\\n \tswitch (sizeof(*__gu_ptr)) {\t\t\t\t\\\n \tcase 1:\t\t\t\t\t\t\t\\\n \t\t__put_user_asm(\"sb\", (x), __gu_ptr, label);\t\\\n@@ -450,11 +468,6 @@ static inline void user_access_restore(unsigned long enabled) { }\n \t(x) = (__force __typeof__(*(ptr)))__gu_val;\t\t\t\\\n } while (0)\n \n-unsigned long __must_check __asm_copy_to_user_sum_enabled(void __user *to,\n-\tconst void *from, unsigned long n);\n-unsigned long __must_check __asm_copy_from_user_sum_enabled(void *to,\n-\tconst void __user *from, unsigned long n);\n-\n #define unsafe_copy_to_user(_dst, _src, _len, label)\t\t\t\\\n \tif (__asm_copy_to_user_sum_enabled(_dst, _src, _len))\t\t\\\n \t\tgoto label;",155 "prediction": "Given the following original C code:\n: \"m\" (__ptr[__LSW]), \"m\" (__ptr[__MSW]));\t\\\n\tif (__gu8_err) {\t\t\t\t\t\\\n\t\t__hi = 0;\t\t\t\t\t\\\n\t\tgoto label;\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\\\n\t(x) = (__typeof__(x))((__typeof__((x) - (x)))(\t\t\\\n\t\t(((u64)__hi << 32) | __lo)));\t\t\t\\\n} while (0)\n#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */\n\n#endif /* CONFIG_64BIT */\n\n#define __get_user_nocheck(x, __gu_ptr, label)\t\t\t\\\ndo {\t\t\t\t\t\t\t\t\\\n\tswitch (sizeof(*__gu_ptr)) {\t\t\t\t\\\n\tcase 1:\t\t\t\t\t\t\t\\\n\t\t__get_user_asm(\"lb\", (x), __gu_ptr, label);\t\\\n\t\tbreak;\t\t\t\t\t\t\\\n\tcase 2:\t\t\t\t\t\t\t\\\n\t\t__get_user_asm(\"lh\", (x), __gu_ptr, label);\t\\\n\nInstruction:\nriscv: uaccess: do not do misaligned accesses in get/put_user()\n\nReturn the diff that fixes it:\n @@ -100,6 +100,11 @@ do {\t\t\t\t\t\t\t\t\t\t\\\n #endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */\n \n #endif /* CONFIG_64BIT */\n+\n+#define __get_user_check(x, __gu_ptr, label)\t\t\t\\\n+do {\t\t\t\t\t\t\t\t\\\n+\tif (unlikely((unsigned long)__gu_ptr & (sizeof(*__gu_ptr) - 1))) \\\n+\t\tgoto label;\t\t\t\t\t\\\n+\t__get_user_nocheck((x), __gu_ptr, label);\t\t\\\n+} while (0)\n \n #define __get_user_nocheck(x, __gu_ptr, label)\t\t\t\\\n do {\t\t\t\t\t\t\t\t\\\n@@ -113,6 +118,11 @@ do {\t\t\t\t\t\t\t\t\t\t\\\n \t\tbreak;"156 },157 {158 "prompt": "Given the following original C code:\nBT_DBG(\"conn %p quote %d\", conn, *quote);\n\treturn conn;\n}\n\nstatic void hci_link_tx_to(struct hci_dev *hdev, __u8 type)\n{\n\tstruct hci_conn_hash *h = &hdev->conn_hash;\n\tstruct hci_conn *c;\n\n\tbt_dev_err(hdev, \"link tx timeout\");\n\n\trcu_read_lock();\n\n\t/* Kill stalled connections */\n\tlist_for_each_entry_rcu(c, &h->list, list) {\n\t\tif (c->type == type && c->sent) {\n\t\t\tbt_dev_err(hdev, \"killing stalled connection %pMR\",\n\t\t\t\t &c->dst);\n\t\t\t/* hci_disconnect might sleep, so, we have to release\n\nInstruction:\nBluetooth: hci_core: fix list_for_each_entry_rcu usage\n\nReturn the diff that fixes it:\n",159 "reference": "@@ -3417,23 +3417,18 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type)\n \n \tbt_dev_err(hdev, \"link tx timeout\");\n \n-\trcu_read_lock();\n+\thci_dev_lock(hdev);\n \n \t/* Kill stalled connections */\n-\tlist_for_each_entry_rcu(c, &h->list, list) {\n+\tlist_for_each_entry(c, &h->list, list) {\n \t\tif (c->type == type && c->sent) {\n \t\t\tbt_dev_err(hdev, \"killing stalled connection %pMR\",\n \t\t\t\t &c->dst);\n-\t\t\t/* hci_disconnect might sleep, so, we have to release\n-\t\t\t * the RCU read lock before calling it.\n-\t\t\t */\n-\t\t\trcu_read_unlock();\n \t\t\thci_disconnect(c, HCI_ERROR_REMOTE_USER_TERM);\n-\t\t\trcu_read_lock();\n \t\t}\n \t}\n \n-\trcu_read_unlock();\n+\thci_dev_unlock(hdev);\n }\n \n static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,",160 "prediction": "Given the following original C code:\nBT_DBG(\"conn %p quote %d\", conn, *quote);\n\treturn conn;\n}\n\nstatic void hci_link_tx_to(struct hci_dev *hdev, __u8 type)\n{\n\tstruct hci_conn_hash *h = &hdev->conn_hash;\n\tstruct hci_conn *c;\n\n\tbt_dev_err(hdev, \"link tx timeout\");\n\n\trcu_read_lock();\n\n\t/* Kill stalled connections */\n\tlist_for_each_entry_rcu(c, &h->list, list) {\n\t\tif (c->type == type && c->sent) {\n\t\t\tbt_dev_err(hdev, \"killing stalled connection %pMR\",\n\t\t\t\t &c->dst);\n\t\t\t/* hci_disconnect might sleep, so, we have to release\n\nInstruction:\nBluetooth: hci_core: fix list_for_each_entry_rcu usage\n\nReturn the diff that fixes it:\n @@ -100,10 +100,10 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type)\n \n \tbt_dev_err(hdev, \"link tx timeout\");\n \n-\trcu_read_lock();\n+\trcu_read_lock_bh();\n \n \t/* Kill stalled connections */\n \tlist_for_each_entry_rcu(c, &h->list, list) {\n \t\tif (c->type == type && c->sent) {\n-\t\t\tbt_dev_err(hdev, \"killing stalled connection %pMR\",\n+\t\t\tbt_dev_err(hdev, \"killing stalled connection %pMR\",\n \t\t\t\t &c->dst);\n \t\t\t/* hci_disconnect might sleep, so, we have to release\n \t\t\t * rcu_read_lock */\n@@ -114,7 +114,7 @@ static void hci_link_"161 },162 {163 "prompt": "Given the following original C code:\ndata->ia.tr_hia[BTINTEL_PCIE_RXQ_NUM] = frbd_index;\n\tipc_print_ia_ring(data->hdev, &data->ia, BTINTEL_PCIE_RXQ_NUM);\n\n\t/* Set the doorbell to notify the device */\n\tbtintel_pcie_set_rx_db(data, frbd_index);\n\n\treturn 0;\n}\n\nstatic int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n{\n\tint i, ret;\n\n\tfor (i = 0; i < BTINTEL_PCIE_RX_MAX_QUEUE; i++) {\n\t\tret = btintel_pcie_submit_rx(data);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n\nInstruction:\nBluetooth: btintel_pcie: Fix driver not posting maximum rx buffers\n\nReturn the diff that fixes it:\n",164 "reference": "@@ -396,8 +396,9 @@ static int btintel_pcie_submit_rx(struct btintel_pcie_data *data)\n static int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n {\n \tint i, ret;\n+\tstruct rxq *rxq = &data->rxq;\n \n-\tfor (i = 0; i < BTINTEL_PCIE_RX_MAX_QUEUE; i++) {\n+\tfor (i = 0; i < rxq->count; i++) {\n \t\tret = btintel_pcie_submit_rx(data);\n \t\tif (ret)\n \t\t\treturn ret;",165 "prediction": "Given the following original C code:\ndata->ia.tr_hia[BTINTEL_PCIE_RXQ_NUM] = frbd_index;\n\tipc_print_ia_ring(data->hdev, &data->ia, BTINTEL_PCIE_RXQ_NUM);\n\n\t/* Set the doorbell to notify the device */\n\tbtintel_pcie_set_rx_db(data, frbd_index);\n\n\treturn 0;\n}\n\nstatic int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n{\n\tint i, ret;\n\n\tfor (i = 0; i < BTINTEL_PCIE_RX_MAX_QUEUE; i++) {\n\t\tret = btintel_pcie_submit_rx(data);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n\nInstruction:\nBluetooth: btintel_pcie: Fix driver not posting maximum rx buffers\n\nReturn the diff that fixes it:\n @@ -100,11 +100,11 @@ static int btintel_pcie_submit_rx(struct btintel_pcie_data *data)\n \n static int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n {\n-\tint i, ret;\n+\tint i;\n \n-\tfor (i = 0; i < BTINTEL_PCIE_RX_MAX_QUEUE; i++) {\n-\t\tret = btintel_pcie_submit_rx(data);\n-\t\tif (ret)\n-\t\t\treturn ret;\n+\tfor (i = 0; i < BTINTEL_PCIE_RXQ_NUM; i++) {\n+\t\tret = btintel_pcie_submit_rx(data);\n+\t\tif (ret)\n+\t\t\treturn ret;\n \t}\n \n \treturn 0;\n@@ -113,7 +113,"166 },167 {168 "prompt": "Given the following original C code:\n/* The size of DMA buffer for TX and RX in bytes */\n#define BTINTEL_PCIE_BUFFER_SIZE\t4096\n\n/* DMA allocation alignment */\n#define BTINTEL_PCIE_DMA_POOL_ALIGNMENT\t256\n\n#define BTINTEL_PCIE_TX_WAIT_TIMEOUT_MS\t\t500\n\n/* Doorbell vector for TFD */\n#define BTINTEL_PCIE_TX_DB_VEC\t0\n\n/* Number of pending RX requests for downlink */\n#define BTINTEL_PCIE_RX_MAX_QUEUE\t6\n\n/* Doorbell vector for FRBD */\n#define BTINTEL_PCIE_RX_DB_VEC\t513\n\n/* RBD buffer size mapping */\n#define BTINTEL_PCIE_RBD_SIZE_4K\t0x04\n\nInstruction:\nBluetooth: btintel_pcie: Fix driver not posting maximum rx buffers\n\nReturn the diff that fixes it:\n",169 "reference": "@@ -177,9 +177,6 @@ enum {\n /* Doorbell vector for TFD */\n #define BTINTEL_PCIE_TX_DB_VEC\t0\n \n-/* Number of pending RX requests for downlink */\n-#define BTINTEL_PCIE_RX_MAX_QUEUE\t6\n-\n /* Doorbell vector for FRBD */\n #define BTINTEL_PCIE_RX_DB_VEC\t513",170 "prediction": "Given the following original C code:\n/* The size of DMA buffer for TX and RX in bytes */\n#define BTINTEL_PCIE_BUFFER_SIZE\t4096\n\n/* DMA allocation alignment */\n#define BTINTEL_PCIE_DMA_POOL_ALIGNMENT\t256\n\n#define BTINTEL_PCIE_TX_WAIT_TIMEOUT_MS\t\t500\n\n/* Doorbell vector for TFD */\n#define BTINTEL_PCIE_TX_DB_VEC\t0\n\n/* Number of pending RX requests for downlink */\n#define BTINTEL_PCIE_RX_MAX_QUEUE\t6\n\n/* Doorbell vector for FRBD */\n#define BTINTEL_PCIE_RX_DB_VEC\t513\n\n/* RBD buffer size mapping */\n#define BTINTEL_PCIE_RBD_SIZE_4K\t0x04\n\nInstruction:\nBluetooth: btintel_pcie: Fix driver not posting maximum rx buffers\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@\n /* Doorbell vector for TFD */\n #define BTINTEL_PCIE_TX_DB_VEC\t0\n \n-/* Number of pending RX requests for downlink */\n+/* Maximum number of pending RX requests for downlink */\n #define BTINTEL_PCIE_RX_MAX_QUEUE\t6\n \n /* Doorbell vector for FRBD */\n@@ -109,7 +109,7 @@\n /* RBD buffer size mapping */\n #define BTINTEL_PCIE_RBD_SIZE_4K\t0x04\n #define BTINTEL_PCIE_RBD_SIZE_8K\t0x05\n-#define BTINTEL_PCIE_RBD_SIZE_16K\t0x06\n+#define BTINTEL_PCIE_RBD_SIZE_32K\t0x06\n #define BTINTEL_PCIE_RBD_"171 },172 {173 "prompt": "Given the following original C code:\n* context information, instead of allocating individually.\n\t * The DMA memory for data buffer is allocated while setting up the\n\t * each queue.\n\t *\n\t * Total size is sum of the following\n\t * + size of TFD * Number of descriptors in queue\n\t * + size of URBD0 * Number of descriptors in queue\n\t * + size of FRBD * Number of descriptors in queue\n\t * + size of URBD1 * Number of descriptors in queue\n\t * + size of index * Number of queues(2) * type of index array(4)\n\t * + size of context information\n\t */\n\ttotal = (sizeof(struct tfd) + sizeof(struct urbd0) + sizeof(struct frbd)\n\t\t+ sizeof(struct urbd1)) * BTINTEL_DESCS_COUNT;\n\n\t/* Add the sum of size of index array and size of ci struct */\n\ttotal += (sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 4) + sizeof(struct ctx_info);\n\n\t/* Allocate DMA Pool */\n\tdata->dma_pool = dma_pool_create(KBUILD_MODNAME, &data->pdev->dev,\n\nInstruction:\nBluetooth: btintel_pcie: Increase the tx and rx descriptor count\n\nReturn the diff that fixes it:\n",174 "reference": "@@ -1783,8 +1783,8 @@ static int btintel_pcie_alloc(struct btintel_pcie_data *data)\n \t * + size of index * Number of queues(2) * type of index array(4)\n \t * + size of context information\n \t */\n-\ttotal = (sizeof(struct tfd) + sizeof(struct urbd0) + sizeof(struct frbd)\n-\t\t+ sizeof(struct urbd1)) * BTINTEL_DESCS_COUNT;\n+\ttotal = (sizeof(struct tfd) + sizeof(struct urbd0)) * BTINTEL_PCIE_TX_DESCS_COUNT;\n+\ttotal += (sizeof(struct frbd) + sizeof(struct urbd1)) * BTINTEL_PCIE_RX_DESCS_COUNT;\n \n \t/* Add the sum of size of index array and size of ci struct */\n \ttotal += (sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 4) + sizeof(struct ctx_info);\n@@ -1809,36 +1809,36 @@ static int btintel_pcie_alloc(struct btintel_pcie_data *data)\n \tdata->dma_v_addr = v_addr;\n \n \t/* Setup descriptor count */\n-\tdata->txq.count = BTINTEL_DESCS_COUNT;\n-\tdata->rxq.count = BTINTEL_DESCS_COUNT;\n+\tdata->txq.count = BTINTEL_PCIE_TX_DESCS_COUNT;\n+\tdata->rxq.count = BTINTEL_PCIE_RX_DESCS_COUNT;\n \n \t/* Setup tfds */\n \tdata->txq.tfds_p_addr = p_addr;\n \tdata->txq.tfds = v_addr;\n \n-\tp_addr += (sizeof(struct tfd) * BTINTEL_DESCS_COUNT);\n-\tv_addr += (sizeof(struct tfd) * BTINTEL_DESCS_COUNT);\n+\tp_addr += (sizeof(struct tfd) * BTINTEL_PCIE_TX_DESCS_COUNT);\n+\tv_addr += (sizeof(struct tfd) * BTINTEL_PCIE_TX_DESCS_COUNT);\n \n \t/* Setup urbd0 */\n \tdata->txq.urbd0s_p_addr = p_addr;\n \tdata->txq.urbd0s = v_addr;\n \n-\tp_addr += (sizeof(struct urbd0) * BTINTEL_DESCS_COUNT);\n-\tv_addr += (sizeof(struct urbd0) * BTINTEL_DESCS_COUNT);\n+\tp_addr += (sizeof(struct urbd0) * BTINTEL_PCIE_TX_DESCS_COUNT);\n+\tv_addr += (sizeof(struct urbd0) * BTINTEL_PCIE_TX_DESCS_COUNT);\n \n \t/* Setup FRBD*/\n \tdata->rxq.frbds_p_addr = p_addr;\n \tdata->rxq.frbds = v_addr;\n \n-\tp_addr += (sizeof(struct frbd) * BTINTEL_DESCS_COUNT);\n-\tv_addr += (sizeof(struct frbd) * BTINTEL_DESCS_COUNT);\n+\tp_addr += (sizeof(struct frbd) * BTINTEL_PCIE_RX_DESCS_COUNT);\n+\tv_addr += (sizeof(struct frbd) * BTINTEL_PCIE_RX_DESCS_COUNT);\n \n \t/* Setup urbd1 */\n \tdata->rxq.urbd1s_p_addr = p_addr;\n \tdata->rxq.urbd1s = v_addr;\n \n-\tp_addr += (sizeof(struct urbd1) * BTINTEL_DESCS_COUNT);\n-\tv_addr += (sizeof(struct urbd1) * BTINTEL_DESCS_COUNT);\n+\tp_addr += (sizeof(struct urbd1) * BTINTEL_PCIE_RX_DESCS_COUNT);\n+\tv_addr += (sizeof(struct urbd1) * BTINTEL_PCIE_RX_DESCS_COUNT);\n \n \t/* Setup data buffers for txq */\n \terr = btintel_pcie_setup_txq_bufs(data, &data->txq);",175 "prediction": "Given the following original C code:\n* context information, instead of allocating individually.\n\t * The DMA memory for data buffer is allocated while setting up the\n\t * each queue.\n\t *\n\t * Total size is sum of the following\n\t * + size of TFD * Number of descriptors in queue\n\t * + size of URBD0 * Number of descriptors in queue\n\t * + size of FRBD * Number of descriptors in queue\n\t * + size of URBD1 * Number of descriptors in queue\n\t * + size of index * Number of queues(2) * type of index array(4)\n\t * + size of context information\n\t */\n\ttotal = (sizeof(struct tfd) + sizeof(struct urbd0) + sizeof(struct frbd)\n\t\t+ sizeof(struct urbd1)) * BTINTEL_DESCS_COUNT;\n\n\t/* Add the sum of size of index array and size of ci struct */\n\ttotal += (sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 4) + sizeof(struct ctx_info);\n\n\t/* Allocate DMA Pool */\n\tdata->dma_pool = dma_pool_create(KBUILD_MODNAME, &data->pdev->dev,\n\nInstruction:\nBluetooth: btintel_pcie: Increase the tx and rx descriptor count\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int btintel_pcie_allocate_dma_pool(struct btintel_pcie_data *data)\n \t * + size of index * Number of queues(2) * type of index array(4)\n \t * + size of context information\n \t */\n-\ttotal = (sizeof(struct tfd) + sizeof(struct urbd0) + sizeof(struct frbd)\n+\ttotal = (sizeof(struct tfd) + sizeof(struct urbd0) + sizeof(struct frbd)\n \t\t+ sizeof(struct urbd1)) * BTINTEL_DESCS_COUNT;\n \n \t/* Add the sum of size of index array and size of ci struct */\n@@ -116,7 +116,7 @@ static int btintel_pcie_allocate_dma_pool(struct btintel_pcie_data *data)\n \ttotal += (sizeof(u16) * BTINTEL_PCIE_"176 },177 {178 "prompt": "Given the following original C code:\n/* Minimum and Maximum number of MSI-X Vector\n * Intel Bluetooth PCIe support only 1 vector\n */\n#define BTINTEL_PCIE_MSIX_VEC_MAX\t1\n#define BTINTEL_PCIE_MSIX_VEC_MIN\t1\n\n/* Default poll time for MAC access during init */\n#define BTINTEL_DEFAULT_MAC_ACCESS_TIMEOUT_US\t200000\n\n/* Default interrupt timeout in msec */\n#define BTINTEL_DEFAULT_INTR_TIMEOUT_MS\t3000\n\n/* The number of descriptors in TX/RX queues */\n#define BTINTEL_DESCS_COUNT\t16\n\n/* Number of Queue for TX and RX\n * It indicates the index of the IA(Index Array)\n */\nenum {\n\tBTINTEL_PCIE_TXQ_NUM = 0,\n\nInstruction:\nBluetooth: btintel_pcie: Increase the tx and rx descriptor count\n\nReturn the diff that fixes it:\n",179 "reference": "@@ -154,8 +154,11 @@ enum msix_mbox_int_causes {\n /* Default interrupt timeout in msec */\n #define BTINTEL_DEFAULT_INTR_TIMEOUT_MS\t3000\n \n-/* The number of descriptors in TX/RX queues */\n-#define BTINTEL_DESCS_COUNT\t16\n+/* The number of descriptors in TX queues */\n+#define BTINTEL_PCIE_TX_DESCS_COUNT\t32\n+\n+/* The number of descriptors in RX queues */\n+#define BTINTEL_PCIE_RX_DESCS_COUNT\t64\n \n /* Number of Queue for TX and RX\n * It indicates the index of the IA(Index Array)",180 "prediction": "Given the following original C code:\n/* Minimum and Maximum number of MSI-X Vector\n * Intel Bluetooth PCIe support only 1 vector\n */\n#define BTINTEL_PCIE_MSIX_VEC_MAX\t1\n#define BTINTEL_PCIE_MSIX_VEC_MIN\t1\n\n/* Default poll time for MAC access during init */\n#define BTINTEL_DEFAULT_MAC_ACCESS_TIMEOUT_US\t200000\n\n/* Default interrupt timeout in msec */\n#define BTINTEL_DEFAULT_INTR_TIMEOUT_MS\t3000\n\n/* The number of descriptors in TX/RX queues */\n#define BTINTEL_DESCS_COUNT\t16\n\n/* Number of Queue for TX and RX\n * It indicates the index of the IA(Index Array)\n */\nenum {\n\tBTINTEL_PCIE_TXQ_NUM = 0,\n\nInstruction:\nBluetooth: btintel_pcie: Increase the tx and rx descriptor count\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@\n /* Default interrupt timeout in msec */\n #define BTINTEL_DEFAULT_INTR_TIMEOUT_MS\t3000\n \n-/* The number of descriptors in TX/RX queues */\n+/* The number of descriptors in TX/RX queues */\n #define BTINTEL_DESCS_COUNT\t16\n \n /* Number of Queue for TX and RX\n@@ -116,7 +116,7 @@ enum {\n * It indicates the index of the IA(Index Array)\n */\n enum {\n-\tBTINTEL_PCIE_TXQ_NUM = 0,\n+\tBTINTEL_PCIE_TXQ_NUM = 0,\n \tBTINTEL_PCIE_RXQ_NUM,\n \tBTINTEL_PCIE_NUM_QUEUES,\n };\n@@ -124,7 +124,7 @@ enum {"181 },182 {183 "prompt": "Given the following original C code:\n/* Set the doorbell to notify the device */\n\tbtintel_pcie_set_rx_db(data, frbd_index);\n\n\treturn 0;\n}\n\nstatic int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n{\n\tint i, ret;\n\tstruct rxq *rxq = &data->rxq;\n\n\tfor (i = 0; i < rxq->count; i++) {\n\t\tret = btintel_pcie_submit_rx(data);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\nInstruction:\nBluetooth: btintel_pcie: Reduce driver buffer posting to prevent race condition\n\nReturn the diff that fixes it:\n",184 "reference": "@@ -398,7 +398,11 @@ static int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n \tint i, ret;\n \tstruct rxq *rxq = &data->rxq;\n \n-\tfor (i = 0; i < rxq->count; i++) {\n+\t/* Post (BTINTEL_PCIE_RX_DESCS_COUNT - 3) buffers to overcome the\n+\t * hardware issues leading to race condition at the firmware.\n+\t */\n+\n+\tfor (i = 0; i < rxq->count - 3; i++) {\n \t\tret = btintel_pcie_submit_rx(data);\n \t\tif (ret)\n \t\t\treturn ret;",185 "prediction": "Given the following original C code:\n/* Set the doorbell to notify the device */\n\tbtintel_pcie_set_rx_db(data, frbd_index);\n\n\treturn 0;\n}\n\nstatic int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n{\n\tint i, ret;\n\tstruct rxq *rxq = &data->rxq;\n\n\tfor (i = 0; i < rxq->count; i++) {\n\t\tret = btintel_pcie_submit_rx(data);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\nInstruction:\nBluetooth: btintel_pcie: Reduce driver buffer posting to prevent race condition\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n \tstruct rxq *rxq = &data->rxq;\n \n \tfor (i = 0; i < rxq->count; i++) {\n-\t\tret = btintel_pcie_submit_rx(data);\n+\t\tret = btintel_pcie_submit_rx(data, i);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n@@ -116,7 +116,7 @@ static int btintel_pcie_start_rx(struct btintel_pcie_data *data)\n \treturn 0;\n }\n \n-static int btintel_pcie_submit_rx(struct btintel_pcie_data *data)\n+static int btintel_pcie_submit_rx(struct btintel_pcie_data *"186 },187 {188 "prompt": "Given the following original C code:\nvoid mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,\n\t\t bool persistent);\nvoid mgmt_new_conn_param(struct hci_dev *hdev, bdaddr_t *bdaddr,\n\t\t\t u8 bdaddr_type, u8 store_hint, u16 min_interval,\n\t\t\t u16 max_interval, u16 latency, u16 timeout);\nvoid mgmt_smp_complete(struct hci_conn *conn, bool complete);\nbool mgmt_get_connectable(struct hci_dev *hdev);\nu8 mgmt_get_adv_discov_flags(struct hci_dev *hdev);\nvoid mgmt_advertising_added(struct sock *sk, struct hci_dev *hdev,\n\t\t\t u8 instance);\nvoid mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev,\n\t\t\t u8 instance);\nvoid mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle);\nint mgmt_phy_configuration_changed(struct hci_dev *hdev, struct sock *skip);\nvoid mgmt_adv_monitor_device_lost(struct hci_dev *hdev, u16 handle,\n\t\t\t\t bdaddr_t *bdaddr, u8 addr_type);\n\nint hci_abort_conn(struct hci_conn *conn, u8 reason);\nu8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,\n\t\t u16 to_multiplier);\n\nInstruction:\nBluetooth: MGMT: Fix UAF on mgmt_remove_adv_monitor_complete\n\nReturn the diff that fixes it:\n",189 "reference": "@@ -2400,7 +2400,6 @@ void mgmt_advertising_added(struct sock *sk, struct hci_dev *hdev,\n \t\t\t u8 instance);\n void mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev,\n \t\t\t u8 instance);\n-void mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle);\n int mgmt_phy_configuration_changed(struct hci_dev *hdev, struct sock *skip);\n void mgmt_adv_monitor_device_lost(struct hci_dev *hdev, u16 handle,\n \t\t\t\t bdaddr_t *bdaddr, u8 addr_type);",190 "prediction": "Given the following original C code:\nvoid mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,\n\t\t bool persistent);\nvoid mgmt_new_conn_param(struct hci_dev *hdev, bdaddr_t *bdaddr,\n\t\t\t u8 bdaddr_type, u8 store_hint, u16 min_interval,\n\t\t\t u16 max_interval, u16 latency, u16 timeout);\nvoid mgmt_smp_complete(struct hci_conn *conn, bool complete);\nbool mgmt_get_connectable(struct hci_dev *hdev);\nu8 mgmt_get_adv_discov_flags(struct hci_dev *hdev);\nvoid mgmt_advertising_added(struct sock *sk, struct hci_dev *hdev,\n\t\t\t u8 instance);\nvoid mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev,\n\t\t\t u8 instance);\nvoid mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle);\nint mgmt_phy_configuration_changed(struct hci_dev *hdev, struct sock *skip);\nvoid mgmt_adv_monitor_device_lost(struct hci_dev *hdev, u16 handle,\n\t\t\t\t bdaddr_t *bdaddr, u8 addr_type);\n\nint hci_abort_conn(struct hci_conn *conn, u8 reason);\nu8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,\n\t\t u16 to_multiplier);\n\nInstruction:\nBluetooth: MGMT: Fix UAF on mgmt_remove_adv_monitor_complete\n\nReturn the diff that fixes it:\n @@ -105,6 +105,7 @@ void mgmt_advertising_added(struct sock *sk, struct hci_dev *hdev,\n \t\t\t u8 instance);\n void mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev,\n \t\t\t u8 instance);\n+void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev, u16 handle);\n void mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle);\n int mgmt_phy_configuration_changed(struct hci_dev *hdev, struct sock *skip);\n void mgmt_adv_monitor_device_lost(struct hci_dev *hdev, u16 handle,\n@@ -113,6 +114,7 @@ u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,"191 },192 {193 "prompt": "Given the following original C code:\nif (!monitor)\n\t\treturn;\n\n\tlist_for_each_entry_safe(pattern, tmp, &monitor->patterns, list) {\n\t\tlist_del(&pattern->list);\n\t\tkfree(pattern);\n\t}\n\n\tif (monitor->handle)\n\t\tidr_remove(&hdev->adv_monitors_idr, monitor->handle);\n\n\tif (monitor->state != ADV_MONITOR_STATE_NOT_REGISTERED) {\n\t\thdev->adv_monitors_cnt--;\n\t\tmgmt_adv_monitor_removed(hdev, monitor->handle);\n\t}\n\n\tkfree(monitor);\n}\n\nInstruction:\nBluetooth: MGMT: Fix UAF on mgmt_remove_adv_monitor_complete\n\nReturn the diff that fixes it:\n",194 "reference": "@@ -1877,10 +1877,8 @@ void hci_free_adv_monitor(struct hci_dev *hdev, struct adv_monitor *monitor)\n \tif (monitor->handle)\n \t\tidr_remove(&hdev->adv_monitors_idr, monitor->handle);\n \n-\tif (monitor->state != ADV_MONITOR_STATE_NOT_REGISTERED) {\n+\tif (monitor->state != ADV_MONITOR_STATE_NOT_REGISTERED)\n \t\thdev->adv_monitors_cnt--;\n-\t\tmgmt_adv_monitor_removed(hdev, monitor->handle);\n-\t}\n \n \tkfree(monitor);\n }",195 "prediction": "Given the following original C code:\nif (!monitor)\n\t\treturn;\n\n\tlist_for_each_entry_safe(pattern, tmp, &monitor->patterns, list) {\n\t\tlist_del(&pattern->list);\n\t\tkfree(pattern);\n\t}\n\n\tif (monitor->handle)\n\t\tidr_remove(&hdev->adv_monitors_idr, monitor->handle);\n\n\tif (monitor->state != ADV_MONITOR_STATE_NOT_REGISTERED) {\n\t\thdev->adv_monitors_cnt--;\n\t\tmgmt_adv_monitor_removed(hdev, monitor->handle);\n\t}\n\n\tkfree(monitor);\n}\n\nInstruction:\nBluetooth: MGMT: Fix UAF on mgmt_remove_adv_monitor_complete\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ void mgmt_remove_adv_monitor(struct hci_dev *hdev, struct adv_monitor *monitor)\n \t\tidr_remove(&hdev->adv_monitors_idr, monitor->handle);\n \n \tif (monitor->state != ADV_MONITOR_STATE_NOT_REGISTERED) {\n-\t\thdev->adv_monitors_cnt--;\n+\t\thdev->adv_monitors_cnt--;\n \t\tmgmt_adv_monitor_removed(hdev, monitor->handle);\n \t}\n \n@@ -116,7 +116,7 @@ void mgmt_remove_adv_monitor(struct hci_dev *hdev, struct adv_monitor *monitor)\n \tkfree(monitor);\n }\n \n-void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev, u16 opcode,\n+void mgmt_"196 },197 {198 "prompt": "Given the following original C code:\n}\n\nstatic void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,\n\t\t\t\t u16 handle)\n{\n\tstruct mgmt_ev_adv_monitor_added ev;\n\n\tev.monitor_handle = cpu_to_le16(handle);\n\n\tmgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk);\n}\n\nvoid mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle)\n{\n\tstruct mgmt_ev_adv_monitor_removed ev;\n\tstruct mgmt_pending_cmd *cmd;\n\tstruct sock *sk_skip = NULL;\n\tstruct mgmt_cp_remove_adv_monitor *cp;\n\n\tcmd = pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev);\n\nInstruction:\nBluetooth: MGMT: Fix UAF on mgmt_remove_adv_monitor_complete\n\nReturn the diff that fixes it:\n",199 "reference": "@@ -5108,24 +5108,14 @@ static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,\n \tmgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk);\n }\n \n-void mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle)\n+static void mgmt_adv_monitor_removed(struct sock *sk, struct hci_dev *hdev,\n+\t\t\t\t u16 handle)\n {\n \tstruct mgmt_ev_adv_monitor_removed ev;\n-\tstruct mgmt_pending_cmd *cmd;\n-\tstruct sock *sk_skip = NULL;\n-\tstruct mgmt_cp_remove_adv_monitor *cp;\n-\n-\tcmd = pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev);\n-\tif (cmd) {\n-\t\tcp = cmd->param;\n-\n-\t\tif (cp->monitor_handle)\n-\t\t\tsk_skip = cmd->sk;\n-\t}\n \n \tev.monitor_handle = cpu_to_le16(handle);\n \n-\tmgmt_event(MGMT_EV_ADV_MONITOR_REMOVED, hdev, &ev, sizeof(ev), sk_skip);\n+\tmgmt_event(MGMT_EV_ADV_MONITOR_REMOVED, hdev, &ev, sizeof(ev), sk);\n }\n \n static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,\n@@ -5227,8 +5217,7 @@ static int __add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,\n \n \tif (pending_find(MGMT_OP_SET_LE, hdev) ||\n \t pending_find(MGMT_OP_ADD_ADV_PATTERNS_MONITOR, hdev) ||\n-\t pending_find(MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI, hdev) ||\n-\t pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev)) {\n+\t pending_find(MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI, hdev)) {\n \t\tstatus = MGMT_STATUS_BUSY;\n \t\tgoto unlock;\n \t}\n@@ -5398,8 +5387,7 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,\n \tstruct mgmt_pending_cmd *cmd = data;\n \tstruct mgmt_cp_remove_adv_monitor *cp;\n \n-\tif (status == -ECANCELED ||\n-\t cmd != pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev))\n+\tif (status == -ECANCELED)\n \t\treturn;\n \n \thci_dev_lock(hdev);\n@@ -5408,12 +5396,14 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,\n \n \trp.monitor_handle = cp->monitor_handle;\n \n-\tif (!status)\n+\tif (!status) {\n+\t\tmgmt_adv_monitor_removed(cmd->sk, hdev, cp->monitor_handle);\n \t\thci_update_passive_scan(hdev);\n+\t}\n \n \tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,\n \t\t\t mgmt_status(status), &rp, sizeof(rp));\n-\tmgmt_pending_remove(cmd);\n+\tmgmt_pending_free(cmd);\n \n \thci_dev_unlock(hdev);\n \tbt_dev_dbg(hdev, \"remove monitor %d complete, status %d\",\n@@ -5423,10 +5413,6 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,\n static int mgmt_remove_adv_monitor_sync(struct hci_dev *hdev, void *data)\n {\n \tstruct mgmt_pending_cmd *cmd = data;\n-\n-\tif (cmd != pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev))\n-\t\treturn -ECANCELED;\n-\n \tstruct mgmt_cp_remove_adv_monitor *cp = cmd->param;\n \tu16 handle = __le16_to_cpu(cp->monitor_handle);\n \n@@ -5445,14 +5431,13 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,\n \thci_dev_lock(hdev);\n \n \tif (pending_find(MGMT_OP_SET_LE, hdev) ||\n-\t pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev) ||\n \t pending_find(MGMT_OP_ADD_ADV_PATTERNS_MONITOR, hdev) ||\n \t pending_find(MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI, hdev)) {\n \t\tstatus = MGMT_STATUS_BUSY;\n \t\tgoto unlock;\n \t}\n \n-\tcmd = mgmt_pending_add(sk, MGMT_OP_REMOVE_ADV_MONITOR, hdev, data, len);\n+\tcmd = mgmt_pending_new(sk, MGMT_OP_REMOVE_ADV_MONITOR, hdev, data, len);\n \tif (!cmd) {\n \t\tstatus = MGMT_STATUS_NO_RESOURCES;\n \t\tgoto unlock;\n@@ -5462,7 +5447,7 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,\n \t\t\t\t mgmt_remove_adv_monitor_complete);\n \n \tif (err) {\n-\t\tmgmt_pending_remove(cmd);\n+\t\tmgmt_pending_free(cmd);\n \n \t\tif (err == -ENOMEM)\n \t\t\tstatus = MGMT_STATUS_NO_RESOURCES;",200 "prediction": "Given the following original C code:\n}\n\nstatic void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,\n\t\t\t\t u16 handle)\n{\n\tstruct mgmt_ev_adv_monitor_added ev;\n\n\tev.monitor_handle = cpu_to_le16(handle);\n\n\tmgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk);\n}\n\nvoid mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle)\n{\n\tstruct mgmt_ev_adv_monitor_removed ev;\n\tstruct mgmt_pending_cmd *cmd;\n\tstruct sock *sk_skip = NULL;\n\tstruct mgmt_cp_remove_adv_monitor *cp;\n\n\tcmd = pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev);\n\nInstruction:\nBluetooth: MGMT: Fix UAF on mgmt_remove_adv_monitor_complete\n\nReturn the diff that fixes it:\n @@ -104,11 +104,11 @@ static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,\n \tmgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk);\n }\n \n-void mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle)\n+void mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle,\n+\t\t\t struct sock *skip_sk)\n {\n \tstruct mgmt_ev_adv_monitor_removed ev;\n \tstruct mgmt_pending_cmd *cmd;\n-\tstruct sock *sk_skip = NULL;\n \tstruct mgmt_cp_remove_adv_monitor *cp;\n \n \tcmd = pending_find(MGMT_OP_REMOVE_ADV_MONITOR"201 },202 {203 "prompt": "Given the following original C code:\nstruct notifier_block\tsuspend_notifier;\n\tenum suspended_state\tsuspend_state_next;\n\tenum suspended_state\tsuspend_state;\n\tbool\t\t\tscanning_paused;\n\tbool\t\t\tsuspended;\n\tu8\t\t\twake_reason;\n\tbdaddr_t\t\twake_addr;\n\tu8\t\t\twake_addr_type;\n\n\tstruct hci_conn_hash\tconn_hash;\n\n\tstruct list_head\tmesh_pending;\n\tstruct list_head\tmgmt_pending;\n\tstruct list_head\treject_list;\n\tstruct list_head\taccept_list;\n\tstruct list_head\tuuids;\n\tstruct list_head\tlink_keys;\n\tstruct list_head\tlong_term_keys;\n\tstruct list_head\tidentity_resolving_keys;\n\tstruct list_head\tremote_oob_data;\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n",204 "reference": "@@ -546,6 +546,7 @@ struct hci_dev {\n \tstruct hci_conn_hash\tconn_hash;\n \n \tstruct list_head\tmesh_pending;\n+\tstruct mutex\t\tmgmt_pending_lock;\n \tstruct list_head\tmgmt_pending;\n \tstruct list_head\treject_list;\n \tstruct list_head\taccept_list;",205 "prediction": "Given the following original C code:\nstruct notifier_block\tsuspend_notifier;\n\tenum suspended_state\tsuspend_state_next;\n\tenum suspended_state\tsuspend_state;\n\tbool\t\t\tscanning_paused;\n\tbool\t\t\tsuspended;\n\tu8\t\t\twake_reason;\n\tbdaddr_t\t\twake_addr;\n\tu8\t\t\twake_addr_type;\n\n\tstruct hci_conn_hash\tconn_hash;\n\n\tstruct list_head\tmesh_pending;\n\tstruct list_head\tmgmt_pending;\n\tstruct list_head\treject_list;\n\tstruct list_head\taccept_list;\n\tstruct list_head\tuuids;\n\tstruct list_head\tlink_keys;\n\tstruct list_head\tlong_term_keys;\n\tstruct list_head\tidentity_resolving_keys;\n\tstruct list_head\tremote_oob_data;\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n @@ -103,6 +103,7 @@ struct hci_dev {\n \tstruct hci_conn_hash\tconn_hash;\n \n \tstruct list_head\tmesh_pending;\n+\tspinlock_t\t\tmesh_pending_lock;\n \tstruct list_head\tmgmt_pending;\n \tstruct list_head\treject_list;\n \tstruct list_head\taccept_list;\n@@ -115,6 +116,7 @@ struct hci_dev {\n \tstruct list_head\tlink_keys;\n \tstruct list_head\tlong_term_keys;\n \tstruct list_head\tidentity_resolving_keys;\n+\tspinlock_t\t\tkey_lock;\n \tstruct list_head\tremote_oob_data;\n \tstruct list_head\tle_white_list;\n \tstruct list_head\tle_resolv_list;\n@@ -127,6 +129,7 @@ struct hci_dev {"206 },207 {208 "prompt": "Given the following original C code:\nhdev->conn_info_min_age = DEFAULT_CONN_INFO_MIN_AGE;\n\thdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE;\n\thdev->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT;\n\thdev->min_enc_key_size = HCI_MIN_ENC_KEY_SIZE;\n\n\t/* default 1.28 sec page scan */\n\thdev->def_page_scan_type = PAGE_SCAN_TYPE_STANDARD;\n\thdev->def_page_scan_int = 0x0800;\n\thdev->def_page_scan_window = 0x0012;\n\n\tmutex_init(&hdev->lock);\n\tmutex_init(&hdev->req_lock);\n\n\tida_init(&hdev->unset_handle_ida);\n\n\tINIT_LIST_HEAD(&hdev->mesh_pending);\n\tINIT_LIST_HEAD(&hdev->mgmt_pending);\n\tINIT_LIST_HEAD(&hdev->reject_list);\n\tINIT_LIST_HEAD(&hdev->accept_list);\n\tINIT_LIST_HEAD(&hdev->uuids);\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n",209 "reference": "@@ -2485,6 +2485,7 @@ struct hci_dev *hci_alloc_dev_priv(int sizeof_priv)\n \n \tmutex_init(&hdev->lock);\n \tmutex_init(&hdev->req_lock);\n+\tmutex_init(&hdev->mgmt_pending_lock);\n \n \tida_init(&hdev->unset_handle_ida);",210 "prediction": "Given the following original C code:\nhdev->conn_info_min_age = DEFAULT_CONN_INFO_MIN_AGE;\n\thdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE;\n\thdev->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT;\n\thdev->min_enc_key_size = HCI_MIN_ENC_KEY_SIZE;\n\n\t/* default 1.28 sec page scan */\n\thdev->def_page_scan_type = PAGE_SCAN_TYPE_STANDARD;\n\thdev->def_page_scan_int = 0x0800;\n\thdev->def_page_scan_window = 0x0012;\n\n\tmutex_init(&hdev->lock);\n\tmutex_init(&hdev->req_lock);\n\n\tida_init(&hdev->unset_handle_ida);\n\n\tINIT_LIST_HEAD(&hdev->mesh_pending);\n\tINIT_LIST_HEAD(&hdev->mgmt_pending);\n\tINIT_LIST_HEAD(&hdev->reject_list);\n\tINIT_LIST_HEAD(&hdev->accept_list);\n\tINIT_LIST_HEAD(&hdev->uuids);\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n @@ -108,6 +108,7 @@ struct hci_dev *hci_alloc_dev(void)\n \n \tmutex_init(&hdev->lock);\n \tmutex_init(&hdev->req_lock);\n+\tmutex_init(&hdev->mgmt_pending_lock);\n \n \tida_init(&hdev->unset_handle_ida);\n \n@@ -116,6 +117,7 @@ struct hci_dev *hci_alloc_dev(void)\n \tINIT_LIST_HEAD(&hdev->mesh_pending);\n \tINIT_LIST_HEAD(&hdev->mgmt_pending);\n \tINIT_LIST_HEAD(&hdev->reject_list);\n+\tINIT_LIST_HEAD(&hdev->accept_list);\n \tINIT_LIST_HEAD(&hdev->uuids);\n \tINIT_LIST_HEAD(&hdev->link_keys);\n \tINIT_LIST_HEAD(&hdev->long_term_keys);\n@@"211 },212 {213 "prompt": "Given the following original C code:\nstruct cmd_lookup {\n\tstruct sock *sk;\n\tstruct hci_dev *hdev;\n\tu8 mgmt_status;\n};\n\nstatic void settings_rsp(struct mgmt_pending_cmd *cmd, void *data)\n{\n\tstruct cmd_lookup *match = data;\n\n\tsend_settings_rsp(cmd->sk, cmd->opcode, match->hdev);\n\n\tlist_del(&cmd->list);\n\n\tif (match->sk == NULL) {\n\t\tmatch->sk = cmd->sk;\n\t\tsock_hold(match->sk);\n\t}\n\n\tmgmt_pending_free(cmd);\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n",214 "reference": "@@ -1447,22 +1447,17 @@ static void settings_rsp(struct mgmt_pending_cmd *cmd, void *data)\n \n \tsend_settings_rsp(cmd->sk, cmd->opcode, match->hdev);\n \n-\tlist_del(&cmd->list);\n-\n \tif (match->sk == NULL) {\n \t\tmatch->sk = cmd->sk;\n \t\tsock_hold(match->sk);\n \t}\n-\n-\tmgmt_pending_free(cmd);\n }\n \n static void cmd_status_rsp(struct mgmt_pending_cmd *cmd, void *data)\n {\n \tu8 *status = data;\n \n-\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);\n-\tmgmt_pending_remove(cmd);\n+\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode, *status);\n }\n \n static void cmd_complete_rsp(struct mgmt_pending_cmd *cmd, void *data)\n@@ -1476,8 +1471,6 @@ static void cmd_complete_rsp(struct mgmt_pending_cmd *cmd, void *data)\n \n \tif (cmd->cmd_complete) {\n \t\tcmd->cmd_complete(cmd, match->mgmt_status);\n-\t\tmgmt_pending_remove(cmd);\n-\n \t\treturn;\n \t}\n \n@@ -1486,13 +1479,13 @@ static void cmd_complete_rsp(struct mgmt_pending_cmd *cmd, void *data)\n \n static int generic_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)\n {\n-\treturn mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status,\n+\treturn mgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode, status,\n \t\t\t\t cmd->param, cmd->param_len);\n }\n \n static int addr_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)\n {\n-\treturn mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status,\n+\treturn mgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode, status,\n \t\t\t\t cmd->param, sizeof(struct mgmt_addr_info));\n }\n \n@@ -1532,7 +1525,7 @@ static void mgmt_set_discoverable_complete(struct hci_dev *hdev, void *data,\n \n \tif (err) {\n \t\tu8 mgmt_err = mgmt_status(err);\n-\t\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);\n+\t\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode, mgmt_err);\n \t\thci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE);\n \t\tgoto done;\n \t}\n@@ -1707,7 +1700,7 @@ static void mgmt_set_connectable_complete(struct hci_dev *hdev, void *data,\n \n \tif (err) {\n \t\tu8 mgmt_err = mgmt_status(err);\n-\t\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);\n+\t\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode, mgmt_err);\n \t\tgoto done;\n \t}\n \n@@ -1943,8 +1936,8 @@ static void set_ssp_complete(struct hci_dev *hdev, void *data, int err)\n \t\t\tnew_settings(hdev, NULL);\n \t\t}\n \n-\t\tmgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, cmd_status_rsp,\n-\t\t\t\t &mgmt_err);\n+\t\tmgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, true,\n+\t\t\t\t cmd_status_rsp, &mgmt_err);\n \t\treturn;\n \t}\n \n@@ -1954,7 +1947,7 @@ static void set_ssp_complete(struct hci_dev *hdev, void *data, int err)\n \t\tchanged = hci_dev_test_and_clear_flag(hdev, HCI_SSP_ENABLED);\n \t}\n \n-\tmgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, settings_rsp, &match);\n+\tmgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, true, settings_rsp, &match);\n \n \tif (changed)\n \t\tnew_settings(hdev, match.sk);\n@@ -2074,12 +2067,12 @@ static void set_le_complete(struct hci_dev *hdev, void *data, int err)\n \tbt_dev_dbg(hdev, \"err %d\", err);\n \n \tif (status) {\n-\t\tmgmt_pending_foreach(MGMT_OP_SET_LE, hdev, cmd_status_rsp,\n-\t\t\t\t\t\t\t&status);\n+\t\tmgmt_pending_foreach(MGMT_OP_SET_LE, hdev, true, cmd_status_rsp,\n+\t\t\t\t &status);\n \t\treturn;\n \t}\n \n-\tmgmt_pending_foreach(MGMT_OP_SET_LE, hdev, settings_rsp, &match);\n+\tmgmt_pending_foreach(MGMT_OP_SET_LE, hdev, true, settings_rsp, &match);\n \n \tnew_settings(hdev, match.sk);\n \n@@ -2138,7 +2131,7 @@ static void set_mesh_complete(struct hci_dev *hdev, void *data, int err)\n \tstruct sock *sk = cmd->sk;\n \n \tif (status) {\n-\t\tmgmt_pending_foreach(MGMT_OP_SET_MESH_RECEIVER, hdev,\n+\t\tmgmt_pending_foreach(MGMT_OP_SET_MESH_RECEIVER, hdev, true,\n \t\t\t\t cmd_status_rsp, &status);\n \t\treturn;\n \t}\n@@ -2638,7 +2631,7 @@ static void mgmt_class_complete(struct hci_dev *hdev, void *data, int err)\n \n \tbt_dev_dbg(hdev, \"err %d\", err);\n \n-\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,\n+\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t mgmt_status(err), hdev->dev_class, 3);\n \n \tmgmt_pending_free(cmd);\n@@ -3427,7 +3420,7 @@ static int pairing_complete(struct mgmt_pending_cmd *cmd, u8 status)\n \tbacpy(&rp.addr.bdaddr, &conn->dst);\n \trp.addr.type = link_to_bdaddr(conn->type, conn->dst_type);\n \n-\terr = mgmt_cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE,\n+\terr = mgmt_cmd_complete(cmd->sk, cmd->hdev->id, MGMT_OP_PAIR_DEVICE,\n \t\t\t\tstatus, &rp, sizeof(rp));\n \n \t/* So we don't get further callbacks for this connection */\n@@ -5186,7 +5179,7 @@ static void mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev,\n \t\thci_update_passive_scan(hdev);\n \t}\n \n-\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,\n+\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t mgmt_status(status), &rp, sizeof(rp));\n \tmgmt_pending_remove(cmd);\n \n@@ -5401,7 +5394,7 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,\n \t\thci_update_passive_scan(hdev);\n \t}\n \n-\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,\n+\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t mgmt_status(status), &rp, sizeof(rp));\n \tmgmt_pending_free(cmd);\n \n@@ -5777,7 +5770,7 @@ static void start_discovery_complete(struct hci_dev *hdev, void *data, int err)\n \t cmd != pending_find(MGMT_OP_START_SERVICE_DISCOVERY, hdev))\n \t\treturn;\n \n-\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, mgmt_status(err),\n+\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode, mgmt_status(err),\n \t\t\t cmd->param, 1);\n \tmgmt_pending_remove(cmd);\n \n@@ -5998,7 +5991,7 @@ static void stop_discovery_complete(struct hci_dev *hdev, void *data, int err)\n \n \tbt_dev_dbg(hdev, \"err %d\", err);\n \n-\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, mgmt_status(err),\n+\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode, mgmt_status(err),\n \t\t\t cmd->param, 1);\n \tmgmt_pending_remove(cmd);\n \n@@ -6223,7 +6216,7 @@ static void set_advertising_complete(struct hci_dev *hdev, void *data, int err)\n \tu8 status = mgmt_status(err);\n \n \tif (status) {\n-\t\tmgmt_pending_foreach(MGMT_OP_SET_ADVERTISING, hdev,\n+\t\tmgmt_pending_foreach(MGMT_OP_SET_ADVERTISING, hdev, true,\n \t\t\t\t cmd_status_rsp, &status);\n \t\treturn;\n \t}\n@@ -6233,7 +6226,7 @@ static void set_advertising_complete(struct hci_dev *hdev, void *data, int err)\n \telse\n \t\thci_dev_clear_flag(hdev, HCI_ADVERTISING);\n \n-\tmgmt_pending_foreach(MGMT_OP_SET_ADVERTISING, hdev, settings_rsp,\n+\tmgmt_pending_foreach(MGMT_OP_SET_ADVERTISING, hdev, true, settings_rsp,\n \t\t\t &match);\n \n \tnew_settings(hdev, match.sk);\n@@ -6577,7 +6570,7 @@ static void set_bredr_complete(struct hci_dev *hdev, void *data, int err)\n \t\t */\n \t\thci_dev_clear_flag(hdev, HCI_BREDR_ENABLED);\n \n-\t\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);\n+\t\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode, mgmt_err);\n \t} else {\n \t\tsend_settings_rsp(cmd->sk, MGMT_OP_SET_BREDR, hdev);\n \t\tnew_settings(hdev, cmd->sk);\n@@ -6714,7 +6707,7 @@ static void set_secure_conn_complete(struct hci_dev *hdev, void *data, int err)\n \tif (err) {\n \t\tu8 mgmt_err = mgmt_status(err);\n \n-\t\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);\n+\t\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode, mgmt_err);\n \t\tgoto done;\n \t}\n \n@@ -7161,7 +7154,7 @@ static void get_conn_info_complete(struct hci_dev *hdev, void *data, int err)\n \t\trp.max_tx_power = HCI_TX_POWER_INVALID;\n \t}\n \n-\tmgmt_cmd_complete(cmd->sk, cmd->index, MGMT_OP_GET_CONN_INFO, status,\n+\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, MGMT_OP_GET_CONN_INFO, status,\n \t\t\t &rp, sizeof(rp));\n \n \tmgmt_pending_free(cmd);\n@@ -7321,7 +7314,7 @@ static void get_clock_info_complete(struct hci_dev *hdev, void *data, int err)\n \t}\n \n complete:\n-\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, &rp,\n+\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode, status, &rp,\n \t\t\t sizeof(rp));\n \n \tmgmt_pending_free(cmd);\n@@ -8571,10 +8564,10 @@ static void add_advertising_complete(struct hci_dev *hdev, void *data, int err)\n \trp.instance = cp->instance;\n \n \tif (err)\n-\t\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode,\n+\t\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t\tmgmt_status(err));\n \telse\n-\t\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,\n+\t\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t\t mgmt_status(err), &rp, sizeof(rp));\n \n \tadd_adv_complete(hdev, cmd->sk, cp->instance, err);\n@@ -8762,10 +8755,10 @@ static void add_ext_adv_params_complete(struct hci_dev *hdev, void *data,\n \n \t\thci_remove_adv_instance(hdev, cp->instance);\n \n-\t\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode,\n+\t\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t\tmgmt_status(err));\n \t} else {\n-\t\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,\n+\t\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t\t mgmt_status(err), &rp, sizeof(rp));\n \t}\n \n@@ -8912,10 +8905,10 @@ static void add_ext_adv_data_complete(struct hci_dev *hdev, void *data, int err)\n \trp.instance = cp->instance;\n \n \tif (err)\n-\t\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode,\n+\t\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t\tmgmt_status(err));\n \telse\n-\t\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,\n+\t\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t\t mgmt_status(err), &rp, sizeof(rp));\n \n \tmgmt_pending_free(cmd);\n@@ -9074,10 +9067,10 @@ static void remove_advertising_complete(struct hci_dev *hdev, void *data,\n \trp.instance = cp->instance;\n \n \tif (err)\n-\t\tmgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode,\n+\t\tmgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t\tmgmt_status(err));\n \telse\n-\t\tmgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,\n+\t\tmgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,\n \t\t\t\t MGMT_STATUS_SUCCESS, &rp, sizeof(rp));\n \n \tmgmt_pending_free(cmd);\n@@ -9349,7 +9342,7 @@ void mgmt_index_removed(struct hci_dev *hdev)\n \tif (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))\n \t\treturn;\n \n-\tmgmt_pending_foreach(0, hdev, cmd_complete_rsp, &match);\n+\tmgmt_pending_foreach(0, hdev, true, cmd_complete_rsp, &match);\n \n \tif (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) {\n \t\tmgmt_index_event(MGMT_EV_UNCONF_INDEX_REMOVED, hdev, NULL, 0,\n@@ -9387,7 +9380,8 @@ void mgmt_power_on(struct hci_dev *hdev, int err)\n \t\thci_update_passive_scan(hdev);\n \t}\n \n-\tmgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match);\n+\tmgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, true, settings_rsp,\n+\t\t\t &match);\n \n \tnew_settings(hdev, match.sk);\n \n@@ -9402,7 +9396,8 @@ void __mgmt_power_off(struct hci_dev *hdev)\n \tstruct cmd_lookup match = { NULL, hdev };\n \tu8 zero_cod[] = { 0, 0, 0 };\n \n-\tmgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match);\n+\tmgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, true, settings_rsp,\n+\t\t\t &match);\n \n \t/* If the power off is because of hdev unregistration let\n \t * use the appropriate INVALID_INDEX status. Otherwise use\n@@ -9416,7 +9411,7 @@ void __mgmt_power_off(struct hci_dev *hdev)\n \telse\n \t\tmatch.mgmt_status = MGMT_STATUS_NOT_POWERED;\n \n-\tmgmt_pending_foreach(0, hdev, cmd_complete_rsp, &match);\n+\tmgmt_pending_foreach(0, hdev, true, cmd_complete_rsp, &match);\n \n \tif (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0) {\n \t\tmgmt_limited_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev,\n@@ -9657,7 +9652,6 @@ static void unpair_device_rsp(struct mgmt_pending_cmd *cmd, void *data)\n \tdevice_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, cmd->sk);\n \n \tcmd->cmd_complete(cmd, 0);\n-\tmgmt_pending_remove(cmd);\n }\n \n bool mgmt_powering_down(struct hci_dev *hdev)\n@@ -9713,8 +9707,8 @@ void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,\n \tstruct mgmt_cp_disconnect *cp;\n \tstruct mgmt_pending_cmd *cmd;\n \n-\tmgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp,\n-\t\t\t hdev);\n+\tmgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, true,\n+\t\t\t unpair_device_rsp, hdev);\n \n \tcmd = pending_find(MGMT_OP_DISCONNECT, hdev);\n \tif (!cmd)\n@@ -9907,7 +9901,7 @@ void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status)\n \n \tif (status) {\n \t\tu8 mgmt_err = mgmt_status(status);\n-\t\tmgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev,\n+\t\tmgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, true,\n \t\t\t\t cmd_status_rsp, &mgmt_err);\n \t\treturn;\n \t}\n@@ -9917,8 +9911,8 @@ void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status)\n \telse\n \t\tchanged = hci_dev_test_and_clear_flag(hdev, HCI_LINK_SECURITY);\n \n-\tmgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, settings_rsp,\n-\t\t\t &match);\n+\tmgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, true,\n+\t\t\t settings_rsp, &match);\n \n \tif (changed)\n \t\tnew_settings(hdev, match.sk);\n@@ -9942,9 +9936,12 @@ void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,\n {\n \tstruct cmd_lookup match = { NULL, hdev, mgmt_status(status) };\n \n-\tmgmt_pending_foreach(MGMT_OP_SET_DEV_CLASS, hdev, sk_lookup, &match);\n-\tmgmt_pending_foreach(MGMT_OP_ADD_UUID, hdev, sk_lookup, &match);\n-\tmgmt_pending_foreach(MGMT_OP_REMOVE_UUID, hdev, sk_lookup, &match);\n+\tmgmt_pending_foreach(MGMT_OP_SET_DEV_CLASS, hdev, false, sk_lookup,\n+\t\t\t &match);\n+\tmgmt_pending_foreach(MGMT_OP_ADD_UUID, hdev, false, sk_lookup,\n+\t\t\t &match);\n+\tmgmt_pending_foreach(MGMT_OP_REMOVE_UUID, hdev, false, sk_lookup,\n+\t\t\t &match);\n \n \tif (!status) {\n \t\tmgmt_limited_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, dev_class,",215 "prediction": "Given the following original C code:\nstruct cmd_lookup {\n\tstruct sock *sk;\n\tstruct hci_dev *hdev;\n\tu8 mgmt_status;\n};\n\nstatic void settings_rsp(struct mgmt_pending_cmd *cmd, void *data)\n{\n\tstruct cmd_lookup *match = data;\n\n\tsend_settings_rsp(cmd->sk, cmd->opcode, match->hdev);\n\n\tlist_del(&cmd->list);\n\n\tif (match->sk == NULL) {\n\t\tmatch->sk = cmd->sk;\n\t\tsock_hold(match->sk);\n\t}\n\n\tmgmt_pending_free(cmd);\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n @@ -110,10 +110,10 @@ static void settings_rsp(struct mgmt_pending_cmd *cmd, void *data)\n \n \tsend_settings_rsp(cmd->sk, cmd->opcode, match->hdev);\n \n-\tlist_del(&cmd->list);\n+\tlist_del_init(&cmd->list);\n \n \tif (match->sk == NULL) {\n \t\tmatch->sk = cmd->sk;\n \t\tsock_hold(match->sk);\n \t}\n-\n \tmgmt_pending_free(cmd);\n \n \tif (match->sk)\n@@ -124,10 +124,10 @@ static void settings_rsp(struct mgmt_pending_cmd *cmd, void *data)\n \n \tsend_settings_rsp(cmd->sk, cmd->opcode, match->hdev);\n \n-\tlist_del(&cmd->list);\n+\tlist_del_init(&cmd->list);"216 },217 {218 "prompt": "Given the following original C code:\nif (mskb) {\n\t\thci_send_to_channel(HCI_CHANNEL_MONITOR, mskb,\n\t\t\t\t HCI_SOCK_TRUSTED, NULL);\n\t\tkfree_skb(mskb);\n\t}\n\n\treturn err;\n}\n\nstruct mgmt_pending_cmd *mgmt_pending_find(unsigned short channel, u16 opcode,\n\t\t\t\t\t struct hci_dev *hdev)\n{\n\tstruct mgmt_pending_cmd *cmd;\n\n\tlist_for_each_entry(cmd, &hdev->mgmt_pending, list) {\n\t\tif (hci_sock_get_channel(cmd->sk) != channel)\n\t\t\tcontinue;\n\t\tif (cmd->opcode == opcode)\n\t\t\treturn cmd;\n\t}\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n",219 "reference": "@@ -217,30 +217,47 @@ int mgmt_cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status,\n struct mgmt_pending_cmd *mgmt_pending_find(unsigned short channel, u16 opcode,\n \t\t\t\t\t struct hci_dev *hdev)\n {\n-\tstruct mgmt_pending_cmd *cmd;\n+\tstruct mgmt_pending_cmd *cmd, *tmp;\n+\n+\tmutex_lock(&hdev->mgmt_pending_lock);\n \n-\tlist_for_each_entry(cmd, &hdev->mgmt_pending, list) {\n+\tlist_for_each_entry_safe(cmd, tmp, &hdev->mgmt_pending, list) {\n \t\tif (hci_sock_get_channel(cmd->sk) != channel)\n \t\t\tcontinue;\n-\t\tif (cmd->opcode == opcode)\n+\n+\t\tif (cmd->opcode == opcode) {\n+\t\t\tmutex_unlock(&hdev->mgmt_pending_lock);\n \t\t\treturn cmd;\n+\t\t}\n \t}\n \n+\tmutex_unlock(&hdev->mgmt_pending_lock);\n+\n \treturn NULL;\n }\n \n-void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev,\n+void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, bool remove,\n \t\t\t void (*cb)(struct mgmt_pending_cmd *cmd, void *data),\n \t\t\t void *data)\n {\n \tstruct mgmt_pending_cmd *cmd, *tmp;\n \n+\tmutex_lock(&hdev->mgmt_pending_lock);\n+\n \tlist_for_each_entry_safe(cmd, tmp, &hdev->mgmt_pending, list) {\n \t\tif (opcode > 0 && cmd->opcode != opcode)\n \t\t\tcontinue;\n \n+\t\tif (remove)\n+\t\t\tlist_del(&cmd->list);\n+\n \t\tcb(cmd, data);\n+\n+\t\tif (remove)\n+\t\t\tmgmt_pending_free(cmd);\n \t}\n+\n+\tmutex_unlock(&hdev->mgmt_pending_lock);\n }\n \n struct mgmt_pending_cmd *mgmt_pending_new(struct sock *sk, u16 opcode,\n@@ -254,7 +271,7 @@ struct mgmt_pending_cmd *mgmt_pending_new(struct sock *sk, u16 opcode,\n \t\treturn NULL;\n \n \tcmd->opcode = opcode;\n-\tcmd->index = hdev->id;\n+\tcmd->hdev = hdev;\n \n \tcmd->param = kmemdup(data, len, GFP_KERNEL);\n \tif (!cmd->param) {\n@@ -280,7 +297,9 @@ struct mgmt_pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode,\n \tif (!cmd)\n \t\treturn NULL;\n \n+\tmutex_lock(&hdev->mgmt_pending_lock);\n \tlist_add_tail(&cmd->list, &hdev->mgmt_pending);\n+\tmutex_unlock(&hdev->mgmt_pending_lock);\n \n \treturn cmd;\n }\n@@ -294,7 +313,10 @@ void mgmt_pending_free(struct mgmt_pending_cmd *cmd)\n \n void mgmt_pending_remove(struct mgmt_pending_cmd *cmd)\n {\n+\tmutex_lock(&cmd->hdev->mgmt_pending_lock);\n \tlist_del(&cmd->list);\n+\tmutex_unlock(&cmd->hdev->mgmt_pending_lock);\n+\n \tmgmt_pending_free(cmd);\n }",220 "prediction": "Given the following original C code:\nif (mskb) {\n\t\thci_send_to_channel(HCI_CHANNEL_MONITOR, mskb,\n\t\t\t\t HCI_SOCK_TRUSTED, NULL);\n\t\tkfree_skb(mskb);\n\t}\n\n\treturn err;\n}\n\nstruct mgmt_pending_cmd *mgmt_pending_find(unsigned short channel, u16 opcode,\n\t\t\t\t\t struct hci_dev *hdev)\n{\n\tstruct mgmt_pending_cmd *cmd;\n\n\tlist_for_each_entry(cmd, &hdev->mgmt_pending, list) {\n\t\tif (hci_sock_get_channel(cmd->sk) != channel)\n\t\t\tcontinue;\n\t\tif (cmd->opcode == opcode)\n\t\t\treturn cmd;\n\t}\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n @@ -100,10 +100,10 @@ int mgmt_event(u16 event, struct hci_dev *hdev, void *data, u16 data_len,\n \n struct mgmt_pending_cmd *mgmt_pending_find(unsigned short channel, u16 opcode,\n \t\t\t\t\t struct hci_dev *hdev)\n+{\n+\tstruct mgmt_pending_cmd *cmd;\n+\n {\n \tstruct mgmt_pending_cmd *cmd;\n \n \tlist_for_each_entry(cmd, &hdev->mgmt_pending, list) {\n-\t\tif (hci_sock_get_channel(cmd->sk) != channel)\n-\t\t\tcontinue;\n-\t\tif (cmd->opcode == opcode)\n+\t\tif (hci_sock_get_channel(cmd->sk) != channel)\n+\t\t\tcontinue;\n+\t\tif (cmd->opcode == opcode)"221 },222 {223 "prompt": "Given the following original C code:\nstruct list_head list;\n\tint index;\n\tsize_t param_len;\n\tstruct sock *sk;\n\tu8 handle;\n\tu8 instance;\n\tu8 param[sizeof(struct mgmt_cp_mesh_send) + 31];\n};\n\nstruct mgmt_pending_cmd {\n\tstruct list_head list;\n\tu16 opcode;\n\tint index;\n\tvoid *param;\n\tsize_t param_len;\n\tstruct sock *sk;\n\tstruct sk_buff *skb;\n\tvoid *user_data;\n\tint (*cmd_complete)(struct mgmt_pending_cmd *cmd, u8 status);\n};\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n",224 "reference": "@@ -33,7 +33,7 @@ struct mgmt_mesh_tx {\n struct mgmt_pending_cmd {\n \tstruct list_head list;\n \tu16 opcode;\n-\tint index;\n+\tstruct hci_dev *hdev;\n \tvoid *param;\n \tsize_t param_len;\n \tstruct sock *sk;\n@@ -54,7 +54,7 @@ int mgmt_cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status,\n \n struct mgmt_pending_cmd *mgmt_pending_find(unsigned short channel, u16 opcode,\n \t\t\t\t\t struct hci_dev *hdev);\n-void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev,\n+void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, bool remove,\n \t\t\t void (*cb)(struct mgmt_pending_cmd *cmd, void *data),\n \t\t\t void *data);\n struct mgmt_pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode,",225 "prediction": "Given the following original C code:\nstruct list_head list;\n\tint index;\n\tsize_t param_len;\n\tstruct sock *sk;\n\tu8 handle;\n\tu8 instance;\n\tu8 param[sizeof(struct mgmt_cp_mesh_send) + 31];\n};\n\nstruct mgmt_pending_cmd {\n\tstruct list_head list;\n\tu16 opcode;\n\tint index;\n\tvoid *param;\n\tsize_t param_len;\n\tstruct sock *sk;\n\tstruct sk_buff *skb;\n\tvoid *user_data;\n\tint (*cmd_complete)(struct mgmt_pending_cmd *cmd, u8 status);\n};\n\nInstruction:\nBluetooth: MGMT: Protect mgmt_pending list with its own lock\n\nReturn the diff that fixes it:\n @@ -104,6 +104,7 @@ struct mgmt_pending_param {\n struct mgmt_pending_cmd {\n \tstruct list_head list;\n \tu16 opcode;\n+\tstruct mutex cmd_lock;\n \tint index;\n \tvoid *param;\n \tsize_t param_len;\n@@ -113,6 +114,7 @@ struct mgmt_pending_cmd {\n \tstruct sk_buff *skb;\n \tvoid *user_data;\n \tint (*cmd_complete)(struct mgmt_pending_cmd *cmd, u8 status);\n+\tvoid (*free_param)(void *param);\n };\n \n struct mgmt_pending_param *mgmt_pending_param_add(struct mgmt_pending_cmd *cmd,\n@@ -121,6 +123,7 @@ struct mgmt_pending_cmd *mgmt_pending_cmd_add(u16 opcode, int index"226 },227 {228 "prompt": "Given the following original C code:\nextern const struct raid6_calls raid6_avx2x2;\nextern const struct raid6_calls raid6_avx2x4;\nextern const struct raid6_calls raid6_avx512x1;\nextern const struct raid6_calls raid6_avx512x2;\nextern const struct raid6_calls raid6_avx512x4;\nextern const struct raid6_calls raid6_s390vx8;\nextern const struct raid6_calls raid6_vpermxor1;\nextern const struct raid6_calls raid6_vpermxor2;\nextern const struct raid6_calls raid6_vpermxor4;\nextern const struct raid6_calls raid6_vpermxor8;\nextern const struct raid6_calls raid6_lsx;\nextern const struct raid6_calls raid6_lasx;\n\nstruct raid6_recov_calls {\n\tvoid (*data2)(int, size_t, int, int, void **);\n\tvoid (*datap)(int, size_t, int, void **);\n\tint (*valid)(void);\n\tconst char *name;\n\tint priority;\n};\n\nInstruction:\nraid6: Add RISC-V SIMD syndrome and recovery calculations\n\nReturn the diff that fixes it:\n",229 "reference": "@@ -108,6 +108,10 @@ extern const struct raid6_calls raid6_vpermxor4;\n extern const struct raid6_calls raid6_vpermxor8;\n extern const struct raid6_calls raid6_lsx;\n extern const struct raid6_calls raid6_lasx;\n+extern const struct raid6_calls raid6_rvvx1;\n+extern const struct raid6_calls raid6_rvvx2;\n+extern const struct raid6_calls raid6_rvvx4;\n+extern const struct raid6_calls raid6_rvvx8;\n \n struct raid6_recov_calls {\n \tvoid (*data2)(int, size_t, int, int, void **);\n@@ -125,6 +129,7 @@ extern const struct raid6_recov_calls raid6_recov_s390xc;\n extern const struct raid6_recov_calls raid6_recov_neon;\n extern const struct raid6_recov_calls raid6_recov_lsx;\n extern const struct raid6_recov_calls raid6_recov_lasx;\n+extern const struct raid6_recov_calls raid6_recov_rvv;\n \n extern const struct raid6_calls raid6_neonx1;\n extern const struct raid6_calls raid6_neonx2;",230 "prediction": "Given the following original C code:\nextern const struct raid6_calls raid6_avx2x2;\nextern const struct raid6_calls raid6_avx2x4;\nextern const struct raid6_calls raid6_avx512x1;\nextern const struct raid6_calls raid6_avx512x2;\nextern const struct raid6_calls raid6_avx512x4;\nextern const struct raid6_calls raid6_s390vx8;\nextern const struct raid6_calls raid6_vpermxor1;\nextern const struct raid6_calls raid6_vpermxor2;\nextern const struct raid6_calls raid6_vpermxor4;\nextern const struct raid6_calls raid6_vpermxor8;\nextern const struct raid6_calls raid6_lsx;\nextern const struct raid6_calls raid6_lasx;\n\nstruct raid6_recov_calls {\n\tvoid (*data2)(int, size_t, int, int, void **);\n\tvoid (*datap)(int, size_t, int, void **);\n\tint (*valid)(void);\n\tconst char *name;\n\tint priority;\n};\n\nInstruction:\nraid6: Add RISC-V SIMD syndrome and recovery calculations\n\nReturn the diff that fixes it:\n @@ -106,6 +106,10 @@ extern const struct raid6_calls raid6_vpermxor4;\n extern const struct raid6_calls raid6_vpermxor8;\n extern const struct raid6_calls raid6_lsx;\n extern const struct raid6_calls raid6_lasx;\n+extern const struct raid6_calls raid6_riscv;\n+extern const struct raid6_calls raid6_riscv_syndrome;\n+extern const struct raid6_calls raid6_riscv_recov;\n+extern const struct raid6_calls raid6_riscv_xor;\n+\n \n struct raid6_recov_calls {\n \tvoid (*data2)(int, size_t, int, int, void **);\n@@ -113,6 +117,7 @@ struct raid6_recov_calls {\n \tint (*valid)(void);\n \tconst"231 },232 {233 "prompt": "Given the following original C code:\n&raid6_neonx8,\n\t&raid6_neonx4,\n\t&raid6_neonx2,\n\t&raid6_neonx1,\n#endif\n#ifdef CONFIG_LOONGARCH\n#ifdef CONFIG_CPU_HAS_LASX\n\t&raid6_lasx,\n#endif\n#ifdef CONFIG_CPU_HAS_LSX\n\t&raid6_lsx,\n#endif\n#endif\n\t&raid6_intx8,\n\t&raid6_intx4,\n\t&raid6_intx2,\n\t&raid6_intx1,\n\tNULL\n};\n\nInstruction:\nraid6: Add RISC-V SIMD syndrome and recovery calculations\n\nReturn the diff that fixes it:\n",234 "reference": "@@ -80,6 +80,12 @@ const struct raid6_calls * const raid6_algos[] = {\n #ifdef CONFIG_CPU_HAS_LSX\n \t&raid6_lsx,\n #endif\n+#endif\n+#ifdef CONFIG_RISCV_ISA_V\n+\t&raid6_rvvx1,\n+\t&raid6_rvvx2,\n+\t&raid6_rvvx4,\n+\t&raid6_rvvx8,\n #endif\n \t&raid6_intx8,\n \t&raid6_intx4,\n@@ -115,6 +121,9 @@ const struct raid6_recov_calls *const raid6_recov_algos[] = {\n #ifdef CONFIG_CPU_HAS_LSX\n \t&raid6_recov_lsx,\n #endif\n+#endif\n+#ifdef CONFIG_RISCV_ISA_V\n+\t&raid6_recov_rvv,\n #endif\n \t&raid6_recov_intx1,\n \tNULL",235 "prediction": "Given the following original C code:\n&raid6_neonx8,\n\t&raid6_neonx4,\n\t&raid6_neonx2,\n\t&raid6_neonx1,\n#endif\n#ifdef CONFIG_LOONGARCH\n#ifdef CONFIG_CPU_HAS_LASX\n\t&raid6_lasx,\n#endif\n#ifdef CONFIG_CPU_HAS_LSX\n\t&raid6_lsx,\n#endif\n#endif\n\t&raid6_intx8,\n\t&raid6_intx4,\n\t&raid6_intx2,\n\t&raid6_intx1,\n\tNULL\n};\n\nInstruction:\nraid6: Add RISC-V SIMD syndrome and recovery calculations\n\nReturn the diff that fixes it:\n @@ -105,6 +105,10 @@ struct raid6_rec_ops *raid6_rec_ops[] = {\n #ifdef CONFIG_CPU_HAS_LSX\n \t&raid6_lsx,\n #endif\n+#ifdef CONFIG_CPU_HAS_RISCV_SIMD\n+\t&raid6_riscv_simd,\n+#endif\n+\n #endif\n \t&raid6_intx8,\n \t&raid6_intx4,\n@@ -113,6 +117,10 @@ struct raid6_rec_ops *raid6_rec_ops[] = {\n \t&raid6_intx2,\n \t&raid6_intx1,\n \tNULL\n+#ifdef CONFIG_CPU_HAS_RISCV_SIMD\n+\t, &raid6_riscv_simd\n+#endif\n };\n \n #ifdef CONFIG_CPU_HAS_LASX\n@@ -121,6 +1"236 },237 {238 "prompt": "Given the following original C code:\n#define RISCV_PREEMPT_V_NEED_RESTORE\t0x40000000\n#define RISCV_PREEMPT_V_IN_SCHEDULE\t0x20000000\n\n/* CPU-specific state of a task */\nstruct thread_struct {\n\t/* Callee-saved registers */\n\tunsigned long ra;\n\tunsigned long sp;\t/* Kernel mode stack */\n\tunsigned long s[12];\t/* s[0]: frame pointer */\n\tstruct __riscv_d_ext_state fstate;\n\tunsigned long bad_cause;\n\tunsigned long envcfg;\n\tunsigned long status;\n\tu32 riscv_v_flags;\n\tu32 vstate_ctrl;\n\tstruct __riscv_v_ext_state vstate;\n\tunsigned long align_ctl;\n\tstruct __riscv_v_ext_state kernel_vstate;\n#ifdef CONFIG_SMP\n\t/* Flush the icache on migration */\n\nInstruction:\nriscv: uaccess: Only restore the CSR_STATUS SUM bit\n\nReturn the diff that fixes it:\n",239 "reference": "@@ -110,7 +110,7 @@ struct thread_struct {\n \tstruct __riscv_d_ext_state fstate;\n \tunsigned long bad_cause;\n \tunsigned long envcfg;\n-\tunsigned long status;\n+\tunsigned long sum;\n \tu32 riscv_v_flags;\n \tu32 vstate_ctrl;\n \tstruct __riscv_v_ext_state vstate;",240 "prediction": "Given the following original C code:\n#define RISCV_PREEMPT_V_NEED_RESTORE\t0x40000000\n#define RISCV_PREEMPT_V_IN_SCHEDULE\t0x20000000\n\n/* CPU-specific state of a task */\nstruct thread_struct {\n\t/* Callee-saved registers */\n\tunsigned long ra;\n\tunsigned long sp;\t/* Kernel mode stack */\n\tunsigned long s[12];\t/* s[0]: frame pointer */\n\tstruct __riscv_d_ext_state fstate;\n\tunsigned long bad_cause;\n\tunsigned long envcfg;\n\tunsigned long status;\n\tu32 riscv_v_flags;\n\tu32 vstate_ctrl;\n\tstruct __riscv_v_ext_state vstate;\n\tunsigned long align_ctl;\n\tstruct __riscv_v_ext_state kernel_vstate;\n#ifdef CONFIG_SMP\n\t/* Flush the icache on migration */\n\nInstruction:\nriscv: uaccess: Only restore the CSR_STATUS SUM bit\n\nReturn the diff that fixes it:\n @@ -100,7 +100,6 @@ struct thread_struct {\n \tstruct __riscv_d_ext_state fstate;\n \tunsigned long bad_cause;\n \tunsigned long envcfg;\n-\tunsigned long status;\n \tu32 riscv_v_flags;\n \tu32 vstate_ctrl;\n \tstruct __riscv_v_ext_state vstate;\n@@ -109,7 +108,6 @@ struct thread_struct {\n \tunsigned long align_ctl;\n \tstruct __riscv_v_ext_state kernel_vstate;\n #ifdef CONFIG_SMP\n-\t/* Flush the icache on migration */\n #endif\n };\n \n@@ -118,7 +116,6 @@ struct thread_struct {\n #endif\n \n #define INIT_THREAD {\t\t\t\t\t\t\t\\\n-\t.status = SR_SIE,\t\t\t\t\t\t\\\n \t.riscv_v_flags = RISCV_"241 },242 {243 "prompt": "Given the following original C code:\nOFFSET(TASK_THREAD_S0, task_struct, thread.s[0]);\n\tOFFSET(TASK_THREAD_S1, task_struct, thread.s[1]);\n\tOFFSET(TASK_THREAD_S2, task_struct, thread.s[2]);\n\tOFFSET(TASK_THREAD_S3, task_struct, thread.s[3]);\n\tOFFSET(TASK_THREAD_S4, task_struct, thread.s[4]);\n\tOFFSET(TASK_THREAD_S5, task_struct, thread.s[5]);\n\tOFFSET(TASK_THREAD_S6, task_struct, thread.s[6]);\n\tOFFSET(TASK_THREAD_S7, task_struct, thread.s[7]);\n\tOFFSET(TASK_THREAD_S8, task_struct, thread.s[8]);\n\tOFFSET(TASK_THREAD_S9, task_struct, thread.s[9]);\n\tOFFSET(TASK_THREAD_S10, task_struct, thread.s[10]);\n\tOFFSET(TASK_THREAD_S11, task_struct, thread.s[11]);\n\tOFFSET(TASK_THREAD_STATUS, task_struct, thread.status);\n\n\tOFFSET(TASK_TI_CPU, task_struct, thread_info.cpu);\n\tOFFSET(TASK_TI_PREEMPT_COUNT, task_struct, thread_info.preempt_count);\n\tOFFSET(TASK_TI_KERNEL_SP, task_struct, thread_info.kernel_sp);\n\tOFFSET(TASK_TI_USER_SP, task_struct, thread_info.user_sp);\n#ifdef CONFIG_SHADOW_CALL_STACK\n\tOFFSET(TASK_TI_SCS_SP, task_struct, thread_info.scs_sp);\n\nInstruction:\nriscv: uaccess: Only restore the CSR_STATUS SUM bit\n\nReturn the diff that fixes it:\n",244 "reference": "@@ -34,7 +34,7 @@ void asm_offsets(void)\n \tOFFSET(TASK_THREAD_S9, task_struct, thread.s[9]);\n \tOFFSET(TASK_THREAD_S10, task_struct, thread.s[10]);\n \tOFFSET(TASK_THREAD_S11, task_struct, thread.s[11]);\n-\tOFFSET(TASK_THREAD_STATUS, task_struct, thread.status);\n+\tOFFSET(TASK_THREAD_SUM, task_struct, thread.sum);\n \n \tOFFSET(TASK_TI_CPU, task_struct, thread_info.cpu);\n \tOFFSET(TASK_TI_PREEMPT_COUNT, task_struct, thread_info.preempt_count);\n@@ -347,8 +347,8 @@ void asm_offsets(void)\n \t\t offsetof(struct task_struct, thread.s[11])\n \t\t- offsetof(struct task_struct, thread.ra)\n \t);\n-\tDEFINE(TASK_THREAD_STATUS_RA,\n-\t\t offsetof(struct task_struct, thread.status)\n+\tDEFINE(TASK_THREAD_SUM_RA,\n+\t\t offsetof(struct task_struct, thread.sum)\n \t\t- offsetof(struct task_struct, thread.ra)\n \t);",245 "prediction": "Given the following original C code:\nOFFSET(TASK_THREAD_S0, task_struct, thread.s[0]);\n\tOFFSET(TASK_THREAD_S1, task_struct, thread.s[1]);\n\tOFFSET(TASK_THREAD_S2, task_struct, thread.s[2]);\n\tOFFSET(TASK_THREAD_S3, task_struct, thread.s[3]);\n\tOFFSET(TASK_THREAD_S4, task_struct, thread.s[4]);\n\tOFFSET(TASK_THREAD_S5, task_struct, thread.s[5]);\n\tOFFSET(TASK_THREAD_S6, task_struct, thread.s[6]);\n\tOFFSET(TASK_THREAD_S7, task_struct, thread.s[7]);\n\tOFFSET(TASK_THREAD_S8, task_struct, thread.s[8]);\n\tOFFSET(TASK_THREAD_S9, task_struct, thread.s[9]);\n\tOFFSET(TASK_THREAD_S10, task_struct, thread.s[10]);\n\tOFFSET(TASK_THREAD_S11, task_struct, thread.s[11]);\n\tOFFSET(TASK_THREAD_STATUS, task_struct, thread.status);\n\n\tOFFSET(TASK_TI_CPU, task_struct, thread_info.cpu);\n\tOFFSET(TASK_TI_PREEMPT_COUNT, task_struct, thread_info.preempt_count);\n\tOFFSET(TASK_TI_KERNEL_SP, task_struct, thread_info.kernel_sp);\n\tOFFSET(TASK_TI_USER_SP, task_struct, thread_info.user_sp);\n#ifdef CONFIG_SHADOW_CALL_STACK\n\tOFFSET(TASK_TI_SCS_SP, task_struct, thread_info.scs_sp);\n\nInstruction:\nriscv: uaccess: Only restore the CSR_STATUS SUM bit\n\nReturn the diff that fixes it:\n @@ -101,6 +101,7 @@ static int __init offset_sanity_check(void)\n \tOFFSET(TASK_THREAD_S8, task_struct, thread.s[8]);\n \tOFFSET(TASK_THREAD_S9, task_struct, thread.s[9]);\n \tOFFSET(TASK_THREAD_S10, task_struct, thread.s[10]);\n+\tOFFSET(TASK_THREAD_S11, task_struct, thread.s[11]);\n \tOFFSET(TASK_THREAD_STATUS, task_struct, thread.status);\n \n \tOFFSET(TASK_TI_CPU, task_struct, thread_info.cpu);\n@@ -109,6 +110,7 @@ static int __init offset_sanity_check(void)\n \tOFFSET(TASK_TI_KERNEL_SP, task_struct, thread_info.kernel_sp);\n \tOFFSET(TAS"246 },247 {248 "prompt": "Given the following original C code:\nif (is58xx(dev)) {\n\t\t\tb53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN,\n\t\t\t\t ®);\n\t\t\treg &= ~BIT(port);\n\t\t\tif ((reg & BIT(cpu_port)) == BIT(cpu_port))\n\t\t\t\treg &= ~BIT(cpu_port);\n\t\t\tb53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN,\n\t\t\t\t reg);\n\t\t}\n\n\t\tb53_get_vlan_entry(dev, pvid, vl);\n\t\tvl->members &= ~BIT(port);\n\t\tif (vl->members == BIT(cpu_port))\n\t\t\tvl->members &= ~BIT(cpu_port);\n\t\tvl->untag = vl->members;\n\t\tb53_set_vlan_entry(dev, pvid, vl);\n\t}\n\n\tb53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan);\n\nInstruction:\nnet: dsa: b53: fix untagged traffic sent via cpu tagged with VID 0\n\nReturn the diff that fixes it:\n",249 "reference": "@@ -2034,9 +2034,6 @@ int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge,\n \n \t\tb53_get_vlan_entry(dev, pvid, vl);\n \t\tvl->members &= ~BIT(port);\n-\t\tif (vl->members == BIT(cpu_port))\n-\t\t\tvl->members &= ~BIT(cpu_port);\n-\t\tvl->untag = vl->members;\n \t\tb53_set_vlan_entry(dev, pvid, vl);\n \t}\n \n@@ -2115,8 +2112,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge)\n \t\t}\n \n \t\tb53_get_vlan_entry(dev, pvid, vl);\n-\t\tvl->members |= BIT(port) | BIT(cpu_port);\n-\t\tvl->untag |= BIT(port) | BIT(cpu_port);\n+\t\tvl->members |= BIT(port);\n \t\tb53_set_vlan_entry(dev, pvid, vl);\n \t}\n }",250 "prediction": "Given the following original C code:\nif (is58xx(dev)) {\n\t\t\tb53_read16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN,\n\t\t\t\t ®);\n\t\t\treg &= ~BIT(port);\n\t\t\tif ((reg & BIT(cpu_port)) == BIT(cpu_port))\n\t\t\t\treg &= ~BIT(cpu_port);\n\t\t\tb53_write16(dev, B53_VLAN_PAGE, B53_JOIN_ALL_VLAN_EN,\n\t\t\t\t reg);\n\t\t}\n\n\t\tb53_get_vlan_entry(dev, pvid, vl);\n\t\tvl->members &= ~BIT(port);\n\t\tif (vl->members == BIT(cpu_port))\n\t\t\tvl->members &= ~BIT(cpu_port);\n\t\tvl->untag = vl->members;\n\t\tb53_set_vlan_entry(dev, pvid, vl);\n\t}\n\n\tb53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan);\n\nInstruction:\nnet: dsa: b53: fix untagged traffic sent via cpu tagged with VID 0\n\nReturn the diff that fixes it:\n A @@ -107,7 +107,7 @@ static int b53_port_vlan_setup(struct dsa_switch *ds, int port,\n \n \t\tb53_get_vlan_entry(dev, pvid, vl);\n \t\tvl->members &= ~BIT(port);\n-\t\tif (vl->members == BIT(cpu_port))\n+\t\tif (vl->members == 0)\n \t\t\tvl->members &= ~BIT(cpu_port);\n \t\tvl->untag = vl->members;\n \t\tb53_set_vlan_entry(dev, pvid, vl);\n@@ -115,7 +115,7 @@ static int b53_port_vlan_setup(struct dsa_switch *ds, int port,\n \n \tb53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan);\n \tpvlan &="251 },252 {253 "prompt": "Given the following original C code:\n{\n\t/*\n\t * Paired with WRITE_ONCE() in enqueue_external_timestamp(),\n\t * ptp_read(), extts_fifo_show().\n\t */\n\tint cnt = READ_ONCE(q->tail) - READ_ONCE(q->head);\n\treturn cnt < 0 ? PTP_MAX_TIMESTAMPS + cnt : cnt;\n}\n\n/* Check if ptp virtual clock is in use */\nstatic inline bool ptp_vclock_in_use(struct ptp_clock *ptp)\n{\n\tbool in_use = false;\n\n\tif (mutex_lock_interruptible(&ptp->n_vclocks_mux))\n\t\treturn true;\n\n\tif (!ptp->is_virtual_clock && ptp->n_vclocks)\n\t\tin_use = true;\n\nInstruction:\nptp: remove ptp->n_vclocks check logic in ptp_vclock_in_use()\n\nReturn the diff that fixes it:\n",254 "reference": "@@ -98,17 +98,7 @@ static inline int queue_cnt(const struct timestamp_event_queue *q)\n /* Check if ptp virtual clock is in use */\n static inline bool ptp_vclock_in_use(struct ptp_clock *ptp)\n {\n-\tbool in_use = false;\n-\n-\tif (mutex_lock_interruptible(&ptp->n_vclocks_mux))\n-\t\treturn true;\n-\n-\tif (!ptp->is_virtual_clock && ptp->n_vclocks)\n-\t\tin_use = true;\n-\n-\tmutex_unlock(&ptp->n_vclocks_mux);\n-\n-\treturn in_use;\n+\treturn !ptp->is_virtual_clock;\n }\n \n /* Check if ptp clock shall be free running */",255 "prediction": "Given the following original C code:\n{\n\t/*\n\t * Paired with WRITE_ONCE() in enqueue_external_timestamp(),\n\t * ptp_read(), extts_fifo_show().\n\t */\n\tint cnt = READ_ONCE(q->tail) - READ_ONCE(q->head);\n\treturn cnt < 0 ? PTP_MAX_TIMESTAMPS + cnt : cnt;\n}\n\n/* Check if ptp virtual clock is in use */\nstatic inline bool ptp_vclock_in_use(struct ptp_clock *ptp)\n{\n\tbool in_use = false;\n\n\tif (mutex_lock_interruptible(&ptp->n_vclocks_mux))\n\t\treturn true;\n\n\tif (!ptp->is_virtual_clock && ptp->n_vclocks)\n\t\tin_use = true;\n\nInstruction:\nptp: remove ptp->n_vclocks check logic in ptp_vclock_in_use()\n\nReturn the diff that fixes it:\n @@ -108,16 +108,12 @@ static inline int ptp_extts_fifo_count(struct ptp_extts_queue *q)\n /* Check if ptp virtual clock is in use */\n static inline bool ptp_vclock_in_use(struct ptp_clock *ptp)\n {\n-\tbool in_use = false;\n-\n-\tif (mutex_lock_interruptible(&ptp->n_vclocks_mux))\n-\t\treturn true;\n-\n-\tif (!ptp->is_virtual_clock && ptp->n_vclocks)\n-\t\tin_use = true;\n-\n-\tmutex_unlock(&ptp->n_vclocks_mux);\n+\treturn mutex_lock_interruptible(&ptp->n_vclocks_mux);\n }\n \n /* Check if ptp clock is in use */\n static inline bool ptp_clock_in_use(struct ptp_clock *ptp)\n@@ -126,11 +"256 },257 {258 "prompt": "Given the following original C code:\nr535_vfn_new(const struct nvkm_vfn_func *hw,\n\t struct nvkm_device *device, enum nvkm_subdev_type type, int inst, u32 addr,\n\t struct nvkm_vfn **pvfn)\n{\n\tconst struct nvkm_rm_gpu *gpu = device->gsp->rm->gpu;\n\tstruct nvkm_vfn_func *rm;\n\tint ret;\n\n\tif (!(rm = kzalloc(sizeof(*rm), GFP_KERNEL)))\n\t\treturn -ENOMEM;\n\n\trm->dtor = r535_vfn_dtor;\n\trm->intr = &tu102_vfn_intr,\n\trm->user.addr = 0x030000;\n\trm->user.size = 0x010000;\n\trm->user.base.minver = -1;\n\trm->user.base.maxver = -1;\n\trm->user.base.oclass = gpu->usermode.class;\n\n\tret = nvkm_vfn_new_(rm, device, type, inst, addr, pvfn);\n\nInstruction:\ndrm/nouveau/vfn/r535: Convert comma to semicolon\n\nReturn the diff that fixes it:\n",259 "reference": "@@ -42,7 +42,7 @@ r535_vfn_new(const struct nvkm_vfn_func *hw,\n \t\treturn -ENOMEM;\n \n \trm->dtor = r535_vfn_dtor;\n-\trm->intr = &tu102_vfn_intr,\n+\trm->intr = &tu102_vfn_intr;\n \trm->user.addr = 0x030000;\n \trm->user.size = 0x010000;\n \trm->user.base.minver = -1;",260 "prediction": "Given the following original C code:\nr535_vfn_new(const struct nvkm_vfn_func *hw,\n\t struct nvkm_device *device, enum nvkm_subdev_type type, int inst, u32 addr,\n\t struct nvkm_vfn **pvfn)\n{\n\tconst struct nvkm_rm_gpu *gpu = device->gsp->rm->gpu;\n\tstruct nvkm_vfn_func *rm;\n\tint ret;\n\n\tif (!(rm = kzalloc(sizeof(*rm), GFP_KERNEL)))\n\t\treturn -ENOMEM;\n\n\trm->dtor = r535_vfn_dtor;\n\trm->intr = &tu102_vfn_intr,\n\trm->user.addr = 0x030000;\n\trm->user.size = 0x010000;\n\trm->user.base.minver = -1;\n\trm->user.base.maxver = -1;\n\trm->user.base.oclass = gpu->usermode.class;\n\n\tret = nvkm_vfn_new_(rm, device, type, inst, addr, pvfn);\n\nInstruction:\ndrm/nouveau/vfn/r535: Convert comma to semicolon\n\nReturn the diff that fixes it:\n @@ -109,7 +109,7 @@ r535_vfn_new(const struct nvkm_vfn_func *hw,\n \t\treturn -ENOMEM;\n \n \trm->dtor = r535_vfn_dtor;\n-\trm->intr = &tu102_vfn_intr,\n+\trm->intr = &tu102_vfn_intr;\n \trm->user.addr = 0x030000;\n \trm->user.size = 0x010000;\n \trm->user.base.minver = -1;\n@@ -117,7 +117,7 @@ r535_vfn_new(const struct nvkm_vfn_func *hw,\n \n \tret = nvkm_vfn_new_(rm, device, type, inst, addr, pvfn);\n \tif (ret)\n-\t\tkfree(rm);\n+\t\tkfree"261 },262 {263 "prompt": "Given the following original C code:\nadjust = NULL;\n\n\tvp->adj_next = adjust;\n\tif (!vp->anon_vma && adjust)\n\t\tvp->anon_vma = adjust->anon_vma;\n\n\tVM_WARN_ON(vp->anon_vma && adjust && adjust->anon_vma &&\n\t\t vp->anon_vma != adjust->anon_vma);\n\n\tvp->file = vma->vm_file;\n\tif (vp->file)\n\t\tvp->mapping = vma->vm_file->f_mapping;\n}\n\n/*\n * Return true if we can merge this (vm_flags,anon_vma,file,vm_pgoff)\n * in front of (at a lower virtual address and file offset than) the vma.\n *\n * We cannot merge two vmas if they have differently assigned (non-NULL)\n * anon_vmas, nor if same anon_vma is assigned but offsets incompatible.\n\nInstruction:\nmm: fix uprobe pte be overwritten when expanding vma\n\nReturn the diff that fixes it:\n",264 "reference": "@@ -169,6 +169,9 @@ static void init_multi_vma_prep(struct vma_prepare *vp,\n \tvp->file = vma->vm_file;\n \tif (vp->file)\n \t\tvp->mapping = vma->vm_file->f_mapping;\n+\n+\tif (vmg && vmg->skip_vma_uprobe)\n+\t\tvp->skip_vma_uprobe = true;\n }\n \n /*\n@@ -358,10 +361,13 @@ static void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi,\n \n \tif (vp->file) {\n \t\ti_mmap_unlock_write(vp->mapping);\n-\t\tuprobe_mmap(vp->vma);\n \n-\t\tif (vp->adj_next)\n-\t\t\tuprobe_mmap(vp->adj_next);\n+\t\tif (!vp->skip_vma_uprobe) {\n+\t\t\tuprobe_mmap(vp->vma);\n+\n+\t\t\tif (vp->adj_next)\n+\t\t\t\tuprobe_mmap(vp->adj_next);\n+\t\t}\n \t}\n \n \tif (vp->remove) {\n@@ -1823,6 +1829,14 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,\n \t\tfaulted_in_anon_vma = false;\n \t}\n \n+\t/*\n+\t * If the VMA we are copying might contain a uprobe PTE, ensure\n+\t * that we do not establish one upon merge. Otherwise, when mremap()\n+\t * moves page tables, it will orphan the newly created PTE.\n+\t */\n+\tif (vma->vm_file)\n+\t\tvmg.skip_vma_uprobe = true;\n+\n \tnew_vma = find_vma_prev(mm, addr, &vmg.prev);\n \tif (new_vma && new_vma->vm_start < addr + len)\n \t\treturn NULL;\t/* should never get here */",265 "prediction": "Given the following original C code:\nadjust = NULL;\n\n\tvp->adj_next = adjust;\n\tif (!vp->anon_vma && adjust)\n\t\tvp->anon_vma = adjust->anon_vma;\n\n\tVM_WARN_ON(vp->anon_vma && adjust && adjust->anon_vma &&\n\t\t vp->anon_vma != adjust->anon_vma);\n\n\tvp->file = vma->vm_file;\n\tif (vp->file)\n\t\tvp->mapping = vma->vm_file->f_mapping;\n}\n\n/*\n * Return true if we can merge this (vm_flags,anon_vma,file,vm_pgoff)\n * in front of (at a lower virtual address and file offset than) the vma.\n *\n * We cannot merge two vmas if they have differently assigned (non-NULL)\n * anon_vmas, nor if same anon_vma is assigned but offsets incompatible.\n\nInstruction:\nmm: fix uprobe pte be overwritten when expanding vma\n\nReturn the diff that fixes it:\n @@ -100,6 +100,11 @@ static void vma_merge(struct vm_area_struct *vma,\n \n \tvp->file = vma->vm_file;\n \tif (vp->file)\n+\t\tvp->mapping = vma->vm_file->f_mapping;\n+\telse\n+\t\tvp->mapping = NULL;\n+\tvp->vm_pgoff = vma->vm_pgoff;\n+\tvp->vm_flags = vma->vm_flags;\n \tif (vp->file)\n \t\tvp->mapping = vma->vm_file->f_mapping;\n }\n@@ -108,6 +113,7 @@ static void vma_merge(struct vm_area_struct *vma,\n \n \tvp->file = vma->vm_file;\n \tif (vp->file)\n+\t\tvp->vm_pgoff = vma->vm_pgoff;\n \tif (vp"266 },267 {268 "prompt": "Given the following original C code:\n/*\n * VMA lock generalization\n */\nstruct vma_prepare {\n\tstruct vm_area_struct *vma;\n\tstruct vm_area_struct *adj_next;\n\tstruct file *file;\n\tstruct address_space *mapping;\n\tstruct anon_vma *anon_vma;\n\tstruct vm_area_struct *insert;\n\tstruct vm_area_struct *remove;\n\tstruct vm_area_struct *remove2;\n};\n\nstruct unlink_vma_file_batch {\n\tint count;\n\tstruct vm_area_struct *vmas[8];\n};\n\n/*\n\nInstruction:\nmm: fix uprobe pte be overwritten when expanding vma\n\nReturn the diff that fixes it:\n",269 "reference": "@@ -19,6 +19,8 @@ struct vma_prepare {\n \tstruct vm_area_struct *insert;\n \tstruct vm_area_struct *remove;\n \tstruct vm_area_struct *remove2;\n+\n+\tbool skip_vma_uprobe :1;\n };\n \n struct unlink_vma_file_batch {\n@@ -120,6 +122,11 @@ struct vma_merge_struct {\n \t */\n \tbool give_up_on_oom :1;\n \n+\t/*\n+\t * If set, skip uprobe_mmap upon merged vma.\n+\t */\n+\tbool skip_vma_uprobe :1;\n+\n \t/* Internal flags set during merge process: */\n \n \t/*",270 "prediction": "Given the following original C code:\n/*\n * VMA lock generalization\n */\nstruct vma_prepare {\n\tstruct vm_area_struct *vma;\n\tstruct vm_area_struct *adj_next;\n\tstruct file *file;\n\tstruct address_space *mapping;\n\tstruct anon_vma *anon_vma;\n\tstruct vm_area_struct *insert;\n\tstruct vm_area_struct *remove;\n\tstruct vm_area_struct *remove2;\n};\n\nstruct unlink_vma_file_batch {\n\tint count;\n\tstruct vm_area_struct *vmas[8];\n};\n\n/*\n\nInstruction:\nmm: fix uprobe pte be overwritten when expanding vma\n\nReturn the diff that fixes it:\n @@ -14,6 +14,7 @@ struct vma_prepare {\n \tstruct anon_vma *anon_vma;\n \tstruct vm_area_struct *insert;\n \tstruct vm_area_struct *remove;\n+\tstruct vm_area_struct *remove2;\n };\n \n struct unlink_vma_file_batch {\n@@ -23,6 +24,7 @@ struct unlink_vma_file_batch {\n \tint count;\n \tstruct vm_area_struct *vmas[8];\n };\n+#define UNLINK_VMA_BATCH_SIZE 8\n \n /*\n * vma_adjust - adjust a vma's vm_start, vm_end, vm_pgoff, or vm_flags.\n@@ -32,6 +34,7 @@ struct unlink_vma_file_batch {\n * @vma: the vma to adjust\n * @start: new vm_start\n * @end: new vm_end\n+ * @pgoff"271 },272 {273 "prompt": "Given the following original C code:\nif (!new_pte) {\n\t\tpte_unmap_unlock(old_pte, old_ptl);\n\t\terr = -EAGAIN;\n\t\tgoto out;\n\t}\n\tif (new_ptl != old_ptl)\n\t\tspin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);\n\tflush_tlb_batched_pending(vma->vm_mm);\n\tarch_enter_lazy_mmu_mode();\n\n\tfor (; old_addr < old_end; old_pte++, old_addr += PAGE_SIZE,\n\t\t\t\t new_pte++, new_addr += PAGE_SIZE) {\n\t\tif (pte_none(ptep_get(old_pte)))\n\t\t\tcontinue;\n\n\t\tpte = ptep_get_and_clear(mm, old_addr, old_pte);\n\t\t/*\n\t\t * If we are remapping a valid PTE, make sure\n\t\t * to flush TLB before we drop the PTL for the\n\t\t * PTE.\n\nInstruction:\nmm: expose abnormal new_pte during move_ptes\n\nReturn the diff that fixes it:\n",274 "reference": "@@ -237,6 +237,8 @@ static int move_ptes(struct pagetable_move_control *pmc,\n \n \tfor (; old_addr < old_end; old_pte++, old_addr += PAGE_SIZE,\n \t\t\t\t new_pte++, new_addr += PAGE_SIZE) {\n+\t\tVM_WARN_ON_ONCE(!pte_none(*new_pte));\n+\n \t\tif (pte_none(ptep_get(old_pte)))\n \t\t\tcontinue;",275 "prediction": "Given the following original C code:\nif (!new_pte) {\n\t\tpte_unmap_unlock(old_pte, old_ptl);\n\t\terr = -EAGAIN;\n\t\tgoto out;\n\t}\n\tif (new_ptl != old_ptl)\n\t\tspin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);\n\tflush_tlb_batched_pending(vma->vm_mm);\n\tarch_enter_lazy_mmu_mode();\n\n\tfor (; old_addr < old_end; old_pte++, old_addr += PAGE_SIZE,\n\t\t\t\t new_pte++, new_addr += PAGE_SIZE) {\n\t\tif (pte_none(ptep_get(old_pte)))\n\t\t\tcontinue;\n\n\t\tpte = ptep_get_and_clear(mm, old_addr, old_pte);\n\t\t/*\n\t\t * If we are remapping a valid PTE, make sure\n\t\t * to flush TLB before we drop the PTL for the\n\t\t * PTE.\n\nInstruction:\nmm: expose abnormal new_pte during move_ptes\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ int move_ptes(struct vm_area_struct *vma,\n \n \tfor (; old_addr < old_end; old_pte++, old_addr += PAGE_SIZE,\n \t\t\t\t new_pte++, new_addr += PAGE_SIZE) {\n-\t\tif (pte_none(ptep_get(old_pte)))\n+\t\tif (pte_none(*new_pte))\n \t\t\tcontinue;\n \n \t\tpte = ptep_get_and_clear(mm, old_addr, old_pte);\n@@ -116,7 +116,7 @@ int move_ptes(struct vm_area_struct *vma,\n \t\t * to flush TLB before we drop the PTL for the\n \t\t * PTE.\n \t\t */\n-\t\tif (pte_none(pte))\n+\t\tif (pte_none(*new_pte))"276 },277 {278 "prompt": "Given the following original C code:\nasce->val = aste.asce;\n\treturn 0;\n}\n\nenum prot_type {\n\tPROT_TYPE_LA = 0,\n\tPROT_TYPE_KEYC = 1,\n\tPROT_TYPE_ALC = 2,\n\tPROT_TYPE_DAT = 3,\n\tPROT_TYPE_IEP = 4,\n\t/* Dummy value for passing an initialized value when code != PGM_PROTECTION */\n\tPROT_NONE,\n};\n\nstatic int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva, u8 ar,\n\t\t\t enum gacc_mode mode, enum prot_type prot, bool terminate)\n{\n\tstruct kvm_s390_pgm_info *pgm = &vcpu->arch.pgm;\n\tunion teid *teid;\n\nInstruction:\nKVM: s390: rename PROT_NONE to PROT_TYPE_DUMMY\n\nReturn the diff that fixes it:\n",279 "reference": "@@ -319,7 +319,7 @@ enum prot_type {\n \tPROT_TYPE_DAT = 3,\n \tPROT_TYPE_IEP = 4,\n \t/* Dummy value for passing an initialized value when code != PGM_PROTECTION */\n-\tPROT_NONE,\n+\tPROT_TYPE_DUMMY,\n };\n \n static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva, u8 ar,\n@@ -335,7 +335,7 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,\n \tswitch (code) {\n \tcase PGM_PROTECTION:\n \t\tswitch (prot) {\n-\t\tcase PROT_NONE:\n+\t\tcase PROT_TYPE_DUMMY:\n \t\t\t/* We should never get here, acts like termination */\n \t\t\tWARN_ON_ONCE(1);\n \t\t\tbreak;\n@@ -805,7 +805,7 @@ static int guest_range_to_gpas(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,\n \t\t\tgpa = kvm_s390_real_to_abs(vcpu, ga);\n \t\t\tif (!kvm_is_gpa_in_memslot(vcpu->kvm, gpa)) {\n \t\t\t\trc = PGM_ADDRESSING;\n-\t\t\t\tprot = PROT_NONE;\n+\t\t\t\tprot = PROT_TYPE_DUMMY;\n \t\t\t}\n \t\t}\n \t\tif (rc)\n@@ -963,7 +963,7 @@ int access_guest_with_key(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,\n \t\tif (rc == PGM_PROTECTION)\n \t\t\tprot = PROT_TYPE_KEYC;\n \t\telse\n-\t\t\tprot = PROT_NONE;\n+\t\t\tprot = PROT_TYPE_DUMMY;\n \t\trc = trans_exc_ending(vcpu, rc, ga, ar, mode, prot, terminate);\n \t}\n out_unlock:",280 "prediction": "Given the following original C code:\nasce->val = aste.asce;\n\treturn 0;\n}\n\nenum prot_type {\n\tPROT_TYPE_LA = 0,\n\tPROT_TYPE_KEYC = 1,\n\tPROT_TYPE_ALC = 2,\n\tPROT_TYPE_DAT = 3,\n\tPROT_TYPE_IEP = 4,\n\t/* Dummy value for passing an initialized value when code != PGM_PROTECTION */\n\tPROT_NONE,\n};\n\nstatic int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva, u8 ar,\n\t\t\t enum gacc_mode mode, enum prot_type prot, bool terminate)\n{\n\tstruct kvm_s390_pgm_info *pgm = &vcpu->arch.pgm;\n\tunion teid *teid;\n\nInstruction:\nKVM: s390: rename PROT_NONE to PROT_TYPE_DUMMY\n\nReturn the diff that fixes it:\n @@ -109,7 +109,7 @@ enum prot_type {\n \tPROT_TYPE_DAT = 3,\n \tPROT_TYPE_IEP = 4,\n \t/* Dummy value for passing an initialized value when code != PGM_PROTECTION */\n-\tPROT_NONE,\n+\tPROT_TYPE_DUMMY,\n };\n \n static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva, u8 ar,\n@@ -117,7 +117,7 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,\n \t\t\t enum gacc_mode mode, enum prot_type prot, bool terminate)\n {\n \tstruct kvm_s390_pgm_info *pgm = &vcpu->arch.pgm;\n-\tunion teid *teid;\n+\tunion teid *teid = &pgm->teid;"281 },282 {283 "prompt": "Given the following original C code:\nconst char * const vmstat_text[] = {\n\t/* enum zone_stat_item counters */\n\t\"nr_free_pages\",\n\t\"nr_free_pages_blocks\",\n\t\"nr_zone_inactive_anon\",\n\t\"nr_zone_active_anon\",\n\t\"nr_zone_inactive_file\",\n\t\"nr_zone_active_file\",\n\t\"nr_zone_unevictable\",\n\t\"nr_zone_write_pending\",\n\t\"nr_mlock\",\n\t\"nr_bounce\",\n#if IS_ENABLED(CONFIG_ZSMALLOC)\n\t\"nr_zspages\",\n#endif\n\t\"nr_free_cma\",\n#ifdef CONFIG_UNACCEPTED_MEMORY\n\t\"nr_unaccepted\",\n#endif\n\nInstruction:\nmm: fix vmstat after removing NR_BOUNCE\n\nReturn the diff that fixes it:\n",284 "reference": "@@ -1201,7 +1201,6 @@ const char * const vmstat_text[] = {\n \t\"nr_zone_unevictable\",\n \t\"nr_zone_write_pending\",\n \t\"nr_mlock\",\n-\t\"nr_bounce\",\n #if IS_ENABLED(CONFIG_ZSMALLOC)\n \t\"nr_zspages\",\n #endif",285 "prediction": "Given the following original C code:\nconst char * const vmstat_text[] = {\n\t/* enum zone_stat_item counters */\n\t\"nr_free_pages\",\n\t\"nr_free_pages_blocks\",\n\t\"nr_zone_inactive_anon\",\n\t\"nr_zone_active_anon\",\n\t\"nr_zone_inactive_file\",\n\t\"nr_zone_active_file\",\n\t\"nr_zone_unevictable\",\n\t\"nr_zone_write_pending\",\n\t\"nr_mlock\",\n\t\"nr_bounce\",\n#if IS_ENABLED(CONFIG_ZSMALLOC)\n\t\"nr_zspages\",\n#endif\n\t\"nr_free_cma\",\n#ifdef CONFIG_UNACCEPTED_MEMORY\n\t\"nr_unaccepted\",\n#endif\n\nInstruction:\nmm: fix vmstat after removing NR_BOUNCE\n\nReturn the diff that fixes it:\n @@ -106,7 +106,6 @@ const char * const vmstat_text[] = {\n \t\"nr_zone_unevictable\",\n \t\"nr_zone_write_pending\",\n \t\"nr_mlock\",\n-\t\"nr_bounce\",\n #if IS_ENABLED(CONFIG_ZSMALLOC)\n \t\"nr_zspages\",\n #endif\n@@ -115,7 +114,6 @@ const char * const vmstat_text[] = {\n \t\"nr_unaccepted\",\n #endif\n \t\"nr_isolated_anon\",\n-\t\"nr_isolated_file\",\n \t\"workingset_refault\",\n \t\"workingset_activate\",\n \t\"workingset_nodereclaim\",\n@@ -125,7 +123,6 @@ const char * const vmstat_text[] = {\n \t\"workingset_pages_shared\",\n \t\"workingset_pages_sharable\",\n \t\"workingset"286 },287 {288 "prompt": "Given the following original C code:\n* try again. We check for fatal signals in case we need exit\n\t\t * early anyway.\n\t\t */\n\t\tif (ret == -ERESTARTNOINTR) {\n\t\t\tif (fatal_signal_pending(current)) {\n\t\t\t\tret = -EINTR;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* Drop and reacquire lock to unwind race. */\n\t\t\tmadvise_finish_tlb(&madv_behavior);\n\t\t\tmadvise_unlock(mm, behavior);\n\t\t\tmadvise_lock(mm, behavior);\n\t\t\tmadvise_init_tlb(&madv_behavior, mm);\n\t\t\tcontinue;\n\t\t}\n\t\tif (ret < 0)\n\t\t\tbreak;\n\t\tiov_iter_advance(iter, iter_iov_len(iter));\n\t}\n\nInstruction:\nmm/madvise: handle madvise_lock() failure during race unwinding\n\nReturn the diff that fixes it:\n",289 "reference": "@@ -1881,7 +1881,9 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,\n \t\t\t/* Drop and reacquire lock to unwind race. */\n \t\t\tmadvise_finish_tlb(&madv_behavior);\n \t\t\tmadvise_unlock(mm, behavior);\n-\t\t\tmadvise_lock(mm, behavior);\n+\t\t\tret = madvise_lock(mm, behavior);\n+\t\t\tif (ret)\n+\t\t\t\tgoto out;\n \t\t\tmadvise_init_tlb(&madv_behavior, mm);\n \t\t\tcontinue;\n \t\t}\n@@ -1892,6 +1894,7 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,\n \tmadvise_finish_tlb(&madv_behavior);\n \tmadvise_unlock(mm, behavior);\n \n+out:\n \tret = (total_len - iov_iter_count(iter)) ? : ret;\n \n \treturn ret;",290 "prediction": "Given the following original C code:\n* try again. We check for fatal signals in case we need exit\n\t\t * early anyway.\n\t\t */\n\t\tif (ret == -ERESTARTNOINTR) {\n\t\t\tif (fatal_signal_pending(current)) {\n\t\t\t\tret = -EINTR;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* Drop and reacquire lock to unwind race. */\n\t\t\tmadvise_finish_tlb(&madv_behavior);\n\t\t\tmadvise_unlock(mm, behavior);\n\t\t\tmadvise_lock(mm, behavior);\n\t\t\tmadvise_init_tlb(&madv_behavior, mm);\n\t\t\tcontinue;\n\t\t}\n\t\tif (ret < 0)\n\t\t\tbreak;\n\t\tiov_iter_advance(iter, iter_iov_len(iter));\n\t}\n\nInstruction:\nmm/madvise: handle madvise_lock() failure during race unwinding\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ int madvise(struct vm_area_struct *vma, unsigned long addr,\n \t\t\t/* Drop and reacquire lock to unwind race. */\n \t\t\tmadvise_finish_tlb(&madv_behavior);\n \t\t\tmadvise_unlock(mm, behavior);\n-\t\t\tmadvise_lock(mm, behavior);\n+\t\t\tret = madvise_lock(mm, behavior);\n \t\t\tmadvise_init_tlb(&madv_behavior, mm);\n \t\t\tcontinue;\n \t\t}\n@@ -116,7 +116,7 @@ int madvise(struct vm_area_struct *vma, unsigned long addr,\n \t\tiov_iter_advance(iter, iter_iov_len(iter));\n \t}\n \n-\tmadvise_finish_tlb(&madv_behavior);\n+\tmadvise_finish_tlb(&madv_"291 },292 {293 "prompt": "Given the following original C code:\nconst char *modname;\n\tconst char *function;\n\tconst char *filename;\n} __aligned(8);\n\nunion codetag_ref {\n\tstruct codetag *ct;\n};\n\nstruct codetag_type_desc {\n\tconst char *section;\n\tsize_t tag_size;\n\tvoid (*module_load)(struct module *mod,\n\t\t\t struct codetag *start, struct codetag *end);\n\tvoid (*module_unload)(struct module *mod,\n\t\t\t struct codetag *start, struct codetag *end);\n#ifdef CONFIG_MODULES\n\tvoid (*module_replaced)(struct module *mod, struct module *new_mod);\n\tbool (*needs_section_mem)(struct module *mod, unsigned long size);\n\tvoid *(*alloc_section_mem)(struct module *mod, unsigned long size,\n\nInstruction:\nalloc_tag: handle module codetag load errors as module load failures\n\nReturn the diff that fixes it:\n",294 "reference": "@@ -36,8 +36,8 @@ union codetag_ref {\n struct codetag_type_desc {\n \tconst char *section;\n \tsize_t tag_size;\n-\tvoid (*module_load)(struct module *mod,\n-\t\t\t struct codetag *start, struct codetag *end);\n+\tint (*module_load)(struct module *mod,\n+\t\t\t struct codetag *start, struct codetag *end);\n \tvoid (*module_unload)(struct module *mod,\n \t\t\t struct codetag *start, struct codetag *end);\n #ifdef CONFIG_MODULES\n@@ -89,7 +89,7 @@ void *codetag_alloc_module_section(struct module *mod, const char *name,\n \t\t\t\t unsigned long align);\n void codetag_free_module_sections(struct module *mod);\n void codetag_module_replaced(struct module *mod, struct module *new_mod);\n-void codetag_load_module(struct module *mod);\n+int codetag_load_module(struct module *mod);\n void codetag_unload_module(struct module *mod);\n \n #else /* defined(CONFIG_CODE_TAGGING) && defined(CONFIG_MODULES) */\n@@ -103,7 +103,7 @@ codetag_alloc_module_section(struct module *mod, const char *name,\n \t\t\t unsigned long align) { return NULL; }\n static inline void codetag_free_module_sections(struct module *mod) {}\n static inline void codetag_module_replaced(struct module *mod, struct module *new_mod) {}\n-static inline void codetag_load_module(struct module *mod) {}\n+static inline int codetag_load_module(struct module *mod) { return 0; }\n static inline void codetag_unload_module(struct module *mod) {}\n \n #endif /* defined(CONFIG_CODE_TAGGING) && defined(CONFIG_MODULES) */",295 "prediction": "Given the following original C code:\nconst char *modname;\n\tconst char *function;\n\tconst char *filename;\n} __aligned(8);\n\nunion codetag_ref {\n\tstruct codetag *ct;\n};\n\nstruct codetag_type_desc {\n\tconst char *section;\n\tsize_t tag_size;\n\tvoid (*module_load)(struct module *mod,\n\t\t\t struct codetag *start, struct codetag *end);\n\tvoid (*module_unload)(struct module *mod,\n\t\t\t struct codetag *start, struct codetag *end);\n#ifdef CONFIG_MODULES\n\tvoid (*module_replaced)(struct module *mod, struct module *new_mod);\n\tbool (*needs_section_mem)(struct module *mod, unsigned long size);\n\tvoid *(*alloc_section_mem)(struct module *mod, unsigned long size,\n\nInstruction:\nalloc_tag: handle module codetag load errors as module load failures\n\nReturn the diff that fixes it:\n @@ -13,7 +13,7 @@ union codetag_ref {\n struct codetag_type_desc {\n \tconst char *section;\n \tsize_t tag_size;\n-\tvoid (*module_load)(struct module *mod,\n-\t\t\t struct codetag *start, struct codetag *end);\n+\tint (*module_load)(struct module *mod,\n+\t\t\t struct codetag *start, struct codetag *end);\n \tvoid (*module_unload)(struct module *mod,\n \t\t\t struct codetag *start, struct codetag *end);\n #ifdef CONFIG_MODULES\n \tvoid (*module_replaced)(struct module *mod, struct module *new_mod);\n@@ -21,7 +21,7 @@ struct codetag_type_desc {\n \tbool (*needs_section_mem)(struct module *mod, unsigned long size);\n \tvoid *(*alloc_section_mem)(struct module *mod, unsigned long size,"296 },297 {298 "prompt": "Given the following original C code:\n/* Link in to sysfs. */\n\terr = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp);\n\tif (err < 0)\n\t\tgoto coming_cleanup;\n\n\tif (is_livepatch_module(mod)) {\n\t\terr = copy_module_elf(mod, info);\n\t\tif (err < 0)\n\t\t\tgoto sysfs_cleanup;\n\t}\n\n\t/* Get rid of temporary copy. */\n\tfree_copy(info, flags);\n\n\tcodetag_load_module(mod);\n\n\t/* Done! */\n\ttrace_module_load(mod);\n\nInstruction:\nalloc_tag: handle module codetag load errors as module load failures\n\nReturn the diff that fixes it:\n",299 "reference": "@@ -3386,11 +3386,12 @@ static int load_module(struct load_info *info, const char __user *uargs,\n \t\t\tgoto sysfs_cleanup;\n \t}\n \n+\tif (codetag_load_module(mod))\n+\t\tgoto sysfs_cleanup;\n+\n \t/* Get rid of temporary copy. */\n \tfree_copy(info, flags);\n \n-\tcodetag_load_module(mod);\n-\n \t/* Done! */\n \ttrace_module_load(mod);",300 "prediction": "Given the following original C code:\n/* Link in to sysfs. */\n\terr = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp);\n\tif (err < 0)\n\t\tgoto coming_cleanup;\n\n\tif (is_livepatch_module(mod)) {\n\t\terr = copy_module_elf(mod, info);\n\t\tif (err < 0)\n\t\t\tgoto sysfs_cleanup;\n\t}\n\n\t/* Get rid of temporary copy. */\n\tfree_copy(info, flags);\n\n\tcodetag_load_module(mod);\n\n\t/* Done! */\n\ttrace_module_load(mod);\n\nInstruction:\nalloc_tag: handle module codetag load errors as module load failures\n\nReturn the diff that fixes it:\n @@ -1008,6 +1008,10 @@ static int load_module(struct module *mod, struct load_info *info,\n \t\t\tgoto sysfs_cleanup;\n \t}\n \n+\terr = alloc_tag(mod);\n+\tif (err < 0)\n+\t\tgoto sysfs_cleanup;\n+\n \t/* Get rid of temporary copy. */\n \tfree_copy(info, flags);\n \n@@ -1016,6 +1020,7 @@ static int load_module(struct module *mod, struct load_info *info,\n \tcodetag_load_module(mod);\n \n \t/* Done! */\n+\tmod->state = MODULE_STATE_LIVE;\n \ttrace_module_load(mod);\n \tmodule_notify(mod, THIS_MODULE, MODULE_STATE_COMING);\n \tmodule_notify(mod, NULL, MODULE_STATE_LIVE);\n@@ -1024,6"301 },302 {303 "prompt": "Given the following original C code:\n} else {\n\t\tused = false;\n\t}\nrelease_area:\n\tmas_store(&mas, used ? &unloaded_mod : NULL);\n\tval = mas_prev_range(&mas, 0);\n\tif (val == &prepend_mod)\n\t\tmas_store(&mas, NULL);\nout:\n\tmas_unlock(&mas);\n}\n\nstatic void load_module(struct module *mod, struct codetag *start, struct codetag *stop)\n{\n\t/* Allocate module alloc_tag percpu counters */\n\tstruct alloc_tag *start_tag;\n\tstruct alloc_tag *stop_tag;\n\tstruct alloc_tag *tag;\n\n\tif (!mod)\n\nInstruction:\nalloc_tag: handle module codetag load errors as module load failures\n\nReturn the diff that fixes it:\n",304 "reference": "@@ -607,15 +607,16 @@ static void release_module_tags(struct module *mod, bool used)\n \tmas_unlock(&mas);\n }\n \n-static void load_module(struct module *mod, struct codetag *start, struct codetag *stop)\n+static int load_module(struct module *mod, struct codetag *start, struct codetag *stop)\n {\n \t/* Allocate module alloc_tag percpu counters */\n \tstruct alloc_tag *start_tag;\n \tstruct alloc_tag *stop_tag;\n \tstruct alloc_tag *tag;\n \n+\t/* percpu counters for core allocations are already statically allocated */\n \tif (!mod)\n-\t\treturn;\n+\t\treturn 0;\n \n \tstart_tag = ct_to_alloc_tag(start);\n \tstop_tag = ct_to_alloc_tag(stop);\n@@ -627,12 +628,13 @@ static void load_module(struct module *mod, struct codetag *start, struct codeta\n \t\t\t\tfree_percpu(tag->counters);\n \t\t\t\ttag->counters = NULL;\n \t\t\t}\n-\t\t\tshutdown_mem_profiling(true);\n-\t\t\tpr_err(\"Failed to allocate memory for allocation tag percpu counters in the module %s. Memory allocation profiling is disabled!\\n\",\n+\t\t\tpr_err(\"Failed to allocate memory for allocation tag percpu counters in the module %s\\n\",\n \t\t\t mod->name);\n-\t\t\tbreak;\n+\t\t\treturn -ENOMEM;\n \t\t}\n \t}\n+\n+\treturn 0;\n }\n \n static void replace_module(struct module *mod, struct module *new_mod)",305 "prediction": "Given the following original C code:\n} else {\n\t\tused = false;\n\t}\nrelease_area:\n\tmas_store(&mas, used ? &unloaded_mod : NULL);\n\tval = mas_prev_range(&mas, 0);\n\tif (val == &prepend_mod)\n\t\tmas_store(&mas, NULL);\nout:\n\tmas_unlock(&mas);\n}\n\nstatic void load_module(struct module *mod, struct codetag *start, struct codetag *stop)\n{\n\t/* Allocate module alloc_tag percpu counters */\n\tstruct alloc_tag *start_tag;\n\tstruct alloc_tag *stop_tag;\n\tstruct alloc_tag *tag;\n\n\tif (!mod)\n\nInstruction:\nalloc_tag: handle module codetag load errors as module load failures\n\nReturn the diff that fixes it:\n @@ -110,6 +110,10 @@ static void unload_module(struct module *mod)\n \tmas_unlock(&mas);\n }\n \n+static int load_module_alloc_tags(struct module *mod, struct codetag *start, struct codetag *stop)\n+{\n+\treturn 0;\n+}\n+\n static void load_module(struct module *mod, struct codetag *start, struct codetag *stop)\n {\n \t/* Allocate module alloc_tag percpu counters */\n@@ -118,6 +122,7 @@ static void load_module(struct module *mod, struct codetag *start, struct codetag *\n \tif (!mod)\n \t\treturn;\n \n+\tif (load_module_alloc_tags(mod, start, stop))\n+\t\treturn;\n \tif (load_module_segments(mod, start, stop))\n \t\treturn;\n \tif (load_module_symbols(mod, start, stop))"306 },307 {308 "prompt": "Given the following original C code:\n{\n#ifdef CONFIG_MODULES\n\tif (mod)\n\t\treturn mod->name;\n#endif\n\treturn \"(built-in)\";\n}\n\nstatic int codetag_module_init(struct codetag_type *cttype, struct module *mod)\n{\n\tstruct codetag_range range;\n\tstruct codetag_module *cmod;\n\tint err;\n\n\trange = get_section_range(mod, cttype->desc.section);\n\tif (!range.start || !range.stop) {\n\t\tpr_warn(\"Failed to load code tags of type %s from the module %s\\n\",\n\t\t\tcttype->desc.section, get_mod_name(mod));\n\t\treturn -EINVAL;\n\t}\n\nInstruction:\nalloc_tag: handle module codetag load errors as module load failures\n\nReturn the diff that fixes it:\n",309 "reference": "@@ -167,6 +167,7 @@ static int codetag_module_init(struct codetag_type *cttype, struct module *mod)\n {\n \tstruct codetag_range range;\n \tstruct codetag_module *cmod;\n+\tint mod_id;\n \tint err;\n \n \trange = get_section_range(mod, cttype->desc.section);\n@@ -190,11 +191,20 @@ static int codetag_module_init(struct codetag_type *cttype, struct module *mod)\n \tcmod->range = range;\n \n \tdown_write(&cttype->mod_lock);\n-\terr = idr_alloc(&cttype->mod_idr, cmod, 0, 0, GFP_KERNEL);\n-\tif (err >= 0) {\n-\t\tcttype->count += range_size(cttype, &range);\n-\t\tif (cttype->desc.module_load)\n-\t\t\tcttype->desc.module_load(mod, range.start, range.stop);\n+\tmod_id = idr_alloc(&cttype->mod_idr, cmod, 0, 0, GFP_KERNEL);\n+\tif (mod_id >= 0) {\n+\t\tif (cttype->desc.module_load) {\n+\t\t\terr = cttype->desc.module_load(mod, range.start, range.stop);\n+\t\t\tif (!err)\n+\t\t\t\tcttype->count += range_size(cttype, &range);\n+\t\t\telse\n+\t\t\t\tidr_remove(&cttype->mod_idr, mod_id);\n+\t\t} else {\n+\t\t\tcttype->count += range_size(cttype, &range);\n+\t\t\terr = 0;\n+\t\t}\n+\t} else {\n+\t\terr = mod_id;\n \t}\n \tup_write(&cttype->mod_lock);\n \n@@ -295,17 +305,23 @@ void codetag_module_replaced(struct module *mod, struct module *new_mod)\n \tmutex_unlock(&codetag_lock);\n }\n \n-void codetag_load_module(struct module *mod)\n+int codetag_load_module(struct module *mod)\n {\n \tstruct codetag_type *cttype;\n+\tint ret = 0;\n \n \tif (!mod)\n-\t\treturn;\n+\t\treturn 0;\n \n \tmutex_lock(&codetag_lock);\n-\tlist_for_each_entry(cttype, &codetag_types, link)\n-\t\tcodetag_module_init(cttype, mod);\n+\tlist_for_each_entry(cttype, &codetag_types, link) {\n+\t\tret = codetag_module_init(cttype, mod);\n+\t\tif (ret)\n+\t\t\tbreak;\n+\t}\n \tmutex_unlock(&codetag_lock);\n+\n+\treturn ret;\n }\n \n void codetag_unload_module(struct module *mod)",310 "prediction": "Given the following original C code:\n{\n#ifdef CONFIG_MODULES\n\tif (mod)\n\t\treturn mod->name;\n#endif\n\treturn \"(built-in)\";\n}\n\nstatic int codetag_module_init(struct codetag_type *cttype, struct module *mod)\n{\n\tstruct codetag_range range;\n\tstruct codetag_module *cmod;\n\tint err;\n\n\trange = get_section_range(mod, cttype->desc.section);\n\tif (!range.start || !range.stop) {\n\t\tpr_warn(\"Failed to load code tags of type %s from the module %s\\n\",\n\t\t\tcttype->desc.section, get_mod_name(mod));\n\t\treturn -EINVAL;\n\t}\n\nInstruction:\nalloc_tag: handle module codetag load errors as module load failures\n\nReturn the diff that fixes it:\n @@ -108,14 +108,14 @@ static int codetag_module_init(struct codetag_type *cttype, struct module *mod)\n {\n \tstruct codetag_range range;\n \tstruct codetag_module *cmod;\n-\tint err;\n+\tint err = 0;\n \n \trange = get_section_range(mod, cttype->desc.section);\n \tif (!range.start || !range.stop) {\n \t\tpr_warn(\"Failed to load code tags of type %s from the module %s\\n\",\n \t\t\tcttype->desc.section, get_mod_name(mod));\n-\t\treturn -EINVAL;\n+\t\terr = -EINVAL;\n \t}\n \n \tcmod = kzalloc(sizeof(*cmod), GFP_KERNEL);\n \tif (!cmod) {\n-\t\treturn -ENOMEM;\n+\t\terr = -ENOMEM;\n \t}"311 },312 {313 "prompt": "Given the following original C code:\n}\n\nstatic void wi_state_free(void)\n{\n\tstruct weighted_interleave_state *old_wi_state;\n\n\tmutex_lock(&wi_state_lock);\n\n\told_wi_state = rcu_dereference_protected(wi_state,\n\t\t\tlockdep_is_held(&wi_state_lock));\n\tif (!old_wi_state) {\n\t\tmutex_unlock(&wi_state_lock);\n\t\tgoto out;\n\t}\n\n\trcu_assign_pointer(wi_state, NULL);\n\tmutex_unlock(&wi_state_lock);\n\tsynchronize_rcu();\n\tkfree(old_wi_state);\nout:\n\nInstruction:\nmm/mempolicy: fix incorrect freeing of wi_kobj\n\nReturn the diff that fixes it:\n",314 "reference": "@@ -3708,15 +3708,13 @@ static void wi_state_free(void)\n \t\t\tlockdep_is_held(&wi_state_lock));\n \tif (!old_wi_state) {\n \t\tmutex_unlock(&wi_state_lock);\n-\t\tgoto out;\n+\t\treturn;\n \t}\n \n \trcu_assign_pointer(wi_state, NULL);\n \tmutex_unlock(&wi_state_lock);\n \tsynchronize_rcu();\n \tkfree(old_wi_state);\n-out:\n-\tkfree(&wi_group->wi_kobj);\n }\n \n static struct kobj_attribute wi_auto_attr =",315 "prediction": "Given the following original C code:\n}\n\nstatic void wi_state_free(void)\n{\n\tstruct weighted_interleave_state *old_wi_state;\n\n\tmutex_lock(&wi_state_lock);\n\n\told_wi_state = rcu_dereference_protected(wi_state,\n\t\t\tlockdep_is_held(&wi_state_lock));\n\tif (!old_wi_state) {\n\t\tmutex_unlock(&wi_state_lock);\n\t\tgoto out;\n\t}\n\n\trcu_assign_pointer(wi_state, NULL);\n\tmutex_unlock(&wi_state_lock);\n\tsynchronize_rcu();\n\tkfree(old_wi_state);\nout:\n\nInstruction:\nmm/mempolicy: fix incorrect freeing of wi_kobj\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static void wi_state_free(void)\n \t\t\tlockdep_is_held(&wi_state_lock));\n \tif (!old_wi_state) {\n \t\tmutex_unlock(&wi_state_lock);\n-\t\tgoto out;\n+\t\tgoto out_free;\n \t}\n \n \trcu_assign_pointer(wi_state, NULL);\n@@ -116,7 +116,7 @@ static void wi_state_free(void)\n \tmutex_unlock(&wi_state_lock);\n \tsynchronize_rcu();\n \tkfree(old_wi_state);\n-out:\n+out_free:\n \treturn;\n }\n \n@@ -124,7 +124,7 @@ static void wi_state_free(void)\n static void wi_kobj_release(struct kobject *kobj)\n {\n \tstruct weighted_interleave_state *"316 },317 {318 "prompt": "Given the following original C code:\nreturn true;\n}\n\nstatic bool iov_iter_aligned_bvec(const struct iov_iter *i, unsigned addr_mask,\n\t\t\t\t unsigned len_mask)\n{\n\tconst struct bio_vec *bvec = i->bvec;\n\tunsigned skip = i->iov_offset;\n\tsize_t size = i->count;\n\n\tdo {\n\t\tsize_t len = bvec->bv_len;\n\n\t\tif (len > size)\n\t\t\tlen = size;\n\t\tif (len & len_mask)\n\t\t\treturn false;\n\t\tif ((unsigned long)(bvec->bv_offset + skip) & addr_mask)\n\t\t\treturn false;\n\nInstruction:\niov_iter: use iov_offset for length calculation in iov_iter_aligned_bvec\n\nReturn the diff that fixes it:\n",319 "reference": "@@ -817,7 +817,7 @@ static bool iov_iter_aligned_bvec(const struct iov_iter *i, unsigned addr_mask,\n \tsize_t size = i->count;\n \n \tdo {\n-\t\tsize_t len = bvec->bv_len;\n+\t\tsize_t len = bvec->bv_len - skip;\n \n \t\tif (len > size)\n \t\t\tlen = size;",320 "prediction": "Given the following original C code:\nreturn true;\n}\n\nstatic bool iov_iter_aligned_bvec(const struct iov_iter *i, unsigned addr_mask,\n\t\t\t\t unsigned len_mask)\n{\n\tconst struct bio_vec *bvec = i->bvec;\n\tunsigned skip = i->iov_offset;\n\tsize_t size = i->count;\n\n\tdo {\n\t\tsize_t len = bvec->bv_len;\n\n\t\tif (len > size)\n\t\t\tlen = size;\n\t\tif (len & len_mask)\n\t\t\treturn false;\n\t\tif ((unsigned long)(bvec->bv_offset + skip) & addr_mask)\n\t\t\treturn false;\n\nInstruction:\niov_iter: use iov_offset for length calculation in iov_iter_aligned_bvec\n\nReturn the diff that fixes it:\n @@ -109,7 +109,7 @@ static bool iov_iter_aligned_bvec(const struct iov_iter *i, unsigned addr_mask,\n \n \tdo {\n \t\tsize_t len = bvec->bv_len;\n-\n+\t\tlen -= i->iov_offset;\n \t\tif (len > size)\n \t\t\tlen = size;\n \t\tif (len & len_mask)\n@@ -117,7 +117,7 @@ static bool iov_iter_aligned_bvec(const struct iov_iter *i, unsigned addr_mask,\n \t\tif ((unsigned long)(bvec->bv_offset + skip) & addr_mask)\n \t\t\treturn false;\n \n-\t\tsize -= len;\n+\t\tsize -= len - i->iov_offset;\n \t\tskip = 0;\n \t\tbvec++;\n \t} while (size);\n@@ -125,7 +125,7 @@ static bool iov"321 },322 {323 "prompt": "Given the following original C code:\nvoid hugetlb_vma_lock_write(struct vm_area_struct *vma);\nvoid hugetlb_vma_unlock_write(struct vm_area_struct *vma);\nint hugetlb_vma_trylock_write(struct vm_area_struct *vma);\nvoid hugetlb_vma_assert_locked(struct vm_area_struct *vma);\nvoid hugetlb_vma_lock_release(struct kref *kref);\nlong hugetlb_change_protection(struct vm_area_struct *vma,\n\t\tunsigned long address, unsigned long end, pgprot_t newprot,\n\t\tunsigned long cp_flags);\nbool is_hugetlb_entry_migration(pte_t pte);\nbool is_hugetlb_entry_hwpoisoned(pte_t pte);\nvoid hugetlb_unshare_all_pmds(struct vm_area_struct *vma);\nvoid fixup_hugetlb_reservations(struct vm_area_struct *vma);\n\n#else /* !CONFIG_HUGETLB_PAGE */\n\nstatic inline void hugetlb_dup_vma_private(struct vm_area_struct *vma)\n{\n}\n\nstatic inline void clear_vma_resv_huge_pages(struct vm_area_struct *vma)\n\nInstruction:\nmm/hugetlb: unshare page tables during VMA split, not before\n\nReturn the diff that fixes it:\n",324 "reference": "@@ -279,6 +279,7 @@ bool is_hugetlb_entry_migration(pte_t pte);\n bool is_hugetlb_entry_hwpoisoned(pte_t pte);\n void hugetlb_unshare_all_pmds(struct vm_area_struct *vma);\n void fixup_hugetlb_reservations(struct vm_area_struct *vma);\n+void hugetlb_split(struct vm_area_struct *vma, unsigned long addr);\n \n #else /* !CONFIG_HUGETLB_PAGE */\n \n@@ -476,6 +477,8 @@ static inline void fixup_hugetlb_reservations(struct vm_area_struct *vma)\n {\n }\n \n+static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr) {}\n+\n #endif /* !CONFIG_HUGETLB_PAGE */\n \n #ifndef pgd_write",325 "prediction": "Given the following original C code:\nvoid hugetlb_vma_lock_write(struct vm_area_struct *vma);\nvoid hugetlb_vma_unlock_write(struct vm_area_struct *vma);\nint hugetlb_vma_trylock_write(struct vm_area_struct *vma);\nvoid hugetlb_vma_assert_locked(struct vm_area_struct *vma);\nvoid hugetlb_vma_lock_release(struct kref *kref);\nlong hugetlb_change_protection(struct vm_area_struct *vma,\n\t\tunsigned long address, unsigned long end, pgprot_t newprot,\n\t\tunsigned long cp_flags);\nbool is_hugetlb_entry_migration(pte_t pte);\nbool is_hugetlb_entry_hwpoisoned(pte_t pte);\nvoid hugetlb_unshare_all_pmds(struct vm_area_struct *vma);\nvoid fixup_hugetlb_reservations(struct vm_area_struct *vma);\n\n#else /* !CONFIG_HUGETLB_PAGE */\n\nstatic inline void hugetlb_dup_vma_private(struct vm_area_struct *vma)\n{\n}\n\nstatic inline void clear_vma_resv_huge_pages(struct vm_area_struct *vma)\n\nInstruction:\nmm/hugetlb: unshare page tables during VMA split, not before\n\nReturn the diff that fixes it:\n @@ -106,7 +106,6 @@ bool is_hugetlb_entry_migration(pte_t pte);\n bool is_hugetlb_entry_hwpoisoned(pte_t pte);\n void hugetlb_unshare_all_pmds(struct vm_area_struct *vma);\n void fixup_hugetlb_reservations(struct vm_area_struct *vma);\n-\n-#else /* !CONFIG_HUGETLB_PAGE */\n-\n static inline void hugetlb_dup_vma_private(struct vm_area_struct *vma)\n {\n }\n@@ -115,7 +114,6 @@ static inline void clear_vma_resv_huge_pages(struct vm_area_struct *vma)\n static inline void hugetlb_unshare_all_pmds(struct vm_area_struct *vma)\n {\n }\n-\n static inline void fixup_hugetlb_reservations(struct vm_area_struct *vma)\n {"326 },327 {328 "prompt": "Given the following original C code:\n* Serializes faults on the same logical page. This is used to\n * prevent spurious OOMs when the hugepage pool is fully utilized.\n */\nstatic int num_fault_mutexes __ro_after_init;\nstruct mutex *hugetlb_fault_mutex_table __ro_after_init;\n\n/* Forward declaration */\nstatic int hugetlb_acct_memory(struct hstate *h, long delta);\nstatic void hugetlb_vma_lock_free(struct vm_area_struct *vma);\nstatic void hugetlb_vma_lock_alloc(struct vm_area_struct *vma);\nstatic void __hugetlb_vma_unlock_write_free(struct vm_area_struct *vma);\nstatic void hugetlb_unshare_pmds(struct vm_area_struct *vma,\n\t\tunsigned long start, unsigned long end);\nstatic struct resv_map *vma_resv_map(struct vm_area_struct *vma);\n\nstatic void hugetlb_free_folio(struct folio *folio)\n{\n\tif (folio_test_hugetlb_cma(folio)) {\n\t\thugetlb_cma_free_folio(folio);\n\t\treturn;\n\nInstruction:\nmm/hugetlb: unshare page tables during VMA split, not before\n\nReturn the diff that fixes it:\n",329 "reference": "@@ -121,7 +121,7 @@ static void hugetlb_vma_lock_free(struct vm_area_struct *vma);\n static void hugetlb_vma_lock_alloc(struct vm_area_struct *vma);\n static void __hugetlb_vma_unlock_write_free(struct vm_area_struct *vma);\n static void hugetlb_unshare_pmds(struct vm_area_struct *vma,\n-\t\tunsigned long start, unsigned long end);\n+\t\tunsigned long start, unsigned long end, bool take_locks);\n static struct resv_map *vma_resv_map(struct vm_area_struct *vma);\n \n static void hugetlb_free_folio(struct folio *folio)\n@@ -5426,26 +5426,40 @@ static int hugetlb_vm_op_split(struct vm_area_struct *vma, unsigned long addr)\n {\n \tif (addr & ~(huge_page_mask(hstate_vma(vma))))\n \t\treturn -EINVAL;\n+\treturn 0;\n+}\n \n+void hugetlb_split(struct vm_area_struct *vma, unsigned long addr)\n+{\n \t/*\n \t * PMD sharing is only possible for PUD_SIZE-aligned address ranges\n \t * in HugeTLB VMAs. If we will lose PUD_SIZE alignment due to this\n \t * split, unshare PMDs in the PUD_SIZE interval surrounding addr now.\n+\t * This function is called in the middle of a VMA split operation, with\n+\t * MM, VMA and rmap all write-locked to prevent concurrent page table\n+\t * walks (except hardware and gup_fast()).\n \t */\n+\tvma_assert_write_locked(vma);\n+\ti_mmap_assert_write_locked(vma->vm_file->f_mapping);\n+\n \tif (addr & ~PUD_MASK) {\n-\t\t/*\n-\t\t * hugetlb_vm_op_split is called right before we attempt to\n-\t\t * split the VMA. We will need to unshare PMDs in the old and\n-\t\t * new VMAs, so let's unshare before we split.\n-\t\t */\n \t\tunsigned long floor = addr & PUD_MASK;\n \t\tunsigned long ceil = floor + PUD_SIZE;\n \n-\t\tif (floor >= vma->vm_start && ceil <= vma->vm_end)\n-\t\t\thugetlb_unshare_pmds(vma, floor, ceil);\n+\t\tif (floor >= vma->vm_start && ceil <= vma->vm_end) {\n+\t\t\t/*\n+\t\t\t * Locking:\n+\t\t\t * Use take_locks=false here.\n+\t\t\t * The file rmap lock is already held.\n+\t\t\t * The hugetlb VMA lock can't be taken when we already\n+\t\t\t * hold the file rmap lock, and we don't need it because\n+\t\t\t * its purpose is to synchronize against concurrent page\n+\t\t\t * table walks, which are not possible thanks to the\n+\t\t\t * locks held by our caller.\n+\t\t\t */\n+\t\t\thugetlb_unshare_pmds(vma, floor, ceil, /* take_locks = */ false);\n+\t\t}\n \t}\n-\n-\treturn 0;\n }\n \n static unsigned long hugetlb_vm_op_pagesize(struct vm_area_struct *vma)\n@@ -7885,9 +7899,16 @@ void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int re\n \tspin_unlock_irq(&hugetlb_lock);\n }\n \n+/*\n+ * If @take_locks is false, the caller must ensure that no concurrent page table\n+ * access can happen (except for gup_fast() and hardware page walks).\n+ * If @take_locks is true, we take the hugetlb VMA lock (to lock out things like\n+ * concurrent page fault handling) and the file rmap lock.\n+ */\n static void hugetlb_unshare_pmds(struct vm_area_struct *vma,\n \t\t\t\t unsigned long start,\n-\t\t\t\t unsigned long end)\n+\t\t\t\t unsigned long end,\n+\t\t\t\t bool take_locks)\n {\n \tstruct hstate *h = hstate_vma(vma);\n \tunsigned long sz = huge_page_size(h);\n@@ -7911,8 +7932,12 @@ static void hugetlb_unshare_pmds(struct vm_area_struct *vma,\n \tmmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, mm,\n \t\t\t\tstart, end);\n \tmmu_notifier_invalidate_range_start(&range);\n-\thugetlb_vma_lock_write(vma);\n-\ti_mmap_lock_write(vma->vm_file->f_mapping);\n+\tif (take_locks) {\n+\t\thugetlb_vma_lock_write(vma);\n+\t\ti_mmap_lock_write(vma->vm_file->f_mapping);\n+\t} else {\n+\t\ti_mmap_assert_write_locked(vma->vm_file->f_mapping);\n+\t}\n \tfor (address = start; address < end; address += PUD_SIZE) {\n \t\tptep = hugetlb_walk(vma, address, sz);\n \t\tif (!ptep)\n@@ -7922,8 +7947,10 @@ static void hugetlb_unshare_pmds(struct vm_area_struct *vma,\n \t\tspin_unlock(ptl);\n \t}\n \tflush_hugetlb_tlb_range(vma, start, end);\n-\ti_mmap_unlock_write(vma->vm_file->f_mapping);\n-\thugetlb_vma_unlock_write(vma);\n+\tif (take_locks) {\n+\t\ti_mmap_unlock_write(vma->vm_file->f_mapping);\n+\t\thugetlb_vma_unlock_write(vma);\n+\t}\n \t/*\n \t * No need to call mmu_notifier_arch_invalidate_secondary_tlbs(), see\n \t * Documentation/mm/mmu_notifier.rst.\n@@ -7938,7 +7965,8 @@ static void hugetlb_unshare_pmds(struct vm_area_struct *vma,\n void hugetlb_unshare_all_pmds(struct vm_area_struct *vma)\n {\n \thugetlb_unshare_pmds(vma, ALIGN(vma->vm_start, PUD_SIZE),\n-\t\t\tALIGN_DOWN(vma->vm_end, PUD_SIZE));\n+\t\t\tALIGN_DOWN(vma->vm_end, PUD_SIZE),\n+\t\t\t/* take_locks = */ true);\n }\n \n /*",330 "prediction": "Given the following original C code:\n* Serializes faults on the same logical page. This is used to\n * prevent spurious OOMs when the hugepage pool is fully utilized.\n */\nstatic int num_fault_mutexes __ro_after_init;\nstruct mutex *hugetlb_fault_mutex_table __ro_after_init;\n\n/* Forward declaration */\nstatic int hugetlb_acct_memory(struct hstate *h, long delta);\nstatic void hugetlb_vma_lock_free(struct vm_area_struct *vma);\nstatic void hugetlb_vma_lock_alloc(struct vm_area_struct *vma);\nstatic void __hugetlb_vma_unlock_write_free(struct vm_area_struct *vma);\nstatic void hugetlb_unshare_pmds(struct vm_area_struct *vma,\n\t\tunsigned long start, unsigned long end);\nstatic struct resv_map *vma_resv_map(struct vm_area_struct *vma);\n\nstatic void hugetlb_free_folio(struct folio *folio)\n{\n\tif (folio_test_hugetlb_cma(folio)) {\n\t\thugetlb_cma_free_folio(folio);\n\t\treturn;\n\nInstruction:\nmm/hugetlb: unshare page tables during VMA split, not before\n\nReturn the diff that fixes it:\n @@ -106,6 +106,7 @@ static void hugetlb_vma_lock_free(struct vm_area_struct *vma);\n static void hugetlb_vma_lock_alloc(struct vm_area_struct *vma);\n static void __hugetlb_vma_unlock_write_free(struct vm_area_struct *vma);\n static void hugetlb_unshare_pmds(struct vm_area_struct *vma,\n+\t\tunsigned long start, unsigned long end);\n static struct resv_map *vma_resv_map(struct vm_area_struct *vma);\n \n static void hugetlb_free_folio(struct folio *folio)\n@@ -114,6 +115,7 @@ static void hugetlb_free_folio(struct folio *folio)\n \t\thugetlb_cma_free_folio(folio);\n \t\treturn;\n \t}\n+\thugetlb_unshare_pmds(folio->vma, folio_address(folio),"331 },332 {333 "prompt": "Given the following original C code:\nif (new->vm_file)\n\t\tget_file(new->vm_file);\n\n\tif (new->vm_ops && new->vm_ops->open)\n\t\tnew->vm_ops->open(new);\n\n\tvma_start_write(vma);\n\tvma_start_write(new);\n\n\tinit_vma_prep(&vp, vma);\n\tvp.insert = new;\n\tvma_prepare(&vp);\n\tvma_adjust_trans_huge(vma, vma->vm_start, addr, NULL);\n\n\tif (new_below) {\n\t\tvma->vm_start = addr;\n\t\tvma->vm_pgoff += (addr - new->vm_start) >> PAGE_SHIFT;\n\t} else {\n\t\tvma->vm_end = addr;\n\t}\n\nInstruction:\nmm/hugetlb: unshare page tables during VMA split, not before\n\nReturn the diff that fixes it:\n",334 "reference": "@@ -539,7 +539,14 @@ __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma,\n \tinit_vma_prep(&vp, vma);\n \tvp.insert = new;\n \tvma_prepare(&vp);\n+\n+\t/*\n+\t * Get rid of huge pages and shared page tables straddling the split\n+\t * boundary.\n+\t */\n \tvma_adjust_trans_huge(vma, vma->vm_start, addr, NULL);\n+\tif (is_vm_hugetlb_page(vma))\n+\t\thugetlb_split(vma, addr);\n \n \tif (new_below) {\n \t\tvma->vm_start = addr;",335 "prediction": "Given the following original C code:\nif (new->vm_file)\n\t\tget_file(new->vm_file);\n\n\tif (new->vm_ops && new->vm_ops->open)\n\t\tnew->vm_ops->open(new);\n\n\tvma_start_write(vma);\n\tvma_start_write(new);\n\n\tinit_vma_prep(&vp, vma);\n\tvp.insert = new;\n\tvma_prepare(&vp);\n\tvma_adjust_trans_huge(vma, vma->vm_start, addr, NULL);\n\n\tif (new_below) {\n\t\tvma->vm_start = addr;\n\t\tvma->vm_pgoff += (addr - new->vm_start) >> PAGE_SHIFT;\n\t} else {\n\t\tvma->vm_end = addr;\n\t}\n\nInstruction:\nmm/hugetlb: unshare page tables during VMA split, not before\n\nReturn the diff that fixes it:\n @@ -107,6 +107,10 @@ int split_vma(struct vm_area_struct *vma, unsigned long addr,\n \n \tinit_vma_prep(&vp, vma);\n \tvp.insert = new;\n+\tif (new->vm_ops && new->vm_ops->unmap)\n+\t\tnew->vm_ops->unmap(new);\n+\tnew->vm_ops = NULL;\n+\tnew->vm_file = NULL;\n \tvma_prepare(&vp);\n \tvma_adjust_trans_huge(vma, vma->vm_start, addr, NULL);\n \n@@ -115,6 +119,10 @@ int split_vma(struct vm_area_struct *vma, unsigned long addr,\n \tif (new_below) {\n \t\tvma->vm_start = addr;\n \t\tvma->vm_pgoff += (addr - new->vm_start) >> PAGE_SHIFT;\n+"336 },337 {338 "prompt": "Given the following original C code:\nstatic inline void vma_adjust_trans_huge(struct vm_area_struct *vma,\n\t\t\t\t\t unsigned long start,\n\t\t\t\t\t unsigned long end,\n\t\t\t\t\t struct vm_area_struct *next)\n{\n\t(void)vma;\n\t(void)start;\n\t(void)end;\n\t(void)next;\n}\n\nstatic inline void vma_iter_free(struct vma_iterator *vmi)\n{\n\tmas_destroy(&vmi->mas);\n}\n\nstatic inline\nstruct vm_area_struct *vma_iter_next_range(struct vma_iterator *vmi)\n{\n\nInstruction:\nmm/hugetlb: unshare page tables during VMA split, not before\n\nReturn the diff that fixes it:\n",339 "reference": "@@ -932,6 +932,8 @@ static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,\n \t(void)next;\n }\n \n+static inline void hugetlb_split(struct vm_area_struct *, unsigned long) {}\n+\n static inline void vma_iter_free(struct vma_iterator *vmi)\n {\n \tmas_destroy(&vmi->mas);",340 "prediction": "Given the following original C code:\nstatic inline void vma_adjust_trans_huge(struct vm_area_struct *vma,\n\t\t\t\t\t unsigned long start,\n\t\t\t\t\t unsigned long end,\n\t\t\t\t\t struct vm_area_struct *next)\n{\n\t(void)vma;\n\t(void)start;\n\t(void)end;\n\t(void)next;\n}\n\nstatic inline void vma_iter_free(struct vma_iterator *vmi)\n{\n\tmas_destroy(&vmi->mas);\n}\n\nstatic inline\nstruct vm_area_struct *vma_iter_next_range(struct vma_iterator *vmi)\n{\n\nInstruction:\nmm/hugetlb: unshare page tables during VMA split, not before\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,\n \t(void)next;\n }\n \n-static inline void vma_iter_free(struct vma_iterator *vmi)\n+static inline void vma_iter_free(struct mm_struct *mm, struct vma_iterator *vmi)\n {\n \tmas_destroy(&vmi->mas);\n }\n@@ -111,7 +111,7 @@ static inline\n struct vm_area_struct *vma_iter_next_range(struct vma_iterator *vmi)\n {\n \tstruct vm_area_struct *vma;\n-\tstruct mm_struct *mm = vmi->mm;\n+\tstruct mm_struct *mm = vmi->mas.mm;\n \n \tvma = mas_next(&vmi->mas);\n \tif (vma) {\n@@ -120,7 +120,7 @@ struct vm_area_"341 },342 {343 "prompt": "Given the following original C code:\npgd_t *pgd = pgd_offset(mm, addr);\n\tp4d_t *p4d = p4d_offset(pgd, addr);\n\tpud_t *pud = pud_offset(p4d, addr);\n\n\ti_mmap_assert_write_locked(vma->vm_file->f_mapping);\n\thugetlb_vma_assert_locked(vma);\n\tif (sz != PMD_SIZE)\n\t\treturn 0;\n\tif (!ptdesc_pmd_pts_count(virt_to_ptdesc(ptep)))\n\t\treturn 0;\n\n\tpud_clear(pud);\n\tptdesc_pmd_pts_dec(virt_to_ptdesc(ptep));\n\tmm_dec_nr_pmds(mm);\n\treturn 1;\n}\n\n#else /* !CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING */\n\npte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma,\n\nInstruction:\nmm/hugetlb: fix huge_pmd_unshare() vs GUP-fast race\n\nReturn the diff that fixes it:\n",344 "reference": "@@ -7629,6 +7629,13 @@ int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma,\n \t\treturn 0;\n \n \tpud_clear(pud);\n+\t/*\n+\t * Once our caller drops the rmap lock, some other process might be\n+\t * using this page table as a normal, non-hugetlb page table.\n+\t * Wait for pending gup_fast() in other threads to finish before letting\n+\t * that happen.\n+\t */\n+\ttlb_remove_table_sync_one();\n \tptdesc_pmd_pts_dec(virt_to_ptdesc(ptep));\n \tmm_dec_nr_pmds(mm);\n \treturn 1;",345 "prediction": "Given the following original C code:\npgd_t *pgd = pgd_offset(mm, addr);\n\tp4d_t *p4d = p4d_offset(pgd, addr);\n\tpud_t *pud = pud_offset(p4d, addr);\n\n\ti_mmap_assert_write_locked(vma->vm_file->f_mapping);\n\thugetlb_vma_assert_locked(vma);\n\tif (sz != PMD_SIZE)\n\t\treturn 0;\n\tif (!ptdesc_pmd_pts_count(virt_to_ptdesc(ptep)))\n\t\treturn 0;\n\n\tpud_clear(pud);\n\tptdesc_pmd_pts_dec(virt_to_ptdesc(ptep));\n\tmm_dec_nr_pmds(mm);\n\treturn 1;\n}\n\n#else /* !CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING */\n\npte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma,\n\nInstruction:\nmm/hugetlb: fix huge_pmd_unshare() vs GUP-fast race\n\nReturn the diff that fixes it:\n @@ -104,7 +104,7 @@ int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma,\n \t\treturn 0;\n \n \tpud_clear(pud);\n-\tptdesc_pmd_pts_dec(virt_to_ptdesc(ptep));\n+\tptdesc_pmd_pts_dec(virt_to_ptdesc(ptep), mm);\n \tmm_dec_nr_pmds(mm);\n \treturn 1;\n }\n@@ -113,7 +113,7 @@ pte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma,\n \t\treturn NULL;\n \n \tpud_clear(pud);\n-\tptdesc_pmd_pts_inc(virt_to_ptdesc(ptep));\n+\tptdesc_pmd_pts_inc(virt_to_ptdesc(ptep), mm);"346 },347 {348 "prompt": "Given the following original C code:\n#include <linux/kvm_para.h>\n#include <linux/rcu_notifier.h>\n#include <linux/smp.h>\n\n//////////////////////////////////////////////////////////////////////////////\n//\n// Controlling CPU stall warnings, including delay calculation.\n\n/* panic() on RCU Stall sysctl. */\nint sysctl_panic_on_rcu_stall __read_mostly;\nint sysctl_max_rcu_stall_to_panic __read_mostly;\n\n#ifdef CONFIG_PROVE_RCU\n#define RCU_STALL_DELAY_DELTA\t\t(5 * HZ)\n#else\n#define RCU_STALL_DELAY_DELTA\t\t0\n#endif\n#define RCU_STALL_MIGHT_DIV\t\t8\n#define RCU_STALL_MIGHT_MIN\t\t(2 * HZ)\n\nInstruction:\nkernel/rcu/tree_stall: add /sys/kernel/rcu_stall_count\n\nReturn the diff that fixes it:\n",349 "reference": "@@ -20,6 +20,28 @@\n int sysctl_panic_on_rcu_stall __read_mostly;\n int sysctl_max_rcu_stall_to_panic __read_mostly;\n \n+#ifdef CONFIG_SYSFS\n+\n+static unsigned int rcu_stall_count;\n+\n+static ssize_t rcu_stall_count_show(struct kobject *kobj, struct kobj_attribute *attr,\n+\t\t\t\t char *page)\n+{\n+\treturn sysfs_emit(page, \"%u\\n\", rcu_stall_count);\n+}\n+\n+static struct kobj_attribute rcu_stall_count_attr = __ATTR_RO(rcu_stall_count);\n+\n+static __init int kernel_rcu_stall_sysfs_init(void)\n+{\n+\tsysfs_add_file_to_group(kernel_kobj, &rcu_stall_count_attr.attr, NULL);\n+\treturn 0;\n+}\n+\n+late_initcall(kernel_rcu_stall_sysfs_init);\n+\n+#endif // CONFIG_SYSFS\n+\n #ifdef CONFIG_PROVE_RCU\n #define RCU_STALL_DELAY_DELTA\t\t(5 * HZ)\n #else\n@@ -784,6 +806,10 @@ static void check_cpu_stall(struct rcu_data *rdp)\n \t\tif (kvm_check_and_clear_guest_paused())\n \t\t\treturn;\n \n+#ifdef CONFIG_SYSFS\n+\t\t++rcu_stall_count;\n+#endif\n+\n \t\trcu_stall_notifier_call_chain(RCU_STALL_NOTIFY_NORM, (void *)j - gps);\n \t\tif (READ_ONCE(csd_lock_suppress_rcu_stall) && csd_lock_is_stuck()) {\n \t\t\tpr_err(\"INFO: %s detected stall, but suppressed full report due to a stuck CSD-lock.\\n\", rcu_state.name);",350 "prediction": "Given the following original C code:\n#include <linux/kvm_para.h>\n#include <linux/rcu_notifier.h>\n#include <linux/smp.h>\n\n//////////////////////////////////////////////////////////////////////////////\n//\n// Controlling CPU stall warnings, including delay calculation.\n\n/* panic() on RCU Stall sysctl. */\nint sysctl_panic_on_rcu_stall __read_mostly;\nint sysctl_max_rcu_stall_to_panic __read_mostly;\n\n#ifdef CONFIG_PROVE_RCU\n#define RCU_STALL_DELAY_DELTA\t\t(5 * HZ)\n#else\n#define RCU_STALL_DELAY_DELTA\t\t0\n#endif\n#define RCU_STALL_MIGHT_DIV\t\t8\n#define RCU_STALL_MIGHT_MIN\t\t(2 * HZ)\n\nInstruction:\nkernel/rcu/tree_stall: add /sys/kernel/rcu_stall_count\n\nReturn the diff that fixes it:\n @@ -19,6 +19,7 @@\n int sysctl_panic_on_rcu_stall __read_mostly;\n int sysctl_max_rcu_stall_to_panic __read_mostly;\n \n+int rcu_stall_suppress __read_mostly;\n #ifdef CONFIG_PROVE_RCU\n #define RCU_STALL_DELAY_DELTA\t\t(5 * HZ)\n #else\n@@ -28,6 +29,7 @@\n #define RCU_STALL_DELAY_DELTA\t\t0\n #endif\n #define RCU_STALL_MIGHT_DIV\t\t8\n+#define RCU_STALL_MIGHT_MIN\t\t(2 * HZ)\n #define RCU_STALL_MIGHT_MAX\t\t(10 * HZ)\n #define RCU_STALL_RATIO_MIN\t\t1\n #define RCU_STALL_RATIO_MAX\t\t100\n@@ -38,6 +"351 },352 {353 "prompt": "Given the following original C code:\nreturn err;\n\n\terr = security_inode_listsecurity(inode, buffer, remaining_size);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (buffer) {\n\t\tif (remaining_size < err)\n\t\t\treturn -ERANGE;\n\t\tbuffer += err;\n\t}\n\tremaining_size -= err;\n\n\tread_lock(&xattrs->lock);\n\tfor (rbp = rb_first(&xattrs->rb_root); rbp; rbp = rb_next(rbp)) {\n\t\txattr = rb_entry(rbp, struct simple_xattr, rb_node);\n\n\t\t/* skip \"trusted.\" attributes for unprivileged callers */\n\t\tif (!trusted && xattr_is_trusted(xattr->name))\n\t\t\tcontinue;\n\nInstruction:\nfs/xattr.c: fix simple_xattr_list()\n\nReturn the diff that fixes it:\n",354 "reference": "@@ -1479,6 +1479,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,\n \t\tbuffer += err;\n \t}\n \tremaining_size -= err;\n+\terr = 0;\n \n \tread_lock(&xattrs->lock);\n \tfor (rbp = rb_first(&xattrs->rb_root); rbp; rbp = rb_next(rbp)) {",355 "prediction": "Given the following original C code:\nreturn err;\n\n\terr = security_inode_listsecurity(inode, buffer, remaining_size);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (buffer) {\n\t\tif (remaining_size < err)\n\t\t\treturn -ERANGE;\n\t\tbuffer += err;\n\t}\n\tremaining_size -= err;\n\n\tread_lock(&xattrs->lock);\n\tfor (rbp = rb_first(&xattrs->rb_root); rbp; rbp = rb_next(rbp)) {\n\t\txattr = rb_entry(rbp, struct simple_xattr, rb_node);\n\n\t\t/* skip \"trusted.\" attributes for unprivileged callers */\n\t\tif (!trusted && xattr_is_trusted(xattr->name))\n\t\t\tcontinue;\n\nInstruction:\nfs/xattr.c: fix simple_xattr_list()\n\nReturn the diff that fixes it:\n @@ -103,6 +103,10 @@ int simple_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)\n \t\tbuffer += err;\n \t}\n \tremaining_size -= err;\n+\n+\tif (buffer)\n+\t\t*buffer = '\\0';\n+\n \tread_lock(&xattrs->lock);\n \tfor (rbp = rb_first(&xattrs->rb_root); rbp; rbp = rb_next(rbp)) {\n \t\txattr = rb_entry(rbp, struct simple_xattr, rb_node);\n@@ -112,6 +116,10 @@ int simple_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)\n \t\t\tcontinue;\n \n \t\tif (buffer) {\n+\t\t\tsize_t len = strlen(xattr->name);\n+\n+\t\t\tif (remaining_size < len"356 },357 {358 "prompt": "Given the following original C code:\nfsc->filp_gen++; // invalidate open files\n}\n\n/*\n * ceph_umount_begin - initiate forced umount. Tear down the\n * mount, skipping steps that may hang while waiting for server(s).\n */\nvoid ceph_umount_begin(struct super_block *sb)\n{\n\tstruct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);\n\n\tdoutc(fsc->client, \"starting forced umount\\n\");\n\tif (!fsc)\n\t\treturn;\n\tfsc->mount_state = CEPH_MOUNT_SHUTDOWN;\n\t__ceph_umount_begin(fsc);\n}\n\nstatic const struct super_operations ceph_super_ops = {\n\t.alloc_inode\t= ceph_alloc_inode,\n\nInstruction:\nceph: fix variable dereferenced before check in ceph_umount_begin()\n\nReturn the diff that fixes it:\n",359 "reference": "@@ -1033,8 +1033,7 @@ void ceph_umount_begin(struct super_block *sb)\n \tstruct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);\n \n \tdoutc(fsc->client, \"starting forced umount\\n\");\n-\tif (!fsc)\n-\t\treturn;\n+\n \tfsc->mount_state = CEPH_MOUNT_SHUTDOWN;\n \t__ceph_umount_begin(fsc);\n }",360 "prediction": "Given the following original C code:\nfsc->filp_gen++; // invalidate open files\n}\n\n/*\n * ceph_umount_begin - initiate forced umount. Tear down the\n * mount, skipping steps that may hang while waiting for server(s).\n */\nvoid ceph_umount_begin(struct super_block *sb)\n{\n\tstruct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);\n\n\tdoutc(fsc->client, \"starting forced umount\\n\");\n\tif (!fsc)\n\t\treturn;\n\tfsc->mount_state = CEPH_MOUNT_SHUTDOWN;\n\t__ceph_umount_begin(fsc);\n}\n\nstatic const struct super_operations ceph_super_ops = {\n\t.alloc_inode\t= ceph_alloc_inode,\n\nInstruction:\nceph: fix variable dereferenced before check in ceph_umount_begin()\n\nReturn the diff that fixes it:\n @@ -109,7 +109,7 @@ void ceph_umount_begin(struct super_block *sb)\n {\n \tstruct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);\n \n-\tdoutc(fsc->client, \"starting forced umount\\n\");\n+\tdout(\"starting forced umount\\n\");\n \tif (!fsc)\n \t\treturn;\n \tfsc->mount_state = CEPH_MOUNT_SHUTDOWN;\n@@ -118,7 +118,7 @@ void ceph_umount_begin(struct super_block *sb)\n \t__ceph_umount_begin(fsc);\n }\n \n-static const struct super_operations ceph_super_ops = {\n+static const struct super_operations ceph_super_ops = {\n \t.alloc_inode\t= ceph_alloc_inode,\n \t.destroy_inode\t= ceph_destroy_inode,"361 },362 {363 "prompt": "Given the following original C code:\n#include <asm/vdso/vdso.h>\n\nstatic __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsigned int _flags)\n{\n\tregister long ret asm(\"a0\");\n\tregister long nr asm(\"a7\") = __NR_getrandom;\n\tregister void *buffer asm(\"a0\") = _buffer;\n\tregister size_t len asm(\"a1\") = _len;\n\tregister unsigned int flags asm(\"a2\") = _flags;\n\n\tasm volatile(\n\t\" syscall 0\\n\"\n\t: \"+r\" (ret)\n\t: \"r\" (nr), \"r\" (buffer), \"r\" (len), \"r\" (flags)\n\t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\", \"$t8\",\n\t \"memory\");\n\n\treturn ret;\n}\n\nInstruction:\nLoongArch: vDSO: Correctly use asm parameters in syscall wrappers\n\nReturn the diff that fixes it:\n",364 "reference": "@@ -20,7 +20,7 @@ static __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, uns\n \n \tasm volatile(\n \t\" syscall 0\\n\"\n-\t: \"+r\" (ret)\n+\t: \"=r\" (ret)\n \t: \"r\" (nr), \"r\" (buffer), \"r\" (len), \"r\" (flags)\n \t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\", \"$t8\",\n \t \"memory\");",365 "prediction": "Given the following original C code:\n#include <asm/vdso/vdso.h>\n\nstatic __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsigned int _flags)\n{\n\tregister long ret asm(\"a0\");\n\tregister long nr asm(\"a7\") = __NR_getrandom;\n\tregister void *buffer asm(\"a0\") = _buffer;\n\tregister size_t len asm(\"a1\") = _len;\n\tregister unsigned int flags asm(\"a2\") = _flags;\n\n\tasm volatile(\n\t\" syscall 0\\n\"\n\t: \"+r\" (ret)\n\t: \"r\" (nr), \"r\" (buffer), \"r\" (len), \"r\" (flags)\n\t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\", \"$t8\",\n\t \"memory\");\n\n\treturn ret;\n}\n\nInstruction:\nLoongArch: vDSO: Correctly use asm parameters in syscall wrappers\n\nReturn the diff that fixes it:\n @@ -11,7 +11,7 @@ static __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsi\n \n \tasm volatile(\n \t\" syscall 0\\n\"\n-\t: \"+r\" (ret)\n+\t: \"+r\" (ret) : \"r\" (nr), \"r\" (buffer), \"r\" (len), \"r\" (flags)\n \t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\", \"$t8\",\n \t \"memory\");\n \n@@ -21,7 +21,7 @@ static __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsi\n \n \tasm volatile(\n \t\" syscall 0\\n\"\n-\t: \"+r\" (ret)\n+\t: \"+r\" (ret) : \"r\" (nr), \"r\" (buffer), \"r"366 },367 {368 "prompt": "Given the following original C code:\nstatic __always_inline long gettimeofday_fallback(\n\t\t\t\tstruct __kernel_old_timeval *_tv,\n\t\t\t\tstruct timezone *_tz)\n{\n\tregister struct __kernel_old_timeval *tv asm(\"a0\") = _tv;\n\tregister struct timezone *tz asm(\"a1\") = _tz;\n\tregister long nr asm(\"a7\") = __NR_gettimeofday;\n\tregister long ret asm(\"a0\");\n\n\tasm volatile(\n\t\" syscall 0\\n\"\n\t: \"+r\" (ret)\n\t: \"r\" (nr), \"r\" (tv), \"r\" (tz)\n\t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\",\n\t \"$t8\", \"memory\");\n\n\treturn ret;\n}\n\nInstruction:\nLoongArch: vDSO: Correctly use asm parameters in syscall wrappers\n\nReturn the diff that fixes it:\n",369 "reference": "@@ -25,7 +25,7 @@ static __always_inline long gettimeofday_fallback(\n \n \tasm volatile(\n \t\" syscall 0\\n\"\n-\t: \"+r\" (ret)\n+\t: \"=r\" (ret)\n \t: \"r\" (nr), \"r\" (tv), \"r\" (tz)\n \t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\",\n \t \"$t8\", \"memory\");\n@@ -44,7 +44,7 @@ static __always_inline long clock_gettime_fallback(\n \n \tasm volatile(\n \t\" syscall 0\\n\"\n-\t: \"+r\" (ret)\n+\t: \"=r\" (ret)\n \t: \"r\" (nr), \"r\" (clkid), \"r\" (ts)\n \t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\",\n \t \"$t8\", \"memory\");\n@@ -63,7 +63,7 @@ static __always_inline int clock_getres_fallback(\n \n \tasm volatile(\n \t\" syscall 0\\n\"\n-\t: \"+r\" (ret)\n+\t: \"=r\" (ret)\n \t: \"r\" (nr), \"r\" (clkid), \"r\" (ts)\n \t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\",\n \t \"$t8\", \"memory\");",370 "prediction": "Given the following original C code:\nstatic __always_inline long gettimeofday_fallback(\n\t\t\t\tstruct __kernel_old_timeval *_tv,\n\t\t\t\tstruct timezone *_tz)\n{\n\tregister struct __kernel_old_timeval *tv asm(\"a0\") = _tv;\n\tregister struct timezone *tz asm(\"a1\") = _tz;\n\tregister long nr asm(\"a7\") = __NR_gettimeofday;\n\tregister long ret asm(\"a0\");\n\n\tasm volatile(\n\t\" syscall 0\\n\"\n\t: \"+r\" (ret)\n\t: \"r\" (nr), \"r\" (tv), \"r\" (tz)\n\t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\",\n\t \"$t8\", \"memory\");\n\n\treturn ret;\n}\n\nInstruction:\nLoongArch: vDSO: Correctly use asm parameters in syscall wrappers\n\nReturn the diff that fixes it:\n @@ -103,7 +103,7 @@ static __always_inline long gettimeofday_fallback(\n \tasm volatile(\n \t\" syscall 0\\n\"\n \t: \"+r\" (ret)\n-\t: \"r\" (nr), \"r\" (tv), \"r\" (tz)\n+\t: \"r\" (nr), \"r\" (tv), \"r\" (tz)\n \t: \"$t0\", \"$t1\", \"$t2\", \"$t3\", \"$t4\", \"$t5\", \"$t6\", \"$t7\",\n \t \"$t8\", \"memory\");\n \n@@ -113,7 +113,7 @@ static __always_inline long gettimeofday_fallback(\n \tasm volatile(\n \t\" syscall 0\\n\"\n \t: \"+r\" (ret)\n-\t: \"r\" (nr), \"r\" (tv)\n+\t: \"r\" (nr), \"r\" (tv)\n \t: \"$t0\", \"$t1\","371 },372 {373 "prompt": "Given the following original C code:\n};\n\nstatic int laptop_backlight_register(void)\n{\n\tint status = 0;\n\tstruct backlight_properties props;\n\n\tmemset(&props, 0, sizeof(props));\n\n\tif (!acpi_evalf(hotkey_handle, &status, \"ECLL\", \"d\"))\n\t\treturn -EIO;\n\n\tprops.brightness = 1;\n\tprops.max_brightness = status;\n\tprops.type = BACKLIGHT_PLATFORM;\n\n\tbacklight_device_register(\"loongson_laptop\",\n\t\t\t\tNULL, NULL, &backlight_laptop_ops, &props);\n\n\treturn 0;\n\nInstruction:\nplatform/loongarch: laptop: Get brightness setting from EC on probe\n\nReturn the diff that fixes it:\n",374 "reference": "@@ -392,8 +392,8 @@ static int laptop_backlight_register(void)\n \tif (!acpi_evalf(hotkey_handle, &status, \"ECLL\", \"d\"))\n \t\treturn -EIO;\n \n-\tprops.brightness = 1;\n \tprops.max_brightness = status;\n+\tprops.brightness = ec_get_brightness();\n \tprops.type = BACKLIGHT_PLATFORM;\n \n \tbacklight_device_register(\"loongson_laptop\",",375 "prediction": "Given the following original C code:\n};\n\nstatic int laptop_backlight_register(void)\n{\n\tint status = 0;\n\tstruct backlight_properties props;\n\n\tmemset(&props, 0, sizeof(props));\n\n\tif (!acpi_evalf(hotkey_handle, &status, \"ECLL\", \"d\"))\n\t\treturn -EIO;\n\n\tprops.brightness = 1;\n\tprops.max_brightness = status;\n\tprops.type = BACKLIGHT_PLATFORM;\n\n\tbacklight_device_register(\"loongson_laptop\",\n\t\t\t\tNULL, NULL, &backlight_laptop_ops, &props);\n\n\treturn 0;\n\nInstruction:\nplatform/loongarch: laptop: Get brightness setting from EC on probe\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int laptop_backlight_register(void)\n \tif (!acpi_evalf(hotkey_handle, &status, \"ECLL\", \"d\"))\n \t\treturn -EIO;\n \n-\tprops.brightness = 1;\n+\tprops.brightness = status;\n \tprops.max_brightness = status;\n \tprops.type = BACKLIGHT_PLATFORM;\n \n@@ -116,7 +116,7 @@ static int laptop_backlight_register(void)\n \tbacklight_device_register(\"loongson_laptop\",\n \t\t\t\tNULL, NULL, &backlight_laptop_ops, &props);\n \n-\tacpi_evalf(hotkey_handle, NULL, \"ECLS\", \"d\", props.brightness);\n+\tacpi_evalf(hotkey_handle, NULL, \"ECLS\", \"d\", props.max_brightness);\n \n \treturn"376 },377 {378 "prompt": "Given the following original C code:\n/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n/* bits.h: Macros for dealing with bitmasks. */\n\n#ifndef _UAPI_LINUX_BITS_H\n#define _UAPI_LINUX_BITS_H\n\n#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))\n\n#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))\n\n#define __GENMASK_U128(h, l) \\\n\t((_BIT128((h)) << 1) - (_BIT128(l)))\n\n#endif /* _UAPI_LINUX_BITS_H */\n\nInstruction:\nuapi: bitops: use UAPI-safe variant of BITS_PER_LONG again\n\nReturn the diff that fixes it:\n",379 "reference": "@@ -4,9 +4,9 @@\n #ifndef _UAPI_LINUX_BITS_H\n #define _UAPI_LINUX_BITS_H\n \n-#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))\n+#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))\n \n-#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))\n+#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))\n \n #define __GENMASK_U128(h, l) \\\n \t((_BIT128((h)) << 1) - (_BIT128(l)))",380 "prediction": "Given the following original C code:\n/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n/* bits.h: Macros for dealing with bitmasks. */\n\n#ifndef _UAPI_LINUX_BITS_H\n#define _UAPI_LINUX_BITS_H\n\n#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))\n\n#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))\n\n#define __GENMASK_U128(h, l) \\\n\t((_BIT128((h)) << 1) - (_BIT128(l)))\n\n#endif /* _UAPI_LINUX_BITS_H */\n\nInstruction:\nuapi: bitops: use UAPI-safe variant of BITS_PER_LONG again\n\nReturn the diff that fixes it:\n @@ -3,7 +3,7 @@\n #define _UAPI_LINUX_BITS_H\n \n #define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))\n-\n #define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))\n+#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG - 1 - (h))))\n \n #define __GENMASK_U128(h, l) \\\n \t((_BIT128((h)) << 1) - (_BIT128(l)))\n@@ -18,7 +18,7 @@\n #define __GENMASK_ULL(h, l"381 },382 {383 "prompt": "Given the following original C code:\nreturn libbpf_ptr(btf_parse_raw(path, base_btf));\n}\n\nstatic struct btf *btf_parse_raw_mmap(const char *path, struct btf *base_btf)\n{\n\tstruct stat st;\n\tvoid *data;\n\tstruct btf *btf;\n\tint fd, err;\n\n\tfd = open(path, O_RDONLY);\n\tif (fd < 0)\n\t\treturn libbpf_err_ptr(-errno);\n\n\tif (fstat(fd, &st) < 0) {\n\t\terr = -errno;\n\t\tclose(fd);\n\t\treturn libbpf_err_ptr(err);\n\t}\n\nInstruction:\nlibbpf: Handle unsupported mmap-based /sys/kernel/btf/vmlinux correctly\n\nReturn the diff that fixes it:\n",384 "reference": "@@ -1384,12 +1384,12 @@ static struct btf *btf_parse_raw_mmap(const char *path, struct btf *base_btf)\n \n \tfd = open(path, O_RDONLY);\n \tif (fd < 0)\n-\t\treturn libbpf_err_ptr(-errno);\n+\t\treturn ERR_PTR(-errno);\n \n \tif (fstat(fd, &st) < 0) {\n \t\terr = -errno;\n \t\tclose(fd);\n-\t\treturn libbpf_err_ptr(err);\n+\t\treturn ERR_PTR(err);\n \t}\n \n \tdata = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);\n@@ -1397,7 +1397,7 @@ static struct btf *btf_parse_raw_mmap(const char *path, struct btf *base_btf)\n \tclose(fd);\n \n \tif (data == MAP_FAILED)\n-\t\treturn libbpf_err_ptr(err);\n+\t\treturn ERR_PTR(err);\n \n \tbtf = btf_new(data, st.st_size, base_btf, true);\n \tif (IS_ERR(btf))",385 "prediction": "Given the following original C code:\nreturn libbpf_ptr(btf_parse_raw(path, base_btf));\n}\n\nstatic struct btf *btf_parse_raw_mmap(const char *path, struct btf *base_btf)\n{\n\tstruct stat st;\n\tvoid *data;\n\tstruct btf *btf;\n\tint fd, err;\n\n\tfd = open(path, O_RDONLY);\n\tif (fd < 0)\n\t\treturn libbpf_err_ptr(-errno);\n\n\tif (fstat(fd, &st) < 0) {\n\t\terr = -errno;\n\t\tclose(fd);\n\t\treturn libbpf_err_ptr(err);\n\t}\n\nInstruction:\nlibbpf: Handle unsupported mmap-based /sys/kernel/btf/vmlinux correctly\n\nReturn the diff that fixes it:\n @@ -106,6 +106,10 @@ static struct btf *btf_parse_raw_mmap(const char *path, struct btf *base_btf)\n \tint fd, err;\n \n \tfd = open(path, O_RDONLY);\n+\tif (fd < 0) {\n+\t\tif (errno == ENOENT)\n+\t\t\treturn libbpf_err_ptr(-ENOENT);\n+\t\treturn libbpf_err_ptr(-errno);\n+\t}\n \tif (fd < 0)\n \t\treturn libbpf_err_ptr(-errno);\n \n@@ -114,6 +118,10 @@ static struct btf *btf_parse_raw_mmap(const char *path, struct btf *base_btf)\n \tif (fstat(fd, &st) < 0) {\n \t\terr = -errno;\n \t\tclose(fd);\n+\t\tif (err == -EN"386 },387 {388 "prompt": "Given the following original C code:\nstatic void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,\n\t\t\t\t\tstruct trace_array *tr)\n{\n\tstruct trace_event_file *file;\n\n\tlist_for_each_entry(file, &tr->events, list) {\n\t\tif (file->system != dir)\n\t\t\tcontinue;\n\t\t__remove_filter(file);\n\t}\n}\n\nstatic inline void __free_subsystem_filter(struct trace_event_file *file)\n{\n\t__free_filter(file->filter);\n\tfile->filter = NULL;\n}\n\nstatic void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,\n\t\t\t\t\t struct trace_array *tr)\n\nInstruction:\ntracing: Fix regression of filter waiting a long time on RCU synchronization\n\nReturn the diff that fixes it:\n",389 "reference": "@@ -1335,22 +1335,139 @@ static void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,\n \t}\n }\n \n+struct filter_list {\n+\tstruct list_head\tlist;\n+\tstruct event_filter\t*filter;\n+};\n+\n+struct filter_head {\n+\tstruct list_head\tlist;\n+\tstruct rcu_head\t\trcu;\n+};\n+\n+\n+static void free_filter_list(struct rcu_head *rhp)\n+{\n+\tstruct filter_head *filter_list = container_of(rhp, struct filter_head, rcu);\n+\tstruct filter_list *filter_item, *tmp;\n+\n+\tlist_for_each_entry_safe(filter_item, tmp, &filter_list->list, list) {\n+\t\t__free_filter(filter_item->filter);\n+\t\tlist_del(&filter_item->list);\n+\t\tkfree(filter_item);\n+\t}\n+\tkfree(filter_list);\n+}\n+\n+static void free_filter_list_tasks(struct rcu_head *rhp)\n+{\n+\tcall_rcu(rhp, free_filter_list);\n+}\n+\n+/*\n+ * The tracepoint_synchronize_unregister() is a double rcu call.\n+ * It calls synchronize_rcu_tasks_trace() followed by synchronize_rcu().\n+ * Instead of waiting for it, simply call these via the call_rcu*()\n+ * variants.\n+ */\n+static void delay_free_filter(struct filter_head *head)\n+{\n+\tcall_rcu_tasks_trace(&head->rcu, free_filter_list_tasks);\n+}\n+\n+static void try_delay_free_filter(struct event_filter *filter)\n+{\n+\tstruct filter_head *head;\n+\tstruct filter_list *item;\n+\n+\thead = kmalloc(sizeof(*head), GFP_KERNEL);\n+\tif (!head)\n+\t\tgoto free_now;\n+\n+\tINIT_LIST_HEAD(&head->list);\n+\n+\titem = kmalloc(sizeof(*item), GFP_KERNEL);\n+\tif (!item) {\n+\t\tkfree(head);\n+\t\tgoto free_now;\n+\t}\n+\n+\titem->filter = filter;\n+\tlist_add_tail(&item->list, &head->list);\n+\tdelay_free_filter(head);\n+\treturn;\n+\n+ free_now:\n+\t/* Make sure the filter is not being used */\n+\ttracepoint_synchronize_unregister();\n+\t__free_filter(filter);\n+}\n+\n static inline void __free_subsystem_filter(struct trace_event_file *file)\n {\n \t__free_filter(file->filter);\n \tfile->filter = NULL;\n }\n \n+static inline void event_set_filter(struct trace_event_file *file,\n+\t\t\t\t struct event_filter *filter)\n+{\n+\trcu_assign_pointer(file->filter, filter);\n+}\n+\n+static inline void event_clear_filter(struct trace_event_file *file)\n+{\n+\tRCU_INIT_POINTER(file->filter, NULL);\n+}\n+\n static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,\n-\t\t\t\t\t struct trace_array *tr)\n+\t\t\t\t\t struct trace_array *tr,\n+\t\t\t\t\t struct event_filter *filter)\n {\n \tstruct trace_event_file *file;\n+\tstruct filter_head *head;\n+\tstruct filter_list *item;\n+\n+\thead = kmalloc(sizeof(*head), GFP_KERNEL);\n+\tif (!head)\n+\t\tgoto free_now;\n+\n+\tINIT_LIST_HEAD(&head->list);\n+\n+\titem = kmalloc(sizeof(*item), GFP_KERNEL);\n+\tif (!item) {\n+\t\tkfree(head);\n+\t\tgoto free_now;\n+\t}\n+\n+\titem->filter = filter;\n+\tlist_add_tail(&item->list, &head->list);\n \n \tlist_for_each_entry(file, &tr->events, list) {\n \t\tif (file->system != dir)\n \t\t\tcontinue;\n-\t\t__free_subsystem_filter(file);\n+\t\titem = kmalloc(sizeof(*item), GFP_KERNEL);\n+\t\tif (!item)\n+\t\t\tgoto free_now;\n+\t\titem->filter = event_filter(file);\n+\t\tlist_add_tail(&item->list, &head->list);\n+\t\tevent_clear_filter(file);\n \t}\n+\n+\tdelay_free_filter(head);\n+\treturn;\n+ free_now:\n+\ttracepoint_synchronize_unregister();\n+\n+\tif (head)\n+\t\tfree_filter_list(&head->rcu);\n+\n+\tlist_for_each_entry(file, &tr->events, list) {\n+\t\tif (file->system != dir || !file->filter)\n+\t\t\tcontinue;\n+\t\t__free_filter(file->filter);\n+\t}\n+\t__free_filter(filter);\n }\n \n int filter_assign_type(const char *type)\n@@ -2120,22 +2237,6 @@ static inline void event_set_filtered_flag(struct trace_event_file *file)\n \t\ttrace_buffered_event_enable();\n }\n \n-static inline void event_set_filter(struct trace_event_file *file,\n-\t\t\t\t struct event_filter *filter)\n-{\n-\trcu_assign_pointer(file->filter, filter);\n-}\n-\n-static inline void event_clear_filter(struct trace_event_file *file)\n-{\n-\tRCU_INIT_POINTER(file->filter, NULL);\n-}\n-\n-struct filter_list {\n-\tstruct list_head\tlist;\n-\tstruct event_filter\t*filter;\n-};\n-\n static int process_system_preds(struct trace_subsystem_dir *dir,\n \t\t\t\tstruct trace_array *tr,\n \t\t\t\tstruct filter_parse_error *pe,\n@@ -2144,11 +2245,16 @@ static int process_system_preds(struct trace_subsystem_dir *dir,\n \tstruct trace_event_file *file;\n \tstruct filter_list *filter_item;\n \tstruct event_filter *filter = NULL;\n-\tstruct filter_list *tmp;\n-\tLIST_HEAD(filter_list);\n+\tstruct filter_head *filter_list;\n \tbool fail = true;\n \tint err;\n \n+\tfilter_list = kmalloc(sizeof(*filter_list), GFP_KERNEL);\n+\tif (!filter_list)\n+\t\treturn -ENOMEM;\n+\n+\tINIT_LIST_HEAD(&filter_list->list);\n+\n \tlist_for_each_entry(file, &tr->events, list) {\n \n \t\tif (file->system != dir)\n@@ -2175,7 +2281,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir,\n \t\tif (!filter_item)\n \t\t\tgoto fail_mem;\n \n-\t\tlist_add_tail(&filter_item->list, &filter_list);\n+\t\tlist_add_tail(&filter_item->list, &filter_list->list);\n \t\t/*\n \t\t * Regardless of if this returned an error, we still\n \t\t * replace the filter for the call.\n@@ -2195,31 +2301,22 @@ static int process_system_preds(struct trace_subsystem_dir *dir,\n \t * Do a synchronize_rcu() and to ensure all calls are\n \t * done with them before we free them.\n \t */\n-\ttracepoint_synchronize_unregister();\n-\tlist_for_each_entry_safe(filter_item, tmp, &filter_list, list) {\n-\t\t__free_filter(filter_item->filter);\n-\t\tlist_del(&filter_item->list);\n-\t\tkfree(filter_item);\n-\t}\n+\tdelay_free_filter(filter_list);\n \treturn 0;\n fail:\n \t/* No call succeeded */\n-\tlist_for_each_entry_safe(filter_item, tmp, &filter_list, list) {\n-\t\tlist_del(&filter_item->list);\n-\t\tkfree(filter_item);\n-\t}\n+\tfree_filter_list(&filter_list->rcu);\n \tparse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0);\n \treturn -EINVAL;\n fail_mem:\n \t__free_filter(filter);\n+\n \t/* If any call succeeded, we still need to sync */\n \tif (!fail)\n-\t\ttracepoint_synchronize_unregister();\n-\tlist_for_each_entry_safe(filter_item, tmp, &filter_list, list) {\n-\t\t__free_filter(filter_item->filter);\n-\t\tlist_del(&filter_item->list);\n-\t\tkfree(filter_item);\n-\t}\n+\t\tdelay_free_filter(filter_list);\n+\telse\n+\t\tfree_filter_list(&filter_list->rcu);\n+\n \treturn -ENOMEM;\n }\n \n@@ -2361,9 +2458,7 @@ int apply_event_filter(struct trace_event_file *file, char *filter_string)\n \n \t\tevent_clear_filter(file);\n \n-\t\t/* Make sure the filter is not being used */\n-\t\ttracepoint_synchronize_unregister();\n-\t\t__free_filter(filter);\n+\t\ttry_delay_free_filter(filter);\n \n \t\treturn 0;\n \t}\n@@ -2387,11 +2482,8 @@ int apply_event_filter(struct trace_event_file *file, char *filter_string)\n \n \t\tevent_set_filter(file, filter);\n \n-\t\tif (tmp) {\n-\t\t\t/* Make sure the call is done with the filter */\n-\t\t\ttracepoint_synchronize_unregister();\n-\t\t\t__free_filter(tmp);\n-\t\t}\n+\t\tif (tmp)\n+\t\t\ttry_delay_free_filter(tmp);\n \t}\n \n \treturn err;\n@@ -2417,9 +2509,7 @@ int apply_subsystem_event_filter(struct trace_subsystem_dir *dir,\n \t\tfilter = system->filter;\n \t\tsystem->filter = NULL;\n \t\t/* Ensure all filters are no longer used */\n-\t\ttracepoint_synchronize_unregister();\n-\t\tfilter_free_subsystem_filters(dir, tr);\n-\t\t__free_filter(filter);\n+\t\tfilter_free_subsystem_filters(dir, tr, filter);\n \t\treturn 0;\n \t}",390 "prediction": "Given the following original C code:\nstatic void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,\n\t\t\t\t\tstruct trace_array *tr)\n{\n\tstruct trace_event_file *file;\n\n\tlist_for_each_entry(file, &tr->events, list) {\n\t\tif (file->system != dir)\n\t\t\tcontinue;\n\t\t__remove_filter(file);\n\t}\n}\n\nstatic inline void __free_subsystem_filter(struct trace_event_file *file)\n{\n\t__free_filter(file->filter);\n\tfile->filter = NULL;\n}\n\nstatic void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,\n\t\t\t\t\t struct trace_array *tr)\n\nInstruction:\ntracing: Fix regression of filter waiting a long time on RCU synchronization\n\nReturn the diff that fixes it:\n @@ -105,6 +105,11 @@ static void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,\n \t}\n }\n \n+static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,\n+\t\t\t\t\t struct trace_array *tr)\n+{\n+\tstruct trace_event_file *file;\n+\n static inline void __free_subsystem_filter(struct trace_event_file *file)\n {\n \t__free_filter(file->filter);\n \tfile->filter = NULL;\n@@ -113,6 +118,7 @@ static void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,\n \n static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,\n \t\t\t\t\t struct trace_array *tr)\n {\n+\trcu_read_lock();\n \tlist_for_each_entry_rcu(dir, &tr"391 },392 {393 "prompt": "Given the following original C code:\npsize = (1 << order) * PAGE_SIZE;\n\tif (psize <= BUF_PAGE_HDR_SIZE)\n\t\treturn -EINVAL;\n\n\t/* Size of a subbuf cannot be greater than the write counter */\n\tif (psize > RB_WRITE_MASK + 1)\n\t\treturn -EINVAL;\n\n\told_order = buffer->subbuf_order;\n\told_size = buffer->subbuf_size;\n\n\t/* prevent another thread from changing buffer sizes */\n\tmutex_lock(&buffer->mutex);\n\tatomic_inc(&buffer->record_disabled);\n\n\t/* Make sure all commits have finished */\n\tsynchronize_rcu();\n\n\tbuffer->subbuf_order = order;\n\tbuffer->subbuf_size = psize - BUF_PAGE_HDR_SIZE;\n\nInstruction:\nring-buffer: Fix buffer locking in ring_buffer_subbuf_order_set()\n\nReturn the diff that fixes it:\n",394 "reference": "@@ -6795,7 +6795,7 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)\n \told_size = buffer->subbuf_size;\n \n \t/* prevent another thread from changing buffer sizes */\n-\tmutex_lock(&buffer->mutex);\n+\tguard(mutex)(&buffer->mutex);\n \tatomic_inc(&buffer->record_disabled);\n \n \t/* Make sure all commits have finished */\n@@ -6900,7 +6900,6 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)\n \t}\n \n \tatomic_dec(&buffer->record_disabled);\n-\tmutex_unlock(&buffer->mutex);\n \n \treturn 0;\n \n@@ -6909,7 +6908,6 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)\n \tbuffer->subbuf_size = old_size;\n \n \tatomic_dec(&buffer->record_disabled);\n-\tmutex_unlock(&buffer->mutex);\n \n \tfor_each_buffer_cpu(buffer, cpu) {\n \t\tcpu_buffer = buffer->buffers[cpu];",395 "prediction": "Given the following original C code:\npsize = (1 << order) * PAGE_SIZE;\n\tif (psize <= BUF_PAGE_HDR_SIZE)\n\t\treturn -EINVAL;\n\n\t/* Size of a subbuf cannot be greater than the write counter */\n\tif (psize > RB_WRITE_MASK + 1)\n\t\treturn -EINVAL;\n\n\told_order = buffer->subbuf_order;\n\told_size = buffer->subbuf_size;\n\n\t/* prevent another thread from changing buffer sizes */\n\tmutex_lock(&buffer->mutex);\n\tatomic_inc(&buffer->record_disabled);\n\n\t/* Make sure all commits have finished */\n\tsynchronize_rcu();\n\n\tbuffer->subbuf_order = order;\n\tbuffer->subbuf_size = psize - BUF_PAGE_HDR_SIZE;\n\nInstruction:\nring-buffer: Fix buffer locking in ring_buffer_subbuf_order_set()\n\nReturn the diff that fixes it:\n @@ -107,10 +107,10 @@ int ring_buffer_subbuf_order_set(struct ring_buffer *buffer, unsigned order)\n \told_order = buffer->subbuf_order;\n \told_size = buffer->subbuf_size;\n \n-\t/* prevent another thread from changing buffer sizes */\n-\tmutex_lock(&buffer->mutex);\n+\tmutex_lock(&buffer->mutex);\n \tatomic_inc(&buffer->record_disabled);\n \n \t/* Make sure all commits have finished */\n \tsynchronize_rcu();\n+\tmutex_unlock(&buffer->mutex);\n \n \tbuffer->subbuf_order = order;\n \tbuffer->subbuf_size = psize - BUF_PAGE_HDR_SIZE;\n@@ -119,7 +119,7 @@ int ring_buffer_subbuf_order_set(struct ring_buffer *buffer, unsigned order)\n \tif (old_size != buffer->subbuf_size)"396 },397 {398 "prompt": "Given the following original C code:\nTP_PROTO(const char *name, unsigned int state),\n\n\tTP_ARGS(name, state)\n);\n\nDEFINE_EVENT(wakeup_source, wakeup_source_deactivate,\n\n\tTP_PROTO(const char *name, unsigned int state),\n\n\tTP_ARGS(name, state)\n);\n\n/*\n * The clock events are used for clock enable/disable and for\n * clock rate change\n */\nDECLARE_EVENT_CLASS(clock,\n\n\tTP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),\n\nInstruction:\ntracing: PM: Remove unused clock events\n\nReturn the diff that fixes it:\n",399 "reference": "@@ -337,53 +337,6 @@ DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,\n \tTP_ARGS(name, state)\n );\n \n-/*\n- * The clock events are used for clock enable/disable and for\n- * clock rate change\n- */\n-DECLARE_EVENT_CLASS(clock,\n-\n-\tTP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),\n-\n-\tTP_ARGS(name, state, cpu_id),\n-\n-\tTP_STRUCT__entry(\n-\t\t__string( name, name )\n-\t\t__field( u64, state )\n-\t\t__field( u64, cpu_id )\n-\t),\n-\n-\tTP_fast_assign(\n-\t\t__assign_str(name);\n-\t\t__entry->state = state;\n-\t\t__entry->cpu_id = cpu_id;\n-\t),\n-\n-\tTP_printk(\"%s state=%lu cpu_id=%lu\", __get_str(name),\n-\t\t(unsigned long)__entry->state, (unsigned long)__entry->cpu_id)\n-);\n-\n-DEFINE_EVENT(clock, clock_enable,\n-\n-\tTP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),\n-\n-\tTP_ARGS(name, state, cpu_id)\n-);\n-\n-DEFINE_EVENT(clock, clock_disable,\n-\n-\tTP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),\n-\n-\tTP_ARGS(name, state, cpu_id)\n-);\n-\n-DEFINE_EVENT(clock, clock_set_rate,\n-\n-\tTP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),\n-\n-\tTP_ARGS(name, state, cpu_id)\n-);\n-\n /*\n * The power domain events are used for power domains transitions\n */",400 "prediction": "Given the following original C code:\nTP_PROTO(const char *name, unsigned int state),\n\n\tTP_ARGS(name, state)\n);\n\nDEFINE_EVENT(wakeup_source, wakeup_source_deactivate,\n\n\tTP_PROTO(const char *name, unsigned int state),\n\n\tTP_ARGS(name, state)\n);\n\n/*\n * The clock events are used for clock enable/disable and for\n * clock rate change\n */\nDECLARE_EVENT_CLASS(clock,\n\n\tTP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),\n\nInstruction:\ntracing: PM: Remove unused clock events\n\nReturn the diff that fixes it:\n @@ -100,13 +100,6 @@ DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,\n \tTP_ARGS(name, state)\n );\n \n-/*\n- * The clock events are used for clock enable/disable and for\n- * clock rate change\n- */\n-DECLARE_EVENT_CLASS(clock,\n-\n-\tTP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),\n-\n-\tTP_ARGS(name, state, cpu_id),\n-\n-\tTP_STRUCT__entry(\n-\t\t__string(name, name)\n-\t\t__field(unsigned int, state)\n-\t\t__field(unsigned int, cpu_id)\n-\t),\n-\n-\tTP_fast_assign(\n-\t\t__assign_str(name, name);\n-\t\t__entry->state = state;\n-\t\t__entry->cpu_id = cpu_id;\n-\t),\n-\n-\tTP_"401 },402 {403 "prompt": "Given the following original C code:\nstruct platform_driver *driver;\n\tint (*init)(struct generic_sub_driver *sub_driver);\n\tvoid (*notify)(struct generic_sub_driver *sub_driver, u32 event);\n\tu8 acpi_notify_installed;\n};\n\nstatic u32 input_device_registered;\nstatic struct input_dev *generic_inputdev;\n\nstatic acpi_handle hotkey_handle;\nstatic struct key_entry hotkey_keycode_map[GENERIC_HOTKEY_MAP_MAX];\n\nint loongson_laptop_turn_on_backlight(void);\nint loongson_laptop_turn_off_backlight(void);\nstatic int loongson_laptop_backlight_update(struct backlight_device *bd);\n\n/* 2. ACPI Helpers and device model */\n\nstatic int acpi_evalf(acpi_handle handle, int *res, char *method, char *fmt, ...)\n{\n\nInstruction:\nplatform/loongarch: laptop: Add backlight power control support\n\nReturn the diff that fixes it:\n",404 "reference": "@@ -56,8 +56,7 @@ static struct input_dev *generic_inputdev;\n static acpi_handle hotkey_handle;\n static struct key_entry hotkey_keycode_map[GENERIC_HOTKEY_MAP_MAX];\n \n-int loongson_laptop_turn_on_backlight(void);\n-int loongson_laptop_turn_off_backlight(void);\n+static bool bl_powered;\n static int loongson_laptop_backlight_update(struct backlight_device *bd);\n \n /* 2. ACPI Helpers and device model */\n@@ -354,16 +353,42 @@ static int ec_backlight_level(u8 level)\n \treturn level;\n }\n \n+static int ec_backlight_set_power(bool state)\n+{\n+\tint status;\n+\tunion acpi_object arg0 = { ACPI_TYPE_INTEGER };\n+\tstruct acpi_object_list args = { 1, &arg0 };\n+\n+\targ0.integer.value = state;\n+\tstatus = acpi_evaluate_object(NULL, \"\\\\BLSW\", &args, NULL);\n+\tif (ACPI_FAILURE(status)) {\n+\t\tpr_info(\"Loongson lvds error: 0x%x\\n\", status);\n+\t\treturn -EIO;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int loongson_laptop_backlight_update(struct backlight_device *bd)\n {\n-\tint lvl = ec_backlight_level(bd->props.brightness);\n+\tbool target_powered = !backlight_is_blank(bd);\n+\tint ret = 0, lvl = ec_backlight_level(bd->props.brightness);\n \n \tif (lvl < 0)\n \t\treturn -EIO;\n+\n \tif (ec_set_brightness(lvl))\n \t\treturn -EIO;\n \n-\treturn 0;\n+\tif (target_powered != bl_powered) {\n+\t\tret = ec_backlight_set_power(target_powered);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\n+\t\tbl_powered = target_powered;\n+\t}\n+\n+\treturn ret;\n }\n \n static int loongson_laptop_get_brightness(struct backlight_device *bd)\n@@ -384,7 +409,7 @@ static const struct backlight_ops backlight_laptop_ops = {\n \n static int laptop_backlight_register(void)\n {\n-\tint status = 0;\n+\tint status = 0, ret;\n \tstruct backlight_properties props;\n \n \tmemset(&props, 0, sizeof(props));\n@@ -392,44 +417,20 @@ static int laptop_backlight_register(void)\n \tif (!acpi_evalf(hotkey_handle, &status, \"ECLL\", \"d\"))\n \t\treturn -EIO;\n \n+\tret = ec_backlight_set_power(true);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tbl_powered = true;\n+\n \tprops.max_brightness = status;\n \tprops.brightness = ec_get_brightness();\n+\tprops.power = BACKLIGHT_POWER_ON;\n \tprops.type = BACKLIGHT_PLATFORM;\n \n \tbacklight_device_register(\"loongson_laptop\",\n \t\t\t\tNULL, NULL, &backlight_laptop_ops, &props);\n \n-\treturn 0;\n-}\n-\n-int loongson_laptop_turn_on_backlight(void)\n-{\n-\tint status;\n-\tunion acpi_object arg0 = { ACPI_TYPE_INTEGER };\n-\tstruct acpi_object_list args = { 1, &arg0 };\n-\n-\targ0.integer.value = 1;\n-\tstatus = acpi_evaluate_object(NULL, \"\\\\BLSW\", &args, NULL);\n-\tif (ACPI_FAILURE(status)) {\n-\t\tpr_info(\"Loongson lvds error: 0x%x\\n\", status);\n-\t\treturn -ENODEV;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-int loongson_laptop_turn_off_backlight(void)\n-{\n-\tint status;\n-\tunion acpi_object arg0 = { ACPI_TYPE_INTEGER };\n-\tstruct acpi_object_list args = { 1, &arg0 };\n-\n-\targ0.integer.value = 0;\n-\tstatus = acpi_evaluate_object(NULL, \"\\\\BLSW\", &args, NULL);\n-\tif (ACPI_FAILURE(status)) {\n-\t\tpr_info(\"Loongson lvds error: 0x%x\\n\", status);\n-\t\treturn -ENODEV;\n-\t}\n \n \treturn 0;\n }",405 "prediction": "Given the following original C code:\nstruct platform_driver *driver;\n\tint (*init)(struct generic_sub_driver *sub_driver);\n\tvoid (*notify)(struct generic_sub_driver *sub_driver, u32 event);\n\tu8 acpi_notify_installed;\n};\n\nstatic u32 input_device_registered;\nstatic struct input_dev *generic_inputdev;\n\nstatic acpi_handle hotkey_handle;\nstatic struct key_entry hotkey_keycode_map[GENERIC_HOTKEY_MAP_MAX];\n\nint loongson_laptop_turn_on_backlight(void);\nint loongson_laptop_turn_off_backlight(void);\nstatic int loongson_laptop_backlight_update(struct backlight_device *bd);\n\n/* 2. ACPI Helpers and device model */\n\nstatic int acpi_evalf(acpi_handle handle, int *res, char *method, char *fmt, ...)\n{\n\nInstruction:\nplatform/loongarch: laptop: Add backlight power control support\n\nReturn the diff that fixes it:\n @@ -106,7 +106,7 @@ static struct input_dev *generic_inputdev;\n static acpi_handle hotkey_handle;\n static struct key_entry hotkey_keycode_map[GENERIC_HOTKEY_MAP_MAX];\n \n-int loongson_laptop_turn_on_backlight(void);\n+int loongson_laptop_turn_on_backlight(struct backlight_device *bd);\n int loongson_laptop_turn_off_backlight(void);\n static int loongson_laptop_backlight_update(struct backlight_device *bd);\n \n@@ -114,7 +114,7 @@ static int acpi_evalf(acpi_handle handle, int *res, char *method, char *fmt,\n static int acpi_evalf(acpi_handle handle, int *res, char *method, char *fmt, ...)\n {\n \tva_list args;\n-\tstruct acpi_object_list params;\n+\tstruct acpi_object_list"406 },407 {408 "prompt": "Given the following original C code:\nif (acpi_evalf(hotkey_handle, &status, \"ECBG\", \"d\")) {\n\t\tpr_info(\"Loongson Laptop used, init brightness is 0x%x\\n\", status);\n\t\tret = laptop_backlight_register();\n\t\tif (ret < 0)\n\t\t\tpr_err(\"Loongson Laptop: laptop-backlight device register failed\\n\");\n\t}\n\n\treturn 0;\n}\n\nstatic void __exit generic_acpi_laptop_exit(void)\n{\n\tif (generic_inputdev) {\n\t\tif (input_device_registered)\n\t\t\tinput_unregister_device(generic_inputdev);\n\t\telse\n\t\t\tinput_free_device(generic_inputdev);\n\t}\n}\n\nInstruction:\nplatform/loongarch: laptop: Unregister generic_sub_drivers on exit\n\nReturn the diff that fixes it:\n",409 "reference": "@@ -612,11 +612,17 @@ static int __init generic_acpi_laptop_init(void)\n \n static void __exit generic_acpi_laptop_exit(void)\n {\n+\tint i;\n+\n \tif (generic_inputdev) {\n-\t\tif (input_device_registered)\n-\t\t\tinput_unregister_device(generic_inputdev);\n-\t\telse\n+\t\tif (!input_device_registered) {\n \t\t\tinput_free_device(generic_inputdev);\n+\t\t} else {\n+\t\t\tinput_unregister_device(generic_inputdev);\n+\n+\t\t\tfor (i = 0; i < ARRAY_SIZE(generic_sub_drivers); i++)\n+\t\t\t\tgeneric_subdriver_exit(&generic_sub_drivers[i]);\n+\t\t}\n \t}\n }",410 "prediction": "Given the following original C code:\nif (acpi_evalf(hotkey_handle, &status, \"ECBG\", \"d\")) {\n\t\tpr_info(\"Loongson Laptop used, init brightness is 0x%x\\n\", status);\n\t\tret = laptop_backlight_register();\n\t\tif (ret < 0)\n\t\t\tpr_err(\"Loongson Laptop: laptop-backlight device register failed\\n\");\n\t}\n\n\treturn 0;\n}\n\nstatic void __exit generic_acpi_laptop_exit(void)\n{\n\tif (generic_inputdev) {\n\t\tif (input_device_registered)\n\t\t\tinput_unregister_device(generic_inputdev);\n\t\telse\n\t\t\tinput_free_device(generic_inputdev);\n\t}\n}\n\nInstruction:\nplatform/loongarch: laptop: Unregister generic_sub_drivers on exit\n\nReturn the diff that fixes it:\n @@ -100,10 +100,10 @@ static int __init generic_acpi_laptop_init(void)\n }\n \n static void __exit generic_acpi_laptop_exit(void)\n+{\n \tif (generic_inputdev) {\n-\t\tif (input_device_registered)\n-\t\t\tinput_unregister_device(generic_inputdev);\n-\t\telse\n+\t\tif (input_device_registered)\n+\t\t\tinput_unregister_device(generic_inputdev);\n+\t\telse\n \t\t\tinput_free_device(generic_inputdev);\n \t}\n }\n@@ -113,6 +113,7 @@ module_init(generic_acpi_laptop_init);\n module_exit(generic_acpi_laptop_exit);\n MODULE_LICENSE(\"GPL\");\n MODULE_DESCRIPTION(\"Generic ACPI Laptop Driver\");\n+MODULE_ALIAS(\"platform:generic-laptop\");"411 },412 {413 "prompt": "Given the following original C code:\nfree_mnt_ns(ns);\n}\n\nvoid drop_collected_mounts(struct vfsmount *mnt)\n{\n\tnamespace_lock();\n\tlock_mount_hash();\n\tumount_tree(real_mount(mnt), 0);\n\tunlock_mount_hash();\n\tnamespace_unlock();\n}\n\nbool has_locked_children(struct mount *mnt, struct dentry *dentry)\n{\n\tstruct mount *child;\n\n\tlist_for_each_entry(child, &mnt->mnt_mounts, mnt_child) {\n\t\tif (!is_subdir(child->mnt_mountpoint, dentry))\n\t\t\tcontinue;\n\nInstruction:\nfs/fhandle.c: fix a race in call of has_locked_children()\n\nReturn the diff that fixes it:\n",414 "reference": "@@ -2425,7 +2425,7 @@ void drop_collected_mounts(struct vfsmount *mnt)\n \tnamespace_unlock();\n }\n \n-bool has_locked_children(struct mount *mnt, struct dentry *dentry)\n+static bool __has_locked_children(struct mount *mnt, struct dentry *dentry)\n {\n \tstruct mount *child;\n \n@@ -2439,6 +2439,16 @@ bool has_locked_children(struct mount *mnt, struct dentry *dentry)\n \treturn false;\n }\n \n+bool has_locked_children(struct mount *mnt, struct dentry *dentry)\n+{\n+\tbool res;\n+\n+\tread_seqlock_excl(&mount_lock);\n+\tres = __has_locked_children(mnt, dentry);\n+\tread_sequnlock_excl(&mount_lock);\n+\treturn res;\n+}\n+\n /*\n * Check that there aren't references to earlier/same mount namespaces in the\n * specified subtree. Such references can act as pins for mount namespaces\n@@ -2499,7 +2509,7 @@ struct vfsmount *clone_private_mount(const struct path *path)\n \t\t\treturn ERR_PTR(-EINVAL);\n \t}\n \n-\tif (has_locked_children(old_mnt, path->dentry))\n+\tif (__has_locked_children(old_mnt, path->dentry))\n \t\treturn ERR_PTR(-EINVAL);\n \n \tnew_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);\n@@ -3036,7 +3046,7 @@ static struct mount *__do_loopback(struct path *old_path, int recurse)\n \tif (!may_copy_tree(old_path))\n \t\treturn mnt;\n \n-\tif (!recurse && has_locked_children(old, old_path->dentry))\n+\tif (!recurse && __has_locked_children(old, old_path->dentry))\n \t\treturn mnt;\n \n \tif (recurse)\n@@ -3429,7 +3439,7 @@ static int do_set_group(struct path *from_path, struct path *to_path)\n \t\tgoto out;\n \n \t/* From mount should not have locked children in place of To's root */\n-\tif (has_locked_children(from, to->mnt.mnt_root))\n+\tif (__has_locked_children(from, to->mnt.mnt_root))\n \t\tgoto out;\n \n \t/* Setting sharing groups is only allowed on private mounts */",415 "prediction": "Given the following original C code:\nfree_mnt_ns(ns);\n}\n\nvoid drop_collected_mounts(struct vfsmount *mnt)\n{\n\tnamespace_lock();\n\tlock_mount_hash();\n\tumount_tree(real_mount(mnt), 0);\n\tunlock_mount_hash();\n\tnamespace_unlock();\n}\n\nbool has_locked_children(struct mount *mnt, struct dentry *dentry)\n{\n\tstruct mount *child;\n\n\tlist_for_each_entry(child, &mnt->mnt_mounts, mnt_child) {\n\t\tif (!is_subdir(child->mnt_mountpoint, dentry))\n\t\t\tcontinue;\n\nInstruction:\nfs/fhandle.c: fix a race in call of has_locked_children()\n\nReturn the diff that fixes it:\n @@ -100,10 +100,11 @@ void drop_collected_mounts(struct vfsmount *mnt)\n \tnamespace_unlock();\n }\n \n-bool has_locked_children(struct mount *mnt, struct dentry *dentry)\n+static bool has_locked_children(struct mount *mnt, struct dentry *dentry)\n {\n-\tstruct mount *child;\n+\tstruct mount *child, *p;\n \n-\tlist_for_each_entry(child, &mnt->mnt_mounts, mnt_child) {\n+\tlist_for_each_entry_safe(child, p, &mnt->mnt_mounts, mnt_child) {\n \t\tif (!is_subdir(child->mnt_mountpoint, dentry))\n \t\t\tcontinue;\n \t\tif (has_locked_children(child, dentry))\n@@ -113,7 +114,7 @@ bool has_locked_children(struct mount *mnt, struct d"416 },417 {418 "prompt": "Given the following original C code:\nout:\n\tnamespace_unlock();\n\treturn err;\n}\n\n/**\n * path_overmounted - check if path is overmounted\n * @path: path to check\n *\n * Check if path is overmounted, i.e., if there's a mount on top of\n * @path->mnt with @path->dentry as mountpoint.\n *\n * Context: This function expects namespace_lock() to be held.\n * Return: If path is overmounted true is returned, false if not.\n */\nstatic inline bool path_overmounted(const struct path *path)\n{\n\trcu_read_lock();\n\tif (unlikely(__lookup_mnt(path->mnt, path->dentry))) {\n\t\trcu_read_unlock();\n\nInstruction:\npath_overmount(): avoid false negatives\n\nReturn the diff that fixes it:\n",419 "reference": "@@ -3478,18 +3478,25 @@ static int do_set_group(struct path *from_path, struct path *to_path)\n * Check if path is overmounted, i.e., if there's a mount on top of\n * @path->mnt with @path->dentry as mountpoint.\n *\n- * Context: This function expects namespace_lock() to be held.\n+ * Context: namespace_sem must be held at least shared.\n+ * MUST NOT be called under lock_mount_hash() (there one should just\n+ * call __lookup_mnt() and check if it returns NULL).\n * Return: If path is overmounted true is returned, false if not.\n */\n static inline bool path_overmounted(const struct path *path)\n {\n+\tunsigned seq = read_seqbegin(&mount_lock);\n+\tbool no_child;\n+\n \trcu_read_lock();\n-\tif (unlikely(__lookup_mnt(path->mnt, path->dentry))) {\n-\t\trcu_read_unlock();\n-\t\treturn true;\n-\t}\n+\tno_child = !__lookup_mnt(path->mnt, path->dentry);\n \trcu_read_unlock();\n-\treturn false;\n+\tif (need_seqretry(&mount_lock, seq)) {\n+\t\tread_seqlock_excl(&mount_lock);\n+\t\tno_child = !__lookup_mnt(path->mnt, path->dentry);\n+\t\tread_sequnlock_excl(&mount_lock);\n+\t}\n+\treturn unlikely(!no_child);\n }\n \n /**",420 "prediction": "Given the following original C code:\nout:\n\tnamespace_unlock();\n\treturn err;\n}\n\n/**\n * path_overmounted - check if path is overmounted\n * @path: path to check\n *\n * Check if path is overmounted, i.e., if there's a mount on top of\n * @path->mnt with @path->dentry as mountpoint.\n *\n * Context: This function expects namespace_lock() to be held.\n * Return: If path is overmounted true is returned, false if not.\n */\nstatic inline bool path_overmounted(const struct path *path)\n{\n\trcu_read_lock();\n\tif (unlikely(__lookup_mnt(path->mnt, path->dentry))) {\n\t\trcu_read_unlock();\n\nInstruction:\npath_overmount(): avoid false negatives\n\nReturn the diff that fixes it:\n @@ -100,13 +100,13 @@ static int __path_lookup(const char *name, struct path *path)\n * Check if path is overmounted, i.e., if there's a mount on top of\n * @path->mnt with @path->dentry as mountpoint.\n *\n- * Context: This function expects namespace_lock() to be held.\n+ * Context: namespace_lock must be held.\n * Return: If path is overmounted true is returned, false if not.\n */\n static inline bool path_overmounted(const struct path *path)\n {\n-\trcu_read_lock();\n+\trcu_read_lock_sched();\n \tif (unlikely(__lookup_mnt(path->mnt, path->dentry))) {\n-\t\trcu_read_unlock();\n+\t\trcu_read_unlock_sched();\n \t\treturn true;\n \t}\n-\trcu_read_unlock();\n+\trcu_read_unlock_"421 },422 {423 "prompt": "Given the following original C code:\n* mount becomes shared. Currently, this is only the flag that says a\n\t * mount cannot be bind mounted, since this is how we create a mount\n\t * that shares events with another mount. If you add a new MNT_*\n\t * flag, consider how it interacts with shared mounts.\n\t */\n\tMNT_SHARED_MASK\t= MNT_UNBINDABLE,\n\tMNT_USER_SETTABLE_MASK = MNT_NOSUID | MNT_NODEV | MNT_NOEXEC\n\t\t\t\t | MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME\n\t\t\t\t | MNT_READONLY | MNT_NOSYMFOLLOW,\n\tMNT_ATIME_MASK = MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME,\n\n\tMNT_INTERNAL_FLAGS = MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL |\n\t\t\t MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED,\n};\n\nstruct vfsmount {\n\tstruct dentry *mnt_root;\t/* root of the mounted tree */\n\tstruct super_block *mnt_sb;\t/* pointer to superblock */\n\tint mnt_flags;\n\tstruct mnt_idmap *mnt_idmap;\n\nInstruction:\nfinish_automount(): don't leak MNT_LOCKED from parent to child\n\nReturn the diff that fixes it:\n",424 "reference": "@@ -65,7 +65,8 @@ enum mount_flags {\n \tMNT_ATIME_MASK = MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME,\n \n \tMNT_INTERNAL_FLAGS = MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL |\n-\t\t\t MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED,\n+\t\t\t MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED |\n+\t\t\t MNT_LOCKED,\n };\n \n struct vfsmount {",425 "prediction": "Given the following original C code:\n* mount becomes shared. Currently, this is only the flag that says a\n\t * mount cannot be bind mounted, since this is how we create a mount\n\t * that shares events with another mount. If you add a new MNT_*\n\t * flag, consider how it interacts with shared mounts.\n\t */\n\tMNT_SHARED_MASK\t= MNT_UNBINDABLE,\n\tMNT_USER_SETTABLE_MASK = MNT_NOSUID | MNT_NODEV | MNT_NOEXEC\n\t\t\t\t | MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME\n\t\t\t\t | MNT_READONLY | MNT_NOSYMFOLLOW,\n\tMNT_ATIME_MASK = MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME,\n\n\tMNT_INTERNAL_FLAGS = MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL |\n\t\t\t MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED,\n};\n\nstruct vfsmount {\n\tstruct dentry *mnt_root;\t/* root of the mounted tree */\n\tstruct super_block *mnt_sb;\t/* pointer to superblock */\n\tint mnt_flags;\n\tstruct mnt_idmap *mnt_idmap;\n\nInstruction:\nfinish_automount(): don't leak MNT_LOCKED from parent to child\n\nReturn the diff that fixes it:\n @@ -108,6 +108,7 @@ enum {\n \tMNT_ATIME_MASK = MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME,\n \n \tMNT_INTERNAL_FLAGS = MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL |\n+\t\t\t MNT_LOCKED |\n \t\t\t MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED,\n };\n \n@@ -116,6 +117,7 @@ struct vfsmount {\n \tstruct dentry *mnt_root;\t/* root of the mounted tree */\n \tstruct super_block *mnt_sb;\t/* pointer to superblock */\n \tint mnt_flags;\n+\tint mnt_count;\n \tstruct mnt_idmap *mnt_idmap;\n \tstruct hlist_node mnt_hash;\n \tstruct list_head m"426 },427 {428 "prompt": "Given the following original C code:\n/* Setting sharing groups is only allowed on private mounts */\n\tif (IS_MNT_SHARED(to) || IS_MNT_SLAVE(to))\n\t\tgoto out;\n\n\t/* From should not be private */\n\tif (!IS_MNT_SHARED(from) && !IS_MNT_SLAVE(from))\n\t\tgoto out;\n\n\tif (IS_MNT_SLAVE(from)) {\n\t\tstruct mount *m = from->mnt_master;\n\n\t\tlist_add(&to->mnt_slave, &m->mnt_slave_list);\n\t\tto->mnt_master = m;\n\t}\n\n\tif (IS_MNT_SHARED(from)) {\n\t\tto->mnt_group_id = from->mnt_group_id;\n\t\tlist_add(&to->mnt_share, &from->mnt_share);\n\t\tlock_mount_hash();\n\nInstruction:\nfix propagation graph breakage by MOVE_MOUNT_SET_GROUP move_mount(2)\n\nReturn the diff that fixes it:\n",429 "reference": "@@ -3453,7 +3453,7 @@ static int do_set_group(struct path *from_path, struct path *to_path)\n \tif (IS_MNT_SLAVE(from)) {\n \t\tstruct mount *m = from->mnt_master;\n \n-\t\tlist_add(&to->mnt_slave, &m->mnt_slave_list);\n+\t\tlist_add(&to->mnt_slave, &from->mnt_slave);\n \t\tto->mnt_master = m;\n \t}",430 "prediction": "Given the following original C code:\n/* Setting sharing groups is only allowed on private mounts */\n\tif (IS_MNT_SHARED(to) || IS_MNT_SLAVE(to))\n\t\tgoto out;\n\n\t/* From should not be private */\n\tif (!IS_MNT_SHARED(from) && !IS_MNT_SLAVE(from))\n\t\tgoto out;\n\n\tif (IS_MNT_SLAVE(from)) {\n\t\tstruct mount *m = from->mnt_master;\n\n\t\tlist_add(&to->mnt_slave, &m->mnt_slave_list);\n\t\tto->mnt_master = m;\n\t}\n\n\tif (IS_MNT_SHARED(from)) {\n\t\tto->mnt_group_id = from->mnt_group_id;\n\t\tlist_add(&to->mnt_share, &from->mnt_share);\n\t\tlock_mount_hash();\n\nInstruction:\nfix propagation graph breakage by MOVE_MOUNT_SET_GROUP move_mount(2)\n\nReturn the diff that fixes it:\n @@ -105,6 +105,11 @@ int move_mount(struct mount *from, struct mount *to)\n \tif (IS_MNT_SLAVE(from)) {\n \t\tstruct mount *m = from->mnt_master;\n \n+\t\t/*\n+\t\t * If we're moving a slave mount to a new master,\n+\t\t * we need to remove it from the old master's\n+\t\t * slave list.\n+\t\t */\n+\t\tlist_del_init(&to->mnt_slave);\n \t\tlist_add(&to->mnt_slave, &m->mnt_slave_list);\n \t\tto->mnt_master = m;\n \t}\n@@ -113,6 +118,11 @@ int move_mount(struct mount *from, struct mount *to)\n \tif (IS_MNT_SHARED(from)) {\n \t\tto->mnt_group_id = from->mnt_group_id;"431 },432 {433 "prompt": "Given the following original C code:\n* Release with mntput().\n */\nstruct vfsmount *clone_private_mount(const struct path *path)\n{\n\tstruct mount *old_mnt = real_mount(path->mnt);\n\tstruct mount *new_mnt;\n\n\tguard(rwsem_read)(&namespace_sem);\n\n\tif (IS_MNT_UNBINDABLE(old_mnt))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tif (mnt_has_parent(old_mnt)) {\n\t\tif (!check_mnt(old_mnt))\n\t\t\treturn ERR_PTR(-EINVAL);\n\t} else {\n\t\tif (!is_mounted(&old_mnt->mnt))\n\t\t\treturn ERR_PTR(-EINVAL);\n\n\t\t/* Make sure this isn't something purely kernel internal. */\n\nInstruction:\nfs: allow clone_private_mount() for a path on real rootfs\n\nReturn the diff that fixes it:\n",434 "reference": "@@ -2493,18 +2493,19 @@ struct vfsmount *clone_private_mount(const struct path *path)\n \tif (IS_MNT_UNBINDABLE(old_mnt))\n \t\treturn ERR_PTR(-EINVAL);\n \n-\tif (mnt_has_parent(old_mnt)) {\n-\t\tif (!check_mnt(old_mnt))\n-\t\t\treturn ERR_PTR(-EINVAL);\n-\t} else {\n-\t\tif (!is_mounted(&old_mnt->mnt))\n-\t\t\treturn ERR_PTR(-EINVAL);\n-\n-\t\t/* Make sure this isn't something purely kernel internal. */\n-\t\tif (!is_anon_ns(old_mnt->mnt_ns))\n+\t/*\n+\t * Make sure the source mount is acceptable.\n+\t * Anything mounted in our mount namespace is allowed.\n+\t * Otherwise, it must be the root of an anonymous mount\n+\t * namespace, and we need to make sure no namespace\n+\t * loops get created.\n+\t */\n+\tif (!check_mnt(old_mnt)) {\n+\t\tif (!is_mounted(&old_mnt->mnt) ||\n+\t\t\t!is_anon_ns(old_mnt->mnt_ns) ||\n+\t\t\tmnt_has_parent(old_mnt))\n \t\t\treturn ERR_PTR(-EINVAL);\n \n-\t\t/* Make sure we don't create mount namespace loops. */\n \t\tif (!check_for_nsfs_mounts(old_mnt))\n \t\t\treturn ERR_PTR(-EINVAL);\n \t}",435 "prediction": "Given the following original C code:\n* Release with mntput().\n */\nstruct vfsmount *clone_private_mount(const struct path *path)\n{\n\tstruct mount *old_mnt = real_mount(path->mnt);\n\tstruct mount *new_mnt;\n\n\tguard(rwsem_read)(&namespace_sem);\n\n\tif (IS_MNT_UNBINDABLE(old_mnt))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tif (mnt_has_parent(old_mnt)) {\n\t\tif (!check_mnt(old_mnt))\n\t\t\treturn ERR_PTR(-EINVAL);\n\t} else {\n\t\tif (!is_mounted(&old_mnt->mnt))\n\t\t\treturn ERR_PTR(-EINVAL);\n\n\t\t/* Make sure this isn't something purely kernel internal. */\n\nInstruction:\nfs: allow clone_private_mount() for a path on real rootfs\n\nReturn the diff that fixes it:\n @@ -100,10 +100,10 @@ struct vfsmount *clone_private_mount(const struct path *path)\n \tif (IS_MNT_UNBINDABLE(old_mnt))\n \t\treturn ERR_PTR(-EINVAL);\n \n-\tif (mnt_has_parent(old_mnt)) {\n-\t\tif (!check_mnt(old_mnt))\n-\t\t\treturn ERR_PTR(-EINVAL);\n-\t} else {\n+\tif (!mnt_has_parent(old_mnt)) {\n+\t\tif (!check_mnt(old_mnt))\n+\t\t\treturn ERR_PTR(-EINVAL);\n+\t} else {\n \t\tif (!is_mounted(&old_mnt->mnt))\n \t\t\treturn ERR_PTR(-EINVAL);\n \n@@ -113,6 +113,10 @@ struct vfsmount *clone_private_mount(const struct path *path)"436 },437 {438 "prompt": "Given the following original C code:\nreturn PTR_ERR(mp);\n\n\told = real_mount(old_path->mnt);\n\tp = real_mount(new_path->mnt);\n\tparent = old->mnt_parent;\n\tattached = mnt_has_parent(old);\n\tif (attached)\n\t\tflags |= MNT_TREE_MOVE;\n\told_mp = old->mnt_mp;\n\tns = old->mnt_ns;\n\n\terr = -EINVAL;\n\tif (!may_use_mount(p))\n\t\tgoto out;\n\n\t/* The thing moved must be mounted... */\n\tif (!is_mounted(&old->mnt))\n\t\tgoto out;\n\n\t/* ... and either ours or the root of anon namespace */\n\nInstruction:\ndo_move_mount(): split the checks in subtree-of-our-ns and entire-anon cases\n\nReturn the diff that fixes it:\n",439 "reference": "@@ -3656,37 +3656,41 @@ static int do_move_mount(struct path *old_path,\n \tns = old->mnt_ns;\n \n \terr = -EINVAL;\n-\tif (!may_use_mount(p))\n-\t\tgoto out;\n-\n \t/* The thing moved must be mounted... */\n \tif (!is_mounted(&old->mnt))\n \t\tgoto out;\n \n-\t/* ... and either ours or the root of anon namespace */\n-\tif (!(attached ? check_mnt(old) : is_anon_ns(ns)))\n-\t\tgoto out;\n-\n-\tif (is_anon_ns(ns) && ns == p->mnt_ns) {\n+\tif (check_mnt(old)) {\n+\t\t/* if the source is in our namespace... */\n+\t\t/* ... it should be detachable from parent */\n+\t\tif (!mnt_has_parent(old) || IS_MNT_LOCKED(old))\n+\t\t\tgoto out;\n+\t\t/* ... and the target should be in our namespace */\n+\t\tif (!check_mnt(p))\n+\t\t\tgoto out;\n+\t} else {\n \t\t/*\n-\t\t * Ending up with two files referring to the root of the\n-\t\t * same anonymous mount namespace would cause an error\n-\t\t * as this would mean trying to move the same mount\n-\t\t * twice into the mount tree which would be rejected\n-\t\t * later. But be explicit about it right here.\n+\t\t * otherwise the source must be the root of some anon namespace.\n+\t\t * AV: check for mount being root of an anon namespace is worth\n+\t\t * an inlined predicate...\n \t\t */\n-\t\tgoto out;\n-\t} else if (is_anon_ns(p->mnt_ns)) {\n+\t\tif (!is_anon_ns(ns) || mnt_has_parent(old))\n+\t\t\tgoto out;\n \t\t/*\n-\t\t * Don't allow moving an attached mount tree to an\n-\t\t * anonymous mount tree.\n+\t\t * Bail out early if the target is within the same namespace -\n+\t\t * subsequent checks would've rejected that, but they lose\n+\t\t * some corner cases if we check it early.\n \t\t */\n-\t\tgoto out;\n+\t\tif (ns == p->mnt_ns)\n+\t\t\tgoto out;\n+\t\t/*\n+\t\t * Target should be either in our namespace or in an acceptable\n+\t\t * anon namespace, sensu check_anonymous_mnt().\n+\t\t */\n+\t\tif (!may_use_mount(p))\n+\t\t\tgoto out;\n \t}\n \n-\tif (old->mnt.mnt_flags & MNT_LOCKED)\n-\t\tgoto out;\n-\n \tif (!path_mounted(old_path))\n \t\tgoto out;",440 "prediction": "Given the following original C code:\nreturn PTR_ERR(mp);\n\n\told = real_mount(old_path->mnt);\n\tp = real_mount(new_path->mnt);\n\tparent = old->mnt_parent;\n\tattached = mnt_has_parent(old);\n\tif (attached)\n\t\tflags |= MNT_TREE_MOVE;\n\told_mp = old->mnt_mp;\n\tns = old->mnt_ns;\n\n\terr = -EINVAL;\n\tif (!may_use_mount(p))\n\t\tgoto out;\n\n\t/* The thing moved must be mounted... */\n\tif (!is_mounted(&old->mnt))\n\t\tgoto out;\n\n\t/* ... and either ours or the root of anon namespace */\n\nInstruction:\ndo_move_mount(): split the checks in subtree-of-our-ns and entire-anon cases\n\nReturn the diff that fixes it:\n @@ -100,11 +100,11 @@ int do_move_mount(const struct path *old_path, const struct path *new_path)\n \told_mp = old->mnt_mp;\n \tns = old->mnt_ns;\n \n-\terr = -EINVAL;\n-\tif (!may_use_mount(p))\n-\t\tgoto out;\n-\n \t/* The thing moved must be mounted... */\n \tif (!is_mounted(&old->mnt))\n \t\tgoto out;\n \n+\terr = -EINVAL;\n+\tif (!may_use_mount(p))\n+\t\tgoto out;\n+\n \t/* ... and either ours or the root of anon namespace */\n \tif (ns != current->nsproxy->mnt_ns && ns != &init_ns)\n \t\tgoto out;\n@@ -115,11 +115,11 @@ int do_move_mount(const struct path *old_path, const struct path *new"441 },442 {443 "prompt": "Given the following original C code:\n* loops get created.\n\t */\n\tif (!check_mnt(old_mnt)) {\n\t\tif (!is_mounted(&old_mnt->mnt) ||\n\t\t\t!is_anon_ns(old_mnt->mnt_ns) ||\n\t\t\tmnt_has_parent(old_mnt))\n\t\t\treturn ERR_PTR(-EINVAL);\n\n\t\tif (!check_for_nsfs_mounts(old_mnt))\n\t\t\treturn ERR_PTR(-EINVAL);\n\t}\n\n\tif (__has_locked_children(old_mnt, path->dentry))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tnew_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);\n\tif (IS_ERR(new_mnt))\n\t\treturn ERR_PTR(-EINVAL);\n\n\t/* Longterm mount to be removed by kern_unmount*() */\n\nInstruction:\nclone_private_mnt(): make sure that caller has CAP_SYS_ADMIN in the right userns\n\nReturn the diff that fixes it:\n",444 "reference": "@@ -2510,6 +2510,9 @@ struct vfsmount *clone_private_mount(const struct path *path)\n \t\t\treturn ERR_PTR(-EINVAL);\n \t}\n \n+ if (!ns_capable(old_mnt->mnt_ns->user_ns, CAP_SYS_ADMIN))\n+\t\treturn ERR_PTR(-EPERM);\n+\n \tif (__has_locked_children(old_mnt, path->dentry))\n \t\treturn ERR_PTR(-EINVAL);",445 "prediction": "Given the following original C code:\n* loops get created.\n\t */\n\tif (!check_mnt(old_mnt)) {\n\t\tif (!is_mounted(&old_mnt->mnt) ||\n\t\t\t!is_anon_ns(old_mnt->mnt_ns) ||\n\t\t\tmnt_has_parent(old_mnt))\n\t\t\treturn ERR_PTR(-EINVAL);\n\n\t\tif (!check_for_nsfs_mounts(old_mnt))\n\t\t\treturn ERR_PTR(-EINVAL);\n\t}\n\n\tif (__has_locked_children(old_mnt, path->dentry))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tnew_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);\n\tif (IS_ERR(new_mnt))\n\t\treturn ERR_PTR(-EINVAL);\n\n\t/* Longterm mount to be removed by kern_unmount*() */\n\nInstruction:\nclone_private_mnt(): make sure that caller has CAP_SYS_ADMIN in the right userns\n\nReturn the diff that fixes it:\n @@ -100,6 +100,10 @@ struct vfsmount *clone_private_mnt(const struct path *path)\n \t\t\treturn ERR_PTR(-EINVAL);\n \t}\n \n+\tif (!capable(CAP_SYS_ADMIN))\n+\t\treturn ERR_PTR(-EPERM);\n+\n+\n \tif (__has_locked_children(old_mnt, path->dentry))\n \t\treturn ERR_PTR(-EINVAL);\n \n@@ -108,6 +112,7 @@ struct vfsmount *clone_private_mnt(const struct path *path)\n \t\treturn ERR_PTR(-EINVAL);\n \n \t/* Longterm mount to be removed by kern_unmount*() */\n+\tnew_mnt->mnt_flags |= MNT_SYNCHRONOUS;\n \treturn new_mnt;\n }\n EXPORT_SYMBOL_GPL(clone_private_mnt);"446 },447 {448 "prompt": "Given the following original C code:\nint recurse = ms_flags & MS_REC;\n\tint type;\n\tint err = 0;\n\n\tif (!path_mounted(path))\n\t\treturn -EINVAL;\n\n\ttype = flags_to_propagation_type(ms_flags);\n\tif (!type)\n\t\treturn -EINVAL;\n\n\tnamespace_lock();\n\tif (type == MS_SHARED) {\n\t\terr = invent_group_ids(mnt, recurse);\n\t\tif (err)\n\t\t\tgoto out_unlock;\n\t}\n\n\tlock_mount_hash();\n\tfor (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))\n\nInstruction:\ndo_change_type(): refuse to operate on unmounted/not ours mounts\n\nReturn the diff that fixes it:\n",449 "reference": "@@ -2959,6 +2959,10 @@ static int do_change_type(struct path *path, int ms_flags)\n \t\treturn -EINVAL;\n \n \tnamespace_lock();\n+\tif (!check_mnt(mnt)) {\n+\t\terr = -EINVAL;\n+\t\tgoto out_unlock;\n+\t}\n \tif (type == MS_SHARED) {\n \t\terr = invent_group_ids(mnt, recurse);\n \t\tif (err)",450 "prediction": "Given the following original C code:\nint recurse = ms_flags & MS_REC;\n\tint type;\n\tint err = 0;\n\n\tif (!path_mounted(path))\n\t\treturn -EINVAL;\n\n\ttype = flags_to_propagation_type(ms_flags);\n\tif (!type)\n\t\treturn -EINVAL;\n\n\tnamespace_lock();\n\tif (type == MS_SHARED) {\n\t\terr = invent_group_ids(mnt, recurse);\n\t\tif (err)\n\t\t\tgoto out_unlock;\n\t}\n\n\tlock_mount_hash();\n\tfor (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))\n\nInstruction:\ndo_change_type(): refuse to operate on unmounted/not ours mounts\n\nReturn the diff that fixes it:\n @@ -106,6 +106,11 @@ int do_change_type(struct path *path, int flags)\n \t\treturn -EINVAL;\n \n \tnamespace_lock();\n+\tif (!path_mounted(path)) {\n+\t\terr = -EINVAL;\n+\t\tgoto out_unlock;\n+\t}\n+\n \tif (type == MS_SHARED) {\n \t\terr = invent_group_ids(mnt, recurse);\n \t\tif (err)\n@@ -114,6 +119,11 @@ int do_change_type(struct path *path, int flags)\n \t\tgoto out_unlock;\n \t}\n \n+\tif (!path_mounted(path)) {\n+\t\terr = -EINVAL;\n+\t\tgoto out_unlock;\n+\t}\n+\n \tlock_mount_hash();\n \tfor (m = mnt; m; m = (recurse ? next_mnt(m, m"451 },452 {453 "prompt": "Given the following original C code:\nreturn ((sym->type == SYM_STRUCT ||\n\t\t sym->type == SYM_UNION ||\n\t\t sym->type == SYM_ENUM) &&\n\t\t(defn = sym->defn) && defn->tag == SYM_NORMAL &&\n\t\t\tstrcmp(defn->string, \"}\") == 0 &&\n\t\t(defn = defn->next) && defn->tag == SYM_NORMAL &&\n\t\t\tstrcmp(defn->string, \"UNKNOWN\") == 0 &&\n\t\t(defn = defn->next) && defn->tag == SYM_NORMAL &&\n\t\t\tstrcmp(defn->string, \"{\") == 0);\n}\n\nstatic struct symbol *__add_symbol(const char *name, enum symbol_type type,\n\t\t\t struct string_list *defn, int is_extern,\n\t\t\t int is_reference)\n{\n\tunsigned long h;\n\tstruct symbol *sym;\n\tenum symbol_status status = STATUS_UNCHANGED;\n\t/* The parser adds symbols in the order their declaration completes,\n\nInstruction:\ngenksyms: Fix enum consts from a reference affecting new values\n\nReturn the diff that fixes it:\n",454 "reference": "@@ -181,13 +181,9 @@ static int is_unknown_symbol(struct symbol *sym)\n \t\t\tstrcmp(defn->string, \"{\") == 0);\n }\n \n-static struct symbol *__add_symbol(const char *name, enum symbol_type type,\n-\t\t\t struct string_list *defn, int is_extern,\n-\t\t\t int is_reference)\n+static struct string_list *process_enum(const char *name, enum symbol_type type,\n+\t\t\t\t\tstruct string_list *defn)\n {\n-\tunsigned long h;\n-\tstruct symbol *sym;\n-\tenum symbol_status status = STATUS_UNCHANGED;\n \t/* The parser adds symbols in the order their declaration completes,\n \t * so it is safe to store the value of the previous enum constant in\n \t * a static variable.\n@@ -216,7 +212,7 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,\n \t\t\t\tdefn = mk_node(buf);\n \t\t\t}\n \t\t}\n-\t} else if (type == SYM_ENUM) {\n+\t} else {\n \t\tfree_list(last_enum_expr, NULL);\n \t\tlast_enum_expr = NULL;\n \t\tenum_counter = 0;\n@@ -225,6 +221,23 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,\n \t\t\treturn NULL;\n \t}\n \n+\treturn defn;\n+}\n+\n+static struct symbol *__add_symbol(const char *name, enum symbol_type type,\n+\t\t\t struct string_list *defn, int is_extern,\n+\t\t\t int is_reference)\n+{\n+\tunsigned long h;\n+\tstruct symbol *sym;\n+\tenum symbol_status status = STATUS_UNCHANGED;\n+\n+\tif ((type == SYM_ENUM_CONST || type == SYM_ENUM) && !is_reference) {\n+\t\tdefn = process_enum(name, type, defn);\n+\t\tif (defn == NULL)\n+\t\t\treturn NULL;\n+\t}\n+\n \th = crc32(name);\n \thash_for_each_possible(symbol_hashtable, sym, hnode, h) {\n \t\tif (map_to_ns(sym->type) != map_to_ns(type) ||",455 "prediction": "Given the following original C code:\nreturn ((sym->type == SYM_STRUCT ||\n\t\t sym->type == SYM_UNION ||\n\t\t sym->type == SYM_ENUM) &&\n\t\t(defn = sym->defn) && defn->tag == SYM_NORMAL &&\n\t\t\tstrcmp(defn->string, \"}\") == 0 &&\n\t\t(defn = defn->next) && defn->tag == SYM_NORMAL &&\n\t\t\tstrcmp(defn->string, \"UNKNOWN\") == 0 &&\n\t\t(defn = defn->next) && defn->tag == SYM_NORMAL &&\n\t\t\tstrcmp(defn->string, \"{\") == 0);\n}\n\nstatic struct symbol *__add_symbol(const char *name, enum symbol_type type,\n\t\t\t struct string_list *defn, int is_extern,\n\t\t\t int is_reference)\n{\n\tunsigned long h;\n\tstruct symbol *sym;\n\tenum symbol_status status = STATUS_UNCHANGED;\n\t/* The parser adds symbols in the order their declaration completes,\n\nInstruction:\ngenksyms: Fix enum consts from a reference affecting new values\n\nReturn the diff that fixes it:\n @@ -101,6 +101,10 @@ static int is_struct_or_union(struct symbol *sym)\n \t\t\tstrcmp(defn->string, \"{\") == 0);\n }\n \n+static int is_enum_const(struct symbol *sym)\n+{\n+\treturn sym->type == SYM_ENUM_CONST;\n+}\n+\n static struct symbol *__add_symbol(const char *name, enum symbol_type type,\n \t\t\t struct string_list *defn, int is_extern,\n \t\t\t int is_reference)\n@@ -111,6 +115,10 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,\n \t\t\t struct string_list *defn, int is_extern,\n \t\t\t int is_reference)\n {\n+\tif (is_enum_const(sym))\n+\t\treturn sym;\n+\n \tsym->name = name;\n \tsym->type = type;"456 },457 {458 "prompt": "Given the following original C code:\nbreak;\n\t}\n\n\treturn 0;\n}\n\n/*\n * Wrapper routine to for handling exceptions.\n */\nint __kprobes kprobe_exceptions_notify(struct notifier_block *self,\n\t\t\t\t unsigned long val, void *data)\n{\n\tstruct kprobe *p = NULL;\n\tstruct die_args *args = (struct die_args *)data;\n\tint ret = NOTIFY_DONE;\n\tkprobe_opcode_t *addr = NULL;\n\tstruct kprobe_ctlblk *kcb = get_kprobe_ctlblk();\n\n\taddr = (kprobe_opcode_t *) (args->regs->pc);\n\tif (val == DIE_TRAP &&\n\nInstruction:\nsh: kprobes: Remove unused variables in kprobe_exceptions_notify()\n\nReturn the diff that fixes it:\n",459 "reference": "@@ -404,13 +404,10 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)\n int __kprobes kprobe_exceptions_notify(struct notifier_block *self,\n \t\t\t\t unsigned long val, void *data)\n {\n-\tstruct kprobe *p = NULL;\n \tstruct die_args *args = (struct die_args *)data;\n \tint ret = NOTIFY_DONE;\n-\tkprobe_opcode_t *addr = NULL;\n \tstruct kprobe_ctlblk *kcb = get_kprobe_ctlblk();\n \n-\taddr = (kprobe_opcode_t *) (args->regs->pc);\n \tif (val == DIE_TRAP &&\n \t args->trapnr == (BREAKPOINT_INSTRUCTION & 0xff)) {\n \t\tif (!kprobe_running()) {\n@@ -421,7 +418,6 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,\n \t\t\t\tret = NOTIFY_DONE;\n \t\t\t}\n \t\t} else {\n-\t\t\tp = get_kprobe(addr);\n \t\t\tif ((kcb->kprobe_status == KPROBE_HIT_SS) ||\n \t\t\t (kcb->kprobe_status == KPROBE_REENTER)) {\n \t\t\t\tif (post_kprobe_handler(args->regs))",460 "prediction": "Given the following original C code:\nbreak;\n\t}\n\n\treturn 0;\n}\n\n/*\n * Wrapper routine to for handling exceptions.\n */\nint __kprobes kprobe_exceptions_notify(struct notifier_block *self,\n\t\t\t\t unsigned long val, void *data)\n{\n\tstruct kprobe *p = NULL;\n\tstruct die_args *args = (struct die_args *)data;\n\tint ret = NOTIFY_DONE;\n\tkprobe_opcode_t *addr = NULL;\n\tstruct kprobe_ctlblk *kcb = get_kprobe_ctlblk();\n\n\taddr = (kprobe_opcode_t *) (args->regs->pc);\n\tif (val == DIE_TRAP &&\n\nInstruction:\nsh: kprobes: Remove unused variables in kprobe_exceptions_notify()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,6 @@ static int __kprobes kprobe_handler(struct kprobe *p, struct pt_regs *regs)\n int __kprobes kprobe_exceptions_notify(struct notifier_block *self,\n \t\t\t\t unsigned long val, void *data)\n {\n-\tstruct kprobe *p = NULL;\n \tstruct die_args *args = (struct die_args *)data;\n \tint ret = NOTIFY_DONE;\n \tkprobe_opcode_t *addr = NULL;\n@@ -116,10 +115,8 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,\n \taddr = (kprobe_opcode_t *) (args->regs->pc);\n \tif (val == DIE_TRAP &&\n \t (p = get_kprobe(addr)) != NULL) {\n-\t\tp = get_kprobe(addr);\n-"461 },462 {463 "prompt": "Given the following original C code:\n}\n\ttrace_seq_putc(s, 0);\n\tbuf = kmemdup_nul(s->buffer, s->seq.len, GFP_KERNEL);\n\tif (buf) {\n\t\tkfree(filter->filter_string);\n\t\tfilter->filter_string = buf;\n\t}\n\tkfree(s);\n}\n\nstatic inline struct event_filter *event_filter(struct trace_event_file *file)\n{\n\treturn file->filter;\n}\n\n/* caller must hold event_mutex */\nvoid print_event_filter(struct trace_event_file *file, struct trace_seq *s)\n{\n\tstruct event_filter *filter = event_filter(file);\n\nInstruction:\ntracing: Add rcu annotation around file->filter accesses\n\nReturn the diff that fixes it:\n",464 "reference": "@@ -1250,7 +1250,9 @@ static void append_filter_err(struct trace_array *tr,\n \n static inline struct event_filter *event_filter(struct trace_event_file *file)\n {\n-\treturn file->filter;\n+\treturn rcu_dereference_protected(file->filter,\n+\t\t\t\t\t lockdep_is_held(&event_mutex));\n+\n }\n \n /* caller must hold event_mutex */\n@@ -1320,7 +1322,7 @@ void free_event_filter(struct event_filter *filter)\n static inline void __remove_filter(struct trace_event_file *file)\n {\n \tfilter_disable(file);\n-\tremove_filter_string(file->filter);\n+\tremove_filter_string(event_filter(file));\n }\n \n static void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,\n@@ -1405,7 +1407,7 @@ static void try_delay_free_filter(struct event_filter *filter)\n \n static inline void __free_subsystem_filter(struct trace_event_file *file)\n {\n-\t__free_filter(file->filter);\n+\t__free_filter(event_filter(file));\n \tfile->filter = NULL;\n }\n \n@@ -1465,7 +1467,7 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,\n \tlist_for_each_entry(file, &tr->events, list) {\n \t\tif (file->system != dir || !file->filter)\n \t\t\tcontinue;\n-\t\t__free_filter(file->filter);\n+\t\t__free_subsystem_filter(file);\n \t}\n \t__free_filter(filter);\n }",465 "prediction": "Given the following original C code:\n}\n\ttrace_seq_putc(s, 0);\n\tbuf = kmemdup_nul(s->buffer, s->seq.len, GFP_KERNEL);\n\tif (buf) {\n\t\tkfree(filter->filter_string);\n\t\tfilter->filter_string = buf;\n\t}\n\tkfree(s);\n}\n\nstatic inline struct event_filter *event_filter(struct trace_event_file *file)\n{\n\treturn file->filter;\n}\n\n/* caller must hold event_mutex */\nvoid print_event_filter(struct trace_event_file *file, struct trace_seq *s)\n{\n\tstruct event_filter *filter = event_filter(file);\n\nInstruction:\ntracing: Add rcu annotation around file->filter accesses\n\nReturn the diff that fixes it:\n @@ -103,7 +103,7 @@ void free_event_filter(struct event_filter *filter)\n \n static inline struct event_filter *event_filter(struct trace_event_file *file)\n {\n-\treturn file->filter;\n+\treturn rcu_dereference(file->filter);\n }\n \n /* caller must hold event_mutex */\n@@ -112,7 +112,7 @@ void print_event_filter(struct trace_event_file *file, struct trace_seq *s)\n {\n \tstruct event_filter *filter = event_filter(file);\n \n-\tif (filter && filter->filter_string)\n+\tif (filter && rcu_access_pointer(filter->filter_string))\n \t\ttrace_seq_printf(s, \"%s\\n\", filter->filter_string);\n }\n \n@@ -121,7 +121,7 @@ void print_event_filters(struct trace_array *tr, struct trace_seq *s)\n {\n \tstruct trace"466 },467 {468 "prompt": "Given the following original C code:\nath10k_snoc_buffer_cleanup(ar);\n\tath10k_dbg(ar, ATH10K_DBG_BOOT, \"boot hif stop\\n\");\n}\n\nstatic int ath10k_snoc_hif_start(struct ath10k *ar)\n{\n\tstruct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);\n\n\tbitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX);\n\n\tdev_set_threaded(ar->napi_dev, true);\n\tath10k_core_napi_enable(ar);\n\tath10k_snoc_irq_enable(ar);\n\tath10k_snoc_rx_post(ar);\n\n\tclear_bit(ATH10K_SNOC_FLAG_RECOVERY, &ar_snoc->flags);\n\n\tath10k_dbg(ar, ATH10K_DBG_BOOT, \"boot hif start\\n\");\n\n\treturn 0;\n\nInstruction:\nath10k: snoc: fix unbalanced IRQ enable in crash recovery\n\nReturn the diff that fixes it:\n",469 "reference": "@@ -937,7 +937,9 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)\n \n \tdev_set_threaded(ar->napi_dev, true);\n \tath10k_core_napi_enable(ar);\n-\tath10k_snoc_irq_enable(ar);\n+\t/* IRQs are left enabled when we restart due to a firmware crash */\n+\tif (!test_bit(ATH10K_SNOC_FLAG_RECOVERY, &ar_snoc->flags))\n+\t\tath10k_snoc_irq_enable(ar);\n \tath10k_snoc_rx_post(ar);\n \n \tclear_bit(ATH10K_SNOC_FLAG_RECOVERY, &ar_snoc->flags);",470 "prediction": "Given the following original C code:\nath10k_snoc_buffer_cleanup(ar);\n\tath10k_dbg(ar, ATH10K_DBG_BOOT, \"boot hif stop\\n\");\n}\n\nstatic int ath10k_snoc_hif_start(struct ath10k *ar)\n{\n\tstruct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);\n\n\tbitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX);\n\n\tdev_set_threaded(ar->napi_dev, true);\n\tath10k_core_napi_enable(ar);\n\tath10k_snoc_irq_enable(ar);\n\tath10k_snoc_rx_post(ar);\n\n\tclear_bit(ATH10K_SNOC_FLAG_RECOVERY, &ar_snoc->flags);\n\n\tath10k_dbg(ar, ATH10K_DBG_BOOT, \"boot hif start\\n\");\n\n\treturn 0;\n\nInstruction:\nath10k: snoc: fix unbalanced IRQ enable in crash recovery\n\nReturn the diff that fixes it:\n @@ -108,7 +108,6 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)\n \n \tdev_set_threaded(ar->napi_dev, true);\n \tath10k_core_napi_enable(ar);\n-\tath10k_snoc_irq_enable(ar);\n \tath10k_snoc_rx_post(ar);\n \n \tclear_bit(ATH10K_SNOC_FLAG_RECOVERY, &ar_snoc->flags);\n@@ -116,7 +115,6 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)\n \n \tath10k_dbg(ar, ATH10K_DBG_BOOT, \"boot hif start\\n\");\n \n-\tath10k_snoc_irq_enable(ar);\n \treturn 0;\n }\n \n@@ -12"471 },472 {473 "prompt": "Given the following original C code:\n// SPDX-License-Identifier: ISC\n/*\n * Copyright (c) 2005-2011 Atheros Communications Inc.\n * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.\n * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n\n#include \"mac.h\"\n\n#include <net/cfg80211.h>\n#include <net/mac80211.h>\n#include <linux/etherdevice.h>\n#include <linux/acpi.h>\n\nInstruction:\nwifi: ath10k: Avoid vdev delete timeout when firmware is already down\n\nReturn the diff that fixes it:\n",474 "reference": "@@ -4,6 +4,7 @@\n * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.\n * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n */\n \n #include \"mac.h\"\n@@ -1022,6 +1023,26 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar)\n \treturn ar->last_wmi_vdev_start_status;\n }\n \n+static inline int ath10k_vdev_delete_sync(struct ath10k *ar)\n+{\n+\tunsigned long time_left;\n+\n+\tlockdep_assert_held(&ar->conf_mutex);\n+\n+\tif (!test_bit(WMI_SERVICE_SYNC_DELETE_CMDS, ar->wmi.svc_map))\n+\t\treturn 0;\n+\n+\tif (test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags))\n+\t\treturn -ESHUTDOWN;\n+\n+\ttime_left = wait_for_completion_timeout(&ar->vdev_delete_done,\n+\t\t\t\t\t\tATH10K_VDEV_DELETE_TIMEOUT_HZ);\n+\tif (time_left == 0)\n+\t\treturn -ETIMEDOUT;\n+\n+\treturn 0;\n+}\n+\n static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)\n {\n \tstruct cfg80211_chan_def *chandef = NULL;\n@@ -5900,7 +5921,6 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,\n \tstruct ath10k *ar = hw->priv;\n \tstruct ath10k_vif *arvif = (void *)vif->drv_priv;\n \tstruct ath10k_peer *peer;\n-\tunsigned long time_left;\n \tint ret;\n \tint i;\n \n@@ -5940,13 +5960,10 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,\n \t\tath10k_warn(ar, \"failed to delete WMI vdev %i: %d\\n\",\n \t\t\t arvif->vdev_id, ret);\n \n-\tif (test_bit(WMI_SERVICE_SYNC_DELETE_CMDS, ar->wmi.svc_map)) {\n-\t\ttime_left = wait_for_completion_timeout(&ar->vdev_delete_done,\n-\t\t\t\t\t\t\tATH10K_VDEV_DELETE_TIMEOUT_HZ);\n-\t\tif (time_left == 0) {\n-\t\t\tath10k_warn(ar, \"Timeout in receiving vdev delete response\\n\");\n-\t\t\tgoto out;\n-\t\t}\n+\tret = ath10k_vdev_delete_sync(ar);\n+\tif (ret) {\n+\t\tath10k_warn(ar, \"Error in receiving vdev delete response: %d\\n\", ret);\n+\t\tgoto out;\n \t}\n \n \t/* Some firmware revisions don't notify host about self-peer removal",475 "prediction": "Given the following original C code:\n// SPDX-License-Identifier: ISC\n/*\n * Copyright (c) 2005-2011 Atheros Communications Inc.\n * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.\n * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n\n#include \"mac.h\"\n\n#include <net/cfg80211.h>\n#include <net/mac80211.h>\n#include <linux/etherdevice.h>\n#include <linux/acpi.h>\n\nInstruction:\nwifi: ath10k: Avoid vdev delete timeout when firmware is already down\n\nReturn the diff that fixes it:\n @@ -3,7 +3,7 @@\n * Copyright (c) 2005-2011 Atheros Communications Inc.\n * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.\n * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.\n- * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n \n #include \"mac.h\"\n@@ -106,6 +106,10 @@ static void ath10k_mac_vdev_delete(struct ath10k_vif *arvif)\n \tath10k_dbg(ar, ATH10K_DBG_MAC, \"mac vdev %i delete\\n\", arvif->vdev_id);"476 },477 {478 "prompt": "Given the following original C code:\nwil_dbg_irq(wil, \"unmask_irq_pseudo\\n\");\n\n\tset_bit(wil_status_irqen, wil->status);\n\n\twil_w(wil, RGF_DMA_PSEUDO_CAUSE_MASK_SW, WIL6210_IRQ_PSEUDO_MASK);\n}\n\nvoid wil_mask_irq(struct wil6210_priv *wil)\n{\n\twil_dbg_irq(wil, \"mask_irq\\n\");\n\n\twil6210_mask_irq_tx(wil);\n\twil6210_mask_irq_tx_edma(wil);\n\twil6210_mask_irq_rx(wil);\n\twil6210_mask_irq_rx_edma(wil);\n\twil6210_mask_irq_misc(wil, true);\n\twil6210_mask_irq_pseudo(wil);\n}\n\nvoid wil_unmask_irq(struct wil6210_priv *wil)\n\nInstruction:\nwil6210: fix support for sparrow chipsets\n\nReturn the diff that fixes it:\n",479 "reference": "@@ -179,9 +179,11 @@ void wil_mask_irq(struct wil6210_priv *wil)\n \twil_dbg_irq(wil, \"mask_irq\\n\");\n \n \twil6210_mask_irq_tx(wil);\n-\twil6210_mask_irq_tx_edma(wil);\n+\tif (wil->use_enhanced_dma_hw)\n+\t\twil6210_mask_irq_tx_edma(wil);\n \twil6210_mask_irq_rx(wil);\n-\twil6210_mask_irq_rx_edma(wil);\n+\tif (wil->use_enhanced_dma_hw)\n+\t\twil6210_mask_irq_rx_edma(wil);\n \twil6210_mask_irq_misc(wil, true);\n \twil6210_mask_irq_pseudo(wil);\n }\n@@ -190,10 +192,12 @@ void wil_unmask_irq(struct wil6210_priv *wil)\n {\n \twil_dbg_irq(wil, \"unmask_irq\\n\");\n \n-\twil_w(wil, RGF_DMA_EP_RX_ICR + offsetof(struct RGF_ICR, ICC),\n-\t WIL_ICR_ICC_VALUE);\n-\twil_w(wil, RGF_DMA_EP_TX_ICR + offsetof(struct RGF_ICR, ICC),\n-\t WIL_ICR_ICC_VALUE);\n+\tif (wil->use_enhanced_dma_hw) {\n+\t\twil_w(wil, RGF_DMA_EP_RX_ICR + offsetof(struct RGF_ICR, ICC),\n+\t\t WIL_ICR_ICC_VALUE);\n+\t\twil_w(wil, RGF_DMA_EP_TX_ICR + offsetof(struct RGF_ICR, ICC),\n+\t\t WIL_ICR_ICC_VALUE);\n+\t}\n \twil_w(wil, RGF_DMA_EP_MISC_ICR + offsetof(struct RGF_ICR, ICC),\n \t WIL_ICR_ICC_MISC_VALUE);\n \twil_w(wil, RGF_INT_GEN_TX_ICR + offsetof(struct RGF_ICR, ICC),\n@@ -845,10 +849,12 @@ void wil6210_clear_irq(struct wil6210_priv *wil)\n \t\t offsetof(struct RGF_ICR, ICR));\n \twil_clear32(wil->csr + HOSTADDR(RGF_DMA_EP_TX_ICR) +\n \t\t offsetof(struct RGF_ICR, ICR));\n-\twil_clear32(wil->csr + HOSTADDR(RGF_INT_GEN_RX_ICR) +\n-\t\t offsetof(struct RGF_ICR, ICR));\n-\twil_clear32(wil->csr + HOSTADDR(RGF_INT_GEN_TX_ICR) +\n-\t\t offsetof(struct RGF_ICR, ICR));\n+\tif (wil->use_enhanced_dma_hw) {\n+\t\twil_clear32(wil->csr + HOSTADDR(RGF_INT_GEN_RX_ICR) +\n+\t\t\t offsetof(struct RGF_ICR, ICR));\n+\t\twil_clear32(wil->csr + HOSTADDR(RGF_INT_GEN_TX_ICR) +\n+\t\t\t offsetof(struct RGF_ICR, ICR));\n+\t}\n \twil_clear32(wil->csr + HOSTADDR(RGF_DMA_EP_MISC_ICR) +\n \t\t offsetof(struct RGF_ICR, ICR));\n \twmb(); /* make sure write completed */",480 "prediction": "Given the following original C code:\nwil_dbg_irq(wil, \"unmask_irq_pseudo\\n\");\n\n\tset_bit(wil_status_irqen, wil->status);\n\n\twil_w(wil, RGF_DMA_PSEUDO_CAUSE_MASK_SW, WIL6210_IRQ_PSEUDO_MASK);\n}\n\nvoid wil_mask_irq(struct wil6210_priv *wil)\n{\n\twil_dbg_irq(wil, \"mask_irq\\n\");\n\n\twil6210_mask_irq_tx(wil);\n\twil6210_mask_irq_tx_edma(wil);\n\twil6210_mask_irq_rx(wil);\n\twil6210_mask_irq_rx_edma(wil);\n\twil6210_mask_irq_misc(wil, true);\n\twil6210_mask_irq_pseudo(wil);\n}\n\nvoid wil_unmask_irq(struct wil6210_priv *wil)\n\nInstruction:\nwil6210: fix support for sparrow chipsets\n\nReturn the diff that fixes it:\n @@ -101,6 +101,7 @@ void wil_mask_irq(struct wil6210_priv *wil)\n \twil_dbg_irq(wil, \"mask_irq\\n\");\n \n \twil6210_mask_irq_tx(wil);\n+\twil6210_mask_irq_rx(wil);\n \twil6210_mask_irq_tx_edma(wil);\n \twil6210_mask_irq_rx_edma(wil);\n \twil6210_mask_irq_misc(wil, true);\n@@ -109,6 +110,7 @@ void wil_mask_irq(struct wil6210_priv *wil)\n \n void wil_unmask_irq(struct wil6210_priv *wil)\n {\n+\twil6210_unmask_irq_rx(wil);"481 },482 {483 "prompt": "Given the following original C code:\nlist_del(&i->list);\n\t\tkfree(i);\n\t}\n}\n\nvoid ath11k_fw_stats_init(struct ath11k *ar)\n{\n\tINIT_LIST_HEAD(&ar->fw_stats.pdevs);\n\tINIT_LIST_HEAD(&ar->fw_stats.vdevs);\n\tINIT_LIST_HEAD(&ar->fw_stats.bcn);\n\n\tinit_completion(&ar->fw_stats_complete);\n}\n\nvoid ath11k_fw_stats_free(struct ath11k_fw_stats *stats)\n{\n\tath11k_fw_stats_pdevs_free(&stats->pdevs);\n\tath11k_fw_stats_vdevs_free(&stats->vdevs);\n\tath11k_fw_stats_bcn_free(&stats->bcn);\n}\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n",484 "reference": "@@ -990,6 +990,7 @@ void ath11k_fw_stats_init(struct ath11k *ar)\n \tINIT_LIST_HEAD(&ar->fw_stats.bcn);\n \n \tinit_completion(&ar->fw_stats_complete);\n+\tinit_completion(&ar->fw_stats_done);\n }\n \n void ath11k_fw_stats_free(struct ath11k_fw_stats *stats)",485 "prediction": "Given the following original C code:\nlist_del(&i->list);\n\t\tkfree(i);\n\t}\n}\n\nvoid ath11k_fw_stats_init(struct ath11k *ar)\n{\n\tINIT_LIST_HEAD(&ar->fw_stats.pdevs);\n\tINIT_LIST_HEAD(&ar->fw_stats.vdevs);\n\tINIT_LIST_HEAD(&ar->fw_stats.bcn);\n\n\tinit_completion(&ar->fw_stats_complete);\n}\n\nvoid ath11k_fw_stats_free(struct ath11k_fw_stats *stats)\n{\n\tath11k_fw_stats_pdevs_free(&stats->pdevs);\n\tath11k_fw_stats_vdevs_free(&stats->vdevs);\n\tath11k_fw_stats_bcn_free(&stats->bcn);\n}\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n @@ -109,6 +109,10 @@ void ath11k_fw_stats_init(struct ath11k *ar)\n \tINIT_LIST_HEAD(&ar->fw_stats.bcn);\n \n \tinit_completion(&ar->fw_stats_complete);\n+\n+\tspin_lock_init(&ar->fw_stats_lock);\n+\tINIT_WORK(&ar->fw_stats_work, ath11k_debugfs_fw_stats_request);\n+\n }\n \n void ath11k_fw_stats_free(struct ath11k_fw_stats *stats)\n@@ -117,6 +121,7 @@ void ath11k_fw_stats_free(struct ath11k_fw_stats *stats)\n \tath11k_fw_stats_vdevs_free(&stats->vdevs);\n \tath11k_fw_stats_bcn_free(&stats->bcn);\n }\n+EXPORT_SYMBOL(ath11k"486 },487 {488 "prompt": "Given the following original C code:\nbool dfs_block_radar_events;\n\tstruct ath11k_thermal thermal;\n\tu32 vdev_id_11d_scan;\n\tstruct completion completed_11d_scan;\n\tenum ath11k_11d_state state_11d;\n\tbool regdom_set_by_user;\n\tint hw_rate_code;\n\tu8 twt_enabled;\n\tbool nlo_enabled;\n\tu8 alpha2[REG_ALPHA2_LEN + 1];\n\tstruct ath11k_fw_stats fw_stats;\n\tstruct completion fw_stats_complete;\n\tbool fw_stats_done;\n\n\t/* protected by conf_mutex */\n\tbool ps_state_enable;\n\tbool ps_timekeeper_enable;\n\ts8 max_allowed_tx_power;\n};\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n",489 "reference": "@@ -784,7 +784,7 @@ struct ath11k {\n \tu8 alpha2[REG_ALPHA2_LEN + 1];\n \tstruct ath11k_fw_stats fw_stats;\n \tstruct completion fw_stats_complete;\n-\tbool fw_stats_done;\n+\tstruct completion fw_stats_done;\n \n \t/* protected by conf_mutex */\n \tbool ps_state_enable;",490 "prediction": "Given the following original C code:\nbool dfs_block_radar_events;\n\tstruct ath11k_thermal thermal;\n\tu32 vdev_id_11d_scan;\n\tstruct completion completed_11d_scan;\n\tenum ath11k_11d_state state_11d;\n\tbool regdom_set_by_user;\n\tint hw_rate_code;\n\tu8 twt_enabled;\n\tbool nlo_enabled;\n\tu8 alpha2[REG_ALPHA2_LEN + 1];\n\tstruct ath11k_fw_stats fw_stats;\n\tstruct completion fw_stats_complete;\n\tbool fw_stats_done;\n\n\t/* protected by conf_mutex */\n\tbool ps_state_enable;\n\tbool ps_timekeeper_enable;\n\ts8 max_allowed_tx_power;\n};\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,6 @@ struct ath11k {\n \tbool nlo_enabled;\n \tu8 alpha2[REG_ALPHA2_LEN + 1];\n \tstruct ath11k_fw_stats fw_stats;\n-\tstruct completion fw_stats_complete;\n \tbool fw_stats_done;\n \n \t/* protected by conf_mutex */\n@@ -109,6 +108,7 @@ struct ath11k {\n \tbool ps_state_enable;\n \tbool ps_timekeeper_enable;\n \ts8 max_allowed_tx_power;\n+\tstruct delayed_work fw_stats_dwork;\n };\n \n enum ath11k_11d_state {\n@@ -118,6 +118,7 @@ enum ath11k_11d_state {\n \tATH11K_11D_STATE_IDLE,\n \tATH11K_11D_STATE_SCANN"491 },492 {493 "prompt": "Given the following original C code:\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n/*\n * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n\n#include <linux/vmalloc.h>\n\n#include \"debugfs.h\"\n\n#include \"core.h\"\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n",494 "reference": "@@ -1,7 +1,7 @@\n // SPDX-License-Identifier: BSD-3-Clause-Clear\n /*\n * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.\n- * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n+ * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n \n #include <linux/vmalloc.h>\n@@ -96,7 +96,6 @@ void ath11k_debugfs_add_dbring_entry(struct ath11k *ar,\n static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n {\n \tspin_lock_bh(&ar->data_lock);\n-\tar->fw_stats_done = false;\n \tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n \tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n \tspin_unlock_bh(&ar->data_lock);\n@@ -114,7 +113,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \t/* WMI_REQUEST_PDEV_STAT request has been already processed */\n \n \tif (stats->stats_id == WMI_REQUEST_RSSI_PER_CHAIN_STAT) {\n-\t\tar->fw_stats_done = true;\n+\t\tcomplete(&ar->fw_stats_done);\n \t\treturn;\n \t}\n \n@@ -138,7 +137,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \t\t\t\t &ar->fw_stats.vdevs);\n \n \t\tif (is_end) {\n-\t\t\tar->fw_stats_done = true;\n+\t\t\tcomplete(&ar->fw_stats_done);\n \t\t\tnum_vdev = 0;\n \t\t}\n \t\treturn;\n@@ -158,7 +157,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \t\t\t\t &ar->fw_stats.bcn);\n \n \t\tif (is_end) {\n-\t\t\tar->fw_stats_done = true;\n+\t\t\tcomplete(&ar->fw_stats_done);\n \t\t\tnum_bcn = 0;\n \t\t}\n \t}\n@@ -168,21 +167,15 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k *ar,\n \t\t\t\t\t struct stats_request_params *req_param)\n {\n \tstruct ath11k_base *ab = ar->ab;\n-\tunsigned long timeout, time_left;\n+\tunsigned long time_left;\n \tint ret;\n \n \tlockdep_assert_held(&ar->conf_mutex);\n \n-\t/* FW stats can get split when exceeding the stats data buffer limit.\n-\t * In that case, since there is no end marking for the back-to-back\n-\t * received 'update stats' event, we keep a 3 seconds timeout in case,\n-\t * fw_stats_done is not marked yet\n-\t */\n-\ttimeout = jiffies + secs_to_jiffies(3);\n-\n \tath11k_debugfs_fw_stats_reset(ar);\n \n \treinit_completion(&ar->fw_stats_complete);\n+\treinit_completion(&ar->fw_stats_done);\n \n \tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n \n@@ -193,21 +186,18 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k *ar,\n \t}\n \n \ttime_left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ);\n-\n \tif (!time_left)\n \t\treturn -ETIMEDOUT;\n \n-\tfor (;;) {\n-\t\tif (time_after(jiffies, timeout))\n-\t\t\tbreak;\n+\t/* FW stats can get split when exceeding the stats data buffer limit.\n+\t * In that case, since there is no end marking for the back-to-back\n+\t * received 'update stats' event, we keep a 3 seconds timeout in case,\n+\t * fw_stats_done is not marked yet\n+\t */\n+\ttime_left = wait_for_completion_timeout(&ar->fw_stats_done, 3 * HZ);\n+\tif (!time_left)\n+\t\treturn -ETIMEDOUT;\n \n-\t\tspin_lock_bh(&ar->data_lock);\n-\t\tif (ar->fw_stats_done) {\n-\t\t\tspin_unlock_bh(&ar->data_lock);\n-\t\t\tbreak;\n-\t\t}\n-\t\tspin_unlock_bh(&ar->data_lock);\n-\t}\n \treturn 0;\n }",495 "prediction": "Given the following original C code:\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n/*\n * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n\n#include <linux/vmalloc.h>\n\n#include \"debugfs.h\"\n\n#include \"core.h\"\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n @@ -1,7 +1,7 @@\n // SPDX-License-Identifier: BSD-3-Clause-Clear\n /*\n * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.\n- * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n+ * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n \n #include <linux/vmalloc.h>\n@@ -11,6 +11,7 @@\n #include \"core.h\"\n #include \"debug.h\"\n #include \"debugfs.h\"\n+#include \"hif.h\"\n \n #define ATH11K_DEBUGFS_FW_STATS_BUF_SIZE 4096\n #define ATH11K_DEBUGFS_FW_STATS_REQ_TIMEOUT_HZ (10 * HZ)\n@@ -10"496 },497 {498 "prompt": "Given the following original C code:\n}\n\nstatic int ath11k_fw_stats_request(struct ath11k *ar,\n\t\t\t\t struct stats_request_params *req_param)\n{\n\tstruct ath11k_base *ab = ar->ab;\n\tunsigned long time_left;\n\tint ret;\n\n\tlockdep_assert_held(&ar->conf_mutex);\n\n\tspin_lock_bh(&ar->data_lock);\n\tar->fw_stats_done = false;\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tspin_unlock_bh(&ar->data_lock);\n\n\treinit_completion(&ar->fw_stats_complete);\n\n\tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n\tif (ret) {\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n",499 "reference": "@@ -9390,11 +9390,11 @@ static int ath11k_fw_stats_request(struct ath11k *ar,\n \tlockdep_assert_held(&ar->conf_mutex);\n \n \tspin_lock_bh(&ar->data_lock);\n-\tar->fw_stats_done = false;\n \tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n \tspin_unlock_bh(&ar->data_lock);\n \n \treinit_completion(&ar->fw_stats_complete);\n+\treinit_completion(&ar->fw_stats_done);\n \n \tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n \tif (ret) {",500 "prediction": "Given the following original C code:\n}\n\nstatic int ath11k_fw_stats_request(struct ath11k *ar,\n\t\t\t\t struct stats_request_params *req_param)\n{\n\tstruct ath11k_base *ab = ar->ab;\n\tunsigned long time_left;\n\tint ret;\n\n\tlockdep_assert_held(&ar->conf_mutex);\n\n\tspin_lock_bh(&ar->data_lock);\n\tar->fw_stats_done = false;\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tspin_unlock_bh(&ar->data_lock);\n\n\treinit_completion(&ar->fw_stats_complete);\n\n\tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n\tif (ret) {\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n @@ -108,6 +108,7 @@ static int ath11k_fw_stats_request(struct ath11k *ar,\n \n \tlockdep_assert_held(&ar->conf_mutex);\n \n+\tif (ar->state != ATH11K_STATE_ON)\n+\t\treturn -EIO;\n \tspin_lock_bh(&ar->data_lock);\n \tar->fw_stats_done = false;\n \tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n@@ -116,6 +117,7 @@ static int ath11k_fw_stats_request(struct ath11k *ar,\n \tspin_unlock_bh(&ar->data_lock);\n \n \treinit_completion(&ar->fw_stats_complete);\n+\n \tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n \tif (ret)"501 },502 {503 "prompt": "Given the following original C code:\nath11k_warn(ab, \"failed to get ar for pdev_id %d: %d\\n\",\n\t\t\t stats.pdev_id, ret);\n\t\tgoto free;\n\t}\n\n\tspin_lock_bh(&ar->data_lock);\n\n\t/* WMI_REQUEST_PDEV_STAT can be requested via .get_txpower mac ops or via\n\t * debugfs fw stats. Therefore, processing it separately.\n\t */\n\tif (stats.stats_id == WMI_REQUEST_PDEV_STAT) {\n\t\tlist_splice_tail_init(&stats.pdevs, &ar->fw_stats.pdevs);\n\t\tar->fw_stats_done = true;\n\t\tgoto complete;\n\t}\n\n\t/* WMI_REQUEST_VDEV_STAT, WMI_REQUEST_BCN_STAT and WMI_REQUEST_RSSI_PER_CHAIN_STAT\n\t * are currently requested only via debugfs fw stats. Hence, processing these\n\t * in debugfs context\n\t */\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n",504 "reference": "@@ -8189,7 +8189,7 @@ static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *sk\n \t */\n \tif (stats.stats_id == WMI_REQUEST_PDEV_STAT) {\n \t\tlist_splice_tail_init(&stats.pdevs, &ar->fw_stats.pdevs);\n-\t\tar->fw_stats_done = true;\n+\t\tcomplete(&ar->fw_stats_done);\n \t\tgoto complete;\n \t}",505 "prediction": "Given the following original C code:\nath11k_warn(ab, \"failed to get ar for pdev_id %d: %d\\n\",\n\t\t\t stats.pdev_id, ret);\n\t\tgoto free;\n\t}\n\n\tspin_lock_bh(&ar->data_lock);\n\n\t/* WMI_REQUEST_PDEV_STAT can be requested via .get_txpower mac ops or via\n\t * debugfs fw stats. Therefore, processing it separately.\n\t */\n\tif (stats.stats_id == WMI_REQUEST_PDEV_STAT) {\n\t\tlist_splice_tail_init(&stats.pdevs, &ar->fw_stats.pdevs);\n\t\tar->fw_stats_done = true;\n\t\tgoto complete;\n\t}\n\n\t/* WMI_REQUEST_VDEV_STAT, WMI_REQUEST_BCN_STAT and WMI_REQUEST_RSSI_PER_CHAIN_STAT\n\t * are currently requested only via debugfs fw stats. Hence, processing these\n\t * in debugfs context\n\t */\n\nInstruction:\nwifi: ath11k: avoid burning CPU in ath11k_debugfs_fw_stats_request()\n\nReturn the diff that fixes it:\n @@ -102,6 +102,10 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k_base *ab,\n \t */\n \tif (stats.stats_id == WMI_REQUEST_PDEV_STAT) {\n \t\tlist_splice_tail_init(&stats.pdevs, &ar->fw_stats.pdevs);\n+\t\tif (ar->fw_stats_done)\n+\t\t\tcomplete(&ar->fw_stats_completed);\n+\t\telse\n+\t\t\tcomplete(&ar->fw_stats_pending);\n \t\tar->fw_stats_done = true;\n \t\tgoto complete;\n \t}\n@@ -113,6 +117,10 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k_base *ab,\n \t */\n \tif (stats.stats_id == WMI_REQUEST_VDEV_STAT ||\n \t stats.stats_id =="506 },507 {508 "prompt": "Given the following original C code:\n#define ATH11K_INVALID_RSSI_FULL -1\n\n#define ATH11K_INVALID_RSSI_EMPTY -128\n\nstruct ath11k_fw_stats {\n\tstruct dentry *debugfs_fwstats;\n\tu32 pdev_id;\n\tu32 stats_id;\n\tstruct list_head pdevs;\n\tstruct list_head vdevs;\n\tstruct list_head bcn;\n};\n\nstruct ath11k_dbg_htt_stats {\n\tu8 type;\n\tu8 reset;\n\tstruct debug_htt_stats_req *stats_req;\n\t/* protects shared stats req buffer */\n\tspinlock_t lock;\n\nInstruction:\nwifi: ath11k: don't use static variables in ath11k_debugfs_fw_stats_process()\n\nReturn the diff that fixes it:\n",509 "reference": "@@ -600,6 +600,8 @@ struct ath11k_fw_stats {\n \tstruct list_head pdevs;\n \tstruct list_head vdevs;\n \tstruct list_head bcn;\n+\tu32 num_vdev_recvd;\n+\tu32 num_bcn_recvd;\n };\n \n struct ath11k_dbg_htt_stats {",510 "prediction": "Given the following original C code:\n#define ATH11K_INVALID_RSSI_FULL -1\n\n#define ATH11K_INVALID_RSSI_EMPTY -128\n\nstruct ath11k_fw_stats {\n\tstruct dentry *debugfs_fwstats;\n\tu32 pdev_id;\n\tu32 stats_id;\n\tstruct list_head pdevs;\n\tstruct list_head vdevs;\n\tstruct list_head bcn;\n};\n\nstruct ath11k_dbg_htt_stats {\n\tu8 type;\n\tu8 reset;\n\tstruct debug_htt_stats_req *stats_req;\n\t/* protects shared stats req buffer */\n\tspinlock_t lock;\n\nInstruction:\nwifi: ath11k: don't use static variables in ath11k_debugfs_fw_stats_process()\n\nReturn the diff that fixes it:\n @@ -108,6 +108,7 @@ struct ath11k_fw_stats {\n \tstruct list_head pdevs;\n \tstruct list_head vdevs;\n \tstruct list_head bcn;\n+\tstruct ath11k *ar;\n };\n \n struct ath11k_dbg_htt_stats {\n@@ -116,6 +117,7 @@ struct ath11k_dbg_htt_stats {\n \tu8 type;\n \tu8 reset;\n \tstruct debug_htt_stats_req *stats_req;\n+\tstruct ath11k *ar;\n \t/* protects shared stats req buffer */\n \tspinlock_t lock;\n };\n@@ -124,6 +126,7 @@ struct ath11k_dbg_htt_stats {\n \tstruct list_head list;\n };\n \n+struct ath11k_dbg_fw_stats {\n+\tstruct list_head list;\n+};\n+\n struct ath1"511 },512 {513 "prompt": "Given the following original C code:\ndbr_data->num_ring_debug_entries)\n\t\t\tdbr_data->dbr_debug_idx = 0;\n\t}\n\n\tspin_unlock_bh(&dbr_data->lock);\n}\n\nstatic void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n{\n\tspin_lock_bh(&ar->data_lock);\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n\tspin_unlock_bh(&ar->data_lock);\n}\n\nvoid ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats)\n{\n\tstruct ath11k_base *ab = ar->ab;\n\tstruct ath11k_pdev *pdev;\n\tbool is_end;\n\nInstruction:\nwifi: ath11k: don't use static variables in ath11k_debugfs_fw_stats_process()\n\nReturn the diff that fixes it:\n",514 "reference": "@@ -98,6 +98,8 @@ static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n \tspin_lock_bh(&ar->data_lock);\n \tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n \tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n+\tar->fw_stats.num_vdev_recvd = 0;\n+\tar->fw_stats.num_bcn_recvd = 0;\n \tspin_unlock_bh(&ar->data_lock);\n }\n \n@@ -106,7 +108,6 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \tstruct ath11k_base *ab = ar->ab;\n \tstruct ath11k_pdev *pdev;\n \tbool is_end;\n-\tstatic unsigned int num_vdev, num_bcn;\n \tsize_t total_vdevs_started = 0;\n \tint i;\n \n@@ -131,15 +132,14 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \t\t\t\ttotal_vdevs_started += ar->num_started_vdevs;\n \t\t}\n \n-\t\tis_end = ((++num_vdev) == total_vdevs_started);\n+\t\tis_end = ((++ar->fw_stats.num_vdev_recvd) == total_vdevs_started);\n \n \t\tlist_splice_tail_init(&stats->vdevs,\n \t\t\t\t &ar->fw_stats.vdevs);\n \n-\t\tif (is_end) {\n+\t\tif (is_end)\n \t\t\tcomplete(&ar->fw_stats_done);\n-\t\t\tnum_vdev = 0;\n-\t\t}\n+\n \t\treturn;\n \t}\n \n@@ -151,15 +151,13 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \t\t/* Mark end until we reached the count of all started VDEVs\n \t\t * within the PDEV\n \t\t */\n-\t\tis_end = ((++num_bcn) == ar->num_started_vdevs);\n+\t\tis_end = ((++ar->fw_stats.num_bcn_recvd) == ar->num_started_vdevs);\n \n \t\tlist_splice_tail_init(&stats->bcn,\n \t\t\t\t &ar->fw_stats.bcn);\n \n-\t\tif (is_end) {\n+\t\tif (is_end)\n \t\t\tcomplete(&ar->fw_stats_done);\n-\t\t\tnum_bcn = 0;\n-\t\t}\n \t}\n }",515 "prediction": "Given the following original C code:\ndbr_data->num_ring_debug_entries)\n\t\t\tdbr_data->dbr_debug_idx = 0;\n\t}\n\n\tspin_unlock_bh(&dbr_data->lock);\n}\n\nstatic void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n{\n\tspin_lock_bh(&ar->data_lock);\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n\tspin_unlock_bh(&ar->data_lock);\n}\n\nvoid ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats)\n{\n\tstruct ath11k_base *ab = ar->ab;\n\tstruct ath11k_pdev *pdev;\n\tbool is_end;\n\nInstruction:\nwifi: ath11k: don't use static variables in ath11k_debugfs_fw_stats_process()\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n {\n \tspin_lock_bh(&ar->data_lock);\n \tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n-\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n+\tath11k_fw_stats_vdevs_free(&stats->vdevs);\n \tspin_unlock_bh(&ar->data_lock);\n }\n \n@@ -111,7 +111,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *s\n \tstruct ath11k_base *ab = ar->ab;\n \tstruct ath11k_pdev *pdev;\n \tbool is_end;\n-\tstruct"516 },517 {518 "prompt": "Given the following original C code:\nstatic int ath11k_fw_stats_request(struct ath11k *ar,\n\t\t\t\t struct stats_request_params *req_param)\n{\n\tstruct ath11k_base *ab = ar->ab;\n\tunsigned long time_left;\n\tint ret;\n\n\tlockdep_assert_held(&ar->conf_mutex);\n\n\tspin_lock_bh(&ar->data_lock);\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tspin_unlock_bh(&ar->data_lock);\n\n\treinit_completion(&ar->fw_stats_complete);\n\treinit_completion(&ar->fw_stats_done);\n\n\tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n\tif (ret) {\n\t\tath11k_warn(ab, \"could not request fw stats (%d)\\n\",\n\nInstruction:\nwifi: ath11k: don't use static variables in ath11k_debugfs_fw_stats_process()\n\nReturn the diff that fixes it:\n",519 "reference": "@@ -9391,6 +9391,8 @@ static int ath11k_fw_stats_request(struct ath11k *ar,\n \n \tspin_lock_bh(&ar->data_lock);\n \tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n+\tar->fw_stats.num_vdev_recvd = 0;\n+\tar->fw_stats.num_bcn_recvd = 0;\n \tspin_unlock_bh(&ar->data_lock);\n \n \treinit_completion(&ar->fw_stats_complete);",520 "prediction": "Given the following original C code:\nstatic int ath11k_fw_stats_request(struct ath11k *ar,\n\t\t\t\t struct stats_request_params *req_param)\n{\n\tstruct ath11k_base *ab = ar->ab;\n\tunsigned long time_left;\n\tint ret;\n\n\tlockdep_assert_held(&ar->conf_mutex);\n\n\tspin_lock_bh(&ar->data_lock);\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tspin_unlock_bh(&ar->data_lock);\n\n\treinit_completion(&ar->fw_stats_complete);\n\treinit_completion(&ar->fw_stats_done);\n\n\tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n\tif (ret) {\n\t\tath11k_warn(ab, \"could not request fw stats (%d)\\n\",\n\nInstruction:\nwifi: ath11k: don't use static variables in ath11k_debugfs_fw_stats_process()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static int ath11k_fw_stats_request(struct ath11k *ar,\n \n \tspin_lock_bh(&ar->data_lock);\n \tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n-\tspin_unlock_bh(&ar->data_lock);\n+\tspin_unlock_bh(&ar->data_lock);\n \n \treinit_completion(&ar->fw_stats_complete);\n \treinit_completion(&ar->fw_stats_done);\n@@ -109,7 +109,7 @@ static int ath11k_fw_stats_request(struct ath11k *ar,\n \tif (ret) {\n \t\tath11k_warn(ab, \"could not request fw stats (%d)\\n\",\n \t\t\t ret);\n-\t\tspin_unlock_bh(&ar->data_lock);"521 },522 {523 "prompt": "Given the following original C code:\nspin_lock_bh(&ar->data_lock);\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n\tar->fw_stats.num_vdev_recvd = 0;\n\tar->fw_stats.num_bcn_recvd = 0;\n\tspin_unlock_bh(&ar->data_lock);\n}\n\nvoid ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats)\n{\n\tstruct ath11k_base *ab = ar->ab;\n\tstruct ath11k_pdev *pdev;\n\tbool is_end;\n\tsize_t total_vdevs_started = 0;\n\tint i;\n\n\t/* WMI_REQUEST_PDEV_STAT request has been already processed */\n\n\tif (stats->stats_id == WMI_REQUEST_RSSI_PER_CHAIN_STAT) {\n\t\tcomplete(&ar->fw_stats_done);\n\nInstruction:\nwifi: ath11k: don't wait when there is no vdev started\n\nReturn the diff that fixes it:\n",524 "reference": "@@ -107,7 +107,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n {\n \tstruct ath11k_base *ab = ar->ab;\n \tstruct ath11k_pdev *pdev;\n-\tbool is_end;\n+\tbool is_end = true;\n \tsize_t total_vdevs_started = 0;\n \tint i;\n \n@@ -132,7 +132,9 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \t\t\t\ttotal_vdevs_started += ar->num_started_vdevs;\n \t\t}\n \n-\t\tis_end = ((++ar->fw_stats.num_vdev_recvd) == total_vdevs_started);\n+\t\tif (total_vdevs_started)\n+\t\t\tis_end = ((++ar->fw_stats.num_vdev_recvd) ==\n+\t\t\t\t total_vdevs_started);\n \n \t\tlist_splice_tail_init(&stats->vdevs,\n \t\t\t\t &ar->fw_stats.vdevs);\n@@ -151,7 +153,9 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \t\t/* Mark end until we reached the count of all started VDEVs\n \t\t * within the PDEV\n \t\t */\n-\t\tis_end = ((++ar->fw_stats.num_bcn_recvd) == ar->num_started_vdevs);\n+\t\tif (ar->num_started_vdevs)\n+\t\t\tis_end = ((++ar->fw_stats.num_bcn_recvd) ==\n+\t\t\t\t ar->num_started_vdevs);\n \n \t\tlist_splice_tail_init(&stats->bcn,\n \t\t\t\t &ar->fw_stats.bcn);",525 "prediction": "Given the following original C code:\nspin_lock_bh(&ar->data_lock);\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n\tar->fw_stats.num_vdev_recvd = 0;\n\tar->fw_stats.num_bcn_recvd = 0;\n\tspin_unlock_bh(&ar->data_lock);\n}\n\nvoid ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats)\n{\n\tstruct ath11k_base *ab = ar->ab;\n\tstruct ath11k_pdev *pdev;\n\tbool is_end;\n\tsize_t total_vdevs_started = 0;\n\tint i;\n\n\t/* WMI_REQUEST_PDEV_STAT request has been already processed */\n\n\tif (stats->stats_id == WMI_REQUEST_RSSI_PER_CHAIN_STAT) {\n\t\tcomplete(&ar->fw_stats_done);\n\nInstruction:\nwifi: ath11k: don't wait when there is no vdev started\n\nReturn the diff that fixes it:\n @@ -108,6 +108,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n {\n \tstruct ath11k_base *ab = ar->ab;\n \tstruct ath11k_pdev *pdev;\n+\tstruct ath11k_vif *arvif;\n \tbool is_end;\n \tsize_t total_vdevs_started = 0;\n \tint i;\n@@ -116,6 +117,7 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \n \tif (stats->stats_id == WMI_REQUEST_PDEV_STAT) {\n \t\tspin_lock_bh(&ar->data_lock);\n+\t\tlist_for_each_entry(arvif, &ar->arvifs, list)\n+\t\t\ttotal_"526 },527 {528 "prompt": "Given the following original C code:\nentry->timestamp = jiffies;\n\t\tentry->event = event;\n\n\t\tdbr_data->dbr_debug_idx++;\n\t\tif (dbr_data->dbr_debug_idx ==\n\t\t dbr_data->num_ring_debug_entries)\n\t\t\tdbr_data->dbr_debug_idx = 0;\n\t}\n\n\tspin_unlock_bh(&dbr_data->lock);\n}\n\nstatic void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n{\n\tspin_lock_bh(&ar->data_lock);\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n\tar->fw_stats.num_vdev_recvd = 0;\n\tar->fw_stats.num_bcn_recvd = 0;\n\tspin_unlock_bh(&ar->data_lock);\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n",529 "reference": "@@ -93,58 +93,14 @@ void ath11k_debugfs_add_dbring_entry(struct ath11k *ar,\n \tspin_unlock_bh(&dbr_data->lock);\n }\n \n-static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n-{\n-\tspin_lock_bh(&ar->data_lock);\n-\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n-\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n-\tar->fw_stats.num_vdev_recvd = 0;\n-\tar->fw_stats.num_bcn_recvd = 0;\n-\tspin_unlock_bh(&ar->data_lock);\n-}\n-\n void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats)\n {\n \tstruct ath11k_base *ab = ar->ab;\n-\tstruct ath11k_pdev *pdev;\n \tbool is_end = true;\n-\tsize_t total_vdevs_started = 0;\n-\tint i;\n-\n-\t/* WMI_REQUEST_PDEV_STAT request has been already processed */\n-\n-\tif (stats->stats_id == WMI_REQUEST_RSSI_PER_CHAIN_STAT) {\n-\t\tcomplete(&ar->fw_stats_done);\n-\t\treturn;\n-\t}\n-\n-\tif (stats->stats_id == WMI_REQUEST_VDEV_STAT) {\n-\t\tif (list_empty(&stats->vdevs)) {\n-\t\t\tath11k_warn(ab, \"empty vdev stats\");\n-\t\t\treturn;\n-\t\t}\n-\t\t/* FW sends all the active VDEV stats irrespective of PDEV,\n-\t\t * hence limit until the count of all VDEVs started\n-\t\t */\n-\t\tfor (i = 0; i < ab->num_radios; i++) {\n-\t\t\tpdev = rcu_dereference(ab->pdevs_active[i]);\n-\t\t\tif (pdev && pdev->ar)\n-\t\t\t\ttotal_vdevs_started += ar->num_started_vdevs;\n-\t\t}\n-\n-\t\tif (total_vdevs_started)\n-\t\t\tis_end = ((++ar->fw_stats.num_vdev_recvd) ==\n-\t\t\t\t total_vdevs_started);\n-\n-\t\tlist_splice_tail_init(&stats->vdevs,\n-\t\t\t\t &ar->fw_stats.vdevs);\n-\n-\t\tif (is_end)\n-\t\t\tcomplete(&ar->fw_stats_done);\n-\n-\t\treturn;\n-\t}\n \n+\t/* WMI_REQUEST_PDEV_STAT, WMI_REQUEST_RSSI_PER_CHAIN_STAT and\n+\t * WMI_REQUEST_VDEV_STAT requests have been already processed.\n+\t */\n \tif (stats->stats_id == WMI_REQUEST_BCN_STAT) {\n \t\tif (list_empty(&stats->bcn)) {\n \t\t\tath11k_warn(ab, \"empty bcn stats\");\n@@ -165,76 +121,6 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *\n \t}\n }\n \n-static int ath11k_debugfs_fw_stats_request(struct ath11k *ar,\n-\t\t\t\t\t struct stats_request_params *req_param)\n-{\n-\tstruct ath11k_base *ab = ar->ab;\n-\tunsigned long time_left;\n-\tint ret;\n-\n-\tlockdep_assert_held(&ar->conf_mutex);\n-\n-\tath11k_debugfs_fw_stats_reset(ar);\n-\n-\treinit_completion(&ar->fw_stats_complete);\n-\treinit_completion(&ar->fw_stats_done);\n-\n-\tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n-\n-\tif (ret) {\n-\t\tath11k_warn(ab, \"could not request fw stats (%d)\\n\",\n-\t\t\t ret);\n-\t\treturn ret;\n-\t}\n-\n-\ttime_left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ);\n-\tif (!time_left)\n-\t\treturn -ETIMEDOUT;\n-\n-\t/* FW stats can get split when exceeding the stats data buffer limit.\n-\t * In that case, since there is no end marking for the back-to-back\n-\t * received 'update stats' event, we keep a 3 seconds timeout in case,\n-\t * fw_stats_done is not marked yet\n-\t */\n-\ttime_left = wait_for_completion_timeout(&ar->fw_stats_done, 3 * HZ);\n-\tif (!time_left)\n-\t\treturn -ETIMEDOUT;\n-\n-\treturn 0;\n-}\n-\n-int ath11k_debugfs_get_fw_stats(struct ath11k *ar, u32 pdev_id,\n-\t\t\t\tu32 vdev_id, u32 stats_id)\n-{\n-\tstruct ath11k_base *ab = ar->ab;\n-\tstruct stats_request_params req_param;\n-\tint ret;\n-\n-\tmutex_lock(&ar->conf_mutex);\n-\n-\tif (ar->state != ATH11K_STATE_ON) {\n-\t\tret = -ENETDOWN;\n-\t\tgoto err_unlock;\n-\t}\n-\n-\treq_param.pdev_id = pdev_id;\n-\treq_param.vdev_id = vdev_id;\n-\treq_param.stats_id = stats_id;\n-\n-\tret = ath11k_debugfs_fw_stats_request(ar, &req_param);\n-\tif (ret)\n-\t\tath11k_warn(ab, \"failed to request fw stats: %d\\n\", ret);\n-\n-\tath11k_dbg(ab, ATH11K_DBG_WMI,\n-\t\t \"debug get fw stat pdev id %d vdev id %d stats id 0x%x\\n\",\n-\t\t pdev_id, vdev_id, stats_id);\n-\n-err_unlock:\n-\tmutex_unlock(&ar->conf_mutex);\n-\n-\treturn ret;\n-}\n-\n static int ath11k_open_pdev_stats(struct inode *inode, struct file *file)\n {\n \tstruct ath11k *ar = inode->i_private;\n@@ -260,7 +146,7 @@ static int ath11k_open_pdev_stats(struct inode *inode, struct file *file)\n \treq_param.vdev_id = 0;\n \treq_param.stats_id = WMI_REQUEST_PDEV_STAT;\n \n-\tret = ath11k_debugfs_fw_stats_request(ar, &req_param);\n+\tret = ath11k_mac_fw_stats_request(ar, &req_param);\n \tif (ret) {\n \t\tath11k_warn(ab, \"failed to request fw pdev stats: %d\\n\", ret);\n \t\tgoto err_free;\n@@ -331,7 +217,7 @@ static int ath11k_open_vdev_stats(struct inode *inode, struct file *file)\n \treq_param.vdev_id = 0;\n \treq_param.stats_id = WMI_REQUEST_VDEV_STAT;\n \n-\tret = ath11k_debugfs_fw_stats_request(ar, &req_param);\n+\tret = ath11k_mac_fw_stats_request(ar, &req_param);\n \tif (ret) {\n \t\tath11k_warn(ar->ab, \"failed to request fw vdev stats: %d\\n\", ret);\n \t\tgoto err_free;\n@@ -407,7 +293,7 @@ static int ath11k_open_bcn_stats(struct inode *inode, struct file *file)\n \t\t\tcontinue;\n \n \t\treq_param.vdev_id = arvif->vdev_id;\n-\t\tret = ath11k_debugfs_fw_stats_request(ar, &req_param);\n+\t\tret = ath11k_mac_fw_stats_request(ar, &req_param);\n \t\tif (ret) {\n \t\t\tath11k_warn(ar->ab, \"failed to request fw bcn stats: %d\\n\", ret);\n \t\t\tgoto err_free;",530 "prediction": "Given the following original C code:\nentry->timestamp = jiffies;\n\t\tentry->event = event;\n\n\t\tdbr_data->dbr_debug_idx++;\n\t\tif (dbr_data->dbr_debug_idx ==\n\t\t dbr_data->num_ring_debug_entries)\n\t\t\tdbr_data->dbr_debug_idx = 0;\n\t}\n\n\tspin_unlock_bh(&dbr_data->lock);\n}\n\nstatic void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n{\n\tspin_lock_bh(&ar->data_lock);\n\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n\tar->fw_stats.num_vdev_recvd = 0;\n\tar->fw_stats.num_bcn_recvd = 0;\n\tspin_unlock_bh(&ar->data_lock);\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n @@ -108,10 +108,6 @@ static void ath11k_debugfs_fw_stats_event(struct ath11k *ar,\n \tspin_unlock_bh(&dbr_data->lock);\n }\n \n-static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)\n-{\n-\tspin_lock_bh(&ar->data_lock);\n-\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n-\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n-\tar->fw_stats.num_vdev_recvd = 0;\n-\tar->fw_stats.num_bcn_recvd = 0;\n-\tspin_unlock_bh(&ar->data_lock);\n-}\n-\n static void ath11k_debugfs_fw_stats_init(struct ath11k *ar)\n {"531 },532 {533 "prompt": "Given the following original C code:\n/* SPDX-License-Identifier: BSD-3-Clause-Clear */\n/*\n * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n\n#ifndef _ATH11K_DEBUGFS_H_\n#define _ATH11K_DEBUGFS_H_\n\n#include \"hal_tx.h\"\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n",534 "reference": "@@ -1,7 +1,7 @@\n /* SPDX-License-Identifier: BSD-3-Clause-Clear */\n /*\n * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.\n- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.\n+ * Copyright (c) 2021-2022, 2025 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n \n #ifndef _ATH11K_DEBUGFS_H_\n@@ -273,8 +273,6 @@ void ath11k_debugfs_unregister(struct ath11k *ar);\n void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *stats);\n \n void ath11k_debugfs_fw_stats_init(struct ath11k *ar);\n-int ath11k_debugfs_get_fw_stats(struct ath11k *ar, u32 pdev_id,\n-\t\t\t\tu32 vdev_id, u32 stats_id);\n \n static inline bool ath11k_debugfs_is_pktlog_lite_mode_enabled(struct ath11k *ar)\n {\n@@ -381,12 +379,6 @@ static inline int ath11k_debugfs_rx_filter(struct ath11k *ar)\n \treturn 0;\n }\n \n-static inline int ath11k_debugfs_get_fw_stats(struct ath11k *ar,\n-\t\t\t\t\t u32 pdev_id, u32 vdev_id, u32 stats_id)\n-{\n-\treturn 0;\n-}\n-\n static inline void\n ath11k_debugfs_add_dbring_entry(struct ath11k *ar,\n \t\t\t\tenum wmi_direct_buffer_module id,",535 "prediction": "Given the following original C code:\n/* SPDX-License-Identifier: BSD-3-Clause-Clear */\n/*\n * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n\n#ifndef _ATH11K_DEBUGFS_H_\n#define _ATH11K_DEBUGFS_H_\n\n#include \"hal_tx.h\"\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n @@ -1,7 +1,7 @@\n /* SPDX-License-Identifier: BSD-3-Clause-Clear */\n /*\n * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.\n- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.\n+ * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n \n #ifndef _ATH11K_DEBUGFS_H_\n@@ -13,6 +13,7 @@\n #include \"hal_tx.h\"\n #include \"hal_rx.h\"\n #include \"debug.h\"\n+#include \"firmware.h\"\n \n #include <linux/debugfs.h>\n #include <linux/seq_file.h>\n@@ -22,6 +23,7 @@\n #include <net/mac80211.h>\n #include"536 },537 {538 "prompt": "Given the following original C code:\nif (rssi != ATH11K_DEFAULT_NOISE_FLOOR &&\n\t\t rssi != ATH11K_INVALID_RSSI_FULL &&\n\t\t rssi != ATH11K_INVALID_RSSI_EMPTY &&\n\t\t rssi != 0) {\n\t\t\tsinfo->chain_signal[i] = rssi;\n\t\t\tsinfo->chains |= BIT(i);\n\t\t\tsinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);\n\t\t}\n\t}\n}\n\nstatic void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,\n\t\t\t\t\t struct ieee80211_vif *vif,\n\t\t\t\t\t struct ieee80211_sta *sta,\n\t\t\t\t\t struct station_info *sinfo)\n{\n\tstruct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);\n\tstruct ath11k *ar = arsta->arvif->ar;\n\ts8 signal;\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n",539 "reference": "@@ -8997,6 +8997,86 @@ static void ath11k_mac_put_chain_rssi(struct station_info *sinfo,\n \t}\n }\n \n+static void ath11k_mac_fw_stats_reset(struct ath11k *ar)\n+{\n+\tspin_lock_bh(&ar->data_lock);\n+\tath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);\n+\tath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);\n+\tar->fw_stats.num_vdev_recvd = 0;\n+\tar->fw_stats.num_bcn_recvd = 0;\n+\tspin_unlock_bh(&ar->data_lock);\n+}\n+\n+int ath11k_mac_fw_stats_request(struct ath11k *ar,\n+\t\t\t\tstruct stats_request_params *req_param)\n+{\n+\tstruct ath11k_base *ab = ar->ab;\n+\tunsigned long time_left;\n+\tint ret;\n+\n+\tlockdep_assert_held(&ar->conf_mutex);\n+\n+\tath11k_mac_fw_stats_reset(ar);\n+\n+\treinit_completion(&ar->fw_stats_complete);\n+\treinit_completion(&ar->fw_stats_done);\n+\n+\tret = ath11k_wmi_send_stats_request_cmd(ar, req_param);\n+\n+\tif (ret) {\n+\t\tath11k_warn(ab, \"could not request fw stats (%d)\\n\",\n+\t\t\t ret);\n+\t\treturn ret;\n+\t}\n+\n+\ttime_left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ);\n+\tif (!time_left)\n+\t\treturn -ETIMEDOUT;\n+\n+\t/* FW stats can get split when exceeding the stats data buffer limit.\n+\t * In that case, since there is no end marking for the back-to-back\n+\t * received 'update stats' event, we keep a 3 seconds timeout in case,\n+\t * fw_stats_done is not marked yet\n+\t */\n+\ttime_left = wait_for_completion_timeout(&ar->fw_stats_done, 3 * HZ);\n+\tif (!time_left)\n+\t\treturn -ETIMEDOUT;\n+\n+\treturn 0;\n+}\n+\n+static int ath11k_mac_get_fw_stats(struct ath11k *ar, u32 pdev_id,\n+\t\t\t\t u32 vdev_id, u32 stats_id)\n+{\n+\tstruct ath11k_base *ab = ar->ab;\n+\tstruct stats_request_params req_param;\n+\tint ret;\n+\n+\tmutex_lock(&ar->conf_mutex);\n+\n+\tif (ar->state != ATH11K_STATE_ON) {\n+\t\tret = -ENETDOWN;\n+\t\tgoto err_unlock;\n+\t}\n+\n+\treq_param.pdev_id = pdev_id;\n+\treq_param.vdev_id = vdev_id;\n+\treq_param.stats_id = stats_id;\n+\n+\tret = ath11k_mac_fw_stats_request(ar, &req_param);\n+\tif (ret)\n+\t\tath11k_warn(ab, \"failed to request fw stats: %d\\n\", ret);\n+\n+\tath11k_dbg(ab, ATH11K_DBG_WMI,\n+\t\t \"debug get fw stat pdev id %d vdev id %d stats id 0x%x\\n\",\n+\t\t pdev_id, vdev_id, stats_id);\n+\n+err_unlock:\n+\tmutex_unlock(&ar->conf_mutex);\n+\n+\treturn ret;\n+}\n+\n static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,\n \t\t\t\t\t struct ieee80211_vif *vif,\n \t\t\t\t\t struct ieee80211_sta *sta,\n@@ -9034,8 +9114,8 @@ static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,\n \tif (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL)) &&\n \t arsta->arvif->vdev_type == WMI_VDEV_TYPE_STA &&\n \t ar->ab->hw_params.supports_rssi_stats &&\n-\t !ath11k_debugfs_get_fw_stats(ar, ar->pdev->pdev_id, 0,\n-\t\t\t\t\t WMI_REQUEST_RSSI_PER_CHAIN_STAT)) {\n+\t !ath11k_mac_get_fw_stats(ar, ar->pdev->pdev_id, 0,\n+\t\t\t\t WMI_REQUEST_RSSI_PER_CHAIN_STAT)) {\n \t\tath11k_mac_put_chain_rssi(sinfo, arsta, \"fw stats\", true);\n \t}\n \n@@ -9043,8 +9123,8 @@ static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,\n \tif (!signal &&\n \t arsta->arvif->vdev_type == WMI_VDEV_TYPE_STA &&\n \t ar->ab->hw_params.supports_rssi_stats &&\n-\t !(ath11k_debugfs_get_fw_stats(ar, ar->pdev->pdev_id, 0,\n-\t\t\t\t\tWMI_REQUEST_VDEV_STAT)))\n+\t !(ath11k_mac_get_fw_stats(ar, ar->pdev->pdev_id, 0,\n+\t\t\t\t WMI_REQUEST_VDEV_STAT)))\n \t\tsignal = arsta->rssi_beacon;\n \n \tath11k_dbg(ar->ab, ATH11K_DBG_MAC,",540 "prediction": "Given the following original C code:\nif (rssi != ATH11K_DEFAULT_NOISE_FLOOR &&\n\t\t rssi != ATH11K_INVALID_RSSI_FULL &&\n\t\t rssi != ATH11K_INVALID_RSSI_EMPTY &&\n\t\t rssi != 0) {\n\t\t\tsinfo->chain_signal[i] = rssi;\n\t\t\tsinfo->chains |= BIT(i);\n\t\t\tsinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);\n\t\t}\n\t}\n}\n\nstatic void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,\n\t\t\t\t\t struct ieee80211_vif *vif,\n\t\t\t\t\t struct ieee80211_sta *sta,\n\t\t\t\t\t struct station_info *sinfo)\n{\n\tstruct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);\n\tstruct ath11k *ar = arsta->arvif->ar;\n\ts8 signal;\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n A @@ -108,10 +108,10 @@ static void ath11k_mac_op_sta_fill_rssi(struct ath11k *ar,\n }\n \n static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,\n-\t\t\t\t\t struct ieee80211_vif *vif,\n-\t\t\t\t\t struct ieee80211_sta *sta,\n-\t\t\t\t\t struct station_info *sinfo)\n+\t\t\t\t\t struct ieee80211_sta *sta,\n+\t\t\t\t\t struct station_info *sinfo)\n {\n \tstruct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);\n-\tstruct ath11k *ar = arsta->arvif->ar;\n+\tstruct ath11k *ar = arsta->arvif->arvif.ar;\n \ts8 signal;"541 },542 {543 "prompt": "Given the following original C code:\n/* SPDX-License-Identifier: BSD-3-Clause-Clear */\n/*\n * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n\n#ifndef ATH11K_MAC_H\n#define ATH11K_MAC_H\n\n#include <net/mac80211.h>\n#include <net/cfg80211.h>\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n",544 "reference": "@@ -1,7 +1,7 @@\n /* SPDX-License-Identifier: BSD-3-Clause-Clear */\n /*\n * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.\n- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.\n+ * Copyright (c) 2021-2023, 2025 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n \n #ifndef ATH11K_MAC_H\n@@ -179,4 +179,6 @@ int ath11k_mac_vif_set_keepalive(struct ath11k_vif *arvif,\n void ath11k_mac_fill_reg_tpc_info(struct ath11k *ar,\n \t\t\t\t struct ieee80211_vif *vif,\n \t\t\t\t struct ieee80211_chanctx_conf *ctx);\n+int ath11k_mac_fw_stats_request(struct ath11k *ar,\n+\t\t\t\tstruct stats_request_params *req_param);\n #endif",545 "prediction": "Given the following original C code:\n/* SPDX-License-Identifier: BSD-3-Clause-Clear */\n/*\n * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.\n * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n\n#ifndef ATH11K_MAC_H\n#define ATH11K_MAC_H\n\n#include <net/mac80211.h>\n#include <net/cfg80211.h>\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n @@ -1,7 +1,7 @@\n /* SPDX-License-Identifier: BSD-3-Clause-Clear */\n /*\n * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.\n- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.\n+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.\n */\n \n #ifndef ATH11K_MAC_H\n@@ -11,6 +11,7 @@\n #include <net/cfg80211.h>\n #include <net/mac80211.h>\n #include <net/ieee80211_radiotap.h>\n+#include <linux/debugfs.h>\n #include <linux/types.h>\n #include <linux/skbuff.h>\n #include <linux/etherdevice.h>\n@@ -"546 },547 {548 "prompt": "Given the following original C code:\npeer_assoc_conf.vdev_id);\n\t\trcu_read_unlock();\n\t\treturn;\n\t}\n\n\tcomplete(&ar->peer_assoc_done);\n\trcu_read_unlock();\n}\n\nstatic void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *skb)\n{\n\tstruct ath11k_fw_stats stats = {};\n\tstruct ath11k *ar;\n\tint ret;\n\n\tINIT_LIST_HEAD(&stats.pdevs);\n\tINIT_LIST_HEAD(&stats.vdevs);\n\tINIT_LIST_HEAD(&stats.bcn);\n\n\tret = ath11k_wmi_pull_fw_stats(ab, skb, &stats);\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n",549 "reference": "@@ -8158,6 +8158,11 @@ static void ath11k_peer_assoc_conf_event(struct ath11k_base *ab, struct sk_buff\n static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *skb)\n {\n \tstruct ath11k_fw_stats stats = {};\n+\tsize_t total_vdevs_started = 0;\n+\tstruct ath11k_pdev *pdev;\n+\tbool is_end = true;\n+\tint i;\n+\n \tstruct ath11k *ar;\n \tint ret;\n \n@@ -8184,7 +8189,8 @@ static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *sk\n \n \tspin_lock_bh(&ar->data_lock);\n \n-\t/* WMI_REQUEST_PDEV_STAT can be requested via .get_txpower mac ops or via\n+\t/* WMI_REQUEST_PDEV_STAT, WMI_REQUEST_VDEV_STAT and\n+\t * WMI_REQUEST_RSSI_PER_CHAIN_STAT can be requested via mac ops or via\n \t * debugfs fw stats. Therefore, processing it separately.\n \t */\n \tif (stats.stats_id == WMI_REQUEST_PDEV_STAT) {\n@@ -8193,9 +8199,40 @@ static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *sk\n \t\tgoto complete;\n \t}\n \n-\t/* WMI_REQUEST_VDEV_STAT, WMI_REQUEST_BCN_STAT and WMI_REQUEST_RSSI_PER_CHAIN_STAT\n-\t * are currently requested only via debugfs fw stats. Hence, processing these\n-\t * in debugfs context\n+\tif (stats.stats_id == WMI_REQUEST_RSSI_PER_CHAIN_STAT) {\n+\t\tcomplete(&ar->fw_stats_done);\n+\t\tgoto complete;\n+\t}\n+\n+\tif (stats.stats_id == WMI_REQUEST_VDEV_STAT) {\n+\t\tif (list_empty(&stats.vdevs)) {\n+\t\t\tath11k_warn(ab, \"empty vdev stats\");\n+\t\t\tgoto complete;\n+\t\t}\n+\t\t/* FW sends all the active VDEV stats irrespective of PDEV,\n+\t\t * hence limit until the count of all VDEVs started\n+\t\t */\n+\t\tfor (i = 0; i < ab->num_radios; i++) {\n+\t\t\tpdev = rcu_dereference(ab->pdevs_active[i]);\n+\t\t\tif (pdev && pdev->ar)\n+\t\t\t\ttotal_vdevs_started += ar->num_started_vdevs;\n+\t\t}\n+\n+\t\tif (total_vdevs_started)\n+\t\t\tis_end = ((++ar->fw_stats.num_vdev_recvd) ==\n+\t\t\t\t total_vdevs_started);\n+\n+\t\tlist_splice_tail_init(&stats.vdevs,\n+\t\t\t\t &ar->fw_stats.vdevs);\n+\n+\t\tif (is_end)\n+\t\t\tcomplete(&ar->fw_stats_done);\n+\n+\t\tgoto complete;\n+\t}\n+\n+\t/* WMI_REQUEST_BCN_STAT is currently requested only via debugfs fw stats.\n+\t * Hence, processing it in debugfs context\n \t */\n \tath11k_debugfs_fw_stats_process(ar, &stats);",550 "prediction": "Given the following original C code:\npeer_assoc_conf.vdev_id);\n\t\trcu_read_unlock();\n\t\treturn;\n\t}\n\n\tcomplete(&ar->peer_assoc_done);\n\trcu_read_unlock();\n}\n\nstatic void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *skb)\n{\n\tstruct ath11k_fw_stats stats = {};\n\tstruct ath11k *ar;\n\tint ret;\n\n\tINIT_LIST_HEAD(&stats.pdevs);\n\tINIT_LIST_HEAD(&stats.vdevs);\n\tINIT_LIST_HEAD(&stats.bcn);\n\n\tret = ath11k_wmi_pull_fw_stats(ab, skb, &stats);\n\nInstruction:\nwifi: ath11k: move some firmware stats related functions outside of debugfs\n\nReturn the diff that fixes it:\n @@ -101,6 +101,12 @@ static void ath11k_peer_assoc_event(struct ath11k_base *ab, struct sk_buff *skb)\n static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *skb)\n {\n \tstruct ath11k_fw_stats stats = {};\n+\tstruct ath11k *ar;\n+\tint ret;\n+\n+\tINIT_LIST_HEAD(&stats.pdevs);\n+\tINIT_LIST_HEAD(&stats.vdevs);\n+\tINIT_LIST_HEAD(&stats.bcn);\n+\n \tret = ath11k_wmi_pull_fw_stats(ab, skb, &stats);\n \tif (ret) {\n \t\tath11k_warn(ab, \"failed to parse fw stats event: %d\\n\", ret);\n@@ -109,6 +115,7 @@ static void ath11k_update_stats_event"551 },552 {553 "prompt": "Given the following original C code:\nif (ret) {\n\t\tath11k_err(ab, \"failed to send firmware start: %d\\n\", ret);\n\t\treturn ret;\n\t}\n\n\treturn ret;\n}\n\nint ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)\n{\n\tint ret;\n\n\tret = ath11k_core_start_firmware(ab, ab->fw_mode);\n\tif (ret) {\n\t\tath11k_err(ab, \"failed to start firmware: %d\\n\", ret);\n\t\treturn ret;\n\t}\n\n\tret = ath11k_ce_init_pipes(ab);\n\tif (ret) {\n\nInstruction:\nwifi: ath11k: validate ath11k_crypto_mode on top of ath11k_core_qmi_firmware_ready\n\nReturn the diff that fixes it:\n",554 "reference": "@@ -2135,6 +2135,20 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)\n {\n \tint ret;\n \n+\tswitch (ath11k_crypto_mode) {\n+\tcase ATH11K_CRYPT_MODE_SW:\n+\t\tset_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);\n+\t\tset_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);\n+\t\tbreak;\n+\tcase ATH11K_CRYPT_MODE_HW:\n+\t\tclear_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);\n+\t\tclear_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);\n+\t\tbreak;\n+\tdefault:\n+\t\tath11k_info(ab, \"invalid crypto_mode: %d\\n\", ath11k_crypto_mode);\n+\t\treturn -EINVAL;\n+\t}\n+\n \tret = ath11k_core_start_firmware(ab, ab->fw_mode);\n \tif (ret) {\n \t\tath11k_err(ab, \"failed to start firmware: %d\\n\", ret);\n@@ -2153,20 +2167,6 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)\n \t\tgoto err_firmware_stop;\n \t}\n \n-\tswitch (ath11k_crypto_mode) {\n-\tcase ATH11K_CRYPT_MODE_SW:\n-\t\tset_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);\n-\t\tset_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);\n-\t\tbreak;\n-\tcase ATH11K_CRYPT_MODE_HW:\n-\t\tclear_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);\n-\t\tclear_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);\n-\t\tbreak;\n-\tdefault:\n-\t\tath11k_info(ab, \"invalid crypto_mode: %d\\n\", ath11k_crypto_mode);\n-\t\treturn -EINVAL;\n-\t}\n-\n \tif (ath11k_frame_mode == ATH11K_HW_TXRX_RAW)\n \t\tset_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);",555 "prediction": "Given the following original C code:\nif (ret) {\n\t\tath11k_err(ab, \"failed to send firmware start: %d\\n\", ret);\n\t\treturn ret;\n\t}\n\n\treturn ret;\n}\n\nint ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)\n{\n\tint ret;\n\n\tret = ath11k_core_start_firmware(ab, ab->fw_mode);\n\tif (ret) {\n\t\tath11k_err(ab, \"failed to start firmware: %d\\n\", ret);\n\t\treturn ret;\n\t}\n\n\tret = ath11k_ce_init_pipes(ab);\n\tif (ret) {\n\nInstruction:\nwifi: ath11k: validate ath11k_crypto_mode on top of ath11k_core_qmi_firmware_ready\n\nReturn the diff that fixes it:\n @@ -100,6 +100,10 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)\n {\n \tint ret;\n \n+\tif (ab->hw_params.crypto_mode == ATH11K_CRYPTO_MODE_NONE) {\n+\t\tath11k_err(ab, \"invalid crypto mode: %d\\n\",\n+\t\t\t ab->hw_params.crypto_mode);\n+\t\treturn -EINVAL;\n+\t}\n+\n \tret = ath11k_core_start_firmware(ab, ab->fw_mode);\n \tif (ret) {\n \t\tath11k_err(ab, \"failed to start firmware: %d\\n\", ret);\n@@ -108,6 +112,10 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)\n \tif (ret"556 },557 {558 "prompt": "Given the following original C code:\n/* REO cmd ring address */\n\t.hal_reo_cmd_ring_base = 0x0000028c,\n\n\t/* REO status ring address */\n\t.hal_reo_status_ring_base = 0x00000a84,\n\n\t/* CE base address */\n\t.hal_umac_ce0_src_reg_base = 0x01b80000,\n\t.hal_umac_ce0_dest_reg_base = 0x01b81000,\n\t.hal_umac_ce1_src_reg_base = 0x01b82000,\n\t.hal_umac_ce1_dest_reg_base = 0x01b83000,\n};\n\nstatic const struct ath12k_hw_regs qcn9274_v2_regs = {\n\t/* SW2TCL(x) R0 ring configuration address */\n\t.hal_tcl1_ring_id = 0x00000908,\n\t.hal_tcl1_ring_misc = 0x00000910,\n\t.hal_tcl1_ring_tp_addr_lsb = 0x0000091c,\n\t.hal_tcl1_ring_tp_addr_msb = 0x00000920,\n\nInstruction:\nwifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850\n\nReturn the diff that fixes it:\n",559 "reference": "@@ -951,6 +951,8 @@ static const struct ath12k_hw_regs qcn9274_v1_regs = {\n \t.hal_umac_ce0_dest_reg_base = 0x01b81000,\n \t.hal_umac_ce1_src_reg_base = 0x01b82000,\n \t.hal_umac_ce1_dest_reg_base = 0x01b83000,\n+\n+\t.gcc_gcc_pcie_hot_rst = 0x1e38338,\n };\n \n static const struct ath12k_hw_regs qcn9274_v2_regs = {\n@@ -1042,6 +1044,8 @@ static const struct ath12k_hw_regs qcn9274_v2_regs = {\n \t.hal_umac_ce0_dest_reg_base = 0x01b81000,\n \t.hal_umac_ce1_src_reg_base = 0x01b82000,\n \t.hal_umac_ce1_dest_reg_base = 0x01b83000,\n+\n+\t.gcc_gcc_pcie_hot_rst = 0x1e38338,\n };\n \n static const struct ath12k_hw_regs ipq5332_regs = {\n@@ -1215,6 +1219,8 @@ static const struct ath12k_hw_regs wcn7850_regs = {\n \t.hal_umac_ce0_dest_reg_base = 0x01b81000,\n \t.hal_umac_ce1_src_reg_base = 0x01b82000,\n \t.hal_umac_ce1_dest_reg_base = 0x01b83000,\n+\n+\t.gcc_gcc_pcie_hot_rst = 0x1e40304,\n };\n \n static const struct ath12k_hw_hal_params ath12k_hw_hal_params_qcn9274 = {",560 "prediction": "Given the following original C code:\n/* REO cmd ring address */\n\t.hal_reo_cmd_ring_base = 0x0000028c,\n\n\t/* REO status ring address */\n\t.hal_reo_status_ring_base = 0x00000a84,\n\n\t/* CE base address */\n\t.hal_umac_ce0_src_reg_base = 0x01b80000,\n\t.hal_umac_ce0_dest_reg_base = 0x01b81000,\n\t.hal_umac_ce1_src_reg_base = 0x01b82000,\n\t.hal_umac_ce1_dest_reg_base = 0x01b83000,\n};\n\nstatic const struct ath12k_hw_regs qcn9274_v2_regs = {\n\t/* SW2TCL(x) R0 ring configuration address */\n\t.hal_tcl1_ring_id = 0x00000908,\n\t.hal_tcl1_ring_misc = 0x00000910,\n\t.hal_tcl1_ring_tp_addr_lsb = 0x0000091c,\n\t.hal_tcl1_ring_tp_addr_msb = 0x00000920,\n\nInstruction:\nwifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850\n\nReturn the diff that fixes it:\n @@ -101,6 +101,10 @@ static const struct ath12k_hw_regs qcn9074_v2_regs = {\n \t.hal_umac_ce1_dest_reg_base = 0x01b83000,\n \t.hal_umac_ce1_src_reg_base = 0x01b84000,\n \t.hal_umac_ce1_dest_reg_base = 0x01b85000,\n+\n+\t/* PCIe Hot Reset */\n+\t.hal_pcie_hot_reset = 0x00000000,\n+\n };\n \n static const struct ath12k_hw_regs qcn9274_v2_regs = {\n@@ -108,6 +112,10 @@ static const struct ath12k_hw_regs qcn9074_v2_regs = {\n \t.hal_tcl"561 },562 {563 "prompt": "Given the following original C code:\nu32 hal_reo1_aging_thres_ix1;\n\tu32 hal_reo1_aging_thres_ix2;\n\tu32 hal_reo1_aging_thres_ix3;\n\n\tu32 hal_reo2_sw0_ring_base;\n\n\tu32 hal_sw2reo_ring_base;\n\tu32 hal_sw2reo1_ring_base;\n\n\tu32 hal_reo_cmd_ring_base;\n\n\tu32 hal_reo_status_ring_base;\n};\n\nstatic inline const char *ath12k_bd_ie_type_str(enum ath12k_bd_ie_type type)\n{\n\tswitch (type) {\n\tcase ATH12K_BD_IE_BOARD:\n\t\treturn \"board data\";\n\tcase ATH12K_BD_IE_REGDB:\n\nInstruction:\nwifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850\n\nReturn the diff that fixes it:\n",564 "reference": "@@ -375,6 +375,8 @@ struct ath12k_hw_regs {\n \tu32 hal_reo_cmd_ring_base;\n \n \tu32 hal_reo_status_ring_base;\n+\n+\tu32 gcc_gcc_pcie_hot_rst;\n };\n \n static inline const char *ath12k_bd_ie_type_str(enum ath12k_bd_ie_type type)",565 "prediction": "Given the following original C code:\nu32 hal_reo1_aging_thres_ix1;\n\tu32 hal_reo1_aging_thres_ix2;\n\tu32 hal_reo1_aging_thres_ix3;\n\n\tu32 hal_reo2_sw0_ring_base;\n\n\tu32 hal_sw2reo_ring_base;\n\tu32 hal_sw2reo1_ring_base;\n\n\tu32 hal_reo_cmd_ring_base;\n\n\tu32 hal_reo_status_ring_base;\n};\n\nstatic inline const char *ath12k_bd_ie_type_str(enum ath12k_bd_ie_type type)\n{\n\tswitch (type) {\n\tcase ATH12K_BD_IE_BOARD:\n\t\treturn \"board data\";\n\tcase ATH12K_BD_IE_REGDB:\n\nInstruction:\nwifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850\n\nReturn the diff that fixes it:\n @@ -104,6 +104,10 @@ struct ath12k_hw_params {\n \tu32 hal_reo_cmd_ring_base;\n \n \tu32 hal_reo_status_ring_base;\n+\n+#ifdef CONFIG_ATH12K_GCC_PCIE_HOT_RST\n+\tu32 hal_gcc_pcie_hot_rst_base;\n+#endif\n };\n \n static inline const char *ath12k_bd_ie_type_str(enum ath12k_bd_ie_type type)\n@@ -111,6 +115,7 @@ static inline const char *ath12k_bd_ie_type_str(enum ath12k_bd_ie_type type)\n \tcase ATH12K_BD_IE_REGDB:\n \t\treturn \"regulatory database\";\n \tcase ATH12K_BD_IE_CALDATA:\n+\t\treturn \"calibration data\";"566 },567 {568 "prompt": "Given the following original C code:\n/* PCIE link seems very unstable after the Hot Reset*/\n\tfor (i = 0; val != PARM_LTSSM_VALUE && i < 5; i++) {\n\t\tif (val == 0xffffffff)\n\t\t\tmdelay(5);\n\n\t\tath12k_pci_write32(ab, PCIE_PCIE_PARF_LTSSM, PARM_LTSSM_VALUE);\n\t\tval = ath12k_pci_read32(ab, PCIE_PCIE_PARF_LTSSM);\n\t}\n\n\tath12k_dbg(ab, ATH12K_DBG_PCI, \"pci ltssm 0x%x\\n\", val);\n\n\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);\n\tval |= GCC_GCC_PCIE_HOT_RST_VAL;\n\tath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST, val);\n\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);\n\n\tath12k_dbg(ab, ATH12K_DBG_PCI, \"pci pcie_hot_rst 0x%x\\n\", val);\n\n\tmdelay(5);\n\nInstruction:\nwifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850\n\nReturn the diff that fixes it:\n",569 "reference": "@@ -292,10 +292,10 @@ static void ath12k_pci_enable_ltssm(struct ath12k_base *ab)\n \n \tath12k_dbg(ab, ATH12K_DBG_PCI, \"pci ltssm 0x%x\\n\", val);\n \n-\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);\n+\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST(ab));\n \tval |= GCC_GCC_PCIE_HOT_RST_VAL;\n-\tath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST, val);\n-\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);\n+\tath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST(ab), val);\n+\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST(ab));\n \n \tath12k_dbg(ab, ATH12K_DBG_PCI, \"pci pcie_hot_rst 0x%x\\n\", val);",570 "prediction": "Given the following original C code:\n/* PCIE link seems very unstable after the Hot Reset*/\n\tfor (i = 0; val != PARM_LTSSM_VALUE && i < 5; i++) {\n\t\tif (val == 0xffffffff)\n\t\t\tmdelay(5);\n\n\t\tath12k_pci_write32(ab, PCIE_PCIE_PARF_LTSSM, PARM_LTSSM_VALUE);\n\t\tval = ath12k_pci_read32(ab, PCIE_PCIE_PARF_LTSSM);\n\t}\n\n\tath12k_dbg(ab, ATH12K_DBG_PCI, \"pci ltssm 0x%x\\n\", val);\n\n\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);\n\tval |= GCC_GCC_PCIE_HOT_RST_VAL;\n\tath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST, val);\n\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);\n\n\tath12k_dbg(ab, ATH12K_DBG_PCI, \"pci pcie_hot_rst 0x%x\\n\", val);\n\n\tmdelay(5);\n\nInstruction:\nwifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850\n\nReturn the diff that fixes it:\n @@ -104,10 +104,10 @@ static int ath12k_pci_hot_reset(struct ath12k *ab)\n \n \tath12k_dbg(ab, ATH12K_DBG_PCI, \"pci ltssm 0x%x\\n\", val);\n \n-\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST);\n+\tval = ath12k_pci_read32(ab, GCC_GCC_PCIE_HOT_RST_WCN7850);\n \tval |= GCC_GCC_PCIE_HOT_RST_VAL;\n-\tath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST, val);\n+\tath12k_pci_write32(ab, GCC_GCC_PCIE_HOT_RST_"571 },572 {573 "prompt": "Given the following original C code:\n#define PCIE_Q6_COOKIE_ADDR\t\t\t0x01f80500\n#define PCIE_Q6_COOKIE_DATA\t\t\t0xc0000000\n\n/* register to wake the UMAC from power collapse */\n#define PCIE_SCRATCH_0_SOC_PCIE_REG\t\t0x4040\n\n/* register used for handshake mechanism to validate UMAC is awake */\n#define PCIE_SOC_WAKE_PCIE_LOCAL_REG\t\t0x3004\n\n#define PCIE_PCIE_PARF_LTSSM\t\t\t0x1e081b0\n#define PARM_LTSSM_VALUE\t\t\t0x111\n\n#define GCC_GCC_PCIE_HOT_RST\t\t\t0x1e38338\n#define GCC_GCC_PCIE_HOT_RST_VAL\t\t0x10\n\n#define PCIE_PCIE_INT_ALL_CLEAR\t\t\t0x1e08228\n#define PCIE_SMLH_REQ_RST_LINK_DOWN\t\t0x2\n#define PCIE_INT_CLEAR_ALL\t\t\t0xffffffff\n\n#define PCIE_QSERDES_COM_SYSCLK_EN_SEL_REG(ab) \\\n\nInstruction:\nwifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850\n\nReturn the diff that fixes it:\n",574 "reference": "@@ -28,7 +28,9 @@\n #define PCIE_PCIE_PARF_LTSSM\t\t\t0x1e081b0\n #define PARM_LTSSM_VALUE\t\t\t0x111\n \n-#define GCC_GCC_PCIE_HOT_RST\t\t\t0x1e38338\n+#define GCC_GCC_PCIE_HOT_RST(ab) \\\n+\t((ab)->hw_params->regs->gcc_gcc_pcie_hot_rst)\n+\n #define GCC_GCC_PCIE_HOT_RST_VAL\t\t0x10\n \n #define PCIE_PCIE_INT_ALL_CLEAR\t\t\t0x1e08228",575 "prediction": "Given the following original C code:\n#define PCIE_Q6_COOKIE_ADDR\t\t\t0x01f80500\n#define PCIE_Q6_COOKIE_DATA\t\t\t0xc0000000\n\n/* register to wake the UMAC from power collapse */\n#define PCIE_SCRATCH_0_SOC_PCIE_REG\t\t0x4040\n\n/* register used for handshake mechanism to validate UMAC is awake */\n#define PCIE_SOC_WAKE_PCIE_LOCAL_REG\t\t0x3004\n\n#define PCIE_PCIE_PARF_LTSSM\t\t\t0x1e081b0\n#define PARM_LTSSM_VALUE\t\t\t0x111\n\n#define GCC_GCC_PCIE_HOT_RST\t\t\t0x1e38338\n#define GCC_GCC_PCIE_HOT_RST_VAL\t\t0x10\n\n#define PCIE_PCIE_INT_ALL_CLEAR\t\t\t0x1e08228\n#define PCIE_SMLH_REQ_RST_LINK_DOWN\t\t0x2\n#define PCIE_INT_CLEAR_ALL\t\t\t0xffffffff\n\n#define PCIE_QSERDES_COM_SYSCLK_EN_SEL_REG(ab) \\\n\nInstruction:\nwifi: ath12k: fix GCC_GCC_PCIE_HOT_RST definition for WCN7850\n\nReturn the diff that fixes it:\n @@ -106,7 +106,7 @@\n #define PCIE_PCIE_PARF_LTSSM\t\t\t0x1e081b0\n #define PARM_LTSSM_VALUE\t\t\t0x111\n \n-#define GCC_GCC_PCIE_HOT_RST\t\t\t0x1e38338\n+#define GCC_GCC_PCIE_HOT_RST\t\t\t0x1e3833c\n #define GCC_GCC_PCIE_HOT_RST_VAL\t\t0x10\n \n #define PCIE_PCIE_INT_ALL_CLEAR\t\t\t0x1e08228\n@@ -114,7 +114,7 @@\n #define PCIE_SMLH_REQ_RST_LINK_DOWN\t\t0x2\n #define PCIE_INT_CLEAR_ALL\t\t\t0xffffffff\n \n-"576 },577 {578 "prompt": "Given the following original C code:\nHAL_REO_CMD_UNBLOCK_CACHE = 3,\n\tHAL_REO_CMD_FLUSH_TIMEOUT_LIST = 4,\n\tHAL_REO_CMD_UPDATE_RX_QUEUE = 5,\n};\n\n/**\n * enum hal_reo_cmd_status: Enum for execution status of REO command\n * @HAL_REO_CMD_SUCCESS: Command has successfully executed\n * @HAL_REO_CMD_BLOCKED: Command could not be executed as the queue\n *\t\t\t or cache was blocked\n * @HAL_REO_CMD_FAILED: Command execution failed, could be due to\n *\t\t\tinvalid queue desc\n * @HAL_REO_CMD_RESOURCE_BLOCKED:\n * @HAL_REO_CMD_DRAIN:\n */\nenum hal_reo_cmd_status {\n\tHAL_REO_CMD_SUCCESS\t\t= 0,\n\tHAL_REO_CMD_BLOCKED\t\t= 1,\n\tHAL_REO_CMD_FAILED\t\t= 2,\n\tHAL_REO_CMD_RESOURCE_BLOCKED\t= 3,\n\nInstruction:\nwifi: ath12k: Fix hal_reo_cmd_status kernel-doc\n\nReturn the diff that fixes it:\n",579 "reference": "@@ -585,7 +585,8 @@ enum hal_reo_cmd_type {\n *\t\t\t or cache was blocked\n * @HAL_REO_CMD_FAILED: Command execution failed, could be due to\n *\t\t\tinvalid queue desc\n- * @HAL_REO_CMD_RESOURCE_BLOCKED:\n+ * @HAL_REO_CMD_RESOURCE_BLOCKED: Command could not be executed because\n+ *\t\t\t\t one or more descriptors were blocked\n * @HAL_REO_CMD_DRAIN:\n */\n enum hal_reo_cmd_status {",580 "prediction": "Given the following original C code:\nHAL_REO_CMD_UNBLOCK_CACHE = 3,\n\tHAL_REO_CMD_FLUSH_TIMEOUT_LIST = 4,\n\tHAL_REO_CMD_UPDATE_RX_QUEUE = 5,\n};\n\n/**\n * enum hal_reo_cmd_status: Enum for execution status of REO command\n * @HAL_REO_CMD_SUCCESS: Command has successfully executed\n * @HAL_REO_CMD_BLOCKED: Command could not be executed as the queue\n *\t\t\t or cache was blocked\n * @HAL_REO_CMD_FAILED: Command execution failed, could be due to\n *\t\t\tinvalid queue desc\n * @HAL_REO_CMD_RESOURCE_BLOCKED:\n * @HAL_REO_CMD_DRAIN:\n */\nenum hal_reo_cmd_status {\n\tHAL_REO_CMD_SUCCESS\t\t= 0,\n\tHAL_REO_CMD_BLOCKED\t\t= 1,\n\tHAL_REO_CMD_FAILED\t\t= 2,\n\tHAL_REO_CMD_RESOURCE_BLOCKED\t= 3,\n\nInstruction:\nwifi: ath12k: Fix hal_reo_cmd_status kernel-doc\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ enum hal_reo_cmd {\n * @HAL_REO_CMD_FAILED: Command execution failed, could be due to\n *\t\t\tinvalid queue desc\n * @HAL_REO_CMD_RESOURCE_BLOCKED:\n- * @HAL_REO_CMD_DRAIN:\n+ * @HAL_REO_CMD_DRAINED:\n */\n enum hal_reo_cmd_status {\n \tHAL_REO_CMD_SUCCESS\t\t= 0,\n@@ -109,7 +109,7 @@ enum hal_reo_cmd_status {\n \tHAL_REO_CMD_FAILED\t\t= 2,\n \tHAL_REO_CMD_RESOURCE_BLOCKED\t= 3,\n \tHAL_REO_CMD_DRAINED\t\t= 4,\n-\tHAL_REO_CMD_DRA"581 },582 {583 "prompt": "Given the following original C code:\nint ret;\n\n\tret = ath12k_core_panic_notifier_register(ab);\n\tif (ret)\n\t\tath12k_warn(ab, \"failed to register panic handler: %d\\n\", ret);\n\n\tmutex_lock(&ath12k_hw_group_mutex);\n\n\tag = ath12k_core_hw_group_assign(ab);\n\tif (!ag) {\n\t\tmutex_unlock(&ath12k_hw_group_mutex);\n\t\tath12k_warn(ab, \"unable to get hw group\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\tmutex_unlock(&ath12k_hw_group_mutex);\n\n\tmutex_lock(&ag->mutex);\n\n\tath12k_dbg(ab, ATH12K_DBG_BOOT, \"num devices %d num probed %d\\n\",\n\nInstruction:\nwifi: ath12k: fix uaf in ath12k_core_init()\n\nReturn the diff that fixes it:\n",584 "reference": "@@ -2129,7 +2129,8 @@ int ath12k_core_init(struct ath12k_base *ab)\n \tif (!ag) {\n \t\tmutex_unlock(&ath12k_hw_group_mutex);\n \t\tath12k_warn(ab, \"unable to get hw group\\n\");\n-\t\treturn -ENODEV;\n+\t\tret = -ENODEV;\n+\t\tgoto err_unregister_notifier;\n \t}\n \n \tmutex_unlock(&ath12k_hw_group_mutex);\n@@ -2144,7 +2145,7 @@ int ath12k_core_init(struct ath12k_base *ab)\n \t\tif (ret) {\n \t\t\tmutex_unlock(&ag->mutex);\n \t\t\tath12k_warn(ab, \"unable to create hw group\\n\");\n-\t\t\tgoto err;\n+\t\t\tgoto err_destroy_hw_group;\n \t\t}\n \t}\n \n@@ -2152,9 +2153,12 @@ int ath12k_core_init(struct ath12k_base *ab)\n \n \treturn 0;\n \n-err:\n+err_destroy_hw_group:\n \tath12k_core_hw_group_destroy(ab->ag);\n \tath12k_core_hw_group_unassign(ab);\n+err_unregister_notifier:\n+\tath12k_core_panic_notifier_unregister(ab);\n+\n \treturn ret;\n }",585 "prediction": "Given the following original C code:\nint ret;\n\n\tret = ath12k_core_panic_notifier_register(ab);\n\tif (ret)\n\t\tath12k_warn(ab, \"failed to register panic handler: %d\\n\", ret);\n\n\tmutex_lock(&ath12k_hw_group_mutex);\n\n\tag = ath12k_core_hw_group_assign(ab);\n\tif (!ag) {\n\t\tmutex_unlock(&ath12k_hw_group_mutex);\n\t\tath12k_warn(ab, \"unable to get hw group\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\tmutex_unlock(&ath12k_hw_group_mutex);\n\n\tmutex_lock(&ag->mutex);\n\n\tath12k_dbg(ab, ATH12K_DBG_BOOT, \"num devices %d num probed %d\\n\",\n\nInstruction:\nwifi: ath12k: fix uaf in ath12k_core_init()\n\nReturn the diff that fixes it:\n @@ -100,6 +100,7 @@ int ath12k_core_init(struct ath12k *ab)\n \tif (!ag) {\n \t\tmutex_unlock(&ath12k_hw_group_mutex);\n \t\tath12k_warn(ab, \"unable to get hw group\\n\");\n+\t\tgoto err_unlock;\n \t\treturn -ENODEV;\n \t}\n \n@@ -108,6 +109,7 @@ int ath12k_core_init(struct ath12k *ab)\n \tath12k_dbg(ab, ATH12K_DBG_BOOT, \"num devices %d num probed %d\\n\",\n \t\t num_possible_cpus(), num_online_cpus());\n \n+err_unlock:\n \tmutex_unlock(&ag->mutex);\n \tmutex_unlock(&ath12k_hw_group_mutex);\n \n@@ -"586 },587 {588 "prompt": "Given the following original C code:\nreturn 0;\n}\n\nint get_msr_fd(int cpu)\n{\n\tchar pathname[32];\n\tint fd;\n\n\tfd = fd_percpu[cpu];\n\n\tif (fd)\n\t\treturn fd;\n\n\tsprintf(pathname, \"/dev/cpu/%d/msr\", cpu);\n\tfd = open(pathname, O_RDONLY);\n\tif (fd < 0)\n\t\terr(-1, \"%s open failed, try chown or chmod +r /dev/cpu/*/msr, \"\n\t\t \"or run with --no-msr, or run as root\", pathname);\n\n\tfd_percpu[cpu] = fd;\n\nInstruction:\ntools/power turbostat: Add Android support for MSR device handling\n\nReturn the diff that fixes it:\n",589 "reference": "@@ -2140,13 +2140,20 @@ int get_msr_fd(int cpu)\n \n \tif (fd)\n \t\treturn fd;\n-\n+#if defined(ANDROID)\n+\tsprintf(pathname, \"/dev/msr%d\", cpu);\n+#else\n \tsprintf(pathname, \"/dev/cpu/%d/msr\", cpu);\n+#endif\n \tfd = open(pathname, O_RDONLY);\n \tif (fd < 0)\n+#if defined(ANDROID)\n+\t\terr(-1, \"%s open failed, try chown or chmod +r /dev/msr*, \"\n+\t\t \"or run with --no-msr, or run as root\", pathname);\n+#else\n \t\terr(-1, \"%s open failed, try chown or chmod +r /dev/cpu/*/msr, \"\n \t\t \"or run with --no-msr, or run as root\", pathname);\n-\n+#endif\n \tfd_percpu[cpu] = fd;\n \n \treturn fd;\n@@ -6476,8 +6483,11 @@ void check_dev_msr()\n \n \tif (no_msr)\n \t\treturn;\n-\n+#if defined(ANDROID)\n+\tsprintf(pathname, \"/dev/msr%d\", base_cpu);\n+#else\n \tsprintf(pathname, \"/dev/cpu/%d/msr\", base_cpu);\n+#endif\n \tif (stat(pathname, &sb))\n \t\tif (system(\"/sbin/modprobe msr > /dev/null 2>&1\"))\n \t\t\tno_msr = 1;\n@@ -6527,7 +6537,11 @@ void check_msr_permission(void)\n \tfailed += check_for_cap_sys_rawio();\n \n \t/* test file permissions */\n+#if defined(ANDROID)\n+\tsprintf(pathname, \"/dev/msr%d\", base_cpu);\n+#else\n \tsprintf(pathname, \"/dev/cpu/%d/msr\", base_cpu);\n+#endif\n \tif (euidaccess(pathname, R_OK)) {\n \t\tfailed++;\n \t}",590 "prediction": "Given the following original C code:\nreturn 0;\n}\n\nint get_msr_fd(int cpu)\n{\n\tchar pathname[32];\n\tint fd;\n\n\tfd = fd_percpu[cpu];\n\n\tif (fd)\n\t\treturn fd;\n\n\tsprintf(pathname, \"/dev/cpu/%d/msr\", cpu);\n\tfd = open(pathname, O_RDONLY);\n\tif (fd < 0)\n\t\terr(-1, \"%s open failed, try chown or chmod +r /dev/cpu/*/msr, \"\n\t\t \"or run with --no-msr, or run as root\", pathname);\n\n\tfd_percpu[cpu] = fd;\n\nInstruction:\ntools/power turbostat: Add Android support for MSR device handling\n\nReturn the diff that fixes it:\n @@ -109,10 +109,10 @@ int get_msr_fd(int cpu)\n \n \tif (fd)\n \t\treturn fd;\n-\n \tsprintf(pathname, \"/dev/cpu/%d/msr\", cpu);\n \tfd = open(pathname, O_RDONLY);\n \tif (fd < 0)\n+\t\terr(-1, \"%s open failed, try chown or chmod +r /dev/cpu/*/msr, \"\n+\t\t \"or run with --no-msr, or run as root\", pathname);\n \n \tfd_percpu[cpu] = fd;\n \treturn fd;\n@@ -124,10 +124,10 @@ int get_msr_fd(int cpu)\n \n \tif (fd)\n \t\treturn fd;\n-\n \tsprintf(pathname, \"/dev/cpu/%d/msr\", cpu);\n \tfd = open(pathname, O_R"591 },592 {593 "prompt": "Given the following original C code:\nRAPL_PLATFORM_ENERGY_STATUS = BIT(18),\t/* 0x64d MSR_PLATFORM_ENERGY_STATUS */\n};\n\n#define RAPL_PKG\t(RAPL_PKG_ENERGY_STATUS | RAPL_PKG_POWER_LIMIT)\n#define RAPL_DRAM\t(RAPL_DRAM_ENERGY_STATUS | RAPL_DRAM_POWER_LIMIT)\n#define RAPL_CORE\t(RAPL_CORE_ENERGY_STATUS | RAPL_CORE_POWER_LIMIT)\n#define RAPL_GFX\t(RAPL_GFX_POWER_LIMIT | RAPL_GFX_ENERGY_STATUS)\n#define RAPL_PSYS\t(RAPL_PLATFORM_ENERGY_STATUS | RAPL_PLATFORM_ENERGY_LIMIT)\n\n#define RAPL_PKG_ALL\t(RAPL_PKG | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO)\n#define RAPL_DRAM_ALL\t(RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_DRAM_POWER_INFO)\n#define RAPL_CORE_ALL\t(RAPL_CORE | RAPL_CORE_POLICY)\n#define RAPL_GFX_ALL\t(RAPL_GFX | RAPL_GFX_POLIGY)\n\n#define RAPL_AMD_F17H\t(RAPL_AMD_PWR_UNIT | RAPL_AMD_CORE_ENERGY_STAT | RAPL_AMD_PKG_ENERGY_STAT)\n\n/* For Cstates */\nenum cstates {\n\tCC1 = BIT(0),\n\tCC3 = BIT(1),\n\nInstruction:\ntools/power turbostat: Fix RAPL_GFX_ALL typo\n\nReturn the diff that fixes it:\n",594 "reference": "@@ -539,7 +539,7 @@ enum rapl_msrs {\n #define RAPL_PKG_ALL\t(RAPL_PKG | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO)\n #define RAPL_DRAM_ALL\t(RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_DRAM_POWER_INFO)\n #define RAPL_CORE_ALL\t(RAPL_CORE | RAPL_CORE_POLICY)\n-#define RAPL_GFX_ALL\t(RAPL_GFX | RAPL_GFX_POLIGY)\n+#define RAPL_GFX_ALL\t(RAPL_GFX | RAPL_GFX_POLICY)\n \n #define RAPL_AMD_F17H\t(RAPL_AMD_PWR_UNIT | RAPL_AMD_CORE_ENERGY_STAT | RAPL_AMD_PKG_ENERGY_STAT)",595 "prediction": "Given the following original C code:\nRAPL_PLATFORM_ENERGY_STATUS = BIT(18),\t/* 0x64d MSR_PLATFORM_ENERGY_STATUS */\n};\n\n#define RAPL_PKG\t(RAPL_PKG_ENERGY_STATUS | RAPL_PKG_POWER_LIMIT)\n#define RAPL_DRAM\t(RAPL_DRAM_ENERGY_STATUS | RAPL_DRAM_POWER_LIMIT)\n#define RAPL_CORE\t(RAPL_CORE_ENERGY_STATUS | RAPL_CORE_POWER_LIMIT)\n#define RAPL_GFX\t(RAPL_GFX_POWER_LIMIT | RAPL_GFX_ENERGY_STATUS)\n#define RAPL_PSYS\t(RAPL_PLATFORM_ENERGY_STATUS | RAPL_PLATFORM_ENERGY_LIMIT)\n\n#define RAPL_PKG_ALL\t(RAPL_PKG | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO)\n#define RAPL_DRAM_ALL\t(RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_DRAM_POWER_INFO)\n#define RAPL_CORE_ALL\t(RAPL_CORE | RAPL_CORE_POLICY)\n#define RAPL_GFX_ALL\t(RAPL_GFX | RAPL_GFX_POLIGY)\n\n#define RAPL_AMD_F17H\t(RAPL_AMD_PWR_UNIT | RAPL_AMD_CORE_ENERGY_STAT | RAPL_AMD_PKG_ENERGY_STAT)\n\n/* For Cstates */\nenum cstates {\n\tCC1 = BIT(0),\n\tCC3 = BIT(1),\n\nInstruction:\ntools/power turbostat: Fix RAPL_GFX_ALL typo\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ enum rapl_msr {\n #define RAPL_PKG_ALL\t(RAPL_PKG | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO)\n #define RAPL_DRAM_ALL\t(RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_DRAM_POWER_INFO)\n #define RAPL_CORE_ALL\t(RAPL_CORE | RAPL_CORE_POLICY)\n-#define RAPL_GFX_ALL\t(RAPL_GFX | RAPL_GFX_POLIGY)\n+#define RAPL_GFX_ALL\t(RAPL_GFX | RAPL_GFX_POLICY)\n \n #define RAPL_AMD_F17H\t(RAPL_AMD_PWR_UNIT | RAPL_AMD_CORE_ENERG"596 },597 {598 "prompt": "Given the following original C code:\n{\n\tif (domain_id >= ppmt->num_domains)\n\t\treturn 0;\n\n\tconst unsigned long *pmmio = ppmt->domains[domain_id].pcounter;\n\tconst unsigned long value = pmmio ? *pmmio : 0;\n\tconst unsigned long value_mask = pmt_gen_value_mask(ppmt->lsb, ppmt->msb);\n\tconst unsigned long value_shift = ppmt->lsb;\n\n\treturn (value & value_mask) >> value_shift;\n}\n\n/*\n * get_counters(...)\n * migrate to cpu\n * acquire and record local counters for that cpu\n */\nint get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)\n{\n\tint cpu = t->cpu_id;\n\nInstruction:\ntools/power turbostat: Fix AMD package-energy reporting\n\nReturn the diff that fixes it:\n",599 "reference": "@@ -4773,6 +4773,38 @@ unsigned long pmt_read_counter(struct pmt_counter *ppmt, unsigned int domain_id)\n \treturn (value & value_mask) >> value_shift;\n }\n \n+\n+/* Rapl domain enumeration helpers */\n+static inline int get_rapl_num_domains(void)\n+{\n+\tint num_packages = topo.max_package_id + 1;\n+\tint num_cores_per_package;\n+\tint num_cores;\n+\n+\tif (!platform->has_per_core_rapl)\n+\t\treturn num_packages;\n+\n+\tnum_cores_per_package = topo.max_core_id + 1;\n+\tnum_cores = num_cores_per_package * num_packages;\n+\n+\treturn num_cores;\n+}\n+\n+static inline int get_rapl_domain_id(int cpu)\n+{\n+\tint nr_cores_per_package = topo.max_core_id + 1;\n+\tint rapl_core_id;\n+\n+\tif (!platform->has_per_core_rapl)\n+\t\treturn cpus[cpu].physical_package_id;\n+\n+\t/* Compute the system-wide unique core-id for @cpu */\n+\trapl_core_id = cpus[cpu].physical_core_id;\n+\trapl_core_id += cpus[cpu].physical_package_id * nr_cores_per_package;\n+\n+\treturn rapl_core_id;\n+}\n+\n /*\n * get_counters(...)\n * migrate to cpu\n@@ -4828,7 +4860,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)\n \t\tgoto done;\n \n \tif (platform->has_per_core_rapl) {\n-\t\tstatus = get_rapl_counters(cpu, c->core_id, c, p);\n+\t\tstatus = get_rapl_counters(cpu, get_rapl_domain_id(cpu), c, p);\n \t\tif (status != 0)\n \t\t\treturn status;\n \t}\n@@ -4894,7 +4926,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)\n \t\tp->sys_lpi = cpuidle_cur_sys_lpi_us;\n \n \tif (!platform->has_per_core_rapl) {\n-\t\tstatus = get_rapl_counters(cpu, p->package_id, c, p);\n+\t\tstatus = get_rapl_counters(cpu, get_rapl_domain_id(cpu), c, p);\n \t\tif (status != 0)\n \t\t\treturn status;\n \t}\n@@ -7877,7 +7909,7 @@ void linux_perf_init(void)\n \n void rapl_perf_init(void)\n {\n-\tconst unsigned int num_domains = (platform->has_per_core_rapl ? topo.max_core_id : topo.max_package_id) + 1;\n+\tconst unsigned int num_domains = get_rapl_num_domains();\n \tbool *domain_visited = calloc(num_domains, sizeof(bool));\n \n \trapl_counter_info_perdomain = calloc(num_domains, sizeof(*rapl_counter_info_perdomain));\n@@ -7918,8 +7950,7 @@ void rapl_perf_init(void)\n \t\t\t\tcontinue;\n \n \t\t\t/* Skip already seen and handled RAPL domains */\n-\t\t\tnext_domain =\n-\t\t\t platform->has_per_core_rapl ? cpus[cpu].physical_core_id : cpus[cpu].physical_package_id;\n+\t\t\tnext_domain = get_rapl_domain_id(cpu);\n \n \t\t\tassert(next_domain < num_domains);",600 "prediction": "Given the following original C code:\n{\n\tif (domain_id >= ppmt->num_domains)\n\t\treturn 0;\n\n\tconst unsigned long *pmmio = ppmt->domains[domain_id].pcounter;\n\tconst unsigned long value = pmmio ? *pmmio : 0;\n\tconst unsigned long value_mask = pmt_gen_value_mask(ppmt->lsb, ppmt->msb);\n\tconst unsigned long value_shift = ppmt->lsb;\n\n\treturn (value & value_mask) >> value_shift;\n}\n\n/*\n * get_counters(...)\n * migrate to cpu\n * acquire and record local counters for that cpu\n */\nint get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)\n{\n\tint cpu = t->cpu_id;\n\nInstruction:\ntools/power turbostat: Fix AMD package-energy reporting\n\nReturn the diff that fixes it:\n @@ -106,6 +106,10 @@ static unsigned long get_pmc_value(struct ppmt *ppmt, unsigned int domain_id)\n \treturn (value & value_mask) >> value_shift;\n }\n \n+static unsigned long get_amd_pmc_value(struct ppmt *ppmt, unsigned int domain_id)\n+{\n+\treturn get_pmc_value(ppmt, domain_id);\n+}\n+\n /*\n * get_counters(...)\n * migrate to cpu\n@@ -113,6 +117,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)\n \tint cpu = t->cpu_id;\n \tint i;\n \n+\tif (ppmt->is_amd)\n+\t\treturn get_amd_pmc_value(ppmt, domain_id);\n \tfor (i = 0; i < ppmt->num_domains; i++) {"601 },602 {603 "prompt": "Given the following original C code:\nif (fd != -1)\n\t\tclose(fd);\n\n\tif (!has_access)\n\t\twarnx(\"Failed to access %s. Some of the counters may not be available\\n\"\n\t\t \"\\tRun as root to enable them or use %s to disable the access explicitly\",\n\t\t \"instructions retired perf counter\", \"--no-perf\");\n\n\treturn has_access;\n}\n\nint add_rapl_perf_counter_(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,\n\t\t\t double *scale_, enum rapl_unit *unit_)\n{\n\tif (no_perf)\n\t\treturn -1;\n\n\tconst double scale = read_perf_scale(cai->perf_subsys, cai->perf_name);\n\nInstruction:\ntools/power turbostat: Remove add_rapl_perf_counter_()\n\nReturn the diff that fixes it:\n",604 "reference": "@@ -7853,44 +7853,39 @@ static int has_instr_count_access(void)\n \treturn has_access;\n }\n \n-int add_rapl_perf_counter_(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,\n+int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,\n \t\t\t double *scale_, enum rapl_unit *unit_)\n {\n+\tint ret = -1;\n+\n \tif (no_perf)\n \t\treturn -1;\n \n \tconst double scale = read_perf_scale(cai->perf_subsys, cai->perf_name);\n \n \tif (scale == 0.0)\n-\t\treturn -1;\n+\t\tgoto end;\n \n \tconst enum rapl_unit unit = read_perf_rapl_unit(cai->perf_subsys, cai->perf_name);\n \n \tif (unit == RAPL_UNIT_INVALID)\n-\t\treturn -1;\n+\t\tgoto end;\n \n \tconst unsigned int rapl_type = read_perf_type(cai->perf_subsys);\n \tconst unsigned int rapl_energy_pkg_config = read_perf_config(cai->perf_subsys, cai->perf_name);\n \n-\tconst int fd_counter =\n-\t open_perf_counter(cpu, rapl_type, rapl_energy_pkg_config, rci->fd_perf, PERF_FORMAT_GROUP);\n-\tif (fd_counter == -1)\n-\t\treturn -1;\n+\tret = open_perf_counter(cpu, rapl_type, rapl_energy_pkg_config, rci->fd_perf, PERF_FORMAT_GROUP);\n+\tif (ret == -1)\n+\t\tgoto end;\n \n \t/* If it's the first counter opened, make it a group descriptor */\n \tif (rci->fd_perf == -1)\n-\t\trci->fd_perf = fd_counter;\n+\t\trci->fd_perf = ret;\n \n \t*scale_ = scale;\n \t*unit_ = unit;\n-\treturn fd_counter;\n-}\n-\n-int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,\n-\t\t\t double *scale, enum rapl_unit *unit)\n-{\n-\tint ret = add_rapl_perf_counter_(cpu, rci, cai, scale, unit);\n \n+end:\n \tif (debug >= 2)\n \t\tfprintf(stderr, \"%s: %d (cpu: %d)\\n\", __func__, ret, cpu);",605 "prediction": "Given the following original C code:\nif (fd != -1)\n\t\tclose(fd);\n\n\tif (!has_access)\n\t\twarnx(\"Failed to access %s. Some of the counters may not be available\\n\"\n\t\t \"\\tRun as root to enable them or use %s to disable the access explicitly\",\n\t\t \"instructions retired perf counter\", \"--no-perf\");\n\n\treturn has_access;\n}\n\nint add_rapl_perf_counter_(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,\n\t\t\t double *scale_, enum rapl_unit *unit_)\n{\n\tif (no_perf)\n\t\treturn -1;\n\n\tconst double scale = read_perf_scale(cai->perf_subsys, cai->perf_name);\n\nInstruction:\ntools/power turbostat: Remove add_rapl_perf_counter_()\n\nReturn the diff that fixes it:\n @@ -100,11 +100,6 @@ static int has_perf_access(void)\n \treturn has_access;\n }\n \n-int add_rapl_perf_counter_(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,\n-\t\t\t double *scale_, enum rapl_unit *unit_)\n-{\n-\tif (no_perf)\n-\t\treturn -1;\n-\n \tconst double scale = read_perf_scale(cai->perf_subsys, cai->perf_name);\n \tconst enum rapl_unit unit = read_perf_unit(cai->perf_subsys, cai->perf_name);\n \n@@ -114,7 +109,6 @@ int add_rapl_perf_counter_(int cpu, struct rapl_counter_info_t *rci, const struct\n \t\treturn -1;\n \t}\n \n-\t*"606 },607 {608 "prompt": "Given the following original C code:\nint *get_cstate_perf_group_fd(struct cstate_counter_info_t *cci, const char *group_name)\n{\n\tif (strcmp(group_name, \"cstate_core\") == 0)\n\t\treturn &cci->fd_perf_core;\n\n\tif (strcmp(group_name, \"cstate_pkg\") == 0)\n\t\treturn &cci->fd_perf_pkg;\n\n\treturn NULL;\n}\n\nint add_cstate_perf_counter_(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)\n{\n\tif (no_perf)\n\t\treturn -1;\n\n\tint *pfd_group = get_cstate_perf_group_fd(cci, cai->perf_subsys);\n\n\tif (pfd_group == NULL)\n\nInstruction:\ntools/power turbostat: Remove add_cstate_perf_counter_()\n\nReturn the diff that fixes it:\n",609 "reference": "@@ -8021,35 +8021,31 @@ int *get_cstate_perf_group_fd(struct cstate_counter_info_t *cci, const char *gro\n \treturn NULL;\n }\n \n-int add_cstate_perf_counter_(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)\n+int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)\n {\n+\tint ret = -1;\n+\n \tif (no_perf)\n \t\treturn -1;\n \n \tint *pfd_group = get_cstate_perf_group_fd(cci, cai->perf_subsys);\n \n \tif (pfd_group == NULL)\n-\t\treturn -1;\n+\t\tgoto end;\n \n \tconst unsigned int type = read_perf_type(cai->perf_subsys);\n \tconst unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);\n \n-\tconst int fd_counter = open_perf_counter(cpu, type, config, *pfd_group, PERF_FORMAT_GROUP);\n+\tret = open_perf_counter(cpu, type, config, *pfd_group, PERF_FORMAT_GROUP);\n \n-\tif (fd_counter == -1)\n-\t\treturn -1;\n+\tif (ret == -1)\n+\t\tgoto end;\n \n \t/* If it's the first counter opened, make it a group descriptor */\n \tif (*pfd_group == -1)\n-\t\t*pfd_group = fd_counter;\n-\n-\treturn fd_counter;\n-}\n-\n-int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)\n-{\n-\tint ret = add_cstate_perf_counter_(cpu, cci, cai);\n+\t\t*pfd_group = ret;\n \n+end:\n \tif (debug >= 2)\n \t\tfprintf(stderr, \"%s: %d (cpu: %d)\\n\", __func__, ret, cpu);",610 "prediction": "Given the following original C code:\nint *get_cstate_perf_group_fd(struct cstate_counter_info_t *cci, const char *group_name)\n{\n\tif (strcmp(group_name, \"cstate_core\") == 0)\n\t\treturn &cci->fd_perf_core;\n\n\tif (strcmp(group_name, \"cstate_pkg\") == 0)\n\t\treturn &cci->fd_perf_pkg;\n\n\treturn NULL;\n}\n\nint add_cstate_perf_counter_(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)\n{\n\tif (no_perf)\n\t\treturn -1;\n\n\tint *pfd_group = get_cstate_perf_group_fd(cci, cai->perf_subsys);\n\n\tif (pfd_group == NULL)\n\nInstruction:\ntools/power turbostat: Remove add_cstate_perf_counter_()\n\nReturn the diff that fixes it:\n @@ -100,11 +100,6 @@ int *get_cstate_perf_group_fd(struct cstate_counter_info_t *cci, const char *gro\n \treturn NULL;\n }\n \n-int add_cstate_perf_counter_(int cpu, struct cstate_counter_info_t *cci, const struct cstate_counter_arch_info *cai)\n-{\n-\tif (no_perf)\n-\t\treturn -1;\n-\n \tint *pfd_group = get_cstate_perf_group_fd(cci, cai->perf_subsys);\n \n \tif (pfd_group == NULL)\n@@ -114,11 +109,6 @@ int add_cstate_perf_counter_(int cpu, struct cstate_counter_info_t *cci, const s\n \t\treturn -1;\n \t}\n \n-\tif (*pfd_group == -1) {\n-\t\t*pfd_group"611 },612 {613 "prompt": "Given the following original C code:\n/* If it's the first counter opened, make it a group descriptor */\n\tif (*pfd_group == -1)\n\t\t*pfd_group = ret;\n\nend:\n\tif (debug >= 2)\n\t\tfprintf(stderr, \"%s: %d (cpu: %d)\\n\", __func__, ret, cpu);\n\n\treturn ret;\n}\n\nint add_msr_perf_counter_(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)\n{\n\tif (no_perf)\n\t\treturn -1;\n\n\tconst unsigned int type = read_perf_type(cai->perf_subsys);\n\tconst unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);\n\nInstruction:\ntools/power turbostat: Remove add_msr_perf_counter_()\n\nReturn the diff that fixes it:\n",614 "reference": "@@ -8052,30 +8052,26 @@ int add_cstate_perf_counter(int cpu, struct cstate_counter_info_t *cci, const st\n \treturn ret;\n }\n \n-int add_msr_perf_counter_(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)\n+int add_msr_perf_counter(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)\n {\n+\tint ret = -1;\n+\n \tif (no_perf)\n \t\treturn -1;\n \n \tconst unsigned int type = read_perf_type(cai->perf_subsys);\n \tconst unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);\n \n-\tconst int fd_counter = open_perf_counter(cpu, type, config, cci->fd_perf, PERF_FORMAT_GROUP);\n+\tret = open_perf_counter(cpu, type, config, cci->fd_perf, PERF_FORMAT_GROUP);\n \n-\tif (fd_counter == -1)\n-\t\treturn -1;\n+\tif (ret == -1)\n+\t\tgoto end;\n \n \t/* If it's the first counter opened, make it a group descriptor */\n \tif (cci->fd_perf == -1)\n-\t\tcci->fd_perf = fd_counter;\n-\n-\treturn fd_counter;\n-}\n-\n-int add_msr_perf_counter(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)\n-{\n-\tint ret = add_msr_perf_counter_(cpu, cci, cai);\n+\t\tcci->fd_perf = ret;\n \n+end:\n \tif (debug)\n \t\tfprintf(stderr, \"%s: %s/%s: %d (cpu: %d)\\n\", __func__, cai->perf_subsys, cai->perf_name, ret, cpu);",615 "prediction": "Given the following original C code:\n/* If it's the first counter opened, make it a group descriptor */\n\tif (*pfd_group == -1)\n\t\t*pfd_group = ret;\n\nend:\n\tif (debug >= 2)\n\t\tfprintf(stderr, \"%s: %d (cpu: %d)\\n\", __func__, ret, cpu);\n\n\treturn ret;\n}\n\nint add_msr_perf_counter_(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)\n{\n\tif (no_perf)\n\t\treturn -1;\n\n\tconst unsigned int type = read_perf_type(cai->perf_subsys);\n\tconst unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);\n\nInstruction:\ntools/power turbostat: Remove add_msr_perf_counter_()\n\nReturn the diff that fixes it:\n @@ -100,11 +100,6 @@ int add_msr_perf_counter(int cpu, struct msr_counter_info_t *cci, const struct\n \treturn ret;\n }\n \n-int add_msr_perf_counter_(int cpu, struct msr_counter_info_t *cci, const struct msr_counter_arch_info *cai)\n-{\n-\tif (no_perf)\n-\t\treturn -1;\n-\n \tconst unsigned int type = read_perf_type(cai->perf_subsys);\n \tconst unsigned int config = read_perf_config(cai->perf_subsys, cai->perf_name);\n \n@@ -114,7 +109,6 @@ int add_msr_perf_counter_(int cpu, struct msr_counter_info_t *cci, const struct\n \t\treturn -1;\n \t}\n \n-\treturn add_msr_perf_counter(cpu,"616 },617 {618 "prompt": "Given the following original C code:\nassert(next_domain < num_domains);\n\n\t\t\tif (domain_visited[next_domain])\n\t\t\t\tcontinue;\n\n\t\t\tdomain_visited[next_domain] = 1;\n\n\t\t\tif ((cai->flags & RAPL_COUNTER_FLAG_PLATFORM_COUNTER) && (cpu != base_cpu))\n\t\t\t\tcontinue;\n\n\t\t\tstruct rapl_counter_info_t *rci = &rapl_counter_info_perdomain[next_domain];\n\n\t\t\t/* Use perf API for this counter */\n\t\t\tif (add_rapl_perf_counter(cpu, rci, cai, &scale, &unit) != -1) {\n\t\t\t\trci->source[cai->rci_index] = COUNTER_SOURCE_PERF;\n\t\t\t\trci->scale[cai->rci_index] = scale * cai->compat_scale;\n\t\t\t\trci->unit[cai->rci_index] = unit;\n\t\t\t\trci->flags[cai->rci_index] = cai->flags;\n\n\t\t\t/* Use MSR for this counter */\n\nInstruction:\ntools/power turbostat: Avoid probing the same perf counters\n\nReturn the diff that fixes it:\n",619 "reference": "@@ -7991,6 +7991,21 @@ void rapl_perf_init(void)\n \n \t\t\tstruct rapl_counter_info_t *rci = &rapl_counter_info_perdomain[next_domain];\n \n+\t\t\t/*\n+\t\t\t * rapl_counter_arch_infos[] can have multiple entries describing the same\n+\t\t\t * counter, due to the difference from different platforms/Vendors.\n+\t\t\t * E.g. rapl_counter_arch_infos[0] and rapl_counter_arch_infos[1] share the\n+\t\t\t * same perf_subsys and perf_name, but with different MSR address.\n+\t\t\t * rapl_counter_arch_infos[0] is for Intel and rapl_counter_arch_infos[1]\n+\t\t\t * is for AMD.\n+\t\t\t * In this case, it is possible that multiple rapl_counter_arch_infos[]\n+\t\t\t * entries are probed just because their perf/msr is duplicate and valid.\n+\t\t\t *\n+\t\t\t * Thus need a check to avoid re-probe the same counters.\n+\t\t\t */\n+\t\t\tif (rci->source[cai->rci_index] != COUNTER_SOURCE_NONE)\n+\t\t\t\tbreak;\n+\n \t\t\t/* Use perf API for this counter */\n \t\t\tif (add_rapl_perf_counter(cpu, rci, cai, &scale, &unit) != -1) {\n \t\t\t\trci->source[cai->rci_index] = COUNTER_SOURCE_PERF;",620 "prediction": "Given the following original C code:\nassert(next_domain < num_domains);\n\n\t\t\tif (domain_visited[next_domain])\n\t\t\t\tcontinue;\n\n\t\t\tdomain_visited[next_domain] = 1;\n\n\t\t\tif ((cai->flags & RAPL_COUNTER_FLAG_PLATFORM_COUNTER) && (cpu != base_cpu))\n\t\t\t\tcontinue;\n\n\t\t\tstruct rapl_counter_info_t *rci = &rapl_counter_info_perdomain[next_domain];\n\n\t\t\t/* Use perf API for this counter */\n\t\t\tif (add_rapl_perf_counter(cpu, rci, cai, &scale, &unit) != -1) {\n\t\t\t\trci->source[cai->rci_index] = COUNTER_SOURCE_PERF;\n\t\t\t\trci->scale[cai->rci_index] = scale * cai->compat_scale;\n\t\t\t\trci->unit[cai->rci_index] = unit;\n\t\t\t\trci->flags[cai->rci_index] = cai->flags;\n\n\t\t\t/* Use MSR for this counter */\n\nInstruction:\ntools/power turbostat: Avoid probing the same perf counters\n\nReturn the diff that fixes it:\n @@ -108,6 +108,10 @@ static int add_rapl_perf_counters(int base_cpu)\n \t\t\t\tcontinue;\n \n \t\t\tstruct rapl_counter_info_t *rci = &rapl_counter_info_perdomain[next_domain];\n+\n+\t\t\tif (rci->source[cai->rci_index] == COUNTER_SOURCE_PERF)\n+\t\t\t\tcontinue;\n+\n \t\t\t/* Use perf API for this counter */\n \t\t\tif (add_rapl_perf_counter(cpu, rci, cai, &scale, &unit) != -1) {\n \t\t\t\trci->source[cai->rci_index] = COUNTER_SOURCE_PERF;\n@@ -116,6 +120,7 @@ static int add_rapl_perf_counters(int base_cpu)\n \t\t\t\trci->scale[cai->rci_index]"621 },622 {623 "prompt": "Given the following original C code:\n#define\tBIC_Diec6\t\t(1ULL << 58)\n#define\tBIC_SysWatt\t\t(1ULL << 59)\n#define\tBIC_Sys_J\t\t(1ULL << 60)\n#define\tBIC_NMI\t\t\t(1ULL << 61)\n#define\tBIC_CPU_c1e\t\t(1ULL << 62)\n#define\tBIC_pct_idle\t\t(1ULL << 63)\n\n#define BIC_GROUP_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die)\n#define BIC_GROUP_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)\n#define BIC_GROUP_FREQUENCY (BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz | BIC_SAMMHz | BIC_SAMACTMHz | BIC_UNCORE_MHZ)\n#define BIC_GROUP_HW_IDLE (BIC_Busy | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX | BIC_SAM_mc6 | BIC_Diec6)\n#define BIC_GROUP_SW_IDLE (BIC_Busy | BIC_cpuidle | BIC_pct_idle )\n#define BIC_GROUP_IDLE (BIC_GROUP_HW_IDLE | BIC_pct_idle) \n#define BIC_OTHER (BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)\n\n#define BIC_DISABLED_BY_DEFAULT\t(BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC | BIC_cpuidle)\n\nunsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT);\nunsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_cpuidle | BIC_pct_idle | BIC_APIC | BIC_X2APIC;\n\nInstruction:\ntools/power turbostat: version 2025.06.08\n\nReturn the diff that fixes it:\n",624 "reference": "@@ -280,7 +280,7 @@ struct msr_counter bic[] = {\n #define BIC_GROUP_FREQUENCY (BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz | BIC_SAMMHz | BIC_SAMACTMHz | BIC_UNCORE_MHZ)\n #define BIC_GROUP_HW_IDLE (BIC_Busy | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX | BIC_SAM_mc6 | BIC_Diec6)\n #define BIC_GROUP_SW_IDLE (BIC_Busy | BIC_cpuidle | BIC_pct_idle )\n-#define BIC_GROUP_IDLE (BIC_GROUP_HW_IDLE | BIC_pct_idle) \n+#define BIC_GROUP_IDLE (BIC_GROUP_HW_IDLE | BIC_pct_idle)\n #define BIC_OTHER (BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)\n \n #define BIC_DISABLED_BY_DEFAULT\t(BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC | BIC_cpuidle)\n@@ -1091,7 +1091,6 @@ void probe_platform_features(unsigned int family, unsigned int model)\n {\n \tint i;\n \n-\n \tif (authentic_amd || hygon_genuine) {\n \t\t/* fallback to default features on unsupported models */\n \t\tforce_load++;\n@@ -1125,8 +1124,7 @@ void probe_platform_features(unsigned int family, unsigned int model)\n \tif (platform)\n \t\treturn;\n \n-\tfprintf(stderr, \"Unsupported platform detected.\\n\"\n-\t\t\"\\tSee RUN THE LATEST VERSION on turbostat(8)\\n\");\n+\tfprintf(stderr, \"Unsupported platform detected.\\n\\tSee RUN THE LATEST VERSION on turbostat(8)\\n\");\n \texit(1);\n }\n \n@@ -1146,7 +1144,8 @@ char *progname;\n \n #define CPU_SUBSET_MAXCPUS\t8192\t/* need to use before probe... */\n cpu_set_t *cpu_present_set, *cpu_possible_set, *cpu_effective_set, *cpu_allowed_set, *cpu_affinity_set, *cpu_subset;\n-size_t cpu_present_setsize, cpu_possible_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affinity_setsize, cpu_subset_size;\n+size_t cpu_present_setsize, cpu_possible_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affinity_setsize,\n+ cpu_subset_size;\n #define MAX_ADDED_THREAD_COUNTERS 24\n #define MAX_ADDED_CORE_COUNTERS 8\n #define MAX_ADDED_PACKAGE_COUNTERS 16\n@@ -2373,8 +2372,7 @@ void help(void)\n \t\t\"\t\t degrees Celsius\\n\"\n \t\t\" -h, --help\\n\"\n \t\t\"\t\tprint this help message\\n\"\n-\t\t\" -v, --version\\n\"\n-\t\t\"\t\tprint version information\\n\\nFor more help, run \\\"man turbostat\\\"\\n\");\n+\t\t\" -v, --version\\n\\t\\tprint version information\\n\\nFor more help, run \\\"man turbostat\\\"\\n\");\n }\n \n /*\n@@ -3989,7 +3987,6 @@ void compute_average(struct thread_data *t, struct core_data *c, struct pkg_data\n \tif (average.threads.nmi_count > 9999999)\n \t\tsums_need_wide_columns = 1;\n \n-\n \taverage.cores.c3 /= topo.allowed_cores;\n \taverage.cores.c6 /= topo.allowed_cores;\n \taverage.cores.c7 /= topo.allowed_cores;\n@@ -4812,7 +4809,6 @@ unsigned long pmt_read_counter(struct pmt_counter *ppmt, unsigned int domain_id)\n \treturn (value & value_mask) >> value_shift;\n }\n \n-\n /* Rapl domain enumeration helpers */\n static inline int get_rapl_num_domains(void)\n {\n@@ -6822,8 +6818,10 @@ static void probe_intel_uncore_frequency_cluster(void)\n \t\t * This allows \"--show/--hide UncMHz\" to be effective for\n \t\t * the clustered MHz counters, as a group.\n \t\t */\n-\t\tif BIC_IS_ENABLED(BIC_UNCORE_MHZ)\n-\t\t\tadd_counter(0, path, name_buf, 0, SCOPE_PACKAGE, COUNTER_K2M, FORMAT_AVERAGE, 0, package_id);\n+\t\tif BIC_IS_ENABLED\n+\t\t\t(BIC_UNCORE_MHZ)\n+\t\t\t add_counter(0, path, name_buf, 0, SCOPE_PACKAGE, COUNTER_K2M, FORMAT_AVERAGE, 0,\n+\t\t\t\t\tpackage_id);\n \n \t\tif (quiet)\n \t\t\tcontinue;\n@@ -6895,17 +6893,21 @@ static void probe_graphics(void)\n \t\telse\n \t\t\tgoto next;\n \n-\t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt0/gtidle/idle_residency_ms\", gt0_is_gt ? GFX_rc6 : SAM_mc6);\n+\t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt0/gtidle/idle_residency_ms\",\n+\t\t\t\tgt0_is_gt ? GFX_rc6 : SAM_mc6);\n \n \t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt0/freq0/cur_freq\", gt0_is_gt ? GFX_MHz : SAM_MHz);\n \n-\t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt0/freq0/act_freq\", gt0_is_gt ? GFX_ACTMHz : SAM_ACTMHz);\n+\t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt0/freq0/act_freq\",\n+\t\t\t\tgt0_is_gt ? GFX_ACTMHz : SAM_ACTMHz);\n \n-\t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt1/gtidle/idle_residency_ms\", gt0_is_gt ? SAM_mc6 : GFX_rc6);\n+\t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt1/gtidle/idle_residency_ms\",\n+\t\t\t\tgt0_is_gt ? SAM_mc6 : GFX_rc6);\n \n \t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt1/freq0/cur_freq\", gt0_is_gt ? SAM_MHz : GFX_MHz);\n \n-\t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt1/freq0/act_freq\", gt0_is_gt ? SAM_ACTMHz : GFX_ACTMHz);\n+\t\tset_graphics_fp(\"/sys/class/drm/card0/device/tile0/gt1/freq0/act_freq\",\n+\t\t\t\tgt0_is_gt ? SAM_ACTMHz : GFX_ACTMHz);\n \n \t\tgoto end;\n \t}\n@@ -7428,7 +7430,7 @@ static int fread_int(char *path, int *val)\n \tFILE *filep;\n \tint ret;\n \n-\tfilep = fopen (path, \"r\");\n+\tfilep = fopen(path, \"r\");\n \tif (!filep)\n \t\treturn -1;\n \n@@ -7442,7 +7444,7 @@ static int fread_ull(char *path, unsigned long long *val)\n \tFILE *filep;\n \tint ret;\n \n-\tfilep = fopen (path, \"r\");\n+\tfilep = fopen(path, \"r\");\n \tif (!filep)\n \t\treturn -1;\n \n@@ -7457,7 +7459,7 @@ static int fread_str(char *path, char *buf, int size)\n \tint ret;\n \tchar *cp;\n \n-\tfilep = fopen (path, \"r\");\n+\tfilep = fopen(path, \"r\");\n \tif (!filep)\n \t\treturn -1;\n \n@@ -7500,17 +7502,16 @@ static int dump_one_domain(char *domain_path)\n \t\treturn 0;\n \t}\n \n-\tfor (constraint = 0;; constraint++)\n-\t{\n+\tfor (constraint = 0;; constraint++) {\n \t\tsnprintf(path, PATH_MAX, \"%s/constraint_%d_time_window_us\", domain_path, constraint);\n \t\tret = fread_ull(path, &val);\n \t\tif (ret <= 0)\n \t\t\tbreak;\n \n \t\tif (val > 1000000)\n-\t\t\tfprintf(outf, \" %0.1fs\", (double)val/1000000);\n+\t\t\tfprintf(outf, \" %0.1fs\", (double)val / 1000000);\n \t\telse if (val > 1000)\n-\t\t\tfprintf(outf, \" %0.1fms\", (double)val/1000);\n+\t\t\tfprintf(outf, \" %0.1fms\", (double)val / 1000);\n \t\telse\n \t\t\tfprintf(outf, \" %0.1fus\", (double)val);\n \n@@ -7541,30 +7542,29 @@ static int print_rapl_sysfs(void)\n \t\treturn 1;\n \t}\n \n-\twhile ((entry = readdir (dir)) != NULL) {\n+\twhile ((entry = readdir(dir)) != NULL) {\n \t\tif (strlen(entry->d_name) > 100)\n- continue;\n+\t\t\tcontinue;\n \n \t\tif (strncmp(entry->d_name, \"intel-rapl\", strlen(\"intel-rapl\")))\n- continue;\n+\t\t\tcontinue;\n \n \t\tsnprintf(path, PATH_MAX, \"%s/%s/name\", PATH_RAPL_SYSFS, entry->d_name);\n \n \t\t/* Parse top level domains first, including package and psys */\n \t\tfread_str(path, str, PATH_MAX);\n-\t\tif (strncmp(str, \"package\", strlen(\"package\")) &&\n-\t\t strncmp(str, \"psys\", strlen(\"psys\")))\n+\t\tif (strncmp(str, \"package\", strlen(\"package\")) && strncmp(str, \"psys\", strlen(\"psys\")))\n \t\t\tcontinue;\n \n \t\tsnprintf(path, PATH_MAX, \"%s/%s\", PATH_RAPL_SYSFS, entry->d_name);\n \t\tif ((cdir = opendir(path)) == NULL) {\n-\t\t\tperror (\"opendir() error\");\n+\t\t\tperror(\"opendir() error\");\n \t\t\treturn 1;\n \t\t}\n \n \t\tdump_one_domain(path);\n \n-\t\twhile ((centry = readdir (cdir)) != NULL) {\n+\t\twhile ((centry = readdir(cdir)) != NULL) {\n \t\t\tif (strncmp(centry->d_name, \"intel-rapl\", strlen(\"intel-rapl\")))\n \t\t\t\tcontinue;\n \t\t\tsnprintf(path, PATH_MAX, \"%s/%s/%s\", PATH_RAPL_SYSFS, entry->d_name, centry->d_name);\n@@ -8049,7 +8049,7 @@ static int has_instr_count_access(void)\n }\n \n int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,\n-\t\t\t double *scale_, enum rapl_unit *unit_)\n+\t\t\t double *scale_, enum rapl_unit *unit_)\n {\n \tint ret = -1;\n \n@@ -8188,7 +8188,7 @@ void rapl_perf_init(void)\n \t\t\t\trci->unit[cai->rci_index] = unit;\n \t\t\t\trci->flags[cai->rci_index] = cai->flags;\n \n-\t\t\t/* Use MSR for this counter */\n+\t\t\t\t/* Use MSR for this counter */\n \t\t\t} else if (add_rapl_msr_counter(cpu, cai) >= 0) {\n \t\t\t\trci->source[cai->rci_index] = COUNTER_SOURCE_MSR;\n \t\t\t\trci->msr[cai->rci_index] = cai->msr;\n@@ -9299,15 +9299,14 @@ int added_perf_counters_init_(struct perf_counter_info *pinfo)\n \t\t\t\t\tperf_device = \"cpu_atom\";\n \t\t\t\t\tbreak;\n \n-\t\t\t\tdefault: /* Don't change, we will probably fail and report a problem soon. */\n+\t\t\t\tdefault:\t/* Don't change, we will probably fail and report a problem soon. */\n \t\t\t\t\tbreak;\n \t\t\t\t}\n \t\t\t}\n \n \t\t\tperf_type = read_perf_type(perf_device);\n \t\t\tif (perf_type == (unsigned int)-1) {\n-\t\t\t\twarnx(\"%s: perf/%s/%s: failed to read %s\",\n-\t\t\t\t __func__, perf_device, pinfo->event, \"type\");\n+\t\t\t\twarnx(\"%s: perf/%s/%s: failed to read %s\", __func__, perf_device, pinfo->event, \"type\");\n \t\t\t\tcontinue;\n \t\t\t}\n \n@@ -9409,7 +9408,7 @@ struct pmt_mmio *pmt_mmio_open(unsigned int target_guid)\n \t\treturn NULL;\n \t}\n \n-\tfor ( ; entry != NULL; entry = pmt_diriter_next(&pmt_iter)) {\n+\tfor (; entry != NULL; entry = pmt_diriter_next(&pmt_iter)) {\n \t\tif (fstatat(dirfd(pmt_iter.dir), entry->d_name, &st, 0) == -1)\n \t\t\tbreak;\n \n@@ -9849,7 +9848,7 @@ int get_and_dump_counters(void)\n \n void print_version()\n {\n-\tfprintf(outf, \"turbostat version 2025.04.06 - Len Brown <lenb@kernel.org>\\n\");\n+\tfprintf(outf, \"turbostat version 2025.06.08 - Len Brown <lenb@kernel.org>\\n\");\n }\n \n #define COMMAND_LINE_SIZE 2048\n@@ -10305,7 +10304,7 @@ void parse_add_command_pmt(char *add_command)\n \tunsigned int lsb;\n \tunsigned int msb;\n \tunsigned int guid;\n-\tunsigned int seq = 0; /* By default, pick first file in a sequence with a given GUID. */\n+\tunsigned int seq = 0;\t/* By default, pick first file in a sequence with a given GUID. */\n \tunsigned int domain_id;\n \tenum counter_scope scope = 0;\n \tenum pmt_datatype type = PMT_TYPE_RAW;",625 "prediction": "Given the following original C code:\n#define\tBIC_Diec6\t\t(1ULL << 58)\n#define\tBIC_SysWatt\t\t(1ULL << 59)\n#define\tBIC_Sys_J\t\t(1ULL << 60)\n#define\tBIC_NMI\t\t\t(1ULL << 61)\n#define\tBIC_CPU_c1e\t\t(1ULL << 62)\n#define\tBIC_pct_idle\t\t(1ULL << 63)\n\n#define BIC_GROUP_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die)\n#define BIC_GROUP_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)\n#define BIC_GROUP_FREQUENCY (BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz | BIC_SAMMHz | BIC_SAMACTMHz | BIC_UNCORE_MHZ)\n#define BIC_GROUP_HW_IDLE (BIC_Busy | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX | BIC_SAM_mc6 | BIC_Diec6)\n#define BIC_GROUP_SW_IDLE (BIC_Busy | BIC_cpuidle | BIC_pct_idle )\n#define BIC_GROUP_IDLE (BIC_GROUP_HW_IDLE | BIC_pct_idle) \n#define BIC_OTHER (BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)\n\n#define BIC_DISABLED_BY_DEFAULT\t(BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC | BIC_cpuidle)\n\nunsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT);\nunsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_cpuidle | BIC_pct_idle | BIC_APIC | BIC_X2APIC;\n\nInstruction:\ntools/power turbostat: version 2025.06.08\n\nReturn the diff that fixes it:\n @@ -100,6 +100,10 @@\n #define BIC_GROUP_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)\n #define BIC_GROUP_FREQUENCY (BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz | BIC_SAMMHz | BIC_SAMACTMHz | BIC_UNCORE_MHZ)\n #define BIC_GROUP_HW_IDLE (BIC_Busy | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc"626 },627 {628 "prompt": "Given the following original C code:\nn_slots = params_channels(params);\n\t\tslotw = dataw;\n\t}\n\n\tval = snd_soc_component_read(component, base + CS48L32_ASP_CONTROL2);\n\tval = (val & CS48L32_ASP_FMT_MASK) >> CS48L32_ASP_FMT_SHIFT;\n\tif (val == CS48L32_ASP_FMT_I2S_MODE)\n\t\tn_slots_multiple = 2;\n\telse\n\t\tn_slots_multiple = 1;\n\n\tsclk_target = snd_soc_tdm_params_to_bclk(params, slotw, n_slots, n_slots_multiple);\n\n\tfor (i = 0; i < ARRAY_SIZE(cs48l32_sclk_rates); i++) {\n\t\tif ((cs48l32_sclk_rates[i].freq >= sclk_target) &&\n\t\t (cs48l32_sclk_rates[i].freq % rate == 0)) {\n\t\t\tsclk = cs48l32_sclk_rates[i].id;\n\t\t\tbreak;\n\t\t}\n\t}\n\nInstruction:\nASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params()\n\nReturn the diff that fixes it:\n",629 "reference": "@@ -2162,6 +2162,10 @@ static int cs48l32_hw_params(struct snd_pcm_substream *substream,\n \t\tn_slots_multiple = 1;\n \n \tsclk_target = snd_soc_tdm_params_to_bclk(params, slotw, n_slots, n_slots_multiple);\n+\tif (sclk_target < 0) {\n+\t\tcs48l32_asp_err(dai, \"Invalid parameters\\n\");\n+\t\treturn sclk_target;\n+\t}\n \n \tfor (i = 0; i < ARRAY_SIZE(cs48l32_sclk_rates); i++) {\n \t\tif ((cs48l32_sclk_rates[i].freq >= sclk_target) &&",630 "prediction": "Given the following original C code:\nn_slots = params_channels(params);\n\t\tslotw = dataw;\n\t}\n\n\tval = snd_soc_component_read(component, base + CS48L32_ASP_CONTROL2);\n\tval = (val & CS48L32_ASP_FMT_MASK) >> CS48L32_ASP_FMT_SHIFT;\n\tif (val == CS48L32_ASP_FMT_I2S_MODE)\n\t\tn_slots_multiple = 2;\n\telse\n\t\tn_slots_multiple = 1;\n\n\tsclk_target = snd_soc_tdm_params_to_bclk(params, slotw, n_slots, n_slots_multiple);\n\n\tfor (i = 0; i < ARRAY_SIZE(cs48l32_sclk_rates); i++) {\n\t\tif ((cs48l32_sclk_rates[i].freq >= sclk_target) &&\n\t\t (cs48l32_sclk_rates[i].freq % rate == 0)) {\n\t\t\tsclk = cs48l32_sclk_rates[i].id;\n\t\t\tbreak;\n\t\t}\n\t}\n\nInstruction:\nASoC: cs48l32: Fix a signedness bug in cs48l32_hw_params()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int cs48l32_hw_params(struct snd_pcm_substream *substream,\n \t\tn_slots_multiple = 1;\n \n \tsclk_target = snd_soc_tdm_params_to_bclk(params, slotw, n_slots, n_slots_multiple);\n-\n+\tsclk_target = snd_soc_params_to_bclk(params, slotw, n_slots, n_slots_multiple);\n \tfor (i = 0; i < ARRAY_SIZE(cs48l32_sclk_rates); i++) {\n \t\tif ((cs48l32_sclk_rates[i].freq >= sclk_target) &&\n \t\t (cs48l32_sclk_rates[i].freq % rate == 0)) {\n@@ -116,7 +116,7 @@ static int cs48l3"631 },632 {633 "prompt": "Given the following original C code:\n// SPDX-License-Identifier: GPL-2.0\n//\n// Common functions for loongson I2S controller driver\n//\n// Copyright (C) 2023 Loongson Technology Corporation Limited.\n// Author: Yingkun Meng <mengyingkun@loongson.cn>\n//\n\n#include <linux/module.h>\n#include <linux/platform_device.h>\n#include <linux/delay.h>\n#include <linux/pm_runtime.h>\n#include <linux/dma-mapping.h>\n#include <sound/soc.h>\n#include <linux/regmap.h>\n#include <sound/pcm_params.h>\n#include \"loongson_i2s.h\"\n\n#define LOONGSON_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | \\\n\nInstruction:\nASoC: loongson: Fix build warnings about export.h\n\nReturn the diff that fixes it:\n",634 "reference": "@@ -9,6 +9,7 @@\n #include <linux/module.h>\n #include <linux/platform_device.h>\n #include <linux/delay.h>\n+#include <linux/export.h>\n #include <linux/pm_runtime.h>\n #include <linux/dma-mapping.h>\n #include <sound/soc.h>",635 "prediction": "Given the following original C code:\n// SPDX-License-Identifier: GPL-2.0\n//\n// Common functions for loongson I2S controller driver\n//\n// Copyright (C) 2023 Loongson Technology Corporation Limited.\n// Author: Yingkun Meng <mengyingkun@loongson.cn>\n//\n\n#include <linux/module.h>\n#include <linux/platform_device.h>\n#include <linux/delay.h>\n#include <linux/pm_runtime.h>\n#include <linux/dma-mapping.h>\n#include <sound/soc.h>\n#include <linux/regmap.h>\n#include <sound/pcm_params.h>\n#include \"loongson_i2s.h\"\n\n#define LOONGSON_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | \\\n\nInstruction:\nASoC: loongson: Fix build warnings about export.h\n\nReturn the diff that fixes it:\n @@ -10,6 +10,7 @@\n #include <linux/module.h>\n #include <linux/platform_device.h>\n #include <linux/delay.h>\n+#include <linux/export.h>\n #include <linux/pm_runtime.h>\n #include <linux/dma-mapping.h>\n #include <sound/soc.h>\n@@ -18,6 +19,7 @@\n #include \"loongson_i2s.h\"\n \n #define LOONGSON_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | \\\n+\t\t\t SNDRV_PCM_FMTBIT_S16_LE | \\\n \t\t\t SNDRV_PCM_FMTBIT_S18_3LE | \\\n \t\t\t SNDRV_PCM_FMTBIT_S20_3LE | \\\n \t\t\t SNDRV_PCM_FMTBIT_S24_3LE"636 },637 {638 "prompt": "Given the following original C code:\n// SPDX-License-Identifier: GPL-2.0-or-later\n//\n// max20086-regulator.c - MAX20086-MAX20089 camera power protector driver\n//\n// Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com>\n// Copyright (C) 2018 Avnet, Inc.\n\n#include <linux/err.h>\n#include <linux/gpio/consumer.h>\n#include <linux/i2c.h>\n#include <linux/module.h>\n#include <linux/regmap.h>\n#include <linux/regulator/driver.h>\n#include <linux/regulator/machine.h>\n#include <linux/regulator/of_regulator.h>\n\nInstruction:\nregulator: max20086: Fix refcount leak in max20086_parse_regulators_dt()\n\nReturn the diff that fixes it:\n",639 "reference": "@@ -5,6 +5,7 @@\n // Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com>\n // Copyright (C) 2018 Avnet, Inc.\n \n+#include <linux/cleanup.h>\n #include <linux/err.h>\n #include <linux/gpio/consumer.h>\n #include <linux/i2c.h>\n@@ -133,11 +134,11 @@ static int max20086_regulators_register(struct max20086 *chip)\n static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on)\n {\n \tstruct of_regulator_match *matches;\n-\tstruct device_node *node;\n \tunsigned int i;\n \tint ret;\n \n-\tnode = of_get_child_by_name(chip->dev->of_node, \"regulators\");\n+\tstruct device_node *node __free(device_node) =\n+\t\tof_get_child_by_name(chip->dev->of_node, \"regulators\");\n \tif (!node) {\n \t\tdev_err(chip->dev, \"regulators node not found\\n\");\n \t\treturn -ENODEV;\n@@ -153,7 +154,6 @@ static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on)\n \n \tret = of_regulator_match(chip->dev, node, matches,\n \t\t\t\t chip->info->num_outputs);\n-\tof_node_put(node);\n \tif (ret < 0) {\n \t\tdev_err(chip->dev, \"Failed to match regulators\\n\");\n \t\treturn -EINVAL;",640 "prediction": "Given the following original C code:\n// SPDX-License-Identifier: GPL-2.0-or-later\n//\n// max20086-regulator.c - MAX20086-MAX20089 camera power protector driver\n//\n// Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com>\n// Copyright (C) 2018 Avnet, Inc.\n\n#include <linux/err.h>\n#include <linux/gpio/consumer.h>\n#include <linux/i2c.h>\n#include <linux/module.h>\n#include <linux/regmap.h>\n#include <linux/regulator/driver.h>\n#include <linux/regulator/machine.h>\n#include <linux/regulator/of_regulator.h>\n\nInstruction:\nregulator: max20086: Fix refcount leak in max20086_parse_regulators_dt()\n\nReturn the diff that fixes it:\n @@ -4,7 +4,7 @@\n //\n // max20086-regulator.c - MAX20086-MAX20089 camera power protector driver\n //\n-// Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com>\n+// Copyright (C) 2022-2023 Laurent Pinchart <laurent.pinchart@idesonboard.com>\n // Copyright (C) 2018 Avnet, Inc.\n \n #include <linux/err.h>\n@@ -13,6 +13,7 @@\n #include <linux/regulator/driver.h>\n #include <linux/regulator/machine.h>\n #include <linux/regulator/of_regulator.h>\n+#include <linux/slab.h>\n \n struct max20086_regulator {\n \tstruct regulator_desc desc;\n@@ -21,6 +22,7 @@ struct max20086_reg"641 },642 {643 "prompt": "Given the following original C code:\n/*\n\t\t * Check if this transfer contains only one word;\n\t\t */\n\t\tif (bits_per_word < 8 && tr->len == 1) {\n\t\t\t/* multi-mode is applicable, only one word (1..7 bits) */\n\t\t} else if (bits_per_word >= 8 && tr->len == bits_per_word / 8) {\n\t\t\t/* multi-mode is applicable, only one word (8..32 bits) */\n\t\t} else {\n\t\t\t/* multi-mode is not applicable: more than one word in the transfer */\n\t\t\tmcspi->use_multi_mode = false;\n\t\t}\n\n\t\t/* Check if transfer asks to change the CS status after the transfer */\n\t\tif (!tr->cs_change)\n\t\t\tmcspi->use_multi_mode = false;\n\n\t\t/*\n\t\t * If at least one message is not compatible, switch back to single mode\n\t\t *\n\t\t * The bits_per_word of certain transfer can be different, but it will have no\n\nInstruction:\nspi: omap2-mcspi: Disable multi mode when CS should be kept asserted after message\n\nReturn the diff that fixes it:\n",644 "reference": "@@ -1287,9 +1287,15 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,\n \t\t\tmcspi->use_multi_mode = false;\n \t\t}\n \n-\t\t/* Check if transfer asks to change the CS status after the transfer */\n-\t\tif (!tr->cs_change)\n-\t\t\tmcspi->use_multi_mode = false;\n+\t\tif (list_is_last(&tr->transfer_list, &msg->transfers)) {\n+\t\t\t/* Check if transfer asks to keep the CS status after the whole message */\n+\t\t\tif (tr->cs_change)\n+\t\t\t\tmcspi->use_multi_mode = false;\n+\t\t} else {\n+\t\t\t/* Check if transfer asks to change the CS status after the transfer */\n+\t\t\tif (!tr->cs_change)\n+\t\t\t\tmcspi->use_multi_mode = false;\n+\t\t}\n \n \t\t/*\n \t\t * If at least one message is not compatible, switch back to single mode",645 "prediction": "Given the following original C code:\n/*\n\t\t * Check if this transfer contains only one word;\n\t\t */\n\t\tif (bits_per_word < 8 && tr->len == 1) {\n\t\t\t/* multi-mode is applicable, only one word (1..7 bits) */\n\t\t} else if (bits_per_word >= 8 && tr->len == bits_per_word / 8) {\n\t\t\t/* multi-mode is applicable, only one word (8..32 bits) */\n\t\t} else {\n\t\t\t/* multi-mode is not applicable: more than one word in the transfer */\n\t\t\tmcspi->use_multi_mode = false;\n\t\t}\n\n\t\t/* Check if transfer asks to change the CS status after the transfer */\n\t\tif (!tr->cs_change)\n\t\t\tmcspi->use_multi_mode = false;\n\n\t\t/*\n\t\t * If at least one message is not compatible, switch back to single mode\n\t\t *\n\t\t * The bits_per_word of certain transfer can be different, but it will have no\n\nInstruction:\nspi: omap2-mcspi: Disable multi mode when CS should be kept asserted after message\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,\n \t\t\t/* multi-mode is not applicable: more than one word in the transfer */\n \t\t\tmcspi->use_multi_mode = false;\n \n-\t\t/* Check if transfer asks to change the CS status after the transfer */\n+\t\t/* Check if transfer asks to keep CS asserted after the transfer */\n \t\tif (!tr->cs_change)\n \t\t\tmcspi->use_multi_mode = false;\n \n@@ -116,7 +116,7 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,\n \t\t *\n \t\t * The bits_per_word of certain transfer can be different, but it will have no\n \t\t * effect on the transfer.\n-\t\t */\n+\t\t *\n \t\t */\n \t\tif (!mcspi->use_multi_mode"646 },647 {648 "prompt": "Given the following original C code:\nunsigned long\t\tphys;\n\t/* SPI1 has 4 channels, while SPI2 has 2 */\n\tstruct omap2_mcspi_dma\t*dma_channels;\n\tstruct device\t\t*dev;\n\tstruct omap2_mcspi_regs ctx;\n\tstruct clk\t\t*ref_clk;\n\tint\t\t\tfifo_depth;\n\tbool\t\t\ttarget_aborted;\n\tunsigned int\t\tpin_dir:1;\n\tsize_t\t\t\tmax_xfer_len;\n\tu32\t\t\tref_clk_hz;\n\tbool\t\t\tuse_multi_mode;\n};\n\nstruct omap2_mcspi_cs {\n\tvoid __iomem\t\t*base;\n\tunsigned long\t\tphys;\n\tint\t\t\tword_len;\n\tu16\t\t\tmode;\n\tstruct list_head\tnode;\n\nInstruction:\nspi: omap2-mcspi: Disable multi-mode when the previous message kept CS asserted\n\nReturn the diff that fixes it:\n",649 "reference": "@@ -134,6 +134,7 @@ struct omap2_mcspi {\n \tsize_t\t\t\tmax_xfer_len;\n \tu32\t\t\tref_clk_hz;\n \tbool\t\t\tuse_multi_mode;\n+\tbool\t\t\tlast_msg_kept_cs;\n };\n \n struct omap2_mcspi_cs {\n@@ -1269,6 +1270,10 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,\n \t * multi-mode is applicable.\n \t */\n \tmcspi->use_multi_mode = true;\n+\n+\tif (mcspi->last_msg_kept_cs)\n+\t\tmcspi->use_multi_mode = false;\n+\n \tlist_for_each_entry(tr, &msg->transfers, transfer_list) {\n \t\tif (!tr->bits_per_word)\n \t\t\tbits_per_word = msg->spi->bits_per_word;\n@@ -1289,22 +1294,17 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,\n \n \t\tif (list_is_last(&tr->transfer_list, &msg->transfers)) {\n \t\t\t/* Check if transfer asks to keep the CS status after the whole message */\n-\t\t\tif (tr->cs_change)\n+\t\t\tif (tr->cs_change) {\n \t\t\t\tmcspi->use_multi_mode = false;\n+\t\t\t\tmcspi->last_msg_kept_cs = true;\n+\t\t\t} else {\n+\t\t\t\tmcspi->last_msg_kept_cs = false;\n+\t\t\t}\n \t\t} else {\n \t\t\t/* Check if transfer asks to change the CS status after the transfer */\n \t\t\tif (!tr->cs_change)\n \t\t\t\tmcspi->use_multi_mode = false;\n \t\t}\n-\n-\t\t/*\n-\t\t * If at least one message is not compatible, switch back to single mode\n-\t\t *\n-\t\t * The bits_per_word of certain transfer can be different, but it will have no\n-\t\t * impact on the signal itself.\n-\t\t */\n-\t\tif (!mcspi->use_multi_mode)\n-\t\t\tbreak;\n \t}\n \n \tomap2_mcspi_set_mode(ctlr);",650 "prediction": "Given the following original C code:\nunsigned long\t\tphys;\n\t/* SPI1 has 4 channels, while SPI2 has 2 */\n\tstruct omap2_mcspi_dma\t*dma_channels;\n\tstruct device\t\t*dev;\n\tstruct omap2_mcspi_regs ctx;\n\tstruct clk\t\t*ref_clk;\n\tint\t\t\tfifo_depth;\n\tbool\t\t\ttarget_aborted;\n\tunsigned int\t\tpin_dir:1;\n\tsize_t\t\t\tmax_xfer_len;\n\tu32\t\t\tref_clk_hz;\n\tbool\t\t\tuse_multi_mode;\n};\n\nstruct omap2_mcspi_cs {\n\tvoid __iomem\t\t*base;\n\tunsigned long\t\tphys;\n\tint\t\t\tword_len;\n\tu16\t\t\tmode;\n\tstruct list_head\tnode;\n\nInstruction:\nspi: omap2-mcspi: Disable multi-mode when the previous message kept CS asserted\n\nReturn the diff that fixes it:\n @@ -108,6 +108,7 @@ struct omap2_mcspi {\n \tsize_t\t\t\tmax_xfer_len;\n \tu32\t\t\tref_clk_hz;\n \tbool\t\t\tuse_multi_mode;\n+\tbool\t\t\tcs_control;\n };\n \n struct omap2_mcspi_cs {\n@@ -116,6 +117,7 @@ struct omap2_mcspi_cs {\n \tint\t\t\tword_len;\n \tu16\t\t\tmode;\n \tstruct list_head\tnode;\n+\tstruct spi_device\t*spidev;\n };\n \n struct omap2_mcspi_device {\n@@ -124,6 +126,7 @@ struct omap2_mcspi_device {\n \tstruct spi_master\t*master;\n \tstruct omap2_mcspi\t*mcspi;\n \tstruct omap2_mcspi_cs"651 },652 {653 "prompt": "Given the following original C code:\n// SPDX-License-Identifier: GPL-2.0+\n// Loongson SPI Support\n// Copyright (C) 2023 Loongson Technology Corporation Limited\n\n#include <linux/clk.h>\n#include <linux/delay.h>\n#include <linux/err.h>\n#include <linux/init.h>\n#include <linux/interrupt.h>\n#include <linux/io.h>\n#include <linux/iopoll.h>\n#include <linux/kernel.h>\n#include <linux/module.h>\n#include <linux/spi/spi.h>\n\nInstruction:\nspi: loongson: Fix build warnings about export.h\n\nReturn the diff that fixes it:\n",654 "reference": "@@ -5,6 +5,7 @@\n #include <linux/clk.h>\n #include <linux/delay.h>\n #include <linux/err.h>\n+#include <linux/export.h>\n #include <linux/init.h>\n #include <linux/interrupt.h>\n #include <linux/io.h>",655 "prediction": "Given the following original C code:\n// SPDX-License-Identifier: GPL-2.0+\n// Loongson SPI Support\n// Copyright (C) 2023 Loongson Technology Corporation Limited\n\n#include <linux/clk.h>\n#include <linux/delay.h>\n#include <linux/err.h>\n#include <linux/init.h>\n#include <linux/interrupt.h>\n#include <linux/io.h>\n#include <linux/iopoll.h>\n#include <linux/kernel.h>\n#include <linux/module.h>\n#include <linux/spi/spi.h>\n\nInstruction:\nspi: loongson: Fix build warnings about export.h\n\nReturn the diff that fixes it:\n @@ -1,5 +1,5 @@\n-// SPDX-License-Identifier: GPL-2.0+\n-// Loongson SPI Support\n-// Copyright (C) 2023 Loongson Technology Corporation Limited\n+// SPDX-License-Identifier: GPL-2.0+\n+// Loongson SPI Support\n+// Copyright (C) 2023 Loongson Technology Corporation Limited\n \n #include <linux/clk.h>\n #include <linux/delay.h>\n@@ -20,7 +20,7 @@\n #include <linux/spi/spi.h>\n #include <linux/spi/spi_bitbang.h>\n \n-#include <asm/export.h>\n+#include <asm/io.h>\n #include <asm/irq.h>\n #include <asm/mach-loongson/boot_param.h>\n #include <asm/mach-loongson/boot_mode.h>\n@@ -29,"656 },657 {658 "prompt": "Given the following original C code:\nret = pcim_request_all_regions(pdev, DRV_NAME);\n\t\t\tif (ret)\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tspi_bus->reg_base = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0));\n\t\t\tif (!spi_bus->reg_base)\n\t\t\t\treturn -EINVAL;\n\n\t\t\tnum_vector = pci_alloc_irq_vectors(pdev, 1, hw_inst_cnt,\n\t\t\t\t\t\t\t PCI_IRQ_ALL_TYPES);\n\t\t\tif (num_vector < 0) {\n\t\t\t\tdev_err(&pdev->dev, \"Error allocating MSI vectors\\n\");\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\tinit_completion(&spi_sub_ptr->spi_xfer_done);\n\t\t\t/* Initialize Interrupts - SPI_INT */\n\t\t\tregval = readl(spi_bus->reg_base +\n\t\t\t\t SPI_MST_EVENT_MASK_REG_OFFSET(spi_sub_ptr->hw_inst));\n\t\t\tregval &= ~SPI_INTR;\n\nInstruction:\nspi: spi-pci1xxxx: Fix error code in probe\n\nReturn the diff that fixes it:\n",659 "reference": "@@ -765,7 +765,7 @@ static int pci1xxxx_spi_probe(struct pci_dev *pdev, const struct pci_device_id *\n \t\t\t\t\t\t\t PCI_IRQ_ALL_TYPES);\n \t\t\tif (num_vector < 0) {\n \t\t\t\tdev_err(&pdev->dev, \"Error allocating MSI vectors\\n\");\n-\t\t\t\treturn ret;\n+\t\t\t\treturn num_vector;\n \t\t\t}\n \n \t\t\tinit_completion(&spi_sub_ptr->spi_xfer_done);",660 "prediction": "Given the following original C code:\nret = pcim_request_all_regions(pdev, DRV_NAME);\n\t\t\tif (ret)\n\t\t\t\treturn -ENOMEM;\n\n\t\t\tspi_bus->reg_base = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0));\n\t\t\tif (!spi_bus->reg_base)\n\t\t\t\treturn -EINVAL;\n\n\t\t\tnum_vector = pci_alloc_irq_vectors(pdev, 1, hw_inst_cnt,\n\t\t\t\t\t\t\t PCI_IRQ_ALL_TYPES);\n\t\t\tif (num_vector < 0) {\n\t\t\t\tdev_err(&pdev->dev, \"Error allocating MSI vectors\\n\");\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\tinit_completion(&spi_sub_ptr->spi_xfer_done);\n\t\t\t/* Initialize Interrupts - SPI_INT */\n\t\t\tregval = readl(spi_bus->reg_base +\n\t\t\t\t SPI_MST_EVENT_MASK_REG_OFFSET(spi_sub_ptr->hw_inst));\n\t\t\tregval &= ~SPI_INTR;\n\nInstruction:\nspi: spi-pci1xxxx: Fix error code in probe\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int spi_pci1xxxx_probe(struct pci_dev *pdev, const struct pci_device_id\n \t\t\t\t\t\t\t PCI_IRQ_ALL_TYPES);\n \t\t\tif (num_vector < 0) {\n \t\t\t\tdev_err(&pdev->dev, \"Error allocating MSI vectors\\n\");\n-\t\t\t\treturn ret;\n+\t\t\t\treturn -ENOMEM;\n \t\t\t}\n \n \t\t\tinit_completion(&spi_sub_ptr->spi_xfer_done);\n@@ -116,7 +116,7 @@ static int spi_pci1xxxx_probe(struct pci_dev *pdev, const struct pci_device_id\n \t\t\tregval &= ~SPI_INTR;\n \t\t\twritel(regval, spi_bus->reg_base +\n \t\t\t SPI_MST"661 },662 {663 "prompt": "Given the following original C code:\nunsigned int id;\n\tbool wide_bus_supported;\n};\n\nstatic const struct msm_dp_desc msm_dp_desc_sa8775p[] = {\n\t{ .io_start = 0x0af54000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },\n\t{ .io_start = 0x0af5c000, .id = MSM_DP_CONTROLLER_1, .wide_bus_supported = true },\n\t{ .io_start = 0x22154000, .id = MSM_DP_CONTROLLER_2, .wide_bus_supported = true },\n\t{ .io_start = 0x2215c000, .id = MSM_DP_CONTROLLER_3, .wide_bus_supported = true },\n\t{}\n};\n\nstatic const struct msm_dp_desc msm_dp_desc_sc7180[] = {\n\t{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },\n\t{}\n};\n\nstatic const struct msm_dp_desc msm_dp_desc_sc7280[] = {\n\t{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },\n\t{ .io_start = 0x0aea0000, .id = MSM_DP_CONTROLLER_1, .wide_bus_supported = true },\n\nInstruction:\ndrm/msm/dp: Disable wide bus support for SDM845\n\nReturn the diff that fixes it:\n",664 "reference": "@@ -128,6 +128,11 @@ static const struct msm_dp_desc msm_dp_desc_sa8775p[] = {\n \t{}\n };\n \n+static const struct msm_dp_desc msm_dp_desc_sdm845[] = {\n+\t{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0 },\n+\t{}\n+};\n+\n static const struct msm_dp_desc msm_dp_desc_sc7180[] = {\n \t{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },\n \t{}\n@@ -180,7 +185,7 @@ static const struct of_device_id msm_dp_dt_match[] = {\n \t{ .compatible = \"qcom,sc8180x-edp\", .data = &msm_dp_desc_sc8180x },\n \t{ .compatible = \"qcom,sc8280xp-dp\", .data = &msm_dp_desc_sc8280xp },\n \t{ .compatible = \"qcom,sc8280xp-edp\", .data = &msm_dp_desc_sc8280xp },\n-\t{ .compatible = \"qcom,sdm845-dp\", .data = &msm_dp_desc_sc7180 },\n+\t{ .compatible = \"qcom,sdm845-dp\", .data = &msm_dp_desc_sdm845 },\n \t{ .compatible = \"qcom,sm8350-dp\", .data = &msm_dp_desc_sc7180 },\n \t{ .compatible = \"qcom,sm8650-dp\", .data = &msm_dp_desc_sm8650 },\n \t{ .compatible = \"qcom,x1e80100-dp\", .data = &msm_dp_desc_x1e80100 },",665 "prediction": "Given the following original C code:\nunsigned int id;\n\tbool wide_bus_supported;\n};\n\nstatic const struct msm_dp_desc msm_dp_desc_sa8775p[] = {\n\t{ .io_start = 0x0af54000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },\n\t{ .io_start = 0x0af5c000, .id = MSM_DP_CONTROLLER_1, .wide_bus_supported = true },\n\t{ .io_start = 0x22154000, .id = MSM_DP_CONTROLLER_2, .wide_bus_supported = true },\n\t{ .io_start = 0x2215c000, .id = MSM_DP_CONTROLLER_3, .wide_bus_supported = true },\n\t{}\n};\n\nstatic const struct msm_dp_desc msm_dp_desc_sc7180[] = {\n\t{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },\n\t{}\n};\n\nstatic const struct msm_dp_desc msm_dp_desc_sc7280[] = {\n\t{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },\n\t{ .io_start = 0x0aea0000, .id = MSM_DP_CONTROLLER_1, .wide_bus_supported = true },\n\nInstruction:\ndrm/msm/dp: Disable wide bus support for SDM845\n\nReturn the diff that fixes it:\n @@ -100,6 +100,10 @@ static const struct msm_dp_desc msm_dp_desc_sa8775p[] = {\n \t{}\n };\n \n+static const struct msm_dp_desc msm_dp_desc_sdm845[] = {\n+\t{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = false },\n+\t{}\n+};\n+\n static const struct msm_dp_desc msm_dp_desc_sc7180[] = {\n \t{ .io_start = 0x0ae90000, .id = MSM_DP_CONTROLLER_0, .wide_bus_supported = true },\n \t{}\n@@ -108,6 +112,10 @@ static const struct msm_dp_desc msm_dp_desc_sc7180[] = {\n \t{}\n };\n \n+static const"666 },667 {668 "prompt": "Given the following original C code:\ntiming->hsync_polarity = (mode->flags & DRM_MODE_FLAG_NHSYNC) ? 1 : 0;\n\ttiming->vsync_polarity = (mode->flags & DRM_MODE_FLAG_NVSYNC) ? 1 : 0;\n\ttiming->border_clr = 0;\n\ttiming->underflow_clr = 0xff;\n\ttiming->hsync_skew = mode->hskew;\n\n\t/* DSI controller cannot handle active-low sync signals. */\n\tif (phys_enc->hw_intf->cap->type == INTF_DSI) {\n\t\ttiming->hsync_polarity = 0;\n\t\ttiming->vsync_polarity = 0;\n\t}\n\n\t/* for DP/EDP, Shift timings to align it to bottom right */\n\tif (phys_enc->hw_intf->cap->type == INTF_DP) {\n\t\ttiming->h_back_porch += timing->h_front_porch;\n\t\ttiming->h_front_porch = 0;\n\t\ttiming->v_back_porch += timing->v_front_porch;\n\t\ttiming->v_front_porch = 0;\n\t}\n\nInstruction:\ndrm/msm/disp: Correct porch timing for SDM845\n\nReturn the diff that fixes it:\n",669 "reference": "@@ -94,17 +94,21 @@ static void drm_mode_to_intf_timing_params(\n \t\ttiming->vsync_polarity = 0;\n \t}\n \n-\t/* for DP/EDP, Shift timings to align it to bottom right */\n-\tif (phys_enc->hw_intf->cap->type == INTF_DP) {\n+\ttiming->wide_bus_en = dpu_encoder_is_widebus_enabled(phys_enc->parent);\n+\ttiming->compression_en = dpu_encoder_is_dsc_enabled(phys_enc->parent);\n+\n+\t/*\n+\t * For DP/EDP, Shift timings to align it to bottom right.\n+\t * wide_bus_en is set for everything excluding SDM845 &\n+\t * porch changes cause DisplayPort failure and HDMI tearing.\n+\t */\n+\tif (phys_enc->hw_intf->cap->type == INTF_DP && timing->wide_bus_en) {\n \t\ttiming->h_back_porch += timing->h_front_porch;\n \t\ttiming->h_front_porch = 0;\n \t\ttiming->v_back_porch += timing->v_front_porch;\n \t\ttiming->v_front_porch = 0;\n \t}\n \n-\ttiming->wide_bus_en = dpu_encoder_is_widebus_enabled(phys_enc->parent);\n-\ttiming->compression_en = dpu_encoder_is_dsc_enabled(phys_enc->parent);\n-\n \t/*\n \t * for DP, divide the horizonal parameters by 2 when\n \t * widebus is enabled",670 "prediction": "Given the following original C code:\ntiming->hsync_polarity = (mode->flags & DRM_MODE_FLAG_NHSYNC) ? 1 : 0;\n\ttiming->vsync_polarity = (mode->flags & DRM_MODE_FLAG_NVSYNC) ? 1 : 0;\n\ttiming->border_clr = 0;\n\ttiming->underflow_clr = 0xff;\n\ttiming->hsync_skew = mode->hskew;\n\n\t/* DSI controller cannot handle active-low sync signals. */\n\tif (phys_enc->hw_intf->cap->type == INTF_DSI) {\n\t\ttiming->hsync_polarity = 0;\n\t\ttiming->vsync_polarity = 0;\n\t}\n\n\t/* for DP/EDP, Shift timings to align it to bottom right */\n\tif (phys_enc->hw_intf->cap->type == INTF_DP) {\n\t\ttiming->h_back_porch += timing->h_front_porch;\n\t\ttiming->h_front_porch = 0;\n\t\ttiming->v_back_porch += timing->v_front_porch;\n\t\ttiming->v_front_porch = 0;\n\t}\n\nInstruction:\ndrm/msm/disp: Correct porch timing for SDM845\n\nReturn the diff that fixes it:\n @@ -102,12 +102,12 @@ void msm_drm_mode_to_dsi_timing(struct msm_drm_private *priv,\n \t\ttiming->vsync_polarity = 0;\n \t}\n \n-\t/* for DP/EDP, Shift timings to align it to bottom right */\n+\t/* for DP/EDP, Shift timings to align it to bottom right */\n \tif (phys_enc->hw_intf->cap->type == INTF_DP) {\n-\t\ttiming->h_back_porch += timing->h_front_porch;\n-\t\ttiming->h_front_porch = 0;\n-\t\ttiming->v_back_porch += timing->v_front_porch;\n-\t\ttiming->v_front_porch = 0;\n+\t\ttiming->h_back_porch += timing->h_front_porch;\n+\t\ttiming->h_front_porch ="671 },672 {673 "prompt": "Given the following original C code:\nret = pll_10nm_register(pll_10nm, phy->provided_clocks->hws);\n\tif (ret) {\n\t\tDRM_DEV_ERROR(&pdev->dev, \"failed to register PLL: %d\\n\", ret);\n\t\treturn ret;\n\t}\n\n\tphy->vco_hw = &pll_10nm->clk_hw;\n\n\t/* TODO: Remove this when we have proper display handover support */\n\tmsm_dsi_phy_pll_save_state(phy);\n\n\treturn 0;\n}\n\nstatic int dsi_phy_hw_v3_0_is_pll_on(struct msm_dsi_phy *phy)\n{\n\tvoid __iomem *base = phy->base;\n\tu32 data = 0;\n\nInstruction:\ndrm/msm/dsi/dsi_phy_10nm: Fix missing initial VCO rate\n\nReturn the diff that fixes it:\n",674 "reference": "@@ -704,6 +704,13 @@ static int dsi_pll_10nm_init(struct msm_dsi_phy *phy)\n \t/* TODO: Remove this when we have proper display handover support */\n \tmsm_dsi_phy_pll_save_state(phy);\n \n+\t/*\n+\t * Store also proper vco_current_rate, because its value will be used in\n+\t * dsi_10nm_pll_restore_state().\n+\t */\n+\tif (!dsi_pll_10nm_vco_recalc_rate(&pll_10nm->clk_hw, VCO_REF_CLK_RATE))\n+\t\tpll_10nm->vco_current_rate = pll_10nm->phy->cfg->min_pll_rate;\n+\n \treturn 0;\n }",675 "prediction": "Given the following original C code:\nret = pll_10nm_register(pll_10nm, phy->provided_clocks->hws);\n\tif (ret) {\n\t\tDRM_DEV_ERROR(&pdev->dev, \"failed to register PLL: %d\\n\", ret);\n\t\treturn ret;\n\t}\n\n\tphy->vco_hw = &pll_10nm->clk_hw;\n\n\t/* TODO: Remove this when we have proper display handover support */\n\tmsm_dsi_phy_pll_save_state(phy);\n\n\treturn 0;\n}\n\nstatic int dsi_phy_hw_v3_0_is_pll_on(struct msm_dsi_phy *phy)\n{\n\tvoid __iomem *base = phy->base;\n\tu32 data = 0;\n\nInstruction:\ndrm/msm/dsi/dsi_phy_10nm: Fix missing initial VCO rate\n\nReturn the diff that fixes it:\n @@ -100,6 +100,11 @@ static int dsi_phy_hw_v3_0_init(struct platform_device *pdev,\n \tmsm_dsi_phy_pll_save_state(phy);\n \n \treturn 0;\n+}\n+\n+static void dsi_phy_hw_v3_0_destroy(struct msm_dsi_phy *phy)\n+{\n+\tmsm_dsi_phy_pll_restore_state(phy);\n }\n \n static int dsi_phy_hw_v3_0_is_pll_on(struct msm_dsi_phy *phy)\n@@ -107,6 +112,7 @@ static int dsi_phy_hw_v3_0_is_pll_on(struct msm_dsi_phy *phy)\n \tu32 data = 0;\n \n \tdata = readl_relaxed(base + REG_DSI_10nm_PHY_PLL_"676 },677 {678 "prompt": "Given the following original C code:\n* Copyright \u00a9 2010 David Woodhouse <dwmw2@infradead.org>\n */\n\n#define pr_fmt(fmt) KBUILD_MODNAME \": \" fmt\n\n#include <linux/acpi.h>\n#include <linux/backlight.h>\n#include <linux/bitfield.h>\n#include <linux/bitops.h>\n#include <linux/bug.h>\n#include <linux/cleanup.h>\n#include <linux/debugfs.h>\n#include <linux/device.h>\n#include <linux/dmi.h>\n#include <linux/i8042.h>\n#include <linux/init.h>\n#include <linux/input.h>\n#include <linux/input/sparse-keymap.h>\n#include <linux/jiffies.h>\n#include <linux/kernel.h>\n\nInstruction:\nplatform/x86: ideapad-laptop: use usleep_range() for EC polling\n\nReturn the diff that fixes it:\n",679 "reference": "@@ -15,6 +15,7 @@\n #include <linux/bug.h>\n #include <linux/cleanup.h>\n #include <linux/debugfs.h>\n+#include <linux/delay.h>\n #include <linux/device.h>\n #include <linux/dmi.h>\n #include <linux/i8042.h>\n@@ -267,6 +268,20 @@ static void ideapad_shared_exit(struct ideapad_private *priv)\n */\n #define IDEAPAD_EC_TIMEOUT 200 /* in ms */\n \n+/*\n+ * Some models (e.g., ThinkBook since 2024) have a low tolerance for being\n+ * polled too frequently. Doing so may break the state machine in the EC,\n+ * resulting in a hard shutdown.\n+ *\n+ * It is also observed that frequent polls may disturb the ongoing operation\n+ * and notably delay the availability of EC response.\n+ *\n+ * These values are used as the delay before the first poll and the interval\n+ * between subsequent polls to solve the above issues.\n+ */\n+#define IDEAPAD_EC_POLL_MIN_US 150\n+#define IDEAPAD_EC_POLL_MAX_US 300\n+\n static int eval_int(acpi_handle handle, const char *name, unsigned long *res)\n {\n \tunsigned long long result;\n@@ -383,7 +398,7 @@ static int read_ec_data(acpi_handle handle, unsigned long cmd, unsigned long *da\n \tend_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1;\n \n \twhile (time_before(jiffies, end_jiffies)) {\n-\t\tschedule();\n+\t\tusleep_range(IDEAPAD_EC_POLL_MIN_US, IDEAPAD_EC_POLL_MAX_US);\n \n \t\terr = eval_vpcr(handle, 1, &val);\n \t\tif (err)\n@@ -414,7 +429,7 @@ static int write_ec_cmd(acpi_handle handle, unsigned long cmd, unsigned long dat\n \tend_jiffies = jiffies + msecs_to_jiffies(IDEAPAD_EC_TIMEOUT) + 1;\n \n \twhile (time_before(jiffies, end_jiffies)) {\n-\t\tschedule();\n+\t\tusleep_range(IDEAPAD_EC_POLL_MIN_US, IDEAPAD_EC_POLL_MAX_US);\n \n \t\terr = eval_vpcr(handle, 1, &val);\n \t\tif (err)",680 "prediction": "Given the following original C code:\n* Copyright \u00a9 2010 David Woodhouse <dwmw2@infradead.org>\n */\n\n#define pr_fmt(fmt) KBUILD_MODNAME \": \" fmt\n\n#include <linux/acpi.h>\n#include <linux/backlight.h>\n#include <linux/bitfield.h>\n#include <linux/bitops.h>\n#include <linux/bug.h>\n#include <linux/cleanup.h>\n#include <linux/debugfs.h>\n#include <linux/device.h>\n#include <linux/dmi.h>\n#include <linux/i8042.h>\n#include <linux/init.h>\n#include <linux/input.h>\n#include <linux/input/sparse-keymap.h>\n#include <linux/jiffies.h>\n#include <linux/kernel.h>\n\nInstruction:\nplatform/x86: ideapad-laptop: use usleep_range() for EC polling\n\nReturn the diff that fixes it:\n @@ -11,6 +11,7 @@\n #include <linux/bitops.h>\n #include <linux/bug.h>\n #include <linux/cleanup.h>\n+#include <linux/delay.h>\n #include <linux/debugfs.h>\n #include <linux/device.h>\n #include <linux/dmi.h>\n@@ -19,6 +20,7 @@\n #include <linux/input/sparse-keymap.h>\n #include <linux/jiffies.h>\n #include <linux/kernel.h>\n+#include <linux/module.h>\n #include <linux/moduleparam.h>\n #include <linux/mutex.h>\n #include <linux/platform_device.h>\n@@ -28,6 +30,7 @@\n #include <linux/slab.h>\n #include <linux/string.h>\n #include <linux/types.h>\n+#include <linux/uaccess.h>\n #include <linux/units.h>"681 },682 {683 "prompt": "Given the following original C code:\nsizeof(*tpmi_uncore->pd_info),\n\t\t\t\t\t GFP_KERNEL);\n\tif (!tpmi_uncore->pd_info) {\n\t\tret = -ENOMEM;\n\t\tgoto err_rem_common;\n\t}\n\n\ttpmi_uncore->power_domain_count = num_resources;\n\ttpmi_uncore->write_blocked = write_blocked;\n\n\t/* Get the package ID from the TPMI core */\n\tplat_info = tpmi_get_platform_data(auxdev);\n\tif (plat_info)\n\t\tpkg = plat_info->package_id;\n\telse\n\t\tdev_info(&auxdev->dev, \"Platform information is NULL\\n\");\n\n\tfor (i = 0; i < num_resources; ++i) {\n\t\tstruct tpmi_uncore_power_domain_info *pd_info;\n\t\tstruct resource *res;\n\nInstruction:\nplatform/x86/intel-uncore-freq: Fail module load when plat_info is NULL\n\nReturn the diff that fixes it:\n",684 "reference": "@@ -511,10 +511,13 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_\n \n \t/* Get the package ID from the TPMI core */\n \tplat_info = tpmi_get_platform_data(auxdev);\n-\tif (plat_info)\n-\t\tpkg = plat_info->package_id;\n-\telse\n+\tif (unlikely(!plat_info)) {\n \t\tdev_info(&auxdev->dev, \"Platform information is NULL\\n\");\n+\t\tret = -ENODEV;\n+\t\tgoto err_rem_common;\n+\t}\n+\n+\tpkg = plat_info->package_id;\n \n \tfor (i = 0; i < num_resources; ++i) {\n \t\tstruct tpmi_uncore_power_domain_info *pd_info;",685 "prediction": "Given the following original C code:\nsizeof(*tpmi_uncore->pd_info),\n\t\t\t\t\t GFP_KERNEL);\n\tif (!tpmi_uncore->pd_info) {\n\t\tret = -ENOMEM;\n\t\tgoto err_rem_common;\n\t}\n\n\ttpmi_uncore->power_domain_count = num_resources;\n\ttpmi_uncore->write_blocked = write_blocked;\n\n\t/* Get the package ID from the TPMI core */\n\tplat_info = tpmi_get_platform_data(auxdev);\n\tif (plat_info)\n\t\tpkg = plat_info->package_id;\n\telse\n\t\tdev_info(&auxdev->dev, \"Platform information is NULL\\n\");\n\n\tfor (i = 0; i < num_resources; ++i) {\n\t\tstruct tpmi_uncore_power_domain_info *pd_info;\n\t\tstruct resource *res;\n\nInstruction:\nplatform/x86/intel-uncore-freq: Fail module load when plat_info is NULL\n\nReturn the diff that fixes it:\n A @@ -102,10 +102,10 @@ static int tpmi_uncore_probe(struct platform_device *auxdev)\n \n \t/* Get the package ID from the TPMI core */\n \tplat_info = tpmi_get_platform_data(auxdev);\n-\tif (plat_info)\n+\tif (!plat_info)\n \t\tpkg = plat_info->package_id;\n-\telse\n+\telse {\n \t\tdev_info(&auxdev->dev, \"Platform information is NULL\\n\");\n+\t}\n \n \tfor (i = 0; i < num_resources; ++i) {\n \t\tstruct tpmi_uncore_power_domain_info *pd_info;\n@@ -114,7 +114,7 @@ static int tpmi_uncore_probe(struct platform_device *auxdev)\n \n \t\tres = platform_get_resource(auxdev, IORESOURCE_MEM, i);"686 },687 {688 "prompt": "Given the following original C code:\nSND_PCI_QUIRK(0x17aa, 0x2227, \"Lenovo X1 Carbon 3rd Gen\", 0),\n\tSND_PCI_QUIRK(0x17aa, 0x316e, \"Lenovo ThinkCentre M70q\", 0),\n\t/* https://bugzilla.redhat.com/show_bug.cgi?id=1689623 */\n\tSND_PCI_QUIRK(0x17aa, 0x367b, \"Lenovo IdeaCentre B550\", 0),\n\t/* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */\n\tSND_PCI_QUIRK(0x17aa, 0x36a7, \"Lenovo C50 All in one\", 0),\n\t/* https://bugs.launchpad.net/bugs/1821663 */\n\tSND_PCI_QUIRK(0x1631, 0xe017, \"Packard Bell NEC IMEDIA 5204\", 0),\n\t/* KONTRON SinglePC may cause a stall at runtime resume */\n\tSND_PCI_QUIRK(0x1734, 0x1232, \"KONTRON SinglePC\", 0),\n\t/* Dell ALC3271 */\n\tSND_PCI_QUIRK(0x1028, 0x0962, \"Dell ALC3271\", 0),\n\t{}\n};\n\nstatic void set_default_power_save(struct azx *chip)\n{\n\tstruct hda_intel *hda = container_of(chip, struct hda_intel, chip);\n\tint val = power_save;\n\nInstruction:\nALSA: hda/intel: Add Thinkpad E15 to PM deny list\n\nReturn the diff that fixes it:\n",689 "reference": "@@ -2283,6 +2283,8 @@ static const struct snd_pci_quirk power_save_denylist[] = {\n \tSND_PCI_QUIRK(0x1734, 0x1232, \"KONTRON SinglePC\", 0),\n \t/* Dell ALC3271 */\n \tSND_PCI_QUIRK(0x1028, 0x0962, \"Dell ALC3271\", 0),\n+\t/* https://bugzilla.kernel.org/show_bug.cgi?id=220210 */\n+\tSND_PCI_QUIRK(0x17aa, 0x5079, \"Lenovo Thinkpad E15\", 0),\n \t{}\n };",690 "prediction": "Given the following original C code:\nSND_PCI_QUIRK(0x17aa, 0x2227, \"Lenovo X1 Carbon 3rd Gen\", 0),\n\tSND_PCI_QUIRK(0x17aa, 0x316e, \"Lenovo ThinkCentre M70q\", 0),\n\t/* https://bugzilla.redhat.com/show_bug.cgi?id=1689623 */\n\tSND_PCI_QUIRK(0x17aa, 0x367b, \"Lenovo IdeaCentre B550\", 0),\n\t/* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */\n\tSND_PCI_QUIRK(0x17aa, 0x36a7, \"Lenovo C50 All in one\", 0),\n\t/* https://bugs.launchpad.net/bugs/1821663 */\n\tSND_PCI_QUIRK(0x1631, 0xe017, \"Packard Bell NEC IMEDIA 5204\", 0),\n\t/* KONTRON SinglePC may cause a stall at runtime resume */\n\tSND_PCI_QUIRK(0x1734, 0x1232, \"KONTRON SinglePC\", 0),\n\t/* Dell ALC3271 */\n\tSND_PCI_QUIRK(0x1028, 0x0962, \"Dell ALC3271\", 0),\n\t{}\n};\n\nstatic void set_default_power_save(struct azx *chip)\n{\n\tstruct hda_intel *hda = container_of(chip, struct hda_intel, chip);\n\tint val = power_save;\n\nInstruction:\nALSA: hda/intel: Add Thinkpad E15 to PM deny list\n\nReturn the diff that fixes it:\n @@ -106,6 +106,10 @@ static struct snd_pci_quirk pci_quirks[] = {\n \tSND_PCI_QUIRK(0x1734, 0x1232, \"KONTRON SinglePC\", 0),\n \t/* Dell ALC3271 */\n \tSND_PCI_QUIRK(0x1028, 0x0962, \"Dell ALC3271\", 0),\n+\t/* Thinkpad E15 */\n+\tSND_PCI_QUIRK(0x17aa, 0x20f0, \"Thinkpad E15\", 0),\n+\tSND_PCI_QUIRK(0x17aa, 0x20f1, \"Thinkpad E15\", 0),\n+\tSND_PCI_QUIRK(0x17aa, 0x20f2, \"Thinkpad E15\","691 },692 {693 "prompt": "Given the following original C code:\n/* Check for MSR 0x54 presence */\n\tret = rdmsrq_safe(MSR_PM_LOGICAL_ID, &data);\n\tif (ret)\n\t\treturn ret;\n\n\ttpmi_power_domain_mask = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),\n\t\t\t\t\t sizeof(*tpmi_power_domain_mask), GFP_KERNEL);\n\tif (!tpmi_power_domain_mask)\n\t\treturn -ENOMEM;\n\n\tdomain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),\n\t\t\t\t sizeof(*domain_die_map), GFP_KERNEL);\n\tif (!domain_die_map)\n\t\tgoto free_domain_mask;\n\n\tret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,\n\t\t\t\t\"platform/x86/tpmi_power_domains:online\",\n\t\t\t\ttpmi_cpu_online, NULL);\n\tif (ret < 0)\n\t\tgoto free_domain_map;\n\nInstruction:\nplatform/x86/intel: power-domains: Fix error code in tpmi_init()\n\nReturn the diff that fixes it:\n",694 "reference": "@@ -228,8 +228,10 @@ static int __init tpmi_init(void)\n \n \tdomain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),\n \t\t\t\t sizeof(*domain_die_map), GFP_KERNEL);\n-\tif (!domain_die_map)\n+\tif (!domain_die_map) {\n+\t\tret = -ENOMEM;\n \t\tgoto free_domain_mask;\n+\t}\n \n \tret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,\n \t\t\t\t\"platform/x86/tpmi_power_domains:online\",",695 "prediction": "Given the following original C code:\n/* Check for MSR 0x54 presence */\n\tret = rdmsrq_safe(MSR_PM_LOGICAL_ID, &data);\n\tif (ret)\n\t\treturn ret;\n\n\ttpmi_power_domain_mask = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),\n\t\t\t\t\t sizeof(*tpmi_power_domain_mask), GFP_KERNEL);\n\tif (!tpmi_power_domain_mask)\n\t\treturn -ENOMEM;\n\n\tdomain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),\n\t\t\t\t sizeof(*domain_die_map), GFP_KERNEL);\n\tif (!domain_die_map)\n\t\tgoto free_domain_mask;\n\n\tret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,\n\t\t\t\t\"platform/x86/tpmi_power_domains:online\",\n\t\t\t\ttpmi_cpu_online, NULL);\n\tif (ret < 0)\n\t\tgoto free_domain_map;\n\nInstruction:\nplatform/x86/intel: power-domains: Fix error code in tpmi_init()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static int __init tpmi_init(void)\n \t\treturn -ENOMEM;\n \n \tdomain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),\n-\t\t\t\t sizeof(*domain_die_map), GFP_KERNEL);\n+\t\t\t\t sizeof(*domain_die_map), GFP_KERNEL | __GFP_ZERO);\n \tif (!domain_die_map)\n \t\tgoto free_domain_mask;\n \n@@ -109,7 +109,7 @@ static int __init tpmi_init(void)\n \t\t\t\t\"platform/x86/tpmi_power_domains:online\",\n \t\t\t\ttpmi_cpu_online, NULL);\n \tif (ret < 0)\n-\t\tgoto free_domain_map;\n+\t\tgoto free_domain_die_map;"696 },697 {698 "prompt": "Given the following original C code:\nu64 smu_phys_addr;\n\n\t\tamd_pmc_send_cmd(dev, 0, &phys_addr_low, SMU_MSG_LOG_GETDRAM_ADDR_LO, true);\n\t\tamd_pmc_send_cmd(dev, 0, &phys_addr_hi, SMU_MSG_LOG_GETDRAM_ADDR_HI, true);\n\t\tsmu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);\n\n\t\tdev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr,\n\t\t\t\t\t\t sizeof(struct smu_metrics));\n\t\tif (!dev->smu_virt_addr)\n\t\t\treturn -ENOMEM;\n\t}\n\n\t/* Start the logging */\n\tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, false);\n\tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, false);\n\n\treturn 0;\n}\n\nstatic int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table)\n\nInstruction:\nplatform/x86/amd: pmc: Clear metrics table at start of cycle\n\nReturn the diff that fixes it:\n",699 "reference": "@@ -157,6 +157,8 @@ static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)\n \t\t\treturn -ENOMEM;\n \t}\n \n+\tmemset_io(dev->smu_virt_addr, 0, sizeof(struct smu_metrics));\n+\n \t/* Start the logging */\n \tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, false);\n \tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, false);",700 "prediction": "Given the following original C code:\nu64 smu_phys_addr;\n\n\t\tamd_pmc_send_cmd(dev, 0, &phys_addr_low, SMU_MSG_LOG_GETDRAM_ADDR_LO, true);\n\t\tamd_pmc_send_cmd(dev, 0, &phys_addr_hi, SMU_MSG_LOG_GETDRAM_ADDR_HI, true);\n\t\tsmu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);\n\n\t\tdev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr,\n\t\t\t\t\t\t sizeof(struct smu_metrics));\n\t\tif (!dev->smu_virt_addr)\n\t\t\treturn -ENOMEM;\n\t}\n\n\t/* Start the logging */\n\tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, false);\n\tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, false);\n\n\treturn 0;\n}\n\nstatic int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table)\n\nInstruction:\nplatform/x86/amd: pmc: Clear metrics table at start of cycle\n\nReturn the diff that fixes it:\n @@ -111,6 +111,11 @@ static int start_metrics_logging(struct amd_pmc_dev *dev)\n \t\t\treturn -ENOMEM;\n \t}\n \n+\t/* Clear the metrics table */\n+\tmemset(dev->smu_virt_addr, 0, sizeof(struct smu_metrics));\n+\n+\tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_CLEAR, false);\n+\n \t/* Start the logging */\n \tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, false);\n \tamd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, false);\n@@ -120,6 +125,7 @@ static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table\n \treturn 0;\n }"701 },702 {703 "prompt": "Given the following original C code:\nint ret;\n\n\tif (!msg)\n\t\treturn -EINVAL;\n\tret = validate_message(msg);\n\tif (ret)\n\t\treturn ret;\n\n\tif (!hsmp_pdev.sock || msg->sock_ind >= hsmp_pdev.num_sockets)\n\t\treturn -ENODEV;\n\tsock = &hsmp_pdev.sock[msg->sock_ind];\n\n\t/*\n\t * The time taken by smu operation to complete is between\n\t * 10us to 1ms. Sometime it may take more time.\n\t * In SMP system timeout of 100 millisecs should\n\t * be enough for the previous thread to finish the operation\n\t */\n\tret = down_timeout(&sock->hsmp_sem, msecs_to_jiffies(HSMP_MSG_TIMEOUT));\n\tif (ret < 0)\n\nInstruction:\nx86/platform/amd: replace down_timeout() with down_interruptible()\n\nReturn the diff that fixes it:\n",704 "reference": "@@ -214,13 +214,7 @@ int hsmp_send_message(struct hsmp_message *msg)\n \t\treturn -ENODEV;\n \tsock = &hsmp_pdev.sock[msg->sock_ind];\n \n-\t/*\n-\t * The time taken by smu operation to complete is between\n-\t * 10us to 1ms. Sometime it may take more time.\n-\t * In SMP system timeout of 100 millisecs should\n-\t * be enough for the previous thread to finish the operation\n-\t */\n-\tret = down_timeout(&sock->hsmp_sem, msecs_to_jiffies(HSMP_MSG_TIMEOUT));\n+\tret = down_interruptible(&sock->hsmp_sem);\n \tif (ret < 0)\n \t\treturn ret;",705 "prediction": "Given the following original C code:\nint ret;\n\n\tif (!msg)\n\t\treturn -EINVAL;\n\tret = validate_message(msg);\n\tif (ret)\n\t\treturn ret;\n\n\tif (!hsmp_pdev.sock || msg->sock_ind >= hsmp_pdev.num_sockets)\n\t\treturn -ENODEV;\n\tsock = &hsmp_pdev.sock[msg->sock_ind];\n\n\t/*\n\t * The time taken by smu operation to complete is between\n\t * 10us to 1ms. Sometime it may take more time.\n\t * In SMP system timeout of 100 millisecs should\n\t * be enough for the previous thread to finish the operation\n\t */\n\tret = down_timeout(&sock->hsmp_sem, msecs_to_jiffies(HSMP_MSG_TIMEOUT));\n\tif (ret < 0)\n\nInstruction:\nx86/platform/amd: replace down_timeout() with down_interruptible()\n\nReturn the diff that fixes it:\n @@ -107,13 +107,13 @@ static int hsmp_send_msg(struct hsmp_msg *msg)\n \t\treturn -ENODEV;\n \tsock = &hsmp_pdev.sock[msg->sock_ind];\n \n-\t/*\n-\t * The time taken by smu operation to complete is between\n-\t * 10us to 1ms. Sometime it may take more time.\n-\t * In SMP system timeout of 100 millisecs should\n-\t * be enough for the previous thread to finish the operation\n-\t */\n-\tret = down_timeout(&sock->hsmp_sem, msecs_to_jiffies(HSMP_MSG_TIMEOUT));\n+\t/*\n+\t * The time taken by smu operation to complete is between\n+\t * 10us to 1ms. Sometime it may take more time.\n+\t * In SMP system timeout of 100 millisecs should\n+\t * be enough for the previous thread to finish"706 },707 {708 "prompt": "Given the following original C code:\nstatic const struct of_device_id apq8064_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,apq8064-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver apq8064_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"apq8064-pinctrl\",\n\t\t.of_match_table = apq8064_pinctrl_of_match,\n\t},\n\t.probe = apq8064_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init apq8064_pinctrl_init(void)\n{\n\treturn platform_driver_register(&apq8064_pinctrl_driver);\n}\narch_initcall(apq8064_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",709 "reference": "@@ -629,7 +629,6 @@ static struct platform_driver apq8064_pinctrl_driver = {\n \t\t.of_match_table = apq8064_pinctrl_of_match,\n \t},\n \t.probe = apq8064_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init apq8064_pinctrl_init(void)",710 "prediction": "Given the following original C code:\nstatic const struct of_device_id apq8064_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,apq8064-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver apq8064_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"apq8064-pinctrl\",\n\t\t.of_match_table = apq8064_pinctrl_of_match,\n\t},\n\t.probe = apq8064_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init apq8064_pinctrl_init(void)\n{\n\treturn platform_driver_register(&apq8064_pinctrl_driver);\n}\narch_initcall(apq8064_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver apq8064_pinctrl_driver = {\n \t},\n \t.probe = apq8064_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init apq8064_pinctrl_init(void)\n {\n \treturn platform_driver_register(&apq8064_pinctrl_driver);\n@@ -116,7 +116,7 @@ static int __init apq8064_pinctrl_init(void)\n \n arch_initcall(apq8064_pinctrl_init);\n \n-static void __exit apq8064_pinctrl_exit(void)\n+static void __exit apq8064_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&apq8064_pinctrl_driver);\n }"711 },712 {713 "prompt": "Given the following original C code:\nstatic const struct of_device_id apq8084_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,apq8084-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver apq8084_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"apq8084-pinctrl\",\n\t\t.of_match_table = apq8084_pinctrl_of_match,\n\t},\n\t.probe = apq8084_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init apq8084_pinctrl_init(void)\n{\n\treturn platform_driver_register(&apq8084_pinctrl_driver);\n}\narch_initcall(apq8084_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",714 "reference": "@@ -1207,7 +1207,6 @@ static struct platform_driver apq8084_pinctrl_driver = {\n \t\t.of_match_table = apq8084_pinctrl_of_match,\n \t},\n \t.probe = apq8084_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init apq8084_pinctrl_init(void)",715 "prediction": "Given the following original C code:\nstatic const struct of_device_id apq8084_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,apq8084-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver apq8084_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"apq8084-pinctrl\",\n\t\t.of_match_table = apq8084_pinctrl_of_match,\n\t},\n\t.probe = apq8084_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init apq8084_pinctrl_init(void)\n{\n\treturn platform_driver_register(&apq8084_pinctrl_driver);\n}\narch_initcall(apq8084_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -104,7 +104,7 @@ static struct platform_driver apq8084_pinctrl_driver = {\n \t\t.of_match_table = apq8084_pinctrl_of_match,\n \t},\n \t.probe = apq8084_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init apq8084_pinctrl_init(void)\n@@ -112,7 +112,7 @@ static int __init apq8084_pinctrl_init(void)\n \treturn platform_driver_register(&apq8084_pinctrl_driver);\n }\n arch_initcall(apq8084_pinctrl_init);\n-\n+\n static void __exit apq8084_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"716 },717 {718 "prompt": "Given the following original C code:\nstatic const struct of_device_id ipq4019_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq4019-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver ipq4019_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq4019-pinctrl\",\n\t\t.of_match_table = ipq4019_pinctrl_of_match,\n\t},\n\t.probe = ipq4019_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq4019_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq4019_pinctrl_driver);\n}\narch_initcall(ipq4019_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",719 "reference": "@@ -710,7 +710,6 @@ static struct platform_driver ipq4019_pinctrl_driver = {\n \t\t.of_match_table = ipq4019_pinctrl_of_match,\n \t},\n \t.probe = ipq4019_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq4019_pinctrl_init(void)",720 "prediction": "Given the following original C code:\nstatic const struct of_device_id ipq4019_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq4019-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver ipq4019_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq4019-pinctrl\",\n\t\t.of_match_table = ipq4019_pinctrl_of_match,\n\t},\n\t.probe = ipq4019_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq4019_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq4019_pinctrl_driver);\n}\narch_initcall(ipq4019_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver ipq4019_pinctrl_driver = {\n \t\t.of_match_table = ipq4019_pinctrl_of_match,\n \t},\n \t.probe = ipq4019_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq4019_pinctrl_init(void)\n@@ -110,7 +110,7 @@ static int __init ipq4019_pinctrl_init(void)\n \treturn platform_driver_register(&ipq4019_pinctrl_driver);\n }\n arch_initcall(ipq4019_pinctrl_init);\n-\n+\n static void __exit ipq4019_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"721 },722 {723 "prompt": "Given the following original C code:\nstatic const struct of_device_id ipq5018_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq5018-tlmm\", },\n\t{ }\n};\nMODULE_DEVICE_TABLE(of, ipq5018_pinctrl_of_match);\n\nstatic struct platform_driver ipq5018_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq5018-tlmm\",\n\t\t.of_match_table = ipq5018_pinctrl_of_match,\n\t},\n\t.probe = ipq5018_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq5018_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq5018_pinctrl_driver);\n}\narch_initcall(ipq5018_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",724 "reference": "@@ -754,7 +754,6 @@ static struct platform_driver ipq5018_pinctrl_driver = {\n \t\t.of_match_table = ipq5018_pinctrl_of_match,\n \t},\n \t.probe = ipq5018_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq5018_pinctrl_init(void)",725 "prediction": "Given the following original C code:\nstatic const struct of_device_id ipq5018_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq5018-tlmm\", },\n\t{ }\n};\nMODULE_DEVICE_TABLE(of, ipq5018_pinctrl_of_match);\n\nstatic struct platform_driver ipq5018_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq5018-tlmm\",\n\t\t.of_match_table = ipq5018_pinctrl_of_match,\n\t},\n\t.probe = ipq5018_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq5018_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq5018_pinctrl_driver);\n}\narch_initcall(ipq5018_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver ipq5018_pinctrl_driver = {\n \t\t.name = \"ipq5018-tlmm\",\n \t\t.of_match_table = ipq5018_pinctrl_of_match,\n \t},\n-\t.probe = ipq5018_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -110,7 +110,7 @@ static int __init ipq5018_pinctrl_init(void)\n \treturn platform_driver_register(&ipq5018_pinctrl_driver);\n }\n arch_initcall(ipq5018_pinctrl_init);\n-\n+\n static void __exit ipq5018_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"726 },727 {728 "prompt": "Given the following original C code:\nstatic const struct of_device_id ipq5332_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq5332-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, ipq5332_pinctrl_of_match);\n\nstatic struct platform_driver ipq5332_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq5332-tlmm\",\n\t\t.of_match_table = ipq5332_pinctrl_of_match,\n\t},\n\t.probe = ipq5332_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq5332_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq5332_pinctrl_driver);\n}\narch_initcall(ipq5332_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",729 "reference": "@@ -834,7 +834,6 @@ static struct platform_driver ipq5332_pinctrl_driver = {\n \t\t.of_match_table = ipq5332_pinctrl_of_match,\n \t},\n \t.probe = ipq5332_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq5332_pinctrl_init(void)",730 "prediction": "Given the following original C code:\nstatic const struct of_device_id ipq5332_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq5332-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, ipq5332_pinctrl_of_match);\n\nstatic struct platform_driver ipq5332_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq5332-tlmm\",\n\t\t.of_match_table = ipq5332_pinctrl_of_match,\n\t},\n\t.probe = ipq5332_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq5332_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq5332_pinctrl_driver);\n}\narch_initcall(ipq5332_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver ipq5332_pinctrl_driver = {\n \t\t.name = \"ipq5332-tlmm\",\n \t\t.of_match_table = ipq5332_pinctrl_of_match,\n \t},\n-\t.probe = ipq5332_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -110,7 +110,7 @@ static int __init ipq5332_pinctrl_init(void)\n \treturn platform_driver_register(&ipq5332_pinctrl_driver);\n }\n arch_initcall(ipq5332_pinctrl_init);\n-\n+\n static void __exit ipq5332_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"731 },732 {733 "prompt": "Given the following original C code:\nstatic const struct of_device_id ipq5424_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq5424-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, ipq5424_pinctrl_of_match);\n\nstatic struct platform_driver ipq5424_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq5424-tlmm\",\n\t\t.of_match_table = ipq5424_pinctrl_of_match,\n\t},\n\t.probe = ipq5424_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq5424_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq5424_pinctrl_driver);\n}\narch_initcall(ipq5424_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",734 "reference": "@@ -791,7 +791,6 @@ static struct platform_driver ipq5424_pinctrl_driver = {\n \t\t.of_match_table = ipq5424_pinctrl_of_match,\n \t},\n \t.probe = ipq5424_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq5424_pinctrl_init(void)",735 "prediction": "Given the following original C code:\nstatic const struct of_device_id ipq5424_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq5424-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, ipq5424_pinctrl_of_match);\n\nstatic struct platform_driver ipq5424_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq5424-tlmm\",\n\t\t.of_match_table = ipq5424_pinctrl_of_match,\n\t},\n\t.probe = ipq5424_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq5424_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq5424_pinctrl_driver);\n}\narch_initcall(ipq5424_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver ipq5424_pinctrl_driver = {\n \t\t.name = \"ipq5424-tlmm\",\n \t\t.of_match_table = ipq5424_pinctrl_of_match,\n \t},\n-\t.probe = ipq5424_pinctrl_probe,\n+\t.probe = ipq5424_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -110,7 +110,7 @@ static int __init ipq5424_pinctrl_init(void)\n \treturn platform_driver_register(&ipq5424_pinctrl_driver);\n }\n arch_initcall(ipq5424_pinctrl_init);\n-\n+\n static void __exit ipq5424_pinctrl_exit(void)\n {\n \tplatform_driver"736 },737 {738 "prompt": "Given the following original C code:\nstatic const struct of_device_id ipq6018_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq6018-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver ipq6018_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq6018-pinctrl\",\n\t\t.of_match_table = ipq6018_pinctrl_of_match,\n\t},\n\t.probe = ipq6018_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq6018_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq6018_pinctrl_driver);\n}\narch_initcall(ipq6018_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",739 "reference": "@@ -1080,7 +1080,6 @@ static struct platform_driver ipq6018_pinctrl_driver = {\n \t\t.of_match_table = ipq6018_pinctrl_of_match,\n \t},\n \t.probe = ipq6018_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq6018_pinctrl_init(void)",740 "prediction": "Given the following original C code:\nstatic const struct of_device_id ipq6018_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq6018-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver ipq6018_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq6018-pinctrl\",\n\t\t.of_match_table = ipq6018_pinctrl_of_match,\n\t},\n\t.probe = ipq6018_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq6018_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq6018_pinctrl_driver);\n}\narch_initcall(ipq6018_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver ipq6018_pinctrl_driver = {\n \t\t.of_match_table = ipq6018_pinctrl_of_match,\n \t},\n \t.probe = ipq6018_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq6018_pinctrl_init(void)\n@@ -110,7 +110,7 @@ static int __init ipq6018_pinctrl_init(void)\n \treturn platform_driver_register(&ipq6018_pinctrl_driver);\n }\n arch_initcall(ipq6018_pinctrl_init);\n-\n+\n static void __exit ipq6018_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"741 },742 {743 "prompt": "Given the following original C code:\nstatic const struct of_device_id ipq8064_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq8064-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver ipq8064_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq8064-pinctrl\",\n\t\t.of_match_table = ipq8064_pinctrl_of_match,\n\t},\n\t.probe = ipq8064_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq8064_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq8064_pinctrl_driver);\n}\narch_initcall(ipq8064_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",744 "reference": "@@ -631,7 +631,6 @@ static struct platform_driver ipq8064_pinctrl_driver = {\n \t\t.of_match_table = ipq8064_pinctrl_of_match,\n \t},\n \t.probe = ipq8064_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq8064_pinctrl_init(void)",745 "prediction": "Given the following original C code:\nstatic const struct of_device_id ipq8064_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq8064-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver ipq8064_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq8064-pinctrl\",\n\t\t.of_match_table = ipq8064_pinctrl_of_match,\n\t},\n\t.probe = ipq8064_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq8064_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq8064_pinctrl_driver);\n}\narch_initcall(ipq8064_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver ipq8064_pinctrl_driver = {\n \t\t.of_match_table = ipq8064_pinctrl_of_match,\n \t},\n \t.probe = ipq8064_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq8064_pinctrl_init(void)\n@@ -116,7 +116,7 @@ static int __init ipq8064_pinctrl_init(void)\n \treturn platform_driver_register(&ipq8064_pinctrl_driver);\n }\n arch_initcall(ipq8064_pinctrl_init);\n-\n+\n static void __exit ipq8064_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"746 },747 {748 "prompt": "Given the following original C code:\nstatic const struct of_device_id ipq8074_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq8074-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver ipq8074_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq8074-pinctrl\",\n\t\t.of_match_table = ipq8074_pinctrl_of_match,\n\t},\n\t.probe = ipq8074_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq8074_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq8074_pinctrl_driver);\n}\narch_initcall(ipq8074_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",749 "reference": "@@ -1041,7 +1041,6 @@ static struct platform_driver ipq8074_pinctrl_driver = {\n \t\t.of_match_table = ipq8074_pinctrl_of_match,\n \t},\n \t.probe = ipq8074_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq8074_pinctrl_init(void)",750 "prediction": "Given the following original C code:\nstatic const struct of_device_id ipq8074_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq8074-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver ipq8074_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq8074-pinctrl\",\n\t\t.of_match_table = ipq8074_pinctrl_of_match,\n\t},\n\t.probe = ipq8074_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq8074_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq8074_pinctrl_driver);\n}\narch_initcall(ipq8074_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver ipq8074_pinctrl_driver = {\n \t\t.of_match_table = ipq8074_pinctrl_of_match,\n \t},\n \t.probe = ipq8074_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq8074_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init ipq8074_pinctrl_init(void)\n \treturn platform_driver_register(&ipq8074_pinctrl_driver);\n }\n arch_initcall(ipq8074_pinctrl_init);\n-\n+\n static void __exit ipq8074_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"751 },752 {753 "prompt": "Given the following original C code:\nstatic const struct of_device_id ipq9574_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq9574-tlmm\", },\n\t{ }\n};\nMODULE_DEVICE_TABLE(of, ipq9574_pinctrl_of_match);\n\nstatic struct platform_driver ipq9574_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq9574-tlmm\",\n\t\t.of_match_table = ipq9574_pinctrl_of_match,\n\t},\n\t.probe = ipq9574_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq9574_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq9574_pinctrl_driver);\n}\narch_initcall(ipq9574_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",754 "reference": "@@ -799,7 +799,6 @@ static struct platform_driver ipq9574_pinctrl_driver = {\n \t\t.of_match_table = ipq9574_pinctrl_of_match,\n \t},\n \t.probe = ipq9574_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init ipq9574_pinctrl_init(void)",755 "prediction": "Given the following original C code:\nstatic const struct of_device_id ipq9574_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,ipq9574-tlmm\", },\n\t{ }\n};\nMODULE_DEVICE_TABLE(of, ipq9574_pinctrl_of_match);\n\nstatic struct platform_driver ipq9574_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"ipq9574-tlmm\",\n\t\t.of_match_table = ipq9574_pinctrl_of_match,\n\t},\n\t.probe = ipq9574_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init ipq9574_pinctrl_init(void)\n{\n\treturn platform_driver_register(&ipq9574_pinctrl_driver);\n}\narch_initcall(ipq9574_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver ipq9574_pinctrl_driver = {\n \t\t.name = \"ipq9574-tlmm\",\n \t\t.of_match_table = ipq9574_pinctrl_of_match,\n \t},\n-\t.probe = ipq9574_pinctrl_probe,\n+\t.probe = ipq9574_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -110,7 +110,7 @@ static int __init ipq9574_pinctrl_init(void)\n \treturn platform_driver_register(&ipq9574_pinctrl_driver);\n }\n arch_initcall(ipq9574_pinctrl_init);\n-\n+\n static void __exit ipq9574_pinctrl_exit(void)\n {\n \tplatform_driver"756 },757 {758 "prompt": "Given the following original C code:\nstatic const struct of_device_id mdm9607_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,mdm9607-tlmm\", },\n\t{ }\n};\n\nstatic struct platform_driver mdm9607_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"mdm9607-pinctrl\",\n\t\t.of_match_table = mdm9607_pinctrl_of_match,\n\t},\n\t.probe = mdm9607_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init mdm9607_pinctrl_init(void)\n{\n\treturn platform_driver_register(&mdm9607_pinctrl_driver);\n}\narch_initcall(mdm9607_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",759 "reference": "@@ -1059,7 +1059,6 @@ static struct platform_driver mdm9607_pinctrl_driver = {\n \t\t.of_match_table = mdm9607_pinctrl_of_match,\n \t},\n \t.probe = mdm9607_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init mdm9607_pinctrl_init(void)",760 "prediction": "Given the following original C code:\nstatic const struct of_device_id mdm9607_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,mdm9607-tlmm\", },\n\t{ }\n};\n\nstatic struct platform_driver mdm9607_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"mdm9607-pinctrl\",\n\t\t.of_match_table = mdm9607_pinctrl_of_match,\n\t},\n\t.probe = mdm9607_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init mdm9607_pinctrl_init(void)\n{\n\treturn platform_driver_register(&mdm9607_pinctrl_driver);\n}\narch_initcall(mdm9607_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver mdm9607_pinctrl_driver = {\n \t\t.of_match_table = mdm9607_pinctrl_of_match,\n \t},\n \t.probe = mdm9607_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init mdm9607_pinctrl_init(void)\n@@ -116,7 +116,7 @@ static int __init mdm9607_pinctrl_init(void)\n \treturn platform_driver_register(&mdm9607_pinctrl_driver);\n }\n arch_initcall(mdm9607_pinctrl_init);\n-\n+\n static void __exit mdm9607_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"761 },762 {763 "prompt": "Given the following original C code:\nstatic const struct of_device_id mdm9615_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,mdm9615-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver mdm9615_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"mdm9615-pinctrl\",\n\t\t.of_match_table = mdm9615_pinctrl_of_match,\n\t},\n\t.probe = mdm9615_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init mdm9615_pinctrl_init(void)\n{\n\treturn platform_driver_register(&mdm9615_pinctrl_driver);\n}\narch_initcall(mdm9615_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",764 "reference": "@@ -446,7 +446,6 @@ static struct platform_driver mdm9615_pinctrl_driver = {\n \t\t.of_match_table = mdm9615_pinctrl_of_match,\n \t},\n \t.probe = mdm9615_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init mdm9615_pinctrl_init(void)",765 "prediction": "Given the following original C code:\nstatic const struct of_device_id mdm9615_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,mdm9615-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver mdm9615_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"mdm9615-pinctrl\",\n\t\t.of_match_table = mdm9615_pinctrl_of_match,\n\t},\n\t.probe = mdm9615_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init mdm9615_pinctrl_init(void)\n{\n\treturn platform_driver_register(&mdm9615_pinctrl_driver);\n}\narch_initcall(mdm9615_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ static struct platform_driver mdm9615_pinctrl_driver = {\n \t\t.of_match_table = mdm9615_pinctrl_of_match,\n \t},\n \t.probe = mdm9615_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init mdm9615_pinctrl_init(void)\n@@ -109,7 +109,7 @@ static int __init mdm9615_pinctrl_init(void)\n \treturn platform_driver_register(&mdm9615_pinctrl_driver);\n }\n arch_initcall(mdm9615_pinctrl_init);\n-\n+\n static void __exit mdm9615_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"766 },767 {768 "prompt": "Given the following original C code:\ngpio_irq_chip_set_chip(girq, &msm_gpio_irq_chip);\n\tgirq->parent_handler = msm_gpio_irq_handler;\n\tgirq->fwnode = dev_fwnode(pctrl->dev);\n\tgirq->num_parents = 1;\n\tgirq->parents = devm_kcalloc(pctrl->dev, 1, sizeof(*girq->parents),\n\t\t\t\t GFP_KERNEL);\n\tif (!girq->parents)\n\t\treturn -ENOMEM;\n\tgirq->default_type = IRQ_TYPE_NONE;\n\tgirq->handler = handle_bad_irq;\n\tgirq->parents[0] = pctrl->irq;\n\n\tret = gpiochip_add_data(&pctrl->chip, pctrl);\n\tif (ret) {\n\t\tdev_err(pctrl->dev, \"Failed register gpiochip\\n\");\n\t\treturn ret;\n\t}\n\n\t/*\n\t * For DeviceTree-supported systems, the gpio core checks the\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",769 "reference": "@@ -1442,7 +1442,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)\n \tgirq->handler = handle_bad_irq;\n \tgirq->parents[0] = pctrl->irq;\n \n-\tret = gpiochip_add_data(&pctrl->chip, pctrl);\n+\tret = devm_gpiochip_add_data(pctrl->dev, &pctrl->chip, pctrl);\n \tif (ret) {\n \t\tdev_err(pctrl->dev, \"Failed register gpiochip\\n\");\n \t\treturn ret;\n@@ -1463,7 +1463,6 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)\n \t\t\tdev_name(pctrl->dev), 0, 0, chip->ngpio);\n \t\tif (ret) {\n \t\t\tdev_err(pctrl->dev, \"Failed to add pin range\\n\");\n-\t\t\tgpiochip_remove(&pctrl->chip);\n \t\t\treturn ret;\n \t\t}\n \t}\n@@ -1599,13 +1598,5 @@ int msm_pinctrl_probe(struct platform_device *pdev,\n }\n EXPORT_SYMBOL(msm_pinctrl_probe);\n \n-void msm_pinctrl_remove(struct platform_device *pdev)\n-{\n-\tstruct msm_pinctrl *pctrl = platform_get_drvdata(pdev);\n-\n-\tgpiochip_remove(&pctrl->chip);\n-}\n-EXPORT_SYMBOL(msm_pinctrl_remove);\n-\n MODULE_DESCRIPTION(\"Qualcomm Technologies, Inc. TLMM driver\");\n MODULE_LICENSE(\"GPL v2\");",770 "prediction": "Given the following original C code:\ngpio_irq_chip_set_chip(girq, &msm_gpio_irq_chip);\n\tgirq->parent_handler = msm_gpio_irq_handler;\n\tgirq->fwnode = dev_fwnode(pctrl->dev);\n\tgirq->num_parents = 1;\n\tgirq->parents = devm_kcalloc(pctrl->dev, 1, sizeof(*girq->parents),\n\t\t\t\t GFP_KERNEL);\n\tif (!girq->parents)\n\t\treturn -ENOMEM;\n\tgirq->default_type = IRQ_TYPE_NONE;\n\tgirq->handler = handle_bad_irq;\n\tgirq->parents[0] = pctrl->irq;\n\n\tret = gpiochip_add_data(&pctrl->chip, pctrl);\n\tif (ret) {\n\t\tdev_err(pctrl->dev, \"Failed register gpiochip\\n\");\n\t\treturn ret;\n\t}\n\n\t/*\n\t * For DeviceTree-supported systems, the gpio core checks the\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ static int msm_gpio_probe(struct platform_device *pdev)\n \tgirq->handler = handle_bad_irq;\n \tgirq->parents[0] = pctrl->irq;\n \n-\tret = gpiochip_add_data(&pctrl->chip, pctrl);\n+\tret = devm_gpiochip_add_data(&pdev->dev, &pctrl->chip, pctrl);\n \tif (ret) {\n \t\tdev_err(pctrl->dev, \"Failed register gpiochip\\n\");\n \t\treturn ret;\n@@ -113,7 +113,7 @@ static int msm_gpio_probe(struct platform_device *pdev)\n \t\tdev_err(pctrl->dev, \"Failed register gpiochip\\n\");\n \t\treturn ret;\n \t}\n-\tgpiochip_add_pin_range(&pctrl->chip, dev"771 },772 {773 "prompt": "Given the following original C code:\nconst int *reserved_gpios;\n\tconst struct msm_gpio_wakeirq_map *wakeirq_map;\n\tunsigned int nwakeirq_map;\n\tbool wakeirq_dual_edge_errata;\n\tunsigned int gpio_func;\n\tunsigned int egpio_func;\n};\n\nextern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;\n\nint msm_pinctrl_probe(struct platform_device *pdev,\n\t\t const struct msm_pinctrl_soc_data *soc_data);\nvoid msm_pinctrl_remove(struct platform_device *pdev);\n\n#endif\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",774 "reference": "@@ -171,6 +171,5 @@ extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;\n \n int msm_pinctrl_probe(struct platform_device *pdev,\n \t\t const struct msm_pinctrl_soc_data *soc_data);\n-void msm_pinctrl_remove(struct platform_device *pdev);\n \n #endif",775 "prediction": "Given the following original C code:\nconst int *reserved_gpios;\n\tconst struct msm_gpio_wakeirq_map *wakeirq_map;\n\tunsigned int nwakeirq_map;\n\tbool wakeirq_dual_edge_errata;\n\tunsigned int gpio_func;\n\tunsigned int egpio_func;\n};\n\nextern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;\n\nint msm_pinctrl_probe(struct platform_device *pdev,\n\t\t const struct msm_pinctrl_soc_data *soc_data);\nvoid msm_pinctrl_remove(struct platform_device *pdev);\n\n#endif\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,6 +108,7 @@ extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;\n \n int msm_pinctrl_probe(struct platform_device *pdev,\n \t\t const struct msm_pinctrl_soc_data *soc_data);\n+int msm_gpiolib_probe(struct platform_device *pdev,\n \t\t const struct msm_pinctrl_soc_data *soc_data);\n void msm_pinctrl_remove(struct platform_device *pdev);\n+void msm_gpiolib_remove(struct platform_device *pdev);\n \n #endif\n \n@@ -115,6 +116,7 @@ extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;\n \n int msm_pinctrl_probe(struct platform_device *pdev,\n \t\t const struct msm_pinctrl_soc_data *s"776 },777 {778 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8226_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8226-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8226_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8226-pinctrl\",\n\t\t.of_match_table = msm8226_pinctrl_of_match,\n\t},\n\t.probe = msm8226_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8226_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8226_pinctrl_driver);\n}\narch_initcall(msm8226_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",779 "reference": "@@ -654,7 +654,6 @@ static struct platform_driver msm8226_pinctrl_driver = {\n \t\t.of_match_table = msm8226_pinctrl_of_match,\n \t},\n \t.probe = msm8226_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8226_pinctrl_init(void)",780 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8226_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8226-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8226_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8226-pinctrl\",\n\t\t.of_match_table = msm8226_pinctrl_of_match,\n\t},\n\t.probe = msm8226_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8226_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8226_pinctrl_driver);\n}\narch_initcall(msm8226_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver msm8226_pinctrl_driver = {\n \t},\n \t.probe = msm8226_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init msm8226_pinctrl_init(void)\n {\n \treturn platform_driver_register(&msm8226_pinctrl_driver);\n@@ -108,7 +108,7 @@ static int __init msm8226_pinctrl_init(void)\n \n arch_initcall(msm8226_pinctrl_init);\n \n-static void __exit msm8226_pinctrl_exit(void)\n+static void __exit msm8226_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&msm8226_pinctrl_driver);\n }"781 },782 {783 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8660_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8660-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8660_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8660-pinctrl\",\n\t\t.of_match_table = msm8660_pinctrl_of_match,\n\t},\n\t.probe = msm8660_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8660_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8660_pinctrl_driver);\n}\narch_initcall(msm8660_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",784 "reference": "@@ -981,7 +981,6 @@ static struct platform_driver msm8660_pinctrl_driver = {\n \t\t.of_match_table = msm8660_pinctrl_of_match,\n \t},\n \t.probe = msm8660_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8660_pinctrl_init(void)",785 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8660_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8660-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8660_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8660-pinctrl\",\n\t\t.of_match_table = msm8660_pinctrl_of_match,\n\t},\n\t.probe = msm8660_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8660_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8660_pinctrl_driver);\n}\narch_initcall(msm8660_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver msm8660_pinctrl_driver = {\n \t\t.of_match_table = msm8660_pinctrl_of_match,\n \t},\n \t.probe = msm8660_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8660_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init msm8660_pinctrl_init(void)\n \treturn platform_driver_register(&msm8660_pinctrl_driver);\n }\n arch_initcall(msm8660_pinctrl_init);\n-\n+\n static void __exit msm8660_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"786 },787 {788 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8909_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8909-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, msm8909_pinctrl_of_match);\n\nstatic struct platform_driver msm8909_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8909-pinctrl\",\n\t\t.of_match_table = msm8909_pinctrl_of_match,\n\t},\n\t.probe = msm8909_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8909_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8909_pinctrl_driver);\n}\narch_initcall(msm8909_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",789 "reference": "@@ -929,7 +929,6 @@ static struct platform_driver msm8909_pinctrl_driver = {\n \t\t.of_match_table = msm8909_pinctrl_of_match,\n \t},\n \t.probe = msm8909_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8909_pinctrl_init(void)",790 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8909_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8909-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, msm8909_pinctrl_of_match);\n\nstatic struct platform_driver msm8909_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8909-pinctrl\",\n\t\t.of_match_table = msm8909_pinctrl_of_match,\n\t},\n\t.probe = msm8909_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8909_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8909_pinctrl_driver);\n}\narch_initcall(msm8909_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver msm8909_pinctrl_driver = {\n \t\t.name = \"msm8909-pinctrl\",\n \t\t.of_match_table = msm8909_pinctrl_of_match,\n \t},\n-\t.probe = msm8909_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -116,7 +116,7 @@ static int __init msm8909_pinctrl_init(void)\n \treturn platform_driver_register(&msm8909_pinctrl_driver);\n }\n arch_initcall(msm8909_pinctrl_init);\n-\n+\n static void __exit msm8909_pinctrl_exit(void)\n {\n \tplatform_driver_unregister"791 },792 {793 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8916_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8916-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8916_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8916-pinctrl\",\n\t\t.of_match_table = msm8916_pinctrl_of_match,\n\t},\n\t.probe = msm8916_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8916_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8916_pinctrl_driver);\n}\narch_initcall(msm8916_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",794 "reference": "@@ -969,7 +969,6 @@ static struct platform_driver msm8916_pinctrl_driver = {\n \t\t.of_match_table = msm8916_pinctrl_of_match,\n \t},\n \t.probe = msm8916_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8916_pinctrl_init(void)",795 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8916_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8916-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8916_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8916-pinctrl\",\n\t\t.of_match_table = msm8916_pinctrl_of_match,\n\t},\n\t.probe = msm8916_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8916_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8916_pinctrl_driver);\n}\narch_initcall(msm8916_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver msm8916_pinctrl_driver = {\n \t\t.of_match_table = msm8916_pinctrl_of_match,\n \t},\n \t.probe = msm8916_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8916_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init msm8916_pinctrl_init(void)\n \treturn platform_driver_register(&msm8916_pinctrl_driver);\n }\n arch_initcall(msm8916_pinctrl_init);\n-\n+\n static void __exit msm8916_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"796 },797 {798 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8917_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8917-pinctrl\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, msm8917_pinctrl_of_match);\n\nstatic struct platform_driver msm8917_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8917-pinctrl\",\n\t\t.of_match_table = msm8917_pinctrl_of_match,\n\t},\n\t.probe = msm8917_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8917_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8917_pinctrl_driver);\n}\narch_initcall(msm8917_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",799 "reference": "@@ -1607,7 +1607,6 @@ static struct platform_driver msm8917_pinctrl_driver = {\n \t\t.of_match_table = msm8917_pinctrl_of_match,\n \t},\n \t.probe = msm8917_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8917_pinctrl_init(void)",800 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8917_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8917-pinctrl\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, msm8917_pinctrl_of_match);\n\nstatic struct platform_driver msm8917_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8917-pinctrl\",\n\t\t.of_match_table = msm8917_pinctrl_of_match,\n\t},\n\t.probe = msm8917_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8917_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8917_pinctrl_driver);\n}\narch_initcall(msm8917_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver msm8917_pinctrl_driver = {\n \t\t.name = \"msm8917-pinctrl\",\n \t\t.of_match_table = msm8917_pinctrl_of_match,\n \t},\n-\t.probe = msm8917_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -110,7 +110,7 @@ static int __init msm8917_pinctrl_init(void)\n \treturn platform_driver_register(&msm8917_pinctrl_driver);\n }\n arch_initcall(msm8917_pinctrl_init);\n-\n+\n static void __exit msm8917_pinctrl_exit(void)\n {\n \tplatform_driver_unregister"801 },802 {803 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8953_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8953-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8953_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8953-pinctrl\",\n\t\t.of_match_table = msm8953_pinctrl_of_match,\n\t},\n\t.probe = msm8953_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8953_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8953_pinctrl_driver);\n}\narch_initcall(msm8953_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",804 "reference": "@@ -1816,7 +1816,6 @@ static struct platform_driver msm8953_pinctrl_driver = {\n \t\t.of_match_table = msm8953_pinctrl_of_match,\n \t},\n \t.probe = msm8953_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8953_pinctrl_init(void)",805 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8953_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8953-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8953_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8953-pinctrl\",\n\t\t.of_match_table = msm8953_pinctrl_of_match,\n\t},\n\t.probe = msm8953_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8953_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8953_pinctrl_driver);\n}\narch_initcall(msm8953_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver msm8953_pinctrl_driver = {\n \t},\n \t.probe = msm8953_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init msm8953_pinctrl_init(void)\n {\n \treturn platform_driver_register(&msm8953_pinctrl_driver);\n@@ -108,7 +108,7 @@ static int __init msm8953_pinctrl_init(void)\n \n arch_initcall(msm8953_pinctrl_init);\n \n-static void __exit msm8953_pinctrl_exit(void)\n+static void __exit msm8953_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&msm8953_pinctrl_driver);\n }"806 },807 {808 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8960_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8960-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8960_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8960-pinctrl\",\n\t\t.of_match_table = msm8960_pinctrl_of_match,\n\t},\n\t.probe = msm8960_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8960_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8960_pinctrl_driver);\n}\narch_initcall(msm8960_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",809 "reference": "@@ -1246,7 +1246,6 @@ static struct platform_driver msm8960_pinctrl_driver = {\n \t\t.of_match_table = msm8960_pinctrl_of_match,\n \t},\n \t.probe = msm8960_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8960_pinctrl_init(void)",810 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8960_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8960-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8960_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8960-pinctrl\",\n\t\t.of_match_table = msm8960_pinctrl_of_match,\n\t},\n\t.probe = msm8960_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8960_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8960_pinctrl_driver);\n}\narch_initcall(msm8960_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -103,6 +103,7 @@ static struct platform_driver msm8960_pinctrl_driver = {\n \t\t.of_match_table = msm8960_pinctrl_of_match,\n \t},\n \t.probe = msm8960_pinctrl_probe,\n+\t.remove = msm_pinctrl_remove,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -110,6 +111,7 @@ static int __init msm8960_pinctrl_init(void)\n \treturn platform_driver_register(&msm8960_pinctrl_driver);\n }\n arch_initcall(msm8960_pinctrl_init);\n+\n+static void __exit msm8960_pinctrl_exit(void)\n+{\n \tplatform_driver_unregister(&msm8960_pinctrl_driver);\n }\n module_exit("811 },812 {813 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8976_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8976-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8976_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8976-pinctrl\",\n\t\t.of_match_table = msm8976_pinctrl_of_match,\n\t},\n\t.probe = msm8976_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8976_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8976_pinctrl_driver);\n}\narch_initcall(msm8976_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",814 "reference": "@@ -1096,7 +1096,6 @@ static struct platform_driver msm8976_pinctrl_driver = {\n \t\t.of_match_table = msm8976_pinctrl_of_match,\n \t},\n \t.probe = msm8976_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8976_pinctrl_init(void)",815 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8976_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8976-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8976_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8976-pinctrl\",\n\t\t.of_match_table = msm8976_pinctrl_of_match,\n\t},\n\t.probe = msm8976_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8976_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8976_pinctrl_driver);\n}\narch_initcall(msm8976_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver msm8976_pinctrl_driver = {\n \t},\n \t.probe = msm8976_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init msm8976_pinctrl_init(void)\n {\n \treturn platform_driver_register(&msm8976_pinctrl_driver);\n@@ -108,7 +108,7 @@ static int __init msm8976_pinctrl_init(void)\n \n arch_initcall(msm8976_pinctrl_init);\n \n-static void __exit msm8976_pinctrl_exit(void)\n+static void __exit msm8976_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&msm8976_pinctrl_driver);\n }"816 },817 {818 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8994_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8992-pinctrl\", },\n\t{ .compatible = \"qcom,msm8994-pinctrl\", },\n\t{ }\n};\n\nstatic struct platform_driver msm8994_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8994-pinctrl\",\n\t\t.of_match_table = msm8994_pinctrl_of_match,\n\t},\n\t.probe = msm8994_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8994_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8994_pinctrl_driver);\n}\narch_initcall(msm8994_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",819 "reference": "@@ -1343,7 +1343,6 @@ static struct platform_driver msm8994_pinctrl_driver = {\n \t\t.of_match_table = msm8994_pinctrl_of_match,\n \t},\n \t.probe = msm8994_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8994_pinctrl_init(void)",820 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8994_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8992-pinctrl\", },\n\t{ .compatible = \"qcom,msm8994-pinctrl\", },\n\t{ }\n};\n\nstatic struct platform_driver msm8994_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8994-pinctrl\",\n\t\t.of_match_table = msm8994_pinctrl_of_match,\n\t},\n\t.probe = msm8994_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8994_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8994_pinctrl_driver);\n}\narch_initcall(msm8994_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver msm8994_pinctrl_driver = {\n \t\t.name = \"msm8994-pinctrl\",\n \t\t.of_match_table = msm8994_pinctrl_of_match,\n \t},\n-\t.probe = msm8994_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -108,7 +108,7 @@ static int __init msm8994_pinctrl_init(void)\n \treturn platform_driver_register(&msm8994_pinctrl_driver);\n }\n arch_initcall(msm8994_pinctrl_init);\n-\n+\n static void __exit msm8994_pinctrl_exit(void)\n {\n \tplatform_driver_unregister"821 },822 {823 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8996_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8996-pinctrl\", },\n\t{ }\n};\n\nstatic struct platform_driver msm8996_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8996-pinctrl\",\n\t\t.of_match_table = msm8996_pinctrl_of_match,\n\t},\n\t.probe = msm8996_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8996_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8996_pinctrl_driver);\n}\narch_initcall(msm8996_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",824 "reference": "@@ -1920,7 +1920,6 @@ static struct platform_driver msm8996_pinctrl_driver = {\n \t\t.of_match_table = msm8996_pinctrl_of_match,\n \t},\n \t.probe = msm8996_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8996_pinctrl_init(void)",825 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8996_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8996-pinctrl\", },\n\t{ }\n};\n\nstatic struct platform_driver msm8996_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8996-pinctrl\",\n\t\t.of_match_table = msm8996_pinctrl_of_match,\n\t},\n\t.probe = msm8996_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8996_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8996_pinctrl_driver);\n}\narch_initcall(msm8996_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,6 +100,7 @@ static struct platform_driver msm8996_pinctrl_driver = {\n \t\t.of_match_table = msm8996_pinctrl_of_match,\n \t},\n \t.probe = msm8996_pinctrl_probe,\n+\t.remove = msm_pinctrl_remove,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -107,3 +108,4 @@ static int __init msm8996_pinctrl_init(void)\n \treturn platform_driver_register(&msm8996_pinctrl_driver);\n }\n arch_initcall(msm8996_pinctrl_init);\n+\n+static void __exit msm8996_pinctrl_exit(void)\n+{\n \tplatform_driver_unregister(&msm8996_pinctrl_driver);\n }\n module_exit("826 },827 {828 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8998_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8998-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8998_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8998-pinctrl\",\n\t\t.of_match_table = msm8998_pinctrl_of_match,\n\t},\n\t.probe = msm8998_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8998_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8998_pinctrl_driver);\n}\narch_initcall(msm8998_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",829 "reference": "@@ -1535,7 +1535,6 @@ static struct platform_driver msm8998_pinctrl_driver = {\n \t\t.of_match_table = msm8998_pinctrl_of_match,\n \t},\n \t.probe = msm8998_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8998_pinctrl_init(void)",830 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8998_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8998-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8998_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8998-pinctrl\",\n\t\t.of_match_table = msm8998_pinctrl_of_match,\n\t},\n\t.probe = msm8998_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8998_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8998_pinctrl_driver);\n}\narch_initcall(msm8998_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver msm8998_pinctrl_driver = {\n \t\t.of_match_table = msm8998_pinctrl_of_match,\n \t},\n \t.probe = msm8998_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8998_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init msm8998_pinctrl_init(void)\n \treturn platform_driver_register(&msm8998_pinctrl_driver);\n }\n arch_initcall(msm8998_pinctrl_init);\n-\n+\n static void __exit msm8998_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"831 },832 {833 "prompt": "Given the following original C code:\nstatic const struct of_device_id msm8x74_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8974-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8x74_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8x74-pinctrl\",\n\t\t.of_match_table = msm8x74_pinctrl_of_match,\n\t},\n\t.probe = msm8x74_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8x74_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8x74_pinctrl_driver);\n}\narch_initcall(msm8x74_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",834 "reference": "@@ -1083,7 +1083,6 @@ static struct platform_driver msm8x74_pinctrl_driver = {\n \t\t.of_match_table = msm8x74_pinctrl_of_match,\n \t},\n \t.probe = msm8x74_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8x74_pinctrl_init(void)",835 "prediction": "Given the following original C code:\nstatic const struct of_device_id msm8x74_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,msm8974-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver msm8x74_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"msm8x74-pinctrl\",\n\t\t.of_match_table = msm8x74_pinctrl_of_match,\n\t},\n\t.probe = msm8x74_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init msm8x74_pinctrl_init(void)\n{\n\treturn platform_driver_register(&msm8x74_pinctrl_driver);\n}\narch_initcall(msm8x74_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver msm8x74_pinctrl_driver = {\n \t\t.of_match_table = msm8x74_pinctrl_of_match,\n \t},\n \t.probe = msm8x74_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init msm8x74_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init msm8x74_pinctrl_init(void)\n \treturn platform_driver_register(&msm8x74_pinctrl_driver);\n }\n arch_initcall(msm8x74_pinctrl_init);\n-\n+\n static void __exit msm8x74_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"836 },837 {838 "prompt": "Given the following original C code:\nstatic const struct of_device_id qcm2290_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,qcm2290-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver qcm2290_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"qcm2290-pinctrl\",\n\t\t.of_match_table = qcm2290_pinctrl_of_match,\n\t},\n\t.probe = qcm2290_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qcm2290_pinctrl_init(void)\n{\n\treturn platform_driver_register(&qcm2290_pinctrl_driver);\n}\narch_initcall(qcm2290_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",839 "reference": "@@ -1125,7 +1125,6 @@ static struct platform_driver qcm2290_pinctrl_driver = {\n \t\t.of_match_table = qcm2290_pinctrl_of_match,\n \t},\n \t.probe = qcm2290_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qcm2290_pinctrl_init(void)",840 "prediction": "Given the following original C code:\nstatic const struct of_device_id qcm2290_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,qcm2290-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver qcm2290_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"qcm2290-pinctrl\",\n\t\t.of_match_table = qcm2290_pinctrl_of_match,\n\t},\n\t.probe = qcm2290_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qcm2290_pinctrl_init(void)\n{\n\treturn platform_driver_register(&qcm2290_pinctrl_driver);\n}\narch_initcall(qcm2290_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver qcm2290_pinctrl_driver = {\n \t\t.of_match_table = qcm2290_pinctrl_of_match,\n \t},\n \t.probe = qcm2290_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qcm2290_pinctrl_init(void)\n@@ -116,7 +116,7 @@ static int __init qcm2290_pinctrl_init(void)\n \treturn platform_driver_register(&qcm2290_pinctrl_driver);\n }\n arch_initcall(qcm2290_pinctrl_init);\n-\n+\n static void __exit qcm2290_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"841 },842 {843 "prompt": "Given the following original C code:\nstatic const struct of_device_id qcs404_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,qcs404-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver qcs404_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"qcs404-pinctrl\",\n\t\t.of_match_table = qcs404_pinctrl_of_match,\n\t},\n\t.probe = qcs404_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qcs404_pinctrl_init(void)\n{\n\treturn platform_driver_register(&qcs404_pinctrl_driver);\n}\narch_initcall(qcs404_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",844 "reference": "@@ -1644,7 +1644,6 @@ static struct platform_driver qcs404_pinctrl_driver = {\n \t\t.of_match_table = qcs404_pinctrl_of_match,\n \t},\n \t.probe = qcs404_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qcs404_pinctrl_init(void)",845 "prediction": "Given the following original C code:\nstatic const struct of_device_id qcs404_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,qcs404-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver qcs404_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"qcs404-pinctrl\",\n\t\t.of_match_table = qcs404_pinctrl_of_match,\n\t},\n\t.probe = qcs404_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qcs404_pinctrl_init(void)\n{\n\treturn platform_driver_register(&qcs404_pinctrl_driver);\n}\narch_initcall(qcs404_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver qcs404_pinctrl_driver = {\n \t\t.of_match_table = qcs404_pinctrl_of_match,\n \t},\n \t.probe = qcs404_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qcs404_pinctrl_init(void)\n@@ -116,7 +116,7 @@ static int __init qcs404_pinctrl_init(void)\n \treturn platform_driver_register(&qcs404_pinctrl_driver);\n }\n arch_initcall(qcs404_pinctrl_init);\n-\n+\n static void __exit qcs404_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&qcs404_pinct"846 },847 {848 "prompt": "Given the following original C code:\nstatic int qcs615_tlmm_probe(struct platform_device *pdev)\n{\n\treturn msm_pinctrl_probe(pdev, &qcs615_tlmm);\n}\n\nstatic struct platform_driver qcs615_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"qcs615-tlmm\",\n\t\t.of_match_table = qcs615_tlmm_of_match,\n\t},\n\t.probe = qcs615_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qcs615_tlmm_init(void)\n{\n\treturn platform_driver_register(&qcs615_tlmm_driver);\n}\narch_initcall(qcs615_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",849 "reference": "@@ -1087,7 +1087,6 @@ static struct platform_driver qcs615_tlmm_driver = {\n \t\t.of_match_table = qcs615_tlmm_of_match,\n \t},\n \t.probe = qcs615_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qcs615_tlmm_init(void)",850 "prediction": "Given the following original C code:\nstatic int qcs615_tlmm_probe(struct platform_device *pdev)\n{\n\treturn msm_pinctrl_probe(pdev, &qcs615_tlmm);\n}\n\nstatic struct platform_driver qcs615_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"qcs615-tlmm\",\n\t\t.of_match_table = qcs615_tlmm_of_match,\n\t},\n\t.probe = qcs615_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qcs615_tlmm_init(void)\n{\n\treturn platform_driver_register(&qcs615_tlmm_driver);\n}\narch_initcall(qcs615_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -103,7 +103,7 @@ static struct platform_driver qcs615_tlmm_driver = {\n \t\t.of_match_table = qcs615_tlmm_of_match,\n \t},\n \t.probe = qcs615_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qcs615_tlmm_init(void)\n@@ -111,7 +111,7 @@ static int __init qcs615_tlmm_init(void)\n \treturn platform_driver_register(&qcs615_tlmm_driver);\n }\n arch_initcall(qcs615_tlmm_init);\n-\n+\n static void __exit qcs615_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&qcs615_tlmm_driver);\n@@ -11"851 },852 {853 "prompt": "Given the following original C code:\nstatic const struct of_device_id qcs8300_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,qcs8300-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, qcs8300_pinctrl_of_match);\n\nstatic struct platform_driver qcs8300_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"qcs8300-tlmm\",\n\t\t.of_match_table = qcs8300_pinctrl_of_match,\n\t},\n\t.probe = qcs8300_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qcs8300_pinctrl_init(void)\n{\n\treturn platform_driver_register(&qcs8300_pinctrl_driver);\n}\narch_initcall(qcs8300_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",854 "reference": "@@ -1227,7 +1227,6 @@ static struct platform_driver qcs8300_pinctrl_driver = {\n \t\t.of_match_table = qcs8300_pinctrl_of_match,\n \t},\n \t.probe = qcs8300_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qcs8300_pinctrl_init(void)",855 "prediction": "Given the following original C code:\nstatic const struct of_device_id qcs8300_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,qcs8300-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, qcs8300_pinctrl_of_match);\n\nstatic struct platform_driver qcs8300_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"qcs8300-tlmm\",\n\t\t.of_match_table = qcs8300_pinctrl_of_match,\n\t},\n\t.probe = qcs8300_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qcs8300_pinctrl_init(void)\n{\n\treturn platform_driver_register(&qcs8300_pinctrl_driver);\n}\narch_initcall(qcs8300_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver qcs8300_pinctrl_driver = {\n \t\t.name = \"qcs8300-tlmm\",\n \t\t.of_match_table = qcs8300_pinctrl_of_match,\n \t},\n-\t.probe = qcs8300_pinctrl_probe,\n+\t.probe = qcs8300_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -116,7 +116,7 @@ static int __init qcs8300_pinctrl_init(void)\n \treturn platform_driver_register(&qcs8300_pinctrl_driver);\n }\n arch_initcall(qcs8300_pinctrl_init);\n-\n+\n static void __exit qcs8300_pinctrl_exit(void)\n {\n \tplatform_driver"856 },857 {858 "prompt": "Given the following original C code:\nstatic const struct acpi_device_id qdf2xxx_acpi_ids[] = {\n\t{\"QCOM8002\"},\n\t{},\n};\nMODULE_DEVICE_TABLE(acpi, qdf2xxx_acpi_ids);\n\nstatic struct platform_driver qdf2xxx_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"qdf2xxx-pinctrl\",\n\t\t.acpi_match_table = qdf2xxx_acpi_ids,\n\t},\n\t.probe = qdf2xxx_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qdf2xxx_pinctrl_init(void)\n{\n\treturn platform_driver_register(&qdf2xxx_pinctrl_driver);\n}\narch_initcall(qdf2xxx_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",859 "reference": "@@ -145,7 +145,6 @@ static struct platform_driver qdf2xxx_pinctrl_driver = {\n \t\t.acpi_match_table = qdf2xxx_acpi_ids,\n \t},\n \t.probe = qdf2xxx_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qdf2xxx_pinctrl_init(void)",860 "prediction": "Given the following original C code:\nstatic const struct acpi_device_id qdf2xxx_acpi_ids[] = {\n\t{\"QCOM8002\"},\n\t{},\n};\nMODULE_DEVICE_TABLE(acpi, qdf2xxx_acpi_ids);\n\nstatic struct platform_driver qdf2xxx_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"qdf2xxx-pinctrl\",\n\t\t.acpi_match_table = qdf2xxx_acpi_ids,\n\t},\n\t.probe = qdf2xxx_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qdf2xxx_pinctrl_init(void)\n{\n\treturn platform_driver_register(&qdf2xxx_pinctrl_driver);\n}\narch_initcall(qdf2xxx_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver qdf2xxx_pinctrl_driver = {\n \t\t.name = \"qdf2xxx-pinctrl\",\n \t\t.acpi_match_table = qdf2xxx_acpi_ids,\n \t},\n-\t.probe = qdf2xxx_pinctrl_probe,\n+\t.probe = qdf2xxx_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -116,7 +116,7 @@ static int __init qdf2xxx_pinctrl_init(void)\n \treturn platform_driver_register(&qdf2xxx_pinctrl_driver);\n }\n arch_initcall(qdf2xxx_pinctrl_init);\n-\n+\n static void __exit qdf2xxx_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&qdf2xxx_pinctrl_driver);\n@@ -1"861 },862 {863 "prompt": "Given the following original C code:\nstatic const struct of_device_id qdu1000_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,qdu1000-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, qdu1000_tlmm_of_match);\n\nstatic struct platform_driver qdu1000_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"qdu1000-tlmm\",\n\t\t.of_match_table = qdu1000_tlmm_of_match,\n\t},\n\t.probe = qdu1000_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qdu1000_tlmm_init(void)\n{\n\treturn platform_driver_register(&qdu1000_tlmm_driver);\n}\narch_initcall(qdu1000_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",864 "reference": "@@ -1248,7 +1248,6 @@ static struct platform_driver qdu1000_tlmm_driver = {\n \t\t.of_match_table = qdu1000_tlmm_of_match,\n \t},\n \t.probe = qdu1000_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init qdu1000_tlmm_init(void)",865 "prediction": "Given the following original C code:\nstatic const struct of_device_id qdu1000_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,qdu1000-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, qdu1000_tlmm_of_match);\n\nstatic struct platform_driver qdu1000_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"qdu1000-tlmm\",\n\t\t.of_match_table = qdu1000_tlmm_of_match,\n\t},\n\t.probe = qdu1000_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init qdu1000_tlmm_init(void)\n{\n\treturn platform_driver_register(&qdu1000_tlmm_driver);\n}\narch_initcall(qdu1000_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver qdu1000_tlmm_driver = {\n \t\t.name = \"qdu1000-tlmm\",\n \t\t.of_match_table = qdu1000_tlmm_of_match,\n \t},\n-\t.probe = qdu1000_tlmm_probe,\n+\t.probe = qdu1000_tlmm_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -110,7 +110,7 @@ static int __init qdu1000_tlmm_init(void)\n \treturn platform_driver_register(&qdu1000_tlmm_driver);\n }\n arch_initcall(qdu1000_tlmm_init);\n-\n+\n static void __exit qdu1000_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&qdu10"866 },867 {868 "prompt": "Given the following original C code:\nstatic const struct of_device_id sa8775p_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sa8775p-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sa8775p_pinctrl_of_match);\n\nstatic struct platform_driver sa8775p_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sa8775p-tlmm\",\n\t\t.of_match_table = sa8775p_pinctrl_of_match,\n\t},\n\t.probe = sa8775p_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sa8775p_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sa8775p_pinctrl_driver);\n}\narch_initcall(sa8775p_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",869 "reference": "@@ -1540,7 +1540,6 @@ static struct platform_driver sa8775p_pinctrl_driver = {\n \t\t.of_match_table = sa8775p_pinctrl_of_match,\n \t},\n \t.probe = sa8775p_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sa8775p_pinctrl_init(void)",870 "prediction": "Given the following original C code:\nstatic const struct of_device_id sa8775p_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sa8775p-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sa8775p_pinctrl_of_match);\n\nstatic struct platform_driver sa8775p_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sa8775p-tlmm\",\n\t\t.of_match_table = sa8775p_pinctrl_of_match,\n\t},\n\t.probe = sa8775p_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sa8775p_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sa8775p_pinctrl_driver);\n}\narch_initcall(sa8775p_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sa8775p_pinctrl_driver = {\n \t\t.name = \"sa8775p-tlmm\",\n \t\t.of_match_table = sa8775p_pinctrl_of_match,\n \t},\n-\t.probe = sa8775p_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -116,7 +116,7 @@ static int __init sa8775p_pinctrl_init(void)\n \treturn platform_driver_register(&sa8775p_pinctrl_driver);\n }\n arch_initcall(sa8775p_pinctrl_init);\n-\n+\n static void __exit sa8775p_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"871 },872 {873 "prompt": "Given the following original C code:\nstatic const struct of_device_id sar2130p_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sar2130p-tlmm\", .data = &sar2130p_tlmm},\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sar2130p_tlmm_of_match);\n\nstatic struct platform_driver sar2130p_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sar2130p-tlmm\",\n\t\t.of_match_table = sar2130p_tlmm_of_match,\n\t},\n\t.probe = sar2130p_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sar2130p_tlmm_init(void)\n{\n\treturn platform_driver_register(&sar2130p_tlmm_driver);\n}\narch_initcall(sar2130p_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",874 "reference": "@@ -1486,7 +1486,6 @@ static struct platform_driver sar2130p_tlmm_driver = {\n \t\t.of_match_table = sar2130p_tlmm_of_match,\n \t},\n \t.probe = sar2130p_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sar2130p_tlmm_init(void)",875 "prediction": "Given the following original C code:\nstatic const struct of_device_id sar2130p_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sar2130p-tlmm\", .data = &sar2130p_tlmm},\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sar2130p_tlmm_of_match);\n\nstatic struct platform_driver sar2130p_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sar2130p-tlmm\",\n\t\t.of_match_table = sar2130p_tlmm_of_match,\n\t},\n\t.probe = sar2130p_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sar2130p_tlmm_init(void)\n{\n\treturn platform_driver_register(&sar2130p_tlmm_driver);\n}\narch_initcall(sar2130p_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sar2130p_tlmm_driver = {\n \t\t.name = \"sar2130p-tlmm\",\n \t\t.of_match_table = sar2130p_tlmm_of_match,\n \t},\n-\t.probe = sar2130p_tlmm_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -116,7 +116,7 @@ static int __init sar2130p_tlmm_init(void)\n \treturn platform_driver_register(&sar2130p_tlmm_driver);\n }\n arch_initcall(sar2130p_tlmm_init);\n-\n+\n static void __exit sar2130p_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sar21"876 },877 {878 "prompt": "Given the following original C code:\nstatic const struct of_device_id sc7180_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sc7180-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sc7180_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sc7180-pinctrl\",\n\t\t.pm = &msm_pinctrl_dev_pm_ops,\n\t\t.of_match_table = sc7180_pinctrl_of_match,\n\t},\n\t.probe = sc7180_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sc7180_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sc7180_pinctrl_driver);\n}\narch_initcall(sc7180_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",879 "reference": "@@ -1159,7 +1159,6 @@ static struct platform_driver sc7180_pinctrl_driver = {\n \t\t.of_match_table = sc7180_pinctrl_of_match,\n \t},\n \t.probe = sc7180_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sc7180_pinctrl_init(void)",880 "prediction": "Given the following original C code:\nstatic const struct of_device_id sc7180_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sc7180-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sc7180_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sc7180-pinctrl\",\n\t\t.pm = &msm_pinctrl_dev_pm_ops,\n\t\t.of_match_table = sc7180_pinctrl_of_match,\n\t},\n\t.probe = sc7180_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sc7180_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sc7180_pinctrl_driver);\n}\narch_initcall(sc7180_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sc7180_pinctrl_driver = {\n \t\t.of_match_table = sc7180_pinctrl_of_match,\n \t},\n \t.probe = sc7180_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sc7180_pinctrl_init(void)\n@@ -116,7 +116,7 @@ static int __init sc7180_pinctrl_init(void)\n \treturn platform_driver_register(&sc7180_pinctrl_driver);\n }\n arch_initcall(sc7180_pinctrl_init);\n-\n+\n static void __exit sc7180_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&sc7180_pinct"881 },882 {883 "prompt": "Given the following original C code:\nstatic const struct of_device_id sc7280_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sc7280-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sc7280_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sc7280-pinctrl\",\n\t\t.pm = &msm_pinctrl_dev_pm_ops,\n\t\t.of_match_table = sc7280_pinctrl_of_match,\n\t},\n\t.probe = sc7280_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sc7280_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sc7280_pinctrl_driver);\n}\narch_initcall(sc7280_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",884 "reference": "@@ -1505,7 +1505,6 @@ static struct platform_driver sc7280_pinctrl_driver = {\n \t\t.of_match_table = sc7280_pinctrl_of_match,\n \t},\n \t.probe = sc7280_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sc7280_pinctrl_init(void)",885 "prediction": "Given the following original C code:\nstatic const struct of_device_id sc7280_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sc7280-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sc7280_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sc7280-pinctrl\",\n\t\t.pm = &msm_pinctrl_dev_pm_ops,\n\t\t.of_match_table = sc7280_pinctrl_of_match,\n\t},\n\t.probe = sc7280_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sc7280_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sc7280_pinctrl_driver);\n}\narch_initcall(sc7280_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver sc7280_pinctrl_driver = {\n \t\t.of_match_table = sc7280_pinctrl_of_match,\n \t},\n \t.probe = sc7280_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sc7280_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init sc7280_pinctrl_init(void)\n \treturn platform_driver_register(&sc7280_pinctrl_driver);\n }\n arch_initcall(sc7280_pinctrl_init);\n-\n+\n static void __exit sc7280_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&sc7280_pinct"886 },887 {888 "prompt": "Given the following original C code:\n},\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sc8180x_pinctrl_of_match);\n\nstatic struct platform_driver sc8180x_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sc8180x-pinctrl\",\n\t\t.of_match_table = sc8180x_pinctrl_of_match,\n\t\t.acpi_match_table = sc8180x_pinctrl_acpi_match,\n\t},\n\t.probe = sc8180x_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sc8180x_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sc8180x_pinctrl_driver);\n}\narch_initcall(sc8180x_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",889 "reference": "@@ -1720,7 +1720,6 @@ static struct platform_driver sc8180x_pinctrl_driver = {\n \t\t.acpi_match_table = sc8180x_pinctrl_acpi_match,\n \t},\n \t.probe = sc8180x_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sc8180x_pinctrl_init(void)",890 "prediction": "Given the following original C code:\n},\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sc8180x_pinctrl_of_match);\n\nstatic struct platform_driver sc8180x_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sc8180x-pinctrl\",\n\t\t.of_match_table = sc8180x_pinctrl_of_match,\n\t\t.acpi_match_table = sc8180x_pinctrl_acpi_match,\n\t},\n\t.probe = sc8180x_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sc8180x_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sc8180x_pinctrl_driver);\n}\narch_initcall(sc8180x_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sc8180x_pinctrl_driver = {\n \t\t.acpi_match_table = sc8180x_pinctrl_acpi_match,\n \t},\n \t.probe = sc8180x_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sc8180x_pinctrl_init(void)\n@@ -116,7 +116,7 @@ static int __init sc8180x_pinctrl_init(void)\n \treturn platform_driver_register(&sc8180x_pinctrl_driver);\n }\n arch_initcall(sc8180x_pinctrl_init);\n-\n+\n static void __exit sc8180x_pinctrl_exit(void)\n {\n \tplatform_driver_un"891 },892 {893 "prompt": "Given the following original C code:\nstatic const struct of_device_id sc8280xp_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sc8280xp-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sc8280xp_pinctrl_of_match);\n\nstatic struct platform_driver sc8280xp_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sc8280xp-tlmm\",\n\t\t.of_match_table = sc8280xp_pinctrl_of_match,\n\t},\n\t.probe = sc8280xp_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sc8280xp_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sc8280xp_pinctrl_driver);\n}\narch_initcall(sc8280xp_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",894 "reference": "@@ -1926,7 +1926,6 @@ static struct platform_driver sc8280xp_pinctrl_driver = {\n \t\t.of_match_table = sc8280xp_pinctrl_of_match,\n \t},\n \t.probe = sc8280xp_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sc8280xp_pinctrl_init(void)",895 "prediction": "Given the following original C code:\nstatic const struct of_device_id sc8280xp_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sc8280xp-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sc8280xp_pinctrl_of_match);\n\nstatic struct platform_driver sc8280xp_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sc8280xp-tlmm\",\n\t\t.of_match_table = sc8280xp_pinctrl_of_match,\n\t},\n\t.probe = sc8280xp_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sc8280xp_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sc8280xp_pinctrl_driver);\n}\narch_initcall(sc8280xp_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver sc8280xp_pinctrl_driver = {\n \t\t.name = \"sc8280xp-tlmm\",\n \t\t.of_match_table = sc8280xp_pinctrl_of_match,\n \t},\n-\t.probe = sc8280xp_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -110,7 +110,7 @@ static int __init sc8280xp_pinctrl_init(void)\n \treturn platform_driver_register(&sc8280xp_pinctrl_driver);\n }\n arch_initcall(sc8280xp_pinctrl_init);\n-\n+\n static void __exit sc8280xp_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"896 },897 {898 "prompt": "Given the following original C code:\nstatic const struct of_device_id sdm660_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sdm660-pinctrl\", },\n\t{ .compatible = \"qcom,sdm630-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sdm660_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdm660-pinctrl\",\n\t\t.of_match_table = sdm660_pinctrl_of_match,\n\t},\n\t.probe = sdm660_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdm660_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdm660_pinctrl_driver);\n}\narch_initcall(sdm660_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",899 "reference": "@@ -1442,7 +1442,6 @@ static struct platform_driver sdm660_pinctrl_driver = {\n \t\t.of_match_table = sdm660_pinctrl_of_match,\n \t},\n \t.probe = sdm660_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sdm660_pinctrl_init(void)",900 "prediction": "Given the following original C code:\nstatic const struct of_device_id sdm660_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sdm660-pinctrl\", },\n\t{ .compatible = \"qcom,sdm630-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sdm660_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdm660-pinctrl\",\n\t\t.of_match_table = sdm660_pinctrl_of_match,\n\t},\n\t.probe = sdm660_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdm660_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdm660_pinctrl_driver);\n}\narch_initcall(sdm660_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sdm660_pinctrl_driver = {\n \t\t.name = \"sdm660-pinctrl\",\n \t\t.of_match_table = sdm660_pinctrl_of_match,\n \t},\n-\t.probe = sdm660_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -116,7 +116,7 @@ static int __init sdm660_pinctrl_init(void)\n {\n \treturn platform_driver_register(&sdm660_pinctrl_driver);\n }\n-arch_initcall(sdm660_pinctrl_init);\n+module_init(sdm660_pinctrl_init);\n \n static void __exit sdm660_pinctrl_exit(void)"901 },902 {903 "prompt": "Given the following original C code:\nstatic const struct of_device_id sdm670_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sdm670-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sdm670_pinctrl_of_match);\n\nstatic struct platform_driver sdm670_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdm670-pinctrl\",\n\t\t.of_match_table = sdm670_pinctrl_of_match,\n\t},\n\t.probe = sdm670_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdm670_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdm670_pinctrl_driver);\n}\narch_initcall(sdm670_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",904 "reference": "@@ -1337,7 +1337,6 @@ static struct platform_driver sdm670_pinctrl_driver = {\n \t\t.of_match_table = sdm670_pinctrl_of_match,\n \t},\n \t.probe = sdm670_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sdm670_pinctrl_init(void)",905 "prediction": "Given the following original C code:\nstatic const struct of_device_id sdm670_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sdm670-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sdm670_pinctrl_of_match);\n\nstatic struct platform_driver sdm670_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdm670-pinctrl\",\n\t\t.of_match_table = sdm670_pinctrl_of_match,\n\t},\n\t.probe = sdm670_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdm670_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdm670_pinctrl_driver);\n}\narch_initcall(sdm670_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sdm670_pinctrl_driver = {\n \t\t.name = \"sdm670-pinctrl\",\n \t\t.of_match_table = sdm670_pinctrl_of_match,\n \t},\n-\t.probe = sdm670_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -116,7 +116,7 @@ static int __init sdm670_pinctrl_init(void)\n {\n \treturn platform_driver_register(&sdm670_pinctrl_driver);\n }\n-arch_initcall(sdm670_pinctrl_init);\n+module_init(sdm670_pinctrl_init);\n \n static void __exit sdm670_pinctrl_exit(void)"906 },907 {908 "prompt": "Given the following original C code:\n{ .compatible = \"qcom,sdm845-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sdm845_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdm845-pinctrl\",\n\t\t.pm = &msm_pinctrl_dev_pm_ops,\n\t\t.of_match_table = sdm845_pinctrl_of_match,\n\t\t.acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match),\n\t},\n\t.probe = sdm845_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdm845_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdm845_pinctrl_driver);\n}\narch_initcall(sdm845_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",909 "reference": "@@ -1351,7 +1351,6 @@ static struct platform_driver sdm845_pinctrl_driver = {\n \t\t.acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match),\n \t},\n \t.probe = sdm845_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sdm845_pinctrl_init(void)",910 "prediction": "Given the following original C code:\n{ .compatible = \"qcom,sdm845-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sdm845_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdm845-pinctrl\",\n\t\t.pm = &msm_pinctrl_dev_pm_ops,\n\t\t.of_match_table = sdm845_pinctrl_of_match,\n\t\t.acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match),\n\t},\n\t.probe = sdm845_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdm845_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdm845_pinctrl_driver);\n}\narch_initcall(sdm845_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver sdm845_pinctrl_driver = {\n \t\t.acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match),\n \t},\n \t.probe = sdm845_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sdm845_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init sdm845_pinctrl_init(void)\n \treturn platform_driver_register(&sdm845_pinctrl_driver);\n }\n arch_initcall(sdm845_pinctrl_init);\n-\n+\n static void __exit sdm845_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&"911 },912 {913 "prompt": "Given the following original C code:\nstatic const struct of_device_id sdx55_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sdx55-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sdx55_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdx55-pinctrl\",\n\t\t.of_match_table = sdx55_pinctrl_of_match,\n\t},\n\t.probe = sdx55_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdx55_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdx55_pinctrl_driver);\n}\narch_initcall(sdx55_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",914 "reference": "@@ -990,7 +990,6 @@ static struct platform_driver sdx55_pinctrl_driver = {\n \t\t.of_match_table = sdx55_pinctrl_of_match,\n \t},\n \t.probe = sdx55_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sdx55_pinctrl_init(void)",915 "prediction": "Given the following original C code:\nstatic const struct of_device_id sdx55_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sdx55-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sdx55_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdx55-pinctrl\",\n\t\t.of_match_table = sdx55_pinctrl_of_match,\n\t},\n\t.probe = sdx55_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdx55_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdx55_pinctrl_driver);\n}\narch_initcall(sdx55_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver sdx55_pinctrl_driver = {\n \t},\n \t.probe = sdx55_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init sdx55_pinctrl_init(void)\n {\n \treturn platform_driver_register(&sdx55_pinctrl_driver);\n@@ -108,7 +108,7 @@ static int __init sdx55_pinctrl_init(void)\n \n arch_initcall(sdx55_pinctrl_init);\n \n-static void __exit sdx55_pinctrl_exit(void)\n+static void __exit sdx55_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&sdx55_pinctrl_driver);\n }\n@@ -116,7 +116,7 @@ static void"916 },917 {918 "prompt": "Given the following original C code:\nstatic const struct of_device_id sdx65_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sdx65-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sdx65_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdx65-tlmm\",\n\t\t.of_match_table = sdx65_pinctrl_of_match,\n\t},\n\t.probe = sdx65_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdx65_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdx65_pinctrl_driver);\n}\narch_initcall(sdx65_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",919 "reference": "@@ -939,7 +939,6 @@ static struct platform_driver sdx65_pinctrl_driver = {\n \t\t.of_match_table = sdx65_pinctrl_of_match,\n \t},\n \t.probe = sdx65_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sdx65_pinctrl_init(void)",920 "prediction": "Given the following original C code:\nstatic const struct of_device_id sdx65_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sdx65-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sdx65_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdx65-tlmm\",\n\t\t.of_match_table = sdx65_pinctrl_of_match,\n\t},\n\t.probe = sdx65_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdx65_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdx65_pinctrl_driver);\n}\narch_initcall(sdx65_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver sdx65_pinctrl_driver = {\n \t\t.of_match_table = sdx65_pinctrl_of_match,\n \t},\n \t.probe = sdx65_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sdx65_pinctrl_init(void)\n@@ -110,7 +110,7 @@ static int __init sdx65_pinctrl_init(void)\n \treturn platform_driver_register(&sdx65_pinctrl_driver);\n }\n arch_initcall(sdx65_pinctrl_init);\n-\n+\n static void __exit sdx65_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&sdx65_pinctrl_driver);\n@@ -11"921 },922 {923 "prompt": "Given the following original C code:\nif (!pinctrl_data)\n\t\treturn -EINVAL;\n\n\treturn msm_pinctrl_probe(pdev, pinctrl_data);\n}\n\nstatic struct platform_driver sdx75_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdx75-tlmm\",\n\t\t.of_match_table = sdx75_pinctrl_of_match,\n\t},\n\t.probe = sdx75_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdx75_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdx75_pinctrl_driver);\n}\narch_initcall(sdx75_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",924 "reference": "@@ -1124,7 +1124,6 @@ static struct platform_driver sdx75_pinctrl_driver = {\n \t\t.of_match_table = sdx75_pinctrl_of_match,\n \t},\n \t.probe = sdx75_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sdx75_pinctrl_init(void)",925 "prediction": "Given the following original C code:\nif (!pinctrl_data)\n\t\treturn -EINVAL;\n\n\treturn msm_pinctrl_probe(pdev, pinctrl_data);\n}\n\nstatic struct platform_driver sdx75_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sdx75-tlmm\",\n\t\t.of_match_table = sdx75_pinctrl_of_match,\n\t},\n\t.probe = sdx75_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sdx75_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sdx75_pinctrl_driver);\n}\narch_initcall(sdx75_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sdx75_pinctrl_driver = {\n \t\t.name = \"sdx75-tlmm\",\n \t\t.of_match_table = sdx75_pinctrl_of_match,\n \t},\n-\t.probe = sdx75_pinctrl_probe,\n+\t.probe = msm_pinctrl_probe,\n \t.remove = msm_pinctrl_remove,\n };\n \n@@ -116,7 +116,7 @@ static int __init sdx75_pinctrl_init(void)\n {\n \treturn platform_driver_register(&sdx75_pinctrl_driver);\n }\n-arch_initcall(sdx75_pinctrl_init);\n+module_init(sdx75_pinctrl_init);\n \n static void __exit sdx75_pinctrl_exit(void)\n {\n@@ -124,7"926 },927 {928 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm4450_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm4450-tlmm\", },\n\t{ }\n};\n\nstatic struct platform_driver sm4450_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm4450-tlmm\",\n\t\t.of_match_table = sm4450_tlmm_of_match,\n\t},\n\t.probe = sm4450_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\nMODULE_DEVICE_TABLE(of, sm4450_tlmm_of_match);\n\nstatic int __init sm4450_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm4450_tlmm_driver);\n}\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",929 "reference": "@@ -994,7 +994,6 @@ static struct platform_driver sm4450_tlmm_driver = {\n \t\t.of_match_table = sm4450_tlmm_of_match,\n \t},\n \t.probe = sm4450_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n MODULE_DEVICE_TABLE(of, sm4450_tlmm_of_match);",930 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm4450_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm4450-tlmm\", },\n\t{ }\n};\n\nstatic struct platform_driver sm4450_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm4450-tlmm\",\n\t\t.of_match_table = sm4450_tlmm_of_match,\n\t},\n\t.probe = sm4450_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\nMODULE_DEVICE_TABLE(of, sm4450_tlmm_of_match);\n\nstatic int __init sm4450_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm4450_tlmm_driver);\n}\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver sm4450_tlmm_driver = {\n \t},\n \t.probe = sm4450_tlmm_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n MODULE_DEVICE_TABLE(of, sm4450_tlmm_of_match);\n \n static int __init sm4450_tlmm_init(void)\n@@ -110,7 +110,7 @@ static int __init sm4450_tlmm_init(void)\n \treturn platform_driver_register(&sm4450_tlmm_driver);\n }\n \n-static void __exit sm4450_tlmm_exit(void)\n+static void __exit sm4450_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm4450_tlmm_driver);\n }\n@@ -118,7 +11"931 },932 {933 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm6115_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm6115-tlmm\", },\n\t{ }\n};\n\nstatic struct platform_driver sm6115_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm6115-tlmm\",\n\t\t.of_match_table = sm6115_tlmm_of_match,\n\t},\n\t.probe = sm6115_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm6115_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm6115_tlmm_driver);\n}\narch_initcall(sm6115_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",934 "reference": "@@ -907,7 +907,6 @@ static struct platform_driver sm6115_tlmm_driver = {\n \t\t.of_match_table = sm6115_tlmm_of_match,\n \t},\n \t.probe = sm6115_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm6115_tlmm_init(void)",935 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm6115_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm6115-tlmm\", },\n\t{ }\n};\n\nstatic struct platform_driver sm6115_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm6115-tlmm\",\n\t\t.of_match_table = sm6115_tlmm_of_match,\n\t},\n\t.probe = sm6115_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm6115_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm6115_tlmm_driver);\n}\narch_initcall(sm6115_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver sm6115_tlmm_driver = {\n \t},\n \t.probe = sm6115_tlmm_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init sm6115_tlmm_init(void)\n {\n \treturn platform_driver_register(&sm6115_tlmm_driver);\n@@ -108,7 +108,7 @@ static int __init sm6115_tlmm_init(void)\n \n arch_initcall(sm6115_tlmm_init);\n \n-static void __exit sm6115_tlmm_exit(void)\n+static void __exit sm6115_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm6115_tlmm_driver);\n }\n@@ -116,7 +116,7 @@ static void"936 },937 {938 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm6125_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm6125-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sm6125_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm6125-tlmm\",\n\t\t.of_match_table = sm6125_tlmm_of_match,\n\t},\n\t.probe = sm6125_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm6125_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm6125_tlmm_driver);\n}\narch_initcall(sm6125_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",939 "reference": "@@ -1266,7 +1266,6 @@ static struct platform_driver sm6125_tlmm_driver = {\n \t\t.of_match_table = sm6125_tlmm_of_match,\n \t},\n \t.probe = sm6125_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm6125_tlmm_init(void)",940 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm6125_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm6125-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sm6125_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm6125-tlmm\",\n\t\t.of_match_table = sm6125_tlmm_of_match,\n\t},\n\t.probe = sm6125_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm6125_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm6125_tlmm_driver);\n}\narch_initcall(sm6125_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -104,7 +104,7 @@ static struct platform_driver sm6125_tlmm_driver = {\n \t\t.of_match_table = sm6125_tlmm_of_match,\n \t},\n \t.probe = sm6125_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm6125_tlmm_init(void)\n@@ -112,7 +112,7 @@ static int __init sm6125_tlmm_init(void)\n \treturn platform_driver_register(&sm6125_tlmm_driver);\n }\n arch_initcall(sm6125_tlmm_init);\n-\n+\n static void __exit sm6125_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm6125_tlmm_driver);\n@@ -12"941 },942 {943 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm6350_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm6350-tlmm\" },\n\t{ },\n};\n\nstatic struct platform_driver sm6350_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm6350-tlmm\",\n\t\t.of_match_table = sm6350_tlmm_of_match,\n\t},\n\t.probe = sm6350_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm6350_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm6350_tlmm_driver);\n}\narch_initcall(sm6350_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",944 "reference": "@@ -1373,7 +1373,6 @@ static struct platform_driver sm6350_tlmm_driver = {\n \t\t.of_match_table = sm6350_tlmm_of_match,\n \t},\n \t.probe = sm6350_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm6350_tlmm_init(void)",945 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm6350_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm6350-tlmm\" },\n\t{ },\n};\n\nstatic struct platform_driver sm6350_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm6350-tlmm\",\n\t\t.of_match_table = sm6350_tlmm_of_match,\n\t},\n\t.probe = sm6350_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm6350_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm6350_tlmm_driver);\n}\narch_initcall(sm6350_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver sm6350_tlmm_driver = {\n \t\t.of_match_table = sm6350_tlmm_of_match,\n \t},\n \t.probe = sm6350_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm6350_tlmm_init(void)\n@@ -110,7 +110,7 @@ static int __init sm6350_tlmm_init(void)\n \treturn platform_driver_register(&sm6350_tlmm_driver);\n }\n arch_initcall(sm6350_tlmm_init);\n-\n+\n static void __exit sm6350_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm6350_tlmm_driver);\n@@ -11"946 },947 {948 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm6375_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm6375-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sm6375_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm6375-tlmm\",\n\t\t.of_match_table = sm6375_tlmm_of_match,\n\t},\n\t.probe = sm6375_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm6375_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm6375_tlmm_driver);\n}\narch_initcall(sm6375_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",949 "reference": "@@ -1516,7 +1516,6 @@ static struct platform_driver sm6375_tlmm_driver = {\n \t\t.of_match_table = sm6375_tlmm_of_match,\n \t},\n \t.probe = sm6375_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm6375_tlmm_init(void)",950 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm6375_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm6375-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sm6375_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm6375-tlmm\",\n\t\t.of_match_table = sm6375_tlmm_of_match,\n\t},\n\t.probe = sm6375_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm6375_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm6375_tlmm_driver);\n}\narch_initcall(sm6375_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -102,7 +102,7 @@ static struct platform_driver sm6375_tlmm_driver = {\n \t\t.of_match_table = sm6375_tlmm_of_match,\n \t},\n \t.probe = sm6375_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm6375_tlmm_init(void)\n@@ -110,7 +110,7 @@ static int __init sm6375_tlmm_init(void)\n \treturn platform_driver_register(&sm6375_tlmm_driver);\n }\n arch_initcall(sm6375_tlmm_init);\n-\n+\n static void __exit sm6375_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm6375_tlmm_driver);\n@@ -11"951 },952 {953 "prompt": "Given the following original C code:\n{ .compatible = \"qcom,sm7150-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sm7150_tlmm_of_match);\n\nstatic struct platform_driver sm7150_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm7150-tlmm\",\n\t\t.pm = &msm_pinctrl_dev_pm_ops,\n\t\t.of_match_table = sm7150_tlmm_of_match,\n\t},\n\t.probe = sm7150_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm7150_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm7150_tlmm_driver);\n}\narch_initcall(sm7150_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",954 "reference": "@@ -1255,7 +1255,6 @@ static struct platform_driver sm7150_tlmm_driver = {\n \t\t.of_match_table = sm7150_tlmm_of_match,\n \t},\n \t.probe = sm7150_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm7150_tlmm_init(void)",955 "prediction": "Given the following original C code:\n{ .compatible = \"qcom,sm7150-tlmm\", },\n\t{ },\n};\nMODULE_DEVICE_TABLE(of, sm7150_tlmm_of_match);\n\nstatic struct platform_driver sm7150_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm7150-tlmm\",\n\t\t.pm = &msm_pinctrl_dev_pm_ops,\n\t\t.of_match_table = sm7150_tlmm_of_match,\n\t},\n\t.probe = sm7150_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm7150_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm7150_tlmm_driver);\n}\narch_initcall(sm7150_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sm7150_tlmm_driver = {\n \t\t.of_match_table = sm7150_tlmm_of_match,\n \t},\n \t.probe = sm7150_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_gpiochip_remove,\n };\n \n static int __init sm7150_tlmm_init(void)\n@@ -116,7 +116,7 @@ static int __init sm7150_tlmm_init(void)\n \treturn platform_driver_register(&sm7150_tlmm_driver);\n }\n arch_initcall(sm7150_tlmm_init);\n-\n+\n static void __exit sm7150_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm7150_tlmm_driver);"956 },957 {958 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm8150_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sm8150-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sm8150_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sm8150-pinctrl\",\n\t\t.of_match_table = sm8150_pinctrl_of_match,\n\t},\n\t.probe = sm8150_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8150_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sm8150_pinctrl_driver);\n}\narch_initcall(sm8150_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",959 "reference": "@@ -1542,7 +1542,6 @@ static struct platform_driver sm8150_pinctrl_driver = {\n \t\t.of_match_table = sm8150_pinctrl_of_match,\n \t},\n \t.probe = sm8150_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8150_pinctrl_init(void)",960 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm8150_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sm8150-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sm8150_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sm8150-pinctrl\",\n\t\t.of_match_table = sm8150_pinctrl_of_match,\n\t},\n\t.probe = sm8150_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8150_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sm8150_pinctrl_driver);\n}\narch_initcall(sm8150_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -107,7 +107,7 @@ static struct platform_driver sm8150_pinctrl_driver = {\n \t\t.of_match_table = sm8150_pinctrl_of_match,\n \t},\n \t.probe = sm8150_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8150_pinctrl_init(void)\n@@ -115,7 +115,7 @@ static int __init sm8150_pinctrl_init(void)\n \treturn platform_driver_register(&sm8150_pinctrl_driver);\n }\n arch_initcall(sm8150_pinctrl_init);\n-\n+\n static void __exit sm8150_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&sm8150_pinct"961 },962 {963 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm8250_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sm8250-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sm8250_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sm8250-pinctrl\",\n\t\t.of_match_table = sm8250_pinctrl_of_match,\n\t},\n\t.probe = sm8250_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8250_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sm8250_pinctrl_driver);\n}\narch_initcall(sm8250_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",964 "reference": "@@ -1351,7 +1351,6 @@ static struct platform_driver sm8250_pinctrl_driver = {\n \t\t.of_match_table = sm8250_pinctrl_of_match,\n \t},\n \t.probe = sm8250_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8250_pinctrl_init(void)",965 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm8250_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,sm8250-pinctrl\", },\n\t{ },\n};\n\nstatic struct platform_driver sm8250_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"sm8250-pinctrl\",\n\t\t.of_match_table = sm8250_pinctrl_of_match,\n\t},\n\t.probe = sm8250_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8250_pinctrl_init(void)\n{\n\treturn platform_driver_register(&sm8250_pinctrl_driver);\n}\narch_initcall(sm8250_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver sm8250_pinctrl_driver = {\n \t\t.of_match_table = sm8250_pinctrl_of_match,\n \t},\n \t.probe = sm8250_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8250_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init sm8250_pinctrl_init(void)\n \treturn platform_driver_register(&sm8250_pinctrl_driver);\n }\n arch_initcall(sm8250_pinctrl_init);\n-\n+\n static void __exit sm8250_pinctrl_exit(void)\n {\n \tplatform_driver_unregister(&sm8250_pinct"966 },967 {968 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm8350_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8350-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sm8350_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8350-tlmm\",\n\t\t.of_match_table = sm8350_tlmm_of_match,\n\t},\n\t.probe = sm8350_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8350_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8350_tlmm_driver);\n}\narch_initcall(sm8350_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",969 "reference": "@@ -1642,7 +1642,6 @@ static struct platform_driver sm8350_tlmm_driver = {\n \t\t.of_match_table = sm8350_tlmm_of_match,\n \t},\n \t.probe = sm8350_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8350_tlmm_init(void)",970 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm8350_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8350-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sm8350_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8350-tlmm\",\n\t\t.of_match_table = sm8350_tlmm_of_match,\n\t},\n\t.probe = sm8350_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8350_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8350_tlmm_driver);\n}\narch_initcall(sm8350_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sm8350_tlmm_driver = {\n \t\t.of_match_table = sm8350_tlmm_of_match,\n \t},\n \t.probe = sm8350_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8350_tlmm_init(void)\n@@ -116,7 +116,7 @@ static int __init sm8350_tlmm_init(void)\n \treturn platform_driver_register(&sm8350_tlmm_driver);\n }\n arch_initcall(sm8350_tlmm_init);\n-\n+\n static void __exit sm8350_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm8350_tlmm_driver);\n@@ -12"971 },972 {973 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm8450_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8450-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sm8450_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8450-tlmm\",\n\t\t.of_match_table = sm8450_tlmm_of_match,\n\t},\n\t.probe = sm8450_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8450_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8450_tlmm_driver);\n}\narch_initcall(sm8450_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",974 "reference": "@@ -1677,7 +1677,6 @@ static struct platform_driver sm8450_tlmm_driver = {\n \t\t.of_match_table = sm8450_tlmm_of_match,\n \t},\n \t.probe = sm8450_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8450_tlmm_init(void)",975 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm8450_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8450-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver sm8450_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8450-tlmm\",\n\t\t.of_match_table = sm8450_tlmm_of_match,\n\t},\n\t.probe = sm8450_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8450_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8450_tlmm_driver);\n}\narch_initcall(sm8450_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sm8450_tlmm_driver = {\n \t\t.of_match_table = sm8450_tlmm_of_match,\n \t},\n \t.probe = sm8450_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8450_tlmm_init(void)\n@@ -116,7 +116,7 @@ static int __init sm8450_tlmm_init(void)\n \treturn platform_driver_register(&sm8450_tlmm_driver);\n }\n arch_initcall(sm8450_tlmm_init);\n-\n+\n static void __exit sm8450_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm8450_tlmm_driver);\n@@ -12"976 },977 {978 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm8550_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8550-tlmm\", },\n\t{},\n};\n\nstatic struct platform_driver sm8550_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8550-tlmm\",\n\t\t.of_match_table = sm8550_tlmm_of_match,\n\t},\n\t.probe = sm8550_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8550_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8550_tlmm_driver);\n}\narch_initcall(sm8550_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",979 "reference": "@@ -1762,7 +1762,6 @@ static struct platform_driver sm8550_tlmm_driver = {\n \t\t.of_match_table = sm8550_tlmm_of_match,\n \t},\n \t.probe = sm8550_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8550_tlmm_init(void)",980 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm8550_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8550-tlmm\", },\n\t{},\n};\n\nstatic struct platform_driver sm8550_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8550-tlmm\",\n\t\t.of_match_table = sm8550_tlmm_of_match,\n\t},\n\t.probe = sm8550_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8550_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8550_tlmm_driver);\n}\narch_initcall(sm8550_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static struct platform_driver sm8550_tlmm_driver = {\n \t},\n \t.probe = sm8550_tlmm_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init sm8550_tlmm_init(void)\n {\n \treturn platform_driver_register(&sm8550_tlmm_driver);\n@@ -116,7 +116,7 @@ static int __init sm8550_tlmm_init(void)\n \n arch_initcall(sm8550_tlmm_init);\n \n-static void __exit sm8550_tlmm_exit(void)\n+static void __exit sm8550_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm8550_tlmm_driver);\n }\n@@ -124,7 +124,7 @@ static void"981 },982 {983 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm8650_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8650-tlmm\", },\n\t{},\n};\n\nstatic struct platform_driver sm8650_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8650-tlmm\",\n\t\t.of_match_table = sm8650_tlmm_of_match,\n\t},\n\t.probe = sm8650_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8650_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8650_tlmm_driver);\n}\narch_initcall(sm8650_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",984 "reference": "@@ -1742,7 +1742,6 @@ static struct platform_driver sm8650_tlmm_driver = {\n \t\t.of_match_table = sm8650_tlmm_of_match,\n \t},\n \t.probe = sm8650_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8650_tlmm_init(void)",985 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm8650_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8650-tlmm\", },\n\t{},\n};\n\nstatic struct platform_driver sm8650_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8650-tlmm\",\n\t\t.of_match_table = sm8650_tlmm_of_match,\n\t},\n\t.probe = sm8650_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8650_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8650_tlmm_driver);\n}\narch_initcall(sm8650_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver sm8650_tlmm_driver = {\n \t},\n \t.probe = sm8650_tlmm_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init sm8650_tlmm_init(void)\n {\n \treturn platform_driver_register(&sm8650_tlmm_driver);\n@@ -108,7 +108,7 @@ static int __init sm8650_tlmm_init(void)\n \n arch_initcall(sm8650_tlmm_init);\n \n-static void __exit sm8650_tlmm_exit(void)\n+static void __exit sm8650_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm8650_tlmm_driver);\n }\n@@ -116,7 +116,7 @@ static void"986 },987 {988 "prompt": "Given the following original C code:\nstatic const struct of_device_id sm8750_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8750-tlmm\", },\n\t{},\n};\n\nstatic struct platform_driver sm8750_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8750-tlmm\",\n\t\t.of_match_table = sm8750_tlmm_of_match,\n\t},\n\t.probe = sm8750_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8750_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8750_tlmm_driver);\n}\narch_initcall(sm8750_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",989 "reference": "@@ -1711,7 +1711,6 @@ static struct platform_driver sm8750_tlmm_driver = {\n \t\t.of_match_table = sm8750_tlmm_of_match,\n \t},\n \t.probe = sm8750_tlmm_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init sm8750_tlmm_init(void)",990 "prediction": "Given the following original C code:\nstatic const struct of_device_id sm8750_tlmm_of_match[] = {\n\t{ .compatible = \"qcom,sm8750-tlmm\", },\n\t{},\n};\n\nstatic struct platform_driver sm8750_tlmm_driver = {\n\t.driver = {\n\t\t.name = \"sm8750-tlmm\",\n\t\t.of_match_table = sm8750_tlmm_of_match,\n\t},\n\t.probe = sm8750_tlmm_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init sm8750_tlmm_init(void)\n{\n\treturn platform_driver_register(&sm8750_tlmm_driver);\n}\narch_initcall(sm8750_tlmm_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver sm8750_tlmm_driver = {\n \t},\n \t.probe = sm8750_tlmm_probe,\n \t.remove = msm_pinctrl_remove,\n-};\n+};\n \n static int __init sm8750_tlmm_init(void)\n {\n \treturn platform_driver_register(&sm8750_tlmm_driver);\n@@ -108,7 +108,7 @@ static int __init sm8750_tlmm_init(void)\n \n arch_initcall(sm8750_tlmm_init);\n \n-static void __exit sm8750_tlmm_exit(void)\n+static void __exit sm8750_tlmm_exit(void)\n {\n \tplatform_driver_unregister(&sm8750_tlmm_driver);\n }\n@@ -116,7 +116,7 @@ static void"991 },992 {993 "prompt": "Given the following original C code:\nstatic const struct of_device_id x1e80100_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,x1e80100-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver x1e80100_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"x1e80100-tlmm\",\n\t\t.of_match_table = x1e80100_pinctrl_of_match,\n\t},\n\t.probe = x1e80100_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init x1e80100_pinctrl_init(void)\n{\n\treturn platform_driver_register(&x1e80100_pinctrl_driver);\n}\narch_initcall(x1e80100_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n",994 "reference": "@@ -1861,7 +1861,6 @@ static struct platform_driver x1e80100_pinctrl_driver = {\n \t\t.of_match_table = x1e80100_pinctrl_of_match,\n \t},\n \t.probe = x1e80100_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n };\n \n static int __init x1e80100_pinctrl_init(void)",995 "prediction": "Given the following original C code:\nstatic const struct of_device_id x1e80100_pinctrl_of_match[] = {\n\t{ .compatible = \"qcom,x1e80100-tlmm\", },\n\t{ },\n};\n\nstatic struct platform_driver x1e80100_pinctrl_driver = {\n\t.driver = {\n\t\t.name = \"x1e80100-tlmm\",\n\t\t.of_match_table = x1e80100_pinctrl_of_match,\n\t},\n\t.probe = x1e80100_pinctrl_probe,\n\t.remove = msm_pinctrl_remove,\n};\n\nstatic int __init x1e80100_pinctrl_init(void)\n{\n\treturn platform_driver_register(&x1e80100_pinctrl_driver);\n}\narch_initcall(x1e80100_pinctrl_init);\n\nInstruction:\npinctrl: qcom: switch to devm_gpiochip_add_data()\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver x1e80100_pinctrl_driver = {\n \t\t.of_match_table = x1e80100_pinctrl_of_match,\n \t},\n \t.probe = x1e80100_pinctrl_probe,\n-\t.remove = msm_pinctrl_remove,\n+\t.remove = msm_pinctrl_remove,\n };\n \n static int __init x1e80100_pinctrl_init(void)\n@@ -108,7 +108,7 @@ static int __init x1e80100_pinctrl_init(void)\n \treturn platform_driver_register(&x1e80100_pinctrl_driver);\n }\n arch_initcall(x1e80100_pinctrl_init);\n-\n+\n static void __exit x1e80100_pinctrl_"996 },997 {998 "prompt": "Given the following original C code:\nPINCTRL_PIN(53, \"GPIO_53\"),\n\tPINCTRL_PIN(54, \"GPIO_54\"),\n\tPINCTRL_PIN(55, \"GPIO_55\"),\n\tPINCTRL_PIN(56, \"GPIO_56\"),\n\tPINCTRL_PIN(57, \"GPIO_57\"),\n\tPINCTRL_PIN(58, \"GPIO_58\"),\n\tPINCTRL_PIN(59, \"GPIO_59\"),\n\tPINCTRL_PIN(60, \"GPIO_60\"),\n\tPINCTRL_PIN(61, \"GPIO_61\"),\n\tPINCTRL_PIN(62, \"GPIO_62\"),\n\tPINCTRL_PIN(63, \"GPIO_63\"),\n\tPINCTRL_PIN(64, \"GPIO_64\"),\n\tPINCTRL_PIN(69, \"GPIO_69\"),\n\tPINCTRL_PIN(70, \"GPIO_70\"),\n\tPINCTRL_PIN(71, \"GPIO_71\"),\n\tPINCTRL_PIN(72, \"GPIO_72\"),\n\tPINCTRL_PIN(73, \"GPIO_73\"),\n\tPINCTRL_PIN(74, \"GPIO_74\"),\n\tPINCTRL_PIN(75, \"GPIO_75\"),\n\tPINCTRL_PIN(76, \"GPIO_76\"),\n\nInstruction:\npinctrl: qcom: pinctrl-qcm2290: Add missing pins\n\nReturn the diff that fixes it:\n",999 "reference": "@@ -167,6 +167,10 @@ static const struct pinctrl_pin_desc qcm2290_pins[] = {\n \tPINCTRL_PIN(62, \"GPIO_62\"),\n \tPINCTRL_PIN(63, \"GPIO_63\"),\n \tPINCTRL_PIN(64, \"GPIO_64\"),\n+\tPINCTRL_PIN(65, \"GPIO_65\"),\n+\tPINCTRL_PIN(66, \"GPIO_66\"),\n+\tPINCTRL_PIN(67, \"GPIO_67\"),\n+\tPINCTRL_PIN(68, \"GPIO_68\"),\n \tPINCTRL_PIN(69, \"GPIO_69\"),\n \tPINCTRL_PIN(70, \"GPIO_70\"),\n \tPINCTRL_PIN(71, \"GPIO_71\"),\n@@ -181,12 +185,17 @@ static const struct pinctrl_pin_desc qcm2290_pins[] = {\n \tPINCTRL_PIN(80, \"GPIO_80\"),\n \tPINCTRL_PIN(81, \"GPIO_81\"),\n \tPINCTRL_PIN(82, \"GPIO_82\"),\n+\tPINCTRL_PIN(83, \"GPIO_83\"),\n+\tPINCTRL_PIN(84, \"GPIO_84\"),\n+\tPINCTRL_PIN(85, \"GPIO_85\"),\n \tPINCTRL_PIN(86, \"GPIO_86\"),\n \tPINCTRL_PIN(87, \"GPIO_87\"),\n \tPINCTRL_PIN(88, \"GPIO_88\"),\n \tPINCTRL_PIN(89, \"GPIO_89\"),\n \tPINCTRL_PIN(90, \"GPIO_90\"),\n \tPINCTRL_PIN(91, \"GPIO_91\"),\n+\tPINCTRL_PIN(92, \"GPIO_92\"),\n+\tPINCTRL_PIN(93, \"GPIO_93\"),\n \tPINCTRL_PIN(94, \"GPIO_94\"),\n \tPINCTRL_PIN(95, \"GPIO_95\"),\n \tPINCTRL_PIN(96, \"GPIO_96\"),",1000 "prediction": "Given the following original C code:\nPINCTRL_PIN(53, \"GPIO_53\"),\n\tPINCTRL_PIN(54, \"GPIO_54\"),\n\tPINCTRL_PIN(55, \"GPIO_55\"),\n\tPINCTRL_PIN(56, \"GPIO_56\"),\n\tPINCTRL_PIN(57, \"GPIO_57\"),\n\tPINCTRL_PIN(58, \"GPIO_58\"),\n\tPINCTRL_PIN(59, \"GPIO_59\"),\n\tPINCTRL_PIN(60, \"GPIO_60\"),\n\tPINCTRL_PIN(61, \"GPIO_61\"),\n\tPINCTRL_PIN(62, \"GPIO_62\"),\n\tPINCTRL_PIN(63, \"GPIO_63\"),\n\tPINCTRL_PIN(64, \"GPIO_64\"),\n\tPINCTRL_PIN(69, \"GPIO_69\"),\n\tPINCTRL_PIN(70, \"GPIO_70\"),\n\tPINCTRL_PIN(71, \"GPIO_71\"),\n\tPINCTRL_PIN(72, \"GPIO_72\"),\n\tPINCTRL_PIN(73, \"GPIO_73\"),\n\tPINCTRL_PIN(74, \"GPIO_74\"),\n\tPINCTRL_PIN(75, \"GPIO_75\"),\n\tPINCTRL_PIN(76, \"GPIO_76\"),\n\nInstruction:\npinctrl: qcom: pinctrl-qcm2290: Add missing pins\n\nReturn the diff that fixes it:\n @@ -108,6 +108,7 @@ PINCTRL_PIN(59, \"GPIO_59\"),\n \tPINCTRL_PIN(61, \"GPIO_61\"),\n \tPINCTRL_PIN(62, \"GPIO_62\"),\n \tPINCTRL_PIN(63, \"GPIO_63\"),\n+\tPINCTRL_PIN(65, \"GPIO_65\"),\n \tPINCTRL_PIN(64, \"GPIO_64\"),\n \tPINCTRL_PIN(69, \"GPIO_69\"),\n \tPINCTRL_PIN(70, \"GPIO_70\"),\n@@ -116,6 +117,7 @@ PINCTRL_PIN(59, \"GPIO_59\"),\n \tPINCTRL_PIN(61, \"GPIO_61\"),\n \tPINCTRL_PIN(62, \"GPIO_6"1001 },1002 {1003 "prompt": "Given the following original C code:\nstatic struct st_pio_control *st_get_pio_control(\n\t\t\tstruct pinctrl_dev *pctldev, int pin)\n{\n\tstruct pinctrl_gpio_range *range =\n\t\t\t pinctrl_find_gpio_range_from_pin(pctldev, pin);\n\tstruct st_gpio_bank *bank = gpio_range_to_bank(range);\n\n\treturn &bank->pc;\n}\n\n/* Low level functions.. */\nstatic inline int st_gpio_bank(int gpio)\n{\n\treturn gpio/ST_GPIO_PINS_PER_BANK;\n}\n\nstatic inline int st_gpio_pin(int gpio)\n{\n\treturn gpio%ST_GPIO_PINS_PER_BANK;\n\nInstruction:\npinctrl: st: Drop unused st_gpio_bank() function\n\nReturn the diff that fixes it:\n",1004 "reference": "@@ -374,11 +374,6 @@ static struct st_pio_control *st_get_pio_control(\n }\n \n /* Low level functions.. */\n-static inline int st_gpio_bank(int gpio)\n-{\n-\treturn gpio/ST_GPIO_PINS_PER_BANK;\n-}\n-\n static inline int st_gpio_pin(int gpio)\n {\n \treturn gpio%ST_GPIO_PINS_PER_BANK;",1005 "prediction": "Given the following original C code:\nstatic struct st_pio_control *st_get_pio_control(\n\t\t\tstruct pinctrl_dev *pctldev, int pin)\n{\n\tstruct pinctrl_gpio_range *range =\n\t\t\t pinctrl_find_gpio_range_from_pin(pctldev, pin);\n\tstruct st_gpio_bank *bank = gpio_range_to_bank(range);\n\n\treturn &bank->pc;\n}\n\n/* Low level functions.. */\nstatic inline int st_gpio_bank(int gpio)\n{\n\treturn gpio/ST_GPIO_PINS_PER_BANK;\n}\n\nstatic inline int st_gpio_pin(int gpio)\n{\n\treturn gpio%ST_GPIO_PINS_PER_BANK;\n\nInstruction:\npinctrl: st: Drop unused st_gpio_bank() function\n\nReturn the diff that fixes it:\n @@ -106,11 +106,6 @@ static struct st_pio_control *st_get_pio_control(\n \n /* Low level functions.. */\n static inline int st_gpio_bank(int gpio)\n-{\n-\treturn gpio/ST_GPIO_PINS_PER_BANK;\n-}\n-\n-static inline int st_gpio_pin(int gpio)\n+{\n+\treturn gpio%ST_GPIO_PINS_PER_BANK;\n }\n \n static inline int st_gpio_to_irq(struct gpio_chip *chip, unsigned offset)\n@@ -119,7 +114,6 @@ static inline int st_gpio_to_irq(struct gpio_chip *chip, unsigned offset)\n \treturn irq_linear_revmap(chip->irqdomain, offset);\n }\n \n-static inline int st_irq_to_gpio(struct irq_data *d)\n+static inline int"1006 },1007 {1008 "prompt": "Given the following original C code:\nstatic const struct of_device_id tb10x_pinctrl_dt_ids[] = {\n\t{ .compatible = \"abilis,tb10x-iomux\" },\n\t{ }\n};\nMODULE_DEVICE_TABLE(of, tb10x_pinctrl_dt_ids);\n\nstatic struct platform_driver tb10x_pinctrl_pdrv = {\n\t.probe = tb10x_pinctrl_probe,\n\t.remove = tb10x_pinctrl_remove,\n\t.driver = {\n\t\t.name = \"tb10x_pinctrl\",\n\t\t.of_match_table = of_match_ptr(tb10x_pinctrl_dt_ids),\n\t}\n};\n\nmodule_platform_driver(tb10x_pinctrl_pdrv);\n\nMODULE_AUTHOR(\"Christian Ruppert <christian.ruppert@abilis.com>\");\nMODULE_DESCRIPTION(\"Abilis Systems TB10x pinctrl driver\");\n\nInstruction:\npinctrl: tb10x: Drop of_match_ptr for ID table\n\nReturn the diff that fixes it:\n",1009 "reference": "@@ -823,7 +823,7 @@ static struct platform_driver tb10x_pinctrl_pdrv = {\n \t.remove = tb10x_pinctrl_remove,\n \t.driver = {\n \t\t.name = \"tb10x_pinctrl\",\n-\t\t.of_match_table = of_match_ptr(tb10x_pinctrl_dt_ids),\n+\t\t.of_match_table = tb10x_pinctrl_dt_ids,\n \t}\n };",1010 "prediction": "Given the following original C code:\nstatic const struct of_device_id tb10x_pinctrl_dt_ids[] = {\n\t{ .compatible = \"abilis,tb10x-iomux\" },\n\t{ }\n};\nMODULE_DEVICE_TABLE(of, tb10x_pinctrl_dt_ids);\n\nstatic struct platform_driver tb10x_pinctrl_pdrv = {\n\t.probe = tb10x_pinctrl_probe,\n\t.remove = tb10x_pinctrl_remove,\n\t.driver = {\n\t\t.name = \"tb10x_pinctrl\",\n\t\t.of_match_table = of_match_ptr(tb10x_pinctrl_dt_ids),\n\t}\n};\n\nmodule_platform_driver(tb10x_pinctrl_pdrv);\n\nMODULE_AUTHOR(\"Christian Ruppert <christian.ruppert@abilis.com>\");\nMODULE_DESCRIPTION(\"Abilis Systems TB10x pinctrl driver\");\n\nInstruction:\npinctrl: tb10x: Drop of_match_ptr for ID table\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ static struct platform_driver tb10x_pinctrl_pdrv = {\n \t.remove = tb10x_pinctrl_remove,\n \t.driver = {\n \t\t.name = \"tb10x_pinctrl\",\n-\t\t.of_match_table = of_match_ptr(tb10x_pinctrl_dt_ids),\n+\t\t.of_match_table = tb10x_pinctrl_dt_ids,\n \t}\n };\n \n@@ -108,3 +108,4 @@ module_platform_driver(tb10x_pinctrl_pdrv);\n MODULE_AUTHOR(\"Christian Ruppert <christian.ruppert@abilis.com>\");\n MODULE_DESCRIPTION(\"Abilis Systems TB10x pinctrl driver\");\n MODULE_LICENSE(\"GPL v2\");\n+MODULE_AL"1011 },1012 {1013 "prompt": "Given the following original C code:\nstruct psp_device *aie2m_psp_create(struct drm_device *ddev, struct psp_config *conf)\n{\n\tstruct psp_device *psp;\n\tu64 offset;\n\n\tpsp = drmm_kzalloc(ddev, sizeof(*psp), GFP_KERNEL);\n\tif (!psp)\n\t\treturn NULL;\n\n\tpsp->ddev = ddev;\n\tmemcpy(psp->psp_regs, conf->psp_regs, sizeof(psp->psp_regs));\n\n\tpsp->fw_buf_sz = ALIGN(conf->fw_size, PSP_FW_ALIGN) + PSP_FW_ALIGN;\n\tpsp->fw_buffer = drmm_kmalloc(ddev, psp->fw_buf_sz, GFP_KERNEL);\n\tif (!psp->fw_buffer) {\n\t\tdrm_err(ddev, \"no memory for fw buffer\");\n\t\treturn NULL;\n\t}\n\n\t/*\n\nInstruction:\naccel/amdxdna: Fix incorrect PSP firmware size\n\nReturn the diff that fixes it:\n",1014 "reference": "@@ -126,8 +126,8 @@ struct psp_device *aie2m_psp_create(struct drm_device *ddev, struct psp_config *\n \tpsp->ddev = ddev;\n \tmemcpy(psp->psp_regs, conf->psp_regs, sizeof(psp->psp_regs));\n \n-\tpsp->fw_buf_sz = ALIGN(conf->fw_size, PSP_FW_ALIGN) + PSP_FW_ALIGN;\n-\tpsp->fw_buffer = drmm_kmalloc(ddev, psp->fw_buf_sz, GFP_KERNEL);\n+\tpsp->fw_buf_sz = ALIGN(conf->fw_size, PSP_FW_ALIGN);\n+\tpsp->fw_buffer = drmm_kmalloc(ddev, psp->fw_buf_sz + PSP_FW_ALIGN, GFP_KERNEL);\n \tif (!psp->fw_buffer) {\n \t\tdrm_err(ddev, \"no memory for fw buffer\");\n \t\treturn NULL;",1015 "prediction": "Given the following original C code:\nstruct psp_device *aie2m_psp_create(struct drm_device *ddev, struct psp_config *conf)\n{\n\tstruct psp_device *psp;\n\tu64 offset;\n\n\tpsp = drmm_kzalloc(ddev, sizeof(*psp), GFP_KERNEL);\n\tif (!psp)\n\t\treturn NULL;\n\n\tpsp->ddev = ddev;\n\tmemcpy(psp->psp_regs, conf->psp_regs, sizeof(psp->psp_regs));\n\n\tpsp->fw_buf_sz = ALIGN(conf->fw_size, PSP_FW_ALIGN) + PSP_FW_ALIGN;\n\tpsp->fw_buffer = drmm_kmalloc(ddev, psp->fw_buf_sz, GFP_KERNEL);\n\tif (!psp->fw_buffer) {\n\t\tdrm_err(ddev, \"no memory for fw buffer\");\n\t\treturn NULL;\n\t}\n\n\t/*\n\nInstruction:\naccel/amdxdna: Fix incorrect PSP firmware size\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ struct psp_device *aie2m_psp_create(struct drm_device *ddev, struct psp_config\n \tpsp->ddev = ddev;\n \tmemcpy(psp->psp_regs, conf->psp_regs, sizeof(psp->psp_regs));\n \n-\tpsp->fw_buf_sz = ALIGN(conf->fw_size, PSP_FW_ALIGN) + PSP_FW_ALIGN;\n+\tpsp->fw_buf_sz = ALIGN(conf->fw_size, PSP_FW_ALIGN);\n \tpsp->fw_buffer = drmm_kmalloc(ddev, psp->fw_buf_sz, GFP_KERNEL);\n \tif (!psp->fw_buffer) {\n \t\tdrm_err(ddev, \"no memory for fw buffer\");\n@@ -116,7 +116,7 @@ struct psp"1016 },1017 {1018 "prompt": "Given the following original C code:\n{\n\tstruct xe_vm *vm = range_to_vm(&range->base);\n\tu64 range_size = xe_svm_range_size(range);\n\n\tif (!range->base.flags.migrate_devmem)\n\t\treturn false;\n\n\tif (xe_svm_range_in_vram(range)) {\n\t\tdrm_dbg(&vm->xe->drm, \"Range is already in VRAM\\n\");\n\t\treturn false;\n\t}\n\n\tif (range_size <= SZ_64K && !supports_4K_migration(vm->xe)) {\n\t\tdrm_dbg(&vm->xe->drm, \"Platform doesn't support SZ_4K range migration\\n\");\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nInstruction:\ndrm/xe/svm: Fix regression disallowing 64K SVM migration\n\nReturn the diff that fixes it:\n",1019 "reference": "@@ -764,7 +764,7 @@ static bool xe_svm_range_needs_migrate_to_vram(struct xe_svm_range *range,\n \t\treturn false;\n \t}\n \n-\tif (range_size <= SZ_64K && !supports_4K_migration(vm->xe)) {\n+\tif (range_size < SZ_64K && !supports_4K_migration(vm->xe)) {\n \t\tdrm_dbg(&vm->xe->drm, \"Platform doesn't support SZ_4K range migration\\n\");\n \t\treturn false;\n \t}",1020 "prediction": "Given the following original C code:\n{\n\tstruct xe_vm *vm = range_to_vm(&range->base);\n\tu64 range_size = xe_svm_range_size(range);\n\n\tif (!range->base.flags.migrate_devmem)\n\t\treturn false;\n\n\tif (xe_svm_range_in_vram(range)) {\n\t\tdrm_dbg(&vm->xe->drm, \"Range is already in VRAM\\n\");\n\t\treturn false;\n\t}\n\n\tif (range_size <= SZ_64K && !supports_4K_migration(vm->xe)) {\n\t\tdrm_dbg(&vm->xe->drm, \"Platform doesn't support SZ_4K range migration\\n\");\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nInstruction:\ndrm/xe/svm: Fix regression disallowing 64K SVM migration\n\nReturn the diff that fixes it:\n @@ -104,10 +104,6 @@ static bool xe_svm_range_can_migrate(struct xe_svm_range *range)\n \t\treturn false;\n \t}\n \n-\tif (range_size <= SZ_64K && !supports_4K_migration(vm->xe)) {\n-\t\tdrm_dbg(&vm->xe->drm, \"Platform doesn't support SZ_4K range migration\\n\");\n-\t\treturn false;\n-\t}\n-\n \treturn true;\n }\n \n@@ -114,6 +110,10 @@ static bool xe_svm_range_can_migrate(struct xe_svm_range *range)\n \t\treturn false;\n \t}\n \n+\tif (range_size <= SZ_64K && !supports_4K_migration(vm->xe)) {\n+\t\tdrm_dbg(&vm->xe->drm, \"Platform doesn't support SZ"1021 },1022 {1023 "prompt": "Given the following original C code:\nospi->irq = platform_get_irq(pdev, 0);\n\tif (ospi->irq < 0)\n\t\treturn ospi->irq;\n\n\tret = devm_request_irq(dev, ospi->irq, stm32_ospi_irq, 0,\n\t\t\t dev_name(dev), ospi);\n\tif (ret) {\n\t\tdev_err(dev, \"Failed to request irq\\n\");\n\t\treturn ret;\n\t}\n\n\tospi->rstc = devm_reset_control_array_get_exclusive(dev);\n\tif (IS_ERR(ospi->rstc))\n\t\treturn dev_err_probe(dev, PTR_ERR(ospi->rstc),\n\t\t\t\t \"Can't get reset\\n\");\n\n\tospi->dma_chrx = dma_request_chan(dev, \"rx\");\n\tif (IS_ERR(ospi->dma_chrx)) {\n\t\tret = PTR_ERR(ospi->dma_chrx);\n\nInstruction:\nspi: stm32-ospi: Make usage of reset_control_acquire/release() API\n\nReturn the diff that fixes it:\n",1024 "reference": "@@ -804,7 +804,7 @@ static int stm32_ospi_get_resources(struct platform_device *pdev)\n \t\treturn ret;\n \t}\n \n-\tospi->rstc = devm_reset_control_array_get_exclusive(dev);\n+\tospi->rstc = devm_reset_control_array_get_exclusive_released(dev);\n \tif (IS_ERR(ospi->rstc))\n \t\treturn dev_err_probe(dev, PTR_ERR(ospi->rstc),\n \t\t\t\t \"Can't get reset\\n\");\n@@ -936,11 +936,13 @@ static int stm32_ospi_probe(struct platform_device *pdev)\n \tif (ret < 0)\n \t\tgoto err_pm_enable;\n \n-\tif (ospi->rstc) {\n-\t\treset_control_assert(ospi->rstc);\n-\t\tudelay(2);\n-\t\treset_control_deassert(ospi->rstc);\n-\t}\n+\tret = reset_control_acquire(ospi->rstc);\n+\tif (ret)\n+\t\treturn dev_err_probe(dev, ret, \"Can not acquire reset %d\\n\", ret);\n+\n+\treset_control_assert(ospi->rstc);\n+\tudelay(2);\n+\treset_control_deassert(ospi->rstc);\n \n \tret = spi_register_controller(ctrl);\n \tif (ret) {\n@@ -987,6 +989,8 @@ static void stm32_ospi_remove(struct platform_device *pdev)\n \tif (ospi->dma_chrx)\n \t\tdma_release_channel(ospi->dma_chrx);\n \n+\treset_control_release(ospi->rstc);\n+\n \tpm_runtime_put_sync_suspend(ospi->dev);\n \tpm_runtime_force_suspend(ospi->dev);\n }\n@@ -997,6 +1001,8 @@ static int __maybe_unused stm32_ospi_suspend(struct device *dev)\n \n \tpinctrl_pm_select_sleep_state(dev);\n \n+\treset_control_release(ospi->rstc);\n+\n \treturn pm_runtime_force_suspend(ospi->dev);\n }\n \n@@ -1016,6 +1022,12 @@ static int __maybe_unused stm32_ospi_resume(struct device *dev)\n \tif (ret < 0)\n \t\treturn ret;\n \n+\tret = reset_control_acquire(ospi->rstc);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Can not acquire reset\\n\");\n+\t\treturn ret;\n+\t}\n+\n \twritel_relaxed(ospi->cr_reg, regs_base + OSPI_CR);\n \twritel_relaxed(ospi->dcr_reg, regs_base + OSPI_DCR1);\n \tpm_runtime_mark_last_busy(ospi->dev);",1025 "prediction": "Given the following original C code:\nospi->irq = platform_get_irq(pdev, 0);\n\tif (ospi->irq < 0)\n\t\treturn ospi->irq;\n\n\tret = devm_request_irq(dev, ospi->irq, stm32_ospi_irq, 0,\n\t\t\t dev_name(dev), ospi);\n\tif (ret) {\n\t\tdev_err(dev, \"Failed to request irq\\n\");\n\t\treturn ret;\n\t}\n\n\tospi->rstc = devm_reset_control_array_get_exclusive(dev);\n\tif (IS_ERR(ospi->rstc))\n\t\treturn dev_err_probe(dev, PTR_ERR(ospi->rstc),\n\t\t\t\t \"Can't get reset\\n\");\n\n\tospi->dma_chrx = dma_request_chan(dev, \"rx\");\n\tif (IS_ERR(ospi->dma_chrx)) {\n\t\tret = PTR_ERR(ospi->dma_chrx);\n\nInstruction:\nspi: stm32-ospi: Make usage of reset_control_acquire/release() API\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int stm32_ospi_probe(struct platform_device *pdev)\n \t\treturn ret;\n \t}\n \n-\tospi->rstc = devm_reset_control_array_get_exclusive(dev);\n+\tospi->rstc = devm_reset_control_get_exclusive(dev, NULL);\n \tif (IS_ERR(ospi->rstc))\n \t\treturn dev_err_probe(dev, PTR_ERR(ospi->rstc),\n \t\t\t\t \"Can't get reset\\n\");\n@@ -116,7 +116,7 @@ static int stm32_ospi_probe(struct platform_device *pdev)\n \t\treturn ret;\n \t}\n \n-\tospi->rstc = devm_reset_control_array_get_exclusive(dev);\n+\tospi->rstc = devm_reset_control"1026 },1027 {1028 "prompt": "Given the following original C code:\nvoid signal_fault(struct pt_regs *regs, void __user *frame, char *where);\n\nvoid __user *\nget_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size,\n\t void __user **fpstate);\n\nint ia32_setup_frame(struct ksignal *ksig, struct pt_regs *regs);\nint ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\nint x64_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\nint x32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\n\n#endif /* _ASM_X86_SIGHANDLING_H */\n\nInstruction:\nx86/fred/signal: Prevent immediate repeat of single step trap on return from SIGTRAP handler\n\nReturn the diff that fixes it:\n",1029 "reference": "@@ -24,4 +24,26 @@ int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\n int x64_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\n int x32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\n \n+/*\n+ * To prevent immediate repeat of single step trap on return from SIGTRAP\n+ * handler if the trap flag (TF) is set without an external debugger attached,\n+ * clear the software event flag in the augmented SS, ensuring no single-step\n+ * trap is pending upon ERETU completion.\n+ *\n+ * Note, this function should be called in sigreturn() before the original\n+ * state is restored to make sure the TF is read from the entry frame.\n+ */\n+static __always_inline void prevent_single_step_upon_eretu(struct pt_regs *regs)\n+{\n+\t/*\n+\t * If the trap flag (TF) is set, i.e., the sigreturn() SYSCALL instruction\n+\t * is being single-stepped, do not clear the software event flag in the\n+\t * augmented SS, thus a debugger won't skip over the following instruction.\n+\t */\n+#ifdef CONFIG_X86_FRED\n+\tif (!(regs->flags & X86_EFLAGS_TF))\n+\t\tregs->fred_ss.swevent = 0;\n+#endif\n+}\n+\n #endif /* _ASM_X86_SIGHANDLING_H */",1030 "prediction": "Given the following original C code:\nvoid signal_fault(struct pt_regs *regs, void __user *frame, char *where);\n\nvoid __user *\nget_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size,\n\t void __user **fpstate);\n\nint ia32_setup_frame(struct ksignal *ksig, struct pt_regs *regs);\nint ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\nint x64_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\nint x32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\n\n#endif /* _ASM_X86_SIGHANDLING_H */\n\nInstruction:\nx86/fred/signal: Prevent immediate repeat of single step trap on return from SIGTRAP handler\n\nReturn the diff that fixes it:\n @@ -103,3 +103,10 @@ int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\n int x64_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\n int x32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs);\n \n+#ifdef CONFIG_X86_32\n+void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,\n+\t\t\t size_t frame_size, void __user **fpstate);\n+#endif\n+\n #endif /* _ASM_X86_SIGHANDLING_H */\n #endif /* _ASM_X86_SIGHANDLING_H */\n #endif /* _ASM_X86_SIGHANDLING_H */\n@@ -106,3 +111,4 @@ int x32_setup"1031 },1032 {1033 "prompt": "Given the following original C code:\nregs->ds = fixup_rpl(sc.ds);\n#endif\n\n\treturn fpu__restore_sig(compat_ptr(sc.fpstate), 1);\n}\n\nSYSCALL32_DEFINE0(sigreturn)\n{\n\tstruct pt_regs *regs = current_pt_regs();\n\tstruct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(regs->sp-8);\n\tsigset_t set;\n\n\tif (!access_ok(frame, sizeof(*frame)))\n\t\tgoto badframe;\n\tif (__get_user(set.sig[0], &frame->sc.oldmask)\n\t || __get_user(((__u32 *)&set)[1], &frame->extramask[0]))\n\t\tgoto badframe;\n\n\tset_current_blocked(&set);\n\nInstruction:\nx86/fred/signal: Prevent immediate repeat of single step trap on return from SIGTRAP handler\n\nReturn the diff that fixes it:\n",1034 "reference": "@@ -152,6 +152,8 @@ SYSCALL32_DEFINE0(sigreturn)\n \tstruct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(regs->sp-8);\n \tsigset_t set;\n \n+\tprevent_single_step_upon_eretu(regs);\n+\n \tif (!access_ok(frame, sizeof(*frame)))\n \t\tgoto badframe;\n \tif (__get_user(set.sig[0], &frame->sc.oldmask)\n@@ -175,6 +177,8 @@ SYSCALL32_DEFINE0(rt_sigreturn)\n \tstruct rt_sigframe_ia32 __user *frame;\n \tsigset_t set;\n \n+\tprevent_single_step_upon_eretu(regs);\n+\n \tframe = (struct rt_sigframe_ia32 __user *)(regs->sp - 4);\n \n \tif (!access_ok(frame, sizeof(*frame)))",1035 "prediction": "Given the following original C code:\nregs->ds = fixup_rpl(sc.ds);\n#endif\n\n\treturn fpu__restore_sig(compat_ptr(sc.fpstate), 1);\n}\n\nSYSCALL32_DEFINE0(sigreturn)\n{\n\tstruct pt_regs *regs = current_pt_regs();\n\tstruct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(regs->sp-8);\n\tsigset_t set;\n\n\tif (!access_ok(frame, sizeof(*frame)))\n\t\tgoto badframe;\n\tif (__get_user(set.sig[0], &frame->sc.oldmask)\n\t || __get_user(((__u32 *)&set)[1], &frame->extramask[0]))\n\t\tgoto badframe;\n\n\tset_current_blocked(&set);\n\nInstruction:\nx86/fred/signal: Prevent immediate repeat of single step trap on return from SIGTRAP handler\n\nReturn the diff that fixes it:\n @@ -108,6 +108,11 @@ SYSCALL32_DEFINE0(sigreturn)\n \tstruct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(regs->sp-8);\n \tsigset_t set;\n \n+\t/*\n+\t * If we're on the alternate stack, switch back to the main stack\n+\t * before running the signal handler.\n+\t */\n+\tif (on_sig_stack(regs->sp))\n+\t\tregs->sp = current->sas_ss_sp + current->sas_ss_size;\n+\n \tif (!access_ok(frame, sizeof(*frame)))\n \t\tgoto badframe;\n \tif (__get_user(set.sig[0], &frame->sc.oldmask)\n@@ -116,6 +121,11 @@ SYSCALL32_DEFINE0(sigreturn)\n \t || __get_user(((__u32 *)&set)[1], &"1036 },1037 {1038 "prompt": "Given the following original C code:\n}\n\n/*\n * Do a signal return; undo the signal stack.\n */\nSYSCALL_DEFINE0(rt_sigreturn)\n{\n\tstruct pt_regs *regs = current_pt_regs();\n\tstruct rt_sigframe __user *frame;\n\tsigset_t set;\n\tunsigned long uc_flags;\n\n\tframe = (struct rt_sigframe __user *)(regs->sp - sizeof(long));\n\tif (!access_ok(frame, sizeof(*frame)))\n\t\tgoto badframe;\n\tif (__get_user(*(__u64 *)&set, (__u64 __user *)&frame->uc.uc_sigmask))\n\t\tgoto badframe;\n\tif (__get_user(uc_flags, &frame->uc.uc_flags))\n\t\tgoto badframe;\n\nInstruction:\nx86/fred/signal: Prevent immediate repeat of single step trap on return from SIGTRAP handler\n\nReturn the diff that fixes it:\n",1039 "reference": "@@ -250,6 +250,8 @@ SYSCALL_DEFINE0(rt_sigreturn)\n \tsigset_t set;\n \tunsigned long uc_flags;\n \n+\tprevent_single_step_upon_eretu(regs);\n+\n \tframe = (struct rt_sigframe __user *)(regs->sp - sizeof(long));\n \tif (!access_ok(frame, sizeof(*frame)))\n \t\tgoto badframe;\n@@ -366,6 +368,8 @@ COMPAT_SYSCALL_DEFINE0(x32_rt_sigreturn)\n \tsigset_t set;\n \tunsigned long uc_flags;\n \n+\tprevent_single_step_upon_eretu(regs);\n+\n \tframe = (struct rt_sigframe_x32 __user *)(regs->sp - 8);\n \n \tif (!access_ok(frame, sizeof(*frame)))",1040 "prediction": "Given the following original C code:\n}\n\n/*\n * Do a signal return; undo the signal stack.\n */\nSYSCALL_DEFINE0(rt_sigreturn)\n{\n\tstruct pt_regs *regs = current_pt_regs();\n\tstruct rt_sigframe __user *frame;\n\tsigset_t set;\n\tunsigned long uc_flags;\n\n\tframe = (struct rt_sigframe __user *)(regs->sp - sizeof(long));\n\tif (!access_ok(frame, sizeof(*frame)))\n\t\tgoto badframe;\n\tif (__get_user(*(__u64 *)&set, (__u64 __user *)&frame->uc.uc_sigmask))\n\t\tgoto badframe;\n\tif (__get_user(uc_flags, &frame->uc.uc_flags))\n\t\tgoto badframe;\n\nInstruction:\nx86/fred/signal: Prevent immediate repeat of single step trap on return from SIGTRAP handler\n\nReturn the diff that fixes it:\n @@ -101,6 +101,11 @@ SYSCALL_DEFINE0(rt_sigreturn)\n \tsigset_t set;\n \tunsigned long uc_flags;\n \n+\t/*\n+\t * Since we stacked the signal on a 64-bit boundary, then 'sp'\n+\t * should be 16-byte aligned here.\n+\t */\n+\tif (regs->sp % 16)\n+\t\tgoto badframe;\n \tframe = (struct rt_sigframe __user *)(regs->sp - sizeof(long));\n \tif (!access_ok(frame, sizeof(*frame)))\n \t\tgoto badframe;\n@@ -111,6 +116,11 @@ SYSCALL_DEFINE0(rt_sigreturn)\n \tif (restore_sigcontext(regs, &frame->uc.uc_mcontext, &set, uc_flags))\n \t\tgoto badframe;\n \n+\t/*\n+\t * It is more difficult to avoid calling this function"1041 },1042 {1043 "prompt": "Given the following original C code:\nstruct eh_frame_hdr_table_entry {\n\tunsigned long start, fde;\n};\n\nstatic int cmp_eh_frame_hdr_table_entries(const void *p1, const void *p2)\n{\n\tconst struct eh_frame_hdr_table_entry *e1 = p1;\n\tconst struct eh_frame_hdr_table_entry *e2 = p2;\n\n\treturn (e1->start > e2->start) - (e1->start < e2->start);\n}\n\nstatic void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size)\n{\n\tstruct eh_frame_hdr_table_entry *e1 = p1;\n\tstruct eh_frame_hdr_table_entry *e2 = p2;\n\n\tswap(e1->start, e2->start);\n\tswap(e1->fde, e2->fde);\n}\n\nInstruction:\nARC: unwind: Use built-in sort swap to reduce code size and improve performance\n\nReturn the diff that fixes it:\n",1044 "reference": "@@ -241,15 +241,6 @@ static int cmp_eh_frame_hdr_table_entries(const void *p1, const void *p2)\n \treturn (e1->start > e2->start) - (e1->start < e2->start);\n }\n \n-static void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size)\n-{\n-\tstruct eh_frame_hdr_table_entry *e1 = p1;\n-\tstruct eh_frame_hdr_table_entry *e2 = p2;\n-\n-\tswap(e1->start, e2->start);\n-\tswap(e1->fde, e2->fde);\n-}\n-\n static void init_unwind_hdr(struct unwind_table *table,\n \t\t\t void *(*alloc) (unsigned long))\n {\n@@ -345,7 +336,7 @@ static void init_unwind_hdr(struct unwind_table *table,\n \tsort(header->table,\n \t n,\n \t sizeof(*header->table),\n-\t cmp_eh_frame_hdr_table_entries, swap_eh_frame_hdr_table_entries);\n+\t cmp_eh_frame_hdr_table_entries, NULL);\n \n \ttable->hdrsz = hdrSize;\n \tsmp_wmb();",1045 "prediction": "Given the following original C code:\nstruct eh_frame_hdr_table_entry {\n\tunsigned long start, fde;\n};\n\nstatic int cmp_eh_frame_hdr_table_entries(const void *p1, const void *p2)\n{\n\tconst struct eh_frame_hdr_table_entry *e1 = p1;\n\tconst struct eh_frame_hdr_table_entry *e2 = p2;\n\n\treturn (e1->start > e2->start) - (e1->start < e2->start);\n}\n\nstatic void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size)\n{\n\tstruct eh_frame_hdr_table_entry *e1 = p1;\n\tstruct eh_frame_hdr_table_entry *e2 = p2;\n\n\tswap(e1->start, e2->start);\n\tswap(e1->fde, e2->fde);\n}\n\nInstruction:\nARC: unwind: Use built-in sort swap to reduce code size and improve performance\n\nReturn the diff that fixes it:\n @@ -106,14 +106,14 @@ static int cmp_eh_frame_hdr_table_entries(const void *p1, const void *p2)\n \treturn (e1->start > e2->start) - (e1->start < e2->start);\n }\n \n-static void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size)\n+static void swap_eh_frame_hdr_table_entries(void *p1, void *p2)\n {\n \tstruct eh_frame_hdr_table_entry *e1 = p1;\n \tstruct eh_frame_hdr_table_entry *e2 = p2;\n \n-\tswap(e1->start, e2->start);\n-\tswap(e1->fde, e2->fde);\n+\tswap(e1->start, e2->start);\n+\tswap(e1->fde, e2->fde);\n }\n \n static void sort_"1046 },1047 {1048 "prompt": "Given the following original C code:\nreturn no_free_ptr(rpc_out);\n}\n\nstatic bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,\n\t\t\t\t\t const struct fwctl_rpc_cxl *rpc_in,\n\t\t\t\t\t enum fwctl_rpc_scope scope)\n{\n\tu16 effects, imm_mask, reset_mask;\n\tstruct cxl_feat_entry *feat;\n\tu32 flags;\n\n\tif (rpc_in->op_size < sizeof(uuid_t))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tfeat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid);\n\tif (IS_ERR(feat))\n\t\treturn false;\n\n\t/* Ensure that the attribute is changeable */\n\tflags = le32_to_cpu(feat->flags);\n\nInstruction:\ncxl: fix return value in cxlctl_validate_set_features()\n\nReturn the diff that fixes it:\n",1049 "reference": "@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,\n \tu32 flags;\n \n \tif (rpc_in->op_size < sizeof(uuid_t))\n-\t\treturn ERR_PTR(-EINVAL);\n+\t\treturn false;\n \n \tfeat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid);\n \tif (IS_ERR(feat))",1050 "prediction": "Given the following original C code:\nreturn no_free_ptr(rpc_out);\n}\n\nstatic bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,\n\t\t\t\t\t const struct fwctl_rpc_cxl *rpc_in,\n\t\t\t\t\t enum fwctl_rpc_scope scope)\n{\n\tu16 effects, imm_mask, reset_mask;\n\tstruct cxl_feat_entry *feat;\n\tu32 flags;\n\n\tif (rpc_in->op_size < sizeof(uuid_t))\n\t\treturn ERR_PTR(-EINVAL);\n\n\tfeat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid);\n\tif (IS_ERR(feat))\n\t\treturn false;\n\n\t/* Ensure that the attribute is changeable */\n\tflags = le32_to_cpu(feat->flags);\n\nInstruction:\ncxl: fix return value in cxlctl_validate_set_features()\n\nReturn the diff that fixes it:\n @@ -106,7 +106,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,\n \tu32 flags;\n \n \tif (rpc_in->op_size < sizeof(uuid_t))\n-\t\treturn ERR_PTR(-EINVAL);\n+\t\treturn false;\n \n \tfeat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid);\n \tif (IS_ERR(feat))\n@@ -114,7 +114,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,\n \t/* Ensure that the attribute is changeable */\n \tflags = le32_to_cpu(feat->flags);\n \n-\tif (!(flags & CXL_FEATURE_CHANGEABLE))\n+\tif (!(flags & CXL_FEATURE_CHANGEABLE))\n \t\treturn"1051 },1052 {1053 "prompt": "Given the following original C code:\nINIT_LIST_HEAD(&submit->node);\n\n\treturn submit;\n}\n\nvoid __msm_gem_submit_destroy(struct kref *kref)\n{\n\tstruct msm_gem_submit *submit =\n\t\t\tcontainer_of(kref, struct msm_gem_submit, ref);\n\tunsigned i;\n\n\tif (submit->fence_id) {\n\t\tspin_lock(&submit->queue->idr_lock);\n\t\tidr_remove(&submit->queue->fence_idr, submit->fence_id);\n\t\tspin_unlock(&submit->queue->idr_lock);\n\t}\n\n\tdma_fence_put(submit->user_fence);\n\nInstruction:\ndrm/msm: Fix a fence leak in submit error path\n\nReturn the diff that fixes it:\n",1054 "reference": "@@ -85,6 +85,15 @@ void __msm_gem_submit_destroy(struct kref *kref)\n \t\t\tcontainer_of(kref, struct msm_gem_submit, ref);\n \tunsigned i;\n \n+\t/*\n+\t * In error paths, we could unref the submit without calling\n+\t * drm_sched_entity_push_job(), so msm_job_free() will never\n+\t * get called. Since drm_sched_job_cleanup() will NULL out\n+\t * s_fence, we can use that to detect this case.\n+\t */\n+\tif (submit->base.s_fence)\n+\t\tdrm_sched_job_cleanup(&submit->base);\n+\n \tif (submit->fence_id) {\n \t\tspin_lock(&submit->queue->idr_lock);\n \t\tidr_remove(&submit->queue->fence_idr, submit->fence_id);",1055 "prediction": "Given the following original C code:\nINIT_LIST_HEAD(&submit->node);\n\n\treturn submit;\n}\n\nvoid __msm_gem_submit_destroy(struct kref *kref)\n{\n\tstruct msm_gem_submit *submit =\n\t\t\tcontainer_of(kref, struct msm_gem_submit, ref);\n\tunsigned i;\n\n\tif (submit->fence_id) {\n\t\tspin_lock(&submit->queue->idr_lock);\n\t\tidr_remove(&submit->queue->fence_idr, submit->fence_id);\n\t\tspin_unlock(&submit->queue->idr_lock);\n\t}\n\n\tdma_fence_put(submit->user_fence);\n\nInstruction:\ndrm/msm: Fix a fence leak in submit error path\n\nReturn the diff that fixes it:\n @@ -107,6 +107,10 @@ void __msm_gem_submit_destroy(struct kref *kref)\n \tunsigned i;\n \n \tif (submit->fence_id) {\n+\t\tstruct drm_device *dev = submit->queue->dev;\n+\n+\t\tspin_lock(&dev->fence_lock);\n+\n \t\tspin_lock(&submit->queue->idr_lock);\n \t\tidr_remove(&submit->queue->fence_idr, submit->fence_id);\n \t\tspin_unlock(&submit->queue->idr_lock);\n@@ -114,6 +118,8 @@ void __msm_gem_submit_destroy(struct kref *kref)\n \t\tspin_unlock(&submit->queue->idr_lock);\n \t}\n \n+\tspin_unlock(&submit->queue->dev->fence_lock);\n+\n \tdma_fence_put(submit->user_fence"1056 },1057 {1058 "prompt": "Given the following original C code:\nint msm_ioctl_gem_submit(struct drm_device *dev, void *data,\n\t\tstruct drm_file *file)\n{\n\tstruct msm_drm_private *priv = dev->dev_private;\n\tstruct drm_msm_gem_submit *args = data;\n\tstruct msm_file_private *ctx = file->driver_priv;\n\tstruct msm_gem_submit *submit = NULL;\n\tstruct msm_gpu *gpu = priv->gpu;\n\tstruct msm_gpu_submitqueue *queue;\n\tstruct msm_ringbuffer *ring;\n\tstruct msm_submit_post_dep *post_deps = NULL;\n\tstruct drm_syncobj **syncobjs_to_reset = NULL;\n\tint out_fence_fd = -1;\n\tunsigned i;\n\tint ret;\n\n\tif (!gpu)\n\t\treturn -ENXIO;\n\n\tif (args->pad)\n\nInstruction:\ndrm/msm: Fix another leak in the submit error path\n\nReturn the diff that fixes it:\n",1059 "reference": "@@ -658,6 +658,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,\n \tstruct msm_ringbuffer *ring;\n \tstruct msm_submit_post_dep *post_deps = NULL;\n \tstruct drm_syncobj **syncobjs_to_reset = NULL;\n+\tstruct sync_file *sync_file = NULL;\n \tint out_fence_fd = -1;\n \tunsigned i;\n \tint ret;\n@@ -867,7 +868,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,\n \t}\n \n \tif (ret == 0 && args->flags & MSM_SUBMIT_FENCE_FD_OUT) {\n-\t\tstruct sync_file *sync_file = sync_file_create(submit->user_fence);\n+\t\tsync_file = sync_file_create(submit->user_fence);\n \t\tif (!sync_file) {\n \t\t\tret = -ENOMEM;\n \t\t} else {\n@@ -901,8 +902,11 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,\n out_unlock:\n \tmutex_unlock(&queue->lock);\n out_post_unlock:\n-\tif (ret && (out_fence_fd >= 0))\n+\tif (ret && (out_fence_fd >= 0)) {\n \t\tput_unused_fd(out_fence_fd);\n+\t\tif (sync_file)\n+\t\t\tfput(sync_file->file);\n+\t}\n \n \tif (!IS_ERR_OR_NULL(submit)) {\n \t\tmsm_gem_submit_put(submit);",1060 "prediction": "Given the following original C code:\nint msm_ioctl_gem_submit(struct drm_device *dev, void *data,\n\t\tstruct drm_file *file)\n{\n\tstruct msm_drm_private *priv = dev->dev_private;\n\tstruct drm_msm_gem_submit *args = data;\n\tstruct msm_file_private *ctx = file->driver_priv;\n\tstruct msm_gem_submit *submit = NULL;\n\tstruct msm_gpu *gpu = priv->gpu;\n\tstruct msm_gpu_submitqueue *queue;\n\tstruct msm_ringbuffer *ring;\n\tstruct msm_submit_post_dep *post_deps = NULL;\n\tstruct drm_syncobj **syncobjs_to_reset = NULL;\n\tint out_fence_fd = -1;\n\tunsigned i;\n\tint ret;\n\n\tif (!gpu)\n\t\treturn -ENXIO;\n\n\tif (args->pad)\n\nInstruction:\ndrm/msm: Fix another leak in the submit error path\n\nReturn the diff that fixes it:\n @@ -104,6 +104,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,\n \tstruct msm_ringbuffer *ring;\n \tstruct msm_submit_post_dep *post_deps = NULL;\n \tstruct drm_syncobj **syncobjs_to_reset = NULL;\n+\tstruct drm_syncobj *out_fence = NULL;\n \tint out_fence_fd = -1;\n \tunsigned i;\n \tint ret;\n@@ -116,10 +117,11 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,\n \t\treturn -EINVAL;\n \n \tif (args->flags & MSM_SUBMIT_FENCE_FD_OUT) {\n-\t\tout_fence_fd = get_unused_fd_flags(O_CLOEXEC);\n-\t\tif (out_fence_fd < 0)"1061 },1062 {1063 "prompt": "Given the following original C code:\na5xx_idle(gpu, ring);\n\tring->memptrs->fence = submit->seqno;\n\tmsm_gpu_retire(gpu);\n}\n\nstatic void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n{\n\tstruct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);\n\tstruct a5xx_gpu *a5xx_gpu = to_a5xx_gpu(adreno_gpu);\n\tstruct msm_ringbuffer *ring = submit->ring;\n\tunsigned int i, ibs = 0;\n\n\tif (IS_ENABLED(CONFIG_DRM_MSM_GPU_SUDO) && submit->in_rb) {\n\t\tring->cur_ctx_seqno = 0;\n\t\ta5xx_submit_in_rb(gpu, submit);\n\t\treturn;\n\t}\n\n\tOUT_PKT7(ring, CP_PREEMPT_ENABLE_GLOBAL, 1);\n\tOUT_RING(ring, 0x02);\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1064 "reference": "@@ -131,6 +131,8 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n \tstruct msm_ringbuffer *ring = submit->ring;\n \tunsigned int i, ibs = 0;\n \n+\tadreno_check_and_reenable_stall(adreno_gpu);\n+\n \tif (IS_ENABLED(CONFIG_DRM_MSM_GPU_SUDO) && submit->in_rb) {\n \t\tring->cur_ctx_seqno = 0;\n \t\ta5xx_submit_in_rb(gpu, submit);",1065 "prediction": "Given the following original C code:\na5xx_idle(gpu, ring);\n\tring->memptrs->fence = submit->seqno;\n\tmsm_gpu_retire(gpu);\n}\n\nstatic void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n{\n\tstruct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);\n\tstruct a5xx_gpu *a5xx_gpu = to_a5xx_gpu(adreno_gpu);\n\tstruct msm_ringbuffer *ring = submit->ring;\n\tunsigned int i, ibs = 0;\n\n\tif (IS_ENABLED(CONFIG_DRM_MSM_GPU_SUDO) && submit->in_rb) {\n\t\tring->cur_ctx_seqno = 0;\n\t\ta5xx_submit_in_rb(gpu, submit);\n\t\treturn;\n\t}\n\n\tOUT_PKT7(ring, CP_PREEMPT_ENABLE_GLOBAL, 1);\n\tOUT_RING(ring, 0x02);\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -104,6 +104,10 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n \tstruct msm_ringbuffer *ring = submit->ring;\n \tunsigned int i, ibs = 0;\n \n+\t/*\n+\t * Disable stall-on-fault after a page fault. This is a temporary\n+\t * workaround for a5xx hangs.\n+\t */\n+\n \tif (IS_ENABLED(CONFIG_DRM_MSM_GPU_SUDO) && submit->in_rb) {\n \t\tring->cur_ctx_seqno = 0;\n \t\ta5xx_submit_in_rb(gpu, submit);\n@@ -112,6 +116,10 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n \tOUT_PKT7(ring, CP_PREEMPT_ENABLE_G"1066 },1067 {1068 "prompt": "Given the following original C code:\n}\n\t}\n}\n\nstatic void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n{\n\tunsigned int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT;\n\tstruct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);\n\tstruct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);\n\tstruct msm_ringbuffer *ring = submit->ring;\n\tunsigned int i, ibs = 0;\n\n\ta6xx_set_pagetable(a6xx_gpu, ring, submit);\n\n\tget_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP(0),\n\t\trbmemptr_stats(ring, index, cpcycles_start));\n\n\t/*\n\t * For PM4 the GMU register offsets are calculated from the base of the\n\t * GPU registers so we need to add 0x1a800 to the register value on A630\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1069 "reference": "@@ -212,6 +212,8 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n \tstruct msm_ringbuffer *ring = submit->ring;\n \tunsigned int i, ibs = 0;\n \n+\tadreno_check_and_reenable_stall(adreno_gpu);\n+\n \ta6xx_set_pagetable(a6xx_gpu, ring, submit);\n \n \tget_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP(0),\n@@ -335,6 +337,8 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n \tstruct msm_ringbuffer *ring = submit->ring;\n \tunsigned int i, ibs = 0;\n \n+\tadreno_check_and_reenable_stall(adreno_gpu);\n+\n \t/*\n \t * Toggle concurrent binning for pagetable switch and set the thread to\n \t * BR since only it can execute the pagetable switch packets.",1070 "prediction": "Given the following original C code:\n}\n\t}\n}\n\nstatic void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n{\n\tunsigned int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT;\n\tstruct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);\n\tstruct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);\n\tstruct msm_ringbuffer *ring = submit->ring;\n\tunsigned int i, ibs = 0;\n\n\ta6xx_set_pagetable(a6xx_gpu, ring, submit);\n\n\tget_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP(0),\n\t\trbmemptr_stats(ring, index, cpcycles_start));\n\n\t/*\n\t * For PM4 the GMU register offsets are calculated from the base of the\n\t * GPU registers so we need to add 0x1a800 to the register value on A630\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -108,6 +108,10 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)\n \tstruct msm_ringbuffer *ring = submit->ring;\n \tunsigned int i, ibs = 0;\n \n+\t/*\n+\t * Disable stall-on-fault after a page fault. This is a temporary\n+\t * workaround for a630 hangs.\n+\t */\n+\tif (adreno_is_a630(adreno_gpu))\n+\t\tWRITE_ONCE(a6xx_gpu->stall_on_fault, 0);\n+\n \ta6xx_set_pagetable(a6xx_gpu, ring, submit);\n \n \tget_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP(0),\n@@ -116,6 +120,7 @@ static void a6xx_submit(struct msm_gpu"1071 },1072 {1073 "prompt": "Given the following original C code:\nttbr1_cfg = adreno_smmu->get_ttbr1_cfg(adreno_smmu->cookie);\n\n\t/*\n\t * Userspace VM is actually using TTBR0, but both are the same size,\n\t * with b48 (sign bit) selecting which TTBRn to use. So if IAS is\n\t * 48, the total (kernel+user) address space size is effectively\n\t * 49 bits. But what userspace is control of is the lower 48.\n\t */\n\treturn BIT(ttbr1_cfg->ias) - ADRENO_VM_START;\n}\n\n#define ARM_SMMU_FSR_TF BIT(1)\n#define ARM_SMMU_FSR_PF\t\t\tBIT(3)\n#define ARM_SMMU_FSR_EF\t\t\tBIT(4)\n\nint adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags,\n\t\t\t struct adreno_smmu_fault_info *info, const char *block,\n\t\t\t u32 scratch[4])\n{\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1074 "reference": "@@ -259,16 +259,54 @@ u64 adreno_private_address_space_size(struct msm_gpu *gpu)\n \treturn BIT(ttbr1_cfg->ias) - ADRENO_VM_START;\n }\n \n+void adreno_check_and_reenable_stall(struct adreno_gpu *adreno_gpu)\n+{\n+\tstruct msm_gpu *gpu = &adreno_gpu->base;\n+\tstruct msm_drm_private *priv = gpu->dev->dev_private;\n+\tunsigned long flags;\n+\n+\t/*\n+\t * Wait until the cooldown period has passed and we would actually\n+\t * collect a crashdump to re-enable stall-on-fault.\n+\t */\n+\tspin_lock_irqsave(&priv->fault_stall_lock, flags);\n+\tif (!priv->stall_enabled &&\n+\t\t\tktime_after(ktime_get(), priv->stall_reenable_time) &&\n+\t\t\t!READ_ONCE(gpu->crashstate)) {\n+\t\tpriv->stall_enabled = true;\n+\n+\t\tgpu->aspace->mmu->funcs->set_stall(gpu->aspace->mmu, true);\n+\t}\n+\tspin_unlock_irqrestore(&priv->fault_stall_lock, flags);\n+}\n+\n #define ARM_SMMU_FSR_TF BIT(1)\n #define ARM_SMMU_FSR_PF\t\t\tBIT(3)\n #define ARM_SMMU_FSR_EF\t\t\tBIT(4)\n+#define ARM_SMMU_FSR_SS\t\t\tBIT(30)\n \n int adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags,\n \t\t\t struct adreno_smmu_fault_info *info, const char *block,\n \t\t\t u32 scratch[4])\n {\n+\tstruct msm_drm_private *priv = gpu->dev->dev_private;\n \tconst char *type = \"UNKNOWN\";\n-\tbool do_devcoredump = info && !READ_ONCE(gpu->crashstate);\n+\tbool do_devcoredump = info && (info->fsr & ARM_SMMU_FSR_SS) &&\n+\t\t!READ_ONCE(gpu->crashstate);\n+\tunsigned long irq_flags;\n+\n+\t/*\n+\t * In case there is a subsequent storm of pagefaults, disable\n+\t * stall-on-fault for at least half a second.\n+\t */\n+\tspin_lock_irqsave(&priv->fault_stall_lock, irq_flags);\n+\tif (priv->stall_enabled) {\n+\t\tpriv->stall_enabled = false;\n+\n+\t\tgpu->aspace->mmu->funcs->set_stall(gpu->aspace->mmu, false);\n+\t}\n+\tpriv->stall_reenable_time = ktime_add_ms(ktime_get(), 500);\n+\tspin_unlock_irqrestore(&priv->fault_stall_lock, irq_flags);\n \n \t/*\n \t * Print a default message if we couldn't get the data from the",1075 "prediction": "Given the following original C code:\nttbr1_cfg = adreno_smmu->get_ttbr1_cfg(adreno_smmu->cookie);\n\n\t/*\n\t * Userspace VM is actually using TTBR0, but both are the same size,\n\t * with b48 (sign bit) selecting which TTBRn to use. So if IAS is\n\t * 48, the total (kernel+user) address space size is effectively\n\t * 49 bits. But what userspace is control of is the lower 48.\n\t */\n\treturn BIT(ttbr1_cfg->ias) - ADRENO_VM_START;\n}\n\n#define ARM_SMMU_FSR_TF BIT(1)\n#define ARM_SMMU_FSR_PF\t\t\tBIT(3)\n#define ARM_SMMU_FSR_EF\t\t\tBIT(4)\n\nint adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags,\n\t\t\t struct adreno_smmu_fault_info *info, const char *block,\n\t\t\t u32 scratch[4])\n{\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -108,6 +108,10 @@ static unsigned long adreno_smmu_get_vm_size(struct adreno_smmu *adreno_smmu)\n }\n \n #define ARM_SMMU_FSR_TF BIT(1)\n+#define ARM_SMMU_FSR_TF_SHIFT\t\t1\n+#define ARM_SMMU_FSR_TF_MASK\t\t(1 << ARM_SMMU_FSR_TF_SHIFT)\n+#define ARM_SMMU_FSR_TF_BIT\t\t(1 << ARM_SMMU_FSR_TF_SHIFT)\n+\n #define ARM_SMMU_FSR_PF\t\t\tBIT(3)\n #define ARM_SMMU_FSR_EF\t\t\tBIT(4)\n \n@@ -115,6 +119,7 @@ int adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags"1076 },1077 {1078 "prompt": "Given the following original C code:\nadreno_create_address_space(struct msm_gpu *gpu,\n\t\t\t struct platform_device *pdev);\n\nstruct msm_gem_address_space *\nadreno_iommu_create_address_space(struct msm_gpu *gpu,\n\t\t\t\t struct platform_device *pdev,\n\t\t\t\t unsigned long quirks);\n\nint adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags,\n\t\t\t struct adreno_smmu_fault_info *info, const char *block,\n\t\t\t u32 scratch[4]);\n\nint adreno_read_speedbin(struct device *dev, u32 *speedbin);\n\n/*\n * For a5xx and a6xx targets load the zap shader that is used to pull the GPU\n * out of secure mode\n */\nint adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid);\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1079 "reference": "@@ -636,6 +636,8 @@ int adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags,\n \t\t\t struct adreno_smmu_fault_info *info, const char *block,\n \t\t\t u32 scratch[4]);\n \n+void adreno_check_and_reenable_stall(struct adreno_gpu *gpu);\n+\n int adreno_read_speedbin(struct device *dev, u32 *speedbin);\n \n /*",1080 "prediction": "Given the following original C code:\nadreno_create_address_space(struct msm_gpu *gpu,\n\t\t\t struct platform_device *pdev);\n\nstruct msm_gem_address_space *\nadreno_iommu_create_address_space(struct msm_gpu *gpu,\n\t\t\t\t struct platform_device *pdev,\n\t\t\t\t unsigned long quirks);\n\nint adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags,\n\t\t\t struct adreno_smmu_fault_info *info, const char *block,\n\t\t\t u32 scratch[4]);\n\nint adreno_read_speedbin(struct device *dev, u32 *speedbin);\n\n/*\n * For a5xx and a6xx targets load the zap shader that is used to pull the GPU\n * out of secure mode\n */\nint adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid);\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -102,6 +102,10 @@ int adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags,\n \t\t\t struct adreno_smmu_fault_info *info, const char *block,\n \t\t\t u32 scratch[4]);\n \n+int adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags,\n+\t\t\t struct adreno_smmu_fault_info *info, const char *block,\n+\t\t\t u32 scratch[4], bool stall_on_fault);\n+\n+\n int adreno_read_speedbin(struct device *dev, u32 *speedbin);\n \n /*\n@@ -113,6 +117,7 @@ int adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid);\n \n int adreno_idle(struct msm_gpu *gpu);\n \n+void adreno_set_"1081 },1082 {1083 "prompt": "Given the following original C code:\n{\n\tstruct drm_device *dev = data;\n\n\tlast_shrink_freed = msm_gem_shrinker_shrink(dev, val);\n\n\treturn 0;\n}\n\nDEFINE_DEBUGFS_ATTRIBUTE(shrink_fops,\n\t\t\t shrink_get, shrink_set,\n\t\t\t \"0x%08llx\\n\");\n\n\nstatic int msm_gem_show(struct seq_file *m, void *arg)\n{\n\tstruct drm_info_node *node = m->private;\n\tstruct drm_device *dev = node->minor->dev;\n\tstruct msm_drm_private *priv = dev->dev_private;\n\tint ret;\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1084 "reference": "@@ -208,6 +208,35 @@ DEFINE_DEBUGFS_ATTRIBUTE(shrink_fops,\n \t\t\t shrink_get, shrink_set,\n \t\t\t \"0x%08llx\\n\");\n \n+/*\n+ * Return the number of microseconds to wait until stall-on-fault is\n+ * re-enabled. If 0 then it is already enabled or will be re-enabled on the\n+ * next submit (unless there's a leftover devcoredump). This is useful for\n+ * kernel tests that intentionally produce a fault and check the devcoredump to\n+ * wait until the cooldown period is over.\n+ */\n+\n+static int\n+stall_reenable_time_get(void *data, u64 *val)\n+{\n+\tstruct msm_drm_private *priv = data;\n+\tunsigned long irq_flags;\n+\n+\tspin_lock_irqsave(&priv->fault_stall_lock, irq_flags);\n+\n+\tif (priv->stall_enabled)\n+\t\t*val = 0;\n+\telse\n+\t\t*val = max(ktime_us_delta(priv->stall_reenable_time, ktime_get()), 0);\n+\n+\tspin_unlock_irqrestore(&priv->fault_stall_lock, irq_flags);\n+\n+\treturn 0;\n+}\n+\n+DEFINE_DEBUGFS_ATTRIBUTE(stall_reenable_time_fops,\n+\t\t\t stall_reenable_time_get, NULL,\n+\t\t\t \"%lld\\n\");\n \n static int msm_gem_show(struct seq_file *m, void *arg)\n {\n@@ -319,6 +348,9 @@ static void msm_debugfs_gpu_init(struct drm_minor *minor)\n \tdebugfs_create_bool(\"disable_err_irq\", 0600, minor->debugfs_root,\n \t\t&priv->disable_err_irq);\n \n+\tdebugfs_create_file(\"stall_reenable_time_us\", 0400, minor->debugfs_root,\n+\t\tpriv, &stall_reenable_time_fops);\n+\n \tgpu_devfreq = debugfs_create_dir(\"devfreq\", minor->debugfs_root);\n \n \tdebugfs_create_bool(\"idle_clamp\",0600, gpu_devfreq,",1085 "prediction": "Given the following original C code:\n{\n\tstruct drm_device *dev = data;\n\n\tlast_shrink_freed = msm_gem_shrinker_shrink(dev, val);\n\n\treturn 0;\n}\n\nDEFINE_DEBUGFS_ATTRIBUTE(shrink_fops,\n\t\t\t shrink_get, shrink_set,\n\t\t\t \"0x%08llx\\n\");\n\n\nstatic int msm_gem_show(struct seq_file *m, void *arg)\n{\n\tstruct drm_info_node *node = m->private;\n\tstruct drm_device *dev = node->minor->dev;\n\tstruct msm_drm_private *priv = dev->dev_private;\n\tint ret;\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -103,6 +103,11 @@ static int shrink_set(void *data, u64 val)\n DEFINE_DEBUGFS_ATTRIBUTE(shrink_fops,\n \t\t\t shrink_get, shrink_set,\n \t\t\t \"0x%08llx\\n\");\n+\n+static int stall_on_fault_get(void *data, u64 *val)\n+{\n+\t*val = stall_on_fault;\n+\treturn 0;\n+}\n+\n+static int stall_on_fault_set(void *data, u64 val)\n+{\n+\tstall_on_fault = val;\n+\treturn 0;\n+}\n+\n static int msm_gem_show(struct seq_file *m, void *arg)\n {\n \tstruct drm_info_node *node = m->private;\n@@ -111,6 +116,11 @@ static int msm_gem_show(struct seq"1086 },1087 {1088 "prompt": "Given the following original C code:\nINIT_LIST_HEAD(&priv->objects);\n\tmutex_init(&priv->obj_lock);\n\n\t/*\n\t * Initialize the LRUs:\n\t */\n\tmutex_init(&priv->lru.lock);\n\tdrm_gem_lru_init(&priv->lru.unbacked, &priv->lru.lock);\n\tdrm_gem_lru_init(&priv->lru.pinned, &priv->lru.lock);\n\tdrm_gem_lru_init(&priv->lru.willneed, &priv->lru.lock);\n\tdrm_gem_lru_init(&priv->lru.dontneed, &priv->lru.lock);\n\n\t/* Teach lockdep about lock ordering wrt. shrinker: */\n\tfs_reclaim_acquire(GFP_KERNEL);\n\tmight_lock(&priv->lru.lock);\n\tfs_reclaim_release(GFP_KERNEL);\n\n\tif (priv->kms_init) {\n\t\tret = drmm_mode_config_init(ddev);\n\t\tif (ret)\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1089 "reference": "@@ -245,6 +245,10 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)\n \tdrm_gem_lru_init(&priv->lru.willneed, &priv->lru.lock);\n \tdrm_gem_lru_init(&priv->lru.dontneed, &priv->lru.lock);\n \n+\t/* Initialize stall-on-fault */\n+\tspin_lock_init(&priv->fault_stall_lock);\n+\tpriv->stall_enabled = true;\n+\n \t/* Teach lockdep about lock ordering wrt. shrinker: */\n \tfs_reclaim_acquire(GFP_KERNEL);\n \tmight_lock(&priv->lru.lock);",1090 "prediction": "Given the following original C code:\nINIT_LIST_HEAD(&priv->objects);\n\tmutex_init(&priv->obj_lock);\n\n\t/*\n\t * Initialize the LRUs:\n\t */\n\tmutex_init(&priv->lru.lock);\n\tdrm_gem_lru_init(&priv->lru.unbacked, &priv->lru.lock);\n\tdrm_gem_lru_init(&priv->lru.pinned, &priv->lru.lock);\n\tdrm_gem_lru_init(&priv->lru.willneed, &priv->lru.lock);\n\tdrm_gem_lru_init(&priv->lru.dontneed, &priv->lru.lock);\n\n\t/* Teach lockdep about lock ordering wrt. shrinker: */\n\tfs_reclaim_acquire(GFP_KERNEL);\n\tmight_lock(&priv->lru.lock);\n\tfs_reclaim_release(GFP_KERNEL);\n\n\tif (priv->kms_init) {\n\t\tret = drmm_mode_config_init(ddev);\n\t\tif (ret)\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -100,6 +100,10 @@ static int msm_drm_init(struct drm_device *ddev)\n \tdrm_gem_lru_init(&priv->lru.willneed, &priv->lru.lock);\n \tdrm_gem_lru_init(&priv->lru.dontneed, &priv->lru.lock);\n \n+\t/*\n+\t * Disable stall-on-fault after a page fault.\n+\t */\n+\tdrm_mm_set_fault_handler(priv->mm, NULL, NULL);\n+\n \t/* Teach lockdep about lock ordering wrt. shrinker: */\n \tfs_reclaim_acquire(GFP_KERNEL);\n \tmight_lock(&priv->lru.lock);\n@@ -108,6 +112,7 @@ static int msm_drm_init(struct drm_device *ddev)\n \n \tif (priv->kms_init) {\n \t\tret ="1091 },1092 {1093 "prompt": "Given the following original C code:\n* gpu_clamp_to_idle: Enable clamping to idle freq when inactive\n\t */\n\tbool gpu_clamp_to_idle;\n\n\t/**\n\t * disable_err_irq:\n\t *\n\t * Disable handling of GPU hw error interrupts, to force fallback to\n\t * sw hangcheck timer. Written (via debugfs) by igt tests to test\n\t * the sw hangcheck mechanism.\n\t */\n\tbool disable_err_irq;\n};\n\nconst struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format, uint64_t modifier);\n\nstruct msm_pending_timer;\n\nint msm_atomic_init_pending_timer(struct msm_pending_timer *timer,\n\t\tstruct msm_kms *kms, int crtc_idx);\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1094 "reference": "@@ -222,6 +222,29 @@ struct msm_drm_private {\n \t * the sw hangcheck mechanism.\n \t */\n \tbool disable_err_irq;\n+\n+\t/**\n+\t * @fault_stall_lock:\n+\t *\n+\t * Serialize changes to stall-on-fault state.\n+\t */\n+\tspinlock_t fault_stall_lock;\n+\n+\t/**\n+\t * @fault_stall_reenable_time:\n+\t *\n+\t * If stall_enabled is false, when to reenable stall-on-fault.\n+\t * Protected by @fault_stall_lock.\n+\t */\n+\tktime_t stall_reenable_time;\n+\n+\t/**\n+\t * @stall_enabled:\n+\t *\n+\t * Whether stall-on-fault is currently enabled. Protected by\n+\t * @fault_stall_lock.\n+\t */\n+\tbool stall_enabled;\n };\n \n const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format, uint64_t modifier);",1095 "prediction": "Given the following original C code:\n* gpu_clamp_to_idle: Enable clamping to idle freq when inactive\n\t */\n\tbool gpu_clamp_to_idle;\n\n\t/**\n\t * disable_err_irq:\n\t *\n\t * Disable handling of GPU hw error interrupts, to force fallback to\n\t * sw hangcheck timer. Written (via debugfs) by igt tests to test\n\t * the sw hangcheck mechanism.\n\t */\n\tbool disable_err_irq;\n};\n\nconst struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format, uint64_t modifier);\n\nstruct msm_pending_timer;\n\nint msm_atomic_init_pending_timer(struct msm_pending_timer *timer,\n\t\tstruct msm_kms *kms, int crtc_idx);\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -100,6 +100,10 @@ struct msm_kms {\n \t * the sw hangcheck mechanism.\n \t */\n \tbool disable_err_irq;\n+\n+\t/**\n+\t * stall_on_fault:\n+\t *\n+\t * Disable stalling on faults, to allow the GPU to continue running\n+\t * after a page fault.\n+\t */\n+\tbool stall_on_fault;\n };\n \n const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format, uint64_t modifier);\n@@ -108,6 +112,7 @@ struct msm_pending_timer;\n int msm_atomic_init_pending_timer(struct msm_pending_timer *timer,\n \t\tstruct msm_kms *kms, int crtc_idx);\n void msm_atomic_cleanup_pending_timer(struct msm_pending_timer *timer);\n+"1096 },1097 {1098 "prompt": "Given the following original C code:\nstatic int msm_disp_fault_handler(struct iommu_domain *domain, struct device *dev,\n\t\t\t\t unsigned long iova, int flags, void *arg)\n{\n\tstruct msm_iommu *iommu = arg;\n\n\tif (iommu->base.handler)\n\t\treturn iommu->base.handler(iommu->base.arg, iova, flags, NULL);\n\n\treturn -ENOSYS;\n}\n\nstatic void msm_iommu_detach(struct msm_mmu *mmu)\n{\n\tstruct msm_iommu *iommu = to_msm_iommu(mmu);\n\n\tiommu_detach_device(iommu->domain, mmu->dev);\n}\n\nstatic int msm_iommu_map(struct msm_mmu *mmu, uint64_t iova,\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1099 "reference": "@@ -372,6 +372,14 @@ static int msm_disp_fault_handler(struct iommu_domain *domain, struct device *de\n \treturn -ENOSYS;\n }\n \n+static void msm_iommu_set_stall(struct msm_mmu *mmu, bool enable)\n+{\n+\tstruct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(mmu->dev);\n+\n+\tif (adreno_smmu->set_stall)\n+\t\tadreno_smmu->set_stall(adreno_smmu->cookie, enable);\n+}\n+\n static void msm_iommu_detach(struct msm_mmu *mmu)\n {\n \tstruct msm_iommu *iommu = to_msm_iommu(mmu);\n@@ -419,6 +427,7 @@ static const struct msm_mmu_funcs funcs = {\n \t\t.map = msm_iommu_map,\n \t\t.unmap = msm_iommu_unmap,\n \t\t.destroy = msm_iommu_destroy,\n+\t\t.set_stall = msm_iommu_set_stall,\n };\n \n struct msm_mmu *msm_iommu_new(struct device *dev, unsigned long quirks)",1100 "prediction": "Given the following original C code:\nstatic int msm_disp_fault_handler(struct iommu_domain *domain, struct device *dev,\n\t\t\t\t unsigned long iova, int flags, void *arg)\n{\n\tstruct msm_iommu *iommu = arg;\n\n\tif (iommu->base.handler)\n\t\treturn iommu->base.handler(iommu->base.arg, iova, flags, NULL);\n\n\treturn -ENOSYS;\n}\n\nstatic void msm_iommu_detach(struct msm_mmu *mmu)\n{\n\tstruct msm_iommu *iommu = to_msm_iommu(mmu);\n\n\tiommu_detach_device(iommu->domain, mmu->dev);\n}\n\nstatic int msm_iommu_map(struct msm_mmu *mmu, uint64_t iova,\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -104,6 +104,10 @@ static int msm_disp_fault_handler(struct iommu_domain *domain, struct device *d\n \treturn -ENOSYS;\n }\n \n+static int msm_iommu_fault_handler(struct iommu_domain *domain,\n+\t\t\t\t struct device *dev, unsigned long iova,\n+\t\t\t\t int flags, void *arg)\n+{\n+\treturn -ENOSYS;\n+}\n+\n static void msm_iommu_detach(struct msm_mmu *mmu)\n {\n \tstruct msm_iommu *iommu = to_msm_iommu(mmu);\n@@ -112,7 +116,7 @@ static void msm_iommu_detach(struct msm_mmu *mmu)\n \tiommu_detach_device(iommu->domain, mmu->dev);\n }\n \n-static int msm_iommu_fault_handler(struct iommu_"1101 },1102 {1103 "prompt": "Given the following original C code:\n#ifndef __MSM_MMU_H__\n#define __MSM_MMU_H__\n\n#include <linux/iommu.h>\n\nstruct msm_mmu_funcs {\n\tvoid (*detach)(struct msm_mmu *mmu);\n\tint (*map)(struct msm_mmu *mmu, uint64_t iova, struct sg_table *sgt,\n\t\t\tsize_t len, int prot);\n\tint (*unmap)(struct msm_mmu *mmu, uint64_t iova, size_t len);\n\tvoid (*destroy)(struct msm_mmu *mmu);\n};\n\nenum msm_mmu_type {\n\tMSM_MMU_GPUMMU,\n\tMSM_MMU_IOMMU,\n\tMSM_MMU_IOMMU_PAGETABLE,\n};\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n",1104 "reference": "@@ -15,6 +15,7 @@ struct msm_mmu_funcs {\n \t\t\tsize_t len, int prot);\n \tint (*unmap)(struct msm_mmu *mmu, uint64_t iova, size_t len);\n \tvoid (*destroy)(struct msm_mmu *mmu);\n+\tvoid (*set_stall)(struct msm_mmu *mmu, bool enable);\n };\n \n enum msm_mmu_type {",1105 "prediction": "Given the following original C code:\n#ifndef __MSM_MMU_H__\n#define __MSM_MMU_H__\n\n#include <linux/iommu.h>\n\nstruct msm_mmu_funcs {\n\tvoid (*detach)(struct msm_mmu *mmu);\n\tint (*map)(struct msm_mmu *mmu, uint64_t iova, struct sg_table *sgt,\n\t\t\tsize_t len, int prot);\n\tint (*unmap)(struct msm_mmu *mmu, uint64_t iova, size_t len);\n\tvoid (*destroy)(struct msm_mmu *mmu);\n};\n\nenum msm_mmu_type {\n\tMSM_MMU_GPUMMU,\n\tMSM_MMU_IOMMU,\n\tMSM_MMU_IOMMU_PAGETABLE,\n};\n\nInstruction:\ndrm/msm: Temporarily disable stall-on-fault after a page fault\n\nReturn the diff that fixes it:\n @@ -10,6 +10,7 @@ struct msm_mmu_funcs {\n \tint (*map)(struct msm_mmu *mmu, uint64_t iova, struct sg_table *sgt,\n \t\t\tsize_t len, int prot);\n \tint (*unmap)(struct msm_mmu *mmu, uint64_t iova, size_t len);\n+\tint (*fault)(struct msm_mmu *mmu, uint64_t iova, size_t len);\n \tvoid (*destroy)(struct msm_mmu *mmu);\n };\n \n@@ -18,6 +19,7 @@ enum msm_mmu_type {\n \tMSM_MMU_GPUMMU,\n \tMSM_MMU_IOMMU,\n \tMSM_MMU_IOMMU_PAGETABLE,\n+\tMSM_MMU_IOMMU_PAGETABLE_STALL,\n };\n \n struct msm_mmu {\n@@ -"1106 },1107 {1108 "prompt": "Given the following original C code:\nCCTL_ENDIAN_OPEN\t= (1U << 1),\t/* open address frame */\n\tCCTL_ENDIAN_CMD\t\t= (1U << 0),\t/* command table */\n\n\t/* MVS_Px_SER_CTLSTAT (per-phy control) */\n\tPHY_SSP_RST\t\t= (1U << 3),\t/* reset SSP link layer */\n\tPHY_BCAST_CHG\t\t= (1U << 2),\t/* broadcast(change) notif */\n\tPHY_RST_HARD\t\t= (1U << 1),\t/* hard reset + phy reset */\n\tPHY_RST\t\t\t= (1U << 0),\t/* phy reset */\n\tPHY_READY_MASK\t\t= (1U << 20),\n\n\t/* MVS_Px_INT_STAT, MVS_Px_INT_MASK (per-phy events) */\n\tPHYEV_DEC_ERR\t\t= (1U << 24),\t/* Phy Decoding Error */\n\tPHYEV_DCDR_ERR\t\t= (1U << 23),\t/* STP Deocder Error */\n\tPHYEV_CRC_ERR\t\t= (1U << 22),\t/* STP CRC Error */\n\tPHYEV_UNASSOC_FIS\t= (1U << 19),\t/* unassociated FIS rx'd */\n\tPHYEV_AN\t\t= (1U << 18),\t/* SATA async notification */\n\tPHYEV_BIST_ACT\t\t= (1U << 17),\t/* BIST activate FIS */\n\tPHYEV_SIG_FIS\t\t= (1U << 16),\t/* signature FIS */\n\tPHYEV_POOF\t\t= (1U << 12),\t/* phy ready from 1 -> 0 */\n\tPHYEV_IU_BIG\t\t= (1U << 11),\t/* IU too long err */\n\nInstruction:\nscsi: mvsas: Fix typos in per-phy comments and SAS cmd port registers\n\nReturn the diff that fixes it:\n",1109 "reference": "@@ -215,7 +215,7 @@ enum hw_register_bits {\n \n \t/* MVS_Px_INT_STAT, MVS_Px_INT_MASK (per-phy events) */\n \tPHYEV_DEC_ERR\t\t= (1U << 24),\t/* Phy Decoding Error */\n-\tPHYEV_DCDR_ERR\t\t= (1U << 23),\t/* STP Deocder Error */\n+\tPHYEV_DCDR_ERR\t\t= (1U << 23),\t/* STP Decoder Error */\n \tPHYEV_CRC_ERR\t\t= (1U << 22),\t/* STP CRC Error */\n \tPHYEV_UNASSOC_FIS\t= (1U << 19),\t/* unassociated FIS rx'd */\n \tPHYEV_AN\t\t= (1U << 18),\t/* SATA async notification */\n@@ -347,7 +347,7 @@ enum sas_cmd_port_registers {\n \tCMD_SATA_PORT_MEM_CTL0\t= 0x158, /* SATA Port Memory Control 0 */\n \tCMD_SATA_PORT_MEM_CTL1\t= 0x15c, /* SATA Port Memory Control 1 */\n \tCMD_XOR_MEM_BIST_CTL\t= 0x160, /* XOR Memory BIST Control */\n-\tCMD_XOR_MEM_BIST_STAT\t= 0x164, /* XOR Memroy BIST Status */\n+\tCMD_XOR_MEM_BIST_STAT\t= 0x164, /* XOR Memory BIST Status */\n \tCMD_DMA_MEM_BIST_CTL\t= 0x168, /* DMA Memory BIST Control */\n \tCMD_DMA_MEM_BIST_STAT\t= 0x16c, /* DMA Memory BIST Status */\n \tCMD_PORT_MEM_BIST_CTL\t= 0x170, /* Port Memory BIST Control */",1110 "prediction": "Given the following original C code:\nCCTL_ENDIAN_OPEN\t= (1U << 1),\t/* open address frame */\n\tCCTL_ENDIAN_CMD\t\t= (1U << 0),\t/* command table */\n\n\t/* MVS_Px_SER_CTLSTAT (per-phy control) */\n\tPHY_SSP_RST\t\t= (1U << 3),\t/* reset SSP link layer */\n\tPHY_BCAST_CHG\t\t= (1U << 2),\t/* broadcast(change) notif */\n\tPHY_RST_HARD\t\t= (1U << 1),\t/* hard reset + phy reset */\n\tPHY_RST\t\t\t= (1U << 0),\t/* phy reset */\n\tPHY_READY_MASK\t\t= (1U << 20),\n\n\t/* MVS_Px_INT_STAT, MVS_Px_INT_MASK (per-phy events) */\n\tPHYEV_DEC_ERR\t\t= (1U << 24),\t/* Phy Decoding Error */\n\tPHYEV_DCDR_ERR\t\t= (1U << 23),\t/* STP Deocder Error */\n\tPHYEV_CRC_ERR\t\t= (1U << 22),\t/* STP CRC Error */\n\tPHYEV_UNASSOC_FIS\t= (1U << 19),\t/* unassociated FIS rx'd */\n\tPHYEV_AN\t\t= (1U << 18),\t/* SATA async notification */\n\tPHYEV_BIST_ACT\t\t= (1U << 17),\t/* BIST activate FIS */\n\tPHYEV_SIG_FIS\t\t= (1U << 16),\t/* signature FIS */\n\tPHYEV_POOF\t\t= (1U << 12),\t/* phy ready from 1 -> 0 */\n\tPHYEV_IU_BIG\t\t= (1U << 11),\t/* IU too long err */\n\nInstruction:\nscsi: mvsas: Fix typos in per-phy comments and SAS cmd port registers\n\nReturn the diff that fixes it:\n @@ -104,7 +104,7 @@ enum {\n \n \t/* MVS_Px_INT_STAT, MVS_Px_INT_MASK (per-phy events) */\n \tPHYEV_DEC_ERR\t\t= (1U << 24),\t/* Phy Decoding Error */\n-\tPHYEV_DCDR_ERR\t\t= (1U << 23),\t/* STP Deocder Error */\n+\tPHYEV_DCDR_ERR\t\t= (1U << 23),\t/* STP Decode Error */\n \tPHYEV_CRC_ERR\t\t= (1U << 22),\t/* STP CRC Error */\n \tPHYEV_UNASSOC_FIS\t= (1U << 19),\t/* unassociated FIS rx'd */\n \tPHYEV_AN\t\t= (1U << 18),\t/* SATA async notification */\n@@ -112,7 +112,7 @@ enum {"1111 },1112 {1113 "prompt": "Given the following original C code:\nint err = 0;\n\n\tif (!transport->new_flashnode) {\n\t\terr = -ENOSYS;\n\t\tgoto exit_new_fnode;\n\t}\n\n\tshost = scsi_host_lookup(ev->u.new_flashnode.host_no);\n\tif (!shost) {\n\t\tpr_err(\"%s could not find host no %u\\n\",\n\t\t __func__, ev->u.new_flashnode.host_no);\n\t\terr = -ENODEV;\n\t\tgoto put_host;\n\t}\n\n\tindex = transport->new_flashnode(shost, data, len);\n\n\tif (index >= 0)\n\t\tev->r.new_flashnode_ret.flashnode_idx = index;\n\telse\n\nInstruction:\nscsi: iscsi: Fix incorrect error path labels for flashnode operations\n\nReturn the diff that fixes it:\n",1114 "reference": "@@ -3499,7 +3499,7 @@ static int iscsi_new_flashnode(struct iscsi_transport *transport,\n \t\tpr_err(\"%s could not find host no %u\\n\",\n \t\t __func__, ev->u.new_flashnode.host_no);\n \t\terr = -ENODEV;\n-\t\tgoto put_host;\n+\t\tgoto exit_new_fnode;\n \t}\n \n \tindex = transport->new_flashnode(shost, data, len);\n@@ -3509,7 +3509,6 @@ static int iscsi_new_flashnode(struct iscsi_transport *transport,\n \telse\n \t\terr = -EIO;\n \n-put_host:\n \tscsi_host_put(shost);\n \n exit_new_fnode:\n@@ -3534,7 +3533,7 @@ static int iscsi_del_flashnode(struct iscsi_transport *transport,\n \t\tpr_err(\"%s could not find host no %u\\n\",\n \t\t __func__, ev->u.del_flashnode.host_no);\n \t\terr = -ENODEV;\n-\t\tgoto put_host;\n+\t\tgoto exit_del_fnode;\n \t}\n \n \tidx = ev->u.del_flashnode.flashnode_idx;\n@@ -3576,7 +3575,7 @@ static int iscsi_login_flashnode(struct iscsi_transport *transport,\n \t\tpr_err(\"%s could not find host no %u\\n\",\n \t\t __func__, ev->u.login_flashnode.host_no);\n \t\terr = -ENODEV;\n-\t\tgoto put_host;\n+\t\tgoto exit_login_fnode;\n \t}\n \n \tidx = ev->u.login_flashnode.flashnode_idx;\n@@ -3628,7 +3627,7 @@ static int iscsi_logout_flashnode(struct iscsi_transport *transport,\n \t\tpr_err(\"%s could not find host no %u\\n\",\n \t\t __func__, ev->u.logout_flashnode.host_no);\n \t\terr = -ENODEV;\n-\t\tgoto put_host;\n+\t\tgoto exit_logout_fnode;\n \t}\n \n \tidx = ev->u.logout_flashnode.flashnode_idx;\n@@ -3678,7 +3677,7 @@ static int iscsi_logout_flashnode_sid(struct iscsi_transport *transport,\n \t\tpr_err(\"%s could not find host no %u\\n\",\n \t\t __func__, ev->u.logout_flashnode.host_no);\n \t\terr = -ENODEV;\n-\t\tgoto put_host;\n+\t\tgoto exit_logout_sid;\n \t}\n \n \tsession = iscsi_session_lookup(ev->u.logout_flashnode_sid.sid);",1115 "prediction": "Given the following original C code:\nint err = 0;\n\n\tif (!transport->new_flashnode) {\n\t\terr = -ENOSYS;\n\t\tgoto exit_new_fnode;\n\t}\n\n\tshost = scsi_host_lookup(ev->u.new_flashnode.host_no);\n\tif (!shost) {\n\t\tpr_err(\"%s could not find host no %u\\n\",\n\t\t __func__, ev->u.new_flashnode.host_no);\n\t\terr = -ENODEV;\n\t\tgoto put_host;\n\t}\n\n\tindex = transport->new_flashnode(shost, data, len);\n\n\tif (index >= 0)\n\t\tev->r.new_flashnode_ret.flashnode_idx = index;\n\telse\n\nInstruction:\nscsi: iscsi: Fix incorrect error path labels for flashnode operations\n\nReturn the diff that fixes it:\n @@ -100,7 +100,7 @@ int iscsi_host_flashnode_event(struct iscsi_transport *transport,\n \t\tpr_err(\"%s could not find host no %u\\n\",\n \t\t __func__, ev->u.new_flashnode.host_no);\n \t\terr = -ENODEV;\n-\t\tgoto put_host;\n+\t\tgoto exit_put_host;\n \t}\n \n \tindex = transport->new_flashnode(shost, data, len);\n@@ -109,7 +109,7 @@ int iscsi_host_flashnode_event(struct iscsi_transport *transport,\n \tif (index >= 0)\n \t\tev->r.new_flashnode_ret.flashnode_idx = index;\n \telse\n-\t\tgoto put_host;\n+\t\tgoto exit_put_host;\n \n exit_put_host:\n \tscsi_host_put(shost);\n@@ -11"1116 },1117 {1118 "prompt": "Given the following original C code:\nreturn;\n\n\tif (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid))\n\t\treturn;\n\n\tif (adreno_gpu->info->family >= ADRENO_7XX_GEN1) {\n\t\t/* Wait for previous submit to complete before continuing: */\n\t\tOUT_PKT7(ring, CP_WAIT_TIMESTAMP, 4);\n\t\tOUT_RING(ring, 0);\n\t\tOUT_RING(ring, lower_32_bits(rbmemptr(ring, fence)));\n\t\tOUT_RING(ring, upper_32_bits(rbmemptr(ring, fence)));\n\t\tOUT_RING(ring, submit->seqno - 1);\n\t}\n\n\tif (!sysprof) {\n\t\tif (!adreno_is_a7xx(adreno_gpu)) {\n\t\t\t/* Turn off protected mode to write to special registers */\n\t\t\tOUT_PKT7(ring, CP_SET_PROTECTED_MODE, 1);\n\t\t\tOUT_RING(ring, 0);\n\t\t}\n\nInstruction:\ndrm/msm/a7xx: Call CP_RESET_CONTEXT_STATE\n\nReturn the diff that fixes it:\n",1119 "reference": "@@ -130,6 +130,20 @@ static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu,\n \t\tOUT_RING(ring, lower_32_bits(rbmemptr(ring, fence)));\n \t\tOUT_RING(ring, upper_32_bits(rbmemptr(ring, fence)));\n \t\tOUT_RING(ring, submit->seqno - 1);\n+\n+\t\tOUT_PKT7(ring, CP_THREAD_CONTROL, 1);\n+\t\tOUT_RING(ring, CP_SET_THREAD_BOTH);\n+\n+\t\t/* Reset state used to synchronize BR and BV */\n+\t\tOUT_PKT7(ring, CP_RESET_CONTEXT_STATE, 1);\n+\t\tOUT_RING(ring,\n+\t\t\t CP_RESET_CONTEXT_STATE_0_CLEAR_ON_CHIP_TS |\n+\t\t\t CP_RESET_CONTEXT_STATE_0_CLEAR_RESOURCE_TABLE |\n+\t\t\t CP_RESET_CONTEXT_STATE_0_CLEAR_BV_BR_COUNTER |\n+\t\t\t CP_RESET_CONTEXT_STATE_0_RESET_GLOBAL_LOCAL_TS);\n+\n+\t\tOUT_PKT7(ring, CP_THREAD_CONTROL, 1);\n+\t\tOUT_RING(ring, CP_SET_THREAD_BR);\n \t}\n \n \tif (!sysprof) {",1120 "prediction": "Given the following original C code:\nreturn;\n\n\tif (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid))\n\t\treturn;\n\n\tif (adreno_gpu->info->family >= ADRENO_7XX_GEN1) {\n\t\t/* Wait for previous submit to complete before continuing: */\n\t\tOUT_PKT7(ring, CP_WAIT_TIMESTAMP, 4);\n\t\tOUT_RING(ring, 0);\n\t\tOUT_RING(ring, lower_32_bits(rbmemptr(ring, fence)));\n\t\tOUT_RING(ring, upper_32_bits(rbmemptr(ring, fence)));\n\t\tOUT_RING(ring, submit->seqno - 1);\n\t}\n\n\tif (!sysprof) {\n\t\tif (!adreno_is_a7xx(adreno_gpu)) {\n\t\t\t/* Turn off protected mode to write to special registers */\n\t\t\tOUT_PKT7(ring, CP_SET_PROTECTED_MODE, 1);\n\t\t\tOUT_RING(ring, 0);\n\t\t}\n\nInstruction:\ndrm/msm/a7xx: Call CP_RESET_CONTEXT_STATE\n\nReturn the diff that fixes it:\n @@ -100,6 +100,10 @@ void msm_ringbuffer_submit(struct msm_ringbuffer *ring)\n \t\tOUT_RING(ring, lower_32_bits(rbmemptr(ring, fence)));\n \t\tOUT_RING(ring, upper_32_bits(rbmemptr(ring, fence)));\n \t\tOUT_RING(ring, submit->seqno - 1);\n+\t} else {\n+\t\tOUT_PKT7(ring, CP_RESET_CONTEXT_STATE, 0);\n+\t}\n+\n \tif (!sysprof) {\n \t\tif (!adreno_is_a7xx(adreno_gpu)) {\n \t\t\t/* Turn off protected mode to write to special registers */\n@@ -108,6 +112,10 @@ void msm_ringbuffer_submit(struct msm_ringbuffer *ring)\n \t\t\tOUT_RING(ring, 0);\n \t\t}\n \n+"1121 },1122 {1123 "prompt": "Given the following original C code:\nslot->backlog -= len;\n\t\tsfq_dec(q, x);\n\t\tsch->q.qlen--;\n\t\tqdisc_qstats_backlog_dec(sch, skb);\n\t\tqdisc_drop(skb, sch, to_free);\n\t\treturn len;\n\t}\n\n\tif (d == 1) {\n\t\t/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */\n\t\tx = q->tail->next;\n\t\tslot = &q->slots[x];\n\t\tq->tail->next = slot->next;\n\t\tq->ht[slot->hash] = SFQ_EMPTY_SLOT;\n\t\tgoto drop;\n\t}\n\n\treturn 0;\n}\n\nInstruction:\nnet_sched: sch_sfq: fix a potential crash on gso_skb handling\n\nReturn the diff that fixes it:\n",1124 "reference": "@@ -310,7 +310,10 @@ static unsigned int sfq_drop(struct Qdisc *sch, struct sk_buff **to_free)\n \t\t/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */\n \t\tx = q->tail->next;\n \t\tslot = &q->slots[x];\n-\t\tq->tail->next = slot->next;\n+\t\tif (slot->next == x)\n+\t\t\tq->tail = NULL; /* no more active slots */\n+\t\telse\n+\t\t\tq->tail->next = slot->next;\n \t\tq->ht[slot->hash] = SFQ_EMPTY_SLOT;\n \t\tgoto drop;\n \t}",1125 "prediction": "Given the following original C code:\nslot->backlog -= len;\n\t\tsfq_dec(q, x);\n\t\tsch->q.qlen--;\n\t\tqdisc_qstats_backlog_dec(sch, skb);\n\t\tqdisc_drop(skb, sch, to_free);\n\t\treturn len;\n\t}\n\n\tif (d == 1) {\n\t\t/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */\n\t\tx = q->tail->next;\n\t\tslot = &q->slots[x];\n\t\tq->tail->next = slot->next;\n\t\tq->ht[slot->hash] = SFQ_EMPTY_SLOT;\n\t\tgoto drop;\n\t}\n\n\treturn 0;\n}\n\nInstruction:\nnet_sched: sch_sfq: fix a potential crash on gso_skb handling\n\nReturn the diff that fixes it:\n @@ -107,7 +107,7 @@ static int sfq_requeue(struct sk_buff *skb, struct Qdisc *sch)\n \tif (d == 1) {\n \t\t/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */\n \t\tx = q->tail->next;\n-\t\tslot = &q->slots[x];\n+\t\tslot = &q->slots[x - 1];\n \t\tq->tail->next = slot->next;\n \t\tq->ht[slot->hash] = SFQ_EMPTY_SLOT;\n \t\tgoto drop;\n@@ -115,7 +115,7 @@ static int sfq_requeue(struct sk_buff *skb, struct Qdisc *sch)\n \treturn 0;\n }\n \n-static struct sk_buff *sfq_dequeue(struct Qdisc *sch)\n+static struct sk_buff *sfq_dequeue(struct Q"1126 },1127 {1128 "prompt": "Given the following original C code:\nmodule_param(storvsc_vcpus_per_sub_channel, int, S_IRUGO);\nMODULE_PARM_DESC(storvsc_vcpus_per_sub_channel, \"Ratio of VCPUs to subchannels\");\n\nstatic int ring_avail_percent_lowater = 10;\nmodule_param(ring_avail_percent_lowater, int, S_IRUGO);\nMODULE_PARM_DESC(ring_avail_percent_lowater,\n\t\t\"Select a channel if available ring size > this in percent\");\n\n/*\n * Timeout in seconds for all devices managed by this driver.\n */\nstatic int storvsc_timeout = 180;\n\n#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)\nstatic struct scsi_transport_template *fc_transport_template;\n#endif\n\nstatic struct scsi_host_template scsi_driver;\nstatic void storvsc_on_channel_callback(void *context);\n\nInstruction:\nscsi: storvsc: Increase the timeouts to storvsc_timeout\n\nReturn the diff that fixes it:\n",1129 "reference": "@@ -362,7 +362,7 @@ MODULE_PARM_DESC(ring_avail_percent_lowater,\n /*\n * Timeout in seconds for all devices managed by this driver.\n */\n-static int storvsc_timeout = 180;\n+static const int storvsc_timeout = 180;\n \n #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)\n static struct scsi_transport_template *fc_transport_template;\n@@ -768,7 +768,7 @@ static void handle_multichannel_storage(struct hv_device *device, int max_chns)\n \t\treturn;\n \t}\n \n-\tt = wait_for_completion_timeout(&request->wait_event, 10*HZ);\n+\tt = wait_for_completion_timeout(&request->wait_event, storvsc_timeout * HZ);\n \tif (t == 0) {\n \t\tdev_err(dev, \"Failed to create sub-channel: timed out\\n\");\n \t\treturn;\n@@ -833,7 +833,7 @@ static int storvsc_execute_vstor_op(struct hv_device *device,\n \tif (ret != 0)\n \t\treturn ret;\n \n-\tt = wait_for_completion_timeout(&request->wait_event, 5*HZ);\n+\tt = wait_for_completion_timeout(&request->wait_event, storvsc_timeout * HZ);\n \tif (t == 0)\n \t\treturn -ETIMEDOUT;\n \n@@ -1350,6 +1350,8 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size,\n \t\treturn ret;\n \n \tret = storvsc_channel_init(device, is_fc);\n+\tif (ret)\n+\t\tvmbus_close(device->channel);\n \n \treturn ret;\n }\n@@ -1668,7 +1670,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)\n \tif (ret != 0)\n \t\treturn FAILED;\n \n-\tt = wait_for_completion_timeout(&request->wait_event, 5*HZ);\n+\tt = wait_for_completion_timeout(&request->wait_event, storvsc_timeout * HZ);\n \tif (t == 0)\n \t\treturn TIMEOUT_ERROR;",1130 "prediction": "Given the following original C code:\nmodule_param(storvsc_vcpus_per_sub_channel, int, S_IRUGO);\nMODULE_PARM_DESC(storvsc_vcpus_per_sub_channel, \"Ratio of VCPUs to subchannels\");\n\nstatic int ring_avail_percent_lowater = 10;\nmodule_param(ring_avail_percent_lowater, int, S_IRUGO);\nMODULE_PARM_DESC(ring_avail_percent_lowater,\n\t\t\"Select a channel if available ring size > this in percent\");\n\n/*\n * Timeout in seconds for all devices managed by this driver.\n */\nstatic int storvsc_timeout = 180;\n\n#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)\nstatic struct scsi_transport_template *fc_transport_template;\n#endif\n\nstatic struct scsi_host_template scsi_driver;\nstatic void storvsc_on_channel_callback(void *context);\n\nInstruction:\nscsi: storvsc: Increase the timeouts to storvsc_timeout\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ MODULE_PARM_DESC(ring_avail_percent_lowater,\n * Timeout in seconds for all devices managed by this driver.\n */\n static int storvsc_timeout = 180;\n-\n+static int storvsc_timeout_secs = 180;\n #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)\n static struct scsi_transport_template *fc_transport_template;\n #endif\n@@ -116,7 +116,7 @@ static struct scsi_host_template scsi_driver;\n static void storvsc_on_channel_callback(void *context);\n static void storvsc_on_event_callback(void *context);\n static void storvsc_on_io_completion(void *context);\n-static void storvsc_on_request_completion(void *context);\n+static void storvsc_on_request_completion(void *context,\n+"1131 },1132 {1133 "prompt": "Given the following original C code:\n/*\n\t\t * we might also expect a cc/ua if another LUN on the target\n\t\t * reported a UA with an ASC/ASCQ of 3F 0E -\n\t\t * REPORTED LUNS DATA HAS CHANGED.\n\t\t */\n\t\tif (scmd->device->sdev_target->expecting_lun_change &&\n\t\t sshdr.asc == 0x3f && sshdr.ascq == 0x0e)\n\t\t\treturn NEEDS_RETRY;\n\t\t/*\n\t\t * if the device is in the process of becoming ready, we\n\t\t * should retry.\n\t\t */\n\t\tif ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01))\n\t\t\treturn NEEDS_RETRY;\n\t\t/*\n\t\t * if the device is not started, we need to wake\n\t\t * the error handler to start the motor\n\t\t */\n\t\tif (scmd->device->allow_restart &&\n\t\t (sshdr.asc == 0x04) && (sshdr.ascq == 0x02))\n\nInstruction:\nscsi: error: alua: I/O errors for ALUA state transitions\n\nReturn the diff that fixes it:\n",1134 "reference": "@@ -665,7 +665,8 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)\n \t\t * if the device is in the process of becoming ready, we\n \t\t * should retry.\n \t\t */\n-\t\tif ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01))\n+\t\tif ((sshdr.asc == 0x04) &&\n+\t\t (sshdr.ascq == 0x01 || sshdr.ascq == 0x0a))\n \t\t\treturn NEEDS_RETRY;\n \t\t/*\n \t\t * if the device is not started, we need to wake",1135 "prediction": "Given the following original C code:\n/*\n\t\t * we might also expect a cc/ua if another LUN on the target\n\t\t * reported a UA with an ASC/ASCQ of 3F 0E -\n\t\t * REPORTED LUNS DATA HAS CHANGED.\n\t\t */\n\t\tif (scmd->device->sdev_target->expecting_lun_change &&\n\t\t sshdr.asc == 0x3f && sshdr.ascq == 0x0e)\n\t\t\treturn NEEDS_RETRY;\n\t\t/*\n\t\t * if the device is in the process of becoming ready, we\n\t\t * should retry.\n\t\t */\n\t\tif ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01))\n\t\t\treturn NEEDS_RETRY;\n\t\t/*\n\t\t * if the device is not started, we need to wake\n\t\t * the error handler to start the motor\n\t\t */\n\t\tif (scmd->device->allow_restart &&\n\t\t (sshdr.asc == 0x04) && (sshdr.ascq == 0x02))\n\nInstruction:\nscsi: error: alua: I/O errors for ALUA state transitions\n\nReturn the diff that fixes it:\n @@ -101,10 +101,10 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)\n \t\t * if the device is in the process of becoming ready, we\n \t\t * should retry.\n \t\t */\n-\t\tif ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01))\n+\t\tif ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01) &&\n+\t\t scmd->device->sdev_target->expecting_lun_change)\n \t\t\treturn NEEDS_RETRY;\n-\t\t/*\n-\t\t * if the device is not started, we need to wake\n-\t\t * the error handler to start the motor\n-\t\t */\n+\t\t/*\n+\t\t * if the device is not started, we need to wake\n+\t\t * the error handler to start the motor\n+\t\t */\n \t\tif (scmd"1136 },1137 {1138 "prompt": "Given the following original C code:\nstatic ssize_t memtrace_read(struct file *filp, char __user *ubuf,\n\t\t\t size_t count, loff_t *ppos)\n{\n\tstruct memtrace_entry *ent = filp->private_data;\n\n\treturn simple_read_from_buffer(ubuf, count, ppos, ent->mem, ent->size);\n}\n\nstatic int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)\n{\n\tstruct memtrace_entry *ent = filp->private_data;\n\n\tif (ent->size < vma->vm_end - vma->vm_start)\n\t\treturn -EINVAL;\n\n\tif (vma->vm_pgoff << PAGE_SHIFT >= ent->size)\n\t\treturn -EINVAL;\n\n\tvma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);\n\nInstruction:\npowerpc/powernv/memtrace: Fix out of bounds issue in memtrace mmap\n\nReturn the diff that fixes it:\n",1139 "reference": "@@ -48,11 +48,15 @@ static ssize_t memtrace_read(struct file *filp, char __user *ubuf,\n static int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)\n {\n \tstruct memtrace_entry *ent = filp->private_data;\n+\tunsigned long ent_nrpages = ent->size >> PAGE_SHIFT;\n+\tunsigned long vma_nrpages = vma_pages(vma);\n \n-\tif (ent->size < vma->vm_end - vma->vm_start)\n+\t/* The requested page offset should be within object's page count */\n+\tif (vma->vm_pgoff >= ent_nrpages)\n \t\treturn -EINVAL;\n \n-\tif (vma->vm_pgoff << PAGE_SHIFT >= ent->size)\n+\t/* The requested mapping range should remain within the bounds */\n+\tif (vma_nrpages > ent_nrpages - vma->vm_pgoff)\n \t\treturn -EINVAL;\n \n \tvma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);",1140 "prediction": "Given the following original C code:\nstatic ssize_t memtrace_read(struct file *filp, char __user *ubuf,\n\t\t\t size_t count, loff_t *ppos)\n{\n\tstruct memtrace_entry *ent = filp->private_data;\n\n\treturn simple_read_from_buffer(ubuf, count, ppos, ent->mem, ent->size);\n}\n\nstatic int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)\n{\n\tstruct memtrace_entry *ent = filp->private_data;\n\n\tif (ent->size < vma->vm_end - vma->vm_start)\n\t\treturn -EINVAL;\n\n\tif (vma->vm_pgoff << PAGE_SHIFT >= ent->size)\n\t\treturn -EINVAL;\n\n\tvma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);\n\nInstruction:\npowerpc/powernv/memtrace: Fix out of bounds issue in memtrace mmap\n\nReturn the diff that fixes it:\n @@ -106,10 +106,10 @@ static int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)\n {\n \tstruct memtrace_entry *ent = filp->private_data;\n \n-\tif (ent->size < vma->vm_end - vma->vm_start)\n+\tif (ent->size < vma->vm_end - vma->vm_start + 1)\n \t\treturn -EINVAL;\n \n-\tif (vma->vm_pgoff << PAGE_SHIFT >= ent->size)\n+\tif (vma->vm_pgoff << PAGE_SHIFT >= ent->size - 1)\n \t\treturn -EINVAL;\n \n \tvma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);\n@@ -118,7 +118,7 @@ static int memtrace_mmap(struct file *filp, struct vm_area"1141 },1142 {1143 "prompt": "Given the following original C code:\nu64 paste_addr;\n\tpgprot_t prot;\n\tint rc;\n\n\ttxwin = cp_inst->txwin;\n\n\tif ((vma->vm_end - vma->vm_start) > PAGE_SIZE) {\n\t\tpr_debug(\"size 0x%zx, PAGE_SIZE 0x%zx\\n\",\n\t\t\t\t(vma->vm_end - vma->vm_start), PAGE_SIZE);\n\t\treturn -EINVAL;\n\t}\n\n\t/* Ensure instance has an open send window */\n\tif (!txwin) {\n\t\tpr_err(\"No send window open?\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) {\n\t\tpr_err(\"VAS API is not registered\\n\");\n\nInstruction:\npowerpc/vas: Return -EINVAL if the offset is non-zero in mmap()\n\nReturn the diff that fixes it:\n",1144 "reference": "@@ -521,6 +521,15 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)\n \t\treturn -EINVAL;\n \t}\n \n+\t/*\n+\t * Map complete page to the paste address. So the user\n+\t * space should pass 0ULL to the offset parameter.\n+\t */\n+\tif (vma->vm_pgoff) {\n+\t\tpr_debug(\"Page offset unsupported to map paste address\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Ensure instance has an open send window */\n \tif (!txwin) {\n \t\tpr_err(\"No send window open?\\n\");",1145 "prediction": "Given the following original C code:\nu64 paste_addr;\n\tpgprot_t prot;\n\tint rc;\n\n\ttxwin = cp_inst->txwin;\n\n\tif ((vma->vm_end - vma->vm_start) > PAGE_SIZE) {\n\t\tpr_debug(\"size 0x%zx, PAGE_SIZE 0x%zx\\n\",\n\t\t\t\t(vma->vm_end - vma->vm_start), PAGE_SIZE);\n\t\treturn -EINVAL;\n\t}\n\n\t/* Ensure instance has an open send window */\n\tif (!txwin) {\n\t\tpr_err(\"No send window open?\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tif (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) {\n\t\tpr_err(\"VAS API is not registered\\n\");\n\nInstruction:\npowerpc/vas: Return -EINVAL if the offset is non-zero in mmap()\n\nReturn the diff that fixes it:\n @@ -100,6 +100,10 @@ static int cp_mmap(struct file *filp, struct vm_area_struct *vma)\n \t\treturn -EINVAL;\n \t}\n \n+\tif (vma->vm_pgoff) {\n+\t\tpr_err(\"Non-zero offset in mmap()\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Ensure instance has an open send window */\n \tif (!txwin) {\n \t\tpr_err(\"No send window open?\\n\");\n@@ -108,6 +112,10 @@ static int cp_mmap(struct file *filp, struct vm_area_struct *vma)\n \t\treturn -EINVAL;\n \t}\n \n+\tif (vma->vm_pgoff) {\n+\t\tpr_err(\"Non-zero offset in mmap()\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Ens"1146 },1147 {1148 "prompt": "Given the following original C code:\nSND_PCI_QUIRK(0x103c, 0x8e1a, \"HP ZBook Firefly 14 G12A\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1b, \"HP EliteBook G12\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1c, \"HP EliteBook G12\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1d, \"HP ZBook X Gli 16 G12\", ALC236_FIXUP_HP_GPIO_LED),\n\tSND_PCI_QUIRK(0x103c, 0x8e2c, \"HP EliteBook 16 G12\", ALC285_FIXUP_HP_GPIO_LED),\n\tSND_PCI_QUIRK(0x103c, 0x8e36, \"HP 14 Enstrom OmniBook X\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e37, \"HP 16 Piston OmniBook X\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e3a, \"HP Agusta\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e3b, \"HP Agusta\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e60, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e61, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e62, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x103e, \"ASUS X540SA\", ALC256_FIXUP_ASUS_MIC),\n\tSND_PCI_QUIRK(0x1043, 0x103f, \"ASUS TX300\", ALC282_FIXUP_ASUS_TX300),\n\tSND_PCI_QUIRK(0x1043, 0x1054, \"ASUS G614FH/FM/FP\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x106d, \"Asus K53BE\", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),\n\tSND_PCI_QUIRK(0x1043, 0x106f, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1074, \"ASUS G614PH/PM/PP\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x10a1, \"ASUS UX391UA\", ALC294_FIXUP_ASUS_SPK),\n\tSND_PCI_QUIRK(0x1043, 0x10a4, \"ASUS TP3407SA\", ALC287_FIXUP_TAS2781_I2C),\n\nInstruction:\nALSA: hda/realtek: Fix built-in mic on ASUS VivoBook X513EA\n\nReturn the diff that fixes it:\n",1149 "reference": "@@ -10906,6 +10906,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {\n \tSND_PCI_QUIRK(0x103c, 0x8e60, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n \tSND_PCI_QUIRK(0x103c, 0x8e61, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n \tSND_PCI_QUIRK(0x103c, 0x8e62, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n+\tSND_PCI_QUIRK(0x1043, 0x1032, \"ASUS VivoBook X513EA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n \tSND_PCI_QUIRK(0x1043, 0x103e, \"ASUS X540SA\", ALC256_FIXUP_ASUS_MIC),\n \tSND_PCI_QUIRK(0x1043, 0x103f, \"ASUS TX300\", ALC282_FIXUP_ASUS_TX300),\n \tSND_PCI_QUIRK(0x1043, 0x1054, \"ASUS G614FH/FM/FP\", ALC287_FIXUP_CS35L41_I2C_2),",1150 "prediction": "Given the following original C code:\nSND_PCI_QUIRK(0x103c, 0x8e1a, \"HP ZBook Firefly 14 G12A\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1b, \"HP EliteBook G12\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1c, \"HP EliteBook G12\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1d, \"HP ZBook X Gli 16 G12\", ALC236_FIXUP_HP_GPIO_LED),\n\tSND_PCI_QUIRK(0x103c, 0x8e2c, \"HP EliteBook 16 G12\", ALC285_FIXUP_HP_GPIO_LED),\n\tSND_PCI_QUIRK(0x103c, 0x8e36, \"HP 14 Enstrom OmniBook X\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e37, \"HP 16 Piston OmniBook X\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e3a, \"HP Agusta\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e3b, \"HP Agusta\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e60, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e61, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e62, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x103e, \"ASUS X540SA\", ALC256_FIXUP_ASUS_MIC),\n\tSND_PCI_QUIRK(0x1043, 0x103f, \"ASUS TX300\", ALC282_FIXUP_ASUS_TX300),\n\tSND_PCI_QUIRK(0x1043, 0x1054, \"ASUS G614FH/FM/FP\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x106d, \"Asus K53BE\", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),\n\tSND_PCI_QUIRK(0x1043, 0x106f, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1070, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1071, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1072, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1073, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0"1151 },1152 {1153 "prompt": "Given the following original C code:\nSND_PCI_QUIRK(0x103c, 0x8e1b, \"HP EliteBook G12\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1c, \"HP EliteBook G12\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1d, \"HP ZBook X Gli 16 G12\", ALC236_FIXUP_HP_GPIO_LED),\n\tSND_PCI_QUIRK(0x103c, 0x8e2c, \"HP EliteBook 16 G12\", ALC285_FIXUP_HP_GPIO_LED),\n\tSND_PCI_QUIRK(0x103c, 0x8e36, \"HP 14 Enstrom OmniBook X\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e37, \"HP 16 Piston OmniBook X\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e3a, \"HP Agusta\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e3b, \"HP Agusta\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e60, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e61, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e62, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x1032, \"ASUS VivoBook X513EA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x103e, \"ASUS X540SA\", ALC256_FIXUP_ASUS_MIC),\n\tSND_PCI_QUIRK(0x1043, 0x103f, \"ASUS TX300\", ALC282_FIXUP_ASUS_TX300),\n\tSND_PCI_QUIRK(0x1043, 0x1054, \"ASUS G614FH/FM/FP\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x106d, \"Asus K53BE\", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),\n\tSND_PCI_QUIRK(0x1043, 0x106f, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1074, \"ASUS G614PH/PM/PP\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x10a1, \"ASUS UX391UA\", ALC294_FIXUP_ASUS_SPK),\n\tSND_PCI_QUIRK(0x1043, 0x10a4, \"ASUS TP3407SA\", ALC287_FIXUP_TAS2781_I2C),\n\nInstruction:\nALSA: hda/realtek: Add quirk for Asus GU605C\n\nReturn the diff that fixes it:\n",1154 "reference": "@@ -10907,6 +10907,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {\n \tSND_PCI_QUIRK(0x103c, 0x8e61, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n \tSND_PCI_QUIRK(0x103c, 0x8e62, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n \tSND_PCI_QUIRK(0x1043, 0x1032, \"ASUS VivoBook X513EA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n+\tSND_PCI_QUIRK(0x1043, 0x1034, \"ASUS GU605C\", ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1),\n \tSND_PCI_QUIRK(0x1043, 0x103e, \"ASUS X540SA\", ALC256_FIXUP_ASUS_MIC),\n \tSND_PCI_QUIRK(0x1043, 0x103f, \"ASUS TX300\", ALC282_FIXUP_ASUS_TX300),\n \tSND_PCI_QUIRK(0x1043, 0x1054, \"ASUS G614FH/FM/FP\", ALC287_FIXUP_CS35L41_I2C_2),",1155 "prediction": "Given the following original C code:\nSND_PCI_QUIRK(0x103c, 0x8e1b, \"HP EliteBook G12\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1c, \"HP EliteBook G12\", ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A),\n\tSND_PCI_QUIRK(0x103c, 0x8e1d, \"HP ZBook X Gli 16 G12\", ALC236_FIXUP_HP_GPIO_LED),\n\tSND_PCI_QUIRK(0x103c, 0x8e2c, \"HP EliteBook 16 G12\", ALC285_FIXUP_HP_GPIO_LED),\n\tSND_PCI_QUIRK(0x103c, 0x8e36, \"HP 14 Enstrom OmniBook X\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e37, \"HP 16 Piston OmniBook X\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e3a, \"HP Agusta\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e3b, \"HP Agusta\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e60, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e61, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x103c, 0x8e62, \"HP Trekker \", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x1032, \"ASUS VivoBook X513EA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x103e, \"ASUS X540SA\", ALC256_FIXUP_ASUS_MIC),\n\tSND_PCI_QUIRK(0x1043, 0x103f, \"ASUS TX300\", ALC282_FIXUP_ASUS_TX300),\n\tSND_PCI_QUIRK(0x1043, 0x1054, \"ASUS G614FH/FM/FP\", ALC287_FIXUP_CS35L41_I2C_2),\n\tSND_PCI_QUIRK(0x1043, 0x106d, \"Asus K53BE\", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),\n\tSND_PCI_QUIRK(0x1043, 0x106f, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1070, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1071, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1072, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x1073, \"ASUS VivoBook X515UA\", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),\n\tSND_PCI_QUIRK(0x1043, 0x107"1156 },1157 {1158 "prompt": "Given the following original C code:\nucontrol->value.enumerated.item[0] = snd_sb16_get_dma_mode(chip);\n\tspin_unlock_irqrestore(&chip->reg_lock, flags);\n\treturn 0;\n}\n\nstatic int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)\n{\n\tstruct snd_sb *chip = snd_kcontrol_chip(kcontrol);\n\tunsigned long flags;\n\tunsigned char nval, oval;\n\tint change;\n\t\n\tnval = ucontrol->value.enumerated.item[0];\n\tif (nval > 2)\n\t\treturn -EINVAL;\n\tspin_lock_irqsave(&chip->reg_lock, flags);\n\toval = snd_sb16_get_dma_mode(chip);\n\tchange = nval != oval;\n\tsnd_sb16_set_dma_mode(chip, nval);\n\tspin_unlock_irqrestore(&chip->reg_lock, flags);\n\nInstruction:\nALSA: sb: Don't allow changing the DMA mode during operations\n\nReturn the diff that fixes it:\n",1159 "reference": "@@ -703,6 +703,9 @@ static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ct\n \tunsigned char nval, oval;\n \tint change;\n \t\n+\tif (chip->mode & (SB_MODE_PLAYBACK | SB_MODE_CAPTURE))\n+\t\treturn -EBUSY;\n+\n \tnval = ucontrol->value.enumerated.item[0];\n \tif (nval > 2)\n \t\treturn -EINVAL;",1160 "prediction": "Given the following original C code:\nucontrol->value.enumerated.item[0] = snd_sb16_get_dma_mode(chip);\n\tspin_unlock_irqrestore(&chip->reg_lock, flags);\n\treturn 0;\n}\n\nstatic int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)\n{\n\tstruct snd_sb *chip = snd_kcontrol_chip(kcontrol);\n\tunsigned long flags;\n\tunsigned char nval, oval;\n\tint change;\n\t\n\tnval = ucontrol->value.enumerated.item[0];\n\tif (nval > 2)\n\t\treturn -EINVAL;\n\tspin_lock_irqsave(&chip->reg_lock, flags);\n\toval = snd_sb16_get_dma_mode(chip);\n\tchange = nval != oval;\n\tsnd_sb16_set_dma_mode(chip, nval);\n\tspin_unlock_irqrestore(&chip->reg_lock, flags);\n\nInstruction:\nALSA: sb: Don't allow changing the DMA mode during operations\n\nReturn the diff that fixes it:\n @@ -101,7 +101,7 @@ static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_c\n \tunsigned char nval, oval;\n \tint change;\n \t\n-\tnval = ucontrol->value.enumerated.item[0];\n+\tnval = ucontrol->value.integer.value[0];\n \tif (nval > 2)\n \t\treturn -EINVAL;\n \tspin_lock_irqsave(&chip->reg_lock, flags);\n@@ -109,7 +109,7 @@ static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_c\n \tchange = nval != oval;\n \tsnd_sb16_set_dma_mode(chip, nval);\n \tspin_unlock_irqrestore(&chip->reg_lock, flags);\n-\tif (change"1161 },1162 {1163 "prompt": "Given the following original C code:\nif (chip->mode & (SB_MODE_PLAYBACK | SB_MODE_CAPTURE))\n\t\treturn -EBUSY;\n\n\tnval = ucontrol->value.enumerated.item[0];\n\tif (nval > 2)\n\t\treturn -EINVAL;\n\tspin_lock_irqsave(&chip->reg_lock, flags);\n\toval = snd_sb16_get_dma_mode(chip);\n\tchange = nval != oval;\n\tsnd_sb16_set_dma_mode(chip, nval);\n\tspin_unlock_irqrestore(&chip->reg_lock, flags);\n\treturn change;\n}\n\nstatic const struct snd_kcontrol_new snd_sb16_dma_control = {\n\t.iface = SNDRV_CTL_ELEM_IFACE_CARD,\n\t.name = \"16-bit DMA Allocation\",\n\t.info = snd_sb16_dma_control_info,\n\t.get = snd_sb16_dma_control_get,\n\nInstruction:\nALSA: sb: Force to disable DMAs once when DMA mode is changed\n\nReturn the diff that fixes it:\n",1164 "reference": "@@ -714,6 +714,10 @@ static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ct\n \tchange = nval != oval;\n \tsnd_sb16_set_dma_mode(chip, nval);\n \tspin_unlock_irqrestore(&chip->reg_lock, flags);\n+\tif (change) {\n+\t\tsnd_dma_disable(chip->dma8);\n+\t\tsnd_dma_disable(chip->dma16);\n+\t}\n \treturn change;\n }",1165 "prediction": "Given the following original C code:\nif (chip->mode & (SB_MODE_PLAYBACK | SB_MODE_CAPTURE))\n\t\treturn -EBUSY;\n\n\tnval = ucontrol->value.enumerated.item[0];\n\tif (nval > 2)\n\t\treturn -EINVAL;\n\tspin_lock_irqsave(&chip->reg_lock, flags);\n\toval = snd_sb16_get_dma_mode(chip);\n\tchange = nval != oval;\n\tsnd_sb16_set_dma_mode(chip, nval);\n\tspin_unlock_irqrestore(&chip->reg_lock, flags);\n\treturn change;\n}\n\nstatic const struct snd_kcontrol_new snd_sb16_dma_control = {\n\t.iface = SNDRV_CTL_ELEM_IFACE_CARD,\n\t.name = \"16-bit DMA Allocation\",\n\t.info = snd_sb16_dma_control_info,\n\t.get = snd_sb16_dma_control_get,\n\nInstruction:\nALSA: sb: Force to disable DMAs once when DMA mode is changed\n\nReturn the diff that fixes it:\n @@ -107,6 +107,10 @@ static int snd_sb16_dma_control_get(struct snd_kcontrol *kcontrol,\n \tsnd_sb16_set_dma_mode(chip, nval);\n \tspin_unlock_irqrestore(&chip->reg_lock, flags);\n \treturn change;\n+\n+\t/* Force to disable DMAs once when DMA mode is changed */\n+\tif (change)\n+\t\tsnd_sb16_dma_disable(chip);\n }\n \n static const struct snd_kcontrol_new snd_sb16_dma_control = {\n@@ -115,6 +119,10 @@ static const struct snd_kcontrol_new snd_sb16_dma_control = {\n \t.info = snd_sb16_dma_control_info,\n \t.get = snd_sb16_dma_control_get,\n \t.put ="1166 },1167 {1168 "prompt": "Given the following original C code:\ncase AMD_CPU_ID_PS:\n\t\tcase AMD_CPU_ID_RMB:\n\t\t\tdev->mtable_size = sizeof(dev->m_table);\n\t\t\tbreak;\n\t\tcase PCI_DEVICE_ID_AMD_1AH_M20H_ROOT:\n\t\tcase PCI_DEVICE_ID_AMD_1AH_M60H_ROOT:\n\t\t\tdev->mtable_size = sizeof(dev->m_table_v2);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tdev_err(dev->dev, \"Invalid CPU id: 0x%x\", dev->cpu_id);\n\t\t}\n\n\t\tdev->buf = kzalloc(dev->mtable_size, GFP_KERNEL);\n\t\tif (!dev->buf)\n\t\t\treturn -ENOMEM;\n\t}\n\n\tphys_addr = virt_to_phys(dev->buf);\n\thi = phys_addr >> 32;\n\tlow = phys_addr & GENMASK(31, 0);\n\nInstruction:\nplatform/x86/amd: pmf: Use device managed allocations\n\nReturn the diff that fixes it:\n",1169 "reference": "@@ -280,7 +280,7 @@ int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer)\n \t\t\tdev_err(dev->dev, \"Invalid CPU id: 0x%x\", dev->cpu_id);\n \t\t}\n \n-\t\tdev->buf = kzalloc(dev->mtable_size, GFP_KERNEL);\n+\t\tdev->buf = devm_kzalloc(dev->dev, dev->mtable_size, GFP_KERNEL);\n \t\tif (!dev->buf)\n \t\t\treturn -ENOMEM;\n \t}\n@@ -493,7 +493,6 @@ static void amd_pmf_remove(struct platform_device *pdev)\n \tmutex_destroy(&dev->lock);\n \tmutex_destroy(&dev->update_mutex);\n \tmutex_destroy(&dev->cb_mutex);\n-\tkfree(dev->buf);\n }\n \n static const struct attribute_group *amd_pmf_driver_groups[] = {",1170 "prediction": "Given the following original C code:\ncase AMD_CPU_ID_PS:\n\t\tcase AMD_CPU_ID_RMB:\n\t\t\tdev->mtable_size = sizeof(dev->m_table);\n\t\t\tbreak;\n\t\tcase PCI_DEVICE_ID_AMD_1AH_M20H_ROOT:\n\t\tcase PCI_DEVICE_ID_AMD_1AH_M60H_ROOT:\n\t\t\tdev->mtable_size = sizeof(dev->m_table_v2);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tdev_err(dev->dev, \"Invalid CPU id: 0x%x\", dev->cpu_id);\n\t\t}\n\n\t\tdev->buf = kzalloc(dev->mtable_size, GFP_KERNEL);\n\t\tif (!dev->buf)\n\t\t\treturn -ENOMEM;\n\t}\n\n\tphys_addr = virt_to_phys(dev->buf);\n\thi = phys_addr >> 32;\n\tlow = phys_addr & GENMASK(31, 0);\n\nInstruction:\nplatform/x86/amd: pmf: Use device managed allocations\n\nReturn the diff that fixes it:\n @@ -108,10 +108,10 @@ static int amd_iommu_init_msi(struct amd_iommu *dev)\n \t\t\tdev_err(dev->dev, \"Invalid CPU id: 0x%x\", dev->cpu_id);\n \t\t}\n \n-\t\tdev->buf = kzalloc(dev->mtable_size, GFP_KERNEL);\n+\t\tdev->buf = dma_alloc_coherent(dev->dev, dev->mtable_size,\n+\t\t\t\t\t &dev->buf_phys, GFP_KERNEL);\n \t\tif (!dev->buf)\n \t\t\treturn -ENOMEM;\n \t}\n \n-\tphys_addr = virt_to_phys(dev->buf);\n+\tphys_addr = dev->buf_phys;\n \thi = phys_addr >> 32;\n \tlow = phys_addr & GENMASK(31, 0);\n \n@@ -119,"1171 },1172 {1173 "prompt": "Given the following original C code:\nstatic ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,\n\t\t\t\t size_t length, loff_t *pos)\n{\n\tstruct amd_pmf_dev *dev = filp->private_data;\n\tunsigned char *new_policy_buf;\n\tint ret;\n\n\t/* Policy binary size cannot exceed POLICY_BUF_MAX_SZ */\n\tif (length > POLICY_BUF_MAX_SZ || length == 0)\n\t\treturn -EINVAL;\n\n\t/* re-alloc to the new buffer length of the policy binary */\n\tnew_policy_buf = memdup_user(buf, length);\n\tif (IS_ERR(new_policy_buf))\n\t\treturn PTR_ERR(new_policy_buf);\n\n\tkfree(dev->policy_buf);\n\tdev->policy_buf = new_policy_buf;\n\tdev->policy_sz = length;\n\nInstruction:\nplatform/x86/amd: pmf: Use device managed allocations\n\nReturn the diff that fixes it:\n",1174 "reference": "@@ -358,30 +358,28 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,\n \t\treturn -EINVAL;\n \n \t/* re-alloc to the new buffer length of the policy binary */\n-\tnew_policy_buf = memdup_user(buf, length);\n-\tif (IS_ERR(new_policy_buf))\n-\t\treturn PTR_ERR(new_policy_buf);\n+\tnew_policy_buf = devm_kzalloc(dev->dev, length, GFP_KERNEL);\n+\tif (!new_policy_buf)\n+\t\treturn -ENOMEM;\n+\n+\tif (copy_from_user(new_policy_buf, buf, length)) {\n+\t\tdevm_kfree(dev->dev, new_policy_buf);\n+\t\treturn -EFAULT;\n+\t}\n \n-\tkfree(dev->policy_buf);\n+\tdevm_kfree(dev->dev, dev->policy_buf);\n \tdev->policy_buf = new_policy_buf;\n \tdev->policy_sz = length;\n \n-\tif (!amd_pmf_pb_valid(dev)) {\n-\t\tret = -EINVAL;\n-\t\tgoto cleanup;\n-\t}\n+\tif (!amd_pmf_pb_valid(dev))\n+\t\treturn -EINVAL;\n \n \tamd_pmf_hex_dump_pb(dev);\n \tret = amd_pmf_start_policy_engine(dev);\n \tif (ret < 0)\n-\t\tgoto cleanup;\n+\t\treturn ret;\n \n \treturn length;\n-\n-cleanup:\n-\tkfree(dev->policy_buf);\n-\tdev->policy_buf = NULL;\n-\treturn ret;\n }\n \n static const struct file_operations pb_fops = {\n@@ -532,13 +530,13 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \tdev->policy_base = devm_ioremap_resource(dev->dev, dev->res);\n \tif (IS_ERR(dev->policy_base)) {\n \t\tret = PTR_ERR(dev->policy_base);\n-\t\tgoto err_free_dram_buf;\n+\t\tgoto err_cancel_work;\n \t}\n \n-\tdev->policy_buf = kzalloc(dev->policy_sz, GFP_KERNEL);\n+\tdev->policy_buf = devm_kzalloc(dev->dev, dev->policy_sz, GFP_KERNEL);\n \tif (!dev->policy_buf) {\n \t\tret = -ENOMEM;\n-\t\tgoto err_free_dram_buf;\n+\t\tgoto err_cancel_work;\n \t}\n \n \tmemcpy_fromio(dev->policy_buf, dev->policy_base, dev->policy_sz);\n@@ -546,21 +544,21 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \tif (!amd_pmf_pb_valid(dev)) {\n \t\tdev_info(dev->dev, \"No Smart PC policy present\\n\");\n \t\tret = -EINVAL;\n-\t\tgoto err_free_policy;\n+\t\tgoto err_cancel_work;\n \t}\n \n \tamd_pmf_hex_dump_pb(dev);\n \n-\tdev->prev_data = kzalloc(sizeof(*dev->prev_data), GFP_KERNEL);\n+\tdev->prev_data = devm_kzalloc(dev->dev, sizeof(*dev->prev_data), GFP_KERNEL);\n \tif (!dev->prev_data) {\n \t\tret = -ENOMEM;\n-\t\tgoto err_free_policy;\n+\t\tgoto err_cancel_work;\n \t}\n \n \tfor (i = 0; i < ARRAY_SIZE(amd_pmf_ta_uuid); i++) {\n \t\tret = amd_pmf_tee_init(dev, &amd_pmf_ta_uuid[i]);\n \t\tif (ret)\n-\t\t\tgoto err_free_prev_data;\n+\t\t\tgoto err_cancel_work;\n \n \t\tret = amd_pmf_start_policy_engine(dev);\n \t\tswitch (ret) {\n@@ -575,7 +573,7 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \t\tdefault:\n \t\t\tret = -EINVAL;\n \t\t\tamd_pmf_tee_deinit(dev);\n-\t\t\tgoto err_free_prev_data;\n+\t\t\tgoto err_cancel_work;\n \t\t}\n \n \t\tif (status)\n@@ -584,7 +582,7 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \n \tif (!status && !pb_side_load) {\n \t\tret = -EINVAL;\n-\t\tgoto err_free_prev_data;\n+\t\tgoto err_cancel_work;\n \t}\n \n \tif (pb_side_load)\n@@ -600,12 +598,6 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \tif (pb_side_load && dev->esbin)\n \t\tamd_pmf_remove_pb(dev);\n \tamd_pmf_tee_deinit(dev);\n-err_free_prev_data:\n-\tkfree(dev->prev_data);\n-err_free_policy:\n-\tkfree(dev->policy_buf);\n-err_free_dram_buf:\n-\tkfree(dev->buf);\n err_cancel_work:\n \tcancel_delayed_work_sync(&dev->pb_work);\n \n@@ -621,11 +613,5 @@ void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev)\n \t\tamd_pmf_remove_pb(dev);\n \n \tcancel_delayed_work_sync(&dev->pb_work);\n-\tkfree(dev->prev_data);\n-\tdev->prev_data = NULL;\n-\tkfree(dev->policy_buf);\n-\tdev->policy_buf = NULL;\n-\tkfree(dev->buf);\n-\tdev->buf = NULL;\n \tamd_pmf_tee_deinit(dev);\n }",1175 "prediction": "Given the following original C code:\nstatic ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,\n\t\t\t\t size_t length, loff_t *pos)\n{\n\tstruct amd_pmf_dev *dev = filp->private_data;\n\tunsigned char *new_policy_buf;\n\tint ret;\n\n\t/* Policy binary size cannot exceed POLICY_BUF_MAX_SZ */\n\tif (length > POLICY_BUF_MAX_SZ || length == 0)\n\t\treturn -EINVAL;\n\n\t/* re-alloc to the new buffer length of the policy binary */\n\tnew_policy_buf = memdup_user(buf, length);\n\tif (IS_ERR(new_policy_buf))\n\t\treturn PTR_ERR(new_policy_buf);\n\n\tkfree(dev->policy_buf);\n\tdev->policy_buf = new_policy_buf;\n\tdev->policy_sz = length;\n\nInstruction:\nplatform/x86/amd: pmf: Use device managed allocations\n\nReturn the diff that fixes it:\n @@ -100,10 +100,10 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,\n \tif (length > POLICY_BUF_MAX_SZ || length == 0)\n \t\treturn -EINVAL;\n \n-\t/* re-alloc to the new buffer length of the policy binary */\n-\tnew_policy_buf = memdup_user(buf, length);\n-\tif (IS_ERR(new_policy_buf))\n-\t\treturn PTR_ERR(new_policy_buf);\n+\tnew_policy_buf = kzalloc(length, GFP_KERNEL);\n+\tif (!new_policy_buf)\n+\t\treturn -ENOMEM;\n \n-\tkfree(dev->policy_buf);\n+\tkfree(dev->policy_buf);\n \tdev->policy_buf = new_policy_buf;\n \tdev->policy_sz = length;\n \n@@ -11"1176 },1177 {1178 "prompt": "Given the following original C code:\nstatic int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_t *uuid)\n{\n\tstruct tee_ioctl_open_session_arg sess_arg = {};\n\tint rc;\n\n\texport_uuid(sess_arg.uuid, uuid);\n\tsess_arg.clnt_login = TEE_IOCTL_LOGIN_PUBLIC;\n\tsess_arg.num_params = 0;\n\n\trc = tee_client_open_session(ctx, &sess_arg, NULL);\n\tif (rc < 0 || sess_arg.ret != 0) {\n\t\tpr_err(\"Failed to open TEE session err:%#x, rc:%d\\n\", sess_arg.ret, rc);\n\t\treturn rc;\n\t}\n\n\t*id = sess_arg.session;\n\n\treturn rc;\n}\n\nInstruction:\nplatform/x86/amd: pmf: Prevent amd_pmf_tee_deinit() from running twice\n\nReturn the diff that fixes it:\n",1179 "reference": "@@ -420,12 +420,12 @@ static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_\n \trc = tee_client_open_session(ctx, &sess_arg, NULL);\n \tif (rc < 0 || sess_arg.ret != 0) {\n \t\tpr_err(\"Failed to open TEE session err:%#x, rc:%d\\n\", sess_arg.ret, rc);\n-\t\treturn rc;\n+\t\treturn rc ?: -EINVAL;\n \t}\n \n \t*id = sess_arg.session;\n \n-\treturn rc;\n+\treturn 0;\n }\n \n static int amd_pmf_register_input_device(struct amd_pmf_dev *dev)\n@@ -460,7 +460,9 @@ static int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid)\n \tdev->tee_ctx = tee_client_open_context(NULL, amd_pmf_amdtee_ta_match, NULL, NULL);\n \tif (IS_ERR(dev->tee_ctx)) {\n \t\tdev_err(dev->dev, \"Failed to open TEE context\\n\");\n-\t\treturn PTR_ERR(dev->tee_ctx);\n+\t\tret = PTR_ERR(dev->tee_ctx);\n+\t\tdev->tee_ctx = NULL;\n+\t\treturn ret;\n \t}\n \n \tret = amd_pmf_ta_open_session(dev->tee_ctx, &dev->session_id, uuid);\n@@ -500,9 +502,12 @@ static int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid)\n \n static void amd_pmf_tee_deinit(struct amd_pmf_dev *dev)\n {\n+\tif (!dev->tee_ctx)\n+\t\treturn;\n \ttee_shm_free(dev->fw_shm_pool);\n \ttee_client_close_session(dev->tee_ctx, dev->session_id);\n \ttee_client_close_context(dev->tee_ctx);\n+\tdev->tee_ctx = NULL;\n }\n \n int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)",1180 "prediction": "Given the following original C code:\nstatic int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_t *uuid)\n{\n\tstruct tee_ioctl_open_session_arg sess_arg = {};\n\tint rc;\n\n\texport_uuid(sess_arg.uuid, uuid);\n\tsess_arg.clnt_login = TEE_IOCTL_LOGIN_PUBLIC;\n\tsess_arg.num_params = 0;\n\n\trc = tee_client_open_session(ctx, &sess_arg, NULL);\n\tif (rc < 0 || sess_arg.ret != 0) {\n\t\tpr_err(\"Failed to open TEE session err:%#x, rc:%d\\n\", sess_arg.ret, rc);\n\t\treturn rc;\n\t}\n\n\t*id = sess_arg.session;\n\n\treturn rc;\n}\n\nInstruction:\nplatform/x86/amd: pmf: Prevent amd_pmf_tee_deinit() from running twice\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_t\n \trc = tee_client_open_session(ctx, &sess_arg, NULL);\n \tif (rc < 0 || sess_arg.ret != 0) {\n \t\tpr_err(\"Failed to open TEE session err:%#x, rc:%d\\n\", sess_arg.ret, rc);\n-\t\treturn rc;\n+\t\treturn -EINVAL;\n \t}\n \n \t*id = sess_arg.session;\n \n@@ -116,7 +116,7 @@ static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_t\n \treturn rc;\n }\n \n-static void amd_pmf_tee_deinit(void)\n+static void amd_pmf_te"1181 },1182 {1183 "prompt": "Given the following original C code:\n* Lets not return from here if Smart PC bit is not advertised in\n\t\t * the BIOS. This way, there will be some amount of power savings\n\t\t * to the user with static slider (if enabled).\n\t\t */\n\t\tdev_info(dev->dev, \"PMF Smart PC not advertised in BIOS!:%d\\n\", ret);\n\t\treturn -ENODEV;\n\t}\n\n\tINIT_DELAYED_WORK(&dev->pb_work, amd_pmf_invoke_cmd);\n\n\tret = amd_pmf_set_dram_addr(dev, true);\n\tif (ret)\n\t\tgoto err_cancel_work;\n\n\tdev->policy_base = devm_ioremap_resource(dev->dev, dev->res);\n\tif (IS_ERR(dev->policy_base)) {\n\t\tret = PTR_ERR(dev->policy_base);\n\t\tgoto err_cancel_work;\n\t}\n\nInstruction:\nplatform/x86/amd: pmf: Simplify error flow in amd_pmf_init_smart_pc()\n\nReturn the diff that fixes it:\n",1184 "reference": "@@ -530,64 +530,45 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \n \tret = amd_pmf_set_dram_addr(dev, true);\n \tif (ret)\n-\t\tgoto err_cancel_work;\n+\t\treturn ret;\n \n \tdev->policy_base = devm_ioremap_resource(dev->dev, dev->res);\n-\tif (IS_ERR(dev->policy_base)) {\n-\t\tret = PTR_ERR(dev->policy_base);\n-\t\tgoto err_cancel_work;\n-\t}\n+\tif (IS_ERR(dev->policy_base))\n+\t\treturn PTR_ERR(dev->policy_base);\n \n \tdev->policy_buf = devm_kzalloc(dev->dev, dev->policy_sz, GFP_KERNEL);\n-\tif (!dev->policy_buf) {\n-\t\tret = -ENOMEM;\n-\t\tgoto err_cancel_work;\n-\t}\n+\tif (!dev->policy_buf)\n+\t\treturn -ENOMEM;\n \n \tmemcpy_fromio(dev->policy_buf, dev->policy_base, dev->policy_sz);\n \n \tif (!amd_pmf_pb_valid(dev)) {\n \t\tdev_info(dev->dev, \"No Smart PC policy present\\n\");\n-\t\tret = -EINVAL;\n-\t\tgoto err_cancel_work;\n+\t\treturn -EINVAL;\n \t}\n \n \tamd_pmf_hex_dump_pb(dev);\n \n \tdev->prev_data = devm_kzalloc(dev->dev, sizeof(*dev->prev_data), GFP_KERNEL);\n-\tif (!dev->prev_data) {\n-\t\tret = -ENOMEM;\n-\t\tgoto err_cancel_work;\n-\t}\n+\tif (!dev->prev_data)\n+\t\treturn -ENOMEM;\n \n \tfor (i = 0; i < ARRAY_SIZE(amd_pmf_ta_uuid); i++) {\n \t\tret = amd_pmf_tee_init(dev, &amd_pmf_ta_uuid[i]);\n \t\tif (ret)\n-\t\t\tgoto err_cancel_work;\n+\t\t\treturn ret;\n \n \t\tret = amd_pmf_start_policy_engine(dev);\n-\t\tswitch (ret) {\n-\t\tcase TA_PMF_TYPE_SUCCESS:\n-\t\t\tstatus = true;\n-\t\t\tbreak;\n-\t\tcase TA_ERROR_CRYPTO_INVALID_PARAM:\n-\t\tcase TA_ERROR_CRYPTO_BIN_TOO_LARGE:\n-\t\t\tamd_pmf_tee_deinit(dev);\n-\t\t\tstatus = false;\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tret = -EINVAL;\n-\t\t\tamd_pmf_tee_deinit(dev);\n-\t\t\tgoto err_cancel_work;\n-\t\t}\n-\n+\t\tdev_dbg(dev->dev, \"start policy engine ret: %d\\n\", ret);\n+\t\tstatus = ret == TA_PMF_TYPE_SUCCESS;\n \t\tif (status)\n \t\t\tbreak;\n+\t\tamd_pmf_tee_deinit(dev);\n \t}\n \n \tif (!status && !pb_side_load) {\n \t\tret = -EINVAL;\n-\t\tgoto err_cancel_work;\n+\t\tgoto err;\n \t}\n \n \tif (pb_side_load)\n@@ -595,16 +576,12 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \n \tret = amd_pmf_register_input_device(dev);\n \tif (ret)\n-\t\tgoto err_pmf_remove_pb;\n+\t\tgoto err;\n \n \treturn 0;\n \n-err_pmf_remove_pb:\n-\tif (pb_side_load && dev->esbin)\n-\t\tamd_pmf_remove_pb(dev);\n-\tamd_pmf_tee_deinit(dev);\n-err_cancel_work:\n-\tcancel_delayed_work_sync(&dev->pb_work);\n+err:\n+\tamd_pmf_deinit_smart_pc(dev);\n \n \treturn ret;\n }",1185 "prediction": "Given the following original C code:\n* Lets not return from here if Smart PC bit is not advertised in\n\t\t * the BIOS. This way, there will be some amount of power savings\n\t\t * to the user with static slider (if enabled).\n\t\t */\n\t\tdev_info(dev->dev, \"PMF Smart PC not advertised in BIOS!:%d\\n\", ret);\n\t\treturn -ENODEV;\n\t}\n\n\tINIT_DELAYED_WORK(&dev->pb_work, amd_pmf_invoke_cmd);\n\n\tret = amd_pmf_set_dram_addr(dev, true);\n\tif (ret)\n\t\tgoto err_cancel_work;\n\n\tdev->policy_base = devm_ioremap_resource(dev->dev, dev->res);\n\tif (IS_ERR(dev->policy_base)) {\n\t\tret = PTR_ERR(dev->policy_base);\n\t\tgoto err_cancel_work;\n\t}\n\nInstruction:\nplatform/x86/amd: pmf: Simplify error flow in amd_pmf_init_smart_pc()\n\nReturn the diff that fixes it:\n @@ -108,11 +108,10 @@ static int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \n \tret = amd_pmf_set_dram_addr(dev, true);\n \tif (ret)\n-\t\tgoto err_cancel_work;\n+\t\treturn ret;\n \n \tdev->policy_base = devm_ioremap_resource(dev->dev, dev->res);\n \tif (IS_ERR(dev->policy_base)) {\n \t\tret = PTR_ERR(dev->policy_base);\n-\t\tgoto err_cancel_work;\n+\t\treturn ret;\n \t}\n \n \tret = amd_pmf_set_dram_addr(dev, false);\n@@ -119,11 +118,10 @@ static int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)\n \tif (ret)"1186 },1187 {1188 "prompt": "Given the following original C code:\nstatic struct platform_device *rbu_device;\nstatic int context;\n\nstatic void init_packet_head(void)\n{\n\tINIT_LIST_HEAD(&packet_data_head.list);\n\trbu_data.packet_read_count = 0;\n\trbu_data.num_packets = 0;\n\trbu_data.packetsize = 0;\n\trbu_data.imagesize = 0;\n}\n\nstatic int create_packet(void *data, size_t length)\n{\n\tstruct packet_data *newpacket;\n\tint ordernum = 0;\n\tint retval = 0;\n\tunsigned int packet_array_size = 0;\n\tvoid **invalid_addr_packet_array = NULL;\n\tvoid *packet_data_temp_buf = NULL;\n\nInstruction:\nplatform/x86: dell_rbu: Fix lock context warning\n\nReturn the diff that fixes it:\n",1189 "reference": "@@ -91,7 +91,7 @@ static void init_packet_head(void)\n \trbu_data.imagesize = 0;\n }\n \n-static int create_packet(void *data, size_t length)\n+static int create_packet(void *data, size_t length) __must_hold(&rbu_data.lock)\n {\n \tstruct packet_data *newpacket;\n \tint ordernum = 0;",1190 "prediction": "Given the following original C code:\nstatic struct platform_device *rbu_device;\nstatic int context;\n\nstatic void init_packet_head(void)\n{\n\tINIT_LIST_HEAD(&packet_data_head.list);\n\trbu_data.packet_read_count = 0;\n\trbu_data.num_packets = 0;\n\trbu_data.packetsize = 0;\n\trbu_data.imagesize = 0;\n}\n\nstatic int create_packet(void *data, size_t length)\n{\n\tstruct packet_data *newpacket;\n\tint ordernum = 0;\n\tint retval = 0;\n\tunsigned int packet_array_size = 0;\n\tvoid **invalid_addr_packet_array = NULL;\n\tvoid *packet_data_temp_buf = NULL;\n\nInstruction:\nplatform/x86: dell_rbu: Fix lock context warning\n\nReturn the diff that fixes it:\n @@ -104,6 +104,7 @@ static void init_packet_head(void)\n \trbu_data.packetsize = 0;\n \trbu_data.imagesize = 0;\n }\n+static DEFINE_SPINLOCK(rbu_lock);\n \n static int create_packet(void *data, size_t length)\n {\n@@ -114,7 +115,7 @@ static int create_packet(void *data, size_t length)\n \n \tnewpacket = kzalloc(sizeof(struct packet_data), GFP_KERNEL);\n \tif (!newpacket) {\n-\t\tprintk(KERN_ERR \"RBU: create_packet: kzalloc failed\\n\");\n+\t\tprintk(KERN_ERR \"RBU: create_packet: kzalloc failed\\n\");\n \t\tretval = -ENOMEM;\n \t\tgoto create_packet_exit;\n \t}\n@@ -12"1191 },1192 {1193 "prompt": "Given the following original C code:\nint bytes_copied = 0;\n\tint bytes_read = 0;\n\tint remaining_bytes = 0;\n\tchar *pdest = data;\n\n\t/* check if we have any packets */\n\tif (0 == rbu_data.num_packets)\n\t\treturn -ENOMEM;\n\n\tremaining_bytes = *pread_length;\n\tbytes_read = rbu_data.packet_read_count;\n\n\tlist_for_each_entry(newpacket, (&packet_data_head.list)->next, list) {\n\t\tbytes_copied = do_packet_read(pdest, newpacket,\n\t\t\tremaining_bytes, bytes_read, &temp_count);\n\t\tremaining_bytes -= bytes_copied;\n\t\tbytes_read += bytes_copied;\n\t\tpdest += bytes_copied;\n\t\t/*\n\t\t * check if we reached end of buffer before reaching the\n\nInstruction:\nplatform/x86: dell_rbu: Fix list usage\n\nReturn the diff that fixes it:\n",1194 "reference": "@@ -292,7 +292,7 @@ static int packet_read_list(char *data, size_t * pread_length)\n \tremaining_bytes = *pread_length;\n \tbytes_read = rbu_data.packet_read_count;\n \n-\tlist_for_each_entry(newpacket, (&packet_data_head.list)->next, list) {\n+\tlist_for_each_entry(newpacket, &packet_data_head.list, list) {\n \t\tbytes_copied = do_packet_read(pdest, newpacket,\n \t\t\tremaining_bytes, bytes_read, &temp_count);\n \t\tremaining_bytes -= bytes_copied;\n@@ -315,7 +315,7 @@ static void packet_empty_list(void)\n {\n \tstruct packet_data *newpacket, *tmp;\n \n-\tlist_for_each_entry_safe(newpacket, tmp, (&packet_data_head.list)->next, list) {\n+\tlist_for_each_entry_safe(newpacket, tmp, &packet_data_head.list, list) {\n \t\tlist_del(&newpacket->list);\n \n \t\t/*",1195 "prediction": "Given the following original C code:\nint bytes_copied = 0;\n\tint bytes_read = 0;\n\tint remaining_bytes = 0;\n\tchar *pdest = data;\n\n\t/* check if we have any packets */\n\tif (0 == rbu_data.num_packets)\n\t\treturn -ENOMEM;\n\n\tremaining_bytes = *pread_length;\n\tbytes_read = rbu_data.packet_read_count;\n\n\tlist_for_each_entry(newpacket, (&packet_data_head.list)->next, list) {\n\t\tbytes_copied = do_packet_read(pdest, newpacket,\n\t\t\tremaining_bytes, bytes_read, &temp_count);\n\t\tremaining_bytes -= bytes_copied;\n\t\tbytes_read += bytes_copied;\n\t\tpdest += bytes_copied;\n\t\t/*\n\t\t * check if we reached end of buffer before reaching the\n\nInstruction:\nplatform/x86: dell_rbu: Fix list usage\n\nReturn the diff that fixes it:\n @@ -103,7 +103,7 @@ static int do_packet_read(char *data, struct packet_data *newpacket,\n \tremaining_bytes = *pread_length;\n \tbytes_read = rbu_data.packet_read_count;\n \n-\tlist_for_each_entry(newpacket, (&packet_data_head.list)->next, list) {\n+\tlist_for_each_entry(newpacket, &packet_data_head.list, list) {\n \t\tbytes_copied = do_packet_read(pdest, newpacket,\n \t\t\tremaining_bytes, bytes_read, &temp_count);\n \t\tremaining_bytes -= bytes_copied;\n@@ -111,7 +111,7 @@ static int do_packet_read(char *data, struct packet_data *newpacket,\n \t\t * end of buffer\n \t\t */\n \t\tif (0 == remaining_bytes)\n-"1196 },1197 {1198 "prompt": "Given the following original C code:\nstatic void packet_empty_list(void)\n{\n\tstruct packet_data *newpacket, *tmp;\n\n\tlist_for_each_entry_safe(newpacket, tmp, &packet_data_head.list, list) {\n\t\tlist_del(&newpacket->list);\n\n\t\t/*\n\t\t * zero out the RBU packet memory before freeing\n\t\t * to make sure there are no stale RBU packets left in memory\n\t\t */\n\t\tmemset(newpacket->data, 0, rbu_data.packetsize);\n\t\tset_memory_wb((unsigned long)newpacket->data,\n\t\t\t1 << newpacket->ordernum);\n\t\tfree_pages((unsigned long) newpacket->data,\n\t\t\tnewpacket->ordernum);\n\t\tkfree(newpacket);\n\t}\n\trbu_data.packet_read_count = 0;\n\nInstruction:\nplatform/x86: dell_rbu: Stop overwriting data buffer\n\nReturn the diff that fixes it:\n",1199 "reference": "@@ -322,7 +322,7 @@ static void packet_empty_list(void)\n \t\t * zero out the RBU packet memory before freeing\n \t\t * to make sure there are no stale RBU packets left in memory\n \t\t */\n-\t\tmemset(newpacket->data, 0, rbu_data.packetsize);\n+\t\tmemset(newpacket->data, 0, newpacket->length);\n \t\tset_memory_wb((unsigned long)newpacket->data,\n \t\t\t1 << newpacket->ordernum);\n \t\tfree_pages((unsigned long) newpacket->data,",1200 "prediction": "Given the following original C code:\nstatic void packet_empty_list(void)\n{\n\tstruct packet_data *newpacket, *tmp;\n\n\tlist_for_each_entry_safe(newpacket, tmp, &packet_data_head.list, list) {\n\t\tlist_del(&newpacket->list);\n\n\t\t/*\n\t\t * zero out the RBU packet memory before freeing\n\t\t * to make sure there are no stale RBU packets left in memory\n\t\t */\n\t\tmemset(newpacket->data, 0, rbu_data.packetsize);\n\t\tset_memory_wb((unsigned long)newpacket->data,\n\t\t\t1 << newpacket->ordernum);\n\t\tfree_pages((unsigned long) newpacket->data,\n\t\t\tnewpacket->ordernum);\n\t\tkfree(newpacket);\n\t}\n\trbu_data.packet_read_count = 0;\n\nInstruction:\nplatform/x86: dell_rbu: Stop overwriting data buffer\n\nReturn the diff that fixes it:\n @@ -108,7 +108,7 @@ static void packet_empty_list(void)\n \t\t * zero out the RBU packet memory before freeing\n \t\t * to make sure there are no stale RBU packets left in memory\n \t\t */\n-\t\tmemset(newpacket->data, 0, rbu_data.packetsize);\n+\t\tmemset(newpacket->data, 0, rbu_data.packetsize - 1);\n \t\tset_memory_wb((unsigned long)newpacket->data,\n \t\t\t1 << newpacket->ordernum);\n \t\tfree_pages((unsigned long) newpacket->data,\n@@ -116,7 +116,7 @@ static void packet_empty_list(void)\n \t\t */\n \t\tmemset(newpacket->data, 0, rbu_data.packetsize);\n \t\tset_memory_wb((unsigned long)newpacket->data,\n-\t\t\t1 << newpack"