Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'akpm' (incoming from Andrew Morton)

Merge fixes from Andrew Morton:
"A bunch of fixes and one simple fbdev driver which missed the merge
window because people will still talking about it (to no great
effect)."

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (30 commits)
aio: fix kioctx not being freed after cancellation at exit time
mm/pagewalk.c: walk_page_range should avoid VM_PFNMAP areas
drivers/rtc/rtc-max8998.c: check for pdata presence before dereferencing
ocfs2: goto out_unlock if ocfs2_get_clusters_nocache() failed in ocfs2_fiemap()
random: fix accounting race condition with lockless irq entropy_count update
drivers/char/random.c: fix priming of last_data
mm/memory_hotplug.c: fix printk format warnings
nilfs2: fix issue of nilfs_set_page_dirty() for page at EOF boundary
drivers/block/brd.c: fix brd_lookup_page() race
fbdev: FB_GOLDFISH should depend on HAS_DMA
drivers/rtc/rtc-pl031.c: pass correct pointer to free_irq()
auditfilter.c: fix kernel-doc warnings
aio: fix io_getevents documentation
revert "selftest: add simple test for soft-dirty bit"
drivers/leds/leds-ot200.c: fix error caused by shifted mask
mm/THP: use pmd_populate() to update the pmd with pgtable_t pointer
linux/kernel.h: fix kernel-doc warning
mm compaction: fix of improper cache flush in migration code
rapidio/tsi721: fix bug in MSI interrupt handling
hfs: avoid crash in hfs_bnode_create
...

