···301301 void (*issue_read)(struct netfs_io_subrequest *subreq);302302 bool (*is_still_valid)(struct netfs_io_request *rreq);303303 int (*check_write_begin)(struct file *file, loff_t pos, unsigned len,304304- struct folio *folio, void **_fsdata);304304+ struct folio **foliop, void **_fsdata);305305 void (*done)(struct netfs_io_request *rreq);306306 };307307···381381 allocated/grabbed the folio to be modified to allow the filesystem to flush382382 conflicting state before allowing it to be modified.383383384384- It should return 0 if everything is now fine, -EAGAIN if the folio should be385385- regrabbed and any other error code to abort the operation.384384+ It may unlock and discard the folio it was given and set the caller's folio385385+ pointer to NULL. It should return 0 if everything is now fine (``*foliop``386386+ left set) or the op should be retried (``*foliop`` cleared) and any other387387+ error code to abort the operation.386388387389 * ``done``388390
+303-60
Documentation/networking/dsa/dsa.rst
···503503Driver development504504==================505505506506-DSA switch drivers need to implement a dsa_switch_ops structure which will506506+DSA switch drivers need to implement a ``dsa_switch_ops`` structure which will507507contain the various members described below.508508509509-``register_switch_driver()`` registers this dsa_switch_ops in its internal list510510-of drivers to probe for. ``unregister_switch_driver()`` does the exact opposite.509509+Probing, registration and device lifetime510510+-----------------------------------------511511512512-Unless requested differently by setting the priv_size member accordingly, DSA513513-does not allocate any driver private context space.512512+DSA switches are regular ``device`` structures on buses (be they platform, SPI,513513+I2C, MDIO or otherwise). The DSA framework is not involved in their probing514514+with the device core.515515+516516+Switch registration from the perspective of a driver means passing a valid517517+``struct dsa_switch`` pointer to ``dsa_register_switch()``, usually from the518518+switch driver's probing function. The following members must be valid in the519519+provided structure:520520+521521+- ``ds->dev``: will be used to parse the switch's OF node or platform data.522522+523523+- ``ds->num_ports``: will be used to create the port list for this switch, and524524+ to validate the port indices provided in the OF node.525525+526526+- ``ds->ops``: a pointer to the ``dsa_switch_ops`` structure holding the DSA527527+ method implementations.528528+529529+- ``ds->priv``: backpointer to a driver-private data structure which can be530530+ retrieved in all further DSA method callbacks.531531+532532+In addition, the following flags in the ``dsa_switch`` structure may optionally533533+be configured to obtain driver-specific behavior from the DSA core. Their534534+behavior when set is documented through comments in ``include/net/dsa.h``.535535+536536+- ``ds->vlan_filtering_is_global``537537+538538+- ``ds->needs_standalone_vlan_filtering``539539+540540+- ``ds->configure_vlan_while_not_filtering``541541+542542+- ``ds->untag_bridge_pvid``543543+544544+- ``ds->assisted_learning_on_cpu_port``545545+546546+- ``ds->mtu_enforcement_ingress``547547+548548+- ``ds->fdb_isolation``549549+550550+Internally, DSA keeps an array of switch trees (group of switches) global to551551+the kernel, and attaches a ``dsa_switch`` structure to a tree on registration.552552+The tree ID to which the switch is attached is determined by the first u32553553+number of the ``dsa,member`` property of the switch's OF node (0 if missing).554554+The switch ID within the tree is determined by the second u32 number of the555555+same OF property (0 if missing). Registering multiple switches with the same556556+switch ID and tree ID is illegal and will cause an error. Using platform data,557557+a single switch and a single switch tree is permitted.558558+559559+In case of a tree with multiple switches, probing takes place asymmetrically.560560+The first N-1 callers of ``dsa_register_switch()`` only add their ports to the561561+port list of the tree (``dst->ports``), each port having a backpointer to its562562+associated switch (``dp->ds``). Then, these switches exit their563563+``dsa_register_switch()`` call early, because ``dsa_tree_setup_routing_table()``564564+has determined that the tree is not yet complete (not all ports referenced by565565+DSA links are present in the tree's port list). The tree becomes complete when566566+the last switch calls ``dsa_register_switch()``, and this triggers the effective567567+continuation of initialization (including the call to ``ds->ops->setup()``) for568568+all switches within that tree, all as part of the calling context of the last569569+switch's probe function.570570+571571+The opposite of registration takes place when calling ``dsa_unregister_switch()``,572572+which removes a switch's ports from the port list of the tree. The entire tree573573+is torn down when the first switch unregisters.574574+575575+It is mandatory for DSA switch drivers to implement the ``shutdown()`` callback576576+of their respective bus, and call ``dsa_switch_shutdown()`` from it (a minimal577577+version of the full teardown performed by ``dsa_unregister_switch()``).578578+The reason is that DSA keeps a reference on the master net device, and if the579579+driver for the master device decides to unbind on shutdown, DSA's reference580580+will block that operation from finalizing.581581+582582+Either ``dsa_switch_shutdown()`` or ``dsa_unregister_switch()`` must be called,583583+but not both, and the device driver model permits the bus' ``remove()`` method584584+to be called even if ``shutdown()`` was already called. Therefore, drivers are585585+expected to implement a mutual exclusion method between ``remove()`` and586586+``shutdown()`` by setting their drvdata to NULL after any of these has run, and587587+checking whether the drvdata is NULL before proceeding to take any action.588588+589589+After ``dsa_switch_shutdown()`` or ``dsa_unregister_switch()`` was called, no590590+further callbacks via the provided ``dsa_switch_ops`` may take place, and the591591+driver may free the data structures associated with the ``dsa_switch``.514592515593Switch configuration516594--------------------517595518518-- ``tag_protocol``: this is to indicate what kind of tagging protocol is supported,519519- should be a valid value from the ``dsa_tag_protocol`` enum596596+- ``get_tag_protocol``: this is to indicate what kind of tagging protocol is597597+ supported, should be a valid value from the ``dsa_tag_protocol`` enum.598598+ The returned information does not have to be static; the driver is passed the599599+ CPU port number, as well as the tagging protocol of a possibly stacked600600+ upstream switch, in case there are hardware limitations in terms of supported601601+ tag formats.520602521521-- ``probe``: probe routine which will be invoked by the DSA platform device upon522522- registration to test for the presence/absence of a switch device. For MDIO523523- devices, it is recommended to issue a read towards internal registers using524524- the switch pseudo-PHY and return whether this is a supported device. For other525525- buses, return a non-NULL string603603+- ``change_tag_protocol``: when the default tagging protocol has compatibility604604+ problems with the master or other issues, the driver may support changing it605605+ at runtime, either through a device tree property or through sysfs. In that606606+ case, further calls to ``get_tag_protocol`` should report the protocol in607607+ current use.526608527609- ``setup``: setup function for the switch, this function is responsible for setting528610 up the ``dsa_switch_ops`` private structure with all it needs: register maps,···617535 fully configured and ready to serve any kind of request. It is recommended618536 to issue a software reset of the switch during this setup function in order to619537 avoid relying on what a previous software agent such as a bootloader/firmware620620- may have previously configured.538538+ may have previously configured. The method responsible for undoing any539539+ applicable allocations or operations done here is ``teardown``.540540+541541+- ``port_setup`` and ``port_teardown``: methods for initialization and542542+ destruction of per-port data structures. It is mandatory for some operations543543+ such as registering and unregistering devlink port regions to be done from544544+ these methods, otherwise they are optional. A port will be torn down only if545545+ it has been previously set up. It is possible for a port to be set up during546546+ probing only to be torn down immediately afterwards, for example in case its547547+ PHY cannot be found. In this case, probing of the DSA switch continues548548+ without that particular port.621549622550PHY devices and link management623551-------------------------------···727635 ``BR_STATE_DISABLED`` and propagating changes to the hardware if this port is728636 disabled while being a bridge member729637638638+Address databases639639+-----------------640640+641641+Switching hardware is expected to have a table for FDB entries, however not all642642+of them are active at the same time. An address database is the subset (partition)643643+of FDB entries that is active (can be matched by address learning on RX, or FDB644644+lookup on TX) depending on the state of the port. An address database may645645+occasionally be called "FID" (Filtering ID) in this document, although the646646+underlying implementation may choose whatever is available to the hardware.647647+648648+For example, all ports that belong to a VLAN-unaware bridge (which is649649+*currently* VLAN-unaware) are expected to learn source addresses in the650650+database associated by the driver with that bridge (and not with other651651+VLAN-unaware bridges). During forwarding and FDB lookup, a packet received on a652652+VLAN-unaware bridge port should be able to find a VLAN-unaware FDB entry having653653+the same MAC DA as the packet, which is present on another port member of the654654+same bridge. At the same time, the FDB lookup process must be able to not find655655+an FDB entry having the same MAC DA as the packet, if that entry points towards656656+a port which is a member of a different VLAN-unaware bridge (and is therefore657657+associated with a different address database).658658+659659+Similarly, each VLAN of each offloaded VLAN-aware bridge should have an660660+associated address database, which is shared by all ports which are members of661661+that VLAN, but not shared by ports belonging to different bridges that are662662+members of the same VID.663663+664664+In this context, a VLAN-unaware database means that all packets are expected to665665+match on it irrespective of VLAN ID (only MAC address lookup), whereas a666666+VLAN-aware database means that packets are supposed to match based on the VLAN667667+ID from the classified 802.1Q header (or the pvid if untagged).668668+669669+At the bridge layer, VLAN-unaware FDB entries have the special VID value of 0,670670+whereas VLAN-aware FDB entries have non-zero VID values. Note that a671671+VLAN-unaware bridge may have VLAN-aware (non-zero VID) FDB entries, and a672672+VLAN-aware bridge may have VLAN-unaware FDB entries. As in hardware, the673673+software bridge keeps separate address databases, and offloads to hardware the674674+FDB entries belonging to these databases, through switchdev, asynchronously675675+relative to the moment when the databases become active or inactive.676676+677677+When a user port operates in standalone mode, its driver should configure it to678678+use a separate database called a port private database. This is different from679679+the databases described above, and should impede operation as standalone port680680+(packet in, packet out to the CPU port) as little as possible. For example,681681+on ingress, it should not attempt to learn the MAC SA of ingress traffic, since682682+learning is a bridging layer service and this is a standalone port, therefore683683+it would consume useless space. With no address learning, the port private684684+database should be empty in a naive implementation, and in this case, all685685+received packets should be trivially flooded to the CPU port.686686+687687+DSA (cascade) and CPU ports are also called "shared" ports because they service688688+multiple address databases, and the database that a packet should be associated689689+to is usually embedded in the DSA tag. This means that the CPU port may690690+simultaneously transport packets coming from a standalone port (which were691691+classified by hardware in one address database), and from a bridge port (which692692+were classified to a different address database).693693+694694+Switch drivers which satisfy certain criteria are able to optimize the naive695695+configuration by removing the CPU port from the flooding domain of the switch,696696+and just program the hardware with FDB entries pointing towards the CPU port697697+for which it is known that software is interested in those MAC addresses.698698+Packets which do not match a known FDB entry will not be delivered to the CPU,699699+which will save CPU cycles required for creating an skb just to drop it.700700+701701+DSA is able to perform host address filtering for the following kinds of702702+addresses:703703+704704+- Primary unicast MAC addresses of ports (``dev->dev_addr``). These are705705+ associated with the port private database of the respective user port,706706+ and the driver is notified to install them through ``port_fdb_add`` towards707707+ the CPU port.708708+709709+- Secondary unicast and multicast MAC addresses of ports (addresses added710710+ through ``dev_uc_add()`` and ``dev_mc_add()``). These are also associated711711+ with the port private database of the respective user port.712712+713713+- Local/permanent bridge FDB entries (``BR_FDB_LOCAL``). These are the MAC714714+ addresses of the bridge ports, for which packets must be terminated locally715715+ and not forwarded. They are associated with the address database for that716716+ bridge.717717+718718+- Static bridge FDB entries installed towards foreign (non-DSA) interfaces719719+ present in the same bridge as some DSA switch ports. These are also720720+ associated with the address database for that bridge.721721+722722+- Dynamically learned FDB entries on foreign interfaces present in the same723723+ bridge as some DSA switch ports, only if ``ds->assisted_learning_on_cpu_port``724724+ is set to true by the driver. These are associated with the address database725725+ for that bridge.726726+727727+For various operations detailed below, DSA provides a ``dsa_db`` structure728728+which can be of the following types:729729+730730+- ``DSA_DB_PORT``: the FDB (or MDB) entry to be installed or deleted belongs to731731+ the port private database of user port ``db->dp``.732732+- ``DSA_DB_BRIDGE``: the entry belongs to one of the address databases of bridge733733+ ``db->bridge``. Separation between the VLAN-unaware database and the per-VID734734+ databases of this bridge is expected to be done by the driver.735735+- ``DSA_DB_LAG``: the entry belongs to the address database of LAG ``db->lag``.736736+ Note: ``DSA_DB_LAG`` is currently unused and may be removed in the future.737737+738738+The drivers which act upon the ``dsa_db`` argument in ``port_fdb_add``,739739+``port_mdb_add`` etc should declare ``ds->fdb_isolation`` as true.740740+741741+DSA associates each offloaded bridge and each offloaded LAG with a one-based ID742742+(``struct dsa_bridge :: num``, ``struct dsa_lag :: id``) for the purposes of743743+refcounting addresses on shared ports. Drivers may piggyback on DSA's numbering744744+scheme (the ID is readable through ``db->bridge.num`` and ``db->lag.id`` or may745745+implement their own.746746+747747+Only the drivers which declare support for FDB isolation are notified of FDB748748+entries on the CPU port belonging to ``DSA_DB_PORT`` databases.749749+For compatibility/legacy reasons, ``DSA_DB_BRIDGE`` addresses are notified to750750+drivers even if they do not support FDB isolation. However, ``db->bridge.num``751751+and ``db->lag.id`` are always set to 0 in that case (to denote the lack of752752+isolation, for refcounting purposes).753753+754754+Note that it is not mandatory for a switch driver to implement physically755755+separate address databases for each standalone user port. Since FDB entries in756756+the port private databases will always point to the CPU port, there is no risk757757+for incorrect forwarding decisions. In this case, all standalone ports may758758+share the same database, but the reference counting of host-filtered addresses759759+(not deleting the FDB entry for a port's MAC address if it's still in use by760760+another port) becomes the responsibility of the driver, because DSA is unaware761761+that the port databases are in fact shared. This can be achieved by calling762762+``dsa_fdb_present_in_other_db()`` and ``dsa_mdb_present_in_other_db()``.763763+The down side is that the RX filtering lists of each user port are in fact764764+shared, which means that user port A may accept a packet with a MAC DA it765765+shouldn't have, only because that MAC address was in the RX filtering list of766766+user port B. These packets will still be dropped in software, however.767767+730768Bridge layer731769------------770770+771771+Offloading the bridge forwarding plane is optional and handled by the methods772772+below. They may be absent, return -EOPNOTSUPP, or ``ds->max_num_bridges`` may773773+be non-zero and exceeded, and in this case, joining a bridge port is still774774+possible, but the packet forwarding will take place in software, and the ports775775+under a software bridge must remain configured in the same way as for776776+standalone operation, i.e. have all bridging service functions (address777777+learning etc) disabled, and send all received packets to the CPU port only.778778+779779+Concretely, a port starts offloading the forwarding plane of a bridge once it780780+returns success to the ``port_bridge_join`` method, and stops doing so after781781+``port_bridge_leave`` has been called. Offloading the bridge means autonomously782782+learning FDB entries in accordance with the software bridge port's state, and783783+autonomously forwarding (or flooding) received packets without CPU intervention.784784+This is optional even when offloading a bridge port. Tagging protocol drivers785785+are expected to call ``dsa_default_offload_fwd_mark(skb)`` for packets which786786+have already been autonomously forwarded in the forwarding domain of the787787+ingress switch port. DSA, through ``dsa_port_devlink_setup()``, considers all788788+switch ports part of the same tree ID to be part of the same bridge forwarding789789+domain (capable of autonomous forwarding to each other).790790+791791+Offloading the TX forwarding process of a bridge is a distinct concept from792792+simply offloading its forwarding plane, and refers to the ability of certain793793+driver and tag protocol combinations to transmit a single skb coming from the794794+bridge device's transmit function to potentially multiple egress ports (and795795+thereby avoid its cloning in software).796796+797797+Packets for which the bridge requests this behavior are called data plane798798+packets and have ``skb->offload_fwd_mark`` set to true in the tag protocol799799+driver's ``xmit`` function. Data plane packets are subject to FDB lookup,800800+hardware learning on the CPU port, and do not override the port STP state.801801+Additionally, replication of data plane packets (multicast, flooding) is802802+handled in hardware and the bridge driver will transmit a single skb for each803803+packet that may or may not need replication.804804+805805+When the TX forwarding offload is enabled, the tag protocol driver is806806+responsible to inject packets into the data plane of the hardware towards the807807+correct bridging domain (FID) that the port is a part of. The port may be808808+VLAN-unaware, and in this case the FID must be equal to the FID used by the809809+driver for its VLAN-unaware address database associated with that bridge.810810+Alternatively, the bridge may be VLAN-aware, and in that case, it is guaranteed811811+that the packet is also VLAN-tagged with the VLAN ID that the bridge processed812812+this packet in. It is the responsibility of the hardware to untag the VID on813813+the egress-untagged ports, or keep the tag on the egress-tagged ones.732814733815- ``port_bridge_join``: bridge layer function invoked when a given switch port is734816 added to a bridge, this function should do what's necessary at the switch735817 level to permit the joining port to be added to the relevant logical736818 domain for it to ingress/egress traffic with other members of the bridge.819819+ By setting the ``tx_fwd_offload`` argument to true, the TX forwarding process820820+ of this bridge is also offloaded.737821738822- ``port_bridge_leave``: bridge layer function invoked when a given switch port is739823 removed from a bridge, this function should do what's necessary at the740824 switch level to deny the leaving port from ingress/egress traffic from the741741- remaining bridge members. When the port leaves the bridge, it should be aged742742- out at the switch hardware for the switch to (re) learn MAC addresses behind743743- this port.825825+ remaining bridge members.744826745827- ``port_stp_state_set``: bridge layer function invoked when a given switch port STP746828 state is computed by the bridge layer and should be propagated to switch747747- hardware to forward/block/learn traffic. The switch driver is responsible for748748- computing a STP state change based on current and asked parameters and perform749749- the relevant ageing based on the intersection results829829+ hardware to forward/block/learn traffic.750830751831- ``port_bridge_flags``: bridge layer function invoked when a port must752832 configure its settings for e.g. flooding of unknown traffic or source address···931667 CPU port, and flooding towards the CPU port should also be enabled, due to a932668 lack of an explicit address filtering mechanism in the DSA core.933669934934-- ``port_bridge_tx_fwd_offload``: bridge layer function invoked after935935- ``port_bridge_join`` when a driver sets ``ds->num_fwd_offloading_bridges`` to936936- a non-zero value. Returning success in this function activates the TX937937- forwarding offload bridge feature for this port, which enables the tagging938938- protocol driver to inject data plane packets towards the bridging domain that939939- the port is a part of. Data plane packets are subject to FDB lookup, hardware940940- learning on the CPU port, and do not override the port STP state.941941- Additionally, replication of data plane packets (multicast, flooding) is942942- handled in hardware and the bridge driver will transmit a single skb for each943943- packet that needs replication. The method is provided as a configuration944944- point for drivers that need to configure the hardware for enabling this945945- feature.946946-947947-- ``port_bridge_tx_fwd_unoffload``: bridge layer function invoked when a driver948948- leaves a bridge port which had the TX forwarding offload feature enabled.670670+- ``port_fast_age``: bridge layer function invoked when flushing the671671+ dynamically learned FDB entries on the port is necessary. This is called when672672+ transitioning from an STP state where learning should take place to an STP673673+ state where it shouldn't, or when leaving a bridge, or when address learning674674+ is turned off via ``port_bridge_flags``.949675950676Bridge VLAN filtering951677---------------------···951697 allowed.952698953699- ``port_vlan_add``: bridge layer function invoked when a VLAN is configured954954- (tagged or untagged) for the given switch port. If the operation is not955955- supported by the hardware, this function should return ``-EOPNOTSUPP`` to956956- inform the bridge code to fallback to a software implementation.700700+ (tagged or untagged) for the given switch port. The CPU port becomes a member701701+ of a VLAN only if a foreign bridge port is also a member of it (and702702+ forwarding needs to take place in software), or the VLAN is installed to the703703+ VLAN group of the bridge device itself, for termination purposes704704+ (``bridge vlan add dev br0 vid 100 self``). VLANs on shared ports are705705+ reference counted and removed when there is no user left. Drivers do not need706706+ to manually install a VLAN on the CPU port.957707958708- ``port_vlan_del``: bridge layer function invoked when a VLAN is removed from the959709 given switch port960710961961-- ``port_vlan_dump``: bridge layer function invoked with a switchdev callback962962- function that the driver has to call for each VLAN the given port is a member963963- of. A switchdev object is used to carry the VID and bridge flags.964964-965711- ``port_fdb_add``: bridge layer function invoked when the bridge wants to install a966712 Forwarding Database entry, the switch hardware should be programmed with the967713 specified address in the specified VLAN Id in the forwarding database968968- associated with this VLAN ID. If the operation is not supported, this969969- function should return ``-EOPNOTSUPP`` to inform the bridge code to fallback to970970- a software implementation.971971-972972-.. note:: VLAN ID 0 corresponds to the port private database, which, in the context973973- of DSA, would be its port-based VLAN, used by the associated bridge device.714714+ associated with this VLAN ID.974715975716- ``port_fdb_del``: bridge layer function invoked when the bridge wants to remove a976717 Forwarding Database entry, the switch hardware should be programmed to delete977718 the specified MAC address from the specified VLAN ID if it was mapped into978719 this port forwarding database979720980980-- ``port_fdb_dump``: bridge layer function invoked with a switchdev callback981981- function that the driver has to call for each MAC address known to be behind982982- the given port. A switchdev object is used to carry the VID and FDB info.721721+- ``port_fdb_dump``: bridge bypass function invoked by ``ndo_fdb_dump`` on the722722+ physical DSA port interfaces. Since DSA does not attempt to keep in sync its723723+ hardware FDB entries with the software bridge, this method is implemented as724724+ a means to view the entries visible on user ports in the hardware database.725725+ The entries reported by this function have the ``self`` flag in the output of726726+ the ``bridge fdb show`` command.983727984728- ``port_mdb_add``: bridge layer function invoked when the bridge wants to install985985- a multicast database entry. If the operation is not supported, this function986986- should return ``-EOPNOTSUPP`` to inform the bridge code to fallback to a987987- software implementation. The switch hardware should be programmed with the729729+ a multicast database entry. The switch hardware should be programmed with the988730 specified address in the specified VLAN ID in the forwarding database989731 associated with this VLAN ID.990990-991991-.. note:: VLAN ID 0 corresponds to the port private database, which, in the context992992- of DSA, would be its port-based VLAN, used by the associated bridge device.993732994733- ``port_mdb_del``: bridge layer function invoked when the bridge wants to remove a995734 multicast database entry, the switch hardware should be programmed to delete996735 the specified MAC address from the specified VLAN ID if it was mapped into997736 this port forwarding database.998998-999999-- ``port_mdb_dump``: bridge layer function invoked with a switchdev callback10001000- function that the driver has to call for each MAC address known to be behind10011001- the given port. A switchdev object is used to carry the VID and MDB info.10027371003738Link aggregation1004739----------------
+1-5
Documentation/networking/ip-sysctl.rst
···10581058 Default: 4K1059105910601060udp_wmem_min - INTEGER10611061- Minimal size of send buffer used by UDP sockets in moderation.10621062- Each UDP socket is able to use the size for sending data, even if10631063- total pages of UDP sockets exceed udp_mem pressure. The unit is byte.10641064-10651065- Default: 4K10611061+ UDP does not have tx memory accounting and this tunable has no effect.1066106210671063RAW variables10681064=============
+13-4
Documentation/virt/kvm/api.rst
···56575657 #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT)56585658 #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)56595659 #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)56605660+ #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)56605661 #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES5661566256625663 #define KVM_STATS_BASE_SHIFT 8···57035702 by the ``hist_param`` field. The range of the Nth bucket (1 <= N < ``size``)57045703 is [``hist_param``*(N-1), ``hist_param``*N), while the range of the last57055704 bucket is [``hist_param``*(``size``-1), +INF). (+INF means positive infinity57065706- value.) The bucket value indicates how many samples fell in the bucket's range.57055705+ value.)57075706 * ``KVM_STATS_TYPE_LOG_HIST``57085707 The statistic is reported as a logarithmic histogram. The number of57095708 buckets is specified by the ``size`` field. The range of the first bucket is57105709 [0, 1), while the range of the last bucket is [pow(2, ``size``-2), +INF).57115710 Otherwise, The Nth bucket (1 < N < ``size``) covers57125712- [pow(2, N-2), pow(2, N-1)). The bucket value indicates how many samples fell57135713- in the bucket's range.57115711+ [pow(2, N-2), pow(2, N-1)).5714571257155713Bits 4-7 of ``flags`` encode the unit:57165714···57245724 It indicates that the statistics data is used to measure time or latency.57255725 * ``KVM_STATS_UNIT_CYCLES``57265726 It indicates that the statistics data is used to measure CPU clock cycles.57275727+ * ``KVM_STATS_UNIT_BOOLEAN``57285728+ It indicates that the statistic will always be either 0 or 1. Boolean57295729+ statistics of "peak" type will never go back from 1 to 0. Boolean57305730+ statistics can be linear histograms (with two buckets) but not logarithmic57315731+ histograms.57325732+57335733+Note that, in the case of histograms, the unit applies to the bucket57345734+ranges, while the bucket value indicates how many samples fell in the57355735+bucket's range.5727573657285737Bits 8-11 of ``flags``, together with ``exponent``, encode the scale of the57295738unit:···5755574657565747The ``bucket_size`` field is used as a parameter for histogram statistics data.57575748It is only used by linear histogram statistics data, specifying the size of a57585758-bucket.57495749+bucket in the unit expressed by bits 4-11 of ``flags`` together with ``exponent``.5759575057605751The ``name`` field is the name string of the statistics data. The name string57615752starts at the end of ``struct kvm_stats_desc``. The maximum length including
+7-5
MAINTAINERS
···24972497N: oxnas2498249824992499ARM/PALM TREO SUPPORT25002500-M: Tomas Cech <sleep_walker@suse.com>25012500L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)25022502-S: Maintained25032503-W: http://hackndev.com25012501+S: Orphan25042502F: arch/arm/mach-pxa/palmtreo.*2505250325062504ARM/PALMTX,PALMT5,PALMLD,PALMTE2,PALMTC SUPPORT···1437514377F: drivers/net/phy/nxp-c45-tja11xx.c14376143781437714379NXP FSPI DRIVER1437814378-M: Ashish Kumar <ashish.kumar@nxp.com>1438014380+M: Han Xu <han.xu@nxp.com>1438114381+M: Haibo Chen <haibo.chen@nxp.com>1437914382R: Yogesh Gaur <yogeshgaur.83@gmail.com>1438014383L: linux-spi@vger.kernel.org1438114384S: Maintained···1729917300K: riscv17300173011730117302RISC-V/MICROCHIP POLARFIRE SOC SUPPORT1730217302-M: Lewis Hanly <lewis.hanly@microchip.com>1730317303M: Conor Dooley <conor.dooley@microchip.com>1730417304+M: Daire McNamara <daire.mcnamara@microchip.com>1730417305L: linux-riscv@lists.infradead.org1730517306S: Supported1730617307F: arch/riscv/boot/dts/microchip/1730817308+F: drivers/char/hw_random/mpfs-rng.c1730917309+F: drivers/clk/microchip/clk-mpfs.c1730717310F: drivers/mailbox/mailbox-mpfs.c1731117311+F: drivers/pci/controller/pcie-microchip-host.c1730817312F: drivers/soc/microchip/1730917313F: include/soc/microchip/mpfs.h1731017314
···137137 );138138}139139140140-/*141141- * LoongArch doesn't need any special per-pte or per-vma handling, except142142- * we need to flush cache for area to be unmapped.143143- */144144-#define tlb_start_vma(tlb, vma) \145145- do { \146146- if (!(tlb)->fullmm) \147147- flush_cache_range(vma, vma->vm_start, vma->vm_end); \148148- } while (0)149149-#define tlb_end_vma(tlb, vma) do { } while (0)150140#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)151141152142static void tlb_flush(struct mmu_gather *tlb);
···19192020#include <linux/pagemap.h>21212222-#define tlb_start_vma(tlb, vma) do { } while (0)2323-#define tlb_end_vma(tlb, vma) do { } while (0)2422#define __tlb_remove_tlb_entry __tlb_remove_tlb_entry25232624#define tlb_flush tlb_flush
···2222void __flush_tlb_pending(unsigned long, unsigned long, unsigned long *);2323void flush_tlb_pending(void);24242525-#define tlb_start_vma(tlb, vma) do { } while (0)2626-#define tlb_end_vma(tlb, vma) do { } while (0)2725#define tlb_flush(tlb) flush_tlb_pending()28262927/*
···298298 STATS_DESC_COUNTER(VCPU, directed_yield_successful),299299 STATS_DESC_COUNTER(VCPU, preemption_reported),300300 STATS_DESC_COUNTER(VCPU, preemption_other),301301- STATS_DESC_ICOUNTER(VCPU, guest_mode)301301+ STATS_DESC_IBOOLEAN(VCPU, guest_mode)302302};303303304304const struct kvm_stats_header kvm_vcpu_stats_header = {···91439143 */91449144static void kvm_pv_kick_cpu_op(struct kvm *kvm, int apicid)91459145{91469146- struct kvm_lapic_irq lapic_irq;91469146+ /*91479147+ * All other fields are unused for APIC_DM_REMRD, but may be consumed by91489148+ * common code, e.g. for tracing. Defer initialization to the compiler.91499149+ */91509150+ struct kvm_lapic_irq lapic_irq = {91519151+ .delivery_mode = APIC_DM_REMRD,91529152+ .dest_mode = APIC_DEST_PHYSICAL,91539153+ .shorthand = APIC_DEST_NOSHORT,91549154+ .dest_id = apicid,91559155+ };9147915691489148- lapic_irq.shorthand = APIC_DEST_NOSHORT;91499149- lapic_irq.dest_mode = APIC_DEST_PHYSICAL;91509150- lapic_irq.level = 0;91519151- lapic_irq.dest_id = apicid;91529152- lapic_irq.msi_redir_hint = false;91539153-91549154- lapic_irq.delivery_mode = APIC_DM_REMRD;91559157 kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL);91569158}91579159
+12-2
arch/x86/mm/init.c
···7777 [__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,7878};79798080-/* Check that the write-protect PAT entry is set for write-protect */8080+/*8181+ * Check that the write-protect PAT entry is set for write-protect.8282+ * To do this without making assumptions how PAT has been set up (Xen has8383+ * another layout than the kernel), translate the _PAGE_CACHE_MODE_WP cache8484+ * mode via the __cachemode2pte_tbl[] into protection bits (those protection8585+ * bits will select a cache mode of WP or better), and then translate the8686+ * protection bits back into the cache mode using __pte2cm_idx() and the8787+ * __pte2cachemode_tbl[] array. This will return the really used cache mode.8888+ */8189bool x86_has_pat_wp(void)8290{8383- return __pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] == _PAGE_CACHE_MODE_WP;9191+ uint16_t prot = __cachemode2pte_tbl[_PAGE_CACHE_MODE_WP];9292+9393+ return __pte2cachemode_tbl[__pte2cm_idx(prot)] == _PAGE_CACHE_MODE_WP;8494}85958696enum page_cache_mode pgprot2cachemode(pgprot_t pgprot)
···345345 /* there isn't chance to merge the splitted bio */346346 split->bi_opf |= REQ_NOMERGE;347347348348+ blkcg_bio_issue_init(split);348349 bio_chain(split, *bio);349350 trace_block_split(split, (*bio)->bi_iter.bi_sector);350351 submit_bio_noacct(*bio);
···11741174 */11751175static void __cold try_to_generate_entropy(void)11761176{11771177- enum { NUM_TRIAL_SAMPLES = 8192, MAX_SAMPLES_PER_BIT = 32 };11771177+ enum { NUM_TRIAL_SAMPLES = 8192, MAX_SAMPLES_PER_BIT = HZ / 30 };11781178 struct entropy_timer_state stack;11791179 unsigned int i, num_different = 0;11801180 unsigned long last = random_get_entropy();
+6-2
drivers/cpufreq/mediatek-cpufreq.c
···439439440440 /* Both presence and absence of sram regulator are valid cases. */441441 info->sram_reg = regulator_get_optional(cpu_dev, "sram");442442- if (IS_ERR(info->sram_reg))442442+ if (IS_ERR(info->sram_reg)) {443443+ ret = PTR_ERR(info->sram_reg);444444+ if (ret == -EPROBE_DEFER)445445+ goto out_free_resources;446446+443447 info->sram_reg = NULL;444444- else {448448+ } else {445449 ret = regulator_enable(info->sram_reg);446450 if (ret) {447451 dev_warn(cpu_dev, "cpu%d: failed to enable vsram\n", cpu);
+11-10
drivers/firmware/efi/reboot.c
···66#include <linux/efi.h>77#include <linux/reboot.h>8899-static void (*orig_pm_power_off)(void);99+static struct sys_off_handler *efi_sys_off_handler;10101111int efi_reboot_quirk_mode = -1;1212···5151 return false;5252}53535454-static void efi_power_off(void)5454+static int efi_power_off(struct sys_off_data *data)5555{5656 efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);5757- /*5858- * The above call should not return, if it does fall back to5959- * the original power off method (typically ACPI poweroff).6060- */6161- if (orig_pm_power_off)6262- orig_pm_power_off();5757+5858+ return NOTIFY_DONE;6359}64606561static int __init efi_shutdown_init(void)···6468 return -ENODEV;65696670 if (efi_poweroff_required()) {6767- orig_pm_power_off = pm_power_off;6868- pm_power_off = efi_power_off;7171+ /* SYS_OFF_PRIO_FIRMWARE + 1 so that it runs before acpi_power_off */7272+ efi_sys_off_handler =7373+ register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,7474+ SYS_OFF_PRIO_FIRMWARE + 1,7575+ efi_power_off, NULL);7676+ if (IS_ERR(efi_sys_off_handler))7777+ return PTR_ERR(efi_sys_off_handler);6978 }70797180 return 0;
···421421 * @work: the worker that implements software debouncing422422 * @sw_debounced: flag indicating if the software debouncer is active423423 * @level: the current debounced physical level of the line424424+ * @hdesc: the Hardware Timestamp Engine (HTE) descriptor425425+ * @raw_level: the line level at the time of event426426+ * @total_discard_seq: the running counter of the discarded events427427+ * @last_seqno: the last sequence number before debounce period expires424428 */425429struct line {426430 struct gpio_desc *desc;
-1
drivers/gpu/drm/Kconfig
···256256 select HWMON257257 select BACKLIGHT_CLASS_DEVICE258258 select INTERVAL_TREE259259- select DRM_BUDDY260259 help261260 Choose this option if you have a recent AMD Radeon graphics card.262261
···3232#include "atom.h"33333434struct amdgpu_vram_reservation {3535- u64 start;3636- u64 size;3737- struct list_head allocated;3838- struct list_head blocks;3535+ struct list_head node;3636+ struct drm_mm_node mm_node;3937};40384139static inline struct amdgpu_vram_mgr *···186188};187189188190/**189189- * amdgpu_vram_mgr_vis_size - Calculate visible block size191191+ * amdgpu_vram_mgr_vis_size - Calculate visible node size190192 *191193 * @adev: amdgpu_device pointer192192- * @block: DRM BUDDY block structure194194+ * @node: MM node structure193195 *194194- * Calculate how many bytes of the DRM BUDDY block are inside visible VRAM196196+ * Calculate how many bytes of the MM node are inside visible VRAM195197 */196198static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev,197197- struct drm_buddy_block *block)199199+ struct drm_mm_node *node)198200{199199- u64 start = amdgpu_vram_mgr_block_start(block);200200- u64 end = start + amdgpu_vram_mgr_block_size(block);201201+ uint64_t start = node->start << PAGE_SHIFT;202202+ uint64_t end = (node->size + node->start) << PAGE_SHIFT;201203202204 if (start >= adev->gmc.visible_vram_size)203205 return 0;···218220{219221 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);220222 struct ttm_resource *res = bo->tbo.resource;221221- struct amdgpu_vram_mgr_resource *vres = to_amdgpu_vram_mgr_resource(res);222222- struct drm_buddy_block *block;223223- u64 usage = 0;223223+ unsigned pages = res->num_pages;224224+ struct drm_mm_node *mm;225225+ u64 usage;224226225227 if (amdgpu_gmc_vram_full_visible(&adev->gmc))226228 return amdgpu_bo_size(bo);···228230 if (res->start >= adev->gmc.visible_vram_size >> PAGE_SHIFT)229231 return 0;230232231231- list_for_each_entry(block, &vres->blocks, link)232232- usage += amdgpu_vram_mgr_vis_size(adev, block);233233+ mm = &container_of(res, struct ttm_range_mgr_node, base)->mm_nodes[0];234234+ for (usage = 0; pages; pages -= mm->size, mm++)235235+ usage += amdgpu_vram_mgr_vis_size(adev, mm);233236234237 return usage;235238}···240241{241242 struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);242243 struct amdgpu_device *adev = to_amdgpu_device(mgr);243243- struct drm_buddy *mm = &mgr->mm;244244+ struct drm_mm *mm = &mgr->mm;244245 struct amdgpu_vram_reservation *rsv, *temp;245245- struct drm_buddy_block *block;246246 uint64_t vis_usage;247247248248- list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, blocks) {249249- if (drm_buddy_alloc_blocks(mm, rsv->start, rsv->start + rsv->size,250250- rsv->size, mm->chunk_size, &rsv->allocated,251251- DRM_BUDDY_RANGE_ALLOCATION))252252- continue;253253-254254- block = amdgpu_vram_mgr_first_block(&rsv->allocated);255255- if (!block)248248+ list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, node) {249249+ if (drm_mm_reserve_node(mm, &rsv->mm_node))256250 continue;257251258252 dev_dbg(adev->dev, "Reservation 0x%llx - %lld, Succeeded\n",259259- rsv->start, rsv->size);253253+ rsv->mm_node.start, rsv->mm_node.size);260254261261- vis_usage = amdgpu_vram_mgr_vis_size(adev, block);255255+ vis_usage = amdgpu_vram_mgr_vis_size(adev, &rsv->mm_node);262256 atomic64_add(vis_usage, &mgr->vis_usage);263257 spin_lock(&man->bdev->lru_lock);264264- man->usage += rsv->size;258258+ man->usage += rsv->mm_node.size << PAGE_SHIFT;265259 spin_unlock(&man->bdev->lru_lock);266266- list_move(&rsv->blocks, &mgr->reserved_pages);260260+ list_move(&rsv->node, &mgr->reserved_pages);267261 }268262}269263···278286 if (!rsv)279287 return -ENOMEM;280288281281- INIT_LIST_HEAD(&rsv->allocated);282282- INIT_LIST_HEAD(&rsv->blocks);289289+ INIT_LIST_HEAD(&rsv->node);290290+ rsv->mm_node.start = start >> PAGE_SHIFT;291291+ rsv->mm_node.size = size >> PAGE_SHIFT;283292284284- rsv->start = start;285285- rsv->size = size;286286-287287- mutex_lock(&mgr->lock);288288- list_add_tail(&rsv->blocks, &mgr->reservations_pending);293293+ spin_lock(&mgr->lock);294294+ list_add_tail(&rsv->node, &mgr->reservations_pending);289295 amdgpu_vram_mgr_do_reserve(&mgr->manager);290290- mutex_unlock(&mgr->lock);296296+ spin_unlock(&mgr->lock);291297292298 return 0;293299}···307317 struct amdgpu_vram_reservation *rsv;308318 int ret;309319310310- mutex_lock(&mgr->lock);320320+ spin_lock(&mgr->lock);311321312312- list_for_each_entry(rsv, &mgr->reservations_pending, blocks) {313313- if (rsv->start <= start &&314314- (start < (rsv->start + rsv->size))) {322322+ list_for_each_entry(rsv, &mgr->reservations_pending, node) {323323+ if ((rsv->mm_node.start <= start) &&324324+ (start < (rsv->mm_node.start + rsv->mm_node.size))) {315325 ret = -EBUSY;316326 goto out;317327 }318328 }319329320320- list_for_each_entry(rsv, &mgr->reserved_pages, blocks) {321321- if (rsv->start <= start &&322322- (start < (rsv->start + rsv->size))) {330330+ list_for_each_entry(rsv, &mgr->reserved_pages, node) {331331+ if ((rsv->mm_node.start <= start) &&332332+ (start < (rsv->mm_node.start + rsv->mm_node.size))) {323333 ret = 0;324334 goto out;325335 }···327337328338 ret = -ENOENT;329339out:330330- mutex_unlock(&mgr->lock);340340+ spin_unlock(&mgr->lock);331341 return ret;342342+}343343+344344+/**345345+ * amdgpu_vram_mgr_virt_start - update virtual start address346346+ *347347+ * @mem: ttm_resource to update348348+ * @node: just allocated node349349+ *350350+ * Calculate a virtual BO start address to easily check if everything is CPU351351+ * accessible.352352+ */353353+static void amdgpu_vram_mgr_virt_start(struct ttm_resource *mem,354354+ struct drm_mm_node *node)355355+{356356+ unsigned long start;357357+358358+ start = node->start + node->size;359359+ if (start > mem->num_pages)360360+ start -= mem->num_pages;361361+ else362362+ start = 0;363363+ mem->start = max(mem->start, start);332364}333365334366/**···368356 const struct ttm_place *place,369357 struct ttm_resource **res)370358{371371- u64 vis_usage = 0, max_bytes, cur_size, min_block_size;359359+ unsigned long lpfn, num_nodes, pages_per_node, pages_left, pages;372360 struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);373361 struct amdgpu_device *adev = to_amdgpu_device(mgr);374374- struct amdgpu_vram_mgr_resource *vres;375375- u64 size, remaining_size, lpfn, fpfn;376376- struct drm_buddy *mm = &mgr->mm;377377- struct drm_buddy_block *block;378378- unsigned long pages_per_block;362362+ uint64_t vis_usage = 0, mem_bytes, max_bytes;363363+ struct ttm_range_mgr_node *node;364364+ struct drm_mm *mm = &mgr->mm;365365+ enum drm_mm_insert_mode mode;366366+ unsigned i;379367 int r;380368381381- lpfn = place->lpfn << PAGE_SHIFT;369369+ lpfn = place->lpfn;382370 if (!lpfn)383383- lpfn = man->size;384384-385385- fpfn = place->fpfn << PAGE_SHIFT;371371+ lpfn = man->size >> PAGE_SHIFT;386372387373 max_bytes = adev->gmc.mc_vram_size;388374 if (tbo->type != ttm_bo_type_kernel)389375 max_bytes -= AMDGPU_VM_RESERVED_VRAM;390376377377+ mem_bytes = tbo->base.size;391378 if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {392392- pages_per_block = ~0ul;379379+ pages_per_node = ~0ul;380380+ num_nodes = 1;393381 } else {394382#ifdef CONFIG_TRANSPARENT_HUGEPAGE395395- pages_per_block = HPAGE_PMD_NR;383383+ pages_per_node = HPAGE_PMD_NR;396384#else397385 /* default to 2MB */398398- pages_per_block = 2UL << (20UL - PAGE_SHIFT);386386+ pages_per_node = 2UL << (20UL - PAGE_SHIFT);399387#endif400400- pages_per_block = max_t(uint32_t, pages_per_block,401401- tbo->page_alignment);388388+ pages_per_node = max_t(uint32_t, pages_per_node,389389+ tbo->page_alignment);390390+ num_nodes = DIV_ROUND_UP_ULL(PFN_UP(mem_bytes), pages_per_node);402391 }403392404404- vres = kzalloc(sizeof(*vres), GFP_KERNEL);405405- if (!vres)393393+ node = kvmalloc(struct_size(node, mm_nodes, num_nodes),394394+ GFP_KERNEL | __GFP_ZERO);395395+ if (!node)406396 return -ENOMEM;407397408408- ttm_resource_init(tbo, place, &vres->base);398398+ ttm_resource_init(tbo, place, &node->base);409399410400 /* bail out quickly if there's likely not enough VRAM for this BO */411401 if (ttm_resource_manager_usage(man) > max_bytes) {···415401 goto error_fini;416402 }417403418418- INIT_LIST_HEAD(&vres->blocks);419419-404404+ mode = DRM_MM_INSERT_BEST;420405 if (place->flags & TTM_PL_FLAG_TOPDOWN)421421- vres->flags |= DRM_BUDDY_TOPDOWN_ALLOCATION;406406+ mode = DRM_MM_INSERT_HIGH;422407423423- if (fpfn || lpfn != man->size)424424- /* Allocate blocks in desired range */425425- vres->flags |= DRM_BUDDY_RANGE_ALLOCATION;408408+ pages_left = node->base.num_pages;426409427427- remaining_size = vres->base.num_pages << PAGE_SHIFT;410410+ /* Limit maximum size to 2GB due to SG table limitations */411411+ pages = min(pages_left, 2UL << (30 - PAGE_SHIFT));428412429429- mutex_lock(&mgr->lock);430430- while (remaining_size) {431431- if (tbo->page_alignment)432432- min_block_size = tbo->page_alignment << PAGE_SHIFT;433433- else434434- min_block_size = mgr->default_page_size;413413+ i = 0;414414+ spin_lock(&mgr->lock);415415+ while (pages_left) {416416+ uint32_t alignment = tbo->page_alignment;435417436436- BUG_ON(min_block_size < mm->chunk_size);418418+ if (pages >= pages_per_node)419419+ alignment = pages_per_node;437420438438- /* Limit maximum size to 2GiB due to SG table limitations */439439- size = min(remaining_size, 2ULL << 30);440440-441441- if (size >= pages_per_block << PAGE_SHIFT)442442- min_block_size = pages_per_block << PAGE_SHIFT;443443-444444- cur_size = size;445445-446446- if (fpfn + size != place->lpfn << PAGE_SHIFT) {447447- /*448448- * Except for actual range allocation, modify the size and449449- * min_block_size conforming to continuous flag enablement450450- */451451- if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {452452- size = roundup_pow_of_two(size);453453- min_block_size = size;454454- /*455455- * Modify the size value if size is not456456- * aligned with min_block_size457457- */458458- } else if (!IS_ALIGNED(size, min_block_size)) {459459- size = round_up(size, min_block_size);421421+ r = drm_mm_insert_node_in_range(mm, &node->mm_nodes[i], pages,422422+ alignment, 0, place->fpfn,423423+ lpfn, mode);424424+ if (unlikely(r)) {425425+ if (pages > pages_per_node) {426426+ if (is_power_of_2(pages))427427+ pages = pages / 2;428428+ else429429+ pages = rounddown_pow_of_two(pages);430430+ continue;460431 }432432+ goto error_free;461433 }462434463463- r = drm_buddy_alloc_blocks(mm, fpfn,464464- lpfn,465465- size,466466- min_block_size,467467- &vres->blocks,468468- vres->flags);469469- if (unlikely(r))470470- goto error_free_blocks;435435+ vis_usage += amdgpu_vram_mgr_vis_size(adev, &node->mm_nodes[i]);436436+ amdgpu_vram_mgr_virt_start(&node->base, &node->mm_nodes[i]);437437+ pages_left -= pages;438438+ ++i;471439472472- if (size > remaining_size)473473- remaining_size = 0;474474- else475475- remaining_size -= size;440440+ if (pages > pages_left)441441+ pages = pages_left;476442 }477477- mutex_unlock(&mgr->lock);443443+ spin_unlock(&mgr->lock);478444479479- if (cur_size != size) {480480- struct drm_buddy_block *block;481481- struct list_head *trim_list;482482- u64 original_size;483483- LIST_HEAD(temp);484484-485485- trim_list = &vres->blocks;486486- original_size = vres->base.num_pages << PAGE_SHIFT;487487-488488- /*489489- * If size value is rounded up to min_block_size, trim the last490490- * block to the required size491491- */492492- if (!list_is_singular(&vres->blocks)) {493493- block = list_last_entry(&vres->blocks, typeof(*block), link);494494- list_move_tail(&block->link, &temp);495495- trim_list = &temp;496496- /*497497- * Compute the original_size value by subtracting the498498- * last block size with (aligned size - original size)499499- */500500- original_size = amdgpu_vram_mgr_block_size(block) - (size - cur_size);501501- }502502-503503- mutex_lock(&mgr->lock);504504- drm_buddy_block_trim(mm,505505- original_size,506506- trim_list);507507- mutex_unlock(&mgr->lock);508508-509509- if (!list_empty(&temp))510510- list_splice_tail(trim_list, &vres->blocks);511511- }512512-513513- list_for_each_entry(block, &vres->blocks, link)514514- vis_usage += amdgpu_vram_mgr_vis_size(adev, block);515515-516516- block = amdgpu_vram_mgr_first_block(&vres->blocks);517517- if (!block) {518518- r = -EINVAL;519519- goto error_fini;520520- }521521-522522- vres->base.start = amdgpu_vram_mgr_block_start(block) >> PAGE_SHIFT;523523-524524- if (amdgpu_is_vram_mgr_blocks_contiguous(&vres->blocks))525525- vres->base.placement |= TTM_PL_FLAG_CONTIGUOUS;445445+ if (i == 1)446446+ node->base.placement |= TTM_PL_FLAG_CONTIGUOUS;526447527448 if (adev->gmc.xgmi.connected_to_cpu)528528- vres->base.bus.caching = ttm_cached;449449+ node->base.bus.caching = ttm_cached;529450 else530530- vres->base.bus.caching = ttm_write_combined;451451+ node->base.bus.caching = ttm_write_combined;531452532453 atomic64_add(vis_usage, &mgr->vis_usage);533533- *res = &vres->base;454454+ *res = &node->base;534455 return 0;535456536536-error_free_blocks:537537- drm_buddy_free_list(mm, &vres->blocks);538538- mutex_unlock(&mgr->lock);457457+error_free:458458+ while (i--)459459+ drm_mm_remove_node(&node->mm_nodes[i]);460460+ spin_unlock(&mgr->lock);539461error_fini:540540- ttm_resource_fini(man, &vres->base);541541- kfree(vres);462462+ ttm_resource_fini(man, &node->base);463463+ kvfree(node);542464543465 return r;544466}···490540static void amdgpu_vram_mgr_del(struct ttm_resource_manager *man,491541 struct ttm_resource *res)492542{493493- struct amdgpu_vram_mgr_resource *vres = to_amdgpu_vram_mgr_resource(res);543543+ struct ttm_range_mgr_node *node = to_ttm_range_mgr_node(res);494544 struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);495545 struct amdgpu_device *adev = to_amdgpu_device(mgr);496496- struct drm_buddy *mm = &mgr->mm;497497- struct drm_buddy_block *block;498546 uint64_t vis_usage = 0;547547+ unsigned i, pages;499548500500- mutex_lock(&mgr->lock);501501- list_for_each_entry(block, &vres->blocks, link)502502- vis_usage += amdgpu_vram_mgr_vis_size(adev, block);549549+ spin_lock(&mgr->lock);550550+ for (i = 0, pages = res->num_pages; pages;551551+ pages -= node->mm_nodes[i].size, ++i) {552552+ struct drm_mm_node *mm = &node->mm_nodes[i];503553554554+ drm_mm_remove_node(mm);555555+ vis_usage += amdgpu_vram_mgr_vis_size(adev, mm);556556+ }504557 amdgpu_vram_mgr_do_reserve(man);505505-506506- drm_buddy_free_list(mm, &vres->blocks);507507- mutex_unlock(&mgr->lock);558558+ spin_unlock(&mgr->lock);508559509560 atomic64_sub(vis_usage, &mgr->vis_usage);510561511562 ttm_resource_fini(man, res);512512- kfree(vres);563563+ kvfree(node);513564}514565515566/**···542591 if (!*sgt)543592 return -ENOMEM;544593545545- /* Determine the number of DRM_BUDDY blocks to export */594594+ /* Determine the number of DRM_MM nodes to export */546595 amdgpu_res_first(res, offset, length, &cursor);547596 while (cursor.remaining) {548597 num_entries++;···558607 sg->length = 0;559608560609 /*561561- * Walk down DRM_BUDDY blocks to populate scatterlist nodes562562- * @note: Use iterator api to get first the DRM_BUDDY block610610+ * Walk down DRM_MM nodes to populate scatterlist nodes611611+ * @note: Use iterator api to get first the DRM_MM node563612 * and the number of bytes from it. Access the following564564- * DRM_BUDDY block(s) if more buffer needs to exported613613+ * DRM_MM node(s) if more buffer needs to exported565614 */566615 amdgpu_res_first(res, offset, length, &cursor);567616 for_each_sgtable_sg((*sgt), sg, i) {···648697 struct drm_printer *printer)649698{650699 struct amdgpu_vram_mgr *mgr = to_vram_mgr(man);651651- struct drm_buddy *mm = &mgr->mm;652652- struct drm_buddy_block *block;653700654701 drm_printf(printer, " vis usage:%llu\n",655702 amdgpu_vram_mgr_vis_usage(mgr));656703657657- mutex_lock(&mgr->lock);658658- drm_printf(printer, "default_page_size: %lluKiB\n",659659- mgr->default_page_size >> 10);660660-661661- drm_buddy_print(mm, printer);662662-663663- drm_printf(printer, "reserved:\n");664664- list_for_each_entry(block, &mgr->reserved_pages, link)665665- drm_buddy_block_print(mm, block, printer);666666- mutex_unlock(&mgr->lock);704704+ spin_lock(&mgr->lock);705705+ drm_mm_print(&mgr->mm, printer);706706+ spin_unlock(&mgr->lock);667707}668708669709static const struct ttm_resource_manager_func amdgpu_vram_mgr_func = {···674732{675733 struct amdgpu_vram_mgr *mgr = &adev->mman.vram_mgr;676734 struct ttm_resource_manager *man = &mgr->manager;677677- int err;678735679736 ttm_resource_manager_init(man, &adev->mman.bdev,680737 adev->gmc.real_vram_size);681738682739 man->func = &amdgpu_vram_mgr_func;683740684684- err = drm_buddy_init(&mgr->mm, man->size, PAGE_SIZE);685685- if (err)686686- return err;687687-688688- mutex_init(&mgr->lock);741741+ drm_mm_init(&mgr->mm, 0, man->size >> PAGE_SHIFT);742742+ spin_lock_init(&mgr->lock);689743 INIT_LIST_HEAD(&mgr->reservations_pending);690744 INIT_LIST_HEAD(&mgr->reserved_pages);691691- mgr->default_page_size = PAGE_SIZE;692745693746 ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager);694747 ttm_resource_manager_set_used(man, true);···711774 if (ret)712775 return;713776714714- mutex_lock(&mgr->lock);715715- list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, blocks)777777+ spin_lock(&mgr->lock);778778+ list_for_each_entry_safe(rsv, temp, &mgr->reservations_pending, node)716779 kfree(rsv);717780718718- list_for_each_entry_safe(rsv, temp, &mgr->reserved_pages, blocks) {719719- drm_buddy_free_list(&mgr->mm, &rsv->blocks);781781+ list_for_each_entry_safe(rsv, temp, &mgr->reserved_pages, node) {782782+ drm_mm_remove_node(&rsv->mm_node);720783 kfree(rsv);721784 }722722- drm_buddy_fini(&mgr->mm);723723- mutex_unlock(&mgr->lock);785785+ drm_mm_takedown(&mgr->mm);786786+ spin_unlock(&mgr->lock);724787725788 ttm_resource_manager_cleanup(man);726789 ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
-89
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h
···11-/* SPDX-License-Identifier: MIT22- * Copyright 2021 Advanced Micro Devices, Inc.33- *44- * Permission is hereby granted, free of charge, to any person obtaining a55- * copy of this software and associated documentation files (the "Software"),66- * to deal in the Software without restriction, including without limitation77- * the rights to use, copy, modify, merge, publish, distribute, sublicense,88- * and/or sell copies of the Software, and to permit persons to whom the99- * Software is furnished to do so, subject to the following conditions:1010- *1111- * The above copyright notice and this permission notice shall be included in1212- * all copies or substantial portions of the Software.1313- *1414- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1515- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1616- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL1717- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR1818- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,1919- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR2020- * OTHER DEALINGS IN THE SOFTWARE.2121- *2222- */2323-2424-#ifndef __AMDGPU_VRAM_MGR_H__2525-#define __AMDGPU_VRAM_MGR_H__2626-2727-#include <drm/drm_buddy.h>2828-2929-struct amdgpu_vram_mgr {3030- struct ttm_resource_manager manager;3131- struct drm_buddy mm;3232- /* protects access to buffer objects */3333- struct mutex lock;3434- struct list_head reservations_pending;3535- struct list_head reserved_pages;3636- atomic64_t vis_usage;3737- u64 default_page_size;3838-};3939-4040-struct amdgpu_vram_mgr_resource {4141- struct ttm_resource base;4242- struct list_head blocks;4343- unsigned long flags;4444-};4545-4646-static inline u64 amdgpu_vram_mgr_block_start(struct drm_buddy_block *block)4747-{4848- return drm_buddy_block_offset(block);4949-}5050-5151-static inline u64 amdgpu_vram_mgr_block_size(struct drm_buddy_block *block)5252-{5353- return PAGE_SIZE << drm_buddy_block_order(block);5454-}5555-5656-static inline struct drm_buddy_block *5757-amdgpu_vram_mgr_first_block(struct list_head *list)5858-{5959- return list_first_entry_or_null(list, struct drm_buddy_block, link);6060-}6161-6262-static inline bool amdgpu_is_vram_mgr_blocks_contiguous(struct list_head *head)6363-{6464- struct drm_buddy_block *block;6565- u64 start, size;6666-6767- block = amdgpu_vram_mgr_first_block(head);6868- if (!block)6969- return false;7070-7171- while (head != block->link.next) {7272- start = amdgpu_vram_mgr_block_start(block);7373- size = amdgpu_vram_mgr_block_size(block);7474-7575- block = list_entry(block->link.next, struct drm_buddy_block, link);7676- if (start + size != amdgpu_vram_mgr_block_start(block))7777- return false;7878- }7979-8080- return true;8181-}8282-8383-static inline struct amdgpu_vram_mgr_resource *8484-to_amdgpu_vram_mgr_resource(struct ttm_resource *res)8585-{8686- return container_of(res, struct amdgpu_vram_mgr_resource, base);8787-}8888-8989-#endif
···7272#include <linux/pci.h>7373#include <linux/firmware.h>7474#include <linux/component.h>7575+#include <linux/dmi.h>75767677#include <drm/display/drm_dp_mst_helper.h>7778#include <drm/display/drm_hdmi_helper.h>···463462 vrr_active, (int) !e);464463}465464465465+static void dm_crtc_handle_vblank(struct amdgpu_crtc *acrtc)466466+{467467+ struct drm_crtc *crtc = &acrtc->base;468468+ struct drm_device *dev = crtc->dev;469469+ unsigned long flags;470470+471471+ drm_crtc_handle_vblank(crtc);472472+473473+ spin_lock_irqsave(&dev->event_lock, flags);474474+475475+ /* Send completion event for cursor-only commits */476476+ if (acrtc->event && acrtc->pflip_status != AMDGPU_FLIP_SUBMITTED) {477477+ drm_crtc_send_vblank_event(crtc, acrtc->event);478478+ drm_crtc_vblank_put(crtc);479479+ acrtc->event = NULL;480480+ }481481+482482+ spin_unlock_irqrestore(&dev->event_lock, flags);483483+}484484+466485static void dm_vupdate_high_irq(void *interrupt_params)467486{468487 struct common_irq_params *irq_params = interrupt_params;···521500 * if a pageflip happened inside front-porch.522501 */523502 if (vrr_active) {524524- drm_crtc_handle_vblank(&acrtc->base);503503+ dm_crtc_handle_vblank(acrtc);525504526505 /* BTR processing for pre-DCE12 ASICs */527506 if (acrtc->dm_irq_params.stream &&···573552 * to dm_vupdate_high_irq after end of front-porch.574553 */575554 if (!vrr_active)576576- drm_crtc_handle_vblank(&acrtc->base);555555+ dm_crtc_handle_vblank(acrtc);577556578557 /**579558 * Following stuff must happen at start of vblank, for crc···14031382 return false;14041383}1405138413851385+static const struct dmi_system_id hpd_disconnect_quirk_table[] = {13861386+ {13871387+ .matches = {13881388+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),13891389+ DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3660"),13901390+ },13911391+ },13921392+ {13931393+ .matches = {13941394+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),13951395+ DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3260"),13961396+ },13971397+ },13981398+ {13991399+ .matches = {14001400+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),14011401+ DMI_MATCH(DMI_PRODUCT_NAME, "Precision 3460"),14021402+ },14031403+ },14041404+ {}14051405+};14061406+14071407+static void retrieve_dmi_info(struct amdgpu_display_manager *dm)14081408+{14091409+ const struct dmi_system_id *dmi_id;14101410+14111411+ dm->aux_hpd_discon_quirk = false;14121412+14131413+ dmi_id = dmi_first_match(hpd_disconnect_quirk_table);14141414+ if (dmi_id) {14151415+ dm->aux_hpd_discon_quirk = true;14161416+ DRM_INFO("aux_hpd_discon_quirk attached\n");14171417+ }14181418+}14191419+14061420static int amdgpu_dm_init(struct amdgpu_device *adev)14071421{14081422 struct dc_init_data init_data;···15641508 }1565150915661510 INIT_LIST_HEAD(&adev->dm.da_list);15111511+15121512+ retrieve_dmi_info(&adev->dm);15131513+15671514 /* Display Core create. */15681515 adev->dm.dc = dc_create(&init_data);15691516···54665407 }54675408 }5468540954695469- if (per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE)54105410+ if (*per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE)54705411 *pre_multiplied_alpha = false;54715412 }54725413···91949135 struct amdgpu_bo *abo;91959136 uint32_t target_vblank, last_flip_vblank;91969137 bool vrr_active = amdgpu_dm_vrr_active(acrtc_state);91389138+ bool cursor_update = false;91979139 bool pflip_present = false;91989140 struct {91999141 struct dc_surface_update surface_updates[MAX_SURFACES];···92309170 struct dm_plane_state *dm_new_plane_state = to_dm_plane_state(new_plane_state);9231917192329172 /* Cursor plane is handled after stream updates */92339233- if (plane->type == DRM_PLANE_TYPE_CURSOR)91739173+ if (plane->type == DRM_PLANE_TYPE_CURSOR) {91749174+ if ((fb && crtc == pcrtc) ||91759175+ (old_plane_state->fb && old_plane_state->crtc == pcrtc))91769176+ cursor_update = true;91779177+92349178 continue;91799179+ }9235918092369181 if (!fb || !crtc || pcrtc != crtc)92379182 continue;···93999334 bundle->stream_update.vrr_infopacket =94009335 &acrtc_state->stream->vrr_infopacket;94019336 }93379337+ } else if (cursor_update && acrtc_state->active_planes > 0 &&93389338+ !acrtc_state->force_dpms_off &&93399339+ acrtc_attach->base.state->event) {93409340+ drm_crtc_vblank_get(pcrtc);93419341+93429342+ spin_lock_irqsave(&pcrtc->dev->event_lock, flags);93439343+93449344+ acrtc_attach->event = acrtc_attach->base.state->event;93459345+ acrtc_attach->base.state->event = NULL;93469346+93479347+ spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags);94029348 }9403934994049350 /* Update the planes if changed or disable if we don't have any. */
+8
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
···540540 * last successfully applied backlight values.541541 */542542 u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP];543543+544544+ /**545545+ * @aux_hpd_discon_quirk:546546+ *547547+ * quirk for hpd discon while aux is on-going.548548+ * occurred on certain intel platform549549+ */550550+ bool aux_hpd_discon_quirk;543551};544552545553enum dsc_clock_force_state {
···5656 ssize_t result = 0;5757 struct aux_payload payload;5858 enum aux_return_code_type operation_result;5959+ struct amdgpu_device *adev;6060+ struct ddc_service *ddc;59616062 if (WARN_ON(msg->size > 16))6163 return -E2BIG;···75737674 result = dc_link_aux_transfer_raw(TO_DM_AUX(aux)->ddc_service, &payload,7775 &operation_result);7676+7777+ /*7878+ * w/a on certain intel platform where hpd is unexpected to pull low during7979+ * 1st sideband message transaction by return AUX_RET_ERROR_HPD_DISCON8080+ * aux transaction is succuess in such case, therefore bypass the error8181+ */8282+ ddc = TO_DM_AUX(aux)->ddc_service;8383+ adev = ddc->ctx->driver_context;8484+ if (adev->dm.aux_hpd_discon_quirk) {8585+ if (msg->address == DP_SIDEBAND_MSG_DOWN_REQ_BASE &&8686+ operation_result == AUX_RET_ERROR_HPD_DISCON) {8787+ result = 0;8888+ operation_result = AUX_RET_SUCCESS;8989+ }9090+ }78917992 if (payload.write && result >= 0)8093 result = msg->size;
+6-5
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
···11171117 * on certain displays, such as the Sharp 4k. 36bpp is needed11181118 * to support SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 and11191119 * SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 with actual > 10 bpc11201120- * precision on at least DCN display engines. However, at least11211121- * Carrizo with DCE_VERSION_11_0 does not like 36 bpp lb depth,11221122- * so use only 30 bpp on DCE_VERSION_11_0. Testing with DCE 11.2 and 8.311231123- * did not show such problems, so this seems to be the exception.11201120+ * precision on DCN display engines, but apparently not for DCE, as11211121+ * far as testing on DCE-11.2 and DCE-8 showed. Various DCE parts have11221122+ * problems: Carrizo with DCE_VERSION_11_0 does not like 36 bpp lb depth,11231123+ * neither do DCE-8 at 4k resolution, or DCE-11.2 (broken identify pixel11241124+ * passthrough). Therefore only use 36 bpp on DCN where it is actually needed.11241125 */11251125- if (plane_state->ctx->dce_version > DCE_VERSION_11_0)11261126+ if (plane_state->ctx->dce_version > DCE_VERSION_MAX)11261127 pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_36BPP;11271128 else11281129 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
···12281228 uint32_t crystal_clock_freq = 2500;12291229 uint32_t tach_period;1230123012311231+ if (speed == 0)12321232+ return -EINVAL;12311233 /*12321234 * To prevent from possible overheat, some ASICs may have requirement12331235 * for minimum fan speed:
+2
drivers/gpu/drm/i915/gem/i915_gem_region.c
···6060 if (page_size)6161 default_page_size = page_size;62626363+ /* We should be able to fit a page within an sg entry */6464+ GEM_BUG_ON(overflows_type(default_page_size, u32));6365 GEM_BUG_ON(!is_power_of_2_u64(default_page_size));6466 GEM_BUG_ON(default_page_size < PAGE_SIZE);6567
+9-2
drivers/gpu/drm/i915/gem/i915_gem_ttm.c
···620620 struct ttm_resource *res)621621{622622 struct ttm_buffer_object *bo = i915_gem_to_ttm(obj);623623+ u32 page_alignment;623624624625 if (!i915_ttm_gtt_binds_lmem(res))625626 return i915_ttm_tt_get_st(bo->ttm);627627+628628+ page_alignment = bo->page_alignment << PAGE_SHIFT;629629+ if (!page_alignment)630630+ page_alignment = obj->mm.region->min_page_size;626631627632 /*628633 * If CPU mapping differs, we need to add the ttm_tt pages to···639634 struct i915_refct_sgt *rsgt;640635641636 rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region,642642- res);637637+ res,638638+ page_alignment);643639 if (IS_ERR(rsgt))644640 return rsgt;645641···649643 return i915_refct_sgt_get(obj->ttm.cached_io_rsgt);650644 }651645652652- return intel_region_ttm_resource_to_rsgt(obj->mm.region, res);646646+ return intel_region_ttm_resource_to_rsgt(obj->mm.region, res,647647+ page_alignment);653648}654649655650static int i915_ttm_truncate(struct drm_i915_gem_object *obj)
+34
drivers/gpu/drm/i915/gem/i915_gem_wait.c
···99#include <linux/jiffies.h>10101111#include "gt/intel_engine.h"1212+#include "gt/intel_rps.h"12131314#include "i915_gem_ioctls.h"1415#include "i915_gem_object.h"···3231 timeout);3332}34333434+static void3535+i915_gem_object_boost(struct dma_resv *resv, unsigned int flags)3636+{3737+ struct dma_resv_iter cursor;3838+ struct dma_fence *fence;3939+4040+ /*4141+ * Prescan all fences for potential boosting before we begin waiting.4242+ *4343+ * When we wait, we wait on outstanding fences serially. If the4444+ * dma-resv contains a sequence such as 1:1, 1:2 instead of a reduced4545+ * form 1:2, then as we look at each wait in turn we see that each4646+ * request is currently executing and not worthy of boosting. But if4747+ * we only happen to look at the final fence in the sequence (because4848+ * of request coalescing or splitting between read/write arrays by4949+ * the iterator), then we would boost. As such our decision to boost5050+ * or not is delicately balanced on the order we wait on fences.5151+ *5252+ * So instead of looking for boosts sequentially, look for all boosts5353+ * upfront and then wait on the outstanding fences.5454+ */5555+5656+ dma_resv_iter_begin(&cursor, resv,5757+ dma_resv_usage_rw(flags & I915_WAIT_ALL));5858+ dma_resv_for_each_fence_unlocked(&cursor, fence)5959+ if (dma_fence_is_i915(fence) &&6060+ !i915_request_started(to_request(fence)))6161+ intel_rps_boost(to_request(fence));6262+ dma_resv_iter_end(&cursor);6363+}6464+3565static long3666i915_gem_object_wait_reservation(struct dma_resv *resv,3767 unsigned int flags,···7139 struct dma_resv_iter cursor;7240 struct dma_fence *fence;7341 long ret = timeout ?: 1;4242+4343+ i915_gem_object_boost(resv, flags);74447545 dma_resv_iter_begin(&cursor, resv,7646 dma_resv_usage_rw(flags & I915_WAIT_ALL));
···152152 * Convert an opaque TTM resource manager resource to a refcounted sg_table.153153 * @mem: The memory region.154154 * @res: The resource manager resource obtained from the TTM resource manager.155155+ * @page_alignment: Required page alignment for each sg entry. Power of two.155156 *156157 * The gem backends typically use sg-tables for operations on the underlying157158 * io_memory. So provide a way for the backends to translate the···162161 */163162struct i915_refct_sgt *164163intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,165165- struct ttm_resource *res)164164+ struct ttm_resource *res,165165+ u32 page_alignment)166166{167167 if (mem->is_range_manager) {168168 struct ttm_range_mgr_node *range_node =169169 to_ttm_range_mgr_node(res);170170171171 return i915_rsgt_from_mm_node(&range_node->mm_nodes[0],172172- mem->region.start);172172+ mem->region.start,173173+ page_alignment);173174 } else {174174- return i915_rsgt_from_buddy_resource(res, mem->region.start);175175+ return i915_rsgt_from_buddy_resource(res, mem->region.start,176176+ page_alignment);175177 }176178}177179
···900900 } else {901901 dev_warn(dev, "Unexpected ACPI resources: gpio_count %d, gpio_int_idx %d\n",902902 ts->gpio_count, ts->gpio_int_idx);903903+ /*904904+ * On some devices _PS0 does a reset for us and905905+ * sometimes this is necessary for things to work.906906+ */907907+ acpi_device_fix_up_power(ACPI_COMPANION(dev));903908 return -EINVAL;904909 }905910
+3
drivers/input/touchscreen/usbtouchscreen.c
···16541654 if (id->driver_info == DEVTYPE_IGNORE)16551655 return -ENODEV;1656165616571657+ if (id->driver_info >= ARRAY_SIZE(usbtouch_dev_info))16581658+ return -ENODEV;16591659+16571660 endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting);16581661 if (!endpoint)16591662 return -ENXIO;
+3-1
drivers/input/touchscreen/wm97xx-core.c
···758758759759static int wm97xx_mfd_remove(struct platform_device *pdev)760760{761761- return wm97xx_remove(&pdev->dev);761761+ wm97xx_remove(&pdev->dev);762762+763763+ return 0;762764}763765764766static int __maybe_unused wm97xx_suspend(struct device *dev)
···18431843 of_child = of_get_child_by_name(pdev->dev.of_node, name);18441844 if (of_child && of_device_is_available(of_child))18451845 channels_mask |= BIT(i);18461846+ of_node_put(of_child);18461847 }1847184818481849 if (chip_id != RENESAS_RZG2L) {
+13-5
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
···16911691 u32 osc;16921692 int err;1693169316941694- /* The OSC_LPMEN is only supported on MCP2518FD, so use it to16951695- * autodetect the model.16941694+ /* The OSC_LPMEN is only supported on MCP2518FD and MCP251863,16951695+ * so use it to autodetect the model.16961696 */16971697 err = regmap_update_bits(priv->map_reg, MCP251XFD_REG_OSC,16981698 MCP251XFD_REG_OSC_LPMEN,···17041704 if (err)17051705 return err;1706170617071707- if (osc & MCP251XFD_REG_OSC_LPMEN)17081708- devtype_data = &mcp251xfd_devtype_data_mcp2518fd;17091709- else17071707+ if (osc & MCP251XFD_REG_OSC_LPMEN) {17081708+ /* We cannot distinguish between MCP2518FD and17091709+ * MCP251863. If firmware specifies MCP251863, keep17101710+ * it, otherwise set to MCP2518FD.17111711+ */17121712+ if (mcp251xfd_is_251863(priv))17131713+ devtype_data = &mcp251xfd_devtype_data_mcp251863;17141714+ else17151715+ devtype_data = &mcp251xfd_devtype_data_mcp2518fd;17161716+ } else {17101717 devtype_data = &mcp251xfd_devtype_data_mcp2517fd;17181718+ }1711171917121720 if (!mcp251xfd_is_251XFD(priv) &&17131721 priv->devtype_data.model != devtype_data->model) {
+4-1
drivers/net/dsa/microchip/ksz_common.c
···15791579 ports = of_get_child_by_name(dev->dev->of_node, "ethernet-ports");15801580 if (!ports)15811581 ports = of_get_child_by_name(dev->dev->of_node, "ports");15821582- if (ports)15821582+ if (ports) {15831583 for_each_available_child_of_node(ports, port) {15841584 if (of_property_read_u32(port, "reg",15851585 &port_num))15861586 continue;15871587 if (!(dev->port_mask & BIT(port_num))) {15881588 of_node_put(port);15891589+ of_node_put(ports);15891590 return -EINVAL;15901591 }15911592 of_get_phy_mode(port,15921593 &dev->ports[port_num].interface);15931594 }15951595+ of_node_put(ports);15961596+ }15941597 dev->synclko_125 = of_property_read_bool(dev->dev->of_node,15951598 "microchip,synclko-125");15961599 dev->synclko_disable = of_property_read_bool(dev->dev->of_node,
···194194 struct iavf_tx_buffer *tx_buf;195195 struct iavf_tx_desc *tx_desc;196196 unsigned int total_bytes = 0, total_packets = 0;197197- unsigned int budget = vsi->work_limit;197197+ unsigned int budget = IAVF_DEFAULT_IRQ_WORK;198198199199 tx_buf = &tx_ring->tx_bi[i];200200 tx_desc = IAVF_TX_DESC(tx_ring, i);···12851285{12861286 struct iavf_rx_buffer *rx_buffer;1287128712881288- if (!size)12891289- return NULL;12901290-12911288 rx_buffer = &rx_ring->rx_bi[rx_ring->next_to_clean];12921289 prefetchw(rx_buffer->page);12901290+ if (!size)12911291+ return rx_buffer;1293129212941293 /* we are reusing so sync this buffer for CPU use */12951294 dma_sync_single_range_for_cpu(rx_ring->dev,
+63-2
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
···628628}629629630630/**631631+ * iavf_vlan_add_reject632632+ * @adapter: adapter structure633633+ *634634+ * Remove VLAN filters from list based on PF response.635635+ **/636636+static void iavf_vlan_add_reject(struct iavf_adapter *adapter)637637+{638638+ struct iavf_vlan_filter *f, *ftmp;639639+640640+ spin_lock_bh(&adapter->mac_vlan_list_lock);641641+ list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {642642+ if (f->is_new_vlan) {643643+ if (f->vlan.tpid == ETH_P_8021Q)644644+ clear_bit(f->vlan.vid,645645+ adapter->vsi.active_cvlans);646646+ else647647+ clear_bit(f->vlan.vid,648648+ adapter->vsi.active_svlans);649649+650650+ list_del(&f->list);651651+ kfree(f);652652+ }653653+ }654654+ spin_unlock_bh(&adapter->mac_vlan_list_lock);655655+}656656+657657+/**631658 * iavf_add_vlans632659 * @adapter: adapter structure633660 *···711684 vvfl->vlan_id[i] = f->vlan.vid;712685 i++;713686 f->add = false;687687+ f->is_new_vlan = true;714688 if (i == count)715689 break;716690 }···724696 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);725697 kfree(vvfl);726698 } else {699699+ u16 max_vlans = adapter->vlan_v2_caps.filtering.max_filters;700700+ u16 current_vlans = iavf_get_num_vlans_added(adapter);727701 struct virtchnl_vlan_filter_list_v2 *vvfl_v2;728702729703 adapter->current_op = VIRTCHNL_OP_ADD_VLAN_V2;704704+705705+ if ((count + current_vlans) > max_vlans &&706706+ current_vlans < max_vlans) {707707+ count = max_vlans - iavf_get_num_vlans_added(adapter);708708+ more = true;709709+ }730710731711 len = sizeof(*vvfl_v2) + ((count - 1) *732712 sizeof(struct virtchnl_vlan_filter));···762726 &adapter->vlan_v2_caps.filtering.filtering_support;763727 struct virtchnl_vlan *vlan;764728729729+ if (i == count)730730+ break;731731+765732 /* give priority over outer if it's enabled */766733 if (filtering_support->outer)767734 vlan = &vvfl_v2->filters[i].outer;···776737777738 i++;778739 f->add = false;779779- if (i == count)780780- break;740740+ f->is_new_vlan = true;781741 }782742 }783743···21202082 */21212083 iavf_netdev_features_vlan_strip_set(netdev, true);21222084 break;20852085+ case VIRTCHNL_OP_ADD_VLAN_V2:20862086+ iavf_vlan_add_reject(adapter);20872087+ dev_warn(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n",20882088+ iavf_stat_str(&adapter->hw, v_retval));20892089+ break;21232090 default:21242091 dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",21252092 v_retval, iavf_stat_str(&adapter->hw, v_retval),···24262383 }24272384 }24282385 spin_unlock_bh(&adapter->adv_rss_lock);23862386+ }23872387+ break;23882388+ case VIRTCHNL_OP_ADD_VLAN_V2: {23892389+ struct iavf_vlan_filter *f;23902390+23912391+ spin_lock_bh(&adapter->mac_vlan_list_lock);23922392+ list_for_each_entry(f, &adapter->vlan_filter_list, list) {23932393+ if (f->is_new_vlan) {23942394+ f->is_new_vlan = false;23952395+ if (f->vlan.tpid == ETH_P_8021Q)23962396+ set_bit(f->vlan.vid,23972397+ adapter->vsi.active_cvlans);23982398+ else23992399+ set_bit(f->vlan.vid,24002400+ adapter->vsi.active_svlans);24012401+ }24022402+ }24032403+ spin_unlock_bh(&adapter->mac_vlan_list_lock);24292404 }24302405 break;24312406 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
+3
drivers/net/ethernet/intel/igc/igc_main.c
···61826182 u8 __iomem *hw_addr = READ_ONCE(hw->hw_addr);61836183 u32 value = 0;6184618461856185+ if (IGC_REMOVED(hw_addr))61866186+ return ~value;61876187+61856188 value = readl(&hw_addr[reg]);6186618961876190 /* reads should not return all F's */
···64456445 /* n-tuple support exists, always init our spinlock */64466446 spin_lock_init(&adapter->fdir_perfect_lock);6447644764486448+ /* init spinlock to avoid concurrency of VF resources */64496449+ spin_lock_init(&adapter->vfs_lock);64506450+64486451#ifdef CONFIG_IXGBE_DCB64496452 ixgbe_init_dcb(adapter);64506453#endif
+6
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
···205205int ixgbe_disable_sriov(struct ixgbe_adapter *adapter)206206{207207 unsigned int num_vfs = adapter->num_vfs, vf;208208+ unsigned long flags;208209 int rss;209210211211+ spin_lock_irqsave(&adapter->vfs_lock, flags);210212 /* set num VFs to 0 to prevent access to vfinfo */211213 adapter->num_vfs = 0;214214+ spin_unlock_irqrestore(&adapter->vfs_lock, flags);212215213216 /* put the reference to all of the vf devices */214217 for (vf = 0; vf < num_vfs; ++vf) {···13581355void ixgbe_msg_task(struct ixgbe_adapter *adapter)13591356{13601357 struct ixgbe_hw *hw = &adapter->hw;13581358+ unsigned long flags;13611359 u32 vf;1362136013611361+ spin_lock_irqsave(&adapter->vfs_lock, flags);13631362 for (vf = 0; vf < adapter->num_vfs; vf++) {13641363 /* process any reset requests */13651364 if (!ixgbe_check_for_rst(hw, vf))···13751370 if (!ixgbe_check_for_ack(hw, vf))13761371 ixgbe_rcv_ack_from_vf(adapter, vf);13771372 }13731373+ spin_unlock_irqrestore(&adapter->vfs_lock, flags);13781374}1379137513801376static inline void ixgbe_ping_vf(struct ixgbe_adapter *adapter, int vf)
···7575 unsigned int vid,7676 enum macaccess_entry_type type)7777{7878+ int ret;7979+8080+ spin_lock(&lan966x->mac_lock);7881 lan966x_mac_select(lan966x, mac, vid);79828083 /* Issue a write command */···8986 ANA_MACACCESS_MAC_TABLE_CMD_SET(MACACCESS_CMD_LEARN),9087 lan966x, ANA_MACACCESS);91889292- return lan966x_mac_wait_for_completion(lan966x);8989+ ret = lan966x_mac_wait_for_completion(lan966x);9090+ spin_unlock(&lan966x->mac_lock);9191+9292+ return ret;9393}94949595/* The mask of the front ports is encoded inside the mac parameter via a call···119113 return __lan966x_mac_learn(lan966x, port, false, mac, vid, type);120114}121115122122-int lan966x_mac_forget(struct lan966x *lan966x,123123- const unsigned char mac[ETH_ALEN],124124- unsigned int vid,125125- enum macaccess_entry_type type)116116+static int lan966x_mac_forget_locked(struct lan966x *lan966x,117117+ const unsigned char mac[ETH_ALEN],118118+ unsigned int vid,119119+ enum macaccess_entry_type type)126120{121121+ lockdep_assert_held(&lan966x->mac_lock);122122+127123 lan966x_mac_select(lan966x, mac, vid);128124129125 /* Issue a forget command */···134126 lan966x, ANA_MACACCESS);135127136128 return lan966x_mac_wait_for_completion(lan966x);129129+}130130+131131+int lan966x_mac_forget(struct lan966x *lan966x,132132+ const unsigned char mac[ETH_ALEN],133133+ unsigned int vid,134134+ enum macaccess_entry_type type)135135+{136136+ int ret;137137+138138+ spin_lock(&lan966x->mac_lock);139139+ ret = lan966x_mac_forget_locked(lan966x, mac, vid, type);140140+ spin_unlock(&lan966x->mac_lock);141141+142142+ return ret;137143}138144139145int lan966x_mac_cpu_learn(struct lan966x *lan966x, const char *addr, u16 vid)···183161{184162 struct lan966x_mac_entry *mac_entry;185163186186- mac_entry = kzalloc(sizeof(*mac_entry), GFP_KERNEL);164164+ mac_entry = kzalloc(sizeof(*mac_entry), GFP_ATOMIC);187165 if (!mac_entry)188166 return NULL;189167···201179 struct lan966x_mac_entry *res = NULL;202180 struct lan966x_mac_entry *mac_entry;203181204204- spin_lock(&lan966x->mac_lock);205182 list_for_each_entry(mac_entry, &lan966x->mac_entries, list) {206183 if (mac_entry->vid == vid &&207184 ether_addr_equal(mac, mac_entry->mac) &&···209188 break;210189 }211190 }212212- spin_unlock(&lan966x->mac_lock);213191214192 return res;215193}···251231{252232 struct lan966x_mac_entry *mac_entry;253233254254- if (lan966x_mac_lookup(lan966x, addr, vid, ENTRYTYPE_NORMAL))234234+ spin_lock(&lan966x->mac_lock);235235+ if (lan966x_mac_lookup(lan966x, addr, vid, ENTRYTYPE_NORMAL)) {236236+ spin_unlock(&lan966x->mac_lock);255237 return 0;238238+ }256239257240 /* In case the entry already exists, don't add it again to SW,258241 * just update HW, but we need to look in the actual HW because···264241 * add the entry but without the extern_learn flag.265242 */266243 mac_entry = lan966x_mac_find_entry(lan966x, addr, vid, port->chip_port);267267- if (mac_entry)268268- return lan966x_mac_learn(lan966x, port->chip_port,269269- addr, vid, ENTRYTYPE_LOCKED);244244+ if (mac_entry) {245245+ spin_unlock(&lan966x->mac_lock);246246+ goto mac_learn;247247+ }270248271249 mac_entry = lan966x_mac_alloc_entry(addr, vid, port->chip_port);272272- if (!mac_entry)250250+ if (!mac_entry) {251251+ spin_unlock(&lan966x->mac_lock);273252 return -ENOMEM;253253+ }274254275275- spin_lock(&lan966x->mac_lock);276255 list_add_tail(&mac_entry->list, &lan966x->mac_entries);277256 spin_unlock(&lan966x->mac_lock);278257279279- lan966x_mac_learn(lan966x, port->chip_port, addr, vid, ENTRYTYPE_LOCKED);280258 lan966x_fdb_call_notifiers(SWITCHDEV_FDB_OFFLOADED, addr, vid, port->dev);259259+260260+mac_learn:261261+ lan966x_mac_learn(lan966x, port->chip_port, addr, vid, ENTRYTYPE_LOCKED);281262282263 return 0;283264}···296269 list) {297270 if (mac_entry->vid == vid &&298271 ether_addr_equal(addr, mac_entry->mac)) {299299- lan966x_mac_forget(lan966x, mac_entry->mac, mac_entry->vid,300300- ENTRYTYPE_LOCKED);272272+ lan966x_mac_forget_locked(lan966x, mac_entry->mac,273273+ mac_entry->vid,274274+ ENTRYTYPE_LOCKED);301275302276 list_del(&mac_entry->list);303277 kfree(mac_entry);···316288 spin_lock(&lan966x->mac_lock);317289 list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries,318290 list) {319319- lan966x_mac_forget(lan966x, mac_entry->mac, mac_entry->vid,320320- ENTRYTYPE_LOCKED);291291+ lan966x_mac_forget_locked(lan966x, mac_entry->mac,292292+ mac_entry->vid, ENTRYTYPE_LOCKED);321293322294 list_del(&mac_entry->list);323295 kfree(mac_entry);···353325{354326 struct lan966x_mac_entry *mac_entry, *tmp;355327 unsigned char mac[ETH_ALEN] __aligned(2);328328+ struct list_head mac_deleted_entries;356329 u32 dest_idx;357330 u32 column;358331 u16 vid;332332+333333+ INIT_LIST_HEAD(&mac_deleted_entries);359334360335 spin_lock(&lan966x->mac_lock);361336 list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, list) {···393362 }394363395364 if (!found) {396396- /* Notify the bridge that the entry doesn't exist397397- * anymore in the HW and remove the entry from the SW398398- * list399399- */400400- lan966x_mac_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE,401401- mac_entry->mac, mac_entry->vid,402402- lan966x->ports[mac_entry->port_index]->dev);403403-404365 list_del(&mac_entry->list);405405- kfree(mac_entry);366366+ /* Move the entry from SW list to a tmp list such that367367+ * it would be deleted later368368+ */369369+ list_add_tail(&mac_entry->list, &mac_deleted_entries);406370 }407371 }408372 spin_unlock(&lan966x->mac_lock);373373+374374+ list_for_each_entry_safe(mac_entry, tmp, &mac_deleted_entries, list) {375375+ /* Notify the bridge that the entry doesn't exist376376+ * anymore in the HW377377+ */378378+ lan966x_mac_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE,379379+ mac_entry->mac, mac_entry->vid,380380+ lan966x->ports[mac_entry->port_index]->dev);381381+ list_del(&mac_entry->list);382382+ kfree(mac_entry);383383+ }409384410385 /* Now go to the list of columns and see if any entry was not in the SW411386 * list, then that means that the entry is new so it needs to notify the···433396 if (WARN_ON(dest_idx >= lan966x->num_phys_ports))434397 continue;435398399399+ spin_lock(&lan966x->mac_lock);400400+ mac_entry = lan966x_mac_find_entry(lan966x, mac, vid, dest_idx);401401+ if (mac_entry) {402402+ spin_unlock(&lan966x->mac_lock);403403+ continue;404404+ }405405+436406 mac_entry = lan966x_mac_alloc_entry(mac, vid, dest_idx);437437- if (!mac_entry)407407+ if (!mac_entry) {408408+ spin_unlock(&lan966x->mac_lock);438409 return;410410+ }439411440412 mac_entry->row = row;441441-442442- spin_lock(&lan966x->mac_lock);443413 list_add_tail(&mac_entry->list, &lan966x->mac_entries);444414 spin_unlock(&lan966x->mac_lock);445415···468424 lan966x, ANA_MACTINDX);469425470426 while (1) {427427+ spin_lock(&lan966x->mac_lock);471428 lan_rmw(ANA_MACACCESS_MAC_TABLE_CMD_SET(MACACCESS_CMD_SYNC_GET_NEXT),472429 ANA_MACACCESS_MAC_TABLE_CMD,473430 lan966x, ANA_MACACCESS);···492447 stop = false;493448494449 if (column == LAN966X_MAC_COLUMNS - 1 &&495495- index == 0 && stop)450450+ index == 0 && stop) {451451+ spin_unlock(&lan966x->mac_lock);496452 break;453453+ }497454498455 entry[column].mach = lan_rd(lan966x, ANA_MACHDATA);499456 entry[column].macl = lan_rd(lan966x, ANA_MACLDATA);500457 entry[column].maca = lan_rd(lan966x, ANA_MACACCESS);458458+ spin_unlock(&lan966x->mac_lock);501459502460 /* Once all the columns are read process them */503461 if (column == LAN966X_MAC_COLUMNS - 1) {
···803803 netdev_warn(priv->dev,804804 "Setting EEE tx-lpi is not supported\n");805805806806- if (priv->hw->xpcs) {807807- ret = xpcs_config_eee(priv->hw->xpcs,808808- priv->plat->mult_fact_100ns,809809- edata->eee_enabled);810810- if (ret)811811- return ret;812812- }813813-814806 if (!edata->eee_enabled)815807 stmmac_disable_eee_mode(priv);816808
···150150 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M AORUS PRO-P"),151151 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M DS3H"),152152 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B660 GAMING X DDR4"),153153+ DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B660I AORUS PRO DDR4"),153154 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("Z390 I AORUS PRO WIFI-CF"),154155 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("Z490 AORUS ELITE AC"),155156 DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 AORUS ELITE"),
+2-1
drivers/platform/x86/intel/atomisp2/led.c
···5050 {5151 .matches = {5252 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),5353- DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"),5353+ /* Non exact match to also match T100TAF */5454+ DMI_MATCH(DMI_PRODUCT_NAME, "T100TA"),5455 },5556 .driver_data = &asus_t100ta_lookup,5657 },
+3
drivers/platform/x86/intel/ifs/Kconfig
···11config INTEL_IFS22 tristate "Intel In Field Scan"33 depends on X86 && CPU_SUP_INTEL && 64BIT && SMP44+ # Discussion on the list has shown that the sysfs API needs a bit55+ # more work, mark this as broken for now66+ depends on BROKEN47 select INTEL_IFS_DEVICE58 help69 Enable support for the In Field Scan capability in select
+13-4
drivers/platform/x86/x86-android-tablets.c
···2727#include <linux/pinctrl/machine.h>2828#include <linux/platform_data/lp855x.h>2929#include <linux/platform_device.h>3030-#include <linux/pm.h>3130#include <linux/power/bq24190_charger.h>3131+#include <linux/reboot.h>3232#include <linux/rmi.h>3333#include <linux/serdev.h>3434#include <linux/spi/spi.h>···889889 "INT33FC:02", "pmu_clk2_grp", "pmu_clk");890890891891static struct pinctrl *lenovo_yoga_tab2_830_1050_codec_pinctrl;892892+static struct sys_off_handler *lenovo_yoga_tab2_830_1050_sys_off_handler;892893893894static int __init lenovo_yoga_tab2_830_1050_init_codec(void)894895{···934933 * followed by a normal 3 second press to recover. Avoid this by doing an EFI935934 * poweroff instead.936935 */937937-static void lenovo_yoga_tab2_830_1050_power_off(void)936936+static int lenovo_yoga_tab2_830_1050_power_off(struct sys_off_data *data)938937{939938 efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);939939+940940+ return NOTIFY_DONE;940941}941942942943static int __init lenovo_yoga_tab2_830_1050_init(void)···953950 if (ret)954951 return ret;955952956956- pm_power_off = lenovo_yoga_tab2_830_1050_power_off;953953+ /* SYS_OFF_PRIO_FIRMWARE + 1 so that it runs before acpi_power_off */954954+ lenovo_yoga_tab2_830_1050_sys_off_handler =955955+ register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_FIRMWARE + 1,956956+ lenovo_yoga_tab2_830_1050_power_off, NULL);957957+ if (IS_ERR(lenovo_yoga_tab2_830_1050_sys_off_handler))958958+ return PTR_ERR(lenovo_yoga_tab2_830_1050_sys_off_handler);959959+957960 return 0;958961}959962960963static void lenovo_yoga_tab2_830_1050_exit(void)961964{962962- pm_power_off = NULL; /* Just turn poweroff into halt on module unload */965965+ unregister_sys_off_handler(lenovo_yoga_tab2_830_1050_sys_off_handler);963966964967 if (lenovo_yoga_tab2_830_1050_codec_pinctrl) {965968 pinctrl_put(lenovo_yoga_tab2_830_1050_codec_pinctrl);
···31483148 ret = ab8500_fg_init_hw_registers(di);31493149 if (ret) {31503150 dev_err(dev, "failed to initialize registers\n");31513151+ destroy_workqueue(di->fg_wq);31513152 return ret;31523153 }31533154···31603159 di->fg_psy = devm_power_supply_register(dev, &ab8500_fg_desc, &psy_cfg);31613160 if (IS_ERR(di->fg_psy)) {31623161 dev_err(dev, "failed to register FG psy\n");31623162+ destroy_workqueue(di->fg_wq);31633163 return PTR_ERR(di->fg_psy);31643164 }31653165···31763174 /* Register primary interrupt handlers */31773175 for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq); i++) {31783176 irq = platform_get_irq_byname(pdev, ab8500_fg_irq[i].name);31793179- if (irq < 0)31773177+ if (irq < 0) {31783178+ destroy_workqueue(di->fg_wq);31803179 return irq;31803180+ }3181318131823182 ret = devm_request_threaded_irq(dev, irq, NULL,31833183 ab8500_fg_irq[i].isr,···31893185 if (ret != 0) {31903186 dev_err(dev, "failed to request %s IRQ %d: %d\n",31913187 ab8500_fg_irq[i].name, irq, ret);31883188+ destroy_workqueue(di->fg_wq);31923189 return ret;31933190 }31943191 dev_dbg(dev, "Requested %s IRQ %d: %d\n",···32053200 ret = ab8500_fg_sysfs_init(di);32063201 if (ret) {32073202 dev_err(dev, "failed to create sysfs entry\n");32033203+ destroy_workqueue(di->fg_wq);32083204 return ret;32093205 }32103206···32133207 if (ret) {32143208 dev_err(dev, "failed to create FG psy\n");32153209 ab8500_fg_sysfs_exit(di);32103210+ destroy_workqueue(di->fg_wq);32163211 return ret;32173212 }32183213
+12-12
drivers/power/supply/power_supply_core.c
···846846{847847 int i, high, low;848848849849- /* Break loop at table_len - 1 because that is the highest index */850850- for (i = 0; i < table_len - 1; i++)849849+ for (i = 0; i < table_len; i++)851850 if (temp > table[i].temp)852851 break;853852854853 /* The library function will deal with high == low */855855- if ((i == 0) || (i == (table_len - 1)))856856- high = i;854854+ if (i == 0)855855+ high = low = i;856856+ else if (i == table_len)857857+ high = low = i - 1;857858 else858858- high = i - 1;859859- low = i;859859+ high = (low = i) - 1;860860861861 return fixp_linear_interpolate(table[low].temp,862862 table[low].resistance,···958958{959959 int i, high, low;960960961961- /* Break loop at table_len - 1 because that is the highest index */962962- for (i = 0; i < table_len - 1; i++)961961+ for (i = 0; i < table_len; i++)963962 if (ocv > table[i].ocv)964963 break;965964966965 /* The library function will deal with high == low */967967- if ((i == 0) || (i == (table_len - 1)))968968- high = i - 1;966966+ if (i == 0)967967+ high = low = i;968968+ else if (i == table_len)969969+ high = low = i - 1;969970 else970970- high = i; /* i.e. i == 0 */971971- low = i;971971+ high = (low = i) - 1;972972973973 return fixp_linear_interpolate(table[low].ocv,974974 table[low].capacity,
···494494 " backends not supported\n");495495 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;496496 }497497+498498+ if (!cmd->t_data_nents)499499+ return TCM_INVALID_CDB_FIELD;500500+497501 sg = &cmd->t_data_sg[0];498502499503 if (cmd->t_data_nents > 1 ||
+6
drivers/target/target_core_sbc.c
···312312 pr_warn("WRITE SAME with ANCHOR not supported\n");313313 return TCM_INVALID_CDB_FIELD;314314 }315315+316316+ if (flags & 0x01) {317317+ pr_warn("WRITE SAME with NDOB not supported\n");318318+ return TCM_INVALID_CDB_FIELD;319319+ }320320+315321 /*316322 * Special case for WRITE_SAME w/ UNMAP=1 that ends up getting317323 * translated into block discard requests within backend code.
+1-1
drivers/tee/optee/optee_smc.h
···189189 * Have config return register usage:190190 * a0 OPTEE_SMC_RETURN_OK191191 * a1 Physical address of start of SHM192192- * a2 Size of of SHM192192+ * a2 Size of SHM193193 * a3 Cache settings of memory, as defined by the194194 * OPTEE_SMC_SHM_* values above195195 * a4-7 Preserved
+2-2
drivers/tee/optee/smc_abi.c
···884884885885 rpc_arg_offs = OPTEE_MSG_GET_ARG_SIZE(arg->num_params);886886 rpc_arg = tee_shm_get_va(shm, offs + rpc_arg_offs);887887- if (IS_ERR(arg))888888- return PTR_ERR(arg);887887+ if (IS_ERR(rpc_arg))888888+ return PTR_ERR(rpc_arg);889889 }890890891891 if (rpc_arg && tee_shm_is_dynamic(shm)) {
+1-1
drivers/tee/tee_core.c
···10731073/**10741074 * tee_get_drvdata() - Return driver_data pointer10751075 * @teedev: Device containing the driver_data pointer10761076- * @returns the driver_data pointer supplied to tee_register().10761076+ * @returns the driver_data pointer supplied to tee_device_alloc().10771077 */10781078void *tee_get_drvdata(struct tee_device *teedev)10791079{
+2-12
drivers/tty/pty.c
···111111static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)112112{113113 struct tty_struct *to = tty->link;114114- unsigned long flags;115114116116- if (tty->flow.stopped)115115+ if (tty->flow.stopped || !c)117116 return 0;118117119119- if (c > 0) {120120- spin_lock_irqsave(&to->port->lock, flags);121121- /* Stuff the data into the input queue of the other end */122122- c = tty_insert_flip_string(to->port, buf, c);123123- spin_unlock_irqrestore(&to->port->lock, flags);124124- /* And shovel */125125- if (c)126126- tty_flip_buffer_push(to->port);127127- }128128- return c;118118+ return tty_insert_flip_string_and_push_buffer(to->port, buf, c);129119}130120131121/**
···19491949 if ((status & UART_LSR_THRE) && (up->ier & UART_IER_THRI)) {19501950 if (!up->dma || up->dma->tx_err)19511951 serial8250_tx_chars(up);19521952- else19521952+ else if (!up->dma->tx_running)19531953 __stop_tx(up);19541954 }19551955···29752975 case UPIO_MEM32BE:29762976 case UPIO_MEM16:29772977 case UPIO_MEM:29782978- if (!port->mapbase)29782978+ if (!port->mapbase) {29792979+ ret = -EINVAL;29792980 break;29812981+ }2980298229812983 if (!request_mem_region(port->mapbase, size, "serial")) {29822984 ret = -EBUSY;
···675675 rwlock_t global_root_lock;676676 struct rb_root global_root_tree;677677678678- /* The xarray that holds all the FS roots */679679- spinlock_t fs_roots_lock;680680- struct xarray fs_roots;678678+ spinlock_t fs_roots_radix_lock;679679+ struct radix_tree_root fs_roots_radix;681680682681 /* block group cache stuff */683682 rwlock_t block_group_cache_lock;···994995995996 struct btrfs_delayed_root *delayed_root;996997997997- /* Extent buffer xarray */998998+ /* Extent buffer radix tree */998999 spinlock_t buffer_lock;9991000 /* Entries are eb->start / sectorsize */10001000- struct xarray extent_buffers;10011001+ struct radix_tree_root buffer_radix;1001100210021003 /* next backup root to be overwritten */10031004 int backup_root_index;···11181119 */11191120 BTRFS_ROOT_SHAREABLE,11201121 BTRFS_ROOT_TRACK_DIRTY,11211121- /* The root is tracked in fs_info::fs_roots */11221122- BTRFS_ROOT_REGISTERED,11221122+ BTRFS_ROOT_IN_RADIX,11231123 BTRFS_ROOT_ORPHAN_ITEM_INSERTED,11241124 BTRFS_ROOT_DEFRAG_RUNNING,11251125 BTRFS_ROOT_FORCE_COW,···12221224 struct rb_root inode_tree;1223122512241226 /*12251225- * Xarray that keeps track of delayed nodes of every inode, protected12261226- * by inode_lock12271227+ * radix tree that keeps track of delayed nodes of every inode,12281228+ * protected by inode_lock12271229 */12281228- struct xarray delayed_nodes;12301230+ struct radix_tree_root delayed_nodes_tree;12291231 /*12301232 * right now this just gets used so that a root has its own devid12311233 * for stat. It may be used for more later
+45-39
fs/btrfs/delayed-inode.c
···7878 }79798080 spin_lock(&root->inode_lock);8181- node = xa_load(&root->delayed_nodes, ino);8181+ node = radix_tree_lookup(&root->delayed_nodes_tree, ino);82828383 if (node) {8484 if (btrfs_inode->delayed_node) {···90909191 /*9292 * It's possible that we're racing into the middle of removing9393- * this node from the xarray. In this case, the refcount9393+ * this node from the radix tree. In this case, the refcount9494 * was zero and it should never go back to one. Just return9595- * NULL like it was never in the xarray at all; our release9595+ * NULL like it was never in the radix at all; our release9696 * function is in the process of removing it.9797 *9898 * Some implementations of refcount_inc refuse to bump the···100100 * here, refcount_inc() may decide to just WARN_ONCE() instead101101 * of actually bumping the refcount.102102 *103103- * If this node is properly in the xarray, we want to bump the103103+ * If this node is properly in the radix, we want to bump the104104 * refcount twice, once for the inode and once for this get105105 * operation.106106 */···128128 u64 ino = btrfs_ino(btrfs_inode);129129 int ret;130130131131- do {132132- node = btrfs_get_delayed_node(btrfs_inode);133133- if (node)134134- return node;131131+again:132132+ node = btrfs_get_delayed_node(btrfs_inode);133133+ if (node)134134+ return node;135135136136- node = kmem_cache_zalloc(delayed_node_cache, GFP_NOFS);137137- if (!node)138138- return ERR_PTR(-ENOMEM);139139- btrfs_init_delayed_node(node, root, ino);136136+ node = kmem_cache_zalloc(delayed_node_cache, GFP_NOFS);137137+ if (!node)138138+ return ERR_PTR(-ENOMEM);139139+ btrfs_init_delayed_node(node, root, ino);140140141141- /* Cached in the inode and can be accessed */142142- refcount_set(&node->refs, 2);141141+ /* cached in the btrfs inode and can be accessed */142142+ refcount_set(&node->refs, 2);143143144144- spin_lock(&root->inode_lock);145145- ret = xa_insert(&root->delayed_nodes, ino, node, GFP_NOFS);146146- if (ret) {147147- spin_unlock(&root->inode_lock);148148- kmem_cache_free(delayed_node_cache, node);149149- if (ret != -EBUSY)150150- return ERR_PTR(ret);151151- }152152- } while (ret);144144+ ret = radix_tree_preload(GFP_NOFS);145145+ if (ret) {146146+ kmem_cache_free(delayed_node_cache, node);147147+ return ERR_PTR(ret);148148+ }149149+150150+ spin_lock(&root->inode_lock);151151+ ret = radix_tree_insert(&root->delayed_nodes_tree, ino, node);152152+ if (ret == -EEXIST) {153153+ spin_unlock(&root->inode_lock);154154+ kmem_cache_free(delayed_node_cache, node);155155+ radix_tree_preload_end();156156+ goto again;157157+ }153158 btrfs_inode->delayed_node = node;154159 spin_unlock(&root->inode_lock);160160+ radix_tree_preload_end();155161156162 return node;157163}···276270 * back up. We can delete it now.277271 */278272 ASSERT(refcount_read(&delayed_node->refs) == 0);279279- xa_erase(&root->delayed_nodes, delayed_node->inode_id);273273+ radix_tree_delete(&root->delayed_nodes_tree,274274+ delayed_node->inode_id);280275 spin_unlock(&root->inode_lock);281276 kmem_cache_free(delayed_node_cache, delayed_node);282277 }···1870186318711864void btrfs_kill_all_delayed_nodes(struct btrfs_root *root)18721865{18731873- unsigned long index = 0;18741874- struct btrfs_delayed_node *delayed_node;18661866+ u64 inode_id = 0;18751867 struct btrfs_delayed_node *delayed_nodes[8];18681868+ int i, n;1876186918771870 while (1) {18781878- int n = 0;18791879-18801871 spin_lock(&root->inode_lock);18811881- if (xa_empty(&root->delayed_nodes)) {18721872+ n = radix_tree_gang_lookup(&root->delayed_nodes_tree,18731873+ (void **)delayed_nodes, inode_id,18741874+ ARRAY_SIZE(delayed_nodes));18751875+ if (!n) {18821876 spin_unlock(&root->inode_lock);18831883- return;18771877+ break;18841878 }1885187918861886- xa_for_each_start(&root->delayed_nodes, index, delayed_node, index) {18801880+ inode_id = delayed_nodes[n - 1]->inode_id + 1;18811881+ for (i = 0; i < n; i++) {18871882 /*18881883 * Don't increase refs in case the node is dead and18891884 * about to be removed from the tree in the loop below18901885 */18911891- if (refcount_inc_not_zero(&delayed_node->refs)) {18921892- delayed_nodes[n] = delayed_node;18931893- n++;18941894- }18951895- if (n >= ARRAY_SIZE(delayed_nodes))18961896- break;18861886+ if (!refcount_inc_not_zero(&delayed_nodes[i]->refs))18871887+ delayed_nodes[i] = NULL;18971888 }18981898- index++;18991889 spin_unlock(&root->inode_lock);1900189019011901- for (int i = 0; i < n; i++) {18911891+ for (i = 0; i < n; i++) {18921892+ if (!delayed_nodes[i])18931893+ continue;19021894 __btrfs_kill_delayed_node(delayed_nodes[i]);19031895 btrfs_release_delayed_node(delayed_nodes[i]);19041896 }
+103-82
fs/btrfs/disk-io.c
···5566#include <linux/fs.h>77#include <linux/blkdev.h>88+#include <linux/radix-tree.h>89#include <linux/writeback.h>910#include <linux/workqueue.h>1011#include <linux/kthread.h>···486485 uptodate = btrfs_subpage_test_uptodate(fs_info, page, cur,487486 fs_info->nodesize);488487489489- /* A dirty eb shouldn't disappear from extent_buffers */488488+ /* A dirty eb shouldn't disappear from buffer_radix */490489 if (WARN_ON(!eb))491490 return -EUCLEAN;492491···11591158 root->nr_delalloc_inodes = 0;11601159 root->nr_ordered_extents = 0;11611160 root->inode_tree = RB_ROOT;11621162- xa_init_flags(&root->delayed_nodes, GFP_ATOMIC);11611161+ INIT_RADIX_TREE(&root->delayed_nodes_tree, GFP_ATOMIC);1163116211641163 btrfs_init_root_block_rsv(root);11651164···12111210 btrfs_qgroup_init_swapped_blocks(&root->swapped_blocks);12121211#ifdef CONFIG_BTRFS_DEBUG12131212 INIT_LIST_HEAD(&root->leak_list);12141214- spin_lock(&fs_info->fs_roots_lock);12131213+ spin_lock(&fs_info->fs_roots_radix_lock);12151214 list_add_tail(&root->leak_list, &fs_info->allocated_roots);12161216- spin_unlock(&fs_info->fs_roots_lock);12151215+ spin_unlock(&fs_info->fs_roots_radix_lock);12171216#endif12181217}12191218···16601659{16611660 struct btrfs_root *root;1662166116631663- spin_lock(&fs_info->fs_roots_lock);16641664- root = xa_load(&fs_info->fs_roots, (unsigned long)root_id);16621662+ spin_lock(&fs_info->fs_roots_radix_lock);16631663+ root = radix_tree_lookup(&fs_info->fs_roots_radix,16641664+ (unsigned long)root_id);16651665 if (root)16661666 root = btrfs_grab_root(root);16671667- spin_unlock(&fs_info->fs_roots_lock);16671667+ spin_unlock(&fs_info->fs_roots_radix_lock);16681668 return root;16691669}16701670···17071705{17081706 int ret;1709170717101710- spin_lock(&fs_info->fs_roots_lock);17111711- ret = xa_insert(&fs_info->fs_roots, (unsigned long)root->root_key.objectid,17121712- root, GFP_NOFS);17081708+ ret = radix_tree_preload(GFP_NOFS);17091709+ if (ret)17101710+ return ret;17111711+17121712+ spin_lock(&fs_info->fs_roots_radix_lock);17131713+ ret = radix_tree_insert(&fs_info->fs_roots_radix,17141714+ (unsigned long)root->root_key.objectid,17151715+ root);17131716 if (ret == 0) {17141717 btrfs_grab_root(root);17151715- set_bit(BTRFS_ROOT_REGISTERED, &root->state);17181718+ set_bit(BTRFS_ROOT_IN_RADIX, &root->state);17161719 }17171717- spin_unlock(&fs_info->fs_roots_lock);17201720+ spin_unlock(&fs_info->fs_roots_radix_lock);17211721+ radix_tree_preload_end();1718172217191723 return ret;17201724}···23502342 btrfs_drew_lock_destroy(&root->snapshot_lock);23512343 free_root_extent_buffers(root);23522344#ifdef CONFIG_BTRFS_DEBUG23532353- spin_lock(&root->fs_info->fs_roots_lock);23452345+ spin_lock(&root->fs_info->fs_roots_radix_lock);23542346 list_del_init(&root->leak_list);23552355- spin_unlock(&root->fs_info->fs_roots_lock);23472347+ spin_unlock(&root->fs_info->fs_roots_radix_lock);23562348#endif23572349 kfree(root);23582350 }···2360235223612353void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info)23622354{23632363- struct btrfs_root *root;23642364- unsigned long index = 0;23552355+ int ret;23562356+ struct btrfs_root *gang[8];23572357+ int i;2365235823662359 while (!list_empty(&fs_info->dead_roots)) {23672367- root = list_entry(fs_info->dead_roots.next,23682368- struct btrfs_root, root_list);23692369- list_del(&root->root_list);23602360+ gang[0] = list_entry(fs_info->dead_roots.next,23612361+ struct btrfs_root, root_list);23622362+ list_del(&gang[0]->root_list);2370236323712371- if (test_bit(BTRFS_ROOT_REGISTERED, &root->state))23722372- btrfs_drop_and_free_fs_root(fs_info, root);23732373- btrfs_put_root(root);23642364+ if (test_bit(BTRFS_ROOT_IN_RADIX, &gang[0]->state))23652365+ btrfs_drop_and_free_fs_root(fs_info, gang[0]);23662366+ btrfs_put_root(gang[0]);23742367 }2375236823762376- xa_for_each(&fs_info->fs_roots, index, root) {23772377- btrfs_drop_and_free_fs_root(fs_info, root);23692369+ while (1) {23702370+ ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix,23712371+ (void **)gang, 0,23722372+ ARRAY_SIZE(gang));23732373+ if (!ret)23742374+ break;23752375+ for (i = 0; i < ret; i++)23762376+ btrfs_drop_and_free_fs_root(fs_info, gang[i]);23782377 }23792378}23802379···3149313431503135void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)31513136{31523152- xa_init_flags(&fs_info->fs_roots, GFP_ATOMIC);31533153- xa_init_flags(&fs_info->extent_buffers, GFP_ATOMIC);31373137+ INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC);31383138+ INIT_RADIX_TREE(&fs_info->buffer_radix, GFP_ATOMIC);31543139 INIT_LIST_HEAD(&fs_info->trans_list);31553140 INIT_LIST_HEAD(&fs_info->dead_roots);31563141 INIT_LIST_HEAD(&fs_info->delayed_iputs);···31583143 INIT_LIST_HEAD(&fs_info->caching_block_groups);31593144 spin_lock_init(&fs_info->delalloc_root_lock);31603145 spin_lock_init(&fs_info->trans_lock);31613161- spin_lock_init(&fs_info->fs_roots_lock);31463146+ spin_lock_init(&fs_info->fs_roots_radix_lock);31623147 spin_lock_init(&fs_info->delayed_iput_lock);31633148 spin_lock_init(&fs_info->defrag_inodes_lock);31643149 spin_lock_init(&fs_info->super_lock);···33893374 /*33903375 * btrfs_find_orphan_roots() is responsible for finding all the dead33913376 * roots (with 0 refs), flag them with BTRFS_ROOT_DEAD_TREE and load33923392- * them into the fs_info->fs_roots. This must be done before33773377+ * them into the fs_info->fs_roots_radix tree. This must be done before33933378 * calling btrfs_orphan_cleanup() on the tree root. If we don't do it33943379 * first, then btrfs_orphan_cleanup() will delete a dead root's orphan33953380 * item before the root's tree is deleted - this means that if we unmount···45144499{45154500 bool drop_ref = false;4516450145174517- spin_lock(&fs_info->fs_roots_lock);45184518- xa_erase(&fs_info->fs_roots, (unsigned long)root->root_key.objectid);45194519- if (test_and_clear_bit(BTRFS_ROOT_REGISTERED, &root->state))45024502+ spin_lock(&fs_info->fs_roots_radix_lock);45034503+ radix_tree_delete(&fs_info->fs_roots_radix,45044504+ (unsigned long)root->root_key.objectid);45054505+ if (test_and_clear_bit(BTRFS_ROOT_IN_RADIX, &root->state))45204506 drop_ref = true;45214521- spin_unlock(&fs_info->fs_roots_lock);45074507+ spin_unlock(&fs_info->fs_roots_radix_lock);4522450845234509 if (BTRFS_FS_ERROR(fs_info)) {45244510 ASSERT(root->log_root == NULL);···4535451945364520int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)45374521{45384538- struct btrfs_root *roots[8];45394539- unsigned long index = 0;45404540- int i;45224522+ u64 root_objectid = 0;45234523+ struct btrfs_root *gang[8];45244524+ int i = 0;45414525 int err = 0;45424542- int grabbed;45264526+ unsigned int ret = 0;4543452745444528 while (1) {45454545- struct btrfs_root *root;45464546-45474547- spin_lock(&fs_info->fs_roots_lock);45484548- if (!xa_find(&fs_info->fs_roots, &index, ULONG_MAX, XA_PRESENT)) {45494549- spin_unlock(&fs_info->fs_roots_lock);45504550- return err;45294529+ spin_lock(&fs_info->fs_roots_radix_lock);45304530+ ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix,45314531+ (void **)gang, root_objectid,45324532+ ARRAY_SIZE(gang));45334533+ if (!ret) {45344534+ spin_unlock(&fs_info->fs_roots_radix_lock);45354535+ break;45514536 }45374537+ root_objectid = gang[ret - 1]->root_key.objectid + 1;4552453845534553- grabbed = 0;45544554- xa_for_each_start(&fs_info->fs_roots, index, root, index) {45554555- /* Avoid grabbing roots in dead_roots */45564556- if (btrfs_root_refs(&root->root_item) > 0)45574557- roots[grabbed++] = btrfs_grab_root(root);45584558- if (grabbed >= ARRAY_SIZE(roots))45594559- break;45604560- }45614561- spin_unlock(&fs_info->fs_roots_lock);45624562-45634563- for (i = 0; i < grabbed; i++) {45644564- if (!roots[i])45394539+ for (i = 0; i < ret; i++) {45404540+ /* Avoid to grab roots in dead_roots */45414541+ if (btrfs_root_refs(&gang[i]->root_item) == 0) {45424542+ gang[i] = NULL;45654543 continue;45664566- index = roots[i]->root_key.objectid;45674567- err = btrfs_orphan_cleanup(roots[i]);45684568- if (err)45694569- goto out;45704570- btrfs_put_root(roots[i]);45444544+ }45454545+ /* grab all the search result for later use */45464546+ gang[i] = btrfs_grab_root(gang[i]);45714547 }45724572- index++;45484548+ spin_unlock(&fs_info->fs_roots_radix_lock);45494549+45504550+ for (i = 0; i < ret; i++) {45514551+ if (!gang[i])45524552+ continue;45534553+ root_objectid = gang[i]->root_key.objectid;45544554+ err = btrfs_orphan_cleanup(gang[i]);45554555+ if (err)45564556+ break;45574557+ btrfs_put_root(gang[i]);45584558+ }45594559+ root_objectid++;45734560 }4574456145754575-out:45764576- /* Release the roots that remain uncleaned due to error */45774577- for (; i < grabbed; i++) {45784578- if (roots[i])45794579- btrfs_put_root(roots[i]);45624562+ /* release the uncleaned roots due to error */45634563+ for (; i < ret; i++) {45644564+ if (gang[i])45654565+ btrfs_put_root(gang[i]);45804566 }45814567 return err;45824568}···4897487948984880static void btrfs_drop_all_logs(struct btrfs_fs_info *fs_info)48994881{49004900- unsigned long index = 0;49014901- int grabbed = 0;49024902- struct btrfs_root *roots[8];48824882+ struct btrfs_root *gang[8];48834883+ u64 root_objectid = 0;48844884+ int ret;4903488549044904- spin_lock(&fs_info->fs_roots_lock);49054905- while ((grabbed = xa_extract(&fs_info->fs_roots, (void **)roots, index,49064906- ULONG_MAX, 8, XA_PRESENT))) {49074907- for (int i = 0; i < grabbed; i++)49084908- roots[i] = btrfs_grab_root(roots[i]);49094909- spin_unlock(&fs_info->fs_roots_lock);48864886+ spin_lock(&fs_info->fs_roots_radix_lock);48874887+ while ((ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix,48884888+ (void **)gang, root_objectid,48894889+ ARRAY_SIZE(gang))) != 0) {48904890+ int i;4910489149114911- for (int i = 0; i < grabbed; i++) {49124912- if (!roots[i])48924892+ for (i = 0; i < ret; i++)48934893+ gang[i] = btrfs_grab_root(gang[i]);48944894+ spin_unlock(&fs_info->fs_roots_radix_lock);48954895+48964896+ for (i = 0; i < ret; i++) {48974897+ if (!gang[i])49134898 continue;49144914- index = roots[i]->root_key.objectid;49154915- btrfs_free_log(NULL, roots[i]);49164916- btrfs_put_root(roots[i]);48994899+ root_objectid = gang[i]->root_key.objectid;49004900+ btrfs_free_log(NULL, gang[i]);49014901+ btrfs_put_root(gang[i]);49174902 }49184918- index++;49194919- spin_lock(&fs_info->fs_roots_lock);49034903+ root_objectid++;49044904+ spin_lock(&fs_info->fs_roots_radix_lock);49204905 }49214921- spin_unlock(&fs_info->fs_roots_lock);49064906+ spin_unlock(&fs_info->fs_roots_radix_lock);49224907 btrfs_free_log_root_tree(NULL, fs_info);49234908}49244909
+1-1
fs/btrfs/extent-tree.c
···58295829 btrfs_qgroup_convert_reserved_meta(root, INT_MAX);58305830 btrfs_qgroup_free_meta_all_pertrans(root);5831583158325832- if (test_bit(BTRFS_ROOT_REGISTERED, &root->state))58325832+ if (test_bit(BTRFS_ROOT_IN_RADIX, &root->state))58335833 btrfs_add_dropped_root(trans, root);58345834 else58355835 btrfs_put_root(root);
+73-47
fs/btrfs/extent_io.c
···29662966}2967296729682968/*29692969- * Find extent buffer for a given bytenr.29692969+ * Find extent buffer for a givne bytenr.29702970 *29712971 * This is for end_bio_extent_readpage(), thus we can't do any unsafe locking29722972 * in endio context.···29852985 return (struct extent_buffer *)page->private;29862986 }2987298729882988- /* For subpage case, we need to lookup extent buffer xarray */29892989- eb = xa_load(&fs_info->extent_buffers,29902990- bytenr >> fs_info->sectorsize_bits);29882988+ /* For subpage case, we need to lookup buffer radix tree */29892989+ rcu_read_lock();29902990+ eb = radix_tree_lookup(&fs_info->buffer_radix,29912991+ bytenr >> fs_info->sectorsize_bits);29922992+ rcu_read_unlock();29912993 ASSERT(eb);29922994 return eb;29932995}···44374435 struct extent_buffer *eb;4438443644394437 rcu_read_lock();44404440- eb = xa_load(&fs_info->extent_buffers,44414441- start >> fs_info->sectorsize_bits);44384438+ eb = radix_tree_lookup(&fs_info->buffer_radix,44394439+ start >> fs_info->sectorsize_bits);44424440 if (eb && atomic_inc_not_zero(&eb->refs)) {44434441 rcu_read_unlock();44444442 return eb;···61316129 if (!eb)61326130 return ERR_PTR(-ENOMEM);61336131 eb->fs_info = fs_info;61346134-61356135- do {61366136- ret = xa_insert(&fs_info->extent_buffers,61376137- start >> fs_info->sectorsize_bits,61386138- eb, GFP_NOFS);61396139- if (ret == -ENOMEM) {61406140- exists = ERR_PTR(ret);61326132+again:61336133+ ret = radix_tree_preload(GFP_NOFS);61346134+ if (ret) {61356135+ exists = ERR_PTR(ret);61366136+ goto free_eb;61376137+ }61386138+ spin_lock(&fs_info->buffer_lock);61396139+ ret = radix_tree_insert(&fs_info->buffer_radix,61406140+ start >> fs_info->sectorsize_bits, eb);61416141+ spin_unlock(&fs_info->buffer_lock);61426142+ radix_tree_preload_end();61436143+ if (ret == -EEXIST) {61446144+ exists = find_extent_buffer(fs_info, start);61456145+ if (exists)61416146 goto free_eb;61426142- }61436143- if (ret == -EBUSY) {61446144- exists = find_extent_buffer(fs_info, start);61456145- if (exists)61466146- goto free_eb;61476147- }61486148- } while (ret);61496149-61476147+ else61486148+ goto again;61496149+ }61506150 check_buffer_tree_ref(eb);61516151 set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags);61526152···63236319 }63246320 if (uptodate)63256321 set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);63226322+again:63236323+ ret = radix_tree_preload(GFP_NOFS);63246324+ if (ret) {63256325+ exists = ERR_PTR(ret);63266326+ goto free_eb;63276327+ }6326632863276327- do {63286328- ret = xa_insert(&fs_info->extent_buffers,63296329- start >> fs_info->sectorsize_bits,63306330- eb, GFP_NOFS);63316331- if (ret == -ENOMEM) {63326332- exists = ERR_PTR(ret);63296329+ spin_lock(&fs_info->buffer_lock);63306330+ ret = radix_tree_insert(&fs_info->buffer_radix,63316331+ start >> fs_info->sectorsize_bits, eb);63326332+ spin_unlock(&fs_info->buffer_lock);63336333+ radix_tree_preload_end();63346334+ if (ret == -EEXIST) {63356335+ exists = find_extent_buffer(fs_info, start);63366336+ if (exists)63336337 goto free_eb;63346334- }63356335- if (ret == -EBUSY) {63366336- exists = find_extent_buffer(fs_info, start);63376337- if (exists)63386338- goto free_eb;63396339- }63406340- } while (ret);63416341-63386338+ else63396339+ goto again;63406340+ }63426341 /* add one reference for the tree */63436342 check_buffer_tree_ref(eb);63446343 set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags);···6386637963876380 spin_unlock(&eb->refs_lock);6388638163896389- xa_erase(&fs_info->extent_buffers,63906390- eb->start >> fs_info->sectorsize_bits);63826382+ spin_lock(&fs_info->buffer_lock);63836383+ radix_tree_delete(&fs_info->buffer_radix,63846384+ eb->start >> fs_info->sectorsize_bits);63856385+ spin_unlock(&fs_info->buffer_lock);63916386 } else {63926387 spin_unlock(&eb->refs_lock);63936388 }···73347325 }73357326}7336732773287328+#define GANG_LOOKUP_SIZE 1673377329static struct extent_buffer *get_next_extent_buffer(73387330 struct btrfs_fs_info *fs_info, struct page *page, u64 bytenr)73397331{73407340- struct extent_buffer *eb;73417341- unsigned long index;73327332+ struct extent_buffer *gang[GANG_LOOKUP_SIZE];73337333+ struct extent_buffer *found = NULL;73427334 u64 page_start = page_offset(page);73357335+ u64 cur = page_start;7343733673447337 ASSERT(in_range(bytenr, page_start, PAGE_SIZE));73457338 lockdep_assert_held(&fs_info->buffer_lock);7346733973477347- xa_for_each_start(&fs_info->extent_buffers, index, eb,73487348- page_start >> fs_info->sectorsize_bits) {73497349- if (in_range(eb->start, page_start, PAGE_SIZE))73507350- return eb;73517351- else if (eb->start >= page_start + PAGE_SIZE)73527352- /* Already beyond page end */73537353- return NULL;73407340+ while (cur < page_start + PAGE_SIZE) {73417341+ int ret;73427342+ int i;73437343+73447344+ ret = radix_tree_gang_lookup(&fs_info->buffer_radix,73457345+ (void **)gang, cur >> fs_info->sectorsize_bits,73467346+ min_t(unsigned int, GANG_LOOKUP_SIZE,73477347+ PAGE_SIZE / fs_info->nodesize));73487348+ if (ret == 0)73497349+ goto out;73507350+ for (i = 0; i < ret; i++) {73517351+ /* Already beyond page end */73527352+ if (gang[i]->start >= page_start + PAGE_SIZE)73537353+ goto out;73547354+ /* Found one */73557355+ if (gang[i]->start >= bytenr) {73567356+ found = gang[i];73577357+ goto out;73587358+ }73597359+ }73607360+ cur = gang[ret - 1]->start + gang[ret - 1]->len;73547361 }73557355- return NULL;73627362+out:73637363+ return found;73567364}7357736573587366static int try_release_subpage_extent_buffer(struct page *page)
+7-8
fs/btrfs/inode.c
···35783578 u64 last_objectid = 0;35793579 int ret = 0, nr_unlink = 0;3580358035813581- /* Bail out if the cleanup is already running. */35823581 if (test_and_set_bit(BTRFS_ROOT_ORPHAN_CLEANUP, &root->state))35833582 return 0;35843583···36603661 *36613662 * btrfs_find_orphan_roots() ran before us, which has36623663 * found all deleted roots and loaded them into36633663- * fs_info->fs_roots. So here we can find if an36643664+ * fs_info->fs_roots_radix. So here we can find if an36643665 * orphan item corresponds to a deleted root by looking36653665- * up the root from that xarray.36663666+ * up the root from that radix tree.36663667 */3667366836683668- spin_lock(&fs_info->fs_roots_lock);36693669- dead_root = xa_load(&fs_info->fs_roots,36703670- (unsigned long)found_key.objectid);36693669+ spin_lock(&fs_info->fs_roots_radix_lock);36703670+ dead_root = radix_tree_lookup(&fs_info->fs_roots_radix,36713671+ (unsigned long)found_key.objectid);36713672 if (dead_root && btrfs_root_refs(&dead_root->root_item) == 0)36723673 is_dead_root = 1;36733673- spin_unlock(&fs_info->fs_roots_lock);36743674+ spin_unlock(&fs_info->fs_roots_radix_lock);3674367536753676 if (is_dead_root) {36763677 /* prevent this orphan from being found again */···39103911 * cache.39113912 *39123913 * This is required for both inode re-read from disk and delayed inode39133913- * in the delayed_nodes xarray.39143914+ * in delayed_nodes_tree.39143915 */39153916 if (BTRFS_I(inode)->last_trans == fs_info->generation)39163917 set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
+22-18
fs/btrfs/send.c
···1010#include <linux/mount.h>1111#include <linux/xattr.h>1212#include <linux/posix_acl_xattr.h>1313+#include <linux/radix-tree.h>1314#include <linux/vmalloc.h>1415#include <linux/string.h>1516#include <linux/compat.h>···128127 struct list_head new_refs;129128 struct list_head deleted_refs;130129131131- struct xarray name_cache;130130+ struct radix_tree_root name_cache;132131 struct list_head name_cache_list;133132 int name_cache_size;134133···269268struct name_cache_entry {270269 struct list_head list;271270 /*272272- * On 32bit kernels, xarray has only 32bit indices, but we need to273273- * handle 64bit inums. We use the lower 32bit of the 64bit inum to store274274- * it in the tree. If more than one inum would fall into the same entry,275275- * we use inum_aliases to store the additional entries. inum_aliases is276276- * also used to store entries with the same inum but different generations.271271+ * radix_tree has only 32bit entries but we need to handle 64bit inums.272272+ * We use the lower 32bit of the 64bit inum to store it in the tree. If273273+ * more then one inum would fall into the same entry, we use radix_list274274+ * to store the additional entries. radix_list is also used to store275275+ * entries where two entries have the same inum but different276276+ * generations.277277 */278278- struct list_head inum_aliases;278278+ struct list_head radix_list;279279 u64 ino;280280 u64 gen;281281 u64 parent_ino;···20262024}2027202520282026/*20292029- * Insert a name cache entry. On 32bit kernels the xarray index is 32bit,20272027+ * Insert a name cache entry. On 32bit kernels the radix tree index is 32bit,20302028 * so we need to do some special handling in case we have clashes. This function20312031- * takes care of this with the help of name_cache_entry::inum_aliases.20292029+ * takes care of this with the help of name_cache_entry::radix_list.20322030 * In case of error, nce is kfreed.20332031 */20342032static int name_cache_insert(struct send_ctx *sctx,···20372035 int ret = 0;20382036 struct list_head *nce_head;2039203720402040- nce_head = xa_load(&sctx->name_cache, (unsigned long)nce->ino);20382038+ nce_head = radix_tree_lookup(&sctx->name_cache,20392039+ (unsigned long)nce->ino);20412040 if (!nce_head) {20422041 nce_head = kmalloc(sizeof(*nce_head), GFP_KERNEL);20432042 if (!nce_head) {···20472044 }20482045 INIT_LIST_HEAD(nce_head);2049204620502050- ret = xa_insert(&sctx->name_cache, nce->ino, nce_head, GFP_KERNEL);20472047+ ret = radix_tree_insert(&sctx->name_cache, nce->ino, nce_head);20512048 if (ret < 0) {20522049 kfree(nce_head);20532050 kfree(nce);20542051 return ret;20552052 }20562053 }20572057- list_add_tail(&nce->inum_aliases, nce_head);20542054+ list_add_tail(&nce->radix_list, nce_head);20582055 list_add_tail(&nce->list, &sctx->name_cache_list);20592056 sctx->name_cache_size++;20602057···20662063{20672064 struct list_head *nce_head;2068206520692069- nce_head = xa_load(&sctx->name_cache, (unsigned long)nce->ino);20662066+ nce_head = radix_tree_lookup(&sctx->name_cache,20672067+ (unsigned long)nce->ino);20702068 if (!nce_head) {20712069 btrfs_err(sctx->send_root->fs_info,20722070 "name_cache_delete lookup failed ino %llu cache size %d, leaking memory",20732071 nce->ino, sctx->name_cache_size);20742072 }2075207320762076- list_del(&nce->inum_aliases);20742074+ list_del(&nce->radix_list);20772075 list_del(&nce->list);20782076 sctx->name_cache_size--;20792077···20822078 * We may not get to the final release of nce_head if the lookup fails20832079 */20842080 if (nce_head && list_empty(nce_head)) {20852085- xa_erase(&sctx->name_cache, (unsigned long)nce->ino);20812081+ radix_tree_delete(&sctx->name_cache, (unsigned long)nce->ino);20862082 kfree(nce_head);20872083 }20882084}···20932089 struct list_head *nce_head;20942090 struct name_cache_entry *cur;2095209120962096- nce_head = xa_load(&sctx->name_cache, (unsigned long)ino);20922092+ nce_head = radix_tree_lookup(&sctx->name_cache, (unsigned long)ino);20972093 if (!nce_head)20982094 return NULL;2099209521002100- list_for_each_entry(cur, nce_head, inum_aliases) {20962096+ list_for_each_entry(cur, nce_head, radix_list) {21012097 if (cur->ino == ino && cur->gen == gen)21022098 return cur;21032099 }···7522751875237519 INIT_LIST_HEAD(&sctx->new_refs);75247520 INIT_LIST_HEAD(&sctx->deleted_refs);75257525- xa_init_flags(&sctx->name_cache, GFP_KERNEL);75217521+ INIT_RADIX_TREE(&sctx->name_cache, GFP_KERNEL);75267522 INIT_LIST_HEAD(&sctx->name_cache_list);7527752375287524 sctx->flags = arg->flags;
+20-4
fs/btrfs/tests/btrfs-tests.c
···150150151151void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info)152152{153153- unsigned long index;154154- struct extent_buffer *eb;153153+ struct radix_tree_iter iter;154154+ void **slot;155155 struct btrfs_device *dev, *tmp;156156157157 if (!fs_info)···163163164164 test_mnt->mnt_sb->s_fs_info = NULL;165165166166- xa_for_each(&fs_info->extent_buffers, index, eb) {166166+ spin_lock(&fs_info->buffer_lock);167167+ radix_tree_for_each_slot(slot, &fs_info->buffer_radix, &iter, 0) {168168+ struct extent_buffer *eb;169169+170170+ eb = radix_tree_deref_slot_protected(slot, &fs_info->buffer_lock);171171+ if (!eb)172172+ continue;173173+ /* Shouldn't happen but that kind of thinking creates CVE's */174174+ if (radix_tree_exception(eb)) {175175+ if (radix_tree_deref_retry(eb))176176+ slot = radix_tree_iter_retry(&iter);177177+ continue;178178+ }179179+ slot = radix_tree_iter_resume(slot, &iter);180180+ spin_unlock(&fs_info->buffer_lock);167181 free_extent_buffer_stale(eb);182182+ spin_lock(&fs_info->buffer_lock);168183 }184184+ spin_unlock(&fs_info->buffer_lock);169185170186 btrfs_mapping_tree_free(&fs_info->mapping_tree);171187 list_for_each_entry_safe(dev, tmp, &fs_info->fs_devices->devices,···202186 if (!root)203187 return;204188 /* Will be freed by btrfs_free_fs_roots */205205- if (WARN_ON(test_bit(BTRFS_ROOT_REGISTERED, &root->state)))189189+ if (WARN_ON(test_bit(BTRFS_ROOT_IN_RADIX, &root->state)))206190 return;207191 btrfs_global_root_delete(root);208192 btrfs_put_root(root);
+59-45
fs/btrfs/transaction.c
···2323#include "space-info.h"2424#include "zoned.h"25252626-#define BTRFS_ROOT_TRANS_TAG XA_MARK_02626+#define BTRFS_ROOT_TRANS_TAG 027272828/*2929 * Transaction states and transitions···437437 */438438 smp_wmb();439439440440- spin_lock(&fs_info->fs_roots_lock);440440+ spin_lock(&fs_info->fs_roots_radix_lock);441441 if (root->last_trans == trans->transid && !force) {442442- spin_unlock(&fs_info->fs_roots_lock);442442+ spin_unlock(&fs_info->fs_roots_radix_lock);443443 return 0;444444 }445445- xa_set_mark(&fs_info->fs_roots,446446- (unsigned long)root->root_key.objectid,447447- BTRFS_ROOT_TRANS_TAG);448448- spin_unlock(&fs_info->fs_roots_lock);445445+ radix_tree_tag_set(&fs_info->fs_roots_radix,446446+ (unsigned long)root->root_key.objectid,447447+ BTRFS_ROOT_TRANS_TAG);448448+ spin_unlock(&fs_info->fs_roots_radix_lock);449449 root->last_trans = trans->transid;450450451451 /* this is pretty tricky. We don't want to···487487 spin_unlock(&cur_trans->dropped_roots_lock);488488489489 /* Make sure we don't try to update the root at commit time */490490- xa_clear_mark(&fs_info->fs_roots,491491- (unsigned long)root->root_key.objectid,492492- BTRFS_ROOT_TRANS_TAG);490490+ spin_lock(&fs_info->fs_roots_radix_lock);491491+ radix_tree_tag_clear(&fs_info->fs_roots_radix,492492+ (unsigned long)root->root_key.objectid,493493+ BTRFS_ROOT_TRANS_TAG);494494+ spin_unlock(&fs_info->fs_roots_radix_lock);493495}494496495497int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,···14041402static noinline int commit_fs_roots(struct btrfs_trans_handle *trans)14051403{14061404 struct btrfs_fs_info *fs_info = trans->fs_info;14071407- struct btrfs_root *root;14081408- unsigned long index;14051405+ struct btrfs_root *gang[8];14061406+ int i;14071407+ int ret;1409140814101409 /*14111410 * At this point no one can be using this transaction to modify any tree···14141411 */14151412 ASSERT(trans->transaction->state == TRANS_STATE_COMMIT_DOING);1416141314171417- spin_lock(&fs_info->fs_roots_lock);14181418- xa_for_each_marked(&fs_info->fs_roots, index, root, BTRFS_ROOT_TRANS_TAG) {14191419- int ret;14141414+ spin_lock(&fs_info->fs_roots_radix_lock);14151415+ while (1) {14161416+ ret = radix_tree_gang_lookup_tag(&fs_info->fs_roots_radix,14171417+ (void **)gang, 0,14181418+ ARRAY_SIZE(gang),14191419+ BTRFS_ROOT_TRANS_TAG);14201420+ if (ret == 0)14211421+ break;14221422+ for (i = 0; i < ret; i++) {14231423+ struct btrfs_root *root = gang[i];14241424+ int ret2;1420142514211421- /*14221422- * At this point we can neither have tasks logging inodes14231423- * from a root nor trying to commit a log tree.14241424- */14251425- ASSERT(atomic_read(&root->log_writers) == 0);14261426- ASSERT(atomic_read(&root->log_commit[0]) == 0);14271427- ASSERT(atomic_read(&root->log_commit[1]) == 0);14261426+ /*14271427+ * At this point we can neither have tasks logging inodes14281428+ * from a root nor trying to commit a log tree.14291429+ */14301430+ ASSERT(atomic_read(&root->log_writers) == 0);14311431+ ASSERT(atomic_read(&root->log_commit[0]) == 0);14321432+ ASSERT(atomic_read(&root->log_commit[1]) == 0);1428143314291429- xa_clear_mark(&fs_info->fs_roots,14301430- (unsigned long)root->root_key.objectid,14311431- BTRFS_ROOT_TRANS_TAG);14321432- spin_unlock(&fs_info->fs_roots_lock);14341434+ radix_tree_tag_clear(&fs_info->fs_roots_radix,14351435+ (unsigned long)root->root_key.objectid,14361436+ BTRFS_ROOT_TRANS_TAG);14371437+ spin_unlock(&fs_info->fs_roots_radix_lock);1433143814341434- btrfs_free_log(trans, root);14351435- ret = btrfs_update_reloc_root(trans, root);14361436- if (ret)14371437- return ret;14391439+ btrfs_free_log(trans, root);14401440+ ret2 = btrfs_update_reloc_root(trans, root);14411441+ if (ret2)14421442+ return ret2;1438144314391439- /* See comments in should_cow_block() */14401440- clear_bit(BTRFS_ROOT_FORCE_COW, &root->state);14411441- smp_mb__after_atomic();14441444+ /* see comments in should_cow_block() */14451445+ clear_bit(BTRFS_ROOT_FORCE_COW, &root->state);14461446+ smp_mb__after_atomic();1442144714431443- if (root->commit_root != root->node) {14441444- list_add_tail(&root->dirty_list,14451445- &trans->transaction->switch_commits);14461446- btrfs_set_root_node(&root->root_item, root->node);14481448+ if (root->commit_root != root->node) {14491449+ list_add_tail(&root->dirty_list,14501450+ &trans->transaction->switch_commits);14511451+ btrfs_set_root_node(&root->root_item,14521452+ root->node);14531453+ }14541454+14551455+ ret2 = btrfs_update_root(trans, fs_info->tree_root,14561456+ &root->root_key,14571457+ &root->root_item);14581458+ if (ret2)14591459+ return ret2;14601460+ spin_lock(&fs_info->fs_roots_radix_lock);14611461+ btrfs_qgroup_free_meta_all_pertrans(root);14471462 }14481448-14491449- ret = btrfs_update_root(trans, fs_info->tree_root,14501450- &root->root_key, &root->root_item);14511451- if (ret)14521452- return ret;14531453- spin_lock(&fs_info->fs_roots_lock);14541454- btrfs_qgroup_free_meta_all_pertrans(root);14551463 }14561456- spin_unlock(&fs_info->fs_roots_lock);14641464+ spin_unlock(&fs_info->fs_roots_radix_lock);14571465 return 0;14581466}14591467
···319319 * conflicting writes once the folio is grabbed and locked. It is passed a320320 * pointer to the fsdata cookie that gets returned to the VM to be passed to321321 * write_end. It is permitted to sleep. It should return 0 if the request322322- * should go ahead; unlock the folio and return -EAGAIN to cause the folio to323323- * be regot; or return an error.322322+ * should go ahead or it may return an error. It may also unlock and put the323323+ * folio, provided it sets ``*foliop`` to NULL, in which case a return of 0324324+ * will cause the folio to be re-got and the process to be retried.324325 *325326 * The calling netfs must initialise a netfs context contiguous to the vfs326327 * inode before calling this.···349348350349 if (ctx->ops->check_write_begin) {351350 /* Allow the netfs (eg. ceph) to flush conflicts. */352352- ret = ctx->ops->check_write_begin(file, pos, len, folio, _fsdata);351351+ ret = ctx->ops->check_write_begin(file, pos, len, &folio, _fsdata);353352 if (ret < 0) {354353 trace_netfs_failure(NULL, NULL, ret, netfs_fail_check_write_begin);355355- if (ret == -EAGAIN)356356- goto retry;357354 goto error;358355 }356356+ if (!folio)357357+ goto retry;359358 }360359361360 if (folio_test_uptodate(folio))···417416error_put:418417 netfs_put_request(rreq, false, netfs_rreq_trace_put_failed);419418error:420420- folio_unlock(folio);421421- folio_put(folio);419419+ if (folio) {420420+ folio_unlock(folio);421421+ folio_put(folio);422422+ }422423 _leave(" = %d", ret);423424 return ret;424425}
···158158 * Useful if your architecture doesn't use IPIs for remote TLB invalidates159159 * and therefore doesn't naturally serialize with software page-table walkers.160160 *161161+ * MMU_GATHER_NO_FLUSH_CACHE162162+ *163163+ * Indicates the architecture has flush_cache_range() but it needs *NOT* be called164164+ * before unmapping a VMA.165165+ *166166+ * NOTE: strictly speaking we shouldn't have this knob and instead rely on167167+ * flush_cache_range() being a NOP, except Sparc64 seems to be168168+ * different here.169169+ *170170+ * MMU_GATHER_MERGE_VMAS171171+ *172172+ * Indicates the architecture wants to merge ranges over VMAs; typical when173173+ * multiple range invalidates are more expensive than a full invalidate.174174+ *161175 * MMU_GATHER_NO_RANGE162176 *163163- * Use this if your architecture lacks an efficient flush_tlb_range().177177+ * Use this if your architecture lacks an efficient flush_tlb_range(). This178178+ * option implies MMU_GATHER_MERGE_VMAS above.164179 *165180 * MMU_GATHER_NO_GATHER166181 *···303288 */304289 unsigned int vma_exec : 1;305290 unsigned int vma_huge : 1;291291+ unsigned int vma_pfn : 1;306292307293 unsigned int batch_count;308294···350334351335#ifdef CONFIG_MMU_GATHER_NO_RANGE352336353353-#if defined(tlb_flush) || defined(tlb_start_vma) || defined(tlb_end_vma)354354-#error MMU_GATHER_NO_RANGE relies on default tlb_flush(), tlb_start_vma() and tlb_end_vma()337337+#if defined(tlb_flush)338338+#error MMU_GATHER_NO_RANGE relies on default tlb_flush()355339#endif356340357341/*···371355static inline void372356tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma) { }373357374374-#define tlb_end_vma tlb_end_vma375375-static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma) { }376376-377358#else /* CONFIG_MMU_GATHER_NO_RANGE */378359379360#ifndef tlb_flush380380-381381-#if defined(tlb_start_vma) || defined(tlb_end_vma)382382-#error Default tlb_flush() relies on default tlb_start_vma() and tlb_end_vma()383383-#endif384384-385361/*386362 * When an architecture does not provide its own tlb_flush() implementation387363 * but does have a reasonably efficient flush_vma_range() implementation···393385 flush_tlb_range(&vma, tlb->start, tlb->end);394386 }395387}388388+#endif389389+390390+#endif /* CONFIG_MMU_GATHER_NO_RANGE */396391397392static inline void398393tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma)···413402 */414403 tlb->vma_huge = is_vm_hugetlb_page(vma);415404 tlb->vma_exec = !!(vma->vm_flags & VM_EXEC);405405+ tlb->vma_pfn = !!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP));416406}417417-418418-#else419419-420420-static inline void421421-tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma) { }422422-423423-#endif424424-425425-#endif /* CONFIG_MMU_GATHER_NO_RANGE */426407427408static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)428409{···489486 * case where we're doing a full MM flush. When we're doing a munmap,490487 * the vmas are adjusted to only cover the region to be torn down.491488 */492492-#ifndef tlb_start_vma493489static inline void tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)494490{495491 if (tlb->fullmm)496492 return;497493498494 tlb_update_vma_flags(tlb, vma);495495+#ifndef CONFIG_MMU_GATHER_NO_FLUSH_CACHE499496 flush_cache_range(vma, vma->vm_start, vma->vm_end);500500-}501497#endif498498+}502499503503-#ifndef tlb_end_vma504500static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)505501{506502 if (tlb->fullmm)507503 return;508504509505 /*510510- * Do a TLB flush and reset the range at VMA boundaries; this avoids511511- * the ranges growing with the unused space between consecutive VMAs,512512- * but also the mmu_gather::vma_* flags from tlb_start_vma() rely on513513- * this.506506+ * VM_PFNMAP is more fragile because the core mm will not track the507507+ * page mapcount -- there might not be page-frames for these PFNs after508508+ * all. Force flush TLBs for such ranges to avoid munmap() vs509509+ * unmap_mapping_range() races.514510 */515515- tlb_flush_mmu_tlbonly(tlb);511511+ if (tlb->vma_pfn || !IS_ENABLED(CONFIG_MMU_GATHER_MERGE_VMAS)) {512512+ /*513513+ * Do a TLB flush and reset the range at VMA boundaries; this avoids514514+ * the ranges growing with the unused space between consecutive VMAs.515515+ */516516+ tlb_flush_mmu_tlbonly(tlb);517517+ }516518}517517-#endif518519519520/*520521 * tlb_flush_{pte|pmd|pud|p4d}_range() adjust the tlb->start and tlb->end,
···260260 bool has_crossts;261261 int int_snapshot_num;262262 int ext_snapshot_num;263263+ bool int_snapshot_en;263264 bool ext_snapshot_en;264265 bool multi_msi_en;265266 int msi_mac_vec;
···179179 int dif, int sdif)180180{181181#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)182182- return inet_bound_dev_eq(!!net->ipv4.sysctl_tcp_l3mdev_accept,182182+ return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept),183183 bound_dev_if, dif, sdif);184184#else185185 return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
+5-4
include/net/inet_sock.h
···107107108108static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb)109109{110110- if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept)110110+ if (!sk->sk_mark &&111111+ READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept))111112 return skb->mark;112113113114 return sk->sk_mark;···121120#ifdef CONFIG_NET_L3_MASTER_DEV122121 struct net *net = sock_net(sk);123122124124- if (!bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept)123123+ if (!bound_dev_if && READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept))125124 return l3mdev_master_ifindex_by_index(net, skb->skb_iif);126125#endif127126···133132#ifdef CONFIG_NET_L3_MASTER_DEV134133 struct net *net = sock_net(sk);135134136136- if (!net->ipv4.sysctl_tcp_l3mdev_accept)135135+ if (!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept))137136 return l3mdev_master_ifindex_by_index(net,138137 sk->sk_bound_dev_if);139138#endif···375374static inline bool inet_can_nonlocal_bind(struct net *net,376375 struct inet_sock *inet)377376{378378- return net->ipv4.sysctl_ip_nonlocal_bind ||377377+ return READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind) ||379378 inet->freebind || inet->transparent;380379}381380
+3-3
include/net/ip.h
···357357358358static inline bool inet_port_requires_bind_service(struct net *net, unsigned short port)359359{360360- return port < net->ipv4.sysctl_ip_prot_sock;360360+ return port < READ_ONCE(net->ipv4.sysctl_ip_prot_sock);361361}362362363363#else···384384void ip_static_sysctl_init(void);385385386386#define IP4_REPLY_MARK(net, mark) \387387- ((net)->ipv4.sysctl_fwmark_reflect ? (mark) : 0)387387+ (READ_ONCE((net)->ipv4.sysctl_fwmark_reflect) ? (mark) : 0)388388389389static inline bool ip_is_fragment(const struct iphdr *iph)390390{···446446 struct net *net = dev_net(dst->dev);447447 unsigned int mtu;448448449449- if (net->ipv4.sysctl_ip_fwd_use_pmtu ||449449+ if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) ||450450 ip_mtu_locked(dst) ||451451 !forwarding) {452452 mtu = rt->rt_pmtu;
-4
include/net/protocol.h
···35353636/* This is used to register protocols. */3737struct net_protocol {3838- int (*early_demux)(struct sk_buff *skb);3939- int (*early_demux_handler)(struct sk_buff *skb);4038 int (*handler)(struct sk_buff *skb);41394240 /* This returns an error if we weren't able to handle the error. */···50525153#if IS_ENABLED(CONFIG_IPV6)5254struct inet6_protocol {5353- void (*early_demux)(struct sk_buff *skb);5454- void (*early_demux_handler)(struct sk_buff *skb);5555 int (*handler)(struct sk_buff *skb);56565757 /* This returns an error if we weren't able to handle the error. */
+1-1
include/net/route.h
···369369 struct net *net = dev_net(dst->dev);370370371371 if (hoplimit == 0)372372- hoplimit = net->ipv4.sysctl_ip_default_ttl;372372+ hoplimit = READ_ONCE(net->ipv4.sysctl_ip_default_ttl);373373 return hoplimit;374374}375375
···7878 * Note that input core does not clamp reported values to the7979 * [minimum, maximum] limits, such task is left to userspace.8080 *8181- * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z)8282- * is reported in units per millimeter (units/mm), resolution8383- * for rotational axes (ABS_RX, ABS_RY, ABS_RZ) is reported8484- * in units per radian.8181+ * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z,8282+ * ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units8383+ * per millimeter (units/mm), resolution for rotational axes8484+ * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian.8585+ * The resolution for the size axes (ABS_MT_TOUCH_MAJOR,8686+ * ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR)8787+ * is reported in units per millimeter (units/mm).8588 * When INPUT_PROP_ACCELEROMETER is set the resolution changes.8689 * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in8790 * units per g (units/g) and in units per degree per second
···6253625362546254 if (!atomic_inc_not_zero(&event->rb->mmap_count)) {62556255 /*62566256- * Raced against perf_mmap_close() through62576257- * perf_event_set_output(). Try again, hope for better62586258- * luck.62566256+ * Raced against perf_mmap_close(); remove the62576257+ * event and try again.62596258 */62596259+ ring_buffer_attach(event, NULL);62606260 mutex_unlock(&event->mmap_mutex);62616261 goto again;62626262 }···1182911829 goto out;1183011830}11831118311183211832+static void mutex_lock_double(struct mutex *a, struct mutex *b)1183311833+{1183411834+ if (b < a)1183511835+ swap(a, b);1183611836+1183711837+ mutex_lock(a);1183811838+ mutex_lock_nested(b, SINGLE_DEPTH_NESTING);1183911839+}1184011840+1183211841static int1183311842perf_event_set_output(struct perf_event *event, struct perf_event *output_event)1183411843{1183511844 struct perf_buffer *rb = NULL;1183611845 int ret = -EINVAL;11837118461183811838- if (!output_event)1184711847+ if (!output_event) {1184811848+ mutex_lock(&event->mmap_mutex);1183911849 goto set;1185011850+ }11840118511184111852 /* don't allow circular references */1184211853 if (event == output_event)···1188511874 event->pmu != output_event->pmu)1188611875 goto out;11887118761187711877+ /*1187811878+ * Hold both mmap_mutex to serialize against perf_mmap_close(). Since1187911879+ * output_event is already on rb->event_list, and the list iteration1188011880+ * restarts after every removal, it is guaranteed this new event is1188111881+ * observed *OR* if output_event is already removed, it's guaranteed we1188211882+ * observe !rb->mmap_count.1188311883+ */1188411884+ mutex_lock_double(&event->mmap_mutex, &output_event->mmap_mutex);1188811885set:1188911889- mutex_lock(&event->mmap_mutex);1189011886 /* Can't redirect output if we've got an active mmap() */1189111887 if (atomic_read(&event->mmap_count))1189211888 goto unlock;···1190311885 rb = ring_buffer_get(output_event);1190411886 if (!rb)1190511887 goto unlock;1188811888+1188911889+ /* did we race against perf_mmap_close() */1189011890+ if (!atomic_read(&rb->mmap_count)) {1189111891+ ring_buffer_put(rb);1189211892+ goto unlock;1189311893+ }1190611894 }11907118951190811896 ring_buffer_attach(event, rb);···1191611892 ret = 0;1191711893unlock:1191811894 mutex_unlock(&event->mmap_mutex);1189511895+ if (output_event)1189611896+ mutex_unlock(&output_event->mmap_mutex);11919118971192011898out:1192111899 return ret;1192211922-}1192311923-1192411924-static void mutex_lock_double(struct mutex *a, struct mutex *b)1192511925-{1192611926- if (b < a)1192711927- swap(a, b);1192811928-1192911929- mutex_lock(a);1193011930- mutex_lock_nested(b, SINGLE_DEPTH_NESTING);1193111900}11932119011193311902static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id)
+11-2
kernel/printk/printk.c
···33803380 diff = 0;3381338133823382 console_lock();33833383+33833384 for_each_console(c) {33843385 if (con && con != c)33853386 continue;···33903389 if (printk_seq < seq)33913390 diff += seq - printk_seq;33923391 }33933393- console_unlock();3394339233953395- if (diff != last_diff && reset_on_progress)33933393+ /*33943394+ * If consoles are suspended, it cannot be expected that they33953395+ * make forward progress, so timeout immediately. @diff is33963396+ * still used to return a valid flush status.33973397+ */33983398+ if (console_suspended)33993399+ remaining = 0;34003400+ else if (diff != last_diff && reset_on_progress)33963401 remaining = timeout_ms;34023402+34033403+ console_unlock();3397340433983405 if (diff == 0 || remaining == 0)33993406 break;
···3434#define WATCH_QUEUE_NOTE_SIZE 1283535#define WATCH_QUEUE_NOTES_PER_PAGE (PAGE_SIZE / WATCH_QUEUE_NOTE_SIZE)36363737+/*3838+ * This must be called under the RCU read-lock, which makes3939+ * sure that the wqueue still exists. It can then take the lock,4040+ * and check that the wqueue hasn't been destroyed, which in4141+ * turn makes sure that the notification pipe still exists.4242+ */4343+static inline bool lock_wqueue(struct watch_queue *wqueue)4444+{4545+ spin_lock_bh(&wqueue->lock);4646+ if (unlikely(wqueue->defunct)) {4747+ spin_unlock_bh(&wqueue->lock);4848+ return false;4949+ }5050+ return true;5151+}5252+5353+static inline void unlock_wqueue(struct watch_queue *wqueue)5454+{5555+ spin_unlock_bh(&wqueue->lock);5656+}5757+3758static void watch_queue_pipe_buf_release(struct pipe_inode_info *pipe,3859 struct pipe_buffer *buf)3960{···90699170/*9271 * Post a notification to a watch queue.7272+ *7373+ * Must be called with the RCU lock for reading, and the7474+ * watch_queue lock held, which guarantees that the pipe7575+ * hasn't been released.9376 */9477static bool post_one_notification(struct watch_queue *wqueue,9578 struct watch_notification *n)···10984 return false;1108511186 spin_lock_irq(&pipe->rd_wait.lock);112112-113113- if (wqueue->defunct)114114- goto out;1158711688 mask = pipe->ring_size - 1;11789 head = pipe->head;···225203 if (security_post_notification(watch->cred, cred, n) < 0)226204 continue;227205228228- post_one_notification(wqueue, n);206206+ if (lock_wqueue(wqueue)) {207207+ post_one_notification(wqueue, n);208208+ unlock_wqueue(wqueue);209209+ }229210 }230211231212 rcu_read_unlock();···487462 return -EAGAIN;488463 }489464490490- spin_lock_bh(&wqueue->lock);491491- kref_get(&wqueue->usage);492492- kref_get(&watch->usage);493493- hlist_add_head(&watch->queue_node, &wqueue->watches);494494- spin_unlock_bh(&wqueue->lock);465465+ if (lock_wqueue(wqueue)) {466466+ kref_get(&wqueue->usage);467467+ kref_get(&watch->usage);468468+ hlist_add_head(&watch->queue_node, &wqueue->watches);469469+ unlock_wqueue(wqueue);470470+ }495471496472 hlist_add_head(&watch->list_node, &wlist->watchers);497473 return 0;···546520547521 wqueue = rcu_dereference(watch->queue);548522549549- /* We don't need the watch list lock for the next bit as RCU is550550- * protecting *wqueue from deallocation.551551- */552552- if (wqueue) {523523+ if (lock_wqueue(wqueue)) {553524 post_one_notification(wqueue, &n.watch);554554-555555- spin_lock_bh(&wqueue->lock);556525557526 if (!hlist_unhashed(&watch->queue_node)) {558527 hlist_del_init_rcu(&watch->queue_node);559528 put_watch(watch);560529 }561530562562- spin_unlock_bh(&wqueue->lock);531531+ unlock_wqueue(wqueue);563532 }564533565534 if (wlist->release_watch) {
+3
lib/Kconfig.ubsan
···8484config UBSAN_DIV_ZERO8585 bool "Perform checking for integer divide-by-zero"8686 depends on $(cc-option,-fsanitize=integer-divide-by-zero)8787+ # https://github.com/ClangBuiltLinux/linux/issues/16578888+ # https://github.com/llvm/llvm-project/issues/562898989+ depends on !CC_IS_CLANG8790 help8891 This option enables -fsanitize=integer-divide-by-zero which checks8992 for integer division by zero. This is effectively redundant with the
+2-2
net/core/filter.c
···70847084 if (sk->sk_protocol != IPPROTO_TCP || sk->sk_state != TCP_LISTEN)70857085 return -EINVAL;7086708670877087- if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies)70877087+ if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies))70887088 return -EINVAL;7089708970907090 if (!th->ack || th->rst || th->syn)···71597159 if (sk->sk_protocol != IPPROTO_TCP || sk->sk_state != TCP_LISTEN)71607160 return -EINVAL;7161716171627162- if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies)71627162+ if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies))71637163 return -ENOENT;7164716471657165 if (!th->syn || th->ack || th->fin || th->rst)
+2-2
net/core/secure_seq.c
···6464 .daddr = *(struct in6_addr *)daddr,6565 };66666767- if (net->ipv4.sysctl_tcp_timestamps != 1)6767+ if (READ_ONCE(net->ipv4.sysctl_tcp_timestamps) != 1)6868 return 0;69697070 ts_secret_init();···120120#ifdef CONFIG_INET121121u32 secure_tcp_ts_off(const struct net *net, __be32 saddr, __be32 daddr)122122{123123- if (net->ipv4.sysctl_tcp_timestamps != 1)123123+ if (READ_ONCE(net->ipv4.sysctl_tcp_timestamps) != 1)124124 return 0;125125126126 ts_secret_init();
+2-2
net/core/sock_reuseport.c
···387387 prog = rcu_dereference_protected(reuse->prog,388388 lockdep_is_held(&reuseport_lock));389389390390- if (sock_net(sk)->ipv4.sysctl_tcp_migrate_req ||390390+ if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req) ||391391 (prog && prog->expected_attach_type == BPF_SK_REUSEPORT_SELECT_OR_MIGRATE)) {392392 /* Migration capable, move sk from the listening section393393 * to the closed section.···545545 hash = migrating_sk->sk_hash;546546 prog = rcu_dereference(reuse->prog);547547 if (!prog || prog->expected_attach_type != BPF_SK_REUSEPORT_SELECT_OR_MIGRATE) {548548- if (sock_net(sk)->ipv4.sysctl_tcp_migrate_req)548548+ if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req))549549 goto select_by_hash;550550 goto failure;551551 }
+4-3
net/dsa/port.c
···248248 struct netlink_ext_ack extack = {0};249249 bool change_vlan_filtering = false;250250 struct dsa_switch *ds = dp->ds;251251+ struct dsa_port *other_dp;251252 bool vlan_filtering;252253 int err;253254···271270 * VLAN-aware bridge.272271 */273272 if (change_vlan_filtering && ds->vlan_filtering_is_global) {274274- dsa_switch_for_each_port(dp, ds) {275275- struct net_device *br = dsa_port_bridge_dev_get(dp);273273+ dsa_switch_for_each_port(other_dp, ds) {274274+ struct net_device *br = dsa_port_bridge_dev_get(other_dp);276275277276 if (br && br_vlan_enabled(br)) {278277 change_vlan_filtering = false;···800799 ds->vlan_filtering = vlan_filtering;801800802801 dsa_switch_for_each_user_port(other_dp, ds) {803803- struct net_device *slave = dp->slave;802802+ struct net_device *slave = other_dp->slave;804803805804 /* We might be called in the unbind path, so not806805 * all slave devices might still be registered.
+4-14
net/ipv4/af_inet.c
···217217 * because the socket was in TCP_LISTEN state previously but218218 * was shutdown() rather than close().219219 */220220- tcp_fastopen = sock_net(sk)->ipv4.sysctl_tcp_fastopen;220220+ tcp_fastopen = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen);221221 if ((tcp_fastopen & TFO_SERVER_WO_SOCKOPT1) &&222222 (tcp_fastopen & TFO_SERVER_ENABLE) &&223223 !inet_csk(sk)->icsk_accept_queue.fastopenq.max_qlen) {···335335 inet->hdrincl = 1;336336 }337337338338- if (net->ipv4.sysctl_ip_no_pmtu_disc)338338+ if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc))339339 inet->pmtudisc = IP_PMTUDISC_DONT;340340 else341341 inet->pmtudisc = IP_PMTUDISC_WANT;···17111711};17121712#endif1713171317141714-/* thinking of making this const? Don't.17151715- * early_demux can change based on sysctl.17161716- */17171717-static struct net_protocol tcp_protocol = {17181718- .early_demux = tcp_v4_early_demux,17191719- .early_demux_handler = tcp_v4_early_demux,17141714+static const struct net_protocol tcp_protocol = {17201715 .handler = tcp_v4_rcv,17211716 .err_handler = tcp_v4_err,17221717 .no_policy = 1,17231718 .icmp_strict_tag_validation = 1,17241719};1725172017261726-/* thinking of making this const? Don't.17271727- * early_demux can change based on sysctl.17281728- */17291729-static struct net_protocol udp_protocol = {17301730- .early_demux = udp_v4_early_demux,17311731- .early_demux_handler = udp_v4_early_demux,17211721+static const struct net_protocol udp_protocol = {17321722 .handler = udp_rcv,17331723 .err_handler = udp_err,17341724 .no_policy = 1,
···22172217 }2218221822192219 change_nexthops(fi) {22202220- if (net->ipv4.sysctl_fib_multipath_use_neigh) {22202220+ if (READ_ONCE(net->ipv4.sysctl_fib_multipath_use_neigh)) {22212221 if (!fib_good_nh(nexthop_nh))22222222 continue;22232223 if (!first) {
···467467468468 if (pmc->multiaddr == IGMP_ALL_HOSTS)469469 return skb;470470- if (ipv4_is_local_multicast(pmc->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)470470+ if (ipv4_is_local_multicast(pmc->multiaddr) &&471471+ !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))471472 return skb;472473473474 mtu = READ_ONCE(dev->mtu);···594593 if (pmc->multiaddr == IGMP_ALL_HOSTS)595594 continue;596595 if (ipv4_is_local_multicast(pmc->multiaddr) &&597597- !net->ipv4.sysctl_igmp_llm_reports)596596+ !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))598597 continue;599598 spin_lock_bh(&pmc->lock);600599 if (pmc->sfcount[MCAST_EXCLUDE])···737736 if (type == IGMPV3_HOST_MEMBERSHIP_REPORT)738737 return igmpv3_send_report(in_dev, pmc);739738740740- if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports)739739+ if (ipv4_is_local_multicast(group) &&740740+ !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))741741 return 0;742742743743 if (type == IGMP_HOST_LEAVE_MESSAGE)···827825 struct net *net = dev_net(in_dev->dev);828826 if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev))829827 return;830830- WRITE_ONCE(in_dev->mr_ifc_count, in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv);828828+ WRITE_ONCE(in_dev->mr_ifc_count, in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv));831829 igmp_ifc_start_timer(in_dev, 1);832830}833831···922920923921 if (group == IGMP_ALL_HOSTS)924922 return false;925925- if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports)923923+ if (ipv4_is_local_multicast(group) &&924924+ !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))926925 return false;927926928927 rcu_read_lock();···10091006 * received value was zero, use the default or statically10101007 * configured value.10111008 */10121012- in_dev->mr_qrv = ih3->qrv ?: net->ipv4.sysctl_igmp_qrv;10091009+ in_dev->mr_qrv = ih3->qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);10131010 in_dev->mr_qi = IGMPV3_QQIC(ih3->qqic)*HZ ?: IGMP_QUERY_INTERVAL;1014101110151012 /* RFC3376, 8.3. Query Response Interval:···10481045 if (im->multiaddr == IGMP_ALL_HOSTS)10491046 continue;10501047 if (ipv4_is_local_multicast(im->multiaddr) &&10511051- !net->ipv4.sysctl_igmp_llm_reports)10481048+ !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))10521049 continue;10531050 spin_lock_bh(&im->lock);10541051 if (im->tm_running)···11891186 pmc->interface = im->interface;11901187 in_dev_hold(in_dev);11911188 pmc->multiaddr = im->multiaddr;11921192- pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;11891189+ pmc->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);11931190 pmc->sfmode = im->sfmode;11941191 if (pmc->sfmode == MCAST_INCLUDE) {11951192 struct ip_sf_list *psf;···12401237 swap(im->tomb, pmc->tomb);12411238 swap(im->sources, pmc->sources);12421239 for (psf = im->sources; psf; psf = psf->sf_next)12431243- psf->sf_crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;12401240+ psf->sf_crcount = in_dev->mr_qrv ?:12411241+ READ_ONCE(net->ipv4.sysctl_igmp_qrv);12441242 } else {12451245- im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;12431243+ im->crcount = in_dev->mr_qrv ?:12441244+ READ_ONCE(net->ipv4.sysctl_igmp_qrv);12461245 }12471246 in_dev_put(pmc->interface);12481247 kfree_pmc(pmc);···13011296#ifdef CONFIG_IP_MULTICAST13021297 if (im->multiaddr == IGMP_ALL_HOSTS)13031298 return;13041304- if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)12991299+ if (ipv4_is_local_multicast(im->multiaddr) &&13001300+ !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))13051301 return;1306130213071303 reporter = im->reporter;···13441338#ifdef CONFIG_IP_MULTICAST13451339 if (im->multiaddr == IGMP_ALL_HOSTS)13461340 return;13471347- if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)13411341+ if (ipv4_is_local_multicast(im->multiaddr) &&13421342+ !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))13481343 return;1349134413501345 if (in_dev->dead)13511346 return;1352134713531353- im->unsolicit_count = net->ipv4.sysctl_igmp_qrv;13481348+ im->unsolicit_count = READ_ONCE(net->ipv4.sysctl_igmp_qrv);13541349 if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) {13551350 spin_lock_bh(&im->lock);13561351 igmp_start_timer(im, IGMP_INITIAL_REPORT_DELAY);···13651358 * IN() to IN(A).13661359 */13671360 if (im->sfmode == MCAST_EXCLUDE)13681368- im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;13611361+ im->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);1369136213701363 igmp_ifc_event(in_dev);13711364#endif···16491642 if (im->multiaddr == IGMP_ALL_HOSTS)16501643 continue;16511644 if (ipv4_is_local_multicast(im->multiaddr) &&16521652- !net->ipv4.sysctl_igmp_llm_reports)16451645+ !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))16531646 continue;1654164716551648 /* a failover is happening and switches···1756174917571750 in_dev->mr_qi = IGMP_QUERY_INTERVAL;17581751 in_dev->mr_qri = IGMP_QUERY_RESPONSE_INTERVAL;17591759- in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv;17521752+ in_dev->mr_qrv = READ_ONCE(net->ipv4.sysctl_igmp_qrv);17601753}17611754#else17621755static void ip_mc_reset(struct in_device *in_dev)···18901883#ifdef CONFIG_IP_MULTICAST18911884 if (psf->sf_oldin &&18921885 !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) {18931893- psf->sf_crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;18861886+ psf->sf_crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);18941887 psf->sf_next = pmc->tomb;18951888 pmc->tomb = psf;18961889 rv = 1;···19541947 /* filter mode change */19551948 pmc->sfmode = MCAST_INCLUDE;19561949#ifdef CONFIG_IP_MULTICAST19571957- pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;19501950+ pmc->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);19581951 WRITE_ONCE(in_dev->mr_ifc_count, pmc->crcount);19591952 for (psf = pmc->sources; psf; psf = psf->sf_next)19601953 psf->sf_crcount = 0;···21332126#ifdef CONFIG_IP_MULTICAST21342127 /* else no filters; keep old mode for reports */2135212821362136- pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;21292129+ pmc->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);21372130 WRITE_ONCE(in_dev->mr_ifc_count, pmc->crcount);21382131 for (psf = pmc->sources; psf; psf = psf->sf_next)21392132 psf->sf_crcount = 0;···21992192 count++;22002193 }22012194 err = -ENOBUFS;22022202- if (count >= net->ipv4.sysctl_igmp_max_memberships)21952195+ if (count >= READ_ONCE(net->ipv4.sysctl_igmp_max_memberships))22032196 goto done;22042197 iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL);22052198 if (!iml)···23862379 }23872380 /* else, add a new source to the filter */2388238123892389- if (psl && psl->sl_count >= net->ipv4.sysctl_igmp_max_msf) {23822382+ if (psl && psl->sl_count >= READ_ONCE(net->ipv4.sysctl_igmp_max_msf)) {23902383 err = -ENOBUFS;23912384 goto done;23922385 }
+3-2
net/ipv4/inet_connection_sock.c
···263263 goto other_half_scan;264264 }265265266266- if (net->ipv4.sysctl_ip_autobind_reuse && !relax) {266266+ if (READ_ONCE(net->ipv4.sysctl_ip_autobind_reuse) && !relax) {267267 /* We still have a chance to connect to different destinations */268268 relax = true;269269 goto ports_exhausted;···833833834834 icsk = inet_csk(sk_listener);835835 net = sock_net(sk_listener);836836- max_syn_ack_retries = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_synack_retries;836836+ max_syn_ack_retries = icsk->icsk_syn_retries ? :837837+ READ_ONCE(net->ipv4.sysctl_tcp_synack_retries);837838 /* Normally all the openreqs are young and become mature838839 * (i.e. converted to established socket) for first timeout.839840 * If synack was not acknowledged for 1 second, it means
+1-1
net/ipv4/ip_forward.c
···157157 !skb_sec_path(skb))158158 ip_rt_send_redirect(skb);159159160160- if (net->ipv4.sysctl_ip_fwd_update_priority)160160+ if (READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority))161161 skb->priority = rt_tos2priority(iph->tos);162162163163 return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD,
+21-14
net/ipv4/ip_input.c
···312312 ip_hdr(hint)->tos == iph->tos;313313}314314315315-INDIRECT_CALLABLE_DECLARE(int udp_v4_early_demux(struct sk_buff *));316316-INDIRECT_CALLABLE_DECLARE(int tcp_v4_early_demux(struct sk_buff *));315315+int tcp_v4_early_demux(struct sk_buff *skb);316316+int udp_v4_early_demux(struct sk_buff *skb);317317static int ip_rcv_finish_core(struct net *net, struct sock *sk,318318 struct sk_buff *skb, struct net_device *dev,319319 const struct sk_buff *hint)320320{321321 const struct iphdr *iph = ip_hdr(skb);322322- int (*edemux)(struct sk_buff *skb);323322 int err, drop_reason;324323 struct rtable *rt;325324···331332 goto drop_error;332333 }333334334334- if (net->ipv4.sysctl_ip_early_demux &&335335+ if (READ_ONCE(net->ipv4.sysctl_ip_early_demux) &&335336 !skb_dst(skb) &&336337 !skb->sk &&337338 !ip_is_fragment(iph)) {338338- const struct net_protocol *ipprot;339339- int protocol = iph->protocol;339339+ switch (iph->protocol) {340340+ case IPPROTO_TCP:341341+ if (READ_ONCE(net->ipv4.sysctl_tcp_early_demux)) {342342+ tcp_v4_early_demux(skb);340343341341- ipprot = rcu_dereference(inet_protos[protocol]);342342- if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) {343343- err = INDIRECT_CALL_2(edemux, tcp_v4_early_demux,344344- udp_v4_early_demux, skb);345345- if (unlikely(err))346346- goto drop_error;347347- /* must reload iph, skb->head might have changed */348348- iph = ip_hdr(skb);344344+ /* must reload iph, skb->head might have changed */345345+ iph = ip_hdr(skb);346346+ }347347+ break;348348+ case IPPROTO_UDP:349349+ if (READ_ONCE(net->ipv4.sysctl_udp_early_demux)) {350350+ err = udp_v4_early_demux(skb);351351+ if (unlikely(err))352352+ goto drop_error;353353+354354+ /* must reload iph, skb->head might have changed */355355+ iph = ip_hdr(skb);356356+ }357357+ break;349358 }350359 }351360
···35343534 struct tc_action *actions[],35353535 struct netlink_ext_ack *extack)35363536{35373537- int i, j, index, err = 0;35373537+ int i, j, k, index, err = 0;35383538 struct tc_action *act;3539353935403540 BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY != FLOW_ACTION_HW_STATS_ANY);···35543554 if (err)35553555 goto err_out_locked;3556355635573557- entry->hw_stats = tc_act_hw_stats(act->hw_stats);35583558- entry->hw_index = act->tcfa_index;35593557 index = 0;35603558 err = tc_setup_offload_act(act, entry, &index, extack);35613561- if (!err)35623562- j += index;35633563- else35593559+ if (err)35643560 goto err_out_locked;35613561+35623562+ for (k = 0; k < index ; k++) {35633563+ entry[k].hw_stats = tc_act_hw_stats(act->hw_stats);35643564+ entry[k].hw_index = act->tcfa_index;35653565+ }35663566+35673567+ j += index;35683568+35653569 spin_unlock_bh(&act->tcfa_lock);35663570 }35673571
+1-1
net/sctp/protocol.c
···358358 if (addr->v4.sin_addr.s_addr != htonl(INADDR_ANY) &&359359 ret != RTN_LOCAL &&360360 !sp->inet.freebind &&361361- !net->ipv4.sysctl_ip_nonlocal_bind)361361+ !READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind))362362 return 0;363363364364 if (ipv6_only_sock(sctp_opt2sk(sp)))
+1-1
net/smc/smc_llc.c
···21272127 init_waitqueue_head(&lgr->llc_flow_waiter);21282128 init_waitqueue_head(&lgr->llc_msg_waiter);21292129 mutex_init(&lgr->llc_conf_mutex);21302130- lgr->llc_testlink_time = net->ipv4.sysctl_tcp_keepalive_time;21302130+ lgr->llc_testlink_time = READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time);21312131}2132213221332133/* called after lgr was removed from lgr_list */
+5-3
net/tls/tls_device.c
···9898 unsigned long flags;9999100100 spin_lock_irqsave(&tls_device_lock, flags);101101+ if (unlikely(!refcount_dec_and_test(&ctx->refcount)))102102+ goto unlock;103103+101104 list_move_tail(&ctx->list, &tls_device_gc_list);102105103106 /* schedule_work inside the spinlock104107 * to make sure tls_device_down waits for that work.105108 */106109 schedule_work(&tls_device_gc_work);107107-110110+unlock:108111 spin_unlock_irqrestore(&tls_device_lock, flags);109112}110113···198195 clean_acked_data_disable(inet_csk(sk));199196 }200197201201- if (refcount_dec_and_test(&tls_ctx->refcount))202202- tls_device_queue_ctx_destruction(tls_ctx);198198+ tls_device_queue_ctx_destruction(tls_ctx);203199}204200EXPORT_SYMBOL_GPL(tls_device_sk_destruct);205201