We need the fixes in here as well.
Unified · Split
| @@ -109,8 +109,8 @@ ForEachMacros: · 108 unmodified lines | ||
| 109 | 109 | - 'css_for_each_child' |
| 110 | 110 | - 'css_for_each_descendant_post' |
| 111 | 111 | - 'css_for_each_descendant_pre' |
| 112 | − - 'cxl_for_each_cmd' | |
| 113 | 112 | - 'device_for_each_child_node' |
| 113 | + - 'displayid_iter_for_each' | |
| 114 | 114 | - 'dma_fence_chain_for_each' |
| 115 | 115 | - 'do_for_each_ftrace_op' |
| 116 | 116 | - 'drm_atomic_crtc_for_each_plane' |
| @@ -136,6 +136,7 @@ ForEachMacros: · 19 unmodified lines | ||
| 136 | 136 | - 'drm_mm_for_each_node_in_range' |
| 137 | 137 | - 'drm_mm_for_each_node_safe' |
| 138 | 138 | - 'flow_action_for_each' |
| 139 | + - 'for_each_acpi_dev_match' | |
| 139 | 140 | - 'for_each_active_dev_scope' |
| 140 | 141 | - 'for_each_active_drhd_unit' |
| 141 | 142 | - 'for_each_active_iommu' |
| @@ -171,7 +172,6 @@ ForEachMacros: · 29 unmodified lines | ||
| 171 | 172 | - 'for_each_dapm_widgets' |
| 172 | 173 | - 'for_each_dev_addr' |
| 173 | 174 | - 'for_each_dev_scope' |
| 174 | − - 'for_each_displayid_db' | |
| 175 | 175 | - 'for_each_dma_cap_mask' |
| 176 | 176 | - 'for_each_dpcm_be' |
| 177 | 177 | - 'for_each_dpcm_be_rollback' |
| @@ -179,6 +179,7 @@ ForEachMacros: · 1 unmodified line | ||
| 179 | 179 | - 'for_each_dpcm_fe' |
| 180 | 180 | - 'for_each_drhd_unit' |
| 181 | 181 | - 'for_each_dss_dev' |
| 182 | + - 'for_each_dtpm_table' | |
| 182 | 183 | - 'for_each_efi_memory_desc' |
| 183 | 184 | - 'for_each_efi_memory_desc_in_map' |
| 184 | 185 | - 'for_each_element' |
| @@ -215,6 +216,7 @@ ForEachMacros: · 30 unmodified lines | ||
| 215 | 216 | - 'for_each_migratetype_order' |
| 216 | 217 | - 'for_each_msi_entry' |
| 217 | 218 | - 'for_each_msi_entry_safe' |
| 219 | + - 'for_each_msi_vector' | |
| 218 | 220 | - 'for_each_net' |
| 219 | 221 | - 'for_each_net_continue_reverse' |
| 220 | 222 | - 'for_each_netdev' |
| @@ -270,6 +272,12 @@ ForEachMacros: · 49 unmodified lines | ||
| 270 | 272 | - 'for_each_prime_number_from' |
| 271 | 273 | - 'for_each_process' |
| 272 | 274 | - 'for_each_process_thread' |
| 275 | + - 'for_each_prop_codec_conf' | |
| 276 | + - 'for_each_prop_dai_codec' | |
| 277 | + - 'for_each_prop_dai_cpu' | |
| 278 | + - 'for_each_prop_dlc_codecs' | |
| 279 | + - 'for_each_prop_dlc_cpus' | |
| 280 | + - 'for_each_prop_dlc_platforms' | |
| 273 | 281 | - 'for_each_property_of_node' |
| 274 | 282 | - 'for_each_registered_fb' |
| 275 | 283 | - 'for_each_requested_gpio' |
| @@ -430,6 +438,7 @@ ForEachMacros: · 154 unmodified lines | ||
| 430 | 438 | - 'queue_for_each_hw_ctx' |
| 431 | 439 | - 'radix_tree_for_each_slot' |
| 432 | 440 | - 'radix_tree_for_each_tagged' |
| 441 | + - 'rb_for_each' | |
| 433 | 442 | - 'rbtree_postorder_for_each_entry_safe' |
| 434 | 443 | - 'rdma_for_each_block' |
| 435 | 444 | - 'rdma_for_each_port' |
| @@ -243,6 +243,9 @@ Maxime Ripard <mripard@kernel.org> <maxime.ripard@free-electrons.com> · 242 unmodified lines | ||
| 243 | 243 | Mayuresh Janorkar <mayur@ti.com> |
| 244 | 244 | Michael Buesch <m@bues.ch> |
| 245 | 245 | Michel Dänzer <michel@tungstengraphics.com> |
| 246 | +Michel Lespinasse <michel@lespinasse.org> | |
| 247 | +Michel Lespinasse <michel@lespinasse.org> <walken@google.com> | |
| 248 | +Michel Lespinasse <michel@lespinasse.org> <walken@zoy.org> | |
| 246 | 249 | Miguel Ojeda <ojeda@kernel.org> <miguel.ojeda.sandonis@gmail.com> |
| 247 | 250 | Mike Rapoport <rppt@kernel.org> <mike@compulab.co.il> |
| 248 | 251 | Mike Rapoport <rppt@kernel.org> <mike.rapoport@gmail.com> |
| @@ -149,6 +149,17 @@ properties: · 148 unmodified lines | ||
| 149 | 149 | maxItems: 6 |
| 150 | 150 | $ref: /schemas/types.yaml#/definitions/uint32-array |
| 151 | 151 | |
| 152 | + sink-vdos-v1: | |
| 153 | + description: An array of u32 with each entry, a Vendor Defined Message Object (VDO), | |
| 154 | + providing additional information corresponding to the product, the detailed bit | |
| 155 | + definitions and the order of each VDO can be found in | |
| 156 | + "USB Power Delivery Specification Revision 2.0, Version 1.3" chapter 6.4.4.3.1 Discover | |
| 157 | + Identity. User can specify the VDO array via VDO_IDH/_CERT/_PRODUCT/_CABLE/_AMA defined in | |
| 158 | + dt-bindings/usb/pd.h. | |
| 159 | + minItems: 3 | |
| 160 | + maxItems: 6 | |
| 161 | + $ref: /schemas/types.yaml#/definitions/uint32-array | |
| 162 | + | |
| 152 | 163 | op-sink-microwatt: |
| 153 | 164 | description: Sink required operating power in microwatt, if source can't |
| 154 | 165 | offer the power, Capability Mismatch is set. Required for power sink and |
| @@ -207,6 +218,10 @@ properties: · 52 unmodified lines | ||
| 207 | 218 | SNK_READY for non-pd link. |
| 208 | 219 | type: boolean |
| 209 | 220 | |
| 221 | +dependencies: | |
| 222 | + sink-vdos-v1: [ 'sink-vdos' ] | |
| 223 | + sink-vdos: [ 'sink-vdos-v1' ] | |
| 224 | + | |
| 210 | 225 | required: |
| 211 | 226 | - compatible |
| 212 | 227 | |
| @@ -49,7 +49,7 @@ examples: · 48 unmodified lines | ||
| 49 | 49 | #size-cells = <0>; |
| 50 | 50 | |
| 51 | 51 | adc@48 { |
| 52 | − comatible = "ti,ads7828"; | |
| 52 | + compatible = "ti,ads7828"; | |
| 53 | 53 | reg = <0x48>; |
| 54 | 54 | vref-supply = <&vref>; |
| 55 | 55 | ti,differential-input; |
| @@ -67,9 +67,7 @@ properties: · 66 unmodified lines | ||
| 67 | 67 | maxItems: 1 |
| 68 | 68 | |
| 69 | 69 | clock-names: |
| 70 | − maxItems: 1 | |
| 71 | − items: | |
| 72 | − - const: fck | |
| 70 | + const: fck | |
| 73 | 71 | |
| 74 | 72 | resets: |
| 75 | 73 | maxItems: 1 |
| @@ -57,7 +57,7 @@ patternProperties: · 56 unmodified lines | ||
| 57 | 57 | rate |
| 58 | 58 | |
| 59 | 59 | sound-dai: |
| 60 | − $ref: /schemas/types.yaml#/definitions/phandle | |
| 60 | + $ref: /schemas/types.yaml#/definitions/phandle-array | |
| 61 | 61 | description: phandle of the CPU DAI |
| 62 | 62 | |
| 63 | 63 | patternProperties: |
| @@ -71,7 +71,7 @@ patternProperties: · 7 unmodified lines | ||
| 71 | 71 | |
| 72 | 72 | properties: |
| 73 | 73 | sound-dai: |
| 74 | − $ref: /schemas/types.yaml#/definitions/phandle | |
| 74 | + $ref: /schemas/types.yaml#/definitions/phandle-array | |
| 75 | 75 | description: phandle of the codec DAI |
| 76 | 76 | |
| 77 | 77 | required: |
| @@ -171,8 +171,8 @@ Shadow pages contain the following information: · 170 unmodified lines | ||
| 171 | 171 | shadow pages) so role.quadrant takes values in the range 0..3. Each |
| 172 | 172 | quadrant maps 1GB virtual address space. |
| 173 | 173 | role.access: |
| 174 | − Inherited guest access permissions in the form uwx. Note execute | |
| 175 | − permission is positive, not negative. | |
| 174 | + Inherited guest access permissions from the parent ptes in the form uwx. | |
| 175 | + Note execute permission is positive, not negative. | |
| 176 | 176 | role.invalid: |
| 177 | 177 | The page is invalid and should not be used. It is a root page that is |
| 178 | 178 | currently pinned (by a cpu hardware register pointing to it); once it is |
| @@ -3877,6 +3877,7 @@ L: linux-btrfs@vger.kernel.org · 3876 unmodified lines | ||
| 3877 | 3877 | S: Maintained |
| 3878 | 3878 | W: http://btrfs.wiki.kernel.org/ |
| 3879 | 3879 | Q: http://patchwork.kernel.org/project/linux-btrfs/list/ |
| 3880 | +C: irc://irc.libera.chat/btrfs | |
| 3880 | 3881 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git |
| 3881 | 3882 | F: Documentation/filesystems/btrfs.rst |
| 3882 | 3883 | F: fs/btrfs/ |
| @@ -6945,6 +6946,7 @@ F: net/core/failover.c · 3062 unmodified lines | ||
| 6945 | 6946 | FANOTIFY |
| 6946 | 6947 | M: Jan Kara <jack@suse.cz> |
| 6947 | 6948 | R: Amir Goldstein <amir73il@gmail.com> |
| 6949 | +R: Matthew Bobrowski <repnop@google.com> | |
| 6948 | 6950 | L: linux-fsdevel@vger.kernel.org |
| 6949 | 6951 | S: Maintained |
| 6950 | 6952 | F: fs/notify/fanotify/ |
| @@ -12903,7 +12905,7 @@ F: net/ipv4/nexthop.c · 5952 unmodified lines | ||
| 12903 | 12905 | |
| 12904 | 12906 | NFC SUBSYSTEM |
| 12905 | 12907 | M: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> |
| 12906 | −L: linux-nfc@lists.01.org (moderated for non-subscribers) | |
| 12908 | +L: linux-nfc@lists.01.org (subscribers-only) | |
| 12907 | 12909 | L: netdev@vger.kernel.org |
| 12908 | 12910 | S: Maintained |
| 12909 | 12911 | F: Documentation/devicetree/bindings/net/nfc/ |
| @@ -12916,7 +12918,7 @@ F: net/nfc/ · 6 unmodified lines | ||
| 12916 | 12918 | NFC VIRTUAL NCI DEVICE DRIVER |
| 12917 | 12919 | M: Bongsu Jeon <bongsu.jeon@samsung.com> |
| 12918 | 12920 | L: netdev@vger.kernel.org |
| 12919 | −L: linux-nfc@lists.01.org (moderated for non-subscribers) | |
| 12921 | +L: linux-nfc@lists.01.org (subscribers-only) | |
| 12920 | 12922 | S: Supported |
| 12921 | 12923 | F: drivers/nfc/virtual_ncidev.c |
| 12922 | 12924 | F: tools/testing/selftests/nci/ |
| @@ -13214,7 +13216,7 @@ F: sound/soc/codecs/tfa9879* · 291 unmodified lines | ||
| 13214 | 13216 | |
| 13215 | 13217 | NXP-NCI NFC DRIVER |
| 13216 | 13218 | R: Charles Gorand <charles.gorand@effinnov.com> |
| 13217 | −L: linux-nfc@lists.01.org (moderated for non-subscribers) | |
| 13219 | +L: linux-nfc@lists.01.org (subscribers-only) | |
| 13218 | 13220 | S: Supported |
| 13219 | 13221 | F: drivers/nfc/nxp-nci |
| 13220 | 13222 | |
| @@ -14117,6 +14119,7 @@ F: drivers/pci/controller/pci-v3-semi.c · 896 unmodified lines | ||
| 14117 | 14119 | PCI ENDPOINT SUBSYSTEM |
| 14118 | 14120 | M: Kishon Vijay Abraham I <kishon@ti.com> |
| 14119 | 14121 | M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> |
| 14122 | +R: Krzysztof Wilczyński <kw@linux.com> | |
| 14120 | 14123 | L: linux-pci@vger.kernel.org |
| 14121 | 14124 | S: Supported |
| 14122 | 14125 | F: Documentation/PCI/endpoint/* |
| @@ -14165,6 +14168,7 @@ F: drivers/pci/controller/pci-xgene-msi.c · 42 unmodified lines | ||
| 14165 | 14168 | PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS |
| 14166 | 14169 | M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> |
| 14167 | 14170 | R: Rob Herring <robh@kernel.org> |
| 14171 | +R: Krzysztof Wilczyński <kw@linux.com> | |
| 14168 | 14172 | L: linux-pci@vger.kernel.org |
| 14169 | 14173 | S: Supported |
| 14170 | 14174 | Q: http://patchwork.ozlabs.org/project/linux-pci/list/ |
| @@ -16143,7 +16147,7 @@ F: include/media/drv-intf/s3c_camif.h · 1972 unmodified lines | ||
| 16143 | 16147 | SAMSUNG S3FWRN5 NFC DRIVER |
| 16144 | 16148 | M: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> |
| 16145 | 16149 | M: Krzysztof Opasiak <k.opasiak@samsung.com> |
| 16146 | −L: linux-nfc@lists.01.org (moderated for non-subscribers) | |
| 16150 | +L: linux-nfc@lists.01.org (subscribers-only) | |
| 16147 | 16151 | S: Maintained |
| 16148 | 16152 | F: Documentation/devicetree/bindings/net/nfc/samsung,s3fwrn5.yaml |
| 16149 | 16153 | F: drivers/nfc/s3fwrn5 |
| @@ -18333,7 +18337,7 @@ F: sound/soc/codecs/tas571x* · 2183 unmodified lines | ||
| 18333 | 18337 | TI TRF7970A NFC DRIVER |
| 18334 | 18338 | M: Mark Greer <mgreer@animalcreek.com> |
| 18335 | 18339 | L: linux-wireless@vger.kernel.org |
| 18336 | −L: linux-nfc@lists.01.org (moderated for non-subscribers) | |
| 18340 | +L: linux-nfc@lists.01.org (subscribers-only) | |
| 18337 | 18341 | S: Supported |
| 18338 | 18342 | F: Documentation/devicetree/bindings/net/nfc/trf7970a.txt |
| 18339 | 18343 | F: drivers/nfc/trf7970a.c |
| @@ -18869,6 +18873,13 @@ S: Maintained · 529 unmodified lines | ||
| 18869 | 18873 | F: drivers/usb/host/isp116x* |
| 18870 | 18874 | F: include/linux/usb/isp116x.h |
| 18871 | 18875 | |
| 18876 | +USB ISP1760 DRIVER | |
| 18877 | +M: Rui Miguel Silva <rui.silva@linaro.org> | |
| 18878 | +L: linux-usb@vger.kernel.org | |
| 18879 | +S: Maintained | |
| 18880 | +F: drivers/usb/isp1760/* | |
| 18881 | +F: Documentation/devicetree/bindings/usb/nxp,isp1760.yaml | |
| 18882 | + | |
| 18872 | 18883 | USB LAN78XX ETHERNET DRIVER |
| 18873 | 18884 | M: Woojung Huh <woojung.huh@microchip.com> |
| 18874 | 18885 | M: UNGLinuxDriver@microchip.com |
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | VERSION = 5 |
| 3 | 3 | PATCHLEVEL = 13 |
| 4 | 4 | SUBLEVEL = 0 |
| 5 | −EXTRAVERSION = -rc4 | |
| 5 | +EXTRAVERSION = -rc6 | |
| 6 | 6 | NAME = Frozen Wasteland |
| 7 | 7 | |
| 8 | 8 | # *DOCUMENTATION* |
| @@ -105,9 +105,13 @@ · 104 unmodified lines | ||
| 105 | 105 | phy-reset-gpios = <&gpio1 25 GPIO_ACTIVE_LOW>; |
| 106 | 106 | phy-reset-duration = <20>; |
| 107 | 107 | phy-supply = <&sw2_reg>; |
| 108 | − phy-handle = <ðphy0>; | |
| 109 | 108 | status = "okay"; |
| 110 | 109 | |
| 110 | + fixed-link { | |
| 111 | + speed = <1000>; | |
| 112 | + full-duplex; | |
| 113 | + }; | |
| 114 | + | |
| 111 | 115 | mdio { |
| 112 | 116 | #address-cells = <1>; |
| 113 | 117 | #size-cells = <0>; |
| @@ -406,6 +406,18 @@ · 405 unmodified lines | ||
| 406 | 406 | vin-supply = <&sw1_reg>; |
| 407 | 407 | }; |
| 408 | 408 | |
| 409 | +®_pu { | |
| 410 | + vin-supply = <&sw1_reg>; | |
| 411 | +}; | |
| 412 | + | |
| 413 | +®_vdd1p1 { | |
| 414 | + vin-supply = <&sw2_reg>; | |
| 415 | +}; | |
| 416 | + | |
| 417 | +®_vdd2p5 { | |
| 418 | + vin-supply = <&sw2_reg>; | |
| 419 | +}; | |
| 420 | + | |
| 409 | 421 | &uart1 { |
| 410 | 422 | pinctrl-names = "default"; |
| 411 | 423 | pinctrl-0 = <&pinctrl_uart1>; |
| @@ -126,7 +126,7 @@ · 125 unmodified lines | ||
| 126 | 126 | compatible = "nxp,pca8574"; |
| 127 | 127 | reg = <0x3a>; |
| 128 | 128 | gpio-controller; |
| 129 | − #gpio-cells = <1>; | |
| 129 | + #gpio-cells = <2>; | |
| 130 | 130 | }; |
| 131 | 131 | }; |
| 132 | 132 | |
| @@ -193,7 +193,7 @@ · 192 unmodified lines | ||
| 193 | 193 | pinctrl-names = "default"; |
| 194 | 194 | pinctrl-0 = <&pinctrl_usdhc1>; |
| 195 | 195 | keep-power-in-suspend; |
| 196 | − tuning-step = <2>; | |
| 196 | + fsl,tuning-step = <2>; | |
| 197 | 197 | vmmc-supply = <®_3p3v>; |
| 198 | 198 | no-1-8-v; |
| 199 | 199 | broken-cd; |
| @@ -351,7 +351,7 @@ · 350 unmodified lines | ||
| 351 | 351 | pinctrl-2 = <&pinctrl_usdhc1_200mhz>; |
| 352 | 352 | cd-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>; |
| 353 | 353 | bus-width = <4>; |
| 354 | − tuning-step = <2>; | |
| 354 | + fsl,tuning-step = <2>; | |
| 355 | 355 | vmmc-supply = <®_3p3v>; |
| 356 | 356 | wakeup-source; |
| 357 | 357 | no-1-8-v; |
| @@ -7,9 +7,11 @@ · 6 unmodified lines | ||
| 7 | 7 | #ifdef CONFIG_CPU_IDLE |
| 8 | 8 | extern int arm_cpuidle_simple_enter(struct cpuidle_device *dev, |
| 9 | 9 | struct cpuidle_driver *drv, int index); |
| 10 | +#define __cpuidle_method_section __used __section("__cpuidle_method_of_table") | |
| 10 | 11 | #else |
| 11 | 12 | static inline int arm_cpuidle_simple_enter(struct cpuidle_device *dev, |
| 12 | 13 | struct cpuidle_driver *drv, int index) { return -ENODEV; } |
| 14 | +#define __cpuidle_method_section __maybe_unused /* drop silently */ | |
| 13 | 15 | #endif |
| 14 | 16 | |
| 15 | 17 | /* Common ARM WFI state */ |
| @@ -42,8 +44,7 @@ struct of_cpuidle_method { · 26 unmodified lines | ||
| 42 | 44 | |
| 43 | 45 | #define CPUIDLE_METHOD_OF_DECLARE(name, _method, _ops) \ |
| 44 | 46 | static const struct of_cpuidle_method __cpuidle_method_of_table_##name \ |
| 45 | − __used __section("__cpuidle_method_of_table") \ | |
| 46 | − = { .method = _method, .ops = _ops } | |
| 47 | + __cpuidle_method_section = { .method = _method, .ops = _ops } | |
| 47 | 48 | |
| 48 | 49 | extern int arm_cpuidle_suspend(int index); |
| 49 | 50 | |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <linux/suspend.h> |
| 13 | 13 | #include <linux/io.h> |
| 14 | 14 | |
| 15 | +#include "common.h" | |
| 15 | 16 | #include "hardware.h" |
| 16 | 17 | |
| 17 | 18 | static int mx27_suspend_enter(suspend_state_t state) |
| @@ -458,20 +458,6 @@ static struct gpiod_lookup_table leds_gpio_table = { · 457 unmodified lines | ||
| 458 | 458 | |
| 459 | 459 | #ifdef CONFIG_LEDS_TRIGGERS |
| 460 | 460 | DEFINE_LED_TRIGGER(ams_delta_camera_led_trigger); |
| 461 | − | |
| 462 | −static int ams_delta_camera_power(struct device *dev, int power) | |
| 463 | −{ | |
| 464 | − /* | |
| 465 | − * turn on camera LED | |
| 466 | − */ | |
| 467 | − if (power) | |
| 468 | − led_trigger_event(ams_delta_camera_led_trigger, LED_FULL); | |
| 469 | − else | |
| 470 | − led_trigger_event(ams_delta_camera_led_trigger, LED_OFF); | |
| 471 | − return 0; | |
| 472 | −} | |
| 473 | −#else | |
| 474 | −#define ams_delta_camera_power NULL | |
| 475 | 461 | #endif |
| 476 | 462 | |
| 477 | 463 | static struct platform_device ams_delta_audio_device = { |
| @@ -320,7 +320,7 @@ static int tps_setup(struct i2c_client *client, void *context) · 319 unmodified lines | ||
| 320 | 320 | { |
| 321 | 321 | if (!IS_BUILTIN(CONFIG_TPS65010)) |
| 322 | 322 | return -ENOSYS; |
| 323 | − | |
| 323 | + | |
| 324 | 324 | tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V | |
| 325 | 325 | TPS_LDO1_ENABLE | TPS_VLDO1_3_0V); |
| 326 | 326 | |
| @@ -394,6 +394,8 @@ static void __init h2_init(void) · 67 unmodified lines | ||
| 394 | 394 | BUG_ON(gpio_request(H2_NAND_RB_GPIO_PIN, "NAND ready") < 0); |
| 395 | 395 | gpio_direction_input(H2_NAND_RB_GPIO_PIN); |
| 396 | 396 | |
| 397 | + gpiod_add_lookup_table(&isp1301_gpiod_table); | |
| 398 | + | |
| 397 | 399 | omap_cfg_reg(L3_1610_FLASH_CS2B_OE); |
| 398 | 400 | omap_cfg_reg(M8_1610_FLASH_CS2B_WE); |
| 399 | 401 | |
| @@ -655,9 +655,13 @@ static int __init omap_pm_init(void) · 654 unmodified lines | ||
| 655 | 655 | irq = INT_7XX_WAKE_UP_REQ; |
| 656 | 656 | else if (cpu_is_omap16xx()) |
| 657 | 657 | irq = INT_1610_WAKE_UP_REQ; |
| 658 | − if (request_irq(irq, omap_wakeup_interrupt, 0, "peripheral wakeup", | |
| 659 | − NULL)) | |
| 660 | − pr_err("Failed to request irq %d (peripheral wakeup)\n", irq); | |
| 658 | + else | |
| 659 | + irq = -1; | |
| 660 | + | |
| 661 | + if (irq >= 0) { | |
| 662 | + if (request_irq(irq, omap_wakeup_interrupt, 0, "peripheral wakeup", NULL)) | |
| 663 | + pr_err("Failed to request irq %d (peripheral wakeup)\n", irq); | |
| 664 | + } | |
| 661 | 665 | |
| 662 | 666 | /* Program new power ramp-up time |
| 663 | 667 | * (0 for most boards since we don't lower voltage when in deep sleep) |
| @@ -322,6 +322,7 @@ static int n8x0_mmc_get_cover_state(struct device *dev, int slot) · 321 unmodified lines | ||
| 322 | 322 | |
| 323 | 323 | static void n8x0_mmc_callback(void *data, u8 card_mask) |
| 324 | 324 | { |
| 325 | +#ifdef CONFIG_MMC_OMAP | |
| 325 | 326 | int bit, *openp, index; |
| 326 | 327 | |
| 327 | 328 | if (board_is_n800()) { |
| @@ -339,7 +340,6 @@ static void n8x0_mmc_callback(void *data, u8 card_mask) · 11 unmodified lines | ||
| 339 | 340 | else |
| 340 | 341 | *openp = 0; |
| 341 | 342 | |
| 342 | −#ifdef CONFIG_MMC_OMAP | |
| 343 | 343 | omap_mmc_notify_cover_event(mmc_device, index, *openp); |
| 344 | 344 | #else |
| 345 | 345 | pr_warn("MMC: notify cover event not available\n"); |
| @@ -165,6 +165,7 @@ config ARCH_MEDIATEK · 164 unmodified lines | ||
| 165 | 165 | |
| 166 | 166 | config ARCH_MESON |
| 167 | 167 | bool "Amlogic Platforms" |
| 168 | + select COMMON_CLK | |
| 168 | 169 | select MESON_IRQ_GPIO |
| 169 | 170 | help |
| 170 | 171 | This enables support for the arm64 based Amlogic SoCs |
| @@ -46,7 +46,8 @@ · 45 unmodified lines | ||
| 46 | 46 | eee-broken-100tx; |
| 47 | 47 | qca,clk-out-frequency = <125000000>; |
| 48 | 48 | qca,clk-out-strength = <AR803X_STRENGTH_FULL>; |
| 49 | − vddio-supply = <&vddh>; | |
| 49 | + qca,keep-pll-enabled; | |
| 50 | + vddio-supply = <&vddio>; | |
| 50 | 51 | |
| 51 | 52 | vddio: vddio-regulator { |
| 52 | 53 | regulator-name = "VDDIO"; |
| @@ -31,11 +31,10 @@ · 30 unmodified lines | ||
| 31 | 31 | reg = <0x4>; |
| 32 | 32 | eee-broken-1000t; |
| 33 | 33 | eee-broken-100tx; |
| 34 | − | |
| 35 | 34 | qca,clk-out-frequency = <125000000>; |
| 36 | 35 | qca,clk-out-strength = <AR803X_STRENGTH_FULL>; |
| 37 | − | |
| 38 | − vddio-supply = <&vddh>; | |
| 36 | + qca,keep-pll-enabled; | |
| 37 | + vddio-supply = <&vddio>; | |
| 39 | 38 | |
| 40 | 39 | vddio: vddio-regulator { |
| 41 | 40 | regulator-name = "VDDIO"; |
| @@ -197,8 +197,8 @@ · 196 unmodified lines | ||
| 197 | 197 | ddr: memory-controller@1080000 { |
| 198 | 198 | compatible = "fsl,qoriq-memory-controller"; |
| 199 | 199 | reg = <0x0 0x1080000 0x0 0x1000>; |
| 200 | − interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>; | |
| 201 | − big-endian; | |
| 200 | + interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>; | |
| 201 | + little-endian; | |
| 202 | 202 | }; |
| 203 | 203 | |
| 204 | 204 | dcfg: syscon@1e00000 { |
| @@ -88,11 +88,11 @@ · 87 unmodified lines | ||
| 88 | 88 | pinctrl-0 = <&pinctrl_codec2>; |
| 89 | 89 | reg = <0x18>; |
| 90 | 90 | #sound-dai-cells = <0>; |
| 91 | − HPVDD-supply = <®_3p3v>; | |
| 92 | − SPRVDD-supply = <®_3p3v>; | |
| 93 | − SPLVDD-supply = <®_3p3v>; | |
| 94 | − AVDD-supply = <®_3p3v>; | |
| 95 | − IOVDD-supply = <®_3p3v>; | |
| 91 | + HPVDD-supply = <®_gen_3p3>; | |
| 92 | + SPRVDD-supply = <®_gen_3p3>; | |
| 93 | + SPLVDD-supply = <®_gen_3p3>; | |
| 94 | + AVDD-supply = <®_gen_3p3>; | |
| 95 | + IOVDD-supply = <®_gen_3p3>; | |
| 96 | 96 | DVDD-supply = <&vgen4_reg>; |
| 97 | 97 | reset-gpios = <&gpio3 4 GPIO_ACTIVE_HIGH>; |
| 98 | 98 | }; |
| @@ -45,8 +45,8 @@ · 44 unmodified lines | ||
| 45 | 45 | reg_12p0_main: regulator-12p0-main { |
| 46 | 46 | compatible = "regulator-fixed"; |
| 47 | 47 | regulator-name = "12V_MAIN"; |
| 48 | − regulator-min-microvolt = <5000000>; | |
| 49 | − regulator-max-microvolt = <5000000>; | |
| 48 | + regulator-min-microvolt = <12000000>; | |
| 49 | + regulator-max-microvolt = <12000000>; | |
| 50 | 50 | regulator-always-on; |
| 51 | 51 | }; |
| 52 | 52 | |
| @@ -77,15 +77,6 @@ · 24 unmodified lines | ||
| 77 | 77 | regulator-always-on; |
| 78 | 78 | }; |
| 79 | 79 | |
| 80 | − reg_3p3v: regulator-3p3v { | |
| 81 | − compatible = "regulator-fixed"; | |
| 82 | − vin-supply = <®_3p3_main>; | |
| 83 | − regulator-name = "GEN_3V3"; | |
| 84 | − regulator-min-microvolt = <3300000>; | |
| 85 | − regulator-max-microvolt = <3300000>; | |
| 86 | − regulator-always-on; | |
| 87 | − }; | |
| 88 | − | |
| 89 | 80 | reg_usdhc2_vmmc: regulator-vsd-3v3 { |
| 90 | 81 | pinctrl-names = "default"; |
| 91 | 82 | pinctrl-0 = <&pinctrl_reg_usdhc2>; |
| @@ -415,11 +406,11 @@ · 323 unmodified lines | ||
| 415 | 406 | pinctrl-0 = <&pinctrl_codec1>; |
| 416 | 407 | reg = <0x18>; |
| 417 | 408 | #sound-dai-cells = <0>; |
| 418 | − HPVDD-supply = <®_3p3v>; | |
| 419 | − SPRVDD-supply = <®_3p3v>; | |
| 420 | − SPLVDD-supply = <®_3p3v>; | |
| 421 | − AVDD-supply = <®_3p3v>; | |
| 422 | − IOVDD-supply = <®_3p3v>; | |
| 409 | + HPVDD-supply = <®_gen_3p3>; | |
| 410 | + SPRVDD-supply = <®_gen_3p3>; | |
| 411 | + SPLVDD-supply = <®_gen_3p3>; | |
| 412 | + AVDD-supply = <®_gen_3p3>; | |
| 413 | + IOVDD-supply = <®_gen_3p3>; | |
| 423 | 414 | DVDD-supply = <&vgen4_reg>; |
| 424 | 415 | reset-gpios = <&gpio3 3 GPIO_ACTIVE_LOW>; |
| 425 | 416 | }; |
| @@ -42,12 +42,12 @@ · 41 unmodified lines | ||
| 42 | 42 | }; |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | − dmss: dmss { | |
| 45 | + dmss: bus@48000000 { | |
| 46 | 46 | compatible = "simple-mfd"; |
| 47 | 47 | #address-cells = <2>; |
| 48 | 48 | #size-cells = <2>; |
| 49 | 49 | dma-ranges; |
| 50 | − ranges; | |
| 50 | + ranges = <0x00 0x48000000 0x00 0x48000000 0x00 0x06400000>; | |
| 51 | 51 | |
| 52 | 52 | ti,sci-dev-id = <25>; |
| 53 | 53 | |
| @@ -134,7 +134,7 @@ · 80 unmodified lines | ||
| 134 | 134 | }; |
| 135 | 135 | }; |
| 136 | 136 | |
| 137 | − dmsc: dmsc@44043000 { | |
| 137 | + dmsc: system-controller@44043000 { | |
| 138 | 138 | compatible = "ti,k2g-sci"; |
| 139 | 139 | ti,host-id = <12>; |
| 140 | 140 | mbox-names = "rx", "tx"; |
| @@ -148,7 +148,7 @@ · 7 unmodified lines | ||
| 148 | 148 | #power-domain-cells = <2>; |
| 149 | 149 | }; |
| 150 | 150 | |
| 151 | − k3_clks: clocks { | |
| 151 | + k3_clks: clock-controller { | |
| 152 | 152 | compatible = "ti,k2g-sci-clk"; |
| 153 | 153 | #clock-cells = <2>; |
| 154 | 154 | }; |
| @@ -373,8 +373,9 @@ · 218 unmodified lines | ||
| 373 | 373 | clocks = <&k3_clks 145 0>; |
| 374 | 374 | }; |
| 375 | 375 | |
| 376 | − main_gpio_intr: interrupt-controller0 { | |
| 376 | + main_gpio_intr: interrupt-controller@a00000 { | |
| 377 | 377 | compatible = "ti,sci-intr"; |
| 378 | + reg = <0x00 0x00a00000 0x00 0x800>; | |
| 378 | 379 | ti,intr-trigger-type = <1>; |
| 379 | 380 | interrupt-controller; |
| 380 | 381 | interrupt-parent = <&gic500>; |
| @@ -74,8 +74,9 @@ · 73 unmodified lines | ||
| 74 | 74 | clocks = <&k3_clks 148 0>; |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | − mcu_gpio_intr: interrupt-controller1 { | |
| 77 | + mcu_gpio_intr: interrupt-controller@4210000 { | |
| 78 | 78 | compatible = "ti,sci-intr"; |
| 79 | + reg = <0x00 0x04210000 0x00 0x200>; | |
| 79 | 80 | ti,intr-trigger-type = <1>; |
| 80 | 81 | interrupt-controller; |
| 81 | 82 | interrupt-parent = <&gic500>; |
| @@ -433,8 +433,9 @@ · 432 unmodified lines | ||
| 433 | 433 | #phy-cells = <0>; |
| 434 | 434 | }; |
| 435 | 435 | |
| 436 | − intr_main_gpio: interrupt-controller0 { | |
| 436 | + intr_main_gpio: interrupt-controller@a00000 { | |
| 437 | 437 | compatible = "ti,sci-intr"; |
| 438 | + reg = <0x0 0x00a00000 0x0 0x400>; | |
| 438 | 439 | ti,intr-trigger-type = <1>; |
| 439 | 440 | interrupt-controller; |
| 440 | 441 | interrupt-parent = <&gic500>; |
| @@ -444,18 +445,19 @@ · 3 unmodified lines | ||
| 444 | 445 | ti,interrupt-ranges = <0 392 32>; |
| 445 | 446 | }; |
| 446 | 447 | |
| 447 | − main-navss { | |
| 448 | + main_navss: bus@30800000 { | |
| 448 | 449 | compatible = "simple-mfd"; |
| 449 | 450 | #address-cells = <2>; |
| 450 | 451 | #size-cells = <2>; |
| 451 | − ranges; | |
| 452 | + ranges = <0x0 0x30800000 0x0 0x30800000 0x0 0xbc00000>; | |
| 452 | 453 | dma-coherent; |
| 453 | 454 | dma-ranges; |
| 454 | 455 | |
| 455 | 456 | ti,sci-dev-id = <118>; |
| 456 | 457 | |
| 457 | − intr_main_navss: interrupt-controller1 { | |
| 458 | + intr_main_navss: interrupt-controller@310e0000 { | |
| 458 | 459 | compatible = "ti,sci-intr"; |
| 460 | + reg = <0x0 0x310e0000 0x0 0x2000>; | |
| 459 | 461 | ti,intr-trigger-type = <4>; |
| 460 | 462 | interrupt-controller; |
| 461 | 463 | interrupt-parent = <&gic500>; |
| @@ -116,11 +116,11 @@ · 115 unmodified lines | ||
| 116 | 116 | }; |
| 117 | 117 | }; |
| 118 | 118 | |
| 119 | − mcu-navss { | |
| 119 | + mcu_navss: bus@28380000 { | |
| 120 | 120 | compatible = "simple-mfd"; |
| 121 | 121 | #address-cells = <2>; |
| 122 | 122 | #size-cells = <2>; |
| 123 | − ranges; | |
| 123 | + ranges = <0x00 0x28380000 0x00 0x28380000 0x00 0x03880000>; | |
| 124 | 124 | dma-coherent; |
| 125 | 125 | dma-ranges; |
| 126 | 126 | |
| @@ -6,24 +6,24 @@ · 5 unmodified lines | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | &cbass_wakeup { |
| 9 | − dmsc: dmsc { | |
| 9 | + dmsc: system-controller@44083000 { | |
| 10 | 10 | compatible = "ti,am654-sci"; |
| 11 | 11 | ti,host-id = <12>; |
| 12 | − #address-cells = <1>; | |
| 13 | − #size-cells = <1>; | |
| 14 | − ranges; | |
| 15 | 12 | |
| 16 | 13 | mbox-names = "rx", "tx"; |
| 17 | 14 | |
| 18 | 15 | mboxes= <&secure_proxy_main 11>, |
| 19 | 16 | <&secure_proxy_main 13>; |
| 20 | 17 | |
| 18 | + reg-names = "debug_messages"; | |
| 19 | + reg = <0x44083000 0x1000>; | |
| 20 | + | |
| 21 | 21 | k3_pds: power-controller { |
| 22 | 22 | compatible = "ti,sci-pm-domain"; |
| 23 | 23 | #power-domain-cells = <2>; |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | − k3_clks: clocks { | |
| 26 | + k3_clks: clock-controller { | |
| 27 | 27 | compatible = "ti,k2g-sci-clk"; |
| 28 | 28 | #clock-cells = <2>; |
| 29 | 29 | }; |
| @@ -69,8 +69,9 @@ · 39 unmodified lines | ||
| 69 | 69 | power-domains = <&k3_pds 115 TI_SCI_PD_EXCLUSIVE>; |
| 70 | 70 | }; |
| 71 | 71 | |
| 72 | − intr_wkup_gpio: interrupt-controller2 { | |
| 72 | + intr_wkup_gpio: interrupt-controller@42200000 { | |
| 73 | 73 | compatible = "ti,sci-intr"; |
| 74 | + reg = <0x42200000 0x200>; | |
| 74 | 75 | ti,intr-trigger-type = <1>; |
| 75 | 76 | interrupt-controller; |
| 76 | 77 | interrupt-parent = <&gic500>; |
| @@ -85,12 +85,6 @@ · 84 unmodified lines | ||
| 85 | 85 | gpios = <&wkup_gpio0 27 GPIO_ACTIVE_LOW>; |
| 86 | 86 | }; |
| 87 | 87 | }; |
| 88 | − | |
| 89 | − clk_ov5640_fixed: clock { | |
| 90 | − compatible = "fixed-clock"; | |
| 91 | − #clock-cells = <0>; | |
| 92 | − clock-frequency = <24000000>; | |
| 93 | − }; | |
| 94 | 88 | }; |
| 95 | 89 | |
| 96 | 90 | &wkup_pmx0 { |
| @@ -287,23 +281,6 @@ · 190 unmodified lines | ||
| 287 | 281 | pinctrl-names = "default"; |
| 288 | 282 | pinctrl-0 = <&main_i2c1_pins_default>; |
| 289 | 283 | clock-frequency = <400000>; |
| 290 | − | |
| 291 | − ov5640: camera@3c { | |
| 292 | − compatible = "ovti,ov5640"; | |
| 293 | − reg = <0x3c>; | |
| 294 | − | |
| 295 | − clocks = <&clk_ov5640_fixed>; | |
| 296 | − clock-names = "xclk"; | |
| 297 | − | |
| 298 | − port { | |
| 299 | − csi2_cam0: endpoint { | |
| 300 | − remote-endpoint = <&csi2_phy0>; | |
| 301 | − clock-lanes = <0>; | |
| 302 | − data-lanes = <1 2>; | |
| 303 | − }; | |
| 304 | − }; | |
| 305 | − }; | |
| 306 | − | |
| 307 | 284 | }; |
| 308 | 285 | |
| 309 | 286 | &main_i2c2 { |
| @@ -496,14 +473,6 @@ · 186 unmodified lines | ||
| 496 | 473 | }; |
| 497 | 474 | }; |
| 498 | 475 | |
| 499 | −&csi2_0 { | |
| 500 | − csi2_phy0: endpoint { | |
| 501 | − remote-endpoint = <&csi2_cam0>; | |
| 502 | − clock-lanes = <0>; | |
| 503 | − data-lanes = <1 2>; | |
| 504 | − }; | |
| 505 | −}; | |
| 506 | − | |
| 507 | 476 | &mcu_cpsw { |
| 508 | 477 | pinctrl-names = "default"; |
| 509 | 478 | pinctrl-0 = <&mcu_cpsw_pins_default &mcu_mdio_pins_default>; |
| @@ -68,8 +68,9 @@ · 67 unmodified lines | ||
| 68 | 68 | }; |
| 69 | 69 | }; |
| 70 | 70 | |
| 71 | − main_gpio_intr: interrupt-controller0 { | |
| 71 | + main_gpio_intr: interrupt-controller@a00000 { | |
| 72 | 72 | compatible = "ti,sci-intr"; |
| 73 | + reg = <0x00 0x00a00000 0x00 0x800>; | |
| 73 | 74 | ti,intr-trigger-type = <1>; |
| 74 | 75 | interrupt-controller; |
| 75 | 76 | interrupt-parent = <&gic500>; |
| @@ -85,9 +86,12 @@ · 9 unmodified lines | ||
| 85 | 86 | #size-cells = <2>; |
| 86 | 87 | ranges = <0x00 0x30000000 0x00 0x30000000 0x00 0x0c400000>; |
| 87 | 88 | ti,sci-dev-id = <199>; |
| 89 | + dma-coherent; | |
| 90 | + dma-ranges; | |
| 88 | 91 | |
| 89 | − main_navss_intr: interrupt-controller1 { | |
| 92 | + main_navss_intr: interrupt-controller@310e0000 { | |
| 90 | 93 | compatible = "ti,sci-intr"; |
| 94 | + reg = <0x00 0x310e0000 0x00 0x4000>; | |
| 91 | 95 | ti,intr-trigger-type = <4>; |
| 92 | 96 | interrupt-controller; |
| 93 | 97 | interrupt-parent = <&gic500>; |
| @@ -6,7 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | &cbass_mcu_wakeup { |
| 9 | − dmsc: dmsc@44083000 { | |
| 9 | + dmsc: system-controller@44083000 { | |
| 10 | 10 | compatible = "ti,k2g-sci"; |
| 11 | 11 | ti,host-id = <12>; |
| 12 | 12 | |
| @@ -23,7 +23,7 @@ · 10 unmodified lines | ||
| 23 | 23 | #power-domain-cells = <2>; |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | − k3_clks: clocks { | |
| 26 | + k3_clks: clock-controller { | |
| 27 | 27 | compatible = "ti,k2g-sci-clk"; |
| 28 | 28 | #clock-cells = <2>; |
| 29 | 29 | }; |
| @@ -96,8 +96,9 @@ · 66 unmodified lines | ||
| 96 | 96 | clock-names = "fclk"; |
| 97 | 97 | }; |
| 98 | 98 | |
| 99 | − wkup_gpio_intr: interrupt-controller2 { | |
| 99 | + wkup_gpio_intr: interrupt-controller@42200000 { | |
| 100 | 100 | compatible = "ti,sci-intr"; |
| 101 | + reg = <0x00 0x42200000 0x00 0x400>; | |
| 101 | 102 | ti,intr-trigger-type = <1>; |
| 102 | 103 | interrupt-controller; |
| 103 | 104 | interrupt-parent = <&gic500>; |
| @@ -76,8 +76,9 @@ · 75 unmodified lines | ||
| 76 | 76 | }; |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | − main_gpio_intr: interrupt-controller0 { | |
| 79 | + main_gpio_intr: interrupt-controller@a00000 { | |
| 80 | 80 | compatible = "ti,sci-intr"; |
| 81 | + reg = <0x00 0x00a00000 0x00 0x800>; | |
| 81 | 82 | ti,intr-trigger-type = <1>; |
| 82 | 83 | interrupt-controller; |
| 83 | 84 | interrupt-parent = <&gic500>; |
| @@ -87,18 +88,19 @@ · 3 unmodified lines | ||
| 87 | 88 | ti,interrupt-ranges = <8 392 56>; |
| 88 | 89 | }; |
| 89 | 90 | |
| 90 | − main-navss { | |
| 91 | + main_navss: bus@30000000 { | |
| 91 | 92 | compatible = "simple-mfd"; |
| 92 | 93 | #address-cells = <2>; |
| 93 | 94 | #size-cells = <2>; |
| 94 | − ranges; | |
| 95 | + ranges = <0x00 0x30000000 0x00 0x30000000 0x00 0x0c400000>; | |
| 95 | 96 | dma-coherent; |
| 96 | 97 | dma-ranges; |
| 97 | 98 | |
| 98 | 99 | ti,sci-dev-id = <199>; |
| 99 | 100 | |
| 100 | − main_navss_intr: interrupt-controller1 { | |
| 101 | + main_navss_intr: interrupt-controller@310e0000 { | |
| 101 | 102 | compatible = "ti,sci-intr"; |
| 103 | + reg = <0x0 0x310e0000 0x0 0x4000>; | |
| 102 | 104 | ti,intr-trigger-type = <4>; |
| 103 | 105 | interrupt-controller; |
| 104 | 106 | interrupt-parent = <&gic500>; |
| @@ -6,7 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | &cbass_mcu_wakeup { |
| 9 | − dmsc: dmsc@44083000 { | |
| 9 | + dmsc: system-controller@44083000 { | |
| 10 | 10 | compatible = "ti,k2g-sci"; |
| 11 | 11 | ti,host-id = <12>; |
| 12 | 12 | |
| @@ -23,7 +23,7 @@ · 10 unmodified lines | ||
| 23 | 23 | #power-domain-cells = <2>; |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | − k3_clks: clocks { | |
| 26 | + k3_clks: clock-controller { | |
| 27 | 27 | compatible = "ti,k2g-sci-clk"; |
| 28 | 28 | #clock-cells = <2>; |
| 29 | 29 | }; |
| @@ -96,8 +96,9 @@ · 66 unmodified lines | ||
| 96 | 96 | clock-names = "fclk"; |
| 97 | 97 | }; |
| 98 | 98 | |
| 99 | − wkup_gpio_intr: interrupt-controller2 { | |
| 99 | + wkup_gpio_intr: interrupt-controller@42200000 { | |
| 100 | 100 | compatible = "ti,sci-intr"; |
| 101 | + reg = <0x00 0x42200000 0x00 0x400>; | |
| 101 | 102 | ti,intr-trigger-type = <1>; |
| 102 | 103 | interrupt-controller; |
| 103 | 104 | interrupt-parent = <&gic500>; |
| @@ -249,11 +250,11 @@ · 145 unmodified lines | ||
| 249 | 250 | }; |
| 250 | 251 | }; |
| 251 | 252 | |
| 252 | − mcu-navss { | |
| 253 | + mcu_navss: bus@28380000 { | |
| 253 | 254 | compatible = "simple-mfd"; |
| 254 | 255 | #address-cells = <2>; |
| 255 | 256 | #size-cells = <2>; |
| 256 | − ranges; | |
| 257 | + ranges = <0x00 0x28380000 0x00 0x28380000 0x00 0x03880000>; | |
| 257 | 258 | dma-coherent; |
| 258 | 259 | dma-ranges; |
| 259 | 260 | |
| @@ -158,31 +158,29 @@ unsigned long _page_cachable_default; · 157 unmodified lines | ||
| 158 | 158 | EXPORT_SYMBOL(_page_cachable_default); |
| 159 | 159 | |
| 160 | 160 | #define PM(p) __pgprot(_page_cachable_default | (p)) |
| 161 | −#define PVA(p) PM(_PAGE_VALID | _PAGE_ACCESSED | (p)) | |
| 162 | 161 | |
| 163 | 162 | static inline void setup_protection_map(void) |
| 164 | 163 | { |
| 165 | 164 | protection_map[0] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); |
| 166 | − protection_map[1] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC); | |
| 167 | − protection_map[2] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); | |
| 168 | − protection_map[3] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC); | |
| 169 | − protection_map[4] = PVA(_PAGE_PRESENT); | |
| 170 | − protection_map[5] = PVA(_PAGE_PRESENT); | |
| 171 | − protection_map[6] = PVA(_PAGE_PRESENT); | |
| 172 | − protection_map[7] = PVA(_PAGE_PRESENT); | |
| 165 | + protection_map[1] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC); | |
| 166 | + protection_map[2] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); | |
| 167 | + protection_map[3] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC); | |
| 168 | + protection_map[4] = PM(_PAGE_PRESENT); | |
| 169 | + protection_map[5] = PM(_PAGE_PRESENT); | |
| 170 | + protection_map[6] = PM(_PAGE_PRESENT); | |
| 171 | + protection_map[7] = PM(_PAGE_PRESENT); | |
| 173 | 172 | |
| 174 | 173 | protection_map[8] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); |
| 175 | − protection_map[9] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC); | |
| 176 | − protection_map[10] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | | |
| 174 | + protection_map[9] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC); | |
| 175 | + protection_map[10] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | | |
| 177 | 176 | _PAGE_NO_READ); |
| 178 | − protection_map[11] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE); | |
| 179 | − protection_map[12] = PVA(_PAGE_PRESENT); | |
| 180 | − protection_map[13] = PVA(_PAGE_PRESENT); | |
| 181 | − protection_map[14] = PVA(_PAGE_PRESENT); | |
| 182 | − protection_map[15] = PVA(_PAGE_PRESENT); | |
| 177 | + protection_map[11] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE); | |
| 178 | + protection_map[12] = PM(_PAGE_PRESENT); | |
| 179 | + protection_map[13] = PM(_PAGE_PRESENT); | |
| 180 | + protection_map[14] = PM(_PAGE_PRESENT | _PAGE_WRITE); | |
| 181 | + protection_map[15] = PM(_PAGE_PRESENT | _PAGE_WRITE); | |
| 183 | 182 | } |
| 184 | 183 | |
| 185 | −#undef _PVA | |
| 186 | 184 | #undef PM |
| 187 | 185 | |
| 188 | 186 | void cpu_cache_init(void) |
| @@ -31,6 +31,35 @@ static inline pte_t *find_init_mm_pte(unsigned long ea, unsigned *hshift) · 30 unmodified lines | ||
| 31 | 31 | pgd_t *pgdir = init_mm.pgd; |
| 32 | 32 | return __find_linux_pte(pgdir, ea, NULL, hshift); |
| 33 | 33 | } |
| 34 | + | |
| 35 | +/* | |
| 36 | + * Convert a kernel vmap virtual address (vmalloc or ioremap space) to a | |
| 37 | + * physical address, without taking locks. This can be used in real-mode. | |
| 38 | + */ | |
| 39 | +static inline phys_addr_t ppc_find_vmap_phys(unsigned long addr) | |
| 40 | +{ | |
| 41 | + pte_t *ptep; | |
| 42 | + phys_addr_t pa; | |
| 43 | + int hugepage_shift; | |
| 44 | + | |
| 45 | + /* | |
| 46 | + * init_mm does not free page tables, and does not do THP. It may | |
| 47 | + * have huge pages from huge vmalloc / ioremap etc. | |
| 48 | + */ | |
| 49 | + ptep = find_init_mm_pte(addr, &hugepage_shift); | |
| 50 | + if (WARN_ON(!ptep)) | |
| 51 | + return 0; | |
| 52 | + | |
| 53 | + pa = PFN_PHYS(pte_pfn(*ptep)); | |
| 54 | + | |
| 55 | + if (!hugepage_shift) | |
| 56 | + hugepage_shift = PAGE_SHIFT; | |
| 57 | + | |
| 58 | + pa |= addr & ((1ul << hugepage_shift) - 1); | |
| 59 | + | |
| 60 | + return pa; | |
| 61 | +} | |
| 62 | + | |
| 34 | 63 | /* |
| 35 | 64 | * This is what we should always use. Any other lockless page table lookup needs |
| 36 | 65 | * careful audit against THP split. |
| @@ -346,28 +346,7 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity) · 345 unmodified lines | ||
| 346 | 346 | */ |
| 347 | 347 | static inline unsigned long eeh_token_to_phys(unsigned long token) |
| 348 | 348 | { |
| 349 | − pte_t *ptep; | |
| 350 | − unsigned long pa; | |
| 351 | − int hugepage_shift; | |
| 352 | − | |
| 353 | − /* | |
| 354 | − * We won't find hugepages here(this is iomem). Hence we are not | |
| 355 | − * worried about _PAGE_SPLITTING/collapse. Also we will not hit | |
| 356 | − * page table free, because of init_mm. | |
| 357 | − */ | |
| 358 | − ptep = find_init_mm_pte(token, &hugepage_shift); | |
| 359 | − if (!ptep) | |
| 360 | − return token; | |
| 361 | − | |
| 362 | − pa = pte_pfn(*ptep); | |
| 363 | − | |
| 364 | − /* On radix we can do hugepage mappings for io, so handle that */ | |
| 365 | − if (!hugepage_shift) | |
| 366 | − hugepage_shift = PAGE_SHIFT; | |
| 367 | − | |
| 368 | − pa <<= PAGE_SHIFT; | |
| 369 | − pa |= token & ((1ul << hugepage_shift) - 1); | |
| 370 | − return pa; | |
| 349 | + return ppc_find_vmap_phys(token); | |
| 371 | 350 | } |
| 372 | 351 | |
| 373 | 352 | /* |
| @@ -55,7 +55,6 @@ static struct iowa_bus *iowa_pci_find(unsigned long vaddr, unsigned long paddr) · 54 unmodified lines | ||
| 55 | 55 | #ifdef CONFIG_PPC_INDIRECT_MMIO |
| 56 | 56 | struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr) |
| 57 | 57 | { |
| 58 | − unsigned hugepage_shift; | |
| 59 | 58 | struct iowa_bus *bus; |
| 60 | 59 | int token; |
| 61 | 60 | |
| @@ -65,22 +64,13 @@ struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr) · 3 unmodified lines | ||
| 65 | 64 | bus = &iowa_busses[token - 1]; |
| 66 | 65 | else { |
| 67 | 66 | unsigned long vaddr, paddr; |
| 68 | − pte_t *ptep; | |
| 69 | 67 | |
| 70 | 68 | vaddr = (unsigned long)PCI_FIX_ADDR(addr); |
| 71 | 69 | if (vaddr < PHB_IO_BASE || vaddr >= PHB_IO_END) |
| 72 | 70 | return NULL; |
| 73 | − /* | |
| 74 | − * We won't find huge pages here (iomem). Also can't hit | |
| 75 | − * a page table free due to init_mm | |
| 76 | − */ | |
| 77 | − ptep = find_init_mm_pte(vaddr, &hugepage_shift); | |
| 78 | − if (ptep == NULL) | |
| 79 | − paddr = 0; | |
| 80 | − else { | |
| 81 | − WARN_ON(hugepage_shift); | |
| 82 | − paddr = pte_pfn(*ptep) << PAGE_SHIFT; | |
| 83 | − } | |
| 71 | + | |
| 72 | + paddr = ppc_find_vmap_phys(vaddr); | |
| 73 | + | |
| 84 | 74 | bus = iowa_pci_find(vaddr, paddr); |
| 85 | 75 | |
| 86 | 76 | if (bus == NULL) |
| @@ -898,7 +898,6 @@ void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl, · 897 unmodified lines | ||
| 898 | 898 | unsigned int order; |
| 899 | 899 | unsigned int nio_pages, io_order; |
| 900 | 900 | struct page *page; |
| 901 | − size_t size_io = size; | |
| 902 | 901 | |
| 903 | 902 | size = PAGE_ALIGN(size); |
| 904 | 903 | order = get_order(size); |
| @@ -925,9 +924,8 @@ void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl, · 20 unmodified lines | ||
| 925 | 924 | memset(ret, 0, size); |
| 926 | 925 | |
| 927 | 926 | /* Set up tces to cover the allocated range */ |
| 928 | − size_io = IOMMU_PAGE_ALIGN(size_io, tbl); | |
| 929 | − nio_pages = size_io >> tbl->it_page_shift; | |
| 930 | − io_order = get_iommu_order(size_io, tbl); | |
| 927 | + nio_pages = size >> tbl->it_page_shift; | |
| 928 | + io_order = get_iommu_order(size, tbl); | |
| 931 | 929 | mapping = iommu_alloc(dev, tbl, ret, nio_pages, DMA_BIDIRECTIONAL, |
| 932 | 930 | mask >> tbl->it_page_shift, io_order, 0); |
| 933 | 931 | if (mapping == DMA_MAPPING_ERROR) { |
| @@ -942,9 +940,10 @@ void iommu_free_coherent(struct iommu_table *tbl, size_t size, · 8 unmodified lines | ||
| 942 | 940 | void *vaddr, dma_addr_t dma_handle) |
| 943 | 941 | { |
| 944 | 942 | if (tbl) { |
| 945 | − size_t size_io = IOMMU_PAGE_ALIGN(size, tbl); | |
| 946 | − unsigned int nio_pages = size_io >> tbl->it_page_shift; | |
| 943 | + unsigned int nio_pages; | |
| 947 | 944 | |
| 945 | + size = PAGE_ALIGN(size); | |
| 946 | + nio_pages = size >> tbl->it_page_shift; | |
| 948 | 947 | iommu_free(tbl, dma_handle, nio_pages); |
| 949 | 948 | size = PAGE_ALIGN(size); |
| 950 | 949 | free_pages((unsigned long)vaddr, get_order(size)); |
| @@ -108,7 +108,6 @@ int arch_prepare_kprobe(struct kprobe *p) · 107 unmodified lines | ||
| 108 | 108 | int ret = 0; |
| 109 | 109 | struct kprobe *prev; |
| 110 | 110 | struct ppc_inst insn = ppc_inst_read((struct ppc_inst *)p->addr); |
| 111 | − struct ppc_inst prefix = ppc_inst_read((struct ppc_inst *)(p->addr - 1)); | |
| 112 | 111 | |
| 113 | 112 | if ((unsigned long)p->addr & 0x03) { |
| 114 | 113 | printk("Attempt to register kprobe at an unaligned address\n"); |
| @@ -116,7 +115,8 @@ int arch_prepare_kprobe(struct kprobe *p) · 1 unmodified line | ||
| 116 | 115 | } else if (IS_MTMSRD(insn) || IS_RFID(insn) || IS_RFI(insn)) { |
| 117 | 116 | printk("Cannot register a kprobe on rfi/rfid or mtmsr[d]\n"); |
| 118 | 117 | ret = -EINVAL; |
| 119 | − } else if (ppc_inst_prefixed(prefix)) { | |
| 118 | + } else if ((unsigned long)p->addr & ~PAGE_MASK && | |
| 119 | + ppc_inst_prefixed(ppc_inst_read((struct ppc_inst *)(p->addr - 1)))) { | |
| 120 | 120 | printk("Cannot register a kprobe on the second word of prefixed instruction\n"); |
| 121 | 121 | ret = -EINVAL; |
| 122 | 122 | } |
| @@ -4455,7 +4455,6 @@ static int kvmppc_vcpu_run_hv(struct kvm_vcpu *vcpu) · 4454 unmodified lines | ||
| 4455 | 4455 | mtspr(SPRN_EBBRR, ebb_regs[1]); |
| 4456 | 4456 | mtspr(SPRN_BESCR, ebb_regs[2]); |
| 4457 | 4457 | mtspr(SPRN_TAR, user_tar); |
| 4458 | − mtspr(SPRN_FSCR, current->thread.fscr); | |
| 4459 | 4458 | } |
| 4460 | 4459 | mtspr(SPRN_VRSAVE, user_vrsave); |
| 4461 | 4460 | |
| @@ -23,20 +23,9 @@ · 22 unmodified lines | ||
| 23 | 23 | #include <asm/pte-walk.h> |
| 24 | 24 | |
| 25 | 25 | /* Translate address of a vmalloc'd thing to a linear map address */ |
| 26 | −static void *real_vmalloc_addr(void *x) | |
| 26 | +static void *real_vmalloc_addr(void *addr) | |
| 27 | 27 | { |
| 28 | − unsigned long addr = (unsigned long) x; | |
| 29 | − pte_t *p; | |
| 30 | − /* | |
| 31 | − * assume we don't have huge pages in vmalloc space... | |
| 32 | − * So don't worry about THP collapse/split. Called | |
| 33 | − * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore. | |
| 34 | − */ | |
| 35 | − p = find_init_mm_pte(addr, NULL); | |
| 36 | − if (!p || !pte_present(*p)) | |
| 37 | − return NULL; | |
| 38 | − addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK); | |
| 39 | − return __va(addr); | |
| 28 | + return __va(ppc_find_vmap_phys((unsigned long)addr)); | |
| 40 | 29 | } |
| 41 | 30 | |
| 42 | 31 | /* Return 1 if we need to do a global tlbie, 0 if we can use tlbiel */ |
| @@ -59,6 +59,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300) · 58 unmodified lines | ||
| 59 | 59 | #define STACK_SLOT_UAMOR (SFS-88) |
| 60 | 60 | #define STACK_SLOT_DAWR1 (SFS-96) |
| 61 | 61 | #define STACK_SLOT_DAWRX1 (SFS-104) |
| 62 | +#define STACK_SLOT_FSCR (SFS-112) | |
| 62 | 63 | /* the following is used by the P9 short path */ |
| 63 | 64 | #define STACK_SLOT_NVGPRS (SFS-152) /* 18 gprs */ |
| 64 | 65 | |
| @@ -686,6 +687,8 @@ BEGIN_FTR_SECTION · 621 unmodified lines | ||
| 686 | 687 | std r6, STACK_SLOT_DAWR0(r1) |
| 687 | 688 | std r7, STACK_SLOT_DAWRX0(r1) |
| 688 | 689 | std r8, STACK_SLOT_IAMR(r1) |
| 690 | + mfspr r5, SPRN_FSCR | |
| 691 | + std r5, STACK_SLOT_FSCR(r1) | |
| 689 | 692 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) |
| 690 | 693 | BEGIN_FTR_SECTION |
| 691 | 694 | mfspr r6, SPRN_DAWR1 |
| @@ -1663,6 +1666,10 @@ FTR_SECTION_ELSE · 971 unmodified lines | ||
| 1663 | 1666 | ld r7, STACK_SLOT_HFSCR(r1) |
| 1664 | 1667 | mtspr SPRN_HFSCR, r7 |
| 1665 | 1668 | ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_300) |
| 1669 | +BEGIN_FTR_SECTION | |
| 1670 | + ld r5, STACK_SLOT_FSCR(r1) | |
| 1671 | + mtspr SPRN_FSCR, r5 | |
| 1672 | +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |
| 1666 | 1673 | /* |
| 1667 | 1674 | * Restore various registers to 0, where non-zero values |
| 1668 | 1675 | * set by the guest could disrupt the host. |
| @@ -61,11 +61,11 @@ config RISCV · 60 unmodified lines | ||
| 61 | 61 | select GENERIC_TIME_VSYSCALL if MMU && 64BIT |
| 62 | 62 | select HANDLE_DOMAIN_IRQ |
| 63 | 63 | select HAVE_ARCH_AUDITSYSCALL |
| 64 | − select HAVE_ARCH_JUMP_LABEL | |
| 65 | − select HAVE_ARCH_JUMP_LABEL_RELATIVE | |
| 64 | + select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL | |
| 65 | + select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL | |
| 66 | 66 | select HAVE_ARCH_KASAN if MMU && 64BIT |
| 67 | 67 | select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT |
| 68 | − select HAVE_ARCH_KGDB | |
| 68 | + select HAVE_ARCH_KGDB if !XIP_KERNEL | |
| 69 | 69 | select HAVE_ARCH_KGDB_QXFER_PKT |
| 70 | 70 | select HAVE_ARCH_MMAP_RND_BITS if MMU |
| 71 | 71 | select HAVE_ARCH_SECCOMP_FILTER |
| @@ -80,9 +80,9 @@ config RISCV · 8 unmodified lines | ||
| 80 | 80 | select HAVE_GCC_PLUGINS |
| 81 | 81 | select HAVE_GENERIC_VDSO if MMU && 64BIT |
| 82 | 82 | select HAVE_IRQ_TIME_ACCOUNTING |
| 83 | − select HAVE_KPROBES | |
| 84 | − select HAVE_KPROBES_ON_FTRACE | |
| 85 | − select HAVE_KRETPROBES | |
| 83 | + select HAVE_KPROBES if !XIP_KERNEL | |
| 84 | + select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL | |
| 85 | + select HAVE_KRETPROBES if !XIP_KERNEL | |
| 86 | 86 | select HAVE_PCI |
| 87 | 87 | select HAVE_PERF_EVENTS |
| 88 | 88 | select HAVE_PERF_REGS |
| @@ -231,11 +231,11 @@ config ARCH_RV64I · 142 unmodified lines | ||
| 231 | 231 | bool "RV64I" |
| 232 | 232 | select 64BIT |
| 233 | 233 | select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000 |
| 234 | − select HAVE_DYNAMIC_FTRACE if MMU && $(cc-option,-fpatchable-function-entry=8) | |
| 234 | + select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8) | |
| 235 | 235 | select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE |
| 236 | − select HAVE_FTRACE_MCOUNT_RECORD | |
| 236 | + select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL | |
| 237 | 237 | select HAVE_FUNCTION_GRAPH_TRACER |
| 238 | − select HAVE_FUNCTION_TRACER | |
| 238 | + select HAVE_FUNCTION_TRACER if !XIP_KERNEL | |
| 239 | 239 | select SWIOTLB if MMU |
| 240 | 240 | |
| 241 | 241 | endchoice |
| @@ -38,6 +38,15 @@ else · 37 unmodified lines | ||
| 38 | 38 | KBUILD_LDFLAGS += -melf32lriscv |
| 39 | 39 | endif |
| 40 | 40 | |
| 41 | +ifeq ($(CONFIG_LD_IS_LLD),y) | |
| 42 | + KBUILD_CFLAGS += -mno-relax | |
| 43 | + KBUILD_AFLAGS += -mno-relax | |
| 44 | +ifneq ($(LLVM_IAS),1) | |
| 45 | + KBUILD_CFLAGS += -Wa,-mno-relax | |
| 46 | + KBUILD_AFLAGS += -Wa,-mno-relax | |
| 47 | +endif | |
| 48 | +endif | |
| 49 | + | |
| 41 | 50 | # ISA string setting |
| 42 | 51 | riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima |
| 43 | 52 | riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima |
| @@ -1,2 +1,3 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | dtb-$(CONFIG_SOC_MICROCHIP_POLARFIRE) += microchip-mpfs-icicle-kit.dtb |
| 3 | +obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .o, $(dtb-y)) | |
| @@ -1,3 +1,4 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | dtb-$(CONFIG_SOC_SIFIVE) += hifive-unleashed-a00.dtb \ |
| 3 | 3 | hifive-unmatched-a00.dtb |
| 4 | +obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .o, $(dtb-y)) | |
| @@ -1,2 +1,2 @@ | ||
| 1 | −obj-y += errata_cip_453.o | |
| 1 | +obj-$(CONFIG_ERRATA_SIFIVE_CIP_453) += errata_cip_453.o | |
| 2 | 2 | obj-y += errata.o |
| @@ -51,7 +51,7 @@ · 50 unmodified lines | ||
| 51 | 51 | REG_ASM " " newlen "\n" \ |
| 52 | 52 | ".word " errata_id "\n" |
| 53 | 53 | |
| 54 | −#define ALT_NEW_CONSTENT(vendor_id, errata_id, enable, new_c) \ | |
| 54 | +#define ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c) \ | |
| 55 | 55 | ".if " __stringify(enable) " == 1\n" \ |
| 56 | 56 | ".pushsection .alternative, \"a\"\n" \ |
| 57 | 57 | ALT_ENTRY("886b", "888f", __stringify(vendor_id), __stringify(errata_id), "889f - 888f") \ |
| @@ -69,7 +69,7 @@ · 11 unmodified lines | ||
| 69 | 69 | "886 :\n" \ |
| 70 | 70 | old_c "\n" \ |
| 71 | 71 | "887 :\n" \ |
| 72 | − ALT_NEW_CONSTENT(vendor_id, errata_id, enable, new_c) | |
| 72 | + ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c) | |
| 73 | 73 | |
| 74 | 74 | #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \ |
| 75 | 75 | __ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)) |
| @@ -231,13 +231,13 @@ static void __init init_resources(void) · 230 unmodified lines | ||
| 231 | 231 | |
| 232 | 232 | /* Clean-up any unused pre-allocated resources */ |
| 233 | 233 | mem_res_sz = (num_resources - res_idx + 1) * sizeof(*mem_res); |
| 234 | − memblock_free((phys_addr_t) mem_res, mem_res_sz); | |
| 234 | + memblock_free(__pa(mem_res), mem_res_sz); | |
| 235 | 235 | return; |
| 236 | 236 | |
| 237 | 237 | error: |
| 238 | 238 | /* Better an empty resource tree than an inconsistent one */ |
| 239 | 239 | release_child_resources(&iomem_resource); |
| 240 | − memblock_free((phys_addr_t) mem_res, mem_res_sz); | |
| 240 | + memblock_free(__pa(mem_res), mem_res_sz); | |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | |
| @@ -86,8 +86,13 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code, · 85 unmodified lines | ||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | +#if defined (CONFIG_XIP_KERNEL) && defined (CONFIG_RISCV_ERRATA_ALTERNATIVE) | |
| 90 | +#define __trap_section __section(".xip.traps") | |
| 91 | +#else | |
| 92 | +#define __trap_section | |
| 93 | +#endif | |
| 89 | 94 | #define DO_ERROR_INFO(name, signo, code, str) \ |
| 90 | −asmlinkage __visible void name(struct pt_regs *regs) \ | |
| 95 | +asmlinkage __visible __trap_section void name(struct pt_regs *regs) \ | |
| 91 | 96 | { \ |
| 92 | 97 | do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \ |
| 93 | 98 | } |
| @@ -111,7 +116,7 @@ DO_ERROR_INFO(do_trap_store_misaligned, · 17 unmodified lines | ||
| 111 | 116 | int handle_misaligned_load(struct pt_regs *regs); |
| 112 | 117 | int handle_misaligned_store(struct pt_regs *regs); |
| 113 | 118 | |
| 114 | −asmlinkage void do_trap_load_misaligned(struct pt_regs *regs) | |
| 119 | +asmlinkage void __trap_section do_trap_load_misaligned(struct pt_regs *regs) | |
| 115 | 120 | { |
| 116 | 121 | if (!handle_misaligned_load(regs)) |
| 117 | 122 | return; |
| @@ -119,7 +124,7 @@ asmlinkage void do_trap_load_misaligned(struct pt_regs *regs) · 1 unmodified line | ||
| 119 | 124 | "Oops - load address misaligned"); |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | −asmlinkage void do_trap_store_misaligned(struct pt_regs *regs) | |
| 127 | +asmlinkage void __trap_section do_trap_store_misaligned(struct pt_regs *regs) | |
| 123 | 128 | { |
| 124 | 129 | if (!handle_misaligned_store(regs)) |
| 125 | 130 | return; |
| @@ -146,7 +151,7 @@ static inline unsigned long get_break_insn_length(unsigned long pc) · 20 unmodified lines | ||
| 146 | 151 | return GET_INSN_LENGTH(insn); |
| 147 | 152 | } |
| 148 | 153 | |
| 149 | −asmlinkage __visible void do_trap_break(struct pt_regs *regs) | |
| 154 | +asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs) | |
| 150 | 155 | { |
| 151 | 156 | #ifdef CONFIG_KPROBES |
| 152 | 157 | if (kprobe_single_step_handler(regs)) |
| @@ -99,9 +99,22 @@ SECTIONS · 98 unmodified lines | ||
| 99 | 99 | } |
| 100 | 100 | PERCPU_SECTION(L1_CACHE_BYTES) |
| 101 | 101 | |
| 102 | − . = ALIGN(PAGE_SIZE); | |
| 102 | + . = ALIGN(8); | |
| 103 | + .alternative : { | |
| 104 | + __alt_start = .; | |
| 105 | + *(.alternative) | |
| 106 | + __alt_end = .; | |
| 107 | + } | |
| 103 | 108 | __init_end = .; |
| 104 | 109 | |
| 110 | + . = ALIGN(16); | |
| 111 | + .xip.traps : { | |
| 112 | + __xip_traps_start = .; | |
| 113 | + *(.xip.traps) | |
| 114 | + __xip_traps_end = .; | |
| 115 | + } | |
| 116 | + | |
| 117 | + . = ALIGN(PAGE_SIZE); | |
| 105 | 118 | .sdata : { |
| 106 | 119 | __global_pointer$ = . + 0x800; |
| 107 | 120 | *(.sdata*) |
| @@ -746,14 +746,18 @@ void __init protect_kernel_text_data(void) · 745 unmodified lines | ||
| 746 | 746 | unsigned long init_data_start = (unsigned long)__init_data_begin; |
| 747 | 747 | unsigned long rodata_start = (unsigned long)__start_rodata; |
| 748 | 748 | unsigned long data_start = (unsigned long)_data; |
| 749 | − unsigned long max_low = (unsigned long)(__va(PFN_PHYS(max_low_pfn))); | |
| 749 | +#if defined(CONFIG_64BIT) && defined(CONFIG_MMU) | |
| 750 | + unsigned long end_va = kernel_virt_addr + load_sz; | |
| 751 | +#else | |
| 752 | + unsigned long end_va = (unsigned long)(__va(PFN_PHYS(max_low_pfn))); | |
| 753 | +#endif | |
| 750 | 754 | |
| 751 | 755 | set_memory_ro(text_start, (init_text_start - text_start) >> PAGE_SHIFT); |
| 752 | 756 | set_memory_ro(init_text_start, (init_data_start - init_text_start) >> PAGE_SHIFT); |
| 753 | 757 | set_memory_nx(init_data_start, (rodata_start - init_data_start) >> PAGE_SHIFT); |
| 754 | 758 | /* rodata section is marked readonly in mark_rodata_ro */ |
| 755 | 759 | set_memory_nx(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT); |
| 756 | − set_memory_nx(data_start, (max_low - data_start) >> PAGE_SHIFT); | |
| 760 | + set_memory_nx(data_start, (end_va - data_start) >> PAGE_SHIFT); | |
| 757 | 761 | } |
| 758 | 762 | |
| 759 | 763 | void mark_rodata_ro(void) |
| @@ -200,8 +200,9 @@ endif · 199 unmodified lines | ||
| 200 | 200 | KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE) |
| 201 | 201 | |
| 202 | 202 | ifdef CONFIG_LTO_CLANG |
| 203 | −KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \ | |
| 204 | − -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8) | |
| 203 | +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0) | |
| 204 | +KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8) | |
| 205 | +endif | |
| 205 | 206 | endif |
| 206 | 207 | |
| 207 | 208 | ifdef CONFIG_X86_NEED_RELOCS |
| @@ -1406,6 +1406,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool · 1405 unmodified lines | ||
| 1406 | 1406 | die_id = i; |
| 1407 | 1407 | else |
| 1408 | 1408 | die_id = topology_phys_to_logical_pkg(i); |
| 1409 | + if (die_id < 0) | |
| 1410 | + die_id = -ENODEV; | |
| 1409 | 1411 | map->pbus_to_dieid[bus] = die_id; |
| 1410 | 1412 | break; |
| 1411 | 1413 | } |
| @@ -1452,14 +1454,14 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool · 40 unmodified lines | ||
| 1452 | 1454 | i = -1; |
| 1453 | 1455 | if (reverse) { |
| 1454 | 1456 | for (bus = 255; bus >= 0; bus--) { |
| 1455 | − if (map->pbus_to_dieid[bus] >= 0) | |
| 1457 | + if (map->pbus_to_dieid[bus] != -1) | |
| 1456 | 1458 | i = map->pbus_to_dieid[bus]; |
| 1457 | 1459 | else |
| 1458 | 1460 | map->pbus_to_dieid[bus] = i; |
| 1459 | 1461 | } |
| 1460 | 1462 | } else { |
| 1461 | 1463 | for (bus = 0; bus <= 255; bus++) { |
| 1462 | − if (map->pbus_to_dieid[bus] >= 0) | |
| 1464 | + if (map->pbus_to_dieid[bus] != -1) | |
| 1463 | 1465 | i = map->pbus_to_dieid[bus]; |
| 1464 | 1466 | else |
| 1465 | 1467 | map->pbus_to_dieid[bus] = i; |
| @@ -5097,9 +5099,10 @@ static struct intel_uncore_type icx_uncore_m2m = { · 3631 unmodified lines | ||
| 5097 | 5099 | .perf_ctr = SNR_M2M_PCI_PMON_CTR0, |
| 5098 | 5100 | .event_ctl = SNR_M2M_PCI_PMON_CTL0, |
| 5099 | 5101 | .event_mask = SNBEP_PMON_RAW_EVENT_MASK, |
| 5102 | + .event_mask_ext = SNR_M2M_PCI_PMON_UMASK_EXT, | |
| 5100 | 5103 | .box_ctl = SNR_M2M_PCI_PMON_BOX_CTL, |
| 5101 | 5104 | .ops = &snr_m2m_uncore_pci_ops, |
| 5102 | − .format_group = &skx_uncore_format_group, | |
| 5105 | + .format_group = &snr_m2m_uncore_format_group, | |
| 5103 | 5106 | }; |
| 5104 | 5107 | |
| 5105 | 5108 | static struct attribute *icx_upi_uncore_formats_attr[] = { |
| @@ -174,6 +174,7 @@ static inline int apic_is_clustered_box(void) · 173 unmodified lines | ||
| 174 | 174 | extern int setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask); |
| 175 | 175 | extern void lapic_assign_system_vectors(void); |
| 176 | 176 | extern void lapic_assign_legacy_vector(unsigned int isairq, bool replace); |
| 177 | +extern void lapic_update_legacy_vectors(void); | |
| 177 | 178 | extern void lapic_online(void); |
| 178 | 179 | extern void lapic_offline(void); |
| 179 | 180 | extern bool apic_needs_pit(void); |
| @@ -56,11 +56,8 @@ · 55 unmodified lines | ||
| 56 | 56 | # define DISABLE_PTI (1 << (X86_FEATURE_PTI & 31)) |
| 57 | 57 | #endif |
| 58 | 58 | |
| 59 | −#ifdef CONFIG_IOMMU_SUPPORT | |
| 60 | −# define DISABLE_ENQCMD 0 | |
| 61 | −#else | |
| 62 | −# define DISABLE_ENQCMD (1 << (X86_FEATURE_ENQCMD & 31)) | |
| 63 | −#endif | |
| 59 | +/* Force disable because it's broken beyond repair */ | |
| 60 | +#define DISABLE_ENQCMD (1 << (X86_FEATURE_ENQCMD & 31)) | |
| 64 | 61 | |
| 65 | 62 | #ifdef CONFIG_X86_SGX |
| 66 | 63 | # define DISABLE_SGX 0 |
| @@ -106,10 +106,6 @@ extern int cpu_has_xfeatures(u64 xfeatures_mask, const char **feature_name); · 105 unmodified lines | ||
| 106 | 106 | */ |
| 107 | 107 | #define PASID_DISABLED 0 |
| 108 | 108 | |
| 109 | −#ifdef CONFIG_IOMMU_SUPPORT | |
| 110 | −/* Update current's PASID MSR/state by mm's PASID. */ | |
| 111 | −void update_pasid(void); | |
| 112 | −#else | |
| 113 | 109 | static inline void update_pasid(void) { } |
| 114 | −#endif | |
| 110 | + | |
| 115 | 111 | #endif /* _ASM_X86_FPU_API_H */ |
| @@ -584,13 +584,6 @@ static inline void switch_fpu_finish(struct fpu *new_fpu) · 583 unmodified lines | ||
| 584 | 584 | pkru_val = pk->pkru; |
| 585 | 585 | } |
| 586 | 586 | __write_pkru(pkru_val); |
| 587 | − | |
| 588 | − /* | |
| 589 | − * Expensive PASID MSR write will be avoided in update_pasid() because | |
| 590 | − * TIF_NEED_FPU_LOAD was set. And the PASID state won't be updated | |
| 591 | − * unless it's different from mm->pasid to reduce overhead. | |
| 592 | − */ | |
| 593 | − update_pasid(); | |
| 594 | 587 | } |
| 595 | 588 | |
| 596 | 589 | #endif /* _ASM_X86_FPU_INTERNAL_H */ |
| @@ -3,11 +3,13 @@ · 2 unmodified lines | ||
| 3 | 3 | #define _ASM_X86_THERMAL_H |
| 4 | 4 | |
| 5 | 5 | #ifdef CONFIG_X86_THERMAL_VECTOR |
| 6 | +void therm_lvt_init(void); | |
| 6 | 7 | void intel_init_thermal(struct cpuinfo_x86 *c); |
| 7 | 8 | bool x86_thermal_enabled(void); |
| 8 | 9 | void intel_thermal_interrupt(void); |
| 9 | 10 | #else |
| 10 | −static inline void intel_init_thermal(struct cpuinfo_x86 *c) { } | |
| 11 | +static inline void therm_lvt_init(void) { } | |
| 12 | +static inline void intel_init_thermal(struct cpuinfo_x86 *c) { } | |
| 11 | 13 | #endif |
| 12 | 14 | |
| 13 | 15 | #endif /* _ASM_X86_THERMAL_H */ |
| @@ -182,42 +182,70 @@ done: · 181 unmodified lines | ||
| 182 | 182 | n_dspl, (unsigned long)orig_insn + n_dspl + repl_len); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | +/* | |
| 186 | + * optimize_nops_range() - Optimize a sequence of single byte NOPs (0x90) | |
| 187 | + * | |
| 188 | + * @instr: instruction byte stream | |
| 189 | + * @instrlen: length of the above | |
| 190 | + * @off: offset within @instr where the first NOP has been detected | |
| 191 | + * | |
| 192 | + * Return: number of NOPs found (and replaced). | |
| 193 | + */ | |
| 194 | +static __always_inline int optimize_nops_range(u8 *instr, u8 instrlen, int off) | |
| 195 | +{ | |
| 196 | + unsigned long flags; | |
| 197 | + int i = off, nnops; | |
| 198 | + | |
| 199 | + while (i < instrlen) { | |
| 200 | + if (instr[i] != 0x90) | |
| 201 | + break; | |
| 202 | + | |
| 203 | + i++; | |
| 204 | + } | |
| 205 | + | |
| 206 | + nnops = i - off; | |
| 207 | + | |
| 208 | + if (nnops <= 1) | |
| 209 | + return nnops; | |
| 210 | + | |
| 211 | + local_irq_save(flags); | |
| 212 | + add_nops(instr + off, nnops); | |
| 213 | + local_irq_restore(flags); | |
| 214 | + | |
| 215 | + DUMP_BYTES(instr, instrlen, "%px: [%d:%d) optimized NOPs: ", instr, off, i); | |
| 216 | + | |
| 217 | + return nnops; | |
| 218 | +} | |
| 219 | + | |
| 185 | 220 | /* |
| 186 | 221 | * "noinline" to cause control flow change and thus invalidate I$ and |
| 187 | 222 | * cause refetch after modification. |
| 188 | 223 | */ |
| 189 | 224 | static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 *instr) |
| 190 | 225 | { |
| 191 | − unsigned long flags; | |
| 192 | 226 | struct insn insn; |
| 193 | − int nop, i = 0; | |
| 227 | + int i = 0; | |
| 194 | 228 | |
| 195 | 229 | /* |
| 196 | − * Jump over the non-NOP insns, the remaining bytes must be single-byte | |
| 197 | − * NOPs, optimize them. | |
| 230 | + * Jump over the non-NOP insns and optimize single-byte NOPs into bigger | |
| 231 | + * ones. | |
| 198 | 232 | */ |
| 199 | 233 | for (;;) { |
| 200 | 234 | if (insn_decode_kernel(&insn, &instr[i])) |
| 201 | 235 | return; |
| 202 | 236 | |
| 237 | + /* | |
| 238 | + * See if this and any potentially following NOPs can be | |
| 239 | + * optimized. | |
| 240 | + */ | |
| 203 | 241 | if (insn.length == 1 && insn.opcode.bytes[0] == 0x90) |
| 204 | − break; | |
| 205 | − | |
| 206 | − if ((i += insn.length) >= a->instrlen) | |
| 207 | − return; | |
| 208 | − } | |
| 242 | + i += optimize_nops_range(instr, a->instrlen, i); | |
| 243 | + else | |
| 244 | + i += insn.length; | |
| 209 | 245 | |
| 210 | − for (nop = i; i < a->instrlen; i++) { | |
| 211 | − if (WARN_ONCE(instr[i] != 0x90, "Not a NOP at 0x%px\n", &instr[i])) | |
| 246 | + if (i >= a->instrlen) | |
| 212 | 247 | return; |
| 213 | 248 | } |
| 214 | − | |
| 215 | − local_irq_save(flags); | |
| 216 | − add_nops(instr + nop, i - nop); | |
| 217 | − local_irq_restore(flags); | |
| 218 | − | |
| 219 | − DUMP_BYTES(instr, a->instrlen, "%px: [%d:%d) optimized NOPs: ", | |
| 220 | − instr, nop, a->instrlen); | |
| 221 | 249 | } |
| 222 | 250 | |
| 223 | 251 | /* |
| @@ -2604,6 +2604,7 @@ static void __init apic_bsp_setup(bool upmode) · 2603 unmodified lines | ||
| 2604 | 2604 | end_local_APIC_setup(); |
| 2605 | 2605 | irq_remap_enable_fault_handling(); |
| 2606 | 2606 | setup_IO_APIC(); |
| 2607 | + lapic_update_legacy_vectors(); | |
| 2607 | 2608 | } |
| 2608 | 2609 | |
| 2609 | 2610 | #ifdef CONFIG_UP_LATE_INIT |
| @@ -738,6 +738,26 @@ void lapic_assign_legacy_vector(unsigned int irq, bool replace) · 737 unmodified lines | ||
| 738 | 738 | irq_matrix_assign_system(vector_matrix, ISA_IRQ_VECTOR(irq), replace); |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | +void __init lapic_update_legacy_vectors(void) | |
| 742 | +{ | |
| 743 | + unsigned int i; | |
| 744 | + | |
| 745 | + if (IS_ENABLED(CONFIG_X86_IO_APIC) && nr_ioapics > 0) | |
| 746 | + return; | |
| 747 | + | |
| 748 | + /* | |
| 749 | + * If the IO/APIC is disabled via config, kernel command line or | |
| 750 | + * lack of enumeration then all legacy interrupts are routed | |
| 751 | + * through the PIC. Make sure that they are marked as legacy | |
| 752 | + * vectors. PIC_CASCADE_IRQ has already been marked in | |
| 753 | + * lapic_assign_system_vectors(). | |
| 754 | + */ | |
| 755 | + for (i = 0; i < nr_legacy_irqs(); i++) { | |
| 756 | + if (i != PIC_CASCADE_IR) | |
| 757 | + lapic_assign_legacy_vector(i, true); | |
| 758 | + } | |
| 759 | +} | |
| 760 | + | |
| 741 | 761 | void __init lapic_assign_system_vectors(void) |
| 742 | 762 | { |
| 743 | 763 | unsigned int i, vector = 0; |
| @@ -63,7 +63,7 @@ static inline unsigned int nmi_perfctr_msr_to_bit(unsigned int msr) · 62 unmodified lines | ||
| 63 | 63 | case 15: |
| 64 | 64 | return msr - MSR_P4_BPU_PERFCTR0; |
| 65 | 65 | } |
| 66 | − fallthrough; | |
| 66 | + break; | |
| 67 | 67 | case X86_VENDOR_ZHAOXIN: |
| 68 | 68 | case X86_VENDOR_CENTAUR: |
| 69 | 69 | return msr - MSR_ARCH_PERFMON_PERFCTR0; |
| @@ -96,7 +96,7 @@ static inline unsigned int nmi_evntsel_msr_to_bit(unsigned int msr) · 26 unmodified lines | ||
| 96 | 96 | case 15: |
| 97 | 97 | return msr - MSR_P4_BSU_ESCR0; |
| 98 | 98 | } |
| 99 | − fallthrough; | |
| 99 | + break; | |
| 100 | 100 | case X86_VENDOR_ZHAOXIN: |
| 101 | 101 | case X86_VENDOR_CENTAUR: |
| 102 | 102 | return msr - MSR_ARCH_PERFMON_EVENTSEL0; |
| @@ -1402,60 +1402,3 @@ int proc_pid_arch_status(struct seq_file *m, struct pid_namespace *ns, · 1401 unmodified lines | ||
| 1402 | 1402 | return 0; |
| 1403 | 1403 | } |
| 1404 | 1404 | #endif /* CONFIG_PROC_PID_ARCH_STATUS */ |
| 1405 | − | |
| 1406 | −#ifdef CONFIG_IOMMU_SUPPORT | |
| 1407 | −void update_pasid(void) | |
| 1408 | −{ | |
| 1409 | − u64 pasid_state; | |
| 1410 | − u32 pasid; | |
| 1411 | − | |
| 1412 | − if (!cpu_feature_enabled(X86_FEATURE_ENQCMD)) | |
| 1413 | − return; | |
| 1414 | − | |
| 1415 | − if (!current->mm) | |
| 1416 | − return; | |
| 1417 | − | |
| 1418 | − pasid = READ_ONCE(current->mm->pasid); | |
| 1419 | − /* Set the valid bit in the PASID MSR/state only for valid pasid. */ | |
| 1420 | − pasid_state = pasid == PASID_DISABLED ? | |
| 1421 | − pasid : pasid | MSR_IA32_PASID_VALID; | |
| 1422 | − | |
| 1423 | − /* | |
| 1424 | − * No need to hold fregs_lock() since the task's fpstate won't | |
| 1425 | − * be changed by others (e.g. ptrace) while the task is being | |
| 1426 | − * switched to or is in IPI. | |
| 1427 | − */ | |
| 1428 | − if (!test_thread_flag(TIF_NEED_FPU_LOAD)) { | |
| 1429 | − /* The MSR is active and can be directly updated. */ | |
| 1430 | − wrmsrl(MSR_IA32_PASID, pasid_state); | |
| 1431 | − } else { | |
| 1432 | − struct fpu *fpu = ¤t->thread.fpu; | |
| 1433 | − struct ia32_pasid_state *ppasid_state; | |
| 1434 | − struct xregs_state *xsave; | |
| 1435 | − | |
| 1436 | − /* | |
| 1437 | − * The CPU's xstate registers are not currently active. Just | |
| 1438 | − * update the PASID state in the memory buffer here. The | |
| 1439 | − * PASID MSR will be loaded when returning to user mode. | |
| 1440 | − */ | |
| 1441 | − xsave = &fpu->state.xsave; | |
| 1442 | − xsave->header.xfeatures |= XFEATURE_MASK_PASID; | |
| 1443 | − ppasid_state = get_xsave_addr(xsave, XFEATURE_PASID); | |
| 1444 | − /* | |
| 1445 | − * Since XFEATURE_MASK_PASID is set in xfeatures, ppasid_state | |
| 1446 | − * won't be NULL and no need to check its value. | |
| 1447 | − * | |
| 1448 | − * Only update the task's PASID state when it's different | |
| 1449 | − * from the mm's pasid. | |
| 1450 | − */ | |
| 1451 | − if (ppasid_state->pasid != pasid_state) { | |
| 1452 | − /* | |
| 1453 | − * Invalid fpregs so that state restoring will pick up | |
| 1454 | − * the PASID state. | |
| 1455 | − */ | |
| 1456 | − __fpu_invalidate_fpregs_state(fpu); | |
| 1457 | − ppasid_state->pasid = pasid_state; | |
| 1458 | − } | |
| 1459 | − } | |
| 1460 | −} | |
| 1461 | −#endif /* CONFIG_IOMMU_SUPPORT */ | |
| @@ -44,6 +44,7 @@ · 43 unmodified lines | ||
| 44 | 44 | #include <asm/pci-direct.h> |
| 45 | 45 | #include <asm/prom.h> |
| 46 | 46 | #include <asm/proto.h> |
| 47 | +#include <asm/thermal.h> | |
| 47 | 48 | #include <asm/unwind.h> |
| 48 | 49 | #include <asm/vsyscall.h> |
| 49 | 50 | #include <linux/vmalloc.h> |
| @@ -637,11 +638,11 @@ static void __init trim_snb_memory(void) · 587 unmodified lines | ||
| 637 | 638 | * them from accessing certain memory ranges, namely anything below |
| 638 | 639 | * 1M and in the pages listed in bad_pages[] above. |
| 639 | 640 | * |
| 640 | − * To avoid these pages being ever accessed by SNB gfx devices | |
| 641 | − * reserve all memory below the 1 MB mark and bad_pages that have | |
| 642 | − * not already been reserved at boot time. | |
| 641 | + * To avoid these pages being ever accessed by SNB gfx devices reserve | |
| 642 | + * bad_pages that have not already been reserved at boot time. | |
| 643 | + * All memory below the 1 MB mark is anyway reserved later during | |
| 644 | + * setup_arch(), so there is no need to reserve it here. | |
| 643 | 645 | */ |
| 644 | − memblock_reserve(0, 1<<20); | |
| 645 | 646 | |
| 646 | 647 | for (i = 0; i < ARRAY_SIZE(bad_pages); i++) { |
| 647 | 648 | if (memblock_reserve(bad_pages[i], PAGE_SIZE)) |
| @@ -733,14 +734,14 @@ static void __init early_reserve_memory(void) · 85 unmodified lines | ||
| 733 | 734 | * The first 4Kb of memory is a BIOS owned area, but generally it is |
| 734 | 735 | * not listed as such in the E820 table. |
| 735 | 736 | * |
| 736 | − * Reserve the first memory page and typically some additional | |
| 737 | − * memory (64KiB by default) since some BIOSes are known to corrupt | |
| 738 | − * low memory. See the Kconfig help text for X86_RESERVE_LOW. | |
| 737 | + * Reserve the first 64K of memory since some BIOSes are known to | |
| 738 | + * corrupt low memory. After the real mode trampoline is allocated the | |
| 739 | + * rest of the memory below 640k is reserved. | |
| 739 | 740 | * |
| 740 | 741 | * In addition, make sure page 0 is always reserved because on |
| 741 | 742 | * systems with L1TF its contents can be leaked to user processes. |
| 742 | 743 | */ |
| 743 | − memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); | |
| 744 | + memblock_reserve(0, SZ_64K); | |
| 744 | 745 | |
| 745 | 746 | early_reserve_initrd(); |
| 746 | 747 | |
| @@ -751,6 +752,7 @@ static void __init early_reserve_memory(void) · 4 unmodified lines | ||
| 751 | 752 | |
| 752 | 753 | reserve_ibft_region(); |
| 753 | 754 | reserve_bios_regions(); |
| 755 | + trim_snb_memory(); | |
| 754 | 756 | } |
| 755 | 757 | |
| 756 | 758 | /* |
| @@ -1081,14 +1083,20 @@ void __init setup_arch(char **cmdline_p) · 324 unmodified lines | ||
| 1081 | 1083 | (max_pfn_mapped<<PAGE_SHIFT) - 1); |
| 1082 | 1084 | #endif |
| 1083 | 1085 | |
| 1084 | − reserve_real_mode(); | |
| 1085 | − | |
| 1086 | 1086 | /* |
| 1087 | − * Reserving memory causing GPU hangs on Sandy Bridge integrated | |
| 1088 | − * graphics devices should be done after we allocated memory under | |
| 1089 | − * 1M for the real mode trampoline. | |
| 1087 | + * Find free memory for the real mode trampoline and place it | |
| 1088 | + * there. | |
| 1089 | + * If there is not enough free memory under 1M, on EFI-enabled | |
| 1090 | + * systems there will be additional attempt to reclaim the memory | |
| 1091 | + * for the real mode trampoline at efi_free_boot_services(). | |
| 1092 | + * | |
| 1093 | + * Unconditionally reserve the entire first 1M of RAM because | |
| 1094 | + * BIOSes are know to corrupt low memory and several | |
| 1095 | + * hundred kilobytes are not worth complex detection what memory gets | |
| 1096 | + * clobbered. Moreover, on machines with SandyBridge graphics or in | |
| 1097 | + * setups that use crashkernel the entire 1M is reserved anyway. | |
| 1090 | 1098 | */ |
| 1091 | − trim_snb_memory(); | |
| 1099 | + reserve_real_mode(); | |
| 1092 | 1100 | |
| 1093 | 1101 | init_mem_mapping(); |
| 1094 | 1102 | |
| @@ -1226,6 +1234,14 @@ void __init setup_arch(char **cmdline_p) · 131 unmodified lines | ||
| 1226 | 1234 | |
| 1227 | 1235 | x86_init.timers.wallclock_init(); |
| 1228 | 1236 | |
| 1237 | + /* | |
| 1238 | + * This needs to run before setup_local_APIC() which soft-disables the | |
| 1239 | + * local APIC temporarily and that masks the thermal LVT interrupt, | |
| 1240 | + * leading to softlockups on machines which have configured SMI | |
| 1241 | + * interrupt delivery. | |
| 1242 | + */ | |
| 1243 | + therm_lvt_init(); | |
| 1244 | + | |
| 1229 | 1245 | mcheck_init(); |
| 1230 | 1246 | |
| 1231 | 1247 | register_refined_jiffies(CLOCK_TICK_RATE); |
| @@ -1494,6 +1494,15 @@ static void limit_periodic_timer_frequency(struct kvm_lapic *apic) · 1493 unmodified lines | ||
| 1494 | 1494 | |
| 1495 | 1495 | static void cancel_hv_timer(struct kvm_lapic *apic); |
| 1496 | 1496 | |
| 1497 | +static void cancel_apic_timer(struct kvm_lapic *apic) | |
| 1498 | +{ | |
| 1499 | + hrtimer_cancel(&apic->lapic_timer.timer); | |
| 1500 | + preempt_disable(); | |
| 1501 | + if (apic->lapic_timer.hv_timer_in_use) | |
| 1502 | + cancel_hv_timer(apic); | |
| 1503 | + preempt_enable(); | |
| 1504 | +} | |
| 1505 | + | |
| 1497 | 1506 | static void apic_update_lvtt(struct kvm_lapic *apic) |
| 1498 | 1507 | { |
| 1499 | 1508 | u32 timer_mode = kvm_lapic_get_reg(apic, APIC_LVTT) & |
| @@ -1502,11 +1511,7 @@ static void apic_update_lvtt(struct kvm_lapic *apic) · 2 unmodified lines | ||
| 1502 | 1511 | if (apic->lapic_timer.timer_mode != timer_mode) { |
| 1503 | 1512 | if (apic_lvtt_tscdeadline(apic) != (timer_mode == |
| 1504 | 1513 | APIC_LVT_TIMER_TSCDEADLINE)) { |
| 1505 | − hrtimer_cancel(&apic->lapic_timer.timer); | |
| 1506 | − preempt_disable(); | |
| 1507 | − if (apic->lapic_timer.hv_timer_in_use) | |
| 1508 | − cancel_hv_timer(apic); | |
| 1509 | − preempt_enable(); | |
| 1514 | + cancel_apic_timer(apic); | |
| 1510 | 1515 | kvm_lapic_set_reg(apic, APIC_TMICT, 0); |
| 1511 | 1516 | apic->lapic_timer.period = 0; |
| 1512 | 1517 | apic->lapic_timer.tscdeadline = 0; |
| @@ -2092,7 +2097,7 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) · 579 unmodified lines | ||
| 2092 | 2097 | if (apic_lvtt_tscdeadline(apic)) |
| 2093 | 2098 | break; |
| 2094 | 2099 | |
| 2095 | − hrtimer_cancel(&apic->lapic_timer.timer); | |
| 2100 | + cancel_apic_timer(apic); | |
| 2096 | 2101 | kvm_lapic_set_reg(apic, APIC_TMICT, val); |
| 2097 | 2102 | start_apic_timer(apic); |
| 2098 | 2103 | break; |
| @@ -90,8 +90,8 @@ struct guest_walker { · 89 unmodified lines | ||
| 90 | 90 | gpa_t pte_gpa[PT_MAX_FULL_LEVELS]; |
| 91 | 91 | pt_element_t __user *ptep_user[PT_MAX_FULL_LEVELS]; |
| 92 | 92 | bool pte_writable[PT_MAX_FULL_LEVELS]; |
| 93 | − unsigned pt_access; | |
| 94 | − unsigned pte_access; | |
| 93 | + unsigned int pt_access[PT_MAX_FULL_LEVELS]; | |
| 94 | + unsigned int pte_access; | |
| 95 | 95 | gfn_t gfn; |
| 96 | 96 | struct x86_exception fault; |
| 97 | 97 | }; |
| @@ -418,13 +418,15 @@ retry_walk: · 320 unmodified lines | ||
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | walker->ptes[walker->level - 1] = pte; |
| 421 | + | |
| 422 | + /* Convert to ACC_*_MASK flags for struct guest_walker. */ | |
| 423 | + walker->pt_access[walker->level - 1] = FNAME(gpte_access)(pt_access ^ walk_nx_mask); | |
| 421 | 424 | } while (!is_last_gpte(mmu, walker->level, pte)); |
| 422 | 425 | |
| 423 | 426 | pte_pkey = FNAME(gpte_pkeys)(vcpu, pte); |
| 424 | 427 | accessed_dirty = have_ad ? pte_access & PT_GUEST_ACCESSED_MASK : 0; |
| 425 | 428 | |
| 426 | 429 | /* Convert to ACC_*_MASK flags for struct guest_walker. */ |
| 427 | − walker->pt_access = FNAME(gpte_access)(pt_access ^ walk_nx_mask); | |
| 428 | 430 | walker->pte_access = FNAME(gpte_access)(pte_access ^ walk_nx_mask); |
| 429 | 431 | errcode = permission_fault(vcpu, mmu, walker->pte_access, pte_pkey, access); |
| 430 | 432 | if (unlikely(errcode)) |
| @@ -463,7 +465,8 @@ retry_walk: · 32 unmodified lines | ||
| 463 | 465 | } |
| 464 | 466 | |
| 465 | 467 | pgprintk("%s: pte %llx pte_access %x pt_access %x\n", |
| 466 | − __func__, (u64)pte, walker->pte_access, walker->pt_access); | |
| 468 | + __func__, (u64)pte, walker->pte_access, | |
| 469 | + walker->pt_access[walker->level - 1]); | |
| 467 | 470 | return 1; |
| 468 | 471 | |
| 469 | 472 | error: |
| @@ -643,7 +646,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, · 173 unmodified lines | ||
| 643 | 646 | bool huge_page_disallowed = exec && nx_huge_page_workaround_enabled; |
| 644 | 647 | struct kvm_mmu_page *sp = NULL; |
| 645 | 648 | struct kvm_shadow_walk_iterator it; |
| 646 | − unsigned direct_access, access = gw->pt_access; | |
| 649 | + unsigned int direct_access, access; | |
| 647 | 650 | int top_level, level, req_level, ret; |
| 648 | 651 | gfn_t base_gfn = gw->gfn; |
| 649 | 652 | |
| @@ -675,6 +678,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, · 25 unmodified lines | ||
| 675 | 678 | sp = NULL; |
| 676 | 679 | if (!is_shadow_present_pte(*it.sptep)) { |
| 677 | 680 | table_gfn = gw->table_gfn[it.level - 2]; |
| 681 | + access = gw->pt_access[it.level - 2]; | |
| 678 | 682 | sp = kvm_mmu_get_page(vcpu, table_gfn, addr, it.level-1, |
| 679 | 683 | false, access); |
| 680 | 684 | } |
| @@ -1103,10 +1103,9 @@ __sev_send_start_query_session_length(struct kvm *kvm, struct kvm_sev_cmd *argp, · 1102 unmodified lines | ||
| 1103 | 1103 | struct sev_data_send_start data; |
| 1104 | 1104 | int ret; |
| 1105 | 1105 | |
| 1106 | + memset(&data, 0, sizeof(data)); | |
| 1106 | 1107 | data.handle = sev->handle; |
| 1107 | 1108 | ret = sev_issue_cmd(kvm, SEV_CMD_SEND_START, &data, &argp->error); |
| 1108 | − if (ret < 0) | |
| 1109 | − return ret; | |
| 1110 | 1109 | |
| 1111 | 1110 | params->session_len = data.session_len; |
| 1112 | 1111 | if (copy_to_user((void __user *)(uintptr_t)argp->data, params, |
| @@ -1215,10 +1214,9 @@ __sev_send_update_data_query_lengths(struct kvm *kvm, struct kvm_sev_cmd *argp, · 102 unmodified lines | ||
| 1215 | 1214 | struct sev_data_send_update_data data; |
| 1216 | 1215 | int ret; |
| 1217 | 1216 | |
| 1217 | + memset(&data, 0, sizeof(data)); | |
| 1218 | 1218 | data.handle = sev->handle; |
| 1219 | 1219 | ret = sev_issue_cmd(kvm, SEV_CMD_SEND_UPDATE_DATA, &data, &argp->error); |
| 1220 | − if (ret < 0) | |
| 1221 | − return ret; | |
| 1222 | 1220 | |
| 1223 | 1221 | params->hdr_len = data.hdr_len; |
| 1224 | 1222 | params->trans_len = data.trans_len; |
| @@ -1550,16 +1550,16 @@ TRACE_EVENT(kvm_nested_vmenter_failed, · 1549 unmodified lines | ||
| 1550 | 1550 | TP_ARGS(msg, err), |
| 1551 | 1551 | |
| 1552 | 1552 | TP_STRUCT__entry( |
| 1553 | − __field(const char *, msg) | |
| 1553 | + __string(msg, msg) | |
| 1554 | 1554 | __field(u32, err) |
| 1555 | 1555 | ), |
| 1556 | 1556 | |
| 1557 | 1557 | TP_fast_assign( |
| 1558 | − __entry->msg = msg; | |
| 1558 | + __assign_str(msg, msg); | |
| 1559 | 1559 | __entry->err = err; |
| 1560 | 1560 | ), |
| 1561 | 1561 | |
| 1562 | − TP_printk("%s%s", __entry->msg, !__entry->err ? "" : | |
| 1562 | + TP_printk("%s%s", __get_str(msg), !__entry->err ? "" : | |
| 1563 | 1563 | __print_symbolic(__entry->err, VMX_VMENTER_INSTRUCTION_ERRORS)) |
| 1564 | 1564 | ); |
| 1565 | 1565 | |
| @@ -3072,6 +3072,19 @@ static void kvm_vcpu_flush_tlb_all(struct kvm_vcpu *vcpu) · 3071 unmodified lines | ||
| 3072 | 3072 | static void kvm_vcpu_flush_tlb_guest(struct kvm_vcpu *vcpu) |
| 3073 | 3073 | { |
| 3074 | 3074 | ++vcpu->stat.tlb_flush; |
| 3075 | + | |
| 3076 | + if (!tdp_enabled) { | |
| 3077 | + /* | |
| 3078 | + * A TLB flush on behalf of the guest is equivalent to | |
| 3079 | + * INVPCID(all), toggling CR4.PGE, etc., which requires | |
| 3080 | + * a forced sync of the shadow page tables. Unload the | |
| 3081 | + * entire MMU here and the subsequent load will sync the | |
| 3082 | + * shadow page tables, and also flush the TLB. | |
| 3083 | + */ | |
| 3084 | + kvm_mmu_unload(vcpu); | |
| 3085 | + return; | |
| 3086 | + } | |
| 3087 | + | |
| 3075 | 3088 | static_call(kvm_x86_tlb_flush_guest)(vcpu); |
| 3076 | 3089 | } |
| 3077 | 3090 | |
| @@ -3101,9 +3114,11 @@ static void record_steal_time(struct kvm_vcpu *vcpu) · 23 unmodified lines | ||
| 3101 | 3114 | * expensive IPIs. |
| 3102 | 3115 | */ |
| 3103 | 3116 | if (guest_pv_has(vcpu, KVM_FEATURE_PV_TLB_FLUSH)) { |
| 3117 | + u8 st_preempted = xchg(&st->preempted, 0); | |
| 3118 | + | |
| 3104 | 3119 | trace_kvm_pv_tlb_flush(vcpu->vcpu_id, |
| 3105 | − st->preempted & KVM_VCPU_FLUSH_TLB); | |
| 3106 | − if (xchg(&st->preempted, 0) & KVM_VCPU_FLUSH_TLB) | |
| 3120 | + st_preempted & KVM_VCPU_FLUSH_TLB); | |
| 3121 | + if (st_preempted & KVM_VCPU_FLUSH_TLB) | |
| 3107 | 3122 | kvm_vcpu_flush_tlb_guest(vcpu); |
| 3108 | 3123 | } else { |
| 3109 | 3124 | st->preempted = 0; |
| @@ -836,8 +836,8 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, · 835 unmodified lines | ||
| 836 | 836 | |
| 837 | 837 | if (si_code == SEGV_PKUERR) |
| 838 | 838 | force_sig_pkuerr((void __user *)address, pkey); |
| 839 | − | |
| 840 | − force_sig_fault(SIGSEGV, si_code, (void __user *)address); | |
| 839 | + else | |
| 840 | + force_sig_fault(SIGSEGV, si_code, (void __user *)address); | |
| 841 | 841 | |
| 842 | 842 | local_irq_disable(); |
| 843 | 843 | } |
| @@ -504,10 +504,6 @@ void __init sme_enable(struct boot_params *bp) · 503 unmodified lines | ||
| 504 | 504 | #define AMD_SME_BIT BIT(0) |
| 505 | 505 | #define AMD_SEV_BIT BIT(1) |
| 506 | 506 | |
| 507 | − /* Check the SEV MSR whether SEV or SME is enabled */ | |
| 508 | − sev_status = __rdmsr(MSR_AMD64_SEV); | |
| 509 | − feature_mask = (sev_status & MSR_AMD64_SEV_ENABLED) ? AMD_SEV_BIT : AMD_SME_BIT; | |
| 510 | − | |
| 511 | 507 | /* |
| 512 | 508 | * Check for the SME/SEV feature: |
| 513 | 509 | * CPUID Fn8000_001F[EAX] |
| @@ -519,11 +515,16 @@ void __init sme_enable(struct boot_params *bp) · 5 unmodified lines | ||
| 519 | 515 | eax = 0x8000001f; |
| 520 | 516 | ecx = 0; |
| 521 | 517 | native_cpuid(&eax, &ebx, &ecx, &edx); |
| 522 | − if (!(eax & feature_mask)) | |
| 518 | + /* Check whether SEV or SME is supported */ | |
| 519 | + if (!(eax & (AMD_SEV_BIT | AMD_SME_BIT))) | |
| 523 | 520 | return; |
| 524 | 521 | |
| 525 | 522 | me_mask = 1UL << (ebx & 0x3f); |
| 526 | 523 | |
| 524 | + /* Check the SEV MSR whether SEV or SME is enabled */ | |
| 525 | + sev_status = __rdmsr(MSR_AMD64_SEV); | |
| 526 | + feature_mask = (sev_status & MSR_AMD64_SEV_ENABLED) ? AMD_SEV_BIT : AMD_SME_BIT; | |
| 527 | + | |
| 527 | 528 | /* Check if memory encryption is enabled */ |
| 528 | 529 | if (feature_mask == AMD_SME_BIT) { |
| 529 | 530 | /* |
| @@ -450,6 +450,18 @@ void __init efi_free_boot_services(void) · 449 unmodified lines | ||
| 450 | 450 | size -= rm_size; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | + /* | |
| 454 | + * Don't free memory under 1M for two reasons: | |
| 455 | + * - BIOS might clobber it | |
| 456 | + * - Crash kernel needs it to be reserved | |
| 457 | + */ | |
| 458 | + if (start + size < SZ_1M) | |
| 459 | + continue; | |
| 460 | + if (start < SZ_1M) { | |
| 461 | + size -= (SZ_1M - start); | |
| 462 | + start = SZ_1M; | |
| 463 | + } | |
| 464 | + | |
| 453 | 465 | memblock_free_late(start, size); |
| 454 | 466 | } |
| 455 | 467 | |
| @@ -29,14 +29,16 @@ void __init reserve_real_mode(void) · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | /* Has to be under 1M so we can execute real-mode AP code. */ |
| 31 | 31 | mem = memblock_find_in_range(0, 1<<20, size, PAGE_SIZE); |
| 32 | − if (!mem) { | |
| 32 | + if (!mem) | |
| 33 | 33 | pr_info("No sub-1M memory is available for the trampoline\n"); |
| 34 | − return; | |
| 35 | − } | |
| 34 | + else | |
| 35 | + set_real_mode_mem(mem); | |
| 36 | 36 | |
| 37 | − memblock_reserve(mem, size); | |
| 38 | − set_real_mode_mem(mem); | |
| 39 | − crash_reserve_low_1M(); | |
| 37 | + /* | |
| 38 | + * Unconditionally reserve the entire fisrt 1M, see comment in | |
| 39 | + * setup_arch(). | |
| 40 | + */ | |
| 41 | + memblock_reserve(0, SZ_1M); | |
| 40 | 42 | } |
| 41 | 43 | |
| 42 | 44 | static void sme_sev_setup_real_mode(struct trampoline_header *th) |
| @@ -233,7 +233,8 @@ async_xor_offs(struct page *dest, unsigned int offset, · 232 unmodified lines | ||
| 233 | 233 | if (submit->flags & ASYNC_TX_XOR_DROP_DST) { |
| 234 | 234 | src_cnt--; |
| 235 | 235 | src_list++; |
| 236 | − src_offs++; | |
| 236 | + if (src_offs) | |
| 237 | + src_offs++; | |
| 237 | 238 | } |
| 238 | 239 | |
| 239 | 240 | /* wait for any prerequisite operations */ |
| @@ -285,6 +285,14 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) · 284 unmodified lines | ||
| 285 | 285 | } |
| 286 | 286 | break; |
| 287 | 287 | |
| 288 | + case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: | |
| 289 | + | |
| 290 | + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, | |
| 291 | + "***** Address handler %p\n", object)); | |
| 292 | + | |
| 293 | + acpi_os_delete_mutex(object->address_space.context_mutex); | |
| 294 | + break; | |
| 295 | + | |
| 288 | 296 | default: |
| 289 | 297 | |
| 290 | 298 | break; |
| @@ -330,32 +330,21 @@ static void acpi_bus_osc_negotiate_platform_control(void) · 329 unmodified lines | ||
| 330 | 330 | if (ACPI_FAILURE(acpi_run_osc(handle, &context))) |
| 331 | 331 | return; |
| 332 | 332 | |
| 333 | − capbuf_ret = context.ret.pointer; | |
| 334 | − if (context.ret.length <= OSC_SUPPORT_DWORD) { | |
| 335 | − kfree(context.ret.pointer); | |
| 336 | − return; | |
| 337 | − } | |
| 333 | + kfree(context.ret.pointer); | |
| 338 | 334 | |
| 339 | − /* | |
| 340 | − * Now run _OSC again with query flag clear and with the caps | |
| 341 | − * supported by both the OS and the platform. | |
| 342 | − */ | |
| 335 | + /* Now run _OSC again with query flag clear */ | |
| 343 | 336 | capbuf[OSC_QUERY_DWORD] = 0; |
| 344 | − capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD]; | |
| 345 | − kfree(context.ret.pointer); | |
| 346 | 337 | |
| 347 | 338 | if (ACPI_FAILURE(acpi_run_osc(handle, &context))) |
| 348 | 339 | return; |
| 349 | 340 | |
| 350 | 341 | capbuf_ret = context.ret.pointer; |
| 351 | − if (context.ret.length > OSC_SUPPORT_DWORD) { | |
| 352 | − osc_sb_apei_support_acked = | |
| 353 | − capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT; | |
| 354 | − osc_pc_lpi_support_confirmed = | |
| 355 | − capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT; | |
| 356 | − osc_sb_native_usb4_support_confirmed = | |
| 357 | − capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT; | |
| 358 | − } | |
| 342 | + osc_sb_apei_support_acked = | |
| 343 | + capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT; | |
| 344 | + osc_pc_lpi_support_confirmed = | |
| 345 | + capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT; | |
| 346 | + osc_sb_native_usb4_support_confirmed = | |
| 347 | + capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT; | |
| 359 | 348 | |
| 360 | 349 | kfree(context.ret.pointer); |
| 361 | 350 | } |
| @@ -1009,10 +1009,8 @@ static void acpi_sleep_hibernate_setup(void) · 1008 unmodified lines | ||
| 1009 | 1009 | return; |
| 1010 | 1010 | |
| 1011 | 1011 | acpi_get_table(ACPI_SIG_FACS, 1, (struct acpi_table_header **)&facs); |
| 1012 | − if (facs) { | |
| 1012 | + if (facs) | |
| 1013 | 1013 | s4_hardware_signature = facs->hardware_signature; |
| 1014 | − acpi_put_table((struct acpi_table_header *)facs); | |
| 1015 | − } | |
| 1016 | 1014 | } |
| 1017 | 1015 | #else /* !CONFIG_HIBERNATION */ |
| 1018 | 1016 | static inline void acpi_sleep_hibernate_setup(void) {} |
| @@ -218,14 +218,14 @@ static int memory_block_offline(struct memory_block *mem) · 217 unmodified lines | ||
| 218 | 218 | struct zone *zone; |
| 219 | 219 | int ret; |
| 220 | 220 | |
| 221 | − zone = page_zone(pfn_to_page(start_pfn)); | |
| 222 | − | |
| 223 | 221 | /* |
| 224 | 222 | * Unaccount before offlining, such that unpopulated zone and kthreads |
| 225 | 223 | * can properly be torn down in offline_pages(). |
| 226 | 224 | */ |
| 227 | − if (nr_vmemmap_pages) | |
| 225 | + if (nr_vmemmap_pages) { | |
| 226 | + zone = page_zone(pfn_to_page(start_pfn)); | |
| 228 | 227 | adjust_present_page_count(zone, -nr_vmemmap_pages); |
| 228 | + } | |
| 229 | 229 | |
| 230 | 230 | ret = offline_pages(start_pfn + nr_vmemmap_pages, |
| 231 | 231 | nr_pages - nr_vmemmap_pages); |
| @@ -1879,29 +1879,18 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode, · 1878 unmodified lines | ||
| 1879 | 1879 | |
| 1880 | 1880 | static int lo_open(struct block_device *bdev, fmode_t mode) |
| 1881 | 1881 | { |
| 1882 | − struct loop_device *lo; | |
| 1882 | + struct loop_device *lo = bdev->bd_disk->private_data; | |
| 1883 | 1883 | int err; |
| 1884 | 1884 | |
| 1885 | − /* | |
| 1886 | − * take loop_ctl_mutex to protect lo pointer from race with | |
| 1887 | − * loop_control_ioctl(LOOP_CTL_REMOVE), however, to reduce contention | |
| 1888 | − * release it prior to updating lo->lo_refcnt. | |
| 1889 | − */ | |
| 1890 | − err = mutex_lock_killable(&loop_ctl_mutex); | |
| 1891 | − if (err) | |
| 1892 | − return err; | |
| 1893 | − lo = bdev->bd_disk->private_data; | |
| 1894 | − if (!lo) { | |
| 1895 | − mutex_unlock(&loop_ctl_mutex); | |
| 1896 | − return -ENXIO; | |
| 1897 | − } | |
| 1898 | 1885 | err = mutex_lock_killable(&lo->lo_mutex); |
| 1899 | − mutex_unlock(&loop_ctl_mutex); | |
| 1900 | 1886 | if (err) |
| 1901 | 1887 | return err; |
| 1902 | − atomic_inc(&lo->lo_refcnt); | |
| 1888 | + if (lo->lo_state == Lo_deleting) | |
| 1889 | + err = -ENXIO; | |
| 1890 | + else | |
| 1891 | + atomic_inc(&lo->lo_refcnt); | |
| 1903 | 1892 | mutex_unlock(&lo->lo_mutex); |
| 1904 | − return 0; | |
| 1893 | + return err; | |
| 1905 | 1894 | } |
| 1906 | 1895 | |
| 1907 | 1896 | static void lo_release(struct gendisk *disk, fmode_t mode) |
| @@ -2285,7 +2274,7 @@ static long loop_control_ioctl(struct file *file, unsigned int cmd, · 377 unmodified lines | ||
| 2285 | 2274 | mutex_unlock(&lo->lo_mutex); |
| 2286 | 2275 | break; |
| 2287 | 2276 | } |
| 2288 | − lo->lo_disk->private_data = NULL; | |
| 2277 | + lo->lo_state = Lo_deleting; | |
| 2289 | 2278 | mutex_unlock(&lo->lo_mutex); |
| 2290 | 2279 | idr_remove(&loop_index_idr, lo->lo_number); |
| 2291 | 2280 | loop_remove(lo); |
| @@ -22,6 +22,7 @@ enum { · 21 unmodified lines | ||
| 22 | 22 | Lo_unbound, |
| 23 | 23 | Lo_bound, |
| 24 | 24 | Lo_rundown, |
| 25 | + Lo_deleting, | |
| 25 | 26 | }; |
| 26 | 27 | |
| 27 | 28 | struct loop_func_table; |
| @@ -388,6 +388,8 @@ static const struct usb_device_id blacklist_table[] = { · 387 unmodified lines | ||
| 388 | 388 | /* Realtek 8822CE Bluetooth devices */ |
| 389 | 389 | { USB_DEVICE(0x0bda, 0xb00c), .driver_info = BTUSB_REALTEK | |
| 390 | 390 | BTUSB_WIDEBAND_SPEECH }, |
| 391 | + { USB_DEVICE(0x0bda, 0xc822), .driver_info = BTUSB_REALTEK | | |
| 392 | + BTUSB_WIDEBAND_SPEECH }, | |
| 391 | 393 | |
| 392 | 394 | /* Realtek 8852AE Bluetooth devices */ |
| 393 | 395 | { USB_DEVICE(0x0bda, 0xc852), .driver_info = BTUSB_REALTEK | |
| @@ -2527,10 +2529,17 @@ static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev, · 2133 unmodified lines | ||
| 2527 | 2529 | } |
| 2528 | 2530 | |
| 2529 | 2531 | btusb_setup_intel_newgen_get_fw_name(ver, fwname, sizeof(fwname), "sfi"); |
| 2530 | − err = request_firmware(&fw, fwname, &hdev->dev); | |
| 2532 | + err = firmware_request_nowarn(&fw, fwname, &hdev->dev); | |
| 2531 | 2533 | if (err < 0) { |
| 2534 | + if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) { | |
| 2535 | + /* Firmware has already been loaded */ | |
| 2536 | + set_bit(BTUSB_FIRMWARE_LOADED, &data->flags); | |
| 2537 | + return 0; | |
| 2538 | + } | |
| 2539 | + | |
| 2532 | 2540 | bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)", |
| 2533 | 2541 | fwname, err); |
| 2542 | + | |
| 2534 | 2543 | return err; |
| 2535 | 2544 | } |
| 2536 | 2545 | |
| @@ -2680,12 +2689,24 @@ download: · 143 unmodified lines | ||
| 2680 | 2689 | err = btusb_setup_intel_new_get_fw_name(ver, params, fwname, |
| 2681 | 2690 | sizeof(fwname), "sfi"); |
| 2682 | 2691 | if (err < 0) { |
| 2692 | + if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) { | |
| 2693 | + /* Firmware has already been loaded */ | |
| 2694 | + set_bit(BTUSB_FIRMWARE_LOADED, &data->flags); | |
| 2695 | + return 0; | |
| 2696 | + } | |
| 2697 | + | |
| 2683 | 2698 | bt_dev_err(hdev, "Unsupported Intel firmware naming"); |
| 2684 | 2699 | return -EINVAL; |
| 2685 | 2700 | } |
| 2686 | 2701 | |
| 2687 | − err = request_firmware(&fw, fwname, &hdev->dev); | |
| 2702 | + err = firmware_request_nowarn(&fw, fwname, &hdev->dev); | |
| 2688 | 2703 | if (err < 0) { |
| 2704 | + if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) { | |
| 2705 | + /* Firmware has already been loaded */ | |
| 2706 | + set_bit(BTUSB_FIRMWARE_LOADED, &data->flags); | |
| 2707 | + return 0; | |
| 2708 | + } | |
| 2709 | + | |
| 2689 | 2710 | bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)", |
| 2690 | 2711 | fwname, err); |
| 2691 | 2712 | return err; |
| @@ -311,8 +311,8 @@ static const struct mhi_channel_config mhi_foxconn_sdx55_channels[] = { · 310 unmodified lines | ||
| 311 | 311 | MHI_CHANNEL_CONFIG_DL(5, "DIAG", 32, 1), |
| 312 | 312 | MHI_CHANNEL_CONFIG_UL(12, "MBIM", 32, 0), |
| 313 | 313 | MHI_CHANNEL_CONFIG_DL(13, "MBIM", 32, 0), |
| 314 | − MHI_CHANNEL_CONFIG_UL(32, "AT", 32, 0), | |
| 315 | − MHI_CHANNEL_CONFIG_DL(33, "AT", 32, 0), | |
| 314 | + MHI_CHANNEL_CONFIG_UL(32, "DUN", 32, 0), | |
| 315 | + MHI_CHANNEL_CONFIG_DL(33, "DUN", 32, 0), | |
| 316 | 316 | MHI_CHANNEL_CONFIG_HW_UL(100, "IP_HW0_MBIM", 128, 2), |
| 317 | 317 | MHI_CHANNEL_CONFIG_HW_DL(101, "IP_HW0_MBIM", 128, 3), |
| 318 | 318 | }; |
| @@ -708,7 +708,7 @@ static void mhi_pci_remove(struct pci_dev *pdev) · 389 unmodified lines | ||
| 708 | 708 | struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev); |
| 709 | 709 | struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl; |
| 710 | 710 | |
| 711 | − del_timer(&mhi_pdev->health_check_timer); | |
| 711 | + del_timer_sync(&mhi_pdev->health_check_timer); | |
| 712 | 712 | cancel_work_sync(&mhi_pdev->recovery_work); |
| 713 | 713 | |
| 714 | 714 | if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) { |
| @@ -935,9 +935,43 @@ static int __maybe_unused mhi_pci_resume(struct device *dev) · 220 unmodified lines | ||
| 935 | 935 | return ret; |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | +static int __maybe_unused mhi_pci_freeze(struct device *dev) | |
| 939 | +{ | |
| 940 | + struct mhi_pci_device *mhi_pdev = dev_get_drvdata(dev); | |
| 941 | + struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl; | |
| 942 | + | |
| 943 | + /* We want to stop all operations, hibernation does not guarantee that | |
| 944 | + * device will be in the same state as before freezing, especially if | |
| 945 | + * the intermediate restore kernel reinitializes MHI device with new | |
| 946 | + * context. | |
| 947 | + */ | |
| 948 | + if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) { | |
| 949 | + mhi_power_down(mhi_cntrl, false); | |
| 950 | + mhi_unprepare_after_power_down(mhi_cntrl); | |
| 951 | + } | |
| 952 | + | |
| 953 | + return 0; | |
| 954 | +} | |
| 955 | + | |
| 956 | +static int __maybe_unused mhi_pci_restore(struct device *dev) | |
| 957 | +{ | |
| 958 | + struct mhi_pci_device *mhi_pdev = dev_get_drvdata(dev); | |
| 959 | + | |
| 960 | + /* Reinitialize the device */ | |
| 961 | + queue_work(system_long_wq, &mhi_pdev->recovery_work); | |
| 962 | + | |
| 963 | + return 0; | |
| 964 | +} | |
| 965 | + | |
| 938 | 966 | static const struct dev_pm_ops mhi_pci_pm_ops = { |
| 939 | 967 | SET_RUNTIME_PM_OPS(mhi_pci_runtime_suspend, mhi_pci_runtime_resume, NULL) |
| 940 | − SET_SYSTEM_SLEEP_PM_OPS(mhi_pci_suspend, mhi_pci_resume) | |
| 968 | +#ifdef CONFIG_PM_SLEEP | |
| 969 | + .suspend = mhi_pci_suspend, | |
| 970 | + .resume = mhi_pci_resume, | |
| 971 | + .freeze = mhi_pci_freeze, | |
| 972 | + .thaw = mhi_pci_restore, | |
| 973 | + .restore = mhi_pci_restore, | |
| 974 | +#endif | |
| 941 | 975 | }; |
| 942 | 976 | |
| 943 | 977 | static struct pci_driver mhi_pci_driver = { |
| @@ -1334,6 +1334,34 @@ err_allow_idle: · 1333 unmodified lines | ||
| 1334 | 1334 | return error; |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | +static int sysc_reinit_module(struct sysc *ddata, bool leave_enabled) | |
| 1338 | +{ | |
| 1339 | + struct device *dev = ddata->dev; | |
| 1340 | + int error; | |
| 1341 | + | |
| 1342 | + /* Disable target module if it is enabled */ | |
| 1343 | + if (ddata->enabled) { | |
| 1344 | + error = sysc_runtime_suspend(dev); | |
| 1345 | + if (error) | |
| 1346 | + dev_warn(dev, "reinit suspend failed: %i\n", error); | |
| 1347 | + } | |
| 1348 | + | |
| 1349 | + /* Enable target module */ | |
| 1350 | + error = sysc_runtime_resume(dev); | |
| 1351 | + if (error) | |
| 1352 | + dev_warn(dev, "reinit resume failed: %i\n", error); | |
| 1353 | + | |
| 1354 | + if (leave_enabled) | |
| 1355 | + return error; | |
| 1356 | + | |
| 1357 | + /* Disable target module if no leave_enabled was set */ | |
| 1358 | + error = sysc_runtime_suspend(dev); | |
| 1359 | + if (error) | |
| 1360 | + dev_warn(dev, "reinit suspend failed: %i\n", error); | |
| 1361 | + | |
| 1362 | + return error; | |
| 1363 | +} | |
| 1364 | + | |
| 1337 | 1365 | static int __maybe_unused sysc_noirq_suspend(struct device *dev) |
| 1338 | 1366 | { |
| 1339 | 1367 | struct sysc *ddata; |
| @@ -1344,12 +1372,18 @@ static int __maybe_unused sysc_noirq_suspend(struct device *dev) · 4 unmodified lines | ||
| 1344 | 1372 | (SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_NO_IDLE)) |
| 1345 | 1373 | return 0; |
| 1346 | 1374 | |
| 1347 | − return pm_runtime_force_suspend(dev); | |
| 1375 | + if (!ddata->enabled) | |
| 1376 | + return 0; | |
| 1377 | + | |
| 1378 | + ddata->needs_resume = 1; | |
| 1379 | + | |
| 1380 | + return sysc_runtime_suspend(dev); | |
| 1348 | 1381 | } |
| 1349 | 1382 | |
| 1350 | 1383 | static int __maybe_unused sysc_noirq_resume(struct device *dev) |
| 1351 | 1384 | { |
| 1352 | 1385 | struct sysc *ddata; |
| 1386 | + int error = 0; | |
| 1353 | 1387 | |
| 1354 | 1388 | ddata = dev_get_drvdata(dev); |
| 1355 | 1389 | |
| @@ -1357,7 +1391,19 @@ static int __maybe_unused sysc_noirq_resume(struct device *dev) · 1 unmodified line | ||
| 1357 | 1391 | (SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_NO_IDLE)) |
| 1358 | 1392 | return 0; |
| 1359 | 1393 | |
| 1360 | − return pm_runtime_force_resume(dev); | |
| 1394 | + if (ddata->cfg.quirks & SYSC_QUIRK_REINIT_ON_RESUME) { | |
| 1395 | + error = sysc_reinit_module(ddata, ddata->needs_resume); | |
| 1396 | + if (error) | |
| 1397 | + dev_warn(dev, "noirq_resume failed: %i\n", error); | |
| 1398 | + } else if (ddata->needs_resume) { | |
| 1399 | + error = sysc_runtime_resume(dev); | |
| 1400 | + if (error) | |
| 1401 | + dev_warn(dev, "noirq_resume failed: %i\n", error); | |
| 1402 | + } | |
| 1403 | + | |
| 1404 | + ddata->needs_resume = 0; | |
| 1405 | + | |
| 1406 | + return error; | |
| 1361 | 1407 | } |
| 1362 | 1408 | |
| 1363 | 1409 | static const struct dev_pm_ops sysc_pm_ops = { |
| @@ -1408,9 +1454,9 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = { · 44 unmodified lines | ||
| 1408 | 1454 | SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE), |
| 1409 | 1455 | /* Uarts on omap4 and later */ |
| 1410 | 1456 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffff00ff, |
| 1411 | − SYSC_QUIRK_SWSUP_SIDLE_ACT | SYSC_QUIRK_LEGACY_IDLE), | |
| 1457 | + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE), | |
| 1412 | 1458 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47422e03, 0xffffffff, |
| 1413 | − SYSC_QUIRK_SWSUP_SIDLE_ACT | SYSC_QUIRK_LEGACY_IDLE), | |
| 1459 | + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE), | |
| 1414 | 1460 | |
| 1415 | 1461 | /* Quirks that need to be set based on the module address */ |
| 1416 | 1462 | SYSC_QUIRK("mcpdm", 0x40132000, 0, 0x10, -ENODEV, 0x50000800, 0xffffffff, |
| @@ -1459,6 +1505,8 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = { · 42 unmodified lines | ||
| 1459 | 1505 | SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), |
| 1460 | 1506 | SYSC_QUIRK("tptc", 0, 0, -ENODEV, -ENODEV, 0x40007c00, 0xffffffff, |
| 1461 | 1507 | SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), |
| 1508 | + SYSC_QUIRK("sata", 0, 0xfc, 0x1100, -ENODEV, 0x5e412000, 0xffffffff, | |
| 1509 | + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), | |
| 1462 | 1510 | SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, |
| 1463 | 1511 | SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), |
| 1464 | 1512 | SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -ENODEV, 0x50700101, 0xffffffff, |
| @@ -1466,7 +1514,8 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = { · 1 unmodified line | ||
| 1466 | 1514 | SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050, |
| 1467 | 1515 | 0xffffffff, SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), |
| 1468 | 1516 | SYSC_QUIRK("usb_otg_hs", 0, 0, 0x10, -ENODEV, 0x4ea2080d, 0xffffffff, |
| 1469 | − SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), | |
| 1517 | + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY | | |
| 1518 | + SYSC_QUIRK_REINIT_ON_RESUME), | |
| 1470 | 1519 | SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, |
| 1471 | 1520 | SYSC_MODULE_QUIRK_WDT), |
| 1472 | 1521 | /* PRUSS on am3, am4 and am5 */ |
| @@ -1524,7 +1573,6 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = { · 51 unmodified lines | ||
| 1524 | 1573 | SYSC_QUIRK("prcm", 0, 0, -ENODEV, -ENODEV, 0x40000400, 0xffffffff, 0), |
| 1525 | 1574 | SYSC_QUIRK("rfbi", 0x4832a800, 0, 0x10, 0x14, 0x00000010, 0xffffffff, 0), |
| 1526 | 1575 | SYSC_QUIRK("rfbi", 0x58002000, 0, 0x10, 0x14, 0x00000010, 0xffffffff, 0), |
| 1527 | − SYSC_QUIRK("sata", 0, 0xfc, 0x1100, -ENODEV, 0x5e412000, 0xffffffff, 0), | |
| 1528 | 1576 | SYSC_QUIRK("scm", 0, 0, 0x10, -ENODEV, 0x40000900, 0xffffffff, 0), |
| 1529 | 1577 | SYSC_QUIRK("scm", 0, 0, -ENODEV, -ENODEV, 0x4e8b0100, 0xffffffff, 0), |
| 1530 | 1578 | SYSC_QUIRK("scm", 0, 0, -ENODEV, -ENODEV, 0x4f000100, 0xffffffff, 0), |
| @@ -745,12 +745,12 @@ static int __init idxd_init_module(void) · 744 unmodified lines | ||
| 745 | 745 | * If the CPU does not support MOVDIR64B or ENQCMDS, there's no point in |
| 746 | 746 | * enumerating the device. We can not utilize it. |
| 747 | 747 | */ |
| 748 | − if (!boot_cpu_has(X86_FEATURE_MOVDIR64B)) { | |
| 748 | + if (!cpu_feature_enabled(X86_FEATURE_MOVDIR64B)) { | |
| 749 | 749 | pr_warn("idxd driver failed to load without MOVDIR64B.\n"); |
| 750 | 750 | return -ENODEV; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | − if (!boot_cpu_has(X86_FEATURE_ENQCMD)) | |
| 753 | + if (!cpu_feature_enabled(X86_FEATURE_ENQCMD)) | |
| 754 | 754 | pr_warn("Platform does not have ENQCMD(S) support.\n"); |
| 755 | 755 | else |
| 756 | 756 | support_enqcmd = true; |
| @@ -276,8 +276,7 @@ static int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg) · 275 unmodified lines | ||
| 276 | 276 | if (!msg || !(mem->validation_bits & CPER_MEM_VALID_MODULE_HANDLE)) |
| 277 | 277 | return 0; |
| 278 | 278 | |
| 279 | − n = 0; | |
| 280 | − len = CPER_REC_LEN - 1; | |
| 279 | + len = CPER_REC_LEN; | |
| 281 | 280 | dmi_memdev_name(mem->mem_dev_handle, &bank, &device); |
| 282 | 281 | if (bank && device) |
| 283 | 282 | n = snprintf(msg, len, "DIMM location: %s %s ", bank, device); |
| @@ -286,7 +285,6 @@ static int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg) · 2 unmodified lines | ||
| 286 | 285 | "DIMM location: not present. DMI handle: 0x%.4x ", |
| 287 | 286 | mem->mem_dev_handle); |
| 288 | 287 | |
| 289 | − msg[n] = '\0'; | |
| 290 | 288 | return n; |
| 291 | 289 | } |
| 292 | 290 | |
| @@ -98,6 +98,9 @@ u64 __init efi_get_fdt_params(struct efi_memory_map_data *mm) · 97 unmodified lines | ||
| 98 | 98 | BUILD_BUG_ON(ARRAY_SIZE(target) != ARRAY_SIZE(name)); |
| 99 | 99 | BUILD_BUG_ON(ARRAY_SIZE(target) != ARRAY_SIZE(dt_params[0].params)); |
| 100 | 100 | |
| 101 | + if (!fdt) | |
| 102 | + return 0; | |
| 103 | + | |
| 101 | 104 | for (i = 0; i < ARRAY_SIZE(dt_params); i++) { |
| 102 | 105 | node = fdt_path_offset(fdt, dt_params[i].path); |
| 103 | 106 | if (node < 0) |
| @@ -103,7 +103,7 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len, · 102 unmodified lines | ||
| 103 | 103 | return 0; |
| 104 | 104 | |
| 105 | 105 | /* Skip any leading slashes */ |
| 106 | − while (cmdline[i] == L'/' || cmdline[i] == L'\\') | |
| 106 | + while (i < cmdline_len && (cmdline[i] == L'/' || cmdline[i] == L'\\')) | |
| 107 | 107 | i++; |
| 108 | 108 | |
| 109 | 109 | while (--result_len > 0 && i < cmdline_len) { |
| @@ -67,11 +67,6 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out) · 66 unmodified lines | ||
| 67 | 67 | return false; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | − if (!(in->attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP))) { | |
| 71 | − pr_warn("Entry attributes invalid: RO and XP bits both cleared\n"); | |
| 72 | − return false; | |
| 73 | − } | |
| 74 | − | |
| 75 | 70 | if (PAGE_SIZE > EFI_PAGE_SIZE && |
| 76 | 71 | (!PAGE_ALIGNED(in->phys_addr) || |
| 77 | 72 | !PAGE_ALIGNED(in->num_pages << EFI_PAGE_SHIFT))) { |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | #include <linux/slab.h> |
| 8 | 8 | #include <linux/of_device.h> |
| 9 | 9 | |
| 10 | −#define WCD_PIN_MASK(p) BIT(p - 1) | |
| 10 | +#define WCD_PIN_MASK(p) BIT(p) | |
| 11 | 11 | #define WCD_REG_DIR_CTL_OFFSET 0x42 |
| 12 | 12 | #define WCD_REG_VAL_CTL_OFFSET 0x43 |
| 13 | 13 | #define WCD934X_NPINS 5 |
| @@ -337,7 +337,6 @@ static int amdgpu_ctx_query2(struct amdgpu_device *adev, · 336 unmodified lines | ||
| 337 | 337 | { |
| 338 | 338 | struct amdgpu_ctx *ctx; |
| 339 | 339 | struct amdgpu_ctx_mgr *mgr; |
| 340 | − unsigned long ras_counter; | |
| 341 | 340 | |
| 342 | 341 | if (!fpriv) |
| 343 | 342 | return -EINVAL; |
| @@ -362,21 +361,6 @@ static int amdgpu_ctx_query2(struct amdgpu_device *adev, · 18 unmodified lines | ||
| 362 | 361 | if (atomic_read(&ctx->guilty)) |
| 363 | 362 | out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_GUILTY; |
| 364 | 363 | |
| 365 | − /*query ue count*/ | |
| 366 | − ras_counter = amdgpu_ras_query_error_count(adev, false); | |
| 367 | − /*ras counter is monotonic increasing*/ | |
| 368 | − if (ras_counter != ctx->ras_counter_ue) { | |
| 369 | − out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_RAS_UE; | |
| 370 | − ctx->ras_counter_ue = ras_counter; | |
| 371 | − } | |
| 372 | − | |
| 373 | − /*query ce count*/ | |
| 374 | − ras_counter = amdgpu_ras_query_error_count(adev, true); | |
| 375 | − if (ras_counter != ctx->ras_counter_ce) { | |
| 376 | − out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_RAS_CE; | |
| 377 | − ctx->ras_counter_ce = ras_counter; | |
| 378 | − } | |
| 379 | − | |
| 380 | 364 | mutex_unlock(&mgr->lock); |
| 381 | 365 | return 0; |
| 382 | 366 | } |
| @@ -3118,7 +3118,9 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type) · 3117 unmodified lines | ||
| 3118 | 3118 | */ |
| 3119 | 3119 | bool amdgpu_device_has_dc_support(struct amdgpu_device *adev) |
| 3120 | 3120 | { |
| 3121 | − if (amdgpu_sriov_vf(adev) || adev->enable_virtual_display) | |
| 3121 | + if (amdgpu_sriov_vf(adev) || | |
| 3122 | + adev->enable_virtual_display || | |
| 3123 | + (adev->harvest_ip_mask & AMD_HARVEST_IP_DMU_MASK)) | |
| 3122 | 3124 | return false; |
| 3123 | 3125 | |
| 3124 | 3126 | return amdgpu_device_asic_has_dc_support(adev->asic_type); |
| @@ -1057,7 +1057,7 @@ int amdgpu_display_gem_fb_init(struct drm_device *dev, · 1056 unmodified lines | ||
| 1057 | 1057 | |
| 1058 | 1058 | return 0; |
| 1059 | 1059 | err: |
| 1060 | − drm_err(dev, "Failed to init gem fb: %d\n", ret); | |
| 1060 | + drm_dbg_kms(dev, "Failed to init gem fb: %d\n", ret); | |
| 1061 | 1061 | rfb->base.obj[0] = NULL; |
| 1062 | 1062 | return ret; |
| 1063 | 1063 | } |
| @@ -1094,7 +1094,7 @@ int amdgpu_display_gem_fb_verify_and_init( · 30 unmodified lines | ||
| 1094 | 1094 | |
| 1095 | 1095 | return 0; |
| 1096 | 1096 | err: |
| 1097 | − drm_err(dev, "Failed to verify and init gem fb: %d\n", ret); | |
| 1097 | + drm_dbg_kms(dev, "Failed to verify and init gem fb: %d\n", ret); | |
| 1098 | 1098 | rfb->base.obj[0] = NULL; |
| 1099 | 1099 | return ret; |
| 1100 | 1100 | } |
| @@ -101,7 +101,8 @@ static int amdgpu_fru_read_eeprom(struct amdgpu_device *adev, uint32_t addrptr, · 100 unmodified lines | ||
| 101 | 101 | int amdgpu_fru_get_product_info(struct amdgpu_device *adev) |
| 102 | 102 | { |
| 103 | 103 | unsigned char buff[34]; |
| 104 | − int addrptr = 0, size = 0; | |
| 104 | + int addrptr, size; | |
| 105 | + int len; | |
| 105 | 106 | |
| 106 | 107 | if (!is_fru_eeprom_supported(adev)) |
| 107 | 108 | return 0; |
| @@ -109,7 +110,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) · 1 unmodified line | ||
| 109 | 110 | /* If algo exists, it means that the i2c_adapter's initialized */ |
| 110 | 111 | if (!adev->pm.smu_i2c.algo) { |
| 111 | 112 | DRM_WARN("Cannot access FRU, EEPROM accessor not initialized"); |
| 112 | − return 0; | |
| 113 | + return -ENODEV; | |
| 113 | 114 | } |
| 114 | 115 | |
| 115 | 116 | /* There's a lot of repetition here. This is due to the FRU having |
| @@ -128,7 +129,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) · 12 unmodified lines | ||
| 128 | 129 | size = amdgpu_fru_read_eeprom(adev, addrptr, buff); |
| 129 | 130 | if (size < 1) { |
| 130 | 131 | DRM_ERROR("Failed to read FRU Manufacturer, ret:%d", size); |
| 131 | − return size; | |
| 132 | + return -EINVAL; | |
| 132 | 133 | } |
| 133 | 134 | |
| 134 | 135 | /* Increment the addrptr by the size of the field, and 1 due to the |
| @@ -138,43 +139,45 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) · 3 unmodified lines | ||
| 138 | 139 | size = amdgpu_fru_read_eeprom(adev, addrptr, buff); |
| 139 | 140 | if (size < 1) { |
| 140 | 141 | DRM_ERROR("Failed to read FRU product name, ret:%d", size); |
| 141 | − return size; | |
| 142 | + return -EINVAL; | |
| 142 | 143 | } |
| 143 | 144 | |
| 145 | + len = size; | |
| 144 | 146 | /* Product name should only be 32 characters. Any more, |
| 145 | 147 | * and something could be wrong. Cap it at 32 to be safe |
| 146 | 148 | */ |
| 147 | − if (size > 32) { | |
| 149 | + if (len >= sizeof(adev->product_name)) { | |
| 148 | 150 | DRM_WARN("FRU Product Number is larger than 32 characters. This is likely a mistake"); |
| 149 | − size = 32; | |
| 151 | + len = sizeof(adev->product_name) - 1; | |
| 150 | 152 | } |
| 151 | 153 | /* Start at 2 due to buff using fields 0 and 1 for the address */ |
| 152 | − memcpy(adev->product_name, &buff[2], size); | |
| 153 | − adev->product_name[size] = '\0'; | |
| 154 | + memcpy(adev->product_name, &buff[2], len); | |
| 155 | + adev->product_name[len] = '\0'; | |
| 154 | 156 | |
| 155 | 157 | addrptr += size + 1; |
| 156 | 158 | size = amdgpu_fru_read_eeprom(adev, addrptr, buff); |
| 157 | 159 | if (size < 1) { |
| 158 | 160 | DRM_ERROR("Failed to read FRU product number, ret:%d", size); |
| 159 | − return size; | |
| 161 | + return -EINVAL; | |
| 160 | 162 | } |
| 161 | 163 | |
| 164 | + len = size; | |
| 162 | 165 | /* Product number should only be 16 characters. Any more, |
| 163 | 166 | * and something could be wrong. Cap it at 16 to be safe |
| 164 | 167 | */ |
| 165 | − if (size > 16) { | |
| 168 | + if (len >= sizeof(adev->product_number)) { | |
| 166 | 169 | DRM_WARN("FRU Product Number is larger than 16 characters. This is likely a mistake"); |
| 167 | − size = 16; | |
| 170 | + len = sizeof(adev->product_number) - 1; | |
| 168 | 171 | } |
| 169 | − memcpy(adev->product_number, &buff[2], size); | |
| 170 | − adev->product_number[size] = '\0'; | |
| 172 | + memcpy(adev->product_number, &buff[2], len); | |
| 173 | + adev->product_number[len] = '\0'; | |
| 171 | 174 | |
| 172 | 175 | addrptr += size + 1; |
| 173 | 176 | size = amdgpu_fru_read_eeprom(adev, addrptr, buff); |
| 174 | 177 | |
| 175 | 178 | if (size < 1) { |
| 176 | 179 | DRM_ERROR("Failed to read FRU product version, ret:%d", size); |
| 177 | − return size; | |
| 180 | + return -EINVAL; | |
| 178 | 181 | } |
| 179 | 182 | |
| 180 | 183 | addrptr += size + 1; |
| @@ -182,18 +185,19 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) · 1 unmodified line | ||
| 182 | 185 | |
| 183 | 186 | if (size < 1) { |
| 184 | 187 | DRM_ERROR("Failed to read FRU serial number, ret:%d", size); |
| 185 | − return size; | |
| 188 | + return -EINVAL; | |
| 186 | 189 | } |
| 187 | 190 | |
| 191 | + len = size; | |
| 188 | 192 | /* Serial number should only be 16 characters. Any more, |
| 189 | 193 | * and something could be wrong. Cap it at 16 to be safe |
| 190 | 194 | */ |
| 191 | − if (size > 16) { | |
| 195 | + if (len >= sizeof(adev->serial)) { | |
| 192 | 196 | DRM_WARN("FRU Serial Number is larger than 16 characters. This is likely a mistake"); |
| 193 | − size = 16; | |
| 197 | + len = sizeof(adev->serial) - 1; | |
| 194 | 198 | } |
| 195 | − memcpy(adev->serial, &buff[2], size); | |
| 196 | − adev->serial[size] = '\0'; | |
| 199 | + memcpy(adev->serial, &buff[2], len); | |
| 200 | + adev->serial[len] = '\0'; | |
| 197 | 201 | |
| 198 | 202 | return 0; |
| 199 | 203 | } |
| @@ -100,7 +100,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) · 99 unmodified lines | ||
| 100 | 100 | kfree(ubo->metadata); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | − kfree(bo); | |
| 103 | + kvfree(bo); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| @@ -552,7 +552,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, · 445 unmodified lines | ||
| 552 | 552 | BUG_ON(bp->bo_ptr_size < sizeof(struct amdgpu_bo)); |
| 553 | 553 | |
| 554 | 554 | *bo_ptr = NULL; |
| 555 | − bo = kzalloc(bp->bo_ptr_size, GFP_KERNEL); | |
| 555 | + bo = kvzalloc(bp->bo_ptr_size, GFP_KERNEL); | |
| 556 | 556 | if (bo == NULL) |
| 557 | 557 | return -ENOMEM; |
| 558 | 558 | drm_gem_private_object_init(adev_to_drm(adev), &bo->tbo.base, size); |
| @@ -76,6 +76,7 @@ struct psp_ring · 75 unmodified lines | ||
| 76 | 76 | uint64_t ring_mem_mc_addr; |
| 77 | 77 | void *ring_mem_handle; |
| 78 | 78 | uint32_t ring_size; |
| 79 | + uint32_t ring_wptr; | |
| 79 | 80 | }; |
| 80 | 81 | |
| 81 | 82 | /* More registers may will be supported */ |
| @@ -173,6 +173,9 @@ · 172 unmodified lines | ||
| 173 | 173 | #define mmGC_THROTTLE_CTRL_Sienna_Cichlid 0x2030 |
| 174 | 174 | #define mmGC_THROTTLE_CTRL_Sienna_Cichlid_BASE_IDX 0 |
| 175 | 175 | |
| 176 | +#define mmRLC_SPARE_INT_0_Sienna_Cichlid 0x4ca5 | |
| 177 | +#define mmRLC_SPARE_INT_0_Sienna_Cichlid_BASE_IDX 1 | |
| 178 | + | |
| 176 | 179 | #define GFX_RLCG_GC_WRITE_OLD (0x8 << 28) |
| 177 | 180 | #define GFX_RLCG_GC_WRITE (0x0 << 28) |
| 178 | 181 | #define GFX_RLCG_GC_READ (0x1 << 28) |
| @@ -1480,8 +1483,15 @@ static u32 gfx_v10_rlcg_rw(struct amdgpu_device *adev, u32 offset, u32 v, uint32 · 1301 unmodified lines | ||
| 1480 | 1483 | (adev->reg_offset[GC_HWIP][0][mmSCRATCH_REG0_BASE_IDX] + mmSCRATCH_REG2) * 4; |
| 1481 | 1484 | scratch_reg3 = adev->rmmio + |
| 1482 | 1485 | (adev->reg_offset[GC_HWIP][0][mmSCRATCH_REG1_BASE_IDX] + mmSCRATCH_REG3) * 4; |
| 1483 | − spare_int = adev->rmmio + | |
| 1484 | − (adev->reg_offset[GC_HWIP][0][mmRLC_SPARE_INT_BASE_IDX] + mmRLC_SPARE_INT) * 4; | |
| 1486 | + | |
| 1487 | + if (adev->asic_type >= CHIP_SIENNA_CICHLID) { | |
| 1488 | + spare_int = adev->rmmio + | |
| 1489 | + (adev->reg_offset[GC_HWIP][0][mmRLC_SPARE_INT_0_Sienna_Cichlid_BASE_IDX] | |
| 1490 | + + mmRLC_SPARE_INT_0_Sienna_Cichlid) * 4; | |
| 1491 | + } else { | |
| 1492 | + spare_int = adev->rmmio + | |
| 1493 | + (adev->reg_offset[GC_HWIP][0][mmRLC_SPARE_INT_BASE_IDX] + mmRLC_SPARE_INT) * 4; | |
| 1494 | + } | |
| 1485 | 1495 | |
| 1486 | 1496 | grbm_cntl = adev->reg_offset[GC_HWIP][0][mmGRBM_GFX_CNTL_BASE_IDX] + mmGRBM_GFX_CNTL; |
| 1487 | 1497 | grbm_idx = adev->reg_offset[GC_HWIP][0][mmGRBM_GFX_INDEX_BASE_IDX] + mmGRBM_GFX_INDEX; |
| @@ -7349,9 +7359,15 @@ static int gfx_v10_0_hw_fini(void *handle) · 5861 unmodified lines | ||
| 7349 | 7359 | if (amdgpu_sriov_vf(adev)) { |
| 7350 | 7360 | gfx_v10_0_cp_gfx_enable(adev, false); |
| 7351 | 7361 | /* Program KIQ position of RLC_CP_SCHEDULERS during destroy */ |
| 7352 | − tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS); | |
| 7353 | − tmp &= 0xffffff00; | |
| 7354 | − WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp); | |
| 7362 | + if (adev->asic_type >= CHIP_SIENNA_CICHLID) { | |
| 7363 | + tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS_Sienna_Cichlid); | |
| 7364 | + tmp &= 0xffffff00; | |
| 7365 | + WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS_Sienna_Cichlid, tmp); | |
| 7366 | + } else { | |
| 7367 | + tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS); | |
| 7368 | + tmp &= 0xffffff00; | |
| 7369 | + WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp); | |
| 7370 | + } | |
| 7355 | 7371 | |
| 7356 | 7372 | return 0; |
| 7357 | 7373 | } |
| @@ -720,7 +720,7 @@ static uint32_t psp_v11_0_ring_get_wptr(struct psp_context *psp) · 719 unmodified lines | ||
| 720 | 720 | struct amdgpu_device *adev = psp->adev; |
| 721 | 721 | |
| 722 | 722 | if (amdgpu_sriov_vf(adev)) |
| 723 | − data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102); | |
| 723 | + data = psp->km_ring.ring_wptr; | |
| 724 | 724 | else |
| 725 | 725 | data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67); |
| 726 | 726 | |
| @@ -734,6 +734,7 @@ static void psp_v11_0_ring_set_wptr(struct psp_context *psp, uint32_t value) · 7 unmodified lines | ||
| 734 | 734 | if (amdgpu_sriov_vf(adev)) { |
| 735 | 735 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102, value); |
| 736 | 736 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_101, GFX_CTRL_CMD_ID_CONSUME_CMD); |
| 737 | + psp->km_ring.ring_wptr = value; | |
| 737 | 738 | } else |
| 738 | 739 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67, value); |
| 739 | 740 | } |
| @@ -379,7 +379,7 @@ static uint32_t psp_v3_1_ring_get_wptr(struct psp_context *psp) · 378 unmodified lines | ||
| 379 | 379 | struct amdgpu_device *adev = psp->adev; |
| 380 | 380 | |
| 381 | 381 | if (amdgpu_sriov_vf(adev)) |
| 382 | − data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102); | |
| 382 | + data = psp->km_ring.ring_wptr; | |
| 383 | 383 | else |
| 384 | 384 | data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67); |
| 385 | 385 | return data; |
| @@ -394,6 +394,7 @@ static void psp_v3_1_ring_set_wptr(struct psp_context *psp, uint32_t value) · 8 unmodified lines | ||
| 394 | 394 | /* send interrupt to PSP for SRIOV ring write pointer update */ |
| 395 | 395 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_101, |
| 396 | 396 | GFX_CTRL_CMD_ID_CONSUME_CMD); |
| 397 | + psp->km_ring.ring_wptr = value; | |
| 397 | 398 | } else |
| 398 | 399 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67, value); |
| 399 | 400 | } |
| @@ -357,6 +357,7 @@ static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 356 unmodified lines | ||
| 357 | 357 | |
| 358 | 358 | error: |
| 359 | 359 | dma_fence_put(fence); |
| 360 | + amdgpu_bo_unpin(bo); | |
| 360 | 361 | amdgpu_bo_unreserve(bo); |
| 361 | 362 | amdgpu_bo_unref(&bo); |
| 362 | 363 | return r; |
| @@ -925,7 +925,8 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev) · 924 unmodified lines | ||
| 925 | 925 | abm->dmcu_is_running = dmcu->funcs->is_dmcu_initialized(dmcu); |
| 926 | 926 | } |
| 927 | 927 | |
| 928 | − adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv); | |
| 928 | + if (!adev->dm.dc->ctx->dmub_srv) | |
| 929 | + adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv); | |
| 929 | 930 | if (!adev->dm.dc->ctx->dmub_srv) { |
| 930 | 931 | DRM_ERROR("Couldn't allocate DC DMUB server!\n"); |
| 931 | 932 | return -ENOMEM; |
| @@ -1954,7 +1955,6 @@ static int dm_suspend(void *handle) · 1022 unmodified lines | ||
| 1954 | 1955 | |
| 1955 | 1956 | amdgpu_dm_irq_suspend(adev); |
| 1956 | 1957 | |
| 1957 | − | |
| 1958 | 1958 | dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3); |
| 1959 | 1959 | |
| 1960 | 1960 | return 0; |
| @@ -5500,7 +5500,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, · 3539 unmodified lines | ||
| 5500 | 5500 | struct drm_display_mode saved_mode; |
| 5501 | 5501 | struct drm_display_mode *freesync_mode = NULL; |
| 5502 | 5502 | bool native_mode_found = false; |
| 5503 | − bool recalculate_timing = dm_state ? (dm_state->scaling != RMX_OFF) : false; | |
| 5503 | + bool recalculate_timing = false; | |
| 5504 | + bool scale = dm_state ? (dm_state->scaling != RMX_OFF) : false; | |
| 5504 | 5505 | int mode_refresh; |
| 5505 | 5506 | int preferred_refresh = 0; |
| 5506 | 5507 | #if defined(CONFIG_DRM_AMD_DC_DCN) |
| @@ -5563,7 +5564,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, · 56 unmodified lines | ||
| 5563 | 5564 | */ |
| 5564 | 5565 | DRM_DEBUG_DRIVER("No preferred mode found\n"); |
| 5565 | 5566 | } else { |
| 5566 | − recalculate_timing |= amdgpu_freesync_vid_mode && | |
| 5567 | + recalculate_timing = amdgpu_freesync_vid_mode && | |
| 5567 | 5568 | is_freesync_video_mode(&mode, aconnector); |
| 5568 | 5569 | if (recalculate_timing) { |
| 5569 | 5570 | freesync_mode = get_highest_refresh_rate_mode(aconnector, false); |
| @@ -5571,11 +5572,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, · 1 unmodified line | ||
| 5571 | 5572 | mode = *freesync_mode; |
| 5572 | 5573 | } else { |
| 5573 | 5574 | decide_crtc_timing_for_drm_display_mode( |
| 5574 | − &mode, preferred_mode, | |
| 5575 | − dm_state ? (dm_state->scaling != RMX_OFF) : false); | |
| 5576 | − } | |
| 5575 | + &mode, preferred_mode, scale); | |
| 5577 | 5576 | |
| 5578 | − preferred_refresh = drm_mode_vrefresh(preferred_mode); | |
| 5577 | + preferred_refresh = drm_mode_vrefresh(preferred_mode); | |
| 5578 | + } | |
| 5579 | 5579 | } |
| 5580 | 5580 | |
| 5581 | 5581 | if (recalculate_timing) |
| @@ -5587,7 +5587,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, · 5 unmodified lines | ||
| 5587 | 5587 | * If scaling is enabled and refresh rate didn't change |
| 5588 | 5588 | * we copy the vic and polarities of the old timings |
| 5589 | 5589 | */ |
| 5590 | − if (!recalculate_timing || mode_refresh != preferred_refresh) | |
| 5590 | + if (!scale || mode_refresh != preferred_refresh) | |
| 5591 | 5591 | fill_stream_properties_from_drm_display_mode( |
| 5592 | 5592 | stream, &mode, &aconnector->base, con_state, NULL, |
| 5593 | 5593 | requested_bpc); |
| @@ -9854,7 +9854,7 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state, · 4260 unmodified lines | ||
| 9854 | 9854 | |
| 9855 | 9855 | if (cursor_scale_w != primary_scale_w || |
| 9856 | 9856 | cursor_scale_h != primary_scale_h) { |
| 9857 | − DRM_DEBUG_ATOMIC("Cursor plane scaling doesn't match primary plane\n"); | |
| 9857 | + drm_dbg_atomic(crtc->dev, "Cursor plane scaling doesn't match primary plane\n"); | |
| 9858 | 9858 | return -EINVAL; |
| 9859 | 9859 | } |
| 9860 | 9860 | |
| @@ -9891,7 +9891,7 @@ static int validate_overlay(struct drm_atomic_state *state) · 30 unmodified lines | ||
| 9891 | 9891 | int i; |
| 9892 | 9892 | struct drm_plane *plane; |
| 9893 | 9893 | struct drm_plane_state *old_plane_state, *new_plane_state; |
| 9894 | − struct drm_plane_state *primary_state, *overlay_state = NULL; | |
| 9894 | + struct drm_plane_state *primary_state, *cursor_state, *overlay_state = NULL; | |
| 9895 | 9895 | |
| 9896 | 9896 | /* Check if primary plane is contained inside overlay */ |
| 9897 | 9897 | for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) { |
| @@ -9921,6 +9921,14 @@ static int validate_overlay(struct drm_atomic_state *state) · 23 unmodified lines | ||
| 9921 | 9921 | if (!primary_state->crtc) |
| 9922 | 9922 | return 0; |
| 9923 | 9923 | |
| 9924 | + /* check if cursor plane is enabled */ | |
| 9925 | + cursor_state = drm_atomic_get_plane_state(state, overlay_state->crtc->cursor); | |
| 9926 | + if (IS_ERR(cursor_state)) | |
| 9927 | + return PTR_ERR(cursor_state); | |
| 9928 | + | |
| 9929 | + if (drm_atomic_plane_disabling(plane->state, cursor_state)) | |
| 9930 | + return 0; | |
| 9931 | + | |
| 9924 | 9932 | /* Perform the bounds check to ensure the overlay plane covers the primary */ |
| 9925 | 9933 | if (primary_state->crtc_x < overlay_state->crtc_x || |
| 9926 | 9934 | primary_state->crtc_y < overlay_state->crtc_y || |
| @@ -3236,7 +3236,7 @@ static noinline bool dcn20_validate_bandwidth_fp(struct dc *dc, · 3235 unmodified lines | ||
| 3236 | 3236 | voltage_supported = dcn20_validate_bandwidth_internal(dc, context, false); |
| 3237 | 3237 | dummy_pstate_supported = context->bw_ctx.bw.dcn.clk.p_state_change_support; |
| 3238 | 3238 | |
| 3239 | − if (voltage_supported && dummy_pstate_supported) { | |
| 3239 | + if (voltage_supported && (dummy_pstate_supported || !(context->stream_count))) { | |
| 3240 | 3240 | context->bw_ctx.bw.dcn.clk.p_state_change_support = false; |
| 3241 | 3241 | goto restore_dml_state; |
| 3242 | 3242 | } |
| @@ -810,6 +810,7 @@ static int smu10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, · 809 unmodified lines | ||
| 810 | 810 | break; |
| 811 | 811 | case AMD_DPM_FORCED_LEVEL_MANUAL: |
| 812 | 812 | data->fine_grain_enabled = 1; |
| 813 | + break; | |
| 813 | 814 | case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT: |
| 814 | 815 | default: |
| 815 | 816 | break; |
| @@ -314,9 +314,10 @@ int drm_master_open(struct drm_file *file_priv) · 313 unmodified lines | ||
| 314 | 314 | void drm_master_release(struct drm_file *file_priv) |
| 315 | 315 | { |
| 316 | 316 | struct drm_device *dev = file_priv->minor->dev; |
| 317 | − struct drm_master *master = file_priv->master; | |
| 317 | + struct drm_master *master; | |
| 318 | 318 | |
| 319 | 319 | mutex_lock(&dev->master_mutex); |
| 320 | + master = file_priv->master; | |
| 320 | 321 | if (file_priv->magic) |
| 321 | 322 | idr_remove(&file_priv->master->magic_map, file_priv->magic); |
| 322 | 323 | |
| @@ -118,17 +118,18 @@ int drm_getunique(struct drm_device *dev, void *data, · 117 unmodified lines | ||
| 118 | 118 | struct drm_file *file_priv) |
| 119 | 119 | { |
| 120 | 120 | struct drm_unique *u = data; |
| 121 | − struct drm_master *master = file_priv->master; | |
| 121 | + struct drm_master *master; | |
| 122 | 122 | |
| 123 | − mutex_lock(&master->dev->master_mutex); | |
| 123 | + mutex_lock(&dev->master_mutex); | |
| 124 | + master = file_priv->master; | |
| 124 | 125 | if (u->unique_len >= master->unique_len) { |
| 125 | 126 | if (copy_to_user(u->unique, master->unique, master->unique_len)) { |
| 126 | − mutex_unlock(&master->dev->master_mutex); | |
| 127 | + mutex_unlock(&dev->master_mutex); | |
| 127 | 128 | return -EFAULT; |
| 128 | 129 | } |
| 129 | 130 | } |
| 130 | 131 | u->unique_len = master->unique_len; |
| 131 | − mutex_unlock(&master->dev->master_mutex); | |
| 132 | + mutex_unlock(&dev->master_mutex); | |
| 132 | 133 | |
| 133 | 134 | return 0; |
| 134 | 135 | } |
| @@ -20,7 +20,6 @@ config DRM_I915 · 19 unmodified lines | ||
| 20 | 20 | select INPUT if ACPI |
| 21 | 21 | select ACPI_VIDEO if ACPI |
| 22 | 22 | select ACPI_BUTTON if ACPI |
| 23 | − select IO_MAPPING | |
| 24 | 23 | select SYNC_FILE |
| 25 | 24 | select IOSF_MBI |
| 26 | 25 | select CRC32 |
| @@ -367,10 +367,11 @@ retry: · 366 unmodified lines | ||
| 367 | 367 | goto err_unpin; |
| 368 | 368 | |
| 369 | 369 | /* Finally, remap it using the new GTT offset */ |
| 370 | − ret = io_mapping_map_user(&ggtt->iomap, area, area->vm_start + | |
| 371 | − (vma->ggtt_view.partial.offset << PAGE_SHIFT), | |
| 372 | − (ggtt->gmadr.start + vma->node.start) >> PAGE_SHIFT, | |
| 373 | − min_t(u64, vma->size, area->vm_end - area->vm_start)); | |
| 370 | + ret = remap_io_mapping(area, | |
| 371 | + area->vm_start + (vma->ggtt_view.partial.offset << PAGE_SHIFT), | |
| 372 | + (ggtt->gmadr.start + vma->node.start) >> PAGE_SHIFT, | |
| 373 | + min_t(u64, vma->size, area->vm_end - area->vm_start), | |
| 374 | + &ggtt->iomap); | |
| 374 | 375 | if (ret) |
| 375 | 376 | goto err_fence; |
| 376 | 377 | |
| @@ -1905,6 +1905,9 @@ int i915_reg_read_ioctl(struct drm_device *dev, void *data, · 1904 unmodified lines | ||
| 1905 | 1905 | struct drm_file *file); |
| 1906 | 1906 | |
| 1907 | 1907 | /* i915_mm.c */ |
| 1908 | +int remap_io_mapping(struct vm_area_struct *vma, | |
| 1909 | + unsigned long addr, unsigned long pfn, unsigned long size, | |
| 1910 | + struct io_mapping *iomap); | |
| 1908 | 1911 | int remap_io_sg(struct vm_area_struct *vma, |
| 1909 | 1912 | unsigned long addr, unsigned long size, |
| 1910 | 1913 | struct scatterlist *sgl, resource_size_t iobase); |
| @@ -37,6 +37,17 @@ struct remap_pfn { · 36 unmodified lines | ||
| 37 | 37 | resource_size_t iobase; |
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | +static int remap_pfn(pte_t *pte, unsigned long addr, void *data) | |
| 41 | +{ | |
| 42 | + struct remap_pfn *r = data; | |
| 43 | + | |
| 44 | + /* Special PTE are not associated with any struct page */ | |
| 45 | + set_pte_at(r->mm, addr, pte, pte_mkspecial(pfn_pte(r->pfn, r->prot))); | |
| 46 | + r->pfn++; | |
| 47 | + | |
| 48 | + return 0; | |
| 49 | +} | |
| 50 | + | |
| 40 | 51 | #define use_dma(io) ((io) != -1) |
| 41 | 52 | |
| 42 | 53 | static inline unsigned long sgt_pfn(const struct remap_pfn *r) |
| @@ -66,7 +77,40 @@ static int remap_sg(pte_t *pte, unsigned long addr, void *data) · 23 unmodified lines | ||
| 66 | 77 | return 0; |
| 67 | 78 | } |
| 68 | 79 | |
| 80 | +/** | |
| 81 | + * remap_io_mapping - remap an IO mapping to userspace | |
| 82 | + * @vma: user vma to map to | |
| 83 | + * @addr: target user address to start at | |
| 84 | + * @pfn: physical address of kernel memory | |
| 85 | + * @size: size of map area | |
| 86 | + * @iomap: the source io_mapping | |
| 87 | + * | |
| 88 | + * Note: this is only safe if the mm semaphore is held when called. | |
| 89 | + */ | |
| 90 | +int remap_io_mapping(struct vm_area_struct *vma, | |
| 91 | + unsigned long addr, unsigned long pfn, unsigned long size, | |
| 92 | + struct io_mapping *iomap) | |
| 93 | +{ | |
| 94 | + struct remap_pfn r; | |
| 95 | + int err; | |
| 96 | + | |
| 69 | 97 | #define EXPECTED_FLAGS (VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP) |
| 98 | + GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) != EXPECTED_FLAGS); | |
| 99 | + | |
| 100 | + /* We rely on prevalidation of the io-mapping to skip track_pfn(). */ | |
| 101 | + r.mm = vma->vm_mm; | |
| 102 | + r.pfn = pfn; | |
| 103 | + r.prot = __pgprot((pgprot_val(iomap->prot) & _PAGE_CACHE_MASK) | | |
| 104 | + (pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK)); | |
| 105 | + | |
| 106 | + err = apply_to_page_range(r.mm, addr, size, remap_pfn, &r); | |
| 107 | + if (unlikely(err)) { | |
| 108 | + zap_vma_ptes(vma, addr, (r.pfn - pfn) << PAGE_SHIFT); | |
| 109 | + return err; | |
| 110 | + } | |
| 111 | + | |
| 112 | + return 0; | |
| 113 | +} | |
| 70 | 114 | |
| 71 | 115 | /** |
| 72 | 116 | * remap_io_sg - remap an IO mapping to userspace |
| @@ -1592,8 +1592,8 @@ static int live_breadcrumbs_smoketest(void *arg) · 1591 unmodified lines | ||
| 1592 | 1592 | |
| 1593 | 1593 | for (n = 0; n < smoke[0].ncontexts; n++) { |
| 1594 | 1594 | smoke[0].contexts[n] = live_context(i915, file); |
| 1595 | − if (!smoke[0].contexts[n]) { | |
| 1596 | − ret = -ENOMEM; | |
| 1595 | + if (IS_ERR(smoke[0].contexts[n])) { | |
| 1596 | + ret = PTR_ERR(smoke[0].contexts[n]); | |
| 1597 | 1597 | goto out_contexts; |
| 1598 | 1598 | } |
| 1599 | 1599 | } |
| @@ -577,7 +577,7 @@ static void mcde_dsi_setup_video_mode(struct mcde_dsi *d, · 576 unmodified lines | ||
| 577 | 577 | * porches and sync. |
| 578 | 578 | */ |
| 579 | 579 | /* (ps/s) / (pixels/s) = ps/pixels */ |
| 580 | − pclk = DIV_ROUND_UP_ULL(1000000000000, mode->clock); | |
| 580 | + pclk = DIV_ROUND_UP_ULL(1000000000000, (mode->clock * 1000)); | |
| 581 | 581 | dev_dbg(d->dev, "picoseconds between two pixels: %llu\n", |
| 582 | 582 | pclk); |
| 583 | 583 | |
| @@ -157,7 +157,7 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) · 156 unmodified lines | ||
| 157 | 157 | * GPU registers so we need to add 0x1a800 to the register value on A630 |
| 158 | 158 | * to get the right value from PM4. |
| 159 | 159 | */ |
| 160 | − get_stats_counter(ring, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L + 0x1a800, | |
| 160 | + get_stats_counter(ring, REG_A6XX_CP_ALWAYS_ON_COUNTER_LO, | |
| 161 | 161 | rbmemptr_stats(ring, index, alwayson_start)); |
| 162 | 162 | |
| 163 | 163 | /* Invalidate CCU depth and color */ |
| @@ -187,7 +187,7 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) · 23 unmodified lines | ||
| 187 | 187 | |
| 188 | 188 | get_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP_0_LO, |
| 189 | 189 | rbmemptr_stats(ring, index, cpcycles_end)); |
| 190 | − get_stats_counter(ring, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L + 0x1a800, | |
| 190 | + get_stats_counter(ring, REG_A6XX_CP_ALWAYS_ON_COUNTER_LO, | |
| 191 | 191 | rbmemptr_stats(ring, index, alwayson_end)); |
| 192 | 192 | |
| 193 | 193 | /* Write the fence to the scratch register */ |
| @@ -206,8 +206,8 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) · 12 unmodified lines | ||
| 206 | 206 | OUT_RING(ring, submit->seqno); |
| 207 | 207 | |
| 208 | 208 | trace_msm_gpu_submit_flush(submit, |
| 209 | − gmu_read64(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L, | |
| 210 | − REG_A6XX_GMU_ALWAYS_ON_COUNTER_H)); | |
| 209 | + gpu_read64(gpu, REG_A6XX_CP_ALWAYS_ON_COUNTER_LO, | |
| 210 | + REG_A6XX_CP_ALWAYS_ON_COUNTER_HI)); | |
| 211 | 211 | |
| 212 | 212 | a6xx_flush(gpu, ring); |
| 213 | 213 | } |
| @@ -462,6 +462,113 @@ static void a6xx_set_hwcg(struct msm_gpu *gpu, bool state) · 248 unmodified lines | ||
| 462 | 462 | gpu_write(gpu, REG_A6XX_RBBM_CLOCK_CNTL, state ? clock_cntl_on : 0); |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | +/* For a615, a616, a618, A619, a630, a640 and a680 */ | |
| 466 | +static const u32 a6xx_protect[] = { | |
| 467 | + A6XX_PROTECT_RDONLY(0x00000, 0x04ff), | |
| 468 | + A6XX_PROTECT_RDONLY(0x00501, 0x0005), | |
| 469 | + A6XX_PROTECT_RDONLY(0x0050b, 0x02f4), | |
| 470 | + A6XX_PROTECT_NORDWR(0x0050e, 0x0000), | |
| 471 | + A6XX_PROTECT_NORDWR(0x00510, 0x0000), | |
| 472 | + A6XX_PROTECT_NORDWR(0x00534, 0x0000), | |
| 473 | + A6XX_PROTECT_NORDWR(0x00800, 0x0082), | |
| 474 | + A6XX_PROTECT_NORDWR(0x008a0, 0x0008), | |
| 475 | + A6XX_PROTECT_NORDWR(0x008ab, 0x0024), | |
| 476 | + A6XX_PROTECT_RDONLY(0x008de, 0x00ae), | |
| 477 | + A6XX_PROTECT_NORDWR(0x00900, 0x004d), | |
| 478 | + A6XX_PROTECT_NORDWR(0x0098d, 0x0272), | |
| 479 | + A6XX_PROTECT_NORDWR(0x00e00, 0x0001), | |
| 480 | + A6XX_PROTECT_NORDWR(0x00e03, 0x000c), | |
| 481 | + A6XX_PROTECT_NORDWR(0x03c00, 0x00c3), | |
| 482 | + A6XX_PROTECT_RDONLY(0x03cc4, 0x1fff), | |
| 483 | + A6XX_PROTECT_NORDWR(0x08630, 0x01cf), | |
| 484 | + A6XX_PROTECT_NORDWR(0x08e00, 0x0000), | |
| 485 | + A6XX_PROTECT_NORDWR(0x08e08, 0x0000), | |
| 486 | + A6XX_PROTECT_NORDWR(0x08e50, 0x001f), | |
| 487 | + A6XX_PROTECT_NORDWR(0x09624, 0x01db), | |
| 488 | + A6XX_PROTECT_NORDWR(0x09e70, 0x0001), | |
| 489 | + A6XX_PROTECT_NORDWR(0x09e78, 0x0187), | |
| 490 | + A6XX_PROTECT_NORDWR(0x0a630, 0x01cf), | |
| 491 | + A6XX_PROTECT_NORDWR(0x0ae02, 0x0000), | |
| 492 | + A6XX_PROTECT_NORDWR(0x0ae50, 0x032f), | |
| 493 | + A6XX_PROTECT_NORDWR(0x0b604, 0x0000), | |
| 494 | + A6XX_PROTECT_NORDWR(0x0be02, 0x0001), | |
| 495 | + A6XX_PROTECT_NORDWR(0x0be20, 0x17df), | |
| 496 | + A6XX_PROTECT_NORDWR(0x0f000, 0x0bff), | |
| 497 | + A6XX_PROTECT_RDONLY(0x0fc00, 0x1fff), | |
| 498 | + A6XX_PROTECT_NORDWR(0x11c00, 0x0000), /* note: infinite range */ | |
| 499 | +}; | |
| 500 | + | |
| 501 | +/* These are for a620 and a650 */ | |
| 502 | +static const u32 a650_protect[] = { | |
| 503 | + A6XX_PROTECT_RDONLY(0x00000, 0x04ff), | |
| 504 | + A6XX_PROTECT_RDONLY(0x00501, 0x0005), | |
| 505 | + A6XX_PROTECT_RDONLY(0x0050b, 0x02f4), | |
| 506 | + A6XX_PROTECT_NORDWR(0x0050e, 0x0000), | |
| 507 | + A6XX_PROTECT_NORDWR(0x00510, 0x0000), | |
| 508 | + A6XX_PROTECT_NORDWR(0x00534, 0x0000), | |
| 509 | + A6XX_PROTECT_NORDWR(0x00800, 0x0082), | |
| 510 | + A6XX_PROTECT_NORDWR(0x008a0, 0x0008), | |
| 511 | + A6XX_PROTECT_NORDWR(0x008ab, 0x0024), | |
| 512 | + A6XX_PROTECT_RDONLY(0x008de, 0x00ae), | |
| 513 | + A6XX_PROTECT_NORDWR(0x00900, 0x004d), | |
| 514 | + A6XX_PROTECT_NORDWR(0x0098d, 0x0272), | |
| 515 | + A6XX_PROTECT_NORDWR(0x00e00, 0x0001), | |
| 516 | + A6XX_PROTECT_NORDWR(0x00e03, 0x000c), | |
| 517 | + A6XX_PROTECT_NORDWR(0x03c00, 0x00c3), | |
| 518 | + A6XX_PROTECT_RDONLY(0x03cc4, 0x1fff), | |
| 519 | + A6XX_PROTECT_NORDWR(0x08630, 0x01cf), | |
| 520 | + A6XX_PROTECT_NORDWR(0x08e00, 0x0000), | |
| 521 | + A6XX_PROTECT_NORDWR(0x08e08, 0x0000), | |
| 522 | + A6XX_PROTECT_NORDWR(0x08e50, 0x001f), | |
| 523 | + A6XX_PROTECT_NORDWR(0x08e80, 0x027f), | |
| 524 | + A6XX_PROTECT_NORDWR(0x09624, 0x01db), | |
| 525 | + A6XX_PROTECT_NORDWR(0x09e60, 0x0011), | |
| 526 | + A6XX_PROTECT_NORDWR(0x09e78, 0x0187), | |
| 527 | + A6XX_PROTECT_NORDWR(0x0a630, 0x01cf), | |
| 528 | + A6XX_PROTECT_NORDWR(0x0ae02, 0x0000), | |
| 529 | + A6XX_PROTECT_NORDWR(0x0ae50, 0x032f), | |
| 530 | + A6XX_PROTECT_NORDWR(0x0b604, 0x0000), | |
| 531 | + A6XX_PROTECT_NORDWR(0x0b608, 0x0007), | |
| 532 | + A6XX_PROTECT_NORDWR(0x0be02, 0x0001), | |
| 533 | + A6XX_PROTECT_NORDWR(0x0be20, 0x17df), | |
| 534 | + A6XX_PROTECT_NORDWR(0x0f000, 0x0bff), | |
| 535 | + A6XX_PROTECT_RDONLY(0x0fc00, 0x1fff), | |
| 536 | + A6XX_PROTECT_NORDWR(0x18400, 0x1fff), | |
| 537 | + A6XX_PROTECT_NORDWR(0x1a800, 0x1fff), | |
| 538 | + A6XX_PROTECT_NORDWR(0x1f400, 0x0443), | |
| 539 | + A6XX_PROTECT_RDONLY(0x1f844, 0x007b), | |
| 540 | + A6XX_PROTECT_NORDWR(0x1f887, 0x001b), | |
| 541 | + A6XX_PROTECT_NORDWR(0x1f8c0, 0x0000), /* note: infinite range */ | |
| 542 | +}; | |
| 543 | + | |
| 544 | +static void a6xx_set_cp_protect(struct msm_gpu *gpu) | |
| 545 | +{ | |
| 546 | + struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); | |
| 547 | + const u32 *regs = a6xx_protect; | |
| 548 | + unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32; | |
| 549 | + | |
| 550 | + BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32); | |
| 551 | + BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48); | |
| 552 | + | |
| 553 | + if (adreno_is_a650(adreno_gpu)) { | |
| 554 | + regs = a650_protect; | |
| 555 | + count = ARRAY_SIZE(a650_protect); | |
| 556 | + count_max = 48; | |
| 557 | + } | |
| 558 | + | |
| 559 | + /* | |
| 560 | + * Enable access protection to privileged registers, fault on an access | |
| 561 | + * protect violation and select the last span to protect from the start | |
| 562 | + * address all the way to the end of the register address space | |
| 563 | + */ | |
| 564 | + gpu_write(gpu, REG_A6XX_CP_PROTECT_CNTL, BIT(0) | BIT(1) | BIT(3)); | |
| 565 | + | |
| 566 | + for (i = 0; i < count - 1; i++) | |
| 567 | + gpu_write(gpu, REG_A6XX_CP_PROTECT(i), regs[i]); | |
| 568 | + /* last CP_PROTECT to have "infinite" length on the last entry */ | |
| 569 | + gpu_write(gpu, REG_A6XX_CP_PROTECT(count_max - 1), regs[i]); | |
| 570 | +} | |
| 571 | + | |
| 465 | 572 | static void a6xx_set_ubwc_config(struct msm_gpu *gpu) |
| 466 | 573 | { |
| 467 | 574 | struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); |
| @@ -489,7 +596,7 @@ static void a6xx_set_ubwc_config(struct msm_gpu *gpu) · 21 unmodified lines | ||
| 489 | 596 | rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1); |
| 490 | 597 | gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1); |
| 491 | 598 | gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, |
| 492 | − uavflagprd_inv >> 4 | lower_bit << 1); | |
| 599 | + uavflagprd_inv << 4 | lower_bit << 1); | |
| 493 | 600 | gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21); |
| 494 | 601 | } |
| 495 | 602 | |
| @@ -776,41 +883,7 @@ static int a6xx_hw_init(struct msm_gpu *gpu) · 280 unmodified lines | ||
| 776 | 883 | } |
| 777 | 884 | |
| 778 | 885 | /* Protect registers from the CP */ |
| 779 | − gpu_write(gpu, REG_A6XX_CP_PROTECT_CNTL, 0x00000003); | |
| 780 | − | |
| 781 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(0), | |
| 782 | − A6XX_PROTECT_RDONLY(0x600, 0x51)); | |
| 783 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(1), A6XX_PROTECT_RW(0xae50, 0x2)); | |
| 784 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(2), A6XX_PROTECT_RW(0x9624, 0x13)); | |
| 785 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(3), A6XX_PROTECT_RW(0x8630, 0x8)); | |
| 786 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(4), A6XX_PROTECT_RW(0x9e70, 0x1)); | |
| 787 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(5), A6XX_PROTECT_RW(0x9e78, 0x187)); | |
| 788 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(6), A6XX_PROTECT_RW(0xf000, 0x810)); | |
| 789 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(7), | |
| 790 | − A6XX_PROTECT_RDONLY(0xfc00, 0x3)); | |
| 791 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(8), A6XX_PROTECT_RW(0x50e, 0x0)); | |
| 792 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(9), A6XX_PROTECT_RDONLY(0x50f, 0x0)); | |
| 793 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(10), A6XX_PROTECT_RW(0x510, 0x0)); | |
| 794 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(11), | |
| 795 | − A6XX_PROTECT_RDONLY(0x0, 0x4f9)); | |
| 796 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(12), | |
| 797 | − A6XX_PROTECT_RDONLY(0x501, 0xa)); | |
| 798 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(13), | |
| 799 | − A6XX_PROTECT_RDONLY(0x511, 0x44)); | |
| 800 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(14), A6XX_PROTECT_RW(0xe00, 0xe)); | |
| 801 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(15), A6XX_PROTECT_RW(0x8e00, 0x0)); | |
| 802 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(16), A6XX_PROTECT_RW(0x8e50, 0xf)); | |
| 803 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(17), A6XX_PROTECT_RW(0xbe02, 0x0)); | |
| 804 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(18), | |
| 805 | − A6XX_PROTECT_RW(0xbe20, 0x11f3)); | |
| 806 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(19), A6XX_PROTECT_RW(0x800, 0x82)); | |
| 807 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(20), A6XX_PROTECT_RW(0x8a0, 0x8)); | |
| 808 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(21), A6XX_PROTECT_RW(0x8ab, 0x19)); | |
| 809 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(22), A6XX_PROTECT_RW(0x900, 0x4d)); | |
| 810 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(23), A6XX_PROTECT_RW(0x98d, 0x76)); | |
| 811 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(24), | |
| 812 | − A6XX_PROTECT_RDONLY(0x980, 0x4)); | |
| 813 | − gpu_write(gpu, REG_A6XX_CP_PROTECT(25), A6XX_PROTECT_RW(0xa630, 0x0)); | |
| 886 | + a6xx_set_cp_protect(gpu); | |
| 814 | 887 | |
| 815 | 888 | /* Enable expanded apriv for targets that support it */ |
| 816 | 889 | if (gpu->hw_apriv) { |
| @@ -1211,7 +1284,7 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu) · 394 unmodified lines | ||
| 1211 | 1284 | if (ret) |
| 1212 | 1285 | return ret; |
| 1213 | 1286 | |
| 1214 | − if (adreno_gpu->base.hw_apriv || a6xx_gpu->has_whereami) | |
| 1287 | + if (a6xx_gpu->shadow_bo) | |
| 1215 | 1288 | for (i = 0; i < gpu->nr_rings; i++) |
| 1216 | 1289 | a6xx_gpu->shadow[i] = 0; |
| 1217 | 1290 | |
| @@ -44,7 +44,7 @@ struct a6xx_gpu { · 43 unmodified lines | ||
| 44 | 44 | * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len |
| 45 | 45 | * registers starting at _reg. |
| 46 | 46 | */ |
| 47 | −#define A6XX_PROTECT_RW(_reg, _len) \ | |
| 47 | +#define A6XX_PROTECT_NORDWR(_reg, _len) \ | |
| 48 | 48 | ((1 << 31) | \ |
| 49 | 49 | (((_len) & 0x3FFF) << 18) | ((_reg) & 0x3FFFF)) |
| 50 | 50 | |
| @@ -432,6 +432,7 @@ static unsigned long dsi_pll_10nm_vco_recalc_rate(struct clk_hw *hw, · 431 unmodified lines | ||
| 432 | 432 | pll_freq += div_u64(tmp64, multiplier); |
| 433 | 433 | |
| 434 | 434 | vco_rate = pll_freq; |
| 435 | + pll_10nm->vco_current_rate = vco_rate; | |
| 435 | 436 | |
| 436 | 437 | DBG("DSI PLL%d returning vco rate = %lu, dec = %x, frac = %x", |
| 437 | 438 | pll_10nm->phy->id, (unsigned long)vco_rate, dec, frac); |
| @@ -460,6 +460,7 @@ static unsigned long dsi_pll_7nm_vco_recalc_rate(struct clk_hw *hw, · 459 unmodified lines | ||
| 460 | 460 | pll_freq += div_u64(tmp64, multiplier); |
| 461 | 461 | |
| 462 | 462 | vco_rate = pll_freq; |
| 463 | + pll_7nm->vco_current_rate = vco_rate; | |
| 463 | 464 | |
| 464 | 465 | DBG("DSI PLL%d returning vco rate = %lu, dec = %x, frac = %x", |
| 465 | 466 | pll_7nm->phy->id, (unsigned long)vco_rate, dec, frac); |
| @@ -1241,6 +1241,13 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev, · 1240 unmodified lines | ||
| 1241 | 1241 | |
| 1242 | 1242 | to_msm_bo(obj)->vram_node = &vma->node; |
| 1243 | 1243 | |
| 1244 | + /* Call chain get_pages() -> update_inactive() tries to | |
| 1245 | + * access msm_obj->mm_list, but it is not initialized yet. | |
| 1246 | + * To avoid NULL pointer dereference error, initialize | |
| 1247 | + * mm_list to be empty. | |
| 1248 | + */ | |
| 1249 | + INIT_LIST_HEAD(&msm_obj->mm_list); | |
| 1250 | + | |
| 1244 | 1251 | msm_gem_lock(obj); |
| 1245 | 1252 | pages = get_pages(obj); |
| 1246 | 1253 | msm_gem_unlock(obj); |
| @@ -286,7 +286,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) · 285 unmodified lines | ||
| 286 | 286 | if (rdev->uvd.vcpu_bo == NULL) |
| 287 | 287 | return -EINVAL; |
| 288 | 288 | |
| 289 | − memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); | |
| 289 | + memcpy_toio((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); | |
| 290 | 290 | |
| 291 | 291 | size = radeon_bo_size(rdev->uvd.vcpu_bo); |
| 292 | 292 | size -= rdev->uvd_fw->size; |
| @@ -294,7 +294,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) · 1 unmodified line | ||
| 294 | 294 | ptr = rdev->uvd.cpu_addr; |
| 295 | 295 | ptr += rdev->uvd_fw->size; |
| 296 | 296 | |
| 297 | − memset(ptr, 0, size); | |
| 297 | + memset_io((void __iomem *)ptr, 0, size); | |
| 298 | 298 | |
| 299 | 299 | return 0; |
| 300 | 300 | } |
| @@ -209,7 +209,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, · 208 unmodified lines | ||
| 209 | 209 | goto err_disable_clk_tmds; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | − ret = sun8i_hdmi_phy_probe(hdmi, phy_node); | |
| 212 | + ret = sun8i_hdmi_phy_get(hdmi, phy_node); | |
| 213 | 213 | of_node_put(phy_node); |
| 214 | 214 | if (ret) { |
| 215 | 215 | dev_err(dev, "Couldn't get the HDMI PHY\n"); |
| @@ -242,7 +242,6 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, · 26 unmodified lines | ||
| 242 | 242 | |
| 243 | 243 | cleanup_encoder: |
| 244 | 244 | drm_encoder_cleanup(encoder); |
| 245 | − sun8i_hdmi_phy_remove(hdmi); | |
| 246 | 245 | err_disable_clk_tmds: |
| 247 | 246 | clk_disable_unprepare(hdmi->clk_tmds); |
| 248 | 247 | err_assert_ctrl_reset: |
| @@ -263,7 +262,6 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master, · 14 unmodified lines | ||
| 263 | 262 | struct sun8i_dw_hdmi *hdmi = dev_get_drvdata(dev); |
| 264 | 263 | |
| 265 | 264 | dw_hdmi_unbind(hdmi->hdmi); |
| 266 | − sun8i_hdmi_phy_remove(hdmi); | |
| 267 | 265 | clk_disable_unprepare(hdmi->clk_tmds); |
| 268 | 266 | reset_control_assert(hdmi->rst_ctrl); |
| 269 | 267 | gpiod_set_value(hdmi->ddc_en, 0); |
| @@ -320,7 +318,32 @@ static struct platform_driver sun8i_dw_hdmi_pltfm_driver = { · 50 unmodified lines | ||
| 320 | 318 | .of_match_table = sun8i_dw_hdmi_dt_ids, |
| 321 | 319 | }, |
| 322 | 320 | }; |
| 323 | −module_platform_driver(sun8i_dw_hdmi_pltfm_driver); | |
| 321 | + | |
| 322 | +static int __init sun8i_dw_hdmi_init(void) | |
| 323 | +{ | |
| 324 | + int ret; | |
| 325 | + | |
| 326 | + ret = platform_driver_register(&sun8i_dw_hdmi_pltfm_driver); | |
| 327 | + if (ret) | |
| 328 | + return ret; | |
| 329 | + | |
| 330 | + ret = platform_driver_register(&sun8i_hdmi_phy_driver); | |
| 331 | + if (ret) { | |
| 332 | + platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver); | |
| 333 | + return ret; | |
| 334 | + } | |
| 335 | + | |
| 336 | + return ret; | |
| 337 | +} | |
| 338 | + | |
| 339 | +static void __exit sun8i_dw_hdmi_exit(void) | |
| 340 | +{ | |
| 341 | + platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver); | |
| 342 | + platform_driver_unregister(&sun8i_hdmi_phy_driver); | |
| 343 | +} | |
| 344 | + | |
| 345 | +module_init(sun8i_dw_hdmi_init); | |
| 346 | +module_exit(sun8i_dw_hdmi_exit); | |
| 324 | 347 | |
| 325 | 348 | MODULE_AUTHOR("Jernej Skrabec <jernej.skrabec@siol.net>"); |
| 326 | 349 | MODULE_DESCRIPTION("Allwinner DW HDMI bridge"); |
| @@ -195,14 +195,15 @@ struct sun8i_dw_hdmi { · 194 unmodified lines | ||
| 195 | 195 | struct gpio_desc *ddc_en; |
| 196 | 196 | }; |
| 197 | 197 | |
| 198 | +extern struct platform_driver sun8i_hdmi_phy_driver; | |
| 199 | + | |
| 198 | 200 | static inline struct sun8i_dw_hdmi * |
| 199 | 201 | encoder_to_sun8i_dw_hdmi(struct drm_encoder *encoder) |
| 200 | 202 | { |
| 201 | 203 | return container_of(encoder, struct sun8i_dw_hdmi, encoder); |
| 202 | 204 | } |
| 203 | 205 | |
| 204 | −int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node); | |
| 205 | −void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi); | |
| 206 | +int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node); | |
| 206 | 207 | |
| 207 | 208 | void sun8i_hdmi_phy_init(struct sun8i_hdmi_phy *phy); |
| 208 | 209 | void sun8i_hdmi_phy_set_ops(struct sun8i_hdmi_phy *phy, |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | |
| 6 | 6 | #include <linux/delay.h> |
| 7 | 7 | #include <linux/of_address.h> |
| 8 | +#include <linux/of_platform.h> | |
| 8 | 9 | |
| 9 | 10 | #include "sun8i_dw_hdmi.h" |
| 10 | 11 | |
| @@ -597,10 +598,30 @@ static const struct of_device_id sun8i_hdmi_phy_of_table[] = { · 586 unmodified lines | ||
| 597 | 598 | { /* sentinel */ } |
| 598 | 599 | }; |
| 599 | 600 | |
| 600 | −int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node) | |
| 601 | +int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node) | |
| 602 | +{ | |
| 603 | + struct platform_device *pdev = of_find_device_by_node(node); | |
| 604 | + struct sun8i_hdmi_phy *phy; | |
| 605 | + | |
| 606 | + if (!pdev) | |
| 607 | + return -EPROBE_DEFER; | |
| 608 | + | |
| 609 | + phy = platform_get_drvdata(pdev); | |
| 610 | + if (!phy) | |
| 611 | + return -EPROBE_DEFER; | |
| 612 | + | |
| 613 | + hdmi->phy = phy; | |
| 614 | + | |
| 615 | + put_device(&pdev->dev); | |
| 616 | + | |
| 617 | + return 0; | |
| 618 | +} | |
| 619 | + | |
| 620 | +static int sun8i_hdmi_phy_probe(struct platform_device *pdev) | |
| 601 | 621 | { |
| 602 | 622 | const struct of_device_id *match; |
| 603 | − struct device *dev = hdmi->dev; | |
| 623 | + struct device *dev = &pdev->dev; | |
| 624 | + struct device_node *node = dev->of_node; | |
| 604 | 625 | struct sun8i_hdmi_phy *phy; |
| 605 | 626 | struct resource res; |
| 606 | 627 | void __iomem *regs; |
| @@ -704,7 +725,7 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node) · 97 unmodified lines | ||
| 704 | 725 | clk_prepare_enable(phy->clk_phy); |
| 705 | 726 | } |
| 706 | 727 | |
| 707 | − hdmi->phy = phy; | |
| 728 | + platform_set_drvdata(pdev, phy); | |
| 708 | 729 | |
| 709 | 730 | return 0; |
| 710 | 731 | |
| @@ -728,9 +749,9 @@ err_put_clk_bus: · 17 unmodified lines | ||
| 728 | 749 | return ret; |
| 729 | 750 | } |
| 730 | 751 | |
| 731 | −void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi) | |
| 752 | +static int sun8i_hdmi_phy_remove(struct platform_device *pdev) | |
| 732 | 753 | { |
| 733 | − struct sun8i_hdmi_phy *phy = hdmi->phy; | |
| 754 | + struct sun8i_hdmi_phy *phy = platform_get_drvdata(pdev); | |
| 734 | 755 | |
| 735 | 756 | clk_disable_unprepare(phy->clk_mod); |
| 736 | 757 | clk_disable_unprepare(phy->clk_bus); |
| @@ -744,4 +765,14 @@ void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi) · 7 unmodified lines | ||
| 744 | 765 | clk_put(phy->clk_pll1); |
| 745 | 766 | clk_put(phy->clk_mod); |
| 746 | 767 | clk_put(phy->clk_bus); |
| 768 | + return 0; | |
| 747 | 769 | } |
| 770 | + | |
| 771 | +struct platform_driver sun8i_hdmi_phy_driver = { | |
| 772 | + .probe = sun8i_hdmi_phy_probe, | |
| 773 | + .remove = sun8i_hdmi_phy_remove, | |
| 774 | + .driver = { | |
| 775 | + .name = "sun8i-hdmi-phy", | |
| 776 | + .of_match_table = sun8i_hdmi_phy_of_table, | |
| 777 | + }, | |
| 778 | +}; | |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "trace.h" |
| 26 | 26 | |
| 27 | 27 | /* XXX move to include/uapi/drm/drm_fourcc.h? */ |
| 28 | −#define DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT BIT(22) | |
| 28 | +#define DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT BIT_ULL(22) | |
| 29 | 29 | |
| 30 | 30 | struct reset_control; |
| 31 | 31 | |
| @@ -510,7 +510,7 @@ static void tegra_shared_plane_atomic_update(struct drm_plane *plane, · 509 unmodified lines | ||
| 510 | 510 | * dGPU sector layout. |
| 511 | 511 | */ |
| 512 | 512 | if (tegra_plane_state->tiling.sector_layout == TEGRA_BO_SECTOR_LAYOUT_GPU) |
| 513 | − base |= BIT(39); | |
| 513 | + base |= BIT_ULL(39); | |
| 514 | 514 | #endif |
| 515 | 515 | |
| 516 | 516 | tegra_plane_writel(p, tegra_plane_state->format, DC_WIN_COLOR_DEPTH); |
| @@ -3125,21 +3125,21 @@ static int tegra_sor_init(struct host1x_client *client) · 3124 unmodified lines | ||
| 3125 | 3125 | if (err < 0) { |
| 3126 | 3126 | dev_err(sor->dev, "failed to acquire SOR reset: %d\n", |
| 3127 | 3127 | err); |
| 3128 | − return err; | |
| 3128 | + goto rpm_put; | |
| 3129 | 3129 | } |
| 3130 | 3130 | |
| 3131 | 3131 | err = reset_control_assert(sor->rst); |
| 3132 | 3132 | if (err < 0) { |
| 3133 | 3133 | dev_err(sor->dev, "failed to assert SOR reset: %d\n", |
| 3134 | 3134 | err); |
| 3135 | − return err; | |
| 3135 | + goto rpm_put; | |
| 3136 | 3136 | } |
| 3137 | 3137 | } |
| 3138 | 3138 | |
| 3139 | 3139 | err = clk_prepare_enable(sor->clk); |
| 3140 | 3140 | if (err < 0) { |
| 3141 | 3141 | dev_err(sor->dev, "failed to enable clock: %d\n", err); |
| 3142 | − return err; | |
| 3142 | + goto rpm_put; | |
| 3143 | 3143 | } |
| 3144 | 3144 | |
| 3145 | 3145 | usleep_range(1000, 3000); |
| @@ -3150,7 +3150,7 @@ static int tegra_sor_init(struct host1x_client *client) · 4 unmodified lines | ||
| 3150 | 3150 | dev_err(sor->dev, "failed to deassert SOR reset: %d\n", |
| 3151 | 3151 | err); |
| 3152 | 3152 | clk_disable_unprepare(sor->clk); |
| 3153 | − return err; | |
| 3153 | + goto rpm_put; | |
| 3154 | 3154 | } |
| 3155 | 3155 | |
| 3156 | 3156 | reset_control_release(sor->rst); |
| @@ -3171,6 +3171,12 @@ static int tegra_sor_init(struct host1x_client *client) · 14 unmodified lines | ||
| 3171 | 3171 | } |
| 3172 | 3172 | |
| 3173 | 3173 | return 0; |
| 3174 | + | |
| 3175 | +rpm_put: | |
| 3176 | + if (sor->rst) | |
| 3177 | + pm_runtime_put(sor->dev); | |
| 3178 | + | |
| 3179 | + return err; | |
| 3174 | 3180 | } |
| 3175 | 3181 | |
| 3176 | 3182 | static int tegra_sor_exit(struct host1x_client *client) |
| @@ -3739,12 +3745,8 @@ static int tegra_sor_probe(struct platform_device *pdev) · 562 unmodified lines | ||
| 3739 | 3745 | if (!sor->aux) |
| 3740 | 3746 | return -EPROBE_DEFER; |
| 3741 | 3747 | |
| 3742 | − if (get_device(&sor->aux->ddc.dev)) { | |
| 3743 | − if (try_module_get(sor->aux->ddc.owner)) | |
| 3744 | − sor->output.ddc = &sor->aux->ddc; | |
| 3745 | − else | |
| 3746 | − put_device(&sor->aux->ddc.dev); | |
| 3747 | − } | |
| 3748 | + if (get_device(sor->aux->dev)) | |
| 3749 | + sor->output.ddc = &sor->aux->ddc; | |
| 3748 | 3750 | } |
| 3749 | 3751 | |
| 3750 | 3752 | if (!sor->aux) { |
| @@ -3772,12 +3774,13 @@ static int tegra_sor_probe(struct platform_device *pdev) · 21 unmodified lines | ||
| 3772 | 3774 | |
| 3773 | 3775 | err = tegra_sor_parse_dt(sor); |
| 3774 | 3776 | if (err < 0) |
| 3775 | − return err; | |
| 3777 | + goto put_aux; | |
| 3776 | 3778 | |
| 3777 | 3779 | err = tegra_output_probe(&sor->output); |
| 3778 | − if (err < 0) | |
| 3779 | − return dev_err_probe(&pdev->dev, err, | |
| 3780 | − "failed to probe output\n"); | |
| 3780 | + if (err < 0) { | |
| 3781 | + dev_err_probe(&pdev->dev, err, "failed to probe output\n"); | |
| 3782 | + goto put_aux; | |
| 3783 | + } | |
| 3781 | 3784 | |
| 3782 | 3785 | if (sor->ops && sor->ops->probe) { |
| 3783 | 3786 | err = sor->ops->probe(sor); |
| @@ -3916,17 +3919,10 @@ static int tegra_sor_probe(struct platform_device *pdev) · 132 unmodified lines | ||
| 3916 | 3919 | platform_set_drvdata(pdev, sor); |
| 3917 | 3920 | pm_runtime_enable(&pdev->dev); |
| 3918 | 3921 | |
| 3919 | − INIT_LIST_HEAD(&sor->client.list); | |
| 3922 | + host1x_client_init(&sor->client); | |
| 3920 | 3923 | sor->client.ops = &sor_client_ops; |
| 3921 | 3924 | sor->client.dev = &pdev->dev; |
| 3922 | 3925 | |
| 3923 | − err = host1x_client_register(&sor->client); | |
| 3924 | − if (err < 0) { | |
| 3925 | − dev_err(&pdev->dev, "failed to register host1x client: %d\n", | |
| 3926 | − err); | |
| 3927 | − goto rpm_disable; | |
| 3928 | − } | |
| 3929 | − | |
| 3930 | 3926 | /* |
| 3931 | 3927 | * On Tegra210 and earlier, provide our own implementation for the |
| 3932 | 3928 | * pad output clock. |
| @@ -3938,13 +3934,13 @@ static int tegra_sor_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 3938 | 3934 | sor->index); |
| 3939 | 3935 | if (!name) { |
| 3940 | 3936 | err = -ENOMEM; |
| 3941 | − goto unregister; | |
| 3937 | + goto uninit; | |
| 3942 | 3938 | } |
| 3943 | 3939 | |
| 3944 | 3940 | err = host1x_client_resume(&sor->client); |
| 3945 | 3941 | if (err < 0) { |
| 3946 | 3942 | dev_err(sor->dev, "failed to resume: %d\n", err); |
| 3947 | − goto unregister; | |
| 3943 | + goto uninit; | |
| 3948 | 3944 | } |
| 3949 | 3945 | |
| 3950 | 3946 | sor->clk_pad = tegra_clk_sor_pad_register(sor, name); |
| @@ -3955,17 +3951,30 @@ static int tegra_sor_probe(struct platform_device *pdev) · 4 unmodified lines | ||
| 3955 | 3951 | err = PTR_ERR(sor->clk_pad); |
| 3956 | 3952 | dev_err(sor->dev, "failed to register SOR pad clock: %d\n", |
| 3957 | 3953 | err); |
| 3958 | − goto unregister; | |
| 3954 | + goto uninit; | |
| 3955 | + } | |
| 3956 | + | |
| 3957 | + err = __host1x_client_register(&sor->client); | |
| 3958 | + if (err < 0) { | |
| 3959 | + dev_err(&pdev->dev, "failed to register host1x client: %d\n", | |
| 3960 | + err); | |
| 3961 | + goto uninit; | |
| 3959 | 3962 | } |
| 3960 | 3963 | |
| 3961 | 3964 | return 0; |
| 3962 | 3965 | |
| 3963 | −unregister: | |
| 3964 | − host1x_client_unregister(&sor->client); | |
| 3965 | −rpm_disable: | |
| 3966 | +uninit: | |
| 3967 | + host1x_client_exit(&sor->client); | |
| 3966 | 3968 | pm_runtime_disable(&pdev->dev); |
| 3967 | 3969 | remove: |
| 3970 | + if (sor->aux) | |
| 3971 | + sor->output.ddc = NULL; | |
| 3972 | + | |
| 3968 | 3973 | tegra_output_remove(&sor->output); |
| 3974 | +put_aux: | |
| 3975 | + if (sor->aux) | |
| 3976 | + put_device(sor->aux->dev); | |
| 3977 | + | |
| 3969 | 3978 | return err; |
| 3970 | 3979 | } |
| 3971 | 3980 | |
| @@ -3983,6 +3992,11 @@ static int tegra_sor_remove(struct platform_device *pdev) · 11 unmodified lines | ||
| 3983 | 3992 | |
| 3984 | 3993 | pm_runtime_disable(&pdev->dev); |
| 3985 | 3994 | |
| 3995 | + if (sor->aux) { | |
| 3996 | + put_device(sor->aux->dev); | |
| 3997 | + sor->output.ddc = NULL; | |
| 3998 | + } | |
| 3999 | + | |
| 3986 | 4000 | tegra_output_remove(&sor->output); |
| 3987 | 4001 | |
| 3988 | 4002 | return 0; |
| @@ -1172,7 +1172,10 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, · 1171 unmodified lines | ||
| 1172 | 1172 | if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked, NULL)) |
| 1173 | 1173 | return -EBUSY; |
| 1174 | 1174 | |
| 1175 | − if (!ttm_bo_get_unless_zero(bo)) { | |
| 1175 | + if (!bo->ttm || !ttm_tt_is_populated(bo->ttm) || | |
| 1176 | + bo->ttm->page_flags & TTM_PAGE_FLAG_SG || | |
| 1177 | + bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED || | |
| 1178 | + !ttm_bo_get_unless_zero(bo)) { | |
| 1176 | 1179 | if (locked) |
| 1177 | 1180 | dma_resv_unlock(bo->base.resv); |
| 1178 | 1181 | return -EBUSY; |
| @@ -143,14 +143,8 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, · 142 unmodified lines | ||
| 143 | 143 | |
| 144 | 144 | for (j = 0; j < TTM_MAX_BO_PRIORITY; ++j) { |
| 145 | 145 | list_for_each_entry(bo, &man->lru[j], lru) { |
| 146 | − uint32_t num_pages; | |
| 146 | + uint32_t num_pages = PFN_UP(bo->base.size); | |
| 147 | 147 | |
| 148 | − if (!bo->ttm || !ttm_tt_is_populated(bo->ttm) || | |
| 149 | − bo->ttm->page_flags & TTM_PAGE_FLAG_SG || | |
| 150 | − bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED) | |
| 151 | − continue; | |
| 152 | − | |
| 153 | − num_pages = bo->ttm->num_pages; | |
| 154 | 148 | ret = ttm_bo_swapout(bo, ctx, gfp_flags); |
| 155 | 149 | /* ttm_bo_swapout has dropped the lru_lock */ |
| 156 | 150 | if (!ret) |
| @@ -372,7 +372,7 @@ static void vc4_atomic_commit_tail(struct drm_atomic_state *state) · 371 unmodified lines | ||
| 372 | 372 | if (!old_hvs_state->fifo_state[channel].in_use) |
| 373 | 373 | continue; |
| 374 | 374 | |
| 375 | − ret = drm_crtc_commit_wait(old_hvs_state->fifo_state[i].pending_commit); | |
| 375 | + ret = drm_crtc_commit_wait(old_hvs_state->fifo_state[channel].pending_commit); | |
| 376 | 376 | if (ret) |
| 377 | 377 | drm_err(dev, "Timed out waiting for commit\n"); |
| 378 | 378 | } |
| @@ -735,6 +735,29 @@ void host1x_driver_unregister(struct host1x_driver *driver) · 734 unmodified lines | ||
| 735 | 735 | } |
| 736 | 736 | EXPORT_SYMBOL(host1x_driver_unregister); |
| 737 | 737 | |
| 738 | +/** | |
| 739 | + * __host1x_client_init() - initialize a host1x client | |
| 740 | + * @client: host1x client | |
| 741 | + * @key: lock class key for the client-specific mutex | |
| 742 | + */ | |
| 743 | +void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key) | |
| 744 | +{ | |
| 745 | + INIT_LIST_HEAD(&client->list); | |
| 746 | + __mutex_init(&client->lock, "host1x client lock", key); | |
| 747 | + client->usecount = 0; | |
| 748 | +} | |
| 749 | +EXPORT_SYMBOL(__host1x_client_init); | |
| 750 | + | |
| 751 | +/** | |
| 752 | + * host1x_client_exit() - uninitialize a host1x client | |
| 753 | + * @client: host1x client | |
| 754 | + */ | |
| 755 | +void host1x_client_exit(struct host1x_client *client) | |
| 756 | +{ | |
| 757 | + mutex_destroy(&client->lock); | |
| 758 | +} | |
| 759 | +EXPORT_SYMBOL(host1x_client_exit); | |
| 760 | + | |
| 738 | 761 | /** |
| 739 | 762 | * __host1x_client_register() - register a host1x client |
| 740 | 763 | * @client: host1x client |
| @@ -747,16 +770,11 @@ EXPORT_SYMBOL(host1x_driver_unregister); · 6 unmodified lines | ||
| 747 | 770 | * device and call host1x_device_init(), which will in turn call each client's |
| 748 | 771 | * &host1x_client_ops.init implementation. |
| 749 | 772 | */ |
| 750 | −int __host1x_client_register(struct host1x_client *client, | |
| 751 | − struct lock_class_key *key) | |
| 773 | +int __host1x_client_register(struct host1x_client *client) | |
| 752 | 774 | { |
| 753 | 775 | struct host1x *host1x; |
| 754 | 776 | int err; |
| 755 | 777 | |
| 756 | − INIT_LIST_HEAD(&client->list); | |
| 757 | − __mutex_init(&client->lock, "host1x client lock", key); | |
| 758 | − client->usecount = 0; | |
| 759 | − | |
| 760 | 778 | mutex_lock(&devices_lock); |
| 761 | 779 | |
| 762 | 780 | list_for_each_entry(host1x, &devices, list) { |
| @@ -93,11 +93,11 @@ menu "Special HID drivers" · 92 unmodified lines | ||
| 93 | 93 | depends on HID |
| 94 | 94 | |
| 95 | 95 | config HID_A4TECH |
| 96 | − tristate "A4 tech mice" | |
| 96 | + tristate "A4TECH mice" | |
| 97 | 97 | depends on HID |
| 98 | 98 | default !EXPERT |
| 99 | 99 | help |
| 100 | − Support for A4 tech X5 and WOP-35 / Trust 450L mice. | |
| 100 | + Support for some A4TECH mice with two scroll wheels. | |
| 101 | 101 | |
| 102 | 102 | config HID_ACCUTOUCH |
| 103 | 103 | tristate "Accutouch touch device" |
| @@ -922,6 +922,21 @@ config HID_SAMSUNG · 818 unmodified lines | ||
| 922 | 922 | help |
| 923 | 923 | Support for Samsung InfraRed remote control or keyboards. |
| 924 | 924 | |
| 925 | +config HID_SEMITEK | |
| 926 | + tristate "Semitek USB keyboards" | |
| 927 | + depends on HID | |
| 928 | + help | |
| 929 | + Support for Semitek USB keyboards that are not fully compliant | |
| 930 | + with the HID standard. | |
| 931 | + | |
| 932 | + There are many variants, including: | |
| 933 | + - GK61, GK64, GK68, GK84, GK96, etc. | |
| 934 | + - SK61, SK64, SK68, SK84, SK96, etc. | |
| 935 | + - Dierya DK61/DK66 | |
| 936 | + - Tronsmart TK09R | |
| 937 | + - Woo-dy | |
| 938 | + - X-Bows Nature/Knight | |
| 939 | + | |
| 925 | 940 | config HID_SONY |
| 926 | 941 | tristate "Sony PS2/3/4 accessories" |
| 927 | 942 | depends on USB_HID |
| @@ -106,6 +106,7 @@ obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \ · 105 unmodified lines | ||
| 106 | 106 | obj-$(CONFIG_HID_RMI) += hid-rmi.o |
| 107 | 107 | obj-$(CONFIG_HID_SAITEK) += hid-saitek.o |
| 108 | 108 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o |
| 109 | +obj-$(CONFIG_HID_SEMITEK) += hid-semitek.o | |
| 109 | 110 | obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o |
| 110 | 111 | obj-$(CONFIG_HID_SONY) += hid-sony.o |
| 111 | 112 | obj-$(CONFIG_HID_SPEEDLINK) += hid-speedlink.o |
| @@ -88,6 +88,7 @@ static void amd_sfh_work(struct work_struct *work) · 87 unmodified lines | ||
| 88 | 88 | sensor_index = req_node->sensor_idx; |
| 89 | 89 | report_id = req_node->report_id; |
| 90 | 90 | node_type = req_node->report_type; |
| 91 | + kfree(req_node); | |
| 91 | 92 | |
| 92 | 93 | if (node_type == HID_FEATURE_REPORT) { |
| 93 | 94 | report_size = get_feature_report(sensor_index, report_id, |
| @@ -142,7 +143,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) · 48 unmodified lines | ||
| 142 | 143 | int rc, i; |
| 143 | 144 | |
| 144 | 145 | dev = &privdata->pdev->dev; |
| 145 | − cl_data = kzalloc(sizeof(*cl_data), GFP_KERNEL); | |
| 146 | + cl_data = devm_kzalloc(dev, sizeof(*cl_data), GFP_KERNEL); | |
| 146 | 147 | if (!cl_data) |
| 147 | 148 | return -ENOMEM; |
| 148 | 149 | |
| @@ -175,12 +176,12 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) · 26 unmodified lines | ||
| 175 | 176 | rc = -EINVAL; |
| 176 | 177 | goto cleanup; |
| 177 | 178 | } |
| 178 | − cl_data->feature_report[i] = kzalloc(feature_report_size, GFP_KERNEL); | |
| 179 | + cl_data->feature_report[i] = devm_kzalloc(dev, feature_report_size, GFP_KERNEL); | |
| 179 | 180 | if (!cl_data->feature_report[i]) { |
| 180 | 181 | rc = -ENOMEM; |
| 181 | 182 | goto cleanup; |
| 182 | 183 | } |
| 183 | − cl_data->input_report[i] = kzalloc(input_report_size, GFP_KERNEL); | |
| 184 | + cl_data->input_report[i] = devm_kzalloc(dev, input_report_size, GFP_KERNEL); | |
| 184 | 185 | if (!cl_data->input_report[i]) { |
| 185 | 186 | rc = -ENOMEM; |
| 186 | 187 | goto cleanup; |
| @@ -189,7 +190,8 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) · 2 unmodified lines | ||
| 189 | 190 | info.sensor_idx = cl_idx; |
| 190 | 191 | info.dma_address = cl_data->sensor_dma_addr[i]; |
| 191 | 192 | |
| 192 | − cl_data->report_descr[i] = kzalloc(cl_data->report_descr_sz[i], GFP_KERNEL); | |
| 193 | + cl_data->report_descr[i] = | |
| 194 | + devm_kzalloc(dev, cl_data->report_descr_sz[i], GFP_KERNEL); | |
| 193 | 195 | if (!cl_data->report_descr[i]) { |
| 194 | 196 | rc = -ENOMEM; |
| 195 | 197 | goto cleanup; |
| @@ -214,11 +216,11 @@ cleanup: · 18 unmodified lines | ||
| 214 | 216 | cl_data->sensor_virt_addr[i], |
| 215 | 217 | cl_data->sensor_dma_addr[i]); |
| 216 | 218 | } |
| 217 | − kfree(cl_data->feature_report[i]); | |
| 218 | − kfree(cl_data->input_report[i]); | |
| 219 | − kfree(cl_data->report_descr[i]); | |
| 219 | + devm_kfree(dev, cl_data->feature_report[i]); | |
| 220 | + devm_kfree(dev, cl_data->input_report[i]); | |
| 221 | + devm_kfree(dev, cl_data->report_descr[i]); | |
| 220 | 222 | } |
| 221 | − kfree(cl_data); | |
| 223 | + devm_kfree(dev, cl_data); | |
| 222 | 224 | return rc; |
| 223 | 225 | } |
| 224 | 226 | |
| @@ -241,6 +243,5 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata) · 16 unmodified lines | ||
| 241 | 243 | cl_data->sensor_dma_addr[i]); |
| 242 | 244 | } |
| 243 | 245 | } |
| 244 | − kfree(cl_data); | |
| 245 | 246 | return 0; |
| 246 | 247 | } |
| @@ -162,9 +162,6 @@ void amdtp_hid_remove(struct amdtp_cl_data *cli_data) · 161 unmodified lines | ||
| 162 | 162 | int i; |
| 163 | 163 | |
| 164 | 164 | for (i = 0; i < cli_data->num_hid_devices; ++i) { |
| 165 | − kfree(cli_data->feature_report[i]); | |
| 166 | − kfree(cli_data->input_report[i]); | |
| 167 | − kfree(cli_data->report_descr[i]); | |
| 168 | 165 | if (cli_data->hid_sensor_hubs[i]) { |
| 169 | 166 | kfree(cli_data->hid_sensor_hubs[i]->driver_data); |
| 170 | 167 | hid_destroy_device(cli_data->hid_sensor_hubs[i]); |
| @@ -147,6 +147,8 @@ static const struct hid_device_id a4_devices[] = { · 146 unmodified lines | ||
| 147 | 147 | .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, |
| 148 | 148 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649), |
| 149 | 149 | .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, |
| 150 | + { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_NB_95), | |
| 151 | + .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, | |
| 150 | 152 | { } |
| 151 | 153 | }; |
| 152 | 154 | MODULE_DEVICE_TABLE(hid, a4_devices); |
| @@ -79,10 +79,9 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); · 78 unmodified lines | ||
| 79 | 79 | #define QUIRK_T100_KEYBOARD BIT(6) |
| 80 | 80 | #define QUIRK_T100CHI BIT(7) |
| 81 | 81 | #define QUIRK_G752_KEYBOARD BIT(8) |
| 82 | −#define QUIRK_T101HA_DOCK BIT(9) | |
| 83 | −#define QUIRK_T90CHI BIT(10) | |
| 84 | −#define QUIRK_MEDION_E1239T BIT(11) | |
| 85 | −#define QUIRK_ROG_NKEY_KEYBOARD BIT(12) | |
| 82 | +#define QUIRK_T90CHI BIT(9) | |
| 83 | +#define QUIRK_MEDION_E1239T BIT(10) | |
| 84 | +#define QUIRK_ROG_NKEY_KEYBOARD BIT(11) | |
| 86 | 85 | |
| 87 | 86 | #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ |
| 88 | 87 | QUIRK_NO_INIT_REPORTS | \ |
| @@ -335,7 +334,7 @@ static int asus_raw_event(struct hid_device *hdev, · 246 unmodified lines | ||
| 335 | 334 | if (drvdata->quirks & QUIRK_MEDION_E1239T) |
| 336 | 335 | return asus_e1239t_event(drvdata, data, size); |
| 337 | 336 | |
| 338 | − if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) { | |
| 337 | + if (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) { | |
| 339 | 338 | /* |
| 340 | 339 | * Skip these report ID, the device emits a continuous stream associated |
| 341 | 340 | * with the AURA mode it is in which looks like an 'echo'. |
| @@ -355,6 +354,16 @@ static int asus_raw_event(struct hid_device *hdev, · 13 unmodified lines | ||
| 355 | 354 | return -1; |
| 356 | 355 | } |
| 357 | 356 | } |
| 357 | + if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) { | |
| 358 | + /* | |
| 359 | + * G713 and G733 send these codes on some keypresses, depending on | |
| 360 | + * the key pressed it can trigger a shutdown event if not caught. | |
| 361 | + */ | |
| 362 | + if(data[0] == 0x02 && data[1] == 0x30) { | |
| 363 | + return -1; | |
| 364 | + } | |
| 365 | + } | |
| 366 | + | |
| 358 | 367 | } |
| 359 | 368 | |
| 360 | 369 | return 0; |
| @@ -1072,11 +1081,6 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) · 711 unmodified lines | ||
| 1072 | 1081 | return ret; |
| 1073 | 1082 | } |
| 1074 | 1083 | |
| 1075 | − /* use hid-multitouch for T101HA touchpad */ | |
| 1076 | − if (id->driver_data & QUIRK_T101HA_DOCK && | |
| 1077 | − hdev->collection->usage == HID_GD_MOUSE) | |
| 1078 | − return -ENODEV; | |
| 1079 | − | |
| 1080 | 1084 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
| 1081 | 1085 | if (ret) { |
| 1082 | 1086 | hid_err(hdev, "Asus hw start failed: %d\n", ret); |
| @@ -1230,8 +1234,6 @@ static const struct hid_device_id asus_devices[] = { · 147 unmodified lines | ||
| 1230 | 1234 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, |
| 1231 | 1235 | USB_DEVICE_ID_ASUSTEK_T100TAF_KEYBOARD), |
| 1232 | 1236 | QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES }, |
| 1233 | − { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, | |
| 1234 | − USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD), QUIRK_T101HA_DOCK }, | |
| 1235 | 1237 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_ASUS_AK1D) }, |
| 1236 | 1238 | { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) }, |
| 1237 | 1239 | { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) }, |
| @@ -1239,6 +1241,12 @@ static const struct hid_device_id asus_devices[] = { · 1 unmodified line | ||
| 1239 | 1241 | USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD), QUIRK_T100CHI }, |
| 1240 | 1242 | { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE_MEDION_E1239T), |
| 1241 | 1243 | QUIRK_MEDION_E1239T }, |
| 1244 | + /* | |
| 1245 | + * Note bind to the HID_GROUP_GENERIC group, so that we only bind to the keyboard | |
| 1246 | + * part, while letting hid-multitouch.c handle the touchpad. | |
| 1247 | + */ | |
| 1248 | + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, | |
| 1249 | + USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD) }, | |
| 1242 | 1250 | { } |
| 1243 | 1251 | }; |
| 1244 | 1252 | MODULE_DEVICE_TABLE(hid, asus_devices); |
| @@ -2005,6 +2005,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) · 2004 unmodified lines | ||
| 2005 | 2005 | case BUS_I2C: |
| 2006 | 2006 | bus = "I2C"; |
| 2007 | 2007 | break; |
| 2008 | + case BUS_VIRTUAL: | |
| 2009 | + bus = "VIRTUAL"; | |
| 2010 | + break; | |
| 2008 | 2011 | default: |
| 2009 | 2012 | bus = "<UNKNOWN>"; |
| 2010 | 2013 | } |
| @@ -2588,7 +2591,6 @@ int hid_check_keys_pressed(struct hid_device *hid) · 577 unmodified lines | ||
| 2588 | 2591 | |
| 2589 | 2592 | return 0; |
| 2590 | 2593 | } |
| 2591 | − | |
| 2592 | 2594 | EXPORT_SYMBOL_GPL(hid_check_keys_pressed); |
| 2593 | 2595 | |
| 2594 | 2596 | static int __init hid_init(void) |
| @@ -930,6 +930,9 @@ static const char *keys[KEY_MAX + 1] = { · 929 unmodified lines | ||
| 930 | 930 | [KEY_APPSELECT] = "AppSelect", |
| 931 | 931 | [KEY_SCREENSAVER] = "ScreenSaver", |
| 932 | 932 | [KEY_VOICECOMMAND] = "VoiceCommand", |
| 933 | + [KEY_ASSISTANT] = "Assistant", | |
| 934 | + [KEY_KBD_LAYOUT_NEXT] = "KbdLayoutNext", | |
| 935 | + [KEY_EMOJI_PICKER] = "EmojiPicker", | |
| 933 | 936 | [KEY_BRIGHTNESS_MIN] = "BrightnessMin", |
| 934 | 937 | [KEY_BRIGHTNESS_MAX] = "BrightnessMax", |
| 935 | 938 | [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto", |
| @@ -201,7 +201,7 @@ struct ft260_i2c_write_request_report { · 200 unmodified lines | ||
| 201 | 201 | u8 address; /* 7-bit I2C address */ |
| 202 | 202 | u8 flag; /* I2C transaction condition */ |
| 203 | 203 | u8 length; /* data payload length */ |
| 204 | − u8 data[60]; /* data payload */ | |
| 204 | + u8 data[FT260_WR_DATA_MAX]; /* data payload */ | |
| 205 | 205 | } __packed; |
| 206 | 206 | |
| 207 | 207 | struct ft260_i2c_read_request_report { |
| @@ -249,7 +249,10 @@ static int ft260_hid_feature_report_get(struct hid_device *hdev, · 41 unmodified lines | ||
| 249 | 249 | |
| 250 | 250 | ret = hid_hw_raw_request(hdev, report_id, buf, len, HID_FEATURE_REPORT, |
| 251 | 251 | HID_REQ_GET_REPORT); |
| 252 | − memcpy(data, buf, len); | |
| 252 | + if (likely(ret == len)) | |
| 253 | + memcpy(data, buf, len); | |
| 254 | + else if (ret >= 0) | |
| 255 | + ret = -EIO; | |
| 253 | 256 | kfree(buf); |
| 254 | 257 | return ret; |
| 255 | 258 | } |
| @@ -298,7 +301,7 @@ static int ft260_xfer_status(struct ft260_device *dev) · 42 unmodified lines | ||
| 298 | 301 | |
| 299 | 302 | ret = ft260_hid_feature_report_get(hdev, FT260_I2C_STATUS, |
| 300 | 303 | (u8 *)&report, sizeof(report)); |
| 301 | − if (ret < 0) { | |
| 304 | + if (unlikely(ret < 0)) { | |
| 302 | 305 | hid_err(hdev, "failed to retrieve status: %d\n", ret); |
| 303 | 306 | return ret; |
| 304 | 307 | } |
| @@ -429,6 +432,9 @@ static int ft260_smbus_write(struct ft260_device *dev, u8 addr, u8 cmd, · 124 unmodified lines | ||
| 429 | 432 | struct ft260_i2c_write_request_report *rep = |
| 430 | 433 | (struct ft260_i2c_write_request_report *)dev->write_buf; |
| 431 | 434 | |
| 435 | + if (data_len >= sizeof(rep->data)) | |
| 436 | + return -EINVAL; | |
| 437 | + | |
| 432 | 438 | rep->address = addr; |
| 433 | 439 | rep->data[0] = cmd; |
| 434 | 440 | rep->length = data_len + 1; |
| @@ -721,10 +727,9 @@ static int ft260_get_system_config(struct hid_device *hdev, · 286 unmodified lines | ||
| 721 | 727 | |
| 722 | 728 | ret = ft260_hid_feature_report_get(hdev, FT260_SYSTEM_SETTINGS, |
| 723 | 729 | (u8 *)cfg, len); |
| 724 | − if (ret != len) { | |
| 730 | + if (ret < 0) { | |
| 725 | 731 | hid_err(hdev, "failed to retrieve system status\n"); |
| 726 | − if (ret >= 0) | |
| 727 | − return -EIO; | |
| 732 | + return ret; | |
| 728 | 733 | } |
| 729 | 734 | return 0; |
| 730 | 735 | } |
| @@ -777,8 +782,8 @@ static int ft260_byte_show(struct hid_device *hdev, int id, u8 *cfg, int len, · 46 unmodified lines | ||
| 777 | 782 | int ret; |
| 778 | 783 | |
| 779 | 784 | ret = ft260_hid_feature_report_get(hdev, id, cfg, len); |
| 780 | − if (ret != len && ret >= 0) | |
| 781 | − return -EIO; | |
| 785 | + if (ret < 0) | |
| 786 | + return ret; | |
| 782 | 787 | |
| 783 | 788 | return scnprintf(buf, PAGE_SIZE, "%hi\n", *field); |
| 784 | 789 | } |
| @@ -789,8 +794,8 @@ static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len, · 4 unmodified lines | ||
| 789 | 794 | int ret; |
| 790 | 795 | |
| 791 | 796 | ret = ft260_hid_feature_report_get(hdev, id, cfg, len); |
| 792 | − if (ret != len && ret >= 0) | |
| 793 | − return -EIO; | |
| 797 | + if (ret < 0) | |
| 798 | + return ret; | |
| 794 | 799 | |
| 795 | 800 | return scnprintf(buf, PAGE_SIZE, "%hi\n", le16_to_cpu(*field)); |
| 796 | 801 | } |
| @@ -941,10 +946,8 @@ static int ft260_probe(struct hid_device *hdev, const struct hid_device_id *id) · 144 unmodified lines | ||
| 941 | 946 | |
| 942 | 947 | ret = ft260_hid_feature_report_get(hdev, FT260_CHIP_VERSION, |
| 943 | 948 | (u8 *)&version, sizeof(version)); |
| 944 | − if (ret != sizeof(version)) { | |
| 949 | + if (ret < 0) { | |
| 945 | 950 | hid_err(hdev, "failed to retrieve chip version\n"); |
| 946 | − if (ret >= 0) | |
| 947 | − ret = -EIO; | |
| 948 | 951 | goto err_hid_close; |
| 949 | 952 | } |
| 950 | 953 | |
| @@ -54,6 +54,7 @@ static const struct hid_device_id gt683r_led_id[] = { · 53 unmodified lines | ||
| 54 | 54 | { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) }, |
| 55 | 55 | { } |
| 56 | 56 | }; |
| 57 | +MODULE_DEVICE_TABLE(hid, gt683r_led_id); | |
| 57 | 58 | |
| 58 | 59 | static void gt683r_brightness_set(struct led_classdev *led_cdev, |
| 59 | 60 | enum led_brightness brightness) |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 |
| 27 | 27 | #define USB_DEVICE_ID_A4TECH_X5_005D 0x000a |
| 28 | 28 | #define USB_DEVICE_ID_A4TECH_RP_649 0x001a |
| 29 | +#define USB_DEVICE_ID_A4TECH_NB_95 0x022b | |
| 29 | 30 | |
| 30 | 31 | #define USB_VENDOR_ID_AASHIMA 0x06d6 |
| 31 | 32 | #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 |
| @@ -299,8 +300,6 @@ · 267 unmodified lines | ||
| 299 | 300 | |
| 300 | 301 | #define USB_VENDOR_ID_CORSAIR 0x1b1c |
| 301 | 302 | #define USB_DEVICE_ID_CORSAIR_K90 0x1b02 |
| 302 | − | |
| 303 | −#define USB_VENDOR_ID_CORSAIR 0x1b1c | |
| 304 | 303 | #define USB_DEVICE_ID_CORSAIR_K70R 0x1b09 |
| 305 | 304 | #define USB_DEVICE_ID_CORSAIR_K95RGB 0x1b11 |
| 306 | 305 | #define USB_DEVICE_ID_CORSAIR_M65RGB 0x1b12 |
| @@ -751,6 +750,7 @@ · 444 unmodified lines | ||
| 751 | 750 | #define USB_DEVICE_ID_LENOVO_X1_COVER 0x6085 |
| 752 | 751 | #define USB_DEVICE_ID_LENOVO_X1_TAB 0x60a3 |
| 753 | 752 | #define USB_DEVICE_ID_LENOVO_X1_TAB3 0x60b5 |
| 753 | +#define USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E 0x600e | |
| 754 | 754 | #define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D 0x608d |
| 755 | 755 | #define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019 0x6019 |
| 756 | 756 | #define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_602E 0x602e |
| @@ -1051,6 +1051,7 @@ · 294 unmodified lines | ||
| 1051 | 1051 | #define USB_DEVICE_ID_SAITEK_X52 0x075c |
| 1052 | 1052 | #define USB_DEVICE_ID_SAITEK_X52_2 0x0255 |
| 1053 | 1053 | #define USB_DEVICE_ID_SAITEK_X52_PRO 0x0762 |
| 1054 | +#define USB_DEVICE_ID_SAITEK_X65 0x0b6a | |
| 1054 | 1055 | |
| 1055 | 1056 | #define USB_VENDOR_ID_SAMSUNG 0x0419 |
| 1056 | 1057 | #define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 |
| @@ -1060,6 +1061,9 @@ · 3 unmodified lines | ||
| 1060 | 1061 | #define USB_DEVICE_ID_SEMICO_USB_KEYKOARD 0x0023 |
| 1061 | 1062 | #define USB_DEVICE_ID_SEMICO_USB_KEYKOARD2 0x0027 |
| 1062 | 1063 | |
| 1064 | +#define USB_VENDOR_ID_SEMITEK 0x1ea7 | |
| 1065 | +#define USB_DEVICE_ID_SEMITEK_KEYBOARD 0x0907 | |
| 1066 | + | |
| 1063 | 1067 | #define USB_VENDOR_ID_SENNHEISER 0x1395 |
| 1064 | 1068 | #define USB_DEVICE_ID_SENNHEISER_BTD500USB 0x002c |
| 1065 | 1069 | |
| @@ -1161,6 +1165,7 @@ · 95 unmodified lines | ||
| 1161 | 1165 | #define USB_DEVICE_ID_SYNAPTICS_DELL_K12A 0x2819 |
| 1162 | 1166 | #define USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012 0x2968 |
| 1163 | 1167 | #define USB_DEVICE_ID_SYNAPTICS_TP_V103 0x5710 |
| 1168 | +#define USB_DEVICE_ID_SYNAPTICS_DELL_K15A 0x6e21 | |
| 1164 | 1169 | #define USB_DEVICE_ID_SYNAPTICS_ACER_ONE_S1002 0x73f4 |
| 1165 | 1170 | #define USB_DEVICE_ID_SYNAPTICS_ACER_ONE_S1003 0x73f5 |
| 1166 | 1171 | #define USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5 0x81a7 |
| @@ -964,6 +964,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel · 963 unmodified lines | ||
| 964 | 964 | |
| 965 | 965 | case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break; |
| 966 | 966 | case 0x0cf: map_key_clear(KEY_VOICECOMMAND); break; |
| 967 | + | |
| 968 | + case 0x0d9: map_key_clear(KEY_EMOJI_PICKER); break; | |
| 969 | + | |
| 967 | 970 | case 0x0e0: map_abs_clear(ABS_VOLUME); break; |
| 968 | 971 | case 0x0e2: map_key_clear(KEY_MUTE); break; |
| 969 | 972 | case 0x0e5: map_key_clear(KEY_BASSBOOST); break; |
| @@ -1263,6 +1263,7 @@ static int hidpp20_battery_map_status_voltage(u8 data[3], int *voltage, · 1262 unmodified lines | ||
| 1263 | 1263 | int status; |
| 1264 | 1264 | |
| 1265 | 1265 | long flags = (long) data[2]; |
| 1266 | + *level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; | |
| 1266 | 1267 | |
| 1267 | 1268 | if (flags & 0x80) |
| 1268 | 1269 | switch (flags & 0x07) { |
| @@ -693,7 +693,7 @@ static int magicmouse_probe(struct hid_device *hdev, · 692 unmodified lines | ||
| 693 | 693 | if (id->vendor == USB_VENDOR_ID_APPLE && |
| 694 | 694 | id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 && |
| 695 | 695 | hdev->type != HID_TYPE_USBMOUSE) |
| 696 | − return 0; | |
| 696 | + return -ENODEV; | |
| 697 | 697 | |
| 698 | 698 | msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL); |
| 699 | 699 | if (msc == NULL) { |
| @@ -779,7 +779,10 @@ err_stop_hw: · 79 unmodified lines | ||
| 779 | 779 | static void magicmouse_remove(struct hid_device *hdev) |
| 780 | 780 | { |
| 781 | 781 | struct magicmouse_sc *msc = hid_get_drvdata(hdev); |
| 782 | − cancel_delayed_work_sync(&msc->work); | |
| 782 | + | |
| 783 | + if (msc) | |
| 784 | + cancel_delayed_work_sync(&msc->work); | |
| 785 | + | |
| 783 | 786 | hid_hw_stop(hdev); |
| 784 | 787 | } |
| 785 | 788 | |
| @@ -70,6 +70,7 @@ MODULE_LICENSE("GPL"); · 69 unmodified lines | ||
| 70 | 70 | #define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18) |
| 71 | 71 | #define MT_QUIRK_SEPARATE_APP_REPORT BIT(19) |
| 72 | 72 | #define MT_QUIRK_FORCE_MULTI_INPUT BIT(20) |
| 73 | +#define MT_QUIRK_DISABLE_WAKEUP BIT(21) | |
| 73 | 74 | |
| 74 | 75 | #define MT_INPUTMODE_TOUCHSCREEN 0x02 |
| 75 | 76 | #define MT_INPUTMODE_TOUCHPAD 0x03 |
| @@ -191,6 +192,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app); · 115 unmodified lines | ||
| 191 | 192 | #define MT_CLS_EXPORT_ALL_INPUTS 0x0013 |
| 192 | 193 | /* reserved 0x0014 */ |
| 193 | 194 | #define MT_CLS_WIN_8_FORCE_MULTI_INPUT 0x0015 |
| 195 | +#define MT_CLS_WIN_8_DISABLE_WAKEUP 0x0016 | |
| 194 | 196 | |
| 195 | 197 | /* vendor specific classes */ |
| 196 | 198 | #define MT_CLS_3M 0x0101 |
| @@ -283,6 +285,15 @@ static const struct mt_class mt_classes[] = { · 86 unmodified lines | ||
| 283 | 285 | MT_QUIRK_WIN8_PTP_BUTTONS | |
| 284 | 286 | MT_QUIRK_FORCE_MULTI_INPUT, |
| 285 | 287 | .export_all_inputs = true }, |
| 288 | + { .name = MT_CLS_WIN_8_DISABLE_WAKEUP, | |
| 289 | + .quirks = MT_QUIRK_ALWAYS_VALID | | |
| 290 | + MT_QUIRK_IGNORE_DUPLICATES | | |
| 291 | + MT_QUIRK_HOVERING | | |
| 292 | + MT_QUIRK_CONTACT_CNT_ACCURATE | | |
| 293 | + MT_QUIRK_STICKY_FINGERS | | |
| 294 | + MT_QUIRK_WIN8_PTP_BUTTONS | | |
| 295 | + MT_QUIRK_DISABLE_WAKEUP, | |
| 296 | + .export_all_inputs = true }, | |
| 286 | 297 | |
| 287 | 298 | /* |
| 288 | 299 | * vendor specific classes |
| @@ -604,9 +615,13 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td, · 315 unmodified lines | ||
| 604 | 615 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) |
| 605 | 616 | continue; |
| 606 | 617 | |
| 607 | − for (n = 0; n < field->report_count; n++) { | |
| 608 | − if (field->usage[n].hid == HID_DG_CONTACTID) | |
| 609 | − rdata->is_mt_collection = true; | |
| 618 | + if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { | |
| 619 | + for (n = 0; n < field->report_count; n++) { | |
| 620 | + if (field->usage[n].hid == HID_DG_CONTACTID) { | |
| 621 | + rdata->is_mt_collection = true; | |
| 622 | + break; | |
| 623 | + } | |
| 624 | + } | |
| 610 | 625 | } |
| 611 | 626 | } |
| 612 | 627 | |
| @@ -759,7 +774,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, · 146 unmodified lines | ||
| 759 | 774 | return 1; |
| 760 | 775 | case HID_DG_CONFIDENCE: |
| 761 | 776 | if ((cls->name == MT_CLS_WIN_8 || |
| 762 | − cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT) && | |
| 777 | + cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || | |
| 778 | + cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP) && | |
| 763 | 779 | (field->application == HID_DG_TOUCHPAD || |
| 764 | 780 | field->application == HID_DG_TOUCHSCREEN)) |
| 765 | 781 | app->quirks |= MT_QUIRK_CONFIDENCE; |
| @@ -1576,13 +1592,13 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) · 810 unmodified lines | ||
| 1576 | 1592 | /* we do not set suffix = "Touchscreen" */ |
| 1577 | 1593 | hi->input->name = hdev->name; |
| 1578 | 1594 | break; |
| 1579 | − case HID_DG_STYLUS: | |
| 1580 | − /* force BTN_STYLUS to allow tablet matching in udev */ | |
| 1581 | − __set_bit(BTN_STYLUS, hi->input->keybit); | |
| 1582 | − break; | |
| 1583 | 1595 | case HID_VD_ASUS_CUSTOM_MEDIA_KEYS: |
| 1584 | 1596 | suffix = "Custom Media Keys"; |
| 1585 | 1597 | break; |
| 1598 | + case HID_DG_STYLUS: | |
| 1599 | + /* force BTN_STYLUS to allow tablet matching in udev */ | |
| 1600 | + __set_bit(BTN_STYLUS, hi->input->keybit); | |
| 1601 | + fallthrough; | |
| 1586 | 1602 | case HID_DG_PEN: |
| 1587 | 1603 | suffix = "Stylus"; |
| 1588 | 1604 | break; |
| @@ -1749,8 +1765,14 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) · 160 unmodified lines | ||
| 1749 | 1765 | #ifdef CONFIG_PM |
| 1750 | 1766 | static int mt_suspend(struct hid_device *hdev, pm_message_t state) |
| 1751 | 1767 | { |
| 1768 | + struct mt_device *td = hid_get_drvdata(hdev); | |
| 1769 | + | |
| 1752 | 1770 | /* High latency is desirable for power savings during S3/S0ix */ |
| 1753 | − mt_set_modes(hdev, HID_LATENCY_HIGH, true, true); | |
| 1771 | + if (td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) | |
| 1772 | + mt_set_modes(hdev, HID_LATENCY_HIGH, false, false); | |
| 1773 | + else | |
| 1774 | + mt_set_modes(hdev, HID_LATENCY_HIGH, true, true); | |
| 1775 | + | |
| 1754 | 1776 | return 0; |
| 1755 | 1777 | } |
| 1756 | 1778 | |
| @@ -1809,6 +1831,12 @@ static const struct hid_device_id mt_devices[] = { · 52 unmodified lines | ||
| 1809 | 1831 | MT_USB_DEVICE(USB_VENDOR_ID_ANTON, |
| 1810 | 1832 | USB_DEVICE_ID_ANTON_TOUCH_PAD) }, |
| 1811 | 1833 | |
| 1834 | + /* Asus T101HA */ | |
| 1835 | + { .driver_data = MT_CLS_WIN_8_DISABLE_WAKEUP, | |
| 1836 | + HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, | |
| 1837 | + USB_VENDOR_ID_ASUSTEK, | |
| 1838 | + USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD) }, | |
| 1839 | + | |
| 1812 | 1840 | /* Asus T304UA */ |
| 1813 | 1841 | { .driver_data = MT_CLS_ASUS, |
| 1814 | 1842 | HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, |
| @@ -110,6 +110,7 @@ static const struct hid_device_id hid_quirks[] = { · 109 unmodified lines | ||
| 110 | 110 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912), HID_QUIRK_MULTI_INPUT }, |
| 111 | 111 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406XE), HID_QUIRK_MULTI_INPUT }, |
| 112 | 112 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2), HID_QUIRK_ALWAYS_POLL }, |
| 113 | + { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E), HID_QUIRK_ALWAYS_POLL }, | |
| 113 | 114 | { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D), HID_QUIRK_ALWAYS_POLL }, |
| 114 | 115 | { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019), HID_QUIRK_ALWAYS_POLL }, |
| 115 | 116 | { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_602E), HID_QUIRK_ALWAYS_POLL }, |
| @@ -158,6 +159,7 @@ static const struct hid_device_id hid_quirks[] = { · 42 unmodified lines | ||
| 158 | 159 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, |
| 159 | 160 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_2), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, |
| 160 | 161 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_PRO), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, |
| 162 | + { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X65), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, | |
| 161 | 163 | { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD2), HID_QUIRK_NO_INIT_REPORTS }, |
| 162 | 164 | { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD), HID_QUIRK_NO_INIT_REPORTS }, |
| 163 | 165 | { HID_USB_DEVICE(USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB), HID_QUIRK_NOGET }, |
| @@ -176,6 +178,7 @@ static const struct hid_device_id hid_quirks[] = { · 12 unmodified lines | ||
| 176 | 178 | { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_QUAD_HD), HID_QUIRK_NO_INIT_REPORTS }, |
| 177 | 179 | { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP_V103), HID_QUIRK_NO_INIT_REPORTS }, |
| 178 | 180 | { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DELL_K12A), HID_QUIRK_NO_INIT_REPORTS }, |
| 181 | + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DELL_K15A), HID_QUIRK_NO_INIT_REPORTS }, | |
| 179 | 182 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD), HID_QUIRK_BADPAD }, |
| 180 | 183 | { HID_USB_DEVICE(USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS), HID_QUIRK_MULTI_INPUT }, |
| 181 | 184 | { HID_USB_DEVICE(USB_VENDOR_ID_TPV, USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN_8882), HID_QUIRK_NOGET }, |
| @@ -211,6 +214,7 @@ static const struct hid_device_id hid_have_special_driver[] = { · 29 unmodified lines | ||
| 211 | 214 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, |
| 212 | 215 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, |
| 213 | 216 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, |
| 217 | + { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_NB_95) }, | |
| 214 | 218 | #endif |
| 215 | 219 | #if IS_ENABLED(CONFIG_HID_ACCUTOUCH) |
| 216 | 220 | { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) }, |
| @@ -0,0 +1,40 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later | |
| 2 | +/* | |
| 3 | + * HID driver for Semitek keyboards | |
| 4 | + * | |
| 5 | + * Copyright (c) 2021 Benjamin Moody | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#include <linux/device.h> | |
| 9 | +#include <linux/hid.h> | |
| 10 | +#include <linux/module.h> | |
| 11 | + | |
| 12 | +#include "hid-ids.h" | |
| 13 | + | |
| 14 | +static __u8 *semitek_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |
| 15 | + unsigned int *rsize) | |
| 16 | +{ | |
| 17 | + /* In the report descriptor for interface 2, fix the incorrect | |
| 18 | + description of report ID 0x04 (the report contains a | |
| 19 | + bitmask, not an array of keycodes.) */ | |
| 20 | + if (*rsize == 0xcb && rdesc[0x83] == 0x81 && rdesc[0x84] == 0x00) { | |
| 21 | + hid_info(hdev, "fixing up Semitek report descriptor\n"); | |
| 22 | + rdesc[0x84] = 0x02; | |
| 23 | + } | |
| 24 | + return rdesc; | |
| 25 | +} | |
| 26 | + | |
| 27 | +static const struct hid_device_id semitek_devices[] = { | |
| 28 | + { HID_USB_DEVICE(USB_VENDOR_ID_SEMITEK, USB_DEVICE_ID_SEMITEK_KEYBOARD) }, | |
| 29 | + { } | |
| 30 | +}; | |
| 31 | +MODULE_DEVICE_TABLE(hid, semitek_devices); | |
| 32 | + | |
| 33 | +static struct hid_driver semitek_driver = { | |
| 34 | + .name = "semitek", | |
| 35 | + .id_table = semitek_devices, | |
| 36 | + .report_fixup = semitek_report_fixup, | |
| 37 | +}; | |
| 38 | +module_hid_driver(semitek_driver); | |
| 39 | + | |
| 40 | +MODULE_LICENSE("GPL"); | |
| @@ -387,7 +387,7 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr, · 386 unmodified lines | ||
| 387 | 387 | struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev); |
| 388 | 388 | int index, field_index, usage; |
| 389 | 389 | char name[HID_CUSTOM_NAME_LENGTH]; |
| 390 | − int value; | |
| 390 | + int value, ret; | |
| 391 | 391 | |
| 392 | 392 | if (sscanf(attr->attr.name, "feature-%x-%x-%s", &index, &usage, |
| 393 | 393 | name) == 3) { |
| @@ -403,8 +403,10 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr, · 9 unmodified lines | ||
| 403 | 403 | |
| 404 | 404 | report_id = sensor_inst->fields[field_index].attribute. |
| 405 | 405 | report_id; |
| 406 | − sensor_hub_set_feature(sensor_inst->hsdev, report_id, | |
| 407 | − index, sizeof(value), &value); | |
| 406 | + ret = sensor_hub_set_feature(sensor_inst->hsdev, report_id, | |
| 407 | + index, sizeof(value), &value); | |
| 408 | + if (ret) | |
| 409 | + return ret; | |
| 408 | 410 | } else |
| 409 | 411 | return -EINVAL; |
| 410 | 412 | |
| @@ -209,16 +209,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, · 208 unmodified lines | ||
| 209 | 209 | buffer_size = buffer_size / sizeof(__s32); |
| 210 | 210 | if (buffer_size) { |
| 211 | 211 | for (i = 0; i < buffer_size; ++i) { |
| 212 | − hid_set_field(report->field[field_index], i, | |
| 213 | − (__force __s32)cpu_to_le32(*buf32)); | |
| 212 | + ret = hid_set_field(report->field[field_index], i, | |
| 213 | + (__force __s32)cpu_to_le32(*buf32)); | |
| 214 | + if (ret) | |
| 215 | + goto done_proc; | |
| 216 | + | |
| 214 | 217 | ++buf32; |
| 215 | 218 | } |
| 216 | 219 | } |
| 217 | 220 | if (remaining_bytes) { |
| 218 | 221 | value = 0; |
| 219 | 222 | memcpy(&value, (u8 *)buf32, remaining_bytes); |
| 220 | − hid_set_field(report->field[field_index], i, | |
| 221 | − (__force __s32)cpu_to_le32(value)); | |
| 223 | + ret = hid_set_field(report->field[field_index], i, | |
| 224 | + (__force __s32)cpu_to_le32(value)); | |
| 225 | + if (ret) | |
| 226 | + goto done_proc; | |
| 222 | 227 | } |
| 223 | 228 | hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT); |
| 224 | 229 | hid_hw_wait(hsdev->hdev); |
| @@ -312,7 +312,7 @@ static int thrustmaster_probe(struct hid_device *hdev, const struct hid_device_i · 311 unmodified lines | ||
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | tm_wheel->change_request = kzalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); |
| 315 | − if (!tm_wheel->model_request) { | |
| 315 | + if (!tm_wheel->change_request) { | |
| 316 | 316 | ret = -ENOMEM; |
| 317 | 317 | goto error5; |
| 318 | 318 | } |
| @@ -45,6 +45,7 @@ · 44 unmodified lines | ||
| 45 | 45 | #define I2C_HID_QUIRK_BOGUS_IRQ BIT(4) |
| 46 | 46 | #define I2C_HID_QUIRK_RESET_ON_RESUME BIT(5) |
| 47 | 47 | #define I2C_HID_QUIRK_BAD_INPUT_SIZE BIT(6) |
| 48 | +#define I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET BIT(7) | |
| 48 | 49 | |
| 49 | 50 | |
| 50 | 51 | /* flags */ |
| @@ -178,6 +179,11 @@ static const struct i2c_hid_quirks { · 127 unmodified lines | ||
| 178 | 179 | I2C_HID_QUIRK_RESET_ON_RESUME }, |
| 179 | 180 | { USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720, |
| 180 | 181 | I2C_HID_QUIRK_BAD_INPUT_SIZE }, |
| 182 | + /* | |
| 183 | + * Sending the wakeup after reset actually break ELAN touchscreen controller | |
| 184 | + */ | |
| 185 | + { USB_VENDOR_ID_ELAN, HID_ANY_ID, | |
| 186 | + I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET }, | |
| 181 | 187 | { 0, 0 } |
| 182 | 188 | }; |
| 183 | 189 | |
| @@ -461,7 +467,8 @@ static int i2c_hid_hwreset(struct i2c_client *client) · 277 unmodified lines | ||
| 461 | 467 | } |
| 462 | 468 | |
| 463 | 469 | /* At least some SIS devices need this after reset */ |
| 464 | − ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); | |
| 470 | + if (!(ihid->quirks & I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET)) | |
| 471 | + ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); | |
| 465 | 472 | |
| 466 | 473 | out_unlock: |
| 467 | 474 | mutex_unlock(&ihid->reset_lock); |
| @@ -990,8 +997,8 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, · 522 unmodified lines | ||
| 990 | 997 | hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); |
| 991 | 998 | hid->product = le16_to_cpu(ihid->hdesc.wProductID); |
| 992 | 999 | |
| 993 | − snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX", | |
| 994 | − client->name, hid->vendor, hid->product); | |
| 1000 | + snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", | |
| 1001 | + client->name, (u16)hid->vendor, (u16)hid->product); | |
| 995 | 1002 | strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); |
| 996 | 1003 | |
| 997 | 1004 | ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); |
| @@ -28,6 +28,8 @@ · 27 unmodified lines | ||
| 28 | 28 | #define EHL_Ax_DEVICE_ID 0x4BB3 |
| 29 | 29 | #define TGL_LP_DEVICE_ID 0xA0FC |
| 30 | 30 | #define TGL_H_DEVICE_ID 0x43FC |
| 31 | +#define ADL_S_DEVICE_ID 0x7AF8 | |
| 32 | +#define ADL_P_DEVICE_ID 0x51FC | |
| 31 | 33 | |
| 32 | 34 | #define REVISION_ID_CHT_A0 0x6 |
| 33 | 35 | #define REVISION_ID_CHT_Ax_SI 0x0 |
| @@ -39,6 +39,8 @@ static const struct pci_device_id ish_pci_tbl[] = { · 38 unmodified lines | ||
| 39 | 39 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, EHL_Ax_DEVICE_ID)}, |
| 40 | 40 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, TGL_LP_DEVICE_ID)}, |
| 41 | 41 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, TGL_H_DEVICE_ID)}, |
| 42 | + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ADL_S_DEVICE_ID)}, | |
| 43 | + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ADL_P_DEVICE_ID)}, | |
| 42 | 44 | {0, } |
| 43 | 45 | }; |
| 44 | 46 | MODULE_DEVICE_TABLE(pci, ish_pci_tbl); |
| @@ -168,9 +168,9 @@ int surface_hid_device_add(struct surface_hid_device *shid) · 167 unmodified lines | ||
| 168 | 168 | |
| 169 | 169 | shid->hid->dev.parent = shid->dev; |
| 170 | 170 | shid->hid->bus = BUS_HOST; |
| 171 | − shid->hid->vendor = cpu_to_le16(shid->attrs.vendor); | |
| 172 | − shid->hid->product = cpu_to_le16(shid->attrs.product); | |
| 173 | − shid->hid->version = cpu_to_le16(shid->hid_desc.hid_version); | |
| 171 | + shid->hid->vendor = get_unaligned_le16(&shid->attrs.vendor); | |
| 172 | + shid->hid->product = get_unaligned_le16(&shid->attrs.product); | |
| 173 | + shid->hid->version = get_unaligned_le16(&shid->hid_desc.hid_version); | |
| 174 | 174 | shid->hid->country = shid->hid_desc.country_code; |
| 175 | 175 | |
| 176 | 176 | snprintf(shid->hid->name, sizeof(shid->hid->name), "Microsoft Surface %04X:%04X", |
| @@ -374,7 +374,7 @@ static int hid_submit_ctrl(struct hid_device *hid) · 373 unmodified lines | ||
| 374 | 374 | raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report; |
| 375 | 375 | dir = usbhid->ctrl[usbhid->ctrltail].dir; |
| 376 | 376 | |
| 377 | − len = ((report->size - 1) >> 3) + 1 + (report->id > 0); | |
| 377 | + len = hid_report_len(report); | |
| 378 | 378 | if (dir == USB_DIR_OUT) { |
| 379 | 379 | usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0); |
| 380 | 380 | usbhid->urbctrl->transfer_buffer_length = len; |
| @@ -1292,6 +1292,7 @@ int hid_pidff_init(struct hid_device *hid) · 1291 unmodified lines | ||
| 1292 | 1292 | |
| 1293 | 1293 | if (pidff->pool[PID_DEVICE_MANAGED_POOL].value && |
| 1294 | 1294 | pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) { |
| 1295 | + error = -EPERM; | |
| 1295 | 1296 | hid_notice(hid, |
| 1296 | 1297 | "device does not support device managed pool\n"); |
| 1297 | 1298 | goto fail; |
| @@ -771,6 +771,16 @@ static int corsairpsu_raw_event(struct hid_device *hdev, struct hid_report *repo · 770 unmodified lines | ||
| 771 | 771 | return 0; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | +#ifdef CONFIG_PM | |
| 775 | +static int corsairpsu_resume(struct hid_device *hdev) | |
| 776 | +{ | |
| 777 | + struct corsairpsu_data *priv = hid_get_drvdata(hdev); | |
| 778 | + | |
| 779 | + /* some PSUs turn off the microcontroller during standby, so a reinit is required */ | |
| 780 | + return corsairpsu_init(priv); | |
| 781 | +} | |
| 782 | +#endif | |
| 783 | + | |
| 774 | 784 | static const struct hid_device_id corsairpsu_idtable[] = { |
| 775 | 785 | { HID_USB_DEVICE(0x1b1c, 0x1c03) }, /* Corsair HX550i */ |
| 776 | 786 | { HID_USB_DEVICE(0x1b1c, 0x1c04) }, /* Corsair HX650i */ |
| @@ -793,6 +803,10 @@ static struct hid_driver corsairpsu_driver = { · 16 unmodified lines | ||
| 793 | 803 | .probe = corsairpsu_probe, |
| 794 | 804 | .remove = corsairpsu_remove, |
| 795 | 805 | .raw_event = corsairpsu_raw_event, |
| 806 | +#ifdef CONFIG_PM | |
| 807 | + .resume = corsairpsu_resume, | |
| 808 | + .reset_resume = corsairpsu_resume, | |
| 809 | +#endif | |
| 796 | 810 | }; |
| 797 | 811 | module_hid_driver(corsairpsu_driver); |
| 798 | 812 | |
| @@ -838,10 +838,10 @@ static struct attribute *i8k_attrs[] = { · 837 unmodified lines | ||
| 838 | 838 | static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, |
| 839 | 839 | int index) |
| 840 | 840 | { |
| 841 | − if (disallow_fan_support && index >= 8) | |
| 841 | + if (disallow_fan_support && index >= 20) | |
| 842 | 842 | return 0; |
| 843 | 843 | if (disallow_fan_type_call && |
| 844 | − (index == 9 || index == 12 || index == 15)) | |
| 844 | + (index == 21 || index == 25 || index == 28)) | |
| 845 | 845 | return 0; |
| 846 | 846 | if (index >= 0 && index <= 1 && |
| 847 | 847 | !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) |
| @@ -37,6 +37,8 @@ struct fsp3y_data { · 36 unmodified lines | ||
| 37 | 37 | struct pmbus_driver_info info; |
| 38 | 38 | int chip; |
| 39 | 39 | int page; |
| 40 | + | |
| 41 | + bool vout_linear_11; | |
| 40 | 42 | }; |
| 41 | 43 | |
| 42 | 44 | #define to_fsp3y_data(x) container_of(x, struct fsp3y_data, info) |
| @@ -108,11 +110,9 @@ static int fsp3y_read_byte_data(struct i2c_client *client, int page, int reg) · 65 unmodified lines | ||
| 108 | 110 | int rv; |
| 109 | 111 | |
| 110 | 112 | /* |
| 111 | − * YH5151-E outputs vout in linear11. The conversion is done when | |
| 112 | − * reading. Here, we have to inject pmbus_core with the correct | |
| 113 | − * exponent (it is -6). | |
| 113 | + * Inject an exponent for non-compliant YH5151-E. | |
| 114 | 114 | */ |
| 115 | − if (data->chip == yh5151e && reg == PMBUS_VOUT_MODE) | |
| 115 | + if (data->vout_linear_11 && reg == PMBUS_VOUT_MODE) | |
| 116 | 116 | return 0x1A; |
| 117 | 117 | |
| 118 | 118 | rv = set_page(client, page); |
| @@ -161,10 +161,9 @@ static int fsp3y_read_word_data(struct i2c_client *client, int page, int phase, · 42 unmodified lines | ||
| 161 | 161 | return rv; |
| 162 | 162 | |
| 163 | 163 | /* |
| 164 | − * YH-5151E is non-compliant and outputs output voltages in linear11 | |
| 165 | − * instead of linear16. | |
| 164 | + * Handle YH-5151E non-compliant linear11 vout voltage. | |
| 166 | 165 | */ |
| 167 | − if (data->chip == yh5151e && reg == PMBUS_READ_VOUT) | |
| 166 | + if (data->vout_linear_11 && reg == PMBUS_READ_VOUT) | |
| 168 | 167 | rv = sign_extend32(rv, 10) & 0xffff; |
| 169 | 168 | |
| 170 | 169 | return rv; |
| @@ -256,6 +255,25 @@ static int fsp3y_probe(struct i2c_client *client) · 85 unmodified lines | ||
| 256 | 255 | |
| 257 | 256 | data->info = fsp3y_info[data->chip]; |
| 258 | 257 | |
| 258 | + /* | |
| 259 | + * YH-5151E sometimes reports vout in linear11 and sometimes in | |
| 260 | + * linear16. This depends on the exact individual piece of hardware. One | |
| 261 | + * YH-5151E can use linear16 and another might use linear11 instead. | |
| 262 | + * | |
| 263 | + * The format can be recognized by reading VOUT_MODE - if it doesn't | |
| 264 | + * report a valid exponent, then vout uses linear11. Otherwise, the | |
| 265 | + * device is compliant and uses linear16. | |
| 266 | + */ | |
| 267 | + data->vout_linear_11 = false; | |
| 268 | + if (data->chip == yh5151e) { | |
| 269 | + rv = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE); | |
| 270 | + if (rv < 0) | |
| 271 | + return rv; | |
| 272 | + | |
| 273 | + if (rv == 0xFF) | |
| 274 | + data->vout_linear_11 = true; | |
| 275 | + } | |
| 276 | + | |
| 259 | 277 | return pmbus_do_probe(client, &data->info); |
| 260 | 278 | } |
| 261 | 279 | |
| @@ -244,8 +244,8 @@ static int isl68137_probe(struct i2c_client *client) · 243 unmodified lines | ||
| 244 | 244 | info->read_word_data = raa_dmpvr2_read_word_data; |
| 245 | 245 | break; |
| 246 | 246 | case raa_dmpvr2_2rail_nontc: |
| 247 | − info->func[0] &= ~PMBUS_HAVE_TEMP; | |
| 248 | − info->func[1] &= ~PMBUS_HAVE_TEMP; | |
| 247 | + info->func[0] &= ~PMBUS_HAVE_TEMP3; | |
| 248 | + info->func[1] &= ~PMBUS_HAVE_TEMP3; | |
| 249 | 249 | fallthrough; |
| 250 | 250 | case raa_dmpvr2_2rail: |
| 251 | 251 | info->pages = 2; |
| @@ -299,7 +299,7 @@ static int q54sj108a2_probe(struct i2c_client *client) · 298 unmodified lines | ||
| 299 | 299 | dev_err(&client->dev, "Failed to read Manufacturer ID\n"); |
| 300 | 300 | return ret; |
| 301 | 301 | } |
| 302 | − if (ret != 5 || strncmp(buf, "DELTA", 5)) { | |
| 302 | + if (ret != 6 || strncmp(buf, "DELTA", 5)) { | |
| 303 | 303 | buf[ret] = '\0'; |
| 304 | 304 | dev_err(dev, "Unsupported Manufacturer ID '%s'\n", buf); |
| 305 | 305 | return -ENODEV; |
| @@ -99,6 +99,15 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf) · 98 unmodified lines | ||
| 99 | 99 | |
| 100 | 100 | scpi_scale_reading(&value, sensor); |
| 101 | 101 | |
| 102 | + /* | |
| 103 | + * Temperature sensor values are treated as signed values based on | |
| 104 | + * observation even though that is not explicitly specified, and | |
| 105 | + * because an unsigned u64 temperature does not really make practical | |
| 106 | + * sense especially when the temperature is below zero degrees Celsius. | |
| 107 | + */ | |
| 108 | + if (sensor->info.class == TEMPERATURE) | |
| 109 | + return sprintf(buf, "%lld\n", (s64)value); | |
| 110 | + | |
| 102 | 111 | return sprintf(buf, "%llu\n", value); |
| 103 | 112 | } |
| 104 | 113 | |
| @@ -99,11 +99,14 @@ · 98 unmodified lines | ||
| 99 | 99 | #define POWER_ENABLE 0x19 |
| 100 | 100 | #define TPS23861_NUM_PORTS 4 |
| 101 | 101 | |
| 102 | +#define TPS23861_GENERAL_MASK_1 0x17 | |
| 103 | +#define TPS23861_CURRENT_SHUNT_MASK BIT(0) | |
| 104 | + | |
| 102 | 105 | #define TEMPERATURE_LSB 652 /* 0.652 degrees Celsius */ |
| 103 | 106 | #define VOLTAGE_LSB 3662 /* 3.662 mV */ |
| 104 | 107 | #define SHUNT_RESISTOR_DEFAULT 255000 /* 255 mOhm */ |
| 105 | −#define CURRENT_LSB_255 62260 /* 62.260 uA */ | |
| 106 | −#define CURRENT_LSB_250 61039 /* 61.039 uA */ | |
| 108 | +#define CURRENT_LSB_250 62260 /* 62.260 uA */ | |
| 109 | +#define CURRENT_LSB_255 61039 /* 61.039 uA */ | |
| 107 | 110 | #define RESISTANCE_LSB 110966 /* 11.0966 Ohm*/ |
| 108 | 111 | #define RESISTANCE_LSB_LOW 157216 /* 15.7216 Ohm*/ |
| 109 | 112 | |
| @@ -117,6 +120,7 @@ struct tps23861_data { · 7 unmodified lines | ||
| 117 | 120 | static struct regmap_config tps23861_regmap_config = { |
| 118 | 121 | .reg_bits = 8, |
| 119 | 122 | .val_bits = 8, |
| 123 | + .max_register = 0x6f, | |
| 120 | 124 | }; |
| 121 | 125 | |
| 122 | 126 | static int tps23861_read_temp(struct tps23861_data *data, long *val) |
| @@ -560,6 +564,15 @@ static int tps23861_probe(struct i2c_client *client) · 437 unmodified lines | ||
| 560 | 564 | else |
| 561 | 565 | data->shunt_resistor = SHUNT_RESISTOR_DEFAULT; |
| 562 | 566 | |
| 567 | + if (data->shunt_resistor == SHUNT_RESISTOR_DEFAULT) | |
| 568 | + regmap_clear_bits(data->regmap, | |
| 569 | + TPS23861_GENERAL_MASK_1, | |
| 570 | + TPS23861_CURRENT_SHUNT_MASK); | |
| 571 | + else | |
| 572 | + regmap_set_bits(data->regmap, | |
| 573 | + TPS23861_GENERAL_MASK_1, | |
| 574 | + TPS23861_CURRENT_SHUNT_MASK); | |
| 575 | + | |
| 563 | 576 | hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, |
| 564 | 577 | data, &tps23861_chip_info, |
| 565 | 578 | NULL); |
| @@ -55,7 +55,7 @@ · 54 unmodified lines | ||
| 55 | 55 | #define ALTR_I2C_XFER_TIMEOUT (msecs_to_jiffies(250)) |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | − * altr_i2c_dev - I2C device context | |
| 58 | + * struct altr_i2c_dev - I2C device context | |
| 59 | 59 | * @base: pointer to register struct |
| 60 | 60 | * @msg: pointer to current message |
| 61 | 61 | * @msg_len: number of bytes transferred in msg |
| @@ -172,7 +172,7 @@ static void altr_i2c_init(struct altr_i2c_dev *idev) · 110 unmodified lines | ||
| 172 | 172 | altr_i2c_int_enable(idev, ALTR_I2C_ALL_IRQ, false); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | −/** | |
| 175 | +/* | |
| 176 | 176 | * altr_i2c_transfer - On the last byte to be transmitted, send |
| 177 | 177 | * a Stop bit on the last byte. |
| 178 | 178 | */ |
| @@ -185,7 +185,7 @@ static void altr_i2c_transfer(struct altr_i2c_dev *idev, u32 data) · 6 unmodified lines | ||
| 185 | 185 | writel(data, idev->base + ALTR_I2C_TFR_CMD); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | −/** | |
| 188 | +/* | |
| 189 | 189 | * altr_i2c_empty_rx_fifo - Fetch data from RX FIFO until end of |
| 190 | 190 | * transfer. Send a Stop bit on the last byte. |
| 191 | 191 | */ |
| @@ -201,9 +201,8 @@ static void altr_i2c_empty_rx_fifo(struct altr_i2c_dev *idev) · 9 unmodified lines | ||
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | −/** | |
| 204 | +/* | |
| 205 | 205 | * altr_i2c_fill_tx_fifo - Fill TX FIFO from current message buffer. |
| 206 | − * @return: Number of bytes left to transfer. | |
| 207 | 206 | */ |
| 208 | 207 | static int altr_i2c_fill_tx_fifo(struct altr_i2c_dev *idev) |
| 209 | 208 | { |
| @@ -650,6 +650,14 @@ static int geni_i2c_remove(struct platform_device *pdev) · 649 unmodified lines | ||
| 650 | 650 | return 0; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | +static void geni_i2c_shutdown(struct platform_device *pdev) | |
| 654 | +{ | |
| 655 | + struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev); | |
| 656 | + | |
| 657 | + /* Make client i2c transfers start failing */ | |
| 658 | + i2c_mark_adapter_suspended(&gi2c->adap); | |
| 659 | +} | |
| 660 | + | |
| 653 | 661 | static int __maybe_unused geni_i2c_runtime_suspend(struct device *dev) |
| 654 | 662 | { |
| 655 | 663 | int ret; |
| @@ -690,6 +698,8 @@ static int __maybe_unused geni_i2c_suspend_noirq(struct device *dev) · 34 unmodified lines | ||
| 690 | 698 | { |
| 691 | 699 | struct geni_i2c_dev *gi2c = dev_get_drvdata(dev); |
| 692 | 700 | |
| 701 | + i2c_mark_adapter_suspended(&gi2c->adap); | |
| 702 | + | |
| 693 | 703 | if (!gi2c->suspended) { |
| 694 | 704 | geni_i2c_runtime_suspend(dev); |
| 695 | 705 | pm_runtime_disable(dev); |
| @@ -699,8 +709,16 @@ static int __maybe_unused geni_i2c_suspend_noirq(struct device *dev) · 3 unmodified lines | ||
| 699 | 709 | return 0; |
| 700 | 710 | } |
| 701 | 711 | |
| 712 | +static int __maybe_unused geni_i2c_resume_noirq(struct device *dev) | |
| 713 | +{ | |
| 714 | + struct geni_i2c_dev *gi2c = dev_get_drvdata(dev); | |
| 715 | + | |
| 716 | + i2c_mark_adapter_resumed(&gi2c->adap); | |
| 717 | + return 0; | |
| 718 | +} | |
| 719 | + | |
| 702 | 720 | static const struct dev_pm_ops geni_i2c_pm_ops = { |
| 703 | − SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(geni_i2c_suspend_noirq, NULL) | |
| 721 | + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(geni_i2c_suspend_noirq, geni_i2c_resume_noirq) | |
| 704 | 722 | SET_RUNTIME_PM_OPS(geni_i2c_runtime_suspend, geni_i2c_runtime_resume, |
| 705 | 723 | NULL) |
| 706 | 724 | }; |
| @@ -714,6 +732,7 @@ MODULE_DEVICE_TABLE(of, geni_i2c_dt_match); · 7 unmodified lines | ||
| 714 | 732 | static struct platform_driver geni_i2c_driver = { |
| 715 | 733 | .probe = geni_i2c_probe, |
| 716 | 734 | .remove = geni_i2c_remove, |
| 735 | + .shutdown = geni_i2c_shutdown, | |
| 717 | 736 | .driver = { |
| 718 | 737 | .name = "geni_i2c", |
| 719 | 738 | .pm = &geni_i2c_pm_ops, |
| @@ -65,7 +65,7 @@ static void tegra_bpmp_xlate_flags(u16 flags, u16 *out) · 64 unmodified lines | ||
| 65 | 65 | *out |= SERIALI2C_RECV_LEN; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | −/** | |
| 68 | +/* | |
| 69 | 69 | * The serialized I2C format is simply the following: |
| 70 | 70 | * [addr little-endian][flags little-endian][len little-endian][data if write] |
| 71 | 71 | * [addr little-endian][flags little-endian][len little-endian][data if write] |
| @@ -109,7 +109,7 @@ static void tegra_bpmp_serialize_i2c_msg(struct tegra_bpmp_i2c *i2c, · 37 unmodified lines | ||
| 109 | 109 | request->xfer.data_size = pos; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | −/** | |
| 112 | +/* | |
| 113 | 113 | * The data in the BPMP -> CPU direction is composed of sequential blocks for |
| 114 | 114 | * those messages that have I2C_M_RD. So, for example, if you have: |
| 115 | 115 | * |
| @@ -3248,6 +3248,11 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs) · 3247 unmodified lines | ||
| 3248 | 3248 | goto err_free_attr; |
| 3249 | 3249 | } |
| 3250 | 3250 | |
| 3251 | + if (!rdma_is_port_valid(uobj->context->device, cmd.flow_attr.port)) { | |
| 3252 | + err = -EINVAL; | |
| 3253 | + goto err_uobj; | |
| 3254 | + } | |
| 3255 | + | |
| 3251 | 3256 | qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs); |
| 3252 | 3257 | if (!qp) { |
| 3253 | 3258 | err = -EINVAL; |
| @@ -581,12 +581,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev, · 580 unmodified lines | ||
| 581 | 581 | props->cq_caps.max_cq_moderation_count = MLX4_MAX_CQ_COUNT; |
| 582 | 582 | props->cq_caps.max_cq_moderation_period = MLX4_MAX_CQ_PERIOD; |
| 583 | 583 | |
| 584 | − if (!mlx4_is_slave(dev->dev)) | |
| 585 | − err = mlx4_get_internal_clock_params(dev->dev, &clock_params); | |
| 586 | − | |
| 587 | 584 | if (uhw->outlen >= resp.response_length + sizeof(resp.hca_core_clock_offset)) { |
| 588 | 585 | resp.response_length += sizeof(resp.hca_core_clock_offset); |
| 589 | − if (!err && !mlx4_is_slave(dev->dev)) { | |
| 586 | + if (!mlx4_get_internal_clock_params(dev->dev, &clock_params)) { | |
| 590 | 587 | resp.comp_mask |= MLX4_IB_QUERY_DEV_RESP_MASK_CORE_CLOCK_OFFSET; |
| 591 | 588 | resp.hca_core_clock_offset = clock_params.offset % PAGE_SIZE; |
| 592 | 589 | } |
| @@ -1702,9 +1699,6 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp, · 1109 unmodified lines | ||
| 1702 | 1699 | struct mlx4_dev *dev = (to_mdev(qp->device))->dev; |
| 1703 | 1700 | int is_bonded = mlx4_is_bonded(dev); |
| 1704 | 1701 | |
| 1705 | − if (!rdma_is_port_valid(qp->device, flow_attr->port)) | |
| 1706 | − return ERR_PTR(-EINVAL); | |
| 1707 | − | |
| 1708 | 1702 | if (flow_attr->flags & ~IB_FLOW_ATTR_FLAGS_DONT_TRAP) |
| 1709 | 1703 | return ERR_PTR(-EOPNOTSUPP); |
| 1710 | 1704 | |
| @@ -849,15 +849,14 @@ static void destroy_cq_user(struct mlx5_ib_cq *cq, struct ib_udata *udata) · 848 unmodified lines | ||
| 849 | 849 | ib_umem_release(cq->buf.umem); |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | −static void init_cq_frag_buf(struct mlx5_ib_cq *cq, | |
| 853 | − struct mlx5_ib_cq_buf *buf) | |
| 852 | +static void init_cq_frag_buf(struct mlx5_ib_cq_buf *buf) | |
| 854 | 853 | { |
| 855 | 854 | int i; |
| 856 | 855 | void *cqe; |
| 857 | 856 | struct mlx5_cqe64 *cqe64; |
| 858 | 857 | |
| 859 | 858 | for (i = 0; i < buf->nent; i++) { |
| 860 | − cqe = get_cqe(cq, i); | |
| 859 | + cqe = mlx5_frag_buf_get_wqe(&buf->fbc, i); | |
| 861 | 860 | cqe64 = buf->cqe_size == 64 ? cqe : cqe + 64; |
| 862 | 861 | cqe64->op_own = MLX5_CQE_INVALID << 4; |
| 863 | 862 | } |
| @@ -883,7 +882,7 @@ static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq, · 19 unmodified lines | ||
| 883 | 882 | if (err) |
| 884 | 883 | goto err_db; |
| 885 | 884 | |
| 886 | − init_cq_frag_buf(cq, &cq->buf); | |
| 885 | + init_cq_frag_buf(&cq->buf); | |
| 887 | 886 | |
| 888 | 887 | *inlen = MLX5_ST_SZ_BYTES(create_cq_in) + |
| 889 | 888 | MLX5_FLD_SZ_BYTES(create_cq_in, pas[0]) * |
| @@ -1184,7 +1183,7 @@ static int resize_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq, · 294 unmodified lines | ||
| 1184 | 1183 | if (err) |
| 1185 | 1184 | goto ex; |
| 1186 | 1185 | |
| 1187 | − init_cq_frag_buf(cq, cq->resize_buf); | |
| 1186 | + init_cq_frag_buf(cq->resize_buf); | |
| 1188 | 1187 | |
| 1189 | 1188 | return 0; |
| 1190 | 1189 | |
| @@ -41,6 +41,7 @@ struct mlx5_ib_user_db_page { · 40 unmodified lines | ||
| 41 | 41 | struct ib_umem *umem; |
| 42 | 42 | unsigned long user_virt; |
| 43 | 43 | int refcnt; |
| 44 | + struct mm_struct *mm; | |
| 44 | 45 | }; |
| 45 | 46 | |
| 46 | 47 | int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, |
| @@ -53,7 +54,8 @@ int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, · 6 unmodified lines | ||
| 53 | 54 | mutex_lock(&context->db_page_mutex); |
| 54 | 55 | |
| 55 | 56 | list_for_each_entry(page, &context->db_page_list, list) |
| 56 | − if (page->user_virt == (virt & PAGE_MASK)) | |
| 57 | + if ((current->mm == page->mm) && | |
| 58 | + (page->user_virt == (virt & PAGE_MASK))) | |
| 57 | 59 | goto found; |
| 58 | 60 | |
| 59 | 61 | page = kmalloc(sizeof(*page), GFP_KERNEL); |
| @@ -71,6 +73,8 @@ int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, · 11 unmodified lines | ||
| 71 | 73 | kfree(page); |
| 72 | 74 | goto out; |
| 73 | 75 | } |
| 76 | + mmgrab(current->mm); | |
| 77 | + page->mm = current->mm; | |
| 74 | 78 | |
| 75 | 79 | list_add(&page->list, &context->db_page_list); |
| 76 | 80 | |
| @@ -91,6 +95,7 @@ void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db) · 14 unmodified lines | ||
| 91 | 95 | |
| 92 | 96 | if (!--db->u.user_page->refcnt) { |
| 93 | 97 | list_del(&db->u.user_page->list); |
| 98 | + mmdrop(db->u.user_page->mm); | |
| 94 | 99 | ib_umem_release(db->u.user_page->umem); |
| 95 | 100 | kfree(db->u.user_page); |
| 96 | 101 | } |
| @@ -1194,9 +1194,8 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp, · 1193 unmodified lines | ||
| 1194 | 1194 | goto free_ucmd; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | − if (flow_attr->port > dev->num_ports || | |
| 1198 | − (flow_attr->flags & | |
| 1199 | − ~(IB_FLOW_ATTR_FLAGS_DONT_TRAP | IB_FLOW_ATTR_FLAGS_EGRESS))) { | |
| 1197 | + if (flow_attr->flags & | |
| 1198 | + ~(IB_FLOW_ATTR_FLAGS_DONT_TRAP | IB_FLOW_ATTR_FLAGS_EGRESS)) { | |
| 1200 | 1199 | err = -EINVAL; |
| 1201 | 1200 | goto free_ucmd; |
| 1202 | 1201 | } |
| @@ -2134,6 +2133,12 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)( · 931 unmodified lines | ||
| 2134 | 2133 | if (err) |
| 2135 | 2134 | goto end; |
| 2136 | 2135 | |
| 2136 | + if (obj->ns_type == MLX5_FLOW_NAMESPACE_FDB && | |
| 2137 | + mlx5_eswitch_mode(dev->mdev) != MLX5_ESWITCH_OFFLOADS) { | |
| 2138 | + err = -EINVAL; | |
| 2139 | + goto end; | |
| 2140 | + } | |
| 2141 | + | |
| 2137 | 2142 | uobj->object = obj; |
| 2138 | 2143 | obj->mdev = dev->mdev; |
| 2139 | 2144 | atomic_set(&obj->usecnt, 0); |
| @@ -1940,8 +1940,8 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) · 1939 unmodified lines | ||
| 1940 | 1940 | mlx5r_deref_wait_odp_mkey(&mr->mmkey); |
| 1941 | 1941 | |
| 1942 | 1942 | if (ibmr->type == IB_MR_TYPE_INTEGRITY) { |
| 1943 | − xa_cmpxchg(&dev->sig_mrs, mlx5_base_mkey(mr->mmkey.key), ibmr, | |
| 1944 | − NULL, GFP_KERNEL); | |
| 1943 | + xa_cmpxchg(&dev->sig_mrs, mlx5_base_mkey(mr->mmkey.key), | |
| 1944 | + mr->sig, NULL, GFP_KERNEL); | |
| 1945 | 1945 | |
| 1946 | 1946 | if (mr->mtt_mr) { |
| 1947 | 1947 | rc = mlx5_ib_dereg_mr(&mr->mtt_mr->ibmr, NULL); |
| @@ -163,6 +163,7 @@ static size_t ipoib_get_size(const struct net_device *dev) · 162 unmodified lines | ||
| 163 | 163 | |
| 164 | 164 | static struct rtnl_link_ops ipoib_link_ops __read_mostly = { |
| 165 | 165 | .kind = "ipoib", |
| 166 | + .netns_refund = true, | |
| 166 | 167 | .maxtype = IFLA_IPOIB_MAX, |
| 167 | 168 | .policy = ipoib_policy, |
| 168 | 169 | .priv_size = sizeof(struct ipoib_dev_priv), |
| @@ -364,7 +364,6 @@ struct cached_dev { · 363 unmodified lines | ||
| 364 | 364 | |
| 365 | 365 | /* The rest of this all shows up in sysfs */ |
| 366 | 366 | unsigned int sequential_cutoff; |
| 367 | − unsigned int readahead; | |
| 368 | 367 | |
| 369 | 368 | unsigned int io_disable:1; |
| 370 | 369 | unsigned int verify:1; |
| @@ -880,9 +880,9 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s, · 879 unmodified lines | ||
| 880 | 880 | struct bio *bio, unsigned int sectors) |
| 881 | 881 | { |
| 882 | 882 | int ret = MAP_CONTINUE; |
| 883 | − unsigned int reada = 0; | |
| 884 | 883 | struct cached_dev *dc = container_of(s->d, struct cached_dev, disk); |
| 885 | 884 | struct bio *miss, *cache_bio; |
| 885 | + unsigned int size_limit; | |
| 886 | 886 | |
| 887 | 887 | s->cache_missed = 1; |
| 888 | 888 | |
| @@ -892,14 +892,10 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s, · 3 unmodified lines | ||
| 892 | 892 | goto out_submit; |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | − if (!(bio->bi_opf & REQ_RAHEAD) && | |
| 896 | − !(bio->bi_opf & (REQ_META|REQ_PRIO)) && | |
| 897 | − s->iop.c->gc_stats.in_use < CUTOFF_CACHE_READA) | |
| 898 | − reada = min_t(sector_t, dc->readahead >> 9, | |
| 899 | − get_capacity(bio->bi_bdev->bd_disk) - | |
| 900 | − bio_end_sector(bio)); | |
| 901 | − | |
| 902 | − s->insert_bio_sectors = min(sectors, bio_sectors(bio) + reada); | |
| 895 | + /* Limitation for valid replace key size and cache_bio bvecs number */ | |
| 896 | + size_limit = min_t(unsigned int, BIO_MAX_VECS * PAGE_SECTORS, | |
| 897 | + (1 << KEY_SIZE_BITS) - 1); | |
| 898 | + s->insert_bio_sectors = min3(size_limit, sectors, bio_sectors(bio)); | |
| 903 | 899 | |
| 904 | 900 | s->iop.replace_key = KEY(s->iop.inode, |
| 905 | 901 | bio->bi_iter.bi_sector + s->insert_bio_sectors, |
| @@ -911,7 +907,8 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s, · 5 unmodified lines | ||
| 911 | 907 | |
| 912 | 908 | s->iop.replace = true; |
| 913 | 909 | |
| 914 | − miss = bio_next_split(bio, sectors, GFP_NOIO, &s->d->bio_split); | |
| 910 | + miss = bio_next_split(bio, s->insert_bio_sectors, GFP_NOIO, | |
| 911 | + &s->d->bio_split); | |
| 915 | 912 | |
| 916 | 913 | /* btree_search_recurse()'s btree iterator is no good anymore */ |
| 917 | 914 | ret = miss == bio ? MAP_DONE : -EINTR; |
| @@ -933,9 +930,6 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s, · 15 unmodified lines | ||
| 933 | 930 | if (bch_bio_alloc_pages(cache_bio, __GFP_NOWARN|GFP_NOIO)) |
| 934 | 931 | goto out_put; |
| 935 | 932 | |
| 936 | − if (reada) | |
| 937 | − bch_mark_cache_readahead(s->iop.c, s->d); | |
| 938 | − | |
| 939 | 933 | s->cache_miss = miss; |
| 940 | 934 | s->iop.bio = cache_bio; |
| 941 | 935 | bio_get(cache_bio); |
| @@ -46,7 +46,6 @@ read_attribute(cache_misses); · 45 unmodified lines | ||
| 46 | 46 | read_attribute(cache_bypass_hits); |
| 47 | 47 | read_attribute(cache_bypass_misses); |
| 48 | 48 | read_attribute(cache_hit_ratio); |
| 49 | −read_attribute(cache_readaheads); | |
| 50 | 49 | read_attribute(cache_miss_collisions); |
| 51 | 50 | read_attribute(bypassed); |
| 52 | 51 | |
| @@ -64,7 +63,6 @@ SHOW(bch_stats) · 11 unmodified lines | ||
| 64 | 63 | DIV_SAFE(var(cache_hits) * 100, |
| 65 | 64 | var(cache_hits) + var(cache_misses))); |
| 66 | 65 | |
| 67 | − var_print(cache_readaheads); | |
| 68 | 66 | var_print(cache_miss_collisions); |
| 69 | 67 | sysfs_hprint(bypassed, var(sectors_bypassed) << 9); |
| 70 | 68 | #undef var |
| @@ -86,7 +84,6 @@ static struct attribute *bch_stats_files[] = { · 15 unmodified lines | ||
| 86 | 84 | &sysfs_cache_bypass_hits, |
| 87 | 85 | &sysfs_cache_bypass_misses, |
| 88 | 86 | &sysfs_cache_hit_ratio, |
| 89 | − &sysfs_cache_readaheads, | |
| 90 | 87 | &sysfs_cache_miss_collisions, |
| 91 | 88 | &sysfs_bypassed, |
| 92 | 89 | NULL |
| @@ -113,7 +110,6 @@ void bch_cache_accounting_clear(struct cache_accounting *acc) · 20 unmodified lines | ||
| 113 | 110 | acc->total.cache_misses = 0; |
| 114 | 111 | acc->total.cache_bypass_hits = 0; |
| 115 | 112 | acc->total.cache_bypass_misses = 0; |
| 116 | − acc->total.cache_readaheads = 0; | |
| 117 | 113 | acc->total.cache_miss_collisions = 0; |
| 118 | 114 | acc->total.sectors_bypassed = 0; |
| 119 | 115 | } |
| @@ -145,7 +141,6 @@ static void scale_stats(struct cache_stats *stats, unsigned long rescale_at) · 25 unmodified lines | ||
| 145 | 141 | scale_stat(&stats->cache_misses); |
| 146 | 142 | scale_stat(&stats->cache_bypass_hits); |
| 147 | 143 | scale_stat(&stats->cache_bypass_misses); |
| 148 | − scale_stat(&stats->cache_readaheads); | |
| 149 | 144 | scale_stat(&stats->cache_miss_collisions); |
| 150 | 145 | scale_stat(&stats->sectors_bypassed); |
| 151 | 146 | } |
| @@ -168,7 +163,6 @@ static void scale_accounting(struct timer_list *t) · 16 unmodified lines | ||
| 168 | 163 | move_stat(cache_misses); |
| 169 | 164 | move_stat(cache_bypass_hits); |
| 170 | 165 | move_stat(cache_bypass_misses); |
| 171 | − move_stat(cache_readaheads); | |
| 172 | 166 | move_stat(cache_miss_collisions); |
| 173 | 167 | move_stat(sectors_bypassed); |
| 174 | 168 | |
| @@ -209,14 +203,6 @@ void bch_mark_cache_accounting(struct cache_set *c, struct bcache_device *d, · 34 unmodified lines | ||
| 209 | 203 | mark_cache_stats(&c->accounting.collector, hit, bypass); |
| 210 | 204 | } |
| 211 | 205 | |
| 212 | −void bch_mark_cache_readahead(struct cache_set *c, struct bcache_device *d) | |
| 213 | −{ | |
| 214 | − struct cached_dev *dc = container_of(d, struct cached_dev, disk); | |
| 215 | − | |
| 216 | − atomic_inc(&dc->accounting.collector.cache_readaheads); | |
| 217 | − atomic_inc(&c->accounting.collector.cache_readaheads); | |
| 218 | −} | |
| 219 | − | |
| 220 | 206 | void bch_mark_cache_miss_collision(struct cache_set *c, struct bcache_device *d) |
| 221 | 207 | { |
| 222 | 208 | struct cached_dev *dc = container_of(d, struct cached_dev, disk); |
| @@ -7,7 +7,6 @@ struct cache_stat_collector { · 6 unmodified lines | ||
| 7 | 7 | atomic_t cache_misses; |
| 8 | 8 | atomic_t cache_bypass_hits; |
| 9 | 9 | atomic_t cache_bypass_misses; |
| 10 | − atomic_t cache_readaheads; | |
| 11 | 10 | atomic_t cache_miss_collisions; |
| 12 | 11 | atomic_t sectors_bypassed; |
| 13 | 12 | }; |
| @@ -137,7 +137,6 @@ rw_attribute(io_disable); · 136 unmodified lines | ||
| 137 | 137 | rw_attribute(discard); |
| 138 | 138 | rw_attribute(running); |
| 139 | 139 | rw_attribute(label); |
| 140 | −rw_attribute(readahead); | |
| 141 | 140 | rw_attribute(errors); |
| 142 | 141 | rw_attribute(io_error_limit); |
| 143 | 142 | rw_attribute(io_error_halflife); |
| @@ -260,7 +259,6 @@ SHOW(__bch_cached_dev) · 116 unmodified lines | ||
| 260 | 259 | var_printf(partial_stripes_expensive, "%u"); |
| 261 | 260 | |
| 262 | 261 | var_hprint(sequential_cutoff); |
| 263 | − var_hprint(readahead); | |
| 264 | 262 | |
| 265 | 263 | sysfs_print(running, atomic_read(&dc->running)); |
| 266 | 264 | sysfs_print(state, states[BDEV_STATE(&dc->sb)]); |
| @@ -365,7 +363,6 @@ STORE(__cached_dev) · 98 unmodified lines | ||
| 365 | 363 | sysfs_strtoul_clamp(sequential_cutoff, |
| 366 | 364 | dc->sequential_cutoff, |
| 367 | 365 | 0, UINT_MAX); |
| 368 | − d_strtoi_h(readahead); | |
| 369 | 366 | |
| 370 | 367 | if (attr == &sysfs_clear_stats) |
| 371 | 368 | bch_cache_accounting_clear(&dc->accounting); |
| @@ -538,7 +535,6 @@ static struct attribute *bch_cached_dev_files[] = { · 166 unmodified lines | ||
| 538 | 535 | &sysfs_running, |
| 539 | 536 | &sysfs_state, |
| 540 | 537 | &sysfs_label, |
| 541 | − &sysfs_readahead, | |
| 542 | 538 | #ifdef CONFIG_BCACHE_DEBUG |
| 543 | 539 | &sysfs_verify, |
| 544 | 540 | &sysfs_bypass_torture_test, |
| @@ -468,6 +468,7 @@ static void rtl8411_init_common_params(struct rtsx_pcr *pcr) · 467 unmodified lines | ||
| 468 | 468 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; |
| 469 | 469 | pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D; |
| 470 | 470 | pcr->aspm_en = ASPM_L1_EN; |
| 471 | + pcr->aspm_mode = ASPM_MODE_CFG; | |
| 471 | 472 | pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14); |
| 472 | 473 | pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); |
| 473 | 474 | pcr->ic_version = rtl8411_get_ic_version(pcr); |
| @@ -255,6 +255,7 @@ void rts5209_init_params(struct rtsx_pcr *pcr) · 254 unmodified lines | ||
| 255 | 255 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; |
| 256 | 256 | pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D; |
| 257 | 257 | pcr->aspm_en = ASPM_L1_EN; |
| 258 | + pcr->aspm_mode = ASPM_MODE_CFG; | |
| 258 | 259 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 16); |
| 259 | 260 | pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5); |
| 260 | 261 | |
| @@ -358,6 +358,7 @@ void rts5227_init_params(struct rtsx_pcr *pcr) · 357 unmodified lines | ||
| 358 | 358 | pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B; |
| 359 | 359 | pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B; |
| 360 | 360 | pcr->aspm_en = ASPM_L1_EN; |
| 361 | + pcr->aspm_mode = ASPM_MODE_CFG; | |
| 361 | 362 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15); |
| 362 | 363 | pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 7, 7); |
| 363 | 364 | |
| @@ -483,6 +484,7 @@ void rts522a_init_params(struct rtsx_pcr *pcr) · 119 unmodified lines | ||
| 483 | 484 | |
| 484 | 485 | rts5227_init_params(pcr); |
| 485 | 486 | pcr->ops = &rts522a_pcr_ops; |
| 487 | + pcr->aspm_mode = ASPM_MODE_REG; | |
| 486 | 488 | pcr->tx_initial_phase = SET_CLOCK_PHASE(20, 20, 11); |
| 487 | 489 | pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3; |
| 488 | 490 | |
| @@ -718,6 +718,7 @@ void rts5228_init_params(struct rtsx_pcr *pcr) · 717 unmodified lines | ||
| 718 | 718 | pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B; |
| 719 | 719 | pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B; |
| 720 | 720 | pcr->aspm_en = ASPM_L1_EN; |
| 721 | + pcr->aspm_mode = ASPM_MODE_REG; | |
| 721 | 722 | pcr->tx_initial_phase = SET_CLOCK_PHASE(28, 27, 11); |
| 722 | 723 | pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5); |
| 723 | 724 | |
| @@ -246,6 +246,7 @@ void rts5229_init_params(struct rtsx_pcr *pcr) · 245 unmodified lines | ||
| 246 | 246 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; |
| 247 | 247 | pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D; |
| 248 | 248 | pcr->aspm_en = ASPM_L1_EN; |
| 249 | + pcr->aspm_mode = ASPM_MODE_CFG; | |
| 249 | 250 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15); |
| 250 | 251 | pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 6, 6); |
| 251 | 252 | |
| @@ -566,6 +566,7 @@ void rts5249_init_params(struct rtsx_pcr *pcr) · 565 unmodified lines | ||
| 566 | 566 | pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B; |
| 567 | 567 | pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B; |
| 568 | 568 | pcr->aspm_en = ASPM_L1_EN; |
| 569 | + pcr->aspm_mode = ASPM_MODE_CFG; | |
| 569 | 570 | pcr->tx_initial_phase = SET_CLOCK_PHASE(1, 29, 16); |
| 570 | 571 | pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5); |
| 571 | 572 | |
| @@ -729,6 +730,7 @@ static const struct pcr_ops rts524a_pcr_ops = { · 157 unmodified lines | ||
| 729 | 730 | void rts524a_init_params(struct rtsx_pcr *pcr) |
| 730 | 731 | { |
| 731 | 732 | rts5249_init_params(pcr); |
| 733 | + pcr->aspm_mode = ASPM_MODE_REG; | |
| 732 | 734 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 29, 11); |
| 733 | 735 | pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF; |
| 734 | 736 | pcr->option.ltr_l1off_snooze_sspwrgate = |
| @@ -845,6 +847,7 @@ static const struct pcr_ops rts525a_pcr_ops = { · 110 unmodified lines | ||
| 845 | 847 | void rts525a_init_params(struct rtsx_pcr *pcr) |
| 846 | 848 | { |
| 847 | 849 | rts5249_init_params(pcr); |
| 850 | + pcr->aspm_mode = ASPM_MODE_REG; | |
| 848 | 851 | pcr->tx_initial_phase = SET_CLOCK_PHASE(25, 29, 11); |
| 849 | 852 | pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF; |
| 850 | 853 | pcr->option.ltr_l1off_snooze_sspwrgate = |
| @@ -628,6 +628,7 @@ void rts5260_init_params(struct rtsx_pcr *pcr) · 627 unmodified lines | ||
| 628 | 628 | pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B; |
| 629 | 629 | pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B; |
| 630 | 630 | pcr->aspm_en = ASPM_L1_EN; |
| 631 | + pcr->aspm_mode = ASPM_MODE_REG; | |
| 631 | 632 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 29, 11); |
| 632 | 633 | pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5); |
| 633 | 634 | |
| @@ -783,6 +783,7 @@ void rts5261_init_params(struct rtsx_pcr *pcr) · 782 unmodified lines | ||
| 783 | 783 | pcr->sd30_drive_sel_1v8 = 0x00; |
| 784 | 784 | pcr->sd30_drive_sel_3v3 = 0x00; |
| 785 | 785 | pcr->aspm_en = ASPM_L1_EN; |
| 786 | + pcr->aspm_mode = ASPM_MODE_REG; | |
| 786 | 787 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 11); |
| 787 | 788 | pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5); |
| 788 | 789 | |
| @@ -85,12 +85,18 @@ static void rtsx_comm_set_aspm(struct rtsx_pcr *pcr, bool enable) · 84 unmodified lines | ||
| 85 | 85 | if (pcr->aspm_enabled == enable) |
| 86 | 86 | return; |
| 87 | 87 | |
| 88 | − if (pcr->aspm_en & 0x02) | |
| 89 | − rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 | | |
| 90 | − FORCE_ASPM_CTL1, enable ? 0 : FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1); | |
| 91 | − else | |
| 92 | − rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 | | |
| 93 | − FORCE_ASPM_CTL1, FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1); | |
| 88 | + if (pcr->aspm_mode == ASPM_MODE_CFG) { | |
| 89 | + pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, | |
| 90 | + PCI_EXP_LNKCTL_ASPMC, | |
| 91 | + enable ? pcr->aspm_en : 0); | |
| 92 | + } else if (pcr->aspm_mode == ASPM_MODE_REG) { | |
| 93 | + if (pcr->aspm_en & 0x02) | |
| 94 | + rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 | | |
| 95 | + FORCE_ASPM_CTL1, enable ? 0 : FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1); | |
| 96 | + else | |
| 97 | + rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 | | |
| 98 | + FORCE_ASPM_CTL1, FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1); | |
| 99 | + } | |
| 94 | 100 | |
| 95 | 101 | if (!enable && (pcr->aspm_en & 0x02)) |
| 96 | 102 | mdelay(10); |
| @@ -1394,7 +1400,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) · 1297 unmodified lines | ||
| 1394 | 1400 | return err; |
| 1395 | 1401 | } |
| 1396 | 1402 | |
| 1397 | − rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0x30, 0x30); | |
| 1403 | + if (pcr->aspm_mode == ASPM_MODE_REG) | |
| 1404 | + rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0x30, 0x30); | |
| 1398 | 1405 | |
| 1399 | 1406 | /* No CD interrupt if probing driver with card inserted. |
| 1400 | 1407 | * So we need to initialize pcr->card_exist here. |
| @@ -1410,6 +1417,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) · 9 unmodified lines | ||
| 1410 | 1417 | static int rtsx_pci_init_chip(struct rtsx_pcr *pcr) |
| 1411 | 1418 | { |
| 1412 | 1419 | int err; |
| 1420 | + u16 cfg_val; | |
| 1421 | + u8 val; | |
| 1413 | 1422 | |
| 1414 | 1423 | spin_lock_init(&pcr->lock); |
| 1415 | 1424 | mutex_init(&pcr->pcr_mutex); |
| @@ -1477,6 +1486,21 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr) · 61 unmodified lines | ||
| 1477 | 1486 | if (!pcr->slots) |
| 1478 | 1487 | return -ENOMEM; |
| 1479 | 1488 | |
| 1489 | + if (pcr->aspm_mode == ASPM_MODE_CFG) { | |
| 1490 | + pcie_capability_read_word(pcr->pci, PCI_EXP_LNKCTL, &cfg_val); | |
| 1491 | + if (cfg_val & PCI_EXP_LNKCTL_ASPM_L1) | |
| 1492 | + pcr->aspm_enabled = true; | |
| 1493 | + else | |
| 1494 | + pcr->aspm_enabled = false; | |
| 1495 | + | |
| 1496 | + } else if (pcr->aspm_mode == ASPM_MODE_REG) { | |
| 1497 | + rtsx_pci_read_register(pcr, ASPM_FORCE_CTL, &val); | |
| 1498 | + if (val & FORCE_ASPM_CTL0 && val & FORCE_ASPM_CTL1) | |
| 1499 | + pcr->aspm_enabled = false; | |
| 1500 | + else | |
| 1501 | + pcr->aspm_enabled = true; | |
| 1502 | + } | |
| 1503 | + | |
| 1480 | 1504 | if (pcr->ops->fetch_vendor_settings) |
| 1481 | 1505 | pcr->ops->fetch_vendor_settings(pcr); |
| 1482 | 1506 | |
| @@ -1506,7 +1530,6 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, · 23 unmodified lines | ||
| 1506 | 1530 | struct pcr_handle *handle; |
| 1507 | 1531 | u32 base, len; |
| 1508 | 1532 | int ret, i, bar = 0; |
| 1509 | − u8 val; | |
| 1510 | 1533 | |
| 1511 | 1534 | dev_dbg(&(pcidev->dev), |
| 1512 | 1535 | ": Realtek PCI-E Card Reader found at %s [%04x:%04x] (rev %x)\n", |
| @@ -1572,11 +1595,6 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, · 59 unmodified lines | ||
| 1572 | 1595 | pcr->host_cmds_addr = pcr->rtsx_resv_buf_addr; |
| 1573 | 1596 | pcr->host_sg_tbl_ptr = pcr->rtsx_resv_buf + HOST_CMDS_BUF_LEN; |
| 1574 | 1597 | pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr + HOST_CMDS_BUF_LEN; |
| 1575 | − rtsx_pci_read_register(pcr, ASPM_FORCE_CTL, &val); | |
| 1576 | − if (val & FORCE_ASPM_CTL0 && val & FORCE_ASPM_CTL1) | |
| 1577 | − pcr->aspm_enabled = false; | |
| 1578 | − else | |
| 1579 | − pcr->aspm_enabled = true; | |
| 1580 | 1598 | pcr->card_inserted = 0; |
| 1581 | 1599 | pcr->card_removed = 0; |
| 1582 | 1600 | INIT_DELAYED_WORK(&pcr->carddet_work, rtsx_pci_card_detect); |
| @@ -692,14 +692,19 @@ static int renesas_sdhi_execute_tuning(struct mmc_host *mmc, u32 opcode) · 691 unmodified lines | ||
| 692 | 692 | |
| 693 | 693 | /* Issue CMD19 twice for each tap */ |
| 694 | 694 | for (i = 0; i < 2 * priv->tap_num; i++) { |
| 695 | + int cmd_error; | |
| 696 | + | |
| 695 | 697 | /* Set sampling clock position */ |
| 696 | 698 | sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, i % priv->tap_num); |
| 697 | 699 | |
| 698 | − if (mmc_send_tuning(mmc, opcode, NULL) == 0) | |
| 700 | + if (mmc_send_tuning(mmc, opcode, &cmd_error) == 0) | |
| 699 | 701 | set_bit(i, priv->taps); |
| 700 | 702 | |
| 701 | 703 | if (sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_SMPCMP) == 0) |
| 702 | 704 | set_bit(i, priv->smpcmp); |
| 705 | + | |
| 706 | + if (cmd_error) | |
| 707 | + mmc_abort_tuning(mmc, opcode); | |
| 703 | 708 | } |
| 704 | 709 | |
| 705 | 710 | ret = renesas_sdhi_select_tuning(host); |
| @@ -939,7 +944,7 @@ static const struct soc_device_attribute sdhi_quirks_match[] = { · 233 unmodified lines | ||
| 939 | 944 | { .soc_id = "r8a7795", .revision = "ES3.*", .data = &sdhi_quirks_bad_taps2367 }, |
| 940 | 945 | { .soc_id = "r8a7796", .revision = "ES1.[012]", .data = &sdhi_quirks_4tap_nohs400 }, |
| 941 | 946 | { .soc_id = "r8a7796", .revision = "ES1.*", .data = &sdhi_quirks_r8a7796_es13 }, |
| 942 | − { .soc_id = "r8a7796", .revision = "ES3.*", .data = &sdhi_quirks_bad_taps1357 }, | |
| 947 | + { .soc_id = "r8a77961", .data = &sdhi_quirks_bad_taps1357 }, | |
| 943 | 948 | { .soc_id = "r8a77965", .data = &sdhi_quirks_r8a77965 }, |
| 944 | 949 | { .soc_id = "r8a77980", .data = &sdhi_quirks_nohs400 }, |
| 945 | 950 | { .soc_id = "r8a77990", .data = &sdhi_quirks_r8a77990 }, |
| @@ -2177,8 +2177,6 @@ int cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid, · 2176 unmodified lines | ||
| 2177 | 2177 | bool persistent, u8 *smt_idx); |
| 2178 | 2178 | int cxgb4_get_msix_idx_from_bmap(struct adapter *adap); |
| 2179 | 2179 | void cxgb4_free_msix_idx_in_bmap(struct adapter *adap, u32 msix_idx); |
| 2180 | −int cxgb_open(struct net_device *dev); | |
| 2181 | −int cxgb_close(struct net_device *dev); | |
| 2182 | 2180 | void cxgb4_enable_rx(struct adapter *adap, struct sge_rspq *q); |
| 2183 | 2181 | void cxgb4_quiesce_rx(struct sge_rspq *q); |
| 2184 | 2182 | int cxgb4_port_mirror_alloc(struct net_device *dev); |
| @@ -2834,7 +2834,7 @@ static void cxgb_down(struct adapter *adapter) · 2833 unmodified lines | ||
| 2834 | 2834 | /* |
| 2835 | 2835 | * net_device operations |
| 2836 | 2836 | */ |
| 2837 | −int cxgb_open(struct net_device *dev) | |
| 2837 | +static int cxgb_open(struct net_device *dev) | |
| 2838 | 2838 | { |
| 2839 | 2839 | struct port_info *pi = netdev_priv(dev); |
| 2840 | 2840 | struct adapter *adapter = pi->adapter; |
| @@ -2882,7 +2882,7 @@ out_unlock: · 41 unmodified lines | ||
| 2882 | 2882 | return err; |
| 2883 | 2883 | } |
| 2884 | 2884 | |
| 2885 | −int cxgb_close(struct net_device *dev) | |
| 2885 | +static int cxgb_close(struct net_device *dev) | |
| 2886 | 2886 | { |
| 2887 | 2887 | struct port_info *pi = netdev_priv(dev); |
| 2888 | 2888 | struct adapter *adapter = pi->adapter; |
| @@ -997,20 +997,16 @@ int cxgb4_tc_flower_destroy(struct net_device *dev, · 996 unmodified lines | ||
| 997 | 997 | if (!ch_flower) |
| 998 | 998 | return -ENOENT; |
| 999 | 999 | |
| 1000 | + rhashtable_remove_fast(&adap->flower_tbl, &ch_flower->node, | |
| 1001 | + adap->flower_ht_params); | |
| 1002 | + | |
| 1000 | 1003 | ret = cxgb4_flow_rule_destroy(dev, ch_flower->fs.tc_prio, |
| 1001 | 1004 | &ch_flower->fs, ch_flower->filter_id); |
| 1002 | 1005 | if (ret) |
| 1003 | − goto err; | |
| 1006 | + netdev_err(dev, "Flow rule destroy failed for tid: %u, ret: %d", | |
| 1007 | + ch_flower->filter_id, ret); | |
| 1004 | 1008 | |
| 1005 | − ret = rhashtable_remove_fast(&adap->flower_tbl, &ch_flower->node, | |
| 1006 | − adap->flower_ht_params); | |
| 1007 | − if (ret) { | |
| 1008 | − netdev_err(dev, "Flow remove from rhashtable failed"); | |
| 1009 | − goto err; | |
| 1010 | − } | |
| 1011 | 1009 | kfree_rcu(ch_flower, rcu); |
| 1012 | − | |
| 1013 | −err: | |
| 1014 | 1010 | return ret; |
| 1015 | 1011 | } |
| 1016 | 1012 | |
| @@ -589,7 +589,8 @@ int cxgb4_setup_tc_mqprio(struct net_device *dev, · 588 unmodified lines | ||
| 589 | 589 | * down before configuring tc params. |
| 590 | 590 | */ |
| 591 | 591 | if (netif_running(dev)) { |
| 592 | − cxgb_close(dev); | |
| 592 | + netif_tx_stop_all_queues(dev); | |
| 593 | + netif_carrier_off(dev); | |
| 593 | 594 | needs_bring_up = true; |
| 594 | 595 | } |
| 595 | 596 | |
| @@ -615,8 +616,10 @@ int cxgb4_setup_tc_mqprio(struct net_device *dev, · 19 unmodified lines | ||
| 615 | 616 | } |
| 616 | 617 | |
| 617 | 618 | out: |
| 618 | − if (needs_bring_up) | |
| 619 | − cxgb_open(dev); | |
| 619 | + if (needs_bring_up) { | |
| 620 | + netif_tx_start_all_queues(dev); | |
| 621 | + netif_carrier_on(dev); | |
| 622 | + } | |
| 620 | 623 | |
| 621 | 624 | mutex_unlock(&adap->tc_mqprio->mqprio_mutex); |
| 622 | 625 | return ret; |
| @@ -2556,6 +2556,12 @@ int cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc) · 2555 unmodified lines | ||
| 2556 | 2556 | if (!eosw_txq) |
| 2557 | 2557 | return -ENOMEM; |
| 2558 | 2558 | |
| 2559 | + if (!(adap->flags & CXGB4_FW_OK)) { | |
| 2560 | + /* Don't stall caller when access to FW is lost */ | |
| 2561 | + complete(&eosw_txq->completion); | |
| 2562 | + return -EIO; | |
| 2563 | + } | |
| 2564 | + | |
| 2559 | 2565 | skb = alloc_skb(len, GFP_KERNEL); |
| 2560 | 2566 | if (!skb) |
| 2561 | 2567 | return -ENOMEM; |
| @@ -2313,15 +2313,20 @@ static int i40e_run_xdp(struct i40e_ring *rx_ring, struct xdp_buff *xdp) · 2312 unmodified lines | ||
| 2313 | 2313 | case XDP_TX: |
| 2314 | 2314 | xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->queue_index]; |
| 2315 | 2315 | result = i40e_xmit_xdp_tx_ring(xdp, xdp_ring); |
| 2316 | + if (result == I40E_XDP_CONSUMED) | |
| 2317 | + goto out_failure; | |
| 2316 | 2318 | break; |
| 2317 | 2319 | case XDP_REDIRECT: |
| 2318 | 2320 | err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); |
| 2319 | − result = !err ? I40E_XDP_REDIR : I40E_XDP_CONSUMED; | |
| 2321 | + if (err) | |
| 2322 | + goto out_failure; | |
| 2323 | + result = I40E_XDP_REDIR; | |
| 2320 | 2324 | break; |
| 2321 | 2325 | default: |
| 2322 | 2326 | bpf_warn_invalid_xdp_action(act); |
| 2323 | 2327 | fallthrough; |
| 2324 | 2328 | case XDP_ABORTED: |
| 2329 | +out_failure: | |
| 2325 | 2330 | trace_xdp_exception(rx_ring->netdev, xdp_prog, act); |
| 2326 | 2331 | fallthrough; /* handle aborts by dropping packet */ |
| 2327 | 2332 | case XDP_DROP: |
| @@ -162,9 +162,10 @@ static int i40e_run_xdp_zc(struct i40e_ring *rx_ring, struct xdp_buff *xdp) · 161 unmodified lines | ||
| 162 | 162 | |
| 163 | 163 | if (likely(act == XDP_REDIRECT)) { |
| 164 | 164 | err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); |
| 165 | − result = !err ? I40E_XDP_REDIR : I40E_XDP_CONSUMED; | |
| 165 | + if (err) | |
| 166 | + goto out_failure; | |
| 166 | 167 | rcu_read_unlock(); |
| 167 | − return result; | |
| 168 | + return I40E_XDP_REDIR; | |
| 168 | 169 | } |
| 169 | 170 | |
| 170 | 171 | switch (act) { |
| @@ -173,11 +174,14 @@ static int i40e_run_xdp_zc(struct i40e_ring *rx_ring, struct xdp_buff *xdp) · 2 unmodified lines | ||
| 173 | 174 | case XDP_TX: |
| 174 | 175 | xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->queue_index]; |
| 175 | 176 | result = i40e_xmit_xdp_tx_ring(xdp, xdp_ring); |
| 177 | + if (result == I40E_XDP_CONSUMED) | |
| 178 | + goto out_failure; | |
| 176 | 179 | break; |
| 177 | 180 | default: |
| 178 | 181 | bpf_warn_invalid_xdp_action(act); |
| 179 | 182 | fallthrough; |
| 180 | 183 | case XDP_ABORTED: |
| 184 | +out_failure: | |
| 181 | 185 | trace_xdp_exception(rx_ring->netdev, xdp_prog, act); |
| 182 | 186 | fallthrough; /* handle aborts by dropping packet */ |
| 183 | 187 | case XDP_DROP: |
| @@ -335,6 +335,7 @@ struct ice_vsi { · 334 unmodified lines | ||
| 335 | 335 | struct ice_tc_cfg tc_cfg; |
| 336 | 336 | struct bpf_prog *xdp_prog; |
| 337 | 337 | struct ice_ring **xdp_rings; /* XDP ring array */ |
| 338 | + unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled qps */ | |
| 338 | 339 | u16 num_xdp_txq; /* Used XDP queues */ |
| 339 | 340 | u8 xdp_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */ |
| 340 | 341 | |
| @@ -547,15 +548,16 @@ static inline void ice_set_ring_xdp(struct ice_ring *ring) · 206 unmodified lines | ||
| 547 | 548 | */ |
| 548 | 549 | static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_ring *ring) |
| 549 | 550 | { |
| 551 | + struct ice_vsi *vsi = ring->vsi; | |
| 550 | 552 | u16 qid = ring->q_index; |
| 551 | 553 | |
| 552 | 554 | if (ice_ring_is_xdp(ring)) |
| 553 | − qid -= ring->vsi->num_xdp_txq; | |
| 555 | + qid -= vsi->num_xdp_txq; | |
| 554 | 556 | |
| 555 | − if (!ice_is_xdp_ena_vsi(ring->vsi)) | |
| 557 | + if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps)) | |
| 556 | 558 | return NULL; |
| 557 | 559 | |
| 558 | − return xsk_get_pool_from_qid(ring->vsi->netdev, qid); | |
| 560 | + return xsk_get_pool_from_qid(vsi->netdev, qid); | |
| 559 | 561 | } |
| 560 | 562 | |
| 561 | 563 | /** |
| @@ -1773,49 +1773,6 @@ ice_phy_type_to_ethtool(struct net_device *netdev, · 1772 unmodified lines | ||
| 1773 | 1773 | ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB, |
| 1774 | 1774 | 100000baseKR4_Full); |
| 1775 | 1775 | } |
| 1776 | − | |
| 1777 | − /* Autoneg PHY types */ | |
| 1778 | − if (phy_types_low & ICE_PHY_TYPE_LOW_100BASE_TX || | |
| 1779 | − phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_T || | |
| 1780 | − phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_KX || | |
| 1781 | − phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_T || | |
| 1782 | − phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_KX || | |
| 1783 | − phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_T || | |
| 1784 | − phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_KR || | |
| 1785 | − phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_T || | |
| 1786 | − phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_KR_CR1 || | |
| 1787 | − phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_T || | |
| 1788 | − phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR || | |
| 1789 | − phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR_S || | |
| 1790 | − phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR1 || | |
| 1791 | − phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR || | |
| 1792 | − phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR_S || | |
| 1793 | − phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR1 || | |
| 1794 | − phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_CR4 || | |
| 1795 | − phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_KR4) { | |
| 1796 | − ethtool_link_ksettings_add_link_mode(ks, supported, | |
| 1797 | − Autoneg); | |
| 1798 | − ethtool_link_ksettings_add_link_mode(ks, advertising, | |
| 1799 | − Autoneg); | |
| 1800 | − } | |
| 1801 | − if (phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_CR2 || | |
| 1802 | − phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_KR2 || | |
| 1803 | − phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_CP || | |
| 1804 | − phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4) { | |
| 1805 | − ethtool_link_ksettings_add_link_mode(ks, supported, | |
| 1806 | − Autoneg); | |
| 1807 | − ethtool_link_ksettings_add_link_mode(ks, advertising, | |
| 1808 | − Autoneg); | |
| 1809 | − } | |
| 1810 | − if (phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_CR4 || | |
| 1811 | − phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_KR4 || | |
| 1812 | − phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4 || | |
| 1813 | − phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_CP2) { | |
| 1814 | − ethtool_link_ksettings_add_link_mode(ks, supported, | |
| 1815 | − Autoneg); | |
| 1816 | − ethtool_link_ksettings_add_link_mode(ks, advertising, | |
| 1817 | − Autoneg); | |
| 1818 | − } | |
| 1819 | 1776 | } |
| 1820 | 1777 | |
| 1821 | 1778 | #define TEST_SET_BITS_TIMEOUT 50 |
| @@ -1972,9 +1929,7 @@ ice_get_link_ksettings(struct net_device *netdev, · 150 unmodified lines | ||
| 1972 | 1929 | ks->base.port = PORT_TP; |
| 1973 | 1930 | break; |
| 1974 | 1931 | case ICE_MEDIA_BACKPLANE: |
| 1975 | − ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); | |
| 1976 | 1932 | ethtool_link_ksettings_add_link_mode(ks, supported, Backplane); |
| 1977 | − ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); | |
| 1978 | 1933 | ethtool_link_ksettings_add_link_mode(ks, advertising, |
| 1979 | 1934 | Backplane); |
| 1980 | 1935 | ks->base.port = PORT_NONE; |
| @@ -2049,6 +2004,12 @@ ice_get_link_ksettings(struct net_device *netdev, · 68 unmodified lines | ||
| 2049 | 2004 | if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN) |
| 2050 | 2005 | ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); |
| 2051 | 2006 | |
| 2007 | + /* Set supported and advertised autoneg */ | |
| 2008 | + if (ice_is_phy_caps_an_enabled(caps)) { | |
| 2009 | + ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); | |
| 2010 | + ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); | |
| 2011 | + } | |
| 2012 | + | |
| 2052 | 2013 | done: |
| 2053 | 2014 | kfree(caps); |
| 2054 | 2015 | return err; |
| @@ -31,6 +31,7 @@ · 30 unmodified lines | ||
| 31 | 31 | #define PF_FW_ATQLEN_ATQOVFL_M BIT(29) |
| 32 | 32 | #define PF_FW_ATQLEN_ATQCRIT_M BIT(30) |
| 33 | 33 | #define VF_MBX_ARQLEN(_VF) (0x0022BC00 + ((_VF) * 4)) |
| 34 | +#define VF_MBX_ATQLEN(_VF) (0x0022A800 + ((_VF) * 4)) | |
| 34 | 35 | #define PF_FW_ATQLEN_ATQENABLE_M BIT(31) |
| 35 | 36 | #define PF_FW_ATQT 0x00080400 |
| 36 | 37 | #define PF_MBX_ARQBAH 0x0022E400 |
| @@ -105,8 +105,14 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi) · 104 unmodified lines | ||
| 105 | 105 | if (!vsi->q_vectors) |
| 106 | 106 | goto err_vectors; |
| 107 | 107 | |
| 108 | + vsi->af_xdp_zc_qps = bitmap_zalloc(max_t(int, vsi->alloc_txq, vsi->alloc_rxq), GFP_KERNEL); | |
| 109 | + if (!vsi->af_xdp_zc_qps) | |
| 110 | + goto err_zc_qps; | |
| 111 | + | |
| 108 | 112 | return 0; |
| 109 | 113 | |
| 114 | +err_zc_qps: | |
| 115 | + devm_kfree(dev, vsi->q_vectors); | |
| 110 | 116 | err_vectors: |
| 111 | 117 | devm_kfree(dev, vsi->rxq_map); |
| 112 | 118 | err_rxq_map: |
| @@ -194,6 +200,8 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · 81 unmodified lines | ||
| 194 | 200 | break; |
| 195 | 201 | case ICE_VSI_VF: |
| 196 | 202 | vf = &pf->vf[vsi->vf_id]; |
| 203 | + if (vf->num_req_qs) | |
| 204 | + vf->num_vf_qs = vf->num_req_qs; | |
| 197 | 205 | vsi->alloc_txq = vf->num_vf_qs; |
| 198 | 206 | vsi->alloc_rxq = vf->num_vf_qs; |
| 199 | 207 | /* pf->num_msix_per_vf includes (VF miscellaneous vector + |
| @@ -288,6 +296,10 @@ static void ice_vsi_free_arrays(struct ice_vsi *vsi) · 88 unmodified lines | ||
| 288 | 296 | |
| 289 | 297 | dev = ice_pf_to_dev(pf); |
| 290 | 298 | |
| 299 | + if (vsi->af_xdp_zc_qps) { | |
| 300 | + bitmap_free(vsi->af_xdp_zc_qps); | |
| 301 | + vsi->af_xdp_zc_qps = NULL; | |
| 302 | + } | |
| 291 | 303 | /* free the ring and vector containers */ |
| 292 | 304 | if (vsi->q_vectors) { |
| 293 | 305 | devm_kfree(dev, vsi->q_vectors); |
| @@ -523,7 +523,7 @@ ice_run_xdp(struct ice_ring *rx_ring, struct xdp_buff *xdp, · 522 unmodified lines | ||
| 523 | 523 | struct bpf_prog *xdp_prog) |
| 524 | 524 | { |
| 525 | 525 | struct ice_ring *xdp_ring; |
| 526 | − int err; | |
| 526 | + int err, result; | |
| 527 | 527 | u32 act; |
| 528 | 528 | |
| 529 | 529 | act = bpf_prog_run_xdp(xdp_prog, xdp); |
| @@ -532,14 +532,20 @@ ice_run_xdp(struct ice_ring *rx_ring, struct xdp_buff *xdp, · 2 unmodified lines | ||
| 532 | 532 | return ICE_XDP_PASS; |
| 533 | 533 | case XDP_TX: |
| 534 | 534 | xdp_ring = rx_ring->vsi->xdp_rings[smp_processor_id()]; |
| 535 | − return ice_xmit_xdp_buff(xdp, xdp_ring); | |
| 535 | + result = ice_xmit_xdp_buff(xdp, xdp_ring); | |
| 536 | + if (result == ICE_XDP_CONSUMED) | |
| 537 | + goto out_failure; | |
| 538 | + return result; | |
| 536 | 539 | case XDP_REDIRECT: |
| 537 | 540 | err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); |
| 538 | − return !err ? ICE_XDP_REDIR : ICE_XDP_CONSUMED; | |
| 541 | + if (err) | |
| 542 | + goto out_failure; | |
| 543 | + return ICE_XDP_REDIR; | |
| 539 | 544 | default: |
| 540 | 545 | bpf_warn_invalid_xdp_action(act); |
| 541 | 546 | fallthrough; |
| 542 | 547 | case XDP_ABORTED: |
| 548 | +out_failure: | |
| 543 | 549 | trace_xdp_exception(rx_ring->netdev, xdp_prog, act); |
| 544 | 550 | fallthrough; |
| 545 | 551 | case XDP_DROP: |
| @@ -2143,6 +2149,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_ring *tx_ring) · 1597 unmodified lines | ||
| 2143 | 2149 | struct ice_tx_offload_params offload = { 0 }; |
| 2144 | 2150 | struct ice_vsi *vsi = tx_ring->vsi; |
| 2145 | 2151 | struct ice_tx_buf *first; |
| 2152 | + struct ethhdr *eth; | |
| 2146 | 2153 | unsigned int count; |
| 2147 | 2154 | int tso, csum; |
| 2148 | 2155 | |
| @@ -2189,7 +2196,9 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_ring *tx_ring) · 40 unmodified lines | ||
| 2189 | 2196 | goto out_drop; |
| 2190 | 2197 | |
| 2191 | 2198 | /* allow CONTROL frames egress from main VSI if FW LLDP disabled */ |
| 2192 | − if (unlikely(skb->priority == TC_PRIO_CONTROL && | |
| 2199 | + eth = (struct ethhdr *)skb_mac_header(skb); | |
| 2200 | + if (unlikely((skb->priority == TC_PRIO_CONTROL || | |
| 2201 | + eth->h_proto == htons(ETH_P_LLDP)) && | |
| 2193 | 2202 | vsi->type == ICE_VSI_PF && |
| 2194 | 2203 | vsi->port_info->qos_cfg.is_sw_lldp)) |
| 2195 | 2204 | offload.cd_qw1 |= (u64)(ICE_TX_DESC_DTYPE_CTX | |
| @@ -713,13 +713,15 @@ static void ice_trigger_vf_reset(struct ice_vf *vf, bool is_vflr, bool is_pfr) · 712 unmodified lines | ||
| 713 | 713 | */ |
| 714 | 714 | clear_bit(ICE_VF_STATE_INIT, vf->vf_states); |
| 715 | 715 | |
| 716 | − /* VF_MBX_ARQLEN is cleared by PFR, so the driver needs to clear it | |
| 717 | − * in the case of VFR. If this is done for PFR, it can mess up VF | |
| 718 | − * resets because the VF driver may already have started cleanup | |
| 719 | − * by the time we get here. | |
| 716 | + /* VF_MBX_ARQLEN and VF_MBX_ATQLEN are cleared by PFR, so the driver | |
| 717 | + * needs to clear them in the case of VFR/VFLR. If this is done for | |
| 718 | + * PFR, it can mess up VF resets because the VF driver may already | |
| 719 | + * have started cleanup by the time we get here. | |
| 720 | 720 | */ |
| 721 | − if (!is_pfr) | |
| 721 | + if (!is_pfr) { | |
| 722 | 722 | wr32(hw, VF_MBX_ARQLEN(vf->vf_id), 0); |
| 723 | + wr32(hw, VF_MBX_ATQLEN(vf->vf_id), 0); | |
| 724 | + } | |
| 723 | 725 | |
| 724 | 726 | /* In the case of a VFLR, the HW has already reset the VF and we |
| 725 | 727 | * just need to clean up, so don't hit the VFRTRIG register. |
| @@ -1698,7 +1700,12 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) · 972 unmodified lines | ||
| 1698 | 1700 | ice_vf_ctrl_vsi_release(vf); |
| 1699 | 1701 | |
| 1700 | 1702 | ice_vf_pre_vsi_rebuild(vf); |
| 1701 | − ice_vf_rebuild_vsi_with_release(vf); | |
| 1703 | + | |
| 1704 | + if (ice_vf_rebuild_vsi_with_release(vf)) { | |
| 1705 | + dev_err(dev, "Failed to release and setup the VF%u's VSI\n", vf->vf_id); | |
| 1706 | + return false; | |
| 1707 | + } | |
| 1708 | + | |
| 1702 | 1709 | ice_vf_post_vsi_rebuild(vf); |
| 1703 | 1710 | |
| 1704 | 1711 | /* if the VF has been reset allow it to come up again */ |
| @@ -270,6 +270,7 @@ static int ice_xsk_pool_disable(struct ice_vsi *vsi, u16 qid) · 269 unmodified lines | ||
| 270 | 270 | if (!pool) |
| 271 | 271 | return -EINVAL; |
| 272 | 272 | |
| 273 | + clear_bit(qid, vsi->af_xdp_zc_qps); | |
| 273 | 274 | xsk_pool_dma_unmap(pool, ICE_RX_DMA_ATTR); |
| 274 | 275 | |
| 275 | 276 | return 0; |
| @@ -300,6 +301,8 @@ ice_xsk_pool_enable(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid) · 24 unmodified lines | ||
| 300 | 301 | if (err) |
| 301 | 302 | return err; |
| 302 | 303 | |
| 304 | + set_bit(qid, vsi->af_xdp_zc_qps); | |
| 305 | + | |
| 303 | 306 | return 0; |
| 304 | 307 | } |
| 305 | 308 | |
| @@ -473,9 +476,10 @@ ice_run_xdp_zc(struct ice_ring *rx_ring, struct xdp_buff *xdp) · 167 unmodified lines | ||
| 473 | 476 | |
| 474 | 477 | if (likely(act == XDP_REDIRECT)) { |
| 475 | 478 | err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); |
| 476 | − result = !err ? ICE_XDP_REDIR : ICE_XDP_CONSUMED; | |
| 479 | + if (err) | |
| 480 | + goto out_failure; | |
| 477 | 481 | rcu_read_unlock(); |
| 478 | − return result; | |
| 482 | + return ICE_XDP_REDIR; | |
| 479 | 483 | } |
| 480 | 484 | |
| 481 | 485 | switch (act) { |
| @@ -484,11 +488,14 @@ ice_run_xdp_zc(struct ice_ring *rx_ring, struct xdp_buff *xdp) · 2 unmodified lines | ||
| 484 | 488 | case XDP_TX: |
| 485 | 489 | xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->q_index]; |
| 486 | 490 | result = ice_xmit_xdp_buff(xdp, xdp_ring); |
| 491 | + if (result == ICE_XDP_CONSUMED) | |
| 492 | + goto out_failure; | |
| 487 | 493 | break; |
| 488 | 494 | default: |
| 489 | 495 | bpf_warn_invalid_xdp_action(act); |
| 490 | 496 | fallthrough; |
| 491 | 497 | case XDP_ABORTED: |
| 498 | +out_failure: | |
| 492 | 499 | trace_xdp_exception(rx_ring->netdev, xdp_prog, act); |
| 493 | 500 | fallthrough; |
| 494 | 501 | case XDP_DROP: |
| @@ -749,7 +749,7 @@ void igb_ptp_rx_hang(struct igb_adapter *adapter); · 748 unmodified lines | ||
| 749 | 749 | void igb_ptp_tx_hang(struct igb_adapter *adapter); |
| 750 | 750 | void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb); |
| 751 | 751 | int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va, |
| 752 | − struct sk_buff *skb); | |
| 752 | + ktime_t *timestamp); | |
| 753 | 753 | int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr); |
| 754 | 754 | int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr); |
| 755 | 755 | void igb_set_flag_queue_pairs(struct igb_adapter *, const u32); |
| @@ -8280,7 +8280,7 @@ static void igb_add_rx_frag(struct igb_ring *rx_ring, · 8279 unmodified lines | ||
| 8280 | 8280 | static struct sk_buff *igb_construct_skb(struct igb_ring *rx_ring, |
| 8281 | 8281 | struct igb_rx_buffer *rx_buffer, |
| 8282 | 8282 | struct xdp_buff *xdp, |
| 8283 | − union e1000_adv_rx_desc *rx_desc) | |
| 8283 | + ktime_t timestamp) | |
| 8284 | 8284 | { |
| 8285 | 8285 | #if (PAGE_SIZE < 8192) |
| 8286 | 8286 | unsigned int truesize = igb_rx_pg_size(rx_ring) / 2; |
| @@ -8300,12 +8300,8 @@ static struct sk_buff *igb_construct_skb(struct igb_ring *rx_ring, · 13 unmodified lines | ||
| 8300 | 8300 | if (unlikely(!skb)) |
| 8301 | 8301 | return NULL; |
| 8302 | 8302 | |
| 8303 | − if (unlikely(igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP))) { | |
| 8304 | − if (!igb_ptp_rx_pktstamp(rx_ring->q_vector, xdp->data, skb)) { | |
| 8305 | − xdp->data += IGB_TS_HDR_LEN; | |
| 8306 | − size -= IGB_TS_HDR_LEN; | |
| 8307 | − } | |
| 8308 | − } | |
| 8303 | + if (timestamp) | |
| 8304 | + skb_hwtstamps(skb)->hwtstamp = timestamp; | |
| 8309 | 8305 | |
| 8310 | 8306 | /* Determine available headroom for copy */ |
| 8311 | 8307 | headlen = size; |
| @@ -8336,7 +8332,7 @@ static struct sk_buff *igb_construct_skb(struct igb_ring *rx_ring, · 24 unmodified lines | ||
| 8336 | 8332 | static struct sk_buff *igb_build_skb(struct igb_ring *rx_ring, |
| 8337 | 8333 | struct igb_rx_buffer *rx_buffer, |
| 8338 | 8334 | struct xdp_buff *xdp, |
| 8339 | − union e1000_adv_rx_desc *rx_desc) | |
| 8335 | + ktime_t timestamp) | |
| 8340 | 8336 | { |
| 8341 | 8337 | #if (PAGE_SIZE < 8192) |
| 8342 | 8338 | unsigned int truesize = igb_rx_pg_size(rx_ring) / 2; |
| @@ -8363,11 +8359,8 @@ static struct sk_buff *igb_build_skb(struct igb_ring *rx_ring, · 20 unmodified lines | ||
| 8363 | 8359 | if (metasize) |
| 8364 | 8360 | skb_metadata_set(skb, metasize); |
| 8365 | 8361 | |
| 8366 | − /* pull timestamp out of packet data */ | |
| 8367 | − if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) { | |
| 8368 | − if (!igb_ptp_rx_pktstamp(rx_ring->q_vector, skb->data, skb)) | |
| 8369 | − __skb_pull(skb, IGB_TS_HDR_LEN); | |
| 8370 | − } | |
| 8362 | + if (timestamp) | |
| 8363 | + skb_hwtstamps(skb)->hwtstamp = timestamp; | |
| 8371 | 8364 | |
| 8372 | 8365 | /* update buffer offset */ |
| 8373 | 8366 | #if (PAGE_SIZE < 8192) |
| @@ -8401,18 +8394,20 @@ static struct sk_buff *igb_run_xdp(struct igb_adapter *adapter, · 27 unmodified lines | ||
| 8401 | 8394 | break; |
| 8402 | 8395 | case XDP_TX: |
| 8403 | 8396 | result = igb_xdp_xmit_back(adapter, xdp); |
| 8397 | + if (result == IGB_XDP_CONSUMED) | |
| 8398 | + goto out_failure; | |
| 8404 | 8399 | break; |
| 8405 | 8400 | case XDP_REDIRECT: |
| 8406 | 8401 | err = xdp_do_redirect(adapter->netdev, xdp, xdp_prog); |
| 8407 | − if (!err) | |
| 8408 | − result = IGB_XDP_REDIR; | |
| 8409 | − else | |
| 8410 | − result = IGB_XDP_CONSUMED; | |
| 8402 | + if (err) | |
| 8403 | + goto out_failure; | |
| 8404 | + result = IGB_XDP_REDIR; | |
| 8411 | 8405 | break; |
| 8412 | 8406 | default: |
| 8413 | 8407 | bpf_warn_invalid_xdp_action(act); |
| 8414 | 8408 | fallthrough; |
| 8415 | 8409 | case XDP_ABORTED: |
| 8410 | +out_failure: | |
| 8416 | 8411 | trace_xdp_exception(rx_ring->netdev, xdp_prog, act); |
| 8417 | 8412 | fallthrough; |
| 8418 | 8413 | case XDP_DROP: |
| @@ -8682,7 +8677,10 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) · 263 unmodified lines | ||
| 8682 | 8677 | while (likely(total_packets < budget)) { |
| 8683 | 8678 | union e1000_adv_rx_desc *rx_desc; |
| 8684 | 8679 | struct igb_rx_buffer *rx_buffer; |
| 8680 | + ktime_t timestamp = 0; | |
| 8681 | + int pkt_offset = 0; | |
| 8685 | 8682 | unsigned int size; |
| 8683 | + void *pktbuf; | |
| 8686 | 8684 | |
| 8687 | 8685 | /* return some buffers to hardware, one at a time is too slow */ |
| 8688 | 8686 | if (cleaned_count >= IGB_RX_BUFFER_WRITE) { |
| @@ -8702,14 +8700,24 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) · 13 unmodified lines | ||
| 8702 | 8700 | dma_rmb(); |
| 8703 | 8701 | |
| 8704 | 8702 | rx_buffer = igb_get_rx_buffer(rx_ring, size, &rx_buf_pgcnt); |
| 8703 | + pktbuf = page_address(rx_buffer->page) + rx_buffer->page_offset; | |
| 8704 | + | |
| 8705 | + /* pull rx packet timestamp if available and valid */ | |
| 8706 | + if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) { | |
| 8707 | + int ts_hdr_len; | |
| 8708 | + | |
| 8709 | + ts_hdr_len = igb_ptp_rx_pktstamp(rx_ring->q_vector, | |
| 8710 | + pktbuf, ×tamp); | |
| 8711 | + | |
| 8712 | + pkt_offset += ts_hdr_len; | |
| 8713 | + size -= ts_hdr_len; | |
| 8714 | + } | |
| 8705 | 8715 | |
| 8706 | 8716 | /* retrieve a buffer from the ring */ |
| 8707 | 8717 | if (!skb) { |
| 8708 | − unsigned int offset = igb_rx_offset(rx_ring); | |
| 8709 | − unsigned char *hard_start; | |
| 8718 | + unsigned char *hard_start = pktbuf - igb_rx_offset(rx_ring); | |
| 8719 | + unsigned int offset = pkt_offset + igb_rx_offset(rx_ring); | |
| 8710 | 8720 | |
| 8711 | − hard_start = page_address(rx_buffer->page) + | |
| 8712 | − rx_buffer->page_offset - offset; | |
| 8713 | 8721 | xdp_prepare_buff(&xdp, hard_start, offset, size, true); |
| 8714 | 8722 | #if (PAGE_SIZE > 4096) |
| 8715 | 8723 | /* At larger PAGE_SIZE, frame_sz depend on len size */ |
| @@ -8732,10 +8740,11 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) · 16 unmodified lines | ||
| 8732 | 8740 | } else if (skb) |
| 8733 | 8741 | igb_add_rx_frag(rx_ring, rx_buffer, skb, size); |
| 8734 | 8742 | else if (ring_uses_build_skb(rx_ring)) |
| 8735 | − skb = igb_build_skb(rx_ring, rx_buffer, &xdp, rx_desc); | |
| 8743 | + skb = igb_build_skb(rx_ring, rx_buffer, &xdp, | |
| 8744 | + timestamp); | |
| 8736 | 8745 | else |
| 8737 | 8746 | skb = igb_construct_skb(rx_ring, rx_buffer, |
| 8738 | − &xdp, rx_desc); | |
| 8747 | + &xdp, timestamp); | |
| 8739 | 8748 | |
| 8740 | 8749 | /* exit if we failed to retrieve a buffer */ |
| 8741 | 8750 | if (!skb) { |
| @@ -856,30 +856,28 @@ static void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter) · 855 unmodified lines | ||
| 856 | 856 | dev_kfree_skb_any(skb); |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | −#define IGB_RET_PTP_DISABLED 1 | |
| 860 | −#define IGB_RET_PTP_INVALID 2 | |
| 861 | − | |
| 862 | 859 | /** |
| 863 | 860 | * igb_ptp_rx_pktstamp - retrieve Rx per packet timestamp |
| 864 | 861 | * @q_vector: Pointer to interrupt specific structure |
| 865 | 862 | * @va: Pointer to address containing Rx buffer |
| 866 | − * @skb: Buffer containing timestamp and packet | |
| 863 | + * @timestamp: Pointer where timestamp will be stored | |
| 867 | 864 | * |
| 868 | 865 | * This function is meant to retrieve a timestamp from the first buffer of an |
| 869 | 866 | * incoming frame. The value is stored in little endian format starting on |
| 870 | 867 | * byte 8 |
| 871 | 868 | * |
| 872 | − * Returns: 0 if success, nonzero if failure | |
| 869 | + * Returns: The timestamp header length or 0 if not available | |
| 873 | 870 | **/ |
| 874 | 871 | int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va, |
| 875 | − struct sk_buff *skb) | |
| 872 | + ktime_t *timestamp) | |
| 876 | 873 | { |
| 877 | 874 | struct igb_adapter *adapter = q_vector->adapter; |
| 875 | + struct skb_shared_hwtstamps ts; | |
| 878 | 876 | __le64 *regval = (__le64 *)va; |
| 879 | 877 | int adjust = 0; |
| 880 | 878 | |
| 881 | 879 | if (!(adapter->ptp_flags & IGB_PTP_ENABLED)) |
| 882 | − return IGB_RET_PTP_DISABLED; | |
| 880 | + return 0; | |
| 883 | 881 | |
| 884 | 882 | /* The timestamp is recorded in little endian format. |
| 885 | 883 | * DWORD: 0 1 2 3 |
| @@ -888,10 +886,9 @@ int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va, · 2 unmodified lines | ||
| 888 | 886 | |
| 889 | 887 | /* check reserved dwords are zero, be/le doesn't matter for zero */ |
| 890 | 888 | if (regval[0]) |
| 891 | − return IGB_RET_PTP_INVALID; | |
| 889 | + return 0; | |
| 892 | 890 | |
| 893 | − igb_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), | |
| 894 | − le64_to_cpu(regval[1])); | |
| 891 | + igb_ptp_systim_to_hwtstamp(adapter, &ts, le64_to_cpu(regval[1])); | |
| 895 | 892 | |
| 896 | 893 | /* adjust timestamp for the RX latency based on link speed */ |
| 897 | 894 | if (adapter->hw.mac.type == e1000_i210) { |
| @@ -907,10 +904,10 @@ int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va, · 9 unmodified lines | ||
| 907 | 904 | break; |
| 908 | 905 | } |
| 909 | 906 | } |
| 910 | − skb_hwtstamps(skb)->hwtstamp = | |
| 911 | − ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp, adjust); | |
| 912 | 907 | |
| 913 | − return 0; | |
| 908 | + *timestamp = ktime_sub_ns(ts.hwtstamp, adjust); | |
| 909 | + | |
| 910 | + return IGB_TS_HDR_LEN; | |
| 914 | 911 | } |
| 915 | 912 | |
| 916 | 913 | /** |
| @@ -2047,20 +2047,19 @@ static struct sk_buff *igc_xdp_run_prog(struct igc_adapter *adapter, · 2046 unmodified lines | ||
| 2047 | 2047 | break; |
| 2048 | 2048 | case XDP_TX: |
| 2049 | 2049 | if (igc_xdp_xmit_back(adapter, xdp) < 0) |
| 2050 | − res = IGC_XDP_CONSUMED; | |
| 2051 | − else | |
| 2052 | − res = IGC_XDP_TX; | |
| 2050 | + goto out_failure; | |
| 2051 | + res = IGC_XDP_TX; | |
| 2053 | 2052 | break; |
| 2054 | 2053 | case XDP_REDIRECT: |
| 2055 | 2054 | if (xdp_do_redirect(adapter->netdev, xdp, prog) < 0) |
| 2056 | − res = IGC_XDP_CONSUMED; | |
| 2057 | − else | |
| 2058 | − res = IGC_XDP_REDIRECT; | |
| 2055 | + goto out_failure; | |
| 2056 | + res = IGC_XDP_REDIRECT; | |
| 2059 | 2057 | break; |
| 2060 | 2058 | default: |
| 2061 | 2059 | bpf_warn_invalid_xdp_action(act); |
| 2062 | 2060 | fallthrough; |
| 2063 | 2061 | case XDP_ABORTED: |
| 2062 | +out_failure: | |
| 2064 | 2063 | trace_xdp_exception(adapter->netdev, prog, act); |
| 2065 | 2064 | fallthrough; |
| 2066 | 2065 | case XDP_DROP: |
| @@ -2213,23 +2213,23 @@ static struct sk_buff *ixgbe_run_xdp(struct ixgbe_adapter *adapter, · 2212 unmodified lines | ||
| 2213 | 2213 | break; |
| 2214 | 2214 | case XDP_TX: |
| 2215 | 2215 | xdpf = xdp_convert_buff_to_frame(xdp); |
| 2216 | − if (unlikely(!xdpf)) { | |
| 2217 | − result = IXGBE_XDP_CONSUMED; | |
| 2218 | − break; | |
| 2219 | − } | |
| 2216 | + if (unlikely(!xdpf)) | |
| 2217 | + goto out_failure; | |
| 2220 | 2218 | result = ixgbe_xmit_xdp_ring(adapter, xdpf); |
| 2219 | + if (result == IXGBE_XDP_CONSUMED) | |
| 2220 | + goto out_failure; | |
| 2221 | 2221 | break; |
| 2222 | 2222 | case XDP_REDIRECT: |
| 2223 | 2223 | err = xdp_do_redirect(adapter->netdev, xdp, xdp_prog); |
| 2224 | − if (!err) | |
| 2225 | − result = IXGBE_XDP_REDIR; | |
| 2226 | − else | |
| 2227 | − result = IXGBE_XDP_CONSUMED; | |
| 2224 | + if (err) | |
| 2225 | + goto out_failure; | |
| 2226 | + result = IXGBE_XDP_REDIR; | |
| 2228 | 2227 | break; |
| 2229 | 2228 | default: |
| 2230 | 2229 | bpf_warn_invalid_xdp_action(act); |
| 2231 | 2230 | fallthrough; |
| 2232 | 2231 | case XDP_ABORTED: |
| 2232 | +out_failure: | |
| 2233 | 2233 | trace_xdp_exception(rx_ring->netdev, xdp_prog, act); |
| 2234 | 2234 | fallthrough; /* handle aborts by dropping packet */ |
| 2235 | 2235 | case XDP_DROP: |
| @@ -106,9 +106,10 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter, · 105 unmodified lines | ||
| 106 | 106 | |
| 107 | 107 | if (likely(act == XDP_REDIRECT)) { |
| 108 | 108 | err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog); |
| 109 | − result = !err ? IXGBE_XDP_REDIR : IXGBE_XDP_CONSUMED; | |
| 109 | + if (err) | |
| 110 | + goto out_failure; | |
| 110 | 111 | rcu_read_unlock(); |
| 111 | − return result; | |
| 112 | + return IXGBE_XDP_REDIR; | |
| 112 | 113 | } |
| 113 | 114 | |
| 114 | 115 | switch (act) { |
| @@ -116,16 +117,17 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter, · 1 unmodified line | ||
| 116 | 117 | break; |
| 117 | 118 | case XDP_TX: |
| 118 | 119 | xdpf = xdp_convert_buff_to_frame(xdp); |
| 119 | − if (unlikely(!xdpf)) { | |
| 120 | − result = IXGBE_XDP_CONSUMED; | |
| 121 | − break; | |
| 122 | − } | |
| 120 | + if (unlikely(!xdpf)) | |
| 121 | + goto out_failure; | |
| 123 | 122 | result = ixgbe_xmit_xdp_ring(adapter, xdpf); |
| 123 | + if (result == IXGBE_XDP_CONSUMED) | |
| 124 | + goto out_failure; | |
| 124 | 125 | break; |
| 125 | 126 | default: |
| 126 | 127 | bpf_warn_invalid_xdp_action(act); |
| 127 | 128 | fallthrough; |
| 128 | 129 | case XDP_ABORTED: |
| 130 | +out_failure: | |
| 129 | 131 | trace_xdp_exception(rx_ring->netdev, xdp_prog, act); |
| 130 | 132 | fallthrough; /* handle aborts by dropping packet */ |
| 131 | 133 | case XDP_DROP: |
| @@ -1067,11 +1067,14 @@ static struct sk_buff *ixgbevf_run_xdp(struct ixgbevf_adapter *adapter, · 1066 unmodified lines | ||
| 1067 | 1067 | case XDP_TX: |
| 1068 | 1068 | xdp_ring = adapter->xdp_ring[rx_ring->queue_index]; |
| 1069 | 1069 | result = ixgbevf_xmit_xdp_ring(xdp_ring, xdp); |
| 1070 | + if (result == IXGBEVF_XDP_CONSUMED) | |
| 1071 | + goto out_failure; | |
| 1070 | 1072 | break; |
| 1071 | 1073 | default: |
| 1072 | 1074 | bpf_warn_invalid_xdp_action(act); |
| 1073 | 1075 | fallthrough; |
| 1074 | 1076 | case XDP_ABORTED: |
| 1077 | +out_failure: | |
| 1075 | 1078 | trace_xdp_exception(rx_ring->netdev, xdp_prog, act); |
| 1076 | 1079 | fallthrough; /* handle aborts by dropping packet */ |
| 1077 | 1080 | case XDP_DROP: |
| @@ -823,6 +823,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) · 822 unmodified lines | ||
| 823 | 823 | #define QUERY_DEV_CAP_MAD_DEMUX_OFFSET 0xb0 |
| 824 | 824 | #define QUERY_DEV_CAP_DMFS_HIGH_RATE_QPN_BASE_OFFSET 0xa8 |
| 825 | 825 | #define QUERY_DEV_CAP_DMFS_HIGH_RATE_QPN_RANGE_OFFSET 0xac |
| 826 | +#define QUERY_DEV_CAP_MAP_CLOCK_TO_USER 0xc1 | |
| 826 | 827 | #define QUERY_DEV_CAP_QP_RATE_LIMIT_NUM_OFFSET 0xcc |
| 827 | 828 | #define QUERY_DEV_CAP_QP_RATE_LIMIT_MAX_OFFSET 0xd0 |
| 828 | 829 | #define QUERY_DEV_CAP_QP_RATE_LIMIT_MIN_OFFSET 0xd2 |
| @@ -841,6 +842,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) · 12 unmodified lines | ||
| 841 | 842 | |
| 842 | 843 | if (mlx4_is_mfunc(dev)) |
| 843 | 844 | disable_unsupported_roce_caps(outbox); |
| 845 | + MLX4_GET(field, outbox, QUERY_DEV_CAP_MAP_CLOCK_TO_USER); | |
| 846 | + dev_cap->map_clock_to_user = field & 0x80; | |
| 844 | 847 | MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_QP_OFFSET); |
| 845 | 848 | dev_cap->reserved_qps = 1 << (field & 0xf); |
| 846 | 849 | MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_QP_OFFSET); |
| @@ -131,6 +131,7 @@ struct mlx4_dev_cap { · 130 unmodified lines | ||
| 131 | 131 | u32 health_buffer_addrs; |
| 132 | 132 | struct mlx4_port_cap port_cap[MLX4_MAX_PORTS + 1]; |
| 133 | 133 | bool wol_port[MLX4_MAX_PORTS + 1]; |
| 134 | + bool map_clock_to_user; | |
| 134 | 135 | }; |
| 135 | 136 | |
| 136 | 137 | struct mlx4_func_cap { |
| @@ -498,6 +498,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) · 497 unmodified lines | ||
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | + dev->caps.map_clock_to_user = dev_cap->map_clock_to_user; | |
| 501 | 502 | dev->caps.uar_page_size = PAGE_SIZE; |
| 502 | 503 | dev->caps.num_uars = dev_cap->uar_size / PAGE_SIZE; |
| 503 | 504 | dev->caps.local_ca_ack_delay = dev_cap->local_ca_ack_delay; |
| @@ -1948,6 +1949,11 @@ int mlx4_get_internal_clock_params(struct mlx4_dev *dev, · 1444 unmodified lines | ||
| 1948 | 1949 | if (mlx4_is_slave(dev)) |
| 1949 | 1950 | return -EOPNOTSUPP; |
| 1950 | 1951 | |
| 1952 | + if (!dev->caps.map_clock_to_user) { | |
| 1953 | + mlx4_dbg(dev, "Map clock to user is not supported.\n"); | |
| 1954 | + return -EOPNOTSUPP; | |
| 1955 | + } | |
| 1956 | + | |
| 1951 | 1957 | if (!params) |
| 1952 | 1958 | return -EINVAL; |
| 1953 | 1959 | |
| @@ -1624,12 +1624,13 @@ static int mlx5e_set_fecparam(struct net_device *netdev, · 1623 unmodified lines | ||
| 1624 | 1624 | { |
| 1625 | 1625 | struct mlx5e_priv *priv = netdev_priv(netdev); |
| 1626 | 1626 | struct mlx5_core_dev *mdev = priv->mdev; |
| 1627 | + unsigned long fec_bitmap; | |
| 1627 | 1628 | u16 fec_policy = 0; |
| 1628 | 1629 | int mode; |
| 1629 | 1630 | int err; |
| 1630 | 1631 | |
| 1631 | − if (bitmap_weight((unsigned long *)&fecparam->fec, | |
| 1632 | − ETHTOOL_FEC_LLRS_BIT + 1) > 1) | |
| 1632 | + bitmap_from_arr32(&fec_bitmap, &fecparam->fec, sizeof(fecparam->fec) * BITS_PER_BYTE); | |
| 1633 | + if (bitmap_weight(&fec_bitmap, ETHTOOL_FEC_LLRS_BIT + 1) > 1) | |
| 1633 | 1634 | return -EOPNOTSUPP; |
| 1634 | 1635 | |
| 1635 | 1636 | for (mode = 0; mode < ARRAY_SIZE(pplm_fec_2_ethtool); mode++) { |
| @@ -1893,6 +1894,13 @@ int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool new_val · 257 unmodified lines | ||
| 1893 | 1894 | if (curr_val == new_val) |
| 1894 | 1895 | return 0; |
| 1895 | 1896 | |
| 1897 | + if (new_val && !priv->profile->rx_ptp_support && | |
| 1898 | + priv->tstamp.rx_filter != HWTSTAMP_FILTER_NONE) { | |
| 1899 | + netdev_err(priv->netdev, | |
| 1900 | + "Profile doesn't support enabling of CQE compression while hardware time-stamping is enabled.\n"); | |
| 1901 | + return -EINVAL; | |
| 1902 | + } | |
| 1903 | + | |
| 1896 | 1904 | new_params = priv->channels.params; |
| 1897 | 1905 | MLX5E_SET_PFLAG(&new_params, MLX5E_PFLAG_RX_CQE_COMPRESS, new_val); |
| 1898 | 1906 | if (priv->tstamp.rx_filter != HWTSTAMP_FILTER_NONE) |
| @@ -3858,6 +3858,16 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev, · 3857 unmodified lines | ||
| 3858 | 3858 | netdev_warn(netdev, "Disabling rxhash, not supported when CQE compress is active\n"); |
| 3859 | 3859 | } |
| 3860 | 3860 | |
| 3861 | + if (mlx5e_is_uplink_rep(priv)) { | |
| 3862 | + features &= ~NETIF_F_HW_TLS_RX; | |
| 3863 | + if (netdev->features & NETIF_F_HW_TLS_RX) | |
| 3864 | + netdev_warn(netdev, "Disabling hw_tls_rx, not supported in switchdev mode\n"); | |
| 3865 | + | |
| 3866 | + features &= ~NETIF_F_HW_TLS_TX; | |
| 3867 | + if (netdev->features & NETIF_F_HW_TLS_TX) | |
| 3868 | + netdev_warn(netdev, "Disabling hw_tls_tx, not supported in switchdev mode\n"); | |
| 3869 | + } | |
| 3870 | + | |
| 3861 | 3871 | mutex_unlock(&priv->state_lock); |
| 3862 | 3872 | |
| 3863 | 3873 | return features; |
| @@ -3974,11 +3984,45 @@ int mlx5e_ptp_rx_manage_fs_ctx(struct mlx5e_priv *priv, void *ctx) · 110 unmodified lines | ||
| 3974 | 3984 | return mlx5e_ptp_rx_manage_fs(priv, set); |
| 3975 | 3985 | } |
| 3976 | 3986 | |
| 3977 | −int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr) | |
| 3987 | +static int mlx5e_hwstamp_config_no_ptp_rx(struct mlx5e_priv *priv, bool rx_filter) | |
| 3988 | +{ | |
| 3989 | + bool rx_cqe_compress_def = priv->channels.params.rx_cqe_compress_def; | |
| 3990 | + int err; | |
| 3991 | + | |
| 3992 | + if (!rx_filter) | |
| 3993 | + /* Reset CQE compression to Admin default */ | |
| 3994 | + return mlx5e_modify_rx_cqe_compression_locked(priv, rx_cqe_compress_def); | |
| 3995 | + | |
| 3996 | + if (!MLX5E_GET_PFLAG(&priv->channels.params, MLX5E_PFLAG_RX_CQE_COMPRESS)) | |
| 3997 | + return 0; | |
| 3998 | + | |
| 3999 | + /* Disable CQE compression */ | |
| 4000 | + netdev_warn(priv->netdev, "Disabling RX cqe compression\n"); | |
| 4001 | + err = mlx5e_modify_rx_cqe_compression_locked(priv, false); | |
| 4002 | + if (err) | |
| 4003 | + netdev_err(priv->netdev, "Failed disabling cqe compression err=%d\n", err); | |
| 4004 | + | |
| 4005 | + return err; | |
| 4006 | +} | |
| 4007 | + | |
| 4008 | +static int mlx5e_hwstamp_config_ptp_rx(struct mlx5e_priv *priv, bool ptp_rx) | |
| 3978 | 4009 | { |
| 3979 | 4010 | struct mlx5e_params new_params; |
| 4011 | + | |
| 4012 | + if (ptp_rx == priv->channels.params.ptp_rx) | |
| 4013 | + return 0; | |
| 4014 | + | |
| 4015 | + new_params = priv->channels.params; | |
| 4016 | + new_params.ptp_rx = ptp_rx; | |
| 4017 | + return mlx5e_safe_switch_params(priv, &new_params, mlx5e_ptp_rx_manage_fs_ctx, | |
| 4018 | + &new_params.ptp_rx, true); | |
| 4019 | +} | |
| 4020 | + | |
| 4021 | +int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr) | |
| 4022 | +{ | |
| 3980 | 4023 | struct hwtstamp_config config; |
| 3981 | 4024 | bool rx_cqe_compress_def; |
| 4025 | + bool ptp_rx; | |
| 3982 | 4026 | int err; |
| 3983 | 4027 | |
| 3984 | 4028 | if (!MLX5_CAP_GEN(priv->mdev, device_frequency_khz) || |
| @@ -3998,13 +4042,12 @@ int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr) · 13 unmodified lines | ||
| 3998 | 4042 | } |
| 3999 | 4043 | |
| 4000 | 4044 | mutex_lock(&priv->state_lock); |
| 4001 | − new_params = priv->channels.params; | |
| 4002 | 4045 | rx_cqe_compress_def = priv->channels.params.rx_cqe_compress_def; |
| 4003 | 4046 | |
| 4004 | 4047 | /* RX HW timestamp */ |
| 4005 | 4048 | switch (config.rx_filter) { |
| 4006 | 4049 | case HWTSTAMP_FILTER_NONE: |
| 4007 | − new_params.ptp_rx = false; | |
| 4050 | + ptp_rx = false; | |
| 4008 | 4051 | break; |
| 4009 | 4052 | case HWTSTAMP_FILTER_ALL: |
| 4010 | 4053 | case HWTSTAMP_FILTER_SOME: |
| @@ -4021,24 +4064,25 @@ int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr) · 10 unmodified lines | ||
| 4021 | 4064 | case HWTSTAMP_FILTER_PTP_V2_SYNC: |
| 4022 | 4065 | case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: |
| 4023 | 4066 | case HWTSTAMP_FILTER_NTP_ALL: |
| 4024 | − new_params.ptp_rx = rx_cqe_compress_def; | |
| 4025 | 4067 | config.rx_filter = HWTSTAMP_FILTER_ALL; |
| 4068 | + /* ptp_rx is set if both HW TS is set and CQE | |
| 4069 | + * compression is set | |
| 4070 | + */ | |
| 4071 | + ptp_rx = rx_cqe_compress_def; | |
| 4026 | 4072 | break; |
| 4027 | 4073 | default: |
| 4028 | − mutex_unlock(&priv->state_lock); | |
| 4029 | − return -ERANGE; | |
| 4074 | + err = -ERANGE; | |
| 4075 | + goto err_unlock; | |
| 4030 | 4076 | } |
| 4031 | 4077 | |
| 4032 | − if (new_params.ptp_rx == priv->channels.params.ptp_rx) | |
| 4033 | − goto out; | |
| 4078 | + if (!priv->profile->rx_ptp_support) | |
| 4079 | + err = mlx5e_hwstamp_config_no_ptp_rx(priv, | |
| 4080 | + config.rx_filter != HWTSTAMP_FILTER_NONE); | |
| 4081 | + else | |
| 4082 | + err = mlx5e_hwstamp_config_ptp_rx(priv, ptp_rx); | |
| 4083 | + if (err) | |
| 4084 | + goto err_unlock; | |
| 4034 | 4085 | |
| 4035 | − err = mlx5e_safe_switch_params(priv, &new_params, mlx5e_ptp_rx_manage_fs_ctx, | |
| 4036 | − &new_params.ptp_rx, true); | |
| 4037 | − if (err) { | |
| 4038 | − mutex_unlock(&priv->state_lock); | |
| 4039 | − return err; | |
| 4040 | − } | |
| 4041 | −out: | |
| 4042 | 4086 | memcpy(&priv->tstamp, &config, sizeof(config)); |
| 4043 | 4087 | mutex_unlock(&priv->state_lock); |
| 4044 | 4088 | |
| @@ -4047,6 +4091,9 @@ out: · 2 unmodified lines | ||
| 4047 | 4091 | |
| 4048 | 4092 | return copy_to_user(ifr->ifr_data, &config, |
| 4049 | 4093 | sizeof(config)) ? -EFAULT : 0; |
| 4094 | +err_unlock: | |
| 4095 | + mutex_unlock(&priv->state_lock); | |
| 4096 | + return err; | |
| 4050 | 4097 | } |
| 4051 | 4098 | |
| 4052 | 4099 | int mlx5e_hwstamp_get(struct mlx5e_priv *priv, struct ifreq *ifr) |
| @@ -2015,11 +2015,13 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, · 2014 unmodified lines | ||
| 2015 | 2015 | misc_parameters_3); |
| 2016 | 2016 | struct flow_rule *rule = flow_cls_offload_flow_rule(f); |
| 2017 | 2017 | struct flow_dissector *dissector = rule->match.dissector; |
| 2018 | + enum fs_flow_table_type fs_type; | |
| 2018 | 2019 | u16 addr_type = 0; |
| 2019 | 2020 | u8 ip_proto = 0; |
| 2020 | 2021 | u8 *match_level; |
| 2021 | 2022 | int err; |
| 2022 | 2023 | |
| 2024 | + fs_type = mlx5e_is_eswitch_flow(flow) ? FS_FT_FDB : FS_FT_NIC_RX; | |
| 2023 | 2025 | match_level = outer_match_level; |
| 2024 | 2026 | |
| 2025 | 2027 | if (dissector->used_keys & |
| @@ -2145,6 +2147,13 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, · 119 unmodified lines | ||
| 2145 | 2147 | if (match.mask->vlan_id || |
| 2146 | 2148 | match.mask->vlan_priority || |
| 2147 | 2149 | match.mask->vlan_tpid) { |
| 2150 | + if (!MLX5_CAP_FLOWTABLE_TYPE(priv->mdev, ft_field_support.outer_second_vid, | |
| 2151 | + fs_type)) { | |
| 2152 | + NL_SET_ERR_MSG_MOD(extack, | |
| 2153 | + "Matching on CVLAN is not supported"); | |
| 2154 | + return -EOPNOTSUPP; | |
| 2155 | + } | |
| 2156 | + | |
| 2148 | 2157 | if (match.key->vlan_tpid == htons(ETH_P_8021AD)) { |
| 2149 | 2158 | MLX5_SET(fte_match_set_misc, misc_c, |
| 2150 | 2159 | outer_second_svlan_tag, 1); |
| @@ -219,7 +219,8 @@ esw_setup_slow_path_dest(struct mlx5_flow_destination *dest, · 218 unmodified lines | ||
| 219 | 219 | struct mlx5_fs_chains *chains, |
| 220 | 220 | int i) |
| 221 | 221 | { |
| 222 | − flow_act->flags |= FLOW_ACT_IGNORE_FLOW_LEVEL; | |
| 222 | + if (mlx5_chains_ignore_flow_level_supported(chains)) | |
| 223 | + flow_act->flags |= FLOW_ACT_IGNORE_FLOW_LEVEL; | |
| 223 | 224 | dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; |
| 224 | 225 | dest[i].ft = mlx5_chains_get_tc_end_ft(chains); |
| 225 | 226 | } |
| @@ -349,6 +349,9 @@ static void mlx5_sync_reset_abort_event(struct work_struct *work) · 348 unmodified lines | ||
| 349 | 349 | reset_abort_work); |
| 350 | 350 | struct mlx5_core_dev *dev = fw_reset->dev; |
| 351 | 351 | |
| 352 | + if (!test_bit(MLX5_FW_RESET_FLAGS_RESET_REQUESTED, &fw_reset->reset_flags)) | |
| 353 | + return; | |
| 354 | + | |
| 352 | 355 | mlx5_sync_reset_clear_reset_requested(dev, true); |
| 353 | 356 | mlx5_core_warn(dev, "PCI Sync FW Update Reset Aborted.\n"); |
| 354 | 357 | } |
| @@ -107,7 +107,7 @@ bool mlx5_chains_prios_supported(struct mlx5_fs_chains *chains) · 106 unmodified lines | ||
| 107 | 107 | return chains->flags & MLX5_CHAINS_AND_PRIOS_SUPPORTED; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | −static bool mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains) | |
| 110 | +bool mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains) | |
| 111 | 111 | { |
| 112 | 112 | return chains->flags & MLX5_CHAINS_IGNORE_FLOW_LEVEL_SUPPORTED; |
| 113 | 113 | } |
| @@ -28,6 +28,7 @@ struct mlx5_chains_attr { · 27 unmodified lines | ||
| 28 | 28 | |
| 29 | 29 | bool |
| 30 | 30 | mlx5_chains_prios_supported(struct mlx5_fs_chains *chains); |
| 31 | +bool mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains); | |
| 31 | 32 | bool |
| 32 | 33 | mlx5_chains_backwards_supported(struct mlx5_fs_chains *chains); |
| 33 | 34 | u32 |
| @@ -70,6 +71,10 @@ mlx5_chains_set_end_ft(struct mlx5_fs_chains *chains, · 36 unmodified lines | ||
| 70 | 71 | |
| 71 | 72 | #else /* CONFIG_MLX5_CLS_ACT */ |
| 72 | 73 | |
| 74 | +static inline bool | |
| 75 | +mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains) | |
| 76 | +{ return false; } | |
| 77 | + | |
| 73 | 78 | static inline struct mlx5_flow_table * |
| 74 | 79 | mlx5_chains_get_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio, |
| 75 | 80 | u32 level) { return ERR_PTR(-EOPNOTSUPP); } |
| @@ -112,7 +112,8 @@ int mlx5dr_fw_create_md_tbl(struct mlx5dr_domain *dmn, · 111 unmodified lines | ||
| 112 | 112 | int ret; |
| 113 | 113 | |
| 114 | 114 | ft_attr.table_type = MLX5_FLOW_TABLE_TYPE_FDB; |
| 115 | − ft_attr.level = dmn->info.caps.max_ft_level - 2; | |
| 115 | + ft_attr.level = min_t(int, dmn->info.caps.max_ft_level - 2, | |
| 116 | + MLX5_FT_MAX_MULTIPATH_LEVEL); | |
| 116 | 117 | ft_attr.reformat_en = reformat_req; |
| 117 | 118 | ft_attr.decap_en = reformat_req; |
| 118 | 119 | |
| @@ -3815,6 +3815,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 3814 unmodified lines | ||
| 3815 | 3815 | dev_err(&pdev->dev, |
| 3816 | 3816 | "invalid sram_size %dB or board span %ldB\n", |
| 3817 | 3817 | mgp->sram_size, mgp->board_span); |
| 3818 | + status = -EINVAL; | |
| 3818 | 3819 | goto abort_with_ioremap; |
| 3819 | 3820 | } |
| 3820 | 3821 | memcpy_fromio(mgp->eeprom_strings, |
| @@ -1240,8 +1240,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) · 1239 unmodified lines | ||
| 1240 | 1240 | priv->phylink_config.dev = &priv->dev->dev; |
| 1241 | 1241 | priv->phylink_config.type = PHYLINK_NETDEV; |
| 1242 | 1242 | priv->phylink_config.pcs_poll = true; |
| 1243 | − priv->phylink_config.ovr_an_inband = | |
| 1244 | − priv->plat->mdio_bus_data->xpcs_an_inband; | |
| 1243 | + if (priv->plat->mdio_bus_data) | |
| 1244 | + priv->phylink_config.ovr_an_inband = | |
| 1245 | + priv->plat->mdio_bus_data->xpcs_an_inband; | |
| 1245 | 1246 | |
| 1246 | 1247 | if (!fwnode) |
| 1247 | 1248 | fwnode = dev_fwnode(priv->device); |
| @@ -7048,7 +7049,6 @@ error_mdio_register: · 5800 unmodified lines | ||
| 7048 | 7049 | stmmac_napi_del(ndev); |
| 7049 | 7050 | error_hw_init: |
| 7050 | 7051 | destroy_workqueue(priv->wq); |
| 7051 | − stmmac_bus_clks_config(priv, false); | |
| 7052 | 7052 | bitmap_free(priv->af_xdp_zc_qps); |
| 7053 | 7053 | |
| 7054 | 7054 | return ret; |
| @@ -8,8 +8,8 @@ · 7 unmodified lines | ||
| 8 | 8 | |
| 9 | 9 | #include <linux/spi/spi.h> |
| 10 | 10 | #include <linux/interrupt.h> |
| 11 | +#include <linux/mod_devicetable.h> | |
| 11 | 12 | #include <linux/module.h> |
| 12 | −#include <linux/of.h> | |
| 13 | 13 | #include <linux/regmap.h> |
| 14 | 14 | #include <linux/ieee802154.h> |
| 15 | 15 | #include <linux/irq.h> |
| @@ -1388,7 +1388,7 @@ MODULE_DEVICE_TABLE(spi, mrf24j40_ids); · 1372 unmodified lines | ||
| 1388 | 1388 | |
| 1389 | 1389 | static struct spi_driver mrf24j40_driver = { |
| 1390 | 1390 | .driver = { |
| 1391 | − .of_match_table = of_match_ptr(mrf24j40_of_match), | |
| 1391 | + .of_match_table = mrf24j40_of_match, | |
| 1392 | 1392 | .name = "mrf24j40", |
| 1393 | 1393 | }, |
| 1394 | 1394 | .id_table = mrf24j40_ids, |
| @@ -401,18 +401,13 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi, · 400 unmodified lines | ||
| 401 | 401 | /* If headroom is not 0, there is an offset between the beginning of the |
| 402 | 402 | * data and the allocated space, otherwise the data and the allocated |
| 403 | 403 | * space are aligned. |
| 404 | + * | |
| 405 | + * Buffers with headroom use PAGE_SIZE as alloc size, see | |
| 406 | + * add_recvbuf_mergeable() + get_mergeable_buf_len() | |
| 404 | 407 | */ |
| 405 | − if (headroom) { | |
| 406 | − /* Buffers with headroom use PAGE_SIZE as alloc size, | |
| 407 | − * see add_recvbuf_mergeable() + get_mergeable_buf_len() | |
| 408 | − */ | |
| 409 | − truesize = PAGE_SIZE; | |
| 410 | − tailroom = truesize - len - offset; | |
| 411 | − buf = page_address(page); | |
| 412 | − } else { | |
| 413 | − tailroom = truesize - len; | |
| 414 | − buf = p; | |
| 415 | − } | |
| 408 | + truesize = headroom ? PAGE_SIZE : truesize; | |
| 409 | + tailroom = truesize - len - headroom - (hdr_padded_len - hdr_len); | |
| 410 | + buf = p - headroom; | |
| 416 | 411 | |
| 417 | 412 | len -= hdr_len; |
| 418 | 413 | offset += hdr_padded_len; |
| @@ -958,7 +953,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, · 539 unmodified lines | ||
| 958 | 953 | put_page(page); |
| 959 | 954 | head_skb = page_to_skb(vi, rq, xdp_page, offset, |
| 960 | 955 | len, PAGE_SIZE, false, |
| 961 | − metasize, headroom); | |
| 956 | + metasize, | |
| 957 | + VIRTIO_XDP_HEADROOM); | |
| 962 | 958 | return head_skb; |
| 963 | 959 | } |
| 964 | 960 | break; |
| @@ -1,5 +1,4 @@ | ||
| 1 | −ccflags-y := -O3 | |
| 2 | −ccflags-y += -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt' | |
| 1 | +ccflags-y := -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt' | |
| 3 | 2 | ccflags-$(CONFIG_WIREGUARD_DEBUG) += -DDEBUG |
| 4 | 3 | wireguard-y := main.o |
| 5 | 4 | wireguard-y += noise.o |
| @@ -6,6 +6,8 @@ · 5 unmodified lines | ||
| 6 | 6 | #include "allowedips.h" |
| 7 | 7 | #include "peer.h" |
| 8 | 8 | |
| 9 | +static struct kmem_cache *node_cache; | |
| 10 | + | |
| 9 | 11 | static void swap_endian(u8 *dst, const u8 *src, u8 bits) |
| 10 | 12 | { |
| 11 | 13 | if (bits == 32) { |
| @@ -28,8 +30,11 @@ static void copy_and_assign_cidr(struct allowedips_node *node, const u8 *src, · 16 unmodified lines | ||
| 28 | 30 | node->bitlen = bits; |
| 29 | 31 | memcpy(node->bits, src, bits / 8U); |
| 30 | 32 | } |
| 31 | −#define CHOOSE_NODE(parent, key) \ | |
| 32 | − parent->bit[(key[parent->bit_at_a] >> parent->bit_at_b) & 1] | |
| 33 | + | |
| 34 | +static inline u8 choose(struct allowedips_node *node, const u8 *key) | |
| 35 | +{ | |
| 36 | + return (key[node->bit_at_a] >> node->bit_at_b) & 1; | |
| 37 | +} | |
| 33 | 38 | |
| 34 | 39 | static void push_rcu(struct allowedips_node **stack, |
| 35 | 40 | struct allowedips_node __rcu *p, unsigned int *len) |
| @@ -40,6 +45,11 @@ static void push_rcu(struct allowedips_node **stack, · 4 unmodified lines | ||
| 40 | 45 | } |
| 41 | 46 | } |
| 42 | 47 | |
| 48 | +static void node_free_rcu(struct rcu_head *rcu) | |
| 49 | +{ | |
| 50 | + kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu)); | |
| 51 | +} | |
| 52 | + | |
| 43 | 53 | static void root_free_rcu(struct rcu_head *rcu) |
| 44 | 54 | { |
| 45 | 55 | struct allowedips_node *node, *stack[128] = { |
| @@ -49,7 +59,7 @@ static void root_free_rcu(struct rcu_head *rcu) · 3 unmodified lines | ||
| 49 | 59 | while (len > 0 && (node = stack[--len])) { |
| 50 | 60 | push_rcu(stack, node->bit[0], &len); |
| 51 | 61 | push_rcu(stack, node->bit[1], &len); |
| 52 | − kfree(node); | |
| 62 | + kmem_cache_free(node_cache, node); | |
| 53 | 63 | } |
| 54 | 64 | } |
| 55 | 65 | |
| @@ -66,60 +76,6 @@ static void root_remove_peer_lists(struct allowedips_node *root) · 10 unmodified lines | ||
| 66 | 76 | } |
| 67 | 77 | } |
| 68 | 78 | |
| 69 | −static void walk_remove_by_peer(struct allowedips_node __rcu **top, | |
| 70 | − struct wg_peer *peer, struct mutex *lock) | |
| 71 | −{ | |
| 72 | −#define REF(p) rcu_access_pointer(p) | |
| 73 | −#define DEREF(p) rcu_dereference_protected(*(p), lockdep_is_held(lock)) | |
| 74 | −#define PUSH(p) ({ \ | |
| 75 | − WARN_ON(IS_ENABLED(DEBUG) && len >= 128); \ | |
| 76 | − stack[len++] = p; \ | |
| 77 | − }) | |
| 78 | − | |
| 79 | − struct allowedips_node __rcu **stack[128], **nptr; | |
| 80 | − struct allowedips_node *node, *prev; | |
| 81 | − unsigned int len; | |
| 82 | − | |
| 83 | − if (unlikely(!peer || !REF(*top))) | |
| 84 | − return; | |
| 85 | − | |
| 86 | − for (prev = NULL, len = 0, PUSH(top); len > 0; prev = node) { | |
| 87 | − nptr = stack[len - 1]; | |
| 88 | − node = DEREF(nptr); | |
| 89 | − if (!node) { | |
| 90 | − --len; | |
| 91 | − continue; | |
| 92 | − } | |
| 93 | − if (!prev || REF(prev->bit[0]) == node || | |
| 94 | − REF(prev->bit[1]) == node) { | |
| 95 | − if (REF(node->bit[0])) | |
| 96 | − PUSH(&node->bit[0]); | |
| 97 | − else if (REF(node->bit[1])) | |
| 98 | − PUSH(&node->bit[1]); | |
| 99 | − } else if (REF(node->bit[0]) == prev) { | |
| 100 | − if (REF(node->bit[1])) | |
| 101 | − PUSH(&node->bit[1]); | |
| 102 | − } else { | |
| 103 | − if (rcu_dereference_protected(node->peer, | |
| 104 | − lockdep_is_held(lock)) == peer) { | |
| 105 | − RCU_INIT_POINTER(node->peer, NULL); | |
| 106 | − list_del_init(&node->peer_list); | |
| 107 | − if (!node->bit[0] || !node->bit[1]) { | |
| 108 | − rcu_assign_pointer(*nptr, DEREF( | |
| 109 | − &node->bit[!REF(node->bit[0])])); | |
| 110 | − kfree_rcu(node, rcu); | |
| 111 | − node = DEREF(nptr); | |
| 112 | − } | |
| 113 | − } | |
| 114 | − --len; | |
| 115 | − } | |
| 116 | − } | |
| 117 | − | |
| 118 | −#undef REF | |
| 119 | −#undef DEREF | |
| 120 | −#undef PUSH | |
| 121 | −} | |
| 122 | − | |
| 123 | 79 | static unsigned int fls128(u64 a, u64 b) |
| 124 | 80 | { |
| 125 | 81 | return a ? fls64(a) + 64U : fls64(b); |
| @@ -159,7 +115,7 @@ static struct allowedips_node *find_node(struct allowedips_node *trie, u8 bits, · 33 unmodified lines | ||
| 159 | 115 | found = node; |
| 160 | 116 | if (node->cidr == bits) |
| 161 | 117 | break; |
| 162 | − node = rcu_dereference_bh(CHOOSE_NODE(node, key)); | |
| 118 | + node = rcu_dereference_bh(node->bit[choose(node, key)]); | |
| 163 | 119 | } |
| 164 | 120 | return found; |
| 165 | 121 | } |
| @@ -191,8 +147,7 @@ static bool node_placement(struct allowedips_node __rcu *trie, const u8 *key, · 25 unmodified lines | ||
| 191 | 147 | u8 cidr, u8 bits, struct allowedips_node **rnode, |
| 192 | 148 | struct mutex *lock) |
| 193 | 149 | { |
| 194 | − struct allowedips_node *node = rcu_dereference_protected(trie, | |
| 195 | − lockdep_is_held(lock)); | |
| 150 | + struct allowedips_node *node = rcu_dereference_protected(trie, lockdep_is_held(lock)); | |
| 196 | 151 | struct allowedips_node *parent = NULL; |
| 197 | 152 | bool exact = false; |
| 198 | 153 | |
| @@ -202,13 +157,24 @@ static bool node_placement(struct allowedips_node __rcu *trie, const u8 *key, · 3 unmodified lines | ||
| 202 | 157 | exact = true; |
| 203 | 158 | break; |
| 204 | 159 | } |
| 205 | − node = rcu_dereference_protected(CHOOSE_NODE(parent, key), | |
| 206 | − lockdep_is_held(lock)); | |
| 160 | + node = rcu_dereference_protected(parent->bit[choose(parent, key)], lockdep_is_held(lock)); | |
| 207 | 161 | } |
| 208 | 162 | *rnode = parent; |
| 209 | 163 | return exact; |
| 210 | 164 | } |
| 211 | 165 | |
| 166 | +static inline void connect_node(struct allowedips_node **parent, u8 bit, struct allowedips_node *node) | |
| 167 | +{ | |
| 168 | + node->parent_bit_packed = (unsigned long)parent | bit; | |
| 169 | + rcu_assign_pointer(*parent, node); | |
| 170 | +} | |
| 171 | + | |
| 172 | +static inline void choose_and_connect_node(struct allowedips_node *parent, struct allowedips_node *node) | |
| 173 | +{ | |
| 174 | + u8 bit = choose(parent, node->bits); | |
| 175 | + connect_node(&parent->bit[bit], bit, node); | |
| 176 | +} | |
| 177 | + | |
| 212 | 178 | static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, |
| 213 | 179 | u8 cidr, struct wg_peer *peer, struct mutex *lock) |
| 214 | 180 | { |
| @@ -218,13 +184,13 @@ static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, · 3 unmodified lines | ||
| 218 | 184 | return -EINVAL; |
| 219 | 185 | |
| 220 | 186 | if (!rcu_access_pointer(*trie)) { |
| 221 | − node = kzalloc(sizeof(*node), GFP_KERNEL); | |
| 187 | + node = kmem_cache_zalloc(node_cache, GFP_KERNEL); | |
| 222 | 188 | if (unlikely(!node)) |
| 223 | 189 | return -ENOMEM; |
| 224 | 190 | RCU_INIT_POINTER(node->peer, peer); |
| 225 | 191 | list_add_tail(&node->peer_list, &peer->allowedips_list); |
| 226 | 192 | copy_and_assign_cidr(node, key, cidr, bits); |
| 227 | − rcu_assign_pointer(*trie, node); | |
| 193 | + connect_node(trie, 2, node); | |
| 228 | 194 | return 0; |
| 229 | 195 | } |
| 230 | 196 | if (node_placement(*trie, key, cidr, bits, &node, lock)) { |
| @@ -233,7 +199,7 @@ static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, · 2 unmodified lines | ||
| 233 | 199 | return 0; |
| 234 | 200 | } |
| 235 | 201 | |
| 236 | − newnode = kzalloc(sizeof(*newnode), GFP_KERNEL); | |
| 202 | + newnode = kmem_cache_zalloc(node_cache, GFP_KERNEL); | |
| 237 | 203 | if (unlikely(!newnode)) |
| 238 | 204 | return -ENOMEM; |
| 239 | 205 | RCU_INIT_POINTER(newnode->peer, peer); |
| @@ -243,10 +209,10 @@ static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, · 3 unmodified lines | ||
| 243 | 209 | if (!node) { |
| 244 | 210 | down = rcu_dereference_protected(*trie, lockdep_is_held(lock)); |
| 245 | 211 | } else { |
| 246 | − down = rcu_dereference_protected(CHOOSE_NODE(node, key), | |
| 247 | − lockdep_is_held(lock)); | |
| 212 | + const u8 bit = choose(node, key); | |
| 213 | + down = rcu_dereference_protected(node->bit[bit], lockdep_is_held(lock)); | |
| 248 | 214 | if (!down) { |
| 249 | − rcu_assign_pointer(CHOOSE_NODE(node, key), newnode); | |
| 215 | + connect_node(&node->bit[bit], bit, newnode); | |
| 250 | 216 | return 0; |
| 251 | 217 | } |
| 252 | 218 | } |
| @@ -254,30 +220,29 @@ static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, · 1 unmodified line | ||
| 254 | 220 | parent = node; |
| 255 | 221 | |
| 256 | 222 | if (newnode->cidr == cidr) { |
| 257 | − rcu_assign_pointer(CHOOSE_NODE(newnode, down->bits), down); | |
| 223 | + choose_and_connect_node(newnode, down); | |
| 258 | 224 | if (!parent) |
| 259 | − rcu_assign_pointer(*trie, newnode); | |
| 225 | + connect_node(trie, 2, newnode); | |
| 260 | 226 | else |
| 261 | − rcu_assign_pointer(CHOOSE_NODE(parent, newnode->bits), | |
| 262 | − newnode); | |
| 263 | − } else { | |
| 264 | − node = kzalloc(sizeof(*node), GFP_KERNEL); | |
| 265 | − if (unlikely(!node)) { | |
| 266 | − list_del(&newnode->peer_list); | |
| 267 | − kfree(newnode); | |
| 268 | − return -ENOMEM; | |
| 269 | − } | |
| 270 | − INIT_LIST_HEAD(&node->peer_list); | |
| 271 | − copy_and_assign_cidr(node, newnode->bits, cidr, bits); | |
| 227 | + choose_and_connect_node(parent, newnode); | |
| 228 | + return 0; | |
| 229 | + } | |
| 272 | 230 | |
| 273 | − rcu_assign_pointer(CHOOSE_NODE(node, down->bits), down); | |
| 274 | − rcu_assign_pointer(CHOOSE_NODE(node, newnode->bits), newnode); | |
| 275 | − if (!parent) | |
| 276 | − rcu_assign_pointer(*trie, node); | |
| 277 | − else | |
| 278 | − rcu_assign_pointer(CHOOSE_NODE(parent, node->bits), | |
| 279 | − node); | |
| 231 | + node = kmem_cache_zalloc(node_cache, GFP_KERNEL); | |
| 232 | + if (unlikely(!node)) { | |
| 233 | + list_del(&newnode->peer_list); | |
| 234 | + kmem_cache_free(node_cache, newnode); | |
| 235 | + return -ENOMEM; | |
| 280 | 236 | } |
| 237 | + INIT_LIST_HEAD(&node->peer_list); | |
| 238 | + copy_and_assign_cidr(node, newnode->bits, cidr, bits); | |
| 239 | + | |
| 240 | + choose_and_connect_node(node, down); | |
| 241 | + choose_and_connect_node(node, newnode); | |
| 242 | + if (!parent) | |
| 243 | + connect_node(trie, 2, node); | |
| 244 | + else | |
| 245 | + choose_and_connect_node(parent, node); | |
| 281 | 246 | return 0; |
| 282 | 247 | } |
| 283 | 248 | |
| @@ -335,9 +300,41 @@ int wg_allowedips_insert_v6(struct allowedips *table, const struct in6_addr *ip, · 51 unmodified lines | ||
| 335 | 300 | void wg_allowedips_remove_by_peer(struct allowedips *table, |
| 336 | 301 | struct wg_peer *peer, struct mutex *lock) |
| 337 | 302 | { |
| 303 | + struct allowedips_node *node, *child, **parent_bit, *parent, *tmp; | |
| 304 | + bool free_parent; | |
| 305 | + | |
| 306 | + if (list_empty(&peer->allowedips_list)) | |
| 307 | + return; | |
| 338 | 308 | ++table->seq; |
| 339 | − walk_remove_by_peer(&table->root4, peer, lock); | |
| 340 | − walk_remove_by_peer(&table->root6, peer, lock); | |
| 309 | + list_for_each_entry_safe(node, tmp, &peer->allowedips_list, peer_list) { | |
| 310 | + list_del_init(&node->peer_list); | |
| 311 | + RCU_INIT_POINTER(node->peer, NULL); | |
| 312 | + if (node->bit[0] && node->bit[1]) | |
| 313 | + continue; | |
| 314 | + child = rcu_dereference_protected(node->bit[!rcu_access_pointer(node->bit[0])], | |
| 315 | + lockdep_is_held(lock)); | |
| 316 | + if (child) | |
| 317 | + child->parent_bit_packed = node->parent_bit_packed; | |
| 318 | + parent_bit = (struct allowedips_node **)(node->parent_bit_packed & ~3UL); | |
| 319 | + *parent_bit = child; | |
| 320 | + parent = (void *)parent_bit - | |
| 321 | + offsetof(struct allowedips_node, bit[node->parent_bit_packed & 1]); | |
| 322 | + free_parent = !rcu_access_pointer(node->bit[0]) && | |
| 323 | + !rcu_access_pointer(node->bit[1]) && | |
| 324 | + (node->parent_bit_packed & 3) <= 1 && | |
| 325 | + !rcu_access_pointer(parent->peer); | |
| 326 | + if (free_parent) | |
| 327 | + child = rcu_dereference_protected( | |
| 328 | + parent->bit[!(node->parent_bit_packed & 1)], | |
| 329 | + lockdep_is_held(lock)); | |
| 330 | + call_rcu(&node->rcu, node_free_rcu); | |
| 331 | + if (!free_parent) | |
| 332 | + continue; | |
| 333 | + if (child) | |
| 334 | + child->parent_bit_packed = parent->parent_bit_packed; | |
| 335 | + *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child; | |
| 336 | + call_rcu(&parent->rcu, node_free_rcu); | |
| 337 | + } | |
| 341 | 338 | } |
| 342 | 339 | |
| 343 | 340 | int wg_allowedips_read_node(struct allowedips_node *node, u8 ip[16], u8 *cidr) |
| @@ -374,4 +371,16 @@ struct wg_peer *wg_allowedips_lookup_src(struct allowedips *table, · 30 unmodified lines | ||
| 374 | 371 | return NULL; |
| 375 | 372 | } |
| 376 | 373 | |
| 374 | +int __init wg_allowedips_slab_init(void) | |
| 375 | +{ | |
| 376 | + node_cache = KMEM_CACHE(allowedips_node, 0); | |
| 377 | + return node_cache ? 0 : -ENOMEM; | |
| 378 | +} | |
| 379 | + | |
| 380 | +void wg_allowedips_slab_uninit(void) | |
| 381 | +{ | |
| 382 | + rcu_barrier(); | |
| 383 | + kmem_cache_destroy(node_cache); | |
| 384 | +} | |
| 385 | + | |
| 377 | 386 | #include "selftest/allowedips.c" |
| @@ -15,14 +15,11 @@ struct wg_peer; · 14 unmodified lines | ||
| 15 | 15 | struct allowedips_node { |
| 16 | 16 | struct wg_peer __rcu *peer; |
| 17 | 17 | struct allowedips_node __rcu *bit[2]; |
| 18 | − /* While it may seem scandalous that we waste space for v4, | |
| 19 | − * we're alloc'ing to the nearest power of 2 anyway, so this | |
| 20 | − * doesn't actually make a difference. | |
| 21 | − */ | |
| 22 | − u8 bits[16] __aligned(__alignof(u64)); | |
| 23 | 18 | u8 cidr, bit_at_a, bit_at_b, bitlen; |
| 19 | + u8 bits[16] __aligned(__alignof(u64)); | |
| 24 | 20 | |
| 25 | − /* Keep rarely used list at bottom to be beyond cache line. */ | |
| 21 | + /* Keep rarely used members at bottom to be beyond cache line. */ | |
| 22 | + unsigned long parent_bit_packed; | |
| 26 | 23 | union { |
| 27 | 24 | struct list_head peer_list; |
| 28 | 25 | struct rcu_head rcu; |
| @@ -33,7 +30,7 @@ struct allowedips { · 4 unmodified lines | ||
| 33 | 30 | struct allowedips_node __rcu *root4; |
| 34 | 31 | struct allowedips_node __rcu *root6; |
| 35 | 32 | u64 seq; |
| 36 | −}; | |
| 33 | +} __aligned(4); /* We pack the lower 2 bits of &root, but m68k only gives 16-bit alignment. */ | |
| 37 | 34 | |
| 38 | 35 | void wg_allowedips_init(struct allowedips *table); |
| 39 | 36 | void wg_allowedips_free(struct allowedips *table, struct mutex *mutex); |
| @@ -56,4 +53,7 @@ struct wg_peer *wg_allowedips_lookup_src(struct allowedips *table, · 16 unmodified lines | ||
| 56 | 53 | bool wg_allowedips_selftest(void); |
| 57 | 54 | #endif |
| 58 | 55 | |
| 56 | +int wg_allowedips_slab_init(void); | |
| 57 | +void wg_allowedips_slab_uninit(void); | |
| 58 | + | |
| 59 | 59 | #endif /* _WG_ALLOWEDIPS_H */ |
| @@ -21,13 +21,22 @@ static int __init mod_init(void) · 20 unmodified lines | ||
| 21 | 21 | { |
| 22 | 22 | int ret; |
| 23 | 23 | |
| 24 | + ret = wg_allowedips_slab_init(); | |
| 25 | + if (ret < 0) | |
| 26 | + goto err_allowedips; | |
| 27 | + | |
| 24 | 28 | #ifdef DEBUG |
| 29 | + ret = -ENOTRECOVERABLE; | |
| 25 | 30 | if (!wg_allowedips_selftest() || !wg_packet_counter_selftest() || |
| 26 | 31 | !wg_ratelimiter_selftest()) |
| 27 | − return -ENOTRECOVERABLE; | |
| 32 | + goto err_peer; | |
| 28 | 33 | #endif |
| 29 | 34 | wg_noise_init(); |
| 30 | 35 | |
| 36 | + ret = wg_peer_init(); | |
| 37 | + if (ret < 0) | |
| 38 | + goto err_peer; | |
| 39 | + | |
| 31 | 40 | ret = wg_device_init(); |
| 32 | 41 | if (ret < 0) |
| 33 | 42 | goto err_device; |
| @@ -44,6 +53,10 @@ static int __init mod_init(void) · 10 unmodified lines | ||
| 44 | 53 | err_netlink: |
| 45 | 54 | wg_device_uninit(); |
| 46 | 55 | err_device: |
| 56 | + wg_peer_uninit(); | |
| 57 | +err_peer: | |
| 58 | + wg_allowedips_slab_uninit(); | |
| 59 | +err_allowedips: | |
| 47 | 60 | return ret; |
| 48 | 61 | } |
| 49 | 62 | |
| @@ -51,6 +64,8 @@ static void __exit mod_exit(void) · 1 unmodified line | ||
| 51 | 64 | { |
| 52 | 65 | wg_genetlink_uninit(); |
| 53 | 66 | wg_device_uninit(); |
| 67 | + wg_peer_uninit(); | |
| 68 | + wg_allowedips_slab_uninit(); | |
| 54 | 69 | } |
| 55 | 70 | |
| 56 | 71 | module_init(mod_init); |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <linux/rcupdate.h> |
| 16 | 16 | #include <linux/list.h> |
| 17 | 17 | |
| 18 | +static struct kmem_cache *peer_cache; | |
| 18 | 19 | static atomic64_t peer_counter = ATOMIC64_INIT(0); |
| 19 | 20 | |
| 20 | 21 | struct wg_peer *wg_peer_create(struct wg_device *wg, |
| @@ -29,10 +30,10 @@ struct wg_peer *wg_peer_create(struct wg_device *wg, · 8 unmodified lines | ||
| 29 | 30 | if (wg->num_peers >= MAX_PEERS_PER_DEVICE) |
| 30 | 31 | return ERR_PTR(ret); |
| 31 | 32 | |
| 32 | − peer = kzalloc(sizeof(*peer), GFP_KERNEL); | |
| 33 | + peer = kmem_cache_zalloc(peer_cache, GFP_KERNEL); | |
| 33 | 34 | if (unlikely(!peer)) |
| 34 | 35 | return ERR_PTR(ret); |
| 35 | − if (dst_cache_init(&peer->endpoint_cache, GFP_KERNEL)) | |
| 36 | + if (unlikely(dst_cache_init(&peer->endpoint_cache, GFP_KERNEL))) | |
| 36 | 37 | goto err; |
| 37 | 38 | |
| 38 | 39 | peer->device = wg; |
| @@ -64,7 +65,7 @@ struct wg_peer *wg_peer_create(struct wg_device *wg, · 25 unmodified lines | ||
| 64 | 65 | return peer; |
| 65 | 66 | |
| 66 | 67 | err: |
| 67 | − kfree(peer); | |
| 68 | + kmem_cache_free(peer_cache, peer); | |
| 68 | 69 | return ERR_PTR(ret); |
| 69 | 70 | } |
| 70 | 71 | |
| @@ -88,7 +89,7 @@ static void peer_make_dead(struct wg_peer *peer) · 17 unmodified lines | ||
| 88 | 89 | /* Mark as dead, so that we don't allow jumping contexts after. */ |
| 89 | 90 | WRITE_ONCE(peer->is_dead, true); |
| 90 | 91 | |
| 91 | − /* The caller must now synchronize_rcu() for this to take effect. */ | |
| 92 | + /* The caller must now synchronize_net() for this to take effect. */ | |
| 92 | 93 | } |
| 93 | 94 | |
| 94 | 95 | static void peer_remove_after_dead(struct wg_peer *peer) |
| @@ -160,7 +161,7 @@ void wg_peer_remove(struct wg_peer *peer) · 65 unmodified lines | ||
| 160 | 161 | lockdep_assert_held(&peer->device->device_update_lock); |
| 161 | 162 | |
| 162 | 163 | peer_make_dead(peer); |
| 163 | − synchronize_rcu(); | |
| 164 | + synchronize_net(); | |
| 164 | 165 | peer_remove_after_dead(peer); |
| 165 | 166 | } |
| 166 | 167 | |
| @@ -178,7 +179,7 @@ void wg_peer_remove_all(struct wg_device *wg) · 11 unmodified lines | ||
| 178 | 179 | peer_make_dead(peer); |
| 179 | 180 | list_add_tail(&peer->peer_list, &dead_peers); |
| 180 | 181 | } |
| 181 | − synchronize_rcu(); | |
| 182 | + synchronize_net(); | |
| 182 | 183 | list_for_each_entry_safe(peer, temp, &dead_peers, peer_list) |
| 183 | 184 | peer_remove_after_dead(peer); |
| 184 | 185 | } |
| @@ -193,7 +194,8 @@ static void rcu_release(struct rcu_head *rcu) · 8 unmodified lines | ||
| 193 | 194 | /* The final zeroing takes care of clearing any remaining handshake key |
| 194 | 195 | * material and other potentially sensitive information. |
| 195 | 196 | */ |
| 196 | − kfree_sensitive(peer); | |
| 197 | + memzero_explicit(peer, sizeof(*peer)); | |
| 198 | + kmem_cache_free(peer_cache, peer); | |
| 197 | 199 | } |
| 198 | 200 | |
| 199 | 201 | static void kref_release(struct kref *refcount) |
| @@ -225,3 +227,14 @@ void wg_peer_put(struct wg_peer *peer) · 25 unmodified lines | ||
| 225 | 227 | return; |
| 226 | 228 | kref_put(&peer->refcount, kref_release); |
| 227 | 229 | } |
| 230 | + | |
| 231 | +int __init wg_peer_init(void) | |
| 232 | +{ | |
| 233 | + peer_cache = KMEM_CACHE(wg_peer, 0); | |
| 234 | + return peer_cache ? 0 : -ENOMEM; | |
| 235 | +} | |
| 236 | + | |
| 237 | +void wg_peer_uninit(void) | |
| 238 | +{ | |
| 239 | + kmem_cache_destroy(peer_cache); | |
| 240 | +} | |
| @@ -80,4 +80,7 @@ void wg_peer_put(struct wg_peer *peer); · 79 unmodified lines | ||
| 80 | 80 | void wg_peer_remove(struct wg_peer *peer); |
| 81 | 81 | void wg_peer_remove_all(struct wg_device *wg); |
| 82 | 82 | |
| 83 | +int wg_peer_init(void); | |
| 84 | +void wg_peer_uninit(void); | |
| 85 | + | |
| 83 | 86 | #endif /* _WG_PEER_H */ |
| @@ -19,32 +19,22 @@ · 18 unmodified lines | ||
| 19 | 19 | |
| 20 | 20 | #include <linux/siphash.h> |
| 21 | 21 | |
| 22 | −static __init void swap_endian_and_apply_cidr(u8 *dst, const u8 *src, u8 bits, | |
| 23 | − u8 cidr) | |
| 24 | −{ | |
| 25 | − swap_endian(dst, src, bits); | |
| 26 | − memset(dst + (cidr + 7) / 8, 0, bits / 8 - (cidr + 7) / 8); | |
| 27 | − if (cidr) | |
| 28 | − dst[(cidr + 7) / 8 - 1] &= ~0U << ((8 - (cidr % 8)) % 8); | |
| 29 | −} | |
| 30 | − | |
| 31 | 22 | static __init void print_node(struct allowedips_node *node, u8 bits) |
| 32 | 23 | { |
| 33 | 24 | char *fmt_connection = KERN_DEBUG "\t\"%p/%d\" -> \"%p/%d\";\n"; |
| 34 | − char *fmt_declaration = KERN_DEBUG | |
| 35 | − "\t\"%p/%d\"[style=%s, color=\"#%06x\"];\n"; | |
| 25 | + char *fmt_declaration = KERN_DEBUG "\t\"%p/%d\"[style=%s, color=\"#%06x\"];\n"; | |
| 26 | + u8 ip1[16], ip2[16], cidr1, cidr2; | |
| 36 | 27 | char *style = "dotted"; |
| 37 | − u8 ip1[16], ip2[16]; | |
| 38 | 28 | u32 color = 0; |
| 39 | 29 | |
| 30 | + if (node == NULL) | |
| 31 | + return; | |
| 40 | 32 | if (bits == 32) { |
| 41 | 33 | fmt_connection = KERN_DEBUG "\t\"%pI4/%d\" -> \"%pI4/%d\";\n"; |
| 42 | − fmt_declaration = KERN_DEBUG | |
| 43 | − "\t\"%pI4/%d\"[style=%s, color=\"#%06x\"];\n"; | |
| 34 | + fmt_declaration = KERN_DEBUG "\t\"%pI4/%d\"[style=%s, color=\"#%06x\"];\n"; | |
| 44 | 35 | } else if (bits == 128) { |
| 45 | 36 | fmt_connection = KERN_DEBUG "\t\"%pI6/%d\" -> \"%pI6/%d\";\n"; |
| 46 | − fmt_declaration = KERN_DEBUG | |
| 47 | − "\t\"%pI6/%d\"[style=%s, color=\"#%06x\"];\n"; | |
| 37 | + fmt_declaration = KERN_DEBUG "\t\"%pI6/%d\"[style=%s, color=\"#%06x\"];\n"; | |
| 48 | 38 | } |
| 49 | 39 | if (node->peer) { |
| 50 | 40 | hsiphash_key_t key = { { 0 } }; |
| @@ -55,24 +45,20 @@ static __init void print_node(struct allowedips_node *node, u8 bits) · 4 unmodified lines | ||
| 55 | 45 | hsiphash_1u32(0xabad1dea, &key) % 200; |
| 56 | 46 | style = "bold"; |
| 57 | 47 | } |
| 58 | − swap_endian_and_apply_cidr(ip1, node->bits, bits, node->cidr); | |
| 59 | − printk(fmt_declaration, ip1, node->cidr, style, color); | |
| 48 | + wg_allowedips_read_node(node, ip1, &cidr1); | |
| 49 | + printk(fmt_declaration, ip1, cidr1, style, color); | |
| 60 | 50 | if (node->bit[0]) { |
| 61 | − swap_endian_and_apply_cidr(ip2, | |
| 62 | − rcu_dereference_raw(node->bit[0])->bits, bits, | |
| 63 | − node->cidr); | |
| 64 | − printk(fmt_connection, ip1, node->cidr, ip2, | |
| 65 | − rcu_dereference_raw(node->bit[0])->cidr); | |
| 66 | − print_node(rcu_dereference_raw(node->bit[0]), bits); | |
| 51 | + wg_allowedips_read_node(rcu_dereference_raw(node->bit[0]), ip2, &cidr2); | |
| 52 | + printk(fmt_connection, ip1, cidr1, ip2, cidr2); | |
| 67 | 53 | } |
| 68 | 54 | if (node->bit[1]) { |
| 69 | − swap_endian_and_apply_cidr(ip2, | |
| 70 | − rcu_dereference_raw(node->bit[1])->bits, | |
| 71 | − bits, node->cidr); | |
| 72 | − printk(fmt_connection, ip1, node->cidr, ip2, | |
| 73 | − rcu_dereference_raw(node->bit[1])->cidr); | |
| 74 | − print_node(rcu_dereference_raw(node->bit[1]), bits); | |
| 55 | + wg_allowedips_read_node(rcu_dereference_raw(node->bit[1]), ip2, &cidr2); | |
| 56 | + printk(fmt_connection, ip1, cidr1, ip2, cidr2); | |
| 75 | 57 | } |
| 58 | + if (node->bit[0]) | |
| 59 | + print_node(rcu_dereference_raw(node->bit[0]), bits); | |
| 60 | + if (node->bit[1]) | |
| 61 | + print_node(rcu_dereference_raw(node->bit[1]), bits); | |
| 76 | 62 | } |
| 77 | 63 | |
| 78 | 64 | static __init void print_tree(struct allowedips_node __rcu *top, u8 bits) |
| @@ -121,8 +107,8 @@ static __init inline union nf_inet_addr horrible_cidr_to_mask(u8 cidr) · 42 unmodified lines | ||
| 121 | 107 | { |
| 122 | 108 | union nf_inet_addr mask; |
| 123 | 109 | |
| 124 | − memset(&mask, 0x00, 128 / 8); | |
| 125 | − memset(&mask, 0xff, cidr / 8); | |
| 110 | + memset(&mask, 0, sizeof(mask)); | |
| 111 | + memset(&mask.all, 0xff, cidr / 8); | |
| 126 | 112 | if (cidr % 32) |
| 127 | 113 | mask.all[cidr / 32] = (__force u32)htonl( |
| 128 | 114 | (0xFFFFFFFFUL << (32 - (cidr % 32))) & 0xFFFFFFFFUL); |
| @@ -149,42 +135,36 @@ horrible_mask_self(struct horrible_allowedips_node *node) · 20 unmodified lines | ||
| 149 | 135 | } |
| 150 | 136 | |
| 151 | 137 | static __init inline bool |
| 152 | −horrible_match_v4(const struct horrible_allowedips_node *node, | |
| 153 | − struct in_addr *ip) | |
| 138 | +horrible_match_v4(const struct horrible_allowedips_node *node, struct in_addr *ip) | |
| 154 | 139 | { |
| 155 | 140 | return (ip->s_addr & node->mask.ip) == node->ip.ip; |
| 156 | 141 | } |
| 157 | 142 | |
| 158 | 143 | static __init inline bool |
| 159 | −horrible_match_v6(const struct horrible_allowedips_node *node, | |
| 160 | − struct in6_addr *ip) | |
| 144 | +horrible_match_v6(const struct horrible_allowedips_node *node, struct in6_addr *ip) | |
| 161 | 145 | { |
| 162 | − return (ip->in6_u.u6_addr32[0] & node->mask.ip6[0]) == | |
| 163 | − node->ip.ip6[0] && | |
| 164 | − (ip->in6_u.u6_addr32[1] & node->mask.ip6[1]) == | |
| 165 | − node->ip.ip6[1] && | |
| 166 | − (ip->in6_u.u6_addr32[2] & node->mask.ip6[2]) == | |
| 167 | − node->ip.ip6[2] && | |
| 146 | + return (ip->in6_u.u6_addr32[0] & node->mask.ip6[0]) == node->ip.ip6[0] && | |
| 147 | + (ip->in6_u.u6_addr32[1] & node->mask.ip6[1]) == node->ip.ip6[1] && | |
| 148 | + (ip->in6_u.u6_addr32[2] & node->mask.ip6[2]) == node->ip.ip6[2] && | |
| 168 | 149 | (ip->in6_u.u6_addr32[3] & node->mask.ip6[3]) == node->ip.ip6[3]; |
| 169 | 150 | } |
| 170 | 151 | |
| 171 | 152 | static __init void |
| 172 | −horrible_insert_ordered(struct horrible_allowedips *table, | |
| 173 | − struct horrible_allowedips_node *node) | |
| 153 | +horrible_insert_ordered(struct horrible_allowedips *table, struct horrible_allowedips_node *node) | |
| 174 | 154 | { |
| 175 | 155 | struct horrible_allowedips_node *other = NULL, *where = NULL; |
| 176 | 156 | u8 my_cidr = horrible_mask_to_cidr(node->mask); |
| 177 | 157 | |
| 178 | 158 | hlist_for_each_entry(other, &table->head, table) { |
| 179 | − if (!memcmp(&other->mask, &node->mask, | |
| 180 | − sizeof(union nf_inet_addr)) && | |
| 181 | − !memcmp(&other->ip, &node->ip, | |
| 182 | − sizeof(union nf_inet_addr)) && | |
| 183 | − other->ip_version == node->ip_version) { | |
| 159 | + if (other->ip_version == node->ip_version && | |
| 160 | + !memcmp(&other->mask, &node->mask, sizeof(union nf_inet_addr)) && | |
| 161 | + !memcmp(&other->ip, &node->ip, sizeof(union nf_inet_addr))) { | |
| 184 | 162 | other->value = node->value; |
| 185 | 163 | kfree(node); |
| 186 | 164 | return; |
| 187 | 165 | } |
| 166 | + } | |
| 167 | + hlist_for_each_entry(other, &table->head, table) { | |
| 188 | 168 | where = other; |
| 189 | 169 | if (horrible_mask_to_cidr(other->mask) <= my_cidr) |
| 190 | 170 | break; |
| @@ -201,8 +181,7 @@ static __init int · 10 unmodified lines | ||
| 201 | 181 | horrible_allowedips_insert_v4(struct horrible_allowedips *table, |
| 202 | 182 | struct in_addr *ip, u8 cidr, void *value) |
| 203 | 183 | { |
| 204 | − struct horrible_allowedips_node *node = kzalloc(sizeof(*node), | |
| 205 | − GFP_KERNEL); | |
| 184 | + struct horrible_allowedips_node *node = kzalloc(sizeof(*node), GFP_KERNEL); | |
| 206 | 185 | |
| 207 | 186 | if (unlikely(!node)) |
| 208 | 187 | return -ENOMEM; |
| @@ -219,8 +198,7 @@ static __init int · 10 unmodified lines | ||
| 219 | 198 | horrible_allowedips_insert_v6(struct horrible_allowedips *table, |
| 220 | 199 | struct in6_addr *ip, u8 cidr, void *value) |
| 221 | 200 | { |
| 222 | − struct horrible_allowedips_node *node = kzalloc(sizeof(*node), | |
| 223 | − GFP_KERNEL); | |
| 201 | + struct horrible_allowedips_node *node = kzalloc(sizeof(*node), GFP_KERNEL); | |
| 224 | 202 | |
| 225 | 203 | if (unlikely(!node)) |
| 226 | 204 | return -ENOMEM; |
| @@ -234,39 +212,43 @@ horrible_allowedips_insert_v6(struct horrible_allowedips *table, · 7 unmodified lines | ||
| 234 | 212 | } |
| 235 | 213 | |
| 236 | 214 | static __init void * |
| 237 | −horrible_allowedips_lookup_v4(struct horrible_allowedips *table, | |
| 238 | − struct in_addr *ip) | |
| 215 | +horrible_allowedips_lookup_v4(struct horrible_allowedips *table, struct in_addr *ip) | |
| 239 | 216 | { |
| 240 | 217 | struct horrible_allowedips_node *node; |
| 241 | − void *ret = NULL; | |
| 242 | 218 | |
| 243 | 219 | hlist_for_each_entry(node, &table->head, table) { |
| 244 | − if (node->ip_version != 4) | |
| 245 | − continue; | |
| 246 | − if (horrible_match_v4(node, ip)) { | |
| 247 | − ret = node->value; | |
| 248 | − break; | |
| 249 | − } | |
| 220 | + if (node->ip_version == 4 && horrible_match_v4(node, ip)) | |
| 221 | + return node->value; | |
| 250 | 222 | } |
| 251 | − return ret; | |
| 223 | + return NULL; | |
| 252 | 224 | } |
| 253 | 225 | |
| 254 | 226 | static __init void * |
| 255 | −horrible_allowedips_lookup_v6(struct horrible_allowedips *table, | |
| 256 | − struct in6_addr *ip) | |
| 227 | +horrible_allowedips_lookup_v6(struct horrible_allowedips *table, struct in6_addr *ip) | |
| 257 | 228 | { |
| 258 | 229 | struct horrible_allowedips_node *node; |
| 259 | − void *ret = NULL; | |
| 260 | 230 | |
| 261 | 231 | hlist_for_each_entry(node, &table->head, table) { |
| 262 | − if (node->ip_version != 6) | |
| 232 | + if (node->ip_version == 6 && horrible_match_v6(node, ip)) | |
| 233 | + return node->value; | |
| 234 | + } | |
| 235 | + return NULL; | |
| 236 | +} | |
| 237 | + | |
| 238 | + | |
| 239 | +static __init void | |
| 240 | +horrible_allowedips_remove_by_value(struct horrible_allowedips *table, void *value) | |
| 241 | +{ | |
| 242 | + struct horrible_allowedips_node *node; | |
| 243 | + struct hlist_node *h; | |
| 244 | + | |
| 245 | + hlist_for_each_entry_safe(node, h, &table->head, table) { | |
| 246 | + if (node->value != value) | |
| 263 | 247 | continue; |
| 264 | − if (horrible_match_v6(node, ip)) { | |
| 265 | − ret = node->value; | |
| 266 | − break; | |
| 267 | − } | |
| 248 | + hlist_del(&node->table); | |
| 249 | + kfree(node); | |
| 268 | 250 | } |
| 269 | − return ret; | |
| 251 | + | |
| 270 | 252 | } |
| 271 | 253 | |
| 272 | 254 | static __init bool randomized_test(void) |
| @@ -296,6 +278,7 @@ static __init bool randomized_test(void) · 23 unmodified lines | ||
| 296 | 278 | goto free; |
| 297 | 279 | } |
| 298 | 280 | kref_init(&peers[i]->refcount); |
| 281 | + INIT_LIST_HEAD(&peers[i]->allowedips_list); | |
| 299 | 282 | } |
| 300 | 283 | |
| 301 | 284 | mutex_lock(&mutex); |
| @@ -333,7 +316,7 @@ static __init bool randomized_test(void) · 31 unmodified lines | ||
| 333 | 316 | if (wg_allowedips_insert_v4(&t, |
| 334 | 317 | (struct in_addr *)mutated, |
| 335 | 318 | cidr, peer, &mutex) < 0) { |
| 336 | − pr_err("allowedips random malloc: FAIL\n"); | |
| 319 | + pr_err("allowedips random self-test malloc: FAIL\n"); | |
| 337 | 320 | goto free_locked; |
| 338 | 321 | } |
| 339 | 322 | if (horrible_allowedips_insert_v4(&h, |
| @@ -396,23 +379,33 @@ static __init bool randomized_test(void) · 56 unmodified lines | ||
| 396 | 379 | print_tree(t.root6, 128); |
| 397 | 380 | } |
| 398 | 381 | |
| 399 | − for (i = 0; i < NUM_QUERIES; ++i) { | |
| 400 | − prandom_bytes(ip, 4); | |
| 401 | − if (lookup(t.root4, 32, ip) != | |
| 402 | − horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip)) { | |
| 403 | − pr_err("allowedips random self-test: FAIL\n"); | |
| 404 | − goto free; | |
| 382 | + for (j = 0;; ++j) { | |
| 383 | + for (i = 0; i < NUM_QUERIES; ++i) { | |
| 384 | + prandom_bytes(ip, 4); | |
| 385 | + if (lookup(t.root4, 32, ip) != horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip)) { | |
| 386 | + horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip); | |
| 387 | + pr_err("allowedips random v4 self-test: FAIL\n"); | |
| 388 | + goto free; | |
| 389 | + } | |
| 390 | + prandom_bytes(ip, 16); | |
| 391 | + if (lookup(t.root6, 128, ip) != horrible_allowedips_lookup_v6(&h, (struct in6_addr *)ip)) { | |
| 392 | + pr_err("allowedips random v6 self-test: FAIL\n"); | |
| 393 | + goto free; | |
| 394 | + } | |
| 405 | 395 | } |
| 396 | + if (j >= NUM_PEERS) | |
| 397 | + break; | |
| 398 | + mutex_lock(&mutex); | |
| 399 | + wg_allowedips_remove_by_peer(&t, peers[j], &mutex); | |
| 400 | + mutex_unlock(&mutex); | |
| 401 | + horrible_allowedips_remove_by_value(&h, peers[j]); | |
| 406 | 402 | } |
| 407 | 403 | |
| 408 | − for (i = 0; i < NUM_QUERIES; ++i) { | |
| 409 | − prandom_bytes(ip, 16); | |
| 410 | − if (lookup(t.root6, 128, ip) != | |
| 411 | − horrible_allowedips_lookup_v6(&h, (struct in6_addr *)ip)) { | |
| 412 | − pr_err("allowedips random self-test: FAIL\n"); | |
| 413 | − goto free; | |
| 414 | − } | |
| 404 | + if (t.root4 || t.root6) { | |
| 405 | + pr_err("allowedips random self-test removal: FAIL\n"); | |
| 406 | + goto free; | |
| 415 | 407 | } |
| 408 | + | |
| 416 | 409 | ret = true; |
| 417 | 410 | |
| 418 | 411 | free: |
| @@ -430,7 +430,7 @@ void wg_socket_reinit(struct wg_device *wg, struct sock *new4, · 429 unmodified lines | ||
| 430 | 430 | if (new4) |
| 431 | 431 | wg->incoming_port = ntohs(inet_sk(new4)->inet_sport); |
| 432 | 432 | mutex_unlock(&wg->socket_update_lock); |
| 433 | − synchronize_rcu(); | |
| 433 | + synchronize_net(); | |
| 434 | 434 | sock_free(old4); |
| 435 | 435 | sock_free(old6); |
| 436 | 436 | } |
| @@ -514,10 +514,36 @@ EXPORT_SYMBOL_GPL(mt76_free_device); · 513 unmodified lines | ||
| 514 | 514 | static void mt76_rx_release_amsdu(struct mt76_phy *phy, enum mt76_rxq_id q) |
| 515 | 515 | { |
| 516 | 516 | struct sk_buff *skb = phy->rx_amsdu[q].head; |
| 517 | + struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; | |
| 517 | 518 | struct mt76_dev *dev = phy->dev; |
| 518 | 519 | |
| 519 | 520 | phy->rx_amsdu[q].head = NULL; |
| 520 | 521 | phy->rx_amsdu[q].tail = NULL; |
| 522 | + | |
| 523 | + /* | |
| 524 | + * Validate if the amsdu has a proper first subframe. | |
| 525 | + * A single MSDU can be parsed as A-MSDU when the unauthenticated A-MSDU | |
| 526 | + * flag of the QoS header gets flipped. In such cases, the first | |
| 527 | + * subframe has a LLC/SNAP header in the location of the destination | |
| 528 | + * address. | |
| 529 | + */ | |
| 530 | + if (skb_shinfo(skb)->frag_list) { | |
| 531 | + int offset = 0; | |
| 532 | + | |
| 533 | + if (!(status->flag & RX_FLAG_8023)) { | |
| 534 | + offset = ieee80211_get_hdrlen_from_skb(skb); | |
| 535 | + | |
| 536 | + if ((status->flag & | |
| 537 | + (RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED)) == | |
| 538 | + RX_FLAG_DECRYPTED) | |
| 539 | + offset += 8; | |
| 540 | + } | |
| 541 | + | |
| 542 | + if (ether_addr_equal(skb->data + offset, rfc1042_header)) { | |
| 543 | + dev_kfree_skb(skb); | |
| 544 | + return; | |
| 545 | + } | |
| 546 | + } | |
| 521 | 547 | __skb_queue_tail(&dev->rx_skb[q], skb); |
| 522 | 548 | } |
| 523 | 549 | |
| @@ -510,7 +510,6 @@ void mt7615_init_device(struct mt7615_dev *dev) · 509 unmodified lines | ||
| 510 | 510 | mutex_init(&dev->pm.mutex); |
| 511 | 511 | init_waitqueue_head(&dev->pm.wait); |
| 512 | 512 | spin_lock_init(&dev->pm.txq_lock); |
| 513 | − set_bit(MT76_STATE_PM, &dev->mphy.state); | |
| 514 | 513 | INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work); |
| 515 | 514 | INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work); |
| 516 | 515 | INIT_DELAYED_WORK(&dev->coredump.work, mt7615_coredump_work); |
| @@ -1912,8 +1912,9 @@ void mt7615_pm_wake_work(struct work_struct *work) · 1911 unmodified lines | ||
| 1912 | 1912 | napi_schedule(&dev->mt76.napi[i]); |
| 1913 | 1913 | mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); |
| 1914 | 1914 | mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_WM], false); |
| 1915 | − ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, | |
| 1916 | − MT7615_WATCHDOG_TIME); | |
| 1915 | + if (test_bit(MT76_STATE_RUNNING, &mphy->state)) | |
| 1916 | + ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, | |
| 1917 | + MT7615_WATCHDOG_TIME); | |
| 1917 | 1918 | } |
| 1918 | 1919 | |
| 1919 | 1920 | ieee80211_wake_queues(mphy->hw); |
| @@ -51,16 +51,13 @@ mt7663s_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, · 50 unmodified lines | ||
| 51 | 51 | return ret; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | −static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) | |
| 54 | +static int __mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) | |
| 55 | 55 | { |
| 56 | 56 | struct sdio_func *func = dev->mt76.sdio.func; |
| 57 | 57 | struct mt76_phy *mphy = &dev->mt76.phy; |
| 58 | 58 | u32 status; |
| 59 | 59 | int ret; |
| 60 | 60 | |
| 61 | − if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state)) | |
| 62 | − goto out; | |
| 63 | − | |
| 64 | 61 | sdio_claim_host(func); |
| 65 | 62 | |
| 66 | 63 | sdio_writel(func, WHLPCR_FW_OWN_REQ_CLR, MCR_WHLPCR, NULL); |
| @@ -76,13 +73,21 @@ static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) · 9 unmodified lines | ||
| 76 | 73 | } |
| 77 | 74 | |
| 78 | 75 | sdio_release_host(func); |
| 79 | − | |
| 80 | −out: | |
| 81 | 76 | dev->pm.last_activity = jiffies; |
| 82 | 77 | |
| 83 | 78 | return 0; |
| 84 | 79 | } |
| 85 | 80 | |
| 81 | +static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev) | |
| 82 | +{ | |
| 83 | + struct mt76_phy *mphy = &dev->mt76.phy; | |
| 84 | + | |
| 85 | + if (test_and_clear_bit(MT76_STATE_PM, &mphy->state)) | |
| 86 | + return __mt7663s_mcu_drv_pmctrl(dev); | |
| 87 | + | |
| 88 | + return 0; | |
| 89 | +} | |
| 90 | + | |
| 86 | 91 | static int mt7663s_mcu_fw_pmctrl(struct mt7615_dev *dev) |
| 87 | 92 | { |
| 88 | 93 | struct sdio_func *func = dev->mt76.sdio.func; |
| @@ -123,7 +128,7 @@ int mt7663s_mcu_init(struct mt7615_dev *dev) · 34 unmodified lines | ||
| 123 | 128 | struct mt7615_mcu_ops *mcu_ops; |
| 124 | 129 | int ret; |
| 125 | 130 | |
| 126 | − ret = mt7663s_mcu_drv_pmctrl(dev); | |
| 131 | + ret = __mt7663s_mcu_drv_pmctrl(dev); | |
| 127 | 132 | if (ret) |
| 128 | 133 | return ret; |
| 129 | 134 | |
| @@ -55,10 +55,7 @@ int mt7663u_mcu_init(struct mt7615_dev *dev) · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | dev->mt76.mcu_ops = &mt7663u_mcu_ops, |
| 57 | 57 | |
| 58 | − /* usb does not support runtime-pm */ | |
| 59 | − clear_bit(MT76_STATE_PM, &dev->mphy.state); | |
| 60 | 58 | mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN); |
| 61 | − | |
| 62 | 59 | if (test_and_clear_bit(MT76_STATE_POWER_OFF, &dev->mphy.state)) { |
| 63 | 60 | mt7615_mcu_restart(&dev->mt76); |
| 64 | 61 | if (!mt76_poll_msec(dev, MT_CONN_ON_MISC, |
| @@ -721,6 +721,10 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb, · 720 unmodified lines | ||
| 721 | 721 | phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band, sta); |
| 722 | 722 | phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates); |
| 723 | 723 | phy->rcpi = rcpi; |
| 724 | + phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR, | |
| 725 | + sta->ht_cap.ampdu_factor) | | |
| 726 | + FIELD_PREP(IEEE80211_HT_AMPDU_PARM_DENSITY, | |
| 727 | + sta->ht_cap.ampdu_density); | |
| 724 | 728 | |
| 725 | 729 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra_info)); |
| 726 | 730 | ra_info = (struct sta_rec_ra_info *)tlv; |
| @@ -87,7 +87,7 @@ static const struct ieee80211_ops mt76x0e_ops = { · 86 unmodified lines | ||
| 87 | 87 | .reconfig_complete = mt76x02_reconfig_complete, |
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | −static int mt76x0e_register_device(struct mt76x02_dev *dev) | |
| 90 | +static int mt76x0e_init_hardware(struct mt76x02_dev *dev, bool resume) | |
| 91 | 91 | { |
| 92 | 92 | int err; |
| 93 | 93 | |
| @@ -100,9 +100,11 @@ static int mt76x0e_register_device(struct mt76x02_dev *dev) · 6 unmodified lines | ||
| 100 | 100 | if (err < 0) |
| 101 | 101 | return err; |
| 102 | 102 | |
| 103 | − err = mt76x02_dma_init(dev); | |
| 104 | − if (err < 0) | |
| 105 | − return err; | |
| 103 | + if (!resume) { | |
| 104 | + err = mt76x02_dma_init(dev); | |
| 105 | + if (err < 0) | |
| 106 | + return err; | |
| 107 | + } | |
| 106 | 108 | |
| 107 | 109 | err = mt76x0_init_hardware(dev); |
| 108 | 110 | if (err < 0) |
| @@ -123,6 +125,17 @@ static int mt76x0e_register_device(struct mt76x02_dev *dev) · 14 unmodified lines | ||
| 123 | 125 | mt76_clear(dev, 0x110, BIT(9)); |
| 124 | 126 | mt76_set(dev, MT_MAX_LEN_CFG, BIT(13)); |
| 125 | 127 | |
| 128 | + return 0; | |
| 129 | +} | |
| 130 | + | |
| 131 | +static int mt76x0e_register_device(struct mt76x02_dev *dev) | |
| 132 | +{ | |
| 133 | + int err; | |
| 134 | + | |
| 135 | + err = mt76x0e_init_hardware(dev, false); | |
| 136 | + if (err < 0) | |
| 137 | + return err; | |
| 138 | + | |
| 126 | 139 | err = mt76x0_register_device(dev); |
| 127 | 140 | if (err < 0) |
| 128 | 141 | return err; |
| @@ -167,6 +180,8 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 38 unmodified lines | ||
| 167 | 180 | if (ret) |
| 168 | 181 | return ret; |
| 169 | 182 | |
| 183 | + mt76_pci_disable_aspm(pdev); | |
| 184 | + | |
| 170 | 185 | mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt76x0e_ops, |
| 171 | 186 | &drv_ops); |
| 172 | 187 | if (!mdev) |
| @@ -220,6 +235,60 @@ mt76x0e_remove(struct pci_dev *pdev) · 47 unmodified lines | ||
| 220 | 235 | mt76_free_device(mdev); |
| 221 | 236 | } |
| 222 | 237 | |
| 238 | +#ifdef CONFIG_PM | |
| 239 | +static int mt76x0e_suspend(struct pci_dev *pdev, pm_message_t state) | |
| 240 | +{ | |
| 241 | + struct mt76_dev *mdev = pci_get_drvdata(pdev); | |
| 242 | + struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); | |
| 243 | + int i; | |
| 244 | + | |
| 245 | + mt76_worker_disable(&mdev->tx_worker); | |
| 246 | + for (i = 0; i < ARRAY_SIZE(mdev->phy.q_tx); i++) | |
| 247 | + mt76_queue_tx_cleanup(dev, mdev->phy.q_tx[i], true); | |
| 248 | + for (i = 0; i < ARRAY_SIZE(mdev->q_mcu); i++) | |
| 249 | + mt76_queue_tx_cleanup(dev, mdev->q_mcu[i], true); | |
| 250 | + napi_disable(&mdev->tx_napi); | |
| 251 | + | |
| 252 | + mt76_for_each_q_rx(mdev, i) | |
| 253 | + napi_disable(&mdev->napi[i]); | |
| 254 | + | |
| 255 | + mt76x02_dma_disable(dev); | |
| 256 | + mt76x02_mcu_cleanup(dev); | |
| 257 | + mt76x0_chip_onoff(dev, false, false); | |
| 258 | + | |
| 259 | + pci_enable_wake(pdev, pci_choose_state(pdev, state), true); | |
| 260 | + pci_save_state(pdev); | |
| 261 | + | |
| 262 | + return pci_set_power_state(pdev, pci_choose_state(pdev, state)); | |
| 263 | +} | |
| 264 | + | |
| 265 | +static int mt76x0e_resume(struct pci_dev *pdev) | |
| 266 | +{ | |
| 267 | + struct mt76_dev *mdev = pci_get_drvdata(pdev); | |
| 268 | + struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); | |
| 269 | + int err, i; | |
| 270 | + | |
| 271 | + err = pci_set_power_state(pdev, PCI_D0); | |
| 272 | + if (err) | |
| 273 | + return err; | |
| 274 | + | |
| 275 | + pci_restore_state(pdev); | |
| 276 | + | |
| 277 | + mt76_worker_enable(&mdev->tx_worker); | |
| 278 | + | |
| 279 | + mt76_for_each_q_rx(mdev, i) { | |
| 280 | + mt76_queue_rx_reset(dev, i); | |
| 281 | + napi_enable(&mdev->napi[i]); | |
| 282 | + napi_schedule(&mdev->napi[i]); | |
| 283 | + } | |
| 284 | + | |
| 285 | + napi_enable(&mdev->tx_napi); | |
| 286 | + napi_schedule(&mdev->tx_napi); | |
| 287 | + | |
| 288 | + return mt76x0e_init_hardware(dev, true); | |
| 289 | +} | |
| 290 | +#endif /* CONFIG_PM */ | |
| 291 | + | |
| 223 | 292 | static const struct pci_device_id mt76x0e_device_table[] = { |
| 224 | 293 | { PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7610) }, |
| 225 | 294 | { PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7630) }, |
| @@ -237,6 +306,10 @@ static struct pci_driver mt76x0e_driver = { · 11 unmodified lines | ||
| 237 | 306 | .id_table = mt76x0e_device_table, |
| 238 | 307 | .probe = mt76x0e_probe, |
| 239 | 308 | .remove = mt76x0e_remove, |
| 309 | +#ifdef CONFIG_PM | |
| 310 | + .suspend = mt76x0e_suspend, | |
| 311 | + .resume = mt76x0e_resume, | |
| 312 | +#endif /* CONFIG_PM */ | |
| 240 | 313 | }; |
| 241 | 314 | |
| 242 | 315 | module_pci_driver(mt76x0e_driver); |
| @@ -76,8 +76,8 @@ mt7921_init_wiphy(struct ieee80211_hw *hw) · 75 unmodified lines | ||
| 76 | 76 | struct wiphy *wiphy = hw->wiphy; |
| 77 | 77 | |
| 78 | 78 | hw->queues = 4; |
| 79 | − hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF; | |
| 80 | − hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF; | |
| 79 | + hw->max_rx_aggregation_subframes = 64; | |
| 80 | + hw->max_tx_aggregation_subframes = 128; | |
| 81 | 81 | |
| 82 | 82 | hw->radiotap_timestamp.units_pos = |
| 83 | 83 | IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US; |
| @@ -1404,8 +1404,9 @@ void mt7921_pm_wake_work(struct work_struct *work) · 1403 unmodified lines | ||
| 1404 | 1404 | napi_schedule(&dev->mt76.napi[i]); |
| 1405 | 1405 | mt76_connac_pm_dequeue_skbs(mphy, &dev->pm); |
| 1406 | 1406 | mt7921_tx_cleanup(dev); |
| 1407 | − ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, | |
| 1408 | − MT7921_WATCHDOG_TIME); | |
| 1407 | + if (test_bit(MT76_STATE_RUNNING, &mphy->state)) | |
| 1408 | + ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, | |
| 1409 | + MT7921_WATCHDOG_TIME); | |
| 1409 | 1410 | } |
| 1410 | 1411 | |
| 1411 | 1412 | ieee80211_wake_queues(mphy->hw); |
| @@ -74,8 +74,7 @@ mt7921_init_he_caps(struct mt7921_phy *phy, enum nl80211_band band, · 73 unmodified lines | ||
| 74 | 74 | IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; |
| 75 | 75 | else if (band == NL80211_BAND_5GHZ) |
| 76 | 76 | he_cap_elem->phy_cap_info[0] = |
| 77 | − IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G | | |
| 78 | − IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G; | |
| 77 | + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G; | |
| 79 | 78 | |
| 80 | 79 | he_cap_elem->phy_cap_info[1] = |
| 81 | 80 | IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD; |
| @@ -402,20 +402,22 @@ static void · 401 unmodified lines | ||
| 402 | 402 | mt7921_mcu_tx_rate_report(struct mt7921_dev *dev, struct sk_buff *skb, |
| 403 | 403 | u16 wlan_idx) |
| 404 | 404 | { |
| 405 | − struct mt7921_mcu_wlan_info_event *wtbl_info = | |
| 406 | − (struct mt7921_mcu_wlan_info_event *)(skb->data); | |
| 407 | − struct rate_info rate = {}; | |
| 408 | − u8 curr_idx = wtbl_info->rate_info.rate_idx; | |
| 409 | − u16 curr = le16_to_cpu(wtbl_info->rate_info.rate[curr_idx]); | |
| 410 | − struct mt7921_mcu_peer_cap peer = wtbl_info->peer_cap; | |
| 405 | + struct mt7921_mcu_wlan_info_event *wtbl_info; | |
| 411 | 406 | struct mt76_phy *mphy = &dev->mphy; |
| 412 | 407 | struct mt7921_sta_stats *stats; |
| 408 | + struct rate_info rate = {}; | |
| 413 | 409 | struct mt7921_sta *msta; |
| 414 | 410 | struct mt76_wcid *wcid; |
| 411 | + u8 idx; | |
| 415 | 412 | |
| 416 | 413 | if (wlan_idx >= MT76_N_WCIDS) |
| 417 | 414 | return; |
| 418 | 415 | |
| 416 | + wtbl_info = (struct mt7921_mcu_wlan_info_event *)skb->data; | |
| 417 | + idx = wtbl_info->rate_info.rate_idx; | |
| 418 | + if (idx >= ARRAY_SIZE(wtbl_info->rate_info.rate)) | |
| 419 | + return; | |
| 420 | + | |
| 419 | 421 | rcu_read_lock(); |
| 420 | 422 | |
| 421 | 423 | wcid = rcu_dereference(dev->mt76.wcid[wlan_idx]); |
| @@ -426,7 +428,8 @@ mt7921_mcu_tx_rate_report(struct mt7921_dev *dev, struct sk_buff *skb, · 4 unmodified lines | ||
| 426 | 428 | stats = &msta->stats; |
| 427 | 429 | |
| 428 | 430 | /* current rate */ |
| 429 | − mt7921_mcu_tx_rate_parse(mphy, &peer, &rate, curr); | |
| 431 | + mt7921_mcu_tx_rate_parse(mphy, &wtbl_info->peer_cap, &rate, | |
| 432 | + le16_to_cpu(wtbl_info->rate_info.rate[idx])); | |
| 430 | 433 | stats->tx_rate = rate; |
| 431 | 434 | out: |
| 432 | 435 | rcu_read_unlock(); |
| @@ -684,6 +684,7 @@ static void xenvif_disconnect_queue(struct xenvif_queue *queue) · 683 unmodified lines | ||
| 684 | 684 | { |
| 685 | 685 | if (queue->task) { |
| 686 | 686 | kthread_stop(queue->task); |
| 687 | + put_task_struct(queue->task); | |
| 687 | 688 | queue->task = NULL; |
| 688 | 689 | } |
| 689 | 690 | |
| @@ -745,6 +746,11 @@ int xenvif_connect_data(struct xenvif_queue *queue, · 55 unmodified lines | ||
| 745 | 746 | if (IS_ERR(task)) |
| 746 | 747 | goto kthread_err; |
| 747 | 748 | queue->task = task; |
| 749 | + /* | |
| 750 | + * Take a reference to the task in order to prevent it from being freed | |
| 751 | + * if the thread function returns before kthread_stop is called. | |
| 752 | + */ | |
| 753 | + get_task_struct(task); | |
| 748 | 754 | |
| 749 | 755 | task = kthread_run(xenvif_dealloc_kthread, queue, |
| 750 | 756 | "%s-dealloc", queue->name); |
| @@ -1320,16 +1320,17 @@ static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue, · 1319 unmodified lines | ||
| 1320 | 1320 | int count) |
| 1321 | 1321 | { |
| 1322 | 1322 | struct nvme_sgl_desc *sg = &c->common.dptr.sgl; |
| 1323 | − struct scatterlist *sgl = req->data_sgl.sg_table.sgl; | |
| 1324 | 1323 | struct ib_sge *sge = &req->sge[1]; |
| 1324 | + struct scatterlist *sgl; | |
| 1325 | 1325 | u32 len = 0; |
| 1326 | 1326 | int i; |
| 1327 | 1327 | |
| 1328 | − for (i = 0; i < count; i++, sgl++, sge++) { | |
| 1328 | + for_each_sg(req->data_sgl.sg_table.sgl, sgl, count, i) { | |
| 1329 | 1329 | sge->addr = sg_dma_address(sgl); |
| 1330 | 1330 | sge->length = sg_dma_len(sgl); |
| 1331 | 1331 | sge->lkey = queue->device->pd->local_dma_lkey; |
| 1332 | 1332 | len += sge->length; |
| 1333 | + sge++; | |
| 1333 | 1334 | } |
| 1334 | 1335 | |
| 1335 | 1336 | sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); |
| @@ -1005,19 +1005,23 @@ static unsigned int nvmet_data_transfer_len(struct nvmet_req *req) · 1004 unmodified lines | ||
| 1005 | 1005 | return req->transfer_len - req->metadata_len; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | −static int nvmet_req_alloc_p2pmem_sgls(struct nvmet_req *req) | |
| 1008 | +static int nvmet_req_alloc_p2pmem_sgls(struct pci_dev *p2p_dev, | |
| 1009 | + struct nvmet_req *req) | |
| 1009 | 1010 | { |
| 1010 | − req->sg = pci_p2pmem_alloc_sgl(req->p2p_dev, &req->sg_cnt, | |
| 1011 | + req->sg = pci_p2pmem_alloc_sgl(p2p_dev, &req->sg_cnt, | |
| 1011 | 1012 | nvmet_data_transfer_len(req)); |
| 1012 | 1013 | if (!req->sg) |
| 1013 | 1014 | goto out_err; |
| 1014 | 1015 | |
| 1015 | 1016 | if (req->metadata_len) { |
| 1016 | − req->metadata_sg = pci_p2pmem_alloc_sgl(req->p2p_dev, | |
| 1017 | + req->metadata_sg = pci_p2pmem_alloc_sgl(p2p_dev, | |
| 1017 | 1018 | &req->metadata_sg_cnt, req->metadata_len); |
| 1018 | 1019 | if (!req->metadata_sg) |
| 1019 | 1020 | goto out_free_sg; |
| 1020 | 1021 | } |
| 1022 | + | |
| 1023 | + req->p2p_dev = p2p_dev; | |
| 1024 | + | |
| 1021 | 1025 | return 0; |
| 1022 | 1026 | out_free_sg: |
| 1023 | 1027 | pci_p2pmem_free_sgl(req->p2p_dev, req->sg); |
| @@ -1025,25 +1029,19 @@ out_err: · 1 unmodified line | ||
| 1025 | 1029 | return -ENOMEM; |
| 1026 | 1030 | } |
| 1027 | 1031 | |
| 1028 | −static bool nvmet_req_find_p2p_dev(struct nvmet_req *req) | |
| 1032 | +static struct pci_dev *nvmet_req_find_p2p_dev(struct nvmet_req *req) | |
| 1029 | 1033 | { |
| 1030 | − if (!IS_ENABLED(CONFIG_PCI_P2PDMA)) | |
| 1031 | − return false; | |
| 1032 | − | |
| 1033 | − if (req->sq->ctrl && req->sq->qid && req->ns) { | |
| 1034 | − req->p2p_dev = radix_tree_lookup(&req->sq->ctrl->p2p_ns_map, | |
| 1035 | − req->ns->nsid); | |
| 1036 | − if (req->p2p_dev) | |
| 1037 | − return true; | |
| 1038 | − } | |
| 1039 | − | |
| 1040 | − req->p2p_dev = NULL; | |
| 1041 | − return false; | |
| 1034 | + if (!IS_ENABLED(CONFIG_PCI_P2PDMA) || | |
| 1035 | + !req->sq->ctrl || !req->sq->qid || !req->ns) | |
| 1036 | + return NULL; | |
| 1037 | + return radix_tree_lookup(&req->sq->ctrl->p2p_ns_map, req->ns->nsid); | |
| 1042 | 1038 | } |
| 1043 | 1039 | |
| 1044 | 1040 | int nvmet_req_alloc_sgls(struct nvmet_req *req) |
| 1045 | 1041 | { |
| 1046 | − if (nvmet_req_find_p2p_dev(req) && !nvmet_req_alloc_p2pmem_sgls(req)) | |
| 1042 | + struct pci_dev *p2p_dev = nvmet_req_find_p2p_dev(req); | |
| 1043 | + | |
| 1044 | + if (p2p_dev && !nvmet_req_alloc_p2pmem_sgls(p2p_dev, req)) | |
| 1047 | 1045 | return 0; |
| 1048 | 1046 | |
| 1049 | 1047 | req->sg = sgl_alloc(nvmet_data_transfer_len(req), GFP_KERNEL, |
| @@ -1072,6 +1070,7 @@ void nvmet_req_free_sgls(struct nvmet_req *req) · 22 unmodified lines | ||
| 1072 | 1070 | pci_p2pmem_free_sgl(req->p2p_dev, req->sg); |
| 1073 | 1071 | if (req->metadata_sg) |
| 1074 | 1072 | pci_p2pmem_free_sgl(req->p2p_dev, req->metadata_sg); |
| 1073 | + req->p2p_dev = NULL; | |
| 1075 | 1074 | } else { |
| 1076 | 1075 | sgl_free(req->sg); |
| 1077 | 1076 | if (req->metadata_sg) |
| @@ -263,7 +263,8 @@ static const struct blk_mq_ops nvme_loop_admin_mq_ops = { · 262 unmodified lines | ||
| 263 | 263 | |
| 264 | 264 | static void nvme_loop_destroy_admin_queue(struct nvme_loop_ctrl *ctrl) |
| 265 | 265 | { |
| 266 | − clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags); | |
| 266 | + if (!test_and_clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags)) | |
| 267 | + return; | |
| 267 | 268 | nvmet_sq_destroy(&ctrl->queues[0].nvme_sq); |
| 268 | 269 | blk_cleanup_queue(ctrl->ctrl.admin_q); |
| 269 | 270 | blk_cleanup_queue(ctrl->ctrl.fabrics_q); |
| @@ -299,6 +300,7 @@ static void nvme_loop_destroy_io_queues(struct nvme_loop_ctrl *ctrl) · 29 unmodified lines | ||
| 299 | 300 | clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags); |
| 300 | 301 | nvmet_sq_destroy(&ctrl->queues[i].nvme_sq); |
| 301 | 302 | } |
| 303 | + ctrl->ctrl.queue_count = 1; | |
| 302 | 304 | } |
| 303 | 305 | |
| 304 | 306 | static int nvme_loop_init_io_queues(struct nvme_loop_ctrl *ctrl) |
| @@ -405,6 +407,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl) · 100 unmodified lines | ||
| 405 | 407 | return 0; |
| 406 | 408 | |
| 407 | 409 | out_cleanup_queue: |
| 410 | + clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags); | |
| 408 | 411 | blk_cleanup_queue(ctrl->ctrl.admin_q); |
| 409 | 412 | out_cleanup_fabrics_q: |
| 410 | 413 | blk_cleanup_queue(ctrl->ctrl.fabrics_q); |
| @@ -462,8 +465,10 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work) · 51 unmodified lines | ||
| 462 | 465 | nvme_loop_shutdown_ctrl(ctrl); |
| 463 | 466 | |
| 464 | 467 | if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { |
| 465 | − /* state change failure should never happen */ | |
| 466 | − WARN_ON_ONCE(1); | |
| 468 | + if (ctrl->ctrl.state != NVME_CTRL_DELETING && | |
| 469 | + ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO) | |
| 470 | + /* state change failure for non-deleted ctrl? */ | |
| 471 | + WARN_ON_ONCE(1); | |
| 467 | 472 | return; |
| 468 | 473 | } |
| 469 | 474 | |
| @@ -103,6 +103,13 @@ struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus) · 102 unmodified lines | ||
| 103 | 103 | #endif |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | +bool pci_host_of_has_msi_map(struct device *dev) | |
| 107 | +{ | |
| 108 | + if (dev && dev->of_node) | |
| 109 | + return of_get_property(dev->of_node, "msi-map", NULL); | |
| 110 | + return false; | |
| 111 | +} | |
| 112 | + | |
| 106 | 113 | static inline int __of_pci_pci_compare(struct device_node *node, |
| 107 | 114 | unsigned int data) |
| 108 | 115 | { |
| @@ -925,7 +925,8 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) · 924 unmodified lines | ||
| 925 | 925 | device_enable_async_suspend(bus->bridge); |
| 926 | 926 | pci_set_bus_of_node(bus); |
| 927 | 927 | pci_set_bus_msi_domain(bus); |
| 928 | − if (bridge->msi_domain && !dev_get_msi_domain(&bus->dev)) | |
| 928 | + if (bridge->msi_domain && !dev_get_msi_domain(&bus->dev) && | |
| 929 | + !pci_host_of_has_msi_map(parent)) | |
| 929 | 930 | bus->bus_flags |= PCI_BUS_FLAGS_NO_MSI; |
| 930 | 931 | |
| 931 | 932 | if (!parent) |
| @@ -78,7 +78,7 @@ static inline u32 brcm_usb_readl(void __iomem *addr) · 77 unmodified lines | ||
| 78 | 78 | * Other architectures (e.g., ARM) either do not support big endian, or |
| 79 | 79 | * else leave I/O in little endian mode. |
| 80 | 80 | */ |
| 81 | − if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) | |
| 81 | + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) | |
| 82 | 82 | return __raw_readl(addr); |
| 83 | 83 | else |
| 84 | 84 | return readl_relaxed(addr); |
| @@ -87,7 +87,7 @@ static inline u32 brcm_usb_readl(void __iomem *addr) · 2 unmodified lines | ||
| 87 | 87 | static inline void brcm_usb_writel(u32 val, void __iomem *addr) |
| 88 | 88 | { |
| 89 | 89 | /* See brcmnand_readl() comments */ |
| 90 | − if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) | |
| 90 | + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) | |
| 91 | 91 | __raw_writel(val, addr); |
| 92 | 92 | else |
| 93 | 93 | writel_relaxed(val, addr); |
| @@ -940,6 +940,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev) · 939 unmodified lines | ||
| 940 | 940 | sp->nsubnodes = node; |
| 941 | 941 | |
| 942 | 942 | if (sp->num_lanes > SIERRA_MAX_LANES) { |
| 943 | + ret = -EINVAL; | |
| 943 | 944 | dev_err(dev, "Invalid lane configuration\n"); |
| 944 | 945 | goto put_child2; |
| 945 | 946 | } |
| @@ -949,6 +949,8 @@ static int mtk_phy_init(struct phy *phy) · 948 unmodified lines | ||
| 949 | 949 | break; |
| 950 | 950 | default: |
| 951 | 951 | dev_err(tphy->dev, "incompatible PHY type\n"); |
| 952 | + clk_disable_unprepare(instance->ref_clk); | |
| 953 | + clk_disable_unprepare(instance->da_ref_clk); | |
| 952 | 954 | return -EINVAL; |
| 953 | 955 | } |
| 954 | 956 | |
| @@ -2470,6 +2470,10 @@ static int sparx5_serdes_probe(struct platform_device *pdev) · 2469 unmodified lines | ||
| 2470 | 2470 | priv->coreclock = clock; |
| 2471 | 2471 | |
| 2472 | 2472 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 2473 | + if (!iores) { | |
| 2474 | + dev_err(priv->dev, "Invalid resource\n"); | |
| 2475 | + return -EINVAL; | |
| 2476 | + } | |
| 2473 | 2477 | iomem = devm_ioremap(priv->dev, iores->start, resource_size(iores)); |
| 2474 | 2478 | if (IS_ERR(iomem)) { |
| 2475 | 2479 | dev_err(priv->dev, "Unable to get serdes registers: %s\n", |
| @@ -341,7 +341,7 @@ static struct platform_driver mt7621_pci_phy_driver = { · 340 unmodified lines | ||
| 341 | 341 | .probe = mt7621_pci_phy_probe, |
| 342 | 342 | .driver = { |
| 343 | 343 | .name = "mt7621-pci-phy", |
| 344 | − .of_match_table = of_match_ptr(mt7621_pci_phy_ids), | |
| 344 | + .of_match_table = mt7621_pci_phy_ids, | |
| 345 | 345 | }, |
| 346 | 346 | }; |
| 347 | 347 | |
| @@ -1212,6 +1212,7 @@ static int wiz_probe(struct platform_device *pdev) · 1211 unmodified lines | ||
| 1212 | 1212 | |
| 1213 | 1213 | if (wiz->typec_dir_delay < WIZ_TYPEC_DIR_DEBOUNCE_MIN || |
| 1214 | 1214 | wiz->typec_dir_delay > WIZ_TYPEC_DIR_DEBOUNCE_MAX) { |
| 1215 | + ret = -EINVAL; | |
| 1215 | 1216 | dev_err(dev, "Invalid typec-dir-debounce property\n"); |
| 1216 | 1217 | goto err_addr_to_resource; |
| 1217 | 1218 | } |
| @@ -2702,8 +2702,8 @@ static int aspeed_g5_sig_expr_eval(struct aspeed_pinmux_data *ctx, · 2701 unmodified lines | ||
| 2702 | 2702 | } |
| 2703 | 2703 | |
| 2704 | 2704 | /** |
| 2705 | − * Configure a pin's signal by applying an expression's descriptor state for | |
| 2706 | − * all descriptors in the expression. | |
| 2705 | + * aspeed_g5_sig_expr_set() - Configure a pin's signal by applying an | |
| 2706 | + * expression's descriptor state for all descriptors in the expression. | |
| 2707 | 2707 | * |
| 2708 | 2708 | * @ctx: The pinmux context |
| 2709 | 2709 | * @expr: The expression associated with the function whose signal is to be |
| @@ -2611,8 +2611,8 @@ static struct aspeed_pin_config aspeed_g6_configs[] = { · 2610 unmodified lines | ||
| 2611 | 2611 | }; |
| 2612 | 2612 | |
| 2613 | 2613 | /** |
| 2614 | − * Configure a pin's signal by applying an expression's descriptor state for | |
| 2615 | − * all descriptors in the expression. | |
| 2614 | + * aspeed_g6_sig_expr_set() - Configure a pin's signal by applying an | |
| 2615 | + * expression's descriptor state for all descriptors in the expression. | |
| 2616 | 2616 | * |
| 2617 | 2617 | * @ctx: The pinmux context |
| 2618 | 2618 | * @expr: The expression associated with the function whose signal is to be |
| @@ -108,7 +108,8 @@ static int aspeed_sig_expr_disable(struct aspeed_pinmux_data *ctx, · 107 unmodified lines | ||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | − * Disable a signal on a pin by disabling all provided signal expressions. | |
| 111 | + * aspeed_disable_sig() - Disable a signal on a pin by disabling all provided | |
| 112 | + * signal expressions. | |
| 112 | 113 | * |
| 113 | 114 | * @ctx: The pinmux context |
| 114 | 115 | * @exprs: The list of signal expressions (from a priority level on a pin) |
| @@ -21,7 +21,8 @@ static inline void aspeed_sig_desc_print_val( · 20 unmodified lines | ||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | − * Query the enabled or disabled state of a signal descriptor | |
| 24 | + * aspeed_sig_desc_eval() - Query the enabled or disabled state of a signal | |
| 25 | + * descriptor. | |
| 25 | 26 | * |
| 26 | 27 | * @desc: The signal descriptor of interest |
| 27 | 28 | * @enabled: True to query the enabled state, false to query disabled state |
| @@ -223,7 +223,7 @@ config PINCTRL_SC7280 · 222 unmodified lines | ||
| 223 | 223 | config PINCTRL_SC8180X |
| 224 | 224 | tristate "Qualcomm Technologies Inc SC8180x pin controller driver" |
| 225 | 225 | depends on GPIOLIB && (OF || ACPI) |
| 226 | − select PINCTRL_MSM | |
| 226 | + depends on PINCTRL_MSM | |
| 227 | 227 | help |
| 228 | 228 | This is the pinctrl, pinmux, pinconf and gpiolib driver for the |
| 229 | 229 | Qualcomm Technologies Inc TLMM block found on the Qualcomm |
| @@ -410,15 +410,15 @@ static const char * const gpio_groups[] = { · 409 unmodified lines | ||
| 410 | 410 | "gpio29", "gpio30", "gpio31", "gpio32", "gpio33", "gpio34", "gpio35", |
| 411 | 411 | "gpio36", "gpio37", "gpio38", "gpio39", "gpio40", "gpio41", "gpio42", |
| 412 | 412 | "gpio43", "gpio44", "gpio45", "gpio46", "gpio47", "gpio48", "gpio49", |
| 413 | − "gpio50", "gpio51", "gpio52", "gpio52", "gpio53", "gpio53", "gpio54", | |
| 414 | − "gpio55", "gpio56", "gpio57", "gpio58", "gpio59", "gpio60", "gpio61", | |
| 415 | − "gpio62", "gpio63", "gpio64", "gpio65", "gpio66", "gpio67", "gpio68", | |
| 416 | − "gpio69", "gpio70", "gpio71", "gpio72", "gpio73", "gpio74", "gpio75", | |
| 417 | − "gpio76", "gpio77", "gpio78", "gpio79", "gpio80", "gpio81", "gpio82", | |
| 418 | − "gpio83", "gpio84", "gpio85", "gpio86", "gpio87", "gpio88", "gpio89", | |
| 419 | − "gpio90", "gpio91", "gpio92", "gpio93", "gpio94", "gpio95", "gpio96", | |
| 420 | − "gpio97", "gpio98", "gpio99", "gpio100", "gpio101", "gpio102", | |
| 421 | − "gpio103", "gpio104", "gpio105", "gpio106", "gpio107", | |
| 413 | + "gpio50", "gpio51", "gpio52", "gpio53", "gpio54", "gpio55", "gpio56", | |
| 414 | + "gpio57", "gpio58", "gpio59", "gpio60", "gpio61", "gpio62", "gpio63", | |
| 415 | + "gpio64", "gpio65", "gpio66", "gpio67", "gpio68", "gpio69", "gpio70", | |
| 416 | + "gpio71", "gpio72", "gpio73", "gpio74", "gpio75", "gpio76", "gpio77", | |
| 417 | + "gpio78", "gpio79", "gpio80", "gpio81", "gpio82", "gpio83", "gpio84", | |
| 418 | + "gpio85", "gpio86", "gpio87", "gpio88", "gpio89", "gpio90", "gpio91", | |
| 419 | + "gpio92", "gpio93", "gpio94", "gpio95", "gpio96", "gpio97", "gpio98", | |
| 420 | + "gpio99", "gpio100", "gpio101", "gpio102", "gpio103", "gpio104", | |
| 421 | + "gpio105", "gpio106", "gpio107", | |
| 422 | 422 | }; |
| 423 | 423 | |
| 424 | 424 | static const char * const qdss_stm_groups[] = { |
| @@ -127,7 +127,7 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, · 126 unmodified lines | ||
| 127 | 127 | if (p->groups[group].enabled) { |
| 128 | 128 | dev_err(p->dev, "%s is already enabled\n", |
| 129 | 129 | p->groups[group].name); |
| 130 | − return -EBUSY; | |
| 130 | + return 0; | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | p->groups[group].enabled = 1; |
| @@ -683,13 +683,13 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev) · 682 unmodified lines | ||
| 683 | 683 | |
| 684 | 684 | err = devm_request_irq(&pdev->dev, priv->irq, |
| 685 | 685 | mlxreg_hotplug_irq_handler, IRQF_TRIGGER_FALLING |
| 686 | − | IRQF_SHARED | IRQF_NO_AUTOEN, | |
| 687 | − "mlxreg-hotplug", priv); | |
| 686 | + | IRQF_SHARED, "mlxreg-hotplug", priv); | |
| 688 | 687 | if (err) { |
| 689 | 688 | dev_err(&pdev->dev, "Failed to request irq: %d\n", err); |
| 690 | 689 | return err; |
| 691 | 690 | } |
| 692 | 691 | |
| 692 | + disable_irq(priv->irq); | |
| 693 | 693 | spin_lock_init(&priv->lock); |
| 694 | 694 | INIT_DELAYED_WORK(&priv->dwork_irq, mlxreg_hotplug_work_handler); |
| 695 | 695 | dev_set_drvdata(&pdev->dev, priv); |
| @@ -1907,7 +1907,7 @@ static int ssam_ssh_event_disable(struct ssam_controller *ctrl, · 1906 unmodified lines | ||
| 1907 | 1907 | { |
| 1908 | 1908 | int status; |
| 1909 | 1909 | |
| 1910 | − status = __ssam_ssh_event_request(ctrl, reg, reg.cid_enable, id, flags); | |
| 1910 | + status = __ssam_ssh_event_request(ctrl, reg, reg.cid_disable, id, flags); | |
| 1911 | 1911 | |
| 1912 | 1912 | if (status < 0 && status != -EINVAL) { |
| 1913 | 1913 | ssam_err(ctrl, |
| @@ -156,7 +156,7 @@ static const struct software_node *ssam_node_group_sl2[] = { · 155 unmodified lines | ||
| 156 | 156 | NULL, |
| 157 | 157 | }; |
| 158 | 158 | |
| 159 | −/* Devices for Surface Laptop 3. */ | |
| 159 | +/* Devices for Surface Laptop 3 and 4. */ | |
| 160 | 160 | static const struct software_node *ssam_node_group_sl3[] = { |
| 161 | 161 | &ssam_node_root, |
| 162 | 162 | &ssam_node_bat_ac, |
| @@ -521,9 +521,12 @@ static const struct acpi_device_id ssam_platform_hub_match[] = { · 358 unmodified lines | ||
| 521 | 521 | /* Surface Laptop 3 (13", Intel) */ |
| 522 | 522 | { "MSHW0114", (unsigned long)ssam_node_group_sl3 }, |
| 523 | 523 | |
| 524 | − /* Surface Laptop 3 (15", AMD) */ | |
| 524 | + /* Surface Laptop 3 (15", AMD) and 4 (15", AMD) */ | |
| 525 | 525 | { "MSHW0110", (unsigned long)ssam_node_group_sl3 }, |
| 526 | 526 | |
| 527 | + /* Surface Laptop 4 (13", Intel) */ | |
| 528 | + { "MSHW0250", (unsigned long)ssam_node_group_sl3 }, | |
| 529 | + | |
| 527 | 530 | /* Surface Laptop Go 1 */ |
| 528 | 531 | { "MSHW0118", (unsigned long)ssam_node_group_slg1 }, |
| 529 | 532 | |
| @@ -427,6 +427,7 @@ static int surface_dtx_open(struct inode *inode, struct file *file) · 426 unmodified lines | ||
| 427 | 427 | */ |
| 428 | 428 | if (test_bit(SDTX_DEVICE_SHUTDOWN_BIT, &ddev->flags)) { |
| 429 | 429 | up_write(&ddev->client_lock); |
| 430 | + mutex_destroy(&client->read_lock); | |
| 430 | 431 | sdtx_device_put(client->ddev); |
| 431 | 432 | kfree(client); |
| 432 | 433 | return -ENODEV; |
| @@ -8853,6 +8853,7 @@ static const struct tpacpi_quirk fan_quirk_table[] __initconst = { · 8852 unmodified lines | ||
| 8853 | 8853 | TPACPI_Q_LNV3('N', '2', 'O', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (2nd gen) */ |
| 8854 | 8854 | TPACPI_Q_LNV3('N', '2', 'V', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (3nd gen) */ |
| 8855 | 8855 | TPACPI_Q_LNV3('N', '3', '0', TPACPI_FAN_2CTL), /* P15 (1st gen) / P15v (1st gen) */ |
| 8856 | + TPACPI_Q_LNV3('N', '3', '2', TPACPI_FAN_2CTL), /* X1 Carbon (9th gen) */ | |
| 8856 | 8857 | }; |
| 8857 | 8858 | |
| 8858 | 8859 | static int __init fan_init(struct ibm_init_struct *iibm) |
| @@ -1031,7 +1031,7 @@ config REGULATOR_RT5033 · 1030 unmodified lines | ||
| 1031 | 1031 | current source, LDO and Buck. |
| 1032 | 1032 | |
| 1033 | 1033 | config REGULATOR_RTMV20 |
| 1034 | − tristate "RTMV20 Laser Diode Regulator" | |
| 1034 | + tristate "Richtek RTMV20 Laser Diode Regulator" | |
| 1035 | 1035 | depends on I2C |
| 1036 | 1036 | select REGMAP_I2C |
| 1037 | 1037 | help |
| @@ -28,16 +28,16 @@ static const struct linear_range atc2609a_dcdc_voltage_ranges[] = { · 27 unmodified lines | ||
| 28 | 28 | |
| 29 | 29 | static const struct linear_range atc2609a_ldo_voltage_ranges0[] = { |
| 30 | 30 | REGULATOR_LINEAR_RANGE(700000, 0, 15, 100000), |
| 31 | − REGULATOR_LINEAR_RANGE(2100000, 16, 28, 100000), | |
| 31 | + REGULATOR_LINEAR_RANGE(2100000, 0, 12, 100000), | |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | 34 | static const struct linear_range atc2609a_ldo_voltage_ranges1[] = { |
| 35 | 35 | REGULATOR_LINEAR_RANGE(850000, 0, 15, 100000), |
| 36 | − REGULATOR_LINEAR_RANGE(2100000, 16, 27, 100000), | |
| 36 | + REGULATOR_LINEAR_RANGE(2100000, 0, 11, 100000), | |
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | 39 | static const unsigned int atc260x_ldo_voltage_range_sel[] = { |
| 40 | − 0x0, 0x1, | |
| 40 | + 0x0, 0x20, | |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | static int atc260x_dcdc_set_voltage_time_sel(struct regulator_dev *rdev, |
| @@ -411,7 +411,7 @@ enum atc2609a_reg_ids { · 367 unmodified lines | ||
| 411 | 411 | .owner = THIS_MODULE, \ |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | −#define atc2609a_reg_desc_ldo_range_pick(num, n_range) { \ | |
| 414 | +#define atc2609a_reg_desc_ldo_range_pick(num, n_range, n_volt) { \ | |
| 415 | 415 | .name = "LDO"#num, \ |
| 416 | 416 | .supply_name = "ldo"#num, \ |
| 417 | 417 | .of_match = of_match_ptr("ldo"#num), \ |
| @@ -421,6 +421,7 @@ enum atc2609a_reg_ids { · 3 unmodified lines | ||
| 421 | 421 | .type = REGULATOR_VOLTAGE, \ |
| 422 | 422 | .linear_ranges = atc2609a_ldo_voltage_ranges##n_range, \ |
| 423 | 423 | .n_linear_ranges = ARRAY_SIZE(atc2609a_ldo_voltage_ranges##n_range), \ |
| 424 | + .n_voltages = n_volt, \ | |
| 424 | 425 | .vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \ |
| 425 | 426 | .vsel_mask = GENMASK(4, 1), \ |
| 426 | 427 | .vsel_range_reg = ATC2609A_PMU_LDO##num##_CTL0, \ |
| @@ -458,12 +459,12 @@ static const struct regulator_desc atc2609a_reg[] = { · 31 unmodified lines | ||
| 458 | 459 | atc2609a_reg_desc_ldo_bypass(0), |
| 459 | 460 | atc2609a_reg_desc_ldo_bypass(1), |
| 460 | 461 | atc2609a_reg_desc_ldo_bypass(2), |
| 461 | − atc2609a_reg_desc_ldo_range_pick(3, 0), | |
| 462 | − atc2609a_reg_desc_ldo_range_pick(4, 0), | |
| 462 | + atc2609a_reg_desc_ldo_range_pick(3, 0, 29), | |
| 463 | + atc2609a_reg_desc_ldo_range_pick(4, 0, 29), | |
| 463 | 464 | atc2609a_reg_desc_ldo(5), |
| 464 | − atc2609a_reg_desc_ldo_range_pick(6, 1), | |
| 465 | − atc2609a_reg_desc_ldo_range_pick(7, 0), | |
| 466 | − atc2609a_reg_desc_ldo_range_pick(8, 0), | |
| 465 | + atc2609a_reg_desc_ldo_range_pick(6, 1, 28), | |
| 466 | + atc2609a_reg_desc_ldo_range_pick(7, 0, 29), | |
| 467 | + atc2609a_reg_desc_ldo_range_pick(8, 0, 29), | |
| 467 | 468 | atc2609a_reg_desc_ldo_fixed(9), |
| 468 | 469 | }; |
| 469 | 470 | |
| @@ -334,7 +334,7 @@ BD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range, · 333 unmodified lines | ||
| 334 | 334 | NULL); |
| 335 | 335 | |
| 336 | 336 | BD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table, |
| 337 | − regulator_map_voltage_ascend, bd718xx_set_voltage_sel_restricted, | |
| 337 | + regulator_map_voltage_ascend, bd71837_set_voltage_sel_restricted, | |
| 338 | 338 | regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel, |
| 339 | 339 | NULL); |
| 340 | 340 | /* |
| @@ -1425,6 +1425,12 @@ static int set_machine_constraints(struct regulator_dev *rdev) · 1424 unmodified lines | ||
| 1425 | 1425 | * and we have control then make sure it is enabled. |
| 1426 | 1426 | */ |
| 1427 | 1427 | if (rdev->constraints->always_on || rdev->constraints->boot_on) { |
| 1428 | + /* If we want to enable this regulator, make sure that we know | |
| 1429 | + * the supplying regulator. | |
| 1430 | + */ | |
| 1431 | + if (rdev->supply_name && !rdev->supply) | |
| 1432 | + return -EPROBE_DEFER; | |
| 1433 | + | |
| 1428 | 1434 | if (rdev->supply) { |
| 1429 | 1435 | ret = regulator_enable(rdev->supply); |
| 1430 | 1436 | if (ret < 0) { |
| @@ -225,8 +225,9 @@ static int cros_ec_regulator_probe(struct platform_device *pdev) · 224 unmodified lines | ||
| 225 | 225 | |
| 226 | 226 | drvdata->dev = devm_regulator_register(dev, &drvdata->desc, &cfg); |
| 227 | 227 | if (IS_ERR(drvdata->dev)) { |
| 228 | + ret = PTR_ERR(drvdata->dev); | |
| 228 | 229 | dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); |
| 229 | − return PTR_ERR(drvdata->dev); | |
| 230 | + return ret; | |
| 230 | 231 | } |
| 231 | 232 | |
| 232 | 233 | platform_set_drvdata(pdev, drvdata); |
| @@ -280,7 +280,7 @@ static unsigned int da9121_map_mode(unsigned int mode) · 279 unmodified lines | ||
| 280 | 280 | case DA9121_BUCK_MODE_FORCE_PFM: |
| 281 | 281 | return REGULATOR_MODE_STANDBY; |
| 282 | 282 | default: |
| 283 | − return -EINVAL; | |
| 283 | + return REGULATOR_MODE_INVALID; | |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
| @@ -317,7 +317,7 @@ static unsigned int da9121_buck_get_mode(struct regulator_dev *rdev) · 30 unmodified lines | ||
| 317 | 317 | { |
| 318 | 318 | struct da9121 *chip = rdev_get_drvdata(rdev); |
| 319 | 319 | int id = rdev_get_id(rdev); |
| 320 | − unsigned int val; | |
| 320 | + unsigned int val, mode; | |
| 321 | 321 | int ret = 0; |
| 322 | 322 | |
| 323 | 323 | ret = regmap_read(chip->regmap, da9121_mode_field[id].reg, &val); |
| @@ -326,7 +326,11 @@ static unsigned int da9121_buck_get_mode(struct regulator_dev *rdev) · 2 unmodified lines | ||
| 326 | 326 | return -EINVAL; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | − return da9121_map_mode(val & da9121_mode_field[id].msk); | |
| 329 | + mode = da9121_map_mode(val & da9121_mode_field[id].msk); | |
| 330 | + if (mode == REGULATOR_MODE_INVALID) | |
| 331 | + return -EINVAL; | |
| 332 | + | |
| 333 | + return mode; | |
| 330 | 334 | } |
| 331 | 335 | |
| 332 | 336 | static const struct regulator_ops da9121_buck_ops = { |
| @@ -55,7 +55,6 @@ · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | #define FAN53555_NVOLTAGES 64 /* Numbers of voltages */ |
| 57 | 57 | #define FAN53526_NVOLTAGES 128 |
| 58 | −#define TCS4525_NVOLTAGES 127 /* Numbers of voltages */ | |
| 59 | 58 | |
| 60 | 59 | #define TCS_VSEL_NSEL_MASK 0x7f |
| 61 | 60 | #define TCS_VSEL0_MODE (1 << 7) |
| @@ -376,7 +375,7 @@ static int fan53555_voltages_setup_tcs(struct fan53555_device_info *di) · 314 unmodified lines | ||
| 376 | 375 | /* Init voltage range and step */ |
| 377 | 376 | di->vsel_min = 600000; |
| 378 | 377 | di->vsel_step = 6250; |
| 379 | − di->vsel_count = TCS4525_NVOLTAGES; | |
| 378 | + di->vsel_count = FAN53526_NVOLTAGES; | |
| 380 | 379 | |
| 381 | 380 | return 0; |
| 382 | 381 | } |
| @@ -51,6 +51,7 @@ static const struct regulator_ops fan53880_ops = { · 50 unmodified lines | ||
| 51 | 51 | REGULATOR_LINEAR_RANGE(800000, 0xf, 0x73, 25000), \ |
| 52 | 52 | }, \ |
| 53 | 53 | .n_linear_ranges = 2, \ |
| 54 | + .n_voltages = 0x74, \ | |
| 54 | 55 | .vsel_reg = FAN53880_LDO ## _num ## VOUT, \ |
| 55 | 56 | .vsel_mask = 0x7f, \ |
| 56 | 57 | .enable_reg = FAN53880_ENABLE, \ |
| @@ -76,6 +77,7 @@ static const struct regulator_desc fan53880_regulators[] = { · 19 unmodified lines | ||
| 76 | 77 | REGULATOR_LINEAR_RANGE(600000, 0x1f, 0xf7, 12500), |
| 77 | 78 | }, |
| 78 | 79 | .n_linear_ranges = 2, |
| 80 | + .n_voltages = 0xf8, | |
| 79 | 81 | .vsel_reg = FAN53880_BUCKVOUT, |
| 80 | 82 | .vsel_mask = 0x7f, |
| 81 | 83 | .enable_reg = FAN53880_ENABLE, |
| @@ -95,6 +97,7 @@ static const struct regulator_desc fan53880_regulators[] = { · 13 unmodified lines | ||
| 95 | 97 | REGULATOR_LINEAR_RANGE(3000000, 0x4, 0x70, 25000), |
| 96 | 98 | }, |
| 97 | 99 | .n_linear_ranges = 2, |
| 100 | + .n_voltages = 0x71, | |
| 98 | 101 | .vsel_reg = FAN53880_BOOSTVOUT, |
| 99 | 102 | .vsel_mask = 0x7f, |
| 100 | 103 | .enable_reg = FAN53880_ENABLE_BOOST, |
| @@ -88,10 +88,15 @@ static int reg_domain_disable(struct regulator_dev *rdev) · 87 unmodified lines | ||
| 88 | 88 | { |
| 89 | 89 | struct fixed_voltage_data *priv = rdev_get_drvdata(rdev); |
| 90 | 90 | struct device *dev = rdev->dev.parent; |
| 91 | + int ret; | |
| 92 | + | |
| 93 | + ret = dev_pm_genpd_set_performance_state(dev, 0); | |
| 94 | + if (ret) | |
| 95 | + return ret; | |
| 91 | 96 | |
| 92 | 97 | priv->enable_counter--; |
| 93 | 98 | |
| 94 | − return dev_pm_genpd_set_performance_state(dev, 0); | |
| 99 | + return 0; | |
| 95 | 100 | } |
| 96 | 101 | |
| 97 | 102 | static int reg_is_enabled(struct regulator_dev *rdev) |
| @@ -948,7 +948,7 @@ int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay) · 947 unmodified lines | ||
| 948 | 948 | int ret; |
| 949 | 949 | unsigned int sel; |
| 950 | 950 | |
| 951 | − if (!rdev->desc->n_ramp_values) | |
| 951 | + if (WARN_ON(!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table)) | |
| 952 | 952 | return -EINVAL; |
| 953 | 953 | |
| 954 | 954 | ret = find_closest_bigger(ramp_delay, rdev->desc->ramp_delay_table, |
| @@ -3,7 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | // Device driver for regulators in Hisi IC |
| 4 | 4 | // |
| 5 | 5 | // Copyright (c) 2013 Linaro Ltd. |
| 6 | −// Copyright (c) 2011 Hisilicon. | |
| 6 | +// Copyright (c) 2011 HiSilicon Ltd. | |
| 7 | 7 | // Copyright (c) 2020-2021 Huawei Technologies Co., Ltd |
| 8 | 8 | // |
| 9 | 9 | // Guodong Xu <guodong.xu@linaro.org> |
| @@ -83,7 +83,7 @@ static const unsigned int ldo34_voltages[] = { · 73 unmodified lines | ||
| 83 | 83 | .owner = THIS_MODULE, \ |
| 84 | 84 | .volt_table = vtable, \ |
| 85 | 85 | .n_voltages = ARRAY_SIZE(vtable), \ |
| 86 | − .vsel_mask = (1 << (ARRAY_SIZE(vtable) - 1)) - 1, \ | |
| 86 | + .vsel_mask = ARRAY_SIZE(vtable) - 1, \ | |
| 87 | 87 | .vsel_reg = vreg, \ |
| 88 | 88 | .enable_reg = ereg, \ |
| 89 | 89 | .enable_mask = emask, \ |
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | // |
| 3 | 3 | // Device driver for regulators in Hi655x IC |
| 4 | 4 | // |
| 5 | −// Copyright (c) 2016 Hisilicon. | |
| 5 | +// Copyright (c) 2016 HiSilicon Ltd. | |
| 6 | 6 | // |
| 7 | 7 | // Authors: |
| 8 | 8 | // Chen Feng <puck.chen@hisilicon.com> |
| @@ -814,6 +814,13 @@ static int max77620_regulator_probe(struct platform_device *pdev) · 813 unmodified lines | ||
| 814 | 814 | config.dev = dev; |
| 815 | 815 | config.driver_data = pmic; |
| 816 | 816 | |
| 817 | + /* | |
| 818 | + * Set of_node_reuse flag to prevent driver core from attempting to | |
| 819 | + * claim any pinmux resources already claimed by the parent device. | |
| 820 | + * Otherwise PMIC driver will fail to re-probe. | |
| 821 | + */ | |
| 822 | + device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent); | |
| 823 | + | |
| 817 | 824 | for (id = 0; id < MAX77620_NUM_REGS; id++) { |
| 818 | 825 | struct regulator_dev *rdev; |
| 819 | 826 | struct regulator_desc *rdesc; |
| @@ -839,12 +846,10 @@ static int max77620_regulator_probe(struct platform_device *pdev) · 19 unmodified lines | ||
| 839 | 846 | return ret; |
| 840 | 847 | |
| 841 | 848 | rdev = devm_regulator_register(dev, rdesc, &config); |
| 842 | − if (IS_ERR(rdev)) { | |
| 843 | − ret = PTR_ERR(rdev); | |
| 844 | − dev_err(dev, "Regulator registration %s failed: %d\n", | |
| 845 | − rdesc->name, ret); | |
| 846 | − return ret; | |
| 847 | − } | |
| 849 | + if (IS_ERR(rdev)) | |
| 850 | + return dev_err_probe(dev, PTR_ERR(rdev), | |
| 851 | + "Regulator registration %s failed\n", | |
| 852 | + rdesc->name); | |
| 848 | 853 | } |
| 849 | 854 | |
| 850 | 855 | return 0; |
| @@ -59,7 +59,7 @@ static const struct linear_range mt_volt_range1[] = { · 58 unmodified lines | ||
| 59 | 59 | REGULATOR_LINEAR_RANGE(0, 0, 0xbf, 6250), |
| 60 | 60 | }; |
| 61 | 61 | |
| 62 | −static unsigned int mt6315_map_mode(u32 mode) | |
| 62 | +static unsigned int mt6315_map_mode(unsigned int mode) | |
| 63 | 63 | { |
| 64 | 64 | switch (mode) { |
| 65 | 65 | case MT6315_BUCK_MODE_AUTO: |
| @@ -66,7 +66,7 @@ static int rt4801_enable(struct regulator_dev *rdev) · 65 unmodified lines | ||
| 66 | 66 | struct gpio_descs *gpios = priv->enable_gpios; |
| 67 | 67 | int id = rdev_get_id(rdev), ret; |
| 68 | 68 | |
| 69 | − if (gpios->ndescs <= id) { | |
| 69 | + if (!gpios || gpios->ndescs <= id) { | |
| 70 | 70 | dev_warn(&rdev->dev, "no dedicated gpio can control\n"); |
| 71 | 71 | goto bypass_gpio; |
| 72 | 72 | } |
| @@ -88,7 +88,7 @@ static int rt4801_disable(struct regulator_dev *rdev) · 15 unmodified lines | ||
| 88 | 88 | struct gpio_descs *gpios = priv->enable_gpios; |
| 89 | 89 | int id = rdev_get_id(rdev); |
| 90 | 90 | |
| 91 | − if (gpios->ndescs <= id) { | |
| 91 | + if (!gpios || gpios->ndescs <= id) { | |
| 92 | 92 | dev_warn(&rdev->dev, "no dedicated gpio can control\n"); |
| 93 | 93 | goto bypass_gpio; |
| 94 | 94 | } |
| @@ -27,6 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #define RTMV20_REG_LDIRQ 0x30 |
| 28 | 28 | #define RTMV20_REG_LDSTAT 0x40 |
| 29 | 29 | #define RTMV20_REG_LDMASK 0x50 |
| 30 | +#define RTMV20_MAX_REGS (RTMV20_REG_LDMASK + 1) | |
| 30 | 31 | |
| 31 | 32 | #define RTMV20_VID_MASK GENMASK(7, 4) |
| 32 | 33 | #define RICHTEK_VID 0x80 |
| @@ -103,9 +104,47 @@ static int rtmv20_lsw_disable(struct regulator_dev *rdev) · 70 unmodified lines | ||
| 103 | 104 | return 0; |
| 104 | 105 | } |
| 105 | 106 | |
| 107 | +static int rtmv20_lsw_set_current_limit(struct regulator_dev *rdev, int min_uA, | |
| 108 | + int max_uA) | |
| 109 | +{ | |
| 110 | + int sel; | |
| 111 | + | |
| 112 | + if (min_uA > RTMV20_LSW_MAXUA || max_uA < RTMV20_LSW_MINUA) | |
| 113 | + return -EINVAL; | |
| 114 | + | |
| 115 | + if (max_uA > RTMV20_LSW_MAXUA) | |
| 116 | + max_uA = RTMV20_LSW_MAXUA; | |
| 117 | + | |
| 118 | + sel = (max_uA - RTMV20_LSW_MINUA) / RTMV20_LSW_STEPUA; | |
| 119 | + | |
| 120 | + /* Ensure the selected setting is still in range */ | |
| 121 | + if ((sel * RTMV20_LSW_STEPUA + RTMV20_LSW_MINUA) < min_uA) | |
| 122 | + return -EINVAL; | |
| 123 | + | |
| 124 | + sel <<= ffs(rdev->desc->csel_mask) - 1; | |
| 125 | + | |
| 126 | + return regmap_update_bits(rdev->regmap, rdev->desc->csel_reg, | |
| 127 | + rdev->desc->csel_mask, sel); | |
| 128 | +} | |
| 129 | + | |
| 130 | +static int rtmv20_lsw_get_current_limit(struct regulator_dev *rdev) | |
| 131 | +{ | |
| 132 | + unsigned int val; | |
| 133 | + int ret; | |
| 134 | + | |
| 135 | + ret = regmap_read(rdev->regmap, rdev->desc->csel_reg, &val); | |
| 136 | + if (ret) | |
| 137 | + return ret; | |
| 138 | + | |
| 139 | + val &= rdev->desc->csel_mask; | |
| 140 | + val >>= ffs(rdev->desc->csel_mask) - 1; | |
| 141 | + | |
| 142 | + return val * RTMV20_LSW_STEPUA + RTMV20_LSW_MINUA; | |
| 143 | +} | |
| 144 | + | |
| 106 | 145 | static const struct regulator_ops rtmv20_regulator_ops = { |
| 107 | − .set_current_limit = regulator_set_current_limit_regmap, | |
| 108 | − .get_current_limit = regulator_get_current_limit_regmap, | |
| 146 | + .set_current_limit = rtmv20_lsw_set_current_limit, | |
| 147 | + .get_current_limit = rtmv20_lsw_get_current_limit, | |
| 109 | 148 | .enable = rtmv20_lsw_enable, |
| 110 | 149 | .disable = rtmv20_lsw_disable, |
| 111 | 150 | .is_enabled = regulator_is_enabled_regmap, |
| @@ -275,6 +314,7 @@ static const struct regmap_config rtmv20_regmap_config = { · 163 unmodified lines | ||
| 275 | 314 | .val_bits = 8, |
| 276 | 315 | .cache_type = REGCACHE_RBTREE, |
| 277 | 316 | .max_register = RTMV20_REG_LDMASK, |
| 317 | + .num_reg_defaults_raw = RTMV20_MAX_REGS, | |
| 278 | 318 | |
| 279 | 319 | .writeable_reg = rtmv20_is_accessible_reg, |
| 280 | 320 | .readable_reg = rtmv20_is_accessible_reg, |
| @@ -173,7 +173,7 @@ scmi_config_linear_regulator_mappings(struct scmi_regulator *sreg, · 172 unmodified lines | ||
| 173 | 173 | sreg->desc.uV_step = |
| 174 | 174 | vinfo->levels_uv[SCMI_VOLTAGE_SEGMENT_STEP]; |
| 175 | 175 | sreg->desc.linear_min_sel = 0; |
| 176 | − sreg->desc.n_voltages = delta_uV / sreg->desc.uV_step; | |
| 176 | + sreg->desc.n_voltages = (delta_uV / sreg->desc.uV_step) + 1; | |
| 177 | 177 | sreg->desc.ops = &scmi_reg_linear_ops; |
| 178 | 178 | } |
| 179 | 179 | |
| @@ -254,12 +254,11 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, · 253 unmodified lines | ||
| 254 | 254 | |
| 255 | 255 | device_enable_async_suspend(&shost->shost_dev); |
| 256 | 256 | |
| 257 | + get_device(&shost->shost_gendev); | |
| 257 | 258 | error = device_add(&shost->shost_dev); |
| 258 | 259 | if (error) |
| 259 | 260 | goto out_del_gendev; |
| 260 | 261 | |
| 261 | − get_device(&shost->shost_gendev); | |
| 262 | − | |
| 263 | 262 | if (shost->transportt->host_size) { |
| 264 | 263 | shost->shost_data = kzalloc(shost->transportt->host_size, |
| 265 | 264 | GFP_KERNEL); |
| @@ -278,33 +277,36 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, · 12 unmodified lines | ||
| 278 | 277 | |
| 279 | 278 | if (!shost->work_q) { |
| 280 | 279 | error = -EINVAL; |
| 281 | − goto out_free_shost_data; | |
| 280 | + goto out_del_dev; | |
| 282 | 281 | } |
| 283 | 282 | } |
| 284 | 283 | |
| 285 | 284 | error = scsi_sysfs_add_host(shost); |
| 286 | 285 | if (error) |
| 287 | − goto out_destroy_host; | |
| 286 | + goto out_del_dev; | |
| 288 | 287 | |
| 289 | 288 | scsi_proc_host_add(shost); |
| 290 | 289 | scsi_autopm_put_host(shost); |
| 291 | 290 | return error; |
| 292 | 291 | |
| 293 | − out_destroy_host: | |
| 294 | − if (shost->work_q) | |
| 295 | − destroy_workqueue(shost->work_q); | |
| 296 | − out_free_shost_data: | |
| 297 | − kfree(shost->shost_data); | |
| 292 | + /* | |
| 293 | + * Any host allocation in this function will be freed in | |
| 294 | + * scsi_host_dev_release(). | |
| 295 | + */ | |
| 298 | 296 | out_del_dev: |
| 299 | 297 | device_del(&shost->shost_dev); |
| 300 | 298 | out_del_gendev: |
| 299 | + /* | |
| 300 | + * Host state is SHOST_RUNNING so we have to explicitly release | |
| 301 | + * ->shost_dev. | |
| 302 | + */ | |
| 303 | + put_device(&shost->shost_dev); | |
| 301 | 304 | device_del(&shost->shost_gendev); |
| 302 | 305 | out_disable_runtime_pm: |
| 303 | 306 | device_disable_async_suspend(&shost->shost_gendev); |
| 304 | 307 | pm_runtime_disable(&shost->shost_gendev); |
| 305 | 308 | pm_runtime_set_suspended(&shost->shost_gendev); |
| 306 | 309 | pm_runtime_put_noidle(&shost->shost_gendev); |
| 307 | − scsi_mq_destroy_tags(shost); | |
| 308 | 310 | fail: |
| 309 | 311 | return error; |
| 310 | 312 | } |
| @@ -345,7 +347,7 @@ static void scsi_host_dev_release(struct device *dev) · 34 unmodified lines | ||
| 345 | 347 | |
| 346 | 348 | ida_simple_remove(&host_index_ida, shost->host_no); |
| 347 | 349 | |
| 348 | − if (parent) | |
| 350 | + if (shost->shost_state != SHOST_CREATED) | |
| 349 | 351 | put_device(parent); |
| 350 | 352 | kfree(shost); |
| 351 | 353 | } |
| @@ -388,8 +390,10 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) · 36 unmodified lines | ||
| 388 | 390 | mutex_init(&shost->scan_mutex); |
| 389 | 391 | |
| 390 | 392 | index = ida_simple_get(&host_index_ida, 0, 0, GFP_KERNEL); |
| 391 | − if (index < 0) | |
| 392 | − goto fail_kfree; | |
| 393 | + if (index < 0) { | |
| 394 | + kfree(shost); | |
| 395 | + return NULL; | |
| 396 | + } | |
| 393 | 397 | shost->host_no = index; |
| 394 | 398 | |
| 395 | 399 | shost->dma_channel = 0xff; |
| @@ -481,7 +485,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) · 85 unmodified lines | ||
| 481 | 485 | shost_printk(KERN_WARNING, shost, |
| 482 | 486 | "error handler thread failed to spawn, error = %ld\n", |
| 483 | 487 | PTR_ERR(shost->ehandler)); |
| 484 | − goto fail_index_remove; | |
| 488 | + goto fail; | |
| 485 | 489 | } |
| 486 | 490 | |
| 487 | 491 | shost->tmf_work_q = alloc_workqueue("scsi_tmf_%d", |
| @@ -490,17 +494,18 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) · 2 unmodified lines | ||
| 490 | 494 | if (!shost->tmf_work_q) { |
| 491 | 495 | shost_printk(KERN_WARNING, shost, |
| 492 | 496 | "failed to create tmf workq\n"); |
| 493 | − goto fail_kthread; | |
| 497 | + goto fail; | |
| 494 | 498 | } |
| 495 | 499 | scsi_proc_hostdir_add(shost->hostt); |
| 496 | 500 | return shost; |
| 501 | + fail: | |
| 502 | + /* | |
| 503 | + * Host state is still SHOST_CREATED and that is enough to release | |
| 504 | + * ->shost_gendev. scsi_host_dev_release() will free | |
| 505 | + * dev_name(&shost->shost_dev). | |
| 506 | + */ | |
| 507 | + put_device(&shost->shost_gendev); | |
| 497 | 508 | |
| 498 | − fail_kthread: | |
| 499 | − kthread_stop(shost->ehandler); | |
| 500 | − fail_index_remove: | |
| 501 | − ida_simple_remove(&host_index_ida, shost->host_no); | |
| 502 | − fail_kfree: | |
| 503 | − kfree(shost); | |
| 504 | 509 | return NULL; |
| 505 | 510 | } |
| 506 | 511 | EXPORT_SYMBOL(scsi_host_alloc); |
| @@ -20589,10 +20589,8 @@ lpfc_sli4_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 20588 unmodified lines | ||
| 20589 | 20589 | abtswqe = &abtsiocb->wqe; |
| 20590 | 20590 | memset(abtswqe, 0, sizeof(*abtswqe)); |
| 20591 | 20591 | |
| 20592 | − if (lpfc_is_link_up(phba)) | |
| 20592 | + if (!lpfc_is_link_up(phba)) | |
| 20593 | 20593 | bf_set(abort_cmd_ia, &abtswqe->abort_cmd, 1); |
| 20594 | − else | |
| 20595 | − bf_set(abort_cmd_ia, &abtswqe->abort_cmd, 0); | |
| 20596 | 20594 | bf_set(abort_cmd_criteria, &abtswqe->abort_cmd, T_XRI_TAG); |
| 20597 | 20595 | abtswqe->abort_cmd.rsrvd5 = 0; |
| 20598 | 20596 | abtswqe->abort_cmd.wqe_com.abort_tag = xritag; |
| @@ -1827,22 +1827,20 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) · 1826 unmodified lines | ||
| 1827 | 1827 | fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf)); |
| 1828 | 1828 | QEDF_WARN(&(base_qedf->dbg_ctx), "Failed to create vport, " |
| 1829 | 1829 | "WWPN (0x%s) already exists.\n", buf); |
| 1830 | − goto err1; | |
| 1830 | + return rc; | |
| 1831 | 1831 | } |
| 1832 | 1832 | |
| 1833 | 1833 | if (atomic_read(&base_qedf->link_state) != QEDF_LINK_UP) { |
| 1834 | 1834 | QEDF_WARN(&(base_qedf->dbg_ctx), "Cannot create vport " |
| 1835 | 1835 | "because link is not up.\n"); |
| 1836 | − rc = -EIO; | |
| 1837 | − goto err1; | |
| 1836 | + return -EIO; | |
| 1838 | 1837 | } |
| 1839 | 1838 | |
| 1840 | 1839 | vn_port = libfc_vport_create(vport, sizeof(struct qedf_ctx)); |
| 1841 | 1840 | if (!vn_port) { |
| 1842 | 1841 | QEDF_WARN(&(base_qedf->dbg_ctx), "Could not create lport " |
| 1843 | 1842 | "for vport.\n"); |
| 1844 | − rc = -ENOMEM; | |
| 1845 | − goto err1; | |
| 1843 | + return -ENOMEM; | |
| 1846 | 1844 | } |
| 1847 | 1845 | |
| 1848 | 1846 | fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf)); |
| @@ -1866,7 +1864,7 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) · 17 unmodified lines | ||
| 1866 | 1864 | if (rc) { |
| 1867 | 1865 | QEDF_ERR(&(base_qedf->dbg_ctx), "Could not allocate memory " |
| 1868 | 1866 | "for lport stats.\n"); |
| 1869 | − goto err2; | |
| 1867 | + goto err; | |
| 1870 | 1868 | } |
| 1871 | 1869 | |
| 1872 | 1870 | fc_set_wwnn(vn_port, vport->node_name); |
| @@ -1884,7 +1882,7 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) · 11 unmodified lines | ||
| 1884 | 1882 | if (rc) { |
| 1885 | 1883 | QEDF_WARN(&base_qedf->dbg_ctx, |
| 1886 | 1884 | "Error adding Scsi_Host rc=0x%x.\n", rc); |
| 1887 | − goto err2; | |
| 1885 | + goto err; | |
| 1888 | 1886 | } |
| 1889 | 1887 | |
| 1890 | 1888 | /* Set default dev_loss_tmo based on module parameter */ |
| @@ -1925,9 +1923,10 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) · 34 unmodified lines | ||
| 1925 | 1923 | vport_qedf->dbg_ctx.host_no = vn_port->host->host_no; |
| 1926 | 1924 | vport_qedf->dbg_ctx.pdev = base_qedf->pdev; |
| 1927 | 1925 | |
| 1928 | −err2: | |
| 1926 | + return 0; | |
| 1927 | + | |
| 1928 | +err: | |
| 1929 | 1929 | scsi_host_put(vn_port->host); |
| 1930 | −err1: | |
| 1931 | 1930 | return rc; |
| 1932 | 1931 | } |
| 1933 | 1932 | |
| @@ -1968,8 +1967,7 @@ static int qedf_vport_destroy(struct fc_vport *vport) · 34 unmodified lines | ||
| 1968 | 1967 | fc_lport_free_stats(vn_port); |
| 1969 | 1968 | |
| 1970 | 1969 | /* Release Scsi_Host */ |
| 1971 | − if (vn_port->host) | |
| 1972 | − scsi_host_put(vn_port->host); | |
| 1970 | + scsi_host_put(vn_port->host); | |
| 1973 | 1971 | |
| 1974 | 1972 | out: |
| 1975 | 1973 | return 0; |
| @@ -184,6 +184,7 @@ static struct { · 183 unmodified lines | ||
| 184 | 184 | {"HP", "C3323-300", "4269", BLIST_NOTQ}, |
| 185 | 185 | {"HP", "C5713A", NULL, BLIST_NOREPORTLUN}, |
| 186 | 186 | {"HP", "DISK-SUBSYSTEM", "*", BLIST_REPORTLUN2}, |
| 187 | + {"HPE", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES}, | |
| 187 | 188 | {"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN}, |
| 188 | 189 | {"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 189 | 190 | {"IBM", "2105", NULL, BLIST_RETRY_HWERROR}, |
| @@ -603,11 +603,23 @@ static void ufs_mtk_get_controller_version(struct ufs_hba *hba) · 602 unmodified lines | ||
| 603 | 603 | |
| 604 | 604 | ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_LOCALVERINFO), &ver); |
| 605 | 605 | if (!ret) { |
| 606 | − if (ver >= UFS_UNIPRO_VER_1_8) | |
| 606 | + if (ver >= UFS_UNIPRO_VER_1_8) { | |
| 607 | 607 | host->hw_ver.major = 3; |
| 608 | + /* | |
| 609 | + * Fix HCI version for some platforms with | |
| 610 | + * incorrect version | |
| 611 | + */ | |
| 612 | + if (hba->ufs_version < ufshci_version(3, 0)) | |
| 613 | + hba->ufs_version = ufshci_version(3, 0); | |
| 614 | + } | |
| 608 | 615 | } |
| 609 | 616 | } |
| 610 | 617 | |
| 618 | +static u32 ufs_mtk_get_ufs_hci_version(struct ufs_hba *hba) | |
| 619 | +{ | |
| 620 | + return hba->ufs_version; | |
| 621 | +} | |
| 622 | + | |
| 611 | 623 | /** |
| 612 | 624 | * ufs_mtk_init - find other essential mmio bases |
| 613 | 625 | * @hba: host controller instance |
| @@ -1048,6 +1060,7 @@ static void ufs_mtk_event_notify(struct ufs_hba *hba, · 434 unmodified lines | ||
| 1048 | 1060 | static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { |
| 1049 | 1061 | .name = "mediatek.ufshci", |
| 1050 | 1062 | .init = ufs_mtk_init, |
| 1063 | + .get_ufs_hci_version = ufs_mtk_get_ufs_hci_version, | |
| 1051 | 1064 | .setup_clocks = ufs_mtk_setup_clocks, |
| 1052 | 1065 | .hce_enable_notify = ufs_mtk_hce_enable_notify, |
| 1053 | 1066 | .link_startup_notify = ufs_mtk_link_startup_notify, |
| @@ -626,10 +626,8 @@ static int meson_msr_probe(struct platform_device *pdev) · 625 unmodified lines | ||
| 626 | 626 | |
| 627 | 627 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 628 | 628 | base = devm_ioremap_resource(&pdev->dev, res); |
| 629 | − if (IS_ERR(base)) { | |
| 630 | − dev_err(&pdev->dev, "io resource mapping failed\n"); | |
| 629 | + if (IS_ERR(base)) | |
| 631 | 630 | return PTR_ERR(base); |
| 632 | − } | |
| 633 | 631 | |
| 634 | 632 | priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, |
| 635 | 633 | &meson_clk_msr_regmap_config); |
| @@ -68,7 +68,7 @@ · 67 unmodified lines | ||
| 68 | 68 | #define BCM2835_SPI_FIFO_SIZE 64 |
| 69 | 69 | #define BCM2835_SPI_FIFO_SIZE_3_4 48 |
| 70 | 70 | #define BCM2835_SPI_DMA_MIN_LENGTH 96 |
| 71 | −#define BCM2835_SPI_NUM_CS 4 /* raise as necessary */ | |
| 71 | +#define BCM2835_SPI_NUM_CS 24 /* raise as necessary */ | |
| 72 | 72 | #define BCM2835_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ |
| 73 | 73 | | SPI_NO_CS | SPI_3WIRE) |
| 74 | 74 | |
| @@ -1195,6 +1195,12 @@ static int bcm2835_spi_setup(struct spi_device *spi) · 1120 unmodified lines | ||
| 1195 | 1195 | struct gpio_chip *chip; |
| 1196 | 1196 | u32 cs; |
| 1197 | 1197 | |
| 1198 | + if (spi->chip_select >= BCM2835_SPI_NUM_CS) { | |
| 1199 | + dev_err(&spi->dev, "only %d chip-selects supported\n", | |
| 1200 | + BCM2835_SPI_NUM_CS - 1); | |
| 1201 | + return -EINVAL; | |
| 1202 | + } | |
| 1203 | + | |
| 1198 | 1204 | /* |
| 1199 | 1205 | * Precalculate SPI slave's CS register value for ->prepare_message(): |
| 1200 | 1206 | * The driver always uses software-controlled GPIO chip select, hence |
| @@ -1288,7 +1294,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev) · 87 unmodified lines | ||
| 1288 | 1294 | ctlr->use_gpio_descriptors = true; |
| 1289 | 1295 | ctlr->mode_bits = BCM2835_SPI_MODE_BITS; |
| 1290 | 1296 | ctlr->bits_per_word_mask = SPI_BPW_MASK(8); |
| 1291 | − ctlr->num_chipselect = BCM2835_SPI_NUM_CS; | |
| 1297 | + ctlr->num_chipselect = 3; | |
| 1292 | 1298 | ctlr->setup = bcm2835_spi_setup; |
| 1293 | 1299 | ctlr->transfer_one = bcm2835_spi_transfer_one; |
| 1294 | 1300 | ctlr->handle_err = bcm2835_spi_handle_err; |
| @@ -184,6 +184,8 @@ int spi_bitbang_setup(struct spi_device *spi) · 183 unmodified lines | ||
| 184 | 184 | { |
| 185 | 185 | struct spi_bitbang_cs *cs = spi->controller_state; |
| 186 | 186 | struct spi_bitbang *bitbang; |
| 187 | + bool initial_setup = false; | |
| 188 | + int retval; | |
| 187 | 189 | |
| 188 | 190 | bitbang = spi_master_get_devdata(spi->master); |
| 189 | 191 | |
| @@ -192,22 +194,30 @@ int spi_bitbang_setup(struct spi_device *spi) · 2 unmodified lines | ||
| 192 | 194 | if (!cs) |
| 193 | 195 | return -ENOMEM; |
| 194 | 196 | spi->controller_state = cs; |
| 197 | + initial_setup = true; | |
| 195 | 198 | } |
| 196 | 199 | |
| 197 | 200 | /* per-word shift register access, in hardware or bitbanging */ |
| 198 | 201 | cs->txrx_word = bitbang->txrx_word[spi->mode & (SPI_CPOL|SPI_CPHA)]; |
| 199 | − if (!cs->txrx_word) | |
| 200 | − return -EINVAL; | |
| 202 | + if (!cs->txrx_word) { | |
| 203 | + retval = -EINVAL; | |
| 204 | + goto err_free; | |
| 205 | + } | |
| 201 | 206 | |
| 202 | 207 | if (bitbang->setup_transfer) { |
| 203 | − int retval = bitbang->setup_transfer(spi, NULL); | |
| 208 | + retval = bitbang->setup_transfer(spi, NULL); | |
| 204 | 209 | if (retval < 0) |
| 205 | − return retval; | |
| 210 | + goto err_free; | |
| 206 | 211 | } |
| 207 | 212 | |
| 208 | 213 | dev_dbg(&spi->dev, "%s, %u nsec/bit\n", __func__, 2 * cs->nsecs); |
| 209 | 214 | |
| 210 | 215 | return 0; |
| 216 | + | |
| 217 | +err_free: | |
| 218 | + if (initial_setup) | |
| 219 | + kfree(cs); | |
| 220 | + return retval; | |
| 211 | 221 | } |
| 212 | 222 | EXPORT_SYMBOL_GPL(spi_bitbang_setup); |
| 213 | 223 | |
| @@ -440,6 +440,7 @@ static int fsl_spi_setup(struct spi_device *spi) · 439 unmodified lines | ||
| 440 | 440 | { |
| 441 | 441 | struct mpc8xxx_spi *mpc8xxx_spi; |
| 442 | 442 | struct fsl_spi_reg __iomem *reg_base; |
| 443 | + bool initial_setup = false; | |
| 443 | 444 | int retval; |
| 444 | 445 | u32 hw_mode; |
| 445 | 446 | struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); |
| @@ -452,6 +453,7 @@ static int fsl_spi_setup(struct spi_device *spi) · 6 unmodified lines | ||
| 452 | 453 | if (!cs) |
| 453 | 454 | return -ENOMEM; |
| 454 | 455 | spi_set_ctldata(spi, cs); |
| 456 | + initial_setup = true; | |
| 455 | 457 | } |
| 456 | 458 | mpc8xxx_spi = spi_master_get_devdata(spi->master); |
| 457 | 459 | |
| @@ -475,6 +477,8 @@ static int fsl_spi_setup(struct spi_device *spi) · 17 unmodified lines | ||
| 475 | 477 | retval = fsl_spi_setup_transfer(spi, NULL); |
| 476 | 478 | if (retval < 0) { |
| 477 | 479 | cs->hw_mode = hw_mode; /* Restore settings */ |
| 480 | + if (initial_setup) | |
| 481 | + kfree(cs); | |
| 478 | 482 | return retval; |
| 479 | 483 | } |
| 480 | 484 | |
| @@ -424,15 +424,22 @@ done: · 423 unmodified lines | ||
| 424 | 424 | static int uwire_setup(struct spi_device *spi) |
| 425 | 425 | { |
| 426 | 426 | struct uwire_state *ust = spi->controller_state; |
| 427 | + bool initial_setup = false; | |
| 428 | + int status; | |
| 427 | 429 | |
| 428 | 430 | if (ust == NULL) { |
| 429 | 431 | ust = kzalloc(sizeof(*ust), GFP_KERNEL); |
| 430 | 432 | if (ust == NULL) |
| 431 | 433 | return -ENOMEM; |
| 432 | 434 | spi->controller_state = ust; |
| 435 | + initial_setup = true; | |
| 433 | 436 | } |
| 434 | 437 | |
| 435 | − return uwire_setup_transfer(spi, NULL); | |
| 438 | + status = uwire_setup_transfer(spi, NULL); | |
| 439 | + if (status && initial_setup) | |
| 440 | + kfree(ust); | |
| 441 | + | |
| 442 | + return status; | |
| 436 | 443 | } |
| 437 | 444 | |
| 438 | 445 | static void uwire_cleanup(struct spi_device *spi) |
| @@ -1032,8 +1032,22 @@ static void omap2_mcspi_release_dma(struct spi_master *master) · 1031 unmodified lines | ||
| 1032 | 1032 | } |
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | +static void omap2_mcspi_cleanup(struct spi_device *spi) | |
| 1036 | +{ | |
| 1037 | + struct omap2_mcspi_cs *cs; | |
| 1038 | + | |
| 1039 | + if (spi->controller_state) { | |
| 1040 | + /* Unlink controller state from context save list */ | |
| 1041 | + cs = spi->controller_state; | |
| 1042 | + list_del(&cs->node); | |
| 1043 | + | |
| 1044 | + kfree(cs); | |
| 1045 | + } | |
| 1046 | +} | |
| 1047 | + | |
| 1035 | 1048 | static int omap2_mcspi_setup(struct spi_device *spi) |
| 1036 | 1049 | { |
| 1050 | + bool initial_setup = false; | |
| 1037 | 1051 | int ret; |
| 1038 | 1052 | struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master); |
| 1039 | 1053 | struct omap2_mcspi_regs *ctx = &mcspi->ctx; |
| @@ -1051,35 +1065,28 @@ static int omap2_mcspi_setup(struct spi_device *spi) · 11 unmodified lines | ||
| 1051 | 1065 | spi->controller_state = cs; |
| 1052 | 1066 | /* Link this to context save list */ |
| 1053 | 1067 | list_add_tail(&cs->node, &ctx->cs); |
| 1068 | + initial_setup = true; | |
| 1054 | 1069 | } |
| 1055 | 1070 | |
| 1056 | 1071 | ret = pm_runtime_get_sync(mcspi->dev); |
| 1057 | 1072 | if (ret < 0) { |
| 1058 | 1073 | pm_runtime_put_noidle(mcspi->dev); |
| 1074 | + if (initial_setup) | |
| 1075 | + omap2_mcspi_cleanup(spi); | |
| 1059 | 1076 | |
| 1060 | 1077 | return ret; |
| 1061 | 1078 | } |
| 1062 | 1079 | |
| 1063 | 1080 | ret = omap2_mcspi_setup_transfer(spi, NULL); |
| 1081 | + if (ret && initial_setup) | |
| 1082 | + omap2_mcspi_cleanup(spi); | |
| 1083 | + | |
| 1064 | 1084 | pm_runtime_mark_last_busy(mcspi->dev); |
| 1065 | 1085 | pm_runtime_put_autosuspend(mcspi->dev); |
| 1066 | 1086 | |
| 1067 | 1087 | return ret; |
| 1068 | 1088 | } |
| 1069 | 1089 | |
| 1070 | −static void omap2_mcspi_cleanup(struct spi_device *spi) | |
| 1071 | −{ | |
| 1072 | − struct omap2_mcspi_cs *cs; | |
| 1073 | − | |
| 1074 | − if (spi->controller_state) { | |
| 1075 | − /* Unlink controller state from context save list */ | |
| 1076 | − cs = spi->controller_state; | |
| 1077 | − list_del(&cs->node); | |
| 1078 | − | |
| 1079 | − kfree(cs); | |
| 1080 | − } | |
| 1081 | −} | |
| 1082 | − | |
| 1083 | 1090 | static irqreturn_t omap2_mcspi_irq_handler(int irq, void *data) |
| 1084 | 1091 | { |
| 1085 | 1092 | struct omap2_mcspi *mcspi = data; |
| @@ -1254,6 +1254,8 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip, · 1253 unmodified lines | ||
| 1254 | 1254 | chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH; |
| 1255 | 1255 | |
| 1256 | 1256 | err = gpiod_direction_output(gpiod, !chip->gpio_cs_inverted); |
| 1257 | + if (err) | |
| 1258 | + gpiod_put(chip->gpiod_cs); | |
| 1257 | 1259 | } |
| 1258 | 1260 | |
| 1259 | 1261 | return err; |
| @@ -1267,6 +1269,7 @@ static int setup(struct spi_device *spi) · 7 unmodified lines | ||
| 1267 | 1269 | struct driver_data *drv_data = |
| 1268 | 1270 | spi_controller_get_devdata(spi->controller); |
| 1269 | 1271 | uint tx_thres, tx_hi_thres, rx_thres; |
| 1272 | + int err; | |
| 1270 | 1273 | |
| 1271 | 1274 | switch (drv_data->ssp_type) { |
| 1272 | 1275 | case QUARK_X1000_SSP: |
| @@ -1413,7 +1416,11 @@ static int setup(struct spi_device *spi) · 140 unmodified lines | ||
| 1413 | 1416 | if (drv_data->ssp_type == CE4100_SSP) |
| 1414 | 1417 | return 0; |
| 1415 | 1418 | |
| 1416 | − return setup_cs(spi, chip, chip_info); | |
| 1419 | + err = setup_cs(spi, chip, chip_info); | |
| 1420 | + if (err) | |
| 1421 | + kfree(chip); | |
| 1422 | + | |
| 1423 | + return err; | |
| 1417 | 1424 | } |
| 1418 | 1425 | |
| 1419 | 1426 | static void cleanup(struct spi_device *spi) |
| @@ -294,7 +294,7 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, · 293 unmodified lines | ||
| 294 | 294 | int err = 0; |
| 295 | 295 | |
| 296 | 296 | if (!op->data.nbytes) |
| 297 | − return stm32_qspi_wait_nobusy(qspi); | |
| 297 | + goto wait_nobusy; | |
| 298 | 298 | |
| 299 | 299 | if (readl_relaxed(qspi->io_base + QSPI_SR) & SR_TCF) |
| 300 | 300 | goto out; |
| @@ -315,6 +315,9 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, · 14 unmodified lines | ||
| 315 | 315 | out: |
| 316 | 316 | /* clear flags */ |
| 317 | 317 | writel_relaxed(FCR_CTCF | FCR_CTEF, qspi->io_base + QSPI_FCR); |
| 318 | +wait_nobusy: | |
| 319 | + if (!err) | |
| 320 | + err = stm32_qspi_wait_nobusy(qspi); | |
| 318 | 321 | |
| 319 | 322 | return err; |
| 320 | 323 | } |
| @@ -678,14 +678,14 @@ static int zynq_qspi_probe(struct platform_device *pdev) · 677 unmodified lines | ||
| 678 | 678 | xqspi->irq = platform_get_irq(pdev, 0); |
| 679 | 679 | if (xqspi->irq <= 0) { |
| 680 | 680 | ret = -ENXIO; |
| 681 | − goto remove_master; | |
| 681 | + goto clk_dis_all; | |
| 682 | 682 | } |
| 683 | 683 | ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq, |
| 684 | 684 | 0, pdev->name, xqspi); |
| 685 | 685 | if (ret != 0) { |
| 686 | 686 | ret = -ENXIO; |
| 687 | 687 | dev_err(&pdev->dev, "request_irq failed\n"); |
| 688 | − goto remove_master; | |
| 688 | + goto clk_dis_all; | |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | ret = of_property_read_u32(np, "num-cs", |
| @@ -693,8 +693,9 @@ static int zynq_qspi_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 693 | 693 | if (ret < 0) { |
| 694 | 694 | ctlr->num_chipselect = 1; |
| 695 | 695 | } else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) { |
| 696 | + ret = -EINVAL; | |
| 696 | 697 | dev_err(&pdev->dev, "only 2 chip selects are available\n"); |
| 697 | − goto remove_master; | |
| 698 | + goto clk_dis_all; | |
| 698 | 699 | } else { |
| 699 | 700 | ctlr->num_chipselect = num_cs; |
| 700 | 701 | } |
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | 2 | /* |
| 3 | − * Copyright (C) 2013, Lars-Peter Clausen <lars@metafoo.de> | |
| 4 | 3 | * GDMA4740 DMAC support |
| 5 | 4 | */ |
| 6 | 5 | |
| @@ -914,6 +913,5 @@ static struct platform_driver gdma_dma_driver = { · 907 unmodified lines | ||
| 914 | 913 | }; |
| 915 | 914 | module_platform_driver(gdma_dma_driver); |
| 916 | 915 | |
| 917 | −MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | |
| 918 | 916 | MODULE_DESCRIPTION("Ralink/MTK DMA driver"); |
| 919 | 917 | MODULE_LICENSE("GPL v2"); |
| @@ -2091,7 +2091,7 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame, · 2090 unmodified lines | ||
| 2091 | 2091 | struct net_device *ndev = padapter->pnetdev; |
| 2092 | 2092 | |
| 2093 | 2093 | { |
| 2094 | − struct station_info sinfo; | |
| 2094 | + struct station_info sinfo = {}; | |
| 2095 | 2095 | u8 ie_offset; |
| 2096 | 2096 | if (GetFrameSubType(pmgmt_frame) == WIFI_ASSOCREQ) |
| 2097 | 2097 | ie_offset = _ASOCREQ_IE_OFFSET_; |
| @@ -3121,9 +3121,7 @@ __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, · 3120 unmodified lines | ||
| 3121 | 3121 | __releases(&cmd->t_state_lock) |
| 3122 | 3122 | __acquires(&cmd->t_state_lock) |
| 3123 | 3123 | { |
| 3124 | − | |
| 3125 | − assert_spin_locked(&cmd->t_state_lock); | |
| 3126 | − WARN_ON_ONCE(!irqs_disabled()); | |
| 3124 | + lockdep_assert_held(&cmd->t_state_lock); | |
| 3127 | 3125 | |
| 3128 | 3126 | if (fabric_stop) |
| 3129 | 3127 | cmd->transport_state |= CMD_T_FABRIC_STOP; |
| @@ -220,6 +220,7 @@ int optee_open_session(struct tee_context *ctx, · 219 unmodified lines | ||
| 220 | 220 | struct optee_msg_arg *msg_arg; |
| 221 | 221 | phys_addr_t msg_parg; |
| 222 | 222 | struct optee_session *sess = NULL; |
| 223 | + uuid_t client_uuid; | |
| 223 | 224 | |
| 224 | 225 | /* +2 for the meta parameters added below */ |
| 225 | 226 | shm = get_msg_arg(ctx, arg->num_params + 2, &msg_arg, &msg_parg); |
| @@ -240,10 +241,11 @@ int optee_open_session(struct tee_context *ctx, · 14 unmodified lines | ||
| 240 | 241 | memcpy(&msg_arg->params[0].u.value, arg->uuid, sizeof(arg->uuid)); |
| 241 | 242 | msg_arg->params[1].u.value.c = arg->clnt_login; |
| 242 | 243 | |
| 243 | − rc = tee_session_calc_client_uuid((uuid_t *)&msg_arg->params[1].u.value, | |
| 244 | − arg->clnt_login, arg->clnt_uuid); | |
| 244 | + rc = tee_session_calc_client_uuid(&client_uuid, arg->clnt_login, | |
| 245 | + arg->clnt_uuid); | |
| 245 | 246 | if (rc) |
| 246 | 247 | goto out; |
| 248 | + export_uuid(msg_arg->params[1].u.octets, &client_uuid); | |
| 247 | 249 | |
| 248 | 250 | rc = optee_to_msg_param(msg_arg->params + 2, arg->num_params, param); |
| 249 | 251 | if (rc) |
| @@ -9,7 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | #include <linux/types.h> |
| 10 | 10 | |
| 11 | 11 | /* |
| 12 | − * This file defines the OP-TEE message protocol used to communicate | |
| 12 | + * This file defines the OP-TEE message protocol (ABI) used to communicate | |
| 13 | 13 | * with an instance of OP-TEE running in secure world. |
| 14 | 14 | * |
| 15 | 15 | * This file is divided into two sections. |
| @@ -144,9 +144,10 @@ struct optee_msg_param_value { · 128 unmodified lines | ||
| 144 | 144 | * @tmem: parameter by temporary memory reference |
| 145 | 145 | * @rmem: parameter by registered memory reference |
| 146 | 146 | * @value: parameter by opaque value |
| 147 | + * @octets: parameter by octet string | |
| 147 | 148 | * |
| 148 | 149 | * @attr & OPTEE_MSG_ATTR_TYPE_MASK indicates if tmem, rmem or value is used in |
| 149 | − * the union. OPTEE_MSG_ATTR_TYPE_VALUE_* indicates value, | |
| 150 | + * the union. OPTEE_MSG_ATTR_TYPE_VALUE_* indicates value or octets, | |
| 150 | 151 | * OPTEE_MSG_ATTR_TYPE_TMEM_* indicates @tmem and |
| 151 | 152 | * OPTEE_MSG_ATTR_TYPE_RMEM_* indicates @rmem, |
| 152 | 153 | * OPTEE_MSG_ATTR_TYPE_NONE indicates that none of the members are used. |
| @@ -157,6 +158,7 @@ struct optee_msg_param { · 4 unmodified lines | ||
| 157 | 158 | struct optee_msg_param_tmem tmem; |
| 158 | 159 | struct optee_msg_param_rmem rmem; |
| 159 | 160 | struct optee_msg_param_value value; |
| 161 | + u8 octets[24]; | |
| 160 | 162 | } u; |
| 161 | 163 | }; |
| 162 | 164 | |
| @@ -621,6 +621,17 @@ bool x86_thermal_enabled(void) · 620 unmodified lines | ||
| 621 | 621 | return atomic_read(&therm_throt_en); |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | +void __init therm_lvt_init(void) | |
| 625 | +{ | |
| 626 | + /* | |
| 627 | + * This function is only called on boot CPU. Save the init thermal | |
| 628 | + * LVT value on BSP and use that value to restore APs' thermal LVT | |
| 629 | + * entry BIOS programmed later | |
| 630 | + */ | |
| 631 | + if (intel_thermal_supported(&boot_cpu_data)) | |
| 632 | + lvtthmr_init = apic_read(APIC_LVTTHMR); | |
| 633 | +} | |
| 634 | + | |
| 624 | 635 | void intel_init_thermal(struct cpuinfo_x86 *c) |
| 625 | 636 | { |
| 626 | 637 | unsigned int cpu = smp_processor_id(); |
| @@ -630,10 +641,6 @@ void intel_init_thermal(struct cpuinfo_x86 *c) · 3 unmodified lines | ||
| 630 | 641 | if (!intel_thermal_supported(c)) |
| 631 | 642 | return; |
| 632 | 643 | |
| 633 | − /* On the BSP? */ | |
| 634 | − if (c == &boot_cpu_data) | |
| 635 | − lvtthmr_init = apic_read(APIC_LVTTHMR); | |
| 636 | − | |
| 637 | 644 | /* |
| 638 | 645 | * First check if its enabled already, in which case there might |
| 639 | 646 | * be some SMM goo which handles it, so we can't even put a handler |
| @@ -553,7 +553,11 @@ static void pci_xr17v35x_exit(struct pci_dev *pcidev) · 552 unmodified lines | ||
| 553 | 553 | { |
| 554 | 554 | struct exar8250 *priv = pci_get_drvdata(pcidev); |
| 555 | 555 | struct uart_8250_port *port = serial8250_get_port(priv->line[0]); |
| 556 | − struct platform_device *pdev = port->port.private_data; | |
| 556 | + struct platform_device *pdev; | |
| 557 | + | |
| 558 | + pdev = port->port.private_data; | |
| 559 | + if (!pdev) | |
| 560 | + return; | |
| 557 | 561 | |
| 558 | 562 | device_remove_software_node(&pdev->dev); |
| 559 | 563 | platform_device_unregister(pdev); |
| @@ -2007,7 +2007,7 @@ static void cdns3_configure_dmult(struct cdns3_device *priv_dev, · 2006 unmodified lines | ||
| 2007 | 2007 | else |
| 2008 | 2008 | mask = BIT(priv_ep->num); |
| 2009 | 2009 | |
| 2010 | − if (priv_ep->type != USB_ENDPOINT_XFER_ISOC) { | |
| 2010 | + if (priv_ep->type != USB_ENDPOINT_XFER_ISOC && !priv_ep->dir) { | |
| 2011 | 2011 | cdns3_set_register_bit(®s->tdl_from_trb, mask); |
| 2012 | 2012 | cdns3_set_register_bit(®s->tdl_beh, mask); |
| 2013 | 2013 | cdns3_set_register_bit(®s->tdl_beh2, mask); |
| @@ -2046,15 +2046,13 @@ int cdns3_ep_config(struct cdns3_endpoint *priv_ep, bool enable) · 32 unmodified lines | ||
| 2046 | 2046 | case USB_ENDPOINT_XFER_INT: |
| 2047 | 2047 | ep_cfg = EP_CFG_EPTYPE(USB_ENDPOINT_XFER_INT); |
| 2048 | 2048 | |
| 2049 | − if ((priv_dev->dev_ver == DEV_VER_V2 && !priv_ep->dir) || | |
| 2050 | − priv_dev->dev_ver > DEV_VER_V2) | |
| 2049 | + if (priv_dev->dev_ver >= DEV_VER_V2 && !priv_ep->dir) | |
| 2051 | 2050 | ep_cfg |= EP_CFG_TDL_CHK; |
| 2052 | 2051 | break; |
| 2053 | 2052 | case USB_ENDPOINT_XFER_BULK: |
| 2054 | 2053 | ep_cfg = EP_CFG_EPTYPE(USB_ENDPOINT_XFER_BULK); |
| 2055 | 2054 | |
| 2056 | − if ((priv_dev->dev_ver == DEV_VER_V2 && !priv_ep->dir) || | |
| 2057 | − priv_dev->dev_ver > DEV_VER_V2) | |
| 2055 | + if (priv_dev->dev_ver >= DEV_VER_V2 && !priv_ep->dir) | |
| 2058 | 2056 | ep_cfg |= EP_CFG_TDL_CHK; |
| 2059 | 2057 | break; |
| 2060 | 2058 | default: |
| @@ -1517,13 +1517,14 @@ irqreturn_t cdnsp_thread_irq_handler(int irq, void *data) · 1516 unmodified lines | ||
| 1517 | 1517 | { |
| 1518 | 1518 | struct cdnsp_device *pdev = (struct cdnsp_device *)data; |
| 1519 | 1519 | union cdnsp_trb *event_ring_deq; |
| 1520 | + unsigned long flags; | |
| 1520 | 1521 | int counter = 0; |
| 1521 | 1522 | |
| 1522 | − spin_lock(&pdev->lock); | |
| 1523 | + spin_lock_irqsave(&pdev->lock, flags); | |
| 1523 | 1524 | |
| 1524 | 1525 | if (pdev->cdnsp_state & (CDNSP_STATE_HALTED | CDNSP_STATE_DYING)) { |
| 1525 | 1526 | cdnsp_died(pdev); |
| 1526 | − spin_unlock(&pdev->lock); | |
| 1527 | + spin_unlock_irqrestore(&pdev->lock, flags); | |
| 1527 | 1528 | return IRQ_HANDLED; |
| 1528 | 1529 | } |
| 1529 | 1530 | |
| @@ -1539,7 +1540,7 @@ irqreturn_t cdnsp_thread_irq_handler(int irq, void *data) · 9 unmodified lines | ||
| 1539 | 1540 | |
| 1540 | 1541 | cdnsp_update_erst_dequeue(pdev, event_ring_deq, 1); |
| 1541 | 1542 | |
| 1542 | − spin_unlock(&pdev->lock); | |
| 1543 | + spin_unlock_irqrestore(&pdev->lock, flags); | |
| 1543 | 1544 | |
| 1544 | 1545 | return IRQ_HANDLED; |
| 1545 | 1546 | } |
| @@ -1690,11 +1690,6 @@ static int dwc3_remove(struct platform_device *pdev) · 1689 unmodified lines | ||
| 1690 | 1690 | return 0; |
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | −static void dwc3_shutdown(struct platform_device *pdev) | |
| 1694 | −{ | |
| 1695 | − dwc3_remove(pdev); | |
| 1696 | −} | |
| 1697 | − | |
| 1698 | 1693 | #ifdef CONFIG_PM |
| 1699 | 1694 | static int dwc3_core_init_for_resume(struct dwc3 *dwc) |
| 1700 | 1695 | { |
| @@ -2012,7 +2007,6 @@ MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match); · 311 unmodified lines | ||
| 2012 | 2007 | static struct platform_driver dwc3_driver = { |
| 2013 | 2008 | .probe = dwc3_probe, |
| 2014 | 2009 | .remove = dwc3_remove, |
| 2015 | − .shutdown = dwc3_shutdown, | |
| 2016 | 2010 | .driver = { |
| 2017 | 2011 | .name = "dwc3", |
| 2018 | 2012 | .of_match_table = of_match_ptr(of_dwc3_match), |
| @@ -413,9 +413,12 @@ static inline const char *dwc3_gadget_generic_cmd_status_string(int status) · 412 unmodified lines | ||
| 413 | 413 | |
| 414 | 414 | |
| 415 | 415 | #ifdef CONFIG_DEBUG_FS |
| 416 | +extern void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep); | |
| 416 | 417 | extern void dwc3_debugfs_init(struct dwc3 *d); |
| 417 | 418 | extern void dwc3_debugfs_exit(struct dwc3 *d); |
| 418 | 419 | #else |
| 420 | +static inline void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) | |
| 421 | +{ } | |
| 419 | 422 | static inline void dwc3_debugfs_init(struct dwc3 *d) |
| 420 | 423 | { } |
| 421 | 424 | static inline void dwc3_debugfs_exit(struct dwc3 *d) |
| @@ -886,30 +886,14 @@ static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep, · 885 unmodified lines | ||
| 886 | 886 | } |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | −static void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep, | |
| 890 | − struct dentry *parent) | |
| 889 | +void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) | |
| 891 | 890 | { |
| 892 | 891 | struct dentry *dir; |
| 893 | 892 | |
| 894 | − dir = debugfs_create_dir(dep->name, parent); | |
| 893 | + dir = debugfs_create_dir(dep->name, dep->dwc->root); | |
| 895 | 894 | dwc3_debugfs_create_endpoint_files(dep, dir); |
| 896 | 895 | } |
| 897 | 896 | |
| 898 | −static void dwc3_debugfs_create_endpoint_dirs(struct dwc3 *dwc, | |
| 899 | − struct dentry *parent) | |
| 900 | −{ | |
| 901 | − int i; | |
| 902 | − | |
| 903 | − for (i = 0; i < dwc->num_eps; i++) { | |
| 904 | − struct dwc3_ep *dep = dwc->eps[i]; | |
| 905 | − | |
| 906 | − if (!dep) | |
| 907 | − continue; | |
| 908 | − | |
| 909 | − dwc3_debugfs_create_endpoint_dir(dep, parent); | |
| 910 | − } | |
| 911 | −} | |
| 912 | − | |
| 913 | 897 | void dwc3_debugfs_init(struct dwc3 *dwc) |
| 914 | 898 | { |
| 915 | 899 | struct dentry *root; |
| @@ -940,7 +924,6 @@ void dwc3_debugfs_init(struct dwc3 *dwc) · 24 unmodified lines | ||
| 940 | 924 | &dwc3_testmode_fops); |
| 941 | 925 | debugfs_create_file("link_state", 0644, root, dwc, |
| 942 | 926 | &dwc3_link_state_fops); |
| 943 | − dwc3_debugfs_create_endpoint_dirs(dwc, root); | |
| 944 | 927 | } |
| 945 | 928 | } |
| 946 | 929 | |
| @@ -651,7 +651,7 @@ static int dwc3_meson_g12a_setup_regmaps(struct dwc3_meson_g12a *priv, · 650 unmodified lines | ||
| 651 | 651 | return PTR_ERR(priv->usb_glue_regmap); |
| 652 | 652 | |
| 653 | 653 | /* Create a regmap for each USB2 PHY control register set */ |
| 654 | − for (i = 0; i < priv->usb2_ports; i++) { | |
| 654 | + for (i = 0; i < priv->drvdata->num_phys; i++) { | |
| 655 | 655 | struct regmap_config u2p_regmap_config = { |
| 656 | 656 | .reg_bits = 8, |
| 657 | 657 | .val_bits = 32, |
| @@ -659,6 +659,9 @@ static int dwc3_meson_g12a_setup_regmaps(struct dwc3_meson_g12a *priv, · 1 unmodified line | ||
| 659 | 659 | .max_register = U2P_R1, |
| 660 | 660 | }; |
| 661 | 661 | |
| 662 | + if (!strstr(priv->drvdata->phy_names[i], "usb2")) | |
| 663 | + continue; | |
| 664 | + | |
| 662 | 665 | u2p_regmap_config.name = devm_kasprintf(priv->dev, GFP_KERNEL, |
| 663 | 666 | "u2p-%d", i); |
| 664 | 667 | if (!u2p_regmap_config.name) |
| @@ -772,13 +775,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) · 107 unmodified lines | ||
| 772 | 775 | |
| 773 | 776 | ret = priv->drvdata->usb_init(priv); |
| 774 | 777 | if (ret) |
| 775 | − goto err_disable_clks; | |
| 778 | + goto err_disable_regulator; | |
| 776 | 779 | |
| 777 | 780 | /* Init PHYs */ |
| 778 | 781 | for (i = 0 ; i < PHY_COUNT ; ++i) { |
| 779 | 782 | ret = phy_init(priv->phys[i]); |
| 780 | 783 | if (ret) |
| 781 | − goto err_disable_clks; | |
| 784 | + goto err_disable_regulator; | |
| 782 | 785 | } |
| 783 | 786 | |
| 784 | 787 | /* Set PHY Power */ |
| @@ -816,6 +819,10 @@ err_phys_exit: · 31 unmodified lines | ||
| 816 | 819 | for (i = 0 ; i < PHY_COUNT ; ++i) |
| 817 | 820 | phy_exit(priv->phys[i]); |
| 818 | 821 | |
| 822 | +err_disable_regulator: | |
| 823 | + if (priv->vbus) | |
| 824 | + regulator_disable(priv->vbus); | |
| 825 | + | |
| 819 | 826 | err_disable_clks: |
| 820 | 827 | clk_bulk_disable_unprepare(priv->drvdata->num_clks, |
| 821 | 828 | priv->drvdata->clks); |
| @@ -292,6 +292,9 @@ static struct dwc3_ep *dwc3_wIndex_to_dep(struct dwc3 *dwc, __le16 wIndex_le) · 291 unmodified lines | ||
| 292 | 292 | epnum |= 1; |
| 293 | 293 | |
| 294 | 294 | dep = dwc->eps[epnum]; |
| 295 | + if (dep == NULL) | |
| 296 | + return NULL; | |
| 297 | + | |
| 295 | 298 | if (dep->flags & DWC3_EP_ENABLED) |
| 296 | 299 | return dep; |
| 297 | 300 | |
| @@ -2261,13 +2261,10 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) · 2260 unmodified lines | ||
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | /* |
| 2264 | − * Synchronize any pending event handling before executing the controller | |
| 2265 | − * halt routine. | |
| 2264 | + * Synchronize and disable any further event handling while controller | |
| 2265 | + * is being enabled/disabled. | |
| 2266 | 2266 | */ |
| 2267 | − if (!is_on) { | |
| 2268 | − dwc3_gadget_disable_irq(dwc); | |
| 2269 | − synchronize_irq(dwc->irq_gadget); | |
| 2270 | − } | |
| 2267 | + disable_irq(dwc->irq_gadget); | |
| 2271 | 2268 | |
| 2272 | 2269 | spin_lock_irqsave(&dwc->lock, flags); |
| 2273 | 2270 | |
| @@ -2305,6 +2302,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) · 31 unmodified lines | ||
| 2305 | 2302 | |
| 2306 | 2303 | ret = dwc3_gadget_run_stop(dwc, is_on, false); |
| 2307 | 2304 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 2305 | + enable_irq(dwc->irq_gadget); | |
| 2306 | + | |
| 2308 | 2307 | pm_runtime_put(dwc->dev); |
| 2309 | 2308 | |
| 2310 | 2309 | return ret; |
| @@ -2754,6 +2753,8 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum) · 443 unmodified lines | ||
| 2754 | 2753 | INIT_LIST_HEAD(&dep->started_list); |
| 2755 | 2754 | INIT_LIST_HEAD(&dep->cancelled_list); |
| 2756 | 2755 | |
| 2756 | + dwc3_debugfs_create_endpoint_dir(dep); | |
| 2757 | + | |
| 2757 | 2758 | return 0; |
| 2758 | 2759 | } |
| 2759 | 2760 | |
| @@ -2797,6 +2798,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) · 37 unmodified lines | ||
| 2797 | 2798 | list_del(&dep->endpoint.ep_list); |
| 2798 | 2799 | } |
| 2799 | 2800 | |
| 2801 | + debugfs_remove_recursive(debugfs_lookup(dep->name, dwc->root)); | |
| 2800 | 2802 | kfree(dep); |
| 2801 | 2803 | } |
| 2802 | 2804 | } |
| @@ -4046,6 +4048,7 @@ err5: · 1243 unmodified lines | ||
| 4046 | 4048 | dwc3_gadget_free_endpoints(dwc); |
| 4047 | 4049 | err4: |
| 4048 | 4050 | usb_put_gadget(dwc->gadget); |
| 4051 | + dwc->gadget = NULL; | |
| 4049 | 4052 | err3: |
| 4050 | 4053 | dma_free_coherent(dwc->sysdev, DWC3_BOUNCE_SIZE, dwc->bounce, |
| 4051 | 4054 | dwc->bounce_addr); |
| @@ -4065,6 +4068,9 @@ err0: · 13 unmodified lines | ||
| 4065 | 4068 | |
| 4066 | 4069 | void dwc3_gadget_exit(struct dwc3 *dwc) |
| 4067 | 4070 | { |
| 4071 | + if (!dwc->gadget) | |
| 4072 | + return; | |
| 4073 | + | |
| 4068 | 4074 | usb_del_gadget(dwc->gadget); |
| 4069 | 4075 | dwc3_gadget_free_endpoints(dwc); |
| 4070 | 4076 | usb_put_gadget(dwc->gadget); |
| @@ -164,6 +164,14 @@ int usb_assign_descriptors(struct usb_function *f, · 163 unmodified lines | ||
| 164 | 164 | { |
| 165 | 165 | struct usb_gadget *g = f->config->cdev->gadget; |
| 166 | 166 | |
| 167 | + /* super-speed-plus descriptor falls back to super-speed one, | |
| 168 | + * if such a descriptor was provided, thus avoiding a NULL | |
| 169 | + * pointer dereference if a 5gbps capable gadget is used with | |
| 170 | + * a 10gbps capable config (device port + cable + host port) | |
| 171 | + */ | |
| 172 | + if (!ssp) | |
| 173 | + ssp = ss; | |
| 174 | + | |
| 167 | 175 | if (fs) { |
| 168 | 176 | f->fs_descriptors = usb_copy_descriptors(fs); |
| 169 | 177 | if (!f->fs_descriptors) |
| @@ -791,7 +791,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) · 790 unmodified lines | ||
| 791 | 791 | fs_ecm_notify_desc.bEndpointAddress; |
| 792 | 792 | |
| 793 | 793 | status = usb_assign_descriptors(f, ecm_fs_function, ecm_hs_function, |
| 794 | − ecm_ss_function, NULL); | |
| 794 | + ecm_ss_function, ecm_ss_function); | |
| 795 | 795 | if (status) |
| 796 | 796 | goto fail; |
| 797 | 797 | |
| @@ -302,7 +302,7 @@ static int eem_bind(struct usb_configuration *c, struct usb_function *f) · 301 unmodified lines | ||
| 302 | 302 | eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress; |
| 303 | 303 | |
| 304 | 304 | status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function, |
| 305 | − eem_ss_function, NULL); | |
| 305 | + eem_ss_function, eem_ss_function); | |
| 306 | 306 | if (status) |
| 307 | 307 | goto fail; |
| 308 | 308 | |
| @@ -495,7 +495,7 @@ static int eem_unwrap(struct gether *port, · 186 unmodified lines | ||
| 495 | 495 | skb2 = skb_clone(skb, GFP_ATOMIC); |
| 496 | 496 | if (unlikely(!skb2)) { |
| 497 | 497 | DBG(cdev, "unable to unframe EEM packet\n"); |
| 498 | − continue; | |
| 498 | + goto next; | |
| 499 | 499 | } |
| 500 | 500 | skb_trim(skb2, len - ETH_FCS_LEN); |
| 501 | 501 | |
| @@ -505,7 +505,7 @@ static int eem_unwrap(struct gether *port, · 3 unmodified lines | ||
| 505 | 505 | GFP_ATOMIC); |
| 506 | 506 | if (unlikely(!skb3)) { |
| 507 | 507 | dev_kfree_skb_any(skb2); |
| 508 | − continue; | |
| 508 | + goto next; | |
| 509 | 509 | } |
| 510 | 510 | dev_kfree_skb_any(skb2); |
| 511 | 511 | skb_queue_tail(list, skb3); |
| @@ -3567,6 +3567,9 @@ static void ffs_func_unbind(struct usb_configuration *c, · 3566 unmodified lines | ||
| 3567 | 3567 | ffs->func = NULL; |
| 3568 | 3568 | } |
| 3569 | 3569 | |
| 3570 | + /* Drain any pending AIO completions */ | |
| 3571 | + drain_workqueue(ffs->io_completion_wq); | |
| 3572 | + | |
| 3570 | 3573 | if (!--opts->refcnt) |
| 3571 | 3574 | functionfs_unbind(ffs); |
| 3572 | 3575 | |
| @@ -802,7 +802,8 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f) · 801 unmodified lines | ||
| 802 | 802 | hidg_fs_out_ep_desc.bEndpointAddress; |
| 803 | 803 | |
| 804 | 804 | status = usb_assign_descriptors(f, hidg_fs_descriptors, |
| 805 | − hidg_hs_descriptors, hidg_ss_descriptors, NULL); | |
| 805 | + hidg_hs_descriptors, hidg_ss_descriptors, | |
| 806 | + hidg_ss_descriptors); | |
| 806 | 807 | if (status) |
| 807 | 808 | goto fail; |
| 808 | 809 | |
| @@ -207,7 +207,7 @@ autoconf_fail: · 206 unmodified lines | ||
| 207 | 207 | ss_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress; |
| 208 | 208 | |
| 209 | 209 | ret = usb_assign_descriptors(f, fs_loopback_descs, hs_loopback_descs, |
| 210 | − ss_loopback_descs, NULL); | |
| 210 | + ss_loopback_descs, ss_loopback_descs); | |
| 211 | 211 | if (ret) |
| 212 | 212 | return ret; |
| 213 | 213 | |
| @@ -583,7 +583,7 @@ static void ncm_do_notify(struct f_ncm *ncm) · 582 unmodified lines | ||
| 583 | 583 | data[0] = cpu_to_le32(ncm_bitrate(cdev->gadget)); |
| 584 | 584 | data[1] = data[0]; |
| 585 | 585 | |
| 586 | − DBG(cdev, "notify speed %d\n", ncm_bitrate(cdev->gadget)); | |
| 586 | + DBG(cdev, "notify speed %u\n", ncm_bitrate(cdev->gadget)); | |
| 587 | 587 | ncm->notify_state = NCM_NOTIFY_CONNECT; |
| 588 | 588 | break; |
| 589 | 589 | } |
| @@ -1101,11 +1101,11 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, · 511 unmodified lines | ||
| 1101 | 1101 | ncm->ndp_dgram_count = 1; |
| 1102 | 1102 | |
| 1103 | 1103 | /* Note: we skip opts->next_ndp_index */ |
| 1104 | − } | |
| 1105 | 1104 | |
| 1106 | − /* Delay the timer. */ | |
| 1107 | − hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, | |
| 1108 | − HRTIMER_MODE_REL_SOFT); | |
| 1105 | + /* Start the timer. */ | |
| 1106 | + hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, | |
| 1107 | + HRTIMER_MODE_REL_SOFT); | |
| 1108 | + } | |
| 1109 | 1109 | |
| 1110 | 1110 | /* Add the datagram position entries */ |
| 1111 | 1111 | ntb_ndp = skb_put_zero(ncm->skb_tx_ndp, dgram_idx_len); |
| @@ -1101,7 +1101,8 @@ autoconf_fail: · 1100 unmodified lines | ||
| 1101 | 1101 | ss_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; |
| 1102 | 1102 | |
| 1103 | 1103 | ret = usb_assign_descriptors(f, fs_printer_function, |
| 1104 | − hs_printer_function, ss_printer_function, NULL); | |
| 1104 | + hs_printer_function, ss_printer_function, | |
| 1105 | + ss_printer_function); | |
| 1105 | 1106 | if (ret) |
| 1106 | 1107 | return ret; |
| 1107 | 1108 | |
| @@ -789,7 +789,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) · 788 unmodified lines | ||
| 789 | 789 | ss_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress; |
| 790 | 790 | |
| 791 | 791 | status = usb_assign_descriptors(f, eth_fs_function, eth_hs_function, |
| 792 | − eth_ss_function, NULL); | |
| 792 | + eth_ss_function, eth_ss_function); | |
| 793 | 793 | if (status) |
| 794 | 794 | goto fail; |
| 795 | 795 | |
| @@ -233,7 +233,7 @@ static int gser_bind(struct usb_configuration *c, struct usb_function *f) · 232 unmodified lines | ||
| 233 | 233 | gser_ss_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress; |
| 234 | 234 | |
| 235 | 235 | status = usb_assign_descriptors(f, gser_fs_function, gser_hs_function, |
| 236 | − gser_ss_function, NULL); | |
| 236 | + gser_ss_function, gser_ss_function); | |
| 237 | 237 | if (status) |
| 238 | 238 | goto fail; |
| 239 | 239 | dev_dbg(&cdev->gadget->dev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", |
| @@ -431,7 +431,8 @@ no_iso: · 430 unmodified lines | ||
| 431 | 431 | ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; |
| 432 | 432 | |
| 433 | 433 | ret = usb_assign_descriptors(f, fs_source_sink_descs, |
| 434 | − hs_source_sink_descs, ss_source_sink_descs, NULL); | |
| 434 | + hs_source_sink_descs, ss_source_sink_descs, | |
| 435 | + ss_source_sink_descs); | |
| 435 | 436 | if (ret) |
| 436 | 437 | return ret; |
| 437 | 438 | |
| @@ -358,7 +358,7 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) · 357 unmodified lines | ||
| 358 | 358 | fs_subset_out_desc.bEndpointAddress; |
| 359 | 359 | |
| 360 | 360 | status = usb_assign_descriptors(f, fs_eth_function, hs_eth_function, |
| 361 | − ss_eth_function, NULL); | |
| 361 | + ss_eth_function, ss_eth_function); | |
| 362 | 362 | if (status) |
| 363 | 363 | goto fail; |
| 364 | 364 | |
| @@ -2057,7 +2057,8 @@ static int tcm_bind(struct usb_configuration *c, struct usb_function *f) · 2056 unmodified lines | ||
| 2057 | 2057 | uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; |
| 2058 | 2058 | |
| 2059 | 2059 | ret = usb_assign_descriptors(f, uasp_fs_function_desc, |
| 2060 | − uasp_hs_function_desc, uasp_ss_function_desc, NULL); | |
| 2060 | + uasp_hs_function_desc, uasp_ss_function_desc, | |
| 2061 | + uasp_ss_function_desc); | |
| 2061 | 2062 | if (ret) |
| 2062 | 2063 | goto ep_fail; |
| 2063 | 2064 | |
| @@ -59,6 +59,7 @@ · 58 unmodified lines | ||
| 59 | 59 | #define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_XHCI 0x1138 |
| 60 | 60 | #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_XHCI 0x461e |
| 61 | 61 | |
| 62 | +#define PCI_DEVICE_ID_AMD_RENOIR_XHCI 0x1639 | |
| 62 | 63 | #define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9 |
| 63 | 64 | #define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba |
| 64 | 65 | #define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb |
| @@ -182,6 +183,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · 117 unmodified lines | ||
| 182 | 183 | (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_1))) |
| 183 | 184 | xhci->quirks |= XHCI_U2_DISABLE_WAKE; |
| 184 | 185 | |
| 186 | + if (pdev->vendor == PCI_VENDOR_ID_AMD && | |
| 187 | + pdev->device == PCI_DEVICE_ID_AMD_RENOIR_XHCI) | |
| 188 | + xhci->quirks |= XHCI_BROKEN_D3COLD; | |
| 189 | + | |
| 185 | 190 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { |
| 186 | 191 | xhci->quirks |= XHCI_LPM_SUPPORT; |
| 187 | 192 | xhci->quirks |= XHCI_INTEL_HOST; |
| @@ -539,7 +544,7 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) · 351 unmodified lines | ||
| 539 | 544 | * Systems with the TI redriver that loses port status change events |
| 540 | 545 | * need to have the registers polled during D3, so avoid D3cold. |
| 541 | 546 | */ |
| 542 | − if (xhci->quirks & XHCI_COMP_MODE_QUIRK) | |
| 547 | + if (xhci->quirks & (XHCI_COMP_MODE_QUIRK | XHCI_BROKEN_D3COLD)) | |
| 543 | 548 | pci_d3cold_disable(pdev); |
| 544 | 549 | |
| 545 | 550 | if (xhci->quirks & XHCI_PME_STUCK_QUIRK) |
| @@ -1892,6 +1892,7 @@ struct xhci_hcd { · 1891 unmodified lines | ||
| 1892 | 1892 | #define XHCI_DISABLE_SPARSE BIT_ULL(38) |
| 1893 | 1893 | #define XHCI_SG_TRB_CACHE_SIZE_QUIRK BIT_ULL(39) |
| 1894 | 1894 | #define XHCI_NO_SOFT_RETRY BIT_ULL(40) |
| 1895 | +#define XHCI_BROKEN_D3COLD BIT_ULL(41) | |
| 1895 | 1896 | |
| 1896 | 1897 | unsigned int num_active_eps; |
| 1897 | 1898 | unsigned int limit_active_eps; |
| @@ -263,6 +263,8 @@ static int __init brcmstb_usb_pinmap_probe(struct platform_device *pdev) · 262 unmodified lines | ||
| 263 | 263 | return -EINVAL; |
| 264 | 264 | |
| 265 | 265 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 266 | + if (!r) | |
| 267 | + return -EINVAL; | |
| 266 | 268 | |
| 267 | 269 | pdata = devm_kzalloc(&pdev->dev, |
| 268 | 270 | sizeof(*pdata) + |
| @@ -2009,9 +2009,8 @@ static void musb_pm_runtime_check_session(struct musb *musb) · 2008 unmodified lines | ||
| 2009 | 2009 | schedule_delayed_work(&musb->irq_work, |
| 2010 | 2010 | msecs_to_jiffies(1000)); |
| 2011 | 2011 | musb->quirk_retries--; |
| 2012 | − break; | |
| 2013 | 2012 | } |
| 2014 | − fallthrough; | |
| 2013 | + break; | |
| 2015 | 2014 | case MUSB_QUIRK_B_INVALID_VBUS_91: |
| 2016 | 2015 | if (musb->quirk_retries && !musb->flush_irq_work) { |
| 2017 | 2016 | musb_dbg(musb, |
| @@ -252,9 +252,11 @@ struct cp210x_serial_private { · 251 unmodified lines | ||
| 252 | 252 | u8 gpio_input; |
| 253 | 253 | #endif |
| 254 | 254 | u8 partnum; |
| 255 | + u32 fw_version; | |
| 255 | 256 | speed_t min_speed; |
| 256 | 257 | speed_t max_speed; |
| 257 | 258 | bool use_actual_rate; |
| 259 | + bool no_flow_control; | |
| 258 | 260 | }; |
| 259 | 261 | |
| 260 | 262 | enum cp210x_event_state { |
| @@ -398,6 +400,7 @@ struct cp210x_special_chars { · 137 unmodified lines | ||
| 398 | 400 | |
| 399 | 401 | /* CP210X_VENDOR_SPECIFIC values */ |
| 400 | 402 | #define CP210X_READ_2NCONFIG 0x000E |
| 403 | +#define CP210X_GET_FW_VER_2N 0x0010 | |
| 401 | 404 | #define CP210X_READ_LATCH 0x00C2 |
| 402 | 405 | #define CP210X_GET_PARTNUM 0x370B |
| 403 | 406 | #define CP210X_GET_PORTCONFIG 0x370C |
| @@ -537,6 +540,12 @@ struct cp210x_single_port_config { · 133 unmodified lines | ||
| 537 | 540 | #define CP210X_2NCONFIG_GPIO_RSTLATCH_IDX 587 |
| 538 | 541 | #define CP210X_2NCONFIG_GPIO_CONTROL_IDX 600 |
| 539 | 542 | |
| 543 | +/* CP2102N QFN20 port configuration values */ | |
| 544 | +#define CP2102N_QFN20_GPIO2_TXLED_MODE BIT(2) | |
| 545 | +#define CP2102N_QFN20_GPIO3_RXLED_MODE BIT(3) | |
| 546 | +#define CP2102N_QFN20_GPIO1_RS485_MODE BIT(4) | |
| 547 | +#define CP2102N_QFN20_GPIO0_CLK_MODE BIT(6) | |
| 548 | + | |
| 540 | 549 | /* CP210X_VENDOR_SPECIFIC, CP210X_WRITE_LATCH call writes these 0x2 bytes. */ |
| 541 | 550 | struct cp210x_gpio_write { |
| 542 | 551 | u8 mask; |
| @@ -1122,6 +1131,7 @@ static bool cp210x_termios_change(const struct ktermios *a, const struct ktermio · 579 unmodified lines | ||
| 1122 | 1131 | static void cp210x_set_flow_control(struct tty_struct *tty, |
| 1123 | 1132 | struct usb_serial_port *port, struct ktermios *old_termios) |
| 1124 | 1133 | { |
| 1134 | + struct cp210x_serial_private *priv = usb_get_serial_data(port->serial); | |
| 1125 | 1135 | struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); |
| 1126 | 1136 | struct cp210x_special_chars chars; |
| 1127 | 1137 | struct cp210x_flow_ctl flow_ctl; |
| @@ -1129,6 +1139,15 @@ static void cp210x_set_flow_control(struct tty_struct *tty, · 1 unmodified line | ||
| 1129 | 1139 | u32 ctl_hs; |
| 1130 | 1140 | int ret; |
| 1131 | 1141 | |
| 1142 | + /* | |
| 1143 | + * Some CP2102N interpret ulXonLimit as ulFlowReplace (erratum | |
| 1144 | + * CP2102N_E104). Report back that flow control is not supported. | |
| 1145 | + */ | |
| 1146 | + if (priv->no_flow_control) { | |
| 1147 | + tty->termios.c_cflag &= ~CRTSCTS; | |
| 1148 | + tty->termios.c_iflag &= ~(IXON | IXOFF); | |
| 1149 | + } | |
| 1150 | + | |
| 1132 | 1151 | if (old_termios && |
| 1133 | 1152 | C_CRTSCTS(tty) == (old_termios->c_cflag & CRTSCTS) && |
| 1134 | 1153 | I_IXON(tty) == (old_termios->c_iflag & IXON) && |
| @@ -1185,19 +1204,20 @@ static void cp210x_set_flow_control(struct tty_struct *tty, · 50 unmodified lines | ||
| 1185 | 1204 | port_priv->crtscts = false; |
| 1186 | 1205 | } |
| 1187 | 1206 | |
| 1188 | − if (I_IXOFF(tty)) | |
| 1207 | + if (I_IXOFF(tty)) { | |
| 1189 | 1208 | flow_repl |= CP210X_SERIAL_AUTO_RECEIVE; |
| 1190 | − else | |
| 1209 | + | |
| 1210 | + flow_ctl.ulXonLimit = cpu_to_le32(128); | |
| 1211 | + flow_ctl.ulXoffLimit = cpu_to_le32(128); | |
| 1212 | + } else { | |
| 1191 | 1213 | flow_repl &= ~CP210X_SERIAL_AUTO_RECEIVE; |
| 1214 | + } | |
| 1192 | 1215 | |
| 1193 | 1216 | if (I_IXON(tty)) |
| 1194 | 1217 | flow_repl |= CP210X_SERIAL_AUTO_TRANSMIT; |
| 1195 | 1218 | else |
| 1196 | 1219 | flow_repl &= ~CP210X_SERIAL_AUTO_TRANSMIT; |
| 1197 | 1220 | |
| 1198 | − flow_ctl.ulXonLimit = cpu_to_le32(128); | |
| 1199 | − flow_ctl.ulXoffLimit = cpu_to_le32(128); | |
| 1200 | − | |
| 1201 | 1221 | dev_dbg(&port->dev, "%s - ctrl = 0x%02x, flow = 0x%02x\n", __func__, |
| 1202 | 1222 | ctl_hs, flow_repl); |
| 1203 | 1223 | |
| @@ -1733,7 +1753,19 @@ static int cp2102n_gpioconf_init(struct usb_serial *serial) · 529 unmodified lines | ||
| 1733 | 1753 | priv->gpio_pushpull = (gpio_pushpull >> 3) & 0x0f; |
| 1734 | 1754 | |
| 1735 | 1755 | /* 0 indicates GPIO mode, 1 is alternate function */ |
| 1736 | − priv->gpio_altfunc = (gpio_ctrl >> 2) & 0x0f; | |
| 1756 | + if (priv->partnum == CP210X_PARTNUM_CP2102N_QFN20) { | |
| 1757 | + /* QFN20 is special... */ | |
| 1758 | + if (gpio_ctrl & CP2102N_QFN20_GPIO0_CLK_MODE) /* GPIO 0 */ | |
| 1759 | + priv->gpio_altfunc |= BIT(0); | |
| 1760 | + if (gpio_ctrl & CP2102N_QFN20_GPIO1_RS485_MODE) /* GPIO 1 */ | |
| 1761 | + priv->gpio_altfunc |= BIT(1); | |
| 1762 | + if (gpio_ctrl & CP2102N_QFN20_GPIO2_TXLED_MODE) /* GPIO 2 */ | |
| 1763 | + priv->gpio_altfunc |= BIT(2); | |
| 1764 | + if (gpio_ctrl & CP2102N_QFN20_GPIO3_RXLED_MODE) /* GPIO 3 */ | |
| 1765 | + priv->gpio_altfunc |= BIT(3); | |
| 1766 | + } else { | |
| 1767 | + priv->gpio_altfunc = (gpio_ctrl >> 2) & 0x0f; | |
| 1768 | + } | |
| 1737 | 1769 | |
| 1738 | 1770 | if (priv->partnum == CP210X_PARTNUM_CP2102N_QFN28) { |
| 1739 | 1771 | /* |
| @@ -1908,6 +1940,45 @@ static void cp210x_init_max_speed(struct usb_serial *serial) · 168 unmodified lines | ||
| 1908 | 1940 | priv->use_actual_rate = use_actual_rate; |
| 1909 | 1941 | } |
| 1910 | 1942 | |
| 1943 | +static int cp210x_get_fw_version(struct usb_serial *serial, u16 value) | |
| 1944 | +{ | |
| 1945 | + struct cp210x_serial_private *priv = usb_get_serial_data(serial); | |
| 1946 | + u8 ver[3]; | |
| 1947 | + int ret; | |
| 1948 | + | |
| 1949 | + ret = cp210x_read_vendor_block(serial, REQTYPE_DEVICE_TO_HOST, value, | |
| 1950 | + ver, sizeof(ver)); | |
| 1951 | + if (ret) | |
| 1952 | + return ret; | |
| 1953 | + | |
| 1954 | + dev_dbg(&serial->interface->dev, "%s - %d.%d.%d\n", __func__, | |
| 1955 | + ver[0], ver[1], ver[2]); | |
| 1956 | + | |
| 1957 | + priv->fw_version = ver[0] << 16 | ver[1] << 8 | ver[2]; | |
| 1958 | + | |
| 1959 | + return 0; | |
| 1960 | +} | |
| 1961 | + | |
| 1962 | +static void cp210x_determine_quirks(struct usb_serial *serial) | |
| 1963 | +{ | |
| 1964 | + struct cp210x_serial_private *priv = usb_get_serial_data(serial); | |
| 1965 | + int ret; | |
| 1966 | + | |
| 1967 | + switch (priv->partnum) { | |
| 1968 | + case CP210X_PARTNUM_CP2102N_QFN28: | |
| 1969 | + case CP210X_PARTNUM_CP2102N_QFN24: | |
| 1970 | + case CP210X_PARTNUM_CP2102N_QFN20: | |
| 1971 | + ret = cp210x_get_fw_version(serial, CP210X_GET_FW_VER_2N); | |
| 1972 | + if (ret) | |
| 1973 | + break; | |
| 1974 | + if (priv->fw_version <= 0x10004) | |
| 1975 | + priv->no_flow_control = true; | |
| 1976 | + break; | |
| 1977 | + default: | |
| 1978 | + break; | |
| 1979 | + } | |
| 1980 | +} | |
| 1981 | + | |
| 1911 | 1982 | static int cp210x_attach(struct usb_serial *serial) |
| 1912 | 1983 | { |
| 1913 | 1984 | int result; |
| @@ -1928,6 +1999,7 @@ static int cp210x_attach(struct usb_serial *serial) · 14 unmodified lines | ||
| 1928 | 1999 | |
| 1929 | 2000 | usb_set_serial_data(serial, priv); |
| 1930 | 2001 | |
| 2002 | + cp210x_determine_quirks(serial); | |
| 1931 | 2003 | cp210x_init_max_speed(serial); |
| 1932 | 2004 | |
| 1933 | 2005 | result = cp210x_gpio_init(serial); |
| @@ -611,6 +611,7 @@ static const struct usb_device_id id_table_combined[] = { · 610 unmodified lines | ||
| 611 | 611 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 612 | 612 | { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLX_PLUS_PID) }, |
| 613 | 613 | { USB_DEVICE(FTDI_VID, FTDI_NT_ORION_IO_PID) }, |
| 614 | + { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONMX_PID) }, | |
| 614 | 615 | { USB_DEVICE(FTDI_VID, FTDI_SYNAPSE_SS200_PID) }, |
| 615 | 616 | { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX_PID) }, |
| 616 | 617 | { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX2_PID) }, |
| @@ -581,6 +581,7 @@ · 580 unmodified lines | ||
| 581 | 581 | #define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */ |
| 582 | 582 | #define FTDI_NT_ORIONLX_PLUS_PID 0x7c91 /* OrionLX+ Substation Automation Platform */ |
| 583 | 583 | #define FTDI_NT_ORION_IO_PID 0x7c92 /* Orion I/O */ |
| 584 | +#define FTDI_NT_ORIONMX_PID 0x7c93 /* OrionMX */ | |
| 584 | 585 | |
| 585 | 586 | /* |
| 586 | 587 | * Synapse Wireless product ids (FTDI_VID) |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | /* |
| 3 | − * USB ZyXEL omni.net LCD PLUS driver | |
| 3 | + * USB ZyXEL omni.net driver | |
| 4 | 4 | * |
| 5 | 5 | * Copyright (C) 2013,2017 Johan Hovold <johan@kernel.org> |
| 6 | 6 | * |
| @@ -22,10 +22,11 @@ · 15 unmodified lines | ||
| 22 | 22 | #include <linux/usb/serial.h> |
| 23 | 23 | |
| 24 | 24 | #define DRIVER_AUTHOR "Alessandro Zummo" |
| 25 | −#define DRIVER_DESC "USB ZyXEL omni.net LCD PLUS Driver" | |
| 25 | +#define DRIVER_DESC "USB ZyXEL omni.net Driver" | |
| 26 | 26 | |
| 27 | 27 | #define ZYXEL_VENDOR_ID 0x0586 |
| 28 | 28 | #define ZYXEL_OMNINET_ID 0x1000 |
| 29 | +#define ZYXEL_OMNI_56K_PLUS_ID 0x1500 | |
| 29 | 30 | /* This one seems to be a re-branded ZyXEL device */ |
| 30 | 31 | #define BT_IGNITIONPRO_ID 0x2000 |
| 31 | 32 | |
| @@ -40,6 +41,7 @@ static void omninet_port_remove(struct usb_serial_port *port); · 8 unmodified lines | ||
| 40 | 41 | |
| 41 | 42 | static const struct usb_device_id id_table[] = { |
| 42 | 43 | { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, |
| 44 | + { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNI_56K_PLUS_ID) }, | |
| 43 | 45 | { USB_DEVICE(ZYXEL_VENDOR_ID, BT_IGNITIONPRO_ID) }, |
| 44 | 46 | { } /* Terminating entry */ |
| 45 | 47 | }; |
| @@ -50,7 +52,7 @@ static struct usb_serial_driver zyxel_omninet_device = { · 4 unmodified lines | ||
| 50 | 52 | .owner = THIS_MODULE, |
| 51 | 53 | .name = "omninet", |
| 52 | 54 | }, |
| 53 | − .description = "ZyXEL - omni.net lcd plus usb", | |
| 55 | + .description = "ZyXEL - omni.net usb", | |
| 54 | 56 | .id_table = id_table, |
| 55 | 57 | .num_bulk_out = 2, |
| 56 | 58 | .calc_num_ports = omninet_calc_num_ports, |
| @@ -416,7 +416,7 @@ static void qt2_close(struct usb_serial_port *port) · 415 unmodified lines | ||
| 416 | 416 | |
| 417 | 417 | /* flush the port transmit buffer */ |
| 418 | 418 | i = usb_control_msg(serial->dev, |
| 419 | − usb_rcvctrlpipe(serial->dev, 0), | |
| 419 | + usb_sndctrlpipe(serial->dev, 0), | |
| 420 | 420 | QT2_FLUSH_DEVICE, 0x40, 1, |
| 421 | 421 | port_priv->device_port, NULL, 0, QT2_USB_TIMEOUT); |
| 422 | 422 | |
| @@ -426,7 +426,7 @@ static void qt2_close(struct usb_serial_port *port) · 3 unmodified lines | ||
| 426 | 426 | |
| 427 | 427 | /* flush the port receive buffer */ |
| 428 | 428 | i = usb_control_msg(serial->dev, |
| 429 | − usb_rcvctrlpipe(serial->dev, 0), | |
| 429 | + usb_sndctrlpipe(serial->dev, 0), | |
| 430 | 430 | QT2_FLUSH_DEVICE, 0x40, 0, |
| 431 | 431 | port_priv->device_port, NULL, 0, QT2_USB_TIMEOUT); |
| 432 | 432 | |
| @@ -639,7 +639,7 @@ static int qt2_attach(struct usb_serial *serial) · 206 unmodified lines | ||
| 639 | 639 | int status; |
| 640 | 640 | |
| 641 | 641 | /* power on unit */ |
| 642 | − status = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | |
| 642 | + status = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | |
| 643 | 643 | 0xc2, 0x40, 0x8000, 0, NULL, 0, |
| 644 | 644 | QT2_USB_TIMEOUT); |
| 645 | 645 | if (status < 0) { |
| @@ -239,7 +239,7 @@ find_mux: · 238 unmodified lines | ||
| 239 | 239 | dev = class_find_device(&typec_mux_class, NULL, fwnode, |
| 240 | 240 | mux_fwnode_match); |
| 241 | 241 | |
| 242 | − return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER); | |
| 242 | + return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER); | |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
| @@ -582,10 +582,15 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc) · 581 unmodified lines | ||
| 582 | 582 | acpi_dev_free_resource_list(&resource_list); |
| 583 | 583 | |
| 584 | 584 | if (!pmc->iom_base) { |
| 585 | − put_device(&adev->dev); | |
| 585 | + acpi_dev_put(adev); | |
| 586 | 586 | return -ENOMEM; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | + if (IS_ERR(pmc->iom_base)) { | |
| 590 | + acpi_dev_put(adev); | |
| 591 | + return PTR_ERR(pmc->iom_base); | |
| 592 | + } | |
| 593 | + | |
| 589 | 594 | pmc->iom_adev = adev; |
| 590 | 595 | |
| 591 | 596 | return 0; |
| @@ -636,8 +641,10 @@ static int pmc_usb_probe(struct platform_device *pdev) · 44 unmodified lines | ||
| 636 | 641 | break; |
| 637 | 642 | |
| 638 | 643 | ret = pmc_usb_register_port(pmc, i, fwnode); |
| 639 | − if (ret) | |
| 644 | + if (ret) { | |
| 645 | + fwnode_handle_put(fwnode); | |
| 640 | 646 | goto err_remove_ports; |
| 647 | + } | |
| 641 | 648 | } |
| 642 | 649 | |
| 643 | 650 | platform_set_drvdata(pdev, pmc); |
| @@ -651,7 +658,7 @@ err_remove_ports: · 7 unmodified lines | ||
| 651 | 658 | usb_role_switch_unregister(pmc->port[i].usb_sw); |
| 652 | 659 | } |
| 653 | 660 | |
| 654 | − put_device(&pmc->iom_adev->dev); | |
| 661 | + acpi_dev_put(pmc->iom_adev); | |
| 655 | 662 | |
| 656 | 663 | return ret; |
| 657 | 664 | } |
| @@ -667,7 +674,7 @@ static int pmc_usb_remove(struct platform_device *pdev) · 9 unmodified lines | ||
| 667 | 674 | usb_role_switch_unregister(pmc->port[i].usb_sw); |
| 668 | 675 | } |
| 669 | 676 | |
| 670 | − put_device(&pmc->iom_adev->dev); | |
| 677 | + acpi_dev_put(pmc->iom_adev); | |
| 671 | 678 | |
| 672 | 679 | return 0; |
| 673 | 680 | } |
| @@ -401,6 +401,8 @@ struct tcpm_port { · 400 unmodified lines | ||
| 401 | 401 | unsigned int nr_src_pdo; |
| 402 | 402 | u32 snk_pdo[PDO_MAX_OBJECTS]; |
| 403 | 403 | unsigned int nr_snk_pdo; |
| 404 | + u32 snk_vdo_v1[VDO_MAX_OBJECTS]; | |
| 405 | + unsigned int nr_snk_vdo_v1; | |
| 404 | 406 | u32 snk_vdo[VDO_MAX_OBJECTS]; |
| 405 | 407 | unsigned int nr_snk_vdo; |
| 406 | 408 | |
| @@ -1547,42 +1549,45 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, · 1140 unmodified lines | ||
| 1547 | 1549 | if (PD_VDO_VID(p[0]) != USB_SID_PD) |
| 1548 | 1550 | break; |
| 1549 | 1551 | |
| 1550 | − if (PD_VDO_SVDM_VER(p[0]) < svdm_version) | |
| 1552 | + if (PD_VDO_SVDM_VER(p[0]) < svdm_version) { | |
| 1551 | 1553 | typec_partner_set_svdm_version(port->partner, |
| 1552 | 1554 | PD_VDO_SVDM_VER(p[0])); |
| 1555 | + svdm_version = PD_VDO_SVDM_VER(p[0]); | |
| 1556 | + } | |
| 1553 | 1557 | |
| 1554 | − tcpm_ams_start(port, DISCOVER_IDENTITY); | |
| 1555 | − /* 6.4.4.3.1: Only respond as UFP (device) */ | |
| 1556 | − if (port->data_role == TYPEC_DEVICE && | |
| 1558 | + port->ams = DISCOVER_IDENTITY; | |
| 1559 | + /* | |
| 1560 | + * PD2.0 Spec 6.10.3: respond with NAK as DFP (data host) | |
| 1561 | + * PD3.1 Spec 6.4.4.2.5.1: respond with NAK if "invalid field" or | |
| 1562 | + * "wrong configuation" or "Unrecognized" | |
| 1563 | + */ | |
| 1564 | + if ((port->data_role == TYPEC_DEVICE || svdm_version >= SVDM_VER_2_0) && | |
| 1557 | 1565 | port->nr_snk_vdo) { |
| 1558 | − /* | |
| 1559 | − * Product Type DFP and Connector Type are not defined in SVDM | |
| 1560 | − * version 1.0 and shall be set to zero. | |
| 1561 | − */ | |
| 1562 | − if (typec_get_negotiated_svdm_version(typec) < SVDM_VER_2_0) | |
| 1563 | − response[1] = port->snk_vdo[0] & ~IDH_DFP_MASK | |
| 1564 | − & ~IDH_CONN_MASK; | |
| 1565 | − else | |
| 1566 | − response[1] = port->snk_vdo[0]; | |
| 1567 | − for (i = 1; i < port->nr_snk_vdo; i++) | |
| 1568 | − response[i + 1] = port->snk_vdo[i]; | |
| 1569 | − rlen = port->nr_snk_vdo + 1; | |
| 1566 | + if (svdm_version < SVDM_VER_2_0) { | |
| 1567 | + for (i = 0; i < port->nr_snk_vdo_v1; i++) | |
| 1568 | + response[i + 1] = port->snk_vdo_v1[i]; | |
| 1569 | + rlen = port->nr_snk_vdo_v1 + 1; | |
| 1570 | + | |
| 1571 | + } else { | |
| 1572 | + for (i = 0; i < port->nr_snk_vdo; i++) | |
| 1573 | + response[i + 1] = port->snk_vdo[i]; | |
| 1574 | + rlen = port->nr_snk_vdo + 1; | |
| 1575 | + } | |
| 1570 | 1576 | } |
| 1571 | 1577 | break; |
| 1572 | 1578 | case CMD_DISCOVER_SVID: |
| 1573 | − tcpm_ams_start(port, DISCOVER_SVIDS); | |
| 1579 | + port->ams = DISCOVER_SVIDS; | |
| 1574 | 1580 | break; |
| 1575 | 1581 | case CMD_DISCOVER_MODES: |
| 1576 | − tcpm_ams_start(port, DISCOVER_MODES); | |
| 1582 | + port->ams = DISCOVER_MODES; | |
| 1577 | 1583 | break; |
| 1578 | 1584 | case CMD_ENTER_MODE: |
| 1579 | − tcpm_ams_start(port, DFP_TO_UFP_ENTER_MODE); | |
| 1585 | + port->ams = DFP_TO_UFP_ENTER_MODE; | |
| 1580 | 1586 | break; |
| 1581 | 1587 | case CMD_EXIT_MODE: |
| 1582 | − tcpm_ams_start(port, DFP_TO_UFP_EXIT_MODE); | |
| 1588 | + port->ams = DFP_TO_UFP_EXIT_MODE; | |
| 1583 | 1589 | break; |
| 1584 | 1590 | case CMD_ATTENTION: |
| 1585 | − tcpm_ams_start(port, ATTENTION); | |
| 1586 | 1591 | /* Attention command does not have response */ |
| 1587 | 1592 | *adev_action = ADEV_ATTENTION; |
| 1588 | 1593 | return 0; |
| @@ -1937,6 +1942,9 @@ static void vdm_run_state_machine(struct tcpm_port *port) · 348 unmodified lines | ||
| 1937 | 1942 | tcpm_log(port, "VDM Tx error, retry"); |
| 1938 | 1943 | port->vdm_retries++; |
| 1939 | 1944 | port->vdm_state = VDM_STATE_READY; |
| 1945 | + if (PD_VDO_SVDM(vdo_hdr) && PD_VDO_CMDT(vdo_hdr) == CMDT_INIT) | |
| 1946 | + tcpm_ams_finish(port); | |
| 1947 | + } else { | |
| 1940 | 1948 | tcpm_ams_finish(port); |
| 1941 | 1949 | } |
| 1942 | 1950 | break; |
| @@ -2183,20 +2191,25 @@ static void tcpm_handle_alert(struct tcpm_port *port, const __le32 *payload, · 240 unmodified lines | ||
| 2183 | 2191 | |
| 2184 | 2192 | if (!type) { |
| 2185 | 2193 | tcpm_log(port, "Alert message received with no type"); |
| 2194 | + tcpm_queue_message(port, PD_MSG_CTRL_NOT_SUPP); | |
| 2186 | 2195 | return; |
| 2187 | 2196 | } |
| 2188 | 2197 | |
| 2189 | 2198 | /* Just handling non-battery alerts for now */ |
| 2190 | 2199 | if (!(type & USB_PD_ADO_TYPE_BATT_STATUS_CHANGE)) { |
| 2191 | − switch (port->state) { | |
| 2192 | − case SRC_READY: | |
| 2193 | − case SNK_READY: | |
| 2200 | + if (port->pwr_role == TYPEC_SOURCE) { | |
| 2201 | + port->upcoming_state = GET_STATUS_SEND; | |
| 2202 | + tcpm_ams_start(port, GETTING_SOURCE_SINK_STATUS); | |
| 2203 | + } else { | |
| 2204 | + /* | |
| 2205 | + * Do not check SinkTxOk here in case the Source doesn't set its Rp to | |
| 2206 | + * SinkTxOk in time. | |
| 2207 | + */ | |
| 2208 | + port->ams = GETTING_SOURCE_SINK_STATUS; | |
| 2194 | 2209 | tcpm_set_state(port, GET_STATUS_SEND, 0); |
| 2195 | − break; | |
| 2196 | − default: | |
| 2197 | − tcpm_queue_message(port, PD_MSG_CTRL_WAIT); | |
| 2198 | − break; | |
| 2199 | 2210 | } |
| 2211 | + } else { | |
| 2212 | + tcpm_queue_message(port, PD_MSG_CTRL_NOT_SUPP); | |
| 2200 | 2213 | } |
| 2201 | 2214 | } |
| 2202 | 2215 | |
| @@ -2440,7 +2453,12 @@ static void tcpm_pd_data_request(struct tcpm_port *port, · 237 unmodified lines | ||
| 2440 | 2453 | tcpm_pd_handle_state(port, BIST_RX, BIST, 0); |
| 2441 | 2454 | break; |
| 2442 | 2455 | case PD_DATA_ALERT: |
| 2443 | − tcpm_handle_alert(port, msg->payload, cnt); | |
| 2456 | + if (port->state != SRC_READY && port->state != SNK_READY) | |
| 2457 | + tcpm_pd_handle_state(port, port->pwr_role == TYPEC_SOURCE ? | |
| 2458 | + SRC_SOFT_RESET_WAIT_SNK_TX : SNK_SOFT_RESET, | |
| 2459 | + NONE_AMS, 0); | |
| 2460 | + else | |
| 2461 | + tcpm_handle_alert(port, msg->payload, cnt); | |
| 2444 | 2462 | break; |
| 2445 | 2463 | case PD_DATA_BATT_STATUS: |
| 2446 | 2464 | case PD_DATA_GET_COUNTRY_INFO: |
| @@ -2764,24 +2782,16 @@ static void tcpm_pd_ext_msg_request(struct tcpm_port *port, · 317 unmodified lines | ||
| 2764 | 2782 | |
| 2765 | 2783 | switch (type) { |
| 2766 | 2784 | case PD_EXT_STATUS: |
| 2767 | − /* | |
| 2768 | − * If PPS related events raised then get PPS status to clear | |
| 2769 | − * (see USB PD 3.0 Spec, 6.5.2.4) | |
| 2770 | − */ | |
| 2771 | − if (msg->ext_msg.data[USB_PD_EXT_SDB_EVENT_FLAGS] & | |
| 2772 | − USB_PD_EXT_SDB_PPS_EVENTS) | |
| 2773 | − tcpm_pd_handle_state(port, GET_PPS_STATUS_SEND, | |
| 2774 | − GETTING_SOURCE_SINK_STATUS, 0); | |
| 2775 | − | |
| 2776 | − else | |
| 2777 | − tcpm_pd_handle_state(port, ready_state(port), NONE_AMS, 0); | |
| 2778 | − break; | |
| 2779 | 2785 | case PD_EXT_PPS_STATUS: |
| 2780 | − /* | |
| 2781 | − * For now the PPS status message is used to clear events | |
| 2782 | − * and nothing more. | |
| 2783 | − */ | |
| 2784 | − tcpm_pd_handle_state(port, ready_state(port), NONE_AMS, 0); | |
| 2786 | + if (port->ams == GETTING_SOURCE_SINK_STATUS) { | |
| 2787 | + tcpm_ams_finish(port); | |
| 2788 | + tcpm_set_state(port, ready_state(port), 0); | |
| 2789 | + } else { | |
| 2790 | + /* unexpected Status or PPS_Status Message */ | |
| 2791 | + tcpm_pd_handle_state(port, port->pwr_role == TYPEC_SOURCE ? | |
| 2792 | + SRC_SOFT_RESET_WAIT_SNK_TX : SNK_SOFT_RESET, | |
| 2793 | + NONE_AMS, 0); | |
| 2794 | + } | |
| 2785 | 2795 | break; |
| 2786 | 2796 | case PD_EXT_SOURCE_CAP_EXT: |
| 2787 | 2797 | case PD_EXT_GET_BATT_CAP: |
| @@ -5947,6 +5957,22 @@ sink: · 3159 unmodified lines | ||
| 5947 | 5957 | return ret; |
| 5948 | 5958 | } |
| 5949 | 5959 | |
| 5960 | + /* If sink-vdos is found, sink-vdos-v1 is expected for backward compatibility. */ | |
| 5961 | + if (port->nr_snk_vdo) { | |
| 5962 | + ret = fwnode_property_count_u32(fwnode, "sink-vdos-v1"); | |
| 5963 | + if (ret < 0) | |
| 5964 | + return ret; | |
| 5965 | + else if (ret == 0) | |
| 5966 | + return -ENODATA; | |
| 5967 | + | |
| 5968 | + port->nr_snk_vdo_v1 = min(ret, VDO_MAX_OBJECTS); | |
| 5969 | + ret = fwnode_property_read_u32_array(fwnode, "sink-vdos-v1", | |
| 5970 | + port->snk_vdo_v1, | |
| 5971 | + port->nr_snk_vdo_v1); | |
| 5972 | + if (ret < 0) | |
| 5973 | + return ret; | |
| 5974 | + } | |
| 5975 | + | |
| 5950 | 5976 | return 0; |
| 5951 | 5977 | } |
| 5952 | 5978 | |
| @@ -6312,6 +6338,11 @@ void tcpm_unregister_port(struct tcpm_port *port) · 359 unmodified lines | ||
| 6312 | 6338 | { |
| 6313 | 6339 | int i; |
| 6314 | 6340 | |
| 6341 | + hrtimer_cancel(&port->send_discover_timer); | |
| 6342 | + hrtimer_cancel(&port->enable_frs_timer); | |
| 6343 | + hrtimer_cancel(&port->vdm_state_machine_timer); | |
| 6344 | + hrtimer_cancel(&port->state_machine_timer); | |
| 6345 | + | |
| 6315 | 6346 | tcpm_reset_port(port); |
| 6316 | 6347 | for (i = 0; i < ARRAY_SIZE(port->port_altmode); i++) |
| 6317 | 6348 | typec_unregister_altmode(port->port_altmode[i]); |
| @@ -378,7 +378,7 @@ static int wcove_pd_transmit(struct tcpc_dev *tcpc, · 377 unmodified lines | ||
| 378 | 378 | const u8 *data = (void *)msg; |
| 379 | 379 | int i; |
| 380 | 380 | |
| 381 | − for (i = 0; i < pd_header_cnt(msg->header) * 4 + 2; i++) { | |
| 381 | + for (i = 0; i < pd_header_cnt_le(msg->header) * 4 + 2; i++) { | |
| 382 | 382 | ret = regmap_write(wcove->regmap, USBC_TX_DATA + i, |
| 383 | 383 | data[i]); |
| 384 | 384 | if (ret) |
| @@ -1253,6 +1253,7 @@ err_unregister: · 1252 unmodified lines | ||
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | err_reset: |
| 1256 | + memset(&ucsi->cap, 0, sizeof(ucsi->cap)); | |
| 1256 | 1257 | ucsi_reset_ppm(ucsi); |
| 1257 | 1258 | err: |
| 1258 | 1259 | return ret; |
| @@ -2,6 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | config VFIO_PCI |
| 3 | 3 | tristate "VFIO support for PCI devices" |
| 4 | 4 | depends on VFIO && PCI && EVENTFD |
| 5 | + depends on MMU | |
| 5 | 6 | select VFIO_VIRQFD |
| 6 | 7 | select IRQ_BYPASS_MANAGER |
| 7 | 8 | help |
| @@ -1581,7 +1581,7 @@ static int vfio_ecap_init(struct vfio_pci_device *vdev) · 1580 unmodified lines | ||
| 1581 | 1581 | if (len == 0xFF) { |
| 1582 | 1582 | len = vfio_ext_cap_len(vdev, ecap, epos); |
| 1583 | 1583 | if (len < 0) |
| 1584 | − return ret; | |
| 1584 | + return len; | |
| 1585 | 1585 | } |
| 1586 | 1586 | } |
| 1587 | 1587 | |
| @@ -291,7 +291,7 @@ err_irq: · 290 unmodified lines | ||
| 291 | 291 | vfio_platform_regions_cleanup(vdev); |
| 292 | 292 | err_reg: |
| 293 | 293 | mutex_unlock(&driver_lock); |
| 294 | − module_put(THIS_MODULE); | |
| 294 | + module_put(vdev->parent_module); | |
| 295 | 295 | return ret; |
| 296 | 296 | } |
| 297 | 297 | |
| @@ -2795,7 +2795,7 @@ static int vfio_iommu_iova_build_caps(struct vfio_iommu *iommu, · 2794 unmodified lines | ||
| 2795 | 2795 | return 0; |
| 2796 | 2796 | } |
| 2797 | 2797 | |
| 2798 | − size = sizeof(*cap_iovas) + (iovas * sizeof(*cap_iovas->iova_ranges)); | |
| 2798 | + size = struct_size(cap_iovas, iova_ranges, iovas); | |
| 2799 | 2799 | |
| 2800 | 2800 | cap_iovas = kzalloc(size, GFP_KERNEL); |
| 2801 | 2801 | if (!cap_iovas) |
| @@ -52,6 +52,13 @@ static vm_fault_t fb_deferred_io_fault(struct vm_fault *vmf) · 51 unmodified lines | ||
| 52 | 52 | return VM_FAULT_SIGBUS; |
| 53 | 53 | |
| 54 | 54 | get_page(page); |
| 55 | + | |
| 56 | + if (vmf->vma->vm_file) | |
| 57 | + page->mapping = vmf->vma->vm_file->f_mapping; | |
| 58 | + else | |
| 59 | + printk(KERN_ERR "no mapping available\n"); | |
| 60 | + | |
| 61 | + BUG_ON(!page->mapping); | |
| 55 | 62 | page->index = vmf->pgoff; |
| 56 | 63 | |
| 57 | 64 | vmf->page = page; |
| @@ -144,6 +151,17 @@ static const struct vm_operations_struct fb_deferred_io_vm_ops = { · 86 unmodified lines | ||
| 144 | 151 | .page_mkwrite = fb_deferred_io_mkwrite, |
| 145 | 152 | }; |
| 146 | 153 | |
| 154 | +static int fb_deferred_io_set_page_dirty(struct page *page) | |
| 155 | +{ | |
| 156 | + if (!PageDirty(page)) | |
| 157 | + SetPageDirty(page); | |
| 158 | + return 0; | |
| 159 | +} | |
| 160 | + | |
| 161 | +static const struct address_space_operations fb_deferred_io_aops = { | |
| 162 | + .set_page_dirty = fb_deferred_io_set_page_dirty, | |
| 163 | +}; | |
| 164 | + | |
| 147 | 165 | int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) |
| 148 | 166 | { |
| 149 | 167 | vma->vm_ops = &fb_deferred_io_vm_ops; |
| @@ -194,12 +212,29 @@ void fb_deferred_io_init(struct fb_info *info) · 44 unmodified lines | ||
| 194 | 212 | } |
| 195 | 213 | EXPORT_SYMBOL_GPL(fb_deferred_io_init); |
| 196 | 214 | |
| 215 | +void fb_deferred_io_open(struct fb_info *info, | |
| 216 | + struct inode *inode, | |
| 217 | + struct file *file) | |
| 218 | +{ | |
| 219 | + file->f_mapping->a_ops = &fb_deferred_io_aops; | |
| 220 | +} | |
| 221 | +EXPORT_SYMBOL_GPL(fb_deferred_io_open); | |
| 222 | + | |
| 197 | 223 | void fb_deferred_io_cleanup(struct fb_info *info) |
| 198 | 224 | { |
| 199 | 225 | struct fb_deferred_io *fbdefio = info->fbdefio; |
| 226 | + struct page *page; | |
| 227 | + int i; | |
| 200 | 228 | |
| 201 | 229 | BUG_ON(!fbdefio); |
| 202 | 230 | cancel_delayed_work_sync(&info->deferred_work); |
| 231 | + | |
| 232 | + /* clear out the mapping that we setup */ | |
| 233 | + for (i = 0 ; i < info->fix.smem_len; i += PAGE_SIZE) { | |
| 234 | + page = fb_deferred_io_page(info, i); | |
| 235 | + page->mapping = NULL; | |
| 236 | + } | |
| 237 | + | |
| 203 | 238 | mutex_destroy(&fbdefio->lock); |
| 204 | 239 | } |
| 205 | 240 | EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup); |
| @@ -1415,6 +1415,10 @@ __releases(&info->lock) · 1414 unmodified lines | ||
| 1415 | 1415 | if (res) |
| 1416 | 1416 | module_put(info->fbops->owner); |
| 1417 | 1417 | } |
| 1418 | +#ifdef CONFIG_FB_DEFERRED_IO | |
| 1419 | + if (info->fbdefio) | |
| 1420 | + fb_deferred_io_open(info, inode, file); | |
| 1421 | +#endif | |
| 1418 | 1422 | out: |
| 1419 | 1423 | unlock_fb_info(info); |
| 1420 | 1424 | if (res) |
| @@ -730,7 +730,7 @@ static int afs_writepages_region(struct address_space *mapping, · 729 unmodified lines | ||
| 730 | 730 | return ret; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | − start += ret * PAGE_SIZE; | |
| 733 | + start += ret; | |
| 734 | 734 | |
| 735 | 735 | cond_resched(); |
| 736 | 736 | } while (wbc->nr_to_write > 0); |
| @@ -457,7 +457,7 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start, · 456 unmodified lines | ||
| 457 | 457 | bytes_left = compressed_len; |
| 458 | 458 | for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) { |
| 459 | 459 | int submit = 0; |
| 460 | − int len; | |
| 460 | + int len = 0; | |
| 461 | 461 | |
| 462 | 462 | page = compressed_pages[pg_index]; |
| 463 | 463 | page->mapping = inode->vfs_inode.i_mapping; |
| @@ -465,10 +465,17 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start, · 1 unmodified line | ||
| 465 | 465 | submit = btrfs_bio_fits_in_stripe(page, PAGE_SIZE, bio, |
| 466 | 466 | 0); |
| 467 | 467 | |
| 468 | − if (pg_index == 0 && use_append) | |
| 469 | − len = bio_add_zone_append_page(bio, page, PAGE_SIZE, 0); | |
| 470 | − else | |
| 471 | − len = bio_add_page(bio, page, PAGE_SIZE, 0); | |
| 468 | + /* | |
| 469 | + * Page can only be added to bio if the current bio fits in | |
| 470 | + * stripe. | |
| 471 | + */ | |
| 472 | + if (!submit) { | |
| 473 | + if (pg_index == 0 && use_append) | |
| 474 | + len = bio_add_zone_append_page(bio, page, | |
| 475 | + PAGE_SIZE, 0); | |
| 476 | + else | |
| 477 | + len = bio_add_page(bio, page, PAGE_SIZE, 0); | |
| 478 | + } | |
| 472 | 479 | |
| 473 | 480 | page->mapping = NULL; |
| 474 | 481 | if (submit || len < PAGE_SIZE) { |
| @@ -2648,6 +2648,24 @@ static int validate_super(struct btrfs_fs_info *fs_info, · 2647 unmodified lines | ||
| 2648 | 2648 | ret = -EINVAL; |
| 2649 | 2649 | } |
| 2650 | 2650 | |
| 2651 | + if (memcmp(fs_info->fs_devices->fsid, fs_info->super_copy->fsid, | |
| 2652 | + BTRFS_FSID_SIZE)) { | |
| 2653 | + btrfs_err(fs_info, | |
| 2654 | + "superblock fsid doesn't match fsid of fs_devices: %pU != %pU", | |
| 2655 | + fs_info->super_copy->fsid, fs_info->fs_devices->fsid); | |
| 2656 | + ret = -EINVAL; | |
| 2657 | + } | |
| 2658 | + | |
| 2659 | + if (btrfs_fs_incompat(fs_info, METADATA_UUID) && | |
| 2660 | + memcmp(fs_info->fs_devices->metadata_uuid, | |
| 2661 | + fs_info->super_copy->metadata_uuid, BTRFS_FSID_SIZE)) { | |
| 2662 | + btrfs_err(fs_info, | |
| 2663 | +"superblock metadata_uuid doesn't match metadata uuid of fs_devices: %pU != %pU", | |
| 2664 | + fs_info->super_copy->metadata_uuid, | |
| 2665 | + fs_info->fs_devices->metadata_uuid); | |
| 2666 | + ret = -EINVAL; | |
| 2667 | + } | |
| 2668 | + | |
| 2651 | 2669 | if (memcmp(fs_info->fs_devices->metadata_uuid, sb->dev_item.fsid, |
| 2652 | 2670 | BTRFS_FSID_SIZE) != 0) { |
| 2653 | 2671 | btrfs_err(fs_info, |
| @@ -3279,14 +3297,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device · 625 unmodified lines | ||
| 3279 | 3297 | |
| 3280 | 3298 | disk_super = fs_info->super_copy; |
| 3281 | 3299 | |
| 3282 | − ASSERT(!memcmp(fs_info->fs_devices->fsid, fs_info->super_copy->fsid, | |
| 3283 | − BTRFS_FSID_SIZE)); | |
| 3284 | − | |
| 3285 | − if (btrfs_fs_incompat(fs_info, METADATA_UUID)) { | |
| 3286 | − ASSERT(!memcmp(fs_info->fs_devices->metadata_uuid, | |
| 3287 | − fs_info->super_copy->metadata_uuid, | |
| 3288 | − BTRFS_FSID_SIZE)); | |
| 3289 | − } | |
| 3290 | 3300 | |
| 3291 | 3301 | features = btrfs_super_flags(disk_super); |
| 3292 | 3302 | if (features & BTRFS_SUPER_FLAG_CHANGING_FSID_V2) { |
| @@ -1868,7 +1868,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, · 1867 unmodified lines | ||
| 1868 | 1868 | trace_run_delayed_ref_head(fs_info, head, 0); |
| 1869 | 1869 | btrfs_delayed_ref_unlock(head); |
| 1870 | 1870 | btrfs_put_delayed_ref_head(head); |
| 1871 | − return 0; | |
| 1871 | + return ret; | |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | 1874 | static struct btrfs_delayed_ref_head *btrfs_obtain_ref_head( |
| @@ -788,7 +788,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, · 787 unmodified lines | ||
| 788 | 788 | u64 end_byte = bytenr + len; |
| 789 | 789 | u64 csum_end; |
| 790 | 790 | struct extent_buffer *leaf; |
| 791 | − int ret; | |
| 791 | + int ret = 0; | |
| 792 | 792 | const u32 csum_size = fs_info->csum_size; |
| 793 | 793 | u32 blocksize_bits = fs_info->sectorsize_bits; |
| 794 | 794 | |
| @@ -806,6 +806,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, · 11 unmodified lines | ||
| 806 | 806 | |
| 807 | 807 | ret = btrfs_search_slot(trans, root, &key, path, -1, 1); |
| 808 | 808 | if (ret > 0) { |
| 809 | + ret = 0; | |
| 809 | 810 | if (path->slots[0] == 0) |
| 810 | 811 | break; |
| 811 | 812 | path->slots[0]--; |
| @@ -862,7 +863,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, · 50 unmodified lines | ||
| 862 | 863 | ret = btrfs_del_items(trans, root, path, |
| 863 | 864 | path->slots[0], del_nr); |
| 864 | 865 | if (ret) |
| 865 | − goto out; | |
| 866 | + break; | |
| 866 | 867 | if (key.offset == bytenr) |
| 867 | 868 | break; |
| 868 | 869 | } else if (key.offset < bytenr && csum_end > end_byte) { |
| @@ -906,8 +907,9 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, · 37 unmodified lines | ||
| 906 | 907 | ret = btrfs_split_item(trans, root, path, &key, offset); |
| 907 | 908 | if (ret && ret != -EAGAIN) { |
| 908 | 909 | btrfs_abort_transaction(trans, ret); |
| 909 | − goto out; | |
| 910 | + break; | |
| 910 | 911 | } |
| 912 | + ret = 0; | |
| 911 | 913 | |
| 912 | 914 | key.offset = end_byte - 1; |
| 913 | 915 | } else { |
| @@ -917,12 +919,41 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, · 3 unmodified lines | ||
| 917 | 919 | } |
| 918 | 920 | btrfs_release_path(path); |
| 919 | 921 | } |
| 920 | − ret = 0; | |
| 921 | −out: | |
| 922 | 922 | btrfs_free_path(path); |
| 923 | 923 | return ret; |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | +static int find_next_csum_offset(struct btrfs_root *root, | |
| 927 | + struct btrfs_path *path, | |
| 928 | + u64 *next_offset) | |
| 929 | +{ | |
| 930 | + const u32 nritems = btrfs_header_nritems(path->nodes[0]); | |
| 931 | + struct btrfs_key found_key; | |
| 932 | + int slot = path->slots[0] + 1; | |
| 933 | + int ret; | |
| 934 | + | |
| 935 | + if (nritems == 0 || slot >= nritems) { | |
| 936 | + ret = btrfs_next_leaf(root, path); | |
| 937 | + if (ret < 0) { | |
| 938 | + return ret; | |
| 939 | + } else if (ret > 0) { | |
| 940 | + *next_offset = (u64)-1; | |
| 941 | + return 0; | |
| 942 | + } | |
| 943 | + slot = path->slots[0]; | |
| 944 | + } | |
| 945 | + | |
| 946 | + btrfs_item_key_to_cpu(path->nodes[0], &found_key, slot); | |
| 947 | + | |
| 948 | + if (found_key.objectid != BTRFS_EXTENT_CSUM_OBJECTID || | |
| 949 | + found_key.type != BTRFS_EXTENT_CSUM_KEY) | |
| 950 | + *next_offset = (u64)-1; | |
| 951 | + else | |
| 952 | + *next_offset = found_key.offset; | |
| 953 | + | |
| 954 | + return 0; | |
| 955 | +} | |
| 956 | + | |
| 926 | 957 | int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, |
| 927 | 958 | struct btrfs_root *root, |
| 928 | 959 | struct btrfs_ordered_sum *sums) |
| @@ -938,7 +969,6 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, · 9 unmodified lines | ||
| 938 | 969 | u64 total_bytes = 0; |
| 939 | 970 | u64 csum_offset; |
| 940 | 971 | u64 bytenr; |
| 941 | − u32 nritems; | |
| 942 | 972 | u32 ins_size; |
| 943 | 973 | int index = 0; |
| 944 | 974 | int found_next; |
| @@ -981,26 +1011,10 @@ again: · 36 unmodified lines | ||
| 981 | 1011 | goto insert; |
| 982 | 1012 | } |
| 983 | 1013 | } else { |
| 984 | − int slot = path->slots[0] + 1; | |
| 985 | − /* we didn't find a csum item, insert one */ | |
| 986 | − nritems = btrfs_header_nritems(path->nodes[0]); | |
| 987 | − if (!nritems || (path->slots[0] >= nritems - 1)) { | |
| 988 | − ret = btrfs_next_leaf(root, path); | |
| 989 | − if (ret < 0) { | |
| 990 | − goto out; | |
| 991 | − } else if (ret > 0) { | |
| 992 | − found_next = 1; | |
| 993 | − goto insert; | |
| 994 | − } | |
| 995 | − slot = path->slots[0]; | |
| 996 | − } | |
| 997 | − btrfs_item_key_to_cpu(path->nodes[0], &found_key, slot); | |
| 998 | − if (found_key.objectid != BTRFS_EXTENT_CSUM_OBJECTID || | |
| 999 | − found_key.type != BTRFS_EXTENT_CSUM_KEY) { | |
| 1000 | − found_next = 1; | |
| 1001 | − goto insert; | |
| 1002 | − } | |
| 1003 | − next_offset = found_key.offset; | |
| 1014 | + /* We didn't find a csum item, insert one. */ | |
| 1015 | + ret = find_next_csum_offset(root, path, &next_offset); | |
| 1016 | + if (ret < 0) | |
| 1017 | + goto out; | |
| 1004 | 1018 | found_next = 1; |
| 1005 | 1019 | goto insert; |
| 1006 | 1020 | } |
| @@ -1056,8 +1070,48 @@ extend_csum: · 49 unmodified lines | ||
| 1056 | 1070 | tmp = sums->len - total_bytes; |
| 1057 | 1071 | tmp >>= fs_info->sectorsize_bits; |
| 1058 | 1072 | WARN_ON(tmp < 1); |
| 1073 | + extend_nr = max_t(int, 1, tmp); | |
| 1074 | + | |
| 1075 | + /* | |
| 1076 | + * A log tree can already have checksum items with a subset of | |
| 1077 | + * the checksums we are trying to log. This can happen after | |
| 1078 | + * doing a sequence of partial writes into prealloc extents and | |
| 1079 | + * fsyncs in between, with a full fsync logging a larger subrange | |
| 1080 | + * of an extent for which a previous fast fsync logged a smaller | |
| 1081 | + * subrange. And this happens in particular due to merging file | |
| 1082 | + * extent items when we complete an ordered extent for a range | |
| 1083 | + * covered by a prealloc extent - this is done at | |
| 1084 | + * btrfs_mark_extent_written(). | |
| 1085 | + * | |
| 1086 | + * So if we try to extend the previous checksum item, which has | |
| 1087 | + * a range that ends at the start of the range we want to insert, | |
| 1088 | + * make sure we don't extend beyond the start offset of the next | |
| 1089 | + * checksum item. If we are at the last item in the leaf, then | |
| 1090 | + * forget the optimization of extending and add a new checksum | |
| 1091 | + * item - it is not worth the complexity of releasing the path, | |
| 1092 | + * getting the first key for the next leaf, repeat the btree | |
| 1093 | + * search, etc, because log trees are temporary anyway and it | |
| 1094 | + * would only save a few bytes of leaf space. | |
| 1095 | + */ | |
| 1096 | + if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { | |
| 1097 | + if (path->slots[0] + 1 >= | |
| 1098 | + btrfs_header_nritems(path->nodes[0])) { | |
| 1099 | + ret = find_next_csum_offset(root, path, &next_offset); | |
| 1100 | + if (ret < 0) | |
| 1101 | + goto out; | |
| 1102 | + found_next = 1; | |
| 1103 | + goto insert; | |
| 1104 | + } | |
| 1105 | + | |
| 1106 | + ret = find_next_csum_offset(root, path, &next_offset); | |
| 1107 | + if (ret < 0) | |
| 1108 | + goto out; | |
| 1109 | + | |
| 1110 | + tmp = (next_offset - bytenr) >> fs_info->sectorsize_bits; | |
| 1111 | + if (tmp <= INT_MAX) | |
| 1112 | + extend_nr = min_t(int, extend_nr, tmp); | |
| 1113 | + } | |
| 1059 | 1114 | |
| 1060 | − extend_nr = max_t(int, 1, (int)tmp); | |
| 1061 | 1115 | diff = (csum_offset + extend_nr) * csum_size; |
| 1062 | 1116 | diff = min(diff, |
| 1063 | 1117 | MAX_CSUM_ITEMS(fs_info, csum_size) * csum_size); |
| @@ -1094,7 +1094,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, · 1093 unmodified lines | ||
| 1094 | 1094 | int del_nr = 0; |
| 1095 | 1095 | int del_slot = 0; |
| 1096 | 1096 | int recow; |
| 1097 | − int ret; | |
| 1097 | + int ret = 0; | |
| 1098 | 1098 | u64 ino = btrfs_ino(inode); |
| 1099 | 1099 | |
| 1100 | 1100 | path = btrfs_alloc_path(); |
| @@ -1315,7 +1315,7 @@ again: · 214 unmodified lines | ||
| 1315 | 1315 | } |
| 1316 | 1316 | out: |
| 1317 | 1317 | btrfs_free_path(path); |
| 1318 | − return 0; | |
| 1318 | + return ret; | |
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | /* |
| @@ -3000,6 +3000,18 @@ out: · 2999 unmodified lines | ||
| 3000 | 3000 | if (ret || truncated) { |
| 3001 | 3001 | u64 unwritten_start = start; |
| 3002 | 3002 | |
| 3003 | + /* | |
| 3004 | + * If we failed to finish this ordered extent for any reason we | |
| 3005 | + * need to make sure BTRFS_ORDERED_IOERR is set on the ordered | |
| 3006 | + * extent, and mark the inode with the error if it wasn't | |
| 3007 | + * already set. Any error during writeback would have already | |
| 3008 | + * set the mapping error, so we need to set it if we're the ones | |
| 3009 | + * marking this ordered extent as failed. | |
| 3010 | + */ | |
| 3011 | + if (ret && !test_and_set_bit(BTRFS_ORDERED_IOERR, | |
| 3012 | + &ordered_extent->flags)) | |
| 3013 | + mapping_set_error(ordered_extent->inode->i_mapping, -EIO); | |
| 3014 | + | |
| 3003 | 3015 | if (truncated) |
| 3004 | 3016 | unwritten_start += logical_len; |
| 3005 | 3017 | clear_extent_uptodate(io_tree, unwritten_start, end, NULL); |
| @@ -9076,6 +9088,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, · 6070 unmodified lines | ||
| 9076 | 9088 | int ret2; |
| 9077 | 9089 | bool root_log_pinned = false; |
| 9078 | 9090 | bool dest_log_pinned = false; |
| 9091 | + bool need_abort = false; | |
| 9079 | 9092 | |
| 9080 | 9093 | /* we only allow rename subvolume link between subvolumes */ |
| 9081 | 9094 | if (old_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest) |
| @@ -9135,6 +9148,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, · 53 unmodified lines | ||
| 9135 | 9148 | old_idx); |
| 9136 | 9149 | if (ret) |
| 9137 | 9150 | goto out_fail; |
| 9151 | + need_abort = true; | |
| 9138 | 9152 | } |
| 9139 | 9153 | |
| 9140 | 9154 | /* And now for the dest. */ |
| @@ -9150,8 +9164,11 @@ static int btrfs_rename_exchange(struct inode *old_dir, · 9 unmodified lines | ||
| 9150 | 9164 | new_ino, |
| 9151 | 9165 | btrfs_ino(BTRFS_I(old_dir)), |
| 9152 | 9166 | new_idx); |
| 9153 | − if (ret) | |
| 9167 | + if (ret) { | |
| 9168 | + if (need_abort) | |
| 9169 | + btrfs_abort_transaction(trans, ret); | |
| 9154 | 9170 | goto out_fail; |
| 9171 | + } | |
| 9155 | 9172 | } |
| 9156 | 9173 | |
| 9157 | 9174 | /* Update inode version and ctime/mtime. */ |
| @@ -203,10 +203,7 @@ static int clone_copy_inline_extent(struct inode *dst, · 202 unmodified lines | ||
| 203 | 203 | * inline extent's data to the page. |
| 204 | 204 | */ |
| 205 | 205 | ASSERT(key.offset > 0); |
| 206 | − ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset, | |
| 207 | − inline_data, size, datal, | |
| 208 | − comp_type); | |
| 209 | − goto out; | |
| 206 | + goto copy_to_page; | |
| 210 | 207 | } |
| 211 | 208 | } else if (i_size_read(dst) <= datal) { |
| 212 | 209 | struct btrfs_file_extent_item *ei; |
| @@ -222,13 +219,10 @@ static int clone_copy_inline_extent(struct inode *dst, · 9 unmodified lines | ||
| 222 | 219 | BTRFS_FILE_EXTENT_INLINE) |
| 223 | 220 | goto copy_inline_extent; |
| 224 | 221 | |
| 225 | − ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset, | |
| 226 | − inline_data, size, datal, comp_type); | |
| 227 | − goto out; | |
| 222 | + goto copy_to_page; | |
| 228 | 223 | } |
| 229 | 224 | |
| 230 | 225 | copy_inline_extent: |
| 231 | − ret = 0; | |
| 232 | 226 | /* |
| 233 | 227 | * We have no extent items, or we have an extent at offset 0 which may |
| 234 | 228 | * or may not be inlined. All these cases are dealt the same way. |
| @@ -240,11 +234,13 @@ copy_inline_extent: · 5 unmodified lines | ||
| 240 | 234 | * clone. Deal with all these cases by copying the inline extent |
| 241 | 235 | * data into the respective page at the destination inode. |
| 242 | 236 | */ |
| 243 | − ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset, | |
| 244 | − inline_data, size, datal, comp_type); | |
| 245 | − goto out; | |
| 237 | + goto copy_to_page; | |
| 246 | 238 | } |
| 247 | 239 | |
| 240 | + /* | |
| 241 | + * Release path before starting a new transaction so we don't hold locks | |
| 242 | + * that would confuse lockdep. | |
| 243 | + */ | |
| 248 | 244 | btrfs_release_path(path); |
| 249 | 245 | /* |
| 250 | 246 | * If we end up here it means were copy the inline extent into a leaf |
| @@ -281,11 +277,6 @@ copy_inline_extent: · 30 unmodified lines | ||
| 281 | 277 | ret = btrfs_inode_set_file_extent_range(BTRFS_I(dst), 0, aligned_end); |
| 282 | 278 | out: |
| 283 | 279 | if (!ret && !trans) { |
| 284 | − /* | |
| 285 | − * Release path before starting a new transaction so we don't | |
| 286 | − * hold locks that would confuse lockdep. | |
| 287 | − */ | |
| 288 | − btrfs_release_path(path); | |
| 289 | 280 | /* |
| 290 | 281 | * No transaction here means we copied the inline extent into a |
| 291 | 282 | * page of the destination inode. |
| @@ -306,6 +297,21 @@ out: · 14 unmodified lines | ||
| 306 | 297 | *trans_out = trans; |
| 307 | 298 | |
| 308 | 299 | return ret; |
| 300 | + | |
| 301 | +copy_to_page: | |
| 302 | + /* | |
| 303 | + * Release our path because we don't need it anymore and also because | |
| 304 | + * copy_inline_to_page() needs to reserve data and metadata, which may | |
| 305 | + * need to flush delalloc when we are low on available space and | |
| 306 | + * therefore cause a deadlock if writeback of an inline extent needs to | |
| 307 | + * write to the same leaf or an ordered extent completion needs to write | |
| 308 | + * to the same leaf. | |
| 309 | + */ | |
| 310 | + btrfs_release_path(path); | |
| 311 | + | |
| 312 | + ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset, | |
| 313 | + inline_data, size, datal, comp_type); | |
| 314 | + goto out; | |
| 309 | 315 | } |
| 310 | 316 | |
| 311 | 317 | /** |
| @@ -1574,7 +1574,9 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, · 1573 unmodified lines | ||
| 1574 | 1574 | if (ret) |
| 1575 | 1575 | goto out; |
| 1576 | 1576 | |
| 1577 | − btrfs_update_inode(trans, root, BTRFS_I(inode)); | |
| 1577 | + ret = btrfs_update_inode(trans, root, BTRFS_I(inode)); | |
| 1578 | + if (ret) | |
| 1579 | + goto out; | |
| 1578 | 1580 | } |
| 1579 | 1581 | |
| 1580 | 1582 | ref_ptr = (unsigned long)(ref_ptr + ref_struct_size) + namelen; |
| @@ -1749,7 +1751,9 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, · 168 unmodified lines | ||
| 1749 | 1751 | |
| 1750 | 1752 | if (nlink != inode->i_nlink) { |
| 1751 | 1753 | set_nlink(inode, nlink); |
| 1752 | − btrfs_update_inode(trans, root, BTRFS_I(inode)); | |
| 1754 | + ret = btrfs_update_inode(trans, root, BTRFS_I(inode)); | |
| 1755 | + if (ret) | |
| 1756 | + goto out; | |
| 1753 | 1757 | } |
| 1754 | 1758 | BTRFS_I(inode)->index_cnt = (u64)-1; |
| 1755 | 1759 | |
| @@ -1787,6 +1791,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans, · 31 unmodified lines | ||
| 1787 | 1791 | break; |
| 1788 | 1792 | |
| 1789 | 1793 | if (ret == 1) { |
| 1794 | + ret = 0; | |
| 1790 | 1795 | if (path->slots[0] == 0) |
| 1791 | 1796 | break; |
| 1792 | 1797 | path->slots[0]--; |
| @@ -1799,17 +1804,19 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans, · 6 unmodified lines | ||
| 1799 | 1804 | |
| 1800 | 1805 | ret = btrfs_del_item(trans, root, path); |
| 1801 | 1806 | if (ret) |
| 1802 | − goto out; | |
| 1807 | + break; | |
| 1803 | 1808 | |
| 1804 | 1809 | btrfs_release_path(path); |
| 1805 | 1810 | inode = read_one_inode(root, key.offset); |
| 1806 | − if (!inode) | |
| 1807 | − return -EIO; | |
| 1811 | + if (!inode) { | |
| 1812 | + ret = -EIO; | |
| 1813 | + break; | |
| 1814 | + } | |
| 1808 | 1815 | |
| 1809 | 1816 | ret = fixup_inode_link_count(trans, root, inode); |
| 1810 | 1817 | iput(inode); |
| 1811 | 1818 | if (ret) |
| 1812 | − goto out; | |
| 1819 | + break; | |
| 1813 | 1820 | |
| 1814 | 1821 | /* |
| 1815 | 1822 | * fixup on a directory may create new entries, |
| @@ -1818,8 +1825,6 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans, · 2 unmodified lines | ||
| 1818 | 1825 | */ |
| 1819 | 1826 | key.offset = (u64)-1; |
| 1820 | 1827 | } |
| 1821 | − ret = 0; | |
| 1822 | −out: | |
| 1823 | 1828 | btrfs_release_path(path); |
| 1824 | 1829 | return ret; |
| 1825 | 1830 | } |
| @@ -3297,6 +3302,22 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, · 1471 unmodified lines | ||
| 3297 | 3302 | * begins and releases it only after writing its superblock. |
| 3298 | 3303 | */ |
| 3299 | 3304 | mutex_lock(&fs_info->tree_log_mutex); |
| 3305 | + | |
| 3306 | + /* | |
| 3307 | + * The previous transaction writeout phase could have failed, and thus | |
| 3308 | + * marked the fs in an error state. We must not commit here, as we | |
| 3309 | + * could have updated our generation in the super_for_commit and | |
| 3310 | + * writing the super here would result in transid mismatches. If there | |
| 3311 | + * is an error here just bail. | |
| 3312 | + */ | |
| 3313 | + if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) { | |
| 3314 | + ret = -EIO; | |
| 3315 | + btrfs_set_log_full_commit(trans); | |
| 3316 | + btrfs_abort_transaction(trans, ret); | |
| 3317 | + mutex_unlock(&fs_info->tree_log_mutex); | |
| 3318 | + goto out_wake_log_root; | |
| 3319 | + } | |
| 3320 | + | |
| 3300 | 3321 | btrfs_set_super_log_root(fs_info->super_for_commit, log_root_start); |
| 3301 | 3322 | btrfs_set_super_log_root_level(fs_info->super_for_commit, log_root_level); |
| 3302 | 3323 | ret = write_all_supers(fs_info, 1); |
| @@ -150,6 +150,18 @@ static inline u32 sb_zone_number(int shift, int mirror) · 149 unmodified lines | ||
| 150 | 150 | return (u32)zone; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | +static inline sector_t zone_start_sector(u32 zone_number, | |
| 154 | + struct block_device *bdev) | |
| 155 | +{ | |
| 156 | + return (sector_t)zone_number << ilog2(bdev_zone_sectors(bdev)); | |
| 157 | +} | |
| 158 | + | |
| 159 | +static inline u64 zone_start_physical(u32 zone_number, | |
| 160 | + struct btrfs_zoned_device_info *zone_info) | |
| 161 | +{ | |
| 162 | + return (u64)zone_number << zone_info->zone_size_shift; | |
| 163 | +} | |
| 164 | + | |
| 153 | 165 | /* |
| 154 | 166 | * Emulate blkdev_report_zones() for a non-zoned device. It slices up the block |
| 155 | 167 | * device into static sized chunks and fake a conventional zone on each of |
| @@ -405,8 +417,8 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device) · 249 unmodified lines | ||
| 405 | 417 | if (sb_zone + 1 >= zone_info->nr_zones) |
| 406 | 418 | continue; |
| 407 | 419 | |
| 408 | − sector = sb_zone << (zone_info->zone_size_shift - SECTOR_SHIFT); | |
| 409 | − ret = btrfs_get_dev_zones(device, sector << SECTOR_SHIFT, | |
| 420 | + ret = btrfs_get_dev_zones(device, | |
| 421 | + zone_start_physical(sb_zone, zone_info), | |
| 410 | 422 | &zone_info->sb_zones[sb_pos], |
| 411 | 423 | &nr_zones); |
| 412 | 424 | if (ret) |
| @@ -721,7 +733,7 @@ int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw, · 308 unmodified lines | ||
| 721 | 733 | if (sb_zone + 1 >= nr_zones) |
| 722 | 734 | return -ENOENT; |
| 723 | 735 | |
| 724 | − ret = blkdev_report_zones(bdev, sb_zone << zone_sectors_shift, | |
| 736 | + ret = blkdev_report_zones(bdev, zone_start_sector(sb_zone, bdev), | |
| 725 | 737 | BTRFS_NR_SB_LOG_ZONES, copy_zone_info_cb, |
| 726 | 738 | zones); |
| 727 | 739 | if (ret < 0) |
| @@ -826,7 +838,7 @@ int btrfs_reset_sb_log_zones(struct block_device *bdev, int mirror) · 98 unmodified lines | ||
| 826 | 838 | return -ENOENT; |
| 827 | 839 | |
| 828 | 840 | return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET, |
| 829 | − sb_zone << zone_sectors_shift, | |
| 841 | + zone_start_sector(sb_zone, bdev), | |
| 830 | 842 | zone_sectors * BTRFS_NR_SB_LOG_ZONES, GFP_NOFS); |
| 831 | 843 | } |
| 832 | 844 | |
| @@ -878,7 +890,8 @@ u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start, · 45 unmodified lines | ||
| 878 | 890 | if (!(end <= sb_zone || |
| 879 | 891 | sb_zone + BTRFS_NR_SB_LOG_ZONES <= begin)) { |
| 880 | 892 | have_sb = true; |
| 881 | − pos = ((u64)sb_zone + BTRFS_NR_SB_LOG_ZONES) << shift; | |
| 893 | + pos = zone_start_physical( | |
| 894 | + sb_zone + BTRFS_NR_SB_LOG_ZONES, zinfo); | |
| 882 | 895 | break; |
| 883 | 896 | } |
| 884 | 897 | |
| @@ -519,7 +519,7 @@ static bool dump_interrupted(void) · 518 unmodified lines | ||
| 519 | 519 | * but then we need to teach dump_write() to restart and clear |
| 520 | 520 | * TIF_SIGPENDING. |
| 521 | 521 | */ |
| 522 | − return signal_pending(current); | |
| 522 | + return fatal_signal_pending(current) || freezing(current); | |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | static void wait_for_dump_helpers(struct file *file) |
| @@ -893,7 +893,7 @@ ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf, · 892 unmodified lines | ||
| 893 | 893 | |
| 894 | 894 | copy[copy_len] = '\n'; |
| 895 | 895 | |
| 896 | − ret = simple_read_from_buffer(user_buf, count, ppos, copy, copy_len); | |
| 896 | + ret = simple_read_from_buffer(user_buf, count, ppos, copy, len); | |
| 897 | 897 | kfree(copy); |
| 898 | 898 | |
| 899 | 899 | return ret; |
| @@ -3206,7 +3206,10 @@ static int ext4_split_extent_at(handle_t *handle, · 3205 unmodified lines | ||
| 3206 | 3206 | ext4_ext_mark_unwritten(ex2); |
| 3207 | 3207 | |
| 3208 | 3208 | err = ext4_ext_insert_extent(handle, inode, ppath, &newex, flags); |
| 3209 | − if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) { | |
| 3209 | + if (err != -ENOSPC && err != -EDQUOT) | |
| 3210 | + goto out; | |
| 3211 | + | |
| 3212 | + if (EXT4_EXT_MAY_ZEROOUT & split_flag) { | |
| 3210 | 3213 | if (split_flag & (EXT4_EXT_DATA_VALID1|EXT4_EXT_DATA_VALID2)) { |
| 3211 | 3214 | if (split_flag & EXT4_EXT_DATA_VALID1) { |
| 3212 | 3215 | err = ext4_ext_zeroout(inode, ex2); |
| @@ -3232,25 +3235,22 @@ static int ext4_split_extent_at(handle_t *handle, · 19 unmodified lines | ||
| 3232 | 3235 | ext4_ext_pblock(&orig_ex)); |
| 3233 | 3236 | } |
| 3234 | 3237 | |
| 3235 | − if (err) | |
| 3236 | − goto fix_extent_len; | |
| 3237 | − /* update the extent length and mark as initialized */ | |
| 3238 | − ex->ee_len = cpu_to_le16(ee_len); | |
| 3239 | − ext4_ext_try_to_merge(handle, inode, path, ex); | |
| 3240 | − err = ext4_ext_dirty(handle, inode, path + path->p_depth); | |
| 3241 | − if (err) | |
| 3242 | − goto fix_extent_len; | |
| 3243 | − | |
| 3244 | − /* update extent status tree */ | |
| 3245 | − err = ext4_zeroout_es(inode, &zero_ex); | |
| 3246 | − | |
| 3247 | − goto out; | |
| 3248 | − } else if (err) | |
| 3249 | − goto fix_extent_len; | |
| 3250 | − | |
| 3251 | −out: | |
| 3252 | − ext4_ext_show_leaf(inode, path); | |
| 3253 | − return err; | |
| 3238 | + if (!err) { | |
| 3239 | + /* update the extent length and mark as initialized */ | |
| 3240 | + ex->ee_len = cpu_to_le16(ee_len); | |
| 3241 | + ext4_ext_try_to_merge(handle, inode, path, ex); | |
| 3242 | + err = ext4_ext_dirty(handle, inode, path + path->p_depth); | |
| 3243 | + if (!err) | |
| 3244 | + /* update extent status tree */ | |
| 3245 | + err = ext4_zeroout_es(inode, &zero_ex); | |
| 3246 | + /* If we failed at this point, we don't know in which | |
| 3247 | + * state the extent tree exactly is so don't try to fix | |
| 3248 | + * length of the original extent as it may do even more | |
| 3249 | + * damage. | |
| 3250 | + */ | |
| 3251 | + goto out; | |
| 3252 | + } | |
| 3253 | + } | |
| 3254 | 3254 | |
| 3255 | 3255 | fix_extent_len: |
| 3256 | 3256 | ex->ee_len = orig_ex.ee_len; |
| @@ -3260,6 +3260,9 @@ fix_extent_len: · 3 unmodified lines | ||
| 3260 | 3260 | */ |
| 3261 | 3261 | ext4_ext_dirty(handle, inode, path + path->p_depth); |
| 3262 | 3262 | return err; |
| 3263 | +out: | |
| 3264 | + ext4_ext_show_leaf(inode, path); | |
| 3265 | + return err; | |
| 3263 | 3266 | } |
| 3264 | 3267 | |
| 3265 | 3268 | /* |
| @@ -1288,28 +1288,29 @@ struct dentry_info_args { · 1287 unmodified lines | ||
| 1288 | 1288 | }; |
| 1289 | 1289 | |
| 1290 | 1290 | static inline void tl_to_darg(struct dentry_info_args *darg, |
| 1291 | − struct ext4_fc_tl *tl) | |
| 1291 | + struct ext4_fc_tl *tl, u8 *val) | |
| 1292 | 1292 | { |
| 1293 | − struct ext4_fc_dentry_info *fcd; | |
| 1293 | + struct ext4_fc_dentry_info fcd; | |
| 1294 | 1294 | |
| 1295 | − fcd = (struct ext4_fc_dentry_info *)ext4_fc_tag_val(tl); | |
| 1295 | + memcpy(&fcd, val, sizeof(fcd)); | |
| 1296 | 1296 | |
| 1297 | − darg->parent_ino = le32_to_cpu(fcd->fc_parent_ino); | |
| 1298 | − darg->ino = le32_to_cpu(fcd->fc_ino); | |
| 1299 | − darg->dname = fcd->fc_dname; | |
| 1300 | − darg->dname_len = ext4_fc_tag_len(tl) - | |
| 1301 | − sizeof(struct ext4_fc_dentry_info); | |
| 1297 | + darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino); | |
| 1298 | + darg->ino = le32_to_cpu(fcd.fc_ino); | |
| 1299 | + darg->dname = val + offsetof(struct ext4_fc_dentry_info, fc_dname); | |
| 1300 | + darg->dname_len = le16_to_cpu(tl->fc_len) - | |
| 1301 | + sizeof(struct ext4_fc_dentry_info); | |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | /* Unlink replay function */ |
| 1305 | −static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl) | |
| 1305 | +static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl, | |
| 1306 | + u8 *val) | |
| 1306 | 1307 | { |
| 1307 | 1308 | struct inode *inode, *old_parent; |
| 1308 | 1309 | struct qstr entry; |
| 1309 | 1310 | struct dentry_info_args darg; |
| 1310 | 1311 | int ret = 0; |
| 1311 | 1312 | |
| 1312 | − tl_to_darg(&darg, tl); | |
| 1313 | + tl_to_darg(&darg, tl, val); | |
| 1313 | 1314 | |
| 1314 | 1315 | trace_ext4_fc_replay(sb, EXT4_FC_TAG_UNLINK, darg.ino, |
| 1315 | 1316 | darg.parent_ino, darg.dname_len); |
| @@ -1399,13 +1400,14 @@ out: · 83 unmodified lines | ||
| 1399 | 1400 | } |
| 1400 | 1401 | |
| 1401 | 1402 | /* Link replay function */ |
| 1402 | −static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl) | |
| 1403 | +static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl, | |
| 1404 | + u8 *val) | |
| 1403 | 1405 | { |
| 1404 | 1406 | struct inode *inode; |
| 1405 | 1407 | struct dentry_info_args darg; |
| 1406 | 1408 | int ret = 0; |
| 1407 | 1409 | |
| 1408 | − tl_to_darg(&darg, tl); | |
| 1410 | + tl_to_darg(&darg, tl, val); | |
| 1409 | 1411 | trace_ext4_fc_replay(sb, EXT4_FC_TAG_LINK, darg.ino, |
| 1410 | 1412 | darg.parent_ino, darg.dname_len); |
| 1411 | 1413 | |
| @@ -1450,9 +1452,10 @@ static int ext4_fc_record_modified_inode(struct super_block *sb, int ino) · 38 unmodified lines | ||
| 1450 | 1452 | /* |
| 1451 | 1453 | * Inode replay function |
| 1452 | 1454 | */ |
| 1453 | −static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) | |
| 1455 | +static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl, | |
| 1456 | + u8 *val) | |
| 1454 | 1457 | { |
| 1455 | − struct ext4_fc_inode *fc_inode; | |
| 1458 | + struct ext4_fc_inode fc_inode; | |
| 1456 | 1459 | struct ext4_inode *raw_inode; |
| 1457 | 1460 | struct ext4_inode *raw_fc_inode; |
| 1458 | 1461 | struct inode *inode = NULL; |
| @@ -1460,9 +1463,9 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) · 1 unmodified line | ||
| 1460 | 1463 | int inode_len, ino, ret, tag = le16_to_cpu(tl->fc_tag); |
| 1461 | 1464 | struct ext4_extent_header *eh; |
| 1462 | 1465 | |
| 1463 | − fc_inode = (struct ext4_fc_inode *)ext4_fc_tag_val(tl); | |
| 1466 | + memcpy(&fc_inode, val, sizeof(fc_inode)); | |
| 1464 | 1467 | |
| 1465 | − ino = le32_to_cpu(fc_inode->fc_ino); | |
| 1468 | + ino = le32_to_cpu(fc_inode.fc_ino); | |
| 1466 | 1469 | trace_ext4_fc_replay(sb, tag, ino, 0, 0); |
| 1467 | 1470 | |
| 1468 | 1471 | inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL); |
| @@ -1474,12 +1477,13 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) · 5 unmodified lines | ||
| 1474 | 1477 | |
| 1475 | 1478 | ext4_fc_record_modified_inode(sb, ino); |
| 1476 | 1479 | |
| 1477 | − raw_fc_inode = (struct ext4_inode *)fc_inode->fc_raw_inode; | |
| 1480 | + raw_fc_inode = (struct ext4_inode *) | |
| 1481 | + (val + offsetof(struct ext4_fc_inode, fc_raw_inode)); | |
| 1478 | 1482 | ret = ext4_get_fc_inode_loc(sb, ino, &iloc); |
| 1479 | 1483 | if (ret) |
| 1480 | 1484 | goto out; |
| 1481 | 1485 | |
| 1482 | − inode_len = ext4_fc_tag_len(tl) - sizeof(struct ext4_fc_inode); | |
| 1486 | + inode_len = le16_to_cpu(tl->fc_len) - sizeof(struct ext4_fc_inode); | |
| 1483 | 1487 | raw_inode = ext4_raw_inode(&iloc); |
| 1484 | 1488 | |
| 1485 | 1489 | memcpy(raw_inode, raw_fc_inode, offsetof(struct ext4_inode, i_block)); |
| @@ -1547,14 +1551,15 @@ out: · 61 unmodified lines | ||
| 1547 | 1551 | * inode for which we are trying to create a dentry here, should already have |
| 1548 | 1552 | * been replayed before we start here. |
| 1549 | 1553 | */ |
| 1550 | −static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl) | |
| 1554 | +static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl, | |
| 1555 | + u8 *val) | |
| 1551 | 1556 | { |
| 1552 | 1557 | int ret = 0; |
| 1553 | 1558 | struct inode *inode = NULL; |
| 1554 | 1559 | struct inode *dir = NULL; |
| 1555 | 1560 | struct dentry_info_args darg; |
| 1556 | 1561 | |
| 1557 | − tl_to_darg(&darg, tl); | |
| 1562 | + tl_to_darg(&darg, tl, val); | |
| 1558 | 1563 | |
| 1559 | 1564 | trace_ext4_fc_replay(sb, EXT4_FC_TAG_CREAT, darg.ino, |
| 1560 | 1565 | darg.parent_ino, darg.dname_len); |
| @@ -1633,9 +1638,9 @@ static int ext4_fc_record_regions(struct super_block *sb, int ino, · 72 unmodified lines | ||
| 1633 | 1638 | |
| 1634 | 1639 | /* Replay add range tag */ |
| 1635 | 1640 | static int ext4_fc_replay_add_range(struct super_block *sb, |
| 1636 | − struct ext4_fc_tl *tl) | |
| 1641 | + struct ext4_fc_tl *tl, u8 *val) | |
| 1637 | 1642 | { |
| 1638 | − struct ext4_fc_add_range *fc_add_ex; | |
| 1643 | + struct ext4_fc_add_range fc_add_ex; | |
| 1639 | 1644 | struct ext4_extent newex, *ex; |
| 1640 | 1645 | struct inode *inode; |
| 1641 | 1646 | ext4_lblk_t start, cur; |
| @@ -1645,15 +1650,14 @@ static int ext4_fc_replay_add_range(struct super_block *sb, · 3 unmodified lines | ||
| 1645 | 1650 | struct ext4_ext_path *path = NULL; |
| 1646 | 1651 | int ret; |
| 1647 | 1652 | |
| 1648 | − fc_add_ex = (struct ext4_fc_add_range *)ext4_fc_tag_val(tl); | |
| 1649 | − ex = (struct ext4_extent *)&fc_add_ex->fc_ex; | |
| 1653 | + memcpy(&fc_add_ex, val, sizeof(fc_add_ex)); | |
| 1654 | + ex = (struct ext4_extent *)&fc_add_ex.fc_ex; | |
| 1650 | 1655 | |
| 1651 | 1656 | trace_ext4_fc_replay(sb, EXT4_FC_TAG_ADD_RANGE, |
| 1652 | − le32_to_cpu(fc_add_ex->fc_ino), le32_to_cpu(ex->ee_block), | |
| 1657 | + le32_to_cpu(fc_add_ex.fc_ino), le32_to_cpu(ex->ee_block), | |
| 1653 | 1658 | ext4_ext_get_actual_len(ex)); |
| 1654 | 1659 | |
| 1655 | − inode = ext4_iget(sb, le32_to_cpu(fc_add_ex->fc_ino), | |
| 1656 | − EXT4_IGET_NORMAL); | |
| 1660 | + inode = ext4_iget(sb, le32_to_cpu(fc_add_ex.fc_ino), EXT4_IGET_NORMAL); | |
| 1657 | 1661 | if (IS_ERR(inode)) { |
| 1658 | 1662 | jbd_debug(1, "Inode not found."); |
| 1659 | 1663 | return 0; |
| @@ -1762,32 +1766,33 @@ next: · 102 unmodified lines | ||
| 1762 | 1766 | |
| 1763 | 1767 | /* Replay DEL_RANGE tag */ |
| 1764 | 1768 | static int |
| 1765 | −ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl) | |
| 1769 | +ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl, | |
| 1770 | + u8 *val) | |
| 1766 | 1771 | { |
| 1767 | 1772 | struct inode *inode; |
| 1768 | − struct ext4_fc_del_range *lrange; | |
| 1773 | + struct ext4_fc_del_range lrange; | |
| 1769 | 1774 | struct ext4_map_blocks map; |
| 1770 | 1775 | ext4_lblk_t cur, remaining; |
| 1771 | 1776 | int ret; |
| 1772 | 1777 | |
| 1773 | − lrange = (struct ext4_fc_del_range *)ext4_fc_tag_val(tl); | |
| 1774 | − cur = le32_to_cpu(lrange->fc_lblk); | |
| 1775 | − remaining = le32_to_cpu(lrange->fc_len); | |
| 1778 | + memcpy(&lrange, val, sizeof(lrange)); | |
| 1779 | + cur = le32_to_cpu(lrange.fc_lblk); | |
| 1780 | + remaining = le32_to_cpu(lrange.fc_len); | |
| 1776 | 1781 | |
| 1777 | 1782 | trace_ext4_fc_replay(sb, EXT4_FC_TAG_DEL_RANGE, |
| 1778 | − le32_to_cpu(lrange->fc_ino), cur, remaining); | |
| 1783 | + le32_to_cpu(lrange.fc_ino), cur, remaining); | |
| 1779 | 1784 | |
| 1780 | − inode = ext4_iget(sb, le32_to_cpu(lrange->fc_ino), EXT4_IGET_NORMAL); | |
| 1785 | + inode = ext4_iget(sb, le32_to_cpu(lrange.fc_ino), EXT4_IGET_NORMAL); | |
| 1781 | 1786 | if (IS_ERR(inode)) { |
| 1782 | − jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange->fc_ino)); | |
| 1787 | + jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange.fc_ino)); | |
| 1783 | 1788 | return 0; |
| 1784 | 1789 | } |
| 1785 | 1790 | |
| 1786 | 1791 | ret = ext4_fc_record_modified_inode(sb, inode->i_ino); |
| 1787 | 1792 | |
| 1788 | 1793 | jbd_debug(1, "DEL_RANGE, inode %ld, lblk %d, len %d\n", |
| 1789 | − inode->i_ino, le32_to_cpu(lrange->fc_lblk), | |
| 1790 | − le32_to_cpu(lrange->fc_len)); | |
| 1794 | + inode->i_ino, le32_to_cpu(lrange.fc_lblk), | |
| 1795 | + le32_to_cpu(lrange.fc_len)); | |
| 1791 | 1796 | while (remaining > 0) { |
| 1792 | 1797 | map.m_lblk = cur; |
| 1793 | 1798 | map.m_len = remaining; |
| @@ -1808,8 +1813,8 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl) · 14 unmodified lines | ||
| 1808 | 1813 | } |
| 1809 | 1814 | |
| 1810 | 1815 | ret = ext4_punch_hole(inode, |
| 1811 | − le32_to_cpu(lrange->fc_lblk) << sb->s_blocksize_bits, | |
| 1812 | − le32_to_cpu(lrange->fc_len) << sb->s_blocksize_bits); | |
| 1816 | + le32_to_cpu(lrange.fc_lblk) << sb->s_blocksize_bits, | |
| 1817 | + le32_to_cpu(lrange.fc_len) << sb->s_blocksize_bits); | |
| 1813 | 1818 | if (ret) |
| 1814 | 1819 | jbd_debug(1, "ext4_punch_hole returned %d", ret); |
| 1815 | 1820 | ext4_ext_replay_shrink_inode(inode, |
| @@ -1925,11 +1930,11 @@ static int ext4_fc_replay_scan(journal_t *journal, · 109 unmodified lines | ||
| 1925 | 1930 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 1926 | 1931 | struct ext4_fc_replay_state *state; |
| 1927 | 1932 | int ret = JBD2_FC_REPLAY_CONTINUE; |
| 1928 | − struct ext4_fc_add_range *ext; | |
| 1929 | − struct ext4_fc_tl *tl; | |
| 1930 | − struct ext4_fc_tail *tail; | |
| 1931 | − __u8 *start, *end; | |
| 1932 | − struct ext4_fc_head *head; | |
| 1933 | + struct ext4_fc_add_range ext; | |
| 1934 | + struct ext4_fc_tl tl; | |
| 1935 | + struct ext4_fc_tail tail; | |
| 1936 | + __u8 *start, *end, *cur, *val; | |
| 1937 | + struct ext4_fc_head head; | |
| 1933 | 1938 | struct ext4_extent *ex; |
| 1934 | 1939 | |
| 1935 | 1940 | state = &sbi->s_fc_replay_state; |
| @@ -1956,15 +1961,17 @@ static int ext4_fc_replay_scan(journal_t *journal, · 20 unmodified lines | ||
| 1956 | 1961 | } |
| 1957 | 1962 | |
| 1958 | 1963 | state->fc_replay_expected_off++; |
| 1959 | − fc_for_each_tl(start, end, tl) { | |
| 1964 | + for (cur = start; cur < end; cur = cur + sizeof(tl) + le16_to_cpu(tl.fc_len)) { | |
| 1965 | + memcpy(&tl, cur, sizeof(tl)); | |
| 1966 | + val = cur + sizeof(tl); | |
| 1960 | 1967 | jbd_debug(3, "Scan phase, tag:%s, blk %lld\n", |
| 1961 | − tag2str(le16_to_cpu(tl->fc_tag)), bh->b_blocknr); | |
| 1962 | − switch (le16_to_cpu(tl->fc_tag)) { | |
| 1968 | + tag2str(le16_to_cpu(tl.fc_tag)), bh->b_blocknr); | |
| 1969 | + switch (le16_to_cpu(tl.fc_tag)) { | |
| 1963 | 1970 | case EXT4_FC_TAG_ADD_RANGE: |
| 1964 | − ext = (struct ext4_fc_add_range *)ext4_fc_tag_val(tl); | |
| 1965 | − ex = (struct ext4_extent *)&ext->fc_ex; | |
| 1971 | + memcpy(&ext, val, sizeof(ext)); | |
| 1972 | + ex = (struct ext4_extent *)&ext.fc_ex; | |
| 1966 | 1973 | ret = ext4_fc_record_regions(sb, |
| 1967 | − le32_to_cpu(ext->fc_ino), | |
| 1974 | + le32_to_cpu(ext.fc_ino), | |
| 1968 | 1975 | le32_to_cpu(ex->ee_block), ext4_ext_pblock(ex), |
| 1969 | 1976 | ext4_ext_get_actual_len(ex)); |
| 1970 | 1977 | if (ret < 0) |
| @@ -1978,18 +1985,18 @@ static int ext4_fc_replay_scan(journal_t *journal, · 7 unmodified lines | ||
| 1978 | 1985 | case EXT4_FC_TAG_INODE: |
| 1979 | 1986 | case EXT4_FC_TAG_PAD: |
| 1980 | 1987 | state->fc_cur_tag++; |
| 1981 | − state->fc_crc = ext4_chksum(sbi, state->fc_crc, tl, | |
| 1982 | − sizeof(*tl) + ext4_fc_tag_len(tl)); | |
| 1988 | + state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, | |
| 1989 | + sizeof(tl) + le16_to_cpu(tl.fc_len)); | |
| 1983 | 1990 | break; |
| 1984 | 1991 | case EXT4_FC_TAG_TAIL: |
| 1985 | 1992 | state->fc_cur_tag++; |
| 1986 | − tail = (struct ext4_fc_tail *)ext4_fc_tag_val(tl); | |
| 1987 | − state->fc_crc = ext4_chksum(sbi, state->fc_crc, tl, | |
| 1988 | − sizeof(*tl) + | |
| 1993 | + memcpy(&tail, val, sizeof(tail)); | |
| 1994 | + state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, | |
| 1995 | + sizeof(tl) + | |
| 1989 | 1996 | offsetof(struct ext4_fc_tail, |
| 1990 | 1997 | fc_crc)); |
| 1991 | − if (le32_to_cpu(tail->fc_tid) == expected_tid && | |
| 1992 | − le32_to_cpu(tail->fc_crc) == state->fc_crc) { | |
| 1998 | + if (le32_to_cpu(tail.fc_tid) == expected_tid && | |
| 1999 | + le32_to_cpu(tail.fc_crc) == state->fc_crc) { | |
| 1993 | 2000 | state->fc_replay_num_tags = state->fc_cur_tag; |
| 1994 | 2001 | state->fc_regions_valid = |
| 1995 | 2002 | state->fc_regions_used; |
| @@ -2000,19 +2007,19 @@ static int ext4_fc_replay_scan(journal_t *journal, · 4 unmodified lines | ||
| 2000 | 2007 | state->fc_crc = 0; |
| 2001 | 2008 | break; |
| 2002 | 2009 | case EXT4_FC_TAG_HEAD: |
| 2003 | − head = (struct ext4_fc_head *)ext4_fc_tag_val(tl); | |
| 2004 | − if (le32_to_cpu(head->fc_features) & | |
| 2010 | + memcpy(&head, val, sizeof(head)); | |
| 2011 | + if (le32_to_cpu(head.fc_features) & | |
| 2005 | 2012 | ~EXT4_FC_SUPPORTED_FEATURES) { |
| 2006 | 2013 | ret = -EOPNOTSUPP; |
| 2007 | 2014 | break; |
| 2008 | 2015 | } |
| 2009 | − if (le32_to_cpu(head->fc_tid) != expected_tid) { | |
| 2016 | + if (le32_to_cpu(head.fc_tid) != expected_tid) { | |
| 2010 | 2017 | ret = JBD2_FC_REPLAY_STOP; |
| 2011 | 2018 | break; |
| 2012 | 2019 | } |
| 2013 | 2020 | state->fc_cur_tag++; |
| 2014 | − state->fc_crc = ext4_chksum(sbi, state->fc_crc, tl, | |
| 2015 | − sizeof(*tl) + ext4_fc_tag_len(tl)); | |
| 2021 | + state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, | |
| 2022 | + sizeof(tl) + le16_to_cpu(tl.fc_len)); | |
| 2016 | 2023 | break; |
| 2017 | 2024 | default: |
| 2018 | 2025 | ret = state->fc_replay_num_tags ? |
| @@ -2036,11 +2043,11 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh, · 17 unmodified lines | ||
| 2036 | 2043 | { |
| 2037 | 2044 | struct super_block *sb = journal->j_private; |
| 2038 | 2045 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 2039 | − struct ext4_fc_tl *tl; | |
| 2040 | − __u8 *start, *end; | |
| 2046 | + struct ext4_fc_tl tl; | |
| 2047 | + __u8 *start, *end, *cur, *val; | |
| 2041 | 2048 | int ret = JBD2_FC_REPLAY_CONTINUE; |
| 2042 | 2049 | struct ext4_fc_replay_state *state = &sbi->s_fc_replay_state; |
| 2043 | − struct ext4_fc_tail *tail; | |
| 2050 | + struct ext4_fc_tail tail; | |
| 2044 | 2051 | |
| 2045 | 2052 | if (pass == PASS_SCAN) { |
| 2046 | 2053 | state->fc_current_pass = PASS_SCAN; |
| @@ -2067,49 +2074,52 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh, · 20 unmodified lines | ||
| 2067 | 2074 | start = (u8 *)bh->b_data; |
| 2068 | 2075 | end = (__u8 *)bh->b_data + journal->j_blocksize - 1; |
| 2069 | 2076 | |
| 2070 | − fc_for_each_tl(start, end, tl) { | |
| 2077 | + for (cur = start; cur < end; cur = cur + sizeof(tl) + le16_to_cpu(tl.fc_len)) { | |
| 2078 | + memcpy(&tl, cur, sizeof(tl)); | |
| 2079 | + val = cur + sizeof(tl); | |
| 2080 | + | |
| 2071 | 2081 | if (state->fc_replay_num_tags == 0) { |
| 2072 | 2082 | ret = JBD2_FC_REPLAY_STOP; |
| 2073 | 2083 | ext4_fc_set_bitmaps_and_counters(sb); |
| 2074 | 2084 | break; |
| 2075 | 2085 | } |
| 2076 | 2086 | jbd_debug(3, "Replay phase, tag:%s\n", |
| 2077 | − tag2str(le16_to_cpu(tl->fc_tag))); | |
| 2087 | + tag2str(le16_to_cpu(tl.fc_tag))); | |
| 2078 | 2088 | state->fc_replay_num_tags--; |
| 2079 | − switch (le16_to_cpu(tl->fc_tag)) { | |
| 2089 | + switch (le16_to_cpu(tl.fc_tag)) { | |
| 2080 | 2090 | case EXT4_FC_TAG_LINK: |
| 2081 | − ret = ext4_fc_replay_link(sb, tl); | |
| 2091 | + ret = ext4_fc_replay_link(sb, &tl, val); | |
| 2082 | 2092 | break; |
| 2083 | 2093 | case EXT4_FC_TAG_UNLINK: |
| 2084 | − ret = ext4_fc_replay_unlink(sb, tl); | |
| 2094 | + ret = ext4_fc_replay_unlink(sb, &tl, val); | |
| 2085 | 2095 | break; |
| 2086 | 2096 | case EXT4_FC_TAG_ADD_RANGE: |
| 2087 | − ret = ext4_fc_replay_add_range(sb, tl); | |
| 2097 | + ret = ext4_fc_replay_add_range(sb, &tl, val); | |
| 2088 | 2098 | break; |
| 2089 | 2099 | case EXT4_FC_TAG_CREAT: |
| 2090 | − ret = ext4_fc_replay_create(sb, tl); | |
| 2100 | + ret = ext4_fc_replay_create(sb, &tl, val); | |
| 2091 | 2101 | break; |
| 2092 | 2102 | case EXT4_FC_TAG_DEL_RANGE: |
| 2093 | − ret = ext4_fc_replay_del_range(sb, tl); | |
| 2103 | + ret = ext4_fc_replay_del_range(sb, &tl, val); | |
| 2094 | 2104 | break; |
| 2095 | 2105 | case EXT4_FC_TAG_INODE: |
| 2096 | − ret = ext4_fc_replay_inode(sb, tl); | |
| 2106 | + ret = ext4_fc_replay_inode(sb, &tl, val); | |
| 2097 | 2107 | break; |
| 2098 | 2108 | case EXT4_FC_TAG_PAD: |
| 2099 | 2109 | trace_ext4_fc_replay(sb, EXT4_FC_TAG_PAD, 0, |
| 2100 | − ext4_fc_tag_len(tl), 0); | |
| 2110 | + le16_to_cpu(tl.fc_len), 0); | |
| 2101 | 2111 | break; |
| 2102 | 2112 | case EXT4_FC_TAG_TAIL: |
| 2103 | 2113 | trace_ext4_fc_replay(sb, EXT4_FC_TAG_TAIL, 0, |
| 2104 | − ext4_fc_tag_len(tl), 0); | |
| 2105 | − tail = (struct ext4_fc_tail *)ext4_fc_tag_val(tl); | |
| 2106 | − WARN_ON(le32_to_cpu(tail->fc_tid) != expected_tid); | |
| 2114 | + le16_to_cpu(tl.fc_len), 0); | |
| 2115 | + memcpy(&tail, val, sizeof(tail)); | |
| 2116 | + WARN_ON(le32_to_cpu(tail.fc_tid) != expected_tid); | |
| 2107 | 2117 | break; |
| 2108 | 2118 | case EXT4_FC_TAG_HEAD: |
| 2109 | 2119 | break; |
| 2110 | 2120 | default: |
| 2111 | − trace_ext4_fc_replay(sb, le16_to_cpu(tl->fc_tag), 0, | |
| 2112 | − ext4_fc_tag_len(tl), 0); | |
| 2121 | + trace_ext4_fc_replay(sb, le16_to_cpu(tl.fc_tag), 0, | |
| 2122 | + le16_to_cpu(tl.fc_len), 0); | |
| 2113 | 2123 | ret = -ECANCELED; |
| 2114 | 2124 | break; |
| 2115 | 2125 | } |
| @@ -153,13 +153,6 @@ struct ext4_fc_replay_state { · 152 unmodified lines | ||
| 153 | 153 | #define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1) |
| 154 | 154 | #endif |
| 155 | 155 | |
| 156 | −#define fc_for_each_tl(__start, __end, __tl) \ | |
| 157 | − for (tl = (struct ext4_fc_tl *)(__start); \ | |
| 158 | − (__u8 *)tl < (__u8 *)(__end); \ | |
| 159 | − tl = (struct ext4_fc_tl *)((__u8 *)tl + \ | |
| 160 | − sizeof(struct ext4_fc_tl) + \ | |
| 161 | − + le16_to_cpu(tl->fc_len))) | |
| 162 | − | |
| 163 | 156 | static inline const char *tag2str(__u16 tag) |
| 164 | 157 | { |
| 165 | 158 | switch (tag) { |
| @@ -186,16 +179,4 @@ static inline const char *tag2str(__u16 tag) · 20 unmodified lines | ||
| 186 | 179 | } |
| 187 | 180 | } |
| 188 | 181 | |
| 189 | −/* Get length of a particular tlv */ | |
| 190 | −static inline int ext4_fc_tag_len(struct ext4_fc_tl *tl) | |
| 191 | −{ | |
| 192 | − return le16_to_cpu(tl->fc_len); | |
| 193 | −} | |
| 194 | − | |
| 195 | −/* Get a pointer to "value" of a tlv */ | |
| 196 | −static inline __u8 *ext4_fc_tag_val(struct ext4_fc_tl *tl) | |
| 197 | −{ | |
| 198 | − return (__u8 *)tl + sizeof(*tl); | |
| 199 | −} | |
| 200 | − | |
| 201 | 182 | #endif /* __FAST_COMMIT_H__ */ |
| @@ -322,14 +322,16 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) · 321 unmodified lines | ||
| 322 | 322 | if (is_directory) { |
| 323 | 323 | count = ext4_used_dirs_count(sb, gdp) - 1; |
| 324 | 324 | ext4_used_dirs_set(sb, gdp, count); |
| 325 | − percpu_counter_dec(&sbi->s_dirs_counter); | |
| 325 | + if (percpu_counter_initialized(&sbi->s_dirs_counter)) | |
| 326 | + percpu_counter_dec(&sbi->s_dirs_counter); | |
| 326 | 327 | } |
| 327 | 328 | ext4_inode_bitmap_csum_set(sb, block_group, gdp, bitmap_bh, |
| 328 | 329 | EXT4_INODES_PER_GROUP(sb) / 8); |
| 329 | 330 | ext4_group_desc_csum_set(sb, block_group, gdp); |
| 330 | 331 | ext4_unlock_group(sb, block_group); |
| 331 | 332 | |
| 332 | − percpu_counter_inc(&sbi->s_freeinodes_counter); | |
| 333 | + if (percpu_counter_initialized(&sbi->s_freeinodes_counter)) | |
| 334 | + percpu_counter_inc(&sbi->s_freeinodes_counter); | |
| 333 | 335 | if (sbi->s_log_groups_per_flex) { |
| 334 | 336 | struct flex_groups *fg; |
| 335 | 337 | |
| @@ -3217,7 +3217,7 @@ static int ext4_mb_init_backend(struct super_block *sb) · 3216 unmodified lines | ||
| 3217 | 3217 | */ |
| 3218 | 3218 | if (sbi->s_es->s_log_groups_per_flex >= 32) { |
| 3219 | 3219 | ext4_msg(sb, KERN_ERR, "too many log groups per flexible block group"); |
| 3220 | − goto err_freesgi; | |
| 3220 | + goto err_freebuddy; | |
| 3221 | 3221 | } |
| 3222 | 3222 | sbi->s_mb_prefetch = min_t(uint, 1 << sbi->s_es->s_log_groups_per_flex, |
| 3223 | 3223 | BLK_MAX_SEGMENT_SIZE >> (sb->s_blocksize_bits - 9)); |
| @@ -1376,7 +1376,8 @@ int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, · 1375 unmodified lines | ||
| 1376 | 1376 | struct dx_hash_info *hinfo = &name->hinfo; |
| 1377 | 1377 | int len; |
| 1378 | 1378 | |
| 1379 | − if (!IS_CASEFOLDED(dir) || !dir->i_sb->s_encoding) { | |
| 1379 | + if (!IS_CASEFOLDED(dir) || !dir->i_sb->s_encoding || | |
| 1380 | + (IS_ENCRYPTED(dir) && !fscrypt_has_encryption_key(dir))) { | |
| 1380 | 1381 | cf_name->name = NULL; |
| 1381 | 1382 | return 0; |
| 1382 | 1383 | } |
| @@ -1427,7 +1428,8 @@ static bool ext4_match(struct inode *parent, · 44 unmodified lines | ||
| 1427 | 1428 | #endif |
| 1428 | 1429 | |
| 1429 | 1430 | #ifdef CONFIG_UNICODE |
| 1430 | − if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent)) { | |
| 1431 | + if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) && | |
| 1432 | + (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) { | |
| 1431 | 1433 | if (fname->cf_name.name) { |
| 1432 | 1434 | struct qstr cf = {.name = fname->cf_name.name, |
| 1433 | 1435 | .len = fname->cf_name.len}; |
| @@ -4462,14 +4462,20 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) · 4461 unmodified lines | ||
| 4462 | 4462 | } |
| 4463 | 4463 | |
| 4464 | 4464 | if (sb->s_blocksize != blocksize) { |
| 4465 | + /* | |
| 4466 | + * bh must be released before kill_bdev(), otherwise | |
| 4467 | + * it won't be freed and its page also. kill_bdev() | |
| 4468 | + * is called by sb_set_blocksize(). | |
| 4469 | + */ | |
| 4470 | + brelse(bh); | |
| 4465 | 4471 | /* Validate the filesystem blocksize */ |
| 4466 | 4472 | if (!sb_set_blocksize(sb, blocksize)) { |
| 4467 | 4473 | ext4_msg(sb, KERN_ERR, "bad block size %d", |
| 4468 | 4474 | blocksize); |
| 4475 | + bh = NULL; | |
| 4469 | 4476 | goto failed_mount; |
| 4470 | 4477 | } |
| 4471 | 4478 | |
| 4472 | − brelse(bh); | |
| 4473 | 4479 | logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE; |
| 4474 | 4480 | offset = do_div(logical_sb_block, blocksize); |
| 4475 | 4481 | bh = ext4_sb_bread_unmovable(sb, logical_sb_block); |
| @@ -5202,8 +5208,9 @@ failed_mount: · 726 unmodified lines | ||
| 5202 | 5208 | kfree(get_qf_name(sb, sbi, i)); |
| 5203 | 5209 | #endif |
| 5204 | 5210 | fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy); |
| 5205 | − ext4_blkdev_remove(sbi); | |
| 5211 | + /* ext4_blkdev_remove() calls kill_bdev(), release bh before it. */ | |
| 5206 | 5212 | brelse(bh); |
| 5213 | + ext4_blkdev_remove(sbi); | |
| 5207 | 5214 | out_fail: |
| 5208 | 5215 | sb->s_fs_info = NULL; |
| 5209 | 5216 | kfree(sbi->s_blockgroup_lock); |
| @@ -315,7 +315,9 @@ EXT4_ATTR_FEATURE(verity); · 314 unmodified lines | ||
| 315 | 315 | #endif |
| 316 | 316 | EXT4_ATTR_FEATURE(metadata_csum_seed); |
| 317 | 317 | EXT4_ATTR_FEATURE(fast_commit); |
| 318 | +#if defined(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION) | |
| 318 | 319 | EXT4_ATTR_FEATURE(encrypted_casefold); |
| 320 | +#endif | |
| 319 | 321 | |
| 320 | 322 | static struct attribute *ext4_feat_attrs[] = { |
| 321 | 323 | ATTR_LIST(lazy_itable_init), |
| @@ -333,7 +335,9 @@ static struct attribute *ext4_feat_attrs[] = { · 11 unmodified lines | ||
| 333 | 335 | #endif |
| 334 | 336 | ATTR_LIST(metadata_csum_seed), |
| 335 | 337 | ATTR_LIST(fast_commit), |
| 338 | +#if defined(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION) | |
| 336 | 339 | ATTR_LIST(encrypted_casefold), |
| 340 | +#endif | |
| 337 | 341 | NULL, |
| 338 | 342 | }; |
| 339 | 343 | ATTRIBUTE_GROUPS(ext4_feat); |
| @@ -911,8 +911,11 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · 910 unmodified lines | ||
| 911 | 911 | current->backing_dev_info = inode_to_bdi(inode); |
| 912 | 912 | buffered = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); |
| 913 | 913 | current->backing_dev_info = NULL; |
| 914 | − if (unlikely(buffered <= 0)) | |
| 914 | + if (unlikely(buffered <= 0)) { | |
| 915 | + if (!ret) | |
| 916 | + ret = buffered; | |
| 915 | 917 | goto out_unlock; |
| 918 | + } | |
| 916 | 919 | |
| 917 | 920 | /* |
| 918 | 921 | * We need to ensure that the page cache pages are written to |
| @@ -582,6 +582,16 @@ out_locked: · 581 unmodified lines | ||
| 582 | 582 | spin_unlock(&gl->gl_lockref.lock); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | +static bool is_system_glock(struct gfs2_glock *gl) | |
| 586 | +{ | |
| 587 | + struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; | |
| 588 | + struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); | |
| 589 | + | |
| 590 | + if (gl == m_ip->i_gl) | |
| 591 | + return true; | |
| 592 | + return false; | |
| 593 | +} | |
| 594 | + | |
| 585 | 595 | /** |
| 586 | 596 | * do_xmote - Calls the DLM to change the state of a lock |
| 587 | 597 | * @gl: The lock state |
| @@ -671,17 +681,25 @@ skip_inval: · 83 unmodified lines | ||
| 671 | 681 | * to see sd_log_error and withdraw, and in the meantime, requeue the |
| 672 | 682 | * work for later. |
| 673 | 683 | * |
| 684 | + * We make a special exception for some system glocks, such as the | |
| 685 | + * system statfs inode glock, which needs to be granted before the | |
| 686 | + * gfs2_quotad daemon can exit, and that exit needs to finish before | |
| 687 | + * we can unmount the withdrawn file system. | |
| 688 | + * | |
| 674 | 689 | * However, if we're just unlocking the lock (say, for unmount, when |
| 675 | 690 | * gfs2_gl_hash_clear calls clear_glock) and recovery is complete |
| 676 | 691 | * then it's okay to tell dlm to unlock it. |
| 677 | 692 | */ |
| 678 | 693 | if (unlikely(sdp->sd_log_error && !gfs2_withdrawn(sdp))) |
| 679 | 694 | gfs2_withdraw_delayed(sdp); |
| 680 | − if (glock_blocked_by_withdraw(gl)) { | |
| 681 | − if (target != LM_ST_UNLOCKED || | |
| 682 | − test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags)) { | |
| 695 | + if (glock_blocked_by_withdraw(gl) && | |
| 696 | + (target != LM_ST_UNLOCKED || | |
| 697 | + test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags))) { | |
| 698 | + if (!is_system_glock(gl)) { | |
| 683 | 699 | gfs2_glock_queue_work(gl, GL_GLOCK_DFT_HOLD); |
| 684 | 700 | goto out; |
| 701 | + } else { | |
| 702 | + clear_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags); | |
| 685 | 703 | } |
| 686 | 704 | } |
| 687 | 705 | |
| @@ -1466,9 +1484,11 @@ void gfs2_glock_dq(struct gfs2_holder *gh) · 778 unmodified lines | ||
| 1466 | 1484 | glock_blocked_by_withdraw(gl) && |
| 1467 | 1485 | gh->gh_gl != sdp->sd_jinode_gl) { |
| 1468 | 1486 | sdp->sd_glock_dqs_held++; |
| 1487 | + spin_unlock(&gl->gl_lockref.lock); | |
| 1469 | 1488 | might_sleep(); |
| 1470 | 1489 | wait_on_bit(&sdp->sd_flags, SDF_WITHDRAW_RECOVERY, |
| 1471 | 1490 | TASK_UNINTERRUPTIBLE); |
| 1491 | + spin_lock(&gl->gl_lockref.lock); | |
| 1472 | 1492 | } |
| 1473 | 1493 | if (gh->gh_flags & GL_NOCACHE) |
| 1474 | 1494 | handle_callback(gl, LM_ST_UNLOCKED, 0, false); |
| @@ -1775,6 +1795,7 @@ __acquires(&lru_lock) · 300 unmodified lines | ||
| 1775 | 1795 | while(!list_empty(list)) { |
| 1776 | 1796 | gl = list_first_entry(list, struct gfs2_glock, gl_lru); |
| 1777 | 1797 | list_del_init(&gl->gl_lru); |
| 1798 | + clear_bit(GLF_LRU, &gl->gl_flags); | |
| 1778 | 1799 | if (!spin_trylock(&gl->gl_lockref.lock)) { |
| 1779 | 1800 | add_back_to_lru: |
| 1780 | 1801 | list_add(&gl->gl_lru, &lru_list); |
| @@ -1820,7 +1841,6 @@ static long gfs2_scan_glock_lru(int nr) · 39 unmodified lines | ||
| 1820 | 1841 | if (!test_bit(GLF_LOCK, &gl->gl_flags)) { |
| 1821 | 1842 | list_move(&gl->gl_lru, &dispose); |
| 1822 | 1843 | atomic_dec(&lru_count); |
| 1823 | − clear_bit(GLF_LRU, &gl->gl_flags); | |
| 1824 | 1844 | freed++; |
| 1825 | 1845 | continue; |
| 1826 | 1846 | } |
| @@ -396,7 +396,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) · 395 unmodified lines | ||
| 396 | 396 | struct timespec64 atime; |
| 397 | 397 | u16 height, depth; |
| 398 | 398 | umode_t mode = be32_to_cpu(str->di_mode); |
| 399 | − bool is_new = ip->i_inode.i_flags & I_NEW; | |
| 399 | + bool is_new = ip->i_inode.i_state & I_NEW; | |
| 400 | 400 | |
| 401 | 401 | if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr))) |
| 402 | 402 | goto corrupt; |
| @@ -926,10 +926,10 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags) · 925 unmodified lines | ||
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | /** |
| 929 | − * ail_drain - drain the ail lists after a withdraw | |
| 929 | + * gfs2_ail_drain - drain the ail lists after a withdraw | |
| 930 | 930 | * @sdp: Pointer to GFS2 superblock |
| 931 | 931 | */ |
| 932 | −static void ail_drain(struct gfs2_sbd *sdp) | |
| 932 | +void gfs2_ail_drain(struct gfs2_sbd *sdp) | |
| 933 | 933 | { |
| 934 | 934 | struct gfs2_trans *tr; |
| 935 | 935 | |
| @@ -956,6 +956,7 @@ static void ail_drain(struct gfs2_sbd *sdp) · 20 unmodified lines | ||
| 956 | 956 | list_del(&tr->tr_list); |
| 957 | 957 | gfs2_trans_free(sdp, tr); |
| 958 | 958 | } |
| 959 | + gfs2_drain_revokes(sdp); | |
| 959 | 960 | spin_unlock(&sdp->sd_ail_lock); |
| 960 | 961 | } |
| 961 | 962 | |
| @@ -1162,7 +1163,6 @@ out_withdraw: · 200 unmodified lines | ||
| 1162 | 1163 | if (tr && list_empty(&tr->tr_list)) |
| 1163 | 1164 | list_add(&tr->tr_list, &sdp->sd_ail1_list); |
| 1164 | 1165 | spin_unlock(&sdp->sd_ail_lock); |
| 1165 | − ail_drain(sdp); /* frees all transactions */ | |
| 1166 | 1166 | tr = NULL; |
| 1167 | 1167 | goto out_end; |
| 1168 | 1168 | } |
| @@ -93,5 +93,6 @@ extern int gfs2_logd(void *data); · 92 unmodified lines | ||
| 93 | 93 | extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd); |
| 94 | 94 | extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl); |
| 95 | 95 | extern void gfs2_flush_revokes(struct gfs2_sbd *sdp); |
| 96 | +extern void gfs2_ail_drain(struct gfs2_sbd *sdp); | |
| 96 | 97 | |
| 97 | 98 | #endif /* __LOG_DOT_H__ */ |
| @@ -885,7 +885,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) · 884 unmodified lines | ||
| 885 | 885 | gfs2_log_write_page(sdp, page); |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | −static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) | |
| 888 | +void gfs2_drain_revokes(struct gfs2_sbd *sdp) | |
| 889 | 889 | { |
| 890 | 890 | struct list_head *head = &sdp->sd_log_revokes; |
| 891 | 891 | struct gfs2_bufdata *bd; |
| @@ -900,6 +900,11 @@ static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) · 8 unmodified lines | ||
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | +static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) | |
| 904 | +{ | |
| 905 | + gfs2_drain_revokes(sdp); | |
| 906 | +} | |
| 907 | + | |
| 903 | 908 | static void revoke_lo_before_scan(struct gfs2_jdesc *jd, |
| 904 | 909 | struct gfs2_log_header_host *head, int pass) |
| 905 | 910 | { |
| @@ -20,6 +20,7 @@ extern void gfs2_log_submit_bio(struct bio **biop, int opf); · 19 unmodified lines | ||
| 20 | 20 | extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh); |
| 21 | 21 | extern int gfs2_find_jhead(struct gfs2_jdesc *jd, |
| 22 | 22 | struct gfs2_log_header_host *head, bool keep_cache); |
| 23 | +extern void gfs2_drain_revokes(struct gfs2_sbd *sdp); | |
| 23 | 24 | static inline unsigned int buf_limit(struct gfs2_sbd *sdp) |
| 24 | 25 | { |
| 25 | 26 | return sdp->sd_ldptrs; |
| @@ -131,6 +131,7 @@ static void signal_our_withdraw(struct gfs2_sbd *sdp) · 130 unmodified lines | ||
| 131 | 131 | if (test_bit(SDF_NORECOVERY, &sdp->sd_flags) || !sdp->sd_jdesc) |
| 132 | 132 | return; |
| 133 | 133 | |
| 134 | + gfs2_ail_drain(sdp); /* frees all transactions */ | |
| 134 | 135 | inode = sdp->sd_jdesc->jd_inode; |
| 135 | 136 | ip = GFS2_I(inode); |
| 136 | 137 | i_gl = ip->i_gl; |
| @@ -783,6 +783,11 @@ struct io_task_work { · 782 unmodified lines | ||
| 783 | 783 | task_work_func_t func; |
| 784 | 784 | }; |
| 785 | 785 | |
| 786 | +enum { | |
| 787 | + IORING_RSRC_FILE = 0, | |
| 788 | + IORING_RSRC_BUFFER = 1, | |
| 789 | +}; | |
| 790 | + | |
| 786 | 791 | /* |
| 787 | 792 | * NOTE! Each of the iocb union members has the file pointer |
| 788 | 793 | * as the first entry in their struct definition. So you can |
| @@ -8228,6 +8233,7 @@ static int io_buffer_account_pin(struct io_ring_ctx *ctx, struct page **pages, · 7439 unmodified lines | ||
| 8228 | 8233 | { |
| 8229 | 8234 | int i, ret; |
| 8230 | 8235 | |
| 8236 | + imu->acct_pages = 0; | |
| 8231 | 8237 | for (i = 0; i < nr_pages; i++) { |
| 8232 | 8238 | if (!PageCompound(pages[i])) { |
| 8233 | 8239 | imu->acct_pages++; |
| @@ -9670,7 +9676,8 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p, · 1436 unmodified lines | ||
| 9670 | 9676 | IORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS | |
| 9671 | 9677 | IORING_FEAT_CUR_PERSONALITY | IORING_FEAT_FAST_POLL | |
| 9672 | 9678 | IORING_FEAT_POLL_32BITS | IORING_FEAT_SQPOLL_NONFIXED | |
| 9673 | − IORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS; | |
| 9679 | + IORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS | | |
| 9680 | + IORING_FEAT_RSRC_TAGS; | |
| 9674 | 9681 | |
| 9675 | 9682 | if (copy_to_user(params, p, sizeof(*p))) { |
| 9676 | 9683 | ret = -EFAULT; |
| @@ -9910,7 +9917,7 @@ static int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg, · 233 unmodified lines | ||
| 9910 | 9917 | } |
| 9911 | 9918 | |
| 9912 | 9919 | static int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg, |
| 9913 | − unsigned size) | |
| 9920 | + unsigned size, unsigned type) | |
| 9914 | 9921 | { |
| 9915 | 9922 | struct io_uring_rsrc_update2 up; |
| 9916 | 9923 | |
| @@ -9918,13 +9925,13 @@ static int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg, · 1 unmodified line | ||
| 9918 | 9925 | return -EINVAL; |
| 9919 | 9926 | if (copy_from_user(&up, arg, sizeof(up))) |
| 9920 | 9927 | return -EFAULT; |
| 9921 | − if (!up.nr) | |
| 9928 | + if (!up.nr || up.resv) | |
| 9922 | 9929 | return -EINVAL; |
| 9923 | − return __io_register_rsrc_update(ctx, up.type, &up, up.nr); | |
| 9930 | + return __io_register_rsrc_update(ctx, type, &up, up.nr); | |
| 9924 | 9931 | } |
| 9925 | 9932 | |
| 9926 | 9933 | static int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg, |
| 9927 | − unsigned int size) | |
| 9934 | + unsigned int size, unsigned int type) | |
| 9928 | 9935 | { |
| 9929 | 9936 | struct io_uring_rsrc_register rr; |
| 9930 | 9937 | |
| @@ -9935,10 +9942,10 @@ static int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg, · 4 unmodified lines | ||
| 9935 | 9942 | memset(&rr, 0, sizeof(rr)); |
| 9936 | 9943 | if (copy_from_user(&rr, arg, size)) |
| 9937 | 9944 | return -EFAULT; |
| 9938 | − if (!rr.nr) | |
| 9945 | + if (!rr.nr || rr.resv || rr.resv2) | |
| 9939 | 9946 | return -EINVAL; |
| 9940 | 9947 | |
| 9941 | − switch (rr.type) { | |
| 9948 | + switch (type) { | |
| 9942 | 9949 | case IORING_RSRC_FILE: |
| 9943 | 9950 | return io_sqe_files_register(ctx, u64_to_user_ptr(rr.data), |
| 9944 | 9951 | rr.nr, u64_to_user_ptr(rr.tags)); |
| @@ -9960,8 +9967,10 @@ static bool io_register_op_must_quiesce(int op) · 15 unmodified lines | ||
| 9960 | 9967 | case IORING_REGISTER_PROBE: |
| 9961 | 9968 | case IORING_REGISTER_PERSONALITY: |
| 9962 | 9969 | case IORING_UNREGISTER_PERSONALITY: |
| 9963 | − case IORING_REGISTER_RSRC: | |
| 9964 | − case IORING_REGISTER_RSRC_UPDATE: | |
| 9970 | + case IORING_REGISTER_FILES2: | |
| 9971 | + case IORING_REGISTER_FILES_UPDATE2: | |
| 9972 | + case IORING_REGISTER_BUFFERS2: | |
| 9973 | + case IORING_REGISTER_BUFFERS_UPDATE: | |
| 9965 | 9974 | return false; |
| 9966 | 9975 | default: |
| 9967 | 9976 | return true; |
| @@ -10087,11 +10096,19 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, · 119 unmodified lines | ||
| 10087 | 10096 | case IORING_REGISTER_RESTRICTIONS: |
| 10088 | 10097 | ret = io_register_restrictions(ctx, arg, nr_args); |
| 10089 | 10098 | break; |
| 10090 | − case IORING_REGISTER_RSRC: | |
| 10091 | − ret = io_register_rsrc(ctx, arg, nr_args); | |
| 10099 | + case IORING_REGISTER_FILES2: | |
| 10100 | + ret = io_register_rsrc(ctx, arg, nr_args, IORING_RSRC_FILE); | |
| 10101 | + break; | |
| 10102 | + case IORING_REGISTER_FILES_UPDATE2: | |
| 10103 | + ret = io_register_rsrc_update(ctx, arg, nr_args, | |
| 10104 | + IORING_RSRC_FILE); | |
| 10105 | + break; | |
| 10106 | + case IORING_REGISTER_BUFFERS2: | |
| 10107 | + ret = io_register_rsrc(ctx, arg, nr_args, IORING_RSRC_BUFFER); | |
| 10092 | 10108 | break; |
| 10093 | − case IORING_REGISTER_RSRC_UPDATE: | |
| 10094 | − ret = io_register_rsrc_update(ctx, arg, nr_args); | |
| 10109 | + case IORING_REGISTER_BUFFERS_UPDATE: | |
| 10110 | + ret = io_register_rsrc_update(ctx, arg, nr_args, | |
| 10111 | + IORING_RSRC_BUFFER); | |
| 10095 | 10112 | break; |
| 10096 | 10113 | default: |
| 10097 | 10114 | ret = -EINVAL; |
| @@ -406,7 +406,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init) · 405 unmodified lines | ||
| 406 | 406 | |
| 407 | 407 | if (cl_init->hostname == NULL) { |
| 408 | 408 | WARN_ON(1); |
| 409 | − return NULL; | |
| 409 | + return ERR_PTR(-EINVAL); | |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /* see if the client already exists */ |
| @@ -205,6 +205,7 @@ struct nfs4_exception { · 204 unmodified lines | ||
| 205 | 205 | struct inode *inode; |
| 206 | 206 | nfs4_stateid *stateid; |
| 207 | 207 | long timeout; |
| 208 | + unsigned char task_is_privileged : 1; | |
| 208 | 209 | unsigned char delay : 1, |
| 209 | 210 | recovering : 1, |
| 210 | 211 | retry : 1; |
| @@ -435,8 +435,8 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp, · 434 unmodified lines | ||
| 435 | 435 | */ |
| 436 | 436 | nfs_mark_client_ready(clp, -EPERM); |
| 437 | 437 | } |
| 438 | − nfs_put_client(clp); | |
| 439 | 438 | clear_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags); |
| 439 | + nfs_put_client(clp); | |
| 440 | 440 | return old; |
| 441 | 441 | |
| 442 | 442 | error: |
| @@ -589,6 +589,8 @@ int nfs4_handle_exception(struct nfs_server *server, int errorcode, struct nfs4_ · 588 unmodified lines | ||
| 589 | 589 | goto out_retry; |
| 590 | 590 | } |
| 591 | 591 | if (exception->recovering) { |
| 592 | + if (exception->task_is_privileged) | |
| 593 | + return -EDEADLOCK; | |
| 592 | 594 | ret = nfs4_wait_clnt_recover(clp); |
| 593 | 595 | if (test_bit(NFS_MIG_FAILED, &server->mig_status)) |
| 594 | 596 | return -EIO; |
| @@ -614,6 +616,8 @@ nfs4_async_handle_exception(struct rpc_task *task, struct nfs_server *server, · 19 unmodified lines | ||
| 614 | 616 | goto out_retry; |
| 615 | 617 | } |
| 616 | 618 | if (exception->recovering) { |
| 619 | + if (exception->task_is_privileged) | |
| 620 | + return -EDEADLOCK; | |
| 617 | 621 | rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL); |
| 618 | 622 | if (test_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) == 0) |
| 619 | 623 | rpc_wake_up_queued_task(&clp->cl_rpcwaitq, task); |
| @@ -3878,6 +3882,10 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f · 3258 unmodified lines | ||
| 3878 | 3882 | server->caps |= NFS_CAP_HARDLINKS; |
| 3879 | 3883 | if (res.has_symlinks != 0) |
| 3880 | 3884 | server->caps |= NFS_CAP_SYMLINKS; |
| 3885 | +#ifdef CONFIG_NFS_V4_SECURITY_LABEL | |
| 3886 | + if (res.attr_bitmask[2] & FATTR4_WORD2_SECURITY_LABEL) | |
| 3887 | + server->caps |= NFS_CAP_SECURITY_LABEL; | |
| 3888 | +#endif | |
| 3881 | 3889 | if (!(res.attr_bitmask[0] & FATTR4_WORD0_FILEID)) |
| 3882 | 3890 | server->fattr_valid &= ~NFS_ATTR_FATTR_FILEID; |
| 3883 | 3891 | if (!(res.attr_bitmask[1] & FATTR4_WORD1_MODE)) |
| @@ -3898,10 +3906,6 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f · 14 unmodified lines | ||
| 3898 | 3906 | server->fattr_valid &= ~NFS_ATTR_FATTR_CTIME; |
| 3899 | 3907 | if (!(res.attr_bitmask[1] & FATTR4_WORD1_TIME_MODIFY)) |
| 3900 | 3908 | server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME; |
| 3901 | −#ifdef CONFIG_NFS_V4_SECURITY_LABEL | |
| 3902 | − if (!(res.attr_bitmask[2] & FATTR4_WORD2_SECURITY_LABEL)) | |
| 3903 | − server->fattr_valid &= ~NFS_ATTR_FATTR_V4_SECURITY_LABEL; | |
| 3904 | −#endif | |
| 3905 | 3909 | memcpy(server->attr_bitmask_nl, res.attr_bitmask, |
| 3906 | 3910 | sizeof(server->attr_bitmask)); |
| 3907 | 3911 | server->attr_bitmask_nl[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
| @@ -5968,6 +5972,14 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflen · 2060 unmodified lines | ||
| 5968 | 5972 | do { |
| 5969 | 5973 | err = __nfs4_proc_set_acl(inode, buf, buflen); |
| 5970 | 5974 | trace_nfs4_set_acl(inode, err); |
| 5975 | + if (err == -NFS4ERR_BADOWNER || err == -NFS4ERR_BADNAME) { | |
| 5976 | + /* | |
| 5977 | + * no need to retry since the kernel | |
| 5978 | + * isn't involved in encoding the ACEs. | |
| 5979 | + */ | |
| 5980 | + err = -EINVAL; | |
| 5981 | + break; | |
| 5982 | + } | |
| 5971 | 5983 | err = nfs4_handle_exception(NFS_SERVER(inode), err, |
| 5972 | 5984 | &exception); |
| 5973 | 5985 | } while (exception.retry); |
| @@ -6409,6 +6421,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) · 435 unmodified lines | ||
| 6409 | 6421 | struct nfs4_exception exception = { |
| 6410 | 6422 | .inode = data->inode, |
| 6411 | 6423 | .stateid = &data->stateid, |
| 6424 | + .task_is_privileged = data->args.seq_args.sa_privileged, | |
| 6412 | 6425 | }; |
| 6413 | 6426 | |
| 6414 | 6427 | if (!nfs4_sequence_done(task, &data->res.seq_res)) |
| @@ -6532,7 +6545,6 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, · 117 unmodified lines | ||
| 6532 | 6545 | data = kzalloc(sizeof(*data), GFP_NOFS); |
| 6533 | 6546 | if (data == NULL) |
| 6534 | 6547 | return -ENOMEM; |
| 6535 | − nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0); | |
| 6536 | 6548 | |
| 6537 | 6549 | nfs4_state_protect(server->nfs_client, |
| 6538 | 6550 | NFS_SP4_MACH_CRED_CLEANUP, |
| @@ -6563,6 +6575,12 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, · 24 unmodified lines | ||
| 6563 | 6575 | } |
| 6564 | 6576 | } |
| 6565 | 6577 | |
| 6578 | + if (!data->inode) | |
| 6579 | + nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, | |
| 6580 | + 1); | |
| 6581 | + else | |
| 6582 | + nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, | |
| 6583 | + 0); | |
| 6566 | 6584 | task_setup_data.callback_data = data; |
| 6567 | 6585 | msg.rpc_argp = &data->args; |
| 6568 | 6586 | msg.rpc_resp = &data->res; |
| @@ -9640,15 +9658,20 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) · 3071 unmodified lines | ||
| 9640 | 9658 | &task_setup_data.rpc_client, &msg); |
| 9641 | 9659 | |
| 9642 | 9660 | dprintk("--> %s\n", __func__); |
| 9661 | + lrp->inode = nfs_igrab_and_active(lrp->args.inode); | |
| 9643 | 9662 | if (!sync) { |
| 9644 | − lrp->inode = nfs_igrab_and_active(lrp->args.inode); | |
| 9645 | 9663 | if (!lrp->inode) { |
| 9646 | 9664 | nfs4_layoutreturn_release(lrp); |
| 9647 | 9665 | return -EAGAIN; |
| 9648 | 9666 | } |
| 9649 | 9667 | task_setup_data.flags |= RPC_TASK_ASYNC; |
| 9650 | 9668 | } |
| 9651 | − nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, 0); | |
| 9669 | + if (!lrp->inode) | |
| 9670 | + nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, | |
| 9671 | + 1); | |
| 9672 | + else | |
| 9673 | + nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, | |
| 9674 | + 0); | |
| 9652 | 9675 | task = rpc_run_task(&task_setup_data); |
| 9653 | 9676 | if (IS_ERR(task)) |
| 9654 | 9677 | return PTR_ERR(task); |
| @@ -430,10 +430,6 @@ TRACE_DEFINE_ENUM(O_CLOEXEC); · 429 unmodified lines | ||
| 430 | 430 | { O_NOATIME, "O_NOATIME" }, \ |
| 431 | 431 | { O_CLOEXEC, "O_CLOEXEC" }) |
| 432 | 432 | |
| 433 | −TRACE_DEFINE_ENUM(FMODE_READ); | |
| 434 | −TRACE_DEFINE_ENUM(FMODE_WRITE); | |
| 435 | −TRACE_DEFINE_ENUM(FMODE_EXEC); | |
| 436 | − | |
| 437 | 433 | #define show_fmode_flags(mode) \ |
| 438 | 434 | __print_flags(mode, "|", \ |
| 439 | 435 | { ((__force unsigned long)FMODE_READ), "READ" }, \ |
| @@ -424,11 +424,18 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, · 423 unmodified lines | ||
| 424 | 424 | * events generated by the listener process itself, without disclosing |
| 425 | 425 | * the pids of other processes. |
| 426 | 426 | */ |
| 427 | − if (!capable(CAP_SYS_ADMIN) && | |
| 427 | + if (FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) && | |
| 428 | 428 | task_tgid(current) != event->pid) |
| 429 | 429 | metadata.pid = 0; |
| 430 | 430 | |
| 431 | − if (path && path->mnt && path->dentry) { | |
| 431 | + /* | |
| 432 | + * For now, fid mode is required for an unprivileged listener and | |
| 433 | + * fid mode does not report fd in events. Keep this check anyway | |
| 434 | + * for safety in case fid mode requirement is relaxed in the future | |
| 435 | + * to allow unprivileged listener to get events with no fd and no fid. | |
| 436 | + */ | |
| 437 | + if (!FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) && | |
| 438 | + path && path->mnt && path->dentry) { | |
| 432 | 439 | fd = create_fd(group, path, &f); |
| 433 | 440 | if (fd < 0) |
| 434 | 441 | return fd; |
| @@ -1040,6 +1047,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) · 605 unmodified lines | ||
| 1040 | 1047 | int f_flags, fd; |
| 1041 | 1048 | unsigned int fid_mode = flags & FANOTIFY_FID_BITS; |
| 1042 | 1049 | unsigned int class = flags & FANOTIFY_CLASS_BITS; |
| 1050 | + unsigned int internal_flags = 0; | |
| 1043 | 1051 | |
| 1044 | 1052 | pr_debug("%s: flags=%x event_f_flags=%x\n", |
| 1045 | 1053 | __func__, flags, event_f_flags); |
| @@ -1053,6 +1061,13 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) · 7 unmodified lines | ||
| 1053 | 1061 | */ |
| 1054 | 1062 | if ((flags & FANOTIFY_ADMIN_INIT_FLAGS) || !fid_mode) |
| 1055 | 1063 | return -EPERM; |
| 1064 | + | |
| 1065 | + /* | |
| 1066 | + * Setting the internal flag FANOTIFY_UNPRIV on the group | |
| 1067 | + * prevents setting mount/filesystem marks on this group and | |
| 1068 | + * prevents reporting pid and open fd in events. | |
| 1069 | + */ | |
| 1070 | + internal_flags |= FANOTIFY_UNPRIV; | |
| 1056 | 1071 | } |
| 1057 | 1072 | |
| 1058 | 1073 | #ifdef CONFIG_AUDITSYSCALL |
| @@ -1105,7 +1120,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) · 46 unmodified lines | ||
| 1105 | 1120 | goto out_destroy_group; |
| 1106 | 1121 | } |
| 1107 | 1122 | |
| 1108 | − group->fanotify_data.flags = flags; | |
| 1123 | + group->fanotify_data.flags = flags | internal_flags; | |
| 1109 | 1124 | group->memcg = get_mem_cgroup_from_mm(current->mm); |
| 1110 | 1125 | |
| 1111 | 1126 | group->fanotify_data.merge_hash = fanotify_alloc_merge_hash(); |
| @@ -1305,11 +1320,13 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, · 193 unmodified lines | ||
| 1305 | 1320 | group = f.file->private_data; |
| 1306 | 1321 | |
| 1307 | 1322 | /* |
| 1308 | − * An unprivileged user is not allowed to watch a mount point nor | |
| 1309 | − * a filesystem. | |
| 1323 | + * An unprivileged user is not allowed to setup mount nor filesystem | |
| 1324 | + * marks. This also includes setting up such marks by a group that | |
| 1325 | + * was initialized by an unprivileged user. | |
| 1310 | 1326 | */ |
| 1311 | 1327 | ret = -EPERM; |
| 1312 | − if (!capable(CAP_SYS_ADMIN) && | |
| 1328 | + if ((!capable(CAP_SYS_ADMIN) || | |
| 1329 | + FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV)) && | |
| 1313 | 1330 | mark_type != FAN_MARK_INODE) |
| 1314 | 1331 | goto fput_and_out; |
| 1315 | 1332 | |
| @@ -1460,6 +1477,7 @@ static int __init fanotify_user_setup(void) · 144 unmodified lines | ||
| 1460 | 1477 | max_marks = clamp(max_marks, FANOTIFY_OLD_DEFAULT_MAX_MARKS, |
| 1461 | 1478 | FANOTIFY_DEFAULT_MAX_USER_MARKS); |
| 1462 | 1479 | |
| 1480 | + BUILD_BUG_ON(FANOTIFY_INIT_FLAGS & FANOTIFY_INTERNAL_GROUP_FLAGS); | |
| 1463 | 1481 | BUILD_BUG_ON(HWEIGHT32(FANOTIFY_INIT_FLAGS) != 10); |
| 1464 | 1482 | BUILD_BUG_ON(HWEIGHT32(FANOTIFY_MARK_FLAGS) != 9); |
| 1465 | 1483 | |
| @@ -144,7 +144,7 @@ void fanotify_show_fdinfo(struct seq_file *m, struct file *f) · 143 unmodified lines | ||
| 144 | 144 | struct fsnotify_group *group = f->private_data; |
| 145 | 145 | |
| 146 | 146 | seq_printf(m, "fanotify flags:%x event-flags:%x\n", |
| 147 | − group->fanotify_data.flags, | |
| 147 | + group->fanotify_data.flags & FANOTIFY_INIT_FLAGS, | |
| 148 | 148 | group->fanotify_data.f_flags); |
| 149 | 149 | |
| 150 | 150 | show_fdinfo(m, f, fanotify_fdinfo); |
| @@ -1855,6 +1855,45 @@ out: · 1854 unmodified lines | ||
| 1855 | 1855 | return ret; |
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | +/* | |
| 1859 | + * zero out partial blocks of one cluster. | |
| 1860 | + * | |
| 1861 | + * start: file offset where zero starts, will be made upper block aligned. | |
| 1862 | + * len: it will be trimmed to the end of current cluster if "start + len" | |
| 1863 | + * is bigger than it. | |
| 1864 | + */ | |
| 1865 | +static int ocfs2_zeroout_partial_cluster(struct inode *inode, | |
| 1866 | + u64 start, u64 len) | |
| 1867 | +{ | |
| 1868 | + int ret; | |
| 1869 | + u64 start_block, end_block, nr_blocks; | |
| 1870 | + u64 p_block, offset; | |
| 1871 | + u32 cluster, p_cluster, nr_clusters; | |
| 1872 | + struct super_block *sb = inode->i_sb; | |
| 1873 | + u64 end = ocfs2_align_bytes_to_clusters(sb, start); | |
| 1874 | + | |
| 1875 | + if (start + len < end) | |
| 1876 | + end = start + len; | |
| 1877 | + | |
| 1878 | + start_block = ocfs2_blocks_for_bytes(sb, start); | |
| 1879 | + end_block = ocfs2_blocks_for_bytes(sb, end); | |
| 1880 | + nr_blocks = end_block - start_block; | |
| 1881 | + if (!nr_blocks) | |
| 1882 | + return 0; | |
| 1883 | + | |
| 1884 | + cluster = ocfs2_bytes_to_clusters(sb, start); | |
| 1885 | + ret = ocfs2_get_clusters(inode, cluster, &p_cluster, | |
| 1886 | + &nr_clusters, NULL); | |
| 1887 | + if (ret) | |
| 1888 | + return ret; | |
| 1889 | + if (!p_cluster) | |
| 1890 | + return 0; | |
| 1891 | + | |
| 1892 | + offset = start_block - ocfs2_clusters_to_blocks(sb, cluster); | |
| 1893 | + p_block = ocfs2_clusters_to_blocks(sb, p_cluster) + offset; | |
| 1894 | + return sb_issue_zeroout(sb, p_block, nr_blocks, GFP_NOFS); | |
| 1895 | +} | |
| 1896 | + | |
| 1858 | 1897 | /* |
| 1859 | 1898 | * Parts of this function taken from xfs_change_file_space() |
| 1860 | 1899 | */ |
| @@ -1865,7 +1904,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode, · 4 unmodified lines | ||
| 1865 | 1904 | { |
| 1866 | 1905 | int ret; |
| 1867 | 1906 | s64 llen; |
| 1868 | − loff_t size; | |
| 1907 | + loff_t size, orig_isize; | |
| 1869 | 1908 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 1870 | 1909 | struct buffer_head *di_bh = NULL; |
| 1871 | 1910 | handle_t *handle; |
| @@ -1896,6 +1935,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode, · 24 unmodified lines | ||
| 1896 | 1935 | goto out_inode_unlock; |
| 1897 | 1936 | } |
| 1898 | 1937 | |
| 1938 | + orig_isize = i_size_read(inode); | |
| 1899 | 1939 | switch (sr->l_whence) { |
| 1900 | 1940 | case 0: /*SEEK_SET*/ |
| 1901 | 1941 | break; |
| @@ -1903,7 +1943,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode, · 1 unmodified line | ||
| 1903 | 1943 | sr->l_start += f_pos; |
| 1904 | 1944 | break; |
| 1905 | 1945 | case 2: /*SEEK_END*/ |
| 1906 | − sr->l_start += i_size_read(inode); | |
| 1946 | + sr->l_start += orig_isize; | |
| 1907 | 1947 | break; |
| 1908 | 1948 | default: |
| 1909 | 1949 | ret = -EINVAL; |
| @@ -1957,6 +1997,14 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode, · 47 unmodified lines | ||
| 1957 | 1997 | default: |
| 1958 | 1998 | ret = -EINVAL; |
| 1959 | 1999 | } |
| 2000 | + | |
| 2001 | + /* zeroout eof blocks in the cluster. */ | |
| 2002 | + if (!ret && change_size && orig_isize < size) { | |
| 2003 | + ret = ocfs2_zeroout_partial_cluster(inode, orig_isize, | |
| 2004 | + size - orig_isize); | |
| 2005 | + if (!ret) | |
| 2006 | + i_size_write(inode, size); | |
| 2007 | + } | |
| 1960 | 2008 | up_write(&OCFS2_I(inode)->ip_alloc_sem); |
| 1961 | 2009 | if (ret) { |
| 1962 | 2010 | mlog_errno(ret); |
| @@ -1973,9 +2021,6 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode, · 10 unmodified lines | ||
| 1973 | 2021 | goto out_inode_unlock; |
| 1974 | 2022 | } |
| 1975 | 2023 | |
| 1976 | − if (change_size && i_size_read(inode) < size) | |
| 1977 | − i_size_write(inode, size); | |
| 1978 | − | |
| 1979 | 2024 | inode->i_ctime = inode->i_mtime = current_time(inode); |
| 1980 | 2025 | ret = ocfs2_mark_inode_dirty(handle, inode, di_bh); |
| 1981 | 2026 | if (ret < 0) |
| @@ -2674,6 +2674,11 @@ out: · 2673 unmodified lines | ||
| 2674 | 2674 | } |
| 2675 | 2675 | |
| 2676 | 2676 | #ifdef CONFIG_SECURITY |
| 2677 | +static int proc_pid_attr_open(struct inode *inode, struct file *file) | |
| 2678 | +{ | |
| 2679 | + return __mem_open(inode, file, PTRACE_MODE_READ_FSCREDS); | |
| 2680 | +} | |
| 2681 | + | |
| 2677 | 2682 | static ssize_t proc_pid_attr_read(struct file * file, char __user * buf, |
| 2678 | 2683 | size_t count, loff_t *ppos) |
| 2679 | 2684 | { |
| @@ -2704,7 +2709,7 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf, · 24 unmodified lines | ||
| 2704 | 2709 | int rv; |
| 2705 | 2710 | |
| 2706 | 2711 | /* A task may only write when it was the opener. */ |
| 2707 | − if (file->f_cred != current_real_cred()) | |
| 2712 | + if (file->private_data != current->mm) | |
| 2708 | 2713 | return -EPERM; |
| 2709 | 2714 | |
| 2710 | 2715 | rcu_read_lock(); |
| @@ -2754,9 +2759,11 @@ out: · 43 unmodified lines | ||
| 2754 | 2759 | } |
| 2755 | 2760 | |
| 2756 | 2761 | static const struct file_operations proc_pid_attr_operations = { |
| 2762 | + .open = proc_pid_attr_open, | |
| 2757 | 2763 | .read = proc_pid_attr_read, |
| 2758 | 2764 | .write = proc_pid_attr_write, |
| 2759 | 2765 | .llseek = generic_file_llseek, |
| 2766 | + .release = mem_release, | |
| 2760 | 2767 | }; |
| 2761 | 2768 | |
| 2762 | 2769 | #define LSM_DIR_OPS(LSM) \ |
| @@ -960,6 +960,7 @@ · 959 unmodified lines | ||
| 960 | 960 | #ifdef CONFIG_AMD_MEM_ENCRYPT |
| 961 | 961 | #define PERCPU_DECRYPTED_SECTION \ |
| 962 | 962 | . = ALIGN(PAGE_SIZE); \ |
| 963 | + *(.data..decrypted) \ | |
| 963 | 964 | *(.data..percpu..decrypted) \ |
| 964 | 965 | . = ALIGN(PAGE_SIZE); |
| 965 | 966 | #else |
| @@ -106,6 +106,10 @@ · 105 unmodified lines | ||
| 106 | 106 | * <20:16> :: Reserved, Shall be set to zero |
| 107 | 107 | * <15:0> :: USB-IF assigned VID for this cable vendor |
| 108 | 108 | */ |
| 109 | + | |
| 110 | +/* PD Rev2.0 definition */ | |
| 111 | +#define IDH_PTYPE_UNDEF 0 | |
| 112 | + | |
| 109 | 113 | /* SOP Product Type (UFP) */ |
| 110 | 114 | #define IDH_PTYPE_NOT_UFP 0 |
| 111 | 115 | #define IDH_PTYPE_HUB 1 |
| @@ -163,10 +167,10 @@ · 51 unmodified lines | ||
| 163 | 167 | #define UFP_VDO_VER1_2 2 |
| 164 | 168 | |
| 165 | 169 | /* Device Capability */ |
| 166 | −#define DEV_USB2_CAPABLE BIT(0) | |
| 167 | −#define DEV_USB2_BILLBOARD BIT(1) | |
| 168 | −#define DEV_USB3_CAPABLE BIT(2) | |
| 169 | −#define DEV_USB4_CAPABLE BIT(3) | |
| 170 | +#define DEV_USB2_CAPABLE (1 << 0) | |
| 171 | +#define DEV_USB2_BILLBOARD (1 << 1) | |
| 172 | +#define DEV_USB3_CAPABLE (1 << 2) | |
| 173 | +#define DEV_USB4_CAPABLE (1 << 3) | |
| 170 | 174 | |
| 171 | 175 | /* Connector Type */ |
| 172 | 176 | #define UFP_RECEPTACLE 2 |
| @@ -191,9 +195,9 @@ · 18 unmodified lines | ||
| 191 | 195 | |
| 192 | 196 | /* Alternate Modes */ |
| 193 | 197 | #define UFP_ALTMODE_NOT_SUPP 0 |
| 194 | −#define UFP_ALTMODE_TBT3 BIT(0) | |
| 195 | −#define UFP_ALTMODE_RECFG BIT(1) | |
| 196 | −#define UFP_ALTMODE_NO_RECFG BIT(2) | |
| 198 | +#define UFP_ALTMODE_TBT3 (1 << 0) | |
| 199 | +#define UFP_ALTMODE_RECFG (1 << 1) | |
| 200 | +#define UFP_ALTMODE_NO_RECFG (1 << 2) | |
| 197 | 201 | |
| 198 | 202 | /* USB Highest Speed */ |
| 199 | 203 | #define UFP_USB2_ONLY 0 |
| @@ -217,9 +221,9 @@ · 17 unmodified lines | ||
| 217 | 221 | * <4:0> :: Port number |
| 218 | 222 | */ |
| 219 | 223 | #define DFP_VDO_VER1_1 1 |
| 220 | −#define HOST_USB2_CAPABLE BIT(0) | |
| 221 | −#define HOST_USB3_CAPABLE BIT(1) | |
| 222 | −#define HOST_USB4_CAPABLE BIT(2) | |
| 224 | +#define HOST_USB2_CAPABLE (1 << 0) | |
| 225 | +#define HOST_USB3_CAPABLE (1 << 1) | |
| 226 | +#define HOST_USB4_CAPABLE (1 << 2) | |
| 223 | 227 | #define DFP_RECEPTACLE 2 |
| 224 | 228 | #define DFP_CAPTIVE 3 |
| 225 | 229 | |
| @@ -228,7 +232,25 @@ · 2 unmodified lines | ||
| 228 | 232 | | ((pnum) & 0x1f)) |
| 229 | 233 | |
| 230 | 234 | /* |
| 231 | − * Passive Cable VDO | |
| 235 | + * Cable VDO (for both Passive and Active Cable VDO in PD Rev2.0) | |
| 236 | + * --------- | |
| 237 | + * <31:28> :: Cable HW version | |
| 238 | + * <27:24> :: Cable FW version | |
| 239 | + * <23:20> :: Reserved, Shall be set to zero | |
| 240 | + * <19:18> :: type-C to Type-A/B/C/Captive (00b == A, 01 == B, 10 == C, 11 == Captive) | |
| 241 | + * <17> :: Reserved, Shall be set to zero | |
| 242 | + * <16:13> :: cable latency (0001 == <10ns(~1m length)) | |
| 243 | + * <12:11> :: cable termination type (11b == both ends active VCONN req) | |
| 244 | + * <10> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) | |
| 245 | + * <9> :: SSTX2 Directionality support | |
| 246 | + * <8> :: SSRX1 Directionality support | |
| 247 | + * <7> :: SSRX2 Directionality support | |
| 248 | + * <6:5> :: Vbus current handling capability (01b == 3A, 10b == 5A) | |
| 249 | + * <4> :: Vbus through cable (0b == no, 1b == yes) | |
| 250 | + * <3> :: SOP" controller present? (0b == no, 1b == yes) | |
| 251 | + * <2:0> :: USB SS Signaling support | |
| 252 | + * | |
| 253 | + * Passive Cable VDO (PD Rev3.0+) | |
| 232 | 254 | * --------- |
| 233 | 255 | * <31:28> :: Cable HW version |
| 234 | 256 | * <27:24> :: Cable FW version |
| @@ -244,7 +266,7 @@ · 9 unmodified lines | ||
| 244 | 266 | * <4:3> :: Reserved, Shall be set to zero |
| 245 | 267 | * <2:0> :: USB highest speed |
| 246 | 268 | * |
| 247 | − * Active Cable VDO 1 | |
| 269 | + * Active Cable VDO 1 (PD Rev3.0+) | |
| 248 | 270 | * --------- |
| 249 | 271 | * <31:28> :: Cable HW version |
| 250 | 272 | * <27:24> :: Cable FW version |
| @@ -266,7 +288,9 @@ · 15 unmodified lines | ||
| 266 | 288 | #define CABLE_VDO_VER1_0 0 |
| 267 | 289 | #define CABLE_VDO_VER1_3 3 |
| 268 | 290 | |
| 269 | −/* Connector Type */ | |
| 291 | +/* Connector Type (_ATYPE and _BTYPE are for PD Rev2.0 only) */ | |
| 292 | +#define CABLE_ATYPE 0 | |
| 293 | +#define CABLE_BTYPE 1 | |
| 270 | 294 | #define CABLE_CTYPE 2 |
| 271 | 295 | #define CABLE_CAPTIVE 3 |
| 272 | 296 | |
| @@ -303,12 +327,22 @@ · 30 unmodified lines | ||
| 303 | 327 | #define CABLE_CURR_3A 1 |
| 304 | 328 | #define CABLE_CURR_5A 2 |
| 305 | 329 | |
| 330 | +/* USB SuperSpeed Signaling Support (PD Rev2.0) */ | |
| 331 | +#define CABLE_USBSS_U2_ONLY 0 | |
| 332 | +#define CABLE_USBSS_U31_GEN1 1 | |
| 333 | +#define CABLE_USBSS_U31_GEN2 2 | |
| 334 | + | |
| 306 | 335 | /* USB Highest Speed */ |
| 307 | 336 | #define CABLE_USB2_ONLY 0 |
| 308 | 337 | #define CABLE_USB32_GEN1 1 |
| 309 | 338 | #define CABLE_USB32_4_GEN2 2 |
| 310 | 339 | #define CABLE_USB4_GEN3 3 |
| 311 | 340 | |
| 341 | +#define VDO_CABLE(hw, fw, cbl, lat, term, tx1d, tx2d, rx1d, rx2d, cur, vps, sopp, usbss) \ | |
| 342 | + (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18 \ | |
| 343 | + | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11 | (tx1d) << 10 \ | |
| 344 | + | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 | ((cur) & 0x3) << 5 \ | |
| 345 | + | (vps) << 4 | (sopp) << 3 | ((usbss) & 0x7)) | |
| 312 | 346 | #define VDO_PCABLE(hw, fw, ver, conn, lat, term, vbm, cur, spd) \ |
| 313 | 347 | (((hw) & 0xf) << 28 | ((fw) & 0xf) << 24 | ((ver) & 0x7) << 21 \ |
| 314 | 348 | | ((conn) & 0x3) << 18 | ((lat) & 0xf) << 13 | ((term) & 0x3) << 11 \ |
| @@ -373,6 +407,35 @@ · 58 unmodified lines | ||
| 373 | 407 | | ((hops) & 0x3) << 6 | (u2) << 5 | (u32) << 4 | (lane) << 3 \ |
| 374 | 408 | | (iso) << 2 | (gen)) |
| 375 | 409 | |
| 410 | +/* | |
| 411 | + * AMA VDO (PD Rev2.0) | |
| 412 | + * --------- | |
| 413 | + * <31:28> :: Cable HW version | |
| 414 | + * <27:24> :: Cable FW version | |
| 415 | + * <23:12> :: Reserved, Shall be set to zero | |
| 416 | + * <11> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) | |
| 417 | + * <10> :: SSTX2 Directionality support | |
| 418 | + * <9> :: SSRX1 Directionality support | |
| 419 | + * <8> :: SSRX2 Directionality support | |
| 420 | + * <7:5> :: Vconn power | |
| 421 | + * <4> :: Vconn power required | |
| 422 | + * <3> :: Vbus power required | |
| 423 | + * <2:0> :: USB SS Signaling support | |
| 424 | + */ | |
| 425 | +#define VDO_AMA(hw, fw, tx1d, tx2d, rx1d, rx2d, vcpwr, vcr, vbr, usbss) \ | |
| 426 | + (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 \ | |
| 427 | + | (tx1d) << 11 | (tx2d) << 10 | (rx1d) << 9 | (rx2d) << 8 \ | |
| 428 | + | ((vcpwr) & 0x7) << 5 | (vcr) << 4 | (vbr) << 3 \ | |
| 429 | + | ((usbss) & 0x7)) | |
| 430 | + | |
| 431 | +#define PD_VDO_AMA_VCONN_REQ(vdo) (((vdo) >> 4) & 1) | |
| 432 | +#define PD_VDO_AMA_VBUS_REQ(vdo) (((vdo) >> 3) & 1) | |
| 433 | + | |
| 434 | +#define AMA_USBSS_U2_ONLY 0 | |
| 435 | +#define AMA_USBSS_U31_GEN1 1 | |
| 436 | +#define AMA_USBSS_U31_GEN2 2 | |
| 437 | +#define AMA_USBSS_BBONLY 3 | |
| 438 | + | |
| 376 | 439 | /* |
| 377 | 440 | * VPD VDO |
| 378 | 441 | * --------- |
| @@ -830,6 +830,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr); · 829 unmodified lines | ||
| 830 | 830 | |
| 831 | 831 | struct virtchnl_proto_hdrs { |
| 832 | 832 | u8 tunnel_level; |
| 833 | + u8 pad[3]; | |
| 833 | 834 | /** |
| 834 | 835 | * specify where protocol header start from. |
| 835 | 836 | * 0 - from the outer layer |
| @@ -199,6 +199,7 @@ · 198 unmodified lines | ||
| 199 | 199 | * must end with any of these keywords: |
| 200 | 200 | * break; |
| 201 | 201 | * fallthrough; |
| 202 | + * continue; | |
| 202 | 203 | * goto <label>; |
| 203 | 204 | * return [expression]; |
| 204 | 205 | * |
| @@ -3,6 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | #define __LINUX_ENTRYKVM_H |
| 4 | 4 | |
| 5 | 5 | #include <linux/entry-common.h> |
| 6 | +#include <linux/tick.h> | |
| 6 | 7 | |
| 7 | 8 | /* Transfer to guest mode work */ |
| 8 | 9 | #ifdef CONFIG_KVM_XFER_TO_GUEST_WORK |
| @@ -57,7 +58,7 @@ int xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu); · 48 unmodified lines | ||
| 57 | 58 | static inline void xfer_to_guest_mode_prepare(void) |
| 58 | 59 | { |
| 59 | 60 | lockdep_assert_irqs_disabled(); |
| 60 | − rcu_nocb_flush_deferred_wakeup(); | |
| 61 | + tick_nohz_user_enter_prepare(); | |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | /** |
| @@ -51,6 +51,10 @@ extern struct ctl_table fanotify_table[]; /* for sysctl */ · 50 unmodified lines | ||
| 51 | 51 | #define FANOTIFY_INIT_FLAGS (FANOTIFY_ADMIN_INIT_FLAGS | \ |
| 52 | 52 | FANOTIFY_USER_INIT_FLAGS) |
| 53 | 53 | |
| 54 | +/* Internal group flags */ | |
| 55 | +#define FANOTIFY_UNPRIV 0x80000000 | |
| 56 | +#define FANOTIFY_INTERNAL_GROUP_FLAGS (FANOTIFY_UNPRIV) | |
| 57 | + | |
| 54 | 58 | #define FANOTIFY_MARK_TYPE_BITS (FAN_MARK_INODE | FAN_MARK_MOUNT | \ |
| 55 | 59 | FAN_MARK_FILESYSTEM) |
| 56 | 60 | |
| @@ -659,6 +659,9 @@ static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, · 658 unmodified lines | ||
| 659 | 659 | /* drivers/video/fb_defio.c */ |
| 660 | 660 | int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma); |
| 661 | 661 | extern void fb_deferred_io_init(struct fb_info *info); |
| 662 | +extern void fb_deferred_io_open(struct fb_info *info, | |
| 663 | + struct inode *inode, | |
| 664 | + struct file *file); | |
| 662 | 665 | extern void fb_deferred_io_cleanup(struct fb_info *info); |
| 663 | 666 | extern int fb_deferred_io_fsync(struct file *file, loff_t start, |
| 664 | 667 | loff_t end, int datasync); |
| @@ -1167,8 +1167,7 @@ static inline void hid_hw_wait(struct hid_device *hdev) · 1166 unmodified lines | ||
| 1167 | 1167 | */ |
| 1168 | 1168 | static inline u32 hid_report_len(struct hid_report *report) |
| 1169 | 1169 | { |
| 1170 | − /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ | |
| 1171 | − return ((report->size - 1) >> 3) + 1 + (report->id > 0); | |
| 1170 | + return DIV_ROUND_UP(report->size, 8) + (report->id > 0); | |
| 1172 | 1171 | } |
| 1173 | 1172 | |
| 1174 | 1173 | int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, |
| @@ -332,12 +332,30 @@ static inline struct host1x_device *to_host1x_device(struct device *dev) · 331 unmodified lines | ||
| 332 | 332 | int host1x_device_init(struct host1x_device *device); |
| 333 | 333 | int host1x_device_exit(struct host1x_device *device); |
| 334 | 334 | |
| 335 | −int __host1x_client_register(struct host1x_client *client, | |
| 336 | − struct lock_class_key *key); | |
| 337 | −#define host1x_client_register(class) \ | |
| 338 | − ({ \ | |
| 339 | − static struct lock_class_key __key; \ | |
| 340 | − __host1x_client_register(class, &__key); \ | |
| 335 | +void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key); | |
| 336 | +void host1x_client_exit(struct host1x_client *client); | |
| 337 | + | |
| 338 | +#define host1x_client_init(client) \ | |
| 339 | + ({ \ | |
| 340 | + static struct lock_class_key __key; \ | |
| 341 | + __host1x_client_init(client, &__key); \ | |
| 342 | + }) | |
| 343 | + | |
| 344 | +int __host1x_client_register(struct host1x_client *client); | |
| 345 | + | |
| 346 | +/* | |
| 347 | + * Note that this wrapper calls __host1x_client_init() for compatibility | |
| 348 | + * with existing callers. Callers that want to separately initialize and | |
| 349 | + * register a host1x client must first initialize using either of the | |
| 350 | + * __host1x_client_init() or host1x_client_init() functions and then use | |
| 351 | + * the low-level __host1x_client_register() function to avoid the client | |
| 352 | + * getting reinitialized. | |
| 353 | + */ | |
| 354 | +#define host1x_client_register(client) \ | |
| 355 | + ({ \ | |
| 356 | + static struct lock_class_key __key; \ | |
| 357 | + __host1x_client_init(client, &__key); \ | |
| 358 | + __host1x_client_register(client); \ | |
| 341 | 359 | }) |
| 342 | 360 | |
| 343 | 361 | int host1x_client_unregister(struct host1x_client *client); |
| @@ -1185,7 +1185,15 @@ __gfn_to_memslot(struct kvm_memslots *slots, gfn_t gfn) · 1184 unmodified lines | ||
| 1185 | 1185 | static inline unsigned long |
| 1186 | 1186 | __gfn_to_hva_memslot(const struct kvm_memory_slot *slot, gfn_t gfn) |
| 1187 | 1187 | { |
| 1188 | − return slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE; | |
| 1188 | + /* | |
| 1189 | + * The index was checked originally in search_memslots. To avoid | |
| 1190 | + * that a malicious guest builds a Spectre gadget out of e.g. page | |
| 1191 | + * table walks, do not let the processor speculate loads outside | |
| 1192 | + * the guest's registered memslots. | |
| 1193 | + */ | |
| 1194 | + unsigned long offset = gfn - slot->base_gfn; | |
| 1195 | + offset = array_index_nospec(offset, slot->npages); | |
| 1196 | + return slot->userspace_addr + offset * PAGE_SIZE; | |
| 1189 | 1197 | } |
| 1190 | 1198 | |
| 1191 | 1199 | static inline int memslot_id(struct kvm *kvm, gfn_t gfn) |
| @@ -26,9 +26,7 @@ struct bd70528_data { · 25 unmodified lines | ||
| 26 | 26 | struct mutex rtc_timer_lock; |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | −#define BD70528_BUCK_VOLTS 17 | |
| 30 | −#define BD70528_BUCK_VOLTS 17 | |
| 31 | −#define BD70528_BUCK_VOLTS 17 | |
| 29 | +#define BD70528_BUCK_VOLTS 0x10 | |
| 32 | 30 | #define BD70528_LDO_VOLTS 0x20 |
| 33 | 31 | |
| 34 | 32 | #define BD70528_REG_BUCK1_EN 0x0F |
| @@ -26,11 +26,11 @@ enum { · 25 unmodified lines | ||
| 26 | 26 | BD71828_REGULATOR_AMOUNT, |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | −#define BD71828_BUCK1267_VOLTS 0xEF | |
| 30 | −#define BD71828_BUCK3_VOLTS 0x10 | |
| 31 | −#define BD71828_BUCK4_VOLTS 0x20 | |
| 32 | −#define BD71828_BUCK5_VOLTS 0x10 | |
| 33 | −#define BD71828_LDO_VOLTS 0x32 | |
| 29 | +#define BD71828_BUCK1267_VOLTS 0x100 | |
| 30 | +#define BD71828_BUCK3_VOLTS 0x20 | |
| 31 | +#define BD71828_BUCK4_VOLTS 0x40 | |
| 32 | +#define BD71828_BUCK5_VOLTS 0x20 | |
| 33 | +#define BD71828_LDO_VOLTS 0x40 | |
| 34 | 34 | /* LDO6 is fixed 1.8V voltage */ |
| 35 | 35 | #define BD71828_LDO_6_VOLTAGE 1800000 |
| 36 | 36 | |
| @@ -630,6 +630,7 @@ struct mlx4_caps { · 629 unmodified lines | ||
| 630 | 630 | bool wol_port[MLX4_MAX_PORTS + 1]; |
| 631 | 631 | struct mlx4_rate_limit_caps rl_caps; |
| 632 | 632 | u32 health_buffer_addrs; |
| 633 | + bool map_clock_to_user; | |
| 633 | 634 | }; |
| 634 | 635 | |
| 635 | 636 | struct mlx4_buf_list { |
| @@ -1289,6 +1289,8 @@ enum mlx5_fc_bulk_alloc_bitmask { · 1288 unmodified lines | ||
| 1289 | 1289 | |
| 1290 | 1290 | #define MLX5_FC_BULK_NUM_FCS(fc_enum) (MLX5_FC_BULK_SIZE_FACTOR * (fc_enum)) |
| 1291 | 1291 | |
| 1292 | +#define MLX5_FT_MAX_MULTIPATH_LEVEL 63 | |
| 1293 | + | |
| 1292 | 1294 | enum { |
| 1293 | 1295 | MLX5_STEERING_FORMAT_CONNECTX_5 = 0, |
| 1294 | 1296 | MLX5_STEERING_FORMAT_CONNECTX_6DX = 1, |
| @@ -445,13 +445,6 @@ struct mm_struct { · 444 unmodified lines | ||
| 445 | 445 | */ |
| 446 | 446 | atomic_t has_pinned; |
| 447 | 447 | |
| 448 | − /** | |
| 449 | − * @write_protect_seq: Locked when any thread is write | |
| 450 | − * protecting pages mapped by this mm to enforce a later COW, | |
| 451 | − * for instance during page table copying for fork(). | |
| 452 | − */ | |
| 453 | − seqcount_t write_protect_seq; | |
| 454 | − | |
| 455 | 448 | #ifdef CONFIG_MMU |
| 456 | 449 | atomic_long_t pgtables_bytes; /* PTE page table pages */ |
| 457 | 450 | #endif |
| @@ -460,6 +453,18 @@ struct mm_struct { · 2 unmodified lines | ||
| 460 | 453 | spinlock_t page_table_lock; /* Protects page tables and some |
| 461 | 454 | * counters |
| 462 | 455 | */ |
| 456 | + /* | |
| 457 | + * With some kernel config, the current mmap_lock's offset | |
| 458 | + * inside 'mm_struct' is at 0x120, which is very optimal, as | |
| 459 | + * its two hot fields 'count' and 'owner' sit in 2 different | |
| 460 | + * cachelines, and when mmap_lock is highly contended, both | |
| 461 | + * of the 2 fields will be accessed frequently, current layout | |
| 462 | + * will help to reduce cache bouncing. | |
| 463 | + * | |
| 464 | + * So please be careful with adding new fields before | |
| 465 | + * mmap_lock, which can easily push the 2 fields into one | |
| 466 | + * cacheline. | |
| 467 | + */ | |
| 463 | 468 | struct rw_semaphore mmap_lock; |
| 464 | 469 | |
| 465 | 470 | struct list_head mmlist; /* List of maybe swapped mm's. These |
| @@ -480,7 +485,15 @@ struct mm_struct { · 14 unmodified lines | ||
| 480 | 485 | unsigned long stack_vm; /* VM_STACK */ |
| 481 | 486 | unsigned long def_flags; |
| 482 | 487 | |
| 488 | + /** | |
| 489 | + * @write_protect_seq: Locked when any thread is write | |
| 490 | + * protecting pages mapped by this mm to enforce a later COW, | |
| 491 | + * for instance during page table copying for fork(). | |
| 492 | + */ | |
| 493 | + seqcount_t write_protect_seq; | |
| 494 | + | |
| 483 | 495 | spinlock_t arg_lock; /* protect the below fields */ |
| 496 | + | |
| 484 | 497 | unsigned long start_code, end_code, start_data, end_data; |
| 485 | 498 | unsigned long start_brk, brk, start_stack; |
| 486 | 499 | unsigned long arg_start, arg_end, env_start, env_end; |
| @@ -2344,6 +2344,7 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, · 2343 unmodified lines | ||
| 2344 | 2344 | struct device_node; |
| 2345 | 2345 | struct irq_domain; |
| 2346 | 2346 | struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus); |
| 2347 | +bool pci_host_of_has_msi_map(struct device *dev); | |
| 2347 | 2348 | |
| 2348 | 2349 | /* Arch may override this (weak) */ |
| 2349 | 2350 | struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus); |
| @@ -2351,6 +2352,7 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus); · 1 unmodified line | ||
| 2351 | 2352 | #else /* CONFIG_OF */ |
| 2352 | 2353 | static inline struct irq_domain * |
| 2353 | 2354 | pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; } |
| 2355 | +static inline bool pci_host_of_has_msi_map(struct device *dev) { return false; } | |
| 2354 | 2356 | #endif /* CONFIG_OF */ |
| 2355 | 2357 | |
| 2356 | 2358 | static inline struct device_node * |
| @@ -432,6 +432,14 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres · 431 unmodified lines | ||
| 432 | 432 | * To be differentiate with macro pte_mkyoung, this macro is used on platforms |
| 433 | 433 | * where software maintains page access bit. |
| 434 | 434 | */ |
| 435 | +#ifndef pte_sw_mkyoung | |
| 436 | +static inline pte_t pte_sw_mkyoung(pte_t pte) | |
| 437 | +{ | |
| 438 | + return pte; | |
| 439 | +} | |
| 440 | +#define pte_sw_mkyoung pte_sw_mkyoung | |
| 441 | +#endif | |
| 442 | + | |
| 435 | 443 | #ifndef pte_savedwrite |
| 436 | 444 | #define pte_savedwrite pte_write |
| 437 | 445 | #endif |
| @@ -50,6 +50,7 @@ struct sysc_regbits { · 49 unmodified lines | ||
| 50 | 50 | s8 emufree_shift; |
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | +#define SYSC_QUIRK_REINIT_ON_RESUME BIT(27) | |
| 53 | 54 | #define SYSC_QUIRK_GPMC_DEBUG BIT(26) |
| 54 | 55 | #define SYSC_MODULE_QUIRK_ENA_RESETDONE BIT(25) |
| 55 | 56 | #define SYSC_MODULE_QUIRK_PRUSS BIT(24) |
| @@ -1109,6 +1109,7 @@ struct pcr_ops { · 1108 unmodified lines | ||
| 1109 | 1109 | }; |
| 1110 | 1110 | |
| 1111 | 1111 | enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN}; |
| 1112 | +enum ASPM_MODE {ASPM_MODE_CFG, ASPM_MODE_REG}; | |
| 1112 | 1113 | |
| 1113 | 1114 | #define ASPM_L1_1_EN BIT(0) |
| 1114 | 1115 | #define ASPM_L1_2_EN BIT(1) |
| @@ -1234,6 +1235,7 @@ struct rtsx_pcr { · 119 unmodified lines | ||
| 1234 | 1235 | u8 card_drive_sel; |
| 1235 | 1236 | #define ASPM_L1_EN 0x02 |
| 1236 | 1237 | u8 aspm_en; |
| 1238 | + enum ASPM_MODE aspm_mode; | |
| 1237 | 1239 | bool aspm_enabled; |
| 1238 | 1240 | |
| 1239 | 1241 | #define PCR_MS_PMOS (1 << 0) |
| @@ -350,11 +350,19 @@ struct load_weight { · 349 unmodified lines | ||
| 350 | 350 | * Only for tasks we track a moving average of the past instantaneous |
| 351 | 351 | * estimated utilization. This allows to absorb sporadic drops in utilization |
| 352 | 352 | * of an otherwise almost periodic task. |
| 353 | + * | |
| 354 | + * The UTIL_AVG_UNCHANGED flag is used to synchronize util_est with util_avg | |
| 355 | + * updates. When a task is dequeued, its util_est should not be updated if its | |
| 356 | + * util_avg has not been updated in the meantime. | |
| 357 | + * This information is mapped into the MSB bit of util_est.enqueued at dequeue | |
| 358 | + * time. Since max value of util_est.enqueued for a task is 1024 (PELT util_avg | |
| 359 | + * for a task) it is safe to use MSB. | |
| 353 | 360 | */ |
| 354 | 361 | struct util_est { |
| 355 | 362 | unsigned int enqueued; |
| 356 | 363 | unsigned int ewma; |
| 357 | 364 | #define UTIL_EST_WEIGHT_SHIFT 2 |
| 365 | +#define UTIL_AVG_UNCHANGED 0x80000000 | |
| 358 | 366 | } __attribute__((__aligned__(sizeof(u64)))); |
| 359 | 367 | |
| 360 | 368 | /* |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <linux/context_tracking_state.h> |
| 12 | 12 | #include <linux/cpumask.h> |
| 13 | 13 | #include <linux/sched.h> |
| 14 | +#include <linux/rcupdate.h> | |
| 14 | 15 | |
| 15 | 16 | #ifdef CONFIG_GENERIC_CLOCKEVENTS |
| 16 | 17 | extern void __init tick_init(void); |
| @@ -300,4 +301,10 @@ static inline void tick_nohz_task_switch(void) · 283 unmodified lines | ||
| 300 | 301 | __tick_nohz_task_switch(); |
| 301 | 302 | } |
| 302 | 303 | |
| 304 | +static inline void tick_nohz_user_enter_prepare(void) | |
| 305 | +{ | |
| 306 | + if (tick_nohz_full_cpu(smp_processor_id())) | |
| 307 | + rcu_nocb_flush_deferred_wakeup(); | |
| 308 | +} | |
| 309 | + | |
| 303 | 310 | #endif |
| @@ -460,7 +460,7 @@ static inline unsigned int rdo_max_power(u32 rdo) · 459 unmodified lines | ||
| 460 | 460 | #define PD_T_RECEIVER_RESPONSE 15 /* 15ms max */ |
| 461 | 461 | #define PD_T_SOURCE_ACTIVITY 45 |
| 462 | 462 | #define PD_T_SINK_ACTIVITY 135 |
| 463 | −#define PD_T_SINK_WAIT_CAP 240 | |
| 463 | +#define PD_T_SINK_WAIT_CAP 310 /* 310 - 620 ms */ | |
| 464 | 464 | #define PD_T_PS_TRANSITION 500 |
| 465 | 465 | #define PD_T_SRC_TRANSITION 35 |
| 466 | 466 | #define PD_T_DRP_SNK 40 |
| @@ -24,8 +24,4 @@ enum usb_pd_ext_sdb_fields { · 23 unmodified lines | ||
| 24 | 24 | #define USB_PD_EXT_SDB_EVENT_OVP BIT(3) |
| 25 | 25 | #define USB_PD_EXT_SDB_EVENT_CF_CV_MODE BIT(4) |
| 26 | 26 | |
| 27 | −#define USB_PD_EXT_SDB_PPS_EVENTS (USB_PD_EXT_SDB_EVENT_OCP | \ | |
| 28 | − USB_PD_EXT_SDB_EVENT_OTP | \ | |
| 29 | − USB_PD_EXT_SDB_EVENT_OVP) | |
| 30 | − | |
| 31 | 27 | #endif /* __LINUX_USB_PD_EXT_SDB_H */ |
| @@ -119,7 +119,7 @@ void caif_free_client(struct cflayer *adap_layer); · 118 unmodified lines | ||
| 119 | 119 | * The link_support layer is used to add any Link Layer specific |
| 120 | 120 | * framing. |
| 121 | 121 | */ |
| 122 | −void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, | |
| 122 | +int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, | |
| 123 | 123 | struct cflayer *link_support, int head_room, |
| 124 | 124 | struct cflayer **layer, int (**rcv_func)( |
| 125 | 125 | struct sk_buff *, struct net_device *, |
| @@ -62,7 +62,7 @@ void cfcnfg_remove(struct cfcnfg *cfg); · 61 unmodified lines | ||
| 62 | 62 | * @fcs: Specify if checksum is used in CAIF Framing Layer. |
| 63 | 63 | * @head_room: Head space needed by link specific protocol. |
| 64 | 64 | */ |
| 65 | −void | |
| 65 | +int | |
| 66 | 66 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, |
| 67 | 67 | struct net_device *dev, struct cflayer *phy_layer, |
| 68 | 68 | enum cfcnfg_phy_preference pref, |
| @@ -9,4 +9,5 @@ · 8 unmodified lines | ||
| 9 | 9 | #include <net/caif/caif_layer.h> |
| 10 | 10 | |
| 11 | 11 | struct cflayer *cfserl_create(int instance, bool use_stx); |
| 12 | +void cfserl_release(struct cflayer *layer); | |
| 12 | 13 | #endif |
| @@ -1506,16 +1506,10 @@ struct nft_trans_chain { · 1505 unmodified lines | ||
| 1506 | 1506 | |
| 1507 | 1507 | struct nft_trans_table { |
| 1508 | 1508 | bool update; |
| 1509 | − u8 state; | |
| 1510 | − u32 flags; | |
| 1511 | 1509 | }; |
| 1512 | 1510 | |
| 1513 | 1511 | #define nft_trans_table_update(trans) \ |
| 1514 | 1512 | (((struct nft_trans_table *)trans->data)->update) |
| 1515 | −#define nft_trans_table_state(trans) \ | |
| 1516 | − (((struct nft_trans_table *)trans->data)->state) | |
| 1517 | −#define nft_trans_table_flags(trans) \ | |
| 1518 | − (((struct nft_trans_table *)trans->data)->flags) | |
| 1519 | 1513 | |
| 1520 | 1514 | struct nft_trans_elem { |
| 1521 | 1515 | struct nft_set *set; |
| @@ -193,7 +193,11 @@ struct tls_offload_context_tx { · 192 unmodified lines | ||
| 193 | 193 | (sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX) |
| 194 | 194 | |
| 195 | 195 | enum tls_context_flags { |
| 196 | − TLS_RX_SYNC_RUNNING = 0, | |
| 196 | + /* tls_device_down was called after the netdev went down, device state | |
| 197 | + * was released, and kTLS works in software, even though rx_conf is | |
| 198 | + * still TLS_HW (needed for transition). | |
| 199 | + */ | |
| 200 | + TLS_RX_DEV_DEGRADED = 0, | |
| 197 | 201 | /* Unlike RX where resync is driven entirely by the core in TX only |
| 198 | 202 | * the driver knows when things went out of sync, so we need the flag |
| 199 | 203 | * to be atomic. |
| @@ -266,6 +270,7 @@ struct tls_context { · 66 unmodified lines | ||
| 266 | 270 | |
| 267 | 271 | /* cache cold stuff */ |
| 268 | 272 | struct proto *sk_proto; |
| 273 | + struct sock *sk; | |
| 269 | 274 | |
| 270 | 275 | void (*sk_destruct)(struct sock *sk); |
| 271 | 276 | |
| @@ -448,6 +453,9 @@ static inline u16 tls_user_config(struct tls_context *ctx, bool tx) · 176 unmodified lines | ||
| 448 | 453 | struct sk_buff * |
| 449 | 454 | tls_validate_xmit_skb(struct sock *sk, struct net_device *dev, |
| 450 | 455 | struct sk_buff *skb); |
| 456 | +struct sk_buff * | |
| 457 | +tls_validate_xmit_skb_sw(struct sock *sk, struct net_device *dev, | |
| 458 | + struct sk_buff *skb); | |
| 451 | 459 | |
| 452 | 460 | static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk) |
| 453 | 461 | { |
| @@ -611,6 +611,7 @@ · 610 unmodified lines | ||
| 611 | 611 | #define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */ |
| 612 | 612 | #define KEY_ASSISTANT 0x247 /* AL Context-aware desktop assistant */ |
| 613 | 613 | #define KEY_KBD_LAYOUT_NEXT 0x248 /* AC Next Keyboard Layout Select */ |
| 614 | +#define KEY_EMOJI_PICKER 0x249 /* Show/hide emoji picker (HUTRR101) */ | |
| 614 | 615 | |
| 615 | 616 | #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ |
| 616 | 617 | #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ |
| @@ -280,6 +280,7 @@ struct io_uring_params { · 279 unmodified lines | ||
| 280 | 280 | #define IORING_FEAT_SQPOLL_NONFIXED (1U << 7) |
| 281 | 281 | #define IORING_FEAT_EXT_ARG (1U << 8) |
| 282 | 282 | #define IORING_FEAT_NATIVE_WORKERS (1U << 9) |
| 283 | +#define IORING_FEAT_RSRC_TAGS (1U << 10) | |
| 283 | 284 | |
| 284 | 285 | /* |
| 285 | 286 | * io_uring_register(2) opcodes and arguments |
| @@ -298,8 +299,12 @@ enum { · 12 unmodified lines | ||
| 298 | 299 | IORING_UNREGISTER_PERSONALITY = 10, |
| 299 | 300 | IORING_REGISTER_RESTRICTIONS = 11, |
| 300 | 301 | IORING_REGISTER_ENABLE_RINGS = 12, |
| 301 | − IORING_REGISTER_RSRC = 13, | |
| 302 | − IORING_REGISTER_RSRC_UPDATE = 14, | |
| 302 | + | |
| 303 | + /* extended with tagging */ | |
| 304 | + IORING_REGISTER_FILES2 = 13, | |
| 305 | + IORING_REGISTER_FILES_UPDATE2 = 14, | |
| 306 | + IORING_REGISTER_BUFFERS2 = 15, | |
| 307 | + IORING_REGISTER_BUFFERS_UPDATE = 16, | |
| 303 | 308 | |
| 304 | 309 | /* this goes last */ |
| 305 | 310 | IORING_REGISTER_LAST |
| @@ -312,14 +317,10 @@ struct io_uring_files_update { · 6 unmodified lines | ||
| 312 | 317 | __aligned_u64 /* __s32 * */ fds; |
| 313 | 318 | }; |
| 314 | 319 | |
| 315 | −enum { | |
| 316 | − IORING_RSRC_FILE = 0, | |
| 317 | − IORING_RSRC_BUFFER = 1, | |
| 318 | −}; | |
| 319 | − | |
| 320 | 320 | struct io_uring_rsrc_register { |
| 321 | − __u32 type; | |
| 322 | 321 | __u32 nr; |
| 322 | + __u32 resv; | |
| 323 | + __u64 resv2; | |
| 323 | 324 | __aligned_u64 data; |
| 324 | 325 | __aligned_u64 tags; |
| 325 | 326 | }; |
| @@ -335,8 +336,8 @@ struct io_uring_rsrc_update2 { · 9 unmodified lines | ||
| 335 | 336 | __u32 resv; |
| 336 | 337 | __aligned_u64 data; |
| 337 | 338 | __aligned_u64 tags; |
| 338 | − __u32 type; | |
| 339 | 339 | __u32 nr; |
| 340 | + __u32 resv2; | |
| 340 | 341 | }; |
| 341 | 342 | |
| 342 | 343 | /* Skip updating fd indexes set to this value in the fd table */ |
| @@ -54,7 +54,7 @@ · 53 unmodified lines | ||
| 54 | 54 | #define VIRTIO_ID_SOUND 25 /* virtio sound */ |
| 55 | 55 | #define VIRTIO_ID_FS 26 /* virtio filesystem */ |
| 56 | 56 | #define VIRTIO_ID_PMEM 27 /* virtio pmem */ |
| 57 | −#define VIRTIO_ID_BT 28 /* virtio bluetooth */ | |
| 58 | 57 | #define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */ |
| 58 | +#define VIRTIO_ID_BT 40 /* virtio bluetooth */ | |
| 59 | 59 | |
| 60 | 60 | #endif /* _LINUX_VIRTIO_IDS_H */ |
| @@ -1537,7 +1537,7 @@ static noinline void __init kernel_init_freeable(void) · 1536 unmodified lines | ||
| 1537 | 1537 | */ |
| 1538 | 1538 | set_mems_allowed(node_states[N_MEMORY]); |
| 1539 | 1539 | |
| 1540 | − cad_pid = task_pid(current); | |
| 1540 | + cad_pid = get_pid(task_pid(current)); | |
| 1541 | 1541 | |
| 1542 | 1542 | smp_prepare_cpus(setup_max_cpus); |
| 1543 | 1543 | |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <linux/jiffies.h> |
| 15 | 15 | #include <linux/pid_namespace.h> |
| 16 | 16 | #include <linux/proc_ns.h> |
| 17 | +#include <linux/security.h> | |
| 17 | 18 | |
| 18 | 19 | #include "../../lib/kstrtox.h" |
| 19 | 20 | |
| @@ -1069,11 +1070,13 @@ bpf_base_func_proto(enum bpf_func_id func_id) · 1049 unmodified lines | ||
| 1069 | 1070 | case BPF_FUNC_probe_read_user: |
| 1070 | 1071 | return &bpf_probe_read_user_proto; |
| 1071 | 1072 | case BPF_FUNC_probe_read_kernel: |
| 1072 | − return &bpf_probe_read_kernel_proto; | |
| 1073 | + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? | |
| 1074 | + NULL : &bpf_probe_read_kernel_proto; | |
| 1073 | 1075 | case BPF_FUNC_probe_read_user_str: |
| 1074 | 1076 | return &bpf_probe_read_user_str_proto; |
| 1075 | 1077 | case BPF_FUNC_probe_read_kernel_str: |
| 1076 | − return &bpf_probe_read_kernel_str_proto; | |
| 1078 | + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? | |
| 1079 | + NULL : &bpf_probe_read_kernel_str_proto; | |
| 1077 | 1080 | case BPF_FUNC_snprintf_btf: |
| 1078 | 1081 | return &bpf_snprintf_btf_proto; |
| 1079 | 1082 | case BPF_FUNC_snprintf: |
| @@ -820,6 +820,10 @@ static int cgroup1_rename(struct kernfs_node *kn, struct kernfs_node *new_parent · 819 unmodified lines | ||
| 820 | 820 | struct cgroup *cgrp = kn->priv; |
| 821 | 821 | int ret; |
| 822 | 822 | |
| 823 | + /* do not accept '\n' to prevent making /proc/<pid>/cgroup unparsable */ | |
| 824 | + if (strchr(new_name_str, '\n')) | |
| 825 | + return -EINVAL; | |
| 826 | + | |
| 823 | 827 | if (kernfs_type(kn) != KERNFS_DIR) |
| 824 | 828 | return -ENOTDIR; |
| 825 | 829 | if (kn->parent != new_parent) |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | #include <linux/highmem.h> |
| 6 | 6 | #include <linux/livepatch.h> |
| 7 | 7 | #include <linux/audit.h> |
| 8 | +#include <linux/tick.h> | |
| 8 | 9 | |
| 9 | 10 | #include "common.h" |
| 10 | 11 | |
| @@ -186,7 +187,7 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, · 175 unmodified lines | ||
| 186 | 187 | local_irq_disable_exit_to_user(); |
| 187 | 188 | |
| 188 | 189 | /* Check if any of the above work has queued a deferred wakeup */ |
| 189 | − rcu_nocb_flush_deferred_wakeup(); | |
| 190 | + tick_nohz_user_enter_prepare(); | |
| 190 | 191 | |
| 191 | 192 | ti_work = READ_ONCE(current_thread_info()->flags); |
| 192 | 193 | } |
| @@ -202,7 +203,7 @@ static void exit_to_user_mode_prepare(struct pt_regs *regs) · 9 unmodified lines | ||
| 202 | 203 | lockdep_assert_irqs_disabled(); |
| 203 | 204 | |
| 204 | 205 | /* Flush pending rcuog wakeup before the last need_resched() check */ |
| 205 | − rcu_nocb_flush_deferred_wakeup(); | |
| 206 | + tick_nohz_user_enter_prepare(); | |
| 206 | 207 | |
| 207 | 208 | if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK)) |
| 208 | 209 | ti_work = exit_to_user_mode_loop(regs, ti_work); |
| @@ -4609,7 +4609,9 @@ find_get_context(struct pmu *pmu, struct task_struct *task, · 4608 unmodified lines | ||
| 4609 | 4609 | cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); |
| 4610 | 4610 | ctx = &cpuctx->ctx; |
| 4611 | 4611 | get_ctx(ctx); |
| 4612 | + raw_spin_lock_irqsave(&ctx->lock, flags); | |
| 4612 | 4613 | ++ctx->pin_count; |
| 4614 | + raw_spin_unlock_irqrestore(&ctx->lock, flags); | |
| 4613 | 4615 | |
| 4614 | 4616 | return ctx; |
| 4615 | 4617 | } |
| @@ -70,9 +70,6 @@ bool irq_work_queue(struct irq_work *work) · 69 unmodified lines | ||
| 70 | 70 | if (!irq_work_claim(work)) |
| 71 | 71 | return false; |
| 72 | 72 | |
| 73 | − /*record irq_work call stack in order to print it in KASAN reports*/ | |
| 74 | − kasan_record_aux_stack(work); | |
| 75 | − | |
| 76 | 73 | /* Queue the entry and raise the IPI if needed. */ |
| 77 | 74 | preempt_disable(); |
| 78 | 75 | __irq_work_queue_local(work); |
| @@ -885,6 +885,7 @@ static const struct seq_operations sched_debug_sops = { · 884 unmodified lines | ||
| 885 | 885 | #define __PS(S, F) SEQ_printf(m, "%-45s:%21Ld\n", S, (long long)(F)) |
| 886 | 886 | #define __P(F) __PS(#F, F) |
| 887 | 887 | #define P(F) __PS(#F, p->F) |
| 888 | +#define PM(F, M) __PS(#F, p->F & (M)) | |
| 888 | 889 | #define __PSN(S, F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", S, SPLIT_NS((long long)(F))) |
| 889 | 890 | #define __PN(F) __PSN(#F, F) |
| 890 | 891 | #define PN(F) __PSN(#F, p->F) |
| @@ -1011,7 +1012,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, · 120 unmodified lines | ||
| 1011 | 1012 | P(se.avg.util_avg); |
| 1012 | 1013 | P(se.avg.last_update_time); |
| 1013 | 1014 | P(se.avg.util_est.ewma); |
| 1014 | − P(se.avg.util_est.enqueued); | |
| 1015 | + PM(se.avg.util_est.enqueued, ~UTIL_AVG_UNCHANGED); | |
| 1015 | 1016 | #endif |
| 1016 | 1017 | #ifdef CONFIG_UCLAMP_TASK |
| 1017 | 1018 | __PS("uclamp.min", p->uclamp_req[UCLAMP_MIN].value); |
| @@ -3499,10 +3499,9 @@ update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cf · 3498 unmodified lines | ||
| 3499 | 3499 | static inline void |
| 3500 | 3500 | update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) |
| 3501 | 3501 | { |
| 3502 | − long delta_avg, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum; | |
| 3502 | + long delta, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum; | |
| 3503 | 3503 | unsigned long load_avg; |
| 3504 | 3504 | u64 load_sum = 0; |
| 3505 | − s64 delta_sum; | |
| 3506 | 3505 | u32 divider; |
| 3507 | 3506 | |
| 3508 | 3507 | if (!runnable_sum) |
| @@ -3549,13 +3548,13 @@ update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq · 40 unmodified lines | ||
| 3549 | 3548 | load_sum = (s64)se_weight(se) * runnable_sum; |
| 3550 | 3549 | load_avg = div_s64(load_sum, divider); |
| 3551 | 3550 | |
| 3552 | − delta_sum = load_sum - (s64)se_weight(se) * se->avg.load_sum; | |
| 3553 | − delta_avg = load_avg - se->avg.load_avg; | |
| 3551 | + delta = load_avg - se->avg.load_avg; | |
| 3554 | 3552 | |
| 3555 | 3553 | se->avg.load_sum = runnable_sum; |
| 3556 | 3554 | se->avg.load_avg = load_avg; |
| 3557 | − add_positive(&cfs_rq->avg.load_avg, delta_avg); | |
| 3558 | − add_positive(&cfs_rq->avg.load_sum, delta_sum); | |
| 3555 | + | |
| 3556 | + add_positive(&cfs_rq->avg.load_avg, delta); | |
| 3557 | + cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * divider; | |
| 3559 | 3558 | } |
| 3560 | 3559 | |
| 3561 | 3560 | static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum) |
| @@ -3766,11 +3765,17 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s · 204 unmodified lines | ||
| 3766 | 3765 | */ |
| 3767 | 3766 | static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) |
| 3768 | 3767 | { |
| 3768 | + /* | |
| 3769 | + * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. | |
| 3770 | + * See ___update_load_avg() for details. | |
| 3771 | + */ | |
| 3772 | + u32 divider = get_pelt_divider(&cfs_rq->avg); | |
| 3773 | + | |
| 3769 | 3774 | dequeue_load_avg(cfs_rq, se); |
| 3770 | 3775 | sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); |
| 3771 | − sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); | |
| 3776 | + cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; | |
| 3772 | 3777 | sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); |
| 3773 | − sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum); | |
| 3778 | + cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; | |
| 3774 | 3779 | |
| 3775 | 3780 | add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); |
| 3776 | 3781 | |
| @@ -3902,7 +3907,7 @@ static inline unsigned long _task_util_est(struct task_struct *p) · 125 unmodified lines | ||
| 3902 | 3907 | { |
| 3903 | 3908 | struct util_est ue = READ_ONCE(p->se.avg.util_est); |
| 3904 | 3909 | |
| 3905 | − return (max(ue.ewma, ue.enqueued) | UTIL_AVG_UNCHANGED); | |
| 3910 | + return max(ue.ewma, (ue.enqueued & ~UTIL_AVG_UNCHANGED)); | |
| 3906 | 3911 | } |
| 3907 | 3912 | |
| 3908 | 3913 | static inline unsigned long task_util_est(struct task_struct *p) |
| @@ -4002,7 +4007,7 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, · 93 unmodified lines | ||
| 4002 | 4007 | * Reset EWMA on utilization increases, the moving average is used only |
| 4003 | 4008 | * to smooth utilization decreases. |
| 4004 | 4009 | */ |
| 4005 | − ue.enqueued = (task_util(p) | UTIL_AVG_UNCHANGED); | |
| 4010 | + ue.enqueued = task_util(p); | |
| 4006 | 4011 | if (sched_feat(UTIL_EST_FASTUP)) { |
| 4007 | 4012 | if (ue.ewma < ue.enqueued) { |
| 4008 | 4013 | ue.ewma = ue.enqueued; |
| @@ -4051,6 +4056,7 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, · 42 unmodified lines | ||
| 4051 | 4056 | ue.ewma += last_ewma_diff; |
| 4052 | 4057 | ue.ewma >>= UTIL_EST_WEIGHT_SHIFT; |
| 4053 | 4058 | done: |
| 4059 | + ue.enqueued |= UTIL_AVG_UNCHANGED; | |
| 4054 | 4060 | WRITE_ONCE(p->se.avg.util_est, ue); |
| 4055 | 4061 | |
| 4056 | 4062 | trace_sched_util_est_se_tp(&p->se); |
| @@ -8030,7 +8036,7 @@ static bool __update_blocked_fair(struct rq *rq, bool *done) · 3973 unmodified lines | ||
| 8030 | 8036 | /* Propagate pending load changes to the parent, if any: */ |
| 8031 | 8037 | se = cfs_rq->tg->se[cpu]; |
| 8032 | 8038 | if (se && !skip_blocked_update(se)) |
| 8033 | − update_load_avg(cfs_rq_of(se), se, 0); | |
| 8039 | + update_load_avg(cfs_rq_of(se), se, UPDATE_TG); | |
| 8034 | 8040 | |
| 8035 | 8041 | /* |
| 8036 | 8042 | * There can be a lot of idle CPU cgroups. Don't let fully |
| @@ -42,15 +42,6 @@ static inline u32 get_pelt_divider(struct sched_avg *avg) · 41 unmodified lines | ||
| 42 | 42 | return LOAD_AVG_MAX - 1024 + avg->period_contrib; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | −/* | |
| 46 | − * When a task is dequeued, its estimated utilization should not be update if | |
| 47 | − * its util_avg has not been updated at least once. | |
| 48 | − * This flag is used to synchronize util_avg updates with util_est updates. | |
| 49 | − * We map this information into the LSB bit of the utilization saved at | |
| 50 | − * dequeue time (i.e. util_est.dequeued). | |
| 51 | − */ | |
| 52 | −#define UTIL_AVG_UNCHANGED 0x1 | |
| 53 | − | |
| 54 | 45 | static inline void cfs_se_util_change(struct sched_avg *avg) |
| 55 | 46 | { |
| 56 | 47 | unsigned int enqueued; |
| @@ -58,7 +49,7 @@ static inline void cfs_se_util_change(struct sched_avg *avg) · 1 unmodified line | ||
| 58 | 49 | if (!sched_feat(UTIL_EST)) |
| 59 | 50 | return; |
| 60 | 51 | |
| 61 | − /* Avoid store if the flag has been already set */ | |
| 52 | + /* Avoid store if the flag has been already reset */ | |
| 62 | 53 | enqueued = avg->util_est.enqueued; |
| 63 | 54 | if (!(enqueued & UTIL_AVG_UNCHANGED)) |
| 64 | 55 | return; |
| @@ -230,6 +230,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs) · 229 unmodified lines | ||
| 230 | 230 | |
| 231 | 231 | #ifdef CONFIG_NO_HZ_FULL |
| 232 | 232 | cpumask_var_t tick_nohz_full_mask; |
| 233 | +EXPORT_SYMBOL_GPL(tick_nohz_full_mask); | |
| 233 | 234 | bool tick_nohz_full_running; |
| 234 | 235 | EXPORT_SYMBOL_GPL(tick_nohz_full_running); |
| 235 | 236 | static atomic_t tick_dep_mask; |
| @@ -215,16 +215,11 @@ const struct bpf_func_proto bpf_probe_read_user_str_proto = { · 214 unmodified lines | ||
| 215 | 215 | static __always_inline int |
| 216 | 216 | bpf_probe_read_kernel_common(void *dst, u32 size, const void *unsafe_ptr) |
| 217 | 217 | { |
| 218 | − int ret = security_locked_down(LOCKDOWN_BPF_READ); | |
| 218 | + int ret; | |
| 219 | 219 | |
| 220 | − if (unlikely(ret < 0)) | |
| 221 | − goto fail; | |
| 222 | 220 | ret = copy_from_kernel_nofault(dst, unsafe_ptr, size); |
| 223 | 221 | if (unlikely(ret < 0)) |
| 224 | − goto fail; | |
| 225 | − return ret; | |
| 226 | −fail: | |
| 227 | − memset(dst, 0, size); | |
| 222 | + memset(dst, 0, size); | |
| 228 | 223 | return ret; |
| 229 | 224 | } |
| 230 | 225 | |
| @@ -246,10 +241,7 @@ const struct bpf_func_proto bpf_probe_read_kernel_proto = { · 15 unmodified lines | ||
| 246 | 241 | static __always_inline int |
| 247 | 242 | bpf_probe_read_kernel_str_common(void *dst, u32 size, const void *unsafe_ptr) |
| 248 | 243 | { |
| 249 | − int ret = security_locked_down(LOCKDOWN_BPF_READ); | |
| 250 | − | |
| 251 | − if (unlikely(ret < 0)) | |
| 252 | − goto fail; | |
| 244 | + int ret; | |
| 253 | 245 | |
| 254 | 246 | /* |
| 255 | 247 | * The strncpy_from_kernel_nofault() call will likely not fill the |
| @@ -262,11 +254,7 @@ bpf_probe_read_kernel_str_common(void *dst, u32 size, const void *unsafe_ptr) · 6 unmodified lines | ||
| 262 | 254 | */ |
| 263 | 255 | ret = strncpy_from_kernel_nofault(dst, unsafe_ptr, size); |
| 264 | 256 | if (unlikely(ret < 0)) |
| 265 | − goto fail; | |
| 266 | − | |
| 267 | − return ret; | |
| 268 | −fail: | |
| 269 | − memset(dst, 0, size); | |
| 257 | + memset(dst, 0, size); | |
| 270 | 258 | return ret; |
| 271 | 259 | } |
| 272 | 260 | |
| @@ -1011,16 +999,20 @@ bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) · 738 unmodified lines | ||
| 1011 | 999 | case BPF_FUNC_probe_read_user: |
| 1012 | 1000 | return &bpf_probe_read_user_proto; |
| 1013 | 1001 | case BPF_FUNC_probe_read_kernel: |
| 1014 | − return &bpf_probe_read_kernel_proto; | |
| 1002 | + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? | |
| 1003 | + NULL : &bpf_probe_read_kernel_proto; | |
| 1015 | 1004 | case BPF_FUNC_probe_read_user_str: |
| 1016 | 1005 | return &bpf_probe_read_user_str_proto; |
| 1017 | 1006 | case BPF_FUNC_probe_read_kernel_str: |
| 1018 | − return &bpf_probe_read_kernel_str_proto; | |
| 1007 | + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? | |
| 1008 | + NULL : &bpf_probe_read_kernel_str_proto; | |
| 1019 | 1009 | #ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE |
| 1020 | 1010 | case BPF_FUNC_probe_read: |
| 1021 | − return &bpf_probe_read_compat_proto; | |
| 1011 | + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? | |
| 1012 | + NULL : &bpf_probe_read_compat_proto; | |
| 1022 | 1013 | case BPF_FUNC_probe_read_str: |
| 1023 | − return &bpf_probe_read_compat_str_proto; | |
| 1014 | + return security_locked_down(LOCKDOWN_BPF_READ) < 0 ? | |
| 1015 | + NULL : &bpf_probe_read_compat_str_proto; | |
| 1024 | 1016 | #endif |
| 1025 | 1017 | #ifdef CONFIG_CGROUPS |
| 1026 | 1018 | case BPF_FUNC_get_current_cgroup_id: |
| @@ -1967,12 +1967,18 @@ static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops, · 1966 unmodified lines | ||
| 1967 | 1967 | |
| 1968 | 1968 | static void print_ip_ins(const char *fmt, const unsigned char *p) |
| 1969 | 1969 | { |
| 1970 | + char ins[MCOUNT_INSN_SIZE]; | |
| 1970 | 1971 | int i; |
| 1971 | 1972 | |
| 1973 | + if (copy_from_kernel_nofault(ins, p, MCOUNT_INSN_SIZE)) { | |
| 1974 | + printk(KERN_CONT "%s[FAULT] %px\n", fmt, p); | |
| 1975 | + return; | |
| 1976 | + } | |
| 1977 | + | |
| 1972 | 1978 | printk(KERN_CONT "%s", fmt); |
| 1973 | 1979 | |
| 1974 | 1980 | for (i = 0; i < MCOUNT_INSN_SIZE; i++) |
| 1975 | − printk(KERN_CONT "%s%02x", i ? ":" : "", p[i]); | |
| 1981 | + printk(KERN_CONT "%s%02x", i ? ":" : "", ins[i]); | |
| 1976 | 1982 | } |
| 1977 | 1983 | |
| 1978 | 1984 | enum ftrace_bug_type ftrace_bug_type; |
| @@ -2736,7 +2736,7 @@ trace_event_buffer_lock_reserve(struct trace_buffer **current_rb, · 2735 unmodified lines | ||
| 2736 | 2736 | (entry = this_cpu_read(trace_buffered_event))) { |
| 2737 | 2737 | /* Try to use the per cpu buffer first */ |
| 2738 | 2738 | val = this_cpu_inc_return(trace_buffered_event_cnt); |
| 2739 | − if ((len < (PAGE_SIZE - sizeof(*entry))) && val == 1) { | |
| 2739 | + if ((len < (PAGE_SIZE - sizeof(*entry) - sizeof(entry->array[0]))) && val == 1) { | |
| 2740 | 2740 | trace_event_setup(entry, type, trace_ctx); |
| 2741 | 2741 | entry->array[0] = len; |
| 2742 | 2742 | return entry; |
| @@ -37,7 +37,7 @@ MODULE_LICENSE("GPL v2"); · 36 unmodified lines | ||
| 37 | 37 | /** |
| 38 | 38 | * crc64_be - Calculate bitwise big-endian ECMA-182 CRC64 |
| 39 | 39 | * @crc: seed value for computation. 0 or (u64)~0 for a new CRC calculation, |
| 40 | − or the previous crc64 value if computing incrementally. | |
| 40 | + * or the previous crc64 value if computing incrementally. | |
| 41 | 41 | * @p: pointer to buffer over which CRC64 is run |
| 42 | 42 | * @len: length of buffer @p |
| 43 | 43 | */ |
| @@ -192,7 +192,7 @@ static void __init pmd_advanced_tests(struct mm_struct *mm, · 191 unmodified lines | ||
| 192 | 192 | |
| 193 | 193 | pr_debug("Validating PMD advanced\n"); |
| 194 | 194 | /* Align the address wrt HPAGE_PMD_SIZE */ |
| 195 | − vaddr = (vaddr & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE; | |
| 195 | + vaddr &= HPAGE_PMD_MASK; | |
| 196 | 196 | |
| 197 | 197 | pgtable_trans_huge_deposit(mm, pmdp, pgtable); |
| 198 | 198 | |
| @@ -330,7 +330,7 @@ static void __init pud_advanced_tests(struct mm_struct *mm, · 131 unmodified lines | ||
| 330 | 330 | |
| 331 | 331 | pr_debug("Validating PUD advanced\n"); |
| 332 | 332 | /* Align the address wrt HPAGE_PUD_SIZE */ |
| 333 | − vaddr = (vaddr & HPAGE_PUD_MASK) + HPAGE_PUD_SIZE; | |
| 333 | + vaddr &= HPAGE_PUD_MASK; | |
| 334 | 334 | |
| 335 | 335 | set_pud_at(mm, vaddr, pudp, pud); |
| 336 | 336 | pudp_set_wrprotect(mm, vaddr, pudp); |
| @@ -1793,7 +1793,7 @@ retry: · 1792 unmodified lines | ||
| 1793 | 1793 | SetPageHWPoison(page); |
| 1794 | 1794 | ClearPageHWPoison(head); |
| 1795 | 1795 | } |
| 1796 | − remove_hugetlb_page(h, page, false); | |
| 1796 | + remove_hugetlb_page(h, head, false); | |
| 1797 | 1797 | h->max_huge_pages--; |
| 1798 | 1798 | spin_unlock_irq(&hugetlb_lock); |
| 1799 | 1799 | update_and_free_page(h, head); |
| @@ -4889,10 +4889,20 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, · 3089 unmodified lines | ||
| 4889 | 4889 | if (!page) |
| 4890 | 4890 | goto out; |
| 4891 | 4891 | } else if (!*pagep) { |
| 4892 | − ret = -ENOMEM; | |
| 4892 | + /* If a page already exists, then it's UFFDIO_COPY for | |
| 4893 | + * a non-missing case. Return -EEXIST. | |
| 4894 | + */ | |
| 4895 | + if (vm_shared && | |
| 4896 | + hugetlbfs_pagecache_present(h, dst_vma, dst_addr)) { | |
| 4897 | + ret = -EEXIST; | |
| 4898 | + goto out; | |
| 4899 | + } | |
| 4900 | + | |
| 4893 | 4901 | page = alloc_huge_page(dst_vma, dst_addr, 0); |
| 4894 | − if (IS_ERR(page)) | |
| 4902 | + if (IS_ERR(page)) { | |
| 4903 | + ret = -ENOMEM; | |
| 4895 | 4904 | goto out; |
| 4905 | + } | |
| 4896 | 4906 | |
| 4897 | 4907 | ret = copy_huge_page_from_user(page, |
| 4898 | 4908 | (const void __user *) src_addr, |
| @@ -220,8 +220,8 @@ static int __ref zero_p4d_populate(pgd_t *pgd, unsigned long addr, · 219 unmodified lines | ||
| 220 | 220 | /** |
| 221 | 221 | * kasan_populate_early_shadow - populate shadow memory region with |
| 222 | 222 | * kasan_early_shadow_page |
| 223 | − * @shadow_start - start of the memory range to populate | |
| 224 | − * @shadow_end - end of the memory range to populate | |
| 223 | + * @shadow_start: start of the memory range to populate | |
| 224 | + * @shadow_end: end of the memory range to populate | |
| 225 | 225 | */ |
| 226 | 226 | int __ref kasan_populate_early_shadow(const void *shadow_start, |
| 227 | 227 | const void *shadow_end) |
| @@ -627,10 +627,10 @@ static void toggle_allocation_gate(struct work_struct *work) · 626 unmodified lines | ||
| 627 | 627 | * During low activity with no allocations we might wait a |
| 628 | 628 | * while; let's avoid the hung task warning. |
| 629 | 629 | */ |
| 630 | − wait_event_timeout(allocation_wait, atomic_read(&kfence_allocation_gate), | |
| 631 | − sysctl_hung_task_timeout_secs * HZ / 2); | |
| 630 | + wait_event_idle_timeout(allocation_wait, atomic_read(&kfence_allocation_gate), | |
| 631 | + sysctl_hung_task_timeout_secs * HZ / 2); | |
| 632 | 632 | } else { |
| 633 | − wait_event(allocation_wait, atomic_read(&kfence_allocation_gate)); | |
| 633 | + wait_event_idle(allocation_wait, atomic_read(&kfence_allocation_gate)); | |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /* Disable static key and reset timer. */ |
| @@ -2939,6 +2939,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) · 2938 unmodified lines | ||
| 2939 | 2939 | } |
| 2940 | 2940 | flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); |
| 2941 | 2941 | entry = mk_pte(new_page, vma->vm_page_prot); |
| 2942 | + entry = pte_sw_mkyoung(entry); | |
| 2942 | 2943 | entry = maybe_mkwrite(pte_mkdirty(entry), vma); |
| 2943 | 2944 | |
| 2944 | 2945 | /* |
| @@ -3602,6 +3603,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) · 657 unmodified lines | ||
| 3602 | 3603 | __SetPageUptodate(page); |
| 3603 | 3604 | |
| 3604 | 3605 | entry = mk_pte(page, vma->vm_page_prot); |
| 3606 | + entry = pte_sw_mkyoung(entry); | |
| 3605 | 3607 | if (vma->vm_flags & VM_WRITE) |
| 3606 | 3608 | entry = pte_mkwrite(pte_mkdirty(entry)); |
| 3607 | 3609 | |
| @@ -3786,6 +3788,8 @@ void do_set_pte(struct vm_fault *vmf, struct page *page, unsigned long addr) · 178 unmodified lines | ||
| 3786 | 3788 | |
| 3787 | 3789 | if (prefault && arch_wants_old_prefaulted_pte()) |
| 3788 | 3790 | entry = pte_mkold(entry); |
| 3791 | + else | |
| 3792 | + entry = pte_sw_mkyoung(entry); | |
| 3789 | 3793 | |
| 3790 | 3794 | if (write) |
| 3791 | 3795 | entry = maybe_mkwrite(pte_mkdirty(entry), vma); |
| @@ -9158,6 +9158,8 @@ bool take_page_off_buddy(struct page *page) · 9157 unmodified lines | ||
| 9158 | 9158 | del_page_from_free_list(page_head, zone, page_order); |
| 9159 | 9159 | break_down_buddy_pages(zone, page_head, page, 0, |
| 9160 | 9160 | page_order, migratetype); |
| 9161 | + if (!is_migrate_isolate(migratetype)) | |
| 9162 | + __mod_zone_freepage_state(zone, -1, migratetype); | |
| 9161 | 9163 | ret = true; |
| 9162 | 9164 | break; |
| 9163 | 9165 | } |
| @@ -1610,8 +1610,13 @@ setup_failed: · 1609 unmodified lines | ||
| 1610 | 1610 | } else { |
| 1611 | 1611 | /* Init failed, cleanup */ |
| 1612 | 1612 | flush_work(&hdev->tx_work); |
| 1613 | − flush_work(&hdev->cmd_work); | |
| 1613 | + | |
| 1614 | + /* Since hci_rx_work() is possible to awake new cmd_work | |
| 1615 | + * it should be flushed first to avoid unexpected call of | |
| 1616 | + * hci_cmd_work() | |
| 1617 | + */ | |
| 1614 | 1618 | flush_work(&hdev->rx_work); |
| 1619 | + flush_work(&hdev->cmd_work); | |
| 1615 | 1620 | |
| 1616 | 1621 | skb_queue_purge(&hdev->cmd_q); |
| 1617 | 1622 | skb_queue_purge(&hdev->rx_q); |
| @@ -762,7 +762,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event) · 761 unmodified lines | ||
| 762 | 762 | /* Detach sockets from device */ |
| 763 | 763 | read_lock(&hci_sk_list.lock); |
| 764 | 764 | sk_for_each(sk, &hci_sk_list.head) { |
| 765 | − bh_lock_sock_nested(sk); | |
| 765 | + lock_sock(sk); | |
| 766 | 766 | if (hci_pi(sk)->hdev == hdev) { |
| 767 | 767 | hci_pi(sk)->hdev = NULL; |
| 768 | 768 | sk->sk_err = EPIPE; |
| @@ -771,7 +771,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event) · 2 unmodified lines | ||
| 771 | 771 | |
| 772 | 772 | hci_dev_put(hdev); |
| 773 | 773 | } |
| 774 | − bh_unlock_sock(sk); | |
| 774 | + release_sock(sk); | |
| 775 | 775 | } |
| 776 | 776 | read_unlock(&hci_sk_list.lock); |
| 777 | 777 | } |
| @@ -308,7 +308,7 @@ static void dev_flowctrl(struct net_device *dev, int on) · 307 unmodified lines | ||
| 308 | 308 | caifd_put(caifd); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | −void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, | |
| 311 | +int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, | |
| 312 | 312 | struct cflayer *link_support, int head_room, |
| 313 | 313 | struct cflayer **layer, |
| 314 | 314 | int (**rcv_func)(struct sk_buff *, struct net_device *, |
| @@ -319,11 +319,12 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, · 4 unmodified lines | ||
| 319 | 319 | enum cfcnfg_phy_preference pref; |
| 320 | 320 | struct cfcnfg *cfg = get_cfcnfg(dev_net(dev)); |
| 321 | 321 | struct caif_device_entry_list *caifdevs; |
| 322 | + int res; | |
| 322 | 323 | |
| 323 | 324 | caifdevs = caif_device_list(dev_net(dev)); |
| 324 | 325 | caifd = caif_device_alloc(dev); |
| 325 | 326 | if (!caifd) |
| 326 | − return; | |
| 327 | + return -ENOMEM; | |
| 327 | 328 | *layer = &caifd->layer; |
| 328 | 329 | spin_lock_init(&caifd->flow_lock); |
| 329 | 330 | |
| @@ -344,7 +345,7 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, · 14 unmodified lines | ||
| 344 | 345 | strlcpy(caifd->layer.name, dev->name, |
| 345 | 346 | sizeof(caifd->layer.name)); |
| 346 | 347 | caifd->layer.transmit = transmit; |
| 347 | − cfcnfg_add_phy_layer(cfg, | |
| 348 | + res = cfcnfg_add_phy_layer(cfg, | |
| 348 | 349 | dev, |
| 349 | 350 | &caifd->layer, |
| 350 | 351 | pref, |
| @@ -354,6 +355,7 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, · 3 unmodified lines | ||
| 354 | 355 | mutex_unlock(&caifdevs->lock); |
| 355 | 356 | if (rcv_func) |
| 356 | 357 | *rcv_func = receive; |
| 358 | + return res; | |
| 357 | 359 | } |
| 358 | 360 | EXPORT_SYMBOL(caif_enroll_dev); |
| 359 | 361 | |
| @@ -368,6 +370,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what, · 8 unmodified lines | ||
| 368 | 370 | struct cflayer *layer, *link_support; |
| 369 | 371 | int head_room = 0; |
| 370 | 372 | struct caif_device_entry_list *caifdevs; |
| 373 | + int res; | |
| 371 | 374 | |
| 372 | 375 | cfg = get_cfcnfg(dev_net(dev)); |
| 373 | 376 | caifdevs = caif_device_list(dev_net(dev)); |
| @@ -393,8 +396,10 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what, · 19 unmodified lines | ||
| 393 | 396 | break; |
| 394 | 397 | } |
| 395 | 398 | } |
| 396 | − caif_enroll_dev(dev, caifdev, link_support, head_room, | |
| 399 | + res = caif_enroll_dev(dev, caifdev, link_support, head_room, | |
| 397 | 400 | &layer, NULL); |
| 401 | + if (res) | |
| 402 | + cfserl_release(link_support); | |
| 398 | 403 | caifdev->flowctrl = dev_flowctrl; |
| 399 | 404 | break; |
| 400 | 405 | |
| @@ -115,6 +115,11 @@ static struct cflayer *cfusbl_create(int phyid, u8 ethaddr[ETH_ALEN], · 114 unmodified lines | ||
| 115 | 115 | return (struct cflayer *) this; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | +static void cfusbl_release(struct cflayer *layer) | |
| 119 | +{ | |
| 120 | + kfree(layer); | |
| 121 | +} | |
| 122 | + | |
| 118 | 123 | static struct packet_type caif_usb_type __read_mostly = { |
| 119 | 124 | .type = cpu_to_be16(ETH_P_802_EX1), |
| 120 | 125 | }; |
| @@ -127,6 +132,7 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what, · 6 unmodified lines | ||
| 127 | 132 | struct cflayer *layer, *link_support; |
| 128 | 133 | struct usbnet *usbnet; |
| 129 | 134 | struct usb_device *usbdev; |
| 135 | + int res; | |
| 130 | 136 | |
| 131 | 137 | /* Check whether we have a NCM device, and find its VID/PID. */ |
| 132 | 138 | if (!(dev->dev.parent && dev->dev.parent->driver && |
| @@ -169,8 +175,11 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what, · 36 unmodified lines | ||
| 169 | 175 | if (dev->num_tx_queues > 1) |
| 170 | 176 | pr_warn("USB device uses more than one tx queue\n"); |
| 171 | 177 | |
| 172 | − caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN, | |
| 178 | + res = caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN, | |
| 173 | 179 | &layer, &caif_usb_type.func); |
| 180 | + if (res) | |
| 181 | + goto err; | |
| 182 | + | |
| 174 | 183 | if (!pack_added) |
| 175 | 184 | dev_add_pack(&caif_usb_type); |
| 176 | 185 | pack_added = true; |
| @@ -178,6 +187,9 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what, · 1 unmodified line | ||
| 178 | 187 | strlcpy(layer->name, dev->name, sizeof(layer->name)); |
| 179 | 188 | |
| 180 | 189 | return 0; |
| 190 | +err: | |
| 191 | + cfusbl_release(link_support); | |
| 192 | + return res; | |
| 181 | 193 | } |
| 182 | 194 | |
| 183 | 195 | static struct notifier_block caif_device_notifier = { |
| @@ -450,7 +450,7 @@ unlock: · 449 unmodified lines | ||
| 450 | 450 | rcu_read_unlock(); |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | −void | |
| 453 | +int | |
| 454 | 454 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, |
| 455 | 455 | struct net_device *dev, struct cflayer *phy_layer, |
| 456 | 456 | enum cfcnfg_phy_preference pref, |
| @@ -459,7 +459,7 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, · 2 unmodified lines | ||
| 459 | 459 | { |
| 460 | 460 | struct cflayer *frml; |
| 461 | 461 | struct cfcnfg_phyinfo *phyinfo = NULL; |
| 462 | − int i; | |
| 462 | + int i, res = 0; | |
| 463 | 463 | u8 phyid; |
| 464 | 464 | |
| 465 | 465 | mutex_lock(&cnfg->lock); |
| @@ -473,12 +473,15 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, · 7 unmodified lines | ||
| 473 | 473 | goto got_phyid; |
| 474 | 474 | } |
| 475 | 475 | pr_warn("Too many CAIF Link Layers (max 6)\n"); |
| 476 | + res = -EEXIST; | |
| 476 | 477 | goto out; |
| 477 | 478 | |
| 478 | 479 | got_phyid: |
| 479 | 480 | phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC); |
| 480 | − if (!phyinfo) | |
| 481 | + if (!phyinfo) { | |
| 482 | + res = -ENOMEM; | |
| 481 | 483 | goto out_err; |
| 484 | + } | |
| 482 | 485 | |
| 483 | 486 | phy_layer->id = phyid; |
| 484 | 487 | phyinfo->pref = pref; |
| @@ -492,8 +495,10 @@ got_phyid: · 7 unmodified lines | ||
| 492 | 495 | |
| 493 | 496 | frml = cffrml_create(phyid, fcs); |
| 494 | 497 | |
| 495 | − if (!frml) | |
| 498 | + if (!frml) { | |
| 499 | + res = -ENOMEM; | |
| 496 | 500 | goto out_err; |
| 501 | + } | |
| 497 | 502 | phyinfo->frm_layer = frml; |
| 498 | 503 | layer_set_up(frml, cnfg->mux); |
| 499 | 504 | |
| @@ -511,11 +516,12 @@ got_phyid: · 11 unmodified lines | ||
| 511 | 516 | list_add_rcu(&phyinfo->node, &cnfg->phys); |
| 512 | 517 | out: |
| 513 | 518 | mutex_unlock(&cnfg->lock); |
| 514 | − return; | |
| 519 | + return res; | |
| 515 | 520 | |
| 516 | 521 | out_err: |
| 517 | 522 | kfree(phyinfo); |
| 518 | 523 | mutex_unlock(&cnfg->lock); |
| 524 | + return res; | |
| 519 | 525 | } |
| 520 | 526 | EXPORT_SYMBOL(cfcnfg_add_phy_layer); |
| 521 | 527 | |
| @@ -31,6 +31,11 @@ static int cfserl_transmit(struct cflayer *layr, struct cfpkt *pkt); · 30 unmodified lines | ||
| 31 | 31 | static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, |
| 32 | 32 | int phyid); |
| 33 | 33 | |
| 34 | +void cfserl_release(struct cflayer *layer) | |
| 35 | +{ | |
| 36 | + kfree(layer); | |
| 37 | +} | |
| 38 | + | |
| 34 | 39 | struct cflayer *cfserl_create(int instance, bool use_stx) |
| 35 | 40 | { |
| 36 | 41 | struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC); |
| @@ -177,7 +177,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, · 176 unmodified lines | ||
| 177 | 177 | if (kcmlen > stackbuf_size) |
| 178 | 178 | kcmsg_base = kcmsg = sock_kmalloc(sk, kcmlen, GFP_KERNEL); |
| 179 | 179 | if (kcmsg == NULL) |
| 180 | − return -ENOBUFS; | |
| 180 | + return -ENOMEM; | |
| 181 | 181 | |
| 182 | 182 | /* Now copy them over neatly. */ |
| 183 | 183 | memset(kcmsg, 0, kcmlen); |
| @@ -705,7 +705,6 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg, · 704 unmodified lines | ||
| 705 | 705 | case DEVLINK_PORT_FLAVOUR_PHYSICAL: |
| 706 | 706 | case DEVLINK_PORT_FLAVOUR_CPU: |
| 707 | 707 | case DEVLINK_PORT_FLAVOUR_DSA: |
| 708 | − case DEVLINK_PORT_FLAVOUR_VIRTUAL: | |
| 709 | 708 | if (nla_put_u32(msg, DEVLINK_ATTR_PORT_NUMBER, |
| 710 | 709 | attrs->phys.port_number)) |
| 711 | 710 | return -EMSGSIZE; |
| @@ -8631,7 +8630,6 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port, · 7919 unmodified lines | ||
| 8631 | 8630 | |
| 8632 | 8631 | switch (attrs->flavour) { |
| 8633 | 8632 | case DEVLINK_PORT_FLAVOUR_PHYSICAL: |
| 8634 | − case DEVLINK_PORT_FLAVOUR_VIRTUAL: | |
| 8635 | 8633 | if (!attrs->split) |
| 8636 | 8634 | n = snprintf(name, len, "p%u", attrs->phys.port_number); |
| 8637 | 8635 | else |
| @@ -8679,6 +8677,8 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port, · 41 unmodified lines | ||
| 8679 | 8677 | n = snprintf(name, len, "pf%usf%u", attrs->pci_sf.pf, |
| 8680 | 8678 | attrs->pci_sf.sf); |
| 8681 | 8679 | break; |
| 8680 | + case DEVLINK_PORT_FLAVOUR_VIRTUAL: | |
| 8681 | + return -EOPNOTSUPP; | |
| 8682 | 8682 | } |
| 8683 | 8683 | |
| 8684 | 8684 | if (n >= len) |
| @@ -1168,7 +1168,7 @@ static void notify_rule_change(int event, struct fib_rule *rule, · 1167 unmodified lines | ||
| 1168 | 1168 | { |
| 1169 | 1169 | struct net *net; |
| 1170 | 1170 | struct sk_buff *skb; |
| 1171 | − int err = -ENOBUFS; | |
| 1171 | + int err = -ENOMEM; | |
| 1172 | 1172 | |
| 1173 | 1173 | net = ops->fro_net; |
| 1174 | 1174 | skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL); |
| @@ -4842,8 +4842,10 @@ static int rtnl_bridge_notify(struct net_device *dev) · 4841 unmodified lines | ||
| 4842 | 4842 | if (err < 0) |
| 4843 | 4843 | goto errout; |
| 4844 | 4844 | |
| 4845 | − if (!skb->len) | |
| 4845 | + if (!skb->len) { | |
| 4846 | + err = -EINVAL; | |
| 4846 | 4847 | goto errout; |
| 4848 | + } | |
| 4847 | 4849 | |
| 4848 | 4850 | rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); |
| 4849 | 4851 | return 0; |
| @@ -815,10 +815,18 @@ void sock_set_rcvbuf(struct sock *sk, int val) · 814 unmodified lines | ||
| 815 | 815 | } |
| 816 | 816 | EXPORT_SYMBOL(sock_set_rcvbuf); |
| 817 | 817 | |
| 818 | +static void __sock_set_mark(struct sock *sk, u32 val) | |
| 819 | +{ | |
| 820 | + if (val != sk->sk_mark) { | |
| 821 | + sk->sk_mark = val; | |
| 822 | + sk_dst_reset(sk); | |
| 823 | + } | |
| 824 | +} | |
| 825 | + | |
| 818 | 826 | void sock_set_mark(struct sock *sk, u32 val) |
| 819 | 827 | { |
| 820 | 828 | lock_sock(sk); |
| 821 | − sk->sk_mark = val; | |
| 829 | + __sock_set_mark(sk, val); | |
| 822 | 830 | release_sock(sk); |
| 823 | 831 | } |
| 824 | 832 | EXPORT_SYMBOL(sock_set_mark); |
| @@ -1126,10 +1134,10 @@ set_sndbuf: · 301 unmodified lines | ||
| 1126 | 1134 | case SO_MARK: |
| 1127 | 1135 | if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) { |
| 1128 | 1136 | ret = -EPERM; |
| 1129 | − } else if (val != sk->sk_mark) { | |
| 1130 | − sk->sk_mark = val; | |
| 1131 | − sk_dst_reset(sk); | |
| 1137 | + break; | |
| 1132 | 1138 | } |
| 1139 | + | |
| 1140 | + __sock_set_mark(sk, val); | |
| 1133 | 1141 | break; |
| 1134 | 1142 | |
| 1135 | 1143 | case SO_RXQ_OVFL: |
| @@ -64,7 +64,7 @@ · 63 unmodified lines | ||
| 64 | 64 | #define DSA_8021Q_SUBVLAN_HI_SHIFT 9 |
| 65 | 65 | #define DSA_8021Q_SUBVLAN_HI_MASK GENMASK(9, 9) |
| 66 | 66 | #define DSA_8021Q_SUBVLAN_LO_SHIFT 4 |
| 67 | −#define DSA_8021Q_SUBVLAN_LO_MASK GENMASK(4, 3) | |
| 67 | +#define DSA_8021Q_SUBVLAN_LO_MASK GENMASK(5, 4) | |
| 68 | 68 | #define DSA_8021Q_SUBVLAN_HI(x) (((x) & GENMASK(2, 2)) >> 2) |
| 69 | 69 | #define DSA_8021Q_SUBVLAN_LO(x) ((x) & GENMASK(1, 0)) |
| 70 | 70 | #define DSA_8021Q_SUBVLAN(x) \ |
| @@ -680,8 +680,10 @@ int ieee802154_llsec_getparams(struct sk_buff *skb, struct genl_info *info) · 679 unmodified lines | ||
| 680 | 680 | nla_put_u8(msg, IEEE802154_ATTR_LLSEC_SECLEVEL, params.out_level) || |
| 681 | 681 | nla_put_u32(msg, IEEE802154_ATTR_LLSEC_FRAME_COUNTER, |
| 682 | 682 | be32_to_cpu(params.frame_counter)) || |
| 683 | − ieee802154_llsec_fill_key_id(msg, ¶ms.out_key)) | |
| 683 | + ieee802154_llsec_fill_key_id(msg, ¶ms.out_key)) { | |
| 684 | + rc = -ENOBUFS; | |
| 684 | 685 | goto out_free; |
| 686 | + } | |
| 685 | 687 | |
| 686 | 688 | dev_put(dev); |
| 687 | 689 | |
| @@ -1184,7 +1186,7 @@ static int llsec_iter_devkeys(struct llsec_dump_data *data) · 496 unmodified lines | ||
| 1184 | 1186 | { |
| 1185 | 1187 | struct ieee802154_llsec_device *dpos; |
| 1186 | 1188 | struct ieee802154_llsec_device_key *kpos; |
| 1187 | − int rc = 0, idx = 0, idx2; | |
| 1189 | + int idx = 0, idx2; | |
| 1188 | 1190 | |
| 1189 | 1191 | list_for_each_entry(dpos, &data->table->devices, list) { |
| 1190 | 1192 | if (idx++ < data->s_idx) |
| @@ -1200,7 +1202,7 @@ static int llsec_iter_devkeys(struct llsec_dump_data *data) · 9 unmodified lines | ||
| 1200 | 1202 | data->nlmsg_seq, |
| 1201 | 1203 | dpos->hwaddr, kpos, |
| 1202 | 1204 | data->dev)) { |
| 1203 | − return rc = -EMSGSIZE; | |
| 1205 | + return -EMSGSIZE; | |
| 1204 | 1206 | } |
| 1205 | 1207 | |
| 1206 | 1208 | data->s_idx2++; |
| @@ -1209,7 +1211,7 @@ static int llsec_iter_devkeys(struct llsec_dump_data *data) · 2 unmodified lines | ||
| 1209 | 1211 | data->s_idx++; |
| 1210 | 1212 | } |
| 1211 | 1213 | |
| 1212 | − return rc; | |
| 1214 | + return 0; | |
| 1213 | 1215 | } |
| 1214 | 1216 | |
| 1215 | 1217 | int ieee802154_llsec_dump_devkeys(struct sk_buff *skb, |
| @@ -241,8 +241,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) · 240 unmodified lines | ||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
| 244 | − nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) | |
| 244 | + nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) { | |
| 245 | + rc = -EMSGSIZE; | |
| 245 | 246 | goto nla_put_failure; |
| 247 | + } | |
| 246 | 248 | dev_put(dev); |
| 247 | 249 | |
| 248 | 250 | wpan_phy_put(phy); |
| @@ -1298,19 +1298,20 @@ ieee802154_llsec_parse_dev_addr(struct nlattr *nla, · 1297 unmodified lines | ||
| 1298 | 1298 | if (!nla || nla_parse_nested_deprecated(attrs, NL802154_DEV_ADDR_ATTR_MAX, nla, nl802154_dev_addr_policy, NULL)) |
| 1299 | 1299 | return -EINVAL; |
| 1300 | 1300 | |
| 1301 | − if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || | |
| 1302 | − !attrs[NL802154_DEV_ADDR_ATTR_MODE] || | |
| 1303 | − !(attrs[NL802154_DEV_ADDR_ATTR_SHORT] || | |
| 1304 | − attrs[NL802154_DEV_ADDR_ATTR_EXTENDED])) | |
| 1301 | + if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || !attrs[NL802154_DEV_ADDR_ATTR_MODE]) | |
| 1305 | 1302 | return -EINVAL; |
| 1306 | 1303 | |
| 1307 | 1304 | addr->pan_id = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_PAN_ID]); |
| 1308 | 1305 | addr->mode = nla_get_u32(attrs[NL802154_DEV_ADDR_ATTR_MODE]); |
| 1309 | 1306 | switch (addr->mode) { |
| 1310 | 1307 | case NL802154_DEV_ADDR_SHORT: |
| 1308 | + if (!attrs[NL802154_DEV_ADDR_ATTR_SHORT]) | |
| 1309 | + return -EINVAL; | |
| 1311 | 1310 | addr->short_addr = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_SHORT]); |
| 1312 | 1311 | break; |
| 1313 | 1312 | case NL802154_DEV_ADDR_EXTENDED: |
| 1313 | + if (!attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]) | |
| 1314 | + return -EINVAL; | |
| 1314 | 1315 | addr->extended_addr = nla_get_le64(attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]); |
| 1315 | 1316 | break; |
| 1316 | 1317 | default: |
| @@ -886,7 +886,7 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d · 885 unmodified lines | ||
| 886 | 886 | |
| 887 | 887 | |
| 888 | 888 | /* |
| 889 | − * Copy BOOTP-supplied string if not already set. | |
| 889 | + * Copy BOOTP-supplied string | |
| 890 | 890 | */ |
| 891 | 891 | static int __init ic_bootp_string(char *dest, char *src, int len, int max) |
| 892 | 892 | { |
| @@ -935,12 +935,15 @@ static void __init ic_do_bootp_ext(u8 *ext) · 42 unmodified lines | ||
| 935 | 935 | } |
| 936 | 936 | break; |
| 937 | 937 | case 12: /* Host name */ |
| 938 | − ic_bootp_string(utsname()->nodename, ext+1, *ext, | |
| 939 | − __NEW_UTS_LEN); | |
| 940 | − ic_host_name_set = 1; | |
| 938 | + if (!ic_host_name_set) { | |
| 939 | + ic_bootp_string(utsname()->nodename, ext+1, *ext, | |
| 940 | + __NEW_UTS_LEN); | |
| 941 | + ic_host_name_set = 1; | |
| 942 | + } | |
| 941 | 943 | break; |
| 942 | 944 | case 15: /* Domain name (DNS) */ |
| 943 | − ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); | |
| 945 | + if (!ic_domain[0]) | |
| 946 | + ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); | |
| 944 | 947 | break; |
| 945 | 948 | case 17: /* Root path */ |
| 946 | 949 | if (!root_server_path[0]) |
| @@ -3673,11 +3673,11 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, · 3672 unmodified lines | ||
| 3673 | 3673 | if (nh) { |
| 3674 | 3674 | if (rt->fib6_src.plen) { |
| 3675 | 3675 | NL_SET_ERR_MSG(extack, "Nexthops can not be used with source routing"); |
| 3676 | − goto out; | |
| 3676 | + goto out_free; | |
| 3677 | 3677 | } |
| 3678 | 3678 | if (!nexthop_get(nh)) { |
| 3679 | 3679 | NL_SET_ERR_MSG(extack, "Nexthop has been deleted"); |
| 3680 | − goto out; | |
| 3680 | + goto out_free; | |
| 3681 | 3681 | } |
| 3682 | 3682 | rt->nh = nh; |
| 3683 | 3683 | fib6_nh = nexthop_fib6_nh(rt->nh); |
| @@ -3714,6 +3714,10 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, · 30 unmodified lines | ||
| 3714 | 3714 | out: |
| 3715 | 3715 | fib6_info_release(rt); |
| 3716 | 3716 | return ERR_PTR(err); |
| 3717 | +out_free: | |
| 3718 | + ip_fib_metrics_put(rt->fib6_metrics); | |
| 3719 | + kfree(rt); | |
| 3720 | + return ERR_PTR(err); | |
| 3717 | 3721 | } |
| 3718 | 3722 | |
| 3719 | 3723 | int ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags, |
| @@ -271,6 +271,9 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net, · 270 unmodified lines | ||
| 271 | 271 | if (ipip6_tunnel_create(dev) < 0) |
| 272 | 272 | goto failed_free; |
| 273 | 273 | |
| 274 | + if (!parms->name[0]) | |
| 275 | + strcpy(parms->name, dev->name); | |
| 276 | + | |
| 274 | 277 | return nt; |
| 275 | 278 | |
| 276 | 279 | failed_free: |
| @@ -1066,6 +1066,11 @@ out_error: · 1065 unmodified lines | ||
| 1066 | 1066 | goto partial_message; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | + if (skb_has_frag_list(head)) { | |
| 1070 | + kfree_skb_list(skb_shinfo(head)->frag_list); | |
| 1071 | + skb_shinfo(head)->frag_list = NULL; | |
| 1072 | + } | |
| 1073 | + | |
| 1069 | 1074 | if (head != kcm->seq_skb) |
| 1070 | 1075 | kfree_skb(head); |
| 1071 | 1076 | |
| @@ -947,6 +947,10 @@ static void __mptcp_update_wmem(struct sock *sk) · 946 unmodified lines | ||
| 947 | 947 | { |
| 948 | 948 | struct mptcp_sock *msk = mptcp_sk(sk); |
| 949 | 949 | |
| 950 | +#ifdef CONFIG_LOCKDEP | |
| 951 | + WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock)); | |
| 952 | +#endif | |
| 953 | + | |
| 950 | 954 | if (!msk->wmem_reserved) |
| 951 | 955 | return; |
| 952 | 956 | |
| @@ -1085,10 +1089,20 @@ out: · 132 unmodified lines | ||
| 1085 | 1089 | |
| 1086 | 1090 | static void __mptcp_clean_una_wakeup(struct sock *sk) |
| 1087 | 1091 | { |
| 1092 | +#ifdef CONFIG_LOCKDEP | |
| 1093 | + WARN_ON_ONCE(!lockdep_is_held(&sk->sk_lock.slock)); | |
| 1094 | +#endif | |
| 1088 | 1095 | __mptcp_clean_una(sk); |
| 1089 | 1096 | mptcp_write_space(sk); |
| 1090 | 1097 | } |
| 1091 | 1098 | |
| 1099 | +static void mptcp_clean_una_wakeup(struct sock *sk) | |
| 1100 | +{ | |
| 1101 | + mptcp_data_lock(sk); | |
| 1102 | + __mptcp_clean_una_wakeup(sk); | |
| 1103 | + mptcp_data_unlock(sk); | |
| 1104 | +} | |
| 1105 | + | |
| 1092 | 1106 | static void mptcp_enter_memory_pressure(struct sock *sk) |
| 1093 | 1107 | { |
| 1094 | 1108 | struct mptcp_subflow_context *subflow; |
| @@ -2299,7 +2313,7 @@ static void __mptcp_retrans(struct sock *sk) · 1204 unmodified lines | ||
| 2299 | 2313 | struct sock *ssk; |
| 2300 | 2314 | int ret; |
| 2301 | 2315 | |
| 2302 | − __mptcp_clean_una_wakeup(sk); | |
| 2316 | + mptcp_clean_una_wakeup(sk); | |
| 2303 | 2317 | dfrag = mptcp_rtx_head(sk); |
| 2304 | 2318 | if (!dfrag) { |
| 2305 | 2319 | if (mptcp_data_fin_enabled(msk)) { |
| @@ -630,21 +630,20 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, · 629 unmodified lines | ||
| 630 | 630 | |
| 631 | 631 | /* if the sk is MP_CAPABLE, we try to fetch the client key */ |
| 632 | 632 | if (subflow_req->mp_capable) { |
| 633 | − if (TCP_SKB_CB(skb)->seq != subflow_req->ssn_offset + 1) { | |
| 634 | − /* here we can receive and accept an in-window, | |
| 635 | − * out-of-order pkt, which will not carry the MP_CAPABLE | |
| 636 | − * opt even on mptcp enabled paths | |
| 637 | − */ | |
| 638 | − goto create_msk; | |
| 639 | − } | |
| 640 | − | |
| 633 | + /* we can receive and accept an in-window, out-of-order pkt, | |
| 634 | + * which may not carry the MP_CAPABLE opt even on mptcp enabled | |
| 635 | + * paths: always try to extract the peer key, and fallback | |
| 636 | + * for packets missing it. | |
| 637 | + * Even OoO DSS packets coming legitly after dropped or | |
| 638 | + * reordered MPC will cause fallback, but we don't have other | |
| 639 | + * options. | |
| 640 | + */ | |
| 641 | 641 | mptcp_get_options(skb, &mp_opt); |
| 642 | 642 | if (!mp_opt.mp_capable) { |
| 643 | 643 | fallback = true; |
| 644 | 644 | goto create_child; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | −create_msk: | |
| 648 | 647 | new_msk = mptcp_sk_clone(listener->conn, &mp_opt, req); |
| 649 | 648 | if (!new_msk) |
| 650 | 649 | fallback = true; |
| @@ -1012,21 +1011,11 @@ static bool subflow_check_data_avail(struct sock *ssk) · 361 unmodified lines | ||
| 1012 | 1011 | |
| 1013 | 1012 | status = get_mapping_status(ssk, msk); |
| 1014 | 1013 | trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue)); |
| 1015 | − if (status == MAPPING_INVALID) { | |
| 1016 | − ssk->sk_err = EBADMSG; | |
| 1017 | − goto fatal; | |
| 1018 | − } | |
| 1019 | − if (status == MAPPING_DUMMY) { | |
| 1020 | − __mptcp_do_fallback(msk); | |
| 1021 | − skb = skb_peek(&ssk->sk_receive_queue); | |
| 1022 | − subflow->map_valid = 1; | |
| 1023 | − subflow->map_seq = READ_ONCE(msk->ack_seq); | |
| 1024 | − subflow->map_data_len = skb->len; | |
| 1025 | − subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - | |
| 1026 | − subflow->ssn_offset; | |
| 1027 | − subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; | |
| 1028 | − return true; | |
| 1029 | − } | |
| 1014 | + if (unlikely(status == MAPPING_INVALID)) | |
| 1015 | + goto fallback; | |
| 1016 | + | |
| 1017 | + if (unlikely(status == MAPPING_DUMMY)) | |
| 1018 | + goto fallback; | |
| 1030 | 1019 | |
| 1031 | 1020 | if (status != MAPPING_OK) |
| 1032 | 1021 | goto no_data; |
| @@ -1039,10 +1028,8 @@ static bool subflow_check_data_avail(struct sock *ssk) · 6 unmodified lines | ||
| 1039 | 1028 | * MP_CAPABLE-based mapping |
| 1040 | 1029 | */ |
| 1041 | 1030 | if (unlikely(!READ_ONCE(msk->can_ack))) { |
| 1042 | − if (!subflow->mpc_map) { | |
| 1043 | − ssk->sk_err = EBADMSG; | |
| 1044 | − goto fatal; | |
| 1045 | − } | |
| 1031 | + if (!subflow->mpc_map) | |
| 1032 | + goto fallback; | |
| 1046 | 1033 | WRITE_ONCE(msk->remote_key, subflow->remote_key); |
| 1047 | 1034 | WRITE_ONCE(msk->ack_seq, subflow->map_seq); |
| 1048 | 1035 | WRITE_ONCE(msk->can_ack, true); |
| @@ -1070,17 +1057,31 @@ static bool subflow_check_data_avail(struct sock *ssk) · 21 unmodified lines | ||
| 1070 | 1057 | no_data: |
| 1071 | 1058 | subflow_sched_work_if_closed(msk, ssk); |
| 1072 | 1059 | return false; |
| 1073 | −fatal: | |
| 1074 | − /* fatal protocol error, close the socket */ | |
| 1075 | − /* This barrier is coupled with smp_rmb() in tcp_poll() */ | |
| 1076 | − smp_wmb(); | |
| 1077 | − ssk->sk_error_report(ssk); | |
| 1078 | − tcp_set_state(ssk, TCP_CLOSE); | |
| 1079 | − subflow->reset_transient = 0; | |
| 1080 | − subflow->reset_reason = MPTCP_RST_EMPTCP; | |
| 1081 | − tcp_send_active_reset(ssk, GFP_ATOMIC); | |
| 1082 | − subflow->data_avail = 0; | |
| 1083 | − return false; | |
| 1060 | + | |
| 1061 | +fallback: | |
| 1062 | + /* RFC 8684 section 3.7. */ | |
| 1063 | + if (subflow->mp_join || subflow->fully_established) { | |
| 1064 | + /* fatal protocol error, close the socket. | |
| 1065 | + * subflow_error_report() will introduce the appropriate barriers | |
| 1066 | + */ | |
| 1067 | + ssk->sk_err = EBADMSG; | |
| 1068 | + ssk->sk_error_report(ssk); | |
| 1069 | + tcp_set_state(ssk, TCP_CLOSE); | |
| 1070 | + subflow->reset_transient = 0; | |
| 1071 | + subflow->reset_reason = MPTCP_RST_EMPTCP; | |
| 1072 | + tcp_send_active_reset(ssk, GFP_ATOMIC); | |
| 1073 | + subflow->data_avail = 0; | |
| 1074 | + return false; | |
| 1075 | + } | |
| 1076 | + | |
| 1077 | + __mptcp_do_fallback(msk); | |
| 1078 | + skb = skb_peek(&ssk->sk_receive_queue); | |
| 1079 | + subflow->map_valid = 1; | |
| 1080 | + subflow->map_seq = READ_ONCE(msk->ack_seq); | |
| 1081 | + subflow->map_data_len = skb->len; | |
| 1082 | + subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - subflow->ssn_offset; | |
| 1083 | + subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; | |
| 1084 | + return true; | |
| 1084 | 1085 | } |
| 1085 | 1086 | |
| 1086 | 1087 | bool mptcp_subflow_data_available(struct sock *sk) |
| @@ -1367,7 +1367,7 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u, · 1366 unmodified lines | ||
| 1367 | 1367 | ip_vs_addr_copy(svc->af, &svc->addr, &u->addr); |
| 1368 | 1368 | svc->port = u->port; |
| 1369 | 1369 | svc->fwmark = u->fwmark; |
| 1370 | − svc->flags = u->flags; | |
| 1370 | + svc->flags = u->flags & ~IP_VS_SVC_F_HASHED; | |
| 1371 | 1371 | svc->timeout = u->timeout * HZ; |
| 1372 | 1372 | svc->netmask = u->netmask; |
| 1373 | 1373 | svc->ipvs = ipvs; |
| @@ -664,7 +664,7 @@ int nf_conntrack_proto_init(void) · 663 unmodified lines | ||
| 664 | 664 | |
| 665 | 665 | #if IS_ENABLED(CONFIG_IPV6) |
| 666 | 666 | cleanup_sockopt: |
| 667 | − nf_unregister_sockopt(&so_getorigdst6); | |
| 667 | + nf_unregister_sockopt(&so_getorigdst); | |
| 668 | 668 | #endif |
| 669 | 669 | return ret; |
| 670 | 670 | } |
| @@ -736,7 +736,8 @@ static int nf_tables_fill_table_info(struct sk_buff *skb, struct net *net, · 735 unmodified lines | ||
| 736 | 736 | goto nla_put_failure; |
| 737 | 737 | |
| 738 | 738 | if (nla_put_string(skb, NFTA_TABLE_NAME, table->name) || |
| 739 | − nla_put_be32(skb, NFTA_TABLE_FLAGS, htonl(table->flags)) || | |
| 739 | + nla_put_be32(skb, NFTA_TABLE_FLAGS, | |
| 740 | + htonl(table->flags & NFT_TABLE_F_MASK)) || | |
| 740 | 741 | nla_put_be32(skb, NFTA_TABLE_USE, htonl(table->use)) || |
| 741 | 742 | nla_put_be64(skb, NFTA_TABLE_HANDLE, cpu_to_be64(table->handle), |
| 742 | 743 | NFTA_TABLE_PAD)) |
| @@ -947,20 +948,22 @@ err_register_hooks: · 204 unmodified lines | ||
| 947 | 948 | |
| 948 | 949 | static void nf_tables_table_disable(struct net *net, struct nft_table *table) |
| 949 | 950 | { |
| 951 | + table->flags &= ~NFT_TABLE_F_DORMANT; | |
| 950 | 952 | nft_table_disable(net, table, 0); |
| 953 | + table->flags |= NFT_TABLE_F_DORMANT; | |
| 951 | 954 | } |
| 952 | 955 | |
| 953 | −enum { | |
| 954 | − NFT_TABLE_STATE_UNCHANGED = 0, | |
| 955 | − NFT_TABLE_STATE_DORMANT, | |
| 956 | − NFT_TABLE_STATE_WAKEUP | |
| 957 | −}; | |
| 956 | +#define __NFT_TABLE_F_INTERNAL (NFT_TABLE_F_MASK + 1) | |
| 957 | +#define __NFT_TABLE_F_WAS_DORMANT (__NFT_TABLE_F_INTERNAL << 0) | |
| 958 | +#define __NFT_TABLE_F_WAS_AWAKEN (__NFT_TABLE_F_INTERNAL << 1) | |
| 959 | +#define __NFT_TABLE_F_UPDATE (__NFT_TABLE_F_WAS_DORMANT | \ | |
| 960 | + __NFT_TABLE_F_WAS_AWAKEN) | |
| 958 | 961 | |
| 959 | 962 | static int nf_tables_updtable(struct nft_ctx *ctx) |
| 960 | 963 | { |
| 961 | 964 | struct nft_trans *trans; |
| 962 | 965 | u32 flags; |
| 963 | − int ret = 0; | |
| 966 | + int ret; | |
| 964 | 967 | |
| 965 | 968 | if (!ctx->nla[NFTA_TABLE_FLAGS]) |
| 966 | 969 | return 0; |
| @@ -985,21 +988,27 @@ static int nf_tables_updtable(struct nft_ctx *ctx) · 18 unmodified lines | ||
| 985 | 988 | |
| 986 | 989 | if ((flags & NFT_TABLE_F_DORMANT) && |
| 987 | 990 | !(ctx->table->flags & NFT_TABLE_F_DORMANT)) { |
| 988 | − nft_trans_table_state(trans) = NFT_TABLE_STATE_DORMANT; | |
| 991 | + ctx->table->flags |= NFT_TABLE_F_DORMANT; | |
| 992 | + if (!(ctx->table->flags & __NFT_TABLE_F_UPDATE)) | |
| 993 | + ctx->table->flags |= __NFT_TABLE_F_WAS_AWAKEN; | |
| 989 | 994 | } else if (!(flags & NFT_TABLE_F_DORMANT) && |
| 990 | 995 | ctx->table->flags & NFT_TABLE_F_DORMANT) { |
| 991 | − ret = nf_tables_table_enable(ctx->net, ctx->table); | |
| 992 | − if (ret >= 0) | |
| 993 | − nft_trans_table_state(trans) = NFT_TABLE_STATE_WAKEUP; | |
| 996 | + ctx->table->flags &= ~NFT_TABLE_F_DORMANT; | |
| 997 | + if (!(ctx->table->flags & __NFT_TABLE_F_UPDATE)) { | |
| 998 | + ret = nf_tables_table_enable(ctx->net, ctx->table); | |
| 999 | + if (ret < 0) | |
| 1000 | + goto err_register_hooks; | |
| 1001 | + | |
| 1002 | + ctx->table->flags |= __NFT_TABLE_F_WAS_DORMANT; | |
| 1003 | + } | |
| 994 | 1004 | } |
| 995 | − if (ret < 0) | |
| 996 | − goto err; | |
| 997 | 1005 | |
| 998 | − nft_trans_table_flags(trans) = flags; | |
| 999 | 1006 | nft_trans_table_update(trans) = true; |
| 1000 | 1007 | nft_trans_commit_list_add_tail(ctx->net, trans); |
| 1008 | + | |
| 1001 | 1009 | return 0; |
| 1002 | −err: | |
| 1010 | + | |
| 1011 | +err_register_hooks: | |
| 1003 | 1012 | nft_trans_destroy(trans); |
| 1004 | 1013 | return ret; |
| 1005 | 1014 | } |
| @@ -1905,7 +1914,7 @@ static int nft_chain_parse_netdev(struct net *net, · 899 unmodified lines | ||
| 1905 | 1914 | static int nft_chain_parse_hook(struct net *net, |
| 1906 | 1915 | const struct nlattr * const nla[], |
| 1907 | 1916 | struct nft_chain_hook *hook, u8 family, |
| 1908 | − bool autoload) | |
| 1917 | + struct netlink_ext_ack *extack, bool autoload) | |
| 1909 | 1918 | { |
| 1910 | 1919 | struct nftables_pernet *nft_net = nft_pernet(net); |
| 1911 | 1920 | struct nlattr *ha[NFTA_HOOK_MAX + 1]; |
| @@ -1935,8 +1944,10 @@ static int nft_chain_parse_hook(struct net *net, · 23 unmodified lines | ||
| 1935 | 1944 | if (nla[NFTA_CHAIN_TYPE]) { |
| 1936 | 1945 | type = nf_tables_chain_type_lookup(net, nla[NFTA_CHAIN_TYPE], |
| 1937 | 1946 | family, autoload); |
| 1938 | − if (IS_ERR(type)) | |
| 1947 | + if (IS_ERR(type)) { | |
| 1948 | + NL_SET_BAD_ATTR(extack, nla[NFTA_CHAIN_TYPE]); | |
| 1939 | 1949 | return PTR_ERR(type); |
| 1950 | + } | |
| 1940 | 1951 | } |
| 1941 | 1952 | if (hook->num >= NFT_MAX_HOOKS || !(type->hook_mask & (1 << hook->num))) |
| 1942 | 1953 | return -EOPNOTSUPP; |
| @@ -1945,8 +1956,11 @@ static int nft_chain_parse_hook(struct net *net, · 2 unmodified lines | ||
| 1945 | 1956 | hook->priority <= NF_IP_PRI_CONNTRACK) |
| 1946 | 1957 | return -EOPNOTSUPP; |
| 1947 | 1958 | |
| 1948 | − if (!try_module_get(type->owner)) | |
| 1959 | + if (!try_module_get(type->owner)) { | |
| 1960 | + if (nla[NFTA_CHAIN_TYPE]) | |
| 1961 | + NL_SET_BAD_ATTR(extack, nla[NFTA_CHAIN_TYPE]); | |
| 1949 | 1962 | return -ENOENT; |
| 1963 | + } | |
| 1950 | 1964 | |
| 1951 | 1965 | hook->type = type; |
| 1952 | 1966 | |
| @@ -2057,7 +2071,8 @@ static int nft_chain_add(struct nft_table *table, struct nft_chain *chain) · 104 unmodified lines | ||
| 2057 | 2071 | static u64 chain_id; |
| 2058 | 2072 | |
| 2059 | 2073 | static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, |
| 2060 | − u8 policy, u32 flags) | |
| 2074 | + u8 policy, u32 flags, | |
| 2075 | + struct netlink_ext_ack *extack) | |
| 2061 | 2076 | { |
| 2062 | 2077 | const struct nlattr * const *nla = ctx->nla; |
| 2063 | 2078 | struct nft_table *table = ctx->table; |
| @@ -2079,7 +2094,8 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, · 15 unmodified lines | ||
| 2079 | 2094 | if (flags & NFT_CHAIN_BINDING) |
| 2080 | 2095 | return -EOPNOTSUPP; |
| 2081 | 2096 | |
| 2082 | − err = nft_chain_parse_hook(net, nla, &hook, family, true); | |
| 2097 | + err = nft_chain_parse_hook(net, nla, &hook, family, extack, | |
| 2098 | + true); | |
| 2083 | 2099 | if (err < 0) |
| 2084 | 2100 | return err; |
| 2085 | 2101 | |
| @@ -2234,7 +2250,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy, · 148 unmodified lines | ||
| 2234 | 2250 | return -EEXIST; |
| 2235 | 2251 | } |
| 2236 | 2252 | err = nft_chain_parse_hook(ctx->net, nla, &hook, ctx->family, |
| 2237 | − false); | |
| 2253 | + extack, false); | |
| 2238 | 2254 | if (err < 0) |
| 2239 | 2255 | return err; |
| 2240 | 2256 | |
| @@ -2447,7 +2463,7 @@ static int nf_tables_newchain(struct sk_buff *skb, const struct nfnl_info *info, · 206 unmodified lines | ||
| 2447 | 2463 | extack); |
| 2448 | 2464 | } |
| 2449 | 2465 | |
| 2450 | − return nf_tables_addchain(&ctx, family, genmask, policy, flags); | |
| 2466 | + return nf_tables_addchain(&ctx, family, genmask, policy, flags, extack); | |
| 2451 | 2467 | } |
| 2452 | 2468 | |
| 2453 | 2469 | static int nf_tables_delchain(struct sk_buff *skb, const struct nfnl_info *info, |
| @@ -3328,8 +3344,10 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info, · 874 unmodified lines | ||
| 3328 | 3344 | if (n == NFT_RULE_MAXEXPRS) |
| 3329 | 3345 | goto err1; |
| 3330 | 3346 | err = nf_tables_expr_parse(&ctx, tmp, &expr_info[n]); |
| 3331 | − if (err < 0) | |
| 3347 | + if (err < 0) { | |
| 3348 | + NL_SET_BAD_ATTR(extack, tmp); | |
| 3332 | 3349 | goto err1; |
| 3350 | + } | |
| 3333 | 3351 | size += expr_info[n].ops->size; |
| 3334 | 3352 | n++; |
| 3335 | 3353 | } |
| @@ -8547,10 +8565,14 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) · 5211 unmodified lines | ||
| 8547 | 8565 | switch (trans->msg_type) { |
| 8548 | 8566 | case NFT_MSG_NEWTABLE: |
| 8549 | 8567 | if (nft_trans_table_update(trans)) { |
| 8550 | − if (nft_trans_table_state(trans) == NFT_TABLE_STATE_DORMANT) | |
| 8568 | + if (!(trans->ctx.table->flags & __NFT_TABLE_F_UPDATE)) { | |
| 8569 | + nft_trans_destroy(trans); | |
| 8570 | + break; | |
| 8571 | + } | |
| 8572 | + if (trans->ctx.table->flags & NFT_TABLE_F_DORMANT) | |
| 8551 | 8573 | nf_tables_table_disable(net, trans->ctx.table); |
| 8552 | 8574 | |
| 8553 | − trans->ctx.table->flags = nft_trans_table_flags(trans); | |
| 8575 | + trans->ctx.table->flags &= ~__NFT_TABLE_F_UPDATE; | |
| 8554 | 8576 | } else { |
| 8555 | 8577 | nft_clear(net, trans->ctx.table); |
| 8556 | 8578 | } |
| @@ -8768,9 +8790,17 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action) · 211 unmodified lines | ||
| 8768 | 8790 | switch (trans->msg_type) { |
| 8769 | 8791 | case NFT_MSG_NEWTABLE: |
| 8770 | 8792 | if (nft_trans_table_update(trans)) { |
| 8771 | − if (nft_trans_table_state(trans) == NFT_TABLE_STATE_WAKEUP) | |
| 8793 | + if (!(trans->ctx.table->flags & __NFT_TABLE_F_UPDATE)) { | |
| 8794 | + nft_trans_destroy(trans); | |
| 8795 | + break; | |
| 8796 | + } | |
| 8797 | + if (trans->ctx.table->flags & __NFT_TABLE_F_WAS_DORMANT) { | |
| 8772 | 8798 | nf_tables_table_disable(net, trans->ctx.table); |
| 8773 | − | |
| 8799 | + trans->ctx.table->flags |= NFT_TABLE_F_DORMANT; | |
| 8800 | + } else if (trans->ctx.table->flags & __NFT_TABLE_F_WAS_AWAKEN) { | |
| 8801 | + trans->ctx.table->flags &= ~NFT_TABLE_F_DORMANT; | |
| 8802 | + } | |
| 8803 | + trans->ctx.table->flags &= ~__NFT_TABLE_F_UPDATE; | |
| 8774 | 8804 | nft_trans_destroy(trans); |
| 8775 | 8805 | } else { |
| 8776 | 8806 | list_del_rcu(&trans->ctx.table->list); |
| @@ -380,10 +380,14 @@ static int · 379 unmodified lines | ||
| 380 | 380 | nfnl_cthelper_update(const struct nlattr * const tb[], |
| 381 | 381 | struct nf_conntrack_helper *helper) |
| 382 | 382 | { |
| 383 | + u32 size; | |
| 383 | 384 | int ret; |
| 384 | 385 | |
| 385 | − if (tb[NFCTH_PRIV_DATA_LEN]) | |
| 386 | − return -EBUSY; | |
| 386 | + if (tb[NFCTH_PRIV_DATA_LEN]) { | |
| 387 | + size = ntohl(nla_get_be32(tb[NFCTH_PRIV_DATA_LEN])); | |
| 388 | + if (size != helper->data_len) | |
| 389 | + return -EBUSY; | |
| 390 | + } | |
| 387 | 391 | |
| 388 | 392 | if (tb[NFCTH_POLICY]) { |
| 389 | 393 | ret = nfnl_cthelper_update_policy(helper, tb[NFCTH_POLICY]); |
| @@ -1217,7 +1217,7 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj, · 1216 unmodified lines | ||
| 1217 | 1217 | struct nf_conn *ct; |
| 1218 | 1218 | |
| 1219 | 1219 | ct = nf_ct_get(pkt->skb, &ctinfo); |
| 1220 | − if (!ct || ctinfo == IP_CT_UNTRACKED) { | |
| 1220 | + if (!ct || nf_ct_is_confirmed(ct) || nf_ct_is_template(ct)) { | |
| 1221 | 1221 | regs->verdict.code = NFT_BREAK; |
| 1222 | 1222 | return; |
| 1223 | 1223 | } |
| @@ -110,6 +110,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) · 109 unmodified lines | ||
| 110 | 110 | if (!llcp_sock->service_name) { |
| 111 | 111 | nfc_llcp_local_put(llcp_sock->local); |
| 112 | 112 | llcp_sock->local = NULL; |
| 113 | + llcp_sock->dev = NULL; | |
| 113 | 114 | ret = -ENOMEM; |
| 114 | 115 | goto put_dev; |
| 115 | 116 | } |
| @@ -119,6 +120,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) · 3 unmodified lines | ||
| 119 | 120 | llcp_sock->local = NULL; |
| 120 | 121 | kfree(llcp_sock->service_name); |
| 121 | 122 | llcp_sock->service_name = NULL; |
| 123 | + llcp_sock->dev = NULL; | |
| 122 | 124 | ret = -EADDRINUSE; |
| 123 | 125 | goto put_dev; |
| 124 | 126 | } |
| @@ -984,7 +984,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, · 983 unmodified lines | ||
| 984 | 984 | */ |
| 985 | 985 | cached = tcf_ct_skb_nfct_cached(net, skb, p->zone, force); |
| 986 | 986 | if (!cached) { |
| 987 | − if (!commit && tcf_ct_flow_table_lookup(p, skb, family)) { | |
| 987 | + if (tcf_ct_flow_table_lookup(p, skb, family)) { | |
| 988 | 988 | skip_add = true; |
| 989 | 989 | goto do_nat; |
| 990 | 990 | } |
| @@ -1022,10 +1022,11 @@ do_nat: · 31 unmodified lines | ||
| 1022 | 1022 | * even if the connection is already confirmed. |
| 1023 | 1023 | */ |
| 1024 | 1024 | nf_conntrack_confirm(skb); |
| 1025 | − } else if (!skip_add) { | |
| 1026 | − tcf_ct_flow_table_process_conn(p->ct_ft, ct, ctinfo); | |
| 1027 | 1025 | } |
| 1028 | 1026 | |
| 1027 | + if (!skip_add) | |
| 1028 | + tcf_ct_flow_table_process_conn(p->ct_ft, ct, ctinfo); | |
| 1029 | + | |
| 1029 | 1030 | out_push: |
| 1030 | 1031 | skb_push_rcsum(skb, nh_ofs); |
| 1031 | 1032 | |
| @@ -1202,9 +1203,6 @@ static int tcf_ct_fill_params(struct net *net, · 170 unmodified lines | ||
| 1202 | 1203 | sizeof(p->zone)); |
| 1203 | 1204 | } |
| 1204 | 1205 | |
| 1205 | − if (p->zone == NF_CT_DEFAULT_ZONE_ID) | |
| 1206 | − return 0; | |
| 1207 | − | |
| 1208 | 1206 | nf_ct_zone_init(&zone, p->zone, NF_CT_DEFAULT_ZONE_DIR, 0); |
| 1209 | 1207 | tmpl = nf_ct_tmpl_alloc(net, &zone, GFP_KERNEL); |
| 1210 | 1208 | if (!tmpl) { |
| @@ -1488,7 +1488,8 @@ static void htb_parent_to_leaf_offload(struct Qdisc *sch, · 1487 unmodified lines | ||
| 1488 | 1488 | struct Qdisc *old_q; |
| 1489 | 1489 | |
| 1490 | 1490 | /* One ref for cl->leaf.q, the other for dev_queue->qdisc. */ |
| 1491 | − qdisc_refcount_inc(new_q); | |
| 1491 | + if (new_q) | |
| 1492 | + qdisc_refcount_inc(new_q); | |
| 1492 | 1493 | old_q = htb_graft_helper(dev_queue, new_q); |
| 1493 | 1494 | WARN_ON(!(old_q->flags & TCQ_F_BUILTIN)); |
| 1494 | 1495 | } |
| @@ -1675,10 +1676,9 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg, · 180 unmodified lines | ||
| 1675 | 1676 | cl->parent->common.classid, |
| 1676 | 1677 | NULL); |
| 1677 | 1678 | if (q->offload) { |
| 1678 | − if (new_q) { | |
| 1679 | + if (new_q) | |
| 1679 | 1680 | htb_set_lockdep_class_child(new_q); |
| 1680 | − htb_parent_to_leaf_offload(sch, dev_queue, new_q); | |
| 1681 | − } | |
| 1681 | + htb_parent_to_leaf_offload(sch, dev_queue, new_q); | |
| 1682 | 1682 | } |
| 1683 | 1683 | } |
| 1684 | 1684 | |
| @@ -50,6 +50,7 @@ static void tls_device_gc_task(struct work_struct *work); · 49 unmodified lines | ||
| 50 | 50 | static DECLARE_WORK(tls_device_gc_work, tls_device_gc_task); |
| 51 | 51 | static LIST_HEAD(tls_device_gc_list); |
| 52 | 52 | static LIST_HEAD(tls_device_list); |
| 53 | +static LIST_HEAD(tls_device_down_list); | |
| 53 | 54 | static DEFINE_SPINLOCK(tls_device_lock); |
| 54 | 55 | |
| 55 | 56 | static void tls_device_free_ctx(struct tls_context *ctx) |
| @@ -680,15 +681,13 @@ static void tls_device_resync_rx(struct tls_context *tls_ctx, · 624 unmodified lines | ||
| 680 | 681 | struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx); |
| 681 | 682 | struct net_device *netdev; |
| 682 | 683 | |
| 683 | − if (WARN_ON(test_and_set_bit(TLS_RX_SYNC_RUNNING, &tls_ctx->flags))) | |
| 684 | − return; | |
| 685 | − | |
| 686 | 684 | trace_tls_device_rx_resync_send(sk, seq, rcd_sn, rx_ctx->resync_type); |
| 685 | + rcu_read_lock(); | |
| 687 | 686 | netdev = READ_ONCE(tls_ctx->netdev); |
| 688 | 687 | if (netdev) |
| 689 | 688 | netdev->tlsdev_ops->tls_dev_resync(netdev, sk, seq, rcd_sn, |
| 690 | 689 | TLS_OFFLOAD_CTX_DIR_RX); |
| 691 | − clear_bit_unlock(TLS_RX_SYNC_RUNNING, &tls_ctx->flags); | |
| 690 | + rcu_read_unlock(); | |
| 692 | 691 | TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSRXDEVICERESYNC); |
| 693 | 692 | } |
| 694 | 693 | |
| @@ -761,6 +760,8 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) · 66 unmodified lines | ||
| 761 | 760 | |
| 762 | 761 | if (tls_ctx->rx_conf != TLS_HW) |
| 763 | 762 | return; |
| 763 | + if (unlikely(test_bit(TLS_RX_DEV_DEGRADED, &tls_ctx->flags))) | |
| 764 | + return; | |
| 764 | 765 | |
| 765 | 766 | prot = &tls_ctx->prot_info; |
| 766 | 767 | rx_ctx = tls_offload_ctx_rx(tls_ctx); |
| @@ -963,6 +964,17 @@ int tls_device_decrypted(struct sock *sk, struct tls_context *tls_ctx, · 196 unmodified lines | ||
| 963 | 964 | |
| 964 | 965 | ctx->sw.decrypted |= is_decrypted; |
| 965 | 966 | |
| 967 | + if (unlikely(test_bit(TLS_RX_DEV_DEGRADED, &tls_ctx->flags))) { | |
| 968 | + if (likely(is_encrypted || is_decrypted)) | |
| 969 | + return 0; | |
| 970 | + | |
| 971 | + /* After tls_device_down disables the offload, the next SKB will | |
| 972 | + * likely have initial fragments decrypted, and final ones not | |
| 973 | + * decrypted. We need to reencrypt that single SKB. | |
| 974 | + */ | |
| 975 | + return tls_device_reencrypt(sk, skb); | |
| 976 | + } | |
| 977 | + | |
| 966 | 978 | /* Return immediately if the record is either entirely plaintext or |
| 967 | 979 | * entirely ciphertext. Otherwise handle reencrypt partially decrypted |
| 968 | 980 | * record. |
| @@ -1292,6 +1304,26 @@ static int tls_device_down(struct net_device *netdev) · 323 unmodified lines | ||
| 1292 | 1304 | spin_unlock_irqrestore(&tls_device_lock, flags); |
| 1293 | 1305 | |
| 1294 | 1306 | list_for_each_entry_safe(ctx, tmp, &list, list) { |
| 1307 | + /* Stop offloaded TX and switch to the fallback. | |
| 1308 | + * tls_is_sk_tx_device_offloaded will return false. | |
| 1309 | + */ | |
| 1310 | + WRITE_ONCE(ctx->sk->sk_validate_xmit_skb, tls_validate_xmit_skb_sw); | |
| 1311 | + | |
| 1312 | + /* Stop the RX and TX resync. | |
| 1313 | + * tls_dev_resync must not be called after tls_dev_del. | |
| 1314 | + */ | |
| 1315 | + WRITE_ONCE(ctx->netdev, NULL); | |
| 1316 | + | |
| 1317 | + /* Start skipping the RX resync logic completely. */ | |
| 1318 | + set_bit(TLS_RX_DEV_DEGRADED, &ctx->flags); | |
| 1319 | + | |
| 1320 | + /* Sync with inflight packets. After this point: | |
| 1321 | + * TX: no non-encrypted packets will be passed to the driver. | |
| 1322 | + * RX: resync requests from the driver will be ignored. | |
| 1323 | + */ | |
| 1324 | + synchronize_net(); | |
| 1325 | + | |
| 1326 | + /* Release the offload context on the driver side. */ | |
| 1295 | 1327 | if (ctx->tx_conf == TLS_HW) |
| 1296 | 1328 | netdev->tlsdev_ops->tls_dev_del(netdev, ctx, |
| 1297 | 1329 | TLS_OFFLOAD_CTX_DIR_TX); |
| @@ -1299,15 +1331,21 @@ static int tls_device_down(struct net_device *netdev) · 1 unmodified line | ||
| 1299 | 1331 | !test_bit(TLS_RX_DEV_CLOSED, &ctx->flags)) |
| 1300 | 1332 | netdev->tlsdev_ops->tls_dev_del(netdev, ctx, |
| 1301 | 1333 | TLS_OFFLOAD_CTX_DIR_RX); |
| 1302 | − WRITE_ONCE(ctx->netdev, NULL); | |
| 1303 | − smp_mb__before_atomic(); /* pairs with test_and_set_bit() */ | |
| 1304 | − while (test_bit(TLS_RX_SYNC_RUNNING, &ctx->flags)) | |
| 1305 | − usleep_range(10, 200); | |
| 1334 | + | |
| 1306 | 1335 | dev_put(netdev); |
| 1307 | − list_del_init(&ctx->list); | |
| 1308 | 1336 | |
| 1309 | − if (refcount_dec_and_test(&ctx->refcount)) | |
| 1310 | − tls_device_free_ctx(ctx); | |
| 1337 | + /* Move the context to a separate list for two reasons: | |
| 1338 | + * 1. When the context is deallocated, list_del is called. | |
| 1339 | + * 2. It's no longer an offloaded context, so we don't want to | |
| 1340 | + * run offload-specific code on this context. | |
| 1341 | + */ | |
| 1342 | + spin_lock_irqsave(&tls_device_lock, flags); | |
| 1343 | + list_move_tail(&ctx->list, &tls_device_down_list); | |
| 1344 | + spin_unlock_irqrestore(&tls_device_lock, flags); | |
| 1345 | + | |
| 1346 | + /* Device contexts for RX and TX will be freed in on sk_destruct | |
| 1347 | + * by tls_device_free_ctx. rx_conf and tx_conf stay in TLS_HW. | |
| 1348 | + */ | |
| 1311 | 1349 | } |
| 1312 | 1350 | |
| 1313 | 1351 | up_write(&device_offload_lock); |
| @@ -431,6 +431,13 @@ struct sk_buff *tls_validate_xmit_skb(struct sock *sk, · 430 unmodified lines | ||
| 431 | 431 | } |
| 432 | 432 | EXPORT_SYMBOL_GPL(tls_validate_xmit_skb); |
| 433 | 433 | |
| 434 | +struct sk_buff *tls_validate_xmit_skb_sw(struct sock *sk, | |
| 435 | + struct net_device *dev, | |
| 436 | + struct sk_buff *skb) | |
| 437 | +{ | |
| 438 | + return tls_sw_fallback(sk, skb); | |
| 439 | +} | |
| 440 | + | |
| 434 | 441 | struct sk_buff *tls_encrypt_skb(struct sk_buff *skb) |
| 435 | 442 | { |
| 436 | 443 | return tls_sw_fallback(skb->sk, skb); |
| @@ -636,6 +636,7 @@ struct tls_context *tls_ctx_create(struct sock *sk) · 635 unmodified lines | ||
| 636 | 636 | mutex_init(&ctx->tx_lock); |
| 637 | 637 | rcu_assign_pointer(icsk->icsk_ulp_data, ctx); |
| 638 | 638 | ctx->sk_proto = READ_ONCE(sk->sk_prot); |
| 639 | + ctx->sk = sk; | |
| 639 | 640 | return ctx; |
| 640 | 641 | } |
| 641 | 642 | |
| @@ -536,7 +536,7 @@ static int x25_create(struct net *net, struct socket *sock, int protocol, · 535 unmodified lines | ||
| 536 | 536 | if (protocol) |
| 537 | 537 | goto out; |
| 538 | 538 | |
| 539 | − rc = -ENOBUFS; | |
| 539 | + rc = -ENOMEM; | |
| 540 | 540 | if ((sk = x25_alloc_socket(net, kern)) == NULL) |
| 541 | 541 | goto out; |
| 542 | 542 | |
| @@ -117,22 +117,27 @@ static int mdpy_fb_probe(struct pci_dev *pdev, · 116 unmodified lines | ||
| 117 | 117 | if (format != DRM_FORMAT_XRGB8888) { |
| 118 | 118 | pci_err(pdev, "format mismatch (0x%x != 0x%x)\n", |
| 119 | 119 | format, DRM_FORMAT_XRGB8888); |
| 120 | − return -EINVAL; | |
| 120 | + ret = -EINVAL; | |
| 121 | + goto err_release_regions; | |
| 121 | 122 | } |
| 122 | 123 | if (width < 100 || width > 10000) { |
| 123 | 124 | pci_err(pdev, "width (%d) out of range\n", width); |
| 124 | − return -EINVAL; | |
| 125 | + ret = -EINVAL; | |
| 126 | + goto err_release_regions; | |
| 125 | 127 | } |
| 126 | 128 | if (height < 100 || height > 10000) { |
| 127 | 129 | pci_err(pdev, "height (%d) out of range\n", height); |
| 128 | − return -EINVAL; | |
| 130 | + ret = -EINVAL; | |
| 131 | + goto err_release_regions; | |
| 129 | 132 | } |
| 130 | 133 | pci_info(pdev, "mdpy found: %dx%d framebuffer\n", |
| 131 | 134 | width, height); |
| 132 | 135 | |
| 133 | 136 | info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev); |
| 134 | − if (!info) | |
| 137 | + if (!info) { | |
| 138 | + ret = -ENOMEM; | |
| 135 | 139 | goto err_release_regions; |
| 140 | + } | |
| 136 | 141 | pci_set_drvdata(pdev, info); |
| 137 | 142 | par = info->par; |
| 138 | 143 | |
| @@ -59,7 +59,7 @@ quiet_cmd_ld_ko_o = LD [M] $@ · 58 unmodified lines | ||
| 59 | 59 | quiet_cmd_btf_ko = BTF [M] $@ |
| 60 | 60 | cmd_btf_ko = \ |
| 61 | 61 | if [ -f vmlinux ]; then \ |
| 62 | − LLVM_OBJCOPY=$(OBJCOPY) $(PAHOLE) -J --btf_base vmlinux $@; \ | |
| 62 | + LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J --btf_base vmlinux $@; \ | |
| 63 | 63 | else \ |
| 64 | 64 | printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \ |
| 65 | 65 | fi; |
| @@ -240,7 +240,7 @@ gen_btf() · 239 unmodified lines | ||
| 240 | 240 | fi |
| 241 | 241 | |
| 242 | 242 | info "BTF" ${2} |
| 243 | − LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${extra_paholeopt} ${1} | |
| 243 | + LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${extra_paholeopt} ${1} | |
| 244 | 244 | |
| 245 | 245 | # Create ${2} which contains just .BTF section but no symbols. Add |
| 246 | 246 | # SHF_ALLOC because .BTF will be part of the vmlinux image. --strip-all |
| @@ -17,6 +17,9 @@ MODULE_LICENSE("GPL"); · 16 unmodified lines | ||
| 17 | 17 | #define MAX_LED (((SNDRV_CTL_ELEM_ACCESS_MIC_LED - SNDRV_CTL_ELEM_ACCESS_SPK_LED) \ |
| 18 | 18 | >> SNDRV_CTL_ELEM_ACCESS_LED_SHIFT) + 1) |
| 19 | 19 | |
| 20 | +#define to_led_card_dev(_dev) \ | |
| 21 | + container_of(_dev, struct snd_ctl_led_card, dev) | |
| 22 | + | |
| 20 | 23 | enum snd_ctl_led_mode { |
| 21 | 24 | MODE_FOLLOW_MUTE = 0, |
| 22 | 25 | MODE_FOLLOW_ROUTE, |
| @@ -371,6 +374,21 @@ static void snd_ctl_led_disconnect(struct snd_card *card) · 348 unmodified lines | ||
| 371 | 374 | snd_ctl_led_refresh(); |
| 372 | 375 | } |
| 373 | 376 | |
| 377 | +static void snd_ctl_led_card_release(struct device *dev) | |
| 378 | +{ | |
| 379 | + struct snd_ctl_led_card *led_card = to_led_card_dev(dev); | |
| 380 | + | |
| 381 | + kfree(led_card); | |
| 382 | +} | |
| 383 | + | |
| 384 | +static void snd_ctl_led_release(struct device *dev) | |
| 385 | +{ | |
| 386 | +} | |
| 387 | + | |
| 388 | +static void snd_ctl_led_dev_release(struct device *dev) | |
| 389 | +{ | |
| 390 | +} | |
| 391 | + | |
| 374 | 392 | /* |
| 375 | 393 | * sysfs |
| 376 | 394 | */ |
| @@ -663,6 +681,7 @@ static void snd_ctl_led_sysfs_add(struct snd_card *card) · 286 unmodified lines | ||
| 663 | 681 | led_card->number = card->number; |
| 664 | 682 | led_card->led = led; |
| 665 | 683 | device_initialize(&led_card->dev); |
| 684 | + led_card->dev.release = snd_ctl_led_card_release; | |
| 666 | 685 | if (dev_set_name(&led_card->dev, "card%d", card->number) < 0) |
| 667 | 686 | goto cerr; |
| 668 | 687 | led_card->dev.parent = &led->dev; |
| @@ -681,7 +700,6 @@ cerr: · 12 unmodified lines | ||
| 681 | 700 | put_device(&led_card->dev); |
| 682 | 701 | cerr2: |
| 683 | 702 | printk(KERN_ERR "snd_ctl_led: unable to add card%d", card->number); |
| 684 | − kfree(led_card); | |
| 685 | 703 | } |
| 686 | 704 | } |
| 687 | 705 | |
| @@ -700,8 +718,7 @@ static void snd_ctl_led_sysfs_remove(struct snd_card *card) · 12 unmodified lines | ||
| 700 | 718 | snprintf(link_name, sizeof(link_name), "led-%s", led->name); |
| 701 | 719 | sysfs_remove_link(&card->ctl_dev.kobj, link_name); |
| 702 | 720 | sysfs_remove_link(&led_card->dev.kobj, "card"); |
| 703 | − device_del(&led_card->dev); | |
| 704 | − kfree(led_card); | |
| 721 | + device_unregister(&led_card->dev); | |
| 705 | 722 | led->cards[card->number] = NULL; |
| 706 | 723 | } |
| 707 | 724 | } |
| @@ -723,6 +740,7 @@ static int __init snd_ctl_led_init(void) · 15 unmodified lines | ||
| 723 | 740 | |
| 724 | 741 | device_initialize(&snd_ctl_led_dev); |
| 725 | 742 | snd_ctl_led_dev.class = sound_class; |
| 743 | + snd_ctl_led_dev.release = snd_ctl_led_dev_release; | |
| 726 | 744 | dev_set_name(&snd_ctl_led_dev, "ctl-led"); |
| 727 | 745 | if (device_add(&snd_ctl_led_dev)) { |
| 728 | 746 | put_device(&snd_ctl_led_dev); |
| @@ -733,15 +751,16 @@ static int __init snd_ctl_led_init(void) · 4 unmodified lines | ||
| 733 | 751 | INIT_LIST_HEAD(&led->controls); |
| 734 | 752 | device_initialize(&led->dev); |
| 735 | 753 | led->dev.parent = &snd_ctl_led_dev; |
| 754 | + led->dev.release = snd_ctl_led_release; | |
| 736 | 755 | led->dev.groups = snd_ctl_led_dev_attr_groups; |
| 737 | 756 | dev_set_name(&led->dev, led->name); |
| 738 | 757 | if (device_add(&led->dev)) { |
| 739 | 758 | put_device(&led->dev); |
| 740 | 759 | for (; group > 0; group--) { |
| 741 | 760 | led = &snd_ctl_leds[group - 1]; |
| 742 | − device_del(&led->dev); | |
| 761 | + device_unregister(&led->dev); | |
| 743 | 762 | } |
| 744 | − device_del(&snd_ctl_led_dev); | |
| 763 | + device_unregister(&snd_ctl_led_dev); | |
| 745 | 764 | return -ENOMEM; |
| 746 | 765 | } |
| 747 | 766 | } |
| @@ -767,9 +786,9 @@ static void __exit snd_ctl_led_exit(void) · 19 unmodified lines | ||
| 767 | 786 | } |
| 768 | 787 | for (group = 0; group < MAX_LED; group++) { |
| 769 | 788 | led = &snd_ctl_leds[group]; |
| 770 | − device_del(&led->dev); | |
| 789 | + device_unregister(&led->dev); | |
| 771 | 790 | } |
| 772 | − device_del(&snd_ctl_led_dev); | |
| 791 | + device_unregister(&snd_ctl_led_dev); | |
| 773 | 792 | snd_ctl_led_clean(NULL); |
| 774 | 793 | } |
| 775 | 794 | |
| @@ -297,8 +297,16 @@ int snd_seq_timer_open(struct snd_seq_queue *q) · 296 unmodified lines | ||
| 297 | 297 | return err; |
| 298 | 298 | } |
| 299 | 299 | spin_lock_irq(&tmr->lock); |
| 300 | − tmr->timeri = t; | |
| 300 | + if (tmr->timeri) | |
| 301 | + err = -EBUSY; | |
| 302 | + else | |
| 303 | + tmr->timeri = t; | |
| 301 | 304 | spin_unlock_irq(&tmr->lock); |
| 305 | + if (err < 0) { | |
| 306 | + snd_timer_close(t); | |
| 307 | + snd_timer_instance_free(t); | |
| 308 | + return err; | |
| 309 | + } | |
| 302 | 310 | return 0; |
| 303 | 311 | } |
| 304 | 312 | |
| @@ -520,9 +520,10 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event) · 519 unmodified lines | ||
| 520 | 520 | return; |
| 521 | 521 | if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE) |
| 522 | 522 | return; |
| 523 | + event += 10; /* convert to SNDRV_TIMER_EVENT_MXXX */ | |
| 523 | 524 | list_for_each_entry(ts, &ti->slave_active_head, active_list) |
| 524 | 525 | if (ts->ccallback) |
| 525 | − ts->ccallback(ts, event + 100, &tstamp, resolution); | |
| 526 | + ts->ccallback(ts, event, &tstamp, resolution); | |
| 526 | 527 | } |
| 527 | 528 | |
| 528 | 529 | /* start/continue a master timer */ |
| @@ -804,7 +804,7 @@ static void generate_pkt_descs(struct amdtp_stream *s, struct pkt_desc *descs, · 803 unmodified lines | ||
| 804 | 804 | static inline void cancel_stream(struct amdtp_stream *s) |
| 805 | 805 | { |
| 806 | 806 | s->packet_index = -1; |
| 807 | − if (current_work() == &s->period_work) | |
| 807 | + if (in_interrupt()) | |
| 808 | 808 | amdtp_stream_pcm_abort(s); |
| 809 | 809 | WRITE_ONCE(s->pcm_buffer_pointer, SNDRV_PCM_POS_XRUN); |
| 810 | 810 | } |
| @@ -331,6 +331,10 @@ static const struct config_entry config_table[] = { · 330 unmodified lines | ||
| 331 | 331 | .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, |
| 332 | 332 | .device = 0x51c8, |
| 333 | 333 | }, |
| 334 | + { | |
| 335 | + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, | |
| 336 | + .device = 0x51cc, | |
| 337 | + }, | |
| 334 | 338 | #endif |
| 335 | 339 | |
| 336 | 340 | }; |
| @@ -2917,6 +2917,7 @@ static int hda_codec_runtime_resume(struct device *dev) · 2916 unmodified lines | ||
| 2917 | 2917 | #ifdef CONFIG_PM_SLEEP |
| 2918 | 2918 | static int hda_codec_pm_prepare(struct device *dev) |
| 2919 | 2919 | { |
| 2920 | + dev->power.power_state = PMSG_SUSPEND; | |
| 2920 | 2921 | return pm_runtime_suspended(dev); |
| 2921 | 2922 | } |
| 2922 | 2923 | |
| @@ -2924,6 +2925,10 @@ static void hda_codec_pm_complete(struct device *dev) · 1 unmodified line | ||
| 2924 | 2925 | { |
| 2925 | 2926 | struct hda_codec *codec = dev_to_hda_codec(dev); |
| 2926 | 2927 | |
| 2928 | + /* If no other pm-functions are called between prepare() and complete() */ | |
| 2929 | + if (dev->power.power_state.event == PM_EVENT_SUSPEND) | |
| 2930 | + dev->power.power_state = PMSG_RESUME; | |
| 2931 | + | |
| 2927 | 2932 | if (pm_runtime_suspended(dev) && (codec->jackpoll_interval || |
| 2928 | 2933 | hda_codec_need_resume(codec) || codec->forced_resume)) |
| 2929 | 2934 | pm_request_resume(dev); |
| @@ -3520,6 +3520,7 @@ static int cap_sw_put(struct snd_kcontrol *kcontrol, · 3519 unmodified lines | ||
| 3520 | 3520 | static const struct snd_kcontrol_new cap_sw_temp = { |
| 3521 | 3521 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3522 | 3522 | .name = "Capture Switch", |
| 3523 | + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | |
| 3523 | 3524 | .info = cap_sw_info, |
| 3524 | 3525 | .get = cap_sw_get, |
| 3525 | 3526 | .put = cap_sw_put, |
| @@ -2485,6 +2485,9 @@ static const struct pci_device_id azx_ids[] = { · 2484 unmodified lines | ||
| 2485 | 2485 | /* Alderlake-P */ |
| 2486 | 2486 | { PCI_DEVICE(0x8086, 0x51c8), |
| 2487 | 2487 | .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, |
| 2488 | + /* Alderlake-M */ | |
| 2489 | + { PCI_DEVICE(0x8086, 0x51cc), | |
| 2490 | + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, | |
| 2488 | 2491 | /* Elkhart Lake */ |
| 2489 | 2492 | { PCI_DEVICE(0x8086, 0x4b55), |
| 2490 | 2493 | .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, |
| @@ -2206,10 +2206,9 @@ static void cs8409_cs42l42_fixups(struct hda_codec *codec, · 2205 unmodified lines | ||
| 2206 | 2206 | break; |
| 2207 | 2207 | case HDA_FIXUP_ACT_PROBE: |
| 2208 | 2208 | |
| 2209 | − /* Set initial volume on Bullseye to -26 dB */ | |
| 2210 | − if (codec->fixup_id == CS8409_BULLSEYE) | |
| 2211 | − snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID, | |
| 2212 | − HDA_INPUT, 0, 0xff, 0x19); | |
| 2209 | + /* Set initial DMIC volume to -26 dB */ | |
| 2210 | + snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID, | |
| 2211 | + HDA_INPUT, 0, 0xff, 0x19); | |
| 2213 | 2212 | snd_hda_gen_add_kctl(&spec->gen, |
| 2214 | 2213 | NULL, &cs8409_cs42l42_hp_volume_mixer); |
| 2215 | 2214 | snd_hda_gen_add_kctl(&spec->gen, |
| @@ -6568,6 +6568,7 @@ enum { · 6567 unmodified lines | ||
| 6568 | 6568 | ALC285_FIXUP_HP_SPECTRE_X360, |
| 6569 | 6569 | ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, |
| 6570 | 6570 | ALC623_FIXUP_LENOVO_THINKSTATION_P340, |
| 6571 | + ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, | |
| 6571 | 6572 | }; |
| 6572 | 6573 | |
| 6573 | 6574 | static const struct hda_fixup alc269_fixups[] = { |
| @@ -8146,6 +8147,15 @@ static const struct hda_fixup alc269_fixups[] = { · 1572 unmodified lines | ||
| 8146 | 8147 | .chained = true, |
| 8147 | 8148 | .chain_id = ALC283_FIXUP_HEADSET_MIC, |
| 8148 | 8149 | }, |
| 8150 | + [ALC255_FIXUP_ACER_HEADPHONE_AND_MIC] = { | |
| 8151 | + .type = HDA_FIXUP_PINS, | |
| 8152 | + .v.pins = (const struct hda_pintbl[]) { | |
| 8153 | + { 0x21, 0x03211030 }, /* Change the Headphone location to Left */ | |
| 8154 | + { } | |
| 8155 | + }, | |
| 8156 | + .chained = true, | |
| 8157 | + .chain_id = ALC255_FIXUP_XIAOMI_HEADSET_MIC | |
| 8158 | + }, | |
| 8149 | 8159 | }; |
| 8150 | 8160 | |
| 8151 | 8161 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
| @@ -8182,6 +8192,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 30 unmodified lines | ||
| 8182 | 8192 | SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC), |
| 8183 | 8193 | SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC), |
| 8184 | 8194 | SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), |
| 8195 | + SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC), | |
| 8185 | 8196 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 8186 | 8197 | SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS), |
| 8187 | 8198 | SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X), |
| @@ -8303,12 +8314,15 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 115 unmodified lines | ||
| 8303 | 8314 | SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE), |
| 8304 | 8315 | SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE), |
| 8305 | 8316 | SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3), |
| 8317 | + SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3), | |
| 8306 | 8318 | SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3), |
| 8307 | 8319 | SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN), |
| 8308 | 8320 | SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3), |
| 8309 | 8321 | SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360), |
| 8310 | 8322 | SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED), |
| 8311 | 8323 | SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO), |
| 8324 | + SND_PCI_QUIRK(0x103c, 0x8716, "HP Elite Dragonfly G2 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), | |
| 8325 | + SND_PCI_QUIRK(0x103c, 0x8720, "HP EliteBook x360 1040 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), | |
| 8312 | 8326 | SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED), |
| 8313 | 8327 | SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED), |
| 8314 | 8328 | SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), |
| @@ -8327,10 +8341,12 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 12 unmodified lines | ||
| 8327 | 8341 | SND_PCI_QUIRK(0x103c, 0x87f5, "HP", ALC287_FIXUP_HP_GPIO_LED), |
| 8328 | 8342 | SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP), |
| 8329 | 8343 | SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), |
| 8344 | + SND_PCI_QUIRK(0x103c, 0x884b, "HP EliteBook 840 Aero G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), | |
| 8330 | 8345 | SND_PCI_QUIRK(0x103c, 0x884c, "HP EliteBook 840 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), |
| 8331 | 8346 | SND_PCI_QUIRK(0x103c, 0x886d, "HP ZBook Fury 17.3 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), |
| 8332 | 8347 | SND_PCI_QUIRK(0x103c, 0x8870, "HP ZBook Fury 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), |
| 8333 | 8348 | SND_PCI_QUIRK(0x103c, 0x8873, "HP ZBook Studio 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), |
| 8349 | + SND_PCI_QUIRK(0x103c, 0x888d, "HP ZBook Power 15.6 inch G8 Mobile Workstation PC", ALC236_FIXUP_HP_GPIO_LED), | |
| 8334 | 8350 | SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED), |
| 8335 | 8351 | SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), |
| 8336 | 8352 | SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), |
| @@ -8736,6 +8752,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { · 399 unmodified lines | ||
| 8736 | 8752 | {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"}, |
| 8737 | 8753 | {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"}, |
| 8738 | 8754 | {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"}, |
| 8755 | + {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"}, | |
| 8739 | 8756 | {} |
| 8740 | 8757 | }; |
| 8741 | 8758 | #define ALC225_STANDARD_PINS \ |
| @@ -2433,13 +2433,18 @@ static int set_dmic_power(struct snd_soc_dapm_widget *w, · 2432 unmodified lines | ||
| 2433 | 2433 | return 0; |
| 2434 | 2434 | } |
| 2435 | 2435 | |
| 2436 | −static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { | |
| 2436 | +static const struct snd_soc_dapm_widget rt5659_particular_dapm_widgets[] = { | |
| 2437 | 2437 | SND_SOC_DAPM_SUPPLY("LDO2", RT5659_PWR_ANLG_3, RT5659_PWR_LDO2_BIT, 0, |
| 2438 | 2438 | NULL, 0), |
| 2439 | − SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0, | |
| 2440 | − NULL, 0), | |
| 2439 | + SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT, | |
| 2440 | + 0, NULL, 0), | |
| 2441 | 2441 | SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5659_PWR_VOL, |
| 2442 | 2442 | RT5659_PWR_MIC_DET_BIT, 0, NULL, 0), |
| 2443 | +}; | |
| 2444 | + | |
| 2445 | +static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { | |
| 2446 | + SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0, | |
| 2447 | + NULL, 0), | |
| 2443 | 2448 | SND_SOC_DAPM_SUPPLY("Mono Vref", RT5659_PWR_ANLG_1, |
| 2444 | 2449 | RT5659_PWR_VREF3_BIT, 0, NULL, 0), |
| 2445 | 2450 | |
| @@ -2464,8 +2469,6 @@ static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { · 18 unmodified lines | ||
| 2464 | 2469 | RT5659_ADC_MONO_R_ASRC_SFT, 0, NULL, 0), |
| 2465 | 2470 | |
| 2466 | 2471 | /* Input Side */ |
| 2467 | − SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT, | |
| 2468 | − 0, NULL, 0), | |
| 2469 | 2472 | SND_SOC_DAPM_SUPPLY("MICBIAS2", RT5659_PWR_ANLG_2, RT5659_PWR_MB2_BIT, |
| 2470 | 2473 | 0, NULL, 0), |
| 2471 | 2474 | SND_SOC_DAPM_SUPPLY("MICBIAS3", RT5659_PWR_ANLG_2, RT5659_PWR_MB3_BIT, |
| @@ -3660,10 +3663,23 @@ static int rt5659_set_bias_level(struct snd_soc_component *component, · 1188 unmodified lines | ||
| 3660 | 3663 | |
| 3661 | 3664 | static int rt5659_probe(struct snd_soc_component *component) |
| 3662 | 3665 | { |
| 3666 | + struct snd_soc_dapm_context *dapm = | |
| 3667 | + snd_soc_component_get_dapm(component); | |
| 3663 | 3668 | struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); |
| 3664 | 3669 | |
| 3665 | 3670 | rt5659->component = component; |
| 3666 | 3671 | |
| 3672 | + switch (rt5659->pdata.jd_src) { | |
| 3673 | + case RT5659_JD_HDA_HEADER: | |
| 3674 | + break; | |
| 3675 | + | |
| 3676 | + default: | |
| 3677 | + snd_soc_dapm_new_controls(dapm, | |
| 3678 | + rt5659_particular_dapm_widgets, | |
| 3679 | + ARRAY_SIZE(rt5659_particular_dapm_widgets)); | |
| 3680 | + break; | |
| 3681 | + } | |
| 3682 | + | |
| 3667 | 3683 | return 0; |
| 3668 | 3684 | } |
| 3669 | 3685 | |
| @@ -462,7 +462,8 @@ static int rt5682_io_init(struct device *dev, struct sdw_slave *slave) · 461 unmodified lines | ||
| 462 | 462 | |
| 463 | 463 | regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_2, |
| 464 | 464 | RT5682_EXT_JD_SRC, RT5682_EXT_JD_SRC_MANUAL); |
| 465 | − regmap_write(rt5682->regmap, RT5682_CBJ_CTRL_1, 0xd042); | |
| 465 | + regmap_write(rt5682->regmap, RT5682_CBJ_CTRL_1, 0xd142); | |
| 466 | + regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_5, 0x0700, 0x0600); | |
| 466 | 467 | regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_3, |
| 467 | 468 | RT5682_CBJ_IN_BUF_EN, RT5682_CBJ_IN_BUF_EN); |
| 468 | 469 | regmap_update_bits(rt5682->regmap, RT5682_SAR_IL_CMD_1, |
| @@ -57,13 +57,13 @@ · 56 unmodified lines | ||
| 57 | 57 | #define TAS2562_TDM_CFG0_RAMPRATE_MASK BIT(5) |
| 58 | 58 | #define TAS2562_TDM_CFG0_RAMPRATE_44_1 BIT(5) |
| 59 | 59 | #define TAS2562_TDM_CFG0_SAMPRATE_MASK GENMASK(3, 1) |
| 60 | −#define TAS2562_TDM_CFG0_SAMPRATE_7305_8KHZ 0x0 | |
| 61 | −#define TAS2562_TDM_CFG0_SAMPRATE_14_7_16KHZ 0x1 | |
| 62 | −#define TAS2562_TDM_CFG0_SAMPRATE_22_05_24KHZ 0x2 | |
| 63 | −#define TAS2562_TDM_CFG0_SAMPRATE_29_4_32KHZ 0x3 | |
| 64 | −#define TAS2562_TDM_CFG0_SAMPRATE_44_1_48KHZ 0x4 | |
| 65 | −#define TAS2562_TDM_CFG0_SAMPRATE_88_2_96KHZ 0x5 | |
| 66 | −#define TAS2562_TDM_CFG0_SAMPRATE_176_4_192KHZ 0x6 | |
| 60 | +#define TAS2562_TDM_CFG0_SAMPRATE_7305_8KHZ (0x0 << 1) | |
| 61 | +#define TAS2562_TDM_CFG0_SAMPRATE_14_7_16KHZ (0x1 << 1) | |
| 62 | +#define TAS2562_TDM_CFG0_SAMPRATE_22_05_24KHZ (0x2 << 1) | |
| 63 | +#define TAS2562_TDM_CFG0_SAMPRATE_29_4_32KHZ (0x3 << 1) | |
| 64 | +#define TAS2562_TDM_CFG0_SAMPRATE_44_1_48KHZ (0x4 << 1) | |
| 65 | +#define TAS2562_TDM_CFG0_SAMPRATE_88_2_96KHZ (0x5 << 1) | |
| 66 | +#define TAS2562_TDM_CFG0_SAMPRATE_176_4_192KHZ (0x6 << 1) | |
| 67 | 67 | |
| 68 | 68 | #define TAS2562_TDM_CFG2_RIGHT_JUSTIFY BIT(6) |
| 69 | 69 | |
| @@ -744,6 +744,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) · 743 unmodified lines | ||
| 744 | 744 | /* Initialize sound card */ |
| 745 | 745 | priv->pdev = pdev; |
| 746 | 746 | priv->card.dev = &pdev->dev; |
| 747 | + priv->card.owner = THIS_MODULE; | |
| 747 | 748 | ret = snd_soc_of_parse_card_name(&priv->card, "model"); |
| 748 | 749 | if (ret) { |
| 749 | 750 | snprintf(priv->name, sizeof(priv->name), "%s-audio", |
| @@ -93,8 +93,30 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream, · 92 unmodified lines | ||
| 93 | 93 | struct snd_soc_dai *dai) |
| 94 | 94 | { |
| 95 | 95 | struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); |
| 96 | + struct lpaif_i2sctl *i2sctl = drvdata->i2sctl; | |
| 97 | + unsigned int id = dai->driver->id; | |
| 96 | 98 | |
| 97 | 99 | clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]); |
| 100 | + /* | |
| 101 | + * Ensure LRCLK is disabled even in device node validation. | |
| 102 | + * Will not impact if disabled in lpass_cpu_daiops_trigger() | |
| 103 | + * suspend. | |
| 104 | + */ | |
| 105 | + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | |
| 106 | + regmap_fields_write(i2sctl->spken, id, LPAIF_I2SCTL_SPKEN_DISABLE); | |
| 107 | + else | |
| 108 | + regmap_fields_write(i2sctl->micen, id, LPAIF_I2SCTL_MICEN_DISABLE); | |
| 109 | + | |
| 110 | + /* | |
| 111 | + * BCLK may not be enabled if lpass_cpu_daiops_prepare is called before | |
| 112 | + * lpass_cpu_daiops_shutdown. It's paired with the clk_enable in | |
| 113 | + * lpass_cpu_daiops_prepare. | |
| 114 | + */ | |
| 115 | + if (drvdata->mi2s_was_prepared[dai->driver->id]) { | |
| 116 | + drvdata->mi2s_was_prepared[dai->driver->id] = false; | |
| 117 | + clk_disable(drvdata->mi2s_bit_clk[dai->driver->id]); | |
| 118 | + } | |
| 119 | + | |
| 98 | 120 | clk_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]); |
| 99 | 121 | } |
| 100 | 122 | |
| @@ -275,6 +297,18 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, · 174 unmodified lines | ||
| 275 | 297 | case SNDRV_PCM_TRIGGER_START: |
| 276 | 298 | case SNDRV_PCM_TRIGGER_RESUME: |
| 277 | 299 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 300 | + /* | |
| 301 | + * Ensure lpass BCLK/LRCLK is enabled during | |
| 302 | + * device resume as lpass_cpu_daiops_prepare() is not called | |
| 303 | + * after the device resumes. We don't check mi2s_was_prepared before | |
| 304 | + * enable/disable BCLK in trigger events because: | |
| 305 | + * 1. These trigger events are paired, so the BCLK | |
| 306 | + * enable_count is balanced. | |
| 307 | + * 2. the BCLK can be shared (ex: headset and headset mic), | |
| 308 | + * we need to increase the enable_count so that we don't | |
| 309 | + * turn off the shared BCLK while other devices are using | |
| 310 | + * it. | |
| 311 | + */ | |
| 278 | 312 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 279 | 313 | ret = regmap_fields_write(i2sctl->spken, id, |
| 280 | 314 | LPAIF_I2SCTL_SPKEN_ENABLE); |
| @@ -296,6 +330,10 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, · 15 unmodified lines | ||
| 296 | 330 | case SNDRV_PCM_TRIGGER_STOP: |
| 297 | 331 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 298 | 332 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
| 333 | + /* | |
| 334 | + * To ensure lpass BCLK/LRCLK is disabled during | |
| 335 | + * device suspend. | |
| 336 | + */ | |
| 299 | 337 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 300 | 338 | ret = regmap_fields_write(i2sctl->spken, id, |
| 301 | 339 | LPAIF_I2SCTL_SPKEN_DISABLE); |
| @@ -315,12 +353,53 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, · 13 unmodified lines | ||
| 315 | 353 | return ret; |
| 316 | 354 | } |
| 317 | 355 | |
| 356 | +static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream, | |
| 357 | + struct snd_soc_dai *dai) | |
| 358 | +{ | |
| 359 | + struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); | |
| 360 | + struct lpaif_i2sctl *i2sctl = drvdata->i2sctl; | |
| 361 | + unsigned int id = dai->driver->id; | |
| 362 | + int ret; | |
| 363 | + | |
| 364 | + /* | |
| 365 | + * Ensure lpass BCLK/LRCLK is enabled bit before playback/capture | |
| 366 | + * data flow starts. This allows other codec to have some delay before | |
| 367 | + * the data flow. | |
| 368 | + * (ex: to drop start up pop noise before capture starts). | |
| 369 | + */ | |
| 370 | + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | |
| 371 | + ret = regmap_fields_write(i2sctl->spken, id, LPAIF_I2SCTL_SPKEN_ENABLE); | |
| 372 | + else | |
| 373 | + ret = regmap_fields_write(i2sctl->micen, id, LPAIF_I2SCTL_MICEN_ENABLE); | |
| 374 | + | |
| 375 | + if (ret) { | |
| 376 | + dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret); | |
| 377 | + return ret; | |
| 378 | + } | |
| 379 | + | |
| 380 | + /* | |
| 381 | + * Check mi2s_was_prepared before enabling BCLK as lpass_cpu_daiops_prepare can | |
| 382 | + * be called multiple times. It's paired with the clk_disable in | |
| 383 | + * lpass_cpu_daiops_shutdown. | |
| 384 | + */ | |
| 385 | + if (!drvdata->mi2s_was_prepared[dai->driver->id]) { | |
| 386 | + ret = clk_enable(drvdata->mi2s_bit_clk[id]); | |
| 387 | + if (ret) { | |
| 388 | + dev_err(dai->dev, "error in enabling mi2s bit clk: %d\n", ret); | |
| 389 | + return ret; | |
| 390 | + } | |
| 391 | + drvdata->mi2s_was_prepared[dai->driver->id] = true; | |
| 392 | + } | |
| 393 | + return 0; | |
| 394 | +} | |
| 395 | + | |
| 318 | 396 | const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = { |
| 319 | 397 | .set_sysclk = lpass_cpu_daiops_set_sysclk, |
| 320 | 398 | .startup = lpass_cpu_daiops_startup, |
| 321 | 399 | .shutdown = lpass_cpu_daiops_shutdown, |
| 322 | 400 | .hw_params = lpass_cpu_daiops_hw_params, |
| 323 | 401 | .trigger = lpass_cpu_daiops_trigger, |
| 402 | + .prepare = lpass_cpu_daiops_prepare, | |
| 324 | 403 | }; |
| 325 | 404 | EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_ops); |
| 326 | 405 | |
| @@ -67,6 +67,10 @@ struct lpass_data { · 66 unmodified lines | ||
| 67 | 67 | /* MI2S SD lines to use for playback/capture */ |
| 68 | 68 | unsigned int mi2s_playback_sd_mode[LPASS_MAX_MI2S_PORTS]; |
| 69 | 69 | unsigned int mi2s_capture_sd_mode[LPASS_MAX_MI2S_PORTS]; |
| 70 | + | |
| 71 | + /* The state of MI2S prepare dai_ops was called */ | |
| 72 | + bool mi2s_was_prepared[LPASS_MAX_MI2S_PORTS]; | |
| 73 | + | |
| 70 | 74 | int hdmi_port_enable; |
| 71 | 75 | |
| 72 | 76 | /* low-power audio interface (LPAIF) registers */ |
| @@ -2225,6 +2225,8 @@ static char *fmt_single_name(struct device *dev, int *id) · 2224 unmodified lines | ||
| 2225 | 2225 | return NULL; |
| 2226 | 2226 | |
| 2227 | 2227 | name = devm_kstrdup(dev, devname, GFP_KERNEL); |
| 2228 | + if (!name) | |
| 2229 | + return NULL; | |
| 2228 | 2230 | |
| 2229 | 2231 | /* are we a "%s.%d" name (platform and SPI components) */ |
| 2230 | 2232 | found = strstr(name, dev->driver->name); |
| @@ -1901,7 +1901,7 @@ static void stream_caps_new_ver(struct snd_soc_tplg_stream_caps *dest, · 1900 unmodified lines | ||
| 1901 | 1901 | * @src: older version of pcm as a source |
| 1902 | 1902 | * @pcm: latest version of pcm created from the source |
| 1903 | 1903 | * |
| 1904 | − * Support from vesion 4. User should free the returned pcm manually. | |
| 1904 | + * Support from version 4. User should free the returned pcm manually. | |
| 1905 | 1905 | */ |
| 1906 | 1906 | static int pcm_new_ver(struct soc_tplg *tplg, |
| 1907 | 1907 | struct snd_soc_tplg_pcm *src, |
| @@ -2089,7 +2089,7 @@ static void set_link_hw_format(struct snd_soc_dai_link *link, · 181 unmodified lines | ||
| 2089 | 2089 | * @src: old version of phyical link config as a source |
| 2090 | 2090 | * @link: latest version of physical link config created from the source |
| 2091 | 2091 | * |
| 2092 | − * Support from vesion 4. User need free the returned link config manually. | |
| 2092 | + * Support from version 4. User need free the returned link config manually. | |
| 2093 | 2093 | */ |
| 2094 | 2094 | static int link_new_ver(struct soc_tplg *tplg, |
| 2095 | 2095 | struct snd_soc_tplg_link_config *src, |
| @@ -2400,7 +2400,7 @@ static int soc_tplg_dai_elems_load(struct soc_tplg *tplg, · 304 unmodified lines | ||
| 2400 | 2400 | * @src: old version of manifest as a source |
| 2401 | 2401 | * @manifest: latest version of manifest created from the source |
| 2402 | 2402 | * |
| 2403 | − * Support from vesion 4. Users need free the returned manifest manually. | |
| 2403 | + * Support from version 4. Users need free the returned manifest manually. | |
| 2404 | 2404 | */ |
| 2405 | 2405 | static int manifest_new_ver(struct soc_tplg *tplg, |
| 2406 | 2406 | struct snd_soc_tplg_manifest *src, |
| @@ -256,6 +256,7 @@ suspend: · 255 unmodified lines | ||
| 256 | 256 | |
| 257 | 257 | /* reset FW state */ |
| 258 | 258 | sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; |
| 259 | + sdev->enabled_cores_mask = 0; | |
| 259 | 260 | |
| 260 | 261 | return ret; |
| 261 | 262 | } |
| @@ -0,0 +1,40 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
| 2 | +#ifndef _ASM_MIPS_PERF_REGS_H | |
| 3 | +#define _ASM_MIPS_PERF_REGS_H | |
| 4 | + | |
| 5 | +enum perf_event_mips_regs { | |
| 6 | + PERF_REG_MIPS_PC, | |
| 7 | + PERF_REG_MIPS_R1, | |
| 8 | + PERF_REG_MIPS_R2, | |
| 9 | + PERF_REG_MIPS_R3, | |
| 10 | + PERF_REG_MIPS_R4, | |
| 11 | + PERF_REG_MIPS_R5, | |
| 12 | + PERF_REG_MIPS_R6, | |
| 13 | + PERF_REG_MIPS_R7, | |
| 14 | + PERF_REG_MIPS_R8, | |
| 15 | + PERF_REG_MIPS_R9, | |
| 16 | + PERF_REG_MIPS_R10, | |
| 17 | + PERF_REG_MIPS_R11, | |
| 18 | + PERF_REG_MIPS_R12, | |
| 19 | + PERF_REG_MIPS_R13, | |
| 20 | + PERF_REG_MIPS_R14, | |
| 21 | + PERF_REG_MIPS_R15, | |
| 22 | + PERF_REG_MIPS_R16, | |
| 23 | + PERF_REG_MIPS_R17, | |
| 24 | + PERF_REG_MIPS_R18, | |
| 25 | + PERF_REG_MIPS_R19, | |
| 26 | + PERF_REG_MIPS_R20, | |
| 27 | + PERF_REG_MIPS_R21, | |
| 28 | + PERF_REG_MIPS_R22, | |
| 29 | + PERF_REG_MIPS_R23, | |
| 30 | + PERF_REG_MIPS_R24, | |
| 31 | + PERF_REG_MIPS_R25, | |
| 32 | + PERF_REG_MIPS_R26, | |
| 33 | + PERF_REG_MIPS_R27, | |
| 34 | + PERF_REG_MIPS_R28, | |
| 35 | + PERF_REG_MIPS_R29, | |
| 36 | + PERF_REG_MIPS_R30, | |
| 37 | + PERF_REG_MIPS_R31, | |
| 38 | + PERF_REG_MIPS_MAX = PERF_REG_MIPS_R31 + 1, | |
| 39 | +}; | |
| 40 | +#endif /* _ASM_MIPS_PERF_REGS_H */ | |
| @@ -56,11 +56,8 @@ · 55 unmodified lines | ||
| 56 | 56 | # define DISABLE_PTI (1 << (X86_FEATURE_PTI & 31)) |
| 57 | 57 | #endif |
| 58 | 58 | |
| 59 | −#ifdef CONFIG_IOMMU_SUPPORT | |
| 60 | −# define DISABLE_ENQCMD 0 | |
| 61 | −#else | |
| 62 | −# define DISABLE_ENQCMD (1 << (X86_FEATURE_ENQCMD & 31)) | |
| 63 | −#endif | |
| 59 | +/* Force disable because it's broken beyond repair */ | |
| 60 | +#define DISABLE_ENQCMD (1 << (X86_FEATURE_ENQCMD & 31)) | |
| 64 | 61 | |
| 65 | 62 | #ifdef CONFIG_X86_SGX |
| 66 | 63 | # define DISABLE_SGX 0 |
| @@ -4,4 +4,8 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | #include "../../../../include/linux/bootconfig.h" |
| 6 | 6 | |
| 7 | +#ifndef fallthrough | |
| 8 | +# define fallthrough | |
| 9 | +#endif | |
| 10 | + | |
| 7 | 11 | #endif |
| @@ -399,6 +399,7 @@ static int apply_xbc(const char *path, const char *xbc_path) · 398 unmodified lines | ||
| 399 | 399 | } |
| 400 | 400 | /* TODO: Ensure the @path is initramfs/initrd image */ |
| 401 | 401 | if (fstat(fd, &stat) < 0) { |
| 402 | + ret = -errno; | |
| 402 | 403 | pr_err("Failed to get the size of %s\n", path); |
| 403 | 404 | goto out; |
| 404 | 405 | } |
| @@ -747,6 +747,10 @@ int arch_rewrite_retpolines(struct objtool_file *file) · 746 unmodified lines | ||
| 747 | 747 | |
| 748 | 748 | list_for_each_entry(insn, &file->retpoline_call_list, call_node) { |
| 749 | 749 | |
| 750 | + if (insn->type != INSN_JUMP_DYNAMIC && | |
| 751 | + insn->type != INSN_CALL_DYNAMIC) | |
| 752 | + continue; | |
| 753 | + | |
| 750 | 754 | if (!strcmp(insn->sec->name, ".text.__x86.indirect_thunk")) |
| 751 | 755 | continue; |
| 752 | 756 | |
| @@ -717,7 +717,7 @@ static int elf_add_string(struct elf *elf, struct section *strtab, char *str) · 716 unmodified lines | ||
| 717 | 717 | |
| 718 | 718 | struct symbol *elf_create_undef_symbol(struct elf *elf, const char *name) |
| 719 | 719 | { |
| 720 | − struct section *symtab; | |
| 720 | + struct section *symtab, *symtab_shndx; | |
| 721 | 721 | struct symbol *sym; |
| 722 | 722 | Elf_Data *data; |
| 723 | 723 | Elf_Scn *s; |
| @@ -769,6 +769,29 @@ struct symbol *elf_create_undef_symbol(struct elf *elf, const char *name) · 45 unmodified lines | ||
| 769 | 769 | symtab->len += data->d_size; |
| 770 | 770 | symtab->changed = true; |
| 771 | 771 | |
| 772 | + symtab_shndx = find_section_by_name(elf, ".symtab_shndx"); | |
| 773 | + if (symtab_shndx) { | |
| 774 | + s = elf_getscn(elf->elf, symtab_shndx->idx); | |
| 775 | + if (!s) { | |
| 776 | + WARN_ELF("elf_getscn"); | |
| 777 | + return NULL; | |
| 778 | + } | |
| 779 | + | |
| 780 | + data = elf_newdata(s); | |
| 781 | + if (!data) { | |
| 782 | + WARN_ELF("elf_newdata"); | |
| 783 | + return NULL; | |
| 784 | + } | |
| 785 | + | |
| 786 | + data->d_buf = &sym->sym.st_size; /* conveniently 0 */ | |
| 787 | + data->d_size = sizeof(Elf32_Word); | |
| 788 | + data->d_align = 4; | |
| 789 | + data->d_type = ELF_T_WORD; | |
| 790 | + | |
| 791 | + symtab_shndx->len += 4; | |
| 792 | + symtab_shndx->changed = true; | |
| 793 | + } | |
| 794 | + | |
| 772 | 795 | sym->sec = find_section_by_index(elf, 0); |
| 773 | 796 | |
| 774 | 797 | elf_add_symbol(elf, sym); |
| @@ -90,7 +90,6 @@ endif · 89 unmodified lines | ||
| 90 | 90 | ifeq ($(ARCH),mips) |
| 91 | 91 | NO_PERF_REGS := 0 |
| 92 | 92 | CFLAGS += -I$(OUTPUT)arch/mips/include/generated |
| 93 | − CFLAGS += -I../../arch/mips/include/uapi -I../../arch/mips/include/generated/uapi | |
| 94 | 93 | LIBUNWIND_LIBS = -lunwind -lunwind-mips |
| 95 | 94 | endif |
| 96 | 95 | |
| @@ -2714,6 +2714,12 @@ int cmd_record(int argc, const char **argv) · 2713 unmodified lines | ||
| 2714 | 2714 | rec->no_buildid = true; |
| 2715 | 2715 | } |
| 2716 | 2716 | |
| 2717 | + if (rec->opts.record_cgroup && !perf_can_record_cgroup()) { | |
| 2718 | + pr_err("Kernel has no cgroup sampling support.\n"); | |
| 2719 | + err = -EINVAL; | |
| 2720 | + goto out_opts; | |
| 2721 | + } | |
| 2722 | + | |
| 2717 | 2723 | if (rec->opts.kcore) |
| 2718 | 2724 | rec->data.is_dir = true; |
| 2719 | 2725 | |
| @@ -39,6 +39,7 @@ arch/x86/lib/x86-opcode-map.txt · 38 unmodified lines | ||
| 39 | 39 | arch/x86/tools/gen-insn-attr-x86.awk |
| 40 | 40 | arch/arm/include/uapi/asm/perf_regs.h |
| 41 | 41 | arch/arm64/include/uapi/asm/perf_regs.h |
| 42 | +arch/mips/include/uapi/asm/perf_regs.h | |
| 42 | 43 | arch/powerpc/include/uapi/asm/perf_regs.h |
| 43 | 44 | arch/s390/include/uapi/asm/perf_regs.h |
| 44 | 45 | arch/x86/include/uapi/asm/perf_regs.h |
| @@ -16,7 +16,7 @@ pinned=0 · 15 unmodified lines | ||
| 16 | 16 | exclusive=0 |
| 17 | 17 | exclude_user=0 |
| 18 | 18 | exclude_kernel=0|1 |
| 19 | −exclude_hv=0 | |
| 19 | +exclude_hv=0|1 | |
| 20 | 20 | exclude_idle=0 |
| 21 | 21 | mmap=1 |
| 22 | 22 | comm=1 |
| @@ -521,9 +521,10 @@ static int bperf__load(struct evsel *evsel, struct target *target) · 520 unmodified lines | ||
| 521 | 521 | |
| 522 | 522 | evsel->bperf_leader_link_fd = bpf_link_get_fd_by_id(entry.link_id); |
| 523 | 523 | if (evsel->bperf_leader_link_fd < 0 && |
| 524 | − bperf_reload_leader_program(evsel, attr_map_fd, &entry)) | |
| 524 | + bperf_reload_leader_program(evsel, attr_map_fd, &entry)) { | |
| 525 | + err = -1; | |
| 525 | 526 | goto out; |
| 526 | − | |
| 527 | + } | |
| 527 | 528 | /* |
| 528 | 529 | * The bpf_link holds reference to the leader program, and the |
| 529 | 530 | * leader program holds reference to the maps. Therefore, if |
| @@ -550,6 +551,7 @@ static int bperf__load(struct evsel *evsel, struct target *target) · 20 unmodified lines | ||
| 550 | 551 | /* Step 2: load the follower skeleton */ |
| 551 | 552 | evsel->follower_skel = bperf_follower_bpf__open(); |
| 552 | 553 | if (!evsel->follower_skel) { |
| 554 | + err = -1; | |
| 553 | 555 | pr_err("Failed to open follower skeleton\n"); |
| 554 | 556 | goto out; |
| 555 | 557 | } |
| @@ -975,9 +975,13 @@ static int __die_find_variable_cb(Dwarf_Die *die_mem, void *data) · 974 unmodified lines | ||
| 975 | 975 | if ((tag == DW_TAG_formal_parameter || |
| 976 | 976 | tag == DW_TAG_variable) && |
| 977 | 977 | die_compare_name(die_mem, fvp->name) && |
| 978 | − /* Does the DIE have location information or external instance? */ | |
| 978 | + /* | |
| 979 | + * Does the DIE have location information or const value | |
| 980 | + * or external instance? | |
| 981 | + */ | |
| 979 | 982 | (dwarf_attr(die_mem, DW_AT_external, &attr) || |
| 980 | − dwarf_attr(die_mem, DW_AT_location, &attr))) | |
| 983 | + dwarf_attr(die_mem, DW_AT_location, &attr) || | |
| 984 | + dwarf_attr(die_mem, DW_AT_const_value, &attr))) | |
| 981 | 985 | return DIE_FIND_CB_END; |
| 982 | 986 | if (dwarf_haspc(die_mem, fvp->addr)) |
| 983 | 987 | return DIE_FIND_CB_CONTINUE; |
| @@ -144,6 +144,7 @@ static void perf_env__purge_bpf(struct perf_env *env) · 143 unmodified lines | ||
| 144 | 144 | node = rb_entry(next, struct bpf_prog_info_node, rb_node); |
| 145 | 145 | next = rb_next(&node->rb_node); |
| 146 | 146 | rb_erase(&node->rb_node, root); |
| 147 | + free(node->info_linear); | |
| 147 | 148 | free(node); |
| 148 | 149 | } |
| 149 | 150 | |
| @@ -428,6 +428,7 @@ struct evsel *evsel__clone(struct evsel *orig) · 427 unmodified lines | ||
| 428 | 428 | evsel->auto_merge_stats = orig->auto_merge_stats; |
| 429 | 429 | evsel->collect_stat = orig->collect_stat; |
| 430 | 430 | evsel->weak_group = orig->weak_group; |
| 431 | + evsel->use_config_name = orig->use_config_name; | |
| 431 | 432 | |
| 432 | 433 | if (evsel__copy_config_terms(evsel, orig) < 0) |
| 433 | 434 | goto out_err; |
| @@ -83,8 +83,10 @@ struct evsel { · 82 unmodified lines | ||
| 83 | 83 | bool collect_stat; |
| 84 | 84 | bool weak_group; |
| 85 | 85 | bool bpf_counter; |
| 86 | + bool use_config_name; | |
| 86 | 87 | int bpf_fd; |
| 87 | 88 | struct bpf_object *bpf_obj; |
| 89 | + struct list_head config_terms; | |
| 88 | 90 | }; |
| 89 | 91 | |
| 90 | 92 | /* |
| @@ -116,10 +118,8 @@ struct evsel { · 25 unmodified lines | ||
| 116 | 118 | bool merged_stat; |
| 117 | 119 | bool reset_group; |
| 118 | 120 | bool errored; |
| 119 | − bool use_config_name; | |
| 120 | 121 | struct hashmap *per_pkg_mask; |
| 121 | 122 | struct evsel *leader; |
| 122 | − struct list_head config_terms; | |
| 123 | 123 | int err; |
| 124 | 124 | int cpu_iter; |
| 125 | 125 | struct { |
| @@ -103,6 +103,11 @@ static void perf_probe_build_id(struct evsel *evsel) · 102 unmodified lines | ||
| 103 | 103 | evsel->core.attr.build_id = 1; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | +static void perf_probe_cgroup(struct evsel *evsel) | |
| 107 | +{ | |
| 108 | + evsel->core.attr.cgroup = 1; | |
| 109 | +} | |
| 110 | + | |
| 106 | 111 | bool perf_can_sample_identifier(void) |
| 107 | 112 | { |
| 108 | 113 | return perf_probe_api(perf_probe_sample_identifier); |
| @@ -182,3 +187,8 @@ bool perf_can_record_build_id(void) · 73 unmodified lines | ||
| 182 | 187 | { |
| 183 | 188 | return perf_probe_api(perf_probe_build_id); |
| 184 | 189 | } |
| 190 | + | |
| 191 | +bool perf_can_record_cgroup(void) | |
| 192 | +{ | |
| 193 | + return perf_probe_api(perf_probe_cgroup); | |
| 194 | +} | |
| @@ -12,5 +12,6 @@ bool perf_can_record_switch_events(void); · 11 unmodified lines | ||
| 12 | 12 | bool perf_can_record_text_poke_events(void); |
| 13 | 13 | bool perf_can_sample_identifier(void); |
| 14 | 14 | bool perf_can_record_build_id(void); |
| 15 | +bool perf_can_record_cgroup(void); | |
| 15 | 16 | |
| 16 | 17 | #endif // __PERF_API_PROBE_H |
| @@ -190,6 +190,9 @@ static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr, · 189 unmodified lines | ||
| 190 | 190 | immediate_value_is_supported()) { |
| 191 | 191 | Dwarf_Sword snum; |
| 192 | 192 | |
| 193 | + if (!tvar) | |
| 194 | + return 0; | |
| 195 | + | |
| 193 | 196 | dwarf_formsdata(&attr, &snum); |
| 194 | 197 | ret = asprintf(&tvar->value, "\\%ld", (long)snum); |
| 195 | 198 | |
| @@ -1723,6 +1723,7 @@ int perf_session__peek_event(struct perf_session *session, off_t file_offset, · 1722 unmodified lines | ||
| 1723 | 1723 | if (event->header.size < hdr_sz || event->header.size > buf_sz) |
| 1724 | 1724 | return -1; |
| 1725 | 1725 | |
| 1726 | + buf += hdr_sz; | |
| 1726 | 1727 | rest = event->header.size - hdr_sz; |
| 1727 | 1728 | |
| 1728 | 1729 | if (readn(fd, buf, rest) != (ssize_t)rest) |
| @@ -541,7 +541,7 @@ static void uniquify_event_name(struct evsel *counter) · 540 unmodified lines | ||
| 541 | 541 | char *config; |
| 542 | 542 | int ret = 0; |
| 543 | 543 | |
| 544 | − if (counter->uniquified_name || | |
| 544 | + if (counter->uniquified_name || counter->use_config_name || | |
| 545 | 545 | !counter->pmu_name || !strncmp(counter->name, counter->pmu_name, |
| 546 | 546 | strlen(counter->pmu_name))) |
| 547 | 547 | return; |
| @@ -555,10 +555,8 @@ static void uniquify_event_name(struct evsel *counter) · 7 unmodified lines | ||
| 555 | 555 | } |
| 556 | 556 | } else { |
| 557 | 557 | if (perf_pmu__has_hybrid()) { |
| 558 | − if (!counter->use_config_name) { | |
| 559 | − ret = asprintf(&new_name, "%s/%s/", | |
| 560 | − counter->pmu_name, counter->name); | |
| 561 | − } | |
| 558 | + ret = asprintf(&new_name, "%s/%s/", | |
| 559 | + counter->pmu_name, counter->name); | |
| 562 | 560 | } else { |
| 563 | 561 | ret = asprintf(&new_name, "%s [%s]", |
| 564 | 562 | counter->name, counter->pmu_name); |
| @@ -2412,6 +2412,7 @@ int cleanup_sdt_note_list(struct list_head *sdt_notes) · 2411 unmodified lines | ||
| 2412 | 2412 | |
| 2413 | 2413 | list_for_each_entry_safe(pos, tmp, sdt_notes, note_list) { |
| 2414 | 2414 | list_del_init(&pos->note_list); |
| 2415 | + zfree(&pos->args); | |
| 2415 | 2416 | zfree(&pos->name); |
| 2416 | 2417 | zfree(&pos->provider); |
| 2417 | 2418 | free(pos); |
| @@ -43,6 +43,7 @@ enum vm_guest_mode { · 42 unmodified lines | ||
| 43 | 43 | VM_MODE_P40V48_4K, |
| 44 | 44 | VM_MODE_P40V48_64K, |
| 45 | 45 | VM_MODE_PXXV48_4K, /* For 48bits VA but ANY bits PA */ |
| 46 | + VM_MODE_P47V64_4K, | |
| 46 | 47 | NUM_VM_MODES, |
| 47 | 48 | }; |
| 48 | 49 | |
| @@ -60,7 +61,7 @@ enum vm_guest_mode { · 11 unmodified lines | ||
| 60 | 61 | |
| 61 | 62 | #elif defined(__s390x__) |
| 62 | 63 | |
| 63 | −#define VM_MODE_DEFAULT VM_MODE_P52V48_4K | |
| 64 | +#define VM_MODE_DEFAULT VM_MODE_P47V64_4K | |
| 64 | 65 | #define MIN_PAGE_SHIFT 12U |
| 65 | 66 | #define ptes_per_page(page_size) ((page_size) / 16) |
| 66 | 67 | |
| @@ -285,10 +286,11 @@ struct kvm_vm *vm_create_default_with_vcpus(uint32_t nr_vcpus, uint64_t extra_me · 218 unmodified lines | ||
| 285 | 286 | uint32_t num_percpu_pages, void *guest_code, |
| 286 | 287 | uint32_t vcpuids[]); |
| 287 | 288 | |
| 288 | −/* Like vm_create_default_with_vcpus, but accepts mode as a parameter */ | |
| 289 | +/* Like vm_create_default_with_vcpus, but accepts mode and slot0 memory as a parameter */ | |
| 289 | 290 | struct kvm_vm *vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus, |
| 290 | − uint64_t extra_mem_pages, uint32_t num_percpu_pages, | |
| 291 | − void *guest_code, uint32_t vcpuids[]); | |
| 291 | + uint64_t slot0_mem_pages, uint64_t extra_mem_pages, | |
| 292 | + uint32_t num_percpu_pages, void *guest_code, | |
| 293 | + uint32_t vcpuids[]); | |
| 292 | 294 | |
| 293 | 295 | /* |
| 294 | 296 | * Adds a vCPU with reasonable defaults (e.g. a stack) |
| @@ -268,7 +268,7 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg) · 267 unmodified lines | ||
| 268 | 268 | |
| 269 | 269 | /* Create a VM with enough guest pages */ |
| 270 | 270 | guest_num_pages = test_mem_size / guest_page_size; |
| 271 | − vm = vm_create_with_vcpus(mode, nr_vcpus, | |
| 271 | + vm = vm_create_with_vcpus(mode, nr_vcpus, DEFAULT_GUEST_PHY_PAGES, | |
| 272 | 272 | guest_num_pages, 0, guest_code, NULL); |
| 273 | 273 | |
| 274 | 274 | /* Align down GPA of the testing memslot */ |
| @@ -175,6 +175,7 @@ const char *vm_guest_mode_string(uint32_t i) · 174 unmodified lines | ||
| 175 | 175 | [VM_MODE_P40V48_4K] = "PA-bits:40, VA-bits:48, 4K pages", |
| 176 | 176 | [VM_MODE_P40V48_64K] = "PA-bits:40, VA-bits:48, 64K pages", |
| 177 | 177 | [VM_MODE_PXXV48_4K] = "PA-bits:ANY, VA-bits:48, 4K pages", |
| 178 | + [VM_MODE_P47V64_4K] = "PA-bits:47, VA-bits:64, 4K pages", | |
| 178 | 179 | }; |
| 179 | 180 | _Static_assert(sizeof(strings)/sizeof(char *) == NUM_VM_MODES, |
| 180 | 181 | "Missing new mode strings?"); |
| @@ -192,6 +193,7 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = { · 11 unmodified lines | ||
| 192 | 193 | { 40, 48, 0x1000, 12 }, |
| 193 | 194 | { 40, 48, 0x10000, 16 }, |
| 194 | 195 | { 0, 0, 0x1000, 12 }, |
| 196 | + { 47, 64, 0x1000, 12 }, | |
| 195 | 197 | }; |
| 196 | 198 | _Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params) == NUM_VM_MODES, |
| 197 | 199 | "Missing new mode params?"); |
| @@ -277,6 +279,9 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm) · 79 unmodified lines | ||
| 277 | 279 | TEST_FAIL("VM_MODE_PXXV48_4K not supported on non-x86 platforms"); |
| 278 | 280 | #endif |
| 279 | 281 | break; |
| 282 | + case VM_MODE_P47V64_4K: | |
| 283 | + vm->pgtable_levels = 5; | |
| 284 | + break; | |
| 280 | 285 | default: |
| 281 | 286 | TEST_FAIL("Unknown guest mode, mode: 0x%x", mode); |
| 282 | 287 | } |
| @@ -308,21 +313,50 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm) · 25 unmodified lines | ||
| 308 | 313 | return vm; |
| 309 | 314 | } |
| 310 | 315 | |
| 316 | +/* | |
| 317 | + * VM Create with customized parameters | |
| 318 | + * | |
| 319 | + * Input Args: | |
| 320 | + * mode - VM Mode (e.g. VM_MODE_P52V48_4K) | |
| 321 | + * nr_vcpus - VCPU count | |
| 322 | + * slot0_mem_pages - Slot0 physical memory size | |
| 323 | + * extra_mem_pages - Non-slot0 physical memory total size | |
| 324 | + * num_percpu_pages - Per-cpu physical memory pages | |
| 325 | + * guest_code - Guest entry point | |
| 326 | + * vcpuids - VCPU IDs | |
| 327 | + * | |
| 328 | + * Output Args: None | |
| 329 | + * | |
| 330 | + * Return: | |
| 331 | + * Pointer to opaque structure that describes the created VM. | |
| 332 | + * | |
| 333 | + * Creates a VM with the mode specified by mode (e.g. VM_MODE_P52V48_4K), | |
| 334 | + * with customized slot0 memory size, at least 512 pages currently. | |
| 335 | + * extra_mem_pages is only used to calculate the maximum page table size, | |
| 336 | + * no real memory allocation for non-slot0 memory in this function. | |
| 337 | + */ | |
| 311 | 338 | struct kvm_vm *vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus, |
| 312 | − uint64_t extra_mem_pages, uint32_t num_percpu_pages, | |
| 313 | − void *guest_code, uint32_t vcpuids[]) | |
| 339 | + uint64_t slot0_mem_pages, uint64_t extra_mem_pages, | |
| 340 | + uint32_t num_percpu_pages, void *guest_code, | |
| 341 | + uint32_t vcpuids[]) | |
| 314 | 342 | { |
| 343 | + uint64_t vcpu_pages, extra_pg_pages, pages; | |
| 344 | + struct kvm_vm *vm; | |
| 345 | + int i; | |
| 346 | + | |
| 347 | + /* Force slot0 memory size not small than DEFAULT_GUEST_PHY_PAGES */ | |
| 348 | + if (slot0_mem_pages < DEFAULT_GUEST_PHY_PAGES) | |
| 349 | + slot0_mem_pages = DEFAULT_GUEST_PHY_PAGES; | |
| 350 | + | |
| 315 | 351 | /* The maximum page table size for a memory region will be when the |
| 316 | 352 | * smallest pages are used. Considering each page contains x page |
| 317 | 353 | * table descriptors, the total extra size for page tables (for extra |
| 318 | 354 | * N pages) will be: N/x+N/x^2+N/x^3+... which is definitely smaller |
| 319 | 355 | * than N/x*2. |
| 320 | 356 | */ |
| 321 | − uint64_t vcpu_pages = (DEFAULT_STACK_PGS + num_percpu_pages) * nr_vcpus; | |
| 322 | − uint64_t extra_pg_pages = (extra_mem_pages + vcpu_pages) / PTES_PER_MIN_PAGE * 2; | |
| 323 | − uint64_t pages = DEFAULT_GUEST_PHY_PAGES + extra_mem_pages + vcpu_pages + extra_pg_pages; | |
| 324 | − struct kvm_vm *vm; | |
| 325 | − int i; | |
| 357 | + vcpu_pages = (DEFAULT_STACK_PGS + num_percpu_pages) * nr_vcpus; | |
| 358 | + extra_pg_pages = (slot0_mem_pages + extra_mem_pages + vcpu_pages) / PTES_PER_MIN_PAGE * 2; | |
| 359 | + pages = slot0_mem_pages + vcpu_pages + extra_pg_pages; | |
| 326 | 360 | |
| 327 | 361 | TEST_ASSERT(nr_vcpus <= kvm_check_cap(KVM_CAP_MAX_VCPUS), |
| 328 | 362 | "nr_vcpus = %d too large for host, max-vcpus = %d", |
| @@ -354,8 +388,8 @@ struct kvm_vm *vm_create_default_with_vcpus(uint32_t nr_vcpus, uint64_t extra_me · 25 unmodified lines | ||
| 354 | 388 | uint32_t num_percpu_pages, void *guest_code, |
| 355 | 389 | uint32_t vcpuids[]) |
| 356 | 390 | { |
| 357 | − return vm_create_with_vcpus(VM_MODE_DEFAULT, nr_vcpus, extra_mem_pages, | |
| 358 | − num_percpu_pages, guest_code, vcpuids); | |
| 391 | + return vm_create_with_vcpus(VM_MODE_DEFAULT, nr_vcpus, DEFAULT_GUEST_PHY_PAGES, | |
| 392 | + extra_mem_pages, num_percpu_pages, guest_code, vcpuids); | |
| 359 | 393 | } |
| 360 | 394 | |
| 361 | 395 | struct kvm_vm *vm_create_default(uint32_t vcpuid, uint64_t extra_mem_pages, |
| @@ -69,7 +69,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, · 68 unmodified lines | ||
| 69 | 69 | TEST_ASSERT(vcpu_memory_bytes % perf_test_args.guest_page_size == 0, |
| 70 | 70 | "Guest memory size is not guest page size aligned."); |
| 71 | 71 | |
| 72 | − vm = vm_create_with_vcpus(mode, vcpus, | |
| 72 | + vm = vm_create_with_vcpus(mode, vcpus, DEFAULT_GUEST_PHY_PAGES, | |
| 73 | 73 | (vcpus * vcpu_memory_bytes) / perf_test_args.guest_page_size, |
| 74 | 74 | 0, guest_code, NULL); |
| 75 | 75 | |
| @@ -267,7 +267,7 @@ static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots, · 266 unmodified lines | ||
| 267 | 267 | data->hva_slots = malloc(sizeof(*data->hva_slots) * data->nslots); |
| 268 | 268 | TEST_ASSERT(data->hva_slots, "malloc() fail"); |
| 269 | 269 | |
| 270 | − data->vm = vm_create_default(VCPU_ID, 1024, guest_code); | |
| 270 | + data->vm = vm_create_default(VCPU_ID, mempages, guest_code); | |
| 271 | 271 | |
| 272 | 272 | pr_info_v("Adding slots 1..%i, each slot with %"PRIu64" pages + %"PRIu64" extra pages last\n", |
| 273 | 273 | max_mem_slots - 1, data->pages_per_slot, rempages); |
| @@ -501,6 +501,7 @@ do_transfer() · 500 unmodified lines | ||
| 501 | 501 | local stat_ackrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX") |
| 502 | 502 | local stat_cookietx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent") |
| 503 | 503 | local stat_cookierx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv") |
| 504 | + local stat_ooo_now=$(get_mib_counter "${listener_ns}" "TcpExtTCPOFOQueue") | |
| 504 | 505 | |
| 505 | 506 | expect_synrx=$((stat_synrx_last_l)) |
| 506 | 507 | expect_ackrx=$((stat_ackrx_last_l)) |
| @@ -518,10 +519,14 @@ do_transfer() · 11 unmodified lines | ||
| 518 | 519 | "${stat_synrx_now_l}" "${expect_synrx}" 1>&2 |
| 519 | 520 | retc=1 |
| 520 | 521 | fi |
| 521 | − if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} ]; then | |
| 522 | − printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \ | |
| 523 | − "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2 | |
| 524 | − rets=1 | |
| 522 | + if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} -a ${stat_ooo_now} -eq 0 ]; then | |
| 523 | + if [ ${stat_ooo_now} -eq 0 ]; then | |
| 524 | + printf "[ FAIL ] lower MPC ACK rx (%d) than expected (%d)\n" \ | |
| 525 | + "${stat_ackrx_now_l}" "${expect_ackrx}" 1>&2 | |
| 526 | + rets=1 | |
| 527 | + else | |
| 528 | + printf "[ Note ] fallback due to TCP OoO" | |
| 529 | + fi | |
| 525 | 530 | fi |
| 526 | 531 | |
| 527 | 532 | if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then |
| @@ -10,6 +10,7 @@ · 9 unmodified lines | ||
| 10 | 10 | /proc-self-map-files-002 |
| 11 | 11 | /proc-self-syscall |
| 12 | 12 | /proc-self-wchan |
| 13 | +/proc-subset-pid | |
| 13 | 14 | /proc-uptime-001 |
| 14 | 15 | /proc-uptime-002 |
| 15 | 16 | /read |
| @@ -363,6 +363,7 @@ ip1 -6 rule add table main suppress_prefixlength 0 · 362 unmodified lines | ||
| 363 | 363 | ip1 -4 route add default dev wg0 table 51820 |
| 364 | 364 | ip1 -4 rule add not fwmark 51820 table 51820 |
| 365 | 365 | ip1 -4 rule add table main suppress_prefixlength 0 |
| 366 | +n1 bash -c 'printf 0 > /proc/sys/net/ipv4/conf/vethc/rp_filter' | |
| 366 | 367 | # Flood the pings instead of sending just one, to trigger routing table reference counting bugs. |
| 367 | 368 | n1 ping -W 1 -c 100 -f 192.168.99.7 |
| 368 | 369 | n1 ping -W 1 -c 100 -f abab::1111 |
| @@ -19,7 +19,6 @@ CONFIG_NETFILTER_XTABLES=y · 18 unmodified lines | ||
| 19 | 19 | CONFIG_NETFILTER_XT_NAT=y |
| 20 | 20 | CONFIG_NETFILTER_XT_MATCH_LENGTH=y |
| 21 | 21 | CONFIG_NETFILTER_XT_MARK=y |
| 22 | −CONFIG_NF_CONNTRACK_IPV4=y | |
| 23 | 22 | CONFIG_NF_NAT_IPV4=y |
| 24 | 23 | CONFIG_IP_NF_IPTABLES=y |
| 25 | 24 | CONFIG_IP_NF_FILTER=y |