+1034 -420
+25
Documentation/devicetree/bindings/video/simple-framebuffer.txt
··· 1 + Simple Framebuffer 2 + 3 + A simple frame-buffer describes a raw memory region that may be rendered to, 4 + with the assumption that the display hardware has already been set up to scan 5 + out from that buffer. 6 + 7 + Required properties: 8 + - compatible: "simple-framebuffer" 9 + - reg: Should contain the location and size of the framebuffer memory. 10 + - width: The width of the framebuffer in pixels. 11 + - height: The height of the framebuffer in pixels. 12 + - stride: The number of bytes in each line of the framebuffer. 13 + - format: The format of the framebuffer surface. Valid values are: 14 + - r5g6b5 (16-bit pixels, d[15:11]=r, d[10:5]=g, d[4:0]=b). 15 + 16 + Example: 17 + 18 + framebuffer { 19 + compatible = "simple-framebuffer"; 20 + reg = <0x1d385000 (1600 * 1200 * 2)>; 21 + width = <1600>; 22 + height = <1200>; 23 + stride = <(1600 * 2)>; 24 + format = "r5g6b5"; 25 + };
+117 -11
Documentation/rapidio/rapidio.txt
··· 79 79 In order to initialize the RapidIO subsystem, a platform must initialize and 80 80 register at least one master port within the RapidIO network. To register mport 81 81 within the subsystem controller driver initialization code calls function 82 - rio_register_mport() for each available master port. After all active master 83 - ports are registered with a RapidIO subsystem, the rio_init_mports() routine 84 - is called to perform enumeration and discovery. 82 + rio_register_mport() for each available master port. 85 83 86 - In the current PowerPC-based implementation a subsys_initcall() is specified to 87 - perform controller initialization and mport registration. At the end it directly 88 - calls rio_init_mports() to execute RapidIO enumeration and discovery. 84 + RapidIO subsystem uses subsys_initcall() or device_initcall() to perform 85 + controller initialization (depending on controller device type). 86 + 87 + After all active master ports are registered with a RapidIO subsystem, 88 + an enumeration and/or discovery routine may be called automatically or 89 + by user-space command. 89 90 90 91 4. Enumeration and Discovery 91 92 ---------------------------- 92 93 93 - When rio_init_mports() is called it scans a list of registered master ports and 94 - calls an enumeration or discovery routine depending on the configured role of a 95 - master port: host or agent. 94 + 4.1 Overview 95 + ------------ 96 + 97 + RapidIO subsystem configuration options allow users to specify enumeration and 98 + discovery methods as statically linked components or loadable modules. 99 + An enumeration/discovery method implementation and available input parameters 100 + define how any given method can be attached to available RapidIO mports: 101 + simply to all available mports OR individually to the specified mport device. 102 + 103 + Depending on selected enumeration/discovery build configuration, there are 104 + several methods to initiate an enumeration and/or discovery process: 105 + 106 + (a) Statically linked enumeration and discovery process can be started 107 + automatically during kernel initialization time using corresponding module 108 + parameters. This was the original method used since introduction of RapidIO 109 + subsystem. Now this method relies on enumerator module parameter which is 110 + 'rio-scan.scan' for existing basic enumeration/discovery method. 111 + When automatic start of enumeration/discovery is used a user has to ensure 112 + that all discovering endpoints are started before the enumerating endpoint 113 + and are waiting for enumeration to be completed. 114 + Configuration option CONFIG_RAPIDIO_DISC_TIMEOUT defines time that discovering 115 + endpoint waits for enumeration to be completed. If the specified timeout 116 + expires the discovery process is terminated without obtaining RapidIO network 117 + information. NOTE: a timed out discovery process may be restarted later using 118 + a user-space command as it is described later if the given endpoint was 119 + enumerated successfully. 120 + 121 + (b) Statically linked enumeration and discovery process can be started by 122 + a command from user space. This initiation method provides more flexibility 123 + for a system startup compared to the option (a) above. After all participating 124 + endpoints have been successfully booted, an enumeration process shall be 125 + started first by issuing a user-space command, after an enumeration is 126 + completed a discovery process can be started on all remaining endpoints. 127 + 128 + (c) Modular enumeration and discovery process can be started by a command from 129 + user space. After an enumeration/discovery module is loaded, a network scan 130 + process can be started by issuing a user-space command. 131 + Similar to the option (b) above, an enumerator has to be started first. 132 + 133 + (d) Modular enumeration and discovery process can be started by a module 134 + initialization routine. In this case an enumerating module shall be loaded 135 + first. 136 + 137 + When a network scan process is started it calls an enumeration or discovery 138 + routine depending on the configured role of a master port: host or agent. 96 139 97 140 Enumeration is performed by a master port if it is configured as a host port by 98 141 assigning a host device ID greater than or equal to zero. A host device ID is ··· 147 104 The enumeration and discovery routines use RapidIO maintenance transactions 148 105 to access the configuration space of devices. 149 106 150 - The enumeration process is implemented according to the enumeration algorithm 151 - outlined in the RapidIO Interconnect Specification: Annex I [1]. 107 + 4.2 Automatic Start of Enumeration and Discovery 108 + ------------------------------------------------ 109 + 110 + Automatic enumeration/discovery start method is applicable only to built-in 111 + enumeration/discovery RapidIO configuration selection. To enable automatic 112 + enumeration/discovery start by existing basic enumerator method set use boot 113 + command line parameter "rio-scan.scan=1". 114 + 115 + This configuration requires synchronized start of all RapidIO endpoints that 116 + form a network which will be enumerated/discovered. Discovering endpoints have 117 + to be started before an enumeration starts to ensure that all RapidIO 118 + controllers have been initialized and are ready to be discovered. Configuration 119 + parameter CONFIG_RAPIDIO_DISC_TIMEOUT defines time (in seconds) which 120 + a discovering endpoint will wait for enumeration to be completed. 121 + 122 + When automatic enumeration/discovery start is selected, basic method's 123 + initialization routine calls rio_init_mports() to perform enumeration or 124 + discovery for all known mport devices. 125 + 126 + Depending on RapidIO network size and configuration this automatic 127 + enumeration/discovery start method may be difficult to use due to the 128 + requirement for synchronized start of all endpoints. 129 + 130 + 4.3 User-space Start of Enumeration and Discovery 131 + ------------------------------------------------- 132 + 133 + User-space start of enumeration and discovery can be used with built-in and 134 + modular build configurations. For user-space controlled start RapidIO subsystem 135 + creates the sysfs write-only attribute file '/sys/bus/rapidio/scan'. To initiate 136 + an enumeration or discovery process on specific mport device, a user needs to 137 + write mport_ID (not RapidIO destination ID) into that file. The mport_ID is a 138 + sequential number (0 ... RIO_MAX_MPORTS) assigned during mport device 139 + registration. For example for machine with single RapidIO controller, mport_ID 140 + for that controller always will be 0. 141 + 142 + To initiate RapidIO enumeration/discovery on all available mports a user may 143 + write '-1' (or RIO_MPORT_ANY) into the scan attribute file. 144 + 145 + 4.4 Basic Enumeration Method 146 + ---------------------------- 147 + 148 + This is an original enumeration/discovery method which is available since 149 + first release of RapidIO subsystem code. The enumeration process is 150 + implemented according to the enumeration algorithm outlined in the RapidIO 151 + Interconnect Specification: Annex I [1]. 152 + 153 + This method can be configured as statically linked or loadable module. 154 + The method's single parameter "scan" allows to trigger the enumeration/discovery 155 + process from module initialization routine. 156 + 157 + This enumeration/discovery method can be started only once and does not support 158 + unloading if it is built as a module. 152 159 153 160 The enumeration process traverses the network using a recursive depth-first 154 161 algorithm. When a new device is found, the enumerator takes ownership of that ··· 252 159 time period. If this wait time period expires before enumeration is completed, 253 160 an agent skips RapidIO discovery and continues with remaining kernel 254 161 initialization. 162 + 163 + 4.5 Adding New Enumeration/Discovery Method 164 + ------------------------------------------- 165 + 166 + RapidIO subsystem code organization allows addition of new enumeration/discovery 167 + methods as new configuration options without significant impact to to the core 168 + RapidIO code. 169 + 170 + A new enumeration/discovery method has to be attached to one or more mport 171 + devices before an enumeration/discovery process can be started. Normally, 172 + method's module initialization routine calls rio_register_scan() to attach 173 + an enumerator to a specified mport device (or devices). The basic enumerator 174 + implementation demonstrates this process. 255 175 256 176 5. References 257 177 -------------
+17
Documentation/rapidio/sysfs.txt
··· 88 88 89 89 IDT_GEN2: 90 90 errlog - reads contents of device error log until it is empty. 91 + 92 + 93 + 5. RapidIO Bus Attributes 94 + ------------------------- 95 + 96 + RapidIO bus subdirectory /sys/bus/rapidio implements the following bus-specific 97 + attribute: 98 + 99 + scan - allows to trigger enumeration discovery process from user space. This 100 + is a write-only attribute. To initiate an enumeration or discovery 101 + process on specific mport device, a user needs to write mport_ID (not 102 + RapidIO destination ID) into this file. The mport_ID is a sequential 103 + number (0 ... RIO_MAX_MPORTS) assigned to the mport device. 104 + For example, for a machine with a single RapidIO controller, mport_ID 105 + for that controller always will be 0. 106 + To initiate RapidIO enumeration/discovery on all available mports 107 + a user must write '-1' (or RIO_MPORT_ANY) into this attribute file.
+2 -2
drivers/block/brd.c
··· 117 117 118 118 spin_lock(&brd->brd_lock); 119 119 idx = sector >> PAGE_SECTORS_SHIFT; 120 + page->index = idx; 120 121 if (radix_tree_insert(&brd->brd_pages, idx, page)) { 121 122 __free_page(page); 122 123 page = radix_tree_lookup(&brd->brd_pages, idx); 123 124 BUG_ON(!page); 124 125 BUG_ON(page->index != idx); 125 - } else 126 - page->index = idx; 126 + } 127 127 spin_unlock(&brd->brd_lock); 128 128 129 129 radix_tree_preload_end();
+1 -2
drivers/block/xsysace.c
··· 1160 1160 dev_dbg(&dev->dev, "ace_probe(%p)\n", dev); 1161 1161 1162 1162 /* device id and bus width */ 1163 - of_property_read_u32(dev->dev.of_node, "port-number", &id); 1164 - if (id < 0) 1163 + if (of_property_read_u32(dev->dev.of_node, "port-number", &id)) 1165 1164 id = 0; 1166 1165 if (of_find_property(dev->dev.of_node, "8-bit", NULL)) 1167 1166 bus_width = ACE_BUS_WIDTH_8;
+30 -22
drivers/char/random.c
··· 865 865 if (r->entropy_count / 8 < min + reserved) { 866 866 nbytes = 0; 867 867 } else { 868 + int entropy_count, orig; 869 + retry: 870 + entropy_count = orig = ACCESS_ONCE(r->entropy_count); 868 871 /* If limited, never pull more than available */ 869 - if (r->limit && nbytes + reserved >= r->entropy_count / 8) 870 - nbytes = r->entropy_count/8 - reserved; 872 + if (r->limit && nbytes + reserved >= entropy_count / 8) 873 + nbytes = entropy_count/8 - reserved; 871 874 872 - if (r->entropy_count / 8 >= nbytes + reserved) 873 - r->entropy_count -= nbytes*8; 874 - else 875 - r->entropy_count = reserved; 875 + if (entropy_count / 8 >= nbytes + reserved) { 876 + entropy_count -= nbytes*8; 877 + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) 878 + goto retry; 879 + } else { 880 + entropy_count = reserved; 881 + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) 882 + goto retry; 883 + } 876 884 877 - if (r->entropy_count < random_write_wakeup_thresh) 885 + if (entropy_count < random_write_wakeup_thresh) 878 886 wakeup_write = 1; 879 887 } 880 888 ··· 965 957 { 966 958 ssize_t ret = 0, i; 967 959 __u8 tmp[EXTRACT_SIZE]; 960 + unsigned long flags; 968 961 969 962 /* if last_data isn't primed, we need EXTRACT_SIZE extra bytes */ 970 - if (fips_enabled && !r->last_data_init) 971 - nbytes += EXTRACT_SIZE; 963 + if (fips_enabled) { 964 + spin_lock_irqsave(&r->lock, flags); 965 + if (!r->last_data_init) { 966 + r->last_data_init = true; 967 + spin_unlock_irqrestore(&r->lock, flags); 968 + trace_extract_entropy(r->name, EXTRACT_SIZE, 969 + r->entropy_count, _RET_IP_); 970 + xfer_secondary_pool(r, EXTRACT_SIZE); 971 + extract_buf(r, tmp); 972 + spin_lock_irqsave(&r->lock, flags); 973 + memcpy(r->last_data, tmp, EXTRACT_SIZE); 974 + } 975 + spin_unlock_irqrestore(&r->lock, flags); 976 + } 972 977 973 978 trace_extract_entropy(r->name, nbytes, r->entropy_count, _RET_IP_); 974 979 xfer_secondary_pool(r, nbytes); ··· 991 970 extract_buf(r, tmp); 992 971 993 972 if (fips_enabled) { 994 - unsigned long flags; 995 - 996 - 997 - /* prime last_data value if need be, per fips 140-2 */ 998 - if (!r->last_data_init) { 999 - spin_lock_irqsave(&r->lock, flags); 1000 - memcpy(r->last_data, tmp, EXTRACT_SIZE); 1001 - r->last_data_init = true; 1002 - nbytes -= EXTRACT_SIZE; 1003 - spin_unlock_irqrestore(&r->lock, flags); 1004 - extract_buf(r, tmp); 1005 - } 1006 - 1007 973 spin_lock_irqsave(&r->lock, flags); 1008 974 if (!memcmp(tmp, r->last_data, EXTRACT_SIZE)) 1009 975 panic("Hardware RNG duplicated output!\n");
+7 -7
drivers/leds/leds-ot200.c
··· 47 47 { 48 48 .name = "led_1", 49 49 .port = 0x49, 50 - .mask = BIT(7), 50 + .mask = BIT(6), 51 51 }, 52 52 { 53 53 .name = "led_2", 54 54 .port = 0x49, 55 - .mask = BIT(6), 55 + .mask = BIT(5), 56 56 }, 57 57 { 58 58 .name = "led_3", 59 59 .port = 0x49, 60 - .mask = BIT(5), 60 + .mask = BIT(4), 61 61 }, 62 62 { 63 63 .name = "led_4", 64 64 .port = 0x49, 65 - .mask = BIT(4), 65 + .mask = BIT(3), 66 66 }, 67 67 { 68 68 .name = "led_5", 69 69 .port = 0x49, 70 - .mask = BIT(3), 70 + .mask = BIT(2), 71 71 }, 72 72 { 73 73 .name = "led_6", 74 74 .port = 0x49, 75 - .mask = BIT(2), 75 + .mask = BIT(1), 76 76 }, 77 77 { 78 78 .name = "led_7", 79 79 .port = 0x49, 80 - .mask = BIT(1), 80 + .mask = BIT(0), 81 81 } 82 82 }; 83 83
+20
drivers/rapidio/Kconfig
··· 47 47 48 48 If you are unsure about this, say N here. 49 49 50 + choice 51 + prompt "Enumeration method" 52 + depends on RAPIDIO 53 + default RAPIDIO_ENUM_BASIC 54 + help 55 + There are different enumeration and discovery mechanisms offered 56 + for RapidIO subsystem. You may select single built-in method or 57 + or any number of methods to be built as modules. 58 + Selecting a built-in method disables use of loadable methods. 59 + 60 + If unsure, select Basic built-in. 61 + 62 + config RAPIDIO_ENUM_BASIC 63 + tristate "Basic" 64 + help 65 + This option includes basic RapidIO fabric enumeration and discovery 66 + mechanism similar to one described in RapidIO specification Annex 1. 67 + 68 + endchoice 69 + 50 70 source "drivers/rapidio/switches/Kconfig"
+2 -1
drivers/rapidio/Makefile
··· 1 1 # 2 2 # Makefile for RapidIO interconnect services 3 3 # 4 - obj-y += rio.o rio-access.o rio-driver.o rio-scan.o rio-sysfs.o 4 + obj-y += rio.o rio-access.o rio-driver.o rio-sysfs.o 5 + obj-$(CONFIG_RAPIDIO_ENUM_BASIC) += rio-scan.o 5 6 6 7 obj-$(CONFIG_RAPIDIO) += switches/ 7 8 obj-$(CONFIG_RAPIDIO) += devices/
+12
drivers/rapidio/devices/tsi721.c
··· 471 471 u32 intval; 472 472 u32 ch_inte; 473 473 474 + /* For MSI mode disable all device-level interrupts */ 475 + if (priv->flags & TSI721_USING_MSI) 476 + iowrite32(0, priv->regs + TSI721_DEV_INTE); 477 + 474 478 dev_int = ioread32(priv->regs + TSI721_DEV_INT); 475 479 if (!dev_int) 476 480 return IRQ_NONE; ··· 564 560 } 565 561 } 566 562 #endif 563 + 564 + /* For MSI mode re-enable device-level interrupts */ 565 + if (priv->flags & TSI721_USING_MSI) { 566 + dev_int = TSI721_DEV_INT_SR2PC_CH | TSI721_DEV_INT_SRIO | 567 + TSI721_DEV_INT_SMSG_CH | TSI721_DEV_INT_BDMA_CH; 568 + iowrite32(dev_int, priv->regs + TSI721_DEV_INTE); 569 + } 570 + 567 571 return IRQ_HANDLED; 568 572 } 569 573
+8
drivers/rapidio/rio-driver.c
··· 164 164 driver_unregister(&rdrv->driver); 165 165 } 166 166 167 + void rio_attach_device(struct rio_dev *rdev) 168 + { 169 + rdev->dev.bus = &rio_bus_type; 170 + rdev->dev.parent = &rio_bus; 171 + } 172 + EXPORT_SYMBOL_GPL(rio_attach_device); 173 + 167 174 /** 168 175 * rio_match_bus - Tell if a RIO device structure has a matching RIO driver device id structure 169 176 * @dev: the standard device structure to match against ··· 207 200 .name = "rapidio", 208 201 .match = rio_match_bus, 209 202 .dev_attrs = rio_dev_attrs, 203 + .bus_attrs = rio_bus_attrs, 210 204 .probe = rio_device_probe, 211 205 .remove = rio_device_remove, 212 206 };
+60 -130
drivers/rapidio/rio-scan.c
··· 37 37 38 38 #include "rio.h" 39 39 40 - LIST_HEAD(rio_devices); 41 - 42 40 static void rio_init_em(struct rio_dev *rdev); 43 - 44 - DEFINE_SPINLOCK(rio_global_list_lock); 45 41 46 42 static int next_destid = 0; 47 43 static int next_comptag = 1; ··· 323 327 } 324 328 325 329 /** 326 - * rio_switch_init - Sets switch operations for a particular vendor switch 327 - * @rdev: RIO device 328 - * @do_enum: Enumeration/Discovery mode flag 329 - * 330 - * Searches the RIO switch ops table for known switch types. If the vid 331 - * and did match a switch table entry, then call switch initialization 332 - * routine to setup switch-specific routines. 333 - */ 334 - static void rio_switch_init(struct rio_dev *rdev, int do_enum) 335 - { 336 - struct rio_switch_ops *cur = __start_rio_switch_ops; 337 - struct rio_switch_ops *end = __end_rio_switch_ops; 338 - 339 - while (cur < end) { 340 - if ((cur->vid == rdev->vid) && (cur->did == rdev->did)) { 341 - pr_debug("RIO: calling init routine for %s\n", 342 - rio_name(rdev)); 343 - cur->init_hook(rdev, do_enum); 344 - break; 345 - } 346 - cur++; 347 - } 348 - 349 - if ((cur >= end) && (rdev->pef & RIO_PEF_STD_RT)) { 350 - pr_debug("RIO: adding STD routing ops for %s\n", 351 - rio_name(rdev)); 352 - rdev->rswitch->add_entry = rio_std_route_add_entry; 353 - rdev->rswitch->get_entry = rio_std_route_get_entry; 354 - rdev->rswitch->clr_table = rio_std_route_clr_table; 355 - } 356 - 357 - if (!rdev->rswitch->add_entry || !rdev->rswitch->get_entry) 358 - printk(KERN_ERR "RIO: missing routing ops for %s\n", 359 - rio_name(rdev)); 360 - } 361 - 362 - /** 363 - * rio_add_device- Adds a RIO device to the device model 364 - * @rdev: RIO device 365 - * 366 - * Adds the RIO device to the global device list and adds the RIO 367 - * device to the RIO device list. Creates the generic sysfs nodes 368 - * for an RIO device. 369 - */ 370 - static int rio_add_device(struct rio_dev *rdev) 371 - { 372 - int err; 373 - 374 - err = device_add(&rdev->dev); 375 - if (err) 376 - return err; 377 - 378 - spin_lock(&rio_global_list_lock); 379 - list_add_tail(&rdev->global_list, &rio_devices); 380 - spin_unlock(&rio_global_list_lock); 381 - 382 - rio_create_sysfs_dev_files(rdev); 383 - 384 - return 0; 385 - } 386 - 387 - /** 388 - * rio_enable_rx_tx_port - enable input receiver and output transmitter of 389 - * given port 390 - * @port: Master port associated with the RIO network 391 - * @local: local=1 select local port otherwise a far device is reached 392 - * @destid: Destination ID of the device to check host bit 393 - * @hopcount: Number of hops to reach the target 394 - * @port_num: Port (-number on switch) to enable on a far end device 395 - * 396 - * Returns 0 or 1 from on General Control Command and Status Register 397 - * (EXT_PTR+0x3C) 398 - */ 399 - inline int rio_enable_rx_tx_port(struct rio_mport *port, 400 - int local, u16 destid, 401 - u8 hopcount, u8 port_num) { 402 - #ifdef CONFIG_RAPIDIO_ENABLE_RX_TX_PORTS 403 - u32 regval; 404 - u32 ext_ftr_ptr; 405 - 406 - /* 407 - * enable rx input tx output port 408 - */ 409 - pr_debug("rio_enable_rx_tx_port(local = %d, destid = %d, hopcount = " 410 - "%d, port_num = %d)\n", local, destid, hopcount, port_num); 411 - 412 - ext_ftr_ptr = rio_mport_get_physefb(port, local, destid, hopcount); 413 - 414 - if (local) { 415 - rio_local_read_config_32(port, ext_ftr_ptr + 416 - RIO_PORT_N_CTL_CSR(0), 417 - &regval); 418 - } else { 419 - if (rio_mport_read_config_32(port, destid, hopcount, 420 - ext_ftr_ptr + RIO_PORT_N_CTL_CSR(port_num), &regval) < 0) 421 - return -EIO; 422 - } 423 - 424 - if (regval & RIO_PORT_N_CTL_P_TYP_SER) { 425 - /* serial */ 426 - regval = regval | RIO_PORT_N_CTL_EN_RX_SER 427 - | RIO_PORT_N_CTL_EN_TX_SER; 428 - } else { 429 - /* parallel */ 430 - regval = regval | RIO_PORT_N_CTL_EN_RX_PAR 431 - | RIO_PORT_N_CTL_EN_TX_PAR; 432 - } 433 - 434 - if (local) { 435 - rio_local_write_config_32(port, ext_ftr_ptr + 436 - RIO_PORT_N_CTL_CSR(0), regval); 437 - } else { 438 - if (rio_mport_write_config_32(port, destid, hopcount, 439 - ext_ftr_ptr + RIO_PORT_N_CTL_CSR(port_num), regval) < 0) 440 - return -EIO; 441 - } 442 - #endif 443 - return 0; 444 - } 445 - 446 - /** 447 330 * rio_setup_device- Allocates and sets up a RIO device 448 331 * @net: RIO network 449 332 * @port: Master port to send transactions ··· 462 587 rdev->destid); 463 588 } 464 589 465 - rdev->dev.bus = &rio_bus_type; 466 - rdev->dev.parent = &rio_bus; 590 + rio_attach_device(rdev); 467 591 468 592 device_initialize(&rdev->dev); 469 593 rdev->dev.release = rio_release_dev; ··· 1134 1260 /** 1135 1261 * rio_enum_mport- Start enumeration through a master port 1136 1262 * @mport: Master port to send transactions 1263 + * @flags: Enumeration control flags 1137 1264 * 1138 1265 * Starts the enumeration process. If somebody has enumerated our 1139 1266 * master port device, then give up. If not and we have an active 1140 1267 * link, then start recursive peer enumeration. Returns %0 if 1141 1268 * enumeration succeeds or %-EBUSY if enumeration fails. 1142 1269 */ 1143 - int rio_enum_mport(struct rio_mport *mport) 1270 + int rio_enum_mport(struct rio_mport *mport, u32 flags) 1144 1271 { 1145 1272 struct rio_net *net = NULL; 1146 1273 int rc = 0; 1147 1274 1148 1275 printk(KERN_INFO "RIO: enumerate master port %d, %s\n", mport->id, 1149 1276 mport->name); 1277 + 1278 + /* 1279 + * To avoid multiple start requests (repeat enumeration is not supported 1280 + * by this method) check if enumeration/discovery was performed for this 1281 + * mport: if mport was added into the list of mports for a net exit 1282 + * with error. 1283 + */ 1284 + if (mport->nnode.next || mport->nnode.prev) 1285 + return -EBUSY; 1286 + 1150 1287 /* If somebody else enumerated our master port device, bail. */ 1151 1288 if (rio_enum_host(mport) < 0) { 1152 1289 printk(KERN_INFO ··· 1247 1362 /** 1248 1363 * rio_disc_mport- Start discovery through a master port 1249 1364 * @mport: Master port to send transactions 1365 + * @flags: discovery control flags 1250 1366 * 1251 1367 * Starts the discovery process. If we have an active link, 1252 - * then wait for the signal that enumeration is complete. 1368 + * then wait for the signal that enumeration is complete (if wait 1369 + * is allowed). 1253 1370 * When enumeration completion is signaled, start recursive 1254 1371 * peer discovery. Returns %0 if discovery succeeds or %-EBUSY 1255 1372 * on failure. 1256 1373 */ 1257 - int rio_disc_mport(struct rio_mport *mport) 1374 + int rio_disc_mport(struct rio_mport *mport, u32 flags) 1258 1375 { 1259 1376 struct rio_net *net = NULL; 1260 1377 unsigned long to_end; ··· 1266 1379 1267 1380 /* If master port has an active link, allocate net and discover peers */ 1268 1381 if (rio_mport_is_active(mport)) { 1382 + if (rio_enum_complete(mport)) 1383 + goto enum_done; 1384 + else if (flags & RIO_SCAN_ENUM_NO_WAIT) 1385 + return -EAGAIN; 1386 + 1269 1387 pr_debug("RIO: wait for enumeration to complete...\n"); 1270 1388 1271 1389 to_end = jiffies + CONFIG_RAPIDIO_DISC_TIMEOUT * HZ; ··· 1313 1421 bail: 1314 1422 return -EBUSY; 1315 1423 } 1424 + 1425 + static struct rio_scan rio_scan_ops = { 1426 + .enumerate = rio_enum_mport, 1427 + .discover = rio_disc_mport, 1428 + }; 1429 + 1430 + static bool scan; 1431 + module_param(scan, bool, 0); 1432 + MODULE_PARM_DESC(scan, "Start RapidIO network enumeration/discovery " 1433 + "(default = 0)"); 1434 + 1435 + /** 1436 + * rio_basic_attach: 1437 + * 1438 + * When this enumeration/discovery method is loaded as a module this function 1439 + * registers its specific enumeration and discover routines for all available 1440 + * RapidIO mport devices. The "scan" command line parameter controls ability of 1441 + * the module to start RapidIO enumeration/discovery automatically. 1442 + * 1443 + * Returns 0 for success or -EIO if unable to register itself. 1444 + * 1445 + * This enumeration/discovery method cannot be unloaded and therefore does not 1446 + * provide a matching cleanup_module routine. 1447 + */ 1448 + 1449 + static int __init rio_basic_attach(void) 1450 + { 1451 + if (rio_register_scan(RIO_MPORT_ANY, &rio_scan_ops)) 1452 + return -EIO; 1453 + if (scan) 1454 + rio_init_mports(); 1455 + return 0; 1456 + } 1457 + 1458 + late_initcall(rio_basic_attach); 1459 + 1460 + MODULE_DESCRIPTION("Basic RapidIO enumeration/discovery"); 1461 + MODULE_LICENSE("GPL");
+45
drivers/rapidio/rio-sysfs.c
··· 285 285 rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE); 286 286 } 287 287 } 288 + 289 + static ssize_t bus_scan_store(struct bus_type *bus, const char *buf, 290 + size_t count) 291 + { 292 + long val; 293 + struct rio_mport *port = NULL; 294 + int rc; 295 + 296 + if (kstrtol(buf, 0, &val) < 0) 297 + return -EINVAL; 298 + 299 + if (val == RIO_MPORT_ANY) { 300 + rc = rio_init_mports(); 301 + goto exit; 302 + } 303 + 304 + if (val < 0 || val >= RIO_MAX_MPORTS) 305 + return -EINVAL; 306 + 307 + port = rio_find_mport((int)val); 308 + 309 + if (!port) { 310 + pr_debug("RIO: %s: mport_%d not available\n", 311 + __func__, (int)val); 312 + return -EINVAL; 313 + } 314 + 315 + if (!port->nscan) 316 + return -EINVAL; 317 + 318 + if (port->host_deviceid >= 0) 319 + rc = port->nscan->enumerate(port, 0); 320 + else 321 + rc = port->nscan->discover(port, RIO_SCAN_ENUM_NO_WAIT); 322 + exit: 323 + if (!rc) 324 + rc = count; 325 + 326 + return rc; 327 + } 328 + 329 + struct bus_attribute rio_bus_attrs[] = { 330 + __ATTR(scan, (S_IWUSR|S_IWGRP), NULL, bus_scan_store), 331 + __ATTR_NULL 332 + };
+239 -7
drivers/rapidio/rio.c
··· 31 31 32 32 #include "rio.h" 33 33 34 + static LIST_HEAD(rio_devices); 35 + static DEFINE_SPINLOCK(rio_global_list_lock); 36 + 34 37 static LIST_HEAD(rio_mports); 38 + static DEFINE_MUTEX(rio_mport_list_lock); 35 39 static unsigned char next_portid; 36 40 static DEFINE_SPINLOCK(rio_mmap_lock); 37 41 ··· 55 51 56 52 return (RIO_GET_DID(port->sys_size, result)); 57 53 } 54 + 55 + /** 56 + * rio_add_device- Adds a RIO device to the device model 57 + * @rdev: RIO device 58 + * 59 + * Adds the RIO device to the global device list and adds the RIO 60 + * device to the RIO device list. Creates the generic sysfs nodes 61 + * for an RIO device. 62 + */ 63 + int rio_add_device(struct rio_dev *rdev) 64 + { 65 + int err; 66 + 67 + err = device_add(&rdev->dev); 68 + if (err) 69 + return err; 70 + 71 + spin_lock(&rio_global_list_lock); 72 + list_add_tail(&rdev->global_list, &rio_devices); 73 + spin_unlock(&rio_global_list_lock); 74 + 75 + rio_create_sysfs_dev_files(rdev); 76 + 77 + return 0; 78 + } 79 + EXPORT_SYMBOL_GPL(rio_add_device); 58 80 59 81 /** 60 82 * rio_request_inb_mbox - request inbound mailbox service ··· 519 489 520 490 return ext_ftr_ptr; 521 491 } 492 + EXPORT_SYMBOL_GPL(rio_mport_get_physefb); 522 493 523 494 /** 524 495 * rio_get_comptag - Begin or continue searching for a RIO device by component tag ··· 552 521 spin_unlock(&rio_global_list_lock); 553 522 return rdev; 554 523 } 524 + EXPORT_SYMBOL_GPL(rio_get_comptag); 555 525 556 526 /** 557 527 * rio_set_port_lockout - Sets/clears LOCKOUT bit (RIO EM 1.3) for a switch port. ··· 577 545 regval); 578 546 return 0; 579 547 } 548 + EXPORT_SYMBOL_GPL(rio_set_port_lockout); 549 + 550 + /** 551 + * rio_switch_init - Sets switch operations for a particular vendor switch 552 + * @rdev: RIO device 553 + * @do_enum: Enumeration/Discovery mode flag 554 + * 555 + * Searches the RIO switch ops table for known switch types. If the vid 556 + * and did match a switch table entry, then call switch initialization 557 + * routine to setup switch-specific routines. 558 + */ 559 + void rio_switch_init(struct rio_dev *rdev, int do_enum) 560 + { 561 + struct rio_switch_ops *cur = __start_rio_switch_ops; 562 + struct rio_switch_ops *end = __end_rio_switch_ops; 563 + 564 + while (cur < end) { 565 + if ((cur->vid == rdev->vid) && (cur->did == rdev->did)) { 566 + pr_debug("RIO: calling init routine for %s\n", 567 + rio_name(rdev)); 568 + cur->init_hook(rdev, do_enum); 569 + break; 570 + } 571 + cur++; 572 + } 573 + 574 + if ((cur >= end) && (rdev->pef & RIO_PEF_STD_RT)) { 575 + pr_debug("RIO: adding STD routing ops for %s\n", 576 + rio_name(rdev)); 577 + rdev->rswitch->add_entry = rio_std_route_add_entry; 578 + rdev->rswitch->get_entry = rio_std_route_get_entry; 579 + rdev->rswitch->clr_table = rio_std_route_clr_table; 580 + } 581 + 582 + if (!rdev->rswitch->add_entry || !rdev->rswitch->get_entry) 583 + printk(KERN_ERR "RIO: missing routing ops for %s\n", 584 + rio_name(rdev)); 585 + } 586 + EXPORT_SYMBOL_GPL(rio_switch_init); 587 + 588 + /** 589 + * rio_enable_rx_tx_port - enable input receiver and output transmitter of 590 + * given port 591 + * @port: Master port associated with the RIO network 592 + * @local: local=1 select local port otherwise a far device is reached 593 + * @destid: Destination ID of the device to check host bit 594 + * @hopcount: Number of hops to reach the target 595 + * @port_num: Port (-number on switch) to enable on a far end device 596 + * 597 + * Returns 0 or 1 from on General Control Command and Status Register 598 + * (EXT_PTR+0x3C) 599 + */ 600 + int rio_enable_rx_tx_port(struct rio_mport *port, 601 + int local, u16 destid, 602 + u8 hopcount, u8 port_num) 603 + { 604 + #ifdef CONFIG_RAPIDIO_ENABLE_RX_TX_PORTS 605 + u32 regval; 606 + u32 ext_ftr_ptr; 607 + 608 + /* 609 + * enable rx input tx output port 610 + */ 611 + pr_debug("rio_enable_rx_tx_port(local = %d, destid = %d, hopcount = " 612 + "%d, port_num = %d)\n", local, destid, hopcount, port_num); 613 + 614 + ext_ftr_ptr = rio_mport_get_physefb(port, local, destid, hopcount); 615 + 616 + if (local) { 617 + rio_local_read_config_32(port, ext_ftr_ptr + 618 + RIO_PORT_N_CTL_CSR(0), 619 + &regval); 620 + } else { 621 + if (rio_mport_read_config_32(port, destid, hopcount, 622 + ext_ftr_ptr + RIO_PORT_N_CTL_CSR(port_num), &regval) < 0) 623 + return -EIO; 624 + } 625 + 626 + if (regval & RIO_PORT_N_CTL_P_TYP_SER) { 627 + /* serial */ 628 + regval = regval | RIO_PORT_N_CTL_EN_RX_SER 629 + | RIO_PORT_N_CTL_EN_TX_SER; 630 + } else { 631 + /* parallel */ 632 + regval = regval | RIO_PORT_N_CTL_EN_RX_PAR 633 + | RIO_PORT_N_CTL_EN_TX_PAR; 634 + } 635 + 636 + if (local) { 637 + rio_local_write_config_32(port, ext_ftr_ptr + 638 + RIO_PORT_N_CTL_CSR(0), regval); 639 + } else { 640 + if (rio_mport_write_config_32(port, destid, hopcount, 641 + ext_ftr_ptr + RIO_PORT_N_CTL_CSR(port_num), regval) < 0) 642 + return -EIO; 643 + } 644 + #endif 645 + return 0; 646 + } 647 + EXPORT_SYMBOL_GPL(rio_enable_rx_tx_port); 648 + 580 649 581 650 /** 582 651 * rio_chk_dev_route - Validate route to the specified device. ··· 743 610 744 611 return 0; 745 612 } 613 + EXPORT_SYMBOL_GPL(rio_mport_chk_dev_access); 746 614 747 615 /** 748 616 * rio_chk_dev_access - Validate access to the specified device. ··· 1075 941 return RIO_GET_BLOCK_ID(reg_val); 1076 942 } 1077 943 } 944 + EXPORT_SYMBOL_GPL(rio_mport_get_efb); 1078 945 1079 946 /** 1080 947 * rio_mport_get_feature - query for devices' extended features ··· 1132 997 1133 998 return 0; 1134 999 } 1000 + EXPORT_SYMBOL_GPL(rio_mport_get_feature); 1135 1001 1136 1002 /** 1137 1003 * rio_get_asm - Begin or continue searching for a RIO device by vid/did/asm_vid/asm_did ··· 1382 1246 1383 1247 #endif /* CONFIG_RAPIDIO_DMA_ENGINE */ 1384 1248 1249 + /** 1250 + * rio_find_mport - find RIO mport by its ID 1251 + * @mport_id: number (ID) of mport device 1252 + * 1253 + * Given a RIO mport number, the desired mport is located 1254 + * in the global list of mports. If the mport is found, a pointer to its 1255 + * data structure is returned. If no mport is found, %NULL is returned. 1256 + */ 1257 + struct rio_mport *rio_find_mport(int mport_id) 1258 + { 1259 + struct rio_mport *port; 1260 + 1261 + mutex_lock(&rio_mport_list_lock); 1262 + list_for_each_entry(port, &rio_mports, node) { 1263 + if (port->id == mport_id) 1264 + goto found; 1265 + } 1266 + port = NULL; 1267 + found: 1268 + mutex_unlock(&rio_mport_list_lock); 1269 + 1270 + return port; 1271 + } 1272 + 1273 + /** 1274 + * rio_register_scan - enumeration/discovery method registration interface 1275 + * @mport_id: mport device ID for which fabric scan routine has to be set 1276 + * (RIO_MPORT_ANY = set for all available mports) 1277 + * @scan_ops: enumeration/discovery control structure 1278 + * 1279 + * Assigns enumeration or discovery method to the specified mport device (or all 1280 + * available mports if RIO_MPORT_ANY is specified). 1281 + * Returns error if the mport already has an enumerator attached to it. 1282 + * In case of RIO_MPORT_ANY ignores ports with valid scan routines and returns 1283 + * an error if was unable to find at least one available mport. 1284 + */ 1285 + int rio_register_scan(int mport_id, struct rio_scan *scan_ops) 1286 + { 1287 + struct rio_mport *port; 1288 + int rc = -EBUSY; 1289 + 1290 + mutex_lock(&rio_mport_list_lock); 1291 + list_for_each_entry(port, &rio_mports, node) { 1292 + if (port->id == mport_id || mport_id == RIO_MPORT_ANY) { 1293 + if (port->nscan && mport_id == RIO_MPORT_ANY) 1294 + continue; 1295 + else if (port->nscan) 1296 + break; 1297 + 1298 + port->nscan = scan_ops; 1299 + rc = 0; 1300 + 1301 + if (mport_id != RIO_MPORT_ANY) 1302 + break; 1303 + } 1304 + } 1305 + mutex_unlock(&rio_mport_list_lock); 1306 + 1307 + return rc; 1308 + } 1309 + EXPORT_SYMBOL_GPL(rio_register_scan); 1310 + 1311 + /** 1312 + * rio_unregister_scan - removes enumeration/discovery method from mport 1313 + * @mport_id: mport device ID for which fabric scan routine has to be 1314 + * unregistered (RIO_MPORT_ANY = set for all available mports) 1315 + * 1316 + * Removes enumeration or discovery method assigned to the specified mport 1317 + * device (or all available mports if RIO_MPORT_ANY is specified). 1318 + */ 1319 + int rio_unregister_scan(int mport_id) 1320 + { 1321 + struct rio_mport *port; 1322 + 1323 + mutex_lock(&rio_mport_list_lock); 1324 + list_for_each_entry(port, &rio_mports, node) { 1325 + if (port->id == mport_id || mport_id == RIO_MPORT_ANY) { 1326 + if (port->nscan) 1327 + port->nscan = NULL; 1328 + if (mport_id != RIO_MPORT_ANY) 1329 + break; 1330 + } 1331 + } 1332 + mutex_unlock(&rio_mport_list_lock); 1333 + 1334 + return 0; 1335 + } 1336 + EXPORT_SYMBOL_GPL(rio_unregister_scan); 1337 + 1385 1338 static void rio_fixup_device(struct rio_dev *dev) 1386 1339 { 1387 1340 } ··· 1499 1274 work = container_of(_work, struct rio_disc_work, work); 1500 1275 pr_debug("RIO: discovery work for mport %d %s\n", 1501 1276 work->mport->id, work->mport->name); 1502 - rio_disc_mport(work->mport); 1277 + work->mport->nscan->discover(work->mport, 0); 1503 1278 } 1504 1279 1505 1280 int rio_init_mports(void) ··· 1515 1290 * First, run enumerations and check if we need to perform discovery 1516 1291 * on any of the registered mports. 1517 1292 */ 1293 + mutex_lock(&rio_mport_list_lock); 1518 1294 list_for_each_entry(port, &rio_mports, node) { 1519 - if (port->host_deviceid >= 0) 1520 - rio_enum_mport(port); 1521 - else 1295 + if (port->host_deviceid >= 0) { 1296 + if (port->nscan) 1297 + port->nscan->enumerate(port, 0); 1298 + } else 1522 1299 n++; 1523 1300 } 1301 + mutex_unlock(&rio_mport_list_lock); 1524 1302 1525 1303 if (!n) 1526 1304 goto no_disc; ··· 1550 1322 } 1551 1323 1552 1324 n = 0; 1325 + mutex_lock(&rio_mport_list_lock); 1553 1326 list_for_each_entry(port, &rio_mports, node) { 1554 - if (port->host_deviceid < 0) { 1327 + if (port->host_deviceid < 0 && port->nscan) { 1555 1328 work[n].mport = port; 1556 1329 INIT_WORK(&work[n].work, disc_work_handler); 1557 1330 queue_work(rio_wq, &work[n].work); 1558 1331 n++; 1559 1332 } 1560 1333 } 1334 + mutex_unlock(&rio_mport_list_lock); 1561 1335 1562 1336 flush_workqueue(rio_wq); 1563 1337 pr_debug("RIO: destroy discovery workqueue\n"); ··· 1571 1341 1572 1342 return 0; 1573 1343 } 1574 - 1575 - device_initcall_sync(rio_init_mports); 1576 1344 1577 1345 static int hdids[RIO_MAX_MPORTS + 1]; 1578 1346 ··· 1599 1371 1600 1372 port->id = next_portid++; 1601 1373 port->host_deviceid = rio_get_hdid(port->id); 1374 + port->nscan = NULL; 1375 + mutex_lock(&rio_mport_list_lock); 1602 1376 list_add_tail(&port->node, &rio_mports); 1377 + mutex_unlock(&rio_mport_list_lock); 1603 1378 return 0; 1604 1379 } 1605 1380 ··· 1617 1386 EXPORT_SYMBOL_GPL(rio_release_inb_mbox); 1618 1387 EXPORT_SYMBOL_GPL(rio_request_outb_mbox); 1619 1388 EXPORT_SYMBOL_GPL(rio_release_outb_mbox); 1389 + EXPORT_SYMBOL_GPL(rio_init_mports);
+10 -3
drivers/rapidio/rio.h
··· 15 15 #include <linux/rio.h> 16 16 17 17 #define RIO_MAX_CHK_RETRY 3 18 + #define RIO_MPORT_ANY (-1) 18 19 19 20 /* Functions internal to the RIO core code */ 20 21 ··· 28 27 extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, 29 28 u8 hopcount); 30 29 extern int rio_create_sysfs_dev_files(struct rio_dev *rdev); 31 - extern int rio_enum_mport(struct rio_mport *mport); 32 - extern int rio_disc_mport(struct rio_mport *mport); 33 30 extern int rio_std_route_add_entry(struct rio_mport *mport, u16 destid, 34 31 u8 hopcount, u16 table, u16 route_destid, 35 32 u8 route_port); ··· 38 39 u8 hopcount, u16 table); 39 40 extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock); 40 41 extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from); 42 + extern int rio_add_device(struct rio_dev *rdev); 43 + extern void rio_switch_init(struct rio_dev *rdev, int do_enum); 44 + extern int rio_enable_rx_tx_port(struct rio_mport *port, int local, u16 destid, 45 + u8 hopcount, u8 port_num); 46 + extern int rio_register_scan(int mport_id, struct rio_scan *scan_ops); 47 + extern int rio_unregister_scan(int mport_id); 48 + extern void rio_attach_device(struct rio_dev *rdev); 49 + extern struct rio_mport *rio_find_mport(int mport_id); 41 50 42 51 /* Structures internal to the RIO core code */ 43 52 extern struct device_attribute rio_dev_attrs[]; 44 - extern spinlock_t rio_global_list_lock; 53 + extern struct bus_attribute rio_bus_attrs[]; 45 54 46 55 extern struct rio_switch_ops __start_rio_switch_ops[]; 47 56 extern struct rio_switch_ops __end_rio_switch_ops[];
+1 -1
drivers/rtc/rtc-max8998.c
··· 285 285 info->irq, ret); 286 286 287 287 dev_info(&pdev->dev, "RTC CHIP NAME: %s\n", pdev->id_entry->name); 288 - if (pdata->rtc_delay) { 288 + if (pdata && pdata->rtc_delay) { 289 289 info->lp3974_bug_workaround = true; 290 290 dev_warn(&pdev->dev, "LP3974 with RTC REGERR option." 291 291 " RTC updates will be extremely slow.\n");
+1 -1
drivers/rtc/rtc-pl031.c
··· 306 306 struct pl031_local *ldata = dev_get_drvdata(&adev->dev); 307 307 308 308 amba_set_drvdata(adev, NULL); 309 - free_irq(adev->irq[0], ldata->rtc); 309 + free_irq(adev->irq[0], ldata); 310 310 rtc_device_unregister(ldata->rtc); 311 311 iounmap(ldata->base); 312 312 kfree(ldata);
+18 -1
drivers/video/Kconfig
··· 2199 2199 2200 2200 config FB_GOLDFISH 2201 2201 tristate "Goldfish Framebuffer" 2202 - depends on FB 2202 + depends on FB && HAS_DMA 2203 2203 select FB_CFB_FILLRECT 2204 2204 select FB_CFB_COPYAREA 2205 2205 select FB_CFB_IMAGEBLIT ··· 2452 2452 select FB_CFB_IMAGEBLIT 2453 2453 help 2454 2454 This framebuffer driver supports Microsoft Hyper-V Synthetic Video. 2455 + 2456 + config FB_SIMPLE 2457 + bool "Simple framebuffer support" 2458 + depends on (FB = y) && OF 2459 + select FB_CFB_FILLRECT 2460 + select FB_CFB_COPYAREA 2461 + select FB_CFB_IMAGEBLIT 2462 + help 2463 + Say Y if you want support for a simple frame-buffer. 2464 + 2465 + This driver assumes that the display hardware has been initialized 2466 + before the kernel boots, and the kernel will simply render to the 2467 + pre-allocated frame buffer surface. 2468 + 2469 + Configuration re: surface address, size, and format must be provided 2470 + through device tree, or potentially plain old platform data in the 2471 + future. 2455 2472 2456 2473 source "drivers/video/omap/Kconfig" 2457 2474 source "drivers/video/omap2/Kconfig"
+1
drivers/video/Makefile
··· 166 166 obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o 167 167 obj-$(CONFIG_FB_MXS) += mxsfb.o 168 168 obj-$(CONFIG_FB_SSD1307) += ssd1307fb.o 169 + obj-$(CONFIG_FB_SIMPLE) += simplefb.o 169 170 170 171 # the test framebuffer is last 171 172 obj-$(CONFIG_FB_VIRTUAL) += vfb.o
+234
drivers/video/simplefb.c
··· 1 + /* 2 + * Simplest possible simple frame-buffer driver, as a platform device 3 + * 4 + * Copyright (c) 2013, Stephen Warren 5 + * 6 + * Based on q40fb.c, which was: 7 + * Copyright (C) 2001 Richard Zidlicky <rz@linux-m68k.org> 8 + * 9 + * Also based on offb.c, which was: 10 + * Copyright (C) 1997 Geert Uytterhoeven 11 + * Copyright (C) 1996 Paul Mackerras 12 + * 13 + * This program is free software; you can redistribute it and/or modify it 14 + * under the terms and conditions of the GNU General Public License, 15 + * version 2, as published by the Free Software Foundation. 16 + * 17 + * This program is distributed in the hope it will be useful, but WITHOUT 18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 20 + * more details. 21 + */ 22 + 23 + #include <linux/errno.h> 24 + #include <linux/fb.h> 25 + #include <linux/io.h> 26 + #include <linux/module.h> 27 + #include <linux/platform_device.h> 28 + 29 + static struct fb_fix_screeninfo simplefb_fix = { 30 + .id = "simple", 31 + .type = FB_TYPE_PACKED_PIXELS, 32 + .visual = FB_VISUAL_TRUECOLOR, 33 + .accel = FB_ACCEL_NONE, 34 + }; 35 + 36 + static struct fb_var_screeninfo simplefb_var = { 37 + .height = -1, 38 + .width = -1, 39 + .activate = FB_ACTIVATE_NOW, 40 + .vmode = FB_VMODE_NONINTERLACED, 41 + }; 42 + 43 + static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, 44 + u_int transp, struct fb_info *info) 45 + { 46 + u32 *pal = info->pseudo_palette; 47 + u32 cr = red >> (16 - info->var.red.length); 48 + u32 cg = green >> (16 - info->var.green.length); 49 + u32 cb = blue >> (16 - info->var.blue.length); 50 + u32 value; 51 + 52 + if (regno >= 16) 53 + return -EINVAL; 54 + 55 + value = (cr << info->var.red.offset) | 56 + (cg << info->var.green.offset) | 57 + (cb << info->var.blue.offset); 58 + if (info->var.transp.length > 0) { 59 + u32 mask = (1 << info->var.transp.length) - 1; 60 + mask <<= info->var.transp.offset; 61 + value |= mask; 62 + } 63 + pal[regno] = value; 64 + 65 + return 0; 66 + } 67 + 68 + static struct fb_ops simplefb_ops = { 69 + .owner = THIS_MODULE, 70 + .fb_setcolreg = simplefb_setcolreg, 71 + .fb_fillrect = cfb_fillrect, 72 + .fb_copyarea = cfb_copyarea, 73 + .fb_imageblit = cfb_imageblit, 74 + }; 75 + 76 + struct simplefb_format { 77 + const char *name; 78 + u32 bits_per_pixel; 79 + struct fb_bitfield red; 80 + struct fb_bitfield green; 81 + struct fb_bitfield blue; 82 + struct fb_bitfield transp; 83 + }; 84 + 85 + static struct simplefb_format simplefb_formats[] = { 86 + { "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0} }, 87 + }; 88 + 89 + struct simplefb_params { 90 + u32 width; 91 + u32 height; 92 + u32 stride; 93 + struct simplefb_format *format; 94 + }; 95 + 96 + static int simplefb_parse_dt(struct platform_device *pdev, 97 + struct simplefb_params *params) 98 + { 99 + struct device_node *np = pdev->dev.of_node; 100 + int ret; 101 + const char *format; 102 + int i; 103 + 104 + ret = of_property_read_u32(np, "width", &params->width); 105 + if (ret) { 106 + dev_err(&pdev->dev, "Can't parse width property\n"); 107 + return ret; 108 + } 109 + 110 + ret = of_property_read_u32(np, "height", &params->height); 111 + if (ret) { 112 + dev_err(&pdev->dev, "Can't parse height property\n"); 113 + return ret; 114 + } 115 + 116 + ret = of_property_read_u32(np, "stride", &params->stride); 117 + if (ret) { 118 + dev_err(&pdev->dev, "Can't parse stride property\n"); 119 + return ret; 120 + } 121 + 122 + ret = of_property_read_string(np, "format", &format); 123 + if (ret) { 124 + dev_err(&pdev->dev, "Can't parse format property\n"); 125 + return ret; 126 + } 127 + params->format = NULL; 128 + for (i = 0; i < ARRAY_SIZE(simplefb_formats); i++) { 129 + if (strcmp(format, simplefb_formats[i].name)) 130 + continue; 131 + params->format = &simplefb_formats[i]; 132 + break; 133 + } 134 + if (!params->format) { 135 + dev_err(&pdev->dev, "Invalid format value\n"); 136 + return -EINVAL; 137 + } 138 + 139 + return 0; 140 + } 141 + 142 + static int simplefb_probe(struct platform_device *pdev) 143 + { 144 + int ret; 145 + struct simplefb_params params; 146 + struct fb_info *info; 147 + struct resource *mem; 148 + 149 + if (fb_get_options("simplefb", NULL)) 150 + return -ENODEV; 151 + 152 + ret = simplefb_parse_dt(pdev, &params); 153 + if (ret) 154 + return ret; 155 + 156 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 157 + if (!mem) { 158 + dev_err(&pdev->dev, "No memory resource\n"); 159 + return -EINVAL; 160 + } 161 + 162 + info = framebuffer_alloc(sizeof(u32) * 16, &pdev->dev); 163 + if (!info) 164 + return -ENOMEM; 165 + platform_set_drvdata(pdev, info); 166 + 167 + info->fix = simplefb_fix; 168 + info->fix.smem_start = mem->start; 169 + info->fix.smem_len = resource_size(mem); 170 + info->fix.line_length = params.stride; 171 + 172 + info->var = simplefb_var; 173 + info->var.xres = params.width; 174 + info->var.yres = params.height; 175 + info->var.xres_virtual = params.width; 176 + info->var.yres_virtual = params.height; 177 + info->var.bits_per_pixel = params.format->bits_per_pixel; 178 + info->var.red = params.format->red; 179 + info->var.green = params.format->green; 180 + info->var.blue = params.format->blue; 181 + info->var.transp = params.format->transp; 182 + 183 + info->fbops = &simplefb_ops; 184 + info->flags = FBINFO_DEFAULT; 185 + info->screen_base = devm_ioremap(&pdev->dev, info->fix.smem_start, 186 + info->fix.smem_len); 187 + if (!info->screen_base) { 188 + framebuffer_release(info); 189 + return -ENODEV; 190 + } 191 + info->pseudo_palette = (void *)(info + 1); 192 + 193 + ret = register_framebuffer(info); 194 + if (ret < 0) { 195 + dev_err(&pdev->dev, "Unable to register simplefb: %d\n", ret); 196 + framebuffer_release(info); 197 + return ret; 198 + } 199 + 200 + dev_info(&pdev->dev, "fb%d: simplefb registered!\n", info->node); 201 + 202 + return 0; 203 + } 204 + 205 + static int simplefb_remove(struct platform_device *pdev) 206 + { 207 + struct fb_info *info = platform_get_drvdata(pdev); 208 + 209 + unregister_framebuffer(info); 210 + framebuffer_release(info); 211 + 212 + return 0; 213 + } 214 + 215 + static const struct of_device_id simplefb_of_match[] = { 216 + { .compatible = "simple-framebuffer", }, 217 + { }, 218 + }; 219 + MODULE_DEVICE_TABLE(of, simplefb_of_match); 220 + 221 + static struct platform_driver simplefb_driver = { 222 + .driver = { 223 + .name = "simple-framebuffer", 224 + .owner = THIS_MODULE, 225 + .of_match_table = simplefb_of_match, 226 + }, 227 + .probe = simplefb_probe, 228 + .remove = simplefb_remove, 229 + }; 230 + module_platform_driver(simplefb_driver); 231 + 232 + MODULE_AUTHOR("Stephen Warren <swarren@wwwdotorg.org>"); 233 + MODULE_DESCRIPTION("Simple framebuffer driver"); 234 + MODULE_LICENSE("GPL v2");
+4 -3
fs/aio.c
··· 307 307 kunmap_atomic(ring); 308 308 309 309 while (atomic_read(&ctx->reqs_active) > 0) { 310 - wait_event(ctx->wait, head != ctx->tail); 310 + wait_event(ctx->wait, 311 + head != ctx->tail || 312 + atomic_read(&ctx->reqs_active) <= 0); 311 313 312 314 avail = (head <= ctx->tail ? ctx->tail : ctx->nr_events) - head; 313 315 ··· 1301 1299 * < min_nr if the timeout specified by timeout has elapsed 1302 1300 * before sufficient events are available, where timeout == NULL 1303 1301 * specifies an infinite timeout. Note that the timeout pointed to by 1304 - * timeout is relative and will be updated if not NULL and the 1305 - * operation blocks. Will fail with -ENOSYS if not implemented. 1302 + * timeout is relative. Will fail with -ENOSYS if not implemented. 1306 1303 */ 1307 1304 SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id, 1308 1305 long, min_nr,
+14 -1
fs/fat/inode.c
··· 1229 1229 return 0; 1230 1230 } 1231 1231 1232 + static unsigned long calc_fat_clusters(struct super_block *sb) 1233 + { 1234 + struct msdos_sb_info *sbi = MSDOS_SB(sb); 1235 + 1236 + /* Divide first to avoid overflow */ 1237 + if (sbi->fat_bits != 12) { 1238 + unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits; 1239 + return ent_per_sec * sbi->fat_length; 1240 + } 1241 + 1242 + return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits; 1243 + } 1244 + 1232 1245 /* 1233 1246 * Read the super block of an MS-DOS FS. 1234 1247 */ ··· 1447 1434 sbi->dirty = b->fat16.state & FAT_STATE_DIRTY; 1448 1435 1449 1436 /* check that FAT table does not overflow */ 1450 - fat_clusters = sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits; 1437 + fat_clusters = calc_fat_clusters(sb); 1451 1438 total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT); 1452 1439 if (total_clusters > MAX_FAT(sb)) { 1453 1440 if (!silent)
+5 -1
fs/hfs/bnode.c
··· 415 415 spin_lock(&tree->hash_lock); 416 416 node = hfs_bnode_findhash(tree, num); 417 417 spin_unlock(&tree->hash_lock); 418 - BUG_ON(node); 418 + if (node) { 419 + pr_crit("new node %u already hashed?\n", num); 420 + WARN_ON(1); 421 + return node; 422 + } 419 423 node = __hfs_bnode_create(tree, num); 420 424 if (!node) 421 425 return ERR_PTR(-ENOMEM);
+23 -4
fs/nilfs2/inode.c
··· 219 219 220 220 static int nilfs_set_page_dirty(struct page *page) 221 221 { 222 - int ret = __set_page_dirty_buffers(page); 222 + int ret = __set_page_dirty_nobuffers(page); 223 223 224 - if (ret) { 224 + if (page_has_buffers(page)) { 225 225 struct inode *inode = page->mapping->host; 226 - unsigned nr_dirty = 1 << (PAGE_SHIFT - inode->i_blkbits); 226 + unsigned nr_dirty = 0; 227 + struct buffer_head *bh, *head; 227 228 228 - nilfs_set_file_dirty(inode, nr_dirty); 229 + /* 230 + * This page is locked by callers, and no other thread 231 + * concurrently marks its buffers dirty since they are 232 + * only dirtied through routines in fs/buffer.c in 233 + * which call sites of mark_buffer_dirty are protected 234 + * by page lock. 235 + */ 236 + bh = head = page_buffers(page); 237 + do { 238 + /* Do not mark hole blocks dirty */ 239 + if (buffer_dirty(bh) || !buffer_mapped(bh)) 240 + continue; 241 + 242 + set_buffer_dirty(bh); 243 + nr_dirty++; 244 + } while (bh = bh->b_this_page, bh != head); 245 + 246 + if (nr_dirty) 247 + nilfs_set_file_dirty(inode, nr_dirty); 229 248 } 230 249 return ret; 231 250 }
+1 -1
fs/ocfs2/extent_map.c
··· 790 790 &hole_size, &rec, &is_last); 791 791 if (ret) { 792 792 mlog_errno(ret); 793 - goto out; 793 + goto out_unlock; 794 794 } 795 795 796 796 if (rec.e_blkno == 0ULL) {
+1 -1
fs/ocfs2/file.c
··· 2288 2288 ret = ocfs2_inode_lock(inode, NULL, 1); 2289 2289 if (ret < 0) { 2290 2290 mlog_errno(ret); 2291 - goto out_sems; 2291 + goto out; 2292 2292 } 2293 2293 2294 2294 ocfs2_inode_unlock(inode, 1);
+3 -2
include/linux/kernel.h
··· 562 562 extern __printf(2, 3) 563 563 int __trace_printk(unsigned long ip, const char *fmt, ...); 564 564 565 + extern int __trace_bputs(unsigned long ip, const char *str); 566 + extern int __trace_puts(unsigned long ip, const char *str, int size); 567 + 565 568 /** 566 569 * trace_puts - write a string into the ftrace buffer 567 570 * @str: the string to record ··· 590 587 * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) 591 588 */ 592 589 593 - extern int __trace_bputs(unsigned long ip, const char *str); 594 - extern int __trace_puts(unsigned long ip, const char *str, int size); 595 590 #define trace_puts(str) ({ \ 596 591 static const char *trace_printk_fmt \ 597 592 __attribute__((section("__trace_printk_fmt"))) = \
+17 -1
include/linux/rio.h
··· 83 83 84 84 extern struct bus_type rio_bus_type; 85 85 extern struct device rio_bus; 86 - extern struct list_head rio_devices; /* list of all devices */ 87 86 88 87 struct rio_mport; 89 88 struct rio_dev; ··· 236 237 * @name: Port name string 237 238 * @priv: Master port private data 238 239 * @dma: DMA device associated with mport 240 + * @nscan: RapidIO network enumeration/discovery operations 239 241 */ 240 242 struct rio_mport { 241 243 struct list_head dbells; /* list of doorbell events */ ··· 262 262 #ifdef CONFIG_RAPIDIO_DMA_ENGINE 263 263 struct dma_device dma; 264 264 #endif 265 + struct rio_scan *nscan; 265 266 }; 267 + 268 + /* 269 + * Enumeration/discovery control flags 270 + */ 271 + #define RIO_SCAN_ENUM_NO_WAIT 0x00000001 /* Do not wait for enum completed */ 266 272 267 273 struct rio_id_table { 268 274 u16 start; /* logical minimal id */ ··· 465 459 return container_of(ddev, struct rio_mport, dma); 466 460 } 467 461 #endif /* CONFIG_RAPIDIO_DMA_ENGINE */ 462 + 463 + /** 464 + * struct rio_scan - RIO enumeration and discovery operations 465 + * @enumerate: Callback to perform RapidIO fabric enumeration. 466 + * @discover: Callback to perform RapidIO fabric discovery. 467 + */ 468 + struct rio_scan { 469 + int (*enumerate)(struct rio_mport *mport, u32 flags); 470 + int (*discover)(struct rio_mport *mport, u32 flags); 471 + }; 468 472 469 473 /* Architecture and hardware-specific functions */ 470 474 extern int rio_register_mport(struct rio_mport *);
+1
include/linux/rio_drv.h
··· 433 433 extern struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from); 434 434 extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did, 435 435 struct rio_dev *from); 436 + extern int rio_init_mports(void); 436 437 437 438 #endif /* LINUX_RIO_DRV_H */
+11 -5
include/linux/wait.h
··· 217 217 if (!ret) \ 218 218 break; \ 219 219 } \ 220 + if (!ret && (condition)) \ 221 + ret = 1; \ 220 222 finish_wait(&wq, &__wait); \ 221 223 } while (0) 222 224 ··· 235 233 * wake_up() has to be called after changing any variable that could 236 234 * change the result of the wait condition. 237 235 * 238 - * The function returns 0 if the @timeout elapsed, and the remaining 239 - * jiffies if the condition evaluated to true before the timeout elapsed. 236 + * The function returns 0 if the @timeout elapsed, or the remaining 237 + * jiffies (at least 1) if the @condition evaluated to %true before 238 + * the @timeout elapsed. 240 239 */ 241 240 #define wait_event_timeout(wq, condition, timeout) \ 242 241 ({ \ ··· 305 302 ret = -ERESTARTSYS; \ 306 303 break; \ 307 304 } \ 305 + if (!ret && (condition)) \ 306 + ret = 1; \ 308 307 finish_wait(&wq, &__wait); \ 309 308 } while (0) 310 309 ··· 323 318 * wake_up() has to be called after changing any variable that could 324 319 * change the result of the wait condition. 325 320 * 326 - * The function returns 0 if the @timeout elapsed, -ERESTARTSYS if it 327 - * was interrupted by a signal, and the remaining jiffies otherwise 328 - * if the condition evaluated to true before the timeout elapsed. 321 + * Returns: 322 + * 0 if the @timeout elapsed, -%ERESTARTSYS if it was interrupted by 323 + * a signal, or the remaining jiffies (at least 1) if the @condition 324 + * evaluated to %true before the @timeout elapsed. 329 325 */ 330 326 #define wait_event_interruptible_timeout(wq, condition, timeout) \ 331 327 ({ \
-3
kernel/auditfilter.c
··· 1021 1021 * @seq: netlink audit message sequence (serial) number 1022 1022 * @data: payload data 1023 1023 * @datasz: size of payload data 1024 - * @loginuid: loginuid of sender 1025 - * @sessionid: sessionid for netlink audit message 1026 - * @sid: SE Linux Security ID of sender 1027 1024 */ 1028 1025 int audit_receive_filter(int type, int pid, int seq, void *data, size_t datasz) 1029 1026 {
+6 -1
mm/huge_memory.c
··· 2325 2325 pte_unmap(pte); 2326 2326 spin_lock(&mm->page_table_lock); 2327 2327 BUG_ON(!pmd_none(*pmd)); 2328 - set_pmd_at(mm, address, pmd, _pmd); 2328 + /* 2329 + * We can only use set_pmd_at when establishing 2330 + * hugepmds and never for establishing regular pmds that 2331 + * points to regular pagetables. Use pmd_populate for that 2332 + */ 2333 + pmd_populate(mm, pmd, pmd_pgtable(_pmd)); 2329 2334 spin_unlock(&mm->page_table_lock); 2330 2335 anon_vma_unlock_write(vma->anon_vma); 2331 2336 goto out;
+12 -2
mm/memcontrol.c
··· 4108 4108 if (mem_cgroup_disabled()) 4109 4109 return NULL; 4110 4110 4111 - VM_BUG_ON(PageSwapCache(page)); 4112 - 4113 4111 if (PageTransHuge(page)) { 4114 4112 nr_pages <<= compound_order(page); 4115 4113 VM_BUG_ON(!PageTransHuge(page)); ··· 4203 4205 if (page_mapped(page)) 4204 4206 return; 4205 4207 VM_BUG_ON(page->mapping && !PageAnon(page)); 4208 + /* 4209 + * If the page is in swap cache, uncharge should be deferred 4210 + * to the swap path, which also properly accounts swap usage 4211 + * and handles memcg lifetime. 4212 + * 4213 + * Note that this check is not stable and reclaim may add the 4214 + * page to swap cache at any time after this. However, if the 4215 + * page is not in swap cache by the time page->mapcount hits 4216 + * 0, there won't be any page table references to the swap 4217 + * slot, and reclaim will free it and not actually write the 4218 + * page to disk. 4219 + */ 4206 4220 if (PageSwapCache(page)) 4207 4221 return; 4208 4222 __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_ANON, false);
+6 -3
mm/memory_hotplug.c
··· 720 720 start = phys_start_pfn << PAGE_SHIFT; 721 721 size = nr_pages * PAGE_SIZE; 722 722 ret = release_mem_region_adjustable(&iomem_resource, start, size); 723 - if (ret) 724 - pr_warn("Unable to release resource <%016llx-%016llx> (%d)\n", 725 - start, start + size - 1, ret); 723 + if (ret) { 724 + resource_size_t endres = start + size - 1; 725 + 726 + pr_warn("Unable to release resource <%pa-%pa> (%d)\n", 727 + &start, &endres, ret); 728 + } 726 729 727 730 sections_to_remove = nr_pages / PAGES_PER_SECTION; 728 731 for (i = 0; i < sections_to_remove; i++) {
+1 -1
mm/migrate.c
··· 165 165 pte = arch_make_huge_pte(pte, vma, new, 0); 166 166 } 167 167 #endif 168 - flush_cache_page(vma, addr, pte_pfn(pte)); 168 + flush_dcache_page(new); 169 169 set_pte_at(mm, addr, ptep, pte); 170 170 171 171 if (PageHuge(new)) {
+42 -43
mm/mmu_notifier.c
··· 40 40 int id; 41 41 42 42 /* 43 - * srcu_read_lock() here will block synchronize_srcu() in 44 - * mmu_notifier_unregister() until all registered 45 - * ->release() callouts this function makes have 46 - * returned. 43 + * SRCU here will block mmu_notifier_unregister until 44 + * ->release returns. 47 45 */ 48 46 id = srcu_read_lock(&srcu); 47 + hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) 48 + /* 49 + * If ->release runs before mmu_notifier_unregister it must be 50 + * handled, as it's the only way for the driver to flush all 51 + * existing sptes and stop the driver from establishing any more 52 + * sptes before all the pages in the mm are freed. 53 + */ 54 + if (mn->ops->release) 55 + mn->ops->release(mn, mm); 56 + srcu_read_unlock(&srcu, id); 57 + 49 58 spin_lock(&mm->mmu_notifier_mm->lock); 50 59 while (unlikely(!hlist_empty(&mm->mmu_notifier_mm->list))) { 51 60 mn = hlist_entry(mm->mmu_notifier_mm->list.first, 52 61 struct mmu_notifier, 53 62 hlist); 54 - 55 63 /* 56 - * Unlink. This will prevent mmu_notifier_unregister() 57 - * from also making the ->release() callout. 64 + * We arrived before mmu_notifier_unregister so 65 + * mmu_notifier_unregister will do nothing other than to wait 66 + * for ->release to finish and for mmu_notifier_unregister to 67 + * return. 58 68 */ 59 69 hlist_del_init_rcu(&mn->hlist); 60 - spin_unlock(&mm->mmu_notifier_mm->lock); 61 - 62 - /* 63 - * Clear sptes. (see 'release' description in mmu_notifier.h) 64 - */ 65 - if (mn->ops->release) 66 - mn->ops->release(mn, mm); 67 - 68 - spin_lock(&mm->mmu_notifier_mm->lock); 69 70 } 70 71 spin_unlock(&mm->mmu_notifier_mm->lock); 71 72 72 73 /* 73 - * All callouts to ->release() which we have done are complete. 74 - * Allow synchronize_srcu() in mmu_notifier_unregister() to complete 75 - */ 76 - srcu_read_unlock(&srcu, id); 77 - 78 - /* 79 - * mmu_notifier_unregister() may have unlinked a notifier and may 80 - * still be calling out to it. Additionally, other notifiers 81 - * may have been active via vmtruncate() et. al. Block here 82 - * to ensure that all notifier callouts for this mm have been 83 - * completed and the sptes are really cleaned up before returning 84 - * to exit_mmap(). 74 + * synchronize_srcu here prevents mmu_notifier_release from returning to 75 + * exit_mmap (which would proceed with freeing all pages in the mm) 76 + * until the ->release method returns, if it was invoked by 77 + * mmu_notifier_unregister. 78 + * 79 + * The mmu_notifier_mm can't go away from under us because one mm_count 80 + * is held by exit_mmap. 85 81 */ 86 82 synchronize_srcu(&srcu); 87 83 } ··· 288 292 { 289 293 BUG_ON(atomic_read(&mm->mm_count) <= 0); 290 294 291 - spin_lock(&mm->mmu_notifier_mm->lock); 292 295 if (!hlist_unhashed(&mn->hlist)) { 296 + /* 297 + * SRCU here will force exit_mmap to wait for ->release to 298 + * finish before freeing the pages. 299 + */ 293 300 int id; 294 301 295 - /* 296 - * Ensure we synchronize up with __mmu_notifier_release(). 297 - */ 298 302 id = srcu_read_lock(&srcu); 299 - 300 - hlist_del_rcu(&mn->hlist); 301 - spin_unlock(&mm->mmu_notifier_mm->lock); 302 - 303 + /* 304 + * exit_mmap will block in mmu_notifier_release to guarantee 305 + * that ->release is called before freeing the pages. 306 + */ 303 307 if (mn->ops->release) 304 308 mn->ops->release(mn, mm); 305 - 306 - /* 307 - * Allow __mmu_notifier_release() to complete. 308 - */ 309 309 srcu_read_unlock(&srcu, id); 310 - } else 310 + 311 + spin_lock(&mm->mmu_notifier_mm->lock); 312 + /* 313 + * Can not use list_del_rcu() since __mmu_notifier_release 314 + * can delete it before we hold the lock. 315 + */ 316 + hlist_del_init_rcu(&mn->hlist); 311 317 spin_unlock(&mm->mmu_notifier_mm->lock); 318 + } 312 319 313 320 /* 314 - * Wait for any running method to finish, including ->release() if it 315 - * was run by __mmu_notifier_release() instead of us. 321 + * Wait for any running method to finish, of course including 322 + * ->release if it was run by mmu_notifier_relase instead of us. 316 323 */ 317 324 synchronize_srcu(&srcu); 318 325
+37 -35
mm/pagewalk.c
··· 127 127 return 0; 128 128 } 129 129 130 - static struct vm_area_struct* hugetlb_vma(unsigned long addr, struct mm_walk *walk) 131 - { 132 - struct vm_area_struct *vma; 133 - 134 - /* We don't need vma lookup at all. */ 135 - if (!walk->hugetlb_entry) 136 - return NULL; 137 - 138 - VM_BUG_ON(!rwsem_is_locked(&walk->mm->mmap_sem)); 139 - vma = find_vma(walk->mm, addr); 140 - if (vma && vma->vm_start <= addr && is_vm_hugetlb_page(vma)) 141 - return vma; 142 - 143 - return NULL; 144 - } 145 - 146 130 #else /* CONFIG_HUGETLB_PAGE */ 147 - static struct vm_area_struct* hugetlb_vma(unsigned long addr, struct mm_walk *walk) 148 - { 149 - return NULL; 150 - } 151 - 152 131 static int walk_hugetlb_range(struct vm_area_struct *vma, 153 132 unsigned long addr, unsigned long end, 154 133 struct mm_walk *walk) ··· 177 198 if (!walk->mm) 178 199 return -EINVAL; 179 200 201 + VM_BUG_ON(!rwsem_is_locked(&walk->mm->mmap_sem)); 202 + 180 203 pgd = pgd_offset(walk->mm, addr); 181 204 do { 182 - struct vm_area_struct *vma; 205 + struct vm_area_struct *vma = NULL; 183 206 184 207 next = pgd_addr_end(addr, end); 185 208 186 209 /* 187 - * handle hugetlb vma individually because pagetable walk for 188 - * the hugetlb page is dependent on the architecture and 189 - * we can't handled it in the same manner as non-huge pages. 210 + * This function was not intended to be vma based. 211 + * But there are vma special cases to be handled: 212 + * - hugetlb vma's 213 + * - VM_PFNMAP vma's 190 214 */ 191 - vma = hugetlb_vma(addr, walk); 215 + vma = find_vma(walk->mm, addr); 192 216 if (vma) { 193 - if (vma->vm_end < next) 194 - next = vma->vm_end; 195 217 /* 196 - * Hugepage is very tightly coupled with vma, so 197 - * walk through hugetlb entries within a given vma. 218 + * There are no page structures backing a VM_PFNMAP 219 + * range, so do not allow split_huge_page_pmd(). 198 220 */ 199 - err = walk_hugetlb_range(vma, addr, next, walk); 200 - if (err) 201 - break; 202 - pgd = pgd_offset(walk->mm, next); 203 - continue; 221 + if ((vma->vm_start <= addr) && 222 + (vma->vm_flags & VM_PFNMAP)) { 223 + next = vma->vm_end; 224 + pgd = pgd_offset(walk->mm, next); 225 + continue; 226 + } 227 + /* 228 + * Handle hugetlb vma individually because pagetable 229 + * walk for the hugetlb page is dependent on the 230 + * architecture and we can't handled it in the same 231 + * manner as non-huge pages. 232 + */ 233 + if (walk->hugetlb_entry && (vma->vm_start <= addr) && 234 + is_vm_hugetlb_page(vma)) { 235 + if (vma->vm_end < next) 236 + next = vma->vm_end; 237 + /* 238 + * Hugepage is very tightly coupled with vma, 239 + * so walk through hugetlb entries within a 240 + * given vma. 241 + */ 242 + err = walk_hugetlb_range(vma, addr, next, walk); 243 + if (err) 244 + break; 245 + pgd = pgd_offset(walk->mm, next); 246 + continue; 247 + } 204 248 } 205 249 206 250 if (pgd_none_or_clear_bad(pgd)) {
-1
tools/testing/selftests/Makefile
··· 6 6 TARGETS += mqueue 7 7 TARGETS += net 8 8 TARGETS += ptrace 9 - TARGETS += soft-dirty 10 9 TARGETS += vm 11 10 12 11 all:
-10
tools/testing/selftests/soft-dirty/Makefile
··· 1 - CFLAGS += -iquote../../../../include/uapi -Wall 2 - soft-dirty: soft-dirty.c 3 - 4 - all: soft-dirty 5 - 6 - clean: 7 - rm -f soft-dirty 8 - 9 - run_tests: all 10 - @./soft-dirty || echo "soft-dirty selftests: [FAIL]"
-114
tools/testing/selftests/soft-dirty/soft-dirty.c
··· 1 - #include <stdlib.h> 2 - #include <stdio.h> 3 - #include <sys/mman.h> 4 - #include <unistd.h> 5 - #include <fcntl.h> 6 - #include <sys/types.h> 7 - 8 - typedef unsigned long long u64; 9 - 10 - #define PME_PRESENT (1ULL << 63) 11 - #define PME_SOFT_DIRTY (1Ull << 55) 12 - 13 - #define PAGES_TO_TEST 3 14 - #ifndef PAGE_SIZE 15 - #define PAGE_SIZE 4096 16 - #endif 17 - 18 - static void get_pagemap2(char *mem, u64 *map) 19 - { 20 - int fd; 21 - 22 - fd = open("/proc/self/pagemap2", O_RDONLY); 23 - if (fd < 0) { 24 - perror("Can't open pagemap2"); 25 - exit(1); 26 - } 27 - 28 - lseek(fd, (unsigned long)mem / PAGE_SIZE * sizeof(u64), SEEK_SET); 29 - read(fd, map, sizeof(u64) * PAGES_TO_TEST); 30 - close(fd); 31 - } 32 - 33 - static inline char map_p(u64 map) 34 - { 35 - return map & PME_PRESENT ? 'p' : '-'; 36 - } 37 - 38 - static inline char map_sd(u64 map) 39 - { 40 - return map & PME_SOFT_DIRTY ? 'd' : '-'; 41 - } 42 - 43 - static int check_pte(int step, int page, u64 *map, u64 want) 44 - { 45 - if ((map[page] & want) != want) { 46 - printf("Step %d Page %d has %c%c, want %c%c\n", 47 - step, page, 48 - map_p(map[page]), map_sd(map[page]), 49 - map_p(want), map_sd(want)); 50 - return 1; 51 - } 52 - 53 - return 0; 54 - } 55 - 56 - static void clear_refs(void) 57 - { 58 - int fd; 59 - char *v = "4"; 60 - 61 - fd = open("/proc/self/clear_refs", O_WRONLY); 62 - if (write(fd, v, 3) < 3) { 63 - perror("Can't clear soft-dirty bit"); 64 - exit(1); 65 - } 66 - close(fd); 67 - } 68 - 69 - int main(void) 70 - { 71 - char *mem, x; 72 - u64 map[PAGES_TO_TEST]; 73 - 74 - mem = mmap(NULL, PAGES_TO_TEST * PAGE_SIZE, 75 - PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0); 76 - 77 - x = mem[0]; 78 - mem[2 * PAGE_SIZE] = 'c'; 79 - get_pagemap2(mem, map); 80 - 81 - if (check_pte(1, 0, map, PME_PRESENT)) 82 - return 1; 83 - if (check_pte(1, 1, map, 0)) 84 - return 1; 85 - if (check_pte(1, 2, map, PME_PRESENT | PME_SOFT_DIRTY)) 86 - return 1; 87 - 88 - clear_refs(); 89 - get_pagemap2(mem, map); 90 - 91 - if (check_pte(2, 0, map, PME_PRESENT)) 92 - return 1; 93 - if (check_pte(2, 1, map, 0)) 94 - return 1; 95 - if (check_pte(2, 2, map, PME_PRESENT)) 96 - return 1; 97 - 98 - mem[0] = 'a'; 99 - mem[PAGE_SIZE] = 'b'; 100 - x = mem[2 * PAGE_SIZE]; 101 - get_pagemap2(mem, map); 102 - 103 - if (check_pte(3, 0, map, PME_PRESENT | PME_SOFT_DIRTY)) 104 - return 1; 105 - if (check_pte(3, 1, map, PME_PRESENT | PME_SOFT_DIRTY)) 106 - return 1; 107 - if (check_pte(3, 2, map, PME_PRESENT)) 108 - return 1; 109 - 110 - (void)x; /* gcc warn */ 111 - 112 - printf("PASS\n"); 113 - return 0; 114 - }