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