xref: /openbmc/linux/arch/parisc/kernel/pdt.c (revision 83b57531c58f4173d1c0d0b2c0bc88c853c32ea5)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2c9c2877dSHelge Deller /*
3c9c2877dSHelge Deller  *    Page Deallocation Table (PDT) support
4c9c2877dSHelge Deller  *
554ac8fcbSHelge Deller  *    The Page Deallocation Table (PDT) is maintained by firmware and holds a
654ac8fcbSHelge Deller  *    list of memory addresses in which memory errors were detected.
754ac8fcbSHelge Deller  *    The list contains both single-bit (correctable) and double-bit
854ac8fcbSHelge Deller  *    (uncorrectable) errors.
9c9c2877dSHelge Deller  *
10c9c2877dSHelge Deller  *    Copyright 2017 by Helge Deller <deller@gmx.de>
11c9c2877dSHelge Deller  *
1254ac8fcbSHelge Deller  *    possible future enhancements:
1354ac8fcbSHelge Deller  *    - add userspace interface via procfs or sysfs to clear PDT
14c9c2877dSHelge Deller  */
15c9c2877dSHelge Deller 
16c9c2877dSHelge Deller #include <linux/memblock.h>
17c9c2877dSHelge Deller #include <linux/seq_file.h>
1854ac8fcbSHelge Deller #include <linux/kthread.h>
19ea697648SHelge Deller #include <linux/initrd.h>
20c9c2877dSHelge Deller 
21c9c2877dSHelge Deller #include <asm/pdc.h>
22c9c2877dSHelge Deller #include <asm/pdcpat.h>
23c9c2877dSHelge Deller #include <asm/sections.h>
24c9c2877dSHelge Deller #include <asm/pgtable.h>
25c9c2877dSHelge Deller 
26c9c2877dSHelge Deller enum pdt_access_type {
27c9c2877dSHelge Deller 	PDT_NONE,
28c9c2877dSHelge Deller 	PDT_PDC,
29c9c2877dSHelge Deller 	PDT_PAT_NEW,
3054ac8fcbSHelge Deller 	PDT_PAT_CELL
31c9c2877dSHelge Deller };
32c9c2877dSHelge Deller 
33c9c2877dSHelge Deller static enum pdt_access_type pdt_type;
34c9c2877dSHelge Deller 
3554ac8fcbSHelge Deller /* PDT poll interval: 1 minute if errors, 5 minutes if everything OK. */
3654ac8fcbSHelge Deller #define PDT_POLL_INTERVAL_DEFAULT	(5*60*HZ)
3754ac8fcbSHelge Deller #define PDT_POLL_INTERVAL_SHORT		(1*60*HZ)
3854ac8fcbSHelge Deller static unsigned long pdt_poll_interval = PDT_POLL_INTERVAL_DEFAULT;
3954ac8fcbSHelge Deller 
40c9c2877dSHelge Deller /* global PDT status information */
41c9c2877dSHelge Deller static struct pdc_mem_retinfo pdt_status;
42c9c2877dSHelge Deller 
43c9c2877dSHelge Deller #define MAX_PDT_TABLE_SIZE	PAGE_SIZE
44c9c2877dSHelge Deller #define MAX_PDT_ENTRIES		(MAX_PDT_TABLE_SIZE / sizeof(unsigned long))
45c9c2877dSHelge Deller static unsigned long pdt_entry[MAX_PDT_ENTRIES] __page_aligned_bss;
46c9c2877dSHelge Deller 
4754ac8fcbSHelge Deller /*
4854ac8fcbSHelge Deller  * Constants for the pdt_entry format:
4954ac8fcbSHelge Deller  * A pdt_entry holds the physical address in bits 0-57, bits 58-61 are
5054ac8fcbSHelge Deller  * reserved, bit 62 is the perm bit and bit 63 is the error_type bit.
5154ac8fcbSHelge Deller  * The perm bit indicates whether the error have been verified as a permanent
5254ac8fcbSHelge Deller  * error (value of 1) or has not been verified, and may be transient (value
5354ac8fcbSHelge Deller  * of 0). The error_type bit indicates whether the error is a single bit error
5454ac8fcbSHelge Deller  * (value of 1) or a multiple bit error.
5554ac8fcbSHelge Deller  * On non-PAT machines phys_addr is encoded in bits 0-59 and error_type in bit
5654ac8fcbSHelge Deller  * 63. Those machines don't provide the perm bit.
5754ac8fcbSHelge Deller  */
5854ac8fcbSHelge Deller 
5954ac8fcbSHelge Deller #define PDT_ADDR_PHYS_MASK	(pdt_type != PDT_PDC ? ~0x3f : ~0x0f)
6054ac8fcbSHelge Deller #define PDT_ADDR_PERM_ERR	(pdt_type != PDT_PDC ? 2UL : 0UL)
6154ac8fcbSHelge Deller #define PDT_ADDR_SINGLE_ERR	1UL
62c9c2877dSHelge Deller 
63c9c2877dSHelge Deller /* report PDT entries via /proc/meminfo */
64c9c2877dSHelge Deller void arch_report_meminfo(struct seq_file *m)
65c9c2877dSHelge Deller {
66c9c2877dSHelge Deller 	if (pdt_type == PDT_NONE)
67c9c2877dSHelge Deller 		return;
68c9c2877dSHelge Deller 
69c9c2877dSHelge Deller 	seq_printf(m, "PDT_max_entries: %7lu\n",
70c9c2877dSHelge Deller 			pdt_status.pdt_size);
71c9c2877dSHelge Deller 	seq_printf(m, "PDT_cur_entries: %7lu\n",
72c9c2877dSHelge Deller 			pdt_status.pdt_entries);
73c9c2877dSHelge Deller }
74c9c2877dSHelge Deller 
7554ac8fcbSHelge Deller static int get_info_pat_new(void)
7654ac8fcbSHelge Deller {
7754ac8fcbSHelge Deller 	struct pdc_pat_mem_retinfo pat_rinfo;
7854ac8fcbSHelge Deller 	int ret;
7954ac8fcbSHelge Deller 
8054ac8fcbSHelge Deller 	/* newer PAT machines like C8000 report info for all cells */
8154ac8fcbSHelge Deller 	if (is_pdc_pat())
8254ac8fcbSHelge Deller 		ret = pdc_pat_mem_pdt_info(&pat_rinfo);
8354ac8fcbSHelge Deller 	else
8454ac8fcbSHelge Deller 		return PDC_BAD_PROC;
8554ac8fcbSHelge Deller 
8654ac8fcbSHelge Deller 	pdt_status.pdt_size = pat_rinfo.max_pdt_entries;
8754ac8fcbSHelge Deller 	pdt_status.pdt_entries = pat_rinfo.current_pdt_entries;
8854ac8fcbSHelge Deller 	pdt_status.pdt_status = 0;
8954ac8fcbSHelge Deller 	pdt_status.first_dbe_loc = pat_rinfo.first_dbe_loc;
9054ac8fcbSHelge Deller 	pdt_status.good_mem = pat_rinfo.good_mem;
9154ac8fcbSHelge Deller 
9254ac8fcbSHelge Deller 	return ret;
9354ac8fcbSHelge Deller }
9454ac8fcbSHelge Deller 
9554ac8fcbSHelge Deller static int get_info_pat_cell(void)
9654ac8fcbSHelge Deller {
9754ac8fcbSHelge Deller 	struct pdc_pat_mem_cell_pdt_retinfo cell_rinfo;
9854ac8fcbSHelge Deller 	int ret;
9954ac8fcbSHelge Deller 
10054ac8fcbSHelge Deller 	/* older PAT machines like rp5470 report cell info only */
10154ac8fcbSHelge Deller 	if (is_pdc_pat())
10254ac8fcbSHelge Deller 		ret = pdc_pat_mem_pdt_cell_info(&cell_rinfo, parisc_cell_num);
10354ac8fcbSHelge Deller 	else
10454ac8fcbSHelge Deller 		return PDC_BAD_PROC;
10554ac8fcbSHelge Deller 
10654ac8fcbSHelge Deller 	pdt_status.pdt_size = cell_rinfo.max_pdt_entries;
10754ac8fcbSHelge Deller 	pdt_status.pdt_entries = cell_rinfo.current_pdt_entries;
10854ac8fcbSHelge Deller 	pdt_status.pdt_status = 0;
10954ac8fcbSHelge Deller 	pdt_status.first_dbe_loc = cell_rinfo.first_dbe_loc;
11054ac8fcbSHelge Deller 	pdt_status.good_mem = cell_rinfo.good_mem;
11154ac8fcbSHelge Deller 
11254ac8fcbSHelge Deller 	return ret;
11354ac8fcbSHelge Deller }
11454ac8fcbSHelge Deller 
11554ac8fcbSHelge Deller static void report_mem_err(unsigned long pde)
11654ac8fcbSHelge Deller {
11754ac8fcbSHelge Deller 	struct pdc_pat_mem_phys_mem_location loc;
11854ac8fcbSHelge Deller 	unsigned long addr;
11954ac8fcbSHelge Deller 	char dimm_txt[32];
12054ac8fcbSHelge Deller 
12154ac8fcbSHelge Deller 	addr = pde & PDT_ADDR_PHYS_MASK;
12254ac8fcbSHelge Deller 
12354ac8fcbSHelge Deller 	/* show DIMM slot description on PAT machines */
12454ac8fcbSHelge Deller 	if (is_pdc_pat()) {
12554ac8fcbSHelge Deller 		pdc_pat_mem_get_dimm_phys_location(&loc, addr);
12654ac8fcbSHelge Deller 		sprintf(dimm_txt, "DIMM slot %02x, ", loc.dimm_slot);
12754ac8fcbSHelge Deller 	} else
12854ac8fcbSHelge Deller 		dimm_txt[0] = 0;
12954ac8fcbSHelge Deller 
13054ac8fcbSHelge Deller 	pr_warn("PDT: BAD MEMORY at 0x%08lx, %s%s%s-bit error.\n",
13154ac8fcbSHelge Deller 		addr, dimm_txt,
13254ac8fcbSHelge Deller 		pde & PDT_ADDR_PERM_ERR ? "permanent ":"",
13354ac8fcbSHelge Deller 		pde & PDT_ADDR_SINGLE_ERR ? "single":"multi");
13454ac8fcbSHelge Deller }
13554ac8fcbSHelge Deller 
13654ac8fcbSHelge Deller 
137c9c2877dSHelge Deller /*
138c9c2877dSHelge Deller  * pdc_pdt_init()
139c9c2877dSHelge Deller  *
140c9c2877dSHelge Deller  * Initialize kernel PDT structures, read initial PDT table from firmware,
141c9c2877dSHelge Deller  * report all current PDT entries and mark bad memory with memblock_reserve()
142c9c2877dSHelge Deller  * to avoid that the kernel will use broken memory areas.
143c9c2877dSHelge Deller  *
144c9c2877dSHelge Deller  */
145c9c2877dSHelge Deller void __init pdc_pdt_init(void)
146c9c2877dSHelge Deller {
147c9c2877dSHelge Deller 	int ret, i;
148c9c2877dSHelge Deller 	unsigned long entries;
149c9c2877dSHelge Deller 	struct pdc_mem_read_pdt pdt_read_ret;
150c9c2877dSHelge Deller 
151c9c2877dSHelge Deller 	pdt_type = PDT_PAT_NEW;
15254ac8fcbSHelge Deller 	ret = get_info_pat_new();
15354ac8fcbSHelge Deller 
15454ac8fcbSHelge Deller 	if (ret != PDC_OK) {
15554ac8fcbSHelge Deller 		pdt_type = PDT_PAT_CELL;
15654ac8fcbSHelge Deller 		ret = get_info_pat_cell();
15754ac8fcbSHelge Deller 	}
15854ac8fcbSHelge Deller 
15954ac8fcbSHelge Deller 	if (ret != PDC_OK) {
160c9c2877dSHelge Deller 		pdt_type = PDT_PDC;
16154ac8fcbSHelge Deller 		/* non-PAT machines provide the standard PDC call */
162c9c2877dSHelge Deller 		ret = pdc_mem_pdt_info(&pdt_status);
163c9c2877dSHelge Deller 	}
164c9c2877dSHelge Deller 
165c9c2877dSHelge Deller 	if (ret != PDC_OK) {
166c9c2877dSHelge Deller 		pdt_type = PDT_NONE;
167c9c2877dSHelge Deller 		pr_info("PDT: Firmware does not provide any page deallocation"
168c9c2877dSHelge Deller 			" information.\n");
169c9c2877dSHelge Deller 		return;
170c9c2877dSHelge Deller 	}
171c9c2877dSHelge Deller 
172c9c2877dSHelge Deller 	entries = pdt_status.pdt_entries;
17354ac8fcbSHelge Deller 	if (WARN_ON(entries > MAX_PDT_ENTRIES))
17454ac8fcbSHelge Deller 		entries = pdt_status.pdt_entries = MAX_PDT_ENTRIES;
175c9c2877dSHelge Deller 
17654ac8fcbSHelge Deller 	pr_info("PDT: type %s, size %lu, entries %lu, status %lu, dbe_loc 0x%lx,"
17754ac8fcbSHelge Deller 		" good_mem %lu MB\n",
17854ac8fcbSHelge Deller 			pdt_type == PDT_PDC ? __stringify(PDT_PDC) :
17954ac8fcbSHelge Deller 			pdt_type == PDT_PAT_CELL ? __stringify(PDT_PAT_CELL)
18054ac8fcbSHelge Deller 						 : __stringify(PDT_PAT_NEW),
181c9c2877dSHelge Deller 			pdt_status.pdt_size, pdt_status.pdt_entries,
182c9c2877dSHelge Deller 			pdt_status.pdt_status, pdt_status.first_dbe_loc,
18354ac8fcbSHelge Deller 			pdt_status.good_mem / 1024 / 1024);
184c9c2877dSHelge Deller 
185c9c2877dSHelge Deller 	if (entries == 0) {
186c9c2877dSHelge Deller 		pr_info("PDT: Firmware reports all memory OK.\n");
187c9c2877dSHelge Deller 		return;
188c9c2877dSHelge Deller 	}
189c9c2877dSHelge Deller 
190c9c2877dSHelge Deller 	if (pdt_status.first_dbe_loc &&
191c9c2877dSHelge Deller 		pdt_status.first_dbe_loc <= __pa((unsigned long)&_end))
192c9c2877dSHelge Deller 		pr_crit("CRITICAL: Bad memory inside kernel image memory area!\n");
193c9c2877dSHelge Deller 
194c9c2877dSHelge Deller 	pr_warn("PDT: Firmware reports %lu entries of faulty memory:\n",
195c9c2877dSHelge Deller 		entries);
196c9c2877dSHelge Deller 
197c9c2877dSHelge Deller 	if (pdt_type == PDT_PDC)
198c9c2877dSHelge Deller 		ret = pdc_mem_pdt_read_entries(&pdt_read_ret, pdt_entry);
199c9c2877dSHelge Deller 	else {
200c9c2877dSHelge Deller #ifdef CONFIG_64BIT
201c9c2877dSHelge Deller 		struct pdc_pat_mem_read_pd_retinfo pat_pret;
202c9c2877dSHelge Deller 
20354ac8fcbSHelge Deller 		if (pdt_type == PDT_PAT_CELL)
204c9c2877dSHelge Deller 			ret = pdc_pat_mem_read_cell_pdt(&pat_pret, pdt_entry,
205c9c2877dSHelge Deller 				MAX_PDT_ENTRIES);
20654ac8fcbSHelge Deller 		else
207c9c2877dSHelge Deller 			ret = pdc_pat_mem_read_pd_pdt(&pat_pret, pdt_entry,
208c9c2877dSHelge Deller 				MAX_PDT_TABLE_SIZE, 0);
209c9c2877dSHelge Deller #else
210c9c2877dSHelge Deller 		ret = PDC_BAD_PROC;
211c9c2877dSHelge Deller #endif
212c9c2877dSHelge Deller 	}
213c9c2877dSHelge Deller 
214c9c2877dSHelge Deller 	if (ret != PDC_OK) {
215c9c2877dSHelge Deller 		pdt_type = PDT_NONE;
21654ac8fcbSHelge Deller 		pr_warn("PDT: Get PDT entries failed with %d\n", ret);
217c9c2877dSHelge Deller 		return;
218c9c2877dSHelge Deller 	}
219c9c2877dSHelge Deller 
220c9c2877dSHelge Deller 	for (i = 0; i < pdt_status.pdt_entries; i++) {
221ea697648SHelge Deller 		unsigned long addr;
222ea697648SHelge Deller 
22354ac8fcbSHelge Deller 		report_mem_err(pdt_entry[i]);
224c9c2877dSHelge Deller 
225ea697648SHelge Deller 		addr = pdt_entry[i] & PDT_ADDR_PHYS_MASK;
226ea697648SHelge Deller 		if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) &&
227ea697648SHelge Deller 			addr >= initrd_start && addr < initrd_end)
228ea697648SHelge Deller 			pr_crit("CRITICAL: initrd possibly broken "
229ea697648SHelge Deller 				"due to bad memory!\n");
230ea697648SHelge Deller 
231c9c2877dSHelge Deller 		/* mark memory page bad */
232c9c2877dSHelge Deller 		memblock_reserve(pdt_entry[i] & PAGE_MASK, PAGE_SIZE);
233c9c2877dSHelge Deller 	}
234c9c2877dSHelge Deller }
23554ac8fcbSHelge Deller 
23654ac8fcbSHelge Deller 
23754ac8fcbSHelge Deller /*
23854ac8fcbSHelge Deller  * This is the PDT kernel thread main loop.
23954ac8fcbSHelge Deller  */
24054ac8fcbSHelge Deller 
24154ac8fcbSHelge Deller static int pdt_mainloop(void *unused)
24254ac8fcbSHelge Deller {
24354ac8fcbSHelge Deller 	struct pdc_mem_read_pdt pdt_read_ret;
24454ac8fcbSHelge Deller 	struct pdc_pat_mem_read_pd_retinfo pat_pret __maybe_unused;
24554ac8fcbSHelge Deller 	unsigned long old_num_entries;
24654ac8fcbSHelge Deller 	unsigned long *bad_mem_ptr;
24754ac8fcbSHelge Deller 	int num, ret;
24854ac8fcbSHelge Deller 
24954ac8fcbSHelge Deller 	for (;;) {
25054ac8fcbSHelge Deller 		set_current_state(TASK_INTERRUPTIBLE);
25154ac8fcbSHelge Deller 
25254ac8fcbSHelge Deller 		old_num_entries = pdt_status.pdt_entries;
25354ac8fcbSHelge Deller 
25454ac8fcbSHelge Deller 		schedule_timeout(pdt_poll_interval);
25554ac8fcbSHelge Deller 		if (kthread_should_stop())
25654ac8fcbSHelge Deller 			break;
25754ac8fcbSHelge Deller 
25854ac8fcbSHelge Deller 		/* Do we have new PDT entries? */
25954ac8fcbSHelge Deller 		switch (pdt_type) {
26054ac8fcbSHelge Deller 		case PDT_PAT_NEW:
26154ac8fcbSHelge Deller 			ret = get_info_pat_new();
26254ac8fcbSHelge Deller 			break;
26354ac8fcbSHelge Deller 		case PDT_PAT_CELL:
26454ac8fcbSHelge Deller 			ret = get_info_pat_cell();
26554ac8fcbSHelge Deller 			break;
26654ac8fcbSHelge Deller 		default:
26754ac8fcbSHelge Deller 			ret = pdc_mem_pdt_info(&pdt_status);
26854ac8fcbSHelge Deller 			break;
26954ac8fcbSHelge Deller 		}
27054ac8fcbSHelge Deller 
27154ac8fcbSHelge Deller 		if (ret != PDC_OK) {
27254ac8fcbSHelge Deller 			pr_warn("PDT: unexpected failure %d\n", ret);
27354ac8fcbSHelge Deller 			return -EINVAL;
27454ac8fcbSHelge Deller 		}
27554ac8fcbSHelge Deller 
27654ac8fcbSHelge Deller 		/* if no new PDT entries, just wait again */
27754ac8fcbSHelge Deller 		num = pdt_status.pdt_entries - old_num_entries;
27854ac8fcbSHelge Deller 		if (num <= 0)
27954ac8fcbSHelge Deller 			continue;
28054ac8fcbSHelge Deller 
28154ac8fcbSHelge Deller 		/* decrease poll interval in case we found memory errors */
28254ac8fcbSHelge Deller 		if (pdt_status.pdt_entries &&
28354ac8fcbSHelge Deller 			pdt_poll_interval == PDT_POLL_INTERVAL_DEFAULT)
28454ac8fcbSHelge Deller 			pdt_poll_interval = PDT_POLL_INTERVAL_SHORT;
28554ac8fcbSHelge Deller 
28654ac8fcbSHelge Deller 		/* limit entries to get */
28754ac8fcbSHelge Deller 		if (num > MAX_PDT_ENTRIES) {
28854ac8fcbSHelge Deller 			num = MAX_PDT_ENTRIES;
28954ac8fcbSHelge Deller 			pdt_status.pdt_entries = old_num_entries + num;
29054ac8fcbSHelge Deller 		}
29154ac8fcbSHelge Deller 
29254ac8fcbSHelge Deller 		/* get new entries */
29354ac8fcbSHelge Deller 		switch (pdt_type) {
29454ac8fcbSHelge Deller #ifdef CONFIG_64BIT
29554ac8fcbSHelge Deller 		case PDT_PAT_CELL:
29654ac8fcbSHelge Deller 			if (pdt_status.pdt_entries > MAX_PDT_ENTRIES) {
29754ac8fcbSHelge Deller 				pr_crit("PDT: too many entries.\n");
29854ac8fcbSHelge Deller 				return -ENOMEM;
29954ac8fcbSHelge Deller 			}
30054ac8fcbSHelge Deller 			ret = pdc_pat_mem_read_cell_pdt(&pat_pret, pdt_entry,
30154ac8fcbSHelge Deller 				MAX_PDT_ENTRIES);
30254ac8fcbSHelge Deller 			bad_mem_ptr = &pdt_entry[old_num_entries];
30354ac8fcbSHelge Deller 			break;
30454ac8fcbSHelge Deller 		case PDT_PAT_NEW:
30554ac8fcbSHelge Deller 			ret = pdc_pat_mem_read_pd_pdt(&pat_pret,
30654ac8fcbSHelge Deller 				pdt_entry,
30754ac8fcbSHelge Deller 				num * sizeof(unsigned long),
30854ac8fcbSHelge Deller 				old_num_entries * sizeof(unsigned long));
30954ac8fcbSHelge Deller 			bad_mem_ptr = &pdt_entry[0];
31054ac8fcbSHelge Deller 			break;
31154ac8fcbSHelge Deller #endif
31254ac8fcbSHelge Deller 		default:
31354ac8fcbSHelge Deller 			ret = pdc_mem_pdt_read_entries(&pdt_read_ret,
31454ac8fcbSHelge Deller 				pdt_entry);
31554ac8fcbSHelge Deller 			bad_mem_ptr = &pdt_entry[old_num_entries];
31654ac8fcbSHelge Deller 			break;
31754ac8fcbSHelge Deller 		}
31854ac8fcbSHelge Deller 
31954ac8fcbSHelge Deller 		/* report and mark memory broken */
32054ac8fcbSHelge Deller 		while (num--) {
32154ac8fcbSHelge Deller 			unsigned long pde = *bad_mem_ptr++;
32254ac8fcbSHelge Deller 
32354ac8fcbSHelge Deller 			report_mem_err(pde);
32454ac8fcbSHelge Deller 
32554ac8fcbSHelge Deller #ifdef CONFIG_MEMORY_FAILURE
32654ac8fcbSHelge Deller 			if ((pde & PDT_ADDR_PERM_ERR) ||
32754ac8fcbSHelge Deller 			    ((pde & PDT_ADDR_SINGLE_ERR) == 0))
328*83b57531SEric W. Biederman 				memory_failure(pde >> PAGE_SHIFT, 0);
32954ac8fcbSHelge Deller 			else
33054ac8fcbSHelge Deller 				soft_offline_page(
33154ac8fcbSHelge Deller 					pfn_to_page(pde >> PAGE_SHIFT), 0);
33254ac8fcbSHelge Deller #else
33354ac8fcbSHelge Deller 			pr_crit("PDT: memory error at 0x%lx ignored.\n"
33454ac8fcbSHelge Deller 				"Rebuild kernel with CONFIG_MEMORY_FAILURE=y "
33554ac8fcbSHelge Deller 				"for real handling.\n",
33654ac8fcbSHelge Deller 				pde & PDT_ADDR_PHYS_MASK);
33754ac8fcbSHelge Deller #endif
33854ac8fcbSHelge Deller 
33954ac8fcbSHelge Deller 		}
34054ac8fcbSHelge Deller 	}
34154ac8fcbSHelge Deller 
34254ac8fcbSHelge Deller 	return 0;
34354ac8fcbSHelge Deller }
34454ac8fcbSHelge Deller 
34554ac8fcbSHelge Deller 
34654ac8fcbSHelge Deller static int __init pdt_initcall(void)
34754ac8fcbSHelge Deller {
34854ac8fcbSHelge Deller 	struct task_struct *kpdtd_task;
34954ac8fcbSHelge Deller 
35054ac8fcbSHelge Deller 	if (pdt_type == PDT_NONE)
35154ac8fcbSHelge Deller 		return -ENODEV;
35254ac8fcbSHelge Deller 
35354ac8fcbSHelge Deller 	kpdtd_task = kthread_create(pdt_mainloop, NULL, "kpdtd");
35454ac8fcbSHelge Deller 	if (IS_ERR(kpdtd_task))
35554ac8fcbSHelge Deller 		return PTR_ERR(kpdtd_task);
35654ac8fcbSHelge Deller 
35754ac8fcbSHelge Deller 	wake_up_process(kpdtd_task);
35854ac8fcbSHelge Deller 
35954ac8fcbSHelge Deller 	return 0;
36054ac8fcbSHelge Deller }
36154ac8fcbSHelge Deller 
36254ac8fcbSHelge Deller late_initcall(pdt_initcall);
363