Lines Matching refs:acpi_desc
89 static struct acpi_device *to_acpi_dev(struct acpi_nfit_desc *acpi_desc) in to_acpi_dev() argument
91 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; in to_acpi_dev()
101 return to_acpi_device(acpi_desc->dev); in to_acpi_dev()
440 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); in acpi_nfit_ctl() local
444 struct device *dev = acpi_desc->dev; in acpi_nfit_ctl()
477 struct acpi_device *adev = to_acpi_dev(acpi_desc); in acpi_nfit_ctl()
488 dsm_mask = acpi_desc->family_dsm_mask[family]; in acpi_nfit_ctl()
491 dsm_mask = acpi_desc->bus_dsm_mask; in acpi_nfit_ctl()
698 static bool add_spa(struct acpi_nfit_desc *acpi_desc, in add_spa() argument
702 struct device *dev = acpi_desc->dev; in add_spa()
710 list_move_tail(&nfit_spa->list, &acpi_desc->spas); in add_spa()
721 list_add_tail(&nfit_spa->list, &acpi_desc->spas); in add_spa()
728 static bool add_memdev(struct acpi_nfit_desc *acpi_desc, in add_memdev() argument
732 struct device *dev = acpi_desc->dev; in add_memdev()
740 list_move_tail(&nfit_memdev->list, &acpi_desc->memdevs); in add_memdev()
750 list_add_tail(&nfit_memdev->list, &acpi_desc->memdevs); in add_memdev()
760 struct acpi_nfit_desc *acpi_desc; in nfit_get_smbios_id() local
765 list_for_each_entry(acpi_desc, &acpi_descs, list) { in nfit_get_smbios_id()
766 mutex_lock(&acpi_desc->init_mutex); in nfit_get_smbios_id()
767 list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) { in nfit_get_smbios_id()
772 mutex_unlock(&acpi_desc->init_mutex); in nfit_get_smbios_id()
777 mutex_unlock(&acpi_desc->init_mutex); in nfit_get_smbios_id()
799 static bool add_dcr(struct acpi_nfit_desc *acpi_desc, in add_dcr() argument
803 struct device *dev = acpi_desc->dev; in add_dcr()
811 list_move_tail(&nfit_dcr->list, &acpi_desc->dcrs); in add_dcr()
821 list_add_tail(&nfit_dcr->list, &acpi_desc->dcrs); in add_dcr()
827 static bool add_bdw(struct acpi_nfit_desc *acpi_desc, in add_bdw() argument
831 struct device *dev = acpi_desc->dev; in add_bdw()
838 list_move_tail(&nfit_bdw->list, &acpi_desc->bdws); in add_bdw()
848 list_add_tail(&nfit_bdw->list, &acpi_desc->bdws); in add_bdw()
861 static bool add_idt(struct acpi_nfit_desc *acpi_desc, in add_idt() argument
865 struct device *dev = acpi_desc->dev; in add_idt()
876 list_move_tail(&nfit_idt->list, &acpi_desc->idts); in add_idt()
887 list_add_tail(&nfit_idt->list, &acpi_desc->idts); in add_idt()
900 static bool add_flush(struct acpi_nfit_desc *acpi_desc, in add_flush() argument
904 struct device *dev = acpi_desc->dev; in add_flush()
916 list_move_tail(&nfit_flush->list, &acpi_desc->flushes); in add_flush()
927 list_add_tail(&nfit_flush->list, &acpi_desc->flushes); in add_flush()
933 static bool add_platform_cap(struct acpi_nfit_desc *acpi_desc, in add_platform_cap() argument
936 struct device *dev = acpi_desc->dev; in add_platform_cap()
940 acpi_desc->platform_cap = pcap->capabilities & mask; in add_platform_cap()
941 dev_dbg(dev, "cap: %#x\n", acpi_desc->platform_cap); in add_platform_cap()
945 static void *add_table(struct acpi_nfit_desc *acpi_desc, in add_table() argument
948 struct device *dev = acpi_desc->dev; in add_table()
964 if (!add_spa(acpi_desc, prev, table)) in add_table()
968 if (!add_memdev(acpi_desc, prev, table)) in add_table()
972 if (!add_dcr(acpi_desc, prev, table)) in add_table()
976 if (!add_bdw(acpi_desc, prev, table)) in add_table()
980 if (!add_idt(acpi_desc, prev, table)) in add_table()
984 if (!add_flush(acpi_desc, prev, table)) in add_table()
991 if (!add_platform_cap(acpi_desc, table)) in add_table()
1002 static int __nfit_mem_init(struct acpi_nfit_desc *acpi_desc, in __nfit_mem_init() argument
1025 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) { in __nfit_mem_init()
1038 list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) in __nfit_mem_init()
1048 nfit_mem = devm_kzalloc(acpi_desc->dev, in __nfit_mem_init()
1053 nfit_mem->acpi_desc = acpi_desc; in __nfit_mem_init()
1054 list_add(&nfit_mem->list, &acpi_desc->dimms); in __nfit_mem_init()
1057 list_for_each_entry(nfit_dcr, &acpi_desc->dcrs, list) { in __nfit_mem_init()
1075 list_for_each_entry(nfit_flush, &acpi_desc->flushes, list) { in __nfit_mem_init()
1083 nfit_mem->flush_wpq = devm_kcalloc(acpi_desc->dev, in __nfit_mem_init()
1099 dev_err(acpi_desc->dev, "SPA %d missing DCR %d\n", in __nfit_mem_init()
1112 list_for_each_entry(nfit_idt, &acpi_desc->idts, list) { in __nfit_mem_init()
1148 static int nfit_mem_init(struct acpi_nfit_desc *acpi_desc) in nfit_mem_init() argument
1162 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { in nfit_mem_init()
1163 rc = __nfit_mem_init(acpi_desc, nfit_spa->spa); in nfit_mem_init()
1173 rc = __nfit_mem_init(acpi_desc, NULL); in nfit_mem_init()
1177 list_sort(NULL, &acpi_desc->dimms, nfit_mem_cmp); in nfit_mem_init()
1187 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); in bus_dsm_mask_show() local
1189 return sprintf(buf, "%#lx\n", acpi_desc->bus_dsm_mask); in bus_dsm_mask_show()
1199 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); in revision_show() local
1201 return sprintf(buf, "%d\n", acpi_desc->acpi_header.revision); in revision_show()
1210 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); in hw_error_scrub_show() local
1212 return sprintf(buf, "%d\n", acpi_desc->scrub_mode); in hw_error_scrub_show()
1236 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); in hw_error_scrub_store() local
1240 acpi_desc->scrub_mode = HW_ERROR_SCRUB_ON; in hw_error_scrub_store()
1243 acpi_desc->scrub_mode = HW_ERROR_SCRUB_OFF; in hw_error_scrub_store()
1266 struct acpi_nfit_desc *acpi_desc; in scrub_show() local
1276 acpi_desc = to_acpi_desc(nd_desc); in scrub_show()
1278 mutex_lock(&acpi_desc->init_mutex); in scrub_show()
1279 busy = test_bit(ARS_BUSY, &acpi_desc->scrub_flags) in scrub_show()
1280 && !test_bit(ARS_CANCEL, &acpi_desc->scrub_flags); in scrub_show()
1281 rc = sprintf(buf, "%d%s", acpi_desc->scrub_count, busy ? "+\n" : "\n"); in scrub_show()
1284 &acpi_desc->scrub_flags)) { in scrub_show()
1285 acpi_desc->scrub_tmo = 1; in scrub_show()
1286 mod_delayed_work(nfit_wq, &acpi_desc->dwork, HZ); in scrub_show()
1289 mutex_unlock(&acpi_desc->init_mutex); in scrub_show()
1310 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); in scrub_store() local
1312 rc = acpi_nfit_ars_rescan(acpi_desc, ARS_REQ_LONG); in scrub_store()
1479 struct acpi_nfit_desc *acpi_desc; in format1_show() local
1484 acpi_desc = nfit_mem->acpi_desc; in format1_show()
1488 mutex_lock(&acpi_desc->init_mutex); in format1_show()
1489 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) { in format1_show()
1496 list_for_each_entry(nfit_dcr, &acpi_desc->dcrs, list) { in format1_show()
1508 mutex_unlock(&acpi_desc->init_mutex); in format1_show()
1655 static struct nvdimm *acpi_nfit_dimm_by_handle(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_dimm_by_handle() argument
1660 list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) in acpi_nfit_dimm_by_handle()
1670 struct acpi_nfit_desc *acpi_desc; in __acpi_nvdimm_notify() local
1681 acpi_desc = dev_get_drvdata(dev->parent); in __acpi_nvdimm_notify()
1682 if (!acpi_desc) in __acpi_nvdimm_notify()
1773 static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_add_dimm() argument
1776 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; in acpi_nfit_add_dimm()
1778 struct device *dev = acpi_desc->dev; in acpi_nfit_add_dimm()
1786 nfit_mem->dsm_mask = acpi_desc->dimm_cmd_force_en; in acpi_nfit_add_dimm()
1801 adev = to_acpi_dev(acpi_desc); in acpi_nfit_add_dimm()
1931 struct acpi_nfit_desc *acpi_desc = data; in shutdown_dimm_notify() local
1934 mutex_lock(&acpi_desc->init_mutex); in shutdown_dimm_notify()
1939 list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) { in shutdown_dimm_notify()
1952 mutex_unlock(&acpi_desc->init_mutex); in shutdown_dimm_notify()
1969 struct acpi_nfit_desc *acpi_desc = nfit_mem->acpi_desc; in acpi_nfit_get_fw_ops() local
1970 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; in acpi_nfit_get_fw_ops()
1985 static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc) in acpi_nfit_register_dimms() argument
1991 list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) { in acpi_nfit_register_dimms()
1999 nvdimm = acpi_nfit_dimm_by_handle(acpi_desc, device_handle); in acpi_nfit_register_dimms()
2006 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) { in acpi_nfit_register_dimms()
2020 rc = acpi_nfit_add_dimm(acpi_desc, nfit_mem, device_handle); in acpi_nfit_register_dimms()
2048 nvdimm = __nvdimm_create(acpi_desc->nvdimm_bus, nfit_mem, in acpi_nfit_register_dimms()
2063 dev_err(acpi_desc->dev, "Error found in NVDIMM %s flags:%s%s%s%s%s\n", in acpi_nfit_register_dimms()
2073 rc = nvdimm_bus_check_dimm_count(acpi_desc->nvdimm_bus, dimm_count); in acpi_nfit_register_dimms()
2081 list_for_each_entry(nfit_mem, &acpi_desc->dimms, list) { in acpi_nfit_register_dimms()
2094 dev_warn(acpi_desc->dev, "%s: notifications disabled\n", in acpi_nfit_register_dimms()
2098 return devm_add_action_or_reset(acpi_desc->dev, shutdown_dimm_notify, in acpi_nfit_register_dimms()
2099 acpi_desc); in acpi_nfit_register_dimms()
2113 static void acpi_nfit_init_dsms(struct acpi_nfit_desc *acpi_desc) in acpi_nfit_init_dsms() argument
2115 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; in acpi_nfit_init_dsms()
2125 if (acpi_desc->bus_cmd_force_en) { in acpi_nfit_init_dsms()
2126 nd_desc->cmd_mask = acpi_desc->bus_cmd_force_en; in acpi_nfit_init_dsms()
2128 if (acpi_desc->family_dsm_mask[NVDIMM_BUS_FAMILY_INTEL]) { in acpi_nfit_init_dsms()
2134 adev = to_acpi_dev(acpi_desc); in acpi_nfit_init_dsms()
2153 set_bit(i, &acpi_desc->bus_dsm_mask); in acpi_nfit_init_dsms()
2158 mask = &acpi_desc->family_dsm_mask[NVDIMM_BUS_FAMILY_INTEL]; in acpi_nfit_init_dsms()
2245 struct acpi_nfit_desc *acpi_desc, u16 range_index, int n) in memdev_from_spa() argument
2249 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) in memdev_from_spa()
2256 static int acpi_nfit_init_interleave_set(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_init_interleave_set() argument
2260 struct device *dev = acpi_desc->dev; in acpi_nfit_init_interleave_set()
2287 memdev_from_spa(acpi_desc, spa->range_index, i); in acpi_nfit_init_interleave_set()
2346 static int ars_get_cap(struct acpi_nfit_desc *acpi_desc, in ars_get_cap() argument
2349 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; in ars_get_cap()
2362 static int ars_start(struct acpi_nfit_desc *acpi_desc, in ars_start() argument
2369 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; in ars_start()
2390 set_bit(ARS_VALID, &acpi_desc->scrub_flags); in ars_start()
2394 static int ars_continue(struct acpi_nfit_desc *acpi_desc) in ars_continue() argument
2398 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; in ars_continue()
2399 struct nd_cmd_ars_status *ars_status = acpi_desc->ars_status; in ars_continue()
2413 static int ars_get_status(struct acpi_nfit_desc *acpi_desc) in ars_get_status() argument
2415 struct nvdimm_bus_descriptor *nd_desc = &acpi_desc->nd_desc; in ars_get_status()
2416 struct nd_cmd_ars_status *ars_status = acpi_desc->ars_status; in ars_get_status()
2420 acpi_desc->max_ars, &cmd_rc); in ars_get_status()
2426 static void ars_complete(struct acpi_nfit_desc *acpi_desc, in ars_complete() argument
2429 struct nd_cmd_ars_status *ars_status = acpi_desc->ars_status; in ars_complete()
2434 lockdep_assert_held(&acpi_desc->init_mutex); in ars_complete()
2440 if (acpi_desc->scrub_spa != nfit_spa) in ars_complete()
2462 acpi_desc->scrub_spa = NULL; in ars_complete()
2467 dev = acpi_desc->dev; in ars_complete()
2471 static int ars_status_process_records(struct acpi_nfit_desc *acpi_desc) in ars_status_process_records() argument
2473 struct nvdimm_bus *nvdimm_bus = acpi_desc->nvdimm_bus; in ars_status_process_records()
2474 struct nd_cmd_ars_status *ars_status = acpi_desc->ars_status; in ars_status_process_records()
2489 if (!test_and_clear_bit(ARS_VALID, &acpi_desc->scrub_flags)) { in ars_status_process_records()
2490 dev_dbg(acpi_desc->dev, "skip %d stale records\n", in ars_status_process_records()
2507 dev_warn(acpi_desc->dev, "detected truncated ars results\n"); in ars_status_process_records()
2519 static int acpi_nfit_insert_resource(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_insert_resource() argument
2531 res = devm_kzalloc(acpi_desc->dev, sizeof(*res), GFP_KERNEL); in acpi_nfit_insert_resource()
2545 ret = devm_add_action_or_reset(acpi_desc->dev, in acpi_nfit_insert_resource()
2554 static int acpi_nfit_init_mapping(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_init_mapping() argument
2559 struct nvdimm *nvdimm = acpi_nfit_dimm_by_handle(acpi_desc, in acpi_nfit_init_mapping()
2564 dev_err(acpi_desc->dev, "spa%d dimm: %#x not found\n", in acpi_nfit_init_mapping()
2596 static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_register_region() argument
2611 dev_dbg(acpi_desc->dev, "detected invalid spa index\n"); in acpi_nfit_register_region()
2635 dev_info(acpi_desc->dev, "changing numa node from %d to %d for nfit region [%pa-%pa]", in acpi_nfit_register_region()
2640 dev_info(acpi_desc->dev, "changing target node from %d to %d for nfit region [%pa-%pa]", in acpi_nfit_register_region()
2649 if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_CACHE_FLUSH) in acpi_nfit_register_region()
2651 else if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_MEM_FLUSH) in acpi_nfit_register_region()
2654 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) { in acpi_nfit_register_region()
2664 dev_err(acpi_desc->dev, "spa%d exceeds max mappings %d\n", in acpi_nfit_register_region()
2669 rc = acpi_nfit_init_mapping(acpi_desc, mapping, ndr_desc, in acpi_nfit_register_region()
2677 rc = acpi_nfit_init_interleave_set(acpi_desc, ndr_desc, spa); in acpi_nfit_register_region()
2681 nvdimm_bus = acpi_desc->nvdimm_bus; in acpi_nfit_register_region()
2683 rc = acpi_nfit_insert_resource(acpi_desc, ndr_desc); in acpi_nfit_register_region()
2685 dev_warn(acpi_desc->dev, in acpi_nfit_register_region()
2709 dev_err(acpi_desc->dev, "failed to register spa range %d\n", in acpi_nfit_register_region()
2714 static int ars_status_alloc(struct acpi_nfit_desc *acpi_desc) in ars_status_alloc() argument
2716 struct device *dev = acpi_desc->dev; in ars_status_alloc()
2719 if (acpi_desc->ars_status) { in ars_status_alloc()
2720 memset(acpi_desc->ars_status, 0, acpi_desc->max_ars); in ars_status_alloc()
2724 ars_status = devm_kzalloc(dev, acpi_desc->max_ars, GFP_KERNEL); in ars_status_alloc()
2727 acpi_desc->ars_status = ars_status; in ars_status_alloc()
2731 static int acpi_nfit_query_poison(struct acpi_nfit_desc *acpi_desc) in acpi_nfit_query_poison() argument
2735 if (ars_status_alloc(acpi_desc)) in acpi_nfit_query_poison()
2738 rc = ars_get_status(acpi_desc); in acpi_nfit_query_poison()
2743 if (ars_status_process_records(acpi_desc)) in acpi_nfit_query_poison()
2744 dev_err(acpi_desc->dev, "Failed to process ARS records\n"); in acpi_nfit_query_poison()
2749 static int ars_register(struct acpi_nfit_desc *acpi_desc, in ars_register() argument
2755 return acpi_nfit_register_region(acpi_desc, nfit_spa); in ars_register()
2761 switch (acpi_nfit_query_poison(acpi_desc)) { in ars_register()
2765 rc = ars_start(acpi_desc, nfit_spa, ARS_REQ_SHORT); in ars_register()
2774 rc = acpi_nfit_query_poison(acpi_desc); in ars_register()
2777 acpi_desc->scrub_spa = nfit_spa; in ars_register()
2778 ars_complete(acpi_desc, nfit_spa); in ars_register()
2784 acpi_desc->scrub_spa = NULL; in ars_register()
2799 return acpi_nfit_register_region(acpi_desc, nfit_spa); in ars_register()
2802 static void ars_complete_all(struct acpi_nfit_desc *acpi_desc) in ars_complete_all() argument
2806 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { in ars_complete_all()
2809 ars_complete(acpi_desc, nfit_spa); in ars_complete_all()
2813 static unsigned int __acpi_nfit_scrub(struct acpi_nfit_desc *acpi_desc, in __acpi_nfit_scrub() argument
2816 unsigned int tmo = acpi_desc->scrub_tmo; in __acpi_nfit_scrub()
2817 struct device *dev = acpi_desc->dev; in __acpi_nfit_scrub()
2820 lockdep_assert_held(&acpi_desc->init_mutex); in __acpi_nfit_scrub()
2822 if (test_bit(ARS_CANCEL, &acpi_desc->scrub_flags)) in __acpi_nfit_scrub()
2831 ars_continue(acpi_desc); in __acpi_nfit_scrub()
2837 addr = acpi_desc->ars_status->address; in __acpi_nfit_scrub()
2838 end = addr + acpi_desc->ars_status->length; in __acpi_nfit_scrub()
2843 ars_complete_all(acpi_desc); in __acpi_nfit_scrub()
2844 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { in __acpi_nfit_scrub()
2858 rc = ars_start(acpi_desc, nfit_spa, req_type); in __acpi_nfit_scrub()
2872 dev_WARN_ONCE(dev, acpi_desc->scrub_spa, in __acpi_nfit_scrub()
2874 acpi_desc->scrub_spa->spa->range_index); in __acpi_nfit_scrub()
2876 acpi_desc->scrub_spa = nfit_spa; in __acpi_nfit_scrub()
2881 list_move_tail(&nfit_spa->list, &acpi_desc->spas); in __acpi_nfit_scrub()
2892 static void __sched_ars(struct acpi_nfit_desc *acpi_desc, unsigned int tmo) in __sched_ars() argument
2894 lockdep_assert_held(&acpi_desc->init_mutex); in __sched_ars()
2896 set_bit(ARS_BUSY, &acpi_desc->scrub_flags); in __sched_ars()
2899 acpi_desc->scrub_tmo = tmo; in __sched_ars()
2900 queue_delayed_work(nfit_wq, &acpi_desc->dwork, tmo * HZ); in __sched_ars()
2903 static void sched_ars(struct acpi_nfit_desc *acpi_desc) in sched_ars() argument
2905 __sched_ars(acpi_desc, 0); in sched_ars()
2908 static void notify_ars_done(struct acpi_nfit_desc *acpi_desc) in notify_ars_done() argument
2910 lockdep_assert_held(&acpi_desc->init_mutex); in notify_ars_done()
2912 clear_bit(ARS_BUSY, &acpi_desc->scrub_flags); in notify_ars_done()
2913 acpi_desc->scrub_count++; in notify_ars_done()
2914 if (acpi_desc->scrub_count_state) in notify_ars_done()
2915 sysfs_notify_dirent(acpi_desc->scrub_count_state); in notify_ars_done()
2920 struct acpi_nfit_desc *acpi_desc; in acpi_nfit_scrub() local
2924 acpi_desc = container_of(work, typeof(*acpi_desc), dwork.work); in acpi_nfit_scrub()
2925 mutex_lock(&acpi_desc->init_mutex); in acpi_nfit_scrub()
2926 query_rc = acpi_nfit_query_poison(acpi_desc); in acpi_nfit_scrub()
2927 tmo = __acpi_nfit_scrub(acpi_desc, query_rc); in acpi_nfit_scrub()
2929 __sched_ars(acpi_desc, tmo); in acpi_nfit_scrub()
2931 notify_ars_done(acpi_desc); in acpi_nfit_scrub()
2932 memset(acpi_desc->ars_status, 0, acpi_desc->max_ars); in acpi_nfit_scrub()
2933 clear_bit(ARS_POLL, &acpi_desc->scrub_flags); in acpi_nfit_scrub()
2934 mutex_unlock(&acpi_desc->init_mutex); in acpi_nfit_scrub()
2937 static void acpi_nfit_init_ars(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_init_ars() argument
2946 rc = ars_get_cap(acpi_desc, &ars_cap, nfit_spa); in acpi_nfit_init_ars()
2959 acpi_desc->max_ars = max(nfit_spa->max_ars, acpi_desc->max_ars); in acpi_nfit_init_ars()
2963 static int acpi_nfit_register_regions(struct acpi_nfit_desc *acpi_desc) in acpi_nfit_register_regions() argument
2968 set_bit(ARS_VALID, &acpi_desc->scrub_flags); in acpi_nfit_register_regions()
2969 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { in acpi_nfit_register_regions()
2973 acpi_nfit_init_ars(acpi_desc, nfit_spa); in acpi_nfit_register_regions()
2978 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { in acpi_nfit_register_regions()
2983 rc = ars_register(acpi_desc, nfit_spa); in acpi_nfit_register_regions()
3003 rc = acpi_nfit_register_region(acpi_desc, nfit_spa); in acpi_nfit_register_regions()
3014 sched_ars(acpi_desc); in acpi_nfit_register_regions()
3018 static int acpi_nfit_check_deletions(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_check_deletions() argument
3021 struct device *dev = acpi_desc->dev; in acpi_nfit_check_deletions()
3035 static int acpi_nfit_desc_init_scrub_attr(struct acpi_nfit_desc *acpi_desc) in acpi_nfit_desc_init_scrub_attr() argument
3037 struct device *dev = acpi_desc->dev; in acpi_nfit_desc_init_scrub_attr()
3041 if (!ars_supported(acpi_desc->nvdimm_bus)) in acpi_nfit_desc_init_scrub_attr()
3044 bus_dev = to_nvdimm_bus_dev(acpi_desc->nvdimm_bus); in acpi_nfit_desc_init_scrub_attr()
3050 acpi_desc->scrub_count_state = sysfs_get_dirent(nfit, "scrub"); in acpi_nfit_desc_init_scrub_attr()
3052 if (!acpi_desc->scrub_count_state) { in acpi_nfit_desc_init_scrub_attr()
3062 struct acpi_nfit_desc *acpi_desc = data; in acpi_nfit_unregister() local
3064 nvdimm_bus_unregister(acpi_desc->nvdimm_bus); in acpi_nfit_unregister()
3067 int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, void *data, acpi_size sz) in acpi_nfit_init() argument
3069 struct device *dev = acpi_desc->dev; in acpi_nfit_init()
3074 if (!acpi_desc->nvdimm_bus) { in acpi_nfit_init()
3075 acpi_nfit_init_dsms(acpi_desc); in acpi_nfit_init()
3077 acpi_desc->nvdimm_bus = nvdimm_bus_register(dev, in acpi_nfit_init()
3078 &acpi_desc->nd_desc); in acpi_nfit_init()
3079 if (!acpi_desc->nvdimm_bus) in acpi_nfit_init()
3083 acpi_desc); in acpi_nfit_init()
3087 rc = acpi_nfit_desc_init_scrub_attr(acpi_desc); in acpi_nfit_init()
3093 list_add_tail(&acpi_desc->list, &acpi_descs); in acpi_nfit_init()
3097 mutex_lock(&acpi_desc->init_mutex); in acpi_nfit_init()
3106 list_cut_position(&prev.spas, &acpi_desc->spas, in acpi_nfit_init()
3107 acpi_desc->spas.prev); in acpi_nfit_init()
3108 list_cut_position(&prev.memdevs, &acpi_desc->memdevs, in acpi_nfit_init()
3109 acpi_desc->memdevs.prev); in acpi_nfit_init()
3110 list_cut_position(&prev.dcrs, &acpi_desc->dcrs, in acpi_nfit_init()
3111 acpi_desc->dcrs.prev); in acpi_nfit_init()
3112 list_cut_position(&prev.bdws, &acpi_desc->bdws, in acpi_nfit_init()
3113 acpi_desc->bdws.prev); in acpi_nfit_init()
3114 list_cut_position(&prev.idts, &acpi_desc->idts, in acpi_nfit_init()
3115 acpi_desc->idts.prev); in acpi_nfit_init()
3116 list_cut_position(&prev.flushes, &acpi_desc->flushes, in acpi_nfit_init()
3117 acpi_desc->flushes.prev); in acpi_nfit_init()
3121 data = add_table(acpi_desc, &prev, data, end); in acpi_nfit_init()
3129 rc = acpi_nfit_check_deletions(acpi_desc, &prev); in acpi_nfit_init()
3133 rc = nfit_mem_init(acpi_desc); in acpi_nfit_init()
3137 rc = acpi_nfit_register_dimms(acpi_desc); in acpi_nfit_init()
3141 rc = acpi_nfit_register_regions(acpi_desc); in acpi_nfit_init()
3144 mutex_unlock(&acpi_desc->init_mutex); in acpi_nfit_init()
3151 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); in acpi_nfit_flush_probe() local
3152 struct device *dev = acpi_desc->dev; in acpi_nfit_flush_probe()
3159 mutex_lock(&acpi_desc->init_mutex); in acpi_nfit_flush_probe()
3160 mutex_unlock(&acpi_desc->init_mutex); in acpi_nfit_flush_probe()
3168 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); in __acpi_nfit_clear_to_send() local
3181 if (work_busy(&acpi_desc->dwork.work)) in __acpi_nfit_clear_to_send()
3213 int acpi_nfit_ars_rescan(struct acpi_nfit_desc *acpi_desc, in acpi_nfit_ars_rescan() argument
3216 struct device *dev = acpi_desc->dev; in acpi_nfit_ars_rescan()
3220 mutex_lock(&acpi_desc->init_mutex); in acpi_nfit_ars_rescan()
3221 if (test_bit(ARS_CANCEL, &acpi_desc->scrub_flags)) { in acpi_nfit_ars_rescan()
3222 mutex_unlock(&acpi_desc->init_mutex); in acpi_nfit_ars_rescan()
3226 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { in acpi_nfit_ars_rescan()
3240 sched_ars(acpi_desc); in acpi_nfit_ars_rescan()
3243 mutex_unlock(&acpi_desc->init_mutex); in acpi_nfit_ars_rescan()
3252 void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev) in acpi_nfit_desc_init() argument
3256 dev_set_drvdata(dev, acpi_desc); in acpi_nfit_desc_init()
3257 acpi_desc->dev = dev; in acpi_nfit_desc_init()
3258 nd_desc = &acpi_desc->nd_desc; in acpi_nfit_desc_init()
3266 INIT_LIST_HEAD(&acpi_desc->spas); in acpi_nfit_desc_init()
3267 INIT_LIST_HEAD(&acpi_desc->dcrs); in acpi_nfit_desc_init()
3268 INIT_LIST_HEAD(&acpi_desc->bdws); in acpi_nfit_desc_init()
3269 INIT_LIST_HEAD(&acpi_desc->idts); in acpi_nfit_desc_init()
3270 INIT_LIST_HEAD(&acpi_desc->flushes); in acpi_nfit_desc_init()
3271 INIT_LIST_HEAD(&acpi_desc->memdevs); in acpi_nfit_desc_init()
3272 INIT_LIST_HEAD(&acpi_desc->dimms); in acpi_nfit_desc_init()
3273 INIT_LIST_HEAD(&acpi_desc->list); in acpi_nfit_desc_init()
3274 mutex_init(&acpi_desc->init_mutex); in acpi_nfit_desc_init()
3275 acpi_desc->scrub_tmo = 1; in acpi_nfit_desc_init()
3276 INIT_DELAYED_WORK(&acpi_desc->dwork, acpi_nfit_scrub); in acpi_nfit_desc_init()
3304 struct acpi_nfit_desc *acpi_desc = data; in acpi_nfit_shutdown() local
3305 struct device *bus_dev = to_nvdimm_bus_dev(acpi_desc->nvdimm_bus); in acpi_nfit_shutdown()
3312 list_del(&acpi_desc->list); in acpi_nfit_shutdown()
3315 mutex_lock(&acpi_desc->init_mutex); in acpi_nfit_shutdown()
3316 set_bit(ARS_CANCEL, &acpi_desc->scrub_flags); in acpi_nfit_shutdown()
3317 mutex_unlock(&acpi_desc->init_mutex); in acpi_nfit_shutdown()
3318 cancel_delayed_work_sync(&acpi_desc->dwork); in acpi_nfit_shutdown()
3335 struct acpi_nfit_desc *acpi_desc; in acpi_nfit_add() local
3370 acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL); in acpi_nfit_add()
3371 if (!acpi_desc) in acpi_nfit_add()
3373 acpi_nfit_desc_init(acpi_desc, &adev->dev); in acpi_nfit_add()
3376 acpi_desc->acpi_header = *tbl; in acpi_nfit_add()
3384 rc = acpi_nfit_init(acpi_desc, obj->buffer.pointer, in acpi_nfit_add()
3392 rc = acpi_nfit_init(acpi_desc, (void *) tbl in acpi_nfit_add()
3399 return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc); in acpi_nfit_add()
3404 struct acpi_nfit_desc *acpi_desc = dev_get_drvdata(dev); in acpi_nfit_update_notify() local
3416 if (!acpi_desc) { in acpi_nfit_update_notify()
3417 acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL); in acpi_nfit_update_notify()
3418 if (!acpi_desc) in acpi_nfit_update_notify()
3420 acpi_nfit_desc_init(acpi_desc, dev); in acpi_nfit_update_notify()
3438 ret = acpi_nfit_init(acpi_desc, obj->buffer.pointer, in acpi_nfit_update_notify()
3449 struct acpi_nfit_desc *acpi_desc = dev_get_drvdata(dev); in acpi_nfit_uc_error_notify() local
3451 if (acpi_desc->scrub_mode == HW_ERROR_SCRUB_ON) in acpi_nfit_uc_error_notify()
3452 acpi_nfit_ars_rescan(acpi_desc, ARS_REQ_LONG); in acpi_nfit_uc_error_notify()
3454 acpi_nfit_ars_rescan(acpi_desc, ARS_REQ_SHORT); in acpi_nfit_uc_error_notify()