From 4e0b72fd7444e07e2870d193ce8fb6b0b00f5a89 Mon Sep 17 00:00:00 2001 From: "Hans J. Koch" Date: Tue, 9 Aug 2011 20:53:41 +0200 Subject: uio: uio_pci_generic: Remove useless spin_lock The spin_lock in uio_pci_generic.c is only used in the interrupt handler, which cannot be executed twice at the same time. That makes the lock rather pointless. This patch removes it. Cc: "Michael S. Tsirkin" Cc: Chris Wright Cc: Jesse Barnes Cc: Sebastian Andrzej Siewior Cc: Anthony Foiani Reported-by: Anthony Foiani Reported-by: Sebastian Andrzej Siewior Signed-off-by: Hans J. Koch Acked-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio_pci_generic.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers') diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c index fc22e1e6f215..02bd47bdee1c 100644 --- a/drivers/uio/uio_pci_generic.c +++ b/drivers/uio/uio_pci_generic.c @@ -24,7 +24,6 @@ #include #include #include -#include #define DRIVER_VERSION "0.01.0" #define DRIVER_AUTHOR "Michael S. Tsirkin " @@ -33,7 +32,6 @@ struct uio_pci_generic_dev { struct uio_info info; struct pci_dev *pdev; - spinlock_t lock; /* guards command register accesses */ }; static inline struct uio_pci_generic_dev * @@ -57,7 +55,6 @@ static irqreturn_t irqhandler(int irq, struct uio_info *info) BUILD_BUG_ON(PCI_COMMAND % 4); BUILD_BUG_ON(PCI_COMMAND + 2 != PCI_STATUS); - spin_lock_irq(&gdev->lock); pci_block_user_cfg_access(pdev); /* Read both command and status registers in a single 32-bit operation. @@ -83,7 +80,6 @@ static irqreturn_t irqhandler(int irq, struct uio_info *info) done: pci_unblock_user_cfg_access(pdev); - spin_unlock_irq(&gdev->lock); return ret; } @@ -158,7 +154,6 @@ static int __devinit probe(struct pci_dev *pdev, gdev->info.irq_flags = IRQF_SHARED; gdev->info.handler = irqhandler; gdev->pdev = pdev; - spin_lock_init(&gdev->lock); if (uio_register_device(&pdev->dev, &gdev->info)) goto err_register; -- cgit v1.2.2 From d80df1cea036ce8b6064b3b08dd58ad3eb55a6e9 Mon Sep 17 00:00:00 2001 From: Wanlong Gao Date: Sat, 20 Aug 2011 12:12:08 +0800 Subject: drivers:uio:change the goto label to consistent with others Remove one *goto* label in uio.c. Signed-off-by: Wanlong Gao Signed-off-by: "Hans J. Koch" Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index d2efe823c20d..c89f12a8b116 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -750,14 +750,13 @@ static int uio_major_init(void) uio_major = MAJOR(uio_dev); uio_cdev = cdev; - result = 0; -out: - return result; + return 0; out_put: kobject_put(&cdev->kobj); out_unregister: unregister_chrdev_region(uio_dev, UIO_MAX_DEVICES); - goto out; +out: + return result; } static void uio_major_cleanup(void) -- cgit v1.2.2 From 9245acd20d58d5a9a3ed5ebf8c486e0609027817 Mon Sep 17 00:00:00 2001 From: Wanlong Gao Date: Sat, 20 Aug 2011 12:12:07 +0800 Subject: drivers:uio:fix section mismatch in uio_pdrv_genirq.c Remove the __devinitconst to fix the section mismatch. WARNING: drivers/uio/built-in.o(.data+0x2e8): Section mismatch in reference from the variable uio_pdrv_genirq to the variable .devinit.rodata:uio_of_genirq_match The variable uio_pdrv_genirq references the variable __devinitconst uio_of_genirq_match If the reference is valid then annotate the variable with __init* or __refdata (see linux/init.h) or name the variable: *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console Signed-off-by: Wanlong Gao Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio_pdrv_genirq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c index bae96d246760..0b2ed71e3bfa 100644 --- a/drivers/uio/uio_pdrv_genirq.c +++ b/drivers/uio/uio_pdrv_genirq.c @@ -253,7 +253,7 @@ static const struct dev_pm_ops uio_pdrv_genirq_dev_pm_ops = { }; #ifdef CONFIG_OF -static const struct of_device_id __devinitconst uio_of_genirq_match[] = { +static const struct of_device_id uio_of_genirq_match[] = { { /* empty for now */ }, }; MODULE_DEVICE_TABLE(of, uio_of_genirq_match); -- cgit v1.2.2 From 0a26813c9f528f17901b2f2394fba8557d2c9485 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Mon, 15 Aug 2011 16:51:22 +0200 Subject: drivers_base: platform: use always ->name for uevent If id_entry is available then it is used. However if we remove first the driver followed by the device, then the id_entry is pointing to driver's memory which is long gone. Since id->name and plat->name are equal there is no point in distinguishing them. Cc: Grant Likely Cc: linux-kernel@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 0cad9c7f6bb5..cd7157575e58 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -614,7 +614,7 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) return rc; add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX, - (pdev->id_entry) ? pdev->id_entry->name : pdev->name); + pdev->name); return 0; } -- cgit v1.2.2 From dd7d7fea29c18b818e94f252a76f495490d399c3 Mon Sep 17 00:00:00 2001 From: Tomoya MORINAGA Date: Thu, 21 Jul 2011 17:07:08 +0900 Subject: pch_phub: Care FUNCSEL register in PM Only ML7213/ML7223(Bus-n) has this register. Currently,this driver doesn't care register "FUNCSEL" in suspend/resume. This patch saves/restores FUNCSEL register only when the device is ML7213 or ML7223(Bus-n). Signed-off-by: Tomoya MORINAGA Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pch_phub.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c index 0fd7e77bee29..61ece53f2f41 100644 --- a/drivers/misc/pch_phub.c +++ b/drivers/misc/pch_phub.c @@ -90,6 +90,7 @@ #define PCH_PHUB_INTPIN_REG_WPERMIT_REG3 0x002C #define PCH_PHUB_INT_REDUCE_CONTROL_REG_BASE 0x0040 #define CLKCFG_REG_OFFSET 0x500 +#define FUNCSEL_REG_OFFSET 0x508 #define PCH_PHUB_OROM_SIZE 15360 @@ -108,6 +109,7 @@ * @intpin_reg_wpermit_reg3: INTPIN_REG_WPERMIT register 3 val * @int_reduce_control_reg: INT_REDUCE_CONTROL registers val * @clkcfg_reg: CLK CFG register val + * @funcsel_reg: Function select register value * @pch_phub_base_address: Register base address * @pch_phub_extrom_base_address: external rom base address * @pch_mac_start_address: MAC address area start address @@ -128,6 +130,7 @@ struct pch_phub_reg { u32 intpin_reg_wpermit_reg3; u32 int_reduce_control_reg[MAX_NUM_INT_REDUCE_CONTROL_REG]; u32 clkcfg_reg; + u32 funcsel_reg; void __iomem *pch_phub_base_address; void __iomem *pch_phub_extrom_base_address; u32 pch_mac_start_address; @@ -211,6 +214,8 @@ static void pch_phub_save_reg_conf(struct pci_dev *pdev) __func__, i, chip->int_reduce_control_reg[i]); } chip->clkcfg_reg = ioread32(p + CLKCFG_REG_OFFSET); + if ((chip->ioh_type == 2) || (chip->ioh_type == 4)) + chip->funcsel_reg = ioread32(p + FUNCSEL_REG_OFFSET); } /* pch_phub_restore_reg_conf - restore register configuration */ @@ -271,6 +276,8 @@ static void pch_phub_restore_reg_conf(struct pci_dev *pdev) } iowrite32(chip->clkcfg_reg, p + CLKCFG_REG_OFFSET); + if ((chip->ioh_type == 2) || (chip->ioh_type == 4)) + iowrite32(chip->funcsel_reg, p + FUNCSEL_REG_OFFSET); } /** -- cgit v1.2.2 From 25b8a88c10770e8c3f14bf2e222691dc6e79de78 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 18 Jul 2011 11:22:06 +0300 Subject: pch_phub: use kernel's '%pM' format option to print MAC Signed-off-by: Andy Shevchenko Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pch_phub.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c index 61ece53f2f41..dee33addcaeb 100644 --- a/drivers/misc/pch_phub.c +++ b/drivers/misc/pch_phub.c @@ -601,8 +601,7 @@ static ssize_t show_pch_mac(struct device *dev, struct device_attribute *attr, pch_phub_read_gbe_mac_addr(chip, mac); - return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + return sprintf(buf, "%pM\n", mac); } static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr, -- cgit v1.2.2 From cbc4663552ee476f57933920d782222d94878e7e Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 11 Aug 2011 14:36:21 -0400 Subject: dynamic_debug: Add __dynamic_dev_dbg Unlike dynamic_pr_debug, dynamic uses of dev_dbg can not currently add task_pid/KBUILD_MODNAME/__func__/__LINE__ to selected debug output. Add a new function similar to dynamic_pr_debug to optionally emit these prefixes. Cc: Aloisio Almeida Noticed-by: Aloisio Almeida Signed-off-by: Joe Perches Signed-off-by: Jason Baron Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/base/core.c b/drivers/base/core.c index bc8729d603a7..82c865452c70 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1764,8 +1764,8 @@ void device_shutdown(void) #ifdef CONFIG_PRINTK -static int __dev_printk(const char *level, const struct device *dev, - struct va_format *vaf) +int __dev_printk(const char *level, const struct device *dev, + struct va_format *vaf) { if (!dev) return printk("%s(NULL device *): %pV", level, vaf); @@ -1773,6 +1773,7 @@ static int __dev_printk(const char *level, const struct device *dev, return printk("%s%s %s: %pV", level, dev_driver_string(dev), dev_name(dev), vaf); } +EXPORT_SYMBOL(__dev_printk); int dev_printk(const char *level, const struct device *dev, const char *fmt, ...) -- cgit v1.2.2 From 01dcc60a7cb8cd5193676554b94a90d349bdfd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Thu, 25 Aug 2011 11:16:00 +0200 Subject: new helper to create platform devices with dma mask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compared to the most powerful and already existing helper (namely platform_device_register_resndata) this allows to specify a dma_mask. To make eventual extensions later more easy, a struct holding the used information is created instead of passing the information by function parameters. Signed-off-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 52 ++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/base/platform.c b/drivers/base/platform.c index cd7157575e58..4573f5ec9367 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -375,52 +375,64 @@ void platform_device_unregister(struct platform_device *pdev) EXPORT_SYMBOL_GPL(platform_device_unregister); /** - * platform_device_register_resndata - add a platform-level device with + * platform_device_register_full - add a platform-level device with * resources and platform-specific data * - * @parent: parent device for the device we're adding - * @name: base name of the device we're adding - * @id: instance id - * @res: set of resources that needs to be allocated for the device - * @num: number of resources - * @data: platform specific data for this platform device - * @size: size of platform specific data + * @pdevinfo: data used to create device * * Returns &struct platform_device pointer on success, or ERR_PTR() on error. */ -struct platform_device *platform_device_register_resndata( - struct device *parent, - const char *name, int id, - const struct resource *res, unsigned int num, - const void *data, size_t size) +struct platform_device *platform_device_register_full( + struct platform_device_info *pdevinfo) { int ret = -ENOMEM; struct platform_device *pdev; - pdev = platform_device_alloc(name, id); + pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id); if (!pdev) - goto err; - - pdev->dev.parent = parent; + goto err_alloc; + + pdev->dev.parent = pdevinfo->parent; + + if (pdevinfo->dma_mask) { + /* + * This memory isn't freed when the device is put, + * I don't have a nice idea for that though. Conceptually + * dma_mask in struct device should not be a pointer. + * See http://thread.gmane.org/gmane.linux.kernel.pci/9081 + */ + pdev->dev.dma_mask = + kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL); + if (!pdev->dev.dma_mask) + goto err; + + *pdev->dev.dma_mask = pdevinfo->dma_mask; + pdev->dev.coherent_dma_mask = pdevinfo->dma_mask; + } - ret = platform_device_add_resources(pdev, res, num); + ret = platform_device_add_resources(pdev, + pdevinfo->res, pdevinfo->num_res); if (ret) goto err; - ret = platform_device_add_data(pdev, data, size); + ret = platform_device_add_data(pdev, + pdevinfo->data, pdevinfo->size_data); if (ret) goto err; ret = platform_device_add(pdev); if (ret) { err: + kfree(pdev->dev.dma_mask); + +err_alloc: platform_device_put(pdev); return ERR_PTR(ret); } return pdev; } -EXPORT_SYMBOL_GPL(platform_device_register_resndata); +EXPORT_SYMBOL_GPL(platform_device_register_full); static int platform_drv_probe(struct device *_dev) { -- cgit v1.2.2 From 61b94feafa1c59a1de2719d23294dea6fd4ca362 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Thu, 15 Sep 2011 06:26:15 +1000 Subject: memory hotplug: Refuse to add unaligned memory regions The sysfs memory probe interface allows unaligned regions to be added: # echo 0xffffff > /sys/devices/system/memory/probe # cat /proc/iomem 00ffffff-01fffffe : System RAM 01ffffff-02fffffe : System RAM 02ffffff-03fffffe : System RAM 03ffffff-04fffffe : System RAM 04ffffff-05fffffe : System RAM Return -EINVAL instead of creating these bad regions. Signed-off-by: Anton Blanchard Signed-off-by: Greg Kroah-Hartman --- drivers/base/memory.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 2840ed4668c1..2a0b5f1020ed 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -380,9 +380,13 @@ memory_probe_store(struct class *class, struct class_attribute *attr, u64 phys_addr; int nid; int i, ret; + unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block; phys_addr = simple_strtoull(buf, NULL, 0); + if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1)) + return -EINVAL; + for (i = 0; i < sections_per_block; i++) { nid = memory_add_physaddr_to_nid(phys_addr); ret = add_memory(nid, phys_addr, -- cgit v1.2.2 From 54f23eb7ba7619de85d8edca6e5336bc33072dbd Mon Sep 17 00:00:00 2001 From: Nathan Fontenot Date: Mon, 26 Sep 2011 10:22:33 -0500 Subject: memory hotplug: Correct page reservation checking The check to ensure that pages of recently added memory sections are correctly marked as reserved before trying to online the memory is broken. The request to online the memory fails with the following: kernel: section number XXX page number 256 not reserved, was it already online? This updates the page reservation checking to check the pages of each memory section of the memory block being onlined individually. Signed-off-by: Nathan Fontenot Signed-off-by: Greg Kroah-Hartman --- drivers/base/memory.c | 60 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 2a0b5f1020ed..ca8bfe59ae32 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -227,41 +227,42 @@ int memory_isolate_notify(unsigned long val, void *v) * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is * OK to have direct references to sparsemem variables in here. */ +static int check_page_reservations(unsigned long phys_index) +{ + int i; + struct page *page; + + page = pfn_to_page(phys_index << PFN_SECTION_SHIFT); + + for (i = 0; i < PAGES_PER_SECTION; i++) { + if (PageReserved(page + i)) + continue; + + printk(KERN_WARNING "section number %ld page number %d " + "not reserved, was it already online?\n", phys_index, i); + return -EBUSY; + } + + return 0; +} + static int memory_block_action(unsigned long phys_index, unsigned long action) { - int i; unsigned long start_pfn, start_paddr; unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; - struct page *first_page; + struct page *page; int ret; - first_page = pfn_to_page(phys_index << PFN_SECTION_SHIFT); - - /* - * The probe routines leave the pages reserved, just - * as the bootmem code does. Make sure they're still - * that way. - */ - if (action == MEM_ONLINE) { - for (i = 0; i < nr_pages; i++) { - if (PageReserved(first_page+i)) - continue; - - printk(KERN_WARNING "section number %ld page number %d " - "not reserved, was it already online?\n", - phys_index, i); - return -EBUSY; - } - } + page = pfn_to_page(phys_index << PFN_SECTION_SHIFT); switch (action) { case MEM_ONLINE: - start_pfn = page_to_pfn(first_page); + start_pfn = page_to_pfn(page); ret = online_pages(start_pfn, nr_pages); break; case MEM_OFFLINE: - start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; + start_paddr = page_to_pfn(page) << PAGE_SHIFT; ret = remove_memory(start_paddr, nr_pages << PAGE_SHIFT); break; @@ -277,7 +278,7 @@ memory_block_action(unsigned long phys_index, unsigned long action) static int memory_block_change_state(struct memory_block *mem, unsigned long to_state, unsigned long from_state_req) { - int ret = 0; + int i, ret = 0; mutex_lock(&mem->state_mutex); @@ -289,6 +290,19 @@ static int memory_block_change_state(struct memory_block *mem, if (to_state == MEM_OFFLINE) mem->state = MEM_GOING_OFFLINE; + if (to_state == MEM_ONLINE) { + /* + * The probe routines leave the pages reserved, just + * as the bootmem code does. Make sure they're still + * that way. + */ + for (i = 0; i < sections_per_block; i++) { + ret = check_page_reservations(mem->start_section_nr + i); + if (ret) + return ret; + } + } + ret = memory_block_action(mem->start_section_nr, to_state); if (ret) -- cgit v1.2.2 From bcbe4f94d15ae1c985336bb3c35605e595fdde0d Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 20 Sep 2011 19:41:17 +0200 Subject: drivers: base: print rejected matches with DEBUG_DRIVER When DEBUG_DRIVER is activated, be verbose and explicitly state when a device<->driver match was rejected by the probe-function of the driver. Now all code-paths report what is currently happening which helps debugging, because you don't have to remember that no printout means the match is rejected (and then you still don't know if it was because of ENODEV or ENXIO). Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 6658da743c3a..142e3d600f14 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -147,6 +147,9 @@ probe_failed: printk(KERN_WARNING "%s: probe of %s failed with error %d\n", drv->name, dev_name(dev), ret); + } else { + pr_debug("%s: probe of %s rejects match %d\n", + drv->name, dev_name(dev), ret); } /* * Ignore errors returned by ->probe so that the next driver can try -- cgit v1.2.2 From 27a90700a4275c5178b883b65927affdafa5185c Mon Sep 17 00:00:00 2001 From: Kai Jiang Date: Mon, 17 Oct 2011 20:50:20 +0200 Subject: uio: Support physical addresses >32 bits on 32-bit systems To support >32-bit physical addresses for UIO_MEM_PHYS type we need to extend the width of 'addr' in struct uio_mem. Numerous platforms like embedded PPC, ARM, and X86 have support for systems with larger physical address than logical. Since 'addr' may contain a physical, logical, or virtual address the easiest solution is to just change the type to 'phys_addr_t' which should always be greater than or equal to the sizeof(void *) such that it can properly hold any of the address types. For physical address we can support up to a 44-bit physical address on a typical 32-bit system as we utilize remap_pfn_range() for the mapping of the memory region and pfn's are represnted by shifting the address by the page size (typically 4k). Signed-off-by: Kai Jiang Signed-off-by: Minghuan Lian Signed-off-by: Kumar Gala Signed-off-by: Hans J. Koch Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index c89f12a8b116..a783d533a1a6 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -69,7 +69,7 @@ static ssize_t map_name_show(struct uio_mem *mem, char *buf) static ssize_t map_addr_show(struct uio_mem *mem, char *buf) { - return sprintf(buf, "0x%lx\n", mem->addr); + return sprintf(buf, "0x%llx\n", (unsigned long long)mem->addr); } static ssize_t map_size_show(struct uio_mem *mem, char *buf) @@ -79,7 +79,7 @@ static ssize_t map_size_show(struct uio_mem *mem, char *buf) static ssize_t map_offset_show(struct uio_mem *mem, char *buf) { - return sprintf(buf, "0x%lx\n", mem->addr & ~PAGE_MASK); + return sprintf(buf, "0x%llx\n", (unsigned long long)mem->addr & ~PAGE_MASK); } struct map_sysfs_entry { @@ -634,8 +634,7 @@ static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL) page = virt_to_page(idev->info->mem[mi].addr + offset); else - page = vmalloc_to_page((void *)idev->info->mem[mi].addr - + offset); + page = vmalloc_to_page((void *)(unsigned long)idev->info->mem[mi].addr + offset); get_page(page); vmf->page = page; return 0; -- cgit v1.2.2 From de0ed36a3ecc0b51da4f16fa0af47ba6b7ffad22 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 18 Oct 2011 14:00:57 -0700 Subject: Revert "memory hotplug: Correct page reservation checking" This reverts commit 54f23eb7ba7619de85d8edca6e5336bc33072dbd. Turns out this patch is wrong, another correct one will follow it. Signed-off-by: Greg Kroah-Hartman --- drivers/base/memory.c | 60 ++++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 37 deletions(-) (limited to 'drivers') diff --git a/drivers/base/memory.c b/drivers/base/memory.c index ca8bfe59ae32..2a0b5f1020ed 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -227,42 +227,41 @@ int memory_isolate_notify(unsigned long val, void *v) * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is * OK to have direct references to sparsemem variables in here. */ -static int check_page_reservations(unsigned long phys_index) -{ - int i; - struct page *page; - - page = pfn_to_page(phys_index << PFN_SECTION_SHIFT); - - for (i = 0; i < PAGES_PER_SECTION; i++) { - if (PageReserved(page + i)) - continue; - - printk(KERN_WARNING "section number %ld page number %d " - "not reserved, was it already online?\n", phys_index, i); - return -EBUSY; - } - - return 0; -} - static int memory_block_action(unsigned long phys_index, unsigned long action) { + int i; unsigned long start_pfn, start_paddr; unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; - struct page *page; + struct page *first_page; int ret; - page = pfn_to_page(phys_index << PFN_SECTION_SHIFT); + first_page = pfn_to_page(phys_index << PFN_SECTION_SHIFT); + + /* + * The probe routines leave the pages reserved, just + * as the bootmem code does. Make sure they're still + * that way. + */ + if (action == MEM_ONLINE) { + for (i = 0; i < nr_pages; i++) { + if (PageReserved(first_page+i)) + continue; + + printk(KERN_WARNING "section number %ld page number %d " + "not reserved, was it already online?\n", + phys_index, i); + return -EBUSY; + } + } switch (action) { case MEM_ONLINE: - start_pfn = page_to_pfn(page); + start_pfn = page_to_pfn(first_page); ret = online_pages(start_pfn, nr_pages); break; case MEM_OFFLINE: - start_paddr = page_to_pfn(page) << PAGE_SHIFT; + start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; ret = remove_memory(start_paddr, nr_pages << PAGE_SHIFT); break; @@ -278,7 +277,7 @@ memory_block_action(unsigned long phys_index, unsigned long action) static int memory_block_change_state(struct memory_block *mem, unsigned long to_state, unsigned long from_state_req) { - int i, ret = 0; + int ret = 0; mutex_lock(&mem->state_mutex); @@ -290,19 +289,6 @@ static int memory_block_change_state(struct memory_block *mem, if (to_state == MEM_OFFLINE) mem->state = MEM_GOING_OFFLINE; - if (to_state == MEM_ONLINE) { - /* - * The probe routines leave the pages reserved, just - * as the bootmem code does. Make sure they're still - * that way. - */ - for (i = 0; i < sections_per_block; i++) { - ret = check_page_reservations(mem->start_section_nr + i); - if (ret) - return ret; - } - } - ret = memory_block_action(mem->start_section_nr, to_state); if (ret) -- cgit v1.2.2 From 2bbcb8788311a40714b585fc11b51da6ffa2ab92 Mon Sep 17 00:00:00 2001 From: Mel Gorman Date: Mon, 17 Oct 2011 16:38:20 +0200 Subject: mm: memory hotplug: Check if pages are correctly reserved on a per-section basis (Resending as I am not seeing it in -next so maybe it got lost) mm: memory hotplug: Check if pages are correctly reserved on a per-section basis It is expected that memory being brought online is PageReserved similar to what happens when the page allocator is being brought up. Memory is onlined in "memory blocks" which consist of one or more sections. Unfortunately, the code that verifies PageReserved is currently assuming that the memmap backing all these pages is virtually contiguous which is only the case when CONFIG_SPARSEMEM_VMEMMAP is set. As a result, memory hot-add is failing on those configurations with the message; kernel: section number XXX page number 256 not reserved, was it already online? This patch updates the PageReserved check to lookup struct page once per section to guarantee the correct struct page is being checked. [Check pages within sections properly: rientjes@google.com] [original patch by: nfont@linux.vnet.ibm.com] Signed-off-by: Mel Gorman Acked-by: KAMEZAWA Hiroyuki Tested-by: Nathan Fontenot Signed-off-by: Greg Kroah-Hartman --- drivers/base/memory.c | 58 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 2a0b5f1020ed..8272d92d22c0 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -223,6 +223,42 @@ int memory_isolate_notify(unsigned long val, void *v) return atomic_notifier_call_chain(&memory_isolate_chain, val, v); } +/* + * The probe routines leave the pages reserved, just as the bootmem code does. + * Make sure they're still that way. + */ +static bool pages_correctly_reserved(unsigned long start_pfn, + unsigned long nr_pages) +{ + int i, j; + struct page *page; + unsigned long pfn = start_pfn; + + /* + * memmap between sections is not contiguous except with + * SPARSEMEM_VMEMMAP. We lookup the page once per section + * and assume memmap is contiguous within each section + */ + for (i = 0; i < sections_per_block; i++, pfn += PAGES_PER_SECTION) { + if (WARN_ON_ONCE(!pfn_valid(pfn))) + return false; + page = pfn_to_page(pfn); + + for (j = 0; j < PAGES_PER_SECTION; j++) { + if (PageReserved(page + j)) + continue; + + printk(KERN_WARNING "section number %ld page number %d " + "not reserved, was it already online?\n", + pfn_to_section_nr(pfn), j); + + return false; + } + } + + return true; +} + /* * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is * OK to have direct references to sparsemem variables in here. @@ -230,7 +266,6 @@ int memory_isolate_notify(unsigned long val, void *v) static int memory_block_action(unsigned long phys_index, unsigned long action) { - int i; unsigned long start_pfn, start_paddr; unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; struct page *first_page; @@ -238,26 +273,13 @@ memory_block_action(unsigned long phys_index, unsigned long action) first_page = pfn_to_page(phys_index << PFN_SECTION_SHIFT); - /* - * The probe routines leave the pages reserved, just - * as the bootmem code does. Make sure they're still - * that way. - */ - if (action == MEM_ONLINE) { - for (i = 0; i < nr_pages; i++) { - if (PageReserved(first_page+i)) - continue; - - printk(KERN_WARNING "section number %ld page number %d " - "not reserved, was it already online?\n", - phys_index, i); - return -EBUSY; - } - } - switch (action) { case MEM_ONLINE: start_pfn = page_to_pfn(first_page); + + if (!pages_correctly_reserved(start_pfn, nr_pages)) + return -EBUSY; + ret = online_pages(start_pfn, nr_pages); break; case MEM_OFFLINE: -- cgit v1.2.2