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

Configure Feed

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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

No conflicts.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+2630 -1722
+4
CREDITS
··· 627 627 S: Fremont, California 94539 628 628 S: USA 629 629 630 + N: Tomas Cech 631 + E: sleep_walker@suse.com 632 + D: arm/palm treo support 633 + 630 634 N: Florent Chabaud 631 635 E: florent.chabaud@polytechnique.org 632 636 D: software suspend
+1
Documentation/devicetree/bindings/display/allwinner,sun4i-a10-display-engine.yaml
··· 94 94 - allwinner,sun8i-a83t-display-engine 95 95 - allwinner,sun8i-r40-display-engine 96 96 - allwinner,sun9i-a80-display-engine 97 + - allwinner,sun20i-d1-display-engine 97 98 - allwinner,sun50i-a64-display-engine 98 99 99 100 then:
+5 -3
Documentation/filesystems/netfs_library.rst
··· 301 301 void (*issue_read)(struct netfs_io_subrequest *subreq); 302 302 bool (*is_still_valid)(struct netfs_io_request *rreq); 303 303 int (*check_write_begin)(struct file *file, loff_t pos, unsigned len, 304 - struct folio *folio, void **_fsdata); 304 + struct folio **foliop, void **_fsdata); 305 305 void (*done)(struct netfs_io_request *rreq); 306 306 }; 307 307 ··· 381 381 allocated/grabbed the folio to be modified to allow the filesystem to flush 382 382 conflicting state before allowing it to be modified. 383 383 384 - It should return 0 if everything is now fine, -EAGAIN if the folio should be 385 - regrabbed and any other error code to abort the operation. 384 + It may unlock and discard the folio it was given and set the caller's folio 385 + pointer to NULL. It should return 0 if everything is now fine (``*foliop`` 386 + left set) or the op should be retried (``*foliop`` cleared) and any other 387 + error code to abort the operation. 386 388 387 389 * ``done`` 388 390
+303 -60
Documentation/networking/dsa/dsa.rst
··· 503 503 Driver development 504 504 ================== 505 505 506 - DSA switch drivers need to implement a dsa_switch_ops structure which will 506 + DSA switch drivers need to implement a ``dsa_switch_ops`` structure which will 507 507 contain the various members described below. 508 508 509 - ``register_switch_driver()`` registers this dsa_switch_ops in its internal list 510 - of drivers to probe for. ``unregister_switch_driver()`` does the exact opposite. 509 + Probing, registration and device lifetime 510 + ----------------------------------------- 511 511 512 - Unless requested differently by setting the priv_size member accordingly, DSA 513 - does not allocate any driver private context space. 512 + DSA switches are regular ``device`` structures on buses (be they platform, SPI, 513 + I2C, MDIO or otherwise). The DSA framework is not involved in their probing 514 + with the device core. 515 + 516 + Switch registration from the perspective of a driver means passing a valid 517 + ``struct dsa_switch`` pointer to ``dsa_register_switch()``, usually from the 518 + switch driver's probing function. The following members must be valid in the 519 + provided structure: 520 + 521 + - ``ds->dev``: will be used to parse the switch's OF node or platform data. 522 + 523 + - ``ds->num_ports``: will be used to create the port list for this switch, and 524 + to validate the port indices provided in the OF node. 525 + 526 + - ``ds->ops``: a pointer to the ``dsa_switch_ops`` structure holding the DSA 527 + method implementations. 528 + 529 + - ``ds->priv``: backpointer to a driver-private data structure which can be 530 + retrieved in all further DSA method callbacks. 531 + 532 + In addition, the following flags in the ``dsa_switch`` structure may optionally 533 + be configured to obtain driver-specific behavior from the DSA core. Their 534 + behavior when set is documented through comments in ``include/net/dsa.h``. 535 + 536 + - ``ds->vlan_filtering_is_global`` 537 + 538 + - ``ds->needs_standalone_vlan_filtering`` 539 + 540 + - ``ds->configure_vlan_while_not_filtering`` 541 + 542 + - ``ds->untag_bridge_pvid`` 543 + 544 + - ``ds->assisted_learning_on_cpu_port`` 545 + 546 + - ``ds->mtu_enforcement_ingress`` 547 + 548 + - ``ds->fdb_isolation`` 549 + 550 + Internally, DSA keeps an array of switch trees (group of switches) global to 551 + the kernel, and attaches a ``dsa_switch`` structure to a tree on registration. 552 + The tree ID to which the switch is attached is determined by the first u32 553 + number of the ``dsa,member`` property of the switch's OF node (0 if missing). 554 + The switch ID within the tree is determined by the second u32 number of the 555 + same OF property (0 if missing). Registering multiple switches with the same 556 + switch ID and tree ID is illegal and will cause an error. Using platform data, 557 + a single switch and a single switch tree is permitted. 558 + 559 + In case of a tree with multiple switches, probing takes place asymmetrically. 560 + The first N-1 callers of ``dsa_register_switch()`` only add their ports to the 561 + port list of the tree (``dst->ports``), each port having a backpointer to its 562 + associated switch (``dp->ds``). Then, these switches exit their 563 + ``dsa_register_switch()`` call early, because ``dsa_tree_setup_routing_table()`` 564 + has determined that the tree is not yet complete (not all ports referenced by 565 + DSA links are present in the tree's port list). The tree becomes complete when 566 + the last switch calls ``dsa_register_switch()``, and this triggers the effective 567 + continuation of initialization (including the call to ``ds->ops->setup()``) for 568 + all switches within that tree, all as part of the calling context of the last 569 + switch's probe function. 570 + 571 + The opposite of registration takes place when calling ``dsa_unregister_switch()``, 572 + which removes a switch's ports from the port list of the tree. The entire tree 573 + is torn down when the first switch unregisters. 574 + 575 + It is mandatory for DSA switch drivers to implement the ``shutdown()`` callback 576 + of their respective bus, and call ``dsa_switch_shutdown()`` from it (a minimal 577 + version of the full teardown performed by ``dsa_unregister_switch()``). 578 + The reason is that DSA keeps a reference on the master net device, and if the 579 + driver for the master device decides to unbind on shutdown, DSA's reference 580 + will block that operation from finalizing. 581 + 582 + Either ``dsa_switch_shutdown()`` or ``dsa_unregister_switch()`` must be called, 583 + but not both, and the device driver model permits the bus' ``remove()`` method 584 + to be called even if ``shutdown()`` was already called. Therefore, drivers are 585 + expected to implement a mutual exclusion method between ``remove()`` and 586 + ``shutdown()`` by setting their drvdata to NULL after any of these has run, and 587 + checking whether the drvdata is NULL before proceeding to take any action. 588 + 589 + After ``dsa_switch_shutdown()`` or ``dsa_unregister_switch()`` was called, no 590 + further callbacks via the provided ``dsa_switch_ops`` may take place, and the 591 + driver may free the data structures associated with the ``dsa_switch``. 514 592 515 593 Switch configuration 516 594 -------------------- 517 595 518 - - ``tag_protocol``: this is to indicate what kind of tagging protocol is supported, 519 - should be a valid value from the ``dsa_tag_protocol`` enum 596 + - ``get_tag_protocol``: this is to indicate what kind of tagging protocol is 597 + supported, should be a valid value from the ``dsa_tag_protocol`` enum. 598 + The returned information does not have to be static; the driver is passed the 599 + CPU port number, as well as the tagging protocol of a possibly stacked 600 + upstream switch, in case there are hardware limitations in terms of supported 601 + tag formats. 520 602 521 - - ``probe``: probe routine which will be invoked by the DSA platform device upon 522 - registration to test for the presence/absence of a switch device. For MDIO 523 - devices, it is recommended to issue a read towards internal registers using 524 - the switch pseudo-PHY and return whether this is a supported device. For other 525 - buses, return a non-NULL string 603 + - ``change_tag_protocol``: when the default tagging protocol has compatibility 604 + problems with the master or other issues, the driver may support changing it 605 + at runtime, either through a device tree property or through sysfs. In that 606 + case, further calls to ``get_tag_protocol`` should report the protocol in 607 + current use. 526 608 527 609 - ``setup``: setup function for the switch, this function is responsible for setting 528 610 up the ``dsa_switch_ops`` private structure with all it needs: register maps, ··· 617 535 fully configured and ready to serve any kind of request. It is recommended 618 536 to issue a software reset of the switch during this setup function in order to 619 537 avoid relying on what a previous software agent such as a bootloader/firmware 620 - may have previously configured. 538 + may have previously configured. The method responsible for undoing any 539 + applicable allocations or operations done here is ``teardown``. 540 + 541 + - ``port_setup`` and ``port_teardown``: methods for initialization and 542 + destruction of per-port data structures. It is mandatory for some operations 543 + such as registering and unregistering devlink port regions to be done from 544 + these methods, otherwise they are optional. A port will be torn down only if 545 + it has been previously set up. It is possible for a port to be set up during 546 + probing only to be torn down immediately afterwards, for example in case its 547 + PHY cannot be found. In this case, probing of the DSA switch continues 548 + without that particular port. 621 549 622 550 PHY devices and link management 623 551 ------------------------------- ··· 727 635 ``BR_STATE_DISABLED`` and propagating changes to the hardware if this port is 728 636 disabled while being a bridge member 729 637 638 + Address databases 639 + ----------------- 640 + 641 + Switching hardware is expected to have a table for FDB entries, however not all 642 + of them are active at the same time. An address database is the subset (partition) 643 + of FDB entries that is active (can be matched by address learning on RX, or FDB 644 + lookup on TX) depending on the state of the port. An address database may 645 + occasionally be called "FID" (Filtering ID) in this document, although the 646 + underlying implementation may choose whatever is available to the hardware. 647 + 648 + For example, all ports that belong to a VLAN-unaware bridge (which is 649 + *currently* VLAN-unaware) are expected to learn source addresses in the 650 + database associated by the driver with that bridge (and not with other 651 + VLAN-unaware bridges). During forwarding and FDB lookup, a packet received on a 652 + VLAN-unaware bridge port should be able to find a VLAN-unaware FDB entry having 653 + the same MAC DA as the packet, which is present on another port member of the 654 + same bridge. At the same time, the FDB lookup process must be able to not find 655 + an FDB entry having the same MAC DA as the packet, if that entry points towards 656 + a port which is a member of a different VLAN-unaware bridge (and is therefore 657 + associated with a different address database). 658 + 659 + Similarly, each VLAN of each offloaded VLAN-aware bridge should have an 660 + associated address database, which is shared by all ports which are members of 661 + that VLAN, but not shared by ports belonging to different bridges that are 662 + members of the same VID. 663 + 664 + In this context, a VLAN-unaware database means that all packets are expected to 665 + match on it irrespective of VLAN ID (only MAC address lookup), whereas a 666 + VLAN-aware database means that packets are supposed to match based on the VLAN 667 + ID from the classified 802.1Q header (or the pvid if untagged). 668 + 669 + At the bridge layer, VLAN-unaware FDB entries have the special VID value of 0, 670 + whereas VLAN-aware FDB entries have non-zero VID values. Note that a 671 + VLAN-unaware bridge may have VLAN-aware (non-zero VID) FDB entries, and a 672 + VLAN-aware bridge may have VLAN-unaware FDB entries. As in hardware, the 673 + software bridge keeps separate address databases, and offloads to hardware the 674 + FDB entries belonging to these databases, through switchdev, asynchronously 675 + relative to the moment when the databases become active or inactive. 676 + 677 + When a user port operates in standalone mode, its driver should configure it to 678 + use a separate database called a port private database. This is different from 679 + the databases described above, and should impede operation as standalone port 680 + (packet in, packet out to the CPU port) as little as possible. For example, 681 + on ingress, it should not attempt to learn the MAC SA of ingress traffic, since 682 + learning is a bridging layer service and this is a standalone port, therefore 683 + it would consume useless space. With no address learning, the port private 684 + database should be empty in a naive implementation, and in this case, all 685 + received packets should be trivially flooded to the CPU port. 686 + 687 + DSA (cascade) and CPU ports are also called "shared" ports because they service 688 + multiple address databases, and the database that a packet should be associated 689 + to is usually embedded in the DSA tag. This means that the CPU port may 690 + simultaneously transport packets coming from a standalone port (which were 691 + classified by hardware in one address database), and from a bridge port (which 692 + were classified to a different address database). 693 + 694 + Switch drivers which satisfy certain criteria are able to optimize the naive 695 + configuration by removing the CPU port from the flooding domain of the switch, 696 + and just program the hardware with FDB entries pointing towards the CPU port 697 + for which it is known that software is interested in those MAC addresses. 698 + Packets which do not match a known FDB entry will not be delivered to the CPU, 699 + which will save CPU cycles required for creating an skb just to drop it. 700 + 701 + DSA is able to perform host address filtering for the following kinds of 702 + addresses: 703 + 704 + - Primary unicast MAC addresses of ports (``dev->dev_addr``). These are 705 + associated with the port private database of the respective user port, 706 + and the driver is notified to install them through ``port_fdb_add`` towards 707 + the CPU port. 708 + 709 + - Secondary unicast and multicast MAC addresses of ports (addresses added 710 + through ``dev_uc_add()`` and ``dev_mc_add()``). These are also associated 711 + with the port private database of the respective user port. 712 + 713 + - Local/permanent bridge FDB entries (``BR_FDB_LOCAL``). These are the MAC 714 + addresses of the bridge ports, for which packets must be terminated locally 715 + and not forwarded. They are associated with the address database for that 716 + bridge. 717 + 718 + - Static bridge FDB entries installed towards foreign (non-DSA) interfaces 719 + present in the same bridge as some DSA switch ports. These are also 720 + associated with the address database for that bridge. 721 + 722 + - Dynamically learned FDB entries on foreign interfaces present in the same 723 + bridge as some DSA switch ports, only if ``ds->assisted_learning_on_cpu_port`` 724 + is set to true by the driver. These are associated with the address database 725 + for that bridge. 726 + 727 + For various operations detailed below, DSA provides a ``dsa_db`` structure 728 + which can be of the following types: 729 + 730 + - ``DSA_DB_PORT``: the FDB (or MDB) entry to be installed or deleted belongs to 731 + the port private database of user port ``db->dp``. 732 + - ``DSA_DB_BRIDGE``: the entry belongs to one of the address databases of bridge 733 + ``db->bridge``. Separation between the VLAN-unaware database and the per-VID 734 + databases of this bridge is expected to be done by the driver. 735 + - ``DSA_DB_LAG``: the entry belongs to the address database of LAG ``db->lag``. 736 + Note: ``DSA_DB_LAG`` is currently unused and may be removed in the future. 737 + 738 + The drivers which act upon the ``dsa_db`` argument in ``port_fdb_add``, 739 + ``port_mdb_add`` etc should declare ``ds->fdb_isolation`` as true. 740 + 741 + DSA associates each offloaded bridge and each offloaded LAG with a one-based ID 742 + (``struct dsa_bridge :: num``, ``struct dsa_lag :: id``) for the purposes of 743 + refcounting addresses on shared ports. Drivers may piggyback on DSA's numbering 744 + scheme (the ID is readable through ``db->bridge.num`` and ``db->lag.id`` or may 745 + implement their own. 746 + 747 + Only the drivers which declare support for FDB isolation are notified of FDB 748 + entries on the CPU port belonging to ``DSA_DB_PORT`` databases. 749 + For compatibility/legacy reasons, ``DSA_DB_BRIDGE`` addresses are notified to 750 + drivers even if they do not support FDB isolation. However, ``db->bridge.num`` 751 + and ``db->lag.id`` are always set to 0 in that case (to denote the lack of 752 + isolation, for refcounting purposes). 753 + 754 + Note that it is not mandatory for a switch driver to implement physically 755 + separate address databases for each standalone user port. Since FDB entries in 756 + the port private databases will always point to the CPU port, there is no risk 757 + for incorrect forwarding decisions. In this case, all standalone ports may 758 + share the same database, but the reference counting of host-filtered addresses 759 + (not deleting the FDB entry for a port's MAC address if it's still in use by 760 + another port) becomes the responsibility of the driver, because DSA is unaware 761 + that the port databases are in fact shared. This can be achieved by calling 762 + ``dsa_fdb_present_in_other_db()`` and ``dsa_mdb_present_in_other_db()``. 763 + The down side is that the RX filtering lists of each user port are in fact 764 + shared, which means that user port A may accept a packet with a MAC DA it 765 + shouldn't have, only because that MAC address was in the RX filtering list of 766 + user port B. These packets will still be dropped in software, however. 767 + 730 768 Bridge layer 731 769 ------------ 770 + 771 + Offloading the bridge forwarding plane is optional and handled by the methods 772 + below. They may be absent, return -EOPNOTSUPP, or ``ds->max_num_bridges`` may 773 + be non-zero and exceeded, and in this case, joining a bridge port is still 774 + possible, but the packet forwarding will take place in software, and the ports 775 + under a software bridge must remain configured in the same way as for 776 + standalone operation, i.e. have all bridging service functions (address 777 + learning etc) disabled, and send all received packets to the CPU port only. 778 + 779 + Concretely, a port starts offloading the forwarding plane of a bridge once it 780 + returns success to the ``port_bridge_join`` method, and stops doing so after 781 + ``port_bridge_leave`` has been called. Offloading the bridge means autonomously 782 + learning FDB entries in accordance with the software bridge port's state, and 783 + autonomously forwarding (or flooding) received packets without CPU intervention. 784 + This is optional even when offloading a bridge port. Tagging protocol drivers 785 + are expected to call ``dsa_default_offload_fwd_mark(skb)`` for packets which 786 + have already been autonomously forwarded in the forwarding domain of the 787 + ingress switch port. DSA, through ``dsa_port_devlink_setup()``, considers all 788 + switch ports part of the same tree ID to be part of the same bridge forwarding 789 + domain (capable of autonomous forwarding to each other). 790 + 791 + Offloading the TX forwarding process of a bridge is a distinct concept from 792 + simply offloading its forwarding plane, and refers to the ability of certain 793 + driver and tag protocol combinations to transmit a single skb coming from the 794 + bridge device's transmit function to potentially multiple egress ports (and 795 + thereby avoid its cloning in software). 796 + 797 + Packets for which the bridge requests this behavior are called data plane 798 + packets and have ``skb->offload_fwd_mark`` set to true in the tag protocol 799 + driver's ``xmit`` function. Data plane packets are subject to FDB lookup, 800 + hardware learning on the CPU port, and do not override the port STP state. 801 + Additionally, replication of data plane packets (multicast, flooding) is 802 + handled in hardware and the bridge driver will transmit a single skb for each 803 + packet that may or may not need replication. 804 + 805 + When the TX forwarding offload is enabled, the tag protocol driver is 806 + responsible to inject packets into the data plane of the hardware towards the 807 + correct bridging domain (FID) that the port is a part of. The port may be 808 + VLAN-unaware, and in this case the FID must be equal to the FID used by the 809 + driver for its VLAN-unaware address database associated with that bridge. 810 + Alternatively, the bridge may be VLAN-aware, and in that case, it is guaranteed 811 + that the packet is also VLAN-tagged with the VLAN ID that the bridge processed 812 + this packet in. It is the responsibility of the hardware to untag the VID on 813 + the egress-untagged ports, or keep the tag on the egress-tagged ones. 732 814 733 815 - ``port_bridge_join``: bridge layer function invoked when a given switch port is 734 816 added to a bridge, this function should do what's necessary at the switch 735 817 level to permit the joining port to be added to the relevant logical 736 818 domain for it to ingress/egress traffic with other members of the bridge. 819 + By setting the ``tx_fwd_offload`` argument to true, the TX forwarding process 820 + of this bridge is also offloaded. 737 821 738 822 - ``port_bridge_leave``: bridge layer function invoked when a given switch port is 739 823 removed from a bridge, this function should do what's necessary at the 740 824 switch level to deny the leaving port from ingress/egress traffic from the 741 - remaining bridge members. When the port leaves the bridge, it should be aged 742 - out at the switch hardware for the switch to (re) learn MAC addresses behind 743 - this port. 825 + remaining bridge members. 744 826 745 827 - ``port_stp_state_set``: bridge layer function invoked when a given switch port STP 746 828 state is computed by the bridge layer and should be propagated to switch 747 - hardware to forward/block/learn traffic. The switch driver is responsible for 748 - computing a STP state change based on current and asked parameters and perform 749 - the relevant ageing based on the intersection results 829 + hardware to forward/block/learn traffic. 750 830 751 831 - ``port_bridge_flags``: bridge layer function invoked when a port must 752 832 configure its settings for e.g. flooding of unknown traffic or source address ··· 931 667 CPU port, and flooding towards the CPU port should also be enabled, due to a 932 668 lack of an explicit address filtering mechanism in the DSA core. 933 669 934 - - ``port_bridge_tx_fwd_offload``: bridge layer function invoked after 935 - ``port_bridge_join`` when a driver sets ``ds->num_fwd_offloading_bridges`` to 936 - a non-zero value. Returning success in this function activates the TX 937 - forwarding offload bridge feature for this port, which enables the tagging 938 - protocol driver to inject data plane packets towards the bridging domain that 939 - the port is a part of. Data plane packets are subject to FDB lookup, hardware 940 - learning on the CPU port, and do not override the port STP state. 941 - Additionally, replication of data plane packets (multicast, flooding) is 942 - handled in hardware and the bridge driver will transmit a single skb for each 943 - packet that needs replication. The method is provided as a configuration 944 - point for drivers that need to configure the hardware for enabling this 945 - feature. 946 - 947 - - ``port_bridge_tx_fwd_unoffload``: bridge layer function invoked when a driver 948 - leaves a bridge port which had the TX forwarding offload feature enabled. 670 + - ``port_fast_age``: bridge layer function invoked when flushing the 671 + dynamically learned FDB entries on the port is necessary. This is called when 672 + transitioning from an STP state where learning should take place to an STP 673 + state where it shouldn't, or when leaving a bridge, or when address learning 674 + is turned off via ``port_bridge_flags``. 949 675 950 676 Bridge VLAN filtering 951 677 --------------------- ··· 951 697 allowed. 952 698 953 699 - ``port_vlan_add``: bridge layer function invoked when a VLAN is configured 954 - (tagged or untagged) for the given switch port. If the operation is not 955 - supported by the hardware, this function should return ``-EOPNOTSUPP`` to 956 - inform the bridge code to fallback to a software implementation. 700 + (tagged or untagged) for the given switch port. The CPU port becomes a member 701 + of a VLAN only if a foreign bridge port is also a member of it (and 702 + forwarding needs to take place in software), or the VLAN is installed to the 703 + VLAN group of the bridge device itself, for termination purposes 704 + (``bridge vlan add dev br0 vid 100 self``). VLANs on shared ports are 705 + reference counted and removed when there is no user left. Drivers do not need 706 + to manually install a VLAN on the CPU port. 957 707 958 708 - ``port_vlan_del``: bridge layer function invoked when a VLAN is removed from the 959 709 given switch port 960 710 961 - - ``port_vlan_dump``: bridge layer function invoked with a switchdev callback 962 - function that the driver has to call for each VLAN the given port is a member 963 - of. A switchdev object is used to carry the VID and bridge flags. 964 - 965 711 - ``port_fdb_add``: bridge layer function invoked when the bridge wants to install a 966 712 Forwarding Database entry, the switch hardware should be programmed with the 967 713 specified address in the specified VLAN Id in the forwarding database 968 - associated with this VLAN ID. If the operation is not supported, this 969 - function should return ``-EOPNOTSUPP`` to inform the bridge code to fallback to 970 - a software implementation. 971 - 972 - .. note:: VLAN ID 0 corresponds to the port private database, which, in the context 973 - of DSA, would be its port-based VLAN, used by the associated bridge device. 714 + associated with this VLAN ID. 974 715 975 716 - ``port_fdb_del``: bridge layer function invoked when the bridge wants to remove a 976 717 Forwarding Database entry, the switch hardware should be programmed to delete 977 718 the specified MAC address from the specified VLAN ID if it was mapped into 978 719 this port forwarding database 979 720 980 - - ``port_fdb_dump``: bridge layer function invoked with a switchdev callback 981 - function that the driver has to call for each MAC address known to be behind 982 - the given port. A switchdev object is used to carry the VID and FDB info. 721 + - ``port_fdb_dump``: bridge bypass function invoked by ``ndo_fdb_dump`` on the 722 + physical DSA port interfaces. Since DSA does not attempt to keep in sync its 723 + hardware FDB entries with the software bridge, this method is implemented as 724 + a means to view the entries visible on user ports in the hardware database. 725 + The entries reported by this function have the ``self`` flag in the output of 726 + the ``bridge fdb show`` command. 983 727 984 728 - ``port_mdb_add``: bridge layer function invoked when the bridge wants to install 985 - a multicast database entry. If the operation is not supported, this function 986 - should return ``-EOPNOTSUPP`` to inform the bridge code to fallback to a 987 - software implementation. The switch hardware should be programmed with the 729 + a multicast database entry. The switch hardware should be programmed with the 988 730 specified address in the specified VLAN ID in the forwarding database 989 731 associated with this VLAN ID. 990 - 991 - .. note:: VLAN ID 0 corresponds to the port private database, which, in the context 992 - of DSA, would be its port-based VLAN, used by the associated bridge device. 993 732 994 733 - ``port_mdb_del``: bridge layer function invoked when the bridge wants to remove a 995 734 multicast database entry, the switch hardware should be programmed to delete 996 735 the specified MAC address from the specified VLAN ID if it was mapped into 997 736 this port forwarding database. 998 - 999 - - ``port_mdb_dump``: bridge layer function invoked with a switchdev callback 1000 - function that the driver has to call for each MAC address known to be behind 1001 - the given port. A switchdev object is used to carry the VID and MDB info. 1002 737 1003 738 Link aggregation 1004 739 ----------------
+1 -5
Documentation/networking/ip-sysctl.rst
··· 1058 1058 Default: 4K 1059 1059 1060 1060 udp_wmem_min - INTEGER 1061 - Minimal size of send buffer used by UDP sockets in moderation. 1062 - Each UDP socket is able to use the size for sending data, even if 1063 - total pages of UDP sockets exceed udp_mem pressure. The unit is byte. 1064 - 1065 - Default: 4K 1061 + UDP does not have tx memory accounting and this tunable has no effect. 1066 1062 1067 1063 RAW variables 1068 1064 =============
+13 -4
Documentation/virt/kvm/api.rst
··· 5657 5657 #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT) 5658 5658 #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT) 5659 5659 #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT) 5660 + #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT) 5660 5661 #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES 5661 5662 5662 5663 #define KVM_STATS_BASE_SHIFT 8 ··· 5703 5702 by the ``hist_param`` field. The range of the Nth bucket (1 <= N < ``size``) 5704 5703 is [``hist_param``*(N-1), ``hist_param``*N), while the range of the last 5705 5704 bucket is [``hist_param``*(``size``-1), +INF). (+INF means positive infinity 5706 - value.) The bucket value indicates how many samples fell in the bucket's range. 5705 + value.) 5707 5706 * ``KVM_STATS_TYPE_LOG_HIST`` 5708 5707 The statistic is reported as a logarithmic histogram. The number of 5709 5708 buckets is specified by the ``size`` field. The range of the first bucket is 5710 5709 [0, 1), while the range of the last bucket is [pow(2, ``size``-2), +INF). 5711 5710 Otherwise, The Nth bucket (1 < N < ``size``) covers 5712 - [pow(2, N-2), pow(2, N-1)). The bucket value indicates how many samples fell 5713 - in the bucket's range. 5711 + [pow(2, N-2), pow(2, N-1)). 5714 5712 5715 5713 Bits 4-7 of ``flags`` encode the unit: 5716 5714 ··· 5724 5724 It indicates that the statistics data is used to measure time or latency. 5725 5725 * ``KVM_STATS_UNIT_CYCLES`` 5726 5726 It indicates that the statistics data is used to measure CPU clock cycles. 5727 + * ``KVM_STATS_UNIT_BOOLEAN`` 5728 + It indicates that the statistic will always be either 0 or 1. Boolean 5729 + statistics of "peak" type will never go back from 1 to 0. Boolean 5730 + statistics can be linear histograms (with two buckets) but not logarithmic 5731 + histograms. 5732 + 5733 + Note that, in the case of histograms, the unit applies to the bucket 5734 + ranges, while the bucket value indicates how many samples fell in the 5735 + bucket's range. 5727 5736 5728 5737 Bits 8-11 of ``flags``, together with ``exponent``, encode the scale of the 5729 5738 unit: ··· 5755 5746 5756 5747 The ``bucket_size`` field is used as a parameter for histogram statistics data. 5757 5748 It is only used by linear histogram statistics data, specifying the size of a 5758 - bucket. 5749 + bucket in the unit expressed by bits 4-11 of ``flags`` together with ``exponent``. 5759 5750 5760 5751 The ``name`` field is the name string of the statistics data. The name string 5761 5752 starts at the end of ``struct kvm_stats_desc``. The maximum length including
+7 -5
MAINTAINERS
··· 2497 2497 N: oxnas 2498 2498 2499 2499 ARM/PALM TREO SUPPORT 2500 - M: Tomas Cech <sleep_walker@suse.com> 2501 2500 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 2502 - S: Maintained 2503 - W: http://hackndev.com 2501 + S: Orphan 2504 2502 F: arch/arm/mach-pxa/palmtreo.* 2505 2503 2506 2504 ARM/PALMTX,PALMT5,PALMLD,PALMTE2,PALMTC SUPPORT ··· 14375 14377 F: drivers/net/phy/nxp-c45-tja11xx.c 14376 14378 14377 14379 NXP FSPI DRIVER 14378 - M: Ashish Kumar <ashish.kumar@nxp.com> 14380 + M: Han Xu <han.xu@nxp.com> 14381 + M: Haibo Chen <haibo.chen@nxp.com> 14379 14382 R: Yogesh Gaur <yogeshgaur.83@gmail.com> 14380 14383 L: linux-spi@vger.kernel.org 14381 14384 S: Maintained ··· 17299 17300 K: riscv 17300 17301 17301 17302 RISC-V/MICROCHIP POLARFIRE SOC SUPPORT 17302 - M: Lewis Hanly <lewis.hanly@microchip.com> 17303 17303 M: Conor Dooley <conor.dooley@microchip.com> 17304 + M: Daire McNamara <daire.mcnamara@microchip.com> 17304 17305 L: linux-riscv@lists.infradead.org 17305 17306 S: Supported 17306 17307 F: arch/riscv/boot/dts/microchip/ 17308 + F: drivers/char/hw_random/mpfs-rng.c 17309 + F: drivers/clk/microchip/clk-mpfs.c 17307 17310 F: drivers/mailbox/mailbox-mpfs.c 17311 + F: drivers/pci/controller/pcie-microchip-host.c 17308 17312 F: drivers/soc/microchip/ 17309 17313 F: include/soc/microchip/mpfs.h 17310 17314
+1 -1
Makefile
··· 2 2 VERSION = 5 3 3 PATCHLEVEL = 19 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc6 5 + EXTRAVERSION = -rc7 6 6 NAME = Superb Owl 7 7 8 8 # *DOCUMENTATION*
+7
arch/Kconfig
··· 438 438 439 439 config MMU_GATHER_NO_RANGE 440 440 bool 441 + select MMU_GATHER_MERGE_VMAS 442 + 443 + config MMU_GATHER_NO_FLUSH_CACHE 444 + bool 445 + 446 + config MMU_GATHER_MERGE_VMAS 447 + bool 441 448 442 449 config MMU_GATHER_NO_GATHER 443 450 bool
+1 -1
arch/arm/boot/dts/imx6qdl-ts7970.dtsi
··· 226 226 reg = <0x28>; 227 227 #gpio-cells = <2>; 228 228 gpio-controller; 229 - ngpio = <32>; 229 + ngpios = <62>; 230 230 }; 231 231 232 232 sgtl5000: codec@a {
+7 -2
arch/arm/boot/dts/imx6ull-colibri.dtsi
··· 166 166 atmel_mxt_ts: touchscreen@4a { 167 167 compatible = "atmel,maxtouch"; 168 168 pinctrl-names = "default"; 169 - pinctrl-0 = <&pinctrl_atmel_conn>; 169 + pinctrl-0 = <&pinctrl_atmel_conn &pinctrl_atmel_snvs_conn>; 170 170 reg = <0x4a>; 171 171 interrupt-parent = <&gpio5>; 172 172 interrupts = <4 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 107 / INT */ ··· 331 331 pinctrl_atmel_conn: atmelconngrp { 332 332 fsl,pins = < 333 333 MX6UL_PAD_JTAG_MOD__GPIO1_IO10 0xb0a0 /* SODIMM 106 */ 334 - MX6ULL_PAD_SNVS_TAMPER4__GPIO5_IO04 0xb0a0 /* SODIMM 107 */ 335 334 >; 336 335 }; 337 336 ··· 683 684 }; 684 685 685 686 &iomuxc_snvs { 687 + pinctrl_atmel_snvs_conn: atmelsnvsconngrp { 688 + fsl,pins = < 689 + MX6ULL_PAD_SNVS_TAMPER4__GPIO5_IO04 0xb0a0 /* SODIMM 107 */ 690 + >; 691 + }; 692 + 686 693 pinctrl_snvs_gpio1: snvsgpio1grp { 687 694 fsl,pins = < 688 695 MX6ULL_PAD_SNVS_TAMPER6__GPIO5_IO06 0x110a0 /* SODIMM 93 */
+4 -4
arch/arm/boot/dts/lan966x-kontron-kswitch-d10-mmt.dtsi
··· 87 87 88 88 phy4: ethernet-phy@5 { 89 89 reg = <5>; 90 - coma-mode-gpios = <&gpio 37 GPIO_ACTIVE_HIGH>; 90 + coma-mode-gpios = <&gpio 37 GPIO_OPEN_DRAIN>; 91 91 }; 92 92 93 93 phy5: ethernet-phy@6 { 94 94 reg = <6>; 95 - coma-mode-gpios = <&gpio 37 GPIO_ACTIVE_HIGH>; 95 + coma-mode-gpios = <&gpio 37 GPIO_OPEN_DRAIN>; 96 96 }; 97 97 98 98 phy6: ethernet-phy@7 { 99 99 reg = <7>; 100 - coma-mode-gpios = <&gpio 37 GPIO_ACTIVE_HIGH>; 100 + coma-mode-gpios = <&gpio 37 GPIO_OPEN_DRAIN>; 101 101 }; 102 102 103 103 phy7: ethernet-phy@8 { 104 104 reg = <8>; 105 - coma-mode-gpios = <&gpio 37 GPIO_ACTIVE_HIGH>; 105 + coma-mode-gpios = <&gpio 37 GPIO_OPEN_DRAIN>; 106 106 }; 107 107 }; 108 108
+26 -4
arch/arm/boot/dts/qcom-msm8974.dtsi
··· 506 506 interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; 507 507 clocks = <&gcc GCC_BLSP1_UART2_APPS_CLK>, <&gcc GCC_BLSP1_AHB_CLK>; 508 508 clock-names = "core", "iface"; 509 + pinctrl-names = "default"; 510 + pinctrl-0 = <&blsp1_uart2_default>; 509 511 status = "disabled"; 510 512 }; 511 513 ··· 583 581 interrupts = <GIC_SPI 113 IRQ_TYPE_NONE>; 584 582 clocks = <&gcc GCC_BLSP2_UART1_APPS_CLK>, <&gcc GCC_BLSP2_AHB_CLK>; 585 583 clock-names = "core", "iface"; 584 + pinctrl-names = "default", "sleep"; 585 + pinctrl-0 = <&blsp2_uart1_default>; 586 + pinctrl-1 = <&blsp2_uart1_sleep>; 586 587 status = "disabled"; 587 588 }; 588 589 ··· 604 599 interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>; 605 600 clocks = <&gcc GCC_BLSP2_UART4_APPS_CLK>, <&gcc GCC_BLSP2_AHB_CLK>; 606 601 clock-names = "core", "iface"; 602 + pinctrl-names = "default"; 603 + pinctrl-0 = <&blsp2_uart4_default>; 607 604 status = "disabled"; 608 605 }; 609 606 ··· 646 639 interrupts = <0 106 IRQ_TYPE_LEVEL_HIGH>; 647 640 clocks = <&gcc GCC_BLSP2_QUP6_I2C_APPS_CLK>, <&gcc GCC_BLSP2_AHB_CLK>; 648 641 clock-names = "core", "iface"; 642 + pinctrl-names = "default", "sleep"; 643 + pinctrl-0 = <&blsp2_i2c6_default>; 644 + pinctrl-1 = <&blsp2_i2c6_sleep>; 649 645 #address-cells = <1>; 650 646 #size-cells = <0>; 651 647 }; ··· 1266 1256 }; 1267 1257 }; 1268 1258 1269 - blsp1_uart2_active: blsp1-uart2-active { 1259 + blsp1_uart2_default: blsp1-uart2-default { 1270 1260 rx { 1271 1261 pins = "gpio5"; 1272 1262 function = "blsp_uart2"; ··· 1282 1272 }; 1283 1273 }; 1284 1274 1285 - blsp2_uart1_active: blsp2-uart1-active { 1275 + blsp2_uart1_default: blsp2-uart1-default { 1286 1276 tx-rts { 1287 1277 pins = "gpio41", "gpio44"; 1288 1278 function = "blsp_uart7"; ··· 1305 1295 bias-pull-down; 1306 1296 }; 1307 1297 1308 - blsp2_uart4_active: blsp2-uart4-active { 1298 + blsp2_uart4_default: blsp2-uart4-default { 1309 1299 tx-rts { 1310 1300 pins = "gpio53", "gpio56"; 1311 1301 function = "blsp_uart10"; ··· 1416 1406 bias-pull-up; 1417 1407 }; 1418 1408 1419 - /* BLSP2_I2C6 info is missing - nobody uses it though? */ 1409 + blsp2_i2c6_default: blsp2-i2c6-default { 1410 + pins = "gpio87", "gpio88"; 1411 + function = "blsp_i2c12"; 1412 + drive-strength = <2>; 1413 + bias-disable; 1414 + }; 1415 + 1416 + blsp2_i2c6_sleep: blsp2-i2c6-sleep { 1417 + pins = "gpio87", "gpio88"; 1418 + function = "blsp_i2c12"; 1419 + drive-strength = <2>; 1420 + bias-pull-up; 1421 + }; 1420 1422 1421 1423 spi8_default: spi8_default { 1422 1424 mosi {
+1 -1
arch/arm/boot/dts/sama5d2.dtsi
··· 1124 1124 clocks = <&pmc PMC_TYPE_PERIPHERAL 55>, <&pmc PMC_TYPE_GCK 55>; 1125 1125 clock-names = "pclk", "gclk"; 1126 1126 assigned-clocks = <&pmc PMC_TYPE_CORE PMC_I2S1_MUX>; 1127 - assigned-parrents = <&pmc PMC_TYPE_GCK 55>; 1127 + assigned-clock-parents = <&pmc PMC_TYPE_GCK 55>; 1128 1128 status = "disabled"; 1129 1129 }; 1130 1130
+1 -1
arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
··· 169 169 flash@0 { 170 170 #address-cells = <1>; 171 171 #size-cells = <1>; 172 - compatible = "mxicy,mx25l1606e", "winbond,w25q128"; 172 + compatible = "mxicy,mx25l1606e", "jedec,spi-nor"; 173 173 reg = <0>; 174 174 spi-max-frequency = <40000000>; 175 175 };
+5 -2
arch/arm/mach-rockchip/pm.c
··· 311 311 &match); 312 312 if (!match) { 313 313 pr_err("Failed to find PMU node\n"); 314 - return; 314 + goto out_put; 315 315 } 316 316 pm_data = (struct rockchip_pm_data *) match->data; 317 317 ··· 320 320 321 321 if (ret) { 322 322 pr_err("%s: matches init error %d\n", __func__, ret); 323 - return; 323 + goto out_put; 324 324 } 325 325 } 326 326 327 327 suspend_set_ops(pm_data->ops); 328 + 329 + out_put: 330 + of_node_put(np); 328 331 }
+8
arch/arm64/boot/dts/broadcom/bcm4908/bcm4906.dtsi
··· 9 9 /delete-node/ cpu@3; 10 10 }; 11 11 12 + timer { 13 + compatible = "arm,armv8-timer"; 14 + interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>, 15 + <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>, 16 + <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>, 17 + <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>; 18 + }; 19 + 12 20 pmu { 13 21 compatible = "arm,cortex-a53-pmu"; 14 22 interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>,
+2
arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi
··· 29 29 device_type = "cpu"; 30 30 compatible = "brcm,brahma-b53"; 31 31 reg = <0x0>; 32 + enable-method = "spin-table"; 33 + cpu-release-addr = <0x0 0xfff8>; 32 34 next-level-cache = <&l2>; 33 35 }; 34 36
+4 -1
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
··· 224 224 little-endian; 225 225 }; 226 226 227 - efuse@1e80000 { 227 + sfp: efuse@1e80000 { 228 228 compatible = "fsl,ls1028a-sfp"; 229 229 reg = <0x0 0x1e80000 0x0 0x10000>; 230 + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL 231 + QORIQ_CLK_PLL_DIV(4)>; 232 + clock-names = "sfp"; 230 233 #address-cells = <1>; 231 234 #size-cells = <1>; 232 235
+3 -1
arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet.dtsi
··· 376 376 <&cru ACLK_VIO>, 377 377 <&cru ACLK_GIC_PRE>, 378 378 <&cru PCLK_DDR>, 379 - <&cru ACLK_HDCP>; 379 + <&cru ACLK_HDCP>, 380 + <&cru ACLK_VDU>; 380 381 assigned-clock-rates = 381 382 <600000000>, <1600000000>, 382 383 <1000000000>, ··· 389 388 <400000000>, 390 389 <200000000>, 391 390 <200000000>, 391 + <400000000>, 392 392 <400000000>; 393 393 }; 394 394
+4 -2
arch/arm64/boot/dts/rockchip/rk3399.dtsi
··· 1462 1462 <&cru HCLK_PERILP1>, <&cru PCLK_PERILP1>, 1463 1463 <&cru ACLK_VIO>, <&cru ACLK_HDCP>, 1464 1464 <&cru ACLK_GIC_PRE>, 1465 - <&cru PCLK_DDR>; 1465 + <&cru PCLK_DDR>, 1466 + <&cru ACLK_VDU>; 1466 1467 assigned-clock-rates = 1467 1468 <594000000>, <800000000>, 1468 1469 <1000000000>, ··· 1474 1473 <100000000>, <50000000>, 1475 1474 <400000000>, <400000000>, 1476 1475 <200000000>, 1477 - <200000000>; 1476 + <200000000>, 1477 + <400000000>; 1478 1478 }; 1479 1479 1480 1480 grf: syscon@ff770000 {
+1
arch/arm64/boot/dts/rockchip/rk3566-quartz64-a.dts
··· 687 687 }; 688 688 689 689 &usb_host0_xhci { 690 + dr_mode = "host"; 690 691 status = "okay"; 691 692 }; 692 693
+1 -1
arch/arm64/boot/dts/rockchip/rk3566-quartz64-b.dts
··· 133 133 assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru SCLK_GMAC1>; 134 134 assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru SCLK_GMAC1>, <&gmac1_clkin>; 135 135 clock_in_out = "input"; 136 - phy-mode = "rgmii-id"; 136 + phy-mode = "rgmii"; 137 137 phy-supply = <&vcc_3v3>; 138 138 pinctrl-names = "default"; 139 139 pinctrl-0 = <&gmac1m1_miim
-15
arch/csky/include/asm/tlb.h
··· 4 4 #define __ASM_CSKY_TLB_H 5 5 6 6 #include <asm/cacheflush.h> 7 - 8 - #define tlb_start_vma(tlb, vma) \ 9 - do { \ 10 - if (!(tlb)->fullmm) \ 11 - flush_cache_range(vma, (vma)->vm_start, (vma)->vm_end); \ 12 - } while (0) 13 - 14 - #define tlb_end_vma(tlb, vma) \ 15 - do { \ 16 - if (!(tlb)->fullmm) \ 17 - flush_tlb_range(vma, (vma)->vm_start, (vma)->vm_end); \ 18 - } while (0) 19 - 20 - #define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) 21 - 22 7 #include <asm-generic/tlb.h> 23 8 24 9 #endif /* __ASM_CSKY_TLB_H */
+1
arch/loongarch/Kconfig
··· 108 108 select TRACE_IRQFLAGS_SUPPORT 109 109 select USE_PERCPU_NUMA_NODE_ID 110 110 select ZONE_DMA32 111 + select MMU_GATHER_MERGE_VMAS if MMU 111 112 112 113 config 32BIT 113 114 bool
-10
arch/loongarch/include/asm/tlb.h
··· 137 137 ); 138 138 } 139 139 140 - /* 141 - * LoongArch doesn't need any special per-pte or per-vma handling, except 142 - * we need to flush cache for area to be unmapped. 143 - */ 144 - #define tlb_start_vma(tlb, vma) \ 145 - do { \ 146 - if (!(tlb)->fullmm) \ 147 - flush_cache_range(vma, vma->vm_start, vma->vm_end); \ 148 - } while (0) 149 - #define tlb_end_vma(tlb, vma) do { } while (0) 150 140 #define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0) 151 141 152 142 static void tlb_flush(struct mmu_gather *tlb);
+1
arch/powerpc/Kconfig
··· 256 256 select IRQ_FORCED_THREADING 257 257 select MMU_GATHER_PAGE_SIZE 258 258 select MMU_GATHER_RCU_TABLE_FREE 259 + select MMU_GATHER_MERGE_VMAS 259 260 select MODULES_USE_ELF_RELA 260 261 select NEED_DMA_MAP_STATE if PPC64 || NOT_COHERENT_CACHE 261 262 select NEED_PER_CPU_EMBED_FIRST_CHUNK if PPC64
-2
arch/powerpc/include/asm/tlb.h
··· 19 19 20 20 #include <linux/pagemap.h> 21 21 22 - #define tlb_start_vma(tlb, vma) do { } while (0) 23 - #define tlb_end_vma(tlb, vma) do { } while (0) 24 22 #define __tlb_remove_tlb_entry __tlb_remove_tlb_entry 25 23 26 24 #define tlb_flush tlb_flush
+4
arch/riscv/boot/dts/microchip/mpfs.dtsi
··· 50 50 riscv,isa = "rv64imafdc"; 51 51 clocks = <&clkcfg CLK_CPU>; 52 52 tlb-split; 53 + next-level-cache = <&cctrllr>; 53 54 status = "okay"; 54 55 55 56 cpu1_intc: interrupt-controller { ··· 78 77 riscv,isa = "rv64imafdc"; 79 78 clocks = <&clkcfg CLK_CPU>; 80 79 tlb-split; 80 + next-level-cache = <&cctrllr>; 81 81 status = "okay"; 82 82 83 83 cpu2_intc: interrupt-controller { ··· 106 104 riscv,isa = "rv64imafdc"; 107 105 clocks = <&clkcfg CLK_CPU>; 108 106 tlb-split; 107 + next-level-cache = <&cctrllr>; 109 108 status = "okay"; 110 109 111 110 cpu3_intc: interrupt-controller { ··· 134 131 riscv,isa = "rv64imafdc"; 135 132 clocks = <&clkcfg CLK_CPU>; 136 133 tlb-split; 134 + next-level-cache = <&cctrllr>; 137 135 status = "okay"; 138 136 cpu4_intc: interrupt-controller { 139 137 #interrupt-cells = <1>;
+2 -1
arch/riscv/errata/sifive/errata.c
··· 111 111 cpu_apply_errata |= tmp; 112 112 } 113 113 } 114 - if (cpu_apply_errata != cpu_req_errata) 114 + if (stage != RISCV_ALTERNATIVES_MODULE && 115 + cpu_apply_errata != cpu_req_errata) 115 116 warn_miss_errata(cpu_req_errata - cpu_apply_errata); 116 117 }
+6 -6
arch/riscv/include/asm/pgtable-64.h
··· 175 175 176 176 static inline unsigned long _pud_pfn(pud_t pud) 177 177 { 178 - return pud_val(pud) >> _PAGE_PFN_SHIFT; 178 + return __page_val_to_pfn(pud_val(pud)); 179 179 } 180 180 181 181 static inline pmd_t *pud_pgtable(pud_t pud) ··· 278 278 279 279 static inline unsigned long _p4d_pfn(p4d_t p4d) 280 280 { 281 - return p4d_val(p4d) >> _PAGE_PFN_SHIFT; 281 + return __page_val_to_pfn(p4d_val(p4d)); 282 282 } 283 283 284 284 static inline pud_t *p4d_pgtable(p4d_t p4d) 285 285 { 286 286 if (pgtable_l4_enabled) 287 - return (pud_t *)pfn_to_virt(p4d_val(p4d) >> _PAGE_PFN_SHIFT); 287 + return (pud_t *)pfn_to_virt(__page_val_to_pfn(p4d_val(p4d))); 288 288 289 289 return (pud_t *)pud_pgtable((pud_t) { p4d_val(p4d) }); 290 290 } ··· 292 292 293 293 static inline struct page *p4d_page(p4d_t p4d) 294 294 { 295 - return pfn_to_page(p4d_val(p4d) >> _PAGE_PFN_SHIFT); 295 + return pfn_to_page(__page_val_to_pfn(p4d_val(p4d))); 296 296 } 297 297 298 298 #define pud_index(addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)) ··· 347 347 static inline p4d_t *pgd_pgtable(pgd_t pgd) 348 348 { 349 349 if (pgtable_l5_enabled) 350 - return (p4d_t *)pfn_to_virt(pgd_val(pgd) >> _PAGE_PFN_SHIFT); 350 + return (p4d_t *)pfn_to_virt(__page_val_to_pfn(pgd_val(pgd))); 351 351 352 352 return (p4d_t *)p4d_pgtable((p4d_t) { pgd_val(pgd) }); 353 353 } ··· 355 355 356 356 static inline struct page *pgd_page(pgd_t pgd) 357 357 { 358 - return pfn_to_page(pgd_val(pgd) >> _PAGE_PFN_SHIFT); 358 + return pfn_to_page(__page_val_to_pfn(pgd_val(pgd))); 359 359 } 360 360 #define pgd_page(pgd) pgd_page(pgd) 361 361
+3 -3
arch/riscv/include/asm/pgtable.h
··· 261 261 262 262 static inline unsigned long _pgd_pfn(pgd_t pgd) 263 263 { 264 - return pgd_val(pgd) >> _PAGE_PFN_SHIFT; 264 + return __page_val_to_pfn(pgd_val(pgd)); 265 265 } 266 266 267 267 static inline struct page *pmd_page(pmd_t pmd) ··· 590 590 return __pmd(pmd_val(pmd) & ~(_PAGE_PRESENT|_PAGE_PROT_NONE)); 591 591 } 592 592 593 - #define __pmd_to_phys(pmd) (pmd_val(pmd) >> _PAGE_PFN_SHIFT << PAGE_SHIFT) 593 + #define __pmd_to_phys(pmd) (__page_val_to_pfn(pmd_val(pmd)) << PAGE_SHIFT) 594 594 595 595 static inline unsigned long pmd_pfn(pmd_t pmd) 596 596 { 597 597 return ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT); 598 598 } 599 599 600 - #define __pud_to_phys(pud) (pud_val(pud) >> _PAGE_PFN_SHIFT << PAGE_SHIFT) 600 + #define __pud_to_phys(pud) (__page_val_to_pfn(pud_val(pud)) << PAGE_SHIFT) 601 601 602 602 static inline unsigned long pud_pfn(pud_t pud) 603 603 {
+1 -1
arch/riscv/kvm/mmu.c
··· 54 54 55 55 static inline unsigned long gstage_pte_page_vaddr(pte_t pte) 56 56 { 57 - return (unsigned long)pfn_to_virt(pte_val(pte) >> _PAGE_PFN_SHIFT); 57 + return (unsigned long)pfn_to_virt(__page_val_to_pfn(pte_val(pte))); 58 58 } 59 59 60 60 static int gstage_page_size_to_level(unsigned long page_size, u32 *out_level)
+2
arch/riscv/kvm/vcpu.c
··· 781 781 782 782 if (kvm_request_pending(vcpu)) { 783 783 if (kvm_check_request(KVM_REQ_SLEEP, vcpu)) { 784 + kvm_vcpu_srcu_read_unlock(vcpu); 784 785 rcuwait_wait_event(wait, 785 786 (!vcpu->arch.power_off) && (!vcpu->arch.pause), 786 787 TASK_INTERRUPTIBLE); 788 + kvm_vcpu_srcu_read_lock(vcpu); 787 789 788 790 if (vcpu->arch.power_off || vcpu->arch.pause) { 789 791 /*
+1
arch/s390/Kconfig
··· 204 204 select IOMMU_SUPPORT if PCI 205 205 select MMU_GATHER_NO_GATHER 206 206 select MMU_GATHER_RCU_TABLE_FREE 207 + select MMU_GATHER_MERGE_VMAS 207 208 select MODULES_USE_ELF_RELA 208 209 select NEED_DMA_MAP_STATE if PCI 209 210 select NEED_SG_DMA_LENGTH if PCI
+7 -1
arch/s390/Makefile
··· 82 82 83 83 ifdef CONFIG_EXPOLINE 84 84 ifdef CONFIG_EXPOLINE_EXTERN 85 - KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline.o 85 + KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline/expoline.o 86 86 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern 87 87 CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern 88 88 else ··· 163 163 $(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h 164 164 $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \ 165 165 $(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h) 166 + 167 + ifdef CONFIG_EXPOLINE_EXTERN 168 + modules_prepare: expoline_prepare 169 + expoline_prepare: 170 + $(Q)$(MAKE) $(build)=arch/s390/lib/expoline arch/s390/lib/expoline/expoline.o 171 + endif 166 172 endif 167 173 168 174 # Don't use tabs in echo arguments
-2
arch/s390/include/asm/nospec-insn.h
··· 2 2 #ifndef _ASM_S390_NOSPEC_ASM_H 3 3 #define _ASM_S390_NOSPEC_ASM_H 4 4 5 - #include <asm/alternative-asm.h> 6 - #include <asm/asm-offsets.h> 7 5 #include <asm/dwarf.h> 8 6 9 7 #ifdef __ASSEMBLY__
-3
arch/s390/include/asm/tlb.h
··· 27 27 static inline bool __tlb_remove_page_size(struct mmu_gather *tlb, 28 28 struct page *page, int page_size); 29 29 30 - #define tlb_start_vma(tlb, vma) do { } while (0) 31 - #define tlb_end_vma(tlb, vma) do { } while (0) 32 - 33 30 #define tlb_flush tlb_flush 34 31 #define pte_free_tlb pte_free_tlb 35 32 #define pmd_free_tlb pmd_free_tlb
+2 -1
arch/s390/lib/Makefile
··· 7 7 obj-y += mem.o xor.o 8 8 lib-$(CONFIG_KPROBES) += probes.o 9 9 lib-$(CONFIG_UPROBES) += probes.o 10 - obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o 11 10 obj-$(CONFIG_S390_KPROBES_SANITY_TEST) += test_kprobes_s390.o 12 11 test_kprobes_s390-objs += test_kprobes_asm.o test_kprobes.o 13 12 ··· 21 22 obj-$(CONFIG_S390_MODULES_SANITY_TEST_HELPERS) += test_modules_helpers.o 22 23 23 24 lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o 25 + 26 + obj-$(CONFIG_EXPOLINE_EXTERN) += expoline/
arch/s390/lib/expoline.S arch/s390/lib/expoline/expoline.S
+3
arch/s390/lib/expoline/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + obj-y += expoline.o
+2
arch/sparc/Kconfig
··· 67 67 select HAVE_KRETPROBES 68 68 select HAVE_KPROBES 69 69 select MMU_GATHER_RCU_TABLE_FREE if SMP 70 + select MMU_GATHER_MERGE_VMAS 71 + select MMU_GATHER_NO_FLUSH_CACHE 70 72 select HAVE_ARCH_TRANSPARENT_HUGEPAGE 71 73 select HAVE_DYNAMIC_FTRACE 72 74 select HAVE_FTRACE_MCOUNT_RECORD
-2
arch/sparc/include/asm/tlb_64.h
··· 22 22 void __flush_tlb_pending(unsigned long, unsigned long, unsigned long *); 23 23 void flush_tlb_pending(void); 24 24 25 - #define tlb_start_vma(tlb, vma) do { } while (0) 26 - #define tlb_end_vma(tlb, vma) do { } while (0) 27 25 #define tlb_flush(tlb) flush_tlb_pending() 28 26 29 27 /*
+4
arch/um/kernel/um_arch.c
··· 432 432 { 433 433 } 434 434 435 + void apply_returns(s32 *start, s32 *end) 436 + { 437 + } 438 + 435 439 void apply_alternatives(struct alt_instr *start, struct alt_instr *end) 436 440 { 437 441 }
+1
arch/x86/Kconfig
··· 245 245 select HAVE_PERF_REGS 246 246 select HAVE_PERF_USER_STACK_DUMP 247 247 select MMU_GATHER_RCU_TABLE_FREE if PARAVIRT 248 + select MMU_GATHER_MERGE_VMAS 248 249 select HAVE_POSIX_CPU_TIMERS_TASK_WORK 249 250 select HAVE_REGS_AND_STACK_ACCESS_API 250 251 select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC || STACK_VALIDATION
-1
arch/x86/entry/entry_64.S
··· 727 727 pushq %rdi /* Stash user RDI */ 728 728 swapgs /* to kernel GS */ 729 729 SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi /* to kernel CR3 */ 730 - UNTRAIN_RET 731 730 732 731 movq PER_CPU_VAR(espfix_waddr), %rdi 733 732 movq %rax, (0*8)(%rdi) /* user RAX */
-3
arch/x86/include/asm/tlb.h
··· 2 2 #ifndef _ASM_X86_TLB_H 3 3 #define _ASM_X86_TLB_H 4 4 5 - #define tlb_start_vma(tlb, vma) do { } while (0) 6 - #define tlb_end_vma(tlb, vma) do { } while (0) 7 - 8 5 #define tlb_flush tlb_flush 9 6 static inline void tlb_flush(struct mmu_gather *tlb); 10 7
+6
arch/x86/kernel/acpi/cppc.c
··· 16 16 switch (boot_cpu_data.x86_vendor) { 17 17 case X86_VENDOR_AMD: 18 18 case X86_VENDOR_HYGON: 19 + if (boot_cpu_data.x86 == 0x19 && ((boot_cpu_data.x86_model <= 0x0f) || 20 + (boot_cpu_data.x86_model >= 0x20 && boot_cpu_data.x86_model <= 0x2f))) 21 + return true; 22 + else if (boot_cpu_data.x86 == 0x17 && 23 + boot_cpu_data.x86_model >= 0x70 && boot_cpu_data.x86_model <= 0x7f) 24 + return true; 19 25 return boot_cpu_has(X86_FEATURE_CPPC); 20 26 } 21 27 return false;
+2 -2
arch/x86/kernel/cpu/bugs.c
··· 793 793 RETBLEED_CMD_IBPB, 794 794 }; 795 795 796 - const char * const retbleed_strings[] = { 796 + static const char * const retbleed_strings[] = { 797 797 [RETBLEED_MITIGATION_NONE] = "Vulnerable", 798 798 [RETBLEED_MITIGATION_UNRET] = "Mitigation: untrained return thunk", 799 799 [RETBLEED_MITIGATION_IBPB] = "Mitigation: IBPB", ··· 1181 1181 if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET) { 1182 1182 if (mode != SPECTRE_V2_USER_STRICT && 1183 1183 mode != SPECTRE_V2_USER_STRICT_PREFERRED) 1184 - pr_info("Selecting STIBP always-on mode to complement retbleed mitigation'\n"); 1184 + pr_info("Selecting STIBP always-on mode to complement retbleed mitigation\n"); 1185 1185 mode = SPECTRE_V2_USER_STRICT_PREFERRED; 1186 1186 } 1187 1187
+1
arch/x86/kernel/head_32.S
··· 23 23 #include <asm/cpufeatures.h> 24 24 #include <asm/percpu.h> 25 25 #include <asm/nops.h> 26 + #include <asm/nospec-branch.h> 26 27 #include <asm/bootparam.h> 27 28 #include <asm/export.h> 28 29 #include <asm/pgtable_32.h>
+7 -8
arch/x86/kvm/emulate.c
··· 189 189 #define X8(x...) X4(x), X4(x) 190 190 #define X16(x...) X8(x), X8(x) 191 191 192 - #define NR_FASTOP (ilog2(sizeof(ulong)) + 1) 193 - #define FASTOP_SIZE (8 * (1 + HAS_KERNEL_IBT)) 194 - 195 192 struct opcode { 196 193 u64 flags; 197 194 u8 intercept; ··· 303 306 * Moreover, they are all exactly FASTOP_SIZE bytes long, so functions for 304 307 * different operand sizes can be reached by calculation, rather than a jump 305 308 * table (which would be bigger than the code). 309 + * 310 + * The 16 byte alignment, considering 5 bytes for the RET thunk, 3 for ENDBR 311 + * and 1 for the straight line speculation INT3, leaves 7 bytes for the 312 + * body of the function. Currently none is larger than 4. 306 313 */ 307 314 static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); 315 + 316 + #define FASTOP_SIZE 16 308 317 309 318 #define __FOP_FUNC(name) \ 310 319 ".align " __stringify(FASTOP_SIZE) " \n\t" \ ··· 445 442 * RET | JMP __x86_return_thunk [1,5 bytes; CONFIG_RETHUNK] 446 443 * INT3 [1 byte; CONFIG_SLS] 447 444 */ 448 - #define RET_LENGTH (1 + (4 * IS_ENABLED(CONFIG_RETHUNK)) + \ 449 - IS_ENABLED(CONFIG_SLS)) 450 - #define SETCC_LENGTH (ENDBR_INSN_SIZE + 3 + RET_LENGTH) 451 - #define SETCC_ALIGN (4 << ((SETCC_LENGTH > 4) & 1) << ((SETCC_LENGTH > 8) & 1)) 452 - static_assert(SETCC_LENGTH <= SETCC_ALIGN); 445 + #define SETCC_ALIGN 16 453 446 454 447 #define FOP_SETCC(op) \ 455 448 ".align " __stringify(SETCC_ALIGN) " \n\t" \
-1
arch/x86/kvm/vmx/nested.c
··· 2278 2278 SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | 2279 2279 SECONDARY_EXEC_APIC_REGISTER_VIRT | 2280 2280 SECONDARY_EXEC_ENABLE_VMFUNC | 2281 - SECONDARY_EXEC_TSC_SCALING | 2282 2281 SECONDARY_EXEC_DESC); 2283 2282 2284 2283 if (nested_cpu_has(vmcs12,
+11 -9
arch/x86/kvm/x86.c
··· 298 298 STATS_DESC_COUNTER(VCPU, directed_yield_successful), 299 299 STATS_DESC_COUNTER(VCPU, preemption_reported), 300 300 STATS_DESC_COUNTER(VCPU, preemption_other), 301 - STATS_DESC_ICOUNTER(VCPU, guest_mode) 301 + STATS_DESC_IBOOLEAN(VCPU, guest_mode) 302 302 }; 303 303 304 304 const struct kvm_stats_header kvm_vcpu_stats_header = { ··· 9143 9143 */ 9144 9144 static void kvm_pv_kick_cpu_op(struct kvm *kvm, int apicid) 9145 9145 { 9146 - struct kvm_lapic_irq lapic_irq; 9146 + /* 9147 + * All other fields are unused for APIC_DM_REMRD, but may be consumed by 9148 + * common code, e.g. for tracing. Defer initialization to the compiler. 9149 + */ 9150 + struct kvm_lapic_irq lapic_irq = { 9151 + .delivery_mode = APIC_DM_REMRD, 9152 + .dest_mode = APIC_DEST_PHYSICAL, 9153 + .shorthand = APIC_DEST_NOSHORT, 9154 + .dest_id = apicid, 9155 + }; 9147 9156 9148 - lapic_irq.shorthand = APIC_DEST_NOSHORT; 9149 - lapic_irq.dest_mode = APIC_DEST_PHYSICAL; 9150 - lapic_irq.level = 0; 9151 - lapic_irq.dest_id = apicid; 9152 - lapic_irq.msi_redir_hint = false; 9153 - 9154 - lapic_irq.delivery_mode = APIC_DM_REMRD; 9155 9157 kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL); 9156 9158 } 9157 9159
+12 -2
arch/x86/mm/init.c
··· 77 77 [__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC, 78 78 }; 79 79 80 - /* Check that the write-protect PAT entry is set for write-protect */ 80 + /* 81 + * Check that the write-protect PAT entry is set for write-protect. 82 + * To do this without making assumptions how PAT has been set up (Xen has 83 + * another layout than the kernel), translate the _PAGE_CACHE_MODE_WP cache 84 + * mode via the __cachemode2pte_tbl[] into protection bits (those protection 85 + * bits will select a cache mode of WP or better), and then translate the 86 + * protection bits back into the cache mode using __pte2cm_idx() and the 87 + * __pte2cachemode_tbl[] array. This will return the really used cache mode. 88 + */ 81 89 bool x86_has_pat_wp(void) 82 90 { 83 - return __pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] == _PAGE_CACHE_MODE_WP; 91 + uint16_t prot = __cachemode2pte_tbl[_PAGE_CACHE_MODE_WP]; 92 + 93 + return __pte2cachemode_tbl[__pte2cm_idx(prot)] == _PAGE_CACHE_MODE_WP; 84 94 } 85 95 86 96 enum page_cache_mode pgprot2cachemode(pgprot_t pgprot)
+4 -1
arch/x86/platform/efi/efi_thunk_64.S
··· 23 23 #include <linux/objtool.h> 24 24 #include <asm/page_types.h> 25 25 #include <asm/segment.h> 26 + #include <asm/nospec-branch.h> 26 27 27 28 .text 28 29 .code64 ··· 76 75 1: movq 0x20(%rsp), %rsp 77 76 pop %rbx 78 77 pop %rbp 79 - RET 78 + ANNOTATE_UNRET_SAFE 79 + ret 80 + int3 80 81 81 82 .code32 82 83 2: pushl $__KERNEL_CS
+1
block/blk-merge.c
··· 345 345 /* there isn't chance to merge the splitted bio */ 346 346 split->bi_opf |= REQ_NOMERGE; 347 347 348 + blkcg_bio_issue_init(split); 348 349 bio_chain(split, *bio); 349 350 trace_block_split(split, (*bio)->bi_iter.bi_sector); 350 351 submit_bio_noacct(*bio);
+7 -4
drivers/acpi/acpi_video.c
··· 73 73 static int only_lcd = -1; 74 74 module_param(only_lcd, int, 0444); 75 75 76 - static bool has_backlight; 76 + static bool may_report_brightness_keys; 77 77 static int register_count; 78 78 static DEFINE_MUTEX(register_count_mutex); 79 79 static DEFINE_MUTEX(video_list_lock); ··· 1224 1224 acpi_video_device_find_cap(data); 1225 1225 1226 1226 if (data->cap._BCM && data->cap._BCL) 1227 - has_backlight = true; 1227 + may_report_brightness_keys = true; 1228 1228 1229 1229 mutex_lock(&video->device_list_lock); 1230 1230 list_add_tail(&data->entry, &video->video_device_list); ··· 1692 1692 acpi_handle_debug(handle, "Unsupported event [0x%x]\n", event); 1693 1693 break; 1694 1694 } 1695 + 1696 + if (keycode) 1697 + may_report_brightness_keys = true; 1695 1698 1696 1699 acpi_notifier_call_chain(device, event, 0); 1697 1700 ··· 2256 2253 if (register_count) { 2257 2254 acpi_bus_unregister_driver(&acpi_video_bus); 2258 2255 register_count = 0; 2259 - has_backlight = false; 2256 + may_report_brightness_keys = false; 2260 2257 } 2261 2258 mutex_unlock(&register_count_mutex); 2262 2259 } ··· 2278 2275 2279 2276 bool acpi_video_handles_brightness_key_presses(void) 2280 2277 { 2281 - return has_backlight && 2278 + return may_report_brightness_keys && 2282 2279 (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS); 2283 2280 } 2284 2281 EXPORT_SYMBOL(acpi_video_handles_brightness_key_presses);
+1 -1
drivers/char/random.c
··· 1174 1174 */ 1175 1175 static void __cold try_to_generate_entropy(void) 1176 1176 { 1177 - enum { NUM_TRIAL_SAMPLES = 8192, MAX_SAMPLES_PER_BIT = 32 }; 1177 + enum { NUM_TRIAL_SAMPLES = 8192, MAX_SAMPLES_PER_BIT = HZ / 30 }; 1178 1178 struct entropy_timer_state stack; 1179 1179 unsigned int i, num_different = 0; 1180 1180 unsigned long last = random_get_entropy();
+6 -2
drivers/cpufreq/mediatek-cpufreq.c
··· 439 439 440 440 /* Both presence and absence of sram regulator are valid cases. */ 441 441 info->sram_reg = regulator_get_optional(cpu_dev, "sram"); 442 - if (IS_ERR(info->sram_reg)) 442 + if (IS_ERR(info->sram_reg)) { 443 + ret = PTR_ERR(info->sram_reg); 444 + if (ret == -EPROBE_DEFER) 445 + goto out_free_resources; 446 + 443 447 info->sram_reg = NULL; 444 - else { 448 + } else { 445 449 ret = regulator_enable(info->sram_reg); 446 450 if (ret) { 447 451 dev_warn(cpu_dev, "cpu%d: failed to enable vsram\n", cpu);
+11 -10
drivers/firmware/efi/reboot.c
··· 6 6 #include <linux/efi.h> 7 7 #include <linux/reboot.h> 8 8 9 - static void (*orig_pm_power_off)(void); 9 + static struct sys_off_handler *efi_sys_off_handler; 10 10 11 11 int efi_reboot_quirk_mode = -1; 12 12 ··· 51 51 return false; 52 52 } 53 53 54 - static void efi_power_off(void) 54 + static int efi_power_off(struct sys_off_data *data) 55 55 { 56 56 efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); 57 - /* 58 - * The above call should not return, if it does fall back to 59 - * the original power off method (typically ACPI poweroff). 60 - */ 61 - if (orig_pm_power_off) 62 - orig_pm_power_off(); 57 + 58 + return NOTIFY_DONE; 63 59 } 64 60 65 61 static int __init efi_shutdown_init(void) ··· 64 68 return -ENODEV; 65 69 66 70 if (efi_poweroff_required()) { 67 - orig_pm_power_off = pm_power_off; 68 - pm_power_off = efi_power_off; 71 + /* SYS_OFF_PRIO_FIRMWARE + 1 so that it runs before acpi_power_off */ 72 + efi_sys_off_handler = 73 + register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, 74 + SYS_OFF_PRIO_FIRMWARE + 1, 75 + efi_power_off, NULL); 76 + if (IS_ERR(efi_sys_off_handler)) 77 + return PTR_ERR(efi_sys_off_handler); 69 78 } 70 79 71 80 return 0;
+5 -11
drivers/gpio/gpio-sim.c
··· 991 991 }; 992 992 993 993 struct gpio_sim_chip_name_ctx { 994 - struct gpio_sim_device *dev; 994 + struct fwnode_handle *swnode; 995 995 char *page; 996 996 }; 997 997 998 998 static int gpio_sim_emit_chip_name(struct device *dev, void *data) 999 999 { 1000 1000 struct gpio_sim_chip_name_ctx *ctx = data; 1001 - struct fwnode_handle *swnode; 1002 - struct gpio_sim_bank *bank; 1003 1001 1004 1002 /* This would be the sysfs device exported in /sys/class/gpio. */ 1005 1003 if (dev->class) 1006 1004 return 0; 1007 1005 1008 - swnode = dev_fwnode(dev); 1006 + if (device_match_fwnode(dev, ctx->swnode)) 1007 + return sprintf(ctx->page, "%s\n", dev_name(dev)); 1009 1008 1010 - list_for_each_entry(bank, &ctx->dev->bank_list, siblings) { 1011 - if (bank->swnode == swnode) 1012 - return sprintf(ctx->page, "%s\n", dev_name(dev)); 1013 - } 1014 - 1015 - return -ENODATA; 1009 + return 0; 1016 1010 } 1017 1011 1018 1012 static ssize_t gpio_sim_bank_config_chip_name_show(struct config_item *item, ··· 1014 1020 { 1015 1021 struct gpio_sim_bank *bank = to_gpio_sim_bank(item); 1016 1022 struct gpio_sim_device *dev = gpio_sim_bank_get_device(bank); 1017 - struct gpio_sim_chip_name_ctx ctx = { dev, page }; 1023 + struct gpio_sim_chip_name_ctx ctx = { bank->swnode, page }; 1018 1024 int ret; 1019 1025 1020 1026 mutex_lock(&dev->lock);
+4
drivers/gpio/gpiolib-cdev.c
··· 421 421 * @work: the worker that implements software debouncing 422 422 * @sw_debounced: flag indicating if the software debouncer is active 423 423 * @level: the current debounced physical level of the line 424 + * @hdesc: the Hardware Timestamp Engine (HTE) descriptor 425 + * @raw_level: the line level at the time of event 426 + * @total_discard_seq: the running counter of the discarded events 427 + * @last_seqno: the last sequence number before debounce period expires 424 428 */ 425 429 struct line { 426 430 struct gpio_desc *desc;
-1
drivers/gpu/drm/Kconfig
··· 256 256 select HWMON 257 257 select BACKLIGHT_CLASS_DEVICE 258 258 select INTERVAL_TREE 259 - select DRM_BUDDY 260 259 help 261 260 Choose this option if you have a recent AMD Radeon graphics card. 262 261
+19 -78
drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
··· 30 30 #include <drm/ttm/ttm_resource.h> 31 31 #include <drm/ttm/ttm_range_manager.h> 32 32 33 - #include "amdgpu_vram_mgr.h" 34 - 35 33 /* state back for walking over vram_mgr and gtt_mgr allocations */ 36 34 struct amdgpu_res_cursor { 37 35 uint64_t start; 38 36 uint64_t size; 39 37 uint64_t remaining; 40 - void *node; 41 - uint32_t mem_type; 38 + struct drm_mm_node *node; 42 39 }; 43 40 44 41 /** ··· 52 55 uint64_t start, uint64_t size, 53 56 struct amdgpu_res_cursor *cur) 54 57 { 55 - struct drm_buddy_block *block; 56 - struct list_head *head, *next; 57 58 struct drm_mm_node *node; 58 59 59 - if (!res) 60 - goto fallback; 60 + if (!res || res->mem_type == TTM_PL_SYSTEM) { 61 + cur->start = start; 62 + cur->size = size; 63 + cur->remaining = size; 64 + cur->node = NULL; 65 + WARN_ON(res && start + size > res->num_pages << PAGE_SHIFT); 66 + return; 67 + } 61 68 62 69 BUG_ON(start + size > res->num_pages << PAGE_SHIFT); 63 70 64 - cur->mem_type = res->mem_type; 71 + node = to_ttm_range_mgr_node(res)->mm_nodes; 72 + while (start >= node->size << PAGE_SHIFT) 73 + start -= node++->size << PAGE_SHIFT; 65 74 66 - switch (cur->mem_type) { 67 - case TTM_PL_VRAM: 68 - head = &to_amdgpu_vram_mgr_resource(res)->blocks; 69 - 70 - block = list_first_entry_or_null(head, 71 - struct drm_buddy_block, 72 - link); 73 - if (!block) 74 - goto fallback; 75 - 76 - while (start >= amdgpu_vram_mgr_block_size(block)) { 77 - start -= amdgpu_vram_mgr_block_size(block); 78 - 79 - next = block->link.next; 80 - if (next != head) 81 - block = list_entry(next, struct drm_buddy_block, link); 82 - } 83 - 84 - cur->start = amdgpu_vram_mgr_block_start(block) + start; 85 - cur->size = min(amdgpu_vram_mgr_block_size(block) - start, size); 86 - cur->remaining = size; 87 - cur->node = block; 88 - break; 89 - case TTM_PL_TT: 90 - node = to_ttm_range_mgr_node(res)->mm_nodes; 91 - while (start >= node->size << PAGE_SHIFT) 92 - start -= node++->size << PAGE_SHIFT; 93 - 94 - cur->start = (node->start << PAGE_SHIFT) + start; 95 - cur->size = min((node->size << PAGE_SHIFT) - start, size); 96 - cur->remaining = size; 97 - cur->node = node; 98 - break; 99 - default: 100 - goto fallback; 101 - } 102 - 103 - return; 104 - 105 - fallback: 106 - cur->start = start; 107 - cur->size = size; 75 + cur->start = (node->start << PAGE_SHIFT) + start; 76 + cur->size = min((node->size << PAGE_SHIFT) - start, size); 108 77 cur->remaining = size; 109 - cur->node = NULL; 110 - WARN_ON(res && start + size > res->num_pages << PAGE_SHIFT); 111 - return; 78 + cur->node = node; 112 79 } 113 80 114 81 /** ··· 85 124 */ 86 125 static inline void amdgpu_res_next(struct amdgpu_res_cursor *cur, uint64_t size) 87 126 { 88 - struct drm_buddy_block *block; 89 - struct drm_mm_node *node; 90 - struct list_head *next; 127 + struct drm_mm_node *node = cur->node; 91 128 92 129 BUG_ON(size > cur->remaining); 93 130 ··· 99 140 return; 100 141 } 101 142 102 - switch (cur->mem_type) { 103 - case TTM_PL_VRAM: 104 - block = cur->node; 105 - 106 - next = block->link.next; 107 - block = list_entry(next, struct drm_buddy_block, link); 108 - 109 - cur->node = block; 110 - cur->start = amdgpu_vram_mgr_block_start(block); 111 - cur->size = min(amdgpu_vram_mgr_block_size(block), cur->remaining); 112 - break; 113 - case TTM_PL_TT: 114 - node = cur->node; 115 - 116 - cur->node = ++node; 117 - cur->start = node->start << PAGE_SHIFT; 118 - cur->size = min(node->size << PAGE_SHIFT, cur->remaining); 119 - break; 120 - default: 121 - return; 122 - } 143 + cur->node = ++node; 144 + cur->start = node->start << PAGE_SHIFT; 145 + cur->size = min(node->size << PAGE_SHIFT, cur->remaining); 123 146 } 124 147 125 148 #endif
+9 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
··· 26 26 27 27 #include <linux/dma-direction.h> 28 28 #include <drm/gpu_scheduler.h> 29 - #include "amdgpu_vram_mgr.h" 30 29 #include "amdgpu.h" 31 30 32 31 #define AMDGPU_PL_GDS (TTM_PL_PRIV + 0) ··· 37 38 #define AMDGPU_GTT_NUM_TRANSFER_WINDOWS 2 38 39 39 40 #define AMDGPU_POISON 0xd0bed0be 41 + 42 + struct amdgpu_vram_mgr { 43 + struct ttm_resource_manager manager; 44 + struct drm_mm mm; 45 + spinlock_t lock; 46 + struct list_head reservations_pending; 47 + struct list_head reserved_pages; 48 + atomic64_t vis_usage; 49 + }; 40 50 41 51 struct amdgpu_gtt_mgr { 42 52 struct ttm_resource_manager manager;
+143 -206
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
··· 32 32 #include "atom.h" 33 33 34 34 struct amdgpu_vram_reservation { 35 - u64 start; 36 - u64 size; 37 - struct list_head allocated; 38 - struct list_head blocks; 35 + struct list_head node; 36 + struct drm_mm_node mm_node; 39 37 }; 40 38 41 39 static inline struct amdgpu_vram_mgr * ··· 186 188 }; 187 189 188 190 /** 189 - * amdgpu_vram_mgr_vis_size - Calculate visible block size 191 + * amdgpu_vram_mgr_vis_size - Calculate visible node size 190 192 * 191 193 * @adev: amdgpu_device pointer 192 - * @block: DRM BUDDY block structure 194 + * @node: MM node structure 193 195 * 194 - * Calculate how many bytes of the DRM BUDDY block are inside visible VRAM 196 + * Calculate how many bytes of the MM node are inside visible VRAM 195 197 */ 196 198 static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev, 197 - struct drm_buddy_block *block) 199 + struct drm_mm_node *node) 198 200 { 199 - u64 start = amdgpu_vram_mgr_block_start(block); 200 - u64 end = start + amdgpu_vram_mgr_block_size(block); 201 + uint64_t start = node->start << PAGE_SHIFT; 202 + uint64_t end = (node->size + node->start) << PAGE_SHIFT; 201 203 202 204 if (start >= adev->gmc.visible_vram_size) 203 205 return 0; ··· 218 220 { 219 221 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 220 222 struct ttm_resource *res = bo->tbo.resource; 221 - struct amdgpu_vram_mgr_resource *vres = to_amdgpu_vram_mgr_resource(res); 222 - struct drm_buddy_block *block; 223 - u64 usage = 0; 223 + unsigned pages = res->num_pages; 224 + struct drm_mm_node *mm; 225 + u64 usage; 224 226 225 227 if (amdgpu_gmc_vram_full_visible(&adev->gmc)) 226 228 return amdgpu_bo_size(bo); ··· 228 230 if (res->start >= adev->gmc.visible_vram_size >> PAGE_SHIFT) 229 231 return 0; 230 232 231 - list_for_each_entry(block, &vres->blocks, link) 232 - usage += amdgpu_vram_mgr_vis_size(adev, block); 233 + mm = &container_of(res, struct ttm_range_mgr_node, base)->mm_nodes[0]; 234 + for (usage = 0; pages; pages -= mm->size, mm++) 235 + usage += amdgpu_vram_mgr_vis_size(adev, mm); 233 236 234 237 return usage; 235 238 } ··· 240 241 { 241 242 struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); 242 243 struct amdgpu_device *adev = to_amdgpu_device(mgr); 243 - struct drm_buddy *mm = &mgr->mm; 244 + struct drm_mm *mm = &mgr->mm; 244 245 struct amdgpu_vram_reservation *rsv, *temp; 245 - struct drm_buddy_block *block; 246 246 uint64_t vis_usage; 247 247 248 - list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, blocks) { 249 - if (drm_buddy_alloc_blocks(mm, rsv->start, rsv->start + rsv->size, 250 - rsv->size, mm->chunk_size, &rsv->allocated, 251 - DRM_BUDDY_RANGE_ALLOCATION)) 252 - continue; 253 - 254 - block = amdgpu_vram_mgr_first_block(&rsv->allocated); 255 - if (!block) 248 + list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, node) { 249 + if (drm_mm_reserve_node(mm, &rsv->mm_node)) 256 250 continue; 257 251 258 252 dev_dbg(adev->dev, "Reservation 0x%llx - %lld, Succeeded\n", 259 - rsv->start, rsv->size); 253 + rsv->mm_node.start, rsv->mm_node.size); 260 254 261 - vis_usage = amdgpu_vram_mgr_vis_size(adev, block); 255 + vis_usage = amdgpu_vram_mgr_vis_size(adev, &rsv->mm_node); 262 256 atomic64_add(vis_usage, &mgr->vis_usage); 263 257 spin_lock(&man->bdev->lru_lock); 264 - man->usage += rsv->size; 258 + man->usage += rsv->mm_node.size << PAGE_SHIFT; 265 259 spin_unlock(&man->bdev->lru_lock); 266 - list_move(&rsv->blocks, &mgr->reserved_pages); 260 + list_move(&rsv->node, &mgr->reserved_pages); 267 261 } 268 262 } 269 263 ··· 278 286 if (!rsv) 279 287 return -ENOMEM; 280 288 281 - INIT_LIST_HEAD(&rsv->allocated); 282 - INIT_LIST_HEAD(&rsv->blocks); 289 + INIT_LIST_HEAD(&rsv->node); 290 + rsv->mm_node.start = start >> PAGE_SHIFT; 291 + rsv->mm_node.size = size >> PAGE_SHIFT; 283 292 284 - rsv->start = start; 285 - rsv->size = size; 286 - 287 - mutex_lock(&mgr->lock); 288 - list_add_tail(&rsv->blocks, &mgr->reservations_pending); 293 + spin_lock(&mgr->lock); 294 + list_add_tail(&rsv->node, &mgr->reservations_pending); 289 295 amdgpu_vram_mgr_do_reserve(&mgr->manager); 290 - mutex_unlock(&mgr->lock); 296 + spin_unlock(&mgr->lock); 291 297 292 298 return 0; 293 299 } ··· 307 317 struct amdgpu_vram_reservation *rsv; 308 318 int ret; 309 319 310 - mutex_lock(&mgr->lock); 320 + spin_lock(&mgr->lock); 311 321 312 - list_for_each_entry(rsv, &mgr->reservations_pending, blocks) { 313 - if (rsv->start <= start && 314 - (start < (rsv->start + rsv->size))) { 322 + list_for_each_entry(rsv, &mgr->reservations_pending, node) { 323 + if ((rsv->mm_node.start <= start) && 324 + (start < (rsv->mm_node.start + rsv->mm_node.size))) { 315 325 ret = -EBUSY; 316 326 goto out; 317 327 } 318 328 } 319 329 320 - list_for_each_entry(rsv, &mgr->reserved_pages, blocks) { 321 - if (rsv->start <= start && 322 - (start < (rsv->start + rsv->size))) { 330 + list_for_each_entry(rsv, &mgr->reserved_pages, node) { 331 + if ((rsv->mm_node.start <= start) && 332 + (start < (rsv->mm_node.start + rsv->mm_node.size))) { 323 333 ret = 0; 324 334 goto out; 325 335 } ··· 327 337 328 338 ret = -ENOENT; 329 339 out: 330 - mutex_unlock(&mgr->lock); 340 + spin_unlock(&mgr->lock); 331 341 return ret; 342 + } 343 + 344 + /** 345 + * amdgpu_vram_mgr_virt_start - update virtual start address 346 + * 347 + * @mem: ttm_resource to update 348 + * @node: just allocated node 349 + * 350 + * Calculate a virtual BO start address to easily check if everything is CPU 351 + * accessible. 352 + */ 353 + static void amdgpu_vram_mgr_virt_start(struct ttm_resource *mem, 354 + struct drm_mm_node *node) 355 + { 356 + unsigned long start; 357 + 358 + start = node->start + node->size; 359 + if (start > mem->num_pages) 360 + start -= mem->num_pages; 361 + else 362 + start = 0; 363 + mem->start = max(mem->start, start); 332 364 } 333 365 334 366 /** ··· 368 356 const struct ttm_place *place, 369 357 struct ttm_resource **res) 370 358 { 371 - u64 vis_usage = 0, max_bytes, cur_size, min_block_size; 359 + unsigned long lpfn, num_nodes, pages_per_node, pages_left, pages; 372 360 struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); 373 361 struct amdgpu_device *adev = to_amdgpu_device(mgr); 374 - struct amdgpu_vram_mgr_resource *vres; 375 - u64 size, remaining_size, lpfn, fpfn; 376 - struct drm_buddy *mm = &mgr->mm; 377 - struct drm_buddy_block *block; 378 - unsigned long pages_per_block; 362 + uint64_t vis_usage = 0, mem_bytes, max_bytes; 363 + struct ttm_range_mgr_node *node; 364 + struct drm_mm *mm = &mgr->mm; 365 + enum drm_mm_insert_mode mode; 366 + unsigned i; 379 367 int r; 380 368 381 - lpfn = place->lpfn << PAGE_SHIFT; 369 + lpfn = place->lpfn; 382 370 if (!lpfn) 383 - lpfn = man->size; 384 - 385 - fpfn = place->fpfn << PAGE_SHIFT; 371 + lpfn = man->size >> PAGE_SHIFT; 386 372 387 373 max_bytes = adev->gmc.mc_vram_size; 388 374 if (tbo->type != ttm_bo_type_kernel) 389 375 max_bytes -= AMDGPU_VM_RESERVED_VRAM; 390 376 377 + mem_bytes = tbo->base.size; 391 378 if (place->flags & TTM_PL_FLAG_CONTIGUOUS) { 392 - pages_per_block = ~0ul; 379 + pages_per_node = ~0ul; 380 + num_nodes = 1; 393 381 } else { 394 382 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 395 - pages_per_block = HPAGE_PMD_NR; 383 + pages_per_node = HPAGE_PMD_NR; 396 384 #else 397 385 /* default to 2MB */ 398 - pages_per_block = 2UL << (20UL - PAGE_SHIFT); 386 + pages_per_node = 2UL << (20UL - PAGE_SHIFT); 399 387 #endif 400 - pages_per_block = max_t(uint32_t, pages_per_block, 401 - tbo->page_alignment); 388 + pages_per_node = max_t(uint32_t, pages_per_node, 389 + tbo->page_alignment); 390 + num_nodes = DIV_ROUND_UP_ULL(PFN_UP(mem_bytes), pages_per_node); 402 391 } 403 392 404 - vres = kzalloc(sizeof(*vres), GFP_KERNEL); 405 - if (!vres) 393 + node = kvmalloc(struct_size(node, mm_nodes, num_nodes), 394 + GFP_KERNEL | __GFP_ZERO); 395 + if (!node) 406 396 return -ENOMEM; 407 397 408 - ttm_resource_init(tbo, place, &vres->base); 398 + ttm_resource_init(tbo, place, &node->base); 409 399 410 400 /* bail out quickly if there's likely not enough VRAM for this BO */ 411 401 if (ttm_resource_manager_usage(man) > max_bytes) { ··· 415 401 goto error_fini; 416 402 } 417 403 418 - INIT_LIST_HEAD(&vres->blocks); 419 - 404 + mode = DRM_MM_INSERT_BEST; 420 405 if (place->flags & TTM_PL_FLAG_TOPDOWN) 421 - vres->flags |= DRM_BUDDY_TOPDOWN_ALLOCATION; 406 + mode = DRM_MM_INSERT_HIGH; 422 407 423 - if (fpfn || lpfn != man->size) 424 - /* Allocate blocks in desired range */ 425 - vres->flags |= DRM_BUDDY_RANGE_ALLOCATION; 408 + pages_left = node->base.num_pages; 426 409 427 - remaining_size = vres->base.num_pages << PAGE_SHIFT; 410 + /* Limit maximum size to 2GB due to SG table limitations */ 411 + pages = min(pages_left, 2UL << (30 - PAGE_SHIFT)); 428 412 429 - mutex_lock(&mgr->lock); 430 - while (remaining_size) { 431 - if (tbo->page_alignment) 432 - min_block_size = tbo->page_alignment << PAGE_SHIFT; 433 - else 434 - min_block_size = mgr->default_page_size; 413 + i = 0; 414 + spin_lock(&mgr->lock); 415 + while (pages_left) { 416 + uint32_t alignment = tbo->page_alignment; 435 417 436 - BUG_ON(min_block_size < mm->chunk_size); 418 + if (pages >= pages_per_node) 419 + alignment = pages_per_node; 437 420 438 - /* Limit maximum size to 2GiB due to SG table limitations */ 439 - size = min(remaining_size, 2ULL << 30); 440 - 441 - if (size >= pages_per_block << PAGE_SHIFT) 442 - min_block_size = pages_per_block << PAGE_SHIFT; 443 - 444 - cur_size = size; 445 - 446 - if (fpfn + size != place->lpfn << PAGE_SHIFT) { 447 - /* 448 - * Except for actual range allocation, modify the size and 449 - * min_block_size conforming to continuous flag enablement 450 - */ 451 - if (place->flags & TTM_PL_FLAG_CONTIGUOUS) { 452 - size = roundup_pow_of_two(size); 453 - min_block_size = size; 454 - /* 455 - * Modify the size value if size is not 456 - * aligned with min_block_size 457 - */ 458 - } else if (!IS_ALIGNED(size, min_block_size)) { 459 - size = round_up(size, min_block_size); 421 + r = drm_mm_insert_node_in_range(mm, &node->mm_nodes[i], pages, 422 + alignment, 0, place->fpfn, 423 + lpfn, mode); 424 + if (unlikely(r)) { 425 + if (pages > pages_per_node) { 426 + if (is_power_of_2(pages)) 427 + pages = pages / 2; 428 + else 429 + pages = rounddown_pow_of_two(pages); 430 + continue; 460 431 } 432 + goto error_free; 461 433 } 462 434 463 - r = drm_buddy_alloc_blocks(mm, fpfn, 464 - lpfn, 465 - size, 466 - min_block_size, 467 - &vres->blocks, 468 - vres->flags); 469 - if (unlikely(r)) 470 - goto error_free_blocks; 435 + vis_usage += amdgpu_vram_mgr_vis_size(adev, &node->mm_nodes[i]); 436 + amdgpu_vram_mgr_virt_start(&node->base, &node->mm_nodes[i]); 437 + pages_left -= pages; 438 + ++i; 471 439 472 - if (size > remaining_size) 473 - remaining_size = 0; 474 - else 475 - remaining_size -= size; 440 + if (pages > pages_left) 441 + pages = pages_left; 476 442 } 477 - mutex_unlock(&mgr->lock); 443 + spin_unlock(&mgr->lock); 478 444 479 - if (cur_size != size) { 480 - struct drm_buddy_block *block; 481 - struct list_head *trim_list; 482 - u64 original_size; 483 - LIST_HEAD(temp); 484 - 485 - trim_list = &vres->blocks; 486 - original_size = vres->base.num_pages << PAGE_SHIFT; 487 - 488 - /* 489 - * If size value is rounded up to min_block_size, trim the last 490 - * block to the required size 491 - */ 492 - if (!list_is_singular(&vres->blocks)) { 493 - block = list_last_entry(&vres->blocks, typeof(*block), link); 494 - list_move_tail(&block->link, &temp); 495 - trim_list = &temp; 496 - /* 497 - * Compute the original_size value by subtracting the 498 - * last block size with (aligned size - original size) 499 - */ 500 - original_size = amdgpu_vram_mgr_block_size(block) - (size - cur_size); 501 - } 502 - 503 - mutex_lock(&mgr->lock); 504 - drm_buddy_block_trim(mm, 505 - original_size, 506 - trim_list); 507 - mutex_unlock(&mgr->lock); 508 - 509 - if (!list_empty(&temp)) 510 - list_splice_tail(trim_list, &vres->blocks); 511 - } 512 - 513 - list_for_each_entry(block, &vres->blocks, link) 514 - vis_usage += amdgpu_vram_mgr_vis_size(adev, block); 515 - 516 - block = amdgpu_vram_mgr_first_block(&vres->blocks); 517 - if (!block) { 518 - r = -EINVAL; 519 - goto error_fini; 520 - } 521 - 522 - vres->base.start = amdgpu_vram_mgr_block_start(block) >> PAGE_SHIFT; 523 - 524 - if (amdgpu_is_vram_mgr_blocks_contiguous(&vres->blocks)) 525 - vres->base.placement |= TTM_PL_FLAG_CONTIGUOUS; 445 + if (i == 1) 446 + node->base.placement |= TTM_PL_FLAG_CONTIGUOUS; 526 447 527 448 if (adev->gmc.xgmi.connected_to_cpu) 528 - vres->base.bus.caching = ttm_cached; 449 + node->base.bus.caching = ttm_cached; 529 450 else 530 - vres->base.bus.caching = ttm_write_combined; 451 + node->base.bus.caching = ttm_write_combined; 531 452 532 453 atomic64_add(vis_usage, &mgr->vis_usage); 533 - *res = &vres->base; 454 + *res = &node->base; 534 455 return 0; 535 456 536 - error_free_blocks: 537 - drm_buddy_free_list(mm, &vres->blocks); 538 - mutex_unlock(&mgr->lock); 457 + error_free: 458 + while (i--) 459 + drm_mm_remove_node(&node->mm_nodes[i]); 460 + spin_unlock(&mgr->lock); 539 461 error_fini: 540 - ttm_resource_fini(man, &vres->base); 541 - kfree(vres); 462 + ttm_resource_fini(man, &node->base); 463 + kvfree(node); 542 464 543 465 return r; 544 466 } ··· 490 540 static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man, 491 541 struct ttm_resource *res) 492 542 { 493 - struct amdgpu_vram_mgr_resource *vres = to_amdgpu_vram_mgr_resource(res); 543 + struct ttm_range_mgr_node *node = to_ttm_range_mgr_node(res); 494 544 struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); 495 545 struct amdgpu_device *adev = to_amdgpu_device(mgr); 496 - struct drm_buddy *mm = &mgr->mm; 497 - struct drm_buddy_block *block; 498 546 uint64_t vis_usage = 0; 547 + unsigned i, pages; 499 548 500 - mutex_lock(&mgr->lock); 501 - list_for_each_entry(block, &vres->blocks, link) 502 - vis_usage += amdgpu_vram_mgr_vis_size(adev, block); 549 + spin_lock(&mgr->lock); 550 + for (i = 0, pages = res->num_pages; pages; 551 + pages -= node->mm_nodes[i].size, ++i) { 552 + struct drm_mm_node *mm = &node->mm_nodes[i]; 503 553 554 + drm_mm_remove_node(mm); 555 + vis_usage += amdgpu_vram_mgr_vis_size(adev, mm); 556 + } 504 557 amdgpu_vram_mgr_do_reserve(man); 505 - 506 - drm_buddy_free_list(mm, &vres->blocks); 507 - mutex_unlock(&mgr->lock); 558 + spin_unlock(&mgr->lock); 508 559 509 560 atomic64_sub(vis_usage, &mgr->vis_usage); 510 561 511 562 ttm_resource_fini(man, res); 512 - kfree(vres); 563 + kvfree(node); 513 564 } 514 565 515 566 /** ··· 542 591 if (!*sgt) 543 592 return -ENOMEM; 544 593 545 - /* Determine the number of DRM_BUDDY blocks to export */ 594 + /* Determine the number of DRM_MM nodes to export */ 546 595 amdgpu_res_first(res, offset, length, &cursor); 547 596 while (cursor.remaining) { 548 597 num_entries++; ··· 558 607 sg->length = 0; 559 608 560 609 /* 561 - * Walk down DRM_BUDDY blocks to populate scatterlist nodes 562 - * @note: Use iterator api to get first the DRM_BUDDY block 610 + * Walk down DRM_MM nodes to populate scatterlist nodes 611 + * @note: Use iterator api to get first the DRM_MM node 563 612 * and the number of bytes from it. Access the following 564 - * DRM_BUDDY block(s) if more buffer needs to exported 613 + * DRM_MM node(s) if more buffer needs to exported 565 614 */ 566 615 amdgpu_res_first(res, offset, length, &cursor); 567 616 for_each_sgtable_sg((*sgt), sg, i) { ··· 648 697 struct drm_printer *printer) 649 698 { 650 699 struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); 651 - struct drm_buddy *mm = &mgr->mm; 652 - struct drm_buddy_block *block; 653 700 654 701 drm_printf(printer, " vis usage:%llu\n", 655 702 amdgpu_vram_mgr_vis_usage(mgr)); 656 703 657 - mutex_lock(&mgr->lock); 658 - drm_printf(printer, "default_page_size: %lluKiB\n", 659 - mgr->default_page_size >> 10); 660 - 661 - drm_buddy_print(mm, printer); 662 - 663 - drm_printf(printer, "reserved:\n"); 664 - list_for_each_entry(block, &mgr->reserved_pages, link) 665 - drm_buddy_block_print(mm, block, printer); 666 - mutex_unlock(&mgr->lock); 704 + spin_lock(&mgr->lock); 705 + drm_mm_print(&mgr->mm, printer); 706 + spin_unlock(&mgr->lock); 667 707 } 668 708 669 709 static const struct ttm_resource_manager_func amdgpu_vram_mgr_func = { ··· 674 732 { 675 733 struct amdgpu_vram_mgr *mgr = &adev->mman.vram_mgr; 676 734 struct ttm_resource_manager *man = &mgr->manager; 677 - int err; 678 735 679 736 ttm_resource_manager_init(man, &adev->mman.bdev, 680 737 adev->gmc.real_vram_size); 681 738 682 739 man->func = &amdgpu_vram_mgr_func; 683 740 684 - err = drm_buddy_init(&mgr->mm, man->size, PAGE_SIZE); 685 - if (err) 686 - return err; 687 - 688 - mutex_init(&mgr->lock); 741 + drm_mm_init(&mgr->mm, 0, man->size >> PAGE_SHIFT); 742 + spin_lock_init(&mgr->lock); 689 743 INIT_LIST_HEAD(&mgr->reservations_pending); 690 744 INIT_LIST_HEAD(&mgr->reserved_pages); 691 - mgr->default_page_size = PAGE_SIZE; 692 745 693 746 ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager); 694 747 ttm_resource_manager_set_used(man, true); ··· 711 774 if (ret) 712 775 return; 713 776 714 - mutex_lock(&mgr->lock); 715 - list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, blocks) 777 + spin_lock(&mgr->lock); 778 + list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, node) 716 779 kfree(rsv); 717 780 718 - list_for_each_entry_safe(rsv, temp, &mgr->reserved_pages, blocks) { 719 - drm_buddy_free_list(&mgr->mm, &rsv->blocks); 781 + list_for_each_entry_safe(rsv, temp, &mgr->reserved_pages, node) { 782 + drm_mm_remove_node(&rsv->mm_node); 720 783 kfree(rsv); 721 784 } 722 - drm_buddy_fini(&mgr->mm); 723 - mutex_unlock(&mgr->lock); 785 + drm_mm_takedown(&mgr->mm); 786 + spin_unlock(&mgr->lock); 724 787 725 788 ttm_resource_manager_cleanup(man); 726 789 ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
-89
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h
··· 1 - /* SPDX-License-Identifier: MIT 2 - * Copyright 2021 Advanced Micro Devices, Inc. 3 - * 4 - * Permission is hereby granted, free of charge, to any person obtaining a 5 - * copy of this software and associated documentation files (the "Software"), 6 - * to deal in the Software without restriction, including without limitation 7 - * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 - * and/or sell copies of the Software, and to permit persons to whom the 9 - * Software is furnished to do so, subject to the following conditions: 10 - * 11 - * The above copyright notice and this permission notice shall be included in 12 - * all copies or substantial portions of the Software. 13 - * 14 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 - * OTHER DEALINGS IN THE SOFTWARE. 21 - * 22 - */ 23 - 24 - #ifndef __AMDGPU_VRAM_MGR_H__ 25 - #define __AMDGPU_VRAM_MGR_H__ 26 - 27 - #include <drm/drm_buddy.h> 28 - 29 - struct amdgpu_vram_mgr { 30 - struct ttm_resource_manager manager; 31 - struct drm_buddy mm; 32 - /* protects access to buffer objects */ 33 - struct mutex lock; 34 - struct list_head reservations_pending; 35 - struct list_head reserved_pages; 36 - atomic64_t vis_usage; 37 - u64 default_page_size; 38 - }; 39 - 40 - struct amdgpu_vram_mgr_resource { 41 - struct ttm_resource base; 42 - struct list_head blocks; 43 - unsigned long flags; 44 - }; 45 - 46 - static inline u64 amdgpu_vram_mgr_block_start(struct drm_buddy_block *block) 47 - { 48 - return drm_buddy_block_offset(block); 49 - } 50 - 51 - static inline u64 amdgpu_vram_mgr_block_size(struct drm_buddy_block *block) 52 - { 53 - return PAGE_SIZE << drm_buddy_block_order(block); 54 - } 55 - 56 - static inline struct drm_buddy_block * 57 - amdgpu_vram_mgr_first_block(struct list_head *list) 58 - { 59 - return list_first_entry_or_null(list, struct drm_buddy_block, link); 60 - } 61 - 62 - static inline bool amdgpu_is_vram_mgr_blocks_contiguous(struct list_head *head) 63 - { 64 - struct drm_buddy_block *block; 65 - u64 start, size; 66 - 67 - block = amdgpu_vram_mgr_first_block(head); 68 - if (!block) 69 - return false; 70 - 71 - while (head != block->link.next) { 72 - start = amdgpu_vram_mgr_block_start(block); 73 - size = amdgpu_vram_mgr_block_size(block); 74 - 75 - block = list_entry(block->link.next, struct drm_buddy_block, link); 76 - if (start + size != amdgpu_vram_mgr_block_start(block)) 77 - return false; 78 - } 79 - 80 - return true; 81 - } 82 - 83 - static inline struct amdgpu_vram_mgr_resource * 84 - to_amdgpu_vram_mgr_resource(struct ttm_resource *res) 85 - { 86 - return container_of(res, struct amdgpu_vram_mgr_resource, base); 87 - } 88 - 89 - #endif
+2
drivers/gpu/drm/amd/amdkfd/kfd_device.c
··· 184 184 /* Navi2x+, Navi1x+ */ 185 185 if (gc_version == IP_VERSION(10, 3, 6)) 186 186 kfd->device_info.no_atomic_fw_version = 14; 187 + else if (gc_version == IP_VERSION(10, 3, 7)) 188 + kfd->device_info.no_atomic_fw_version = 3; 187 189 else if (gc_version >= IP_VERSION(10, 3, 0)) 188 190 kfd->device_info.no_atomic_fw_version = 92; 189 191 else if (gc_version >= IP_VERSION(10, 1, 1))
+80 -4
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 72 72 #include <linux/pci.h> 73 73 #include <linux/firmware.h> 74 74 #include <linux/component.h> 75 + #include <linux/dmi.h> 75 76 76 77 #include <drm/display/drm_dp_mst_helper.h> 77 78 #include <drm/display/drm_hdmi_helper.h> ··· 463 462 vrr_active, (int) !e); 464 463 } 465 464 465 + static void dm_crtc_handle_vblank(struct amdgpu_crtc *acrtc) 466 + { 467 + struct drm_crtc *crtc = &acrtc->base; 468 + struct drm_device *dev = crtc->dev; 469 + unsigned long flags; 470 + 471 + drm_crtc_handle_vblank(crtc); 472 + 473 + spin_lock_irqsave(&dev->event_lock, flags); 474 + 475 + /* Send completion event for cursor-only commits */ 476 + if (acrtc->event && acrtc->pflip_status != AMDGPU_FLIP_SUBMITTED) { 477 + drm_crtc_send_vblank_event(crtc, acrtc->event); 478 + drm_crtc_vblank_put(crtc); 479 + acrtc->event = NULL; 480 + } 481 + 482 + spin_unlock_irqrestore(&dev->event_lock, flags); 483 + } 484 + 466 485 static void dm_vupdate_high_irq(void *interrupt_params) 467 486 { 468 487 struct common_irq_params *irq_params = interrupt_params; ··· 521 500 * if a pageflip happened inside front-porch. 522 501 */ 523 502 if (vrr_active) { 524 - drm_crtc_handle_vblank(&acrtc->base); 503 + dm_crtc_handle_vblank(acrtc); 525 504 526 505 /* BTR processing for pre-DCE12 ASICs */ 527 506 if (acrtc->dm_irq_params.stream && ··· 573 552 * to dm_vupdate_high_irq after end of front-porch. 574 553 */ 575 554 if (!vrr_active) 576 - drm_crtc_handle_vblank(&acrtc->base); 555 + dm_crtc_handle_vblank(acrtc); 577 556 578 557 /** 579 558 * Following stuff must happen at start of vblank, for crc ··· 1403 1382 return false; 1404 1383 } 1405 1384 1385 + static const struct dmi_system_id hpd_disconnect_quirk_table[] = { 1386 + { 1387 + .matches = { 1388 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1389 + DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3660"), 1390 + }, 1391 + }, 1392 + { 1393 + .matches = { 1394 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1395 + DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3260"), 1396 + }, 1397 + }, 1398 + { 1399 + .matches = { 1400 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1401 + DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3460"), 1402 + }, 1403 + }, 1404 + {} 1405 + }; 1406 + 1407 + static void retrieve_dmi_info(struct amdgpu_display_manager *dm) 1408 + { 1409 + const struct dmi_system_id *dmi_id; 1410 + 1411 + dm->aux_hpd_discon_quirk = false; 1412 + 1413 + dmi_id = dmi_first_match(hpd_disconnect_quirk_table); 1414 + if (dmi_id) { 1415 + dm->aux_hpd_discon_quirk = true; 1416 + DRM_INFO("aux_hpd_discon_quirk attached\n"); 1417 + } 1418 + } 1419 + 1406 1420 static int amdgpu_dm_init(struct amdgpu_device *adev) 1407 1421 { 1408 1422 struct dc_init_data init_data; ··· 1564 1508 } 1565 1509 1566 1510 INIT_LIST_HEAD(&adev->dm.da_list); 1511 + 1512 + retrieve_dmi_info(&adev->dm); 1513 + 1567 1514 /* Display Core create. */ 1568 1515 adev->dm.dc = dc_create(&init_data); 1569 1516 ··· 5466 5407 } 5467 5408 } 5468 5409 5469 - if (per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) 5410 + if (*per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) 5470 5411 *pre_multiplied_alpha = false; 5471 5412 } 5472 5413 ··· 9194 9135 struct amdgpu_bo *abo; 9195 9136 uint32_t target_vblank, last_flip_vblank; 9196 9137 bool vrr_active = amdgpu_dm_vrr_active(acrtc_state); 9138 + bool cursor_update = false; 9197 9139 bool pflip_present = false; 9198 9140 struct { 9199 9141 struct dc_surface_update surface_updates[MAX_SURFACES]; ··· 9230 9170 struct dm_plane_state *dm_new_plane_state = to_dm_plane_state(new_plane_state); 9231 9171 9232 9172 /* Cursor plane is handled after stream updates */ 9233 - if (plane->type == DRM_PLANE_TYPE_CURSOR) 9173 + if (plane->type == DRM_PLANE_TYPE_CURSOR) { 9174 + if ((fb && crtc == pcrtc) || 9175 + (old_plane_state->fb && old_plane_state->crtc == pcrtc)) 9176 + cursor_update = true; 9177 + 9234 9178 continue; 9179 + } 9235 9180 9236 9181 if (!fb || !crtc || pcrtc != crtc) 9237 9182 continue; ··· 9399 9334 bundle->stream_update.vrr_infopacket = 9400 9335 &acrtc_state->stream->vrr_infopacket; 9401 9336 } 9337 + } else if (cursor_update && acrtc_state->active_planes > 0 && 9338 + !acrtc_state->force_dpms_off && 9339 + acrtc_attach->base.state->event) { 9340 + drm_crtc_vblank_get(pcrtc); 9341 + 9342 + spin_lock_irqsave(&pcrtc->dev->event_lock, flags); 9343 + 9344 + acrtc_attach->event = acrtc_attach->base.state->event; 9345 + acrtc_attach->base.state->event = NULL; 9346 + 9347 + spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags); 9402 9348 } 9403 9349 9404 9350 /* Update the planes if changed or disable if we don't have any. */
+8
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
··· 540 540 * last successfully applied backlight values. 541 541 */ 542 542 u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP]; 543 + 544 + /** 545 + * @aux_hpd_discon_quirk: 546 + * 547 + * quirk for hpd discon while aux is on-going. 548 + * occurred on certain intel platform 549 + */ 550 + bool aux_hpd_discon_quirk; 543 551 }; 544 552 545 553 enum dsc_clock_force_state {
+17
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
··· 56 56 ssize_t result = 0; 57 57 struct aux_payload payload; 58 58 enum aux_return_code_type operation_result; 59 + struct amdgpu_device *adev; 60 + struct ddc_service *ddc; 59 61 60 62 if (WARN_ON(msg->size > 16)) 61 63 return -E2BIG; ··· 75 73 76 74 result = dc_link_aux_transfer_raw(TO_DM_AUX(aux)->ddc_service, &payload, 77 75 &operation_result); 76 + 77 + /* 78 + * w/a on certain intel platform where hpd is unexpected to pull low during 79 + * 1st sideband message transaction by return AUX_RET_ERROR_HPD_DISCON 80 + * aux transaction is succuess in such case, therefore bypass the error 81 + */ 82 + ddc = TO_DM_AUX(aux)->ddc_service; 83 + adev = ddc->ctx->driver_context; 84 + if (adev->dm.aux_hpd_discon_quirk) { 85 + if (msg->address == DP_SIDEBAND_MSG_DOWN_REQ_BASE && 86 + operation_result == AUX_RET_ERROR_HPD_DISCON) { 87 + result = 0; 88 + operation_result = AUX_RET_SUCCESS; 89 + } 90 + } 78 91 79 92 if (payload.write && result >= 0) 80 93 result = msg->size;
+6 -5
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
··· 1117 1117 * on certain displays, such as the Sharp 4k. 36bpp is needed 1118 1118 * to support SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 and 1119 1119 * SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 with actual > 10 bpc 1120 - * precision on at least DCN display engines. However, at least 1121 - * Carrizo with DCE_VERSION_11_0 does not like 36 bpp lb depth, 1122 - * so use only 30 bpp on DCE_VERSION_11_0. Testing with DCE 11.2 and 8.3 1123 - * did not show such problems, so this seems to be the exception. 1120 + * precision on DCN display engines, but apparently not for DCE, as 1121 + * far as testing on DCE-11.2 and DCE-8 showed. Various DCE parts have 1122 + * problems: Carrizo with DCE_VERSION_11_0 does not like 36 bpp lb depth, 1123 + * neither do DCE-8 at 4k resolution, or DCE-11.2 (broken identify pixel 1124 + * passthrough). Therefore only use 36 bpp on DCN where it is actually needed. 1124 1125 */ 1125 - if (plane_state->ctx->dce_version > DCE_VERSION_11_0) 1126 + if (plane_state->ctx->dce_version > DCE_VERSION_MAX) 1126 1127 pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_36BPP; 1127 1128 else 1128 1129 pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_30BPP;
+2
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
··· 1228 1228 uint32_t crystal_clock_freq = 2500; 1229 1229 uint32_t tach_period; 1230 1230 1231 + if (speed == 0) 1232 + return -EINVAL; 1231 1233 /* 1232 1234 * To prevent from possible overheat, some ASICs may have requirement 1233 1235 * for minimum fan speed:
+2
drivers/gpu/drm/i915/gem/i915_gem_region.c
··· 60 60 if (page_size) 61 61 default_page_size = page_size; 62 62 63 + /* We should be able to fit a page within an sg entry */ 64 + GEM_BUG_ON(overflows_type(default_page_size, u32)); 63 65 GEM_BUG_ON(!is_power_of_2_u64(default_page_size)); 64 66 GEM_BUG_ON(default_page_size < PAGE_SIZE); 65 67
+9 -2
drivers/gpu/drm/i915/gem/i915_gem_ttm.c
··· 620 620 struct ttm_resource *res) 621 621 { 622 622 struct ttm_buffer_object *bo = i915_gem_to_ttm(obj); 623 + u32 page_alignment; 623 624 624 625 if (!i915_ttm_gtt_binds_lmem(res)) 625 626 return i915_ttm_tt_get_st(bo->ttm); 627 + 628 + page_alignment = bo->page_alignment << PAGE_SHIFT; 629 + if (!page_alignment) 630 + page_alignment = obj->mm.region->min_page_size; 626 631 627 632 /* 628 633 * If CPU mapping differs, we need to add the ttm_tt pages to ··· 639 634 struct i915_refct_sgt *rsgt; 640 635 641 636 rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region, 642 - res); 637 + res, 638 + page_alignment); 643 639 if (IS_ERR(rsgt)) 644 640 return rsgt; 645 641 ··· 649 643 return i915_refct_sgt_get(obj->ttm.cached_io_rsgt); 650 644 } 651 645 652 - return intel_region_ttm_resource_to_rsgt(obj->mm.region, res); 646 + return intel_region_ttm_resource_to_rsgt(obj->mm.region, res, 647 + page_alignment); 653 648 } 654 649 655 650 static int i915_ttm_truncate(struct drm_i915_gem_object *obj)
+34
drivers/gpu/drm/i915/gem/i915_gem_wait.c
··· 9 9 #include <linux/jiffies.h> 10 10 11 11 #include "gt/intel_engine.h" 12 + #include "gt/intel_rps.h" 12 13 13 14 #include "i915_gem_ioctls.h" 14 15 #include "i915_gem_object.h" ··· 32 31 timeout); 33 32 } 34 33 34 + static void 35 + i915_gem_object_boost(struct dma_resv *resv, unsigned int flags) 36 + { 37 + struct dma_resv_iter cursor; 38 + struct dma_fence *fence; 39 + 40 + /* 41 + * Prescan all fences for potential boosting before we begin waiting. 42 + * 43 + * When we wait, we wait on outstanding fences serially. If the 44 + * dma-resv contains a sequence such as 1:1, 1:2 instead of a reduced 45 + * form 1:2, then as we look at each wait in turn we see that each 46 + * request is currently executing and not worthy of boosting. But if 47 + * we only happen to look at the final fence in the sequence (because 48 + * of request coalescing or splitting between read/write arrays by 49 + * the iterator), then we would boost. As such our decision to boost 50 + * or not is delicately balanced on the order we wait on fences. 51 + * 52 + * So instead of looking for boosts sequentially, look for all boosts 53 + * upfront and then wait on the outstanding fences. 54 + */ 55 + 56 + dma_resv_iter_begin(&cursor, resv, 57 + dma_resv_usage_rw(flags & I915_WAIT_ALL)); 58 + dma_resv_for_each_fence_unlocked(&cursor, fence) 59 + if (dma_fence_is_i915(fence) && 60 + !i915_request_started(to_request(fence))) 61 + intel_rps_boost(to_request(fence)); 62 + dma_resv_iter_end(&cursor); 63 + } 64 + 35 65 static long 36 66 i915_gem_object_wait_reservation(struct dma_resv *resv, 37 67 unsigned int flags, ··· 71 39 struct dma_resv_iter cursor; 72 40 struct dma_fence *fence; 73 41 long ret = timeout ?: 1; 42 + 43 + i915_gem_object_boost(resv, flags); 74 44 75 45 dma_resv_iter_begin(&cursor, resv, 76 46 dma_resv_usage_rw(flags & I915_WAIT_ALL));
+14 -1
drivers/gpu/drm/i915/gt/intel_gt.c
··· 1209 1209 mutex_lock(&gt->tlb_invalidate_lock); 1210 1210 intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL); 1211 1211 1212 + spin_lock_irq(&uncore->lock); /* serialise invalidate with GT reset */ 1213 + 1214 + for_each_engine(engine, gt, id) { 1215 + struct reg_and_bit rb; 1216 + 1217 + rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num); 1218 + if (!i915_mmio_reg_offset(rb.reg)) 1219 + continue; 1220 + 1221 + intel_uncore_write_fw(uncore, rb.reg, rb.bit); 1222 + } 1223 + 1224 + spin_unlock_irq(&uncore->lock); 1225 + 1212 1226 for_each_engine(engine, gt, id) { 1213 1227 /* 1214 1228 * HW architecture suggest typical invalidation time at 40us, ··· 1237 1223 if (!i915_mmio_reg_offset(rb.reg)) 1238 1224 continue; 1239 1225 1240 - intel_uncore_write_fw(uncore, rb.reg, rb.bit); 1241 1226 if (__intel_wait_for_register_fw(uncore, 1242 1227 rb.reg, rb.bit, 0, 1243 1228 timeout_us, timeout_ms,
+28 -9
drivers/gpu/drm/i915/gt/intel_reset.c
··· 300 300 return err; 301 301 } 302 302 303 - static int gen6_reset_engines(struct intel_gt *gt, 304 - intel_engine_mask_t engine_mask, 305 - unsigned int retry) 303 + static int __gen6_reset_engines(struct intel_gt *gt, 304 + intel_engine_mask_t engine_mask, 305 + unsigned int retry) 306 306 { 307 307 struct intel_engine_cs *engine; 308 308 u32 hw_mask; ··· 319 319 } 320 320 321 321 return gen6_hw_domain_reset(gt, hw_mask); 322 + } 323 + 324 + static int gen6_reset_engines(struct intel_gt *gt, 325 + intel_engine_mask_t engine_mask, 326 + unsigned int retry) 327 + { 328 + unsigned long flags; 329 + int ret; 330 + 331 + spin_lock_irqsave(&gt->uncore->lock, flags); 332 + ret = __gen6_reset_engines(gt, engine_mask, retry); 333 + spin_unlock_irqrestore(&gt->uncore->lock, flags); 334 + 335 + return ret; 322 336 } 323 337 324 338 static struct intel_engine_cs *find_sfc_paired_vecs_engine(struct intel_engine_cs *engine) ··· 501 487 rmw_clear_fw(uncore, sfc_lock.lock_reg, sfc_lock.lock_bit); 502 488 } 503 489 504 - static int gen11_reset_engines(struct intel_gt *gt, 505 - intel_engine_mask_t engine_mask, 506 - unsigned int retry) 490 + static int __gen11_reset_engines(struct intel_gt *gt, 491 + intel_engine_mask_t engine_mask, 492 + unsigned int retry) 507 493 { 508 494 struct intel_engine_cs *engine; 509 495 intel_engine_mask_t tmp; ··· 597 583 struct intel_engine_cs *engine; 598 584 const bool reset_non_ready = retry >= 1; 599 585 intel_engine_mask_t tmp; 586 + unsigned long flags; 600 587 int ret; 588 + 589 + spin_lock_irqsave(&gt->uncore->lock, flags); 601 590 602 591 for_each_engine_masked(engine, gt, engine_mask, tmp) { 603 592 ret = gen8_engine_reset_prepare(engine); ··· 629 612 * This is best effort, so ignore any error from the initial reset. 630 613 */ 631 614 if (IS_DG2(gt->i915) && engine_mask == ALL_ENGINES) 632 - gen11_reset_engines(gt, gt->info.engine_mask, 0); 615 + __gen11_reset_engines(gt, gt->info.engine_mask, 0); 633 616 634 617 if (GRAPHICS_VER(gt->i915) >= 11) 635 - ret = gen11_reset_engines(gt, engine_mask, retry); 618 + ret = __gen11_reset_engines(gt, engine_mask, retry); 636 619 else 637 - ret = gen6_reset_engines(gt, engine_mask, retry); 620 + ret = __gen6_reset_engines(gt, engine_mask, retry); 638 621 639 622 skip_reset: 640 623 for_each_engine_masked(engine, gt, engine_mask, tmp) 641 624 gen8_engine_reset_cancel(engine); 625 + 626 + spin_unlock_irqrestore(&gt->uncore->lock, flags); 642 627 643 628 return ret; 644 629 }
+4 -4
drivers/gpu/drm/i915/gt/selftest_lrc.c
··· 176 176 continue; 177 177 178 178 hw = shmem_pin_map(engine->default_state); 179 - if (IS_ERR(hw)) { 180 - err = PTR_ERR(hw); 179 + if (!hw) { 180 + err = -ENOMEM; 181 181 break; 182 182 } 183 183 hw += LRC_STATE_OFFSET / sizeof(*hw); ··· 365 365 continue; 366 366 367 367 hw = shmem_pin_map(engine->default_state); 368 - if (IS_ERR(hw)) { 369 - err = PTR_ERR(hw); 368 + if (!hw) { 369 + err = -ENOMEM; 370 370 break; 371 371 } 372 372 hw += LRC_STATE_OFFSET / sizeof(*hw);
+3 -3
drivers/gpu/drm/i915/gvt/cmd_parser.c
··· 3117 3117 continue; 3118 3118 3119 3119 vaddr = shmem_pin_map(engine->default_state); 3120 - if (IS_ERR(vaddr)) { 3121 - gvt_err("failed to map %s->default state, err:%zd\n", 3122 - engine->name, PTR_ERR(vaddr)); 3120 + if (!vaddr) { 3121 + gvt_err("failed to map %s->default state\n", 3122 + engine->name); 3123 3123 return; 3124 3124 } 3125 3125
+19 -8
drivers/gpu/drm/i915/i915_scatterlist.c
··· 68 68 * drm_mm_node 69 69 * @node: The drm_mm_node. 70 70 * @region_start: An offset to add to the dma addresses of the sg list. 71 + * @page_alignment: Required page alignment for each sg entry. Power of two. 71 72 * 72 73 * Create a struct sg_table, initializing it from a struct drm_mm_node, 73 74 * taking a maximum segment length into account, splitting into segments ··· 78 77 * error code cast to an error pointer on failure. 79 78 */ 80 79 struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, 81 - u64 region_start) 80 + u64 region_start, 81 + u32 page_alignment) 82 82 { 83 - const u64 max_segment = SZ_1G; /* Do we have a limit on this? */ 84 - u64 segment_pages = max_segment >> PAGE_SHIFT; 83 + const u32 max_segment = round_down(UINT_MAX, page_alignment); 84 + const u32 segment_pages = max_segment >> PAGE_SHIFT; 85 85 u64 block_size, offset, prev_end; 86 86 struct i915_refct_sgt *rsgt; 87 87 struct sg_table *st; 88 88 struct scatterlist *sg; 89 + 90 + GEM_BUG_ON(!max_segment); 89 91 90 92 rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL); 91 93 if (!rsgt) ··· 96 92 97 93 i915_refct_sgt_init(rsgt, node->size << PAGE_SHIFT); 98 94 st = &rsgt->table; 99 - if (sg_alloc_table(st, DIV_ROUND_UP(node->size, segment_pages), 95 + if (sg_alloc_table(st, DIV_ROUND_UP_ULL(node->size, segment_pages), 100 96 GFP_KERNEL)) { 101 97 i915_refct_sgt_put(rsgt); 102 98 return ERR_PTR(-ENOMEM); ··· 116 112 sg = __sg_next(sg); 117 113 118 114 sg_dma_address(sg) = region_start + offset; 115 + GEM_BUG_ON(!IS_ALIGNED(sg_dma_address(sg), 116 + page_alignment)); 119 117 sg_dma_len(sg) = 0; 120 118 sg->length = 0; 121 119 st->nents++; 122 120 } 123 121 124 - len = min(block_size, max_segment - sg->length); 122 + len = min_t(u64, block_size, max_segment - sg->length); 125 123 sg->length += len; 126 124 sg_dma_len(sg) += len; 127 125 ··· 144 138 * i915_buddy_block list 145 139 * @res: The struct i915_ttm_buddy_resource. 146 140 * @region_start: An offset to add to the dma addresses of the sg list. 141 + * @page_alignment: Required page alignment for each sg entry. Power of two. 147 142 * 148 143 * Create a struct sg_table, initializing it from struct i915_buddy_block list, 149 144 * taking a maximum segment length into account, splitting into segments ··· 154 147 * error code cast to an error pointer on failure. 155 148 */ 156 149 struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, 157 - u64 region_start) 150 + u64 region_start, 151 + u32 page_alignment) 158 152 { 159 153 struct i915_ttm_buddy_resource *bman_res = to_ttm_buddy_resource(res); 160 154 const u64 size = res->num_pages << PAGE_SHIFT; 161 - const u64 max_segment = rounddown(UINT_MAX, PAGE_SIZE); 155 + const u32 max_segment = round_down(UINT_MAX, page_alignment); 162 156 struct drm_buddy *mm = bman_res->mm; 163 157 struct list_head *blocks = &bman_res->blocks; 164 158 struct drm_buddy_block *block; ··· 169 161 resource_size_t prev_end; 170 162 171 163 GEM_BUG_ON(list_empty(blocks)); 164 + GEM_BUG_ON(!max_segment); 172 165 173 166 rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL); 174 167 if (!rsgt) ··· 200 191 sg = __sg_next(sg); 201 192 202 193 sg_dma_address(sg) = region_start + offset; 194 + GEM_BUG_ON(!IS_ALIGNED(sg_dma_address(sg), 195 + page_alignment)); 203 196 sg_dma_len(sg) = 0; 204 197 sg->length = 0; 205 198 st->nents++; 206 199 } 207 200 208 - len = min(block_size, max_segment - sg->length); 201 + len = min_t(u64, block_size, max_segment - sg->length); 209 202 sg->length += len; 210 203 sg_dma_len(sg) += len; 211 204
+4 -2
drivers/gpu/drm/i915/i915_scatterlist.h
··· 213 213 void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size); 214 214 215 215 struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, 216 - u64 region_start); 216 + u64 region_start, 217 + u32 page_alignment); 217 218 218 219 struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, 219 - u64 region_start); 220 + u64 region_start, 221 + u32 page_alignment); 220 222 221 223 #endif
+7 -3
drivers/gpu/drm/i915/intel_region_ttm.c
··· 152 152 * Convert an opaque TTM resource manager resource to a refcounted sg_table. 153 153 * @mem: The memory region. 154 154 * @res: The resource manager resource obtained from the TTM resource manager. 155 + * @page_alignment: Required page alignment for each sg entry. Power of two. 155 156 * 156 157 * The gem backends typically use sg-tables for operations on the underlying 157 158 * io_memory. So provide a way for the backends to translate the ··· 162 161 */ 163 162 struct i915_refct_sgt * 164 163 intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem, 165 - struct ttm_resource *res) 164 + struct ttm_resource *res, 165 + u32 page_alignment) 166 166 { 167 167 if (mem->is_range_manager) { 168 168 struct ttm_range_mgr_node *range_node = 169 169 to_ttm_range_mgr_node(res); 170 170 171 171 return i915_rsgt_from_mm_node(&range_node->mm_nodes[0], 172 - mem->region.start); 172 + mem->region.start, 173 + page_alignment); 173 174 } else { 174 - return i915_rsgt_from_buddy_resource(res, mem->region.start); 175 + return i915_rsgt_from_buddy_resource(res, mem->region.start, 176 + page_alignment); 175 177 } 176 178 } 177 179
+2 -1
drivers/gpu/drm/i915/intel_region_ttm.h
··· 24 24 25 25 struct i915_refct_sgt * 26 26 intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem, 27 - struct ttm_resource *res); 27 + struct ttm_resource *res, 28 + u32 page_alignment); 28 29 29 30 void intel_region_ttm_resource_free(struct intel_memory_region *mem, 30 31 struct ttm_resource *res);
+1 -1
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
··· 742 742 u64 addr; 743 743 744 744 for (addr = round_up(hole_start + min_alignment, step) - min_alignment; 745 - addr <= round_down(hole_end - (2 * min_alignment), step) - min_alignment; 745 + hole_end > addr && hole_end - addr >= 2 * min_alignment; 746 746 addr += step) { 747 747 err = i915_vma_pin(vma, 0, 0, addr | flags); 748 748 if (err) {
+19 -2
drivers/gpu/drm/i915/selftests/intel_memory_region.c
··· 451 451 452 452 static int igt_mock_max_segment(void *arg) 453 453 { 454 - const unsigned int max_segment = rounddown(UINT_MAX, PAGE_SIZE); 455 454 struct intel_memory_region *mem = arg; 456 455 struct drm_i915_private *i915 = mem->i915; 457 456 struct i915_ttm_buddy_resource *res; ··· 459 460 struct drm_buddy *mm; 460 461 struct list_head *blocks; 461 462 struct scatterlist *sg; 463 + I915_RND_STATE(prng); 462 464 LIST_HEAD(objects); 465 + unsigned int max_segment; 466 + unsigned int ps; 463 467 u64 size; 464 468 int err = 0; 465 469 ··· 474 472 */ 475 473 476 474 size = SZ_8G; 477 - mem = mock_region_create(i915, 0, size, PAGE_SIZE, 0, 0); 475 + ps = PAGE_SIZE; 476 + if (i915_prandom_u64_state(&prng) & 1) 477 + ps = SZ_64K; /* For something like DG2 */ 478 + 479 + max_segment = round_down(UINT_MAX, ps); 480 + 481 + mem = mock_region_create(i915, 0, size, ps, 0, 0); 478 482 if (IS_ERR(mem)) 479 483 return PTR_ERR(mem); 480 484 ··· 506 498 } 507 499 508 500 for (sg = obj->mm.pages->sgl; sg; sg = sg_next(sg)) { 501 + dma_addr_t daddr = sg_dma_address(sg); 502 + 509 503 if (sg->length > max_segment) { 510 504 pr_err("%s: Created an oversized scatterlist entry, %u > %u\n", 511 505 __func__, sg->length, max_segment); 506 + err = -EINVAL; 507 + goto out_close; 508 + } 509 + 510 + if (!IS_ALIGNED(daddr, ps)) { 511 + pr_err("%s: Created an unaligned scatterlist entry, addr=%pa, ps=%u\n", 512 + __func__, &daddr, ps); 512 513 err = -EINVAL; 513 514 goto out_close; 514 515 }
+2 -1
drivers/gpu/drm/i915/selftests/mock_region.c
··· 33 33 return PTR_ERR(obj->mm.res); 34 34 35 35 obj->mm.rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region, 36 - obj->mm.res); 36 + obj->mm.res, 37 + obj->mm.region->min_page_size); 37 38 if (IS_ERR(obj->mm.rsgt)) { 38 39 err = PTR_ERR(obj->mm.rsgt); 39 40 goto err_free_resource;
-50
drivers/infiniband/hw/irdma/cm.c
··· 4231 4231 struct irdma_cm_node *cm_node; 4232 4232 struct list_head teardown_list; 4233 4233 struct ib_qp_attr attr; 4234 - struct irdma_sc_vsi *vsi = &iwdev->vsi; 4235 - struct irdma_sc_qp *sc_qp; 4236 - struct irdma_qp *qp; 4237 - int i; 4238 4234 4239 4235 INIT_LIST_HEAD(&teardown_list); 4240 4236 ··· 4246 4250 if (iwdev->rf->reset) 4247 4251 irdma_cm_disconn(cm_node->iwqp); 4248 4252 irdma_rem_ref_cm_node(cm_node); 4249 - } 4250 - if (!iwdev->roce_mode) 4251 - return; 4252 - 4253 - INIT_LIST_HEAD(&teardown_list); 4254 - for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) { 4255 - mutex_lock(&vsi->qos[i].qos_mutex); 4256 - list_for_each_safe (list_node, list_core_temp, 4257 - &vsi->qos[i].qplist) { 4258 - u32 qp_ip[4]; 4259 - 4260 - sc_qp = container_of(list_node, struct irdma_sc_qp, 4261 - list); 4262 - if (sc_qp->qp_uk.qp_type != IRDMA_QP_TYPE_ROCE_RC) 4263 - continue; 4264 - 4265 - qp = sc_qp->qp_uk.back_qp; 4266 - if (!disconnect_all) { 4267 - if (nfo->ipv4) 4268 - qp_ip[0] = qp->udp_info.local_ipaddr[3]; 4269 - else 4270 - memcpy(qp_ip, 4271 - &qp->udp_info.local_ipaddr[0], 4272 - sizeof(qp_ip)); 4273 - } 4274 - 4275 - if (disconnect_all || 4276 - (nfo->vlan_id == (qp->udp_info.vlan_tag & VLAN_VID_MASK) && 4277 - !memcmp(qp_ip, ipaddr, nfo->ipv4 ? 4 : 16))) { 4278 - spin_lock(&iwdev->rf->qptable_lock); 4279 - if (iwdev->rf->qp_table[sc_qp->qp_uk.qp_id]) { 4280 - irdma_qp_add_ref(&qp->ibqp); 4281 - list_add(&qp->teardown_entry, 4282 - &teardown_list); 4283 - } 4284 - spin_unlock(&iwdev->rf->qptable_lock); 4285 - } 4286 - } 4287 - mutex_unlock(&vsi->qos[i].qos_mutex); 4288 - } 4289 - 4290 - list_for_each_safe (list_node, list_core_temp, &teardown_list) { 4291 - qp = container_of(list_node, struct irdma_qp, teardown_entry); 4292 - attr.qp_state = IB_QPS_ERR; 4293 - irdma_modify_qp_roce(&qp->ibqp, &attr, IB_QP_STATE, NULL); 4294 - irdma_qp_rem_ref(&qp->ibqp); 4295 4253 } 4296 4254 } 4297 4255
+1
drivers/infiniband/hw/irdma/i40iw_hw.c
··· 201 201 dev->hw_attrs.uk_attrs.max_hw_read_sges = I40IW_MAX_SGE_RD; 202 202 dev->hw_attrs.max_hw_device_pages = I40IW_MAX_PUSH_PAGE_COUNT; 203 203 dev->hw_attrs.uk_attrs.max_hw_inline = I40IW_MAX_INLINE_DATA_SIZE; 204 + dev->hw_attrs.page_size_cap = SZ_4K | SZ_2M; 204 205 dev->hw_attrs.max_hw_ird = I40IW_MAX_IRD_SIZE; 205 206 dev->hw_attrs.max_hw_ord = I40IW_MAX_ORD_SIZE; 206 207 dev->hw_attrs.max_hw_wqes = I40IW_MAX_WQ_ENTRIES;
+1
drivers/infiniband/hw/irdma/icrdma_hw.c
··· 139 139 dev->cqp_db = dev->hw_regs[IRDMA_CQPDB]; 140 140 dev->cq_ack_db = dev->hw_regs[IRDMA_CQACK]; 141 141 dev->irq_ops = &icrdma_irq_ops; 142 + dev->hw_attrs.page_size_cap = SZ_4K | SZ_2M | SZ_1G; 142 143 dev->hw_attrs.max_hw_ird = ICRDMA_MAX_IRD_SIZE; 143 144 dev->hw_attrs.max_hw_ord = ICRDMA_MAX_ORD_SIZE; 144 145 dev->hw_attrs.max_stat_inst = ICRDMA_MAX_STATS_COUNT;
+1
drivers/infiniband/hw/irdma/irdma.h
··· 127 127 u64 max_hw_outbound_msg_size; 128 128 u64 max_hw_inbound_msg_size; 129 129 u64 max_mr_size; 130 + u64 page_size_cap; 130 131 u32 min_hw_qp_id; 131 132 u32 min_hw_aeq_size; 132 133 u32 max_hw_aeq_size;
+2 -2
drivers/infiniband/hw/irdma/verbs.c
··· 32 32 props->vendor_part_id = pcidev->device; 33 33 34 34 props->hw_ver = rf->pcidev->revision; 35 - props->page_size_cap = SZ_4K | SZ_2M | SZ_1G; 35 + props->page_size_cap = hw_attrs->page_size_cap; 36 36 props->max_mr_size = hw_attrs->max_mr_size; 37 37 props->max_qp = rf->max_qp - rf->used_qps; 38 38 props->max_qp_wr = hw_attrs->max_qp_wr; ··· 2781 2781 2782 2782 if (req.reg_type == IRDMA_MEMREG_TYPE_MEM) { 2783 2783 iwmr->page_size = ib_umem_find_best_pgsz(region, 2784 - SZ_4K | SZ_2M | SZ_1G, 2784 + iwdev->rf->sc_dev.hw_attrs.page_size_cap, 2785 2785 virt); 2786 2786 if (unlikely(!iwmr->page_size)) { 2787 2787 kfree(iwmr);
+5
drivers/input/touchscreen/goodix.c
··· 900 900 } else { 901 901 dev_warn(dev, "Unexpected ACPI resources: gpio_count %d, gpio_int_idx %d\n", 902 902 ts->gpio_count, ts->gpio_int_idx); 903 + /* 904 + * On some devices _PS0 does a reset for us and 905 + * sometimes this is necessary for things to work. 906 + */ 907 + acpi_device_fix_up_power(ACPI_COMPANION(dev)); 903 908 return -EINVAL; 904 909 } 905 910
+3
drivers/input/touchscreen/usbtouchscreen.c
··· 1654 1654 if (id->driver_info == DEVTYPE_IGNORE) 1655 1655 return -ENODEV; 1656 1656 1657 + if (id->driver_info >= ARRAY_SIZE(usbtouch_dev_info)) 1658 + return -ENODEV; 1659 + 1657 1660 endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting); 1658 1661 if (!endpoint) 1659 1662 return -ENXIO;
+3 -1
drivers/input/touchscreen/wm97xx-core.c
··· 758 758 759 759 static int wm97xx_mfd_remove(struct platform_device *pdev) 760 760 { 761 - return wm97xx_remove(&pdev->dev); 761 + wm97xx_remove(&pdev->dev); 762 + 763 + return 0; 762 764 } 763 765 764 766 static int __maybe_unused wm97xx_suspend(struct device *dev)
+206 -71
drivers/net/amt.c
··· 563 563 ihv3->nsrcs = 0; 564 564 ihv3->resv = 0; 565 565 ihv3->suppress = false; 566 - ihv3->qrv = amt->net->ipv4.sysctl_igmp_qrv; 566 + ihv3->qrv = READ_ONCE(amt->net->ipv4.sysctl_igmp_qrv); 567 567 ihv3->csum = 0; 568 568 csum = &ihv3->csum; 569 569 csum_start = (void *)ihv3; ··· 577 577 return skb; 578 578 } 579 579 580 - static void __amt_update_gw_status(struct amt_dev *amt, enum amt_status status, 581 - bool validate) 580 + static void amt_update_gw_status(struct amt_dev *amt, enum amt_status status, 581 + bool validate) 582 582 { 583 583 if (validate && amt->status >= status) 584 584 return; 585 585 netdev_dbg(amt->dev, "Update GW status %s -> %s", 586 586 status_str[amt->status], status_str[status]); 587 - amt->status = status; 587 + WRITE_ONCE(amt->status, status); 588 588 } 589 589 590 590 static void __amt_update_relay_status(struct amt_tunnel_list *tunnel, ··· 598 598 &tunnel->ip4, ntohs(tunnel->source_port), 599 599 status_str[tunnel->status], status_str[status]); 600 600 tunnel->status = status; 601 - } 602 - 603 - static void amt_update_gw_status(struct amt_dev *amt, enum amt_status status, 604 - bool validate) 605 - { 606 - spin_lock_bh(&amt->lock); 607 - __amt_update_gw_status(amt, status, validate); 608 - spin_unlock_bh(&amt->lock); 609 601 } 610 602 611 603 static void amt_update_relay_status(struct amt_tunnel_list *tunnel, ··· 692 700 if (unlikely(net_xmit_eval(err))) 693 701 amt->dev->stats.tx_errors++; 694 702 695 - spin_lock_bh(&amt->lock); 696 - __amt_update_gw_status(amt, AMT_STATUS_SENT_DISCOVERY, true); 697 - spin_unlock_bh(&amt->lock); 703 + amt_update_gw_status(amt, AMT_STATUS_SENT_DISCOVERY, true); 698 704 out: 699 705 rcu_read_unlock(); 700 706 } ··· 890 900 } 891 901 #endif 892 902 903 + static bool amt_queue_event(struct amt_dev *amt, enum amt_event event, 904 + struct sk_buff *skb) 905 + { 906 + int index; 907 + 908 + spin_lock_bh(&amt->lock); 909 + if (amt->nr_events >= AMT_MAX_EVENTS) { 910 + spin_unlock_bh(&amt->lock); 911 + return 1; 912 + } 913 + 914 + index = (amt->event_idx + amt->nr_events) % AMT_MAX_EVENTS; 915 + amt->events[index].event = event; 916 + amt->events[index].skb = skb; 917 + amt->nr_events++; 918 + amt->event_idx %= AMT_MAX_EVENTS; 919 + queue_work(amt_wq, &amt->event_wq); 920 + spin_unlock_bh(&amt->lock); 921 + 922 + return 0; 923 + } 924 + 893 925 static void amt_secret_work(struct work_struct *work) 894 926 { 895 927 struct amt_dev *amt = container_of(to_delayed_work(work), ··· 925 913 msecs_to_jiffies(AMT_SECRET_TIMEOUT)); 926 914 } 927 915 916 + static void amt_event_send_discovery(struct amt_dev *amt) 917 + { 918 + if (amt->status > AMT_STATUS_SENT_DISCOVERY) 919 + goto out; 920 + get_random_bytes(&amt->nonce, sizeof(__be32)); 921 + 922 + amt_send_discovery(amt); 923 + out: 924 + mod_delayed_work(amt_wq, &amt->discovery_wq, 925 + msecs_to_jiffies(AMT_DISCOVERY_TIMEOUT)); 926 + } 927 + 928 928 static void amt_discovery_work(struct work_struct *work) 929 929 { 930 930 struct amt_dev *amt = container_of(to_delayed_work(work), 931 931 struct amt_dev, 932 932 discovery_wq); 933 933 934 - spin_lock_bh(&amt->lock); 935 - if (amt->status > AMT_STATUS_SENT_DISCOVERY) 936 - goto out; 937 - get_random_bytes(&amt->nonce, sizeof(__be32)); 938 - spin_unlock_bh(&amt->lock); 934 + if (amt_queue_event(amt, AMT_EVENT_SEND_DISCOVERY, NULL)) 935 + mod_delayed_work(amt_wq, &amt->discovery_wq, 936 + msecs_to_jiffies(AMT_DISCOVERY_TIMEOUT)); 937 + } 939 938 940 - amt_send_discovery(amt); 941 - spin_lock_bh(&amt->lock); 939 + static void amt_event_send_request(struct amt_dev *amt) 940 + { 941 + u32 exp; 942 + 943 + if (amt->status < AMT_STATUS_RECEIVED_ADVERTISEMENT) 944 + goto out; 945 + 946 + if (amt->req_cnt > AMT_MAX_REQ_COUNT) { 947 + netdev_dbg(amt->dev, "Gateway is not ready"); 948 + amt->qi = AMT_INIT_REQ_TIMEOUT; 949 + WRITE_ONCE(amt->ready4, false); 950 + WRITE_ONCE(amt->ready6, false); 951 + amt->remote_ip = 0; 952 + amt_update_gw_status(amt, AMT_STATUS_INIT, false); 953 + amt->req_cnt = 0; 954 + amt->nonce = 0; 955 + goto out; 956 + } 957 + 958 + if (!amt->req_cnt) { 959 + WRITE_ONCE(amt->ready4, false); 960 + WRITE_ONCE(amt->ready6, false); 961 + get_random_bytes(&amt->nonce, sizeof(__be32)); 962 + } 963 + 964 + amt_send_request(amt, false); 965 + amt_send_request(amt, true); 966 + amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true); 967 + amt->req_cnt++; 942 968 out: 943 - mod_delayed_work(amt_wq, &amt->discovery_wq, 944 - msecs_to_jiffies(AMT_DISCOVERY_TIMEOUT)); 945 - spin_unlock_bh(&amt->lock); 969 + exp = min_t(u32, (1 * (1 << amt->req_cnt)), AMT_MAX_REQ_TIMEOUT); 970 + mod_delayed_work(amt_wq, &amt->req_wq, msecs_to_jiffies(exp * 1000)); 946 971 } 947 972 948 973 static void amt_req_work(struct work_struct *work) ··· 987 938 struct amt_dev *amt = container_of(to_delayed_work(work), 988 939 struct amt_dev, 989 940 req_wq); 990 - u32 exp; 991 941 992 - spin_lock_bh(&amt->lock); 993 - if (amt->status < AMT_STATUS_RECEIVED_ADVERTISEMENT) 994 - goto out; 995 - 996 - if (amt->req_cnt > AMT_MAX_REQ_COUNT) { 997 - netdev_dbg(amt->dev, "Gateway is not ready"); 998 - amt->qi = AMT_INIT_REQ_TIMEOUT; 999 - amt->ready4 = false; 1000 - amt->ready6 = false; 1001 - amt->remote_ip = 0; 1002 - __amt_update_gw_status(amt, AMT_STATUS_INIT, false); 1003 - amt->req_cnt = 0; 1004 - goto out; 1005 - } 1006 - spin_unlock_bh(&amt->lock); 1007 - 1008 - amt_send_request(amt, false); 1009 - amt_send_request(amt, true); 1010 - spin_lock_bh(&amt->lock); 1011 - __amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true); 1012 - amt->req_cnt++; 1013 - out: 1014 - exp = min_t(u32, (1 * (1 << amt->req_cnt)), AMT_MAX_REQ_TIMEOUT); 1015 - mod_delayed_work(amt_wq, &amt->req_wq, msecs_to_jiffies(exp * 1000)); 1016 - spin_unlock_bh(&amt->lock); 942 + if (amt_queue_event(amt, AMT_EVENT_SEND_REQUEST, NULL)) 943 + mod_delayed_work(amt_wq, &amt->req_wq, 944 + msecs_to_jiffies(100)); 1017 945 } 1018 946 1019 947 static bool amt_send_membership_update(struct amt_dev *amt, ··· 1246 1220 /* Gateway only passes IGMP/MLD packets */ 1247 1221 if (!report) 1248 1222 goto free; 1249 - if ((!v6 && !amt->ready4) || (v6 && !amt->ready6)) 1223 + if ((!v6 && !READ_ONCE(amt->ready4)) || 1224 + (v6 && !READ_ONCE(amt->ready6))) 1250 1225 goto free; 1251 1226 if (amt_send_membership_update(amt, skb, v6)) 1252 1227 goto free; ··· 2263 2236 ipv4_is_zeronet(amta->ip4)) 2264 2237 return true; 2265 2238 2239 + if (amt->status != AMT_STATUS_SENT_DISCOVERY || 2240 + amt->nonce != amta->nonce) 2241 + return true; 2242 + 2266 2243 amt->remote_ip = amta->ip4; 2267 2244 netdev_dbg(amt->dev, "advertised remote ip = %pI4\n", &amt->remote_ip); 2268 2245 mod_delayed_work(amt_wq, &amt->req_wq, 0); ··· 2281 2250 int hdr_size, len, err; 2282 2251 struct ethhdr *eth; 2283 2252 struct iphdr *iph; 2253 + 2254 + if (READ_ONCE(amt->status) != AMT_STATUS_SENT_UPDATE) 2255 + return true; 2284 2256 2285 2257 hdr_size = sizeof(*amtmd) + sizeof(struct udphdr); 2286 2258 if (!pskb_may_pull(skb, hdr_size)) ··· 2359 2325 if (amtmq->reserved || amtmq->version) 2360 2326 return true; 2361 2327 2328 + if (amtmq->nonce != amt->nonce) 2329 + return true; 2330 + 2362 2331 hdr_size -= sizeof(*eth); 2363 2332 if (iptunnel_pull_header(skb, hdr_size, htons(ETH_P_TEB), false)) 2364 2333 return true; ··· 2376 2339 2377 2340 iph = ip_hdr(skb); 2378 2341 if (iph->version == 4) { 2342 + if (READ_ONCE(amt->ready4)) 2343 + return true; 2344 + 2379 2345 if (!pskb_may_pull(skb, sizeof(*iph) + AMT_IPHDR_OPTS + 2380 2346 sizeof(*ihv3))) 2381 2347 return true; ··· 2389 2349 ihv3 = skb_pull(skb, sizeof(*iph) + AMT_IPHDR_OPTS); 2390 2350 skb_reset_transport_header(skb); 2391 2351 skb_push(skb, sizeof(*iph) + AMT_IPHDR_OPTS); 2392 - spin_lock_bh(&amt->lock); 2393 - amt->ready4 = true; 2352 + WRITE_ONCE(amt->ready4, true); 2394 2353 amt->mac = amtmq->response_mac; 2395 2354 amt->req_cnt = 0; 2396 2355 amt->qi = ihv3->qqic; 2397 - spin_unlock_bh(&amt->lock); 2398 2356 skb->protocol = htons(ETH_P_IP); 2399 2357 eth->h_proto = htons(ETH_P_IP); 2400 2358 ip_eth_mc_map(iph->daddr, eth->h_dest); ··· 2400 2362 } else if (iph->version == 6) { 2401 2363 struct mld2_query *mld2q; 2402 2364 struct ipv6hdr *ip6h; 2365 + 2366 + if (READ_ONCE(amt->ready6)) 2367 + return true; 2403 2368 2404 2369 if (!pskb_may_pull(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS + 2405 2370 sizeof(*mld2q))) ··· 2415 2374 mld2q = skb_pull(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); 2416 2375 skb_reset_transport_header(skb); 2417 2376 skb_push(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); 2418 - spin_lock_bh(&amt->lock); 2419 - amt->ready6 = true; 2377 + WRITE_ONCE(amt->ready6, true); 2420 2378 amt->mac = amtmq->response_mac; 2421 2379 amt->req_cnt = 0; 2422 2380 amt->qi = mld2q->mld2q_qqic; 2423 - spin_unlock_bh(&amt->lock); 2424 2381 skb->protocol = htons(ETH_P_IPV6); 2425 2382 eth->h_proto = htons(ETH_P_IPV6); 2426 2383 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); ··· 2431 2392 skb->pkt_type = PACKET_MULTICAST; 2432 2393 skb->ip_summed = CHECKSUM_NONE; 2433 2394 len = skb->len; 2395 + local_bh_disable(); 2434 2396 if (__netif_rx(skb) == NET_RX_SUCCESS) { 2435 2397 amt_update_gw_status(amt, AMT_STATUS_RECEIVED_QUERY, true); 2436 2398 dev_sw_netstats_rx_add(amt->dev, len); 2437 2399 } else { 2438 2400 amt->dev->stats.rx_dropped++; 2439 2401 } 2402 + local_bh_enable(); 2440 2403 2441 2404 return false; 2442 2405 } ··· 2679 2638 if (tunnel->ip4 == iph->saddr) 2680 2639 goto send; 2681 2640 2641 + spin_lock_bh(&amt->lock); 2682 2642 if (amt->nr_tunnels >= amt->max_tunnels) { 2643 + spin_unlock_bh(&amt->lock); 2683 2644 icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); 2684 2645 return true; 2685 2646 } ··· 2689 2646 tunnel = kzalloc(sizeof(*tunnel) + 2690 2647 (sizeof(struct hlist_head) * amt->hash_buckets), 2691 2648 GFP_ATOMIC); 2692 - if (!tunnel) 2649 + if (!tunnel) { 2650 + spin_unlock_bh(&amt->lock); 2693 2651 return true; 2652 + } 2694 2653 2695 2654 tunnel->source_port = udph->source; 2696 2655 tunnel->ip4 = iph->saddr; ··· 2705 2660 2706 2661 INIT_DELAYED_WORK(&tunnel->gc_wq, amt_tunnel_expire); 2707 2662 2708 - spin_lock_bh(&amt->lock); 2709 2663 list_add_tail_rcu(&tunnel->list, &amt->tunnel_list); 2710 2664 tunnel->key = amt->key; 2711 - amt_update_relay_status(tunnel, AMT_STATUS_RECEIVED_REQUEST, true); 2665 + __amt_update_relay_status(tunnel, AMT_STATUS_RECEIVED_REQUEST, true); 2712 2666 amt->nr_tunnels++; 2713 2667 mod_delayed_work(amt_wq, &tunnel->gc_wq, 2714 2668 msecs_to_jiffies(amt_gmi(amt))); ··· 2730 2686 amt_send_mld_gq(amt, tunnel); 2731 2687 2732 2688 return false; 2689 + } 2690 + 2691 + static void amt_gw_rcv(struct amt_dev *amt, struct sk_buff *skb) 2692 + { 2693 + int type = amt_parse_type(skb); 2694 + int err = 1; 2695 + 2696 + if (type == -1) 2697 + goto drop; 2698 + 2699 + if (amt->mode == AMT_MODE_GATEWAY) { 2700 + switch (type) { 2701 + case AMT_MSG_ADVERTISEMENT: 2702 + err = amt_advertisement_handler(amt, skb); 2703 + break; 2704 + case AMT_MSG_MEMBERSHIP_QUERY: 2705 + err = amt_membership_query_handler(amt, skb); 2706 + if (!err) 2707 + return; 2708 + break; 2709 + default: 2710 + netdev_dbg(amt->dev, "Invalid type of Gateway\n"); 2711 + break; 2712 + } 2713 + } 2714 + drop: 2715 + if (err) { 2716 + amt->dev->stats.rx_dropped++; 2717 + kfree_skb(skb); 2718 + } else { 2719 + consume_skb(skb); 2720 + } 2733 2721 } 2734 2722 2735 2723 static int amt_rcv(struct sock *sk, struct sk_buff *skb) ··· 2795 2719 err = true; 2796 2720 goto drop; 2797 2721 } 2798 - err = amt_advertisement_handler(amt, skb); 2799 - break; 2722 + if (amt_queue_event(amt, AMT_EVENT_RECEIVE, skb)) { 2723 + netdev_dbg(amt->dev, "AMT Event queue full\n"); 2724 + err = true; 2725 + goto drop; 2726 + } 2727 + goto out; 2800 2728 case AMT_MSG_MULTICAST_DATA: 2801 2729 if (iph->saddr != amt->remote_ip) { 2802 2730 netdev_dbg(amt->dev, "Invalid Relay IP\n"); ··· 2818 2738 err = true; 2819 2739 goto drop; 2820 2740 } 2821 - err = amt_membership_query_handler(amt, skb); 2822 - if (err) 2741 + if (amt_queue_event(amt, AMT_EVENT_RECEIVE, skb)) { 2742 + netdev_dbg(amt->dev, "AMT Event queue full\n"); 2743 + err = true; 2823 2744 goto drop; 2824 - else 2825 - goto out; 2745 + } 2746 + goto out; 2826 2747 default: 2827 2748 err = true; 2828 2749 netdev_dbg(amt->dev, "Invalid type of Gateway\n"); ··· 2861 2780 return 0; 2862 2781 } 2863 2782 2783 + static void amt_event_work(struct work_struct *work) 2784 + { 2785 + struct amt_dev *amt = container_of(work, struct amt_dev, event_wq); 2786 + struct sk_buff *skb; 2787 + u8 event; 2788 + int i; 2789 + 2790 + for (i = 0; i < AMT_MAX_EVENTS; i++) { 2791 + spin_lock_bh(&amt->lock); 2792 + if (amt->nr_events == 0) { 2793 + spin_unlock_bh(&amt->lock); 2794 + return; 2795 + } 2796 + event = amt->events[amt->event_idx].event; 2797 + skb = amt->events[amt->event_idx].skb; 2798 + amt->events[amt->event_idx].event = AMT_EVENT_NONE; 2799 + amt->events[amt->event_idx].skb = NULL; 2800 + amt->nr_events--; 2801 + amt->event_idx++; 2802 + amt->event_idx %= AMT_MAX_EVENTS; 2803 + spin_unlock_bh(&amt->lock); 2804 + 2805 + switch (event) { 2806 + case AMT_EVENT_RECEIVE: 2807 + amt_gw_rcv(amt, skb); 2808 + break; 2809 + case AMT_EVENT_SEND_DISCOVERY: 2810 + amt_event_send_discovery(amt); 2811 + break; 2812 + case AMT_EVENT_SEND_REQUEST: 2813 + amt_event_send_request(amt); 2814 + break; 2815 + default: 2816 + if (skb) 2817 + kfree_skb(skb); 2818 + break; 2819 + } 2820 + } 2821 + } 2822 + 2864 2823 static int amt_err_lookup(struct sock *sk, struct sk_buff *skb) 2865 2824 { 2866 2825 struct amt_dev *amt; ··· 2925 2804 break; 2926 2805 case AMT_MSG_REQUEST: 2927 2806 case AMT_MSG_MEMBERSHIP_UPDATE: 2928 - if (amt->status >= AMT_STATUS_RECEIVED_ADVERTISEMENT) 2807 + if (READ_ONCE(amt->status) >= AMT_STATUS_RECEIVED_ADVERTISEMENT) 2929 2808 mod_delayed_work(amt_wq, &amt->req_wq, 0); 2930 2809 break; 2931 2810 default: ··· 2988 2867 2989 2868 amt->ready4 = false; 2990 2869 amt->ready6 = false; 2870 + amt->event_idx = 0; 2871 + amt->nr_events = 0; 2991 2872 2992 2873 err = amt_socket_create(amt); 2993 2874 if (err) ··· 2997 2874 2998 2875 amt->req_cnt = 0; 2999 2876 amt->remote_ip = 0; 2877 + amt->nonce = 0; 3000 2878 get_random_bytes(&amt->key, sizeof(siphash_key_t)); 3001 2879 3002 2880 amt->status = AMT_STATUS_INIT; ··· 3016 2892 struct amt_dev *amt = netdev_priv(dev); 3017 2893 struct amt_tunnel_list *tunnel, *tmp; 3018 2894 struct socket *sock; 2895 + struct sk_buff *skb; 2896 + int i; 3019 2897 3020 2898 cancel_delayed_work_sync(&amt->req_wq); 3021 2899 cancel_delayed_work_sync(&amt->discovery_wq); ··· 3029 2903 synchronize_net(); 3030 2904 if (sock) 3031 2905 udp_tunnel_sock_release(sock); 2906 + 2907 + cancel_work_sync(&amt->event_wq); 2908 + for (i = 0; i < AMT_MAX_EVENTS; i++) { 2909 + skb = amt->events[i].skb; 2910 + if (skb) 2911 + kfree_skb(skb); 2912 + amt->events[i].event = AMT_EVENT_NONE; 2913 + amt->events[i].skb = NULL; 2914 + } 3032 2915 3033 2916 amt->ready4 = false; 3034 2917 amt->ready6 = false; ··· 3230 3095 goto err; 3231 3096 } 3232 3097 if (amt->mode == AMT_MODE_RELAY) { 3233 - amt->qrv = amt->net->ipv4.sysctl_igmp_qrv; 3098 + amt->qrv = READ_ONCE(amt->net->ipv4.sysctl_igmp_qrv); 3234 3099 amt->qri = 10; 3235 3100 dev->needed_headroom = amt->stream_dev->needed_headroom + 3236 3101 AMT_RELAY_HLEN; ··· 3281 3146 INIT_DELAYED_WORK(&amt->discovery_wq, amt_discovery_work); 3282 3147 INIT_DELAYED_WORK(&amt->req_wq, amt_req_work); 3283 3148 INIT_DELAYED_WORK(&amt->secret_wq, amt_secret_work); 3149 + INIT_WORK(&amt->event_wq, amt_event_work); 3284 3150 INIT_LIST_HEAD(&amt->tunnel_list); 3285 - 3286 3151 return 0; 3287 3152 err: 3288 3153 dev_put(amt->stream_dev); ··· 3415 3280 if (err < 0) 3416 3281 goto unregister_notifier; 3417 3282 3418 - amt_wq = alloc_workqueue("amt", WQ_UNBOUND, 1); 3283 + amt_wq = alloc_workqueue("amt", WQ_UNBOUND, 0); 3419 3284 if (!amt_wq) { 3420 3285 err = -ENOMEM; 3421 3286 goto rtnl_unregister;
+1
drivers/net/can/rcar/rcar_canfd.c
··· 1843 1843 of_child = of_get_child_by_name(pdev->dev.of_node, name); 1844 1844 if (of_child && of_device_is_available(of_child)) 1845 1845 channels_mask |= BIT(i); 1846 + of_node_put(of_child); 1846 1847 } 1847 1848 1848 1849 if (chip_id != RENESAS_RZG2L) {
+13 -5
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
··· 1691 1691 u32 osc; 1692 1692 int err; 1693 1693 1694 - /* The OSC_LPMEN is only supported on MCP2518FD, so use it to 1695 - * autodetect the model. 1694 + /* The OSC_LPMEN is only supported on MCP2518FD and MCP251863, 1695 + * so use it to autodetect the model. 1696 1696 */ 1697 1697 err = regmap_update_bits(priv->map_reg, MCP251XFD_REG_OSC, 1698 1698 MCP251XFD_REG_OSC_LPMEN, ··· 1704 1704 if (err) 1705 1705 return err; 1706 1706 1707 - if (osc & MCP251XFD_REG_OSC_LPMEN) 1708 - devtype_data = &mcp251xfd_devtype_data_mcp2518fd; 1709 - else 1707 + if (osc & MCP251XFD_REG_OSC_LPMEN) { 1708 + /* We cannot distinguish between MCP2518FD and 1709 + * MCP251863. If firmware specifies MCP251863, keep 1710 + * it, otherwise set to MCP2518FD. 1711 + */ 1712 + if (mcp251xfd_is_251863(priv)) 1713 + devtype_data = &mcp251xfd_devtype_data_mcp251863; 1714 + else 1715 + devtype_data = &mcp251xfd_devtype_data_mcp2518fd; 1716 + } else { 1710 1717 devtype_data = &mcp251xfd_devtype_data_mcp2517fd; 1718 + } 1711 1719 1712 1720 if (!mcp251xfd_is_251XFD(priv) && 1713 1721 priv->devtype_data.model != devtype_data->model) {
+4 -1
drivers/net/dsa/microchip/ksz_common.c
··· 1579 1579 ports = of_get_child_by_name(dev->dev->of_node, "ethernet-ports"); 1580 1580 if (!ports) 1581 1581 ports = of_get_child_by_name(dev->dev->of_node, "ports"); 1582 - if (ports) 1582 + if (ports) { 1583 1583 for_each_available_child_of_node(ports, port) { 1584 1584 if (of_property_read_u32(port, "reg", 1585 1585 &port_num)) 1586 1586 continue; 1587 1587 if (!(dev->port_mask & BIT(port_num))) { 1588 1588 of_node_put(port); 1589 + of_node_put(ports); 1589 1590 return -EINVAL; 1590 1591 } 1591 1592 of_get_phy_mode(port, 1592 1593 &dev->ports[port_num].interface); 1593 1594 } 1595 + of_node_put(ports); 1596 + } 1594 1597 dev->synclko_125 = of_property_read_bool(dev->dev->of_node, 1595 1598 "microchip,synclko-125"); 1596 1599 dev->synclko_disable = of_property_read_bool(dev->dev->of_node,
+16
drivers/net/dsa/sja1105/sja1105_main.c
··· 3382 3382 }; 3383 3383 MODULE_DEVICE_TABLE(of, sja1105_dt_ids); 3384 3384 3385 + static const struct spi_device_id sja1105_spi_ids[] = { 3386 + { "sja1105e" }, 3387 + { "sja1105t" }, 3388 + { "sja1105p" }, 3389 + { "sja1105q" }, 3390 + { "sja1105r" }, 3391 + { "sja1105s" }, 3392 + { "sja1110a" }, 3393 + { "sja1110b" }, 3394 + { "sja1110c" }, 3395 + { "sja1110d" }, 3396 + { }, 3397 + }; 3398 + MODULE_DEVICE_TABLE(spi, sja1105_spi_ids); 3399 + 3385 3400 static struct spi_driver sja1105_driver = { 3386 3401 .driver = { 3387 3402 .name = "sja1105", 3388 3403 .owner = THIS_MODULE, 3389 3404 .of_match_table = of_match_ptr(sja1105_dt_ids), 3390 3405 }, 3406 + .id_table = sja1105_spi_ids, 3391 3407 .probe = sja1105_probe, 3392 3408 .remove = sja1105_remove, 3393 3409 .shutdown = sja1105_shutdown,
+10
drivers/net/dsa/vitesse-vsc73xx-spi.c
··· 205 205 }; 206 206 MODULE_DEVICE_TABLE(of, vsc73xx_of_match); 207 207 208 + static const struct spi_device_id vsc73xx_spi_ids[] = { 209 + { "vsc7385" }, 210 + { "vsc7388" }, 211 + { "vsc7395" }, 212 + { "vsc7398" }, 213 + { }, 214 + }; 215 + MODULE_DEVICE_TABLE(spi, vsc73xx_spi_ids); 216 + 208 217 static struct spi_driver vsc73xx_spi_driver = { 209 218 .probe = vsc73xx_spi_probe, 210 219 .remove = vsc73xx_spi_remove, 211 220 .shutdown = vsc73xx_spi_shutdown, 221 + .id_table = vsc73xx_spi_ids, 212 222 .driver = { 213 223 .name = "vsc73xx-spi", 214 224 .of_match_table = vsc73xx_of_match,
+3 -3
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
··· 1236 1236 csk->sndbuf = newsk->sk_sndbuf; 1237 1237 csk->smac_idx = ((struct port_info *)netdev_priv(ndev))->smt_idx; 1238 1238 RCV_WSCALE(tp) = select_rcv_wscale(tcp_full_space(newsk), 1239 - sock_net(newsk)-> 1240 - ipv4.sysctl_tcp_window_scaling, 1239 + READ_ONCE(sock_net(newsk)-> 1240 + ipv4.sysctl_tcp_window_scaling), 1241 1241 tp->window_clamp); 1242 1242 neigh_release(n); 1243 1243 inet_inherit_port(&tcp_hashinfo, lsk, newsk); ··· 1384 1384 #endif 1385 1385 } 1386 1386 if (req->tcpopt.wsf <= 14 && 1387 - sock_net(sk)->ipv4.sysctl_tcp_window_scaling) { 1387 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_window_scaling)) { 1388 1388 inet_rsk(oreq)->wscale_ok = 1; 1389 1389 inet_rsk(oreq)->snd_wscale = req->tcpopt.wsf; 1390 1390 }
+5 -5
drivers/net/ethernet/emulex/benet/be_cmds.c
··· 2287 2287 2288 2288 /* Uses sync mcc */ 2289 2289 int be_cmd_read_port_transceiver_data(struct be_adapter *adapter, 2290 - u8 page_num, u8 *data) 2290 + u8 page_num, u32 off, u32 len, u8 *data) 2291 2291 { 2292 2292 struct be_dma_mem cmd; 2293 2293 struct be_mcc_wrb *wrb; ··· 2321 2321 req->port = cpu_to_le32(adapter->hba_port_num); 2322 2322 req->page_num = cpu_to_le32(page_num); 2323 2323 status = be_mcc_notify_wait(adapter); 2324 - if (!status) { 2324 + if (!status && len > 0) { 2325 2325 struct be_cmd_resp_port_type *resp = cmd.va; 2326 2326 2327 - memcpy(data, resp->page_data, PAGE_DATA_LEN); 2327 + memcpy(data, resp->page_data + off, len); 2328 2328 } 2329 2329 err: 2330 2330 mutex_unlock(&adapter->mcc_lock); ··· 2415 2415 int status; 2416 2416 2417 2417 status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, 2418 - page_data); 2418 + 0, PAGE_DATA_LEN, page_data); 2419 2419 if (!status) { 2420 2420 switch (adapter->phy.interface_type) { 2421 2421 case PHY_TYPE_QSFP: ··· 2440 2440 int status; 2441 2441 2442 2442 status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, 2443 - page_data); 2443 + 0, PAGE_DATA_LEN, page_data); 2444 2444 if (!status) { 2445 2445 strlcpy(adapter->phy.vendor_name, page_data + 2446 2446 SFP_VENDOR_NAME_OFFSET, SFP_VENDOR_NAME_LEN - 1);
+1 -1
drivers/net/ethernet/emulex/benet/be_cmds.h
··· 2427 2427 int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, 2428 2428 u32 *state); 2429 2429 int be_cmd_read_port_transceiver_data(struct be_adapter *adapter, 2430 - u8 page_num, u8 *data); 2430 + u8 page_num, u32 off, u32 len, u8 *data); 2431 2431 int be_cmd_query_cable_type(struct be_adapter *adapter); 2432 2432 int be_cmd_query_sfp_info(struct be_adapter *adapter); 2433 2433 int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
+19 -12
drivers/net/ethernet/emulex/benet/be_ethtool.c
··· 1344 1344 return -EOPNOTSUPP; 1345 1345 1346 1346 status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, 1347 - page_data); 1347 + 0, PAGE_DATA_LEN, page_data); 1348 1348 if (!status) { 1349 1349 if (!page_data[SFP_PLUS_SFF_8472_COMP]) { 1350 1350 modinfo->type = ETH_MODULE_SFF_8079; ··· 1362 1362 { 1363 1363 struct be_adapter *adapter = netdev_priv(netdev); 1364 1364 int status; 1365 + u32 begin, end; 1365 1366 1366 1367 if (!check_privilege(adapter, MAX_PRIVILEGES)) 1367 1368 return -EOPNOTSUPP; 1368 1369 1369 - status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, 1370 - data); 1371 - if (status) 1372 - goto err; 1370 + begin = eeprom->offset; 1371 + end = eeprom->offset + eeprom->len; 1373 1372 1374 - if (eeprom->offset + eeprom->len > PAGE_DATA_LEN) { 1375 - status = be_cmd_read_port_transceiver_data(adapter, 1376 - TR_PAGE_A2, 1377 - data + 1378 - PAGE_DATA_LEN); 1373 + if (begin < PAGE_DATA_LEN) { 1374 + status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, begin, 1375 + min_t(u32, end, PAGE_DATA_LEN) - begin, 1376 + data); 1377 + if (status) 1378 + goto err; 1379 + 1380 + data += PAGE_DATA_LEN - begin; 1381 + begin = PAGE_DATA_LEN; 1382 + } 1383 + 1384 + if (end > PAGE_DATA_LEN) { 1385 + status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A2, 1386 + begin - PAGE_DATA_LEN, 1387 + end - begin, data); 1379 1388 if (status) 1380 1389 goto err; 1381 1390 } 1382 - if (eeprom->offset) 1383 - memcpy(data, data + eeprom->offset, eeprom->len); 1384 1391 err: 1385 1392 return be_cmd_status(status); 1386 1393 }
-1
drivers/net/ethernet/intel/e1000e/hw.h
··· 630 630 bool disable_polarity_correction; 631 631 bool is_mdix; 632 632 bool polarity_correction; 633 - bool reset_disable; 634 633 bool speed_downgraded; 635 634 bool autoneg_wait_to_complete; 636 635 };
-4
drivers/net/ethernet/intel/e1000e/ich8lan.c
··· 2050 2050 bool blocked = false; 2051 2051 int i = 0; 2052 2052 2053 - /* Check the PHY (LCD) reset flag */ 2054 - if (hw->phy.reset_disable) 2055 - return true; 2056 - 2057 2053 while ((blocked = !(er32(FWSM) & E1000_ICH_FWSM_RSPCIPHY)) && 2058 2054 (i++ < 30)) 2059 2055 usleep_range(10000, 11000);
-1
drivers/net/ethernet/intel/e1000e/ich8lan.h
··· 271 271 #define I217_CGFREG_ENABLE_MTA_RESET 0x0002 272 272 #define I217_MEMPWR PHY_REG(772, 26) 273 273 #define I217_MEMPWR_DISABLE_SMB_RELEASE 0x0010 274 - #define I217_MEMPWR_MOEM 0x1000 275 274 276 275 /* Receive Address Initial CRC Calculation */ 277 276 #define E1000_PCH_RAICC(_n) (0x05F50 + ((_n) * 4))
+4 -26
drivers/net/ethernet/intel/e1000e/netdev.c
··· 6494 6494 6495 6495 if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID && 6496 6496 hw->mac.type >= e1000_pch_adp) { 6497 + /* Keep the GPT clock enabled for CSME */ 6498 + mac_data = er32(FEXTNVM); 6499 + mac_data |= BIT(3); 6500 + ew32(FEXTNVM, mac_data); 6497 6501 /* Request ME unconfigure the device from S0ix */ 6498 6502 mac_data = er32(H2ME); 6499 6503 mac_data &= ~E1000_H2ME_START_DPG; ··· 6991 6987 struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev)); 6992 6988 struct e1000_adapter *adapter = netdev_priv(netdev); 6993 6989 struct pci_dev *pdev = to_pci_dev(dev); 6994 - struct e1000_hw *hw = &adapter->hw; 6995 - u16 phy_data; 6996 6990 int rc; 6997 - 6998 - if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID && 6999 - hw->mac.type >= e1000_pch_adp) { 7000 - /* Mask OEM Bits / Gig Disable / Restart AN (772_26[12] = 1) */ 7001 - e1e_rphy(hw, I217_MEMPWR, &phy_data); 7002 - phy_data |= I217_MEMPWR_MOEM; 7003 - e1e_wphy(hw, I217_MEMPWR, phy_data); 7004 - 7005 - /* Disable LCD reset */ 7006 - hw->phy.reset_disable = true; 7007 - } 7008 6991 7009 6992 e1000e_flush_lpic(pdev); 7010 6993 ··· 7014 7023 struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev)); 7015 7024 struct e1000_adapter *adapter = netdev_priv(netdev); 7016 7025 struct pci_dev *pdev = to_pci_dev(dev); 7017 - struct e1000_hw *hw = &adapter->hw; 7018 - u16 phy_data; 7019 7026 int rc; 7020 7027 7021 7028 /* Introduce S0ix implementation */ ··· 7023 7034 rc = __e1000_resume(pdev); 7024 7035 if (rc) 7025 7036 return rc; 7026 - 7027 - if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID && 7028 - hw->mac.type >= e1000_pch_adp) { 7029 - /* Unmask OEM Bits / Gig Disable / Restart AN 772_26[12] = 0 */ 7030 - e1e_rphy(hw, I217_MEMPWR, &phy_data); 7031 - phy_data &= ~I217_MEMPWR_MOEM; 7032 - e1e_wphy(hw, I217_MEMPWR, phy_data); 7033 - 7034 - /* Enable LCD reset */ 7035 - hw->phy.reset_disable = false; 7036 - } 7037 7037 7038 7038 return e1000e_pm_thaw(dev); 7039 7039 }
+5 -8
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 10773 10773 **/ 10774 10774 static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) 10775 10775 { 10776 - int old_recovery_mode_bit = test_bit(__I40E_RECOVERY_MODE, pf->state); 10776 + const bool is_recovery_mode_reported = i40e_check_recovery_mode(pf); 10777 10777 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; 10778 10778 struct i40e_hw *hw = &pf->hw; 10779 10779 i40e_status ret; ··· 10781 10781 int v; 10782 10782 10783 10783 if (test_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state) && 10784 - i40e_check_recovery_mode(pf)) { 10784 + is_recovery_mode_reported) 10785 10785 i40e_set_ethtool_ops(pf->vsi[pf->lan_vsi]->netdev); 10786 - } 10787 10786 10788 10787 if (test_bit(__I40E_DOWN, pf->state) && 10789 - !test_bit(__I40E_RECOVERY_MODE, pf->state) && 10790 - !old_recovery_mode_bit) 10788 + !test_bit(__I40E_RECOVERY_MODE, pf->state)) 10791 10789 goto clear_recovery; 10792 10790 dev_dbg(&pf->pdev->dev, "Rebuilding internal switch\n"); 10793 10791 ··· 10812 10814 * accordingly with regard to resources initialization 10813 10815 * and deinitialization 10814 10816 */ 10815 - if (test_bit(__I40E_RECOVERY_MODE, pf->state) || 10816 - old_recovery_mode_bit) { 10817 + if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { 10817 10818 if (i40e_get_capabilities(pf, 10818 10819 i40e_aqc_opc_list_func_capabilities)) 10819 10820 goto end_unlock; 10820 10821 10821 - if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { 10822 + if (is_recovery_mode_reported) { 10822 10823 /* we're staying in recovery mode so we'll reinitialize 10823 10824 * misc vector here 10824 10825 */
+11 -3
drivers/net/ethernet/intel/iavf/iavf.h
··· 64 64 u16 id; 65 65 DECLARE_BITMAP(state, __IAVF_VSI_STATE_SIZE__); 66 66 int base_vector; 67 - u16 work_limit; 68 67 u16 qs_handle; 69 68 void *priv; /* client driver data reference. */ 70 69 }; ··· 159 160 struct iavf_vlan_filter { 160 161 struct list_head list; 161 162 struct iavf_vlan vlan; 162 - bool remove; /* filter needs to be removed */ 163 - bool add; /* filter needs to be added */ 163 + struct { 164 + u8 is_new_vlan:1; /* filter is new, wait for PF answer */ 165 + u8 remove:1; /* filter needs to be removed */ 166 + u8 add:1; /* filter needs to be added */ 167 + u8 padding:5; 168 + }; 164 169 }; 165 170 166 171 #define IAVF_MAX_TRAFFIC_CLASS 4 ··· 467 464 return "__IAVF_INIT_VERSION_CHECK"; 468 465 case __IAVF_INIT_GET_RESOURCES: 469 466 return "__IAVF_INIT_GET_RESOURCES"; 467 + case __IAVF_INIT_EXTENDED_CAPS: 468 + return "__IAVF_INIT_EXTENDED_CAPS"; 469 + case __IAVF_INIT_CONFIG_ADAPTER: 470 + return "__IAVF_INIT_CONFIG_ADAPTER"; 470 471 case __IAVF_INIT_SW: 471 472 return "__IAVF_INIT_SW"; 472 473 case __IAVF_INIT_FAILED: ··· 530 523 int iavf_get_vf_vlan_v2_caps(struct iavf_adapter *adapter); 531 524 int iavf_send_vf_offload_vlan_v2_msg(struct iavf_adapter *adapter); 532 525 void iavf_set_queue_vlan_tag_loc(struct iavf_adapter *adapter); 526 + u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter); 533 527 void iavf_irq_enable(struct iavf_adapter *adapter, bool flush); 534 528 void iavf_configure_queues(struct iavf_adapter *adapter); 535 529 void iavf_deconfigure_queues(struct iavf_adapter *adapter);
-10
drivers/net/ethernet/intel/iavf/iavf_ethtool.c
··· 692 692 struct ethtool_coalesce *ec, int queue) 693 693 { 694 694 struct iavf_adapter *adapter = netdev_priv(netdev); 695 - struct iavf_vsi *vsi = &adapter->vsi; 696 695 struct iavf_ring *rx_ring, *tx_ring; 697 - 698 - ec->tx_max_coalesced_frames = vsi->work_limit; 699 - ec->rx_max_coalesced_frames = vsi->work_limit; 700 696 701 697 /* Rx and Tx usecs per queue value. If user doesn't specify the 702 698 * queue, return queue 0's value to represent. ··· 821 825 struct ethtool_coalesce *ec, int queue) 822 826 { 823 827 struct iavf_adapter *adapter = netdev_priv(netdev); 824 - struct iavf_vsi *vsi = &adapter->vsi; 825 828 int i; 826 - 827 - if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq) 828 - vsi->work_limit = ec->tx_max_coalesced_frames_irq; 829 829 830 830 if (ec->rx_coalesce_usecs == 0) { 831 831 if (ec->use_adaptive_rx_coalesce) ··· 1961 1969 1962 1970 static const struct ethtool_ops iavf_ethtool_ops = { 1963 1971 .supported_coalesce_params = ETHTOOL_COALESCE_USECS | 1964 - ETHTOOL_COALESCE_MAX_FRAMES | 1965 - ETHTOOL_COALESCE_MAX_FRAMES_IRQ | 1966 1972 ETHTOOL_COALESCE_USE_ADAPTIVE, 1967 1973 .get_drvinfo = iavf_get_drvinfo, 1968 1974 .get_link = ethtool_op_get_link,
+4 -7
drivers/net/ethernet/intel/iavf/iavf_main.c
··· 843 843 * iavf_get_num_vlans_added - get number of VLANs added 844 844 * @adapter: board private structure 845 845 */ 846 - static u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter) 846 + u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter) 847 847 { 848 848 return bitmap_weight(adapter->vsi.active_cvlans, VLAN_N_VID) + 849 849 bitmap_weight(adapter->vsi.active_svlans, VLAN_N_VID); ··· 905 905 906 906 if (!iavf_add_vlan(adapter, IAVF_VLAN(vid, be16_to_cpu(proto)))) 907 907 return -ENOMEM; 908 - 909 - if (proto == cpu_to_be16(ETH_P_8021Q)) 910 - set_bit(vid, adapter->vsi.active_cvlans); 911 - else 912 - set_bit(vid, adapter->vsi.active_svlans); 913 908 914 909 return 0; 915 910 } ··· 2326 2331 2327 2332 adapter->vsi.back = adapter; 2328 2333 adapter->vsi.base_vector = 1; 2329 - adapter->vsi.work_limit = IAVF_DEFAULT_IRQ_WORK; 2330 2334 vsi->netdev = adapter->netdev; 2331 2335 vsi->qs_handle = adapter->vsi_res->qset_handle; 2332 2336 if (adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) { ··· 3037 3043 adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; 3038 3044 adapter->aq_required |= IAVF_FLAG_AQ_ADD_CLOUD_FILTER; 3039 3045 iavf_misc_irq_enable(adapter); 3046 + 3047 + bitmap_clear(adapter->vsi.active_cvlans, 0, VLAN_N_VID); 3048 + bitmap_clear(adapter->vsi.active_svlans, 0, VLAN_N_VID); 3040 3049 3041 3050 mod_delayed_work(iavf_wq, &adapter->watchdog_task, 2); 3042 3051
+3 -4
drivers/net/ethernet/intel/iavf/iavf_txrx.c
··· 194 194 struct iavf_tx_buffer *tx_buf; 195 195 struct iavf_tx_desc *tx_desc; 196 196 unsigned int total_bytes = 0, total_packets = 0; 197 - unsigned int budget = vsi->work_limit; 197 + unsigned int budget = IAVF_DEFAULT_IRQ_WORK; 198 198 199 199 tx_buf = &tx_ring->tx_bi[i]; 200 200 tx_desc = IAVF_TX_DESC(tx_ring, i); ··· 1285 1285 { 1286 1286 struct iavf_rx_buffer *rx_buffer; 1287 1287 1288 - if (!size) 1289 - return NULL; 1290 - 1291 1288 rx_buffer = &rx_ring->rx_bi[rx_ring->next_to_clean]; 1292 1289 prefetchw(rx_buffer->page); 1290 + if (!size) 1291 + return rx_buffer; 1293 1292 1294 1293 /* we are reusing so sync this buffer for CPU use */ 1295 1294 dma_sync_single_range_for_cpu(rx_ring->dev,
+63 -2
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
··· 628 628 } 629 629 630 630 /** 631 + * iavf_vlan_add_reject 632 + * @adapter: adapter structure 633 + * 634 + * Remove VLAN filters from list based on PF response. 635 + **/ 636 + static void iavf_vlan_add_reject(struct iavf_adapter *adapter) 637 + { 638 + struct iavf_vlan_filter *f, *ftmp; 639 + 640 + spin_lock_bh(&adapter->mac_vlan_list_lock); 641 + list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { 642 + if (f->is_new_vlan) { 643 + if (f->vlan.tpid == ETH_P_8021Q) 644 + clear_bit(f->vlan.vid, 645 + adapter->vsi.active_cvlans); 646 + else 647 + clear_bit(f->vlan.vid, 648 + adapter->vsi.active_svlans); 649 + 650 + list_del(&f->list); 651 + kfree(f); 652 + } 653 + } 654 + spin_unlock_bh(&adapter->mac_vlan_list_lock); 655 + } 656 + 657 + /** 631 658 * iavf_add_vlans 632 659 * @adapter: adapter structure 633 660 * ··· 711 684 vvfl->vlan_id[i] = f->vlan.vid; 712 685 i++; 713 686 f->add = false; 687 + f->is_new_vlan = true; 714 688 if (i == count) 715 689 break; 716 690 } ··· 724 696 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len); 725 697 kfree(vvfl); 726 698 } else { 699 + u16 max_vlans = adapter->vlan_v2_caps.filtering.max_filters; 700 + u16 current_vlans = iavf_get_num_vlans_added(adapter); 727 701 struct virtchnl_vlan_filter_list_v2 *vvfl_v2; 728 702 729 703 adapter->current_op = VIRTCHNL_OP_ADD_VLAN_V2; 704 + 705 + if ((count + current_vlans) > max_vlans && 706 + current_vlans < max_vlans) { 707 + count = max_vlans - iavf_get_num_vlans_added(adapter); 708 + more = true; 709 + } 730 710 731 711 len = sizeof(*vvfl_v2) + ((count - 1) * 732 712 sizeof(struct virtchnl_vlan_filter)); ··· 762 726 &adapter->vlan_v2_caps.filtering.filtering_support; 763 727 struct virtchnl_vlan *vlan; 764 728 729 + if (i == count) 730 + break; 731 + 765 732 /* give priority over outer if it's enabled */ 766 733 if (filtering_support->outer) 767 734 vlan = &vvfl_v2->filters[i].outer; ··· 776 737 777 738 i++; 778 739 f->add = false; 779 - if (i == count) 780 - break; 740 + f->is_new_vlan = true; 781 741 } 782 742 } 783 743 ··· 2120 2082 */ 2121 2083 iavf_netdev_features_vlan_strip_set(netdev, true); 2122 2084 break; 2085 + case VIRTCHNL_OP_ADD_VLAN_V2: 2086 + iavf_vlan_add_reject(adapter); 2087 + dev_warn(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n", 2088 + iavf_stat_str(&adapter->hw, v_retval)); 2089 + break; 2123 2090 default: 2124 2091 dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n", 2125 2092 v_retval, iavf_stat_str(&adapter->hw, v_retval), ··· 2426 2383 } 2427 2384 } 2428 2385 spin_unlock_bh(&adapter->adv_rss_lock); 2386 + } 2387 + break; 2388 + case VIRTCHNL_OP_ADD_VLAN_V2: { 2389 + struct iavf_vlan_filter *f; 2390 + 2391 + spin_lock_bh(&adapter->mac_vlan_list_lock); 2392 + list_for_each_entry(f, &adapter->vlan_filter_list, list) { 2393 + if (f->is_new_vlan) { 2394 + f->is_new_vlan = false; 2395 + if (f->vlan.tpid == ETH_P_8021Q) 2396 + set_bit(f->vlan.vid, 2397 + adapter->vsi.active_cvlans); 2398 + else 2399 + set_bit(f->vlan.vid, 2400 + adapter->vsi.active_svlans); 2401 + } 2402 + } 2403 + spin_unlock_bh(&adapter->mac_vlan_list_lock); 2429 2404 } 2430 2405 break; 2431 2406 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
+3
drivers/net/ethernet/intel/igc/igc_main.c
··· 6182 6182 u8 __iomem *hw_addr = READ_ONCE(hw->hw_addr); 6183 6183 u32 value = 0; 6184 6184 6185 + if (IGC_REMOVED(hw_addr)) 6186 + return ~value; 6187 + 6185 6188 value = readl(&hw_addr[reg]); 6186 6189 6187 6190 /* reads should not return all F's */
+4 -1
drivers/net/ethernet/intel/igc/igc_regs.h
··· 303 303 #define wr32(reg, val) \ 304 304 do { \ 305 305 u8 __iomem *hw_addr = READ_ONCE((hw)->hw_addr); \ 306 - writel((val), &hw_addr[(reg)]); \ 306 + if (!IGC_REMOVED(hw_addr)) \ 307 + writel((val), &hw_addr[(reg)]); \ 307 308 } while (0) 308 309 309 310 #define rd32(reg) (igc_rd32(hw, reg)) ··· 315 314 wr32((reg) + ((offset) << 2), (value)) 316 315 317 316 #define array_rd32(reg, offset) (igc_rd32(hw, (reg) + ((offset) << 2))) 317 + 318 + #define IGC_REMOVED(h) unlikely(!(h)) 318 319 319 320 #endif
+1
drivers/net/ethernet/intel/ixgbe/ixgbe.h
··· 813 813 #ifdef CONFIG_IXGBE_IPSEC 814 814 struct ixgbe_ipsec *ipsec; 815 815 #endif /* CONFIG_IXGBE_IPSEC */ 816 + spinlock_t vfs_lock; 816 817 }; 817 818 818 819 static inline int ixgbe_determine_xdp_q_idx(int cpu)
+3
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 6445 6445 /* n-tuple support exists, always init our spinlock */ 6446 6446 spin_lock_init(&adapter->fdir_perfect_lock); 6447 6447 6448 + /* init spinlock to avoid concurrency of VF resources */ 6449 + spin_lock_init(&adapter->vfs_lock); 6450 + 6448 6451 #ifdef CONFIG_IXGBE_DCB 6449 6452 ixgbe_init_dcb(adapter); 6450 6453 #endif
+6
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
··· 205 205 int ixgbe_disable_sriov(struct ixgbe_adapter *adapter) 206 206 { 207 207 unsigned int num_vfs = adapter->num_vfs, vf; 208 + unsigned long flags; 208 209 int rss; 209 210 211 + spin_lock_irqsave(&adapter->vfs_lock, flags); 210 212 /* set num VFs to 0 to prevent access to vfinfo */ 211 213 adapter->num_vfs = 0; 214 + spin_unlock_irqrestore(&adapter->vfs_lock, flags); 212 215 213 216 /* put the reference to all of the vf devices */ 214 217 for (vf = 0; vf < num_vfs; ++vf) { ··· 1358 1355 void ixgbe_msg_task(struct ixgbe_adapter *adapter) 1359 1356 { 1360 1357 struct ixgbe_hw *hw = &adapter->hw; 1358 + unsigned long flags; 1361 1359 u32 vf; 1362 1360 1361 + spin_lock_irqsave(&adapter->vfs_lock, flags); 1363 1362 for (vf = 0; vf < adapter->num_vfs; vf++) { 1364 1363 /* process any reset requests */ 1365 1364 if (!ixgbe_check_for_rst(hw, vf)) ··· 1375 1370 if (!ixgbe_check_for_ack(hw, vf)) 1376 1371 ixgbe_rcv_ack_from_vf(adapter, vf); 1377 1372 } 1373 + spin_unlock_irqrestore(&adapter->vfs_lock, flags); 1378 1374 } 1379 1375 1380 1376 static inline void ixgbe_ping_vf(struct ixgbe_adapter *adapter, int vf)
+3 -3
drivers/net/ethernet/marvell/prestera/prestera_flower.c
··· 168 168 } 169 169 port = netdev_priv(ingress_dev); 170 170 171 - mask = htons(0x1FFF); 172 - key = htons(port->hw_id); 171 + mask = htons(0x1FFF << 3); 172 + key = htons(port->hw_id << 3); 173 173 rule_match_set(r_match->key, SYS_PORT, key); 174 174 rule_match_set(r_match->mask, SYS_PORT, mask); 175 175 176 - mask = htons(0x1FF); 176 + mask = htons(0x3FF); 177 177 key = htons(port->dev_id); 178 178 rule_match_set(r_match->key, SYS_DEV, key); 179 179 rule_match_set(r_match->mask, SYS_DEV, mask);
+3
drivers/net/ethernet/mediatek/mtk_ppe_offload.c
··· 93 93 }; 94 94 struct net_device_path path = {}; 95 95 96 + if (!ctx.dev) 97 + return -ENODEV; 98 + 96 99 memcpy(ctx.daddr, addr, sizeof(ctx.daddr)); 97 100 98 101 if (!IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED))
+1 -1
drivers/net/ethernet/mediatek/mtk_wed.c
··· 651 651 * WDMA RX. 652 652 */ 653 653 654 - BUG_ON(idx > ARRAY_SIZE(dev->tx_ring)); 654 + BUG_ON(idx >= ARRAY_SIZE(dev->tx_ring)); 655 655 656 656 if (mtk_wed_ring_alloc(dev, ring, MTK_WED_TX_RING_SIZE)) 657 657 return -ENOMEM;
+5 -4
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 5292 5292 { 5293 5293 const struct fib_nh *nh = fib_info_nh(fi, 0); 5294 5294 5295 - return nh->fib_nh_scope == RT_SCOPE_LINK || 5295 + return nh->fib_nh_gw_family || 5296 5296 mlxsw_sp_nexthop4_ipip_type(mlxsw_sp, nh, NULL); 5297 5297 } 5298 5298 ··· 10144 10144 unsigned long *fields = config->fields; 10145 10145 u32 hash_fields; 10146 10146 10147 - switch (net->ipv4.sysctl_fib_multipath_hash_policy) { 10147 + switch (READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_policy)) { 10148 10148 case 0: 10149 10149 mlxsw_sp_mp4_hash_outer_addr(config); 10150 10150 break; ··· 10162 10162 mlxsw_sp_mp_hash_inner_l3(config); 10163 10163 break; 10164 10164 case 3: 10165 - hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; 10165 + hash_fields = READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields); 10166 10166 /* Outer */ 10167 10167 MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_NOT_TCP_NOT_UDP); 10168 10168 MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_TCP_UDP); ··· 10343 10343 static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) 10344 10344 { 10345 10345 struct net *net = mlxsw_sp_net(mlxsw_sp); 10346 - bool usp = net->ipv4.sysctl_ip_fwd_update_priority; 10347 10346 char rgcr_pl[MLXSW_REG_RGCR_LEN]; 10348 10347 u64 max_rifs; 10348 + bool usp; 10349 10349 10350 10350 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_RIFS)) 10351 10351 return -EIO; 10352 10352 max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); 10353 + usp = READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority); 10353 10354 10354 10355 mlxsw_reg_rgcr_pack(rgcr_pl, true, true); 10355 10356 mlxsw_reg_rgcr_max_router_interfaces_set(rgcr_pl, max_rifs);
+80 -32
drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
··· 75 75 unsigned int vid, 76 76 enum macaccess_entry_type type) 77 77 { 78 + int ret; 79 + 80 + spin_lock(&lan966x->mac_lock); 78 81 lan966x_mac_select(lan966x, mac, vid); 79 82 80 83 /* Issue a write command */ ··· 89 86 ANA_MACACCESS_MAC_TABLE_CMD_SET(MACACCESS_CMD_LEARN), 90 87 lan966x, ANA_MACACCESS); 91 88 92 - return lan966x_mac_wait_for_completion(lan966x); 89 + ret = lan966x_mac_wait_for_completion(lan966x); 90 + spin_unlock(&lan966x->mac_lock); 91 + 92 + return ret; 93 93 } 94 94 95 95 /* The mask of the front ports is encoded inside the mac parameter via a call ··· 119 113 return __lan966x_mac_learn(lan966x, port, false, mac, vid, type); 120 114 } 121 115 122 - int lan966x_mac_forget(struct lan966x *lan966x, 123 - const unsigned char mac[ETH_ALEN], 124 - unsigned int vid, 125 - enum macaccess_entry_type type) 116 + static int lan966x_mac_forget_locked(struct lan966x *lan966x, 117 + const unsigned char mac[ETH_ALEN], 118 + unsigned int vid, 119 + enum macaccess_entry_type type) 126 120 { 121 + lockdep_assert_held(&lan966x->mac_lock); 122 + 127 123 lan966x_mac_select(lan966x, mac, vid); 128 124 129 125 /* Issue a forget command */ ··· 134 126 lan966x, ANA_MACACCESS); 135 127 136 128 return lan966x_mac_wait_for_completion(lan966x); 129 + } 130 + 131 + int lan966x_mac_forget(struct lan966x *lan966x, 132 + const unsigned char mac[ETH_ALEN], 133 + unsigned int vid, 134 + enum macaccess_entry_type type) 135 + { 136 + int ret; 137 + 138 + spin_lock(&lan966x->mac_lock); 139 + ret = lan966x_mac_forget_locked(lan966x, mac, vid, type); 140 + spin_unlock(&lan966x->mac_lock); 141 + 142 + return ret; 137 143 } 138 144 139 145 int lan966x_mac_cpu_learn(struct lan966x *lan966x, const char *addr, u16 vid) ··· 183 161 { 184 162 struct lan966x_mac_entry *mac_entry; 185 163 186 - mac_entry = kzalloc(sizeof(*mac_entry), GFP_KERNEL); 164 + mac_entry = kzalloc(sizeof(*mac_entry), GFP_ATOMIC); 187 165 if (!mac_entry) 188 166 return NULL; 189 167 ··· 201 179 struct lan966x_mac_entry *res = NULL; 202 180 struct lan966x_mac_entry *mac_entry; 203 181 204 - spin_lock(&lan966x->mac_lock); 205 182 list_for_each_entry(mac_entry, &lan966x->mac_entries, list) { 206 183 if (mac_entry->vid == vid && 207 184 ether_addr_equal(mac, mac_entry->mac) && ··· 209 188 break; 210 189 } 211 190 } 212 - spin_unlock(&lan966x->mac_lock); 213 191 214 192 return res; 215 193 } ··· 251 231 { 252 232 struct lan966x_mac_entry *mac_entry; 253 233 254 - if (lan966x_mac_lookup(lan966x, addr, vid, ENTRYTYPE_NORMAL)) 234 + spin_lock(&lan966x->mac_lock); 235 + if (lan966x_mac_lookup(lan966x, addr, vid, ENTRYTYPE_NORMAL)) { 236 + spin_unlock(&lan966x->mac_lock); 255 237 return 0; 238 + } 256 239 257 240 /* In case the entry already exists, don't add it again to SW, 258 241 * just update HW, but we need to look in the actual HW because ··· 264 241 * add the entry but without the extern_learn flag. 265 242 */ 266 243 mac_entry = lan966x_mac_find_entry(lan966x, addr, vid, port->chip_port); 267 - if (mac_entry) 268 - return lan966x_mac_learn(lan966x, port->chip_port, 269 - addr, vid, ENTRYTYPE_LOCKED); 244 + if (mac_entry) { 245 + spin_unlock(&lan966x->mac_lock); 246 + goto mac_learn; 247 + } 270 248 271 249 mac_entry = lan966x_mac_alloc_entry(addr, vid, port->chip_port); 272 - if (!mac_entry) 250 + if (!mac_entry) { 251 + spin_unlock(&lan966x->mac_lock); 273 252 return -ENOMEM; 253 + } 274 254 275 - spin_lock(&lan966x->mac_lock); 276 255 list_add_tail(&mac_entry->list, &lan966x->mac_entries); 277 256 spin_unlock(&lan966x->mac_lock); 278 257 279 - lan966x_mac_learn(lan966x, port->chip_port, addr, vid, ENTRYTYPE_LOCKED); 280 258 lan966x_fdb_call_notifiers(SWITCHDEV_FDB_OFFLOADED, addr, vid, port->dev); 259 + 260 + mac_learn: 261 + lan966x_mac_learn(lan966x, port->chip_port, addr, vid, ENTRYTYPE_LOCKED); 281 262 282 263 return 0; 283 264 } ··· 296 269 list) { 297 270 if (mac_entry->vid == vid && 298 271 ether_addr_equal(addr, mac_entry->mac)) { 299 - lan966x_mac_forget(lan966x, mac_entry->mac, mac_entry->vid, 300 - ENTRYTYPE_LOCKED); 272 + lan966x_mac_forget_locked(lan966x, mac_entry->mac, 273 + mac_entry->vid, 274 + ENTRYTYPE_LOCKED); 301 275 302 276 list_del(&mac_entry->list); 303 277 kfree(mac_entry); ··· 316 288 spin_lock(&lan966x->mac_lock); 317 289 list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, 318 290 list) { 319 - lan966x_mac_forget(lan966x, mac_entry->mac, mac_entry->vid, 320 - ENTRYTYPE_LOCKED); 291 + lan966x_mac_forget_locked(lan966x, mac_entry->mac, 292 + mac_entry->vid, ENTRYTYPE_LOCKED); 321 293 322 294 list_del(&mac_entry->list); 323 295 kfree(mac_entry); ··· 353 325 { 354 326 struct lan966x_mac_entry *mac_entry, *tmp; 355 327 unsigned char mac[ETH_ALEN] __aligned(2); 328 + struct list_head mac_deleted_entries; 356 329 u32 dest_idx; 357 330 u32 column; 358 331 u16 vid; 332 + 333 + INIT_LIST_HEAD(&mac_deleted_entries); 359 334 360 335 spin_lock(&lan966x->mac_lock); 361 336 list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, list) { ··· 393 362 } 394 363 395 364 if (!found) { 396 - /* Notify the bridge that the entry doesn't exist 397 - * anymore in the HW and remove the entry from the SW 398 - * list 399 - */ 400 - lan966x_mac_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE, 401 - mac_entry->mac, mac_entry->vid, 402 - lan966x->ports[mac_entry->port_index]->dev); 403 - 404 365 list_del(&mac_entry->list); 405 - kfree(mac_entry); 366 + /* Move the entry from SW list to a tmp list such that 367 + * it would be deleted later 368 + */ 369 + list_add_tail(&mac_entry->list, &mac_deleted_entries); 406 370 } 407 371 } 408 372 spin_unlock(&lan966x->mac_lock); 373 + 374 + list_for_each_entry_safe(mac_entry, tmp, &mac_deleted_entries, list) { 375 + /* Notify the bridge that the entry doesn't exist 376 + * anymore in the HW 377 + */ 378 + lan966x_mac_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE, 379 + mac_entry->mac, mac_entry->vid, 380 + lan966x->ports[mac_entry->port_index]->dev); 381 + list_del(&mac_entry->list); 382 + kfree(mac_entry); 383 + } 409 384 410 385 /* Now go to the list of columns and see if any entry was not in the SW 411 386 * list, then that means that the entry is new so it needs to notify the ··· 433 396 if (WARN_ON(dest_idx >= lan966x->num_phys_ports)) 434 397 continue; 435 398 399 + spin_lock(&lan966x->mac_lock); 400 + mac_entry = lan966x_mac_find_entry(lan966x, mac, vid, dest_idx); 401 + if (mac_entry) { 402 + spin_unlock(&lan966x->mac_lock); 403 + continue; 404 + } 405 + 436 406 mac_entry = lan966x_mac_alloc_entry(mac, vid, dest_idx); 437 - if (!mac_entry) 407 + if (!mac_entry) { 408 + spin_unlock(&lan966x->mac_lock); 438 409 return; 410 + } 439 411 440 412 mac_entry->row = row; 441 - 442 - spin_lock(&lan966x->mac_lock); 443 413 list_add_tail(&mac_entry->list, &lan966x->mac_entries); 444 414 spin_unlock(&lan966x->mac_lock); 445 415 ··· 468 424 lan966x, ANA_MACTINDX); 469 425 470 426 while (1) { 427 + spin_lock(&lan966x->mac_lock); 471 428 lan_rmw(ANA_MACACCESS_MAC_TABLE_CMD_SET(MACACCESS_CMD_SYNC_GET_NEXT), 472 429 ANA_MACACCESS_MAC_TABLE_CMD, 473 430 lan966x, ANA_MACACCESS); ··· 492 447 stop = false; 493 448 494 449 if (column == LAN966X_MAC_COLUMNS - 1 && 495 - index == 0 && stop) 450 + index == 0 && stop) { 451 + spin_unlock(&lan966x->mac_lock); 496 452 break; 453 + } 497 454 498 455 entry[column].mach = lan_rd(lan966x, ANA_MACHDATA); 499 456 entry[column].macl = lan_rd(lan966x, ANA_MACLDATA); 500 457 entry[column].maca = lan_rd(lan966x, ANA_MACACCESS); 458 + spin_unlock(&lan966x->mac_lock); 501 459 502 460 /* Once all the columns are read process them */ 503 461 if (column == LAN966X_MAC_COLUMNS - 1) {
+1 -1
drivers/net/ethernet/netronome/nfp/flower/action.c
··· 474 474 set_tun->ttl = ip4_dst_hoplimit(&rt->dst); 475 475 ip_rt_put(rt); 476 476 } else { 477 - set_tun->ttl = net->ipv4.sysctl_ip_default_ttl; 477 + set_tun->ttl = READ_ONCE(net->ipv4.sysctl_ip_default_ttl); 478 478 } 479 479 } 480 480
+16 -9
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
··· 297 297 *art_time = ns; 298 298 } 299 299 300 + static int stmmac_cross_ts_isr(struct stmmac_priv *priv) 301 + { 302 + return (readl(priv->ioaddr + GMAC_INT_STATUS) & GMAC_INT_TSIE); 303 + } 304 + 300 305 static int intel_crosststamp(ktime_t *device, 301 306 struct system_counterval_t *system, 302 307 void *ctx) ··· 317 312 u32 num_snapshot; 318 313 u32 gpio_value; 319 314 u32 acr_value; 320 - int ret; 321 - u32 v; 322 315 int i; 323 316 324 317 if (!boot_cpu_has(X86_FEATURE_ART)) ··· 329 326 */ 330 327 if (priv->plat->ext_snapshot_en) 331 328 return -EBUSY; 329 + 330 + priv->plat->int_snapshot_en = 1; 332 331 333 332 mutex_lock(&priv->aux_ts_lock); 334 333 /* Enable Internal snapshot trigger */ ··· 351 346 break; 352 347 default: 353 348 mutex_unlock(&priv->aux_ts_lock); 349 + priv->plat->int_snapshot_en = 0; 354 350 return -EINVAL; 355 351 } 356 352 writel(acr_value, ptpaddr + PTP_ACR); ··· 373 367 gpio_value |= GMAC_GPO1; 374 368 writel(gpio_value, ioaddr + GMAC_GPIO_STATUS); 375 369 376 - /* Poll for time sync operation done */ 377 - ret = readl_poll_timeout(priv->ioaddr + GMAC_INT_STATUS, v, 378 - (v & GMAC_INT_TSIE), 100, 10000); 379 - 380 - if (ret == -ETIMEDOUT) { 381 - pr_err("%s: Wait for time sync operation timeout\n", __func__); 382 - return ret; 370 + /* Time sync done Indication - Interrupt method */ 371 + if (!wait_event_interruptible_timeout(priv->tstamp_busy_wait, 372 + stmmac_cross_ts_isr(priv), 373 + HZ / 100)) { 374 + priv->plat->int_snapshot_en = 0; 375 + return -ETIMEDOUT; 383 376 } 384 377 385 378 num_snapshot = (readl(ioaddr + GMAC_TIMESTAMP_STATUS) & ··· 396 391 } 397 392 398 393 system->cycles *= intel_priv->crossts_adj; 394 + priv->plat->int_snapshot_en = 0; 399 395 400 396 return 0; 401 397 } ··· 612 606 613 607 plat->has_crossts = true; 614 608 plat->crosststamp = intel_crosststamp; 609 + plat->int_snapshot_en = 0; 615 610 616 611 /* Setup MSI vector offset specific to Intel mGbE controller */ 617 612 plat->msi_mac_vec = 29;
+21 -28
drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
··· 576 576 } 577 577 } 578 578 579 - ret = clk_bulk_prepare_enable(variant->num_clks, plat->clks); 580 - if (ret) { 581 - dev_err(plat->dev, "failed to enable clks, err = %d\n", ret); 582 - return ret; 583 - } 584 - 585 - ret = clk_prepare_enable(plat->rmii_internal_clk); 586 - if (ret) { 587 - dev_err(plat->dev, "failed to enable rmii internal clk, err = %d\n", ret); 588 - goto err_clk; 589 - } 590 - 591 579 return 0; 592 - 593 - err_clk: 594 - clk_bulk_disable_unprepare(variant->num_clks, plat->clks); 595 - return ret; 596 - } 597 - 598 - static void mediatek_dwmac_exit(struct platform_device *pdev, void *priv) 599 - { 600 - struct mediatek_dwmac_plat_data *plat = priv; 601 - const struct mediatek_dwmac_variant *variant = plat->variant; 602 - 603 - clk_disable_unprepare(plat->rmii_internal_clk); 604 - clk_bulk_disable_unprepare(variant->num_clks, plat->clks); 605 580 } 606 581 607 582 static int mediatek_dwmac_clks_config(void *priv, bool enabled) ··· 618 643 plat->addr64 = priv_plat->variant->dma_bit_mask; 619 644 plat->bsp_priv = priv_plat; 620 645 plat->init = mediatek_dwmac_init; 621 - plat->exit = mediatek_dwmac_exit; 622 646 plat->clks_config = mediatek_dwmac_clks_config; 623 647 if (priv_plat->variant->dwmac_fix_mac_speed) 624 648 plat->fix_mac_speed = priv_plat->variant->dwmac_fix_mac_speed; ··· 686 712 mediatek_dwmac_common_data(pdev, plat_dat, priv_plat); 687 713 mediatek_dwmac_init(pdev, priv_plat); 688 714 715 + ret = mediatek_dwmac_clks_config(priv_plat, true); 716 + if (ret) 717 + return ret; 718 + 689 719 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 690 720 if (ret) { 691 721 stmmac_remove_config_dt(pdev, plat_dat); 692 - return ret; 722 + goto err_drv_probe; 693 723 } 694 724 695 725 return 0; 726 + 727 + err_drv_probe: 728 + mediatek_dwmac_clks_config(priv_plat, false); 729 + return ret; 730 + } 731 + 732 + static int mediatek_dwmac_remove(struct platform_device *pdev) 733 + { 734 + struct mediatek_dwmac_plat_data *priv_plat = get_stmmac_bsp_priv(&pdev->dev); 735 + int ret; 736 + 737 + ret = stmmac_pltfr_remove(pdev); 738 + mediatek_dwmac_clks_config(priv_plat, false); 739 + 740 + return ret; 696 741 } 697 742 698 743 static const struct of_device_id mediatek_dwmac_match[] = { ··· 726 733 727 734 static struct platform_driver mediatek_dwmac_driver = { 728 735 .probe = mediatek_dwmac_probe, 729 - .remove = stmmac_pltfr_remove, 736 + .remove = mediatek_dwmac_remove, 730 737 .driver = { 731 738 .name = "dwmac-mediatek", 732 739 .pm = &stmmac_pltfr_pm_ops,
+2 -1
drivers/net/ethernet/stmicro/stmmac/dwmac4.h
··· 150 150 #define GMAC_PCS_IRQ_DEFAULT (GMAC_INT_RGSMIIS | GMAC_INT_PCS_LINK | \ 151 151 GMAC_INT_PCS_ANE) 152 152 153 - #define GMAC_INT_DEFAULT_ENABLE (GMAC_INT_PMT_EN | GMAC_INT_LPI_EN) 153 + #define GMAC_INT_DEFAULT_ENABLE (GMAC_INT_PMT_EN | GMAC_INT_LPI_EN | \ 154 + GMAC_INT_TSIE) 154 155 155 156 enum dwmac4_irq_status { 156 157 time_stamp_irq = 0x00001000,
+7
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
··· 23 23 static void dwmac4_core_init(struct mac_device_info *hw, 24 24 struct net_device *dev) 25 25 { 26 + struct stmmac_priv *priv = netdev_priv(dev); 26 27 void __iomem *ioaddr = hw->pcsr; 27 28 u32 value = readl(ioaddr + GMAC_CONFIG); 28 29 ··· 59 58 value |= GMAC_INT_FPE_EN; 60 59 61 60 writel(value, ioaddr + GMAC_INT_EN); 61 + 62 + if (GMAC_INT_DEFAULT_ENABLE & GMAC_INT_TSIE) 63 + init_waitqueue_head(&priv->tstamp_busy_wait); 62 64 } 63 65 64 66 static void dwmac4_rx_queue_enable(struct mac_device_info *hw, ··· 223 219 if (queue == 0 || queue == 4) { 224 220 value &= ~MTL_RXQ_DMA_Q04MDMACH_MASK; 225 221 value |= MTL_RXQ_DMA_Q04MDMACH(chan); 222 + } else if (queue > 4) { 223 + value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4); 224 + value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4); 226 225 } else { 227 226 value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue); 228 227 value |= MTL_RXQ_DMA_QXMDMACH(chan, queue);
+1
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 266 266 rwlock_t ptp_lock; 267 267 /* Protects auxiliary snapshot registers from concurrent access. */ 268 268 struct mutex aux_ts_lock; 269 + wait_queue_head_t tstamp_busy_wait; 269 270 270 271 void __iomem *mmcaddr; 271 272 void __iomem *ptpaddr;
-8
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
··· 803 803 netdev_warn(priv->dev, 804 804 "Setting EEE tx-lpi is not supported\n"); 805 805 806 - if (priv->hw->xpcs) { 807 - ret = xpcs_config_eee(priv->hw->xpcs, 808 - priv->plat->mult_fact_100ns, 809 - edata->eee_enabled); 810 - if (ret) 811 - return ret; 812 - } 813 - 814 806 if (!edata->eee_enabled) 815 807 stmmac_disable_eee_mode(priv); 816 808
+5
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
··· 179 179 u64 ptp_time; 180 180 int i; 181 181 182 + if (priv->plat->int_snapshot_en) { 183 + wake_up(&priv->tstamp_busy_wait); 184 + return; 185 + } 186 + 182 187 tsync_int = readl(priv->ioaddr + GMAC_INT_STATUS) & GMAC_INT_TSIE; 183 188 184 189 if (!tsync_int)
+11 -11
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 834 834 struct timespec64 now; 835 835 u32 sec_inc = 0; 836 836 u64 temp = 0; 837 - int ret; 838 837 839 838 if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) 840 839 return -EOPNOTSUPP; 841 - 842 - ret = clk_prepare_enable(priv->plat->clk_ptp_ref); 843 - if (ret < 0) { 844 - netdev_warn(priv->dev, 845 - "failed to enable PTP reference clock: %pe\n", 846 - ERR_PTR(ret)); 847 - return ret; 848 - } 849 840 850 841 stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags); 851 842 priv->systime_flags = systime_flags; ··· 3262 3271 stmmac_dma_operation_mode(priv); 3263 3272 3264 3273 stmmac_mmc_setup(priv); 3274 + 3275 + if (ptp_register) { 3276 + ret = clk_prepare_enable(priv->plat->clk_ptp_ref); 3277 + if (ret < 0) 3278 + netdev_warn(priv->dev, 3279 + "failed to enable PTP reference clock: %pe\n", 3280 + ERR_PTR(ret)); 3281 + } 3265 3282 3266 3283 ret = stmmac_init_ptp(priv); 3267 3284 if (ret == -EOPNOTSUPP) ··· 7214 7215 netdev_info(priv->dev, "%s: removing driver", __func__); 7215 7216 7216 7217 pm_runtime_get_sync(dev); 7217 - pm_runtime_disable(dev); 7218 - pm_runtime_put_noidle(dev); 7219 7218 7220 7219 stmmac_stop_all_dma(priv); 7221 7220 stmmac_mac_set(priv, priv->ioaddr, false); ··· 7239 7242 destroy_workqueue(priv->wq); 7240 7243 mutex_destroy(&priv->lock); 7241 7244 bitmap_free(priv->af_xdp_zc_qps); 7245 + 7246 + pm_runtime_disable(dev); 7247 + pm_runtime_put_noidle(dev); 7242 7248 7243 7249 return 0; 7244 7250 }
+7 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 815 815 if (ret) 816 816 return ret; 817 817 818 - stmmac_init_tstamp_counter(priv, priv->systime_flags); 818 + ret = clk_prepare_enable(priv->plat->clk_ptp_ref); 819 + if (ret < 0) { 820 + netdev_warn(priv->dev, 821 + "failed to enable PTP reference clock: %pe\n", 822 + ERR_PTR(ret)); 823 + return ret; 824 + } 819 825 } 820 826 821 827 return 0;
+1 -11
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
··· 175 175 struct stmmac_priv *priv = 176 176 container_of(ptp, struct stmmac_priv, ptp_clock_ops); 177 177 void __iomem *ptpaddr = priv->ptpaddr; 178 - void __iomem *ioaddr = priv->hw->pcsr; 179 178 struct stmmac_pps_cfg *cfg; 180 - u32 intr_value, acr_value; 181 179 int ret = -EOPNOTSUPP; 182 180 unsigned long flags; 181 + u32 acr_value; 183 182 184 183 switch (rq->type) { 185 184 case PTP_CLK_REQ_PEROUT: ··· 212 213 netdev_dbg(priv->dev, "Auxiliary Snapshot %d enabled.\n", 213 214 priv->plat->ext_snapshot_num >> 214 215 PTP_ACR_ATSEN_SHIFT); 215 - /* Enable Timestamp Interrupt */ 216 - intr_value = readl(ioaddr + GMAC_INT_EN); 217 - intr_value |= GMAC_INT_TSIE; 218 - writel(intr_value, ioaddr + GMAC_INT_EN); 219 - 220 216 } else { 221 217 netdev_dbg(priv->dev, "Auxiliary Snapshot %d disabled.\n", 222 218 priv->plat->ext_snapshot_num >> 223 219 PTP_ACR_ATSEN_SHIFT); 224 - /* Disable Timestamp Interrupt */ 225 - intr_value = readl(ioaddr + GMAC_INT_EN); 226 - intr_value &= ~GMAC_INT_TSIE; 227 - writel(intr_value, ioaddr + GMAC_INT_EN); 228 220 } 229 221 writel(acr_value, ptpaddr + PTP_ACR); 230 222 mutex_unlock(&priv->aux_ts_lock);
+14 -2
drivers/net/usb/r8152.c
··· 32 32 #define NETNEXT_VERSION "12" 33 33 34 34 /* Information for net */ 35 - #define NET_VERSION "12" 35 + #define NET_VERSION "13" 36 36 37 37 #define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION 38 38 #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>" ··· 5917 5917 5918 5918 wait_oob_link_list_ready(tp); 5919 5919 5920 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); 5920 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, 1522); 5921 + ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_DEFAULT); 5921 5922 5922 5923 switch (tp->version) { 5923 5924 case RTL_VER_03: ··· 5953 5952 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 5954 5953 ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB; 5955 5954 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); 5955 + 5956 + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); 5957 + ocp_data |= MCU_BORW_EN; 5958 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); 5956 5959 5957 5960 rxdy_gated_en(tp, false); 5958 5961 ··· 6560 6555 rtl_disable(tp); 6561 6556 rtl_reset_bmu(tp); 6562 6557 6558 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, 1522); 6559 + ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_DEFAULT); 6560 + 6563 6561 /* Clear teredo wake event. bit[15:8] is the teredo wakeup 6564 6562 * type. Set it to zero. bits[7:0] are the W1C bits about 6565 6563 * the events. Set them to all 1 to clear them. ··· 6572 6564 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 6573 6565 ocp_data |= NOW_IS_OOB; 6574 6566 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); 6567 + 6568 + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); 6569 + ocp_data |= MCU_BORW_EN; 6570 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); 6575 6571 6576 6572 rtl_rx_vlan_en(tp, true); 6577 6573 rxdy_gated_en(tp, false);
+3 -3
drivers/nvme/host/core.c
··· 3786 3786 } 3787 3787 3788 3788 static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, 3789 - unsigned nsid, struct nvme_ns_ids *ids) 3789 + unsigned nsid, struct nvme_ns_ids *ids, bool is_shared) 3790 3790 { 3791 3791 struct nvme_ns_head *head; 3792 3792 size_t size = sizeof(*head); ··· 3810 3810 head->subsys = ctrl->subsys; 3811 3811 head->ns_id = nsid; 3812 3812 head->ids = *ids; 3813 + head->shared = is_shared; 3813 3814 kref_init(&head->ref); 3814 3815 3815 3816 if (head->ids.csi) { ··· 3892 3891 nsid); 3893 3892 goto out_unlock; 3894 3893 } 3895 - head = nvme_alloc_ns_head(ctrl, nsid, ids); 3894 + head = nvme_alloc_ns_head(ctrl, nsid, ids, is_shared); 3896 3895 if (IS_ERR(head)) { 3897 3896 ret = PTR_ERR(head); 3898 3897 goto out_unlock; 3899 3898 } 3900 - head->shared = is_shared; 3901 3899 } else { 3902 3900 ret = -EINVAL; 3903 3901 if (!is_shared || !head->shared) {
+7 -2
drivers/nvme/host/pci.c
··· 2690 2690 struct pci_dev *pdev = to_pci_dev(dev->dev); 2691 2691 2692 2692 mutex_lock(&dev->shutdown_lock); 2693 - if (pci_device_is_present(pdev) && pci_is_enabled(pdev)) { 2694 - u32 csts = readl(dev->bar + NVME_REG_CSTS); 2693 + if (pci_is_enabled(pdev)) { 2694 + u32 csts; 2695 + 2696 + if (pci_device_is_present(pdev)) 2697 + csts = readl(dev->bar + NVME_REG_CSTS); 2698 + else 2699 + csts = ~0; 2695 2700 2696 2701 if (dev->ctrl.state == NVME_CTRL_LIVE || 2697 2702 dev->ctrl.state == NVME_CTRL_RESETTING) {
+12 -2
drivers/platform/x86/amd-pmc.c
··· 91 91 #define AMD_CPU_ID_PCO AMD_CPU_ID_RV 92 92 #define AMD_CPU_ID_CZN AMD_CPU_ID_RN 93 93 #define AMD_CPU_ID_YC 0x14B5 94 + #define AMD_CPU_ID_CB 0x14D8 95 + #define AMD_CPU_ID_PS 0x14E8 94 96 95 97 #define PMC_MSG_DELAY_MIN_US 50 96 98 #define RESPONSE_REGISTER_LOOP_MAX 20000 ··· 320 318 val = amd_pmc_reg_read(pdev, AMD_PMC_SCRATCH_REG_CZN); 321 319 break; 322 320 case AMD_CPU_ID_YC: 321 + case AMD_CPU_ID_CB: 322 + case AMD_CPU_ID_PS: 323 323 val = amd_pmc_reg_read(pdev, AMD_PMC_SCRATCH_REG_YC); 324 324 break; 325 325 default: ··· 495 491 &amd_pmc_idlemask_fops); 496 492 /* Enable STB only when the module_param is set */ 497 493 if (enable_stb) { 498 - if (dev->cpu_id == AMD_CPU_ID_YC) 494 + if (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB || 495 + dev->cpu_id == AMD_CPU_ID_PS) 499 496 debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev, 500 497 &amd_pmc_stb_debugfs_fops_v2); 501 498 else ··· 620 615 return MSG_OS_HINT_PCO; 621 616 case AMD_CPU_ID_RN: 622 617 case AMD_CPU_ID_YC: 618 + case AMD_CPU_ID_CB: 619 + case AMD_CPU_ID_PS: 623 620 return MSG_OS_HINT_RN; 624 621 } 625 622 return -EINVAL; ··· 742 735 #endif 743 736 744 737 static const struct pci_device_id pmc_pci_ids[] = { 738 + { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) }, 739 + { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_CB) }, 745 740 { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_YC) }, 746 741 { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_CZN) }, 747 742 { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_RN) }, ··· 886 877 887 878 mutex_init(&dev->lock); 888 879 889 - if (enable_stb && dev->cpu_id == AMD_CPU_ID_YC) { 880 + if (enable_stb && (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB)) { 890 881 err = amd_pmc_s2d_init(dev); 891 882 if (err) 892 883 return err; ··· 924 915 {"AMDI0005", 0}, 925 916 {"AMDI0006", 0}, 926 917 {"AMDI0007", 0}, 918 + {"AMDI0008", 0}, 927 919 {"AMD0004", 0}, 928 920 {"AMD0005", 0}, 929 921 { }
+2
drivers/platform/x86/asus-nb-wmi.c
··· 522 522 { KE_KEY, 0x31, { KEY_VOLUMEDOWN } }, 523 523 { KE_KEY, 0x32, { KEY_MUTE } }, 524 524 { KE_KEY, 0x35, { KEY_SCREENLOCK } }, 525 + { KE_KEY, 0x38, { KEY_PROG3 } }, /* Armoury Crate */ 525 526 { KE_KEY, 0x40, { KEY_PREVIOUSSONG } }, 526 527 { KE_KEY, 0x41, { KEY_NEXTSONG } }, 527 528 { KE_KEY, 0x43, { KEY_STOPCD } }, /* Stop/Eject */ ··· 575 574 { KE_KEY, 0xA5, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + TV + HDMI */ 576 575 { KE_KEY, 0xA6, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + TV + HDMI */ 577 576 { KE_KEY, 0xA7, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV + HDMI */ 577 + { KE_KEY, 0xB3, { KEY_PROG4 } }, /* AURA */ 578 578 { KE_KEY, 0xB5, { KEY_CALC } }, 579 579 { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, 580 580 { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } },
+1
drivers/platform/x86/gigabyte-wmi.c
··· 150 150 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M AORUS PRO-P"), 151 151 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M DS3H"), 152 152 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B660 GAMING X DDR4"), 153 + DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B660I AORUS PRO DDR4"), 153 154 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("Z390 I AORUS PRO WIFI-CF"), 154 155 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("Z490 AORUS ELITE AC"), 155 156 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 AORUS ELITE"),
+2 -1
drivers/platform/x86/intel/atomisp2/led.c
··· 50 50 { 51 51 .matches = { 52 52 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 53 - DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"), 53 + /* Non exact match to also match T100TAF */ 54 + DMI_MATCH(DMI_PRODUCT_NAME, "T100TA"), 54 55 }, 55 56 .driver_data = &asus_t100ta_lookup, 56 57 },
+3
drivers/platform/x86/intel/ifs/Kconfig
··· 1 1 config INTEL_IFS 2 2 tristate "Intel In Field Scan" 3 3 depends on X86 && CPU_SUP_INTEL && 64BIT && SMP 4 + # Discussion on the list has shown that the sysfs API needs a bit 5 + # more work, mark this as broken for now 6 + depends on BROKEN 4 7 select INTEL_IFS_DEVICE 5 8 help 6 9 Enable support for the In Field Scan capability in select
+13 -4
drivers/platform/x86/x86-android-tablets.c
··· 27 27 #include <linux/pinctrl/machine.h> 28 28 #include <linux/platform_data/lp855x.h> 29 29 #include <linux/platform_device.h> 30 - #include <linux/pm.h> 31 30 #include <linux/power/bq24190_charger.h> 31 + #include <linux/reboot.h> 32 32 #include <linux/rmi.h> 33 33 #include <linux/serdev.h> 34 34 #include <linux/spi/spi.h> ··· 889 889 "INT33FC:02", "pmu_clk2_grp", "pmu_clk"); 890 890 891 891 static struct pinctrl *lenovo_yoga_tab2_830_1050_codec_pinctrl; 892 + static struct sys_off_handler *lenovo_yoga_tab2_830_1050_sys_off_handler; 892 893 893 894 static int __init lenovo_yoga_tab2_830_1050_init_codec(void) 894 895 { ··· 934 933 * followed by a normal 3 second press to recover. Avoid this by doing an EFI 935 934 * poweroff instead. 936 935 */ 937 - static void lenovo_yoga_tab2_830_1050_power_off(void) 936 + static int lenovo_yoga_tab2_830_1050_power_off(struct sys_off_data *data) 938 937 { 939 938 efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); 939 + 940 + return NOTIFY_DONE; 940 941 } 941 942 942 943 static int __init lenovo_yoga_tab2_830_1050_init(void) ··· 953 950 if (ret) 954 951 return ret; 955 952 956 - pm_power_off = lenovo_yoga_tab2_830_1050_power_off; 953 + /* SYS_OFF_PRIO_FIRMWARE + 1 so that it runs before acpi_power_off */ 954 + lenovo_yoga_tab2_830_1050_sys_off_handler = 955 + register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_FIRMWARE + 1, 956 + lenovo_yoga_tab2_830_1050_power_off, NULL); 957 + if (IS_ERR(lenovo_yoga_tab2_830_1050_sys_off_handler)) 958 + return PTR_ERR(lenovo_yoga_tab2_830_1050_sys_off_handler); 959 + 957 960 return 0; 958 961 } 959 962 960 963 static void lenovo_yoga_tab2_830_1050_exit(void) 961 964 { 962 - pm_power_off = NULL; /* Just turn poweroff into halt on module unload */ 965 + unregister_sys_off_handler(lenovo_yoga_tab2_830_1050_sys_off_handler); 963 966 964 967 if (lenovo_yoga_tab2_830_1050_codec_pinctrl) { 965 968 pinctrl_put(lenovo_yoga_tab2_830_1050_codec_pinctrl);
+1
drivers/power/reset/arm-versatile-reboot.c
··· 146 146 versatile_reboot_type = (enum versatile_reboot)reboot_id->data; 147 147 148 148 syscon_regmap = syscon_node_to_regmap(np); 149 + of_node_put(np); 149 150 if (IS_ERR(syscon_regmap)) 150 151 return PTR_ERR(syscon_regmap); 151 152
+8 -1
drivers/power/supply/ab8500_fg.c
··· 3148 3148 ret = ab8500_fg_init_hw_registers(di); 3149 3149 if (ret) { 3150 3150 dev_err(dev, "failed to initialize registers\n"); 3151 + destroy_workqueue(di->fg_wq); 3151 3152 return ret; 3152 3153 } 3153 3154 ··· 3160 3159 di->fg_psy = devm_power_supply_register(dev, &ab8500_fg_desc, &psy_cfg); 3161 3160 if (IS_ERR(di->fg_psy)) { 3162 3161 dev_err(dev, "failed to register FG psy\n"); 3162 + destroy_workqueue(di->fg_wq); 3163 3163 return PTR_ERR(di->fg_psy); 3164 3164 } 3165 3165 ··· 3176 3174 /* Register primary interrupt handlers */ 3177 3175 for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq); i++) { 3178 3176 irq = platform_get_irq_byname(pdev, ab8500_fg_irq[i].name); 3179 - if (irq < 0) 3177 + if (irq < 0) { 3178 + destroy_workqueue(di->fg_wq); 3180 3179 return irq; 3180 + } 3181 3181 3182 3182 ret = devm_request_threaded_irq(dev, irq, NULL, 3183 3183 ab8500_fg_irq[i].isr, ··· 3189 3185 if (ret != 0) { 3190 3186 dev_err(dev, "failed to request %s IRQ %d: %d\n", 3191 3187 ab8500_fg_irq[i].name, irq, ret); 3188 + destroy_workqueue(di->fg_wq); 3192 3189 return ret; 3193 3190 } 3194 3191 dev_dbg(dev, "Requested %s IRQ %d: %d\n", ··· 3205 3200 ret = ab8500_fg_sysfs_init(di); 3206 3201 if (ret) { 3207 3202 dev_err(dev, "failed to create sysfs entry\n"); 3203 + destroy_workqueue(di->fg_wq); 3208 3204 return ret; 3209 3205 } 3210 3206 ··· 3213 3207 if (ret) { 3214 3208 dev_err(dev, "failed to create FG psy\n"); 3215 3209 ab8500_fg_sysfs_exit(di); 3210 + destroy_workqueue(di->fg_wq); 3216 3211 return ret; 3217 3212 } 3218 3213
+12 -12
drivers/power/supply/power_supply_core.c
··· 846 846 { 847 847 int i, high, low; 848 848 849 - /* Break loop at table_len - 1 because that is the highest index */ 850 - for (i = 0; i < table_len - 1; i++) 849 + for (i = 0; i < table_len; i++) 851 850 if (temp > table[i].temp) 852 851 break; 853 852 854 853 /* The library function will deal with high == low */ 855 - if ((i == 0) || (i == (table_len - 1))) 856 - high = i; 854 + if (i == 0) 855 + high = low = i; 856 + else if (i == table_len) 857 + high = low = i - 1; 857 858 else 858 - high = i - 1; 859 - low = i; 859 + high = (low = i) - 1; 860 860 861 861 return fixp_linear_interpolate(table[low].temp, 862 862 table[low].resistance, ··· 958 958 { 959 959 int i, high, low; 960 960 961 - /* Break loop at table_len - 1 because that is the highest index */ 962 - for (i = 0; i < table_len - 1; i++) 961 + for (i = 0; i < table_len; i++) 963 962 if (ocv > table[i].ocv) 964 963 break; 965 964 966 965 /* The library function will deal with high == low */ 967 - if ((i == 0) || (i == (table_len - 1))) 968 - high = i - 1; 966 + if (i == 0) 967 + high = low = i; 968 + else if (i == table_len) 969 + high = low = i - 1; 969 970 else 970 - high = i; /* i.e. i == 0 */ 971 - low = i; 971 + high = (low = i) - 1; 972 972 973 973 return fixp_linear_interpolate(table[low].ocv, 974 974 table[low].capacity,
+1 -1
drivers/s390/crypto/ap_bus.c
··· 1435 1435 if (ap_drv->in_use) { 1436 1436 rc = ap_drv->in_use(ap_perms.apm, newaqm); 1437 1437 if (rc) 1438 - return -EBUSY; 1438 + rc = -EBUSY; 1439 1439 } 1440 1440 1441 1441 /* release the driver's module */
+3
drivers/scsi/megaraid/megaraid_sas_base.c
··· 3195 3195 qoff += map->nr_queues; 3196 3196 offset += map->nr_queues; 3197 3197 3198 + /* we never use READ queue, so can't cheat blk-mq */ 3199 + shost->tag_set.map[HCTX_TYPE_READ].nr_queues = 0; 3200 + 3198 3201 /* Setup Poll hctx */ 3199 3202 map = &shost->tag_set.map[HCTX_TYPE_POLL]; 3200 3203 map->nr_queues = instance->iopoll_q_count;
+3 -16
drivers/scsi/pm8001/pm8001_hwi.c
··· 3145 3145 if (!phy->phy_attached) 3146 3146 return; 3147 3147 3148 - if (sas_phy->phy) { 3149 - struct sas_phy *sphy = sas_phy->phy; 3150 - sphy->negotiated_linkrate = sas_phy->linkrate; 3151 - sphy->minimum_linkrate = phy->minimum_linkrate; 3152 - sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; 3153 - sphy->maximum_linkrate = phy->maximum_linkrate; 3154 - sphy->maximum_linkrate_hw = phy->maximum_linkrate; 3155 - } 3156 - 3157 3148 if (phy->phy_type & PORT_TYPE_SAS) { 3158 3149 struct sas_identify_frame *id; 3159 3150 id = (struct sas_identify_frame *)phy->frame_rcvd; ··· 3168 3177 switch (link_rate) { 3169 3178 case PHY_SPEED_120: 3170 3179 phy->sas_phy.linkrate = SAS_LINK_RATE_12_0_GBPS; 3171 - phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_12_0_GBPS; 3172 3180 break; 3173 3181 case PHY_SPEED_60: 3174 3182 phy->sas_phy.linkrate = SAS_LINK_RATE_6_0_GBPS; 3175 - phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_6_0_GBPS; 3176 3183 break; 3177 3184 case PHY_SPEED_30: 3178 3185 phy->sas_phy.linkrate = SAS_LINK_RATE_3_0_GBPS; 3179 - phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS; 3180 3186 break; 3181 3187 case PHY_SPEED_15: 3182 3188 phy->sas_phy.linkrate = SAS_LINK_RATE_1_5_GBPS; 3183 - phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS; 3184 3189 break; 3185 3190 } 3186 3191 sas_phy->negotiated_linkrate = phy->sas_phy.linkrate; 3187 - sas_phy->maximum_linkrate_hw = SAS_LINK_RATE_6_0_GBPS; 3192 + sas_phy->maximum_linkrate_hw = phy->maximum_linkrate; 3188 3193 sas_phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; 3189 - sas_phy->maximum_linkrate = SAS_LINK_RATE_6_0_GBPS; 3190 - sas_phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS; 3194 + sas_phy->maximum_linkrate = phy->maximum_linkrate; 3195 + sas_phy->minimum_linkrate = phy->minimum_linkrate; 3191 3196 } 3192 3197 3193 3198 /**
+2
drivers/scsi/pm8001/pm8001_init.c
··· 143 143 struct asd_sas_phy *sas_phy = &phy->sas_phy; 144 144 phy->phy_state = PHY_LINK_DISABLE; 145 145 phy->pm8001_ha = pm8001_ha; 146 + phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS; 147 + phy->maximum_linkrate = SAS_LINK_RATE_6_0_GBPS; 146 148 sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0; 147 149 sas_phy->class = SAS; 148 150 sas_phy->iproto = SAS_PROTOCOL_ALL;
+5 -1
drivers/scsi/pm8001/pm80xx_hwi.c
··· 3723 3723 pm8001_dbg(pm8001_ha, MSG, "phy:0x%x status:0x%x\n", 3724 3724 phyid, status); 3725 3725 if (status == PHY_STOP_SUCCESS || 3726 - status == PHY_STOP_ERR_DEVICE_ATTACHED) 3726 + status == PHY_STOP_ERR_DEVICE_ATTACHED) { 3727 3727 phy->phy_state = PHY_LINK_DISABLE; 3728 + phy->sas_phy.phy->negotiated_linkrate = SAS_PHY_DISABLED; 3729 + phy->sas_phy.linkrate = SAS_PHY_DISABLED; 3730 + } 3731 + 3728 3732 return 0; 3729 3733 } 3730 3734
+8
drivers/spi/spi-amd.c
··· 33 33 #define AMD_SPI_RX_COUNT_REG 0x4B 34 34 #define AMD_SPI_STATUS_REG 0x4C 35 35 36 + #define AMD_SPI_FIFO_SIZE 70 36 37 #define AMD_SPI_MEM_SIZE 200 37 38 38 39 /* M_CMD OP codes for SPI */ ··· 271 270 return 0; 272 271 } 273 272 273 + static size_t amd_spi_max_transfer_size(struct spi_device *spi) 274 + { 275 + return AMD_SPI_FIFO_SIZE; 276 + } 277 + 274 278 static int amd_spi_probe(struct platform_device *pdev) 275 279 { 276 280 struct device *dev = &pdev->dev; ··· 308 302 master->flags = SPI_MASTER_HALF_DUPLEX; 309 303 master->setup = amd_spi_master_setup; 310 304 master->transfer_one_message = amd_spi_master_transfer; 305 + master->max_transfer_size = amd_spi_max_transfer_size; 306 + master->max_message_size = amd_spi_max_transfer_size; 311 307 312 308 /* Register the controller with SPI framework */ 313 309 err = devm_spi_register_master(dev, master);
+11 -1
drivers/spi/spi-aspeed-smc.c
··· 558 558 u32 ctl_val; 559 559 int ret = 0; 560 560 561 + dev_dbg(aspi->dev, 562 + "CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n", 563 + chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write", 564 + desc->info.offset, desc->info.offset + desc->info.length, 565 + op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth, 566 + op->dummy.buswidth, op->data.buswidth, 567 + op->addr.nbytes, op->dummy.nbytes); 568 + 561 569 chip->clk_freq = desc->mem->spi->max_speed_hz; 562 570 563 571 /* Only for reads */ ··· 582 574 ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK; 583 575 ctl_val |= aspeed_spi_get_io_mode(op) | 584 576 op->cmd.opcode << CTRL_COMMAND_SHIFT | 585 - CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) | 586 577 CTRL_IO_MODE_READ; 578 + 579 + if (op->dummy.nbytes) 580 + ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth); 587 581 588 582 /* Tune 4BYTE address mode */ 589 583 if (op->addr.nbytes) {
+7 -12
drivers/spi/spi-cadence-quadspi.c
··· 1578 1578 ret = cqspi_of_get_pdata(cqspi); 1579 1579 if (ret) { 1580 1580 dev_err(dev, "Cannot get mandatory OF data.\n"); 1581 - ret = -ENODEV; 1582 - goto probe_master_put; 1581 + return -ENODEV; 1583 1582 } 1584 1583 1585 1584 /* Obtain QSPI clock. */ ··· 1586 1587 if (IS_ERR(cqspi->clk)) { 1587 1588 dev_err(dev, "Cannot claim QSPI clock.\n"); 1588 1589 ret = PTR_ERR(cqspi->clk); 1589 - goto probe_master_put; 1590 + return ret; 1590 1591 } 1591 1592 1592 1593 /* Obtain and remap controller address. */ ··· 1595 1596 if (IS_ERR(cqspi->iobase)) { 1596 1597 dev_err(dev, "Cannot remap controller address.\n"); 1597 1598 ret = PTR_ERR(cqspi->iobase); 1598 - goto probe_master_put; 1599 + return ret; 1599 1600 } 1600 1601 1601 1602 /* Obtain and remap AHB address. */ ··· 1604 1605 if (IS_ERR(cqspi->ahb_base)) { 1605 1606 dev_err(dev, "Cannot remap AHB address.\n"); 1606 1607 ret = PTR_ERR(cqspi->ahb_base); 1607 - goto probe_master_put; 1608 + return ret; 1608 1609 } 1609 1610 cqspi->mmap_phys_base = (dma_addr_t)res_ahb->start; 1610 1611 cqspi->ahb_size = resource_size(res_ahb); ··· 1613 1614 1614 1615 /* Obtain IRQ line. */ 1615 1616 irq = platform_get_irq(pdev, 0); 1616 - if (irq < 0) { 1617 - ret = -ENXIO; 1618 - goto probe_master_put; 1619 - } 1617 + if (irq < 0) 1618 + return -ENXIO; 1620 1619 1621 1620 pm_runtime_enable(dev); 1622 1621 ret = pm_runtime_resume_and_get(dev); 1623 1622 if (ret < 0) 1624 - goto probe_master_put; 1623 + return ret; 1625 1624 1626 1625 ret = clk_prepare_enable(cqspi->clk); 1627 1626 if (ret) { ··· 1713 1716 probe_clk_failed: 1714 1717 pm_runtime_put_sync(dev); 1715 1718 pm_runtime_disable(dev); 1716 - probe_master_put: 1717 - spi_master_put(master); 1718 1719 return ret; 1719 1720 } 1720 1721
+3
drivers/target/target_core_file.c
··· 448 448 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 449 449 } 450 450 451 + if (!cmd->t_data_nents) 452 + return TCM_INVALID_CDB_FIELD; 453 + 451 454 if (cmd->t_data_nents > 1 || 452 455 cmd->t_data_sg[0].length != cmd->se_dev->dev_attrib.block_size) { 453 456 pr_err("WRITE_SAME: Illegal SGL t_data_nents: %u length: %u"
+4
drivers/target/target_core_iblock.c
··· 494 494 " backends not supported\n"); 495 495 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 496 496 } 497 + 498 + if (!cmd->t_data_nents) 499 + return TCM_INVALID_CDB_FIELD; 500 + 497 501 sg = &cmd->t_data_sg[0]; 498 502 499 503 if (cmd->t_data_nents > 1 ||
+6
drivers/target/target_core_sbc.c
··· 312 312 pr_warn("WRITE SAME with ANCHOR not supported\n"); 313 313 return TCM_INVALID_CDB_FIELD; 314 314 } 315 + 316 + if (flags & 0x01) { 317 + pr_warn("WRITE SAME with NDOB not supported\n"); 318 + return TCM_INVALID_CDB_FIELD; 319 + } 320 + 315 321 /* 316 322 * Special case for WRITE_SAME w/ UNMAP=1 that ends up getting 317 323 * translated into block discard requests within backend code.
+1 -1
drivers/tee/optee/optee_smc.h
··· 189 189 * Have config return register usage: 190 190 * a0 OPTEE_SMC_RETURN_OK 191 191 * a1 Physical address of start of SHM 192 - * a2 Size of of SHM 192 + * a2 Size of SHM 193 193 * a3 Cache settings of memory, as defined by the 194 194 * OPTEE_SMC_SHM_* values above 195 195 * a4-7 Preserved
+2 -2
drivers/tee/optee/smc_abi.c
··· 884 884 885 885 rpc_arg_offs = OPTEE_MSG_GET_ARG_SIZE(arg->num_params); 886 886 rpc_arg = tee_shm_get_va(shm, offs + rpc_arg_offs); 887 - if (IS_ERR(arg)) 888 - return PTR_ERR(arg); 887 + if (IS_ERR(rpc_arg)) 888 + return PTR_ERR(rpc_arg); 889 889 } 890 890 891 891 if (rpc_arg && tee_shm_is_dynamic(shm)) {
+1 -1
drivers/tee/tee_core.c
··· 1073 1073 /** 1074 1074 * tee_get_drvdata() - Return driver_data pointer 1075 1075 * @teedev: Device containing the driver_data pointer 1076 - * @returns the driver_data pointer supplied to tee_register(). 1076 + * @returns the driver_data pointer supplied to tee_device_alloc(). 1077 1077 */ 1078 1078 void *tee_get_drvdata(struct tee_device *teedev) 1079 1079 {
+2 -12
drivers/tty/pty.c
··· 111 111 static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) 112 112 { 113 113 struct tty_struct *to = tty->link; 114 - unsigned long flags; 115 114 116 - if (tty->flow.stopped) 115 + if (tty->flow.stopped || !c) 117 116 return 0; 118 117 119 - if (c > 0) { 120 - spin_lock_irqsave(&to->port->lock, flags); 121 - /* Stuff the data into the input queue of the other end */ 122 - c = tty_insert_flip_string(to->port, buf, c); 123 - spin_unlock_irqrestore(&to->port->lock, flags); 124 - /* And shovel */ 125 - if (c) 126 - tty_flip_buffer_push(to->port); 127 - } 128 - return c; 118 + return tty_insert_flip_string_and_push_buffer(to->port, buf, c); 129 119 } 130 120 131 121 /**
+4
drivers/tty/serial/8250/8250_core.c
··· 23 23 #include <linux/sysrq.h> 24 24 #include <linux/delay.h> 25 25 #include <linux/platform_device.h> 26 + #include <linux/pm_runtime.h> 26 27 #include <linux/tty.h> 27 28 #include <linux/ratelimit.h> 28 29 #include <linux/tty_flip.h> ··· 559 558 continue; 560 559 561 560 up->port.dev = dev; 561 + 562 + if (uart_console_enabled(&up->port)) 563 + pm_runtime_get_sync(up->port.dev); 562 564 563 565 serial8250_apply_quirks(up); 564 566 uart_add_one_port(drv, &up->port);
+3 -3
drivers/tty/serial/8250/8250_dma.c
··· 106 106 UART_XMIT_SIZE, DMA_TO_DEVICE); 107 107 108 108 dma_async_issue_pending(dma->txchan); 109 - if (dma->tx_err) { 109 + serial8250_clear_THRI(p); 110 + if (dma->tx_err) 110 111 dma->tx_err = 0; 111 - serial8250_clear_THRI(p); 112 - } 112 + 113 113 return 0; 114 114 err: 115 115 dma->tx_err = 1;
+13 -13
drivers/tty/serial/8250/8250_dw.c
··· 47 47 #define RZN1_UART_xDMACR_DMA_EN BIT(0) 48 48 #define RZN1_UART_xDMACR_1_WORD_BURST (0 << 1) 49 49 #define RZN1_UART_xDMACR_4_WORD_BURST (1 << 1) 50 - #define RZN1_UART_xDMACR_8_WORD_BURST (3 << 1) 50 + #define RZN1_UART_xDMACR_8_WORD_BURST (2 << 1) 51 51 #define RZN1_UART_xDMACR_BLK_SZ(x) ((x) << 3) 52 52 53 53 /* Quirks */ ··· 773 773 MODULE_DEVICE_TABLE(of, dw8250_of_match); 774 774 775 775 static const struct acpi_device_id dw8250_acpi_match[] = { 776 - { "INT33C4", 0 }, 777 - { "INT33C5", 0 }, 778 - { "INT3434", 0 }, 779 - { "INT3435", 0 }, 780 - { "80860F0A", 0 }, 781 - { "8086228A", 0 }, 782 - { "APMC0D08", 0}, 783 - { "AMD0020", 0 }, 784 - { "AMDI0020", 0 }, 785 - { "AMDI0022", 0 }, 786 - { "BRCM2032", 0 }, 787 - { "HISI0031", 0 }, 776 + { "80860F0A", (kernel_ulong_t)&dw8250_dw_apb }, 777 + { "8086228A", (kernel_ulong_t)&dw8250_dw_apb }, 778 + { "AMD0020", (kernel_ulong_t)&dw8250_dw_apb }, 779 + { "AMDI0020", (kernel_ulong_t)&dw8250_dw_apb }, 780 + { "AMDI0022", (kernel_ulong_t)&dw8250_dw_apb }, 781 + { "APMC0D08", (kernel_ulong_t)&dw8250_dw_apb}, 782 + { "BRCM2032", (kernel_ulong_t)&dw8250_dw_apb }, 783 + { "HISI0031", (kernel_ulong_t)&dw8250_dw_apb }, 784 + { "INT33C4", (kernel_ulong_t)&dw8250_dw_apb }, 785 + { "INT33C5", (kernel_ulong_t)&dw8250_dw_apb }, 786 + { "INT3434", (kernel_ulong_t)&dw8250_dw_apb }, 787 + { "INT3435", (kernel_ulong_t)&dw8250_dw_apb }, 788 788 { }, 789 789 }; 790 790 MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);
+4 -2
drivers/tty/serial/8250/8250_port.c
··· 1949 1949 if ((status & UART_LSR_THRE) && (up->ier & UART_IER_THRI)) { 1950 1950 if (!up->dma || up->dma->tx_err) 1951 1951 serial8250_tx_chars(up); 1952 - else 1952 + else if (!up->dma->tx_running) 1953 1953 __stop_tx(up); 1954 1954 } 1955 1955 ··· 2975 2975 case UPIO_MEM32BE: 2976 2976 case UPIO_MEM16: 2977 2977 case UPIO_MEM: 2978 - if (!port->mapbase) 2978 + if (!port->mapbase) { 2979 + ret = -EINVAL; 2979 2980 break; 2981 + } 2980 2982 2981 2983 if (!request_mem_region(port->mapbase, size, "serial")) { 2982 2984 ret = -EBUSY;
+21 -2
drivers/tty/serial/amba-pl011.c
··· 1367 1367 pl011_dma_rx_stop(uap); 1368 1368 } 1369 1369 1370 + static void pl011_throttle_rx(struct uart_port *port) 1371 + { 1372 + unsigned long flags; 1373 + 1374 + spin_lock_irqsave(&port->lock, flags); 1375 + pl011_stop_rx(port); 1376 + spin_unlock_irqrestore(&port->lock, flags); 1377 + } 1378 + 1370 1379 static void pl011_enable_ms(struct uart_port *port) 1371 1380 { 1372 1381 struct uart_amba_port *uap = ··· 1797 1788 */ 1798 1789 static void pl011_enable_interrupts(struct uart_amba_port *uap) 1799 1790 { 1791 + unsigned long flags; 1800 1792 unsigned int i; 1801 1793 1802 - spin_lock_irq(&uap->port.lock); 1794 + spin_lock_irqsave(&uap->port.lock, flags); 1803 1795 1804 1796 /* Clear out any spuriously appearing RX interrupts */ 1805 1797 pl011_write(UART011_RTIS | UART011_RXIS, uap, REG_ICR); ··· 1822 1812 if (!pl011_dma_rx_running(uap)) 1823 1813 uap->im |= UART011_RXIM; 1824 1814 pl011_write(uap->im, uap, REG_IMSC); 1825 - spin_unlock_irq(&uap->port.lock); 1815 + spin_unlock_irqrestore(&uap->port.lock, flags); 1816 + } 1817 + 1818 + static void pl011_unthrottle_rx(struct uart_port *port) 1819 + { 1820 + struct uart_amba_port *uap = container_of(port, struct uart_amba_port, port); 1821 + 1822 + pl011_enable_interrupts(uap); 1826 1823 } 1827 1824 1828 1825 static int pl011_startup(struct uart_port *port) ··· 2242 2225 .stop_tx = pl011_stop_tx, 2243 2226 .start_tx = pl011_start_tx, 2244 2227 .stop_rx = pl011_stop_rx, 2228 + .throttle = pl011_throttle_rx, 2229 + .unthrottle = pl011_unthrottle_rx, 2245 2230 .enable_ms = pl011_enable_ms, 2246 2231 .break_ctl = pl011_break_ctl, 2247 2232 .startup = pl011_startup,
+13 -12
drivers/tty/serial/mvebu-uart.c
··· 470 470 } 471 471 } 472 472 473 - static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud) 473 + static unsigned int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud) 474 474 { 475 475 unsigned int d_divisor, m_divisor; 476 476 unsigned long flags; 477 477 u32 brdv, osamp; 478 478 479 479 if (!port->uartclk) 480 - return -EOPNOTSUPP; 480 + return 0; 481 481 482 482 /* 483 483 * The baudrate is derived from the UART clock thanks to divisors: ··· 548 548 (m_divisor << 16) | (m_divisor << 24); 549 549 writel(osamp, port->membase + UART_OSAMP); 550 550 551 - return 0; 551 + return DIV_ROUND_CLOSEST(port->uartclk, d_divisor * m_divisor); 552 552 } 553 553 554 554 static void mvebu_uart_set_termios(struct uart_port *port, ··· 587 587 max_baud = port->uartclk / 80; 588 588 589 589 baud = uart_get_baud_rate(port, termios, old, min_baud, max_baud); 590 - if (mvebu_uart_baud_rate_set(port, baud)) { 591 - /* No clock available, baudrate cannot be changed */ 592 - if (old) 593 - baud = uart_get_baud_rate(port, old, NULL, 594 - min_baud, max_baud); 595 - } else { 596 - tty_termios_encode_baud_rate(termios, baud, baud); 597 - uart_update_timeout(port, termios->c_cflag, baud); 598 - } 590 + baud = mvebu_uart_baud_rate_set(port, baud); 591 + 592 + /* In case baudrate cannot be changed, report previous old value */ 593 + if (baud == 0 && old) 594 + baud = tty_termios_baud_rate(old); 599 595 600 596 /* Only the following flag changes are supported */ 601 597 if (old) { ··· 600 604 termios->c_cflag &= CREAD | CBAUD; 601 605 termios->c_cflag |= old->c_cflag & ~(CREAD | CBAUD); 602 606 termios->c_cflag |= CS8; 607 + } 608 + 609 + if (baud != 0) { 610 + tty_termios_encode_baud_rate(termios, baud, baud); 611 + uart_update_timeout(port, termios->c_cflag, baud); 603 612 } 604 613 605 614 spin_unlock_irqrestore(&port->lock, flags);
+2 -3
drivers/tty/serial/samsung_tty.c
··· 377 377 /* Enable tx dma mode */ 378 378 ucon = rd_regl(port, S3C2410_UCON); 379 379 ucon &= ~(S3C64XX_UCON_TXBURST_MASK | S3C64XX_UCON_TXMODE_MASK); 380 - ucon |= (dma_get_cache_alignment() >= 16) ? 381 - S3C64XX_UCON_TXBURST_16 : S3C64XX_UCON_TXBURST_1; 380 + ucon |= S3C64XX_UCON_TXBURST_1; 382 381 ucon |= S3C64XX_UCON_TXMODE_DMA; 383 382 wr_regl(port, S3C2410_UCON, ucon); 384 383 ··· 673 674 S3C64XX_UCON_DMASUS_EN | 674 675 S3C64XX_UCON_TIMEOUT_EN | 675 676 S3C64XX_UCON_RXMODE_MASK); 676 - ucon |= S3C64XX_UCON_RXBURST_16 | 677 + ucon |= S3C64XX_UCON_RXBURST_1 | 677 678 0xf << S3C64XX_UCON_TIMEOUT_SHIFT | 678 679 S3C64XX_UCON_EMPTYINT_EN | 679 680 S3C64XX_UCON_TIMEOUT_EN |
-5
drivers/tty/serial/serial_core.c
··· 1941 1941 } 1942 1942 #endif 1943 1943 1944 - static inline bool uart_console_enabled(struct uart_port *port) 1945 - { 1946 - return uart_console(port) && (port->cons->flags & CON_ENABLED); 1947 - } 1948 - 1949 1944 static void uart_port_spin_lock_init(struct uart_port *port) 1950 1945 { 1951 1946 spin_lock_init(&port->lock);
+2
drivers/tty/serial/stm32-usart.c
··· 72 72 *cr3 |= USART_CR3_DEM; 73 73 over8 = *cr1 & USART_CR1_OVER8; 74 74 75 + *cr1 &= ~(USART_CR1_DEDT_MASK | USART_CR1_DEAT_MASK); 76 + 75 77 if (over8) 76 78 rs485_deat_dedt = delay_ADE * baud * 8; 77 79 else
+3
drivers/tty/tty.h
··· 111 111 112 112 ssize_t redirected_tty_write(struct kiocb *, struct iov_iter *); 113 113 114 + int tty_insert_flip_string_and_push_buffer(struct tty_port *port, 115 + const unsigned char *chars, size_t cnt); 116 + 114 117 #endif
+41 -5
drivers/tty/tty_buffer.c
··· 532 532 533 533 } 534 534 535 + static inline void tty_flip_buffer_commit(struct tty_buffer *tail) 536 + { 537 + /* 538 + * Paired w/ acquire in flush_to_ldisc(); ensures flush_to_ldisc() sees 539 + * buffer data. 540 + */ 541 + smp_store_release(&tail->commit, tail->used); 542 + } 543 + 535 544 /** 536 545 * tty_flip_buffer_push - push terminal buffers 537 546 * @port: tty port to push ··· 555 546 { 556 547 struct tty_bufhead *buf = &port->buf; 557 548 558 - /* 559 - * Paired w/ acquire in flush_to_ldisc(); ensures flush_to_ldisc() sees 560 - * buffer data. 561 - */ 562 - smp_store_release(&buf->tail->commit, buf->tail->used); 549 + tty_flip_buffer_commit(buf->tail); 563 550 queue_work(system_unbound_wq, &buf->work); 564 551 } 565 552 EXPORT_SYMBOL(tty_flip_buffer_push); 553 + 554 + /** 555 + * tty_insert_flip_string_and_push_buffer - add characters to the tty buffer and 556 + * push 557 + * @port: tty port 558 + * @chars: characters 559 + * @size: size 560 + * 561 + * The function combines tty_insert_flip_string() and tty_flip_buffer_push() 562 + * with the exception of properly holding the @port->lock. 563 + * 564 + * To be used only internally (by pty currently). 565 + * 566 + * Returns: the number added. 567 + */ 568 + int tty_insert_flip_string_and_push_buffer(struct tty_port *port, 569 + const unsigned char *chars, size_t size) 570 + { 571 + struct tty_bufhead *buf = &port->buf; 572 + unsigned long flags; 573 + 574 + spin_lock_irqsave(&port->lock, flags); 575 + size = tty_insert_flip_string(port, chars, size); 576 + if (size) 577 + tty_flip_buffer_commit(buf->tail); 578 + spin_unlock_irqrestore(&port->lock, flags); 579 + 580 + queue_work(system_unbound_wq, &buf->work); 581 + 582 + return size; 583 + } 566 584 567 585 /** 568 586 * tty_buffer_init - prepare a tty buffer structure
+1 -1
drivers/tty/vt/vt.c
··· 855 855 unsigned short *p = (unsigned short *) vc->vc_pos; 856 856 857 857 vc_uniscr_delete(vc, nr); 858 - scr_memcpyw(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2); 858 + scr_memmovew(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2); 859 859 scr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char, 860 860 nr * 2); 861 861 vc->vc_need_wrap = 0;
+2 -2
drivers/ufs/core/ufshcd.c
··· 5738 5738 } 5739 5739 5740 5740 hba->dev_info.wb_enabled = enable; 5741 - dev_info(hba->dev, "%s Write Booster %s\n", 5741 + dev_dbg(hba->dev, "%s Write Booster %s\n", 5742 5742 __func__, enable ? "enabled" : "disabled"); 5743 5743 5744 5744 return ret; ··· 7253 7253 hba->silence_err_logs = false; 7254 7254 7255 7255 /* scale up clocks to max frequency before full reinitialization */ 7256 - ufshcd_set_clk_freq(hba, true); 7256 + ufshcd_scale_clks(hba, true); 7257 7257 7258 7258 err = ufshcd_hba_enable(hba); 7259 7259
+2 -6
drivers/usb/dwc3/dwc3-am62.c
··· 195 195 196 196 if (i == ARRAY_SIZE(dwc3_ti_rate_table)) { 197 197 dev_err(dev, "unsupported usb2_refclk rate: %lu KHz\n", rate); 198 - ret = -EINVAL; 199 - goto err_clk_disable; 198 + return -EINVAL; 200 199 } 201 200 202 201 data->rate_code = i; ··· 203 204 /* Read the syscon property and set the rate code */ 204 205 ret = phy_syscon_pll_refclk(data); 205 206 if (ret) 206 - goto err_clk_disable; 207 + return ret; 207 208 208 209 /* VBUS divider select */ 209 210 data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); ··· 244 245 clk_disable_unprepare(data->usb2_refclk); 245 246 pm_runtime_disable(dev); 246 247 pm_runtime_set_suspended(dev); 247 - err_clk_disable: 248 - clk_put(data->usb2_refclk); 249 248 return ret; 250 249 } 251 250 ··· 273 276 pm_runtime_disable(dev); 274 277 pm_runtime_set_suspended(dev); 275 278 276 - clk_put(data->usb2_refclk); 277 279 platform_set_drvdata(pdev, NULL); 278 280 return 0; 279 281 }
+3 -1
drivers/usb/dwc3/gadget.c
··· 4249 4249 } 4250 4250 4251 4251 evt->count = 0; 4252 - evt->flags &= ~DWC3_EVENT_PENDING; 4253 4252 ret = IRQ_HANDLED; 4254 4253 4255 4254 /* Unmask interrupt */ ··· 4259 4260 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), DWC3_GEVNTCOUNT_EHB); 4260 4261 dwc3_writel(dwc->regs, DWC3_DEV_IMOD(0), dwc->imod_interval); 4261 4262 } 4263 + 4264 + /* Keep the clearing of DWC3_EVENT_PENDING at the end */ 4265 + evt->flags &= ~DWC3_EVENT_PENDING; 4262 4266 4263 4267 return ret; 4264 4268 }
+4 -2
drivers/usb/gadget/function/uvc_configfs.c
··· 2371 2371 const char *page, size_t len) \ 2372 2372 { \ 2373 2373 struct f_uvc_opts *opts = to_f_uvc_opts(item); \ 2374 + int size = min(sizeof(opts->aname), len + 1); \ 2374 2375 int ret = 0; \ 2375 2376 \ 2376 2377 mutex_lock(&opts->lock); \ ··· 2380 2379 goto end; \ 2381 2380 } \ 2382 2381 \ 2383 - ret = snprintf(opts->aname, min(sizeof(opts->aname), len), \ 2384 - "%s", page); \ 2382 + ret = strscpy(opts->aname, page, size); \ 2383 + if (ret == -E2BIG) \ 2384 + ret = size - 1; \ 2385 2385 \ 2386 2386 end: \ 2387 2387 mutex_unlock(&opts->lock); \
+3 -8
drivers/usb/host/ehci-fsl.c
··· 76 76 return -ENODEV; 77 77 } 78 78 79 - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 80 - if (!res) { 81 - dev_err(&pdev->dev, 82 - "Found HC with no IRQ. Check %s setup!\n", 83 - dev_name(&pdev->dev)); 84 - return -ENODEV; 85 - } 86 - irq = res->start; 79 + irq = platform_get_irq(pdev, 0); 80 + if (irq < 0) 81 + return irq; 87 82 88 83 hcd = __usb_create_hcd(&fsl_ehci_hc_driver, pdev->dev.parent, 89 84 &pdev->dev, dev_name(&pdev->dev), NULL);
+3
drivers/usb/host/fsl-mph-dr-of.c
··· 112 112 goto error; 113 113 } 114 114 115 + pdev->dev.of_node = ofdev->dev.of_node; 116 + pdev->dev.of_node_reused = true; 117 + 115 118 retval = platform_device_add(pdev); 116 119 if (retval) 117 120 goto error;
+3
drivers/usb/serial/ftdi_sio.c
··· 1023 1023 { USB_DEVICE(FTDI_VID, CHETCO_SEASMART_DISPLAY_PID) }, 1024 1024 { USB_DEVICE(FTDI_VID, CHETCO_SEASMART_LITE_PID) }, 1025 1025 { USB_DEVICE(FTDI_VID, CHETCO_SEASMART_ANALOG_PID) }, 1026 + /* Belimo Automation devices */ 1027 + { USB_DEVICE(FTDI_VID, BELIMO_ZTH_PID) }, 1028 + { USB_DEVICE(FTDI_VID, BELIMO_ZIP_PID) }, 1026 1029 /* ICP DAS I-756xU devices */ 1027 1030 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7560U_PID) }, 1028 1031 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) },
+6
drivers/usb/serial/ftdi_sio_ids.h
··· 1569 1569 #define CHETCO_SEASMART_ANALOG_PID 0xA5AF /* SeaSmart Analog Adapter */ 1570 1570 1571 1571 /* 1572 + * Belimo Automation 1573 + */ 1574 + #define BELIMO_ZTH_PID 0x8050 1575 + #define BELIMO_ZIP_PID 0xC811 1576 + 1577 + /* 1572 1578 * Unjo AB 1573 1579 */ 1574 1580 #define UNJO_VID 0x22B7
+1
drivers/usb/typec/class.c
··· 1718 1718 partner->usb_pd = 1; 1719 1719 sysfs_notify(&partner_dev->kobj, NULL, 1720 1720 "supports_usb_power_delivery"); 1721 + kobject_uevent(&partner_dev->kobj, KOBJ_CHANGE); 1721 1722 } 1722 1723 put_device(partner_dev); 1723 1724 }
+4 -2
drivers/xen/gntdev.c
··· 396 396 unsigned int offset = data->unmap_ops - map->unmap_ops; 397 397 398 398 for (i = 0; i < data->count; i++) { 399 - WARN_ON(map->unmap_ops[offset+i].status); 399 + WARN_ON(map->unmap_ops[offset + i].status != GNTST_okay && 400 + map->unmap_ops[offset + i].handle != INVALID_GRANT_HANDLE); 400 401 pr_debug("unmap handle=%d st=%d\n", 401 402 map->unmap_ops[offset+i].handle, 402 403 map->unmap_ops[offset+i].status); 403 404 map->unmap_ops[offset+i].handle = INVALID_GRANT_HANDLE; 404 405 if (use_ptemod) { 405 - WARN_ON(map->kunmap_ops[offset+i].status); 406 + WARN_ON(map->kunmap_ops[offset + i].status != GNTST_okay && 407 + map->kunmap_ops[offset + i].handle != INVALID_GRANT_HANDLE); 406 408 pr_debug("kunmap handle=%u st=%d\n", 407 409 map->kunmap_ops[offset+i].handle, 408 410 map->kunmap_ops[offset+i].status);
+1 -1
fs/afs/file.c
··· 375 375 } 376 376 377 377 static int afs_check_write_begin(struct file *file, loff_t pos, unsigned len, 378 - struct folio *folio, void **_fsdata) 378 + struct folio **foliop, void **_fsdata) 379 379 { 380 380 struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); 381 381
+8 -10
fs/btrfs/ctree.h
··· 675 675 rwlock_t global_root_lock; 676 676 struct rb_root global_root_tree; 677 677 678 - /* The xarray that holds all the FS roots */ 679 - spinlock_t fs_roots_lock; 680 - struct xarray fs_roots; 678 + spinlock_t fs_roots_radix_lock; 679 + struct radix_tree_root fs_roots_radix; 681 680 682 681 /* block group cache stuff */ 683 682 rwlock_t block_group_cache_lock; ··· 994 995 995 996 struct btrfs_delayed_root *delayed_root; 996 997 997 - /* Extent buffer xarray */ 998 + /* Extent buffer radix tree */ 998 999 spinlock_t buffer_lock; 999 1000 /* Entries are eb->start / sectorsize */ 1000 - struct xarray extent_buffers; 1001 + struct radix_tree_root buffer_radix; 1001 1002 1002 1003 /* next backup root to be overwritten */ 1003 1004 int backup_root_index; ··· 1118 1119 */ 1119 1120 BTRFS_ROOT_SHAREABLE, 1120 1121 BTRFS_ROOT_TRACK_DIRTY, 1121 - /* The root is tracked in fs_info::fs_roots */ 1122 - BTRFS_ROOT_REGISTERED, 1122 + BTRFS_ROOT_IN_RADIX, 1123 1123 BTRFS_ROOT_ORPHAN_ITEM_INSERTED, 1124 1124 BTRFS_ROOT_DEFRAG_RUNNING, 1125 1125 BTRFS_ROOT_FORCE_COW, ··· 1222 1224 struct rb_root inode_tree; 1223 1225 1224 1226 /* 1225 - * Xarray that keeps track of delayed nodes of every inode, protected 1226 - * by inode_lock 1227 + * radix tree that keeps track of delayed nodes of every inode, 1228 + * protected by inode_lock 1227 1229 */ 1228 - struct xarray delayed_nodes; 1230 + struct radix_tree_root delayed_nodes_tree; 1229 1231 /* 1230 1232 * right now this just gets used so that a root has its own devid 1231 1233 * for stat. It may be used for more later
+45 -39
fs/btrfs/delayed-inode.c
··· 78 78 } 79 79 80 80 spin_lock(&root->inode_lock); 81 - node = xa_load(&root->delayed_nodes, ino); 81 + node = radix_tree_lookup(&root->delayed_nodes_tree, ino); 82 82 83 83 if (node) { 84 84 if (btrfs_inode->delayed_node) { ··· 90 90 91 91 /* 92 92 * It's possible that we're racing into the middle of removing 93 - * this node from the xarray. In this case, the refcount 93 + * this node from the radix tree. In this case, the refcount 94 94 * was zero and it should never go back to one. Just return 95 - * NULL like it was never in the xarray at all; our release 95 + * NULL like it was never in the radix at all; our release 96 96 * function is in the process of removing it. 97 97 * 98 98 * Some implementations of refcount_inc refuse to bump the ··· 100 100 * here, refcount_inc() may decide to just WARN_ONCE() instead 101 101 * of actually bumping the refcount. 102 102 * 103 - * If this node is properly in the xarray, we want to bump the 103 + * If this node is properly in the radix, we want to bump the 104 104 * refcount twice, once for the inode and once for this get 105 105 * operation. 106 106 */ ··· 128 128 u64 ino = btrfs_ino(btrfs_inode); 129 129 int ret; 130 130 131 - do { 132 - node = btrfs_get_delayed_node(btrfs_inode); 133 - if (node) 134 - return node; 131 + again: 132 + node = btrfs_get_delayed_node(btrfs_inode); 133 + if (node) 134 + return node; 135 135 136 - node = kmem_cache_zalloc(delayed_node_cache, GFP_NOFS); 137 - if (!node) 138 - return ERR_PTR(-ENOMEM); 139 - btrfs_init_delayed_node(node, root, ino); 136 + node = kmem_cache_zalloc(delayed_node_cache, GFP_NOFS); 137 + if (!node) 138 + return ERR_PTR(-ENOMEM); 139 + btrfs_init_delayed_node(node, root, ino); 140 140 141 - /* Cached in the inode and can be accessed */ 142 - refcount_set(&node->refs, 2); 141 + /* cached in the btrfs inode and can be accessed */ 142 + refcount_set(&node->refs, 2); 143 143 144 - spin_lock(&root->inode_lock); 145 - ret = xa_insert(&root->delayed_nodes, ino, node, GFP_NOFS); 146 - if (ret) { 147 - spin_unlock(&root->inode_lock); 148 - kmem_cache_free(delayed_node_cache, node); 149 - if (ret != -EBUSY) 150 - return ERR_PTR(ret); 151 - } 152 - } while (ret); 144 + ret = radix_tree_preload(GFP_NOFS); 145 + if (ret) { 146 + kmem_cache_free(delayed_node_cache, node); 147 + return ERR_PTR(ret); 148 + } 149 + 150 + spin_lock(&root->inode_lock); 151 + ret = radix_tree_insert(&root->delayed_nodes_tree, ino, node); 152 + if (ret == -EEXIST) { 153 + spin_unlock(&root->inode_lock); 154 + kmem_cache_free(delayed_node_cache, node); 155 + radix_tree_preload_end(); 156 + goto again; 157 + } 153 158 btrfs_inode->delayed_node = node; 154 159 spin_unlock(&root->inode_lock); 160 + radix_tree_preload_end(); 155 161 156 162 return node; 157 163 } ··· 276 270 * back up. We can delete it now. 277 271 */ 278 272 ASSERT(refcount_read(&delayed_node->refs) == 0); 279 - xa_erase(&root->delayed_nodes, delayed_node->inode_id); 273 + radix_tree_delete(&root->delayed_nodes_tree, 274 + delayed_node->inode_id); 280 275 spin_unlock(&root->inode_lock); 281 276 kmem_cache_free(delayed_node_cache, delayed_node); 282 277 } ··· 1870 1863 1871 1864 void btrfs_kill_all_delayed_nodes(struct btrfs_root *root) 1872 1865 { 1873 - unsigned long index = 0; 1874 - struct btrfs_delayed_node *delayed_node; 1866 + u64 inode_id = 0; 1875 1867 struct btrfs_delayed_node *delayed_nodes[8]; 1868 + int i, n; 1876 1869 1877 1870 while (1) { 1878 - int n = 0; 1879 - 1880 1871 spin_lock(&root->inode_lock); 1881 - if (xa_empty(&root->delayed_nodes)) { 1872 + n = radix_tree_gang_lookup(&root->delayed_nodes_tree, 1873 + (void **)delayed_nodes, inode_id, 1874 + ARRAY_SIZE(delayed_nodes)); 1875 + if (!n) { 1882 1876 spin_unlock(&root->inode_lock); 1883 - return; 1877 + break; 1884 1878 } 1885 1879 1886 - xa_for_each_start(&root->delayed_nodes, index, delayed_node, index) { 1880 + inode_id = delayed_nodes[n - 1]->inode_id + 1; 1881 + for (i = 0; i < n; i++) { 1887 1882 /* 1888 1883 * Don't increase refs in case the node is dead and 1889 1884 * about to be removed from the tree in the loop below 1890 1885 */ 1891 - if (refcount_inc_not_zero(&delayed_node->refs)) { 1892 - delayed_nodes[n] = delayed_node; 1893 - n++; 1894 - } 1895 - if (n >= ARRAY_SIZE(delayed_nodes)) 1896 - break; 1886 + if (!refcount_inc_not_zero(&delayed_nodes[i]->refs)) 1887 + delayed_nodes[i] = NULL; 1897 1888 } 1898 - index++; 1899 1889 spin_unlock(&root->inode_lock); 1900 1890 1901 - for (int i = 0; i < n; i++) { 1891 + for (i = 0; i < n; i++) { 1892 + if (!delayed_nodes[i]) 1893 + continue; 1902 1894 __btrfs_kill_delayed_node(delayed_nodes[i]); 1903 1895 btrfs_release_delayed_node(delayed_nodes[i]); 1904 1896 }
+103 -82
fs/btrfs/disk-io.c
··· 5 5 6 6 #include <linux/fs.h> 7 7 #include <linux/blkdev.h> 8 + #include <linux/radix-tree.h> 8 9 #include <linux/writeback.h> 9 10 #include <linux/workqueue.h> 10 11 #include <linux/kthread.h> ··· 486 485 uptodate = btrfs_subpage_test_uptodate(fs_info, page, cur, 487 486 fs_info->nodesize); 488 487 489 - /* A dirty eb shouldn't disappear from extent_buffers */ 488 + /* A dirty eb shouldn't disappear from buffer_radix */ 490 489 if (WARN_ON(!eb)) 491 490 return -EUCLEAN; 492 491 ··· 1159 1158 root->nr_delalloc_inodes = 0; 1160 1159 root->nr_ordered_extents = 0; 1161 1160 root->inode_tree = RB_ROOT; 1162 - xa_init_flags(&root->delayed_nodes, GFP_ATOMIC); 1161 + INIT_RADIX_TREE(&root->delayed_nodes_tree, GFP_ATOMIC); 1163 1162 1164 1163 btrfs_init_root_block_rsv(root); 1165 1164 ··· 1211 1210 btrfs_qgroup_init_swapped_blocks(&root->swapped_blocks); 1212 1211 #ifdef CONFIG_BTRFS_DEBUG 1213 1212 INIT_LIST_HEAD(&root->leak_list); 1214 - spin_lock(&fs_info->fs_roots_lock); 1213 + spin_lock(&fs_info->fs_roots_radix_lock); 1215 1214 list_add_tail(&root->leak_list, &fs_info->allocated_roots); 1216 - spin_unlock(&fs_info->fs_roots_lock); 1215 + spin_unlock(&fs_info->fs_roots_radix_lock); 1217 1216 #endif 1218 1217 } 1219 1218 ··· 1660 1659 { 1661 1660 struct btrfs_root *root; 1662 1661 1663 - spin_lock(&fs_info->fs_roots_lock); 1664 - root = xa_load(&fs_info->fs_roots, (unsigned long)root_id); 1662 + spin_lock(&fs_info->fs_roots_radix_lock); 1663 + root = radix_tree_lookup(&fs_info->fs_roots_radix, 1664 + (unsigned long)root_id); 1665 1665 if (root) 1666 1666 root = btrfs_grab_root(root); 1667 - spin_unlock(&fs_info->fs_roots_lock); 1667 + spin_unlock(&fs_info->fs_roots_radix_lock); 1668 1668 return root; 1669 1669 } 1670 1670 ··· 1707 1705 { 1708 1706 int ret; 1709 1707 1710 - spin_lock(&fs_info->fs_roots_lock); 1711 - ret = xa_insert(&fs_info->fs_roots, (unsigned long)root->root_key.objectid, 1712 - root, GFP_NOFS); 1708 + ret = radix_tree_preload(GFP_NOFS); 1709 + if (ret) 1710 + return ret; 1711 + 1712 + spin_lock(&fs_info->fs_roots_radix_lock); 1713 + ret = radix_tree_insert(&fs_info->fs_roots_radix, 1714 + (unsigned long)root->root_key.objectid, 1715 + root); 1713 1716 if (ret == 0) { 1714 1717 btrfs_grab_root(root); 1715 - set_bit(BTRFS_ROOT_REGISTERED, &root->state); 1718 + set_bit(BTRFS_ROOT_IN_RADIX, &root->state); 1716 1719 } 1717 - spin_unlock(&fs_info->fs_roots_lock); 1720 + spin_unlock(&fs_info->fs_roots_radix_lock); 1721 + radix_tree_preload_end(); 1718 1722 1719 1723 return ret; 1720 1724 } ··· 2350 2342 btrfs_drew_lock_destroy(&root->snapshot_lock); 2351 2343 free_root_extent_buffers(root); 2352 2344 #ifdef CONFIG_BTRFS_DEBUG 2353 - spin_lock(&root->fs_info->fs_roots_lock); 2345 + spin_lock(&root->fs_info->fs_roots_radix_lock); 2354 2346 list_del_init(&root->leak_list); 2355 - spin_unlock(&root->fs_info->fs_roots_lock); 2347 + spin_unlock(&root->fs_info->fs_roots_radix_lock); 2356 2348 #endif 2357 2349 kfree(root); 2358 2350 } ··· 2360 2352 2361 2353 void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info) 2362 2354 { 2363 - struct btrfs_root *root; 2364 - unsigned long index = 0; 2355 + int ret; 2356 + struct btrfs_root *gang[8]; 2357 + int i; 2365 2358 2366 2359 while (!list_empty(&fs_info->dead_roots)) { 2367 - root = list_entry(fs_info->dead_roots.next, 2368 - struct btrfs_root, root_list); 2369 - list_del(&root->root_list); 2360 + gang[0] = list_entry(fs_info->dead_roots.next, 2361 + struct btrfs_root, root_list); 2362 + list_del(&gang[0]->root_list); 2370 2363 2371 - if (test_bit(BTRFS_ROOT_REGISTERED, &root->state)) 2372 - btrfs_drop_and_free_fs_root(fs_info, root); 2373 - btrfs_put_root(root); 2364 + if (test_bit(BTRFS_ROOT_IN_RADIX, &gang[0]->state)) 2365 + btrfs_drop_and_free_fs_root(fs_info, gang[0]); 2366 + btrfs_put_root(gang[0]); 2374 2367 } 2375 2368 2376 - xa_for_each(&fs_info->fs_roots, index, root) { 2377 - btrfs_drop_and_free_fs_root(fs_info, root); 2369 + while (1) { 2370 + ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix, 2371 + (void **)gang, 0, 2372 + ARRAY_SIZE(gang)); 2373 + if (!ret) 2374 + break; 2375 + for (i = 0; i < ret; i++) 2376 + btrfs_drop_and_free_fs_root(fs_info, gang[i]); 2378 2377 } 2379 2378 } 2380 2379 ··· 3149 3134 3150 3135 void btrfs_init_fs_info(struct btrfs_fs_info *fs_info) 3151 3136 { 3152 - xa_init_flags(&fs_info->fs_roots, GFP_ATOMIC); 3153 - xa_init_flags(&fs_info->extent_buffers, GFP_ATOMIC); 3137 + INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC); 3138 + INIT_RADIX_TREE(&fs_info->buffer_radix, GFP_ATOMIC); 3154 3139 INIT_LIST_HEAD(&fs_info->trans_list); 3155 3140 INIT_LIST_HEAD(&fs_info->dead_roots); 3156 3141 INIT_LIST_HEAD(&fs_info->delayed_iputs); ··· 3158 3143 INIT_LIST_HEAD(&fs_info->caching_block_groups); 3159 3144 spin_lock_init(&fs_info->delalloc_root_lock); 3160 3145 spin_lock_init(&fs_info->trans_lock); 3161 - spin_lock_init(&fs_info->fs_roots_lock); 3146 + spin_lock_init(&fs_info->fs_roots_radix_lock); 3162 3147 spin_lock_init(&fs_info->delayed_iput_lock); 3163 3148 spin_lock_init(&fs_info->defrag_inodes_lock); 3164 3149 spin_lock_init(&fs_info->super_lock); ··· 3389 3374 /* 3390 3375 * btrfs_find_orphan_roots() is responsible for finding all the dead 3391 3376 * roots (with 0 refs), flag them with BTRFS_ROOT_DEAD_TREE and load 3392 - * them into the fs_info->fs_roots. This must be done before 3377 + * them into the fs_info->fs_roots_radix tree. This must be done before 3393 3378 * calling btrfs_orphan_cleanup() on the tree root. If we don't do it 3394 3379 * first, then btrfs_orphan_cleanup() will delete a dead root's orphan 3395 3380 * item before the root's tree is deleted - this means that if we unmount ··· 4514 4499 { 4515 4500 bool drop_ref = false; 4516 4501 4517 - spin_lock(&fs_info->fs_roots_lock); 4518 - xa_erase(&fs_info->fs_roots, (unsigned long)root->root_key.objectid); 4519 - if (test_and_clear_bit(BTRFS_ROOT_REGISTERED, &root->state)) 4502 + spin_lock(&fs_info->fs_roots_radix_lock); 4503 + radix_tree_delete(&fs_info->fs_roots_radix, 4504 + (unsigned long)root->root_key.objectid); 4505 + if (test_and_clear_bit(BTRFS_ROOT_IN_RADIX, &root->state)) 4520 4506 drop_ref = true; 4521 - spin_unlock(&fs_info->fs_roots_lock); 4507 + spin_unlock(&fs_info->fs_roots_radix_lock); 4522 4508 4523 4509 if (BTRFS_FS_ERROR(fs_info)) { 4524 4510 ASSERT(root->log_root == NULL); ··· 4535 4519 4536 4520 int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info) 4537 4521 { 4538 - struct btrfs_root *roots[8]; 4539 - unsigned long index = 0; 4540 - int i; 4522 + u64 root_objectid = 0; 4523 + struct btrfs_root *gang[8]; 4524 + int i = 0; 4541 4525 int err = 0; 4542 - int grabbed; 4526 + unsigned int ret = 0; 4543 4527 4544 4528 while (1) { 4545 - struct btrfs_root *root; 4546 - 4547 - spin_lock(&fs_info->fs_roots_lock); 4548 - if (!xa_find(&fs_info->fs_roots, &index, ULONG_MAX, XA_PRESENT)) { 4549 - spin_unlock(&fs_info->fs_roots_lock); 4550 - return err; 4529 + spin_lock(&fs_info->fs_roots_radix_lock); 4530 + ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix, 4531 + (void **)gang, root_objectid, 4532 + ARRAY_SIZE(gang)); 4533 + if (!ret) { 4534 + spin_unlock(&fs_info->fs_roots_radix_lock); 4535 + break; 4551 4536 } 4537 + root_objectid = gang[ret - 1]->root_key.objectid + 1; 4552 4538 4553 - grabbed = 0; 4554 - xa_for_each_start(&fs_info->fs_roots, index, root, index) { 4555 - /* Avoid grabbing roots in dead_roots */ 4556 - if (btrfs_root_refs(&root->root_item) > 0) 4557 - roots[grabbed++] = btrfs_grab_root(root); 4558 - if (grabbed >= ARRAY_SIZE(roots)) 4559 - break; 4560 - } 4561 - spin_unlock(&fs_info->fs_roots_lock); 4562 - 4563 - for (i = 0; i < grabbed; i++) { 4564 - if (!roots[i]) 4539 + for (i = 0; i < ret; i++) { 4540 + /* Avoid to grab roots in dead_roots */ 4541 + if (btrfs_root_refs(&gang[i]->root_item) == 0) { 4542 + gang[i] = NULL; 4565 4543 continue; 4566 - index = roots[i]->root_key.objectid; 4567 - err = btrfs_orphan_cleanup(roots[i]); 4568 - if (err) 4569 - goto out; 4570 - btrfs_put_root(roots[i]); 4544 + } 4545 + /* grab all the search result for later use */ 4546 + gang[i] = btrfs_grab_root(gang[i]); 4571 4547 } 4572 - index++; 4548 + spin_unlock(&fs_info->fs_roots_radix_lock); 4549 + 4550 + for (i = 0; i < ret; i++) { 4551 + if (!gang[i]) 4552 + continue; 4553 + root_objectid = gang[i]->root_key.objectid; 4554 + err = btrfs_orphan_cleanup(gang[i]); 4555 + if (err) 4556 + break; 4557 + btrfs_put_root(gang[i]); 4558 + } 4559 + root_objectid++; 4573 4560 } 4574 4561 4575 - out: 4576 - /* Release the roots that remain uncleaned due to error */ 4577 - for (; i < grabbed; i++) { 4578 - if (roots[i]) 4579 - btrfs_put_root(roots[i]); 4562 + /* release the uncleaned roots due to error */ 4563 + for (; i < ret; i++) { 4564 + if (gang[i]) 4565 + btrfs_put_root(gang[i]); 4580 4566 } 4581 4567 return err; 4582 4568 } ··· 4897 4879 4898 4880 static void btrfs_drop_all_logs(struct btrfs_fs_info *fs_info) 4899 4881 { 4900 - unsigned long index = 0; 4901 - int grabbed = 0; 4902 - struct btrfs_root *roots[8]; 4882 + struct btrfs_root *gang[8]; 4883 + u64 root_objectid = 0; 4884 + int ret; 4903 4885 4904 - spin_lock(&fs_info->fs_roots_lock); 4905 - while ((grabbed = xa_extract(&fs_info->fs_roots, (void **)roots, index, 4906 - ULONG_MAX, 8, XA_PRESENT))) { 4907 - for (int i = 0; i < grabbed; i++) 4908 - roots[i] = btrfs_grab_root(roots[i]); 4909 - spin_unlock(&fs_info->fs_roots_lock); 4886 + spin_lock(&fs_info->fs_roots_radix_lock); 4887 + while ((ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix, 4888 + (void **)gang, root_objectid, 4889 + ARRAY_SIZE(gang))) != 0) { 4890 + int i; 4910 4891 4911 - for (int i = 0; i < grabbed; i++) { 4912 - if (!roots[i]) 4892 + for (i = 0; i < ret; i++) 4893 + gang[i] = btrfs_grab_root(gang[i]); 4894 + spin_unlock(&fs_info->fs_roots_radix_lock); 4895 + 4896 + for (i = 0; i < ret; i++) { 4897 + if (!gang[i]) 4913 4898 continue; 4914 - index = roots[i]->root_key.objectid; 4915 - btrfs_free_log(NULL, roots[i]); 4916 - btrfs_put_root(roots[i]); 4899 + root_objectid = gang[i]->root_key.objectid; 4900 + btrfs_free_log(NULL, gang[i]); 4901 + btrfs_put_root(gang[i]); 4917 4902 } 4918 - index++; 4919 - spin_lock(&fs_info->fs_roots_lock); 4903 + root_objectid++; 4904 + spin_lock(&fs_info->fs_roots_radix_lock); 4920 4905 } 4921 - spin_unlock(&fs_info->fs_roots_lock); 4906 + spin_unlock(&fs_info->fs_roots_radix_lock); 4922 4907 btrfs_free_log_root_tree(NULL, fs_info); 4923 4908 } 4924 4909
+1 -1
fs/btrfs/extent-tree.c
··· 5829 5829 btrfs_qgroup_convert_reserved_meta(root, INT_MAX); 5830 5830 btrfs_qgroup_free_meta_all_pertrans(root); 5831 5831 5832 - if (test_bit(BTRFS_ROOT_REGISTERED, &root->state)) 5832 + if (test_bit(BTRFS_ROOT_IN_RADIX, &root->state)) 5833 5833 btrfs_add_dropped_root(trans, root); 5834 5834 else 5835 5835 btrfs_put_root(root);
+73 -47
fs/btrfs/extent_io.c
··· 2966 2966 } 2967 2967 2968 2968 /* 2969 - * Find extent buffer for a given bytenr. 2969 + * Find extent buffer for a givne bytenr. 2970 2970 * 2971 2971 * This is for end_bio_extent_readpage(), thus we can't do any unsafe locking 2972 2972 * in endio context. ··· 2985 2985 return (struct extent_buffer *)page->private; 2986 2986 } 2987 2987 2988 - /* For subpage case, we need to lookup extent buffer xarray */ 2989 - eb = xa_load(&fs_info->extent_buffers, 2990 - bytenr >> fs_info->sectorsize_bits); 2988 + /* For subpage case, we need to lookup buffer radix tree */ 2989 + rcu_read_lock(); 2990 + eb = radix_tree_lookup(&fs_info->buffer_radix, 2991 + bytenr >> fs_info->sectorsize_bits); 2992 + rcu_read_unlock(); 2991 2993 ASSERT(eb); 2992 2994 return eb; 2993 2995 } ··· 4437 4435 struct extent_buffer *eb; 4438 4436 4439 4437 rcu_read_lock(); 4440 - eb = xa_load(&fs_info->extent_buffers, 4441 - start >> fs_info->sectorsize_bits); 4438 + eb = radix_tree_lookup(&fs_info->buffer_radix, 4439 + start >> fs_info->sectorsize_bits); 4442 4440 if (eb && atomic_inc_not_zero(&eb->refs)) { 4443 4441 rcu_read_unlock(); 4444 4442 return eb; ··· 6131 6129 if (!eb) 6132 6130 return ERR_PTR(-ENOMEM); 6133 6131 eb->fs_info = fs_info; 6134 - 6135 - do { 6136 - ret = xa_insert(&fs_info->extent_buffers, 6137 - start >> fs_info->sectorsize_bits, 6138 - eb, GFP_NOFS); 6139 - if (ret == -ENOMEM) { 6140 - exists = ERR_PTR(ret); 6132 + again: 6133 + ret = radix_tree_preload(GFP_NOFS); 6134 + if (ret) { 6135 + exists = ERR_PTR(ret); 6136 + goto free_eb; 6137 + } 6138 + spin_lock(&fs_info->buffer_lock); 6139 + ret = radix_tree_insert(&fs_info->buffer_radix, 6140 + start >> fs_info->sectorsize_bits, eb); 6141 + spin_unlock(&fs_info->buffer_lock); 6142 + radix_tree_preload_end(); 6143 + if (ret == -EEXIST) { 6144 + exists = find_extent_buffer(fs_info, start); 6145 + if (exists) 6141 6146 goto free_eb; 6142 - } 6143 - if (ret == -EBUSY) { 6144 - exists = find_extent_buffer(fs_info, start); 6145 - if (exists) 6146 - goto free_eb; 6147 - } 6148 - } while (ret); 6149 - 6147 + else 6148 + goto again; 6149 + } 6150 6150 check_buffer_tree_ref(eb); 6151 6151 set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags); 6152 6152 ··· 6323 6319 } 6324 6320 if (uptodate) 6325 6321 set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); 6322 + again: 6323 + ret = radix_tree_preload(GFP_NOFS); 6324 + if (ret) { 6325 + exists = ERR_PTR(ret); 6326 + goto free_eb; 6327 + } 6326 6328 6327 - do { 6328 - ret = xa_insert(&fs_info->extent_buffers, 6329 - start >> fs_info->sectorsize_bits, 6330 - eb, GFP_NOFS); 6331 - if (ret == -ENOMEM) { 6332 - exists = ERR_PTR(ret); 6329 + spin_lock(&fs_info->buffer_lock); 6330 + ret = radix_tree_insert(&fs_info->buffer_radix, 6331 + start >> fs_info->sectorsize_bits, eb); 6332 + spin_unlock(&fs_info->buffer_lock); 6333 + radix_tree_preload_end(); 6334 + if (ret == -EEXIST) { 6335 + exists = find_extent_buffer(fs_info, start); 6336 + if (exists) 6333 6337 goto free_eb; 6334 - } 6335 - if (ret == -EBUSY) { 6336 - exists = find_extent_buffer(fs_info, start); 6337 - if (exists) 6338 - goto free_eb; 6339 - } 6340 - } while (ret); 6341 - 6338 + else 6339 + goto again; 6340 + } 6342 6341 /* add one reference for the tree */ 6343 6342 check_buffer_tree_ref(eb); 6344 6343 set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags); ··· 6386 6379 6387 6380 spin_unlock(&eb->refs_lock); 6388 6381 6389 - xa_erase(&fs_info->extent_buffers, 6390 - eb->start >> fs_info->sectorsize_bits); 6382 + spin_lock(&fs_info->buffer_lock); 6383 + radix_tree_delete(&fs_info->buffer_radix, 6384 + eb->start >> fs_info->sectorsize_bits); 6385 + spin_unlock(&fs_info->buffer_lock); 6391 6386 } else { 6392 6387 spin_unlock(&eb->refs_lock); 6393 6388 } ··· 7334 7325 } 7335 7326 } 7336 7327 7328 + #define GANG_LOOKUP_SIZE 16 7337 7329 static struct extent_buffer *get_next_extent_buffer( 7338 7330 struct btrfs_fs_info *fs_info, struct page *page, u64 bytenr) 7339 7331 { 7340 - struct extent_buffer *eb; 7341 - unsigned long index; 7332 + struct extent_buffer *gang[GANG_LOOKUP_SIZE]; 7333 + struct extent_buffer *found = NULL; 7342 7334 u64 page_start = page_offset(page); 7335 + u64 cur = page_start; 7343 7336 7344 7337 ASSERT(in_range(bytenr, page_start, PAGE_SIZE)); 7345 7338 lockdep_assert_held(&fs_info->buffer_lock); 7346 7339 7347 - xa_for_each_start(&fs_info->extent_buffers, index, eb, 7348 - page_start >> fs_info->sectorsize_bits) { 7349 - if (in_range(eb->start, page_start, PAGE_SIZE)) 7350 - return eb; 7351 - else if (eb->start >= page_start + PAGE_SIZE) 7352 - /* Already beyond page end */ 7353 - return NULL; 7340 + while (cur < page_start + PAGE_SIZE) { 7341 + int ret; 7342 + int i; 7343 + 7344 + ret = radix_tree_gang_lookup(&fs_info->buffer_radix, 7345 + (void **)gang, cur >> fs_info->sectorsize_bits, 7346 + min_t(unsigned int, GANG_LOOKUP_SIZE, 7347 + PAGE_SIZE / fs_info->nodesize)); 7348 + if (ret == 0) 7349 + goto out; 7350 + for (i = 0; i < ret; i++) { 7351 + /* Already beyond page end */ 7352 + if (gang[i]->start >= page_start + PAGE_SIZE) 7353 + goto out; 7354 + /* Found one */ 7355 + if (gang[i]->start >= bytenr) { 7356 + found = gang[i]; 7357 + goto out; 7358 + } 7359 + } 7360 + cur = gang[ret - 1]->start + gang[ret - 1]->len; 7354 7361 } 7355 - return NULL; 7362 + out: 7363 + return found; 7356 7364 } 7357 7365 7358 7366 static int try_release_subpage_extent_buffer(struct page *page)
+7 -8
fs/btrfs/inode.c
··· 3578 3578 u64 last_objectid = 0; 3579 3579 int ret = 0, nr_unlink = 0; 3580 3580 3581 - /* Bail out if the cleanup is already running. */ 3582 3581 if (test_and_set_bit(BTRFS_ROOT_ORPHAN_CLEANUP, &root->state)) 3583 3582 return 0; 3584 3583 ··· 3660 3661 * 3661 3662 * btrfs_find_orphan_roots() ran before us, which has 3662 3663 * found all deleted roots and loaded them into 3663 - * fs_info->fs_roots. So here we can find if an 3664 + * fs_info->fs_roots_radix. So here we can find if an 3664 3665 * orphan item corresponds to a deleted root by looking 3665 - * up the root from that xarray. 3666 + * up the root from that radix tree. 3666 3667 */ 3667 3668 3668 - spin_lock(&fs_info->fs_roots_lock); 3669 - dead_root = xa_load(&fs_info->fs_roots, 3670 - (unsigned long)found_key.objectid); 3669 + spin_lock(&fs_info->fs_roots_radix_lock); 3670 + dead_root = radix_tree_lookup(&fs_info->fs_roots_radix, 3671 + (unsigned long)found_key.objectid); 3671 3672 if (dead_root && btrfs_root_refs(&dead_root->root_item) == 0) 3672 3673 is_dead_root = 1; 3673 - spin_unlock(&fs_info->fs_roots_lock); 3674 + spin_unlock(&fs_info->fs_roots_radix_lock); 3674 3675 3675 3676 if (is_dead_root) { 3676 3677 /* prevent this orphan from being found again */ ··· 3910 3911 * cache. 3911 3912 * 3912 3913 * This is required for both inode re-read from disk and delayed inode 3913 - * in the delayed_nodes xarray. 3914 + * in delayed_nodes_tree. 3914 3915 */ 3915 3916 if (BTRFS_I(inode)->last_trans == fs_info->generation) 3916 3917 set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
+22 -18
fs/btrfs/send.c
··· 10 10 #include <linux/mount.h> 11 11 #include <linux/xattr.h> 12 12 #include <linux/posix_acl_xattr.h> 13 + #include <linux/radix-tree.h> 13 14 #include <linux/vmalloc.h> 14 15 #include <linux/string.h> 15 16 #include <linux/compat.h> ··· 128 127 struct list_head new_refs; 129 128 struct list_head deleted_refs; 130 129 131 - struct xarray name_cache; 130 + struct radix_tree_root name_cache; 132 131 struct list_head name_cache_list; 133 132 int name_cache_size; 134 133 ··· 269 268 struct name_cache_entry { 270 269 struct list_head list; 271 270 /* 272 - * On 32bit kernels, xarray has only 32bit indices, but we need to 273 - * handle 64bit inums. We use the lower 32bit of the 64bit inum to store 274 - * it in the tree. If more than one inum would fall into the same entry, 275 - * we use inum_aliases to store the additional entries. inum_aliases is 276 - * also used to store entries with the same inum but different generations. 271 + * radix_tree has only 32bit entries but we need to handle 64bit inums. 272 + * We use the lower 32bit of the 64bit inum to store it in the tree. If 273 + * more then one inum would fall into the same entry, we use radix_list 274 + * to store the additional entries. radix_list is also used to store 275 + * entries where two entries have the same inum but different 276 + * generations. 277 277 */ 278 - struct list_head inum_aliases; 278 + struct list_head radix_list; 279 279 u64 ino; 280 280 u64 gen; 281 281 u64 parent_ino; ··· 2026 2024 } 2027 2025 2028 2026 /* 2029 - * Insert a name cache entry. On 32bit kernels the xarray index is 32bit, 2027 + * Insert a name cache entry. On 32bit kernels the radix tree index is 32bit, 2030 2028 * so we need to do some special handling in case we have clashes. This function 2031 - * takes care of this with the help of name_cache_entry::inum_aliases. 2029 + * takes care of this with the help of name_cache_entry::radix_list. 2032 2030 * In case of error, nce is kfreed. 2033 2031 */ 2034 2032 static int name_cache_insert(struct send_ctx *sctx, ··· 2037 2035 int ret = 0; 2038 2036 struct list_head *nce_head; 2039 2037 2040 - nce_head = xa_load(&sctx->name_cache, (unsigned long)nce->ino); 2038 + nce_head = radix_tree_lookup(&sctx->name_cache, 2039 + (unsigned long)nce->ino); 2041 2040 if (!nce_head) { 2042 2041 nce_head = kmalloc(sizeof(*nce_head), GFP_KERNEL); 2043 2042 if (!nce_head) { ··· 2047 2044 } 2048 2045 INIT_LIST_HEAD(nce_head); 2049 2046 2050 - ret = xa_insert(&sctx->name_cache, nce->ino, nce_head, GFP_KERNEL); 2047 + ret = radix_tree_insert(&sctx->name_cache, nce->ino, nce_head); 2051 2048 if (ret < 0) { 2052 2049 kfree(nce_head); 2053 2050 kfree(nce); 2054 2051 return ret; 2055 2052 } 2056 2053 } 2057 - list_add_tail(&nce->inum_aliases, nce_head); 2054 + list_add_tail(&nce->radix_list, nce_head); 2058 2055 list_add_tail(&nce->list, &sctx->name_cache_list); 2059 2056 sctx->name_cache_size++; 2060 2057 ··· 2066 2063 { 2067 2064 struct list_head *nce_head; 2068 2065 2069 - nce_head = xa_load(&sctx->name_cache, (unsigned long)nce->ino); 2066 + nce_head = radix_tree_lookup(&sctx->name_cache, 2067 + (unsigned long)nce->ino); 2070 2068 if (!nce_head) { 2071 2069 btrfs_err(sctx->send_root->fs_info, 2072 2070 "name_cache_delete lookup failed ino %llu cache size %d, leaking memory", 2073 2071 nce->ino, sctx->name_cache_size); 2074 2072 } 2075 2073 2076 - list_del(&nce->inum_aliases); 2074 + list_del(&nce->radix_list); 2077 2075 list_del(&nce->list); 2078 2076 sctx->name_cache_size--; 2079 2077 ··· 2082 2078 * We may not get to the final release of nce_head if the lookup fails 2083 2079 */ 2084 2080 if (nce_head && list_empty(nce_head)) { 2085 - xa_erase(&sctx->name_cache, (unsigned long)nce->ino); 2081 + radix_tree_delete(&sctx->name_cache, (unsigned long)nce->ino); 2086 2082 kfree(nce_head); 2087 2083 } 2088 2084 } ··· 2093 2089 struct list_head *nce_head; 2094 2090 struct name_cache_entry *cur; 2095 2091 2096 - nce_head = xa_load(&sctx->name_cache, (unsigned long)ino); 2092 + nce_head = radix_tree_lookup(&sctx->name_cache, (unsigned long)ino); 2097 2093 if (!nce_head) 2098 2094 return NULL; 2099 2095 2100 - list_for_each_entry(cur, nce_head, inum_aliases) { 2096 + list_for_each_entry(cur, nce_head, radix_list) { 2101 2097 if (cur->ino == ino && cur->gen == gen) 2102 2098 return cur; 2103 2099 } ··· 7522 7518 7523 7519 INIT_LIST_HEAD(&sctx->new_refs); 7524 7520 INIT_LIST_HEAD(&sctx->deleted_refs); 7525 - xa_init_flags(&sctx->name_cache, GFP_KERNEL); 7521 + INIT_RADIX_TREE(&sctx->name_cache, GFP_KERNEL); 7526 7522 INIT_LIST_HEAD(&sctx->name_cache_list); 7527 7523 7528 7524 sctx->flags = arg->flags;
+20 -4
fs/btrfs/tests/btrfs-tests.c
··· 150 150 151 151 void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info) 152 152 { 153 - unsigned long index; 154 - struct extent_buffer *eb; 153 + struct radix_tree_iter iter; 154 + void **slot; 155 155 struct btrfs_device *dev, *tmp; 156 156 157 157 if (!fs_info) ··· 163 163 164 164 test_mnt->mnt_sb->s_fs_info = NULL; 165 165 166 - xa_for_each(&fs_info->extent_buffers, index, eb) { 166 + spin_lock(&fs_info->buffer_lock); 167 + radix_tree_for_each_slot(slot, &fs_info->buffer_radix, &iter, 0) { 168 + struct extent_buffer *eb; 169 + 170 + eb = radix_tree_deref_slot_protected(slot, &fs_info->buffer_lock); 171 + if (!eb) 172 + continue; 173 + /* Shouldn't happen but that kind of thinking creates CVE's */ 174 + if (radix_tree_exception(eb)) { 175 + if (radix_tree_deref_retry(eb)) 176 + slot = radix_tree_iter_retry(&iter); 177 + continue; 178 + } 179 + slot = radix_tree_iter_resume(slot, &iter); 180 + spin_unlock(&fs_info->buffer_lock); 167 181 free_extent_buffer_stale(eb); 182 + spin_lock(&fs_info->buffer_lock); 168 183 } 184 + spin_unlock(&fs_info->buffer_lock); 169 185 170 186 btrfs_mapping_tree_free(&fs_info->mapping_tree); 171 187 list_for_each_entry_safe(dev, tmp, &fs_info->fs_devices->devices, ··· 202 186 if (!root) 203 187 return; 204 188 /* Will be freed by btrfs_free_fs_roots */ 205 - if (WARN_ON(test_bit(BTRFS_ROOT_REGISTERED, &root->state))) 189 + if (WARN_ON(test_bit(BTRFS_ROOT_IN_RADIX, &root->state))) 206 190 return; 207 191 btrfs_global_root_delete(root); 208 192 btrfs_put_root(root);
+59 -45
fs/btrfs/transaction.c
··· 23 23 #include "space-info.h" 24 24 #include "zoned.h" 25 25 26 - #define BTRFS_ROOT_TRANS_TAG XA_MARK_0 26 + #define BTRFS_ROOT_TRANS_TAG 0 27 27 28 28 /* 29 29 * Transaction states and transitions ··· 437 437 */ 438 438 smp_wmb(); 439 439 440 - spin_lock(&fs_info->fs_roots_lock); 440 + spin_lock(&fs_info->fs_roots_radix_lock); 441 441 if (root->last_trans == trans->transid && !force) { 442 - spin_unlock(&fs_info->fs_roots_lock); 442 + spin_unlock(&fs_info->fs_roots_radix_lock); 443 443 return 0; 444 444 } 445 - xa_set_mark(&fs_info->fs_roots, 446 - (unsigned long)root->root_key.objectid, 447 - BTRFS_ROOT_TRANS_TAG); 448 - spin_unlock(&fs_info->fs_roots_lock); 445 + radix_tree_tag_set(&fs_info->fs_roots_radix, 446 + (unsigned long)root->root_key.objectid, 447 + BTRFS_ROOT_TRANS_TAG); 448 + spin_unlock(&fs_info->fs_roots_radix_lock); 449 449 root->last_trans = trans->transid; 450 450 451 451 /* this is pretty tricky. We don't want to ··· 487 487 spin_unlock(&cur_trans->dropped_roots_lock); 488 488 489 489 /* Make sure we don't try to update the root at commit time */ 490 - xa_clear_mark(&fs_info->fs_roots, 491 - (unsigned long)root->root_key.objectid, 492 - BTRFS_ROOT_TRANS_TAG); 490 + spin_lock(&fs_info->fs_roots_radix_lock); 491 + radix_tree_tag_clear(&fs_info->fs_roots_radix, 492 + (unsigned long)root->root_key.objectid, 493 + BTRFS_ROOT_TRANS_TAG); 494 + spin_unlock(&fs_info->fs_roots_radix_lock); 493 495 } 494 496 495 497 int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, ··· 1404 1402 static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) 1405 1403 { 1406 1404 struct btrfs_fs_info *fs_info = trans->fs_info; 1407 - struct btrfs_root *root; 1408 - unsigned long index; 1405 + struct btrfs_root *gang[8]; 1406 + int i; 1407 + int ret; 1409 1408 1410 1409 /* 1411 1410 * At this point no one can be using this transaction to modify any tree ··· 1414 1411 */ 1415 1412 ASSERT(trans->transaction->state == TRANS_STATE_COMMIT_DOING); 1416 1413 1417 - spin_lock(&fs_info->fs_roots_lock); 1418 - xa_for_each_marked(&fs_info->fs_roots, index, root, BTRFS_ROOT_TRANS_TAG) { 1419 - int ret; 1414 + spin_lock(&fs_info->fs_roots_radix_lock); 1415 + while (1) { 1416 + ret = radix_tree_gang_lookup_tag(&fs_info->fs_roots_radix, 1417 + (void **)gang, 0, 1418 + ARRAY_SIZE(gang), 1419 + BTRFS_ROOT_TRANS_TAG); 1420 + if (ret == 0) 1421 + break; 1422 + for (i = 0; i < ret; i++) { 1423 + struct btrfs_root *root = gang[i]; 1424 + int ret2; 1420 1425 1421 - /* 1422 - * At this point we can neither have tasks logging inodes 1423 - * from a root nor trying to commit a log tree. 1424 - */ 1425 - ASSERT(atomic_read(&root->log_writers) == 0); 1426 - ASSERT(atomic_read(&root->log_commit[0]) == 0); 1427 - ASSERT(atomic_read(&root->log_commit[1]) == 0); 1426 + /* 1427 + * At this point we can neither have tasks logging inodes 1428 + * from a root nor trying to commit a log tree. 1429 + */ 1430 + ASSERT(atomic_read(&root->log_writers) == 0); 1431 + ASSERT(atomic_read(&root->log_commit[0]) == 0); 1432 + ASSERT(atomic_read(&root->log_commit[1]) == 0); 1428 1433 1429 - xa_clear_mark(&fs_info->fs_roots, 1430 - (unsigned long)root->root_key.objectid, 1431 - BTRFS_ROOT_TRANS_TAG); 1432 - spin_unlock(&fs_info->fs_roots_lock); 1434 + radix_tree_tag_clear(&fs_info->fs_roots_radix, 1435 + (unsigned long)root->root_key.objectid, 1436 + BTRFS_ROOT_TRANS_TAG); 1437 + spin_unlock(&fs_info->fs_roots_radix_lock); 1433 1438 1434 - btrfs_free_log(trans, root); 1435 - ret = btrfs_update_reloc_root(trans, root); 1436 - if (ret) 1437 - return ret; 1439 + btrfs_free_log(trans, root); 1440 + ret2 = btrfs_update_reloc_root(trans, root); 1441 + if (ret2) 1442 + return ret2; 1438 1443 1439 - /* See comments in should_cow_block() */ 1440 - clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); 1441 - smp_mb__after_atomic(); 1444 + /* see comments in should_cow_block() */ 1445 + clear_bit(BTRFS_ROOT_FORCE_COW, &root->state); 1446 + smp_mb__after_atomic(); 1442 1447 1443 - if (root->commit_root != root->node) { 1444 - list_add_tail(&root->dirty_list, 1445 - &trans->transaction->switch_commits); 1446 - btrfs_set_root_node(&root->root_item, root->node); 1448 + if (root->commit_root != root->node) { 1449 + list_add_tail(&root->dirty_list, 1450 + &trans->transaction->switch_commits); 1451 + btrfs_set_root_node(&root->root_item, 1452 + root->node); 1453 + } 1454 + 1455 + ret2 = btrfs_update_root(trans, fs_info->tree_root, 1456 + &root->root_key, 1457 + &root->root_item); 1458 + if (ret2) 1459 + return ret2; 1460 + spin_lock(&fs_info->fs_roots_radix_lock); 1461 + btrfs_qgroup_free_meta_all_pertrans(root); 1447 1462 } 1448 - 1449 - ret = btrfs_update_root(trans, fs_info->tree_root, 1450 - &root->root_key, &root->root_item); 1451 - if (ret) 1452 - return ret; 1453 - spin_lock(&fs_info->fs_roots_lock); 1454 - btrfs_qgroup_free_meta_all_pertrans(root); 1455 1463 } 1456 - spin_unlock(&fs_info->fs_roots_lock); 1464 + spin_unlock(&fs_info->fs_roots_radix_lock); 1457 1465 return 0; 1458 1466 } 1459 1467
+6 -5
fs/ceph/addr.c
··· 63 63 (CONGESTION_ON_THRESH(congestion_kb) >> 2)) 64 64 65 65 static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned int len, 66 - struct folio *folio, void **_fsdata); 66 + struct folio **foliop, void **_fsdata); 67 67 68 68 static inline struct ceph_snap_context *page_snap_context(struct page *page) 69 69 { ··· 1288 1288 } 1289 1289 1290 1290 static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned int len, 1291 - struct folio *folio, void **_fsdata) 1291 + struct folio **foliop, void **_fsdata) 1292 1292 { 1293 1293 struct inode *inode = file_inode(file); 1294 1294 struct ceph_inode_info *ci = ceph_inode(inode); 1295 1295 struct ceph_snap_context *snapc; 1296 1296 1297 - snapc = ceph_find_incompatible(folio_page(folio, 0)); 1297 + snapc = ceph_find_incompatible(folio_page(*foliop, 0)); 1298 1298 if (snapc) { 1299 1299 int r; 1300 1300 1301 - folio_unlock(folio); 1302 - folio_put(folio); 1301 + folio_unlock(*foliop); 1302 + folio_put(*foliop); 1303 + *foliop = NULL; 1303 1304 if (IS_ERR(snapc)) 1304 1305 return PTR_ERR(snapc); 1305 1306
+10 -7
fs/netfs/buffered_read.c
··· 319 319 * conflicting writes once the folio is grabbed and locked. It is passed a 320 320 * pointer to the fsdata cookie that gets returned to the VM to be passed to 321 321 * write_end. It is permitted to sleep. It should return 0 if the request 322 - * should go ahead; unlock the folio and return -EAGAIN to cause the folio to 323 - * be regot; or return an error. 322 + * should go ahead or it may return an error. It may also unlock and put the 323 + * folio, provided it sets ``*foliop`` to NULL, in which case a return of 0 324 + * will cause the folio to be re-got and the process to be retried. 324 325 * 325 326 * The calling netfs must initialise a netfs context contiguous to the vfs 326 327 * inode before calling this. ··· 349 348 350 349 if (ctx->ops->check_write_begin) { 351 350 /* Allow the netfs (eg. ceph) to flush conflicts. */ 352 - ret = ctx->ops->check_write_begin(file, pos, len, folio, _fsdata); 351 + ret = ctx->ops->check_write_begin(file, pos, len, &folio, _fsdata); 353 352 if (ret < 0) { 354 353 trace_netfs_failure(NULL, NULL, ret, netfs_fail_check_write_begin); 355 - if (ret == -EAGAIN) 356 - goto retry; 357 354 goto error; 358 355 } 356 + if (!folio) 357 + goto retry; 359 358 } 360 359 361 360 if (folio_test_uptodate(folio)) ··· 417 416 error_put: 418 417 netfs_put_request(rreq, false, netfs_rreq_trace_put_failed); 419 418 error: 420 - folio_unlock(folio); 421 - folio_put(folio); 419 + if (folio) { 420 + folio_unlock(folio); 421 + folio_put(folio); 422 + } 422 423 _leave(" = %d", ret); 423 424 return ret; 424 425 }
+1 -1
fs/remap_range.c
··· 547 547 else if (deduped < 0) 548 548 info->status = deduped; 549 549 else 550 - info->bytes_deduped = deduped; 550 + info->bytes_deduped = len; 551 551 552 552 next_fdput: 553 553 fdput(dst_fd);
+36 -29
include/asm-generic/tlb.h
··· 158 158 * Useful if your architecture doesn't use IPIs for remote TLB invalidates 159 159 * and therefore doesn't naturally serialize with software page-table walkers. 160 160 * 161 + * MMU_GATHER_NO_FLUSH_CACHE 162 + * 163 + * Indicates the architecture has flush_cache_range() but it needs *NOT* be called 164 + * before unmapping a VMA. 165 + * 166 + * NOTE: strictly speaking we shouldn't have this knob and instead rely on 167 + * flush_cache_range() being a NOP, except Sparc64 seems to be 168 + * different here. 169 + * 170 + * MMU_GATHER_MERGE_VMAS 171 + * 172 + * Indicates the architecture wants to merge ranges over VMAs; typical when 173 + * multiple range invalidates are more expensive than a full invalidate. 174 + * 161 175 * MMU_GATHER_NO_RANGE 162 176 * 163 - * Use this if your architecture lacks an efficient flush_tlb_range(). 177 + * Use this if your architecture lacks an efficient flush_tlb_range(). This 178 + * option implies MMU_GATHER_MERGE_VMAS above. 164 179 * 165 180 * MMU_GATHER_NO_GATHER 166 181 * ··· 303 288 */ 304 289 unsigned int vma_exec : 1; 305 290 unsigned int vma_huge : 1; 291 + unsigned int vma_pfn : 1; 306 292 307 293 unsigned int batch_count; 308 294 ··· 350 334 351 335 #ifdef CONFIG_MMU_GATHER_NO_RANGE 352 336 353 - #if defined(tlb_flush) || defined(tlb_start_vma) || defined(tlb_end_vma) 354 - #error MMU_GATHER_NO_RANGE relies on default tlb_flush(), tlb_start_vma() and tlb_end_vma() 337 + #if defined(tlb_flush) 338 + #error MMU_GATHER_NO_RANGE relies on default tlb_flush() 355 339 #endif 356 340 357 341 /* ··· 371 355 static inline void 372 356 tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma) { } 373 357 374 - #define tlb_end_vma tlb_end_vma 375 - static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma) { } 376 - 377 358 #else /* CONFIG_MMU_GATHER_NO_RANGE */ 378 359 379 360 #ifndef tlb_flush 380 - 381 - #if defined(tlb_start_vma) || defined(tlb_end_vma) 382 - #error Default tlb_flush() relies on default tlb_start_vma() and tlb_end_vma() 383 - #endif 384 - 385 361 /* 386 362 * When an architecture does not provide its own tlb_flush() implementation 387 363 * but does have a reasonably efficient flush_vma_range() implementation ··· 393 385 flush_tlb_range(&vma, tlb->start, tlb->end); 394 386 } 395 387 } 388 + #endif 389 + 390 + #endif /* CONFIG_MMU_GATHER_NO_RANGE */ 396 391 397 392 static inline void 398 393 tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma) ··· 413 402 */ 414 403 tlb->vma_huge = is_vm_hugetlb_page(vma); 415 404 tlb->vma_exec = !!(vma->vm_flags & VM_EXEC); 405 + tlb->vma_pfn = !!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)); 416 406 } 417 - 418 - #else 419 - 420 - static inline void 421 - tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma) { } 422 - 423 - #endif 424 - 425 - #endif /* CONFIG_MMU_GATHER_NO_RANGE */ 426 407 427 408 static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) 428 409 { ··· 489 486 * case where we're doing a full MM flush. When we're doing a munmap, 490 487 * the vmas are adjusted to only cover the region to be torn down. 491 488 */ 492 - #ifndef tlb_start_vma 493 489 static inline void tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma) 494 490 { 495 491 if (tlb->fullmm) 496 492 return; 497 493 498 494 tlb_update_vma_flags(tlb, vma); 495 + #ifndef CONFIG_MMU_GATHER_NO_FLUSH_CACHE 499 496 flush_cache_range(vma, vma->vm_start, vma->vm_end); 500 - } 501 497 #endif 498 + } 502 499 503 - #ifndef tlb_end_vma 504 500 static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma) 505 501 { 506 502 if (tlb->fullmm) 507 503 return; 508 504 509 505 /* 510 - * Do a TLB flush and reset the range at VMA boundaries; this avoids 511 - * the ranges growing with the unused space between consecutive VMAs, 512 - * but also the mmu_gather::vma_* flags from tlb_start_vma() rely on 513 - * this. 506 + * VM_PFNMAP is more fragile because the core mm will not track the 507 + * page mapcount -- there might not be page-frames for these PFNs after 508 + * all. Force flush TLBs for such ranges to avoid munmap() vs 509 + * unmap_mapping_range() races. 514 510 */ 515 - tlb_flush_mmu_tlbonly(tlb); 511 + if (tlb->vma_pfn || !IS_ENABLED(CONFIG_MMU_GATHER_MERGE_VMAS)) { 512 + /* 513 + * Do a TLB flush and reset the range at VMA boundaries; this avoids 514 + * the ranges growing with the unused space between consecutive VMAs. 515 + */ 516 + tlb_flush_mmu_tlbonly(tlb); 517 + } 516 518 } 517 - #endif 518 519 519 520 /* 520 521 * tlb_flush_{pte|pmd|pud|p4d}_range() adjust the tlb->start and tlb->end,
+10 -1
include/linux/kvm_host.h
··· 1822 1822 STATS_DESC_PEAK(SCOPE, name, KVM_STATS_UNIT_NONE, \ 1823 1823 KVM_STATS_BASE_POW10, 0) 1824 1824 1825 + /* Instantaneous boolean value, read only */ 1826 + #define STATS_DESC_IBOOLEAN(SCOPE, name) \ 1827 + STATS_DESC_INSTANT(SCOPE, name, KVM_STATS_UNIT_BOOLEAN, \ 1828 + KVM_STATS_BASE_POW10, 0) 1829 + /* Peak (sticky) boolean value, read/write */ 1830 + #define STATS_DESC_PBOOLEAN(SCOPE, name) \ 1831 + STATS_DESC_PEAK(SCOPE, name, KVM_STATS_UNIT_BOOLEAN, \ 1832 + KVM_STATS_BASE_POW10, 0) 1833 + 1825 1834 /* Cumulative time in nanosecond */ 1826 1835 #define STATS_DESC_TIME_NSEC(SCOPE, name) \ 1827 1836 STATS_DESC_CUMULATIVE(SCOPE, name, KVM_STATS_UNIT_SECONDS, \ ··· 1862 1853 HALT_POLL_HIST_COUNT), \ 1863 1854 STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_wait_hist, \ 1864 1855 HALT_POLL_HIST_COUNT), \ 1865 - STATS_DESC_ICOUNTER(VCPU_GENERIC, blocking) 1856 + STATS_DESC_IBOOLEAN(VCPU_GENERIC, blocking) 1866 1857 1867 1858 extern struct dentry *kvm_debugfs_dir; 1868 1859
+1 -1
include/linux/netfs.h
··· 214 214 void (*issue_read)(struct netfs_io_subrequest *subreq); 215 215 bool (*is_still_valid)(struct netfs_io_request *rreq); 216 216 int (*check_write_begin)(struct file *file, loff_t pos, unsigned len, 217 - struct folio *folio, void **_fsdata); 217 + struct folio **foliop, void **_fsdata); 218 218 void (*done)(struct netfs_io_request *rreq); 219 219 }; 220 220
+1 -1
include/linux/reset.h
··· 731 731 devm_reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs, 732 732 struct reset_control_bulk_data *rstcs) 733 733 { 734 - return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, true); 734 + return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, true); 735 735 } 736 736 737 737 /**
+5
include/linux/serial_core.h
··· 390 390 static inline int setup_earlycon(char *buf) { return 0; } 391 391 #endif 392 392 393 + static inline bool uart_console_enabled(struct uart_port *port) 394 + { 395 + return uart_console(port) && (port->cons->flags & CON_ENABLED); 396 + } 397 + 393 398 struct uart_port *uart_get_console(struct uart_port *ports, int nr, 394 399 struct console *c); 395 400 int uart_parse_earlycon(char *p, unsigned char *iotype, resource_size_t *addr,
+1
include/linux/stmmac.h
··· 260 260 bool has_crossts; 261 261 int int_snapshot_num; 262 262 int ext_snapshot_num; 263 + bool int_snapshot_en; 263 264 bool ext_snapshot_en; 264 265 bool multi_msi_en; 265 266 int msi_mac_vec;
+20
include/net/amt.h
··· 78 78 79 79 #define AMT_STATUS_MAX (__AMT_STATUS_MAX - 1) 80 80 81 + /* Gateway events only */ 82 + enum amt_event { 83 + AMT_EVENT_NONE, 84 + AMT_EVENT_RECEIVE, 85 + AMT_EVENT_SEND_DISCOVERY, 86 + AMT_EVENT_SEND_REQUEST, 87 + __AMT_EVENT_MAX, 88 + }; 89 + 81 90 struct amt_header { 82 91 #if defined(__LITTLE_ENDIAN_BITFIELD) 83 92 u8 type:4, ··· 301 292 struct hlist_head sources[]; 302 293 }; 303 294 295 + #define AMT_MAX_EVENTS 16 296 + struct amt_events { 297 + enum amt_event event; 298 + struct sk_buff *skb; 299 + }; 300 + 304 301 struct amt_dev { 305 302 struct net_device *dev; 306 303 struct net_device *stream_dev; ··· 323 308 struct delayed_work req_wq; 324 309 /* Protected by RTNL */ 325 310 struct delayed_work secret_wq; 311 + struct work_struct event_wq; 326 312 /* AMT status */ 327 313 enum amt_status status; 328 314 /* Generated key */ ··· 361 345 /* Used only in gateway mode */ 362 346 u64 mac:48, 363 347 reserved:16; 348 + /* AMT gateway side message handler queue */ 349 + struct amt_events events[AMT_MAX_EVENTS]; 350 + u8 event_idx; 351 + u8 nr_events; 364 352 }; 365 353 366 354 #define AMT_TOS 0xc0
+1 -1
include/net/inet_hashtables.h
··· 179 179 int dif, int sdif) 180 180 { 181 181 #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) 182 - return inet_bound_dev_eq(!!net->ipv4.sysctl_tcp_l3mdev_accept, 182 + return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept), 183 183 bound_dev_if, dif, sdif); 184 184 #else 185 185 return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
+5 -4
include/net/inet_sock.h
··· 107 107 108 108 static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb) 109 109 { 110 - if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept) 110 + if (!sk->sk_mark && 111 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept)) 111 112 return skb->mark; 112 113 113 114 return sk->sk_mark; ··· 121 120 #ifdef CONFIG_NET_L3_MASTER_DEV 122 121 struct net *net = sock_net(sk); 123 122 124 - if (!bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept) 123 + if (!bound_dev_if && READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept)) 125 124 return l3mdev_master_ifindex_by_index(net, skb->skb_iif); 126 125 #endif 127 126 ··· 133 132 #ifdef CONFIG_NET_L3_MASTER_DEV 134 133 struct net *net = sock_net(sk); 135 134 136 - if (!net->ipv4.sysctl_tcp_l3mdev_accept) 135 + if (!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept)) 137 136 return l3mdev_master_ifindex_by_index(net, 138 137 sk->sk_bound_dev_if); 139 138 #endif ··· 375 374 static inline bool inet_can_nonlocal_bind(struct net *net, 376 375 struct inet_sock *inet) 377 376 { 378 - return net->ipv4.sysctl_ip_nonlocal_bind || 377 + return READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind) || 379 378 inet->freebind || inet->transparent; 380 379 } 381 380
+3 -3
include/net/ip.h
··· 357 357 358 358 static inline bool inet_port_requires_bind_service(struct net *net, unsigned short port) 359 359 { 360 - return port < net->ipv4.sysctl_ip_prot_sock; 360 + return port < READ_ONCE(net->ipv4.sysctl_ip_prot_sock); 361 361 } 362 362 363 363 #else ··· 384 384 void ip_static_sysctl_init(void); 385 385 386 386 #define IP4_REPLY_MARK(net, mark) \ 387 - ((net)->ipv4.sysctl_fwmark_reflect ? (mark) : 0) 387 + (READ_ONCE((net)->ipv4.sysctl_fwmark_reflect) ? (mark) : 0) 388 388 389 389 static inline bool ip_is_fragment(const struct iphdr *iph) 390 390 { ··· 446 446 struct net *net = dev_net(dst->dev); 447 447 unsigned int mtu; 448 448 449 - if (net->ipv4.sysctl_ip_fwd_use_pmtu || 449 + if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) || 450 450 ip_mtu_locked(dst) || 451 451 !forwarding) { 452 452 mtu = rt->rt_pmtu;
-4
include/net/protocol.h
··· 35 35 36 36 /* This is used to register protocols. */ 37 37 struct net_protocol { 38 - int (*early_demux)(struct sk_buff *skb); 39 - int (*early_demux_handler)(struct sk_buff *skb); 40 38 int (*handler)(struct sk_buff *skb); 41 39 42 40 /* This returns an error if we weren't able to handle the error. */ ··· 50 52 51 53 #if IS_ENABLED(CONFIG_IPV6) 52 54 struct inet6_protocol { 53 - void (*early_demux)(struct sk_buff *skb); 54 - void (*early_demux_handler)(struct sk_buff *skb); 55 55 int (*handler)(struct sk_buff *skb); 56 56 57 57 /* This returns an error if we weren't able to handle the error. */
+1 -1
include/net/route.h
··· 369 369 struct net *net = dev_net(dst->dev); 370 370 371 371 if (hoplimit == 0) 372 - hoplimit = net->ipv4.sysctl_ip_default_ttl; 372 + hoplimit = READ_ONCE(net->ipv4.sysctl_ip_default_ttl); 373 373 return hoplimit; 374 374 } 375 375
+12 -8
include/net/tcp.h
··· 936 936 937 937 INDIRECT_CALLABLE_DECLARE(void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb)); 938 938 INDIRECT_CALLABLE_DECLARE(int tcp_v6_rcv(struct sk_buff *skb)); 939 - INDIRECT_CALLABLE_DECLARE(void tcp_v6_early_demux(struct sk_buff *skb)); 939 + void tcp_v6_early_demux(struct sk_buff *skb); 940 940 941 941 #endif 942 942 ··· 1407 1407 struct tcp_sock *tp = tcp_sk(sk); 1408 1408 s32 delta; 1409 1409 1410 - if (!sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle || tp->packets_out || 1411 - ca_ops->cong_control) 1410 + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle) || 1411 + tp->packets_out || ca_ops->cong_control) 1412 1412 return; 1413 1413 delta = tcp_jiffies32 - tp->lsndtime; 1414 1414 if (delta > inet_csk(sk)->icsk_rto) ··· 1497 1497 { 1498 1498 struct net *net = sock_net((struct sock *)tp); 1499 1499 1500 - return tp->keepalive_intvl ? : net->ipv4.sysctl_tcp_keepalive_intvl; 1500 + return tp->keepalive_intvl ? : 1501 + READ_ONCE(net->ipv4.sysctl_tcp_keepalive_intvl); 1501 1502 } 1502 1503 1503 1504 static inline int keepalive_time_when(const struct tcp_sock *tp) 1504 1505 { 1505 1506 struct net *net = sock_net((struct sock *)tp); 1506 1507 1507 - return tp->keepalive_time ? : net->ipv4.sysctl_tcp_keepalive_time; 1508 + return tp->keepalive_time ? : 1509 + READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time); 1508 1510 } 1509 1511 1510 1512 static inline int keepalive_probes(const struct tcp_sock *tp) 1511 1513 { 1512 1514 struct net *net = sock_net((struct sock *)tp); 1513 1515 1514 - return tp->keepalive_probes ? : net->ipv4.sysctl_tcp_keepalive_probes; 1516 + return tp->keepalive_probes ? : 1517 + READ_ONCE(net->ipv4.sysctl_tcp_keepalive_probes); 1515 1518 } 1516 1519 1517 1520 static inline u32 keepalive_time_elapsed(const struct tcp_sock *tp) ··· 1527 1524 1528 1525 static inline int tcp_fin_time(const struct sock *sk) 1529 1526 { 1530 - int fin_timeout = tcp_sk(sk)->linger2 ? : sock_net(sk)->ipv4.sysctl_tcp_fin_timeout; 1527 + int fin_timeout = tcp_sk(sk)->linger2 ? : 1528 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fin_timeout); 1531 1529 const int rto = inet_csk(sk)->icsk_rto; 1532 1530 1533 1531 if (fin_timeout < (rto << 2) - (rto >> 1)) ··· 2031 2027 static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp) 2032 2028 { 2033 2029 struct net *net = sock_net((struct sock *)tp); 2034 - return tp->notsent_lowat ?: net->ipv4.sysctl_tcp_notsent_lowat; 2030 + return tp->notsent_lowat ?: READ_ONCE(net->ipv4.sysctl_tcp_notsent_lowat); 2035 2031 } 2036 2032 2037 2033 bool tcp_stream_memory_free(const struct sock *sk, int wake);
+2 -2
include/net/udp.h
··· 168 168 typedef struct sock *(*udp_lookup_t)(const struct sk_buff *skb, __be16 sport, 169 169 __be16 dport); 170 170 171 - INDIRECT_CALLABLE_DECLARE(void udp_v6_early_demux(struct sk_buff *)); 171 + void udp_v6_early_demux(struct sk_buff *skb); 172 172 INDIRECT_CALLABLE_DECLARE(int udpv6_rcv(struct sk_buff *)); 173 173 174 174 struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, ··· 239 239 int dif, int sdif) 240 240 { 241 241 #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) 242 - return inet_bound_dev_eq(!!net->ipv4.sysctl_udp_l3mdev_accept, 242 + return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_udp_l3mdev_accept), 243 243 bound_dev_if, dif, sdif); 244 244 #else 245 245 return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
+7 -4
include/uapi/linux/input.h
··· 78 78 * Note that input core does not clamp reported values to the 79 79 * [minimum, maximum] limits, such task is left to userspace. 80 80 * 81 - * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z) 82 - * is reported in units per millimeter (units/mm), resolution 83 - * for rotational axes (ABS_RX, ABS_RY, ABS_RZ) is reported 84 - * in units per radian. 81 + * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z, 82 + * ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units 83 + * per millimeter (units/mm), resolution for rotational axes 84 + * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian. 85 + * The resolution for the size axes (ABS_MT_TOUCH_MAJOR, 86 + * ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR) 87 + * is reported in units per millimeter (units/mm). 85 88 * When INPUT_PROP_ACCELEROMETER is set the resolution changes. 86 89 * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in 87 90 * units per g (units/g) and in units per degree per second
+1
include/uapi/linux/kvm.h
··· 2083 2083 #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT) 2084 2084 #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT) 2085 2085 #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT) 2086 + #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT) 2086 2087 #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES 2087 2088 2088 2089 #define KVM_STATS_BASE_SHIFT 8
+31 -14
kernel/events/core.c
··· 6253 6253 6254 6254 if (!atomic_inc_not_zero(&event->rb->mmap_count)) { 6255 6255 /* 6256 - * Raced against perf_mmap_close() through 6257 - * perf_event_set_output(). Try again, hope for better 6258 - * luck. 6256 + * Raced against perf_mmap_close(); remove the 6257 + * event and try again. 6259 6258 */ 6259 + ring_buffer_attach(event, NULL); 6260 6260 mutex_unlock(&event->mmap_mutex); 6261 6261 goto again; 6262 6262 } ··· 11829 11829 goto out; 11830 11830 } 11831 11831 11832 + static void mutex_lock_double(struct mutex *a, struct mutex *b) 11833 + { 11834 + if (b < a) 11835 + swap(a, b); 11836 + 11837 + mutex_lock(a); 11838 + mutex_lock_nested(b, SINGLE_DEPTH_NESTING); 11839 + } 11840 + 11832 11841 static int 11833 11842 perf_event_set_output(struct perf_event *event, struct perf_event *output_event) 11834 11843 { 11835 11844 struct perf_buffer *rb = NULL; 11836 11845 int ret = -EINVAL; 11837 11846 11838 - if (!output_event) 11847 + if (!output_event) { 11848 + mutex_lock(&event->mmap_mutex); 11839 11849 goto set; 11850 + } 11840 11851 11841 11852 /* don't allow circular references */ 11842 11853 if (event == output_event) ··· 11885 11874 event->pmu != output_event->pmu) 11886 11875 goto out; 11887 11876 11877 + /* 11878 + * Hold both mmap_mutex to serialize against perf_mmap_close(). Since 11879 + * output_event is already on rb->event_list, and the list iteration 11880 + * restarts after every removal, it is guaranteed this new event is 11881 + * observed *OR* if output_event is already removed, it's guaranteed we 11882 + * observe !rb->mmap_count. 11883 + */ 11884 + mutex_lock_double(&event->mmap_mutex, &output_event->mmap_mutex); 11888 11885 set: 11889 - mutex_lock(&event->mmap_mutex); 11890 11886 /* Can't redirect output if we've got an active mmap() */ 11891 11887 if (atomic_read(&event->mmap_count)) 11892 11888 goto unlock; ··· 11903 11885 rb = ring_buffer_get(output_event); 11904 11886 if (!rb) 11905 11887 goto unlock; 11888 + 11889 + /* did we race against perf_mmap_close() */ 11890 + if (!atomic_read(&rb->mmap_count)) { 11891 + ring_buffer_put(rb); 11892 + goto unlock; 11893 + } 11906 11894 } 11907 11895 11908 11896 ring_buffer_attach(event, rb); ··· 11916 11892 ret = 0; 11917 11893 unlock: 11918 11894 mutex_unlock(&event->mmap_mutex); 11895 + if (output_event) 11896 + mutex_unlock(&output_event->mmap_mutex); 11919 11897 11920 11898 out: 11921 11899 return ret; 11922 - } 11923 - 11924 - static void mutex_lock_double(struct mutex *a, struct mutex *b) 11925 - { 11926 - if (b < a) 11927 - swap(a, b); 11928 - 11929 - mutex_lock(a); 11930 - mutex_lock_nested(b, SINGLE_DEPTH_NESTING); 11931 11900 } 11932 11901 11933 11902 static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id)
+11 -2
kernel/printk/printk.c
··· 3380 3380 diff = 0; 3381 3381 3382 3382 console_lock(); 3383 + 3383 3384 for_each_console(c) { 3384 3385 if (con && con != c) 3385 3386 continue; ··· 3390 3389 if (printk_seq < seq) 3391 3390 diff += seq - printk_seq; 3392 3391 } 3393 - console_unlock(); 3394 3392 3395 - if (diff != last_diff && reset_on_progress) 3393 + /* 3394 + * If consoles are suspended, it cannot be expected that they 3395 + * make forward progress, so timeout immediately. @diff is 3396 + * still used to return a valid flush status. 3397 + */ 3398 + if (console_suspended) 3399 + remaining = 0; 3400 + else if (diff != last_diff && reset_on_progress) 3396 3401 remaining = timeout_ms; 3402 + 3403 + console_unlock(); 3397 3404 3398 3405 if (diff == 0 || remaining == 0) 3399 3406 break;
+11 -9
kernel/sysctl.c
··· 2135 2135 .extra1 = SYSCTL_ZERO, 2136 2136 .extra2 = SYSCTL_TWO_HUNDRED, 2137 2137 }, 2138 + #ifdef CONFIG_NUMA 2139 + { 2140 + .procname = "numa_stat", 2141 + .data = &sysctl_vm_numa_stat, 2142 + .maxlen = sizeof(int), 2143 + .mode = 0644, 2144 + .proc_handler = sysctl_vm_numa_stat_handler, 2145 + .extra1 = SYSCTL_ZERO, 2146 + .extra2 = SYSCTL_ONE, 2147 + }, 2148 + #endif 2138 2149 #ifdef CONFIG_HUGETLB_PAGE 2139 2150 { 2140 2151 .procname = "nr_hugepages", ··· 2161 2150 .maxlen = sizeof(unsigned long), 2162 2151 .mode = 0644, 2163 2152 .proc_handler = &hugetlb_mempolicy_sysctl_handler, 2164 - }, 2165 - { 2166 - .procname = "numa_stat", 2167 - .data = &sysctl_vm_numa_stat, 2168 - .maxlen = sizeof(int), 2169 - .mode = 0644, 2170 - .proc_handler = sysctl_vm_numa_stat_handler, 2171 - .extra1 = SYSCTL_ZERO, 2172 - .extra2 = SYSCTL_ONE, 2173 2153 }, 2174 2154 #endif 2175 2155 {
+37 -16
kernel/watch_queue.c
··· 34 34 #define WATCH_QUEUE_NOTE_SIZE 128 35 35 #define WATCH_QUEUE_NOTES_PER_PAGE (PAGE_SIZE / WATCH_QUEUE_NOTE_SIZE) 36 36 37 + /* 38 + * This must be called under the RCU read-lock, which makes 39 + * sure that the wqueue still exists. It can then take the lock, 40 + * and check that the wqueue hasn't been destroyed, which in 41 + * turn makes sure that the notification pipe still exists. 42 + */ 43 + static inline bool lock_wqueue(struct watch_queue *wqueue) 44 + { 45 + spin_lock_bh(&wqueue->lock); 46 + if (unlikely(wqueue->defunct)) { 47 + spin_unlock_bh(&wqueue->lock); 48 + return false; 49 + } 50 + return true; 51 + } 52 + 53 + static inline void unlock_wqueue(struct watch_queue *wqueue) 54 + { 55 + spin_unlock_bh(&wqueue->lock); 56 + } 57 + 37 58 static void watch_queue_pipe_buf_release(struct pipe_inode_info *pipe, 38 59 struct pipe_buffer *buf) 39 60 { ··· 90 69 91 70 /* 92 71 * Post a notification to a watch queue. 72 + * 73 + * Must be called with the RCU lock for reading, and the 74 + * watch_queue lock held, which guarantees that the pipe 75 + * hasn't been released. 93 76 */ 94 77 static bool post_one_notification(struct watch_queue *wqueue, 95 78 struct watch_notification *n) ··· 109 84 return false; 110 85 111 86 spin_lock_irq(&pipe->rd_wait.lock); 112 - 113 - if (wqueue->defunct) 114 - goto out; 115 87 116 88 mask = pipe->ring_size - 1; 117 89 head = pipe->head; ··· 225 203 if (security_post_notification(watch->cred, cred, n) < 0) 226 204 continue; 227 205 228 - post_one_notification(wqueue, n); 206 + if (lock_wqueue(wqueue)) { 207 + post_one_notification(wqueue, n); 208 + unlock_wqueue(wqueue); 209 + } 229 210 } 230 211 231 212 rcu_read_unlock(); ··· 487 462 return -EAGAIN; 488 463 } 489 464 490 - spin_lock_bh(&wqueue->lock); 491 - kref_get(&wqueue->usage); 492 - kref_get(&watch->usage); 493 - hlist_add_head(&watch->queue_node, &wqueue->watches); 494 - spin_unlock_bh(&wqueue->lock); 465 + if (lock_wqueue(wqueue)) { 466 + kref_get(&wqueue->usage); 467 + kref_get(&watch->usage); 468 + hlist_add_head(&watch->queue_node, &wqueue->watches); 469 + unlock_wqueue(wqueue); 470 + } 495 471 496 472 hlist_add_head(&watch->list_node, &wlist->watchers); 497 473 return 0; ··· 546 520 547 521 wqueue = rcu_dereference(watch->queue); 548 522 549 - /* We don't need the watch list lock for the next bit as RCU is 550 - * protecting *wqueue from deallocation. 551 - */ 552 - if (wqueue) { 523 + if (lock_wqueue(wqueue)) { 553 524 post_one_notification(wqueue, &n.watch); 554 - 555 - spin_lock_bh(&wqueue->lock); 556 525 557 526 if (!hlist_unhashed(&watch->queue_node)) { 558 527 hlist_del_init_rcu(&watch->queue_node); 559 528 put_watch(watch); 560 529 } 561 530 562 - spin_unlock_bh(&wqueue->lock); 531 + unlock_wqueue(wqueue); 563 532 } 564 533 565 534 if (wlist->release_watch) {
+3
lib/Kconfig.ubsan
··· 84 84 config UBSAN_DIV_ZERO 85 85 bool "Perform checking for integer divide-by-zero" 86 86 depends on $(cc-option,-fsanitize=integer-divide-by-zero) 87 + # https://github.com/ClangBuiltLinux/linux/issues/1657 88 + # https://github.com/llvm/llvm-project/issues/56289 89 + depends on !CC_IS_CLANG 87 90 help 88 91 This option enables -fsanitize=integer-divide-by-zero which checks 89 92 for integer division by zero. This is effectively redundant with the
+2 -2
net/core/filter.c
··· 7084 7084 if (sk->sk_protocol != IPPROTO_TCP || sk->sk_state != TCP_LISTEN) 7085 7085 return -EINVAL; 7086 7086 7087 - if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies) 7087 + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies)) 7088 7088 return -EINVAL; 7089 7089 7090 7090 if (!th->ack || th->rst || th->syn) ··· 7159 7159 if (sk->sk_protocol != IPPROTO_TCP || sk->sk_state != TCP_LISTEN) 7160 7160 return -EINVAL; 7161 7161 7162 - if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies) 7162 + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies)) 7163 7163 return -ENOENT; 7164 7164 7165 7165 if (!th->syn || th->ack || th->fin || th->rst)
+2 -2
net/core/secure_seq.c
··· 64 64 .daddr = *(struct in6_addr *)daddr, 65 65 }; 66 66 67 - if (net->ipv4.sysctl_tcp_timestamps != 1) 67 + if (READ_ONCE(net->ipv4.sysctl_tcp_timestamps) != 1) 68 68 return 0; 69 69 70 70 ts_secret_init(); ··· 120 120 #ifdef CONFIG_INET 121 121 u32 secure_tcp_ts_off(const struct net *net, __be32 saddr, __be32 daddr) 122 122 { 123 - if (net->ipv4.sysctl_tcp_timestamps != 1) 123 + if (READ_ONCE(net->ipv4.sysctl_tcp_timestamps) != 1) 124 124 return 0; 125 125 126 126 ts_secret_init();
+2 -2
net/core/sock_reuseport.c
··· 387 387 prog = rcu_dereference_protected(reuse->prog, 388 388 lockdep_is_held(&reuseport_lock)); 389 389 390 - if (sock_net(sk)->ipv4.sysctl_tcp_migrate_req || 390 + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req) || 391 391 (prog && prog->expected_attach_type == BPF_SK_REUSEPORT_SELECT_OR_MIGRATE)) { 392 392 /* Migration capable, move sk from the listening section 393 393 * to the closed section. ··· 545 545 hash = migrating_sk->sk_hash; 546 546 prog = rcu_dereference(reuse->prog); 547 547 if (!prog || prog->expected_attach_type != BPF_SK_REUSEPORT_SELECT_OR_MIGRATE) { 548 - if (sock_net(sk)->ipv4.sysctl_tcp_migrate_req) 548 + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req)) 549 549 goto select_by_hash; 550 550 goto failure; 551 551 }
+4 -3
net/dsa/port.c
··· 248 248 struct netlink_ext_ack extack = {0}; 249 249 bool change_vlan_filtering = false; 250 250 struct dsa_switch *ds = dp->ds; 251 + struct dsa_port *other_dp; 251 252 bool vlan_filtering; 252 253 int err; 253 254 ··· 271 270 * VLAN-aware bridge. 272 271 */ 273 272 if (change_vlan_filtering && ds->vlan_filtering_is_global) { 274 - dsa_switch_for_each_port(dp, ds) { 275 - struct net_device *br = dsa_port_bridge_dev_get(dp); 273 + dsa_switch_for_each_port(other_dp, ds) { 274 + struct net_device *br = dsa_port_bridge_dev_get(other_dp); 276 275 277 276 if (br && br_vlan_enabled(br)) { 278 277 change_vlan_filtering = false; ··· 800 799 ds->vlan_filtering = vlan_filtering; 801 800 802 801 dsa_switch_for_each_user_port(other_dp, ds) { 803 - struct net_device *slave = dp->slave; 802 + struct net_device *slave = other_dp->slave; 804 803 805 804 /* We might be called in the unbind path, so not 806 805 * all slave devices might still be registered.
+4 -14
net/ipv4/af_inet.c
··· 217 217 * because the socket was in TCP_LISTEN state previously but 218 218 * was shutdown() rather than close(). 219 219 */ 220 - tcp_fastopen = sock_net(sk)->ipv4.sysctl_tcp_fastopen; 220 + tcp_fastopen = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen); 221 221 if ((tcp_fastopen & TFO_SERVER_WO_SOCKOPT1) && 222 222 (tcp_fastopen & TFO_SERVER_ENABLE) && 223 223 !inet_csk(sk)->icsk_accept_queue.fastopenq.max_qlen) { ··· 335 335 inet->hdrincl = 1; 336 336 } 337 337 338 - if (net->ipv4.sysctl_ip_no_pmtu_disc) 338 + if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) 339 339 inet->pmtudisc = IP_PMTUDISC_DONT; 340 340 else 341 341 inet->pmtudisc = IP_PMTUDISC_WANT; ··· 1711 1711 }; 1712 1712 #endif 1713 1713 1714 - /* thinking of making this const? Don't. 1715 - * early_demux can change based on sysctl. 1716 - */ 1717 - static struct net_protocol tcp_protocol = { 1718 - .early_demux = tcp_v4_early_demux, 1719 - .early_demux_handler = tcp_v4_early_demux, 1714 + static const struct net_protocol tcp_protocol = { 1720 1715 .handler = tcp_v4_rcv, 1721 1716 .err_handler = tcp_v4_err, 1722 1717 .no_policy = 1, 1723 1718 .icmp_strict_tag_validation = 1, 1724 1719 }; 1725 1720 1726 - /* thinking of making this const? Don't. 1727 - * early_demux can change based on sysctl. 1728 - */ 1729 - static struct net_protocol udp_protocol = { 1730 - .early_demux = udp_v4_early_demux, 1731 - .early_demux_handler = udp_v4_early_demux, 1721 + static const struct net_protocol udp_protocol = { 1732 1722 .handler = udp_rcv, 1733 1723 .err_handler = udp_err, 1734 1724 .no_policy = 1,
+1 -1
net/ipv4/ah4.c
··· 507 507 508 508 if (aalg_desc->uinfo.auth.icv_fullbits/8 != 509 509 crypto_ahash_digestsize(ahash)) { 510 - pr_info("%s: %s digestsize %u != %hu\n", 510 + pr_info("%s: %s digestsize %u != %u\n", 511 511 __func__, x->aalg->alg_name, 512 512 crypto_ahash_digestsize(ahash), 513 513 aalg_desc->uinfo.auth.icv_fullbits / 8);
+1 -1
net/ipv4/esp4.c
··· 1106 1106 err = -EINVAL; 1107 1107 if (aalg_desc->uinfo.auth.icv_fullbits / 8 != 1108 1108 crypto_aead_authsize(aead)) { 1109 - pr_info("ESP: %s digestsize %u != %hu\n", 1109 + pr_info("ESP: %s digestsize %u != %u\n", 1110 1110 x->aalg->alg_name, 1111 1111 crypto_aead_authsize(aead), 1112 1112 aalg_desc->uinfo.auth.icv_fullbits / 8);
+1 -1
net/ipv4/fib_semantics.c
··· 2217 2217 } 2218 2218 2219 2219 change_nexthops(fi) { 2220 - if (net->ipv4.sysctl_fib_multipath_use_neigh) { 2220 + if (READ_ONCE(net->ipv4.sysctl_fib_multipath_use_neigh)) { 2221 2221 if (!fib_good_nh(nexthop_nh)) 2222 2222 continue; 2223 2223 if (!first) {
+1 -1
net/ipv4/icmp.c
··· 881 881 * values please see 882 882 * Documentation/networking/ip-sysctl.rst 883 883 */ 884 - switch (net->ipv4.sysctl_ip_no_pmtu_disc) { 884 + switch (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) { 885 885 default: 886 886 net_dbg_ratelimited("%pI4: fragmentation needed and DF set\n", 887 887 &iph->daddr);
+28 -21
net/ipv4/igmp.c
··· 467 467 468 468 if (pmc->multiaddr == IGMP_ALL_HOSTS) 469 469 return skb; 470 - if (ipv4_is_local_multicast(pmc->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) 470 + if (ipv4_is_local_multicast(pmc->multiaddr) && 471 + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) 471 472 return skb; 472 473 473 474 mtu = READ_ONCE(dev->mtu); ··· 594 593 if (pmc->multiaddr == IGMP_ALL_HOSTS) 595 594 continue; 596 595 if (ipv4_is_local_multicast(pmc->multiaddr) && 597 - !net->ipv4.sysctl_igmp_llm_reports) 596 + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) 598 597 continue; 599 598 spin_lock_bh(&pmc->lock); 600 599 if (pmc->sfcount[MCAST_EXCLUDE]) ··· 737 736 if (type == IGMPV3_HOST_MEMBERSHIP_REPORT) 738 737 return igmpv3_send_report(in_dev, pmc); 739 738 740 - if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports) 739 + if (ipv4_is_local_multicast(group) && 740 + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) 741 741 return 0; 742 742 743 743 if (type == IGMP_HOST_LEAVE_MESSAGE) ··· 827 825 struct net *net = dev_net(in_dev->dev); 828 826 if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) 829 827 return; 830 - WRITE_ONCE(in_dev->mr_ifc_count, in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv); 828 + WRITE_ONCE(in_dev->mr_ifc_count, in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv)); 831 829 igmp_ifc_start_timer(in_dev, 1); 832 830 } 833 831 ··· 922 920 923 921 if (group == IGMP_ALL_HOSTS) 924 922 return false; 925 - if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports) 923 + if (ipv4_is_local_multicast(group) && 924 + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) 926 925 return false; 927 926 928 927 rcu_read_lock(); ··· 1009 1006 * received value was zero, use the default or statically 1010 1007 * configured value. 1011 1008 */ 1012 - in_dev->mr_qrv = ih3->qrv ?: net->ipv4.sysctl_igmp_qrv; 1009 + in_dev->mr_qrv = ih3->qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1013 1010 in_dev->mr_qi = IGMPV3_QQIC(ih3->qqic)*HZ ?: IGMP_QUERY_INTERVAL; 1014 1011 1015 1012 /* RFC3376, 8.3. Query Response Interval: ··· 1048 1045 if (im->multiaddr == IGMP_ALL_HOSTS) 1049 1046 continue; 1050 1047 if (ipv4_is_local_multicast(im->multiaddr) && 1051 - !net->ipv4.sysctl_igmp_llm_reports) 1048 + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) 1052 1049 continue; 1053 1050 spin_lock_bh(&im->lock); 1054 1051 if (im->tm_running) ··· 1189 1186 pmc->interface = im->interface; 1190 1187 in_dev_hold(in_dev); 1191 1188 pmc->multiaddr = im->multiaddr; 1192 - pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 1189 + pmc->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1193 1190 pmc->sfmode = im->sfmode; 1194 1191 if (pmc->sfmode == MCAST_INCLUDE) { 1195 1192 struct ip_sf_list *psf; ··· 1240 1237 swap(im->tomb, pmc->tomb); 1241 1238 swap(im->sources, pmc->sources); 1242 1239 for (psf = im->sources; psf; psf = psf->sf_next) 1243 - psf->sf_crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 1240 + psf->sf_crcount = in_dev->mr_qrv ?: 1241 + READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1244 1242 } else { 1245 - im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 1243 + im->crcount = in_dev->mr_qrv ?: 1244 + READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1246 1245 } 1247 1246 in_dev_put(pmc->interface); 1248 1247 kfree_pmc(pmc); ··· 1301 1296 #ifdef CONFIG_IP_MULTICAST 1302 1297 if (im->multiaddr == IGMP_ALL_HOSTS) 1303 1298 return; 1304 - if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) 1299 + if (ipv4_is_local_multicast(im->multiaddr) && 1300 + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) 1305 1301 return; 1306 1302 1307 1303 reporter = im->reporter; ··· 1344 1338 #ifdef CONFIG_IP_MULTICAST 1345 1339 if (im->multiaddr == IGMP_ALL_HOSTS) 1346 1340 return; 1347 - if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) 1341 + if (ipv4_is_local_multicast(im->multiaddr) && 1342 + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) 1348 1343 return; 1349 1344 1350 1345 if (in_dev->dead) 1351 1346 return; 1352 1347 1353 - im->unsolicit_count = net->ipv4.sysctl_igmp_qrv; 1348 + im->unsolicit_count = READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1354 1349 if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) { 1355 1350 spin_lock_bh(&im->lock); 1356 1351 igmp_start_timer(im, IGMP_INITIAL_REPORT_DELAY); ··· 1365 1358 * IN() to IN(A). 1366 1359 */ 1367 1360 if (im->sfmode == MCAST_EXCLUDE) 1368 - im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 1361 + im->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1369 1362 1370 1363 igmp_ifc_event(in_dev); 1371 1364 #endif ··· 1649 1642 if (im->multiaddr == IGMP_ALL_HOSTS) 1650 1643 continue; 1651 1644 if (ipv4_is_local_multicast(im->multiaddr) && 1652 - !net->ipv4.sysctl_igmp_llm_reports) 1645 + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) 1653 1646 continue; 1654 1647 1655 1648 /* a failover is happening and switches ··· 1756 1749 1757 1750 in_dev->mr_qi = IGMP_QUERY_INTERVAL; 1758 1751 in_dev->mr_qri = IGMP_QUERY_RESPONSE_INTERVAL; 1759 - in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv; 1752 + in_dev->mr_qrv = READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1760 1753 } 1761 1754 #else 1762 1755 static void ip_mc_reset(struct in_device *in_dev) ··· 1890 1883 #ifdef CONFIG_IP_MULTICAST 1891 1884 if (psf->sf_oldin && 1892 1885 !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) { 1893 - psf->sf_crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 1886 + psf->sf_crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1894 1887 psf->sf_next = pmc->tomb; 1895 1888 pmc->tomb = psf; 1896 1889 rv = 1; ··· 1954 1947 /* filter mode change */ 1955 1948 pmc->sfmode = MCAST_INCLUDE; 1956 1949 #ifdef CONFIG_IP_MULTICAST 1957 - pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 1950 + pmc->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); 1958 1951 WRITE_ONCE(in_dev->mr_ifc_count, pmc->crcount); 1959 1952 for (psf = pmc->sources; psf; psf = psf->sf_next) 1960 1953 psf->sf_crcount = 0; ··· 2133 2126 #ifdef CONFIG_IP_MULTICAST 2134 2127 /* else no filters; keep old mode for reports */ 2135 2128 2136 - pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 2129 + pmc->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); 2137 2130 WRITE_ONCE(in_dev->mr_ifc_count, pmc->crcount); 2138 2131 for (psf = pmc->sources; psf; psf = psf->sf_next) 2139 2132 psf->sf_crcount = 0; ··· 2199 2192 count++; 2200 2193 } 2201 2194 err = -ENOBUFS; 2202 - if (count >= net->ipv4.sysctl_igmp_max_memberships) 2195 + if (count >= READ_ONCE(net->ipv4.sysctl_igmp_max_memberships)) 2203 2196 goto done; 2204 2197 iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL); 2205 2198 if (!iml) ··· 2386 2379 } 2387 2380 /* else, add a new source to the filter */ 2388 2381 2389 - if (psl && psl->sl_count >= net->ipv4.sysctl_igmp_max_msf) { 2382 + if (psl && psl->sl_count >= READ_ONCE(net->ipv4.sysctl_igmp_max_msf)) { 2390 2383 err = -ENOBUFS; 2391 2384 goto done; 2392 2385 }
+3 -2
net/ipv4/inet_connection_sock.c
··· 263 263 goto other_half_scan; 264 264 } 265 265 266 - if (net->ipv4.sysctl_ip_autobind_reuse && !relax) { 266 + if (READ_ONCE(net->ipv4.sysctl_ip_autobind_reuse) && !relax) { 267 267 /* We still have a chance to connect to different destinations */ 268 268 relax = true; 269 269 goto ports_exhausted; ··· 833 833 834 834 icsk = inet_csk(sk_listener); 835 835 net = sock_net(sk_listener); 836 - max_syn_ack_retries = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_synack_retries; 836 + max_syn_ack_retries = icsk->icsk_syn_retries ? : 837 + READ_ONCE(net->ipv4.sysctl_tcp_synack_retries); 837 838 /* Normally all the openreqs are young and become mature 838 839 * (i.e. converted to established socket) for first timeout. 839 840 * If synack was not acknowledged for 1 second, it means
+1 -1
net/ipv4/ip_forward.c
··· 157 157 !skb_sec_path(skb)) 158 158 ip_rt_send_redirect(skb); 159 159 160 - if (net->ipv4.sysctl_ip_fwd_update_priority) 160 + if (READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority)) 161 161 skb->priority = rt_tos2priority(iph->tos); 162 162 163 163 return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD,
+21 -14
net/ipv4/ip_input.c
··· 312 312 ip_hdr(hint)->tos == iph->tos; 313 313 } 314 314 315 - INDIRECT_CALLABLE_DECLARE(int udp_v4_early_demux(struct sk_buff *)); 316 - INDIRECT_CALLABLE_DECLARE(int tcp_v4_early_demux(struct sk_buff *)); 315 + int tcp_v4_early_demux(struct sk_buff *skb); 316 + int udp_v4_early_demux(struct sk_buff *skb); 317 317 static int ip_rcv_finish_core(struct net *net, struct sock *sk, 318 318 struct sk_buff *skb, struct net_device *dev, 319 319 const struct sk_buff *hint) 320 320 { 321 321 const struct iphdr *iph = ip_hdr(skb); 322 - int (*edemux)(struct sk_buff *skb); 323 322 int err, drop_reason; 324 323 struct rtable *rt; 325 324 ··· 331 332 goto drop_error; 332 333 } 333 334 334 - if (net->ipv4.sysctl_ip_early_demux && 335 + if (READ_ONCE(net->ipv4.sysctl_ip_early_demux) && 335 336 !skb_dst(skb) && 336 337 !skb->sk && 337 338 !ip_is_fragment(iph)) { 338 - const struct net_protocol *ipprot; 339 - int protocol = iph->protocol; 339 + switch (iph->protocol) { 340 + case IPPROTO_TCP: 341 + if (READ_ONCE(net->ipv4.sysctl_tcp_early_demux)) { 342 + tcp_v4_early_demux(skb); 340 343 341 - ipprot = rcu_dereference(inet_protos[protocol]); 342 - if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) { 343 - err = INDIRECT_CALL_2(edemux, tcp_v4_early_demux, 344 - udp_v4_early_demux, skb); 345 - if (unlikely(err)) 346 - goto drop_error; 347 - /* must reload iph, skb->head might have changed */ 348 - iph = ip_hdr(skb); 344 + /* must reload iph, skb->head might have changed */ 345 + iph = ip_hdr(skb); 346 + } 347 + break; 348 + case IPPROTO_UDP: 349 + if (READ_ONCE(net->ipv4.sysctl_udp_early_demux)) { 350 + err = udp_v4_early_demux(skb); 351 + if (unlikely(err)) 352 + goto drop_error; 353 + 354 + /* must reload iph, skb->head might have changed */ 355 + iph = ip_hdr(skb); 356 + } 357 + break; 349 358 } 350 359 } 351 360
+4 -4
net/ipv4/ip_sockglue.c
··· 782 782 /* numsrc >= (4G-140)/128 overflow in 32 bits */ 783 783 err = -ENOBUFS; 784 784 if (gsf->gf_numsrc >= 0x1ffffff || 785 - gsf->gf_numsrc > sock_net(sk)->ipv4.sysctl_igmp_max_msf) 785 + gsf->gf_numsrc > READ_ONCE(sock_net(sk)->ipv4.sysctl_igmp_max_msf)) 786 786 goto out_free_gsf; 787 787 788 788 err = -EINVAL; ··· 832 832 833 833 /* numsrc >= (4G-140)/128 overflow in 32 bits */ 834 834 err = -ENOBUFS; 835 - if (n > sock_net(sk)->ipv4.sysctl_igmp_max_msf) 835 + if (n > READ_ONCE(sock_net(sk)->ipv4.sysctl_igmp_max_msf)) 836 836 goto out_free_gsf; 837 837 err = set_mcast_msfilter(sk, gf32->gf_interface, n, gf32->gf_fmode, 838 838 &gf32->gf_group, gf32->gf_slist_flex); ··· 1244 1244 } 1245 1245 /* numsrc >= (1G-4) overflow in 32 bits */ 1246 1246 if (msf->imsf_numsrc >= 0x3ffffffcU || 1247 - msf->imsf_numsrc > net->ipv4.sysctl_igmp_max_msf) { 1247 + msf->imsf_numsrc > READ_ONCE(net->ipv4.sysctl_igmp_max_msf)) { 1248 1248 kfree(msf); 1249 1249 err = -ENOBUFS; 1250 1250 break; ··· 1606 1606 { 1607 1607 struct net *net = sock_net(sk); 1608 1608 val = (inet->uc_ttl == -1 ? 1609 - net->ipv4.sysctl_ip_default_ttl : 1609 + READ_ONCE(net->ipv4.sysctl_ip_default_ttl) : 1610 1610 inet->uc_ttl); 1611 1611 break; 1612 1612 }
+2 -2
net/ipv4/netfilter/nf_reject_ipv4.c
··· 62 62 63 63 skb_reserve(nskb, LL_MAX_HEADER); 64 64 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP, 65 - net->ipv4.sysctl_ip_default_ttl); 65 + READ_ONCE(net->ipv4.sysctl_ip_default_ttl)); 66 66 nf_reject_ip_tcphdr_put(nskb, oldskb, oth); 67 67 niph->tot_len = htons(nskb->len); 68 68 ip_send_check(niph); ··· 117 117 118 118 skb_reserve(nskb, LL_MAX_HEADER); 119 119 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_ICMP, 120 - net->ipv4.sysctl_ip_default_ttl); 120 + READ_ONCE(net->ipv4.sysctl_ip_default_ttl)); 121 121 122 122 skb_reset_transport_header(nskb); 123 123 icmph = skb_put_zero(nskb, sizeof(struct icmphdr));
+1 -1
net/ipv4/proc.c
··· 387 387 388 388 seq_printf(seq, "\nIp: %d %d", 389 389 IPV4_DEVCONF_ALL(net, FORWARDING) ? 1 : 2, 390 - net->ipv4.sysctl_ip_default_ttl); 390 + READ_ONCE(net->ipv4.sysctl_ip_default_ttl)); 391 391 392 392 BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0); 393 393 snmp_get_cpu_field64_batch(buff64, snmp4_ipstats_list,
+5 -5
net/ipv4/route.c
··· 1398 1398 struct fib_info *fi = res->fi; 1399 1399 u32 mtu = 0; 1400 1400 1401 - if (dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu || 1401 + if (READ_ONCE(dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu) || 1402 1402 fi->fib_metrics->metrics[RTAX_LOCK - 1] & (1 << RTAX_MTU)) 1403 1403 mtu = fi->fib_mtu; 1404 1404 ··· 1928 1928 const struct sk_buff *skb, 1929 1929 bool *p_has_inner) 1930 1930 { 1931 - u32 hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; 1931 + u32 hash_fields = READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields); 1932 1932 struct flow_keys keys, hash_keys; 1933 1933 1934 1934 if (!(hash_fields & FIB_MULTIPATH_HASH_FIELD_OUTER_MASK)) ··· 1957 1957 const struct sk_buff *skb, 1958 1958 bool has_inner) 1959 1959 { 1960 - u32 hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; 1960 + u32 hash_fields = READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields); 1961 1961 struct flow_keys keys, hash_keys; 1962 1962 1963 1963 /* We assume the packet carries an encapsulation, but if none was ··· 2017 2017 static u32 fib_multipath_custom_hash_fl4(const struct net *net, 2018 2018 const struct flowi4 *fl4) 2019 2019 { 2020 - u32 hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; 2020 + u32 hash_fields = READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields); 2021 2021 struct flow_keys hash_keys; 2022 2022 2023 2023 if (!(hash_fields & FIB_MULTIPATH_HASH_FIELD_OUTER_MASK)) ··· 2047 2047 struct flow_keys hash_keys; 2048 2048 u32 mhash = 0; 2049 2049 2050 - switch (net->ipv4.sysctl_fib_multipath_hash_policy) { 2050 + switch (READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_policy)) { 2051 2051 case 0: 2052 2052 memset(&hash_keys, 0, sizeof(hash_keys)); 2053 2053 hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
+5 -4
net/ipv4/syncookies.c
··· 247 247 return true; 248 248 } 249 249 250 - if (!net->ipv4.sysctl_tcp_timestamps) 250 + if (!READ_ONCE(net->ipv4.sysctl_tcp_timestamps)) 251 251 return false; 252 252 253 253 tcp_opt->sack_ok = (options & TS_OPT_SACK) ? TCP_SACK_SEEN : 0; 254 254 255 - if (tcp_opt->sack_ok && !net->ipv4.sysctl_tcp_sack) 255 + if (tcp_opt->sack_ok && !READ_ONCE(net->ipv4.sysctl_tcp_sack)) 256 256 return false; 257 257 258 258 if ((options & TS_OPT_WSCALE_MASK) == TS_OPT_WSCALE_MASK) ··· 261 261 tcp_opt->wscale_ok = 1; 262 262 tcp_opt->snd_wscale = options & TS_OPT_WSCALE_MASK; 263 263 264 - return net->ipv4.sysctl_tcp_window_scaling != 0; 264 + return READ_ONCE(net->ipv4.sysctl_tcp_window_scaling) != 0; 265 265 } 266 266 EXPORT_SYMBOL(cookie_timestamp_decode); 267 267 ··· 340 340 struct flowi4 fl4; 341 341 u32 tsoff = 0; 342 342 343 - if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies || !th->ack || th->rst) 343 + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies) || 344 + !th->ack || th->rst) 344 345 goto out; 345 346 346 347 if (tcp_synq_no_recent_overflow(sk))
+5 -60
net/ipv4/sysctl_net_ipv4.c
··· 84 84 * port limit. 85 85 */ 86 86 if ((range[1] < range[0]) || 87 - (range[0] < net->ipv4.sysctl_ip_prot_sock)) 87 + (range[0] < READ_ONCE(net->ipv4.sysctl_ip_prot_sock))) 88 88 ret = -EINVAL; 89 89 else 90 90 set_local_port_range(net, range); ··· 110 110 .extra2 = &ip_privileged_port_max, 111 111 }; 112 112 113 - pports = net->ipv4.sysctl_ip_prot_sock; 113 + pports = READ_ONCE(net->ipv4.sysctl_ip_prot_sock); 114 114 115 115 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 116 116 ··· 122 122 if (range[0] < pports) 123 123 ret = -EINVAL; 124 124 else 125 - net->ipv4.sysctl_ip_prot_sock = pports; 125 + WRITE_ONCE(net->ipv4.sysctl_ip_prot_sock, pports); 126 126 } 127 127 128 128 return ret; ··· 347 347 348 348 bad_key: 349 349 kfree(tbl.data); 350 - return ret; 351 - } 352 - 353 - static void proc_configure_early_demux(int enabled, int protocol) 354 - { 355 - struct net_protocol *ipprot; 356 - #if IS_ENABLED(CONFIG_IPV6) 357 - struct inet6_protocol *ip6prot; 358 - #endif 359 - 360 - rcu_read_lock(); 361 - 362 - ipprot = rcu_dereference(inet_protos[protocol]); 363 - if (ipprot) 364 - ipprot->early_demux = enabled ? ipprot->early_demux_handler : 365 - NULL; 366 - 367 - #if IS_ENABLED(CONFIG_IPV6) 368 - ip6prot = rcu_dereference(inet6_protos[protocol]); 369 - if (ip6prot) 370 - ip6prot->early_demux = enabled ? ip6prot->early_demux_handler : 371 - NULL; 372 - #endif 373 - rcu_read_unlock(); 374 - } 375 - 376 - static int proc_tcp_early_demux(struct ctl_table *table, int write, 377 - void *buffer, size_t *lenp, loff_t *ppos) 378 - { 379 - int ret = 0; 380 - 381 - ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos); 382 - 383 - if (write && !ret) { 384 - int enabled = init_net.ipv4.sysctl_tcp_early_demux; 385 - 386 - proc_configure_early_demux(enabled, IPPROTO_TCP); 387 - } 388 - 389 - return ret; 390 - } 391 - 392 - static int proc_udp_early_demux(struct ctl_table *table, int write, 393 - void *buffer, size_t *lenp, loff_t *ppos) 394 - { 395 - int ret = 0; 396 - 397 - ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos); 398 - 399 - if (write && !ret) { 400 - int enabled = init_net.ipv4.sysctl_udp_early_demux; 401 - 402 - proc_configure_early_demux(enabled, IPPROTO_UDP); 403 - } 404 - 405 350 return ret; 406 351 } 407 352 ··· 652 707 .data = &init_net.ipv4.sysctl_udp_early_demux, 653 708 .maxlen = sizeof(u8), 654 709 .mode = 0644, 655 - .proc_handler = proc_udp_early_demux 710 + .proc_handler = proc_dou8vec_minmax, 656 711 }, 657 712 { 658 713 .procname = "tcp_early_demux", 659 714 .data = &init_net.ipv4.sysctl_tcp_early_demux, 660 715 .maxlen = sizeof(u8), 661 716 .mode = 0644, 662 - .proc_handler = proc_tcp_early_demux 717 + .proc_handler = proc_dou8vec_minmax, 663 718 }, 664 719 { 665 720 .procname = "nexthop_compat_mode",
+8 -5
net/ipv4/tcp.c
··· 443 443 tp->snd_cwnd_clamp = ~0; 444 444 tp->mss_cache = TCP_MSS_DEFAULT; 445 445 446 - tp->reordering = sock_net(sk)->ipv4.sysctl_tcp_reordering; 446 + tp->reordering = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reordering); 447 447 tcp_assign_congestion_control(sk); 448 448 449 449 tp->tsoffset = 0; ··· 1171 1171 struct sockaddr *uaddr = msg->msg_name; 1172 1172 int err, flags; 1173 1173 1174 - if (!(sock_net(sk)->ipv4.sysctl_tcp_fastopen & TFO_CLIENT_ENABLE) || 1174 + if (!(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen) & 1175 + TFO_CLIENT_ENABLE) || 1175 1176 (uaddr && msg->msg_namelen >= sizeof(uaddr->sa_family) && 1176 1177 uaddr->sa_family == AF_UNSPEC)) 1177 1178 return -EOPNOTSUPP; ··· 3692 3691 case TCP_FASTOPEN_CONNECT: 3693 3692 if (val > 1 || val < 0) { 3694 3693 err = -EINVAL; 3695 - } else if (net->ipv4.sysctl_tcp_fastopen & TFO_CLIENT_ENABLE) { 3694 + } else if (READ_ONCE(net->ipv4.sysctl_tcp_fastopen) & 3695 + TFO_CLIENT_ENABLE) { 3696 3696 if (sk->sk_state == TCP_CLOSE) 3697 3697 tp->fastopen_connect = val; 3698 3698 else ··· 4043 4041 val = keepalive_probes(tp); 4044 4042 break; 4045 4043 case TCP_SYNCNT: 4046 - val = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries; 4044 + val = icsk->icsk_syn_retries ? : 4045 + READ_ONCE(net->ipv4.sysctl_tcp_syn_retries); 4047 4046 break; 4048 4047 case TCP_LINGER2: 4049 4048 val = tp->linger2; 4050 4049 if (val >= 0) 4051 - val = (val ? : net->ipv4.sysctl_tcp_fin_timeout) / HZ; 4050 + val = (val ? : READ_ONCE(net->ipv4.sysctl_tcp_fin_timeout)) / HZ; 4052 4051 break; 4053 4052 case TCP_DEFER_ACCEPT: 4054 4053 val = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept,
+5 -4
net/ipv4/tcp_fastopen.c
··· 332 332 const struct dst_entry *dst, 333 333 int flag) 334 334 { 335 - return (sock_net(sk)->ipv4.sysctl_tcp_fastopen & flag) || 335 + return (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen) & flag) || 336 336 tcp_sk(sk)->fastopen_no_cookie || 337 337 (dst && dst_metric(dst, RTAX_FASTOPEN_NO_COOKIE)); 338 338 } ··· 347 347 const struct dst_entry *dst) 348 348 { 349 349 bool syn_data = TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq + 1; 350 - int tcp_fastopen = sock_net(sk)->ipv4.sysctl_tcp_fastopen; 350 + int tcp_fastopen = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen); 351 351 struct tcp_fastopen_cookie valid_foc = { .len = -1 }; 352 352 struct sock *child; 353 353 int ret = 0; ··· 489 489 { 490 490 struct net *net = sock_net(sk); 491 491 492 - if (!sock_net(sk)->ipv4.sysctl_tcp_fastopen_blackhole_timeout) 492 + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen_blackhole_timeout)) 493 493 return; 494 494 495 495 /* Paired with READ_ONCE() in tcp_fastopen_active_should_disable() */ ··· 510 510 */ 511 511 bool tcp_fastopen_active_should_disable(struct sock *sk) 512 512 { 513 - unsigned int tfo_bh_timeout = sock_net(sk)->ipv4.sysctl_tcp_fastopen_blackhole_timeout; 513 + unsigned int tfo_bh_timeout = 514 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen_blackhole_timeout); 514 515 unsigned long timeout; 515 516 int tfo_da_times; 516 517 int multiplier;
+31 -20
net/ipv4/tcp_input.c
··· 1050 1050 tp->undo_marker ? tp->undo_retrans : 0); 1051 1051 #endif 1052 1052 tp->reordering = min_t(u32, (metric + mss - 1) / mss, 1053 - sock_net(sk)->ipv4.sysctl_tcp_max_reordering); 1053 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_max_reordering)); 1054 1054 } 1055 1055 1056 1056 /* This exciting event is worth to be remembered. 8) */ ··· 2029 2029 return; 2030 2030 2031 2031 tp->reordering = min_t(u32, tp->packets_out + addend, 2032 - sock_net(sk)->ipv4.sysctl_tcp_max_reordering); 2032 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_max_reordering)); 2033 2033 tp->reord_seen++; 2034 2034 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRENOREORDER); 2035 2035 } ··· 2094 2094 2095 2095 static bool tcp_is_rack(const struct sock *sk) 2096 2096 { 2097 - return sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_LOSS_DETECTION; 2097 + return READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & 2098 + TCP_RACK_LOSS_DETECTION; 2098 2099 } 2099 2100 2100 2101 /* If we detect SACK reneging, forget all SACK information ··· 2139 2138 struct tcp_sock *tp = tcp_sk(sk); 2140 2139 struct net *net = sock_net(sk); 2141 2140 bool new_recovery = icsk->icsk_ca_state < TCP_CA_Recovery; 2141 + u8 reordering; 2142 2142 2143 2143 tcp_timeout_mark_lost(sk); 2144 2144 ··· 2160 2158 /* Timeout in disordered state after receiving substantial DUPACKs 2161 2159 * suggests that the degree of reordering is over-estimated. 2162 2160 */ 2161 + reordering = READ_ONCE(net->ipv4.sysctl_tcp_reordering); 2163 2162 if (icsk->icsk_ca_state <= TCP_CA_Disorder && 2164 - tp->sacked_out >= net->ipv4.sysctl_tcp_reordering) 2163 + tp->sacked_out >= reordering) 2165 2164 tp->reordering = min_t(unsigned int, tp->reordering, 2166 - net->ipv4.sysctl_tcp_reordering); 2165 + reordering); 2166 + 2167 2167 tcp_set_ca_state(sk, TCP_CA_Loss); 2168 2168 tp->high_seq = tp->snd_nxt; 2169 2169 tcp_ecn_queue_cwr(tp); ··· 3467 3463 * new SACK or ECE mark may first advance cwnd here and later reduce 3468 3464 * cwnd in tcp_fastretrans_alert() based on more states. 3469 3465 */ 3470 - if (tcp_sk(sk)->reordering > sock_net(sk)->ipv4.sysctl_tcp_reordering) 3466 + if (tcp_sk(sk)->reordering > 3467 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reordering)) 3471 3468 return flag & FLAG_FORWARD_PROGRESS; 3472 3469 3473 3470 return flag & FLAG_DATA_ACKED; ··· 4061 4056 break; 4062 4057 case TCPOPT_WINDOW: 4063 4058 if (opsize == TCPOLEN_WINDOW && th->syn && 4064 - !estab && net->ipv4.sysctl_tcp_window_scaling) { 4059 + !estab && READ_ONCE(net->ipv4.sysctl_tcp_window_scaling)) { 4065 4060 __u8 snd_wscale = *(__u8 *)ptr; 4066 4061 opt_rx->wscale_ok = 1; 4067 4062 if (snd_wscale > TCP_MAX_WSCALE) { ··· 4077 4072 case TCPOPT_TIMESTAMP: 4078 4073 if ((opsize == TCPOLEN_TIMESTAMP) && 4079 4074 ((estab && opt_rx->tstamp_ok) || 4080 - (!estab && net->ipv4.sysctl_tcp_timestamps))) { 4075 + (!estab && READ_ONCE(net->ipv4.sysctl_tcp_timestamps)))) { 4081 4076 opt_rx->saw_tstamp = 1; 4082 4077 opt_rx->rcv_tsval = get_unaligned_be32(ptr); 4083 4078 opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4); ··· 4085 4080 break; 4086 4081 case TCPOPT_SACK_PERM: 4087 4082 if (opsize == TCPOLEN_SACK_PERM && th->syn && 4088 - !estab && net->ipv4.sysctl_tcp_sack) { 4083 + !estab && READ_ONCE(net->ipv4.sysctl_tcp_sack)) { 4089 4084 opt_rx->sack_ok = TCP_SACK_SEEN; 4090 4085 tcp_sack_reset(opt_rx); 4091 4086 } ··· 5569 5564 struct tcp_sock *tp = tcp_sk(sk); 5570 5565 u32 ptr = ntohs(th->urg_ptr); 5571 5566 5572 - if (ptr && !sock_net(sk)->ipv4.sysctl_tcp_stdurg) 5567 + if (ptr && !READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_stdurg)) 5573 5568 ptr--; 5574 5569 ptr += ntohl(th->seq); 5575 5570 ··· 6799 6794 { 6800 6795 struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue; 6801 6796 const char *msg = "Dropping request"; 6802 - bool want_cookie = false; 6803 6797 struct net *net = sock_net(sk); 6798 + bool want_cookie = false; 6799 + u8 syncookies; 6800 + 6801 + syncookies = READ_ONCE(net->ipv4.sysctl_tcp_syncookies); 6804 6802 6805 6803 #ifdef CONFIG_SYN_COOKIES 6806 - if (net->ipv4.sysctl_tcp_syncookies) { 6804 + if (syncookies) { 6807 6805 msg = "Sending cookies"; 6808 6806 want_cookie = true; 6809 6807 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPREQQFULLDOCOOKIES); ··· 6814 6806 #endif 6815 6807 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP); 6816 6808 6817 - if (!queue->synflood_warned && 6818 - net->ipv4.sysctl_tcp_syncookies != 2 && 6809 + if (!queue->synflood_warned && syncookies != 2 && 6819 6810 xchg(&queue->synflood_warned, 1) == 0) 6820 6811 net_info_ratelimited("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n", 6821 6812 proto, sk->sk_num, msg); ··· 6863 6856 struct tcp_sock *tp = tcp_sk(sk); 6864 6857 u16 mss; 6865 6858 6866 - if (sock_net(sk)->ipv4.sysctl_tcp_syncookies != 2 && 6859 + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies) != 2 && 6867 6860 !inet_csk_reqsk_queue_is_full(sk)) 6868 6861 return 0; 6869 6862 ··· 6897 6890 bool want_cookie = false; 6898 6891 struct dst_entry *dst; 6899 6892 struct flowi fl; 6893 + u8 syncookies; 6894 + 6895 + syncookies = READ_ONCE(net->ipv4.sysctl_tcp_syncookies); 6900 6896 6901 6897 /* TW buckets are converted to open requests without 6902 6898 * limitations, they conserve resources and peer is 6903 6899 * evidently real one. 6904 6900 */ 6905 - if ((net->ipv4.sysctl_tcp_syncookies == 2 || 6906 - inet_csk_reqsk_queue_is_full(sk)) && !isn) { 6901 + if ((syncookies == 2 || inet_csk_reqsk_queue_is_full(sk)) && !isn) { 6907 6902 want_cookie = tcp_syn_flood_action(sk, rsk_ops->slab_name); 6908 6903 if (!want_cookie) 6909 6904 goto drop; ··· 6954 6945 tcp_rsk(req)->ts_off = af_ops->init_ts_off(net, skb); 6955 6946 6956 6947 if (!want_cookie && !isn) { 6948 + int max_syn_backlog = READ_ONCE(net->ipv4.sysctl_max_syn_backlog); 6949 + 6957 6950 /* Kill the following clause, if you dislike this way. */ 6958 - if (!net->ipv4.sysctl_tcp_syncookies && 6959 - (net->ipv4.sysctl_max_syn_backlog - inet_csk_reqsk_queue_len(sk) < 6960 - (net->ipv4.sysctl_max_syn_backlog >> 2)) && 6951 + if (!syncookies && 6952 + (max_syn_backlog - inet_csk_reqsk_queue_len(sk) < 6953 + (max_syn_backlog >> 2)) && 6961 6954 !tcp_peer_is_proven(req, dst)) { 6962 6955 /* Without syncookies last quarter of 6963 6956 * backlog is filled with destinations,
+1 -1
net/ipv4/tcp_ipv4.c
··· 108 108 109 109 int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp) 110 110 { 111 + int reuse = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_tw_reuse); 111 112 const struct inet_timewait_sock *tw = inet_twsk(sktw); 112 113 const struct tcp_timewait_sock *tcptw = tcp_twsk(sktw); 113 114 struct tcp_sock *tp = tcp_sk(sk); 114 - int reuse = sock_net(sk)->ipv4.sysctl_tcp_tw_reuse; 115 115 116 116 if (reuse == 2) { 117 117 /* Still does not detect *everything* that goes through
+2 -1
net/ipv4/tcp_metrics.c
··· 428 428 if (!tcp_metric_locked(tm, TCP_METRIC_REORDERING)) { 429 429 val = tcp_metric_get(tm, TCP_METRIC_REORDERING); 430 430 if (val < tp->reordering && 431 - tp->reordering != net->ipv4.sysctl_tcp_reordering) 431 + tp->reordering != 432 + READ_ONCE(net->ipv4.sysctl_tcp_reordering)) 432 433 tcp_metric_set(tm, TCP_METRIC_REORDERING, 433 434 tp->reordering); 434 435 }
+2 -2
net/ipv4/tcp_minisocks.c
··· 173 173 * Oh well... nobody has a sufficient solution to this 174 174 * protocol bug yet. 175 175 */ 176 - if (twsk_net(tw)->ipv4.sysctl_tcp_rfc1337 == 0) { 176 + if (!READ_ONCE(twsk_net(tw)->ipv4.sysctl_tcp_rfc1337)) { 177 177 kill: 178 178 inet_twsk_deschedule_put(tw); 179 179 return TCP_TW_SUCCESS; ··· 781 781 if (sk != req->rsk_listener) 782 782 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMIGRATEREQFAILURE); 783 783 784 - if (!sock_net(sk)->ipv4.sysctl_tcp_abort_on_overflow) { 784 + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_abort_on_overflow)) { 785 785 inet_rsk(req)->acked = 1; 786 786 return NULL; 787 787 }
+15 -14
net/ipv4/tcp_output.c
··· 791 791 opts->mss = tcp_advertise_mss(sk); 792 792 remaining -= TCPOLEN_MSS_ALIGNED; 793 793 794 - if (likely(sock_net(sk)->ipv4.sysctl_tcp_timestamps && !*md5)) { 794 + if (likely(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_timestamps) && !*md5)) { 795 795 opts->options |= OPTION_TS; 796 796 opts->tsval = tcp_skb_timestamp(skb) + tp->tsoffset; 797 797 opts->tsecr = tp->rx_opt.ts_recent; 798 798 remaining -= TCPOLEN_TSTAMP_ALIGNED; 799 799 } 800 - if (likely(sock_net(sk)->ipv4.sysctl_tcp_window_scaling)) { 800 + if (likely(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_window_scaling))) { 801 801 opts->ws = tp->rx_opt.rcv_wscale; 802 802 opts->options |= OPTION_WSCALE; 803 803 remaining -= TCPOLEN_WSCALE_ALIGNED; 804 804 } 805 - if (likely(sock_net(sk)->ipv4.sysctl_tcp_sack)) { 805 + if (likely(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_sack))) { 806 806 opts->options |= OPTION_SACK_ADVERTISE; 807 807 if (unlikely(!(OPTION_TS & opts->options))) 808 808 remaining -= TCPOLEN_SACKPERM_ALIGNED; ··· 1719 1719 mss_now -= icsk->icsk_ext_hdr_len; 1720 1720 1721 1721 /* Then reserve room for full set of TCP options and 8 bytes of data */ 1722 - mss_now = max(mss_now, sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss); 1722 + mss_now = max(mss_now, 1723 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss)); 1723 1724 return mss_now; 1724 1725 } 1725 1726 ··· 1763 1762 struct inet_connection_sock *icsk = inet_csk(sk); 1764 1763 struct net *net = sock_net(sk); 1765 1764 1766 - icsk->icsk_mtup.enabled = net->ipv4.sysctl_tcp_mtu_probing > 1; 1765 + icsk->icsk_mtup.enabled = READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing) > 1; 1767 1766 icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) + 1768 1767 icsk->icsk_af_ops->net_header_len; 1769 - icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, net->ipv4.sysctl_tcp_base_mss); 1768 + icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, READ_ONCE(net->ipv4.sysctl_tcp_base_mss)); 1770 1769 icsk->icsk_mtup.probe_size = 0; 1771 1770 if (icsk->icsk_mtup.enabled) 1772 1771 icsk->icsk_mtup.probe_timestamp = tcp_jiffies32; ··· 1898 1897 if (tp->packets_out > tp->snd_cwnd_used) 1899 1898 tp->snd_cwnd_used = tp->packets_out; 1900 1899 1901 - if (sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle && 1900 + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle) && 1902 1901 (s32)(tcp_jiffies32 - tp->snd_cwnd_stamp) >= inet_csk(sk)->icsk_rto && 1903 1902 !ca_ops->cong_control) 1904 1903 tcp_cwnd_application_limited(sk); ··· 2283 2282 u32 interval; 2284 2283 s32 delta; 2285 2284 2286 - interval = net->ipv4.sysctl_tcp_probe_interval; 2285 + interval = READ_ONCE(net->ipv4.sysctl_tcp_probe_interval); 2287 2286 delta = tcp_jiffies32 - icsk->icsk_mtup.probe_timestamp; 2288 2287 if (unlikely(delta >= interval * HZ)) { 2289 2288 int mss = tcp_current_mss(sk); ··· 2367 2366 * probing process by not resetting search range to its orignal. 2368 2367 */ 2369 2368 if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high) || 2370 - interval < net->ipv4.sysctl_tcp_probe_threshold) { 2369 + interval < READ_ONCE(net->ipv4.sysctl_tcp_probe_threshold)) { 2371 2370 /* Check whether enough time has elaplased for 2372 2371 * another round of probing. 2373 2372 */ ··· 2741 2740 if (rcu_access_pointer(tp->fastopen_rsk)) 2742 2741 return false; 2743 2742 2744 - early_retrans = sock_net(sk)->ipv4.sysctl_tcp_early_retrans; 2743 + early_retrans = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_early_retrans); 2745 2744 /* Schedule a loss probe in 2*RTT for SACK capable connections 2746 2745 * not in loss recovery, that are either limited by cwnd or application. 2747 2746 */ ··· 3105 3104 struct sk_buff *skb = to, *tmp; 3106 3105 bool first = true; 3107 3106 3108 - if (!sock_net(sk)->ipv4.sysctl_tcp_retrans_collapse) 3107 + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_retrans_collapse)) 3109 3108 return; 3110 3109 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN) 3111 3110 return; ··· 3657 3656 * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. 3658 3657 */ 3659 3658 tp->tcp_header_len = sizeof(struct tcphdr); 3660 - if (sock_net(sk)->ipv4.sysctl_tcp_timestamps) 3659 + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_timestamps)) 3661 3660 tp->tcp_header_len += TCPOLEN_TSTAMP_ALIGNED; 3662 3661 3663 3662 #ifdef CONFIG_TCP_MD5SIG ··· 3693 3692 tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), 3694 3693 &tp->rcv_wnd, 3695 3694 &tp->window_clamp, 3696 - sock_net(sk)->ipv4.sysctl_tcp_window_scaling, 3695 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_window_scaling), 3697 3696 &rcv_wscale, 3698 3697 rcv_wnd); 3699 3698 ··· 4100 4099 4101 4100 icsk->icsk_probes_out++; 4102 4101 if (err <= 0) { 4103 - if (icsk->icsk_backoff < net->ipv4.sysctl_tcp_retries2) 4102 + if (icsk->icsk_backoff < READ_ONCE(net->ipv4.sysctl_tcp_retries2)) 4104 4103 icsk->icsk_backoff++; 4105 4104 timeout = tcp_probe0_when(sk, TCP_RTO_MAX); 4106 4105 } else {
+4 -2
net/ipv4/tcp_recovery.c
··· 14 14 return 0; 15 15 16 16 if (tp->sacked_out >= tp->reordering && 17 - !(sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_NO_DUPTHRESH)) 17 + !(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & 18 + TCP_RACK_NO_DUPTHRESH)) 18 19 return 0; 19 20 } 20 21 ··· 188 187 { 189 188 struct tcp_sock *tp = tcp_sk(sk); 190 189 191 - if (sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_STATIC_REO_WND || 190 + if ((READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & 191 + TCP_RACK_STATIC_REO_WND) || 192 192 !rs->prior_delivered) 193 193 return; 194 194
+17 -13
net/ipv4/tcp_timer.c
··· 143 143 */ 144 144 static int tcp_orphan_retries(struct sock *sk, bool alive) 145 145 { 146 - int retries = sock_net(sk)->ipv4.sysctl_tcp_orphan_retries; /* May be zero. */ 146 + int retries = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_orphan_retries); /* May be zero. */ 147 147 148 148 /* We know from an ICMP that something is wrong. */ 149 149 if (sk->sk_err_soft && !alive) ··· 163 163 int mss; 164 164 165 165 /* Black hole detection */ 166 - if (!net->ipv4.sysctl_tcp_mtu_probing) 166 + if (!READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing)) 167 167 return; 168 168 169 169 if (!icsk->icsk_mtup.enabled) { ··· 171 171 icsk->icsk_mtup.probe_timestamp = tcp_jiffies32; 172 172 } else { 173 173 mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1; 174 - mss = min(net->ipv4.sysctl_tcp_base_mss, mss); 175 - mss = max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor); 176 - mss = max(mss, net->ipv4.sysctl_tcp_min_snd_mss); 174 + mss = min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss); 175 + mss = max(mss, READ_ONCE(net->ipv4.sysctl_tcp_mtu_probe_floor)); 176 + mss = max(mss, READ_ONCE(net->ipv4.sysctl_tcp_min_snd_mss)); 177 177 icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss); 178 178 } 179 179 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); ··· 239 239 if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { 240 240 if (icsk->icsk_retransmits) 241 241 __dst_negative_advice(sk); 242 - retry_until = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries; 242 + retry_until = icsk->icsk_syn_retries ? : 243 + READ_ONCE(net->ipv4.sysctl_tcp_syn_retries); 243 244 expired = icsk->icsk_retransmits >= retry_until; 244 245 } else { 245 - if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1, 0)) { 246 + if (retransmits_timed_out(sk, READ_ONCE(net->ipv4.sysctl_tcp_retries1), 0)) { 246 247 /* Black hole detection */ 247 248 tcp_mtu_probing(icsk, sk); 248 249 249 250 __dst_negative_advice(sk); 250 251 } 251 252 252 - retry_until = net->ipv4.sysctl_tcp_retries2; 253 + retry_until = READ_ONCE(net->ipv4.sysctl_tcp_retries2); 253 254 if (sock_flag(sk, SOCK_DEAD)) { 254 255 const bool alive = icsk->icsk_rto < TCP_RTO_MAX; 255 256 ··· 375 374 msecs_to_jiffies(icsk->icsk_user_timeout)) 376 375 goto abort; 377 376 378 - max_probes = sock_net(sk)->ipv4.sysctl_tcp_retries2; 377 + max_probes = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_retries2); 379 378 if (sock_flag(sk, SOCK_DEAD)) { 380 379 const bool alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_MAX; 381 380 ··· 401 400 static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock *req) 402 401 { 403 402 struct inet_connection_sock *icsk = inet_csk(sk); 404 - int max_retries = icsk->icsk_syn_retries ? : 405 - sock_net(sk)->ipv4.sysctl_tcp_synack_retries + 1; /* add one more retry for fastopen */ 406 403 struct tcp_sock *tp = tcp_sk(sk); 404 + int max_retries; 407 405 408 406 req->rsk_ops->syn_ack_timeout(req); 407 + 408 + /* add one more retry for fastopen */ 409 + max_retries = icsk->icsk_syn_retries ? : 410 + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_synack_retries) + 1; 409 411 410 412 if (req->num_timeout >= max_retries) { 411 413 tcp_write_err(sk); ··· 572 568 * linear-timeout retransmissions into a black hole 573 569 */ 574 570 if (sk->sk_state == TCP_ESTABLISHED && 575 - (tp->thin_lto || net->ipv4.sysctl_tcp_thin_linear_timeouts) && 571 + (tp->thin_lto || READ_ONCE(net->ipv4.sysctl_tcp_thin_linear_timeouts)) && 576 572 tcp_stream_is_thin(tp) && 577 573 icsk->icsk_retransmits <= TCP_THIN_LINEAR_RETRIES) { 578 574 icsk->icsk_backoff = 0; ··· 583 579 } 584 580 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, 585 581 tcp_clamp_rto_to_user_timeout(sk), TCP_RTO_MAX); 586 - if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1 + 1, 0)) 582 + if (retransmits_timed_out(sk, READ_ONCE(net->ipv4.sysctl_tcp_retries1) + 1, 0)) 587 583 __sk_dst_reset(sk); 588 584 589 585 out:;
+1 -1
net/ipv6/af_inet6.c
··· 227 227 RCU_INIT_POINTER(inet->mc_list, NULL); 228 228 inet->rcv_tos = 0; 229 229 230 - if (net->ipv4.sysctl_ip_no_pmtu_disc) 230 + if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) 231 231 inet->pmtudisc = IP_PMTUDISC_DONT; 232 232 else 233 233 inet->pmtudisc = IP_PMTUDISC_WANT;
+13 -10
net/ipv6/ip6_input.c
··· 45 45 #include <net/inet_ecn.h> 46 46 #include <net/dst_metadata.h> 47 47 48 - INDIRECT_CALLABLE_DECLARE(void tcp_v6_early_demux(struct sk_buff *)); 49 48 static void ip6_rcv_finish_core(struct net *net, struct sock *sk, 50 49 struct sk_buff *skb) 51 50 { 52 - void (*edemux)(struct sk_buff *skb); 53 - 54 - if (net->ipv4.sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) { 55 - const struct inet6_protocol *ipprot; 56 - 57 - ipprot = rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]); 58 - if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) 59 - INDIRECT_CALL_2(edemux, tcp_v6_early_demux, 60 - udp_v6_early_demux, skb); 51 + if (READ_ONCE(net->ipv4.sysctl_ip_early_demux) && 52 + !skb_dst(skb) && !skb->sk) { 53 + switch (ipv6_hdr(skb)->nexthdr) { 54 + case IPPROTO_TCP: 55 + if (READ_ONCE(net->ipv4.sysctl_tcp_early_demux)) 56 + tcp_v6_early_demux(skb); 57 + break; 58 + case IPPROTO_UDP: 59 + if (READ_ONCE(net->ipv4.sysctl_udp_early_demux)) 60 + udp_v6_early_demux(skb); 61 + break; 62 + } 61 63 } 64 + 62 65 if (!skb_valid_dst(skb)) 63 66 ip6_route_input(skb); 64 67 }
+2 -1
net/ipv6/syncookies.c
··· 141 141 __u8 rcv_wscale; 142 142 u32 tsoff = 0; 143 143 144 - if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies || !th->ack || th->rst) 144 + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies) || 145 + !th->ack || th->rst) 145 146 goto out; 146 147 147 148 if (tcp_synq_no_recent_overflow(sk))
+2 -7
net/ipv6/tcp_ipv6.c
··· 1825 1825 goto discard_it; 1826 1826 } 1827 1827 1828 - INDIRECT_CALLABLE_SCOPE void tcp_v6_early_demux(struct sk_buff *skb) 1828 + void tcp_v6_early_demux(struct sk_buff *skb) 1829 1829 { 1830 1830 const struct ipv6hdr *hdr; 1831 1831 const struct tcphdr *th; ··· 2182 2182 }; 2183 2183 EXPORT_SYMBOL_GPL(tcpv6_prot); 2184 2184 2185 - /* thinking of making this const? Don't. 2186 - * early_demux can change based on sysctl. 2187 - */ 2188 - static struct inet6_protocol tcpv6_protocol = { 2189 - .early_demux = tcp_v6_early_demux, 2190 - .early_demux_handler = tcp_v6_early_demux, 2185 + static const struct inet6_protocol tcpv6_protocol = { 2191 2186 .handler = tcp_v6_rcv, 2192 2187 .err_handler = tcp_v6_err, 2193 2188 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
+2 -7
net/ipv6/udp.c
··· 1052 1052 return NULL; 1053 1053 } 1054 1054 1055 - INDIRECT_CALLABLE_SCOPE void udp_v6_early_demux(struct sk_buff *skb) 1055 + void udp_v6_early_demux(struct sk_buff *skb) 1056 1056 { 1057 1057 struct net *net = dev_net(skb->dev); 1058 1058 const struct udphdr *uh; ··· 1660 1660 return ipv6_getsockopt(sk, level, optname, optval, optlen); 1661 1661 } 1662 1662 1663 - /* thinking of making this const? Don't. 1664 - * early_demux can change based on sysctl. 1665 - */ 1666 - static struct inet6_protocol udpv6_protocol = { 1667 - .early_demux = udp_v6_early_demux, 1668 - .early_demux_handler = udp_v6_early_demux, 1663 + static const struct inet6_protocol udpv6_protocol = { 1669 1664 .handler = udpv6_rcv, 1670 1665 .err_handler = udpv6_err, 1671 1666 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
+1 -1
net/netfilter/nf_synproxy_core.c
··· 405 405 iph->tos = 0; 406 406 iph->id = 0; 407 407 iph->frag_off = htons(IP_DF); 408 - iph->ttl = net->ipv4.sysctl_ip_default_ttl; 408 + iph->ttl = READ_ONCE(net->ipv4.sysctl_ip_default_ttl); 409 409 iph->protocol = IPPROTO_TCP; 410 410 iph->check = 0; 411 411 iph->saddr = saddr;
+10 -6
net/sched/cls_api.c
··· 3534 3534 struct tc_action *actions[], 3535 3535 struct netlink_ext_ack *extack) 3536 3536 { 3537 - int i, j, index, err = 0; 3537 + int i, j, k, index, err = 0; 3538 3538 struct tc_action *act; 3539 3539 3540 3540 BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY != FLOW_ACTION_HW_STATS_ANY); ··· 3554 3554 if (err) 3555 3555 goto err_out_locked; 3556 3556 3557 - entry->hw_stats = tc_act_hw_stats(act->hw_stats); 3558 - entry->hw_index = act->tcfa_index; 3559 3557 index = 0; 3560 3558 err = tc_setup_offload_act(act, entry, &index, extack); 3561 - if (!err) 3562 - j += index; 3563 - else 3559 + if (err) 3564 3560 goto err_out_locked; 3561 + 3562 + for (k = 0; k < index ; k++) { 3563 + entry[k].hw_stats = tc_act_hw_stats(act->hw_stats); 3564 + entry[k].hw_index = act->tcfa_index; 3565 + } 3566 + 3567 + j += index; 3568 + 3565 3569 spin_unlock_bh(&act->tcfa_lock); 3566 3570 } 3567 3571
+1 -1
net/sctp/protocol.c
··· 358 358 if (addr->v4.sin_addr.s_addr != htonl(INADDR_ANY) && 359 359 ret != RTN_LOCAL && 360 360 !sp->inet.freebind && 361 - !net->ipv4.sysctl_ip_nonlocal_bind) 361 + !READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind)) 362 362 return 0; 363 363 364 364 if (ipv6_only_sock(sctp_opt2sk(sp)))
+1 -1
net/smc/smc_llc.c
··· 2127 2127 init_waitqueue_head(&lgr->llc_flow_waiter); 2128 2128 init_waitqueue_head(&lgr->llc_msg_waiter); 2129 2129 mutex_init(&lgr->llc_conf_mutex); 2130 - lgr->llc_testlink_time = net->ipv4.sysctl_tcp_keepalive_time; 2130 + lgr->llc_testlink_time = READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time); 2131 2131 } 2132 2132 2133 2133 /* called after lgr was removed from lgr_list */
+5 -3
net/tls/tls_device.c
··· 98 98 unsigned long flags; 99 99 100 100 spin_lock_irqsave(&tls_device_lock, flags); 101 + if (unlikely(!refcount_dec_and_test(&ctx->refcount))) 102 + goto unlock; 103 + 101 104 list_move_tail(&ctx->list, &tls_device_gc_list); 102 105 103 106 /* schedule_work inside the spinlock 104 107 * to make sure tls_device_down waits for that work. 105 108 */ 106 109 schedule_work(&tls_device_gc_work); 107 - 110 + unlock: 108 111 spin_unlock_irqrestore(&tls_device_lock, flags); 109 112 } 110 113 ··· 198 195 clean_acked_data_disable(inet_csk(sk)); 199 196 } 200 197 201 - if (refcount_dec_and_test(&tls_ctx->refcount)) 202 - tls_device_queue_ctx_destruction(tls_ctx); 198 + tls_device_queue_ctx_destruction(tls_ctx); 203 199 } 204 200 EXPORT_SYMBOL_GPL(tls_device_sk_destruct); 205 201
+4 -1
net/xfrm/xfrm_policy.c
··· 2678 2678 *num_xfrms = 0; 2679 2679 return 0; 2680 2680 } 2681 - if (IS_ERR(pols[0])) 2681 + if (IS_ERR(pols[0])) { 2682 + *num_pols = 0; 2682 2683 return PTR_ERR(pols[0]); 2684 + } 2683 2685 2684 2686 *num_xfrms = pols[0]->xfrm_nr; 2685 2687 ··· 2696 2694 if (pols[1]) { 2697 2695 if (IS_ERR(pols[1])) { 2698 2696 xfrm_pols_put(pols, *num_pols); 2697 + *num_pols = 0; 2699 2698 return PTR_ERR(pols[1]); 2700 2699 } 2701 2700 (*num_pols)++;
+1 -1
net/xfrm/xfrm_state.c
··· 2620 2620 int err; 2621 2621 2622 2622 if (family == AF_INET && 2623 - xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc) 2623 + READ_ONCE(xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc)) 2624 2624 x->props.flags |= XFRM_STATE_NOPMTUDISC; 2625 2625 2626 2626 err = -EPROTONOSUPPORT;
+1 -1
scripts/gdb/linux/symbols.py
··· 180 180 self.breakpoint.delete() 181 181 self.breakpoint = None 182 182 self.breakpoint = LoadModuleBreakpoint( 183 - "kernel/module.c:do_init_module", self) 183 + "kernel/module/main.c:do_init_module", self) 184 184 else: 185 185 gdb.write("Note: symbol update on module loading not supported " 186 186 "with this gdb version\n")
+4
security/integrity/ima/ima_policy.c
··· 2247 2247 if (id >= READING_MAX_ID) 2248 2248 return false; 2249 2249 2250 + if (id == READING_KEXEC_IMAGE && !(ima_appraise & IMA_APPRAISE_ENFORCE) 2251 + && security_locked_down(LOCKDOWN_KEXEC)) 2252 + return false; 2253 + 2250 2254 func = read_idmap[id] ?: FILE_CHECK; 2251 2255 2252 2256 rcu_read_lock();
+10 -2
tools/arch/x86/include/asm/cpufeatures.h
··· 203 203 #define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ 204 204 #define X86_FEATURE_XCOMPACTED ( 7*32+10) /* "" Use compacted XSTATE (XSAVES or XSAVEC) */ 205 205 #define X86_FEATURE_PTI ( 7*32+11) /* Kernel Page Table Isolation enabled */ 206 - #define X86_FEATURE_RETPOLINE ( 7*32+12) /* "" Generic Retpoline mitigation for Spectre variant 2 */ 207 - #define X86_FEATURE_RETPOLINE_LFENCE ( 7*32+13) /* "" Use LFENCE for Spectre variant 2 */ 206 + #define X86_FEATURE_KERNEL_IBRS ( 7*32+12) /* "" Set/clear IBRS on kernel entry/exit */ 207 + #define X86_FEATURE_RSB_VMEXIT ( 7*32+13) /* "" Fill RSB on VM-Exit */ 208 208 #define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */ 209 209 #define X86_FEATURE_CDP_L2 ( 7*32+15) /* Code and Data Prioritization L2 */ 210 210 #define X86_FEATURE_MSR_SPEC_CTRL ( 7*32+16) /* "" MSR SPEC_CTRL is implemented */ ··· 296 296 #define X86_FEATURE_PER_THREAD_MBA (11*32+ 7) /* "" Per-thread Memory Bandwidth Allocation */ 297 297 #define X86_FEATURE_SGX1 (11*32+ 8) /* "" Basic SGX */ 298 298 #define X86_FEATURE_SGX2 (11*32+ 9) /* "" SGX Enclave Dynamic Memory Management (EDMM) */ 299 + #define X86_FEATURE_ENTRY_IBPB (11*32+10) /* "" Issue an IBPB on kernel entry */ 300 + #define X86_FEATURE_RRSBA_CTRL (11*32+11) /* "" RET prediction control */ 301 + #define X86_FEATURE_RETPOLINE (11*32+12) /* "" Generic Retpoline mitigation for Spectre variant 2 */ 302 + #define X86_FEATURE_RETPOLINE_LFENCE (11*32+13) /* "" Use LFENCE for Spectre variant 2 */ 303 + #define X86_FEATURE_RETHUNK (11*32+14) /* "" Use REturn THUNK */ 304 + #define X86_FEATURE_UNRET (11*32+15) /* "" AMD BTB untrain return */ 299 305 300 306 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ 301 307 #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ ··· 322 316 #define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */ 323 317 #define X86_FEATURE_AMD_SSB_NO (13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */ 324 318 #define X86_FEATURE_CPPC (13*32+27) /* Collaborative Processor Performance Control */ 319 + #define X86_FEATURE_BTC_NO (13*32+29) /* "" Not vulnerable to Branch Type Confusion */ 325 320 #define X86_FEATURE_BRS (13*32+31) /* Branch Sampling available */ 326 321 327 322 /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ ··· 454 447 #define X86_BUG_ITLB_MULTIHIT X86_BUG(23) /* CPU may incur MCE during certain page attribute changes */ 455 448 #define X86_BUG_SRBDS X86_BUG(24) /* CPU may leak RNG bits if not mitigated */ 456 449 #define X86_BUG_MMIO_STALE_DATA X86_BUG(25) /* CPU is affected by Processor MMIO Stale Data vulnerabilities */ 450 + #define X86_BUG_RETBLEED X86_BUG(26) /* CPU is affected by RETBleed */ 457 451 458 452 #endif /* _ASM_X86_CPUFEATURES_H */
+20 -1
tools/arch/x86/include/asm/disabled-features.h
··· 50 50 # define DISABLE_PTI (1 << (X86_FEATURE_PTI & 31)) 51 51 #endif 52 52 53 + #ifdef CONFIG_RETPOLINE 54 + # define DISABLE_RETPOLINE 0 55 + #else 56 + # define DISABLE_RETPOLINE ((1 << (X86_FEATURE_RETPOLINE & 31)) | \ 57 + (1 << (X86_FEATURE_RETPOLINE_LFENCE & 31))) 58 + #endif 59 + 60 + #ifdef CONFIG_RETHUNK 61 + # define DISABLE_RETHUNK 0 62 + #else 63 + # define DISABLE_RETHUNK (1 << (X86_FEATURE_RETHUNK & 31)) 64 + #endif 65 + 66 + #ifdef CONFIG_CPU_UNRET_ENTRY 67 + # define DISABLE_UNRET 0 68 + #else 69 + # define DISABLE_UNRET (1 << (X86_FEATURE_UNRET & 31)) 70 + #endif 71 + 53 72 #ifdef CONFIG_INTEL_IOMMU_SVM 54 73 # define DISABLE_ENQCMD 0 55 74 #else ··· 101 82 #define DISABLED_MASK8 (DISABLE_TDX_GUEST) 102 83 #define DISABLED_MASK9 (DISABLE_SGX) 103 84 #define DISABLED_MASK10 0 104 - #define DISABLED_MASK11 0 85 + #define DISABLED_MASK11 (DISABLE_RETPOLINE|DISABLE_RETHUNK|DISABLE_UNRET) 105 86 #define DISABLED_MASK12 0 106 87 #define DISABLED_MASK13 0 107 88 #define DISABLED_MASK14 0
+4
tools/arch/x86/include/asm/msr-index.h
··· 95 95 #define MSR_IA32_ARCH_CAPABILITIES 0x0000010a 96 96 #define ARCH_CAP_RDCL_NO BIT(0) /* Not susceptible to Meltdown */ 97 97 #define ARCH_CAP_IBRS_ALL BIT(1) /* Enhanced IBRS support */ 98 + #define ARCH_CAP_RSBA BIT(2) /* RET may use alternative branch predictors */ 98 99 #define ARCH_CAP_SKIP_VMENTRY_L1DFLUSH BIT(3) /* Skip L1D flush on vmentry */ 99 100 #define ARCH_CAP_SSB_NO BIT(4) /* 100 101 * Not susceptible to Speculative Store Bypass ··· 576 575 577 576 /* Fam 17h MSRs */ 578 577 #define MSR_F17H_IRPERF 0xc00000e9 578 + 579 + #define MSR_ZEN2_SPECTRAL_CHICKEN 0xc00110e3 580 + #define MSR_ZEN2_SPECTRAL_CHICKEN_BIT BIT_ULL(1) 579 581 580 582 /* Fam 16h MSRs */ 581 583 #define MSR_F16H_L2I_PERF_CTL 0xc0010230
+1
tools/include/uapi/linux/kvm.h
··· 2083 2083 #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT) 2084 2084 #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT) 2085 2085 #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT) 2086 + #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT) 2086 2087 #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES 2087 2088 2088 2089 #define KVM_STATS_BASE_SHIFT 8
+2
tools/perf/builtin-trace.c
··· 4280 4280 goto out; 4281 4281 4282 4282 evsel = evlist__find_tracepoint_by_name(session->evlist, "raw_syscalls:sys_enter"); 4283 + trace->syscalls.events.sys_enter = evsel; 4283 4284 /* older kernels have syscalls tp versus raw_syscalls */ 4284 4285 if (evsel == NULL) 4285 4286 evsel = evlist__find_tracepoint_by_name(session->evlist, "syscalls:sys_enter"); ··· 4293 4292 } 4294 4293 4295 4294 evsel = evlist__find_tracepoint_by_name(session->evlist, "raw_syscalls:sys_exit"); 4295 + trace->syscalls.events.sys_exit = evsel; 4296 4296 if (evsel == NULL) 4297 4297 evsel = evlist__find_tracepoint_by_name(session->evlist, "syscalls:sys_exit"); 4298 4298 if (evsel &&
+10 -17
tools/perf/tests/perf-time-to-tsc.c
··· 20 20 #include "tsc.h" 21 21 #include "mmap.h" 22 22 #include "tests.h" 23 - #include "pmu.h" 24 - #include "pmu-hybrid.h" 25 23 26 24 /* 27 25 * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just ··· 104 106 105 107 evlist__config(evlist, &opts, NULL); 106 108 107 - evsel = evlist__first(evlist); 108 - 109 - evsel->core.attr.comm = 1; 110 - evsel->core.attr.disabled = 1; 111 - evsel->core.attr.enable_on_exec = 0; 112 - 113 - /* 114 - * For hybrid "cycles:u", it creates two events. 115 - * Init the second evsel here. 116 - */ 117 - if (perf_pmu__has_hybrid() && perf_pmu__hybrid_mounted("cpu_atom")) { 118 - evsel = evsel__next(evsel); 109 + /* For hybrid "cycles:u", it creates two events */ 110 + evlist__for_each_entry(evlist, evsel) { 119 111 evsel->core.attr.comm = 1; 120 112 evsel->core.attr.disabled = 1; 121 113 evsel->core.attr.enable_on_exec = 0; 122 114 } 123 115 124 - if (evlist__open(evlist) == -ENOENT) { 125 - err = TEST_SKIP; 116 + ret = evlist__open(evlist); 117 + if (ret < 0) { 118 + if (ret == -ENOENT) 119 + err = TEST_SKIP; 120 + else 121 + pr_debug("evlist__open() failed\n"); 126 122 goto out_err; 127 123 } 128 - CHECK__(evlist__open(evlist)); 129 124 130 125 CHECK__(evlist__mmap(evlist, UINT_MAX)); 131 126 ··· 158 167 goto next_event; 159 168 160 169 if (strcmp(event->comm.comm, comm1) == 0) { 170 + CHECK_NOT_NULL__(evsel = evlist__event2evsel(evlist, event)); 161 171 CHECK__(evsel__parse_sample(evsel, event, &sample)); 162 172 comm1_time = sample.time; 163 173 } 164 174 if (strcmp(event->comm.comm, comm2) == 0) { 175 + CHECK_NOT_NULL__(evsel = evlist__event2evsel(evlist, event)); 165 176 CHECK__(evsel__parse_sample(evsel, event, &sample)); 166 177 comm2_time = sample.time; 167 178 }