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