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

Merge branch 'topic/ocp' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-qcom-spmi

+5792 -1918
+17 -1
Documentation/arm/sunxi/README
··· 36 36 + User Manual 37 37 http://dl.linux-sunxi.org/A20/A20%20User%20Manual%202013-03-22.pdf 38 38 39 - - Allwinner A23 39 + - Allwinner A23 (sun8i) 40 40 + Datasheet 41 41 http://dl.linux-sunxi.org/A23/A23%20Datasheet%20V1.0%2020130830.pdf 42 42 + User Manual ··· 55 55 + User Manual 56 56 http://dl.linux-sunxi.org/A31/A3x_release_document/A31s/IC/A31s%20User%20Manual%20%20V1.0%2020130322.pdf 57 57 58 + - Allwinner A33 (sun8i) 59 + + Datasheet 60 + http://dl.linux-sunxi.org/A33/A33%20Datasheet%20release%201.1.pdf 61 + + User Manual 62 + http://dl.linux-sunxi.org/A33/A33%20user%20manual%20release%201.1.pdf 63 + 64 + - Allwinner H3 (sun8i) 65 + + Datasheet 66 + http://dl.linux-sunxi.org/H3/Allwinner_H3_Datasheet_V1.0.pdf 67 + 58 68 * Quad ARM Cortex-A15, Quad ARM Cortex-A7 based SoCs 59 69 - Allwinner A80 60 70 + Datasheet 61 71 http://dl.linux-sunxi.org/A80/A80_Datasheet_Revision_1.0_0404.pdf 72 + 73 + * Octa ARM Cortex-A7 based SoCs 74 + - Allwinner A83T 75 + + Not Supported 76 + + Datasheet 77 + http://dl.linux-sunxi.org/A83T/A83T_datasheet_Revision_1.1.pdf
+2
Documentation/devicetree/bindings/arm/sunxi.txt
··· 9 9 allwinner,sun6i-a31 10 10 allwinner,sun7i-a20 11 11 allwinner,sun8i-a23 12 + allwinner,sun8i-a33 13 + allwinner,sun8i-h3 12 14 allwinner,sun9i-a80
+1
Documentation/devicetree/bindings/memory-controllers/ti/emif.txt
··· 8 8 Required properties: 9 9 - compatible : Should be of the form "ti,emif-<ip-rev>" where <ip-rev> 10 10 is the IP revision of the specific EMIF instance. 11 + For am437x should be ti,emif-am4372. 11 12 12 13 - phy-type : <u32> indicating the DDR phy type. Following are the 13 14 allowed values
+1
Documentation/devicetree/bindings/regulator/regulator.txt
··· 42 42 - regulator-system-load: Load in uA present on regulator that is not captured by 43 43 any consumer request. 44 44 - regulator-pull-down: Enable pull down resistor when the regulator is disabled. 45 + - regulator-over-current-protection: Enable over current protection. 45 46 46 47 Deprecated properties: 47 48 - regulator-compatible: If a regulator chip contains multiple
+11 -2
Documentation/power/swsusp.txt
··· 410 410 411 411 Q: Can I suspend-to-disk using a swap partition under LVM? 412 412 413 - A: No. You can suspend successfully, but you'll not be able to 414 - resume. uswsusp should be able to work with LVM. See suspend.sf.net. 413 + A: Yes and No. You can suspend successfully, but the kernel will not be able 414 + to resume on its own. You need an initramfs that can recognize the resume 415 + situation, activate the logical volume containing the swap volume (but not 416 + touch any filesystems!), and eventually call 417 + 418 + echo -n "$major:$minor" > /sys/power/resume 419 + 420 + where $major and $minor are the respective major and minor device numbers of 421 + the swap volume. 422 + 423 + uswsusp works with LVM, too. See http://suspend.sourceforge.net/ 415 424 416 425 Q: I upgraded the kernel from 2.6.15 to 2.6.16. Both kernels were 417 426 compiled with the similar configuration files. Anyway I found that
+21 -5
MAINTAINERS
··· 1614 1614 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1615 1615 S: Maintained 1616 1616 F: arch/arm/boot/dts/vexpress* 1617 + F: arch/arm64/boot/dts/arm/vexpress* 1617 1618 F: arch/arm/mach-vexpress/ 1618 1619 F: */*/vexpress* 1619 1620 F: */*/*/vexpress* ··· 2563 2562 F: arch/powerpc/oprofile/*cell* 2564 2563 F: arch/powerpc/platforms/cell/ 2565 2564 2566 - CEPH DISTRIBUTED FILE SYSTEM CLIENT 2565 + CEPH COMMON CODE (LIBCEPH) 2566 + M: Ilya Dryomov <idryomov@gmail.com> 2567 2567 M: "Yan, Zheng" <zyan@redhat.com> 2568 2568 M: Sage Weil <sage@redhat.com> 2569 2569 L: ceph-devel@vger.kernel.org 2570 2570 W: http://ceph.com/ 2571 2571 T: git git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.git 2572 + T: git git://github.com/ceph/ceph-client.git 2572 2573 S: Supported 2573 - F: Documentation/filesystems/ceph.txt 2574 - F: fs/ceph/ 2575 2574 F: net/ceph/ 2576 2575 F: include/linux/ceph/ 2577 2576 F: include/linux/crush/ 2577 + 2578 + CEPH DISTRIBUTED FILE SYSTEM CLIENT (CEPH) 2579 + M: "Yan, Zheng" <zyan@redhat.com> 2580 + M: Sage Weil <sage@redhat.com> 2581 + M: Ilya Dryomov <idryomov@gmail.com> 2582 + L: ceph-devel@vger.kernel.org 2583 + W: http://ceph.com/ 2584 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.git 2585 + T: git git://github.com/ceph/ceph-client.git 2586 + S: Supported 2587 + F: Documentation/filesystems/ceph.txt 2588 + F: fs/ceph/ 2578 2589 2579 2590 CERTIFIED WIRELESS USB (WUSB) SUBSYSTEM: 2580 2591 L: linux-usb@vger.kernel.org ··· 6160 6147 Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ 6161 6148 S: Supported 6162 6149 F: drivers/nvdimm/pmem.c 6150 + F: include/linux/pmem.h 6163 6151 6164 6152 LINUX FOR IBM pSERIES (RS/6000) 6165 6153 M: Paul Mackerras <paulus@au.ibm.com> ··· 6175 6161 W: http://www.penguinppc.org/ 6176 6162 L: linuxppc-dev@lists.ozlabs.org 6177 6163 Q: http://patchwork.ozlabs.org/project/linuxppc-dev/list/ 6178 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc.git 6164 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 6179 6165 S: Supported 6180 6166 F: Documentation/powerpc/ 6181 6167 F: arch/powerpc/ ··· 8380 8366 M: Ilya Dryomov <idryomov@gmail.com> 8381 8367 M: Sage Weil <sage@redhat.com> 8382 8368 M: Alex Elder <elder@kernel.org> 8383 - M: ceph-devel@vger.kernel.org 8369 + L: ceph-devel@vger.kernel.org 8384 8370 W: http://ceph.com/ 8385 8371 T: git git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.git 8372 + T: git git://github.com/ceph/ceph-client.git 8386 8373 S: Supported 8374 + F: Documentation/ABI/testing/sysfs-bus-rbd 8387 8375 F: drivers/block/rbd.c 8388 8376 F: drivers/block/rbd_types.h 8389 8377
+1 -1
Makefile
··· 1 1 VERSION = 4 2 2 PATCHLEVEL = 2 3 3 SUBLEVEL = 0 4 - EXTRAVERSION = -rc1 4 + EXTRAVERSION = -rc2 5 5 NAME = Hurr durr I'ma sheep 6 6 7 7 # *DOCUMENTATION*
+6
arch/arm/Kconfig
··· 1693 1693 config HIGHPTE 1694 1694 bool "Allocate 2nd-level pagetables from highmem" 1695 1695 depends on HIGHMEM 1696 + help 1697 + The VM uses one page of physical memory for each page table. 1698 + For systems with a lot of processes, this can use a lot of 1699 + precious low memory, eventually leading to low memory being 1700 + consumed by page tables. Setting this option will allow 1701 + user-space 2nd level page tables to reside in high memory. 1696 1702 1697 1703 config HW_PERF_EVENTS 1698 1704 bool "Enable hardware performance counter support for perf events"
+1 -1
arch/arm/Kconfig.debug
··· 1635 1635 1636 1636 config DEBUG_SET_MODULE_RONX 1637 1637 bool "Set loadable kernel module data as NX and text as RO" 1638 - depends on MODULES 1638 + depends on MODULES && MMU 1639 1639 ---help--- 1640 1640 This option helps catch unintended modifications to loadable 1641 1641 kernel module's text and read-only data. It also prevents execution
+4
arch/arm/boot/dts/am335x-boneblack.dts
··· 80 80 status = "okay"; 81 81 }; 82 82 }; 83 + 84 + &rtc { 85 + system-power-controller; 86 + };
+7
arch/arm/boot/dts/am4372.dtsi
··· 132 132 }; 133 133 }; 134 134 135 + emif: emif@4c000000 { 136 + compatible = "ti,emif-am4372"; 137 + reg = <0x4c000000 0x1000000>; 138 + ti,hwmods = "emif"; 139 + }; 140 + 135 141 edma: edma@49000000 { 136 142 compatible = "ti,edma3"; 137 143 ti,hwmods = "tpcc", "tptc0", "tptc1", "tptc2"; ··· 947 941 ti,hwmods = "dss_rfbi"; 948 942 clocks = <&disp_clk>; 949 943 clock-names = "fck"; 944 + status = "disabled"; 950 945 }; 951 946 }; 952 947
+4
arch/arm/boot/dts/am57xx-beagle-x15.dts
··· 605 605 phy-supply = <&ldousb_reg>; 606 606 }; 607 607 608 + &usb2_phy2 { 609 + phy-supply = <&ldousb_reg>; 610 + }; 611 + 608 612 &usb1 { 609 613 dr_mode = "host"; 610 614 pinctrl-names = "default";
+1041 -1
arch/arm/boot/dts/atlas7.dtsi
··· 135 135 compatible = "sirf,atlas7-ioc"; 136 136 reg = <0x18880000 0x1000>, 137 137 <0x10E40000 0x1000>; 138 + 139 + audio_ac97_pmx: audio_ac97@0 { 140 + audio_ac97 { 141 + groups = "audio_ac97_grp"; 142 + function = "audio_ac97"; 143 + }; 144 + }; 145 + 146 + audio_func_dbg_pmx: audio_func_dbg@0 { 147 + audio_func_dbg { 148 + groups = "audio_func_dbg_grp"; 149 + function = "audio_func_dbg"; 150 + }; 151 + }; 152 + 153 + audio_i2s_pmx: audio_i2s@0 { 154 + audio_i2s { 155 + groups = "audio_i2s_grp"; 156 + function = "audio_i2s"; 157 + }; 158 + }; 159 + 160 + audio_i2s_2ch_pmx: audio_i2s_2ch@0 { 161 + audio_i2s_2ch { 162 + groups = "audio_i2s_2ch_grp"; 163 + function = "audio_i2s_2ch"; 164 + }; 165 + }; 166 + 167 + audio_i2s_extclk_pmx: audio_i2s_extclk@0 { 168 + audio_i2s_extclk { 169 + groups = "audio_i2s_extclk_grp"; 170 + function = "audio_i2s_extclk"; 171 + }; 172 + }; 173 + 174 + audio_uart0_pmx: audio_uart0@0 { 175 + audio_uart0 { 176 + groups = "audio_uart0_grp"; 177 + function = "audio_uart0"; 178 + }; 179 + }; 180 + 181 + audio_uart1_pmx: audio_uart1@0 { 182 + audio_uart1 { 183 + groups = "audio_uart1_grp"; 184 + function = "audio_uart1"; 185 + }; 186 + }; 187 + 188 + audio_uart2_pmx0: audio_uart2@0 { 189 + audio_uart2_0 { 190 + groups = "audio_uart2_grp0"; 191 + function = "audio_uart2_m0"; 192 + }; 193 + }; 194 + 195 + audio_uart2_pmx1: audio_uart2@1 { 196 + audio_uart2_1 { 197 + groups = "audio_uart2_grp1"; 198 + function = "audio_uart2_m1"; 199 + }; 200 + }; 201 + 202 + c_can_trnsvr_pmx: c_can_trnsvr@0 { 203 + c_can_trnsvr { 204 + groups = "c_can_trnsvr_grp"; 205 + function = "c_can_trnsvr"; 206 + }; 207 + }; 208 + 209 + c0_can_pmx0: c0_can@0 { 210 + c0_can_0 { 211 + groups = "c0_can_grp0"; 212 + function = "c0_can_m0"; 213 + }; 214 + }; 215 + 216 + c0_can_pmx1: c0_can@1 { 217 + c0_can_1 { 218 + groups = "c0_can_grp1"; 219 + function = "c0_can_m1"; 220 + }; 221 + }; 222 + 223 + c1_can_pmx0: c1_can@0 { 224 + c1_can_0 { 225 + groups = "c1_can_grp0"; 226 + function = "c1_can_m0"; 227 + }; 228 + }; 229 + 230 + c1_can_pmx1: c1_can@1 { 231 + c1_can_1 { 232 + groups = "c1_can_grp1"; 233 + function = "c1_can_m1"; 234 + }; 235 + }; 236 + 237 + c1_can_pmx2: c1_can@2 { 238 + c1_can_2 { 239 + groups = "c1_can_grp2"; 240 + function = "c1_can_m2"; 241 + }; 242 + }; 243 + 244 + ca_audio_lpc_pmx: ca_audio_lpc@0 { 245 + ca_audio_lpc { 246 + groups = "ca_audio_lpc_grp"; 247 + function = "ca_audio_lpc"; 248 + }; 249 + }; 250 + 251 + ca_bt_lpc_pmx: ca_bt_lpc@0 { 252 + ca_bt_lpc { 253 + groups = "ca_bt_lpc_grp"; 254 + function = "ca_bt_lpc"; 255 + }; 256 + }; 257 + 258 + ca_coex_pmx: ca_coex@0 { 259 + ca_coex { 260 + groups = "ca_coex_grp"; 261 + function = "ca_coex"; 262 + }; 263 + }; 264 + 265 + ca_curator_lpc_pmx: ca_curator_lpc@0 { 266 + ca_curator_lpc { 267 + groups = "ca_curator_lpc_grp"; 268 + function = "ca_curator_lpc"; 269 + }; 270 + }; 271 + 272 + ca_pcm_debug_pmx: ca_pcm_debug@0 { 273 + ca_pcm_debug { 274 + groups = "ca_pcm_debug_grp"; 275 + function = "ca_pcm_debug"; 276 + }; 277 + }; 278 + 279 + ca_pio_pmx: ca_pio@0 { 280 + ca_pio { 281 + groups = "ca_pio_grp"; 282 + function = "ca_pio"; 283 + }; 284 + }; 285 + 286 + ca_sdio_debug_pmx: ca_sdio_debug@0 { 287 + ca_sdio_debug { 288 + groups = "ca_sdio_debug_grp"; 289 + function = "ca_sdio_debug"; 290 + }; 291 + }; 292 + 293 + ca_spi_pmx: ca_spi@0 { 294 + ca_spi { 295 + groups = "ca_spi_grp"; 296 + function = "ca_spi"; 297 + }; 298 + }; 299 + 300 + ca_trb_pmx: ca_trb@0 { 301 + ca_trb { 302 + groups = "ca_trb_grp"; 303 + function = "ca_trb"; 304 + }; 305 + }; 306 + 307 + ca_uart_debug_pmx: ca_uart_debug@0 { 308 + ca_uart_debug { 309 + groups = "ca_uart_debug_grp"; 310 + function = "ca_uart_debug"; 311 + }; 312 + }; 313 + 314 + clkc_pmx0: clkc@0 { 315 + clkc_0 { 316 + groups = "clkc_grp0"; 317 + function = "clkc_m0"; 318 + }; 319 + }; 320 + 321 + clkc_pmx1: clkc@1 { 322 + clkc_1 { 323 + groups = "clkc_grp1"; 324 + function = "clkc_m1"; 325 + }; 326 + }; 327 + 328 + gn_gnss_i2c_pmx: gn_gnss_i2c@0 { 329 + gn_gnss_i2c { 330 + groups = "gn_gnss_i2c_grp"; 331 + function = "gn_gnss_i2c"; 332 + }; 333 + }; 334 + 335 + gn_gnss_uart_nopause_pmx: gn_gnss_uart_nopause@0 { 336 + gn_gnss_uart_nopause { 337 + groups = "gn_gnss_uart_nopause_grp"; 338 + function = "gn_gnss_uart_nopause"; 339 + }; 340 + }; 341 + 342 + gn_gnss_uart_pmx: gn_gnss_uart@0 { 343 + gn_gnss_uart { 344 + groups = "gn_gnss_uart_grp"; 345 + function = "gn_gnss_uart"; 346 + }; 347 + }; 348 + 349 + gn_trg_spi_pmx0: gn_trg_spi@0 { 350 + gn_trg_spi_0 { 351 + groups = "gn_trg_spi_grp0"; 352 + function = "gn_trg_spi_m0"; 353 + }; 354 + }; 355 + 356 + gn_trg_spi_pmx1: gn_trg_spi@1 { 357 + gn_trg_spi_1 { 358 + groups = "gn_trg_spi_grp1"; 359 + function = "gn_trg_spi_m1"; 360 + }; 361 + }; 362 + 363 + cvbs_dbg_pmx: cvbs_dbg@0 { 364 + cvbs_dbg { 365 + groups = "cvbs_dbg_grp"; 366 + function = "cvbs_dbg"; 367 + }; 368 + }; 369 + 370 + cvbs_dbg_test_pmx0: cvbs_dbg_test@0 { 371 + cvbs_dbg_test_0 { 372 + groups = "cvbs_dbg_test_grp0"; 373 + function = "cvbs_dbg_test_m0"; 374 + }; 375 + }; 376 + 377 + cvbs_dbg_test_pmx1: cvbs_dbg_test@1 { 378 + cvbs_dbg_test_1 { 379 + groups = "cvbs_dbg_test_grp1"; 380 + function = "cvbs_dbg_test_m1"; 381 + }; 382 + }; 383 + 384 + cvbs_dbg_test_pmx2: cvbs_dbg_test@2 { 385 + cvbs_dbg_test_2 { 386 + groups = "cvbs_dbg_test_grp2"; 387 + function = "cvbs_dbg_test_m2"; 388 + }; 389 + }; 390 + 391 + cvbs_dbg_test_pmx3: cvbs_dbg_test@3 { 392 + cvbs_dbg_test_3 { 393 + groups = "cvbs_dbg_test_grp3"; 394 + function = "cvbs_dbg_test_m3"; 395 + }; 396 + }; 397 + 398 + cvbs_dbg_test_pmx4: cvbs_dbg_test@4 { 399 + cvbs_dbg_test_4 { 400 + groups = "cvbs_dbg_test_grp4"; 401 + function = "cvbs_dbg_test_m4"; 402 + }; 403 + }; 404 + 405 + cvbs_dbg_test_pmx5: cvbs_dbg_test@5 { 406 + cvbs_dbg_test_5 { 407 + groups = "cvbs_dbg_test_grp5"; 408 + function = "cvbs_dbg_test_m5"; 409 + }; 410 + }; 411 + 412 + cvbs_dbg_test_pmx6: cvbs_dbg_test@6 { 413 + cvbs_dbg_test_6 { 414 + groups = "cvbs_dbg_test_grp6"; 415 + function = "cvbs_dbg_test_m6"; 416 + }; 417 + }; 418 + 419 + cvbs_dbg_test_pmx7: cvbs_dbg_test@7 { 420 + cvbs_dbg_test_7 { 421 + groups = "cvbs_dbg_test_grp7"; 422 + function = "cvbs_dbg_test_m7"; 423 + }; 424 + }; 425 + 426 + cvbs_dbg_test_pmx8: cvbs_dbg_test@8 { 427 + cvbs_dbg_test_8 { 428 + groups = "cvbs_dbg_test_grp8"; 429 + function = "cvbs_dbg_test_m8"; 430 + }; 431 + }; 432 + 433 + cvbs_dbg_test_pmx9: cvbs_dbg_test@9 { 434 + cvbs_dbg_test_9 { 435 + groups = "cvbs_dbg_test_grp9"; 436 + function = "cvbs_dbg_test_m9"; 437 + }; 438 + }; 439 + 440 + cvbs_dbg_test_pmx10: cvbs_dbg_test@10 { 441 + cvbs_dbg_test_10 { 442 + groups = "cvbs_dbg_test_grp10"; 443 + function = "cvbs_dbg_test_m10"; 444 + }; 445 + }; 446 + 447 + cvbs_dbg_test_pmx11: cvbs_dbg_test@11 { 448 + cvbs_dbg_test_11 { 449 + groups = "cvbs_dbg_test_grp11"; 450 + function = "cvbs_dbg_test_m11"; 451 + }; 452 + }; 453 + 454 + cvbs_dbg_test_pmx12: cvbs_dbg_test@12 { 455 + cvbs_dbg_test_12 { 456 + groups = "cvbs_dbg_test_grp12"; 457 + function = "cvbs_dbg_test_m12"; 458 + }; 459 + }; 460 + 461 + cvbs_dbg_test_pmx13: cvbs_dbg_test@13 { 462 + cvbs_dbg_test_13 { 463 + groups = "cvbs_dbg_test_grp13"; 464 + function = "cvbs_dbg_test_m13"; 465 + }; 466 + }; 467 + 468 + cvbs_dbg_test_pmx14: cvbs_dbg_test@14 { 469 + cvbs_dbg_test_14 { 470 + groups = "cvbs_dbg_test_grp14"; 471 + function = "cvbs_dbg_test_m14"; 472 + }; 473 + }; 474 + 475 + cvbs_dbg_test_pmx15: cvbs_dbg_test@15 { 476 + cvbs_dbg_test_15 { 477 + groups = "cvbs_dbg_test_grp15"; 478 + function = "cvbs_dbg_test_m15"; 479 + }; 480 + }; 481 + 482 + gn_gnss_power_pmx: gn_gnss_power@0 { 483 + gn_gnss_power { 484 + groups = "gn_gnss_power_grp"; 485 + function = "gn_gnss_power"; 486 + }; 487 + }; 488 + 489 + gn_gnss_sw_status_pmx: gn_gnss_sw_status@0 { 490 + gn_gnss_sw_status { 491 + groups = "gn_gnss_sw_status_grp"; 492 + function = "gn_gnss_sw_status"; 493 + }; 494 + }; 495 + 496 + gn_gnss_eclk_pmx: gn_gnss_eclk@0 { 497 + gn_gnss_eclk { 498 + groups = "gn_gnss_eclk_grp"; 499 + function = "gn_gnss_eclk"; 500 + }; 501 + }; 502 + 503 + gn_gnss_irq1_pmx0: gn_gnss_irq1@0 { 504 + gn_gnss_irq1_0 { 505 + groups = "gn_gnss_irq1_grp0"; 506 + function = "gn_gnss_irq1_m0"; 507 + }; 508 + }; 509 + 510 + gn_gnss_irq2_pmx0: gn_gnss_irq2@0 { 511 + gn_gnss_irq2_0 { 512 + groups = "gn_gnss_irq2_grp0"; 513 + function = "gn_gnss_irq2_m0"; 514 + }; 515 + }; 516 + 517 + gn_gnss_tm_pmx: gn_gnss_tm@0 { 518 + gn_gnss_tm { 519 + groups = "gn_gnss_tm_grp"; 520 + function = "gn_gnss_tm"; 521 + }; 522 + }; 523 + 524 + gn_gnss_tsync_pmx: gn_gnss_tsync@0 { 525 + gn_gnss_tsync { 526 + groups = "gn_gnss_tsync_grp"; 527 + function = "gn_gnss_tsync"; 528 + }; 529 + }; 530 + 531 + gn_io_gnsssys_sw_cfg_pmx: gn_io_gnsssys_sw_cfg@0 { 532 + gn_io_gnsssys_sw_cfg { 533 + groups = "gn_io_gnsssys_sw_cfg_grp"; 534 + function = "gn_io_gnsssys_sw_cfg"; 535 + }; 536 + }; 537 + 538 + gn_trg_pmx0: gn_trg@0 { 539 + gn_trg_0 { 540 + groups = "gn_trg_grp0"; 541 + function = "gn_trg_m0"; 542 + }; 543 + }; 544 + 545 + gn_trg_pmx1: gn_trg@1 { 546 + gn_trg_1 { 547 + groups = "gn_trg_grp1"; 548 + function = "gn_trg_m1"; 549 + }; 550 + }; 551 + 552 + gn_trg_shutdown_pmx0: gn_trg_shutdown@0 { 553 + gn_trg_shutdown_0 { 554 + groups = "gn_trg_shutdown_grp0"; 555 + function = "gn_trg_shutdown_m0"; 556 + }; 557 + }; 558 + 559 + gn_trg_shutdown_pmx1: gn_trg_shutdown@1 { 560 + gn_trg_shutdown_1 { 561 + groups = "gn_trg_shutdown_grp1"; 562 + function = "gn_trg_shutdown_m1"; 563 + }; 564 + }; 565 + 566 + gn_trg_shutdown_pmx2: gn_trg_shutdown@2 { 567 + gn_trg_shutdown_2 { 568 + groups = "gn_trg_shutdown_grp2"; 569 + function = "gn_trg_shutdown_m2"; 570 + }; 571 + }; 572 + 573 + gn_trg_shutdown_pmx3: gn_trg_shutdown@3 { 574 + gn_trg_shutdown_3 { 575 + groups = "gn_trg_shutdown_grp3"; 576 + function = "gn_trg_shutdown_m3"; 577 + }; 578 + }; 579 + 580 + i2c0_pmx: i2c0@0 { 581 + i2c0 { 582 + groups = "i2c0_grp"; 583 + function = "i2c0"; 584 + }; 585 + }; 586 + 587 + i2c1_pmx: i2c1@0 { 588 + i2c1 { 589 + groups = "i2c1_grp"; 590 + function = "i2c1"; 591 + }; 592 + }; 593 + 594 + jtag_pmx0: jtag@0 { 595 + jtag_0 { 596 + groups = "jtag_grp0"; 597 + function = "jtag_m0"; 598 + }; 599 + }; 600 + 601 + ks_kas_spi_pmx0: ks_kas_spi@0 { 602 + ks_kas_spi_0 { 603 + groups = "ks_kas_spi_grp0"; 604 + function = "ks_kas_spi_m0"; 605 + }; 606 + }; 607 + 608 + ld_ldd_pmx: ld_ldd@0 { 609 + ld_ldd { 610 + groups = "ld_ldd_grp"; 611 + function = "ld_ldd"; 612 + }; 613 + }; 614 + 615 + ld_ldd_16bit_pmx: ld_ldd_16bit@0 { 616 + ld_ldd_16bit { 617 + groups = "ld_ldd_16bit_grp"; 618 + function = "ld_ldd_16bit"; 619 + }; 620 + }; 621 + 622 + ld_ldd_fck_pmx: ld_ldd_fck@0 { 623 + ld_ldd_fck { 624 + groups = "ld_ldd_fck_grp"; 625 + function = "ld_ldd_fck"; 626 + }; 627 + }; 628 + 629 + ld_ldd_lck_pmx: ld_ldd_lck@0 { 630 + ld_ldd_lck { 631 + groups = "ld_ldd_lck_grp"; 632 + function = "ld_ldd_lck"; 633 + }; 634 + }; 635 + 636 + lr_lcdrom_pmx: lr_lcdrom@0 { 637 + lr_lcdrom { 638 + groups = "lr_lcdrom_grp"; 639 + function = "lr_lcdrom"; 640 + }; 641 + }; 642 + 643 + lvds_analog_pmx: lvds_analog@0 { 644 + lvds_analog { 645 + groups = "lvds_analog_grp"; 646 + function = "lvds_analog"; 647 + }; 648 + }; 649 + 650 + nd_df_pmx: nd_df@0 { 651 + nd_df { 652 + groups = "nd_df_grp"; 653 + function = "nd_df"; 654 + }; 655 + }; 656 + 657 + nd_df_nowp_pmx: nd_df_nowp@0 { 658 + nd_df_nowp { 659 + groups = "nd_df_nowp_grp"; 660 + function = "nd_df_nowp"; 661 + }; 662 + }; 663 + 664 + ps_pmx: ps@0 { 665 + ps { 666 + groups = "ps_grp"; 667 + function = "ps"; 668 + }; 669 + }; 670 + 671 + pwc_core_on_pmx: pwc_core_on@0 { 672 + pwc_core_on { 673 + groups = "pwc_core_on_grp"; 674 + function = "pwc_core_on"; 675 + }; 676 + }; 677 + 678 + pwc_ext_on_pmx: pwc_ext_on@0 { 679 + pwc_ext_on { 680 + groups = "pwc_ext_on_grp"; 681 + function = "pwc_ext_on"; 682 + }; 683 + }; 684 + 685 + pwc_gpio3_clk_pmx: pwc_gpio3_clk@0 { 686 + pwc_gpio3_clk { 687 + groups = "pwc_gpio3_clk_grp"; 688 + function = "pwc_gpio3_clk"; 689 + }; 690 + }; 691 + 692 + pwc_io_on_pmx: pwc_io_on@0 { 693 + pwc_io_on { 694 + groups = "pwc_io_on_grp"; 695 + function = "pwc_io_on"; 696 + }; 697 + }; 698 + 699 + pwc_lowbatt_b_pmx0: pwc_lowbatt_b@0 { 700 + pwc_lowbatt_b_0 { 701 + groups = "pwc_lowbatt_b_grp0"; 702 + function = "pwc_lowbatt_b_m0"; 703 + }; 704 + }; 705 + 706 + pwc_mem_on_pmx: pwc_mem_on@0 { 707 + pwc_mem_on { 708 + groups = "pwc_mem_on_grp"; 709 + function = "pwc_mem_on"; 710 + }; 711 + }; 712 + 713 + pwc_on_key_b_pmx0: pwc_on_key_b@0 { 714 + pwc_on_key_b_0 { 715 + groups = "pwc_on_key_b_grp0"; 716 + function = "pwc_on_key_b_m0"; 717 + }; 718 + }; 719 + 720 + pwc_wakeup_src0_pmx: pwc_wakeup_src0@0 { 721 + pwc_wakeup_src0 { 722 + groups = "pwc_wakeup_src0_grp"; 723 + function = "pwc_wakeup_src0"; 724 + }; 725 + }; 726 + 727 + pwc_wakeup_src1_pmx: pwc_wakeup_src1@0 { 728 + pwc_wakeup_src1 { 729 + groups = "pwc_wakeup_src1_grp"; 730 + function = "pwc_wakeup_src1"; 731 + }; 732 + }; 733 + 734 + pwc_wakeup_src2_pmx: pwc_wakeup_src2@0 { 735 + pwc_wakeup_src2 { 736 + groups = "pwc_wakeup_src2_grp"; 737 + function = "pwc_wakeup_src2"; 738 + }; 739 + }; 740 + 741 + pwc_wakeup_src3_pmx: pwc_wakeup_src3@0 { 742 + pwc_wakeup_src3 { 743 + groups = "pwc_wakeup_src3_grp"; 744 + function = "pwc_wakeup_src3"; 745 + }; 746 + }; 747 + 748 + pw_cko0_pmx0: pw_cko0@0 { 749 + pw_cko0_0 { 750 + groups = "pw_cko0_grp0"; 751 + function = "pw_cko0_m0"; 752 + }; 753 + }; 754 + 755 + pw_cko0_pmx1: pw_cko0@1 { 756 + pw_cko0_1 { 757 + groups = "pw_cko0_grp1"; 758 + function = "pw_cko0_m1"; 759 + }; 760 + }; 761 + 762 + pw_cko0_pmx2: pw_cko0@2 { 763 + pw_cko0_2 { 764 + groups = "pw_cko0_grp2"; 765 + function = "pw_cko0_m2"; 766 + }; 767 + }; 768 + 769 + pw_cko1_pmx0: pw_cko1@0 { 770 + pw_cko1_0 { 771 + groups = "pw_cko1_grp0"; 772 + function = "pw_cko1_m0"; 773 + }; 774 + }; 775 + 776 + pw_cko1_pmx1: pw_cko1@1 { 777 + pw_cko1_1 { 778 + groups = "pw_cko1_grp1"; 779 + function = "pw_cko1_m1"; 780 + }; 781 + }; 782 + 783 + pw_i2s01_clk_pmx0: pw_i2s01_clk@0 { 784 + pw_i2s01_clk_0 { 785 + groups = "pw_i2s01_clk_grp0"; 786 + function = "pw_i2s01_clk_m0"; 787 + }; 788 + }; 789 + 790 + pw_i2s01_clk_pmx1: pw_i2s01_clk@1 { 791 + pw_i2s01_clk_1 { 792 + groups = "pw_i2s01_clk_grp1"; 793 + function = "pw_i2s01_clk_m1"; 794 + }; 795 + }; 796 + 797 + pw_pwm0_pmx: pw_pwm0@0 { 798 + pw_pwm0 { 799 + groups = "pw_pwm0_grp"; 800 + function = "pw_pwm0"; 801 + }; 802 + }; 803 + 804 + pw_pwm1_pmx: pw_pwm1@0 { 805 + pw_pwm1 { 806 + groups = "pw_pwm1_grp"; 807 + function = "pw_pwm1"; 808 + }; 809 + }; 810 + 811 + pw_pwm2_pmx0: pw_pwm2@0 { 812 + pw_pwm2_0 { 813 + groups = "pw_pwm2_grp0"; 814 + function = "pw_pwm2_m0"; 815 + }; 816 + }; 817 + 818 + pw_pwm2_pmx1: pw_pwm2@1 { 819 + pw_pwm2_1 { 820 + groups = "pw_pwm2_grp1"; 821 + function = "pw_pwm2_m1"; 822 + }; 823 + }; 824 + 825 + pw_pwm3_pmx0: pw_pwm3@0 { 826 + pw_pwm3_0 { 827 + groups = "pw_pwm3_grp0"; 828 + function = "pw_pwm3_m0"; 829 + }; 830 + }; 831 + 832 + pw_pwm3_pmx1: pw_pwm3@1 { 833 + pw_pwm3_1 { 834 + groups = "pw_pwm3_grp1"; 835 + function = "pw_pwm3_m1"; 836 + }; 837 + }; 838 + 839 + pw_pwm_cpu_vol_pmx0: pw_pwm_cpu_vol@0 { 840 + pw_pwm_cpu_vol_0 { 841 + groups = "pw_pwm_cpu_vol_grp0"; 842 + function = "pw_pwm_cpu_vol_m0"; 843 + }; 844 + }; 845 + 846 + pw_pwm_cpu_vol_pmx1: pw_pwm_cpu_vol@1 { 847 + pw_pwm_cpu_vol_1 { 848 + groups = "pw_pwm_cpu_vol_grp1"; 849 + function = "pw_pwm_cpu_vol_m1"; 850 + }; 851 + }; 852 + 853 + pw_backlight_pmx0: pw_backlight@0 { 854 + pw_backlight_0 { 855 + groups = "pw_backlight_grp0"; 856 + function = "pw_backlight_m0"; 857 + }; 858 + }; 859 + 860 + pw_backlight_pmx1: pw_backlight@1 { 861 + pw_backlight_1 { 862 + groups = "pw_backlight_grp1"; 863 + function = "pw_backlight_m1"; 864 + }; 865 + }; 866 + 867 + rg_eth_mac_pmx: rg_eth_mac@0 { 868 + rg_eth_mac { 869 + groups = "rg_eth_mac_grp"; 870 + function = "rg_eth_mac"; 871 + }; 872 + }; 873 + 874 + rg_gmac_phy_intr_n_pmx: rg_gmac_phy_intr_n@0 { 875 + rg_gmac_phy_intr_n { 876 + groups = "rg_gmac_phy_intr_n_grp"; 877 + function = "rg_gmac_phy_intr_n"; 878 + }; 879 + }; 880 + 881 + rg_rgmii_mac_pmx: rg_rgmii_mac@0 { 882 + rg_rgmii_mac { 883 + groups = "rg_rgmii_mac_grp"; 884 + function = "rg_rgmii_mac"; 885 + }; 886 + }; 887 + 888 + rg_rgmii_phy_ref_clk_pmx0: rg_rgmii_phy_ref_clk@0 { 889 + rg_rgmii_phy_ref_clk_0 { 890 + groups = 891 + "rg_rgmii_phy_ref_clk_grp0"; 892 + function = 893 + "rg_rgmii_phy_ref_clk_m0"; 894 + }; 895 + }; 896 + 897 + rg_rgmii_phy_ref_clk_pmx1: rg_rgmii_phy_ref_clk@1 { 898 + rg_rgmii_phy_ref_clk_1 { 899 + groups = 900 + "rg_rgmii_phy_ref_clk_grp1"; 901 + function = 902 + "rg_rgmii_phy_ref_clk_m1"; 903 + }; 904 + }; 905 + 906 + sd0_pmx: sd0@0 { 907 + sd0 { 908 + groups = "sd0_grp"; 909 + function = "sd0"; 910 + }; 911 + }; 912 + 913 + sd0_4bit_pmx: sd0_4bit@0 { 914 + sd0_4bit { 915 + groups = "sd0_4bit_grp"; 916 + function = "sd0_4bit"; 917 + }; 918 + }; 919 + 920 + sd1_pmx: sd1@0 { 921 + sd1 { 922 + groups = "sd1_grp"; 923 + function = "sd1"; 924 + }; 925 + }; 926 + 927 + sd1_4bit_pmx0: sd1_4bit@0 { 928 + sd1_4bit_0 { 929 + groups = "sd1_4bit_grp0"; 930 + function = "sd1_4bit_m0"; 931 + }; 932 + }; 933 + 934 + sd1_4bit_pmx1: sd1_4bit@1 { 935 + sd1_4bit_1 { 936 + groups = "sd1_4bit_grp1"; 937 + function = "sd1_4bit_m1"; 938 + }; 939 + }; 940 + 941 + sd2_pmx0: sd2@0 { 942 + sd2_0 { 943 + groups = "sd2_grp0"; 944 + function = "sd2_m0"; 945 + }; 946 + }; 947 + 948 + sd2_no_cdb_pmx0: sd2_no_cdb@0 { 949 + sd2_no_cdb_0 { 950 + groups = "sd2_no_cdb_grp0"; 951 + function = "sd2_no_cdb_m0"; 952 + }; 953 + }; 954 + 955 + sd3_pmx: sd3@0 { 956 + sd3 { 957 + groups = "sd3_grp"; 958 + function = "sd3"; 959 + }; 960 + }; 961 + 962 + sd5_pmx: sd5@0 { 963 + sd5 { 964 + groups = "sd5_grp"; 965 + function = "sd5"; 966 + }; 967 + }; 968 + 969 + sd6_pmx0: sd6@0 { 970 + sd6_0 { 971 + groups = "sd6_grp0"; 972 + function = "sd6_m0"; 973 + }; 974 + }; 975 + 976 + sd6_pmx1: sd6@1 { 977 + sd6_1 { 978 + groups = "sd6_grp1"; 979 + function = "sd6_m1"; 980 + }; 981 + }; 982 + 983 + sp0_ext_ldo_on_pmx: sp0_ext_ldo_on@0 { 984 + sp0_ext_ldo_on { 985 + groups = "sp0_ext_ldo_on_grp"; 986 + function = "sp0_ext_ldo_on"; 987 + }; 988 + }; 989 + 990 + sp0_qspi_pmx: sp0_qspi@0 { 991 + sp0_qspi { 992 + groups = "sp0_qspi_grp"; 993 + function = "sp0_qspi"; 994 + }; 995 + }; 996 + 997 + sp1_spi_pmx: sp1_spi@0 { 998 + sp1_spi { 999 + groups = "sp1_spi_grp"; 1000 + function = "sp1_spi"; 1001 + }; 1002 + }; 1003 + 1004 + tpiu_trace_pmx: tpiu_trace@0 { 1005 + tpiu_trace { 1006 + groups = "tpiu_trace_grp"; 1007 + function = "tpiu_trace"; 1008 + }; 1009 + }; 1010 + 1011 + uart0_pmx: uart0@0 { 1012 + uart0 { 1013 + groups = "uart0_grp"; 1014 + function = "uart0"; 1015 + }; 1016 + }; 1017 + 1018 + uart0_nopause_pmx: uart0_nopause@0 { 1019 + uart0_nopause { 1020 + groups = "uart0_nopause_grp"; 1021 + function = "uart0_nopause"; 1022 + }; 1023 + }; 1024 + 1025 + uart1_pmx: uart1@0 { 1026 + uart1 { 1027 + groups = "uart1_grp"; 1028 + function = "uart1"; 1029 + }; 1030 + }; 1031 + 1032 + uart2_pmx: uart2@0 { 1033 + uart2 { 1034 + groups = "uart2_grp"; 1035 + function = "uart2"; 1036 + }; 1037 + }; 1038 + 1039 + uart3_pmx0: uart3@0 { 1040 + uart3_0 { 1041 + groups = "uart3_grp0"; 1042 + function = "uart3_m0"; 1043 + }; 1044 + }; 1045 + 1046 + uart3_pmx1: uart3@1 { 1047 + uart3_1 { 1048 + groups = "uart3_grp1"; 1049 + function = "uart3_m1"; 1050 + }; 1051 + }; 1052 + 1053 + uart3_pmx2: uart3@2 { 1054 + uart3_2 { 1055 + groups = "uart3_grp2"; 1056 + function = "uart3_m2"; 1057 + }; 1058 + }; 1059 + 1060 + uart3_pmx3: uart3@3 { 1061 + uart3_3 { 1062 + groups = "uart3_grp3"; 1063 + function = "uart3_m3"; 1064 + }; 1065 + }; 1066 + 1067 + uart3_nopause_pmx0: uart3_nopause@0 { 1068 + uart3_nopause_0 { 1069 + groups = "uart3_nopause_grp0"; 1070 + function = "uart3_nopause_m0"; 1071 + }; 1072 + }; 1073 + 1074 + uart3_nopause_pmx1: uart3_nopause@1 { 1075 + uart3_nopause_1 { 1076 + groups = "uart3_nopause_grp1"; 1077 + function = "uart3_nopause_m1"; 1078 + }; 1079 + }; 1080 + 1081 + uart4_pmx0: uart4@0 { 1082 + uart4_0 { 1083 + groups = "uart4_grp0"; 1084 + function = "uart4_m0"; 1085 + }; 1086 + }; 1087 + 1088 + uart4_pmx1: uart4@1 { 1089 + uart4_1 { 1090 + groups = "uart4_grp1"; 1091 + function = "uart4_m1"; 1092 + }; 1093 + }; 1094 + 1095 + uart4_pmx2: uart4@2 { 1096 + uart4_2 { 1097 + groups = "uart4_grp2"; 1098 + function = "uart4_m2"; 1099 + }; 1100 + }; 1101 + 1102 + uart4_nopause_pmx: uart4_nopause@0 { 1103 + uart4_nopause { 1104 + groups = "uart4_nopause_grp"; 1105 + function = "uart4_nopause"; 1106 + }; 1107 + }; 1108 + 1109 + usb0_drvvbus_pmx: usb0_drvvbus@0 { 1110 + usb0_drvvbus { 1111 + groups = "usb0_drvvbus_grp"; 1112 + function = "usb0_drvvbus"; 1113 + }; 1114 + }; 1115 + 1116 + usb1_drvvbus_pmx: usb1_drvvbus@0 { 1117 + usb1_drvvbus { 1118 + groups = "usb1_drvvbus_grp"; 1119 + function = "usb1_drvvbus"; 1120 + }; 1121 + }; 1122 + 1123 + visbus_dout_pmx: visbus_dout@0 { 1124 + visbus_dout { 1125 + groups = "visbus_dout_grp"; 1126 + function = "visbus_dout"; 1127 + }; 1128 + }; 1129 + 1130 + vi_vip1_pmx: vi_vip1@0 { 1131 + vi_vip1 { 1132 + groups = "vi_vip1_grp"; 1133 + function = "vi_vip1"; 1134 + }; 1135 + }; 1136 + 1137 + vi_vip1_ext_pmx: vi_vip1_ext@0 { 1138 + vi_vip1_ext { 1139 + groups = "vi_vip1_ext_grp"; 1140 + function = "vi_vip1_ext"; 1141 + }; 1142 + }; 1143 + 1144 + vi_vip1_low8bit_pmx: vi_vip1_low8bit@0 { 1145 + vi_vip1_low8bit { 1146 + groups = "vi_vip1_low8bit_grp"; 1147 + function = "vi_vip1_low8bit"; 1148 + }; 1149 + }; 1150 + 1151 + vi_vip1_high8bit_pmx: vi_vip1_high8bit@0 { 1152 + vi_vip1_high8bit { 1153 + groups = "vi_vip1_high8bit_grp"; 1154 + function = "vi_vip1_high8bit"; 1155 + }; 1156 + }; 138 1157 }; 139 1158 140 1159 pmipc { ··· 1375 356 clock-names = "gpio0_io"; 1376 357 gpio-controller; 1377 358 interrupt-controller; 359 + 360 + gpio-banks = <2>; 361 + gpio-ranges = <&pinctrl 0 0 0>, 362 + <&pinctrl 32 0 0>; 363 + gpio-ranges-group-names = "lvds_gpio_grp", 364 + "uart_nand_gpio_grp"; 1378 365 }; 1379 366 1380 367 nand@17050000 { ··· 1486 461 #interrupt-cells = <2>; 1487 462 compatible = "sirf,atlas7-gpio"; 1488 463 reg = <0x13300000 0x1000>; 1489 - interrupts = <0 43 0>, <0 44 0>, <0 45 0>; 464 + interrupts = <0 43 0>, <0 44 0>, 465 + <0 45 0>, <0 46 0>; 1490 466 clocks = <&car 84>; 1491 467 clock-names = "gpio1_io"; 1492 468 gpio-controller; 1493 469 interrupt-controller; 470 + 471 + gpio-banks = <4>; 472 + gpio-ranges = <&pinctrl 0 0 0>, 473 + <&pinctrl 32 0 0>, 474 + <&pinctrl 64 0 0>, 475 + <&pinctrl 96 0 0>; 476 + gpio-ranges-group-names = "gnss_gpio_grp", 477 + "lcd_vip_gpio_grp", 478 + "sdio_i2s_gpio_grp", 479 + "sp_rgmii_gpio_grp"; 1494 480 }; 1495 481 1496 482 sd2: sdhci@14200000 { ··· 1780 744 interrupts = <0 47 0>; 1781 745 gpio-controller; 1782 746 interrupt-controller; 747 + 748 + gpio-banks = <1>; 749 + gpio-ranges = <&pinctrl 0 0 0>; 750 + gpio-ranges-group-names = "rtc_gpio_grp"; 1783 751 }; 1784 752 1785 753 rtc-iobg@18840000 {
+23 -2
arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
··· 150 150 interface-type = "ace"; 151 151 reg = <0x5000 0x1000>; 152 152 }; 153 + 154 + pmu@9000 { 155 + compatible = "arm,cci-400-pmu,r0"; 156 + reg = <0x9000 0x5000>; 157 + interrupts = <0 105 4>, 158 + <0 101 4>, 159 + <0 102 4>, 160 + <0 103 4>, 161 + <0 104 4>; 162 + }; 153 163 }; 154 164 155 165 memory-controller@7ffd0000 { ··· 197 187 <1 10 0xf08>; 198 188 }; 199 189 200 - pmu { 190 + pmu_a15 { 201 191 compatible = "arm,cortex-a15-pmu"; 202 192 interrupts = <0 68 4>, 203 193 <0 69 4>; 204 - interrupt-affinity = <&cpu0>, <&cpu1>; 194 + interrupt-affinity = <&cpu0>, 195 + <&cpu1>; 196 + }; 197 + 198 + pmu_a7 { 199 + compatible = "arm,cortex-a7-pmu"; 200 + interrupts = <0 128 4>, 201 + <0 129 4>, 202 + <0 130 4>; 203 + interrupt-affinity = <&cpu2>, 204 + <&cpu3>, 205 + <&cpu4>; 205 206 }; 206 207 207 208 oscclk6a: oscclk6a {
-1
arch/arm/configs/multi_v7_defconfig
··· 353 353 CONFIG_POWER_RESET_GPIO=y 354 354 CONFIG_POWER_RESET_GPIO_RESTART=y 355 355 CONFIG_POWER_RESET_KEYSTONE=y 356 - CONFIG_POWER_RESET_SUN6I=y 357 356 CONFIG_POWER_RESET_RMOBILE=y 358 357 CONFIG_SENSORS_LM90=y 359 358 CONFIG_SENSORS_LM95245=y
+5 -1
arch/arm/configs/sunxi_defconfig
··· 2 2 CONFIG_HIGH_RES_TIMERS=y 3 3 CONFIG_BLK_DEV_INITRD=y 4 4 CONFIG_PERF_EVENTS=y 5 + CONFIG_MODULES=y 5 6 CONFIG_ARCH_SUNXI=y 6 7 CONFIG_SMP=y 7 8 CONFIG_NR_CPUS=8 ··· 78 77 CONFIG_GPIO_SYSFS=y 79 78 CONFIG_POWER_SUPPLY=y 80 79 CONFIG_POWER_RESET=y 81 - CONFIG_POWER_RESET_SUN6I=y 82 80 CONFIG_THERMAL=y 83 81 CONFIG_CPU_THERMAL=y 84 82 CONFIG_WATCHDOG=y ··· 87 87 CONFIG_REGULATOR_FIXED_VOLTAGE=y 88 88 CONFIG_REGULATOR_AXP20X=y 89 89 CONFIG_REGULATOR_GPIO=y 90 + CONFIG_FB=y 91 + CONFIG_FB_SIMPLE=y 92 + CONFIG_FRAMEBUFFER_CONSOLE=y 93 + CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y 90 94 CONFIG_USB=y 91 95 CONFIG_USB_EHCI_HCD=y 92 96 CONFIG_USB_EHCI_HCD_PLATFORM=y
+58 -17
arch/arm/include/asm/io.h
··· 140 140 * The _caller variety takes a __builtin_return_address(0) value for 141 141 * /proc/vmalloc to use - and should only be used in non-inline functions. 142 142 */ 143 - extern void __iomem *__arm_ioremap_pfn_caller(unsigned long, unsigned long, 144 - size_t, unsigned int, void *); 145 143 extern void __iomem *__arm_ioremap_caller(phys_addr_t, size_t, unsigned int, 146 144 void *); 147 - 148 145 extern void __iomem *__arm_ioremap_pfn(unsigned long, unsigned long, size_t, unsigned int); 149 - extern void __iomem *__arm_ioremap(phys_addr_t, size_t, unsigned int); 150 146 extern void __iomem *__arm_ioremap_exec(phys_addr_t, size_t, bool cached); 151 147 extern void __iounmap(volatile void __iomem *addr); 152 - extern void __arm_iounmap(volatile void __iomem *addr); 153 148 154 149 extern void __iomem * (*arch_ioremap_caller)(phys_addr_t, size_t, 155 150 unsigned int, void *); ··· 316 321 static inline void memset_io(volatile void __iomem *dst, unsigned c, 317 322 size_t count) 318 323 { 319 - memset((void __force *)dst, c, count); 324 + extern void mmioset(void *, unsigned int, size_t); 325 + mmioset((void __force *)dst, c, count); 320 326 } 321 327 #define memset_io(dst,c,count) memset_io(dst,c,count) 322 328 323 329 static inline void memcpy_fromio(void *to, const volatile void __iomem *from, 324 330 size_t count) 325 331 { 326 - memcpy(to, (const void __force *)from, count); 332 + extern void mmiocpy(void *, const void *, size_t); 333 + mmiocpy(to, (const void __force *)from, count); 327 334 } 328 335 #define memcpy_fromio(to,from,count) memcpy_fromio(to,from,count) 329 336 330 337 static inline void memcpy_toio(volatile void __iomem *to, const void *from, 331 338 size_t count) 332 339 { 333 - memcpy((void __force *)to, from, count); 340 + extern void mmiocpy(void *, const void *, size_t); 341 + mmiocpy((void __force *)to, from, count); 334 342 } 335 343 #define memcpy_toio(to,from,count) memcpy_toio(to,from,count) 336 344 ··· 346 348 #endif /* readl */ 347 349 348 350 /* 349 - * ioremap and friends. 351 + * ioremap() and friends. 350 352 * 351 - * ioremap takes a PCI memory address, as specified in 352 - * Documentation/io-mapping.txt. 353 + * ioremap() takes a resource address, and size. Due to the ARM memory 354 + * types, it is important to use the correct ioremap() function as each 355 + * mapping has specific properties. 353 356 * 357 + * Function Memory type Cacheability Cache hint 358 + * ioremap() Device n/a n/a 359 + * ioremap_nocache() Device n/a n/a 360 + * ioremap_cache() Normal Writeback Read allocate 361 + * ioremap_wc() Normal Non-cacheable n/a 362 + * ioremap_wt() Normal Non-cacheable n/a 363 + * 364 + * All device mappings have the following properties: 365 + * - no access speculation 366 + * - no repetition (eg, on return from an exception) 367 + * - number, order and size of accesses are maintained 368 + * - unaligned accesses are "unpredictable" 369 + * - writes may be delayed before they hit the endpoint device 370 + * 371 + * ioremap_nocache() is the same as ioremap() as there are too many device 372 + * drivers using this for device registers, and documentation which tells 373 + * people to use it for such for this to be any different. This is not a 374 + * safe fallback for memory-like mappings, or memory regions where the 375 + * compiler may generate unaligned accesses - eg, via inlining its own 376 + * memcpy. 377 + * 378 + * All normal memory mappings have the following properties: 379 + * - reads can be repeated with no side effects 380 + * - repeated reads return the last value written 381 + * - reads can fetch additional locations without side effects 382 + * - writes can be repeated (in certain cases) with no side effects 383 + * - writes can be merged before accessing the target 384 + * - unaligned accesses can be supported 385 + * - ordering is not guaranteed without explicit dependencies or barrier 386 + * instructions 387 + * - writes may be delayed before they hit the endpoint memory 388 + * 389 + * The cache hint is only a performance hint: CPUs may alias these hints. 390 + * Eg, a CPU not implementing read allocate but implementing write allocate 391 + * will provide a write allocate mapping instead. 354 392 */ 355 - #define ioremap(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE) 356 - #define ioremap_nocache(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE) 357 - #define ioremap_cache(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE_CACHED) 358 - #define ioremap_wc(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE_WC) 359 - #define ioremap_wt(cookie,size) __arm_ioremap((cookie), (size), MT_DEVICE) 360 - #define iounmap __arm_iounmap 393 + void __iomem *ioremap(resource_size_t res_cookie, size_t size); 394 + #define ioremap ioremap 395 + #define ioremap_nocache ioremap 396 + 397 + void __iomem *ioremap_cache(resource_size_t res_cookie, size_t size); 398 + #define ioremap_cache ioremap_cache 399 + 400 + void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size); 401 + #define ioremap_wc ioremap_wc 402 + #define ioremap_wt ioremap_wc 403 + 404 + void iounmap(volatile void __iomem *iomem_cookie); 405 + #define iounmap iounmap 361 406 362 407 /* 363 408 * io{read,write}{16,32}be() macros
+1 -1
arch/arm/include/asm/memory.h
··· 275 275 */ 276 276 #define __pa(x) __virt_to_phys((unsigned long)(x)) 277 277 #define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x))) 278 - #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 278 + #define pfn_to_kaddr(pfn) __va((phys_addr_t)(pfn) << PAGE_SHIFT) 279 279 280 280 extern phys_addr_t (*arch_virt_to_idmap)(unsigned long x); 281 281
+30 -1
arch/arm/include/asm/pgtable-2level.h
··· 129 129 130 130 /* 131 131 * These are the memory types, defined to be compatible with 132 - * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB 132 + * pre-ARMv6 CPUs cacheable and bufferable bits: n/a,n/a,C,B 133 + * ARMv6+ without TEX remapping, they are a table index. 134 + * ARMv6+ with TEX remapping, they correspond to n/a,TEX(0),C,B 135 + * 136 + * MT type Pre-ARMv6 ARMv6+ type / cacheable status 137 + * UNCACHED Uncached Strongly ordered 138 + * BUFFERABLE Bufferable Normal memory / non-cacheable 139 + * WRITETHROUGH Writethrough Normal memory / write through 140 + * WRITEBACK Writeback Normal memory / write back, read alloc 141 + * MINICACHE Minicache N/A 142 + * WRITEALLOC Writeback Normal memory / write back, write alloc 143 + * DEV_SHARED Uncached Device memory (shared) 144 + * DEV_NONSHARED Uncached Device memory (non-shared) 145 + * DEV_WC Bufferable Normal memory / non-cacheable 146 + * DEV_CACHED Writeback Normal memory / write back, read alloc 147 + * VECTORS Variable Normal memory / variable 148 + * 149 + * All normal memory mappings have the following properties: 150 + * - reads can be repeated with no side effects 151 + * - repeated reads return the last value written 152 + * - reads can fetch additional locations without side effects 153 + * - writes can be repeated (in certain cases) with no side effects 154 + * - writes can be merged before accessing the target 155 + * - unaligned accesses can be supported 156 + * 157 + * All device mappings have the following properties: 158 + * - no access speculation 159 + * - no repetition (eg, on return from an exception) 160 + * - number, order and size of accesses are maintained 161 + * - unaligned accesses are "unpredictable" 133 162 */ 134 163 #define L_PTE_MT_UNCACHED (_AT(pteval_t, 0x00) << 2) /* 0000 */ 135 164 #define L_PTE_MT_BUFFERABLE (_AT(pteval_t, 0x01) << 2) /* 0001 */
+6
arch/arm/kernel/armksyms.c
··· 50 50 51 51 extern void fpundefinstr(void); 52 52 53 + void mmioset(void *, unsigned int, size_t); 54 + void mmiocpy(void *, const void *, size_t); 55 + 53 56 /* platform dependent support */ 54 57 EXPORT_SYMBOL(arm_delay_ops); 55 58 ··· 90 87 EXPORT_SYMBOL(memmove); 91 88 EXPORT_SYMBOL(memchr); 92 89 EXPORT_SYMBOL(__memzero); 90 + 91 + EXPORT_SYMBOL(mmioset); 92 + EXPORT_SYMBOL(mmiocpy); 93 93 94 94 #ifdef CONFIG_MMU 95 95 EXPORT_SYMBOL(copy_page);
+1 -1
arch/arm/kernel/entry-armv.S
··· 410 410 zero_fp 411 411 412 412 .if \trace 413 - #ifdef CONFIG_IRQSOFF_TRACER 413 + #ifdef CONFIG_TRACE_IRQFLAGS 414 414 bl trace_hardirqs_off 415 415 #endif 416 416 ct_user_exit save = 0
+2 -2
arch/arm/kernel/smp.c
··· 578 578 struct pt_regs *old_regs = set_irq_regs(regs); 579 579 580 580 if ((unsigned)ipinr < NR_IPI) { 581 - trace_ipi_entry(ipi_types[ipinr]); 581 + trace_ipi_entry_rcuidle(ipi_types[ipinr]); 582 582 __inc_irq_stat(cpu, ipi_irqs[ipinr]); 583 583 } 584 584 ··· 637 637 } 638 638 639 639 if ((unsigned)ipinr < NR_IPI) 640 - trace_ipi_exit(ipi_types[ipinr]); 640 + trace_ipi_exit_rcuidle(ipi_types[ipinr]); 641 641 set_irq_regs(old_regs); 642 642 } 643 643
+2
arch/arm/lib/memcpy.S
··· 61 61 62 62 /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */ 63 63 64 + ENTRY(mmiocpy) 64 65 ENTRY(memcpy) 65 66 66 67 #include "copy_template.S" 67 68 68 69 ENDPROC(memcpy) 70 + ENDPROC(mmiocpy)
+2
arch/arm/lib/memset.S
··· 16 16 .text 17 17 .align 5 18 18 19 + ENTRY(mmioset) 19 20 ENTRY(memset) 20 21 UNWIND( .fnstart ) 21 22 ands r3, r0, #3 @ 1 unaligned? ··· 134 133 b 1b 135 134 UNWIND( .fnend ) 136 135 ENDPROC(memset) 136 + ENDPROC(mmioset)
-1
arch/arm/mach-omap2/dma.c
··· 117 117 u8 revision = dma_read(REVISION, 0) & 0xff; 118 118 printk(KERN_INFO "OMAP DMA hardware revision %d.%d\n", 119 119 revision >> 4, revision & 0xf); 120 - return; 121 120 } 122 121 123 122 static unsigned configure_dma_errata(void)
+1
arch/arm/mach-prima2/Kconfig
··· 4 4 select ARCH_REQUIRE_GPIOLIB 5 5 select GENERIC_IRQ_CHIP 6 6 select NO_IOPORT_MAP 7 + select REGMAP 7 8 select PINCTRL 8 9 select PINCTRL_SIRF 9 10 help
+45 -3
arch/arm/mach-prima2/rtciobrg.c
··· 1 1 /* 2 - * RTC I/O Bridge interfaces for CSR SiRFprimaII 2 + * RTC I/O Bridge interfaces for CSR SiRFprimaII/atlas7 3 3 * ARM access the registers of SYSRTC, GPSRTC and PWRC through this module 4 4 * 5 5 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. ··· 10 10 #include <linux/kernel.h> 11 11 #include <linux/module.h> 12 12 #include <linux/io.h> 13 + #include <linux/regmap.h> 13 14 #include <linux/of.h> 14 15 #include <linux/of_address.h> 15 16 #include <linux/of_device.h> ··· 67 66 { 68 67 unsigned long flags, val; 69 68 69 + /* TODO: add hwspinlock to sync with M3 */ 70 70 spin_lock_irqsave(&rtciobrg_lock, flags); 71 71 72 72 val = __sirfsoc_rtc_iobrg_readl(addr); ··· 92 90 { 93 91 unsigned long flags; 94 92 93 + /* TODO: add hwspinlock to sync with M3 */ 95 94 spin_lock_irqsave(&rtciobrg_lock, flags); 96 95 97 96 sirfsoc_rtc_iobrg_pre_writel(val, addr); ··· 104 101 spin_unlock_irqrestore(&rtciobrg_lock, flags); 105 102 } 106 103 EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_writel); 104 + 105 + 106 + static int regmap_iobg_regwrite(void *context, unsigned int reg, 107 + unsigned int val) 108 + { 109 + sirfsoc_rtc_iobrg_writel(val, reg); 110 + return 0; 111 + } 112 + 113 + static int regmap_iobg_regread(void *context, unsigned int reg, 114 + unsigned int *val) 115 + { 116 + *val = (u32)sirfsoc_rtc_iobrg_readl(reg); 117 + return 0; 118 + } 119 + 120 + static struct regmap_bus regmap_iobg = { 121 + .reg_write = regmap_iobg_regwrite, 122 + .reg_read = regmap_iobg_regread, 123 + }; 124 + 125 + /** 126 + * devm_regmap_init_iobg(): Initialise managed register map 127 + * 128 + * @iobg: Device that will be interacted with 129 + * @config: Configuration for register map 130 + * 131 + * The return value will be an ERR_PTR() on error or a valid pointer 132 + * to a struct regmap. The regmap will be automatically freed by the 133 + * device management code. 134 + */ 135 + struct regmap *devm_regmap_init_iobg(struct device *dev, 136 + const struct regmap_config *config) 137 + { 138 + const struct regmap_bus *bus = &regmap_iobg; 139 + 140 + return devm_regmap_init(dev, bus, dev, config); 141 + } 142 + EXPORT_SYMBOL_GPL(devm_regmap_init_iobg); 107 143 108 144 static const struct of_device_id rtciobrg_ids[] = { 109 145 { .compatible = "sirf,prima2-rtciobg" }, ··· 174 132 } 175 133 postcore_initcall(sirfsoc_rtciobrg_init); 176 134 177 - MODULE_AUTHOR("Zhiwu Song <zhiwu.song@csr.com>, " 178 - "Barry Song <baohua.song@csr.com>"); 135 + MODULE_AUTHOR("Zhiwu Song <zhiwu.song@csr.com>"); 136 + MODULE_AUTHOR("Barry Song <baohua.song@csr.com>"); 179 137 MODULE_DESCRIPTION("CSR SiRFprimaII rtc io bridge"); 180 138 MODULE_LICENSE("GPL v2");
+1 -1
arch/arm/mach-sunxi/Kconfig
··· 35 35 select SUN5I_HSTIMER 36 36 37 37 config MACH_SUN8I 38 - bool "Allwinner A23 (sun8i) SoCs support" 38 + bool "Allwinner sun8i Family SoCs support" 39 39 default ARCH_SUNXI 40 40 select ARM_GIC 41 41 select MFD_SUN6I_PRCM
+4 -1
arch/arm/mach-sunxi/sunxi.c
··· 67 67 68 68 static const char * const sun8i_board_dt_compat[] = { 69 69 "allwinner,sun8i-a23", 70 + "allwinner,sun8i-a33", 71 + "allwinner,sun8i-h3", 70 72 NULL, 71 73 }; 72 74 73 - DT_MACHINE_START(SUN8I_DT, "Allwinner sun8i (A23) Family") 75 + DT_MACHINE_START(SUN8I_DT, "Allwinner sun8i Family") 76 + .init_time = sun6i_timer_init, 74 77 .dt_compat = sun8i_board_dt_compat, 75 78 .init_late = sunxi_dt_cpufreq_init, 76 79 MACHINE_END
+23 -10
arch/arm/mm/ioremap.c
··· 255 255 } 256 256 #endif 257 257 258 - void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn, 258 + static void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn, 259 259 unsigned long offset, size_t size, unsigned int mtype, void *caller) 260 260 { 261 261 const struct mem_type *type; ··· 363 363 unsigned int mtype) 364 364 { 365 365 return __arm_ioremap_pfn_caller(pfn, offset, size, mtype, 366 - __builtin_return_address(0)); 366 + __builtin_return_address(0)); 367 367 } 368 368 EXPORT_SYMBOL(__arm_ioremap_pfn); 369 369 ··· 371 371 unsigned int, void *) = 372 372 __arm_ioremap_caller; 373 373 374 - void __iomem * 375 - __arm_ioremap(phys_addr_t phys_addr, size_t size, unsigned int mtype) 374 + void __iomem *ioremap(resource_size_t res_cookie, size_t size) 376 375 { 377 - return arch_ioremap_caller(phys_addr, size, mtype, 378 - __builtin_return_address(0)); 376 + return arch_ioremap_caller(res_cookie, size, MT_DEVICE, 377 + __builtin_return_address(0)); 379 378 } 380 - EXPORT_SYMBOL(__arm_ioremap); 379 + EXPORT_SYMBOL(ioremap); 380 + 381 + void __iomem *ioremap_cache(resource_size_t res_cookie, size_t size) 382 + { 383 + return arch_ioremap_caller(res_cookie, size, MT_DEVICE_CACHED, 384 + __builtin_return_address(0)); 385 + } 386 + EXPORT_SYMBOL(ioremap_cache); 387 + 388 + void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size) 389 + { 390 + return arch_ioremap_caller(res_cookie, size, MT_DEVICE_WC, 391 + __builtin_return_address(0)); 392 + } 393 + EXPORT_SYMBOL(ioremap_wc); 381 394 382 395 /* 383 396 * Remap an arbitrary physical address space into the kernel virtual ··· 444 431 445 432 void (*arch_iounmap)(volatile void __iomem *) = __iounmap; 446 433 447 - void __arm_iounmap(volatile void __iomem *io_addr) 434 + void iounmap(volatile void __iomem *cookie) 448 435 { 449 - arch_iounmap(io_addr); 436 + arch_iounmap(cookie); 450 437 } 451 - EXPORT_SYMBOL(__arm_iounmap); 438 + EXPORT_SYMBOL(iounmap); 452 439 453 440 #ifdef CONFIG_PCI 454 441 static int pci_ioremap_mem_type = MT_DEVICE;
+7
arch/arm/mm/mmu.c
··· 1072 1072 int highmem = 0; 1073 1073 phys_addr_t vmalloc_limit = __pa(vmalloc_min - 1) + 1; 1074 1074 struct memblock_region *reg; 1075 + bool should_use_highmem = false; 1075 1076 1076 1077 for_each_memblock(memory, reg) { 1077 1078 phys_addr_t block_start = reg->base; ··· 1091 1090 pr_notice("Ignoring RAM at %pa-%pa (!CONFIG_HIGHMEM)\n", 1092 1091 &block_start, &block_end); 1093 1092 memblock_remove(reg->base, reg->size); 1093 + should_use_highmem = true; 1094 1094 continue; 1095 1095 } 1096 1096 ··· 1102 1100 &block_start, &block_end, &vmalloc_limit); 1103 1101 memblock_remove(vmalloc_limit, overlap_size); 1104 1102 block_end = vmalloc_limit; 1103 + should_use_highmem = true; 1105 1104 } 1106 1105 } 1107 1106 ··· 1136 1133 1137 1134 } 1138 1135 } 1136 + 1137 + if (should_use_highmem) 1138 + pr_notice("Consider using a HIGHMEM enabled kernel.\n"); 1139 1139 1140 1140 high_memory = __va(arm_lowmem_limit - 1) + 1; 1141 1141 ··· 1500 1494 build_mem_type_table(); 1501 1495 prepare_page_table(); 1502 1496 map_lowmem(); 1497 + memblock_set_current_limit(arm_lowmem_limit); 1503 1498 dma_contiguous_remap(); 1504 1499 devicemaps_init(mdesc); 1505 1500 kmap_init();
+31 -18
arch/arm/mm/nommu.c
··· 351 351 } 352 352 EXPORT_SYMBOL(__arm_ioremap_pfn); 353 353 354 - void __iomem *__arm_ioremap_pfn_caller(unsigned long pfn, unsigned long offset, 355 - size_t size, unsigned int mtype, void *caller) 356 - { 357 - return __arm_ioremap_pfn(pfn, offset, size, mtype); 358 - } 359 - 360 - void __iomem *__arm_ioremap(phys_addr_t phys_addr, size_t size, 361 - unsigned int mtype) 362 - { 363 - return (void __iomem *)phys_addr; 364 - } 365 - EXPORT_SYMBOL(__arm_ioremap); 366 - 367 - void __iomem * (*arch_ioremap_caller)(phys_addr_t, size_t, unsigned int, void *); 368 - 369 354 void __iomem *__arm_ioremap_caller(phys_addr_t phys_addr, size_t size, 370 355 unsigned int mtype, void *caller) 371 356 { 372 - return __arm_ioremap(phys_addr, size, mtype); 357 + return (void __iomem *)phys_addr; 373 358 } 359 + 360 + void __iomem * (*arch_ioremap_caller)(phys_addr_t, size_t, unsigned int, void *); 361 + 362 + void __iomem *ioremap(resource_size_t res_cookie, size_t size) 363 + { 364 + return __arm_ioremap_caller(res_cookie, size, MT_DEVICE, 365 + __builtin_return_address(0)); 366 + } 367 + EXPORT_SYMBOL(ioremap); 368 + 369 + void __iomem *ioremap_cache(resource_size_t res_cookie, size_t size) 370 + { 371 + return __arm_ioremap_caller(res_cookie, size, MT_DEVICE_CACHED, 372 + __builtin_return_address(0)); 373 + } 374 + EXPORT_SYMBOL(ioremap_cache); 375 + 376 + void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size) 377 + { 378 + return __arm_ioremap_caller(res_cookie, size, MT_DEVICE_WC, 379 + __builtin_return_address(0)); 380 + } 381 + EXPORT_SYMBOL(ioremap_wc); 382 + 383 + void __iounmap(volatile void __iomem *addr) 384 + { 385 + } 386 + EXPORT_SYMBOL(__iounmap); 374 387 375 388 void (*arch_iounmap)(volatile void __iomem *); 376 389 377 - void __arm_iounmap(volatile void __iomem *addr) 390 + void iounmap(volatile void __iomem *addr) 378 391 { 379 392 } 380 - EXPORT_SYMBOL(__arm_iounmap); 393 + EXPORT_SYMBOL(iounmap);
+33 -23
arch/arm/vdso/vdsomunge.c
··· 45 45 * it does. 46 46 */ 47 47 48 - #define _GNU_SOURCE 49 - 50 48 #include <byteswap.h> 51 49 #include <elf.h> 52 50 #include <errno.h> 53 - #include <error.h> 54 51 #include <fcntl.h> 52 + #include <stdarg.h> 55 53 #include <stdbool.h> 56 54 #include <stdio.h> 57 55 #include <stdlib.h> ··· 80 82 #define EF_ARM_ABI_FLOAT_HARD 0x400 81 83 #endif 82 84 85 + static int failed; 86 + static const char *argv0; 83 87 static const char *outfile; 88 + 89 + static void fail(const char *fmt, ...) 90 + { 91 + va_list ap; 92 + 93 + failed = 1; 94 + fprintf(stderr, "%s: ", argv0); 95 + va_start(ap, fmt); 96 + vfprintf(stderr, fmt, ap); 97 + va_end(ap); 98 + exit(EXIT_FAILURE); 99 + } 84 100 85 101 static void cleanup(void) 86 102 { 87 - if (error_message_count > 0 && outfile != NULL) 103 + if (failed && outfile != NULL) 88 104 unlink(outfile); 89 105 } 90 106 ··· 131 119 int infd; 132 120 133 121 atexit(cleanup); 122 + argv0 = argv[0]; 134 123 135 124 if (argc != 3) 136 - error(EXIT_FAILURE, 0, "Usage: %s [infile] [outfile]", argv[0]); 125 + fail("Usage: %s [infile] [outfile]\n", argv[0]); 137 126 138 127 infile = argv[1]; 139 128 outfile = argv[2]; 140 129 141 130 infd = open(infile, O_RDONLY); 142 131 if (infd < 0) 143 - error(EXIT_FAILURE, errno, "Cannot open %s", infile); 132 + fail("Cannot open %s: %s\n", infile, strerror(errno)); 144 133 145 134 if (fstat(infd, &stat) != 0) 146 - error(EXIT_FAILURE, errno, "Failed stat for %s", infile); 135 + fail("Failed stat for %s: %s\n", infile, strerror(errno)); 147 136 148 137 inbuf = mmap(NULL, stat.st_size, PROT_READ, MAP_PRIVATE, infd, 0); 149 138 if (inbuf == MAP_FAILED) 150 - error(EXIT_FAILURE, errno, "Failed to map %s", infile); 139 + fail("Failed to map %s: %s\n", infile, strerror(errno)); 151 140 152 141 close(infd); 153 142 154 143 inhdr = inbuf; 155 144 156 145 if (memcmp(&inhdr->e_ident, ELFMAG, SELFMAG) != 0) 157 - error(EXIT_FAILURE, 0, "Not an ELF file"); 146 + fail("Not an ELF file\n"); 158 147 159 148 if (inhdr->e_ident[EI_CLASS] != ELFCLASS32) 160 - error(EXIT_FAILURE, 0, "Unsupported ELF class"); 149 + fail("Unsupported ELF class\n"); 161 150 162 151 swap = inhdr->e_ident[EI_DATA] != HOST_ORDER; 163 152 164 153 if (read_elf_half(inhdr->e_type, swap) != ET_DYN) 165 - error(EXIT_FAILURE, 0, "Not a shared object"); 154 + fail("Not a shared object\n"); 166 155 167 - if (read_elf_half(inhdr->e_machine, swap) != EM_ARM) { 168 - error(EXIT_FAILURE, 0, "Unsupported architecture %#x", 169 - inhdr->e_machine); 170 - } 156 + if (read_elf_half(inhdr->e_machine, swap) != EM_ARM) 157 + fail("Unsupported architecture %#x\n", inhdr->e_machine); 171 158 172 159 e_flags = read_elf_word(inhdr->e_flags, swap); 173 160 174 161 if (EF_ARM_EABI_VERSION(e_flags) != EF_ARM_EABI_VER5) { 175 - error(EXIT_FAILURE, 0, "Unsupported EABI version %#x", 176 - EF_ARM_EABI_VERSION(e_flags)); 162 + fail("Unsupported EABI version %#x\n", 163 + EF_ARM_EABI_VERSION(e_flags)); 177 164 } 178 165 179 166 if (e_flags & EF_ARM_ABI_FLOAT_HARD) 180 - error(EXIT_FAILURE, 0, 181 - "Unexpected hard-float flag set in e_flags"); 167 + fail("Unexpected hard-float flag set in e_flags\n"); 182 168 183 169 clear_soft_float = !!(e_flags & EF_ARM_ABI_FLOAT_SOFT); 184 170 185 171 outfd = open(outfile, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); 186 172 if (outfd < 0) 187 - error(EXIT_FAILURE, errno, "Cannot open %s", outfile); 173 + fail("Cannot open %s: %s\n", outfile, strerror(errno)); 188 174 189 175 if (ftruncate(outfd, stat.st_size) != 0) 190 - error(EXIT_FAILURE, errno, "Cannot truncate %s", outfile); 176 + fail("Cannot truncate %s: %s\n", outfile, strerror(errno)); 191 177 192 178 outbuf = mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, 193 179 outfd, 0); 194 180 if (outbuf == MAP_FAILED) 195 - error(EXIT_FAILURE, errno, "Failed to map %s", outfile); 181 + fail("Failed to map %s: %s\n", outfile, strerror(errno)); 196 182 197 183 close(outfd); 198 184 ··· 205 195 } 206 196 207 197 if (msync(outbuf, stat.st_size, MS_SYNC) != 0) 208 - error(EXIT_FAILURE, errno, "Failed to sync %s", outfile); 198 + fail("Failed to sync %s: %s\n", outfile, strerror(errno)); 209 199 210 200 return EXIT_SUCCESS; 211 201 }
+1 -1
arch/arm64/Kconfig
··· 23 23 select BUILDTIME_EXTABLE_SORT 24 24 select CLONE_BACKWARDS 25 25 select COMMON_CLK 26 - select EDAC_SUPPORT 27 26 select CPU_PM if (SUSPEND || CPU_IDLE) 28 27 select DCACHE_WORD_ACCESS 28 + select EDAC_SUPPORT 29 29 select GENERIC_ALLOCATOR 30 30 select GENERIC_CLOCKEVENTS 31 31 select GENERIC_CLOCKEVENTS_BROADCAST if SMP
+10
arch/arm64/boot/dts/apm/apm-mustang.dts
··· 23 23 device_type = "memory"; 24 24 reg = < 0x1 0x00000000 0x0 0x80000000 >; /* Updated by bootloader */ 25 25 }; 26 + 27 + gpio-keys { 28 + compatible = "gpio-keys"; 29 + button@1 { 30 + label = "POWER"; 31 + linux,code = <116>; 32 + linux,input-type = <0x1>; 33 + interrupts = <0x0 0x2d 0x1>; 34 + }; 35 + }; 26 36 }; 27 37 28 38 &pcie0clk {
+1
arch/arm64/boot/dts/arm/Makefile
··· 1 1 dtb-$(CONFIG_ARCH_VEXPRESS) += foundation-v8.dtb 2 2 dtb-$(CONFIG_ARCH_VEXPRESS) += juno.dtb juno-r1.dtb 3 3 dtb-$(CONFIG_ARCH_VEXPRESS) += rtsm_ve-aemv8a.dtb 4 + dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2f-1xv7-ca53x2.dtb 4 5 5 6 always := $(dtb-y) 6 7 subdir-y := $(dts-dirs)
+191
arch/arm64/boot/dts/arm/vexpress-v2f-1xv7-ca53x2.dts
··· 1 + /* 2 + * ARM Ltd. Versatile Express 3 + * 4 + * LogicTile Express 20MG 5 + * V2F-1XV7 6 + * 7 + * Cortex-A53 (2 cores) Soft Macrocell Model 8 + * 9 + * HBI-0247C 10 + */ 11 + 12 + /dts-v1/; 13 + 14 + #include <dt-bindings/interrupt-controller/arm-gic.h> 15 + 16 + / { 17 + model = "V2F-1XV7 Cortex-A53x2 SMM"; 18 + arm,hbi = <0x247>; 19 + arm,vexpress,site = <0xf>; 20 + compatible = "arm,vexpress,v2f-1xv7,ca53x2", "arm,vexpress,v2f-1xv7", "arm,vexpress"; 21 + interrupt-parent = <&gic>; 22 + #address-cells = <2>; 23 + #size-cells = <2>; 24 + 25 + chosen { 26 + stdout-path = "serial0:38400n8"; 27 + }; 28 + 29 + aliases { 30 + serial0 = &v2m_serial0; 31 + serial1 = &v2m_serial1; 32 + serial2 = &v2m_serial2; 33 + serial3 = &v2m_serial3; 34 + i2c0 = &v2m_i2c_dvi; 35 + i2c1 = &v2m_i2c_pcie; 36 + }; 37 + 38 + cpus { 39 + #address-cells = <2>; 40 + #size-cells = <0>; 41 + 42 + cpu@0 { 43 + device_type = "cpu"; 44 + compatible = "arm,cortex-a53", "arm,armv8"; 45 + reg = <0 0>; 46 + next-level-cache = <&L2_0>; 47 + }; 48 + 49 + cpu@1 { 50 + device_type = "cpu"; 51 + compatible = "arm,cortex-a53", "arm,armv8"; 52 + reg = <0 1>; 53 + next-level-cache = <&L2_0>; 54 + }; 55 + 56 + L2_0: l2-cache0 { 57 + compatible = "cache"; 58 + }; 59 + }; 60 + 61 + memory@80000000 { 62 + device_type = "memory"; 63 + reg = <0 0x80000000 0 0x80000000>; /* 2GB @ 2GB */ 64 + }; 65 + 66 + gic: interrupt-controller@2c001000 { 67 + compatible = "arm,gic-400"; 68 + #interrupt-cells = <3>; 69 + #address-cells = <0>; 70 + interrupt-controller; 71 + reg = <0 0x2c001000 0 0x1000>, 72 + <0 0x2c002000 0 0x2000>, 73 + <0 0x2c004000 0 0x2000>, 74 + <0 0x2c006000 0 0x2000>; 75 + interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_HIGH)>; 76 + }; 77 + 78 + timer { 79 + compatible = "arm,armv8-timer"; 80 + interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>, 81 + <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>, 82 + <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>, 83 + <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>; 84 + }; 85 + 86 + pmu { 87 + compatible = "arm,armv8-pmuv3"; 88 + interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>, 89 + <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>; 90 + }; 91 + 92 + dcc { 93 + compatible = "arm,vexpress,config-bus"; 94 + arm,vexpress,config-bridge = <&v2m_sysreg>; 95 + 96 + smbclk: osc@4 { 97 + /* SMC clock */ 98 + compatible = "arm,vexpress-osc"; 99 + arm,vexpress-sysreg,func = <1 4>; 100 + freq-range = <40000000 40000000>; 101 + #clock-cells = <0>; 102 + clock-output-names = "smclk"; 103 + }; 104 + 105 + volt@0 { 106 + /* VIO to expansion board above */ 107 + compatible = "arm,vexpress-volt"; 108 + arm,vexpress-sysreg,func = <2 0>; 109 + regulator-name = "VIO_UP"; 110 + regulator-min-microvolt = <800000>; 111 + regulator-max-microvolt = <1800000>; 112 + regulator-always-on; 113 + }; 114 + 115 + volt@1 { 116 + /* 12V from power connector J6 */ 117 + compatible = "arm,vexpress-volt"; 118 + arm,vexpress-sysreg,func = <2 1>; 119 + regulator-name = "12"; 120 + regulator-always-on; 121 + }; 122 + 123 + temp@0 { 124 + /* FPGA temperature */ 125 + compatible = "arm,vexpress-temp"; 126 + arm,vexpress-sysreg,func = <4 0>; 127 + label = "FPGA"; 128 + }; 129 + }; 130 + 131 + smb { 132 + compatible = "simple-bus"; 133 + 134 + #address-cells = <2>; 135 + #size-cells = <1>; 136 + ranges = <0 0 0 0x08000000 0x04000000>, 137 + <1 0 0 0x14000000 0x04000000>, 138 + <2 0 0 0x18000000 0x04000000>, 139 + <3 0 0 0x1c000000 0x04000000>, 140 + <4 0 0 0x0c000000 0x04000000>, 141 + <5 0 0 0x10000000 0x04000000>; 142 + 143 + #interrupt-cells = <1>; 144 + interrupt-map-mask = <0 0 63>; 145 + interrupt-map = <0 0 0 &gic GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>, 146 + <0 0 1 &gic GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>, 147 + <0 0 2 &gic GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>, 148 + <0 0 3 &gic GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>, 149 + <0 0 4 &gic GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>, 150 + <0 0 5 &gic GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>, 151 + <0 0 6 &gic GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>, 152 + <0 0 7 &gic GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>, 153 + <0 0 8 &gic GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>, 154 + <0 0 9 &gic GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>, 155 + <0 0 10 &gic GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>, 156 + <0 0 11 &gic GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, 157 + <0 0 12 &gic GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>, 158 + <0 0 13 &gic GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>, 159 + <0 0 14 &gic GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>, 160 + <0 0 15 &gic GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>, 161 + <0 0 16 &gic GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>, 162 + <0 0 17 &gic GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>, 163 + <0 0 18 &gic GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>, 164 + <0 0 19 &gic GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>, 165 + <0 0 20 &gic GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>, 166 + <0 0 21 &gic GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>, 167 + <0 0 22 &gic GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>, 168 + <0 0 23 &gic GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>, 169 + <0 0 24 &gic GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>, 170 + <0 0 25 &gic GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>, 171 + <0 0 26 &gic GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>, 172 + <0 0 27 &gic GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>, 173 + <0 0 28 &gic GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>, 174 + <0 0 29 &gic GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>, 175 + <0 0 30 &gic GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>, 176 + <0 0 31 &gic GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>, 177 + <0 0 32 &gic GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>, 178 + <0 0 33 &gic GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>, 179 + <0 0 34 &gic GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>, 180 + <0 0 35 &gic GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>, 181 + <0 0 36 &gic GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>, 182 + <0 0 37 &gic GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>, 183 + <0 0 38 &gic GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>, 184 + <0 0 39 &gic GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>, 185 + <0 0 40 &gic GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>, 186 + <0 0 41 &gic GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>, 187 + <0 0 42 &gic GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>; 188 + 189 + /include/ "../../../../arm/boot/dts/vexpress-v2m-rs1.dtsi" 190 + }; 191 + };
+9
arch/arm64/boot/dts/cavium/thunder-88xx.dtsi
··· 376 376 gic0: interrupt-controller@8010,00000000 { 377 377 compatible = "arm,gic-v3"; 378 378 #interrupt-cells = <3>; 379 + #address-cells = <2>; 380 + #size-cells = <2>; 381 + ranges; 379 382 interrupt-controller; 380 383 reg = <0x8010 0x00000000 0x0 0x010000>, /* GICD */ 381 384 <0x8010 0x80000000 0x0 0x600000>; /* GICR */ 382 385 interrupts = <1 9 0xf04>; 386 + 387 + its: gic-its@8010,00020000 { 388 + compatible = "arm,gic-v3-its"; 389 + msi-controller; 390 + reg = <0x8010 0x20000 0x0 0x200000>; 391 + }; 383 392 }; 384 393 385 394 uaa0: serial@87e0,24000000 {
+1
arch/arm64/configs/defconfig
··· 83 83 CONFIG_ATA=y 84 84 CONFIG_SATA_AHCI=y 85 85 CONFIG_SATA_AHCI_PLATFORM=y 86 + CONFIG_AHCI_CEVA=y 86 87 CONFIG_AHCI_XGENE=y 87 88 CONFIG_PATA_PLATFORM=y 88 89 CONFIG_PATA_OF_PLATFORM=y
+8
arch/arm64/include/asm/acpi.h
··· 19 19 #include <asm/psci.h> 20 20 #include <asm/smp_plat.h> 21 21 22 + /* Macros for consistency checks of the GICC subtable of MADT */ 23 + #define ACPI_MADT_GICC_LENGTH \ 24 + (acpi_gbl_FADT.header.revision < 6 ? 76 : 80) 25 + 26 + #define BAD_MADT_GICC_ENTRY(entry, end) \ 27 + (!(entry) || (unsigned long)(entry) + sizeof(*(entry)) > (end) || \ 28 + (entry)->header.length != ACPI_MADT_GICC_LENGTH) 29 + 22 30 /* Basic configuration for ACPI */ 23 31 #ifdef CONFIG_ACPI 24 32 /* ACPI table mapping after acpi_gbl_permanent_mmap is set */
+2 -2
arch/arm64/kernel/entry.S
··· 352 352 // TODO: add support for undefined instructions in kernel mode 353 353 enable_dbg 354 354 mov x0, sp 355 + mov x2, x1 355 356 mov x1, #BAD_SYNC 356 - mrs x2, esr_el1 357 357 b bad_mode 358 358 ENDPROC(el1_sync) 359 359 ··· 553 553 ct_user_exit 554 554 mov x0, sp 555 555 mov x1, #BAD_SYNC 556 - mrs x2, esr_el1 556 + mov x2, x25 557 557 bl bad_mode 558 558 b ret_to_user 559 559 ENDPROC(el0_sync)
-2
arch/arm64/kernel/entry32.S
··· 32 32 33 33 ENTRY(compat_sys_sigreturn_wrapper) 34 34 mov x0, sp 35 - mov x27, #0 // prevent syscall restart handling (why) 36 35 b compat_sys_sigreturn 37 36 ENDPROC(compat_sys_sigreturn_wrapper) 38 37 39 38 ENTRY(compat_sys_rt_sigreturn_wrapper) 40 39 mov x0, sp 41 - mov x27, #0 // prevent syscall restart handling (why) 42 40 b compat_sys_rt_sigreturn 43 41 ENDPROC(compat_sys_rt_sigreturn_wrapper) 44 42
+1 -1
arch/arm64/kernel/smp.c
··· 438 438 struct acpi_madt_generic_interrupt *processor; 439 439 440 440 processor = (struct acpi_madt_generic_interrupt *)header; 441 - if (BAD_MADT_ENTRY(processor, end)) 441 + if (BAD_MADT_GICC_ENTRY(processor, end)) 442 442 return -EINVAL; 443 443 444 444 acpi_table_print_madt_entry(header);
-2
arch/arm64/mm/Makefile
··· 4 4 context.o proc.o pageattr.o 5 5 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 6 6 obj-$(CONFIG_ARM64_PTDUMP) += dump.o 7 - 8 - CFLAGS_mmu.o := -I$(srctree)/scripts/dtc/libfdt/
+1 -1
arch/cris/arch-v32/drivers/sync_serial.c
··· 1464 1464 if (port->write_ts_idx == NBR_IN_DESCR) 1465 1465 port->write_ts_idx = 0; 1466 1466 idx = port->write_ts_idx++; 1467 - do_posix_clock_monotonic_gettime(&port->timestamp[idx]); 1467 + ktime_get_ts(&port->timestamp[idx]); 1468 1468 port->in_buffer_len += port->inbufchunk; 1469 1469 } 1470 1470 spin_unlock_irqrestore(&port->lock, flags);
+1 -1
arch/mips/Kconfig
··· 2231 2231 2232 2232 config MIPS_CPS 2233 2233 bool "MIPS Coherent Processing System support" 2234 - depends on SYS_SUPPORTS_MIPS_CPS && !64BIT 2234 + depends on SYS_SUPPORTS_MIPS_CPS 2235 2235 select MIPS_CM 2236 2236 select MIPS_CPC 2237 2237 select MIPS_CPS_PM if HOTPLUG_CPU
+1 -1
arch/mips/include/asm/mach-loongson64/mmzone.h
··· 1 1 /* 2 2 * Copyright (C) 2010 Loongson Inc. & Lemote Inc. & 3 - * Insititute of Computing Technology 3 + * Institute of Computing Technology 4 4 * Author: Xiang Gao, gaoxiang@ict.ac.cn 5 5 * Huacai Chen, chenhc@lemote.com 6 6 * Xiaofu Meng, Shuangshuang Zhang
+1
arch/mips/include/asm/smp.h
··· 23 23 extern int smp_num_siblings; 24 24 extern cpumask_t cpu_sibling_map[]; 25 25 extern cpumask_t cpu_core_map[]; 26 + extern cpumask_t cpu_foreign_map; 26 27 27 28 #define raw_smp_processor_id() (current_thread_info()->cpu) 28 29
+2 -2
arch/mips/kernel/branch.c
··· 600 600 break; 601 601 602 602 case blezl_op: /* not really i_format */ 603 - if (NO_R6EMU) 603 + if (!insn.i_format.rt && NO_R6EMU) 604 604 goto sigill_r6; 605 605 case blez_op: 606 606 /* ··· 635 635 break; 636 636 637 637 case bgtzl_op: 638 - if (NO_R6EMU) 638 + if (!insn.i_format.rt && NO_R6EMU) 639 639 goto sigill_r6; 640 640 case bgtz_op: 641 641 /*
+48 -48
arch/mips/kernel/cps-vec.S
··· 60 60 nop 61 61 62 62 /* This is an NMI */ 63 - la k0, nmi_handler 63 + PTR_LA k0, nmi_handler 64 64 jr k0 65 65 nop 66 66 ··· 107 107 mul t1, t1, t0 108 108 mul t1, t1, t2 109 109 110 - li a0, KSEG0 111 - add a1, a0, t1 110 + li a0, CKSEG0 111 + PTR_ADD a1, a0, t1 112 112 1: cache Index_Store_Tag_I, 0(a0) 113 - add a0, a0, t0 113 + PTR_ADD a0, a0, t0 114 114 bne a0, a1, 1b 115 115 nop 116 116 icache_done: ··· 134 134 mul t1, t1, t0 135 135 mul t1, t1, t2 136 136 137 - li a0, KSEG0 138 - addu a1, a0, t1 139 - subu a1, a1, t0 137 + li a0, CKSEG0 138 + PTR_ADDU a1, a0, t1 139 + PTR_SUBU a1, a1, t0 140 140 1: cache Index_Store_Tag_D, 0(a0) 141 141 bne a0, a1, 1b 142 - add a0, a0, t0 142 + PTR_ADD a0, a0, t0 143 143 dcache_done: 144 144 145 145 /* Set Kseg0 CCA to that in s0 */ ··· 152 152 153 153 /* Enter the coherent domain */ 154 154 li t0, 0xff 155 - sw t0, GCR_CL_COHERENCE_OFS(v1) 155 + PTR_S t0, GCR_CL_COHERENCE_OFS(v1) 156 156 ehb 157 157 158 158 /* Jump to kseg0 */ 159 - la t0, 1f 159 + PTR_LA t0, 1f 160 160 jr t0 161 161 nop 162 162 ··· 178 178 nop 179 179 180 180 /* Off we go! */ 181 - lw t1, VPEBOOTCFG_PC(v0) 182 - lw gp, VPEBOOTCFG_GP(v0) 183 - lw sp, VPEBOOTCFG_SP(v0) 181 + PTR_L t1, VPEBOOTCFG_PC(v0) 182 + PTR_L gp, VPEBOOTCFG_GP(v0) 183 + PTR_L sp, VPEBOOTCFG_SP(v0) 184 184 jr t1 185 185 nop 186 186 END(mips_cps_core_entry) ··· 217 217 218 218 .org 0x480 219 219 LEAF(excep_ejtag) 220 - la k0, ejtag_debug_handler 220 + PTR_LA k0, ejtag_debug_handler 221 221 jr k0 222 222 nop 223 223 END(excep_ejtag) ··· 229 229 nop 230 230 231 231 .set push 232 - .set mips32r2 232 + .set mips64r2 233 233 .set mt 234 234 235 235 /* Only allow 1 TC per VPE to execute... */ ··· 237 237 238 238 /* ...and for the moment only 1 VPE */ 239 239 dvpe 240 - la t1, 1f 240 + PTR_LA t1, 1f 241 241 jr.hb t1 242 242 nop 243 243 ··· 250 250 mfc0 t0, CP0_MVPCONF0 251 251 srl t0, t0, MVPCONF0_PVPE_SHIFT 252 252 andi t0, t0, (MVPCONF0_PVPE >> MVPCONF0_PVPE_SHIFT) 253 - addiu t7, t0, 1 253 + addiu ta3, t0, 1 254 254 255 255 /* If there's only 1, we're done */ 256 256 beqz t0, 2f 257 257 nop 258 258 259 259 /* Loop through each VPE within this core */ 260 - li t5, 1 260 + li ta1, 1 261 261 262 262 1: /* Operate on the appropriate TC */ 263 - mtc0 t5, CP0_VPECONTROL 263 + mtc0 ta1, CP0_VPECONTROL 264 264 ehb 265 265 266 266 /* Bind TC to VPE (1:1 TC:VPE mapping) */ 267 - mttc0 t5, CP0_TCBIND 267 + mttc0 ta1, CP0_TCBIND 268 268 269 269 /* Set exclusive TC, non-active, master */ 270 270 li t0, VPECONF0_MVP 271 - sll t1, t5, VPECONF0_XTC_SHIFT 271 + sll t1, ta1, VPECONF0_XTC_SHIFT 272 272 or t0, t0, t1 273 273 mttc0 t0, CP0_VPECONF0 274 274 ··· 280 280 mttc0 t0, CP0_TCHALT 281 281 282 282 /* Next VPE */ 283 - addiu t5, t5, 1 284 - slt t0, t5, t7 283 + addiu ta1, ta1, 1 284 + slt t0, ta1, ta3 285 285 bnez t0, 1b 286 286 nop 287 287 ··· 298 298 299 299 LEAF(mips_cps_boot_vpes) 300 300 /* Retrieve CM base address */ 301 - la t0, mips_cm_base 302 - lw t0, 0(t0) 301 + PTR_LA t0, mips_cm_base 302 + PTR_L t0, 0(t0) 303 303 304 304 /* Calculate a pointer to this cores struct core_boot_config */ 305 - lw t0, GCR_CL_ID_OFS(t0) 305 + PTR_L t0, GCR_CL_ID_OFS(t0) 306 306 li t1, COREBOOTCFG_SIZE 307 307 mul t0, t0, t1 308 - la t1, mips_cps_core_bootcfg 309 - lw t1, 0(t1) 310 - addu t0, t0, t1 308 + PTR_LA t1, mips_cps_core_bootcfg 309 + PTR_L t1, 0(t1) 310 + PTR_ADDU t0, t0, t1 311 311 312 312 /* Calculate this VPEs ID. If the core doesn't support MT use 0 */ 313 - has_mt t6, 1f 313 + has_mt ta2, 1f 314 314 li t9, 0 315 315 316 316 /* Find the number of VPEs present in the core */ ··· 334 334 1: /* Calculate a pointer to this VPEs struct vpe_boot_config */ 335 335 li t1, VPEBOOTCFG_SIZE 336 336 mul v0, t9, t1 337 - lw t7, COREBOOTCFG_VPECONFIG(t0) 338 - addu v0, v0, t7 337 + PTR_L ta3, COREBOOTCFG_VPECONFIG(t0) 338 + PTR_ADDU v0, v0, ta3 339 339 340 340 #ifdef CONFIG_MIPS_MT 341 341 342 342 /* If the core doesn't support MT then return */ 343 - bnez t6, 1f 343 + bnez ta2, 1f 344 344 nop 345 345 jr ra 346 346 nop 347 347 348 348 .set push 349 - .set mips32r2 349 + .set mips64r2 350 350 .set mt 351 351 352 352 1: /* Enter VPE configuration state */ 353 353 dvpe 354 - la t1, 1f 354 + PTR_LA t1, 1f 355 355 jr.hb t1 356 356 nop 357 357 1: mfc0 t1, CP0_MVPCONTROL ··· 360 360 ehb 361 361 362 362 /* Loop through each VPE */ 363 - lw t6, COREBOOTCFG_VPEMASK(t0) 364 - move t8, t6 365 - li t5, 0 363 + PTR_L ta2, COREBOOTCFG_VPEMASK(t0) 364 + move t8, ta2 365 + li ta1, 0 366 366 367 367 /* Check whether the VPE should be running. If not, skip it */ 368 - 1: andi t0, t6, 1 368 + 1: andi t0, ta2, 1 369 369 beqz t0, 2f 370 370 nop 371 371 ··· 373 373 mfc0 t0, CP0_VPECONTROL 374 374 ori t0, t0, VPECONTROL_TARGTC 375 375 xori t0, t0, VPECONTROL_TARGTC 376 - or t0, t0, t5 376 + or t0, t0, ta1 377 377 mtc0 t0, CP0_VPECONTROL 378 378 ehb 379 379 ··· 384 384 385 385 /* Calculate a pointer to the VPEs struct vpe_boot_config */ 386 386 li t0, VPEBOOTCFG_SIZE 387 - mul t0, t0, t5 388 - addu t0, t0, t7 387 + mul t0, t0, ta1 388 + addu t0, t0, ta3 389 389 390 390 /* Set the TC restart PC */ 391 391 lw t1, VPEBOOTCFG_PC(t0) ··· 423 423 mttc0 t0, CP0_VPECONF0 424 424 425 425 /* Next VPE */ 426 - 2: srl t6, t6, 1 427 - addiu t5, t5, 1 428 - bnez t6, 1b 426 + 2: srl ta2, ta2, 1 427 + addiu ta1, ta1, 1 428 + bnez ta2, 1b 429 429 nop 430 430 431 431 /* Leave VPE configuration state */ ··· 445 445 /* This VPE should be offline, halt the TC */ 446 446 li t0, TCHALT_H 447 447 mtc0 t0, CP0_TCHALT 448 - la t0, 1f 448 + PTR_LA t0, 1f 449 449 1: jr.hb t0 450 450 nop 451 451 ··· 466 466 .set noat 467 467 lw $1, TI_CPU(gp) 468 468 sll $1, $1, LONGLOG 469 - la \dest, __per_cpu_offset 469 + PTR_LA \dest, __per_cpu_offset 470 470 addu $1, $1, \dest 471 471 lw $1, 0($1) 472 - la \dest, cps_cpu_state 472 + PTR_LA \dest, cps_cpu_state 473 473 addu \dest, \dest, $1 474 474 .set pop 475 475 .endm
+27 -10
arch/mips/kernel/scall32-o32.S
··· 73 73 .set noreorder 74 74 .set nomacro 75 75 76 - 1: user_lw(t5, 16(t0)) # argument #5 from usp 77 - 4: user_lw(t6, 20(t0)) # argument #6 from usp 78 - 3: user_lw(t7, 24(t0)) # argument #7 from usp 79 - 2: user_lw(t8, 28(t0)) # argument #8 from usp 76 + load_a4: user_lw(t5, 16(t0)) # argument #5 from usp 77 + load_a5: user_lw(t6, 20(t0)) # argument #6 from usp 78 + load_a6: user_lw(t7, 24(t0)) # argument #7 from usp 79 + load_a7: user_lw(t8, 28(t0)) # argument #8 from usp 80 + loads_done: 80 81 81 82 sw t5, 16(sp) # argument #5 to ksp 82 83 sw t6, 20(sp) # argument #6 to ksp ··· 86 85 .set pop 87 86 88 87 .section __ex_table,"a" 89 - PTR 1b,bad_stack 90 - PTR 2b,bad_stack 91 - PTR 3b,bad_stack 92 - PTR 4b,bad_stack 88 + PTR load_a4, bad_stack_a4 89 + PTR load_a5, bad_stack_a5 90 + PTR load_a6, bad_stack_a6 91 + PTR load_a7, bad_stack_a7 93 92 .previous 94 93 95 94 lw t0, TI_FLAGS($28) # syscall tracing enabled? ··· 154 153 /* ------------------------------------------------------------------------ */ 155 154 156 155 /* 157 - * The stackpointer for a call with more than 4 arguments is bad. 158 - * We probably should handle this case a bit more drastic. 156 + * Our open-coded access area sanity test for the stack pointer 157 + * failed. We probably should handle this case a bit more drastic. 159 158 */ 160 159 bad_stack: 161 160 li v0, EFAULT ··· 163 162 li t0, 1 # set error flag 164 163 sw t0, PT_R7(sp) 165 164 j o32_syscall_exit 165 + 166 + bad_stack_a4: 167 + li t5, 0 168 + b load_a5 169 + 170 + bad_stack_a5: 171 + li t6, 0 172 + b load_a6 173 + 174 + bad_stack_a6: 175 + li t7, 0 176 + b load_a7 177 + 178 + bad_stack_a7: 179 + li t8, 0 180 + b loads_done 166 181 167 182 /* 168 183 * The system call does not exist in this kernel
+26 -9
arch/mips/kernel/scall64-o32.S
··· 69 69 daddu t1, t0, 32 70 70 bltz t1, bad_stack 71 71 72 - 1: lw a4, 16(t0) # argument #5 from usp 73 - 2: lw a5, 20(t0) # argument #6 from usp 74 - 3: lw a6, 24(t0) # argument #7 from usp 75 - 4: lw a7, 28(t0) # argument #8 from usp (for indirect syscalls) 72 + load_a4: lw a4, 16(t0) # argument #5 from usp 73 + load_a5: lw a5, 20(t0) # argument #6 from usp 74 + load_a6: lw a6, 24(t0) # argument #7 from usp 75 + load_a7: lw a7, 28(t0) # argument #8 from usp 76 + loads_done: 76 77 77 78 .section __ex_table,"a" 78 - PTR 1b, bad_stack 79 - PTR 2b, bad_stack 80 - PTR 3b, bad_stack 81 - PTR 4b, bad_stack 79 + PTR load_a4, bad_stack_a4 80 + PTR load_a5, bad_stack_a5 81 + PTR load_a6, bad_stack_a6 82 + PTR load_a7, bad_stack_a7 82 83 .previous 83 84 84 85 li t1, _TIF_WORK_SYSCALL_ENTRY ··· 167 166 li t0, 1 # set error flag 168 167 sd t0, PT_R7(sp) 169 168 j o32_syscall_exit 169 + 170 + bad_stack_a4: 171 + li a4, 0 172 + b load_a5 173 + 174 + bad_stack_a5: 175 + li a5, 0 176 + b load_a6 177 + 178 + bad_stack_a6: 179 + li a6, 0 180 + b load_a7 181 + 182 + bad_stack_a7: 183 + li a7, 0 184 + b loads_done 170 185 171 186 not_o32_scall: 172 187 /* ··· 400 383 PTR sys_connect /* 4170 */ 401 384 PTR sys_getpeername 402 385 PTR sys_getsockname 403 - PTR sys_getsockopt 386 + PTR compat_sys_getsockopt 404 387 PTR sys_listen 405 388 PTR compat_sys_recv /* 4175 */ 406 389 PTR compat_sys_recvfrom
+5 -8
arch/mips/kernel/setup.c
··· 337 337 min_low_pfn = start; 338 338 if (end <= reserved_end) 339 339 continue; 340 + #ifdef CONFIG_BLK_DEV_INITRD 341 + /* mapstart should be after initrd_end */ 342 + if (initrd_end && end <= (unsigned long)PFN_UP(__pa(initrd_end))) 343 + continue; 344 + #endif 340 345 if (start >= mapstart) 341 346 continue; 342 347 mapstart = max(reserved_end, start); ··· 370 365 #endif 371 366 max_low_pfn = PFN_DOWN(HIGHMEM_START); 372 367 } 373 - 374 - #ifdef CONFIG_BLK_DEV_INITRD 375 - /* 376 - * mapstart should be after initrd_end 377 - */ 378 - if (initrd_end) 379 - mapstart = max(mapstart, (unsigned long)PFN_UP(__pa(initrd_end))); 380 - #endif 381 368 382 369 /* 383 370 * Initialize the boot-time allocator with low memory only.
+3 -3
arch/mips/kernel/smp-cps.c
··· 133 133 /* 134 134 * Patch the start of mips_cps_core_entry to provide: 135 135 * 136 - * v0 = CM base address 136 + * v1 = CM base address 137 137 * s0 = kseg0 CCA 138 138 */ 139 139 entry_code = (u32 *)&mips_cps_core_entry; ··· 369 369 370 370 static void wait_for_sibling_halt(void *ptr_cpu) 371 371 { 372 - unsigned cpu = (unsigned)ptr_cpu; 372 + unsigned cpu = (unsigned long)ptr_cpu; 373 373 unsigned vpe_id = cpu_vpe_id(&cpu_data[cpu]); 374 374 unsigned halted; 375 375 unsigned long flags; ··· 430 430 */ 431 431 err = smp_call_function_single(cpu_death_sibling, 432 432 wait_for_sibling_halt, 433 - (void *)cpu, 1); 433 + (void *)(unsigned long)cpu, 1); 434 434 if (err) 435 435 panic("Failed to call remote sibling CPU\n"); 436 436 }
+43 -1
arch/mips/kernel/smp.c
··· 63 63 cpumask_t cpu_core_map[NR_CPUS] __read_mostly; 64 64 EXPORT_SYMBOL(cpu_core_map); 65 65 66 + /* 67 + * A logcal cpu mask containing only one VPE per core to 68 + * reduce the number of IPIs on large MT systems. 69 + */ 70 + cpumask_t cpu_foreign_map __read_mostly; 71 + EXPORT_SYMBOL(cpu_foreign_map); 72 + 66 73 /* representing cpus for which sibling maps can be computed */ 67 74 static cpumask_t cpu_sibling_setup_map; 68 75 ··· 108 101 cpumask_set_cpu(cpu, &cpu_core_map[i]); 109 102 } 110 103 } 104 + } 105 + 106 + /* 107 + * Calculate a new cpu_foreign_map mask whenever a 108 + * new cpu appears or disappears. 109 + */ 110 + static inline void calculate_cpu_foreign_map(void) 111 + { 112 + int i, k, core_present; 113 + cpumask_t temp_foreign_map; 114 + 115 + /* Re-calculate the mask */ 116 + for_each_online_cpu(i) { 117 + core_present = 0; 118 + for_each_cpu(k, &temp_foreign_map) 119 + if (cpu_data[i].package == cpu_data[k].package && 120 + cpu_data[i].core == cpu_data[k].core) 121 + core_present = 1; 122 + if (!core_present) 123 + cpumask_set_cpu(i, &temp_foreign_map); 124 + } 125 + 126 + cpumask_copy(&cpu_foreign_map, &temp_foreign_map); 111 127 } 112 128 113 129 struct plat_smp_ops *mp_ops; ··· 176 146 set_cpu_sibling_map(cpu); 177 147 set_cpu_core_map(cpu); 178 148 149 + calculate_cpu_foreign_map(); 150 + 179 151 cpumask_set_cpu(cpu, &cpu_callin_map); 180 152 181 153 synchronise_count_slave(cpu); ··· 205 173 static void stop_this_cpu(void *dummy) 206 174 { 207 175 /* 208 - * Remove this CPU: 176 + * Remove this CPU. Be a bit slow here and 177 + * set the bits for every online CPU so we don't miss 178 + * any IPI whilst taking this VPE down. 209 179 */ 180 + 181 + cpumask_copy(&cpu_foreign_map, cpu_online_mask); 182 + 183 + /* Make it visible to every other CPU */ 184 + smp_mb(); 185 + 210 186 set_cpu_online(smp_processor_id(), false); 187 + calculate_cpu_foreign_map(); 211 188 local_irq_disable(); 212 189 while (1); 213 190 } ··· 238 197 mp_ops->prepare_cpus(max_cpus); 239 198 set_cpu_sibling_map(0); 240 199 set_cpu_core_map(0); 200 + calculate_cpu_foreign_map(); 241 201 #ifndef CONFIG_HOTPLUG_CPU 242 202 init_cpu_present(cpu_possible_mask); 243 203 #endif
+4 -4
arch/mips/kernel/traps.c
··· 2130 2130 BUG_ON(current->mm); 2131 2131 enter_lazy_tlb(&init_mm, current); 2132 2132 2133 - /* Boot CPU's cache setup in setup_arch(). */ 2134 - if (!is_boot_cpu) 2135 - cpu_cache_init(); 2136 - tlb_init(); 2133 + /* Boot CPU's cache setup in setup_arch(). */ 2134 + if (!is_boot_cpu) 2135 + cpu_cache_init(); 2136 + tlb_init(); 2137 2137 TLBMISS_HANDLER_SETUP(); 2138 2138 } 2139 2139
+1 -1
arch/mips/loongson64/common/bonito-irq.c
··· 3 3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net 4 4 * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org) 5 5 * 6 - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology 6 + * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology 7 7 * Author: Fuxin Zhang, zhangfx@lemote.com 8 8 * 9 9 * This program is free software; you can redistribute it and/or modify it
+1 -1
arch/mips/loongson64/common/cmdline.c
··· 6 6 * Copyright 2003 ICT CAS 7 7 * Author: Michael Guo <guoyi@ict.ac.cn> 8 8 * 9 - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology 9 + * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology 10 10 * Author: Fuxin Zhang, zhangfx@lemote.com 11 11 * 12 12 * Copyright (C) 2009 Lemote Inc.
+1 -1
arch/mips/loongson64/common/cs5536/cs5536_mfgpt.c
··· 1 1 /* 2 2 * CS5536 General timer functions 3 3 * 4 - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology 4 + * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology 5 5 * Author: Yanhua, yanh@lemote.com 6 6 * 7 7 * Copyright (C) 2009 Lemote Inc.
+1 -1
arch/mips/loongson64/common/env.c
··· 6 6 * Copyright 2003 ICT CAS 7 7 * Author: Michael Guo <guoyi@ict.ac.cn> 8 8 * 9 - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology 9 + * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology 10 10 * Author: Fuxin Zhang, zhangfx@lemote.com 11 11 * 12 12 * Copyright (C) 2009 Lemote Inc.
+1 -1
arch/mips/loongson64/common/irq.c
··· 1 1 /* 2 - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology 2 + * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology 3 3 * Author: Fuxin Zhang, zhangfx@lemote.com 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it
+1 -1
arch/mips/loongson64/common/setup.c
··· 1 1 /* 2 - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology 2 + * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology 3 3 * Author: Fuxin Zhang, zhangfx@lemote.com 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it
+1 -1
arch/mips/loongson64/fuloong-2e/irq.c
··· 1 1 /* 2 - * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology 2 + * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology 3 3 * Author: Fuxin Zhang, zhangfx@lemote.com 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it
+2 -2
arch/mips/loongson64/lemote-2f/clock.c
··· 1 1 /* 2 - * Copyright (C) 2006 - 2008 Lemote Inc. & Insititute of Computing Technology 2 + * Copyright (C) 2006 - 2008 Lemote Inc. & Institute of Computing Technology 3 3 * Author: Yanhua, yanh@lemote.com 4 4 * 5 5 * This file is subject to the terms and conditions of the GNU General Public ··· 15 15 #include <linux/spinlock.h> 16 16 17 17 #include <asm/clock.h> 18 - #include <asm/mach-loongson/loongson.h> 18 + #include <asm/mach-loongson64/loongson.h> 19 19 20 20 static LIST_HEAD(clock_list); 21 21 static DEFINE_SPINLOCK(clock_lock);
+1 -1
arch/mips/loongson64/loongson-3/numa.c
··· 1 1 /* 2 2 * Copyright (C) 2010 Loongson Inc. & Lemote Inc. & 3 - * Insititute of Computing Technology 3 + * Institute of Computing Technology 4 4 * Author: Xiang Gao, gaoxiang@ict.ac.cn 5 5 * Huacai Chen, chenhc@lemote.com 6 6 * Xiaofu Meng, Shuangshuang Zhang
+3 -3
arch/mips/math-emu/cp1emu.c
··· 451 451 /* Fall through */ 452 452 case jr_op: 453 453 /* For R6, JR already emulated in jalr_op */ 454 - if (NO_R6EMU && insn.r_format.opcode == jr_op) 454 + if (NO_R6EMU && insn.r_format.func == jr_op) 455 455 break; 456 456 *contpc = regs->regs[insn.r_format.rs]; 457 457 return 1; ··· 551 551 dec_insn.next_pc_inc; 552 552 return 1; 553 553 case blezl_op: 554 - if (NO_R6EMU) 554 + if (!insn.i_format.rt && NO_R6EMU) 555 555 break; 556 556 case blez_op: 557 557 ··· 588 588 dec_insn.next_pc_inc; 589 589 return 1; 590 590 case bgtzl_op: 591 - if (NO_R6EMU) 591 + if (!insn.i_format.rt && NO_R6EMU) 592 592 break; 593 593 case bgtz_op: 594 594 /*
+14 -4
arch/mips/mm/c-r4k.c
··· 37 37 #include <asm/cacheflush.h> /* for run_uncached() */ 38 38 #include <asm/traps.h> 39 39 #include <asm/dma-coherence.h> 40 + #include <asm/mips-cm.h> 40 41 41 42 /* 42 43 * Special Variant of smp_call_function for use by cache functions: ··· 52 51 { 53 52 preempt_disable(); 54 53 55 - #ifndef CONFIG_MIPS_MT_SMP 56 - smp_call_function(func, info, 1); 57 - #endif 54 + /* 55 + * The Coherent Manager propagates address-based cache ops to other 56 + * cores but not index-based ops. However, r4k_on_each_cpu is used 57 + * in both cases so there is no easy way to tell what kind of op is 58 + * executed to the other cores. The best we can probably do is 59 + * to restrict that call when a CM is not present because both 60 + * CM-based SMP protocols (CMP & CPS) restrict index-based cache ops. 61 + */ 62 + if (!mips_cm_present()) 63 + smp_call_function_many(&cpu_foreign_map, func, info, 1); 58 64 func(info); 59 65 preempt_enable(); 60 66 } ··· 945 937 } 946 938 947 939 static char *way_string[] = { NULL, "direct mapped", "2-way", 948 - "3-way", "4-way", "5-way", "6-way", "7-way", "8-way" 940 + "3-way", "4-way", "5-way", "6-way", "7-way", "8-way", 941 + "9-way", "10-way", "11-way", "12-way", 942 + "13-way", "14-way", "15-way", "16-way", 949 943 }; 950 944 951 945 static void probe_pcache(void)
+13 -7
arch/mips/mti-malta/malta-time.c
··· 119 119 120 120 int get_c0_fdc_int(void) 121 121 { 122 - int mips_cpu_fdc_irq; 122 + /* 123 + * Some cores claim the FDC is routable through the GIC, but it doesn't 124 + * actually seem to be connected for those Malta bitstreams. 125 + */ 126 + switch (current_cpu_type()) { 127 + case CPU_INTERAPTIV: 128 + case CPU_PROAPTIV: 129 + return -1; 130 + }; 123 131 124 132 if (cpu_has_veic) 125 - mips_cpu_fdc_irq = -1; 133 + return -1; 126 134 else if (gic_present) 127 - mips_cpu_fdc_irq = gic_get_c0_fdc_int(); 135 + return gic_get_c0_fdc_int(); 128 136 else if (cp0_fdc_irq >= 0) 129 - mips_cpu_fdc_irq = MIPS_CPU_IRQ_BASE + cp0_fdc_irq; 137 + return MIPS_CPU_IRQ_BASE + cp0_fdc_irq; 130 138 else 131 - mips_cpu_fdc_irq = -1; 132 - 133 - return mips_cpu_fdc_irq; 139 + return -1; 134 140 } 135 141 136 142 int get_c0_perfcount_int(void)
+7 -1
arch/mips/pistachio/init.c
··· 63 63 plat_setup_iocoherency(); 64 64 } 65 65 66 - #define DEFAULT_CPC_BASE_ADDR 0x1bde0000 66 + #define DEFAULT_CPC_BASE_ADDR 0x1bde0000 67 + #define DEFAULT_CDMM_BASE_ADDR 0x1bdd0000 67 68 68 69 phys_addr_t mips_cpc_default_phys_base(void) 69 70 { 70 71 return DEFAULT_CPC_BASE_ADDR; 72 + } 73 + 74 + phys_addr_t mips_cdmm_phys_base(void) 75 + { 76 + return DEFAULT_CDMM_BASE_ADDR; 71 77 } 72 78 73 79 static void __init mips_nmi_setup(void)
+5
arch/mips/pistachio/time.c
··· 27 27 return gic_get_c0_perfcount_int(); 28 28 } 29 29 30 + int get_c0_fdc_int(void) 31 + { 32 + return gic_get_c0_fdc_int(); 33 + } 34 + 30 35 void __init plat_time_init(void) 31 36 { 32 37 struct device_node *np;
+37 -18
arch/parisc/include/asm/pgtable.h
··· 16 16 #include <asm/processor.h> 17 17 #include <asm/cache.h> 18 18 19 - extern spinlock_t pa_dbit_lock; 19 + extern spinlock_t pa_tlb_lock; 20 20 21 21 /* 22 22 * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel ··· 33 33 */ 34 34 #define kern_addr_valid(addr) (1) 35 35 36 + /* Purge data and instruction TLB entries. Must be called holding 37 + * the pa_tlb_lock. The TLB purge instructions are slow on SMP 38 + * machines since the purge must be broadcast to all CPUs. 39 + */ 40 + 41 + static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr) 42 + { 43 + mtsp(mm->context, 1); 44 + pdtlb(addr); 45 + if (unlikely(split_tlb)) 46 + pitlb(addr); 47 + } 48 + 36 49 /* Certain architectures need to do special things when PTEs 37 50 * within a page table are directly modified. Thus, the following 38 51 * hook is made available. ··· 55 42 *(pteptr) = (pteval); \ 56 43 } while(0) 57 44 58 - extern void purge_tlb_entries(struct mm_struct *, unsigned long); 45 + #define pte_inserted(x) \ 46 + ((pte_val(x) & (_PAGE_PRESENT|_PAGE_ACCESSED)) \ 47 + == (_PAGE_PRESENT|_PAGE_ACCESSED)) 59 48 60 - #define set_pte_at(mm, addr, ptep, pteval) \ 61 - do { \ 49 + #define set_pte_at(mm, addr, ptep, pteval) \ 50 + do { \ 51 + pte_t old_pte; \ 62 52 unsigned long flags; \ 63 - spin_lock_irqsave(&pa_dbit_lock, flags); \ 64 - set_pte(ptep, pteval); \ 65 - purge_tlb_entries(mm, addr); \ 66 - spin_unlock_irqrestore(&pa_dbit_lock, flags); \ 53 + spin_lock_irqsave(&pa_tlb_lock, flags); \ 54 + old_pte = *ptep; \ 55 + set_pte(ptep, pteval); \ 56 + if (pte_inserted(old_pte)) \ 57 + purge_tlb_entries(mm, addr); \ 58 + spin_unlock_irqrestore(&pa_tlb_lock, flags); \ 67 59 } while (0) 68 60 69 61 #endif /* !__ASSEMBLY__ */ ··· 286 268 287 269 #define pte_none(x) (pte_val(x) == 0) 288 270 #define pte_present(x) (pte_val(x) & _PAGE_PRESENT) 289 - #define pte_clear(mm,addr,xp) do { pte_val(*(xp)) = 0; } while (0) 271 + #define pte_clear(mm, addr, xp) set_pte_at(mm, addr, xp, __pte(0)) 290 272 291 273 #define pmd_flag(x) (pmd_val(x) & PxD_FLAG_MASK) 292 274 #define pmd_address(x) ((unsigned long)(pmd_val(x) &~ PxD_FLAG_MASK) << PxD_VALUE_SHIFT) ··· 453 435 if (!pte_young(*ptep)) 454 436 return 0; 455 437 456 - spin_lock_irqsave(&pa_dbit_lock, flags); 438 + spin_lock_irqsave(&pa_tlb_lock, flags); 457 439 pte = *ptep; 458 440 if (!pte_young(pte)) { 459 - spin_unlock_irqrestore(&pa_dbit_lock, flags); 441 + spin_unlock_irqrestore(&pa_tlb_lock, flags); 460 442 return 0; 461 443 } 462 444 set_pte(ptep, pte_mkold(pte)); 463 445 purge_tlb_entries(vma->vm_mm, addr); 464 - spin_unlock_irqrestore(&pa_dbit_lock, flags); 446 + spin_unlock_irqrestore(&pa_tlb_lock, flags); 465 447 return 1; 466 448 } 467 449 ··· 471 453 pte_t old_pte; 472 454 unsigned long flags; 473 455 474 - spin_lock_irqsave(&pa_dbit_lock, flags); 456 + spin_lock_irqsave(&pa_tlb_lock, flags); 475 457 old_pte = *ptep; 476 - pte_clear(mm,addr,ptep); 477 - purge_tlb_entries(mm, addr); 478 - spin_unlock_irqrestore(&pa_dbit_lock, flags); 458 + set_pte(ptep, __pte(0)); 459 + if (pte_inserted(old_pte)) 460 + purge_tlb_entries(mm, addr); 461 + spin_unlock_irqrestore(&pa_tlb_lock, flags); 479 462 480 463 return old_pte; 481 464 } ··· 484 465 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 485 466 { 486 467 unsigned long flags; 487 - spin_lock_irqsave(&pa_dbit_lock, flags); 468 + spin_lock_irqsave(&pa_tlb_lock, flags); 488 469 set_pte(ptep, pte_wrprotect(*ptep)); 489 470 purge_tlb_entries(mm, addr); 490 - spin_unlock_irqrestore(&pa_dbit_lock, flags); 471 + spin_unlock_irqrestore(&pa_tlb_lock, flags); 491 472 } 492 473 493 474 #define pte_same(A,B) (pte_val(A) == pte_val(B))
+29 -24
arch/parisc/include/asm/tlbflush.h
··· 13 13 * active at any one time on the Merced bus. This tlb purge 14 14 * synchronisation is fairly lightweight and harmless so we activate 15 15 * it on all systems not just the N class. 16 + 17 + * It is also used to ensure PTE updates are atomic and consistent 18 + * with the TLB. 16 19 */ 17 20 extern spinlock_t pa_tlb_lock; 18 21 ··· 27 24 28 25 #define smp_flush_tlb_all() flush_tlb_all() 29 26 27 + int __flush_tlb_range(unsigned long sid, 28 + unsigned long start, unsigned long end); 29 + 30 + #define flush_tlb_range(vma, start, end) \ 31 + __flush_tlb_range((vma)->vm_mm->context, start, end) 32 + 33 + #define flush_tlb_kernel_range(start, end) \ 34 + __flush_tlb_range(0, start, end) 35 + 30 36 /* 31 37 * flush_tlb_mm() 32 38 * 33 - * XXX This code is NOT valid for HP-UX compatibility processes, 34 - * (although it will probably work 99% of the time). HP-UX 35 - * processes are free to play with the space id's and save them 36 - * over long periods of time, etc. so we have to preserve the 37 - * space and just flush the entire tlb. We need to check the 38 - * personality in order to do that, but the personality is not 39 - * currently being set correctly. 40 - * 41 - * Of course, Linux processes could do the same thing, but 42 - * we don't support that (and the compilers, dynamic linker, 43 - * etc. do not do that). 39 + * The code to switch to a new context is NOT valid for processes 40 + * which play with the space id's. Thus, we have to preserve the 41 + * space and just flush the entire tlb. However, the compilers, 42 + * dynamic linker, etc, do not manipulate space id's, so there 43 + * could be a significant performance benefit in switching contexts 44 + * and not flushing the whole tlb. 44 45 */ 45 46 46 47 static inline void flush_tlb_mm(struct mm_struct *mm) ··· 52 45 BUG_ON(mm == &init_mm); /* Should never happen */ 53 46 54 47 #if 1 || defined(CONFIG_SMP) 48 + /* Except for very small threads, flushing the whole TLB is 49 + * faster than using __flush_tlb_range. The pdtlb and pitlb 50 + * instructions are very slow because of the TLB broadcast. 51 + * It might be faster to do local range flushes on all CPUs 52 + * on PA 2.0 systems. 53 + */ 55 54 flush_tlb_all(); 56 55 #else 57 56 /* FIXME: currently broken, causing space id and protection ids 58 - * to go out of sync, resulting in faults on userspace accesses. 57 + * to go out of sync, resulting in faults on userspace accesses. 58 + * This approach needs further investigation since running many 59 + * small applications (e.g., GCC testsuite) is faster on HP-UX. 59 60 */ 60 61 if (mm) { 61 62 if (mm->context != 0) ··· 80 65 { 81 66 unsigned long flags, sid; 82 67 83 - /* For one page, it's not worth testing the split_tlb variable */ 84 - 85 - mb(); 86 68 sid = vma->vm_mm->context; 87 69 purge_tlb_start(flags); 88 70 mtsp(sid, 1); 89 71 pdtlb(addr); 90 - pitlb(addr); 72 + if (unlikely(split_tlb)) 73 + pitlb(addr); 91 74 purge_tlb_end(flags); 92 75 } 93 - 94 - void __flush_tlb_range(unsigned long sid, 95 - unsigned long start, unsigned long end); 96 - 97 - #define flush_tlb_range(vma,start,end) __flush_tlb_range((vma)->vm_mm->context,start,end) 98 - 99 - #define flush_tlb_kernel_range(start, end) __flush_tlb_range(0,start,end) 100 - 101 76 #endif
+67 -38
arch/parisc/kernel/cache.c
··· 342 342 EXPORT_SYMBOL(flush_kernel_icache_range_asm); 343 343 344 344 #define FLUSH_THRESHOLD 0x80000 /* 0.5MB */ 345 - int parisc_cache_flush_threshold __read_mostly = FLUSH_THRESHOLD; 345 + static unsigned long parisc_cache_flush_threshold __read_mostly = FLUSH_THRESHOLD; 346 + 347 + #define FLUSH_TLB_THRESHOLD (2*1024*1024) /* 2MB initial TLB threshold */ 348 + static unsigned long parisc_tlb_flush_threshold __read_mostly = FLUSH_TLB_THRESHOLD; 346 349 347 350 void __init parisc_setup_cache_timing(void) 348 351 { 349 352 unsigned long rangetime, alltime; 350 - unsigned long size; 353 + unsigned long size, start; 351 354 352 355 alltime = mfctl(16); 353 356 flush_data_cache(); ··· 367 364 /* Racy, but if we see an intermediate value, it's ok too... */ 368 365 parisc_cache_flush_threshold = size * alltime / rangetime; 369 366 370 - parisc_cache_flush_threshold = (parisc_cache_flush_threshold + L1_CACHE_BYTES - 1) &~ (L1_CACHE_BYTES - 1); 367 + parisc_cache_flush_threshold = L1_CACHE_ALIGN(parisc_cache_flush_threshold); 371 368 if (!parisc_cache_flush_threshold) 372 369 parisc_cache_flush_threshold = FLUSH_THRESHOLD; 373 370 374 371 if (parisc_cache_flush_threshold > cache_info.dc_size) 375 372 parisc_cache_flush_threshold = cache_info.dc_size; 376 373 377 - printk(KERN_INFO "Setting cache flush threshold to %x (%d CPUs online)\n", parisc_cache_flush_threshold, num_online_cpus()); 374 + printk(KERN_INFO "Setting cache flush threshold to %lu kB\n", 375 + parisc_cache_flush_threshold/1024); 376 + 377 + /* calculate TLB flush threshold */ 378 + 379 + alltime = mfctl(16); 380 + flush_tlb_all(); 381 + alltime = mfctl(16) - alltime; 382 + 383 + size = PAGE_SIZE; 384 + start = (unsigned long) _text; 385 + rangetime = mfctl(16); 386 + while (start < (unsigned long) _end) { 387 + flush_tlb_kernel_range(start, start + PAGE_SIZE); 388 + start += PAGE_SIZE; 389 + size += PAGE_SIZE; 390 + } 391 + rangetime = mfctl(16) - rangetime; 392 + 393 + printk(KERN_DEBUG "Whole TLB flush %lu cycles, flushing %lu bytes %lu cycles\n", 394 + alltime, size, rangetime); 395 + 396 + parisc_tlb_flush_threshold = size * alltime / rangetime; 397 + parisc_tlb_flush_threshold *= num_online_cpus(); 398 + parisc_tlb_flush_threshold = PAGE_ALIGN(parisc_tlb_flush_threshold); 399 + if (!parisc_tlb_flush_threshold) 400 + parisc_tlb_flush_threshold = FLUSH_TLB_THRESHOLD; 401 + 402 + printk(KERN_INFO "Setting TLB flush threshold to %lu kB\n", 403 + parisc_tlb_flush_threshold/1024); 378 404 } 379 405 380 406 extern void purge_kernel_dcache_page_asm(unsigned long); ··· 435 403 } 436 404 EXPORT_SYMBOL(copy_user_page); 437 405 438 - void purge_tlb_entries(struct mm_struct *mm, unsigned long addr) 406 + /* __flush_tlb_range() 407 + * 408 + * returns 1 if all TLBs were flushed. 409 + */ 410 + int __flush_tlb_range(unsigned long sid, unsigned long start, 411 + unsigned long end) 439 412 { 440 - unsigned long flags; 413 + unsigned long flags, size; 441 414 442 - /* Note: purge_tlb_entries can be called at startup with 443 - no context. */ 444 - 445 - purge_tlb_start(flags); 446 - mtsp(mm->context, 1); 447 - pdtlb(addr); 448 - pitlb(addr); 449 - purge_tlb_end(flags); 450 - } 451 - EXPORT_SYMBOL(purge_tlb_entries); 452 - 453 - void __flush_tlb_range(unsigned long sid, unsigned long start, 454 - unsigned long end) 455 - { 456 - unsigned long npages; 457 - 458 - npages = ((end - (start & PAGE_MASK)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT; 459 - if (npages >= 512) /* 2MB of space: arbitrary, should be tuned */ 415 + size = (end - start); 416 + if (size >= parisc_tlb_flush_threshold) { 460 417 flush_tlb_all(); 461 - else { 462 - unsigned long flags; 418 + return 1; 419 + } 463 420 421 + /* Purge TLB entries for small ranges using the pdtlb and 422 + pitlb instructions. These instructions execute locally 423 + but cause a purge request to be broadcast to other TLBs. */ 424 + if (likely(!split_tlb)) { 425 + while (start < end) { 426 + purge_tlb_start(flags); 427 + mtsp(sid, 1); 428 + pdtlb(start); 429 + purge_tlb_end(flags); 430 + start += PAGE_SIZE; 431 + } 432 + return 0; 433 + } 434 + 435 + /* split TLB case */ 436 + while (start < end) { 464 437 purge_tlb_start(flags); 465 438 mtsp(sid, 1); 466 - if (split_tlb) { 467 - while (npages--) { 468 - pdtlb(start); 469 - pitlb(start); 470 - start += PAGE_SIZE; 471 - } 472 - } else { 473 - while (npages--) { 474 - pdtlb(start); 475 - start += PAGE_SIZE; 476 - } 477 - } 439 + pdtlb(start); 440 + pitlb(start); 478 441 purge_tlb_end(flags); 442 + start += PAGE_SIZE; 479 443 } 444 + return 0; 480 445 } 481 446 482 447 static void cacheflush_h_tmp_function(void *dummy)
+79 -84
arch/parisc/kernel/entry.S
··· 45 45 .level 2.0 46 46 #endif 47 47 48 - .import pa_dbit_lock,data 48 + .import pa_tlb_lock,data 49 49 50 50 /* space_to_prot macro creates a prot id from a space id */ 51 51 ··· 420 420 SHLREG %r9,PxD_VALUE_SHIFT,\pmd 421 421 extru \va,31-PAGE_SHIFT,ASM_BITS_PER_PTE,\index 422 422 dep %r0,31,PAGE_SHIFT,\pmd /* clear offset */ 423 - shladd \index,BITS_PER_PTE_ENTRY,\pmd,\pmd 424 - LDREG %r0(\pmd),\pte /* pmd is now pte */ 423 + shladd \index,BITS_PER_PTE_ENTRY,\pmd,\pmd /* pmd is now pte */ 424 + LDREG %r0(\pmd),\pte 425 425 bb,>=,n \pte,_PAGE_PRESENT_BIT,\fault 426 426 .endm 427 427 ··· 453 453 L2_ptep \pgd,\pte,\index,\va,\fault 454 454 .endm 455 455 456 - /* Acquire pa_dbit_lock lock. */ 457 - .macro dbit_lock spc,tmp,tmp1 456 + /* Acquire pa_tlb_lock lock and recheck page is still present. */ 457 + .macro tlb_lock spc,ptp,pte,tmp,tmp1,fault 458 458 #ifdef CONFIG_SMP 459 459 cmpib,COND(=),n 0,\spc,2f 460 - load32 PA(pa_dbit_lock),\tmp 460 + load32 PA(pa_tlb_lock),\tmp 461 461 1: LDCW 0(\tmp),\tmp1 462 462 cmpib,COND(=) 0,\tmp1,1b 463 463 nop 464 + LDREG 0(\ptp),\pte 465 + bb,<,n \pte,_PAGE_PRESENT_BIT,2f 466 + b \fault 467 + stw \spc,0(\tmp) 464 468 2: 465 469 #endif 466 470 .endm 467 471 468 - /* Release pa_dbit_lock lock without reloading lock address. */ 469 - .macro dbit_unlock0 spc,tmp 472 + /* Release pa_tlb_lock lock without reloading lock address. */ 473 + .macro tlb_unlock0 spc,tmp 470 474 #ifdef CONFIG_SMP 471 475 or,COND(=) %r0,\spc,%r0 472 476 stw \spc,0(\tmp) 473 477 #endif 474 478 .endm 475 479 476 - /* Release pa_dbit_lock lock. */ 477 - .macro dbit_unlock1 spc,tmp 480 + /* Release pa_tlb_lock lock. */ 481 + .macro tlb_unlock1 spc,tmp 478 482 #ifdef CONFIG_SMP 479 - load32 PA(pa_dbit_lock),\tmp 480 - dbit_unlock0 \spc,\tmp 483 + load32 PA(pa_tlb_lock),\tmp 484 + tlb_unlock0 \spc,\tmp 481 485 #endif 482 486 .endm 483 487 484 488 /* Set the _PAGE_ACCESSED bit of the PTE. Be clever and 485 489 * don't needlessly dirty the cache line if it was already set */ 486 - .macro update_ptep spc,ptep,pte,tmp,tmp1 487 - #ifdef CONFIG_SMP 488 - or,COND(=) %r0,\spc,%r0 489 - LDREG 0(\ptep),\pte 490 - #endif 490 + .macro update_accessed ptp,pte,tmp,tmp1 491 491 ldi _PAGE_ACCESSED,\tmp1 492 492 or \tmp1,\pte,\tmp 493 493 and,COND(<>) \tmp1,\pte,%r0 494 - STREG \tmp,0(\ptep) 494 + STREG \tmp,0(\ptp) 495 495 .endm 496 496 497 497 /* Set the dirty bit (and accessed bit). No need to be 498 498 * clever, this is only used from the dirty fault */ 499 - .macro update_dirty spc,ptep,pte,tmp 500 - #ifdef CONFIG_SMP 501 - or,COND(=) %r0,\spc,%r0 502 - LDREG 0(\ptep),\pte 503 - #endif 499 + .macro update_dirty ptp,pte,tmp 504 500 ldi _PAGE_ACCESSED|_PAGE_DIRTY,\tmp 505 501 or \tmp,\pte,\pte 506 - STREG \pte,0(\ptep) 502 + STREG \pte,0(\ptp) 507 503 .endm 508 504 509 505 /* bitshift difference between a PFN (based on kernel's PAGE_SIZE) ··· 1144 1148 1145 1149 L3_ptep ptp,pte,t0,va,dtlb_check_alias_20w 1146 1150 1147 - dbit_lock spc,t0,t1 1148 - update_ptep spc,ptp,pte,t0,t1 1151 + tlb_lock spc,ptp,pte,t0,t1,dtlb_check_alias_20w 1152 + update_accessed ptp,pte,t0,t1 1149 1153 1150 1154 make_insert_tlb spc,pte,prot 1151 1155 1152 1156 idtlbt pte,prot 1153 - dbit_unlock1 spc,t0 1154 1157 1158 + tlb_unlock1 spc,t0 1155 1159 rfir 1156 1160 nop 1157 1161 ··· 1170 1174 1171 1175 L3_ptep ptp,pte,t0,va,nadtlb_check_alias_20w 1172 1176 1173 - dbit_lock spc,t0,t1 1174 - update_ptep spc,ptp,pte,t0,t1 1177 + tlb_lock spc,ptp,pte,t0,t1,nadtlb_check_alias_20w 1178 + update_accessed ptp,pte,t0,t1 1175 1179 1176 1180 make_insert_tlb spc,pte,prot 1177 1181 1178 1182 idtlbt pte,prot 1179 - dbit_unlock1 spc,t0 1180 1183 1184 + tlb_unlock1 spc,t0 1181 1185 rfir 1182 1186 nop 1183 1187 ··· 1198 1202 1199 1203 L2_ptep ptp,pte,t0,va,dtlb_check_alias_11 1200 1204 1201 - dbit_lock spc,t0,t1 1202 - update_ptep spc,ptp,pte,t0,t1 1205 + tlb_lock spc,ptp,pte,t0,t1,dtlb_check_alias_11 1206 + update_accessed ptp,pte,t0,t1 1203 1207 1204 1208 make_insert_tlb_11 spc,pte,prot 1205 1209 1206 - mfsp %sr1,t0 /* Save sr1 so we can use it in tlb inserts */ 1210 + mfsp %sr1,t1 /* Save sr1 so we can use it in tlb inserts */ 1207 1211 mtsp spc,%sr1 1208 1212 1209 1213 idtlba pte,(%sr1,va) 1210 1214 idtlbp prot,(%sr1,va) 1211 1215 1212 - mtsp t0, %sr1 /* Restore sr1 */ 1213 - dbit_unlock1 spc,t0 1216 + mtsp t1, %sr1 /* Restore sr1 */ 1214 1217 1218 + tlb_unlock1 spc,t0 1215 1219 rfir 1216 1220 nop 1217 1221 ··· 1231 1235 1232 1236 L2_ptep ptp,pte,t0,va,nadtlb_check_alias_11 1233 1237 1234 - dbit_lock spc,t0,t1 1235 - update_ptep spc,ptp,pte,t0,t1 1238 + tlb_lock spc,ptp,pte,t0,t1,nadtlb_check_alias_11 1239 + update_accessed ptp,pte,t0,t1 1236 1240 1237 1241 make_insert_tlb_11 spc,pte,prot 1238 1242 1239 - 1240 - mfsp %sr1,t0 /* Save sr1 so we can use it in tlb inserts */ 1243 + mfsp %sr1,t1 /* Save sr1 so we can use it in tlb inserts */ 1241 1244 mtsp spc,%sr1 1242 1245 1243 1246 idtlba pte,(%sr1,va) 1244 1247 idtlbp prot,(%sr1,va) 1245 1248 1246 - mtsp t0, %sr1 /* Restore sr1 */ 1247 - dbit_unlock1 spc,t0 1249 + mtsp t1, %sr1 /* Restore sr1 */ 1248 1250 1251 + tlb_unlock1 spc,t0 1249 1252 rfir 1250 1253 nop 1251 1254 ··· 1264 1269 1265 1270 L2_ptep ptp,pte,t0,va,dtlb_check_alias_20 1266 1271 1267 - dbit_lock spc,t0,t1 1268 - update_ptep spc,ptp,pte,t0,t1 1272 + tlb_lock spc,ptp,pte,t0,t1,dtlb_check_alias_20 1273 + update_accessed ptp,pte,t0,t1 1269 1274 1270 1275 make_insert_tlb spc,pte,prot 1271 1276 1272 - f_extend pte,t0 1277 + f_extend pte,t1 1273 1278 1274 1279 idtlbt pte,prot 1275 - dbit_unlock1 spc,t0 1276 1280 1281 + tlb_unlock1 spc,t0 1277 1282 rfir 1278 1283 nop 1279 1284 ··· 1292 1297 1293 1298 L2_ptep ptp,pte,t0,va,nadtlb_check_alias_20 1294 1299 1295 - dbit_lock spc,t0,t1 1296 - update_ptep spc,ptp,pte,t0,t1 1300 + tlb_lock spc,ptp,pte,t0,t1,nadtlb_check_alias_20 1301 + update_accessed ptp,pte,t0,t1 1297 1302 1298 1303 make_insert_tlb spc,pte,prot 1299 1304 1300 - f_extend pte,t0 1305 + f_extend pte,t1 1301 1306 1302 - idtlbt pte,prot 1303 - dbit_unlock1 spc,t0 1307 + idtlbt pte,prot 1304 1308 1309 + tlb_unlock1 spc,t0 1305 1310 rfir 1306 1311 nop 1307 1312 ··· 1401 1406 1402 1407 L3_ptep ptp,pte,t0,va,itlb_fault 1403 1408 1404 - dbit_lock spc,t0,t1 1405 - update_ptep spc,ptp,pte,t0,t1 1409 + tlb_lock spc,ptp,pte,t0,t1,itlb_fault 1410 + update_accessed ptp,pte,t0,t1 1406 1411 1407 1412 make_insert_tlb spc,pte,prot 1408 1413 1409 1414 iitlbt pte,prot 1410 - dbit_unlock1 spc,t0 1411 1415 1416 + tlb_unlock1 spc,t0 1412 1417 rfir 1413 1418 nop 1414 1419 ··· 1425 1430 1426 1431 L3_ptep ptp,pte,t0,va,naitlb_check_alias_20w 1427 1432 1428 - dbit_lock spc,t0,t1 1429 - update_ptep spc,ptp,pte,t0,t1 1433 + tlb_lock spc,ptp,pte,t0,t1,naitlb_check_alias_20w 1434 + update_accessed ptp,pte,t0,t1 1430 1435 1431 1436 make_insert_tlb spc,pte,prot 1432 1437 1433 1438 iitlbt pte,prot 1434 - dbit_unlock1 spc,t0 1435 1439 1440 + tlb_unlock1 spc,t0 1436 1441 rfir 1437 1442 nop 1438 1443 ··· 1453 1458 1454 1459 L2_ptep ptp,pte,t0,va,itlb_fault 1455 1460 1456 - dbit_lock spc,t0,t1 1457 - update_ptep spc,ptp,pte,t0,t1 1461 + tlb_lock spc,ptp,pte,t0,t1,itlb_fault 1462 + update_accessed ptp,pte,t0,t1 1458 1463 1459 1464 make_insert_tlb_11 spc,pte,prot 1460 1465 1461 - mfsp %sr1,t0 /* Save sr1 so we can use it in tlb inserts */ 1466 + mfsp %sr1,t1 /* Save sr1 so we can use it in tlb inserts */ 1462 1467 mtsp spc,%sr1 1463 1468 1464 1469 iitlba pte,(%sr1,va) 1465 1470 iitlbp prot,(%sr1,va) 1466 1471 1467 - mtsp t0, %sr1 /* Restore sr1 */ 1468 - dbit_unlock1 spc,t0 1472 + mtsp t1, %sr1 /* Restore sr1 */ 1469 1473 1474 + tlb_unlock1 spc,t0 1470 1475 rfir 1471 1476 nop 1472 1477 ··· 1477 1482 1478 1483 L2_ptep ptp,pte,t0,va,naitlb_check_alias_11 1479 1484 1480 - dbit_lock spc,t0,t1 1481 - update_ptep spc,ptp,pte,t0,t1 1485 + tlb_lock spc,ptp,pte,t0,t1,naitlb_check_alias_11 1486 + update_accessed ptp,pte,t0,t1 1482 1487 1483 1488 make_insert_tlb_11 spc,pte,prot 1484 1489 1485 - mfsp %sr1,t0 /* Save sr1 so we can use it in tlb inserts */ 1490 + mfsp %sr1,t1 /* Save sr1 so we can use it in tlb inserts */ 1486 1491 mtsp spc,%sr1 1487 1492 1488 1493 iitlba pte,(%sr1,va) 1489 1494 iitlbp prot,(%sr1,va) 1490 1495 1491 - mtsp t0, %sr1 /* Restore sr1 */ 1492 - dbit_unlock1 spc,t0 1496 + mtsp t1, %sr1 /* Restore sr1 */ 1493 1497 1498 + tlb_unlock1 spc,t0 1494 1499 rfir 1495 1500 nop 1496 1501 ··· 1511 1516 1512 1517 L2_ptep ptp,pte,t0,va,itlb_fault 1513 1518 1514 - dbit_lock spc,t0,t1 1515 - update_ptep spc,ptp,pte,t0,t1 1519 + tlb_lock spc,ptp,pte,t0,t1,itlb_fault 1520 + update_accessed ptp,pte,t0,t1 1516 1521 1517 1522 make_insert_tlb spc,pte,prot 1518 1523 1519 - f_extend pte,t0 1524 + f_extend pte,t1 1520 1525 1521 1526 iitlbt pte,prot 1522 - dbit_unlock1 spc,t0 1523 1527 1528 + tlb_unlock1 spc,t0 1524 1529 rfir 1525 1530 nop 1526 1531 ··· 1531 1536 1532 1537 L2_ptep ptp,pte,t0,va,naitlb_check_alias_20 1533 1538 1534 - dbit_lock spc,t0,t1 1535 - update_ptep spc,ptp,pte,t0,t1 1539 + tlb_lock spc,ptp,pte,t0,t1,naitlb_check_alias_20 1540 + update_accessed ptp,pte,t0,t1 1536 1541 1537 1542 make_insert_tlb spc,pte,prot 1538 1543 1539 - f_extend pte,t0 1544 + f_extend pte,t1 1540 1545 1541 1546 iitlbt pte,prot 1542 - dbit_unlock1 spc,t0 1543 1547 1548 + tlb_unlock1 spc,t0 1544 1549 rfir 1545 1550 nop 1546 1551 ··· 1563 1568 1564 1569 L3_ptep ptp,pte,t0,va,dbit_fault 1565 1570 1566 - dbit_lock spc,t0,t1 1567 - update_dirty spc,ptp,pte,t1 1571 + tlb_lock spc,ptp,pte,t0,t1,dbit_fault 1572 + update_dirty ptp,pte,t1 1568 1573 1569 1574 make_insert_tlb spc,pte,prot 1570 1575 1571 1576 idtlbt pte,prot 1572 - dbit_unlock0 spc,t0 1573 1577 1578 + tlb_unlock0 spc,t0 1574 1579 rfir 1575 1580 nop 1576 1581 #else ··· 1583 1588 1584 1589 L2_ptep ptp,pte,t0,va,dbit_fault 1585 1590 1586 - dbit_lock spc,t0,t1 1587 - update_dirty spc,ptp,pte,t1 1591 + tlb_lock spc,ptp,pte,t0,t1,dbit_fault 1592 + update_dirty ptp,pte,t1 1588 1593 1589 1594 make_insert_tlb_11 spc,pte,prot 1590 1595 ··· 1595 1600 idtlbp prot,(%sr1,va) 1596 1601 1597 1602 mtsp t1, %sr1 /* Restore sr1 */ 1598 - dbit_unlock0 spc,t0 1599 1603 1604 + tlb_unlock0 spc,t0 1600 1605 rfir 1601 1606 nop 1602 1607 ··· 1607 1612 1608 1613 L2_ptep ptp,pte,t0,va,dbit_fault 1609 1614 1610 - dbit_lock spc,t0,t1 1611 - update_dirty spc,ptp,pte,t1 1615 + tlb_lock spc,ptp,pte,t0,t1,dbit_fault 1616 + update_dirty ptp,pte,t1 1612 1617 1613 1618 make_insert_tlb spc,pte,prot 1614 1619 1615 1620 f_extend pte,t1 1616 1621 1617 - idtlbt pte,prot 1618 - dbit_unlock0 spc,t0 1622 + idtlbt pte,prot 1619 1623 1624 + tlb_unlock0 spc,t0 1620 1625 rfir 1621 1626 nop 1622 1627 #endif
-4
arch/parisc/kernel/traps.c
··· 43 43 44 44 #include "../math-emu/math-emu.h" /* for handle_fpe() */ 45 45 46 - #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 47 - DEFINE_SPINLOCK(pa_dbit_lock); 48 - #endif 49 - 50 46 static void parisc_show_stack(struct task_struct *task, unsigned long *sp, 51 47 struct pt_regs *regs); 52 48
+21 -10
arch/powerpc/kernel/idle_power7.S
··· 52 52 .text 53 53 54 54 /* 55 + * Used by threads when the lock bit of core_idle_state is set. 56 + * Threads will spin in HMT_LOW until the lock bit is cleared. 57 + * r14 - pointer to core_idle_state 58 + * r15 - used to load contents of core_idle_state 59 + */ 60 + 61 + core_idle_lock_held: 62 + HMT_LOW 63 + 3: lwz r15,0(r14) 64 + andi. r15,r15,PNV_CORE_IDLE_LOCK_BIT 65 + bne 3b 66 + HMT_MEDIUM 67 + lwarx r15,0,r14 68 + blr 69 + 70 + /* 55 71 * Pass requested state in r3: 56 72 * r3 - PNV_THREAD_NAP/SLEEP/WINKLE 57 73 * ··· 166 150 ld r14,PACA_CORE_IDLE_STATE_PTR(r13) 167 151 lwarx_loop1: 168 152 lwarx r15,0,r14 153 + 154 + andi. r9,r15,PNV_CORE_IDLE_LOCK_BIT 155 + bnel core_idle_lock_held 156 + 169 157 andc r15,r15,r7 /* Clear thread bit */ 170 158 171 159 andi. r15,r15,PNV_CORE_IDLE_THREAD_BITS ··· 314 294 * workaround undo code or resyncing timebase or restoring context 315 295 * In either case loop until the lock bit is cleared. 316 296 */ 317 - bne core_idle_lock_held 297 + bnel core_idle_lock_held 318 298 319 299 cmpwi cr2,r15,0 320 300 lbz r4,PACA_SUBCORE_SIBLING_MASK(r13) ··· 338 318 bne- lwarx_loop2 339 319 isync 340 320 b common_exit 341 - 342 - core_idle_lock_held: 343 - HMT_LOW 344 - core_idle_lock_loop: 345 - lwz r15,0(14) 346 - andi. r9,r15,PNV_CORE_IDLE_LOCK_BIT 347 - bne core_idle_lock_loop 348 - HMT_MEDIUM 349 - b lwarx_loop2 350 321 351 322 first_thread_in_subcore: 352 323 /* First thread in subcore to wakeup */
+2
arch/powerpc/kernel/traps.c
··· 297 297 298 298 __this_cpu_inc(irq_stat.mce_exceptions); 299 299 300 + add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE); 301 + 300 302 if (cur_cpu_spec && cur_cpu_spec->machine_check_early) 301 303 handled = cur_cpu_spec->machine_check_early(regs); 302 304 return handled;
+4
arch/powerpc/mm/fault.c
··· 529 529 printk(KERN_ALERT "Unable to handle kernel paging request for " 530 530 "instruction fetch\n"); 531 531 break; 532 + case 0x600: 533 + printk(KERN_ALERT "Unable to handle kernel paging request for " 534 + "unaligned access at address 0x%08lx\n", regs->dar); 535 + break; 532 536 default: 533 537 printk(KERN_ALERT "Unable to handle kernel paging request for " 534 538 "unknown fault\n");
+2
arch/powerpc/perf/hv-24x7.c
··· 320 320 if (!attr) 321 321 return NULL; 322 322 323 + sysfs_attr_init(&attr->attr.attr); 324 + 323 325 attr->var = str; 324 326 attr->attr.attr.name = name; 325 327 attr->attr.attr.mode = 0444;
+5 -11
arch/powerpc/platforms/powernv/opal-elog.c
··· 237 237 return elog; 238 238 } 239 239 240 - static void elog_work_fn(struct work_struct *work) 240 + static irqreturn_t elog_event(int irq, void *data) 241 241 { 242 242 __be64 size; 243 243 __be64 id; ··· 251 251 rc = opal_get_elog_size(&id, &size, &type); 252 252 if (rc != OPAL_SUCCESS) { 253 253 pr_err("ELOG: OPAL log info read failed\n"); 254 - return; 254 + return IRQ_HANDLED; 255 255 } 256 256 257 257 elog_size = be64_to_cpu(size); ··· 270 270 * entries. 271 271 */ 272 272 if (kset_find_obj(elog_kset, name)) 273 - return; 273 + return IRQ_HANDLED; 274 274 275 275 create_elog_obj(log_id, elog_size, elog_type); 276 - } 277 276 278 - static DECLARE_WORK(elog_work, elog_work_fn); 279 - 280 - static irqreturn_t elog_event(int irq, void *data) 281 - { 282 - schedule_work(&elog_work); 283 277 return IRQ_HANDLED; 284 278 } 285 279 ··· 298 304 return irq; 299 305 } 300 306 301 - rc = request_irq(irq, elog_event, 302 - IRQ_TYPE_LEVEL_HIGH, "opal-elog", NULL); 307 + rc = request_threaded_irq(irq, NULL, elog_event, 308 + IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "opal-elog", NULL); 303 309 if (rc) { 304 310 pr_err("%s: Can't request OPAL event irq (%d)\n", 305 311 __func__, rc);
+4 -5
arch/powerpc/platforms/powernv/opal-prd.c
··· 112 112 static int opal_prd_mmap(struct file *file, struct vm_area_struct *vma) 113 113 { 114 114 size_t addr, size; 115 + pgprot_t page_prot; 115 116 int rc; 116 117 117 118 pr_devel("opal_prd_mmap(0x%016lx, 0x%016lx, 0x%lx, 0x%lx)\n", ··· 126 125 if (!opal_prd_range_is_valid(addr, size)) 127 126 return -EINVAL; 128 127 129 - vma->vm_page_prot = __pgprot(pgprot_val(phys_mem_access_prot(file, 130 - vma->vm_pgoff, 131 - size, vma->vm_page_prot)) 132 - | _PAGE_SPECIAL); 128 + page_prot = phys_mem_access_prot(file, vma->vm_pgoff, 129 + size, vma->vm_page_prot); 133 130 134 131 rc = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, size, 135 - vma->vm_page_prot); 132 + page_prot); 136 133 137 134 return rc; 138 135 }
+1
arch/powerpc/sysdev/ppc4xx_hsta_msi.c
··· 18 18 #include <linux/pci.h> 19 19 #include <linux/semaphore.h> 20 20 #include <asm/msi_bitmap.h> 21 + #include <asm/ppc-pci.h> 21 22 22 23 struct ppc4xx_hsta_msi { 23 24 struct device *dev;
+2 -2
arch/tile/lib/memcpy_user_64.c
··· 28 28 #define _ST(p, inst, v) \ 29 29 ({ \ 30 30 asm("1: " #inst " %0, %1;" \ 31 - ".pushsection .coldtext.memcpy,\"ax\";" \ 31 + ".pushsection .coldtext,\"ax\";" \ 32 32 "2: { move r0, %2; jrp lr };" \ 33 33 ".section __ex_table,\"a\";" \ 34 34 ".align 8;" \ ··· 41 41 ({ \ 42 42 unsigned long __v; \ 43 43 asm("1: " #inst " %0, %1;" \ 44 - ".pushsection .coldtext.memcpy,\"ax\";" \ 44 + ".pushsection .coldtext,\"ax\";" \ 45 45 "2: { move r0, %2; jrp lr };" \ 46 46 ".section __ex_table,\"a\";" \ 47 47 ".align 8;" \
+6 -1
arch/x86/Kconfig
··· 254 254 config ARCH_SUPPORTS_DEBUG_PAGEALLOC 255 255 def_bool y 256 256 257 + config KASAN_SHADOW_OFFSET 258 + hex 259 + depends on KASAN 260 + default 0xdffffc0000000000 261 + 257 262 config HAVE_INTEL_TXT 258 263 def_bool y 259 264 depends on INTEL_IOMMU && ACPI ··· 2020 2015 2021 2016 To compile command line arguments into the kernel, 2022 2017 set this option to 'Y', then fill in the 2023 - the boot arguments in CONFIG_CMDLINE. 2018 + boot arguments in CONFIG_CMDLINE. 2024 2019 2025 2020 Systems with fully functional boot loaders (i.e. non-embedded) 2026 2021 should leave this option set to 'N'.
+1 -1
arch/x86/include/asm/espfix.h
··· 9 9 DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr); 10 10 11 11 extern void init_espfix_bsp(void); 12 - extern void init_espfix_ap(void); 12 + extern void init_espfix_ap(int cpu); 13 13 14 14 #endif /* CONFIG_X86_64 */ 15 15
+2 -6
arch/x86/include/asm/kasan.h
··· 14 14 15 15 #ifndef __ASSEMBLY__ 16 16 17 - extern pte_t kasan_zero_pte[]; 18 - extern pte_t kasan_zero_pmd[]; 19 - extern pte_t kasan_zero_pud[]; 20 - 21 17 #ifdef CONFIG_KASAN 22 - void __init kasan_map_early_shadow(pgd_t *pgd); 18 + void __init kasan_early_init(void); 23 19 void __init kasan_init(void); 24 20 #else 25 - static inline void kasan_map_early_shadow(pgd_t *pgd) { } 21 + static inline void kasan_early_init(void) { } 26 22 static inline void kasan_init(void) { } 27 23 #endif 28 24
+2 -8
arch/x86/kernel/apic/vector.c
··· 409 409 int irq, vector; 410 410 struct apic_chip_data *data; 411 411 412 - /* 413 - * vector_lock will make sure that we don't run into irq vector 414 - * assignments that might be happening on another cpu in parallel, 415 - * while we setup our initial vector to irq mappings. 416 - */ 417 - raw_spin_lock(&vector_lock); 418 412 /* Mark the inuse vectors */ 419 413 for_each_active_irq(irq) { 420 414 data = apic_chip_data(irq_get_irq_data(irq)); ··· 430 436 if (!cpumask_test_cpu(cpu, data->domain)) 431 437 per_cpu(vector_irq, cpu)[vector] = VECTOR_UNDEFINED; 432 438 } 433 - raw_spin_unlock(&vector_lock); 434 439 } 435 440 436 441 /* 437 - * Setup the vector to irq mappings. 442 + * Setup the vector to irq mappings. Must be called with vector_lock held. 438 443 */ 439 444 void setup_vector_irq(int cpu) 440 445 { 441 446 int irq; 442 447 448 + lockdep_assert_held(&vector_lock); 443 449 /* 444 450 * On most of the platforms, legacy PIC delivers the interrupts on the 445 451 * boot cpu. But there are certain platforms where PIC interrupts are
+3 -1
arch/x86/kernel/early_printk.c
··· 175 175 } 176 176 177 177 if (*s) { 178 - if (kstrtoul(s, 0, &baud) < 0 || baud == 0) 178 + baud = simple_strtoull(s, &e, 0); 179 + 180 + if (baud == 0 || s == e) 179 181 baud = DEFAULT_BAUD; 180 182 } 181 183
+16 -12
arch/x86/kernel/espfix_64.c
··· 131 131 init_espfix_random(); 132 132 133 133 /* The rest is the same as for any other processor */ 134 - init_espfix_ap(); 134 + init_espfix_ap(0); 135 135 } 136 136 137 - void init_espfix_ap(void) 137 + void init_espfix_ap(int cpu) 138 138 { 139 - unsigned int cpu, page; 139 + unsigned int page; 140 140 unsigned long addr; 141 141 pud_t pud, *pud_p; 142 142 pmd_t pmd, *pmd_p; 143 143 pte_t pte, *pte_p; 144 - int n; 144 + int n, node; 145 145 void *stack_page; 146 146 pteval_t ptemask; 147 147 148 148 /* We only have to do this once... */ 149 - if (likely(this_cpu_read(espfix_stack))) 149 + if (likely(per_cpu(espfix_stack, cpu))) 150 150 return; /* Already initialized */ 151 151 152 - cpu = smp_processor_id(); 153 152 addr = espfix_base_addr(cpu); 154 153 page = cpu/ESPFIX_STACKS_PER_PAGE; 155 154 ··· 164 165 if (stack_page) 165 166 goto unlock_done; 166 167 168 + node = cpu_to_node(cpu); 167 169 ptemask = __supported_pte_mask; 168 170 169 171 pud_p = &espfix_pud_page[pud_index(addr)]; 170 172 pud = *pud_p; 171 173 if (!pud_present(pud)) { 172 - pmd_p = (pmd_t *)__get_free_page(PGALLOC_GFP); 174 + struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0); 175 + 176 + pmd_p = (pmd_t *)page_address(page); 173 177 pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask)); 174 178 paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT); 175 179 for (n = 0; n < ESPFIX_PUD_CLONES; n++) ··· 182 180 pmd_p = pmd_offset(&pud, addr); 183 181 pmd = *pmd_p; 184 182 if (!pmd_present(pmd)) { 185 - pte_p = (pte_t *)__get_free_page(PGALLOC_GFP); 183 + struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0); 184 + 185 + pte_p = (pte_t *)page_address(page); 186 186 pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask)); 187 187 paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT); 188 188 for (n = 0; n < ESPFIX_PMD_CLONES; n++) ··· 192 188 } 193 189 194 190 pte_p = pte_offset_kernel(&pmd, addr); 195 - stack_page = (void *)__get_free_page(GFP_KERNEL); 191 + stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0)); 196 192 pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask)); 197 193 for (n = 0; n < ESPFIX_PTE_CLONES; n++) 198 194 set_pte(&pte_p[n*PTE_STRIDE], pte); ··· 203 199 unlock_done: 204 200 mutex_unlock(&espfix_init_mutex); 205 201 done: 206 - this_cpu_write(espfix_stack, addr); 207 - this_cpu_write(espfix_waddr, (unsigned long)stack_page 208 - + (addr & ~PAGE_MASK)); 202 + per_cpu(espfix_stack, cpu) = addr; 203 + per_cpu(espfix_waddr, cpu) = (unsigned long)stack_page 204 + + (addr & ~PAGE_MASK); 209 205 }
+4 -6
arch/x86/kernel/head64.c
··· 161 161 /* Kill off the identity-map trampoline */ 162 162 reset_early_page_tables(); 163 163 164 - kasan_map_early_shadow(early_level4_pgt); 165 - 166 - /* clear bss before set_intr_gate with early_idt_handler */ 167 164 clear_bss(); 165 + 166 + clear_page(init_level4_pgt); 167 + 168 + kasan_early_init(); 168 169 169 170 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) 170 171 set_intr_gate(i, early_idt_handler_array[i]); ··· 178 177 */ 179 178 load_ucode_bsp(); 180 179 181 - clear_page(init_level4_pgt); 182 180 /* set init_level4_pgt kernel high mapping*/ 183 181 init_level4_pgt[511] = early_level4_pgt[511]; 184 - 185 - kasan_map_early_shadow(init_level4_pgt); 186 182 187 183 x86_64_start_reservations(real_mode_data); 188 184 }
-29
arch/x86/kernel/head_64.S
··· 516 516 /* This must match the first entry in level2_kernel_pgt */ 517 517 .quad 0x0000000000000000 518 518 519 - #ifdef CONFIG_KASAN 520 - #define FILL(VAL, COUNT) \ 521 - .rept (COUNT) ; \ 522 - .quad (VAL) ; \ 523 - .endr 524 - 525 - NEXT_PAGE(kasan_zero_pte) 526 - FILL(kasan_zero_page - __START_KERNEL_map + _KERNPG_TABLE, 512) 527 - NEXT_PAGE(kasan_zero_pmd) 528 - FILL(kasan_zero_pte - __START_KERNEL_map + _KERNPG_TABLE, 512) 529 - NEXT_PAGE(kasan_zero_pud) 530 - FILL(kasan_zero_pmd - __START_KERNEL_map + _KERNPG_TABLE, 512) 531 - 532 - #undef FILL 533 - #endif 534 - 535 - 536 519 #include "../../x86/xen/xen-head.S" 537 520 538 521 __PAGE_ALIGNED_BSS 539 522 NEXT_PAGE(empty_zero_page) 540 523 .skip PAGE_SIZE 541 524 542 - #ifdef CONFIG_KASAN 543 - /* 544 - * This page used as early shadow. We don't use empty_zero_page 545 - * at early stages, stack instrumentation could write some garbage 546 - * to this page. 547 - * Latter we reuse it as zero shadow for large ranges of memory 548 - * that allowed to access, but not instrumented by kasan 549 - * (vmalloc/vmemmap ...). 550 - */ 551 - NEXT_PAGE(kasan_zero_page) 552 - .skip PAGE_SIZE 553 - #endif
+18 -2
arch/x86/kernel/irq.c
··· 347 347 if (!desc) 348 348 continue; 349 349 350 + /* 351 + * Protect against concurrent action removal, 352 + * affinity changes etc. 353 + */ 354 + raw_spin_lock(&desc->lock); 350 355 data = irq_desc_get_irq_data(desc); 351 356 cpumask_copy(&affinity_new, data->affinity); 352 357 cpumask_clear_cpu(this_cpu, &affinity_new); 353 358 354 359 /* Do not count inactive or per-cpu irqs. */ 355 - if (!irq_has_action(irq) || irqd_is_per_cpu(data)) 360 + if (!irq_has_action(irq) || irqd_is_per_cpu(data)) { 361 + raw_spin_unlock(&desc->lock); 356 362 continue; 363 + } 357 364 365 + raw_spin_unlock(&desc->lock); 358 366 /* 359 367 * A single irq may be mapped to multiple 360 368 * cpu's vector_irq[] (for example IOAPIC cluster ··· 393 385 * vector. If the vector is marked in the used vectors 394 386 * bitmap or an irq is assigned to it, we don't count 395 387 * it as available. 388 + * 389 + * As this is an inaccurate snapshot anyway, we can do 390 + * this w/o holding vector_lock. 396 391 */ 397 392 for (vector = FIRST_EXTERNAL_VECTOR; 398 393 vector < first_system_vector; vector++) { ··· 497 486 */ 498 487 mdelay(1); 499 488 489 + /* 490 + * We can walk the vector array of this cpu without holding 491 + * vector_lock because the cpu is already marked !online, so 492 + * nothing else will touch it. 493 + */ 500 494 for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) { 501 495 unsigned int irr; 502 496 ··· 513 497 irq = __this_cpu_read(vector_irq[vector]); 514 498 515 499 desc = irq_to_desc(irq); 500 + raw_spin_lock(&desc->lock); 516 501 data = irq_desc_get_irq_data(desc); 517 502 chip = irq_data_get_irq_chip(data); 518 - raw_spin_lock(&desc->lock); 519 503 if (chip->irq_retrigger) { 520 504 chip->irq_retrigger(data); 521 505 __this_cpu_write(vector_irq[vector], VECTOR_RETRIGGERED);
+12 -15
arch/x86/kernel/smpboot.c
··· 171 171 apic_ap_setup(); 172 172 173 173 /* 174 - * Need to setup vector mappings before we enable interrupts. 175 - */ 176 - setup_vector_irq(smp_processor_id()); 177 - 178 - /* 179 174 * Save our processor parameters. Note: this information 180 175 * is needed for clock calibration. 181 176 */ ··· 234 239 check_tsc_sync_target(); 235 240 236 241 /* 237 - * Enable the espfix hack for this CPU 238 - */ 239 - #ifdef CONFIG_X86_ESPFIX64 240 - init_espfix_ap(); 241 - #endif 242 - 243 - /* 244 - * We need to hold vector_lock so there the set of online cpus 245 - * does not change while we are assigning vectors to cpus. Holding 246 - * this lock ensures we don't half assign or remove an irq from a cpu. 242 + * Lock vector_lock and initialize the vectors on this cpu 243 + * before setting the cpu online. We must set it online with 244 + * vector_lock held to prevent a concurrent setup/teardown 245 + * from seeing a half valid vector space. 247 246 */ 248 247 lock_vector_lock(); 248 + setup_vector_irq(smp_processor_id()); 249 249 set_cpu_online(smp_processor_id(), true); 250 250 unlock_vector_lock(); 251 251 cpu_set_state_online(smp_processor_id()); ··· 843 853 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); 844 854 initial_code = (unsigned long)start_secondary; 845 855 stack_start = idle->thread.sp; 856 + 857 + /* 858 + * Enable the espfix hack for this CPU 859 + */ 860 + #ifdef CONFIG_X86_ESPFIX64 861 + init_espfix_ap(cpu); 862 + #endif 846 863 847 864 /* So we see what's up */ 848 865 announce_cpu(cpu, apicid);
+10 -1
arch/x86/kernel/tsc.c
··· 598 598 if (!pit_expect_msb(0xff-i, &delta, &d2)) 599 599 break; 600 600 601 + delta -= tsc; 602 + 603 + /* 604 + * Extrapolate the error and fail fast if the error will 605 + * never be below 500 ppm. 606 + */ 607 + if (i == 1 && 608 + d1 + d2 >= (delta * MAX_QUICK_PIT_ITERATIONS) >> 11) 609 + return 0; 610 + 601 611 /* 602 612 * Iterate until the error is less than 500 ppm 603 613 */ 604 - delta -= tsc; 605 614 if (d1+d2 >= delta >> 11) 606 615 continue; 607 616
+1 -1
arch/x86/lib/usercopy.c
··· 20 20 unsigned long ret; 21 21 22 22 if (__range_not_ok(from, n, TASK_SIZE)) 23 - return 0; 23 + return n; 24 24 25 25 /* 26 26 * Even though this function is typically called from NMI/IRQ context
+42 -5
arch/x86/mm/kasan_init_64.c
··· 1 + #define pr_fmt(fmt) "kasan: " fmt 1 2 #include <linux/bootmem.h> 2 3 #include <linux/kasan.h> 3 4 #include <linux/kdebug.h> ··· 12 11 extern pgd_t early_level4_pgt[PTRS_PER_PGD]; 13 12 extern struct range pfn_mapped[E820_X_MAX]; 14 13 15 - extern unsigned char kasan_zero_page[PAGE_SIZE]; 14 + static pud_t kasan_zero_pud[PTRS_PER_PUD] __page_aligned_bss; 15 + static pmd_t kasan_zero_pmd[PTRS_PER_PMD] __page_aligned_bss; 16 + static pte_t kasan_zero_pte[PTRS_PER_PTE] __page_aligned_bss; 17 + 18 + /* 19 + * This page used as early shadow. We don't use empty_zero_page 20 + * at early stages, stack instrumentation could write some garbage 21 + * to this page. 22 + * Latter we reuse it as zero shadow for large ranges of memory 23 + * that allowed to access, but not instrumented by kasan 24 + * (vmalloc/vmemmap ...). 25 + */ 26 + static unsigned char kasan_zero_page[PAGE_SIZE] __page_aligned_bss; 16 27 17 28 static int __init map_range(struct range *range) 18 29 { ··· 49 36 pgd_clear(pgd_offset_k(start)); 50 37 } 51 38 52 - void __init kasan_map_early_shadow(pgd_t *pgd) 39 + static void __init kasan_map_early_shadow(pgd_t *pgd) 53 40 { 54 41 int i; 55 42 unsigned long start = KASAN_SHADOW_START; ··· 86 73 while (IS_ALIGNED(addr, PMD_SIZE) && addr + PMD_SIZE <= end) { 87 74 WARN_ON(!pmd_none(*pmd)); 88 75 set_pmd(pmd, __pmd(__pa_nodebug(kasan_zero_pte) 89 - | __PAGE_KERNEL_RO)); 76 + | _KERNPG_TABLE)); 90 77 addr += PMD_SIZE; 91 78 pmd = pmd_offset(pud, addr); 92 79 } ··· 112 99 while (IS_ALIGNED(addr, PUD_SIZE) && addr + PUD_SIZE <= end) { 113 100 WARN_ON(!pud_none(*pud)); 114 101 set_pud(pud, __pud(__pa_nodebug(kasan_zero_pmd) 115 - | __PAGE_KERNEL_RO)); 102 + | _KERNPG_TABLE)); 116 103 addr += PUD_SIZE; 117 104 pud = pud_offset(pgd, addr); 118 105 } ··· 137 124 while (IS_ALIGNED(addr, PGDIR_SIZE) && addr + PGDIR_SIZE <= end) { 138 125 WARN_ON(!pgd_none(*pgd)); 139 126 set_pgd(pgd, __pgd(__pa_nodebug(kasan_zero_pud) 140 - | __PAGE_KERNEL_RO)); 127 + | _KERNPG_TABLE)); 141 128 addr += PGDIR_SIZE; 142 129 pgd = pgd_offset_k(addr); 143 130 } ··· 179 166 }; 180 167 #endif 181 168 169 + void __init kasan_early_init(void) 170 + { 171 + int i; 172 + pteval_t pte_val = __pa_nodebug(kasan_zero_page) | __PAGE_KERNEL; 173 + pmdval_t pmd_val = __pa_nodebug(kasan_zero_pte) | _KERNPG_TABLE; 174 + pudval_t pud_val = __pa_nodebug(kasan_zero_pmd) | _KERNPG_TABLE; 175 + 176 + for (i = 0; i < PTRS_PER_PTE; i++) 177 + kasan_zero_pte[i] = __pte(pte_val); 178 + 179 + for (i = 0; i < PTRS_PER_PMD; i++) 180 + kasan_zero_pmd[i] = __pmd(pmd_val); 181 + 182 + for (i = 0; i < PTRS_PER_PUD; i++) 183 + kasan_zero_pud[i] = __pud(pud_val); 184 + 185 + kasan_map_early_shadow(early_level4_pgt); 186 + kasan_map_early_shadow(init_level4_pgt); 187 + } 188 + 182 189 void __init kasan_init(void) 183 190 { 184 191 int i; ··· 209 176 210 177 memcpy(early_level4_pgt, init_level4_pgt, sizeof(early_level4_pgt)); 211 178 load_cr3(early_level4_pgt); 179 + __flush_tlb_all(); 212 180 213 181 clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); 214 182 ··· 236 202 memset(kasan_zero_page, 0, PAGE_SIZE); 237 203 238 204 load_cr3(init_level4_pgt); 205 + __flush_tlb_all(); 239 206 init_task.kasan_depth = 0; 207 + 208 + pr_info("Kernel address sanitizer initialized\n"); 240 209 }
+5 -2
drivers/acpi/acpi_lpss.c
··· 352 352 pdata->mmio_size = resource_size(rentry->res); 353 353 pdata->mmio_base = ioremap(rentry->res->start, 354 354 pdata->mmio_size); 355 - if (!pdata->mmio_base) 356 - goto err_out; 357 355 break; 358 356 } 359 357 360 358 acpi_dev_free_resource_list(&resource_list); 359 + 360 + if (!pdata->mmio_base) { 361 + ret = -ENOMEM; 362 + goto err_out; 363 + } 361 364 362 365 pdata->dev_desc = dev_desc; 363 366
+120 -14
drivers/acpi/nfit.c
··· 18 18 #include <linux/list.h> 19 19 #include <linux/acpi.h> 20 20 #include <linux/sort.h> 21 + #include <linux/pmem.h> 21 22 #include <linux/io.h> 22 23 #include "nfit.h" 23 24 ··· 306 305 return true; 307 306 } 308 307 308 + static bool add_flush(struct acpi_nfit_desc *acpi_desc, 309 + struct acpi_nfit_flush_address *flush) 310 + { 311 + struct device *dev = acpi_desc->dev; 312 + struct nfit_flush *nfit_flush = devm_kzalloc(dev, sizeof(*nfit_flush), 313 + GFP_KERNEL); 314 + 315 + if (!nfit_flush) 316 + return false; 317 + INIT_LIST_HEAD(&nfit_flush->list); 318 + nfit_flush->flush = flush; 319 + list_add_tail(&nfit_flush->list, &acpi_desc->flushes); 320 + dev_dbg(dev, "%s: nfit_flush handle: %d hint_count: %d\n", __func__, 321 + flush->device_handle, flush->hint_count); 322 + return true; 323 + } 324 + 309 325 static void *add_table(struct acpi_nfit_desc *acpi_desc, void *table, 310 326 const void *end) 311 327 { ··· 356 338 return err; 357 339 break; 358 340 case ACPI_NFIT_TYPE_FLUSH_ADDRESS: 359 - dev_dbg(dev, "%s: flush\n", __func__); 341 + if (!add_flush(acpi_desc, table)) 342 + return err; 360 343 break; 361 344 case ACPI_NFIT_TYPE_SMBIOS: 362 345 dev_dbg(dev, "%s: smbios\n", __func__); ··· 408 389 { 409 390 u16 dcr = __to_nfit_memdev(nfit_mem)->region_index; 410 391 struct nfit_memdev *nfit_memdev; 392 + struct nfit_flush *nfit_flush; 411 393 struct nfit_dcr *nfit_dcr; 412 394 struct nfit_bdw *nfit_bdw; 413 395 struct nfit_idt *nfit_idt; ··· 460 440 if (nfit_idt->idt->interleave_index != idt_idx) 461 441 continue; 462 442 nfit_mem->idt_bdw = nfit_idt->idt; 443 + break; 444 + } 445 + 446 + list_for_each_entry(nfit_flush, &acpi_desc->flushes, list) { 447 + if (nfit_flush->flush->device_handle != 448 + nfit_memdev->memdev->device_handle) 449 + continue; 450 + nfit_mem->nfit_flush = nfit_flush; 463 451 break; 464 452 } 465 453 break; ··· 1006 978 return mmio->base_offset + line_offset + table_offset + sub_line_offset; 1007 979 } 1008 980 981 + static void wmb_blk(struct nfit_blk *nfit_blk) 982 + { 983 + 984 + if (nfit_blk->nvdimm_flush) { 985 + /* 986 + * The first wmb() is needed to 'sfence' all previous writes 987 + * such that they are architecturally visible for the platform 988 + * buffer flush. Note that we've already arranged for pmem 989 + * writes to avoid the cache via arch_memcpy_to_pmem(). The 990 + * final wmb() ensures ordering for the NVDIMM flush write. 991 + */ 992 + wmb(); 993 + writeq(1, nfit_blk->nvdimm_flush); 994 + wmb(); 995 + } else 996 + wmb_pmem(); 997 + } 998 + 1009 999 static u64 read_blk_stat(struct nfit_blk *nfit_blk, unsigned int bw) 1010 1000 { 1011 1001 struct nfit_blk_mmio *mmio = &nfit_blk->mmio[DCR]; ··· 1058 1012 offset = to_interleave_offset(offset, mmio); 1059 1013 1060 1014 writeq(cmd, mmio->base + offset); 1061 - /* FIXME: conditionally perform read-back if mandated by firmware */ 1015 + wmb_blk(nfit_blk); 1016 + 1017 + if (nfit_blk->dimm_flags & ND_BLK_DCR_LATCH) 1018 + readq(mmio->base + offset); 1062 1019 } 1063 1020 1064 1021 static int acpi_nfit_blk_single_io(struct nfit_blk *nfit_blk, ··· 1075 1026 1076 1027 base_offset = nfit_blk->bdw_offset + dpa % L1_CACHE_BYTES 1077 1028 + lane * mmio->size; 1078 - /* TODO: non-temporal access, flush hints, cache management etc... */ 1079 1029 write_blk_ctl(nfit_blk, lane, dpa, len, rw); 1080 1030 while (len) { 1081 1031 unsigned int c; ··· 1093 1045 } 1094 1046 1095 1047 if (rw) 1096 - memcpy(mmio->aperture + offset, iobuf + copied, c); 1048 + memcpy_to_pmem(mmio->aperture + offset, 1049 + iobuf + copied, c); 1097 1050 else 1098 - memcpy(iobuf + copied, mmio->aperture + offset, c); 1051 + memcpy_from_pmem(iobuf + copied, 1052 + mmio->aperture + offset, c); 1099 1053 1100 1054 copied += c; 1101 1055 len -= c; 1102 1056 } 1057 + 1058 + if (rw) 1059 + wmb_blk(nfit_blk); 1060 + 1103 1061 rc = read_blk_stat(nfit_blk, lane) ? -EIO : 0; 1104 1062 return rc; 1105 1063 } ··· 1178 1124 } 1179 1125 1180 1126 static void __iomem *__nfit_spa_map(struct acpi_nfit_desc *acpi_desc, 1181 - struct acpi_nfit_system_address *spa) 1127 + struct acpi_nfit_system_address *spa, enum spa_map_type type) 1182 1128 { 1183 1129 resource_size_t start = spa->address; 1184 1130 resource_size_t n = spa->length; ··· 1206 1152 if (!res) 1207 1153 goto err_mem; 1208 1154 1209 - /* TODO: cacheability based on the spa type */ 1210 - spa_map->iomem = ioremap_nocache(start, n); 1155 + if (type == SPA_MAP_APERTURE) { 1156 + /* 1157 + * TODO: memremap_pmem() support, but that requires cache 1158 + * flushing when the aperture is moved. 1159 + */ 1160 + spa_map->iomem = ioremap_wc(start, n); 1161 + } else 1162 + spa_map->iomem = ioremap_nocache(start, n); 1163 + 1211 1164 if (!spa_map->iomem) 1212 1165 goto err_map; 1213 1166 ··· 1232 1171 * nfit_spa_map - interleave-aware managed-mappings of acpi_nfit_system_address ranges 1233 1172 * @nvdimm_bus: NFIT-bus that provided the spa table entry 1234 1173 * @nfit_spa: spa table to map 1174 + * @type: aperture or control region 1235 1175 * 1236 1176 * In the case where block-data-window apertures and 1237 1177 * dimm-control-regions are interleaved they will end up sharing a ··· 1242 1180 * unbound. 1243 1181 */ 1244 1182 static void __iomem *nfit_spa_map(struct acpi_nfit_desc *acpi_desc, 1245 - struct acpi_nfit_system_address *spa) 1183 + struct acpi_nfit_system_address *spa, enum spa_map_type type) 1246 1184 { 1247 1185 void __iomem *iomem; 1248 1186 1249 1187 mutex_lock(&acpi_desc->spa_map_mutex); 1250 - iomem = __nfit_spa_map(acpi_desc, spa); 1188 + iomem = __nfit_spa_map(acpi_desc, spa, type); 1251 1189 mutex_unlock(&acpi_desc->spa_map_mutex); 1252 1190 1253 1191 return iomem; ··· 1268 1206 return 0; 1269 1207 } 1270 1208 1209 + static int acpi_nfit_blk_get_flags(struct nvdimm_bus_descriptor *nd_desc, 1210 + struct nvdimm *nvdimm, struct nfit_blk *nfit_blk) 1211 + { 1212 + struct nd_cmd_dimm_flags flags; 1213 + int rc; 1214 + 1215 + memset(&flags, 0, sizeof(flags)); 1216 + rc = nd_desc->ndctl(nd_desc, nvdimm, ND_CMD_DIMM_FLAGS, &flags, 1217 + sizeof(flags)); 1218 + 1219 + if (rc >= 0 && flags.status == 0) 1220 + nfit_blk->dimm_flags = flags.flags; 1221 + else if (rc == -ENOTTY) { 1222 + /* fall back to a conservative default */ 1223 + nfit_blk->dimm_flags = ND_BLK_DCR_LATCH; 1224 + rc = 0; 1225 + } else 1226 + rc = -ENXIO; 1227 + 1228 + return rc; 1229 + } 1230 + 1271 1231 static int acpi_nfit_blk_region_enable(struct nvdimm_bus *nvdimm_bus, 1272 1232 struct device *dev) 1273 1233 { 1274 1234 struct nvdimm_bus_descriptor *nd_desc = to_nd_desc(nvdimm_bus); 1275 1235 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); 1276 1236 struct nd_blk_region *ndbr = to_nd_blk_region(dev); 1237 + struct nfit_flush *nfit_flush; 1277 1238 struct nfit_blk_mmio *mmio; 1278 1239 struct nfit_blk *nfit_blk; 1279 1240 struct nfit_mem *nfit_mem; ··· 1308 1223 if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) { 1309 1224 dev_dbg(dev, "%s: missing%s%s%s\n", __func__, 1310 1225 nfit_mem ? "" : " nfit_mem", 1311 - nfit_mem->dcr ? "" : " dcr", 1312 - nfit_mem->bdw ? "" : " bdw"); 1226 + (nfit_mem && nfit_mem->dcr) ? "" : " dcr", 1227 + (nfit_mem && nfit_mem->bdw) ? "" : " bdw"); 1313 1228 return -ENXIO; 1314 1229 } 1315 1230 ··· 1322 1237 /* map block aperture memory */ 1323 1238 nfit_blk->bdw_offset = nfit_mem->bdw->offset; 1324 1239 mmio = &nfit_blk->mmio[BDW]; 1325 - mmio->base = nfit_spa_map(acpi_desc, nfit_mem->spa_bdw); 1240 + mmio->base = nfit_spa_map(acpi_desc, nfit_mem->spa_bdw, 1241 + SPA_MAP_APERTURE); 1326 1242 if (!mmio->base) { 1327 1243 dev_dbg(dev, "%s: %s failed to map bdw\n", __func__, 1328 1244 nvdimm_name(nvdimm)); ··· 1345 1259 nfit_blk->cmd_offset = nfit_mem->dcr->command_offset; 1346 1260 nfit_blk->stat_offset = nfit_mem->dcr->status_offset; 1347 1261 mmio = &nfit_blk->mmio[DCR]; 1348 - mmio->base = nfit_spa_map(acpi_desc, nfit_mem->spa_dcr); 1262 + mmio->base = nfit_spa_map(acpi_desc, nfit_mem->spa_dcr, 1263 + SPA_MAP_CONTROL); 1349 1264 if (!mmio->base) { 1350 1265 dev_dbg(dev, "%s: %s failed to map dcr\n", __func__, 1351 1266 nvdimm_name(nvdimm)); ··· 1363 1276 __func__, nvdimm_name(nvdimm)); 1364 1277 return rc; 1365 1278 } 1279 + 1280 + rc = acpi_nfit_blk_get_flags(nd_desc, nvdimm, nfit_blk); 1281 + if (rc < 0) { 1282 + dev_dbg(dev, "%s: %s failed get DIMM flags\n", 1283 + __func__, nvdimm_name(nvdimm)); 1284 + return rc; 1285 + } 1286 + 1287 + nfit_flush = nfit_mem->nfit_flush; 1288 + if (nfit_flush && nfit_flush->flush->hint_count != 0) { 1289 + nfit_blk->nvdimm_flush = devm_ioremap_nocache(dev, 1290 + nfit_flush->flush->hint_address[0], 8); 1291 + if (!nfit_blk->nvdimm_flush) 1292 + return -ENOMEM; 1293 + } 1294 + 1295 + if (!arch_has_pmem_api() && !nfit_blk->nvdimm_flush) 1296 + dev_warn(dev, "unable to guarantee persistence of writes\n"); 1366 1297 1367 1298 if (mmio->line_size == 0) 1368 1299 return 0; ··· 1564 1459 INIT_LIST_HEAD(&acpi_desc->dcrs); 1565 1460 INIT_LIST_HEAD(&acpi_desc->bdws); 1566 1461 INIT_LIST_HEAD(&acpi_desc->idts); 1462 + INIT_LIST_HEAD(&acpi_desc->flushes); 1567 1463 INIT_LIST_HEAD(&acpi_desc->memdevs); 1568 1464 INIT_LIST_HEAD(&acpi_desc->dimms); 1569 1465 mutex_init(&acpi_desc->spa_map_mutex);
+19 -1
drivers/acpi/nfit.h
··· 40 40 NFIT_UUID_MAX, 41 41 }; 42 42 43 + enum { 44 + ND_BLK_DCR_LATCH = 2, 45 + }; 46 + 43 47 struct nfit_spa { 44 48 struct acpi_nfit_system_address *spa; 45 49 struct list_head list; ··· 64 60 struct list_head list; 65 61 }; 66 62 63 + struct nfit_flush { 64 + struct acpi_nfit_flush_address *flush; 65 + struct list_head list; 66 + }; 67 + 67 68 struct nfit_memdev { 68 69 struct acpi_nfit_memory_map *memdev; 69 70 struct list_head list; ··· 86 77 struct acpi_nfit_system_address *spa_bdw; 87 78 struct acpi_nfit_interleave *idt_dcr; 88 79 struct acpi_nfit_interleave *idt_bdw; 80 + struct nfit_flush *nfit_flush; 89 81 struct list_head list; 90 82 struct acpi_device *adev; 91 83 unsigned long dsm_mask; ··· 98 88 struct mutex spa_map_mutex; 99 89 struct list_head spa_maps; 100 90 struct list_head memdevs; 91 + struct list_head flushes; 101 92 struct list_head dimms; 102 93 struct list_head spas; 103 94 struct list_head dcrs; ··· 120 109 struct nfit_blk_mmio { 121 110 union { 122 111 void __iomem *base; 123 - void *aperture; 112 + void __pmem *aperture; 124 113 }; 125 114 u64 size; 126 115 u64 base_offset; ··· 134 123 u64 bdw_offset; /* post interleave offset */ 135 124 u64 stat_offset; 136 125 u64 cmd_offset; 126 + void __iomem *nvdimm_flush; 127 + u32 dimm_flags; 128 + }; 129 + 130 + enum spa_map_type { 131 + SPA_MAP_CONTROL, 132 + SPA_MAP_APERTURE, 137 133 }; 138 134 139 135 struct nfit_spa_mapping {
+9 -3
drivers/acpi/osl.c
··· 175 175 if (!addr || !length) 176 176 return; 177 177 178 - acpi_reserve_region(addr, length, gas->space_id, 0, desc); 178 + /* Resources are never freed */ 179 + if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) 180 + request_region(addr, length, desc); 181 + else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) 182 + request_mem_region(addr, length, desc); 179 183 } 180 184 181 - static void __init acpi_reserve_resources(void) 185 + static int __init acpi_reserve_resources(void) 182 186 { 183 187 acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length, 184 188 "ACPI PM1a_EVT_BLK"); ··· 211 207 if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) 212 208 acpi_request_region(&acpi_gbl_FADT.xgpe1_block, 213 209 acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); 210 + 211 + return 0; 214 212 } 213 + fs_initcall_sync(acpi_reserve_resources); 215 214 216 215 void acpi_os_printf(const char *fmt, ...) 217 216 { ··· 1869 1862 1870 1863 acpi_status __init acpi_os_initialize1(void) 1871 1864 { 1872 - acpi_reserve_resources(); 1873 1865 kacpid_wq = alloc_workqueue("kacpid", 0, 1); 1874 1866 kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); 1875 1867 kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0);
-162
drivers/acpi/resource.c
··· 26 26 #include <linux/device.h> 27 27 #include <linux/export.h> 28 28 #include <linux/ioport.h> 29 - #include <linux/list.h> 30 29 #include <linux/slab.h> 31 30 32 31 #ifdef CONFIG_X86 ··· 621 622 return (type & types) ? 0 : 1; 622 623 } 623 624 EXPORT_SYMBOL_GPL(acpi_dev_filter_resource_type); 624 - 625 - struct reserved_region { 626 - struct list_head node; 627 - u64 start; 628 - u64 end; 629 - }; 630 - 631 - static LIST_HEAD(reserved_io_regions); 632 - static LIST_HEAD(reserved_mem_regions); 633 - 634 - static int request_range(u64 start, u64 end, u8 space_id, unsigned long flags, 635 - char *desc) 636 - { 637 - unsigned int length = end - start + 1; 638 - struct resource *res; 639 - 640 - res = space_id == ACPI_ADR_SPACE_SYSTEM_IO ? 641 - request_region(start, length, desc) : 642 - request_mem_region(start, length, desc); 643 - if (!res) 644 - return -EIO; 645 - 646 - res->flags &= ~flags; 647 - return 0; 648 - } 649 - 650 - static int add_region_before(u64 start, u64 end, u8 space_id, 651 - unsigned long flags, char *desc, 652 - struct list_head *head) 653 - { 654 - struct reserved_region *reg; 655 - int error; 656 - 657 - reg = kmalloc(sizeof(*reg), GFP_KERNEL); 658 - if (!reg) 659 - return -ENOMEM; 660 - 661 - error = request_range(start, end, space_id, flags, desc); 662 - if (error) { 663 - kfree(reg); 664 - return error; 665 - } 666 - 667 - reg->start = start; 668 - reg->end = end; 669 - list_add_tail(&reg->node, head); 670 - return 0; 671 - } 672 - 673 - /** 674 - * acpi_reserve_region - Reserve an I/O or memory region as a system resource. 675 - * @start: Starting address of the region. 676 - * @length: Length of the region. 677 - * @space_id: Identifier of address space to reserve the region from. 678 - * @flags: Resource flags to clear for the region after requesting it. 679 - * @desc: Region description (for messages). 680 - * 681 - * Reserve an I/O or memory region as a system resource to prevent others from 682 - * using it. If the new region overlaps with one of the regions (in the given 683 - * address space) already reserved by this routine, only the non-overlapping 684 - * parts of it will be reserved. 685 - * 686 - * Returned is either 0 (success) or a negative error code indicating a resource 687 - * reservation problem. It is the code of the first encountered error, but the 688 - * routine doesn't abort until it has attempted to request all of the parts of 689 - * the new region that don't overlap with other regions reserved previously. 690 - * 691 - * The resources requested by this routine are never released. 692 - */ 693 - int acpi_reserve_region(u64 start, unsigned int length, u8 space_id, 694 - unsigned long flags, char *desc) 695 - { 696 - struct list_head *regions; 697 - struct reserved_region *reg; 698 - u64 end = start + length - 1; 699 - int ret = 0, error = 0; 700 - 701 - if (space_id == ACPI_ADR_SPACE_SYSTEM_IO) 702 - regions = &reserved_io_regions; 703 - else if (space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) 704 - regions = &reserved_mem_regions; 705 - else 706 - return -EINVAL; 707 - 708 - if (list_empty(regions)) 709 - return add_region_before(start, end, space_id, flags, desc, regions); 710 - 711 - list_for_each_entry(reg, regions, node) 712 - if (reg->start == end + 1) { 713 - /* The new region can be prepended to this one. */ 714 - ret = request_range(start, end, space_id, flags, desc); 715 - if (!ret) 716 - reg->start = start; 717 - 718 - return ret; 719 - } else if (reg->start > end) { 720 - /* No overlap. Add the new region here and get out. */ 721 - return add_region_before(start, end, space_id, flags, 722 - desc, &reg->node); 723 - } else if (reg->end == start - 1) { 724 - goto combine; 725 - } else if (reg->end >= start) { 726 - goto overlap; 727 - } 728 - 729 - /* The new region goes after the last existing one. */ 730 - return add_region_before(start, end, space_id, flags, desc, regions); 731 - 732 - overlap: 733 - /* 734 - * The new region overlaps an existing one. 735 - * 736 - * The head part of the new region immediately preceding the existing 737 - * overlapping one can be combined with it right away. 738 - */ 739 - if (reg->start > start) { 740 - error = request_range(start, reg->start - 1, space_id, flags, desc); 741 - if (error) 742 - ret = error; 743 - else 744 - reg->start = start; 745 - } 746 - 747 - combine: 748 - /* 749 - * The new region is adjacent to an existing one. If it extends beyond 750 - * that region all the way to the next one, it is possible to combine 751 - * all three of them. 752 - */ 753 - while (reg->end < end) { 754 - struct reserved_region *next = NULL; 755 - u64 a = reg->end + 1, b = end; 756 - 757 - if (!list_is_last(&reg->node, regions)) { 758 - next = list_next_entry(reg, node); 759 - if (next->start <= end) 760 - b = next->start - 1; 761 - } 762 - error = request_range(a, b, space_id, flags, desc); 763 - if (!error) { 764 - if (next && next->start == b + 1) { 765 - reg->end = next->end; 766 - list_del(&next->node); 767 - kfree(next); 768 - } else { 769 - reg->end = end; 770 - break; 771 - } 772 - } else if (next) { 773 - if (!ret) 774 - ret = error; 775 - 776 - reg = next; 777 - } else { 778 - break; 779 - } 780 - } 781 - 782 - return ret ? ret : error; 783 - } 784 - EXPORT_SYMBOL_GPL(acpi_reserve_region);
+30 -2
drivers/acpi/scan.c
··· 1019 1019 return false; 1020 1020 } 1021 1021 1022 + static bool __acpi_match_device_cls(const struct acpi_device_id *id, 1023 + struct acpi_hardware_id *hwid) 1024 + { 1025 + int i, msk, byte_shift; 1026 + char buf[3]; 1027 + 1028 + if (!id->cls) 1029 + return false; 1030 + 1031 + /* Apply class-code bitmask, before checking each class-code byte */ 1032 + for (i = 1; i <= 3; i++) { 1033 + byte_shift = 8 * (3 - i); 1034 + msk = (id->cls_msk >> byte_shift) & 0xFF; 1035 + if (!msk) 1036 + continue; 1037 + 1038 + sprintf(buf, "%02x", (id->cls >> byte_shift) & msk); 1039 + if (strncmp(buf, &hwid->id[(i - 1) * 2], 2)) 1040 + return false; 1041 + } 1042 + return true; 1043 + } 1044 + 1022 1045 static const struct acpi_device_id *__acpi_match_device( 1023 1046 struct acpi_device *device, 1024 1047 const struct acpi_device_id *ids, ··· 1059 1036 1060 1037 list_for_each_entry(hwid, &device->pnp.ids, list) { 1061 1038 /* First, check the ACPI/PNP IDs provided by the caller. */ 1062 - for (id = ids; id->id[0]; id++) 1063 - if (!strcmp((char *) id->id, hwid->id)) 1039 + for (id = ids; id->id[0] || id->cls; id++) { 1040 + if (id->id[0] && !strcmp((char *) id->id, hwid->id)) 1064 1041 return id; 1042 + else if (id->cls && __acpi_match_device_cls(id, hwid)) 1043 + return id; 1044 + } 1065 1045 1066 1046 /* 1067 1047 * Next, check ACPI_DT_NAMESPACE_HID and try to match the ··· 2127 2101 if (info->valid & ACPI_VALID_UID) 2128 2102 pnp->unique_id = kstrdup(info->unique_id.string, 2129 2103 GFP_KERNEL); 2104 + if (info->valid & ACPI_VALID_CLS) 2105 + acpi_add_id(pnp, info->class_code.string); 2130 2106 2131 2107 kfree(info); 2132 2108
+1 -1
drivers/ata/Kconfig
··· 48 48 49 49 config ATA_ACPI 50 50 bool "ATA ACPI Support" 51 - depends on ACPI && PCI 51 + depends on ACPI 52 52 default y 53 53 help 54 54 This option adds support for ATA-related ACPI objects.
+9
drivers/ata/ahci_platform.c
··· 20 20 #include <linux/platform_device.h> 21 21 #include <linux/libata.h> 22 22 #include <linux/ahci_platform.h> 23 + #include <linux/acpi.h> 24 + #include <linux/pci_ids.h> 23 25 #include "ahci.h" 24 26 25 27 #define DRV_NAME "ahci" ··· 81 79 }; 82 80 MODULE_DEVICE_TABLE(of, ahci_of_match); 83 81 82 + static const struct acpi_device_id ahci_acpi_match[] = { 83 + { ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff) }, 84 + {}, 85 + }; 86 + MODULE_DEVICE_TABLE(acpi, ahci_acpi_match); 87 + 84 88 static struct platform_driver ahci_driver = { 85 89 .probe = ahci_probe, 86 90 .remove = ata_platform_remove_one, 87 91 .driver = { 88 92 .name = DRV_NAME, 89 93 .of_match_table = ahci_of_match, 94 + .acpi_match_table = ahci_acpi_match, 90 95 .pm = &ahci_pm_ops, 91 96 }, 92 97 };
+13 -3
drivers/base/firmware_class.c
··· 563 563 kfree(fw_priv); 564 564 } 565 565 566 - static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) 566 + static int do_firmware_uevent(struct firmware_priv *fw_priv, struct kobj_uevent_env *env) 567 567 { 568 - struct firmware_priv *fw_priv = to_firmware_priv(dev); 569 - 570 568 if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->buf->fw_id)) 571 569 return -ENOMEM; 572 570 if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) ··· 573 575 return -ENOMEM; 574 576 575 577 return 0; 578 + } 579 + 580 + static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) 581 + { 582 + struct firmware_priv *fw_priv = to_firmware_priv(dev); 583 + int err = 0; 584 + 585 + mutex_lock(&fw_lock); 586 + if (fw_priv->buf) 587 + err = do_firmware_uevent(fw_priv, env); 588 + mutex_unlock(&fw_lock); 589 + return err; 576 590 } 577 591 578 592 static struct class firmware_class = {
+11 -2
drivers/base/power/domain.c
··· 6 6 * This file is released under the GPLv2. 7 7 */ 8 8 9 + #include <linux/delay.h> 9 10 #include <linux/kernel.h> 10 11 #include <linux/io.h> 11 12 #include <linux/platform_device.h> ··· 19 18 #include <linux/sched.h> 20 19 #include <linux/suspend.h> 21 20 #include <linux/export.h> 21 + 22 + #define GENPD_RETRY_MAX_MS 250 /* Approximate */ 22 23 23 24 #define GENPD_DEV_CALLBACK(genpd, type, callback, dev) \ 24 25 ({ \ ··· 2134 2131 static void genpd_dev_pm_detach(struct device *dev, bool power_off) 2135 2132 { 2136 2133 struct generic_pm_domain *pd; 2134 + unsigned int i; 2137 2135 int ret = 0; 2138 2136 2139 2137 pd = pm_genpd_lookup_dev(dev); ··· 2143 2139 2144 2140 dev_dbg(dev, "removing from PM domain %s\n", pd->name); 2145 2141 2146 - while (1) { 2142 + for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) { 2147 2143 ret = pm_genpd_remove_device(pd, dev); 2148 2144 if (ret != -EAGAIN) 2149 2145 break; 2146 + 2147 + mdelay(i); 2150 2148 cond_resched(); 2151 2149 } 2152 2150 ··· 2189 2183 { 2190 2184 struct of_phandle_args pd_args; 2191 2185 struct generic_pm_domain *pd; 2186 + unsigned int i; 2192 2187 int ret; 2193 2188 2194 2189 if (!dev->of_node) ··· 2225 2218 2226 2219 dev_dbg(dev, "adding to PM domain %s\n", pd->name); 2227 2220 2228 - while (1) { 2221 + for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) { 2229 2222 ret = pm_genpd_add_device(pd, dev); 2230 2223 if (ret != -EAGAIN) 2231 2224 break; 2225 + 2226 + mdelay(i); 2232 2227 cond_resched(); 2233 2228 } 2234 2229
+5 -7
drivers/base/power/wakeirq.c
··· 45 45 return -EEXIST; 46 46 } 47 47 48 - dev->power.wakeirq = wirq; 49 - spin_unlock_irqrestore(&dev->power.lock, flags); 50 - 51 48 err = device_wakeup_attach_irq(dev, wirq); 52 - if (err) 53 - return err; 49 + if (!err) 50 + dev->power.wakeirq = wirq; 54 51 55 - return 0; 52 + spin_unlock_irqrestore(&dev->power.lock, flags); 53 + return err; 56 54 } 57 55 58 56 /** ··· 103 105 return; 104 106 105 107 spin_lock_irqsave(&dev->power.lock, flags); 108 + device_wakeup_detach_irq(dev); 106 109 dev->power.wakeirq = NULL; 107 110 spin_unlock_irqrestore(&dev->power.lock, flags); 108 111 109 - device_wakeup_detach_irq(dev); 110 112 if (wirq->dedicated_irq) 111 113 free_irq(wirq->irq, wirq); 112 114 kfree(wirq);
+10 -21
drivers/base/power/wakeup.c
··· 281 281 * Attach a device wakeirq to the wakeup source so the device 282 282 * wake IRQ can be configured automatically for suspend and 283 283 * resume. 284 + * 285 + * Call under the device's power.lock lock. 284 286 */ 285 287 int device_wakeup_attach_irq(struct device *dev, 286 288 struct wake_irq *wakeirq) 287 289 { 288 290 struct wakeup_source *ws; 289 - int ret = 0; 290 291 291 - spin_lock_irq(&dev->power.lock); 292 292 ws = dev->power.wakeup; 293 293 if (!ws) { 294 294 dev_err(dev, "forgot to call call device_init_wakeup?\n"); 295 - ret = -EINVAL; 296 - goto unlock; 295 + return -EINVAL; 297 296 } 298 297 299 - if (ws->wakeirq) { 300 - ret = -EEXIST; 301 - goto unlock; 302 - } 298 + if (ws->wakeirq) 299 + return -EEXIST; 303 300 304 301 ws->wakeirq = wakeirq; 305 - 306 - unlock: 307 - spin_unlock_irq(&dev->power.lock); 308 - 309 - return ret; 302 + return 0; 310 303 } 311 304 312 305 /** ··· 307 314 * @dev: Device to handle 308 315 * 309 316 * Removes a device wakeirq from the wakeup source. 317 + * 318 + * Call under the device's power.lock lock. 310 319 */ 311 320 void device_wakeup_detach_irq(struct device *dev) 312 321 { 313 322 struct wakeup_source *ws; 314 323 315 - spin_lock_irq(&dev->power.lock); 316 324 ws = dev->power.wakeup; 317 - if (!ws) 318 - goto unlock; 319 - 320 - ws->wakeirq = NULL; 321 - 322 - unlock: 323 - spin_unlock_irq(&dev->power.lock); 325 + if (ws) 326 + ws->wakeirq = NULL; 324 327 } 325 328 326 329 /**
+3 -1
drivers/clk/at91/clk-h32mx.c
··· 116 116 h32mxclk->pmc = pmc; 117 117 118 118 clk = clk_register(NULL, &h32mxclk->hw); 119 - if (!clk) 119 + if (!clk) { 120 + kfree(h32mxclk); 120 121 return; 122 + } 121 123 122 124 of_clk_add_provider(np, of_clk_src_simple_get, clk); 123 125 }
+3 -1
drivers/clk/at91/clk-main.c
··· 171 171 irq_set_status_flags(osc->irq, IRQ_NOAUTOEN); 172 172 ret = request_irq(osc->irq, clk_main_osc_irq_handler, 173 173 IRQF_TRIGGER_HIGH, name, osc); 174 - if (ret) 174 + if (ret) { 175 + kfree(osc); 175 176 return ERR_PTR(ret); 177 + } 176 178 177 179 if (bypass) 178 180 pmc_write(pmc, AT91_CKGR_MOR,
+6 -2
drivers/clk/at91/clk-master.c
··· 165 165 irq_set_status_flags(master->irq, IRQ_NOAUTOEN); 166 166 ret = request_irq(master->irq, clk_master_irq_handler, 167 167 IRQF_TRIGGER_HIGH, "clk-master", master); 168 - if (ret) 168 + if (ret) { 169 + kfree(master); 169 170 return ERR_PTR(ret); 171 + } 170 172 171 173 clk = clk_register(NULL, &master->hw); 172 - if (IS_ERR(clk)) 174 + if (IS_ERR(clk)) { 175 + free_irq(master->irq, master); 173 176 kfree(master); 177 + } 174 178 175 179 return clk; 176 180 }
+6 -2
drivers/clk/at91/clk-pll.c
··· 346 346 irq_set_status_flags(pll->irq, IRQ_NOAUTOEN); 347 347 ret = request_irq(pll->irq, clk_pll_irq_handler, IRQF_TRIGGER_HIGH, 348 348 id ? "clk-pllb" : "clk-plla", pll); 349 - if (ret) 349 + if (ret) { 350 + kfree(pll); 350 351 return ERR_PTR(ret); 352 + } 351 353 352 354 clk = clk_register(NULL, &pll->hw); 353 - if (IS_ERR(clk)) 355 + if (IS_ERR(clk)) { 356 + free_irq(pll->irq, pll); 354 357 kfree(pll); 358 + } 355 359 356 360 return clk; 357 361 }
+6 -2
drivers/clk/at91/clk-system.c
··· 130 130 irq_set_status_flags(sys->irq, IRQ_NOAUTOEN); 131 131 ret = request_irq(sys->irq, clk_system_irq_handler, 132 132 IRQF_TRIGGER_HIGH, name, sys); 133 - if (ret) 133 + if (ret) { 134 + kfree(sys); 134 135 return ERR_PTR(ret); 136 + } 135 137 } 136 138 137 139 clk = clk_register(NULL, &sys->hw); 138 - if (IS_ERR(clk)) 140 + if (IS_ERR(clk)) { 141 + free_irq(sys->irq, sys); 139 142 kfree(sys); 143 + } 140 144 141 145 return clk; 142 146 }
+6 -2
drivers/clk/at91/clk-utmi.c
··· 118 118 irq_set_status_flags(utmi->irq, IRQ_NOAUTOEN); 119 119 ret = request_irq(utmi->irq, clk_utmi_irq_handler, 120 120 IRQF_TRIGGER_HIGH, "clk-utmi", utmi); 121 - if (ret) 121 + if (ret) { 122 + kfree(utmi); 122 123 return ERR_PTR(ret); 124 + } 123 125 124 126 clk = clk_register(NULL, &utmi->hw); 125 - if (IS_ERR(clk)) 127 + if (IS_ERR(clk)) { 128 + free_irq(utmi->irq, utmi); 126 129 kfree(utmi); 130 + } 127 131 128 132 return clk; 129 133 }
+1 -5
drivers/clk/bcm/clk-iproc-asiu.c
··· 222 222 struct iproc_asiu_clk *asiu_clk; 223 223 const char *clk_name; 224 224 225 - clk_name = kzalloc(IPROC_CLK_NAME_LEN, GFP_KERNEL); 226 - if (WARN_ON(!clk_name)) 227 - goto err_clk_register; 228 - 229 225 ret = of_property_read_string_index(node, "clock-output-names", 230 226 i, &clk_name); 231 227 if (WARN_ON(ret)) ··· 255 259 256 260 err_clk_register: 257 261 for (i = 0; i < num_clks; i++) 258 - kfree(asiu->clks[i].name); 262 + clk_unregister(asiu->clk_data.clks[i]); 259 263 iounmap(asiu->gate_base); 260 264 261 265 err_iomap_gate:
+4 -9
drivers/clk/bcm/clk-iproc-pll.c
··· 366 366 val = readl(pll->pll_base + ctrl->ndiv_int.offset); 367 367 ndiv_int = (val >> ctrl->ndiv_int.shift) & 368 368 bit_mask(ctrl->ndiv_int.width); 369 - ndiv = ndiv_int << ctrl->ndiv_int.shift; 369 + ndiv = (u64)ndiv_int << ctrl->ndiv_int.shift; 370 370 371 371 if (ctrl->flags & IPROC_CLK_PLL_HAS_NDIV_FRAC) { 372 372 val = readl(pll->pll_base + ctrl->ndiv_frac.offset); ··· 374 374 bit_mask(ctrl->ndiv_frac.width); 375 375 376 376 if (ndiv_frac != 0) 377 - ndiv = (ndiv_int << ctrl->ndiv_int.shift) | ndiv_frac; 377 + ndiv = ((u64)ndiv_int << ctrl->ndiv_int.shift) | 378 + ndiv_frac; 378 379 } 379 380 380 381 val = readl(pll->pll_base + ctrl->pdiv.offset); ··· 656 655 memset(&init, 0, sizeof(init)); 657 656 parent_name = node->name; 658 657 659 - clk_name = kzalloc(IPROC_CLK_NAME_LEN, GFP_KERNEL); 660 - if (WARN_ON(!clk_name)) 661 - goto err_clk_register; 662 - 663 658 ret = of_property_read_string_index(node, "clock-output-names", 664 659 i, &clk_name); 665 660 if (WARN_ON(ret)) ··· 687 690 return; 688 691 689 692 err_clk_register: 690 - for (i = 0; i < num_clks; i++) { 691 - kfree(pll->clks[i].name); 693 + for (i = 0; i < num_clks; i++) 692 694 clk_unregister(pll->clk_data.clks[i]); 693 - } 694 695 695 696 err_pll_register: 696 697 if (pll->asiu_base)
+1 -1
drivers/clk/clk-stm32f4.c
··· 268 268 memcpy(table, stm32f42xx_gate_map, sizeof(table)); 269 269 270 270 /* only bits set in table can be used as indices */ 271 - if (WARN_ON(secondary > 8 * sizeof(table) || 271 + if (WARN_ON(secondary >= BITS_PER_BYTE * sizeof(table) || 272 272 0 == (table[BIT_ULL_WORD(secondary)] & 273 273 BIT_ULL_MASK(secondary)))) 274 274 return -EINVAL;
+21 -5
drivers/clk/mediatek/clk-mt8173.c
··· 700 700 MUX(CLK_PERI_UART3_SEL, "uart3_ck_sel", uart_ck_sel_parents, 0x40c, 3, 1), 701 701 }; 702 702 703 + static struct clk_onecell_data *mt8173_top_clk_data __initdata; 704 + static struct clk_onecell_data *mt8173_pll_clk_data __initdata; 705 + 706 + static void __init mtk_clk_enable_critical(void) 707 + { 708 + if (!mt8173_top_clk_data || !mt8173_pll_clk_data) 709 + return; 710 + 711 + clk_prepare_enable(mt8173_pll_clk_data->clks[CLK_APMIXED_ARMCA15PLL]); 712 + clk_prepare_enable(mt8173_pll_clk_data->clks[CLK_APMIXED_ARMCA7PLL]); 713 + clk_prepare_enable(mt8173_top_clk_data->clks[CLK_TOP_MEM_SEL]); 714 + clk_prepare_enable(mt8173_top_clk_data->clks[CLK_TOP_DDRPHYCFG_SEL]); 715 + clk_prepare_enable(mt8173_top_clk_data->clks[CLK_TOP_CCI400_SEL]); 716 + clk_prepare_enable(mt8173_top_clk_data->clks[CLK_TOP_RTC_SEL]); 717 + } 718 + 703 719 static void __init mtk_topckgen_init(struct device_node *node) 704 720 { 705 721 struct clk_onecell_data *clk_data; ··· 728 712 return; 729 713 } 730 714 731 - clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 715 + mt8173_top_clk_data = clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 732 716 733 717 mtk_clk_register_factors(root_clk_alias, ARRAY_SIZE(root_clk_alias), clk_data); 734 718 mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 735 719 mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), base, 736 720 &mt8173_clk_lock, clk_data); 737 721 738 - clk_prepare_enable(clk_data->clks[CLK_TOP_CCI400_SEL]); 739 - 740 722 r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 741 723 if (r) 742 724 pr_err("%s(): could not register clock provider: %d\n", 743 725 __func__, r); 726 + 727 + mtk_clk_enable_critical(); 744 728 } 745 729 CLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8173-topckgen", mtk_topckgen_init); 746 730 ··· 834 818 { 835 819 struct clk_onecell_data *clk_data; 836 820 837 - clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 821 + mt8173_pll_clk_data = clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 838 822 if (!clk_data) 839 823 return; 840 824 841 825 mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 842 826 843 - clk_prepare_enable(clk_data->clks[CLK_APMIXED_ARMCA15PLL]); 827 + mtk_clk_enable_critical(); 844 828 } 845 829 CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8173-apmixedsys", 846 830 mtk_apmixedsys_init);
+3 -6
drivers/clk/qcom/clk-rcg2.c
··· 530 530 struct clk_rcg2 *rcg = to_clk_rcg2(hw); 531 531 struct freq_tbl f = *rcg->freq_tbl; 532 532 const struct frac_entry *frac = frac_table_pixel; 533 - unsigned long request, src_rate; 533 + unsigned long request; 534 534 int delta = 100000; 535 535 u32 mask = BIT(rcg->hid_width) - 1; 536 536 u32 hid_div; 537 - int index = qcom_find_src_index(hw, rcg->parent_map, f.src); 538 - struct clk *parent = clk_get_parent_by_index(hw->clk, index); 539 537 540 538 for (; frac->num; frac++) { 541 539 request = (rate * frac->den) / frac->num; 542 540 543 - src_rate = __clk_round_rate(parent, request); 544 - if ((src_rate < (request - delta)) || 545 - (src_rate > (request + delta))) 541 + if ((parent_rate < (request - delta)) || 542 + (parent_rate > (request + delta))) 546 543 continue; 547 544 548 545 regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG,
+3 -1
drivers/clk/st/clk-flexgen.c
··· 190 190 191 191 init.name = name; 192 192 init.ops = &flexgen_ops; 193 - init.flags = CLK_IS_BASIC | flexgen_flags; 193 + init.flags = CLK_IS_BASIC | CLK_GET_RATE_NOCACHE | flexgen_flags; 194 194 init.parent_names = parent_names; 195 195 init.num_parents = num_parents; 196 196 ··· 302 302 rlock = kzalloc(sizeof(spinlock_t), GFP_KERNEL); 303 303 if (!rlock) 304 304 goto err; 305 + 306 + spin_lock_init(rlock); 305 307 306 308 for (i = 0; i < clk_data->clk_num; i++) { 307 309 struct clk *clk;
+4 -8
drivers/clk/st/clkgen-fsyn.c
··· 340 340 CLKGEN_FIELD(0x30c, 0xf, 20), 341 341 CLKGEN_FIELD(0x310, 0xf, 20) }, 342 342 .lockstatus_present = true, 343 - .lock_status = CLKGEN_FIELD(0x2A0, 0x1, 24), 343 + .lock_status = CLKGEN_FIELD(0x2f0, 0x1, 24), 344 344 .powerup_polarity = 1, 345 345 .standby_polarity = 1, 346 346 .pll_ops = &st_quadfs_pll_c32_ops, ··· 489 489 struct st_clk_quadfs_pll *pll = to_quadfs_pll(hw); 490 490 u32 npda = CLKGEN_READ(pll, npda); 491 491 492 - return !!npda; 492 + return pll->data->powerup_polarity ? !npda : !!npda; 493 493 } 494 494 495 495 static int clk_fs660c32_vco_get_rate(unsigned long input, struct stm_fs *fs, ··· 635 635 636 636 init.name = name; 637 637 init.ops = quadfs->pll_ops; 638 - init.flags = CLK_IS_BASIC; 638 + init.flags = CLK_IS_BASIC | CLK_GET_RATE_NOCACHE; 639 639 init.parent_names = &parent_name; 640 640 init.num_parents = 1; 641 641 ··· 774 774 if (fs->lock) 775 775 spin_lock_irqsave(fs->lock, flags); 776 776 777 - CLKGEN_WRITE(fs, nsb[fs->chan], !fs->data->standby_polarity); 777 + CLKGEN_WRITE(fs, nsb[fs->chan], fs->data->standby_polarity); 778 778 779 779 if (fs->lock) 780 780 spin_unlock_irqrestore(fs->lock, flags); ··· 1081 1081 { 1082 1082 .compatible = "st,stih407-quadfs660-D", 1083 1083 .data = &st_fs660c32_D_407 1084 - }, 1085 - { 1086 - .compatible = "st,stih407-quadfs660-D", 1087 - .data = (void *)&st_fs660c32_D_407 1088 1084 }, 1089 1085 {} 1090 1086 };
+6 -4
drivers/clk/st/clkgen-mux.c
··· 237 237 238 238 init.name = name; 239 239 init.ops = &clkgena_divmux_ops; 240 - init.flags = CLK_IS_BASIC; 240 + init.flags = CLK_IS_BASIC | CLK_GET_RATE_NOCACHE; 241 241 init.parent_names = parent_names; 242 242 init.num_parents = num_parents; 243 243 ··· 513 513 0, &clk_name)) 514 514 return; 515 515 516 - clk = clk_register_divider_table(NULL, clk_name, parent_name, 0, 516 + clk = clk_register_divider_table(NULL, clk_name, parent_name, 517 + CLK_GET_RATE_NOCACHE, 517 518 reg + data->offset, data->shift, 1, 518 519 0, data->table, NULL); 519 520 if (IS_ERR(clk)) ··· 583 582 }; 584 583 static struct clkgen_mux_data stih407_a9_mux_data = { 585 584 .offset = 0x1a4, 586 - .shift = 1, 585 + .shift = 0, 587 586 .width = 2, 588 587 }; 589 588 ··· 787 786 &mux->hw, &clk_mux_ops, 788 787 &div->hw, &clk_divider_ops, 789 788 &gate->hw, &clk_gate_ops, 790 - data->clk_flags); 789 + data->clk_flags | 790 + CLK_GET_RATE_NOCACHE); 791 791 if (IS_ERR(clk)) { 792 792 kfree(gate); 793 793 kfree(div);
+1 -1
drivers/clk/st/clkgen-pll.c
··· 406 406 init.name = clk_name; 407 407 init.ops = pll_data->ops; 408 408 409 - init.flags = CLK_IS_BASIC; 409 + init.flags = CLK_IS_BASIC | CLK_GET_RATE_NOCACHE; 410 410 init.parent_names = &parent_name; 411 411 init.num_parents = 1; 412 412
+1
drivers/clk/sunxi/clk-sunxi.c
··· 1391 1391 CLK_OF_DECLARE(sun6i_a31_clk_init, "allwinner,sun6i-a31", sun6i_init_clocks); 1392 1392 CLK_OF_DECLARE(sun6i_a31s_clk_init, "allwinner,sun6i-a31s", sun6i_init_clocks); 1393 1393 CLK_OF_DECLARE(sun8i_a23_clk_init, "allwinner,sun8i-a23", sun6i_init_clocks); 1394 + CLK_OF_DECLARE(sun8i_a33_clk_init, "allwinner,sun8i-a33", sun6i_init_clocks); 1394 1395 1395 1396 static void __init sun9i_init_clocks(struct device_node *node) 1396 1397 {
+1
drivers/clocksource/timer-imx-gpt.c
··· 529 529 530 530 CLOCKSOURCE_OF_DECLARE(imx1_timer, "fsl,imx1-gpt", imx1_timer_init_dt); 531 531 CLOCKSOURCE_OF_DECLARE(imx21_timer, "fsl,imx21-gpt", imx21_timer_init_dt); 532 + CLOCKSOURCE_OF_DECLARE(imx27_timer, "fsl,imx27-gpt", imx21_timer_init_dt); 532 533 CLOCKSOURCE_OF_DECLARE(imx31_timer, "fsl,imx31-gpt", imx31_timer_init_dt); 533 534 CLOCKSOURCE_OF_DECLARE(imx25_timer, "fsl,imx25-gpt", imx31_timer_init_dt); 534 535 CLOCKSOURCE_OF_DECLARE(imx50_timer, "fsl,imx50-gpt", imx31_timer_init_dt);
+1 -1
drivers/cpufreq/loongson2_cpufreq.c
··· 3 3 * 4 4 * The 2E revision of loongson processor not support this feature. 5 5 * 6 - * Copyright (C) 2006 - 2008 Lemote Inc. & Insititute of Computing Technology 6 + * Copyright (C) 2006 - 2008 Lemote Inc. & Institute of Computing Technology 7 7 * Author: Yanhua, yanh@lemote.com 8 8 * 9 9 * This file is subject to the terms and conditions of the GNU General Public
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 352 352 if (((int64_t)timeout_ns) < 0) 353 353 return MAX_SCHEDULE_TIMEOUT; 354 354 355 - timeout = ktime_sub_ns(ktime_get(), timeout_ns); 355 + timeout = ktime_sub(ns_to_ktime(timeout_ns), ktime_get()); 356 356 if (ktime_to_ns(timeout) < 0) 357 357 return 0; 358 358
+14 -8
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
··· 3403 3403 3404 3404 switch (entry->src_data) { 3405 3405 case 0: /* vblank */ 3406 - if (disp_int & interrupt_status_offsets[crtc].vblank) { 3406 + if (disp_int & interrupt_status_offsets[crtc].vblank) 3407 3407 dce_v10_0_crtc_vblank_int_ack(adev, crtc); 3408 - if (amdgpu_irq_enabled(adev, source, irq_type)) { 3409 - drm_handle_vblank(adev->ddev, crtc); 3410 - } 3411 - DRM_DEBUG("IH: D%d vblank\n", crtc + 1); 3408 + else 3409 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 3410 + 3411 + if (amdgpu_irq_enabled(adev, source, irq_type)) { 3412 + drm_handle_vblank(adev->ddev, crtc); 3412 3413 } 3414 + DRM_DEBUG("IH: D%d vblank\n", crtc + 1); 3415 + 3413 3416 break; 3414 3417 case 1: /* vline */ 3415 - if (disp_int & interrupt_status_offsets[crtc].vline) { 3418 + if (disp_int & interrupt_status_offsets[crtc].vline) 3416 3419 dce_v10_0_crtc_vline_int_ack(adev, crtc); 3417 - DRM_DEBUG("IH: D%d vline\n", crtc + 1); 3418 - } 3420 + else 3421 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 3422 + 3423 + DRM_DEBUG("IH: D%d vline\n", crtc + 1); 3424 + 3419 3425 break; 3420 3426 default: 3421 3427 DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data);
+14 -8
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
··· 3402 3402 3403 3403 switch (entry->src_data) { 3404 3404 case 0: /* vblank */ 3405 - if (disp_int & interrupt_status_offsets[crtc].vblank) { 3405 + if (disp_int & interrupt_status_offsets[crtc].vblank) 3406 3406 dce_v11_0_crtc_vblank_int_ack(adev, crtc); 3407 - if (amdgpu_irq_enabled(adev, source, irq_type)) { 3408 - drm_handle_vblank(adev->ddev, crtc); 3409 - } 3410 - DRM_DEBUG("IH: D%d vblank\n", crtc + 1); 3407 + else 3408 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 3409 + 3410 + if (amdgpu_irq_enabled(adev, source, irq_type)) { 3411 + drm_handle_vblank(adev->ddev, crtc); 3411 3412 } 3413 + DRM_DEBUG("IH: D%d vblank\n", crtc + 1); 3414 + 3412 3415 break; 3413 3416 case 1: /* vline */ 3414 - if (disp_int & interrupt_status_offsets[crtc].vline) { 3417 + if (disp_int & interrupt_status_offsets[crtc].vline) 3415 3418 dce_v11_0_crtc_vline_int_ack(adev, crtc); 3416 - DRM_DEBUG("IH: D%d vline\n", crtc + 1); 3417 - } 3419 + else 3420 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 3421 + 3422 + DRM_DEBUG("IH: D%d vline\n", crtc + 1); 3423 + 3418 3424 break; 3419 3425 default: 3420 3426 DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data);
+14 -8
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
··· 3237 3237 3238 3238 switch (entry->src_data) { 3239 3239 case 0: /* vblank */ 3240 - if (disp_int & interrupt_status_offsets[crtc].vblank) { 3240 + if (disp_int & interrupt_status_offsets[crtc].vblank) 3241 3241 WREG32(mmLB_VBLANK_STATUS + crtc_offsets[crtc], LB_VBLANK_STATUS__VBLANK_ACK_MASK); 3242 - if (amdgpu_irq_enabled(adev, source, irq_type)) { 3243 - drm_handle_vblank(adev->ddev, crtc); 3244 - } 3245 - DRM_DEBUG("IH: D%d vblank\n", crtc + 1); 3242 + else 3243 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 3244 + 3245 + if (amdgpu_irq_enabled(adev, source, irq_type)) { 3246 + drm_handle_vblank(adev->ddev, crtc); 3246 3247 } 3248 + DRM_DEBUG("IH: D%d vblank\n", crtc + 1); 3249 + 3247 3250 break; 3248 3251 case 1: /* vline */ 3249 - if (disp_int & interrupt_status_offsets[crtc].vline) { 3252 + if (disp_int & interrupt_status_offsets[crtc].vline) 3250 3253 WREG32(mmLB_VLINE_STATUS + crtc_offsets[crtc], LB_VLINE_STATUS__VLINE_ACK_MASK); 3251 - DRM_DEBUG("IH: D%d vline\n", crtc + 1); 3252 - } 3254 + else 3255 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 3256 + 3257 + DRM_DEBUG("IH: D%d vline\n", crtc + 1); 3258 + 3253 3259 break; 3254 3260 default: 3255 3261 DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data);
+7 -2
drivers/gpu/drm/amd/amdkfd/kfd_process.c
··· 420 420 pqm_uninit(&p->pqm); 421 421 422 422 pdd = kfd_get_process_device_data(dev, p); 423 + 424 + if (!pdd) { 425 + mutex_unlock(&p->mutex); 426 + return; 427 + } 428 + 423 429 if (pdd->reset_wavefronts) { 424 430 dbgdev_wave_reset_wavefronts(pdd->dev, p); 425 431 pdd->reset_wavefronts = false; ··· 437 431 * We don't call amd_iommu_unbind_pasid() here 438 432 * because the IOMMU called us. 439 433 */ 440 - if (pdd) 441 - pdd->bound = false; 434 + pdd->bound = false; 442 435 443 436 mutex_unlock(&p->mutex); 444 437 }
+1 -3
drivers/gpu/drm/i915/i915_gem_context.c
··· 157 157 struct drm_i915_gem_object *obj; 158 158 int ret; 159 159 160 - obj = i915_gem_object_create_stolen(dev, size); 161 - if (obj == NULL) 162 - obj = i915_gem_alloc_object(dev, size); 160 + obj = i915_gem_alloc_object(dev, size); 163 161 if (obj == NULL) 164 162 return ERR_PTR(-ENOMEM); 165 163
+16 -7
drivers/gpu/drm/i915/i915_gem_gtt.c
··· 2546 2546 struct drm_i915_private *dev_priv = dev->dev_private; 2547 2547 struct drm_i915_gem_object *obj; 2548 2548 struct i915_address_space *vm; 2549 + struct i915_vma *vma; 2550 + bool flush; 2549 2551 2550 2552 i915_check_and_clear_faults(dev); 2551 2553 ··· 2557 2555 dev_priv->gtt.base.total, 2558 2556 true); 2559 2557 2558 + /* Cache flush objects bound into GGTT and rebind them. */ 2559 + vm = &dev_priv->gtt.base; 2560 2560 list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) { 2561 - struct i915_vma *vma = i915_gem_obj_to_vma(obj, 2562 - &dev_priv->gtt.base); 2563 - if (!vma) 2564 - continue; 2561 + flush = false; 2562 + list_for_each_entry(vma, &obj->vma_list, vma_link) { 2563 + if (vma->vm != vm) 2564 + continue; 2565 2565 2566 - i915_gem_clflush_object(obj, obj->pin_display); 2567 - WARN_ON(i915_vma_bind(vma, obj->cache_level, PIN_UPDATE)); 2566 + WARN_ON(i915_vma_bind(vma, obj->cache_level, 2567 + PIN_UPDATE)); 2568 + 2569 + flush = true; 2570 + } 2571 + 2572 + if (flush) 2573 + i915_gem_clflush_object(obj, obj->pin_display); 2568 2574 } 2569 - 2570 2575 2571 2576 if (INTEL_INFO(dev)->gen >= 8) { 2572 2577 if (IS_CHERRYVIEW(dev) || IS_BROXTON(dev))
+11 -1
drivers/gpu/drm/i915/i915_gem_tiling.c
··· 183 183 if (IS_GEN4(dev)) { 184 184 uint32_t ddc2 = I915_READ(DCC2); 185 185 186 - if (!(ddc2 & DCC2_MODIFIED_ENHANCED_DISABLE)) 186 + if (!(ddc2 & DCC2_MODIFIED_ENHANCED_DISABLE)) { 187 + /* Since the swizzling may vary within an 188 + * object, we have no idea what the swizzling 189 + * is for any page in particular. Thus we 190 + * cannot migrate tiled pages using the GPU, 191 + * nor can we tell userspace what the exact 192 + * swizzling is for any object. 193 + */ 187 194 dev_priv->quirks |= QUIRK_PIN_SWIZZLED_PAGES; 195 + swizzle_x = I915_BIT_6_SWIZZLE_UNKNOWN; 196 + swizzle_y = I915_BIT_6_SWIZZLE_UNKNOWN; 197 + } 188 198 } 189 199 190 200 if (dcc == 0xffffffff) {
+8 -2
drivers/gpu/drm/i915/intel_display.c
··· 4854 4854 struct intel_plane *intel_plane; 4855 4855 int pipe = intel_crtc->pipe; 4856 4856 4857 + if (!intel_crtc->active) 4858 + return; 4859 + 4857 4860 intel_crtc_wait_for_pending_flips(crtc); 4858 4861 4859 4862 intel_pre_disable_primary(crtc); ··· 7890 7887 int pipe = pipe_config->cpu_transcoder; 7891 7888 enum dpio_channel port = vlv_pipe_to_channel(pipe); 7892 7889 intel_clock_t clock; 7893 - u32 cmn_dw13, pll_dw0, pll_dw1, pll_dw2; 7890 + u32 cmn_dw13, pll_dw0, pll_dw1, pll_dw2, pll_dw3; 7894 7891 int refclk = 100000; 7895 7892 7896 7893 mutex_lock(&dev_priv->sb_lock); ··· 7898 7895 pll_dw0 = vlv_dpio_read(dev_priv, pipe, CHV_PLL_DW0(port)); 7899 7896 pll_dw1 = vlv_dpio_read(dev_priv, pipe, CHV_PLL_DW1(port)); 7900 7897 pll_dw2 = vlv_dpio_read(dev_priv, pipe, CHV_PLL_DW2(port)); 7898 + pll_dw3 = vlv_dpio_read(dev_priv, pipe, CHV_PLL_DW3(port)); 7901 7899 mutex_unlock(&dev_priv->sb_lock); 7902 7900 7903 7901 clock.m1 = (pll_dw1 & 0x7) == DPIO_CHV_M1_DIV_BY_2 ? 2 : 0; 7904 - clock.m2 = ((pll_dw0 & 0xff) << 22) | (pll_dw2 & 0x3fffff); 7902 + clock.m2 = (pll_dw0 & 0xff) << 22; 7903 + if (pll_dw3 & DPIO_CHV_FRAC_DIV_EN) 7904 + clock.m2 |= pll_dw2 & 0x3fffff; 7905 7905 clock.n = (pll_dw1 >> DPIO_CHV_N_DIV_SHIFT) & 0xf; 7906 7906 clock.p1 = (cmn_dw13 >> DPIO_CHV_P1_DIV_SHIFT) & 0x7; 7907 7907 clock.p2 = (cmn_dw13 >> DPIO_CHV_P2_DIV_SHIFT) & 0x1f;
+1 -1
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
··· 285 285 286 286 if (wait) { 287 287 if (!wait_for_completion_timeout(&engine->compl, 288 - msecs_to_jiffies(1))) { 288 + msecs_to_jiffies(100))) { 289 289 dev_err(dmm->dev, "timed out waiting for done\n"); 290 290 ret = -ETIMEDOUT; 291 291 }
+3 -3
drivers/gpu/drm/omapdrm/omap_drv.h
··· 177 177 struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos); 178 178 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p); 179 179 int omap_framebuffer_pin(struct drm_framebuffer *fb); 180 - int omap_framebuffer_unpin(struct drm_framebuffer *fb); 180 + void omap_framebuffer_unpin(struct drm_framebuffer *fb); 181 181 void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, 182 182 struct omap_drm_window *win, struct omap_overlay_info *info); 183 183 struct drm_connector *omap_framebuffer_get_next_connector( ··· 211 211 enum dma_data_direction dir); 212 212 int omap_gem_get_paddr(struct drm_gem_object *obj, 213 213 dma_addr_t *paddr, bool remap); 214 - int omap_gem_put_paddr(struct drm_gem_object *obj); 214 + void omap_gem_put_paddr(struct drm_gem_object *obj); 215 215 int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages, 216 216 bool remap); 217 217 int omap_gem_put_pages(struct drm_gem_object *obj); ··· 236 236 /* PVR needs alignment to 8 pixels.. right now that is the most 237 237 * restrictive stride requirement.. 238 238 */ 239 - return ALIGN(pitch, 8 * bytespp); 239 + return roundup(pitch, 8 * bytespp); 240 240 } 241 241 242 242 /* map crtc to vblank mask */
+4 -12
drivers/gpu/drm/omapdrm/omap_fb.c
··· 287 287 } 288 288 289 289 /* unpin, no longer being scanned out: */ 290 - int omap_framebuffer_unpin(struct drm_framebuffer *fb) 290 + void omap_framebuffer_unpin(struct drm_framebuffer *fb) 291 291 { 292 292 struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb); 293 - int ret, i, n = drm_format_num_planes(fb->pixel_format); 293 + int i, n = drm_format_num_planes(fb->pixel_format); 294 294 295 295 mutex_lock(&omap_fb->lock); 296 296 ··· 298 298 299 299 if (omap_fb->pin_count > 0) { 300 300 mutex_unlock(&omap_fb->lock); 301 - return 0; 301 + return; 302 302 } 303 303 304 304 for (i = 0; i < n; i++) { 305 305 struct plane *plane = &omap_fb->planes[i]; 306 - ret = omap_gem_put_paddr(plane->bo); 307 - if (ret) 308 - goto fail; 306 + omap_gem_put_paddr(plane->bo); 309 307 plane->paddr = 0; 310 308 } 311 309 312 310 mutex_unlock(&omap_fb->lock); 313 - 314 - return 0; 315 - 316 - fail: 317 - mutex_unlock(&omap_fb->lock); 318 - return ret; 319 311 } 320 312 321 313 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p)
+1 -1
drivers/gpu/drm/omapdrm/omap_fbdev.c
··· 135 135 fbdev->ywrap_enabled = priv->has_dmm && ywrap_enabled; 136 136 if (fbdev->ywrap_enabled) { 137 137 /* need to align pitch to page size if using DMM scrolling */ 138 - mode_cmd.pitches[0] = ALIGN(mode_cmd.pitches[0], PAGE_SIZE); 138 + mode_cmd.pitches[0] = PAGE_ALIGN(mode_cmd.pitches[0]); 139 139 } 140 140 141 141 /* allocate backing bo */
+14 -12
drivers/gpu/drm/omapdrm/omap_gem.c
··· 808 808 /* Release physical address, when DMA is no longer being performed.. this 809 809 * could potentially unpin and unmap buffers from TILER 810 810 */ 811 - int omap_gem_put_paddr(struct drm_gem_object *obj) 811 + void omap_gem_put_paddr(struct drm_gem_object *obj) 812 812 { 813 813 struct omap_gem_object *omap_obj = to_omap_bo(obj); 814 - int ret = 0; 814 + int ret; 815 815 816 816 mutex_lock(&obj->dev->struct_mutex); 817 817 if (omap_obj->paddr_cnt > 0) { ··· 821 821 if (ret) { 822 822 dev_err(obj->dev->dev, 823 823 "could not unpin pages: %d\n", ret); 824 - goto fail; 825 824 } 826 825 ret = tiler_release(omap_obj->block); 827 826 if (ret) { ··· 831 832 omap_obj->block = NULL; 832 833 } 833 834 } 834 - fail: 835 + 835 836 mutex_unlock(&obj->dev->struct_mutex); 836 - return ret; 837 837 } 838 838 839 839 /* Get rotated scanout address (only valid if already pinned), at the ··· 1376 1378 1377 1379 omap_obj = kzalloc(sizeof(*omap_obj), GFP_KERNEL); 1378 1380 if (!omap_obj) 1379 - goto fail; 1380 - 1381 - spin_lock(&priv->list_lock); 1382 - list_add(&omap_obj->mm_list, &priv->obj_list); 1383 - spin_unlock(&priv->list_lock); 1381 + return NULL; 1384 1382 1385 1383 obj = &omap_obj->base; 1386 1384 ··· 1386 1392 */ 1387 1393 omap_obj->vaddr = dma_alloc_writecombine(dev->dev, size, 1388 1394 &omap_obj->paddr, GFP_KERNEL); 1389 - if (omap_obj->vaddr) 1390 - flags |= OMAP_BO_DMA; 1395 + if (!omap_obj->vaddr) { 1396 + kfree(omap_obj); 1391 1397 1398 + return NULL; 1399 + } 1400 + 1401 + flags |= OMAP_BO_DMA; 1392 1402 } 1403 + 1404 + spin_lock(&priv->list_lock); 1405 + list_add(&omap_obj->mm_list, &priv->obj_list); 1406 + spin_unlock(&priv->list_lock); 1393 1407 1394 1408 omap_obj->flags = flags; 1395 1409
+26
drivers/gpu/drm/omapdrm/omap_plane.c
··· 17 17 * this program. If not, see <http://www.gnu.org/licenses/>. 18 18 */ 19 19 20 + #include <drm/drm_atomic.h> 20 21 #include <drm/drm_atomic_helper.h> 21 22 #include <drm/drm_plane_helper.h> 22 23 ··· 154 153 dispc_ovl_enable(omap_plane->id, false); 155 154 } 156 155 156 + static int omap_plane_atomic_check(struct drm_plane *plane, 157 + struct drm_plane_state *state) 158 + { 159 + struct drm_crtc_state *crtc_state; 160 + 161 + if (!state->crtc) 162 + return 0; 163 + 164 + crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc); 165 + if (IS_ERR(crtc_state)) 166 + return PTR_ERR(crtc_state); 167 + 168 + if (state->crtc_x < 0 || state->crtc_y < 0) 169 + return -EINVAL; 170 + 171 + if (state->crtc_x + state->crtc_w > crtc_state->adjusted_mode.hdisplay) 172 + return -EINVAL; 173 + 174 + if (state->crtc_y + state->crtc_h > crtc_state->adjusted_mode.vdisplay) 175 + return -EINVAL; 176 + 177 + return 0; 178 + } 179 + 157 180 static const struct drm_plane_helper_funcs omap_plane_helper_funcs = { 158 181 .prepare_fb = omap_plane_prepare_fb, 159 182 .cleanup_fb = omap_plane_cleanup_fb, 183 + .atomic_check = omap_plane_atomic_check, 160 184 .atomic_update = omap_plane_atomic_update, 161 185 .atomic_disable = omap_plane_atomic_disable, 162 186 };
+192 -144
drivers/gpu/drm/radeon/cik.c
··· 7964 7964 case 1: /* D1 vblank/vline */ 7965 7965 switch (src_data) { 7966 7966 case 0: /* D1 vblank */ 7967 - if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VBLANK_INTERRUPT) { 7968 - if (rdev->irq.crtc_vblank_int[0]) { 7969 - drm_handle_vblank(rdev->ddev, 0); 7970 - rdev->pm.vblank_sync = true; 7971 - wake_up(&rdev->irq.vblank_queue); 7972 - } 7973 - if (atomic_read(&rdev->irq.pflip[0])) 7974 - radeon_crtc_handle_vblank(rdev, 0); 7975 - rdev->irq.stat_regs.cik.disp_int &= ~LB_D1_VBLANK_INTERRUPT; 7976 - DRM_DEBUG("IH: D1 vblank\n"); 7967 + if (!(rdev->irq.stat_regs.cik.disp_int & LB_D1_VBLANK_INTERRUPT)) 7968 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 7969 + 7970 + if (rdev->irq.crtc_vblank_int[0]) { 7971 + drm_handle_vblank(rdev->ddev, 0); 7972 + rdev->pm.vblank_sync = true; 7973 + wake_up(&rdev->irq.vblank_queue); 7977 7974 } 7975 + if (atomic_read(&rdev->irq.pflip[0])) 7976 + radeon_crtc_handle_vblank(rdev, 0); 7977 + rdev->irq.stat_regs.cik.disp_int &= ~LB_D1_VBLANK_INTERRUPT; 7978 + DRM_DEBUG("IH: D1 vblank\n"); 7979 + 7978 7980 break; 7979 7981 case 1: /* D1 vline */ 7980 - if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VLINE_INTERRUPT) { 7981 - rdev->irq.stat_regs.cik.disp_int &= ~LB_D1_VLINE_INTERRUPT; 7982 - DRM_DEBUG("IH: D1 vline\n"); 7983 - } 7982 + if (!(rdev->irq.stat_regs.cik.disp_int & LB_D1_VLINE_INTERRUPT)) 7983 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 7984 + 7985 + rdev->irq.stat_regs.cik.disp_int &= ~LB_D1_VLINE_INTERRUPT; 7986 + DRM_DEBUG("IH: D1 vline\n"); 7987 + 7984 7988 break; 7985 7989 default: 7986 7990 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 7994 7990 case 2: /* D2 vblank/vline */ 7995 7991 switch (src_data) { 7996 7992 case 0: /* D2 vblank */ 7997 - if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VBLANK_INTERRUPT) { 7998 - if (rdev->irq.crtc_vblank_int[1]) { 7999 - drm_handle_vblank(rdev->ddev, 1); 8000 - rdev->pm.vblank_sync = true; 8001 - wake_up(&rdev->irq.vblank_queue); 8002 - } 8003 - if (atomic_read(&rdev->irq.pflip[1])) 8004 - radeon_crtc_handle_vblank(rdev, 1); 8005 - rdev->irq.stat_regs.cik.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; 8006 - DRM_DEBUG("IH: D2 vblank\n"); 7993 + if (!(rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VBLANK_INTERRUPT)) 7994 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 7995 + 7996 + if (rdev->irq.crtc_vblank_int[1]) { 7997 + drm_handle_vblank(rdev->ddev, 1); 7998 + rdev->pm.vblank_sync = true; 7999 + wake_up(&rdev->irq.vblank_queue); 8007 8000 } 8001 + if (atomic_read(&rdev->irq.pflip[1])) 8002 + radeon_crtc_handle_vblank(rdev, 1); 8003 + rdev->irq.stat_regs.cik.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; 8004 + DRM_DEBUG("IH: D2 vblank\n"); 8005 + 8008 8006 break; 8009 8007 case 1: /* D2 vline */ 8010 - if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VLINE_INTERRUPT) { 8011 - rdev->irq.stat_regs.cik.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; 8012 - DRM_DEBUG("IH: D2 vline\n"); 8013 - } 8008 + if (!(rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VLINE_INTERRUPT)) 8009 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8010 + 8011 + rdev->irq.stat_regs.cik.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; 8012 + DRM_DEBUG("IH: D2 vline\n"); 8013 + 8014 8014 break; 8015 8015 default: 8016 8016 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 8024 8016 case 3: /* D3 vblank/vline */ 8025 8017 switch (src_data) { 8026 8018 case 0: /* D3 vblank */ 8027 - if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) { 8028 - if (rdev->irq.crtc_vblank_int[2]) { 8029 - drm_handle_vblank(rdev->ddev, 2); 8030 - rdev->pm.vblank_sync = true; 8031 - wake_up(&rdev->irq.vblank_queue); 8032 - } 8033 - if (atomic_read(&rdev->irq.pflip[2])) 8034 - radeon_crtc_handle_vblank(rdev, 2); 8035 - rdev->irq.stat_regs.cik.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; 8036 - DRM_DEBUG("IH: D3 vblank\n"); 8019 + if (!(rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT)) 8020 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8021 + 8022 + if (rdev->irq.crtc_vblank_int[2]) { 8023 + drm_handle_vblank(rdev->ddev, 2); 8024 + rdev->pm.vblank_sync = true; 8025 + wake_up(&rdev->irq.vblank_queue); 8037 8026 } 8027 + if (atomic_read(&rdev->irq.pflip[2])) 8028 + radeon_crtc_handle_vblank(rdev, 2); 8029 + rdev->irq.stat_regs.cik.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; 8030 + DRM_DEBUG("IH: D3 vblank\n"); 8031 + 8038 8032 break; 8039 8033 case 1: /* D3 vline */ 8040 - if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) { 8041 - rdev->irq.stat_regs.cik.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; 8042 - DRM_DEBUG("IH: D3 vline\n"); 8043 - } 8034 + if (!(rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VLINE_INTERRUPT)) 8035 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8036 + 8037 + rdev->irq.stat_regs.cik.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; 8038 + DRM_DEBUG("IH: D3 vline\n"); 8039 + 8044 8040 break; 8045 8041 default: 8046 8042 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 8054 8042 case 4: /* D4 vblank/vline */ 8055 8043 switch (src_data) { 8056 8044 case 0: /* D4 vblank */ 8057 - if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) { 8058 - if (rdev->irq.crtc_vblank_int[3]) { 8059 - drm_handle_vblank(rdev->ddev, 3); 8060 - rdev->pm.vblank_sync = true; 8061 - wake_up(&rdev->irq.vblank_queue); 8062 - } 8063 - if (atomic_read(&rdev->irq.pflip[3])) 8064 - radeon_crtc_handle_vblank(rdev, 3); 8065 - rdev->irq.stat_regs.cik.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; 8066 - DRM_DEBUG("IH: D4 vblank\n"); 8045 + if (!(rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT)) 8046 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8047 + 8048 + if (rdev->irq.crtc_vblank_int[3]) { 8049 + drm_handle_vblank(rdev->ddev, 3); 8050 + rdev->pm.vblank_sync = true; 8051 + wake_up(&rdev->irq.vblank_queue); 8067 8052 } 8053 + if (atomic_read(&rdev->irq.pflip[3])) 8054 + radeon_crtc_handle_vblank(rdev, 3); 8055 + rdev->irq.stat_regs.cik.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; 8056 + DRM_DEBUG("IH: D4 vblank\n"); 8057 + 8068 8058 break; 8069 8059 case 1: /* D4 vline */ 8070 - if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) { 8071 - rdev->irq.stat_regs.cik.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; 8072 - DRM_DEBUG("IH: D4 vline\n"); 8073 - } 8060 + if (!(rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VLINE_INTERRUPT)) 8061 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8062 + 8063 + rdev->irq.stat_regs.cik.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; 8064 + DRM_DEBUG("IH: D4 vline\n"); 8065 + 8074 8066 break; 8075 8067 default: 8076 8068 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 8084 8068 case 5: /* D5 vblank/vline */ 8085 8069 switch (src_data) { 8086 8070 case 0: /* D5 vblank */ 8087 - if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) { 8088 - if (rdev->irq.crtc_vblank_int[4]) { 8089 - drm_handle_vblank(rdev->ddev, 4); 8090 - rdev->pm.vblank_sync = true; 8091 - wake_up(&rdev->irq.vblank_queue); 8092 - } 8093 - if (atomic_read(&rdev->irq.pflip[4])) 8094 - radeon_crtc_handle_vblank(rdev, 4); 8095 - rdev->irq.stat_regs.cik.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; 8096 - DRM_DEBUG("IH: D5 vblank\n"); 8071 + if (!(rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT)) 8072 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8073 + 8074 + if (rdev->irq.crtc_vblank_int[4]) { 8075 + drm_handle_vblank(rdev->ddev, 4); 8076 + rdev->pm.vblank_sync = true; 8077 + wake_up(&rdev->irq.vblank_queue); 8097 8078 } 8079 + if (atomic_read(&rdev->irq.pflip[4])) 8080 + radeon_crtc_handle_vblank(rdev, 4); 8081 + rdev->irq.stat_regs.cik.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; 8082 + DRM_DEBUG("IH: D5 vblank\n"); 8083 + 8098 8084 break; 8099 8085 case 1: /* D5 vline */ 8100 - if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) { 8101 - rdev->irq.stat_regs.cik.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; 8102 - DRM_DEBUG("IH: D5 vline\n"); 8103 - } 8086 + if (!(rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VLINE_INTERRUPT)) 8087 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8088 + 8089 + rdev->irq.stat_regs.cik.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; 8090 + DRM_DEBUG("IH: D5 vline\n"); 8091 + 8104 8092 break; 8105 8093 default: 8106 8094 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 8114 8094 case 6: /* D6 vblank/vline */ 8115 8095 switch (src_data) { 8116 8096 case 0: /* D6 vblank */ 8117 - if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) { 8118 - if (rdev->irq.crtc_vblank_int[5]) { 8119 - drm_handle_vblank(rdev->ddev, 5); 8120 - rdev->pm.vblank_sync = true; 8121 - wake_up(&rdev->irq.vblank_queue); 8122 - } 8123 - if (atomic_read(&rdev->irq.pflip[5])) 8124 - radeon_crtc_handle_vblank(rdev, 5); 8125 - rdev->irq.stat_regs.cik.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; 8126 - DRM_DEBUG("IH: D6 vblank\n"); 8097 + if (!(rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT)) 8098 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8099 + 8100 + if (rdev->irq.crtc_vblank_int[5]) { 8101 + drm_handle_vblank(rdev->ddev, 5); 8102 + rdev->pm.vblank_sync = true; 8103 + wake_up(&rdev->irq.vblank_queue); 8127 8104 } 8105 + if (atomic_read(&rdev->irq.pflip[5])) 8106 + radeon_crtc_handle_vblank(rdev, 5); 8107 + rdev->irq.stat_regs.cik.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; 8108 + DRM_DEBUG("IH: D6 vblank\n"); 8109 + 8128 8110 break; 8129 8111 case 1: /* D6 vline */ 8130 - if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) { 8131 - rdev->irq.stat_regs.cik.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; 8132 - DRM_DEBUG("IH: D6 vline\n"); 8133 - } 8112 + if (!(rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VLINE_INTERRUPT)) 8113 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8114 + 8115 + rdev->irq.stat_regs.cik.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; 8116 + DRM_DEBUG("IH: D6 vline\n"); 8117 + 8134 8118 break; 8135 8119 default: 8136 8120 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 8154 8130 case 42: /* HPD hotplug */ 8155 8131 switch (src_data) { 8156 8132 case 0: 8157 - if (rdev->irq.stat_regs.cik.disp_int & DC_HPD1_INTERRUPT) { 8158 - rdev->irq.stat_regs.cik.disp_int &= ~DC_HPD1_INTERRUPT; 8159 - queue_hotplug = true; 8160 - DRM_DEBUG("IH: HPD1\n"); 8161 - } 8133 + if (!(rdev->irq.stat_regs.cik.disp_int & DC_HPD1_INTERRUPT)) 8134 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8135 + 8136 + rdev->irq.stat_regs.cik.disp_int &= ~DC_HPD1_INTERRUPT; 8137 + queue_hotplug = true; 8138 + DRM_DEBUG("IH: HPD1\n"); 8139 + 8162 8140 break; 8163 8141 case 1: 8164 - if (rdev->irq.stat_regs.cik.disp_int_cont & DC_HPD2_INTERRUPT) { 8165 - rdev->irq.stat_regs.cik.disp_int_cont &= ~DC_HPD2_INTERRUPT; 8166 - queue_hotplug = true; 8167 - DRM_DEBUG("IH: HPD2\n"); 8168 - } 8142 + if (!(rdev->irq.stat_regs.cik.disp_int_cont & DC_HPD2_INTERRUPT)) 8143 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8144 + 8145 + rdev->irq.stat_regs.cik.disp_int_cont &= ~DC_HPD2_INTERRUPT; 8146 + queue_hotplug = true; 8147 + DRM_DEBUG("IH: HPD2\n"); 8148 + 8169 8149 break; 8170 8150 case 2: 8171 - if (rdev->irq.stat_regs.cik.disp_int_cont2 & DC_HPD3_INTERRUPT) { 8172 - rdev->irq.stat_regs.cik.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; 8173 - queue_hotplug = true; 8174 - DRM_DEBUG("IH: HPD3\n"); 8175 - } 8151 + if (!(rdev->irq.stat_regs.cik.disp_int_cont2 & DC_HPD3_INTERRUPT)) 8152 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8153 + 8154 + rdev->irq.stat_regs.cik.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; 8155 + queue_hotplug = true; 8156 + DRM_DEBUG("IH: HPD3\n"); 8157 + 8176 8158 break; 8177 8159 case 3: 8178 - if (rdev->irq.stat_regs.cik.disp_int_cont3 & DC_HPD4_INTERRUPT) { 8179 - rdev->irq.stat_regs.cik.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; 8180 - queue_hotplug = true; 8181 - DRM_DEBUG("IH: HPD4\n"); 8182 - } 8160 + if (!(rdev->irq.stat_regs.cik.disp_int_cont3 & DC_HPD4_INTERRUPT)) 8161 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8162 + 8163 + rdev->irq.stat_regs.cik.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; 8164 + queue_hotplug = true; 8165 + DRM_DEBUG("IH: HPD4\n"); 8166 + 8183 8167 break; 8184 8168 case 4: 8185 - if (rdev->irq.stat_regs.cik.disp_int_cont4 & DC_HPD5_INTERRUPT) { 8186 - rdev->irq.stat_regs.cik.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; 8187 - queue_hotplug = true; 8188 - DRM_DEBUG("IH: HPD5\n"); 8189 - } 8169 + if (!(rdev->irq.stat_regs.cik.disp_int_cont4 & DC_HPD5_INTERRUPT)) 8170 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8171 + 8172 + rdev->irq.stat_regs.cik.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; 8173 + queue_hotplug = true; 8174 + DRM_DEBUG("IH: HPD5\n"); 8175 + 8190 8176 break; 8191 8177 case 5: 8192 - if (rdev->irq.stat_regs.cik.disp_int_cont5 & DC_HPD6_INTERRUPT) { 8193 - rdev->irq.stat_regs.cik.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; 8194 - queue_hotplug = true; 8195 - DRM_DEBUG("IH: HPD6\n"); 8196 - } 8178 + if (!(rdev->irq.stat_regs.cik.disp_int_cont5 & DC_HPD6_INTERRUPT)) 8179 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8180 + 8181 + rdev->irq.stat_regs.cik.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; 8182 + queue_hotplug = true; 8183 + DRM_DEBUG("IH: HPD6\n"); 8184 + 8197 8185 break; 8198 8186 case 6: 8199 - if (rdev->irq.stat_regs.cik.disp_int & DC_HPD1_RX_INTERRUPT) { 8200 - rdev->irq.stat_regs.cik.disp_int &= ~DC_HPD1_RX_INTERRUPT; 8201 - queue_dp = true; 8202 - DRM_DEBUG("IH: HPD_RX 1\n"); 8203 - } 8187 + if (!(rdev->irq.stat_regs.cik.disp_int & DC_HPD1_RX_INTERRUPT)) 8188 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8189 + 8190 + rdev->irq.stat_regs.cik.disp_int &= ~DC_HPD1_RX_INTERRUPT; 8191 + queue_dp = true; 8192 + DRM_DEBUG("IH: HPD_RX 1\n"); 8193 + 8204 8194 break; 8205 8195 case 7: 8206 - if (rdev->irq.stat_regs.cik.disp_int_cont & DC_HPD2_RX_INTERRUPT) { 8207 - rdev->irq.stat_regs.cik.disp_int_cont &= ~DC_HPD2_RX_INTERRUPT; 8208 - queue_dp = true; 8209 - DRM_DEBUG("IH: HPD_RX 2\n"); 8210 - } 8196 + if (!(rdev->irq.stat_regs.cik.disp_int_cont & DC_HPD2_RX_INTERRUPT)) 8197 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8198 + 8199 + rdev->irq.stat_regs.cik.disp_int_cont &= ~DC_HPD2_RX_INTERRUPT; 8200 + queue_dp = true; 8201 + DRM_DEBUG("IH: HPD_RX 2\n"); 8202 + 8211 8203 break; 8212 8204 case 8: 8213 - if (rdev->irq.stat_regs.cik.disp_int_cont2 & DC_HPD3_RX_INTERRUPT) { 8214 - rdev->irq.stat_regs.cik.disp_int_cont2 &= ~DC_HPD3_RX_INTERRUPT; 8215 - queue_dp = true; 8216 - DRM_DEBUG("IH: HPD_RX 3\n"); 8217 - } 8205 + if (!(rdev->irq.stat_regs.cik.disp_int_cont2 & DC_HPD3_RX_INTERRUPT)) 8206 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8207 + 8208 + rdev->irq.stat_regs.cik.disp_int_cont2 &= ~DC_HPD3_RX_INTERRUPT; 8209 + queue_dp = true; 8210 + DRM_DEBUG("IH: HPD_RX 3\n"); 8211 + 8218 8212 break; 8219 8213 case 9: 8220 - if (rdev->irq.stat_regs.cik.disp_int_cont3 & DC_HPD4_RX_INTERRUPT) { 8221 - rdev->irq.stat_regs.cik.disp_int_cont3 &= ~DC_HPD4_RX_INTERRUPT; 8222 - queue_dp = true; 8223 - DRM_DEBUG("IH: HPD_RX 4\n"); 8224 - } 8214 + if (!(rdev->irq.stat_regs.cik.disp_int_cont3 & DC_HPD4_RX_INTERRUPT)) 8215 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8216 + 8217 + rdev->irq.stat_regs.cik.disp_int_cont3 &= ~DC_HPD4_RX_INTERRUPT; 8218 + queue_dp = true; 8219 + DRM_DEBUG("IH: HPD_RX 4\n"); 8220 + 8225 8221 break; 8226 8222 case 10: 8227 - if (rdev->irq.stat_regs.cik.disp_int_cont4 & DC_HPD5_RX_INTERRUPT) { 8228 - rdev->irq.stat_regs.cik.disp_int_cont4 &= ~DC_HPD5_RX_INTERRUPT; 8229 - queue_dp = true; 8230 - DRM_DEBUG("IH: HPD_RX 5\n"); 8231 - } 8223 + if (!(rdev->irq.stat_regs.cik.disp_int_cont4 & DC_HPD5_RX_INTERRUPT)) 8224 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8225 + 8226 + rdev->irq.stat_regs.cik.disp_int_cont4 &= ~DC_HPD5_RX_INTERRUPT; 8227 + queue_dp = true; 8228 + DRM_DEBUG("IH: HPD_RX 5\n"); 8229 + 8232 8230 break; 8233 8231 case 11: 8234 - if (rdev->irq.stat_regs.cik.disp_int_cont5 & DC_HPD6_RX_INTERRUPT) { 8235 - rdev->irq.stat_regs.cik.disp_int_cont5 &= ~DC_HPD6_RX_INTERRUPT; 8236 - queue_dp = true; 8237 - DRM_DEBUG("IH: HPD_RX 6\n"); 8238 - } 8232 + if (!(rdev->irq.stat_regs.cik.disp_int_cont5 & DC_HPD6_RX_INTERRUPT)) 8233 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 8234 + 8235 + rdev->irq.stat_regs.cik.disp_int_cont5 &= ~DC_HPD6_RX_INTERRUPT; 8236 + queue_dp = true; 8237 + DRM_DEBUG("IH: HPD_RX 6\n"); 8238 + 8239 8239 break; 8240 8240 default: 8241 8241 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
+217 -175
drivers/gpu/drm/radeon/evergreen.c
··· 4924 4924 return IRQ_NONE; 4925 4925 4926 4926 rptr = rdev->ih.rptr; 4927 - DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr); 4927 + DRM_DEBUG("evergreen_irq_process start: rptr %d, wptr %d\n", rptr, wptr); 4928 4928 4929 4929 /* Order reading of wptr vs. reading of IH ring data */ 4930 4930 rmb(); ··· 4942 4942 case 1: /* D1 vblank/vline */ 4943 4943 switch (src_data) { 4944 4944 case 0: /* D1 vblank */ 4945 - if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT) { 4946 - if (rdev->irq.crtc_vblank_int[0]) { 4947 - drm_handle_vblank(rdev->ddev, 0); 4948 - rdev->pm.vblank_sync = true; 4949 - wake_up(&rdev->irq.vblank_queue); 4950 - } 4951 - if (atomic_read(&rdev->irq.pflip[0])) 4952 - radeon_crtc_handle_vblank(rdev, 0); 4953 - rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VBLANK_INTERRUPT; 4954 - DRM_DEBUG("IH: D1 vblank\n"); 4945 + if (!(rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT)) 4946 + DRM_DEBUG("IH: D1 vblank - IH event w/o asserted irq bit?\n"); 4947 + 4948 + if (rdev->irq.crtc_vblank_int[0]) { 4949 + drm_handle_vblank(rdev->ddev, 0); 4950 + rdev->pm.vblank_sync = true; 4951 + wake_up(&rdev->irq.vblank_queue); 4955 4952 } 4953 + if (atomic_read(&rdev->irq.pflip[0])) 4954 + radeon_crtc_handle_vblank(rdev, 0); 4955 + rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VBLANK_INTERRUPT; 4956 + DRM_DEBUG("IH: D1 vblank\n"); 4957 + 4956 4958 break; 4957 4959 case 1: /* D1 vline */ 4958 - if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT) { 4959 - rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VLINE_INTERRUPT; 4960 - DRM_DEBUG("IH: D1 vline\n"); 4961 - } 4960 + if (!(rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT)) 4961 + DRM_DEBUG("IH: D1 vline - IH event w/o asserted irq bit?\n"); 4962 + 4963 + rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VLINE_INTERRUPT; 4964 + DRM_DEBUG("IH: D1 vline\n"); 4965 + 4962 4966 break; 4963 4967 default: 4964 4968 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 4972 4968 case 2: /* D2 vblank/vline */ 4973 4969 switch (src_data) { 4974 4970 case 0: /* D2 vblank */ 4975 - if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT) { 4976 - if (rdev->irq.crtc_vblank_int[1]) { 4977 - drm_handle_vblank(rdev->ddev, 1); 4978 - rdev->pm.vblank_sync = true; 4979 - wake_up(&rdev->irq.vblank_queue); 4980 - } 4981 - if (atomic_read(&rdev->irq.pflip[1])) 4982 - radeon_crtc_handle_vblank(rdev, 1); 4983 - rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; 4984 - DRM_DEBUG("IH: D2 vblank\n"); 4971 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT)) 4972 + DRM_DEBUG("IH: D2 vblank - IH event w/o asserted irq bit?\n"); 4973 + 4974 + if (rdev->irq.crtc_vblank_int[1]) { 4975 + drm_handle_vblank(rdev->ddev, 1); 4976 + rdev->pm.vblank_sync = true; 4977 + wake_up(&rdev->irq.vblank_queue); 4985 4978 } 4979 + if (atomic_read(&rdev->irq.pflip[1])) 4980 + radeon_crtc_handle_vblank(rdev, 1); 4981 + rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; 4982 + DRM_DEBUG("IH: D2 vblank\n"); 4983 + 4986 4984 break; 4987 4985 case 1: /* D2 vline */ 4988 - if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT) { 4989 - rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; 4990 - DRM_DEBUG("IH: D2 vline\n"); 4991 - } 4986 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT)) 4987 + DRM_DEBUG("IH: D2 vline - IH event w/o asserted irq bit?\n"); 4988 + 4989 + rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; 4990 + DRM_DEBUG("IH: D2 vline\n"); 4991 + 4992 4992 break; 4993 4993 default: 4994 4994 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 5002 4994 case 3: /* D3 vblank/vline */ 5003 4995 switch (src_data) { 5004 4996 case 0: /* D3 vblank */ 5005 - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) { 5006 - if (rdev->irq.crtc_vblank_int[2]) { 5007 - drm_handle_vblank(rdev->ddev, 2); 5008 - rdev->pm.vblank_sync = true; 5009 - wake_up(&rdev->irq.vblank_queue); 5010 - } 5011 - if (atomic_read(&rdev->irq.pflip[2])) 5012 - radeon_crtc_handle_vblank(rdev, 2); 5013 - rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; 5014 - DRM_DEBUG("IH: D3 vblank\n"); 4997 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT)) 4998 + DRM_DEBUG("IH: D3 vblank - IH event w/o asserted irq bit?\n"); 4999 + 5000 + if (rdev->irq.crtc_vblank_int[2]) { 5001 + drm_handle_vblank(rdev->ddev, 2); 5002 + rdev->pm.vblank_sync = true; 5003 + wake_up(&rdev->irq.vblank_queue); 5015 5004 } 5005 + if (atomic_read(&rdev->irq.pflip[2])) 5006 + radeon_crtc_handle_vblank(rdev, 2); 5007 + rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; 5008 + DRM_DEBUG("IH: D3 vblank\n"); 5009 + 5016 5010 break; 5017 5011 case 1: /* D3 vline */ 5018 - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) { 5019 - rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; 5020 - DRM_DEBUG("IH: D3 vline\n"); 5021 - } 5012 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT)) 5013 + DRM_DEBUG("IH: D3 vline - IH event w/o asserted irq bit?\n"); 5014 + 5015 + rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; 5016 + DRM_DEBUG("IH: D3 vline\n"); 5017 + 5022 5018 break; 5023 5019 default: 5024 5020 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 5032 5020 case 4: /* D4 vblank/vline */ 5033 5021 switch (src_data) { 5034 5022 case 0: /* D4 vblank */ 5035 - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) { 5036 - if (rdev->irq.crtc_vblank_int[3]) { 5037 - drm_handle_vblank(rdev->ddev, 3); 5038 - rdev->pm.vblank_sync = true; 5039 - wake_up(&rdev->irq.vblank_queue); 5040 - } 5041 - if (atomic_read(&rdev->irq.pflip[3])) 5042 - radeon_crtc_handle_vblank(rdev, 3); 5043 - rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; 5044 - DRM_DEBUG("IH: D4 vblank\n"); 5023 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT)) 5024 + DRM_DEBUG("IH: D4 vblank - IH event w/o asserted irq bit?\n"); 5025 + 5026 + if (rdev->irq.crtc_vblank_int[3]) { 5027 + drm_handle_vblank(rdev->ddev, 3); 5028 + rdev->pm.vblank_sync = true; 5029 + wake_up(&rdev->irq.vblank_queue); 5045 5030 } 5031 + if (atomic_read(&rdev->irq.pflip[3])) 5032 + radeon_crtc_handle_vblank(rdev, 3); 5033 + rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; 5034 + DRM_DEBUG("IH: D4 vblank\n"); 5035 + 5046 5036 break; 5047 5037 case 1: /* D4 vline */ 5048 - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) { 5049 - rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; 5050 - DRM_DEBUG("IH: D4 vline\n"); 5051 - } 5038 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT)) 5039 + DRM_DEBUG("IH: D4 vline - IH event w/o asserted irq bit?\n"); 5040 + 5041 + rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; 5042 + DRM_DEBUG("IH: D4 vline\n"); 5043 + 5052 5044 break; 5053 5045 default: 5054 5046 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 5062 5046 case 5: /* D5 vblank/vline */ 5063 5047 switch (src_data) { 5064 5048 case 0: /* D5 vblank */ 5065 - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) { 5066 - if (rdev->irq.crtc_vblank_int[4]) { 5067 - drm_handle_vblank(rdev->ddev, 4); 5068 - rdev->pm.vblank_sync = true; 5069 - wake_up(&rdev->irq.vblank_queue); 5070 - } 5071 - if (atomic_read(&rdev->irq.pflip[4])) 5072 - radeon_crtc_handle_vblank(rdev, 4); 5073 - rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; 5074 - DRM_DEBUG("IH: D5 vblank\n"); 5049 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT)) 5050 + DRM_DEBUG("IH: D5 vblank - IH event w/o asserted irq bit?\n"); 5051 + 5052 + if (rdev->irq.crtc_vblank_int[4]) { 5053 + drm_handle_vblank(rdev->ddev, 4); 5054 + rdev->pm.vblank_sync = true; 5055 + wake_up(&rdev->irq.vblank_queue); 5075 5056 } 5057 + if (atomic_read(&rdev->irq.pflip[4])) 5058 + radeon_crtc_handle_vblank(rdev, 4); 5059 + rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; 5060 + DRM_DEBUG("IH: D5 vblank\n"); 5061 + 5076 5062 break; 5077 5063 case 1: /* D5 vline */ 5078 - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) { 5079 - rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; 5080 - DRM_DEBUG("IH: D5 vline\n"); 5081 - } 5064 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT)) 5065 + DRM_DEBUG("IH: D5 vline - IH event w/o asserted irq bit?\n"); 5066 + 5067 + rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; 5068 + DRM_DEBUG("IH: D5 vline\n"); 5069 + 5082 5070 break; 5083 5071 default: 5084 5072 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 5092 5072 case 6: /* D6 vblank/vline */ 5093 5073 switch (src_data) { 5094 5074 case 0: /* D6 vblank */ 5095 - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) { 5096 - if (rdev->irq.crtc_vblank_int[5]) { 5097 - drm_handle_vblank(rdev->ddev, 5); 5098 - rdev->pm.vblank_sync = true; 5099 - wake_up(&rdev->irq.vblank_queue); 5100 - } 5101 - if (atomic_read(&rdev->irq.pflip[5])) 5102 - radeon_crtc_handle_vblank(rdev, 5); 5103 - rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; 5104 - DRM_DEBUG("IH: D6 vblank\n"); 5075 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT)) 5076 + DRM_DEBUG("IH: D6 vblank - IH event w/o asserted irq bit?\n"); 5077 + 5078 + if (rdev->irq.crtc_vblank_int[5]) { 5079 + drm_handle_vblank(rdev->ddev, 5); 5080 + rdev->pm.vblank_sync = true; 5081 + wake_up(&rdev->irq.vblank_queue); 5105 5082 } 5083 + if (atomic_read(&rdev->irq.pflip[5])) 5084 + radeon_crtc_handle_vblank(rdev, 5); 5085 + rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; 5086 + DRM_DEBUG("IH: D6 vblank\n"); 5087 + 5106 5088 break; 5107 5089 case 1: /* D6 vline */ 5108 - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) { 5109 - rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; 5110 - DRM_DEBUG("IH: D6 vline\n"); 5111 - } 5090 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT)) 5091 + DRM_DEBUG("IH: D6 vline - IH event w/o asserted irq bit?\n"); 5092 + 5093 + rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; 5094 + DRM_DEBUG("IH: D6 vline\n"); 5095 + 5112 5096 break; 5113 5097 default: 5114 5098 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 5132 5108 case 42: /* HPD hotplug */ 5133 5109 switch (src_data) { 5134 5110 case 0: 5135 - if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT) { 5136 - rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_INTERRUPT; 5137 - queue_hotplug = true; 5138 - DRM_DEBUG("IH: HPD1\n"); 5139 - } 5111 + if (!(rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT)) 5112 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5113 + 5114 + rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_INTERRUPT; 5115 + queue_hotplug = true; 5116 + DRM_DEBUG("IH: HPD1\n"); 5140 5117 break; 5141 5118 case 1: 5142 - if (rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_INTERRUPT) { 5143 - rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_INTERRUPT; 5144 - queue_hotplug = true; 5145 - DRM_DEBUG("IH: HPD2\n"); 5146 - } 5119 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_INTERRUPT)) 5120 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5121 + 5122 + rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_INTERRUPT; 5123 + queue_hotplug = true; 5124 + DRM_DEBUG("IH: HPD2\n"); 5147 5125 break; 5148 5126 case 2: 5149 - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_INTERRUPT) { 5150 - rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; 5151 - queue_hotplug = true; 5152 - DRM_DEBUG("IH: HPD3\n"); 5153 - } 5127 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_INTERRUPT)) 5128 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5129 + 5130 + rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; 5131 + queue_hotplug = true; 5132 + DRM_DEBUG("IH: HPD3\n"); 5154 5133 break; 5155 5134 case 3: 5156 - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_INTERRUPT) { 5157 - rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; 5158 - queue_hotplug = true; 5159 - DRM_DEBUG("IH: HPD4\n"); 5160 - } 5135 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_INTERRUPT)) 5136 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5137 + 5138 + rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; 5139 + queue_hotplug = true; 5140 + DRM_DEBUG("IH: HPD4\n"); 5161 5141 break; 5162 5142 case 4: 5163 - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_INTERRUPT) { 5164 - rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; 5165 - queue_hotplug = true; 5166 - DRM_DEBUG("IH: HPD5\n"); 5167 - } 5143 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_INTERRUPT)) 5144 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5145 + 5146 + rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; 5147 + queue_hotplug = true; 5148 + DRM_DEBUG("IH: HPD5\n"); 5168 5149 break; 5169 5150 case 5: 5170 - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_INTERRUPT) { 5171 - rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; 5172 - queue_hotplug = true; 5173 - DRM_DEBUG("IH: HPD6\n"); 5174 - } 5151 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_INTERRUPT)) 5152 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5153 + 5154 + rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; 5155 + queue_hotplug = true; 5156 + DRM_DEBUG("IH: HPD6\n"); 5175 5157 break; 5176 5158 case 6: 5177 - if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_RX_INTERRUPT) { 5178 - rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_RX_INTERRUPT; 5179 - queue_dp = true; 5180 - DRM_DEBUG("IH: HPD_RX 1\n"); 5181 - } 5159 + if (!(rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_RX_INTERRUPT)) 5160 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5161 + 5162 + rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_RX_INTERRUPT; 5163 + queue_dp = true; 5164 + DRM_DEBUG("IH: HPD_RX 1\n"); 5182 5165 break; 5183 5166 case 7: 5184 - if (rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_RX_INTERRUPT) { 5185 - rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_RX_INTERRUPT; 5186 - queue_dp = true; 5187 - DRM_DEBUG("IH: HPD_RX 2\n"); 5188 - } 5167 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_RX_INTERRUPT)) 5168 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5169 + 5170 + rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_RX_INTERRUPT; 5171 + queue_dp = true; 5172 + DRM_DEBUG("IH: HPD_RX 2\n"); 5189 5173 break; 5190 5174 case 8: 5191 - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_RX_INTERRUPT) { 5192 - rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_RX_INTERRUPT; 5193 - queue_dp = true; 5194 - DRM_DEBUG("IH: HPD_RX 3\n"); 5195 - } 5175 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_RX_INTERRUPT)) 5176 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5177 + 5178 + rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_RX_INTERRUPT; 5179 + queue_dp = true; 5180 + DRM_DEBUG("IH: HPD_RX 3\n"); 5196 5181 break; 5197 5182 case 9: 5198 - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_RX_INTERRUPT) { 5199 - rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_RX_INTERRUPT; 5200 - queue_dp = true; 5201 - DRM_DEBUG("IH: HPD_RX 4\n"); 5202 - } 5183 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_RX_INTERRUPT)) 5184 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5185 + 5186 + rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_RX_INTERRUPT; 5187 + queue_dp = true; 5188 + DRM_DEBUG("IH: HPD_RX 4\n"); 5203 5189 break; 5204 5190 case 10: 5205 - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_RX_INTERRUPT) { 5206 - rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_RX_INTERRUPT; 5207 - queue_dp = true; 5208 - DRM_DEBUG("IH: HPD_RX 5\n"); 5209 - } 5191 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_RX_INTERRUPT)) 5192 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5193 + 5194 + rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_RX_INTERRUPT; 5195 + queue_dp = true; 5196 + DRM_DEBUG("IH: HPD_RX 5\n"); 5210 5197 break; 5211 5198 case 11: 5212 - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_RX_INTERRUPT) { 5213 - rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_RX_INTERRUPT; 5214 - queue_dp = true; 5215 - DRM_DEBUG("IH: HPD_RX 6\n"); 5216 - } 5199 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_RX_INTERRUPT)) 5200 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5201 + 5202 + rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_RX_INTERRUPT; 5203 + queue_dp = true; 5204 + DRM_DEBUG("IH: HPD_RX 6\n"); 5217 5205 break; 5218 5206 default: 5219 5207 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 5235 5199 case 44: /* hdmi */ 5236 5200 switch (src_data) { 5237 5201 case 0: 5238 - if (rdev->irq.stat_regs.evergreen.afmt_status1 & AFMT_AZ_FORMAT_WTRIG) { 5239 - rdev->irq.stat_regs.evergreen.afmt_status1 &= ~AFMT_AZ_FORMAT_WTRIG; 5240 - queue_hdmi = true; 5241 - DRM_DEBUG("IH: HDMI0\n"); 5242 - } 5202 + if (!(rdev->irq.stat_regs.evergreen.afmt_status1 & AFMT_AZ_FORMAT_WTRIG)) 5203 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5204 + 5205 + rdev->irq.stat_regs.evergreen.afmt_status1 &= ~AFMT_AZ_FORMAT_WTRIG; 5206 + queue_hdmi = true; 5207 + DRM_DEBUG("IH: HDMI0\n"); 5243 5208 break; 5244 5209 case 1: 5245 - if (rdev->irq.stat_regs.evergreen.afmt_status2 & AFMT_AZ_FORMAT_WTRIG) { 5246 - rdev->irq.stat_regs.evergreen.afmt_status2 &= ~AFMT_AZ_FORMAT_WTRIG; 5247 - queue_hdmi = true; 5248 - DRM_DEBUG("IH: HDMI1\n"); 5249 - } 5210 + if (!(rdev->irq.stat_regs.evergreen.afmt_status2 & AFMT_AZ_FORMAT_WTRIG)) 5211 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5212 + 5213 + rdev->irq.stat_regs.evergreen.afmt_status2 &= ~AFMT_AZ_FORMAT_WTRIG; 5214 + queue_hdmi = true; 5215 + DRM_DEBUG("IH: HDMI1\n"); 5250 5216 break; 5251 5217 case 2: 5252 - if (rdev->irq.stat_regs.evergreen.afmt_status3 & AFMT_AZ_FORMAT_WTRIG) { 5253 - rdev->irq.stat_regs.evergreen.afmt_status3 &= ~AFMT_AZ_FORMAT_WTRIG; 5254 - queue_hdmi = true; 5255 - DRM_DEBUG("IH: HDMI2\n"); 5256 - } 5218 + if (!(rdev->irq.stat_regs.evergreen.afmt_status3 & AFMT_AZ_FORMAT_WTRIG)) 5219 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5220 + 5221 + rdev->irq.stat_regs.evergreen.afmt_status3 &= ~AFMT_AZ_FORMAT_WTRIG; 5222 + queue_hdmi = true; 5223 + DRM_DEBUG("IH: HDMI2\n"); 5257 5224 break; 5258 5225 case 3: 5259 - if (rdev->irq.stat_regs.evergreen.afmt_status4 & AFMT_AZ_FORMAT_WTRIG) { 5260 - rdev->irq.stat_regs.evergreen.afmt_status4 &= ~AFMT_AZ_FORMAT_WTRIG; 5261 - queue_hdmi = true; 5262 - DRM_DEBUG("IH: HDMI3\n"); 5263 - } 5226 + if (!(rdev->irq.stat_regs.evergreen.afmt_status4 & AFMT_AZ_FORMAT_WTRIG)) 5227 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5228 + 5229 + rdev->irq.stat_regs.evergreen.afmt_status4 &= ~AFMT_AZ_FORMAT_WTRIG; 5230 + queue_hdmi = true; 5231 + DRM_DEBUG("IH: HDMI3\n"); 5264 5232 break; 5265 5233 case 4: 5266 - if (rdev->irq.stat_regs.evergreen.afmt_status5 & AFMT_AZ_FORMAT_WTRIG) { 5267 - rdev->irq.stat_regs.evergreen.afmt_status5 &= ~AFMT_AZ_FORMAT_WTRIG; 5268 - queue_hdmi = true; 5269 - DRM_DEBUG("IH: HDMI4\n"); 5270 - } 5234 + if (!(rdev->irq.stat_regs.evergreen.afmt_status5 & AFMT_AZ_FORMAT_WTRIG)) 5235 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5236 + 5237 + rdev->irq.stat_regs.evergreen.afmt_status5 &= ~AFMT_AZ_FORMAT_WTRIG; 5238 + queue_hdmi = true; 5239 + DRM_DEBUG("IH: HDMI4\n"); 5271 5240 break; 5272 5241 case 5: 5273 - if (rdev->irq.stat_regs.evergreen.afmt_status6 & AFMT_AZ_FORMAT_WTRIG) { 5274 - rdev->irq.stat_regs.evergreen.afmt_status6 &= ~AFMT_AZ_FORMAT_WTRIG; 5275 - queue_hdmi = true; 5276 - DRM_DEBUG("IH: HDMI5\n"); 5277 - } 5242 + if (!(rdev->irq.stat_regs.evergreen.afmt_status6 & AFMT_AZ_FORMAT_WTRIG)) 5243 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 5244 + 5245 + rdev->irq.stat_regs.evergreen.afmt_status6 &= ~AFMT_AZ_FORMAT_WTRIG; 5246 + queue_hdmi = true; 5247 + DRM_DEBUG("IH: HDMI5\n"); 5278 5248 break; 5279 5249 default: 5280 5250 DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data);
+14 -11
drivers/gpu/drm/radeon/ni.c
··· 2162 2162 DRM_ERROR("radeon: failed initializing UVD (%d).\n", r); 2163 2163 } 2164 2164 2165 - ring = &rdev->ring[TN_RING_TYPE_VCE1_INDEX]; 2166 - if (ring->ring_size) 2167 - r = radeon_ring_init(rdev, ring, ring->ring_size, 0, 0x0); 2165 + if (rdev->family == CHIP_ARUBA) { 2166 + ring = &rdev->ring[TN_RING_TYPE_VCE1_INDEX]; 2167 + if (ring->ring_size) 2168 + r = radeon_ring_init(rdev, ring, ring->ring_size, 0, 0x0); 2168 2169 2169 - ring = &rdev->ring[TN_RING_TYPE_VCE2_INDEX]; 2170 - if (ring->ring_size) 2171 - r = radeon_ring_init(rdev, ring, ring->ring_size, 0, 0x0); 2170 + ring = &rdev->ring[TN_RING_TYPE_VCE2_INDEX]; 2171 + if (ring->ring_size) 2172 + r = radeon_ring_init(rdev, ring, ring->ring_size, 0, 0x0); 2172 2173 2173 - if (!r) 2174 - r = vce_v1_0_init(rdev); 2175 - else if (r != -ENOENT) 2176 - DRM_ERROR("radeon: failed initializing VCE (%d).\n", r); 2174 + if (!r) 2175 + r = vce_v1_0_init(rdev); 2176 + if (r) 2177 + DRM_ERROR("radeon: failed initializing VCE (%d).\n", r); 2178 + } 2177 2179 2178 2180 r = radeon_ib_pool_init(rdev); 2179 2181 if (r) { ··· 2398 2396 radeon_irq_kms_fini(rdev); 2399 2397 uvd_v1_0_fini(rdev); 2400 2398 radeon_uvd_fini(rdev); 2401 - radeon_vce_fini(rdev); 2399 + if (rdev->family == CHIP_ARUBA) 2400 + radeon_vce_fini(rdev); 2402 2401 cayman_pcie_gart_fini(rdev); 2403 2402 r600_vram_scratch_fini(rdev); 2404 2403 radeon_gem_fini(rdev);
+87 -68
drivers/gpu/drm/radeon/r600.c
··· 4086 4086 case 1: /* D1 vblank/vline */ 4087 4087 switch (src_data) { 4088 4088 case 0: /* D1 vblank */ 4089 - if (rdev->irq.stat_regs.r600.disp_int & LB_D1_VBLANK_INTERRUPT) { 4090 - if (rdev->irq.crtc_vblank_int[0]) { 4091 - drm_handle_vblank(rdev->ddev, 0); 4092 - rdev->pm.vblank_sync = true; 4093 - wake_up(&rdev->irq.vblank_queue); 4094 - } 4095 - if (atomic_read(&rdev->irq.pflip[0])) 4096 - radeon_crtc_handle_vblank(rdev, 0); 4097 - rdev->irq.stat_regs.r600.disp_int &= ~LB_D1_VBLANK_INTERRUPT; 4098 - DRM_DEBUG("IH: D1 vblank\n"); 4089 + if (!(rdev->irq.stat_regs.r600.disp_int & LB_D1_VBLANK_INTERRUPT)) 4090 + DRM_DEBUG("IH: D1 vblank - IH event w/o asserted irq bit?\n"); 4091 + 4092 + if (rdev->irq.crtc_vblank_int[0]) { 4093 + drm_handle_vblank(rdev->ddev, 0); 4094 + rdev->pm.vblank_sync = true; 4095 + wake_up(&rdev->irq.vblank_queue); 4099 4096 } 4097 + if (atomic_read(&rdev->irq.pflip[0])) 4098 + radeon_crtc_handle_vblank(rdev, 0); 4099 + rdev->irq.stat_regs.r600.disp_int &= ~LB_D1_VBLANK_INTERRUPT; 4100 + DRM_DEBUG("IH: D1 vblank\n"); 4101 + 4100 4102 break; 4101 4103 case 1: /* D1 vline */ 4102 - if (rdev->irq.stat_regs.r600.disp_int & LB_D1_VLINE_INTERRUPT) { 4103 - rdev->irq.stat_regs.r600.disp_int &= ~LB_D1_VLINE_INTERRUPT; 4104 - DRM_DEBUG("IH: D1 vline\n"); 4105 - } 4104 + if (!(rdev->irq.stat_regs.r600.disp_int & LB_D1_VLINE_INTERRUPT)) 4105 + DRM_DEBUG("IH: D1 vline - IH event w/o asserted irq bit?\n"); 4106 + 4107 + rdev->irq.stat_regs.r600.disp_int &= ~LB_D1_VLINE_INTERRUPT; 4108 + DRM_DEBUG("IH: D1 vline\n"); 4109 + 4106 4110 break; 4107 4111 default: 4108 4112 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 4116 4112 case 5: /* D2 vblank/vline */ 4117 4113 switch (src_data) { 4118 4114 case 0: /* D2 vblank */ 4119 - if (rdev->irq.stat_regs.r600.disp_int & LB_D2_VBLANK_INTERRUPT) { 4120 - if (rdev->irq.crtc_vblank_int[1]) { 4121 - drm_handle_vblank(rdev->ddev, 1); 4122 - rdev->pm.vblank_sync = true; 4123 - wake_up(&rdev->irq.vblank_queue); 4124 - } 4125 - if (atomic_read(&rdev->irq.pflip[1])) 4126 - radeon_crtc_handle_vblank(rdev, 1); 4127 - rdev->irq.stat_regs.r600.disp_int &= ~LB_D2_VBLANK_INTERRUPT; 4128 - DRM_DEBUG("IH: D2 vblank\n"); 4115 + if (!(rdev->irq.stat_regs.r600.disp_int & LB_D2_VBLANK_INTERRUPT)) 4116 + DRM_DEBUG("IH: D2 vblank - IH event w/o asserted irq bit?\n"); 4117 + 4118 + if (rdev->irq.crtc_vblank_int[1]) { 4119 + drm_handle_vblank(rdev->ddev, 1); 4120 + rdev->pm.vblank_sync = true; 4121 + wake_up(&rdev->irq.vblank_queue); 4129 4122 } 4123 + if (atomic_read(&rdev->irq.pflip[1])) 4124 + radeon_crtc_handle_vblank(rdev, 1); 4125 + rdev->irq.stat_regs.r600.disp_int &= ~LB_D2_VBLANK_INTERRUPT; 4126 + DRM_DEBUG("IH: D2 vblank\n"); 4127 + 4130 4128 break; 4131 4129 case 1: /* D1 vline */ 4132 - if (rdev->irq.stat_regs.r600.disp_int & LB_D2_VLINE_INTERRUPT) { 4133 - rdev->irq.stat_regs.r600.disp_int &= ~LB_D2_VLINE_INTERRUPT; 4134 - DRM_DEBUG("IH: D2 vline\n"); 4135 - } 4130 + if (!(rdev->irq.stat_regs.r600.disp_int & LB_D2_VLINE_INTERRUPT)) 4131 + DRM_DEBUG("IH: D2 vline - IH event w/o asserted irq bit?\n"); 4132 + 4133 + rdev->irq.stat_regs.r600.disp_int &= ~LB_D2_VLINE_INTERRUPT; 4134 + DRM_DEBUG("IH: D2 vline\n"); 4135 + 4136 4136 break; 4137 4137 default: 4138 4138 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 4156 4148 case 19: /* HPD/DAC hotplug */ 4157 4149 switch (src_data) { 4158 4150 case 0: 4159 - if (rdev->irq.stat_regs.r600.disp_int & DC_HPD1_INTERRUPT) { 4160 - rdev->irq.stat_regs.r600.disp_int &= ~DC_HPD1_INTERRUPT; 4161 - queue_hotplug = true; 4162 - DRM_DEBUG("IH: HPD1\n"); 4163 - } 4151 + if (!(rdev->irq.stat_regs.r600.disp_int & DC_HPD1_INTERRUPT)) 4152 + DRM_DEBUG("IH: HPD1 - IH event w/o asserted irq bit?\n"); 4153 + 4154 + rdev->irq.stat_regs.r600.disp_int &= ~DC_HPD1_INTERRUPT; 4155 + queue_hotplug = true; 4156 + DRM_DEBUG("IH: HPD1\n"); 4164 4157 break; 4165 4158 case 1: 4166 - if (rdev->irq.stat_regs.r600.disp_int & DC_HPD2_INTERRUPT) { 4167 - rdev->irq.stat_regs.r600.disp_int &= ~DC_HPD2_INTERRUPT; 4168 - queue_hotplug = true; 4169 - DRM_DEBUG("IH: HPD2\n"); 4170 - } 4159 + if (!(rdev->irq.stat_regs.r600.disp_int & DC_HPD2_INTERRUPT)) 4160 + DRM_DEBUG("IH: HPD2 - IH event w/o asserted irq bit?\n"); 4161 + 4162 + rdev->irq.stat_regs.r600.disp_int &= ~DC_HPD2_INTERRUPT; 4163 + queue_hotplug = true; 4164 + DRM_DEBUG("IH: HPD2\n"); 4171 4165 break; 4172 4166 case 4: 4173 - if (rdev->irq.stat_regs.r600.disp_int_cont & DC_HPD3_INTERRUPT) { 4174 - rdev->irq.stat_regs.r600.disp_int_cont &= ~DC_HPD3_INTERRUPT; 4175 - queue_hotplug = true; 4176 - DRM_DEBUG("IH: HPD3\n"); 4177 - } 4167 + if (!(rdev->irq.stat_regs.r600.disp_int_cont & DC_HPD3_INTERRUPT)) 4168 + DRM_DEBUG("IH: HPD3 - IH event w/o asserted irq bit?\n"); 4169 + 4170 + rdev->irq.stat_regs.r600.disp_int_cont &= ~DC_HPD3_INTERRUPT; 4171 + queue_hotplug = true; 4172 + DRM_DEBUG("IH: HPD3\n"); 4178 4173 break; 4179 4174 case 5: 4180 - if (rdev->irq.stat_regs.r600.disp_int_cont & DC_HPD4_INTERRUPT) { 4181 - rdev->irq.stat_regs.r600.disp_int_cont &= ~DC_HPD4_INTERRUPT; 4182 - queue_hotplug = true; 4183 - DRM_DEBUG("IH: HPD4\n"); 4184 - } 4175 + if (!(rdev->irq.stat_regs.r600.disp_int_cont & DC_HPD4_INTERRUPT)) 4176 + DRM_DEBUG("IH: HPD4 - IH event w/o asserted irq bit?\n"); 4177 + 4178 + rdev->irq.stat_regs.r600.disp_int_cont &= ~DC_HPD4_INTERRUPT; 4179 + queue_hotplug = true; 4180 + DRM_DEBUG("IH: HPD4\n"); 4185 4181 break; 4186 4182 case 10: 4187 - if (rdev->irq.stat_regs.r600.disp_int_cont2 & DC_HPD5_INTERRUPT) { 4188 - rdev->irq.stat_regs.r600.disp_int_cont2 &= ~DC_HPD5_INTERRUPT; 4189 - queue_hotplug = true; 4190 - DRM_DEBUG("IH: HPD5\n"); 4191 - } 4183 + if (!(rdev->irq.stat_regs.r600.disp_int_cont2 & DC_HPD5_INTERRUPT)) 4184 + DRM_DEBUG("IH: HPD5 - IH event w/o asserted irq bit?\n"); 4185 + 4186 + rdev->irq.stat_regs.r600.disp_int_cont2 &= ~DC_HPD5_INTERRUPT; 4187 + queue_hotplug = true; 4188 + DRM_DEBUG("IH: HPD5\n"); 4192 4189 break; 4193 4190 case 12: 4194 - if (rdev->irq.stat_regs.r600.disp_int_cont2 & DC_HPD6_INTERRUPT) { 4195 - rdev->irq.stat_regs.r600.disp_int_cont2 &= ~DC_HPD6_INTERRUPT; 4196 - queue_hotplug = true; 4197 - DRM_DEBUG("IH: HPD6\n"); 4198 - } 4191 + if (!(rdev->irq.stat_regs.r600.disp_int_cont2 & DC_HPD6_INTERRUPT)) 4192 + DRM_DEBUG("IH: HPD6 - IH event w/o asserted irq bit?\n"); 4193 + 4194 + rdev->irq.stat_regs.r600.disp_int_cont2 &= ~DC_HPD6_INTERRUPT; 4195 + queue_hotplug = true; 4196 + DRM_DEBUG("IH: HPD6\n"); 4197 + 4199 4198 break; 4200 4199 default: 4201 4200 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 4212 4197 case 21: /* hdmi */ 4213 4198 switch (src_data) { 4214 4199 case 4: 4215 - if (rdev->irq.stat_regs.r600.hdmi0_status & HDMI0_AZ_FORMAT_WTRIG) { 4216 - rdev->irq.stat_regs.r600.hdmi0_status &= ~HDMI0_AZ_FORMAT_WTRIG; 4217 - queue_hdmi = true; 4218 - DRM_DEBUG("IH: HDMI0\n"); 4219 - } 4200 + if (!(rdev->irq.stat_regs.r600.hdmi0_status & HDMI0_AZ_FORMAT_WTRIG)) 4201 + DRM_DEBUG("IH: HDMI0 - IH event w/o asserted irq bit?\n"); 4202 + 4203 + rdev->irq.stat_regs.r600.hdmi0_status &= ~HDMI0_AZ_FORMAT_WTRIG; 4204 + queue_hdmi = true; 4205 + DRM_DEBUG("IH: HDMI0\n"); 4206 + 4220 4207 break; 4221 4208 case 5: 4222 - if (rdev->irq.stat_regs.r600.hdmi1_status & HDMI0_AZ_FORMAT_WTRIG) { 4223 - rdev->irq.stat_regs.r600.hdmi1_status &= ~HDMI0_AZ_FORMAT_WTRIG; 4224 - queue_hdmi = true; 4225 - DRM_DEBUG("IH: HDMI1\n"); 4226 - } 4209 + if (!(rdev->irq.stat_regs.r600.hdmi1_status & HDMI0_AZ_FORMAT_WTRIG)) 4210 + DRM_DEBUG("IH: HDMI1 - IH event w/o asserted irq bit?\n"); 4211 + 4212 + rdev->irq.stat_regs.r600.hdmi1_status &= ~HDMI0_AZ_FORMAT_WTRIG; 4213 + queue_hdmi = true; 4214 + DRM_DEBUG("IH: HDMI1\n"); 4215 + 4227 4216 break; 4228 4217 default: 4229 4218 DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data);
+1 -1
drivers/gpu/drm/radeon/r600_cp.c
··· 2483 2483 struct drm_buf *buf; 2484 2484 u32 *buffer; 2485 2485 const u8 __user *data; 2486 - int size, pass_size; 2486 + unsigned int size, pass_size; 2487 2487 u64 src_offset, dst_offset; 2488 2488 2489 2489 if (!radeon_check_offset(dev_priv, tex->offset)) {
+44 -65
drivers/gpu/drm/radeon/radeon_cursor.c
··· 91 91 struct radeon_device *rdev = crtc->dev->dev_private; 92 92 93 93 if (ASIC_IS_DCE4(rdev)) { 94 + WREG32(EVERGREEN_CUR_SURFACE_ADDRESS_HIGH + radeon_crtc->crtc_offset, 95 + upper_32_bits(radeon_crtc->cursor_addr)); 96 + WREG32(EVERGREEN_CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, 97 + lower_32_bits(radeon_crtc->cursor_addr)); 94 98 WREG32(RADEON_MM_INDEX, EVERGREEN_CUR_CONTROL + radeon_crtc->crtc_offset); 95 99 WREG32(RADEON_MM_DATA, EVERGREEN_CURSOR_EN | 96 100 EVERGREEN_CURSOR_MODE(EVERGREEN_CURSOR_24_8_PRE_MULT) | 97 101 EVERGREEN_CURSOR_URGENT_CONTROL(EVERGREEN_CURSOR_URGENT_1_2)); 98 102 } else if (ASIC_IS_AVIVO(rdev)) { 103 + if (rdev->family >= CHIP_RV770) { 104 + if (radeon_crtc->crtc_id) 105 + WREG32(R700_D2CUR_SURFACE_ADDRESS_HIGH, 106 + upper_32_bits(radeon_crtc->cursor_addr)); 107 + else 108 + WREG32(R700_D1CUR_SURFACE_ADDRESS_HIGH, 109 + upper_32_bits(radeon_crtc->cursor_addr)); 110 + } 111 + 112 + WREG32(AVIVO_D1CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, 113 + lower_32_bits(radeon_crtc->cursor_addr)); 99 114 WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL + radeon_crtc->crtc_offset); 100 115 WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN | 101 116 (AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT)); 102 117 } else { 118 + /* offset is from DISP(2)_BASE_ADDRESS */ 119 + WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, 120 + radeon_crtc->cursor_addr - radeon_crtc->legacy_display_base_addr); 121 + 103 122 switch (radeon_crtc->crtc_id) { 104 123 case 0: 105 124 WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL); ··· 224 205 | (x << 16) 225 206 | y)); 226 207 /* offset is from DISP(2)_BASE_ADDRESS */ 227 - WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, (radeon_crtc->legacy_cursor_offset + 228 - (yorigin * 256))); 208 + WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, 209 + radeon_crtc->cursor_addr - radeon_crtc->legacy_display_base_addr + 210 + yorigin * 256); 229 211 } 230 212 231 213 radeon_crtc->cursor_x = x; ··· 247 227 return ret; 248 228 } 249 229 250 - static int radeon_set_cursor(struct drm_crtc *crtc, struct drm_gem_object *obj) 251 - { 252 - struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 253 - struct radeon_device *rdev = crtc->dev->dev_private; 254 - struct radeon_bo *robj = gem_to_radeon_bo(obj); 255 - uint64_t gpu_addr; 256 - int ret; 257 - 258 - ret = radeon_bo_reserve(robj, false); 259 - if (unlikely(ret != 0)) 260 - goto fail; 261 - /* Only 27 bit offset for legacy cursor */ 262 - ret = radeon_bo_pin_restricted(robj, RADEON_GEM_DOMAIN_VRAM, 263 - ASIC_IS_AVIVO(rdev) ? 0 : 1 << 27, 264 - &gpu_addr); 265 - radeon_bo_unreserve(robj); 266 - if (ret) 267 - goto fail; 268 - 269 - if (ASIC_IS_DCE4(rdev)) { 270 - WREG32(EVERGREEN_CUR_SURFACE_ADDRESS_HIGH + radeon_crtc->crtc_offset, 271 - upper_32_bits(gpu_addr)); 272 - WREG32(EVERGREEN_CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, 273 - gpu_addr & 0xffffffff); 274 - } else if (ASIC_IS_AVIVO(rdev)) { 275 - if (rdev->family >= CHIP_RV770) { 276 - if (radeon_crtc->crtc_id) 277 - WREG32(R700_D2CUR_SURFACE_ADDRESS_HIGH, upper_32_bits(gpu_addr)); 278 - else 279 - WREG32(R700_D1CUR_SURFACE_ADDRESS_HIGH, upper_32_bits(gpu_addr)); 280 - } 281 - WREG32(AVIVO_D1CUR_SURFACE_ADDRESS + radeon_crtc->crtc_offset, 282 - gpu_addr & 0xffffffff); 283 - } else { 284 - radeon_crtc->legacy_cursor_offset = gpu_addr - radeon_crtc->legacy_display_base_addr; 285 - /* offset is from DISP(2)_BASE_ADDRESS */ 286 - WREG32(RADEON_CUR_OFFSET + radeon_crtc->crtc_offset, radeon_crtc->legacy_cursor_offset); 287 - } 288 - 289 - return 0; 290 - 291 - fail: 292 - drm_gem_object_unreference_unlocked(obj); 293 - 294 - return ret; 295 - } 296 - 297 230 int radeon_crtc_cursor_set2(struct drm_crtc *crtc, 298 231 struct drm_file *file_priv, 299 232 uint32_t handle, ··· 256 283 int32_t hot_y) 257 284 { 258 285 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 286 + struct radeon_device *rdev = crtc->dev->dev_private; 259 287 struct drm_gem_object *obj; 288 + struct radeon_bo *robj; 260 289 int ret; 261 290 262 291 if (!handle) { ··· 280 305 return -ENOENT; 281 306 } 282 307 308 + robj = gem_to_radeon_bo(obj); 309 + ret = radeon_bo_reserve(robj, false); 310 + if (ret != 0) { 311 + drm_gem_object_unreference_unlocked(obj); 312 + return ret; 313 + } 314 + /* Only 27 bit offset for legacy cursor */ 315 + ret = radeon_bo_pin_restricted(robj, RADEON_GEM_DOMAIN_VRAM, 316 + ASIC_IS_AVIVO(rdev) ? 0 : 1 << 27, 317 + &radeon_crtc->cursor_addr); 318 + radeon_bo_unreserve(robj); 319 + if (ret) { 320 + DRM_ERROR("Failed to pin new cursor BO (%d)\n", ret); 321 + drm_gem_object_unreference_unlocked(obj); 322 + return ret; 323 + } 324 + 283 325 radeon_crtc->cursor_width = width; 284 326 radeon_crtc->cursor_height = height; 285 327 ··· 315 323 radeon_crtc->cursor_hot_y = hot_y; 316 324 } 317 325 318 - ret = radeon_set_cursor(crtc, obj); 319 - 320 - if (ret) 321 - DRM_ERROR("radeon_set_cursor returned %d, not changing cursor\n", 322 - ret); 323 - else 324 - radeon_show_cursor(crtc); 326 + radeon_show_cursor(crtc); 325 327 326 328 radeon_lock_cursor(crtc, false); 327 329 ··· 327 341 radeon_bo_unpin(robj); 328 342 radeon_bo_unreserve(robj); 329 343 } 330 - if (radeon_crtc->cursor_bo != obj) 331 - drm_gem_object_unreference_unlocked(radeon_crtc->cursor_bo); 344 + drm_gem_object_unreference_unlocked(radeon_crtc->cursor_bo); 332 345 } 333 346 334 347 radeon_crtc->cursor_bo = obj; ··· 345 360 void radeon_cursor_reset(struct drm_crtc *crtc) 346 361 { 347 362 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 348 - int ret; 349 363 350 364 if (radeon_crtc->cursor_bo) { 351 365 radeon_lock_cursor(crtc, true); ··· 352 368 radeon_cursor_move_locked(crtc, radeon_crtc->cursor_x, 353 369 radeon_crtc->cursor_y); 354 370 355 - ret = radeon_set_cursor(crtc, radeon_crtc->cursor_bo); 356 - if (ret) 357 - DRM_ERROR("radeon_set_cursor returned %d, not showing " 358 - "cursor\n", ret); 359 - else 360 - radeon_show_cursor(crtc); 371 + radeon_show_cursor(crtc); 361 372 362 373 radeon_lock_cursor(crtc, false); 363 374 }
+52 -14
drivers/gpu/drm/radeon/radeon_device.c
··· 1080 1080 } 1081 1081 1082 1082 /** 1083 + * Determine a sensible default GART size according to ASIC family. 1084 + * 1085 + * @family ASIC family name 1086 + */ 1087 + static int radeon_gart_size_auto(enum radeon_family family) 1088 + { 1089 + /* default to a larger gart size on newer asics */ 1090 + if (family >= CHIP_TAHITI) 1091 + return 2048; 1092 + else if (family >= CHIP_RV770) 1093 + return 1024; 1094 + else 1095 + return 512; 1096 + } 1097 + 1098 + /** 1083 1099 * radeon_check_arguments - validate module params 1084 1100 * 1085 1101 * @rdev: radeon_device pointer ··· 1113 1097 } 1114 1098 1115 1099 if (radeon_gart_size == -1) { 1116 - /* default to a larger gart size on newer asics */ 1117 - if (rdev->family >= CHIP_RV770) 1118 - radeon_gart_size = 1024; 1119 - else 1120 - radeon_gart_size = 512; 1100 + radeon_gart_size = radeon_gart_size_auto(rdev->family); 1121 1101 } 1122 1102 /* gtt size must be power of two and greater or equal to 32M */ 1123 1103 if (radeon_gart_size < 32) { 1124 1104 dev_warn(rdev->dev, "gart size (%d) too small\n", 1125 1105 radeon_gart_size); 1126 - if (rdev->family >= CHIP_RV770) 1127 - radeon_gart_size = 1024; 1128 - else 1129 - radeon_gart_size = 512; 1106 + radeon_gart_size = radeon_gart_size_auto(rdev->family); 1130 1107 } else if (!radeon_check_pot_argument(radeon_gart_size)) { 1131 1108 dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n", 1132 1109 radeon_gart_size); 1133 - if (rdev->family >= CHIP_RV770) 1134 - radeon_gart_size = 1024; 1135 - else 1136 - radeon_gart_size = 512; 1110 + radeon_gart_size = radeon_gart_size_auto(rdev->family); 1137 1111 } 1138 1112 rdev->mc.gtt_size = (uint64_t)radeon_gart_size << 20; 1139 1113 ··· 1578 1572 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 1579 1573 } 1580 1574 1581 - /* unpin the front buffers */ 1575 + /* unpin the front buffers and cursors */ 1582 1576 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 1577 + struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 1583 1578 struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->primary->fb); 1584 1579 struct radeon_bo *robj; 1580 + 1581 + if (radeon_crtc->cursor_bo) { 1582 + struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo); 1583 + r = radeon_bo_reserve(robj, false); 1584 + if (r == 0) { 1585 + radeon_bo_unpin(robj); 1586 + radeon_bo_unreserve(robj); 1587 + } 1588 + } 1585 1589 1586 1590 if (rfb == NULL || rfb->obj == NULL) { 1587 1591 continue; ··· 1655 1639 { 1656 1640 struct drm_connector *connector; 1657 1641 struct radeon_device *rdev = dev->dev_private; 1642 + struct drm_crtc *crtc; 1658 1643 int r; 1659 1644 1660 1645 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) ··· 1694 1677 } 1695 1678 1696 1679 radeon_restore_bios_scratch_regs(rdev); 1680 + 1681 + /* pin cursors */ 1682 + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 1683 + struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 1684 + 1685 + if (radeon_crtc->cursor_bo) { 1686 + struct radeon_bo *robj = gem_to_radeon_bo(radeon_crtc->cursor_bo); 1687 + r = radeon_bo_reserve(robj, false); 1688 + if (r == 0) { 1689 + /* Only 27 bit offset for legacy cursor */ 1690 + r = radeon_bo_pin_restricted(robj, 1691 + RADEON_GEM_DOMAIN_VRAM, 1692 + ASIC_IS_AVIVO(rdev) ? 1693 + 0 : 1 << 27, 1694 + &radeon_crtc->cursor_addr); 1695 + if (r != 0) 1696 + DRM_ERROR("Failed to pin cursor BO (%d)\n", r); 1697 + radeon_bo_unreserve(robj); 1698 + } 1699 + } 1700 + } 1697 1701 1698 1702 /* init dig PHYs, disp eng pll */ 1699 1703 if (rdev->is_atom_bios) {
+1
drivers/gpu/drm/radeon/radeon_fb.c
··· 257 257 } 258 258 259 259 info->par = rfbdev; 260 + info->skip_vt_switch = true; 260 261 261 262 ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->rfb, &mode_cmd, gobj); 262 263 if (ret) {
+9 -3
drivers/gpu/drm/radeon/radeon_gem.c
··· 428 428 int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, 429 429 struct drm_file *filp) 430 430 { 431 - struct radeon_device *rdev = dev->dev_private; 432 431 struct drm_radeon_gem_busy *args = data; 433 432 struct drm_gem_object *gobj; 434 433 struct radeon_bo *robj; ··· 439 440 return -ENOENT; 440 441 } 441 442 robj = gem_to_radeon_bo(gobj); 442 - r = radeon_bo_wait(robj, &cur_placement, true); 443 + 444 + r = reservation_object_test_signaled_rcu(robj->tbo.resv, true); 445 + if (r == 0) 446 + r = -EBUSY; 447 + else 448 + r = 0; 449 + 450 + cur_placement = ACCESS_ONCE(robj->tbo.mem.mem_type); 443 451 args->domain = radeon_mem_type_to_domain(cur_placement); 444 452 drm_gem_object_unreference_unlocked(gobj); 445 - r = radeon_gem_handle_lockup(rdev, r); 446 453 return r; 447 454 } 448 455 ··· 476 471 r = ret; 477 472 478 473 /* Flush HDP cache via MMIO if necessary */ 474 + cur_placement = ACCESS_ONCE(robj->tbo.mem.mem_type); 479 475 if (rdev->asic->mmio_hdp_flush && 480 476 radeon_mem_type_to_domain(cur_placement) == RADEON_GEM_DOMAIN_VRAM) 481 477 robj->rdev->asic->mmio_hdp_flush(rdev);
-1
drivers/gpu/drm/radeon/radeon_mode.h
··· 343 343 int max_cursor_width; 344 344 int max_cursor_height; 345 345 uint32_t legacy_display_base_addr; 346 - uint32_t legacy_cursor_offset; 347 346 enum radeon_rmx_type rmx_type; 348 347 u8 h_border; 349 348 u8 v_border;
+19 -21
drivers/gpu/drm/radeon/radeon_vm.c
··· 493 493 } 494 494 495 495 if (bo_va->it.start || bo_va->it.last) { 496 - spin_lock(&vm->status_lock); 497 - if (list_empty(&bo_va->vm_status)) { 498 - /* add a clone of the bo_va to clear the old address */ 499 - struct radeon_bo_va *tmp; 500 - spin_unlock(&vm->status_lock); 501 - tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL); 502 - if (!tmp) { 503 - mutex_unlock(&vm->mutex); 504 - r = -ENOMEM; 505 - goto error_unreserve; 506 - } 507 - tmp->it.start = bo_va->it.start; 508 - tmp->it.last = bo_va->it.last; 509 - tmp->vm = vm; 510 - tmp->bo = radeon_bo_ref(bo_va->bo); 511 - spin_lock(&vm->status_lock); 512 - list_add(&tmp->vm_status, &vm->freed); 496 + /* add a clone of the bo_va to clear the old address */ 497 + struct radeon_bo_va *tmp; 498 + tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL); 499 + if (!tmp) { 500 + mutex_unlock(&vm->mutex); 501 + r = -ENOMEM; 502 + goto error_unreserve; 513 503 } 514 - spin_unlock(&vm->status_lock); 504 + tmp->it.start = bo_va->it.start; 505 + tmp->it.last = bo_va->it.last; 506 + tmp->vm = vm; 507 + tmp->bo = radeon_bo_ref(bo_va->bo); 515 508 516 509 interval_tree_remove(&bo_va->it, &vm->va); 510 + spin_lock(&vm->status_lock); 517 511 bo_va->it.start = 0; 518 512 bo_va->it.last = 0; 513 + list_del_init(&bo_va->vm_status); 514 + list_add(&tmp->vm_status, &vm->freed); 515 + spin_unlock(&vm->status_lock); 519 516 } 520 517 521 518 if (soffset || eoffset) { 519 + spin_lock(&vm->status_lock); 522 520 bo_va->it.start = soffset; 523 521 bo_va->it.last = eoffset - 1; 524 - interval_tree_insert(&bo_va->it, &vm->va); 525 - spin_lock(&vm->status_lock); 526 522 list_add(&bo_va->vm_status, &vm->cleared); 527 523 spin_unlock(&vm->status_lock); 524 + interval_tree_insert(&bo_va->it, &vm->va); 528 525 } 529 526 530 527 bo_va->flags = flags; ··· 1155 1158 1156 1159 list_for_each_entry(bo_va, &bo->va, bo_list) { 1157 1160 spin_lock(&bo_va->vm->status_lock); 1158 - if (list_empty(&bo_va->vm_status)) 1161 + if (list_empty(&bo_va->vm_status) && 1162 + (bo_va->it.start || bo_va->it.last)) 1159 1163 list_add(&bo_va->vm_status, &bo_va->vm->invalidated); 1160 1164 spin_unlock(&bo_va->vm->status_lock); 1161 1165 }
+192 -144
drivers/gpu/drm/radeon/si.c
··· 6466 6466 case 1: /* D1 vblank/vline */ 6467 6467 switch (src_data) { 6468 6468 case 0: /* D1 vblank */ 6469 - if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT) { 6470 - if (rdev->irq.crtc_vblank_int[0]) { 6471 - drm_handle_vblank(rdev->ddev, 0); 6472 - rdev->pm.vblank_sync = true; 6473 - wake_up(&rdev->irq.vblank_queue); 6474 - } 6475 - if (atomic_read(&rdev->irq.pflip[0])) 6476 - radeon_crtc_handle_vblank(rdev, 0); 6477 - rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VBLANK_INTERRUPT; 6478 - DRM_DEBUG("IH: D1 vblank\n"); 6469 + if (!(rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT)) 6470 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6471 + 6472 + if (rdev->irq.crtc_vblank_int[0]) { 6473 + drm_handle_vblank(rdev->ddev, 0); 6474 + rdev->pm.vblank_sync = true; 6475 + wake_up(&rdev->irq.vblank_queue); 6479 6476 } 6477 + if (atomic_read(&rdev->irq.pflip[0])) 6478 + radeon_crtc_handle_vblank(rdev, 0); 6479 + rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VBLANK_INTERRUPT; 6480 + DRM_DEBUG("IH: D1 vblank\n"); 6481 + 6480 6482 break; 6481 6483 case 1: /* D1 vline */ 6482 - if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT) { 6483 - rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VLINE_INTERRUPT; 6484 - DRM_DEBUG("IH: D1 vline\n"); 6485 - } 6484 + if (!(rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT)) 6485 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6486 + 6487 + rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VLINE_INTERRUPT; 6488 + DRM_DEBUG("IH: D1 vline\n"); 6489 + 6486 6490 break; 6487 6491 default: 6488 6492 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 6496 6492 case 2: /* D2 vblank/vline */ 6497 6493 switch (src_data) { 6498 6494 case 0: /* D2 vblank */ 6499 - if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT) { 6500 - if (rdev->irq.crtc_vblank_int[1]) { 6501 - drm_handle_vblank(rdev->ddev, 1); 6502 - rdev->pm.vblank_sync = true; 6503 - wake_up(&rdev->irq.vblank_queue); 6504 - } 6505 - if (atomic_read(&rdev->irq.pflip[1])) 6506 - radeon_crtc_handle_vblank(rdev, 1); 6507 - rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; 6508 - DRM_DEBUG("IH: D2 vblank\n"); 6495 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT)) 6496 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6497 + 6498 + if (rdev->irq.crtc_vblank_int[1]) { 6499 + drm_handle_vblank(rdev->ddev, 1); 6500 + rdev->pm.vblank_sync = true; 6501 + wake_up(&rdev->irq.vblank_queue); 6509 6502 } 6503 + if (atomic_read(&rdev->irq.pflip[1])) 6504 + radeon_crtc_handle_vblank(rdev, 1); 6505 + rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; 6506 + DRM_DEBUG("IH: D2 vblank\n"); 6507 + 6510 6508 break; 6511 6509 case 1: /* D2 vline */ 6512 - if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT) { 6513 - rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; 6514 - DRM_DEBUG("IH: D2 vline\n"); 6515 - } 6510 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT)) 6511 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6512 + 6513 + rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; 6514 + DRM_DEBUG("IH: D2 vline\n"); 6515 + 6516 6516 break; 6517 6517 default: 6518 6518 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 6526 6518 case 3: /* D3 vblank/vline */ 6527 6519 switch (src_data) { 6528 6520 case 0: /* D3 vblank */ 6529 - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) { 6530 - if (rdev->irq.crtc_vblank_int[2]) { 6531 - drm_handle_vblank(rdev->ddev, 2); 6532 - rdev->pm.vblank_sync = true; 6533 - wake_up(&rdev->irq.vblank_queue); 6534 - } 6535 - if (atomic_read(&rdev->irq.pflip[2])) 6536 - radeon_crtc_handle_vblank(rdev, 2); 6537 - rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; 6538 - DRM_DEBUG("IH: D3 vblank\n"); 6521 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT)) 6522 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6523 + 6524 + if (rdev->irq.crtc_vblank_int[2]) { 6525 + drm_handle_vblank(rdev->ddev, 2); 6526 + rdev->pm.vblank_sync = true; 6527 + wake_up(&rdev->irq.vblank_queue); 6539 6528 } 6529 + if (atomic_read(&rdev->irq.pflip[2])) 6530 + radeon_crtc_handle_vblank(rdev, 2); 6531 + rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; 6532 + DRM_DEBUG("IH: D3 vblank\n"); 6533 + 6540 6534 break; 6541 6535 case 1: /* D3 vline */ 6542 - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) { 6543 - rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; 6544 - DRM_DEBUG("IH: D3 vline\n"); 6545 - } 6536 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT)) 6537 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6538 + 6539 + rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; 6540 + DRM_DEBUG("IH: D3 vline\n"); 6541 + 6546 6542 break; 6547 6543 default: 6548 6544 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 6556 6544 case 4: /* D4 vblank/vline */ 6557 6545 switch (src_data) { 6558 6546 case 0: /* D4 vblank */ 6559 - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) { 6560 - if (rdev->irq.crtc_vblank_int[3]) { 6561 - drm_handle_vblank(rdev->ddev, 3); 6562 - rdev->pm.vblank_sync = true; 6563 - wake_up(&rdev->irq.vblank_queue); 6564 - } 6565 - if (atomic_read(&rdev->irq.pflip[3])) 6566 - radeon_crtc_handle_vblank(rdev, 3); 6567 - rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; 6568 - DRM_DEBUG("IH: D4 vblank\n"); 6547 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT)) 6548 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6549 + 6550 + if (rdev->irq.crtc_vblank_int[3]) { 6551 + drm_handle_vblank(rdev->ddev, 3); 6552 + rdev->pm.vblank_sync = true; 6553 + wake_up(&rdev->irq.vblank_queue); 6569 6554 } 6555 + if (atomic_read(&rdev->irq.pflip[3])) 6556 + radeon_crtc_handle_vblank(rdev, 3); 6557 + rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; 6558 + DRM_DEBUG("IH: D4 vblank\n"); 6559 + 6570 6560 break; 6571 6561 case 1: /* D4 vline */ 6572 - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) { 6573 - rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; 6574 - DRM_DEBUG("IH: D4 vline\n"); 6575 - } 6562 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT)) 6563 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6564 + 6565 + rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; 6566 + DRM_DEBUG("IH: D4 vline\n"); 6567 + 6576 6568 break; 6577 6569 default: 6578 6570 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 6586 6570 case 5: /* D5 vblank/vline */ 6587 6571 switch (src_data) { 6588 6572 case 0: /* D5 vblank */ 6589 - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) { 6590 - if (rdev->irq.crtc_vblank_int[4]) { 6591 - drm_handle_vblank(rdev->ddev, 4); 6592 - rdev->pm.vblank_sync = true; 6593 - wake_up(&rdev->irq.vblank_queue); 6594 - } 6595 - if (atomic_read(&rdev->irq.pflip[4])) 6596 - radeon_crtc_handle_vblank(rdev, 4); 6597 - rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; 6598 - DRM_DEBUG("IH: D5 vblank\n"); 6573 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT)) 6574 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6575 + 6576 + if (rdev->irq.crtc_vblank_int[4]) { 6577 + drm_handle_vblank(rdev->ddev, 4); 6578 + rdev->pm.vblank_sync = true; 6579 + wake_up(&rdev->irq.vblank_queue); 6599 6580 } 6581 + if (atomic_read(&rdev->irq.pflip[4])) 6582 + radeon_crtc_handle_vblank(rdev, 4); 6583 + rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; 6584 + DRM_DEBUG("IH: D5 vblank\n"); 6585 + 6600 6586 break; 6601 6587 case 1: /* D5 vline */ 6602 - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) { 6603 - rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; 6604 - DRM_DEBUG("IH: D5 vline\n"); 6605 - } 6588 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT)) 6589 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6590 + 6591 + rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; 6592 + DRM_DEBUG("IH: D5 vline\n"); 6593 + 6606 6594 break; 6607 6595 default: 6608 6596 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 6616 6596 case 6: /* D6 vblank/vline */ 6617 6597 switch (src_data) { 6618 6598 case 0: /* D6 vblank */ 6619 - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) { 6620 - if (rdev->irq.crtc_vblank_int[5]) { 6621 - drm_handle_vblank(rdev->ddev, 5); 6622 - rdev->pm.vblank_sync = true; 6623 - wake_up(&rdev->irq.vblank_queue); 6624 - } 6625 - if (atomic_read(&rdev->irq.pflip[5])) 6626 - radeon_crtc_handle_vblank(rdev, 5); 6627 - rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; 6628 - DRM_DEBUG("IH: D6 vblank\n"); 6599 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT)) 6600 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6601 + 6602 + if (rdev->irq.crtc_vblank_int[5]) { 6603 + drm_handle_vblank(rdev->ddev, 5); 6604 + rdev->pm.vblank_sync = true; 6605 + wake_up(&rdev->irq.vblank_queue); 6629 6606 } 6607 + if (atomic_read(&rdev->irq.pflip[5])) 6608 + radeon_crtc_handle_vblank(rdev, 5); 6609 + rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; 6610 + DRM_DEBUG("IH: D6 vblank\n"); 6611 + 6630 6612 break; 6631 6613 case 1: /* D6 vline */ 6632 - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) { 6633 - rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; 6634 - DRM_DEBUG("IH: D6 vline\n"); 6635 - } 6614 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT)) 6615 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6616 + 6617 + rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; 6618 + DRM_DEBUG("IH: D6 vline\n"); 6619 + 6636 6620 break; 6637 6621 default: 6638 6622 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); ··· 6656 6632 case 42: /* HPD hotplug */ 6657 6633 switch (src_data) { 6658 6634 case 0: 6659 - if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT) { 6660 - rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_INTERRUPT; 6661 - queue_hotplug = true; 6662 - DRM_DEBUG("IH: HPD1\n"); 6663 - } 6635 + if (!(rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT)) 6636 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6637 + 6638 + rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_INTERRUPT; 6639 + queue_hotplug = true; 6640 + DRM_DEBUG("IH: HPD1\n"); 6641 + 6664 6642 break; 6665 6643 case 1: 6666 - if (rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_INTERRUPT) { 6667 - rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_INTERRUPT; 6668 - queue_hotplug = true; 6669 - DRM_DEBUG("IH: HPD2\n"); 6670 - } 6644 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_INTERRUPT)) 6645 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6646 + 6647 + rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_INTERRUPT; 6648 + queue_hotplug = true; 6649 + DRM_DEBUG("IH: HPD2\n"); 6650 + 6671 6651 break; 6672 6652 case 2: 6673 - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_INTERRUPT) { 6674 - rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; 6675 - queue_hotplug = true; 6676 - DRM_DEBUG("IH: HPD3\n"); 6677 - } 6653 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_INTERRUPT)) 6654 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6655 + 6656 + rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; 6657 + queue_hotplug = true; 6658 + DRM_DEBUG("IH: HPD3\n"); 6659 + 6678 6660 break; 6679 6661 case 3: 6680 - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_INTERRUPT) { 6681 - rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; 6682 - queue_hotplug = true; 6683 - DRM_DEBUG("IH: HPD4\n"); 6684 - } 6662 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_INTERRUPT)) 6663 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6664 + 6665 + rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; 6666 + queue_hotplug = true; 6667 + DRM_DEBUG("IH: HPD4\n"); 6668 + 6685 6669 break; 6686 6670 case 4: 6687 - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_INTERRUPT) { 6688 - rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; 6689 - queue_hotplug = true; 6690 - DRM_DEBUG("IH: HPD5\n"); 6691 - } 6671 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_INTERRUPT)) 6672 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6673 + 6674 + rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; 6675 + queue_hotplug = true; 6676 + DRM_DEBUG("IH: HPD5\n"); 6677 + 6692 6678 break; 6693 6679 case 5: 6694 - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_INTERRUPT) { 6695 - rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; 6696 - queue_hotplug = true; 6697 - DRM_DEBUG("IH: HPD6\n"); 6698 - } 6680 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_INTERRUPT)) 6681 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6682 + 6683 + rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; 6684 + queue_hotplug = true; 6685 + DRM_DEBUG("IH: HPD6\n"); 6686 + 6699 6687 break; 6700 6688 case 6: 6701 - if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_RX_INTERRUPT) { 6702 - rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_RX_INTERRUPT; 6703 - queue_dp = true; 6704 - DRM_DEBUG("IH: HPD_RX 1\n"); 6705 - } 6689 + if (!(rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_RX_INTERRUPT)) 6690 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6691 + 6692 + rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_RX_INTERRUPT; 6693 + queue_dp = true; 6694 + DRM_DEBUG("IH: HPD_RX 1\n"); 6695 + 6706 6696 break; 6707 6697 case 7: 6708 - if (rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_RX_INTERRUPT) { 6709 - rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_RX_INTERRUPT; 6710 - queue_dp = true; 6711 - DRM_DEBUG("IH: HPD_RX 2\n"); 6712 - } 6698 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_RX_INTERRUPT)) 6699 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6700 + 6701 + rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_RX_INTERRUPT; 6702 + queue_dp = true; 6703 + DRM_DEBUG("IH: HPD_RX 2\n"); 6704 + 6713 6705 break; 6714 6706 case 8: 6715 - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_RX_INTERRUPT) { 6716 - rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_RX_INTERRUPT; 6717 - queue_dp = true; 6718 - DRM_DEBUG("IH: HPD_RX 3\n"); 6719 - } 6707 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_RX_INTERRUPT)) 6708 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6709 + 6710 + rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_RX_INTERRUPT; 6711 + queue_dp = true; 6712 + DRM_DEBUG("IH: HPD_RX 3\n"); 6713 + 6720 6714 break; 6721 6715 case 9: 6722 - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_RX_INTERRUPT) { 6723 - rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_RX_INTERRUPT; 6724 - queue_dp = true; 6725 - DRM_DEBUG("IH: HPD_RX 4\n"); 6726 - } 6716 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_RX_INTERRUPT)) 6717 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6718 + 6719 + rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_RX_INTERRUPT; 6720 + queue_dp = true; 6721 + DRM_DEBUG("IH: HPD_RX 4\n"); 6722 + 6727 6723 break; 6728 6724 case 10: 6729 - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_RX_INTERRUPT) { 6730 - rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_RX_INTERRUPT; 6731 - queue_dp = true; 6732 - DRM_DEBUG("IH: HPD_RX 5\n"); 6733 - } 6725 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_RX_INTERRUPT)) 6726 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6727 + 6728 + rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_RX_INTERRUPT; 6729 + queue_dp = true; 6730 + DRM_DEBUG("IH: HPD_RX 5\n"); 6731 + 6734 6732 break; 6735 6733 case 11: 6736 - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_RX_INTERRUPT) { 6737 - rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_RX_INTERRUPT; 6738 - queue_dp = true; 6739 - DRM_DEBUG("IH: HPD_RX 6\n"); 6740 - } 6734 + if (!(rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_RX_INTERRUPT)) 6735 + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); 6736 + 6737 + rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_RX_INTERRUPT; 6738 + queue_dp = true; 6739 + DRM_DEBUG("IH: HPD_RX 6\n"); 6740 + 6741 6741 break; 6742 6742 default: 6743 6743 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
+1
drivers/i2c/busses/Kconfig
··· 633 633 config I2C_MT65XX 634 634 tristate "MediaTek I2C adapter" 635 635 depends on ARCH_MEDIATEK || COMPILE_TEST 636 + depends on HAS_DMA 636 637 help 637 638 This selects the MediaTek(R) Integrated Inter Circuit bus driver 638 639 for MT65xx and MT81xx.
+8 -7
drivers/i2c/busses/i2c-jz4780.c
··· 764 764 if (IS_ERR(i2c->clk)) 765 765 return PTR_ERR(i2c->clk); 766 766 767 - clk_prepare_enable(i2c->clk); 767 + ret = clk_prepare_enable(i2c->clk); 768 + if (ret) 769 + return ret; 768 770 769 - if (of_property_read_u32(pdev->dev.of_node, "clock-frequency", 770 - &clk_freq)) { 771 + ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", 772 + &clk_freq); 773 + if (ret) { 771 774 dev_err(&pdev->dev, "clock-frequency not specified in DT"); 772 - return clk_freq; 775 + goto err; 773 776 } 774 777 775 778 i2c->speed = clk_freq / 1000; ··· 793 790 i2c->irq = platform_get_irq(pdev, 0); 794 791 ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, 795 792 dev_name(&pdev->dev), i2c); 796 - if (ret) { 797 - ret = -ENODEV; 793 + if (ret) 798 794 goto err; 799 - } 800 795 801 796 ret = i2c_add_adapter(&i2c->adap); 802 797 if (ret < 0) {
+1
drivers/i2c/busses/i2c-xgene-slimpro.c
··· 419 419 rc = i2c_add_adapter(adapter); 420 420 if (rc) { 421 421 dev_err(&pdev->dev, "Adapter registeration failed\n"); 422 + mbox_free_channel(ctx->mbox_chan); 422 423 return rc; 423 424 } 424 425
+15 -1
drivers/i2c/i2c-core.c
··· 1012 1012 */ 1013 1013 void i2c_unregister_device(struct i2c_client *client) 1014 1014 { 1015 + if (client->dev.of_node) 1016 + of_node_clear_flag(client->dev.of_node, OF_POPULATED); 1015 1017 device_unregister(&client->dev); 1016 1018 } 1017 1019 EXPORT_SYMBOL_GPL(i2c_unregister_device); ··· 1322 1320 1323 1321 dev_dbg(&adap->dev, "of_i2c: walking child nodes\n"); 1324 1322 1325 - for_each_available_child_of_node(adap->dev.of_node, node) 1323 + for_each_available_child_of_node(adap->dev.of_node, node) { 1324 + if (of_node_test_and_set_flag(node, OF_POPULATED)) 1325 + continue; 1326 1326 of_i2c_register_device(adap, node); 1327 + } 1327 1328 } 1328 1329 1329 1330 static int of_dev_node_match(struct device *dev, void *data) ··· 1858 1853 if (adap == NULL) 1859 1854 return NOTIFY_OK; /* not for us */ 1860 1855 1856 + if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) { 1857 + put_device(&adap->dev); 1858 + return NOTIFY_OK; 1859 + } 1860 + 1861 1861 client = of_i2c_register_device(adap, rd->dn); 1862 1862 put_device(&adap->dev); 1863 1863 ··· 1873 1863 } 1874 1864 break; 1875 1865 case OF_RECONFIG_CHANGE_REMOVE: 1866 + /* already depopulated? */ 1867 + if (!of_node_check_flag(rd->dn, OF_POPULATED)) 1868 + return NOTIFY_OK; 1869 + 1876 1870 /* find our device by node */ 1877 1871 client = of_find_i2c_device_by_node(rd->dn); 1878 1872 if (client == NULL)
+5 -7
drivers/input/mouse/elan_i2c_core.c
··· 771 771 */ 772 772 static void elan_report_contact(struct elan_tp_data *data, 773 773 int contact_num, bool contact_valid, 774 - bool hover_event, u8 *finger_data) 774 + u8 *finger_data) 775 775 { 776 776 struct input_dev *input = data->input; 777 777 unsigned int pos_x, pos_y; ··· 815 815 input_mt_report_slot_state(input, MT_TOOL_FINGER, true); 816 816 input_report_abs(input, ABS_MT_POSITION_X, pos_x); 817 817 input_report_abs(input, ABS_MT_POSITION_Y, data->max_y - pos_y); 818 - input_report_abs(input, ABS_MT_DISTANCE, hover_event); 819 - input_report_abs(input, ABS_MT_PRESSURE, 820 - hover_event ? 0 : scaled_pressure); 818 + input_report_abs(input, ABS_MT_PRESSURE, scaled_pressure); 821 819 input_report_abs(input, ABS_TOOL_WIDTH, mk_x); 822 820 input_report_abs(input, ABS_MT_TOUCH_MAJOR, major); 823 821 input_report_abs(input, ABS_MT_TOUCH_MINOR, minor); ··· 837 839 hover_event = hover_info & 0x40; 838 840 for (i = 0; i < ETP_MAX_FINGERS; i++) { 839 841 contact_valid = tp_info & (1U << (3 + i)); 840 - elan_report_contact(data, i, contact_valid, hover_event, 841 - finger_data); 842 + elan_report_contact(data, i, contact_valid, finger_data); 842 843 843 844 if (contact_valid) 844 845 finger_data += ETP_FINGER_DATA_LEN; 845 846 } 846 847 847 848 input_report_key(input, BTN_LEFT, tp_info & 0x01); 849 + input_report_abs(input, ABS_DISTANCE, hover_event != 0); 848 850 input_mt_report_pointer_emulation(input, true); 849 851 input_sync(input); 850 852 } ··· 920 922 input_abs_set_res(input, ABS_Y, data->y_res); 921 923 input_set_abs_params(input, ABS_PRESSURE, 0, ETP_MAX_PRESSURE, 0, 0); 922 924 input_set_abs_params(input, ABS_TOOL_WIDTH, 0, ETP_FINGER_WIDTH, 0, 0); 925 + input_set_abs_params(input, ABS_DISTANCE, 0, 1, 0, 0); 923 926 924 927 /* And MT parameters */ 925 928 input_set_abs_params(input, ABS_MT_POSITION_X, 0, data->max_x, 0, 0); ··· 933 934 ETP_FINGER_WIDTH * max_width, 0, 0); 934 935 input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 935 936 ETP_FINGER_WIDTH * min_width, 0, 0); 936 - input_set_abs_params(input, ABS_MT_DISTANCE, 0, 1, 0, 0); 937 937 938 938 data->input = input; 939 939
+1 -1
drivers/input/mouse/synaptics.c
··· 1199 1199 ABS_MT_POSITION_Y); 1200 1200 /* Image sensors can report per-contact pressure */ 1201 1201 input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0); 1202 - input_mt_init_slots(dev, 3, INPUT_MT_POINTER | INPUT_MT_TRACK); 1202 + input_mt_init_slots(dev, 2, INPUT_MT_POINTER | INPUT_MT_TRACK); 1203 1203 1204 1204 /* Image sensors can signal 4 and 5 finger clicks */ 1205 1205 __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+1 -1
drivers/irqchip/irq-gic.c
··· 1055 1055 1056 1056 processor = (struct acpi_madt_generic_interrupt *)header; 1057 1057 1058 - if (BAD_MADT_ENTRY(processor, end)) 1058 + if (BAD_MADT_GICC_ENTRY(processor, end)) 1059 1059 return -EINVAL; 1060 1060 1061 1061 /*
-10
drivers/irqchip/irq-mips-gic.c
··· 257 257 return MIPS_CPU_IRQ_BASE + cp0_fdc_irq; 258 258 } 259 259 260 - /* 261 - * Some cores claim the FDC is routable but it doesn't actually seem to 262 - * be connected. 263 - */ 264 - switch (current_cpu_type()) { 265 - case CPU_INTERAPTIV: 266 - case CPU_PROAPTIV: 267 - return -1; 268 - } 269 - 270 260 return irq_create_mapping(gic_irq_domain, 271 261 GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_FDC)); 272 262 }
+1 -7
drivers/memory/omap-gpmc.c
··· 2074 2074 ret = gpmc_probe_nand_child(pdev, child); 2075 2075 else if (of_node_cmp(child->name, "onenand") == 0) 2076 2076 ret = gpmc_probe_onenand_child(pdev, child); 2077 - else if (of_node_cmp(child->name, "ethernet") == 0 || 2078 - of_node_cmp(child->name, "nor") == 0 || 2079 - of_node_cmp(child->name, "uart") == 0) 2077 + else 2080 2078 ret = gpmc_probe_generic_child(pdev, child); 2081 - 2082 - if (WARN(ret < 0, "%s: probing gpmc child %s failed\n", 2083 - __func__, child->full_name)) 2084 - of_node_put(child); 2085 2079 } 2086 2080 2087 2081 return 0;
+5 -7
drivers/misc/cxl/api.c
··· 23 23 24 24 afu = cxl_pci_to_afu(dev); 25 25 26 + get_device(&afu->dev); 26 27 ctx = cxl_context_alloc(); 27 28 if (IS_ERR(ctx)) 28 29 return ctx; ··· 32 31 rc = cxl_context_init(ctx, afu, false, NULL); 33 32 if (rc) { 34 33 kfree(ctx); 34 + put_device(&afu->dev); 35 35 return ERR_PTR(-ENOMEM); 36 36 } 37 37 cxl_assign_psn_space(ctx); ··· 61 59 { 62 60 if (ctx->status != CLOSED) 63 61 return -EBUSY; 62 + 63 + put_device(&ctx->afu->dev); 64 64 65 65 cxl_context_free(ctx); 66 66 ··· 163 159 } 164 160 165 161 ctx->status = STARTED; 166 - get_device(&ctx->afu->dev); 167 162 out: 168 163 mutex_unlock(&ctx->status_mutex); 169 164 return rc; ··· 178 175 /* Stop a context. Returns 0 on success, otherwise -Errno */ 179 176 int cxl_stop_context(struct cxl_context *ctx) 180 177 { 181 - int rc; 182 - 183 - rc = __detach_context(ctx); 184 - if (!rc) 185 - put_device(&ctx->afu->dev); 186 - return rc; 178 + return __detach_context(ctx); 187 179 } 188 180 EXPORT_SYMBOL_GPL(cxl_stop_context); 189 181
+11 -3
drivers/misc/cxl/context.c
··· 113 113 114 114 if (ctx->afu->current_mode == CXL_MODE_DEDICATED) { 115 115 area = ctx->afu->psn_phys; 116 - if (offset > ctx->afu->adapter->ps_size) 116 + if (offset >= ctx->afu->adapter->ps_size) 117 117 return VM_FAULT_SIGBUS; 118 118 } else { 119 119 area = ctx->psn_phys; 120 - if (offset > ctx->psn_size) 120 + if (offset >= ctx->psn_size) 121 121 return VM_FAULT_SIGBUS; 122 122 } 123 123 ··· 145 145 */ 146 146 int cxl_context_iomap(struct cxl_context *ctx, struct vm_area_struct *vma) 147 147 { 148 + u64 start = vma->vm_pgoff << PAGE_SHIFT; 148 149 u64 len = vma->vm_end - vma->vm_start; 149 - len = min(len, ctx->psn_size); 150 + 151 + if (ctx->afu->current_mode == CXL_MODE_DEDICATED) { 152 + if (start + len > ctx->afu->adapter->ps_size) 153 + return -EINVAL; 154 + } else { 155 + if (start + len > ctx->psn_size) 156 + return -EINVAL; 157 + } 150 158 151 159 if (ctx->afu->current_mode != CXL_MODE_DEDICATED) { 152 160 /* make sure there is a valid per process space for this AFU */
+1 -1
drivers/misc/cxl/main.c
··· 73 73 spin_lock(&adapter->afu_list_lock); 74 74 for (slice = 0; slice < adapter->slices; slice++) { 75 75 afu = adapter->afu[slice]; 76 - if (!afu->enabled) 76 + if (!afu || !afu->enabled) 77 77 continue; 78 78 rcu_read_lock(); 79 79 idr_for_each_entry(&afu->contexts_idr, ctx, id)
+1 -1
drivers/misc/cxl/pci.c
··· 539 539 540 540 static void cxl_unmap_slice_regs(struct cxl_afu *afu) 541 541 { 542 - if (afu->p1n_mmio) 542 + if (afu->p2n_mmio) 543 543 iounmap(afu->p2n_mmio); 544 544 if (afu->p1n_mmio) 545 545 iounmap(afu->p1n_mmio);
+2 -1
drivers/misc/cxl/vphb.c
··· 112 112 unsigned long addr; 113 113 114 114 phb = pci_bus_to_host(bus); 115 - afu = (struct cxl_afu *)phb->private_data; 116 115 if (phb == NULL) 117 116 return PCIBIOS_DEVICE_NOT_FOUND; 117 + afu = (struct cxl_afu *)phb->private_data; 118 + 118 119 if (cxl_pcie_cfg_record(bus->number, devfn) > afu->crs_num) 119 120 return PCIBIOS_DEVICE_NOT_FOUND; 120 121 if (offset >= (unsigned long)phb->cfg_data)
-16
drivers/misc/mei/bus.c
··· 552 552 schedule_work(&device->event_work); 553 553 } 554 554 555 - void mei_cl_bus_remove_devices(struct mei_device *dev) 556 - { 557 - struct mei_cl *cl, *next; 558 - 559 - mutex_lock(&dev->device_lock); 560 - list_for_each_entry_safe(cl, next, &dev->device_list, device_link) { 561 - if (cl->device) 562 - mei_cl_remove_device(cl->device); 563 - 564 - list_del(&cl->device_link); 565 - mei_cl_unlink(cl); 566 - kfree(cl); 567 - } 568 - mutex_unlock(&dev->device_lock); 569 - } 570 - 571 555 int __init mei_cl_bus_init(void) 572 556 { 573 557 return bus_register(&mei_cl_bus_type);
-2
drivers/misc/mei/init.c
··· 333 333 334 334 mei_nfc_host_exit(dev); 335 335 336 - mei_cl_bus_remove_devices(dev); 337 - 338 336 mutex_lock(&dev->device_lock); 339 337 340 338 mei_wd_stop(dev);
+2 -1
drivers/misc/mei/nfc.c
··· 402 402 403 403 cldev->priv_data = NULL; 404 404 405 - mutex_lock(&dev->device_lock); 406 405 /* Need to remove the device here 407 406 * since mei_nfc_free will unlink the clients 408 407 */ 409 408 mei_cl_remove_device(cldev); 409 + 410 + mutex_lock(&dev->device_lock); 410 411 mei_nfc_free(ndev); 411 412 mutex_unlock(&dev->device_lock); 412 413 }
+3 -8
drivers/nvdimm/bus.c
··· 535 535 __func__, dimm_name, cmd_name, i); 536 536 return -ENXIO; 537 537 } 538 - if (!access_ok(VERIFY_READ, p + in_len, in_size)) 539 - return -EFAULT; 540 538 if (in_len < sizeof(in_env)) 541 539 copy = min_t(u32, sizeof(in_env) - in_len, in_size); 542 540 else ··· 555 557 __func__, dimm_name, cmd_name, i); 556 558 return -EFAULT; 557 559 } 558 - if (!access_ok(VERIFY_WRITE, p + in_len + out_len, out_size)) 559 - return -EFAULT; 560 560 if (out_len < sizeof(out_env)) 561 561 copy = min_t(u32, sizeof(out_env) - out_len, out_size); 562 562 else ··· 566 570 } 567 571 568 572 buf_len = out_len + in_len; 569 - if (!access_ok(VERIFY_WRITE, p, sizeof(buf_len))) 570 - return -EFAULT; 571 - 572 573 if (buf_len > ND_IOCTL_MAX_BUFLEN) { 573 574 dev_dbg(dev, "%s:%s cmd: %s buf_len: %zu > %d\n", __func__, 574 575 dimm_name, cmd_name, buf_len, ··· 699 706 nvdimm_major = rc; 700 707 701 708 nd_class = class_create(THIS_MODULE, "nd"); 702 - if (IS_ERR(nd_class)) 709 + if (IS_ERR(nd_class)) { 710 + rc = PTR_ERR(nd_class); 703 711 goto err_class; 712 + } 704 713 705 714 return 0; 706 715
+9 -26
drivers/pnp/system.c
··· 7 7 * Bjorn Helgaas <bjorn.helgaas@hp.com> 8 8 */ 9 9 10 - #include <linux/acpi.h> 11 10 #include <linux/pnp.h> 12 11 #include <linux/device.h> 13 12 #include <linux/init.h> ··· 22 23 {"", 0} 23 24 }; 24 25 25 - #ifdef CONFIG_ACPI 26 - static bool __reserve_range(u64 start, unsigned int length, bool io, char *desc) 27 - { 28 - u8 space_id = io ? ACPI_ADR_SPACE_SYSTEM_IO : ACPI_ADR_SPACE_SYSTEM_MEMORY; 29 - return !acpi_reserve_region(start, length, space_id, IORESOURCE_BUSY, desc); 30 - } 31 - #else 32 - static bool __reserve_range(u64 start, unsigned int length, bool io, char *desc) 33 - { 34 - struct resource *res; 35 - 36 - res = io ? request_region(start, length, desc) : 37 - request_mem_region(start, length, desc); 38 - if (res) { 39 - res->flags &= ~IORESOURCE_BUSY; 40 - return true; 41 - } 42 - return false; 43 - } 44 - #endif 45 - 46 26 static void reserve_range(struct pnp_dev *dev, struct resource *r, int port) 47 27 { 48 28 char *regionid; 49 29 const char *pnpid = dev_name(&dev->dev); 50 30 resource_size_t start = r->start, end = r->end; 51 - bool reserved; 31 + struct resource *res; 52 32 53 33 regionid = kmalloc(16, GFP_KERNEL); 54 34 if (!regionid) 55 35 return; 56 36 57 37 snprintf(regionid, 16, "pnp %s", pnpid); 58 - reserved = __reserve_range(start, end - start + 1, !!port, regionid); 59 - if (!reserved) 38 + if (port) 39 + res = request_region(start, end - start + 1, regionid); 40 + else 41 + res = request_mem_region(start, end - start + 1, regionid); 42 + if (res) 43 + res->flags &= ~IORESOURCE_BUSY; 44 + else 60 45 kfree(regionid); 61 46 62 47 /* ··· 49 66 * have double reservations. 50 67 */ 51 68 dev_info(&dev->dev, "%pR %s reserved\n", r, 52 - reserved ? "has been" : "could not be"); 69 + res ? "has been" : "could not be"); 53 70 } 54 71 55 72 static void reserve_resources_of_dev(struct pnp_dev *dev)
+9
drivers/regulator/core.c
··· 1081 1081 } 1082 1082 } 1083 1083 1084 + if (rdev->constraints->over_current_protection 1085 + && ops->set_over_current_protection) { 1086 + ret = ops->set_over_current_protection(rdev); 1087 + if (ret < 0) { 1088 + rdev_err(rdev, "failed to set over current protection\n"); 1089 + goto out; 1090 + } 1091 + } 1092 + 1084 1093 print_constraints(rdev); 1085 1094 return 0; 1086 1095 out:
+3
drivers/regulator/of_regulator.c
··· 107 107 if (!of_property_read_u32(np, "regulator-system-load", &pval)) 108 108 constraints->system_load = pval; 109 109 110 + constraints->over_current_protection = of_property_read_bool(np, 111 + "regulator-over-current-protection"); 112 + 110 113 for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { 111 114 switch (i) { 112 115 case PM_SUSPEND_MEM:
+38 -2
drivers/video/fbdev/stifb.c
··· 121 121 #define REG_3 0x0004a0 122 122 #define REG_4 0x000600 123 123 #define REG_6 0x000800 124 + #define REG_7 0x000804 124 125 #define REG_8 0x000820 125 126 #define REG_9 0x000a04 126 127 #define REG_10 0x018000 ··· 136 135 #define REG_21 0x200218 137 136 #define REG_22 0x0005a0 138 137 #define REG_23 0x0005c0 138 + #define REG_24 0x000808 139 + #define REG_25 0x000b00 139 140 #define REG_26 0x200118 140 141 #define REG_27 0x200308 141 142 #define REG_32 0x21003c ··· 431 428 432 429 #define SET_LENXY_START_RECFILL(fb, lenxy) \ 433 430 WRITE_WORD(lenxy, fb, REG_9) 431 + 432 + #define SETUP_COPYAREA(fb) \ 433 + WRITE_BYTE(0, fb, REG_16b1) 434 434 435 435 static void 436 436 HYPER_ENABLE_DISABLE_DISPLAY(struct stifb_info *fb, int enable) ··· 1010 1004 return 0; 1011 1005 } 1012 1006 1007 + static void 1008 + stifb_copyarea(struct fb_info *info, const struct fb_copyarea *area) 1009 + { 1010 + struct stifb_info *fb = container_of(info, struct stifb_info, info); 1011 + 1012 + SETUP_COPYAREA(fb); 1013 + 1014 + SETUP_HW(fb); 1015 + if (fb->info.var.bits_per_pixel == 32) { 1016 + WRITE_WORD(0xBBA0A000, fb, REG_10); 1017 + 1018 + NGLE_REALLY_SET_IMAGE_PLANEMASK(fb, 0xffffffff); 1019 + } else { 1020 + WRITE_WORD(fb->id == S9000_ID_HCRX ? 0x13a02000 : 0x13a01000, fb, REG_10); 1021 + 1022 + NGLE_REALLY_SET_IMAGE_PLANEMASK(fb, 0xff); 1023 + } 1024 + 1025 + NGLE_QUICK_SET_IMAGE_BITMAP_OP(fb, 1026 + IBOvals(RopSrc, MaskAddrOffset(0), 1027 + BitmapExtent08, StaticReg(1), 1028 + DataDynamic, MaskOtc, BGx(0), FGx(0))); 1029 + 1030 + WRITE_WORD(((area->sx << 16) | area->sy), fb, REG_24); 1031 + WRITE_WORD(((area->width << 16) | area->height), fb, REG_7); 1032 + WRITE_WORD(((area->dx << 16) | area->dy), fb, REG_25); 1033 + 1034 + SETUP_FB(fb); 1035 + } 1036 + 1013 1037 static void __init 1014 1038 stifb_init_display(struct stifb_info *fb) 1015 1039 { ··· 1105 1069 .fb_setcolreg = stifb_setcolreg, 1106 1070 .fb_blank = stifb_blank, 1107 1071 .fb_fillrect = cfb_fillrect, 1108 - .fb_copyarea = cfb_copyarea, 1072 + .fb_copyarea = stifb_copyarea, 1109 1073 .fb_imageblit = cfb_imageblit, 1110 1074 }; 1111 1075 ··· 1294 1258 info->fbops = &stifb_ops; 1295 1259 info->screen_base = ioremap_nocache(REGION_BASE(fb,1), fix->smem_len); 1296 1260 info->screen_size = fix->smem_len; 1297 - info->flags = FBINFO_DEFAULT; 1261 + info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA; 1298 1262 info->pseudo_palette = &fb->pseudo_palette; 1299 1263 1300 1264 /* This has to be done !!! */
+1 -2
fs/9p/vfs_inode.c
··· 540 540 unlock_new_inode(inode); 541 541 return inode; 542 542 error: 543 - unlock_new_inode(inode); 544 - iput(inode); 543 + iget_failed(inode); 545 544 return ERR_PTR(retval); 546 545 547 546 }
+1 -2
fs/9p/vfs_inode_dotl.c
··· 149 149 unlock_new_inode(inode); 150 150 return inode; 151 151 error: 152 - unlock_new_inode(inode); 153 - iput(inode); 152 + iget_failed(inode); 154 153 return ERR_PTR(retval); 155 154 156 155 }
+2
fs/btrfs/btrfs_inode.h
··· 44 44 #define BTRFS_INODE_IN_DELALLOC_LIST 9 45 45 #define BTRFS_INODE_READDIO_NEED_LOCK 10 46 46 #define BTRFS_INODE_HAS_PROPS 11 47 + /* DIO is ready to submit */ 48 + #define BTRFS_INODE_DIO_READY 12 47 49 /* 48 50 * The following 3 bits are meant only for the btree inode. 49 51 * When any of them is set, it means an error happened while writing an
+1
fs/btrfs/ctree.h
··· 1778 1778 spinlock_t unused_bgs_lock; 1779 1779 struct list_head unused_bgs; 1780 1780 struct mutex unused_bg_unpin_mutex; 1781 + struct mutex delete_unused_bgs_mutex; 1781 1782 1782 1783 /* For btrfs to record security options */ 1783 1784 struct security_mnt_opts security_opts;
+40 -1
fs/btrfs/disk-io.c
··· 1751 1751 { 1752 1752 struct btrfs_root *root = arg; 1753 1753 int again; 1754 + struct btrfs_trans_handle *trans; 1754 1755 1755 1756 do { 1756 1757 again = 0; ··· 1773 1772 } 1774 1773 1775 1774 btrfs_run_delayed_iputs(root); 1776 - btrfs_delete_unused_bgs(root->fs_info); 1777 1775 again = btrfs_clean_one_deleted_snapshot(root); 1778 1776 mutex_unlock(&root->fs_info->cleaner_mutex); 1779 1777 ··· 1781 1781 * needn't do anything special here. 1782 1782 */ 1783 1783 btrfs_run_defrag_inodes(root->fs_info); 1784 + 1785 + /* 1786 + * Acquires fs_info->delete_unused_bgs_mutex to avoid racing 1787 + * with relocation (btrfs_relocate_chunk) and relocation 1788 + * acquires fs_info->cleaner_mutex (btrfs_relocate_block_group) 1789 + * after acquiring fs_info->delete_unused_bgs_mutex. So we 1790 + * can't hold, nor need to, fs_info->cleaner_mutex when deleting 1791 + * unused block groups. 1792 + */ 1793 + btrfs_delete_unused_bgs(root->fs_info); 1784 1794 sleep: 1785 1795 if (!try_to_freeze() && !again) { 1786 1796 set_current_state(TASK_INTERRUPTIBLE); ··· 1799 1789 __set_current_state(TASK_RUNNING); 1800 1790 } 1801 1791 } while (!kthread_should_stop()); 1792 + 1793 + /* 1794 + * Transaction kthread is stopped before us and wakes us up. 1795 + * However we might have started a new transaction and COWed some 1796 + * tree blocks when deleting unused block groups for example. So 1797 + * make sure we commit the transaction we started to have a clean 1798 + * shutdown when evicting the btree inode - if it has dirty pages 1799 + * when we do the final iput() on it, eviction will trigger a 1800 + * writeback for it which will fail with null pointer dereferences 1801 + * since work queues and other resources were already released and 1802 + * destroyed by the time the iput/eviction/writeback is made. 1803 + */ 1804 + trans = btrfs_attach_transaction(root); 1805 + if (IS_ERR(trans)) { 1806 + if (PTR_ERR(trans) != -ENOENT) 1807 + btrfs_err(root->fs_info, 1808 + "cleaner transaction attach returned %ld", 1809 + PTR_ERR(trans)); 1810 + } else { 1811 + int ret; 1812 + 1813 + ret = btrfs_commit_transaction(trans, root); 1814 + if (ret) 1815 + btrfs_err(root->fs_info, 1816 + "cleaner open transaction commit returned %d", 1817 + ret); 1818 + } 1819 + 1802 1820 return 0; 1803 1821 } 1804 1822 ··· 2530 2492 spin_lock_init(&fs_info->unused_bgs_lock); 2531 2493 rwlock_init(&fs_info->tree_mod_log_lock); 2532 2494 mutex_init(&fs_info->unused_bg_unpin_mutex); 2495 + mutex_init(&fs_info->delete_unused_bgs_mutex); 2533 2496 mutex_init(&fs_info->reloc_mutex); 2534 2497 mutex_init(&fs_info->delalloc_root_mutex); 2535 2498 seqlock_init(&fs_info->profiles_lock);
+3
fs/btrfs/extent-tree.c
··· 9889 9889 } 9890 9890 spin_unlock(&fs_info->unused_bgs_lock); 9891 9891 9892 + mutex_lock(&root->fs_info->delete_unused_bgs_mutex); 9893 + 9892 9894 /* Don't want to race with allocators so take the groups_sem */ 9893 9895 down_write(&space_info->groups_sem); 9894 9896 spin_lock(&block_group->lock); ··· 9985 9983 end_trans: 9986 9984 btrfs_end_transaction(trans, root); 9987 9985 next: 9986 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 9988 9987 btrfs_put_block_group(block_group); 9989 9988 spin_lock(&fs_info->unused_bgs_lock); 9990 9989 }
+12 -5
fs/btrfs/inode-map.c
··· 246 246 { 247 247 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; 248 248 struct rb_root *rbroot = &root->free_ino_pinned->free_space_offset; 249 + spinlock_t *rbroot_lock = &root->free_ino_pinned->tree_lock; 249 250 struct btrfs_free_space *info; 250 251 struct rb_node *n; 251 252 u64 count; ··· 255 254 return; 256 255 257 256 while (1) { 257 + bool add_to_ctl = true; 258 + 259 + spin_lock(rbroot_lock); 258 260 n = rb_first(rbroot); 259 - if (!n) 261 + if (!n) { 262 + spin_unlock(rbroot_lock); 260 263 break; 264 + } 261 265 262 266 info = rb_entry(n, struct btrfs_free_space, offset_index); 263 267 BUG_ON(info->bitmap); /* Logic error */ 264 268 265 269 if (info->offset > root->ino_cache_progress) 266 - goto free; 270 + add_to_ctl = false; 267 271 else if (info->offset + info->bytes > root->ino_cache_progress) 268 272 count = root->ino_cache_progress - info->offset + 1; 269 273 else 270 274 count = info->bytes; 271 275 272 - __btrfs_add_free_space(ctl, info->offset, count); 273 - free: 274 276 rb_erase(&info->offset_index, rbroot); 275 - kfree(info); 277 + spin_unlock(rbroot_lock); 278 + if (add_to_ctl) 279 + __btrfs_add_free_space(ctl, info->offset, count); 280 + kmem_cache_free(btrfs_free_space_cachep, info); 276 281 } 277 282 } 278 283
+63 -26
fs/btrfs/inode.c
··· 4989 4989 /* 4990 4990 * Keep looping until we have no more ranges in the io tree. 4991 4991 * We can have ongoing bios started by readpages (called from readahead) 4992 - * that didn't get their end io callbacks called yet or they are still 4993 - * in progress ((extent_io.c:end_bio_extent_readpage()). This means some 4992 + * that have their endio callback (extent_io.c:end_bio_extent_readpage) 4993 + * still in progress (unlocked the pages in the bio but did not yet 4994 + * unlocked the ranges in the io tree). Therefore this means some 4994 4995 * ranges can still be locked and eviction started because before 4995 4996 * submitting those bios, which are executed by a separate task (work 4996 4997 * queue kthread), inode references (inode->i_count) were not taken ··· 7547 7546 7548 7547 current->journal_info = outstanding_extents; 7549 7548 btrfs_free_reserved_data_space(inode, len); 7549 + set_bit(BTRFS_INODE_DIO_READY, &BTRFS_I(inode)->runtime_flags); 7550 7550 } 7551 7551 7552 7552 /* ··· 7873 7871 struct bio *dio_bio; 7874 7872 int ret; 7875 7873 7876 - if (err) 7877 - goto out_done; 7878 7874 again: 7879 7875 ret = btrfs_dec_test_first_ordered_pending(inode, &ordered, 7880 7876 &ordered_offset, ··· 7895 7895 ordered = NULL; 7896 7896 goto again; 7897 7897 } 7898 - out_done: 7899 7898 dio_bio = dip->dio_bio; 7900 7899 7901 7900 kfree(dip); ··· 8162 8163 static void btrfs_submit_direct(int rw, struct bio *dio_bio, 8163 8164 struct inode *inode, loff_t file_offset) 8164 8165 { 8165 - struct btrfs_root *root = BTRFS_I(inode)->root; 8166 - struct btrfs_dio_private *dip; 8167 - struct bio *io_bio; 8166 + struct btrfs_dio_private *dip = NULL; 8167 + struct bio *io_bio = NULL; 8168 8168 struct btrfs_io_bio *btrfs_bio; 8169 8169 int skip_sum; 8170 8170 int write = rw & REQ_WRITE; ··· 8180 8182 dip = kzalloc(sizeof(*dip), GFP_NOFS); 8181 8183 if (!dip) { 8182 8184 ret = -ENOMEM; 8183 - goto free_io_bio; 8185 + goto free_ordered; 8184 8186 } 8185 8187 8186 8188 dip->private = dio_bio->bi_private; ··· 8208 8210 8209 8211 if (btrfs_bio->end_io) 8210 8212 btrfs_bio->end_io(btrfs_bio, ret); 8211 - free_io_bio: 8212 - bio_put(io_bio); 8213 8213 8214 8214 free_ordered: 8215 8215 /* 8216 - * If this is a write, we need to clean up the reserved space and kill 8217 - * the ordered extent. 8216 + * If we arrived here it means either we failed to submit the dip 8217 + * or we either failed to clone the dio_bio or failed to allocate the 8218 + * dip. If we cloned the dio_bio and allocated the dip, we can just 8219 + * call bio_endio against our io_bio so that we get proper resource 8220 + * cleanup if we fail to submit the dip, otherwise, we must do the 8221 + * same as btrfs_endio_direct_[write|read] because we can't call these 8222 + * callbacks - they require an allocated dip and a clone of dio_bio. 8218 8223 */ 8219 - if (write) { 8220 - struct btrfs_ordered_extent *ordered; 8221 - ordered = btrfs_lookup_ordered_extent(inode, file_offset); 8222 - if (!test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags) && 8223 - !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags)) 8224 - btrfs_free_reserved_extent(root, ordered->start, 8225 - ordered->disk_len, 1); 8226 - btrfs_put_ordered_extent(ordered); 8227 - btrfs_put_ordered_extent(ordered); 8224 + if (io_bio && dip) { 8225 + bio_endio(io_bio, ret); 8226 + /* 8227 + * The end io callbacks free our dip, do the final put on io_bio 8228 + * and all the cleanup and final put for dio_bio (through 8229 + * dio_end_io()). 8230 + */ 8231 + dip = NULL; 8232 + io_bio = NULL; 8233 + } else { 8234 + if (write) { 8235 + struct btrfs_ordered_extent *ordered; 8236 + 8237 + ordered = btrfs_lookup_ordered_extent(inode, 8238 + file_offset); 8239 + set_bit(BTRFS_ORDERED_IOERR, &ordered->flags); 8240 + /* 8241 + * Decrements our ref on the ordered extent and removes 8242 + * the ordered extent from the inode's ordered tree, 8243 + * doing all the proper resource cleanup such as for the 8244 + * reserved space and waking up any waiters for this 8245 + * ordered extent (through btrfs_remove_ordered_extent). 8246 + */ 8247 + btrfs_finish_ordered_io(ordered); 8248 + } else { 8249 + unlock_extent(&BTRFS_I(inode)->io_tree, file_offset, 8250 + file_offset + dio_bio->bi_iter.bi_size - 1); 8251 + } 8252 + clear_bit(BIO_UPTODATE, &dio_bio->bi_flags); 8253 + /* 8254 + * Releases and cleans up our dio_bio, no need to bio_put() 8255 + * nor bio_endio()/bio_io_error() against dio_bio. 8256 + */ 8257 + dio_end_io(dio_bio, ret); 8228 8258 } 8229 - bio_endio(dio_bio, ret); 8259 + if (io_bio) 8260 + bio_put(io_bio); 8261 + kfree(dip); 8230 8262 } 8231 8263 8232 8264 static ssize_t check_direct_IO(struct btrfs_root *root, struct kiocb *iocb, ··· 8358 8330 btrfs_submit_direct, flags); 8359 8331 if (iov_iter_rw(iter) == WRITE) { 8360 8332 current->journal_info = NULL; 8361 - if (ret < 0 && ret != -EIOCBQUEUED) 8362 - btrfs_delalloc_release_space(inode, count); 8363 - else if (ret >= 0 && (size_t)ret < count) 8333 + if (ret < 0 && ret != -EIOCBQUEUED) { 8334 + /* 8335 + * If the error comes from submitting stage, 8336 + * btrfs_get_blocsk_direct() has free'd data space, 8337 + * and metadata space will be handled by 8338 + * finish_ordered_fn, don't do that again to make 8339 + * sure bytes_may_use is correct. 8340 + */ 8341 + if (!test_and_clear_bit(BTRFS_INODE_DIO_READY, 8342 + &BTRFS_I(inode)->runtime_flags)) 8343 + btrfs_delalloc_release_space(inode, count); 8344 + } else if (ret >= 0 && (size_t)ret < count) 8364 8345 btrfs_delalloc_release_space(inode, 8365 8346 count - (size_t)ret); 8366 8347 }
+189 -54
fs/btrfs/ioctl.c
··· 87 87 88 88 89 89 static int btrfs_clone(struct inode *src, struct inode *inode, 90 - u64 off, u64 olen, u64 olen_aligned, u64 destoff); 90 + u64 off, u64 olen, u64 olen_aligned, u64 destoff, 91 + int no_time_update); 91 92 92 93 /* Mask out flags that are inappropriate for the given type of inode. */ 93 94 static inline __u32 btrfs_mask_flags(umode_t mode, __u32 flags) ··· 2766 2765 return ret; 2767 2766 } 2768 2767 2769 - static struct page *extent_same_get_page(struct inode *inode, u64 off) 2768 + static struct page *extent_same_get_page(struct inode *inode, pgoff_t index) 2770 2769 { 2771 2770 struct page *page; 2772 - pgoff_t index; 2773 2771 struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; 2774 - 2775 - index = off >> PAGE_CACHE_SHIFT; 2776 2772 2777 2773 page = grab_cache_page(inode->i_mapping, index); 2778 2774 if (!page) ··· 2789 2791 unlock_page(page); 2790 2792 2791 2793 return page; 2794 + } 2795 + 2796 + static int gather_extent_pages(struct inode *inode, struct page **pages, 2797 + int num_pages, u64 off) 2798 + { 2799 + int i; 2800 + pgoff_t index = off >> PAGE_CACHE_SHIFT; 2801 + 2802 + for (i = 0; i < num_pages; i++) { 2803 + pages[i] = extent_same_get_page(inode, index + i); 2804 + if (!pages[i]) 2805 + return -ENOMEM; 2806 + } 2807 + return 0; 2792 2808 } 2793 2809 2794 2810 static inline void lock_extent_range(struct inode *inode, u64 off, u64 len) ··· 2830 2818 } 2831 2819 } 2832 2820 2833 - static void btrfs_double_unlock(struct inode *inode1, u64 loff1, 2834 - struct inode *inode2, u64 loff2, u64 len) 2821 + static void btrfs_double_inode_unlock(struct inode *inode1, struct inode *inode2) 2835 2822 { 2836 - unlock_extent(&BTRFS_I(inode1)->io_tree, loff1, loff1 + len - 1); 2837 - unlock_extent(&BTRFS_I(inode2)->io_tree, loff2, loff2 + len - 1); 2838 - 2839 2823 mutex_unlock(&inode1->i_mutex); 2840 2824 mutex_unlock(&inode2->i_mutex); 2841 2825 } 2842 2826 2843 - static void btrfs_double_lock(struct inode *inode1, u64 loff1, 2844 - struct inode *inode2, u64 loff2, u64 len) 2827 + static void btrfs_double_inode_lock(struct inode *inode1, struct inode *inode2) 2828 + { 2829 + if (inode1 < inode2) 2830 + swap(inode1, inode2); 2831 + 2832 + mutex_lock_nested(&inode1->i_mutex, I_MUTEX_PARENT); 2833 + if (inode1 != inode2) 2834 + mutex_lock_nested(&inode2->i_mutex, I_MUTEX_CHILD); 2835 + } 2836 + 2837 + static void btrfs_double_extent_unlock(struct inode *inode1, u64 loff1, 2838 + struct inode *inode2, u64 loff2, u64 len) 2839 + { 2840 + unlock_extent(&BTRFS_I(inode1)->io_tree, loff1, loff1 + len - 1); 2841 + unlock_extent(&BTRFS_I(inode2)->io_tree, loff2, loff2 + len - 1); 2842 + } 2843 + 2844 + static void btrfs_double_extent_lock(struct inode *inode1, u64 loff1, 2845 + struct inode *inode2, u64 loff2, u64 len) 2845 2846 { 2846 2847 if (inode1 < inode2) { 2847 2848 swap(inode1, inode2); 2848 2849 swap(loff1, loff2); 2849 2850 } 2850 - 2851 - mutex_lock_nested(&inode1->i_mutex, I_MUTEX_PARENT); 2852 2851 lock_extent_range(inode1, loff1, len); 2853 - if (inode1 != inode2) { 2854 - mutex_lock_nested(&inode2->i_mutex, I_MUTEX_CHILD); 2852 + if (inode1 != inode2) 2855 2853 lock_extent_range(inode2, loff2, len); 2854 + } 2855 + 2856 + struct cmp_pages { 2857 + int num_pages; 2858 + struct page **src_pages; 2859 + struct page **dst_pages; 2860 + }; 2861 + 2862 + static void btrfs_cmp_data_free(struct cmp_pages *cmp) 2863 + { 2864 + int i; 2865 + struct page *pg; 2866 + 2867 + for (i = 0; i < cmp->num_pages; i++) { 2868 + pg = cmp->src_pages[i]; 2869 + if (pg) 2870 + page_cache_release(pg); 2871 + pg = cmp->dst_pages[i]; 2872 + if (pg) 2873 + page_cache_release(pg); 2856 2874 } 2875 + kfree(cmp->src_pages); 2876 + kfree(cmp->dst_pages); 2877 + } 2878 + 2879 + static int btrfs_cmp_data_prepare(struct inode *src, u64 loff, 2880 + struct inode *dst, u64 dst_loff, 2881 + u64 len, struct cmp_pages *cmp) 2882 + { 2883 + int ret; 2884 + int num_pages = PAGE_CACHE_ALIGN(len) >> PAGE_CACHE_SHIFT; 2885 + struct page **src_pgarr, **dst_pgarr; 2886 + 2887 + /* 2888 + * We must gather up all the pages before we initiate our 2889 + * extent locking. We use an array for the page pointers. Size 2890 + * of the array is bounded by len, which is in turn bounded by 2891 + * BTRFS_MAX_DEDUPE_LEN. 2892 + */ 2893 + src_pgarr = kzalloc(num_pages * sizeof(struct page *), GFP_NOFS); 2894 + dst_pgarr = kzalloc(num_pages * sizeof(struct page *), GFP_NOFS); 2895 + if (!src_pgarr || !dst_pgarr) { 2896 + kfree(src_pgarr); 2897 + kfree(dst_pgarr); 2898 + return -ENOMEM; 2899 + } 2900 + cmp->num_pages = num_pages; 2901 + cmp->src_pages = src_pgarr; 2902 + cmp->dst_pages = dst_pgarr; 2903 + 2904 + ret = gather_extent_pages(src, cmp->src_pages, cmp->num_pages, loff); 2905 + if (ret) 2906 + goto out; 2907 + 2908 + ret = gather_extent_pages(dst, cmp->dst_pages, cmp->num_pages, dst_loff); 2909 + 2910 + out: 2911 + if (ret) 2912 + btrfs_cmp_data_free(cmp); 2913 + return 0; 2857 2914 } 2858 2915 2859 2916 static int btrfs_cmp_data(struct inode *src, u64 loff, struct inode *dst, 2860 - u64 dst_loff, u64 len) 2917 + u64 dst_loff, u64 len, struct cmp_pages *cmp) 2861 2918 { 2862 2919 int ret = 0; 2920 + int i; 2863 2921 struct page *src_page, *dst_page; 2864 2922 unsigned int cmp_len = PAGE_CACHE_SIZE; 2865 2923 void *addr, *dst_addr; 2866 2924 2925 + i = 0; 2867 2926 while (len) { 2868 2927 if (len < PAGE_CACHE_SIZE) 2869 2928 cmp_len = len; 2870 2929 2871 - src_page = extent_same_get_page(src, loff); 2872 - if (!src_page) 2873 - return -EINVAL; 2874 - dst_page = extent_same_get_page(dst, dst_loff); 2875 - if (!dst_page) { 2876 - page_cache_release(src_page); 2877 - return -EINVAL; 2878 - } 2930 + BUG_ON(i >= cmp->num_pages); 2931 + 2932 + src_page = cmp->src_pages[i]; 2933 + dst_page = cmp->dst_pages[i]; 2934 + 2879 2935 addr = kmap_atomic(src_page); 2880 2936 dst_addr = kmap_atomic(dst_page); 2881 2937 ··· 2955 2875 2956 2876 kunmap_atomic(addr); 2957 2877 kunmap_atomic(dst_addr); 2958 - page_cache_release(src_page); 2959 - page_cache_release(dst_page); 2960 2878 2961 2879 if (ret) 2962 2880 break; 2963 2881 2964 - loff += cmp_len; 2965 - dst_loff += cmp_len; 2966 2882 len -= cmp_len; 2883 + i++; 2967 2884 } 2968 2885 2969 2886 return ret; ··· 2991 2914 { 2992 2915 int ret; 2993 2916 u64 len = olen; 2917 + struct cmp_pages cmp; 2918 + int same_inode = 0; 2919 + u64 same_lock_start = 0; 2920 + u64 same_lock_len = 0; 2994 2921 2995 - /* 2996 - * btrfs_clone() can't handle extents in the same file 2997 - * yet. Once that works, we can drop this check and replace it 2998 - * with a check for the same inode, but overlapping extents. 2999 - */ 3000 2922 if (src == dst) 3001 - return -EINVAL; 2923 + same_inode = 1; 3002 2924 3003 2925 if (len == 0) 3004 2926 return 0; 3005 2927 3006 - btrfs_double_lock(src, loff, dst, dst_loff, len); 2928 + if (same_inode) { 2929 + mutex_lock(&src->i_mutex); 3007 2930 3008 - ret = extent_same_check_offsets(src, loff, &len, olen); 3009 - if (ret) 3010 - goto out_unlock; 2931 + ret = extent_same_check_offsets(src, loff, &len, olen); 2932 + if (ret) 2933 + goto out_unlock; 3011 2934 3012 - ret = extent_same_check_offsets(dst, dst_loff, &len, olen); 3013 - if (ret) 3014 - goto out_unlock; 2935 + /* 2936 + * Single inode case wants the same checks, except we 2937 + * don't want our length pushed out past i_size as 2938 + * comparing that data range makes no sense. 2939 + * 2940 + * extent_same_check_offsets() will do this for an 2941 + * unaligned length at i_size, so catch it here and 2942 + * reject the request. 2943 + * 2944 + * This effectively means we require aligned extents 2945 + * for the single-inode case, whereas the other cases 2946 + * allow an unaligned length so long as it ends at 2947 + * i_size. 2948 + */ 2949 + if (len != olen) { 2950 + ret = -EINVAL; 2951 + goto out_unlock; 2952 + } 2953 + 2954 + /* Check for overlapping ranges */ 2955 + if (dst_loff + len > loff && dst_loff < loff + len) { 2956 + ret = -EINVAL; 2957 + goto out_unlock; 2958 + } 2959 + 2960 + same_lock_start = min_t(u64, loff, dst_loff); 2961 + same_lock_len = max_t(u64, loff, dst_loff) + len - same_lock_start; 2962 + } else { 2963 + btrfs_double_inode_lock(src, dst); 2964 + 2965 + ret = extent_same_check_offsets(src, loff, &len, olen); 2966 + if (ret) 2967 + goto out_unlock; 2968 + 2969 + ret = extent_same_check_offsets(dst, dst_loff, &len, olen); 2970 + if (ret) 2971 + goto out_unlock; 2972 + } 3015 2973 3016 2974 /* don't make the dst file partly checksummed */ 3017 2975 if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) != ··· 3055 2943 goto out_unlock; 3056 2944 } 3057 2945 3058 - ret = btrfs_cmp_data(src, loff, dst, dst_loff, len); 3059 - if (ret == 0) 3060 - ret = btrfs_clone(src, dst, loff, olen, len, dst_loff); 2946 + ret = btrfs_cmp_data_prepare(src, loff, dst, dst_loff, olen, &cmp); 2947 + if (ret) 2948 + goto out_unlock; 3061 2949 2950 + if (same_inode) 2951 + lock_extent_range(src, same_lock_start, same_lock_len); 2952 + else 2953 + btrfs_double_extent_lock(src, loff, dst, dst_loff, len); 2954 + 2955 + /* pass original length for comparison so we stay within i_size */ 2956 + ret = btrfs_cmp_data(src, loff, dst, dst_loff, olen, &cmp); 2957 + if (ret == 0) 2958 + ret = btrfs_clone(src, dst, loff, olen, len, dst_loff, 1); 2959 + 2960 + if (same_inode) 2961 + unlock_extent(&BTRFS_I(src)->io_tree, same_lock_start, 2962 + same_lock_start + same_lock_len - 1); 2963 + else 2964 + btrfs_double_extent_unlock(src, loff, dst, dst_loff, len); 2965 + 2966 + btrfs_cmp_data_free(&cmp); 3062 2967 out_unlock: 3063 - btrfs_double_unlock(src, loff, dst, dst_loff, len); 2968 + if (same_inode) 2969 + mutex_unlock(&src->i_mutex); 2970 + else 2971 + btrfs_double_inode_unlock(src, dst); 3064 2972 3065 2973 return ret; 3066 2974 } ··· 3232 3100 struct inode *inode, 3233 3101 u64 endoff, 3234 3102 const u64 destoff, 3235 - const u64 olen) 3103 + const u64 olen, 3104 + int no_time_update) 3236 3105 { 3237 3106 struct btrfs_root *root = BTRFS_I(inode)->root; 3238 3107 int ret; 3239 3108 3240 3109 inode_inc_iversion(inode); 3241 - inode->i_mtime = inode->i_ctime = CURRENT_TIME; 3110 + if (!no_time_update) 3111 + inode->i_mtime = inode->i_ctime = CURRENT_TIME; 3242 3112 /* 3243 3113 * We round up to the block size at eof when determining which 3244 3114 * extents to clone above, but shouldn't round up the file size. ··· 3325 3191 * @inode: Inode to clone to 3326 3192 * @off: Offset within source to start clone from 3327 3193 * @olen: Original length, passed by user, of range to clone 3328 - * @olen_aligned: Block-aligned value of olen, extent_same uses 3329 - * identical values here 3194 + * @olen_aligned: Block-aligned value of olen 3330 3195 * @destoff: Offset within @inode to start clone 3196 + * @no_time_update: Whether to update mtime/ctime on the target inode 3331 3197 */ 3332 3198 static int btrfs_clone(struct inode *src, struct inode *inode, 3333 3199 const u64 off, const u64 olen, const u64 olen_aligned, 3334 - const u64 destoff) 3200 + const u64 destoff, int no_time_update) 3335 3201 { 3336 3202 struct btrfs_root *root = BTRFS_I(inode)->root; 3337 3203 struct btrfs_path *path = NULL; ··· 3655 3521 root->sectorsize); 3656 3522 ret = clone_finish_inode_update(trans, inode, 3657 3523 last_dest_end, 3658 - destoff, olen); 3524 + destoff, olen, 3525 + no_time_update); 3659 3526 if (ret) 3660 3527 goto out; 3661 3528 if (new_key.offset + datal >= destoff + len) ··· 3694 3559 clone_update_extent_map(inode, trans, NULL, last_dest_end, 3695 3560 destoff + len - last_dest_end); 3696 3561 ret = clone_finish_inode_update(trans, inode, destoff + len, 3697 - destoff, olen); 3562 + destoff, olen, no_time_update); 3698 3563 } 3699 3564 3700 3565 out: ··· 3831 3696 lock_extent_range(inode, destoff, len); 3832 3697 } 3833 3698 3834 - ret = btrfs_clone(src, inode, off, olen, len, destoff); 3699 + ret = btrfs_clone(src, inode, off, olen, len, destoff, 0); 3835 3700 3836 3701 if (same_inode) { 3837 3702 u64 lock_start = min_t(u64, off, destoff);
+5
fs/btrfs/ordered-data.c
··· 552 552 trace_btrfs_ordered_extent_put(entry->inode, entry); 553 553 554 554 if (atomic_dec_and_test(&entry->refs)) { 555 + ASSERT(list_empty(&entry->log_list)); 556 + ASSERT(list_empty(&entry->trans_list)); 557 + ASSERT(list_empty(&entry->root_extent_list)); 558 + ASSERT(RB_EMPTY_NODE(&entry->rb_node)); 555 559 if (entry->inode) 556 560 btrfs_add_delayed_iput(entry->inode); 557 561 while (!list_empty(&entry->list)) { ··· 583 579 spin_lock_irq(&tree->lock); 584 580 node = &entry->rb_node; 585 581 rb_erase(node, &tree->tree); 582 + RB_CLEAR_NODE(node); 586 583 if (tree->last == node) 587 584 tree->last = NULL; 588 585 set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags);
+41 -8
fs/btrfs/qgroup.c
··· 1349 1349 struct btrfs_root *quota_root; 1350 1350 struct btrfs_qgroup *qgroup; 1351 1351 int ret = 0; 1352 + /* Sometimes we would want to clear the limit on this qgroup. 1353 + * To meet this requirement, we treat the -1 as a special value 1354 + * which tell kernel to clear the limit on this qgroup. 1355 + */ 1356 + const u64 CLEAR_VALUE = -1; 1352 1357 1353 1358 mutex_lock(&fs_info->qgroup_ioctl_lock); 1354 1359 quota_root = fs_info->quota_root; ··· 1369 1364 } 1370 1365 1371 1366 spin_lock(&fs_info->qgroup_lock); 1372 - if (limit->flags & BTRFS_QGROUP_LIMIT_MAX_RFER) 1373 - qgroup->max_rfer = limit->max_rfer; 1374 - if (limit->flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) 1375 - qgroup->max_excl = limit->max_excl; 1376 - if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_RFER) 1377 - qgroup->rsv_rfer = limit->rsv_rfer; 1378 - if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_EXCL) 1379 - qgroup->rsv_excl = limit->rsv_excl; 1367 + if (limit->flags & BTRFS_QGROUP_LIMIT_MAX_RFER) { 1368 + if (limit->max_rfer == CLEAR_VALUE) { 1369 + qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_MAX_RFER; 1370 + limit->flags &= ~BTRFS_QGROUP_LIMIT_MAX_RFER; 1371 + qgroup->max_rfer = 0; 1372 + } else { 1373 + qgroup->max_rfer = limit->max_rfer; 1374 + } 1375 + } 1376 + if (limit->flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) { 1377 + if (limit->max_excl == CLEAR_VALUE) { 1378 + qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_MAX_EXCL; 1379 + limit->flags &= ~BTRFS_QGROUP_LIMIT_MAX_EXCL; 1380 + qgroup->max_excl = 0; 1381 + } else { 1382 + qgroup->max_excl = limit->max_excl; 1383 + } 1384 + } 1385 + if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_RFER) { 1386 + if (limit->rsv_rfer == CLEAR_VALUE) { 1387 + qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER; 1388 + limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER; 1389 + qgroup->rsv_rfer = 0; 1390 + } else { 1391 + qgroup->rsv_rfer = limit->rsv_rfer; 1392 + } 1393 + } 1394 + if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_EXCL) { 1395 + if (limit->rsv_excl == CLEAR_VALUE) { 1396 + qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL; 1397 + limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL; 1398 + qgroup->rsv_excl = 0; 1399 + } else { 1400 + qgroup->rsv_excl = limit->rsv_excl; 1401 + } 1402 + } 1380 1403 qgroup->lim_flags |= limit->flags; 1381 1404 1382 1405 spin_unlock(&fs_info->qgroup_lock);
+1 -1
fs/btrfs/relocation.c
··· 4049 4049 if (trans && progress && err == -ENOSPC) { 4050 4050 ret = btrfs_force_chunk_alloc(trans, rc->extent_root, 4051 4051 rc->block_group->flags); 4052 - if (ret == 0) { 4052 + if (ret == 1) { 4053 4053 err = 0; 4054 4054 progress = 0; 4055 4055 goto restart;
+20 -19
fs/btrfs/scrub.c
··· 3571 3571 static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info, 3572 3572 int is_dev_replace) 3573 3573 { 3574 - int ret = 0; 3575 3574 unsigned int flags = WQ_FREEZABLE | WQ_UNBOUND; 3576 3575 int max_active = fs_info->thread_pool_size; 3577 3576 ··· 3583 3584 fs_info->scrub_workers = 3584 3585 btrfs_alloc_workqueue("btrfs-scrub", flags, 3585 3586 max_active, 4); 3586 - if (!fs_info->scrub_workers) { 3587 - ret = -ENOMEM; 3588 - goto out; 3589 - } 3587 + if (!fs_info->scrub_workers) 3588 + goto fail_scrub_workers; 3589 + 3590 3590 fs_info->scrub_wr_completion_workers = 3591 3591 btrfs_alloc_workqueue("btrfs-scrubwrc", flags, 3592 3592 max_active, 2); 3593 - if (!fs_info->scrub_wr_completion_workers) { 3594 - ret = -ENOMEM; 3595 - goto out; 3596 - } 3593 + if (!fs_info->scrub_wr_completion_workers) 3594 + goto fail_scrub_wr_completion_workers; 3595 + 3597 3596 fs_info->scrub_nocow_workers = 3598 3597 btrfs_alloc_workqueue("btrfs-scrubnc", flags, 1, 0); 3599 - if (!fs_info->scrub_nocow_workers) { 3600 - ret = -ENOMEM; 3601 - goto out; 3602 - } 3598 + if (!fs_info->scrub_nocow_workers) 3599 + goto fail_scrub_nocow_workers; 3603 3600 fs_info->scrub_parity_workers = 3604 3601 btrfs_alloc_workqueue("btrfs-scrubparity", flags, 3605 3602 max_active, 2); 3606 - if (!fs_info->scrub_parity_workers) { 3607 - ret = -ENOMEM; 3608 - goto out; 3609 - } 3603 + if (!fs_info->scrub_parity_workers) 3604 + goto fail_scrub_parity_workers; 3610 3605 } 3611 3606 ++fs_info->scrub_workers_refcnt; 3612 - out: 3613 - return ret; 3607 + return 0; 3608 + 3609 + fail_scrub_parity_workers: 3610 + btrfs_destroy_workqueue(fs_info->scrub_nocow_workers); 3611 + fail_scrub_nocow_workers: 3612 + btrfs_destroy_workqueue(fs_info->scrub_wr_completion_workers); 3613 + fail_scrub_wr_completion_workers: 3614 + btrfs_destroy_workqueue(fs_info->scrub_workers); 3615 + fail_scrub_workers: 3616 + return -ENOMEM; 3614 3617 } 3615 3618 3616 3619 static noinline_for_stack void scrub_workers_put(struct btrfs_fs_info *fs_info)
+221 -5
fs/btrfs/tree-log.c
··· 4117 4117 return 0; 4118 4118 } 4119 4119 4120 + /* 4121 + * At the moment we always log all xattrs. This is to figure out at log replay 4122 + * time which xattrs must have their deletion replayed. If a xattr is missing 4123 + * in the log tree and exists in the fs/subvol tree, we delete it. This is 4124 + * because if a xattr is deleted, the inode is fsynced and a power failure 4125 + * happens, causing the log to be replayed the next time the fs is mounted, 4126 + * we want the xattr to not exist anymore (same behaviour as other filesystems 4127 + * with a journal, ext3/4, xfs, f2fs, etc). 4128 + */ 4129 + static int btrfs_log_all_xattrs(struct btrfs_trans_handle *trans, 4130 + struct btrfs_root *root, 4131 + struct inode *inode, 4132 + struct btrfs_path *path, 4133 + struct btrfs_path *dst_path) 4134 + { 4135 + int ret; 4136 + struct btrfs_key key; 4137 + const u64 ino = btrfs_ino(inode); 4138 + int ins_nr = 0; 4139 + int start_slot = 0; 4140 + 4141 + key.objectid = ino; 4142 + key.type = BTRFS_XATTR_ITEM_KEY; 4143 + key.offset = 0; 4144 + 4145 + ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 4146 + if (ret < 0) 4147 + return ret; 4148 + 4149 + while (true) { 4150 + int slot = path->slots[0]; 4151 + struct extent_buffer *leaf = path->nodes[0]; 4152 + int nritems = btrfs_header_nritems(leaf); 4153 + 4154 + if (slot >= nritems) { 4155 + if (ins_nr > 0) { 4156 + u64 last_extent = 0; 4157 + 4158 + ret = copy_items(trans, inode, dst_path, path, 4159 + &last_extent, start_slot, 4160 + ins_nr, 1, 0); 4161 + /* can't be 1, extent items aren't processed */ 4162 + ASSERT(ret <= 0); 4163 + if (ret < 0) 4164 + return ret; 4165 + ins_nr = 0; 4166 + } 4167 + ret = btrfs_next_leaf(root, path); 4168 + if (ret < 0) 4169 + return ret; 4170 + else if (ret > 0) 4171 + break; 4172 + continue; 4173 + } 4174 + 4175 + btrfs_item_key_to_cpu(leaf, &key, slot); 4176 + if (key.objectid != ino || key.type != BTRFS_XATTR_ITEM_KEY) 4177 + break; 4178 + 4179 + if (ins_nr == 0) 4180 + start_slot = slot; 4181 + ins_nr++; 4182 + path->slots[0]++; 4183 + cond_resched(); 4184 + } 4185 + if (ins_nr > 0) { 4186 + u64 last_extent = 0; 4187 + 4188 + ret = copy_items(trans, inode, dst_path, path, 4189 + &last_extent, start_slot, 4190 + ins_nr, 1, 0); 4191 + /* can't be 1, extent items aren't processed */ 4192 + ASSERT(ret <= 0); 4193 + if (ret < 0) 4194 + return ret; 4195 + } 4196 + 4197 + return 0; 4198 + } 4199 + 4200 + /* 4201 + * If the no holes feature is enabled we need to make sure any hole between the 4202 + * last extent and the i_size of our inode is explicitly marked in the log. This 4203 + * is to make sure that doing something like: 4204 + * 4205 + * 1) create file with 128Kb of data 4206 + * 2) truncate file to 64Kb 4207 + * 3) truncate file to 256Kb 4208 + * 4) fsync file 4209 + * 5) <crash/power failure> 4210 + * 6) mount fs and trigger log replay 4211 + * 4212 + * Will give us a file with a size of 256Kb, the first 64Kb of data match what 4213 + * the file had in its first 64Kb of data at step 1 and the last 192Kb of the 4214 + * file correspond to a hole. The presence of explicit holes in a log tree is 4215 + * what guarantees that log replay will remove/adjust file extent items in the 4216 + * fs/subvol tree. 4217 + * 4218 + * Here we do not need to care about holes between extents, that is already done 4219 + * by copy_items(). We also only need to do this in the full sync path, where we 4220 + * lookup for extents from the fs/subvol tree only. In the fast path case, we 4221 + * lookup the list of modified extent maps and if any represents a hole, we 4222 + * insert a corresponding extent representing a hole in the log tree. 4223 + */ 4224 + static int btrfs_log_trailing_hole(struct btrfs_trans_handle *trans, 4225 + struct btrfs_root *root, 4226 + struct inode *inode, 4227 + struct btrfs_path *path) 4228 + { 4229 + int ret; 4230 + struct btrfs_key key; 4231 + u64 hole_start; 4232 + u64 hole_size; 4233 + struct extent_buffer *leaf; 4234 + struct btrfs_root *log = root->log_root; 4235 + const u64 ino = btrfs_ino(inode); 4236 + const u64 i_size = i_size_read(inode); 4237 + 4238 + if (!btrfs_fs_incompat(root->fs_info, NO_HOLES)) 4239 + return 0; 4240 + 4241 + key.objectid = ino; 4242 + key.type = BTRFS_EXTENT_DATA_KEY; 4243 + key.offset = (u64)-1; 4244 + 4245 + ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 4246 + ASSERT(ret != 0); 4247 + if (ret < 0) 4248 + return ret; 4249 + 4250 + ASSERT(path->slots[0] > 0); 4251 + path->slots[0]--; 4252 + leaf = path->nodes[0]; 4253 + btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); 4254 + 4255 + if (key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY) { 4256 + /* inode does not have any extents */ 4257 + hole_start = 0; 4258 + hole_size = i_size; 4259 + } else { 4260 + struct btrfs_file_extent_item *extent; 4261 + u64 len; 4262 + 4263 + /* 4264 + * If there's an extent beyond i_size, an explicit hole was 4265 + * already inserted by copy_items(). 4266 + */ 4267 + if (key.offset >= i_size) 4268 + return 0; 4269 + 4270 + extent = btrfs_item_ptr(leaf, path->slots[0], 4271 + struct btrfs_file_extent_item); 4272 + 4273 + if (btrfs_file_extent_type(leaf, extent) == 4274 + BTRFS_FILE_EXTENT_INLINE) { 4275 + len = btrfs_file_extent_inline_len(leaf, 4276 + path->slots[0], 4277 + extent); 4278 + ASSERT(len == i_size); 4279 + return 0; 4280 + } 4281 + 4282 + len = btrfs_file_extent_num_bytes(leaf, extent); 4283 + /* Last extent goes beyond i_size, no need to log a hole. */ 4284 + if (key.offset + len > i_size) 4285 + return 0; 4286 + hole_start = key.offset + len; 4287 + hole_size = i_size - hole_start; 4288 + } 4289 + btrfs_release_path(path); 4290 + 4291 + /* Last extent ends at i_size. */ 4292 + if (hole_size == 0) 4293 + return 0; 4294 + 4295 + hole_size = ALIGN(hole_size, root->sectorsize); 4296 + ret = btrfs_insert_file_extent(trans, log, ino, hole_start, 0, 0, 4297 + hole_size, 0, hole_size, 0, 0, 0); 4298 + return ret; 4299 + } 4300 + 4120 4301 /* log a single inode in the tree log. 4121 4302 * At least one parent directory for this inode must exist in the tree 4122 4303 * or be logged already. ··· 4336 4155 u64 ino = btrfs_ino(inode); 4337 4156 struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; 4338 4157 u64 logged_isize = 0; 4158 + bool need_log_inode_item = true; 4339 4159 4340 4160 path = btrfs_alloc_path(); 4341 4161 if (!path) ··· 4445 4263 } else { 4446 4264 if (inode_only == LOG_INODE_ALL) 4447 4265 fast_search = true; 4448 - ret = log_inode_item(trans, log, dst_path, inode); 4449 - if (ret) { 4450 - err = ret; 4451 - goto out_unlock; 4452 - } 4453 4266 goto log_extents; 4454 4267 } 4455 4268 ··· 4466 4289 break; 4467 4290 if (min_key.type > max_key.type) 4468 4291 break; 4292 + 4293 + if (min_key.type == BTRFS_INODE_ITEM_KEY) 4294 + need_log_inode_item = false; 4295 + 4296 + /* Skip xattrs, we log them later with btrfs_log_all_xattrs() */ 4297 + if (min_key.type == BTRFS_XATTR_ITEM_KEY) { 4298 + if (ins_nr == 0) 4299 + goto next_slot; 4300 + ret = copy_items(trans, inode, dst_path, path, 4301 + &last_extent, ins_start_slot, 4302 + ins_nr, inode_only, logged_isize); 4303 + if (ret < 0) { 4304 + err = ret; 4305 + goto out_unlock; 4306 + } 4307 + ins_nr = 0; 4308 + if (ret) { 4309 + btrfs_release_path(path); 4310 + continue; 4311 + } 4312 + goto next_slot; 4313 + } 4469 4314 4470 4315 src = path->nodes[0]; 4471 4316 if (ins_nr && ins_start_slot + ins_nr == path->slots[0]) { ··· 4556 4357 ins_nr = 0; 4557 4358 } 4558 4359 4360 + btrfs_release_path(path); 4361 + btrfs_release_path(dst_path); 4362 + err = btrfs_log_all_xattrs(trans, root, inode, path, dst_path); 4363 + if (err) 4364 + goto out_unlock; 4365 + if (max_key.type >= BTRFS_EXTENT_DATA_KEY && !fast_search) { 4366 + btrfs_release_path(path); 4367 + btrfs_release_path(dst_path); 4368 + err = btrfs_log_trailing_hole(trans, root, inode, path); 4369 + if (err) 4370 + goto out_unlock; 4371 + } 4559 4372 log_extents: 4560 4373 btrfs_release_path(path); 4561 4374 btrfs_release_path(dst_path); 4375 + if (need_log_inode_item) { 4376 + err = log_inode_item(trans, log, dst_path, inode); 4377 + if (err) 4378 + goto out_unlock; 4379 + } 4562 4380 if (fast_search) { 4563 4381 /* 4564 4382 * Some ordered extents started by fsync might have completed
+44 -6
fs/btrfs/volumes.c
··· 2766 2766 root = root->fs_info->chunk_root; 2767 2767 extent_root = root->fs_info->extent_root; 2768 2768 2769 + /* 2770 + * Prevent races with automatic removal of unused block groups. 2771 + * After we relocate and before we remove the chunk with offset 2772 + * chunk_offset, automatic removal of the block group can kick in, 2773 + * resulting in a failure when calling btrfs_remove_chunk() below. 2774 + * 2775 + * Make sure to acquire this mutex before doing a tree search (dev 2776 + * or chunk trees) to find chunks. Otherwise the cleaner kthread might 2777 + * call btrfs_remove_chunk() (through btrfs_delete_unused_bgs()) after 2778 + * we release the path used to search the chunk/dev tree and before 2779 + * the current task acquires this mutex and calls us. 2780 + */ 2781 + ASSERT(mutex_is_locked(&root->fs_info->delete_unused_bgs_mutex)); 2782 + 2769 2783 ret = btrfs_can_relocate(extent_root, chunk_offset); 2770 2784 if (ret) 2771 2785 return -ENOSPC; ··· 2828 2814 key.type = BTRFS_CHUNK_ITEM_KEY; 2829 2815 2830 2816 while (1) { 2817 + mutex_lock(&root->fs_info->delete_unused_bgs_mutex); 2831 2818 ret = btrfs_search_slot(NULL, chunk_root, &key, path, 0, 0); 2832 - if (ret < 0) 2819 + if (ret < 0) { 2820 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 2833 2821 goto error; 2822 + } 2834 2823 BUG_ON(ret == 0); /* Corruption */ 2835 2824 2836 2825 ret = btrfs_previous_item(chunk_root, path, key.objectid, 2837 2826 key.type); 2827 + if (ret) 2828 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 2838 2829 if (ret < 0) 2839 2830 goto error; 2840 2831 if (ret > 0) ··· 2862 2843 else 2863 2844 BUG_ON(ret); 2864 2845 } 2846 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 2865 2847 2866 2848 if (found_key.offset == 0) 2867 2849 break; ··· 3319 3299 goto error; 3320 3300 } 3321 3301 3302 + mutex_lock(&fs_info->delete_unused_bgs_mutex); 3322 3303 ret = btrfs_search_slot(NULL, chunk_root, &key, path, 0, 0); 3323 - if (ret < 0) 3304 + if (ret < 0) { 3305 + mutex_unlock(&fs_info->delete_unused_bgs_mutex); 3324 3306 goto error; 3307 + } 3325 3308 3326 3309 /* 3327 3310 * this shouldn't happen, it means the last relocate ··· 3336 3313 ret = btrfs_previous_item(chunk_root, path, 0, 3337 3314 BTRFS_CHUNK_ITEM_KEY); 3338 3315 if (ret) { 3316 + mutex_unlock(&fs_info->delete_unused_bgs_mutex); 3339 3317 ret = 0; 3340 3318 break; 3341 3319 } ··· 3345 3321 slot = path->slots[0]; 3346 3322 btrfs_item_key_to_cpu(leaf, &found_key, slot); 3347 3323 3348 - if (found_key.objectid != key.objectid) 3324 + if (found_key.objectid != key.objectid) { 3325 + mutex_unlock(&fs_info->delete_unused_bgs_mutex); 3349 3326 break; 3327 + } 3350 3328 3351 3329 chunk = btrfs_item_ptr(leaf, slot, struct btrfs_chunk); 3352 3330 ··· 3361 3335 ret = should_balance_chunk(chunk_root, leaf, chunk, 3362 3336 found_key.offset); 3363 3337 btrfs_release_path(path); 3364 - if (!ret) 3338 + if (!ret) { 3339 + mutex_unlock(&fs_info->delete_unused_bgs_mutex); 3365 3340 goto loop; 3341 + } 3366 3342 3367 3343 if (counting) { 3344 + mutex_unlock(&fs_info->delete_unused_bgs_mutex); 3368 3345 spin_lock(&fs_info->balance_lock); 3369 3346 bctl->stat.expected++; 3370 3347 spin_unlock(&fs_info->balance_lock); ··· 3377 3348 ret = btrfs_relocate_chunk(chunk_root, 3378 3349 found_key.objectid, 3379 3350 found_key.offset); 3351 + mutex_unlock(&fs_info->delete_unused_bgs_mutex); 3380 3352 if (ret && ret != -ENOSPC) 3381 3353 goto error; 3382 3354 if (ret == -ENOSPC) { ··· 4117 4087 key.type = BTRFS_DEV_EXTENT_KEY; 4118 4088 4119 4089 do { 4090 + mutex_lock(&root->fs_info->delete_unused_bgs_mutex); 4120 4091 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 4121 - if (ret < 0) 4092 + if (ret < 0) { 4093 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 4122 4094 goto done; 4095 + } 4123 4096 4124 4097 ret = btrfs_previous_item(root, path, 0, key.type); 4098 + if (ret) 4099 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 4125 4100 if (ret < 0) 4126 4101 goto done; 4127 4102 if (ret) { ··· 4140 4105 btrfs_item_key_to_cpu(l, &key, path->slots[0]); 4141 4106 4142 4107 if (key.objectid != device->devid) { 4108 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 4143 4109 btrfs_release_path(path); 4144 4110 break; 4145 4111 } ··· 4149 4113 length = btrfs_dev_extent_length(l, dev_extent); 4150 4114 4151 4115 if (key.offset + length <= new_size) { 4116 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 4152 4117 btrfs_release_path(path); 4153 4118 break; 4154 4119 } ··· 4159 4122 btrfs_release_path(path); 4160 4123 4161 4124 ret = btrfs_relocate_chunk(root, chunk_objectid, chunk_offset); 4125 + mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); 4162 4126 if (ret && ret != -ENOSPC) 4163 4127 goto done; 4164 4128 if (ret == -ENOSPC) ··· 5753 5715 static void btrfs_end_bio(struct bio *bio, int err) 5754 5716 { 5755 5717 struct btrfs_bio *bbio = bio->bi_private; 5756 - struct btrfs_device *dev = bbio->stripes[0].dev; 5757 5718 int is_orig_bio = 0; 5758 5719 5759 5720 if (err) { ··· 5760 5723 if (err == -EIO || err == -EREMOTEIO) { 5761 5724 unsigned int stripe_index = 5762 5725 btrfs_io_bio(bio)->stripe_index; 5726 + struct btrfs_device *dev; 5763 5727 5764 5728 BUG_ON(stripe_index >= bbio->num_stripes); 5765 5729 dev = bbio->stripes[stripe_index].dev;
+1
fs/compat_ioctl.c
··· 896 896 /* 'X' - originally XFS but some now in the VFS */ 897 897 COMPATIBLE_IOCTL(FIFREEZE) 898 898 COMPATIBLE_IOCTL(FITHAW) 899 + COMPATIBLE_IOCTL(FITRIM) 899 900 COMPATIBLE_IOCTL(KDGETKEYCODE) 900 901 COMPATIBLE_IOCTL(KDSETKEYCODE) 901 902 COMPATIBLE_IOCTL(KDGKBTYPE)
+5 -2
fs/dcache.c
··· 642 642 643 643 /* 644 644 * If we have a d_op->d_delete() operation, we sould not 645 - * let the dentry count go to zero, so use "put__or_lock". 645 + * let the dentry count go to zero, so use "put_or_lock". 646 646 */ 647 647 if (unlikely(dentry->d_flags & DCACHE_OP_DELETE)) 648 648 return lockref_put_or_lock(&dentry->d_lockref); ··· 697 697 */ 698 698 smp_rmb(); 699 699 d_flags = ACCESS_ONCE(dentry->d_flags); 700 - d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST; 700 + d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST | DCACHE_DISCONNECTED; 701 701 702 702 /* Nothing to do? Dropping the reference was all we needed? */ 703 703 if (d_flags == (DCACHE_REFERENCED | DCACHE_LRU_LIST) && !d_unhashed(dentry)) ··· 774 774 775 775 /* Unreachable? Get rid of it */ 776 776 if (unlikely(d_unhashed(dentry))) 777 + goto kill_it; 778 + 779 + if (unlikely(dentry->d_flags & DCACHE_DISCONNECTED)) 777 780 goto kill_it; 778 781 779 782 if (unlikely(dentry->d_flags & DCACHE_OP_DELETE)) {
-1
fs/ecryptfs/file.c
··· 325 325 return rc; 326 326 327 327 switch (cmd) { 328 - case FITRIM: 329 328 case FS_IOC32_GETFLAGS: 330 329 case FS_IOC32_SETFLAGS: 331 330 case FS_IOC32_GETVERSION:
+3 -3
fs/ext4/extents.c
··· 504 504 struct buffer_head *bh; 505 505 int err; 506 506 507 - bh = sb_getblk(inode->i_sb, pblk); 507 + bh = sb_getblk_gfp(inode->i_sb, pblk, __GFP_MOVABLE | GFP_NOFS); 508 508 if (unlikely(!bh)) 509 509 return ERR_PTR(-ENOMEM); 510 510 ··· 1089 1089 err = -EIO; 1090 1090 goto cleanup; 1091 1091 } 1092 - bh = sb_getblk(inode->i_sb, newblock); 1092 + bh = sb_getblk_gfp(inode->i_sb, newblock, __GFP_MOVABLE | GFP_NOFS); 1093 1093 if (unlikely(!bh)) { 1094 1094 err = -ENOMEM; 1095 1095 goto cleanup; ··· 1283 1283 if (newblock == 0) 1284 1284 return err; 1285 1285 1286 - bh = sb_getblk(inode->i_sb, newblock); 1286 + bh = sb_getblk_gfp(inode->i_sb, newblock, __GFP_MOVABLE | GFP_NOFS); 1287 1287 if (unlikely(!bh)) 1288 1288 return -ENOMEM; 1289 1289 lock_buffer(bh);
+18 -4
fs/ext4/inode.c
··· 1323 1323 unsigned int offset, 1324 1324 unsigned int length) 1325 1325 { 1326 - int to_release = 0; 1326 + int to_release = 0, contiguous_blks = 0; 1327 1327 struct buffer_head *head, *bh; 1328 1328 unsigned int curr_off = 0; 1329 1329 struct inode *inode = page->mapping->host; ··· 1344 1344 1345 1345 if ((offset <= curr_off) && (buffer_delay(bh))) { 1346 1346 to_release++; 1347 + contiguous_blks++; 1347 1348 clear_buffer_delay(bh); 1349 + } else if (contiguous_blks) { 1350 + lblk = page->index << 1351 + (PAGE_CACHE_SHIFT - inode->i_blkbits); 1352 + lblk += (curr_off >> inode->i_blkbits) - 1353 + contiguous_blks; 1354 + ext4_es_remove_extent(inode, lblk, contiguous_blks); 1355 + contiguous_blks = 0; 1348 1356 } 1349 1357 curr_off = next_off; 1350 1358 } while ((bh = bh->b_this_page) != head); 1351 1359 1352 - if (to_release) { 1360 + if (contiguous_blks) { 1353 1361 lblk = page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); 1354 - ext4_es_remove_extent(inode, lblk, to_release); 1362 + lblk += (curr_off >> inode->i_blkbits) - contiguous_blks; 1363 + ext4_es_remove_extent(inode, lblk, contiguous_blks); 1355 1364 } 1356 1365 1357 1366 /* If we have released all the blocks belonging to a cluster, then we ··· 4353 4344 int inode_size = EXT4_INODE_SIZE(sb); 4354 4345 4355 4346 oi.orig_ino = orig_ino; 4356 - ino = (orig_ino & ~(inodes_per_block - 1)) + 1; 4347 + /* 4348 + * Calculate the first inode in the inode table block. Inode 4349 + * numbers are one-based. That is, the first inode in a block 4350 + * (assuming 4k blocks and 256 byte inodes) is (n*16 + 1). 4351 + */ 4352 + ino = ((orig_ino - 1) & ~(inodes_per_block - 1)) + 1; 4357 4353 for (i = 0; i < inodes_per_block; i++, ino++, buf += inode_size) { 4358 4354 if (ino == orig_ino) 4359 4355 continue;
-1
fs/ext4/ioctl.c
··· 755 755 return err; 756 756 } 757 757 case EXT4_IOC_MOVE_EXT: 758 - case FITRIM: 759 758 case EXT4_IOC_RESIZE_FS: 760 759 case EXT4_IOC_PRECACHE_EXTENTS: 761 760 case EXT4_IOC_SET_ENCRYPTION_POLICY:
+5 -11
fs/ext4/mballoc.c
··· 4816 4816 /* 4817 4817 * blocks being freed are metadata. these blocks shouldn't 4818 4818 * be used until this transaction is committed 4819 + * 4820 + * We use __GFP_NOFAIL because ext4_free_blocks() is not allowed 4821 + * to fail. 4819 4822 */ 4820 - retry: 4821 - new_entry = kmem_cache_alloc(ext4_free_data_cachep, GFP_NOFS); 4822 - if (!new_entry) { 4823 - /* 4824 - * We use a retry loop because 4825 - * ext4_free_blocks() is not allowed to fail. 4826 - */ 4827 - cond_resched(); 4828 - congestion_wait(BLK_RW_ASYNC, HZ/50); 4829 - goto retry; 4830 - } 4823 + new_entry = kmem_cache_alloc(ext4_free_data_cachep, 4824 + GFP_NOFS|__GFP_NOFAIL); 4831 4825 new_entry->efd_start_cluster = bit; 4832 4826 new_entry->efd_group = block_group; 4833 4827 new_entry->efd_count = count_clusters;
+14 -3
fs/ext4/migrate.c
··· 620 620 struct ext4_inode_info *ei = EXT4_I(inode); 621 621 struct ext4_extent *ex; 622 622 unsigned int i, len; 623 + ext4_lblk_t start, end; 623 624 ext4_fsblk_t blk; 624 625 handle_t *handle; 625 626 int ret; ··· 633 632 if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, 634 633 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) 635 634 return -EOPNOTSUPP; 635 + 636 + /* 637 + * In order to get correct extent info, force all delayed allocation 638 + * blocks to be allocated, otherwise delayed allocation blocks may not 639 + * be reflected and bypass the checks on extent header. 640 + */ 641 + if (test_opt(inode->i_sb, DELALLOC)) 642 + ext4_alloc_da_blocks(inode); 636 643 637 644 handle = ext4_journal_start(inode, EXT4_HT_MIGRATE, 1); 638 645 if (IS_ERR(handle)) ··· 659 650 goto errout; 660 651 } 661 652 if (eh->eh_entries == 0) 662 - blk = len = 0; 653 + blk = len = start = end = 0; 663 654 else { 664 655 len = le16_to_cpu(ex->ee_len); 665 656 blk = ext4_ext_pblock(ex); 666 - if (len > EXT4_NDIR_BLOCKS) { 657 + start = le32_to_cpu(ex->ee_block); 658 + end = start + len - 1; 659 + if (end >= EXT4_NDIR_BLOCKS) { 667 660 ret = -EOPNOTSUPP; 668 661 goto errout; 669 662 } ··· 673 662 674 663 ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS); 675 664 memset(ei->i_data, 0, sizeof(ei->i_data)); 676 - for (i=0; i < len; i++) 665 + for (i = start; i <= end; i++) 677 666 ei->i_data[i] = cpu_to_le32(blk++); 678 667 ext4_mark_inode_dirty(handle, inode); 679 668 errout:
+95
fs/hpfs/alloc.c
··· 484 484 a->btree.first_free = cpu_to_le16(8); 485 485 return a; 486 486 } 487 + 488 + static unsigned find_run(__le32 *bmp, unsigned *idx) 489 + { 490 + unsigned len; 491 + while (tstbits(bmp, *idx, 1)) { 492 + (*idx)++; 493 + if (unlikely(*idx >= 0x4000)) 494 + return 0; 495 + } 496 + len = 1; 497 + while (!tstbits(bmp, *idx + len, 1)) 498 + len++; 499 + return len; 500 + } 501 + 502 + static int do_trim(struct super_block *s, secno start, unsigned len, secno limit_start, secno limit_end, unsigned minlen, unsigned *result) 503 + { 504 + int err; 505 + secno end; 506 + if (fatal_signal_pending(current)) 507 + return -EINTR; 508 + end = start + len; 509 + if (start < limit_start) 510 + start = limit_start; 511 + if (end > limit_end) 512 + end = limit_end; 513 + if (start >= end) 514 + return 0; 515 + if (end - start < minlen) 516 + return 0; 517 + err = sb_issue_discard(s, start, end - start, GFP_NOFS, 0); 518 + if (err) 519 + return err; 520 + *result += end - start; 521 + return 0; 522 + } 523 + 524 + int hpfs_trim_fs(struct super_block *s, u64 start, u64 end, u64 minlen, unsigned *result) 525 + { 526 + int err = 0; 527 + struct hpfs_sb_info *sbi = hpfs_sb(s); 528 + unsigned idx, len, start_bmp, end_bmp; 529 + __le32 *bmp; 530 + struct quad_buffer_head qbh; 531 + 532 + *result = 0; 533 + if (!end || end > sbi->sb_fs_size) 534 + end = sbi->sb_fs_size; 535 + if (start >= sbi->sb_fs_size) 536 + return 0; 537 + if (minlen > 0x4000) 538 + return 0; 539 + if (start < sbi->sb_dirband_start + sbi->sb_dirband_size && end > sbi->sb_dirband_start) { 540 + hpfs_lock(s); 541 + if (s->s_flags & MS_RDONLY) { 542 + err = -EROFS; 543 + goto unlock_1; 544 + } 545 + if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { 546 + err = -EIO; 547 + goto unlock_1; 548 + } 549 + idx = 0; 550 + while ((len = find_run(bmp, &idx)) && !err) { 551 + err = do_trim(s, sbi->sb_dirband_start + idx * 4, len * 4, start, end, minlen, result); 552 + idx += len; 553 + } 554 + hpfs_brelse4(&qbh); 555 + unlock_1: 556 + hpfs_unlock(s); 557 + } 558 + start_bmp = start >> 14; 559 + end_bmp = (end + 0x3fff) >> 14; 560 + while (start_bmp < end_bmp && !err) { 561 + hpfs_lock(s); 562 + if (s->s_flags & MS_RDONLY) { 563 + err = -EROFS; 564 + goto unlock_2; 565 + } 566 + if (!(bmp = hpfs_map_bitmap(s, start_bmp, &qbh, "trim"))) { 567 + err = -EIO; 568 + goto unlock_2; 569 + } 570 + idx = 0; 571 + while ((len = find_run(bmp, &idx)) && !err) { 572 + err = do_trim(s, (start_bmp << 14) + idx, len, start, end, minlen, result); 573 + idx += len; 574 + } 575 + hpfs_brelse4(&qbh); 576 + unlock_2: 577 + hpfs_unlock(s); 578 + start_bmp++; 579 + } 580 + return err; 581 + }
+1
fs/hpfs/dir.c
··· 327 327 .iterate = hpfs_readdir, 328 328 .release = hpfs_dir_release, 329 329 .fsync = hpfs_file_fsync, 330 + .unlocked_ioctl = hpfs_ioctl, 330 331 };
+1
fs/hpfs/file.c
··· 203 203 .release = hpfs_file_release, 204 204 .fsync = hpfs_file_fsync, 205 205 .splice_read = generic_file_splice_read, 206 + .unlocked_ioctl = hpfs_ioctl, 206 207 }; 207 208 208 209 const struct inode_operations hpfs_file_iops =
+4
fs/hpfs/hpfs_fn.h
··· 18 18 #include <linux/pagemap.h> 19 19 #include <linux/buffer_head.h> 20 20 #include <linux/slab.h> 21 + #include <linux/sched.h> 22 + #include <linux/blkdev.h> 21 23 #include <asm/unaligned.h> 22 24 23 25 #include "hpfs.h" ··· 202 200 struct dnode *hpfs_alloc_dnode(struct super_block *, secno, dnode_secno *, struct quad_buffer_head *); 203 201 struct fnode *hpfs_alloc_fnode(struct super_block *, secno, fnode_secno *, struct buffer_head **); 204 202 struct anode *hpfs_alloc_anode(struct super_block *, secno, anode_secno *, struct buffer_head **); 203 + int hpfs_trim_fs(struct super_block *, u64, u64, u64, unsigned *); 205 204 206 205 /* anode.c */ 207 206 ··· 321 318 void hpfs_error(struct super_block *, const char *, ...); 322 319 int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *); 323 320 unsigned hpfs_get_free_dnodes(struct super_block *); 321 + long hpfs_ioctl(struct file *file, unsigned cmd, unsigned long arg); 324 322 325 323 /* 326 324 * local time (HPFS) to GMT (Unix)
+40 -7
fs/hpfs/super.c
··· 52 52 } 53 53 54 54 /* Filesystem error... */ 55 - static char err_buf[1024]; 56 - 57 55 void hpfs_error(struct super_block *s, const char *fmt, ...) 58 56 { 57 + struct va_format vaf; 59 58 va_list args; 60 59 61 60 va_start(args, fmt); 62 - vsnprintf(err_buf, sizeof(err_buf), fmt, args); 61 + 62 + vaf.fmt = fmt; 63 + vaf.va = &args; 64 + 65 + pr_err("filesystem error: %pV", &vaf); 66 + 63 67 va_end(args); 64 68 65 - pr_err("filesystem error: %s", err_buf); 66 69 if (!hpfs_sb(s)->sb_was_error) { 67 70 if (hpfs_sb(s)->sb_err == 2) { 68 71 pr_cont("; crashing the system because you wanted it\n"); ··· 199 196 return 0; 200 197 } 201 198 199 + 200 + long hpfs_ioctl(struct file *file, unsigned cmd, unsigned long arg) 201 + { 202 + switch (cmd) { 203 + case FITRIM: { 204 + struct fstrim_range range; 205 + secno n_trimmed; 206 + int r; 207 + if (!capable(CAP_SYS_ADMIN)) 208 + return -EPERM; 209 + if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range))) 210 + return -EFAULT; 211 + r = hpfs_trim_fs(file_inode(file)->i_sb, range.start >> 9, (range.start + range.len) >> 9, (range.minlen + 511) >> 9, &n_trimmed); 212 + if (r) 213 + return r; 214 + range.len = (u64)n_trimmed << 9; 215 + if (copy_to_user((struct fstrim_range __user *)arg, &range, sizeof(range))) 216 + return -EFAULT; 217 + return 0; 218 + } 219 + default: { 220 + return -ENOIOCTLCMD; 221 + } 222 + } 223 + } 224 + 225 + 202 226 static struct kmem_cache * hpfs_inode_cachep; 203 227 204 228 static struct inode *hpfs_alloc_inode(struct super_block *sb) 205 229 { 206 230 struct hpfs_inode_info *ei; 207 - ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, GFP_NOFS); 231 + ei = kmem_cache_alloc(hpfs_inode_cachep, GFP_NOFS); 208 232 if (!ei) 209 233 return NULL; 210 234 ei->vfs_inode.i_version = 1; ··· 454 424 int o; 455 425 struct hpfs_sb_info *sbi = hpfs_sb(s); 456 426 char *new_opts = kstrdup(data, GFP_KERNEL); 457 - 427 + 428 + if (!new_opts) 429 + return -ENOMEM; 430 + 458 431 sync_filesystem(s); 459 432 460 433 *flags |= MS_NOATIME; 461 - 434 + 462 435 hpfs_lock(s); 463 436 uid = sbi->sb_uid; gid = sbi->sb_gid; 464 437 umask = 0777 & ~sbi->sb_mode;
-3
fs/jfs/ioctl.c
··· 180 180 case JFS_IOC_SETFLAGS32: 181 181 cmd = JFS_IOC_SETFLAGS; 182 182 break; 183 - case FITRIM: 184 - cmd = FITRIM; 185 - break; 186 183 } 187 184 return jfs_ioctl(filp, cmd, arg); 188 185 }
-1
fs/nilfs2/ioctl.c
··· 1369 1369 case NILFS_IOCTL_SYNC: 1370 1370 case NILFS_IOCTL_RESIZE: 1371 1371 case NILFS_IOCTL_SET_ALLOC_RANGE: 1372 - case FITRIM: 1373 1372 break; 1374 1373 default: 1375 1374 return -ENOIOCTLCMD;
-1
fs/ocfs2/ioctl.c
··· 980 980 case OCFS2_IOC_GROUP_EXTEND: 981 981 case OCFS2_IOC_GROUP_ADD: 982 982 case OCFS2_IOC_GROUP_ADD64: 983 - case FITRIM: 984 983 break; 985 984 case OCFS2_IOC_REFLINK: 986 985 if (copy_from_user(&args, argp, sizeof(args)))
+3
fs/overlayfs/inode.c
··· 343 343 struct path realpath; 344 344 enum ovl_path_type type; 345 345 346 + if (d_is_dir(dentry)) 347 + return d_backing_inode(dentry); 348 + 346 349 type = ovl_path_real(dentry, &realpath); 347 350 if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) { 348 351 err = ovl_want_write(dentry);
+14 -10
include/linux/acpi.h
··· 58 58 acpi_fwnode_handle(adev) : NULL) 59 59 #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) 60 60 61 + /** 62 + * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with 63 + * the PCI-defined class-code information 64 + * 65 + * @_cls : the class, subclass, prog-if triple for this device 66 + * @_msk : the class mask for this device 67 + * 68 + * This macro is used to create a struct acpi_device_id that matches a 69 + * specific PCI class. The .id and .driver_data fields will be left 70 + * initialized with the default value. 71 + */ 72 + #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (_cls), .cls_msk = (_msk), 73 + 61 74 static inline bool has_acpi_companion(struct device *dev) 62 75 { 63 76 return is_acpi_node(dev->fwnode); ··· 322 309 323 310 int acpi_resources_are_enforced(void); 324 311 325 - int acpi_reserve_region(u64 start, unsigned int length, u8 space_id, 326 - unsigned long flags, char *desc); 327 - 328 312 #ifdef CONFIG_HIBERNATION 329 313 void __init acpi_no_s4_hw_signature(void); 330 314 #endif ··· 456 446 #define ACPI_COMPANION(dev) (NULL) 457 447 #define ACPI_COMPANION_SET(dev, adev) do { } while (0) 458 448 #define ACPI_HANDLE(dev) (NULL) 449 + #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0), 459 450 460 451 struct fwnode_handle; 461 452 ··· 516 505 const char *name) 517 506 { 518 507 return 0; 519 - } 520 - 521 - static inline int acpi_reserve_region(u64 start, unsigned int length, 522 - u8 space_id, unsigned long flags, 523 - char *desc) 524 - { 525 - return -ENXIO; 526 508 } 527 509 528 510 struct acpi_table_header;
+7
include/linux/buffer_head.h
··· 317 317 return __getblk_gfp(sb->s_bdev, block, sb->s_blocksize, __GFP_MOVABLE); 318 318 } 319 319 320 + 321 + static inline struct buffer_head * 322 + sb_getblk_gfp(struct super_block *sb, sector_t block, gfp_t gfp) 323 + { 324 + return __getblk_gfp(sb->s_bdev, block, sb->s_blocksize, gfp); 325 + } 326 + 320 327 static inline struct buffer_head * 321 328 sb_find_get_block(struct super_block *sb, sector_t block) 322 329 {
+3
include/linux/ceph/messenger.h
··· 8 8 #include <linux/radix-tree.h> 9 9 #include <linux/uio.h> 10 10 #include <linux/workqueue.h> 11 + #include <net/net_namespace.h> 11 12 12 13 #include <linux/ceph/types.h> 13 14 #include <linux/ceph/buffer.h> ··· 57 56 struct ceph_entity_addr my_enc_addr; 58 57 59 58 atomic_t stopping; 59 + possible_net_t net; 60 60 bool nocrc; 61 61 bool tcp_nodelay; 62 62 ··· 269 267 u64 required_features, 270 268 bool nocrc, 271 269 bool tcp_nodelay); 270 + extern void ceph_messenger_fini(struct ceph_messenger *msgr); 272 271 273 272 extern void ceph_con_init(struct ceph_connection *con, void *private, 274 273 const struct ceph_connection_operations *ops,
+1 -1
include/linux/compiler.h
··· 17 17 # define __release(x) __context__(x,-1) 18 18 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0) 19 19 # define __percpu __attribute__((noderef, address_space(3))) 20 + # define __pmem __attribute__((noderef, address_space(5))) 20 21 #ifdef CONFIG_SPARSE_RCU_POINTER 21 22 # define __rcu __attribute__((noderef, address_space(4))) 22 23 #else 23 24 # define __rcu 24 - # define __pmem __attribute__((noderef, address_space(5))) 25 25 #endif 26 26 extern void __chk_user_ptr(const volatile void __user *); 27 27 extern void __chk_io_ptr(const volatile void __iomem *);
+6 -1
include/linux/irqdesc.h
··· 87 87 const char *name; 88 88 } ____cacheline_internodealigned_in_smp; 89 89 90 - #ifndef CONFIG_SPARSE_IRQ 90 + #ifdef CONFIG_SPARSE_IRQ 91 + extern void irq_lock_sparse(void); 92 + extern void irq_unlock_sparse(void); 93 + #else 94 + static inline void irq_lock_sparse(void) { } 95 + static inline void irq_unlock_sparse(void) { } 91 96 extern struct irq_desc irq_desc[NR_IRQS]; 92 97 #endif 93 98
+2
include/linux/mod_devicetable.h
··· 189 189 struct acpi_device_id { 190 190 __u8 id[ACPI_ID_LEN]; 191 191 kernel_ulong_t driver_data; 192 + __u32 cls; 193 + __u32 cls_msk; 192 194 }; 193 195 194 196 #define PNP_ID_LEN 8
+1
include/linux/regulator/driver.h
··· 148 148 int (*get_current_limit) (struct regulator_dev *); 149 149 150 150 int (*set_input_current_limit) (struct regulator_dev *, int lim_uA); 151 + int (*set_over_current_protection) (struct regulator_dev *); 151 152 152 153 /* enable/disable regulator */ 153 154 int (*enable) (struct regulator_dev *);
+1
include/linux/regulator/machine.h
··· 147 147 unsigned ramp_disable:1; /* disable ramp delay */ 148 148 unsigned soft_start:1; /* ramp voltage slowly */ 149 149 unsigned pull_down:1; /* pull down resistor when regulator off */ 150 + unsigned over_current_protection:1; /* auto disable on over current */ 150 151 }; 151 152 152 153 /**
+4
include/linux/rtc/sirfsoc_rtciobrg.h
··· 9 9 #ifndef _SIRFSOC_RTC_IOBRG_H_ 10 10 #define _SIRFSOC_RTC_IOBRG_H_ 11 11 12 + struct regmap_config; 13 + 12 14 extern void sirfsoc_rtc_iobrg_besyncing(void); 13 15 14 16 extern u32 sirfsoc_rtc_iobrg_readl(u32 addr); 15 17 16 18 extern void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr); 19 + struct regmap *devm_regmap_init_iobg(struct device *dev, 20 + const struct regmap_config *config); 17 21 18 22 #endif
+5 -2
include/linux/tick.h
··· 67 67 static inline void tick_broadcast_control(enum tick_broadcast_mode mode) { } 68 68 #endif /* BROADCAST */ 69 69 70 - #if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) && defined(CONFIG_TICK_ONESHOT) 70 + #ifdef CONFIG_GENERIC_CLOCKEVENTS 71 71 extern int tick_broadcast_oneshot_control(enum tick_broadcast_state state); 72 72 #else 73 - static inline int tick_broadcast_oneshot_control(enum tick_broadcast_state state) { return 0; } 73 + static inline int tick_broadcast_oneshot_control(enum tick_broadcast_state state) 74 + { 75 + return 0; 76 + } 74 77 #endif 75 78 76 79 static inline void tick_broadcast_enable(void)
-1
include/linux/timekeeping.h
··· 145 145 } 146 146 #endif 147 147 148 - #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) 149 148 #define ktime_get_real_ts64(ts) getnstimeofday64(ts) 150 149 151 150 /*
+1 -2
kernel/auditsc.c
··· 1021 1021 * for strings that are too long, we should not have created 1022 1022 * any. 1023 1023 */ 1024 - if (unlikely((len == 0) || len > MAX_ARG_STRLEN - 1)) { 1025 - WARN_ON(1); 1024 + if (WARN_ON_ONCE(len < 0 || len > MAX_ARG_STRLEN - 1)) { 1026 1025 send_sig(SIGKILL, current, 0); 1027 1026 return -1; 1028 1027 }
+21 -1
kernel/cpu.c
··· 21 21 #include <linux/suspend.h> 22 22 #include <linux/lockdep.h> 23 23 #include <linux/tick.h> 24 + #include <linux/irq.h> 24 25 #include <trace/events/power.h> 25 26 26 27 #include "smpboot.h" ··· 393 392 smpboot_park_threads(cpu); 394 393 395 394 /* 395 + * Prevent irq alloc/free while the dying cpu reorganizes the 396 + * interrupt affinities. 397 + */ 398 + irq_lock_sparse(); 399 + 400 + /* 396 401 * So now all preempt/rcu users must observe !cpu_active(). 397 402 */ 398 - 399 403 err = __stop_machine(take_cpu_down, &tcd_param, cpumask_of(cpu)); 400 404 if (err) { 401 405 /* CPU didn't die: tell everyone. Can't complain. */ 402 406 cpu_notify_nofail(CPU_DOWN_FAILED | mod, hcpu); 407 + irq_unlock_sparse(); 403 408 goto out_release; 404 409 } 405 410 BUG_ON(cpu_online(cpu)); ··· 421 414 cpu_relax(); 422 415 smp_mb(); /* Read from cpu_dead_idle before __cpu_die(). */ 423 416 per_cpu(cpu_dead_idle, cpu) = false; 417 + 418 + /* Interrupts are moved away from the dying cpu, reenable alloc/free */ 419 + irq_unlock_sparse(); 424 420 425 421 hotplug_cpu__broadcast_tick_pull(cpu); 426 422 /* This actually kills the CPU. */ ··· 527 517 goto out_notify; 528 518 } 529 519 520 + /* 521 + * Some architectures have to walk the irq descriptors to 522 + * setup the vector space for the cpu which comes online. 523 + * Prevent irq alloc/free across the bringup. 524 + */ 525 + irq_lock_sparse(); 526 + 530 527 /* Arch-specific enabling code. */ 531 528 ret = __cpu_up(cpu, idle); 529 + 530 + irq_unlock_sparse(); 531 + 532 532 if (ret != 0) 533 533 goto out_notify; 534 534 BUG_ON(!cpu_online(cpu));
-8
kernel/events/core.c
··· 4358 4358 rcu_read_unlock(); 4359 4359 } 4360 4360 4361 - static void rb_free_rcu(struct rcu_head *rcu_head) 4362 - { 4363 - struct ring_buffer *rb; 4364 - 4365 - rb = container_of(rcu_head, struct ring_buffer, rcu_head); 4366 - rb_free(rb); 4367 - } 4368 - 4369 4361 struct ring_buffer *ring_buffer_get(struct perf_event *event) 4370 4362 { 4371 4363 struct ring_buffer *rb;
+10
kernel/events/internal.h
··· 11 11 struct ring_buffer { 12 12 atomic_t refcount; 13 13 struct rcu_head rcu_head; 14 + struct irq_work irq_work; 14 15 #ifdef CONFIG_PERF_USE_VMALLOC 15 16 struct work_struct work; 16 17 int page_order; /* allocation order */ ··· 56 55 }; 57 56 58 57 extern void rb_free(struct ring_buffer *rb); 58 + 59 + static inline void rb_free_rcu(struct rcu_head *rcu_head) 60 + { 61 + struct ring_buffer *rb; 62 + 63 + rb = container_of(rcu_head, struct ring_buffer, rcu_head); 64 + rb_free(rb); 65 + } 66 + 59 67 extern struct ring_buffer * 60 68 rb_alloc(int nr_pages, long watermark, int cpu, int flags); 61 69 extern void perf_event_wakeup(struct perf_event *event);
+25 -2
kernel/events/ring_buffer.c
··· 221 221 rcu_read_unlock(); 222 222 } 223 223 224 + static void rb_irq_work(struct irq_work *work); 225 + 224 226 static void 225 227 ring_buffer_init(struct ring_buffer *rb, long watermark, int flags) 226 228 { ··· 243 241 244 242 INIT_LIST_HEAD(&rb->event_list); 245 243 spin_lock_init(&rb->event_lock); 244 + init_irq_work(&rb->irq_work, rb_irq_work); 245 + } 246 + 247 + static void ring_buffer_put_async(struct ring_buffer *rb) 248 + { 249 + if (!atomic_dec_and_test(&rb->refcount)) 250 + return; 251 + 252 + rb->rcu_head.next = (void *)rb; 253 + irq_work_queue(&rb->irq_work); 246 254 } 247 255 248 256 /* ··· 331 319 rb_free_aux(rb); 332 320 333 321 err: 334 - ring_buffer_put(rb); 322 + ring_buffer_put_async(rb); 335 323 handle->event = NULL; 336 324 337 325 return NULL; ··· 382 370 383 371 local_set(&rb->aux_nest, 0); 384 372 rb_free_aux(rb); 385 - ring_buffer_put(rb); 373 + ring_buffer_put_async(rb); 386 374 } 387 375 388 376 /* ··· 569 557 void rb_free_aux(struct ring_buffer *rb) 570 558 { 571 559 if (atomic_dec_and_test(&rb->aux_refcount)) 560 + irq_work_queue(&rb->irq_work); 561 + } 562 + 563 + static void rb_irq_work(struct irq_work *work) 564 + { 565 + struct ring_buffer *rb = container_of(work, struct ring_buffer, irq_work); 566 + 567 + if (!atomic_read(&rb->aux_refcount)) 572 568 __rb_free_aux(rb); 569 + 570 + if (rb->rcu_head.next == (void *)rb) 571 + call_rcu(&rb->rcu_head, rb_free_rcu); 573 572 } 574 573 575 574 #ifndef CONFIG_PERF_USE_VMALLOC
-4
kernel/irq/internals.h
··· 76 76 77 77 #ifdef CONFIG_SPARSE_IRQ 78 78 static inline void irq_mark_irq(unsigned int irq) { } 79 - extern void irq_lock_sparse(void); 80 - extern void irq_unlock_sparse(void); 81 79 #else 82 80 extern void irq_mark_irq(unsigned int irq); 83 - static inline void irq_lock_sparse(void) { } 84 - static inline void irq_unlock_sparse(void) { } 85 81 #endif 86 82 87 83 extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
+1
kernel/module.c
··· 3557 3557 mutex_lock(&module_mutex); 3558 3558 /* Unlink carefully: kallsyms could be walking list. */ 3559 3559 list_del_rcu(&mod->list); 3560 + mod_tree_remove(mod); 3560 3561 wake_up_all(&module_wq); 3561 3562 /* Wait for RCU-sched synchronizing before releasing mod->list. */ 3562 3563 synchronize_sched();
+9 -15
kernel/time/clockevents.c
··· 120 120 /* The clockevent device is getting replaced. Shut it down. */ 121 121 122 122 case CLOCK_EVT_STATE_SHUTDOWN: 123 - return dev->set_state_shutdown(dev); 123 + if (dev->set_state_shutdown) 124 + return dev->set_state_shutdown(dev); 125 + return 0; 124 126 125 127 case CLOCK_EVT_STATE_PERIODIC: 126 128 /* Core internal bug */ 127 129 if (!(dev->features & CLOCK_EVT_FEAT_PERIODIC)) 128 130 return -ENOSYS; 129 - return dev->set_state_periodic(dev); 131 + if (dev->set_state_periodic) 132 + return dev->set_state_periodic(dev); 133 + return 0; 130 134 131 135 case CLOCK_EVT_STATE_ONESHOT: 132 136 /* Core internal bug */ 133 137 if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT)) 134 138 return -ENOSYS; 135 - return dev->set_state_oneshot(dev); 139 + if (dev->set_state_oneshot) 140 + return dev->set_state_oneshot(dev); 141 + return 0; 136 142 137 143 case CLOCK_EVT_STATE_ONESHOT_STOPPED: 138 144 /* Core internal bug */ ··· 476 470 477 471 if (dev->features & CLOCK_EVT_FEAT_DUMMY) 478 472 return 0; 479 - 480 - /* New state-specific callbacks */ 481 - if (!dev->set_state_shutdown) 482 - return -EINVAL; 483 - 484 - if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) && 485 - !dev->set_state_periodic) 486 - return -EINVAL; 487 - 488 - if ((dev->features & CLOCK_EVT_FEAT_ONESHOT) && 489 - !dev->set_state_oneshot) 490 - return -EINVAL; 491 473 492 474 return 0; 493 475 }
+108 -55
kernel/time/tick-broadcast.c
··· 159 159 { 160 160 struct clock_event_device *bc = tick_broadcast_device.evtdev; 161 161 unsigned long flags; 162 - int ret; 162 + int ret = 0; 163 163 164 164 raw_spin_lock_irqsave(&tick_broadcast_lock, flags); 165 165 ··· 221 221 * If we kept the cpu in the broadcast mask, 222 222 * tell the caller to leave the per cpu device 223 223 * in shutdown state. The periodic interrupt 224 - * is delivered by the broadcast device. 224 + * is delivered by the broadcast device, if 225 + * the broadcast device exists and is not 226 + * hrtimer based. 225 227 */ 226 - ret = cpumask_test_cpu(cpu, tick_broadcast_mask); 228 + if (bc && !(bc->features & CLOCK_EVT_FEAT_HRTIMER)) 229 + ret = cpumask_test_cpu(cpu, tick_broadcast_mask); 227 230 break; 228 231 default: 229 - /* Nothing to do */ 230 - ret = 0; 231 232 break; 232 233 } 233 234 } ··· 266 265 * Check, if the current cpu is in the mask 267 266 */ 268 267 if (cpumask_test_cpu(cpu, mask)) { 268 + struct clock_event_device *bc = tick_broadcast_device.evtdev; 269 + 269 270 cpumask_clear_cpu(cpu, mask); 270 - local = true; 271 + /* 272 + * We only run the local handler, if the broadcast 273 + * device is not hrtimer based. Otherwise we run into 274 + * a hrtimer recursion. 275 + * 276 + * local timer_interrupt() 277 + * local_handler() 278 + * expire_hrtimers() 279 + * bc_handler() 280 + * local_handler() 281 + * expire_hrtimers() 282 + */ 283 + local = !(bc->features & CLOCK_EVT_FEAT_HRTIMER); 271 284 } 272 285 273 286 if (!cpumask_empty(mask)) { ··· 316 301 bool bc_local; 317 302 318 303 raw_spin_lock(&tick_broadcast_lock); 304 + 305 + /* Handle spurious interrupts gracefully */ 306 + if (clockevent_state_shutdown(tick_broadcast_device.evtdev)) { 307 + raw_spin_unlock(&tick_broadcast_lock); 308 + return; 309 + } 310 + 319 311 bc_local = tick_do_periodic_broadcast(); 320 312 321 313 if (clockevent_state_oneshot(dev)) { ··· 381 359 case TICK_BROADCAST_ON: 382 360 cpumask_set_cpu(cpu, tick_broadcast_on); 383 361 if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) { 384 - if (tick_broadcast_device.mode == 385 - TICKDEV_MODE_PERIODIC) 362 + /* 363 + * Only shutdown the cpu local device, if: 364 + * 365 + * - the broadcast device exists 366 + * - the broadcast device is not a hrtimer based one 367 + * - the broadcast device is in periodic mode to 368 + * avoid a hickup during switch to oneshot mode 369 + */ 370 + if (bc && !(bc->features & CLOCK_EVT_FEAT_HRTIMER) && 371 + tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) 386 372 clockevents_shutdown(dev); 387 373 } 388 374 break; ··· 409 379 break; 410 380 } 411 381 412 - if (cpumask_empty(tick_broadcast_mask)) { 413 - if (!bc_stopped) 414 - clockevents_shutdown(bc); 415 - } else if (bc_stopped) { 416 - if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) 417 - tick_broadcast_start_periodic(bc); 418 - else 419 - tick_broadcast_setup_oneshot(bc); 382 + if (bc) { 383 + if (cpumask_empty(tick_broadcast_mask)) { 384 + if (!bc_stopped) 385 + clockevents_shutdown(bc); 386 + } else if (bc_stopped) { 387 + if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) 388 + tick_broadcast_start_periodic(bc); 389 + else 390 + tick_broadcast_setup_oneshot(bc); 391 + } 420 392 } 421 393 raw_spin_unlock(&tick_broadcast_lock); 422 394 } ··· 694 662 clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN); 695 663 } 696 664 697 - /** 698 - * tick_broadcast_oneshot_control - Enter/exit broadcast oneshot mode 699 - * @state: The target state (enter/exit) 700 - * 701 - * The system enters/leaves a state, where affected devices might stop 702 - * Returns 0 on success, -EBUSY if the cpu is used to broadcast wakeups. 703 - * 704 - * Called with interrupts disabled, so clockevents_lock is not 705 - * required here because the local clock event device cannot go away 706 - * under us. 707 - */ 708 - int tick_broadcast_oneshot_control(enum tick_broadcast_state state) 665 + int __tick_broadcast_oneshot_control(enum tick_broadcast_state state) 709 666 { 710 667 struct clock_event_device *bc, *dev; 711 - struct tick_device *td; 712 668 int cpu, ret = 0; 713 669 ktime_t now; 714 670 715 671 /* 716 - * Periodic mode does not care about the enter/exit of power 717 - * states 672 + * If there is no broadcast device, tell the caller not to go 673 + * into deep idle. 718 674 */ 719 - if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) 720 - return 0; 675 + if (!tick_broadcast_device.evtdev) 676 + return -EBUSY; 721 677 722 - /* 723 - * We are called with preemtion disabled from the depth of the 724 - * idle code, so we can't be moved away. 725 - */ 726 - td = this_cpu_ptr(&tick_cpu_device); 727 - dev = td->evtdev; 728 - 729 - if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) 730 - return 0; 678 + dev = this_cpu_ptr(&tick_cpu_device)->evtdev; 731 679 732 680 raw_spin_lock(&tick_broadcast_lock); 733 681 bc = tick_broadcast_device.evtdev; 734 682 cpu = smp_processor_id(); 735 683 736 684 if (state == TICK_BROADCAST_ENTER) { 685 + /* 686 + * If the current CPU owns the hrtimer broadcast 687 + * mechanism, it cannot go deep idle and we do not add 688 + * the CPU to the broadcast mask. We don't have to go 689 + * through the EXIT path as the local timer is not 690 + * shutdown. 691 + */ 692 + ret = broadcast_needs_cpu(bc, cpu); 693 + if (ret) 694 + goto out; 695 + 696 + /* 697 + * If the broadcast device is in periodic mode, we 698 + * return. 699 + */ 700 + if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) { 701 + /* If it is a hrtimer based broadcast, return busy */ 702 + if (bc->features & CLOCK_EVT_FEAT_HRTIMER) 703 + ret = -EBUSY; 704 + goto out; 705 + } 706 + 737 707 if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_oneshot_mask)) { 738 708 WARN_ON_ONCE(cpumask_test_cpu(cpu, tick_broadcast_pending_mask)); 709 + 710 + /* Conditionally shut down the local timer. */ 739 711 broadcast_shutdown_local(bc, dev); 712 + 740 713 /* 741 714 * We only reprogram the broadcast timer if we 742 715 * did not mark ourself in the force mask and 743 716 * if the cpu local event is earlier than the 744 717 * broadcast event. If the current CPU is in 745 718 * the force mask, then we are going to be 746 - * woken by the IPI right away. 719 + * woken by the IPI right away; we return 720 + * busy, so the CPU does not try to go deep 721 + * idle. 747 722 */ 748 - if (!cpumask_test_cpu(cpu, tick_broadcast_force_mask) && 749 - dev->next_event.tv64 < bc->next_event.tv64) 723 + if (cpumask_test_cpu(cpu, tick_broadcast_force_mask)) { 724 + ret = -EBUSY; 725 + } else if (dev->next_event.tv64 < bc->next_event.tv64) { 750 726 tick_broadcast_set_event(bc, cpu, dev->next_event); 727 + /* 728 + * In case of hrtimer broadcasts the 729 + * programming might have moved the 730 + * timer to this cpu. If yes, remove 731 + * us from the broadcast mask and 732 + * return busy. 733 + */ 734 + ret = broadcast_needs_cpu(bc, cpu); 735 + if (ret) { 736 + cpumask_clear_cpu(cpu, 737 + tick_broadcast_oneshot_mask); 738 + } 739 + } 751 740 } 752 - /* 753 - * If the current CPU owns the hrtimer broadcast 754 - * mechanism, it cannot go deep idle and we remove the 755 - * CPU from the broadcast mask. We don't have to go 756 - * through the EXIT path as the local timer is not 757 - * shutdown. 758 - */ 759 - ret = broadcast_needs_cpu(bc, cpu); 760 - if (ret) 761 - cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask); 762 741 } else { 763 742 if (cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask)) { 764 743 clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT); ··· 981 938 return bc ? bc->features & CLOCK_EVT_FEAT_ONESHOT : false; 982 939 } 983 940 941 + #else 942 + int __tick_broadcast_oneshot_control(enum tick_broadcast_state state) 943 + { 944 + struct clock_event_device *bc = tick_broadcast_device.evtdev; 945 + 946 + if (!bc || (bc->features & CLOCK_EVT_FEAT_HRTIMER)) 947 + return -EBUSY; 948 + 949 + return 0; 950 + } 984 951 #endif 985 952 986 953 void __init tick_broadcast_init(void)
+21
kernel/time/tick-common.c
··· 343 343 tick_install_broadcast_device(newdev); 344 344 } 345 345 346 + /** 347 + * tick_broadcast_oneshot_control - Enter/exit broadcast oneshot mode 348 + * @state: The target state (enter/exit) 349 + * 350 + * The system enters/leaves a state, where affected devices might stop 351 + * Returns 0 on success, -EBUSY if the cpu is used to broadcast wakeups. 352 + * 353 + * Called with interrupts disabled, so clockevents_lock is not 354 + * required here because the local clock event device cannot go away 355 + * under us. 356 + */ 357 + int tick_broadcast_oneshot_control(enum tick_broadcast_state state) 358 + { 359 + struct tick_device *td = this_cpu_ptr(&tick_cpu_device); 360 + 361 + if (!(td->evtdev->features & CLOCK_EVT_FEAT_C3STOP)) 362 + return 0; 363 + 364 + return __tick_broadcast_oneshot_control(state); 365 + } 366 + 346 367 #ifdef CONFIG_HOTPLUG_CPU 347 368 /* 348 369 * Transfer the do_timer job away from a dying cpu.
+10
kernel/time/tick-sched.h
··· 71 71 static inline void tick_cancel_sched_timer(int cpu) { } 72 72 #endif 73 73 74 + #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 75 + extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state); 76 + #else 77 + static inline int 78 + __tick_broadcast_oneshot_control(enum tick_broadcast_state state) 79 + { 80 + return -EBUSY; 81 + } 82 + #endif 83 + 74 84 #endif
-4
lib/Kconfig.kasan
··· 18 18 For better error detection enable CONFIG_STACKTRACE, 19 19 and add slub_debug=U to boot cmdline. 20 20 21 - config KASAN_SHADOW_OFFSET 22 - hex 23 - default 0xdffffc0000000000 if X86_64 24 - 25 21 choice 26 22 prompt "Instrumentation type" 27 23 depends on KASAN
+13 -7
mm/memory.c
··· 2670 2670 2671 2671 pte_unmap(page_table); 2672 2672 2673 + /* File mapping without ->vm_ops ? */ 2674 + if (vma->vm_flags & VM_SHARED) 2675 + return VM_FAULT_SIGBUS; 2676 + 2673 2677 /* Check if we need to add a guard page to the stack */ 2674 2678 if (check_stack_guard_page(vma, address) < 0) 2675 2679 return VM_FAULT_SIGSEGV; ··· 3103 3099 - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; 3104 3100 3105 3101 pte_unmap(page_table); 3102 + /* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */ 3103 + if (!vma->vm_ops->fault) 3104 + return VM_FAULT_SIGBUS; 3106 3105 if (!(flags & FAULT_FLAG_WRITE)) 3107 3106 return do_read_fault(mm, vma, address, pmd, pgoff, flags, 3108 3107 orig_pte); ··· 3251 3244 barrier(); 3252 3245 if (!pte_present(entry)) { 3253 3246 if (pte_none(entry)) { 3254 - if (vma->vm_ops) { 3255 - if (likely(vma->vm_ops->fault)) 3256 - return do_fault(mm, vma, address, pte, 3257 - pmd, flags, entry); 3258 - } 3259 - return do_anonymous_page(mm, vma, address, 3260 - pte, pmd, flags); 3247 + if (vma->vm_ops) 3248 + return do_fault(mm, vma, address, pte, pmd, 3249 + flags, entry); 3250 + 3251 + return do_anonymous_page(mm, vma, address, pte, pmd, 3252 + flags); 3261 3253 } 3262 3254 return do_swap_page(mm, vma, address, 3263 3255 pte, pmd, flags, entry);
+10 -6
net/ceph/ceph_common.c
··· 9 9 #include <keys/ceph-type.h> 10 10 #include <linux/module.h> 11 11 #include <linux/mount.h> 12 + #include <linux/nsproxy.h> 12 13 #include <linux/parser.h> 13 14 #include <linux/sched.h> 14 15 #include <linux/seq_file.h> ··· 17 16 #include <linux/statfs.h> 18 17 #include <linux/string.h> 19 18 #include <linux/vmalloc.h> 20 - #include <linux/nsproxy.h> 21 - #include <net/net_namespace.h> 22 19 23 20 24 21 #include <linux/ceph/ceph_features.h> ··· 129 130 int ofs = offsetof(struct ceph_options, mon_addr); 130 131 int i; 131 132 int ret; 133 + 134 + /* 135 + * Don't bother comparing options if network namespaces don't 136 + * match. 137 + */ 138 + if (!net_eq(current->nsproxy->net_ns, read_pnet(&client->msgr.net))) 139 + return -1; 132 140 133 141 ret = memcmp(opt1, opt2, ofs); 134 142 if (ret) ··· 340 334 const char *c; 341 335 int err = -ENOMEM; 342 336 substring_t argstr[MAX_OPT_ARGS]; 343 - 344 - if (current->nsproxy->net_ns != &init_net) 345 - return ERR_PTR(-EINVAL); 346 337 347 338 opt = kzalloc(sizeof(*opt), GFP_KERNEL); 348 339 if (!opt) ··· 611 608 fail_monc: 612 609 ceph_monc_stop(&client->monc); 613 610 fail: 611 + ceph_messenger_fini(&client->msgr); 614 612 kfree(client); 615 613 return ERR_PTR(err); 616 614 } ··· 625 621 626 622 /* unmount */ 627 623 ceph_osdc_stop(&client->osdc); 628 - 629 624 ceph_monc_stop(&client->monc); 625 + ceph_messenger_fini(&client->msgr); 630 626 631 627 ceph_debugfs_client_cleanup(client); 632 628
+16 -8
net/ceph/messenger.c
··· 6 6 #include <linux/inet.h> 7 7 #include <linux/kthread.h> 8 8 #include <linux/net.h> 9 + #include <linux/nsproxy.h> 9 10 #include <linux/slab.h> 10 11 #include <linux/socket.h> 11 12 #include <linux/string.h> ··· 480 479 int ret; 481 480 482 481 BUG_ON(con->sock); 483 - ret = sock_create_kern(&init_net, con->peer_addr.in_addr.ss_family, 482 + ret = sock_create_kern(read_pnet(&con->msgr->net), paddr->ss_family, 484 483 SOCK_STREAM, IPPROTO_TCP, &sock); 485 484 if (ret) 486 485 return ret; ··· 1732 1731 1733 1732 static bool addr_is_blank(struct sockaddr_storage *ss) 1734 1733 { 1734 + struct in_addr *addr = &((struct sockaddr_in *)ss)->sin_addr; 1735 + struct in6_addr *addr6 = &((struct sockaddr_in6 *)ss)->sin6_addr; 1736 + 1735 1737 switch (ss->ss_family) { 1736 1738 case AF_INET: 1737 - return ((struct sockaddr_in *)ss)->sin_addr.s_addr == 0; 1739 + return addr->s_addr == htonl(INADDR_ANY); 1738 1740 case AF_INET6: 1739 - return 1740 - ((struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[0] == 0 && 1741 - ((struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[1] == 0 && 1742 - ((struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[2] == 0 && 1743 - ((struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[3] == 0; 1741 + return ipv6_addr_any(addr6); 1742 + default: 1743 + return true; 1744 1744 } 1745 - return false; 1746 1745 } 1747 1746 1748 1747 static int addr_port(struct sockaddr_storage *ss) ··· 2945 2944 msgr->tcp_nodelay = tcp_nodelay; 2946 2945 2947 2946 atomic_set(&msgr->stopping, 0); 2947 + write_pnet(&msgr->net, get_net(current->nsproxy->net_ns)); 2948 2948 2949 2949 dout("%s %p\n", __func__, msgr); 2950 2950 } 2951 2951 EXPORT_SYMBOL(ceph_messenger_init); 2952 + 2953 + void ceph_messenger_fini(struct ceph_messenger *msgr) 2954 + { 2955 + put_net(read_pnet(&msgr->net)); 2956 + } 2957 + EXPORT_SYMBOL(ceph_messenger_fini); 2952 2958 2953 2959 static void clear_standby(struct ceph_connection *con) 2954 2960 {
+2
scripts/mod/devicetable-offsets.c
··· 63 63 64 64 DEVID(acpi_device_id); 65 65 DEVID_FIELD(acpi_device_id, id); 66 + DEVID_FIELD(acpi_device_id, cls); 67 + DEVID_FIELD(acpi_device_id, cls_msk); 66 68 67 69 DEVID(pnp_device_id); 68 70 DEVID_FIELD(pnp_device_id, id);
+30 -2
scripts/mod/file2alias.c
··· 523 523 } 524 524 ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); 525 525 526 - /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ 526 + /* looks like: "acpi:ACPI0003" or "acpi:PNP0C0B" or "acpi:LNXVIDEO" or 527 + * "acpi:bbsspp" (bb=base-class, ss=sub-class, pp=prog-if) 528 + * 529 + * NOTE: Each driver should use one of the following : _HID, _CIDs 530 + * or _CLS. Also, bb, ss, and pp can be substituted with ?? 531 + * as don't care byte. 532 + */ 527 533 static int do_acpi_entry(const char *filename, 528 534 void *symval, char *alias) 529 535 { 530 536 DEF_FIELD_ADDR(symval, acpi_device_id, id); 531 - sprintf(alias, "acpi*:%s:*", *id); 537 + DEF_FIELD_ADDR(symval, acpi_device_id, cls); 538 + DEF_FIELD_ADDR(symval, acpi_device_id, cls_msk); 539 + 540 + if (id && strlen((const char *)*id)) 541 + sprintf(alias, "acpi*:%s:*", *id); 542 + else if (cls) { 543 + int i, byte_shift, cnt = 0; 544 + unsigned int msk; 545 + 546 + sprintf(&alias[cnt], "acpi*:"); 547 + cnt = 6; 548 + for (i = 1; i <= 3; i++) { 549 + byte_shift = 8 * (3-i); 550 + msk = (*cls_msk >> byte_shift) & 0xFF; 551 + if (msk) 552 + sprintf(&alias[cnt], "%02x", 553 + (*cls >> byte_shift) & 0xFF); 554 + else 555 + sprintf(&alias[cnt], "??"); 556 + cnt += 2; 557 + } 558 + sprintf(&alias[cnt], ":*"); 559 + } 532 560 return 1; 533 561 } 534 562 ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry);
+2 -1
scripts/mod/modpost.c
··· 886 886 #define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \ 887 887 ".kprobes.text" 888 888 #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ 889 - ".fixup", ".entry.text", ".exception.text", ".text.*" 889 + ".fixup", ".entry.text", ".exception.text", ".text.*", \ 890 + ".coldtext" 890 891 891 892 #define INIT_SECTIONS ".init.*" 892 893 #define MEM_INIT_SECTIONS ".meminit.*"
+2 -1
security/selinux/hooks.c
··· 3283 3283 int rc = 0; 3284 3284 3285 3285 if (default_noexec && 3286 - (prot & PROT_EXEC) && (!file || (!shared && (prot & PROT_WRITE)))) { 3286 + (prot & PROT_EXEC) && (!file || IS_PRIVATE(file_inode(file)) || 3287 + (!shared && (prot & PROT_WRITE)))) { 3287 3288 /* 3288 3289 * We are making executable an anonymous mapping or a 3289 3290 * private file mapping that will also be writable.
+6
security/selinux/ss/ebitmap.c
··· 153 153 if (offset == (u32)-1) 154 154 return 0; 155 155 156 + /* don't waste ebitmap space if the netlabel bitmap is empty */ 157 + if (bitmap == 0) { 158 + offset += EBITMAP_UNIT_SIZE; 159 + continue; 160 + } 161 + 156 162 if (e_iter == NULL || 157 163 offset >= e_iter->startbit + EBITMAP_SIZE) { 158 164 e_prev = e_iter;
+58
tools/include/linux/compiler.h
··· 41 41 42 42 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) 43 43 44 + #include <linux/types.h> 45 + 46 + static __always_inline void __read_once_size(const volatile void *p, void *res, int size) 47 + { 48 + switch (size) { 49 + case 1: *(__u8 *)res = *(volatile __u8 *)p; break; 50 + case 2: *(__u16 *)res = *(volatile __u16 *)p; break; 51 + case 4: *(__u32 *)res = *(volatile __u32 *)p; break; 52 + case 8: *(__u64 *)res = *(volatile __u64 *)p; break; 53 + default: 54 + barrier(); 55 + __builtin_memcpy((void *)res, (const void *)p, size); 56 + barrier(); 57 + } 58 + } 59 + 60 + static __always_inline void __write_once_size(volatile void *p, void *res, int size) 61 + { 62 + switch (size) { 63 + case 1: *(volatile __u8 *)p = *(__u8 *)res; break; 64 + case 2: *(volatile __u16 *)p = *(__u16 *)res; break; 65 + case 4: *(volatile __u32 *)p = *(__u32 *)res; break; 66 + case 8: *(volatile __u64 *)p = *(__u64 *)res; break; 67 + default: 68 + barrier(); 69 + __builtin_memcpy((void *)p, (const void *)res, size); 70 + barrier(); 71 + } 72 + } 73 + 74 + /* 75 + * Prevent the compiler from merging or refetching reads or writes. The 76 + * compiler is also forbidden from reordering successive instances of 77 + * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the 78 + * compiler is aware of some particular ordering. One way to make the 79 + * compiler aware of ordering is to put the two invocations of READ_ONCE, 80 + * WRITE_ONCE or ACCESS_ONCE() in different C statements. 81 + * 82 + * In contrast to ACCESS_ONCE these two macros will also work on aggregate 83 + * data types like structs or unions. If the size of the accessed data 84 + * type exceeds the word size of the machine (e.g., 32 bits or 64 bits) 85 + * READ_ONCE() and WRITE_ONCE() will fall back to memcpy and print a 86 + * compile-time warning. 87 + * 88 + * Their two major use cases are: (1) Mediating communication between 89 + * process-level code and irq/NMI handlers, all running on the same CPU, 90 + * and (2) Ensuring that the compiler does not fold, spindle, or otherwise 91 + * mutilate accesses that either do not require ordering or that interact 92 + * with an explicit memory barrier or atomic instruction that provides the 93 + * required ordering. 94 + */ 95 + 96 + #define READ_ONCE(x) \ 97 + ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) 98 + 99 + #define WRITE_ONCE(x, val) \ 100 + ({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) 101 + 44 102 #endif /* _TOOLS_LINUX_COMPILER_H */
-10
tools/include/linux/export.h
··· 1 - #ifndef _TOOLS_LINUX_EXPORT_H_ 2 - #define _TOOLS_LINUX_EXPORT_H_ 3 - 4 - #define EXPORT_SYMBOL(sym) 5 - #define EXPORT_SYMBOL_GPL(sym) 6 - #define EXPORT_SYMBOL_GPL_FUTURE(sym) 7 - #define EXPORT_UNUSED_SYMBOL(sym) 8 - #define EXPORT_UNUSED_SYMBOL_GPL(sym) 9 - 10 - #endif
+104
tools/include/linux/rbtree.h
··· 1 + /* 2 + Red Black Trees 3 + (C) 1999 Andrea Arcangeli <andrea@suse.de> 4 + 5 + This program is free software; you can redistribute it and/or modify 6 + it under the terms of the GNU General Public License as published by 7 + the Free Software Foundation; either version 2 of the License, or 8 + (at your option) any later version. 9 + 10 + This program is distributed in the hope that it will be useful, 11 + but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + GNU General Public License for more details. 14 + 15 + You should have received a copy of the GNU General Public License 16 + along with this program; if not, write to the Free Software 17 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 + 19 + linux/include/linux/rbtree.h 20 + 21 + To use rbtrees you'll have to implement your own insert and search cores. 22 + This will avoid us to use callbacks and to drop drammatically performances. 23 + I know it's not the cleaner way, but in C (not in C++) to get 24 + performances and genericity... 25 + 26 + See Documentation/rbtree.txt for documentation and samples. 27 + */ 28 + 29 + #ifndef __TOOLS_LINUX_PERF_RBTREE_H 30 + #define __TOOLS_LINUX_PERF_RBTREE_H 31 + 32 + #include <linux/kernel.h> 33 + #include <linux/stddef.h> 34 + 35 + struct rb_node { 36 + unsigned long __rb_parent_color; 37 + struct rb_node *rb_right; 38 + struct rb_node *rb_left; 39 + } __attribute__((aligned(sizeof(long)))); 40 + /* The alignment might seem pointless, but allegedly CRIS needs it */ 41 + 42 + struct rb_root { 43 + struct rb_node *rb_node; 44 + }; 45 + 46 + 47 + #define rb_parent(r) ((struct rb_node *)((r)->__rb_parent_color & ~3)) 48 + 49 + #define RB_ROOT (struct rb_root) { NULL, } 50 + #define rb_entry(ptr, type, member) container_of(ptr, type, member) 51 + 52 + #define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) 53 + 54 + /* 'empty' nodes are nodes that are known not to be inserted in an rbtree */ 55 + #define RB_EMPTY_NODE(node) \ 56 + ((node)->__rb_parent_color == (unsigned long)(node)) 57 + #define RB_CLEAR_NODE(node) \ 58 + ((node)->__rb_parent_color = (unsigned long)(node)) 59 + 60 + 61 + extern void rb_insert_color(struct rb_node *, struct rb_root *); 62 + extern void rb_erase(struct rb_node *, struct rb_root *); 63 + 64 + 65 + /* Find logical next and previous nodes in a tree */ 66 + extern struct rb_node *rb_next(const struct rb_node *); 67 + extern struct rb_node *rb_prev(const struct rb_node *); 68 + extern struct rb_node *rb_first(const struct rb_root *); 69 + extern struct rb_node *rb_last(const struct rb_root *); 70 + 71 + /* Postorder iteration - always visit the parent after its children */ 72 + extern struct rb_node *rb_first_postorder(const struct rb_root *); 73 + extern struct rb_node *rb_next_postorder(const struct rb_node *); 74 + 75 + /* Fast replacement of a single node without remove/rebalance/add/rebalance */ 76 + extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, 77 + struct rb_root *root); 78 + 79 + static inline void rb_link_node(struct rb_node *node, struct rb_node *parent, 80 + struct rb_node **rb_link) 81 + { 82 + node->__rb_parent_color = (unsigned long)parent; 83 + node->rb_left = node->rb_right = NULL; 84 + 85 + *rb_link = node; 86 + } 87 + 88 + #define rb_entry_safe(ptr, type, member) \ 89 + ({ typeof(ptr) ____ptr = (ptr); \ 90 + ____ptr ? rb_entry(____ptr, type, member) : NULL; \ 91 + }) 92 + 93 + 94 + /* 95 + * Handy for checking that we are not deleting an entry that is 96 + * already in a list, found in block/{blk-throttle,cfq-iosched}.c, 97 + * probably should be moved to lib/rbtree.c... 98 + */ 99 + static inline void rb_erase_init(struct rb_node *n, struct rb_root *root) 100 + { 101 + rb_erase(n, root); 102 + RB_CLEAR_NODE(n); 103 + } 104 + #endif /* __TOOLS_LINUX_PERF_RBTREE_H */
+245
tools/include/linux/rbtree_augmented.h
··· 1 + /* 2 + Red Black Trees 3 + (C) 1999 Andrea Arcangeli <andrea@suse.de> 4 + (C) 2002 David Woodhouse <dwmw2@infradead.org> 5 + (C) 2012 Michel Lespinasse <walken@google.com> 6 + 7 + This program is free software; you can redistribute it and/or modify 8 + it under the terms of the GNU General Public License as published by 9 + the Free Software Foundation; either version 2 of the License, or 10 + (at your option) any later version. 11 + 12 + This program is distributed in the hope that it will be useful, 13 + but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + GNU General Public License for more details. 16 + 17 + You should have received a copy of the GNU General Public License 18 + along with this program; if not, write to the Free Software 19 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 + 21 + tools/linux/include/linux/rbtree_augmented.h 22 + 23 + Copied from: 24 + linux/include/linux/rbtree_augmented.h 25 + */ 26 + 27 + #ifndef _TOOLS_LINUX_RBTREE_AUGMENTED_H 28 + #define _TOOLS_LINUX_RBTREE_AUGMENTED_H 29 + 30 + #include <linux/compiler.h> 31 + #include <linux/rbtree.h> 32 + 33 + /* 34 + * Please note - only struct rb_augment_callbacks and the prototypes for 35 + * rb_insert_augmented() and rb_erase_augmented() are intended to be public. 36 + * The rest are implementation details you are not expected to depend on. 37 + * 38 + * See Documentation/rbtree.txt for documentation and samples. 39 + */ 40 + 41 + struct rb_augment_callbacks { 42 + void (*propagate)(struct rb_node *node, struct rb_node *stop); 43 + void (*copy)(struct rb_node *old, struct rb_node *new); 44 + void (*rotate)(struct rb_node *old, struct rb_node *new); 45 + }; 46 + 47 + extern void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, 48 + void (*augment_rotate)(struct rb_node *old, struct rb_node *new)); 49 + /* 50 + * Fixup the rbtree and update the augmented information when rebalancing. 51 + * 52 + * On insertion, the user must update the augmented information on the path 53 + * leading to the inserted node, then call rb_link_node() as usual and 54 + * rb_augment_inserted() instead of the usual rb_insert_color() call. 55 + * If rb_augment_inserted() rebalances the rbtree, it will callback into 56 + * a user provided function to update the augmented information on the 57 + * affected subtrees. 58 + */ 59 + static inline void 60 + rb_insert_augmented(struct rb_node *node, struct rb_root *root, 61 + const struct rb_augment_callbacks *augment) 62 + { 63 + __rb_insert_augmented(node, root, augment->rotate); 64 + } 65 + 66 + #define RB_DECLARE_CALLBACKS(rbstatic, rbname, rbstruct, rbfield, \ 67 + rbtype, rbaugmented, rbcompute) \ 68 + static inline void \ 69 + rbname ## _propagate(struct rb_node *rb, struct rb_node *stop) \ 70 + { \ 71 + while (rb != stop) { \ 72 + rbstruct *node = rb_entry(rb, rbstruct, rbfield); \ 73 + rbtype augmented = rbcompute(node); \ 74 + if (node->rbaugmented == augmented) \ 75 + break; \ 76 + node->rbaugmented = augmented; \ 77 + rb = rb_parent(&node->rbfield); \ 78 + } \ 79 + } \ 80 + static inline void \ 81 + rbname ## _copy(struct rb_node *rb_old, struct rb_node *rb_new) \ 82 + { \ 83 + rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \ 84 + rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \ 85 + new->rbaugmented = old->rbaugmented; \ 86 + } \ 87 + static void \ 88 + rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \ 89 + { \ 90 + rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \ 91 + rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \ 92 + new->rbaugmented = old->rbaugmented; \ 93 + old->rbaugmented = rbcompute(old); \ 94 + } \ 95 + rbstatic const struct rb_augment_callbacks rbname = { \ 96 + rbname ## _propagate, rbname ## _copy, rbname ## _rotate \ 97 + }; 98 + 99 + 100 + #define RB_RED 0 101 + #define RB_BLACK 1 102 + 103 + #define __rb_parent(pc) ((struct rb_node *)(pc & ~3)) 104 + 105 + #define __rb_color(pc) ((pc) & 1) 106 + #define __rb_is_black(pc) __rb_color(pc) 107 + #define __rb_is_red(pc) (!__rb_color(pc)) 108 + #define rb_color(rb) __rb_color((rb)->__rb_parent_color) 109 + #define rb_is_red(rb) __rb_is_red((rb)->__rb_parent_color) 110 + #define rb_is_black(rb) __rb_is_black((rb)->__rb_parent_color) 111 + 112 + static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p) 113 + { 114 + rb->__rb_parent_color = rb_color(rb) | (unsigned long)p; 115 + } 116 + 117 + static inline void rb_set_parent_color(struct rb_node *rb, 118 + struct rb_node *p, int color) 119 + { 120 + rb->__rb_parent_color = (unsigned long)p | color; 121 + } 122 + 123 + static inline void 124 + __rb_change_child(struct rb_node *old, struct rb_node *new, 125 + struct rb_node *parent, struct rb_root *root) 126 + { 127 + if (parent) { 128 + if (parent->rb_left == old) 129 + parent->rb_left = new; 130 + else 131 + parent->rb_right = new; 132 + } else 133 + root->rb_node = new; 134 + } 135 + 136 + extern void __rb_erase_color(struct rb_node *parent, struct rb_root *root, 137 + void (*augment_rotate)(struct rb_node *old, struct rb_node *new)); 138 + 139 + static __always_inline struct rb_node * 140 + __rb_erase_augmented(struct rb_node *node, struct rb_root *root, 141 + const struct rb_augment_callbacks *augment) 142 + { 143 + struct rb_node *child = node->rb_right, *tmp = node->rb_left; 144 + struct rb_node *parent, *rebalance; 145 + unsigned long pc; 146 + 147 + if (!tmp) { 148 + /* 149 + * Case 1: node to erase has no more than 1 child (easy!) 150 + * 151 + * Note that if there is one child it must be red due to 5) 152 + * and node must be black due to 4). We adjust colors locally 153 + * so as to bypass __rb_erase_color() later on. 154 + */ 155 + pc = node->__rb_parent_color; 156 + parent = __rb_parent(pc); 157 + __rb_change_child(node, child, parent, root); 158 + if (child) { 159 + child->__rb_parent_color = pc; 160 + rebalance = NULL; 161 + } else 162 + rebalance = __rb_is_black(pc) ? parent : NULL; 163 + tmp = parent; 164 + } else if (!child) { 165 + /* Still case 1, but this time the child is node->rb_left */ 166 + tmp->__rb_parent_color = pc = node->__rb_parent_color; 167 + parent = __rb_parent(pc); 168 + __rb_change_child(node, tmp, parent, root); 169 + rebalance = NULL; 170 + tmp = parent; 171 + } else { 172 + struct rb_node *successor = child, *child2; 173 + tmp = child->rb_left; 174 + if (!tmp) { 175 + /* 176 + * Case 2: node's successor is its right child 177 + * 178 + * (n) (s) 179 + * / \ / \ 180 + * (x) (s) -> (x) (c) 181 + * \ 182 + * (c) 183 + */ 184 + parent = successor; 185 + child2 = successor->rb_right; 186 + augment->copy(node, successor); 187 + } else { 188 + /* 189 + * Case 3: node's successor is leftmost under 190 + * node's right child subtree 191 + * 192 + * (n) (s) 193 + * / \ / \ 194 + * (x) (y) -> (x) (y) 195 + * / / 196 + * (p) (p) 197 + * / / 198 + * (s) (c) 199 + * \ 200 + * (c) 201 + */ 202 + do { 203 + parent = successor; 204 + successor = tmp; 205 + tmp = tmp->rb_left; 206 + } while (tmp); 207 + parent->rb_left = child2 = successor->rb_right; 208 + successor->rb_right = child; 209 + rb_set_parent(child, successor); 210 + augment->copy(node, successor); 211 + augment->propagate(parent, successor); 212 + } 213 + 214 + successor->rb_left = tmp = node->rb_left; 215 + rb_set_parent(tmp, successor); 216 + 217 + pc = node->__rb_parent_color; 218 + tmp = __rb_parent(pc); 219 + __rb_change_child(node, successor, tmp, root); 220 + if (child2) { 221 + successor->__rb_parent_color = pc; 222 + rb_set_parent_color(child2, parent, RB_BLACK); 223 + rebalance = NULL; 224 + } else { 225 + unsigned long pc2 = successor->__rb_parent_color; 226 + successor->__rb_parent_color = pc; 227 + rebalance = __rb_is_black(pc2) ? parent : NULL; 228 + } 229 + tmp = successor; 230 + } 231 + 232 + augment->propagate(tmp, NULL); 233 + return rebalance; 234 + } 235 + 236 + static __always_inline void 237 + rb_erase_augmented(struct rb_node *node, struct rb_root *root, 238 + const struct rb_augment_callbacks *augment) 239 + { 240 + struct rb_node *rebalance = __rb_erase_augmented(node, root, augment); 241 + if (rebalance) 242 + __rb_erase_color(rebalance, root, augment->rotate); 243 + } 244 + 245 + #endif /* _TOOLS_LINUX_RBTREE_AUGMENTED_H */
+548
tools/lib/rbtree.c
··· 1 + /* 2 + Red Black Trees 3 + (C) 1999 Andrea Arcangeli <andrea@suse.de> 4 + (C) 2002 David Woodhouse <dwmw2@infradead.org> 5 + (C) 2012 Michel Lespinasse <walken@google.com> 6 + 7 + This program is free software; you can redistribute it and/or modify 8 + it under the terms of the GNU General Public License as published by 9 + the Free Software Foundation; either version 2 of the License, or 10 + (at your option) any later version. 11 + 12 + This program is distributed in the hope that it will be useful, 13 + but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + GNU General Public License for more details. 16 + 17 + You should have received a copy of the GNU General Public License 18 + along with this program; if not, write to the Free Software 19 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 + 21 + linux/lib/rbtree.c 22 + */ 23 + 24 + #include <linux/rbtree_augmented.h> 25 + 26 + /* 27 + * red-black trees properties: http://en.wikipedia.org/wiki/Rbtree 28 + * 29 + * 1) A node is either red or black 30 + * 2) The root is black 31 + * 3) All leaves (NULL) are black 32 + * 4) Both children of every red node are black 33 + * 5) Every simple path from root to leaves contains the same number 34 + * of black nodes. 35 + * 36 + * 4 and 5 give the O(log n) guarantee, since 4 implies you cannot have two 37 + * consecutive red nodes in a path and every red node is therefore followed by 38 + * a black. So if B is the number of black nodes on every simple path (as per 39 + * 5), then the longest possible path due to 4 is 2B. 40 + * 41 + * We shall indicate color with case, where black nodes are uppercase and red 42 + * nodes will be lowercase. Unknown color nodes shall be drawn as red within 43 + * parentheses and have some accompanying text comment. 44 + */ 45 + 46 + static inline void rb_set_black(struct rb_node *rb) 47 + { 48 + rb->__rb_parent_color |= RB_BLACK; 49 + } 50 + 51 + static inline struct rb_node *rb_red_parent(struct rb_node *red) 52 + { 53 + return (struct rb_node *)red->__rb_parent_color; 54 + } 55 + 56 + /* 57 + * Helper function for rotations: 58 + * - old's parent and color get assigned to new 59 + * - old gets assigned new as a parent and 'color' as a color. 60 + */ 61 + static inline void 62 + __rb_rotate_set_parents(struct rb_node *old, struct rb_node *new, 63 + struct rb_root *root, int color) 64 + { 65 + struct rb_node *parent = rb_parent(old); 66 + new->__rb_parent_color = old->__rb_parent_color; 67 + rb_set_parent_color(old, new, color); 68 + __rb_change_child(old, new, parent, root); 69 + } 70 + 71 + static __always_inline void 72 + __rb_insert(struct rb_node *node, struct rb_root *root, 73 + void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 74 + { 75 + struct rb_node *parent = rb_red_parent(node), *gparent, *tmp; 76 + 77 + while (true) { 78 + /* 79 + * Loop invariant: node is red 80 + * 81 + * If there is a black parent, we are done. 82 + * Otherwise, take some corrective action as we don't 83 + * want a red root or two consecutive red nodes. 84 + */ 85 + if (!parent) { 86 + rb_set_parent_color(node, NULL, RB_BLACK); 87 + break; 88 + } else if (rb_is_black(parent)) 89 + break; 90 + 91 + gparent = rb_red_parent(parent); 92 + 93 + tmp = gparent->rb_right; 94 + if (parent != tmp) { /* parent == gparent->rb_left */ 95 + if (tmp && rb_is_red(tmp)) { 96 + /* 97 + * Case 1 - color flips 98 + * 99 + * G g 100 + * / \ / \ 101 + * p u --> P U 102 + * / / 103 + * n n 104 + * 105 + * However, since g's parent might be red, and 106 + * 4) does not allow this, we need to recurse 107 + * at g. 108 + */ 109 + rb_set_parent_color(tmp, gparent, RB_BLACK); 110 + rb_set_parent_color(parent, gparent, RB_BLACK); 111 + node = gparent; 112 + parent = rb_parent(node); 113 + rb_set_parent_color(node, parent, RB_RED); 114 + continue; 115 + } 116 + 117 + tmp = parent->rb_right; 118 + if (node == tmp) { 119 + /* 120 + * Case 2 - left rotate at parent 121 + * 122 + * G G 123 + * / \ / \ 124 + * p U --> n U 125 + * \ / 126 + * n p 127 + * 128 + * This still leaves us in violation of 4), the 129 + * continuation into Case 3 will fix that. 130 + */ 131 + parent->rb_right = tmp = node->rb_left; 132 + node->rb_left = parent; 133 + if (tmp) 134 + rb_set_parent_color(tmp, parent, 135 + RB_BLACK); 136 + rb_set_parent_color(parent, node, RB_RED); 137 + augment_rotate(parent, node); 138 + parent = node; 139 + tmp = node->rb_right; 140 + } 141 + 142 + /* 143 + * Case 3 - right rotate at gparent 144 + * 145 + * G P 146 + * / \ / \ 147 + * p U --> n g 148 + * / \ 149 + * n U 150 + */ 151 + gparent->rb_left = tmp; /* == parent->rb_right */ 152 + parent->rb_right = gparent; 153 + if (tmp) 154 + rb_set_parent_color(tmp, gparent, RB_BLACK); 155 + __rb_rotate_set_parents(gparent, parent, root, RB_RED); 156 + augment_rotate(gparent, parent); 157 + break; 158 + } else { 159 + tmp = gparent->rb_left; 160 + if (tmp && rb_is_red(tmp)) { 161 + /* Case 1 - color flips */ 162 + rb_set_parent_color(tmp, gparent, RB_BLACK); 163 + rb_set_parent_color(parent, gparent, RB_BLACK); 164 + node = gparent; 165 + parent = rb_parent(node); 166 + rb_set_parent_color(node, parent, RB_RED); 167 + continue; 168 + } 169 + 170 + tmp = parent->rb_left; 171 + if (node == tmp) { 172 + /* Case 2 - right rotate at parent */ 173 + parent->rb_left = tmp = node->rb_right; 174 + node->rb_right = parent; 175 + if (tmp) 176 + rb_set_parent_color(tmp, parent, 177 + RB_BLACK); 178 + rb_set_parent_color(parent, node, RB_RED); 179 + augment_rotate(parent, node); 180 + parent = node; 181 + tmp = node->rb_left; 182 + } 183 + 184 + /* Case 3 - left rotate at gparent */ 185 + gparent->rb_right = tmp; /* == parent->rb_left */ 186 + parent->rb_left = gparent; 187 + if (tmp) 188 + rb_set_parent_color(tmp, gparent, RB_BLACK); 189 + __rb_rotate_set_parents(gparent, parent, root, RB_RED); 190 + augment_rotate(gparent, parent); 191 + break; 192 + } 193 + } 194 + } 195 + 196 + /* 197 + * Inline version for rb_erase() use - we want to be able to inline 198 + * and eliminate the dummy_rotate callback there 199 + */ 200 + static __always_inline void 201 + ____rb_erase_color(struct rb_node *parent, struct rb_root *root, 202 + void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 203 + { 204 + struct rb_node *node = NULL, *sibling, *tmp1, *tmp2; 205 + 206 + while (true) { 207 + /* 208 + * Loop invariants: 209 + * - node is black (or NULL on first iteration) 210 + * - node is not the root (parent is not NULL) 211 + * - All leaf paths going through parent and node have a 212 + * black node count that is 1 lower than other leaf paths. 213 + */ 214 + sibling = parent->rb_right; 215 + if (node != sibling) { /* node == parent->rb_left */ 216 + if (rb_is_red(sibling)) { 217 + /* 218 + * Case 1 - left rotate at parent 219 + * 220 + * P S 221 + * / \ / \ 222 + * N s --> p Sr 223 + * / \ / \ 224 + * Sl Sr N Sl 225 + */ 226 + parent->rb_right = tmp1 = sibling->rb_left; 227 + sibling->rb_left = parent; 228 + rb_set_parent_color(tmp1, parent, RB_BLACK); 229 + __rb_rotate_set_parents(parent, sibling, root, 230 + RB_RED); 231 + augment_rotate(parent, sibling); 232 + sibling = tmp1; 233 + } 234 + tmp1 = sibling->rb_right; 235 + if (!tmp1 || rb_is_black(tmp1)) { 236 + tmp2 = sibling->rb_left; 237 + if (!tmp2 || rb_is_black(tmp2)) { 238 + /* 239 + * Case 2 - sibling color flip 240 + * (p could be either color here) 241 + * 242 + * (p) (p) 243 + * / \ / \ 244 + * N S --> N s 245 + * / \ / \ 246 + * Sl Sr Sl Sr 247 + * 248 + * This leaves us violating 5) which 249 + * can be fixed by flipping p to black 250 + * if it was red, or by recursing at p. 251 + * p is red when coming from Case 1. 252 + */ 253 + rb_set_parent_color(sibling, parent, 254 + RB_RED); 255 + if (rb_is_red(parent)) 256 + rb_set_black(parent); 257 + else { 258 + node = parent; 259 + parent = rb_parent(node); 260 + if (parent) 261 + continue; 262 + } 263 + break; 264 + } 265 + /* 266 + * Case 3 - right rotate at sibling 267 + * (p could be either color here) 268 + * 269 + * (p) (p) 270 + * / \ / \ 271 + * N S --> N Sl 272 + * / \ \ 273 + * sl Sr s 274 + * \ 275 + * Sr 276 + */ 277 + sibling->rb_left = tmp1 = tmp2->rb_right; 278 + tmp2->rb_right = sibling; 279 + parent->rb_right = tmp2; 280 + if (tmp1) 281 + rb_set_parent_color(tmp1, sibling, 282 + RB_BLACK); 283 + augment_rotate(sibling, tmp2); 284 + tmp1 = sibling; 285 + sibling = tmp2; 286 + } 287 + /* 288 + * Case 4 - left rotate at parent + color flips 289 + * (p and sl could be either color here. 290 + * After rotation, p becomes black, s acquires 291 + * p's color, and sl keeps its color) 292 + * 293 + * (p) (s) 294 + * / \ / \ 295 + * N S --> P Sr 296 + * / \ / \ 297 + * (sl) sr N (sl) 298 + */ 299 + parent->rb_right = tmp2 = sibling->rb_left; 300 + sibling->rb_left = parent; 301 + rb_set_parent_color(tmp1, sibling, RB_BLACK); 302 + if (tmp2) 303 + rb_set_parent(tmp2, parent); 304 + __rb_rotate_set_parents(parent, sibling, root, 305 + RB_BLACK); 306 + augment_rotate(parent, sibling); 307 + break; 308 + } else { 309 + sibling = parent->rb_left; 310 + if (rb_is_red(sibling)) { 311 + /* Case 1 - right rotate at parent */ 312 + parent->rb_left = tmp1 = sibling->rb_right; 313 + sibling->rb_right = parent; 314 + rb_set_parent_color(tmp1, parent, RB_BLACK); 315 + __rb_rotate_set_parents(parent, sibling, root, 316 + RB_RED); 317 + augment_rotate(parent, sibling); 318 + sibling = tmp1; 319 + } 320 + tmp1 = sibling->rb_left; 321 + if (!tmp1 || rb_is_black(tmp1)) { 322 + tmp2 = sibling->rb_right; 323 + if (!tmp2 || rb_is_black(tmp2)) { 324 + /* Case 2 - sibling color flip */ 325 + rb_set_parent_color(sibling, parent, 326 + RB_RED); 327 + if (rb_is_red(parent)) 328 + rb_set_black(parent); 329 + else { 330 + node = parent; 331 + parent = rb_parent(node); 332 + if (parent) 333 + continue; 334 + } 335 + break; 336 + } 337 + /* Case 3 - right rotate at sibling */ 338 + sibling->rb_right = tmp1 = tmp2->rb_left; 339 + tmp2->rb_left = sibling; 340 + parent->rb_left = tmp2; 341 + if (tmp1) 342 + rb_set_parent_color(tmp1, sibling, 343 + RB_BLACK); 344 + augment_rotate(sibling, tmp2); 345 + tmp1 = sibling; 346 + sibling = tmp2; 347 + } 348 + /* Case 4 - left rotate at parent + color flips */ 349 + parent->rb_left = tmp2 = sibling->rb_right; 350 + sibling->rb_right = parent; 351 + rb_set_parent_color(tmp1, sibling, RB_BLACK); 352 + if (tmp2) 353 + rb_set_parent(tmp2, parent); 354 + __rb_rotate_set_parents(parent, sibling, root, 355 + RB_BLACK); 356 + augment_rotate(parent, sibling); 357 + break; 358 + } 359 + } 360 + } 361 + 362 + /* Non-inline version for rb_erase_augmented() use */ 363 + void __rb_erase_color(struct rb_node *parent, struct rb_root *root, 364 + void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 365 + { 366 + ____rb_erase_color(parent, root, augment_rotate); 367 + } 368 + 369 + /* 370 + * Non-augmented rbtree manipulation functions. 371 + * 372 + * We use dummy augmented callbacks here, and have the compiler optimize them 373 + * out of the rb_insert_color() and rb_erase() function definitions. 374 + */ 375 + 376 + static inline void dummy_propagate(struct rb_node *node, struct rb_node *stop) {} 377 + static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {} 378 + static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {} 379 + 380 + static const struct rb_augment_callbacks dummy_callbacks = { 381 + dummy_propagate, dummy_copy, dummy_rotate 382 + }; 383 + 384 + void rb_insert_color(struct rb_node *node, struct rb_root *root) 385 + { 386 + __rb_insert(node, root, dummy_rotate); 387 + } 388 + 389 + void rb_erase(struct rb_node *node, struct rb_root *root) 390 + { 391 + struct rb_node *rebalance; 392 + rebalance = __rb_erase_augmented(node, root, &dummy_callbacks); 393 + if (rebalance) 394 + ____rb_erase_color(rebalance, root, dummy_rotate); 395 + } 396 + 397 + /* 398 + * Augmented rbtree manipulation functions. 399 + * 400 + * This instantiates the same __always_inline functions as in the non-augmented 401 + * case, but this time with user-defined callbacks. 402 + */ 403 + 404 + void __rb_insert_augmented(struct rb_node *node, struct rb_root *root, 405 + void (*augment_rotate)(struct rb_node *old, struct rb_node *new)) 406 + { 407 + __rb_insert(node, root, augment_rotate); 408 + } 409 + 410 + /* 411 + * This function returns the first node (in sort order) of the tree. 412 + */ 413 + struct rb_node *rb_first(const struct rb_root *root) 414 + { 415 + struct rb_node *n; 416 + 417 + n = root->rb_node; 418 + if (!n) 419 + return NULL; 420 + while (n->rb_left) 421 + n = n->rb_left; 422 + return n; 423 + } 424 + 425 + struct rb_node *rb_last(const struct rb_root *root) 426 + { 427 + struct rb_node *n; 428 + 429 + n = root->rb_node; 430 + if (!n) 431 + return NULL; 432 + while (n->rb_right) 433 + n = n->rb_right; 434 + return n; 435 + } 436 + 437 + struct rb_node *rb_next(const struct rb_node *node) 438 + { 439 + struct rb_node *parent; 440 + 441 + if (RB_EMPTY_NODE(node)) 442 + return NULL; 443 + 444 + /* 445 + * If we have a right-hand child, go down and then left as far 446 + * as we can. 447 + */ 448 + if (node->rb_right) { 449 + node = node->rb_right; 450 + while (node->rb_left) 451 + node=node->rb_left; 452 + return (struct rb_node *)node; 453 + } 454 + 455 + /* 456 + * No right-hand children. Everything down and left is smaller than us, 457 + * so any 'next' node must be in the general direction of our parent. 458 + * Go up the tree; any time the ancestor is a right-hand child of its 459 + * parent, keep going up. First time it's a left-hand child of its 460 + * parent, said parent is our 'next' node. 461 + */ 462 + while ((parent = rb_parent(node)) && node == parent->rb_right) 463 + node = parent; 464 + 465 + return parent; 466 + } 467 + 468 + struct rb_node *rb_prev(const struct rb_node *node) 469 + { 470 + struct rb_node *parent; 471 + 472 + if (RB_EMPTY_NODE(node)) 473 + return NULL; 474 + 475 + /* 476 + * If we have a left-hand child, go down and then right as far 477 + * as we can. 478 + */ 479 + if (node->rb_left) { 480 + node = node->rb_left; 481 + while (node->rb_right) 482 + node=node->rb_right; 483 + return (struct rb_node *)node; 484 + } 485 + 486 + /* 487 + * No left-hand children. Go up till we find an ancestor which 488 + * is a right-hand child of its parent. 489 + */ 490 + while ((parent = rb_parent(node)) && node == parent->rb_left) 491 + node = parent; 492 + 493 + return parent; 494 + } 495 + 496 + void rb_replace_node(struct rb_node *victim, struct rb_node *new, 497 + struct rb_root *root) 498 + { 499 + struct rb_node *parent = rb_parent(victim); 500 + 501 + /* Set the surrounding nodes to point to the replacement */ 502 + __rb_change_child(victim, new, parent, root); 503 + if (victim->rb_left) 504 + rb_set_parent(victim->rb_left, new); 505 + if (victim->rb_right) 506 + rb_set_parent(victim->rb_right, new); 507 + 508 + /* Copy the pointers/colour from the victim to the replacement */ 509 + *new = *victim; 510 + } 511 + 512 + static struct rb_node *rb_left_deepest_node(const struct rb_node *node) 513 + { 514 + for (;;) { 515 + if (node->rb_left) 516 + node = node->rb_left; 517 + else if (node->rb_right) 518 + node = node->rb_right; 519 + else 520 + return (struct rb_node *)node; 521 + } 522 + } 523 + 524 + struct rb_node *rb_next_postorder(const struct rb_node *node) 525 + { 526 + const struct rb_node *parent; 527 + if (!node) 528 + return NULL; 529 + parent = rb_parent(node); 530 + 531 + /* If we're sitting on node, we've already seen our children */ 532 + if (parent && node == parent->rb_left && parent->rb_right) { 533 + /* If we are the parent's left node, go to the parent's right 534 + * node then all the way down to the left */ 535 + return rb_left_deepest_node(parent->rb_right); 536 + } else 537 + /* Otherwise we are the parent's right node, and the parent 538 + * should be next */ 539 + return (struct rb_node *)parent; 540 + } 541 + 542 + struct rb_node *rb_first_postorder(const struct rb_root *root) 543 + { 544 + if (!root->rb_node) 545 + return NULL; 546 + 547 + return rb_left_deepest_node(root->rb_node); 548 + }
+3 -3
tools/perf/MANIFEST
··· 18 18 tools/arch/x86/include/asm/rmwcc.h 19 19 tools/lib/traceevent 20 20 tools/lib/api 21 + tools/lib/rbtree.c 21 22 tools/lib/symbol/kallsyms.c 22 23 tools/lib/symbol/kallsyms.h 23 24 tools/lib/util/find_next_bit.c ··· 45 44 tools/include/linux/list.h 46 45 tools/include/linux/log2.h 47 46 tools/include/linux/poison.h 47 + tools/include/linux/rbtree.h 48 + tools/include/linux/rbtree_augmented.h 48 49 tools/include/linux/types.h 49 50 include/asm-generic/bitops/arch_hweight.h 50 51 include/asm-generic/bitops/const_hweight.h ··· 54 51 include/asm-generic/bitops/__fls.h 55 52 include/asm-generic/bitops/fls.h 56 53 include/linux/perf_event.h 57 - include/linux/rbtree.h 58 54 include/linux/list.h 59 55 include/linux/hash.h 60 56 include/linux/stringify.h 61 57 lib/hweight.c 62 - lib/rbtree.c 63 58 include/linux/swab.h 64 59 arch/*/include/asm/unistd*.h 65 60 arch/*/include/uapi/asm/unistd*.h ··· 66 65 arch/*/lib/memset*.S 67 66 include/linux/poison.h 68 67 include/linux/hw_breakpoint.h 69 - include/linux/rbtree_augmented.h 70 68 include/uapi/linux/perf_event.h 71 69 include/uapi/linux/const.h 72 70 include/uapi/linux/swab.h
+1 -1
tools/perf/util/Build
··· 139 139 $(call rule_mkdir) 140 140 $(call if_changed_dep,cc_o_c) 141 141 142 - $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c FORCE 142 + $(OUTPUT)util/rbtree.o: ../lib/rbtree.c FORCE 143 143 $(call rule_mkdir) 144 144 $(call if_changed_dep,cc_o_c) 145 145
-16
tools/perf/util/include/linux/rbtree.h
··· 1 - #ifndef __TOOLS_LINUX_PERF_RBTREE_H 2 - #define __TOOLS_LINUX_PERF_RBTREE_H 3 - #include <stdbool.h> 4 - #include "../../../../include/linux/rbtree.h" 5 - 6 - /* 7 - * Handy for checking that we are not deleting an entry that is 8 - * already in a list, found in block/{blk-throttle,cfq-iosched}.c, 9 - * probably should be moved to lib/rbtree.c... 10 - */ 11 - static inline void rb_erase_init(struct rb_node *n, struct rb_root *root) 12 - { 13 - rb_erase(n, root); 14 - RB_CLEAR_NODE(n); 15 - } 16 - #endif /* __TOOLS_LINUX_PERF_RBTREE_H */
-2
tools/perf/util/include/linux/rbtree_augmented.h
··· 1 - #include <stdbool.h> 2 - #include "../../../../include/linux/rbtree_augmented.h"
+3
tools/testing/nvdimm/Kbuild
··· 1 + ldflags-y += --wrap=ioremap_wt 2 + ldflags-y += --wrap=ioremap_wc 3 + ldflags-y += --wrap=devm_ioremap_nocache 1 4 ldflags-y += --wrap=ioremap_cache 2 5 ldflags-y += --wrap=ioremap_nocache 3 6 ldflags-y += --wrap=iounmap
+27
tools/testing/nvdimm/test/iomap.c
··· 65 65 return fallback_fn(offset, size); 66 66 } 67 67 68 + void __iomem *__wrap_devm_ioremap_nocache(struct device *dev, 69 + resource_size_t offset, unsigned long size) 70 + { 71 + struct nfit_test_resource *nfit_res; 72 + 73 + rcu_read_lock(); 74 + nfit_res = get_nfit_res(offset); 75 + rcu_read_unlock(); 76 + if (nfit_res) 77 + return (void __iomem *) nfit_res->buf + offset 78 + - nfit_res->res->start; 79 + return devm_ioremap_nocache(dev, offset, size); 80 + } 81 + EXPORT_SYMBOL(__wrap_devm_ioremap_nocache); 82 + 68 83 void __iomem *__wrap_ioremap_cache(resource_size_t offset, unsigned long size) 69 84 { 70 85 return __nfit_test_ioremap(offset, size, ioremap_cache); ··· 91 76 return __nfit_test_ioremap(offset, size, ioremap_nocache); 92 77 } 93 78 EXPORT_SYMBOL(__wrap_ioremap_nocache); 79 + 80 + void __iomem *__wrap_ioremap_wt(resource_size_t offset, unsigned long size) 81 + { 82 + return __nfit_test_ioremap(offset, size, ioremap_wt); 83 + } 84 + EXPORT_SYMBOL(__wrap_ioremap_wt); 85 + 86 + void __iomem *__wrap_ioremap_wc(resource_size_t offset, unsigned long size) 87 + { 88 + return __nfit_test_ioremap(offset, size, ioremap_wc); 89 + } 90 + EXPORT_SYMBOL(__wrap_ioremap_wc); 94 91 95 92 void __wrap_iounmap(volatile void __iomem *addr) 96 93 {
+49 -3
tools/testing/nvdimm/test/nfit.c
··· 128 128 int num_pm; 129 129 void **dimm; 130 130 dma_addr_t *dimm_dma; 131 + void **flush; 132 + dma_addr_t *flush_dma; 131 133 void **label; 132 134 dma_addr_t *label_dma; 133 135 void **spa_set; ··· 157 155 int i, rc; 158 156 159 157 if (!nfit_mem || !test_bit(cmd, &nfit_mem->dsm_mask)) 160 - return -ENXIO; 158 + return -ENOTTY; 161 159 162 160 /* lookup label space for the given dimm */ 163 161 for (i = 0; i < ARRAY_SIZE(handle); i++) ··· 333 331 + sizeof(struct acpi_nfit_system_address) * NUM_SPA 334 332 + sizeof(struct acpi_nfit_memory_map) * NUM_MEM 335 333 + sizeof(struct acpi_nfit_control_region) * NUM_DCR 336 - + sizeof(struct acpi_nfit_data_region) * NUM_BDW; 334 + + sizeof(struct acpi_nfit_data_region) * NUM_BDW 335 + + sizeof(struct acpi_nfit_flush_address) * NUM_DCR; 337 336 int i; 338 337 339 338 t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma); ··· 359 356 if (!t->label[i]) 360 357 return -ENOMEM; 361 358 sprintf(t->label[i], "label%d", i); 359 + 360 + t->flush[i] = test_alloc(t, 8, &t->flush_dma[i]); 361 + if (!t->flush[i]) 362 + return -ENOMEM; 362 363 } 363 364 364 365 for (i = 0; i < NUM_DCR; i++) { ··· 415 408 struct acpi_nfit_system_address *spa; 416 409 struct acpi_nfit_control_region *dcr; 417 410 struct acpi_nfit_data_region *bdw; 411 + struct acpi_nfit_flush_address *flush; 418 412 unsigned int offset; 419 413 420 414 nfit_test_init_header(nfit_buf, size); ··· 839 831 bdw->capacity = DIMM_SIZE; 840 832 bdw->start_address = 0; 841 833 834 + offset = offset + sizeof(struct acpi_nfit_data_region) * 4; 835 + /* flush0 (dimm0) */ 836 + flush = nfit_buf + offset; 837 + flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 838 + flush->header.length = sizeof(struct acpi_nfit_flush_address); 839 + flush->device_handle = handle[0]; 840 + flush->hint_count = 1; 841 + flush->hint_address[0] = t->flush_dma[0]; 842 + 843 + /* flush1 (dimm1) */ 844 + flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 1; 845 + flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 846 + flush->header.length = sizeof(struct acpi_nfit_flush_address); 847 + flush->device_handle = handle[1]; 848 + flush->hint_count = 1; 849 + flush->hint_address[0] = t->flush_dma[1]; 850 + 851 + /* flush2 (dimm2) */ 852 + flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 2; 853 + flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 854 + flush->header.length = sizeof(struct acpi_nfit_flush_address); 855 + flush->device_handle = handle[2]; 856 + flush->hint_count = 1; 857 + flush->hint_address[0] = t->flush_dma[2]; 858 + 859 + /* flush3 (dimm3) */ 860 + flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 3; 861 + flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 862 + flush->header.length = sizeof(struct acpi_nfit_flush_address); 863 + flush->device_handle = handle[3]; 864 + flush->hint_count = 1; 865 + flush->hint_address[0] = t->flush_dma[3]; 866 + 842 867 acpi_desc = &t->acpi_desc; 843 868 set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en); 844 869 set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en); ··· 974 933 GFP_KERNEL); 975 934 nfit_test->dimm_dma = devm_kcalloc(dev, num, sizeof(dma_addr_t), 976 935 GFP_KERNEL); 936 + nfit_test->flush = devm_kcalloc(dev, num, sizeof(void *), 937 + GFP_KERNEL); 938 + nfit_test->flush_dma = devm_kcalloc(dev, num, sizeof(dma_addr_t), 939 + GFP_KERNEL); 977 940 nfit_test->label = devm_kcalloc(dev, num, sizeof(void *), 978 941 GFP_KERNEL); 979 942 nfit_test->label_dma = devm_kcalloc(dev, num, ··· 988 943 sizeof(dma_addr_t), GFP_KERNEL); 989 944 if (nfit_test->dimm && nfit_test->dimm_dma && nfit_test->label 990 945 && nfit_test->label_dma && nfit_test->dcr 991 - && nfit_test->dcr_dma) 946 + && nfit_test->dcr_dma && nfit_test->flush 947 + && nfit_test->flush_dma) 992 948 /* pass */; 993 949 else 994 950 return -ENOMEM;