diff options
490 files changed, 5613 insertions, 6960 deletions
| @@ -224,3 +224,5 @@ Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com> | |||
| 224 | Yusuke Goda <goda.yusuke@renesas.com> | 224 | Yusuke Goda <goda.yusuke@renesas.com> |
| 225 | Gustavo Padovan <gustavo@las.ic.unicamp.br> | 225 | Gustavo Padovan <gustavo@las.ic.unicamp.br> |
| 226 | Gustavo Padovan <padovan@profusion.mobi> | 226 | Gustavo Padovan <padovan@profusion.mobi> |
| 227 | Changbin Du <changbin.du@intel.com> <changbin.du@intel.com> | ||
| 228 | Changbin Du <changbin.du@intel.com> <changbin.du@gmail.com> | ||
diff --git a/Documentation/devicetree/bindings/i2c/i2c-xscale.txt b/Documentation/devicetree/bindings/i2c/i2c-iop3xx.txt index dcc8390e0d24..dcc8390e0d24 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-xscale.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-iop3xx.txt | |||
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt b/Documentation/devicetree/bindings/i2c/i2c-mt65xx.txt index ee4c32454198..ee4c32454198 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mt65xx.txt | |||
diff --git a/Documentation/devicetree/bindings/i2c/i2c-st-ddci2c.txt b/Documentation/devicetree/bindings/i2c/i2c-stu300.txt index bd81a482634f..bd81a482634f 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-st-ddci2c.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-stu300.txt | |||
diff --git a/Documentation/devicetree/bindings/i2c/i2c-sunxi-p2wi.txt b/Documentation/devicetree/bindings/i2c/i2c-sun6i-p2wi.txt index 49df0053347a..49df0053347a 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-sunxi-p2wi.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-sun6i-p2wi.txt | |||
diff --git a/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt b/Documentation/devicetree/bindings/i2c/i2c-wmt.txt index 94a425eaa6c7..94a425eaa6c7 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-vt8500.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-wmt.txt | |||
diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.txt b/Documentation/devicetree/bindings/net/dsa/qca8k.txt index bbcb255c3150..93a7469e70d4 100644 --- a/Documentation/devicetree/bindings/net/dsa/qca8k.txt +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.txt | |||
| @@ -12,10 +12,15 @@ Required properties: | |||
| 12 | Subnodes: | 12 | Subnodes: |
| 13 | 13 | ||
| 14 | The integrated switch subnode should be specified according to the binding | 14 | The integrated switch subnode should be specified according to the binding |
| 15 | described in dsa/dsa.txt. As the QCA8K switches do not have a N:N mapping of | 15 | described in dsa/dsa.txt. If the QCA8K switch is connect to a SoC's external |
| 16 | port and PHY id, each subnode describing a port needs to have a valid phandle | 16 | mdio-bus each subnode describing a port needs to have a valid phandle |
| 17 | referencing the internal PHY connected to it. The CPU port of this switch is | 17 | referencing the internal PHY it is connected to. This is because there's no |
| 18 | always port 0. | 18 | N:N mapping of port and PHY id. |
| 19 | |||
| 20 | Don't use mixed external and internal mdio-bus configurations, as this is | ||
| 21 | not supported by the hardware. | ||
| 22 | |||
| 23 | The CPU port of this switch is always port 0. | ||
| 19 | 24 | ||
| 20 | A CPU port node has the following optional node: | 25 | A CPU port node has the following optional node: |
| 21 | 26 | ||
| @@ -31,8 +36,9 @@ For QCA8K the 'fixed-link' sub-node supports only the following properties: | |||
| 31 | - 'full-duplex' (boolean, optional), to indicate that full duplex is | 36 | - 'full-duplex' (boolean, optional), to indicate that full duplex is |
| 32 | used. When absent, half duplex is assumed. | 37 | used. When absent, half duplex is assumed. |
| 33 | 38 | ||
| 34 | Example: | 39 | Examples: |
| 35 | 40 | ||
| 41 | for the external mdio-bus configuration: | ||
| 36 | 42 | ||
| 37 | &mdio0 { | 43 | &mdio0 { |
| 38 | phy_port1: phy@0 { | 44 | phy_port1: phy@0 { |
| @@ -55,12 +61,12 @@ Example: | |||
| 55 | reg = <4>; | 61 | reg = <4>; |
| 56 | }; | 62 | }; |
| 57 | 63 | ||
| 58 | switch0@0 { | 64 | switch@10 { |
| 59 | compatible = "qca,qca8337"; | 65 | compatible = "qca,qca8337"; |
| 60 | #address-cells = <1>; | 66 | #address-cells = <1>; |
| 61 | #size-cells = <0>; | 67 | #size-cells = <0>; |
| 62 | 68 | ||
| 63 | reg = <0>; | 69 | reg = <0x10>; |
| 64 | 70 | ||
| 65 | ports { | 71 | ports { |
| 66 | #address-cells = <1>; | 72 | #address-cells = <1>; |
| @@ -108,3 +114,56 @@ Example: | |||
| 108 | }; | 114 | }; |
| 109 | }; | 115 | }; |
| 110 | }; | 116 | }; |
| 117 | |||
| 118 | for the internal master mdio-bus configuration: | ||
| 119 | |||
| 120 | &mdio0 { | ||
| 121 | switch@10 { | ||
| 122 | compatible = "qca,qca8337"; | ||
| 123 | #address-cells = <1>; | ||
| 124 | #size-cells = <0>; | ||
| 125 | |||
| 126 | reg = <0x10>; | ||
| 127 | |||
| 128 | ports { | ||
| 129 | #address-cells = <1>; | ||
| 130 | #size-cells = <0>; | ||
| 131 | |||
| 132 | port@0 { | ||
| 133 | reg = <0>; | ||
| 134 | label = "cpu"; | ||
| 135 | ethernet = <&gmac1>; | ||
| 136 | phy-mode = "rgmii"; | ||
| 137 | fixed-link { | ||
| 138 | speed = 1000; | ||
| 139 | full-duplex; | ||
| 140 | }; | ||
| 141 | }; | ||
| 142 | |||
| 143 | port@1 { | ||
| 144 | reg = <1>; | ||
| 145 | label = "lan1"; | ||
| 146 | }; | ||
| 147 | |||
| 148 | port@2 { | ||
| 149 | reg = <2>; | ||
| 150 | label = "lan2"; | ||
| 151 | }; | ||
| 152 | |||
| 153 | port@3 { | ||
| 154 | reg = <3>; | ||
| 155 | label = "lan3"; | ||
| 156 | }; | ||
| 157 | |||
| 158 | port@4 { | ||
| 159 | reg = <4>; | ||
| 160 | label = "lan4"; | ||
| 161 | }; | ||
| 162 | |||
| 163 | port@5 { | ||
| 164 | reg = <5>; | ||
| 165 | label = "wan"; | ||
| 166 | }; | ||
| 167 | }; | ||
| 168 | }; | ||
| 169 | }; | ||
diff --git a/Documentation/devicetree/bindings/serial/mtk-uart.txt b/Documentation/devicetree/bindings/serial/mtk-uart.txt index 742cb470595b..bcfb13194f16 100644 --- a/Documentation/devicetree/bindings/serial/mtk-uart.txt +++ b/Documentation/devicetree/bindings/serial/mtk-uart.txt | |||
| @@ -16,6 +16,7 @@ Required properties: | |||
| 16 | * "mediatek,mt8127-uart" for MT8127 compatible UARTS | 16 | * "mediatek,mt8127-uart" for MT8127 compatible UARTS |
| 17 | * "mediatek,mt8135-uart" for MT8135 compatible UARTS | 17 | * "mediatek,mt8135-uart" for MT8135 compatible UARTS |
| 18 | * "mediatek,mt8173-uart" for MT8173 compatible UARTS | 18 | * "mediatek,mt8173-uart" for MT8173 compatible UARTS |
| 19 | * "mediatek,mt8183-uart", "mediatek,mt6577-uart" for MT8183 compatible UARTS | ||
| 19 | * "mediatek,mt6577-uart" for MT6577 and all of the above | 20 | * "mediatek,mt6577-uart" for MT6577 and all of the above |
| 20 | 21 | ||
| 21 | - reg: The base address of the UART register bank. | 22 | - reg: The base address of the UART register bank. |
diff --git a/Documentation/filesystems/mount_api.txt b/Documentation/filesystems/mount_api.txt index 944d1965e917..00ff0cfccfa7 100644 --- a/Documentation/filesystems/mount_api.txt +++ b/Documentation/filesystems/mount_api.txt | |||
| @@ -12,11 +12,13 @@ CONTENTS | |||
| 12 | 12 | ||
| 13 | (4) Filesystem context security. | 13 | (4) Filesystem context security. |
| 14 | 14 | ||
| 15 | (5) VFS filesystem context operations. | 15 | (5) VFS filesystem context API. |
| 16 | 16 | ||
| 17 | (6) Parameter description. | 17 | (6) Superblock creation helpers. |
| 18 | 18 | ||
| 19 | (7) Parameter helper functions. | 19 | (7) Parameter description. |
| 20 | |||
| 21 | (8) Parameter helper functions. | ||
| 20 | 22 | ||
| 21 | 23 | ||
| 22 | ======== | 24 | ======== |
| @@ -41,12 +43,15 @@ The creation of new mounts is now to be done in a multistep process: | |||
| 41 | 43 | ||
| 42 | (7) Destroy the context. | 44 | (7) Destroy the context. |
| 43 | 45 | ||
| 44 | To support this, the file_system_type struct gains a new field: | 46 | To support this, the file_system_type struct gains two new fields: |
| 45 | 47 | ||
| 46 | int (*init_fs_context)(struct fs_context *fc); | 48 | int (*init_fs_context)(struct fs_context *fc); |
| 49 | const struct fs_parameter_description *parameters; | ||
| 47 | 50 | ||
| 48 | which is invoked to set up the filesystem-specific parts of a filesystem | 51 | The first is invoked to set up the filesystem-specific parts of a filesystem |
| 49 | context, including the additional space. | 52 | context, including the additional space, and the second points to the |
| 53 | parameter description for validation at registration time and querying by a | ||
| 54 | future system call. | ||
| 50 | 55 | ||
| 51 | Note that security initialisation is done *after* the filesystem is called so | 56 | Note that security initialisation is done *after* the filesystem is called so |
| 52 | that the namespaces may be adjusted first. | 57 | that the namespaces may be adjusted first. |
| @@ -73,9 +78,9 @@ context. This is represented by the fs_context structure: | |||
| 73 | void *s_fs_info; | 78 | void *s_fs_info; |
| 74 | unsigned int sb_flags; | 79 | unsigned int sb_flags; |
| 75 | unsigned int sb_flags_mask; | 80 | unsigned int sb_flags_mask; |
| 81 | unsigned int s_iflags; | ||
| 82 | unsigned int lsm_flags; | ||
| 76 | enum fs_context_purpose purpose:8; | 83 | enum fs_context_purpose purpose:8; |
| 77 | bool sloppy:1; | ||
| 78 | bool silent:1; | ||
| 79 | ... | 84 | ... |
| 80 | }; | 85 | }; |
| 81 | 86 | ||
| @@ -141,6 +146,10 @@ The fs_context fields are as follows: | |||
| 141 | 146 | ||
| 142 | Which bits SB_* flags are to be set/cleared in super_block::s_flags. | 147 | Which bits SB_* flags are to be set/cleared in super_block::s_flags. |
| 143 | 148 | ||
| 149 | (*) unsigned int s_iflags | ||
| 150 | |||
| 151 | These will be bitwise-OR'd with s->s_iflags when a superblock is created. | ||
| 152 | |||
| 144 | (*) enum fs_context_purpose | 153 | (*) enum fs_context_purpose |
| 145 | 154 | ||
| 146 | This indicates the purpose for which the context is intended. The | 155 | This indicates the purpose for which the context is intended. The |
| @@ -150,17 +159,6 @@ The fs_context fields are as follows: | |||
| 150 | FS_CONTEXT_FOR_SUBMOUNT -- New automatic submount of extant mount | 159 | FS_CONTEXT_FOR_SUBMOUNT -- New automatic submount of extant mount |
| 151 | FS_CONTEXT_FOR_RECONFIGURE -- Change an existing mount | 160 | FS_CONTEXT_FOR_RECONFIGURE -- Change an existing mount |
| 152 | 161 | ||
| 153 | (*) bool sloppy | ||
| 154 | (*) bool silent | ||
| 155 | |||
| 156 | These are set if the sloppy or silent mount options are given. | ||
| 157 | |||
| 158 | [NOTE] sloppy is probably unnecessary when userspace passes over one | ||
| 159 | option at a time since the error can just be ignored if userspace deems it | ||
| 160 | to be unimportant. | ||
| 161 | |||
| 162 | [NOTE] silent is probably redundant with sb_flags & SB_SILENT. | ||
| 163 | |||
| 164 | The mount context is created by calling vfs_new_fs_context() or | 162 | The mount context is created by calling vfs_new_fs_context() or |
| 165 | vfs_dup_fs_context() and is destroyed with put_fs_context(). Note that the | 163 | vfs_dup_fs_context() and is destroyed with put_fs_context(). Note that the |
| 166 | structure is not refcounted. | 164 | structure is not refcounted. |
| @@ -342,28 +340,47 @@ number of operations used by the new mount code for this purpose: | |||
| 342 | It should return 0 on success or a negative error code on failure. | 340 | It should return 0 on success or a negative error code on failure. |
| 343 | 341 | ||
| 344 | 342 | ||
| 345 | ================================= | 343 | ========================== |
| 346 | VFS FILESYSTEM CONTEXT OPERATIONS | 344 | VFS FILESYSTEM CONTEXT API |
| 347 | ================================= | 345 | ========================== |
| 348 | 346 | ||
| 349 | There are four operations for creating a filesystem context and | 347 | There are four operations for creating a filesystem context and one for |
| 350 | one for destroying a context: | 348 | destroying a context: |
| 351 | 349 | ||
| 352 | (*) struct fs_context *vfs_new_fs_context(struct file_system_type *fs_type, | 350 | (*) struct fs_context *fs_context_for_mount( |
| 353 | struct dentry *reference, | 351 | struct file_system_type *fs_type, |
| 354 | unsigned int sb_flags, | 352 | unsigned int sb_flags); |
| 355 | unsigned int sb_flags_mask, | ||
| 356 | enum fs_context_purpose purpose); | ||
| 357 | 353 | ||
| 358 | Create a filesystem context for a given filesystem type and purpose. This | 354 | Allocate a filesystem context for the purpose of setting up a new mount, |
| 359 | allocates the filesystem context, sets the superblock flags, initialises | 355 | whether that be with a new superblock or sharing an existing one. This |
| 360 | the security and calls fs_type->init_fs_context() to initialise the | 356 | sets the superblock flags, initialises the security and calls |
| 361 | filesystem private data. | 357 | fs_type->init_fs_context() to initialise the filesystem private data. |
| 362 | 358 | ||
| 363 | reference can be NULL or it may indicate the root dentry of a superblock | 359 | fs_type specifies the filesystem type that will manage the context and |
| 364 | that is going to be reconfigured (FS_CONTEXT_FOR_RECONFIGURE) or | 360 | sb_flags presets the superblock flags stored therein. |
| 365 | the automount point that triggered a submount (FS_CONTEXT_FOR_SUBMOUNT). | 361 | |
| 366 | This is provided as a source of namespace information. | 362 | (*) struct fs_context *fs_context_for_reconfigure( |
| 363 | struct dentry *dentry, | ||
| 364 | unsigned int sb_flags, | ||
| 365 | unsigned int sb_flags_mask); | ||
| 366 | |||
| 367 | Allocate a filesystem context for the purpose of reconfiguring an | ||
| 368 | existing superblock. dentry provides a reference to the superblock to be | ||
| 369 | configured. sb_flags and sb_flags_mask indicate which superblock flags | ||
| 370 | need changing and to what. | ||
| 371 | |||
| 372 | (*) struct fs_context *fs_context_for_submount( | ||
| 373 | struct file_system_type *fs_type, | ||
| 374 | struct dentry *reference); | ||
| 375 | |||
| 376 | Allocate a filesystem context for the purpose of creating a new mount for | ||
| 377 | an automount point or other derived superblock. fs_type specifies the | ||
| 378 | filesystem type that will manage the context and the reference dentry | ||
| 379 | supplies the parameters. Namespaces are propagated from the reference | ||
| 380 | dentry's superblock also. | ||
| 381 | |||
| 382 | Note that it's not a requirement that the reference dentry be of the same | ||
| 383 | filesystem type as fs_type. | ||
| 367 | 384 | ||
| 368 | (*) struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc); | 385 | (*) struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc); |
| 369 | 386 | ||
| @@ -390,20 +407,6 @@ context pointer or a negative error code. | |||
| 390 | For the remaining operations, if an error occurs, a negative error code will be | 407 | For the remaining operations, if an error occurs, a negative error code will be |
| 391 | returned. | 408 | returned. |
| 392 | 409 | ||
| 393 | (*) int vfs_get_tree(struct fs_context *fc); | ||
| 394 | |||
| 395 | Get or create the mountable root and superblock, using the parameters in | ||
| 396 | the filesystem context to select/configure the superblock. This invokes | ||
| 397 | the ->validate() op and then the ->get_tree() op. | ||
| 398 | |||
| 399 | [NOTE] ->validate() could perhaps be rolled into ->get_tree() and | ||
| 400 | ->reconfigure(). | ||
| 401 | |||
| 402 | (*) struct vfsmount *vfs_create_mount(struct fs_context *fc); | ||
| 403 | |||
| 404 | Create a mount given the parameters in the specified filesystem context. | ||
| 405 | Note that this does not attach the mount to anything. | ||
| 406 | |||
| 407 | (*) int vfs_parse_fs_param(struct fs_context *fc, | 410 | (*) int vfs_parse_fs_param(struct fs_context *fc, |
| 408 | struct fs_parameter *param); | 411 | struct fs_parameter *param); |
| 409 | 412 | ||
| @@ -432,17 +435,80 @@ returned. | |||
| 432 | clear the pointer, but then becomes responsible for disposing of the | 435 | clear the pointer, but then becomes responsible for disposing of the |
| 433 | object. | 436 | object. |
| 434 | 437 | ||
| 435 | (*) int vfs_parse_fs_string(struct fs_context *fc, char *key, | 438 | (*) int vfs_parse_fs_string(struct fs_context *fc, const char *key, |
| 436 | const char *value, size_t v_size); | 439 | const char *value, size_t v_size); |
| 437 | 440 | ||
| 438 | A wrapper around vfs_parse_fs_param() that just passes a constant string. | 441 | A wrapper around vfs_parse_fs_param() that copies the value string it is |
| 442 | passed. | ||
| 439 | 443 | ||
| 440 | (*) int generic_parse_monolithic(struct fs_context *fc, void *data); | 444 | (*) int generic_parse_monolithic(struct fs_context *fc, void *data); |
| 441 | 445 | ||
| 442 | Parse a sys_mount() data page, assuming the form to be a text list | 446 | Parse a sys_mount() data page, assuming the form to be a text list |
| 443 | consisting of key[=val] options separated by commas. Each item in the | 447 | consisting of key[=val] options separated by commas. Each item in the |
| 444 | list is passed to vfs_mount_option(). This is the default when the | 448 | list is passed to vfs_mount_option(). This is the default when the |
| 445 | ->parse_monolithic() operation is NULL. | 449 | ->parse_monolithic() method is NULL. |
| 450 | |||
| 451 | (*) int vfs_get_tree(struct fs_context *fc); | ||
| 452 | |||
| 453 | Get or create the mountable root and superblock, using the parameters in | ||
| 454 | the filesystem context to select/configure the superblock. This invokes | ||
| 455 | the ->get_tree() method. | ||
| 456 | |||
| 457 | (*) struct vfsmount *vfs_create_mount(struct fs_context *fc); | ||
| 458 | |||
| 459 | Create a mount given the parameters in the specified filesystem context. | ||
| 460 | Note that this does not attach the mount to anything. | ||
| 461 | |||
| 462 | |||
| 463 | =========================== | ||
| 464 | SUPERBLOCK CREATION HELPERS | ||
| 465 | =========================== | ||
| 466 | |||
| 467 | A number of VFS helpers are available for use by filesystems for the creation | ||
| 468 | or looking up of superblocks. | ||
| 469 | |||
| 470 | (*) struct super_block * | ||
| 471 | sget_fc(struct fs_context *fc, | ||
| 472 | int (*test)(struct super_block *sb, struct fs_context *fc), | ||
| 473 | int (*set)(struct super_block *sb, struct fs_context *fc)); | ||
| 474 | |||
| 475 | This is the core routine. If test is non-NULL, it searches for an | ||
| 476 | existing superblock matching the criteria held in the fs_context, using | ||
| 477 | the test function to match them. If no match is found, a new superblock | ||
| 478 | is created and the set function is called to set it up. | ||
| 479 | |||
| 480 | Prior to the set function being called, fc->s_fs_info will be transferred | ||
| 481 | to sb->s_fs_info - and fc->s_fs_info will be cleared if set returns | ||
| 482 | success (ie. 0). | ||
| 483 | |||
| 484 | The following helpers all wrap sget_fc(): | ||
| 485 | |||
| 486 | (*) int vfs_get_super(struct fs_context *fc, | ||
| 487 | enum vfs_get_super_keying keying, | ||
| 488 | int (*fill_super)(struct super_block *sb, | ||
| 489 | struct fs_context *fc)) | ||
| 490 | |||
| 491 | This creates/looks up a deviceless superblock. The keying indicates how | ||
| 492 | many superblocks of this type may exist and in what manner they may be | ||
| 493 | shared: | ||
| 494 | |||
| 495 | (1) vfs_get_single_super | ||
| 496 | |||
| 497 | Only one such superblock may exist in the system. Any further | ||
| 498 | attempt to get a new superblock gets this one (and any parameter | ||
| 499 | differences are ignored). | ||
| 500 | |||
| 501 | (2) vfs_get_keyed_super | ||
| 502 | |||
| 503 | Multiple superblocks of this type may exist and they're keyed on | ||
| 504 | their s_fs_info pointer (for example this may refer to a | ||
| 505 | namespace). | ||
| 506 | |||
| 507 | (3) vfs_get_independent_super | ||
| 508 | |||
| 509 | Multiple independent superblocks of this type may exist. This | ||
| 510 | function never matches an existing one and always creates a new | ||
| 511 | one. | ||
| 446 | 512 | ||
| 447 | 513 | ||
| 448 | ===================== | 514 | ===================== |
| @@ -454,35 +520,22 @@ There's a core description struct that links everything together: | |||
| 454 | 520 | ||
| 455 | struct fs_parameter_description { | 521 | struct fs_parameter_description { |
| 456 | const char name[16]; | 522 | const char name[16]; |
| 457 | u8 nr_params; | ||
| 458 | u8 nr_alt_keys; | ||
| 459 | u8 nr_enums; | ||
| 460 | bool ignore_unknown; | ||
| 461 | bool no_source; | ||
| 462 | const char *const *keys; | ||
| 463 | const struct constant_table *alt_keys; | ||
| 464 | const struct fs_parameter_spec *specs; | 523 | const struct fs_parameter_spec *specs; |
| 465 | const struct fs_parameter_enum *enums; | 524 | const struct fs_parameter_enum *enums; |
| 466 | }; | 525 | }; |
| 467 | 526 | ||
| 468 | For example: | 527 | For example: |
| 469 | 528 | ||
| 470 | enum afs_param { | 529 | enum { |
| 471 | Opt_autocell, | 530 | Opt_autocell, |
| 472 | Opt_bar, | 531 | Opt_bar, |
| 473 | Opt_dyn, | 532 | Opt_dyn, |
| 474 | Opt_foo, | 533 | Opt_foo, |
| 475 | Opt_source, | 534 | Opt_source, |
| 476 | nr__afs_params | ||
| 477 | }; | 535 | }; |
| 478 | 536 | ||
| 479 | static const struct fs_parameter_description afs_fs_parameters = { | 537 | static const struct fs_parameter_description afs_fs_parameters = { |
| 480 | .name = "kAFS", | 538 | .name = "kAFS", |
| 481 | .nr_params = nr__afs_params, | ||
| 482 | .nr_alt_keys = ARRAY_SIZE(afs_param_alt_keys), | ||
| 483 | .nr_enums = ARRAY_SIZE(afs_param_enums), | ||
| 484 | .keys = afs_param_keys, | ||
| 485 | .alt_keys = afs_param_alt_keys, | ||
| 486 | .specs = afs_param_specs, | 539 | .specs = afs_param_specs, |
| 487 | .enums = afs_param_enums, | 540 | .enums = afs_param_enums, |
| 488 | }; | 541 | }; |
| @@ -494,28 +547,24 @@ The members are as follows: | |||
| 494 | The name to be used in error messages generated by the parse helper | 547 | The name to be used in error messages generated by the parse helper |
| 495 | functions. | 548 | functions. |
| 496 | 549 | ||
| 497 | (2) u8 nr_params; | 550 | (2) const struct fs_parameter_specification *specs; |
| 498 | |||
| 499 | The number of discrete parameter identifiers. This indicates the number | ||
| 500 | of elements in the ->types[] array and also limits the values that may be | ||
| 501 | used in the values that the ->keys[] array maps to. | ||
| 502 | |||
| 503 | It is expected that, for example, two parameters that are related, say | ||
| 504 | "acl" and "noacl" with have the same ID, but will be flagged to indicate | ||
| 505 | that one is the inverse of the other. The value can then be picked out | ||
| 506 | from the parse result. | ||
| 507 | 551 | ||
| 508 | (3) const struct fs_parameter_specification *specs; | 552 | Table of parameter specifications, terminated with a null entry, where the |
| 553 | entries are of type: | ||
| 509 | 554 | ||
| 510 | Table of parameter specifications, where the entries are of type: | 555 | struct fs_parameter_spec { |
| 511 | 556 | const char *name; | |
| 512 | struct fs_parameter_type { | 557 | u8 opt; |
| 513 | enum fs_parameter_spec type:8; | 558 | enum fs_parameter_type type:8; |
| 514 | u8 flags; | 559 | unsigned short flags; |
| 515 | }; | 560 | }; |
| 516 | 561 | ||
| 517 | and the parameter identifier is the index to the array. 'type' indicates | 562 | The 'name' field is a string to match exactly to the parameter key (no |
| 518 | the desired value type and must be one of: | 563 | wildcards, patterns and no case-independence) and 'opt' is the value that |
| 564 | will be returned by the fs_parser() function in the case of a successful | ||
| 565 | match. | ||
| 566 | |||
| 567 | The 'type' field indicates the desired value type and must be one of: | ||
| 519 | 568 | ||
| 520 | TYPE NAME EXPECTED VALUE RESULT IN | 569 | TYPE NAME EXPECTED VALUE RESULT IN |
| 521 | ======================= ======================= ===================== | 570 | ======================= ======================= ===================== |
| @@ -525,85 +574,65 @@ The members are as follows: | |||
| 525 | fs_param_is_u32_octal 32-bit octal int result->uint_32 | 574 | fs_param_is_u32_octal 32-bit octal int result->uint_32 |
| 526 | fs_param_is_u32_hex 32-bit hex int result->uint_32 | 575 | fs_param_is_u32_hex 32-bit hex int result->uint_32 |
| 527 | fs_param_is_s32 32-bit signed int result->int_32 | 576 | fs_param_is_s32 32-bit signed int result->int_32 |
| 577 | fs_param_is_u64 64-bit unsigned int result->uint_64 | ||
| 528 | fs_param_is_enum Enum value name result->uint_32 | 578 | fs_param_is_enum Enum value name result->uint_32 |
| 529 | fs_param_is_string Arbitrary string param->string | 579 | fs_param_is_string Arbitrary string param->string |
| 530 | fs_param_is_blob Binary blob param->blob | 580 | fs_param_is_blob Binary blob param->blob |
| 531 | fs_param_is_blockdev Blockdev path * Needs lookup | 581 | fs_param_is_blockdev Blockdev path * Needs lookup |
| 532 | fs_param_is_path Path * Needs lookup | 582 | fs_param_is_path Path * Needs lookup |
| 533 | fs_param_is_fd File descriptor param->file | 583 | fs_param_is_fd File descriptor result->int_32 |
| 534 | |||
| 535 | And each parameter can be qualified with 'flags': | ||
| 536 | |||
| 537 | fs_param_v_optional The value is optional | ||
| 538 | fs_param_neg_with_no If key name is prefixed with "no", it is false | ||
| 539 | fs_param_neg_with_empty If value is "", it is false | ||
| 540 | fs_param_deprecated The parameter is deprecated. | ||
| 541 | |||
| 542 | For example: | ||
| 543 | |||
| 544 | static const struct fs_parameter_spec afs_param_specs[nr__afs_params] = { | ||
| 545 | [Opt_autocell] = { fs_param_is flag }, | ||
| 546 | [Opt_bar] = { fs_param_is_enum }, | ||
| 547 | [Opt_dyn] = { fs_param_is flag }, | ||
| 548 | [Opt_foo] = { fs_param_is_bool, fs_param_neg_with_no }, | ||
| 549 | [Opt_source] = { fs_param_is_string }, | ||
| 550 | }; | ||
| 551 | 584 | ||
| 552 | Note that if the value is of fs_param_is_bool type, fs_parse() will try | 585 | Note that if the value is of fs_param_is_bool type, fs_parse() will try |
| 553 | to match any string value against "0", "1", "no", "yes", "false", "true". | 586 | to match any string value against "0", "1", "no", "yes", "false", "true". |
| 554 | 587 | ||
| 555 | [!] NOTE that the table must be sorted according to primary key name so | 588 | Each parameter can also be qualified with 'flags': |
| 556 | that ->keys[] is also sorted. | ||
| 557 | |||
| 558 | (4) const char *const *keys; | ||
| 559 | |||
| 560 | Table of primary key names for the parameters. There must be one entry | ||
| 561 | per defined parameter. The table is optional if ->nr_params is 0. The | ||
| 562 | table is just an array of names e.g.: | ||
| 563 | 589 | ||
| 564 | static const char *const afs_param_keys[nr__afs_params] = { | 590 | fs_param_v_optional The value is optional |
| 565 | [Opt_autocell] = "autocell", | 591 | fs_param_neg_with_no result->negated set if key is prefixed with "no" |
| 566 | [Opt_bar] = "bar", | 592 | fs_param_neg_with_empty result->negated set if value is "" |
| 567 | [Opt_dyn] = "dyn", | 593 | fs_param_deprecated The parameter is deprecated. |
| 568 | [Opt_foo] = "foo", | ||
| 569 | [Opt_source] = "source", | ||
| 570 | }; | ||
| 571 | |||
| 572 | [!] NOTE that the table must be sorted such that the table can be searched | ||
| 573 | with bsearch() using strcmp(). This means that the Opt_* values must | ||
| 574 | correspond to the entries in this table. | ||
| 575 | |||
| 576 | (5) const struct constant_table *alt_keys; | ||
| 577 | u8 nr_alt_keys; | ||
| 578 | |||
| 579 | Table of additional key names and their mappings to parameter ID plus the | ||
| 580 | number of elements in the table. This is optional. The table is just an | ||
| 581 | array of { name, integer } pairs, e.g.: | ||
| 582 | 594 | ||
| 583 | static const struct constant_table afs_param_keys[] = { | 595 | These are wrapped with a number of convenience wrappers: |
| 584 | { "baz", Opt_bar }, | 596 | |
| 585 | { "dynamic", Opt_dyn }, | 597 | MACRO SPECIFIES |
| 598 | ======================= =============================================== | ||
| 599 | fsparam_flag() fs_param_is_flag | ||
| 600 | fsparam_flag_no() fs_param_is_flag, fs_param_neg_with_no | ||
| 601 | fsparam_bool() fs_param_is_bool | ||
| 602 | fsparam_u32() fs_param_is_u32 | ||
| 603 | fsparam_u32oct() fs_param_is_u32_octal | ||
| 604 | fsparam_u32hex() fs_param_is_u32_hex | ||
| 605 | fsparam_s32() fs_param_is_s32 | ||
| 606 | fsparam_u64() fs_param_is_u64 | ||
| 607 | fsparam_enum() fs_param_is_enum | ||
| 608 | fsparam_string() fs_param_is_string | ||
| 609 | fsparam_blob() fs_param_is_blob | ||
| 610 | fsparam_bdev() fs_param_is_blockdev | ||
| 611 | fsparam_path() fs_param_is_path | ||
| 612 | fsparam_fd() fs_param_is_fd | ||
| 613 | |||
| 614 | all of which take two arguments, name string and option number - for | ||
| 615 | example: | ||
| 616 | |||
| 617 | static const struct fs_parameter_spec afs_param_specs[] = { | ||
| 618 | fsparam_flag ("autocell", Opt_autocell), | ||
| 619 | fsparam_flag ("dyn", Opt_dyn), | ||
| 620 | fsparam_string ("source", Opt_source), | ||
| 621 | fsparam_flag_no ("foo", Opt_foo), | ||
| 622 | {} | ||
| 586 | }; | 623 | }; |
| 587 | 624 | ||
| 588 | [!] NOTE that the table must be sorted such that strcmp() can be used with | 625 | An addition macro, __fsparam() is provided that takes an additional pair |
| 589 | bsearch() to search the entries. | 626 | of arguments to specify the type and the flags for anything that doesn't |
| 590 | 627 | match one of the above macros. | |
| 591 | The parameter ID can also be fs_param_key_removed to indicate that a | ||
| 592 | deprecated parameter has been removed and that an error will be given. | ||
| 593 | This differs from fs_param_deprecated where the parameter may still have | ||
| 594 | an effect. | ||
| 595 | |||
| 596 | Further, the behaviour of the parameter may differ when an alternate name | ||
| 597 | is used (for instance with NFS, "v3", "v4.2", etc. are alternate names). | ||
| 598 | 628 | ||
| 599 | (6) const struct fs_parameter_enum *enums; | 629 | (6) const struct fs_parameter_enum *enums; |
| 600 | u8 nr_enums; | ||
| 601 | 630 | ||
| 602 | Table of enum value names to integer mappings and the number of elements | 631 | Table of enum value names to integer mappings, terminated with a null |
| 603 | stored therein. This is of type: | 632 | entry. This is of type: |
| 604 | 633 | ||
| 605 | struct fs_parameter_enum { | 634 | struct fs_parameter_enum { |
| 606 | u8 param_id; | 635 | u8 opt; |
| 607 | char name[14]; | 636 | char name[14]; |
| 608 | u8 value; | 637 | u8 value; |
| 609 | }; | 638 | }; |
| @@ -621,11 +650,6 @@ The members are as follows: | |||
| 621 | try to look the value up in the enum table and the result will be stored | 650 | try to look the value up in the enum table and the result will be stored |
| 622 | in the parse result. | 651 | in the parse result. |
| 623 | 652 | ||
| 624 | (7) bool no_source; | ||
| 625 | |||
| 626 | If this is set, fs_parse() will ignore any "source" parameter and not | ||
| 627 | pass it to the filesystem. | ||
| 628 | |||
| 629 | The parser should be pointed to by the parser pointer in the file_system_type | 653 | The parser should be pointed to by the parser pointer in the file_system_type |
| 630 | struct as this will provide validation on registration (if | 654 | struct as this will provide validation on registration (if |
| 631 | CONFIG_VALIDATE_FS_PARSER=y) and will allow the description to be queried from | 655 | CONFIG_VALIDATE_FS_PARSER=y) and will allow the description to be queried from |
| @@ -650,9 +674,8 @@ process the parameters it is given. | |||
| 650 | int value; | 674 | int value; |
| 651 | }; | 675 | }; |
| 652 | 676 | ||
| 653 | and it must be sorted such that it can be searched using bsearch() using | 677 | If a match is found, the corresponding value is returned. If a match |
| 654 | strcmp(). If a match is found, the corresponding value is returned. If a | 678 | isn't found, the not_found value is returned instead. |
| 655 | match isn't found, the not_found value is returned instead. | ||
| 656 | 679 | ||
| 657 | (*) bool validate_constant_table(const struct constant_table *tbl, | 680 | (*) bool validate_constant_table(const struct constant_table *tbl, |
| 658 | size_t tbl_size, | 681 | size_t tbl_size, |
| @@ -665,36 +688,36 @@ process the parameters it is given. | |||
| 665 | should just be set to lie inside the low-to-high range. | 688 | should just be set to lie inside the low-to-high range. |
| 666 | 689 | ||
| 667 | If all is good, true is returned. If the table is invalid, errors are | 690 | If all is good, true is returned. If the table is invalid, errors are |
| 668 | logged to dmesg, the stack is dumped and false is returned. | 691 | logged to dmesg and false is returned. |
| 692 | |||
| 693 | (*) bool fs_validate_description(const struct fs_parameter_description *desc); | ||
| 694 | |||
| 695 | This performs some validation checks on a parameter description. It | ||
| 696 | returns true if the description is good and false if it is not. It will | ||
| 697 | log errors to dmesg if validation fails. | ||
| 669 | 698 | ||
| 670 | (*) int fs_parse(struct fs_context *fc, | 699 | (*) int fs_parse(struct fs_context *fc, |
| 671 | const struct fs_param_parser *parser, | 700 | const struct fs_parameter_description *desc, |
| 672 | struct fs_parameter *param, | 701 | struct fs_parameter *param, |
| 673 | struct fs_param_parse_result *result); | 702 | struct fs_parse_result *result); |
| 674 | 703 | ||
| 675 | This is the main interpreter of parameters. It uses the parameter | 704 | This is the main interpreter of parameters. It uses the parameter |
| 676 | description (parser) to look up the name of the parameter to use and to | 705 | description to look up a parameter by key name and to convert that to an |
| 677 | convert that to a parameter ID (stored in result->key). | 706 | option number (which it returns). |
| 678 | 707 | ||
| 679 | If successful, and if the parameter type indicates the result is a | 708 | If successful, and if the parameter type indicates the result is a |
| 680 | boolean, integer or enum type, the value is converted by this function and | 709 | boolean, integer or enum type, the value is converted by this function and |
| 681 | the result stored in result->{boolean,int_32,uint_32}. | 710 | the result stored in result->{boolean,int_32,uint_32,uint_64}. |
| 682 | 711 | ||
| 683 | If a match isn't initially made, the key is prefixed with "no" and no | 712 | If a match isn't initially made, the key is prefixed with "no" and no |
| 684 | value is present then an attempt will be made to look up the key with the | 713 | value is present then an attempt will be made to look up the key with the |
| 685 | prefix removed. If this matches a parameter for which the type has flag | 714 | prefix removed. If this matches a parameter for which the type has flag |
| 686 | fs_param_neg_with_no set, then a match will be made and the value will be | 715 | fs_param_neg_with_no set, then a match will be made and result->negated |
| 687 | set to false/0/NULL. | 716 | will be set to true. |
| 688 | |||
| 689 | If the parameter is successfully matched and, optionally, parsed | ||
| 690 | correctly, 1 is returned. If the parameter isn't matched and | ||
| 691 | parser->ignore_unknown is set, then 0 is returned. Otherwise -EINVAL is | ||
| 692 | returned. | ||
| 693 | |||
| 694 | (*) bool fs_validate_description(const struct fs_parameter_description *desc); | ||
| 695 | 717 | ||
| 696 | This is validates the parameter description. It returns true if the | 718 | If the parameter isn't matched, -ENOPARAM will be returned; if the |
| 697 | description is good and false if it is not. | 719 | parameter is matched, but the value is erroneous, -EINVAL will be |
| 720 | returned; otherwise the parameter's option number will be returned. | ||
| 698 | 721 | ||
| 699 | (*) int fs_lookup_param(struct fs_context *fc, | 722 | (*) int fs_lookup_param(struct fs_context *fc, |
| 700 | struct fs_parameter *value, | 723 | struct fs_parameter *value, |
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801 index d1ee484a787d..ee9984f35868 100644 --- a/Documentation/i2c/busses/i2c-i801 +++ b/Documentation/i2c/busses/i2c-i801 | |||
| @@ -36,6 +36,7 @@ Supported adapters: | |||
| 36 | * Intel Cannon Lake (PCH) | 36 | * Intel Cannon Lake (PCH) |
| 37 | * Intel Cedar Fork (PCH) | 37 | * Intel Cedar Fork (PCH) |
| 38 | * Intel Ice Lake (PCH) | 38 | * Intel Ice Lake (PCH) |
| 39 | * Intel Comet Lake (PCH) | ||
| 39 | Datasheets: Publicly available at the Intel website | 40 | Datasheets: Publicly available at the Intel website |
| 40 | 41 | ||
| 41 | On Intel Patsburg and later chipsets, both the normal host SMBus controller | 42 | On Intel Patsburg and later chipsets, both the normal host SMBus controller |
diff --git a/Documentation/networking/msg_zerocopy.rst b/Documentation/networking/msg_zerocopy.rst index 18c1415e7bfa..ace56204dd03 100644 --- a/Documentation/networking/msg_zerocopy.rst +++ b/Documentation/networking/msg_zerocopy.rst | |||
| @@ -50,7 +50,7 @@ the excellent reporting over at LWN.net or read the original code. | |||
| 50 | 50 | ||
| 51 | patchset | 51 | patchset |
| 52 | [PATCH net-next v4 0/9] socket sendmsg MSG_ZEROCOPY | 52 | [PATCH net-next v4 0/9] socket sendmsg MSG_ZEROCOPY |
| 53 | http://lkml.kernel.org/r/20170803202945.70750-1-willemdebruijn.kernel@gmail.com | 53 | https://lkml.kernel.org/netdev/20170803202945.70750-1-willemdebruijn.kernel@gmail.com |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | Interface | 56 | Interface |
diff --git a/Documentation/networking/netdev-FAQ.rst b/Documentation/networking/netdev-FAQ.rst index 0ac5fa77f501..8c7a713cf657 100644 --- a/Documentation/networking/netdev-FAQ.rst +++ b/Documentation/networking/netdev-FAQ.rst | |||
| @@ -131,6 +131,19 @@ it to the maintainer to figure out what is the most recent and current | |||
| 131 | version that should be applied. If there is any doubt, the maintainer | 131 | version that should be applied. If there is any doubt, the maintainer |
| 132 | will reply and ask what should be done. | 132 | will reply and ask what should be done. |
| 133 | 133 | ||
| 134 | Q: I made changes to only a few patches in a patch series should I resend only those changed? | ||
| 135 | -------------------------------------------------------------------------------------------- | ||
| 136 | A: No, please resend the entire patch series and make sure you do number your | ||
| 137 | patches such that it is clear this is the latest and greatest set of patches | ||
| 138 | that can be applied. | ||
| 139 | |||
| 140 | Q: I submitted multiple versions of a patch series and it looks like a version other than the last one has been accepted, what should I do? | ||
| 141 | ------------------------------------------------------------------------------------------------------------------------------------------- | ||
| 142 | A: There is no revert possible, once it is pushed out, it stays like that. | ||
| 143 | Please send incremental versions on top of what has been merged in order to fix | ||
| 144 | the patches the way they would look like if your latest patch series was to be | ||
| 145 | merged. | ||
| 146 | |||
| 134 | Q: How can I tell what patches are queued up for backporting to the various stable releases? | 147 | Q: How can I tell what patches are queued up for backporting to the various stable releases? |
| 135 | -------------------------------------------------------------------------------------------- | 148 | -------------------------------------------------------------------------------------------- |
| 136 | A: Normally Greg Kroah-Hartman collects stable commits himself, but for | 149 | A: Normally Greg Kroah-Hartman collects stable commits himself, but for |
diff --git a/Documentation/networking/nf_flowtable.txt b/Documentation/networking/nf_flowtable.txt index 54128c50d508..ca2136c76042 100644 --- a/Documentation/networking/nf_flowtable.txt +++ b/Documentation/networking/nf_flowtable.txt | |||
| @@ -44,10 +44,10 @@ including the Netfilter hooks and the flowtable fastpath bypass. | |||
| 44 | / \ / \ |Routing | / \ | 44 | / \ / \ |Routing | / \ |
| 45 | --> ingress ---> prerouting ---> |decision| | postrouting |--> neigh_xmit | 45 | --> ingress ---> prerouting ---> |decision| | postrouting |--> neigh_xmit |
| 46 | \_________/ \__________/ ---------- \____________/ ^ | 46 | \_________/ \__________/ ---------- \____________/ ^ |
| 47 | | ^ | | ^ | | 47 | | ^ | ^ | |
| 48 | flowtable | | ____\/___ | | | 48 | flowtable | ____\/___ | | |
| 49 | | | | / \ | | | 49 | | | / \ | | |
| 50 | __\/___ | --------->| forward |------------ | | 50 | __\/___ | | forward |------------ | |
| 51 | |-----| | \_________/ | | 51 | |-----| | \_________/ | |
| 52 | |-----| | 'flow offload' rule | | 52 | |-----| | 'flow offload' rule | |
| 53 | |-----| | adds entry to | | 53 | |-----| | adds entry to | |
diff --git a/Documentation/networking/snmp_counter.rst b/Documentation/networking/snmp_counter.rst index 52b026be028f..38a4edc4522b 100644 --- a/Documentation/networking/snmp_counter.rst +++ b/Documentation/networking/snmp_counter.rst | |||
| @@ -413,7 +413,7 @@ algorithm. | |||
| 413 | .. _F-RTO: https://tools.ietf.org/html/rfc5682 | 413 | .. _F-RTO: https://tools.ietf.org/html/rfc5682 |
| 414 | 414 | ||
| 415 | TCP Fast Path | 415 | TCP Fast Path |
| 416 | ============ | 416 | ============= |
| 417 | When kernel receives a TCP packet, it has two paths to handler the | 417 | When kernel receives a TCP packet, it has two paths to handler the |
| 418 | packet, one is fast path, another is slow path. The comment in kernel | 418 | packet, one is fast path, another is slow path. The comment in kernel |
| 419 | code provides a good explanation of them, I pasted them below:: | 419 | code provides a good explanation of them, I pasted them below:: |
| @@ -681,6 +681,7 @@ The TCP stack receives an out of order duplicate packet, so it sends a | |||
| 681 | DSACK to the sender. | 681 | DSACK to the sender. |
| 682 | 682 | ||
| 683 | * TcpExtTCPDSACKRecv | 683 | * TcpExtTCPDSACKRecv |
| 684 | |||
| 684 | The TCP stack receives a DSACK, which indicates an acknowledged | 685 | The TCP stack receives a DSACK, which indicates an acknowledged |
| 685 | duplicate packet is received. | 686 | duplicate packet is received. |
| 686 | 687 | ||
| @@ -690,7 +691,7 @@ The TCP stack receives a DSACK, which indicate an out of order | |||
| 690 | duplicate packet is received. | 691 | duplicate packet is received. |
| 691 | 692 | ||
| 692 | invalid SACK and DSACK | 693 | invalid SACK and DSACK |
| 693 | ==================== | 694 | ====================== |
| 694 | When a SACK (or DSACK) block is invalid, a corresponding counter would | 695 | When a SACK (or DSACK) block is invalid, a corresponding counter would |
| 695 | be updated. The validation method is base on the start/end sequence | 696 | be updated. The validation method is base on the start/end sequence |
| 696 | number of the SACK block. For more details, please refer the comment | 697 | number of the SACK block. For more details, please refer the comment |
| @@ -704,11 +705,13 @@ explaination: | |||
| 704 | .. _Add counters for discarded SACK blocks: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=18f02545a9a16c9a89778b91a162ad16d510bb32 | 705 | .. _Add counters for discarded SACK blocks: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=18f02545a9a16c9a89778b91a162ad16d510bb32 |
| 705 | 706 | ||
| 706 | * TcpExtTCPSACKDiscard | 707 | * TcpExtTCPSACKDiscard |
| 708 | |||
| 707 | This counter indicates how many SACK blocks are invalid. If the invalid | 709 | This counter indicates how many SACK blocks are invalid. If the invalid |
| 708 | SACK block is caused by ACK recording, the TCP stack will only ignore | 710 | SACK block is caused by ACK recording, the TCP stack will only ignore |
| 709 | it and won't update this counter. | 711 | it and won't update this counter. |
| 710 | 712 | ||
| 711 | * TcpExtTCPDSACKIgnoredOld and TcpExtTCPDSACKIgnoredNoUndo | 713 | * TcpExtTCPDSACKIgnoredOld and TcpExtTCPDSACKIgnoredNoUndo |
| 714 | |||
| 712 | When a DSACK block is invalid, one of these two counters would be | 715 | When a DSACK block is invalid, one of these two counters would be |
| 713 | updated. Which counter will be updated depends on the undo_marker flag | 716 | updated. Which counter will be updated depends on the undo_marker flag |
| 714 | of the TCP socket. If the undo_marker is not set, the TCP stack isn't | 717 | of the TCP socket. If the undo_marker is not set, the TCP stack isn't |
| @@ -719,7 +722,7 @@ will be updated. If the undo_marker is set, TcpExtTCPDSACKIgnoredOld | |||
| 719 | will be updated. As implied in its name, it might be an old packet. | 722 | will be updated. As implied in its name, it might be an old packet. |
| 720 | 723 | ||
| 721 | SACK shift | 724 | SACK shift |
| 722 | ========= | 725 | ========== |
| 723 | The linux networking stack stores data in sk_buff struct (skb for | 726 | The linux networking stack stores data in sk_buff struct (skb for |
| 724 | short). If a SACK block acrosses multiple skb, the TCP stack will try | 727 | short). If a SACK block acrosses multiple skb, the TCP stack will try |
| 725 | to re-arrange data in these skb. E.g. if a SACK block acknowledges seq | 728 | to re-arrange data in these skb. E.g. if a SACK block acknowledges seq |
| @@ -730,12 +733,15 @@ seq 14 to 20. All data in skb2 will be moved to skb1, and skb2 will be | |||
| 730 | discard, this operation is 'merge'. | 733 | discard, this operation is 'merge'. |
| 731 | 734 | ||
| 732 | * TcpExtTCPSackShifted | 735 | * TcpExtTCPSackShifted |
| 736 | |||
| 733 | A skb is shifted | 737 | A skb is shifted |
| 734 | 738 | ||
| 735 | * TcpExtTCPSackMerged | 739 | * TcpExtTCPSackMerged |
| 740 | |||
| 736 | A skb is merged | 741 | A skb is merged |
| 737 | 742 | ||
| 738 | * TcpExtTCPSackShiftFallback | 743 | * TcpExtTCPSackShiftFallback |
| 744 | |||
| 739 | A skb should be shifted or merged, but the TCP stack doesn't do it for | 745 | A skb should be shifted or merged, but the TCP stack doesn't do it for |
| 740 | some reasons. | 746 | some reasons. |
| 741 | 747 | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 3e5a5d263f29..43b36dbed48e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -2356,7 +2356,7 @@ F: arch/arm/mm/cache-uniphier.c | |||
| 2356 | F: arch/arm64/boot/dts/socionext/uniphier* | 2356 | F: arch/arm64/boot/dts/socionext/uniphier* |
| 2357 | F: drivers/bus/uniphier-system-bus.c | 2357 | F: drivers/bus/uniphier-system-bus.c |
| 2358 | F: drivers/clk/uniphier/ | 2358 | F: drivers/clk/uniphier/ |
| 2359 | F: drivers/dmaengine/uniphier-mdmac.c | 2359 | F: drivers/dma/uniphier-mdmac.c |
| 2360 | F: drivers/gpio/gpio-uniphier.c | 2360 | F: drivers/gpio/gpio-uniphier.c |
| 2361 | F: drivers/i2c/busses/i2c-uniphier* | 2361 | F: drivers/i2c/busses/i2c-uniphier* |
| 2362 | F: drivers/irqchip/irq-uniphier-aidet.c | 2362 | F: drivers/irqchip/irq-uniphier-aidet.c |
| @@ -6408,7 +6408,6 @@ L: linux-kernel@vger.kernel.org | |||
| 6408 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core | 6408 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core |
| 6409 | S: Maintained | 6409 | S: Maintained |
| 6410 | F: kernel/futex.c | 6410 | F: kernel/futex.c |
| 6411 | F: kernel/futex_compat.c | ||
| 6412 | F: include/asm-generic/futex.h | 6411 | F: include/asm-generic/futex.h |
| 6413 | F: include/linux/futex.h | 6412 | F: include/linux/futex.h |
| 6414 | F: include/uapi/linux/futex.h | 6413 | F: include/uapi/linux/futex.h |
| @@ -31,26 +31,12 @@ _all: | |||
| 31 | # descending is started. They are now explicitly listed as the | 31 | # descending is started. They are now explicitly listed as the |
| 32 | # prepare rule. | 32 | # prepare rule. |
| 33 | 33 | ||
| 34 | # Ugly workaround for Debian make-kpkg: | 34 | ifneq ($(sub_make_done),1) |
| 35 | # make-kpkg directly includes the top Makefile of Linux kernel. In such a case, | ||
| 36 | # skip sub-make to support debian_* targets in ruleset/kernel_version.mk, but | ||
| 37 | # displays warning to discourage such abusage. | ||
| 38 | ifneq ($(word 2, $(MAKEFILE_LIST)),) | ||
| 39 | $(warning Do not include top Makefile of Linux Kernel) | ||
| 40 | sub-make-done := 1 | ||
| 41 | MAKEFLAGS += -rR | ||
| 42 | endif | ||
| 43 | |||
| 44 | ifneq ($(sub-make-done),1) | ||
| 45 | 35 | ||
| 46 | # Do not use make's built-in rules and variables | 36 | # Do not use make's built-in rules and variables |
| 47 | # (this increases performance and avoids hard-to-debug behaviour) | 37 | # (this increases performance and avoids hard-to-debug behaviour) |
| 48 | MAKEFLAGS += -rR | 38 | MAKEFLAGS += -rR |
| 49 | 39 | ||
| 50 | # 'MAKEFLAGS += -rR' does not become immediately effective for old | ||
| 51 | # GNU Make versions. Cancel implicit rules for this Makefile. | ||
| 52 | $(lastword $(MAKEFILE_LIST)): ; | ||
| 53 | |||
| 54 | # Avoid funny character set dependencies | 40 | # Avoid funny character set dependencies |
| 55 | unexport LC_ALL | 41 | unexport LC_ALL |
| 56 | LC_COLLATE=C | 42 | LC_COLLATE=C |
| @@ -153,6 +139,7 @@ $(if $(KBUILD_OUTPUT),, \ | |||
| 153 | # 'sub-make' below. | 139 | # 'sub-make' below. |
| 154 | MAKEFLAGS += --include-dir=$(CURDIR) | 140 | MAKEFLAGS += --include-dir=$(CURDIR) |
| 155 | 141 | ||
| 142 | need-sub-make := 1 | ||
| 156 | else | 143 | else |
| 157 | 144 | ||
| 158 | # Do not print "Entering directory ..." at all for in-tree build. | 145 | # Do not print "Entering directory ..." at all for in-tree build. |
| @@ -160,6 +147,18 @@ MAKEFLAGS += --no-print-directory | |||
| 160 | 147 | ||
| 161 | endif # ifneq ($(KBUILD_OUTPUT),) | 148 | endif # ifneq ($(KBUILD_OUTPUT),) |
| 162 | 149 | ||
| 150 | ifneq ($(filter 3.%,$(MAKE_VERSION)),) | ||
| 151 | # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x | ||
| 152 | # We need to invoke sub-make to avoid implicit rules in the top Makefile. | ||
| 153 | need-sub-make := 1 | ||
| 154 | # Cancel implicit rules for this Makefile. | ||
| 155 | $(lastword $(MAKEFILE_LIST)): ; | ||
| 156 | endif | ||
| 157 | |||
| 158 | export sub_make_done := 1 | ||
| 159 | |||
| 160 | ifeq ($(need-sub-make),1) | ||
| 161 | |||
| 163 | PHONY += $(MAKECMDGOALS) sub-make | 162 | PHONY += $(MAKECMDGOALS) sub-make |
| 164 | 163 | ||
| 165 | $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make | 164 | $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make |
| @@ -167,12 +166,15 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make | |||
| 167 | 166 | ||
| 168 | # Invoke a second make in the output directory, passing relevant variables | 167 | # Invoke a second make in the output directory, passing relevant variables |
| 169 | sub-make: | 168 | sub-make: |
| 170 | $(Q)$(MAKE) sub-make-done=1 \ | 169 | $(Q)$(MAKE) \ |
| 171 | $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ | 170 | $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ |
| 172 | -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) | 171 | -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) |
| 173 | 172 | ||
| 174 | else # sub-make-done | 173 | endif # need-sub-make |
| 174 | endif # sub_make_done | ||
| 175 | |||
| 175 | # We process the rest of the Makefile if this is the final invocation of make | 176 | # We process the rest of the Makefile if this is the final invocation of make |
| 177 | ifeq ($(need-sub-make),) | ||
| 176 | 178 | ||
| 177 | # Do not print "Entering directory ...", | 179 | # Do not print "Entering directory ...", |
| 178 | # but we want to display it when entering to the output directory | 180 | # but we want to display it when entering to the output directory |
| @@ -497,7 +499,8 @@ outputmakefile: | |||
| 497 | ifneq ($(KBUILD_SRC),) | 499 | ifneq ($(KBUILD_SRC),) |
| 498 | $(Q)ln -fsn $(srctree) source | 500 | $(Q)ln -fsn $(srctree) source |
| 499 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) | 501 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) |
| 500 | $(Q){ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore | 502 | $(Q)test -e .gitignore || \ |
| 503 | { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore | ||
| 501 | endif | 504 | endif |
| 502 | 505 | ||
| 503 | ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) | 506 | ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) |
| @@ -677,7 +680,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) | |||
| 677 | KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) | 680 | KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) |
| 678 | 681 | ||
| 679 | ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE | 682 | ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE |
| 680 | KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) | 683 | KBUILD_CFLAGS += -Os |
| 681 | else | 684 | else |
| 682 | KBUILD_CFLAGS += -O2 | 685 | KBUILD_CFLAGS += -O2 |
| 683 | endif | 686 | endif |
| @@ -950,9 +953,11 @@ mod_sign_cmd = true | |||
| 950 | endif | 953 | endif |
| 951 | export mod_sign_cmd | 954 | export mod_sign_cmd |
| 952 | 955 | ||
| 956 | HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) | ||
| 957 | |||
| 953 | ifdef CONFIG_STACK_VALIDATION | 958 | ifdef CONFIG_STACK_VALIDATION |
| 954 | has_libelf := $(call try-run,\ | 959 | has_libelf := $(call try-run,\ |
| 955 | echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0) | 960 | echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0) |
| 956 | ifeq ($(has_libelf),1) | 961 | ifeq ($(has_libelf),1) |
| 957 | objtool_target := tools/objtool FORCE | 962 | objtool_target := tools/objtool FORCE |
| 958 | else | 963 | else |
| @@ -1757,7 +1762,7 @@ existing-targets := $(wildcard $(sort $(targets))) | |||
| 1757 | 1762 | ||
| 1758 | endif # ifeq ($(config-targets),1) | 1763 | endif # ifeq ($(config-targets),1) |
| 1759 | endif # ifeq ($(mixed-targets),1) | 1764 | endif # ifeq ($(mixed-targets),1) |
| 1760 | endif # sub-make-done | 1765 | endif # need-sub-make |
| 1761 | 1766 | ||
| 1762 | PHONY += FORCE | 1767 | PHONY += FORCE |
| 1763 | FORCE: | 1768 | FORCE: |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 054ead960f98..850b4805e2d1 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -596,6 +596,7 @@ config ARCH_DAVINCI | |||
| 596 | select HAVE_IDE | 596 | select HAVE_IDE |
| 597 | select PM_GENERIC_DOMAINS if PM | 597 | select PM_GENERIC_DOMAINS if PM |
| 598 | select PM_GENERIC_DOMAINS_OF if PM && OF | 598 | select PM_GENERIC_DOMAINS_OF if PM && OF |
| 599 | select REGMAP_MMIO | ||
| 599 | select RESET_CONTROLLER | 600 | select RESET_CONTROLLER |
| 600 | select SPARSE_IRQ | 601 | select SPARSE_IRQ |
| 601 | select USE_OF | 602 | select USE_OF |
diff --git a/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts b/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts index 5641d162dfdb..28e7513ce617 100644 --- a/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts +++ b/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts | |||
| @@ -93,7 +93,7 @@ | |||
| 93 | }; | 93 | }; |
| 94 | 94 | ||
| 95 | &hdmi { | 95 | &hdmi { |
| 96 | hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>; | 96 | hpd-gpios = <&gpio 46 GPIO_ACTIVE_HIGH>; |
| 97 | }; | 97 | }; |
| 98 | 98 | ||
| 99 | &pwm { | 99 | &pwm { |
diff --git a/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi b/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi index b715ab0fa1ff..e8d800fec637 100644 --- a/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi +++ b/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi | |||
| @@ -114,9 +114,9 @@ | |||
| 114 | reg = <2>; | 114 | reg = <2>; |
| 115 | }; | 115 | }; |
| 116 | 116 | ||
| 117 | switch@0 { | 117 | switch@10 { |
| 118 | compatible = "qca,qca8334"; | 118 | compatible = "qca,qca8334"; |
| 119 | reg = <0>; | 119 | reg = <10>; |
| 120 | 120 | ||
| 121 | switch_ports: ports { | 121 | switch_ports: ports { |
| 122 | #address-cells = <1>; | 122 | #address-cells = <1>; |
| @@ -125,7 +125,7 @@ | |||
| 125 | ethphy0: port@0 { | 125 | ethphy0: port@0 { |
| 126 | reg = <0>; | 126 | reg = <0>; |
| 127 | label = "cpu"; | 127 | label = "cpu"; |
| 128 | phy-mode = "rgmii"; | 128 | phy-mode = "rgmii-id"; |
| 129 | ethernet = <&fec>; | 129 | ethernet = <&fec>; |
| 130 | 130 | ||
| 131 | fixed-link { | 131 | fixed-link { |
diff --git a/arch/arm/boot/dts/imx6qdl-icore-rqs.dtsi b/arch/arm/boot/dts/imx6qdl-icore-rqs.dtsi index 1d1b4bd0670f..a4217f564a53 100644 --- a/arch/arm/boot/dts/imx6qdl-icore-rqs.dtsi +++ b/arch/arm/boot/dts/imx6qdl-icore-rqs.dtsi | |||
| @@ -264,7 +264,7 @@ | |||
| 264 | pinctrl-2 = <&pinctrl_usdhc3_200mhz>; | 264 | pinctrl-2 = <&pinctrl_usdhc3_200mhz>; |
| 265 | vmcc-supply = <®_sd3_vmmc>; | 265 | vmcc-supply = <®_sd3_vmmc>; |
| 266 | cd-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>; | 266 | cd-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>; |
| 267 | bus-witdh = <4>; | 267 | bus-width = <4>; |
| 268 | no-1-8-v; | 268 | no-1-8-v; |
| 269 | status = "okay"; | 269 | status = "okay"; |
| 270 | }; | 270 | }; |
| @@ -275,7 +275,7 @@ | |||
| 275 | pinctrl-1 = <&pinctrl_usdhc4_100mhz>; | 275 | pinctrl-1 = <&pinctrl_usdhc4_100mhz>; |
| 276 | pinctrl-2 = <&pinctrl_usdhc4_200mhz>; | 276 | pinctrl-2 = <&pinctrl_usdhc4_200mhz>; |
| 277 | vmcc-supply = <®_sd4_vmmc>; | 277 | vmcc-supply = <®_sd4_vmmc>; |
| 278 | bus-witdh = <8>; | 278 | bus-width = <8>; |
| 279 | no-1-8-v; | 279 | no-1-8-v; |
| 280 | non-removable; | 280 | non-removable; |
| 281 | status = "okay"; | 281 | status = "okay"; |
diff --git a/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi b/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi index 433bf09a1954..027df06c5dc7 100644 --- a/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi +++ b/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi | |||
| @@ -91,6 +91,7 @@ | |||
| 91 | pinctrl-0 = <&pinctrl_enet>; | 91 | pinctrl-0 = <&pinctrl_enet>; |
| 92 | phy-handle = <ðphy>; | 92 | phy-handle = <ðphy>; |
| 93 | phy-mode = "rgmii"; | 93 | phy-mode = "rgmii"; |
| 94 | phy-reset-duration = <10>; /* in msecs */ | ||
| 94 | phy-reset-gpios = <&gpio3 23 GPIO_ACTIVE_LOW>; | 95 | phy-reset-gpios = <&gpio3 23 GPIO_ACTIVE_LOW>; |
| 95 | phy-supply = <&vdd_eth_io_reg>; | 96 | phy-supply = <&vdd_eth_io_reg>; |
| 96 | status = "disabled"; | 97 | status = "disabled"; |
diff --git a/arch/arm/boot/dts/imx6ull-pinfunc-snvs.h b/arch/arm/boot/dts/imx6ull-pinfunc-snvs.h index f6fb6783c193..54cfe72295aa 100644 --- a/arch/arm/boot/dts/imx6ull-pinfunc-snvs.h +++ b/arch/arm/boot/dts/imx6ull-pinfunc-snvs.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (C) 2016 Freescale Semiconductor, Inc. | 3 | * Copyright (C) 2016 Freescale Semiconductor, Inc. |
| 4 | * Copyright (C) 2017 NXP | 4 | * Copyright (C) 2017 NXP |
diff --git a/arch/arm/boot/dts/ste-nomadik-nhk15.dts b/arch/arm/boot/dts/ste-nomadik-nhk15.dts index 04066f9cb8a3..f2f6558a00f1 100644 --- a/arch/arm/boot/dts/ste-nomadik-nhk15.dts +++ b/arch/arm/boot/dts/ste-nomadik-nhk15.dts | |||
| @@ -213,12 +213,13 @@ | |||
| 213 | gpio-sck = <&gpio0 5 GPIO_ACTIVE_HIGH>; | 213 | gpio-sck = <&gpio0 5 GPIO_ACTIVE_HIGH>; |
| 214 | gpio-mosi = <&gpio0 4 GPIO_ACTIVE_HIGH>; | 214 | gpio-mosi = <&gpio0 4 GPIO_ACTIVE_HIGH>; |
| 215 | /* | 215 | /* |
| 216 | * It's not actually active high, but the frameworks assume | 216 | * This chipselect is active high. Just setting the flags |
| 217 | * the polarity of the passed-in GPIO is "normal" (active | 217 | * to GPIO_ACTIVE_HIGH is not enough for the SPI DT bindings, |
| 218 | * high) then actively drives the line low to select the | 218 | * it will be ignored, only the special "spi-cs-high" flag |
| 219 | * chip. | 219 | * really counts. |
| 220 | */ | 220 | */ |
| 221 | cs-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; | 221 | cs-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; |
| 222 | spi-cs-high; | ||
| 222 | num-chipselects = <1>; | 223 | num-chipselects = <1>; |
| 223 | 224 | ||
| 224 | /* | 225 | /* |
diff --git a/arch/arm/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig index 8661dd9b064a..b37f8e675e40 100644 --- a/arch/arm/configs/imx_v4_v5_defconfig +++ b/arch/arm/configs/imx_v4_v5_defconfig | |||
| @@ -170,6 +170,9 @@ CONFIG_IMX_SDMA=y | |||
| 170 | # CONFIG_IOMMU_SUPPORT is not set | 170 | # CONFIG_IOMMU_SUPPORT is not set |
| 171 | CONFIG_IIO=y | 171 | CONFIG_IIO=y |
| 172 | CONFIG_FSL_MX25_ADC=y | 172 | CONFIG_FSL_MX25_ADC=y |
| 173 | CONFIG_PWM=y | ||
| 174 | CONFIG_PWM_IMX1=y | ||
| 175 | CONFIG_PWM_IMX27=y | ||
| 173 | CONFIG_EXT4_FS=y | 176 | CONFIG_EXT4_FS=y |
| 174 | # CONFIG_DNOTIFY is not set | 177 | # CONFIG_DNOTIFY is not set |
| 175 | CONFIG_VFAT_FS=y | 178 | CONFIG_VFAT_FS=y |
diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig index 5586a5074a96..50fb01d70b10 100644 --- a/arch/arm/configs/imx_v6_v7_defconfig +++ b/arch/arm/configs/imx_v6_v7_defconfig | |||
| @@ -398,7 +398,7 @@ CONFIG_MAG3110=y | |||
| 398 | CONFIG_MPL3115=y | 398 | CONFIG_MPL3115=y |
| 399 | CONFIG_PWM=y | 399 | CONFIG_PWM=y |
| 400 | CONFIG_PWM_FSL_FTM=y | 400 | CONFIG_PWM_FSL_FTM=y |
| 401 | CONFIG_PWM_IMX=y | 401 | CONFIG_PWM_IMX27=y |
| 402 | CONFIG_NVMEM_IMX_OCOTP=y | 402 | CONFIG_NVMEM_IMX_OCOTP=y |
| 403 | CONFIG_NVMEM_VF610_OCOTP=y | 403 | CONFIG_NVMEM_VF610_OCOTP=y |
| 404 | CONFIG_TEE=y | 404 | CONFIG_TEE=y |
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c index bfeb25aaf9a2..326e870d7123 100644 --- a/arch/arm/mach-imx/cpuidle-imx6q.c +++ b/arch/arm/mach-imx/cpuidle-imx6q.c | |||
| @@ -16,30 +16,23 @@ | |||
| 16 | #include "cpuidle.h" | 16 | #include "cpuidle.h" |
| 17 | #include "hardware.h" | 17 | #include "hardware.h" |
| 18 | 18 | ||
| 19 | static atomic_t master = ATOMIC_INIT(0); | 19 | static int num_idle_cpus = 0; |
| 20 | static DEFINE_SPINLOCK(master_lock); | 20 | static DEFINE_SPINLOCK(cpuidle_lock); |
| 21 | 21 | ||
| 22 | static int imx6q_enter_wait(struct cpuidle_device *dev, | 22 | static int imx6q_enter_wait(struct cpuidle_device *dev, |
| 23 | struct cpuidle_driver *drv, int index) | 23 | struct cpuidle_driver *drv, int index) |
| 24 | { | 24 | { |
| 25 | if (atomic_inc_return(&master) == num_online_cpus()) { | 25 | spin_lock(&cpuidle_lock); |
| 26 | /* | 26 | if (++num_idle_cpus == num_online_cpus()) |
| 27 | * With this lock, we prevent other cpu to exit and enter | ||
| 28 | * this function again and become the master. | ||
| 29 | */ | ||
| 30 | if (!spin_trylock(&master_lock)) | ||
| 31 | goto idle; | ||
| 32 | imx6_set_lpm(WAIT_UNCLOCKED); | 27 | imx6_set_lpm(WAIT_UNCLOCKED); |
| 33 | cpu_do_idle(); | 28 | spin_unlock(&cpuidle_lock); |
| 34 | imx6_set_lpm(WAIT_CLOCKED); | ||
| 35 | spin_unlock(&master_lock); | ||
| 36 | goto done; | ||
| 37 | } | ||
| 38 | 29 | ||
| 39 | idle: | ||
| 40 | cpu_do_idle(); | 30 | cpu_do_idle(); |
| 41 | done: | 31 | |
| 42 | atomic_dec(&master); | 32 | spin_lock(&cpuidle_lock); |
| 33 | if (num_idle_cpus-- == num_online_cpus()) | ||
| 34 | imx6_set_lpm(WAIT_CLOCKED); | ||
| 35 | spin_unlock(&cpuidle_lock); | ||
| 43 | 36 | ||
| 44 | return index; | 37 | return index; |
| 45 | } | 38 | } |
diff --git a/arch/arm/mach-imx/mach-imx51.c b/arch/arm/mach-imx/mach-imx51.c index c7169c2f94c4..08c7892866c2 100644 --- a/arch/arm/mach-imx/mach-imx51.c +++ b/arch/arm/mach-imx/mach-imx51.c | |||
| @@ -59,6 +59,7 @@ static void __init imx51_m4if_setup(void) | |||
| 59 | return; | 59 | return; |
| 60 | 60 | ||
| 61 | m4if_base = of_iomap(np, 0); | 61 | m4if_base = of_iomap(np, 0); |
| 62 | of_node_put(np); | ||
| 62 | if (!m4if_base) { | 63 | if (!m4if_base) { |
| 63 | pr_err("Unable to map M4IF registers\n"); | 64 | pr_err("Unable to map M4IF registers\n"); |
| 64 | return; | 65 | return; |
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms index 70498a033cf5..b5ca9c50876d 100644 --- a/arch/arm64/Kconfig.platforms +++ b/arch/arm64/Kconfig.platforms | |||
| @@ -27,6 +27,7 @@ config ARCH_BCM2835 | |||
| 27 | bool "Broadcom BCM2835 family" | 27 | bool "Broadcom BCM2835 family" |
| 28 | select TIMER_OF | 28 | select TIMER_OF |
| 29 | select GPIOLIB | 29 | select GPIOLIB |
| 30 | select MFD_CORE | ||
| 30 | select PINCTRL | 31 | select PINCTRL |
| 31 | select PINCTRL_BCM2835 | 32 | select PINCTRL_BCM2835 |
| 32 | select ARM_AMBA | 33 | select ARM_AMBA |
diff --git a/arch/arm64/boot/dts/nvidia/tegra186.dtsi b/arch/arm64/boot/dts/nvidia/tegra186.dtsi index bb2045be8814..97aeb946ed5e 100644 --- a/arch/arm64/boot/dts/nvidia/tegra186.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra186.dtsi | |||
| @@ -321,7 +321,6 @@ | |||
| 321 | nvidia,default-trim = <0x9>; | 321 | nvidia,default-trim = <0x9>; |
| 322 | nvidia,dqs-trim = <63>; | 322 | nvidia,dqs-trim = <63>; |
| 323 | mmc-hs400-1_8v; | 323 | mmc-hs400-1_8v; |
| 324 | supports-cqe; | ||
| 325 | status = "disabled"; | 324 | status = "disabled"; |
| 326 | }; | 325 | }; |
| 327 | 326 | ||
diff --git a/arch/arm64/boot/dts/renesas/r8a774c0.dtsi b/arch/arm64/boot/dts/renesas/r8a774c0.dtsi index 61a0afb74e63..1ea684af99c4 100644 --- a/arch/arm64/boot/dts/renesas/r8a774c0.dtsi +++ b/arch/arm64/boot/dts/renesas/r8a774c0.dtsi | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Device Tree Source for the RZ/G2E (R8A774C0) SoC | 3 | * Device Tree Source for the RZ/G2E (R8A774C0) SoC |
| 4 | * | 4 | * |
| 5 | * Copyright (C) 2018 Renesas Electronics Corp. | 5 | * Copyright (C) 2018-2019 Renesas Electronics Corp. |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #include <dt-bindings/clock/r8a774c0-cpg-mssr.h> | 8 | #include <dt-bindings/clock/r8a774c0-cpg-mssr.h> |
| @@ -1150,9 +1150,8 @@ | |||
| 1150 | <&cpg CPG_CORE R8A774C0_CLK_S3D1C>, | 1150 | <&cpg CPG_CORE R8A774C0_CLK_S3D1C>, |
| 1151 | <&scif_clk>; | 1151 | <&scif_clk>; |
| 1152 | clock-names = "fck", "brg_int", "scif_clk"; | 1152 | clock-names = "fck", "brg_int", "scif_clk"; |
| 1153 | dmas = <&dmac1 0x5b>, <&dmac1 0x5a>, | 1153 | dmas = <&dmac0 0x5b>, <&dmac0 0x5a>; |
| 1154 | <&dmac2 0x5b>, <&dmac2 0x5a>; | 1154 | dma-names = "tx", "rx"; |
| 1155 | dma-names = "tx", "rx", "tx", "rx"; | ||
| 1156 | power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; | 1155 | power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; |
| 1157 | resets = <&cpg 202>; | 1156 | resets = <&cpg 202>; |
| 1158 | status = "disabled"; | 1157 | status = "disabled"; |
diff --git a/arch/arm64/boot/dts/renesas/r8a77990.dtsi b/arch/arm64/boot/dts/renesas/r8a77990.dtsi index a69faa60ea4d..d2ad665fe2d9 100644 --- a/arch/arm64/boot/dts/renesas/r8a77990.dtsi +++ b/arch/arm64/boot/dts/renesas/r8a77990.dtsi | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Device Tree Source for the R-Car E3 (R8A77990) SoC | 3 | * Device Tree Source for the R-Car E3 (R8A77990) SoC |
| 4 | * | 4 | * |
| 5 | * Copyright (C) 2018 Renesas Electronics Corp. | 5 | * Copyright (C) 2018-2019 Renesas Electronics Corp. |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #include <dt-bindings/clock/r8a77990-cpg-mssr.h> | 8 | #include <dt-bindings/clock/r8a77990-cpg-mssr.h> |
| @@ -1067,9 +1067,8 @@ | |||
| 1067 | <&cpg CPG_CORE R8A77990_CLK_S3D1C>, | 1067 | <&cpg CPG_CORE R8A77990_CLK_S3D1C>, |
| 1068 | <&scif_clk>; | 1068 | <&scif_clk>; |
| 1069 | clock-names = "fck", "brg_int", "scif_clk"; | 1069 | clock-names = "fck", "brg_int", "scif_clk"; |
| 1070 | dmas = <&dmac1 0x5b>, <&dmac1 0x5a>, | 1070 | dmas = <&dmac0 0x5b>, <&dmac0 0x5a>; |
| 1071 | <&dmac2 0x5b>, <&dmac2 0x5a>; | 1071 | dma-names = "tx", "rx"; |
| 1072 | dma-names = "tx", "rx", "tx", "rx"; | ||
| 1073 | power-domains = <&sysc R8A77990_PD_ALWAYS_ON>; | 1072 | power-domains = <&sysc R8A77990_PD_ALWAYS_ON>; |
| 1074 | resets = <&cpg 202>; | 1073 | resets = <&cpg 202>; |
| 1075 | status = "disabled"; | 1074 | status = "disabled"; |
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index f8482fe5a190..413d566405d1 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c | |||
| @@ -217,7 +217,7 @@ static void __init request_standard_resources(void) | |||
| 217 | 217 | ||
| 218 | num_standard_resources = memblock.memory.cnt; | 218 | num_standard_resources = memblock.memory.cnt; |
| 219 | res_size = num_standard_resources * sizeof(*standard_resources); | 219 | res_size = num_standard_resources * sizeof(*standard_resources); |
| 220 | standard_resources = memblock_alloc_low(res_size, SMP_CACHE_BYTES); | 220 | standard_resources = memblock_alloc(res_size, SMP_CACHE_BYTES); |
| 221 | if (!standard_resources) | 221 | if (!standard_resources) |
| 222 | panic("%s: Failed to allocate %zu bytes\n", __func__, res_size); | 222 | panic("%s: Failed to allocate %zu bytes\n", __func__, res_size); |
| 223 | 223 | ||
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h index c5698a523bb1..23f7ed796f38 100644 --- a/arch/powerpc/include/asm/ppc-opcode.h +++ b/arch/powerpc/include/asm/ppc-opcode.h | |||
| @@ -302,6 +302,7 @@ | |||
| 302 | /* Misc instructions for BPF compiler */ | 302 | /* Misc instructions for BPF compiler */ |
| 303 | #define PPC_INST_LBZ 0x88000000 | 303 | #define PPC_INST_LBZ 0x88000000 |
| 304 | #define PPC_INST_LD 0xe8000000 | 304 | #define PPC_INST_LD 0xe8000000 |
| 305 | #define PPC_INST_LDX 0x7c00002a | ||
| 305 | #define PPC_INST_LHZ 0xa0000000 | 306 | #define PPC_INST_LHZ 0xa0000000 |
| 306 | #define PPC_INST_LWZ 0x80000000 | 307 | #define PPC_INST_LWZ 0x80000000 |
| 307 | #define PPC_INST_LHBRX 0x7c00062c | 308 | #define PPC_INST_LHBRX 0x7c00062c |
| @@ -309,6 +310,7 @@ | |||
| 309 | #define PPC_INST_STB 0x98000000 | 310 | #define PPC_INST_STB 0x98000000 |
| 310 | #define PPC_INST_STH 0xb0000000 | 311 | #define PPC_INST_STH 0xb0000000 |
| 311 | #define PPC_INST_STD 0xf8000000 | 312 | #define PPC_INST_STD 0xf8000000 |
| 313 | #define PPC_INST_STDX 0x7c00012a | ||
| 312 | #define PPC_INST_STDU 0xf8000001 | 314 | #define PPC_INST_STDU 0xf8000001 |
| 313 | #define PPC_INST_STW 0x90000000 | 315 | #define PPC_INST_STW 0x90000000 |
| 314 | #define PPC_INST_STWU 0x94000000 | 316 | #define PPC_INST_STWU 0x94000000 |
diff --git a/arch/powerpc/lib/memcmp_64.S b/arch/powerpc/lib/memcmp_64.S index 844d8e774492..b7f6f6e0b6e8 100644 --- a/arch/powerpc/lib/memcmp_64.S +++ b/arch/powerpc/lib/memcmp_64.S | |||
| @@ -215,11 +215,20 @@ _GLOBAL_TOC(memcmp) | |||
| 215 | beq .Lzero | 215 | beq .Lzero |
| 216 | 216 | ||
| 217 | .Lcmp_rest_lt8bytes: | 217 | .Lcmp_rest_lt8bytes: |
| 218 | /* Here we have only less than 8 bytes to compare with. at least s1 | 218 | /* |
| 219 | * Address is aligned with 8 bytes. | 219 | * Here we have less than 8 bytes to compare. At least s1 is aligned to |
| 220 | * The next double words are load and shift right with appropriate | 220 | * 8 bytes, but s2 may not be. We must make sure s2 + 7 doesn't cross a |
| 221 | * bits. | 221 | * page boundary, otherwise we might read past the end of the buffer and |
| 222 | * trigger a page fault. We use 4K as the conservative minimum page | ||
| 223 | * size. If we detect that case we go to the byte-by-byte loop. | ||
| 224 | * | ||
| 225 | * Otherwise the next double word is loaded from s1 and s2, and shifted | ||
| 226 | * right to compare the appropriate bits. | ||
| 222 | */ | 227 | */ |
| 228 | clrldi r6,r4,(64-12) // r6 = r4 & 0xfff | ||
| 229 | cmpdi r6,0xff8 | ||
| 230 | bgt .Lshort | ||
| 231 | |||
| 223 | subfic r6,r5,8 | 232 | subfic r6,r5,8 |
| 224 | slwi r6,r6,3 | 233 | slwi r6,r6,3 |
| 225 | LD rA,0,r3 | 234 | LD rA,0,r3 |
diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h index 549e9490ff2a..dcac37745b05 100644 --- a/arch/powerpc/net/bpf_jit.h +++ b/arch/powerpc/net/bpf_jit.h | |||
| @@ -51,6 +51,8 @@ | |||
| 51 | #define PPC_LIS(r, i) PPC_ADDIS(r, 0, i) | 51 | #define PPC_LIS(r, i) PPC_ADDIS(r, 0, i) |
| 52 | #define PPC_STD(r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \ | 52 | #define PPC_STD(r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \ |
| 53 | ___PPC_RA(base) | ((i) & 0xfffc)) | 53 | ___PPC_RA(base) | ((i) & 0xfffc)) |
| 54 | #define PPC_STDX(r, base, b) EMIT(PPC_INST_STDX | ___PPC_RS(r) | \ | ||
| 55 | ___PPC_RA(base) | ___PPC_RB(b)) | ||
| 54 | #define PPC_STDU(r, base, i) EMIT(PPC_INST_STDU | ___PPC_RS(r) | \ | 56 | #define PPC_STDU(r, base, i) EMIT(PPC_INST_STDU | ___PPC_RS(r) | \ |
| 55 | ___PPC_RA(base) | ((i) & 0xfffc)) | 57 | ___PPC_RA(base) | ((i) & 0xfffc)) |
| 56 | #define PPC_STW(r, base, i) EMIT(PPC_INST_STW | ___PPC_RS(r) | \ | 58 | #define PPC_STW(r, base, i) EMIT(PPC_INST_STW | ___PPC_RS(r) | \ |
| @@ -65,7 +67,9 @@ | |||
| 65 | #define PPC_LBZ(r, base, i) EMIT(PPC_INST_LBZ | ___PPC_RT(r) | \ | 67 | #define PPC_LBZ(r, base, i) EMIT(PPC_INST_LBZ | ___PPC_RT(r) | \ |
| 66 | ___PPC_RA(base) | IMM_L(i)) | 68 | ___PPC_RA(base) | IMM_L(i)) |
| 67 | #define PPC_LD(r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \ | 69 | #define PPC_LD(r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \ |
| 68 | ___PPC_RA(base) | IMM_L(i)) | 70 | ___PPC_RA(base) | ((i) & 0xfffc)) |
| 71 | #define PPC_LDX(r, base, b) EMIT(PPC_INST_LDX | ___PPC_RT(r) | \ | ||
| 72 | ___PPC_RA(base) | ___PPC_RB(b)) | ||
| 69 | #define PPC_LWZ(r, base, i) EMIT(PPC_INST_LWZ | ___PPC_RT(r) | \ | 73 | #define PPC_LWZ(r, base, i) EMIT(PPC_INST_LWZ | ___PPC_RT(r) | \ |
| 70 | ___PPC_RA(base) | IMM_L(i)) | 74 | ___PPC_RA(base) | IMM_L(i)) |
| 71 | #define PPC_LHZ(r, base, i) EMIT(PPC_INST_LHZ | ___PPC_RT(r) | \ | 75 | #define PPC_LHZ(r, base, i) EMIT(PPC_INST_LHZ | ___PPC_RT(r) | \ |
| @@ -85,17 +89,6 @@ | |||
| 85 | ___PPC_RA(a) | ___PPC_RB(b)) | 89 | ___PPC_RA(a) | ___PPC_RB(b)) |
| 86 | #define PPC_BPF_STDCX(s, a, b) EMIT(PPC_INST_STDCX | ___PPC_RS(s) | \ | 90 | #define PPC_BPF_STDCX(s, a, b) EMIT(PPC_INST_STDCX | ___PPC_RS(s) | \ |
| 87 | ___PPC_RA(a) | ___PPC_RB(b)) | 91 | ___PPC_RA(a) | ___PPC_RB(b)) |
| 88 | |||
| 89 | #ifdef CONFIG_PPC64 | ||
| 90 | #define PPC_BPF_LL(r, base, i) do { PPC_LD(r, base, i); } while(0) | ||
| 91 | #define PPC_BPF_STL(r, base, i) do { PPC_STD(r, base, i); } while(0) | ||
| 92 | #define PPC_BPF_STLU(r, base, i) do { PPC_STDU(r, base, i); } while(0) | ||
| 93 | #else | ||
| 94 | #define PPC_BPF_LL(r, base, i) do { PPC_LWZ(r, base, i); } while(0) | ||
| 95 | #define PPC_BPF_STL(r, base, i) do { PPC_STW(r, base, i); } while(0) | ||
| 96 | #define PPC_BPF_STLU(r, base, i) do { PPC_STWU(r, base, i); } while(0) | ||
| 97 | #endif | ||
| 98 | |||
| 99 | #define PPC_CMPWI(a, i) EMIT(PPC_INST_CMPWI | ___PPC_RA(a) | IMM_L(i)) | 92 | #define PPC_CMPWI(a, i) EMIT(PPC_INST_CMPWI | ___PPC_RA(a) | IMM_L(i)) |
| 100 | #define PPC_CMPDI(a, i) EMIT(PPC_INST_CMPDI | ___PPC_RA(a) | IMM_L(i)) | 93 | #define PPC_CMPDI(a, i) EMIT(PPC_INST_CMPDI | ___PPC_RA(a) | IMM_L(i)) |
| 101 | #define PPC_CMPW(a, b) EMIT(PPC_INST_CMPW | ___PPC_RA(a) | \ | 94 | #define PPC_CMPW(a, b) EMIT(PPC_INST_CMPW | ___PPC_RA(a) | \ |
diff --git a/arch/powerpc/net/bpf_jit32.h b/arch/powerpc/net/bpf_jit32.h index dc50a8d4b3b9..21744d8aa053 100644 --- a/arch/powerpc/net/bpf_jit32.h +++ b/arch/powerpc/net/bpf_jit32.h | |||
| @@ -122,6 +122,10 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh); | |||
| 122 | #define PPC_NTOHS_OFFS(r, base, i) PPC_LHZ_OFFS(r, base, i) | 122 | #define PPC_NTOHS_OFFS(r, base, i) PPC_LHZ_OFFS(r, base, i) |
| 123 | #endif | 123 | #endif |
| 124 | 124 | ||
| 125 | #define PPC_BPF_LL(r, base, i) do { PPC_LWZ(r, base, i); } while(0) | ||
| 126 | #define PPC_BPF_STL(r, base, i) do { PPC_STW(r, base, i); } while(0) | ||
| 127 | #define PPC_BPF_STLU(r, base, i) do { PPC_STWU(r, base, i); } while(0) | ||
| 128 | |||
| 125 | #define SEEN_DATAREF 0x10000 /* might call external helpers */ | 129 | #define SEEN_DATAREF 0x10000 /* might call external helpers */ |
| 126 | #define SEEN_XREG 0x20000 /* X reg is used */ | 130 | #define SEEN_XREG 0x20000 /* X reg is used */ |
| 127 | #define SEEN_MEM 0x40000 /* SEEN_MEM+(1<<n) = use mem[n] for temporary | 131 | #define SEEN_MEM 0x40000 /* SEEN_MEM+(1<<n) = use mem[n] for temporary |
diff --git a/arch/powerpc/net/bpf_jit64.h b/arch/powerpc/net/bpf_jit64.h index 3609be4692b3..47f441f351a6 100644 --- a/arch/powerpc/net/bpf_jit64.h +++ b/arch/powerpc/net/bpf_jit64.h | |||
| @@ -68,6 +68,26 @@ static const int b2p[] = { | |||
| 68 | /* PPC NVR range -- update this if we ever use NVRs below r27 */ | 68 | /* PPC NVR range -- update this if we ever use NVRs below r27 */ |
| 69 | #define BPF_PPC_NVR_MIN 27 | 69 | #define BPF_PPC_NVR_MIN 27 |
| 70 | 70 | ||
| 71 | /* | ||
| 72 | * WARNING: These can use TMP_REG_2 if the offset is not at word boundary, | ||
| 73 | * so ensure that it isn't in use already. | ||
| 74 | */ | ||
| 75 | #define PPC_BPF_LL(r, base, i) do { \ | ||
| 76 | if ((i) % 4) { \ | ||
| 77 | PPC_LI(b2p[TMP_REG_2], (i)); \ | ||
| 78 | PPC_LDX(r, base, b2p[TMP_REG_2]); \ | ||
| 79 | } else \ | ||
| 80 | PPC_LD(r, base, i); \ | ||
| 81 | } while(0) | ||
| 82 | #define PPC_BPF_STL(r, base, i) do { \ | ||
| 83 | if ((i) % 4) { \ | ||
| 84 | PPC_LI(b2p[TMP_REG_2], (i)); \ | ||
| 85 | PPC_STDX(r, base, b2p[TMP_REG_2]); \ | ||
| 86 | } else \ | ||
| 87 | PPC_STD(r, base, i); \ | ||
| 88 | } while(0) | ||
| 89 | #define PPC_BPF_STLU(r, base, i) do { PPC_STDU(r, base, i); } while(0) | ||
| 90 | |||
| 71 | #define SEEN_FUNC 0x1000 /* might call external helpers */ | 91 | #define SEEN_FUNC 0x1000 /* might call external helpers */ |
| 72 | #define SEEN_STACK 0x2000 /* uses BPF stack */ | 92 | #define SEEN_STACK 0x2000 /* uses BPF stack */ |
| 73 | #define SEEN_TAILCALL 0x4000 /* uses tail calls */ | 93 | #define SEEN_TAILCALL 0x4000 /* uses tail calls */ |
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c index 4194d3cfb60c..21a1dcd4b156 100644 --- a/arch/powerpc/net/bpf_jit_comp64.c +++ b/arch/powerpc/net/bpf_jit_comp64.c | |||
| @@ -252,7 +252,7 @@ static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 | |||
| 252 | * if (tail_call_cnt > MAX_TAIL_CALL_CNT) | 252 | * if (tail_call_cnt > MAX_TAIL_CALL_CNT) |
| 253 | * goto out; | 253 | * goto out; |
| 254 | */ | 254 | */ |
| 255 | PPC_LD(b2p[TMP_REG_1], 1, bpf_jit_stack_tailcallcnt(ctx)); | 255 | PPC_BPF_LL(b2p[TMP_REG_1], 1, bpf_jit_stack_tailcallcnt(ctx)); |
| 256 | PPC_CMPLWI(b2p[TMP_REG_1], MAX_TAIL_CALL_CNT); | 256 | PPC_CMPLWI(b2p[TMP_REG_1], MAX_TAIL_CALL_CNT); |
| 257 | PPC_BCC(COND_GT, out); | 257 | PPC_BCC(COND_GT, out); |
| 258 | 258 | ||
| @@ -265,7 +265,7 @@ static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 | |||
| 265 | /* prog = array->ptrs[index]; */ | 265 | /* prog = array->ptrs[index]; */ |
| 266 | PPC_MULI(b2p[TMP_REG_1], b2p_index, 8); | 266 | PPC_MULI(b2p[TMP_REG_1], b2p_index, 8); |
| 267 | PPC_ADD(b2p[TMP_REG_1], b2p[TMP_REG_1], b2p_bpf_array); | 267 | PPC_ADD(b2p[TMP_REG_1], b2p[TMP_REG_1], b2p_bpf_array); |
| 268 | PPC_LD(b2p[TMP_REG_1], b2p[TMP_REG_1], offsetof(struct bpf_array, ptrs)); | 268 | PPC_BPF_LL(b2p[TMP_REG_1], b2p[TMP_REG_1], offsetof(struct bpf_array, ptrs)); |
| 269 | 269 | ||
| 270 | /* | 270 | /* |
| 271 | * if (prog == NULL) | 271 | * if (prog == NULL) |
| @@ -275,7 +275,7 @@ static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 | |||
| 275 | PPC_BCC(COND_EQ, out); | 275 | PPC_BCC(COND_EQ, out); |
| 276 | 276 | ||
| 277 | /* goto *(prog->bpf_func + prologue_size); */ | 277 | /* goto *(prog->bpf_func + prologue_size); */ |
| 278 | PPC_LD(b2p[TMP_REG_1], b2p[TMP_REG_1], offsetof(struct bpf_prog, bpf_func)); | 278 | PPC_BPF_LL(b2p[TMP_REG_1], b2p[TMP_REG_1], offsetof(struct bpf_prog, bpf_func)); |
| 279 | #ifdef PPC64_ELF_ABI_v1 | 279 | #ifdef PPC64_ELF_ABI_v1 |
| 280 | /* skip past the function descriptor */ | 280 | /* skip past the function descriptor */ |
| 281 | PPC_ADDI(b2p[TMP_REG_1], b2p[TMP_REG_1], | 281 | PPC_ADDI(b2p[TMP_REG_1], b2p[TMP_REG_1], |
| @@ -606,7 +606,7 @@ bpf_alu32_trunc: | |||
| 606 | * the instructions generated will remain the | 606 | * the instructions generated will remain the |
| 607 | * same across all passes | 607 | * same across all passes |
| 608 | */ | 608 | */ |
| 609 | PPC_STD(dst_reg, 1, bpf_jit_stack_local(ctx)); | 609 | PPC_BPF_STL(dst_reg, 1, bpf_jit_stack_local(ctx)); |
| 610 | PPC_ADDI(b2p[TMP_REG_1], 1, bpf_jit_stack_local(ctx)); | 610 | PPC_ADDI(b2p[TMP_REG_1], 1, bpf_jit_stack_local(ctx)); |
| 611 | PPC_LDBRX(dst_reg, 0, b2p[TMP_REG_1]); | 611 | PPC_LDBRX(dst_reg, 0, b2p[TMP_REG_1]); |
| 612 | break; | 612 | break; |
| @@ -662,7 +662,7 @@ emit_clear: | |||
| 662 | PPC_LI32(b2p[TMP_REG_1], imm); | 662 | PPC_LI32(b2p[TMP_REG_1], imm); |
| 663 | src_reg = b2p[TMP_REG_1]; | 663 | src_reg = b2p[TMP_REG_1]; |
| 664 | } | 664 | } |
| 665 | PPC_STD(src_reg, dst_reg, off); | 665 | PPC_BPF_STL(src_reg, dst_reg, off); |
| 666 | break; | 666 | break; |
| 667 | 667 | ||
| 668 | /* | 668 | /* |
| @@ -709,7 +709,7 @@ emit_clear: | |||
| 709 | break; | 709 | break; |
| 710 | /* dst = *(u64 *)(ul) (src + off) */ | 710 | /* dst = *(u64 *)(ul) (src + off) */ |
| 711 | case BPF_LDX | BPF_MEM | BPF_DW: | 711 | case BPF_LDX | BPF_MEM | BPF_DW: |
| 712 | PPC_LD(dst_reg, src_reg, off); | 712 | PPC_BPF_LL(dst_reg, src_reg, off); |
| 713 | break; | 713 | break; |
| 714 | 714 | ||
| 715 | /* | 715 | /* |
diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c index 6ed22127391b..921f12182f3e 100644 --- a/arch/powerpc/platforms/pseries/pseries_energy.c +++ b/arch/powerpc/platforms/pseries/pseries_energy.c | |||
| @@ -77,18 +77,27 @@ static u32 cpu_to_drc_index(int cpu) | |||
| 77 | 77 | ||
| 78 | ret = drc.drc_index_start + (thread_index * drc.sequential_inc); | 78 | ret = drc.drc_index_start + (thread_index * drc.sequential_inc); |
| 79 | } else { | 79 | } else { |
| 80 | const __be32 *indexes; | 80 | u32 nr_drc_indexes, thread_drc_index; |
| 81 | |||
| 82 | indexes = of_get_property(dn, "ibm,drc-indexes", NULL); | ||
| 83 | if (indexes == NULL) | ||
| 84 | goto err_of_node_put; | ||
| 85 | 81 | ||
| 86 | /* | 82 | /* |
| 87 | * The first element indexes[0] is the number of drc_indexes | 83 | * The first element of ibm,drc-indexes array is the |
| 88 | * returned in the list. Hence thread_index+1 will get the | 84 | * number of drc_indexes returned in the list. Hence |
| 89 | * drc_index corresponding to core number thread_index. | 85 | * thread_index+1 will get the drc_index corresponding |
| 86 | * to core number thread_index. | ||
| 90 | */ | 87 | */ |
| 91 | ret = indexes[thread_index + 1]; | 88 | rc = of_property_read_u32_index(dn, "ibm,drc-indexes", |
| 89 | 0, &nr_drc_indexes); | ||
| 90 | if (rc) | ||
| 91 | goto err_of_node_put; | ||
| 92 | |||
| 93 | WARN_ON_ONCE(thread_index > nr_drc_indexes); | ||
| 94 | rc = of_property_read_u32_index(dn, "ibm,drc-indexes", | ||
| 95 | thread_index + 1, | ||
| 96 | &thread_drc_index); | ||
| 97 | if (rc) | ||
| 98 | goto err_of_node_put; | ||
| 99 | |||
| 100 | ret = thread_drc_index; | ||
| 92 | } | 101 | } |
| 93 | 102 | ||
| 94 | rc = 0; | 103 | rc = 0; |
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index d97d52772789..452dcfd7e5dd 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c | |||
| @@ -550,6 +550,7 @@ static void pseries_print_mce_info(struct pt_regs *regs, | |||
| 550 | "UE", | 550 | "UE", |
| 551 | "SLB", | 551 | "SLB", |
| 552 | "ERAT", | 552 | "ERAT", |
| 553 | "Unknown", | ||
| 553 | "TLB", | 554 | "TLB", |
| 554 | "D-Cache", | 555 | "D-Cache", |
| 555 | "Unknown", | 556 | "Unknown", |
diff --git a/arch/s390/include/asm/ap.h b/arch/s390/include/asm/ap.h index 1a6a7092d942..e94a0a28b5eb 100644 --- a/arch/s390/include/asm/ap.h +++ b/arch/s390/include/asm/ap.h | |||
| @@ -360,4 +360,15 @@ static inline struct ap_queue_status ap_dqap(ap_qid_t qid, | |||
| 360 | return reg1; | 360 | return reg1; |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | /* | ||
| 364 | * Interface to tell the AP bus code that a configuration | ||
| 365 | * change has happened. The bus code should at least do | ||
| 366 | * an ap bus resource rescan. | ||
| 367 | */ | ||
| 368 | #if IS_ENABLED(CONFIG_ZCRYPT) | ||
| 369 | void ap_bus_cfg_chg(void); | ||
| 370 | #else | ||
| 371 | static inline void ap_bus_cfg_chg(void){}; | ||
| 372 | #endif | ||
| 373 | |||
| 363 | #endif /* _ASM_S390_AP_H_ */ | 374 | #endif /* _ASM_S390_AP_H_ */ |
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h index 7d22a474a040..f74639a05f0f 100644 --- a/arch/s390/include/asm/elf.h +++ b/arch/s390/include/asm/elf.h | |||
| @@ -252,11 +252,14 @@ do { \ | |||
| 252 | 252 | ||
| 253 | /* | 253 | /* |
| 254 | * Cache aliasing on the latest machines calls for a mapping granularity | 254 | * Cache aliasing on the latest machines calls for a mapping granularity |
| 255 | * of 512KB. For 64-bit processes use a 512KB alignment and a randomization | 255 | * of 512KB for the anonymous mapping base. For 64-bit processes use a |
| 256 | * of up to 1GB. For 31-bit processes the virtual address space is limited, | 256 | * 512KB alignment and a randomization of up to 1GB. For 31-bit processes |
| 257 | * use no alignment and limit the randomization to 8MB. | 257 | * the virtual address space is limited, use no alignment and limit the |
| 258 | * randomization to 8MB. | ||
| 259 | * For the additional randomization of the program break use 32MB for | ||
| 260 | * 64-bit and 8MB for 31-bit. | ||
| 258 | */ | 261 | */ |
| 259 | #define BRK_RND_MASK (is_compat_task() ? 0x7ffUL : 0x3ffffUL) | 262 | #define BRK_RND_MASK (is_compat_task() ? 0x7ffUL : 0x1fffUL) |
| 260 | #define MMAP_RND_MASK (is_compat_task() ? 0x7ffUL : 0x3ff80UL) | 263 | #define MMAP_RND_MASK (is_compat_task() ? 0x7ffUL : 0x3ff80UL) |
| 261 | #define MMAP_ALIGN_MASK (is_compat_task() ? 0 : 0x7fUL) | 264 | #define MMAP_ALIGN_MASK (is_compat_task() ? 0 : 0x7fUL) |
| 262 | #define STACK_RND_MASK MMAP_RND_MASK | 265 | #define STACK_RND_MASK MMAP_RND_MASK |
diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h index cc0947e08b6f..5b9f10b1e55d 100644 --- a/arch/s390/include/asm/lowcore.h +++ b/arch/s390/include/asm/lowcore.h | |||
| @@ -91,52 +91,53 @@ struct lowcore { | |||
| 91 | __u64 hardirq_timer; /* 0x02e8 */ | 91 | __u64 hardirq_timer; /* 0x02e8 */ |
| 92 | __u64 softirq_timer; /* 0x02f0 */ | 92 | __u64 softirq_timer; /* 0x02f0 */ |
| 93 | __u64 steal_timer; /* 0x02f8 */ | 93 | __u64 steal_timer; /* 0x02f8 */ |
| 94 | __u64 last_update_timer; /* 0x0300 */ | 94 | __u64 avg_steal_timer; /* 0x0300 */ |
| 95 | __u64 last_update_clock; /* 0x0308 */ | 95 | __u64 last_update_timer; /* 0x0308 */ |
| 96 | __u64 int_clock; /* 0x0310 */ | 96 | __u64 last_update_clock; /* 0x0310 */ |
| 97 | __u64 mcck_clock; /* 0x0318 */ | 97 | __u64 int_clock; /* 0x0318*/ |
| 98 | __u64 clock_comparator; /* 0x0320 */ | 98 | __u64 mcck_clock; /* 0x0320 */ |
| 99 | __u64 boot_clock[2]; /* 0x0328 */ | 99 | __u64 clock_comparator; /* 0x0328 */ |
| 100 | __u64 boot_clock[2]; /* 0x0330 */ | ||
| 100 | 101 | ||
| 101 | /* Current process. */ | 102 | /* Current process. */ |
| 102 | __u64 current_task; /* 0x0338 */ | 103 | __u64 current_task; /* 0x0340 */ |
| 103 | __u64 kernel_stack; /* 0x0340 */ | 104 | __u64 kernel_stack; /* 0x0348 */ |
| 104 | 105 | ||
| 105 | /* Interrupt, DAT-off and restartstack. */ | 106 | /* Interrupt, DAT-off and restartstack. */ |
| 106 | __u64 async_stack; /* 0x0348 */ | 107 | __u64 async_stack; /* 0x0350 */ |
| 107 | __u64 nodat_stack; /* 0x0350 */ | 108 | __u64 nodat_stack; /* 0x0358 */ |
| 108 | __u64 restart_stack; /* 0x0358 */ | 109 | __u64 restart_stack; /* 0x0360 */ |
| 109 | 110 | ||
| 110 | /* Restart function and parameter. */ | 111 | /* Restart function and parameter. */ |
| 111 | __u64 restart_fn; /* 0x0360 */ | 112 | __u64 restart_fn; /* 0x0368 */ |
| 112 | __u64 restart_data; /* 0x0368 */ | 113 | __u64 restart_data; /* 0x0370 */ |
| 113 | __u64 restart_source; /* 0x0370 */ | 114 | __u64 restart_source; /* 0x0378 */ |
| 114 | 115 | ||
| 115 | /* Address space pointer. */ | 116 | /* Address space pointer. */ |
| 116 | __u64 kernel_asce; /* 0x0378 */ | 117 | __u64 kernel_asce; /* 0x0380 */ |
| 117 | __u64 user_asce; /* 0x0380 */ | 118 | __u64 user_asce; /* 0x0388 */ |
| 118 | __u64 vdso_asce; /* 0x0388 */ | 119 | __u64 vdso_asce; /* 0x0390 */ |
| 119 | 120 | ||
| 120 | /* | 121 | /* |
| 121 | * The lpp and current_pid fields form a | 122 | * The lpp and current_pid fields form a |
| 122 | * 64-bit value that is set as program | 123 | * 64-bit value that is set as program |
| 123 | * parameter with the LPP instruction. | 124 | * parameter with the LPP instruction. |
| 124 | */ | 125 | */ |
| 125 | __u32 lpp; /* 0x0390 */ | 126 | __u32 lpp; /* 0x0398 */ |
| 126 | __u32 current_pid; /* 0x0394 */ | 127 | __u32 current_pid; /* 0x039c */ |
| 127 | 128 | ||
| 128 | /* SMP info area */ | 129 | /* SMP info area */ |
| 129 | __u32 cpu_nr; /* 0x0398 */ | 130 | __u32 cpu_nr; /* 0x03a0 */ |
| 130 | __u32 softirq_pending; /* 0x039c */ | 131 | __u32 softirq_pending; /* 0x03a4 */ |
| 131 | __u32 preempt_count; /* 0x03a0 */ | 132 | __u32 preempt_count; /* 0x03a8 */ |
| 132 | __u32 spinlock_lockval; /* 0x03a4 */ | 133 | __u32 spinlock_lockval; /* 0x03ac */ |
| 133 | __u32 spinlock_index; /* 0x03a8 */ | 134 | __u32 spinlock_index; /* 0x03b0 */ |
| 134 | __u32 fpu_flags; /* 0x03ac */ | 135 | __u32 fpu_flags; /* 0x03b4 */ |
| 135 | __u64 percpu_offset; /* 0x03b0 */ | 136 | __u64 percpu_offset; /* 0x03b8 */ |
| 136 | __u64 vdso_per_cpu_data; /* 0x03b8 */ | 137 | __u64 vdso_per_cpu_data; /* 0x03c0 */ |
| 137 | __u64 machine_flags; /* 0x03c0 */ | 138 | __u64 machine_flags; /* 0x03c8 */ |
| 138 | __u64 gmap; /* 0x03c8 */ | 139 | __u64 gmap; /* 0x03d0 */ |
| 139 | __u8 pad_0x03d0[0x0400-0x03d0]; /* 0x03d0 */ | 140 | __u8 pad_0x03d8[0x0400-0x03d8]; /* 0x03d8 */ |
| 140 | 141 | ||
| 141 | /* br %r1 trampoline */ | 142 | /* br %r1 trampoline */ |
| 142 | __u16 br_r1_trampoline; /* 0x0400 */ | 143 | __u16 br_r1_trampoline; /* 0x0400 */ |
diff --git a/arch/s390/kernel/perf_cpum_cf_diag.c b/arch/s390/kernel/perf_cpum_cf_diag.c index c6fad208c2fa..b6854812d2ed 100644 --- a/arch/s390/kernel/perf_cpum_cf_diag.c +++ b/arch/s390/kernel/perf_cpum_cf_diag.c | |||
| @@ -196,23 +196,30 @@ static void cf_diag_perf_event_destroy(struct perf_event *event) | |||
| 196 | */ | 196 | */ |
| 197 | static int __hw_perf_event_init(struct perf_event *event) | 197 | static int __hw_perf_event_init(struct perf_event *event) |
| 198 | { | 198 | { |
| 199 | struct cpu_cf_events *cpuhw = this_cpu_ptr(&cpu_cf_events); | ||
| 200 | struct perf_event_attr *attr = &event->attr; | 199 | struct perf_event_attr *attr = &event->attr; |
| 200 | struct cpu_cf_events *cpuhw; | ||
| 201 | enum cpumf_ctr_set i; | 201 | enum cpumf_ctr_set i; |
| 202 | int err = 0; | 202 | int err = 0; |
| 203 | 203 | ||
| 204 | debug_sprintf_event(cf_diag_dbg, 5, | 204 | debug_sprintf_event(cf_diag_dbg, 5, "%s event %p cpu %d\n", __func__, |
| 205 | "%s event %p cpu %d authorized %#x\n", __func__, | 205 | event, event->cpu); |
| 206 | event, event->cpu, cpuhw->info.auth_ctl); | ||
| 207 | 206 | ||
| 208 | event->hw.config = attr->config; | 207 | event->hw.config = attr->config; |
| 209 | event->hw.config_base = 0; | 208 | event->hw.config_base = 0; |
| 210 | local64_set(&event->count, 0); | ||
| 211 | 209 | ||
| 212 | /* Add all authorized counter sets to config_base */ | 210 | /* Add all authorized counter sets to config_base. The |
| 211 | * the hardware init function is either called per-cpu or just once | ||
| 212 | * for all CPUS (event->cpu == -1). This depends on the whether | ||
| 213 | * counting is started for all CPUs or on a per workload base where | ||
| 214 | * the perf event moves from one CPU to another CPU. | ||
| 215 | * Checking the authorization on any CPU is fine as the hardware | ||
| 216 | * applies the same authorization settings to all CPUs. | ||
| 217 | */ | ||
| 218 | cpuhw = &get_cpu_var(cpu_cf_events); | ||
| 213 | for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) | 219 | for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) |
| 214 | if (cpuhw->info.auth_ctl & cpumf_ctr_ctl[i]) | 220 | if (cpuhw->info.auth_ctl & cpumf_ctr_ctl[i]) |
| 215 | event->hw.config_base |= cpumf_ctr_ctl[i]; | 221 | event->hw.config_base |= cpumf_ctr_ctl[i]; |
| 222 | put_cpu_var(cpu_cf_events); | ||
| 216 | 223 | ||
| 217 | /* No authorized counter sets, nothing to count/sample */ | 224 | /* No authorized counter sets, nothing to count/sample */ |
| 218 | if (!event->hw.config_base) { | 225 | if (!event->hw.config_base) { |
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 3fe1c77c361b..bd197baf1dc3 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c | |||
| @@ -266,7 +266,8 @@ static void pcpu_prepare_secondary(struct pcpu *pcpu, int cpu) | |||
| 266 | lc->percpu_offset = __per_cpu_offset[cpu]; | 266 | lc->percpu_offset = __per_cpu_offset[cpu]; |
| 267 | lc->kernel_asce = S390_lowcore.kernel_asce; | 267 | lc->kernel_asce = S390_lowcore.kernel_asce; |
| 268 | lc->machine_flags = S390_lowcore.machine_flags; | 268 | lc->machine_flags = S390_lowcore.machine_flags; |
| 269 | lc->user_timer = lc->system_timer = lc->steal_timer = 0; | 269 | lc->user_timer = lc->system_timer = |
| 270 | lc->steal_timer = lc->avg_steal_timer = 0; | ||
| 270 | __ctl_store(lc->cregs_save_area, 0, 15); | 271 | __ctl_store(lc->cregs_save_area, 0, 15); |
| 271 | save_access_regs((unsigned int *) lc->access_regs_save_area); | 272 | save_access_regs((unsigned int *) lc->access_regs_save_area); |
| 272 | memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list, | 273 | memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list, |
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index 98f850e00008..a69a0911ed0e 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c | |||
| @@ -124,7 +124,7 @@ static void account_system_index_scaled(struct task_struct *p, u64 cputime, | |||
| 124 | */ | 124 | */ |
| 125 | static int do_account_vtime(struct task_struct *tsk) | 125 | static int do_account_vtime(struct task_struct *tsk) |
| 126 | { | 126 | { |
| 127 | u64 timer, clock, user, guest, system, hardirq, softirq, steal; | 127 | u64 timer, clock, user, guest, system, hardirq, softirq; |
| 128 | 128 | ||
| 129 | timer = S390_lowcore.last_update_timer; | 129 | timer = S390_lowcore.last_update_timer; |
| 130 | clock = S390_lowcore.last_update_clock; | 130 | clock = S390_lowcore.last_update_clock; |
| @@ -182,12 +182,6 @@ static int do_account_vtime(struct task_struct *tsk) | |||
| 182 | if (softirq) | 182 | if (softirq) |
| 183 | account_system_index_scaled(tsk, softirq, CPUTIME_SOFTIRQ); | 183 | account_system_index_scaled(tsk, softirq, CPUTIME_SOFTIRQ); |
| 184 | 184 | ||
| 185 | steal = S390_lowcore.steal_timer; | ||
| 186 | if ((s64) steal > 0) { | ||
| 187 | S390_lowcore.steal_timer = 0; | ||
| 188 | account_steal_time(cputime_to_nsecs(steal)); | ||
| 189 | } | ||
| 190 | |||
| 191 | return virt_timer_forward(user + guest + system + hardirq + softirq); | 185 | return virt_timer_forward(user + guest + system + hardirq + softirq); |
| 192 | } | 186 | } |
| 193 | 187 | ||
| @@ -213,8 +207,19 @@ void vtime_task_switch(struct task_struct *prev) | |||
| 213 | */ | 207 | */ |
| 214 | void vtime_flush(struct task_struct *tsk) | 208 | void vtime_flush(struct task_struct *tsk) |
| 215 | { | 209 | { |
| 210 | u64 steal, avg_steal; | ||
| 211 | |||
| 216 | if (do_account_vtime(tsk)) | 212 | if (do_account_vtime(tsk)) |
| 217 | virt_timer_expire(); | 213 | virt_timer_expire(); |
| 214 | |||
| 215 | steal = S390_lowcore.steal_timer; | ||
| 216 | avg_steal = S390_lowcore.avg_steal_timer / 2; | ||
| 217 | if ((s64) steal > 0) { | ||
| 218 | S390_lowcore.steal_timer = 0; | ||
| 219 | account_steal_time(steal); | ||
| 220 | avg_steal += steal; | ||
| 221 | } | ||
| 222 | S390_lowcore.avg_steal_timer = avg_steal; | ||
| 218 | } | 223 | } |
| 219 | 224 | ||
| 220 | /* | 225 | /* |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c1f9b3cf437c..5ad92419be19 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -2217,14 +2217,8 @@ config RANDOMIZE_MEMORY_PHYSICAL_PADDING | |||
| 2217 | If unsure, leave at the default value. | 2217 | If unsure, leave at the default value. |
| 2218 | 2218 | ||
| 2219 | config HOTPLUG_CPU | 2219 | config HOTPLUG_CPU |
| 2220 | bool "Support for hot-pluggable CPUs" | 2220 | def_bool y |
| 2221 | depends on SMP | 2221 | depends on SMP |
| 2222 | ---help--- | ||
| 2223 | Say Y here to allow turning CPUs off and on. CPUs can be | ||
| 2224 | controlled through /sys/devices/system/cpu. | ||
| 2225 | ( Note: power management support will enable this option | ||
| 2226 | automatically on SMP systems. ) | ||
| 2227 | Say N if you want to disable CPU hotplug. | ||
| 2228 | 2222 | ||
| 2229 | config BOOTPARAM_HOTPLUG_CPU0 | 2223 | config BOOTPARAM_HOTPLUG_CPU0 |
| 2230 | bool "Set default setting of cpu0_hotpluggable" | 2224 | bool "Set default setting of cpu0_hotpluggable" |
diff --git a/block/blk-flush.c b/block/blk-flush.c index 6e0f2d97fc6d..d95f94892015 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c | |||
| @@ -220,7 +220,7 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error) | |||
| 220 | blk_mq_tag_set_rq(hctx, flush_rq->tag, fq->orig_rq); | 220 | blk_mq_tag_set_rq(hctx, flush_rq->tag, fq->orig_rq); |
| 221 | flush_rq->tag = -1; | 221 | flush_rq->tag = -1; |
| 222 | } else { | 222 | } else { |
| 223 | blk_mq_put_driver_tag_hctx(hctx, flush_rq); | 223 | blk_mq_put_driver_tag(flush_rq); |
| 224 | flush_rq->internal_tag = -1; | 224 | flush_rq->internal_tag = -1; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| @@ -324,7 +324,7 @@ static void mq_flush_data_end_io(struct request *rq, blk_status_t error) | |||
| 324 | 324 | ||
| 325 | if (q->elevator) { | 325 | if (q->elevator) { |
| 326 | WARN_ON(rq->tag < 0); | 326 | WARN_ON(rq->tag < 0); |
| 327 | blk_mq_put_driver_tag_hctx(hctx, rq); | 327 | blk_mq_put_driver_tag(rq); |
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | /* | 330 | /* |
diff --git a/block/blk-mq.c b/block/blk-mq.c index 70b210a308c4..3ff3d7b49969 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
| @@ -59,7 +59,8 @@ static int blk_mq_poll_stats_bkt(const struct request *rq) | |||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | /* | 61 | /* |
| 62 | * Check if any of the ctx's have pending work in this hardware queue | 62 | * Check if any of the ctx, dispatch list or elevator |
| 63 | * have pending work in this hardware queue. | ||
| 63 | */ | 64 | */ |
| 64 | static bool blk_mq_hctx_has_pending(struct blk_mq_hw_ctx *hctx) | 65 | static bool blk_mq_hctx_has_pending(struct blk_mq_hw_ctx *hctx) |
| 65 | { | 66 | { |
| @@ -1071,7 +1072,13 @@ static int blk_mq_dispatch_wake(wait_queue_entry_t *wait, unsigned mode, | |||
| 1071 | hctx = container_of(wait, struct blk_mq_hw_ctx, dispatch_wait); | 1072 | hctx = container_of(wait, struct blk_mq_hw_ctx, dispatch_wait); |
| 1072 | 1073 | ||
| 1073 | spin_lock(&hctx->dispatch_wait_lock); | 1074 | spin_lock(&hctx->dispatch_wait_lock); |
| 1074 | list_del_init(&wait->entry); | 1075 | if (!list_empty(&wait->entry)) { |
| 1076 | struct sbitmap_queue *sbq; | ||
| 1077 | |||
| 1078 | list_del_init(&wait->entry); | ||
| 1079 | sbq = &hctx->tags->bitmap_tags; | ||
| 1080 | atomic_dec(&sbq->ws_active); | ||
| 1081 | } | ||
| 1075 | spin_unlock(&hctx->dispatch_wait_lock); | 1082 | spin_unlock(&hctx->dispatch_wait_lock); |
| 1076 | 1083 | ||
| 1077 | blk_mq_run_hw_queue(hctx, true); | 1084 | blk_mq_run_hw_queue(hctx, true); |
| @@ -1087,6 +1094,7 @@ static int blk_mq_dispatch_wake(wait_queue_entry_t *wait, unsigned mode, | |||
| 1087 | static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx, | 1094 | static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx, |
| 1088 | struct request *rq) | 1095 | struct request *rq) |
| 1089 | { | 1096 | { |
| 1097 | struct sbitmap_queue *sbq = &hctx->tags->bitmap_tags; | ||
| 1090 | struct wait_queue_head *wq; | 1098 | struct wait_queue_head *wq; |
| 1091 | wait_queue_entry_t *wait; | 1099 | wait_queue_entry_t *wait; |
| 1092 | bool ret; | 1100 | bool ret; |
| @@ -1109,7 +1117,7 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx, | |||
| 1109 | if (!list_empty_careful(&wait->entry)) | 1117 | if (!list_empty_careful(&wait->entry)) |
| 1110 | return false; | 1118 | return false; |
| 1111 | 1119 | ||
| 1112 | wq = &bt_wait_ptr(&hctx->tags->bitmap_tags, hctx)->wait; | 1120 | wq = &bt_wait_ptr(sbq, hctx)->wait; |
| 1113 | 1121 | ||
| 1114 | spin_lock_irq(&wq->lock); | 1122 | spin_lock_irq(&wq->lock); |
| 1115 | spin_lock(&hctx->dispatch_wait_lock); | 1123 | spin_lock(&hctx->dispatch_wait_lock); |
| @@ -1119,6 +1127,7 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx, | |||
| 1119 | return false; | 1127 | return false; |
| 1120 | } | 1128 | } |
| 1121 | 1129 | ||
| 1130 | atomic_inc(&sbq->ws_active); | ||
| 1122 | wait->flags &= ~WQ_FLAG_EXCLUSIVE; | 1131 | wait->flags &= ~WQ_FLAG_EXCLUSIVE; |
| 1123 | __add_wait_queue(wq, wait); | 1132 | __add_wait_queue(wq, wait); |
| 1124 | 1133 | ||
| @@ -1139,6 +1148,7 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx *hctx, | |||
| 1139 | * someone else gets the wakeup. | 1148 | * someone else gets the wakeup. |
| 1140 | */ | 1149 | */ |
| 1141 | list_del_init(&wait->entry); | 1150 | list_del_init(&wait->entry); |
| 1151 | atomic_dec(&sbq->ws_active); | ||
| 1142 | spin_unlock(&hctx->dispatch_wait_lock); | 1152 | spin_unlock(&hctx->dispatch_wait_lock); |
| 1143 | spin_unlock_irq(&wq->lock); | 1153 | spin_unlock_irq(&wq->lock); |
| 1144 | 1154 | ||
diff --git a/block/blk-mq.h b/block/blk-mq.h index 0ed8e5a8729f..d704fc7766f4 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h | |||
| @@ -224,15 +224,6 @@ static inline void __blk_mq_put_driver_tag(struct blk_mq_hw_ctx *hctx, | |||
| 224 | } | 224 | } |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | static inline void blk_mq_put_driver_tag_hctx(struct blk_mq_hw_ctx *hctx, | ||
| 228 | struct request *rq) | ||
| 229 | { | ||
| 230 | if (rq->tag == -1 || rq->internal_tag == -1) | ||
| 231 | return; | ||
| 232 | |||
| 233 | __blk_mq_put_driver_tag(hctx, rq); | ||
| 234 | } | ||
| 235 | |||
| 236 | static inline void blk_mq_put_driver_tag(struct request *rq) | 227 | static inline void blk_mq_put_driver_tag(struct request *rq) |
| 237 | { | 228 | { |
| 238 | if (rq->tag == -1 || rq->internal_tag == -1) | 229 | if (rq->tag == -1 || rq->internal_tag == -1) |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 6ecbbabf1233..eec263c9019e 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
| @@ -1043,9 +1043,6 @@ void __init acpi_early_init(void) | |||
| 1043 | 1043 | ||
| 1044 | acpi_permanent_mmap = true; | 1044 | acpi_permanent_mmap = true; |
| 1045 | 1045 | ||
| 1046 | /* Initialize debug output. Linux does not use ACPICA defaults */ | ||
| 1047 | acpi_dbg_level = ACPI_LV_INFO | ACPI_LV_REPAIR; | ||
| 1048 | |||
| 1049 | #ifdef CONFIG_X86 | 1046 | #ifdef CONFIG_X86 |
| 1050 | /* | 1047 | /* |
| 1051 | * If the machine falls into the DMI check table, | 1048 | * If the machine falls into the DMI check table, |
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 1b207fca1420..d4244e7d0e38 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c | |||
| @@ -1150,8 +1150,13 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) | |||
| 1150 | cpc_read(cpunum, nominal_reg, &nom); | 1150 | cpc_read(cpunum, nominal_reg, &nom); |
| 1151 | perf_caps->nominal_perf = nom; | 1151 | perf_caps->nominal_perf = nom; |
| 1152 | 1152 | ||
| 1153 | cpc_read(cpunum, guaranteed_reg, &guaranteed); | 1153 | if (guaranteed_reg->type != ACPI_TYPE_BUFFER || |
| 1154 | perf_caps->guaranteed_perf = guaranteed; | 1154 | IS_NULL_REG(&guaranteed_reg->cpc_entry.reg)) { |
| 1155 | perf_caps->guaranteed_perf = 0; | ||
| 1156 | } else { | ||
| 1157 | cpc_read(cpunum, guaranteed_reg, &guaranteed); | ||
| 1158 | perf_caps->guaranteed_perf = guaranteed; | ||
| 1159 | } | ||
| 1155 | 1160 | ||
| 1156 | cpc_read(cpunum, lowest_non_linear_reg, &min_nonlinear); | 1161 | cpc_read(cpunum, lowest_non_linear_reg, &min_nonlinear); |
| 1157 | perf_caps->lowest_nonlinear_perf = min_nonlinear; | 1162 | perf_caps->lowest_nonlinear_perf = min_nonlinear; |
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 8685882da64c..4b9c7ca492e6 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c | |||
| @@ -2057,7 +2057,8 @@ static size_t binder_get_object(struct binder_proc *proc, | |||
| 2057 | size_t object_size = 0; | 2057 | size_t object_size = 0; |
| 2058 | 2058 | ||
| 2059 | read_size = min_t(size_t, sizeof(*object), buffer->data_size - offset); | 2059 | read_size = min_t(size_t, sizeof(*object), buffer->data_size - offset); |
| 2060 | if (read_size < sizeof(*hdr) || !IS_ALIGNED(offset, sizeof(u32))) | 2060 | if (offset > buffer->data_size || read_size < sizeof(*hdr) || |
| 2061 | !IS_ALIGNED(offset, sizeof(u32))) | ||
| 2061 | return 0; | 2062 | return 0; |
| 2062 | binder_alloc_copy_from_buffer(&proc->alloc, object, buffer, | 2063 | binder_alloc_copy_from_buffer(&proc->alloc, object, buffer, |
| 2063 | offset, read_size); | 2064 | offset, read_size); |
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 6389467670a0..195f120c4e8c 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c | |||
| @@ -927,14 +927,13 @@ enum lru_status binder_alloc_free_page(struct list_head *item, | |||
| 927 | 927 | ||
| 928 | index = page - alloc->pages; | 928 | index = page - alloc->pages; |
| 929 | page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE; | 929 | page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE; |
| 930 | |||
| 931 | mm = alloc->vma_vm_mm; | ||
| 932 | if (!mmget_not_zero(mm)) | ||
| 933 | goto err_mmget; | ||
| 934 | if (!down_write_trylock(&mm->mmap_sem)) | ||
| 935 | goto err_down_write_mmap_sem_failed; | ||
| 930 | vma = binder_alloc_get_vma(alloc); | 936 | vma = binder_alloc_get_vma(alloc); |
| 931 | if (vma) { | ||
| 932 | if (!mmget_not_zero(alloc->vma_vm_mm)) | ||
| 933 | goto err_mmget; | ||
| 934 | mm = alloc->vma_vm_mm; | ||
| 935 | if (!down_read_trylock(&mm->mmap_sem)) | ||
| 936 | goto err_down_write_mmap_sem_failed; | ||
| 937 | } | ||
| 938 | 937 | ||
| 939 | list_lru_isolate(lru, item); | 938 | list_lru_isolate(lru, item); |
| 940 | spin_unlock(lock); | 939 | spin_unlock(lock); |
| @@ -945,10 +944,9 @@ enum lru_status binder_alloc_free_page(struct list_head *item, | |||
| 945 | zap_page_range(vma, page_addr, PAGE_SIZE); | 944 | zap_page_range(vma, page_addr, PAGE_SIZE); |
| 946 | 945 | ||
| 947 | trace_binder_unmap_user_end(alloc, index); | 946 | trace_binder_unmap_user_end(alloc, index); |
| 948 | |||
| 949 | up_read(&mm->mmap_sem); | ||
| 950 | mmput(mm); | ||
| 951 | } | 947 | } |
| 948 | up_write(&mm->mmap_sem); | ||
| 949 | mmput(mm); | ||
| 952 | 950 | ||
| 953 | trace_binder_unmap_kernel_start(alloc, index); | 951 | trace_binder_unmap_kernel_start(alloc, index); |
| 954 | 952 | ||
diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c index b3ed8f9953a8..173e6f2dd9af 100644 --- a/drivers/ata/libata-zpodd.c +++ b/drivers/ata/libata-zpodd.c | |||
| @@ -52,38 +52,52 @@ static int eject_tray(struct ata_device *dev) | |||
| 52 | /* Per the spec, only slot type and drawer type ODD can be supported */ | 52 | /* Per the spec, only slot type and drawer type ODD can be supported */ |
| 53 | static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev) | 53 | static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev) |
| 54 | { | 54 | { |
| 55 | char buf[16]; | 55 | char *buf; |
| 56 | unsigned int ret; | 56 | unsigned int ret; |
| 57 | struct rm_feature_desc *desc = (void *)(buf + 8); | 57 | struct rm_feature_desc *desc; |
| 58 | struct ata_taskfile tf; | 58 | struct ata_taskfile tf; |
| 59 | static const char cdb[] = { GPCMD_GET_CONFIGURATION, | 59 | static const char cdb[] = { GPCMD_GET_CONFIGURATION, |
| 60 | 2, /* only 1 feature descriptor requested */ | 60 | 2, /* only 1 feature descriptor requested */ |
| 61 | 0, 3, /* 3, removable medium feature */ | 61 | 0, 3, /* 3, removable medium feature */ |
| 62 | 0, 0, 0,/* reserved */ | 62 | 0, 0, 0,/* reserved */ |
| 63 | 0, sizeof(buf), | 63 | 0, 16, |
| 64 | 0, 0, 0, | 64 | 0, 0, 0, |
| 65 | }; | 65 | }; |
| 66 | 66 | ||
| 67 | buf = kzalloc(16, GFP_KERNEL); | ||
| 68 | if (!buf) | ||
| 69 | return ODD_MECH_TYPE_UNSUPPORTED; | ||
| 70 | desc = (void *)(buf + 8); | ||
| 71 | |||
| 67 | ata_tf_init(dev, &tf); | 72 | ata_tf_init(dev, &tf); |
| 68 | tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 73 | tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
| 69 | tf.command = ATA_CMD_PACKET; | 74 | tf.command = ATA_CMD_PACKET; |
| 70 | tf.protocol = ATAPI_PROT_PIO; | 75 | tf.protocol = ATAPI_PROT_PIO; |
| 71 | tf.lbam = sizeof(buf); | 76 | tf.lbam = 16; |
| 72 | 77 | ||
| 73 | ret = ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, | 78 | ret = ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, |
| 74 | buf, sizeof(buf), 0); | 79 | buf, 16, 0); |
| 75 | if (ret) | 80 | if (ret) { |
| 81 | kfree(buf); | ||
| 76 | return ODD_MECH_TYPE_UNSUPPORTED; | 82 | return ODD_MECH_TYPE_UNSUPPORTED; |
| 83 | } | ||
| 77 | 84 | ||
| 78 | if (be16_to_cpu(desc->feature_code) != 3) | 85 | if (be16_to_cpu(desc->feature_code) != 3) { |
| 86 | kfree(buf); | ||
| 79 | return ODD_MECH_TYPE_UNSUPPORTED; | 87 | return ODD_MECH_TYPE_UNSUPPORTED; |
| 88 | } | ||
| 80 | 89 | ||
| 81 | if (desc->mech_type == 0 && desc->load == 0 && desc->eject == 1) | 90 | if (desc->mech_type == 0 && desc->load == 0 && desc->eject == 1) { |
| 91 | kfree(buf); | ||
| 82 | return ODD_MECH_TYPE_SLOT; | 92 | return ODD_MECH_TYPE_SLOT; |
| 83 | else if (desc->mech_type == 1 && desc->load == 0 && desc->eject == 1) | 93 | } else if (desc->mech_type == 1 && desc->load == 0 && |
| 94 | desc->eject == 1) { | ||
| 95 | kfree(buf); | ||
| 84 | return ODD_MECH_TYPE_DRAWER; | 96 | return ODD_MECH_TYPE_DRAWER; |
| 85 | else | 97 | } else { |
| 98 | kfree(buf); | ||
| 86 | return ODD_MECH_TYPE_UNSUPPORTED; | 99 | return ODD_MECH_TYPE_UNSUPPORTED; |
| 100 | } | ||
| 87 | } | 101 | } |
| 88 | 102 | ||
| 89 | /* Test if ODD is zero power ready by sense code */ | 103 | /* Test if ODD is zero power ready by sense code */ |
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index e7a5f1d1c314..399cad7daae7 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
| @@ -290,18 +290,8 @@ static ssize_t idle_store(struct device *dev, | |||
| 290 | struct zram *zram = dev_to_zram(dev); | 290 | struct zram *zram = dev_to_zram(dev); |
| 291 | unsigned long nr_pages = zram->disksize >> PAGE_SHIFT; | 291 | unsigned long nr_pages = zram->disksize >> PAGE_SHIFT; |
| 292 | int index; | 292 | int index; |
| 293 | char mode_buf[8]; | ||
| 294 | ssize_t sz; | ||
| 295 | 293 | ||
| 296 | sz = strscpy(mode_buf, buf, sizeof(mode_buf)); | 294 | if (!sysfs_streq(buf, "all")) |
| 297 | if (sz <= 0) | ||
| 298 | return -EINVAL; | ||
| 299 | |||
| 300 | /* ignore trailing new line */ | ||
| 301 | if (mode_buf[sz - 1] == '\n') | ||
| 302 | mode_buf[sz - 1] = 0x00; | ||
| 303 | |||
| 304 | if (strcmp(mode_buf, "all")) | ||
| 305 | return -EINVAL; | 295 | return -EINVAL; |
| 306 | 296 | ||
| 307 | down_read(&zram->init_lock); | 297 | down_read(&zram->init_lock); |
| @@ -635,25 +625,15 @@ static ssize_t writeback_store(struct device *dev, | |||
| 635 | struct bio bio; | 625 | struct bio bio; |
| 636 | struct bio_vec bio_vec; | 626 | struct bio_vec bio_vec; |
| 637 | struct page *page; | 627 | struct page *page; |
| 638 | ssize_t ret, sz; | 628 | ssize_t ret; |
| 639 | char mode_buf[8]; | 629 | int mode; |
| 640 | int mode = -1; | ||
| 641 | unsigned long blk_idx = 0; | 630 | unsigned long blk_idx = 0; |
| 642 | 631 | ||
| 643 | sz = strscpy(mode_buf, buf, sizeof(mode_buf)); | 632 | if (sysfs_streq(buf, "idle")) |
| 644 | if (sz <= 0) | ||
| 645 | return -EINVAL; | ||
| 646 | |||
| 647 | /* ignore trailing newline */ | ||
| 648 | if (mode_buf[sz - 1] == '\n') | ||
| 649 | mode_buf[sz - 1] = 0x00; | ||
| 650 | |||
| 651 | if (!strcmp(mode_buf, "idle")) | ||
| 652 | mode = IDLE_WRITEBACK; | 633 | mode = IDLE_WRITEBACK; |
| 653 | else if (!strcmp(mode_buf, "huge")) | 634 | else if (sysfs_streq(buf, "huge")) |
| 654 | mode = HUGE_WRITEBACK; | 635 | mode = HUGE_WRITEBACK; |
| 655 | 636 | else | |
| 656 | if (mode == -1) | ||
| 657 | return -EINVAL; | 637 | return -EINVAL; |
| 658 | 638 | ||
| 659 | down_read(&zram->init_lock); | 639 | down_read(&zram->init_lock); |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index e22f0dbaebb1..b599c7318aab 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -385,7 +385,10 @@ static int intel_pstate_get_cppc_guranteed(int cpu) | |||
| 385 | if (ret) | 385 | if (ret) |
| 386 | return ret; | 386 | return ret; |
| 387 | 387 | ||
| 388 | return cppc_perf.guaranteed_perf; | 388 | if (cppc_perf.guaranteed_perf) |
| 389 | return cppc_perf.guaranteed_perf; | ||
| 390 | |||
| 391 | return cppc_perf.nominal_perf; | ||
| 389 | } | 392 | } |
| 390 | 393 | ||
| 391 | #else /* CONFIG_ACPI_CPPC_LIB */ | 394 | #else /* CONFIG_ACPI_CPPC_LIB */ |
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c index 3f49427766b8..2b51e0718c9f 100644 --- a/drivers/cpufreq/scpi-cpufreq.c +++ b/drivers/cpufreq/scpi-cpufreq.c | |||
| @@ -189,8 +189,8 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy) | |||
| 189 | 189 | ||
| 190 | clk_put(priv->clk); | 190 | clk_put(priv->clk); |
| 191 | dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); | 191 | dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); |
| 192 | kfree(priv); | ||
| 193 | dev_pm_opp_remove_all_dynamic(priv->cpu_dev); | 192 | dev_pm_opp_remove_all_dynamic(priv->cpu_dev); |
| 193 | kfree(priv); | ||
| 194 | 194 | ||
| 195 | return 0; | 195 | return 0; |
| 196 | } | 196 | } |
diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index 4e0eede599a8..ac0301b69593 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c | |||
| @@ -1578,11 +1578,9 @@ static int stm32_mdma_probe(struct platform_device *pdev) | |||
| 1578 | 1578 | ||
| 1579 | dmadev->nr_channels = nr_channels; | 1579 | dmadev->nr_channels = nr_channels; |
| 1580 | dmadev->nr_requests = nr_requests; | 1580 | dmadev->nr_requests = nr_requests; |
| 1581 | ret = device_property_read_u32_array(&pdev->dev, "st,ahb-addr-masks", | 1581 | device_property_read_u32_array(&pdev->dev, "st,ahb-addr-masks", |
| 1582 | dmadev->ahb_addr_masks, | 1582 | dmadev->ahb_addr_masks, |
| 1583 | count); | 1583 | count); |
| 1584 | if (ret) | ||
| 1585 | return ret; | ||
| 1586 | dmadev->nr_ahb_addr_masks = count; | 1584 | dmadev->nr_ahb_addr_masks = count; |
| 1587 | 1585 | ||
| 1588 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1586 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index 91b90c0cea73..12acdac85820 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c | |||
| @@ -132,8 +132,10 @@ static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | |||
| 132 | if (err < 0) | 132 | if (err < 0) |
| 133 | goto out; | 133 | goto out; |
| 134 | 134 | ||
| 135 | if (err & BIT(pos)) | 135 | if (value & BIT(pos)) { |
| 136 | err = -EACCES; | 136 | err = -EPERM; |
| 137 | goto out; | ||
| 138 | } | ||
| 137 | 139 | ||
| 138 | err = 0; | 140 | err = 0; |
| 139 | 141 | ||
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c index 854bce4fb9e7..217507002dbc 100644 --- a/drivers/gpio/gpio-aspeed.c +++ b/drivers/gpio/gpio-aspeed.c | |||
| @@ -1224,6 +1224,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) | |||
| 1224 | 1224 | ||
| 1225 | gpio->offset_timer = | 1225 | gpio->offset_timer = |
| 1226 | devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL); | 1226 | devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL); |
| 1227 | if (!gpio->offset_timer) | ||
| 1228 | return -ENOMEM; | ||
| 1227 | 1229 | ||
| 1228 | return aspeed_gpio_setup_irqs(gpio, pdev); | 1230 | return aspeed_gpio_setup_irqs(gpio, pdev); |
| 1229 | } | 1231 | } |
diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 0ecd2369c2ca..a09d2f9ebacc 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c | |||
| @@ -148,6 +148,8 @@ static int gpio_exar_probe(struct platform_device *pdev) | |||
| 148 | mutex_init(&exar_gpio->lock); | 148 | mutex_init(&exar_gpio->lock); |
| 149 | 149 | ||
| 150 | index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL); | 150 | index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL); |
| 151 | if (index < 0) | ||
| 152 | goto err_destroy; | ||
| 151 | 153 | ||
| 152 | sprintf(exar_gpio->name, "exar_gpio%d", index); | 154 | sprintf(exar_gpio->name, "exar_gpio%d", index); |
| 153 | exar_gpio->gpio_chip.label = exar_gpio->name; | 155 | exar_gpio->gpio_chip.label = exar_gpio->name; |
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 154d959e8993..b6a4efce7c92 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c | |||
| @@ -204,8 +204,8 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file, | |||
| 204 | struct gpio_mockup_chip *chip; | 204 | struct gpio_mockup_chip *chip; |
| 205 | struct seq_file *sfile; | 205 | struct seq_file *sfile; |
| 206 | struct gpio_chip *gc; | 206 | struct gpio_chip *gc; |
| 207 | int val, cnt; | ||
| 207 | char buf[3]; | 208 | char buf[3]; |
| 208 | int val, rv; | ||
| 209 | 209 | ||
| 210 | if (*ppos != 0) | 210 | if (*ppos != 0) |
| 211 | return 0; | 211 | return 0; |
| @@ -216,13 +216,9 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file, | |||
| 216 | gc = &chip->gc; | 216 | gc = &chip->gc; |
| 217 | 217 | ||
| 218 | val = gpio_mockup_get(gc, priv->offset); | 218 | val = gpio_mockup_get(gc, priv->offset); |
| 219 | snprintf(buf, sizeof(buf), "%d\n", val); | 219 | cnt = snprintf(buf, sizeof(buf), "%d\n", val); |
| 220 | 220 | ||
| 221 | rv = copy_to_user(usr_buf, buf, sizeof(buf)); | 221 | return simple_read_from_buffer(usr_buf, size, ppos, buf, cnt); |
| 222 | if (rv) | ||
| 223 | return rv; | ||
| 224 | |||
| 225 | return sizeof(buf) - 1; | ||
| 226 | } | 222 | } |
| 227 | 223 | ||
| 228 | static ssize_t gpio_mockup_debugfs_write(struct file *file, | 224 | static ssize_t gpio_mockup_debugfs_write(struct file *file, |
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 8b9c3ab70f6e..6a3ec575a404 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
| @@ -120,7 +120,8 @@ static void of_gpio_flags_quirks(struct device_node *np, | |||
| 120 | * to determine if the flags should have inverted semantics. | 120 | * to determine if the flags should have inverted semantics. |
| 121 | */ | 121 | */ |
| 122 | if (IS_ENABLED(CONFIG_SPI_MASTER) && | 122 | if (IS_ENABLED(CONFIG_SPI_MASTER) && |
| 123 | of_property_read_bool(np, "cs-gpios")) { | 123 | of_property_read_bool(np, "cs-gpios") && |
| 124 | !strcmp(propname, "cs-gpios")) { | ||
| 124 | struct device_node *child; | 125 | struct device_node *child; |
| 125 | u32 cs; | 126 | u32 cs; |
| 126 | int ret; | 127 | int ret; |
| @@ -142,16 +143,16 @@ static void of_gpio_flags_quirks(struct device_node *np, | |||
| 142 | * conflict and the "spi-cs-high" flag will | 143 | * conflict and the "spi-cs-high" flag will |
| 143 | * take precedence. | 144 | * take precedence. |
| 144 | */ | 145 | */ |
| 145 | if (of_property_read_bool(np, "spi-cs-high")) { | 146 | if (of_property_read_bool(child, "spi-cs-high")) { |
| 146 | if (*flags & OF_GPIO_ACTIVE_LOW) { | 147 | if (*flags & OF_GPIO_ACTIVE_LOW) { |
| 147 | pr_warn("%s GPIO handle specifies active low - ignored\n", | 148 | pr_warn("%s GPIO handle specifies active low - ignored\n", |
| 148 | of_node_full_name(np)); | 149 | of_node_full_name(child)); |
| 149 | *flags &= ~OF_GPIO_ACTIVE_LOW; | 150 | *flags &= ~OF_GPIO_ACTIVE_LOW; |
| 150 | } | 151 | } |
| 151 | } else { | 152 | } else { |
| 152 | if (!(*flags & OF_GPIO_ACTIVE_LOW)) | 153 | if (!(*flags & OF_GPIO_ACTIVE_LOW)) |
| 153 | pr_info("%s enforce active low on chipselect handle\n", | 154 | pr_info("%s enforce active low on chipselect handle\n", |
| 154 | of_node_full_name(np)); | 155 | of_node_full_name(child)); |
| 155 | *flags |= OF_GPIO_ACTIVE_LOW; | 156 | *flags |= OF_GPIO_ACTIVE_LOW; |
| 156 | } | 157 | } |
| 157 | break; | 158 | break; |
| @@ -717,7 +718,13 @@ int of_gpiochip_add(struct gpio_chip *chip) | |||
| 717 | 718 | ||
| 718 | of_node_get(chip->of_node); | 719 | of_node_get(chip->of_node); |
| 719 | 720 | ||
| 720 | return of_gpiochip_scan_gpios(chip); | 721 | status = of_gpiochip_scan_gpios(chip); |
| 722 | if (status) { | ||
| 723 | of_node_put(chip->of_node); | ||
| 724 | gpiochip_remove_pin_ranges(chip); | ||
| 725 | } | ||
| 726 | |||
| 727 | return status; | ||
| 721 | } | 728 | } |
| 722 | 729 | ||
| 723 | void of_gpiochip_remove(struct gpio_chip *chip) | 730 | void of_gpiochip_remove(struct gpio_chip *chip) |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 144af0733581..0495bf1d480a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
| @@ -2776,7 +2776,7 @@ int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) | |||
| 2776 | } | 2776 | } |
| 2777 | 2777 | ||
| 2778 | config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce); | 2778 | config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce); |
| 2779 | return gpio_set_config(chip, gpio_chip_hwgpio(desc), config); | 2779 | return chip->set_config(chip, gpio_chip_hwgpio(desc), config); |
| 2780 | } | 2780 | } |
| 2781 | EXPORT_SYMBOL_GPL(gpiod_set_debounce); | 2781 | EXPORT_SYMBOL_GPL(gpiod_set_debounce); |
| 2782 | 2782 | ||
| @@ -2813,7 +2813,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) | |||
| 2813 | packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, | 2813 | packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, |
| 2814 | !transitory); | 2814 | !transitory); |
| 2815 | gpio = gpio_chip_hwgpio(desc); | 2815 | gpio = gpio_chip_hwgpio(desc); |
| 2816 | rc = gpio_set_config(chip, gpio, packed); | 2816 | rc = chip->set_config(chip, gpio, packed); |
| 2817 | if (rc == -ENOTSUPP) { | 2817 | if (rc == -ENOTSUPP) { |
| 2818 | dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", | 2818 | dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", |
| 2819 | gpio); | 2819 | gpio); |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index fb27783d7a54..81127f7d6ed1 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |||
| @@ -5429,9 +5429,11 @@ static void get_freesync_config_for_crtc( | |||
| 5429 | struct amdgpu_dm_connector *aconnector = | 5429 | struct amdgpu_dm_connector *aconnector = |
| 5430 | to_amdgpu_dm_connector(new_con_state->base.connector); | 5430 | to_amdgpu_dm_connector(new_con_state->base.connector); |
| 5431 | struct drm_display_mode *mode = &new_crtc_state->base.mode; | 5431 | struct drm_display_mode *mode = &new_crtc_state->base.mode; |
| 5432 | int vrefresh = drm_mode_vrefresh(mode); | ||
| 5432 | 5433 | ||
| 5433 | new_crtc_state->vrr_supported = new_con_state->freesync_capable && | 5434 | new_crtc_state->vrr_supported = new_con_state->freesync_capable && |
| 5434 | aconnector->min_vfreq <= drm_mode_vrefresh(mode); | 5435 | vrefresh >= aconnector->min_vfreq && |
| 5436 | vrefresh <= aconnector->max_vfreq; | ||
| 5435 | 5437 | ||
| 5436 | if (new_crtc_state->vrr_supported) { | 5438 | if (new_crtc_state->vrr_supported) { |
| 5437 | new_crtc_state->stream->ignore_msa_timing_param = true; | 5439 | new_crtc_state->stream->ignore_msa_timing_param = true; |
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 381581b01d48..05bbc2b622fc 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c | |||
| @@ -376,11 +376,7 @@ void drm_dev_unplug(struct drm_device *dev) | |||
| 376 | synchronize_srcu(&drm_unplug_srcu); | 376 | synchronize_srcu(&drm_unplug_srcu); |
| 377 | 377 | ||
| 378 | drm_dev_unregister(dev); | 378 | drm_dev_unregister(dev); |
| 379 | 379 | drm_dev_put(dev); | |
| 380 | mutex_lock(&drm_global_mutex); | ||
| 381 | if (dev->open_count == 0) | ||
| 382 | drm_dev_put(dev); | ||
| 383 | mutex_unlock(&drm_global_mutex); | ||
| 384 | } | 380 | } |
| 385 | EXPORT_SYMBOL(drm_dev_unplug); | 381 | EXPORT_SYMBOL(drm_dev_unplug); |
| 386 | 382 | ||
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 0e9349ff2d16..af2ab640cadb 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c | |||
| @@ -1963,7 +1963,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, | |||
| 1963 | best_depth = fmt->depth; | 1963 | best_depth = fmt->depth; |
| 1964 | } | 1964 | } |
| 1965 | } | 1965 | } |
| 1966 | if (sizes.surface_depth != best_depth) { | 1966 | if (sizes.surface_depth != best_depth && best_depth) { |
| 1967 | DRM_INFO("requested bpp %d, scaled depth down to %d", | 1967 | DRM_INFO("requested bpp %d, scaled depth down to %d", |
| 1968 | sizes.surface_bpp, best_depth); | 1968 | sizes.surface_bpp, best_depth); |
| 1969 | sizes.surface_depth = best_depth; | 1969 | sizes.surface_depth = best_depth; |
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 83a5bbca6e7e..7caa3c7ed978 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c | |||
| @@ -489,11 +489,9 @@ int drm_release(struct inode *inode, struct file *filp) | |||
| 489 | 489 | ||
| 490 | drm_close_helper(filp); | 490 | drm_close_helper(filp); |
| 491 | 491 | ||
| 492 | if (!--dev->open_count) { | 492 | if (!--dev->open_count) |
| 493 | drm_lastclose(dev); | 493 | drm_lastclose(dev); |
| 494 | if (drm_dev_is_unplugged(dev)) | 494 | |
| 495 | drm_put_dev(dev); | ||
| 496 | } | ||
| 497 | mutex_unlock(&drm_global_mutex); | 495 | mutex_unlock(&drm_global_mutex); |
| 498 | 496 | ||
| 499 | drm_minor_release(minor); | 497 | drm_minor_release(minor); |
diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c index 35b4ec3f7618..3592d04c33b2 100644 --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c | |||
| @@ -1441,7 +1441,7 @@ static inline int cmd_address_audit(struct parser_exec_state *s, | |||
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| 1443 | if (index_mode) { | 1443 | if (index_mode) { |
| 1444 | if (guest_gma >= I915_GTT_PAGE_SIZE / sizeof(u64)) { | 1444 | if (guest_gma >= I915_GTT_PAGE_SIZE) { |
| 1445 | ret = -EFAULT; | 1445 | ret = -EFAULT; |
| 1446 | goto err; | 1446 | goto err; |
| 1447 | } | 1447 | } |
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c index c7103dd2d8d5..d7052ab7908c 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.c +++ b/drivers/gpu/drm/i915/gvt/gtt.c | |||
| @@ -1882,7 +1882,11 @@ struct intel_vgpu_mm *intel_vgpu_create_ppgtt_mm(struct intel_vgpu *vgpu, | |||
| 1882 | } | 1882 | } |
| 1883 | 1883 | ||
| 1884 | list_add_tail(&mm->ppgtt_mm.list, &vgpu->gtt.ppgtt_mm_list_head); | 1884 | list_add_tail(&mm->ppgtt_mm.list, &vgpu->gtt.ppgtt_mm_list_head); |
| 1885 | |||
| 1886 | mutex_lock(&gvt->gtt.ppgtt_mm_lock); | ||
| 1885 | list_add_tail(&mm->ppgtt_mm.lru_list, &gvt->gtt.ppgtt_mm_lru_list_head); | 1887 | list_add_tail(&mm->ppgtt_mm.lru_list, &gvt->gtt.ppgtt_mm_lru_list_head); |
| 1888 | mutex_unlock(&gvt->gtt.ppgtt_mm_lock); | ||
| 1889 | |||
| 1886 | return mm; | 1890 | return mm; |
| 1887 | } | 1891 | } |
| 1888 | 1892 | ||
| @@ -1967,9 +1971,10 @@ int intel_vgpu_pin_mm(struct intel_vgpu_mm *mm) | |||
| 1967 | if (ret) | 1971 | if (ret) |
| 1968 | return ret; | 1972 | return ret; |
| 1969 | 1973 | ||
| 1974 | mutex_lock(&mm->vgpu->gvt->gtt.ppgtt_mm_lock); | ||
| 1970 | list_move_tail(&mm->ppgtt_mm.lru_list, | 1975 | list_move_tail(&mm->ppgtt_mm.lru_list, |
| 1971 | &mm->vgpu->gvt->gtt.ppgtt_mm_lru_list_head); | 1976 | &mm->vgpu->gvt->gtt.ppgtt_mm_lru_list_head); |
| 1972 | 1977 | mutex_unlock(&mm->vgpu->gvt->gtt.ppgtt_mm_lock); | |
| 1973 | } | 1978 | } |
| 1974 | 1979 | ||
| 1975 | return 0; | 1980 | return 0; |
| @@ -1980,6 +1985,8 @@ static int reclaim_one_ppgtt_mm(struct intel_gvt *gvt) | |||
| 1980 | struct intel_vgpu_mm *mm; | 1985 | struct intel_vgpu_mm *mm; |
| 1981 | struct list_head *pos, *n; | 1986 | struct list_head *pos, *n; |
| 1982 | 1987 | ||
| 1988 | mutex_lock(&gvt->gtt.ppgtt_mm_lock); | ||
| 1989 | |||
| 1983 | list_for_each_safe(pos, n, &gvt->gtt.ppgtt_mm_lru_list_head) { | 1990 | list_for_each_safe(pos, n, &gvt->gtt.ppgtt_mm_lru_list_head) { |
| 1984 | mm = container_of(pos, struct intel_vgpu_mm, ppgtt_mm.lru_list); | 1991 | mm = container_of(pos, struct intel_vgpu_mm, ppgtt_mm.lru_list); |
| 1985 | 1992 | ||
| @@ -1987,9 +1994,11 @@ static int reclaim_one_ppgtt_mm(struct intel_gvt *gvt) | |||
| 1987 | continue; | 1994 | continue; |
| 1988 | 1995 | ||
| 1989 | list_del_init(&mm->ppgtt_mm.lru_list); | 1996 | list_del_init(&mm->ppgtt_mm.lru_list); |
| 1997 | mutex_unlock(&gvt->gtt.ppgtt_mm_lock); | ||
| 1990 | invalidate_ppgtt_mm(mm); | 1998 | invalidate_ppgtt_mm(mm); |
| 1991 | return 1; | 1999 | return 1; |
| 1992 | } | 2000 | } |
| 2001 | mutex_unlock(&gvt->gtt.ppgtt_mm_lock); | ||
| 1993 | return 0; | 2002 | return 0; |
| 1994 | } | 2003 | } |
| 1995 | 2004 | ||
| @@ -2659,6 +2668,7 @@ int intel_gvt_init_gtt(struct intel_gvt *gvt) | |||
| 2659 | } | 2668 | } |
| 2660 | } | 2669 | } |
| 2661 | INIT_LIST_HEAD(&gvt->gtt.ppgtt_mm_lru_list_head); | 2670 | INIT_LIST_HEAD(&gvt->gtt.ppgtt_mm_lru_list_head); |
| 2671 | mutex_init(&gvt->gtt.ppgtt_mm_lock); | ||
| 2662 | return 0; | 2672 | return 0; |
| 2663 | } | 2673 | } |
| 2664 | 2674 | ||
| @@ -2699,7 +2709,9 @@ void intel_vgpu_invalidate_ppgtt(struct intel_vgpu *vgpu) | |||
| 2699 | list_for_each_safe(pos, n, &vgpu->gtt.ppgtt_mm_list_head) { | 2709 | list_for_each_safe(pos, n, &vgpu->gtt.ppgtt_mm_list_head) { |
| 2700 | mm = container_of(pos, struct intel_vgpu_mm, ppgtt_mm.list); | 2710 | mm = container_of(pos, struct intel_vgpu_mm, ppgtt_mm.list); |
| 2701 | if (mm->type == INTEL_GVT_MM_PPGTT) { | 2711 | if (mm->type == INTEL_GVT_MM_PPGTT) { |
| 2712 | mutex_lock(&vgpu->gvt->gtt.ppgtt_mm_lock); | ||
| 2702 | list_del_init(&mm->ppgtt_mm.lru_list); | 2713 | list_del_init(&mm->ppgtt_mm.lru_list); |
| 2714 | mutex_unlock(&vgpu->gvt->gtt.ppgtt_mm_lock); | ||
| 2703 | if (mm->ppgtt_mm.shadowed) | 2715 | if (mm->ppgtt_mm.shadowed) |
| 2704 | invalidate_ppgtt_mm(mm); | 2716 | invalidate_ppgtt_mm(mm); |
| 2705 | } | 2717 | } |
diff --git a/drivers/gpu/drm/i915/gvt/gtt.h b/drivers/gpu/drm/i915/gvt/gtt.h index d8cb04cc946d..edb610dc5d86 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.h +++ b/drivers/gpu/drm/i915/gvt/gtt.h | |||
| @@ -88,6 +88,7 @@ struct intel_gvt_gtt { | |||
| 88 | void (*mm_free_page_table)(struct intel_vgpu_mm *mm); | 88 | void (*mm_free_page_table)(struct intel_vgpu_mm *mm); |
| 89 | struct list_head oos_page_use_list_head; | 89 | struct list_head oos_page_use_list_head; |
| 90 | struct list_head oos_page_free_list_head; | 90 | struct list_head oos_page_free_list_head; |
| 91 | struct mutex ppgtt_mm_lock; | ||
| 91 | struct list_head ppgtt_mm_lru_list_head; | 92 | struct list_head ppgtt_mm_lru_list_head; |
| 92 | 93 | ||
| 93 | struct page *scratch_page; | 94 | struct page *scratch_page; |
diff --git a/drivers/gpu/drm/i915/gvt/mmio_context.c b/drivers/gpu/drm/i915/gvt/mmio_context.c index 7d84cfb9051a..7902fb162d09 100644 --- a/drivers/gpu/drm/i915/gvt/mmio_context.c +++ b/drivers/gpu/drm/i915/gvt/mmio_context.c | |||
| @@ -132,6 +132,7 @@ static struct engine_mmio gen9_engine_mmio_list[] __cacheline_aligned = { | |||
| 132 | 132 | ||
| 133 | {RCS, GEN9_GAMT_ECO_REG_RW_IA, 0x0, false}, /* 0x4ab0 */ | 133 | {RCS, GEN9_GAMT_ECO_REG_RW_IA, 0x0, false}, /* 0x4ab0 */ |
| 134 | {RCS, GEN9_CSFE_CHICKEN1_RCS, 0xffff, false}, /* 0x20d4 */ | 134 | {RCS, GEN9_CSFE_CHICKEN1_RCS, 0xffff, false}, /* 0x20d4 */ |
| 135 | {RCS, _MMIO(0x20D8), 0xffff, true}, /* 0x20d8 */ | ||
| 135 | 136 | ||
| 136 | {RCS, GEN8_GARBCNTL, 0x0, false}, /* 0xb004 */ | 137 | {RCS, GEN8_GARBCNTL, 0x0, false}, /* 0xb004 */ |
| 137 | {RCS, GEN7_FF_THREAD_MODE, 0x0, false}, /* 0x20a0 */ | 138 | {RCS, GEN7_FF_THREAD_MODE, 0x0, false}, /* 0x20a0 */ |
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c index 1bb8f936fdaa..159192c097cc 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c | |||
| @@ -346,7 +346,7 @@ static int set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload, | |||
| 346 | int i = 0; | 346 | int i = 0; |
| 347 | 347 | ||
| 348 | if (mm->type != INTEL_GVT_MM_PPGTT || !mm->ppgtt_mm.shadowed) | 348 | if (mm->type != INTEL_GVT_MM_PPGTT || !mm->ppgtt_mm.shadowed) |
| 349 | return -1; | 349 | return -EINVAL; |
| 350 | 350 | ||
| 351 | if (mm->ppgtt_mm.root_entry_type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY) { | 351 | if (mm->ppgtt_mm.root_entry_type == GTT_TYPE_PPGTT_ROOT_L4_ENTRY) { |
| 352 | px_dma(&ppgtt->pml4) = mm->ppgtt_mm.shadow_pdps[0]; | 352 | px_dma(&ppgtt->pml4) = mm->ppgtt_mm.shadow_pdps[0]; |
| @@ -410,12 +410,6 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload) | |||
| 410 | if (workload->shadow) | 410 | if (workload->shadow) |
| 411 | return 0; | 411 | return 0; |
| 412 | 412 | ||
| 413 | ret = set_context_ppgtt_from_shadow(workload, shadow_ctx); | ||
| 414 | if (ret < 0) { | ||
| 415 | gvt_vgpu_err("workload shadow ppgtt isn't ready\n"); | ||
| 416 | return ret; | ||
| 417 | } | ||
| 418 | |||
| 419 | /* pin shadow context by gvt even the shadow context will be pinned | 413 | /* pin shadow context by gvt even the shadow context will be pinned |
| 420 | * when i915 alloc request. That is because gvt will update the guest | 414 | * when i915 alloc request. That is because gvt will update the guest |
| 421 | * context from shadow context when workload is completed, and at that | 415 | * context from shadow context when workload is completed, and at that |
| @@ -678,6 +672,9 @@ static int dispatch_workload(struct intel_vgpu_workload *workload) | |||
| 678 | { | 672 | { |
| 679 | struct intel_vgpu *vgpu = workload->vgpu; | 673 | struct intel_vgpu *vgpu = workload->vgpu; |
| 680 | struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; | 674 | struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; |
| 675 | struct intel_vgpu_submission *s = &vgpu->submission; | ||
| 676 | struct i915_gem_context *shadow_ctx = s->shadow_ctx; | ||
| 677 | struct i915_request *rq; | ||
| 681 | int ring_id = workload->ring_id; | 678 | int ring_id = workload->ring_id; |
| 682 | int ret; | 679 | int ret; |
| 683 | 680 | ||
| @@ -687,6 +684,12 @@ static int dispatch_workload(struct intel_vgpu_workload *workload) | |||
| 687 | mutex_lock(&vgpu->vgpu_lock); | 684 | mutex_lock(&vgpu->vgpu_lock); |
| 688 | mutex_lock(&dev_priv->drm.struct_mutex); | 685 | mutex_lock(&dev_priv->drm.struct_mutex); |
| 689 | 686 | ||
| 687 | ret = set_context_ppgtt_from_shadow(workload, shadow_ctx); | ||
| 688 | if (ret < 0) { | ||
| 689 | gvt_vgpu_err("workload shadow ppgtt isn't ready\n"); | ||
| 690 | goto err_req; | ||
| 691 | } | ||
| 692 | |||
| 690 | ret = intel_gvt_workload_req_alloc(workload); | 693 | ret = intel_gvt_workload_req_alloc(workload); |
| 691 | if (ret) | 694 | if (ret) |
| 692 | goto err_req; | 695 | goto err_req; |
| @@ -703,6 +706,14 @@ static int dispatch_workload(struct intel_vgpu_workload *workload) | |||
| 703 | 706 | ||
| 704 | ret = prepare_workload(workload); | 707 | ret = prepare_workload(workload); |
| 705 | out: | 708 | out: |
| 709 | if (ret) { | ||
| 710 | /* We might still need to add request with | ||
| 711 | * clean ctx to retire it properly.. | ||
| 712 | */ | ||
| 713 | rq = fetch_and_zero(&workload->req); | ||
| 714 | i915_request_put(rq); | ||
| 715 | } | ||
| 716 | |||
| 706 | if (!IS_ERR_OR_NULL(workload->req)) { | 717 | if (!IS_ERR_OR_NULL(workload->req)) { |
| 707 | gvt_dbg_sched("ring id %d submit workload to i915 %p\n", | 718 | gvt_dbg_sched("ring id %d submit workload to i915 %p\n", |
| 708 | ring_id, workload->req); | 719 | ring_id, workload->req); |
| @@ -739,7 +750,8 @@ static struct intel_vgpu_workload *pick_next_workload( | |||
| 739 | goto out; | 750 | goto out; |
| 740 | } | 751 | } |
| 741 | 752 | ||
| 742 | if (list_empty(workload_q_head(scheduler->current_vgpu, ring_id))) | 753 | if (!scheduler->current_vgpu->active || |
| 754 | list_empty(workload_q_head(scheduler->current_vgpu, ring_id))) | ||
| 743 | goto out; | 755 | goto out; |
| 744 | 756 | ||
| 745 | /* | 757 | /* |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 9adc7bb9e69c..a67a63b5aa84 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
| @@ -2346,7 +2346,8 @@ static inline unsigned int i915_sg_segment_size(void) | |||
| 2346 | INTEL_DEVID(dev_priv) == 0x5915 || \ | 2346 | INTEL_DEVID(dev_priv) == 0x5915 || \ |
| 2347 | INTEL_DEVID(dev_priv) == 0x591E) | 2347 | INTEL_DEVID(dev_priv) == 0x591E) |
| 2348 | #define IS_AML_ULX(dev_priv) (INTEL_DEVID(dev_priv) == 0x591C || \ | 2348 | #define IS_AML_ULX(dev_priv) (INTEL_DEVID(dev_priv) == 0x591C || \ |
| 2349 | INTEL_DEVID(dev_priv) == 0x87C0) | 2349 | INTEL_DEVID(dev_priv) == 0x87C0 || \ |
| 2350 | INTEL_DEVID(dev_priv) == 0x87CA) | ||
| 2350 | #define IS_SKL_GT2(dev_priv) (IS_SKYLAKE(dev_priv) && \ | 2351 | #define IS_SKL_GT2(dev_priv) (IS_SKYLAKE(dev_priv) && \ |
| 2351 | INTEL_INFO(dev_priv)->gt == 2) | 2352 | INTEL_INFO(dev_priv)->gt == 2) |
| 2352 | #define IS_SKL_GT3(dev_priv) (IS_SKYLAKE(dev_priv) && \ | 2353 | #define IS_SKL_GT3(dev_priv) (IS_SKYLAKE(dev_priv) && \ |
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 638a586469f9..047855dd8c6b 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
| @@ -2863,7 +2863,7 @@ enum i915_power_well_id { | |||
| 2863 | #define GEN11_GT_VEBOX_VDBOX_DISABLE _MMIO(0x9140) | 2863 | #define GEN11_GT_VEBOX_VDBOX_DISABLE _MMIO(0x9140) |
| 2864 | #define GEN11_GT_VDBOX_DISABLE_MASK 0xff | 2864 | #define GEN11_GT_VDBOX_DISABLE_MASK 0xff |
| 2865 | #define GEN11_GT_VEBOX_DISABLE_SHIFT 16 | 2865 | #define GEN11_GT_VEBOX_DISABLE_SHIFT 16 |
| 2866 | #define GEN11_GT_VEBOX_DISABLE_MASK (0xff << GEN11_GT_VEBOX_DISABLE_SHIFT) | 2866 | #define GEN11_GT_VEBOX_DISABLE_MASK (0x0f << GEN11_GT_VEBOX_DISABLE_SHIFT) |
| 2867 | 2867 | ||
| 2868 | #define GEN11_EU_DISABLE _MMIO(0x9134) | 2868 | #define GEN11_EU_DISABLE _MMIO(0x9134) |
| 2869 | #define GEN11_EU_DIS_MASK 0xFF | 2869 | #define GEN11_EU_DIS_MASK 0xFF |
| @@ -9243,7 +9243,7 @@ enum skl_power_gate { | |||
| 9243 | #define TRANS_DDI_FUNC_CTL2(tran) _MMIO_TRANS2(tran, \ | 9243 | #define TRANS_DDI_FUNC_CTL2(tran) _MMIO_TRANS2(tran, \ |
| 9244 | _TRANS_DDI_FUNC_CTL2_A) | 9244 | _TRANS_DDI_FUNC_CTL2_A) |
| 9245 | #define PORT_SYNC_MODE_ENABLE (1 << 4) | 9245 | #define PORT_SYNC_MODE_ENABLE (1 << 4) |
| 9246 | #define PORT_SYNC_MODE_MASTER_SELECT(x) ((x) < 0) | 9246 | #define PORT_SYNC_MODE_MASTER_SELECT(x) ((x) << 0) |
| 9247 | #define PORT_SYNC_MODE_MASTER_SELECT_MASK (0x7 << 0) | 9247 | #define PORT_SYNC_MODE_MASTER_SELECT_MASK (0x7 << 0) |
| 9248 | #define PORT_SYNC_MODE_MASTER_SELECT_SHIFT 0 | 9248 | #define PORT_SYNC_MODE_MASTER_SELECT_SHIFT 0 |
| 9249 | 9249 | ||
diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c index 32dce7176f63..b9b0ea4e2404 100644 --- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c | |||
| @@ -455,7 +455,7 @@ static int igt_evict_contexts(void *arg) | |||
| 455 | struct i915_gem_context *ctx; | 455 | struct i915_gem_context *ctx; |
| 456 | 456 | ||
| 457 | ctx = live_context(i915, file); | 457 | ctx = live_context(i915, file); |
| 458 | if (!ctx) | 458 | if (IS_ERR(ctx)) |
| 459 | break; | 459 | break; |
| 460 | 460 | ||
| 461 | /* We will need some GGTT space for the rq's context */ | 461 | /* We will need some GGTT space for the rq's context */ |
diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c index 2281ed3eb774..8a4ebcb6405c 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c | |||
| @@ -337,12 +337,14 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) | |||
| 337 | 337 | ||
| 338 | ret = drm_dev_register(drm, 0); | 338 | ret = drm_dev_register(drm, 0); |
| 339 | if (ret) | 339 | if (ret) |
| 340 | goto free_drm; | 340 | goto uninstall_irq; |
| 341 | 341 | ||
| 342 | drm_fbdev_generic_setup(drm, 32); | 342 | drm_fbdev_generic_setup(drm, 32); |
| 343 | 343 | ||
| 344 | return 0; | 344 | return 0; |
| 345 | 345 | ||
| 346 | uninstall_irq: | ||
| 347 | drm_irq_uninstall(drm); | ||
| 346 | free_drm: | 348 | free_drm: |
| 347 | drm_dev_put(drm); | 349 | drm_dev_put(drm); |
| 348 | 350 | ||
| @@ -356,8 +358,8 @@ static int meson_drv_bind(struct device *dev) | |||
| 356 | 358 | ||
| 357 | static void meson_drv_unbind(struct device *dev) | 359 | static void meson_drv_unbind(struct device *dev) |
| 358 | { | 360 | { |
| 359 | struct drm_device *drm = dev_get_drvdata(dev); | 361 | struct meson_drm *priv = dev_get_drvdata(dev); |
| 360 | struct meson_drm *priv = drm->dev_private; | 362 | struct drm_device *drm = priv->drm; |
| 361 | 363 | ||
| 362 | if (priv->canvas) { | 364 | if (priv->canvas) { |
| 363 | meson_canvas_free(priv->canvas, priv->canvas_id_osd1); | 365 | meson_canvas_free(priv->canvas, priv->canvas_id_osd1); |
| @@ -367,6 +369,7 @@ static void meson_drv_unbind(struct device *dev) | |||
| 367 | } | 369 | } |
| 368 | 370 | ||
| 369 | drm_dev_unregister(drm); | 371 | drm_dev_unregister(drm); |
| 372 | drm_irq_uninstall(drm); | ||
| 370 | drm_kms_helper_poll_fini(drm); | 373 | drm_kms_helper_poll_fini(drm); |
| 371 | drm_mode_config_cleanup(drm); | 374 | drm_mode_config_cleanup(drm); |
| 372 | drm_dev_put(drm); | 375 | drm_dev_put(drm); |
diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index e28814f4ea6c..563953ec6ad0 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c | |||
| @@ -569,7 +569,8 @@ dw_hdmi_mode_valid(struct drm_connector *connector, | |||
| 569 | DRM_DEBUG_DRIVER("Modeline " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode)); | 569 | DRM_DEBUG_DRIVER("Modeline " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode)); |
| 570 | 570 | ||
| 571 | /* If sink max TMDS clock, we reject the mode */ | 571 | /* If sink max TMDS clock, we reject the mode */ |
| 572 | if (mode->clock > connector->display_info.max_tmds_clock) | 572 | if (connector->display_info.max_tmds_clock && |
| 573 | mode->clock > connector->display_info.max_tmds_clock) | ||
| 573 | return MODE_BAD; | 574 | return MODE_BAD; |
| 574 | 575 | ||
| 575 | /* Check against non-VIC supported modes */ | 576 | /* Check against non-VIC supported modes */ |
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index c7d4c6073ea5..0d4ade9d4722 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c | |||
| @@ -541,6 +541,18 @@ static void vop_core_clks_disable(struct vop *vop) | |||
| 541 | clk_disable(vop->hclk); | 541 | clk_disable(vop->hclk); |
| 542 | } | 542 | } |
| 543 | 543 | ||
| 544 | static void vop_win_disable(struct vop *vop, const struct vop_win_data *win) | ||
| 545 | { | ||
| 546 | if (win->phy->scl && win->phy->scl->ext) { | ||
| 547 | VOP_SCL_SET_EXT(vop, win, yrgb_hor_scl_mode, SCALE_NONE); | ||
| 548 | VOP_SCL_SET_EXT(vop, win, yrgb_ver_scl_mode, SCALE_NONE); | ||
| 549 | VOP_SCL_SET_EXT(vop, win, cbcr_hor_scl_mode, SCALE_NONE); | ||
| 550 | VOP_SCL_SET_EXT(vop, win, cbcr_ver_scl_mode, SCALE_NONE); | ||
| 551 | } | ||
| 552 | |||
| 553 | VOP_WIN_SET(vop, win, enable, 0); | ||
| 554 | } | ||
| 555 | |||
| 544 | static int vop_enable(struct drm_crtc *crtc) | 556 | static int vop_enable(struct drm_crtc *crtc) |
| 545 | { | 557 | { |
| 546 | struct vop *vop = to_vop(crtc); | 558 | struct vop *vop = to_vop(crtc); |
| @@ -586,7 +598,7 @@ static int vop_enable(struct drm_crtc *crtc) | |||
| 586 | struct vop_win *vop_win = &vop->win[i]; | 598 | struct vop_win *vop_win = &vop->win[i]; |
| 587 | const struct vop_win_data *win = vop_win->data; | 599 | const struct vop_win_data *win = vop_win->data; |
| 588 | 600 | ||
| 589 | VOP_WIN_SET(vop, win, enable, 0); | 601 | vop_win_disable(vop, win); |
| 590 | } | 602 | } |
| 591 | spin_unlock(&vop->reg_lock); | 603 | spin_unlock(&vop->reg_lock); |
| 592 | 604 | ||
| @@ -735,7 +747,7 @@ static void vop_plane_atomic_disable(struct drm_plane *plane, | |||
| 735 | 747 | ||
| 736 | spin_lock(&vop->reg_lock); | 748 | spin_lock(&vop->reg_lock); |
| 737 | 749 | ||
| 738 | VOP_WIN_SET(vop, win, enable, 0); | 750 | vop_win_disable(vop, win); |
| 739 | 751 | ||
| 740 | spin_unlock(&vop->reg_lock); | 752 | spin_unlock(&vop->reg_lock); |
| 741 | } | 753 | } |
| @@ -1622,7 +1634,7 @@ static int vop_initial(struct vop *vop) | |||
| 1622 | int channel = i * 2 + 1; | 1634 | int channel = i * 2 + 1; |
| 1623 | 1635 | ||
| 1624 | VOP_WIN_SET(vop, win, channel, (channel + 1) << 4 | channel); | 1636 | VOP_WIN_SET(vop, win, channel, (channel + 1) << 4 | channel); |
| 1625 | VOP_WIN_SET(vop, win, enable, 0); | 1637 | vop_win_disable(vop, win); |
| 1626 | VOP_WIN_SET(vop, win, gate, 1); | 1638 | VOP_WIN_SET(vop, win, gate, 1); |
| 1627 | } | 1639 | } |
| 1628 | 1640 | ||
diff --git a/drivers/gpu/drm/tegra/hub.c b/drivers/gpu/drm/tegra/hub.c index ba9b3cfb8c3d..b3436c2aed68 100644 --- a/drivers/gpu/drm/tegra/hub.c +++ b/drivers/gpu/drm/tegra/hub.c | |||
| @@ -378,14 +378,16 @@ static int tegra_shared_plane_atomic_check(struct drm_plane *plane, | |||
| 378 | static void tegra_shared_plane_atomic_disable(struct drm_plane *plane, | 378 | static void tegra_shared_plane_atomic_disable(struct drm_plane *plane, |
| 379 | struct drm_plane_state *old_state) | 379 | struct drm_plane_state *old_state) |
| 380 | { | 380 | { |
| 381 | struct tegra_dc *dc = to_tegra_dc(old_state->crtc); | ||
| 382 | struct tegra_plane *p = to_tegra_plane(plane); | 381 | struct tegra_plane *p = to_tegra_plane(plane); |
| 382 | struct tegra_dc *dc; | ||
| 383 | u32 value; | 383 | u32 value; |
| 384 | 384 | ||
| 385 | /* rien ne va plus */ | 385 | /* rien ne va plus */ |
| 386 | if (!old_state || !old_state->crtc) | 386 | if (!old_state || !old_state->crtc) |
| 387 | return; | 387 | return; |
| 388 | 388 | ||
| 389 | dc = to_tegra_dc(old_state->crtc); | ||
| 390 | |||
| 389 | /* | 391 | /* |
| 390 | * XXX Legacy helpers seem to sometimes call ->atomic_disable() even | 392 | * XXX Legacy helpers seem to sometimes call ->atomic_disable() even |
| 391 | * on planes that are already disabled. Make sure we fallback to the | 393 | * on planes that are already disabled. Make sure we fallback to the |
diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index 39bfed9623de..982ce37ecde1 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c | |||
| @@ -106,6 +106,7 @@ static int vic_boot(struct vic *vic) | |||
| 106 | if (vic->booted) | 106 | if (vic->booted) |
| 107 | return 0; | 107 | return 0; |
| 108 | 108 | ||
| 109 | #ifdef CONFIG_IOMMU_API | ||
| 109 | if (vic->config->supports_sid) { | 110 | if (vic->config->supports_sid) { |
| 110 | struct iommu_fwspec *spec = dev_iommu_fwspec_get(vic->dev); | 111 | struct iommu_fwspec *spec = dev_iommu_fwspec_get(vic->dev); |
| 111 | u32 value; | 112 | u32 value; |
| @@ -121,6 +122,7 @@ static int vic_boot(struct vic *vic) | |||
| 121 | vic_writel(vic, value, VIC_THI_STREAMID1); | 122 | vic_writel(vic, value, VIC_THI_STREAMID1); |
| 122 | } | 123 | } |
| 123 | } | 124 | } |
| 125 | #endif | ||
| 124 | 126 | ||
| 125 | /* setup clockgating registers */ | 127 | /* setup clockgating registers */ |
| 126 | vic_writel(vic, CG_IDLE_CG_DLY_CNT(4) | | 128 | vic_writel(vic, CG_IDLE_CG_DLY_CNT(4) | |
diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c index 66885c24590f..c1bd5e3d9e4a 100644 --- a/drivers/gpu/drm/udl/udl_connector.c +++ b/drivers/gpu/drm/udl/udl_connector.c | |||
| @@ -18,18 +18,19 @@ | |||
| 18 | #include "udl_connector.h" | 18 | #include "udl_connector.h" |
| 19 | #include "udl_drv.h" | 19 | #include "udl_drv.h" |
| 20 | 20 | ||
| 21 | static bool udl_get_edid_block(struct udl_device *udl, int block_idx, | 21 | static int udl_get_edid_block(void *data, u8 *buf, unsigned int block, |
| 22 | u8 *buff) | 22 | size_t len) |
| 23 | { | 23 | { |
| 24 | int ret, i; | 24 | int ret, i; |
| 25 | u8 *read_buff; | 25 | u8 *read_buff; |
| 26 | struct udl_device *udl = data; | ||
| 26 | 27 | ||
| 27 | read_buff = kmalloc(2, GFP_KERNEL); | 28 | read_buff = kmalloc(2, GFP_KERNEL); |
| 28 | if (!read_buff) | 29 | if (!read_buff) |
| 29 | return false; | 30 | return -1; |
| 30 | 31 | ||
| 31 | for (i = 0; i < EDID_LENGTH; i++) { | 32 | for (i = 0; i < len; i++) { |
| 32 | int bval = (i + block_idx * EDID_LENGTH) << 8; | 33 | int bval = (i + block * EDID_LENGTH) << 8; |
| 33 | ret = usb_control_msg(udl->udev, | 34 | ret = usb_control_msg(udl->udev, |
| 34 | usb_rcvctrlpipe(udl->udev, 0), | 35 | usb_rcvctrlpipe(udl->udev, 0), |
| 35 | (0x02), (0x80 | (0x02 << 5)), bval, | 36 | (0x02), (0x80 | (0x02 << 5)), bval, |
| @@ -37,60 +38,13 @@ static bool udl_get_edid_block(struct udl_device *udl, int block_idx, | |||
| 37 | if (ret < 1) { | 38 | if (ret < 1) { |
| 38 | DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret); | 39 | DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret); |
| 39 | kfree(read_buff); | 40 | kfree(read_buff); |
| 40 | return false; | 41 | return -1; |
| 41 | } | 42 | } |
| 42 | buff[i] = read_buff[1]; | 43 | buf[i] = read_buff[1]; |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | kfree(read_buff); | 46 | kfree(read_buff); |
| 46 | return true; | 47 | return 0; |
| 47 | } | ||
| 48 | |||
| 49 | static bool udl_get_edid(struct udl_device *udl, u8 **result_buff, | ||
| 50 | int *result_buff_size) | ||
| 51 | { | ||
| 52 | int i, extensions; | ||
| 53 | u8 *block_buff = NULL, *buff_ptr; | ||
| 54 | |||
| 55 | block_buff = kmalloc(EDID_LENGTH, GFP_KERNEL); | ||
| 56 | if (block_buff == NULL) | ||
| 57 | return false; | ||
| 58 | |||
| 59 | if (udl_get_edid_block(udl, 0, block_buff) && | ||
| 60 | memchr_inv(block_buff, 0, EDID_LENGTH)) { | ||
| 61 | extensions = ((struct edid *)block_buff)->extensions; | ||
| 62 | if (extensions > 0) { | ||
| 63 | /* we have to read all extensions one by one */ | ||
| 64 | *result_buff_size = EDID_LENGTH * (extensions + 1); | ||
| 65 | *result_buff = kmalloc(*result_buff_size, GFP_KERNEL); | ||
| 66 | buff_ptr = *result_buff; | ||
| 67 | if (buff_ptr == NULL) { | ||
| 68 | kfree(block_buff); | ||
| 69 | return false; | ||
| 70 | } | ||
| 71 | memcpy(buff_ptr, block_buff, EDID_LENGTH); | ||
| 72 | kfree(block_buff); | ||
| 73 | buff_ptr += EDID_LENGTH; | ||
| 74 | for (i = 1; i < extensions; ++i) { | ||
| 75 | if (udl_get_edid_block(udl, i, buff_ptr)) { | ||
| 76 | buff_ptr += EDID_LENGTH; | ||
| 77 | } else { | ||
| 78 | kfree(*result_buff); | ||
| 79 | *result_buff = NULL; | ||
| 80 | return false; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | return true; | ||
| 84 | } | ||
| 85 | /* we have only base edid block */ | ||
| 86 | *result_buff = block_buff; | ||
| 87 | *result_buff_size = EDID_LENGTH; | ||
| 88 | return true; | ||
| 89 | } | ||
| 90 | |||
| 91 | kfree(block_buff); | ||
| 92 | |||
| 93 | return false; | ||
| 94 | } | 48 | } |
| 95 | 49 | ||
| 96 | static int udl_get_modes(struct drm_connector *connector) | 50 | static int udl_get_modes(struct drm_connector *connector) |
| @@ -122,8 +76,6 @@ static enum drm_mode_status udl_mode_valid(struct drm_connector *connector, | |||
| 122 | static enum drm_connector_status | 76 | static enum drm_connector_status |
| 123 | udl_detect(struct drm_connector *connector, bool force) | 77 | udl_detect(struct drm_connector *connector, bool force) |
| 124 | { | 78 | { |
| 125 | u8 *edid_buff = NULL; | ||
| 126 | int edid_buff_size = 0; | ||
| 127 | struct udl_device *udl = connector->dev->dev_private; | 79 | struct udl_device *udl = connector->dev->dev_private; |
| 128 | struct udl_drm_connector *udl_connector = | 80 | struct udl_drm_connector *udl_connector = |
| 129 | container_of(connector, | 81 | container_of(connector, |
| @@ -136,12 +88,10 @@ udl_detect(struct drm_connector *connector, bool force) | |||
| 136 | udl_connector->edid = NULL; | 88 | udl_connector->edid = NULL; |
| 137 | } | 89 | } |
| 138 | 90 | ||
| 139 | 91 | udl_connector->edid = drm_do_get_edid(connector, udl_get_edid_block, udl); | |
| 140 | if (!udl_get_edid(udl, &edid_buff, &edid_buff_size)) | 92 | if (!udl_connector->edid) |
| 141 | return connector_status_disconnected; | 93 | return connector_status_disconnected; |
| 142 | 94 | ||
| 143 | udl_connector->edid = (struct edid *)edid_buff; | ||
| 144 | |||
| 145 | return connector_status_connected; | 95 | return connector_status_connected; |
| 146 | } | 96 | } |
| 147 | 97 | ||
diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index 5930facd6d2d..11a8f99ba18c 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c | |||
| @@ -191,13 +191,9 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev, | |||
| 191 | ret = drm_gem_handle_create(file, &obj->base, handle); | 191 | ret = drm_gem_handle_create(file, &obj->base, handle); |
| 192 | drm_gem_object_put_unlocked(&obj->base); | 192 | drm_gem_object_put_unlocked(&obj->base); |
| 193 | if (ret) | 193 | if (ret) |
| 194 | goto err; | 194 | return ERR_PTR(ret); |
| 195 | 195 | ||
| 196 | return &obj->base; | 196 | return &obj->base; |
| 197 | |||
| 198 | err: | ||
| 199 | __vgem_gem_destroy(obj); | ||
| 200 | return ERR_PTR(ret); | ||
| 201 | } | 197 | } |
| 202 | 198 | ||
| 203 | static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev, | 199 | static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev, |
diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c index 138b0bb325cf..69048e73377d 100644 --- a/drivers/gpu/drm/vkms/vkms_gem.c +++ b/drivers/gpu/drm/vkms/vkms_gem.c | |||
| @@ -111,11 +111,8 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, | |||
| 111 | 111 | ||
| 112 | ret = drm_gem_handle_create(file, &obj->gem, handle); | 112 | ret = drm_gem_handle_create(file, &obj->gem, handle); |
| 113 | drm_gem_object_put_unlocked(&obj->gem); | 113 | drm_gem_object_put_unlocked(&obj->gem); |
| 114 | if (ret) { | 114 | if (ret) |
| 115 | drm_gem_object_release(&obj->gem); | ||
| 116 | kfree(obj); | ||
| 117 | return ERR_PTR(ret); | 115 | return ERR_PTR(ret); |
| 118 | } | ||
| 119 | 116 | ||
| 120 | return &obj->gem; | 117 | return &obj->gem; |
| 121 | } | 118 | } |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index f2c681971201..f8979abb9a19 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
| @@ -131,6 +131,7 @@ config I2C_I801 | |||
| 131 | Cannon Lake (PCH) | 131 | Cannon Lake (PCH) |
| 132 | Cedar Fork (PCH) | 132 | Cedar Fork (PCH) |
| 133 | Ice Lake (PCH) | 133 | Ice Lake (PCH) |
| 134 | Comet Lake (PCH) | ||
| 134 | 135 | ||
| 135 | This driver can also be built as a module. If so, the module | 136 | This driver can also be built as a module. If so, the module |
| 136 | will be called i2c-i801. | 137 | will be called i2c-i801. |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index c91e145ef5a5..679c6c41f64b 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
| @@ -71,6 +71,7 @@ | |||
| 71 | * Cannon Lake-LP (PCH) 0x9da3 32 hard yes yes yes | 71 | * Cannon Lake-LP (PCH) 0x9da3 32 hard yes yes yes |
| 72 | * Cedar Fork (PCH) 0x18df 32 hard yes yes yes | 72 | * Cedar Fork (PCH) 0x18df 32 hard yes yes yes |
| 73 | * Ice Lake-LP (PCH) 0x34a3 32 hard yes yes yes | 73 | * Ice Lake-LP (PCH) 0x34a3 32 hard yes yes yes |
| 74 | * Comet Lake (PCH) 0x02a3 32 hard yes yes yes | ||
| 74 | * | 75 | * |
| 75 | * Features supported by this driver: | 76 | * Features supported by this driver: |
| 76 | * Software PEC no | 77 | * Software PEC no |
| @@ -240,6 +241,7 @@ | |||
| 240 | #define PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS 0xa223 | 241 | #define PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS 0xa223 |
| 241 | #define PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS 0xa2a3 | 242 | #define PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS 0xa2a3 |
| 242 | #define PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS 0xa323 | 243 | #define PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS 0xa323 |
| 244 | #define PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS 0x02a3 | ||
| 243 | 245 | ||
| 244 | struct i801_mux_config { | 246 | struct i801_mux_config { |
| 245 | char *gpio_chip; | 247 | char *gpio_chip; |
| @@ -1038,6 +1040,7 @@ static const struct pci_device_id i801_ids[] = { | |||
| 1038 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS) }, | 1040 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS) }, |
| 1039 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS) }, | 1041 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS) }, |
| 1040 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS) }, | 1042 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS) }, |
| 1043 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS) }, | ||
| 1041 | { 0, } | 1044 | { 0, } |
| 1042 | }; | 1045 | }; |
| 1043 | 1046 | ||
| @@ -1534,6 +1537,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
| 1534 | case PCI_DEVICE_ID_INTEL_DNV_SMBUS: | 1537 | case PCI_DEVICE_ID_INTEL_DNV_SMBUS: |
| 1535 | case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS: | 1538 | case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS: |
| 1536 | case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS: | 1539 | case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS: |
| 1540 | case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS: | ||
| 1537 | priv->features |= FEATURE_I2C_BLOCK_READ; | 1541 | priv->features |= FEATURE_I2C_BLOCK_READ; |
| 1538 | priv->features |= FEATURE_IRQ; | 1542 | priv->features |= FEATURE_IRQ; |
| 1539 | priv->features |= FEATURE_SMBUS_PEC; | 1543 | priv->features |= FEATURE_SMBUS_PEC; |
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 21cb088d6687..f7cdd2ab7f11 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
| @@ -3169,21 +3169,24 @@ static void amd_iommu_get_resv_regions(struct device *dev, | |||
| 3169 | return; | 3169 | return; |
| 3170 | 3170 | ||
| 3171 | list_for_each_entry(entry, &amd_iommu_unity_map, list) { | 3171 | list_for_each_entry(entry, &amd_iommu_unity_map, list) { |
| 3172 | int type, prot = 0; | ||
| 3172 | size_t length; | 3173 | size_t length; |
| 3173 | int prot = 0; | ||
| 3174 | 3174 | ||
| 3175 | if (devid < entry->devid_start || devid > entry->devid_end) | 3175 | if (devid < entry->devid_start || devid > entry->devid_end) |
| 3176 | continue; | 3176 | continue; |
| 3177 | 3177 | ||
| 3178 | type = IOMMU_RESV_DIRECT; | ||
| 3178 | length = entry->address_end - entry->address_start; | 3179 | length = entry->address_end - entry->address_start; |
| 3179 | if (entry->prot & IOMMU_PROT_IR) | 3180 | if (entry->prot & IOMMU_PROT_IR) |
| 3180 | prot |= IOMMU_READ; | 3181 | prot |= IOMMU_READ; |
| 3181 | if (entry->prot & IOMMU_PROT_IW) | 3182 | if (entry->prot & IOMMU_PROT_IW) |
| 3182 | prot |= IOMMU_WRITE; | 3183 | prot |= IOMMU_WRITE; |
| 3184 | if (entry->prot & IOMMU_UNITY_MAP_FLAG_EXCL_RANGE) | ||
| 3185 | /* Exclusion range */ | ||
| 3186 | type = IOMMU_RESV_RESERVED; | ||
| 3183 | 3187 | ||
| 3184 | region = iommu_alloc_resv_region(entry->address_start, | 3188 | region = iommu_alloc_resv_region(entry->address_start, |
| 3185 | length, prot, | 3189 | length, prot, type); |
| 3186 | IOMMU_RESV_DIRECT); | ||
| 3187 | if (!region) { | 3190 | if (!region) { |
| 3188 | dev_err(dev, "Out of memory allocating dm-regions\n"); | 3191 | dev_err(dev, "Out of memory allocating dm-regions\n"); |
| 3189 | return; | 3192 | return; |
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index f773792d77fd..1b1378619fc9 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c | |||
| @@ -2013,6 +2013,9 @@ static int __init init_unity_map_range(struct ivmd_header *m) | |||
| 2013 | if (e == NULL) | 2013 | if (e == NULL) |
| 2014 | return -ENOMEM; | 2014 | return -ENOMEM; |
| 2015 | 2015 | ||
| 2016 | if (m->flags & IVMD_FLAG_EXCL_RANGE) | ||
| 2017 | init_exclusion_range(m); | ||
| 2018 | |||
| 2016 | switch (m->type) { | 2019 | switch (m->type) { |
| 2017 | default: | 2020 | default: |
| 2018 | kfree(e); | 2021 | kfree(e); |
| @@ -2059,9 +2062,7 @@ static int __init init_memory_definitions(struct acpi_table_header *table) | |||
| 2059 | 2062 | ||
| 2060 | while (p < end) { | 2063 | while (p < end) { |
| 2061 | m = (struct ivmd_header *)p; | 2064 | m = (struct ivmd_header *)p; |
| 2062 | if (m->flags & IVMD_FLAG_EXCL_RANGE) | 2065 | if (m->flags & (IVMD_FLAG_UNITY_MAP | IVMD_FLAG_EXCL_RANGE)) |
| 2063 | init_exclusion_range(m); | ||
| 2064 | else if (m->flags & IVMD_FLAG_UNITY_MAP) | ||
| 2065 | init_unity_map_range(m); | 2066 | init_unity_map_range(m); |
| 2066 | 2067 | ||
| 2067 | p += m->length; | 2068 | p += m->length; |
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index eae0741f72dc..87965e4d9647 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h | |||
| @@ -374,6 +374,8 @@ | |||
| 374 | #define IOMMU_PROT_IR 0x01 | 374 | #define IOMMU_PROT_IR 0x01 |
| 375 | #define IOMMU_PROT_IW 0x02 | 375 | #define IOMMU_PROT_IW 0x02 |
| 376 | 376 | ||
| 377 | #define IOMMU_UNITY_MAP_FLAG_EXCL_RANGE (1 << 2) | ||
| 378 | |||
| 377 | /* IOMMU capabilities */ | 379 | /* IOMMU capabilities */ |
| 378 | #define IOMMU_CAP_IOTLB 24 | 380 | #define IOMMU_CAP_IOTLB 24 |
| 379 | #define IOMMU_CAP_NPCACHE 26 | 381 | #define IOMMU_CAP_NPCACHE 26 |
diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index f101afc315ab..9a8a8870e267 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c | |||
| @@ -160,6 +160,14 @@ | |||
| 160 | 160 | ||
| 161 | #define ARM_V7S_TCR_PD1 BIT(5) | 161 | #define ARM_V7S_TCR_PD1 BIT(5) |
| 162 | 162 | ||
| 163 | #ifdef CONFIG_ZONE_DMA32 | ||
| 164 | #define ARM_V7S_TABLE_GFP_DMA GFP_DMA32 | ||
| 165 | #define ARM_V7S_TABLE_SLAB_FLAGS SLAB_CACHE_DMA32 | ||
| 166 | #else | ||
| 167 | #define ARM_V7S_TABLE_GFP_DMA GFP_DMA | ||
| 168 | #define ARM_V7S_TABLE_SLAB_FLAGS SLAB_CACHE_DMA | ||
| 169 | #endif | ||
| 170 | |||
| 163 | typedef u32 arm_v7s_iopte; | 171 | typedef u32 arm_v7s_iopte; |
| 164 | 172 | ||
| 165 | static bool selftest_running; | 173 | static bool selftest_running; |
| @@ -197,13 +205,16 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp, | |||
| 197 | void *table = NULL; | 205 | void *table = NULL; |
| 198 | 206 | ||
| 199 | if (lvl == 1) | 207 | if (lvl == 1) |
| 200 | table = (void *)__get_dma_pages(__GFP_ZERO, get_order(size)); | 208 | table = (void *)__get_free_pages( |
| 209 | __GFP_ZERO | ARM_V7S_TABLE_GFP_DMA, get_order(size)); | ||
| 201 | else if (lvl == 2) | 210 | else if (lvl == 2) |
| 202 | table = kmem_cache_zalloc(data->l2_tables, gfp | GFP_DMA); | 211 | table = kmem_cache_zalloc(data->l2_tables, gfp); |
| 203 | phys = virt_to_phys(table); | 212 | phys = virt_to_phys(table); |
| 204 | if (phys != (arm_v7s_iopte)phys) | 213 | if (phys != (arm_v7s_iopte)phys) { |
| 205 | /* Doesn't fit in PTE */ | 214 | /* Doesn't fit in PTE */ |
| 215 | dev_err(dev, "Page table does not fit in PTE: %pa", &phys); | ||
| 206 | goto out_free; | 216 | goto out_free; |
| 217 | } | ||
| 207 | if (table && !(cfg->quirks & IO_PGTABLE_QUIRK_NO_DMA)) { | 218 | if (table && !(cfg->quirks & IO_PGTABLE_QUIRK_NO_DMA)) { |
| 208 | dma = dma_map_single(dev, table, size, DMA_TO_DEVICE); | 219 | dma = dma_map_single(dev, table, size, DMA_TO_DEVICE); |
| 209 | if (dma_mapping_error(dev, dma)) | 220 | if (dma_mapping_error(dev, dma)) |
| @@ -733,7 +744,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg, | |||
| 733 | data->l2_tables = kmem_cache_create("io-pgtable_armv7s_l2", | 744 | data->l2_tables = kmem_cache_create("io-pgtable_armv7s_l2", |
| 734 | ARM_V7S_TABLE_SIZE(2), | 745 | ARM_V7S_TABLE_SIZE(2), |
| 735 | ARM_V7S_TABLE_SIZE(2), | 746 | ARM_V7S_TABLE_SIZE(2), |
| 736 | SLAB_CACHE_DMA, NULL); | 747 | ARM_V7S_TABLE_SLAB_FLAGS, NULL); |
| 737 | if (!data->l2_tables) | 748 | if (!data->l2_tables) |
| 738 | goto out_free_data; | 749 | goto out_free_data; |
| 739 | 750 | ||
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 33a982e33716..109de67d5d72 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c | |||
| @@ -1105,10 +1105,12 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev) | |||
| 1105 | 1105 | ||
| 1106 | dom = __iommu_domain_alloc(dev->bus, iommu_def_domain_type); | 1106 | dom = __iommu_domain_alloc(dev->bus, iommu_def_domain_type); |
| 1107 | if (!dom && iommu_def_domain_type != IOMMU_DOMAIN_DMA) { | 1107 | if (!dom && iommu_def_domain_type != IOMMU_DOMAIN_DMA) { |
| 1108 | dev_warn(dev, | ||
| 1109 | "failed to allocate default IOMMU domain of type %u; falling back to IOMMU_DOMAIN_DMA", | ||
| 1110 | iommu_def_domain_type); | ||
| 1111 | dom = __iommu_domain_alloc(dev->bus, IOMMU_DOMAIN_DMA); | 1108 | dom = __iommu_domain_alloc(dev->bus, IOMMU_DOMAIN_DMA); |
| 1109 | if (dom) { | ||
| 1110 | dev_warn(dev, | ||
| 1111 | "failed to allocate default IOMMU domain of type %u; falling back to IOMMU_DOMAIN_DMA", | ||
| 1112 | iommu_def_domain_type); | ||
| 1113 | } | ||
| 1112 | } | 1114 | } |
| 1113 | 1115 | ||
| 1114 | group->default_domain = dom; | 1116 | group->default_domain = dom; |
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c index 4d85645c87f7..0928fd1f0e0c 100644 --- a/drivers/isdn/hardware/mISDN/hfcmulti.c +++ b/drivers/isdn/hardware/mISDN/hfcmulti.c | |||
| @@ -4365,7 +4365,8 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev, | |||
| 4365 | if (m->clock2) | 4365 | if (m->clock2) |
| 4366 | test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip); | 4366 | test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip); |
| 4367 | 4367 | ||
| 4368 | if (ent->device == 0xB410) { | 4368 | if (ent->vendor == PCI_VENDOR_ID_DIGIUM && |
| 4369 | ent->device == PCI_DEVICE_ID_DIGIUM_HFC4S) { | ||
| 4369 | test_and_set_bit(HFC_CHIP_B410P, &hc->chip); | 4370 | test_and_set_bit(HFC_CHIP_B410P, &hc->chip); |
| 4370 | test_and_set_bit(HFC_CHIP_PCM_MASTER, &hc->chip); | 4371 | test_and_set_bit(HFC_CHIP_PCM_MASTER, &hc->chip); |
| 4371 | test_and_clear_bit(HFC_CHIP_PCM_SLAVE, &hc->chip); | 4372 | test_and_clear_bit(HFC_CHIP_PCM_SLAVE, &hc->chip); |
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c index 7fea18b0c15d..7cb4d685a1f1 100644 --- a/drivers/leds/leds-pca9532.c +++ b/drivers/leds/leds-pca9532.c | |||
| @@ -513,6 +513,7 @@ static int pca9532_probe(struct i2c_client *client, | |||
| 513 | const struct i2c_device_id *id) | 513 | const struct i2c_device_id *id) |
| 514 | { | 514 | { |
| 515 | int devid; | 515 | int devid; |
| 516 | const struct of_device_id *of_id; | ||
| 516 | struct pca9532_data *data = i2c_get_clientdata(client); | 517 | struct pca9532_data *data = i2c_get_clientdata(client); |
| 517 | struct pca9532_platform_data *pca9532_pdata = | 518 | struct pca9532_platform_data *pca9532_pdata = |
| 518 | dev_get_platdata(&client->dev); | 519 | dev_get_platdata(&client->dev); |
| @@ -528,8 +529,11 @@ static int pca9532_probe(struct i2c_client *client, | |||
| 528 | dev_err(&client->dev, "no platform data\n"); | 529 | dev_err(&client->dev, "no platform data\n"); |
| 529 | return -EINVAL; | 530 | return -EINVAL; |
| 530 | } | 531 | } |
| 531 | devid = (int)(uintptr_t)of_match_device( | 532 | of_id = of_match_device(of_pca9532_leds_match, |
| 532 | of_pca9532_leds_match, &client->dev)->data; | 533 | &client->dev); |
| 534 | if (unlikely(!of_id)) | ||
| 535 | return -EINVAL; | ||
| 536 | devid = (int)(uintptr_t) of_id->data; | ||
| 533 | } else { | 537 | } else { |
| 534 | devid = id->driver_data; | 538 | devid = id->driver_data; |
| 535 | } | 539 | } |
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index 3dd3ed46d473..136f86a1627d 100644 --- a/drivers/leds/trigger/ledtrig-netdev.c +++ b/drivers/leds/trigger/ledtrig-netdev.c | |||
| @@ -122,7 +122,8 @@ static ssize_t device_name_store(struct device *dev, | |||
| 122 | trigger_data->net_dev = NULL; | 122 | trigger_data->net_dev = NULL; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | strncpy(trigger_data->device_name, buf, size); | 125 | memcpy(trigger_data->device_name, buf, size); |
| 126 | trigger_data->device_name[size] = 0; | ||
| 126 | if (size > 0 && trigger_data->device_name[size - 1] == '\n') | 127 | if (size > 0 && trigger_data->device_name[size - 1] == '\n') |
| 127 | trigger_data->device_name[size - 1] = 0; | 128 | trigger_data->device_name[size - 1] = 0; |
| 128 | 129 | ||
| @@ -301,11 +302,11 @@ static int netdev_trig_notify(struct notifier_block *nb, | |||
| 301 | container_of(nb, struct led_netdev_data, notifier); | 302 | container_of(nb, struct led_netdev_data, notifier); |
| 302 | 303 | ||
| 303 | if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE | 304 | if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE |
| 304 | && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER | 305 | && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER) |
| 305 | && evt != NETDEV_CHANGENAME) | ||
| 306 | return NOTIFY_DONE; | 306 | return NOTIFY_DONE; |
| 307 | 307 | ||
| 308 | if (strcmp(dev->name, trigger_data->device_name)) | 308 | if (!(dev == trigger_data->net_dev || |
| 309 | (evt == NETDEV_REGISTER && !strcmp(dev->name, trigger_data->device_name)))) | ||
| 309 | return NOTIFY_DONE; | 310 | return NOTIFY_DONE; |
| 310 | 311 | ||
| 311 | cancel_delayed_work_sync(&trigger_data->work); | 312 | cancel_delayed_work_sync(&trigger_data->work); |
| @@ -320,12 +321,9 @@ static int netdev_trig_notify(struct notifier_block *nb, | |||
| 320 | dev_hold(dev); | 321 | dev_hold(dev); |
| 321 | trigger_data->net_dev = dev; | 322 | trigger_data->net_dev = dev; |
| 322 | break; | 323 | break; |
| 323 | case NETDEV_CHANGENAME: | ||
| 324 | case NETDEV_UNREGISTER: | 324 | case NETDEV_UNREGISTER: |
| 325 | if (trigger_data->net_dev) { | 325 | dev_put(trigger_data->net_dev); |
| 326 | dev_put(trigger_data->net_dev); | 326 | trigger_data->net_dev = NULL; |
| 327 | trigger_data->net_dev = NULL; | ||
| 328 | } | ||
| 329 | break; | 327 | break; |
| 330 | case NETDEV_UP: | 328 | case NETDEV_UP: |
| 331 | case NETDEV_CHANGE: | 329 | case NETDEV_CHANGE: |
diff --git a/drivers/misc/habanalabs/command_submission.c b/drivers/misc/habanalabs/command_submission.c index 3525236ed8d9..19c84214a7ea 100644 --- a/drivers/misc/habanalabs/command_submission.c +++ b/drivers/misc/habanalabs/command_submission.c | |||
| @@ -179,6 +179,12 @@ static void cs_do_release(struct kref *ref) | |||
| 179 | 179 | ||
| 180 | /* We also need to update CI for internal queues */ | 180 | /* We also need to update CI for internal queues */ |
| 181 | if (cs->submitted) { | 181 | if (cs->submitted) { |
| 182 | int cs_cnt = atomic_dec_return(&hdev->cs_active_cnt); | ||
| 183 | |||
| 184 | WARN_ONCE((cs_cnt < 0), | ||
| 185 | "hl%d: error in CS active cnt %d\n", | ||
| 186 | hdev->id, cs_cnt); | ||
| 187 | |||
| 182 | hl_int_hw_queue_update_ci(cs); | 188 | hl_int_hw_queue_update_ci(cs); |
| 183 | 189 | ||
| 184 | spin_lock(&hdev->hw_queues_mirror_lock); | 190 | spin_lock(&hdev->hw_queues_mirror_lock); |
diff --git a/drivers/misc/habanalabs/debugfs.c b/drivers/misc/habanalabs/debugfs.c index a53c12aff6ad..974a87789bd8 100644 --- a/drivers/misc/habanalabs/debugfs.c +++ b/drivers/misc/habanalabs/debugfs.c | |||
| @@ -232,6 +232,7 @@ static int vm_show(struct seq_file *s, void *data) | |||
| 232 | struct hl_vm_phys_pg_pack *phys_pg_pack = NULL; | 232 | struct hl_vm_phys_pg_pack *phys_pg_pack = NULL; |
| 233 | enum vm_type_t *vm_type; | 233 | enum vm_type_t *vm_type; |
| 234 | bool once = true; | 234 | bool once = true; |
| 235 | u64 j; | ||
| 235 | int i; | 236 | int i; |
| 236 | 237 | ||
| 237 | if (!dev_entry->hdev->mmu_enable) | 238 | if (!dev_entry->hdev->mmu_enable) |
| @@ -260,7 +261,7 @@ static int vm_show(struct seq_file *s, void *data) | |||
| 260 | } else { | 261 | } else { |
| 261 | phys_pg_pack = hnode->ptr; | 262 | phys_pg_pack = hnode->ptr; |
| 262 | seq_printf(s, | 263 | seq_printf(s, |
| 263 | " 0x%-14llx %-10u %-4u\n", | 264 | " 0x%-14llx %-10llu %-4u\n", |
| 264 | hnode->vaddr, phys_pg_pack->total_size, | 265 | hnode->vaddr, phys_pg_pack->total_size, |
| 265 | phys_pg_pack->handle); | 266 | phys_pg_pack->handle); |
| 266 | } | 267 | } |
| @@ -282,9 +283,9 @@ static int vm_show(struct seq_file *s, void *data) | |||
| 282 | phys_pg_pack->page_size); | 283 | phys_pg_pack->page_size); |
| 283 | seq_puts(s, " physical address\n"); | 284 | seq_puts(s, " physical address\n"); |
| 284 | seq_puts(s, "---------------------\n"); | 285 | seq_puts(s, "---------------------\n"); |
| 285 | for (i = 0 ; i < phys_pg_pack->npages ; i++) { | 286 | for (j = 0 ; j < phys_pg_pack->npages ; j++) { |
| 286 | seq_printf(s, " 0x%-14llx\n", | 287 | seq_printf(s, " 0x%-14llx\n", |
| 287 | phys_pg_pack->pages[i]); | 288 | phys_pg_pack->pages[j]); |
| 288 | } | 289 | } |
| 289 | } | 290 | } |
| 290 | spin_unlock(&vm->idr_lock); | 291 | spin_unlock(&vm->idr_lock); |
diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c index de46aa6ed154..77d51be66c7e 100644 --- a/drivers/misc/habanalabs/device.c +++ b/drivers/misc/habanalabs/device.c | |||
| @@ -11,6 +11,8 @@ | |||
| 11 | #include <linux/sched/signal.h> | 11 | #include <linux/sched/signal.h> |
| 12 | #include <linux/hwmon.h> | 12 | #include <linux/hwmon.h> |
| 13 | 13 | ||
| 14 | #define HL_PLDM_PENDING_RESET_PER_SEC (HL_PENDING_RESET_PER_SEC * 10) | ||
| 15 | |||
| 14 | bool hl_device_disabled_or_in_reset(struct hl_device *hdev) | 16 | bool hl_device_disabled_or_in_reset(struct hl_device *hdev) |
| 15 | { | 17 | { |
| 16 | if ((hdev->disabled) || (atomic_read(&hdev->in_reset))) | 18 | if ((hdev->disabled) || (atomic_read(&hdev->in_reset))) |
| @@ -216,6 +218,7 @@ static int device_early_init(struct hl_device *hdev) | |||
| 216 | spin_lock_init(&hdev->hw_queues_mirror_lock); | 218 | spin_lock_init(&hdev->hw_queues_mirror_lock); |
| 217 | atomic_set(&hdev->in_reset, 0); | 219 | atomic_set(&hdev->in_reset, 0); |
| 218 | atomic_set(&hdev->fd_open_cnt, 0); | 220 | atomic_set(&hdev->fd_open_cnt, 0); |
| 221 | atomic_set(&hdev->cs_active_cnt, 0); | ||
| 219 | 222 | ||
| 220 | return 0; | 223 | return 0; |
| 221 | 224 | ||
| @@ -413,6 +416,27 @@ int hl_device_suspend(struct hl_device *hdev) | |||
| 413 | 416 | ||
| 414 | pci_save_state(hdev->pdev); | 417 | pci_save_state(hdev->pdev); |
| 415 | 418 | ||
| 419 | /* Block future CS/VM/JOB completion operations */ | ||
| 420 | rc = atomic_cmpxchg(&hdev->in_reset, 0, 1); | ||
| 421 | if (rc) { | ||
| 422 | dev_err(hdev->dev, "Can't suspend while in reset\n"); | ||
| 423 | return -EIO; | ||
| 424 | } | ||
| 425 | |||
| 426 | /* This blocks all other stuff that is not blocked by in_reset */ | ||
| 427 | hdev->disabled = true; | ||
| 428 | |||
| 429 | /* | ||
| 430 | * Flush anyone that is inside the critical section of enqueue | ||
| 431 | * jobs to the H/W | ||
| 432 | */ | ||
| 433 | hdev->asic_funcs->hw_queues_lock(hdev); | ||
| 434 | hdev->asic_funcs->hw_queues_unlock(hdev); | ||
| 435 | |||
| 436 | /* Flush processes that are sending message to CPU */ | ||
| 437 | mutex_lock(&hdev->send_cpu_message_lock); | ||
| 438 | mutex_unlock(&hdev->send_cpu_message_lock); | ||
| 439 | |||
| 416 | rc = hdev->asic_funcs->suspend(hdev); | 440 | rc = hdev->asic_funcs->suspend(hdev); |
| 417 | if (rc) | 441 | if (rc) |
| 418 | dev_err(hdev->dev, | 442 | dev_err(hdev->dev, |
| @@ -440,21 +464,38 @@ int hl_device_resume(struct hl_device *hdev) | |||
| 440 | 464 | ||
| 441 | pci_set_power_state(hdev->pdev, PCI_D0); | 465 | pci_set_power_state(hdev->pdev, PCI_D0); |
| 442 | pci_restore_state(hdev->pdev); | 466 | pci_restore_state(hdev->pdev); |
| 443 | rc = pci_enable_device(hdev->pdev); | 467 | rc = pci_enable_device_mem(hdev->pdev); |
| 444 | if (rc) { | 468 | if (rc) { |
| 445 | dev_err(hdev->dev, | 469 | dev_err(hdev->dev, |
| 446 | "Failed to enable PCI device in resume\n"); | 470 | "Failed to enable PCI device in resume\n"); |
| 447 | return rc; | 471 | return rc; |
| 448 | } | 472 | } |
| 449 | 473 | ||
| 474 | pci_set_master(hdev->pdev); | ||
| 475 | |||
| 450 | rc = hdev->asic_funcs->resume(hdev); | 476 | rc = hdev->asic_funcs->resume(hdev); |
| 451 | if (rc) { | 477 | if (rc) { |
| 452 | dev_err(hdev->dev, | 478 | dev_err(hdev->dev, "Failed to resume device after suspend\n"); |
| 453 | "Failed to enable PCI access from device CPU\n"); | 479 | goto disable_device; |
| 454 | return rc; | 480 | } |
| 481 | |||
| 482 | |||
| 483 | hdev->disabled = false; | ||
| 484 | atomic_set(&hdev->in_reset, 0); | ||
| 485 | |||
| 486 | rc = hl_device_reset(hdev, true, false); | ||
| 487 | if (rc) { | ||
| 488 | dev_err(hdev->dev, "Failed to reset device during resume\n"); | ||
| 489 | goto disable_device; | ||
| 455 | } | 490 | } |
| 456 | 491 | ||
| 457 | return 0; | 492 | return 0; |
| 493 | |||
| 494 | disable_device: | ||
| 495 | pci_clear_master(hdev->pdev); | ||
| 496 | pci_disable_device(hdev->pdev); | ||
| 497 | |||
| 498 | return rc; | ||
| 458 | } | 499 | } |
| 459 | 500 | ||
| 460 | static void hl_device_hard_reset_pending(struct work_struct *work) | 501 | static void hl_device_hard_reset_pending(struct work_struct *work) |
| @@ -462,9 +503,16 @@ static void hl_device_hard_reset_pending(struct work_struct *work) | |||
| 462 | struct hl_device_reset_work *device_reset_work = | 503 | struct hl_device_reset_work *device_reset_work = |
| 463 | container_of(work, struct hl_device_reset_work, reset_work); | 504 | container_of(work, struct hl_device_reset_work, reset_work); |
| 464 | struct hl_device *hdev = device_reset_work->hdev; | 505 | struct hl_device *hdev = device_reset_work->hdev; |
| 465 | u16 pending_cnt = HL_PENDING_RESET_PER_SEC; | 506 | u16 pending_total, pending_cnt; |
| 466 | struct task_struct *task = NULL; | 507 | struct task_struct *task = NULL; |
| 467 | 508 | ||
| 509 | if (hdev->pldm) | ||
| 510 | pending_total = HL_PLDM_PENDING_RESET_PER_SEC; | ||
| 511 | else | ||
| 512 | pending_total = HL_PENDING_RESET_PER_SEC; | ||
| 513 | |||
| 514 | pending_cnt = pending_total; | ||
| 515 | |||
| 468 | /* Flush all processes that are inside hl_open */ | 516 | /* Flush all processes that are inside hl_open */ |
| 469 | mutex_lock(&hdev->fd_open_cnt_lock); | 517 | mutex_lock(&hdev->fd_open_cnt_lock); |
| 470 | 518 | ||
| @@ -489,6 +537,19 @@ static void hl_device_hard_reset_pending(struct work_struct *work) | |||
| 489 | } | 537 | } |
| 490 | } | 538 | } |
| 491 | 539 | ||
| 540 | pending_cnt = pending_total; | ||
| 541 | |||
| 542 | while ((atomic_read(&hdev->fd_open_cnt)) && (pending_cnt)) { | ||
| 543 | |||
| 544 | pending_cnt--; | ||
| 545 | |||
| 546 | ssleep(1); | ||
| 547 | } | ||
| 548 | |||
| 549 | if (atomic_read(&hdev->fd_open_cnt)) | ||
| 550 | dev_crit(hdev->dev, | ||
| 551 | "Going to hard reset with open user contexts\n"); | ||
| 552 | |||
| 492 | mutex_unlock(&hdev->fd_open_cnt_lock); | 553 | mutex_unlock(&hdev->fd_open_cnt_lock); |
| 493 | 554 | ||
| 494 | hl_device_reset(hdev, true, true); | 555 | hl_device_reset(hdev, true, true); |
diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index 238dd57c541b..ea979ebd62fb 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c | |||
| @@ -1201,15 +1201,6 @@ static int goya_stop_external_queues(struct hl_device *hdev) | |||
| 1201 | return retval; | 1201 | return retval; |
| 1202 | } | 1202 | } |
| 1203 | 1203 | ||
| 1204 | static void goya_resume_external_queues(struct hl_device *hdev) | ||
| 1205 | { | ||
| 1206 | WREG32(mmDMA_QM_0_GLBL_CFG1, 0); | ||
| 1207 | WREG32(mmDMA_QM_1_GLBL_CFG1, 0); | ||
| 1208 | WREG32(mmDMA_QM_2_GLBL_CFG1, 0); | ||
| 1209 | WREG32(mmDMA_QM_3_GLBL_CFG1, 0); | ||
| 1210 | WREG32(mmDMA_QM_4_GLBL_CFG1, 0); | ||
| 1211 | } | ||
| 1212 | |||
| 1213 | /* | 1204 | /* |
| 1214 | * goya_init_cpu_queues - Initialize PQ/CQ/EQ of CPU | 1205 | * goya_init_cpu_queues - Initialize PQ/CQ/EQ of CPU |
| 1215 | * | 1206 | * |
| @@ -2178,36 +2169,6 @@ static int goya_stop_internal_queues(struct hl_device *hdev) | |||
| 2178 | return retval; | 2169 | return retval; |
| 2179 | } | 2170 | } |
| 2180 | 2171 | ||
| 2181 | static void goya_resume_internal_queues(struct hl_device *hdev) | ||
| 2182 | { | ||
| 2183 | WREG32(mmMME_QM_GLBL_CFG1, 0); | ||
| 2184 | WREG32(mmMME_CMDQ_GLBL_CFG1, 0); | ||
| 2185 | |||
| 2186 | WREG32(mmTPC0_QM_GLBL_CFG1, 0); | ||
| 2187 | WREG32(mmTPC0_CMDQ_GLBL_CFG1, 0); | ||
| 2188 | |||
| 2189 | WREG32(mmTPC1_QM_GLBL_CFG1, 0); | ||
| 2190 | WREG32(mmTPC1_CMDQ_GLBL_CFG1, 0); | ||
| 2191 | |||
| 2192 | WREG32(mmTPC2_QM_GLBL_CFG1, 0); | ||
| 2193 | WREG32(mmTPC2_CMDQ_GLBL_CFG1, 0); | ||
| 2194 | |||
| 2195 | WREG32(mmTPC3_QM_GLBL_CFG1, 0); | ||
| 2196 | WREG32(mmTPC3_CMDQ_GLBL_CFG1, 0); | ||
| 2197 | |||
| 2198 | WREG32(mmTPC4_QM_GLBL_CFG1, 0); | ||
| 2199 | WREG32(mmTPC4_CMDQ_GLBL_CFG1, 0); | ||
| 2200 | |||
| 2201 | WREG32(mmTPC5_QM_GLBL_CFG1, 0); | ||
| 2202 | WREG32(mmTPC5_CMDQ_GLBL_CFG1, 0); | ||
| 2203 | |||
| 2204 | WREG32(mmTPC6_QM_GLBL_CFG1, 0); | ||
| 2205 | WREG32(mmTPC6_CMDQ_GLBL_CFG1, 0); | ||
| 2206 | |||
| 2207 | WREG32(mmTPC7_QM_GLBL_CFG1, 0); | ||
| 2208 | WREG32(mmTPC7_CMDQ_GLBL_CFG1, 0); | ||
| 2209 | } | ||
| 2210 | |||
| 2211 | static void goya_dma_stall(struct hl_device *hdev) | 2172 | static void goya_dma_stall(struct hl_device *hdev) |
| 2212 | { | 2173 | { |
| 2213 | WREG32(mmDMA_QM_0_GLBL_CFG1, 1 << DMA_QM_0_GLBL_CFG1_DMA_STOP_SHIFT); | 2174 | WREG32(mmDMA_QM_0_GLBL_CFG1, 1 << DMA_QM_0_GLBL_CFG1_DMA_STOP_SHIFT); |
| @@ -2905,20 +2866,6 @@ int goya_suspend(struct hl_device *hdev) | |||
| 2905 | { | 2866 | { |
| 2906 | int rc; | 2867 | int rc; |
| 2907 | 2868 | ||
| 2908 | rc = goya_stop_internal_queues(hdev); | ||
| 2909 | |||
| 2910 | if (rc) { | ||
| 2911 | dev_err(hdev->dev, "failed to stop internal queues\n"); | ||
| 2912 | return rc; | ||
| 2913 | } | ||
| 2914 | |||
| 2915 | rc = goya_stop_external_queues(hdev); | ||
| 2916 | |||
| 2917 | if (rc) { | ||
| 2918 | dev_err(hdev->dev, "failed to stop external queues\n"); | ||
| 2919 | return rc; | ||
| 2920 | } | ||
| 2921 | |||
| 2922 | rc = goya_send_pci_access_msg(hdev, ARMCP_PACKET_DISABLE_PCI_ACCESS); | 2869 | rc = goya_send_pci_access_msg(hdev, ARMCP_PACKET_DISABLE_PCI_ACCESS); |
| 2923 | if (rc) | 2870 | if (rc) |
| 2924 | dev_err(hdev->dev, "Failed to disable PCI access from CPU\n"); | 2871 | dev_err(hdev->dev, "Failed to disable PCI access from CPU\n"); |
| @@ -2928,15 +2875,7 @@ int goya_suspend(struct hl_device *hdev) | |||
| 2928 | 2875 | ||
| 2929 | int goya_resume(struct hl_device *hdev) | 2876 | int goya_resume(struct hl_device *hdev) |
| 2930 | { | 2877 | { |
| 2931 | int rc; | 2878 | return goya_init_iatu(hdev); |
| 2932 | |||
| 2933 | goya_resume_external_queues(hdev); | ||
| 2934 | goya_resume_internal_queues(hdev); | ||
| 2935 | |||
| 2936 | rc = goya_send_pci_access_msg(hdev, ARMCP_PACKET_ENABLE_PCI_ACCESS); | ||
| 2937 | if (rc) | ||
| 2938 | dev_err(hdev->dev, "Failed to enable PCI access from CPU\n"); | ||
| 2939 | return rc; | ||
| 2940 | } | 2879 | } |
| 2941 | 2880 | ||
| 2942 | static int goya_cb_mmap(struct hl_device *hdev, struct vm_area_struct *vma, | 2881 | static int goya_cb_mmap(struct hl_device *hdev, struct vm_area_struct *vma, |
| @@ -3070,7 +3009,7 @@ void *goya_get_int_queue_base(struct hl_device *hdev, u32 queue_id, | |||
| 3070 | 3009 | ||
| 3071 | *dma_handle = hdev->asic_prop.sram_base_address; | 3010 | *dma_handle = hdev->asic_prop.sram_base_address; |
| 3072 | 3011 | ||
| 3073 | base = hdev->pcie_bar[SRAM_CFG_BAR_ID]; | 3012 | base = (void *) hdev->pcie_bar[SRAM_CFG_BAR_ID]; |
| 3074 | 3013 | ||
| 3075 | switch (queue_id) { | 3014 | switch (queue_id) { |
| 3076 | case GOYA_QUEUE_ID_MME: | 3015 | case GOYA_QUEUE_ID_MME: |
diff --git a/drivers/misc/habanalabs/habanalabs.h b/drivers/misc/habanalabs/habanalabs.h index a7c95e9f9b9a..a8ee52c880cd 100644 --- a/drivers/misc/habanalabs/habanalabs.h +++ b/drivers/misc/habanalabs/habanalabs.h | |||
| @@ -793,11 +793,11 @@ struct hl_vm_hash_node { | |||
| 793 | * struct hl_vm_phys_pg_pack - physical page pack. | 793 | * struct hl_vm_phys_pg_pack - physical page pack. |
| 794 | * @vm_type: describes the type of the virtual area descriptor. | 794 | * @vm_type: describes the type of the virtual area descriptor. |
| 795 | * @pages: the physical page array. | 795 | * @pages: the physical page array. |
| 796 | * @npages: num physical pages in the pack. | ||
| 797 | * @total_size: total size of all the pages in this list. | ||
| 796 | * @mapping_cnt: number of shared mappings. | 798 | * @mapping_cnt: number of shared mappings. |
| 797 | * @asid: the context related to this list. | 799 | * @asid: the context related to this list. |
| 798 | * @npages: num physical pages in the pack. | ||
| 799 | * @page_size: size of each page in the pack. | 800 | * @page_size: size of each page in the pack. |
| 800 | * @total_size: total size of all the pages in this list. | ||
| 801 | * @flags: HL_MEM_* flags related to this list. | 801 | * @flags: HL_MEM_* flags related to this list. |
| 802 | * @handle: the provided handle related to this list. | 802 | * @handle: the provided handle related to this list. |
| 803 | * @offset: offset from the first page. | 803 | * @offset: offset from the first page. |
| @@ -807,11 +807,11 @@ struct hl_vm_hash_node { | |||
| 807 | struct hl_vm_phys_pg_pack { | 807 | struct hl_vm_phys_pg_pack { |
| 808 | enum vm_type_t vm_type; /* must be first */ | 808 | enum vm_type_t vm_type; /* must be first */ |
| 809 | u64 *pages; | 809 | u64 *pages; |
| 810 | u64 npages; | ||
| 811 | u64 total_size; | ||
| 810 | atomic_t mapping_cnt; | 812 | atomic_t mapping_cnt; |
| 811 | u32 asid; | 813 | u32 asid; |
| 812 | u32 npages; | ||
| 813 | u32 page_size; | 814 | u32 page_size; |
| 814 | u32 total_size; | ||
| 815 | u32 flags; | 815 | u32 flags; |
| 816 | u32 handle; | 816 | u32 handle; |
| 817 | u32 offset; | 817 | u32 offset; |
| @@ -1056,13 +1056,15 @@ struct hl_device_reset_work { | |||
| 1056 | * @cb_pool_lock: protects the CB pool. | 1056 | * @cb_pool_lock: protects the CB pool. |
| 1057 | * @user_ctx: current user context executing. | 1057 | * @user_ctx: current user context executing. |
| 1058 | * @dram_used_mem: current DRAM memory consumption. | 1058 | * @dram_used_mem: current DRAM memory consumption. |
| 1059 | * @in_reset: is device in reset flow. | ||
| 1060 | * @curr_pll_profile: current PLL profile. | ||
| 1061 | * @fd_open_cnt: number of open user processes. | ||
| 1062 | * @timeout_jiffies: device CS timeout value. | 1059 | * @timeout_jiffies: device CS timeout value. |
| 1063 | * @max_power: the max power of the device, as configured by the sysadmin. This | 1060 | * @max_power: the max power of the device, as configured by the sysadmin. This |
| 1064 | * value is saved so in case of hard-reset, KMD will restore this | 1061 | * value is saved so in case of hard-reset, KMD will restore this |
| 1065 | * value and update the F/W after the re-initialization | 1062 | * value and update the F/W after the re-initialization |
| 1063 | * @in_reset: is device in reset flow. | ||
| 1064 | * @curr_pll_profile: current PLL profile. | ||
| 1065 | * @fd_open_cnt: number of open user processes. | ||
| 1066 | * @cs_active_cnt: number of active command submissions on this device (active | ||
| 1067 | * means already in H/W queues) | ||
| 1066 | * @major: habanalabs KMD major. | 1068 | * @major: habanalabs KMD major. |
| 1067 | * @high_pll: high PLL profile frequency. | 1069 | * @high_pll: high PLL profile frequency. |
| 1068 | * @soft_reset_cnt: number of soft reset since KMD loading. | 1070 | * @soft_reset_cnt: number of soft reset since KMD loading. |
| @@ -1128,11 +1130,12 @@ struct hl_device { | |||
| 1128 | struct hl_ctx *user_ctx; | 1130 | struct hl_ctx *user_ctx; |
| 1129 | 1131 | ||
| 1130 | atomic64_t dram_used_mem; | 1132 | atomic64_t dram_used_mem; |
| 1133 | u64 timeout_jiffies; | ||
| 1134 | u64 max_power; | ||
| 1131 | atomic_t in_reset; | 1135 | atomic_t in_reset; |
| 1132 | atomic_t curr_pll_profile; | 1136 | atomic_t curr_pll_profile; |
| 1133 | atomic_t fd_open_cnt; | 1137 | atomic_t fd_open_cnt; |
| 1134 | u64 timeout_jiffies; | 1138 | atomic_t cs_active_cnt; |
| 1135 | u64 max_power; | ||
| 1136 | u32 major; | 1139 | u32 major; |
| 1137 | u32 high_pll; | 1140 | u32 high_pll; |
| 1138 | u32 soft_reset_cnt; | 1141 | u32 soft_reset_cnt; |
diff --git a/drivers/misc/habanalabs/hw_queue.c b/drivers/misc/habanalabs/hw_queue.c index 67bece26417c..ef3bb6951360 100644 --- a/drivers/misc/habanalabs/hw_queue.c +++ b/drivers/misc/habanalabs/hw_queue.c | |||
| @@ -370,12 +370,13 @@ int hl_hw_queue_schedule_cs(struct hl_cs *cs) | |||
| 370 | spin_unlock(&hdev->hw_queues_mirror_lock); | 370 | spin_unlock(&hdev->hw_queues_mirror_lock); |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | list_for_each_entry_safe(job, tmp, &cs->job_list, cs_node) { | 373 | atomic_inc(&hdev->cs_active_cnt); |
| 374 | |||
| 375 | list_for_each_entry_safe(job, tmp, &cs->job_list, cs_node) | ||
| 374 | if (job->ext_queue) | 376 | if (job->ext_queue) |
| 375 | ext_hw_queue_schedule_job(job); | 377 | ext_hw_queue_schedule_job(job); |
| 376 | else | 378 | else |
| 377 | int_hw_queue_schedule_job(job); | 379 | int_hw_queue_schedule_job(job); |
| 378 | } | ||
| 379 | 380 | ||
| 380 | cs->submitted = true; | 381 | cs->submitted = true; |
| 381 | 382 | ||
diff --git a/drivers/misc/habanalabs/memory.c b/drivers/misc/habanalabs/memory.c index 3a12fd1a5274..ce1fda40a8b8 100644 --- a/drivers/misc/habanalabs/memory.c +++ b/drivers/misc/habanalabs/memory.c | |||
| @@ -56,9 +56,9 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args, | |||
| 56 | struct hl_device *hdev = ctx->hdev; | 56 | struct hl_device *hdev = ctx->hdev; |
| 57 | struct hl_vm *vm = &hdev->vm; | 57 | struct hl_vm *vm = &hdev->vm; |
| 58 | struct hl_vm_phys_pg_pack *phys_pg_pack; | 58 | struct hl_vm_phys_pg_pack *phys_pg_pack; |
| 59 | u64 paddr = 0; | 59 | u64 paddr = 0, total_size, num_pgs, i; |
| 60 | u32 total_size, num_pgs, num_curr_pgs, page_size, page_shift; | 60 | u32 num_curr_pgs, page_size, page_shift; |
| 61 | int handle, rc, i; | 61 | int handle, rc; |
| 62 | bool contiguous; | 62 | bool contiguous; |
| 63 | 63 | ||
| 64 | num_curr_pgs = 0; | 64 | num_curr_pgs = 0; |
| @@ -73,7 +73,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args, | |||
| 73 | paddr = (u64) gen_pool_alloc(vm->dram_pg_pool, total_size); | 73 | paddr = (u64) gen_pool_alloc(vm->dram_pg_pool, total_size); |
| 74 | if (!paddr) { | 74 | if (!paddr) { |
| 75 | dev_err(hdev->dev, | 75 | dev_err(hdev->dev, |
| 76 | "failed to allocate %u huge contiguous pages\n", | 76 | "failed to allocate %llu huge contiguous pages\n", |
| 77 | num_pgs); | 77 | num_pgs); |
| 78 | return -ENOMEM; | 78 | return -ENOMEM; |
| 79 | } | 79 | } |
| @@ -93,7 +93,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args, | |||
| 93 | phys_pg_pack->flags = args->flags; | 93 | phys_pg_pack->flags = args->flags; |
| 94 | phys_pg_pack->contiguous = contiguous; | 94 | phys_pg_pack->contiguous = contiguous; |
| 95 | 95 | ||
| 96 | phys_pg_pack->pages = kcalloc(num_pgs, sizeof(u64), GFP_KERNEL); | 96 | phys_pg_pack->pages = kvmalloc_array(num_pgs, sizeof(u64), GFP_KERNEL); |
| 97 | if (!phys_pg_pack->pages) { | 97 | if (!phys_pg_pack->pages) { |
| 98 | rc = -ENOMEM; | 98 | rc = -ENOMEM; |
| 99 | goto pages_arr_err; | 99 | goto pages_arr_err; |
| @@ -148,7 +148,7 @@ page_err: | |||
| 148 | gen_pool_free(vm->dram_pg_pool, phys_pg_pack->pages[i], | 148 | gen_pool_free(vm->dram_pg_pool, phys_pg_pack->pages[i], |
| 149 | page_size); | 149 | page_size); |
| 150 | 150 | ||
| 151 | kfree(phys_pg_pack->pages); | 151 | kvfree(phys_pg_pack->pages); |
| 152 | pages_arr_err: | 152 | pages_arr_err: |
| 153 | kfree(phys_pg_pack); | 153 | kfree(phys_pg_pack); |
| 154 | pages_pack_err: | 154 | pages_pack_err: |
| @@ -267,7 +267,7 @@ static void free_phys_pg_pack(struct hl_device *hdev, | |||
| 267 | struct hl_vm_phys_pg_pack *phys_pg_pack) | 267 | struct hl_vm_phys_pg_pack *phys_pg_pack) |
| 268 | { | 268 | { |
| 269 | struct hl_vm *vm = &hdev->vm; | 269 | struct hl_vm *vm = &hdev->vm; |
| 270 | int i; | 270 | u64 i; |
| 271 | 271 | ||
| 272 | if (!phys_pg_pack->created_from_userptr) { | 272 | if (!phys_pg_pack->created_from_userptr) { |
| 273 | if (phys_pg_pack->contiguous) { | 273 | if (phys_pg_pack->contiguous) { |
| @@ -288,7 +288,7 @@ static void free_phys_pg_pack(struct hl_device *hdev, | |||
| 288 | } | 288 | } |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | kfree(phys_pg_pack->pages); | 291 | kvfree(phys_pg_pack->pages); |
| 292 | kfree(phys_pg_pack); | 292 | kfree(phys_pg_pack); |
| 293 | } | 293 | } |
| 294 | 294 | ||
| @@ -519,7 +519,7 @@ static inline int add_va_block(struct hl_device *hdev, | |||
| 519 | * - Return the start address of the virtual block | 519 | * - Return the start address of the virtual block |
| 520 | */ | 520 | */ |
| 521 | static u64 get_va_block(struct hl_device *hdev, | 521 | static u64 get_va_block(struct hl_device *hdev, |
| 522 | struct hl_va_range *va_range, u32 size, u64 hint_addr, | 522 | struct hl_va_range *va_range, u64 size, u64 hint_addr, |
| 523 | bool is_userptr) | 523 | bool is_userptr) |
| 524 | { | 524 | { |
| 525 | struct hl_vm_va_block *va_block, *new_va_block = NULL; | 525 | struct hl_vm_va_block *va_block, *new_va_block = NULL; |
| @@ -577,7 +577,8 @@ static u64 get_va_block(struct hl_device *hdev, | |||
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | if (!new_va_block) { | 579 | if (!new_va_block) { |
| 580 | dev_err(hdev->dev, "no available va block for size %u\n", size); | 580 | dev_err(hdev->dev, "no available va block for size %llu\n", |
| 581 | size); | ||
| 581 | goto out; | 582 | goto out; |
| 582 | } | 583 | } |
| 583 | 584 | ||
| @@ -648,8 +649,8 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx, | |||
| 648 | struct hl_vm_phys_pg_pack *phys_pg_pack; | 649 | struct hl_vm_phys_pg_pack *phys_pg_pack; |
| 649 | struct scatterlist *sg; | 650 | struct scatterlist *sg; |
| 650 | dma_addr_t dma_addr; | 651 | dma_addr_t dma_addr; |
| 651 | u64 page_mask; | 652 | u64 page_mask, total_npages; |
| 652 | u32 npages, total_npages, page_size = PAGE_SIZE; | 653 | u32 npages, page_size = PAGE_SIZE; |
| 653 | bool first = true, is_huge_page_opt = true; | 654 | bool first = true, is_huge_page_opt = true; |
| 654 | int rc, i, j; | 655 | int rc, i, j; |
| 655 | 656 | ||
| @@ -691,7 +692,8 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx, | |||
| 691 | 692 | ||
| 692 | page_mask = ~(((u64) page_size) - 1); | 693 | page_mask = ~(((u64) page_size) - 1); |
| 693 | 694 | ||
| 694 | phys_pg_pack->pages = kcalloc(total_npages, sizeof(u64), GFP_KERNEL); | 695 | phys_pg_pack->pages = kvmalloc_array(total_npages, sizeof(u64), |
| 696 | GFP_KERNEL); | ||
| 695 | if (!phys_pg_pack->pages) { | 697 | if (!phys_pg_pack->pages) { |
| 696 | rc = -ENOMEM; | 698 | rc = -ENOMEM; |
| 697 | goto page_pack_arr_mem_err; | 699 | goto page_pack_arr_mem_err; |
| @@ -750,9 +752,9 @@ static int map_phys_page_pack(struct hl_ctx *ctx, u64 vaddr, | |||
| 750 | struct hl_vm_phys_pg_pack *phys_pg_pack) | 752 | struct hl_vm_phys_pg_pack *phys_pg_pack) |
| 751 | { | 753 | { |
| 752 | struct hl_device *hdev = ctx->hdev; | 754 | struct hl_device *hdev = ctx->hdev; |
| 753 | u64 next_vaddr = vaddr, paddr; | 755 | u64 next_vaddr = vaddr, paddr, mapped_pg_cnt = 0, i; |
| 754 | u32 page_size = phys_pg_pack->page_size; | 756 | u32 page_size = phys_pg_pack->page_size; |
| 755 | int i, rc = 0, mapped_pg_cnt = 0; | 757 | int rc = 0; |
| 756 | 758 | ||
| 757 | for (i = 0 ; i < phys_pg_pack->npages ; i++) { | 759 | for (i = 0 ; i < phys_pg_pack->npages ; i++) { |
| 758 | paddr = phys_pg_pack->pages[i]; | 760 | paddr = phys_pg_pack->pages[i]; |
| @@ -764,7 +766,7 @@ static int map_phys_page_pack(struct hl_ctx *ctx, u64 vaddr, | |||
| 764 | rc = hl_mmu_map(ctx, next_vaddr, paddr, page_size); | 766 | rc = hl_mmu_map(ctx, next_vaddr, paddr, page_size); |
| 765 | if (rc) { | 767 | if (rc) { |
| 766 | dev_err(hdev->dev, | 768 | dev_err(hdev->dev, |
| 767 | "map failed for handle %u, npages: %d, mapped: %d", | 769 | "map failed for handle %u, npages: %llu, mapped: %llu", |
| 768 | phys_pg_pack->handle, phys_pg_pack->npages, | 770 | phys_pg_pack->handle, phys_pg_pack->npages, |
| 769 | mapped_pg_cnt); | 771 | mapped_pg_cnt); |
| 770 | goto err; | 772 | goto err; |
| @@ -985,10 +987,10 @@ static int unmap_device_va(struct hl_ctx *ctx, u64 vaddr) | |||
| 985 | struct hl_vm_hash_node *hnode = NULL; | 987 | struct hl_vm_hash_node *hnode = NULL; |
| 986 | struct hl_userptr *userptr = NULL; | 988 | struct hl_userptr *userptr = NULL; |
| 987 | enum vm_type_t *vm_type; | 989 | enum vm_type_t *vm_type; |
| 988 | u64 next_vaddr; | 990 | u64 next_vaddr, i; |
| 989 | u32 page_size; | 991 | u32 page_size; |
| 990 | bool is_userptr; | 992 | bool is_userptr; |
| 991 | int i, rc; | 993 | int rc; |
| 992 | 994 | ||
| 993 | /* protect from double entrance */ | 995 | /* protect from double entrance */ |
| 994 | mutex_lock(&ctx->mem_hash_lock); | 996 | mutex_lock(&ctx->mem_hash_lock); |
diff --git a/drivers/misc/habanalabs/mmu.c b/drivers/misc/habanalabs/mmu.c index 2f2e99cb2743..3a5a2cec8305 100644 --- a/drivers/misc/habanalabs/mmu.c +++ b/drivers/misc/habanalabs/mmu.c | |||
| @@ -832,7 +832,7 @@ err: | |||
| 832 | int hl_mmu_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr, u32 page_size) | 832 | int hl_mmu_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr, u32 page_size) |
| 833 | { | 833 | { |
| 834 | struct hl_device *hdev = ctx->hdev; | 834 | struct hl_device *hdev = ctx->hdev; |
| 835 | u64 real_virt_addr; | 835 | u64 real_virt_addr, real_phys_addr; |
| 836 | u32 real_page_size, npages; | 836 | u32 real_page_size, npages; |
| 837 | int i, rc, mapped_cnt = 0; | 837 | int i, rc, mapped_cnt = 0; |
| 838 | 838 | ||
| @@ -857,14 +857,16 @@ int hl_mmu_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr, u32 page_size) | |||
| 857 | 857 | ||
| 858 | npages = page_size / real_page_size; | 858 | npages = page_size / real_page_size; |
| 859 | real_virt_addr = virt_addr; | 859 | real_virt_addr = virt_addr; |
| 860 | real_phys_addr = phys_addr; | ||
| 860 | 861 | ||
| 861 | for (i = 0 ; i < npages ; i++) { | 862 | for (i = 0 ; i < npages ; i++) { |
| 862 | rc = _hl_mmu_map(ctx, real_virt_addr, phys_addr, | 863 | rc = _hl_mmu_map(ctx, real_virt_addr, real_phys_addr, |
| 863 | real_page_size); | 864 | real_page_size); |
| 864 | if (rc) | 865 | if (rc) |
| 865 | goto err; | 866 | goto err; |
| 866 | 867 | ||
| 867 | real_virt_addr += real_page_size; | 868 | real_virt_addr += real_page_size; |
| 869 | real_phys_addr += real_page_size; | ||
| 868 | mapped_cnt++; | 870 | mapped_cnt++; |
| 869 | } | 871 | } |
| 870 | 872 | ||
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 5e4ca082cfcd..7a96d168efc4 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
| @@ -216,8 +216,8 @@ config GENEVE | |||
| 216 | 216 | ||
| 217 | config GTP | 217 | config GTP |
| 218 | tristate "GPRS Tunneling Protocol datapath (GTP-U)" | 218 | tristate "GPRS Tunneling Protocol datapath (GTP-U)" |
| 219 | depends on INET && NET_UDP_TUNNEL | 219 | depends on INET |
| 220 | select NET_IP_TUNNEL | 220 | select NET_UDP_TUNNEL |
| 221 | ---help--- | 221 | ---help--- |
| 222 | This allows one to create gtp virtual interfaces that provide | 222 | This allows one to create gtp virtual interfaces that provide |
| 223 | the GPRS Tunneling Protocol datapath (GTP-U). This tunneling protocol | 223 | the GPRS Tunneling Protocol datapath (GTP-U). This tunneling protocol |
diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 576b37d12a63..c4fa400efdcc 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c | |||
| @@ -481,6 +481,155 @@ qca8k_port_set_status(struct qca8k_priv *priv, int port, int enable) | |||
| 481 | qca8k_reg_clear(priv, QCA8K_REG_PORT_STATUS(port), mask); | 481 | qca8k_reg_clear(priv, QCA8K_REG_PORT_STATUS(port), mask); |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | static u32 | ||
| 485 | qca8k_port_to_phy(int port) | ||
| 486 | { | ||
| 487 | /* From Andrew Lunn: | ||
| 488 | * Port 0 has no internal phy. | ||
| 489 | * Port 1 has an internal PHY at MDIO address 0. | ||
| 490 | * Port 2 has an internal PHY at MDIO address 1. | ||
| 491 | * ... | ||
| 492 | * Port 5 has an internal PHY at MDIO address 4. | ||
| 493 | * Port 6 has no internal PHY. | ||
| 494 | */ | ||
| 495 | |||
| 496 | return port - 1; | ||
| 497 | } | ||
| 498 | |||
| 499 | static int | ||
| 500 | qca8k_mdio_write(struct qca8k_priv *priv, int port, u32 regnum, u16 data) | ||
| 501 | { | ||
| 502 | u32 phy, val; | ||
| 503 | |||
| 504 | if (regnum >= QCA8K_MDIO_MASTER_MAX_REG) | ||
| 505 | return -EINVAL; | ||
| 506 | |||
| 507 | /* callee is responsible for not passing bad ports, | ||
| 508 | * but we still would like to make spills impossible. | ||
| 509 | */ | ||
| 510 | phy = qca8k_port_to_phy(port) % PHY_MAX_ADDR; | ||
| 511 | val = QCA8K_MDIO_MASTER_BUSY | QCA8K_MDIO_MASTER_EN | | ||
| 512 | QCA8K_MDIO_MASTER_WRITE | QCA8K_MDIO_MASTER_PHY_ADDR(phy) | | ||
| 513 | QCA8K_MDIO_MASTER_REG_ADDR(regnum) | | ||
| 514 | QCA8K_MDIO_MASTER_DATA(data); | ||
| 515 | |||
| 516 | qca8k_write(priv, QCA8K_MDIO_MASTER_CTRL, val); | ||
| 517 | |||
| 518 | return qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL, | ||
| 519 | QCA8K_MDIO_MASTER_BUSY); | ||
| 520 | } | ||
| 521 | |||
| 522 | static int | ||
| 523 | qca8k_mdio_read(struct qca8k_priv *priv, int port, u32 regnum) | ||
| 524 | { | ||
| 525 | u32 phy, val; | ||
| 526 | |||
| 527 | if (regnum >= QCA8K_MDIO_MASTER_MAX_REG) | ||
| 528 | return -EINVAL; | ||
| 529 | |||
| 530 | /* callee is responsible for not passing bad ports, | ||
| 531 | * but we still would like to make spills impossible. | ||
| 532 | */ | ||
| 533 | phy = qca8k_port_to_phy(port) % PHY_MAX_ADDR; | ||
| 534 | val = QCA8K_MDIO_MASTER_BUSY | QCA8K_MDIO_MASTER_EN | | ||
| 535 | QCA8K_MDIO_MASTER_READ | QCA8K_MDIO_MASTER_PHY_ADDR(phy) | | ||
| 536 | QCA8K_MDIO_MASTER_REG_ADDR(regnum); | ||
| 537 | |||
| 538 | qca8k_write(priv, QCA8K_MDIO_MASTER_CTRL, val); | ||
| 539 | |||
| 540 | if (qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL, | ||
| 541 | QCA8K_MDIO_MASTER_BUSY)) | ||
| 542 | return -ETIMEDOUT; | ||
| 543 | |||
| 544 | val = (qca8k_read(priv, QCA8K_MDIO_MASTER_CTRL) & | ||
| 545 | QCA8K_MDIO_MASTER_DATA_MASK); | ||
| 546 | |||
| 547 | return val; | ||
| 548 | } | ||
| 549 | |||
| 550 | static int | ||
| 551 | qca8k_phy_write(struct dsa_switch *ds, int port, int regnum, u16 data) | ||
| 552 | { | ||
| 553 | struct qca8k_priv *priv = ds->priv; | ||
| 554 | |||
| 555 | return qca8k_mdio_write(priv, port, regnum, data); | ||
| 556 | } | ||
| 557 | |||
| 558 | static int | ||
| 559 | qca8k_phy_read(struct dsa_switch *ds, int port, int regnum) | ||
| 560 | { | ||
| 561 | struct qca8k_priv *priv = ds->priv; | ||
| 562 | int ret; | ||
| 563 | |||
| 564 | ret = qca8k_mdio_read(priv, port, regnum); | ||
| 565 | |||
| 566 | if (ret < 0) | ||
| 567 | return 0xffff; | ||
| 568 | |||
| 569 | return ret; | ||
| 570 | } | ||
| 571 | |||
| 572 | static int | ||
| 573 | qca8k_setup_mdio_bus(struct qca8k_priv *priv) | ||
| 574 | { | ||
| 575 | u32 internal_mdio_mask = 0, external_mdio_mask = 0, reg; | ||
| 576 | struct device_node *ports, *port; | ||
| 577 | int err; | ||
| 578 | |||
| 579 | ports = of_get_child_by_name(priv->dev->of_node, "ports"); | ||
| 580 | if (!ports) | ||
| 581 | return -EINVAL; | ||
| 582 | |||
| 583 | for_each_available_child_of_node(ports, port) { | ||
| 584 | err = of_property_read_u32(port, "reg", ®); | ||
| 585 | if (err) | ||
| 586 | return err; | ||
| 587 | |||
| 588 | if (!dsa_is_user_port(priv->ds, reg)) | ||
| 589 | continue; | ||
| 590 | |||
| 591 | if (of_property_read_bool(port, "phy-handle")) | ||
| 592 | external_mdio_mask |= BIT(reg); | ||
| 593 | else | ||
| 594 | internal_mdio_mask |= BIT(reg); | ||
| 595 | } | ||
| 596 | |||
| 597 | if (!external_mdio_mask && !internal_mdio_mask) { | ||
| 598 | dev_err(priv->dev, "no PHYs are defined.\n"); | ||
| 599 | return -EINVAL; | ||
| 600 | } | ||
| 601 | |||
| 602 | /* The QCA8K_MDIO_MASTER_EN Bit, which grants access to PHYs through | ||
| 603 | * the MDIO_MASTER register also _disconnects_ the external MDC | ||
| 604 | * passthrough to the internal PHYs. It's not possible to use both | ||
| 605 | * configurations at the same time! | ||
| 606 | * | ||
| 607 | * Because this came up during the review process: | ||
| 608 | * If the external mdio-bus driver is capable magically disabling | ||
| 609 | * the QCA8K_MDIO_MASTER_EN and mutex/spin-locking out the qca8k's | ||
| 610 | * accessors for the time being, it would be possible to pull this | ||
| 611 | * off. | ||
| 612 | */ | ||
| 613 | if (!!external_mdio_mask && !!internal_mdio_mask) { | ||
| 614 | dev_err(priv->dev, "either internal or external mdio bus configuration is supported.\n"); | ||
| 615 | return -EINVAL; | ||
| 616 | } | ||
| 617 | |||
| 618 | if (external_mdio_mask) { | ||
| 619 | /* Make sure to disable the internal mdio bus in cases | ||
| 620 | * a dt-overlay and driver reload changed the configuration | ||
| 621 | */ | ||
| 622 | |||
| 623 | qca8k_reg_clear(priv, QCA8K_MDIO_MASTER_CTRL, | ||
| 624 | QCA8K_MDIO_MASTER_EN); | ||
| 625 | return 0; | ||
| 626 | } | ||
| 627 | |||
| 628 | priv->ops.phy_read = qca8k_phy_read; | ||
| 629 | priv->ops.phy_write = qca8k_phy_write; | ||
| 630 | return 0; | ||
| 631 | } | ||
| 632 | |||
| 484 | static int | 633 | static int |
| 485 | qca8k_setup(struct dsa_switch *ds) | 634 | qca8k_setup(struct dsa_switch *ds) |
| 486 | { | 635 | { |
| @@ -502,6 +651,10 @@ qca8k_setup(struct dsa_switch *ds) | |||
| 502 | if (IS_ERR(priv->regmap)) | 651 | if (IS_ERR(priv->regmap)) |
| 503 | pr_warn("regmap initialization failed"); | 652 | pr_warn("regmap initialization failed"); |
| 504 | 653 | ||
| 654 | ret = qca8k_setup_mdio_bus(priv); | ||
| 655 | if (ret) | ||
| 656 | return ret; | ||
| 657 | |||
| 505 | /* Initialize CPU port pad mode (xMII type, delays...) */ | 658 | /* Initialize CPU port pad mode (xMII type, delays...) */ |
| 506 | phy_mode = of_get_phy_mode(ds->ports[QCA8K_CPU_PORT].dn); | 659 | phy_mode = of_get_phy_mode(ds->ports[QCA8K_CPU_PORT].dn); |
| 507 | if (phy_mode < 0) { | 660 | if (phy_mode < 0) { |
| @@ -624,22 +777,6 @@ qca8k_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phy) | |||
| 624 | qca8k_port_set_status(priv, port, 1); | 777 | qca8k_port_set_status(priv, port, 1); |
| 625 | } | 778 | } |
| 626 | 779 | ||
| 627 | static int | ||
| 628 | qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum) | ||
| 629 | { | ||
| 630 | struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; | ||
| 631 | |||
| 632 | return mdiobus_read(priv->bus, phy, regnum); | ||
| 633 | } | ||
| 634 | |||
| 635 | static int | ||
| 636 | qca8k_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val) | ||
| 637 | { | ||
| 638 | struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; | ||
| 639 | |||
| 640 | return mdiobus_write(priv->bus, phy, regnum, val); | ||
| 641 | } | ||
| 642 | |||
| 643 | static void | 780 | static void |
| 644 | qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data) | 781 | qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data) |
| 645 | { | 782 | { |
| @@ -879,8 +1016,6 @@ static const struct dsa_switch_ops qca8k_switch_ops = { | |||
| 879 | .setup = qca8k_setup, | 1016 | .setup = qca8k_setup, |
| 880 | .adjust_link = qca8k_adjust_link, | 1017 | .adjust_link = qca8k_adjust_link, |
| 881 | .get_strings = qca8k_get_strings, | 1018 | .get_strings = qca8k_get_strings, |
| 882 | .phy_read = qca8k_phy_read, | ||
| 883 | .phy_write = qca8k_phy_write, | ||
| 884 | .get_ethtool_stats = qca8k_get_ethtool_stats, | 1019 | .get_ethtool_stats = qca8k_get_ethtool_stats, |
| 885 | .get_sset_count = qca8k_get_sset_count, | 1020 | .get_sset_count = qca8k_get_sset_count, |
| 886 | .get_mac_eee = qca8k_get_mac_eee, | 1021 | .get_mac_eee = qca8k_get_mac_eee, |
| @@ -923,7 +1058,8 @@ qca8k_sw_probe(struct mdio_device *mdiodev) | |||
| 923 | return -ENOMEM; | 1058 | return -ENOMEM; |
| 924 | 1059 | ||
| 925 | priv->ds->priv = priv; | 1060 | priv->ds->priv = priv; |
| 926 | priv->ds->ops = &qca8k_switch_ops; | 1061 | priv->ops = qca8k_switch_ops; |
| 1062 | priv->ds->ops = &priv->ops; | ||
| 927 | mutex_init(&priv->reg_mutex); | 1063 | mutex_init(&priv->reg_mutex); |
| 928 | dev_set_drvdata(&mdiodev->dev, priv); | 1064 | dev_set_drvdata(&mdiodev->dev, priv); |
| 929 | 1065 | ||
diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h index d146e54c8a6c..249fd62268e5 100644 --- a/drivers/net/dsa/qca8k.h +++ b/drivers/net/dsa/qca8k.h | |||
| @@ -49,6 +49,18 @@ | |||
| 49 | #define QCA8K_MIB_FLUSH BIT(24) | 49 | #define QCA8K_MIB_FLUSH BIT(24) |
| 50 | #define QCA8K_MIB_CPU_KEEP BIT(20) | 50 | #define QCA8K_MIB_CPU_KEEP BIT(20) |
| 51 | #define QCA8K_MIB_BUSY BIT(17) | 51 | #define QCA8K_MIB_BUSY BIT(17) |
| 52 | #define QCA8K_MDIO_MASTER_CTRL 0x3c | ||
| 53 | #define QCA8K_MDIO_MASTER_BUSY BIT(31) | ||
| 54 | #define QCA8K_MDIO_MASTER_EN BIT(30) | ||
| 55 | #define QCA8K_MDIO_MASTER_READ BIT(27) | ||
| 56 | #define QCA8K_MDIO_MASTER_WRITE 0 | ||
| 57 | #define QCA8K_MDIO_MASTER_SUP_PRE BIT(26) | ||
| 58 | #define QCA8K_MDIO_MASTER_PHY_ADDR(x) ((x) << 21) | ||
| 59 | #define QCA8K_MDIO_MASTER_REG_ADDR(x) ((x) << 16) | ||
| 60 | #define QCA8K_MDIO_MASTER_DATA(x) (x) | ||
| 61 | #define QCA8K_MDIO_MASTER_DATA_MASK GENMASK(15, 0) | ||
| 62 | #define QCA8K_MDIO_MASTER_MAX_PORTS 5 | ||
| 63 | #define QCA8K_MDIO_MASTER_MAX_REG 32 | ||
| 52 | #define QCA8K_GOL_MAC_ADDR0 0x60 | 64 | #define QCA8K_GOL_MAC_ADDR0 0x60 |
| 53 | #define QCA8K_GOL_MAC_ADDR1 0x64 | 65 | #define QCA8K_GOL_MAC_ADDR1 0x64 |
| 54 | #define QCA8K_REG_PORT_STATUS(_i) (0x07c + (_i) * 4) | 66 | #define QCA8K_REG_PORT_STATUS(_i) (0x07c + (_i) * 4) |
| @@ -169,6 +181,7 @@ struct qca8k_priv { | |||
| 169 | struct dsa_switch *ds; | 181 | struct dsa_switch *ds; |
| 170 | struct mutex reg_mutex; | 182 | struct mutex reg_mutex; |
| 171 | struct device *dev; | 183 | struct device *dev; |
| 184 | struct dsa_switch_ops ops; | ||
| 172 | }; | 185 | }; |
| 173 | 186 | ||
| 174 | struct qca8k_mib_desc { | 187 | struct qca8k_mib_desc { |
diff --git a/drivers/net/ethernet/3com/3c515.c b/drivers/net/ethernet/3com/3c515.c index 808abb6b3671..b15752267c8d 100644 --- a/drivers/net/ethernet/3com/3c515.c +++ b/drivers/net/ethernet/3com/3c515.c | |||
| @@ -1521,7 +1521,7 @@ static void update_stats(int ioaddr, struct net_device *dev) | |||
| 1521 | static void set_rx_mode(struct net_device *dev) | 1521 | static void set_rx_mode(struct net_device *dev) |
| 1522 | { | 1522 | { |
| 1523 | int ioaddr = dev->base_addr; | 1523 | int ioaddr = dev->base_addr; |
| 1524 | short new_mode; | 1524 | unsigned short new_mode; |
| 1525 | 1525 | ||
| 1526 | if (dev->flags & IFF_PROMISC) { | 1526 | if (dev->flags & IFF_PROMISC) { |
| 1527 | if (corkscrew_debug > 3) | 1527 | if (corkscrew_debug > 3) |
diff --git a/drivers/net/ethernet/8390/mac8390.c b/drivers/net/ethernet/8390/mac8390.c index 342ae08ec3c2..d60a86aa8aa8 100644 --- a/drivers/net/ethernet/8390/mac8390.c +++ b/drivers/net/ethernet/8390/mac8390.c | |||
| @@ -153,8 +153,6 @@ static void dayna_block_input(struct net_device *dev, int count, | |||
| 153 | static void dayna_block_output(struct net_device *dev, int count, | 153 | static void dayna_block_output(struct net_device *dev, int count, |
| 154 | const unsigned char *buf, int start_page); | 154 | const unsigned char *buf, int start_page); |
| 155 | 155 | ||
| 156 | #define memcmp_withio(a, b, c) memcmp((a), (void *)(b), (c)) | ||
| 157 | |||
| 158 | /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */ | 156 | /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */ |
| 159 | static void slow_sane_get_8390_hdr(struct net_device *dev, | 157 | static void slow_sane_get_8390_hdr(struct net_device *dev, |
| 160 | struct e8390_pkt_hdr *hdr, int ring_page); | 158 | struct e8390_pkt_hdr *hdr, int ring_page); |
| @@ -233,19 +231,26 @@ static enum mac8390_type mac8390_ident(struct nubus_rsrc *fres) | |||
| 233 | 231 | ||
| 234 | static enum mac8390_access mac8390_testio(unsigned long membase) | 232 | static enum mac8390_access mac8390_testio(unsigned long membase) |
| 235 | { | 233 | { |
| 236 | unsigned long outdata = 0xA5A0B5B0; | 234 | u32 outdata = 0xA5A0B5B0; |
| 237 | unsigned long indata = 0x00000000; | 235 | u32 indata = 0; |
| 236 | |||
| 238 | /* Try writing 32 bits */ | 237 | /* Try writing 32 bits */ |
| 239 | memcpy_toio((void __iomem *)membase, &outdata, 4); | 238 | nubus_writel(outdata, membase); |
| 240 | /* Now compare them */ | 239 | /* Now read it back */ |
| 241 | if (memcmp_withio(&outdata, membase, 4) == 0) | 240 | indata = nubus_readl(membase); |
| 241 | if (outdata == indata) | ||
| 242 | return ACCESS_32; | 242 | return ACCESS_32; |
| 243 | |||
| 244 | outdata = 0xC5C0D5D0; | ||
| 245 | indata = 0; | ||
| 246 | |||
| 243 | /* Write 16 bit output */ | 247 | /* Write 16 bit output */ |
| 244 | word_memcpy_tocard(membase, &outdata, 4); | 248 | word_memcpy_tocard(membase, &outdata, 4); |
| 245 | /* Now read it back */ | 249 | /* Now read it back */ |
| 246 | word_memcpy_fromcard(&indata, membase, 4); | 250 | word_memcpy_fromcard(&indata, membase, 4); |
| 247 | if (outdata == indata) | 251 | if (outdata == indata) |
| 248 | return ACCESS_16; | 252 | return ACCESS_16; |
| 253 | |||
| 249 | return ACCESS_UNKNOWN; | 254 | return ACCESS_UNKNOWN; |
| 250 | } | 255 | } |
| 251 | 256 | ||
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index 74550ccc7a20..e2ffb159cbe2 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c | |||
| @@ -186,11 +186,12 @@ static void aq_rx_checksum(struct aq_ring_s *self, | |||
| 186 | } | 186 | } |
| 187 | if (buff->is_ip_cso) { | 187 | if (buff->is_ip_cso) { |
| 188 | __skb_incr_checksum_unnecessary(skb); | 188 | __skb_incr_checksum_unnecessary(skb); |
| 189 | if (buff->is_udp_cso || buff->is_tcp_cso) | ||
| 190 | __skb_incr_checksum_unnecessary(skb); | ||
| 191 | } else { | 189 | } else { |
| 192 | skb->ip_summed = CHECKSUM_NONE; | 190 | skb->ip_summed = CHECKSUM_NONE; |
| 193 | } | 191 | } |
| 192 | |||
| 193 | if (buff->is_udp_cso || buff->is_tcp_cso) | ||
| 194 | __skb_incr_checksum_unnecessary(skb); | ||
| 194 | } | 195 | } |
| 195 | 196 | ||
| 196 | #define AQ_SKB_ALIGN SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) | 197 | #define AQ_SKB_ALIGN SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) |
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index ad099fd01b45..1522aee81884 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c | |||
| @@ -3370,14 +3370,20 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, | |||
| 3370 | *hclk = devm_clk_get(&pdev->dev, "hclk"); | 3370 | *hclk = devm_clk_get(&pdev->dev, "hclk"); |
| 3371 | } | 3371 | } |
| 3372 | 3372 | ||
| 3373 | if (IS_ERR(*pclk)) { | 3373 | if (IS_ERR_OR_NULL(*pclk)) { |
| 3374 | err = PTR_ERR(*pclk); | 3374 | err = PTR_ERR(*pclk); |
| 3375 | if (!err) | ||
| 3376 | err = -ENODEV; | ||
| 3377 | |||
| 3375 | dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); | 3378 | dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); |
| 3376 | return err; | 3379 | return err; |
| 3377 | } | 3380 | } |
| 3378 | 3381 | ||
| 3379 | if (IS_ERR(*hclk)) { | 3382 | if (IS_ERR_OR_NULL(*hclk)) { |
| 3380 | err = PTR_ERR(*hclk); | 3383 | err = PTR_ERR(*hclk); |
| 3384 | if (!err) | ||
| 3385 | err = -ENODEV; | ||
| 3386 | |||
| 3381 | dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); | 3387 | dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); |
| 3382 | return err; | 3388 | return err; |
| 3383 | } | 3389 | } |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 3130b43bba52..02959035ed3f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
| @@ -2620,7 +2620,7 @@ static inline struct port_info *ethqset2pinfo(struct adapter *adap, int qset) | |||
| 2620 | } | 2620 | } |
| 2621 | 2621 | ||
| 2622 | /* should never happen! */ | 2622 | /* should never happen! */ |
| 2623 | BUG_ON(1); | 2623 | BUG(); |
| 2624 | return NULL; | 2624 | return NULL; |
| 2625 | } | 2625 | } |
| 2626 | 2626 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 88773ca58e6b..b3da81e90132 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c | |||
| @@ -476,7 +476,7 @@ static inline int get_buf_size(struct adapter *adapter, | |||
| 476 | break; | 476 | break; |
| 477 | 477 | ||
| 478 | default: | 478 | default: |
| 479 | BUG_ON(1); | 479 | BUG(); |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | return buf_size; | 482 | return buf_size; |
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 2ba49e959c3f..dc339dc1adb2 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | |||
| @@ -815,6 +815,14 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) | |||
| 815 | */ | 815 | */ |
| 816 | queue_mapping = skb_get_queue_mapping(skb); | 816 | queue_mapping = skb_get_queue_mapping(skb); |
| 817 | fq = &priv->fq[queue_mapping]; | 817 | fq = &priv->fq[queue_mapping]; |
| 818 | |||
| 819 | fd_len = dpaa2_fd_get_len(&fd); | ||
| 820 | nq = netdev_get_tx_queue(net_dev, queue_mapping); | ||
| 821 | netdev_tx_sent_queue(nq, fd_len); | ||
| 822 | |||
| 823 | /* Everything that happens after this enqueues might race with | ||
| 824 | * the Tx confirmation callback for this frame | ||
| 825 | */ | ||
| 818 | for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { | 826 | for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { |
| 819 | err = priv->enqueue(priv, fq, &fd, 0); | 827 | err = priv->enqueue(priv, fq, &fd, 0); |
| 820 | if (err != -EBUSY) | 828 | if (err != -EBUSY) |
| @@ -825,13 +833,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) | |||
| 825 | percpu_stats->tx_errors++; | 833 | percpu_stats->tx_errors++; |
| 826 | /* Clean up everything, including freeing the skb */ | 834 | /* Clean up everything, including freeing the skb */ |
| 827 | free_tx_fd(priv, fq, &fd, false); | 835 | free_tx_fd(priv, fq, &fd, false); |
| 836 | netdev_tx_completed_queue(nq, 1, fd_len); | ||
| 828 | } else { | 837 | } else { |
| 829 | fd_len = dpaa2_fd_get_len(&fd); | ||
| 830 | percpu_stats->tx_packets++; | 838 | percpu_stats->tx_packets++; |
| 831 | percpu_stats->tx_bytes += fd_len; | 839 | percpu_stats->tx_bytes += fd_len; |
| 832 | |||
| 833 | nq = netdev_get_tx_queue(net_dev, queue_mapping); | ||
| 834 | netdev_tx_sent_queue(nq, fd_len); | ||
| 835 | } | 840 | } |
| 836 | 841 | ||
| 837 | return NETDEV_TX_OK; | 842 | return NETDEV_TX_OK; |
| @@ -1817,7 +1822,7 @@ static int dpaa2_eth_xdp_xmit_frame(struct net_device *net_dev, | |||
| 1817 | dpaa2_fd_set_format(&fd, dpaa2_fd_single); | 1822 | dpaa2_fd_set_format(&fd, dpaa2_fd_single); |
| 1818 | dpaa2_fd_set_ctrl(&fd, FD_CTRL_PTA); | 1823 | dpaa2_fd_set_ctrl(&fd, FD_CTRL_PTA); |
| 1819 | 1824 | ||
| 1820 | fq = &priv->fq[smp_processor_id()]; | 1825 | fq = &priv->fq[smp_processor_id() % dpaa2_eth_queue_count(priv)]; |
| 1821 | for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { | 1826 | for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { |
| 1822 | err = priv->enqueue(priv, fq, &fd, 0); | 1827 | err = priv->enqueue(priv, fq, &fd, 0); |
| 1823 | if (err != -EBUSY) | 1828 | if (err != -EBUSY) |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 1c1f17ec6be2..162cb9afa0e7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include "hns3_enet.h" | 22 | #include "hns3_enet.h" |
| 23 | 23 | ||
| 24 | #define hns3_set_field(origin, shift, val) ((origin) |= ((val) << (shift))) | 24 | #define hns3_set_field(origin, shift, val) ((origin) |= ((val) << (shift))) |
| 25 | #define hns3_tx_bd_count(S) DIV_ROUND_UP(S, HNS3_MAX_BD_SIZE) | ||
| 25 | 26 | ||
| 26 | static void hns3_clear_all_ring(struct hnae3_handle *h); | 27 | static void hns3_clear_all_ring(struct hnae3_handle *h); |
| 27 | static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h); | 28 | static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h); |
| @@ -1079,7 +1080,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, | |||
| 1079 | 1080 | ||
| 1080 | desc_cb->length = size; | 1081 | desc_cb->length = size; |
| 1081 | 1082 | ||
| 1082 | frag_buf_num = (size + HNS3_MAX_BD_SIZE - 1) >> HNS3_MAX_BD_SIZE_OFFSET; | 1083 | frag_buf_num = hns3_tx_bd_count(size); |
| 1083 | sizeoflast = size & HNS3_TX_LAST_SIZE_M; | 1084 | sizeoflast = size & HNS3_TX_LAST_SIZE_M; |
| 1084 | sizeoflast = sizeoflast ? sizeoflast : HNS3_MAX_BD_SIZE; | 1085 | sizeoflast = sizeoflast ? sizeoflast : HNS3_MAX_BD_SIZE; |
| 1085 | 1086 | ||
| @@ -1124,14 +1125,13 @@ static int hns3_nic_maybe_stop_tso(struct sk_buff **out_skb, int *bnum, | |||
| 1124 | int i; | 1125 | int i; |
| 1125 | 1126 | ||
| 1126 | size = skb_headlen(skb); | 1127 | size = skb_headlen(skb); |
| 1127 | buf_num = (size + HNS3_MAX_BD_SIZE - 1) >> HNS3_MAX_BD_SIZE_OFFSET; | 1128 | buf_num = hns3_tx_bd_count(size); |
| 1128 | 1129 | ||
| 1129 | frag_num = skb_shinfo(skb)->nr_frags; | 1130 | frag_num = skb_shinfo(skb)->nr_frags; |
| 1130 | for (i = 0; i < frag_num; i++) { | 1131 | for (i = 0; i < frag_num; i++) { |
| 1131 | frag = &skb_shinfo(skb)->frags[i]; | 1132 | frag = &skb_shinfo(skb)->frags[i]; |
| 1132 | size = skb_frag_size(frag); | 1133 | size = skb_frag_size(frag); |
| 1133 | bdnum_for_frag = (size + HNS3_MAX_BD_SIZE - 1) >> | 1134 | bdnum_for_frag = hns3_tx_bd_count(size); |
| 1134 | HNS3_MAX_BD_SIZE_OFFSET; | ||
| 1135 | if (unlikely(bdnum_for_frag > HNS3_MAX_BD_PER_FRAG)) | 1135 | if (unlikely(bdnum_for_frag > HNS3_MAX_BD_PER_FRAG)) |
| 1136 | return -ENOMEM; | 1136 | return -ENOMEM; |
| 1137 | 1137 | ||
| @@ -1139,8 +1139,7 @@ static int hns3_nic_maybe_stop_tso(struct sk_buff **out_skb, int *bnum, | |||
| 1139 | } | 1139 | } |
| 1140 | 1140 | ||
| 1141 | if (unlikely(buf_num > HNS3_MAX_BD_PER_FRAG)) { | 1141 | if (unlikely(buf_num > HNS3_MAX_BD_PER_FRAG)) { |
| 1142 | buf_num = (skb->len + HNS3_MAX_BD_SIZE - 1) >> | 1142 | buf_num = hns3_tx_bd_count(skb->len); |
| 1143 | HNS3_MAX_BD_SIZE_OFFSET; | ||
| 1144 | if (ring_space(ring) < buf_num) | 1143 | if (ring_space(ring) < buf_num) |
| 1145 | return -EBUSY; | 1144 | return -EBUSY; |
| 1146 | /* manual split the send packet */ | 1145 | /* manual split the send packet */ |
| @@ -1169,7 +1168,7 @@ static int hns3_nic_maybe_stop_tx(struct sk_buff **out_skb, int *bnum, | |||
| 1169 | buf_num = skb_shinfo(skb)->nr_frags + 1; | 1168 | buf_num = skb_shinfo(skb)->nr_frags + 1; |
| 1170 | 1169 | ||
| 1171 | if (unlikely(buf_num > HNS3_MAX_BD_PER_FRAG)) { | 1170 | if (unlikely(buf_num > HNS3_MAX_BD_PER_FRAG)) { |
| 1172 | buf_num = (skb->len + HNS3_MAX_BD_SIZE - 1) / HNS3_MAX_BD_SIZE; | 1171 | buf_num = hns3_tx_bd_count(skb->len); |
| 1173 | if (ring_space(ring) < buf_num) | 1172 | if (ring_space(ring) < buf_num) |
| 1174 | return -EBUSY; | 1173 | return -EBUSY; |
| 1175 | /* manual split the send packet */ | 1174 | /* manual split the send packet */ |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 1db0bd41d209..75669cd0c311 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | |||
| @@ -193,7 +193,6 @@ enum hns3_nic_state { | |||
| 193 | #define HNS3_VECTOR_INITED 1 | 193 | #define HNS3_VECTOR_INITED 1 |
| 194 | 194 | ||
| 195 | #define HNS3_MAX_BD_SIZE 65535 | 195 | #define HNS3_MAX_BD_SIZE 65535 |
| 196 | #define HNS3_MAX_BD_SIZE_OFFSET 16 | ||
| 197 | #define HNS3_MAX_BD_PER_FRAG 8 | 196 | #define HNS3_MAX_BD_PER_FRAG 8 |
| 198 | #define HNS3_MAX_BD_PER_PKT MAX_SKB_FRAGS | 197 | #define HNS3_MAX_BD_PER_PKT MAX_SKB_FRAGS |
| 199 | 198 | ||
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c index 3baabdc89726..90b62c1412c8 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c | |||
| @@ -3160,6 +3160,7 @@ static ssize_t ehea_probe_port(struct device *dev, | |||
| 3160 | 3160 | ||
| 3161 | if (ehea_add_adapter_mr(adapter)) { | 3161 | if (ehea_add_adapter_mr(adapter)) { |
| 3162 | pr_err("creating MR failed\n"); | 3162 | pr_err("creating MR failed\n"); |
| 3163 | of_node_put(eth_dn); | ||
| 3163 | return -EIO; | 3164 | return -EIO; |
| 3164 | } | 3165 | } |
| 3165 | 3166 | ||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c index 7a15e932ed2f..c1c1965d7acc 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c | |||
| @@ -113,7 +113,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, | |||
| 113 | return 0; | 113 | return 0; |
| 114 | default: | 114 | default: |
| 115 | /* Do not consider thresholds for zero temperature. */ | 115 | /* Do not consider thresholds for zero temperature. */ |
| 116 | if (!MLXSW_REG_MTMP_TEMP_TO_MC(module_temp)) { | 116 | if (MLXSW_REG_MTMP_TEMP_TO_MC(module_temp) == 0) { |
| 117 | *temp = 0; | 117 | *temp = 0; |
| 118 | return 0; | 118 | return 0; |
| 119 | } | 119 | } |
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index bd6e9014bc74..7849119d407a 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c | |||
| @@ -142,6 +142,12 @@ struct ks8851_net { | |||
| 142 | 142 | ||
| 143 | static int msg_enable; | 143 | static int msg_enable; |
| 144 | 144 | ||
| 145 | /* SPI frame opcodes */ | ||
| 146 | #define KS_SPIOP_RD (0x00) | ||
| 147 | #define KS_SPIOP_WR (0x40) | ||
| 148 | #define KS_SPIOP_RXFIFO (0x80) | ||
| 149 | #define KS_SPIOP_TXFIFO (0xC0) | ||
| 150 | |||
| 145 | /* shift for byte-enable data */ | 151 | /* shift for byte-enable data */ |
| 146 | #define BYTE_EN(_x) ((_x) << 2) | 152 | #define BYTE_EN(_x) ((_x) << 2) |
| 147 | 153 | ||
| @@ -535,9 +541,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) | |||
| 535 | /* set dma read address */ | 541 | /* set dma read address */ |
| 536 | ks8851_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI | 0x00); | 542 | ks8851_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI | 0x00); |
| 537 | 543 | ||
| 538 | /* start the packet dma process, and set auto-dequeue rx */ | 544 | /* start DMA access */ |
| 539 | ks8851_wrreg16(ks, KS_RXQCR, | 545 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); |
| 540 | ks->rc_rxqcr | RXQCR_SDA | RXQCR_ADRFE); | ||
| 541 | 546 | ||
| 542 | if (rxlen > 4) { | 547 | if (rxlen > 4) { |
| 543 | unsigned int rxalign; | 548 | unsigned int rxalign; |
| @@ -568,7 +573,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) | |||
| 568 | } | 573 | } |
| 569 | } | 574 | } |
| 570 | 575 | ||
| 571 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); | 576 | /* end DMA access and dequeue packet */ |
| 577 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_RRXEF); | ||
| 572 | } | 578 | } |
| 573 | } | 579 | } |
| 574 | 580 | ||
| @@ -785,6 +791,15 @@ static void ks8851_tx_work(struct work_struct *work) | |||
| 785 | static int ks8851_net_open(struct net_device *dev) | 791 | static int ks8851_net_open(struct net_device *dev) |
| 786 | { | 792 | { |
| 787 | struct ks8851_net *ks = netdev_priv(dev); | 793 | struct ks8851_net *ks = netdev_priv(dev); |
| 794 | int ret; | ||
| 795 | |||
| 796 | ret = request_threaded_irq(dev->irq, NULL, ks8851_irq, | ||
| 797 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
| 798 | dev->name, ks); | ||
| 799 | if (ret < 0) { | ||
| 800 | netdev_err(dev, "failed to get irq\n"); | ||
| 801 | return ret; | ||
| 802 | } | ||
| 788 | 803 | ||
| 789 | /* lock the card, even if we may not actually be doing anything | 804 | /* lock the card, even if we may not actually be doing anything |
| 790 | * else at the moment */ | 805 | * else at the moment */ |
| @@ -849,6 +864,7 @@ static int ks8851_net_open(struct net_device *dev) | |||
| 849 | netif_dbg(ks, ifup, ks->netdev, "network device up\n"); | 864 | netif_dbg(ks, ifup, ks->netdev, "network device up\n"); |
| 850 | 865 | ||
| 851 | mutex_unlock(&ks->lock); | 866 | mutex_unlock(&ks->lock); |
| 867 | mii_check_link(&ks->mii); | ||
| 852 | return 0; | 868 | return 0; |
| 853 | } | 869 | } |
| 854 | 870 | ||
| @@ -899,6 +915,8 @@ static int ks8851_net_stop(struct net_device *dev) | |||
| 899 | dev_kfree_skb(txb); | 915 | dev_kfree_skb(txb); |
| 900 | } | 916 | } |
| 901 | 917 | ||
| 918 | free_irq(dev->irq, ks); | ||
| 919 | |||
| 902 | return 0; | 920 | return 0; |
| 903 | } | 921 | } |
| 904 | 922 | ||
| @@ -1508,6 +1526,7 @@ static int ks8851_probe(struct spi_device *spi) | |||
| 1508 | 1526 | ||
| 1509 | spi_set_drvdata(spi, ks); | 1527 | spi_set_drvdata(spi, ks); |
| 1510 | 1528 | ||
| 1529 | netif_carrier_off(ks->netdev); | ||
| 1511 | ndev->if_port = IF_PORT_100BASET; | 1530 | ndev->if_port = IF_PORT_100BASET; |
| 1512 | ndev->netdev_ops = &ks8851_netdev_ops; | 1531 | ndev->netdev_ops = &ks8851_netdev_ops; |
| 1513 | ndev->irq = spi->irq; | 1532 | ndev->irq = spi->irq; |
| @@ -1529,14 +1548,6 @@ static int ks8851_probe(struct spi_device *spi) | |||
| 1529 | ks8851_read_selftest(ks); | 1548 | ks8851_read_selftest(ks); |
| 1530 | ks8851_init_mac(ks); | 1549 | ks8851_init_mac(ks); |
| 1531 | 1550 | ||
| 1532 | ret = request_threaded_irq(spi->irq, NULL, ks8851_irq, | ||
| 1533 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
| 1534 | ndev->name, ks); | ||
| 1535 | if (ret < 0) { | ||
| 1536 | dev_err(&spi->dev, "failed to get irq\n"); | ||
| 1537 | goto err_irq; | ||
| 1538 | } | ||
| 1539 | |||
| 1540 | ret = register_netdev(ndev); | 1551 | ret = register_netdev(ndev); |
| 1541 | if (ret) { | 1552 | if (ret) { |
| 1542 | dev_err(&spi->dev, "failed to register network device\n"); | 1553 | dev_err(&spi->dev, "failed to register network device\n"); |
| @@ -1549,14 +1560,10 @@ static int ks8851_probe(struct spi_device *spi) | |||
| 1549 | 1560 | ||
| 1550 | return 0; | 1561 | return 0; |
| 1551 | 1562 | ||
| 1552 | |||
| 1553 | err_netdev: | 1563 | err_netdev: |
| 1554 | free_irq(ndev->irq, ks); | 1564 | err_id: |
| 1555 | |||
| 1556 | err_irq: | ||
| 1557 | if (gpio_is_valid(gpio)) | 1565 | if (gpio_is_valid(gpio)) |
| 1558 | gpio_set_value(gpio, 0); | 1566 | gpio_set_value(gpio, 0); |
| 1559 | err_id: | ||
| 1560 | regulator_disable(ks->vdd_reg); | 1567 | regulator_disable(ks->vdd_reg); |
| 1561 | err_reg: | 1568 | err_reg: |
| 1562 | regulator_disable(ks->vdd_io); | 1569 | regulator_disable(ks->vdd_io); |
| @@ -1574,7 +1581,6 @@ static int ks8851_remove(struct spi_device *spi) | |||
| 1574 | dev_info(&spi->dev, "remove\n"); | 1581 | dev_info(&spi->dev, "remove\n"); |
| 1575 | 1582 | ||
| 1576 | unregister_netdev(priv->netdev); | 1583 | unregister_netdev(priv->netdev); |
| 1577 | free_irq(spi->irq, priv); | ||
| 1578 | if (gpio_is_valid(priv->gpio)) | 1584 | if (gpio_is_valid(priv->gpio)) |
| 1579 | gpio_set_value(priv->gpio, 0); | 1585 | gpio_set_value(priv->gpio, 0); |
| 1580 | regulator_disable(priv->vdd_reg); | 1586 | regulator_disable(priv->vdd_reg); |
diff --git a/drivers/net/ethernet/micrel/ks8851.h b/drivers/net/ethernet/micrel/ks8851.h index 852256ef1f22..23da1e3ee429 100644 --- a/drivers/net/ethernet/micrel/ks8851.h +++ b/drivers/net/ethernet/micrel/ks8851.h | |||
| @@ -11,9 +11,15 @@ | |||
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #define KS_CCR 0x08 | 13 | #define KS_CCR 0x08 |
| 14 | #define CCR_LE (1 << 10) /* KSZ8851-16MLL */ | ||
| 14 | #define CCR_EEPROM (1 << 9) | 15 | #define CCR_EEPROM (1 << 9) |
| 15 | #define CCR_SPI (1 << 8) | 16 | #define CCR_SPI (1 << 8) /* KSZ8851SNL */ |
| 16 | #define CCR_32PIN (1 << 0) | 17 | #define CCR_8BIT (1 << 7) /* KSZ8851-16MLL */ |
| 18 | #define CCR_16BIT (1 << 6) /* KSZ8851-16MLL */ | ||
| 19 | #define CCR_32BIT (1 << 5) /* KSZ8851-16MLL */ | ||
| 20 | #define CCR_SHARED (1 << 4) /* KSZ8851-16MLL */ | ||
| 21 | #define CCR_48PIN (1 << 1) /* KSZ8851-16MLL */ | ||
| 22 | #define CCR_32PIN (1 << 0) /* KSZ8851SNL */ | ||
| 17 | 23 | ||
| 18 | /* MAC address registers */ | 24 | /* MAC address registers */ |
| 19 | #define KS_MAR(_m) (0x15 - (_m)) | 25 | #define KS_MAR(_m) (0x15 - (_m)) |
| @@ -112,13 +118,13 @@ | |||
| 112 | #define RXCR1_RXE (1 << 0) | 118 | #define RXCR1_RXE (1 << 0) |
| 113 | 119 | ||
| 114 | #define KS_RXCR2 0x76 | 120 | #define KS_RXCR2 0x76 |
| 115 | #define RXCR2_SRDBL_MASK (0x7 << 5) | 121 | #define RXCR2_SRDBL_MASK (0x7 << 5) /* KSZ8851SNL */ |
| 116 | #define RXCR2_SRDBL_SHIFT (5) | 122 | #define RXCR2_SRDBL_SHIFT (5) /* KSZ8851SNL */ |
| 117 | #define RXCR2_SRDBL_4B (0x0 << 5) | 123 | #define RXCR2_SRDBL_4B (0x0 << 5) /* KSZ8851SNL */ |
| 118 | #define RXCR2_SRDBL_8B (0x1 << 5) | 124 | #define RXCR2_SRDBL_8B (0x1 << 5) /* KSZ8851SNL */ |
| 119 | #define RXCR2_SRDBL_16B (0x2 << 5) | 125 | #define RXCR2_SRDBL_16B (0x2 << 5) /* KSZ8851SNL */ |
| 120 | #define RXCR2_SRDBL_32B (0x3 << 5) | 126 | #define RXCR2_SRDBL_32B (0x3 << 5) /* KSZ8851SNL */ |
| 121 | #define RXCR2_SRDBL_FRAME (0x4 << 5) | 127 | #define RXCR2_SRDBL_FRAME (0x4 << 5) /* KSZ8851SNL */ |
| 122 | #define RXCR2_IUFFP (1 << 4) | 128 | #define RXCR2_IUFFP (1 << 4) |
| 123 | #define RXCR2_RXIUFCEZ (1 << 3) | 129 | #define RXCR2_RXIUFCEZ (1 << 3) |
| 124 | #define RXCR2_UDPLFE (1 << 2) | 130 | #define RXCR2_UDPLFE (1 << 2) |
| @@ -143,8 +149,10 @@ | |||
| 143 | #define RXFSHR_RXCE (1 << 0) | 149 | #define RXFSHR_RXCE (1 << 0) |
| 144 | 150 | ||
| 145 | #define KS_RXFHBCR 0x7E | 151 | #define KS_RXFHBCR 0x7E |
| 152 | #define RXFHBCR_CNT_MASK (0xfff << 0) | ||
| 153 | |||
| 146 | #define KS_TXQCR 0x80 | 154 | #define KS_TXQCR 0x80 |
| 147 | #define TXQCR_AETFE (1 << 2) | 155 | #define TXQCR_AETFE (1 << 2) /* KSZ8851SNL */ |
| 148 | #define TXQCR_TXQMAM (1 << 1) | 156 | #define TXQCR_TXQMAM (1 << 1) |
| 149 | #define TXQCR_METFE (1 << 0) | 157 | #define TXQCR_METFE (1 << 0) |
| 150 | 158 | ||
| @@ -167,6 +175,10 @@ | |||
| 167 | 175 | ||
| 168 | #define KS_RXFDPR 0x86 | 176 | #define KS_RXFDPR 0x86 |
| 169 | #define RXFDPR_RXFPAI (1 << 14) | 177 | #define RXFDPR_RXFPAI (1 << 14) |
| 178 | #define RXFDPR_WST (1 << 12) /* KSZ8851-16MLL */ | ||
| 179 | #define RXFDPR_EMS (1 << 11) /* KSZ8851-16MLL */ | ||
| 180 | #define RXFDPR_RXFP_MASK (0x7ff << 0) | ||
| 181 | #define RXFDPR_RXFP_SHIFT (0) | ||
| 170 | 182 | ||
| 171 | #define KS_RXDTTR 0x8C | 183 | #define KS_RXDTTR 0x8C |
| 172 | #define KS_RXDBCTR 0x8E | 184 | #define KS_RXDBCTR 0x8E |
| @@ -184,7 +196,7 @@ | |||
| 184 | #define IRQ_RXMPDI (1 << 4) | 196 | #define IRQ_RXMPDI (1 << 4) |
| 185 | #define IRQ_LDI (1 << 3) | 197 | #define IRQ_LDI (1 << 3) |
| 186 | #define IRQ_EDI (1 << 2) | 198 | #define IRQ_EDI (1 << 2) |
| 187 | #define IRQ_SPIBEI (1 << 1) | 199 | #define IRQ_SPIBEI (1 << 1) /* KSZ8851SNL */ |
| 188 | #define IRQ_DEDI (1 << 0) | 200 | #define IRQ_DEDI (1 << 0) |
| 189 | 201 | ||
| 190 | #define KS_RXFCTR 0x9C | 202 | #define KS_RXFCTR 0x9C |
| @@ -257,42 +269,37 @@ | |||
| 257 | #define KS_P1ANLPR 0xEE | 269 | #define KS_P1ANLPR 0xEE |
| 258 | 270 | ||
| 259 | #define KS_P1SCLMD 0xF4 | 271 | #define KS_P1SCLMD 0xF4 |
| 260 | #define P1SCLMD_LEDOFF (1 << 15) | ||
| 261 | #define P1SCLMD_TXIDS (1 << 14) | ||
| 262 | #define P1SCLMD_RESTARTAN (1 << 13) | ||
| 263 | #define P1SCLMD_DISAUTOMDIX (1 << 10) | ||
| 264 | #define P1SCLMD_FORCEMDIX (1 << 9) | ||
| 265 | #define P1SCLMD_AUTONEGEN (1 << 7) | ||
| 266 | #define P1SCLMD_FORCE100 (1 << 6) | ||
| 267 | #define P1SCLMD_FORCEFDX (1 << 5) | ||
| 268 | #define P1SCLMD_ADV_FLOW (1 << 4) | ||
| 269 | #define P1SCLMD_ADV_100BT_FDX (1 << 3) | ||
| 270 | #define P1SCLMD_ADV_100BT_HDX (1 << 2) | ||
| 271 | #define P1SCLMD_ADV_10BT_FDX (1 << 1) | ||
| 272 | #define P1SCLMD_ADV_10BT_HDX (1 << 0) | ||
| 273 | 272 | ||
| 274 | #define KS_P1CR 0xF6 | 273 | #define KS_P1CR 0xF6 |
| 275 | #define P1CR_HP_MDIX (1 << 15) | 274 | #define P1CR_LEDOFF (1 << 15) |
| 276 | #define P1CR_REV_POL (1 << 13) | 275 | #define P1CR_TXIDS (1 << 14) |
| 277 | #define P1CR_OP_100M (1 << 10) | 276 | #define P1CR_RESTARTAN (1 << 13) |
| 278 | #define P1CR_OP_FDX (1 << 9) | 277 | #define P1CR_DISAUTOMDIX (1 << 10) |
| 279 | #define P1CR_OP_MDI (1 << 7) | 278 | #define P1CR_FORCEMDIX (1 << 9) |
| 280 | #define P1CR_AN_DONE (1 << 6) | 279 | #define P1CR_AUTONEGEN (1 << 7) |
| 281 | #define P1CR_LINK_GOOD (1 << 5) | 280 | #define P1CR_FORCE100 (1 << 6) |
| 282 | #define P1CR_PNTR_FLOW (1 << 4) | 281 | #define P1CR_FORCEFDX (1 << 5) |
| 283 | #define P1CR_PNTR_100BT_FDX (1 << 3) | 282 | #define P1CR_ADV_FLOW (1 << 4) |
| 284 | #define P1CR_PNTR_100BT_HDX (1 << 2) | 283 | #define P1CR_ADV_100BT_FDX (1 << 3) |
| 285 | #define P1CR_PNTR_10BT_FDX (1 << 1) | 284 | #define P1CR_ADV_100BT_HDX (1 << 2) |
| 286 | #define P1CR_PNTR_10BT_HDX (1 << 0) | 285 | #define P1CR_ADV_10BT_FDX (1 << 1) |
| 286 | #define P1CR_ADV_10BT_HDX (1 << 0) | ||
| 287 | |||
| 288 | #define KS_P1SR 0xF8 | ||
| 289 | #define P1SR_HP_MDIX (1 << 15) | ||
| 290 | #define P1SR_REV_POL (1 << 13) | ||
| 291 | #define P1SR_OP_100M (1 << 10) | ||
| 292 | #define P1SR_OP_FDX (1 << 9) | ||
| 293 | #define P1SR_OP_MDI (1 << 7) | ||
| 294 | #define P1SR_AN_DONE (1 << 6) | ||
| 295 | #define P1SR_LINK_GOOD (1 << 5) | ||
| 296 | #define P1SR_PNTR_FLOW (1 << 4) | ||
| 297 | #define P1SR_PNTR_100BT_FDX (1 << 3) | ||
| 298 | #define P1SR_PNTR_100BT_HDX (1 << 2) | ||
| 299 | #define P1SR_PNTR_10BT_FDX (1 << 1) | ||
| 300 | #define P1SR_PNTR_10BT_HDX (1 << 0) | ||
| 287 | 301 | ||
| 288 | /* TX Frame control */ | 302 | /* TX Frame control */ |
| 289 | |||
| 290 | #define TXFR_TXIC (1 << 15) | 303 | #define TXFR_TXIC (1 << 15) |
| 291 | #define TXFR_TXFID_MASK (0x3f << 0) | 304 | #define TXFR_TXFID_MASK (0x3f << 0) |
| 292 | #define TXFR_TXFID_SHIFT (0) | 305 | #define TXFR_TXFID_SHIFT (0) |
| 293 | |||
| 294 | /* SPI frame opcodes */ | ||
| 295 | #define KS_SPIOP_RD (0x00) | ||
| 296 | #define KS_SPIOP_WR (0x40) | ||
| 297 | #define KS_SPIOP_RXFIFO (0x80) | ||
| 298 | #define KS_SPIOP_TXFIFO (0xC0) | ||
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c index 35f8c9ef204d..c946841c0a06 100644 --- a/drivers/net/ethernet/micrel/ks8851_mll.c +++ b/drivers/net/ethernet/micrel/ks8851_mll.c | |||
| @@ -40,6 +40,8 @@ | |||
| 40 | #include <linux/of_device.h> | 40 | #include <linux/of_device.h> |
| 41 | #include <linux/of_net.h> | 41 | #include <linux/of_net.h> |
| 42 | 42 | ||
| 43 | #include "ks8851.h" | ||
| 44 | |||
| 43 | #define DRV_NAME "ks8851_mll" | 45 | #define DRV_NAME "ks8851_mll" |
| 44 | 46 | ||
| 45 | static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 }; | 47 | static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 }; |
| @@ -48,319 +50,10 @@ static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 }; | |||
| 48 | #define TX_BUF_SIZE 2000 | 50 | #define TX_BUF_SIZE 2000 |
| 49 | #define RX_BUF_SIZE 2000 | 51 | #define RX_BUF_SIZE 2000 |
| 50 | 52 | ||
| 51 | #define KS_CCR 0x08 | ||
| 52 | #define CCR_EEPROM (1 << 9) | ||
| 53 | #define CCR_SPI (1 << 8) | ||
| 54 | #define CCR_8BIT (1 << 7) | ||
| 55 | #define CCR_16BIT (1 << 6) | ||
| 56 | #define CCR_32BIT (1 << 5) | ||
| 57 | #define CCR_SHARED (1 << 4) | ||
| 58 | #define CCR_32PIN (1 << 0) | ||
| 59 | |||
| 60 | /* MAC address registers */ | ||
| 61 | #define KS_MARL 0x10 | ||
| 62 | #define KS_MARM 0x12 | ||
| 63 | #define KS_MARH 0x14 | ||
| 64 | |||
| 65 | #define KS_OBCR 0x20 | ||
| 66 | #define OBCR_ODS_16MA (1 << 6) | ||
| 67 | |||
| 68 | #define KS_EEPCR 0x22 | ||
| 69 | #define EEPCR_EESA (1 << 4) | ||
| 70 | #define EEPCR_EESB (1 << 3) | ||
| 71 | #define EEPCR_EEDO (1 << 2) | ||
| 72 | #define EEPCR_EESCK (1 << 1) | ||
| 73 | #define EEPCR_EECS (1 << 0) | ||
| 74 | |||
| 75 | #define KS_MBIR 0x24 | ||
| 76 | #define MBIR_TXMBF (1 << 12) | ||
| 77 | #define MBIR_TXMBFA (1 << 11) | ||
| 78 | #define MBIR_RXMBF (1 << 4) | ||
| 79 | #define MBIR_RXMBFA (1 << 3) | ||
| 80 | |||
| 81 | #define KS_GRR 0x26 | ||
| 82 | #define GRR_QMU (1 << 1) | ||
| 83 | #define GRR_GSR (1 << 0) | ||
| 84 | |||
| 85 | #define KS_WFCR 0x2A | ||
| 86 | #define WFCR_MPRXE (1 << 7) | ||
| 87 | #define WFCR_WF3E (1 << 3) | ||
| 88 | #define WFCR_WF2E (1 << 2) | ||
| 89 | #define WFCR_WF1E (1 << 1) | ||
| 90 | #define WFCR_WF0E (1 << 0) | ||
| 91 | |||
| 92 | #define KS_WF0CRC0 0x30 | ||
| 93 | #define KS_WF0CRC1 0x32 | ||
| 94 | #define KS_WF0BM0 0x34 | ||
| 95 | #define KS_WF0BM1 0x36 | ||
| 96 | #define KS_WF0BM2 0x38 | ||
| 97 | #define KS_WF0BM3 0x3A | ||
| 98 | |||
| 99 | #define KS_WF1CRC0 0x40 | ||
| 100 | #define KS_WF1CRC1 0x42 | ||
| 101 | #define KS_WF1BM0 0x44 | ||
| 102 | #define KS_WF1BM1 0x46 | ||
| 103 | #define KS_WF1BM2 0x48 | ||
| 104 | #define KS_WF1BM3 0x4A | ||
| 105 | |||
| 106 | #define KS_WF2CRC0 0x50 | ||
| 107 | #define KS_WF2CRC1 0x52 | ||
| 108 | #define KS_WF2BM0 0x54 | ||
| 109 | #define KS_WF2BM1 0x56 | ||
| 110 | #define KS_WF2BM2 0x58 | ||
| 111 | #define KS_WF2BM3 0x5A | ||
| 112 | |||
| 113 | #define KS_WF3CRC0 0x60 | ||
| 114 | #define KS_WF3CRC1 0x62 | ||
| 115 | #define KS_WF3BM0 0x64 | ||
| 116 | #define KS_WF3BM1 0x66 | ||
| 117 | #define KS_WF3BM2 0x68 | ||
| 118 | #define KS_WF3BM3 0x6A | ||
| 119 | |||
| 120 | #define KS_TXCR 0x70 | ||
| 121 | #define TXCR_TCGICMP (1 << 8) | ||
| 122 | #define TXCR_TCGUDP (1 << 7) | ||
| 123 | #define TXCR_TCGTCP (1 << 6) | ||
| 124 | #define TXCR_TCGIP (1 << 5) | ||
| 125 | #define TXCR_FTXQ (1 << 4) | ||
| 126 | #define TXCR_TXFCE (1 << 3) | ||
| 127 | #define TXCR_TXPE (1 << 2) | ||
| 128 | #define TXCR_TXCRC (1 << 1) | ||
| 129 | #define TXCR_TXE (1 << 0) | ||
| 130 | |||
| 131 | #define KS_TXSR 0x72 | ||
| 132 | #define TXSR_TXLC (1 << 13) | ||
| 133 | #define TXSR_TXMC (1 << 12) | ||
| 134 | #define TXSR_TXFID_MASK (0x3f << 0) | ||
| 135 | #define TXSR_TXFID_SHIFT (0) | ||
| 136 | #define TXSR_TXFID_GET(_v) (((_v) >> 0) & 0x3f) | ||
| 137 | |||
| 138 | |||
| 139 | #define KS_RXCR1 0x74 | ||
| 140 | #define RXCR1_FRXQ (1 << 15) | ||
| 141 | #define RXCR1_RXUDPFCC (1 << 14) | ||
| 142 | #define RXCR1_RXTCPFCC (1 << 13) | ||
| 143 | #define RXCR1_RXIPFCC (1 << 12) | ||
| 144 | #define RXCR1_RXPAFMA (1 << 11) | ||
| 145 | #define RXCR1_RXFCE (1 << 10) | ||
| 146 | #define RXCR1_RXEFE (1 << 9) | ||
| 147 | #define RXCR1_RXMAFMA (1 << 8) | ||
| 148 | #define RXCR1_RXBE (1 << 7) | ||
| 149 | #define RXCR1_RXME (1 << 6) | ||
| 150 | #define RXCR1_RXUE (1 << 5) | ||
| 151 | #define RXCR1_RXAE (1 << 4) | ||
| 152 | #define RXCR1_RXINVF (1 << 1) | ||
| 153 | #define RXCR1_RXE (1 << 0) | ||
| 154 | #define RXCR1_FILTER_MASK (RXCR1_RXINVF | RXCR1_RXAE | \ | 53 | #define RXCR1_FILTER_MASK (RXCR1_RXINVF | RXCR1_RXAE | \ |
| 155 | RXCR1_RXMAFMA | RXCR1_RXPAFMA) | 54 | RXCR1_RXMAFMA | RXCR1_RXPAFMA) |
| 156 | |||
| 157 | #define KS_RXCR2 0x76 | ||
| 158 | #define RXCR2_SRDBL_MASK (0x7 << 5) | ||
| 159 | #define RXCR2_SRDBL_SHIFT (5) | ||
| 160 | #define RXCR2_SRDBL_4B (0x0 << 5) | ||
| 161 | #define RXCR2_SRDBL_8B (0x1 << 5) | ||
| 162 | #define RXCR2_SRDBL_16B (0x2 << 5) | ||
| 163 | #define RXCR2_SRDBL_32B (0x3 << 5) | ||
| 164 | /* #define RXCR2_SRDBL_FRAME (0x4 << 5) */ | ||
| 165 | #define RXCR2_IUFFP (1 << 4) | ||
| 166 | #define RXCR2_RXIUFCEZ (1 << 3) | ||
| 167 | #define RXCR2_UDPLFE (1 << 2) | ||
| 168 | #define RXCR2_RXICMPFCC (1 << 1) | ||
| 169 | #define RXCR2_RXSAF (1 << 0) | ||
| 170 | |||
| 171 | #define KS_TXMIR 0x78 | ||
| 172 | |||
| 173 | #define KS_RXFHSR 0x7C | ||
| 174 | #define RXFSHR_RXFV (1 << 15) | ||
| 175 | #define RXFSHR_RXICMPFCS (1 << 13) | ||
| 176 | #define RXFSHR_RXIPFCS (1 << 12) | ||
| 177 | #define RXFSHR_RXTCPFCS (1 << 11) | ||
| 178 | #define RXFSHR_RXUDPFCS (1 << 10) | ||
| 179 | #define RXFSHR_RXBF (1 << 7) | ||
| 180 | #define RXFSHR_RXMF (1 << 6) | ||
| 181 | #define RXFSHR_RXUF (1 << 5) | ||
| 182 | #define RXFSHR_RXMR (1 << 4) | ||
| 183 | #define RXFSHR_RXFT (1 << 3) | ||
| 184 | #define RXFSHR_RXFTL (1 << 2) | ||
| 185 | #define RXFSHR_RXRF (1 << 1) | ||
| 186 | #define RXFSHR_RXCE (1 << 0) | ||
| 187 | #define RXFSHR_ERR (RXFSHR_RXCE | RXFSHR_RXRF |\ | ||
| 188 | RXFSHR_RXFTL | RXFSHR_RXMR |\ | ||
| 189 | RXFSHR_RXICMPFCS | RXFSHR_RXIPFCS |\ | ||
| 190 | RXFSHR_RXTCPFCS) | ||
| 191 | #define KS_RXFHBCR 0x7E | ||
| 192 | #define RXFHBCR_CNT_MASK 0x0FFF | ||
| 193 | |||
| 194 | #define KS_TXQCR 0x80 | ||
| 195 | #define TXQCR_AETFE (1 << 2) | ||
| 196 | #define TXQCR_TXQMAM (1 << 1) | ||
| 197 | #define TXQCR_METFE (1 << 0) | ||
| 198 | |||
| 199 | #define KS_RXQCR 0x82 | ||
| 200 | #define RXQCR_RXDTTS (1 << 12) | ||
| 201 | #define RXQCR_RXDBCTS (1 << 11) | ||
| 202 | #define RXQCR_RXFCTS (1 << 10) | ||
| 203 | #define RXQCR_RXIPHTOE (1 << 9) | ||
| 204 | #define RXQCR_RXDTTE (1 << 7) | ||
| 205 | #define RXQCR_RXDBCTE (1 << 6) | ||
| 206 | #define RXQCR_RXFCTE (1 << 5) | ||
| 207 | #define RXQCR_ADRFE (1 << 4) | ||
| 208 | #define RXQCR_SDA (1 << 3) | ||
| 209 | #define RXQCR_RRXEF (1 << 0) | ||
| 210 | #define RXQCR_CMD_CNTL (RXQCR_RXFCTE|RXQCR_ADRFE) | 55 | #define RXQCR_CMD_CNTL (RXQCR_RXFCTE|RXQCR_ADRFE) |
| 211 | 56 | ||
| 212 | #define KS_TXFDPR 0x84 | ||
| 213 | #define TXFDPR_TXFPAI (1 << 14) | ||
| 214 | #define TXFDPR_TXFP_MASK (0x7ff << 0) | ||
| 215 | #define TXFDPR_TXFP_SHIFT (0) | ||
| 216 | |||
| 217 | #define KS_RXFDPR 0x86 | ||
| 218 | #define RXFDPR_RXFPAI (1 << 14) | ||
| 219 | |||
| 220 | #define KS_RXDTTR 0x8C | ||
| 221 | #define KS_RXDBCTR 0x8E | ||
| 222 | |||
| 223 | #define KS_IER 0x90 | ||
| 224 | #define KS_ISR 0x92 | ||
| 225 | #define IRQ_LCI (1 << 15) | ||
| 226 | #define IRQ_TXI (1 << 14) | ||
| 227 | #define IRQ_RXI (1 << 13) | ||
| 228 | #define IRQ_RXOI (1 << 11) | ||
| 229 | #define IRQ_TXPSI (1 << 9) | ||
| 230 | #define IRQ_RXPSI (1 << 8) | ||
| 231 | #define IRQ_TXSAI (1 << 6) | ||
| 232 | #define IRQ_RXWFDI (1 << 5) | ||
| 233 | #define IRQ_RXMPDI (1 << 4) | ||
| 234 | #define IRQ_LDI (1 << 3) | ||
| 235 | #define IRQ_EDI (1 << 2) | ||
| 236 | #define IRQ_SPIBEI (1 << 1) | ||
| 237 | #define IRQ_DEDI (1 << 0) | ||
| 238 | |||
| 239 | #define KS_RXFCTR 0x9C | ||
| 240 | #define RXFCTR_THRESHOLD_MASK 0x00FF | ||
| 241 | |||
| 242 | #define KS_RXFC 0x9D | ||
| 243 | #define RXFCTR_RXFC_MASK (0xff << 8) | ||
| 244 | #define RXFCTR_RXFC_SHIFT (8) | ||
| 245 | #define RXFCTR_RXFC_GET(_v) (((_v) >> 8) & 0xff) | ||
| 246 | #define RXFCTR_RXFCT_MASK (0xff << 0) | ||
| 247 | #define RXFCTR_RXFCT_SHIFT (0) | ||
| 248 | |||
| 249 | #define KS_TXNTFSR 0x9E | ||
| 250 | |||
| 251 | #define KS_MAHTR0 0xA0 | ||
| 252 | #define KS_MAHTR1 0xA2 | ||
| 253 | #define KS_MAHTR2 0xA4 | ||
| 254 | #define KS_MAHTR3 0xA6 | ||
| 255 | |||
| 256 | #define KS_FCLWR 0xB0 | ||
| 257 | #define KS_FCHWR 0xB2 | ||
| 258 | #define KS_FCOWR 0xB4 | ||
| 259 | |||
| 260 | #define KS_CIDER 0xC0 | ||
| 261 | #define CIDER_ID 0x8870 | ||
| 262 | #define CIDER_REV_MASK (0x7 << 1) | ||
| 263 | #define CIDER_REV_SHIFT (1) | ||
| 264 | #define CIDER_REV_GET(_v) (((_v) >> 1) & 0x7) | ||
| 265 | |||
| 266 | #define KS_CGCR 0xC6 | ||
| 267 | #define KS_IACR 0xC8 | ||
| 268 | #define IACR_RDEN (1 << 12) | ||
| 269 | #define IACR_TSEL_MASK (0x3 << 10) | ||
| 270 | #define IACR_TSEL_SHIFT (10) | ||
| 271 | #define IACR_TSEL_MIB (0x3 << 10) | ||
| 272 | #define IACR_ADDR_MASK (0x1f << 0) | ||
| 273 | #define IACR_ADDR_SHIFT (0) | ||
| 274 | |||
| 275 | #define KS_IADLR 0xD0 | ||
| 276 | #define KS_IAHDR 0xD2 | ||
| 277 | |||
| 278 | #define KS_PMECR 0xD4 | ||
| 279 | #define PMECR_PME_DELAY (1 << 14) | ||
| 280 | #define PMECR_PME_POL (1 << 12) | ||
| 281 | #define PMECR_WOL_WAKEUP (1 << 11) | ||
| 282 | #define PMECR_WOL_MAGICPKT (1 << 10) | ||
| 283 | #define PMECR_WOL_LINKUP (1 << 9) | ||
| 284 | #define PMECR_WOL_ENERGY (1 << 8) | ||
| 285 | #define PMECR_AUTO_WAKE_EN (1 << 7) | ||
| 286 | #define PMECR_WAKEUP_NORMAL (1 << 6) | ||
| 287 | #define PMECR_WKEVT_MASK (0xf << 2) | ||
| 288 | #define PMECR_WKEVT_SHIFT (2) | ||
| 289 | #define PMECR_WKEVT_GET(_v) (((_v) >> 2) & 0xf) | ||
| 290 | #define PMECR_WKEVT_ENERGY (0x1 << 2) | ||
| 291 | #define PMECR_WKEVT_LINK (0x2 << 2) | ||
| 292 | #define PMECR_WKEVT_MAGICPKT (0x4 << 2) | ||
| 293 | #define PMECR_WKEVT_FRAME (0x8 << 2) | ||
| 294 | #define PMECR_PM_MASK (0x3 << 0) | ||
| 295 | #define PMECR_PM_SHIFT (0) | ||
| 296 | #define PMECR_PM_NORMAL (0x0 << 0) | ||
| 297 | #define PMECR_PM_ENERGY (0x1 << 0) | ||
| 298 | #define PMECR_PM_SOFTDOWN (0x2 << 0) | ||
| 299 | #define PMECR_PM_POWERSAVE (0x3 << 0) | ||
| 300 | |||
| 301 | /* Standard MII PHY data */ | ||
| 302 | #define KS_P1MBCR 0xE4 | ||
| 303 | #define P1MBCR_FORCE_FDX (1 << 8) | ||
| 304 | |||
| 305 | #define KS_P1MBSR 0xE6 | ||
| 306 | #define P1MBSR_AN_COMPLETE (1 << 5) | ||
| 307 | #define P1MBSR_AN_CAPABLE (1 << 3) | ||
| 308 | #define P1MBSR_LINK_UP (1 << 2) | ||
| 309 | |||
| 310 | #define KS_PHY1ILR 0xE8 | ||
| 311 | #define KS_PHY1IHR 0xEA | ||
| 312 | #define KS_P1ANAR 0xEC | ||
| 313 | #define KS_P1ANLPR 0xEE | ||
| 314 | |||
| 315 | #define KS_P1SCLMD 0xF4 | ||
| 316 | #define P1SCLMD_LEDOFF (1 << 15) | ||
| 317 | #define P1SCLMD_TXIDS (1 << 14) | ||
| 318 | #define P1SCLMD_RESTARTAN (1 << 13) | ||
| 319 | #define P1SCLMD_DISAUTOMDIX (1 << 10) | ||
| 320 | #define P1SCLMD_FORCEMDIX (1 << 9) | ||
| 321 | #define P1SCLMD_AUTONEGEN (1 << 7) | ||
| 322 | #define P1SCLMD_FORCE100 (1 << 6) | ||
| 323 | #define P1SCLMD_FORCEFDX (1 << 5) | ||
| 324 | #define P1SCLMD_ADV_FLOW (1 << 4) | ||
| 325 | #define P1SCLMD_ADV_100BT_FDX (1 << 3) | ||
| 326 | #define P1SCLMD_ADV_100BT_HDX (1 << 2) | ||
| 327 | #define P1SCLMD_ADV_10BT_FDX (1 << 1) | ||
| 328 | #define P1SCLMD_ADV_10BT_HDX (1 << 0) | ||
| 329 | |||
| 330 | #define KS_P1CR 0xF6 | ||
| 331 | #define P1CR_HP_MDIX (1 << 15) | ||
| 332 | #define P1CR_REV_POL (1 << 13) | ||
| 333 | #define P1CR_OP_100M (1 << 10) | ||
| 334 | #define P1CR_OP_FDX (1 << 9) | ||
| 335 | #define P1CR_OP_MDI (1 << 7) | ||
| 336 | #define P1CR_AN_DONE (1 << 6) | ||
| 337 | #define P1CR_LINK_GOOD (1 << 5) | ||
| 338 | #define P1CR_PNTR_FLOW (1 << 4) | ||
| 339 | #define P1CR_PNTR_100BT_FDX (1 << 3) | ||
| 340 | #define P1CR_PNTR_100BT_HDX (1 << 2) | ||
| 341 | #define P1CR_PNTR_10BT_FDX (1 << 1) | ||
| 342 | #define P1CR_PNTR_10BT_HDX (1 << 0) | ||
| 343 | |||
| 344 | /* TX Frame control */ | ||
| 345 | |||
| 346 | #define TXFR_TXIC (1 << 15) | ||
| 347 | #define TXFR_TXFID_MASK (0x3f << 0) | ||
| 348 | #define TXFR_TXFID_SHIFT (0) | ||
| 349 | |||
| 350 | #define KS_P1SR 0xF8 | ||
| 351 | #define P1SR_HP_MDIX (1 << 15) | ||
| 352 | #define P1SR_REV_POL (1 << 13) | ||
| 353 | #define P1SR_OP_100M (1 << 10) | ||
| 354 | #define P1SR_OP_FDX (1 << 9) | ||
| 355 | #define P1SR_OP_MDI (1 << 7) | ||
| 356 | #define P1SR_AN_DONE (1 << 6) | ||
| 357 | #define P1SR_LINK_GOOD (1 << 5) | ||
| 358 | #define P1SR_PNTR_FLOW (1 << 4) | ||
| 359 | #define P1SR_PNTR_100BT_FDX (1 << 3) | ||
| 360 | #define P1SR_PNTR_100BT_HDX (1 << 2) | ||
| 361 | #define P1SR_PNTR_10BT_FDX (1 << 1) | ||
| 362 | #define P1SR_PNTR_10BT_HDX (1 << 0) | ||
| 363 | |||
| 364 | #define ENUM_BUS_NONE 0 | 57 | #define ENUM_BUS_NONE 0 |
| 365 | #define ENUM_BUS_8BIT 1 | 58 | #define ENUM_BUS_8BIT 1 |
| 366 | #define ENUM_BUS_16BIT 2 | 59 | #define ENUM_BUS_16BIT 2 |
| @@ -1475,7 +1168,7 @@ static void ks_setup(struct ks_net *ks) | |||
| 1475 | ks_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI); | 1168 | ks_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI); |
| 1476 | 1169 | ||
| 1477 | /* Setup Receive Frame Threshold - 1 frame (RXFCTFC) */ | 1170 | /* Setup Receive Frame Threshold - 1 frame (RXFCTFC) */ |
| 1478 | ks_wrreg16(ks, KS_RXFCTR, 1 & RXFCTR_THRESHOLD_MASK); | 1171 | ks_wrreg16(ks, KS_RXFCTR, 1 & RXFCTR_RXFCT_MASK); |
| 1479 | 1172 | ||
| 1480 | /* Setup RxQ Command Control (RXQCR) */ | 1173 | /* Setup RxQ Command Control (RXQCR) */ |
| 1481 | ks->rc_rxqcr = RXQCR_CMD_CNTL; | 1174 | ks->rc_rxqcr = RXQCR_CMD_CNTL; |
| @@ -1488,7 +1181,7 @@ static void ks_setup(struct ks_net *ks) | |||
| 1488 | */ | 1181 | */ |
| 1489 | 1182 | ||
| 1490 | w = ks_rdreg16(ks, KS_P1MBCR); | 1183 | w = ks_rdreg16(ks, KS_P1MBCR); |
| 1491 | w &= ~P1MBCR_FORCE_FDX; | 1184 | w &= ~BMCR_FULLDPLX; |
| 1492 | ks_wrreg16(ks, KS_P1MBCR, w); | 1185 | ks_wrreg16(ks, KS_P1MBCR, w); |
| 1493 | 1186 | ||
| 1494 | w = TXCR_TXFCE | TXCR_TXPE | TXCR_TXCRC | TXCR_TCGIP; | 1187 | w = TXCR_TXFCE | TXCR_TXPE | TXCR_TXCRC | TXCR_TCGIP; |
| @@ -1629,7 +1322,7 @@ static int ks8851_probe(struct platform_device *pdev) | |||
| 1629 | ks_setup_int(ks); | 1322 | ks_setup_int(ks); |
| 1630 | 1323 | ||
| 1631 | data = ks_rdreg16(ks, KS_OBCR); | 1324 | data = ks_rdreg16(ks, KS_OBCR); |
| 1632 | ks_wrreg16(ks, KS_OBCR, data | OBCR_ODS_16MA); | 1325 | ks_wrreg16(ks, KS_OBCR, data | OBCR_ODS_16mA); |
| 1633 | 1326 | ||
| 1634 | /* overwriting the default MAC address */ | 1327 | /* overwriting the default MAC address */ |
| 1635 | if (pdev->dev.of_node) { | 1328 | if (pdev->dev.of_node) { |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index 3b0adda7cc9c..a4cd6f2cfb86 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | |||
| @@ -1048,6 +1048,8 @@ int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode) | |||
| 1048 | 1048 | ||
| 1049 | for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { | 1049 | for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { |
| 1050 | skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); | 1050 | skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); |
| 1051 | if (!skb) | ||
| 1052 | break; | ||
| 1051 | qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); | 1053 | qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); |
| 1052 | skb_put(skb, QLCNIC_ILB_PKT_SIZE); | 1054 | skb_put(skb, QLCNIC_ILB_PKT_SIZE); |
| 1053 | adapter->ahw->diag_cnt = 0; | 1055 | adapter->ahw->diag_cnt = 0; |
diff --git a/drivers/net/ethernet/realtek/atp.c b/drivers/net/ethernet/realtek/atp.c index cfb67b746595..58e0ca9093d3 100644 --- a/drivers/net/ethernet/realtek/atp.c +++ b/drivers/net/ethernet/realtek/atp.c | |||
| @@ -482,7 +482,7 @@ static void hardware_init(struct net_device *dev) | |||
| 482 | write_reg_high(ioaddr, IMR, ISRh_RxErr); | 482 | write_reg_high(ioaddr, IMR, ISRh_RxErr); |
| 483 | 483 | ||
| 484 | lp->tx_unit_busy = 0; | 484 | lp->tx_unit_busy = 0; |
| 485 | lp->pac_cnt_in_tx_buf = 0; | 485 | lp->pac_cnt_in_tx_buf = 0; |
| 486 | lp->saved_tx_size = 0; | 486 | lp->saved_tx_size = 0; |
| 487 | } | 487 | } |
| 488 | 488 | ||
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index c29dde064078..7562ccbbb39a 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
| @@ -678,6 +678,7 @@ struct rtl8169_private { | |||
| 678 | struct work_struct work; | 678 | struct work_struct work; |
| 679 | } wk; | 679 | } wk; |
| 680 | 680 | ||
| 681 | unsigned irq_enabled:1; | ||
| 681 | unsigned supports_gmii:1; | 682 | unsigned supports_gmii:1; |
| 682 | dma_addr_t counters_phys_addr; | 683 | dma_addr_t counters_phys_addr; |
| 683 | struct rtl8169_counters *counters; | 684 | struct rtl8169_counters *counters; |
| @@ -1293,6 +1294,7 @@ static void rtl_ack_events(struct rtl8169_private *tp, u16 bits) | |||
| 1293 | static void rtl_irq_disable(struct rtl8169_private *tp) | 1294 | static void rtl_irq_disable(struct rtl8169_private *tp) |
| 1294 | { | 1295 | { |
| 1295 | RTL_W16(tp, IntrMask, 0); | 1296 | RTL_W16(tp, IntrMask, 0); |
| 1297 | tp->irq_enabled = 0; | ||
| 1296 | } | 1298 | } |
| 1297 | 1299 | ||
| 1298 | #define RTL_EVENT_NAPI_RX (RxOK | RxErr) | 1300 | #define RTL_EVENT_NAPI_RX (RxOK | RxErr) |
| @@ -1301,6 +1303,7 @@ static void rtl_irq_disable(struct rtl8169_private *tp) | |||
| 1301 | 1303 | ||
| 1302 | static void rtl_irq_enable(struct rtl8169_private *tp) | 1304 | static void rtl_irq_enable(struct rtl8169_private *tp) |
| 1303 | { | 1305 | { |
| 1306 | tp->irq_enabled = 1; | ||
| 1304 | RTL_W16(tp, IntrMask, tp->irq_mask); | 1307 | RTL_W16(tp, IntrMask, tp->irq_mask); |
| 1305 | } | 1308 | } |
| 1306 | 1309 | ||
| @@ -6520,9 +6523,8 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) | |||
| 6520 | { | 6523 | { |
| 6521 | struct rtl8169_private *tp = dev_instance; | 6524 | struct rtl8169_private *tp = dev_instance; |
| 6522 | u16 status = RTL_R16(tp, IntrStatus); | 6525 | u16 status = RTL_R16(tp, IntrStatus); |
| 6523 | u16 irq_mask = RTL_R16(tp, IntrMask); | ||
| 6524 | 6526 | ||
| 6525 | if (status == 0xffff || !(status & irq_mask)) | 6527 | if (!tp->irq_enabled || status == 0xffff || !(status & tp->irq_mask)) |
| 6526 | return IRQ_NONE; | 6528 | return IRQ_NONE; |
| 6527 | 6529 | ||
| 6528 | if (unlikely(status & SYSErr)) { | 6530 | if (unlikely(status & SYSErr)) { |
| @@ -6540,7 +6542,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) | |||
| 6540 | set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags); | 6542 | set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags); |
| 6541 | } | 6543 | } |
| 6542 | 6544 | ||
| 6543 | if (status & RTL_EVENT_NAPI) { | 6545 | if (status & (RTL_EVENT_NAPI | LinkChg)) { |
| 6544 | rtl_irq_disable(tp); | 6546 | rtl_irq_disable(tp); |
| 6545 | napi_schedule_irqoff(&tp->napi); | 6547 | napi_schedule_irqoff(&tp->napi); |
| 6546 | } | 6548 | } |
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c index 6073387511f8..67f9bb6e941b 100644 --- a/drivers/net/ethernet/sis/sis900.c +++ b/drivers/net/ethernet/sis/sis900.c | |||
| @@ -730,10 +730,10 @@ static u16 sis900_default_phy(struct net_device * net_dev) | |||
| 730 | status = mdio_read(net_dev, phy->phy_addr, MII_STATUS); | 730 | status = mdio_read(net_dev, phy->phy_addr, MII_STATUS); |
| 731 | 731 | ||
| 732 | /* Link ON & Not select default PHY & not ghost PHY */ | 732 | /* Link ON & Not select default PHY & not ghost PHY */ |
| 733 | if ((status & MII_STAT_LINK) && !default_phy && | 733 | if ((status & MII_STAT_LINK) && !default_phy && |
| 734 | (phy->phy_types != UNKNOWN)) | 734 | (phy->phy_types != UNKNOWN)) { |
| 735 | default_phy = phy; | 735 | default_phy = phy; |
| 736 | else { | 736 | } else { |
| 737 | status = mdio_read(net_dev, phy->phy_addr, MII_CONTROL); | 737 | status = mdio_read(net_dev, phy->phy_addr, MII_CONTROL); |
| 738 | mdio_write(net_dev, phy->phy_addr, MII_CONTROL, | 738 | mdio_write(net_dev, phy->phy_addr, MII_CONTROL, |
| 739 | status | MII_CNTL_AUTO | MII_CNTL_ISOLATE); | 739 | status | MII_CNTL_AUTO | MII_CNTL_ISOLATE); |
| @@ -741,7 +741,7 @@ static u16 sis900_default_phy(struct net_device * net_dev) | |||
| 741 | phy_home = phy; | 741 | phy_home = phy; |
| 742 | else if(phy->phy_types == LAN) | 742 | else if(phy->phy_types == LAN) |
| 743 | phy_lan = phy; | 743 | phy_lan = phy; |
| 744 | } | 744 | } |
| 745 | } | 745 | } |
| 746 | 746 | ||
| 747 | if (!default_phy && phy_home) | 747 | if (!default_phy && phy_home) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c index d8c5bc412219..4d9bcb4d0378 100644 --- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c | |||
| @@ -59,7 +59,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) | |||
| 59 | 59 | ||
| 60 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); | 60 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); |
| 61 | stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum, | 61 | stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum, |
| 62 | STMMAC_RING_MODE, 1, false, skb->len); | 62 | STMMAC_RING_MODE, 0, false, skb->len); |
| 63 | tx_q->tx_skbuff[entry] = NULL; | 63 | tx_q->tx_skbuff[entry] = NULL; |
| 64 | entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); | 64 | entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); |
| 65 | 65 | ||
| @@ -79,7 +79,8 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) | |||
| 79 | 79 | ||
| 80 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); | 80 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); |
| 81 | stmmac_prepare_tx_desc(priv, desc, 0, len, csum, | 81 | stmmac_prepare_tx_desc(priv, desc, 0, len, csum, |
| 82 | STMMAC_RING_MODE, 1, true, skb->len); | 82 | STMMAC_RING_MODE, 1, !skb_is_nonlinear(skb), |
| 83 | skb->len); | ||
| 83 | } else { | 84 | } else { |
| 84 | des2 = dma_map_single(priv->device, skb->data, | 85 | des2 = dma_map_single(priv->device, skb->data, |
| 85 | nopaged_len, DMA_TO_DEVICE); | 86 | nopaged_len, DMA_TO_DEVICE); |
| @@ -91,7 +92,8 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) | |||
| 91 | tx_q->tx_skbuff_dma[entry].is_jumbo = true; | 92 | tx_q->tx_skbuff_dma[entry].is_jumbo = true; |
| 92 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); | 93 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); |
| 93 | stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum, | 94 | stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum, |
| 94 | STMMAC_RING_MODE, 1, true, skb->len); | 95 | STMMAC_RING_MODE, 0, !skb_is_nonlinear(skb), |
| 96 | skb->len); | ||
| 95 | } | 97 | } |
| 96 | 98 | ||
| 97 | tx_q->cur_tx = entry; | 99 | tx_q->cur_tx = entry; |
| @@ -111,10 +113,11 @@ static unsigned int is_jumbo_frm(int len, int enh_desc) | |||
| 111 | 113 | ||
| 112 | static void refill_desc3(void *priv_ptr, struct dma_desc *p) | 114 | static void refill_desc3(void *priv_ptr, struct dma_desc *p) |
| 113 | { | 115 | { |
| 114 | struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; | 116 | struct stmmac_rx_queue *rx_q = priv_ptr; |
| 117 | struct stmmac_priv *priv = rx_q->priv_data; | ||
| 115 | 118 | ||
| 116 | /* Fill DES3 in case of RING mode */ | 119 | /* Fill DES3 in case of RING mode */ |
| 117 | if (priv->dma_buf_sz >= BUF_SIZE_8KiB) | 120 | if (priv->dma_buf_sz == BUF_SIZE_16KiB) |
| 118 | p->des3 = cpu_to_le32(le32_to_cpu(p->des2) + BUF_SIZE_8KiB); | 121 | p->des3 = cpu_to_le32(le32_to_cpu(p->des2) + BUF_SIZE_8KiB); |
| 119 | } | 122 | } |
| 120 | 123 | ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 97c5e1aad88f..6a2e1031a62a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
| @@ -3216,14 +3216,16 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 3216 | stmmac_prepare_tx_desc(priv, first, 1, nopaged_len, | 3216 | stmmac_prepare_tx_desc(priv, first, 1, nopaged_len, |
| 3217 | csum_insertion, priv->mode, 1, last_segment, | 3217 | csum_insertion, priv->mode, 1, last_segment, |
| 3218 | skb->len); | 3218 | skb->len); |
| 3219 | 3219 | } else { | |
| 3220 | /* The own bit must be the latest setting done when prepare the | 3220 | stmmac_set_tx_owner(priv, first); |
| 3221 | * descriptor and then barrier is needed to make sure that | ||
| 3222 | * all is coherent before granting the DMA engine. | ||
| 3223 | */ | ||
| 3224 | wmb(); | ||
| 3225 | } | 3221 | } |
| 3226 | 3222 | ||
| 3223 | /* The own bit must be the latest setting done when prepare the | ||
| 3224 | * descriptor and then barrier is needed to make sure that | ||
| 3225 | * all is coherent before granting the DMA engine. | ||
| 3226 | */ | ||
| 3227 | wmb(); | ||
| 3228 | |||
| 3227 | netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len); | 3229 | netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len); |
| 3228 | 3230 | ||
| 3229 | stmmac_enable_dma_transmission(priv, priv->ioaddr); | 3231 | stmmac_enable_dma_transmission(priv, priv->ioaddr); |
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c index 5174d318901e..0a920c5936b2 100644 --- a/drivers/net/ethernet/ti/netcp_ethss.c +++ b/drivers/net/ethernet/ti/netcp_ethss.c | |||
| @@ -3657,12 +3657,16 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, | |||
| 3657 | 3657 | ||
| 3658 | ret = netcp_txpipe_init(&gbe_dev->tx_pipe, netcp_device, | 3658 | ret = netcp_txpipe_init(&gbe_dev->tx_pipe, netcp_device, |
| 3659 | gbe_dev->dma_chan_name, gbe_dev->tx_queue_id); | 3659 | gbe_dev->dma_chan_name, gbe_dev->tx_queue_id); |
| 3660 | if (ret) | 3660 | if (ret) { |
| 3661 | of_node_put(interfaces); | ||
| 3661 | return ret; | 3662 | return ret; |
| 3663 | } | ||
| 3662 | 3664 | ||
| 3663 | ret = netcp_txpipe_open(&gbe_dev->tx_pipe); | 3665 | ret = netcp_txpipe_open(&gbe_dev->tx_pipe); |
| 3664 | if (ret) | 3666 | if (ret) { |
| 3667 | of_node_put(interfaces); | ||
| 3665 | return ret; | 3668 | return ret; |
| 3669 | } | ||
| 3666 | 3670 | ||
| 3667 | /* Create network interfaces */ | 3671 | /* Create network interfaces */ |
| 3668 | INIT_LIST_HEAD(&gbe_dev->gbe_intf_head); | 3672 | INIT_LIST_HEAD(&gbe_dev->gbe_intf_head); |
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index ec7e7ec24ff9..4041c75997ba 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c | |||
| @@ -1575,12 +1575,14 @@ static int axienet_probe(struct platform_device *pdev) | |||
| 1575 | ret = of_address_to_resource(np, 0, &dmares); | 1575 | ret = of_address_to_resource(np, 0, &dmares); |
| 1576 | if (ret) { | 1576 | if (ret) { |
| 1577 | dev_err(&pdev->dev, "unable to get DMA resource\n"); | 1577 | dev_err(&pdev->dev, "unable to get DMA resource\n"); |
| 1578 | of_node_put(np); | ||
| 1578 | goto free_netdev; | 1579 | goto free_netdev; |
| 1579 | } | 1580 | } |
| 1580 | lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); | 1581 | lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); |
| 1581 | if (IS_ERR(lp->dma_regs)) { | 1582 | if (IS_ERR(lp->dma_regs)) { |
| 1582 | dev_err(&pdev->dev, "could not map DMA regs\n"); | 1583 | dev_err(&pdev->dev, "could not map DMA regs\n"); |
| 1583 | ret = PTR_ERR(lp->dma_regs); | 1584 | ret = PTR_ERR(lp->dma_regs); |
| 1585 | of_node_put(np); | ||
| 1584 | goto free_netdev; | 1586 | goto free_netdev; |
| 1585 | } | 1587 | } |
| 1586 | lp->rx_irq = irq_of_parse_and_map(np, 1); | 1588 | lp->rx_irq = irq_of_parse_and_map(np, 1); |
diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c index cd1d8faccca5..cd6b95e673a5 100644 --- a/drivers/net/ieee802154/adf7242.c +++ b/drivers/net/ieee802154/adf7242.c | |||
| @@ -1268,6 +1268,10 @@ static int adf7242_probe(struct spi_device *spi) | |||
| 1268 | INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work); | 1268 | INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work); |
| 1269 | lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev), | 1269 | lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev), |
| 1270 | WQ_MEM_RECLAIM); | 1270 | WQ_MEM_RECLAIM); |
| 1271 | if (unlikely(!lp->wqueue)) { | ||
| 1272 | ret = -ENOMEM; | ||
| 1273 | goto err_hw_init; | ||
| 1274 | } | ||
| 1271 | 1275 | ||
| 1272 | ret = adf7242_hw_init(lp); | 1276 | ret = adf7242_hw_init(lp); |
| 1273 | if (ret) | 1277 | if (ret) |
diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index b6743f03dce0..3b88846de31b 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c | |||
| @@ -324,7 +324,7 @@ static int hwsim_get_radio_nl(struct sk_buff *msg, struct genl_info *info) | |||
| 324 | goto out_err; | 324 | goto out_err; |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | genlmsg_reply(skb, info); | 327 | res = genlmsg_reply(skb, info); |
| 328 | break; | 328 | break; |
| 329 | } | 329 | } |
| 330 | 330 | ||
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 071869db44cf..520657945b82 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
| @@ -7,6 +7,8 @@ menuconfig MDIO_DEVICE | |||
| 7 | help | 7 | help |
| 8 | MDIO devices and driver infrastructure code. | 8 | MDIO devices and driver infrastructure code. |
| 9 | 9 | ||
| 10 | if MDIO_DEVICE | ||
| 11 | |||
| 10 | config MDIO_BUS | 12 | config MDIO_BUS |
| 11 | tristate | 13 | tristate |
| 12 | default m if PHYLIB=m | 14 | default m if PHYLIB=m |
| @@ -179,6 +181,7 @@ config MDIO_XGENE | |||
| 179 | APM X-Gene SoC's. | 181 | APM X-Gene SoC's. |
| 180 | 182 | ||
| 181 | endif | 183 | endif |
| 184 | endif | ||
| 182 | 185 | ||
| 183 | config PHYLINK | 186 | config PHYLINK |
| 184 | tristate | 187 | tristate |
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 9605d4fe540b..cb86a3e90c7d 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c | |||
| @@ -323,6 +323,19 @@ static int bcm54xx_config_init(struct phy_device *phydev) | |||
| 323 | 323 | ||
| 324 | bcm54xx_phydsp_config(phydev); | 324 | bcm54xx_phydsp_config(phydev); |
| 325 | 325 | ||
| 326 | /* Encode link speed into LED1 and LED3 pair (green/amber). | ||
| 327 | * Also flash these two LEDs on activity. This means configuring | ||
| 328 | * them for MULTICOLOR and encoding link/activity into them. | ||
| 329 | */ | ||
| 330 | val = BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_MULTICOLOR1) | | ||
| 331 | BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_MULTICOLOR1); | ||
| 332 | bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val); | ||
| 333 | |||
| 334 | val = BCM_LED_MULTICOLOR_IN_PHASE | | ||
| 335 | BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) | | ||
| 336 | BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT); | ||
| 337 | bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val); | ||
| 338 | |||
| 326 | return 0; | 339 | return 0; |
| 327 | } | 340 | } |
| 328 | 341 | ||
diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index bbd8c22067f3..97d45bd5b38e 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
| 16 | 16 | ||
| 17 | #define DP83822_PHY_ID 0x2000a240 | 17 | #define DP83822_PHY_ID 0x2000a240 |
| 18 | #define DP83825I_PHY_ID 0x2000a150 | ||
| 19 | |||
| 18 | #define DP83822_DEVADDR 0x1f | 20 | #define DP83822_DEVADDR 0x1f |
| 19 | 21 | ||
| 20 | #define MII_DP83822_PHYSCR 0x11 | 22 | #define MII_DP83822_PHYSCR 0x11 |
| @@ -304,26 +306,30 @@ static int dp83822_resume(struct phy_device *phydev) | |||
| 304 | return 0; | 306 | return 0; |
| 305 | } | 307 | } |
| 306 | 308 | ||
| 309 | #define DP83822_PHY_DRIVER(_id, _name) \ | ||
| 310 | { \ | ||
| 311 | PHY_ID_MATCH_MODEL(_id), \ | ||
| 312 | .name = (_name), \ | ||
| 313 | .features = PHY_BASIC_FEATURES, \ | ||
| 314 | .soft_reset = dp83822_phy_reset, \ | ||
| 315 | .config_init = dp83822_config_init, \ | ||
| 316 | .get_wol = dp83822_get_wol, \ | ||
| 317 | .set_wol = dp83822_set_wol, \ | ||
| 318 | .ack_interrupt = dp83822_ack_interrupt, \ | ||
| 319 | .config_intr = dp83822_config_intr, \ | ||
| 320 | .suspend = dp83822_suspend, \ | ||
| 321 | .resume = dp83822_resume, \ | ||
| 322 | } | ||
| 323 | |||
| 307 | static struct phy_driver dp83822_driver[] = { | 324 | static struct phy_driver dp83822_driver[] = { |
| 308 | { | 325 | DP83822_PHY_DRIVER(DP83822_PHY_ID, "TI DP83822"), |
| 309 | .phy_id = DP83822_PHY_ID, | 326 | DP83822_PHY_DRIVER(DP83825I_PHY_ID, "TI DP83825I"), |
| 310 | .phy_id_mask = 0xfffffff0, | ||
| 311 | .name = "TI DP83822", | ||
| 312 | .features = PHY_BASIC_FEATURES, | ||
| 313 | .config_init = dp83822_config_init, | ||
| 314 | .soft_reset = dp83822_phy_reset, | ||
| 315 | .get_wol = dp83822_get_wol, | ||
| 316 | .set_wol = dp83822_set_wol, | ||
| 317 | .ack_interrupt = dp83822_ack_interrupt, | ||
| 318 | .config_intr = dp83822_config_intr, | ||
| 319 | .suspend = dp83822_suspend, | ||
| 320 | .resume = dp83822_resume, | ||
| 321 | }, | ||
| 322 | }; | 327 | }; |
| 323 | module_phy_driver(dp83822_driver); | 328 | module_phy_driver(dp83822_driver); |
| 324 | 329 | ||
| 325 | static struct mdio_device_id __maybe_unused dp83822_tbl[] = { | 330 | static struct mdio_device_id __maybe_unused dp83822_tbl[] = { |
| 326 | { DP83822_PHY_ID, 0xfffffff0 }, | 331 | { DP83822_PHY_ID, 0xfffffff0 }, |
| 332 | { DP83825I_PHY_ID, 0xfffffff0 }, | ||
| 327 | { }, | 333 | { }, |
| 328 | }; | 334 | }; |
| 329 | MODULE_DEVICE_TABLE(mdio, dp83822_tbl); | 335 | MODULE_DEVICE_TABLE(mdio, dp83822_tbl); |
diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c index a238388eb1a5..0eec2913c289 100644 --- a/drivers/net/phy/meson-gxl.c +++ b/drivers/net/phy/meson-gxl.c | |||
| @@ -201,6 +201,7 @@ static int meson_gxl_ack_interrupt(struct phy_device *phydev) | |||
| 201 | static int meson_gxl_config_intr(struct phy_device *phydev) | 201 | static int meson_gxl_config_intr(struct phy_device *phydev) |
| 202 | { | 202 | { |
| 203 | u16 val; | 203 | u16 val; |
| 204 | int ret; | ||
| 204 | 205 | ||
| 205 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { | 206 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { |
| 206 | val = INTSRC_ANEG_PR | 207 | val = INTSRC_ANEG_PR |
| @@ -213,6 +214,11 @@ static int meson_gxl_config_intr(struct phy_device *phydev) | |||
| 213 | val = 0; | 214 | val = 0; |
| 214 | } | 215 | } |
| 215 | 216 | ||
| 217 | /* Ack any pending IRQ */ | ||
| 218 | ret = meson_gxl_ack_interrupt(phydev); | ||
| 219 | if (ret) | ||
| 220 | return ret; | ||
| 221 | |||
| 216 | return phy_write(phydev, INTSRC_MASK, val); | 222 | return phy_write(phydev, INTSRC_MASK, val); |
| 217 | } | 223 | } |
| 218 | 224 | ||
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 49fdd1ee798e..77068c545de0 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
| @@ -1831,7 +1831,7 @@ int genphy_soft_reset(struct phy_device *phydev) | |||
| 1831 | { | 1831 | { |
| 1832 | int ret; | 1832 | int ret; |
| 1833 | 1833 | ||
| 1834 | ret = phy_write(phydev, MII_BMCR, BMCR_RESET); | 1834 | ret = phy_set_bits(phydev, MII_BMCR, BMCR_RESET); |
| 1835 | if (ret < 0) | 1835 | if (ret < 0) |
| 1836 | return ret; | 1836 | return ret; |
| 1837 | 1837 | ||
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 1d68921723dc..e9ca1c088d0b 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
| @@ -1763,9 +1763,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1763 | int skb_xdp = 1; | 1763 | int skb_xdp = 1; |
| 1764 | bool frags = tun_napi_frags_enabled(tfile); | 1764 | bool frags = tun_napi_frags_enabled(tfile); |
| 1765 | 1765 | ||
| 1766 | if (!(tun->dev->flags & IFF_UP)) | ||
| 1767 | return -EIO; | ||
| 1768 | |||
| 1769 | if (!(tun->flags & IFF_NO_PI)) { | 1766 | if (!(tun->flags & IFF_NO_PI)) { |
| 1770 | if (len < sizeof(pi)) | 1767 | if (len < sizeof(pi)) |
| 1771 | return -EINVAL; | 1768 | return -EINVAL; |
| @@ -1867,6 +1864,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1867 | err = skb_copy_datagram_from_iter(skb, 0, from, len); | 1864 | err = skb_copy_datagram_from_iter(skb, 0, from, len); |
| 1868 | 1865 | ||
| 1869 | if (err) { | 1866 | if (err) { |
| 1867 | err = -EFAULT; | ||
| 1868 | drop: | ||
| 1870 | this_cpu_inc(tun->pcpu_stats->rx_dropped); | 1869 | this_cpu_inc(tun->pcpu_stats->rx_dropped); |
| 1871 | kfree_skb(skb); | 1870 | kfree_skb(skb); |
| 1872 | if (frags) { | 1871 | if (frags) { |
| @@ -1874,7 +1873,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1874 | mutex_unlock(&tfile->napi_mutex); | 1873 | mutex_unlock(&tfile->napi_mutex); |
| 1875 | } | 1874 | } |
| 1876 | 1875 | ||
| 1877 | return -EFAULT; | 1876 | return err; |
| 1878 | } | 1877 | } |
| 1879 | } | 1878 | } |
| 1880 | 1879 | ||
| @@ -1958,6 +1957,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1958 | !tfile->detached) | 1957 | !tfile->detached) |
| 1959 | rxhash = __skb_get_hash_symmetric(skb); | 1958 | rxhash = __skb_get_hash_symmetric(skb); |
| 1960 | 1959 | ||
| 1960 | rcu_read_lock(); | ||
| 1961 | if (unlikely(!(tun->dev->flags & IFF_UP))) { | ||
| 1962 | err = -EIO; | ||
| 1963 | rcu_read_unlock(); | ||
| 1964 | goto drop; | ||
| 1965 | } | ||
| 1966 | |||
| 1961 | if (frags) { | 1967 | if (frags) { |
| 1962 | /* Exercise flow dissector code path. */ | 1968 | /* Exercise flow dissector code path. */ |
| 1963 | u32 headlen = eth_get_headlen(skb->data, skb_headlen(skb)); | 1969 | u32 headlen = eth_get_headlen(skb->data, skb_headlen(skb)); |
| @@ -1965,6 +1971,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1965 | if (unlikely(headlen > skb_headlen(skb))) { | 1971 | if (unlikely(headlen > skb_headlen(skb))) { |
| 1966 | this_cpu_inc(tun->pcpu_stats->rx_dropped); | 1972 | this_cpu_inc(tun->pcpu_stats->rx_dropped); |
| 1967 | napi_free_frags(&tfile->napi); | 1973 | napi_free_frags(&tfile->napi); |
| 1974 | rcu_read_unlock(); | ||
| 1968 | mutex_unlock(&tfile->napi_mutex); | 1975 | mutex_unlock(&tfile->napi_mutex); |
| 1969 | WARN_ON(1); | 1976 | WARN_ON(1); |
| 1970 | return -ENOMEM; | 1977 | return -ENOMEM; |
| @@ -1992,6 +1999,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1992 | } else { | 1999 | } else { |
| 1993 | netif_rx_ni(skb); | 2000 | netif_rx_ni(skb); |
| 1994 | } | 2001 | } |
| 2002 | rcu_read_unlock(); | ||
| 1995 | 2003 | ||
| 1996 | stats = get_cpu_ptr(tun->pcpu_stats); | 2004 | stats = get_cpu_ptr(tun->pcpu_stats); |
| 1997 | u64_stats_update_begin(&stats->syncp); | 2005 | u64_stats_update_begin(&stats->syncp); |
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 820a2fe7d027..aff995be2a31 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c | |||
| @@ -1301,6 +1301,20 @@ static const struct driver_info trendnet_info = { | |||
| 1301 | .tx_fixup = aqc111_tx_fixup, | 1301 | .tx_fixup = aqc111_tx_fixup, |
| 1302 | }; | 1302 | }; |
| 1303 | 1303 | ||
| 1304 | static const struct driver_info qnap_info = { | ||
| 1305 | .description = "QNAP QNA-UC5G1T USB to 5GbE Adapter", | ||
| 1306 | .bind = aqc111_bind, | ||
| 1307 | .unbind = aqc111_unbind, | ||
| 1308 | .status = aqc111_status, | ||
| 1309 | .link_reset = aqc111_link_reset, | ||
| 1310 | .reset = aqc111_reset, | ||
| 1311 | .stop = aqc111_stop, | ||
| 1312 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | | ||
| 1313 | FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET, | ||
| 1314 | .rx_fixup = aqc111_rx_fixup, | ||
| 1315 | .tx_fixup = aqc111_tx_fixup, | ||
| 1316 | }; | ||
| 1317 | |||
| 1304 | static int aqc111_suspend(struct usb_interface *intf, pm_message_t message) | 1318 | static int aqc111_suspend(struct usb_interface *intf, pm_message_t message) |
| 1305 | { | 1319 | { |
| 1306 | struct usbnet *dev = usb_get_intfdata(intf); | 1320 | struct usbnet *dev = usb_get_intfdata(intf); |
| @@ -1455,6 +1469,7 @@ static const struct usb_device_id products[] = { | |||
| 1455 | {AQC111_USB_ETH_DEV(0x0b95, 0x2790, asix111_info)}, | 1469 | {AQC111_USB_ETH_DEV(0x0b95, 0x2790, asix111_info)}, |
| 1456 | {AQC111_USB_ETH_DEV(0x0b95, 0x2791, asix112_info)}, | 1470 | {AQC111_USB_ETH_DEV(0x0b95, 0x2791, asix112_info)}, |
| 1457 | {AQC111_USB_ETH_DEV(0x20f4, 0xe05a, trendnet_info)}, | 1471 | {AQC111_USB_ETH_DEV(0x20f4, 0xe05a, trendnet_info)}, |
| 1472 | {AQC111_USB_ETH_DEV(0x1c04, 0x0015, qnap_info)}, | ||
| 1458 | { },/* END */ | 1473 | { },/* END */ |
| 1459 | }; | 1474 | }; |
| 1460 | MODULE_DEVICE_TABLE(usb, products); | 1475 | MODULE_DEVICE_TABLE(usb, products); |
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 5512a1038721..3e9b2c319e45 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
| @@ -851,6 +851,14 @@ static const struct usb_device_id products[] = { | |||
| 851 | .driver_info = 0, | 851 | .driver_info = 0, |
| 852 | }, | 852 | }, |
| 853 | 853 | ||
| 854 | /* QNAP QNA-UC5G1T USB to 5GbE Adapter (based on AQC111U) */ | ||
| 855 | { | ||
| 856 | USB_DEVICE_AND_INTERFACE_INFO(0x1c04, 0x0015, USB_CLASS_COMM, | ||
| 857 | USB_CDC_SUBCLASS_ETHERNET, | ||
| 858 | USB_CDC_PROTO_NONE), | ||
| 859 | .driver_info = 0, | ||
| 860 | }, | ||
| 861 | |||
| 854 | /* WHITELIST!!! | 862 | /* WHITELIST!!! |
| 855 | * | 863 | * |
| 856 | * CDC Ether uses two interfaces, not necessarily consecutive. | 864 | * CDC Ether uses two interfaces, not necessarily consecutive. |
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 077f1b9f2761..d76dfed8d9bb 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
| @@ -4335,10 +4335,8 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head) | |||
| 4335 | /* If vxlan->dev is in the same netns, it has already been added | 4335 | /* If vxlan->dev is in the same netns, it has already been added |
| 4336 | * to the list by the previous loop. | 4336 | * to the list by the previous loop. |
| 4337 | */ | 4337 | */ |
| 4338 | if (!net_eq(dev_net(vxlan->dev), net)) { | 4338 | if (!net_eq(dev_net(vxlan->dev), net)) |
| 4339 | gro_cells_destroy(&vxlan->gro_cells); | ||
| 4340 | unregister_netdevice_queue(vxlan->dev, head); | 4339 | unregister_netdevice_queue(vxlan->dev, head); |
| 4341 | } | ||
| 4342 | } | 4340 | } |
| 4343 | 4341 | ||
| 4344 | for (h = 0; h < PORT_HASH_SIZE; ++h) | 4342 | for (h = 0; h < PORT_HASH_SIZE; ++h) |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c index e9822a3ec373..94132cfd1f56 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | |||
| @@ -460,9 +460,7 @@ static int iwl_mvm_ftm_range_resp_valid(struct iwl_mvm *mvm, u8 request_id, | |||
| 460 | static void iwl_mvm_debug_range_resp(struct iwl_mvm *mvm, u8 index, | 460 | static void iwl_mvm_debug_range_resp(struct iwl_mvm *mvm, u8 index, |
| 461 | struct cfg80211_pmsr_result *res) | 461 | struct cfg80211_pmsr_result *res) |
| 462 | { | 462 | { |
| 463 | s64 rtt_avg = res->ftm.rtt_avg * 100; | 463 | s64 rtt_avg = div_s64(res->ftm.rtt_avg * 100, 6666); |
| 464 | |||
| 465 | do_div(rtt_avg, 6666); | ||
| 466 | 464 | ||
| 467 | IWL_DEBUG_INFO(mvm, "entry %d\n", index); | 465 | IWL_DEBUG_INFO(mvm, "entry %d\n", index); |
| 468 | IWL_DEBUG_INFO(mvm, "\tstatus: %d\n", res->status); | 466 | IWL_DEBUG_INFO(mvm, "\tstatus: %d\n", res->status); |
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index 6eedc0ec7661..76629b98c78d 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c | |||
| @@ -130,6 +130,8 @@ mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct mt76_queue *q, int idx, | |||
| 130 | static void | 130 | static void |
| 131 | mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q) | 131 | mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q) |
| 132 | { | 132 | { |
| 133 | iowrite32(q->desc_dma, &q->regs->desc_base); | ||
| 134 | iowrite32(q->ndesc, &q->regs->ring_size); | ||
| 133 | q->head = ioread32(&q->regs->dma_idx); | 135 | q->head = ioread32(&q->regs->dma_idx); |
| 134 | q->tail = q->head; | 136 | q->tail = q->head; |
| 135 | iowrite32(q->head, &q->regs->cpu_idx); | 137 | iowrite32(q->head, &q->regs->cpu_idx); |
| @@ -180,7 +182,10 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush) | |||
| 180 | else | 182 | else |
| 181 | mt76_dma_sync_idx(dev, q); | 183 | mt76_dma_sync_idx(dev, q); |
| 182 | 184 | ||
| 183 | wake = wake && qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; | 185 | wake = wake && q->stopped && |
| 186 | qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; | ||
| 187 | if (wake) | ||
| 188 | q->stopped = false; | ||
| 184 | 189 | ||
| 185 | if (!q->queued) | 190 | if (!q->queued) |
| 186 | wake_up(&dev->tx_wait); | 191 | wake_up(&dev->tx_wait); |
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index a033745adb2f..316167404729 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c | |||
| @@ -679,19 +679,15 @@ out: | |||
| 679 | return ret; | 679 | return ret; |
| 680 | } | 680 | } |
| 681 | 681 | ||
| 682 | static void | 682 | void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 683 | mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, | 683 | struct ieee80211_sta *sta) |
| 684 | struct ieee80211_sta *sta) | ||
| 685 | { | 684 | { |
| 686 | struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; | 685 | struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; |
| 687 | int idx = wcid->idx; | 686 | int i, idx = wcid->idx; |
| 688 | int i; | ||
| 689 | 687 | ||
| 690 | rcu_assign_pointer(dev->wcid[idx], NULL); | 688 | rcu_assign_pointer(dev->wcid[idx], NULL); |
| 691 | synchronize_rcu(); | 689 | synchronize_rcu(); |
| 692 | 690 | ||
| 693 | mutex_lock(&dev->mutex); | ||
| 694 | |||
| 695 | if (dev->drv->sta_remove) | 691 | if (dev->drv->sta_remove) |
| 696 | dev->drv->sta_remove(dev, vif, sta); | 692 | dev->drv->sta_remove(dev, vif, sta); |
| 697 | 693 | ||
| @@ -699,7 +695,15 @@ mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, | |||
| 699 | for (i = 0; i < ARRAY_SIZE(sta->txq); i++) | 695 | for (i = 0; i < ARRAY_SIZE(sta->txq); i++) |
| 700 | mt76_txq_remove(dev, sta->txq[i]); | 696 | mt76_txq_remove(dev, sta->txq[i]); |
| 701 | mt76_wcid_free(dev->wcid_mask, idx); | 697 | mt76_wcid_free(dev->wcid_mask, idx); |
| 698 | } | ||
| 699 | EXPORT_SYMBOL_GPL(__mt76_sta_remove); | ||
| 702 | 700 | ||
| 701 | static void | ||
| 702 | mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, | ||
| 703 | struct ieee80211_sta *sta) | ||
| 704 | { | ||
| 705 | mutex_lock(&dev->mutex); | ||
| 706 | __mt76_sta_remove(dev, vif, sta); | ||
| 703 | mutex_unlock(&dev->mutex); | 707 | mutex_unlock(&dev->mutex); |
| 704 | } | 708 | } |
| 705 | 709 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 5dfb0601f101..bcbfd3c4a44b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h | |||
| @@ -126,6 +126,7 @@ struct mt76_queue { | |||
| 126 | int ndesc; | 126 | int ndesc; |
| 127 | int queued; | 127 | int queued; |
| 128 | int buf_size; | 128 | int buf_size; |
| 129 | bool stopped; | ||
| 129 | 130 | ||
| 130 | u8 buf_offset; | 131 | u8 buf_offset; |
| 131 | u8 hw_idx; | 132 | u8 hw_idx; |
| @@ -143,6 +144,7 @@ struct mt76_mcu_ops { | |||
| 143 | const struct mt76_reg_pair *rp, int len); | 144 | const struct mt76_reg_pair *rp, int len); |
| 144 | int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base, | 145 | int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base, |
| 145 | struct mt76_reg_pair *rp, int len); | 146 | struct mt76_reg_pair *rp, int len); |
| 147 | int (*mcu_restart)(struct mt76_dev *dev); | ||
| 146 | }; | 148 | }; |
| 147 | 149 | ||
| 148 | struct mt76_queue_ops { | 150 | struct mt76_queue_ops { |
| @@ -693,6 +695,8 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |||
| 693 | struct ieee80211_sta *sta, | 695 | struct ieee80211_sta *sta, |
| 694 | enum ieee80211_sta_state old_state, | 696 | enum ieee80211_sta_state old_state, |
| 695 | enum ieee80211_sta_state new_state); | 697 | enum ieee80211_sta_state new_state); |
| 698 | void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, | ||
| 699 | struct ieee80211_sta *sta); | ||
| 696 | 700 | ||
| 697 | struct ieee80211_sta *mt76_rx_convert(struct sk_buff *skb); | 701 | struct ieee80211_sta *mt76_rx_convert(struct sk_buff *skb); |
| 698 | 702 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/beacon.c b/drivers/net/wireless/mediatek/mt76/mt7603/beacon.c index afcd86f735b4..4dcb465095d1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/beacon.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/beacon.c | |||
| @@ -135,8 +135,7 @@ void mt7603_pre_tbtt_tasklet(unsigned long arg) | |||
| 135 | 135 | ||
| 136 | out: | 136 | out: |
| 137 | mt76_queue_tx_cleanup(dev, MT_TXQ_BEACON, false); | 137 | mt76_queue_tx_cleanup(dev, MT_TXQ_BEACON, false); |
| 138 | if (dev->mt76.q_tx[MT_TXQ_BEACON].queued > | 138 | if (dev->mt76.q_tx[MT_TXQ_BEACON].queued > hweight8(dev->beacon_mask)) |
| 139 | __sw_hweight8(dev->beacon_mask)) | ||
| 140 | dev->beacon_check++; | 139 | dev->beacon_check++; |
| 141 | } | 140 | } |
| 142 | 141 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/dma.c b/drivers/net/wireless/mediatek/mt76/mt7603/dma.c index d69e82c66ab2..b3ae0aaea62a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/dma.c | |||
| @@ -27,12 +27,16 @@ static void | |||
| 27 | mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb) | 27 | mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb) |
| 28 | { | 28 | { |
| 29 | __le32 *txd = (__le32 *)skb->data; | 29 | __le32 *txd = (__le32 *)skb->data; |
| 30 | struct ieee80211_hdr *hdr; | ||
| 31 | struct ieee80211_sta *sta; | ||
| 30 | struct mt7603_sta *msta; | 32 | struct mt7603_sta *msta; |
| 31 | struct mt76_wcid *wcid; | 33 | struct mt76_wcid *wcid; |
| 34 | void *priv; | ||
| 32 | int idx; | 35 | int idx; |
| 33 | u32 val; | 36 | u32 val; |
| 37 | u8 tid; | ||
| 34 | 38 | ||
| 35 | if (skb->len < sizeof(MT_TXD_SIZE) + sizeof(struct ieee80211_hdr)) | 39 | if (skb->len < MT_TXD_SIZE + sizeof(struct ieee80211_hdr)) |
| 36 | goto free; | 40 | goto free; |
| 37 | 41 | ||
| 38 | val = le32_to_cpu(txd[1]); | 42 | val = le32_to_cpu(txd[1]); |
| @@ -46,10 +50,19 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb) | |||
| 46 | if (!wcid) | 50 | if (!wcid) |
| 47 | goto free; | 51 | goto free; |
| 48 | 52 | ||
| 49 | msta = container_of(wcid, struct mt7603_sta, wcid); | 53 | priv = msta = container_of(wcid, struct mt7603_sta, wcid); |
| 50 | val = le32_to_cpu(txd[0]); | 54 | val = le32_to_cpu(txd[0]); |
| 51 | skb_set_queue_mapping(skb, FIELD_GET(MT_TXD0_Q_IDX, val)); | 55 | skb_set_queue_mapping(skb, FIELD_GET(MT_TXD0_Q_IDX, val)); |
| 52 | 56 | ||
| 57 | val &= ~(MT_TXD0_P_IDX | MT_TXD0_Q_IDX); | ||
| 58 | val |= FIELD_PREP(MT_TXD0_Q_IDX, MT_TX_HW_QUEUE_MGMT); | ||
| 59 | txd[0] = cpu_to_le32(val); | ||
| 60 | |||
| 61 | sta = container_of(priv, struct ieee80211_sta, drv_priv); | ||
| 62 | hdr = (struct ieee80211_hdr *) &skb->data[MT_TXD_SIZE]; | ||
| 63 | tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK; | ||
| 64 | ieee80211_sta_set_buffered(sta, tid, true); | ||
| 65 | |||
| 53 | spin_lock_bh(&dev->ps_lock); | 66 | spin_lock_bh(&dev->ps_lock); |
| 54 | __skb_queue_tail(&msta->psq, skb); | 67 | __skb_queue_tail(&msta->psq, skb); |
| 55 | if (skb_queue_len(&msta->psq) >= 64) { | 68 | if (skb_queue_len(&msta->psq) >= 64) { |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/init.c b/drivers/net/wireless/mediatek/mt76/mt7603/init.c index 15cc8f33b34d..d54dda67d036 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/init.c | |||
| @@ -112,7 +112,7 @@ static void | |||
| 112 | mt7603_phy_init(struct mt7603_dev *dev) | 112 | mt7603_phy_init(struct mt7603_dev *dev) |
| 113 | { | 113 | { |
| 114 | int rx_chains = dev->mt76.antenna_mask; | 114 | int rx_chains = dev->mt76.antenna_mask; |
| 115 | int tx_chains = __sw_hweight8(rx_chains) - 1; | 115 | int tx_chains = hweight8(rx_chains) - 1; |
| 116 | 116 | ||
| 117 | mt76_rmw(dev, MT_WF_RMAC_RMCR, | 117 | mt76_rmw(dev, MT_WF_RMAC_RMCR, |
| 118 | (MT_WF_RMAC_RMCR_SMPS_MODE | | 118 | (MT_WF_RMAC_RMCR_SMPS_MODE | |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c index 0a0115861b51..5e31d7da96fc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c | |||
| @@ -1072,7 +1072,7 @@ out: | |||
| 1072 | case MT_PHY_TYPE_HT: | 1072 | case MT_PHY_TYPE_HT: |
| 1073 | final_rate_flags |= IEEE80211_TX_RC_MCS; | 1073 | final_rate_flags |= IEEE80211_TX_RC_MCS; |
| 1074 | final_rate &= GENMASK(5, 0); | 1074 | final_rate &= GENMASK(5, 0); |
| 1075 | if (i > 15) | 1075 | if (final_rate > 15) |
| 1076 | return false; | 1076 | return false; |
| 1077 | break; | 1077 | break; |
| 1078 | default: | 1078 | default: |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/main.c b/drivers/net/wireless/mediatek/mt76/mt7603/main.c index b10775ed92e6..cc0fe0933b2d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/main.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <linux/pci.h> | 5 | #include <linux/pci.h> |
| 6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
| 7 | #include "mt7603.h" | 7 | #include "mt7603.h" |
| 8 | #include "mac.h" | ||
| 8 | #include "eeprom.h" | 9 | #include "eeprom.h" |
| 9 | 10 | ||
| 10 | static int | 11 | static int |
| @@ -386,6 +387,15 @@ mt7603_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps) | |||
| 386 | } | 387 | } |
| 387 | 388 | ||
| 388 | static void | 389 | static void |
| 390 | mt7603_ps_set_more_data(struct sk_buff *skb) | ||
| 391 | { | ||
| 392 | struct ieee80211_hdr *hdr; | ||
| 393 | |||
| 394 | hdr = (struct ieee80211_hdr *) &skb->data[MT_TXD_SIZE]; | ||
| 395 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); | ||
| 396 | } | ||
| 397 | |||
| 398 | static void | ||
| 389 | mt7603_release_buffered_frames(struct ieee80211_hw *hw, | 399 | mt7603_release_buffered_frames(struct ieee80211_hw *hw, |
| 390 | struct ieee80211_sta *sta, | 400 | struct ieee80211_sta *sta, |
| 391 | u16 tids, int nframes, | 401 | u16 tids, int nframes, |
| @@ -399,6 +409,8 @@ mt7603_release_buffered_frames(struct ieee80211_hw *hw, | |||
| 399 | 409 | ||
| 400 | __skb_queue_head_init(&list); | 410 | __skb_queue_head_init(&list); |
| 401 | 411 | ||
| 412 | mt7603_wtbl_set_ps(dev, msta, false); | ||
| 413 | |||
| 402 | spin_lock_bh(&dev->ps_lock); | 414 | spin_lock_bh(&dev->ps_lock); |
| 403 | skb_queue_walk_safe(&msta->psq, skb, tmp) { | 415 | skb_queue_walk_safe(&msta->psq, skb, tmp) { |
| 404 | if (!nframes) | 416 | if (!nframes) |
| @@ -409,11 +421,15 @@ mt7603_release_buffered_frames(struct ieee80211_hw *hw, | |||
| 409 | 421 | ||
| 410 | skb_set_queue_mapping(skb, MT_TXQ_PSD); | 422 | skb_set_queue_mapping(skb, MT_TXQ_PSD); |
| 411 | __skb_unlink(skb, &msta->psq); | 423 | __skb_unlink(skb, &msta->psq); |
| 424 | mt7603_ps_set_more_data(skb); | ||
| 412 | __skb_queue_tail(&list, skb); | 425 | __skb_queue_tail(&list, skb); |
| 413 | nframes--; | 426 | nframes--; |
| 414 | } | 427 | } |
| 415 | spin_unlock_bh(&dev->ps_lock); | 428 | spin_unlock_bh(&dev->ps_lock); |
| 416 | 429 | ||
| 430 | if (!skb_queue_empty(&list)) | ||
| 431 | ieee80211_sta_eosp(sta); | ||
| 432 | |||
| 417 | mt7603_ps_tx_list(dev, &list); | 433 | mt7603_ps_tx_list(dev, &list); |
| 418 | 434 | ||
| 419 | if (nframes) | 435 | if (nframes) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c index 4b0713f1fd5e..d06905ea8cc6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | |||
| @@ -433,7 +433,7 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev) | |||
| 433 | { | 433 | { |
| 434 | struct cfg80211_chan_def *chandef = &dev->mt76.chandef; | 434 | struct cfg80211_chan_def *chandef = &dev->mt76.chandef; |
| 435 | struct ieee80211_hw *hw = mt76_hw(dev); | 435 | struct ieee80211_hw *hw = mt76_hw(dev); |
| 436 | int n_chains = __sw_hweight8(dev->mt76.antenna_mask); | 436 | int n_chains = hweight8(dev->mt76.antenna_mask); |
| 437 | struct { | 437 | struct { |
| 438 | u8 control_chan; | 438 | u8 control_chan; |
| 439 | u8 center_chan; | 439 | u8 center_chan; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/soc.c b/drivers/net/wireless/mediatek/mt76/mt7603/soc.c index e13fea80d970..b920be1f5718 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/soc.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/soc.c | |||
| @@ -23,9 +23,9 @@ mt76_wmac_probe(struct platform_device *pdev) | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | mem_base = devm_ioremap_resource(&pdev->dev, res); | 25 | mem_base = devm_ioremap_resource(&pdev->dev, res); |
| 26 | if (!mem_base) { | 26 | if (IS_ERR(mem_base)) { |
| 27 | dev_err(&pdev->dev, "Failed to get memory resource\n"); | 27 | dev_err(&pdev->dev, "Failed to get memory resource\n"); |
| 28 | return -EINVAL; | 28 | return PTR_ERR(mem_base); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops, | 31 | mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops, |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h b/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h index 0290ba5869a5..736f81752b5b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h | |||
| @@ -46,7 +46,7 @@ static const struct mt76_reg_pair common_mac_reg_table[] = { | |||
| 46 | { MT_MM20_PROT_CFG, 0x01742004 }, | 46 | { MT_MM20_PROT_CFG, 0x01742004 }, |
| 47 | { MT_MM40_PROT_CFG, 0x03f42084 }, | 47 | { MT_MM40_PROT_CFG, 0x03f42084 }, |
| 48 | { MT_TXOP_CTRL_CFG, 0x0000583f }, | 48 | { MT_TXOP_CTRL_CFG, 0x0000583f }, |
| 49 | { MT_TX_RTS_CFG, 0x00092b20 }, | 49 | { MT_TX_RTS_CFG, 0x00ffff20 }, |
| 50 | { MT_EXP_ACK_TIME, 0x002400ca }, | 50 | { MT_EXP_ACK_TIME, 0x002400ca }, |
| 51 | { MT_TXOP_HLDR_ET, 0x00000002 }, | 51 | { MT_TXOP_HLDR_ET, 0x00000002 }, |
| 52 | { MT_XIFS_TIME_CFG, 0x33a41010 }, | 52 | { MT_XIFS_TIME_CFG, 0x33a41010 }, |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index 91718647da02..e5a06f74a6f7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | |||
| @@ -229,7 +229,7 @@ static int mt76x0u_probe(struct usb_interface *usb_intf, | |||
| 229 | struct usb_device *usb_dev = interface_to_usbdev(usb_intf); | 229 | struct usb_device *usb_dev = interface_to_usbdev(usb_intf); |
| 230 | struct mt76x02_dev *dev; | 230 | struct mt76x02_dev *dev; |
| 231 | struct mt76_dev *mdev; | 231 | struct mt76_dev *mdev; |
| 232 | u32 asic_rev, mac_rev; | 232 | u32 mac_rev; |
| 233 | int ret; | 233 | int ret; |
| 234 | 234 | ||
| 235 | mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), &mt76x0u_ops, | 235 | mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), &mt76x0u_ops, |
| @@ -262,10 +262,14 @@ static int mt76x0u_probe(struct usb_interface *usb_intf, | |||
| 262 | goto err; | 262 | goto err; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | asic_rev = mt76_rr(dev, MT_ASIC_VERSION); | 265 | mdev->rev = mt76_rr(dev, MT_ASIC_VERSION); |
| 266 | mac_rev = mt76_rr(dev, MT_MAC_CSR0); | 266 | mac_rev = mt76_rr(dev, MT_MAC_CSR0); |
| 267 | dev_info(mdev->dev, "ASIC revision: %08x MAC revision: %08x\n", | 267 | dev_info(mdev->dev, "ASIC revision: %08x MAC revision: %08x\n", |
| 268 | asic_rev, mac_rev); | 268 | mdev->rev, mac_rev); |
| 269 | if (!is_mt76x0(dev)) { | ||
| 270 | ret = -ENODEV; | ||
| 271 | goto err; | ||
| 272 | } | ||
| 269 | 273 | ||
| 270 | /* Note: vendor driver skips this check for MT76X0U */ | 274 | /* Note: vendor driver skips this check for MT76X0U */ |
| 271 | if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) | 275 | if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h index 6915cce5def9..07061eb4d1e1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h | |||
| @@ -51,6 +51,7 @@ struct mt76x02_calibration { | |||
| 51 | u16 false_cca; | 51 | u16 false_cca; |
| 52 | s8 avg_rssi_all; | 52 | s8 avg_rssi_all; |
| 53 | s8 agc_gain_adjust; | 53 | s8 agc_gain_adjust; |
| 54 | s8 agc_lowest_gain; | ||
| 54 | s8 low_gain; | 55 | s8 low_gain; |
| 55 | 56 | ||
| 56 | s8 temp_vco; | 57 | s8 temp_vco; |
| @@ -114,8 +115,11 @@ struct mt76x02_dev { | |||
| 114 | struct mt76x02_dfs_pattern_detector dfs_pd; | 115 | struct mt76x02_dfs_pattern_detector dfs_pd; |
| 115 | 116 | ||
| 116 | /* edcca monitor */ | 117 | /* edcca monitor */ |
| 118 | unsigned long ed_trigger_timeout; | ||
| 117 | bool ed_tx_blocked; | 119 | bool ed_tx_blocked; |
| 118 | bool ed_monitor; | 120 | bool ed_monitor; |
| 121 | u8 ed_monitor_enabled; | ||
| 122 | u8 ed_monitor_learning; | ||
| 119 | u8 ed_trigger; | 123 | u8 ed_trigger; |
| 120 | u8 ed_silent; | 124 | u8 ed_silent; |
| 121 | ktime_t ed_time; | 125 | ktime_t ed_time; |
| @@ -188,6 +192,13 @@ void mt76x02_mac_start(struct mt76x02_dev *dev); | |||
| 188 | 192 | ||
| 189 | void mt76x02_init_debugfs(struct mt76x02_dev *dev); | 193 | void mt76x02_init_debugfs(struct mt76x02_dev *dev); |
| 190 | 194 | ||
| 195 | static inline bool is_mt76x0(struct mt76x02_dev *dev) | ||
| 196 | { | ||
| 197 | return mt76_chip(&dev->mt76) == 0x7610 || | ||
| 198 | mt76_chip(&dev->mt76) == 0x7630 || | ||
| 199 | mt76_chip(&dev->mt76) == 0x7650; | ||
| 200 | } | ||
| 201 | |||
| 191 | static inline bool is_mt76x2(struct mt76x02_dev *dev) | 202 | static inline bool is_mt76x2(struct mt76x02_dev *dev) |
| 192 | { | 203 | { |
| 193 | return mt76_chip(&dev->mt76) == 0x7612 || | 204 | return mt76_chip(&dev->mt76) == 0x7612 || |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c index 7580c5c986ff..b1d6fd4861e3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c | |||
| @@ -116,6 +116,32 @@ static int read_agc(struct seq_file *file, void *data) | |||
| 116 | return 0; | 116 | return 0; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | static int | ||
| 120 | mt76_edcca_set(void *data, u64 val) | ||
| 121 | { | ||
| 122 | struct mt76x02_dev *dev = data; | ||
| 123 | enum nl80211_dfs_regions region = dev->dfs_pd.region; | ||
| 124 | |||
| 125 | dev->ed_monitor_enabled = !!val; | ||
| 126 | dev->ed_monitor = dev->ed_monitor_enabled && | ||
| 127 | region == NL80211_DFS_ETSI; | ||
| 128 | mt76x02_edcca_init(dev, true); | ||
| 129 | |||
| 130 | return 0; | ||
| 131 | } | ||
| 132 | |||
| 133 | static int | ||
| 134 | mt76_edcca_get(void *data, u64 *val) | ||
| 135 | { | ||
| 136 | struct mt76x02_dev *dev = data; | ||
| 137 | |||
| 138 | *val = dev->ed_monitor_enabled; | ||
| 139 | return 0; | ||
| 140 | } | ||
| 141 | |||
| 142 | DEFINE_DEBUGFS_ATTRIBUTE(fops_edcca, mt76_edcca_get, mt76_edcca_set, | ||
| 143 | "%lld\n"); | ||
| 144 | |||
| 119 | void mt76x02_init_debugfs(struct mt76x02_dev *dev) | 145 | void mt76x02_init_debugfs(struct mt76x02_dev *dev) |
| 120 | { | 146 | { |
| 121 | struct dentry *dir; | 147 | struct dentry *dir; |
| @@ -127,6 +153,7 @@ void mt76x02_init_debugfs(struct mt76x02_dev *dev) | |||
| 127 | debugfs_create_u8("temperature", 0400, dir, &dev->cal.temp); | 153 | debugfs_create_u8("temperature", 0400, dir, &dev->cal.temp); |
| 128 | debugfs_create_bool("tpc", 0600, dir, &dev->enable_tpc); | 154 | debugfs_create_bool("tpc", 0600, dir, &dev->enable_tpc); |
| 129 | 155 | ||
| 156 | debugfs_create_file("edcca", 0400, dir, dev, &fops_edcca); | ||
| 130 | debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat); | 157 | debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat); |
| 131 | debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat); | 158 | debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat); |
| 132 | debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir, | 159 | debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir, |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c b/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c index e4649103efd4..17d12d212d1b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c | |||
| @@ -885,7 +885,8 @@ mt76x02_dfs_set_domain(struct mt76x02_dev *dev, | |||
| 885 | if (dfs_pd->region != region) { | 885 | if (dfs_pd->region != region) { |
| 886 | tasklet_disable(&dfs_pd->dfs_tasklet); | 886 | tasklet_disable(&dfs_pd->dfs_tasklet); |
| 887 | 887 | ||
| 888 | dev->ed_monitor = region == NL80211_DFS_ETSI; | 888 | dev->ed_monitor = dev->ed_monitor_enabled && |
| 889 | region == NL80211_DFS_ETSI; | ||
| 889 | mt76x02_edcca_init(dev, true); | 890 | mt76x02_edcca_init(dev, true); |
| 890 | 891 | ||
| 891 | dfs_pd->region = region; | 892 | dfs_pd->region = region; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c index 91ff6598eccf..9ed231abe916 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | |||
| @@ -67,12 +67,39 @@ int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx, | |||
| 67 | } | 67 | } |
| 68 | EXPORT_SYMBOL_GPL(mt76x02_mac_shared_key_setup); | 68 | EXPORT_SYMBOL_GPL(mt76x02_mac_shared_key_setup); |
| 69 | 69 | ||
| 70 | void mt76x02_mac_wcid_sync_pn(struct mt76x02_dev *dev, u8 idx, | ||
| 71 | struct ieee80211_key_conf *key) | ||
| 72 | { | ||
| 73 | enum mt76x02_cipher_type cipher; | ||
| 74 | u8 key_data[32]; | ||
| 75 | u32 iv, eiv; | ||
| 76 | u64 pn; | ||
| 77 | |||
| 78 | cipher = mt76x02_mac_get_key_info(key, key_data); | ||
| 79 | iv = mt76_rr(dev, MT_WCID_IV(idx)); | ||
| 80 | eiv = mt76_rr(dev, MT_WCID_IV(idx) + 4); | ||
| 81 | |||
| 82 | pn = (u64)eiv << 16; | ||
| 83 | if (cipher == MT_CIPHER_TKIP) { | ||
| 84 | pn |= (iv >> 16) & 0xff; | ||
| 85 | pn |= (iv & 0xff) << 8; | ||
| 86 | } else if (cipher >= MT_CIPHER_AES_CCMP) { | ||
| 87 | pn |= iv & 0xffff; | ||
| 88 | } else { | ||
| 89 | return; | ||
| 90 | } | ||
| 91 | |||
| 92 | atomic64_set(&key->tx_pn, pn); | ||
| 93 | } | ||
| 94 | |||
| 95 | |||
| 70 | int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, | 96 | int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, |
| 71 | struct ieee80211_key_conf *key) | 97 | struct ieee80211_key_conf *key) |
| 72 | { | 98 | { |
| 73 | enum mt76x02_cipher_type cipher; | 99 | enum mt76x02_cipher_type cipher; |
| 74 | u8 key_data[32]; | 100 | u8 key_data[32]; |
| 75 | u8 iv_data[8]; | 101 | u8 iv_data[8]; |
| 102 | u64 pn; | ||
| 76 | 103 | ||
| 77 | cipher = mt76x02_mac_get_key_info(key, key_data); | 104 | cipher = mt76x02_mac_get_key_info(key, key_data); |
| 78 | if (cipher == MT_CIPHER_NONE && key) | 105 | if (cipher == MT_CIPHER_NONE && key) |
| @@ -85,9 +112,22 @@ int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, | |||
| 85 | if (key) { | 112 | if (key) { |
| 86 | mt76_rmw_field(dev, MT_WCID_ATTR(idx), MT_WCID_ATTR_PAIRWISE, | 113 | mt76_rmw_field(dev, MT_WCID_ATTR(idx), MT_WCID_ATTR_PAIRWISE, |
| 87 | !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)); | 114 | !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)); |
| 115 | |||
| 116 | pn = atomic64_read(&key->tx_pn); | ||
| 117 | |||
| 88 | iv_data[3] = key->keyidx << 6; | 118 | iv_data[3] = key->keyidx << 6; |
| 89 | if (cipher >= MT_CIPHER_TKIP) | 119 | if (cipher >= MT_CIPHER_TKIP) { |
| 90 | iv_data[3] |= 0x20; | 120 | iv_data[3] |= 0x20; |
| 121 | put_unaligned_le32(pn >> 16, &iv_data[4]); | ||
| 122 | } | ||
| 123 | |||
| 124 | if (cipher == MT_CIPHER_TKIP) { | ||
| 125 | iv_data[0] = (pn >> 8) & 0xff; | ||
| 126 | iv_data[1] = (iv_data[0] | 0x20) & 0x7f; | ||
| 127 | iv_data[2] = pn & 0xff; | ||
| 128 | } else if (cipher >= MT_CIPHER_AES_CCMP) { | ||
| 129 | put_unaligned_le16((pn & 0xffff), &iv_data[0]); | ||
| 130 | } | ||
| 91 | } | 131 | } |
| 92 | 132 | ||
| 93 | mt76_wr_copy(dev, MT_WCID_IV(idx), iv_data, sizeof(iv_data)); | 133 | mt76_wr_copy(dev, MT_WCID_IV(idx), iv_data, sizeof(iv_data)); |
| @@ -920,6 +960,7 @@ void mt76x02_edcca_init(struct mt76x02_dev *dev, bool enable) | |||
| 920 | } | 960 | } |
| 921 | } | 961 | } |
| 922 | mt76x02_edcca_tx_enable(dev, true); | 962 | mt76x02_edcca_tx_enable(dev, true); |
| 963 | dev->ed_monitor_learning = true; | ||
| 923 | 964 | ||
| 924 | /* clear previous CCA timer value */ | 965 | /* clear previous CCA timer value */ |
| 925 | mt76_rr(dev, MT_ED_CCA_TIMER); | 966 | mt76_rr(dev, MT_ED_CCA_TIMER); |
| @@ -929,6 +970,10 @@ EXPORT_SYMBOL_GPL(mt76x02_edcca_init); | |||
| 929 | 970 | ||
| 930 | #define MT_EDCCA_TH 92 | 971 | #define MT_EDCCA_TH 92 |
| 931 | #define MT_EDCCA_BLOCK_TH 2 | 972 | #define MT_EDCCA_BLOCK_TH 2 |
| 973 | #define MT_EDCCA_LEARN_TH 50 | ||
| 974 | #define MT_EDCCA_LEARN_CCA 180 | ||
| 975 | #define MT_EDCCA_LEARN_TIMEOUT (20 * HZ) | ||
| 976 | |||
| 932 | static void mt76x02_edcca_check(struct mt76x02_dev *dev) | 977 | static void mt76x02_edcca_check(struct mt76x02_dev *dev) |
| 933 | { | 978 | { |
| 934 | ktime_t cur_time; | 979 | ktime_t cur_time; |
| @@ -951,11 +996,23 @@ static void mt76x02_edcca_check(struct mt76x02_dev *dev) | |||
| 951 | dev->ed_trigger = 0; | 996 | dev->ed_trigger = 0; |
| 952 | } | 997 | } |
| 953 | 998 | ||
| 954 | if (dev->ed_trigger > MT_EDCCA_BLOCK_TH && | 999 | if (dev->cal.agc_lowest_gain && |
| 955 | !dev->ed_tx_blocked) | 1000 | dev->cal.false_cca > MT_EDCCA_LEARN_CCA && |
| 1001 | dev->ed_trigger > MT_EDCCA_LEARN_TH) { | ||
| 1002 | dev->ed_monitor_learning = false; | ||
| 1003 | dev->ed_trigger_timeout = jiffies + 20 * HZ; | ||
| 1004 | } else if (!dev->ed_monitor_learning && | ||
| 1005 | time_is_after_jiffies(dev->ed_trigger_timeout)) { | ||
| 1006 | dev->ed_monitor_learning = true; | ||
| 1007 | mt76x02_edcca_tx_enable(dev, true); | ||
| 1008 | } | ||
| 1009 | |||
| 1010 | if (dev->ed_monitor_learning) | ||
| 1011 | return; | ||
| 1012 | |||
| 1013 | if (dev->ed_trigger > MT_EDCCA_BLOCK_TH && !dev->ed_tx_blocked) | ||
| 956 | mt76x02_edcca_tx_enable(dev, false); | 1014 | mt76x02_edcca_tx_enable(dev, false); |
| 957 | else if (dev->ed_silent > MT_EDCCA_BLOCK_TH && | 1015 | else if (dev->ed_silent > MT_EDCCA_BLOCK_TH && dev->ed_tx_blocked) |
| 958 | dev->ed_tx_blocked) | ||
| 959 | mt76x02_edcca_tx_enable(dev, true); | 1016 | mt76x02_edcca_tx_enable(dev, true); |
| 960 | } | 1017 | } |
| 961 | 1018 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h index 6b1f25d2f64c..caeeef96c42f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h | |||
| @@ -177,6 +177,8 @@ int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx, | |||
| 177 | u8 key_idx, struct ieee80211_key_conf *key); | 177 | u8 key_idx, struct ieee80211_key_conf *key); |
| 178 | int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, | 178 | int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, |
| 179 | struct ieee80211_key_conf *key); | 179 | struct ieee80211_key_conf *key); |
| 180 | void mt76x02_mac_wcid_sync_pn(struct mt76x02_dev *dev, u8 idx, | ||
| 181 | struct ieee80211_key_conf *key); | ||
| 180 | void mt76x02_mac_wcid_setup(struct mt76x02_dev *dev, u8 idx, u8 vif_idx, | 182 | void mt76x02_mac_wcid_setup(struct mt76x02_dev *dev, u8 idx, u8 vif_idx, |
| 181 | u8 *mac); | 183 | u8 *mac); |
| 182 | void mt76x02_mac_wcid_set_drop(struct mt76x02_dev *dev, u8 idx, bool drop); | 184 | void mt76x02_mac_wcid_set_drop(struct mt76x02_dev *dev, u8 idx, bool drop); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c index 1229f19f2b02..daaed1220147 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/irq.h> | 19 | #include <linux/irq.h> |
| 20 | 20 | ||
| 21 | #include "mt76x02.h" | 21 | #include "mt76x02.h" |
| 22 | #include "mt76x02_mcu.h" | ||
| 22 | #include "mt76x02_trace.h" | 23 | #include "mt76x02_trace.h" |
| 23 | 24 | ||
| 24 | struct beacon_bc_data { | 25 | struct beacon_bc_data { |
| @@ -418,9 +419,66 @@ static bool mt76x02_tx_hang(struct mt76x02_dev *dev) | |||
| 418 | return i < 4; | 419 | return i < 4; |
| 419 | } | 420 | } |
| 420 | 421 | ||
| 422 | static void mt76x02_key_sync(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | ||
| 423 | struct ieee80211_sta *sta, | ||
| 424 | struct ieee80211_key_conf *key, void *data) | ||
| 425 | { | ||
| 426 | struct mt76x02_dev *dev = hw->priv; | ||
| 427 | struct mt76_wcid *wcid; | ||
| 428 | |||
| 429 | if (!sta) | ||
| 430 | return; | ||
| 431 | |||
| 432 | wcid = (struct mt76_wcid *) sta->drv_priv; | ||
| 433 | |||
| 434 | if (wcid->hw_key_idx != key->keyidx || wcid->sw_iv) | ||
| 435 | return; | ||
| 436 | |||
| 437 | mt76x02_mac_wcid_sync_pn(dev, wcid->idx, key); | ||
| 438 | } | ||
| 439 | |||
| 440 | static void mt76x02_reset_state(struct mt76x02_dev *dev) | ||
| 441 | { | ||
| 442 | int i; | ||
| 443 | |||
| 444 | lockdep_assert_held(&dev->mt76.mutex); | ||
| 445 | |||
| 446 | clear_bit(MT76_STATE_RUNNING, &dev->mt76.state); | ||
| 447 | |||
| 448 | rcu_read_lock(); | ||
| 449 | ieee80211_iter_keys_rcu(dev->mt76.hw, NULL, mt76x02_key_sync, NULL); | ||
| 450 | rcu_read_unlock(); | ||
| 451 | |||
| 452 | for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid); i++) { | ||
| 453 | struct ieee80211_sta *sta; | ||
| 454 | struct ieee80211_vif *vif; | ||
| 455 | struct mt76x02_sta *msta; | ||
| 456 | struct mt76_wcid *wcid; | ||
| 457 | void *priv; | ||
| 458 | |||
| 459 | wcid = rcu_dereference_protected(dev->mt76.wcid[i], | ||
| 460 | lockdep_is_held(&dev->mt76.mutex)); | ||
| 461 | if (!wcid) | ||
| 462 | continue; | ||
| 463 | |||
| 464 | priv = msta = container_of(wcid, struct mt76x02_sta, wcid); | ||
| 465 | sta = container_of(priv, struct ieee80211_sta, drv_priv); | ||
| 466 | |||
| 467 | priv = msta->vif; | ||
| 468 | vif = container_of(priv, struct ieee80211_vif, drv_priv); | ||
| 469 | |||
| 470 | __mt76_sta_remove(&dev->mt76, vif, sta); | ||
| 471 | memset(msta, 0, sizeof(*msta)); | ||
| 472 | } | ||
| 473 | |||
| 474 | dev->vif_mask = 0; | ||
| 475 | dev->beacon_mask = 0; | ||
| 476 | } | ||
| 477 | |||
| 421 | static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) | 478 | static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) |
| 422 | { | 479 | { |
| 423 | u32 mask = dev->mt76.mmio.irqmask; | 480 | u32 mask = dev->mt76.mmio.irqmask; |
| 481 | bool restart = dev->mt76.mcu_ops->mcu_restart; | ||
| 424 | int i; | 482 | int i; |
| 425 | 483 | ||
| 426 | ieee80211_stop_queues(dev->mt76.hw); | 484 | ieee80211_stop_queues(dev->mt76.hw); |
| @@ -434,6 +492,9 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) | |||
| 434 | 492 | ||
| 435 | mutex_lock(&dev->mt76.mutex); | 493 | mutex_lock(&dev->mt76.mutex); |
| 436 | 494 | ||
| 495 | if (restart) | ||
| 496 | mt76x02_reset_state(dev); | ||
| 497 | |||
| 437 | if (dev->beacon_mask) | 498 | if (dev->beacon_mask) |
| 438 | mt76_clear(dev, MT_BEACON_TIME_CFG, | 499 | mt76_clear(dev, MT_BEACON_TIME_CFG, |
| 439 | MT_BEACON_TIME_CFG_BEACON_TX | | 500 | MT_BEACON_TIME_CFG_BEACON_TX | |
| @@ -452,20 +513,21 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) | |||
| 452 | /* let fw reset DMA */ | 513 | /* let fw reset DMA */ |
| 453 | mt76_set(dev, 0x734, 0x3); | 514 | mt76_set(dev, 0x734, 0x3); |
| 454 | 515 | ||
| 516 | if (restart) | ||
| 517 | dev->mt76.mcu_ops->mcu_restart(&dev->mt76); | ||
| 518 | |||
| 455 | for (i = 0; i < ARRAY_SIZE(dev->mt76.q_tx); i++) | 519 | for (i = 0; i < ARRAY_SIZE(dev->mt76.q_tx); i++) |
| 456 | mt76_queue_tx_cleanup(dev, i, true); | 520 | mt76_queue_tx_cleanup(dev, i, true); |
| 457 | 521 | ||
| 458 | for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++) | 522 | for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++) |
| 459 | mt76_queue_rx_reset(dev, i); | 523 | mt76_queue_rx_reset(dev, i); |
| 460 | 524 | ||
| 461 | mt76_wr(dev, MT_MAC_SYS_CTRL, | 525 | mt76x02_mac_start(dev); |
| 462 | MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX); | 526 | |
| 463 | mt76_set(dev, MT_WPDMA_GLO_CFG, | ||
| 464 | MT_WPDMA_GLO_CFG_TX_DMA_EN | MT_WPDMA_GLO_CFG_RX_DMA_EN); | ||
| 465 | if (dev->ed_monitor) | 527 | if (dev->ed_monitor) |
| 466 | mt76_set(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN); | 528 | mt76_set(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN); |
| 467 | 529 | ||
| 468 | if (dev->beacon_mask) | 530 | if (dev->beacon_mask && !restart) |
| 469 | mt76_set(dev, MT_BEACON_TIME_CFG, | 531 | mt76_set(dev, MT_BEACON_TIME_CFG, |
| 470 | MT_BEACON_TIME_CFG_BEACON_TX | | 532 | MT_BEACON_TIME_CFG_BEACON_TX | |
| 471 | MT_BEACON_TIME_CFG_TBTT_EN); | 533 | MT_BEACON_TIME_CFG_TBTT_EN); |
| @@ -486,9 +548,13 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) | |||
| 486 | napi_schedule(&dev->mt76.napi[i]); | 548 | napi_schedule(&dev->mt76.napi[i]); |
| 487 | } | 549 | } |
| 488 | 550 | ||
| 489 | ieee80211_wake_queues(dev->mt76.hw); | 551 | if (restart) { |
| 490 | 552 | mt76x02_mcu_function_select(dev, Q_SELECT, 1); | |
| 491 | mt76_txq_schedule_all(&dev->mt76); | 553 | ieee80211_restart_hw(dev->mt76.hw); |
| 554 | } else { | ||
| 555 | ieee80211_wake_queues(dev->mt76.hw); | ||
| 556 | mt76_txq_schedule_all(&dev->mt76); | ||
| 557 | } | ||
| 492 | } | 558 | } |
| 493 | 559 | ||
| 494 | static void mt76x02_check_tx_hang(struct mt76x02_dev *dev) | 560 | static void mt76x02_check_tx_hang(struct mt76x02_dev *dev) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c index a020c757ba5c..a54b63a96eae 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | |||
| @@ -194,6 +194,8 @@ bool mt76x02_phy_adjust_vga_gain(struct mt76x02_dev *dev) | |||
| 194 | ret = true; | 194 | ret = true; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | dev->cal.agc_lowest_gain = dev->cal.agc_gain_adjust >= limit; | ||
| 198 | |||
| 197 | return ret; | 199 | return ret; |
| 198 | } | 200 | } |
| 199 | EXPORT_SYMBOL_GPL(mt76x02_phy_adjust_vga_gain); | 201 | EXPORT_SYMBOL_GPL(mt76x02_phy_adjust_vga_gain); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c index 43f07461c8d3..6fb52b596d42 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c | |||
| @@ -85,8 +85,9 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data, | |||
| 85 | 85 | ||
| 86 | mt76x02_insert_hdr_pad(skb); | 86 | mt76x02_insert_hdr_pad(skb); |
| 87 | 87 | ||
| 88 | txwi = skb_push(skb, sizeof(struct mt76x02_txwi)); | 88 | txwi = (struct mt76x02_txwi *)(skb->data - sizeof(struct mt76x02_txwi)); |
| 89 | mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len); | 89 | mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len); |
| 90 | skb_push(skb, sizeof(struct mt76x02_txwi)); | ||
| 90 | 91 | ||
| 91 | pid = mt76_tx_status_skb_add(mdev, wcid, skb); | 92 | pid = mt76_tx_status_skb_add(mdev, wcid, skb); |
| 92 | txwi->pktid = pid; | 93 | txwi->pktid = pid; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c index a48c261b0c63..cd072ac614f7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c | |||
| @@ -237,6 +237,8 @@ int mt76x02_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, | |||
| 237 | struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; | 237 | struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; |
| 238 | int idx = 0; | 238 | int idx = 0; |
| 239 | 239 | ||
| 240 | memset(msta, 0, sizeof(*msta)); | ||
| 241 | |||
| 240 | idx = mt76_wcid_alloc(dev->mt76.wcid_mask, ARRAY_SIZE(dev->mt76.wcid)); | 242 | idx = mt76_wcid_alloc(dev->mt76.wcid_mask, ARRAY_SIZE(dev->mt76.wcid)); |
| 241 | if (idx < 0) | 243 | if (idx < 0) |
| 242 | return -ENOSPC; | 244 | return -ENOSPC; |
| @@ -274,6 +276,8 @@ mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif, | |||
| 274 | struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; | 276 | struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; |
| 275 | struct mt76_txq *mtxq; | 277 | struct mt76_txq *mtxq; |
| 276 | 278 | ||
| 279 | memset(mvif, 0, sizeof(*mvif)); | ||
| 280 | |||
| 277 | mvif->idx = idx; | 281 | mvif->idx = idx; |
| 278 | mvif->group_wcid.idx = MT_VIF_WCID(idx); | 282 | mvif->group_wcid.idx = MT_VIF_WCID(idx); |
| 279 | mvif->group_wcid.hw_key_idx = -1; | 283 | mvif->group_wcid.hw_key_idx = -1; |
| @@ -289,6 +293,12 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |||
| 289 | struct mt76x02_dev *dev = hw->priv; | 293 | struct mt76x02_dev *dev = hw->priv; |
| 290 | unsigned int idx = 0; | 294 | unsigned int idx = 0; |
| 291 | 295 | ||
| 296 | /* Allow to change address in HW if we create first interface. */ | ||
| 297 | if (!dev->vif_mask && | ||
| 298 | (((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) || | ||
| 299 | memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1))) | ||
| 300 | mt76x02_mac_setaddr(dev, vif->addr); | ||
| 301 | |||
| 292 | if (vif->addr[0] & BIT(1)) | 302 | if (vif->addr[0] & BIT(1)) |
| 293 | idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7); | 303 | idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7); |
| 294 | 304 | ||
| @@ -311,10 +321,6 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |||
| 311 | if (dev->vif_mask & BIT(idx)) | 321 | if (dev->vif_mask & BIT(idx)) |
| 312 | return -EBUSY; | 322 | return -EBUSY; |
| 313 | 323 | ||
| 314 | /* Allow to change address in HW if we create first interface. */ | ||
| 315 | if (!dev->vif_mask && !ether_addr_equal(dev->mt76.macaddr, vif->addr)) | ||
| 316 | mt76x02_mac_setaddr(dev, vif->addr); | ||
| 317 | |||
| 318 | dev->vif_mask |= BIT(idx); | 324 | dev->vif_mask |= BIT(idx); |
| 319 | 325 | ||
| 320 | mt76x02_vif_init(dev, vif, idx); | 326 | mt76x02_vif_init(dev, vif, idx); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/init.c index f8534362e2c8..a30ef2c5a9db 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/init.c | |||
| @@ -106,7 +106,7 @@ void mt76_write_mac_initvals(struct mt76x02_dev *dev) | |||
| 106 | { MT_TX_SW_CFG1, 0x00010000 }, | 106 | { MT_TX_SW_CFG1, 0x00010000 }, |
| 107 | { MT_TX_SW_CFG2, 0x00000000 }, | 107 | { MT_TX_SW_CFG2, 0x00000000 }, |
| 108 | { MT_TXOP_CTRL_CFG, 0x0400583f }, | 108 | { MT_TXOP_CTRL_CFG, 0x0400583f }, |
| 109 | { MT_TX_RTS_CFG, 0x00100020 }, | 109 | { MT_TX_RTS_CFG, 0x00ffff20 }, |
| 110 | { MT_TX_TIMEOUT_CFG, 0x000a2290 }, | 110 | { MT_TX_TIMEOUT_CFG, 0x000a2290 }, |
| 111 | { MT_TX_RETRY_CFG, 0x47f01f0f }, | 111 | { MT_TX_RETRY_CFG, 0x47f01f0f }, |
| 112 | { MT_EXP_ACK_TIME, 0x002c00dc }, | 112 | { MT_EXP_ACK_TIME, 0x002c00dc }, |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h index 6c619f1c65c9..d7abe3d73bad 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h | |||
| @@ -71,6 +71,7 @@ int mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level, | |||
| 71 | 71 | ||
| 72 | void mt76x2_cleanup(struct mt76x02_dev *dev); | 72 | void mt76x2_cleanup(struct mt76x02_dev *dev); |
| 73 | 73 | ||
| 74 | int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard); | ||
| 74 | void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable); | 75 | void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable); |
| 75 | void mt76x2_init_txpower(struct mt76x02_dev *dev, | 76 | void mt76x2_init_txpower(struct mt76x02_dev *dev, |
| 76 | struct ieee80211_supported_band *sband); | 77 | struct ieee80211_supported_band *sband); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c index 984d9c4c2e1a..d3927a13e92e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c | |||
| @@ -77,7 +77,7 @@ mt76x2_fixup_xtal(struct mt76x02_dev *dev) | |||
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard) | 80 | int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard) |
| 81 | { | 81 | { |
| 82 | const u8 *macaddr = dev->mt76.macaddr; | 82 | const u8 *macaddr = dev->mt76.macaddr; |
| 83 | u32 val; | 83 | u32 val; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c index 03e24ae7f66c..605dc66ae83b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c | |||
| @@ -165,9 +165,30 @@ error: | |||
| 165 | return -ENOENT; | 165 | return -ENOENT; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | static int | ||
| 169 | mt76pci_mcu_restart(struct mt76_dev *mdev) | ||
| 170 | { | ||
| 171 | struct mt76x02_dev *dev; | ||
| 172 | int ret; | ||
| 173 | |||
| 174 | dev = container_of(mdev, struct mt76x02_dev, mt76); | ||
| 175 | |||
| 176 | mt76x02_mcu_cleanup(dev); | ||
| 177 | mt76x2_mac_reset(dev, true); | ||
| 178 | |||
| 179 | ret = mt76pci_load_firmware(dev); | ||
| 180 | if (ret) | ||
| 181 | return ret; | ||
| 182 | |||
| 183 | mt76_wr(dev, MT_WPDMA_RST_IDX, ~0); | ||
| 184 | |||
| 185 | return 0; | ||
| 186 | } | ||
| 187 | |||
| 168 | int mt76x2_mcu_init(struct mt76x02_dev *dev) | 188 | int mt76x2_mcu_init(struct mt76x02_dev *dev) |
| 169 | { | 189 | { |
| 170 | static const struct mt76_mcu_ops mt76x2_mcu_ops = { | 190 | static const struct mt76_mcu_ops mt76x2_mcu_ops = { |
| 191 | .mcu_restart = mt76pci_mcu_restart, | ||
| 171 | .mcu_send_msg = mt76x02_mcu_msg_send, | 192 | .mcu_send_msg = mt76x02_mcu_msg_send, |
| 172 | }; | 193 | }; |
| 173 | int ret; | 194 | int ret; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c index 1848e8ab2e21..769a9b972044 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c | |||
| @@ -260,10 +260,15 @@ mt76x2_phy_set_gain_val(struct mt76x02_dev *dev) | |||
| 260 | gain_val[0] = dev->cal.agc_gain_cur[0] - dev->cal.agc_gain_adjust; | 260 | gain_val[0] = dev->cal.agc_gain_cur[0] - dev->cal.agc_gain_adjust; |
| 261 | gain_val[1] = dev->cal.agc_gain_cur[1] - dev->cal.agc_gain_adjust; | 261 | gain_val[1] = dev->cal.agc_gain_cur[1] - dev->cal.agc_gain_adjust; |
| 262 | 262 | ||
| 263 | if (dev->mt76.chandef.width >= NL80211_CHAN_WIDTH_40) | 263 | val = 0x1836 << 16; |
| 264 | if (!mt76x2_has_ext_lna(dev) && | ||
| 265 | dev->mt76.chandef.width >= NL80211_CHAN_WIDTH_40) | ||
| 264 | val = 0x1e42 << 16; | 266 | val = 0x1e42 << 16; |
| 265 | else | 267 | |
| 266 | val = 0x1836 << 16; | 268 | if (mt76x2_has_ext_lna(dev) && |
| 269 | dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ && | ||
| 270 | dev->mt76.chandef.width < NL80211_CHAN_WIDTH_40) | ||
| 271 | val = 0x0f36 << 16; | ||
| 267 | 272 | ||
| 268 | val |= 0xf8; | 273 | val |= 0xf8; |
| 269 | 274 | ||
| @@ -280,6 +285,7 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) | |||
| 280 | { | 285 | { |
| 281 | u8 *gain = dev->cal.agc_gain_init; | 286 | u8 *gain = dev->cal.agc_gain_init; |
| 282 | u8 low_gain_delta, gain_delta; | 287 | u8 low_gain_delta, gain_delta; |
| 288 | u32 agc_35, agc_37; | ||
| 283 | bool gain_change; | 289 | bool gain_change; |
| 284 | int low_gain; | 290 | int low_gain; |
| 285 | u32 val; | 291 | u32 val; |
| @@ -318,6 +324,16 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) | |||
| 318 | else | 324 | else |
| 319 | low_gain_delta = 14; | 325 | low_gain_delta = 14; |
| 320 | 326 | ||
| 327 | agc_37 = 0x2121262c; | ||
| 328 | if (dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ) | ||
| 329 | agc_35 = 0x11111516; | ||
| 330 | else if (low_gain == 2) | ||
| 331 | agc_35 = agc_37 = 0x08080808; | ||
| 332 | else if (dev->mt76.chandef.width == NL80211_CHAN_WIDTH_80) | ||
| 333 | agc_35 = 0x10101014; | ||
| 334 | else | ||
| 335 | agc_35 = 0x11111116; | ||
| 336 | |||
| 321 | if (low_gain == 2) { | 337 | if (low_gain == 2) { |
| 322 | mt76_wr(dev, MT_BBP(RXO, 18), 0xf000a990); | 338 | mt76_wr(dev, MT_BBP(RXO, 18), 0xf000a990); |
| 323 | mt76_wr(dev, MT_BBP(AGC, 35), 0x08080808); | 339 | mt76_wr(dev, MT_BBP(AGC, 35), 0x08080808); |
| @@ -326,15 +342,13 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) | |||
| 326 | dev->cal.agc_gain_adjust = 0; | 342 | dev->cal.agc_gain_adjust = 0; |
| 327 | } else { | 343 | } else { |
| 328 | mt76_wr(dev, MT_BBP(RXO, 18), 0xf000a991); | 344 | mt76_wr(dev, MT_BBP(RXO, 18), 0xf000a991); |
| 329 | if (dev->mt76.chandef.width == NL80211_CHAN_WIDTH_80) | ||
| 330 | mt76_wr(dev, MT_BBP(AGC, 35), 0x10101014); | ||
| 331 | else | ||
| 332 | mt76_wr(dev, MT_BBP(AGC, 35), 0x11111116); | ||
| 333 | mt76_wr(dev, MT_BBP(AGC, 37), 0x2121262C); | ||
| 334 | gain_delta = 0; | 345 | gain_delta = 0; |
| 335 | dev->cal.agc_gain_adjust = low_gain_delta; | 346 | dev->cal.agc_gain_adjust = low_gain_delta; |
| 336 | } | 347 | } |
| 337 | 348 | ||
| 349 | mt76_wr(dev, MT_BBP(AGC, 35), agc_35); | ||
| 350 | mt76_wr(dev, MT_BBP(AGC, 37), agc_37); | ||
| 351 | |||
| 338 | dev->cal.agc_gain_cur[0] = gain[0] - gain_delta; | 352 | dev->cal.agc_gain_cur[0] = gain[0] - gain_delta; |
| 339 | dev->cal.agc_gain_cur[1] = gain[1] - gain_delta; | 353 | dev->cal.agc_gain_cur[1] = gain[1] - gain_delta; |
| 340 | mt76x2_phy_set_gain_val(dev); | 354 | mt76x2_phy_set_gain_val(dev); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c index ddb6b2c48e01..ac0f13d46299 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c | |||
| @@ -21,11 +21,10 @@ | |||
| 21 | #include "mt76x2u.h" | 21 | #include "mt76x2u.h" |
| 22 | 22 | ||
| 23 | static const struct usb_device_id mt76x2u_device_table[] = { | 23 | static const struct usb_device_id mt76x2u_device_table[] = { |
| 24 | { USB_DEVICE(0x0e8d, 0x7612) }, /* Alfa AWUS036ACM */ | ||
| 25 | { USB_DEVICE(0x0b05, 0x1833) }, /* Asus USB-AC54 */ | 24 | { USB_DEVICE(0x0b05, 0x1833) }, /* Asus USB-AC54 */ |
| 26 | { USB_DEVICE(0x0b05, 0x17eb) }, /* Asus USB-AC55 */ | 25 | { USB_DEVICE(0x0b05, 0x17eb) }, /* Asus USB-AC55 */ |
| 27 | { USB_DEVICE(0x0b05, 0x180b) }, /* Asus USB-N53 B1 */ | 26 | { USB_DEVICE(0x0b05, 0x180b) }, /* Asus USB-N53 B1 */ |
| 28 | { USB_DEVICE(0x0e8d, 0x7612) }, /* Aukey USB-AC1200 */ | 27 | { USB_DEVICE(0x0e8d, 0x7612) }, /* Aukey USBAC1200 - Alfa AWUS036ACM */ |
| 29 | { USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */ | 28 | { USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */ |
| 30 | { USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */ | 29 | { USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */ |
| 31 | { USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */ | 30 | { USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */ |
| @@ -66,6 +65,10 @@ static int mt76x2u_probe(struct usb_interface *intf, | |||
| 66 | 65 | ||
| 67 | mdev->rev = mt76_rr(dev, MT_ASIC_VERSION); | 66 | mdev->rev = mt76_rr(dev, MT_ASIC_VERSION); |
| 68 | dev_info(mdev->dev, "ASIC revision: %08x\n", mdev->rev); | 67 | dev_info(mdev->dev, "ASIC revision: %08x\n", mdev->rev); |
| 68 | if (!is_mt76x2(dev)) { | ||
| 69 | err = -ENODEV; | ||
| 70 | goto err; | ||
| 71 | } | ||
| 69 | 72 | ||
| 70 | err = mt76x2u_register_device(dev); | 73 | err = mt76x2u_register_device(dev); |
| 71 | if (err < 0) | 74 | if (err < 0) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c index 5e84b4535cb1..3b82345756ea 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c | |||
| @@ -93,7 +93,6 @@ int mt76x2u_mac_reset(struct mt76x02_dev *dev) | |||
| 93 | mt76_wr(dev, MT_TX_LINK_CFG, 0x1020); | 93 | mt76_wr(dev, MT_TX_LINK_CFG, 0x1020); |
| 94 | mt76_wr(dev, MT_AUTO_RSP_CFG, 0x13); | 94 | mt76_wr(dev, MT_AUTO_RSP_CFG, 0x13); |
| 95 | mt76_wr(dev, MT_MAX_LEN_CFG, 0x2f00); | 95 | mt76_wr(dev, MT_MAX_LEN_CFG, 0x2f00); |
| 96 | mt76_wr(dev, MT_TX_RTS_CFG, 0x92b20); | ||
| 97 | 96 | ||
| 98 | mt76_wr(dev, MT_WMM_AIFSN, 0x2273); | 97 | mt76_wr(dev, MT_WMM_AIFSN, 0x2273); |
| 99 | mt76_wr(dev, MT_WMM_CWMIN, 0x2344); | 98 | mt76_wr(dev, MT_WMM_CWMIN, 0x2344); |
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c index 5a349fe3e576..2585df512335 100644 --- a/drivers/net/wireless/mediatek/mt76/tx.c +++ b/drivers/net/wireless/mediatek/mt76/tx.c | |||
| @@ -289,8 +289,11 @@ mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta, | |||
| 289 | dev->queue_ops->tx_queue_skb(dev, q, skb, wcid, sta); | 289 | dev->queue_ops->tx_queue_skb(dev, q, skb, wcid, sta); |
| 290 | dev->queue_ops->kick(dev, q); | 290 | dev->queue_ops->kick(dev, q); |
| 291 | 291 | ||
| 292 | if (q->queued > q->ndesc - 8) | 292 | if (q->queued > q->ndesc - 8 && !q->stopped) { |
| 293 | ieee80211_stop_queue(dev->hw, skb_get_queue_mapping(skb)); | 293 | ieee80211_stop_queue(dev->hw, skb_get_queue_mapping(skb)); |
| 294 | q->stopped = true; | ||
| 295 | } | ||
| 296 | |||
| 294 | spin_unlock_bh(&q->lock); | 297 | spin_unlock_bh(&q->lock); |
| 295 | } | 298 | } |
| 296 | EXPORT_SYMBOL_GPL(mt76_tx); | 299 | EXPORT_SYMBOL_GPL(mt76_tx); |
| @@ -374,7 +377,10 @@ mt76_release_buffered_frames(struct ieee80211_hw *hw, struct ieee80211_sta *sta, | |||
| 374 | if (last_skb) { | 377 | if (last_skb) { |
| 375 | mt76_queue_ps_skb(dev, sta, last_skb, true); | 378 | mt76_queue_ps_skb(dev, sta, last_skb, true); |
| 376 | dev->queue_ops->kick(dev, hwq); | 379 | dev->queue_ops->kick(dev, hwq); |
| 380 | } else { | ||
| 381 | ieee80211_sta_eosp(sta); | ||
| 377 | } | 382 | } |
| 383 | |||
| 378 | spin_unlock_bh(&hwq->lock); | 384 | spin_unlock_bh(&hwq->lock); |
| 379 | } | 385 | } |
| 380 | EXPORT_SYMBOL_GPL(mt76_release_buffered_frames); | 386 | EXPORT_SYMBOL_GPL(mt76_release_buffered_frames); |
| @@ -577,6 +583,9 @@ void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) | |||
| 577 | struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv; | 583 | struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv; |
| 578 | struct mt76_queue *hwq = mtxq->hwq; | 584 | struct mt76_queue *hwq = mtxq->hwq; |
| 579 | 585 | ||
| 586 | if (!test_bit(MT76_STATE_RUNNING, &dev->state)) | ||
| 587 | return; | ||
| 588 | |||
| 580 | spin_lock_bh(&hwq->lock); | 589 | spin_lock_bh(&hwq->lock); |
| 581 | if (list_empty(&mtxq->list)) | 590 | if (list_empty(&mtxq->list)) |
| 582 | list_add_tail(&mtxq->list, &hwq->swq); | 591 | list_add_tail(&mtxq->list, &hwq->swq); |
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index ae6ada370597..4c1abd492405 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c | |||
| @@ -655,7 +655,11 @@ static void mt76u_tx_tasklet(unsigned long data) | |||
| 655 | spin_lock_bh(&q->lock); | 655 | spin_lock_bh(&q->lock); |
| 656 | } | 656 | } |
| 657 | mt76_txq_schedule(dev, q); | 657 | mt76_txq_schedule(dev, q); |
| 658 | wake = i < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; | 658 | |
| 659 | wake = q->stopped && q->queued < q->ndesc - 8; | ||
| 660 | if (wake) | ||
| 661 | q->stopped = false; | ||
| 662 | |||
| 659 | if (!q->queued) | 663 | if (!q->queued) |
| 660 | wake_up(&dev->tx_wait); | 664 | wake_up(&dev->tx_wait); |
| 661 | 665 | ||
diff --git a/drivers/net/wireless/mediatek/mt7601u/usb.c b/drivers/net/wireless/mediatek/mt7601u/usb.c index d8b7863f7926..6ae7f14dc9bf 100644 --- a/drivers/net/wireless/mediatek/mt7601u/usb.c +++ b/drivers/net/wireless/mediatek/mt7601u/usb.c | |||
| @@ -303,6 +303,10 @@ static int mt7601u_probe(struct usb_interface *usb_intf, | |||
| 303 | mac_rev = mt7601u_rr(dev, MT_MAC_CSR0); | 303 | mac_rev = mt7601u_rr(dev, MT_MAC_CSR0); |
| 304 | dev_info(dev->dev, "ASIC revision: %08x MAC revision: %08x\n", | 304 | dev_info(dev->dev, "ASIC revision: %08x MAC revision: %08x\n", |
| 305 | asic_rev, mac_rev); | 305 | asic_rev, mac_rev); |
| 306 | if ((asic_rev >> 16) != 0x7601) { | ||
| 307 | ret = -ENODEV; | ||
| 308 | goto err; | ||
| 309 | } | ||
| 306 | 310 | ||
| 307 | /* Note: vendor driver skips this check for MT7601U */ | 311 | /* Note: vendor driver skips this check for MT7601U */ |
| 308 | if (!(mt7601u_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) | 312 | if (!(mt7601u_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) |
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 2839bb70badf..f0716f6ce41f 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c | |||
| @@ -404,15 +404,12 @@ static inline bool nvme_state_is_live(enum nvme_ana_state state) | |||
| 404 | static void nvme_update_ns_ana_state(struct nvme_ana_group_desc *desc, | 404 | static void nvme_update_ns_ana_state(struct nvme_ana_group_desc *desc, |
| 405 | struct nvme_ns *ns) | 405 | struct nvme_ns *ns) |
| 406 | { | 406 | { |
| 407 | enum nvme_ana_state old; | ||
| 408 | |||
| 409 | mutex_lock(&ns->head->lock); | 407 | mutex_lock(&ns->head->lock); |
| 410 | old = ns->ana_state; | ||
| 411 | ns->ana_grpid = le32_to_cpu(desc->grpid); | 408 | ns->ana_grpid = le32_to_cpu(desc->grpid); |
| 412 | ns->ana_state = desc->state; | 409 | ns->ana_state = desc->state; |
| 413 | clear_bit(NVME_NS_ANA_PENDING, &ns->flags); | 410 | clear_bit(NVME_NS_ANA_PENDING, &ns->flags); |
| 414 | 411 | ||
| 415 | if (nvme_state_is_live(ns->ana_state) && !nvme_state_is_live(old)) | 412 | if (nvme_state_is_live(ns->ana_state)) |
| 416 | nvme_mpath_set_live(ns); | 413 | nvme_mpath_set_live(ns); |
| 417 | mutex_unlock(&ns->head->lock); | 414 | mutex_unlock(&ns->head->lock); |
| 418 | } | 415 | } |
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index e7e08889865e..68c49dd67210 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c | |||
| @@ -627,7 +627,7 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb, | |||
| 627 | return ret; | 627 | return ret; |
| 628 | } | 628 | } |
| 629 | 629 | ||
| 630 | static inline void nvme_tcp_end_request(struct request *rq, __le16 status) | 630 | static inline void nvme_tcp_end_request(struct request *rq, u16 status) |
| 631 | { | 631 | { |
| 632 | union nvme_result res = {}; | 632 | union nvme_result res = {}; |
| 633 | 633 | ||
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 2d73b66e3686..b3e765a95af8 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c | |||
| @@ -509,7 +509,7 @@ int nvmet_ns_enable(struct nvmet_ns *ns) | |||
| 509 | 509 | ||
| 510 | ret = nvmet_p2pmem_ns_enable(ns); | 510 | ret = nvmet_p2pmem_ns_enable(ns); |
| 511 | if (ret) | 511 | if (ret) |
| 512 | goto out_unlock; | 512 | goto out_dev_disable; |
| 513 | 513 | ||
| 514 | list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) | 514 | list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) |
| 515 | nvmet_p2pmem_ns_add_p2p(ctrl, ns); | 515 | nvmet_p2pmem_ns_add_p2p(ctrl, ns); |
| @@ -550,7 +550,7 @@ out_unlock: | |||
| 550 | out_dev_put: | 550 | out_dev_put: |
| 551 | list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) | 551 | list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) |
| 552 | pci_dev_put(radix_tree_delete(&ctrl->p2p_ns_map, ns->nsid)); | 552 | pci_dev_put(radix_tree_delete(&ctrl->p2p_ns_map, ns->nsid)); |
| 553 | 553 | out_dev_disable: | |
| 554 | nvmet_ns_dev_disable(ns); | 554 | nvmet_ns_dev_disable(ns); |
| 555 | goto out_unlock; | 555 | goto out_unlock; |
| 556 | } | 556 | } |
diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c index 3e43212d3c1c..bc6ebb51b0bf 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c | |||
| @@ -75,11 +75,11 @@ err: | |||
| 75 | return ret; | 75 | return ret; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | static void nvmet_file_init_bvec(struct bio_vec *bv, struct sg_page_iter *iter) | 78 | static void nvmet_file_init_bvec(struct bio_vec *bv, struct scatterlist *sg) |
| 79 | { | 79 | { |
| 80 | bv->bv_page = sg_page_iter_page(iter); | 80 | bv->bv_page = sg_page(sg); |
| 81 | bv->bv_offset = iter->sg->offset; | 81 | bv->bv_offset = sg->offset; |
| 82 | bv->bv_len = PAGE_SIZE - iter->sg->offset; | 82 | bv->bv_len = sg->length; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | static ssize_t nvmet_file_submit_bvec(struct nvmet_req *req, loff_t pos, | 85 | static ssize_t nvmet_file_submit_bvec(struct nvmet_req *req, loff_t pos, |
| @@ -128,14 +128,14 @@ static void nvmet_file_io_done(struct kiocb *iocb, long ret, long ret2) | |||
| 128 | 128 | ||
| 129 | static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags) | 129 | static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags) |
| 130 | { | 130 | { |
| 131 | ssize_t nr_bvec = DIV_ROUND_UP(req->data_len, PAGE_SIZE); | 131 | ssize_t nr_bvec = req->sg_cnt; |
| 132 | struct sg_page_iter sg_pg_iter; | ||
| 133 | unsigned long bv_cnt = 0; | 132 | unsigned long bv_cnt = 0; |
| 134 | bool is_sync = false; | 133 | bool is_sync = false; |
| 135 | size_t len = 0, total_len = 0; | 134 | size_t len = 0, total_len = 0; |
| 136 | ssize_t ret = 0; | 135 | ssize_t ret = 0; |
| 137 | loff_t pos; | 136 | loff_t pos; |
| 138 | 137 | int i; | |
| 138 | struct scatterlist *sg; | ||
| 139 | 139 | ||
| 140 | if (req->f.mpool_alloc && nr_bvec > NVMET_MAX_MPOOL_BVEC) | 140 | if (req->f.mpool_alloc && nr_bvec > NVMET_MAX_MPOOL_BVEC) |
| 141 | is_sync = true; | 141 | is_sync = true; |
| @@ -147,8 +147,8 @@ static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags) | |||
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | memset(&req->f.iocb, 0, sizeof(struct kiocb)); | 149 | memset(&req->f.iocb, 0, sizeof(struct kiocb)); |
| 150 | for_each_sg_page(req->sg, &sg_pg_iter, req->sg_cnt, 0) { | 150 | for_each_sg(req->sg, sg, req->sg_cnt, i) { |
| 151 | nvmet_file_init_bvec(&req->f.bvec[bv_cnt], &sg_pg_iter); | 151 | nvmet_file_init_bvec(&req->f.bvec[bv_cnt], sg); |
| 152 | len += req->f.bvec[bv_cnt].bv_len; | 152 | len += req->f.bvec[bv_cnt].bv_len; |
| 153 | total_len += req->f.bvec[bv_cnt].bv_len; | 153 | total_len += req->f.bvec[bv_cnt].bv_len; |
| 154 | bv_cnt++; | 154 | bv_cnt++; |
| @@ -225,7 +225,7 @@ static void nvmet_file_submit_buffered_io(struct nvmet_req *req) | |||
| 225 | 225 | ||
| 226 | static void nvmet_file_execute_rw(struct nvmet_req *req) | 226 | static void nvmet_file_execute_rw(struct nvmet_req *req) |
| 227 | { | 227 | { |
| 228 | ssize_t nr_bvec = DIV_ROUND_UP(req->data_len, PAGE_SIZE); | 228 | ssize_t nr_bvec = req->sg_cnt; |
| 229 | 229 | ||
| 230 | if (!req->sg_cnt || !nr_bvec) { | 230 | if (!req->sg_cnt || !nr_bvec) { |
| 231 | nvmet_req_complete(req, 0); | 231 | nvmet_req_complete(req, 0); |
diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c index 56dd83a45e55..5484a46dafda 100644 --- a/drivers/parport/daisy.c +++ b/drivers/parport/daisy.c | |||
| @@ -213,12 +213,10 @@ void parport_daisy_fini(struct parport *port) | |||
| 213 | struct pardevice *parport_open(int devnum, const char *name) | 213 | struct pardevice *parport_open(int devnum, const char *name) |
| 214 | { | 214 | { |
| 215 | struct daisydev *p = topology; | 215 | struct daisydev *p = topology; |
| 216 | struct pardev_cb par_cb; | ||
| 217 | struct parport *port; | 216 | struct parport *port; |
| 218 | struct pardevice *dev; | 217 | struct pardevice *dev; |
| 219 | int daisy; | 218 | int daisy; |
| 220 | 219 | ||
| 221 | memset(&par_cb, 0, sizeof(par_cb)); | ||
| 222 | spin_lock(&topology_lock); | 220 | spin_lock(&topology_lock); |
| 223 | while (p && p->devnum != devnum) | 221 | while (p && p->devnum != devnum) |
| 224 | p = p->next; | 222 | p = p->next; |
| @@ -232,7 +230,7 @@ struct pardevice *parport_open(int devnum, const char *name) | |||
| 232 | port = parport_get_port(p->port); | 230 | port = parport_get_port(p->port); |
| 233 | spin_unlock(&topology_lock); | 231 | spin_unlock(&topology_lock); |
| 234 | 232 | ||
| 235 | dev = parport_register_dev_model(port, name, &par_cb, devnum); | 233 | dev = parport_register_device(port, name, NULL, NULL, NULL, 0, NULL); |
| 236 | parport_put_port(port); | 234 | parport_put_port(port); |
| 237 | if (!dev) | 235 | if (!dev) |
| 238 | return NULL; | 236 | return NULL; |
| @@ -482,31 +480,3 @@ static int assign_addrs(struct parport *port) | |||
| 482 | kfree(deviceid); | 480 | kfree(deviceid); |
| 483 | return detected; | 481 | return detected; |
| 484 | } | 482 | } |
| 485 | |||
| 486 | static int daisy_drv_probe(struct pardevice *par_dev) | ||
| 487 | { | ||
| 488 | struct device_driver *drv = par_dev->dev.driver; | ||
| 489 | |||
| 490 | if (strcmp(drv->name, "daisy_drv")) | ||
| 491 | return -ENODEV; | ||
| 492 | if (strcmp(par_dev->name, daisy_dev_name)) | ||
| 493 | return -ENODEV; | ||
| 494 | |||
| 495 | return 0; | ||
| 496 | } | ||
| 497 | |||
| 498 | static struct parport_driver daisy_driver = { | ||
| 499 | .name = "daisy_drv", | ||
| 500 | .probe = daisy_drv_probe, | ||
| 501 | .devmodel = true, | ||
| 502 | }; | ||
| 503 | |||
| 504 | int daisy_drv_init(void) | ||
| 505 | { | ||
| 506 | return parport_register_driver(&daisy_driver); | ||
| 507 | } | ||
| 508 | |||
| 509 | void daisy_drv_exit(void) | ||
| 510 | { | ||
| 511 | parport_unregister_driver(&daisy_driver); | ||
| 512 | } | ||
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c index e5e6a463a941..e035174ba205 100644 --- a/drivers/parport/probe.c +++ b/drivers/parport/probe.c | |||
| @@ -257,7 +257,7 @@ static ssize_t parport_read_device_id (struct parport *port, char *buffer, | |||
| 257 | ssize_t parport_device_id (int devnum, char *buffer, size_t count) | 257 | ssize_t parport_device_id (int devnum, char *buffer, size_t count) |
| 258 | { | 258 | { |
| 259 | ssize_t retval = -ENXIO; | 259 | ssize_t retval = -ENXIO; |
| 260 | struct pardevice *dev = parport_open(devnum, daisy_dev_name); | 260 | struct pardevice *dev = parport_open (devnum, "Device ID probe"); |
| 261 | if (!dev) | 261 | if (!dev) |
| 262 | return -ENXIO; | 262 | return -ENXIO; |
| 263 | 263 | ||
diff --git a/drivers/parport/share.c b/drivers/parport/share.c index 0171b8dbcdcd..5dc53d420ca8 100644 --- a/drivers/parport/share.c +++ b/drivers/parport/share.c | |||
| @@ -137,19 +137,11 @@ static struct bus_type parport_bus_type = { | |||
| 137 | 137 | ||
| 138 | int parport_bus_init(void) | 138 | int parport_bus_init(void) |
| 139 | { | 139 | { |
| 140 | int retval; | 140 | return bus_register(&parport_bus_type); |
| 141 | |||
| 142 | retval = bus_register(&parport_bus_type); | ||
| 143 | if (retval) | ||
| 144 | return retval; | ||
| 145 | daisy_drv_init(); | ||
| 146 | |||
| 147 | return 0; | ||
| 148 | } | 141 | } |
| 149 | 142 | ||
| 150 | void parport_bus_exit(void) | 143 | void parport_bus_exit(void) |
| 151 | { | 144 | { |
| 152 | daisy_drv_exit(); | ||
| 153 | bus_unregister(&parport_bus_type); | 145 | bus_unregister(&parport_bus_type); |
| 154 | } | 146 | } |
| 155 | 147 | ||
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 224d88634115..d994839a3e24 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
| @@ -273,6 +273,7 @@ enum pcie_link_width pcie_get_width_cap(struct pci_dev *dev); | |||
| 273 | u32 pcie_bandwidth_capable(struct pci_dev *dev, enum pci_bus_speed *speed, | 273 | u32 pcie_bandwidth_capable(struct pci_dev *dev, enum pci_bus_speed *speed, |
| 274 | enum pcie_link_width *width); | 274 | enum pcie_link_width *width); |
| 275 | void __pcie_print_link_status(struct pci_dev *dev, bool verbose); | 275 | void __pcie_print_link_status(struct pci_dev *dev, bool verbose); |
| 276 | void pcie_report_downtraining(struct pci_dev *dev); | ||
| 276 | 277 | ||
| 277 | /* Single Root I/O Virtualization */ | 278 | /* Single Root I/O Virtualization */ |
| 278 | struct pci_sriov { | 279 | struct pci_sriov { |
diff --git a/drivers/pci/pcie/bw_notification.c b/drivers/pci/pcie/bw_notification.c index d2eae3b7cc0f..4fa9e3523ee1 100644 --- a/drivers/pci/pcie/bw_notification.c +++ b/drivers/pci/pcie/bw_notification.c | |||
| @@ -30,6 +30,8 @@ static void pcie_enable_link_bandwidth_notification(struct pci_dev *dev) | |||
| 30 | { | 30 | { |
| 31 | u16 lnk_ctl; | 31 | u16 lnk_ctl; |
| 32 | 32 | ||
| 33 | pcie_capability_write_word(dev, PCI_EXP_LNKSTA, PCI_EXP_LNKSTA_LBMS); | ||
| 34 | |||
| 33 | pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &lnk_ctl); | 35 | pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &lnk_ctl); |
| 34 | lnk_ctl |= PCI_EXP_LNKCTL_LBMIE; | 36 | lnk_ctl |= PCI_EXP_LNKCTL_LBMIE; |
| 35 | pcie_capability_write_word(dev, PCI_EXP_LNKCTL, lnk_ctl); | 37 | pcie_capability_write_word(dev, PCI_EXP_LNKCTL, lnk_ctl); |
| @@ -44,11 +46,10 @@ static void pcie_disable_link_bandwidth_notification(struct pci_dev *dev) | |||
| 44 | pcie_capability_write_word(dev, PCI_EXP_LNKCTL, lnk_ctl); | 46 | pcie_capability_write_word(dev, PCI_EXP_LNKCTL, lnk_ctl); |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | static irqreturn_t pcie_bw_notification_handler(int irq, void *context) | 49 | static irqreturn_t pcie_bw_notification_irq(int irq, void *context) |
| 48 | { | 50 | { |
| 49 | struct pcie_device *srv = context; | 51 | struct pcie_device *srv = context; |
| 50 | struct pci_dev *port = srv->port; | 52 | struct pci_dev *port = srv->port; |
| 51 | struct pci_dev *dev; | ||
| 52 | u16 link_status, events; | 53 | u16 link_status, events; |
| 53 | int ret; | 54 | int ret; |
| 54 | 55 | ||
| @@ -58,17 +59,26 @@ static irqreturn_t pcie_bw_notification_handler(int irq, void *context) | |||
| 58 | if (ret != PCIBIOS_SUCCESSFUL || !events) | 59 | if (ret != PCIBIOS_SUCCESSFUL || !events) |
| 59 | return IRQ_NONE; | 60 | return IRQ_NONE; |
| 60 | 61 | ||
| 62 | pcie_capability_write_word(port, PCI_EXP_LNKSTA, events); | ||
| 63 | pcie_update_link_speed(port->subordinate, link_status); | ||
| 64 | return IRQ_WAKE_THREAD; | ||
| 65 | } | ||
| 66 | |||
| 67 | static irqreturn_t pcie_bw_notification_handler(int irq, void *context) | ||
| 68 | { | ||
| 69 | struct pcie_device *srv = context; | ||
| 70 | struct pci_dev *port = srv->port; | ||
| 71 | struct pci_dev *dev; | ||
| 72 | |||
| 61 | /* | 73 | /* |
| 62 | * Print status from downstream devices, not this root port or | 74 | * Print status from downstream devices, not this root port or |
| 63 | * downstream switch port. | 75 | * downstream switch port. |
| 64 | */ | 76 | */ |
| 65 | down_read(&pci_bus_sem); | 77 | down_read(&pci_bus_sem); |
| 66 | list_for_each_entry(dev, &port->subordinate->devices, bus_list) | 78 | list_for_each_entry(dev, &port->subordinate->devices, bus_list) |
| 67 | __pcie_print_link_status(dev, false); | 79 | pcie_report_downtraining(dev); |
| 68 | up_read(&pci_bus_sem); | 80 | up_read(&pci_bus_sem); |
| 69 | 81 | ||
| 70 | pcie_update_link_speed(port->subordinate, link_status); | ||
| 71 | pcie_capability_write_word(port, PCI_EXP_LNKSTA, events); | ||
| 72 | return IRQ_HANDLED; | 82 | return IRQ_HANDLED; |
| 73 | } | 83 | } |
| 74 | 84 | ||
| @@ -80,7 +90,8 @@ static int pcie_bandwidth_notification_probe(struct pcie_device *srv) | |||
| 80 | if (!pcie_link_bandwidth_notification_supported(srv->port)) | 90 | if (!pcie_link_bandwidth_notification_supported(srv->port)) |
| 81 | return -ENODEV; | 91 | return -ENODEV; |
| 82 | 92 | ||
| 83 | ret = request_threaded_irq(srv->irq, NULL, pcie_bw_notification_handler, | 93 | ret = request_threaded_irq(srv->irq, pcie_bw_notification_irq, |
| 94 | pcie_bw_notification_handler, | ||
| 84 | IRQF_SHARED, "PCIe BW notif", srv); | 95 | IRQF_SHARED, "PCIe BW notif", srv); |
| 85 | if (ret) | 96 | if (ret) |
| 86 | return ret; | 97 | return ret; |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 2ec0df04e0dc..7e12d0163863 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
| @@ -2388,7 +2388,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) | |||
| 2388 | return dev; | 2388 | return dev; |
| 2389 | } | 2389 | } |
| 2390 | 2390 | ||
| 2391 | static void pcie_report_downtraining(struct pci_dev *dev) | 2391 | void pcie_report_downtraining(struct pci_dev *dev) |
| 2392 | { | 2392 | { |
| 2393 | if (!pci_is_pcie(dev)) | 2393 | if (!pci_is_pcie(dev)) |
| 2394 | return; | 2394 | return; |
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index 5163097b43df..4bbd9ede38c8 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c | |||
| @@ -485,8 +485,11 @@ static int sun4i_usb_phy_set_mode(struct phy *_phy, | |||
| 485 | struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); | 485 | struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); |
| 486 | int new_mode; | 486 | int new_mode; |
| 487 | 487 | ||
| 488 | if (phy->index != 0) | 488 | if (phy->index != 0) { |
| 489 | if (mode == PHY_MODE_USB_HOST) | ||
| 490 | return 0; | ||
| 489 | return -EINVAL; | 491 | return -EINVAL; |
| 492 | } | ||
| 490 | 493 | ||
| 491 | switch (mode) { | 494 | switch (mode) { |
| 492 | case PHY_MODE_USB_HOST: | 495 | case PHY_MODE_USB_HOST: |
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c index 4159c63a5fd2..a835b31aad99 100644 --- a/drivers/s390/cio/chsc.c +++ b/drivers/s390/cio/chsc.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <asm/crw.h> | 24 | #include <asm/crw.h> |
| 25 | #include <asm/isc.h> | 25 | #include <asm/isc.h> |
| 26 | #include <asm/ebcdic.h> | 26 | #include <asm/ebcdic.h> |
| 27 | #include <asm/ap.h> | ||
| 27 | 28 | ||
| 28 | #include "css.h" | 29 | #include "css.h" |
| 29 | #include "cio.h" | 30 | #include "cio.h" |
| @@ -586,6 +587,15 @@ static void chsc_process_sei_scm_avail(struct chsc_sei_nt0_area *sei_area) | |||
| 586 | " failed (rc=%d).\n", ret); | 587 | " failed (rc=%d).\n", ret); |
| 587 | } | 588 | } |
| 588 | 589 | ||
| 590 | static void chsc_process_sei_ap_cfg_chg(struct chsc_sei_nt0_area *sei_area) | ||
| 591 | { | ||
| 592 | CIO_CRW_EVENT(3, "chsc: ap config changed\n"); | ||
| 593 | if (sei_area->rs != 5) | ||
| 594 | return; | ||
| 595 | |||
| 596 | ap_bus_cfg_chg(); | ||
| 597 | } | ||
| 598 | |||
| 589 | static void chsc_process_sei_nt2(struct chsc_sei_nt2_area *sei_area) | 599 | static void chsc_process_sei_nt2(struct chsc_sei_nt2_area *sei_area) |
| 590 | { | 600 | { |
| 591 | switch (sei_area->cc) { | 601 | switch (sei_area->cc) { |
| @@ -612,6 +622,9 @@ static void chsc_process_sei_nt0(struct chsc_sei_nt0_area *sei_area) | |||
| 612 | case 2: /* i/o resource accessibility */ | 622 | case 2: /* i/o resource accessibility */ |
| 613 | chsc_process_sei_res_acc(sei_area); | 623 | chsc_process_sei_res_acc(sei_area); |
| 614 | break; | 624 | break; |
| 625 | case 3: /* ap config changed */ | ||
| 626 | chsc_process_sei_ap_cfg_chg(sei_area); | ||
| 627 | break; | ||
| 615 | case 7: /* channel-path-availability information */ | 628 | case 7: /* channel-path-availability information */ |
| 616 | chsc_process_sei_chp_avail(sei_area); | 629 | chsc_process_sei_chp_avail(sei_area); |
| 617 | break; | 630 | break; |
diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c index a10cec0e86eb..0b3b9de45c60 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c | |||
| @@ -72,20 +72,24 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work) | |||
| 72 | { | 72 | { |
| 73 | struct vfio_ccw_private *private; | 73 | struct vfio_ccw_private *private; |
| 74 | struct irb *irb; | 74 | struct irb *irb; |
| 75 | bool is_final; | ||
| 75 | 76 | ||
| 76 | private = container_of(work, struct vfio_ccw_private, io_work); | 77 | private = container_of(work, struct vfio_ccw_private, io_work); |
| 77 | irb = &private->irb; | 78 | irb = &private->irb; |
| 78 | 79 | ||
| 80 | is_final = !(scsw_actl(&irb->scsw) & | ||
| 81 | (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)); | ||
| 79 | if (scsw_is_solicited(&irb->scsw)) { | 82 | if (scsw_is_solicited(&irb->scsw)) { |
| 80 | cp_update_scsw(&private->cp, &irb->scsw); | 83 | cp_update_scsw(&private->cp, &irb->scsw); |
| 81 | cp_free(&private->cp); | 84 | if (is_final) |
| 85 | cp_free(&private->cp); | ||
| 82 | } | 86 | } |
| 83 | memcpy(private->io_region->irb_area, irb, sizeof(*irb)); | 87 | memcpy(private->io_region->irb_area, irb, sizeof(*irb)); |
| 84 | 88 | ||
| 85 | if (private->io_trigger) | 89 | if (private->io_trigger) |
| 86 | eventfd_signal(private->io_trigger, 1); | 90 | eventfd_signal(private->io_trigger, 1); |
| 87 | 91 | ||
| 88 | if (private->mdev) | 92 | if (private->mdev && is_final) |
| 89 | private->state = VFIO_CCW_STATE_IDLE; | 93 | private->state = VFIO_CCW_STATE_IDLE; |
| 90 | } | 94 | } |
| 91 | 95 | ||
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index e15816ff1265..1546389d71db 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
| @@ -810,11 +810,18 @@ static int ap_device_remove(struct device *dev) | |||
| 810 | struct ap_device *ap_dev = to_ap_dev(dev); | 810 | struct ap_device *ap_dev = to_ap_dev(dev); |
| 811 | struct ap_driver *ap_drv = ap_dev->drv; | 811 | struct ap_driver *ap_drv = ap_dev->drv; |
| 812 | 812 | ||
| 813 | /* prepare ap queue device removal */ | ||
| 813 | if (is_queue_dev(dev)) | 814 | if (is_queue_dev(dev)) |
| 814 | ap_queue_remove(to_ap_queue(dev)); | 815 | ap_queue_prepare_remove(to_ap_queue(dev)); |
| 816 | |||
| 817 | /* driver's chance to clean up gracefully */ | ||
| 815 | if (ap_drv->remove) | 818 | if (ap_drv->remove) |
| 816 | ap_drv->remove(ap_dev); | 819 | ap_drv->remove(ap_dev); |
| 817 | 820 | ||
| 821 | /* now do the ap queue device remove */ | ||
| 822 | if (is_queue_dev(dev)) | ||
| 823 | ap_queue_remove(to_ap_queue(dev)); | ||
| 824 | |||
| 818 | /* Remove queue/card from list of active queues/cards */ | 825 | /* Remove queue/card from list of active queues/cards */ |
| 819 | spin_lock_bh(&ap_list_lock); | 826 | spin_lock_bh(&ap_list_lock); |
| 820 | if (is_card_dev(dev)) | 827 | if (is_card_dev(dev)) |
| @@ -861,6 +868,16 @@ void ap_bus_force_rescan(void) | |||
| 861 | EXPORT_SYMBOL(ap_bus_force_rescan); | 868 | EXPORT_SYMBOL(ap_bus_force_rescan); |
| 862 | 869 | ||
| 863 | /* | 870 | /* |
| 871 | * A config change has happened, force an ap bus rescan. | ||
| 872 | */ | ||
| 873 | void ap_bus_cfg_chg(void) | ||
| 874 | { | ||
| 875 | AP_DBF(DBF_INFO, "%s config change, forcing bus rescan\n", __func__); | ||
| 876 | |||
| 877 | ap_bus_force_rescan(); | ||
| 878 | } | ||
| 879 | |||
| 880 | /* | ||
| 864 | * hex2bitmap() - parse hex mask string and set bitmap. | 881 | * hex2bitmap() - parse hex mask string and set bitmap. |
| 865 | * Valid strings are "0x012345678" with at least one valid hex number. | 882 | * Valid strings are "0x012345678" with at least one valid hex number. |
| 866 | * Rest of the bitmap to the right is padded with 0. No spaces allowed | 883 | * Rest of the bitmap to the right is padded with 0. No spaces allowed |
diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h index d0059eae5d94..15a98a673c5c 100644 --- a/drivers/s390/crypto/ap_bus.h +++ b/drivers/s390/crypto/ap_bus.h | |||
| @@ -91,6 +91,7 @@ enum ap_state { | |||
| 91 | AP_STATE_WORKING, | 91 | AP_STATE_WORKING, |
| 92 | AP_STATE_QUEUE_FULL, | 92 | AP_STATE_QUEUE_FULL, |
| 93 | AP_STATE_SUSPEND_WAIT, | 93 | AP_STATE_SUSPEND_WAIT, |
| 94 | AP_STATE_REMOVE, /* about to be removed from driver */ | ||
| 94 | AP_STATE_UNBOUND, /* momentary not bound to a driver */ | 95 | AP_STATE_UNBOUND, /* momentary not bound to a driver */ |
| 95 | AP_STATE_BORKED, /* broken */ | 96 | AP_STATE_BORKED, /* broken */ |
| 96 | NR_AP_STATES | 97 | NR_AP_STATES |
| @@ -252,6 +253,7 @@ void ap_bus_force_rescan(void); | |||
| 252 | 253 | ||
| 253 | void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *ap_msg); | 254 | void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *ap_msg); |
| 254 | struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type); | 255 | struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type); |
| 256 | void ap_queue_prepare_remove(struct ap_queue *aq); | ||
| 255 | void ap_queue_remove(struct ap_queue *aq); | 257 | void ap_queue_remove(struct ap_queue *aq); |
| 256 | void ap_queue_suspend(struct ap_device *ap_dev); | 258 | void ap_queue_suspend(struct ap_device *ap_dev); |
| 257 | void ap_queue_resume(struct ap_device *ap_dev); | 259 | void ap_queue_resume(struct ap_device *ap_dev); |
diff --git a/drivers/s390/crypto/ap_queue.c b/drivers/s390/crypto/ap_queue.c index ba261210c6da..6a340f2c3556 100644 --- a/drivers/s390/crypto/ap_queue.c +++ b/drivers/s390/crypto/ap_queue.c | |||
| @@ -420,6 +420,10 @@ static ap_func_t *ap_jumptable[NR_AP_STATES][NR_AP_EVENTS] = { | |||
| 420 | [AP_EVENT_POLL] = ap_sm_suspend_read, | 420 | [AP_EVENT_POLL] = ap_sm_suspend_read, |
| 421 | [AP_EVENT_TIMEOUT] = ap_sm_nop, | 421 | [AP_EVENT_TIMEOUT] = ap_sm_nop, |
| 422 | }, | 422 | }, |
| 423 | [AP_STATE_REMOVE] = { | ||
| 424 | [AP_EVENT_POLL] = ap_sm_nop, | ||
| 425 | [AP_EVENT_TIMEOUT] = ap_sm_nop, | ||
| 426 | }, | ||
| 423 | [AP_STATE_UNBOUND] = { | 427 | [AP_STATE_UNBOUND] = { |
| 424 | [AP_EVENT_POLL] = ap_sm_nop, | 428 | [AP_EVENT_POLL] = ap_sm_nop, |
| 425 | [AP_EVENT_TIMEOUT] = ap_sm_nop, | 429 | [AP_EVENT_TIMEOUT] = ap_sm_nop, |
| @@ -740,18 +744,31 @@ void ap_flush_queue(struct ap_queue *aq) | |||
| 740 | } | 744 | } |
| 741 | EXPORT_SYMBOL(ap_flush_queue); | 745 | EXPORT_SYMBOL(ap_flush_queue); |
| 742 | 746 | ||
| 743 | void ap_queue_remove(struct ap_queue *aq) | 747 | void ap_queue_prepare_remove(struct ap_queue *aq) |
| 744 | { | 748 | { |
| 745 | ap_flush_queue(aq); | 749 | spin_lock_bh(&aq->lock); |
| 750 | /* flush queue */ | ||
| 751 | __ap_flush_queue(aq); | ||
| 752 | /* set REMOVE state to prevent new messages are queued in */ | ||
| 753 | aq->state = AP_STATE_REMOVE; | ||
| 746 | del_timer_sync(&aq->timeout); | 754 | del_timer_sync(&aq->timeout); |
| 755 | spin_unlock_bh(&aq->lock); | ||
| 756 | } | ||
| 747 | 757 | ||
| 748 | /* reset with zero, also clears irq registration */ | 758 | void ap_queue_remove(struct ap_queue *aq) |
| 759 | { | ||
| 760 | /* | ||
| 761 | * all messages have been flushed and the state is | ||
| 762 | * AP_STATE_REMOVE. Now reset with zero which also | ||
| 763 | * clears the irq registration and move the state | ||
| 764 | * to AP_STATE_UNBOUND to signal that this queue | ||
| 765 | * is not used by any driver currently. | ||
| 766 | */ | ||
| 749 | spin_lock_bh(&aq->lock); | 767 | spin_lock_bh(&aq->lock); |
| 750 | ap_zapq(aq->qid); | 768 | ap_zapq(aq->qid); |
| 751 | aq->state = AP_STATE_UNBOUND; | 769 | aq->state = AP_STATE_UNBOUND; |
| 752 | spin_unlock_bh(&aq->lock); | 770 | spin_unlock_bh(&aq->lock); |
| 753 | } | 771 | } |
| 754 | EXPORT_SYMBOL(ap_queue_remove); | ||
| 755 | 772 | ||
| 756 | void ap_queue_reinit_state(struct ap_queue *aq) | 773 | void ap_queue_reinit_state(struct ap_queue *aq) |
| 757 | { | 774 | { |
| @@ -760,4 +777,3 @@ void ap_queue_reinit_state(struct ap_queue *aq) | |||
| 760 | ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); | 777 | ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); |
| 761 | spin_unlock_bh(&aq->lock); | 778 | spin_unlock_bh(&aq->lock); |
| 762 | } | 779 | } |
| 763 | EXPORT_SYMBOL(ap_queue_reinit_state); | ||
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index eb93c2d27d0a..689c2af7026a 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c | |||
| @@ -586,6 +586,7 @@ static inline bool zcrypt_check_queue(struct ap_perms *perms, int queue) | |||
| 586 | 586 | ||
| 587 | static inline struct zcrypt_queue *zcrypt_pick_queue(struct zcrypt_card *zc, | 587 | static inline struct zcrypt_queue *zcrypt_pick_queue(struct zcrypt_card *zc, |
| 588 | struct zcrypt_queue *zq, | 588 | struct zcrypt_queue *zq, |
| 589 | struct module **pmod, | ||
| 589 | unsigned int weight) | 590 | unsigned int weight) |
| 590 | { | 591 | { |
| 591 | if (!zq || !try_module_get(zq->queue->ap_dev.drv->driver.owner)) | 592 | if (!zq || !try_module_get(zq->queue->ap_dev.drv->driver.owner)) |
| @@ -595,15 +596,15 @@ static inline struct zcrypt_queue *zcrypt_pick_queue(struct zcrypt_card *zc, | |||
| 595 | atomic_add(weight, &zc->load); | 596 | atomic_add(weight, &zc->load); |
| 596 | atomic_add(weight, &zq->load); | 597 | atomic_add(weight, &zq->load); |
| 597 | zq->request_count++; | 598 | zq->request_count++; |
| 599 | *pmod = zq->queue->ap_dev.drv->driver.owner; | ||
| 598 | return zq; | 600 | return zq; |
| 599 | } | 601 | } |
| 600 | 602 | ||
| 601 | static inline void zcrypt_drop_queue(struct zcrypt_card *zc, | 603 | static inline void zcrypt_drop_queue(struct zcrypt_card *zc, |
| 602 | struct zcrypt_queue *zq, | 604 | struct zcrypt_queue *zq, |
| 605 | struct module *mod, | ||
| 603 | unsigned int weight) | 606 | unsigned int weight) |
| 604 | { | 607 | { |
| 605 | struct module *mod = zq->queue->ap_dev.drv->driver.owner; | ||
| 606 | |||
| 607 | zq->request_count--; | 608 | zq->request_count--; |
| 608 | atomic_sub(weight, &zc->load); | 609 | atomic_sub(weight, &zc->load); |
| 609 | atomic_sub(weight, &zq->load); | 610 | atomic_sub(weight, &zq->load); |
| @@ -653,6 +654,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms, | |||
| 653 | unsigned int weight, pref_weight; | 654 | unsigned int weight, pref_weight; |
| 654 | unsigned int func_code; | 655 | unsigned int func_code; |
| 655 | int qid = 0, rc = -ENODEV; | 656 | int qid = 0, rc = -ENODEV; |
| 657 | struct module *mod; | ||
| 656 | 658 | ||
| 657 | trace_s390_zcrypt_req(mex, TP_ICARSAMODEXPO); | 659 | trace_s390_zcrypt_req(mex, TP_ICARSAMODEXPO); |
| 658 | 660 | ||
| @@ -706,7 +708,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms, | |||
| 706 | pref_weight = weight; | 708 | pref_weight = weight; |
| 707 | } | 709 | } |
| 708 | } | 710 | } |
| 709 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); | 711 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight); |
| 710 | spin_unlock(&zcrypt_list_lock); | 712 | spin_unlock(&zcrypt_list_lock); |
| 711 | 713 | ||
| 712 | if (!pref_zq) { | 714 | if (!pref_zq) { |
| @@ -718,7 +720,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms, | |||
| 718 | rc = pref_zq->ops->rsa_modexpo(pref_zq, mex); | 720 | rc = pref_zq->ops->rsa_modexpo(pref_zq, mex); |
| 719 | 721 | ||
| 720 | spin_lock(&zcrypt_list_lock); | 722 | spin_lock(&zcrypt_list_lock); |
| 721 | zcrypt_drop_queue(pref_zc, pref_zq, weight); | 723 | zcrypt_drop_queue(pref_zc, pref_zq, mod, weight); |
| 722 | spin_unlock(&zcrypt_list_lock); | 724 | spin_unlock(&zcrypt_list_lock); |
| 723 | 725 | ||
| 724 | out: | 726 | out: |
| @@ -735,6 +737,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms, | |||
| 735 | unsigned int weight, pref_weight; | 737 | unsigned int weight, pref_weight; |
| 736 | unsigned int func_code; | 738 | unsigned int func_code; |
| 737 | int qid = 0, rc = -ENODEV; | 739 | int qid = 0, rc = -ENODEV; |
| 740 | struct module *mod; | ||
| 738 | 741 | ||
| 739 | trace_s390_zcrypt_req(crt, TP_ICARSACRT); | 742 | trace_s390_zcrypt_req(crt, TP_ICARSACRT); |
| 740 | 743 | ||
| @@ -788,7 +791,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms, | |||
| 788 | pref_weight = weight; | 791 | pref_weight = weight; |
| 789 | } | 792 | } |
| 790 | } | 793 | } |
| 791 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); | 794 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight); |
| 792 | spin_unlock(&zcrypt_list_lock); | 795 | spin_unlock(&zcrypt_list_lock); |
| 793 | 796 | ||
| 794 | if (!pref_zq) { | 797 | if (!pref_zq) { |
| @@ -800,7 +803,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms, | |||
| 800 | rc = pref_zq->ops->rsa_modexpo_crt(pref_zq, crt); | 803 | rc = pref_zq->ops->rsa_modexpo_crt(pref_zq, crt); |
| 801 | 804 | ||
| 802 | spin_lock(&zcrypt_list_lock); | 805 | spin_lock(&zcrypt_list_lock); |
| 803 | zcrypt_drop_queue(pref_zc, pref_zq, weight); | 806 | zcrypt_drop_queue(pref_zc, pref_zq, mod, weight); |
| 804 | spin_unlock(&zcrypt_list_lock); | 807 | spin_unlock(&zcrypt_list_lock); |
| 805 | 808 | ||
| 806 | out: | 809 | out: |
| @@ -819,6 +822,7 @@ static long _zcrypt_send_cprb(struct ap_perms *perms, | |||
| 819 | unsigned int func_code; | 822 | unsigned int func_code; |
| 820 | unsigned short *domain; | 823 | unsigned short *domain; |
| 821 | int qid = 0, rc = -ENODEV; | 824 | int qid = 0, rc = -ENODEV; |
| 825 | struct module *mod; | ||
| 822 | 826 | ||
| 823 | trace_s390_zcrypt_req(xcRB, TB_ZSECSENDCPRB); | 827 | trace_s390_zcrypt_req(xcRB, TB_ZSECSENDCPRB); |
| 824 | 828 | ||
| @@ -865,7 +869,7 @@ static long _zcrypt_send_cprb(struct ap_perms *perms, | |||
| 865 | pref_weight = weight; | 869 | pref_weight = weight; |
| 866 | } | 870 | } |
| 867 | } | 871 | } |
| 868 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); | 872 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight); |
| 869 | spin_unlock(&zcrypt_list_lock); | 873 | spin_unlock(&zcrypt_list_lock); |
| 870 | 874 | ||
| 871 | if (!pref_zq) { | 875 | if (!pref_zq) { |
| @@ -881,7 +885,7 @@ static long _zcrypt_send_cprb(struct ap_perms *perms, | |||
| 881 | rc = pref_zq->ops->send_cprb(pref_zq, xcRB, &ap_msg); | 885 | rc = pref_zq->ops->send_cprb(pref_zq, xcRB, &ap_msg); |
| 882 | 886 | ||
| 883 | spin_lock(&zcrypt_list_lock); | 887 | spin_lock(&zcrypt_list_lock); |
| 884 | zcrypt_drop_queue(pref_zc, pref_zq, weight); | 888 | zcrypt_drop_queue(pref_zc, pref_zq, mod, weight); |
| 885 | spin_unlock(&zcrypt_list_lock); | 889 | spin_unlock(&zcrypt_list_lock); |
| 886 | 890 | ||
| 887 | out: | 891 | out: |
| @@ -932,6 +936,7 @@ static long zcrypt_send_ep11_cprb(struct ap_perms *perms, | |||
| 932 | unsigned int func_code; | 936 | unsigned int func_code; |
| 933 | struct ap_message ap_msg; | 937 | struct ap_message ap_msg; |
| 934 | int qid = 0, rc = -ENODEV; | 938 | int qid = 0, rc = -ENODEV; |
| 939 | struct module *mod; | ||
| 935 | 940 | ||
| 936 | trace_s390_zcrypt_req(xcrb, TP_ZSENDEP11CPRB); | 941 | trace_s390_zcrypt_req(xcrb, TP_ZSENDEP11CPRB); |
| 937 | 942 | ||
| @@ -1000,7 +1005,7 @@ static long zcrypt_send_ep11_cprb(struct ap_perms *perms, | |||
| 1000 | pref_weight = weight; | 1005 | pref_weight = weight; |
| 1001 | } | 1006 | } |
| 1002 | } | 1007 | } |
| 1003 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); | 1008 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight); |
| 1004 | spin_unlock(&zcrypt_list_lock); | 1009 | spin_unlock(&zcrypt_list_lock); |
| 1005 | 1010 | ||
| 1006 | if (!pref_zq) { | 1011 | if (!pref_zq) { |
| @@ -1012,7 +1017,7 @@ static long zcrypt_send_ep11_cprb(struct ap_perms *perms, | |||
| 1012 | rc = pref_zq->ops->send_ep11_cprb(pref_zq, xcrb, &ap_msg); | 1017 | rc = pref_zq->ops->send_ep11_cprb(pref_zq, xcrb, &ap_msg); |
| 1013 | 1018 | ||
| 1014 | spin_lock(&zcrypt_list_lock); | 1019 | spin_lock(&zcrypt_list_lock); |
| 1015 | zcrypt_drop_queue(pref_zc, pref_zq, weight); | 1020 | zcrypt_drop_queue(pref_zc, pref_zq, mod, weight); |
| 1016 | spin_unlock(&zcrypt_list_lock); | 1021 | spin_unlock(&zcrypt_list_lock); |
| 1017 | 1022 | ||
| 1018 | out_free: | 1023 | out_free: |
| @@ -1033,6 +1038,7 @@ static long zcrypt_rng(char *buffer) | |||
| 1033 | struct ap_message ap_msg; | 1038 | struct ap_message ap_msg; |
| 1034 | unsigned int domain; | 1039 | unsigned int domain; |
| 1035 | int qid = 0, rc = -ENODEV; | 1040 | int qid = 0, rc = -ENODEV; |
| 1041 | struct module *mod; | ||
| 1036 | 1042 | ||
| 1037 | trace_s390_zcrypt_req(buffer, TP_HWRNGCPRB); | 1043 | trace_s390_zcrypt_req(buffer, TP_HWRNGCPRB); |
| 1038 | 1044 | ||
| @@ -1064,7 +1070,7 @@ static long zcrypt_rng(char *buffer) | |||
| 1064 | pref_weight = weight; | 1070 | pref_weight = weight; |
| 1065 | } | 1071 | } |
| 1066 | } | 1072 | } |
| 1067 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); | 1073 | pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight); |
| 1068 | spin_unlock(&zcrypt_list_lock); | 1074 | spin_unlock(&zcrypt_list_lock); |
| 1069 | 1075 | ||
| 1070 | if (!pref_zq) { | 1076 | if (!pref_zq) { |
| @@ -1076,7 +1082,7 @@ static long zcrypt_rng(char *buffer) | |||
| 1076 | rc = pref_zq->ops->rng(pref_zq, buffer, &ap_msg); | 1082 | rc = pref_zq->ops->rng(pref_zq, buffer, &ap_msg); |
| 1077 | 1083 | ||
| 1078 | spin_lock(&zcrypt_list_lock); | 1084 | spin_lock(&zcrypt_list_lock); |
| 1079 | zcrypt_drop_queue(pref_zc, pref_zq, weight); | 1085 | zcrypt_drop_queue(pref_zc, pref_zq, mod, weight); |
| 1080 | spin_unlock(&zcrypt_list_lock); | 1086 | spin_unlock(&zcrypt_list_lock); |
| 1081 | 1087 | ||
| 1082 | out: | 1088 | out: |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 197b0f5b63e7..44bd6f04c145 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
| @@ -1150,13 +1150,16 @@ static void qeth_notify_skbs(struct qeth_qdio_out_q *q, | |||
| 1150 | 1150 | ||
| 1151 | static void qeth_release_skbs(struct qeth_qdio_out_buffer *buf) | 1151 | static void qeth_release_skbs(struct qeth_qdio_out_buffer *buf) |
| 1152 | { | 1152 | { |
| 1153 | struct sk_buff *skb; | ||
| 1154 | |||
| 1153 | /* release may never happen from within CQ tasklet scope */ | 1155 | /* release may never happen from within CQ tasklet scope */ |
| 1154 | WARN_ON_ONCE(atomic_read(&buf->state) == QETH_QDIO_BUF_IN_CQ); | 1156 | WARN_ON_ONCE(atomic_read(&buf->state) == QETH_QDIO_BUF_IN_CQ); |
| 1155 | 1157 | ||
| 1156 | if (atomic_read(&buf->state) == QETH_QDIO_BUF_PENDING) | 1158 | if (atomic_read(&buf->state) == QETH_QDIO_BUF_PENDING) |
| 1157 | qeth_notify_skbs(buf->q, buf, TX_NOTIFY_GENERALERROR); | 1159 | qeth_notify_skbs(buf->q, buf, TX_NOTIFY_GENERALERROR); |
| 1158 | 1160 | ||
| 1159 | __skb_queue_purge(&buf->skb_list); | 1161 | while ((skb = __skb_dequeue(&buf->skb_list)) != NULL) |
| 1162 | consume_skb(skb); | ||
| 1160 | } | 1163 | } |
| 1161 | 1164 | ||
| 1162 | static void qeth_clear_output_buffer(struct qeth_qdio_out_q *queue, | 1165 | static void qeth_clear_output_buffer(struct qeth_qdio_out_q *queue, |
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 8efb2e8ff8f4..c3067fd3bd9e 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c | |||
| @@ -629,8 +629,7 @@ static netdev_tx_t qeth_l2_hard_start_xmit(struct sk_buff *skb, | |||
| 629 | } /* else fall through */ | 629 | } /* else fall through */ |
| 630 | 630 | ||
| 631 | QETH_TXQ_STAT_INC(queue, tx_dropped); | 631 | QETH_TXQ_STAT_INC(queue, tx_dropped); |
| 632 | QETH_TXQ_STAT_INC(queue, tx_errors); | 632 | kfree_skb(skb); |
| 633 | dev_kfree_skb_any(skb); | ||
| 634 | netif_wake_queue(dev); | 633 | netif_wake_queue(dev); |
| 635 | return NETDEV_TX_OK; | 634 | return NETDEV_TX_OK; |
| 636 | } | 635 | } |
| @@ -645,6 +644,8 @@ static int qeth_l2_probe_device(struct ccwgroup_device *gdev) | |||
| 645 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); | 644 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
| 646 | int rc; | 645 | int rc; |
| 647 | 646 | ||
| 647 | qeth_l2_vnicc_set_defaults(card); | ||
| 648 | |||
| 648 | if (gdev->dev.type == &qeth_generic_devtype) { | 649 | if (gdev->dev.type == &qeth_generic_devtype) { |
| 649 | rc = qeth_l2_create_device_attributes(&gdev->dev); | 650 | rc = qeth_l2_create_device_attributes(&gdev->dev); |
| 650 | if (rc) | 651 | if (rc) |
| @@ -652,8 +653,6 @@ static int qeth_l2_probe_device(struct ccwgroup_device *gdev) | |||
| 652 | } | 653 | } |
| 653 | 654 | ||
| 654 | hash_init(card->mac_htable); | 655 | hash_init(card->mac_htable); |
| 655 | card->info.hwtrap = 0; | ||
| 656 | qeth_l2_vnicc_set_defaults(card); | ||
| 657 | return 0; | 656 | return 0; |
| 658 | } | 657 | } |
| 659 | 658 | ||
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 7e68d9d16859..53712cf26406 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c | |||
| @@ -2096,8 +2096,7 @@ static netdev_tx_t qeth_l3_hard_start_xmit(struct sk_buff *skb, | |||
| 2096 | 2096 | ||
| 2097 | tx_drop: | 2097 | tx_drop: |
| 2098 | QETH_TXQ_STAT_INC(queue, tx_dropped); | 2098 | QETH_TXQ_STAT_INC(queue, tx_dropped); |
| 2099 | QETH_TXQ_STAT_INC(queue, tx_errors); | 2099 | kfree_skb(skb); |
| 2100 | dev_kfree_skb_any(skb); | ||
| 2101 | netif_wake_queue(dev); | 2100 | netif_wake_queue(dev); |
| 2102 | return NETDEV_TX_OK; | 2101 | return NETDEV_TX_OK; |
| 2103 | } | 2102 | } |
| @@ -2253,14 +2252,15 @@ static int qeth_l3_probe_device(struct ccwgroup_device *gdev) | |||
| 2253 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); | 2252 | struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
| 2254 | int rc; | 2253 | int rc; |
| 2255 | 2254 | ||
| 2255 | hash_init(card->ip_htable); | ||
| 2256 | |||
| 2256 | if (gdev->dev.type == &qeth_generic_devtype) { | 2257 | if (gdev->dev.type == &qeth_generic_devtype) { |
| 2257 | rc = qeth_l3_create_device_attributes(&gdev->dev); | 2258 | rc = qeth_l3_create_device_attributes(&gdev->dev); |
| 2258 | if (rc) | 2259 | if (rc) |
| 2259 | return rc; | 2260 | return rc; |
| 2260 | } | 2261 | } |
| 2261 | hash_init(card->ip_htable); | 2262 | |
| 2262 | hash_init(card->ip_mc_htable); | 2263 | hash_init(card->ip_mc_htable); |
| 2263 | card->info.hwtrap = 0; | ||
| 2264 | return 0; | 2264 | return 0; |
| 2265 | } | 2265 | } |
| 2266 | 2266 | ||
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 744a64680d5b..e8fc28dba8df 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c | |||
| @@ -624,6 +624,20 @@ static void zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action) | |||
| 624 | add_timer(&erp_action->timer); | 624 | add_timer(&erp_action->timer); |
| 625 | } | 625 | } |
| 626 | 626 | ||
| 627 | void zfcp_erp_port_forced_reopen_all(struct zfcp_adapter *adapter, | ||
| 628 | int clear, char *dbftag) | ||
| 629 | { | ||
| 630 | unsigned long flags; | ||
| 631 | struct zfcp_port *port; | ||
| 632 | |||
| 633 | write_lock_irqsave(&adapter->erp_lock, flags); | ||
| 634 | read_lock(&adapter->port_list_lock); | ||
| 635 | list_for_each_entry(port, &adapter->port_list, list) | ||
| 636 | _zfcp_erp_port_forced_reopen(port, clear, dbftag); | ||
| 637 | read_unlock(&adapter->port_list_lock); | ||
| 638 | write_unlock_irqrestore(&adapter->erp_lock, flags); | ||
| 639 | } | ||
| 640 | |||
| 627 | static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, | 641 | static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, |
| 628 | int clear, char *dbftag) | 642 | int clear, char *dbftag) |
| 629 | { | 643 | { |
| @@ -1341,6 +1355,9 @@ static void zfcp_erp_try_rport_unblock(struct zfcp_port *port) | |||
| 1341 | struct zfcp_scsi_dev *zsdev = sdev_to_zfcp(sdev); | 1355 | struct zfcp_scsi_dev *zsdev = sdev_to_zfcp(sdev); |
| 1342 | int lun_status; | 1356 | int lun_status; |
| 1343 | 1357 | ||
| 1358 | if (sdev->sdev_state == SDEV_DEL || | ||
| 1359 | sdev->sdev_state == SDEV_CANCEL) | ||
| 1360 | continue; | ||
| 1344 | if (zsdev->port != port) | 1361 | if (zsdev->port != port) |
| 1345 | continue; | 1362 | continue; |
| 1346 | /* LUN under port of interest */ | 1363 | /* LUN under port of interest */ |
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h index 3fce47b0b21b..c6acca521ffe 100644 --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h | |||
| @@ -70,6 +70,8 @@ extern void zfcp_erp_port_reopen(struct zfcp_port *port, int clear, | |||
| 70 | char *dbftag); | 70 | char *dbftag); |
| 71 | extern void zfcp_erp_port_shutdown(struct zfcp_port *, int, char *); | 71 | extern void zfcp_erp_port_shutdown(struct zfcp_port *, int, char *); |
| 72 | extern void zfcp_erp_port_forced_reopen(struct zfcp_port *, int, char *); | 72 | extern void zfcp_erp_port_forced_reopen(struct zfcp_port *, int, char *); |
| 73 | extern void zfcp_erp_port_forced_reopen_all(struct zfcp_adapter *adapter, | ||
| 74 | int clear, char *dbftag); | ||
| 73 | extern void zfcp_erp_set_lun_status(struct scsi_device *, u32); | 75 | extern void zfcp_erp_set_lun_status(struct scsi_device *, u32); |
| 74 | extern void zfcp_erp_clear_lun_status(struct scsi_device *, u32); | 76 | extern void zfcp_erp_clear_lun_status(struct scsi_device *, u32); |
| 75 | extern void zfcp_erp_lun_reopen(struct scsi_device *, int, char *); | 77 | extern void zfcp_erp_lun_reopen(struct scsi_device *, int, char *); |
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index db00b5e3abbe..33eddb02ee30 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c | |||
| @@ -239,10 +239,6 @@ static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range, | |||
| 239 | list_for_each_entry(port, &adapter->port_list, list) { | 239 | list_for_each_entry(port, &adapter->port_list, list) { |
| 240 | if ((port->d_id & range) == (ntoh24(page->rscn_fid) & range)) | 240 | if ((port->d_id & range) == (ntoh24(page->rscn_fid) & range)) |
| 241 | zfcp_fc_test_link(port); | 241 | zfcp_fc_test_link(port); |
| 242 | if (!port->d_id) | ||
| 243 | zfcp_erp_port_reopen(port, | ||
| 244 | ZFCP_STATUS_COMMON_ERP_FAILED, | ||
| 245 | "fcrscn1"); | ||
| 246 | } | 242 | } |
| 247 | read_unlock_irqrestore(&adapter->port_list_lock, flags); | 243 | read_unlock_irqrestore(&adapter->port_list_lock, flags); |
| 248 | } | 244 | } |
| @@ -250,6 +246,7 @@ static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range, | |||
| 250 | static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req) | 246 | static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req) |
| 251 | { | 247 | { |
| 252 | struct fsf_status_read_buffer *status_buffer = (void *)fsf_req->data; | 248 | struct fsf_status_read_buffer *status_buffer = (void *)fsf_req->data; |
| 249 | struct zfcp_adapter *adapter = fsf_req->adapter; | ||
| 253 | struct fc_els_rscn *head; | 250 | struct fc_els_rscn *head; |
| 254 | struct fc_els_rscn_page *page; | 251 | struct fc_els_rscn_page *page; |
| 255 | u16 i; | 252 | u16 i; |
| @@ -263,6 +260,22 @@ static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req) | |||
| 263 | no_entries = be16_to_cpu(head->rscn_plen) / | 260 | no_entries = be16_to_cpu(head->rscn_plen) / |
| 264 | sizeof(struct fc_els_rscn_page); | 261 | sizeof(struct fc_els_rscn_page); |
| 265 | 262 | ||
| 263 | if (no_entries > 1) { | ||
| 264 | /* handle failed ports */ | ||
| 265 | unsigned long flags; | ||
| 266 | struct zfcp_port *port; | ||
| 267 | |||
| 268 | read_lock_irqsave(&adapter->port_list_lock, flags); | ||
| 269 | list_for_each_entry(port, &adapter->port_list, list) { | ||
| 270 | if (port->d_id) | ||
| 271 | continue; | ||
| 272 | zfcp_erp_port_reopen(port, | ||
| 273 | ZFCP_STATUS_COMMON_ERP_FAILED, | ||
| 274 | "fcrscn1"); | ||
| 275 | } | ||
| 276 | read_unlock_irqrestore(&adapter->port_list_lock, flags); | ||
| 277 | } | ||
| 278 | |||
| 266 | for (i = 1; i < no_entries; i++) { | 279 | for (i = 1; i < no_entries; i++) { |
| 267 | /* skip head and start with 1st element */ | 280 | /* skip head and start with 1st element */ |
| 268 | page++; | 281 | page++; |
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index f4f6a07c5222..221d0dfb8493 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c | |||
| @@ -368,6 +368,10 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) | |||
| 368 | struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; | 368 | struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; |
| 369 | int ret = SUCCESS, fc_ret; | 369 | int ret = SUCCESS, fc_ret; |
| 370 | 370 | ||
| 371 | if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE)) { | ||
| 372 | zfcp_erp_port_forced_reopen_all(adapter, 0, "schrh_p"); | ||
| 373 | zfcp_erp_wait(adapter); | ||
| 374 | } | ||
| 371 | zfcp_erp_adapter_reopen(adapter, 0, "schrh_1"); | 375 | zfcp_erp_adapter_reopen(adapter, 0, "schrh_1"); |
| 372 | zfcp_erp_wait(adapter); | 376 | zfcp_erp_wait(adapter); |
| 373 | fc_ret = fc_block_scsi_eh(scpnt); | 377 | fc_ret = fc_block_scsi_eh(scpnt); |
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 1df5171594b8..11fb68d7e60d 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h | |||
| @@ -2640,9 +2640,14 @@ static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor) | |||
| 2640 | return capacity; | 2640 | return capacity; |
| 2641 | } | 2641 | } |
| 2642 | 2642 | ||
| 2643 | static inline int aac_pci_offline(struct aac_dev *dev) | ||
| 2644 | { | ||
| 2645 | return pci_channel_offline(dev->pdev) || dev->handle_pci_error; | ||
| 2646 | } | ||
| 2647 | |||
| 2643 | static inline int aac_adapter_check_health(struct aac_dev *dev) | 2648 | static inline int aac_adapter_check_health(struct aac_dev *dev) |
| 2644 | { | 2649 | { |
| 2645 | if (unlikely(pci_channel_offline(dev->pdev))) | 2650 | if (unlikely(aac_pci_offline(dev))) |
| 2646 | return -1; | 2651 | return -1; |
| 2647 | 2652 | ||
| 2648 | return (dev)->a_ops.adapter_check_health(dev); | 2653 | return (dev)->a_ops.adapter_check_health(dev); |
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index e67e032936ef..78430a7b294c 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c | |||
| @@ -672,7 +672,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, | |||
| 672 | return -ETIMEDOUT; | 672 | return -ETIMEDOUT; |
| 673 | } | 673 | } |
| 674 | 674 | ||
| 675 | if (unlikely(pci_channel_offline(dev->pdev))) | 675 | if (unlikely(aac_pci_offline(dev))) |
| 676 | return -EFAULT; | 676 | return -EFAULT; |
| 677 | 677 | ||
| 678 | if ((blink = aac_adapter_check_health(dev)) > 0) { | 678 | if ((blink = aac_adapter_check_health(dev)) > 0) { |
| @@ -772,7 +772,7 @@ int aac_hba_send(u8 command, struct fib *fibptr, fib_callback callback, | |||
| 772 | 772 | ||
| 773 | spin_unlock_irqrestore(&fibptr->event_lock, flags); | 773 | spin_unlock_irqrestore(&fibptr->event_lock, flags); |
| 774 | 774 | ||
| 775 | if (unlikely(pci_channel_offline(dev->pdev))) | 775 | if (unlikely(aac_pci_offline(dev))) |
| 776 | return -EFAULT; | 776 | return -EFAULT; |
| 777 | 777 | ||
| 778 | fibptr->flags |= FIB_CONTEXT_FLAG_WAIT; | 778 | fibptr->flags |= FIB_CONTEXT_FLAG_WAIT; |
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index dbaa4f131433..3ad997ac3510 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c | |||
| @@ -139,6 +139,7 @@ static const struct { | |||
| 139 | { IBMVFC_FC_FAILURE, IBMVFC_VENDOR_SPECIFIC, DID_ERROR, 1, 1, "vendor specific" }, | 139 | { IBMVFC_FC_FAILURE, IBMVFC_VENDOR_SPECIFIC, DID_ERROR, 1, 1, "vendor specific" }, |
| 140 | 140 | ||
| 141 | { IBMVFC_FC_SCSI_ERROR, 0, DID_OK, 1, 0, "SCSI error" }, | 141 | { IBMVFC_FC_SCSI_ERROR, 0, DID_OK, 1, 0, "SCSI error" }, |
| 142 | { IBMVFC_FC_SCSI_ERROR, IBMVFC_COMMAND_FAILED, DID_ERROR, 0, 1, "PRLI to device failed." }, | ||
| 142 | }; | 143 | }; |
| 143 | 144 | ||
| 144 | static void ibmvfc_npiv_login(struct ibmvfc_host *); | 145 | static void ibmvfc_npiv_login(struct ibmvfc_host *); |
| @@ -1494,9 +1495,9 @@ static void ibmvfc_log_error(struct ibmvfc_event *evt) | |||
| 1494 | if (rsp->flags & FCP_RSP_LEN_VALID) | 1495 | if (rsp->flags & FCP_RSP_LEN_VALID) |
| 1495 | rsp_code = rsp->data.info.rsp_code; | 1496 | rsp_code = rsp->data.info.rsp_code; |
| 1496 | 1497 | ||
| 1497 | scmd_printk(KERN_ERR, cmnd, "Command (%02X) failed: %s (%x:%x) " | 1498 | scmd_printk(KERN_ERR, cmnd, "Command (%02X) : %s (%x:%x) " |
| 1498 | "flags: %x fcp_rsp: %x, resid=%d, scsi_status: %x\n", | 1499 | "flags: %x fcp_rsp: %x, resid=%d, scsi_status: %x\n", |
| 1499 | cmnd->cmnd[0], err, vfc_cmd->status, vfc_cmd->error, | 1500 | cmnd->cmnd[0], err, be16_to_cpu(vfc_cmd->status), be16_to_cpu(vfc_cmd->error), |
| 1500 | rsp->flags, rsp_code, scsi_get_resid(cmnd), rsp->scsi_status); | 1501 | rsp->flags, rsp_code, scsi_get_resid(cmnd), rsp->scsi_status); |
| 1501 | } | 1502 | } |
| 1502 | 1503 | ||
| @@ -2022,7 +2023,7 @@ static int ibmvfc_reset_device(struct scsi_device *sdev, int type, char *desc) | |||
| 2022 | sdev_printk(KERN_ERR, sdev, "%s reset failed: %s (%x:%x) " | 2023 | sdev_printk(KERN_ERR, sdev, "%s reset failed: %s (%x:%x) " |
| 2023 | "flags: %x fcp_rsp: %x, scsi_status: %x\n", desc, | 2024 | "flags: %x fcp_rsp: %x, scsi_status: %x\n", desc, |
| 2024 | ibmvfc_get_cmd_error(be16_to_cpu(rsp_iu.cmd.status), be16_to_cpu(rsp_iu.cmd.error)), | 2025 | ibmvfc_get_cmd_error(be16_to_cpu(rsp_iu.cmd.status), be16_to_cpu(rsp_iu.cmd.error)), |
| 2025 | rsp_iu.cmd.status, rsp_iu.cmd.error, fc_rsp->flags, rsp_code, | 2026 | be16_to_cpu(rsp_iu.cmd.status), be16_to_cpu(rsp_iu.cmd.error), fc_rsp->flags, rsp_code, |
| 2026 | fc_rsp->scsi_status); | 2027 | fc_rsp->scsi_status); |
| 2027 | rsp_rc = -EIO; | 2028 | rsp_rc = -EIO; |
| 2028 | } else | 2029 | } else |
| @@ -2381,7 +2382,7 @@ static int ibmvfc_abort_task_set(struct scsi_device *sdev) | |||
| 2381 | sdev_printk(KERN_ERR, sdev, "Abort failed: %s (%x:%x) " | 2382 | sdev_printk(KERN_ERR, sdev, "Abort failed: %s (%x:%x) " |
| 2382 | "flags: %x fcp_rsp: %x, scsi_status: %x\n", | 2383 | "flags: %x fcp_rsp: %x, scsi_status: %x\n", |
| 2383 | ibmvfc_get_cmd_error(be16_to_cpu(rsp_iu.cmd.status), be16_to_cpu(rsp_iu.cmd.error)), | 2384 | ibmvfc_get_cmd_error(be16_to_cpu(rsp_iu.cmd.status), be16_to_cpu(rsp_iu.cmd.error)), |
| 2384 | rsp_iu.cmd.status, rsp_iu.cmd.error, fc_rsp->flags, rsp_code, | 2385 | be16_to_cpu(rsp_iu.cmd.status), be16_to_cpu(rsp_iu.cmd.error), fc_rsp->flags, rsp_code, |
| 2385 | fc_rsp->scsi_status); | 2386 | fc_rsp->scsi_status); |
| 2386 | rsp_rc = -EIO; | 2387 | rsp_rc = -EIO; |
| 2387 | } else | 2388 | } else |
| @@ -2755,16 +2756,18 @@ static void ibmvfc_handle_crq(struct ibmvfc_crq *crq, struct ibmvfc_host *vhost) | |||
| 2755 | ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_NONE); | 2756 | ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_NONE); |
| 2756 | if (crq->format == IBMVFC_PARTITION_MIGRATED) { | 2757 | if (crq->format == IBMVFC_PARTITION_MIGRATED) { |
| 2757 | /* We need to re-setup the interpartition connection */ | 2758 | /* We need to re-setup the interpartition connection */ |
| 2758 | dev_info(vhost->dev, "Re-enabling adapter\n"); | 2759 | dev_info(vhost->dev, "Partition migrated, Re-enabling adapter\n"); |
| 2759 | vhost->client_migrated = 1; | 2760 | vhost->client_migrated = 1; |
| 2760 | ibmvfc_purge_requests(vhost, DID_REQUEUE); | 2761 | ibmvfc_purge_requests(vhost, DID_REQUEUE); |
| 2761 | ibmvfc_link_down(vhost, IBMVFC_LINK_DOWN); | 2762 | ibmvfc_link_down(vhost, IBMVFC_LINK_DOWN); |
| 2762 | ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_REENABLE); | 2763 | ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_REENABLE); |
| 2763 | } else { | 2764 | } else if (crq->format == IBMVFC_PARTNER_FAILED || crq->format == IBMVFC_PARTNER_DEREGISTER) { |
| 2764 | dev_err(vhost->dev, "Virtual adapter failed (rc=%d)\n", crq->format); | 2765 | dev_err(vhost->dev, "Host partner adapter deregistered or failed (rc=%d)\n", crq->format); |
| 2765 | ibmvfc_purge_requests(vhost, DID_ERROR); | 2766 | ibmvfc_purge_requests(vhost, DID_ERROR); |
| 2766 | ibmvfc_link_down(vhost, IBMVFC_LINK_DOWN); | 2767 | ibmvfc_link_down(vhost, IBMVFC_LINK_DOWN); |
| 2767 | ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_RESET); | 2768 | ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_RESET); |
| 2769 | } else { | ||
| 2770 | dev_err(vhost->dev, "Received unknown transport event from partner (rc=%d)\n", crq->format); | ||
| 2768 | } | 2771 | } |
| 2769 | return; | 2772 | return; |
| 2770 | case IBMVFC_CRQ_CMD_RSP: | 2773 | case IBMVFC_CRQ_CMD_RSP: |
| @@ -3348,7 +3351,7 @@ static void ibmvfc_tgt_prli_done(struct ibmvfc_event *evt) | |||
| 3348 | 3351 | ||
| 3349 | tgt_log(tgt, level, "Process Login failed: %s (%x:%x) rc=0x%02X\n", | 3352 | tgt_log(tgt, level, "Process Login failed: %s (%x:%x) rc=0x%02X\n", |
| 3350 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), | 3353 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), |
| 3351 | rsp->status, rsp->error, status); | 3354 | be16_to_cpu(rsp->status), be16_to_cpu(rsp->error), status); |
| 3352 | break; | 3355 | break; |
| 3353 | } | 3356 | } |
| 3354 | 3357 | ||
| @@ -3446,9 +3449,10 @@ static void ibmvfc_tgt_plogi_done(struct ibmvfc_event *evt) | |||
| 3446 | ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); | 3449 | ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); |
| 3447 | 3450 | ||
| 3448 | tgt_log(tgt, level, "Port Login failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", | 3451 | tgt_log(tgt, level, "Port Login failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", |
| 3449 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), rsp->status, rsp->error, | 3452 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), |
| 3450 | ibmvfc_get_fc_type(be16_to_cpu(rsp->fc_type)), rsp->fc_type, | 3453 | be16_to_cpu(rsp->status), be16_to_cpu(rsp->error), |
| 3451 | ibmvfc_get_ls_explain(be16_to_cpu(rsp->fc_explain)), rsp->fc_explain, status); | 3454 | ibmvfc_get_fc_type(be16_to_cpu(rsp->fc_type)), be16_to_cpu(rsp->fc_type), |
| 3455 | ibmvfc_get_ls_explain(be16_to_cpu(rsp->fc_explain)), be16_to_cpu(rsp->fc_explain), status); | ||
| 3452 | break; | 3456 | break; |
| 3453 | } | 3457 | } |
| 3454 | 3458 | ||
| @@ -3619,7 +3623,7 @@ static void ibmvfc_tgt_adisc_done(struct ibmvfc_event *evt) | |||
| 3619 | fc_explain = (be32_to_cpu(mad->fc_iu.response[1]) & 0x0000ff00) >> 8; | 3623 | fc_explain = (be32_to_cpu(mad->fc_iu.response[1]) & 0x0000ff00) >> 8; |
| 3620 | tgt_info(tgt, "ADISC failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", | 3624 | tgt_info(tgt, "ADISC failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", |
| 3621 | ibmvfc_get_cmd_error(be16_to_cpu(mad->iu.status), be16_to_cpu(mad->iu.error)), | 3625 | ibmvfc_get_cmd_error(be16_to_cpu(mad->iu.status), be16_to_cpu(mad->iu.error)), |
| 3622 | mad->iu.status, mad->iu.error, | 3626 | be16_to_cpu(mad->iu.status), be16_to_cpu(mad->iu.error), |
| 3623 | ibmvfc_get_fc_type(fc_reason), fc_reason, | 3627 | ibmvfc_get_fc_type(fc_reason), fc_reason, |
| 3624 | ibmvfc_get_ls_explain(fc_explain), fc_explain, status); | 3628 | ibmvfc_get_ls_explain(fc_explain), fc_explain, status); |
| 3625 | break; | 3629 | break; |
| @@ -3831,9 +3835,10 @@ static void ibmvfc_tgt_query_target_done(struct ibmvfc_event *evt) | |||
| 3831 | 3835 | ||
| 3832 | tgt_log(tgt, level, "Query Target failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", | 3836 | tgt_log(tgt, level, "Query Target failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n", |
| 3833 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), | 3837 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), |
| 3834 | rsp->status, rsp->error, ibmvfc_get_fc_type(be16_to_cpu(rsp->fc_type)), | 3838 | be16_to_cpu(rsp->status), be16_to_cpu(rsp->error), |
| 3835 | rsp->fc_type, ibmvfc_get_gs_explain(be16_to_cpu(rsp->fc_explain)), | 3839 | ibmvfc_get_fc_type(be16_to_cpu(rsp->fc_type)), be16_to_cpu(rsp->fc_type), |
| 3836 | rsp->fc_explain, status); | 3840 | ibmvfc_get_gs_explain(be16_to_cpu(rsp->fc_explain)), be16_to_cpu(rsp->fc_explain), |
| 3841 | status); | ||
| 3837 | break; | 3842 | break; |
| 3838 | } | 3843 | } |
| 3839 | 3844 | ||
| @@ -3959,7 +3964,7 @@ static void ibmvfc_discover_targets_done(struct ibmvfc_event *evt) | |||
| 3959 | level += ibmvfc_retry_host_init(vhost); | 3964 | level += ibmvfc_retry_host_init(vhost); |
| 3960 | ibmvfc_log(vhost, level, "Discover Targets failed: %s (%x:%x)\n", | 3965 | ibmvfc_log(vhost, level, "Discover Targets failed: %s (%x:%x)\n", |
| 3961 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), | 3966 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), |
| 3962 | rsp->status, rsp->error); | 3967 | be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)); |
| 3963 | break; | 3968 | break; |
| 3964 | case IBMVFC_MAD_DRIVER_FAILED: | 3969 | case IBMVFC_MAD_DRIVER_FAILED: |
| 3965 | break; | 3970 | break; |
| @@ -4024,7 +4029,7 @@ static void ibmvfc_npiv_login_done(struct ibmvfc_event *evt) | |||
| 4024 | ibmvfc_link_down(vhost, IBMVFC_LINK_DEAD); | 4029 | ibmvfc_link_down(vhost, IBMVFC_LINK_DEAD); |
| 4025 | ibmvfc_log(vhost, level, "NPIV Login failed: %s (%x:%x)\n", | 4030 | ibmvfc_log(vhost, level, "NPIV Login failed: %s (%x:%x)\n", |
| 4026 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), | 4031 | ibmvfc_get_cmd_error(be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)), |
| 4027 | rsp->status, rsp->error); | 4032 | be16_to_cpu(rsp->status), be16_to_cpu(rsp->error)); |
| 4028 | ibmvfc_free_event(evt); | 4033 | ibmvfc_free_event(evt); |
| 4029 | return; | 4034 | return; |
| 4030 | case IBMVFC_MAD_CRQ_ERROR: | 4035 | case IBMVFC_MAD_CRQ_ERROR: |
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index b81a53c4a9a8..459cc288ba1d 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h | |||
| @@ -78,9 +78,14 @@ enum ibmvfc_crq_valid { | |||
| 78 | IBMVFC_CRQ_XPORT_EVENT = 0xFF, | 78 | IBMVFC_CRQ_XPORT_EVENT = 0xFF, |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | enum ibmvfc_crq_format { | 81 | enum ibmvfc_crq_init_msg { |
| 82 | IBMVFC_CRQ_INIT = 0x01, | 82 | IBMVFC_CRQ_INIT = 0x01, |
| 83 | IBMVFC_CRQ_INIT_COMPLETE = 0x02, | 83 | IBMVFC_CRQ_INIT_COMPLETE = 0x02, |
| 84 | }; | ||
| 85 | |||
| 86 | enum ibmvfc_crq_xport_evts { | ||
| 87 | IBMVFC_PARTNER_FAILED = 0x01, | ||
| 88 | IBMVFC_PARTNER_DEREGISTER = 0x02, | ||
| 84 | IBMVFC_PARTITION_MIGRATED = 0x06, | 89 | IBMVFC_PARTITION_MIGRATED = 0x06, |
| 85 | }; | 90 | }; |
| 86 | 91 | ||
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index e57774472e75..1d8c584ec1e9 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c | |||
| @@ -3281,12 +3281,18 @@ mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid) | |||
| 3281 | 3281 | ||
| 3282 | if (smid < ioc->hi_priority_smid) { | 3282 | if (smid < ioc->hi_priority_smid) { |
| 3283 | struct scsiio_tracker *st; | 3283 | struct scsiio_tracker *st; |
| 3284 | void *request; | ||
| 3284 | 3285 | ||
| 3285 | st = _get_st_from_smid(ioc, smid); | 3286 | st = _get_st_from_smid(ioc, smid); |
| 3286 | if (!st) { | 3287 | if (!st) { |
| 3287 | _base_recovery_check(ioc); | 3288 | _base_recovery_check(ioc); |
| 3288 | return; | 3289 | return; |
| 3289 | } | 3290 | } |
| 3291 | |||
| 3292 | /* Clear MPI request frame */ | ||
| 3293 | request = mpt3sas_base_get_msg_frame(ioc, smid); | ||
| 3294 | memset(request, 0, ioc->request_sz); | ||
| 3295 | |||
| 3290 | mpt3sas_base_clear_st(ioc, st); | 3296 | mpt3sas_base_clear_st(ioc, st); |
| 3291 | _base_recovery_check(ioc); | 3297 | _base_recovery_check(ioc); |
| 3292 | return; | 3298 | return; |
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 8bb5b8f9f4d2..1ccfbc7eebe0 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c | |||
| @@ -1462,11 +1462,23 @@ mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc, u16 smid) | |||
| 1462 | { | 1462 | { |
| 1463 | struct scsi_cmnd *scmd = NULL; | 1463 | struct scsi_cmnd *scmd = NULL; |
| 1464 | struct scsiio_tracker *st; | 1464 | struct scsiio_tracker *st; |
| 1465 | Mpi25SCSIIORequest_t *mpi_request; | ||
| 1465 | 1466 | ||
| 1466 | if (smid > 0 && | 1467 | if (smid > 0 && |
| 1467 | smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { | 1468 | smid <= ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) { |
| 1468 | u32 unique_tag = smid - 1; | 1469 | u32 unique_tag = smid - 1; |
| 1469 | 1470 | ||
| 1471 | mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); | ||
| 1472 | |||
| 1473 | /* | ||
| 1474 | * If SCSI IO request is outstanding at driver level then | ||
| 1475 | * DevHandle filed must be non-zero. If DevHandle is zero | ||
| 1476 | * then it means that this smid is free at driver level, | ||
| 1477 | * so return NULL. | ||
| 1478 | */ | ||
| 1479 | if (!mpi_request->DevHandle) | ||
| 1480 | return scmd; | ||
| 1481 | |||
| 1470 | scmd = scsi_host_find_tag(ioc->shost, unique_tag); | 1482 | scmd = scsi_host_find_tag(ioc->shost, unique_tag); |
| 1471 | if (scmd) { | 1483 | if (scmd) { |
| 1472 | st = scsi_cmd_priv(scmd); | 1484 | st = scsi_cmd_priv(scmd); |
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 16a18d5d856f..6e4f4931ae17 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
| @@ -3203,6 +3203,8 @@ static int qla4xxx_conn_bind(struct iscsi_cls_session *cls_session, | |||
| 3203 | if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) | 3203 | if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) |
| 3204 | return -EINVAL; | 3204 | return -EINVAL; |
| 3205 | ep = iscsi_lookup_endpoint(transport_fd); | 3205 | ep = iscsi_lookup_endpoint(transport_fd); |
| 3206 | if (!ep) | ||
| 3207 | return -EINVAL; | ||
| 3206 | conn = cls_conn->dd_data; | 3208 | conn = cls_conn->dd_data; |
| 3207 | qla_conn = conn->dd_data; | 3209 | qla_conn = conn->dd_data; |
| 3208 | qla_conn->qla_ep = ep->dd_data; | 3210 | qla_conn->qla_ep = ep->dd_data; |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 6a9040faed00..3b119ca0cc0c 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
| @@ -771,6 +771,12 @@ store_state_field(struct device *dev, struct device_attribute *attr, | |||
| 771 | 771 | ||
| 772 | mutex_lock(&sdev->state_mutex); | 772 | mutex_lock(&sdev->state_mutex); |
| 773 | ret = scsi_device_set_state(sdev, state); | 773 | ret = scsi_device_set_state(sdev, state); |
| 774 | /* | ||
| 775 | * If the device state changes to SDEV_RUNNING, we need to run | ||
| 776 | * the queue to avoid I/O hang. | ||
| 777 | */ | ||
| 778 | if (ret == 0 && state == SDEV_RUNNING) | ||
| 779 | blk_mq_run_hw_queues(sdev->request_queue, true); | ||
| 774 | mutex_unlock(&sdev->state_mutex); | 780 | mutex_unlock(&sdev->state_mutex); |
| 775 | 781 | ||
| 776 | return ret == 0 ? count : -EINVAL; | 782 | return ret == 0 ? count : -EINVAL; |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 251db30d0882..2b2bc4b49d78 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
| @@ -1415,11 +1415,6 @@ static void sd_release(struct gendisk *disk, fmode_t mode) | |||
| 1415 | scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW); | 1415 | scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW); |
| 1416 | } | 1416 | } |
| 1417 | 1417 | ||
| 1418 | /* | ||
| 1419 | * XXX and what if there are packets in flight and this close() | ||
| 1420 | * XXX is followed by a "rmmod sd_mod"? | ||
| 1421 | */ | ||
| 1422 | |||
| 1423 | scsi_disk_put(sdkp); | 1418 | scsi_disk_put(sdkp); |
| 1424 | } | 1419 | } |
| 1425 | 1420 | ||
| @@ -3076,6 +3071,9 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, | |||
| 3076 | unsigned int opt_xfer_bytes = | 3071 | unsigned int opt_xfer_bytes = |
| 3077 | logical_to_bytes(sdp, sdkp->opt_xfer_blocks); | 3072 | logical_to_bytes(sdp, sdkp->opt_xfer_blocks); |
| 3078 | 3073 | ||
| 3074 | if (sdkp->opt_xfer_blocks == 0) | ||
| 3075 | return false; | ||
| 3076 | |||
| 3079 | if (sdkp->opt_xfer_blocks > dev_max) { | 3077 | if (sdkp->opt_xfer_blocks > dev_max) { |
| 3080 | sd_first_printk(KERN_WARNING, sdkp, | 3078 | sd_first_printk(KERN_WARNING, sdkp, |
| 3081 | "Optimal transfer size %u logical blocks " \ | 3079 | "Optimal transfer size %u logical blocks " \ |
| @@ -3505,9 +3503,21 @@ static void scsi_disk_release(struct device *dev) | |||
| 3505 | { | 3503 | { |
| 3506 | struct scsi_disk *sdkp = to_scsi_disk(dev); | 3504 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
| 3507 | struct gendisk *disk = sdkp->disk; | 3505 | struct gendisk *disk = sdkp->disk; |
| 3508 | 3506 | struct request_queue *q = disk->queue; | |
| 3507 | |||
| 3509 | ida_free(&sd_index_ida, sdkp->index); | 3508 | ida_free(&sd_index_ida, sdkp->index); |
| 3510 | 3509 | ||
| 3510 | /* | ||
| 3511 | * Wait until all requests that are in progress have completed. | ||
| 3512 | * This is necessary to avoid that e.g. scsi_end_request() crashes | ||
| 3513 | * due to clearing the disk->private_data pointer. Wait from inside | ||
| 3514 | * scsi_disk_release() instead of from sd_release() to avoid that | ||
| 3515 | * freezing and unfreezing the request queue affects user space I/O | ||
| 3516 | * in case multiple processes open a /dev/sd... node concurrently. | ||
| 3517 | */ | ||
| 3518 | blk_mq_freeze_queue(q); | ||
| 3519 | blk_mq_unfreeze_queue(q); | ||
| 3520 | |||
| 3511 | disk->private_data = NULL; | 3521 | disk->private_data = NULL; |
| 3512 | put_disk(disk); | 3522 | put_disk(disk); |
| 3513 | put_device(&sdkp->device->sdev_gendev); | 3523 | put_device(&sdkp->device->sdev_gendev); |
diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c index 9351349cf0a9..1e0041ec8132 100644 --- a/drivers/soc/bcm/bcm2835-power.c +++ b/drivers/soc/bcm/bcm2835-power.c | |||
| @@ -150,7 +150,12 @@ struct bcm2835_power { | |||
| 150 | 150 | ||
| 151 | static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) | 151 | static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) |
| 152 | { | 152 | { |
| 153 | u64 start = ktime_get_ns(); | 153 | u64 start; |
| 154 | |||
| 155 | if (!reg) | ||
| 156 | return 0; | ||
| 157 | |||
| 158 | start = ktime_get_ns(); | ||
| 154 | 159 | ||
| 155 | /* Enable the module's async AXI bridges. */ | 160 | /* Enable the module's async AXI bridges. */ |
| 156 | ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP); | 161 | ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP); |
| @@ -165,7 +170,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) | |||
| 165 | 170 | ||
| 166 | static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) | 171 | static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) |
| 167 | { | 172 | { |
| 168 | u64 start = ktime_get_ns(); | 173 | u64 start; |
| 174 | |||
| 175 | if (!reg) | ||
| 176 | return 0; | ||
| 177 | |||
| 178 | start = ktime_get_ns(); | ||
| 169 | 179 | ||
| 170 | /* Enable the module's async AXI bridges. */ | 180 | /* Enable the module's async AXI bridges. */ |
| 171 | ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP); | 181 | ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP); |
| @@ -475,7 +485,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain) | |||
| 475 | } | 485 | } |
| 476 | } | 486 | } |
| 477 | 487 | ||
| 478 | static void | 488 | static int |
| 479 | bcm2835_init_power_domain(struct bcm2835_power *power, | 489 | bcm2835_init_power_domain(struct bcm2835_power *power, |
| 480 | int pd_xlate_index, const char *name) | 490 | int pd_xlate_index, const char *name) |
| 481 | { | 491 | { |
| @@ -483,6 +493,17 @@ bcm2835_init_power_domain(struct bcm2835_power *power, | |||
| 483 | struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index]; | 493 | struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index]; |
| 484 | 494 | ||
| 485 | dom->clk = devm_clk_get(dev->parent, name); | 495 | dom->clk = devm_clk_get(dev->parent, name); |
| 496 | if (IS_ERR(dom->clk)) { | ||
| 497 | int ret = PTR_ERR(dom->clk); | ||
| 498 | |||
| 499 | if (ret == -EPROBE_DEFER) | ||
| 500 | return ret; | ||
| 501 | |||
| 502 | /* Some domains don't have a clk, so make sure that we | ||
| 503 | * don't deref an error pointer later. | ||
| 504 | */ | ||
| 505 | dom->clk = NULL; | ||
| 506 | } | ||
| 486 | 507 | ||
| 487 | dom->base.name = name; | 508 | dom->base.name = name; |
| 488 | dom->base.power_on = bcm2835_power_pd_power_on; | 509 | dom->base.power_on = bcm2835_power_pd_power_on; |
| @@ -495,6 +516,8 @@ bcm2835_init_power_domain(struct bcm2835_power *power, | |||
| 495 | pm_genpd_init(&dom->base, NULL, true); | 516 | pm_genpd_init(&dom->base, NULL, true); |
| 496 | 517 | ||
| 497 | power->pd_xlate.domains[pd_xlate_index] = &dom->base; | 518 | power->pd_xlate.domains[pd_xlate_index] = &dom->base; |
| 519 | |||
| 520 | return 0; | ||
| 498 | } | 521 | } |
| 499 | 522 | ||
| 500 | /** bcm2835_reset_reset - Resets a block that has a reset line in the | 523 | /** bcm2835_reset_reset - Resets a block that has a reset line in the |
| @@ -592,7 +615,7 @@ static int bcm2835_power_probe(struct platform_device *pdev) | |||
| 592 | { BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_CAM0 }, | 615 | { BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_CAM0 }, |
| 593 | { BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_CAM1 }, | 616 | { BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_CAM1 }, |
| 594 | }; | 617 | }; |
| 595 | int ret, i; | 618 | int ret = 0, i; |
| 596 | u32 id; | 619 | u32 id; |
| 597 | 620 | ||
| 598 | power = devm_kzalloc(dev, sizeof(*power), GFP_KERNEL); | 621 | power = devm_kzalloc(dev, sizeof(*power), GFP_KERNEL); |
| @@ -619,8 +642,11 @@ static int bcm2835_power_probe(struct platform_device *pdev) | |||
| 619 | 642 | ||
| 620 | power->pd_xlate.num_domains = ARRAY_SIZE(power_domain_names); | 643 | power->pd_xlate.num_domains = ARRAY_SIZE(power_domain_names); |
| 621 | 644 | ||
| 622 | for (i = 0; i < ARRAY_SIZE(power_domain_names); i++) | 645 | for (i = 0; i < ARRAY_SIZE(power_domain_names); i++) { |
| 623 | bcm2835_init_power_domain(power, i, power_domain_names[i]); | 646 | ret = bcm2835_init_power_domain(power, i, power_domain_names[i]); |
| 647 | if (ret) | ||
| 648 | goto fail; | ||
| 649 | } | ||
| 624 | 650 | ||
| 625 | for (i = 0; i < ARRAY_SIZE(domain_deps); i++) { | 651 | for (i = 0; i < ARRAY_SIZE(domain_deps); i++) { |
| 626 | pm_genpd_add_subdomain(&power->domains[domain_deps[i].parent].base, | 652 | pm_genpd_add_subdomain(&power->domains[domain_deps[i].parent].base, |
| @@ -634,12 +660,21 @@ static int bcm2835_power_probe(struct platform_device *pdev) | |||
| 634 | 660 | ||
| 635 | ret = devm_reset_controller_register(dev, &power->reset); | 661 | ret = devm_reset_controller_register(dev, &power->reset); |
| 636 | if (ret) | 662 | if (ret) |
| 637 | return ret; | 663 | goto fail; |
| 638 | 664 | ||
| 639 | of_genpd_add_provider_onecell(dev->parent->of_node, &power->pd_xlate); | 665 | of_genpd_add_provider_onecell(dev->parent->of_node, &power->pd_xlate); |
| 640 | 666 | ||
| 641 | dev_info(dev, "Broadcom BCM2835 power domains driver"); | 667 | dev_info(dev, "Broadcom BCM2835 power domains driver"); |
| 642 | return 0; | 668 | return 0; |
| 669 | |||
| 670 | fail: | ||
| 671 | for (i = 0; i < ARRAY_SIZE(power_domain_names); i++) { | ||
| 672 | struct generic_pm_domain *dom = &power->domains[i].base; | ||
| 673 | |||
| 674 | if (dom->name) | ||
| 675 | pm_genpd_remove(dom); | ||
| 676 | } | ||
| 677 | return ret; | ||
| 643 | } | 678 | } |
| 644 | 679 | ||
| 645 | static int bcm2835_power_remove(struct platform_device *pdev) | 680 | static int bcm2835_power_remove(struct platform_device *pdev) |
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index c0901b96cfe4..62951e836cbc 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig | |||
| @@ -114,8 +114,6 @@ source "drivers/staging/ralink-gdma/Kconfig" | |||
| 114 | 114 | ||
| 115 | source "drivers/staging/mt7621-mmc/Kconfig" | 115 | source "drivers/staging/mt7621-mmc/Kconfig" |
| 116 | 116 | ||
| 117 | source "drivers/staging/mt7621-eth/Kconfig" | ||
| 118 | |||
| 119 | source "drivers/staging/mt7621-dts/Kconfig" | 117 | source "drivers/staging/mt7621-dts/Kconfig" |
| 120 | 118 | ||
| 121 | source "drivers/staging/gasket/Kconfig" | 119 | source "drivers/staging/gasket/Kconfig" |
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 57c6bce13ff4..d1b17ddcd354 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile | |||
| @@ -47,7 +47,6 @@ obj-$(CONFIG_SPI_MT7621) += mt7621-spi/ | |||
| 47 | obj-$(CONFIG_SOC_MT7621) += mt7621-dma/ | 47 | obj-$(CONFIG_SOC_MT7621) += mt7621-dma/ |
| 48 | obj-$(CONFIG_DMA_RALINK) += ralink-gdma/ | 48 | obj-$(CONFIG_DMA_RALINK) += ralink-gdma/ |
| 49 | obj-$(CONFIG_MTK_MMC) += mt7621-mmc/ | 49 | obj-$(CONFIG_MTK_MMC) += mt7621-mmc/ |
| 50 | obj-$(CONFIG_NET_MEDIATEK_SOC_STAGING) += mt7621-eth/ | ||
| 51 | obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ | 50 | obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ |
| 52 | obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ | 51 | obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ |
| 53 | obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/ | 52 | obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/ |
diff --git a/drivers/staging/axis-fifo/Kconfig b/drivers/staging/axis-fifo/Kconfig index 687537203d9c..d9725888af6f 100644 --- a/drivers/staging/axis-fifo/Kconfig +++ b/drivers/staging/axis-fifo/Kconfig | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | # | 3 | # |
| 4 | config XIL_AXIS_FIFO | 4 | config XIL_AXIS_FIFO |
| 5 | tristate "Xilinx AXI-Stream FIFO IP core driver" | 5 | tristate "Xilinx AXI-Stream FIFO IP core driver" |
| 6 | depends on OF | ||
| 6 | default n | 7 | default n |
| 7 | help | 8 | help |
| 8 | This adds support for the Xilinx AXI-Stream | 9 | This adds support for the Xilinx AXI-Stream |
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index a7d569cfca5d..0dff1ac057cd 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h | |||
| @@ -1001,6 +1001,8 @@ int comedi_dio_insn_config(struct comedi_device *dev, | |||
| 1001 | unsigned int mask); | 1001 | unsigned int mask); |
| 1002 | unsigned int comedi_dio_update_state(struct comedi_subdevice *s, | 1002 | unsigned int comedi_dio_update_state(struct comedi_subdevice *s, |
| 1003 | unsigned int *data); | 1003 | unsigned int *data); |
| 1004 | unsigned int comedi_bytes_per_scan_cmd(struct comedi_subdevice *s, | ||
| 1005 | struct comedi_cmd *cmd); | ||
| 1004 | unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s); | 1006 | unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s); |
| 1005 | unsigned int comedi_nscans_left(struct comedi_subdevice *s, | 1007 | unsigned int comedi_nscans_left(struct comedi_subdevice *s, |
| 1006 | unsigned int nscans); | 1008 | unsigned int nscans); |
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index eefa62f42c0f..5a32b8fc000e 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c | |||
| @@ -394,11 +394,13 @@ unsigned int comedi_dio_update_state(struct comedi_subdevice *s, | |||
| 394 | EXPORT_SYMBOL_GPL(comedi_dio_update_state); | 394 | EXPORT_SYMBOL_GPL(comedi_dio_update_state); |
| 395 | 395 | ||
| 396 | /** | 396 | /** |
| 397 | * comedi_bytes_per_scan() - Get length of asynchronous command "scan" in bytes | 397 | * comedi_bytes_per_scan_cmd() - Get length of asynchronous command "scan" in |
| 398 | * bytes | ||
| 398 | * @s: COMEDI subdevice. | 399 | * @s: COMEDI subdevice. |
| 400 | * @cmd: COMEDI command. | ||
| 399 | * | 401 | * |
| 400 | * Determines the overall scan length according to the subdevice type and the | 402 | * Determines the overall scan length according to the subdevice type and the |
| 401 | * number of channels in the scan. | 403 | * number of channels in the scan for the specified command. |
| 402 | * | 404 | * |
| 403 | * For digital input, output or input/output subdevices, samples for | 405 | * For digital input, output or input/output subdevices, samples for |
| 404 | * multiple channels are assumed to be packed into one or more unsigned | 406 | * multiple channels are assumed to be packed into one or more unsigned |
| @@ -408,9 +410,9 @@ EXPORT_SYMBOL_GPL(comedi_dio_update_state); | |||
| 408 | * | 410 | * |
| 409 | * Returns the overall scan length in bytes. | 411 | * Returns the overall scan length in bytes. |
| 410 | */ | 412 | */ |
| 411 | unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s) | 413 | unsigned int comedi_bytes_per_scan_cmd(struct comedi_subdevice *s, |
| 414 | struct comedi_cmd *cmd) | ||
| 412 | { | 415 | { |
| 413 | struct comedi_cmd *cmd = &s->async->cmd; | ||
| 414 | unsigned int num_samples; | 416 | unsigned int num_samples; |
| 415 | unsigned int bits_per_sample; | 417 | unsigned int bits_per_sample; |
| 416 | 418 | ||
| @@ -427,6 +429,29 @@ unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s) | |||
| 427 | } | 429 | } |
| 428 | return comedi_samples_to_bytes(s, num_samples); | 430 | return comedi_samples_to_bytes(s, num_samples); |
| 429 | } | 431 | } |
| 432 | EXPORT_SYMBOL_GPL(comedi_bytes_per_scan_cmd); | ||
| 433 | |||
| 434 | /** | ||
| 435 | * comedi_bytes_per_scan() - Get length of asynchronous command "scan" in bytes | ||
| 436 | * @s: COMEDI subdevice. | ||
| 437 | * | ||
| 438 | * Determines the overall scan length according to the subdevice type and the | ||
| 439 | * number of channels in the scan for the current command. | ||
| 440 | * | ||
| 441 | * For digital input, output or input/output subdevices, samples for | ||
| 442 | * multiple channels are assumed to be packed into one or more unsigned | ||
| 443 | * short or unsigned int values according to the subdevice's %SDF_LSAMPL | ||
| 444 | * flag. For other types of subdevice, samples are assumed to occupy a | ||
| 445 | * whole unsigned short or unsigned int according to the %SDF_LSAMPL flag. | ||
| 446 | * | ||
| 447 | * Returns the overall scan length in bytes. | ||
| 448 | */ | ||
| 449 | unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s) | ||
| 450 | { | ||
| 451 | struct comedi_cmd *cmd = &s->async->cmd; | ||
| 452 | |||
| 453 | return comedi_bytes_per_scan_cmd(s, cmd); | ||
| 454 | } | ||
| 430 | EXPORT_SYMBOL_GPL(comedi_bytes_per_scan); | 455 | EXPORT_SYMBOL_GPL(comedi_bytes_per_scan); |
| 431 | 456 | ||
| 432 | static unsigned int __comedi_nscans_left(struct comedi_subdevice *s, | 457 | static unsigned int __comedi_nscans_left(struct comedi_subdevice *s, |
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 5edf59ac6706..b04dad8c7092 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c | |||
| @@ -3545,6 +3545,7 @@ static int ni_cdio_cmdtest(struct comedi_device *dev, | |||
| 3545 | struct comedi_subdevice *s, struct comedi_cmd *cmd) | 3545 | struct comedi_subdevice *s, struct comedi_cmd *cmd) |
| 3546 | { | 3546 | { |
| 3547 | struct ni_private *devpriv = dev->private; | 3547 | struct ni_private *devpriv = dev->private; |
| 3548 | unsigned int bytes_per_scan; | ||
| 3548 | int err = 0; | 3549 | int err = 0; |
| 3549 | 3550 | ||
| 3550 | /* Step 1 : check if triggers are trivially valid */ | 3551 | /* Step 1 : check if triggers are trivially valid */ |
| @@ -3579,9 +3580,12 @@ static int ni_cdio_cmdtest(struct comedi_device *dev, | |||
| 3579 | err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0); | 3580 | err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0); |
| 3580 | err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, | 3581 | err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, |
| 3581 | cmd->chanlist_len); | 3582 | cmd->chanlist_len); |
| 3582 | err |= comedi_check_trigger_arg_max(&cmd->stop_arg, | 3583 | bytes_per_scan = comedi_bytes_per_scan_cmd(s, cmd); |
| 3583 | s->async->prealloc_bufsz / | 3584 | if (bytes_per_scan) { |
| 3584 | comedi_bytes_per_scan(s)); | 3585 | err |= comedi_check_trigger_arg_max(&cmd->stop_arg, |
| 3586 | s->async->prealloc_bufsz / | ||
| 3587 | bytes_per_scan); | ||
| 3588 | } | ||
| 3585 | 3589 | ||
| 3586 | if (err) | 3590 | if (err) |
| 3587 | return 3; | 3591 | return 3; |
diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c index 829f7b12e0dc..9bbc68729c11 100644 --- a/drivers/staging/erofs/dir.c +++ b/drivers/staging/erofs/dir.c | |||
| @@ -23,6 +23,21 @@ static const unsigned char erofs_filetype_table[EROFS_FT_MAX] = { | |||
| 23 | [EROFS_FT_SYMLINK] = DT_LNK, | 23 | [EROFS_FT_SYMLINK] = DT_LNK, |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | static void debug_one_dentry(unsigned char d_type, const char *de_name, | ||
| 27 | unsigned int de_namelen) | ||
| 28 | { | ||
| 29 | #ifdef CONFIG_EROFS_FS_DEBUG | ||
| 30 | /* since the on-disk name could not have the trailing '\0' */ | ||
| 31 | unsigned char dbg_namebuf[EROFS_NAME_LEN + 1]; | ||
| 32 | |||
| 33 | memcpy(dbg_namebuf, de_name, de_namelen); | ||
| 34 | dbg_namebuf[de_namelen] = '\0'; | ||
| 35 | |||
| 36 | debugln("found dirent %s de_len %u d_type %d", dbg_namebuf, | ||
| 37 | de_namelen, d_type); | ||
| 38 | #endif | ||
| 39 | } | ||
| 40 | |||
| 26 | static int erofs_fill_dentries(struct dir_context *ctx, | 41 | static int erofs_fill_dentries(struct dir_context *ctx, |
| 27 | void *dentry_blk, unsigned int *ofs, | 42 | void *dentry_blk, unsigned int *ofs, |
| 28 | unsigned int nameoff, unsigned int maxsize) | 43 | unsigned int nameoff, unsigned int maxsize) |
| @@ -33,14 +48,10 @@ static int erofs_fill_dentries(struct dir_context *ctx, | |||
| 33 | de = dentry_blk + *ofs; | 48 | de = dentry_blk + *ofs; |
| 34 | while (de < end) { | 49 | while (de < end) { |
| 35 | const char *de_name; | 50 | const char *de_name; |
| 36 | int de_namelen; | 51 | unsigned int de_namelen; |
| 37 | unsigned char d_type; | 52 | unsigned char d_type; |
| 38 | #ifdef CONFIG_EROFS_FS_DEBUG | ||
| 39 | unsigned int dbg_namelen; | ||
| 40 | unsigned char dbg_namebuf[EROFS_NAME_LEN]; | ||
| 41 | #endif | ||
| 42 | 53 | ||
| 43 | if (unlikely(de->file_type < EROFS_FT_MAX)) | 54 | if (de->file_type < EROFS_FT_MAX) |
| 44 | d_type = erofs_filetype_table[de->file_type]; | 55 | d_type = erofs_filetype_table[de->file_type]; |
| 45 | else | 56 | else |
| 46 | d_type = DT_UNKNOWN; | 57 | d_type = DT_UNKNOWN; |
| @@ -48,26 +59,20 @@ static int erofs_fill_dentries(struct dir_context *ctx, | |||
| 48 | nameoff = le16_to_cpu(de->nameoff); | 59 | nameoff = le16_to_cpu(de->nameoff); |
| 49 | de_name = (char *)dentry_blk + nameoff; | 60 | de_name = (char *)dentry_blk + nameoff; |
| 50 | 61 | ||
| 51 | de_namelen = unlikely(de + 1 >= end) ? | 62 | /* the last dirent in the block? */ |
| 52 | /* last directory entry */ | 63 | if (de + 1 >= end) |
| 53 | strnlen(de_name, maxsize - nameoff) : | 64 | de_namelen = strnlen(de_name, maxsize - nameoff); |
| 54 | le16_to_cpu(de[1].nameoff) - nameoff; | 65 | else |
| 66 | de_namelen = le16_to_cpu(de[1].nameoff) - nameoff; | ||
| 55 | 67 | ||
| 56 | /* a corrupted entry is found */ | 68 | /* a corrupted entry is found */ |
| 57 | if (unlikely(de_namelen < 0)) { | 69 | if (unlikely(nameoff + de_namelen > maxsize || |
| 70 | de_namelen > EROFS_NAME_LEN)) { | ||
| 58 | DBG_BUGON(1); | 71 | DBG_BUGON(1); |
| 59 | return -EIO; | 72 | return -EIO; |
| 60 | } | 73 | } |
| 61 | 74 | ||
| 62 | #ifdef CONFIG_EROFS_FS_DEBUG | 75 | debug_one_dentry(d_type, de_name, de_namelen); |
| 63 | dbg_namelen = min(EROFS_NAME_LEN - 1, de_namelen); | ||
| 64 | memcpy(dbg_namebuf, de_name, dbg_namelen); | ||
| 65 | dbg_namebuf[dbg_namelen] = '\0'; | ||
| 66 | |||
| 67 | debugln("%s, found de_name %s de_len %d d_type %d", __func__, | ||
| 68 | dbg_namebuf, de_namelen, d_type); | ||
| 69 | #endif | ||
| 70 | |||
| 71 | if (!dir_emit(ctx, de_name, de_namelen, | 76 | if (!dir_emit(ctx, de_name, de_namelen, |
| 72 | le64_to_cpu(de->nid), d_type)) | 77 | le64_to_cpu(de->nid), d_type)) |
| 73 | /* stopped by some reason */ | 78 | /* stopped by some reason */ |
diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 8715bc50e09c..31eef8395774 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c | |||
| @@ -972,6 +972,7 @@ repeat: | |||
| 972 | overlapped = false; | 972 | overlapped = false; |
| 973 | compressed_pages = grp->compressed_pages; | 973 | compressed_pages = grp->compressed_pages; |
| 974 | 974 | ||
| 975 | err = 0; | ||
| 975 | for (i = 0; i < clusterpages; ++i) { | 976 | for (i = 0; i < clusterpages; ++i) { |
| 976 | unsigned int pagenr; | 977 | unsigned int pagenr; |
| 977 | 978 | ||
| @@ -981,26 +982,39 @@ repeat: | |||
| 981 | DBG_BUGON(!page); | 982 | DBG_BUGON(!page); |
| 982 | DBG_BUGON(!page->mapping); | 983 | DBG_BUGON(!page->mapping); |
| 983 | 984 | ||
| 984 | if (z_erofs_is_stagingpage(page)) | 985 | if (!z_erofs_is_stagingpage(page)) { |
| 985 | continue; | ||
| 986 | #ifdef EROFS_FS_HAS_MANAGED_CACHE | 986 | #ifdef EROFS_FS_HAS_MANAGED_CACHE |
| 987 | if (page->mapping == MNGD_MAPPING(sbi)) { | 987 | if (page->mapping == MNGD_MAPPING(sbi)) { |
| 988 | DBG_BUGON(!PageUptodate(page)); | 988 | if (unlikely(!PageUptodate(page))) |
| 989 | continue; | 989 | err = -EIO; |
| 990 | } | 990 | continue; |
| 991 | } | ||
| 991 | #endif | 992 | #endif |
| 992 | 993 | ||
| 993 | /* only non-head page could be reused as a compressed page */ | 994 | /* |
| 994 | pagenr = z_erofs_onlinepage_index(page); | 995 | * only if non-head page can be selected |
| 996 | * for inplace decompression | ||
| 997 | */ | ||
| 998 | pagenr = z_erofs_onlinepage_index(page); | ||
| 995 | 999 | ||
| 996 | DBG_BUGON(pagenr >= nr_pages); | 1000 | DBG_BUGON(pagenr >= nr_pages); |
| 997 | DBG_BUGON(pages[pagenr]); | 1001 | DBG_BUGON(pages[pagenr]); |
| 998 | ++sparsemem_pages; | 1002 | ++sparsemem_pages; |
| 999 | pages[pagenr] = page; | 1003 | pages[pagenr] = page; |
| 1000 | 1004 | ||
| 1001 | overlapped = true; | 1005 | overlapped = true; |
| 1006 | } | ||
| 1007 | |||
| 1008 | /* PG_error needs checking for inplaced and staging pages */ | ||
| 1009 | if (unlikely(PageError(page))) { | ||
| 1010 | DBG_BUGON(PageUptodate(page)); | ||
| 1011 | err = -EIO; | ||
| 1012 | } | ||
| 1002 | } | 1013 | } |
| 1003 | 1014 | ||
| 1015 | if (unlikely(err)) | ||
| 1016 | goto out; | ||
| 1017 | |||
| 1004 | llen = (nr_pages << PAGE_SHIFT) - work->pageofs; | 1018 | llen = (nr_pages << PAGE_SHIFT) - work->pageofs; |
| 1005 | 1019 | ||
| 1006 | if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) { | 1020 | if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) { |
| @@ -1029,6 +1043,10 @@ repeat: | |||
| 1029 | 1043 | ||
| 1030 | skip_allocpage: | 1044 | skip_allocpage: |
| 1031 | vout = erofs_vmap(pages, nr_pages); | 1045 | vout = erofs_vmap(pages, nr_pages); |
| 1046 | if (!vout) { | ||
| 1047 | err = -ENOMEM; | ||
| 1048 | goto out; | ||
| 1049 | } | ||
| 1032 | 1050 | ||
| 1033 | err = z_erofs_vle_unzip_vmap(compressed_pages, | 1051 | err = z_erofs_vle_unzip_vmap(compressed_pages, |
| 1034 | clusterpages, vout, llen, work->pageofs, overlapped); | 1052 | clusterpages, vout, llen, work->pageofs, overlapped); |
| @@ -1194,6 +1212,7 @@ repeat: | |||
| 1194 | if (page->mapping == mc) { | 1212 | if (page->mapping == mc) { |
| 1195 | WRITE_ONCE(grp->compressed_pages[nr], page); | 1213 | WRITE_ONCE(grp->compressed_pages[nr], page); |
| 1196 | 1214 | ||
| 1215 | ClearPageError(page); | ||
| 1197 | if (!PagePrivate(page)) { | 1216 | if (!PagePrivate(page)) { |
| 1198 | /* | 1217 | /* |
| 1199 | * impossible to be !PagePrivate(page) for | 1218 | * impossible to be !PagePrivate(page) for |
diff --git a/drivers/staging/erofs/unzip_vle_lz4.c b/drivers/staging/erofs/unzip_vle_lz4.c index 48b263a2731a..0daac9b984a8 100644 --- a/drivers/staging/erofs/unzip_vle_lz4.c +++ b/drivers/staging/erofs/unzip_vle_lz4.c | |||
| @@ -136,10 +136,13 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, | |||
| 136 | 136 | ||
| 137 | nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE); | 137 | nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE); |
| 138 | 138 | ||
| 139 | if (clusterpages == 1) | 139 | if (clusterpages == 1) { |
| 140 | vin = kmap_atomic(compressed_pages[0]); | 140 | vin = kmap_atomic(compressed_pages[0]); |
| 141 | else | 141 | } else { |
| 142 | vin = erofs_vmap(compressed_pages, clusterpages); | 142 | vin = erofs_vmap(compressed_pages, clusterpages); |
| 143 | if (!vin) | ||
| 144 | return -ENOMEM; | ||
| 145 | } | ||
| 143 | 146 | ||
| 144 | preempt_disable(); | 147 | preempt_disable(); |
| 145 | vout = erofs_pcpubuf[smp_processor_id()].data; | 148 | vout = erofs_pcpubuf[smp_processor_id()].data; |
diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts index b73385540216..250c15ace2a7 100644 --- a/drivers/staging/mt7621-dts/gbpc1.dts +++ b/drivers/staging/mt7621-dts/gbpc1.dts | |||
| @@ -117,22 +117,6 @@ | |||
| 117 | status = "okay"; | 117 | status = "okay"; |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | ðernet { | ||
| 121 | //mtd-mac-address = <&factory 0xe000>; | ||
| 122 | gmac1: mac@0 { | ||
| 123 | compatible = "mediatek,eth-mac"; | ||
| 124 | reg = <0>; | ||
| 125 | phy-handle = <&phy1>; | ||
| 126 | }; | ||
| 127 | |||
| 128 | mdio-bus { | ||
| 129 | phy1: ethernet-phy@1 { | ||
| 130 | reg = <1>; | ||
| 131 | phy-mode = "rgmii"; | ||
| 132 | }; | ||
| 133 | }; | ||
| 134 | }; | ||
| 135 | |||
| 136 | &pinctrl { | 120 | &pinctrl { |
| 137 | state_default: pinctrl0 { | 121 | state_default: pinctrl0 { |
| 138 | gpio { | 122 | gpio { |
| @@ -141,3 +125,16 @@ | |||
| 141 | }; | 125 | }; |
| 142 | }; | 126 | }; |
| 143 | }; | 127 | }; |
| 128 | |||
| 129 | &switch0 { | ||
| 130 | ports { | ||
| 131 | port@0 { | ||
| 132 | label = "ethblack"; | ||
| 133 | status = "ok"; | ||
| 134 | }; | ||
| 135 | port@4 { | ||
| 136 | label = "ethblue"; | ||
| 137 | status = "ok"; | ||
| 138 | }; | ||
| 139 | }; | ||
| 140 | }; | ||
diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 6aff3680ce4b..17020e24abd2 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi | |||
| @@ -372,16 +372,83 @@ | |||
| 372 | 372 | ||
| 373 | mediatek,ethsys = <ðsys>; | 373 | mediatek,ethsys = <ðsys>; |
| 374 | 374 | ||
| 375 | mediatek,switch = <&gsw>; | ||
| 376 | 375 | ||
| 376 | gmac0: mac@0 { | ||
| 377 | compatible = "mediatek,eth-mac"; | ||
| 378 | reg = <0>; | ||
| 379 | phy-mode = "rgmii"; | ||
| 380 | fixed-link { | ||
| 381 | speed = <1000>; | ||
| 382 | full-duplex; | ||
| 383 | pause; | ||
| 384 | }; | ||
| 385 | }; | ||
| 386 | gmac1: mac@1 { | ||
| 387 | compatible = "mediatek,eth-mac"; | ||
| 388 | reg = <1>; | ||
| 389 | status = "off"; | ||
| 390 | phy-mode = "rgmii"; | ||
| 391 | phy-handle = <&phy5>; | ||
| 392 | }; | ||
| 377 | mdio-bus { | 393 | mdio-bus { |
| 378 | #address-cells = <1>; | 394 | #address-cells = <1>; |
| 379 | #size-cells = <0>; | 395 | #size-cells = <0>; |
| 380 | 396 | ||
| 381 | phy1f: ethernet-phy@1f { | 397 | phy5: ethernet-phy@5 { |
| 382 | reg = <0x1f>; | 398 | reg = <5>; |
| 383 | phy-mode = "rgmii"; | 399 | phy-mode = "rgmii"; |
| 384 | }; | 400 | }; |
| 401 | |||
| 402 | switch0: switch0@0 { | ||
| 403 | compatible = "mediatek,mt7621"; | ||
| 404 | #address-cells = <1>; | ||
| 405 | #size-cells = <0>; | ||
| 406 | reg = <0>; | ||
| 407 | mediatek,mcm; | ||
| 408 | resets = <&rstctrl 2>; | ||
| 409 | reset-names = "mcm"; | ||
| 410 | |||
| 411 | ports { | ||
| 412 | #address-cells = <1>; | ||
| 413 | #size-cells = <0>; | ||
| 414 | reg = <0>; | ||
| 415 | port@0 { | ||
| 416 | status = "off"; | ||
| 417 | reg = <0>; | ||
| 418 | label = "lan0"; | ||
| 419 | }; | ||
| 420 | port@1 { | ||
| 421 | status = "off"; | ||
| 422 | reg = <1>; | ||
| 423 | label = "lan1"; | ||
| 424 | }; | ||
| 425 | port@2 { | ||
| 426 | status = "off"; | ||
| 427 | reg = <2>; | ||
| 428 | label = "lan2"; | ||
| 429 | }; | ||
| 430 | port@3 { | ||
| 431 | status = "off"; | ||
| 432 | reg = <3>; | ||
| 433 | label = "lan3"; | ||
| 434 | }; | ||
| 435 | port@4 { | ||
| 436 | status = "off"; | ||
| 437 | reg = <4>; | ||
| 438 | label = "lan4"; | ||
| 439 | }; | ||
| 440 | port@6 { | ||
| 441 | reg = <6>; | ||
| 442 | label = "cpu"; | ||
| 443 | ethernet = <&gmac0>; | ||
| 444 | phy-mode = "trgmii"; | ||
| 445 | fixed-link { | ||
| 446 | speed = <1000>; | ||
| 447 | full-duplex; | ||
| 448 | }; | ||
| 449 | }; | ||
| 450 | }; | ||
| 451 | }; | ||
| 385 | }; | 452 | }; |
| 386 | }; | 453 | }; |
| 387 | 454 | ||
diff --git a/drivers/staging/mt7621-eth/Documentation/devicetree/bindings/net/mediatek-net-gsw.txt b/drivers/staging/mt7621-eth/Documentation/devicetree/bindings/net/mediatek-net-gsw.txt deleted file mode 100644 index 596b38552697..000000000000 --- a/drivers/staging/mt7621-eth/Documentation/devicetree/bindings/net/mediatek-net-gsw.txt +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | Mediatek Gigabit Switch | ||
| 2 | ======================= | ||
| 3 | |||
| 4 | The mediatek gigabit switch can be found on Mediatek SoCs. | ||
| 5 | |||
| 6 | Required properties: | ||
| 7 | - compatible: Should be "mediatek,mt7620-gsw", "mediatek,mt7621-gsw", | ||
| 8 | "mediatek,mt7623-gsw" | ||
| 9 | - reg: Address and length of the register set for the device | ||
| 10 | - interrupts: Should contain the gigabit switches interrupt | ||
| 11 | |||
| 12 | |||
| 13 | Additional required properties for ARM based SoCs: | ||
| 14 | - mediatek,reset-pin: phandle describing the reset GPIO | ||
| 15 | - clocks: the clocks used by the switch | ||
| 16 | - clock-names: the names of the clocks listed in the clocks property | ||
| 17 | these should be "trgpll", "esw", "gp2", "gp1" | ||
| 18 | - mt7530-supply: the phandle of the regulator used to power the switch | ||
| 19 | - mediatek,pctl-regmap: phandle to the port control regmap. this is used to | ||
| 20 | setup the drive current | ||
| 21 | |||
| 22 | |||
| 23 | Optional properties: | ||
| 24 | - interrupt-parent: Should be the phandle for the interrupt controller | ||
| 25 | that services interrupts for this device | ||
| 26 | |||
| 27 | Example: | ||
| 28 | |||
| 29 | gsw: switch@1b100000 { | ||
| 30 | compatible = "mediatek,mt7623-gsw"; | ||
| 31 | reg = <0 0x1b110000 0 0x300000>; | ||
| 32 | |||
| 33 | interrupt-parent = <&pio>; | ||
| 34 | interrupts = <168 IRQ_TYPE_EDGE_RISING>; | ||
| 35 | |||
| 36 | clocks = <&apmixedsys CLK_APMIXED_TRGPLL>, | ||
| 37 | <ðsys CLK_ETHSYS_ESW>, | ||
| 38 | <ðsys CLK_ETHSYS_GP2>, | ||
| 39 | <ðsys CLK_ETHSYS_GP1>; | ||
| 40 | clock-names = "trgpll", "esw", "gp2", "gp1"; | ||
| 41 | |||
| 42 | mt7530-supply = <&mt6323_vpa_reg>; | ||
| 43 | |||
| 44 | mediatek,pctl-regmap = <&syscfg_pctl_a>; | ||
| 45 | mediatek,reset-pin = <&pio 15 0>; | ||
| 46 | |||
| 47 | status = "okay"; | ||
| 48 | }; | ||
diff --git a/drivers/staging/mt7621-eth/Kconfig b/drivers/staging/mt7621-eth/Kconfig deleted file mode 100644 index 44ea86c7a96c..000000000000 --- a/drivers/staging/mt7621-eth/Kconfig +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | config NET_VENDOR_MEDIATEK_STAGING | ||
| 2 | bool "MediaTek ethernet driver - staging version" | ||
| 3 | depends on RALINK | ||
| 4 | ---help--- | ||
| 5 | If you have an MT7621 Mediatek SoC with ethernet, say Y. | ||
| 6 | |||
| 7 | if NET_VENDOR_MEDIATEK_STAGING | ||
| 8 | choice | ||
| 9 | prompt "MAC type" | ||
| 10 | |||
| 11 | config NET_MEDIATEK_MT7621 | ||
| 12 | bool "MT7621" | ||
| 13 | depends on MIPS && SOC_MT7621 | ||
| 14 | |||
| 15 | endchoice | ||
| 16 | |||
| 17 | config NET_MEDIATEK_SOC_STAGING | ||
| 18 | tristate "MediaTek SoC Gigabit Ethernet support" | ||
| 19 | depends on NET_VENDOR_MEDIATEK_STAGING | ||
| 20 | select PHYLIB | ||
| 21 | ---help--- | ||
| 22 | This driver supports the gigabit ethernet MACs in the | ||
| 23 | MediaTek SoC family. | ||
| 24 | |||
| 25 | config NET_MEDIATEK_MDIO | ||
| 26 | def_bool NET_MEDIATEK_SOC_STAGING | ||
| 27 | depends on NET_MEDIATEK_MT7621 | ||
| 28 | select PHYLIB | ||
| 29 | |||
| 30 | config NET_MEDIATEK_MDIO_MT7620 | ||
| 31 | def_bool NET_MEDIATEK_SOC_STAGING | ||
| 32 | depends on NET_MEDIATEK_MT7621 | ||
| 33 | select NET_MEDIATEK_MDIO | ||
| 34 | |||
| 35 | config NET_MEDIATEK_GSW_MT7621 | ||
| 36 | def_tristate NET_MEDIATEK_SOC_STAGING | ||
| 37 | depends on NET_MEDIATEK_MT7621 | ||
| 38 | |||
| 39 | endif #NET_VENDOR_MEDIATEK_STAGING | ||
diff --git a/drivers/staging/mt7621-eth/Makefile b/drivers/staging/mt7621-eth/Makefile deleted file mode 100644 index 018bcc3596b3..000000000000 --- a/drivers/staging/mt7621-eth/Makefile +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Makefile for the Ralink SoCs built-in ethernet macs | ||
| 3 | # | ||
| 4 | |||
| 5 | mtk-eth-soc-y += mtk_eth_soc.o ethtool.o | ||
| 6 | |||
| 7 | mtk-eth-soc-$(CONFIG_NET_MEDIATEK_MDIO) += mdio.o | ||
| 8 | mtk-eth-soc-$(CONFIG_NET_MEDIATEK_MDIO_MT7620) += mdio_mt7620.o | ||
| 9 | |||
| 10 | mtk-eth-soc-$(CONFIG_NET_MEDIATEK_MT7621) += soc_mt7621.o | ||
| 11 | |||
| 12 | obj-$(CONFIG_NET_MEDIATEK_GSW_MT7621) += gsw_mt7621.o | ||
| 13 | |||
| 14 | obj-$(CONFIG_NET_MEDIATEK_SOC_STAGING) += mtk-eth-soc.o | ||
diff --git a/drivers/staging/mt7621-eth/TODO b/drivers/staging/mt7621-eth/TODO deleted file mode 100644 index f9e47d4b4cd4..000000000000 --- a/drivers/staging/mt7621-eth/TODO +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 1 | |||
| 2 | - verify devicetree documentation is consistent with code | ||
| 3 | - fix ethtool - currently doesn't return valid data. | ||
| 4 | - general code review and clean up | ||
| 5 | - add support for second MAC on mt7621 | ||
| 6 | - convert gsw code to use switchdev interfaces | ||
| 7 | - md7620_mmi_write etc should probably be wrapped | ||
| 8 | in a regmap abstraction. | ||
| 9 | - Get soc_mt7621 to work with QDMA TX if possible. | ||
| 10 | - Ensure phys are correctly configured when a cable | ||
| 11 | is plugged in. | ||
| 12 | |||
| 13 | Cc: NeilBrown <neil@brown.name> | ||
diff --git a/drivers/staging/mt7621-eth/ethtool.c b/drivers/staging/mt7621-eth/ethtool.c deleted file mode 100644 index 8c4228e2c987..000000000000 --- a/drivers/staging/mt7621-eth/ethtool.c +++ /dev/null | |||
| @@ -1,250 +0,0 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* This program is free software; you can redistribute it and/or modify | ||
| 3 | * it under the terms of the GNU General Public License as published by | ||
| 4 | * the Free Software Foundation; version 2 of the License | ||
| 5 | * | ||
| 6 | * This program is distributed in the hope that it will be useful, | ||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | * GNU General Public License for more details. | ||
| 10 | * | ||
| 11 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 12 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 13 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include "mtk_eth_soc.h" | ||
| 17 | #include "ethtool.h" | ||
| 18 | |||
| 19 | struct mtk_stat { | ||
| 20 | char name[ETH_GSTRING_LEN]; | ||
| 21 | unsigned int idx; | ||
| 22 | }; | ||
| 23 | |||
| 24 | #define MTK_HW_STAT(stat) { \ | ||
| 25 | .name = #stat, \ | ||
| 26 | .idx = offsetof(struct mtk_hw_stats, stat) / sizeof(u64) \ | ||
| 27 | } | ||
| 28 | |||
| 29 | static const struct mtk_stat mtk_ethtool_hw_stats[] = { | ||
| 30 | MTK_HW_STAT(tx_bytes), | ||
| 31 | MTK_HW_STAT(tx_packets), | ||
| 32 | MTK_HW_STAT(tx_skip), | ||
| 33 | MTK_HW_STAT(tx_collisions), | ||
| 34 | MTK_HW_STAT(rx_bytes), | ||
| 35 | MTK_HW_STAT(rx_packets), | ||
| 36 | MTK_HW_STAT(rx_overflow), | ||
| 37 | MTK_HW_STAT(rx_fcs_errors), | ||
| 38 | MTK_HW_STAT(rx_short_errors), | ||
| 39 | MTK_HW_STAT(rx_long_errors), | ||
| 40 | MTK_HW_STAT(rx_checksum_errors), | ||
| 41 | MTK_HW_STAT(rx_flow_control_packets), | ||
| 42 | }; | ||
| 43 | |||
| 44 | #define MTK_HW_STATS_LEN ARRAY_SIZE(mtk_ethtool_hw_stats) | ||
| 45 | |||
| 46 | static int mtk_get_link_ksettings(struct net_device *dev, | ||
| 47 | struct ethtool_link_ksettings *cmd) | ||
| 48 | { | ||
| 49 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 50 | int err; | ||
| 51 | |||
| 52 | if (!mac->phy_dev) | ||
| 53 | return -ENODEV; | ||
| 54 | |||
| 55 | if (mac->phy_flags == MTK_PHY_FLAG_ATTACH) { | ||
| 56 | err = phy_read_status(mac->phy_dev); | ||
| 57 | if (err) | ||
| 58 | return -ENODEV; | ||
| 59 | } | ||
| 60 | |||
| 61 | phy_ethtool_ksettings_get(mac->phy_dev, cmd); | ||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | |||
| 65 | static int mtk_set_link_ksettings(struct net_device *dev, | ||
| 66 | const struct ethtool_link_ksettings *cmd) | ||
| 67 | { | ||
| 68 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 69 | |||
| 70 | if (!mac->phy_dev) | ||
| 71 | return -ENODEV; | ||
| 72 | |||
| 73 | if (cmd->base.phy_address != mac->phy_dev->mdio.addr) { | ||
| 74 | if (mac->hw->phy->phy_node[cmd->base.phy_address]) { | ||
| 75 | mac->phy_dev = mac->hw->phy->phy[cmd->base.phy_address]; | ||
| 76 | mac->phy_flags = MTK_PHY_FLAG_PORT; | ||
| 77 | } else if (mac->hw->mii_bus) { | ||
| 78 | mac->phy_dev = mdiobus_get_phy(mac->hw->mii_bus, | ||
| 79 | cmd->base.phy_address); | ||
| 80 | if (!mac->phy_dev) | ||
| 81 | return -ENODEV; | ||
| 82 | mac->phy_flags = MTK_PHY_FLAG_ATTACH; | ||
| 83 | } else { | ||
| 84 | return -ENODEV; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | return phy_ethtool_ksettings_set(mac->phy_dev, cmd); | ||
| 89 | } | ||
| 90 | |||
| 91 | static void mtk_get_drvinfo(struct net_device *dev, | ||
| 92 | struct ethtool_drvinfo *info) | ||
| 93 | { | ||
| 94 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 95 | struct mtk_soc_data *soc = mac->hw->soc; | ||
| 96 | |||
| 97 | strlcpy(info->driver, mac->hw->dev->driver->name, sizeof(info->driver)); | ||
| 98 | strlcpy(info->bus_info, dev_name(mac->hw->dev), sizeof(info->bus_info)); | ||
| 99 | |||
| 100 | if (soc->reg_table[MTK_REG_MTK_COUNTER_BASE]) | ||
| 101 | info->n_stats = MTK_HW_STATS_LEN; | ||
| 102 | } | ||
| 103 | |||
| 104 | static u32 mtk_get_msglevel(struct net_device *dev) | ||
| 105 | { | ||
| 106 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 107 | |||
| 108 | return mac->hw->msg_enable; | ||
| 109 | } | ||
| 110 | |||
| 111 | static void mtk_set_msglevel(struct net_device *dev, u32 value) | ||
| 112 | { | ||
| 113 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 114 | |||
| 115 | mac->hw->msg_enable = value; | ||
| 116 | } | ||
| 117 | |||
| 118 | static int mtk_nway_reset(struct net_device *dev) | ||
| 119 | { | ||
| 120 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 121 | |||
| 122 | if (!mac->phy_dev) | ||
| 123 | return -EOPNOTSUPP; | ||
| 124 | |||
| 125 | return genphy_restart_aneg(mac->phy_dev); | ||
| 126 | } | ||
| 127 | |||
| 128 | static u32 mtk_get_link(struct net_device *dev) | ||
| 129 | { | ||
| 130 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 131 | int err; | ||
| 132 | |||
| 133 | if (!mac->phy_dev) | ||
| 134 | goto out_get_link; | ||
| 135 | |||
| 136 | if (mac->phy_flags == MTK_PHY_FLAG_ATTACH) { | ||
| 137 | err = genphy_update_link(mac->phy_dev); | ||
| 138 | if (err) | ||
| 139 | goto out_get_link; | ||
| 140 | } | ||
| 141 | |||
| 142 | return mac->phy_dev->link; | ||
| 143 | |||
| 144 | out_get_link: | ||
| 145 | return ethtool_op_get_link(dev); | ||
| 146 | } | ||
| 147 | |||
| 148 | static int mtk_set_ringparam(struct net_device *dev, | ||
| 149 | struct ethtool_ringparam *ring) | ||
| 150 | { | ||
| 151 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 152 | |||
| 153 | if ((ring->tx_pending < 2) || | ||
| 154 | (ring->rx_pending < 2) || | ||
| 155 | (ring->rx_pending > mac->hw->soc->dma_ring_size) || | ||
| 156 | (ring->tx_pending > mac->hw->soc->dma_ring_size)) | ||
| 157 | return -EINVAL; | ||
| 158 | |||
| 159 | dev->netdev_ops->ndo_stop(dev); | ||
| 160 | |||
| 161 | mac->hw->tx_ring.tx_ring_size = BIT(fls(ring->tx_pending) - 1); | ||
| 162 | mac->hw->rx_ring[0].rx_ring_size = BIT(fls(ring->rx_pending) - 1); | ||
| 163 | |||
| 164 | return dev->netdev_ops->ndo_open(dev); | ||
| 165 | } | ||
| 166 | |||
| 167 | static void mtk_get_ringparam(struct net_device *dev, | ||
| 168 | struct ethtool_ringparam *ring) | ||
| 169 | { | ||
| 170 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 171 | |||
| 172 | ring->rx_max_pending = mac->hw->soc->dma_ring_size; | ||
| 173 | ring->tx_max_pending = mac->hw->soc->dma_ring_size; | ||
| 174 | ring->rx_pending = mac->hw->rx_ring[0].rx_ring_size; | ||
| 175 | ring->tx_pending = mac->hw->tx_ring.tx_ring_size; | ||
| 176 | } | ||
| 177 | |||
| 178 | static void mtk_get_strings(struct net_device *dev, u32 stringset, u8 *data) | ||
| 179 | { | ||
| 180 | int i; | ||
| 181 | |||
| 182 | switch (stringset) { | ||
| 183 | case ETH_SS_STATS: | ||
| 184 | for (i = 0; i < MTK_HW_STATS_LEN; i++) { | ||
| 185 | memcpy(data, mtk_ethtool_hw_stats[i].name, | ||
| 186 | ETH_GSTRING_LEN); | ||
| 187 | data += ETH_GSTRING_LEN; | ||
| 188 | } | ||
| 189 | break; | ||
| 190 | } | ||
| 191 | } | ||
| 192 | |||
| 193 | static int mtk_get_sset_count(struct net_device *dev, int sset) | ||
| 194 | { | ||
| 195 | switch (sset) { | ||
| 196 | case ETH_SS_STATS: | ||
| 197 | return MTK_HW_STATS_LEN; | ||
| 198 | default: | ||
| 199 | return -EOPNOTSUPP; | ||
| 200 | } | ||
| 201 | } | ||
| 202 | |||
| 203 | static void mtk_get_ethtool_stats(struct net_device *dev, | ||
| 204 | struct ethtool_stats *stats, u64 *data) | ||
| 205 | { | ||
| 206 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 207 | struct mtk_hw_stats *hwstats = mac->hw_stats; | ||
| 208 | unsigned int start; | ||
| 209 | int i; | ||
| 210 | |||
| 211 | if (netif_running(dev) && netif_device_present(dev)) { | ||
| 212 | if (spin_trylock(&hwstats->stats_lock)) { | ||
| 213 | mtk_stats_update_mac(mac); | ||
| 214 | spin_unlock(&hwstats->stats_lock); | ||
| 215 | } | ||
| 216 | } | ||
| 217 | |||
| 218 | do { | ||
| 219 | start = u64_stats_fetch_begin_irq(&hwstats->syncp); | ||
| 220 | for (i = 0; i < MTK_HW_STATS_LEN; i++) | ||
| 221 | data[i] = ((u64 *)hwstats)[mtk_ethtool_hw_stats[i].idx]; | ||
| 222 | |||
| 223 | } while (u64_stats_fetch_retry_irq(&hwstats->syncp, start)); | ||
| 224 | } | ||
| 225 | |||
| 226 | static struct ethtool_ops mtk_ethtool_ops = { | ||
| 227 | .get_link_ksettings = mtk_get_link_ksettings, | ||
| 228 | .set_link_ksettings = mtk_set_link_ksettings, | ||
| 229 | .get_drvinfo = mtk_get_drvinfo, | ||
| 230 | .get_msglevel = mtk_get_msglevel, | ||
| 231 | .set_msglevel = mtk_set_msglevel, | ||
| 232 | .nway_reset = mtk_nway_reset, | ||
| 233 | .get_link = mtk_get_link, | ||
| 234 | .set_ringparam = mtk_set_ringparam, | ||
| 235 | .get_ringparam = mtk_get_ringparam, | ||
| 236 | }; | ||
| 237 | |||
| 238 | void mtk_set_ethtool_ops(struct net_device *netdev) | ||
| 239 | { | ||
| 240 | struct mtk_mac *mac = netdev_priv(netdev); | ||
| 241 | struct mtk_soc_data *soc = mac->hw->soc; | ||
| 242 | |||
| 243 | if (soc->reg_table[MTK_REG_MTK_COUNTER_BASE]) { | ||
| 244 | mtk_ethtool_ops.get_strings = mtk_get_strings; | ||
| 245 | mtk_ethtool_ops.get_sset_count = mtk_get_sset_count; | ||
| 246 | mtk_ethtool_ops.get_ethtool_stats = mtk_get_ethtool_stats; | ||
| 247 | } | ||
| 248 | |||
| 249 | netdev->ethtool_ops = &mtk_ethtool_ops; | ||
| 250 | } | ||
diff --git a/drivers/staging/mt7621-eth/ethtool.h b/drivers/staging/mt7621-eth/ethtool.h deleted file mode 100644 index 0071469aea6c..000000000000 --- a/drivers/staging/mt7621-eth/ethtool.h +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 4 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 5 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef MTK_ETHTOOL_H | ||
| 9 | #define MTK_ETHTOOL_H | ||
| 10 | |||
| 11 | #include <linux/ethtool.h> | ||
| 12 | |||
| 13 | void mtk_set_ethtool_ops(struct net_device *netdev); | ||
| 14 | |||
| 15 | #endif /* MTK_ETHTOOL_H */ | ||
diff --git a/drivers/staging/mt7621-eth/gsw_mt7620.h b/drivers/staging/mt7621-eth/gsw_mt7620.h deleted file mode 100644 index 70f7e5481952..000000000000 --- a/drivers/staging/mt7621-eth/gsw_mt7620.h +++ /dev/null | |||
| @@ -1,277 +0,0 @@ | |||
| 1 | /* This program is free software; you can redistribute it and/or modify | ||
| 2 | * it under the terms of the GNU General Public License as published by | ||
| 3 | * the Free Software Foundation; version 2 of the License | ||
| 4 | * | ||
| 5 | * This program is distributed in the hope that it will be useful, | ||
| 6 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 7 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 8 | * GNU General Public License for more details. | ||
| 9 | * | ||
| 10 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 11 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 12 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef _RALINK_GSW_MT7620_H__ | ||
| 16 | #define _RALINK_GSW_MT7620_H__ | ||
| 17 | |||
| 18 | #define GSW_REG_PHY_TIMEOUT (5 * HZ) | ||
| 19 | |||
| 20 | #define MT7620_GSW_REG_PIAC 0x0004 | ||
| 21 | |||
| 22 | #define GSW_NUM_VLANS 16 | ||
| 23 | #define GSW_NUM_VIDS 4096 | ||
| 24 | #define GSW_NUM_PORTS 7 | ||
| 25 | #define GSW_PORT6 6 | ||
| 26 | |||
| 27 | #define GSW_MDIO_ACCESS BIT(31) | ||
| 28 | #define GSW_MDIO_READ BIT(19) | ||
| 29 | #define GSW_MDIO_WRITE BIT(18) | ||
| 30 | #define GSW_MDIO_START BIT(16) | ||
| 31 | #define GSW_MDIO_ADDR_SHIFT 20 | ||
| 32 | #define GSW_MDIO_REG_SHIFT 25 | ||
| 33 | |||
| 34 | #define GSW_REG_PORT_PMCR(x) (0x3000 + (x * 0x100)) | ||
| 35 | #define GSW_REG_PORT_STATUS(x) (0x3008 + (x * 0x100)) | ||
| 36 | #define GSW_REG_SMACCR0 0x3fE4 | ||
| 37 | #define GSW_REG_SMACCR1 0x3fE8 | ||
| 38 | #define GSW_REG_CKGCR 0x3ff0 | ||
| 39 | |||
| 40 | #define GSW_REG_IMR 0x7008 | ||
| 41 | #define GSW_REG_ISR 0x700c | ||
| 42 | #define GSW_REG_GPC1 0x7014 | ||
| 43 | |||
| 44 | #define SYSC_REG_CHIP_REV_ID 0x0c | ||
| 45 | #define SYSC_REG_CFG 0x10 | ||
| 46 | #define SYSC_REG_CFG1 0x14 | ||
| 47 | #define RST_CTRL_MCM BIT(2) | ||
| 48 | #define SYSC_PAD_RGMII2_MDIO 0x58 | ||
| 49 | #define SYSC_GPIO_MODE 0x60 | ||
| 50 | |||
| 51 | #define PORT_IRQ_ST_CHG 0x7f | ||
| 52 | |||
| 53 | #define MT7621_ESW_PHY_POLLING 0x0000 | ||
| 54 | #define MT7620_ESW_PHY_POLLING 0x7000 | ||
| 55 | |||
| 56 | #define PMCR_IPG BIT(18) | ||
| 57 | #define PMCR_MAC_MODE BIT(16) | ||
| 58 | #define PMCR_FORCE BIT(15) | ||
| 59 | #define PMCR_TX_EN BIT(14) | ||
| 60 | #define PMCR_RX_EN BIT(13) | ||
| 61 | #define PMCR_BACKOFF BIT(9) | ||
| 62 | #define PMCR_BACKPRES BIT(8) | ||
| 63 | #define PMCR_RX_FC BIT(5) | ||
| 64 | #define PMCR_TX_FC BIT(4) | ||
| 65 | #define PMCR_SPEED(_x) (_x << 2) | ||
| 66 | #define PMCR_DUPLEX BIT(1) | ||
| 67 | #define PMCR_LINK BIT(0) | ||
| 68 | |||
| 69 | #define PHY_AN_EN BIT(31) | ||
| 70 | #define PHY_PRE_EN BIT(30) | ||
| 71 | #define PMY_MDC_CONF(_x) ((_x & 0x3f) << 24) | ||
| 72 | |||
| 73 | /* ethernet subsystem config register */ | ||
| 74 | #define ETHSYS_SYSCFG0 0x14 | ||
| 75 | /* ethernet subsystem clock register */ | ||
| 76 | #define ETHSYS_CLKCFG0 0x2c | ||
| 77 | #define ETHSYS_TRGMII_CLK_SEL362_5 BIT(11) | ||
| 78 | |||
| 79 | /* p5 RGMII wrapper TX clock control register */ | ||
| 80 | #define MT7530_P5RGMIITXCR 0x7b04 | ||
| 81 | /* p5 RGMII wrapper RX clock control register */ | ||
| 82 | #define MT7530_P5RGMIIRXCR 0x7b00 | ||
| 83 | /* TRGMII TDX ODT registers */ | ||
| 84 | #define MT7530_TRGMII_TD0_ODT 0x7a54 | ||
| 85 | #define MT7530_TRGMII_TD1_ODT 0x7a5c | ||
| 86 | #define MT7530_TRGMII_TD2_ODT 0x7a64 | ||
| 87 | #define MT7530_TRGMII_TD3_ODT 0x7a6c | ||
| 88 | #define MT7530_TRGMII_TD4_ODT 0x7a74 | ||
| 89 | #define MT7530_TRGMII_TD5_ODT 0x7a7c | ||
| 90 | /* TRGMII TCK ctrl register */ | ||
| 91 | #define MT7530_TRGMII_TCK_CTRL 0x7a78 | ||
| 92 | /* TRGMII Tx ctrl register */ | ||
| 93 | #define MT7530_TRGMII_TXCTRL 0x7a40 | ||
| 94 | /* port 6 extended control register */ | ||
| 95 | #define MT7530_P6ECR 0x7830 | ||
| 96 | /* IO driver control register */ | ||
| 97 | #define MT7530_IO_DRV_CR 0x7810 | ||
| 98 | /* top signal control register */ | ||
| 99 | #define MT7530_TOP_SIG_CTRL 0x7808 | ||
| 100 | /* modified hwtrap register */ | ||
| 101 | #define MT7530_MHWTRAP 0x7804 | ||
| 102 | /* hwtrap status register */ | ||
| 103 | #define MT7530_HWTRAP 0x7800 | ||
| 104 | /* status interrupt register */ | ||
| 105 | #define MT7530_SYS_INT_STS 0x700c | ||
| 106 | /* system nterrupt register */ | ||
| 107 | #define MT7530_SYS_INT_EN 0x7008 | ||
| 108 | /* system control register */ | ||
| 109 | #define MT7530_SYS_CTRL 0x7000 | ||
| 110 | /* port MAC status register */ | ||
| 111 | #define MT7530_PMSR_P(x) (0x3008 + (x * 0x100)) | ||
| 112 | /* port MAC control register */ | ||
| 113 | #define MT7530_PMCR_P(x) (0x3000 + (x * 0x100)) | ||
| 114 | |||
| 115 | #define MT7621_XTAL_SHIFT 6 | ||
| 116 | #define MT7621_XTAL_MASK 0x7 | ||
| 117 | #define MT7621_XTAL_25 6 | ||
| 118 | #define MT7621_XTAL_40 3 | ||
| 119 | #define MT7621_MDIO_DRV_MASK (3 << 4) | ||
| 120 | #define MT7621_GE1_MODE_MASK (3 << 12) | ||
| 121 | |||
| 122 | #define TRGMII_TXCTRL_TXC_INV BIT(30) | ||
| 123 | #define P6ECR_INTF_MODE_RGMII BIT(1) | ||
| 124 | #define P5RGMIIRXCR_C_ALIGN BIT(8) | ||
| 125 | #define P5RGMIIRXCR_DELAY_2 BIT(1) | ||
| 126 | #define P5RGMIITXCR_DELAY_2 (BIT(8) | BIT(2)) | ||
| 127 | |||
| 128 | /* TOP_SIG_CTRL bits */ | ||
| 129 | #define TOP_SIG_CTRL_NORMAL (BIT(17) | BIT(16)) | ||
| 130 | |||
| 131 | /* MHWTRAP bits */ | ||
| 132 | #define MHWTRAP_MANUAL BIT(16) | ||
| 133 | #define MHWTRAP_P5_MAC_SEL BIT(13) | ||
| 134 | #define MHWTRAP_P6_DIS BIT(8) | ||
| 135 | #define MHWTRAP_P5_RGMII_MODE BIT(7) | ||
| 136 | #define MHWTRAP_P5_DIS BIT(6) | ||
| 137 | #define MHWTRAP_PHY_ACCESS BIT(5) | ||
| 138 | |||
| 139 | /* HWTRAP bits */ | ||
| 140 | #define HWTRAP_XTAL_SHIFT 9 | ||
| 141 | #define HWTRAP_XTAL_MASK 0x3 | ||
| 142 | |||
| 143 | /* SYS_CTRL bits */ | ||
| 144 | #define SYS_CTRL_SW_RST BIT(1) | ||
| 145 | #define SYS_CTRL_REG_RST BIT(0) | ||
| 146 | |||
| 147 | /* PMCR bits */ | ||
| 148 | #define PMCR_IFG_XMIT_96 BIT(18) | ||
| 149 | #define PMCR_MAC_MODE BIT(16) | ||
| 150 | #define PMCR_FORCE_MODE BIT(15) | ||
| 151 | #define PMCR_TX_EN BIT(14) | ||
| 152 | #define PMCR_RX_EN BIT(13) | ||
| 153 | #define PMCR_BACK_PRES_EN BIT(9) | ||
| 154 | #define PMCR_BACKOFF_EN BIT(8) | ||
| 155 | #define PMCR_TX_FC_EN BIT(5) | ||
| 156 | #define PMCR_RX_FC_EN BIT(4) | ||
| 157 | #define PMCR_FORCE_SPEED_1000 BIT(3) | ||
| 158 | #define PMCR_FORCE_FDX BIT(1) | ||
| 159 | #define PMCR_FORCE_LNK BIT(0) | ||
| 160 | #define PMCR_FIXED_LINK (PMCR_IFG_XMIT_96 | PMCR_MAC_MODE | \ | ||
| 161 | PMCR_FORCE_MODE | PMCR_TX_EN | PMCR_RX_EN | \ | ||
| 162 | PMCR_BACK_PRES_EN | PMCR_BACKOFF_EN | \ | ||
| 163 | PMCR_FORCE_SPEED_1000 | PMCR_FORCE_FDX | \ | ||
| 164 | PMCR_FORCE_LNK) | ||
| 165 | |||
| 166 | #define PMCR_FIXED_LINK_FC (PMCR_FIXED_LINK | \ | ||
| 167 | PMCR_TX_FC_EN | PMCR_RX_FC_EN) | ||
| 168 | |||
| 169 | /* TRGMII control registers */ | ||
| 170 | #define GSW_INTF_MODE 0x390 | ||
| 171 | #define GSW_TRGMII_TD0_ODT 0x354 | ||
| 172 | #define GSW_TRGMII_TD1_ODT 0x35c | ||
| 173 | #define GSW_TRGMII_TD2_ODT 0x364 | ||
| 174 | #define GSW_TRGMII_TD3_ODT 0x36c | ||
| 175 | #define GSW_TRGMII_TXCTL_ODT 0x374 | ||
| 176 | #define GSW_TRGMII_TCK_ODT 0x37c | ||
| 177 | #define GSW_TRGMII_RCK_CTRL 0x300 | ||
| 178 | |||
| 179 | #define INTF_MODE_TRGMII BIT(1) | ||
| 180 | #define TRGMII_RCK_CTRL_RX_RST BIT(31) | ||
| 181 | |||
| 182 | /* Mac control registers */ | ||
| 183 | #define MTK_MAC_P2_MCR 0x200 | ||
| 184 | #define MTK_MAC_P1_MCR 0x100 | ||
| 185 | |||
| 186 | #define MAC_MCR_MAX_RX_2K BIT(29) | ||
| 187 | #define MAC_MCR_IPG_CFG (BIT(18) | BIT(16)) | ||
| 188 | #define MAC_MCR_FORCE_MODE BIT(15) | ||
| 189 | #define MAC_MCR_TX_EN BIT(14) | ||
| 190 | #define MAC_MCR_RX_EN BIT(13) | ||
| 191 | #define MAC_MCR_BACKOFF_EN BIT(9) | ||
| 192 | #define MAC_MCR_BACKPR_EN BIT(8) | ||
| 193 | #define MAC_MCR_FORCE_RX_FC BIT(5) | ||
| 194 | #define MAC_MCR_FORCE_TX_FC BIT(4) | ||
| 195 | #define MAC_MCR_SPEED_1000 BIT(3) | ||
| 196 | #define MAC_MCR_FORCE_DPX BIT(1) | ||
| 197 | #define MAC_MCR_FORCE_LINK BIT(0) | ||
| 198 | #define MAC_MCR_FIXED_LINK (MAC_MCR_MAX_RX_2K | MAC_MCR_IPG_CFG | \ | ||
| 199 | MAC_MCR_FORCE_MODE | MAC_MCR_TX_EN | \ | ||
| 200 | MAC_MCR_RX_EN | MAC_MCR_BACKOFF_EN | \ | ||
| 201 | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_RX_FC | \ | ||
| 202 | MAC_MCR_FORCE_TX_FC | MAC_MCR_SPEED_1000 | \ | ||
| 203 | MAC_MCR_FORCE_DPX | MAC_MCR_FORCE_LINK) | ||
| 204 | #define MAC_MCR_FIXED_LINK_FC (MAC_MCR_MAX_RX_2K | MAC_MCR_IPG_CFG | \ | ||
| 205 | MAC_MCR_FIXED_LINK) | ||
| 206 | |||
| 207 | /* possible XTAL speed */ | ||
| 208 | #define MT7623_XTAL_40 0 | ||
| 209 | #define MT7623_XTAL_20 1 | ||
| 210 | #define MT7623_XTAL_25 3 | ||
| 211 | |||
| 212 | /* GPIO port control registers */ | ||
| 213 | #define GPIO_OD33_CTRL8 0x4c0 | ||
| 214 | #define GPIO_BIAS_CTRL 0xed0 | ||
| 215 | #define GPIO_DRV_SEL10 0xf00 | ||
| 216 | |||
| 217 | /* on MT7620 the functio of port 4 can be software configured */ | ||
| 218 | enum { | ||
| 219 | PORT4_EPHY = 0, | ||
| 220 | PORT4_EXT, | ||
| 221 | }; | ||
| 222 | |||
| 223 | /* struct mt7620_gsw - the structure that holds the SoC specific data | ||
| 224 | * @dev: The Device struct | ||
| 225 | * @base: The base address | ||
| 226 | * @piac_offset: The PIAC base may change depending on SoC | ||
| 227 | * @irq: The IRQ we are using | ||
| 228 | * @port4: The port4 mode on MT7620 | ||
| 229 | * @autopoll: Is MDIO autopolling enabled | ||
| 230 | * @ethsys: The ethsys register map | ||
| 231 | * @pctl: The pin control register map | ||
| 232 | * @clk_gsw: The switch clock | ||
| 233 | * @clk_gp1: The gmac1 clock | ||
| 234 | * @clk_gp2: The gmac2 clock | ||
| 235 | * @clk_trgpll: The trgmii pll clock | ||
| 236 | */ | ||
| 237 | struct mt7620_gsw { | ||
| 238 | struct device *dev; | ||
| 239 | void __iomem *base; | ||
| 240 | u32 piac_offset; | ||
| 241 | int irq; | ||
| 242 | int port4; | ||
| 243 | unsigned long int autopoll; | ||
| 244 | |||
| 245 | struct regmap *ethsys; | ||
| 246 | struct regmap *pctl; | ||
| 247 | |||
| 248 | struct clk *clk_gsw; | ||
| 249 | struct clk *clk_gp1; | ||
| 250 | struct clk *clk_gp2; | ||
| 251 | struct clk *clk_trgpll; | ||
| 252 | }; | ||
| 253 | |||
| 254 | /* switch register I/O wrappers */ | ||
| 255 | void mtk_switch_w32(struct mt7620_gsw *gsw, u32 val, unsigned int reg); | ||
| 256 | u32 mtk_switch_r32(struct mt7620_gsw *gsw, unsigned int reg); | ||
| 257 | |||
| 258 | /* the callback used by the driver core to bringup the switch */ | ||
| 259 | int mtk_gsw_init(struct mtk_eth *eth); | ||
| 260 | |||
| 261 | /* MDIO access wrappers */ | ||
| 262 | int mt7620_mdio_write(struct mii_bus *bus, int phy_addr, int phy_reg, u16 val); | ||
| 263 | int mt7620_mdio_read(struct mii_bus *bus, int phy_addr, int phy_reg); | ||
| 264 | void mt7620_mdio_link_adjust(struct mtk_eth *eth, int port); | ||
| 265 | int mt7620_has_carrier(struct mtk_eth *eth); | ||
| 266 | void mt7620_print_link_state(struct mtk_eth *eth, int port, int link, | ||
| 267 | int speed, int duplex); | ||
| 268 | void mt7530_mdio_w32(struct mt7620_gsw *gsw, u32 reg, u32 val); | ||
| 269 | u32 mt7530_mdio_r32(struct mt7620_gsw *gsw, u32 reg); | ||
| 270 | void mt7530_mdio_m32(struct mt7620_gsw *gsw, u32 mask, u32 set, u32 reg); | ||
| 271 | |||
| 272 | u32 _mt7620_mii_write(struct mt7620_gsw *gsw, u32 phy_addr, | ||
| 273 | u32 phy_register, u32 write_data); | ||
| 274 | u32 _mt7620_mii_read(struct mt7620_gsw *gsw, int phy_addr, int phy_reg); | ||
| 275 | void mt7620_handle_carrier(struct mtk_eth *eth); | ||
| 276 | |||
| 277 | #endif | ||
diff --git a/drivers/staging/mt7621-eth/gsw_mt7621.c b/drivers/staging/mt7621-eth/gsw_mt7621.c deleted file mode 100644 index 53767b17bad9..000000000000 --- a/drivers/staging/mt7621-eth/gsw_mt7621.c +++ /dev/null | |||
| @@ -1,297 +0,0 @@ | |||
| 1 | /* This program is free software; you can redistribute it and/or modify | ||
| 2 | * it under the terms of the GNU General Public License as published by | ||
| 3 | * the Free Software Foundation; version 2 of the License | ||
| 4 | * | ||
| 5 | * This program is distributed in the hope that it will be useful, | ||
| 6 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 7 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 8 | * GNU General Public License for more details. | ||
| 9 | * | ||
| 10 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 11 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 12 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | #include <linux/types.h> | ||
| 18 | #include <linux/platform_device.h> | ||
| 19 | #include <linux/of_device.h> | ||
| 20 | #include <linux/of_irq.h> | ||
| 21 | |||
| 22 | #include <ralink_regs.h> | ||
| 23 | |||
| 24 | #include "mtk_eth_soc.h" | ||
| 25 | #include "gsw_mt7620.h" | ||
| 26 | |||
| 27 | void mtk_switch_w32(struct mt7620_gsw *gsw, u32 val, unsigned int reg) | ||
| 28 | { | ||
| 29 | iowrite32(val, gsw->base + reg); | ||
| 30 | } | ||
| 31 | EXPORT_SYMBOL_GPL(mtk_switch_w32); | ||
| 32 | |||
| 33 | u32 mtk_switch_r32(struct mt7620_gsw *gsw, unsigned int reg) | ||
| 34 | { | ||
| 35 | return ioread32(gsw->base + reg); | ||
| 36 | } | ||
| 37 | EXPORT_SYMBOL_GPL(mtk_switch_r32); | ||
| 38 | |||
| 39 | static irqreturn_t gsw_interrupt_mt7621(int irq, void *_eth) | ||
| 40 | { | ||
| 41 | struct mtk_eth *eth = (struct mtk_eth *)_eth; | ||
| 42 | struct mt7620_gsw *gsw = (struct mt7620_gsw *)eth->sw_priv; | ||
| 43 | u32 reg, i; | ||
| 44 | |||
| 45 | reg = mt7530_mdio_r32(gsw, MT7530_SYS_INT_STS); | ||
| 46 | |||
| 47 | for (i = 0; i < 5; i++) { | ||
| 48 | unsigned int link; | ||
| 49 | |||
| 50 | if ((reg & BIT(i)) == 0) | ||
| 51 | continue; | ||
| 52 | |||
| 53 | link = mt7530_mdio_r32(gsw, MT7530_PMSR_P(i)) & 0x1; | ||
| 54 | |||
| 55 | if (link == eth->link[i]) | ||
| 56 | continue; | ||
| 57 | |||
| 58 | eth->link[i] = link; | ||
| 59 | if (link) | ||
| 60 | netdev_info(*eth->netdev, | ||
| 61 | "port %d link up\n", i); | ||
| 62 | else | ||
| 63 | netdev_info(*eth->netdev, | ||
| 64 | "port %d link down\n", i); | ||
| 65 | } | ||
| 66 | |||
| 67 | mt7530_mdio_w32(gsw, MT7530_SYS_INT_STS, 0x1f); | ||
| 68 | |||
| 69 | return IRQ_HANDLED; | ||
| 70 | } | ||
| 71 | |||
| 72 | static void mt7621_hw_init(struct mtk_eth *eth, struct mt7620_gsw *gsw, | ||
| 73 | struct device_node *np) | ||
| 74 | { | ||
| 75 | u32 i; | ||
| 76 | u32 val; | ||
| 77 | |||
| 78 | /* hardware reset the switch */ | ||
| 79 | mtk_reset(eth, RST_CTRL_MCM); | ||
| 80 | mdelay(10); | ||
| 81 | |||
| 82 | /* reduce RGMII2 PAD driving strength */ | ||
| 83 | rt_sysc_m32(MT7621_MDIO_DRV_MASK, 0, SYSC_PAD_RGMII2_MDIO); | ||
| 84 | |||
| 85 | /* gpio mux - RGMII1=Normal mode */ | ||
| 86 | rt_sysc_m32(BIT(14), 0, SYSC_GPIO_MODE); | ||
| 87 | |||
| 88 | /* set GMAC1 RGMII mode */ | ||
| 89 | rt_sysc_m32(MT7621_GE1_MODE_MASK, 0, SYSC_REG_CFG1); | ||
| 90 | |||
| 91 | /* enable MDIO to control MT7530 */ | ||
| 92 | rt_sysc_m32(3 << 12, 0, SYSC_GPIO_MODE); | ||
| 93 | |||
| 94 | /* turn off all PHYs */ | ||
| 95 | for (i = 0; i <= 4; i++) { | ||
| 96 | val = _mt7620_mii_read(gsw, i, 0x0); | ||
| 97 | val |= BIT(11); | ||
| 98 | _mt7620_mii_write(gsw, i, 0x0, val); | ||
| 99 | } | ||
| 100 | |||
| 101 | /* reset the switch */ | ||
| 102 | mt7530_mdio_w32(gsw, MT7530_SYS_CTRL, | ||
| 103 | SYS_CTRL_SW_RST | SYS_CTRL_REG_RST); | ||
| 104 | usleep_range(10, 20); | ||
| 105 | |||
| 106 | if ((rt_sysc_r32(SYSC_REG_CHIP_REV_ID) & 0xFFFF) == 0x0101) { | ||
| 107 | /* GE1, Force 1000M/FD, FC ON, MAX_RX_LENGTH 1536 */ | ||
| 108 | mtk_switch_w32(gsw, MAC_MCR_FIXED_LINK, MTK_MAC_P2_MCR); | ||
| 109 | mt7530_mdio_w32(gsw, MT7530_PMCR_P(6), PMCR_FIXED_LINK); | ||
| 110 | } else { | ||
| 111 | /* GE1, Force 1000M/FD, FC ON, MAX_RX_LENGTH 1536 */ | ||
| 112 | mtk_switch_w32(gsw, MAC_MCR_FIXED_LINK_FC, MTK_MAC_P1_MCR); | ||
| 113 | mt7530_mdio_w32(gsw, MT7530_PMCR_P(6), PMCR_FIXED_LINK_FC); | ||
| 114 | } | ||
| 115 | |||
| 116 | /* GE2, Link down */ | ||
| 117 | mtk_switch_w32(gsw, MAC_MCR_FORCE_MODE, MTK_MAC_P2_MCR); | ||
| 118 | |||
| 119 | /* Enable Port 6, P5 as GMAC5, P5 disable */ | ||
| 120 | val = mt7530_mdio_r32(gsw, MT7530_MHWTRAP); | ||
| 121 | /* Enable Port 6 */ | ||
| 122 | val &= ~MHWTRAP_P6_DIS; | ||
| 123 | /* Disable Port 5 */ | ||
| 124 | val |= MHWTRAP_P5_DIS; | ||
| 125 | /* manual override of HW-Trap */ | ||
| 126 | val |= MHWTRAP_MANUAL; | ||
| 127 | mt7530_mdio_w32(gsw, MT7530_MHWTRAP, val); | ||
| 128 | |||
| 129 | val = rt_sysc_r32(SYSC_REG_CFG); | ||
| 130 | val = (val >> MT7621_XTAL_SHIFT) & MT7621_XTAL_MASK; | ||
| 131 | if (val < MT7621_XTAL_25 && val >= MT7621_XTAL_40) { | ||
| 132 | /* 40Mhz */ | ||
| 133 | |||
| 134 | /* disable MT7530 core clock */ | ||
| 135 | _mt7620_mii_write(gsw, 0, 13, 0x1f); | ||
| 136 | _mt7620_mii_write(gsw, 0, 14, 0x410); | ||
| 137 | _mt7620_mii_write(gsw, 0, 13, 0x401f); | ||
| 138 | _mt7620_mii_write(gsw, 0, 14, 0x0); | ||
| 139 | |||
| 140 | /* disable MT7530 PLL */ | ||
| 141 | _mt7620_mii_write(gsw, 0, 13, 0x1f); | ||
| 142 | _mt7620_mii_write(gsw, 0, 14, 0x40d); | ||
| 143 | _mt7620_mii_write(gsw, 0, 13, 0x401f); | ||
| 144 | _mt7620_mii_write(gsw, 0, 14, 0x2020); | ||
| 145 | |||
| 146 | /* for MT7530 core clock = 500Mhz */ | ||
| 147 | _mt7620_mii_write(gsw, 0, 13, 0x1f); | ||
| 148 | _mt7620_mii_write(gsw, 0, 14, 0x40e); | ||
| 149 | _mt7620_mii_write(gsw, 0, 13, 0x401f); | ||
| 150 | _mt7620_mii_write(gsw, 0, 14, 0x119); | ||
| 151 | |||
| 152 | /* enable MT7530 PLL */ | ||
| 153 | _mt7620_mii_write(gsw, 0, 13, 0x1f); | ||
| 154 | _mt7620_mii_write(gsw, 0, 14, 0x40d); | ||
| 155 | _mt7620_mii_write(gsw, 0, 13, 0x401f); | ||
| 156 | _mt7620_mii_write(gsw, 0, 14, 0x2820); | ||
| 157 | |||
| 158 | usleep_range(20, 40); | ||
| 159 | |||
| 160 | /* enable MT7530 core clock */ | ||
| 161 | _mt7620_mii_write(gsw, 0, 13, 0x1f); | ||
| 162 | _mt7620_mii_write(gsw, 0, 14, 0x410); | ||
| 163 | _mt7620_mii_write(gsw, 0, 13, 0x401f); | ||
| 164 | } | ||
| 165 | |||
| 166 | /* RGMII */ | ||
| 167 | _mt7620_mii_write(gsw, 0, 14, 0x1); | ||
| 168 | |||
| 169 | /* set MT7530 central align */ | ||
| 170 | mt7530_mdio_m32(gsw, BIT(0), P6ECR_INTF_MODE_RGMII, MT7530_P6ECR); | ||
| 171 | mt7530_mdio_m32(gsw, TRGMII_TXCTRL_TXC_INV, 0, | ||
| 172 | MT7530_TRGMII_TXCTRL); | ||
| 173 | mt7530_mdio_w32(gsw, MT7530_TRGMII_TCK_CTRL, 0x855); | ||
| 174 | |||
| 175 | /* delay setting for 10/1000M */ | ||
| 176 | mt7530_mdio_w32(gsw, MT7530_P5RGMIIRXCR, | ||
| 177 | P5RGMIIRXCR_C_ALIGN | P5RGMIIRXCR_DELAY_2); | ||
| 178 | mt7530_mdio_w32(gsw, MT7530_P5RGMIITXCR, 0x14); | ||
| 179 | |||
| 180 | /* lower Tx Driving*/ | ||
| 181 | mt7530_mdio_w32(gsw, MT7530_TRGMII_TD0_ODT, 0x44); | ||
| 182 | mt7530_mdio_w32(gsw, MT7530_TRGMII_TD1_ODT, 0x44); | ||
| 183 | mt7530_mdio_w32(gsw, MT7530_TRGMII_TD2_ODT, 0x44); | ||
| 184 | mt7530_mdio_w32(gsw, MT7530_TRGMII_TD3_ODT, 0x44); | ||
| 185 | mt7530_mdio_w32(gsw, MT7530_TRGMII_TD4_ODT, 0x44); | ||
| 186 | mt7530_mdio_w32(gsw, MT7530_TRGMII_TD5_ODT, 0x44); | ||
| 187 | |||
| 188 | /* turn on all PHYs */ | ||
| 189 | for (i = 0; i <= 4; i++) { | ||
| 190 | val = _mt7620_mii_read(gsw, i, 0); | ||
| 191 | val &= ~BIT(11); | ||
| 192 | _mt7620_mii_write(gsw, i, 0, val); | ||
| 193 | } | ||
| 194 | |||
| 195 | #define MT7530_NUM_PORTS 8 | ||
| 196 | #define REG_ESW_PORT_PCR(x) (0x2004 | ((x) << 8)) | ||
| 197 | #define REG_ESW_PORT_PVC(x) (0x2010 | ((x) << 8)) | ||
| 198 | #define REG_ESW_PORT_PPBV1(x) (0x2014 | ((x) << 8)) | ||
| 199 | #define MT7530_CPU_PORT 6 | ||
| 200 | |||
| 201 | /* This is copied from mt7530_apply_config in libreCMC driver */ | ||
| 202 | { | ||
| 203 | int i; | ||
| 204 | |||
| 205 | for (i = 0; i < MT7530_NUM_PORTS; i++) | ||
| 206 | mt7530_mdio_w32(gsw, REG_ESW_PORT_PCR(i), 0x00400000); | ||
| 207 | |||
| 208 | mt7530_mdio_w32(gsw, REG_ESW_PORT_PCR(MT7530_CPU_PORT), | ||
| 209 | 0x00ff0000); | ||
| 210 | |||
| 211 | for (i = 0; i < MT7530_NUM_PORTS; i++) | ||
| 212 | mt7530_mdio_w32(gsw, REG_ESW_PORT_PVC(i), 0x810000c0); | ||
| 213 | } | ||
| 214 | |||
| 215 | /* enable irq */ | ||
| 216 | mt7530_mdio_m32(gsw, 0, 3 << 16, MT7530_TOP_SIG_CTRL); | ||
| 217 | mt7530_mdio_w32(gsw, MT7530_SYS_INT_EN, 0x1f); | ||
| 218 | } | ||
| 219 | |||
| 220 | static const struct of_device_id mediatek_gsw_match[] = { | ||
| 221 | { .compatible = "mediatek,mt7621-gsw" }, | ||
| 222 | {}, | ||
| 223 | }; | ||
| 224 | MODULE_DEVICE_TABLE(of, mediatek_gsw_match); | ||
| 225 | |||
| 226 | int mtk_gsw_init(struct mtk_eth *eth) | ||
| 227 | { | ||
| 228 | struct device_node *np = eth->switch_np; | ||
| 229 | struct platform_device *pdev = of_find_device_by_node(np); | ||
| 230 | struct mt7620_gsw *gsw; | ||
| 231 | |||
| 232 | if (!pdev) | ||
| 233 | return -ENODEV; | ||
| 234 | |||
| 235 | if (!of_device_is_compatible(np, mediatek_gsw_match->compatible)) | ||
| 236 | return -EINVAL; | ||
| 237 | |||
| 238 | gsw = platform_get_drvdata(pdev); | ||
| 239 | eth->sw_priv = gsw; | ||
| 240 | |||
| 241 | if (!gsw->irq) | ||
| 242 | return -EINVAL; | ||
| 243 | |||
| 244 | request_irq(gsw->irq, gsw_interrupt_mt7621, 0, | ||
| 245 | "gsw", eth); | ||
| 246 | disable_irq(gsw->irq); | ||
| 247 | |||
| 248 | mt7621_hw_init(eth, gsw, np); | ||
| 249 | |||
| 250 | enable_irq(gsw->irq); | ||
| 251 | |||
| 252 | return 0; | ||
| 253 | } | ||
| 254 | EXPORT_SYMBOL_GPL(mtk_gsw_init); | ||
| 255 | |||
| 256 | static int mt7621_gsw_probe(struct platform_device *pdev) | ||
| 257 | { | ||
| 258 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 259 | struct mt7620_gsw *gsw; | ||
| 260 | |||
| 261 | gsw = devm_kzalloc(&pdev->dev, sizeof(struct mt7620_gsw), GFP_KERNEL); | ||
| 262 | if (!gsw) | ||
| 263 | return -ENOMEM; | ||
| 264 | |||
| 265 | gsw->base = devm_ioremap_resource(&pdev->dev, res); | ||
| 266 | if (IS_ERR(gsw->base)) | ||
| 267 | return PTR_ERR(gsw->base); | ||
| 268 | |||
| 269 | gsw->dev = &pdev->dev; | ||
| 270 | gsw->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | ||
| 271 | |||
| 272 | platform_set_drvdata(pdev, gsw); | ||
| 273 | |||
| 274 | return 0; | ||
| 275 | } | ||
| 276 | |||
| 277 | static int mt7621_gsw_remove(struct platform_device *pdev) | ||
| 278 | { | ||
| 279 | platform_set_drvdata(pdev, NULL); | ||
| 280 | |||
| 281 | return 0; | ||
| 282 | } | ||
| 283 | |||
| 284 | static struct platform_driver gsw_driver = { | ||
| 285 | .probe = mt7621_gsw_probe, | ||
| 286 | .remove = mt7621_gsw_remove, | ||
| 287 | .driver = { | ||
| 288 | .name = "mt7621-gsw", | ||
| 289 | .of_match_table = mediatek_gsw_match, | ||
| 290 | }, | ||
| 291 | }; | ||
| 292 | |||
| 293 | module_platform_driver(gsw_driver); | ||
| 294 | |||
| 295 | MODULE_LICENSE("GPL"); | ||
| 296 | MODULE_AUTHOR("John Crispin <blogic@openwrt.org>"); | ||
| 297 | MODULE_DESCRIPTION("GBit switch driver for Mediatek MT7621 SoC"); | ||
diff --git a/drivers/staging/mt7621-eth/mdio.c b/drivers/staging/mt7621-eth/mdio.c deleted file mode 100644 index 5fea6a447eed..000000000000 --- a/drivers/staging/mt7621-eth/mdio.c +++ /dev/null | |||
| @@ -1,275 +0,0 @@ | |||
| 1 | /* This program is free software; you can redistribute it and/or modify | ||
| 2 | * it under the terms of the GNU General Public License as published by | ||
| 3 | * the Free Software Foundation; version 2 of the License | ||
| 4 | * | ||
| 5 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 6 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 7 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include <linux/module.h> | ||
| 11 | #include <linux/kernel.h> | ||
| 12 | #include <linux/phy.h> | ||
| 13 | #include <linux/of_net.h> | ||
| 14 | #include <linux/of_mdio.h> | ||
| 15 | |||
| 16 | #include "mtk_eth_soc.h" | ||
| 17 | #include "mdio.h" | ||
| 18 | |||
| 19 | static int mtk_mdio_reset(struct mii_bus *bus) | ||
| 20 | { | ||
| 21 | /* TODO */ | ||
| 22 | return 0; | ||
| 23 | } | ||
| 24 | |||
| 25 | static void mtk_phy_link_adjust(struct net_device *dev) | ||
| 26 | { | ||
| 27 | struct mtk_eth *eth = netdev_priv(dev); | ||
| 28 | unsigned long flags; | ||
| 29 | int i; | ||
| 30 | |||
| 31 | spin_lock_irqsave(ð->phy->lock, flags); | ||
| 32 | for (i = 0; i < 8; i++) { | ||
| 33 | if (eth->phy->phy_node[i]) { | ||
| 34 | struct phy_device *phydev = eth->phy->phy[i]; | ||
| 35 | int status_change = 0; | ||
| 36 | |||
| 37 | if (phydev->link) | ||
| 38 | if (eth->phy->duplex[i] != phydev->duplex || | ||
| 39 | eth->phy->speed[i] != phydev->speed) | ||
| 40 | status_change = 1; | ||
| 41 | |||
| 42 | if (phydev->link != eth->link[i]) | ||
| 43 | status_change = 1; | ||
| 44 | |||
| 45 | switch (phydev->speed) { | ||
| 46 | case SPEED_1000: | ||
| 47 | case SPEED_100: | ||
| 48 | case SPEED_10: | ||
| 49 | eth->link[i] = phydev->link; | ||
| 50 | eth->phy->duplex[i] = phydev->duplex; | ||
| 51 | eth->phy->speed[i] = phydev->speed; | ||
| 52 | |||
| 53 | if (status_change && | ||
| 54 | eth->soc->mdio_adjust_link) | ||
| 55 | eth->soc->mdio_adjust_link(eth, i); | ||
| 56 | break; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | } | ||
| 60 | spin_unlock_irqrestore(ð->phy->lock, flags); | ||
| 61 | } | ||
| 62 | |||
| 63 | int mtk_connect_phy_node(struct mtk_eth *eth, struct mtk_mac *mac, | ||
| 64 | struct device_node *phy_node) | ||
| 65 | { | ||
| 66 | const __be32 *_port = NULL; | ||
| 67 | struct phy_device *phydev; | ||
| 68 | int phy_mode, port; | ||
| 69 | |||
| 70 | _port = of_get_property(phy_node, "reg", NULL); | ||
| 71 | |||
| 72 | if (!_port || (be32_to_cpu(*_port) >= 0x20)) { | ||
| 73 | pr_err("%pOFn: invalid port id\n", phy_node); | ||
| 74 | return -EINVAL; | ||
| 75 | } | ||
| 76 | port = be32_to_cpu(*_port); | ||
| 77 | phy_mode = of_get_phy_mode(phy_node); | ||
| 78 | if (phy_mode < 0) { | ||
| 79 | dev_err(eth->dev, "incorrect phy-mode %d\n", phy_mode); | ||
| 80 | eth->phy->phy_node[port] = NULL; | ||
| 81 | return -EINVAL; | ||
| 82 | } | ||
| 83 | |||
| 84 | phydev = of_phy_connect(eth->netdev[mac->id], phy_node, | ||
| 85 | mtk_phy_link_adjust, 0, phy_mode); | ||
| 86 | if (!phydev) { | ||
| 87 | dev_err(eth->dev, "could not connect to PHY\n"); | ||
| 88 | eth->phy->phy_node[port] = NULL; | ||
| 89 | return -ENODEV; | ||
| 90 | } | ||
| 91 | |||
| 92 | phydev->supported &= PHY_1000BT_FEATURES; | ||
| 93 | phydev->advertising = phydev->supported; | ||
| 94 | |||
| 95 | dev_info(eth->dev, | ||
| 96 | "connected port %d to PHY at %s [uid=%08x, driver=%s]\n", | ||
| 97 | port, phydev_name(phydev), phydev->phy_id, | ||
| 98 | phydev->drv->name); | ||
| 99 | |||
| 100 | eth->phy->phy[port] = phydev; | ||
| 101 | eth->link[port] = 0; | ||
| 102 | |||
| 103 | return 0; | ||
| 104 | } | ||
| 105 | |||
| 106 | static void phy_init(struct mtk_eth *eth, struct mtk_mac *mac, | ||
| 107 | struct phy_device *phy) | ||
| 108 | { | ||
| 109 | phy_attach(eth->netdev[mac->id], phydev_name(phy), | ||
| 110 | PHY_INTERFACE_MODE_MII); | ||
| 111 | |||
| 112 | phy->autoneg = AUTONEG_ENABLE; | ||
| 113 | phy->speed = 0; | ||
| 114 | phy->duplex = 0; | ||
| 115 | phy_set_max_speed(phy, SPEED_100); | ||
| 116 | phy->advertising = phy->supported | ADVERTISED_Autoneg; | ||
| 117 | |||
| 118 | phy_start_aneg(phy); | ||
| 119 | } | ||
| 120 | |||
| 121 | static int mtk_phy_connect(struct mtk_mac *mac) | ||
| 122 | { | ||
| 123 | struct mtk_eth *eth = mac->hw; | ||
| 124 | int i; | ||
| 125 | |||
| 126 | for (i = 0; i < 8; i++) { | ||
| 127 | if (eth->phy->phy_node[i]) { | ||
| 128 | if (!mac->phy_dev) { | ||
| 129 | mac->phy_dev = eth->phy->phy[i]; | ||
| 130 | mac->phy_flags = MTK_PHY_FLAG_PORT; | ||
| 131 | } | ||
| 132 | } else if (eth->mii_bus) { | ||
| 133 | struct phy_device *phy; | ||
| 134 | |||
| 135 | phy = mdiobus_get_phy(eth->mii_bus, i); | ||
| 136 | if (phy) { | ||
| 137 | phy_init(eth, mac, phy); | ||
| 138 | if (!mac->phy_dev) { | ||
| 139 | mac->phy_dev = phy; | ||
| 140 | mac->phy_flags = MTK_PHY_FLAG_ATTACH; | ||
| 141 | } | ||
| 142 | } | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | return 0; | ||
| 147 | } | ||
| 148 | |||
| 149 | static void mtk_phy_disconnect(struct mtk_mac *mac) | ||
| 150 | { | ||
| 151 | struct mtk_eth *eth = mac->hw; | ||
| 152 | unsigned long flags; | ||
| 153 | int i; | ||
| 154 | |||
| 155 | for (i = 0; i < 8; i++) | ||
| 156 | if (eth->phy->phy_fixed[i]) { | ||
| 157 | spin_lock_irqsave(ð->phy->lock, flags); | ||
| 158 | eth->link[i] = 0; | ||
| 159 | if (eth->soc->mdio_adjust_link) | ||
| 160 | eth->soc->mdio_adjust_link(eth, i); | ||
| 161 | spin_unlock_irqrestore(ð->phy->lock, flags); | ||
| 162 | } else if (eth->phy->phy[i]) { | ||
| 163 | phy_disconnect(eth->phy->phy[i]); | ||
| 164 | } else if (eth->mii_bus) { | ||
| 165 | struct phy_device *phy = | ||
| 166 | mdiobus_get_phy(eth->mii_bus, i); | ||
| 167 | |||
| 168 | if (phy) | ||
| 169 | phy_detach(phy); | ||
| 170 | } | ||
| 171 | } | ||
| 172 | |||
| 173 | static void mtk_phy_start(struct mtk_mac *mac) | ||
| 174 | { | ||
| 175 | struct mtk_eth *eth = mac->hw; | ||
| 176 | unsigned long flags; | ||
| 177 | int i; | ||
| 178 | |||
| 179 | for (i = 0; i < 8; i++) { | ||
| 180 | if (eth->phy->phy_fixed[i]) { | ||
| 181 | spin_lock_irqsave(ð->phy->lock, flags); | ||
| 182 | eth->link[i] = 1; | ||
| 183 | if (eth->soc->mdio_adjust_link) | ||
| 184 | eth->soc->mdio_adjust_link(eth, i); | ||
| 185 | spin_unlock_irqrestore(ð->phy->lock, flags); | ||
| 186 | } else if (eth->phy->phy[i]) { | ||
| 187 | phy_start(eth->phy->phy[i]); | ||
| 188 | } | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | static void mtk_phy_stop(struct mtk_mac *mac) | ||
| 193 | { | ||
| 194 | struct mtk_eth *eth = mac->hw; | ||
| 195 | unsigned long flags; | ||
| 196 | int i; | ||
| 197 | |||
| 198 | for (i = 0; i < 8; i++) | ||
| 199 | if (eth->phy->phy_fixed[i]) { | ||
| 200 | spin_lock_irqsave(ð->phy->lock, flags); | ||
| 201 | eth->link[i] = 0; | ||
| 202 | if (eth->soc->mdio_adjust_link) | ||
| 203 | eth->soc->mdio_adjust_link(eth, i); | ||
| 204 | spin_unlock_irqrestore(ð->phy->lock, flags); | ||
| 205 | } else if (eth->phy->phy[i]) { | ||
| 206 | phy_stop(eth->phy->phy[i]); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | static struct mtk_phy phy_ralink = { | ||
| 211 | .connect = mtk_phy_connect, | ||
| 212 | .disconnect = mtk_phy_disconnect, | ||
| 213 | .start = mtk_phy_start, | ||
| 214 | .stop = mtk_phy_stop, | ||
| 215 | }; | ||
| 216 | |||
| 217 | int mtk_mdio_init(struct mtk_eth *eth) | ||
| 218 | { | ||
| 219 | struct device_node *mii_np; | ||
| 220 | int err; | ||
| 221 | |||
| 222 | if (!eth->soc->mdio_read || !eth->soc->mdio_write) | ||
| 223 | return 0; | ||
| 224 | |||
| 225 | spin_lock_init(&phy_ralink.lock); | ||
| 226 | eth->phy = &phy_ralink; | ||
| 227 | |||
| 228 | mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus"); | ||
| 229 | if (!mii_np) { | ||
| 230 | dev_err(eth->dev, "no %s child node found", "mdio-bus"); | ||
| 231 | return -ENODEV; | ||
| 232 | } | ||
| 233 | |||
| 234 | if (!of_device_is_available(mii_np)) { | ||
| 235 | err = 0; | ||
| 236 | goto err_put_node; | ||
| 237 | } | ||
| 238 | |||
| 239 | eth->mii_bus = mdiobus_alloc(); | ||
| 240 | if (!eth->mii_bus) { | ||
| 241 | err = -ENOMEM; | ||
| 242 | goto err_put_node; | ||
| 243 | } | ||
| 244 | |||
| 245 | eth->mii_bus->name = "mdio"; | ||
| 246 | eth->mii_bus->read = eth->soc->mdio_read; | ||
| 247 | eth->mii_bus->write = eth->soc->mdio_write; | ||
| 248 | eth->mii_bus->reset = mtk_mdio_reset; | ||
| 249 | eth->mii_bus->priv = eth; | ||
| 250 | eth->mii_bus->parent = eth->dev; | ||
| 251 | |||
| 252 | snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%pOFn", mii_np); | ||
| 253 | err = of_mdiobus_register(eth->mii_bus, mii_np); | ||
| 254 | if (err) | ||
| 255 | goto err_free_bus; | ||
| 256 | |||
| 257 | return 0; | ||
| 258 | |||
| 259 | err_free_bus: | ||
| 260 | kfree(eth->mii_bus); | ||
| 261 | err_put_node: | ||
| 262 | of_node_put(mii_np); | ||
| 263 | eth->mii_bus = NULL; | ||
| 264 | return err; | ||
| 265 | } | ||
| 266 | |||
| 267 | void mtk_mdio_cleanup(struct mtk_eth *eth) | ||
| 268 | { | ||
| 269 | if (!eth->mii_bus) | ||
| 270 | return; | ||
| 271 | |||
| 272 | mdiobus_unregister(eth->mii_bus); | ||
| 273 | of_node_put(eth->mii_bus->dev.of_node); | ||
| 274 | kfree(eth->mii_bus); | ||
| 275 | } | ||
diff --git a/drivers/staging/mt7621-eth/mdio.h b/drivers/staging/mt7621-eth/mdio.h deleted file mode 100644 index b14e23842a01..000000000000 --- a/drivers/staging/mt7621-eth/mdio.h +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 1 | /* This program is free software; you can redistribute it and/or modify | ||
| 2 | * it under the terms of the GNU General Public License as published by | ||
| 3 | * the Free Software Foundation; version 2 of the License | ||
| 4 | * | ||
| 5 | * This program is distributed in the hope that it will be useful, | ||
| 6 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 7 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 8 | * GNU General Public License for more details. | ||
| 9 | * | ||
| 10 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 11 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 12 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef _RALINK_MDIO_H__ | ||
| 16 | #define _RALINK_MDIO_H__ | ||
| 17 | |||
| 18 | #ifdef CONFIG_NET_MEDIATEK_MDIO | ||
| 19 | int mtk_mdio_init(struct mtk_eth *eth); | ||
| 20 | void mtk_mdio_cleanup(struct mtk_eth *eth); | ||
| 21 | int mtk_connect_phy_node(struct mtk_eth *eth, struct mtk_mac *mac, | ||
| 22 | struct device_node *phy_node); | ||
| 23 | #else | ||
| 24 | static inline int mtk_mdio_init(struct mtk_eth *eth) { return 0; } | ||
| 25 | static inline void mtk_mdio_cleanup(struct mtk_eth *eth) {} | ||
| 26 | #endif | ||
| 27 | #endif | ||
diff --git a/drivers/staging/mt7621-eth/mdio_mt7620.c b/drivers/staging/mt7621-eth/mdio_mt7620.c deleted file mode 100644 index ced605c2914e..000000000000 --- a/drivers/staging/mt7621-eth/mdio_mt7620.c +++ /dev/null | |||
| @@ -1,173 +0,0 @@ | |||
| 1 | /* This program is free software; you can redistribute it and/or modify | ||
| 2 | * it under the terms of the GNU General Public License as published by | ||
| 3 | * the Free Software Foundation; version 2 of the License | ||
| 4 | * | ||
| 5 | * This program is distributed in the hope that it will be useful, | ||
| 6 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 7 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 8 | * GNU General Public License for more details. | ||
| 9 | * | ||
| 10 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 11 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 12 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | #include <linux/types.h> | ||
| 18 | |||
| 19 | #include "mtk_eth_soc.h" | ||
| 20 | #include "gsw_mt7620.h" | ||
| 21 | #include "mdio.h" | ||
| 22 | |||
| 23 | static int mt7620_mii_busy_wait(struct mt7620_gsw *gsw) | ||
| 24 | { | ||
| 25 | unsigned long t_start = jiffies; | ||
| 26 | |||
| 27 | while (1) { | ||
| 28 | if (!(mtk_switch_r32(gsw, | ||
| 29 | gsw->piac_offset + MT7620_GSW_REG_PIAC) & | ||
| 30 | GSW_MDIO_ACCESS)) | ||
| 31 | return 0; | ||
| 32 | if (time_after(jiffies, t_start + GSW_REG_PHY_TIMEOUT)) | ||
| 33 | break; | ||
| 34 | } | ||
| 35 | |||
| 36 | dev_err(gsw->dev, "mdio: MDIO timeout\n"); | ||
| 37 | return -1; | ||
| 38 | } | ||
| 39 | |||
| 40 | u32 _mt7620_mii_write(struct mt7620_gsw *gsw, u32 phy_addr, | ||
| 41 | u32 phy_register, u32 write_data) | ||
| 42 | { | ||
| 43 | if (mt7620_mii_busy_wait(gsw)) | ||
| 44 | return -1; | ||
| 45 | |||
| 46 | write_data &= 0xffff; | ||
| 47 | |||
| 48 | mtk_switch_w32(gsw, GSW_MDIO_ACCESS | GSW_MDIO_START | GSW_MDIO_WRITE | | ||
| 49 | (phy_register << GSW_MDIO_REG_SHIFT) | | ||
| 50 | (phy_addr << GSW_MDIO_ADDR_SHIFT) | write_data, | ||
| 51 | MT7620_GSW_REG_PIAC); | ||
| 52 | |||
| 53 | if (mt7620_mii_busy_wait(gsw)) | ||
| 54 | return -1; | ||
| 55 | |||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | EXPORT_SYMBOL_GPL(_mt7620_mii_write); | ||
| 59 | |||
| 60 | u32 _mt7620_mii_read(struct mt7620_gsw *gsw, int phy_addr, int phy_reg) | ||
| 61 | { | ||
| 62 | u32 d; | ||
| 63 | |||
| 64 | if (mt7620_mii_busy_wait(gsw)) | ||
| 65 | return 0xffff; | ||
| 66 | |||
| 67 | mtk_switch_w32(gsw, GSW_MDIO_ACCESS | GSW_MDIO_START | GSW_MDIO_READ | | ||
| 68 | (phy_reg << GSW_MDIO_REG_SHIFT) | | ||
| 69 | (phy_addr << GSW_MDIO_ADDR_SHIFT), | ||
| 70 | MT7620_GSW_REG_PIAC); | ||
| 71 | |||
| 72 | if (mt7620_mii_busy_wait(gsw)) | ||
| 73 | return 0xffff; | ||
| 74 | |||
| 75 | d = mtk_switch_r32(gsw, MT7620_GSW_REG_PIAC) & 0xffff; | ||
| 76 | |||
| 77 | return d; | ||
| 78 | } | ||
| 79 | EXPORT_SYMBOL_GPL(_mt7620_mii_read); | ||
| 80 | |||
| 81 | int mt7620_mdio_write(struct mii_bus *bus, int phy_addr, int phy_reg, u16 val) | ||
| 82 | { | ||
| 83 | struct mtk_eth *eth = bus->priv; | ||
| 84 | struct mt7620_gsw *gsw = (struct mt7620_gsw *)eth->sw_priv; | ||
| 85 | |||
| 86 | return _mt7620_mii_write(gsw, phy_addr, phy_reg, val); | ||
| 87 | } | ||
| 88 | |||
| 89 | int mt7620_mdio_read(struct mii_bus *bus, int phy_addr, int phy_reg) | ||
| 90 | { | ||
| 91 | struct mtk_eth *eth = bus->priv; | ||
| 92 | struct mt7620_gsw *gsw = (struct mt7620_gsw *)eth->sw_priv; | ||
| 93 | |||
| 94 | return _mt7620_mii_read(gsw, phy_addr, phy_reg); | ||
| 95 | } | ||
| 96 | |||
| 97 | void mt7530_mdio_w32(struct mt7620_gsw *gsw, u32 reg, u32 val) | ||
| 98 | { | ||
| 99 | _mt7620_mii_write(gsw, 0x1f, 0x1f, (reg >> 6) & 0x3ff); | ||
| 100 | _mt7620_mii_write(gsw, 0x1f, (reg >> 2) & 0xf, val & 0xffff); | ||
| 101 | _mt7620_mii_write(gsw, 0x1f, 0x10, val >> 16); | ||
| 102 | } | ||
| 103 | EXPORT_SYMBOL_GPL(mt7530_mdio_w32); | ||
| 104 | |||
| 105 | u32 mt7530_mdio_r32(struct mt7620_gsw *gsw, u32 reg) | ||
| 106 | { | ||
| 107 | u16 high, low; | ||
| 108 | |||
| 109 | _mt7620_mii_write(gsw, 0x1f, 0x1f, (reg >> 6) & 0x3ff); | ||
| 110 | low = _mt7620_mii_read(gsw, 0x1f, (reg >> 2) & 0xf); | ||
| 111 | high = _mt7620_mii_read(gsw, 0x1f, 0x10); | ||
| 112 | |||
| 113 | return (high << 16) | (low & 0xffff); | ||
| 114 | } | ||
| 115 | EXPORT_SYMBOL_GPL(mt7530_mdio_r32); | ||
| 116 | |||
| 117 | void mt7530_mdio_m32(struct mt7620_gsw *gsw, u32 mask, u32 set, u32 reg) | ||
| 118 | { | ||
| 119 | u32 val = mt7530_mdio_r32(gsw, reg); | ||
| 120 | |||
| 121 | val &= ~mask; | ||
| 122 | val |= set; | ||
| 123 | mt7530_mdio_w32(gsw, reg, val); | ||
| 124 | } | ||
| 125 | EXPORT_SYMBOL_GPL(mt7530_mdio_m32); | ||
| 126 | |||
| 127 | static unsigned char *mtk_speed_str(int speed) | ||
| 128 | { | ||
| 129 | switch (speed) { | ||
| 130 | case 2: | ||
| 131 | case SPEED_1000: | ||
| 132 | return "1000"; | ||
| 133 | case 1: | ||
| 134 | case SPEED_100: | ||
| 135 | return "100"; | ||
| 136 | case 0: | ||
| 137 | case SPEED_10: | ||
| 138 | return "10"; | ||
| 139 | } | ||
| 140 | |||
| 141 | return "? "; | ||
| 142 | } | ||
| 143 | |||
| 144 | int mt7620_has_carrier(struct mtk_eth *eth) | ||
| 145 | { | ||
| 146 | struct mt7620_gsw *gsw = (struct mt7620_gsw *)eth->sw_priv; | ||
| 147 | int i; | ||
| 148 | |||
| 149 | for (i = 0; i < GSW_PORT6; i++) | ||
| 150 | if (mt7530_mdio_r32(gsw, GSW_REG_PORT_STATUS(i)) & 0x1) | ||
| 151 | return 1; | ||
| 152 | return 0; | ||
| 153 | } | ||
| 154 | |||
| 155 | void mt7620_print_link_state(struct mtk_eth *eth, int port, int link, | ||
| 156 | int speed, int duplex) | ||
| 157 | { | ||
| 158 | struct mt7620_gsw *gsw = eth->sw_priv; | ||
| 159 | |||
| 160 | if (link) | ||
| 161 | dev_info(gsw->dev, "port %d link up (%sMbps/%s duplex)\n", | ||
| 162 | port, mtk_speed_str(speed), | ||
| 163 | (duplex) ? "Full" : "Half"); | ||
| 164 | else | ||
| 165 | dev_info(gsw->dev, "port %d link down\n", port); | ||
| 166 | } | ||
| 167 | |||
| 168 | void mt7620_mdio_link_adjust(struct mtk_eth *eth, int port) | ||
| 169 | { | ||
| 170 | mt7620_print_link_state(eth, port, eth->link[port], | ||
| 171 | eth->phy->speed[port], | ||
| 172 | (eth->phy->duplex[port] == DUPLEX_FULL)); | ||
| 173 | } | ||
diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c deleted file mode 100644 index 6027b19f7bc2..000000000000 --- a/drivers/staging/mt7621-eth/mtk_eth_soc.c +++ /dev/null | |||
| @@ -1,2176 +0,0 @@ | |||
| 1 | /* This program is free software; you can redistribute it and/or modify | ||
| 2 | * it under the terms of the GNU General Public License as published by | ||
| 3 | * the Free Software Foundation; version 2 of the License | ||
| 4 | * | ||
| 5 | * This program is distributed in the hope that it will be useful, | ||
| 6 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 7 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 8 | * GNU General Public License for more details. | ||
| 9 | * | ||
| 10 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 11 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 12 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | #include <linux/types.h> | ||
| 18 | #include <linux/dma-mapping.h> | ||
| 19 | #include <linux/init.h> | ||
| 20 | #include <linux/skbuff.h> | ||
| 21 | #include <linux/etherdevice.h> | ||
| 22 | #include <linux/ethtool.h> | ||
| 23 | #include <linux/platform_device.h> | ||
| 24 | #include <linux/of_device.h> | ||
| 25 | #include <linux/mfd/syscon.h> | ||
| 26 | #include <linux/clk.h> | ||
| 27 | #include <linux/of_net.h> | ||
| 28 | #include <linux/of_mdio.h> | ||
| 29 | #include <linux/if_vlan.h> | ||
| 30 | #include <linux/reset.h> | ||
| 31 | #include <linux/tcp.h> | ||
| 32 | #include <linux/io.h> | ||
| 33 | #include <linux/bug.h> | ||
| 34 | #include <linux/regmap.h> | ||
| 35 | |||
| 36 | #include "mtk_eth_soc.h" | ||
| 37 | #include "mdio.h" | ||
| 38 | #include "ethtool.h" | ||
| 39 | |||
| 40 | #define MAX_RX_LENGTH 1536 | ||
| 41 | #define MTK_RX_ETH_HLEN (VLAN_ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN) | ||
| 42 | #define MTK_RX_HLEN (NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN) | ||
| 43 | #define DMA_DUMMY_DESC 0xffffffff | ||
| 44 | #define MTK_DEFAULT_MSG_ENABLE \ | ||
| 45 | (NETIF_MSG_DRV | \ | ||
| 46 | NETIF_MSG_PROBE | \ | ||
| 47 | NETIF_MSG_LINK | \ | ||
| 48 | NETIF_MSG_TIMER | \ | ||
| 49 | NETIF_MSG_IFDOWN | \ | ||
| 50 | NETIF_MSG_IFUP | \ | ||
| 51 | NETIF_MSG_RX_ERR | \ | ||
| 52 | NETIF_MSG_TX_ERR) | ||
| 53 | |||
| 54 | #define TX_DMA_DESP2_DEF (TX_DMA_LS0 | TX_DMA_DONE) | ||
| 55 | #define NEXT_TX_DESP_IDX(X) (((X) + 1) & (ring->tx_ring_size - 1)) | ||
| 56 | #define NEXT_RX_DESP_IDX(X) (((X) + 1) & (ring->rx_ring_size - 1)) | ||
| 57 | |||
| 58 | #define SYSC_REG_RSTCTRL 0x34 | ||
| 59 | |||
| 60 | static int mtk_msg_level = -1; | ||
| 61 | module_param_named(msg_level, mtk_msg_level, int, 0); | ||
| 62 | MODULE_PARM_DESC(msg_level, "Message level (-1=defaults,0=none,...,16=all)"); | ||
| 63 | |||
| 64 | static const u16 mtk_reg_table_default[MTK_REG_COUNT] = { | ||
| 65 | [MTK_REG_PDMA_GLO_CFG] = MTK_PDMA_GLO_CFG, | ||
| 66 | [MTK_REG_PDMA_RST_CFG] = MTK_PDMA_RST_CFG, | ||
| 67 | [MTK_REG_DLY_INT_CFG] = MTK_DLY_INT_CFG, | ||
| 68 | [MTK_REG_TX_BASE_PTR0] = MTK_TX_BASE_PTR0, | ||
| 69 | [MTK_REG_TX_MAX_CNT0] = MTK_TX_MAX_CNT0, | ||
| 70 | [MTK_REG_TX_CTX_IDX0] = MTK_TX_CTX_IDX0, | ||
| 71 | [MTK_REG_TX_DTX_IDX0] = MTK_TX_DTX_IDX0, | ||
| 72 | [MTK_REG_RX_BASE_PTR0] = MTK_RX_BASE_PTR0, | ||
| 73 | [MTK_REG_RX_MAX_CNT0] = MTK_RX_MAX_CNT0, | ||
| 74 | [MTK_REG_RX_CALC_IDX0] = MTK_RX_CALC_IDX0, | ||
| 75 | [MTK_REG_RX_DRX_IDX0] = MTK_RX_DRX_IDX0, | ||
| 76 | [MTK_REG_MTK_INT_ENABLE] = MTK_INT_ENABLE, | ||
| 77 | [MTK_REG_MTK_INT_STATUS] = MTK_INT_STATUS, | ||
| 78 | [MTK_REG_MTK_DMA_VID_BASE] = MTK_DMA_VID0, | ||
| 79 | [MTK_REG_MTK_COUNTER_BASE] = MTK_GDMA1_TX_GBCNT, | ||
| 80 | [MTK_REG_MTK_RST_GL] = MTK_RST_GL, | ||
| 81 | }; | ||
| 82 | |||
| 83 | static const u16 *mtk_reg_table = mtk_reg_table_default; | ||
| 84 | |||
| 85 | void mtk_w32(struct mtk_eth *eth, u32 val, unsigned int reg) | ||
| 86 | { | ||
| 87 | __raw_writel(val, eth->base + reg); | ||
| 88 | } | ||
| 89 | |||
| 90 | u32 mtk_r32(struct mtk_eth *eth, unsigned int reg) | ||
| 91 | { | ||
| 92 | return __raw_readl(eth->base + reg); | ||
| 93 | } | ||
| 94 | |||
| 95 | static void mtk_reg_w32(struct mtk_eth *eth, u32 val, enum mtk_reg reg) | ||
| 96 | { | ||
| 97 | mtk_w32(eth, val, mtk_reg_table[reg]); | ||
| 98 | } | ||
| 99 | |||
| 100 | static u32 mtk_reg_r32(struct mtk_eth *eth, enum mtk_reg reg) | ||
| 101 | { | ||
| 102 | return mtk_r32(eth, mtk_reg_table[reg]); | ||
| 103 | } | ||
| 104 | |||
| 105 | /* these bits are also exposed via the reset-controller API. however the switch | ||
| 106 | * and FE need to be brought out of reset in the exakt same moemtn and the | ||
| 107 | * reset-controller api does not provide this feature yet. Do the reset manually | ||
| 108 | * until we fixed the reset-controller api to be able to do this | ||
| 109 | */ | ||
| 110 | void mtk_reset(struct mtk_eth *eth, u32 reset_bits) | ||
| 111 | { | ||
| 112 | u32 val; | ||
| 113 | |||
| 114 | regmap_read(eth->ethsys, SYSC_REG_RSTCTRL, &val); | ||
| 115 | val |= reset_bits; | ||
| 116 | regmap_write(eth->ethsys, SYSC_REG_RSTCTRL, val); | ||
| 117 | usleep_range(10, 20); | ||
| 118 | val &= ~reset_bits; | ||
| 119 | regmap_write(eth->ethsys, SYSC_REG_RSTCTRL, val); | ||
| 120 | usleep_range(10, 20); | ||
| 121 | } | ||
| 122 | EXPORT_SYMBOL(mtk_reset); | ||
| 123 | |||
| 124 | static inline void mtk_irq_ack(struct mtk_eth *eth, u32 mask) | ||
| 125 | { | ||
| 126 | if (eth->soc->dma_type & MTK_PDMA) | ||
| 127 | mtk_reg_w32(eth, mask, MTK_REG_MTK_INT_STATUS); | ||
| 128 | if (eth->soc->dma_type & MTK_QDMA) | ||
| 129 | mtk_w32(eth, mask, MTK_QMTK_INT_STATUS); | ||
| 130 | } | ||
| 131 | |||
| 132 | static inline u32 mtk_irq_pending(struct mtk_eth *eth) | ||
| 133 | { | ||
| 134 | u32 status = 0; | ||
| 135 | |||
| 136 | if (eth->soc->dma_type & MTK_PDMA) | ||
| 137 | status |= mtk_reg_r32(eth, MTK_REG_MTK_INT_STATUS); | ||
| 138 | if (eth->soc->dma_type & MTK_QDMA) | ||
| 139 | status |= mtk_r32(eth, MTK_QMTK_INT_STATUS); | ||
| 140 | |||
| 141 | return status; | ||
| 142 | } | ||
| 143 | |||
| 144 | static void mtk_irq_ack_status(struct mtk_eth *eth, u32 mask) | ||
| 145 | { | ||
| 146 | u32 status_reg = MTK_REG_MTK_INT_STATUS; | ||
| 147 | |||
| 148 | if (mtk_reg_table[MTK_REG_MTK_INT_STATUS2]) | ||
| 149 | status_reg = MTK_REG_MTK_INT_STATUS2; | ||
| 150 | |||
| 151 | mtk_reg_w32(eth, mask, status_reg); | ||
| 152 | } | ||
| 153 | |||
| 154 | static u32 mtk_irq_pending_status(struct mtk_eth *eth) | ||
| 155 | { | ||
| 156 | u32 status_reg = MTK_REG_MTK_INT_STATUS; | ||
| 157 | |||
| 158 | if (mtk_reg_table[MTK_REG_MTK_INT_STATUS2]) | ||
| 159 | status_reg = MTK_REG_MTK_INT_STATUS2; | ||
| 160 | |||
| 161 | return mtk_reg_r32(eth, status_reg); | ||
| 162 | } | ||
| 163 | |||
| 164 | static inline void mtk_irq_disable(struct mtk_eth *eth, u32 mask) | ||
| 165 | { | ||
| 166 | u32 val; | ||
| 167 | |||
| 168 | if (eth->soc->dma_type & MTK_PDMA) { | ||
| 169 | val = mtk_reg_r32(eth, MTK_REG_MTK_INT_ENABLE); | ||
| 170 | mtk_reg_w32(eth, val & ~mask, MTK_REG_MTK_INT_ENABLE); | ||
| 171 | /* flush write */ | ||
| 172 | mtk_reg_r32(eth, MTK_REG_MTK_INT_ENABLE); | ||
| 173 | } | ||
| 174 | if (eth->soc->dma_type & MTK_QDMA) { | ||
| 175 | val = mtk_r32(eth, MTK_QMTK_INT_ENABLE); | ||
| 176 | mtk_w32(eth, val & ~mask, MTK_QMTK_INT_ENABLE); | ||
| 177 | /* flush write */ | ||
| 178 | mtk_r32(eth, MTK_QMTK_INT_ENABLE); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | |||
| 182 | static inline void mtk_irq_enable(struct mtk_eth *eth, u32 mask) | ||
| 183 | { | ||
| 184 | u32 val; | ||
| 185 | |||
| 186 | if (eth->soc->dma_type & MTK_PDMA) { | ||
| 187 | val = mtk_reg_r32(eth, MTK_REG_MTK_INT_ENABLE); | ||
| 188 | mtk_reg_w32(eth, val | mask, MTK_REG_MTK_INT_ENABLE); | ||
| 189 | /* flush write */ | ||
| 190 | mtk_reg_r32(eth, MTK_REG_MTK_INT_ENABLE); | ||
| 191 | } | ||
| 192 | if (eth->soc->dma_type & MTK_QDMA) { | ||
| 193 | val = mtk_r32(eth, MTK_QMTK_INT_ENABLE); | ||
| 194 | mtk_w32(eth, val | mask, MTK_QMTK_INT_ENABLE); | ||
| 195 | /* flush write */ | ||
| 196 | mtk_r32(eth, MTK_QMTK_INT_ENABLE); | ||
| 197 | } | ||
| 198 | } | ||
| 199 | |||
| 200 | static inline u32 mtk_irq_enabled(struct mtk_eth *eth) | ||
| 201 | { | ||
| 202 | u32 enabled = 0; | ||
| 203 | |||
| 204 | if (eth->soc->dma_type & MTK_PDMA) | ||
| 205 | enabled |= mtk_reg_r32(eth, MTK_REG_MTK_INT_ENABLE); | ||
| 206 | if (eth->soc->dma_type & MTK_QDMA) | ||
| 207 | enabled |= mtk_r32(eth, MTK_QMTK_INT_ENABLE); | ||
| 208 | |||
| 209 | return enabled; | ||
| 210 | } | ||
| 211 | |||
| 212 | static inline void mtk_hw_set_macaddr(struct mtk_mac *mac, | ||
| 213 | unsigned char *macaddr) | ||
| 214 | { | ||
| 215 | unsigned long flags; | ||
| 216 | |||
| 217 | spin_lock_irqsave(&mac->hw->page_lock, flags); | ||
| 218 | mtk_w32(mac->hw, (macaddr[0] << 8) | macaddr[1], MTK_GDMA1_MAC_ADRH); | ||
| 219 | mtk_w32(mac->hw, (macaddr[2] << 24) | (macaddr[3] << 16) | | ||
| 220 | (macaddr[4] << 8) | macaddr[5], | ||
| 221 | MTK_GDMA1_MAC_ADRL); | ||
| 222 | spin_unlock_irqrestore(&mac->hw->page_lock, flags); | ||
| 223 | } | ||
| 224 | |||
| 225 | static int mtk_set_mac_address(struct net_device *dev, void *p) | ||
| 226 | { | ||
| 227 | int ret = eth_mac_addr(dev, p); | ||
| 228 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 229 | struct mtk_eth *eth = mac->hw; | ||
| 230 | |||
| 231 | if (ret) | ||
| 232 | return ret; | ||
| 233 | |||
| 234 | if (eth->soc->set_mac) | ||
| 235 | eth->soc->set_mac(mac, dev->dev_addr); | ||
| 236 | else | ||
| 237 | mtk_hw_set_macaddr(mac, p); | ||
| 238 | |||
| 239 | return 0; | ||
| 240 | } | ||
| 241 | |||
| 242 | static inline int mtk_max_frag_size(int mtu) | ||
| 243 | { | ||
| 244 | /* make sure buf_size will be at least MAX_RX_LENGTH */ | ||
| 245 | if (mtu + MTK_RX_ETH_HLEN < MAX_RX_LENGTH) | ||
| 246 | mtu = MAX_RX_LENGTH - MTK_RX_ETH_HLEN; | ||
| 247 | |||
| 248 | return SKB_DATA_ALIGN(MTK_RX_HLEN + mtu) + | ||
| 249 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); | ||
| 250 | } | ||
| 251 | |||
| 252 | static inline int mtk_max_buf_size(int frag_size) | ||
| 253 | { | ||
| 254 | int buf_size = frag_size - NET_SKB_PAD - NET_IP_ALIGN - | ||
| 255 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); | ||
| 256 | |||
| 257 | WARN_ON(buf_size < MAX_RX_LENGTH); | ||
| 258 | |||
| 259 | return buf_size; | ||
| 260 | } | ||
| 261 | |||
| 262 | static inline void mtk_get_rxd(struct mtk_rx_dma *rxd, | ||
| 263 | struct mtk_rx_dma *dma_rxd) | ||
| 264 | { | ||
| 265 | rxd->rxd1 = READ_ONCE(dma_rxd->rxd1); | ||
| 266 | rxd->rxd2 = READ_ONCE(dma_rxd->rxd2); | ||
| 267 | rxd->rxd3 = READ_ONCE(dma_rxd->rxd3); | ||
| 268 | rxd->rxd4 = READ_ONCE(dma_rxd->rxd4); | ||
| 269 | } | ||
| 270 | |||
| 271 | static inline void mtk_set_txd_pdma(struct mtk_tx_dma *txd, | ||
| 272 | struct mtk_tx_dma *dma_txd) | ||
| 273 | { | ||
| 274 | WRITE_ONCE(dma_txd->txd1, txd->txd1); | ||
| 275 | WRITE_ONCE(dma_txd->txd3, txd->txd3); | ||
| 276 | WRITE_ONCE(dma_txd->txd4, txd->txd4); | ||
| 277 | /* clean dma done flag last */ | ||
| 278 | WRITE_ONCE(dma_txd->txd2, txd->txd2); | ||
| 279 | } | ||
| 280 | |||
| 281 | static void mtk_clean_rx(struct mtk_eth *eth, struct mtk_rx_ring *ring) | ||
| 282 | { | ||
| 283 | int i; | ||
| 284 | |||
| 285 | if (ring->rx_data && ring->rx_dma) { | ||
| 286 | for (i = 0; i < ring->rx_ring_size; i++) { | ||
| 287 | if (!ring->rx_data[i]) | ||
| 288 | continue; | ||
| 289 | if (!ring->rx_dma[i].rxd1) | ||
| 290 | continue; | ||
| 291 | dma_unmap_single(eth->dev, | ||
| 292 | ring->rx_dma[i].rxd1, | ||
| 293 | ring->rx_buf_size, | ||
| 294 | DMA_FROM_DEVICE); | ||
| 295 | skb_free_frag(ring->rx_data[i]); | ||
| 296 | } | ||
| 297 | kfree(ring->rx_data); | ||
| 298 | ring->rx_data = NULL; | ||
| 299 | } | ||
| 300 | |||
| 301 | if (ring->rx_dma) { | ||
| 302 | dma_free_coherent(eth->dev, | ||
| 303 | ring->rx_ring_size * sizeof(*ring->rx_dma), | ||
| 304 | ring->rx_dma, | ||
| 305 | ring->rx_phys); | ||
| 306 | ring->rx_dma = NULL; | ||
| 307 | } | ||
| 308 | } | ||
| 309 | |||
| 310 | static int mtk_dma_rx_alloc(struct mtk_eth *eth, struct mtk_rx_ring *ring) | ||
| 311 | { | ||
| 312 | int i, pad = 0; | ||
| 313 | |||
| 314 | ring->frag_size = mtk_max_frag_size(ETH_DATA_LEN); | ||
| 315 | ring->rx_buf_size = mtk_max_buf_size(ring->frag_size); | ||
| 316 | ring->rx_ring_size = eth->soc->dma_ring_size; | ||
| 317 | ring->rx_data = kcalloc(ring->rx_ring_size, sizeof(*ring->rx_data), | ||
| 318 | GFP_KERNEL); | ||
| 319 | if (!ring->rx_data) | ||
| 320 | goto no_rx_mem; | ||
| 321 | |||
| 322 | for (i = 0; i < ring->rx_ring_size; i++) { | ||
| 323 | ring->rx_data[i] = netdev_alloc_frag(ring->frag_size); | ||
| 324 | if (!ring->rx_data[i]) | ||
| 325 | goto no_rx_mem; | ||
| 326 | } | ||
| 327 | |||
| 328 | ring->rx_dma = | ||
| 329 | dma_alloc_coherent(eth->dev, | ||
| 330 | ring->rx_ring_size * sizeof(*ring->rx_dma), | ||
| 331 | &ring->rx_phys, GFP_ATOMIC | __GFP_ZERO); | ||
| 332 | if (!ring->rx_dma) | ||
| 333 | goto no_rx_mem; | ||
| 334 | |||
| 335 | if (!eth->soc->rx_2b_offset) | ||
| 336 | pad = NET_IP_ALIGN; | ||
| 337 | |||
| 338 | for (i = 0; i < ring->rx_ring_size; i++) { | ||
| 339 | dma_addr_t dma_addr = dma_map_single(eth->dev, | ||
| 340 | ring->rx_data[i] + NET_SKB_PAD + pad, | ||
| 341 | ring->rx_buf_size, | ||
| 342 | DMA_FROM_DEVICE); | ||
| 343 | if (unlikely(dma_mapping_error(eth->dev, dma_addr))) | ||
| 344 | goto no_rx_mem; | ||
| 345 | ring->rx_dma[i].rxd1 = (unsigned int)dma_addr; | ||
| 346 | |||
| 347 | if (eth->soc->rx_sg_dma) | ||
| 348 | ring->rx_dma[i].rxd2 = RX_DMA_PLEN0(ring->rx_buf_size); | ||
| 349 | else | ||
| 350 | ring->rx_dma[i].rxd2 = RX_DMA_LSO; | ||
| 351 | } | ||
| 352 | ring->rx_calc_idx = ring->rx_ring_size - 1; | ||
| 353 | /* make sure that all changes to the dma ring are flushed before we | ||
| 354 | * continue | ||
| 355 | */ | ||
| 356 | wmb(); | ||
| 357 | |||
| 358 | return 0; | ||
| 359 | |||
| 360 | no_rx_mem: | ||
| 361 | return -ENOMEM; | ||
| 362 | } | ||
| 363 | |||
| 364 | static void mtk_txd_unmap(struct device *dev, struct mtk_tx_buf *tx_buf) | ||
| 365 | { | ||
| 366 | if (tx_buf->flags & MTK_TX_FLAGS_SINGLE0) { | ||
| 367 | dma_unmap_single(dev, | ||
| 368 | dma_unmap_addr(tx_buf, dma_addr0), | ||
| 369 | dma_unmap_len(tx_buf, dma_len0), | ||
| 370 | DMA_TO_DEVICE); | ||
| 371 | } else if (tx_buf->flags & MTK_TX_FLAGS_PAGE0) { | ||
| 372 | dma_unmap_page(dev, | ||
| 373 | dma_unmap_addr(tx_buf, dma_addr0), | ||
| 374 | dma_unmap_len(tx_buf, dma_len0), | ||
| 375 | DMA_TO_DEVICE); | ||
| 376 | } | ||
| 377 | if (tx_buf->flags & MTK_TX_FLAGS_PAGE1) | ||
| 378 | dma_unmap_page(dev, | ||
| 379 | dma_unmap_addr(tx_buf, dma_addr1), | ||
| 380 | dma_unmap_len(tx_buf, dma_len1), | ||
| 381 | DMA_TO_DEVICE); | ||
| 382 | |||
| 383 | tx_buf->flags = 0; | ||
| 384 | if (tx_buf->skb && (tx_buf->skb != (struct sk_buff *)DMA_DUMMY_DESC)) | ||
| 385 | dev_kfree_skb_any(tx_buf->skb); | ||
| 386 | tx_buf->skb = NULL; | ||
| 387 | } | ||
| 388 | |||
| 389 | static void mtk_pdma_tx_clean(struct mtk_eth *eth) | ||
| 390 | { | ||
| 391 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 392 | int i; | ||
| 393 | |||
| 394 | if (ring->tx_buf) { | ||
| 395 | for (i = 0; i < ring->tx_ring_size; i++) | ||
| 396 | mtk_txd_unmap(eth->dev, &ring->tx_buf[i]); | ||
| 397 | kfree(ring->tx_buf); | ||
| 398 | ring->tx_buf = NULL; | ||
| 399 | } | ||
| 400 | |||
| 401 | if (ring->tx_dma) { | ||
| 402 | dma_free_coherent(eth->dev, | ||
| 403 | ring->tx_ring_size * sizeof(*ring->tx_dma), | ||
| 404 | ring->tx_dma, | ||
| 405 | ring->tx_phys); | ||
| 406 | ring->tx_dma = NULL; | ||
| 407 | } | ||
| 408 | } | ||
| 409 | |||
| 410 | static void mtk_qdma_tx_clean(struct mtk_eth *eth) | ||
| 411 | { | ||
| 412 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 413 | int i; | ||
| 414 | |||
| 415 | if (ring->tx_buf) { | ||
| 416 | for (i = 0; i < ring->tx_ring_size; i++) | ||
| 417 | mtk_txd_unmap(eth->dev, &ring->tx_buf[i]); | ||
| 418 | kfree(ring->tx_buf); | ||
| 419 | ring->tx_buf = NULL; | ||
| 420 | } | ||
| 421 | |||
| 422 | if (ring->tx_dma) { | ||
| 423 | dma_free_coherent(eth->dev, | ||
| 424 | ring->tx_ring_size * sizeof(*ring->tx_dma), | ||
| 425 | ring->tx_dma, | ||
| 426 | ring->tx_phys); | ||
| 427 | ring->tx_dma = NULL; | ||
| 428 | } | ||
| 429 | } | ||
| 430 | |||
| 431 | void mtk_stats_update_mac(struct mtk_mac *mac) | ||
| 432 | { | ||
| 433 | struct mtk_hw_stats *hw_stats = mac->hw_stats; | ||
| 434 | unsigned int base = mtk_reg_table[MTK_REG_MTK_COUNTER_BASE]; | ||
| 435 | u64 stats; | ||
| 436 | |||
| 437 | base += hw_stats->reg_offset; | ||
| 438 | |||
| 439 | u64_stats_update_begin(&hw_stats->syncp); | ||
| 440 | |||
| 441 | if (mac->hw->soc->new_stats) { | ||
| 442 | hw_stats->rx_bytes += mtk_r32(mac->hw, base); | ||
| 443 | stats = mtk_r32(mac->hw, base + 0x04); | ||
| 444 | if (stats) | ||
| 445 | hw_stats->rx_bytes += (stats << 32); | ||
| 446 | hw_stats->rx_packets += mtk_r32(mac->hw, base + 0x08); | ||
| 447 | hw_stats->rx_overflow += mtk_r32(mac->hw, base + 0x10); | ||
| 448 | hw_stats->rx_fcs_errors += mtk_r32(mac->hw, base + 0x14); | ||
| 449 | hw_stats->rx_short_errors += mtk_r32(mac->hw, base + 0x18); | ||
| 450 | hw_stats->rx_long_errors += mtk_r32(mac->hw, base + 0x1c); | ||
| 451 | hw_stats->rx_checksum_errors += mtk_r32(mac->hw, base + 0x20); | ||
| 452 | hw_stats->rx_flow_control_packets += | ||
| 453 | mtk_r32(mac->hw, base + 0x24); | ||
| 454 | hw_stats->tx_skip += mtk_r32(mac->hw, base + 0x28); | ||
| 455 | hw_stats->tx_collisions += mtk_r32(mac->hw, base + 0x2c); | ||
| 456 | hw_stats->tx_bytes += mtk_r32(mac->hw, base + 0x30); | ||
| 457 | stats = mtk_r32(mac->hw, base + 0x34); | ||
| 458 | if (stats) | ||
| 459 | hw_stats->tx_bytes += (stats << 32); | ||
| 460 | hw_stats->tx_packets += mtk_r32(mac->hw, base + 0x38); | ||
| 461 | } else { | ||
| 462 | hw_stats->tx_bytes += mtk_r32(mac->hw, base); | ||
| 463 | hw_stats->tx_packets += mtk_r32(mac->hw, base + 0x04); | ||
| 464 | hw_stats->tx_skip += mtk_r32(mac->hw, base + 0x08); | ||
| 465 | hw_stats->tx_collisions += mtk_r32(mac->hw, base + 0x0c); | ||
| 466 | hw_stats->rx_bytes += mtk_r32(mac->hw, base + 0x20); | ||
| 467 | hw_stats->rx_packets += mtk_r32(mac->hw, base + 0x24); | ||
| 468 | hw_stats->rx_overflow += mtk_r32(mac->hw, base + 0x28); | ||
| 469 | hw_stats->rx_fcs_errors += mtk_r32(mac->hw, base + 0x2c); | ||
| 470 | hw_stats->rx_short_errors += mtk_r32(mac->hw, base + 0x30); | ||
| 471 | hw_stats->rx_long_errors += mtk_r32(mac->hw, base + 0x34); | ||
| 472 | hw_stats->rx_checksum_errors += mtk_r32(mac->hw, base + 0x38); | ||
| 473 | hw_stats->rx_flow_control_packets += | ||
| 474 | mtk_r32(mac->hw, base + 0x3c); | ||
| 475 | } | ||
| 476 | |||
| 477 | u64_stats_update_end(&hw_stats->syncp); | ||
| 478 | } | ||
| 479 | |||
| 480 | static void mtk_get_stats64(struct net_device *dev, | ||
| 481 | struct rtnl_link_stats64 *storage) | ||
| 482 | { | ||
| 483 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 484 | struct mtk_hw_stats *hw_stats = mac->hw_stats; | ||
| 485 | unsigned int base = mtk_reg_table[MTK_REG_MTK_COUNTER_BASE]; | ||
| 486 | unsigned int start; | ||
| 487 | |||
| 488 | if (!base) { | ||
| 489 | netdev_stats_to_stats64(storage, &dev->stats); | ||
| 490 | return; | ||
| 491 | } | ||
| 492 | |||
| 493 | if (netif_running(dev) && netif_device_present(dev)) { | ||
| 494 | if (spin_trylock(&hw_stats->stats_lock)) { | ||
| 495 | mtk_stats_update_mac(mac); | ||
| 496 | spin_unlock(&hw_stats->stats_lock); | ||
| 497 | } | ||
| 498 | } | ||
| 499 | |||
| 500 | do { | ||
| 501 | start = u64_stats_fetch_begin_irq(&hw_stats->syncp); | ||
| 502 | storage->rx_packets = hw_stats->rx_packets; | ||
| 503 | storage->tx_packets = hw_stats->tx_packets; | ||
| 504 | storage->rx_bytes = hw_stats->rx_bytes; | ||
| 505 | storage->tx_bytes = hw_stats->tx_bytes; | ||
| 506 | storage->collisions = hw_stats->tx_collisions; | ||
| 507 | storage->rx_length_errors = hw_stats->rx_short_errors + | ||
| 508 | hw_stats->rx_long_errors; | ||
| 509 | storage->rx_over_errors = hw_stats->rx_overflow; | ||
| 510 | storage->rx_crc_errors = hw_stats->rx_fcs_errors; | ||
| 511 | storage->rx_errors = hw_stats->rx_checksum_errors; | ||
| 512 | storage->tx_aborted_errors = hw_stats->tx_skip; | ||
| 513 | } while (u64_stats_fetch_retry_irq(&hw_stats->syncp, start)); | ||
| 514 | |||
| 515 | storage->tx_errors = dev->stats.tx_errors; | ||
| 516 | storage->rx_dropped = dev->stats.rx_dropped; | ||
| 517 | storage->tx_dropped = dev->stats.tx_dropped; | ||
| 518 | } | ||
| 519 | |||
| 520 | static int mtk_vlan_rx_add_vid(struct net_device *dev, | ||
| 521 | __be16 proto, u16 vid) | ||
| 522 | { | ||
| 523 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 524 | struct mtk_eth *eth = mac->hw; | ||
| 525 | u32 idx = (vid & 0xf); | ||
| 526 | u32 vlan_cfg; | ||
| 527 | |||
| 528 | if (!((mtk_reg_table[MTK_REG_MTK_DMA_VID_BASE]) && | ||
| 529 | (dev->features & NETIF_F_HW_VLAN_CTAG_TX))) | ||
| 530 | return 0; | ||
| 531 | |||
| 532 | if (test_bit(idx, ð->vlan_map)) { | ||
| 533 | netdev_warn(dev, "disable tx vlan offload\n"); | ||
| 534 | dev->wanted_features &= ~NETIF_F_HW_VLAN_CTAG_TX; | ||
| 535 | netdev_update_features(dev); | ||
| 536 | } else { | ||
| 537 | vlan_cfg = mtk_r32(eth, | ||
| 538 | mtk_reg_table[MTK_REG_MTK_DMA_VID_BASE] + | ||
| 539 | ((idx >> 1) << 2)); | ||
| 540 | if (idx & 0x1) { | ||
| 541 | vlan_cfg &= 0xffff; | ||
| 542 | vlan_cfg |= (vid << 16); | ||
| 543 | } else { | ||
| 544 | vlan_cfg &= 0xffff0000; | ||
| 545 | vlan_cfg |= vid; | ||
| 546 | } | ||
| 547 | mtk_w32(eth, | ||
| 548 | vlan_cfg, mtk_reg_table[MTK_REG_MTK_DMA_VID_BASE] + | ||
| 549 | ((idx >> 1) << 2)); | ||
| 550 | set_bit(idx, ð->vlan_map); | ||
| 551 | } | ||
| 552 | |||
| 553 | return 0; | ||
| 554 | } | ||
| 555 | |||
| 556 | static int mtk_vlan_rx_kill_vid(struct net_device *dev, | ||
| 557 | __be16 proto, u16 vid) | ||
| 558 | { | ||
| 559 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 560 | struct mtk_eth *eth = mac->hw; | ||
| 561 | u32 idx = (vid & 0xf); | ||
| 562 | |||
| 563 | if (!((mtk_reg_table[MTK_REG_MTK_DMA_VID_BASE]) && | ||
| 564 | (dev->features & NETIF_F_HW_VLAN_CTAG_TX))) | ||
| 565 | return 0; | ||
| 566 | |||
| 567 | clear_bit(idx, ð->vlan_map); | ||
| 568 | |||
| 569 | return 0; | ||
| 570 | } | ||
| 571 | |||
| 572 | static inline u32 mtk_pdma_empty_txd(struct mtk_tx_ring *ring) | ||
| 573 | { | ||
| 574 | barrier(); | ||
| 575 | return (u32)(ring->tx_ring_size - | ||
| 576 | ((ring->tx_next_idx - ring->tx_free_idx) & | ||
| 577 | (ring->tx_ring_size - 1))); | ||
| 578 | } | ||
| 579 | |||
| 580 | static int mtk_skb_padto(struct sk_buff *skb, struct mtk_eth *eth) | ||
| 581 | { | ||
| 582 | unsigned int len; | ||
| 583 | int ret; | ||
| 584 | |||
| 585 | if (unlikely(skb->len >= VLAN_ETH_ZLEN)) | ||
| 586 | return 0; | ||
| 587 | |||
| 588 | if (eth->soc->padding_64b && !eth->soc->padding_bug) | ||
| 589 | return 0; | ||
| 590 | |||
| 591 | if (skb_vlan_tag_present(skb)) | ||
| 592 | len = ETH_ZLEN; | ||
| 593 | else if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) | ||
| 594 | len = VLAN_ETH_ZLEN; | ||
| 595 | else if (!eth->soc->padding_64b) | ||
| 596 | len = ETH_ZLEN; | ||
| 597 | else | ||
| 598 | return 0; | ||
| 599 | |||
| 600 | if (skb->len >= len) | ||
| 601 | return 0; | ||
| 602 | |||
| 603 | ret = skb_pad(skb, len - skb->len); | ||
| 604 | if (ret < 0) | ||
| 605 | return ret; | ||
| 606 | skb->len = len; | ||
| 607 | skb_set_tail_pointer(skb, len); | ||
| 608 | |||
| 609 | return ret; | ||
| 610 | } | ||
| 611 | |||
| 612 | static int mtk_pdma_tx_map(struct sk_buff *skb, struct net_device *dev, | ||
| 613 | int tx_num, struct mtk_tx_ring *ring, bool gso) | ||
| 614 | { | ||
| 615 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 616 | struct mtk_eth *eth = mac->hw; | ||
| 617 | struct skb_frag_struct *frag; | ||
| 618 | struct mtk_tx_dma txd, *ptxd; | ||
| 619 | struct mtk_tx_buf *tx_buf; | ||
| 620 | int i, j, k, frag_size, frag_map_size, offset; | ||
| 621 | dma_addr_t mapped_addr; | ||
| 622 | unsigned int nr_frags; | ||
| 623 | u32 def_txd4; | ||
| 624 | |||
| 625 | if (mtk_skb_padto(skb, eth)) { | ||
| 626 | netif_warn(eth, tx_err, dev, "tx padding failed!\n"); | ||
| 627 | return -1; | ||
| 628 | } | ||
| 629 | |||
| 630 | tx_buf = &ring->tx_buf[ring->tx_next_idx]; | ||
| 631 | memset(tx_buf, 0, sizeof(*tx_buf)); | ||
| 632 | memset(&txd, 0, sizeof(txd)); | ||
| 633 | nr_frags = skb_shinfo(skb)->nr_frags; | ||
| 634 | |||
| 635 | /* init tx descriptor */ | ||
| 636 | def_txd4 = eth->soc->txd4; | ||
| 637 | txd.txd4 = def_txd4; | ||
| 638 | |||
| 639 | if (eth->soc->mac_count > 1) | ||
| 640 | txd.txd4 |= (mac->id + 1) << TX_DMA_FPORT_SHIFT; | ||
| 641 | |||
| 642 | if (gso) | ||
| 643 | txd.txd4 |= TX_DMA_TSO; | ||
| 644 | |||
| 645 | /* TX Checksum offload */ | ||
| 646 | if (skb->ip_summed == CHECKSUM_PARTIAL) | ||
| 647 | txd.txd4 |= TX_DMA_CHKSUM; | ||
| 648 | |||
| 649 | /* VLAN header offload */ | ||
| 650 | if (skb_vlan_tag_present(skb)) { | ||
| 651 | u16 tag = skb_vlan_tag_get(skb); | ||
| 652 | |||
| 653 | txd.txd4 |= TX_DMA_INS_VLAN | | ||
| 654 | ((tag >> VLAN_PRIO_SHIFT) << 4) | | ||
| 655 | (tag & 0xF); | ||
| 656 | } | ||
| 657 | |||
| 658 | mapped_addr = dma_map_single(&dev->dev, skb->data, | ||
| 659 | skb_headlen(skb), DMA_TO_DEVICE); | ||
| 660 | if (unlikely(dma_mapping_error(&dev->dev, mapped_addr))) | ||
| 661 | return -1; | ||
| 662 | |||
| 663 | txd.txd1 = mapped_addr; | ||
| 664 | txd.txd2 = TX_DMA_PLEN0(skb_headlen(skb)); | ||
| 665 | |||
| 666 | tx_buf->flags |= MTK_TX_FLAGS_SINGLE0; | ||
| 667 | dma_unmap_addr_set(tx_buf, dma_addr0, mapped_addr); | ||
| 668 | dma_unmap_len_set(tx_buf, dma_len0, skb_headlen(skb)); | ||
| 669 | |||
| 670 | /* TX SG offload */ | ||
| 671 | j = ring->tx_next_idx; | ||
| 672 | k = 0; | ||
| 673 | for (i = 0; i < nr_frags; i++) { | ||
| 674 | offset = 0; | ||
| 675 | frag = &skb_shinfo(skb)->frags[i]; | ||
| 676 | frag_size = skb_frag_size(frag); | ||
| 677 | |||
| 678 | while (frag_size > 0) { | ||
| 679 | frag_map_size = min(frag_size, TX_DMA_BUF_LEN); | ||
| 680 | mapped_addr = skb_frag_dma_map(&dev->dev, frag, offset, | ||
| 681 | frag_map_size, | ||
| 682 | DMA_TO_DEVICE); | ||
| 683 | if (unlikely(dma_mapping_error(&dev->dev, mapped_addr))) | ||
| 684 | goto err_dma; | ||
| 685 | |||
| 686 | if (k & 0x1) { | ||
| 687 | j = NEXT_TX_DESP_IDX(j); | ||
| 688 | txd.txd1 = mapped_addr; | ||
| 689 | txd.txd2 = TX_DMA_PLEN0(frag_map_size); | ||
| 690 | txd.txd4 = def_txd4; | ||
| 691 | |||
| 692 | tx_buf = &ring->tx_buf[j]; | ||
| 693 | memset(tx_buf, 0, sizeof(*tx_buf)); | ||
| 694 | |||
| 695 | tx_buf->flags |= MTK_TX_FLAGS_PAGE0; | ||
| 696 | dma_unmap_addr_set(tx_buf, dma_addr0, | ||
| 697 | mapped_addr); | ||
| 698 | dma_unmap_len_set(tx_buf, dma_len0, | ||
| 699 | frag_map_size); | ||
| 700 | } else { | ||
| 701 | txd.txd3 = mapped_addr; | ||
| 702 | txd.txd2 |= TX_DMA_PLEN1(frag_map_size); | ||
| 703 | |||
| 704 | tx_buf->skb = (struct sk_buff *)DMA_DUMMY_DESC; | ||
| 705 | tx_buf->flags |= MTK_TX_FLAGS_PAGE1; | ||
| 706 | dma_unmap_addr_set(tx_buf, dma_addr1, | ||
| 707 | mapped_addr); | ||
| 708 | dma_unmap_len_set(tx_buf, dma_len1, | ||
| 709 | frag_map_size); | ||
| 710 | |||
| 711 | if (!((i == (nr_frags - 1)) && | ||
| 712 | (frag_map_size == frag_size))) { | ||
| 713 | mtk_set_txd_pdma(&txd, | ||
| 714 | &ring->tx_dma[j]); | ||
| 715 | memset(&txd, 0, sizeof(txd)); | ||
| 716 | } | ||
| 717 | } | ||
| 718 | frag_size -= frag_map_size; | ||
| 719 | offset += frag_map_size; | ||
| 720 | k++; | ||
| 721 | } | ||
| 722 | } | ||
| 723 | |||
| 724 | /* set last segment */ | ||
| 725 | if (k & 0x1) | ||
| 726 | txd.txd2 |= TX_DMA_LS1; | ||
| 727 | else | ||
| 728 | txd.txd2 |= TX_DMA_LS0; | ||
| 729 | mtk_set_txd_pdma(&txd, &ring->tx_dma[j]); | ||
| 730 | |||
| 731 | /* store skb to cleanup */ | ||
| 732 | tx_buf->skb = skb; | ||
| 733 | |||
| 734 | netdev_sent_queue(dev, skb->len); | ||
| 735 | skb_tx_timestamp(skb); | ||
| 736 | |||
| 737 | ring->tx_next_idx = NEXT_TX_DESP_IDX(j); | ||
| 738 | /* make sure that all changes to the dma ring are flushed before we | ||
| 739 | * continue | ||
| 740 | */ | ||
| 741 | wmb(); | ||
| 742 | atomic_set(&ring->tx_free_count, mtk_pdma_empty_txd(ring)); | ||
| 743 | |||
| 744 | if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || !skb->xmit_more) | ||
| 745 | mtk_reg_w32(eth, ring->tx_next_idx, MTK_REG_TX_CTX_IDX0); | ||
| 746 | |||
| 747 | return 0; | ||
| 748 | |||
| 749 | err_dma: | ||
| 750 | j = ring->tx_next_idx; | ||
| 751 | for (i = 0; i < tx_num; i++) { | ||
| 752 | ptxd = &ring->tx_dma[j]; | ||
| 753 | tx_buf = &ring->tx_buf[j]; | ||
| 754 | |||
| 755 | /* unmap dma */ | ||
| 756 | mtk_txd_unmap(&dev->dev, tx_buf); | ||
| 757 | |||
| 758 | ptxd->txd2 = TX_DMA_DESP2_DEF; | ||
| 759 | j = NEXT_TX_DESP_IDX(j); | ||
| 760 | } | ||
| 761 | /* make sure that all changes to the dma ring are flushed before we | ||
| 762 | * continue | ||
| 763 | */ | ||
| 764 | wmb(); | ||
| 765 | return -1; | ||
| 766 | } | ||
| 767 | |||
| 768 | /* the qdma core needs scratch memory to be setup */ | ||
| 769 | static int mtk_init_fq_dma(struct mtk_eth *eth) | ||
| 770 | { | ||
| 771 | dma_addr_t dma_addr, phy_ring_head, phy_ring_tail; | ||
| 772 | int cnt = eth->soc->dma_ring_size; | ||
| 773 | int i; | ||
| 774 | |||
| 775 | eth->scratch_ring = dma_alloc_coherent(eth->dev, | ||
| 776 | cnt * sizeof(struct mtk_tx_dma), | ||
| 777 | &phy_ring_head, | ||
| 778 | GFP_ATOMIC | __GFP_ZERO); | ||
| 779 | if (unlikely(!eth->scratch_ring)) | ||
| 780 | return -ENOMEM; | ||
| 781 | |||
| 782 | eth->scratch_head = kcalloc(cnt, QDMA_PAGE_SIZE, | ||
| 783 | GFP_KERNEL); | ||
| 784 | dma_addr = dma_map_single(eth->dev, | ||
| 785 | eth->scratch_head, cnt * QDMA_PAGE_SIZE, | ||
| 786 | DMA_FROM_DEVICE); | ||
| 787 | if (unlikely(dma_mapping_error(eth->dev, dma_addr))) | ||
| 788 | return -ENOMEM; | ||
| 789 | |||
| 790 | memset(eth->scratch_ring, 0x0, sizeof(struct mtk_tx_dma) * cnt); | ||
| 791 | phy_ring_tail = phy_ring_head + (sizeof(struct mtk_tx_dma) * (cnt - 1)); | ||
| 792 | |||
| 793 | for (i = 0; i < cnt; i++) { | ||
| 794 | eth->scratch_ring[i].txd1 = (dma_addr + (i * QDMA_PAGE_SIZE)); | ||
| 795 | if (i < cnt - 1) | ||
| 796 | eth->scratch_ring[i].txd2 = (phy_ring_head + | ||
| 797 | ((i + 1) * sizeof(struct mtk_tx_dma))); | ||
| 798 | eth->scratch_ring[i].txd3 = TX_QDMA_SDL(QDMA_PAGE_SIZE); | ||
| 799 | } | ||
| 800 | |||
| 801 | mtk_w32(eth, phy_ring_head, MTK_QDMA_FQ_HEAD); | ||
| 802 | mtk_w32(eth, phy_ring_tail, MTK_QDMA_FQ_TAIL); | ||
| 803 | mtk_w32(eth, (cnt << 16) | cnt, MTK_QDMA_FQ_CNT); | ||
| 804 | mtk_w32(eth, QDMA_PAGE_SIZE << 16, MTK_QDMA_FQ_BLEN); | ||
| 805 | |||
| 806 | return 0; | ||
| 807 | } | ||
| 808 | |||
| 809 | static void *mtk_qdma_phys_to_virt(struct mtk_tx_ring *ring, u32 desc) | ||
| 810 | { | ||
| 811 | void *ret = ring->tx_dma; | ||
| 812 | |||
| 813 | return ret + (desc - ring->tx_phys); | ||
| 814 | } | ||
| 815 | |||
| 816 | static struct mtk_tx_dma *mtk_tx_next_qdma(struct mtk_tx_ring *ring, | ||
| 817 | struct mtk_tx_dma *txd) | ||
| 818 | { | ||
| 819 | return mtk_qdma_phys_to_virt(ring, txd->txd2); | ||
| 820 | } | ||
| 821 | |||
| 822 | static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, | ||
| 823 | struct mtk_tx_dma *txd) | ||
| 824 | { | ||
| 825 | int idx = txd - ring->tx_dma; | ||
| 826 | |||
| 827 | return &ring->tx_buf[idx]; | ||
| 828 | } | ||
| 829 | |||
| 830 | static int mtk_qdma_tx_map(struct sk_buff *skb, struct net_device *dev, | ||
| 831 | int tx_num, struct mtk_tx_ring *ring, bool gso) | ||
| 832 | { | ||
| 833 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 834 | struct mtk_eth *eth = mac->hw; | ||
| 835 | struct mtk_tx_dma *itxd, *txd; | ||
| 836 | struct mtk_tx_buf *tx_buf; | ||
| 837 | dma_addr_t mapped_addr; | ||
| 838 | unsigned int nr_frags; | ||
| 839 | int i, n_desc = 1; | ||
| 840 | u32 txd4 = eth->soc->txd4; | ||
| 841 | |||
| 842 | itxd = ring->tx_next_free; | ||
| 843 | if (itxd == ring->tx_last_free) | ||
| 844 | return -ENOMEM; | ||
| 845 | |||
| 846 | if (eth->soc->mac_count > 1) | ||
| 847 | txd4 |= (mac->id + 1) << TX_DMA_FPORT_SHIFT; | ||
| 848 | |||
| 849 | tx_buf = mtk_desc_to_tx_buf(ring, itxd); | ||
| 850 | memset(tx_buf, 0, sizeof(*tx_buf)); | ||
| 851 | |||
| 852 | if (gso) | ||
| 853 | txd4 |= TX_DMA_TSO; | ||
| 854 | |||
| 855 | /* TX Checksum offload */ | ||
| 856 | if (skb->ip_summed == CHECKSUM_PARTIAL) | ||
| 857 | txd4 |= TX_DMA_CHKSUM; | ||
| 858 | |||
| 859 | /* VLAN header offload */ | ||
| 860 | if (skb_vlan_tag_present(skb)) | ||
| 861 | txd4 |= TX_DMA_INS_VLAN_MT7621 | skb_vlan_tag_get(skb); | ||
| 862 | |||
| 863 | mapped_addr = dma_map_single(&dev->dev, skb->data, | ||
| 864 | skb_headlen(skb), DMA_TO_DEVICE); | ||
| 865 | if (unlikely(dma_mapping_error(&dev->dev, mapped_addr))) | ||
| 866 | return -ENOMEM; | ||
| 867 | |||
| 868 | WRITE_ONCE(itxd->txd1, mapped_addr); | ||
| 869 | tx_buf->flags |= MTK_TX_FLAGS_SINGLE0; | ||
| 870 | dma_unmap_addr_set(tx_buf, dma_addr0, mapped_addr); | ||
| 871 | dma_unmap_len_set(tx_buf, dma_len0, skb_headlen(skb)); | ||
| 872 | |||
| 873 | /* TX SG offload */ | ||
| 874 | txd = itxd; | ||
| 875 | nr_frags = skb_shinfo(skb)->nr_frags; | ||
| 876 | for (i = 0; i < nr_frags; i++) { | ||
| 877 | struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i]; | ||
| 878 | unsigned int offset = 0; | ||
| 879 | int frag_size = skb_frag_size(frag); | ||
| 880 | |||
| 881 | while (frag_size) { | ||
| 882 | bool last_frag = false; | ||
| 883 | unsigned int frag_map_size; | ||
| 884 | |||
| 885 | txd = mtk_tx_next_qdma(ring, txd); | ||
| 886 | if (txd == ring->tx_last_free) | ||
| 887 | goto err_dma; | ||
| 888 | |||
| 889 | n_desc++; | ||
| 890 | frag_map_size = min(frag_size, TX_DMA_BUF_LEN); | ||
| 891 | mapped_addr = skb_frag_dma_map(&dev->dev, frag, offset, | ||
| 892 | frag_map_size, | ||
| 893 | DMA_TO_DEVICE); | ||
| 894 | if (unlikely(dma_mapping_error(&dev->dev, mapped_addr))) | ||
| 895 | goto err_dma; | ||
| 896 | |||
| 897 | if (i == nr_frags - 1 && | ||
| 898 | (frag_size - frag_map_size) == 0) | ||
| 899 | last_frag = true; | ||
| 900 | |||
| 901 | WRITE_ONCE(txd->txd1, mapped_addr); | ||
| 902 | WRITE_ONCE(txd->txd3, (QDMA_TX_SWC | | ||
| 903 | TX_DMA_PLEN0(frag_map_size) | | ||
| 904 | last_frag * TX_DMA_LS0) | | ||
| 905 | mac->id); | ||
| 906 | WRITE_ONCE(txd->txd4, 0); | ||
| 907 | |||
| 908 | tx_buf->skb = (struct sk_buff *)DMA_DUMMY_DESC; | ||
| 909 | tx_buf = mtk_desc_to_tx_buf(ring, txd); | ||
| 910 | memset(tx_buf, 0, sizeof(*tx_buf)); | ||
| 911 | |||
| 912 | tx_buf->flags |= MTK_TX_FLAGS_PAGE0; | ||
| 913 | dma_unmap_addr_set(tx_buf, dma_addr0, mapped_addr); | ||
| 914 | dma_unmap_len_set(tx_buf, dma_len0, frag_map_size); | ||
| 915 | frag_size -= frag_map_size; | ||
| 916 | offset += frag_map_size; | ||
| 917 | } | ||
| 918 | } | ||
| 919 | |||
| 920 | /* store skb to cleanup */ | ||
| 921 | tx_buf->skb = skb; | ||
| 922 | |||
| 923 | WRITE_ONCE(itxd->txd4, txd4); | ||
| 924 | WRITE_ONCE(itxd->txd3, (QDMA_TX_SWC | TX_DMA_PLEN0(skb_headlen(skb)) | | ||
| 925 | (!nr_frags * TX_DMA_LS0))); | ||
| 926 | |||
| 927 | netdev_sent_queue(dev, skb->len); | ||
| 928 | skb_tx_timestamp(skb); | ||
| 929 | |||
| 930 | ring->tx_next_free = mtk_tx_next_qdma(ring, txd); | ||
| 931 | atomic_sub(n_desc, &ring->tx_free_count); | ||
| 932 | |||
| 933 | /* make sure that all changes to the dma ring are flushed before we | ||
| 934 | * continue | ||
| 935 | */ | ||
| 936 | wmb(); | ||
| 937 | |||
| 938 | if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || !skb->xmit_more) | ||
| 939 | mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR); | ||
| 940 | |||
| 941 | return 0; | ||
| 942 | |||
| 943 | err_dma: | ||
| 944 | do { | ||
| 945 | tx_buf = mtk_desc_to_tx_buf(ring, txd); | ||
| 946 | |||
| 947 | /* unmap dma */ | ||
| 948 | mtk_txd_unmap(&dev->dev, tx_buf); | ||
| 949 | |||
| 950 | itxd->txd3 = TX_DMA_DESP2_DEF; | ||
| 951 | itxd = mtk_tx_next_qdma(ring, itxd); | ||
| 952 | } while (itxd != txd); | ||
| 953 | |||
| 954 | return -ENOMEM; | ||
| 955 | } | ||
| 956 | |||
| 957 | static inline int mtk_cal_txd_req(struct sk_buff *skb) | ||
| 958 | { | ||
| 959 | int i, nfrags; | ||
| 960 | struct skb_frag_struct *frag; | ||
| 961 | |||
| 962 | nfrags = 1; | ||
| 963 | if (skb_is_gso(skb)) { | ||
| 964 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | ||
| 965 | frag = &skb_shinfo(skb)->frags[i]; | ||
| 966 | nfrags += DIV_ROUND_UP(frag->size, TX_DMA_BUF_LEN); | ||
| 967 | } | ||
| 968 | } else { | ||
| 969 | nfrags += skb_shinfo(skb)->nr_frags; | ||
| 970 | } | ||
| 971 | |||
| 972 | return DIV_ROUND_UP(nfrags, 2); | ||
| 973 | } | ||
| 974 | |||
| 975 | static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
| 976 | { | ||
| 977 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 978 | struct mtk_eth *eth = mac->hw; | ||
| 979 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 980 | struct net_device_stats *stats = &dev->stats; | ||
| 981 | int tx_num; | ||
| 982 | int len = skb->len; | ||
| 983 | bool gso = false; | ||
| 984 | |||
| 985 | tx_num = mtk_cal_txd_req(skb); | ||
| 986 | if (unlikely(atomic_read(&ring->tx_free_count) <= tx_num)) { | ||
| 987 | netif_stop_queue(dev); | ||
| 988 | netif_err(eth, tx_queued, dev, | ||
| 989 | "Tx Ring full when queue awake!\n"); | ||
| 990 | return NETDEV_TX_BUSY; | ||
| 991 | } | ||
| 992 | |||
| 993 | /* TSO: fill MSS info in tcp checksum field */ | ||
| 994 | if (skb_is_gso(skb)) { | ||
| 995 | if (skb_cow_head(skb, 0)) { | ||
| 996 | netif_warn(eth, tx_err, dev, | ||
| 997 | "GSO expand head fail.\n"); | ||
| 998 | goto drop; | ||
| 999 | } | ||
| 1000 | |||
| 1001 | if (skb_shinfo(skb)->gso_type & | ||
| 1002 | (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { | ||
| 1003 | gso = true; | ||
| 1004 | tcp_hdr(skb)->check = htons(skb_shinfo(skb)->gso_size); | ||
| 1005 | } | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | if (ring->tx_map(skb, dev, tx_num, ring, gso) < 0) | ||
| 1009 | goto drop; | ||
| 1010 | |||
| 1011 | stats->tx_packets++; | ||
| 1012 | stats->tx_bytes += len; | ||
| 1013 | |||
| 1014 | if (unlikely(atomic_read(&ring->tx_free_count) <= ring->tx_thresh)) { | ||
| 1015 | netif_stop_queue(dev); | ||
| 1016 | smp_mb(); | ||
| 1017 | if (unlikely(atomic_read(&ring->tx_free_count) > | ||
| 1018 | ring->tx_thresh)) | ||
| 1019 | netif_wake_queue(dev); | ||
| 1020 | } | ||
| 1021 | |||
| 1022 | return NETDEV_TX_OK; | ||
| 1023 | |||
| 1024 | drop: | ||
| 1025 | stats->tx_dropped++; | ||
| 1026 | dev_kfree_skb(skb); | ||
| 1027 | return NETDEV_TX_OK; | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | static int mtk_poll_rx(struct napi_struct *napi, int budget, | ||
| 1031 | struct mtk_eth *eth, u32 rx_intr) | ||
| 1032 | { | ||
| 1033 | struct mtk_soc_data *soc = eth->soc; | ||
| 1034 | struct mtk_rx_ring *ring = ð->rx_ring[0]; | ||
| 1035 | int idx = ring->rx_calc_idx; | ||
| 1036 | u32 checksum_bit; | ||
| 1037 | struct sk_buff *skb; | ||
| 1038 | u8 *data, *new_data; | ||
| 1039 | struct mtk_rx_dma *rxd, trxd; | ||
| 1040 | int done = 0, pad; | ||
| 1041 | |||
| 1042 | if (eth->soc->hw_features & NETIF_F_RXCSUM) | ||
| 1043 | checksum_bit = soc->checksum_bit; | ||
| 1044 | else | ||
| 1045 | checksum_bit = 0; | ||
| 1046 | |||
| 1047 | if (eth->soc->rx_2b_offset) | ||
| 1048 | pad = 0; | ||
| 1049 | else | ||
| 1050 | pad = NET_IP_ALIGN; | ||
| 1051 | |||
| 1052 | while (done < budget) { | ||
| 1053 | struct net_device *netdev; | ||
| 1054 | unsigned int pktlen; | ||
| 1055 | dma_addr_t dma_addr; | ||
| 1056 | int mac = 0; | ||
| 1057 | |||
| 1058 | idx = NEXT_RX_DESP_IDX(idx); | ||
| 1059 | rxd = &ring->rx_dma[idx]; | ||
| 1060 | data = ring->rx_data[idx]; | ||
| 1061 | |||
| 1062 | mtk_get_rxd(&trxd, rxd); | ||
| 1063 | if (!(trxd.rxd2 & RX_DMA_DONE)) | ||
| 1064 | break; | ||
| 1065 | |||
| 1066 | /* find out which mac the packet come from. values start at 1 */ | ||
| 1067 | if (eth->soc->mac_count > 1) { | ||
| 1068 | mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) & | ||
| 1069 | RX_DMA_FPORT_MASK; | ||
| 1070 | mac--; | ||
| 1071 | if (mac < 0 || mac >= eth->soc->mac_count) | ||
| 1072 | goto release_desc; | ||
| 1073 | } | ||
| 1074 | |||
| 1075 | netdev = eth->netdev[mac]; | ||
| 1076 | |||
| 1077 | /* alloc new buffer */ | ||
| 1078 | new_data = napi_alloc_frag(ring->frag_size); | ||
| 1079 | if (unlikely(!new_data || !netdev)) { | ||
| 1080 | netdev->stats.rx_dropped++; | ||
| 1081 | goto release_desc; | ||
| 1082 | } | ||
| 1083 | dma_addr = dma_map_single(&netdev->dev, | ||
| 1084 | new_data + NET_SKB_PAD + pad, | ||
| 1085 | ring->rx_buf_size, | ||
| 1086 | DMA_FROM_DEVICE); | ||
| 1087 | if (unlikely(dma_mapping_error(&netdev->dev, dma_addr))) { | ||
| 1088 | skb_free_frag(new_data); | ||
| 1089 | goto release_desc; | ||
| 1090 | } | ||
| 1091 | |||
| 1092 | /* receive data */ | ||
| 1093 | skb = build_skb(data, ring->frag_size); | ||
| 1094 | if (unlikely(!skb)) { | ||
| 1095 | put_page(virt_to_head_page(new_data)); | ||
| 1096 | goto release_desc; | ||
| 1097 | } | ||
| 1098 | skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN); | ||
| 1099 | |||
| 1100 | dma_unmap_single(&netdev->dev, trxd.rxd1, | ||
| 1101 | ring->rx_buf_size, DMA_FROM_DEVICE); | ||
| 1102 | pktlen = RX_DMA_GET_PLEN0(trxd.rxd2); | ||
| 1103 | skb->dev = netdev; | ||
| 1104 | skb_put(skb, pktlen); | ||
| 1105 | if (trxd.rxd4 & checksum_bit) | ||
| 1106 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
| 1107 | else | ||
| 1108 | skb_checksum_none_assert(skb); | ||
| 1109 | skb->protocol = eth_type_trans(skb, netdev); | ||
| 1110 | |||
| 1111 | netdev->stats.rx_packets++; | ||
| 1112 | netdev->stats.rx_bytes += pktlen; | ||
| 1113 | |||
| 1114 | if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX && | ||
| 1115 | RX_DMA_VID(trxd.rxd3)) | ||
| 1116 | __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), | ||
| 1117 | RX_DMA_VID(trxd.rxd3)); | ||
| 1118 | napi_gro_receive(napi, skb); | ||
| 1119 | |||
| 1120 | ring->rx_data[idx] = new_data; | ||
| 1121 | rxd->rxd1 = (unsigned int)dma_addr; | ||
| 1122 | |||
| 1123 | release_desc: | ||
| 1124 | if (eth->soc->rx_sg_dma) | ||
| 1125 | rxd->rxd2 = RX_DMA_PLEN0(ring->rx_buf_size); | ||
| 1126 | else | ||
| 1127 | rxd->rxd2 = RX_DMA_LSO; | ||
| 1128 | |||
| 1129 | ring->rx_calc_idx = idx; | ||
| 1130 | /* make sure that all changes to the dma ring are flushed before | ||
| 1131 | * we continue | ||
| 1132 | */ | ||
| 1133 | wmb(); | ||
| 1134 | if (eth->soc->dma_type == MTK_QDMA) | ||
| 1135 | mtk_w32(eth, ring->rx_calc_idx, MTK_QRX_CRX_IDX0); | ||
| 1136 | else | ||
| 1137 | mtk_reg_w32(eth, ring->rx_calc_idx, | ||
| 1138 | MTK_REG_RX_CALC_IDX0); | ||
| 1139 | done++; | ||
| 1140 | } | ||
| 1141 | |||
| 1142 | if (done < budget) | ||
| 1143 | mtk_irq_ack(eth, rx_intr); | ||
| 1144 | |||
| 1145 | return done; | ||
| 1146 | } | ||
| 1147 | |||
| 1148 | static int mtk_pdma_tx_poll(struct mtk_eth *eth, int budget, bool *tx_again) | ||
| 1149 | { | ||
| 1150 | struct sk_buff *skb; | ||
| 1151 | struct mtk_tx_buf *tx_buf; | ||
| 1152 | int done = 0; | ||
| 1153 | u32 idx, hwidx; | ||
| 1154 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 1155 | unsigned int bytes = 0; | ||
| 1156 | |||
| 1157 | idx = ring->tx_free_idx; | ||
| 1158 | hwidx = mtk_reg_r32(eth, MTK_REG_TX_DTX_IDX0); | ||
| 1159 | |||
| 1160 | while ((idx != hwidx) && budget) { | ||
| 1161 | tx_buf = &ring->tx_buf[idx]; | ||
| 1162 | skb = tx_buf->skb; | ||
| 1163 | |||
| 1164 | if (!skb) | ||
| 1165 | break; | ||
| 1166 | |||
| 1167 | if (skb != (struct sk_buff *)DMA_DUMMY_DESC) { | ||
| 1168 | bytes += skb->len; | ||
| 1169 | done++; | ||
| 1170 | budget--; | ||
| 1171 | } | ||
| 1172 | mtk_txd_unmap(eth->dev, tx_buf); | ||
| 1173 | idx = NEXT_TX_DESP_IDX(idx); | ||
| 1174 | } | ||
| 1175 | ring->tx_free_idx = idx; | ||
| 1176 | atomic_set(&ring->tx_free_count, mtk_pdma_empty_txd(ring)); | ||
| 1177 | |||
| 1178 | /* read hw index again make sure no new tx packet */ | ||
| 1179 | if (idx != hwidx || idx != mtk_reg_r32(eth, MTK_REG_TX_DTX_IDX0)) | ||
| 1180 | *tx_again = 1; | ||
| 1181 | |||
| 1182 | if (done) | ||
| 1183 | netdev_completed_queue(*eth->netdev, done, bytes); | ||
| 1184 | |||
| 1185 | return done; | ||
| 1186 | } | ||
| 1187 | |||
| 1188 | static int mtk_qdma_tx_poll(struct mtk_eth *eth, int budget, bool *tx_again) | ||
| 1189 | { | ||
| 1190 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 1191 | struct mtk_tx_dma *desc; | ||
| 1192 | struct sk_buff *skb; | ||
| 1193 | struct mtk_tx_buf *tx_buf; | ||
| 1194 | int total = 0, done[MTK_MAX_DEVS]; | ||
| 1195 | unsigned int bytes[MTK_MAX_DEVS]; | ||
| 1196 | u32 cpu, dma; | ||
| 1197 | int i; | ||
| 1198 | |||
| 1199 | memset(done, 0, sizeof(done)); | ||
| 1200 | memset(bytes, 0, sizeof(bytes)); | ||
| 1201 | |||
| 1202 | cpu = mtk_r32(eth, MTK_QTX_CRX_PTR); | ||
| 1203 | dma = mtk_r32(eth, MTK_QTX_DRX_PTR); | ||
| 1204 | |||
| 1205 | desc = mtk_qdma_phys_to_virt(ring, cpu); | ||
| 1206 | |||
| 1207 | while ((cpu != dma) && budget) { | ||
| 1208 | u32 next_cpu = desc->txd2; | ||
| 1209 | int mac; | ||
| 1210 | |||
| 1211 | desc = mtk_tx_next_qdma(ring, desc); | ||
| 1212 | if ((desc->txd3 & QDMA_TX_OWNER_CPU) == 0) | ||
| 1213 | break; | ||
| 1214 | |||
| 1215 | mac = (desc->txd4 >> TX_DMA_FPORT_SHIFT) & | ||
| 1216 | TX_DMA_FPORT_MASK; | ||
| 1217 | mac--; | ||
| 1218 | |||
| 1219 | tx_buf = mtk_desc_to_tx_buf(ring, desc); | ||
| 1220 | skb = tx_buf->skb; | ||
| 1221 | if (!skb) | ||
| 1222 | break; | ||
| 1223 | |||
| 1224 | if (skb != (struct sk_buff *)DMA_DUMMY_DESC) { | ||
| 1225 | bytes[mac] += skb->len; | ||
| 1226 | done[mac]++; | ||
| 1227 | budget--; | ||
| 1228 | } | ||
| 1229 | mtk_txd_unmap(eth->dev, tx_buf); | ||
| 1230 | |||
| 1231 | ring->tx_last_free->txd2 = next_cpu; | ||
| 1232 | ring->tx_last_free = desc; | ||
| 1233 | atomic_inc(&ring->tx_free_count); | ||
| 1234 | |||
| 1235 | cpu = next_cpu; | ||
| 1236 | } | ||
| 1237 | |||
| 1238 | mtk_w32(eth, cpu, MTK_QTX_CRX_PTR); | ||
| 1239 | |||
| 1240 | /* read hw index again make sure no new tx packet */ | ||
| 1241 | if (cpu != dma || cpu != mtk_r32(eth, MTK_QTX_DRX_PTR)) | ||
| 1242 | *tx_again = true; | ||
| 1243 | |||
| 1244 | for (i = 0; i < eth->soc->mac_count; i++) { | ||
| 1245 | if (!done[i]) | ||
| 1246 | continue; | ||
| 1247 | netdev_completed_queue(eth->netdev[i], done[i], bytes[i]); | ||
| 1248 | total += done[i]; | ||
| 1249 | } | ||
| 1250 | |||
| 1251 | return total; | ||
| 1252 | } | ||
| 1253 | |||
| 1254 | static int mtk_poll_tx(struct mtk_eth *eth, int budget, u32 tx_intr, | ||
| 1255 | bool *tx_again) | ||
| 1256 | { | ||
| 1257 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 1258 | struct net_device *netdev = eth->netdev[0]; | ||
| 1259 | int done; | ||
| 1260 | |||
| 1261 | done = eth->tx_ring.tx_poll(eth, budget, tx_again); | ||
| 1262 | if (!*tx_again) | ||
| 1263 | mtk_irq_ack(eth, tx_intr); | ||
| 1264 | |||
| 1265 | if (!done) | ||
| 1266 | return 0; | ||
| 1267 | |||
| 1268 | smp_mb(); | ||
| 1269 | if (unlikely(!netif_queue_stopped(netdev))) | ||
| 1270 | return done; | ||
| 1271 | |||
| 1272 | if (atomic_read(&ring->tx_free_count) > ring->tx_thresh) | ||
| 1273 | netif_wake_queue(netdev); | ||
| 1274 | |||
| 1275 | return done; | ||
| 1276 | } | ||
| 1277 | |||
| 1278 | static void mtk_stats_update(struct mtk_eth *eth) | ||
| 1279 | { | ||
| 1280 | int i; | ||
| 1281 | |||
| 1282 | for (i = 0; i < eth->soc->mac_count; i++) { | ||
| 1283 | if (!eth->mac[i] || !eth->mac[i]->hw_stats) | ||
| 1284 | continue; | ||
| 1285 | if (spin_trylock(ð->mac[i]->hw_stats->stats_lock)) { | ||
| 1286 | mtk_stats_update_mac(eth->mac[i]); | ||
| 1287 | spin_unlock(ð->mac[i]->hw_stats->stats_lock); | ||
| 1288 | } | ||
| 1289 | } | ||
| 1290 | } | ||
| 1291 | |||
| 1292 | static int mtk_poll(struct napi_struct *napi, int budget) | ||
| 1293 | { | ||
| 1294 | struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi); | ||
| 1295 | u32 status, mtk_status, mask, tx_intr, rx_intr, status_intr; | ||
| 1296 | int tx_done, rx_done; | ||
| 1297 | bool tx_again = false; | ||
| 1298 | |||
| 1299 | status = mtk_irq_pending(eth); | ||
| 1300 | mtk_status = mtk_irq_pending_status(eth); | ||
| 1301 | tx_intr = eth->soc->tx_int; | ||
| 1302 | rx_intr = eth->soc->rx_int; | ||
| 1303 | status_intr = eth->soc->status_int; | ||
| 1304 | tx_done = 0; | ||
| 1305 | rx_done = 0; | ||
| 1306 | tx_again = 0; | ||
| 1307 | |||
| 1308 | if (status & tx_intr) | ||
| 1309 | tx_done = mtk_poll_tx(eth, budget, tx_intr, &tx_again); | ||
| 1310 | |||
| 1311 | if (status & rx_intr) | ||
| 1312 | rx_done = mtk_poll_rx(napi, budget, eth, rx_intr); | ||
| 1313 | |||
| 1314 | if (unlikely(mtk_status & status_intr)) { | ||
| 1315 | mtk_stats_update(eth); | ||
| 1316 | mtk_irq_ack_status(eth, status_intr); | ||
| 1317 | } | ||
| 1318 | |||
| 1319 | if (unlikely(netif_msg_intr(eth))) { | ||
| 1320 | mask = mtk_irq_enabled(eth); | ||
| 1321 | netdev_info(eth->netdev[0], | ||
| 1322 | "done tx %d, rx %d, intr 0x%08x/0x%x\n", | ||
| 1323 | tx_done, rx_done, status, mask); | ||
| 1324 | } | ||
| 1325 | |||
| 1326 | if (tx_again || rx_done == budget) | ||
| 1327 | return budget; | ||
| 1328 | |||
| 1329 | status = mtk_irq_pending(eth); | ||
| 1330 | if (status & (tx_intr | rx_intr)) | ||
| 1331 | return budget; | ||
| 1332 | |||
| 1333 | napi_complete(napi); | ||
| 1334 | mtk_irq_enable(eth, tx_intr | rx_intr); | ||
| 1335 | |||
| 1336 | return rx_done; | ||
| 1337 | } | ||
| 1338 | |||
| 1339 | static int mtk_pdma_tx_alloc(struct mtk_eth *eth) | ||
| 1340 | { | ||
| 1341 | int i; | ||
| 1342 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 1343 | |||
| 1344 | ring->tx_ring_size = eth->soc->dma_ring_size; | ||
| 1345 | ring->tx_free_idx = 0; | ||
| 1346 | ring->tx_next_idx = 0; | ||
| 1347 | ring->tx_thresh = max((unsigned long)ring->tx_ring_size >> 2, | ||
| 1348 | MAX_SKB_FRAGS); | ||
| 1349 | |||
| 1350 | ring->tx_buf = kcalloc(ring->tx_ring_size, sizeof(*ring->tx_buf), | ||
| 1351 | GFP_KERNEL); | ||
| 1352 | if (!ring->tx_buf) | ||
| 1353 | goto no_tx_mem; | ||
| 1354 | |||
| 1355 | ring->tx_dma = | ||
| 1356 | dma_alloc_coherent(eth->dev, | ||
| 1357 | ring->tx_ring_size * sizeof(*ring->tx_dma), | ||
| 1358 | &ring->tx_phys, GFP_ATOMIC | __GFP_ZERO); | ||
| 1359 | if (!ring->tx_dma) | ||
| 1360 | goto no_tx_mem; | ||
| 1361 | |||
| 1362 | for (i = 0; i < ring->tx_ring_size; i++) { | ||
| 1363 | ring->tx_dma[i].txd2 = TX_DMA_DESP2_DEF; | ||
| 1364 | ring->tx_dma[i].txd4 = eth->soc->txd4; | ||
| 1365 | } | ||
| 1366 | |||
| 1367 | atomic_set(&ring->tx_free_count, mtk_pdma_empty_txd(ring)); | ||
| 1368 | ring->tx_map = mtk_pdma_tx_map; | ||
| 1369 | ring->tx_poll = mtk_pdma_tx_poll; | ||
| 1370 | ring->tx_clean = mtk_pdma_tx_clean; | ||
| 1371 | |||
| 1372 | /* make sure that all changes to the dma ring are flushed before we | ||
| 1373 | * continue | ||
| 1374 | */ | ||
| 1375 | wmb(); | ||
| 1376 | |||
| 1377 | mtk_reg_w32(eth, ring->tx_phys, MTK_REG_TX_BASE_PTR0); | ||
| 1378 | mtk_reg_w32(eth, ring->tx_ring_size, MTK_REG_TX_MAX_CNT0); | ||
| 1379 | mtk_reg_w32(eth, 0, MTK_REG_TX_CTX_IDX0); | ||
| 1380 | mtk_reg_w32(eth, MTK_PST_DTX_IDX0, MTK_REG_PDMA_RST_CFG); | ||
| 1381 | |||
| 1382 | return 0; | ||
| 1383 | |||
| 1384 | no_tx_mem: | ||
| 1385 | return -ENOMEM; | ||
| 1386 | } | ||
| 1387 | |||
| 1388 | static int mtk_qdma_tx_alloc_tx(struct mtk_eth *eth) | ||
| 1389 | { | ||
| 1390 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 1391 | int i, sz = sizeof(*ring->tx_dma); | ||
| 1392 | |||
| 1393 | ring->tx_ring_size = eth->soc->dma_ring_size; | ||
| 1394 | ring->tx_buf = kcalloc(ring->tx_ring_size, sizeof(*ring->tx_buf), | ||
| 1395 | GFP_KERNEL); | ||
| 1396 | if (!ring->tx_buf) | ||
| 1397 | goto no_tx_mem; | ||
| 1398 | |||
| 1399 | ring->tx_dma = dma_alloc_coherent(eth->dev, ring->tx_ring_size * sz, | ||
| 1400 | &ring->tx_phys, | ||
| 1401 | GFP_ATOMIC | __GFP_ZERO); | ||
| 1402 | if (!ring->tx_dma) | ||
| 1403 | goto no_tx_mem; | ||
| 1404 | |||
| 1405 | for (i = 0; i < ring->tx_ring_size; i++) { | ||
| 1406 | int next = (i + 1) % ring->tx_ring_size; | ||
| 1407 | u32 next_ptr = ring->tx_phys + next * sz; | ||
| 1408 | |||
| 1409 | ring->tx_dma[i].txd2 = next_ptr; | ||
| 1410 | ring->tx_dma[i].txd3 = TX_DMA_DESP2_DEF; | ||
| 1411 | } | ||
| 1412 | |||
| 1413 | atomic_set(&ring->tx_free_count, ring->tx_ring_size - 2); | ||
| 1414 | ring->tx_next_free = &ring->tx_dma[0]; | ||
| 1415 | ring->tx_last_free = &ring->tx_dma[ring->tx_ring_size - 2]; | ||
| 1416 | ring->tx_thresh = max((unsigned long)ring->tx_ring_size >> 2, | ||
| 1417 | MAX_SKB_FRAGS); | ||
| 1418 | |||
| 1419 | ring->tx_map = mtk_qdma_tx_map; | ||
| 1420 | ring->tx_poll = mtk_qdma_tx_poll; | ||
| 1421 | ring->tx_clean = mtk_qdma_tx_clean; | ||
| 1422 | |||
| 1423 | /* make sure that all changes to the dma ring are flushed before we | ||
| 1424 | * continue | ||
| 1425 | */ | ||
| 1426 | wmb(); | ||
| 1427 | |||
| 1428 | mtk_w32(eth, ring->tx_phys, MTK_QTX_CTX_PTR); | ||
| 1429 | mtk_w32(eth, ring->tx_phys, MTK_QTX_DTX_PTR); | ||
| 1430 | mtk_w32(eth, | ||
| 1431 | ring->tx_phys + ((ring->tx_ring_size - 1) * sz), | ||
| 1432 | MTK_QTX_CRX_PTR); | ||
| 1433 | mtk_w32(eth, | ||
| 1434 | ring->tx_phys + ((ring->tx_ring_size - 1) * sz), | ||
| 1435 | MTK_QTX_DRX_PTR); | ||
| 1436 | |||
| 1437 | return 0; | ||
| 1438 | |||
| 1439 | no_tx_mem: | ||
| 1440 | return -ENOMEM; | ||
| 1441 | } | ||
| 1442 | |||
| 1443 | static int mtk_qdma_init(struct mtk_eth *eth, int ring) | ||
| 1444 | { | ||
| 1445 | int err; | ||
| 1446 | |||
| 1447 | err = mtk_init_fq_dma(eth); | ||
| 1448 | if (err) | ||
| 1449 | return err; | ||
| 1450 | |||
| 1451 | err = mtk_qdma_tx_alloc_tx(eth); | ||
| 1452 | if (err) | ||
| 1453 | return err; | ||
| 1454 | |||
| 1455 | err = mtk_dma_rx_alloc(eth, ð->rx_ring[ring]); | ||
| 1456 | if (err) | ||
| 1457 | return err; | ||
| 1458 | |||
| 1459 | mtk_w32(eth, eth->rx_ring[ring].rx_phys, MTK_QRX_BASE_PTR0); | ||
| 1460 | mtk_w32(eth, eth->rx_ring[ring].rx_ring_size, MTK_QRX_MAX_CNT0); | ||
| 1461 | mtk_w32(eth, eth->rx_ring[ring].rx_calc_idx, MTK_QRX_CRX_IDX0); | ||
| 1462 | mtk_w32(eth, MTK_PST_DRX_IDX0, MTK_QDMA_RST_IDX); | ||
| 1463 | mtk_w32(eth, (QDMA_RES_THRES << 8) | QDMA_RES_THRES, MTK_QTX_CFG(0)); | ||
| 1464 | |||
| 1465 | /* Enable random early drop and set drop threshold automatically */ | ||
| 1466 | mtk_w32(eth, 0x174444, MTK_QDMA_FC_THRES); | ||
| 1467 | mtk_w32(eth, 0x0, MTK_QDMA_HRED2); | ||
| 1468 | |||
| 1469 | return 0; | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | static int mtk_pdma_qdma_init(struct mtk_eth *eth) | ||
| 1473 | { | ||
| 1474 | int err = mtk_qdma_init(eth, 1); | ||
| 1475 | |||
| 1476 | if (err) | ||
| 1477 | return err; | ||
| 1478 | |||
| 1479 | err = mtk_dma_rx_alloc(eth, ð->rx_ring[0]); | ||
| 1480 | if (err) | ||
| 1481 | return err; | ||
| 1482 | |||
| 1483 | mtk_reg_w32(eth, eth->rx_ring[0].rx_phys, MTK_REG_RX_BASE_PTR0); | ||
| 1484 | mtk_reg_w32(eth, eth->rx_ring[0].rx_ring_size, MTK_REG_RX_MAX_CNT0); | ||
| 1485 | mtk_reg_w32(eth, eth->rx_ring[0].rx_calc_idx, MTK_REG_RX_CALC_IDX0); | ||
| 1486 | mtk_reg_w32(eth, MTK_PST_DRX_IDX0, MTK_REG_PDMA_RST_CFG); | ||
| 1487 | |||
| 1488 | return 0; | ||
| 1489 | } | ||
| 1490 | |||
| 1491 | static int mtk_pdma_init(struct mtk_eth *eth) | ||
| 1492 | { | ||
| 1493 | struct mtk_rx_ring *ring = ð->rx_ring[0]; | ||
| 1494 | int err; | ||
| 1495 | |||
| 1496 | err = mtk_pdma_tx_alloc(eth); | ||
| 1497 | if (err) | ||
| 1498 | return err; | ||
| 1499 | |||
| 1500 | err = mtk_dma_rx_alloc(eth, ring); | ||
| 1501 | if (err) | ||
| 1502 | return err; | ||
| 1503 | |||
| 1504 | mtk_reg_w32(eth, ring->rx_phys, MTK_REG_RX_BASE_PTR0); | ||
| 1505 | mtk_reg_w32(eth, ring->rx_ring_size, MTK_REG_RX_MAX_CNT0); | ||
| 1506 | mtk_reg_w32(eth, ring->rx_calc_idx, MTK_REG_RX_CALC_IDX0); | ||
| 1507 | mtk_reg_w32(eth, MTK_PST_DRX_IDX0, MTK_REG_PDMA_RST_CFG); | ||
| 1508 | |||
| 1509 | return 0; | ||
| 1510 | } | ||
| 1511 | |||
| 1512 | static void mtk_dma_free(struct mtk_eth *eth) | ||
| 1513 | { | ||
| 1514 | int i; | ||
| 1515 | |||
| 1516 | for (i = 0; i < eth->soc->mac_count; i++) | ||
| 1517 | if (eth->netdev[i]) | ||
| 1518 | netdev_reset_queue(eth->netdev[i]); | ||
| 1519 | eth->tx_ring.tx_clean(eth); | ||
| 1520 | mtk_clean_rx(eth, ð->rx_ring[0]); | ||
| 1521 | mtk_clean_rx(eth, ð->rx_ring[1]); | ||
| 1522 | kfree(eth->scratch_head); | ||
| 1523 | } | ||
| 1524 | |||
| 1525 | static void mtk_tx_timeout(struct net_device *dev) | ||
| 1526 | { | ||
| 1527 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 1528 | struct mtk_eth *eth = mac->hw; | ||
| 1529 | struct mtk_tx_ring *ring = ð->tx_ring; | ||
| 1530 | |||
| 1531 | eth->netdev[mac->id]->stats.tx_errors++; | ||
| 1532 | netif_err(eth, tx_err, dev, | ||
| 1533 | "transmit timed out\n"); | ||
| 1534 | if (eth->soc->dma_type & MTK_PDMA) { | ||
| 1535 | netif_info(eth, drv, dev, "pdma_cfg:%08x\n", | ||
| 1536 | mtk_reg_r32(eth, MTK_REG_PDMA_GLO_CFG)); | ||
| 1537 | netif_info(eth, drv, dev, | ||
| 1538 | "tx_ring=%d, base=%08x, max=%u, ctx=%u, dtx=%u, fdx=%hu, next=%hu\n", | ||
| 1539 | 0, mtk_reg_r32(eth, MTK_REG_TX_BASE_PTR0), | ||
| 1540 | mtk_reg_r32(eth, MTK_REG_TX_MAX_CNT0), | ||
| 1541 | mtk_reg_r32(eth, MTK_REG_TX_CTX_IDX0), | ||
| 1542 | mtk_reg_r32(eth, MTK_REG_TX_DTX_IDX0), | ||
| 1543 | ring->tx_free_idx, | ||
| 1544 | ring->tx_next_idx); | ||
| 1545 | } | ||
| 1546 | if (eth->soc->dma_type & MTK_QDMA) { | ||
| 1547 | netif_info(eth, drv, dev, "qdma_cfg:%08x\n", | ||
| 1548 | mtk_r32(eth, MTK_QDMA_GLO_CFG)); | ||
| 1549 | netif_info(eth, drv, dev, | ||
| 1550 | "tx_ring=%d, ctx=%08x, dtx=%08x, crx=%08x, drx=%08x, free=%hu\n", | ||
| 1551 | 0, mtk_r32(eth, MTK_QTX_CTX_PTR), | ||
| 1552 | mtk_r32(eth, MTK_QTX_DTX_PTR), | ||
| 1553 | mtk_r32(eth, MTK_QTX_CRX_PTR), | ||
| 1554 | mtk_r32(eth, MTK_QTX_DRX_PTR), | ||
| 1555 | atomic_read(&ring->tx_free_count)); | ||
| 1556 | } | ||
| 1557 | netif_info(eth, drv, dev, | ||
| 1558 | "rx_ring=%d, base=%08x, max=%u, calc=%u, drx=%u\n", | ||
| 1559 | 0, mtk_reg_r32(eth, MTK_REG_RX_BASE_PTR0), | ||
| 1560 | mtk_reg_r32(eth, MTK_REG_RX_MAX_CNT0), | ||
| 1561 | mtk_reg_r32(eth, MTK_REG_RX_CALC_IDX0), | ||
| 1562 | mtk_reg_r32(eth, MTK_REG_RX_DRX_IDX0)); | ||
| 1563 | |||
| 1564 | schedule_work(&mac->pending_work); | ||
| 1565 | } | ||
| 1566 | |||
| 1567 | static irqreturn_t mtk_handle_irq(int irq, void *_eth) | ||
| 1568 | { | ||
| 1569 | struct mtk_eth *eth = _eth; | ||
| 1570 | u32 status, int_mask; | ||
| 1571 | |||
| 1572 | status = mtk_irq_pending(eth); | ||
| 1573 | if (unlikely(!status)) | ||
| 1574 | return IRQ_NONE; | ||
| 1575 | |||
| 1576 | int_mask = (eth->soc->rx_int | eth->soc->tx_int); | ||
| 1577 | if (likely(status & int_mask)) { | ||
| 1578 | if (likely(napi_schedule_prep(ð->rx_napi))) | ||
| 1579 | __napi_schedule(ð->rx_napi); | ||
| 1580 | } else { | ||
| 1581 | mtk_irq_ack(eth, status); | ||
| 1582 | } | ||
| 1583 | mtk_irq_disable(eth, int_mask); | ||
| 1584 | |||
| 1585 | return IRQ_HANDLED; | ||
| 1586 | } | ||
| 1587 | |||
| 1588 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
| 1589 | static void mtk_poll_controller(struct net_device *dev) | ||
| 1590 | { | ||
| 1591 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 1592 | struct mtk_eth *eth = mac->hw; | ||
| 1593 | u32 int_mask = eth->soc->tx_int | eth->soc->rx_int; | ||
| 1594 | |||
| 1595 | mtk_irq_disable(eth, int_mask); | ||
| 1596 | mtk_handle_irq(dev->irq, dev); | ||
| 1597 | mtk_irq_enable(eth, int_mask); | ||
| 1598 | } | ||
| 1599 | #endif | ||
| 1600 | |||
| 1601 | int mtk_set_clock_cycle(struct mtk_eth *eth) | ||
| 1602 | { | ||
| 1603 | unsigned long sysclk = eth->sysclk; | ||
| 1604 | |||
| 1605 | sysclk /= MTK_US_CYC_CNT_DIVISOR; | ||
| 1606 | sysclk <<= MTK_US_CYC_CNT_SHIFT; | ||
| 1607 | |||
| 1608 | mtk_w32(eth, (mtk_r32(eth, MTK_GLO_CFG) & | ||
| 1609 | ~(MTK_US_CYC_CNT_MASK << MTK_US_CYC_CNT_SHIFT)) | | ||
| 1610 | sysclk, | ||
| 1611 | MTK_GLO_CFG); | ||
| 1612 | return 0; | ||
| 1613 | } | ||
| 1614 | |||
| 1615 | void mtk_fwd_config(struct mtk_eth *eth) | ||
| 1616 | { | ||
| 1617 | u32 fwd_cfg; | ||
| 1618 | |||
| 1619 | fwd_cfg = mtk_r32(eth, MTK_GDMA1_FWD_CFG); | ||
| 1620 | |||
| 1621 | /* disable jumbo frame */ | ||
| 1622 | if (eth->soc->jumbo_frame) | ||
| 1623 | fwd_cfg &= ~MTK_GDM1_JMB_EN; | ||
| 1624 | |||
| 1625 | /* set unicast/multicast/broadcast frame to cpu */ | ||
| 1626 | fwd_cfg &= ~0xffff; | ||
| 1627 | |||
| 1628 | mtk_w32(eth, fwd_cfg, MTK_GDMA1_FWD_CFG); | ||
| 1629 | } | ||
| 1630 | |||
| 1631 | void mtk_csum_config(struct mtk_eth *eth) | ||
| 1632 | { | ||
| 1633 | if (eth->soc->hw_features & NETIF_F_RXCSUM) | ||
| 1634 | mtk_w32(eth, mtk_r32(eth, MTK_GDMA1_FWD_CFG) | | ||
| 1635 | (MTK_GDM1_ICS_EN | MTK_GDM1_TCS_EN | MTK_GDM1_UCS_EN), | ||
| 1636 | MTK_GDMA1_FWD_CFG); | ||
| 1637 | else | ||
| 1638 | mtk_w32(eth, mtk_r32(eth, MTK_GDMA1_FWD_CFG) & | ||
| 1639 | ~(MTK_GDM1_ICS_EN | MTK_GDM1_TCS_EN | MTK_GDM1_UCS_EN), | ||
| 1640 | MTK_GDMA1_FWD_CFG); | ||
| 1641 | if (eth->soc->hw_features & NETIF_F_IP_CSUM) | ||
| 1642 | mtk_w32(eth, mtk_r32(eth, MTK_CDMA_CSG_CFG) | | ||
| 1643 | (MTK_ICS_GEN_EN | MTK_TCS_GEN_EN | MTK_UCS_GEN_EN), | ||
| 1644 | MTK_CDMA_CSG_CFG); | ||
| 1645 | else | ||
| 1646 | mtk_w32(eth, mtk_r32(eth, MTK_CDMA_CSG_CFG) & | ||
| 1647 | ~(MTK_ICS_GEN_EN | MTK_TCS_GEN_EN | MTK_UCS_GEN_EN), | ||
| 1648 | MTK_CDMA_CSG_CFG); | ||
| 1649 | } | ||
| 1650 | |||
| 1651 | static int mtk_start_dma(struct mtk_eth *eth) | ||
| 1652 | { | ||
| 1653 | unsigned long flags; | ||
| 1654 | u32 val; | ||
| 1655 | int err; | ||
| 1656 | |||
| 1657 | if (eth->soc->dma_type == MTK_PDMA) | ||
| 1658 | err = mtk_pdma_init(eth); | ||
| 1659 | else if (eth->soc->dma_type == MTK_QDMA) | ||
| 1660 | err = mtk_qdma_init(eth, 0); | ||
| 1661 | else | ||
| 1662 | err = mtk_pdma_qdma_init(eth); | ||
| 1663 | if (err) { | ||
| 1664 | mtk_dma_free(eth); | ||
| 1665 | return err; | ||
| 1666 | } | ||
| 1667 | |||
| 1668 | spin_lock_irqsave(ð->page_lock, flags); | ||
| 1669 | |||
| 1670 | val = MTK_TX_WB_DDONE | MTK_RX_DMA_EN | MTK_TX_DMA_EN; | ||
| 1671 | if (eth->soc->rx_2b_offset) | ||
| 1672 | val |= MTK_RX_2B_OFFSET; | ||
| 1673 | val |= eth->soc->pdma_glo_cfg; | ||
| 1674 | |||
| 1675 | if (eth->soc->dma_type & MTK_PDMA) | ||
| 1676 | mtk_reg_w32(eth, val, MTK_REG_PDMA_GLO_CFG); | ||
| 1677 | |||
| 1678 | if (eth->soc->dma_type & MTK_QDMA) | ||
| 1679 | mtk_w32(eth, val, MTK_QDMA_GLO_CFG); | ||
| 1680 | |||
| 1681 | spin_unlock_irqrestore(ð->page_lock, flags); | ||
| 1682 | |||
| 1683 | return 0; | ||
| 1684 | } | ||
| 1685 | |||
| 1686 | static int mtk_open(struct net_device *dev) | ||
| 1687 | { | ||
| 1688 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 1689 | struct mtk_eth *eth = mac->hw; | ||
| 1690 | |||
| 1691 | dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); | ||
| 1692 | |||
| 1693 | if (!atomic_read(ð->dma_refcnt)) { | ||
| 1694 | int err = mtk_start_dma(eth); | ||
| 1695 | |||
| 1696 | if (err) | ||
| 1697 | return err; | ||
| 1698 | |||
| 1699 | napi_enable(ð->rx_napi); | ||
| 1700 | mtk_irq_enable(eth, eth->soc->tx_int | eth->soc->rx_int); | ||
| 1701 | } | ||
| 1702 | atomic_inc(ð->dma_refcnt); | ||
| 1703 | |||
| 1704 | if (eth->phy) | ||
| 1705 | eth->phy->start(mac); | ||
| 1706 | |||
| 1707 | if (eth->soc->has_carrier && eth->soc->has_carrier(eth)) | ||
| 1708 | netif_carrier_on(dev); | ||
| 1709 | |||
| 1710 | netif_start_queue(dev); | ||
| 1711 | eth->soc->fwd_config(eth); | ||
| 1712 | |||
| 1713 | return 0; | ||
| 1714 | } | ||
| 1715 | |||
| 1716 | static void mtk_stop_dma(struct mtk_eth *eth, u32 glo_cfg) | ||
| 1717 | { | ||
| 1718 | unsigned long flags; | ||
| 1719 | u32 val; | ||
| 1720 | int i; | ||
| 1721 | |||
| 1722 | /* stop the dma enfine */ | ||
| 1723 | spin_lock_irqsave(ð->page_lock, flags); | ||
| 1724 | val = mtk_r32(eth, glo_cfg); | ||
| 1725 | mtk_w32(eth, val & ~(MTK_TX_WB_DDONE | MTK_RX_DMA_EN | MTK_TX_DMA_EN), | ||
| 1726 | glo_cfg); | ||
| 1727 | spin_unlock_irqrestore(ð->page_lock, flags); | ||
| 1728 | |||
| 1729 | /* wait for dma stop */ | ||
| 1730 | for (i = 0; i < 10; i++) { | ||
| 1731 | val = mtk_r32(eth, glo_cfg); | ||
| 1732 | if (val & (MTK_TX_DMA_BUSY | MTK_RX_DMA_BUSY)) { | ||
| 1733 | msleep(20); | ||
| 1734 | continue; | ||
| 1735 | } | ||
| 1736 | break; | ||
| 1737 | } | ||
| 1738 | } | ||
| 1739 | |||
| 1740 | static int mtk_stop(struct net_device *dev) | ||
| 1741 | { | ||
| 1742 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 1743 | struct mtk_eth *eth = mac->hw; | ||
| 1744 | |||
| 1745 | netif_tx_disable(dev); | ||
| 1746 | if (eth->phy) | ||
| 1747 | eth->phy->stop(mac); | ||
| 1748 | |||
| 1749 | if (!atomic_dec_and_test(ð->dma_refcnt)) | ||
| 1750 | return 0; | ||
| 1751 | |||
| 1752 | mtk_irq_disable(eth, eth->soc->tx_int | eth->soc->rx_int); | ||
| 1753 | napi_disable(ð->rx_napi); | ||
| 1754 | |||
| 1755 | if (eth->soc->dma_type & MTK_PDMA) | ||
| 1756 | mtk_stop_dma(eth, mtk_reg_table[MTK_REG_PDMA_GLO_CFG]); | ||
| 1757 | |||
| 1758 | if (eth->soc->dma_type & MTK_QDMA) | ||
| 1759 | mtk_stop_dma(eth, MTK_QDMA_GLO_CFG); | ||
| 1760 | |||
| 1761 | mtk_dma_free(eth); | ||
| 1762 | |||
| 1763 | return 0; | ||
| 1764 | } | ||
| 1765 | |||
| 1766 | static int __init mtk_init_hw(struct mtk_eth *eth) | ||
| 1767 | { | ||
| 1768 | int i, err; | ||
| 1769 | |||
| 1770 | eth->soc->reset_fe(eth); | ||
| 1771 | |||
| 1772 | if (eth->soc->switch_init) | ||
| 1773 | if (eth->soc->switch_init(eth)) { | ||
| 1774 | dev_err(eth->dev, "failed to initialize switch core\n"); | ||
| 1775 | return -ENODEV; | ||
| 1776 | } | ||
| 1777 | |||
| 1778 | err = devm_request_irq(eth->dev, eth->irq, mtk_handle_irq, 0, | ||
| 1779 | dev_name(eth->dev), eth); | ||
| 1780 | if (err) | ||
| 1781 | return err; | ||
| 1782 | |||
| 1783 | err = mtk_mdio_init(eth); | ||
| 1784 | if (err) | ||
| 1785 | return err; | ||
| 1786 | |||
| 1787 | /* disable delay and normal interrupt */ | ||
| 1788 | mtk_reg_w32(eth, 0, MTK_REG_DLY_INT_CFG); | ||
| 1789 | if (eth->soc->dma_type & MTK_QDMA) | ||
| 1790 | mtk_w32(eth, 0, MTK_QDMA_DELAY_INT); | ||
| 1791 | mtk_irq_disable(eth, eth->soc->tx_int | eth->soc->rx_int); | ||
| 1792 | |||
| 1793 | /* frame engine will push VLAN tag regarding to VIDX field in Tx desc */ | ||
| 1794 | if (mtk_reg_table[MTK_REG_MTK_DMA_VID_BASE]) | ||
| 1795 | for (i = 0; i < 16; i += 2) | ||
| 1796 | mtk_w32(eth, ((i + 1) << 16) + i, | ||
| 1797 | mtk_reg_table[MTK_REG_MTK_DMA_VID_BASE] + | ||
| 1798 | (i * 2)); | ||
| 1799 | |||
| 1800 | if (eth->soc->fwd_config(eth)) | ||
| 1801 | dev_err(eth->dev, "unable to get clock\n"); | ||
| 1802 | |||
| 1803 | if (mtk_reg_table[MTK_REG_MTK_RST_GL]) { | ||
| 1804 | mtk_reg_w32(eth, 1, MTK_REG_MTK_RST_GL); | ||
| 1805 | mtk_reg_w32(eth, 0, MTK_REG_MTK_RST_GL); | ||
| 1806 | } | ||
| 1807 | |||
| 1808 | return 0; | ||
| 1809 | } | ||
| 1810 | |||
| 1811 | static int __init mtk_init(struct net_device *dev) | ||
| 1812 | { | ||
| 1813 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 1814 | struct mtk_eth *eth = mac->hw; | ||
| 1815 | struct device_node *port; | ||
| 1816 | const char *mac_addr; | ||
| 1817 | int err; | ||
| 1818 | |||
| 1819 | mac_addr = of_get_mac_address(mac->of_node); | ||
| 1820 | if (mac_addr) | ||
| 1821 | ether_addr_copy(dev->dev_addr, mac_addr); | ||
| 1822 | |||
| 1823 | /* If the mac address is invalid, use random mac address */ | ||
| 1824 | if (!is_valid_ether_addr(dev->dev_addr)) { | ||
| 1825 | eth_hw_addr_random(dev); | ||
| 1826 | dev_err(eth->dev, "generated random MAC address %pM\n", | ||
| 1827 | dev->dev_addr); | ||
| 1828 | } | ||
| 1829 | mac->hw->soc->set_mac(mac, dev->dev_addr); | ||
| 1830 | |||
| 1831 | if (eth->soc->port_init) | ||
| 1832 | for_each_child_of_node(mac->of_node, port) | ||
| 1833 | if (of_device_is_compatible(port, | ||
| 1834 | "mediatek,eth-port") && | ||
| 1835 | of_device_is_available(port)) | ||
| 1836 | eth->soc->port_init(eth, mac, port); | ||
| 1837 | |||
| 1838 | if (eth->phy) { | ||
| 1839 | err = eth->phy->connect(mac); | ||
| 1840 | if (err) | ||
| 1841 | return err; | ||
| 1842 | } | ||
| 1843 | |||
| 1844 | return 0; | ||
| 1845 | } | ||
| 1846 | |||
| 1847 | static void mtk_uninit(struct net_device *dev) | ||
| 1848 | { | ||
| 1849 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 1850 | struct mtk_eth *eth = mac->hw; | ||
| 1851 | |||
| 1852 | if (eth->phy) | ||
| 1853 | eth->phy->disconnect(mac); | ||
| 1854 | mtk_mdio_cleanup(eth); | ||
| 1855 | |||
| 1856 | mtk_irq_disable(eth, ~0); | ||
| 1857 | free_irq(dev->irq, dev); | ||
| 1858 | } | ||
| 1859 | |||
| 1860 | static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | ||
| 1861 | { | ||
| 1862 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 1863 | |||
| 1864 | if (!mac->phy_dev) | ||
| 1865 | return -ENODEV; | ||
| 1866 | |||
| 1867 | switch (cmd) { | ||
| 1868 | case SIOCGMIIPHY: | ||
| 1869 | case SIOCGMIIREG: | ||
| 1870 | case SIOCSMIIREG: | ||
| 1871 | return phy_mii_ioctl(mac->phy_dev, ifr, cmd); | ||
| 1872 | default: | ||
| 1873 | break; | ||
| 1874 | } | ||
| 1875 | |||
| 1876 | return -EOPNOTSUPP; | ||
| 1877 | } | ||
| 1878 | |||
| 1879 | static int mtk_change_mtu(struct net_device *dev, int new_mtu) | ||
| 1880 | { | ||
| 1881 | struct mtk_mac *mac = netdev_priv(dev); | ||
| 1882 | struct mtk_eth *eth = mac->hw; | ||
| 1883 | int frag_size, old_mtu; | ||
| 1884 | u32 fwd_cfg; | ||
| 1885 | |||
| 1886 | if (!eth->soc->jumbo_frame) | ||
| 1887 | return eth_change_mtu(dev, new_mtu); | ||
| 1888 | |||
| 1889 | frag_size = mtk_max_frag_size(new_mtu); | ||
| 1890 | if (new_mtu < 68 || frag_size > PAGE_SIZE) | ||
| 1891 | return -EINVAL; | ||
| 1892 | |||
| 1893 | old_mtu = dev->mtu; | ||
| 1894 | dev->mtu = new_mtu; | ||
| 1895 | |||
| 1896 | /* return early if the buffer sizes will not change */ | ||
| 1897 | if (old_mtu <= ETH_DATA_LEN && new_mtu <= ETH_DATA_LEN) | ||
| 1898 | return 0; | ||
| 1899 | if (old_mtu > ETH_DATA_LEN && new_mtu > ETH_DATA_LEN) | ||
| 1900 | return 0; | ||
| 1901 | |||
| 1902 | if (new_mtu <= ETH_DATA_LEN) | ||
| 1903 | eth->rx_ring[0].frag_size = mtk_max_frag_size(ETH_DATA_LEN); | ||
| 1904 | else | ||
| 1905 | eth->rx_ring[0].frag_size = PAGE_SIZE; | ||
| 1906 | eth->rx_ring[0].rx_buf_size = | ||
| 1907 | mtk_max_buf_size(eth->rx_ring[0].frag_size); | ||
| 1908 | |||
| 1909 | if (!netif_running(dev)) | ||
| 1910 | return 0; | ||
| 1911 | |||
| 1912 | mtk_stop(dev); | ||
| 1913 | fwd_cfg = mtk_r32(eth, MTK_GDMA1_FWD_CFG); | ||
| 1914 | if (new_mtu <= ETH_DATA_LEN) { | ||
| 1915 | fwd_cfg &= ~MTK_GDM1_JMB_EN; | ||
| 1916 | } else { | ||
| 1917 | fwd_cfg &= ~(MTK_GDM1_JMB_LEN_MASK << MTK_GDM1_JMB_LEN_SHIFT); | ||
| 1918 | fwd_cfg |= (DIV_ROUND_UP(frag_size, 1024) << | ||
| 1919 | MTK_GDM1_JMB_LEN_SHIFT) | MTK_GDM1_JMB_EN; | ||
| 1920 | } | ||
| 1921 | mtk_w32(eth, fwd_cfg, MTK_GDMA1_FWD_CFG); | ||
| 1922 | |||
| 1923 | return mtk_open(dev); | ||
| 1924 | } | ||
| 1925 | |||
| 1926 | static void mtk_pending_work(struct work_struct *work) | ||
| 1927 | { | ||
| 1928 | struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work); | ||
| 1929 | struct mtk_eth *eth = mac->hw; | ||
| 1930 | struct net_device *dev = eth->netdev[mac->id]; | ||
| 1931 | int err; | ||
| 1932 | |||
| 1933 | rtnl_lock(); | ||
| 1934 | mtk_stop(dev); | ||
| 1935 | |||
| 1936 | err = mtk_open(dev); | ||
| 1937 | if (err) { | ||
| 1938 | netif_alert(eth, ifup, dev, | ||
| 1939 | "Driver up/down cycle failed, closing device.\n"); | ||
| 1940 | dev_close(dev); | ||
| 1941 | } | ||
| 1942 | rtnl_unlock(); | ||
| 1943 | } | ||
| 1944 | |||
| 1945 | static int mtk_cleanup(struct mtk_eth *eth) | ||
| 1946 | { | ||
| 1947 | int i; | ||
| 1948 | |||
| 1949 | for (i = 0; i < eth->soc->mac_count; i++) { | ||
| 1950 | struct mtk_mac *mac = netdev_priv(eth->netdev[i]); | ||
| 1951 | |||
| 1952 | if (!eth->netdev[i]) | ||
| 1953 | continue; | ||
| 1954 | |||
| 1955 | unregister_netdev(eth->netdev[i]); | ||
| 1956 | free_netdev(eth->netdev[i]); | ||
| 1957 | cancel_work_sync(&mac->pending_work); | ||
| 1958 | } | ||
| 1959 | |||
| 1960 | return 0; | ||
| 1961 | } | ||
| 1962 | |||
| 1963 | static const struct net_device_ops mtk_netdev_ops = { | ||
| 1964 | .ndo_init = mtk_init, | ||
| 1965 | .ndo_uninit = mtk_uninit, | ||
| 1966 | .ndo_open = mtk_open, | ||
| 1967 | .ndo_stop = mtk_stop, | ||
| 1968 | .ndo_start_xmit = mtk_start_xmit, | ||
| 1969 | .ndo_set_mac_address = mtk_set_mac_address, | ||
| 1970 | .ndo_validate_addr = eth_validate_addr, | ||
| 1971 | .ndo_do_ioctl = mtk_do_ioctl, | ||
| 1972 | .ndo_change_mtu = mtk_change_mtu, | ||
| 1973 | .ndo_tx_timeout = mtk_tx_timeout, | ||
| 1974 | .ndo_get_stats64 = mtk_get_stats64, | ||
| 1975 | .ndo_vlan_rx_add_vid = mtk_vlan_rx_add_vid, | ||
| 1976 | .ndo_vlan_rx_kill_vid = mtk_vlan_rx_kill_vid, | ||
| 1977 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
| 1978 | .ndo_poll_controller = mtk_poll_controller, | ||
| 1979 | #endif | ||
| 1980 | }; | ||
| 1981 | |||
| 1982 | static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) | ||
| 1983 | { | ||
| 1984 | struct mtk_mac *mac; | ||
| 1985 | const __be32 *_id = of_get_property(np, "reg", NULL); | ||
| 1986 | int id, err; | ||
| 1987 | |||
| 1988 | if (!_id) { | ||
| 1989 | dev_err(eth->dev, "missing mac id\n"); | ||
| 1990 | return -EINVAL; | ||
| 1991 | } | ||
| 1992 | id = be32_to_cpup(_id); | ||
| 1993 | if (id >= eth->soc->mac_count || eth->netdev[id]) { | ||
| 1994 | dev_err(eth->dev, "%d is not a valid mac id\n", id); | ||
| 1995 | return -EINVAL; | ||
| 1996 | } | ||
| 1997 | |||
| 1998 | eth->netdev[id] = alloc_etherdev(sizeof(*mac)); | ||
| 1999 | if (!eth->netdev[id]) { | ||
| 2000 | dev_err(eth->dev, "alloc_etherdev failed\n"); | ||
| 2001 | return -ENOMEM; | ||
| 2002 | } | ||
| 2003 | mac = netdev_priv(eth->netdev[id]); | ||
| 2004 | eth->mac[id] = mac; | ||
| 2005 | mac->id = id; | ||
| 2006 | mac->hw = eth; | ||
| 2007 | mac->of_node = np; | ||
| 2008 | INIT_WORK(&mac->pending_work, mtk_pending_work); | ||
| 2009 | |||
| 2010 | if (mtk_reg_table[MTK_REG_MTK_COUNTER_BASE]) { | ||
| 2011 | mac->hw_stats = devm_kzalloc(eth->dev, | ||
| 2012 | sizeof(*mac->hw_stats), | ||
| 2013 | GFP_KERNEL); | ||
| 2014 | if (!mac->hw_stats) { | ||
| 2015 | err = -ENOMEM; | ||
| 2016 | goto free_netdev; | ||
| 2017 | } | ||
| 2018 | spin_lock_init(&mac->hw_stats->stats_lock); | ||
| 2019 | mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET; | ||
| 2020 | } | ||
| 2021 | |||
| 2022 | SET_NETDEV_DEV(eth->netdev[id], eth->dev); | ||
| 2023 | eth->netdev[id]->netdev_ops = &mtk_netdev_ops; | ||
| 2024 | eth->netdev[id]->base_addr = (unsigned long)eth->base; | ||
| 2025 | |||
| 2026 | if (eth->soc->init_data) | ||
| 2027 | eth->soc->init_data(eth->soc, eth->netdev[id]); | ||
| 2028 | |||
| 2029 | eth->netdev[id]->vlan_features = eth->soc->hw_features & | ||
| 2030 | ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX); | ||
| 2031 | eth->netdev[id]->features |= eth->soc->hw_features; | ||
| 2032 | |||
| 2033 | if (mtk_reg_table[MTK_REG_MTK_DMA_VID_BASE]) | ||
| 2034 | eth->netdev[id]->features |= NETIF_F_HW_VLAN_CTAG_FILTER; | ||
| 2035 | |||
| 2036 | mtk_set_ethtool_ops(eth->netdev[id]); | ||
| 2037 | |||
| 2038 | err = register_netdev(eth->netdev[id]); | ||
| 2039 | if (err) { | ||
| 2040 | dev_err(eth->dev, "error bringing up device\n"); | ||
| 2041 | err = -ENOMEM; | ||
| 2042 | goto free_netdev; | ||
| 2043 | } | ||
| 2044 | eth->netdev[id]->irq = eth->irq; | ||
| 2045 | netif_info(eth, probe, eth->netdev[id], | ||
| 2046 | "mediatek frame engine at 0x%08lx, irq %d\n", | ||
| 2047 | eth->netdev[id]->base_addr, eth->netdev[id]->irq); | ||
| 2048 | |||
| 2049 | return 0; | ||
| 2050 | |||
| 2051 | free_netdev: | ||
| 2052 | free_netdev(eth->netdev[id]); | ||
| 2053 | return err; | ||
| 2054 | } | ||
| 2055 | |||
| 2056 | static int mtk_probe(struct platform_device *pdev) | ||
| 2057 | { | ||
| 2058 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 2059 | const struct of_device_id *match; | ||
| 2060 | struct device_node *mac_np; | ||
| 2061 | struct mtk_soc_data *soc; | ||
| 2062 | struct mtk_eth *eth; | ||
| 2063 | struct clk *sysclk; | ||
| 2064 | int err; | ||
| 2065 | |||
| 2066 | device_reset(&pdev->dev); | ||
| 2067 | |||
| 2068 | match = of_match_device(of_mtk_match, &pdev->dev); | ||
| 2069 | soc = (struct mtk_soc_data *)match->data; | ||
| 2070 | |||
| 2071 | if (soc->reg_table) | ||
| 2072 | mtk_reg_table = soc->reg_table; | ||
| 2073 | |||
| 2074 | eth = devm_kzalloc(&pdev->dev, sizeof(*eth), GFP_KERNEL); | ||
| 2075 | if (!eth) | ||
| 2076 | return -ENOMEM; | ||
| 2077 | |||
| 2078 | eth->base = devm_ioremap_resource(&pdev->dev, res); | ||
| 2079 | if (IS_ERR(eth->base)) | ||
| 2080 | return PTR_ERR(eth->base); | ||
| 2081 | |||
| 2082 | spin_lock_init(ð->page_lock); | ||
| 2083 | |||
| 2084 | eth->ethsys = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, | ||
| 2085 | "mediatek,ethsys"); | ||
| 2086 | if (IS_ERR(eth->ethsys)) | ||
| 2087 | return PTR_ERR(eth->ethsys); | ||
| 2088 | |||
| 2089 | eth->irq = platform_get_irq(pdev, 0); | ||
| 2090 | if (eth->irq < 0) { | ||
| 2091 | dev_err(&pdev->dev, "no IRQ resource found\n"); | ||
| 2092 | return -ENXIO; | ||
| 2093 | } | ||
| 2094 | |||
| 2095 | sysclk = devm_clk_get(&pdev->dev, NULL); | ||
| 2096 | if (IS_ERR(sysclk)) { | ||
| 2097 | dev_err(&pdev->dev, | ||
| 2098 | "the clock is not defined in the devicetree\n"); | ||
| 2099 | return -ENXIO; | ||
| 2100 | } | ||
| 2101 | eth->sysclk = clk_get_rate(sysclk); | ||
| 2102 | |||
| 2103 | eth->switch_np = of_parse_phandle(pdev->dev.of_node, | ||
| 2104 | "mediatek,switch", 0); | ||
| 2105 | if (soc->has_switch && !eth->switch_np) { | ||
| 2106 | dev_err(&pdev->dev, "failed to read switch phandle\n"); | ||
| 2107 | return -ENODEV; | ||
| 2108 | } | ||
| 2109 | |||
| 2110 | eth->dev = &pdev->dev; | ||
| 2111 | eth->soc = soc; | ||
| 2112 | eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE); | ||
| 2113 | |||
| 2114 | err = mtk_init_hw(eth); | ||
| 2115 | if (err) | ||
| 2116 | return err; | ||
| 2117 | |||
| 2118 | if (eth->soc->mac_count > 1) { | ||
| 2119 | for_each_child_of_node(pdev->dev.of_node, mac_np) { | ||
| 2120 | if (!of_device_is_compatible(mac_np, | ||
| 2121 | "mediatek,eth-mac")) | ||
| 2122 | continue; | ||
| 2123 | |||
| 2124 | if (!of_device_is_available(mac_np)) | ||
| 2125 | continue; | ||
| 2126 | |||
| 2127 | err = mtk_add_mac(eth, mac_np); | ||
| 2128 | if (err) | ||
| 2129 | goto err_free_dev; | ||
| 2130 | } | ||
| 2131 | |||
| 2132 | init_dummy_netdev(ð->dummy_dev); | ||
| 2133 | netif_napi_add(ð->dummy_dev, ð->rx_napi, mtk_poll, | ||
| 2134 | soc->napi_weight); | ||
| 2135 | } else { | ||
| 2136 | err = mtk_add_mac(eth, pdev->dev.of_node); | ||
| 2137 | if (err) | ||
| 2138 | goto err_free_dev; | ||
| 2139 | netif_napi_add(eth->netdev[0], ð->rx_napi, mtk_poll, | ||
| 2140 | soc->napi_weight); | ||
| 2141 | } | ||
| 2142 | |||
| 2143 | platform_set_drvdata(pdev, eth); | ||
| 2144 | |||
| 2145 | return 0; | ||
| 2146 | |||
| 2147 | err_free_dev: | ||
| 2148 | mtk_cleanup(eth); | ||
| 2149 | return err; | ||
| 2150 | } | ||
| 2151 | |||
| 2152 | static int mtk_remove(struct platform_device *pdev) | ||
| 2153 | { | ||
| 2154 | struct mtk_eth *eth = platform_get_drvdata(pdev); | ||
| 2155 | |||
| 2156 | netif_napi_del(ð->rx_napi); | ||
| 2157 | mtk_cleanup(eth); | ||
| 2158 | platform_set_drvdata(pdev, NULL); | ||
| 2159 | |||
| 2160 | return 0; | ||
| 2161 | } | ||
| 2162 | |||
| 2163 | static struct platform_driver mtk_driver = { | ||
| 2164 | .probe = mtk_probe, | ||
| 2165 | .remove = mtk_remove, | ||
| 2166 | .driver = { | ||
| 2167 | .name = "mtk_soc_eth", | ||
| 2168 | .of_match_table = of_mtk_match, | ||
| 2169 | }, | ||
| 2170 | }; | ||
| 2171 | |||
| 2172 | module_platform_driver(mtk_driver); | ||
| 2173 | |||
| 2174 | MODULE_LICENSE("GPL"); | ||
| 2175 | MODULE_AUTHOR("John Crispin <blogic@openwrt.org>"); | ||
| 2176 | MODULE_DESCRIPTION("Ethernet driver for MediaTek SoC"); | ||
diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.h b/drivers/staging/mt7621-eth/mtk_eth_soc.h deleted file mode 100644 index e6ed80433f49..000000000000 --- a/drivers/staging/mt7621-eth/mtk_eth_soc.h +++ /dev/null | |||
| @@ -1,716 +0,0 @@ | |||
| 1 | /* This program is free software; you can redistribute it and/or modify | ||
| 2 | * it under the terms of the GNU General Public License as published by | ||
| 3 | * the Free Software Foundation; version 2 of the License | ||
| 4 | * | ||
| 5 | * This program is distributed in the hope that it will be useful, | ||
| 6 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 7 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 8 | * GNU General Public License for more details. | ||
| 9 | * | ||
| 10 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 11 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 12 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef MTK_ETH_H | ||
| 16 | #define MTK_ETH_H | ||
| 17 | |||
| 18 | #include <linux/mii.h> | ||
| 19 | #include <linux/interrupt.h> | ||
| 20 | #include <linux/netdevice.h> | ||
| 21 | #include <linux/dma-mapping.h> | ||
| 22 | #include <linux/phy.h> | ||
| 23 | #include <linux/ethtool.h> | ||
| 24 | #include <linux/version.h> | ||
| 25 | #include <linux/atomic.h> | ||
| 26 | |||
| 27 | /* these registers have different offsets depending on the SoC. we use a lookup | ||
| 28 | * table for these | ||
| 29 | */ | ||
| 30 | enum mtk_reg { | ||
| 31 | MTK_REG_PDMA_GLO_CFG = 0, | ||
| 32 | MTK_REG_PDMA_RST_CFG, | ||
| 33 | MTK_REG_DLY_INT_CFG, | ||
| 34 | MTK_REG_TX_BASE_PTR0, | ||
| 35 | MTK_REG_TX_MAX_CNT0, | ||
| 36 | MTK_REG_TX_CTX_IDX0, | ||
| 37 | MTK_REG_TX_DTX_IDX0, | ||
| 38 | MTK_REG_RX_BASE_PTR0, | ||
| 39 | MTK_REG_RX_MAX_CNT0, | ||
| 40 | MTK_REG_RX_CALC_IDX0, | ||
| 41 | MTK_REG_RX_DRX_IDX0, | ||
| 42 | MTK_REG_MTK_INT_ENABLE, | ||
| 43 | MTK_REG_MTK_INT_STATUS, | ||
| 44 | MTK_REG_MTK_DMA_VID_BASE, | ||
| 45 | MTK_REG_MTK_COUNTER_BASE, | ||
| 46 | MTK_REG_MTK_RST_GL, | ||
| 47 | MTK_REG_MTK_INT_STATUS2, | ||
| 48 | MTK_REG_COUNT | ||
| 49 | }; | ||
| 50 | |||
| 51 | /* delayed interrupt bits */ | ||
| 52 | #define MTK_DELAY_EN_INT 0x80 | ||
| 53 | #define MTK_DELAY_MAX_INT 0x04 | ||
| 54 | #define MTK_DELAY_MAX_TOUT 0x04 | ||
| 55 | #define MTK_DELAY_TIME 20 | ||
| 56 | #define MTK_DELAY_CHAN (((MTK_DELAY_EN_INT | MTK_DELAY_MAX_INT) << 8) \ | ||
| 57 | | MTK_DELAY_MAX_TOUT) | ||
| 58 | #define MTK_DELAY_INIT ((MTK_DELAY_CHAN << 16) | MTK_DELAY_CHAN) | ||
| 59 | #define MTK_PSE_FQFC_CFG_INIT 0x80504000 | ||
| 60 | #define MTK_PSE_FQFC_CFG_256Q 0xff908000 | ||
| 61 | |||
| 62 | /* interrupt bits */ | ||
| 63 | #define MTK_CNT_PPE_AF BIT(31) | ||
| 64 | #define MTK_CNT_GDM_AF BIT(29) | ||
| 65 | #define MTK_PSE_P2_FC BIT(26) | ||
| 66 | #define MTK_PSE_BUF_DROP BIT(24) | ||
| 67 | #define MTK_GDM_OTHER_DROP BIT(23) | ||
| 68 | #define MTK_PSE_P1_FC BIT(22) | ||
| 69 | #define MTK_PSE_P0_FC BIT(21) | ||
| 70 | #define MTK_PSE_FQ_EMPTY BIT(20) | ||
| 71 | #define MTK_GE1_STA_CHG BIT(18) | ||
| 72 | #define MTK_TX_COHERENT BIT(17) | ||
| 73 | #define MTK_RX_COHERENT BIT(16) | ||
| 74 | #define MTK_TX_DONE_INT3 BIT(11) | ||
| 75 | #define MTK_TX_DONE_INT2 BIT(10) | ||
| 76 | #define MTK_TX_DONE_INT1 BIT(9) | ||
| 77 | #define MTK_TX_DONE_INT0 BIT(8) | ||
| 78 | #define MTK_RX_DONE_INT0 BIT(2) | ||
| 79 | #define MTK_TX_DLY_INT BIT(1) | ||
| 80 | #define MTK_RX_DLY_INT BIT(0) | ||
| 81 | |||
| 82 | #define MTK_RX_DONE_INT MTK_RX_DONE_INT0 | ||
| 83 | #define MTK_TX_DONE_INT (MTK_TX_DONE_INT0 | MTK_TX_DONE_INT1 | \ | ||
| 84 | MTK_TX_DONE_INT2 | MTK_TX_DONE_INT3) | ||
| 85 | |||
| 86 | #define RT5350_RX_DLY_INT BIT(30) | ||
| 87 | #define RT5350_TX_DLY_INT BIT(28) | ||
| 88 | #define RT5350_RX_DONE_INT1 BIT(17) | ||
| 89 | #define RT5350_RX_DONE_INT0 BIT(16) | ||
| 90 | #define RT5350_TX_DONE_INT3 BIT(3) | ||
| 91 | #define RT5350_TX_DONE_INT2 BIT(2) | ||
| 92 | #define RT5350_TX_DONE_INT1 BIT(1) | ||
| 93 | #define RT5350_TX_DONE_INT0 BIT(0) | ||
| 94 | |||
| 95 | #define RT5350_RX_DONE_INT (RT5350_RX_DONE_INT0 | RT5350_RX_DONE_INT1) | ||
| 96 | #define RT5350_TX_DONE_INT (RT5350_TX_DONE_INT0 | RT5350_TX_DONE_INT1 | \ | ||
| 97 | RT5350_TX_DONE_INT2 | RT5350_TX_DONE_INT3) | ||
| 98 | |||
| 99 | /* registers */ | ||
| 100 | #define MTK_GDMA_OFFSET 0x0020 | ||
| 101 | #define MTK_PSE_OFFSET 0x0040 | ||
| 102 | #define MTK_GDMA2_OFFSET 0x0060 | ||
| 103 | #define MTK_CDMA_OFFSET 0x0080 | ||
| 104 | #define MTK_DMA_VID0 0x00a8 | ||
| 105 | #define MTK_PDMA_OFFSET 0x0100 | ||
| 106 | #define MTK_PPE_OFFSET 0x0200 | ||
| 107 | #define MTK_CMTABLE_OFFSET 0x0400 | ||
| 108 | #define MTK_POLICYTABLE_OFFSET 0x1000 | ||
| 109 | |||
| 110 | #define MT7621_GDMA_OFFSET 0x0500 | ||
| 111 | #define MT7620_GDMA_OFFSET 0x0600 | ||
| 112 | |||
| 113 | #define RT5350_PDMA_OFFSET 0x0800 | ||
| 114 | #define RT5350_SDM_OFFSET 0x0c00 | ||
| 115 | |||
| 116 | #define MTK_MDIO_ACCESS 0x00 | ||
| 117 | #define MTK_MDIO_CFG 0x04 | ||
| 118 | #define MTK_GLO_CFG 0x08 | ||
| 119 | #define MTK_RST_GL 0x0C | ||
| 120 | #define MTK_INT_STATUS 0x10 | ||
| 121 | #define MTK_INT_ENABLE 0x14 | ||
| 122 | #define MTK_MDIO_CFG2 0x18 | ||
| 123 | #define MTK_FOC_TS_T 0x1C | ||
| 124 | |||
| 125 | #define MTK_GDMA1_FWD_CFG (MTK_GDMA_OFFSET + 0x00) | ||
| 126 | #define MTK_GDMA1_SCH_CFG (MTK_GDMA_OFFSET + 0x04) | ||
| 127 | #define MTK_GDMA1_SHPR_CFG (MTK_GDMA_OFFSET + 0x08) | ||
| 128 | #define MTK_GDMA1_MAC_ADRL (MTK_GDMA_OFFSET + 0x0C) | ||
| 129 | #define MTK_GDMA1_MAC_ADRH (MTK_GDMA_OFFSET + 0x10) | ||
| 130 | |||
| 131 | #define MTK_GDMA2_FWD_CFG (MTK_GDMA2_OFFSET + 0x00) | ||
| 132 | #define MTK_GDMA2_SCH_CFG (MTK_GDMA2_OFFSET + 0x04) | ||
| 133 | #define MTK_GDMA2_SHPR_CFG (MTK_GDMA2_OFFSET + 0x08) | ||
| 134 | #define MTK_GDMA2_MAC_ADRL (MTK_GDMA2_OFFSET + 0x0C) | ||
| 135 | #define MTK_GDMA2_MAC_ADRH (MTK_GDMA2_OFFSET + 0x10) | ||
| 136 | |||
| 137 | #define MTK_PSE_FQ_CFG (MTK_PSE_OFFSET + 0x00) | ||
| 138 | #define MTK_CDMA_FC_CFG (MTK_PSE_OFFSET + 0x04) | ||
| 139 | #define MTK_GDMA1_FC_CFG (MTK_PSE_OFFSET + 0x08) | ||
| 140 | #define MTK_GDMA2_FC_CFG (MTK_PSE_OFFSET + 0x0C) | ||
| 141 | |||
| 142 | #define MTK_CDMA_CSG_CFG (MTK_CDMA_OFFSET + 0x00) | ||
| 143 | #define MTK_CDMA_SCH_CFG (MTK_CDMA_OFFSET + 0x04) | ||
| 144 | |||
| 145 | #define MT7621_GDMA_FWD_CFG(x) (MT7621_GDMA_OFFSET + (x * 0x1000)) | ||
| 146 | |||
| 147 | /* FIXME this might be different for different SOCs */ | ||
| 148 | #define MT7620_GDMA1_FWD_CFG (MT7621_GDMA_OFFSET + 0x00) | ||
| 149 | |||
| 150 | #define RT5350_TX_BASE_PTR0 (RT5350_PDMA_OFFSET + 0x00) | ||
| 151 | #define RT5350_TX_MAX_CNT0 (RT5350_PDMA_OFFSET + 0x04) | ||
| 152 | #define RT5350_TX_CTX_IDX0 (RT5350_PDMA_OFFSET + 0x08) | ||
| 153 | #define RT5350_TX_DTX_IDX0 (RT5350_PDMA_OFFSET + 0x0C) | ||
| 154 | #define RT5350_TX_BASE_PTR1 (RT5350_PDMA_OFFSET + 0x10) | ||
| 155 | #define RT5350_TX_MAX_CNT1 (RT5350_PDMA_OFFSET + 0x14) | ||
| 156 | #define RT5350_TX_CTX_IDX1 (RT5350_PDMA_OFFSET + 0x18) | ||
| 157 | #define RT5350_TX_DTX_IDX1 (RT5350_PDMA_OFFSET + 0x1C) | ||
| 158 | #define RT5350_TX_BASE_PTR2 (RT5350_PDMA_OFFSET + 0x20) | ||
| 159 | #define RT5350_TX_MAX_CNT2 (RT5350_PDMA_OFFSET + 0x24) | ||
| 160 | #define RT5350_TX_CTX_IDX2 (RT5350_PDMA_OFFSET + 0x28) | ||
| 161 | #define RT5350_TX_DTX_IDX2 (RT5350_PDMA_OFFSET + 0x2C) | ||
| 162 | #define RT5350_TX_BASE_PTR3 (RT5350_PDMA_OFFSET + 0x30) | ||
| 163 | #define RT5350_TX_MAX_CNT3 (RT5350_PDMA_OFFSET + 0x34) | ||
| 164 | #define RT5350_TX_CTX_IDX3 (RT5350_PDMA_OFFSET + 0x38) | ||
| 165 | #define RT5350_TX_DTX_IDX3 (RT5350_PDMA_OFFSET + 0x3C) | ||
| 166 | #define RT5350_RX_BASE_PTR0 (RT5350_PDMA_OFFSET + 0x100) | ||
| 167 | #define RT5350_RX_MAX_CNT0 (RT5350_PDMA_OFFSET + 0x104) | ||
| 168 | #define RT5350_RX_CALC_IDX0 (RT5350_PDMA_OFFSET + 0x108) | ||
| 169 | #define RT5350_RX_DRX_IDX0 (RT5350_PDMA_OFFSET + 0x10C) | ||
| 170 | #define RT5350_RX_BASE_PTR1 (RT5350_PDMA_OFFSET + 0x110) | ||
| 171 | #define RT5350_RX_MAX_CNT1 (RT5350_PDMA_OFFSET + 0x114) | ||
| 172 | #define RT5350_RX_CALC_IDX1 (RT5350_PDMA_OFFSET + 0x118) | ||
| 173 | #define RT5350_RX_DRX_IDX1 (RT5350_PDMA_OFFSET + 0x11C) | ||
| 174 | #define RT5350_PDMA_GLO_CFG (RT5350_PDMA_OFFSET + 0x204) | ||
| 175 | #define RT5350_PDMA_RST_CFG (RT5350_PDMA_OFFSET + 0x208) | ||
| 176 | #define RT5350_DLY_INT_CFG (RT5350_PDMA_OFFSET + 0x20c) | ||
| 177 | #define RT5350_MTK_INT_STATUS (RT5350_PDMA_OFFSET + 0x220) | ||
| 178 | #define RT5350_MTK_INT_ENABLE (RT5350_PDMA_OFFSET + 0x228) | ||
| 179 | #define RT5350_PDMA_SCH_CFG (RT5350_PDMA_OFFSET + 0x280) | ||
| 180 | |||
| 181 | #define MTK_PDMA_GLO_CFG (MTK_PDMA_OFFSET + 0x00) | ||
| 182 | #define MTK_PDMA_RST_CFG (MTK_PDMA_OFFSET + 0x04) | ||
| 183 | #define MTK_PDMA_SCH_CFG (MTK_PDMA_OFFSET + 0x08) | ||
| 184 | #define MTK_DLY_INT_CFG (MTK_PDMA_OFFSET + 0x0C) | ||
| 185 | #define MTK_TX_BASE_PTR0 (MTK_PDMA_OFFSET + 0x10) | ||
| 186 | #define MTK_TX_MAX_CNT0 (MTK_PDMA_OFFSET + 0x14) | ||
| 187 | #define MTK_TX_CTX_IDX0 (MTK_PDMA_OFFSET + 0x18) | ||
| 188 | #define MTK_TX_DTX_IDX0 (MTK_PDMA_OFFSET + 0x1C) | ||
| 189 | #define MTK_TX_BASE_PTR1 (MTK_PDMA_OFFSET + 0x20) | ||
| 190 | #define MTK_TX_MAX_CNT1 (MTK_PDMA_OFFSET + 0x24) | ||
| 191 | #define MTK_TX_CTX_IDX1 (MTK_PDMA_OFFSET + 0x28) | ||
| 192 | #define MTK_TX_DTX_IDX1 (MTK_PDMA_OFFSET + 0x2C) | ||
| 193 | #define MTK_RX_BASE_PTR0 (MTK_PDMA_OFFSET + 0x30) | ||
| 194 | #define MTK_RX_MAX_CNT0 (MTK_PDMA_OFFSET + 0x34) | ||
| 195 | #define MTK_RX_CALC_IDX0 (MTK_PDMA_OFFSET + 0x38) | ||
| 196 | #define MTK_RX_DRX_IDX0 (MTK_PDMA_OFFSET + 0x3C) | ||
| 197 | #define MTK_TX_BASE_PTR2 (MTK_PDMA_OFFSET + 0x40) | ||
| 198 | #define MTK_TX_MAX_CNT2 (MTK_PDMA_OFFSET + 0x44) | ||
| 199 | #define MTK_TX_CTX_IDX2 (MTK_PDMA_OFFSET + 0x48) | ||
| 200 | #define MTK_TX_DTX_IDX2 (MTK_PDMA_OFFSET + 0x4C) | ||
| 201 | #define MTK_TX_BASE_PTR3 (MTK_PDMA_OFFSET + 0x50) | ||
| 202 | #define MTK_TX_MAX_CNT3 (MTK_PDMA_OFFSET + 0x54) | ||
| 203 | #define MTK_TX_CTX_IDX3 (MTK_PDMA_OFFSET + 0x58) | ||
| 204 | #define MTK_TX_DTX_IDX3 (MTK_PDMA_OFFSET + 0x5C) | ||
| 205 | #define MTK_RX_BASE_PTR1 (MTK_PDMA_OFFSET + 0x60) | ||
| 206 | #define MTK_RX_MAX_CNT1 (MTK_PDMA_OFFSET + 0x64) | ||
| 207 | #define MTK_RX_CALC_IDX1 (MTK_PDMA_OFFSET + 0x68) | ||
| 208 | #define MTK_RX_DRX_IDX1 (MTK_PDMA_OFFSET + 0x6C) | ||
| 209 | |||
| 210 | /* Switch DMA configuration */ | ||
| 211 | #define RT5350_SDM_CFG (RT5350_SDM_OFFSET + 0x00) | ||
| 212 | #define RT5350_SDM_RRING (RT5350_SDM_OFFSET + 0x04) | ||
| 213 | #define RT5350_SDM_TRING (RT5350_SDM_OFFSET + 0x08) | ||
| 214 | #define RT5350_SDM_MAC_ADRL (RT5350_SDM_OFFSET + 0x0C) | ||
| 215 | #define RT5350_SDM_MAC_ADRH (RT5350_SDM_OFFSET + 0x10) | ||
| 216 | #define RT5350_SDM_TPCNT (RT5350_SDM_OFFSET + 0x100) | ||
| 217 | #define RT5350_SDM_TBCNT (RT5350_SDM_OFFSET + 0x104) | ||
| 218 | #define RT5350_SDM_RPCNT (RT5350_SDM_OFFSET + 0x108) | ||
| 219 | #define RT5350_SDM_RBCNT (RT5350_SDM_OFFSET + 0x10C) | ||
| 220 | #define RT5350_SDM_CS_ERR (RT5350_SDM_OFFSET + 0x110) | ||
| 221 | |||
| 222 | #define RT5350_SDM_ICS_EN BIT(16) | ||
| 223 | #define RT5350_SDM_TCS_EN BIT(17) | ||
| 224 | #define RT5350_SDM_UCS_EN BIT(18) | ||
| 225 | |||
| 226 | /* QDMA registers */ | ||
| 227 | #define MTK_QTX_CFG(x) (0x1800 + (x * 0x10)) | ||
| 228 | #define MTK_QTX_SCH(x) (0x1804 + (x * 0x10)) | ||
| 229 | #define MTK_QRX_BASE_PTR0 0x1900 | ||
| 230 | #define MTK_QRX_MAX_CNT0 0x1904 | ||
| 231 | #define MTK_QRX_CRX_IDX0 0x1908 | ||
| 232 | #define MTK_QRX_DRX_IDX0 0x190C | ||
| 233 | #define MTK_QDMA_GLO_CFG 0x1A04 | ||
| 234 | #define MTK_QDMA_RST_IDX 0x1A08 | ||
| 235 | #define MTK_QDMA_DELAY_INT 0x1A0C | ||
| 236 | #define MTK_QDMA_FC_THRES 0x1A10 | ||
| 237 | #define MTK_QMTK_INT_STATUS 0x1A18 | ||
| 238 | #define MTK_QMTK_INT_ENABLE 0x1A1C | ||
| 239 | #define MTK_QDMA_HRED2 0x1A44 | ||
| 240 | |||
| 241 | #define MTK_QTX_CTX_PTR 0x1B00 | ||
| 242 | #define MTK_QTX_DTX_PTR 0x1B04 | ||
| 243 | |||
| 244 | #define MTK_QTX_CRX_PTR 0x1B10 | ||
| 245 | #define MTK_QTX_DRX_PTR 0x1B14 | ||
| 246 | |||
| 247 | #define MTK_QDMA_FQ_HEAD 0x1B20 | ||
| 248 | #define MTK_QDMA_FQ_TAIL 0x1B24 | ||
| 249 | #define MTK_QDMA_FQ_CNT 0x1B28 | ||
| 250 | #define MTK_QDMA_FQ_BLEN 0x1B2C | ||
| 251 | |||
| 252 | #define QDMA_PAGE_SIZE 2048 | ||
| 253 | #define QDMA_TX_OWNER_CPU BIT(31) | ||
| 254 | #define QDMA_TX_SWC BIT(14) | ||
| 255 | #define TX_QDMA_SDL(_x) (((_x) & 0x3fff) << 16) | ||
| 256 | #define QDMA_RES_THRES 4 | ||
| 257 | |||
| 258 | /* MDIO_CFG register bits */ | ||
| 259 | #define MTK_MDIO_CFG_AUTO_POLL_EN BIT(29) | ||
| 260 | #define MTK_MDIO_CFG_GP1_BP_EN BIT(16) | ||
| 261 | #define MTK_MDIO_CFG_GP1_FRC_EN BIT(15) | ||
| 262 | #define MTK_MDIO_CFG_GP1_SPEED_10 (0 << 13) | ||
| 263 | #define MTK_MDIO_CFG_GP1_SPEED_100 (1 << 13) | ||
| 264 | #define MTK_MDIO_CFG_GP1_SPEED_1000 (2 << 13) | ||
| 265 | #define MTK_MDIO_CFG_GP1_DUPLEX BIT(12) | ||
| 266 | #define MTK_MDIO_CFG_GP1_FC_TX BIT(11) | ||
| 267 | #define MTK_MDIO_CFG_GP1_FC_RX BIT(10) | ||
| 268 | #define MTK_MDIO_CFG_GP1_LNK_DWN BIT(9) | ||
| 269 | #define MTK_MDIO_CFG_GP1_AN_FAIL BIT(8) | ||
| 270 | #define MTK_MDIO_CFG_MDC_CLK_DIV_1 (0 << 6) | ||
| 271 | #define MTK_MDIO_CFG_MDC_CLK_DIV_2 (1 << 6) | ||
| 272 | #define MTK_MDIO_CFG_MDC_CLK_DIV_4 (2 << 6) | ||
| 273 | #define MTK_MDIO_CFG_MDC_CLK_DIV_8 (3 << 6) | ||
| 274 | #define MTK_MDIO_CFG_TURBO_MII_FREQ BIT(5) | ||
| 275 | #define MTK_MDIO_CFG_TURBO_MII_MODE BIT(4) | ||
| 276 | #define MTK_MDIO_CFG_RX_CLK_SKEW_0 (0 << 2) | ||
| 277 | #define MTK_MDIO_CFG_RX_CLK_SKEW_200 (1 << 2) | ||
| 278 | #define MTK_MDIO_CFG_RX_CLK_SKEW_400 (2 << 2) | ||
| 279 | #define MTK_MDIO_CFG_RX_CLK_SKEW_INV (3 << 2) | ||
| 280 | #define MTK_MDIO_CFG_TX_CLK_SKEW_0 0 | ||
| 281 | #define MTK_MDIO_CFG_TX_CLK_SKEW_200 1 | ||
| 282 | #define MTK_MDIO_CFG_TX_CLK_SKEW_400 2 | ||
| 283 | #define MTK_MDIO_CFG_TX_CLK_SKEW_INV 3 | ||
| 284 | |||
| 285 | /* uni-cast port */ | ||
| 286 | #define MTK_GDM1_JMB_LEN_MASK 0xf | ||
| 287 | #define MTK_GDM1_JMB_LEN_SHIFT 28 | ||
| 288 | #define MTK_GDM1_ICS_EN BIT(22) | ||
| 289 | #define MTK_GDM1_TCS_EN BIT(21) | ||
| 290 | #define MTK_GDM1_UCS_EN BIT(20) | ||
| 291 | #define MTK_GDM1_JMB_EN BIT(19) | ||
| 292 | #define MTK_GDM1_STRPCRC BIT(16) | ||
| 293 | #define MTK_GDM1_UFRC_P_CPU (0 << 12) | ||
| 294 | #define MTK_GDM1_UFRC_P_GDMA1 (1 << 12) | ||
| 295 | #define MTK_GDM1_UFRC_P_PPE (6 << 12) | ||
| 296 | |||
| 297 | /* checksums */ | ||
| 298 | #define MTK_ICS_GEN_EN BIT(2) | ||
| 299 | #define MTK_UCS_GEN_EN BIT(1) | ||
| 300 | #define MTK_TCS_GEN_EN BIT(0) | ||
| 301 | |||
| 302 | /* dma mode */ | ||
| 303 | #define MTK_PDMA BIT(0) | ||
| 304 | #define MTK_QDMA BIT(1) | ||
| 305 | #define MTK_PDMA_RX_QDMA_TX (MTK_PDMA | MTK_QDMA) | ||
| 306 | |||
| 307 | /* dma ring */ | ||
| 308 | #define MTK_PST_DRX_IDX0 BIT(16) | ||
| 309 | #define MTK_PST_DTX_IDX3 BIT(3) | ||
| 310 | #define MTK_PST_DTX_IDX2 BIT(2) | ||
| 311 | #define MTK_PST_DTX_IDX1 BIT(1) | ||
| 312 | #define MTK_PST_DTX_IDX0 BIT(0) | ||
| 313 | |||
| 314 | #define MTK_RX_2B_OFFSET BIT(31) | ||
| 315 | #define MTK_TX_WB_DDONE BIT(6) | ||
| 316 | #define MTK_RX_DMA_BUSY BIT(3) | ||
| 317 | #define MTK_TX_DMA_BUSY BIT(1) | ||
| 318 | #define MTK_RX_DMA_EN BIT(2) | ||
| 319 | #define MTK_TX_DMA_EN BIT(0) | ||
| 320 | |||
| 321 | #define MTK_PDMA_SIZE_4DWORDS (0 << 4) | ||
| 322 | #define MTK_PDMA_SIZE_8DWORDS (1 << 4) | ||
| 323 | #define MTK_PDMA_SIZE_16DWORDS (2 << 4) | ||
| 324 | |||
| 325 | #define MTK_US_CYC_CNT_MASK 0xff | ||
| 326 | #define MTK_US_CYC_CNT_SHIFT 0x8 | ||
| 327 | #define MTK_US_CYC_CNT_DIVISOR 1000000 | ||
| 328 | |||
| 329 | /* PDMA descriptor rxd2 */ | ||
| 330 | #define RX_DMA_DONE BIT(31) | ||
| 331 | #define RX_DMA_LSO BIT(30) | ||
| 332 | #define RX_DMA_PLEN0(_x) (((_x) & 0x3fff) << 16) | ||
| 333 | #define RX_DMA_GET_PLEN0(_x) (((_x) >> 16) & 0x3fff) | ||
| 334 | #define RX_DMA_TAG BIT(15) | ||
| 335 | |||
| 336 | /* PDMA descriptor rxd3 */ | ||
| 337 | #define RX_DMA_TPID(_x) (((_x) >> 16) & 0xffff) | ||
| 338 | #define RX_DMA_VID(_x) ((_x) & 0xfff) | ||
| 339 | |||
| 340 | /* PDMA descriptor rxd4 */ | ||
| 341 | #define RX_DMA_L4VALID BIT(30) | ||
| 342 | #define RX_DMA_FPORT_SHIFT 19 | ||
| 343 | #define RX_DMA_FPORT_MASK 0x7 | ||
| 344 | |||
| 345 | struct mtk_rx_dma { | ||
| 346 | unsigned int rxd1; | ||
| 347 | unsigned int rxd2; | ||
| 348 | unsigned int rxd3; | ||
| 349 | unsigned int rxd4; | ||
| 350 | } __packed __aligned(4); | ||
| 351 | |||
| 352 | /* PDMA tx descriptor bits */ | ||
| 353 | #define TX_DMA_BUF_LEN 0x3fff | ||
| 354 | #define TX_DMA_PLEN0_MASK (TX_DMA_BUF_LEN << 16) | ||
| 355 | #define TX_DMA_PLEN0(_x) (((_x) & TX_DMA_BUF_LEN) << 16) | ||
| 356 | #define TX_DMA_PLEN1(_x) ((_x) & TX_DMA_BUF_LEN) | ||
| 357 | #define TX_DMA_GET_PLEN0(_x) (((_x) >> 16) & TX_DMA_BUF_LEN) | ||
| 358 | #define TX_DMA_GET_PLEN1(_x) ((_x) & TX_DMA_BUF_LEN) | ||
| 359 | #define TX_DMA_LS1 BIT(14) | ||
| 360 | #define TX_DMA_LS0 BIT(30) | ||
| 361 | #define TX_DMA_DONE BIT(31) | ||
| 362 | #define TX_DMA_FPORT_SHIFT 25 | ||
| 363 | #define TX_DMA_FPORT_MASK 0x7 | ||
| 364 | #define TX_DMA_INS_VLAN_MT7621 BIT(16) | ||
| 365 | #define TX_DMA_INS_VLAN BIT(7) | ||
| 366 | #define TX_DMA_INS_PPPOE BIT(12) | ||
| 367 | #define TX_DMA_TAG BIT(15) | ||
| 368 | #define TX_DMA_TAG_MASK BIT(15) | ||
| 369 | #define TX_DMA_QN(_x) ((_x) << 16) | ||
| 370 | #define TX_DMA_PN(_x) ((_x) << 24) | ||
| 371 | #define TX_DMA_QN_MASK TX_DMA_QN(0x7) | ||
| 372 | #define TX_DMA_PN_MASK TX_DMA_PN(0x7) | ||
| 373 | #define TX_DMA_UDF BIT(20) | ||
| 374 | #define TX_DMA_CHKSUM (0x7 << 29) | ||
| 375 | #define TX_DMA_TSO BIT(28) | ||
| 376 | #define TX_DMA_DESP4_DEF (TX_DMA_QN(3) | TX_DMA_PN(1)) | ||
| 377 | |||
| 378 | /* frame engine counters */ | ||
| 379 | #define MTK_PPE_AC_BCNT0 (MTK_CMTABLE_OFFSET + 0x00) | ||
| 380 | #define MTK_GDMA1_TX_GBCNT (MTK_CMTABLE_OFFSET + 0x300) | ||
| 381 | #define MTK_GDMA2_TX_GBCNT (MTK_GDMA1_TX_GBCNT + 0x40) | ||
| 382 | |||
| 383 | /* phy device flags */ | ||
| 384 | #define MTK_PHY_FLAG_PORT BIT(0) | ||
| 385 | #define MTK_PHY_FLAG_ATTACH BIT(1) | ||
| 386 | |||
| 387 | struct mtk_tx_dma { | ||
| 388 | unsigned int txd1; | ||
| 389 | unsigned int txd2; | ||
| 390 | unsigned int txd3; | ||
| 391 | unsigned int txd4; | ||
| 392 | } __packed __aligned(4); | ||
| 393 | |||
| 394 | struct mtk_eth; | ||
| 395 | struct mtk_mac; | ||
| 396 | |||
| 397 | /* manage the attached phys */ | ||
| 398 | struct mtk_phy { | ||
| 399 | spinlock_t lock; | ||
| 400 | |||
| 401 | struct phy_device *phy[8]; | ||
| 402 | struct device_node *phy_node[8]; | ||
| 403 | const __be32 *phy_fixed[8]; | ||
| 404 | int duplex[8]; | ||
| 405 | int speed[8]; | ||
| 406 | int tx_fc[8]; | ||
| 407 | int rx_fc[8]; | ||
| 408 | int (*connect)(struct mtk_mac *mac); | ||
| 409 | void (*disconnect)(struct mtk_mac *mac); | ||
| 410 | void (*start)(struct mtk_mac *mac); | ||
| 411 | void (*stop)(struct mtk_mac *mac); | ||
| 412 | }; | ||
| 413 | |||
| 414 | /* struct mtk_soc_data - the structure that holds the SoC specific data | ||
| 415 | * @reg_table: Some of the legacy registers changed their location | ||
| 416 | * over time. Their offsets are stored in this table | ||
| 417 | * | ||
| 418 | * @init_data: Some features depend on the silicon revision. This | ||
| 419 | * callback allows runtime modification of the content of | ||
| 420 | * this struct | ||
| 421 | * @reset_fe: This callback is used to trigger the reset of the frame | ||
| 422 | * engine | ||
| 423 | * @set_mac: This callback is used to set the unicast mac address | ||
| 424 | * filter | ||
| 425 | * @fwd_config: This callback is used to setup the forward config | ||
| 426 | * register of the MAC | ||
| 427 | * @switch_init: This callback is used to bring up the switch core | ||
| 428 | * @port_init: Some SoCs have ports that can be router to a switch port | ||
| 429 | * or an external PHY. This callback is used to setup these | ||
| 430 | * ports. | ||
| 431 | * @has_carrier: This callback allows driver to check if there is a cable | ||
| 432 | * attached. | ||
| 433 | * @mdio_init: This callbck is used to setup the MDIO bus if one is | ||
| 434 | * present | ||
| 435 | * @mdio_cleanup: This callback is used to cleanup the MDIO state. | ||
| 436 | * @mdio_write: This callback is used to write data to the MDIO bus. | ||
| 437 | * @mdio_read: This callback is used to write data to the MDIO bus. | ||
| 438 | * @mdio_adjust_link: This callback is used to apply the PHY settings. | ||
| 439 | * @piac_offset: the PIAC register has a different different base offset | ||
| 440 | * @hw_features: feature set depends on the SoC type | ||
| 441 | * @dma_ring_size: allow GBit SoCs to set bigger rings than FE SoCs | ||
| 442 | * @napi_weight: allow GBit SoCs to set bigger napi weight than FE SoCs | ||
| 443 | * @dma_type: SoCs is PDMA, QDMA or a mix of the 2 | ||
| 444 | * @pdma_glo_cfg: the default DMA configuration | ||
| 445 | * @rx_int: the TX interrupt bits used by the SoC | ||
| 446 | * @tx_int: the TX interrupt bits used by the SoC | ||
| 447 | * @status_int: the Status interrupt bits used by the SoC | ||
| 448 | * @checksum_bit: the bits used to turn on HW checksumming | ||
| 449 | * @txd4: default value of the TXD4 descriptor | ||
| 450 | * @mac_count: the number of MACs that the SoC has | ||
| 451 | * @new_stats: there is a old and new way to read hardware stats | ||
| 452 | * registers | ||
| 453 | * @jumbo_frame: does the SoC support jumbo frames ? | ||
| 454 | * @rx_2b_offset: tell the rx dma to offset the data by 2 bytes | ||
| 455 | * @rx_sg_dma: scatter gather support | ||
| 456 | * @padding_64b enable 64 bit padding | ||
| 457 | * @padding_bug: rt2880 has a padding bug | ||
| 458 | * @has_switch: does the SoC have a built-in switch | ||
| 459 | * | ||
| 460 | * Although all of the supported SoCs share the same basic functionality, there | ||
| 461 | * are several SoC specific functions and features that we need to support. This | ||
| 462 | * struct holds the SoC specific data so that the common core can figure out | ||
| 463 | * how to setup and use these differences. | ||
| 464 | */ | ||
| 465 | struct mtk_soc_data { | ||
| 466 | const u16 *reg_table; | ||
| 467 | |||
| 468 | void (*init_data)(struct mtk_soc_data *data, struct net_device *netdev); | ||
| 469 | void (*reset_fe)(struct mtk_eth *eth); | ||
| 470 | void (*set_mac)(struct mtk_mac *mac, unsigned char *macaddr); | ||
| 471 | int (*fwd_config)(struct mtk_eth *eth); | ||
| 472 | int (*switch_init)(struct mtk_eth *eth); | ||
| 473 | void (*port_init)(struct mtk_eth *eth, struct mtk_mac *mac, | ||
| 474 | struct device_node *port); | ||
| 475 | int (*has_carrier)(struct mtk_eth *eth); | ||
| 476 | int (*mdio_init)(struct mtk_eth *eth); | ||
| 477 | void (*mdio_cleanup)(struct mtk_eth *eth); | ||
| 478 | int (*mdio_write)(struct mii_bus *bus, int phy_addr, int phy_reg, | ||
| 479 | u16 val); | ||
| 480 | int (*mdio_read)(struct mii_bus *bus, int phy_addr, int phy_reg); | ||
| 481 | void (*mdio_adjust_link)(struct mtk_eth *eth, int port); | ||
| 482 | u32 piac_offset; | ||
| 483 | netdev_features_t hw_features; | ||
| 484 | u32 dma_ring_size; | ||
| 485 | u32 napi_weight; | ||
| 486 | u32 dma_type; | ||
| 487 | u32 pdma_glo_cfg; | ||
| 488 | u32 rx_int; | ||
| 489 | u32 tx_int; | ||
| 490 | u32 status_int; | ||
| 491 | u32 checksum_bit; | ||
| 492 | u32 txd4; | ||
| 493 | u32 mac_count; | ||
| 494 | |||
| 495 | u32 new_stats:1; | ||
| 496 | u32 jumbo_frame:1; | ||
| 497 | u32 rx_2b_offset:1; | ||
| 498 | u32 rx_sg_dma:1; | ||
| 499 | u32 padding_64b:1; | ||
| 500 | u32 padding_bug:1; | ||
| 501 | u32 has_switch:1; | ||
| 502 | }; | ||
| 503 | |||
| 504 | #define MTK_STAT_OFFSET 0x40 | ||
| 505 | |||
| 506 | /* struct mtk_hw_stats - the structure that holds the traffic statistics. | ||
| 507 | * @stats_lock: make sure that stats operations are atomic | ||
| 508 | * @reg_offset: the status register offset of the SoC | ||
| 509 | * @syncp: the refcount | ||
| 510 | * | ||
| 511 | * All of the supported SoCs have hardware counters for traffic statstics. | ||
| 512 | * Whenever the status IRQ triggers we can read the latest stats from these | ||
| 513 | * counters and store them in this struct. | ||
| 514 | */ | ||
| 515 | struct mtk_hw_stats { | ||
| 516 | spinlock_t stats_lock; | ||
| 517 | u32 reg_offset; | ||
| 518 | struct u64_stats_sync syncp; | ||
| 519 | |||
| 520 | u64 tx_bytes; | ||
| 521 | u64 tx_packets; | ||
| 522 | u64 tx_skip; | ||
| 523 | u64 tx_collisions; | ||
| 524 | u64 rx_bytes; | ||
| 525 | u64 rx_packets; | ||
| 526 | u64 rx_overflow; | ||
| 527 | u64 rx_fcs_errors; | ||
| 528 | u64 rx_short_errors; | ||
| 529 | u64 rx_long_errors; | ||
| 530 | u64 rx_checksum_errors; | ||
| 531 | u64 rx_flow_control_packets; | ||
| 532 | }; | ||
| 533 | |||
| 534 | /* PDMA descriptor can point at 1-2 segments. This enum allows us to track how | ||
| 535 | * memory was allocated so that it can be freed properly | ||
| 536 | */ | ||
| 537 | enum mtk_tx_flags { | ||
| 538 | MTK_TX_FLAGS_SINGLE0 = 0x01, | ||
| 539 | MTK_TX_FLAGS_PAGE0 = 0x02, | ||
| 540 | MTK_TX_FLAGS_PAGE1 = 0x04, | ||
| 541 | }; | ||
| 542 | |||
| 543 | /* struct mtk_tx_buf - This struct holds the pointers to the memory pointed at | ||
| 544 | * by the TX descriptor s | ||
| 545 | * @skb: The SKB pointer of the packet being sent | ||
| 546 | * @dma_addr0: The base addr of the first segment | ||
| 547 | * @dma_len0: The length of the first segment | ||
| 548 | * @dma_addr1: The base addr of the second segment | ||
| 549 | * @dma_len1: The length of the second segment | ||
| 550 | */ | ||
| 551 | struct mtk_tx_buf { | ||
| 552 | struct sk_buff *skb; | ||
| 553 | u32 flags; | ||
| 554 | DEFINE_DMA_UNMAP_ADDR(dma_addr0); | ||
| 555 | DEFINE_DMA_UNMAP_LEN(dma_len0); | ||
| 556 | DEFINE_DMA_UNMAP_ADDR(dma_addr1); | ||
| 557 | DEFINE_DMA_UNMAP_LEN(dma_len1); | ||
| 558 | }; | ||
| 559 | |||
| 560 | /* struct mtk_tx_ring - This struct holds info describing a TX ring | ||
| 561 | * @tx_dma: The descriptor ring | ||
| 562 | * @tx_buf: The memory pointed at by the ring | ||
| 563 | * @tx_phys: The physical addr of tx_buf | ||
| 564 | * @tx_next_free: Pointer to the next free descriptor | ||
| 565 | * @tx_last_free: Pointer to the last free descriptor | ||
| 566 | * @tx_thresh: The threshold of minimum amount of free descriptors | ||
| 567 | * @tx_map: Callback to map a new packet into the ring | ||
| 568 | * @tx_poll: Callback for the housekeeping function | ||
| 569 | * @tx_clean: Callback for the cleanup function | ||
| 570 | * @tx_ring_size: How many descriptors are in the ring | ||
| 571 | * @tx_free_idx: The index of th next free descriptor | ||
| 572 | * @tx_next_idx: QDMA uses a linked list. This element points to the next | ||
| 573 | * free descriptor in the list | ||
| 574 | * @tx_free_count: QDMA uses a linked list. Track how many free descriptors | ||
| 575 | * are present | ||
| 576 | */ | ||
| 577 | struct mtk_tx_ring { | ||
| 578 | struct mtk_tx_dma *tx_dma; | ||
| 579 | struct mtk_tx_buf *tx_buf; | ||
| 580 | dma_addr_t tx_phys; | ||
| 581 | struct mtk_tx_dma *tx_next_free; | ||
| 582 | struct mtk_tx_dma *tx_last_free; | ||
| 583 | u16 tx_thresh; | ||
| 584 | int (*tx_map)(struct sk_buff *skb, struct net_device *dev, int tx_num, | ||
| 585 | struct mtk_tx_ring *ring, bool gso); | ||
| 586 | int (*tx_poll)(struct mtk_eth *eth, int budget, bool *tx_again); | ||
| 587 | void (*tx_clean)(struct mtk_eth *eth); | ||
| 588 | |||
| 589 | /* PDMA only */ | ||
| 590 | u16 tx_ring_size; | ||
| 591 | u16 tx_free_idx; | ||
| 592 | |||
| 593 | /* QDMA only */ | ||
| 594 | u16 tx_next_idx; | ||
| 595 | atomic_t tx_free_count; | ||
| 596 | }; | ||
| 597 | |||
| 598 | /* struct mtk_rx_ring - This struct holds info describing a RX ring | ||
| 599 | * @rx_dma: The descriptor ring | ||
| 600 | * @rx_data: The memory pointed at by the ring | ||
| 601 | * @trx_phys: The physical addr of rx_buf | ||
| 602 | * @rx_ring_size: How many descriptors are in the ring | ||
| 603 | * @rx_buf_size: The size of each packet buffer | ||
| 604 | * @rx_calc_idx: The current head of ring | ||
| 605 | */ | ||
| 606 | struct mtk_rx_ring { | ||
| 607 | struct mtk_rx_dma *rx_dma; | ||
| 608 | u8 **rx_data; | ||
| 609 | dma_addr_t rx_phys; | ||
| 610 | u16 rx_ring_size; | ||
| 611 | u16 frag_size; | ||
| 612 | u16 rx_buf_size; | ||
| 613 | u16 rx_calc_idx; | ||
| 614 | }; | ||
| 615 | |||
| 616 | /* currently no SoC has more than 2 macs */ | ||
| 617 | #define MTK_MAX_DEVS 2 | ||
| 618 | |||
| 619 | /* struct mtk_eth - This is the main datasructure for holding the state | ||
| 620 | * of the driver | ||
| 621 | * @dev: The device pointer | ||
| 622 | * @base: The mapped register i/o base | ||
| 623 | * @page_lock: Make sure that register operations are atomic | ||
| 624 | * @soc: pointer to our SoC specific data | ||
| 625 | * @dummy_dev: we run 2 netdevs on 1 physical DMA ring and need a | ||
| 626 | * dummy for NAPI to work | ||
| 627 | * @netdev: The netdev instances | ||
| 628 | * @mac: Each netdev is linked to a physical MAC | ||
| 629 | * @switch_np: The phandle for the switch | ||
| 630 | * @irq: The IRQ that we are using | ||
| 631 | * @msg_enable: Ethtool msg level | ||
| 632 | * @ysclk: The sysclk rate - neeed for calibration | ||
| 633 | * @ethsys: The register map pointing at the range used to setup | ||
| 634 | * MII modes | ||
| 635 | * @dma_refcnt: track how many netdevs are using the DMA engine | ||
| 636 | * @tx_ring: Pointer to the memore holding info about the TX ring | ||
| 637 | * @rx_ring: Pointer to the memore holding info about the RX ring | ||
| 638 | * @rx_napi: The NAPI struct | ||
| 639 | * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring | ||
| 640 | * @scratch_head: The scratch memory that scratch_ring points to. | ||
| 641 | * @phy: Info about the attached PHYs | ||
| 642 | * @mii_bus: If there is a bus we need to create an instance for it | ||
| 643 | * @link: Track if the ports have a physical link | ||
| 644 | * @sw_priv: Pointer to the switches private data | ||
| 645 | * @vlan_map: RX VID tracking | ||
| 646 | */ | ||
| 647 | |||
| 648 | struct mtk_eth { | ||
| 649 | struct device *dev; | ||
| 650 | void __iomem *base; | ||
| 651 | spinlock_t page_lock; | ||
| 652 | struct mtk_soc_data *soc; | ||
| 653 | struct net_device dummy_dev; | ||
| 654 | struct net_device *netdev[MTK_MAX_DEVS]; | ||
| 655 | struct mtk_mac *mac[MTK_MAX_DEVS]; | ||
| 656 | struct device_node *switch_np; | ||
| 657 | int irq; | ||
| 658 | u32 msg_enable; | ||
| 659 | unsigned long sysclk; | ||
| 660 | struct regmap *ethsys; | ||
| 661 | atomic_t dma_refcnt; | ||
| 662 | struct mtk_tx_ring tx_ring; | ||
| 663 | struct mtk_rx_ring rx_ring[2]; | ||
| 664 | struct napi_struct rx_napi; | ||
| 665 | struct mtk_tx_dma *scratch_ring; | ||
| 666 | void *scratch_head; | ||
| 667 | struct mtk_phy *phy; | ||
| 668 | struct mii_bus *mii_bus; | ||
| 669 | int link[8]; | ||
| 670 | void *sw_priv; | ||
| 671 | unsigned long vlan_map; | ||
| 672 | }; | ||
| 673 | |||
| 674 | /* struct mtk_mac - the structure that holds the info about the MACs of the | ||
| 675 | * SoC | ||
| 676 | * @id: The number of the MAC | ||
| 677 | * @of_node: Our devicetree node | ||
| 678 | * @hw: Backpointer to our main datastruture | ||
| 679 | * @hw_stats: Packet statistics counter | ||
| 680 | * @phy_dev: The attached PHY if available | ||
| 681 | * @phy_flags: The PHYs flags | ||
| 682 | * @pending_work: The workqueue used to reset the dma ring | ||
| 683 | */ | ||
| 684 | struct mtk_mac { | ||
| 685 | int id; | ||
| 686 | struct device_node *of_node; | ||
| 687 | struct mtk_eth *hw; | ||
| 688 | struct mtk_hw_stats *hw_stats; | ||
| 689 | struct phy_device *phy_dev; | ||
| 690 | u32 phy_flags; | ||
| 691 | struct work_struct pending_work; | ||
| 692 | }; | ||
| 693 | |||
| 694 | /* the struct describing the SoC. these are declared in the soc_xyz.c files */ | ||
| 695 | extern const struct of_device_id of_mtk_match[]; | ||
| 696 | |||
| 697 | /* read the hardware status register */ | ||
| 698 | void mtk_stats_update_mac(struct mtk_mac *mac); | ||
| 699 | |||
| 700 | /* default checksum setup handler */ | ||
| 701 | void mtk_reset(struct mtk_eth *eth, u32 reset_bits); | ||
| 702 | |||
| 703 | /* register i/o wrappers */ | ||
| 704 | void mtk_w32(struct mtk_eth *eth, u32 val, unsigned int reg); | ||
| 705 | u32 mtk_r32(struct mtk_eth *eth, unsigned int reg); | ||
| 706 | |||
| 707 | /* default clock calibration handler */ | ||
| 708 | int mtk_set_clock_cycle(struct mtk_eth *eth); | ||
| 709 | |||
| 710 | /* default checksum setup handler */ | ||
| 711 | void mtk_csum_config(struct mtk_eth *eth); | ||
| 712 | |||
| 713 | /* default forward config handler */ | ||
| 714 | void mtk_fwd_config(struct mtk_eth *eth); | ||
| 715 | |||
| 716 | #endif /* MTK_ETH_H */ | ||
diff --git a/drivers/staging/mt7621-eth/soc_mt7621.c b/drivers/staging/mt7621-eth/soc_mt7621.c deleted file mode 100644 index 5d63b5d96f6b..000000000000 --- a/drivers/staging/mt7621-eth/soc_mt7621.c +++ /dev/null | |||
| @@ -1,161 +0,0 @@ | |||
| 1 | /* This program is free software; you can redistribute it and/or modify | ||
| 2 | * it under the terms of the GNU General Public License as published by | ||
| 3 | * the Free Software Foundation; version 2 of the License | ||
| 4 | * | ||
| 5 | * This program is distributed in the hope that it will be useful, | ||
| 6 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 7 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 8 | * GNU General Public License for more details. | ||
| 9 | * | ||
| 10 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> | ||
| 11 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> | ||
| 12 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/platform_device.h> | ||
| 17 | #include <linux/if_vlan.h> | ||
| 18 | #include <linux/of_net.h> | ||
| 19 | |||
| 20 | #include <asm/mach-ralink/ralink_regs.h> | ||
| 21 | |||
| 22 | #include "mtk_eth_soc.h" | ||
| 23 | #include "gsw_mt7620.h" | ||
| 24 | #include "mdio.h" | ||
| 25 | |||
| 26 | #define MT7620_CDMA_CSG_CFG 0x400 | ||
| 27 | #define MT7621_CDMP_IG_CTRL (MT7620_CDMA_CSG_CFG + 0x00) | ||
| 28 | #define MT7621_CDMP_EG_CTRL (MT7620_CDMA_CSG_CFG + 0x04) | ||
| 29 | #define MT7621_RESET_FE BIT(6) | ||
| 30 | #define MT7621_L4_VALID BIT(24) | ||
| 31 | |||
| 32 | #define MT7621_TX_DMA_UDF BIT(19) | ||
| 33 | |||
| 34 | #define CDMA_ICS_EN BIT(2) | ||
| 35 | #define CDMA_UCS_EN BIT(1) | ||
| 36 | #define CDMA_TCS_EN BIT(0) | ||
| 37 | |||
| 38 | #define GDMA_ICS_EN BIT(22) | ||
| 39 | #define GDMA_TCS_EN BIT(21) | ||
| 40 | #define GDMA_UCS_EN BIT(20) | ||
| 41 | |||
| 42 | /* frame engine counters */ | ||
| 43 | #define MT7621_REG_MIB_OFFSET 0x2000 | ||
| 44 | #define MT7621_PPE_AC_BCNT0 (MT7621_REG_MIB_OFFSET + 0x00) | ||
| 45 | #define MT7621_GDM1_TX_GBCNT (MT7621_REG_MIB_OFFSET + 0x400) | ||
| 46 | #define MT7621_GDM2_TX_GBCNT (MT7621_GDM1_TX_GBCNT + 0x40) | ||
| 47 | |||
| 48 | #define GSW_REG_GDMA1_MAC_ADRL 0x508 | ||
| 49 | #define GSW_REG_GDMA1_MAC_ADRH 0x50C | ||
| 50 | #define GSW_REG_GDMA2_MAC_ADRL 0x1508 | ||
| 51 | #define GSW_REG_GDMA2_MAC_ADRH 0x150C | ||
| 52 | |||
| 53 | #define MT7621_MTK_RST_GL 0x04 | ||
| 54 | #define MT7620_MTK_INT_STATUS2 0x08 | ||
| 55 | |||
| 56 | /* MTK_INT_STATUS reg on mt7620 define CNT_GDM1_AF at BIT(29) | ||
| 57 | * but after test it should be BIT(13). | ||
| 58 | */ | ||
| 59 | #define MT7621_MTK_GDM1_AF BIT(28) | ||
| 60 | #define MT7621_MTK_GDM2_AF BIT(29) | ||
| 61 | |||
| 62 | static const u16 mt7621_reg_table[MTK_REG_COUNT] = { | ||
| 63 | [MTK_REG_PDMA_GLO_CFG] = RT5350_PDMA_GLO_CFG, | ||
| 64 | [MTK_REG_PDMA_RST_CFG] = RT5350_PDMA_RST_CFG, | ||
| 65 | [MTK_REG_DLY_INT_CFG] = RT5350_DLY_INT_CFG, | ||
| 66 | [MTK_REG_TX_BASE_PTR0] = RT5350_TX_BASE_PTR0, | ||
| 67 | [MTK_REG_TX_MAX_CNT0] = RT5350_TX_MAX_CNT0, | ||
| 68 | [MTK_REG_TX_CTX_IDX0] = RT5350_TX_CTX_IDX0, | ||
| 69 | [MTK_REG_TX_DTX_IDX0] = RT5350_TX_DTX_IDX0, | ||
| 70 | [MTK_REG_RX_BASE_PTR0] = RT5350_RX_BASE_PTR0, | ||
| 71 | [MTK_REG_RX_MAX_CNT0] = RT5350_RX_MAX_CNT0, | ||
| 72 | [MTK_REG_RX_CALC_IDX0] = RT5350_RX_CALC_IDX0, | ||
| 73 | [MTK_REG_RX_DRX_IDX0] = RT5350_RX_DRX_IDX0, | ||
| 74 | [MTK_REG_MTK_INT_ENABLE] = RT5350_MTK_INT_ENABLE, | ||
| 75 | [MTK_REG_MTK_INT_STATUS] = RT5350_MTK_INT_STATUS, | ||
| 76 | [MTK_REG_MTK_DMA_VID_BASE] = 0, | ||
| 77 | [MTK_REG_MTK_COUNTER_BASE] = MT7621_GDM1_TX_GBCNT, | ||
| 78 | [MTK_REG_MTK_RST_GL] = MT7621_MTK_RST_GL, | ||
| 79 | [MTK_REG_MTK_INT_STATUS2] = MT7620_MTK_INT_STATUS2, | ||
| 80 | }; | ||
| 81 | |||
| 82 | static void mt7621_mtk_reset(struct mtk_eth *eth) | ||
| 83 | { | ||
| 84 | mtk_reset(eth, MT7621_RESET_FE); | ||
| 85 | } | ||
| 86 | |||
| 87 | static int mt7621_fwd_config(struct mtk_eth *eth) | ||
| 88 | { | ||
| 89 | /* Setup GMAC1 only, there is no support for GMAC2 yet */ | ||
| 90 | mtk_w32(eth, mtk_r32(eth, MT7620_GDMA1_FWD_CFG) & ~0xffff, | ||
| 91 | MT7620_GDMA1_FWD_CFG); | ||
| 92 | |||
| 93 | /* Enable RX checksum */ | ||
| 94 | mtk_w32(eth, mtk_r32(eth, MT7620_GDMA1_FWD_CFG) | (GDMA_ICS_EN | | ||
| 95 | GDMA_TCS_EN | GDMA_UCS_EN), | ||
| 96 | MT7620_GDMA1_FWD_CFG); | ||
| 97 | |||
| 98 | /* Enable RX VLan Offloading */ | ||
| 99 | mtk_w32(eth, 0, MT7621_CDMP_EG_CTRL); | ||
| 100 | |||
| 101 | return 0; | ||
| 102 | } | ||
| 103 | |||
| 104 | static void mt7621_set_mac(struct mtk_mac *mac, unsigned char *hwaddr) | ||
| 105 | { | ||
| 106 | unsigned long flags; | ||
| 107 | |||
| 108 | spin_lock_irqsave(&mac->hw->page_lock, flags); | ||
| 109 | if (mac->id == 0) { | ||
| 110 | mtk_w32(mac->hw, (hwaddr[0] << 8) | hwaddr[1], | ||
| 111 | GSW_REG_GDMA1_MAC_ADRH); | ||
| 112 | mtk_w32(mac->hw, (hwaddr[2] << 24) | (hwaddr[3] << 16) | | ||
| 113 | (hwaddr[4] << 8) | hwaddr[5], | ||
| 114 | GSW_REG_GDMA1_MAC_ADRL); | ||
| 115 | } | ||
| 116 | if (mac->id == 1) { | ||
| 117 | mtk_w32(mac->hw, (hwaddr[0] << 8) | hwaddr[1], | ||
| 118 | GSW_REG_GDMA2_MAC_ADRH); | ||
| 119 | mtk_w32(mac->hw, (hwaddr[2] << 24) | (hwaddr[3] << 16) | | ||
| 120 | (hwaddr[4] << 8) | hwaddr[5], | ||
| 121 | GSW_REG_GDMA2_MAC_ADRL); | ||
| 122 | } | ||
| 123 | spin_unlock_irqrestore(&mac->hw->page_lock, flags); | ||
| 124 | } | ||
| 125 | |||
| 126 | static struct mtk_soc_data mt7621_data = { | ||
| 127 | .hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM | | ||
| 128 | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | | ||
| 129 | NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | | ||
| 130 | NETIF_F_IPV6_CSUM, | ||
| 131 | .dma_type = MTK_PDMA, | ||
| 132 | .dma_ring_size = 256, | ||
| 133 | .napi_weight = 64, | ||
| 134 | .new_stats = 1, | ||
| 135 | .padding_64b = 1, | ||
| 136 | .rx_2b_offset = 1, | ||
| 137 | .rx_sg_dma = 1, | ||
| 138 | .has_switch = 1, | ||
| 139 | .mac_count = 2, | ||
| 140 | .reset_fe = mt7621_mtk_reset, | ||
| 141 | .set_mac = mt7621_set_mac, | ||
| 142 | .fwd_config = mt7621_fwd_config, | ||
| 143 | .switch_init = mtk_gsw_init, | ||
| 144 | .reg_table = mt7621_reg_table, | ||
| 145 | .pdma_glo_cfg = MTK_PDMA_SIZE_16DWORDS, | ||
| 146 | .rx_int = RT5350_RX_DONE_INT, | ||
| 147 | .tx_int = RT5350_TX_DONE_INT, | ||
| 148 | .status_int = MT7621_MTK_GDM1_AF | MT7621_MTK_GDM2_AF, | ||
| 149 | .checksum_bit = MT7621_L4_VALID, | ||
| 150 | .has_carrier = mt7620_has_carrier, | ||
| 151 | .mdio_read = mt7620_mdio_read, | ||
| 152 | .mdio_write = mt7620_mdio_write, | ||
| 153 | .mdio_adjust_link = mt7620_mdio_link_adjust, | ||
| 154 | }; | ||
| 155 | |||
| 156 | const struct of_device_id of_mtk_match[] = { | ||
| 157 | { .compatible = "mediatek,mt7621-eth", .data = &mt7621_data }, | ||
| 158 | {}, | ||
| 159 | }; | ||
| 160 | |||
| 161 | MODULE_DEVICE_TABLE(of, of_mtk_match); | ||
diff --git a/drivers/staging/mt7621-pci/Kconfig b/drivers/staging/mt7621-pci/Kconfig index d33533872a16..c8fa17cfa807 100644 --- a/drivers/staging/mt7621-pci/Kconfig +++ b/drivers/staging/mt7621-pci/Kconfig | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | config PCI_MT7621 | 1 | config PCI_MT7621 |
| 2 | tristate "MediaTek MT7621 PCI Controller" | 2 | tristate "MediaTek MT7621 PCI Controller" |
| 3 | depends on RALINK | 3 | depends on RALINK |
| 4 | depends on PCI | ||
| 4 | select PCI_DRIVERS_GENERIC | 5 | select PCI_DRIVERS_GENERIC |
| 5 | help | 6 | help |
| 6 | This selects a driver for the MediaTek MT7621 PCI Controller. | 7 | This selects a driver for the MediaTek MT7621 PCI Controller. |
diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index d6248eecf123..2aee64fdaec5 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c | |||
| @@ -163,7 +163,7 @@ int cvm_oct_phy_setup_device(struct net_device *dev) | |||
| 163 | goto no_phy; | 163 | goto no_phy; |
| 164 | 164 | ||
| 165 | phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0, | 165 | phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0, |
| 166 | PHY_INTERFACE_MODE_GMII); | 166 | priv->phy_mode); |
| 167 | of_node_put(phy_node); | 167 | of_node_put(phy_node); |
| 168 | 168 | ||
| 169 | if (!phydev) | 169 | if (!phydev) |
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index ce61c5670ef6..986db76705cc 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c | |||
| @@ -653,14 +653,37 @@ static struct device_node *cvm_oct_node_for_port(struct device_node *pip, | |||
| 653 | return np; | 653 | return np; |
| 654 | } | 654 | } |
| 655 | 655 | ||
| 656 | static void cvm_set_rgmii_delay(struct device_node *np, int iface, int port) | 656 | static void cvm_set_rgmii_delay(struct octeon_ethernet *priv, int iface, |
| 657 | int port) | ||
| 657 | { | 658 | { |
| 659 | struct device_node *np = priv->of_node; | ||
| 658 | u32 delay_value; | 660 | u32 delay_value; |
| 661 | bool rx_delay; | ||
| 662 | bool tx_delay; | ||
| 659 | 663 | ||
| 660 | if (!of_property_read_u32(np, "rx-delay", &delay_value)) | 664 | /* By default, both RX/TX delay is enabled in |
| 665 | * __cvmx_helper_rgmii_enable(). | ||
| 666 | */ | ||
| 667 | rx_delay = true; | ||
| 668 | tx_delay = true; | ||
| 669 | |||
| 670 | if (!of_property_read_u32(np, "rx-delay", &delay_value)) { | ||
| 661 | cvmx_write_csr(CVMX_ASXX_RX_CLK_SETX(port, iface), delay_value); | 671 | cvmx_write_csr(CVMX_ASXX_RX_CLK_SETX(port, iface), delay_value); |
| 662 | if (!of_property_read_u32(np, "tx-delay", &delay_value)) | 672 | rx_delay = delay_value > 0; |
| 673 | } | ||
| 674 | if (!of_property_read_u32(np, "tx-delay", &delay_value)) { | ||
| 663 | cvmx_write_csr(CVMX_ASXX_TX_CLK_SETX(port, iface), delay_value); | 675 | cvmx_write_csr(CVMX_ASXX_TX_CLK_SETX(port, iface), delay_value); |
| 676 | tx_delay = delay_value > 0; | ||
| 677 | } | ||
| 678 | |||
| 679 | if (!rx_delay && !tx_delay) | ||
| 680 | priv->phy_mode = PHY_INTERFACE_MODE_RGMII_ID; | ||
| 681 | else if (!rx_delay) | ||
| 682 | priv->phy_mode = PHY_INTERFACE_MODE_RGMII_RXID; | ||
| 683 | else if (!tx_delay) | ||
| 684 | priv->phy_mode = PHY_INTERFACE_MODE_RGMII_TXID; | ||
| 685 | else | ||
| 686 | priv->phy_mode = PHY_INTERFACE_MODE_RGMII; | ||
| 664 | } | 687 | } |
| 665 | 688 | ||
| 666 | static int cvm_oct_probe(struct platform_device *pdev) | 689 | static int cvm_oct_probe(struct platform_device *pdev) |
| @@ -825,6 +848,7 @@ static int cvm_oct_probe(struct platform_device *pdev) | |||
| 825 | priv->port = port; | 848 | priv->port = port; |
| 826 | priv->queue = cvmx_pko_get_base_queue(priv->port); | 849 | priv->queue = cvmx_pko_get_base_queue(priv->port); |
| 827 | priv->fau = fau - cvmx_pko_get_num_queues(port) * 4; | 850 | priv->fau = fau - cvmx_pko_get_num_queues(port) * 4; |
| 851 | priv->phy_mode = PHY_INTERFACE_MODE_NA; | ||
| 828 | for (qos = 0; qos < 16; qos++) | 852 | for (qos = 0; qos < 16; qos++) |
| 829 | skb_queue_head_init(&priv->tx_free_list[qos]); | 853 | skb_queue_head_init(&priv->tx_free_list[qos]); |
| 830 | for (qos = 0; qos < cvmx_pko_get_num_queues(port); | 854 | for (qos = 0; qos < cvmx_pko_get_num_queues(port); |
| @@ -856,6 +880,7 @@ static int cvm_oct_probe(struct platform_device *pdev) | |||
| 856 | break; | 880 | break; |
| 857 | 881 | ||
| 858 | case CVMX_HELPER_INTERFACE_MODE_SGMII: | 882 | case CVMX_HELPER_INTERFACE_MODE_SGMII: |
| 883 | priv->phy_mode = PHY_INTERFACE_MODE_SGMII; | ||
| 859 | dev->netdev_ops = &cvm_oct_sgmii_netdev_ops; | 884 | dev->netdev_ops = &cvm_oct_sgmii_netdev_ops; |
| 860 | strcpy(dev->name, "eth%d"); | 885 | strcpy(dev->name, "eth%d"); |
| 861 | break; | 886 | break; |
| @@ -865,11 +890,16 @@ static int cvm_oct_probe(struct platform_device *pdev) | |||
| 865 | strcpy(dev->name, "spi%d"); | 890 | strcpy(dev->name, "spi%d"); |
| 866 | break; | 891 | break; |
| 867 | 892 | ||
| 868 | case CVMX_HELPER_INTERFACE_MODE_RGMII: | ||
| 869 | case CVMX_HELPER_INTERFACE_MODE_GMII: | 893 | case CVMX_HELPER_INTERFACE_MODE_GMII: |
| 894 | priv->phy_mode = PHY_INTERFACE_MODE_GMII; | ||
| 895 | dev->netdev_ops = &cvm_oct_rgmii_netdev_ops; | ||
| 896 | strcpy(dev->name, "eth%d"); | ||
| 897 | break; | ||
| 898 | |||
| 899 | case CVMX_HELPER_INTERFACE_MODE_RGMII: | ||
| 870 | dev->netdev_ops = &cvm_oct_rgmii_netdev_ops; | 900 | dev->netdev_ops = &cvm_oct_rgmii_netdev_ops; |
| 871 | strcpy(dev->name, "eth%d"); | 901 | strcpy(dev->name, "eth%d"); |
| 872 | cvm_set_rgmii_delay(priv->of_node, interface, | 902 | cvm_set_rgmii_delay(priv, interface, |
| 873 | port_index); | 903 | port_index); |
| 874 | break; | 904 | break; |
| 875 | } | 905 | } |
diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 4a07e7f43d12..be570d33685a 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #define OCTEON_ETHERNET_H | 12 | #define OCTEON_ETHERNET_H |
| 13 | 13 | ||
| 14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
| 15 | 15 | #include <linux/phy.h> | |
| 16 | #include <asm/octeon/cvmx-helper-board.h> | 16 | #include <asm/octeon/cvmx-helper-board.h> |
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| @@ -33,6 +33,8 @@ struct octeon_ethernet { | |||
| 33 | * cvmx_helper_interface_mode_t | 33 | * cvmx_helper_interface_mode_t |
| 34 | */ | 34 | */ |
| 35 | int imode; | 35 | int imode; |
| 36 | /* PHY mode */ | ||
| 37 | phy_interface_t phy_mode; | ||
| 36 | /* List of outstanding tx buffers per queue */ | 38 | /* List of outstanding tx buffers per queue */ |
| 37 | struct sk_buff_head tx_free_list[16]; | 39 | struct sk_buff_head tx_free_list[16]; |
| 38 | unsigned int last_speed; | 40 | unsigned int last_speed; |
diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c index 80b8d4153414..a54286498a47 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c +++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c | |||
| @@ -45,7 +45,7 @@ static int dcon_init_xo_1(struct dcon_priv *dcon) | |||
| 45 | { | 45 | { |
| 46 | unsigned char lob; | 46 | unsigned char lob; |
| 47 | int ret, i; | 47 | int ret, i; |
| 48 | struct dcon_gpio *pin = &gpios_asis[0]; | 48 | const struct dcon_gpio *pin = &gpios_asis[0]; |
| 49 | 49 | ||
| 50 | for (i = 0; i < ARRAY_SIZE(gpios_asis); i++) { | 50 | for (i = 0; i < ARRAY_SIZE(gpios_asis); i++) { |
| 51 | gpios[i] = devm_gpiod_get(&dcon->client->dev, pin[i].name, | 51 | gpios[i] = devm_gpiod_get(&dcon->client->dev, pin[i].name, |
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 1723a47a96b4..952f2ab51347 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c | |||
| @@ -174,7 +174,9 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) | |||
| 174 | 174 | ||
| 175 | pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; | 175 | pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; |
| 176 | 176 | ||
| 177 | rtw_alloc_hwxmits(padapter); | 177 | res = rtw_alloc_hwxmits(padapter); |
| 178 | if (res == _FAIL) | ||
| 179 | goto exit; | ||
| 178 | rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); | 180 | rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); |
| 179 | 181 | ||
| 180 | for (i = 0; i < 4; i++) | 182 | for (i = 0; i < 4; i++) |
| @@ -1503,7 +1505,7 @@ exit: | |||
| 1503 | return res; | 1505 | return res; |
| 1504 | } | 1506 | } |
| 1505 | 1507 | ||
| 1506 | void rtw_alloc_hwxmits(struct adapter *padapter) | 1508 | s32 rtw_alloc_hwxmits(struct adapter *padapter) |
| 1507 | { | 1509 | { |
| 1508 | struct hw_xmit *hwxmits; | 1510 | struct hw_xmit *hwxmits; |
| 1509 | struct xmit_priv *pxmitpriv = &padapter->xmitpriv; | 1511 | struct xmit_priv *pxmitpriv = &padapter->xmitpriv; |
| @@ -1512,6 +1514,8 @@ void rtw_alloc_hwxmits(struct adapter *padapter) | |||
| 1512 | 1514 | ||
| 1513 | pxmitpriv->hwxmits = kcalloc(pxmitpriv->hwxmit_entry, | 1515 | pxmitpriv->hwxmits = kcalloc(pxmitpriv->hwxmit_entry, |
| 1514 | sizeof(struct hw_xmit), GFP_KERNEL); | 1516 | sizeof(struct hw_xmit), GFP_KERNEL); |
| 1517 | if (!pxmitpriv->hwxmits) | ||
| 1518 | return _FAIL; | ||
| 1515 | 1519 | ||
| 1516 | hwxmits = pxmitpriv->hwxmits; | 1520 | hwxmits = pxmitpriv->hwxmits; |
| 1517 | 1521 | ||
| @@ -1519,6 +1523,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter) | |||
| 1519 | hwxmits[1] .sta_queue = &pxmitpriv->vi_pending; | 1523 | hwxmits[1] .sta_queue = &pxmitpriv->vi_pending; |
| 1520 | hwxmits[2] .sta_queue = &pxmitpriv->be_pending; | 1524 | hwxmits[2] .sta_queue = &pxmitpriv->be_pending; |
| 1521 | hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; | 1525 | hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; |
| 1526 | return _SUCCESS; | ||
| 1522 | } | 1527 | } |
| 1523 | 1528 | ||
| 1524 | void rtw_free_hwxmits(struct adapter *padapter) | 1529 | void rtw_free_hwxmits(struct adapter *padapter) |
diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h index 788f59c74ea1..ba7e15fbde72 100644 --- a/drivers/staging/rtl8188eu/include/rtw_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h | |||
| @@ -336,7 +336,7 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, | |||
| 336 | void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry); | 336 | void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry); |
| 337 | s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter); | 337 | s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter); |
| 338 | void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv); | 338 | void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv); |
| 339 | void rtw_alloc_hwxmits(struct adapter *padapter); | 339 | s32 rtw_alloc_hwxmits(struct adapter *padapter); |
| 340 | void rtw_free_hwxmits(struct adapter *padapter); | 340 | void rtw_free_hwxmits(struct adapter *padapter); |
| 341 | s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt); | 341 | s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt); |
| 342 | 342 | ||
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c index 1920d02f7c9f..8c36acedf507 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c | |||
| @@ -147,17 +147,9 @@ static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf) | |||
| 147 | 147 | ||
| 148 | static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf) | 148 | static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf) |
| 149 | { | 149 | { |
| 150 | u32 val; | ||
| 151 | void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); | ||
| 152 | struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; | 150 | struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; |
| 153 | 151 | ||
| 154 | if (pcmd->rsp && pcmd->rspsz > 0) | 152 | r8712_free_cmd_obj(pcmd); |
| 155 | memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz); | ||
| 156 | pcmd_callback = cmd_callback[pcmd->cmdcode].callback; | ||
| 157 | if (!pcmd_callback) | ||
| 158 | r8712_free_cmd_obj(pcmd); | ||
| 159 | else | ||
| 160 | pcmd_callback(padapter, pcmd); | ||
| 161 | return H2C_SUCCESS; | 153 | return H2C_SUCCESS; |
| 162 | } | 154 | } |
| 163 | 155 | ||
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.h b/drivers/staging/rtl8712/rtl8712_cmd.h index 92fb77666d44..1ef86b8c592f 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.h +++ b/drivers/staging/rtl8712/rtl8712_cmd.h | |||
| @@ -140,7 +140,7 @@ enum rtl8712_h2c_cmd { | |||
| 140 | static struct _cmd_callback cmd_callback[] = { | 140 | static struct _cmd_callback cmd_callback[] = { |
| 141 | {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ | 141 | {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ |
| 142 | {GEN_CMD_CODE(_Write_MACREG), NULL}, | 142 | {GEN_CMD_CODE(_Write_MACREG), NULL}, |
| 143 | {GEN_CMD_CODE(_Read_BBREG), &r8712_getbbrfreg_cmdrsp_callback}, | 143 | {GEN_CMD_CODE(_Read_BBREG), NULL}, |
| 144 | {GEN_CMD_CODE(_Write_BBREG), NULL}, | 144 | {GEN_CMD_CODE(_Write_BBREG), NULL}, |
| 145 | {GEN_CMD_CODE(_Read_RFREG), &r8712_getbbrfreg_cmdrsp_callback}, | 145 | {GEN_CMD_CODE(_Read_RFREG), &r8712_getbbrfreg_cmdrsp_callback}, |
| 146 | {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/ | 146 | {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/ |
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 094d61bcb469..b87f13a0b563 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c | |||
| @@ -260,7 +260,9 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) | |||
| 260 | } | 260 | } |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | rtw_alloc_hwxmits(padapter); | 263 | res = rtw_alloc_hwxmits(padapter); |
| 264 | if (res == _FAIL) | ||
| 265 | goto exit; | ||
| 264 | rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); | 266 | rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); |
| 265 | 267 | ||
| 266 | for (i = 0; i < 4; i++) { | 268 | for (i = 0; i < 4; i++) { |
| @@ -2144,7 +2146,7 @@ exit: | |||
| 2144 | return res; | 2146 | return res; |
| 2145 | } | 2147 | } |
| 2146 | 2148 | ||
| 2147 | void rtw_alloc_hwxmits(struct adapter *padapter) | 2149 | s32 rtw_alloc_hwxmits(struct adapter *padapter) |
| 2148 | { | 2150 | { |
| 2149 | struct hw_xmit *hwxmits; | 2151 | struct hw_xmit *hwxmits; |
| 2150 | struct xmit_priv *pxmitpriv = &padapter->xmitpriv; | 2152 | struct xmit_priv *pxmitpriv = &padapter->xmitpriv; |
| @@ -2155,10 +2157,8 @@ void rtw_alloc_hwxmits(struct adapter *padapter) | |||
| 2155 | 2157 | ||
| 2156 | pxmitpriv->hwxmits = rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); | 2158 | pxmitpriv->hwxmits = rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); |
| 2157 | 2159 | ||
| 2158 | if (pxmitpriv->hwxmits == NULL) { | 2160 | if (!pxmitpriv->hwxmits) |
| 2159 | DBG_871X("alloc hwxmits fail!...\n"); | 2161 | return _FAIL; |
| 2160 | return; | ||
| 2161 | } | ||
| 2162 | 2162 | ||
| 2163 | hwxmits = pxmitpriv->hwxmits; | 2163 | hwxmits = pxmitpriv->hwxmits; |
| 2164 | 2164 | ||
| @@ -2204,7 +2204,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter) | |||
| 2204 | 2204 | ||
| 2205 | } | 2205 | } |
| 2206 | 2206 | ||
| 2207 | 2207 | return _SUCCESS; | |
| 2208 | } | 2208 | } |
| 2209 | 2209 | ||
| 2210 | void rtw_free_hwxmits(struct adapter *padapter) | 2210 | void rtw_free_hwxmits(struct adapter *padapter) |
diff --git a/drivers/staging/rtl8723bs/include/rtw_xmit.h b/drivers/staging/rtl8723bs/include/rtw_xmit.h index 1b38b9182b31..37f42b2f22f1 100644 --- a/drivers/staging/rtl8723bs/include/rtw_xmit.h +++ b/drivers/staging/rtl8723bs/include/rtw_xmit.h | |||
| @@ -487,7 +487,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter); | |||
| 487 | void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv); | 487 | void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv); |
| 488 | 488 | ||
| 489 | 489 | ||
| 490 | void rtw_alloc_hwxmits(struct adapter *padapter); | 490 | s32 rtw_alloc_hwxmits(struct adapter *padapter); |
| 491 | void rtw_free_hwxmits(struct adapter *padapter); | 491 | void rtw_free_hwxmits(struct adapter *padapter); |
| 492 | 492 | ||
| 493 | 493 | ||
diff --git a/drivers/staging/rtlwifi/phydm/rtl_phydm.c b/drivers/staging/rtlwifi/phydm/rtl_phydm.c index 9930ed954abb..4cc77b2016e1 100644 --- a/drivers/staging/rtlwifi/phydm/rtl_phydm.c +++ b/drivers/staging/rtlwifi/phydm/rtl_phydm.c | |||
| @@ -180,6 +180,8 @@ static int rtl_phydm_init_priv(struct rtl_priv *rtlpriv, | |||
| 180 | 180 | ||
| 181 | rtlpriv->phydm.internal = | 181 | rtlpriv->phydm.internal = |
| 182 | kzalloc(sizeof(struct phy_dm_struct), GFP_KERNEL); | 182 | kzalloc(sizeof(struct phy_dm_struct), GFP_KERNEL); |
| 183 | if (!rtlpriv->phydm.internal) | ||
| 184 | return 0; | ||
| 183 | 185 | ||
| 184 | _rtl_phydm_init_com_info(rtlpriv, ic, params); | 186 | _rtl_phydm_init_com_info(rtlpriv, ic, params); |
| 185 | 187 | ||
diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c b/drivers/staging/rtlwifi/rtl8822be/fw.c index f061dd1382aa..cf6b7a80b753 100644 --- a/drivers/staging/rtlwifi/rtl8822be/fw.c +++ b/drivers/staging/rtlwifi/rtl8822be/fw.c | |||
| @@ -743,6 +743,8 @@ void rtl8822be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished) | |||
| 743 | u1_rsvd_page_loc, 3); | 743 | u1_rsvd_page_loc, 3); |
| 744 | 744 | ||
| 745 | skb = dev_alloc_skb(totalpacketlen); | 745 | skb = dev_alloc_skb(totalpacketlen); |
| 746 | if (!skb) | ||
| 747 | return; | ||
| 746 | memcpy((u8 *)skb_put(skb, totalpacketlen), &reserved_page_packet, | 748 | memcpy((u8 *)skb_put(skb, totalpacketlen), &reserved_page_packet, |
| 747 | totalpacketlen); | 749 | totalpacketlen); |
| 748 | 750 | ||
diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c index edff6ce85655..9d85a3a1af4c 100644 --- a/drivers/staging/speakup/speakup_soft.c +++ b/drivers/staging/speakup/speakup_soft.c | |||
| @@ -210,12 +210,15 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count, | |||
| 210 | return -EINVAL; | 210 | return -EINVAL; |
| 211 | 211 | ||
| 212 | spin_lock_irqsave(&speakup_info.spinlock, flags); | 212 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
| 213 | synth_soft.alive = 1; | ||
| 213 | while (1) { | 214 | while (1) { |
| 214 | prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE); | 215 | prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE); |
| 215 | if (!unicode) | 216 | if (synth_current() == &synth_soft) { |
| 216 | synth_buffer_skip_nonlatin1(); | 217 | if (!unicode) |
| 217 | if (!synth_buffer_empty() || speakup_info.flushing) | 218 | synth_buffer_skip_nonlatin1(); |
| 218 | break; | 219 | if (!synth_buffer_empty() || speakup_info.flushing) |
| 220 | break; | ||
| 221 | } | ||
| 219 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); | 222 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
| 220 | if (fp->f_flags & O_NONBLOCK) { | 223 | if (fp->f_flags & O_NONBLOCK) { |
| 221 | finish_wait(&speakup_event, &wait); | 224 | finish_wait(&speakup_event, &wait); |
| @@ -235,6 +238,8 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count, | |||
| 235 | 238 | ||
| 236 | /* Keep 3 bytes available for a 16bit UTF-8-encoded character */ | 239 | /* Keep 3 bytes available for a 16bit UTF-8-encoded character */ |
| 237 | while (chars_sent <= count - bytes_per_ch) { | 240 | while (chars_sent <= count - bytes_per_ch) { |
| 241 | if (synth_current() != &synth_soft) | ||
| 242 | break; | ||
| 238 | if (speakup_info.flushing) { | 243 | if (speakup_info.flushing) { |
| 239 | speakup_info.flushing = 0; | 244 | speakup_info.flushing = 0; |
| 240 | ch = '\x18'; | 245 | ch = '\x18'; |
| @@ -331,7 +336,8 @@ static __poll_t softsynth_poll(struct file *fp, struct poll_table_struct *wait) | |||
| 331 | poll_wait(fp, &speakup_event, wait); | 336 | poll_wait(fp, &speakup_event, wait); |
| 332 | 337 | ||
| 333 | spin_lock_irqsave(&speakup_info.spinlock, flags); | 338 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
| 334 | if (!synth_buffer_empty() || speakup_info.flushing) | 339 | if (synth_current() == &synth_soft && |
| 340 | (!synth_buffer_empty() || speakup_info.flushing)) | ||
| 335 | ret = EPOLLIN | EPOLLRDNORM; | 341 | ret = EPOLLIN | EPOLLRDNORM; |
| 336 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); | 342 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
| 337 | return ret; | 343 | return ret; |
diff --git a/drivers/staging/speakup/spk_priv.h b/drivers/staging/speakup/spk_priv.h index c8e688878fc7..ac6a74883af4 100644 --- a/drivers/staging/speakup/spk_priv.h +++ b/drivers/staging/speakup/spk_priv.h | |||
| @@ -74,6 +74,7 @@ int synth_request_region(unsigned long start, unsigned long n); | |||
| 74 | int synth_release_region(unsigned long start, unsigned long n); | 74 | int synth_release_region(unsigned long start, unsigned long n); |
| 75 | int synth_add(struct spk_synth *in_synth); | 75 | int synth_add(struct spk_synth *in_synth); |
| 76 | void synth_remove(struct spk_synth *in_synth); | 76 | void synth_remove(struct spk_synth *in_synth); |
| 77 | struct spk_synth *synth_current(void); | ||
| 77 | 78 | ||
| 78 | extern struct speakup_info_t speakup_info; | 79 | extern struct speakup_info_t speakup_info; |
| 79 | 80 | ||
diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c index 25f259ee4ffc..3568bfb89912 100644 --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c | |||
| @@ -481,4 +481,10 @@ void synth_remove(struct spk_synth *in_synth) | |||
| 481 | } | 481 | } |
| 482 | EXPORT_SYMBOL_GPL(synth_remove); | 482 | EXPORT_SYMBOL_GPL(synth_remove); |
| 483 | 483 | ||
| 484 | struct spk_synth *synth_current(void) | ||
| 485 | { | ||
| 486 | return synth; | ||
| 487 | } | ||
| 488 | EXPORT_SYMBOL_GPL(synth_current); | ||
| 489 | |||
| 484 | short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM }; | 490 | short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM }; |
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 804daf83be35..064d0db4c51e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | |||
| @@ -3513,6 +3513,7 @@ static int vchiq_probe(struct platform_device *pdev) | |||
| 3513 | struct device_node *fw_node; | 3513 | struct device_node *fw_node; |
| 3514 | const struct of_device_id *of_id; | 3514 | const struct of_device_id *of_id; |
| 3515 | struct vchiq_drvdata *drvdata; | 3515 | struct vchiq_drvdata *drvdata; |
| 3516 | struct device *vchiq_dev; | ||
| 3516 | int err; | 3517 | int err; |
| 3517 | 3518 | ||
| 3518 | of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); | 3519 | of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); |
| @@ -3547,9 +3548,12 @@ static int vchiq_probe(struct platform_device *pdev) | |||
| 3547 | goto failed_platform_init; | 3548 | goto failed_platform_init; |
| 3548 | } | 3549 | } |
| 3549 | 3550 | ||
| 3550 | if (IS_ERR(device_create(vchiq_class, &pdev->dev, vchiq_devid, | 3551 | vchiq_dev = device_create(vchiq_class, &pdev->dev, vchiq_devid, NULL, |
| 3551 | NULL, "vchiq"))) | 3552 | "vchiq"); |
| 3553 | if (IS_ERR(vchiq_dev)) { | ||
| 3554 | err = PTR_ERR(vchiq_dev); | ||
| 3552 | goto failed_device_create; | 3555 | goto failed_device_create; |
| 3556 | } | ||
| 3553 | 3557 | ||
| 3554 | vchiq_debugfs_init(); | 3558 | vchiq_debugfs_init(); |
| 3555 | 3559 | ||
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index b370985b58a1..c6bb4aaf9bd0 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c | |||
| @@ -1033,8 +1033,6 @@ static void vnt_interrupt_process(struct vnt_private *priv) | |||
| 1033 | return; | 1033 | return; |
| 1034 | } | 1034 | } |
| 1035 | 1035 | ||
| 1036 | MACvIntDisable(priv->PortOffset); | ||
| 1037 | |||
| 1038 | spin_lock_irqsave(&priv->lock, flags); | 1036 | spin_lock_irqsave(&priv->lock, flags); |
| 1039 | 1037 | ||
| 1040 | /* Read low level stats */ | 1038 | /* Read low level stats */ |
| @@ -1122,8 +1120,6 @@ static void vnt_interrupt_process(struct vnt_private *priv) | |||
| 1122 | } | 1120 | } |
| 1123 | 1121 | ||
| 1124 | spin_unlock_irqrestore(&priv->lock, flags); | 1122 | spin_unlock_irqrestore(&priv->lock, flags); |
| 1125 | |||
| 1126 | MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE); | ||
| 1127 | } | 1123 | } |
| 1128 | 1124 | ||
| 1129 | static void vnt_interrupt_work(struct work_struct *work) | 1125 | static void vnt_interrupt_work(struct work_struct *work) |
| @@ -1133,14 +1129,17 @@ static void vnt_interrupt_work(struct work_struct *work) | |||
| 1133 | 1129 | ||
| 1134 | if (priv->vif) | 1130 | if (priv->vif) |
| 1135 | vnt_interrupt_process(priv); | 1131 | vnt_interrupt_process(priv); |
| 1132 | |||
| 1133 | MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE); | ||
| 1136 | } | 1134 | } |
| 1137 | 1135 | ||
| 1138 | static irqreturn_t vnt_interrupt(int irq, void *arg) | 1136 | static irqreturn_t vnt_interrupt(int irq, void *arg) |
| 1139 | { | 1137 | { |
| 1140 | struct vnt_private *priv = arg; | 1138 | struct vnt_private *priv = arg; |
| 1141 | 1139 | ||
| 1142 | if (priv->vif) | 1140 | schedule_work(&priv->interrupt_work); |
| 1143 | schedule_work(&priv->interrupt_work); | 1141 | |
| 1142 | MACvIntDisable(priv->PortOffset); | ||
| 1144 | 1143 | ||
| 1145 | return IRQ_HANDLED; | 1144 | return IRQ_HANDLED; |
| 1146 | } | 1145 | } |
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c index db5df3d54818..3bdd56a1021b 100644 --- a/drivers/tty/serial/ar933x_uart.c +++ b/drivers/tty/serial/ar933x_uart.c | |||
| @@ -49,11 +49,6 @@ struct ar933x_uart_port { | |||
| 49 | struct clk *clk; | 49 | struct clk *clk; |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | static inline bool ar933x_uart_console_enabled(void) | ||
| 53 | { | ||
| 54 | return IS_ENABLED(CONFIG_SERIAL_AR933X_CONSOLE); | ||
| 55 | } | ||
| 56 | |||
| 57 | static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, | 52 | static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, |
| 58 | int offset) | 53 | int offset) |
| 59 | { | 54 | { |
| @@ -508,6 +503,7 @@ static const struct uart_ops ar933x_uart_ops = { | |||
| 508 | .verify_port = ar933x_uart_verify_port, | 503 | .verify_port = ar933x_uart_verify_port, |
| 509 | }; | 504 | }; |
| 510 | 505 | ||
| 506 | #ifdef CONFIG_SERIAL_AR933X_CONSOLE | ||
| 511 | static struct ar933x_uart_port * | 507 | static struct ar933x_uart_port * |
| 512 | ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS]; | 508 | ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS]; |
| 513 | 509 | ||
| @@ -604,14 +600,7 @@ static struct console ar933x_uart_console = { | |||
| 604 | .index = -1, | 600 | .index = -1, |
| 605 | .data = &ar933x_uart_driver, | 601 | .data = &ar933x_uart_driver, |
| 606 | }; | 602 | }; |
| 607 | 603 | #endif /* CONFIG_SERIAL_AR933X_CONSOLE */ | |
| 608 | static void ar933x_uart_add_console_port(struct ar933x_uart_port *up) | ||
| 609 | { | ||
| 610 | if (!ar933x_uart_console_enabled()) | ||
| 611 | return; | ||
| 612 | |||
| 613 | ar933x_console_ports[up->port.line] = up; | ||
| 614 | } | ||
| 615 | 604 | ||
| 616 | static struct uart_driver ar933x_uart_driver = { | 605 | static struct uart_driver ar933x_uart_driver = { |
| 617 | .owner = THIS_MODULE, | 606 | .owner = THIS_MODULE, |
| @@ -700,7 +689,9 @@ static int ar933x_uart_probe(struct platform_device *pdev) | |||
| 700 | baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP); | 689 | baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP); |
| 701 | up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD); | 690 | up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD); |
| 702 | 691 | ||
| 703 | ar933x_uart_add_console_port(up); | 692 | #ifdef CONFIG_SERIAL_AR933X_CONSOLE |
| 693 | ar933x_console_ports[up->port.line] = up; | ||
| 694 | #endif | ||
| 704 | 695 | ||
| 705 | ret = uart_add_one_port(&ar933x_uart_driver, &up->port); | 696 | ret = uart_add_one_port(&ar933x_uart_driver, &up->port); |
| 706 | if (ret) | 697 | if (ret) |
| @@ -749,8 +740,9 @@ static int __init ar933x_uart_init(void) | |||
| 749 | { | 740 | { |
| 750 | int ret; | 741 | int ret; |
| 751 | 742 | ||
| 752 | if (ar933x_uart_console_enabled()) | 743 | #ifdef CONFIG_SERIAL_AR933X_CONSOLE |
| 753 | ar933x_uart_driver.cons = &ar933x_uart_console; | 744 | ar933x_uart_driver.cons = &ar933x_uart_console; |
| 745 | #endif | ||
| 754 | 746 | ||
| 755 | ret = uart_register_driver(&ar933x_uart_driver); | 747 | ret = uart_register_driver(&ar933x_uart_driver); |
| 756 | if (ret) | 748 | if (ret) |
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 05147fe24343..0b4f36905321 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
| @@ -166,6 +166,8 @@ struct atmel_uart_port { | |||
| 166 | unsigned int pending_status; | 166 | unsigned int pending_status; |
| 167 | spinlock_t lock_suspended; | 167 | spinlock_t lock_suspended; |
| 168 | 168 | ||
| 169 | bool hd_start_rx; /* can start RX during half-duplex operation */ | ||
| 170 | |||
| 169 | /* ISO7816 */ | 171 | /* ISO7816 */ |
| 170 | unsigned int fidi_min; | 172 | unsigned int fidi_min; |
| 171 | unsigned int fidi_max; | 173 | unsigned int fidi_max; |
| @@ -231,6 +233,13 @@ static inline void atmel_uart_write_char(struct uart_port *port, u8 value) | |||
| 231 | __raw_writeb(value, port->membase + ATMEL_US_THR); | 233 | __raw_writeb(value, port->membase + ATMEL_US_THR); |
| 232 | } | 234 | } |
| 233 | 235 | ||
| 236 | static inline int atmel_uart_is_half_duplex(struct uart_port *port) | ||
| 237 | { | ||
| 238 | return ((port->rs485.flags & SER_RS485_ENABLED) && | ||
| 239 | !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || | ||
| 240 | (port->iso7816.flags & SER_ISO7816_ENABLED); | ||
| 241 | } | ||
| 242 | |||
| 234 | #ifdef CONFIG_SERIAL_ATMEL_PDC | 243 | #ifdef CONFIG_SERIAL_ATMEL_PDC |
| 235 | static bool atmel_use_pdc_rx(struct uart_port *port) | 244 | static bool atmel_use_pdc_rx(struct uart_port *port) |
| 236 | { | 245 | { |
| @@ -608,10 +617,9 @@ static void atmel_stop_tx(struct uart_port *port) | |||
| 608 | /* Disable interrupts */ | 617 | /* Disable interrupts */ |
| 609 | atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); | 618 | atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); |
| 610 | 619 | ||
| 611 | if (((port->rs485.flags & SER_RS485_ENABLED) && | 620 | if (atmel_uart_is_half_duplex(port)) |
| 612 | !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || | ||
| 613 | port->iso7816.flags & SER_ISO7816_ENABLED) | ||
| 614 | atmel_start_rx(port); | 621 | atmel_start_rx(port); |
| 622 | |||
| 615 | } | 623 | } |
| 616 | 624 | ||
| 617 | /* | 625 | /* |
| @@ -628,9 +636,7 @@ static void atmel_start_tx(struct uart_port *port) | |||
| 628 | return; | 636 | return; |
| 629 | 637 | ||
| 630 | if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port)) | 638 | if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port)) |
| 631 | if (((port->rs485.flags & SER_RS485_ENABLED) && | 639 | if (atmel_uart_is_half_duplex(port)) |
| 632 | !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || | ||
| 633 | port->iso7816.flags & SER_ISO7816_ENABLED) | ||
| 634 | atmel_stop_rx(port); | 640 | atmel_stop_rx(port); |
| 635 | 641 | ||
| 636 | if (atmel_use_pdc_tx(port)) | 642 | if (atmel_use_pdc_tx(port)) |
| @@ -928,11 +934,14 @@ static void atmel_complete_tx_dma(void *arg) | |||
| 928 | */ | 934 | */ |
| 929 | if (!uart_circ_empty(xmit)) | 935 | if (!uart_circ_empty(xmit)) |
| 930 | atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); | 936 | atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); |
| 931 | else if (((port->rs485.flags & SER_RS485_ENABLED) && | 937 | else if (atmel_uart_is_half_duplex(port)) { |
| 932 | !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || | 938 | /* |
| 933 | port->iso7816.flags & SER_ISO7816_ENABLED) { | 939 | * DMA done, re-enable TXEMPTY and signal that we can stop |
| 934 | /* DMA done, stop TX, start RX for RS485 */ | 940 | * TX and start RX for RS485 |
| 935 | atmel_start_rx(port); | 941 | */ |
| 942 | atmel_port->hd_start_rx = true; | ||
| 943 | atmel_uart_writel(port, ATMEL_US_IER, | ||
| 944 | atmel_port->tx_done_mask); | ||
| 936 | } | 945 | } |
| 937 | 946 | ||
| 938 | spin_unlock_irqrestore(&port->lock, flags); | 947 | spin_unlock_irqrestore(&port->lock, flags); |
| @@ -1288,6 +1297,10 @@ static int atmel_prepare_rx_dma(struct uart_port *port) | |||
| 1288 | sg_dma_len(&atmel_port->sg_rx)/2, | 1297 | sg_dma_len(&atmel_port->sg_rx)/2, |
| 1289 | DMA_DEV_TO_MEM, | 1298 | DMA_DEV_TO_MEM, |
| 1290 | DMA_PREP_INTERRUPT); | 1299 | DMA_PREP_INTERRUPT); |
| 1300 | if (!desc) { | ||
| 1301 | dev_err(port->dev, "Preparing DMA cyclic failed\n"); | ||
| 1302 | goto chan_err; | ||
| 1303 | } | ||
| 1291 | desc->callback = atmel_complete_rx_dma; | 1304 | desc->callback = atmel_complete_rx_dma; |
| 1292 | desc->callback_param = port; | 1305 | desc->callback_param = port; |
| 1293 | atmel_port->desc_rx = desc; | 1306 | atmel_port->desc_rx = desc; |
| @@ -1376,9 +1389,20 @@ atmel_handle_transmit(struct uart_port *port, unsigned int pending) | |||
| 1376 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | 1389 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); |
| 1377 | 1390 | ||
| 1378 | if (pending & atmel_port->tx_done_mask) { | 1391 | if (pending & atmel_port->tx_done_mask) { |
| 1379 | /* Either PDC or interrupt transmission */ | ||
| 1380 | atmel_uart_writel(port, ATMEL_US_IDR, | 1392 | atmel_uart_writel(port, ATMEL_US_IDR, |
| 1381 | atmel_port->tx_done_mask); | 1393 | atmel_port->tx_done_mask); |
| 1394 | |||
| 1395 | /* Start RX if flag was set and FIFO is empty */ | ||
| 1396 | if (atmel_port->hd_start_rx) { | ||
| 1397 | if (!(atmel_uart_readl(port, ATMEL_US_CSR) | ||
| 1398 | & ATMEL_US_TXEMPTY)) | ||
| 1399 | dev_warn(port->dev, "Should start RX, but TX fifo is not empty\n"); | ||
| 1400 | |||
| 1401 | atmel_port->hd_start_rx = false; | ||
| 1402 | atmel_start_rx(port); | ||
| 1403 | return; | ||
| 1404 | } | ||
| 1405 | |||
| 1382 | atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); | 1406 | atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); |
| 1383 | } | 1407 | } |
| 1384 | } | 1408 | } |
| @@ -1508,9 +1532,7 @@ static void atmel_tx_pdc(struct uart_port *port) | |||
| 1508 | atmel_uart_writel(port, ATMEL_US_IER, | 1532 | atmel_uart_writel(port, ATMEL_US_IER, |
| 1509 | atmel_port->tx_done_mask); | 1533 | atmel_port->tx_done_mask); |
| 1510 | } else { | 1534 | } else { |
| 1511 | if (((port->rs485.flags & SER_RS485_ENABLED) && | 1535 | if (atmel_uart_is_half_duplex(port)) { |
| 1512 | !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || | ||
| 1513 | port->iso7816.flags & SER_ISO7816_ENABLED) { | ||
| 1514 | /* DMA done, stop TX, start RX for RS485 */ | 1536 | /* DMA done, stop TX, start RX for RS485 */ |
| 1515 | atmel_start_rx(port); | 1537 | atmel_start_rx(port); |
| 1516 | } | 1538 | } |
diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 6fb312e7af71..bfe5e9e034ec 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c | |||
| @@ -148,8 +148,10 @@ static int configure_kgdboc(void) | |||
| 148 | char *cptr = config; | 148 | char *cptr = config; |
| 149 | struct console *cons; | 149 | struct console *cons; |
| 150 | 150 | ||
| 151 | if (!strlen(config) || isspace(config[0])) | 151 | if (!strlen(config) || isspace(config[0])) { |
| 152 | err = 0; | ||
| 152 | goto noconfig; | 153 | goto noconfig; |
| 154 | } | ||
| 153 | 155 | ||
| 154 | kgdboc_io_ops.is_console = 0; | 156 | kgdboc_io_ops.is_console = 0; |
| 155 | kgdb_tty_driver = NULL; | 157 | kgdb_tty_driver = NULL; |
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index f5bdde405627..450ba6d7996c 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c | |||
| @@ -1415,6 +1415,8 @@ static int max310x_spi_probe(struct spi_device *spi) | |||
| 1415 | if (spi->dev.of_node) { | 1415 | if (spi->dev.of_node) { |
| 1416 | const struct of_device_id *of_id = | 1416 | const struct of_device_id *of_id = |
| 1417 | of_match_device(max310x_dt_ids, &spi->dev); | 1417 | of_match_device(max310x_dt_ids, &spi->dev); |
| 1418 | if (!of_id) | ||
| 1419 | return -ENODEV; | ||
| 1418 | 1420 | ||
| 1419 | devtype = (struct max310x_devtype *)of_id->data; | 1421 | devtype = (struct max310x_devtype *)of_id->data; |
| 1420 | } else { | 1422 | } else { |
diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c index 231f751d1ef4..7e7b1559fa36 100644 --- a/drivers/tty/serial/mvebu-uart.c +++ b/drivers/tty/serial/mvebu-uart.c | |||
| @@ -810,6 +810,9 @@ static int mvebu_uart_probe(struct platform_device *pdev) | |||
| 810 | return -EINVAL; | 810 | return -EINVAL; |
| 811 | } | 811 | } |
| 812 | 812 | ||
| 813 | if (!match) | ||
| 814 | return -ENODEV; | ||
| 815 | |||
| 813 | /* Assume that all UART ports have a DT alias or none has */ | 816 | /* Assume that all UART ports have a DT alias or none has */ |
| 814 | id = of_alias_get_id(pdev->dev.of_node, "serial"); | 817 | id = of_alias_get_id(pdev->dev.of_node, "serial"); |
| 815 | if (!pdev->dev.of_node || id < 0) | 818 | if (!pdev->dev.of_node || id < 0) |
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index 27235a526cce..4c188f4079b3 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c | |||
| @@ -1686,6 +1686,10 @@ static int mxs_auart_probe(struct platform_device *pdev) | |||
| 1686 | 1686 | ||
| 1687 | s->port.mapbase = r->start; | 1687 | s->port.mapbase = r->start; |
| 1688 | s->port.membase = ioremap(r->start, resource_size(r)); | 1688 | s->port.membase = ioremap(r->start, resource_size(r)); |
| 1689 | if (!s->port.membase) { | ||
| 1690 | ret = -ENOMEM; | ||
| 1691 | goto out_disable_clks; | ||
| 1692 | } | ||
| 1689 | s->port.ops = &mxs_auart_ops; | 1693 | s->port.ops = &mxs_auart_ops; |
| 1690 | s->port.iotype = UPIO_MEM; | 1694 | s->port.iotype = UPIO_MEM; |
| 1691 | s->port.fifosize = MXS_AUART_FIFO_SIZE; | 1695 | s->port.fifosize = MXS_AUART_FIFO_SIZE; |
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 3bcec1c20219..35e5f9c5d5be 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c | |||
| @@ -1050,7 +1050,7 @@ static int __init qcom_geni_console_setup(struct console *co, char *options) | |||
| 1050 | { | 1050 | { |
| 1051 | struct uart_port *uport; | 1051 | struct uart_port *uport; |
| 1052 | struct qcom_geni_serial_port *port; | 1052 | struct qcom_geni_serial_port *port; |
| 1053 | int baud; | 1053 | int baud = 9600; |
| 1054 | int bits = 8; | 1054 | int bits = 8; |
| 1055 | int parity = 'n'; | 1055 | int parity = 'n'; |
| 1056 | int flow = 'n'; | 1056 | int flow = 'n'; |
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 635178cf3eed..09a183dfc526 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c | |||
| @@ -1507,7 +1507,7 @@ static int __init sc16is7xx_init(void) | |||
| 1507 | ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver); | 1507 | ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver); |
| 1508 | if (ret < 0) { | 1508 | if (ret < 0) { |
| 1509 | pr_err("failed to init sc16is7xx i2c --> %d\n", ret); | 1509 | pr_err("failed to init sc16is7xx i2c --> %d\n", ret); |
| 1510 | return ret; | 1510 | goto err_i2c; |
| 1511 | } | 1511 | } |
| 1512 | #endif | 1512 | #endif |
| 1513 | 1513 | ||
| @@ -1515,10 +1515,18 @@ static int __init sc16is7xx_init(void) | |||
| 1515 | ret = spi_register_driver(&sc16is7xx_spi_uart_driver); | 1515 | ret = spi_register_driver(&sc16is7xx_spi_uart_driver); |
| 1516 | if (ret < 0) { | 1516 | if (ret < 0) { |
| 1517 | pr_err("failed to init sc16is7xx spi --> %d\n", ret); | 1517 | pr_err("failed to init sc16is7xx spi --> %d\n", ret); |
| 1518 | return ret; | 1518 | goto err_spi; |
| 1519 | } | 1519 | } |
| 1520 | #endif | 1520 | #endif |
| 1521 | return ret; | 1521 | return ret; |
| 1522 | |||
| 1523 | err_spi: | ||
| 1524 | #ifdef CONFIG_SERIAL_SC16IS7XX_I2C | ||
| 1525 | i2c_del_driver(&sc16is7xx_i2c_uart_driver); | ||
| 1526 | #endif | ||
| 1527 | err_i2c: | ||
| 1528 | uart_unregister_driver(&sc16is7xx_uart); | ||
| 1529 | return ret; | ||
| 1522 | } | 1530 | } |
| 1523 | module_init(sc16is7xx_init); | 1531 | module_init(sc16is7xx_init); |
| 1524 | 1532 | ||
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 060fcd42b6d5..2d1c626312cd 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c | |||
| @@ -838,19 +838,9 @@ static void sci_transmit_chars(struct uart_port *port) | |||
| 838 | 838 | ||
| 839 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 839 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
| 840 | uart_write_wakeup(port); | 840 | uart_write_wakeup(port); |
| 841 | if (uart_circ_empty(xmit)) { | 841 | if (uart_circ_empty(xmit)) |
| 842 | sci_stop_tx(port); | 842 | sci_stop_tx(port); |
| 843 | } else { | ||
| 844 | ctrl = serial_port_in(port, SCSCR); | ||
| 845 | |||
| 846 | if (port->type != PORT_SCI) { | ||
| 847 | serial_port_in(port, SCxSR); /* Dummy read */ | ||
| 848 | sci_clear_SCxSR(port, SCxSR_TDxE_CLEAR(port)); | ||
| 849 | } | ||
| 850 | 843 | ||
| 851 | ctrl |= SCSCR_TIE; | ||
| 852 | serial_port_out(port, SCSCR, ctrl); | ||
| 853 | } | ||
| 854 | } | 844 | } |
| 855 | 845 | ||
| 856 | /* On SH3, SCIF may read end-of-break as a space->mark char */ | 846 | /* On SH3, SCIF may read end-of-break as a space->mark char */ |
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 044c3cbdcfa4..a9e12b3bc31d 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c | |||
| @@ -325,7 +325,7 @@ static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) | |||
| 325 | if (tty && C_HUPCL(tty)) | 325 | if (tty && C_HUPCL(tty)) |
| 326 | tty_port_lower_dtr_rts(port); | 326 | tty_port_lower_dtr_rts(port); |
| 327 | 327 | ||
| 328 | if (port->ops->shutdown) | 328 | if (port->ops && port->ops->shutdown) |
| 329 | port->ops->shutdown(port); | 329 | port->ops->shutdown(port); |
| 330 | } | 330 | } |
| 331 | out: | 331 | out: |
| @@ -398,7 +398,7 @@ EXPORT_SYMBOL_GPL(tty_port_tty_wakeup); | |||
| 398 | */ | 398 | */ |
| 399 | int tty_port_carrier_raised(struct tty_port *port) | 399 | int tty_port_carrier_raised(struct tty_port *port) |
| 400 | { | 400 | { |
| 401 | if (port->ops->carrier_raised == NULL) | 401 | if (!port->ops || !port->ops->carrier_raised) |
| 402 | return 1; | 402 | return 1; |
| 403 | return port->ops->carrier_raised(port); | 403 | return port->ops->carrier_raised(port); |
| 404 | } | 404 | } |
| @@ -414,7 +414,7 @@ EXPORT_SYMBOL(tty_port_carrier_raised); | |||
| 414 | */ | 414 | */ |
| 415 | void tty_port_raise_dtr_rts(struct tty_port *port) | 415 | void tty_port_raise_dtr_rts(struct tty_port *port) |
| 416 | { | 416 | { |
| 417 | if (port->ops->dtr_rts) | 417 | if (port->ops && port->ops->dtr_rts) |
| 418 | port->ops->dtr_rts(port, 1); | 418 | port->ops->dtr_rts(port, 1); |
| 419 | } | 419 | } |
| 420 | EXPORT_SYMBOL(tty_port_raise_dtr_rts); | 420 | EXPORT_SYMBOL(tty_port_raise_dtr_rts); |
| @@ -429,7 +429,7 @@ EXPORT_SYMBOL(tty_port_raise_dtr_rts); | |||
| 429 | */ | 429 | */ |
| 430 | void tty_port_lower_dtr_rts(struct tty_port *port) | 430 | void tty_port_lower_dtr_rts(struct tty_port *port) |
| 431 | { | 431 | { |
| 432 | if (port->ops->dtr_rts) | 432 | if (port->ops && port->ops->dtr_rts) |
| 433 | port->ops->dtr_rts(port, 0); | 433 | port->ops->dtr_rts(port, 0); |
| 434 | } | 434 | } |
| 435 | EXPORT_SYMBOL(tty_port_lower_dtr_rts); | 435 | EXPORT_SYMBOL(tty_port_lower_dtr_rts); |
| @@ -684,7 +684,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty, | |||
| 684 | 684 | ||
| 685 | if (!tty_port_initialized(port)) { | 685 | if (!tty_port_initialized(port)) { |
| 686 | clear_bit(TTY_IO_ERROR, &tty->flags); | 686 | clear_bit(TTY_IO_ERROR, &tty->flags); |
| 687 | if (port->ops->activate) { | 687 | if (port->ops && port->ops->activate) { |
| 688 | int retval = port->ops->activate(port, tty); | 688 | int retval = port->ops->activate(port, tty); |
| 689 | if (retval) { | 689 | if (retval) { |
| 690 | mutex_unlock(&port->mutex); | 690 | mutex_unlock(&port->mutex); |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 739f8960811a..ec666eb4b7b4 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
| @@ -558,10 +558,8 @@ static void acm_softint(struct work_struct *work) | |||
| 558 | clear_bit(EVENT_RX_STALL, &acm->flags); | 558 | clear_bit(EVENT_RX_STALL, &acm->flags); |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | if (test_bit(EVENT_TTY_WAKEUP, &acm->flags)) { | 561 | if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags)) |
| 562 | tty_port_tty_wakeup(&acm->port); | 562 | tty_port_tty_wakeup(&acm->port); |
| 563 | clear_bit(EVENT_TTY_WAKEUP, &acm->flags); | ||
| 564 | } | ||
| 565 | } | 563 | } |
| 566 | 564 | ||
| 567 | /* | 565 | /* |
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 48277bbc15e4..73c8e6591746 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c | |||
| @@ -145,6 +145,8 @@ enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0) | |||
| 145 | 145 | ||
| 146 | do { | 146 | do { |
| 147 | controller = of_find_node_with_property(controller, "phys"); | 147 | controller = of_find_node_with_property(controller, "phys"); |
| 148 | if (!of_device_is_available(controller)) | ||
| 149 | continue; | ||
| 148 | index = 0; | 150 | index = 0; |
| 149 | do { | 151 | do { |
| 150 | if (arg0 == -1) { | 152 | if (arg0 == -1) { |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 3189181bb628..975d7c1288e3 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
| @@ -2742,6 +2742,9 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
| 2742 | retval = usb_phy_roothub_set_mode(hcd->phy_roothub, | 2742 | retval = usb_phy_roothub_set_mode(hcd->phy_roothub, |
| 2743 | PHY_MODE_USB_HOST_SS); | 2743 | PHY_MODE_USB_HOST_SS); |
| 2744 | if (retval) | 2744 | if (retval) |
| 2745 | retval = usb_phy_roothub_set_mode(hcd->phy_roothub, | ||
| 2746 | PHY_MODE_USB_HOST); | ||
| 2747 | if (retval) | ||
| 2745 | goto err_usb_phy_roothub_power_on; | 2748 | goto err_usb_phy_roothub_power_on; |
| 2746 | 2749 | ||
| 2747 | retval = usb_phy_roothub_power_on(hcd->phy_roothub); | 2750 | retval = usb_phy_roothub_power_on(hcd->phy_roothub); |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index fdc6e4e403e8..8cced3609e24 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa | 29 | #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa |
| 30 | #define PCI_DEVICE_ID_INTEL_APL 0x5aaa | 30 | #define PCI_DEVICE_ID_INTEL_APL 0x5aaa |
| 31 | #define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 | 31 | #define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 |
| 32 | #define PCI_DEVICE_ID_INTEL_CMLH 0x02ee | ||
| 32 | #define PCI_DEVICE_ID_INTEL_GLK 0x31aa | 33 | #define PCI_DEVICE_ID_INTEL_GLK 0x31aa |
| 33 | #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee | 34 | #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee |
| 34 | #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e | 35 | #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e |
| @@ -305,6 +306,9 @@ static const struct pci_device_id dwc3_pci_id_table[] = { | |||
| 305 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD), | 306 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD), |
| 306 | (kernel_ulong_t) &dwc3_pci_mrfld_properties, }, | 307 | (kernel_ulong_t) &dwc3_pci_mrfld_properties, }, |
| 307 | 308 | ||
| 309 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CMLH), | ||
| 310 | (kernel_ulong_t) &dwc3_pci_intel_properties, }, | ||
| 311 | |||
| 308 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SPTLP), | 312 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SPTLP), |
| 309 | (kernel_ulong_t) &dwc3_pci_intel_properties, }, | 313 | (kernel_ulong_t) &dwc3_pci_intel_properties, }, |
| 310 | 314 | ||
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index 75b113a5b25c..f3816a5c861e 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c | |||
| @@ -391,20 +391,20 @@ try_again: | |||
| 391 | req->complete = f_hidg_req_complete; | 391 | req->complete = f_hidg_req_complete; |
| 392 | req->context = hidg; | 392 | req->context = hidg; |
| 393 | 393 | ||
| 394 | spin_unlock_irqrestore(&hidg->write_spinlock, flags); | ||
| 395 | |||
| 394 | status = usb_ep_queue(hidg->in_ep, req, GFP_ATOMIC); | 396 | status = usb_ep_queue(hidg->in_ep, req, GFP_ATOMIC); |
| 395 | if (status < 0) { | 397 | if (status < 0) { |
| 396 | ERROR(hidg->func.config->cdev, | 398 | ERROR(hidg->func.config->cdev, |
| 397 | "usb_ep_queue error on int endpoint %zd\n", status); | 399 | "usb_ep_queue error on int endpoint %zd\n", status); |
| 398 | goto release_write_pending_unlocked; | 400 | goto release_write_pending; |
| 399 | } else { | 401 | } else { |
| 400 | status = count; | 402 | status = count; |
| 401 | } | 403 | } |
| 402 | spin_unlock_irqrestore(&hidg->write_spinlock, flags); | ||
| 403 | 404 | ||
| 404 | return status; | 405 | return status; |
| 405 | release_write_pending: | 406 | release_write_pending: |
| 406 | spin_lock_irqsave(&hidg->write_spinlock, flags); | 407 | spin_lock_irqsave(&hidg->write_spinlock, flags); |
| 407 | release_write_pending_unlocked: | ||
| 408 | hidg->write_pending = 0; | 408 | hidg->write_pending = 0; |
| 409 | spin_unlock_irqrestore(&hidg->write_spinlock, flags); | 409 | spin_unlock_irqrestore(&hidg->write_spinlock, flags); |
| 410 | 410 | ||
diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c index b77f3126580e..c2011cd7df8c 100644 --- a/drivers/usb/gadget/udc/net2272.c +++ b/drivers/usb/gadget/udc/net2272.c | |||
| @@ -945,6 +945,7 @@ net2272_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
| 945 | break; | 945 | break; |
| 946 | } | 946 | } |
| 947 | if (&req->req != _req) { | 947 | if (&req->req != _req) { |
| 948 | ep->stopped = stopped; | ||
| 948 | spin_unlock_irqrestore(&ep->dev->lock, flags); | 949 | spin_unlock_irqrestore(&ep->dev->lock, flags); |
| 949 | return -EINVAL; | 950 | return -EINVAL; |
| 950 | } | 951 | } |
diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index f63f82450bf4..898339e5df10 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c | |||
| @@ -866,9 +866,6 @@ static void start_queue(struct net2280_ep *ep, u32 dmactl, u32 td_dma) | |||
| 866 | (void) readl(&ep->dev->pci->pcimstctl); | 866 | (void) readl(&ep->dev->pci->pcimstctl); |
| 867 | 867 | ||
| 868 | writel(BIT(DMA_START), &dma->dmastat); | 868 | writel(BIT(DMA_START), &dma->dmastat); |
| 869 | |||
| 870 | if (!ep->is_in) | ||
| 871 | stop_out_naking(ep); | ||
| 872 | } | 869 | } |
| 873 | 870 | ||
| 874 | static void start_dma(struct net2280_ep *ep, struct net2280_request *req) | 871 | static void start_dma(struct net2280_ep *ep, struct net2280_request *req) |
| @@ -907,6 +904,7 @@ static void start_dma(struct net2280_ep *ep, struct net2280_request *req) | |||
| 907 | writel(BIT(DMA_START), &dma->dmastat); | 904 | writel(BIT(DMA_START), &dma->dmastat); |
| 908 | return; | 905 | return; |
| 909 | } | 906 | } |
| 907 | stop_out_naking(ep); | ||
| 910 | } | 908 | } |
| 911 | 909 | ||
| 912 | tmp = dmactl_default; | 910 | tmp = dmactl_default; |
| @@ -1275,9 +1273,9 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
| 1275 | break; | 1273 | break; |
| 1276 | } | 1274 | } |
| 1277 | if (&req->req != _req) { | 1275 | if (&req->req != _req) { |
| 1276 | ep->stopped = stopped; | ||
| 1278 | spin_unlock_irqrestore(&ep->dev->lock, flags); | 1277 | spin_unlock_irqrestore(&ep->dev->lock, flags); |
| 1279 | dev_err(&ep->dev->pdev->dev, "%s: Request mismatch\n", | 1278 | ep_dbg(ep->dev, "%s: Request mismatch\n", __func__); |
| 1280 | __func__); | ||
| 1281 | return -EINVAL; | 1279 | return -EINVAL; |
| 1282 | } | 1280 | } |
| 1283 | 1281 | ||
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 934584f0a20a..6343fbacd244 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
| @@ -3204,6 +3204,9 @@ static int __init u132_hcd_init(void) | |||
| 3204 | printk(KERN_INFO "driver %s\n", hcd_name); | 3204 | printk(KERN_INFO "driver %s\n", hcd_name); |
| 3205 | workqueue = create_singlethread_workqueue("u132"); | 3205 | workqueue = create_singlethread_workqueue("u132"); |
| 3206 | retval = platform_driver_register(&u132_platform_driver); | 3206 | retval = platform_driver_register(&u132_platform_driver); |
| 3207 | if (retval) | ||
| 3208 | destroy_workqueue(workqueue); | ||
| 3209 | |||
| 3207 | return retval; | 3210 | return retval; |
| 3208 | } | 3211 | } |
| 3209 | 3212 | ||
diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index c78be578abb0..d932cc31711e 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c | |||
| @@ -516,7 +516,6 @@ static int xhci_do_dbc_stop(struct xhci_hcd *xhci) | |||
| 516 | return -1; | 516 | return -1; |
| 517 | 517 | ||
| 518 | writel(0, &dbc->regs->control); | 518 | writel(0, &dbc->regs->control); |
| 519 | xhci_dbc_mem_cleanup(xhci); | ||
| 520 | dbc->state = DS_DISABLED; | 519 | dbc->state = DS_DISABLED; |
| 521 | 520 | ||
| 522 | return 0; | 521 | return 0; |
| @@ -562,8 +561,10 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci) | |||
| 562 | ret = xhci_do_dbc_stop(xhci); | 561 | ret = xhci_do_dbc_stop(xhci); |
| 563 | spin_unlock_irqrestore(&dbc->lock, flags); | 562 | spin_unlock_irqrestore(&dbc->lock, flags); |
| 564 | 563 | ||
| 565 | if (!ret) | 564 | if (!ret) { |
| 565 | xhci_dbc_mem_cleanup(xhci); | ||
| 566 | pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller); | 566 | pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller); |
| 567 | } | ||
| 567 | } | 568 | } |
| 568 | 569 | ||
| 569 | static void | 570 | static void |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index e2eece693655..96a740543183 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
| @@ -1545,20 +1545,25 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
| 1545 | port_index = max_ports; | 1545 | port_index = max_ports; |
| 1546 | while (port_index--) { | 1546 | while (port_index--) { |
| 1547 | u32 t1, t2; | 1547 | u32 t1, t2; |
| 1548 | 1548 | int retries = 10; | |
| 1549 | retry: | ||
| 1549 | t1 = readl(ports[port_index]->addr); | 1550 | t1 = readl(ports[port_index]->addr); |
| 1550 | t2 = xhci_port_state_to_neutral(t1); | 1551 | t2 = xhci_port_state_to_neutral(t1); |
| 1551 | portsc_buf[port_index] = 0; | 1552 | portsc_buf[port_index] = 0; |
| 1552 | 1553 | ||
| 1553 | /* Bail out if a USB3 port has a new device in link training */ | 1554 | /* |
| 1554 | if ((hcd->speed >= HCD_USB3) && | 1555 | * Give a USB3 port in link training time to finish, but don't |
| 1556 | * prevent suspend as port might be stuck | ||
| 1557 | */ | ||
| 1558 | if ((hcd->speed >= HCD_USB3) && retries-- && | ||
| 1555 | (t1 & PORT_PLS_MASK) == XDEV_POLLING) { | 1559 | (t1 & PORT_PLS_MASK) == XDEV_POLLING) { |
| 1556 | bus_state->bus_suspended = 0; | ||
| 1557 | spin_unlock_irqrestore(&xhci->lock, flags); | 1560 | spin_unlock_irqrestore(&xhci->lock, flags); |
| 1558 | xhci_dbg(xhci, "Bus suspend bailout, port in polling\n"); | 1561 | msleep(XHCI_PORT_POLLING_LFPS_TIME); |
| 1559 | return -EBUSY; | 1562 | spin_lock_irqsave(&xhci->lock, flags); |
| 1563 | xhci_dbg(xhci, "port %d polling in bus suspend, waiting\n", | ||
| 1564 | port_index); | ||
| 1565 | goto retry; | ||
| 1560 | } | 1566 | } |
| 1561 | |||
| 1562 | /* suspend ports in U0, or bail out for new connect changes */ | 1567 | /* suspend ports in U0, or bail out for new connect changes */ |
| 1563 | if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) { | 1568 | if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) { |
| 1564 | if ((t1 & PORT_CSC) && wake_enabled) { | 1569 | if ((t1 & PORT_CSC) && wake_enabled) { |
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index a6e463715779..671bce18782c 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c | |||
| @@ -246,6 +246,7 @@ int xhci_rcar_init_quirk(struct usb_hcd *hcd) | |||
| 246 | if (!xhci_rcar_wait_for_pll_active(hcd)) | 246 | if (!xhci_rcar_wait_for_pll_active(hcd)) |
| 247 | return -ETIMEDOUT; | 247 | return -ETIMEDOUT; |
| 248 | 248 | ||
| 249 | xhci->quirks |= XHCI_TRUST_TX_LENGTH; | ||
| 249 | return xhci_rcar_download_firmware(hcd); | 250 | return xhci_rcar_download_firmware(hcd); |
| 250 | } | 251 | } |
| 251 | 252 | ||
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 40fa25c4d041..9215a28dad40 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
| @@ -1647,10 +1647,13 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
| 1647 | } | 1647 | } |
| 1648 | } | 1648 | } |
| 1649 | 1649 | ||
| 1650 | if ((portsc & PORT_PLC) && (portsc & PORT_PLS_MASK) == XDEV_U0 && | 1650 | if ((portsc & PORT_PLC) && |
| 1651 | DEV_SUPERSPEED_ANY(portsc)) { | 1651 | DEV_SUPERSPEED_ANY(portsc) && |
| 1652 | ((portsc & PORT_PLS_MASK) == XDEV_U0 || | ||
| 1653 | (portsc & PORT_PLS_MASK) == XDEV_U1 || | ||
| 1654 | (portsc & PORT_PLS_MASK) == XDEV_U2)) { | ||
| 1652 | xhci_dbg(xhci, "resume SS port %d finished\n", port_id); | 1655 | xhci_dbg(xhci, "resume SS port %d finished\n", port_id); |
| 1653 | /* We've just brought the device into U0 through either the | 1656 | /* We've just brought the device into U0/1/2 through either the |
| 1654 | * Resume state after a device remote wakeup, or through the | 1657 | * Resume state after a device remote wakeup, or through the |
| 1655 | * U3Exit state after a host-initiated resume. If it's a device | 1658 | * U3Exit state after a host-initiated resume. If it's a device |
| 1656 | * initiated remote wake, don't pass up the link state change, | 1659 | * initiated remote wake, don't pass up the link state change, |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 652dc36e3012..9334cdee382a 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
| @@ -452,6 +452,14 @@ struct xhci_op_regs { | |||
| 452 | */ | 452 | */ |
| 453 | #define XHCI_DEFAULT_BESL 4 | 453 | #define XHCI_DEFAULT_BESL 4 |
| 454 | 454 | ||
| 455 | /* | ||
| 456 | * USB3 specification define a 360ms tPollingLFPSTiemout for USB3 ports | ||
| 457 | * to complete link training. usually link trainig completes much faster | ||
| 458 | * so check status 10 times with 36ms sleep in places we need to wait for | ||
| 459 | * polling to complete. | ||
| 460 | */ | ||
| 461 | #define XHCI_PORT_POLLING_LFPS_TIME 36 | ||
| 462 | |||
| 455 | /** | 463 | /** |
| 456 | * struct xhci_intr_reg - Interrupt Register Set | 464 | * struct xhci_intr_reg - Interrupt Register Set |
| 457 | * @irq_pending: IMAN - Interrupt Management Register. Used to enable | 465 | * @irq_pending: IMAN - Interrupt Management Register. Used to enable |
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c index 4d72b7d1d383..04684849d683 100644 --- a/drivers/usb/misc/usb251xb.c +++ b/drivers/usb/misc/usb251xb.c | |||
| @@ -547,7 +547,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, | |||
| 547 | */ | 547 | */ |
| 548 | hub->port_swap = USB251XB_DEF_PORT_SWAP; | 548 | hub->port_swap = USB251XB_DEF_PORT_SWAP; |
| 549 | of_property_for_each_u32(np, "swap-dx-lanes", prop, p, port) { | 549 | of_property_for_each_u32(np, "swap-dx-lanes", prop, p, port) { |
| 550 | if ((port >= 0) && (port <= data->port_cnt)) | 550 | if (port <= data->port_cnt) |
| 551 | hub->port_swap |= BIT(port); | 551 | hub->port_swap |= BIT(port); |
| 552 | } | 552 | } |
| 553 | 553 | ||
| @@ -612,7 +612,7 @@ static int usb251xb_probe(struct usb251xb *hub) | |||
| 612 | dev); | 612 | dev); |
| 613 | int err; | 613 | int err; |
| 614 | 614 | ||
| 615 | if (np) { | 615 | if (np && of_id) { |
| 616 | err = usb251xb_get_ofdata(hub, | 616 | err = usb251xb_get_ofdata(hub, |
| 617 | (struct usb251xb_data *)of_id->data); | 617 | (struct usb251xb_data *)of_id->data); |
| 618 | if (err) { | 618 | if (err) { |
diff --git a/drivers/usb/mtu3/Kconfig b/drivers/usb/mtu3/Kconfig index bcc23486c4ed..928c2cd6fc00 100644 --- a/drivers/usb/mtu3/Kconfig +++ b/drivers/usb/mtu3/Kconfig | |||
| @@ -6,6 +6,7 @@ config USB_MTU3 | |||
| 6 | tristate "MediaTek USB3 Dual Role controller" | 6 | tristate "MediaTek USB3 Dual Role controller" |
| 7 | depends on USB || USB_GADGET | 7 | depends on USB || USB_GADGET |
| 8 | depends on ARCH_MEDIATEK || COMPILE_TEST | 8 | depends on ARCH_MEDIATEK || COMPILE_TEST |
| 9 | depends on EXTCON || !EXTCON | ||
| 9 | select USB_XHCI_MTK if USB_SUPPORT && USB_XHCI_HCD | 10 | select USB_XHCI_MTK if USB_SUPPORT && USB_XHCI_HCD |
| 10 | help | 11 | help |
| 11 | Say Y or M here if your system runs on MediaTek SoCs with | 12 | Say Y or M here if your system runs on MediaTek SoCs with |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index fffe23ab0189..979bef9bfb6b 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
| @@ -80,6 +80,7 @@ static const struct usb_device_id id_table[] = { | |||
| 80 | { USB_DEVICE(0x10C4, 0x804E) }, /* Software Bisque Paramount ME build-in converter */ | 80 | { USB_DEVICE(0x10C4, 0x804E) }, /* Software Bisque Paramount ME build-in converter */ |
| 81 | { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ | 81 | { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ |
| 82 | { USB_DEVICE(0x10C4, 0x8054) }, /* Enfora GSM2228 */ | 82 | { USB_DEVICE(0x10C4, 0x8054) }, /* Enfora GSM2228 */ |
| 83 | { USB_DEVICE(0x10C4, 0x8056) }, /* Lorenz Messtechnik devices */ | ||
| 83 | { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ | 84 | { USB_DEVICE(0x10C4, 0x8066) }, /* Argussoft In-System Programmer */ |
| 84 | { USB_DEVICE(0x10C4, 0x806F) }, /* IMS USB to RS422 Converter Cable */ | 85 | { USB_DEVICE(0x10C4, 0x806F) }, /* IMS USB to RS422 Converter Cable */ |
| 85 | { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */ | 86 | { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */ |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 8f5b17471759..1d8461ae2c34 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
| @@ -609,6 +609,8 @@ static const struct usb_device_id id_table_combined[] = { | |||
| 609 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 609 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 610 | { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLXM_PID), | 610 | { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLXM_PID), |
| 611 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 611 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 612 | { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLX_PLUS_PID) }, | ||
| 613 | { USB_DEVICE(FTDI_VID, FTDI_NT_ORION_IO_PID) }, | ||
| 612 | { USB_DEVICE(FTDI_VID, FTDI_SYNAPSE_SS200_PID) }, | 614 | { USB_DEVICE(FTDI_VID, FTDI_SYNAPSE_SS200_PID) }, |
| 613 | { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX_PID) }, | 615 | { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX_PID) }, |
| 614 | { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX2_PID) }, | 616 | { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX2_PID) }, |
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index b863bedb55a1..5755f0df0025 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
| @@ -567,7 +567,9 @@ | |||
| 567 | /* | 567 | /* |
| 568 | * NovaTech product ids (FTDI_VID) | 568 | * NovaTech product ids (FTDI_VID) |
| 569 | */ | 569 | */ |
| 570 | #define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */ | 570 | #define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */ |
| 571 | #define FTDI_NT_ORIONLX_PLUS_PID 0x7c91 /* OrionLX+ Substation Automation Platform */ | ||
| 572 | #define FTDI_NT_ORION_IO_PID 0x7c92 /* Orion I/O */ | ||
| 571 | 573 | ||
| 572 | /* | 574 | /* |
| 573 | * Synapse Wireless product ids (FTDI_VID) | 575 | * Synapse Wireless product ids (FTDI_VID) |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index fc52ac75fbf6..18110225d506 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
| @@ -366,8 +366,6 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport, | |||
| 366 | if (!urbtrack) | 366 | if (!urbtrack) |
| 367 | return -ENOMEM; | 367 | return -ENOMEM; |
| 368 | 368 | ||
| 369 | kref_get(&mos_parport->ref_count); | ||
| 370 | urbtrack->mos_parport = mos_parport; | ||
| 371 | urbtrack->urb = usb_alloc_urb(0, GFP_ATOMIC); | 369 | urbtrack->urb = usb_alloc_urb(0, GFP_ATOMIC); |
| 372 | if (!urbtrack->urb) { | 370 | if (!urbtrack->urb) { |
| 373 | kfree(urbtrack); | 371 | kfree(urbtrack); |
| @@ -388,6 +386,8 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport, | |||
| 388 | usb_sndctrlpipe(usbdev, 0), | 386 | usb_sndctrlpipe(usbdev, 0), |
| 389 | (unsigned char *)urbtrack->setup, | 387 | (unsigned char *)urbtrack->setup, |
| 390 | NULL, 0, async_complete, urbtrack); | 388 | NULL, 0, async_complete, urbtrack); |
| 389 | kref_get(&mos_parport->ref_count); | ||
| 390 | urbtrack->mos_parport = mos_parport; | ||
| 391 | kref_init(&urbtrack->ref_count); | 391 | kref_init(&urbtrack->ref_count); |
| 392 | INIT_LIST_HEAD(&urbtrack->urblist_entry); | 392 | INIT_LIST_HEAD(&urbtrack->urblist_entry); |
| 393 | 393 | ||
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 11b21d9410f3..83869065b802 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
| @@ -246,6 +246,7 @@ static void option_instat_callback(struct urb *urb); | |||
| 246 | #define QUECTEL_PRODUCT_EC25 0x0125 | 246 | #define QUECTEL_PRODUCT_EC25 0x0125 |
| 247 | #define QUECTEL_PRODUCT_BG96 0x0296 | 247 | #define QUECTEL_PRODUCT_BG96 0x0296 |
| 248 | #define QUECTEL_PRODUCT_EP06 0x0306 | 248 | #define QUECTEL_PRODUCT_EP06 0x0306 |
| 249 | #define QUECTEL_PRODUCT_EM12 0x0512 | ||
| 249 | 250 | ||
| 250 | #define CMOTECH_VENDOR_ID 0x16d8 | 251 | #define CMOTECH_VENDOR_ID 0x16d8 |
| 251 | #define CMOTECH_PRODUCT_6001 0x6001 | 252 | #define CMOTECH_PRODUCT_6001 0x6001 |
| @@ -1066,7 +1067,8 @@ static const struct usb_device_id option_ids[] = { | |||
| 1066 | .driver_info = RSVD(3) }, | 1067 | .driver_info = RSVD(3) }, |
| 1067 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ | 1068 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ |
| 1068 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ | 1069 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ |
| 1069 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ | 1070 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000), /* SIMCom SIM5218 */ |
| 1071 | .driver_info = NCTRL(0) | NCTRL(1) | NCTRL(2) | NCTRL(3) | RSVD(4) }, | ||
| 1070 | /* Quectel products using Qualcomm vendor ID */ | 1072 | /* Quectel products using Qualcomm vendor ID */ |
| 1071 | { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)}, | 1073 | { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)}, |
| 1072 | { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20), | 1074 | { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20), |
| @@ -1087,6 +1089,9 @@ static const struct usb_device_id option_ids[] = { | |||
| 1087 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff), | 1089 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff), |
| 1088 | .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 }, | 1090 | .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 }, |
| 1089 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, | 1091 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, |
| 1092 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0xff, 0xff), | ||
| 1093 | .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 }, | ||
| 1094 | { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EM12, 0xff, 0, 0) }, | ||
| 1090 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, | 1095 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, |
| 1091 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, | 1096 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, |
| 1092 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), | 1097 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), |
| @@ -1940,10 +1945,12 @@ static const struct usb_device_id option_ids[] = { | |||
| 1940 | .driver_info = RSVD(4) }, | 1945 | .driver_info = RSVD(4) }, |
| 1941 | { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff), /* D-Link DWM-222 */ | 1946 | { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff), /* D-Link DWM-222 */ |
| 1942 | .driver_info = RSVD(4) }, | 1947 | .driver_info = RSVD(4) }, |
| 1943 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ | 1948 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ |
| 1944 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ | 1949 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ |
| 1945 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */ | 1950 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */ |
| 1946 | { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */ | 1951 | { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x2031, 0xff), /* Olicard 600 */ |
| 1952 | .driver_info = RSVD(4) }, | ||
| 1953 | { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */ | ||
| 1947 | { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, | 1954 | { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, |
| 1948 | { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, | 1955 | { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, |
| 1949 | { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) }, | 1956 | { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) }, |
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 0f62db091d8d..a2233d72ae7c 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | S(SRC_ATTACHED), \ | 37 | S(SRC_ATTACHED), \ |
| 38 | S(SRC_STARTUP), \ | 38 | S(SRC_STARTUP), \ |
| 39 | S(SRC_SEND_CAPABILITIES), \ | 39 | S(SRC_SEND_CAPABILITIES), \ |
| 40 | S(SRC_SEND_CAPABILITIES_TIMEOUT), \ | ||
| 40 | S(SRC_NEGOTIATE_CAPABILITIES), \ | 41 | S(SRC_NEGOTIATE_CAPABILITIES), \ |
| 41 | S(SRC_TRANSITION_SUPPLY), \ | 42 | S(SRC_TRANSITION_SUPPLY), \ |
| 42 | S(SRC_READY), \ | 43 | S(SRC_READY), \ |
| @@ -2966,10 +2967,34 @@ static void run_state_machine(struct tcpm_port *port) | |||
| 2966 | /* port->hard_reset_count = 0; */ | 2967 | /* port->hard_reset_count = 0; */ |
| 2967 | port->caps_count = 0; | 2968 | port->caps_count = 0; |
| 2968 | port->pd_capable = true; | 2969 | port->pd_capable = true; |
| 2969 | tcpm_set_state_cond(port, hard_reset_state(port), | 2970 | tcpm_set_state_cond(port, SRC_SEND_CAPABILITIES_TIMEOUT, |
| 2970 | PD_T_SEND_SOURCE_CAP); | 2971 | PD_T_SEND_SOURCE_CAP); |
| 2971 | } | 2972 | } |
| 2972 | break; | 2973 | break; |
| 2974 | case SRC_SEND_CAPABILITIES_TIMEOUT: | ||
| 2975 | /* | ||
| 2976 | * Error recovery for a PD_DATA_SOURCE_CAP reply timeout. | ||
| 2977 | * | ||
| 2978 | * PD 2.0 sinks are supposed to accept src-capabilities with a | ||
| 2979 | * 3.0 header and simply ignore any src PDOs which the sink does | ||
| 2980 | * not understand such as PPS but some 2.0 sinks instead ignore | ||
| 2981 | * the entire PD_DATA_SOURCE_CAP message, causing contract | ||
| 2982 | * negotiation to fail. | ||
| 2983 | * | ||
| 2984 | * After PD_N_HARD_RESET_COUNT hard-reset attempts, we try | ||
| 2985 | * sending src-capabilities with a lower PD revision to | ||
| 2986 | * make these broken sinks work. | ||
| 2987 | */ | ||
| 2988 | if (port->hard_reset_count < PD_N_HARD_RESET_COUNT) { | ||
| 2989 | tcpm_set_state(port, HARD_RESET_SEND, 0); | ||
| 2990 | } else if (port->negotiated_rev > PD_REV20) { | ||
| 2991 | port->negotiated_rev--; | ||
| 2992 | port->hard_reset_count = 0; | ||
| 2993 | tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); | ||
| 2994 | } else { | ||
| 2995 | tcpm_set_state(port, hard_reset_state(port), 0); | ||
| 2996 | } | ||
| 2997 | break; | ||
| 2973 | case SRC_NEGOTIATE_CAPABILITIES: | 2998 | case SRC_NEGOTIATE_CAPABILITIES: |
| 2974 | ret = tcpm_pd_check_request(port); | 2999 | ret = tcpm_pd_check_request(port); |
| 2975 | if (ret < 0) { | 3000 | if (ret < 0) { |
diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c index 423208e19383..6770afd40765 100644 --- a/drivers/usb/typec/tcpm/wcove.c +++ b/drivers/usb/typec/tcpm/wcove.c | |||
| @@ -615,8 +615,13 @@ static int wcove_typec_probe(struct platform_device *pdev) | |||
| 615 | wcove->dev = &pdev->dev; | 615 | wcove->dev = &pdev->dev; |
| 616 | wcove->regmap = pmic->regmap; | 616 | wcove->regmap = pmic->regmap; |
| 617 | 617 | ||
| 618 | irq = regmap_irq_get_virq(pmic->irq_chip_data_chgr, | 618 | irq = platform_get_irq(pdev, 0); |
| 619 | platform_get_irq(pdev, 0)); | 619 | if (irq < 0) { |
| 620 | dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq); | ||
| 621 | return irq; | ||
| 622 | } | ||
| 623 | |||
| 624 | irq = regmap_irq_get_virq(pmic->irq_chip_data_chgr, irq); | ||
| 620 | if (irq < 0) | 625 | if (irq < 0) |
| 621 | return irq; | 626 | return irq; |
| 622 | 627 | ||
diff --git a/drivers/virt/vboxguest/vboxguest_core.c b/drivers/virt/vboxguest/vboxguest_core.c index df7d09409efe..8ca333f21292 100644 --- a/drivers/virt/vboxguest/vboxguest_core.c +++ b/drivers/virt/vboxguest/vboxguest_core.c | |||
| @@ -27,6 +27,10 @@ | |||
| 27 | 27 | ||
| 28 | #define GUEST_MAPPINGS_TRIES 5 | 28 | #define GUEST_MAPPINGS_TRIES 5 |
| 29 | 29 | ||
| 30 | #define VBG_KERNEL_REQUEST \ | ||
| 31 | (VMMDEV_REQUESTOR_KERNEL | VMMDEV_REQUESTOR_USR_DRV | \ | ||
| 32 | VMMDEV_REQUESTOR_CON_DONT_KNOW | VMMDEV_REQUESTOR_TRUST_NOT_GIVEN) | ||
| 33 | |||
| 30 | /** | 34 | /** |
| 31 | * Reserves memory in which the VMM can relocate any guest mappings | 35 | * Reserves memory in which the VMM can relocate any guest mappings |
| 32 | * that are floating around. | 36 | * that are floating around. |
| @@ -48,7 +52,8 @@ static void vbg_guest_mappings_init(struct vbg_dev *gdev) | |||
| 48 | int i, rc; | 52 | int i, rc; |
| 49 | 53 | ||
| 50 | /* Query the required space. */ | 54 | /* Query the required space. */ |
| 51 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_GET_HYPERVISOR_INFO); | 55 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_GET_HYPERVISOR_INFO, |
| 56 | VBG_KERNEL_REQUEST); | ||
| 52 | if (!req) | 57 | if (!req) |
| 53 | return; | 58 | return; |
| 54 | 59 | ||
| @@ -135,7 +140,8 @@ static void vbg_guest_mappings_exit(struct vbg_dev *gdev) | |||
| 135 | * Tell the host that we're going to free the memory we reserved for | 140 | * Tell the host that we're going to free the memory we reserved for |
| 136 | * it, the free it up. (Leak the memory if anything goes wrong here.) | 141 | * it, the free it up. (Leak the memory if anything goes wrong here.) |
| 137 | */ | 142 | */ |
| 138 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_HYPERVISOR_INFO); | 143 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_HYPERVISOR_INFO, |
| 144 | VBG_KERNEL_REQUEST); | ||
| 139 | if (!req) | 145 | if (!req) |
| 140 | return; | 146 | return; |
| 141 | 147 | ||
| @@ -172,8 +178,10 @@ static int vbg_report_guest_info(struct vbg_dev *gdev) | |||
| 172 | struct vmmdev_guest_info2 *req2 = NULL; | 178 | struct vmmdev_guest_info2 *req2 = NULL; |
| 173 | int rc, ret = -ENOMEM; | 179 | int rc, ret = -ENOMEM; |
| 174 | 180 | ||
| 175 | req1 = vbg_req_alloc(sizeof(*req1), VMMDEVREQ_REPORT_GUEST_INFO); | 181 | req1 = vbg_req_alloc(sizeof(*req1), VMMDEVREQ_REPORT_GUEST_INFO, |
| 176 | req2 = vbg_req_alloc(sizeof(*req2), VMMDEVREQ_REPORT_GUEST_INFO2); | 182 | VBG_KERNEL_REQUEST); |
| 183 | req2 = vbg_req_alloc(sizeof(*req2), VMMDEVREQ_REPORT_GUEST_INFO2, | ||
| 184 | VBG_KERNEL_REQUEST); | ||
| 177 | if (!req1 || !req2) | 185 | if (!req1 || !req2) |
| 178 | goto out_free; | 186 | goto out_free; |
| 179 | 187 | ||
| @@ -187,8 +195,8 @@ static int vbg_report_guest_info(struct vbg_dev *gdev) | |||
| 187 | req2->additions_minor = VBG_VERSION_MINOR; | 195 | req2->additions_minor = VBG_VERSION_MINOR; |
| 188 | req2->additions_build = VBG_VERSION_BUILD; | 196 | req2->additions_build = VBG_VERSION_BUILD; |
| 189 | req2->additions_revision = VBG_SVN_REV; | 197 | req2->additions_revision = VBG_SVN_REV; |
| 190 | /* (no features defined yet) */ | 198 | req2->additions_features = |
| 191 | req2->additions_features = 0; | 199 | VMMDEV_GUEST_INFO2_ADDITIONS_FEATURES_REQUESTOR_INFO; |
| 192 | strlcpy(req2->name, VBG_VERSION_STRING, | 200 | strlcpy(req2->name, VBG_VERSION_STRING, |
| 193 | sizeof(req2->name)); | 201 | sizeof(req2->name)); |
| 194 | 202 | ||
| @@ -230,7 +238,8 @@ static int vbg_report_driver_status(struct vbg_dev *gdev, bool active) | |||
| 230 | struct vmmdev_guest_status *req; | 238 | struct vmmdev_guest_status *req; |
| 231 | int rc; | 239 | int rc; |
| 232 | 240 | ||
| 233 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_REPORT_GUEST_STATUS); | 241 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_REPORT_GUEST_STATUS, |
| 242 | VBG_KERNEL_REQUEST); | ||
| 234 | if (!req) | 243 | if (!req) |
| 235 | return -ENOMEM; | 244 | return -ENOMEM; |
| 236 | 245 | ||
| @@ -423,7 +432,8 @@ static int vbg_heartbeat_host_config(struct vbg_dev *gdev, bool enabled) | |||
| 423 | struct vmmdev_heartbeat *req; | 432 | struct vmmdev_heartbeat *req; |
| 424 | int rc; | 433 | int rc; |
| 425 | 434 | ||
| 426 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_HEARTBEAT_CONFIGURE); | 435 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_HEARTBEAT_CONFIGURE, |
| 436 | VBG_KERNEL_REQUEST); | ||
| 427 | if (!req) | 437 | if (!req) |
| 428 | return -ENOMEM; | 438 | return -ENOMEM; |
| 429 | 439 | ||
| @@ -457,7 +467,8 @@ static int vbg_heartbeat_init(struct vbg_dev *gdev) | |||
| 457 | 467 | ||
| 458 | gdev->guest_heartbeat_req = vbg_req_alloc( | 468 | gdev->guest_heartbeat_req = vbg_req_alloc( |
| 459 | sizeof(*gdev->guest_heartbeat_req), | 469 | sizeof(*gdev->guest_heartbeat_req), |
| 460 | VMMDEVREQ_GUEST_HEARTBEAT); | 470 | VMMDEVREQ_GUEST_HEARTBEAT, |
| 471 | VBG_KERNEL_REQUEST); | ||
| 461 | if (!gdev->guest_heartbeat_req) | 472 | if (!gdev->guest_heartbeat_req) |
| 462 | return -ENOMEM; | 473 | return -ENOMEM; |
| 463 | 474 | ||
| @@ -528,7 +539,8 @@ static int vbg_reset_host_event_filter(struct vbg_dev *gdev, | |||
| 528 | struct vmmdev_mask *req; | 539 | struct vmmdev_mask *req; |
| 529 | int rc; | 540 | int rc; |
| 530 | 541 | ||
| 531 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_CTL_GUEST_FILTER_MASK); | 542 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_CTL_GUEST_FILTER_MASK, |
| 543 | VBG_KERNEL_REQUEST); | ||
| 532 | if (!req) | 544 | if (!req) |
| 533 | return -ENOMEM; | 545 | return -ENOMEM; |
| 534 | 546 | ||
| @@ -567,8 +579,14 @@ static int vbg_set_session_event_filter(struct vbg_dev *gdev, | |||
| 567 | u32 changed, previous; | 579 | u32 changed, previous; |
| 568 | int rc, ret = 0; | 580 | int rc, ret = 0; |
| 569 | 581 | ||
| 570 | /* Allocate a request buffer before taking the spinlock */ | 582 | /* |
| 571 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_CTL_GUEST_FILTER_MASK); | 583 | * Allocate a request buffer before taking the spinlock, when |
| 584 | * the session is being terminated the requestor is the kernel, | ||
| 585 | * as we're cleaning up. | ||
| 586 | */ | ||
| 587 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_CTL_GUEST_FILTER_MASK, | ||
| 588 | session_termination ? VBG_KERNEL_REQUEST : | ||
| 589 | session->requestor); | ||
| 572 | if (!req) { | 590 | if (!req) { |
| 573 | if (!session_termination) | 591 | if (!session_termination) |
| 574 | return -ENOMEM; | 592 | return -ENOMEM; |
| @@ -627,7 +645,8 @@ static int vbg_reset_host_capabilities(struct vbg_dev *gdev) | |||
| 627 | struct vmmdev_mask *req; | 645 | struct vmmdev_mask *req; |
| 628 | int rc; | 646 | int rc; |
| 629 | 647 | ||
| 630 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_GUEST_CAPABILITIES); | 648 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_GUEST_CAPABILITIES, |
| 649 | VBG_KERNEL_REQUEST); | ||
| 631 | if (!req) | 650 | if (!req) |
| 632 | return -ENOMEM; | 651 | return -ENOMEM; |
| 633 | 652 | ||
| @@ -662,8 +681,14 @@ static int vbg_set_session_capabilities(struct vbg_dev *gdev, | |||
| 662 | u32 changed, previous; | 681 | u32 changed, previous; |
| 663 | int rc, ret = 0; | 682 | int rc, ret = 0; |
| 664 | 683 | ||
| 665 | /* Allocate a request buffer before taking the spinlock */ | 684 | /* |
| 666 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_GUEST_CAPABILITIES); | 685 | * Allocate a request buffer before taking the spinlock, when |
| 686 | * the session is being terminated the requestor is the kernel, | ||
| 687 | * as we're cleaning up. | ||
| 688 | */ | ||
| 689 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_GUEST_CAPABILITIES, | ||
| 690 | session_termination ? VBG_KERNEL_REQUEST : | ||
| 691 | session->requestor); | ||
| 667 | if (!req) { | 692 | if (!req) { |
| 668 | if (!session_termination) | 693 | if (!session_termination) |
| 669 | return -ENOMEM; | 694 | return -ENOMEM; |
| @@ -722,7 +747,8 @@ static int vbg_query_host_version(struct vbg_dev *gdev) | |||
| 722 | struct vmmdev_host_version *req; | 747 | struct vmmdev_host_version *req; |
| 723 | int rc, ret; | 748 | int rc, ret; |
| 724 | 749 | ||
| 725 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_GET_HOST_VERSION); | 750 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_GET_HOST_VERSION, |
| 751 | VBG_KERNEL_REQUEST); | ||
| 726 | if (!req) | 752 | if (!req) |
| 727 | return -ENOMEM; | 753 | return -ENOMEM; |
| 728 | 754 | ||
| @@ -783,19 +809,24 @@ int vbg_core_init(struct vbg_dev *gdev, u32 fixed_events) | |||
| 783 | 809 | ||
| 784 | gdev->mem_balloon.get_req = | 810 | gdev->mem_balloon.get_req = |
| 785 | vbg_req_alloc(sizeof(*gdev->mem_balloon.get_req), | 811 | vbg_req_alloc(sizeof(*gdev->mem_balloon.get_req), |
| 786 | VMMDEVREQ_GET_MEMBALLOON_CHANGE_REQ); | 812 | VMMDEVREQ_GET_MEMBALLOON_CHANGE_REQ, |
| 813 | VBG_KERNEL_REQUEST); | ||
| 787 | gdev->mem_balloon.change_req = | 814 | gdev->mem_balloon.change_req = |
| 788 | vbg_req_alloc(sizeof(*gdev->mem_balloon.change_req), | 815 | vbg_req_alloc(sizeof(*gdev->mem_balloon.change_req), |
| 789 | VMMDEVREQ_CHANGE_MEMBALLOON); | 816 | VMMDEVREQ_CHANGE_MEMBALLOON, |
| 817 | VBG_KERNEL_REQUEST); | ||
| 790 | gdev->cancel_req = | 818 | gdev->cancel_req = |
| 791 | vbg_req_alloc(sizeof(*(gdev->cancel_req)), | 819 | vbg_req_alloc(sizeof(*(gdev->cancel_req)), |
| 792 | VMMDEVREQ_HGCM_CANCEL2); | 820 | VMMDEVREQ_HGCM_CANCEL2, |
| 821 | VBG_KERNEL_REQUEST); | ||
| 793 | gdev->ack_events_req = | 822 | gdev->ack_events_req = |
| 794 | vbg_req_alloc(sizeof(*gdev->ack_events_req), | 823 | vbg_req_alloc(sizeof(*gdev->ack_events_req), |
| 795 | VMMDEVREQ_ACKNOWLEDGE_EVENTS); | 824 | VMMDEVREQ_ACKNOWLEDGE_EVENTS, |
| 825 | VBG_KERNEL_REQUEST); | ||
| 796 | gdev->mouse_status_req = | 826 | gdev->mouse_status_req = |
| 797 | vbg_req_alloc(sizeof(*gdev->mouse_status_req), | 827 | vbg_req_alloc(sizeof(*gdev->mouse_status_req), |
| 798 | VMMDEVREQ_GET_MOUSE_STATUS); | 828 | VMMDEVREQ_GET_MOUSE_STATUS, |
| 829 | VBG_KERNEL_REQUEST); | ||
| 799 | 830 | ||
| 800 | if (!gdev->mem_balloon.get_req || !gdev->mem_balloon.change_req || | 831 | if (!gdev->mem_balloon.get_req || !gdev->mem_balloon.change_req || |
| 801 | !gdev->cancel_req || !gdev->ack_events_req || | 832 | !gdev->cancel_req || !gdev->ack_events_req || |
| @@ -892,9 +923,9 @@ void vbg_core_exit(struct vbg_dev *gdev) | |||
| 892 | * vboxguest_linux.c calls this when userspace opens the char-device. | 923 | * vboxguest_linux.c calls this when userspace opens the char-device. |
| 893 | * Return: A pointer to the new session or an ERR_PTR on error. | 924 | * Return: A pointer to the new session or an ERR_PTR on error. |
| 894 | * @gdev: The Guest extension device. | 925 | * @gdev: The Guest extension device. |
| 895 | * @user: Set if this is a session for the vboxuser device. | 926 | * @requestor: VMMDEV_REQUESTOR_* flags |
| 896 | */ | 927 | */ |
| 897 | struct vbg_session *vbg_core_open_session(struct vbg_dev *gdev, bool user) | 928 | struct vbg_session *vbg_core_open_session(struct vbg_dev *gdev, u32 requestor) |
| 898 | { | 929 | { |
| 899 | struct vbg_session *session; | 930 | struct vbg_session *session; |
| 900 | 931 | ||
| @@ -903,7 +934,7 @@ struct vbg_session *vbg_core_open_session(struct vbg_dev *gdev, bool user) | |||
| 903 | return ERR_PTR(-ENOMEM); | 934 | return ERR_PTR(-ENOMEM); |
| 904 | 935 | ||
| 905 | session->gdev = gdev; | 936 | session->gdev = gdev; |
| 906 | session->user_session = user; | 937 | session->requestor = requestor; |
| 907 | 938 | ||
| 908 | return session; | 939 | return session; |
| 909 | } | 940 | } |
| @@ -924,7 +955,9 @@ void vbg_core_close_session(struct vbg_session *session) | |||
| 924 | if (!session->hgcm_client_ids[i]) | 955 | if (!session->hgcm_client_ids[i]) |
| 925 | continue; | 956 | continue; |
| 926 | 957 | ||
| 927 | vbg_hgcm_disconnect(gdev, session->hgcm_client_ids[i], &rc); | 958 | /* requestor is kernel here, as we're cleaning up. */ |
| 959 | vbg_hgcm_disconnect(gdev, VBG_KERNEL_REQUEST, | ||
| 960 | session->hgcm_client_ids[i], &rc); | ||
| 928 | } | 961 | } |
| 929 | 962 | ||
| 930 | kfree(session); | 963 | kfree(session); |
| @@ -1152,7 +1185,8 @@ static int vbg_req_allowed(struct vbg_dev *gdev, struct vbg_session *session, | |||
| 1152 | return -EPERM; | 1185 | return -EPERM; |
| 1153 | } | 1186 | } |
| 1154 | 1187 | ||
| 1155 | if (trusted_apps_only && session->user_session) { | 1188 | if (trusted_apps_only && |
| 1189 | (session->requestor & VMMDEV_REQUESTOR_USER_DEVICE)) { | ||
| 1156 | vbg_err("Denying userspace vmm call type %#08x through vboxuser device node\n", | 1190 | vbg_err("Denying userspace vmm call type %#08x through vboxuser device node\n", |
| 1157 | req->request_type); | 1191 | req->request_type); |
| 1158 | return -EPERM; | 1192 | return -EPERM; |
| @@ -1209,8 +1243,8 @@ static int vbg_ioctl_hgcm_connect(struct vbg_dev *gdev, | |||
| 1209 | if (i >= ARRAY_SIZE(session->hgcm_client_ids)) | 1243 | if (i >= ARRAY_SIZE(session->hgcm_client_ids)) |
| 1210 | return -EMFILE; | 1244 | return -EMFILE; |
| 1211 | 1245 | ||
| 1212 | ret = vbg_hgcm_connect(gdev, &conn->u.in.loc, &client_id, | 1246 | ret = vbg_hgcm_connect(gdev, session->requestor, &conn->u.in.loc, |
| 1213 | &conn->hdr.rc); | 1247 | &client_id, &conn->hdr.rc); |
| 1214 | 1248 | ||
| 1215 | mutex_lock(&gdev->session_mutex); | 1249 | mutex_lock(&gdev->session_mutex); |
| 1216 | if (ret == 0 && conn->hdr.rc >= 0) { | 1250 | if (ret == 0 && conn->hdr.rc >= 0) { |
| @@ -1251,7 +1285,8 @@ static int vbg_ioctl_hgcm_disconnect(struct vbg_dev *gdev, | |||
| 1251 | if (i >= ARRAY_SIZE(session->hgcm_client_ids)) | 1285 | if (i >= ARRAY_SIZE(session->hgcm_client_ids)) |
| 1252 | return -EINVAL; | 1286 | return -EINVAL; |
| 1253 | 1287 | ||
| 1254 | ret = vbg_hgcm_disconnect(gdev, client_id, &disconn->hdr.rc); | 1288 | ret = vbg_hgcm_disconnect(gdev, session->requestor, client_id, |
| 1289 | &disconn->hdr.rc); | ||
| 1255 | 1290 | ||
| 1256 | mutex_lock(&gdev->session_mutex); | 1291 | mutex_lock(&gdev->session_mutex); |
| 1257 | if (ret == 0 && disconn->hdr.rc >= 0) | 1292 | if (ret == 0 && disconn->hdr.rc >= 0) |
| @@ -1313,12 +1348,12 @@ static int vbg_ioctl_hgcm_call(struct vbg_dev *gdev, | |||
| 1313 | } | 1348 | } |
| 1314 | 1349 | ||
| 1315 | if (IS_ENABLED(CONFIG_COMPAT) && f32bit) | 1350 | if (IS_ENABLED(CONFIG_COMPAT) && f32bit) |
| 1316 | ret = vbg_hgcm_call32(gdev, client_id, | 1351 | ret = vbg_hgcm_call32(gdev, session->requestor, client_id, |
| 1317 | call->function, call->timeout_ms, | 1352 | call->function, call->timeout_ms, |
| 1318 | VBG_IOCTL_HGCM_CALL_PARMS32(call), | 1353 | VBG_IOCTL_HGCM_CALL_PARMS32(call), |
| 1319 | call->parm_count, &call->hdr.rc); | 1354 | call->parm_count, &call->hdr.rc); |
| 1320 | else | 1355 | else |
| 1321 | ret = vbg_hgcm_call(gdev, client_id, | 1356 | ret = vbg_hgcm_call(gdev, session->requestor, client_id, |
| 1322 | call->function, call->timeout_ms, | 1357 | call->function, call->timeout_ms, |
| 1323 | VBG_IOCTL_HGCM_CALL_PARMS(call), | 1358 | VBG_IOCTL_HGCM_CALL_PARMS(call), |
| 1324 | call->parm_count, &call->hdr.rc); | 1359 | call->parm_count, &call->hdr.rc); |
| @@ -1408,6 +1443,7 @@ static int vbg_ioctl_check_balloon(struct vbg_dev *gdev, | |||
| 1408 | } | 1443 | } |
| 1409 | 1444 | ||
| 1410 | static int vbg_ioctl_write_core_dump(struct vbg_dev *gdev, | 1445 | static int vbg_ioctl_write_core_dump(struct vbg_dev *gdev, |
| 1446 | struct vbg_session *session, | ||
| 1411 | struct vbg_ioctl_write_coredump *dump) | 1447 | struct vbg_ioctl_write_coredump *dump) |
| 1412 | { | 1448 | { |
| 1413 | struct vmmdev_write_core_dump *req; | 1449 | struct vmmdev_write_core_dump *req; |
| @@ -1415,7 +1451,8 @@ static int vbg_ioctl_write_core_dump(struct vbg_dev *gdev, | |||
| 1415 | if (vbg_ioctl_chk(&dump->hdr, sizeof(dump->u.in), 0)) | 1451 | if (vbg_ioctl_chk(&dump->hdr, sizeof(dump->u.in), 0)) |
| 1416 | return -EINVAL; | 1452 | return -EINVAL; |
| 1417 | 1453 | ||
| 1418 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_WRITE_COREDUMP); | 1454 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_WRITE_COREDUMP, |
| 1455 | session->requestor); | ||
| 1419 | if (!req) | 1456 | if (!req) |
| 1420 | return -ENOMEM; | 1457 | return -ENOMEM; |
| 1421 | 1458 | ||
| @@ -1476,7 +1513,7 @@ int vbg_core_ioctl(struct vbg_session *session, unsigned int req, void *data) | |||
| 1476 | case VBG_IOCTL_CHECK_BALLOON: | 1513 | case VBG_IOCTL_CHECK_BALLOON: |
| 1477 | return vbg_ioctl_check_balloon(gdev, data); | 1514 | return vbg_ioctl_check_balloon(gdev, data); |
| 1478 | case VBG_IOCTL_WRITE_CORE_DUMP: | 1515 | case VBG_IOCTL_WRITE_CORE_DUMP: |
| 1479 | return vbg_ioctl_write_core_dump(gdev, data); | 1516 | return vbg_ioctl_write_core_dump(gdev, session, data); |
| 1480 | } | 1517 | } |
| 1481 | 1518 | ||
| 1482 | /* Variable sized requests. */ | 1519 | /* Variable sized requests. */ |
| @@ -1508,7 +1545,8 @@ int vbg_core_set_mouse_status(struct vbg_dev *gdev, u32 features) | |||
| 1508 | struct vmmdev_mouse_status *req; | 1545 | struct vmmdev_mouse_status *req; |
| 1509 | int rc; | 1546 | int rc; |
| 1510 | 1547 | ||
| 1511 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_MOUSE_STATUS); | 1548 | req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_MOUSE_STATUS, |
| 1549 | VBG_KERNEL_REQUEST); | ||
| 1512 | if (!req) | 1550 | if (!req) |
| 1513 | return -ENOMEM; | 1551 | return -ENOMEM; |
| 1514 | 1552 | ||
diff --git a/drivers/virt/vboxguest/vboxguest_core.h b/drivers/virt/vboxguest/vboxguest_core.h index 7ad9ec45bfa9..4188c12b839f 100644 --- a/drivers/virt/vboxguest/vboxguest_core.h +++ b/drivers/virt/vboxguest/vboxguest_core.h | |||
| @@ -154,15 +154,15 @@ struct vbg_session { | |||
| 154 | * host. Protected by vbg_gdev.session_mutex. | 154 | * host. Protected by vbg_gdev.session_mutex. |
| 155 | */ | 155 | */ |
| 156 | u32 guest_caps; | 156 | u32 guest_caps; |
| 157 | /** Does this session belong to a root process or a user one? */ | 157 | /** VMMDEV_REQUESTOR_* flags */ |
| 158 | bool user_session; | 158 | u32 requestor; |
| 159 | /** Set on CANCEL_ALL_WAITEVENTS, protected by vbg_devevent_spinlock. */ | 159 | /** Set on CANCEL_ALL_WAITEVENTS, protected by vbg_devevent_spinlock. */ |
| 160 | bool cancel_waiters; | 160 | bool cancel_waiters; |
| 161 | }; | 161 | }; |
| 162 | 162 | ||
| 163 | int vbg_core_init(struct vbg_dev *gdev, u32 fixed_events); | 163 | int vbg_core_init(struct vbg_dev *gdev, u32 fixed_events); |
| 164 | void vbg_core_exit(struct vbg_dev *gdev); | 164 | void vbg_core_exit(struct vbg_dev *gdev); |
| 165 | struct vbg_session *vbg_core_open_session(struct vbg_dev *gdev, bool user); | 165 | struct vbg_session *vbg_core_open_session(struct vbg_dev *gdev, u32 requestor); |
| 166 | void vbg_core_close_session(struct vbg_session *session); | 166 | void vbg_core_close_session(struct vbg_session *session); |
| 167 | int vbg_core_ioctl(struct vbg_session *session, unsigned int req, void *data); | 167 | int vbg_core_ioctl(struct vbg_session *session, unsigned int req, void *data); |
| 168 | int vbg_core_set_mouse_status(struct vbg_dev *gdev, u32 features); | 168 | int vbg_core_set_mouse_status(struct vbg_dev *gdev, u32 features); |
| @@ -172,12 +172,13 @@ irqreturn_t vbg_core_isr(int irq, void *dev_id); | |||
| 172 | void vbg_linux_mouse_event(struct vbg_dev *gdev); | 172 | void vbg_linux_mouse_event(struct vbg_dev *gdev); |
| 173 | 173 | ||
| 174 | /* Private (non exported) functions form vboxguest_utils.c */ | 174 | /* Private (non exported) functions form vboxguest_utils.c */ |
| 175 | void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type); | 175 | void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type, |
| 176 | u32 requestor); | ||
| 176 | void vbg_req_free(void *req, size_t len); | 177 | void vbg_req_free(void *req, size_t len); |
| 177 | int vbg_req_perform(struct vbg_dev *gdev, void *req); | 178 | int vbg_req_perform(struct vbg_dev *gdev, void *req); |
| 178 | int vbg_hgcm_call32( | 179 | int vbg_hgcm_call32( |
| 179 | struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms, | 180 | struct vbg_dev *gdev, u32 requestor, u32 client_id, u32 function, |
| 180 | struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count, | 181 | u32 timeout_ms, struct vmmdev_hgcm_function_parameter32 *parm32, |
| 181 | int *vbox_status); | 182 | u32 parm_count, int *vbox_status); |
| 182 | 183 | ||
| 183 | #endif | 184 | #endif |
diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c index 6e2a9619192d..6e8c0f1c1056 100644 --- a/drivers/virt/vboxguest/vboxguest_linux.c +++ b/drivers/virt/vboxguest/vboxguest_linux.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | * Copyright (C) 2006-2016 Oracle Corporation | 5 | * Copyright (C) 2006-2016 Oracle Corporation |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #include <linux/cred.h> | ||
| 8 | #include <linux/input.h> | 9 | #include <linux/input.h> |
| 9 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
| 10 | #include <linux/miscdevice.h> | 11 | #include <linux/miscdevice.h> |
| @@ -28,6 +29,23 @@ static DEFINE_MUTEX(vbg_gdev_mutex); | |||
| 28 | /** Global vbg_gdev pointer used by vbg_get/put_gdev. */ | 29 | /** Global vbg_gdev pointer used by vbg_get/put_gdev. */ |
| 29 | static struct vbg_dev *vbg_gdev; | 30 | static struct vbg_dev *vbg_gdev; |
| 30 | 31 | ||
| 32 | static u32 vbg_misc_device_requestor(struct inode *inode) | ||
| 33 | { | ||
| 34 | u32 requestor = VMMDEV_REQUESTOR_USERMODE | | ||
| 35 | VMMDEV_REQUESTOR_CON_DONT_KNOW | | ||
| 36 | VMMDEV_REQUESTOR_TRUST_NOT_GIVEN; | ||
| 37 | |||
| 38 | if (from_kuid(current_user_ns(), current->cred->uid) == 0) | ||
| 39 | requestor |= VMMDEV_REQUESTOR_USR_ROOT; | ||
| 40 | else | ||
| 41 | requestor |= VMMDEV_REQUESTOR_USR_USER; | ||
| 42 | |||
| 43 | if (in_egroup_p(inode->i_gid)) | ||
| 44 | requestor |= VMMDEV_REQUESTOR_GRP_VBOX; | ||
| 45 | |||
| 46 | return requestor; | ||
| 47 | } | ||
| 48 | |||
| 31 | static int vbg_misc_device_open(struct inode *inode, struct file *filp) | 49 | static int vbg_misc_device_open(struct inode *inode, struct file *filp) |
| 32 | { | 50 | { |
| 33 | struct vbg_session *session; | 51 | struct vbg_session *session; |
| @@ -36,7 +54,7 @@ static int vbg_misc_device_open(struct inode *inode, struct file *filp) | |||
| 36 | /* misc_open sets filp->private_data to our misc device */ | 54 | /* misc_open sets filp->private_data to our misc device */ |
| 37 | gdev = container_of(filp->private_data, struct vbg_dev, misc_device); | 55 | gdev = container_of(filp->private_data, struct vbg_dev, misc_device); |
| 38 | 56 | ||
| 39 | session = vbg_core_open_session(gdev, false); | 57 | session = vbg_core_open_session(gdev, vbg_misc_device_requestor(inode)); |
| 40 | if (IS_ERR(session)) | 58 | if (IS_ERR(session)) |
| 41 | return PTR_ERR(session); | 59 | return PTR_ERR(session); |
| 42 | 60 | ||
| @@ -53,7 +71,8 @@ static int vbg_misc_device_user_open(struct inode *inode, struct file *filp) | |||
| 53 | gdev = container_of(filp->private_data, struct vbg_dev, | 71 | gdev = container_of(filp->private_data, struct vbg_dev, |
| 54 | misc_device_user); | 72 | misc_device_user); |
| 55 | 73 | ||
| 56 | session = vbg_core_open_session(gdev, false); | 74 | session = vbg_core_open_session(gdev, vbg_misc_device_requestor(inode) | |
| 75 | VMMDEV_REQUESTOR_USER_DEVICE); | ||
| 57 | if (IS_ERR(session)) | 76 | if (IS_ERR(session)) |
| 58 | return PTR_ERR(session); | 77 | return PTR_ERR(session); |
| 59 | 78 | ||
| @@ -115,7 +134,8 @@ static long vbg_misc_device_ioctl(struct file *filp, unsigned int req, | |||
| 115 | req == VBG_IOCTL_VMMDEV_REQUEST_BIG; | 134 | req == VBG_IOCTL_VMMDEV_REQUEST_BIG; |
| 116 | 135 | ||
| 117 | if (is_vmmdev_req) | 136 | if (is_vmmdev_req) |
| 118 | buf = vbg_req_alloc(size, VBG_IOCTL_HDR_TYPE_DEFAULT); | 137 | buf = vbg_req_alloc(size, VBG_IOCTL_HDR_TYPE_DEFAULT, |
| 138 | session->requestor); | ||
| 119 | else | 139 | else |
| 120 | buf = kmalloc(size, GFP_KERNEL); | 140 | buf = kmalloc(size, GFP_KERNEL); |
| 121 | if (!buf) | 141 | if (!buf) |
diff --git a/drivers/virt/vboxguest/vboxguest_utils.c b/drivers/virt/vboxguest/vboxguest_utils.c index bf4474214b4d..75fd140b02ff 100644 --- a/drivers/virt/vboxguest/vboxguest_utils.c +++ b/drivers/virt/vboxguest/vboxguest_utils.c | |||
| @@ -62,7 +62,8 @@ VBG_LOG(vbg_err, pr_err); | |||
| 62 | VBG_LOG(vbg_debug, pr_debug); | 62 | VBG_LOG(vbg_debug, pr_debug); |
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type) | 65 | void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type, |
| 66 | u32 requestor) | ||
| 66 | { | 67 | { |
| 67 | struct vmmdev_request_header *req; | 68 | struct vmmdev_request_header *req; |
| 68 | int order = get_order(PAGE_ALIGN(len)); | 69 | int order = get_order(PAGE_ALIGN(len)); |
| @@ -78,7 +79,7 @@ void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type) | |||
| 78 | req->request_type = req_type; | 79 | req->request_type = req_type; |
| 79 | req->rc = VERR_GENERAL_FAILURE; | 80 | req->rc = VERR_GENERAL_FAILURE; |
| 80 | req->reserved1 = 0; | 81 | req->reserved1 = 0; |
| 81 | req->reserved2 = 0; | 82 | req->requestor = requestor; |
| 82 | 83 | ||
| 83 | return req; | 84 | return req; |
| 84 | } | 85 | } |
| @@ -119,7 +120,7 @@ static bool hgcm_req_done(struct vbg_dev *gdev, | |||
| 119 | return done; | 120 | return done; |
| 120 | } | 121 | } |
| 121 | 122 | ||
| 122 | int vbg_hgcm_connect(struct vbg_dev *gdev, | 123 | int vbg_hgcm_connect(struct vbg_dev *gdev, u32 requestor, |
| 123 | struct vmmdev_hgcm_service_location *loc, | 124 | struct vmmdev_hgcm_service_location *loc, |
| 124 | u32 *client_id, int *vbox_status) | 125 | u32 *client_id, int *vbox_status) |
| 125 | { | 126 | { |
| @@ -127,7 +128,7 @@ int vbg_hgcm_connect(struct vbg_dev *gdev, | |||
| 127 | int rc; | 128 | int rc; |
| 128 | 129 | ||
| 129 | hgcm_connect = vbg_req_alloc(sizeof(*hgcm_connect), | 130 | hgcm_connect = vbg_req_alloc(sizeof(*hgcm_connect), |
| 130 | VMMDEVREQ_HGCM_CONNECT); | 131 | VMMDEVREQ_HGCM_CONNECT, requestor); |
| 131 | if (!hgcm_connect) | 132 | if (!hgcm_connect) |
| 132 | return -ENOMEM; | 133 | return -ENOMEM; |
| 133 | 134 | ||
| @@ -153,13 +154,15 @@ int vbg_hgcm_connect(struct vbg_dev *gdev, | |||
| 153 | } | 154 | } |
| 154 | EXPORT_SYMBOL(vbg_hgcm_connect); | 155 | EXPORT_SYMBOL(vbg_hgcm_connect); |
| 155 | 156 | ||
| 156 | int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 client_id, int *vbox_status) | 157 | int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 requestor, |
| 158 | u32 client_id, int *vbox_status) | ||
| 157 | { | 159 | { |
| 158 | struct vmmdev_hgcm_disconnect *hgcm_disconnect = NULL; | 160 | struct vmmdev_hgcm_disconnect *hgcm_disconnect = NULL; |
| 159 | int rc; | 161 | int rc; |
| 160 | 162 | ||
| 161 | hgcm_disconnect = vbg_req_alloc(sizeof(*hgcm_disconnect), | 163 | hgcm_disconnect = vbg_req_alloc(sizeof(*hgcm_disconnect), |
| 162 | VMMDEVREQ_HGCM_DISCONNECT); | 164 | VMMDEVREQ_HGCM_DISCONNECT, |
| 165 | requestor); | ||
| 163 | if (!hgcm_disconnect) | 166 | if (!hgcm_disconnect) |
| 164 | return -ENOMEM; | 167 | return -ENOMEM; |
| 165 | 168 | ||
| @@ -593,9 +596,10 @@ static int hgcm_call_copy_back_result( | |||
| 593 | return 0; | 596 | return 0; |
| 594 | } | 597 | } |
| 595 | 598 | ||
| 596 | int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 function, | 599 | int vbg_hgcm_call(struct vbg_dev *gdev, u32 requestor, u32 client_id, |
| 597 | u32 timeout_ms, struct vmmdev_hgcm_function_parameter *parms, | 600 | u32 function, u32 timeout_ms, |
| 598 | u32 parm_count, int *vbox_status) | 601 | struct vmmdev_hgcm_function_parameter *parms, u32 parm_count, |
| 602 | int *vbox_status) | ||
| 599 | { | 603 | { |
| 600 | struct vmmdev_hgcm_call *call; | 604 | struct vmmdev_hgcm_call *call; |
| 601 | void **bounce_bufs = NULL; | 605 | void **bounce_bufs = NULL; |
| @@ -615,7 +619,7 @@ int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 function, | |||
| 615 | goto free_bounce_bufs; | 619 | goto free_bounce_bufs; |
| 616 | } | 620 | } |
| 617 | 621 | ||
| 618 | call = vbg_req_alloc(size, VMMDEVREQ_HGCM_CALL); | 622 | call = vbg_req_alloc(size, VMMDEVREQ_HGCM_CALL, requestor); |
| 619 | if (!call) { | 623 | if (!call) { |
| 620 | ret = -ENOMEM; | 624 | ret = -ENOMEM; |
| 621 | goto free_bounce_bufs; | 625 | goto free_bounce_bufs; |
| @@ -647,9 +651,9 @@ EXPORT_SYMBOL(vbg_hgcm_call); | |||
| 647 | 651 | ||
| 648 | #ifdef CONFIG_COMPAT | 652 | #ifdef CONFIG_COMPAT |
| 649 | int vbg_hgcm_call32( | 653 | int vbg_hgcm_call32( |
| 650 | struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms, | 654 | struct vbg_dev *gdev, u32 requestor, u32 client_id, u32 function, |
| 651 | struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count, | 655 | u32 timeout_ms, struct vmmdev_hgcm_function_parameter32 *parm32, |
| 652 | int *vbox_status) | 656 | u32 parm_count, int *vbox_status) |
| 653 | { | 657 | { |
| 654 | struct vmmdev_hgcm_function_parameter *parm64 = NULL; | 658 | struct vmmdev_hgcm_function_parameter *parm64 = NULL; |
| 655 | u32 i, size; | 659 | u32 i, size; |
| @@ -689,7 +693,7 @@ int vbg_hgcm_call32( | |||
| 689 | goto out_free; | 693 | goto out_free; |
| 690 | } | 694 | } |
| 691 | 695 | ||
| 692 | ret = vbg_hgcm_call(gdev, client_id, function, timeout_ms, | 696 | ret = vbg_hgcm_call(gdev, requestor, client_id, function, timeout_ms, |
| 693 | parm64, parm_count, vbox_status); | 697 | parm64, parm_count, vbox_status); |
| 694 | if (ret < 0) | 698 | if (ret < 0) |
| 695 | goto out_free; | 699 | goto out_free; |
diff --git a/drivers/virt/vboxguest/vboxguest_version.h b/drivers/virt/vboxguest/vboxguest_version.h index 77f0c8f8a231..84834dad38d5 100644 --- a/drivers/virt/vboxguest/vboxguest_version.h +++ b/drivers/virt/vboxguest/vboxguest_version.h | |||
| @@ -9,11 +9,10 @@ | |||
| 9 | #ifndef __VBOX_VERSION_H__ | 9 | #ifndef __VBOX_VERSION_H__ |
| 10 | #define __VBOX_VERSION_H__ | 10 | #define __VBOX_VERSION_H__ |
| 11 | 11 | ||
| 12 | /* Last synced October 4th 2017 */ | 12 | #define VBG_VERSION_MAJOR 6 |
| 13 | #define VBG_VERSION_MAJOR 5 | 13 | #define VBG_VERSION_MINOR 0 |
| 14 | #define VBG_VERSION_MINOR 2 | ||
| 15 | #define VBG_VERSION_BUILD 0 | 14 | #define VBG_VERSION_BUILD 0 |
| 16 | #define VBG_SVN_REV 68940 | 15 | #define VBG_SVN_REV 127566 |
| 17 | #define VBG_VERSION_STRING "5.2.0" | 16 | #define VBG_VERSION_STRING "6.0.0" |
| 18 | 17 | ||
| 19 | #endif | 18 | #endif |
diff --git a/drivers/virt/vboxguest/vmmdev.h b/drivers/virt/vboxguest/vmmdev.h index 5e2ae978935d..6337b8d75d96 100644 --- a/drivers/virt/vboxguest/vmmdev.h +++ b/drivers/virt/vboxguest/vmmdev.h | |||
| @@ -98,8 +98,8 @@ struct vmmdev_request_header { | |||
| 98 | s32 rc; | 98 | s32 rc; |
| 99 | /** Reserved field no.1. MBZ. */ | 99 | /** Reserved field no.1. MBZ. */ |
| 100 | u32 reserved1; | 100 | u32 reserved1; |
| 101 | /** Reserved field no.2. MBZ. */ | 101 | /** IN: Requestor information (VMMDEV_REQUESTOR_*) */ |
| 102 | u32 reserved2; | 102 | u32 requestor; |
| 103 | }; | 103 | }; |
| 104 | VMMDEV_ASSERT_SIZE(vmmdev_request_header, 24); | 104 | VMMDEV_ASSERT_SIZE(vmmdev_request_header, 24); |
| 105 | 105 | ||
| @@ -247,6 +247,8 @@ struct vmmdev_guest_info { | |||
| 247 | }; | 247 | }; |
| 248 | VMMDEV_ASSERT_SIZE(vmmdev_guest_info, 24 + 8); | 248 | VMMDEV_ASSERT_SIZE(vmmdev_guest_info, 24 + 8); |
| 249 | 249 | ||
| 250 | #define VMMDEV_GUEST_INFO2_ADDITIONS_FEATURES_REQUESTOR_INFO BIT(0) | ||
| 251 | |||
| 250 | /** struct vmmdev_guestinfo2 - Guest information report, version 2. */ | 252 | /** struct vmmdev_guestinfo2 - Guest information report, version 2. */ |
| 251 | struct vmmdev_guest_info2 { | 253 | struct vmmdev_guest_info2 { |
| 252 | /** Header. */ | 254 | /** Header. */ |
| @@ -259,7 +261,7 @@ struct vmmdev_guest_info2 { | |||
| 259 | u32 additions_build; | 261 | u32 additions_build; |
| 260 | /** SVN revision. */ | 262 | /** SVN revision. */ |
| 261 | u32 additions_revision; | 263 | u32 additions_revision; |
| 262 | /** Feature mask, currently unused. */ | 264 | /** Feature mask. */ |
| 263 | u32 additions_features; | 265 | u32 additions_features; |
| 264 | /** | 266 | /** |
| 265 | * The intentional meaning of this field was: | 267 | * The intentional meaning of this field was: |
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c index ca08c83168f5..0b37867b5c20 100644 --- a/fs/afs/fsclient.c +++ b/fs/afs/fsclient.c | |||
| @@ -1515,8 +1515,8 @@ static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr) | |||
| 1515 | 1515 | ||
| 1516 | xdr_encode_AFS_StoreStatus(&bp, attr); | 1516 | xdr_encode_AFS_StoreStatus(&bp, attr); |
| 1517 | 1517 | ||
| 1518 | *bp++ = 0; /* position of start of write */ | 1518 | *bp++ = htonl(attr->ia_size >> 32); /* position of start of write */ |
| 1519 | *bp++ = 0; | 1519 | *bp++ = htonl((u32) attr->ia_size); |
| 1520 | *bp++ = 0; /* size of write */ | 1520 | *bp++ = 0; /* size of write */ |
| 1521 | *bp++ = 0; | 1521 | *bp++ = 0; |
| 1522 | *bp++ = htonl(attr->ia_size >> 32); /* new file length */ | 1522 | *bp++ = htonl(attr->ia_size >> 32); /* new file length */ |
| @@ -1564,7 +1564,7 @@ static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr) | |||
| 1564 | 1564 | ||
| 1565 | xdr_encode_AFS_StoreStatus(&bp, attr); | 1565 | xdr_encode_AFS_StoreStatus(&bp, attr); |
| 1566 | 1566 | ||
| 1567 | *bp++ = 0; /* position of start of write */ | 1567 | *bp++ = htonl(attr->ia_size); /* position of start of write */ |
| 1568 | *bp++ = 0; /* size of write */ | 1568 | *bp++ = 0; /* size of write */ |
| 1569 | *bp++ = htonl(attr->ia_size); /* new file length */ | 1569 | *bp++ = htonl(attr->ia_size); /* new file length */ |
| 1570 | 1570 | ||
diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c index 5aa57929e8c2..6e97a42d24d1 100644 --- a/fs/afs/yfsclient.c +++ b/fs/afs/yfsclient.c | |||
| @@ -1514,7 +1514,7 @@ static int yfs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr) | |||
| 1514 | bp = xdr_encode_u32(bp, 0); /* RPC flags */ | 1514 | bp = xdr_encode_u32(bp, 0); /* RPC flags */ |
| 1515 | bp = xdr_encode_YFSFid(bp, &vnode->fid); | 1515 | bp = xdr_encode_YFSFid(bp, &vnode->fid); |
| 1516 | bp = xdr_encode_YFS_StoreStatus(bp, attr); | 1516 | bp = xdr_encode_YFS_StoreStatus(bp, attr); |
| 1517 | bp = xdr_encode_u64(bp, 0); /* position of start of write */ | 1517 | bp = xdr_encode_u64(bp, attr->ia_size); /* position of start of write */ |
| 1518 | bp = xdr_encode_u64(bp, 0); /* size of write */ | 1518 | bp = xdr_encode_u64(bp, 0); /* size of write */ |
| 1519 | bp = xdr_encode_u64(bp, attr->ia_size); /* new file length */ | 1519 | bp = xdr_encode_u64(bp, attr->ia_size); /* new file length */ |
| 1520 | yfs_check_req(call, bp); | 1520 | yfs_check_req(call, bp); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 1d49694e6ae3..c5880329ae37 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
| @@ -6174,7 +6174,7 @@ static void btrfs_calculate_inode_block_rsv_size(struct btrfs_fs_info *fs_info, | |||
| 6174 | * | 6174 | * |
| 6175 | * This is overestimating in most cases. | 6175 | * This is overestimating in most cases. |
| 6176 | */ | 6176 | */ |
| 6177 | qgroup_rsv_size = outstanding_extents * fs_info->nodesize; | 6177 | qgroup_rsv_size = (u64)outstanding_extents * fs_info->nodesize; |
| 6178 | 6178 | ||
| 6179 | spin_lock(&block_rsv->lock); | 6179 | spin_lock(&block_rsv->lock); |
| 6180 | block_rsv->size = reserve_size; | 6180 | block_rsv->size = reserve_size; |
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index eb680b715dd6..e659d9d61107 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
| @@ -1922,8 +1922,8 @@ static int qgroup_trace_new_subtree_blocks(struct btrfs_trans_handle* trans, | |||
| 1922 | int i; | 1922 | int i; |
| 1923 | 1923 | ||
| 1924 | /* Level sanity check */ | 1924 | /* Level sanity check */ |
| 1925 | if (cur_level < 0 || cur_level >= BTRFS_MAX_LEVEL || | 1925 | if (cur_level < 0 || cur_level >= BTRFS_MAX_LEVEL - 1 || |
| 1926 | root_level < 0 || root_level >= BTRFS_MAX_LEVEL || | 1926 | root_level < 0 || root_level >= BTRFS_MAX_LEVEL - 1 || |
| 1927 | root_level < cur_level) { | 1927 | root_level < cur_level) { |
| 1928 | btrfs_err_rl(fs_info, | 1928 | btrfs_err_rl(fs_info, |
| 1929 | "%s: bad levels, cur_level=%d root_level=%d", | 1929 | "%s: bad levels, cur_level=%d root_level=%d", |
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 1869ba8e5981..67a6f7d47402 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c | |||
| @@ -2430,8 +2430,9 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, | |||
| 2430 | bitmap_clear(rbio->dbitmap, pagenr, 1); | 2430 | bitmap_clear(rbio->dbitmap, pagenr, 1); |
| 2431 | kunmap(p); | 2431 | kunmap(p); |
| 2432 | 2432 | ||
| 2433 | for (stripe = 0; stripe < rbio->real_stripes; stripe++) | 2433 | for (stripe = 0; stripe < nr_data; stripe++) |
| 2434 | kunmap(page_in_rbio(rbio, stripe, pagenr, 0)); | 2434 | kunmap(page_in_rbio(rbio, stripe, pagenr, 0)); |
| 2435 | kunmap(p_page); | ||
| 2435 | } | 2436 | } |
| 2436 | 2437 | ||
| 2437 | __free_page(p_page); | 2438 | __free_page(p_page); |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index acdad6d658f5..e4e665f422fc 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
| @@ -1886,8 +1886,10 @@ static void btrfs_cleanup_pending_block_groups(struct btrfs_trans_handle *trans) | |||
| 1886 | } | 1886 | } |
| 1887 | } | 1887 | } |
| 1888 | 1888 | ||
| 1889 | static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info) | 1889 | static inline int btrfs_start_delalloc_flush(struct btrfs_trans_handle *trans) |
| 1890 | { | 1890 | { |
| 1891 | struct btrfs_fs_info *fs_info = trans->fs_info; | ||
| 1892 | |||
| 1891 | /* | 1893 | /* |
| 1892 | * We use writeback_inodes_sb here because if we used | 1894 | * We use writeback_inodes_sb here because if we used |
| 1893 | * btrfs_start_delalloc_roots we would deadlock with fs freeze. | 1895 | * btrfs_start_delalloc_roots we would deadlock with fs freeze. |
| @@ -1897,15 +1899,50 @@ static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info) | |||
| 1897 | * from already being in a transaction and our join_transaction doesn't | 1899 | * from already being in a transaction and our join_transaction doesn't |
| 1898 | * have to re-take the fs freeze lock. | 1900 | * have to re-take the fs freeze lock. |
| 1899 | */ | 1901 | */ |
| 1900 | if (btrfs_test_opt(fs_info, FLUSHONCOMMIT)) | 1902 | if (btrfs_test_opt(fs_info, FLUSHONCOMMIT)) { |
| 1901 | writeback_inodes_sb(fs_info->sb, WB_REASON_SYNC); | 1903 | writeback_inodes_sb(fs_info->sb, WB_REASON_SYNC); |
| 1904 | } else { | ||
| 1905 | struct btrfs_pending_snapshot *pending; | ||
| 1906 | struct list_head *head = &trans->transaction->pending_snapshots; | ||
| 1907 | |||
| 1908 | /* | ||
| 1909 | * Flush dellaloc for any root that is going to be snapshotted. | ||
| 1910 | * This is done to avoid a corrupted version of files, in the | ||
| 1911 | * snapshots, that had both buffered and direct IO writes (even | ||
| 1912 | * if they were done sequentially) due to an unordered update of | ||
| 1913 | * the inode's size on disk. | ||
| 1914 | */ | ||
| 1915 | list_for_each_entry(pending, head, list) { | ||
| 1916 | int ret; | ||
| 1917 | |||
| 1918 | ret = btrfs_start_delalloc_snapshot(pending->root); | ||
| 1919 | if (ret) | ||
| 1920 | return ret; | ||
| 1921 | } | ||
| 1922 | } | ||
| 1902 | return 0; | 1923 | return 0; |
| 1903 | } | 1924 | } |
| 1904 | 1925 | ||
| 1905 | static inline void btrfs_wait_delalloc_flush(struct btrfs_fs_info *fs_info) | 1926 | static inline void btrfs_wait_delalloc_flush(struct btrfs_trans_handle *trans) |
| 1906 | { | 1927 | { |
| 1907 | if (btrfs_test_opt(fs_info, FLUSHONCOMMIT)) | 1928 | struct btrfs_fs_info *fs_info = trans->fs_info; |
| 1929 | |||
| 1930 | if (btrfs_test_opt(fs_info, FLUSHONCOMMIT)) { | ||
| 1908 | btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); | 1931 | btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); |
| 1932 | } else { | ||
| 1933 | struct btrfs_pending_snapshot *pending; | ||
| 1934 | struct list_head *head = &trans->transaction->pending_snapshots; | ||
| 1935 | |||
| 1936 | /* | ||
| 1937 | * Wait for any dellaloc that we started previously for the roots | ||
| 1938 | * that are going to be snapshotted. This is to avoid a corrupted | ||
| 1939 | * version of files in the snapshots that had both buffered and | ||
| 1940 | * direct IO writes (even if they were done sequentially). | ||
| 1941 | */ | ||
| 1942 | list_for_each_entry(pending, head, list) | ||
| 1943 | btrfs_wait_ordered_extents(pending->root, | ||
| 1944 | U64_MAX, 0, U64_MAX); | ||
| 1945 | } | ||
| 1909 | } | 1946 | } |
| 1910 | 1947 | ||
| 1911 | int btrfs_commit_transaction(struct btrfs_trans_handle *trans) | 1948 | int btrfs_commit_transaction(struct btrfs_trans_handle *trans) |
| @@ -2023,7 +2060,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) | |||
| 2023 | 2060 | ||
| 2024 | extwriter_counter_dec(cur_trans, trans->type); | 2061 | extwriter_counter_dec(cur_trans, trans->type); |
| 2025 | 2062 | ||
| 2026 | ret = btrfs_start_delalloc_flush(fs_info); | 2063 | ret = btrfs_start_delalloc_flush(trans); |
| 2027 | if (ret) | 2064 | if (ret) |
| 2028 | goto cleanup_transaction; | 2065 | goto cleanup_transaction; |
| 2029 | 2066 | ||
| @@ -2039,7 +2076,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) | |||
| 2039 | if (ret) | 2076 | if (ret) |
| 2040 | goto cleanup_transaction; | 2077 | goto cleanup_transaction; |
| 2041 | 2078 | ||
| 2042 | btrfs_wait_delalloc_flush(fs_info); | 2079 | btrfs_wait_delalloc_flush(trans); |
| 2043 | 2080 | ||
| 2044 | btrfs_scrub_pause(fs_info); | 2081 | btrfs_scrub_pause(fs_info); |
| 2045 | /* | 2082 | /* |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index f06454a55e00..561884f60d35 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
| @@ -3578,9 +3578,16 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
| 3578 | } | 3578 | } |
| 3579 | btrfs_release_path(path); | 3579 | btrfs_release_path(path); |
| 3580 | 3580 | ||
| 3581 | /* find the first key from this transaction again */ | 3581 | /* |
| 3582 | * Find the first key from this transaction again. See the note for | ||
| 3583 | * log_new_dir_dentries, if we're logging a directory recursively we | ||
| 3584 | * won't be holding its i_mutex, which means we can modify the directory | ||
| 3585 | * while we're logging it. If we remove an entry between our first | ||
| 3586 | * search and this search we'll not find the key again and can just | ||
| 3587 | * bail. | ||
| 3588 | */ | ||
| 3582 | ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0); | 3589 | ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0); |
| 3583 | if (WARN_ON(ret != 0)) | 3590 | if (ret != 0) |
| 3584 | goto done; | 3591 | goto done; |
| 3585 | 3592 | ||
| 3586 | /* | 3593 | /* |
| @@ -4544,6 +4551,19 @@ static int logged_inode_size(struct btrfs_root *log, struct btrfs_inode *inode, | |||
| 4544 | item = btrfs_item_ptr(path->nodes[0], path->slots[0], | 4551 | item = btrfs_item_ptr(path->nodes[0], path->slots[0], |
| 4545 | struct btrfs_inode_item); | 4552 | struct btrfs_inode_item); |
| 4546 | *size_ret = btrfs_inode_size(path->nodes[0], item); | 4553 | *size_ret = btrfs_inode_size(path->nodes[0], item); |
| 4554 | /* | ||
| 4555 | * If the in-memory inode's i_size is smaller then the inode | ||
| 4556 | * size stored in the btree, return the inode's i_size, so | ||
| 4557 | * that we get a correct inode size after replaying the log | ||
| 4558 | * when before a power failure we had a shrinking truncate | ||
| 4559 | * followed by addition of a new name (rename / new hard link). | ||
| 4560 | * Otherwise return the inode size from the btree, to avoid | ||
| 4561 | * data loss when replaying a log due to previously doing a | ||
| 4562 | * write that expands the inode's size and logging a new name | ||
| 4563 | * immediately after. | ||
| 4564 | */ | ||
| 4565 | if (*size_ret > inode->vfs_inode.i_size) | ||
| 4566 | *size_ret = inode->vfs_inode.i_size; | ||
| 4547 | } | 4567 | } |
| 4548 | 4568 | ||
| 4549 | btrfs_release_path(path); | 4569 | btrfs_release_path(path); |
| @@ -4705,15 +4725,8 @@ static int btrfs_log_trailing_hole(struct btrfs_trans_handle *trans, | |||
| 4705 | struct btrfs_file_extent_item); | 4725 | struct btrfs_file_extent_item); |
| 4706 | 4726 | ||
| 4707 | if (btrfs_file_extent_type(leaf, extent) == | 4727 | if (btrfs_file_extent_type(leaf, extent) == |
| 4708 | BTRFS_FILE_EXTENT_INLINE) { | 4728 | BTRFS_FILE_EXTENT_INLINE) |
| 4709 | len = btrfs_file_extent_ram_bytes(leaf, extent); | ||
| 4710 | ASSERT(len == i_size || | ||
| 4711 | (len == fs_info->sectorsize && | ||
| 4712 | btrfs_file_extent_compression(leaf, extent) != | ||
| 4713 | BTRFS_COMPRESS_NONE) || | ||
| 4714 | (len < i_size && i_size < fs_info->sectorsize)); | ||
| 4715 | return 0; | 4729 | return 0; |
| 4716 | } | ||
| 4717 | 4730 | ||
| 4718 | len = btrfs_file_extent_num_bytes(leaf, extent); | 4731 | len = btrfs_file_extent_num_bytes(leaf, extent); |
| 4719 | /* Last extent goes beyond i_size, no need to log a hole. */ | 4732 | /* Last extent goes beyond i_size, no need to log a hole. */ |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 9024eee889b9..db934ceae9c1 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -6407,7 +6407,7 @@ static void btrfs_end_bio(struct bio *bio) | |||
| 6407 | if (bio_op(bio) == REQ_OP_WRITE) | 6407 | if (bio_op(bio) == REQ_OP_WRITE) |
| 6408 | btrfs_dev_stat_inc_and_print(dev, | 6408 | btrfs_dev_stat_inc_and_print(dev, |
| 6409 | BTRFS_DEV_STAT_WRITE_ERRS); | 6409 | BTRFS_DEV_STAT_WRITE_ERRS); |
| 6410 | else | 6410 | else if (!(bio->bi_opf & REQ_RAHEAD)) |
| 6411 | btrfs_dev_stat_inc_and_print(dev, | 6411 | btrfs_dev_stat_inc_and_print(dev, |
| 6412 | BTRFS_DEV_STAT_READ_ERRS); | 6412 | BTRFS_DEV_STAT_READ_ERRS); |
| 6413 | if (bio->bi_opf & REQ_PREFLUSH) | 6413 | if (bio->bi_opf & REQ_PREFLUSH) |
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index e3346628efe2..2d61ddda9bf5 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
| @@ -524,6 +524,7 @@ static void ceph_i_callback(struct rcu_head *head) | |||
| 524 | struct inode *inode = container_of(head, struct inode, i_rcu); | 524 | struct inode *inode = container_of(head, struct inode, i_rcu); |
| 525 | struct ceph_inode_info *ci = ceph_inode(inode); | 525 | struct ceph_inode_info *ci = ceph_inode(inode); |
| 526 | 526 | ||
| 527 | kfree(ci->i_symlink); | ||
| 527 | kmem_cache_free(ceph_inode_cachep, ci); | 528 | kmem_cache_free(ceph_inode_cachep, ci); |
| 528 | } | 529 | } |
| 529 | 530 | ||
| @@ -566,7 +567,6 @@ void ceph_destroy_inode(struct inode *inode) | |||
| 566 | } | 567 | } |
| 567 | } | 568 | } |
| 568 | 569 | ||
| 569 | kfree(ci->i_symlink); | ||
| 570 | while ((n = rb_first(&ci->i_fragtree)) != NULL) { | 570 | while ((n = rb_first(&ci->i_fragtree)) != NULL) { |
| 571 | frag = rb_entry(n, struct ceph_inode_frag, node); | 571 | frag = rb_entry(n, struct ceph_inode_frag, node); |
| 572 | rb_erase(n, &ci->i_fragtree); | 572 | rb_erase(n, &ci->i_fragtree); |
diff --git a/fs/fs_parser.c b/fs/fs_parser.c index 842e8f749db6..570d71043acf 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c | |||
| @@ -410,7 +410,7 @@ bool fs_validate_description(const struct fs_parameter_description *desc) | |||
| 410 | for (param = desc->specs; param->name; param++) { | 410 | for (param = desc->specs; param->name; param++) { |
| 411 | if (param->opt == e->opt && | 411 | if (param->opt == e->opt && |
| 412 | param->type != fs_param_is_enum) { | 412 | param->type != fs_param_is_enum) { |
| 413 | pr_err("VALIDATE %s: e[%lu] enum val for %s\n", | 413 | pr_err("VALIDATE %s: e[%tu] enum val for %s\n", |
| 414 | name, e - desc->enums, param->name); | 414 | name, e - desc->enums, param->name); |
| 415 | good = false; | 415 | good = false; |
| 416 | } | 416 | } |
diff --git a/fs/io_uring.c b/fs/io_uring.c index 6aaa30580a2b..bbdbd56cf2ac 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c | |||
| @@ -1022,6 +1022,8 @@ static int io_write(struct io_kiocb *req, const struct sqe_submit *s, | |||
| 1022 | 1022 | ||
| 1023 | ret = rw_verify_area(WRITE, file, &kiocb->ki_pos, iov_count); | 1023 | ret = rw_verify_area(WRITE, file, &kiocb->ki_pos, iov_count); |
| 1024 | if (!ret) { | 1024 | if (!ret) { |
| 1025 | ssize_t ret2; | ||
| 1026 | |||
| 1025 | /* | 1027 | /* |
| 1026 | * Open-code file_start_write here to grab freeze protection, | 1028 | * Open-code file_start_write here to grab freeze protection, |
| 1027 | * which will be released by another thread in | 1029 | * which will be released by another thread in |
| @@ -1036,7 +1038,19 @@ static int io_write(struct io_kiocb *req, const struct sqe_submit *s, | |||
| 1036 | SB_FREEZE_WRITE); | 1038 | SB_FREEZE_WRITE); |
| 1037 | } | 1039 | } |
| 1038 | kiocb->ki_flags |= IOCB_WRITE; | 1040 | kiocb->ki_flags |= IOCB_WRITE; |
| 1039 | io_rw_done(kiocb, call_write_iter(file, kiocb, &iter)); | 1041 | |
| 1042 | ret2 = call_write_iter(file, kiocb, &iter); | ||
| 1043 | if (!force_nonblock || ret2 != -EAGAIN) { | ||
| 1044 | io_rw_done(kiocb, ret2); | ||
| 1045 | } else { | ||
| 1046 | /* | ||
| 1047 | * If ->needs_lock is true, we're already in async | ||
| 1048 | * context. | ||
| 1049 | */ | ||
| 1050 | if (!s->needs_lock) | ||
| 1051 | io_async_list_note(WRITE, req, iov_count); | ||
| 1052 | ret = -EAGAIN; | ||
| 1053 | } | ||
| 1040 | } | 1054 | } |
| 1041 | out_free: | 1055 | out_free: |
| 1042 | kfree(iovec); | 1056 | kfree(iovec); |
| @@ -1968,7 +1982,15 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, | |||
| 1968 | return 0; | 1982 | return 0; |
| 1969 | 1983 | ||
| 1970 | if (sig) { | 1984 | if (sig) { |
| 1971 | ret = set_user_sigmask(sig, &ksigmask, &sigsaved, sigsz); | 1985 | #ifdef CONFIG_COMPAT |
| 1986 | if (in_compat_syscall()) | ||
| 1987 | ret = set_compat_user_sigmask((const compat_sigset_t __user *)sig, | ||
| 1988 | &ksigmask, &sigsaved, sigsz); | ||
| 1989 | else | ||
| 1990 | #endif | ||
| 1991 | ret = set_user_sigmask(sig, &ksigmask, | ||
| 1992 | &sigsaved, sigsz); | ||
| 1993 | |||
| 1972 | if (ret) | 1994 | if (ret) |
| 1973 | return ret; | 1995 | return ret; |
| 1974 | } | 1996 | } |
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 93fb7cf0b92b..f0b5c987d6ae 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
| @@ -290,12 +290,11 @@ void nlmclnt_release_host(struct nlm_host *host) | |||
| 290 | 290 | ||
| 291 | WARN_ON_ONCE(host->h_server); | 291 | WARN_ON_ONCE(host->h_server); |
| 292 | 292 | ||
| 293 | if (refcount_dec_and_test(&host->h_count)) { | 293 | if (refcount_dec_and_mutex_lock(&host->h_count, &nlm_host_mutex)) { |
| 294 | WARN_ON_ONCE(!list_empty(&host->h_lockowners)); | 294 | WARN_ON_ONCE(!list_empty(&host->h_lockowners)); |
| 295 | WARN_ON_ONCE(!list_empty(&host->h_granted)); | 295 | WARN_ON_ONCE(!list_empty(&host->h_granted)); |
| 296 | WARN_ON_ONCE(!list_empty(&host->h_reclaim)); | 296 | WARN_ON_ONCE(!list_empty(&host->h_reclaim)); |
| 297 | 297 | ||
| 298 | mutex_lock(&nlm_host_mutex); | ||
| 299 | nlm_destroy_host_locked(host); | 298 | nlm_destroy_host_locked(host); |
| 300 | mutex_unlock(&nlm_host_mutex); | 299 | mutex_unlock(&nlm_host_mutex); |
| 301 | } | 300 | } |
diff --git a/fs/locks.c b/fs/locks.c index eaa1cfaf73b0..71d0c6c2aac5 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
| @@ -1160,6 +1160,11 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, | |||
| 1160 | */ | 1160 | */ |
| 1161 | error = -EDEADLK; | 1161 | error = -EDEADLK; |
| 1162 | spin_lock(&blocked_lock_lock); | 1162 | spin_lock(&blocked_lock_lock); |
| 1163 | /* | ||
| 1164 | * Ensure that we don't find any locks blocked on this | ||
| 1165 | * request during deadlock detection. | ||
| 1166 | */ | ||
| 1167 | __locks_wake_up_blocks(request); | ||
| 1163 | if (likely(!posix_locks_deadlock(request, fl))) { | 1168 | if (likely(!posix_locks_deadlock(request, fl))) { |
| 1164 | error = FILE_LOCK_DEFERRED; | 1169 | error = FILE_LOCK_DEFERRED; |
| 1165 | __locks_insert_block(fl, request, | 1170 | __locks_insert_block(fl, request, |
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index fb1cf1a4bda2..90d71fda65ce 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
| @@ -453,7 +453,7 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
| 453 | case XPRT_TRANSPORT_RDMA: | 453 | case XPRT_TRANSPORT_RDMA: |
| 454 | if (retrans == NFS_UNSPEC_RETRANS) | 454 | if (retrans == NFS_UNSPEC_RETRANS) |
| 455 | to->to_retries = NFS_DEF_TCP_RETRANS; | 455 | to->to_retries = NFS_DEF_TCP_RETRANS; |
| 456 | if (timeo == NFS_UNSPEC_TIMEO || to->to_retries == 0) | 456 | if (timeo == NFS_UNSPEC_TIMEO || to->to_initval == 0) |
| 457 | to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; | 457 | to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; |
| 458 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) | 458 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) |
| 459 | to->to_initval = NFS_MAX_TCP_TIMEOUT; | 459 | to->to_initval = NFS_MAX_TCP_TIMEOUT; |
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index f9264e1922a2..6673d4ff5a2a 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
| @@ -1289,6 +1289,7 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg, | |||
| 1289 | static int ff_layout_read_done_cb(struct rpc_task *task, | 1289 | static int ff_layout_read_done_cb(struct rpc_task *task, |
| 1290 | struct nfs_pgio_header *hdr) | 1290 | struct nfs_pgio_header *hdr) |
| 1291 | { | 1291 | { |
| 1292 | int new_idx = hdr->pgio_mirror_idx; | ||
| 1292 | int err; | 1293 | int err; |
| 1293 | 1294 | ||
| 1294 | trace_nfs4_pnfs_read(hdr, task->tk_status); | 1295 | trace_nfs4_pnfs_read(hdr, task->tk_status); |
| @@ -1307,7 +1308,7 @@ static int ff_layout_read_done_cb(struct rpc_task *task, | |||
| 1307 | case -NFS4ERR_RESET_TO_PNFS: | 1308 | case -NFS4ERR_RESET_TO_PNFS: |
| 1308 | if (ff_layout_choose_best_ds_for_read(hdr->lseg, | 1309 | if (ff_layout_choose_best_ds_for_read(hdr->lseg, |
| 1309 | hdr->pgio_mirror_idx + 1, | 1310 | hdr->pgio_mirror_idx + 1, |
| 1310 | &hdr->pgio_mirror_idx)) | 1311 | &new_idx)) |
| 1311 | goto out_layouterror; | 1312 | goto out_layouterror; |
| 1312 | set_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags); | 1313 | set_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags); |
| 1313 | return task->tk_status; | 1314 | return task->tk_status; |
| @@ -1320,7 +1321,9 @@ static int ff_layout_read_done_cb(struct rpc_task *task, | |||
| 1320 | 1321 | ||
| 1321 | return 0; | 1322 | return 0; |
| 1322 | out_layouterror: | 1323 | out_layouterror: |
| 1324 | ff_layout_read_record_layoutstats_done(task, hdr); | ||
| 1323 | ff_layout_send_layouterror(hdr->lseg); | 1325 | ff_layout_send_layouterror(hdr->lseg); |
| 1326 | hdr->pgio_mirror_idx = new_idx; | ||
| 1324 | out_eagain: | 1327 | out_eagain: |
| 1325 | rpc_restart_call_prepare(task); | 1328 | rpc_restart_call_prepare(task); |
| 1326 | return -EAGAIN; | 1329 | return -EAGAIN; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4dbb0ee23432..741ff8c9c6ed 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -2933,7 +2933,8 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, | |||
| 2933 | } | 2933 | } |
| 2934 | 2934 | ||
| 2935 | out: | 2935 | out: |
| 2936 | nfs4_sequence_free_slot(&opendata->o_res.seq_res); | 2936 | if (!opendata->cancelled) |
| 2937 | nfs4_sequence_free_slot(&opendata->o_res.seq_res); | ||
| 2937 | return ret; | 2938 | return ret; |
| 2938 | } | 2939 | } |
| 2939 | 2940 | ||
| @@ -6301,7 +6302,6 @@ static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl, | |||
| 6301 | p->arg.seqid = seqid; | 6302 | p->arg.seqid = seqid; |
| 6302 | p->res.seqid = seqid; | 6303 | p->res.seqid = seqid; |
| 6303 | p->lsp = lsp; | 6304 | p->lsp = lsp; |
| 6304 | refcount_inc(&lsp->ls_count); | ||
| 6305 | /* Ensure we don't close file until we're done freeing locks! */ | 6305 | /* Ensure we don't close file until we're done freeing locks! */ |
| 6306 | p->ctx = get_nfs_open_context(ctx); | 6306 | p->ctx = get_nfs_open_context(ctx); |
| 6307 | p->l_ctx = nfs_get_lock_context(ctx); | 6307 | p->l_ctx = nfs_get_lock_context(ctx); |
| @@ -6526,7 +6526,6 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl, | |||
| 6526 | p->res.lock_seqid = p->arg.lock_seqid; | 6526 | p->res.lock_seqid = p->arg.lock_seqid; |
| 6527 | p->lsp = lsp; | 6527 | p->lsp = lsp; |
| 6528 | p->server = server; | 6528 | p->server = server; |
| 6529 | refcount_inc(&lsp->ls_count); | ||
| 6530 | p->ctx = get_nfs_open_context(ctx); | 6529 | p->ctx = get_nfs_open_context(ctx); |
| 6531 | locks_init_lock(&p->fl); | 6530 | locks_init_lock(&p->fl); |
| 6532 | locks_copy_lock(&p->fl, fl); | 6531 | locks_copy_lock(&p->fl, fl); |
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index a35259eebc56..1dc9a08e8bdc 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c | |||
| @@ -4719,22 +4719,23 @@ out: | |||
| 4719 | 4719 | ||
| 4720 | /* Lock an inode and grab a bh pointing to the inode. */ | 4720 | /* Lock an inode and grab a bh pointing to the inode. */ |
| 4721 | int ocfs2_reflink_inodes_lock(struct inode *s_inode, | 4721 | int ocfs2_reflink_inodes_lock(struct inode *s_inode, |
| 4722 | struct buffer_head **bh1, | 4722 | struct buffer_head **bh_s, |
| 4723 | struct inode *t_inode, | 4723 | struct inode *t_inode, |
| 4724 | struct buffer_head **bh2) | 4724 | struct buffer_head **bh_t) |
| 4725 | { | 4725 | { |
| 4726 | struct inode *inode1; | 4726 | struct inode *inode1 = s_inode; |
| 4727 | struct inode *inode2; | 4727 | struct inode *inode2 = t_inode; |
| 4728 | struct ocfs2_inode_info *oi1; | 4728 | struct ocfs2_inode_info *oi1; |
| 4729 | struct ocfs2_inode_info *oi2; | 4729 | struct ocfs2_inode_info *oi2; |
| 4730 | struct buffer_head *bh1 = NULL; | ||
| 4731 | struct buffer_head *bh2 = NULL; | ||
| 4730 | bool same_inode = (s_inode == t_inode); | 4732 | bool same_inode = (s_inode == t_inode); |
| 4733 | bool need_swap = (inode1->i_ino > inode2->i_ino); | ||
| 4731 | int status; | 4734 | int status; |
| 4732 | 4735 | ||
| 4733 | /* First grab the VFS and rw locks. */ | 4736 | /* First grab the VFS and rw locks. */ |
| 4734 | lock_two_nondirectories(s_inode, t_inode); | 4737 | lock_two_nondirectories(s_inode, t_inode); |
| 4735 | inode1 = s_inode; | 4738 | if (need_swap) |
| 4736 | inode2 = t_inode; | ||
| 4737 | if (inode1->i_ino > inode2->i_ino) | ||
| 4738 | swap(inode1, inode2); | 4739 | swap(inode1, inode2); |
| 4739 | 4740 | ||
| 4740 | status = ocfs2_rw_lock(inode1, 1); | 4741 | status = ocfs2_rw_lock(inode1, 1); |
| @@ -4757,17 +4758,13 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode, | |||
| 4757 | trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno, | 4758 | trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno, |
| 4758 | (unsigned long long)oi2->ip_blkno); | 4759 | (unsigned long long)oi2->ip_blkno); |
| 4759 | 4760 | ||
| 4760 | if (*bh1) | ||
| 4761 | *bh1 = NULL; | ||
| 4762 | if (*bh2) | ||
| 4763 | *bh2 = NULL; | ||
| 4764 | |||
| 4765 | /* We always want to lock the one with the lower lockid first. */ | 4761 | /* We always want to lock the one with the lower lockid first. */ |
| 4766 | if (oi1->ip_blkno > oi2->ip_blkno) | 4762 | if (oi1->ip_blkno > oi2->ip_blkno) |
| 4767 | mlog_errno(-ENOLCK); | 4763 | mlog_errno(-ENOLCK); |
| 4768 | 4764 | ||
| 4769 | /* lock id1 */ | 4765 | /* lock id1 */ |
| 4770 | status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_REFLINK_TARGET); | 4766 | status = ocfs2_inode_lock_nested(inode1, &bh1, 1, |
| 4767 | OI_LS_REFLINK_TARGET); | ||
| 4771 | if (status < 0) { | 4768 | if (status < 0) { |
| 4772 | if (status != -ENOENT) | 4769 | if (status != -ENOENT) |
| 4773 | mlog_errno(status); | 4770 | mlog_errno(status); |
| @@ -4776,15 +4773,25 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode, | |||
| 4776 | 4773 | ||
| 4777 | /* lock id2 */ | 4774 | /* lock id2 */ |
| 4778 | if (!same_inode) { | 4775 | if (!same_inode) { |
| 4779 | status = ocfs2_inode_lock_nested(inode2, bh2, 1, | 4776 | status = ocfs2_inode_lock_nested(inode2, &bh2, 1, |
| 4780 | OI_LS_REFLINK_TARGET); | 4777 | OI_LS_REFLINK_TARGET); |
| 4781 | if (status < 0) { | 4778 | if (status < 0) { |
| 4782 | if (status != -ENOENT) | 4779 | if (status != -ENOENT) |
| 4783 | mlog_errno(status); | 4780 | mlog_errno(status); |
| 4784 | goto out_cl1; | 4781 | goto out_cl1; |
| 4785 | } | 4782 | } |
| 4786 | } else | 4783 | } else { |
| 4787 | *bh2 = *bh1; | 4784 | bh2 = bh1; |
| 4785 | } | ||
| 4786 | |||
| 4787 | /* | ||
| 4788 | * If we swapped inode order above, we have to swap the buffer heads | ||
| 4789 | * before passing them back to the caller. | ||
| 4790 | */ | ||
| 4791 | if (need_swap) | ||
| 4792 | swap(bh1, bh2); | ||
| 4793 | *bh_s = bh1; | ||
| 4794 | *bh_t = bh2; | ||
| 4788 | 4795 | ||
| 4789 | trace_ocfs2_double_lock_end( | 4796 | trace_ocfs2_double_lock_end( |
| 4790 | (unsigned long long)oi1->ip_blkno, | 4797 | (unsigned long long)oi1->ip_blkno, |
| @@ -4794,8 +4801,7 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode, | |||
| 4794 | 4801 | ||
| 4795 | out_cl1: | 4802 | out_cl1: |
| 4796 | ocfs2_inode_unlock(inode1, 1); | 4803 | ocfs2_inode_unlock(inode1, 1); |
| 4797 | brelse(*bh1); | 4804 | brelse(bh1); |
| 4798 | *bh1 = NULL; | ||
| 4799 | out_rw2: | 4805 | out_rw2: |
| 4800 | ocfs2_rw_unlock(inode2, 1); | 4806 | ocfs2_rw_unlock(inode2, 1); |
| 4801 | out_i2: | 4807 | out_i2: |
| @@ -733,6 +733,12 @@ static int do_dentry_open(struct file *f, | |||
| 733 | return 0; | 733 | return 0; |
| 734 | } | 734 | } |
| 735 | 735 | ||
| 736 | /* Any file opened for execve()/uselib() has to be a regular file. */ | ||
| 737 | if (unlikely(f->f_flags & FMODE_EXEC && !S_ISREG(inode->i_mode))) { | ||
| 738 | error = -EACCES; | ||
| 739 | goto cleanup_file; | ||
| 740 | } | ||
| 741 | |||
| 736 | if (f->f_mode & FMODE_WRITE && !special_file(inode->i_mode)) { | 742 | if (f->f_mode & FMODE_WRITE && !special_file(inode->i_mode)) { |
| 737 | error = get_write_access(inode); | 743 | error = get_write_access(inode); |
| 738 | if (unlikely(error)) | 744 | if (unlikely(error)) |
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index d29d869abec1..f5834488b67d 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c | |||
| @@ -615,7 +615,7 @@ static void __init proc_kcore_text_init(void) | |||
| 615 | /* | 615 | /* |
| 616 | * MODULES_VADDR has no intersection with VMALLOC_ADDR. | 616 | * MODULES_VADDR has no intersection with VMALLOC_ADDR. |
| 617 | */ | 617 | */ |
| 618 | struct kcore_list kcore_modules; | 618 | static struct kcore_list kcore_modules; |
| 619 | static void __init add_modules_range(void) | 619 | static void __init add_modules_range(void) |
| 620 | { | 620 | { |
| 621 | if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) { | 621 | if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) { |
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 4d598a399bbf..d65390727541 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
| @@ -1626,7 +1626,8 @@ static void drop_sysctl_table(struct ctl_table_header *header) | |||
| 1626 | if (--header->nreg) | 1626 | if (--header->nreg) |
| 1627 | return; | 1627 | return; |
| 1628 | 1628 | ||
| 1629 | put_links(header); | 1629 | if (parent) |
| 1630 | put_links(header); | ||
| 1630 | start_unregistering(header); | 1631 | start_unregistering(header); |
| 1631 | if (!--header->count) | 1632 | if (!--header->count) |
| 1632 | kfree_rcu(header, rcu); | 1633 | kfree_rcu(header, rcu); |
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 48502cb9990f..4637ae1ae91c 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
| @@ -1191,7 +1191,10 @@ xfs_iread_extents( | |||
| 1191 | * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. | 1191 | * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. |
| 1192 | */ | 1192 | */ |
| 1193 | level = be16_to_cpu(block->bb_level); | 1193 | level = be16_to_cpu(block->bb_level); |
| 1194 | ASSERT(level > 0); | 1194 | if (unlikely(level == 0)) { |
| 1195 | XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); | ||
| 1196 | return -EFSCORRUPTED; | ||
| 1197 | } | ||
| 1195 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); | 1198 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); |
| 1196 | bno = be64_to_cpu(*pp); | 1199 | bno = be64_to_cpu(*pp); |
| 1197 | 1200 | ||
| @@ -4249,9 +4252,13 @@ xfs_bmapi_write( | |||
| 4249 | struct xfs_bmbt_irec *mval, /* output: map values */ | 4252 | struct xfs_bmbt_irec *mval, /* output: map values */ |
| 4250 | int *nmap) /* i/o: mval size/count */ | 4253 | int *nmap) /* i/o: mval size/count */ |
| 4251 | { | 4254 | { |
| 4255 | struct xfs_bmalloca bma = { | ||
| 4256 | .tp = tp, | ||
| 4257 | .ip = ip, | ||
| 4258 | .total = total, | ||
| 4259 | }; | ||
| 4252 | struct xfs_mount *mp = ip->i_mount; | 4260 | struct xfs_mount *mp = ip->i_mount; |
| 4253 | struct xfs_ifork *ifp; | 4261 | struct xfs_ifork *ifp; |
| 4254 | struct xfs_bmalloca bma = { NULL }; /* args for xfs_bmap_alloc */ | ||
| 4255 | xfs_fileoff_t end; /* end of mapped file region */ | 4262 | xfs_fileoff_t end; /* end of mapped file region */ |
| 4256 | bool eof = false; /* after the end of extents */ | 4263 | bool eof = false; /* after the end of extents */ |
| 4257 | int error; /* error return */ | 4264 | int error; /* error return */ |
| @@ -4319,10 +4326,6 @@ xfs_bmapi_write( | |||
| 4319 | eof = true; | 4326 | eof = true; |
| 4320 | if (!xfs_iext_peek_prev_extent(ifp, &bma.icur, &bma.prev)) | 4327 | if (!xfs_iext_peek_prev_extent(ifp, &bma.icur, &bma.prev)) |
| 4321 | bma.prev.br_startoff = NULLFILEOFF; | 4328 | bma.prev.br_startoff = NULLFILEOFF; |
| 4322 | bma.tp = tp; | ||
| 4323 | bma.ip = ip; | ||
| 4324 | bma.total = total; | ||
| 4325 | bma.datatype = 0; | ||
| 4326 | bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork); | 4329 | bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork); |
| 4327 | 4330 | ||
| 4328 | n = 0; | 4331 | n = 0; |
diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c index 6f94d1f7322d..117910db51b8 100644 --- a/fs/xfs/scrub/btree.c +++ b/fs/xfs/scrub/btree.c | |||
| @@ -415,8 +415,17 @@ xchk_btree_check_owner( | |||
| 415 | struct xfs_btree_cur *cur = bs->cur; | 415 | struct xfs_btree_cur *cur = bs->cur; |
| 416 | struct check_owner *co; | 416 | struct check_owner *co; |
| 417 | 417 | ||
| 418 | if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && bp == NULL) | 418 | /* |
| 419 | * In theory, xfs_btree_get_block should only give us a null buffer | ||
| 420 | * pointer for the root of a root-in-inode btree type, but we need | ||
| 421 | * to check defensively here in case the cursor state is also screwed | ||
| 422 | * up. | ||
| 423 | */ | ||
| 424 | if (bp == NULL) { | ||
| 425 | if (!(cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)) | ||
| 426 | xchk_btree_set_corrupt(bs->sc, bs->cur, level); | ||
| 419 | return 0; | 427 | return 0; |
| 428 | } | ||
| 420 | 429 | ||
| 421 | /* | 430 | /* |
| 422 | * We want to cross-reference each btree block with the bnobt | 431 | * We want to cross-reference each btree block with the bnobt |
diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c index f1260b4bfdee..90527b094878 100644 --- a/fs/xfs/scrub/dabtree.c +++ b/fs/xfs/scrub/dabtree.c | |||
| @@ -574,6 +574,11 @@ xchk_da_btree( | |||
| 574 | /* Drill another level deeper. */ | 574 | /* Drill another level deeper. */ |
| 575 | blkno = be32_to_cpu(key->before); | 575 | blkno = be32_to_cpu(key->before); |
| 576 | level++; | 576 | level++; |
| 577 | if (level >= XFS_DA_NODE_MAXDEPTH) { | ||
| 578 | /* Too deep! */ | ||
| 579 | xchk_da_set_corrupt(&ds, level - 1); | ||
| 580 | break; | ||
| 581 | } | ||
| 577 | ds.tree_level--; | 582 | ds.tree_level--; |
| 578 | error = xchk_da_btree_block(&ds, level, blkno); | 583 | error = xchk_da_btree_block(&ds, level, blkno); |
| 579 | if (error) | 584 | if (error) |
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c index 93f07edafd81..9ee2a7d02e70 100644 --- a/fs/xfs/xfs_discard.c +++ b/fs/xfs/xfs_discard.c | |||
| @@ -161,6 +161,14 @@ xfs_ioc_trim( | |||
| 161 | return -EPERM; | 161 | return -EPERM; |
| 162 | if (!blk_queue_discard(q)) | 162 | if (!blk_queue_discard(q)) |
| 163 | return -EOPNOTSUPP; | 163 | return -EOPNOTSUPP; |
| 164 | |||
| 165 | /* | ||
| 166 | * We haven't recovered the log, so we cannot use our bnobt-guided | ||
| 167 | * storage zapping commands. | ||
| 168 | */ | ||
| 169 | if (mp->m_flags & XFS_MOUNT_NORECOVERY) | ||
| 170 | return -EROFS; | ||
| 171 | |||
| 164 | if (copy_from_user(&range, urange, sizeof(range))) | 172 | if (copy_from_user(&range, urange, sizeof(range))) |
| 165 | return -EFAULT; | 173 | return -EFAULT; |
| 166 | 174 | ||
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 1f2e2845eb76..a7ceae90110e 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
| @@ -529,18 +529,17 @@ xfs_file_dio_aio_write( | |||
| 529 | count = iov_iter_count(from); | 529 | count = iov_iter_count(from); |
| 530 | 530 | ||
| 531 | /* | 531 | /* |
| 532 | * If we are doing unaligned IO, wait for all other IO to drain, | 532 | * If we are doing unaligned IO, we can't allow any other overlapping IO |
| 533 | * otherwise demote the lock if we had to take the exclusive lock | 533 | * in-flight at the same time or we risk data corruption. Wait for all |
| 534 | * for other reasons in xfs_file_aio_write_checks. | 534 | * other IO to drain before we submit. If the IO is aligned, demote the |
| 535 | * iolock if we had to take the exclusive lock in | ||
| 536 | * xfs_file_aio_write_checks() for other reasons. | ||
| 535 | */ | 537 | */ |
| 536 | if (unaligned_io) { | 538 | if (unaligned_io) { |
| 537 | /* If we are going to wait for other DIO to finish, bail */ | 539 | /* unaligned dio always waits, bail */ |
| 538 | if (iocb->ki_flags & IOCB_NOWAIT) { | 540 | if (iocb->ki_flags & IOCB_NOWAIT) |
| 539 | if (atomic_read(&inode->i_dio_count)) | 541 | return -EAGAIN; |
| 540 | return -EAGAIN; | 542 | inode_dio_wait(inode); |
| 541 | } else { | ||
| 542 | inode_dio_wait(inode); | ||
| 543 | } | ||
| 544 | } else if (iolock == XFS_IOLOCK_EXCL) { | 543 | } else if (iolock == XFS_IOLOCK_EXCL) { |
| 545 | xfs_ilock_demote(ip, XFS_IOLOCK_EXCL); | 544 | xfs_ilock_demote(ip, XFS_IOLOCK_EXCL); |
| 546 | iolock = XFS_IOLOCK_SHARED; | 545 | iolock = XFS_IOLOCK_SHARED; |
| @@ -548,6 +547,14 @@ xfs_file_dio_aio_write( | |||
| 548 | 547 | ||
| 549 | trace_xfs_file_direct_write(ip, count, iocb->ki_pos); | 548 | trace_xfs_file_direct_write(ip, count, iocb->ki_pos); |
| 550 | ret = iomap_dio_rw(iocb, from, &xfs_iomap_ops, xfs_dio_write_end_io); | 549 | ret = iomap_dio_rw(iocb, from, &xfs_iomap_ops, xfs_dio_write_end_io); |
| 550 | |||
| 551 | /* | ||
| 552 | * If unaligned, this is the only IO in-flight. If it has not yet | ||
| 553 | * completed, wait on it before we release the iolock to prevent | ||
| 554 | * subsequent overlapping IO. | ||
| 555 | */ | ||
| 556 | if (ret == -EIOCBQUEUED && unaligned_io) | ||
| 557 | inode_dio_wait(inode); | ||
| 551 | out: | 558 | out: |
| 552 | xfs_iunlock(ip, iolock); | 559 | xfs_iunlock(ip, iolock); |
| 553 | 560 | ||
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h index 30b1ae53689f..c50542dc71e0 100644 --- a/include/acpi/acoutput.h +++ b/include/acpi/acoutput.h | |||
| @@ -150,7 +150,10 @@ | |||
| 150 | 150 | ||
| 151 | /* Defaults for debug_level, debug and normal */ | 151 | /* Defaults for debug_level, debug and normal */ |
| 152 | 152 | ||
| 153 | #ifndef ACPI_DEBUG_DEFAULT | ||
| 153 | #define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_EVALUATION | ACPI_LV_REPAIR) | 154 | #define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_EVALUATION | ACPI_LV_REPAIR) |
| 155 | #endif | ||
| 156 | |||
| 154 | #define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) | 157 | #define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) |
| 155 | #define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) | 158 | #define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) |
| 156 | 159 | ||
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index 9ff328fd946a..624b90b34085 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h | |||
| @@ -82,6 +82,11 @@ | |||
| 82 | #define ACPI_NO_ERROR_MESSAGES | 82 | #define ACPI_NO_ERROR_MESSAGES |
| 83 | #undef ACPI_DEBUG_OUTPUT | 83 | #undef ACPI_DEBUG_OUTPUT |
| 84 | 84 | ||
| 85 | /* Use a specific bugging default separate from ACPICA */ | ||
| 86 | |||
| 87 | #undef ACPI_DEBUG_DEFAULT | ||
| 88 | #define ACPI_DEBUG_DEFAULT (ACPI_LV_INFO | ACPI_LV_REPAIR) | ||
| 89 | |||
| 85 | /* External interface for __KERNEL__, stub is needed */ | 90 | /* External interface for __KERNEL__, stub is needed */ |
| 86 | 91 | ||
| 87 | #define ACPI_EXTERNAL_RETURN_STATUS(prototype) \ | 92 | #define ACPI_EXTERNAL_RETURN_STATUS(prototype) \ |
diff --git a/include/linux/atalk.h b/include/linux/atalk.h index d5cfc0b15b76..f6034ba774be 100644 --- a/include/linux/atalk.h +++ b/include/linux/atalk.h | |||
| @@ -108,7 +108,7 @@ static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb) | |||
| 108 | #define AARP_RESOLVE_TIME (10 * HZ) | 108 | #define AARP_RESOLVE_TIME (10 * HZ) |
| 109 | 109 | ||
| 110 | extern struct datalink_proto *ddp_dl, *aarp_dl; | 110 | extern struct datalink_proto *ddp_dl, *aarp_dl; |
| 111 | extern void aarp_proto_init(void); | 111 | extern int aarp_proto_init(void); |
| 112 | 112 | ||
| 113 | /* Inter module exports */ | 113 | /* Inter module exports */ |
| 114 | 114 | ||
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index a2132e09dc1c..f02367faa58d 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h | |||
| @@ -193,7 +193,6 @@ enum bpf_arg_type { | |||
| 193 | 193 | ||
| 194 | ARG_PTR_TO_CTX, /* pointer to context */ | 194 | ARG_PTR_TO_CTX, /* pointer to context */ |
| 195 | ARG_ANYTHING, /* any (initialized) argument is ok */ | 195 | ARG_ANYTHING, /* any (initialized) argument is ok */ |
| 196 | ARG_PTR_TO_SOCKET, /* pointer to bpf_sock */ | ||
| 197 | ARG_PTR_TO_SPIN_LOCK, /* pointer to bpf_spin_lock */ | 196 | ARG_PTR_TO_SPIN_LOCK, /* pointer to bpf_spin_lock */ |
| 198 | ARG_PTR_TO_SOCK_COMMON, /* pointer to sock_common */ | 197 | ARG_PTR_TO_SOCK_COMMON, /* pointer to sock_common */ |
| 199 | }; | 198 | }; |
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index 69f7a3449eda..7d8228d1c898 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h | |||
| @@ -66,6 +66,46 @@ struct bpf_reg_state { | |||
| 66 | * same reference to the socket, to determine proper reference freeing. | 66 | * same reference to the socket, to determine proper reference freeing. |
| 67 | */ | 67 | */ |
| 68 | u32 id; | 68 | u32 id; |
| 69 | /* PTR_TO_SOCKET and PTR_TO_TCP_SOCK could be a ptr returned | ||
| 70 | * from a pointer-cast helper, bpf_sk_fullsock() and | ||
| 71 | * bpf_tcp_sock(). | ||
| 72 | * | ||
| 73 | * Consider the following where "sk" is a reference counted | ||
| 74 | * pointer returned from "sk = bpf_sk_lookup_tcp();": | ||
| 75 | * | ||
| 76 | * 1: sk = bpf_sk_lookup_tcp(); | ||
| 77 | * 2: if (!sk) { return 0; } | ||
| 78 | * 3: fullsock = bpf_sk_fullsock(sk); | ||
| 79 | * 4: if (!fullsock) { bpf_sk_release(sk); return 0; } | ||
| 80 | * 5: tp = bpf_tcp_sock(fullsock); | ||
| 81 | * 6: if (!tp) { bpf_sk_release(sk); return 0; } | ||
| 82 | * 7: bpf_sk_release(sk); | ||
| 83 | * 8: snd_cwnd = tp->snd_cwnd; // verifier will complain | ||
| 84 | * | ||
| 85 | * After bpf_sk_release(sk) at line 7, both "fullsock" ptr and | ||
| 86 | * "tp" ptr should be invalidated also. In order to do that, | ||
| 87 | * the reg holding "fullsock" and "sk" need to remember | ||
| 88 | * the original refcounted ptr id (i.e. sk_reg->id) in ref_obj_id | ||
| 89 | * such that the verifier can reset all regs which have | ||
| 90 | * ref_obj_id matching the sk_reg->id. | ||
| 91 | * | ||
| 92 | * sk_reg->ref_obj_id is set to sk_reg->id at line 1. | ||
| 93 | * sk_reg->id will stay as NULL-marking purpose only. | ||
| 94 | * After NULL-marking is done, sk_reg->id can be reset to 0. | ||
| 95 | * | ||
| 96 | * After "fullsock = bpf_sk_fullsock(sk);" at line 3, | ||
| 97 | * fullsock_reg->ref_obj_id is set to sk_reg->ref_obj_id. | ||
| 98 | * | ||
| 99 | * After "tp = bpf_tcp_sock(fullsock);" at line 5, | ||
| 100 | * tp_reg->ref_obj_id is set to fullsock_reg->ref_obj_id | ||
| 101 | * which is the same as sk_reg->ref_obj_id. | ||
| 102 | * | ||
| 103 | * From the verifier perspective, if sk, fullsock and tp | ||
| 104 | * are not NULL, they are the same ptr with different | ||
| 105 | * reg->type. In particular, bpf_sk_release(tp) is also | ||
| 106 | * allowed and has the same effect as bpf_sk_release(sk). | ||
| 107 | */ | ||
| 108 | u32 ref_obj_id; | ||
| 69 | /* For scalar types (SCALAR_VALUE), this represents our knowledge of | 109 | /* For scalar types (SCALAR_VALUE), this represents our knowledge of |
| 70 | * the actual value. | 110 | * the actual value. |
| 71 | * For pointer types, this represents the variable part of the offset | 111 | * For pointer types, this represents the variable part of the offset |
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h index 9cd00a37b8d3..6db2d9a6e503 100644 --- a/include/linux/brcmphy.h +++ b/include/linux/brcmphy.h | |||
| @@ -148,6 +148,22 @@ | |||
| 148 | #define BCM_LED_SRC_OFF 0xe /* Tied high */ | 148 | #define BCM_LED_SRC_OFF 0xe /* Tied high */ |
| 149 | #define BCM_LED_SRC_ON 0xf /* Tied low */ | 149 | #define BCM_LED_SRC_ON 0xf /* Tied low */ |
| 150 | 150 | ||
| 151 | /* | ||
| 152 | * Broadcom Multicolor LED configurations (expansion register 4) | ||
| 153 | */ | ||
| 154 | #define BCM_EXP_MULTICOLOR (MII_BCM54XX_EXP_SEL_ER + 0x04) | ||
| 155 | #define BCM_LED_MULTICOLOR_IN_PHASE BIT(8) | ||
| 156 | #define BCM_LED_MULTICOLOR_LINK_ACT 0x0 | ||
| 157 | #define BCM_LED_MULTICOLOR_SPEED 0x1 | ||
| 158 | #define BCM_LED_MULTICOLOR_ACT_FLASH 0x2 | ||
| 159 | #define BCM_LED_MULTICOLOR_FDX 0x3 | ||
| 160 | #define BCM_LED_MULTICOLOR_OFF 0x4 | ||
| 161 | #define BCM_LED_MULTICOLOR_ON 0x5 | ||
| 162 | #define BCM_LED_MULTICOLOR_ALT 0x6 | ||
| 163 | #define BCM_LED_MULTICOLOR_FLASH 0x7 | ||
| 164 | #define BCM_LED_MULTICOLOR_LINK 0x8 | ||
| 165 | #define BCM_LED_MULTICOLOR_ACT 0x9 | ||
| 166 | #define BCM_LED_MULTICOLOR_PROGRAM 0xa | ||
| 151 | 167 | ||
| 152 | /* | 168 | /* |
| 153 | * BCM5482: Shadow registers | 169 | * BCM5482: Shadow registers |
diff --git a/include/linux/device.h b/include/linux/device.h index b425a7ee04ce..4e6987e11f68 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -49,8 +49,6 @@ struct bus_attribute { | |||
| 49 | ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count); | 49 | ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count); |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | #define BUS_ATTR(_name, _mode, _show, _store) \ | ||
| 53 | struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) | ||
| 54 | #define BUS_ATTR_RW(_name) \ | 52 | #define BUS_ATTR_RW(_name) \ |
| 55 | struct bus_attribute bus_attr_##_name = __ATTR_RW(_name) | 53 | struct bus_attribute bus_attr_##_name = __ATTR_RW(_name) |
| 56 | #define BUS_ATTR_RO(_name) \ | 54 | #define BUS_ATTR_RO(_name) \ |
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index ea35263eb76b..11943b60f208 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h | |||
| @@ -203,7 +203,6 @@ static inline void hugetlb_show_meminfo(void) | |||
| 203 | #define pud_huge(x) 0 | 203 | #define pud_huge(x) 0 |
| 204 | #define is_hugepage_only_range(mm, addr, len) 0 | 204 | #define is_hugepage_only_range(mm, addr, len) 0 |
| 205 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) | 205 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) |
| 206 | #define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; }) | ||
| 207 | #define hugetlb_mcopy_atomic_pte(dst_mm, dst_pte, dst_vma, dst_addr, \ | 206 | #define hugetlb_mcopy_atomic_pte(dst_mm, dst_pte, dst_vma, dst_addr, \ |
| 208 | src_addr, pagep) ({ BUG(); 0; }) | 207 | src_addr, pagep) ({ BUG(); 0; }) |
| 209 | #define huge_pte_offset(mm, address, sz) 0 | 208 | #define huge_pte_offset(mm, address, sz) 0 |
| @@ -234,6 +233,13 @@ static inline void __unmap_hugepage_range(struct mmu_gather *tlb, | |||
| 234 | { | 233 | { |
| 235 | BUG(); | 234 | BUG(); |
| 236 | } | 235 | } |
| 236 | static inline vm_fault_t hugetlb_fault(struct mm_struct *mm, | ||
| 237 | struct vm_area_struct *vma, unsigned long address, | ||
| 238 | unsigned int flags) | ||
| 239 | { | ||
| 240 | BUG(); | ||
| 241 | return 0; | ||
| 242 | } | ||
| 237 | 243 | ||
| 238 | #endif /* !CONFIG_HUGETLB_PAGE */ | 244 | #endif /* !CONFIG_HUGETLB_PAGE */ |
| 239 | /* | 245 | /* |
diff --git a/include/linux/kcore.h b/include/linux/kcore.h index c843f4a9c512..da676cdbd727 100644 --- a/include/linux/kcore.h +++ b/include/linux/kcore.h | |||
| @@ -38,12 +38,6 @@ struct vmcoredd_node { | |||
| 38 | 38 | ||
| 39 | #ifdef CONFIG_PROC_KCORE | 39 | #ifdef CONFIG_PROC_KCORE |
| 40 | void __init kclist_add(struct kcore_list *, void *, size_t, int type); | 40 | void __init kclist_add(struct kcore_list *, void *, size_t, int type); |
| 41 | static inline | ||
| 42 | void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz) | ||
| 43 | { | ||
| 44 | m->vaddr = (unsigned long)vaddr; | ||
| 45 | kclist_add(m, addr, sz, KCORE_REMAP); | ||
| 46 | } | ||
| 47 | 41 | ||
| 48 | extern int __init register_mem_pfn_is_ram(int (*fn)(unsigned long pfn)); | 42 | extern int __init register_mem_pfn_is_ram(int (*fn)(unsigned long pfn)); |
| 49 | #else | 43 | #else |
| @@ -51,11 +45,6 @@ static inline | |||
| 51 | void kclist_add(struct kcore_list *new, void *addr, size_t size, int type) | 45 | void kclist_add(struct kcore_list *new, void *addr, size_t size, int type) |
| 52 | { | 46 | { |
| 53 | } | 47 | } |
| 54 | |||
| 55 | static inline | ||
| 56 | void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz) | ||
| 57 | { | ||
| 58 | } | ||
| 59 | #endif | 48 | #endif |
| 60 | 49 | ||
| 61 | #endif /* _LINUX_KCORE_H */ | 50 | #endif /* _LINUX_KCORE_H */ |
diff --git a/include/linux/list.h b/include/linux/list.h index 79626b5ab36c..58aa3adf94e6 100644 --- a/include/linux/list.h +++ b/include/linux/list.h | |||
| @@ -207,7 +207,7 @@ static inline void list_bulk_move_tail(struct list_head *head, | |||
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | /** | 209 | /** |
| 210 | * list_is_first -- tests whether @ list is the first entry in list @head | 210 | * list_is_first -- tests whether @list is the first entry in list @head |
| 211 | * @list: the entry to test | 211 | * @list: the entry to test |
| 212 | * @head: the head of the list | 212 | * @head: the head of the list |
| 213 | */ | 213 | */ |
diff --git a/include/linux/net.h b/include/linux/net.h index 651fca72286c..c606c72311d0 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
| @@ -83,6 +83,12 @@ enum sock_type { | |||
| 83 | 83 | ||
| 84 | #endif /* ARCH_HAS_SOCKET_TYPES */ | 84 | #endif /* ARCH_HAS_SOCKET_TYPES */ |
| 85 | 85 | ||
| 86 | /** | ||
| 87 | * enum sock_shutdown_cmd - Shutdown types | ||
| 88 | * @SHUT_RD: shutdown receptions | ||
| 89 | * @SHUT_WR: shutdown transmissions | ||
| 90 | * @SHUT_RDWR: shutdown receptions/transmissions | ||
| 91 | */ | ||
| 86 | enum sock_shutdown_cmd { | 92 | enum sock_shutdown_cmd { |
| 87 | SHUT_RD, | 93 | SHUT_RD, |
| 88 | SHUT_WR, | 94 | SHUT_WR, |
diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h index 4eb26d278046..280ae96dc4c3 100644 --- a/include/linux/page-isolation.h +++ b/include/linux/page-isolation.h | |||
| @@ -41,16 +41,6 @@ int move_freepages_block(struct zone *zone, struct page *page, | |||
| 41 | 41 | ||
| 42 | /* | 42 | /* |
| 43 | * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE. | 43 | * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE. |
| 44 | * If specified range includes migrate types other than MOVABLE or CMA, | ||
| 45 | * this will fail with -EBUSY. | ||
| 46 | * | ||
| 47 | * For isolating all pages in the range finally, the caller have to | ||
| 48 | * free all pages in the range. test_page_isolated() can be used for | ||
| 49 | * test it. | ||
| 50 | * | ||
| 51 | * The following flags are allowed (they can be combined in a bit mask) | ||
| 52 | * SKIP_HWPOISON - ignore hwpoison pages | ||
| 53 | * REPORT_FAILURE - report details about the failure to isolate the range | ||
| 54 | */ | 44 | */ |
| 55 | int | 45 | int |
| 56 | start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, | 46 | start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, |
diff --git a/include/linux/parport.h b/include/linux/parport.h index f41f1d041e2c..397607a0c0eb 100644 --- a/include/linux/parport.h +++ b/include/linux/parport.h | |||
| @@ -460,7 +460,6 @@ extern size_t parport_ieee1284_epp_read_addr (struct parport *, | |||
| 460 | void *, size_t, int); | 460 | void *, size_t, int); |
| 461 | 461 | ||
| 462 | /* IEEE1284.3 functions */ | 462 | /* IEEE1284.3 functions */ |
| 463 | #define daisy_dev_name "Device ID probe" | ||
| 464 | extern int parport_daisy_init (struct parport *port); | 463 | extern int parport_daisy_init (struct parport *port); |
| 465 | extern void parport_daisy_fini (struct parport *port); | 464 | extern void parport_daisy_fini (struct parport *port); |
| 466 | extern struct pardevice *parport_open (int devnum, const char *name); | 465 | extern struct pardevice *parport_open (int devnum, const char *name); |
| @@ -469,18 +468,6 @@ extern ssize_t parport_device_id (int devnum, char *buffer, size_t len); | |||
| 469 | extern void parport_daisy_deselect_all (struct parport *port); | 468 | extern void parport_daisy_deselect_all (struct parport *port); |
| 470 | extern int parport_daisy_select (struct parport *port, int daisy, int mode); | 469 | extern int parport_daisy_select (struct parport *port, int daisy, int mode); |
| 471 | 470 | ||
| 472 | #ifdef CONFIG_PARPORT_1284 | ||
| 473 | extern int daisy_drv_init(void); | ||
| 474 | extern void daisy_drv_exit(void); | ||
| 475 | #else | ||
| 476 | static inline int daisy_drv_init(void) | ||
| 477 | { | ||
| 478 | return 0; | ||
| 479 | } | ||
| 480 | |||
| 481 | static inline void daisy_drv_exit(void) {} | ||
| 482 | #endif | ||
| 483 | |||
| 484 | /* Lowlevel drivers _can_ call this support function to handle irqs. */ | 471 | /* Lowlevel drivers _can_ call this support function to handle irqs. */ |
| 485 | static inline void parport_generic_irq(struct parport *port) | 472 | static inline void parport_generic_irq(struct parport *port) |
| 486 | { | 473 | { |
diff --git a/include/linux/platform_data/gpio/gpio-amd-fch.h b/include/linux/platform_data/gpio/gpio-amd-fch.h index a867637e172d..9e46678edb2a 100644 --- a/include/linux/platform_data/gpio/gpio-amd-fch.h +++ b/include/linux/platform_data/gpio/gpio-amd-fch.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL+ */ | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * AMD FCH gpio driver platform-data | 4 | * AMD FCH gpio driver platform-data |
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index ae5655197698..e412c092c1e8 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h | |||
| @@ -418,10 +418,20 @@ static inline void set_restore_sigmask(void) | |||
| 418 | set_thread_flag(TIF_RESTORE_SIGMASK); | 418 | set_thread_flag(TIF_RESTORE_SIGMASK); |
| 419 | WARN_ON(!test_thread_flag(TIF_SIGPENDING)); | 419 | WARN_ON(!test_thread_flag(TIF_SIGPENDING)); |
| 420 | } | 420 | } |
| 421 | |||
| 422 | static inline void clear_tsk_restore_sigmask(struct task_struct *tsk) | ||
| 423 | { | ||
| 424 | clear_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK); | ||
| 425 | } | ||
| 426 | |||
| 421 | static inline void clear_restore_sigmask(void) | 427 | static inline void clear_restore_sigmask(void) |
| 422 | { | 428 | { |
| 423 | clear_thread_flag(TIF_RESTORE_SIGMASK); | 429 | clear_thread_flag(TIF_RESTORE_SIGMASK); |
| 424 | } | 430 | } |
| 431 | static inline bool test_tsk_restore_sigmask(struct task_struct *tsk) | ||
| 432 | { | ||
| 433 | return test_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK); | ||
| 434 | } | ||
| 425 | static inline bool test_restore_sigmask(void) | 435 | static inline bool test_restore_sigmask(void) |
| 426 | { | 436 | { |
| 427 | return test_thread_flag(TIF_RESTORE_SIGMASK); | 437 | return test_thread_flag(TIF_RESTORE_SIGMASK); |
| @@ -439,6 +449,10 @@ static inline void set_restore_sigmask(void) | |||
| 439 | current->restore_sigmask = true; | 449 | current->restore_sigmask = true; |
| 440 | WARN_ON(!test_thread_flag(TIF_SIGPENDING)); | 450 | WARN_ON(!test_thread_flag(TIF_SIGPENDING)); |
| 441 | } | 451 | } |
| 452 | static inline void clear_tsk_restore_sigmask(struct task_struct *tsk) | ||
| 453 | { | ||
| 454 | tsk->restore_sigmask = false; | ||
| 455 | } | ||
| 442 | static inline void clear_restore_sigmask(void) | 456 | static inline void clear_restore_sigmask(void) |
| 443 | { | 457 | { |
| 444 | current->restore_sigmask = false; | 458 | current->restore_sigmask = false; |
| @@ -447,6 +461,10 @@ static inline bool test_restore_sigmask(void) | |||
| 447 | { | 461 | { |
| 448 | return current->restore_sigmask; | 462 | return current->restore_sigmask; |
| 449 | } | 463 | } |
| 464 | static inline bool test_tsk_restore_sigmask(struct task_struct *tsk) | ||
| 465 | { | ||
| 466 | return tsk->restore_sigmask; | ||
| 467 | } | ||
| 450 | static inline bool test_and_clear_restore_sigmask(void) | 468 | static inline bool test_and_clear_restore_sigmask(void) |
| 451 | { | 469 | { |
| 452 | if (!current->restore_sigmask) | 470 | if (!current->restore_sigmask) |
diff --git a/include/linux/slab.h b/include/linux/slab.h index 11b45f7ae405..9449b19c5f10 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
| @@ -32,6 +32,8 @@ | |||
| 32 | #define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U) | 32 | #define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U) |
| 33 | /* Use GFP_DMA memory */ | 33 | /* Use GFP_DMA memory */ |
| 34 | #define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U) | 34 | #define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U) |
| 35 | /* Use GFP_DMA32 memory */ | ||
| 36 | #define SLAB_CACHE_DMA32 ((slab_flags_t __force)0x00008000U) | ||
| 35 | /* DEBUG: Store the last owner for bug hunting */ | 37 | /* DEBUG: Store the last owner for bug hunting */ |
| 36 | #define SLAB_STORE_USER ((slab_flags_t __force)0x00010000U) | 38 | #define SLAB_STORE_USER ((slab_flags_t __force)0x00010000U) |
| 37 | /* Panic if kmem_cache_create() fails */ | 39 | /* Panic if kmem_cache_create() fails */ |
diff --git a/include/linux/socket.h b/include/linux/socket.h index 6016daeecee4..b57cd8bf96e2 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h | |||
| @@ -26,7 +26,7 @@ typedef __kernel_sa_family_t sa_family_t; | |||
| 26 | /* | 26 | /* |
| 27 | * 1003.1g requires sa_family_t and that sa_data is char. | 27 | * 1003.1g requires sa_family_t and that sa_data is char. |
| 28 | */ | 28 | */ |
| 29 | 29 | ||
| 30 | struct sockaddr { | 30 | struct sockaddr { |
| 31 | sa_family_t sa_family; /* address family, AF_xxx */ | 31 | sa_family_t sa_family; /* address family, AF_xxx */ |
| 32 | char sa_data[14]; /* 14 bytes of protocol address */ | 32 | char sa_data[14]; /* 14 bytes of protocol address */ |
| @@ -44,7 +44,7 @@ struct linger { | |||
| 44 | * system, not 4.3. Thus msg_accrights(len) are now missing. They | 44 | * system, not 4.3. Thus msg_accrights(len) are now missing. They |
| 45 | * belong in an obscure libc emulation or the bin. | 45 | * belong in an obscure libc emulation or the bin. |
| 46 | */ | 46 | */ |
| 47 | 47 | ||
| 48 | struct msghdr { | 48 | struct msghdr { |
| 49 | void *msg_name; /* ptr to socket address structure */ | 49 | void *msg_name; /* ptr to socket address structure */ |
| 50 | int msg_namelen; /* size of socket address structure */ | 50 | int msg_namelen; /* size of socket address structure */ |
| @@ -54,7 +54,7 @@ struct msghdr { | |||
| 54 | unsigned int msg_flags; /* flags on received message */ | 54 | unsigned int msg_flags; /* flags on received message */ |
| 55 | struct kiocb *msg_iocb; /* ptr to iocb for async requests */ | 55 | struct kiocb *msg_iocb; /* ptr to iocb for async requests */ |
| 56 | }; | 56 | }; |
| 57 | 57 | ||
| 58 | struct user_msghdr { | 58 | struct user_msghdr { |
| 59 | void __user *msg_name; /* ptr to socket address structure */ | 59 | void __user *msg_name; /* ptr to socket address structure */ |
| 60 | int msg_namelen; /* size of socket address structure */ | 60 | int msg_namelen; /* size of socket address structure */ |
| @@ -122,7 +122,7 @@ struct cmsghdr { | |||
| 122 | * inside range, given by msg->msg_controllen before using | 122 | * inside range, given by msg->msg_controllen before using |
| 123 | * ancillary object DATA. --ANK (980731) | 123 | * ancillary object DATA. --ANK (980731) |
| 124 | */ | 124 | */ |
| 125 | 125 | ||
| 126 | static inline struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size, | 126 | static inline struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size, |
| 127 | struct cmsghdr *__cmsg) | 127 | struct cmsghdr *__cmsg) |
| 128 | { | 128 | { |
| @@ -264,10 +264,10 @@ struct ucred { | |||
| 264 | /* Maximum queue length specifiable by listen. */ | 264 | /* Maximum queue length specifiable by listen. */ |
| 265 | #define SOMAXCONN 128 | 265 | #define SOMAXCONN 128 |
| 266 | 266 | ||
| 267 | /* Flags we can use with send/ and recv. | 267 | /* Flags we can use with send/ and recv. |
| 268 | Added those for 1003.1g not all are supported yet | 268 | Added those for 1003.1g not all are supported yet |
| 269 | */ | 269 | */ |
| 270 | 270 | ||
| 271 | #define MSG_OOB 1 | 271 | #define MSG_OOB 1 |
| 272 | #define MSG_PEEK 2 | 272 | #define MSG_PEEK 2 |
| 273 | #define MSG_DONTROUTE 4 | 273 | #define MSG_DONTROUTE 4 |
diff --git a/include/linux/vbox_utils.h b/include/linux/vbox_utils.h index a240ed2a0372..ff56c443180c 100644 --- a/include/linux/vbox_utils.h +++ b/include/linux/vbox_utils.h | |||
| @@ -24,15 +24,17 @@ __printf(1, 2) void vbg_debug(const char *fmt, ...); | |||
| 24 | #define vbg_debug pr_debug | 24 | #define vbg_debug pr_debug |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | int vbg_hgcm_connect(struct vbg_dev *gdev, | 27 | int vbg_hgcm_connect(struct vbg_dev *gdev, u32 requestor, |
| 28 | struct vmmdev_hgcm_service_location *loc, | 28 | struct vmmdev_hgcm_service_location *loc, |
| 29 | u32 *client_id, int *vbox_status); | 29 | u32 *client_id, int *vbox_status); |
| 30 | 30 | ||
| 31 | int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 client_id, int *vbox_status); | 31 | int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 requestor, |
| 32 | u32 client_id, int *vbox_status); | ||
| 32 | 33 | ||
| 33 | int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 function, | 34 | int vbg_hgcm_call(struct vbg_dev *gdev, u32 requestor, u32 client_id, |
| 34 | u32 timeout_ms, struct vmmdev_hgcm_function_parameter *parms, | 35 | u32 function, u32 timeout_ms, |
| 35 | u32 parm_count, int *vbox_status); | 36 | struct vmmdev_hgcm_function_parameter *parms, u32 parm_count, |
| 37 | int *vbox_status); | ||
| 36 | 38 | ||
| 37 | /** | 39 | /** |
| 38 | * Convert a VirtualBox status code to a standard Linux kernel return value. | 40 | * Convert a VirtualBox status code to a standard Linux kernel return value. |
diff --git a/include/net/act_api.h b/include/net/act_api.h index c745e9ccfab2..c61a1bf4e3de 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h | |||
| @@ -39,7 +39,7 @@ struct tc_action { | |||
| 39 | struct gnet_stats_basic_cpu __percpu *cpu_bstats_hw; | 39 | struct gnet_stats_basic_cpu __percpu *cpu_bstats_hw; |
| 40 | struct gnet_stats_queue __percpu *cpu_qstats; | 40 | struct gnet_stats_queue __percpu *cpu_qstats; |
| 41 | struct tc_cookie __rcu *act_cookie; | 41 | struct tc_cookie __rcu *act_cookie; |
| 42 | struct tcf_chain *goto_chain; | 42 | struct tcf_chain __rcu *goto_chain; |
| 43 | }; | 43 | }; |
| 44 | #define tcf_index common.tcfa_index | 44 | #define tcf_index common.tcfa_index |
| 45 | #define tcf_refcnt common.tcfa_refcnt | 45 | #define tcf_refcnt common.tcfa_refcnt |
| @@ -90,7 +90,7 @@ struct tc_action_ops { | |||
| 90 | int (*lookup)(struct net *net, struct tc_action **a, u32 index); | 90 | int (*lookup)(struct net *net, struct tc_action **a, u32 index); |
| 91 | int (*init)(struct net *net, struct nlattr *nla, | 91 | int (*init)(struct net *net, struct nlattr *nla, |
| 92 | struct nlattr *est, struct tc_action **act, int ovr, | 92 | struct nlattr *est, struct tc_action **act, int ovr, |
| 93 | int bind, bool rtnl_held, | 93 | int bind, bool rtnl_held, struct tcf_proto *tp, |
| 94 | struct netlink_ext_ack *extack); | 94 | struct netlink_ext_ack *extack); |
| 95 | int (*walk)(struct net *, struct sk_buff *, | 95 | int (*walk)(struct net *, struct sk_buff *, |
| 96 | struct netlink_callback *, int, | 96 | struct netlink_callback *, int, |
| @@ -181,6 +181,11 @@ int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); | |||
| 181 | int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); | 181 | int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); |
| 182 | int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); | 182 | int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); |
| 183 | 183 | ||
| 184 | int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, | ||
| 185 | struct tcf_chain **handle, | ||
| 186 | struct netlink_ext_ack *newchain); | ||
| 187 | struct tcf_chain *tcf_action_set_ctrlact(struct tc_action *a, int action, | ||
| 188 | struct tcf_chain *newchain); | ||
| 184 | #endif /* CONFIG_NET_CLS_ACT */ | 189 | #endif /* CONFIG_NET_CLS_ACT */ |
| 185 | 190 | ||
| 186 | static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes, | 191 | static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes, |
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 31284c078d06..7d1a0483a17b 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
| @@ -378,6 +378,7 @@ struct tcf_chain { | |||
| 378 | bool flushing; | 378 | bool flushing; |
| 379 | const struct tcf_proto_ops *tmplt_ops; | 379 | const struct tcf_proto_ops *tmplt_ops; |
| 380 | void *tmplt_priv; | 380 | void *tmplt_priv; |
| 381 | struct rcu_head rcu; | ||
| 381 | }; | 382 | }; |
| 382 | 383 | ||
| 383 | struct tcf_block { | 384 | struct tcf_block { |
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h index 32ee65a30aff..1c6e6c0766ca 100644 --- a/include/net/sctp/checksum.h +++ b/include/net/sctp/checksum.h | |||
| @@ -61,7 +61,7 @@ static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2, | |||
| 61 | static inline __le32 sctp_compute_cksum(const struct sk_buff *skb, | 61 | static inline __le32 sctp_compute_cksum(const struct sk_buff *skb, |
| 62 | unsigned int offset) | 62 | unsigned int offset) |
| 63 | { | 63 | { |
| 64 | struct sctphdr *sh = sctp_hdr(skb); | 64 | struct sctphdr *sh = (struct sctphdr *)(skb->data + offset); |
| 65 | const struct skb_checksum_ops ops = { | 65 | const struct skb_checksum_ops ops = { |
| 66 | .update = sctp_csum_update, | 66 | .update = sctp_csum_update, |
| 67 | .combine = sctp_csum_combine, | 67 | .combine = sctp_csum_combine, |
diff --git a/include/net/sock.h b/include/net/sock.h index 328cb7cb7b0b..8de5ee258b93 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
| @@ -710,6 +710,12 @@ static inline void sk_add_node_rcu(struct sock *sk, struct hlist_head *list) | |||
| 710 | hlist_add_head_rcu(&sk->sk_node, list); | 710 | hlist_add_head_rcu(&sk->sk_node, list); |
| 711 | } | 711 | } |
| 712 | 712 | ||
| 713 | static inline void sk_add_node_tail_rcu(struct sock *sk, struct hlist_head *list) | ||
| 714 | { | ||
| 715 | sock_hold(sk); | ||
| 716 | hlist_add_tail_rcu(&sk->sk_node, list); | ||
| 717 | } | ||
| 718 | |||
| 713 | static inline void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list) | 719 | static inline void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list) |
| 714 | { | 720 | { |
| 715 | hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list); | 721 | hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list); |
diff --git a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h index ee8d005f56fc..eb8f01c819e6 100644 --- a/include/net/tc_act/tc_gact.h +++ b/include/net/tc_act/tc_gact.h | |||
| @@ -56,7 +56,7 @@ static inline bool is_tcf_gact_goto_chain(const struct tc_action *a) | |||
| 56 | 56 | ||
| 57 | static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a) | 57 | static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a) |
| 58 | { | 58 | { |
| 59 | return a->goto_chain->index; | 59 | return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | #endif /* __NET_TC_GACT_H */ | 62 | #endif /* __NET_TC_GACT_H */ |
diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h index 61cf7dbb6782..d074b6d60f8a 100644 --- a/include/net/xdp_sock.h +++ b/include/net/xdp_sock.h | |||
| @@ -36,7 +36,6 @@ struct xdp_umem { | |||
| 36 | u32 headroom; | 36 | u32 headroom; |
| 37 | u32 chunk_size_nohr; | 37 | u32 chunk_size_nohr; |
| 38 | struct user_struct *user; | 38 | struct user_struct *user; |
| 39 | struct pid *pid; | ||
| 40 | unsigned long address; | 39 | unsigned long address; |
| 41 | refcount_t users; | 40 | refcount_t users; |
| 42 | struct work_struct work; | 41 | struct work_struct work; |
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 3c38ac9a92a7..929c8e537a14 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h | |||
| @@ -502,16 +502,6 @@ union bpf_attr { | |||
| 502 | * Return | 502 | * Return |
| 503 | * 0 on success, or a negative error in case of failure. | 503 | * 0 on success, or a negative error in case of failure. |
| 504 | * | 504 | * |
| 505 | * int bpf_map_push_elem(struct bpf_map *map, const void *value, u64 flags) | ||
| 506 | * Description | ||
| 507 | * Push an element *value* in *map*. *flags* is one of: | ||
| 508 | * | ||
| 509 | * **BPF_EXIST** | ||
| 510 | * If the queue/stack is full, the oldest element is removed to | ||
| 511 | * make room for this. | ||
| 512 | * Return | ||
| 513 | * 0 on success, or a negative error in case of failure. | ||
| 514 | * | ||
| 515 | * int bpf_probe_read(void *dst, u32 size, const void *src) | 505 | * int bpf_probe_read(void *dst, u32 size, const void *src) |
| 516 | * Description | 506 | * Description |
| 517 | * For tracing programs, safely attempt to read *size* bytes from | 507 | * For tracing programs, safely attempt to read *size* bytes from |
| @@ -1435,14 +1425,14 @@ union bpf_attr { | |||
| 1435 | * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) | 1425 | * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) |
| 1436 | * Description | 1426 | * Description |
| 1437 | * Equivalent to bpf_get_socket_cookie() helper that accepts | 1427 | * Equivalent to bpf_get_socket_cookie() helper that accepts |
| 1438 | * *skb*, but gets socket from **struct bpf_sock_addr** contex. | 1428 | * *skb*, but gets socket from **struct bpf_sock_addr** context. |
| 1439 | * Return | 1429 | * Return |
| 1440 | * A 8-byte long non-decreasing number. | 1430 | * A 8-byte long non-decreasing number. |
| 1441 | * | 1431 | * |
| 1442 | * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) | 1432 | * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) |
| 1443 | * Description | 1433 | * Description |
| 1444 | * Equivalent to bpf_get_socket_cookie() helper that accepts | 1434 | * Equivalent to bpf_get_socket_cookie() helper that accepts |
| 1445 | * *skb*, but gets socket from **struct bpf_sock_ops** contex. | 1435 | * *skb*, but gets socket from **struct bpf_sock_ops** context. |
| 1446 | * Return | 1436 | * Return |
| 1447 | * A 8-byte long non-decreasing number. | 1437 | * A 8-byte long non-decreasing number. |
| 1448 | * | 1438 | * |
| @@ -2098,52 +2088,52 @@ union bpf_attr { | |||
| 2098 | * Return | 2088 | * Return |
| 2099 | * 0 on success, or a negative error in case of failure. | 2089 | * 0 on success, or a negative error in case of failure. |
| 2100 | * | 2090 | * |
| 2101 | * int bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle) | 2091 | * int bpf_rc_repeat(void *ctx) |
| 2102 | * Description | 2092 | * Description |
| 2103 | * This helper is used in programs implementing IR decoding, to | 2093 | * This helper is used in programs implementing IR decoding, to |
| 2104 | * report a successfully decoded key press with *scancode*, | 2094 | * report a successfully decoded repeat key message. This delays |
| 2105 | * *toggle* value in the given *protocol*. The scancode will be | 2095 | * the generation of a key up event for previously generated |
| 2106 | * translated to a keycode using the rc keymap, and reported as | 2096 | * key down event. |
| 2107 | * an input key down event. After a period a key up event is | ||
| 2108 | * generated. This period can be extended by calling either | ||
| 2109 | * **bpf_rc_keydown**\ () again with the same values, or calling | ||
| 2110 | * **bpf_rc_repeat**\ (). | ||
| 2111 | * | 2097 | * |
| 2112 | * Some protocols include a toggle bit, in case the button was | 2098 | * Some IR protocols like NEC have a special IR message for |
| 2113 | * released and pressed again between consecutive scancodes. | 2099 | * repeating last button, for when a button is held down. |
| 2114 | * | 2100 | * |
| 2115 | * The *ctx* should point to the lirc sample as passed into | 2101 | * The *ctx* should point to the lirc sample as passed into |
| 2116 | * the program. | 2102 | * the program. |
| 2117 | * | 2103 | * |
| 2118 | * The *protocol* is the decoded protocol number (see | ||
| 2119 | * **enum rc_proto** for some predefined values). | ||
| 2120 | * | ||
| 2121 | * This helper is only available is the kernel was compiled with | 2104 | * This helper is only available is the kernel was compiled with |
| 2122 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to | 2105 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to |
| 2123 | * "**y**". | 2106 | * "**y**". |
| 2124 | * Return | 2107 | * Return |
| 2125 | * 0 | 2108 | * 0 |
| 2126 | * | 2109 | * |
| 2127 | * int bpf_rc_repeat(void *ctx) | 2110 | * int bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle) |
| 2128 | * Description | 2111 | * Description |
| 2129 | * This helper is used in programs implementing IR decoding, to | 2112 | * This helper is used in programs implementing IR decoding, to |
| 2130 | * report a successfully decoded repeat key message. This delays | 2113 | * report a successfully decoded key press with *scancode*, |
| 2131 | * the generation of a key up event for previously generated | 2114 | * *toggle* value in the given *protocol*. The scancode will be |
| 2132 | * key down event. | 2115 | * translated to a keycode using the rc keymap, and reported as |
| 2116 | * an input key down event. After a period a key up event is | ||
| 2117 | * generated. This period can be extended by calling either | ||
| 2118 | * **bpf_rc_keydown**\ () again with the same values, or calling | ||
| 2119 | * **bpf_rc_repeat**\ (). | ||
| 2133 | * | 2120 | * |
| 2134 | * Some IR protocols like NEC have a special IR message for | 2121 | * Some protocols include a toggle bit, in case the button was |
| 2135 | * repeating last button, for when a button is held down. | 2122 | * released and pressed again between consecutive scancodes. |
| 2136 | * | 2123 | * |
| 2137 | * The *ctx* should point to the lirc sample as passed into | 2124 | * The *ctx* should point to the lirc sample as passed into |
| 2138 | * the program. | 2125 | * the program. |
| 2139 | * | 2126 | * |
| 2127 | * The *protocol* is the decoded protocol number (see | ||
| 2128 | * **enum rc_proto** for some predefined values). | ||
| 2129 | * | ||
| 2140 | * This helper is only available is the kernel was compiled with | 2130 | * This helper is only available is the kernel was compiled with |
| 2141 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to | 2131 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to |
| 2142 | * "**y**". | 2132 | * "**y**". |
| 2143 | * Return | 2133 | * Return |
| 2144 | * 0 | 2134 | * 0 |
| 2145 | * | 2135 | * |
| 2146 | * uint64_t bpf_skb_cgroup_id(struct sk_buff *skb) | 2136 | * u64 bpf_skb_cgroup_id(struct sk_buff *skb) |
| 2147 | * Description | 2137 | * Description |
| 2148 | * Return the cgroup v2 id of the socket associated with the *skb*. | 2138 | * Return the cgroup v2 id of the socket associated with the *skb*. |
| 2149 | * This is roughly similar to the **bpf_get_cgroup_classid**\ () | 2139 | * This is roughly similar to the **bpf_get_cgroup_classid**\ () |
| @@ -2159,30 +2149,12 @@ union bpf_attr { | |||
| 2159 | * Return | 2149 | * Return |
| 2160 | * The id is returned or 0 in case the id could not be retrieved. | 2150 | * The id is returned or 0 in case the id could not be retrieved. |
| 2161 | * | 2151 | * |
| 2162 | * u64 bpf_skb_ancestor_cgroup_id(struct sk_buff *skb, int ancestor_level) | ||
| 2163 | * Description | ||
| 2164 | * Return id of cgroup v2 that is ancestor of cgroup associated | ||
| 2165 | * with the *skb* at the *ancestor_level*. The root cgroup is at | ||
| 2166 | * *ancestor_level* zero and each step down the hierarchy | ||
| 2167 | * increments the level. If *ancestor_level* == level of cgroup | ||
| 2168 | * associated with *skb*, then return value will be same as that | ||
| 2169 | * of **bpf_skb_cgroup_id**\ (). | ||
| 2170 | * | ||
| 2171 | * The helper is useful to implement policies based on cgroups | ||
| 2172 | * that are upper in hierarchy than immediate cgroup associated | ||
| 2173 | * with *skb*. | ||
| 2174 | * | ||
| 2175 | * The format of returned id and helper limitations are same as in | ||
| 2176 | * **bpf_skb_cgroup_id**\ (). | ||
| 2177 | * Return | ||
| 2178 | * The id is returned or 0 in case the id could not be retrieved. | ||
| 2179 | * | ||
| 2180 | * u64 bpf_get_current_cgroup_id(void) | 2152 | * u64 bpf_get_current_cgroup_id(void) |
| 2181 | * Return | 2153 | * Return |
| 2182 | * A 64-bit integer containing the current cgroup id based | 2154 | * A 64-bit integer containing the current cgroup id based |
| 2183 | * on the cgroup within which the current task is running. | 2155 | * on the cgroup within which the current task is running. |
| 2184 | * | 2156 | * |
| 2185 | * void* get_local_storage(void *map, u64 flags) | 2157 | * void *bpf_get_local_storage(void *map, u64 flags) |
| 2186 | * Description | 2158 | * Description |
| 2187 | * Get the pointer to the local storage area. | 2159 | * Get the pointer to the local storage area. |
| 2188 | * The type and the size of the local storage is defined | 2160 | * The type and the size of the local storage is defined |
| @@ -2209,6 +2181,24 @@ union bpf_attr { | |||
| 2209 | * Return | 2181 | * Return |
| 2210 | * 0 on success, or a negative error in case of failure. | 2182 | * 0 on success, or a negative error in case of failure. |
| 2211 | * | 2183 | * |
| 2184 | * u64 bpf_skb_ancestor_cgroup_id(struct sk_buff *skb, int ancestor_level) | ||
| 2185 | * Description | ||
| 2186 | * Return id of cgroup v2 that is ancestor of cgroup associated | ||
| 2187 | * with the *skb* at the *ancestor_level*. The root cgroup is at | ||
| 2188 | * *ancestor_level* zero and each step down the hierarchy | ||
| 2189 | * increments the level. If *ancestor_level* == level of cgroup | ||
| 2190 | * associated with *skb*, then return value will be same as that | ||
| 2191 | * of **bpf_skb_cgroup_id**\ (). | ||
| 2192 | * | ||
| 2193 | * The helper is useful to implement policies based on cgroups | ||
| 2194 | * that are upper in hierarchy than immediate cgroup associated | ||
| 2195 | * with *skb*. | ||
| 2196 | * | ||
| 2197 | * The format of returned id and helper limitations are same as in | ||
| 2198 | * **bpf_skb_cgroup_id**\ (). | ||
| 2199 | * Return | ||
| 2200 | * The id is returned or 0 in case the id could not be retrieved. | ||
| 2201 | * | ||
| 2212 | * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) | 2202 | * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) |
| 2213 | * Description | 2203 | * Description |
| 2214 | * Look for TCP socket matching *tuple*, optionally in a child | 2204 | * Look for TCP socket matching *tuple*, optionally in a child |
| @@ -2289,6 +2279,16 @@ union bpf_attr { | |||
| 2289 | * Return | 2279 | * Return |
| 2290 | * 0 on success, or a negative error in case of failure. | 2280 | * 0 on success, or a negative error in case of failure. |
| 2291 | * | 2281 | * |
| 2282 | * int bpf_map_push_elem(struct bpf_map *map, const void *value, u64 flags) | ||
| 2283 | * Description | ||
| 2284 | * Push an element *value* in *map*. *flags* is one of: | ||
| 2285 | * | ||
| 2286 | * **BPF_EXIST** | ||
| 2287 | * If the queue/stack is full, the oldest element is | ||
| 2288 | * removed to make room for this. | ||
| 2289 | * Return | ||
| 2290 | * 0 on success, or a negative error in case of failure. | ||
| 2291 | * | ||
| 2292 | * int bpf_map_pop_elem(struct bpf_map *map, void *value) | 2292 | * int bpf_map_pop_elem(struct bpf_map *map, void *value) |
| 2293 | * Description | 2293 | * Description |
| 2294 | * Pop an element from *map*. | 2294 | * Pop an element from *map*. |
| @@ -2343,29 +2343,94 @@ union bpf_attr { | |||
| 2343 | * Return | 2343 | * Return |
| 2344 | * 0 | 2344 | * 0 |
| 2345 | * | 2345 | * |
| 2346 | * int bpf_spin_lock(struct bpf_spin_lock *lock) | ||
| 2347 | * Description | ||
| 2348 | * Acquire a spinlock represented by the pointer *lock*, which is | ||
| 2349 | * stored as part of a value of a map. Taking the lock allows to | ||
| 2350 | * safely update the rest of the fields in that value. The | ||
| 2351 | * spinlock can (and must) later be released with a call to | ||
| 2352 | * **bpf_spin_unlock**\ (\ *lock*\ ). | ||
| 2353 | * | ||
| 2354 | * Spinlocks in BPF programs come with a number of restrictions | ||
| 2355 | * and constraints: | ||
| 2356 | * | ||
| 2357 | * * **bpf_spin_lock** objects are only allowed inside maps of | ||
| 2358 | * types **BPF_MAP_TYPE_HASH** and **BPF_MAP_TYPE_ARRAY** (this | ||
| 2359 | * list could be extended in the future). | ||
| 2360 | * * BTF description of the map is mandatory. | ||
| 2361 | * * The BPF program can take ONE lock at a time, since taking two | ||
| 2362 | * or more could cause dead locks. | ||
| 2363 | * * Only one **struct bpf_spin_lock** is allowed per map element. | ||
| 2364 | * * When the lock is taken, calls (either BPF to BPF or helpers) | ||
| 2365 | * are not allowed. | ||
| 2366 | * * The **BPF_LD_ABS** and **BPF_LD_IND** instructions are not | ||
| 2367 | * allowed inside a spinlock-ed region. | ||
| 2368 | * * The BPF program MUST call **bpf_spin_unlock**\ () to release | ||
| 2369 | * the lock, on all execution paths, before it returns. | ||
| 2370 | * * The BPF program can access **struct bpf_spin_lock** only via | ||
| 2371 | * the **bpf_spin_lock**\ () and **bpf_spin_unlock**\ () | ||
| 2372 | * helpers. Loading or storing data into the **struct | ||
| 2373 | * bpf_spin_lock** *lock*\ **;** field of a map is not allowed. | ||
| 2374 | * * To use the **bpf_spin_lock**\ () helper, the BTF description | ||
| 2375 | * of the map value must be a struct and have **struct | ||
| 2376 | * bpf_spin_lock** *anyname*\ **;** field at the top level. | ||
| 2377 | * Nested lock inside another struct is not allowed. | ||
| 2378 | * * The **struct bpf_spin_lock** *lock* field in a map value must | ||
| 2379 | * be aligned on a multiple of 4 bytes in that value. | ||
| 2380 | * * Syscall with command **BPF_MAP_LOOKUP_ELEM** does not copy | ||
| 2381 | * the **bpf_spin_lock** field to user space. | ||
| 2382 | * * Syscall with command **BPF_MAP_UPDATE_ELEM**, or update from | ||
| 2383 | * a BPF program, do not update the **bpf_spin_lock** field. | ||
| 2384 | * * **bpf_spin_lock** cannot be on the stack or inside a | ||
| 2385 | * networking packet (it can only be inside of a map values). | ||
| 2386 | * * **bpf_spin_lock** is available to root only. | ||
| 2387 | * * Tracing programs and socket filter programs cannot use | ||
| 2388 | * **bpf_spin_lock**\ () due to insufficient preemption checks | ||
| 2389 | * (but this may change in the future). | ||
| 2390 | * * **bpf_spin_lock** is not allowed in inner maps of map-in-map. | ||
| 2391 | * Return | ||
| 2392 | * 0 | ||
| 2393 | * | ||
| 2394 | * int bpf_spin_unlock(struct bpf_spin_lock *lock) | ||
| 2395 | * Description | ||
| 2396 | * Release the *lock* previously locked by a call to | ||
| 2397 | * **bpf_spin_lock**\ (\ *lock*\ ). | ||
| 2398 | * Return | ||
| 2399 | * 0 | ||
| 2400 | * | ||
| 2346 | * struct bpf_sock *bpf_sk_fullsock(struct bpf_sock *sk) | 2401 | * struct bpf_sock *bpf_sk_fullsock(struct bpf_sock *sk) |
| 2347 | * Description | 2402 | * Description |
| 2348 | * This helper gets a **struct bpf_sock** pointer such | 2403 | * This helper gets a **struct bpf_sock** pointer such |
| 2349 | * that all the fields in bpf_sock can be accessed. | 2404 | * that all the fields in this **bpf_sock** can be accessed. |
| 2350 | * Return | 2405 | * Return |
| 2351 | * A **struct bpf_sock** pointer on success, or NULL in | 2406 | * A **struct bpf_sock** pointer on success, or **NULL** in |
| 2352 | * case of failure. | 2407 | * case of failure. |
| 2353 | * | 2408 | * |
| 2354 | * struct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *sk) | 2409 | * struct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *sk) |
| 2355 | * Description | 2410 | * Description |
| 2356 | * This helper gets a **struct bpf_tcp_sock** pointer from a | 2411 | * This helper gets a **struct bpf_tcp_sock** pointer from a |
| 2357 | * **struct bpf_sock** pointer. | 2412 | * **struct bpf_sock** pointer. |
| 2358 | * | ||
| 2359 | * Return | 2413 | * Return |
| 2360 | * A **struct bpf_tcp_sock** pointer on success, or NULL in | 2414 | * A **struct bpf_tcp_sock** pointer on success, or **NULL** in |
| 2361 | * case of failure. | 2415 | * case of failure. |
| 2362 | * | 2416 | * |
| 2363 | * int bpf_skb_ecn_set_ce(struct sk_buf *skb) | 2417 | * int bpf_skb_ecn_set_ce(struct sk_buf *skb) |
| 2364 | * Description | 2418 | * Description |
| 2365 | * Sets ECN of IP header to ce (congestion encountered) if | 2419 | * Set ECN (Explicit Congestion Notification) field of IP header |
| 2366 | * current value is ect (ECN capable). Works with IPv6 and IPv4. | 2420 | * to **CE** (Congestion Encountered) if current value is **ECT** |
| 2367 | * Return | 2421 | * (ECN Capable Transport). Otherwise, do nothing. Works with IPv6 |
| 2368 | * 1 if set, 0 if not set. | 2422 | * and IPv4. |
| 2423 | * Return | ||
| 2424 | * 1 if the **CE** flag is set (either by the current helper call | ||
| 2425 | * or because it was already present), 0 if it is not set. | ||
| 2426 | * | ||
| 2427 | * struct bpf_sock *bpf_get_listener_sock(struct bpf_sock *sk) | ||
| 2428 | * Description | ||
| 2429 | * Return a **struct bpf_sock** pointer in **TCP_LISTEN** state. | ||
| 2430 | * **bpf_sk_release**\ () is unnecessary and not allowed. | ||
| 2431 | * Return | ||
| 2432 | * A **struct bpf_sock** pointer on success, or **NULL** in | ||
| 2433 | * case of failure. | ||
| 2369 | */ | 2434 | */ |
| 2370 | #define __BPF_FUNC_MAPPER(FN) \ | 2435 | #define __BPF_FUNC_MAPPER(FN) \ |
| 2371 | FN(unspec), \ | 2436 | FN(unspec), \ |
| @@ -2465,7 +2530,8 @@ union bpf_attr { | |||
| 2465 | FN(spin_unlock), \ | 2530 | FN(spin_unlock), \ |
| 2466 | FN(sk_fullsock), \ | 2531 | FN(sk_fullsock), \ |
| 2467 | FN(tcp_sock), \ | 2532 | FN(tcp_sock), \ |
| 2468 | FN(skb_ecn_set_ce), | 2533 | FN(skb_ecn_set_ce), \ |
| 2534 | FN(get_listener_sock), | ||
| 2469 | 2535 | ||
| 2470 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 2536 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 2471 | * function eBPF program intends to call | 2537 | * function eBPF program intends to call |
diff --git a/include/uapi/linux/vbox_vmmdev_types.h b/include/uapi/linux/vbox_vmmdev_types.h index 0e68024f36c7..26f39816af14 100644 --- a/include/uapi/linux/vbox_vmmdev_types.h +++ b/include/uapi/linux/vbox_vmmdev_types.h | |||
| @@ -102,6 +102,66 @@ enum vmmdev_request_type { | |||
| 102 | #define VMMDEVREQ_HGCM_CALL VMMDEVREQ_HGCM_CALL32 | 102 | #define VMMDEVREQ_HGCM_CALL VMMDEVREQ_HGCM_CALL32 |
| 103 | #endif | 103 | #endif |
| 104 | 104 | ||
| 105 | /* vmmdev_request_header.requestor defines */ | ||
| 106 | |||
| 107 | /* Requestor user not given. */ | ||
| 108 | #define VMMDEV_REQUESTOR_USR_NOT_GIVEN 0x00000000 | ||
| 109 | /* The kernel driver (vboxguest) is the requestor. */ | ||
| 110 | #define VMMDEV_REQUESTOR_USR_DRV 0x00000001 | ||
| 111 | /* Some other kernel driver is the requestor. */ | ||
| 112 | #define VMMDEV_REQUESTOR_USR_DRV_OTHER 0x00000002 | ||
| 113 | /* The root or a admin user is the requestor. */ | ||
| 114 | #define VMMDEV_REQUESTOR_USR_ROOT 0x00000003 | ||
| 115 | /* Regular joe user is making the request. */ | ||
| 116 | #define VMMDEV_REQUESTOR_USR_USER 0x00000006 | ||
| 117 | /* User classification mask. */ | ||
| 118 | #define VMMDEV_REQUESTOR_USR_MASK 0x00000007 | ||
| 119 | |||
| 120 | /* Kernel mode request. Note this is 0, check for !USERMODE instead. */ | ||
| 121 | #define VMMDEV_REQUESTOR_KERNEL 0x00000000 | ||
| 122 | /* User mode request. */ | ||
| 123 | #define VMMDEV_REQUESTOR_USERMODE 0x00000008 | ||
| 124 | /* User or kernel mode classification mask. */ | ||
| 125 | #define VMMDEV_REQUESTOR_MODE_MASK 0x00000008 | ||
| 126 | |||
| 127 | /* Don't know the physical console association of the requestor. */ | ||
| 128 | #define VMMDEV_REQUESTOR_CON_DONT_KNOW 0x00000000 | ||
| 129 | /* | ||
| 130 | * The request originates with a process that is NOT associated with the | ||
| 131 | * physical console. | ||
| 132 | */ | ||
| 133 | #define VMMDEV_REQUESTOR_CON_NO 0x00000010 | ||
| 134 | /* Requestor process is associated with the physical console. */ | ||
| 135 | #define VMMDEV_REQUESTOR_CON_YES 0x00000020 | ||
| 136 | /* Console classification mask. */ | ||
| 137 | #define VMMDEV_REQUESTOR_CON_MASK 0x00000030 | ||
| 138 | |||
| 139 | /* Requestor is member of special VirtualBox user group. */ | ||
| 140 | #define VMMDEV_REQUESTOR_GRP_VBOX 0x00000080 | ||
| 141 | |||
| 142 | /* Note: trust level is for windows guests only, linux always uses not-given */ | ||
| 143 | /* Requestor trust level: Unspecified */ | ||
| 144 | #define VMMDEV_REQUESTOR_TRUST_NOT_GIVEN 0x00000000 | ||
| 145 | /* Requestor trust level: Untrusted (SID S-1-16-0) */ | ||
| 146 | #define VMMDEV_REQUESTOR_TRUST_UNTRUSTED 0x00001000 | ||
| 147 | /* Requestor trust level: Untrusted (SID S-1-16-4096) */ | ||
| 148 | #define VMMDEV_REQUESTOR_TRUST_LOW 0x00002000 | ||
| 149 | /* Requestor trust level: Medium (SID S-1-16-8192) */ | ||
| 150 | #define VMMDEV_REQUESTOR_TRUST_MEDIUM 0x00003000 | ||
| 151 | /* Requestor trust level: Medium plus (SID S-1-16-8448) */ | ||
| 152 | #define VMMDEV_REQUESTOR_TRUST_MEDIUM_PLUS 0x00004000 | ||
| 153 | /* Requestor trust level: High (SID S-1-16-12288) */ | ||
| 154 | #define VMMDEV_REQUESTOR_TRUST_HIGH 0x00005000 | ||
| 155 | /* Requestor trust level: System (SID S-1-16-16384) */ | ||
| 156 | #define VMMDEV_REQUESTOR_TRUST_SYSTEM 0x00006000 | ||
| 157 | /* Requestor trust level >= Protected (SID S-1-16-20480, S-1-16-28672) */ | ||
| 158 | #define VMMDEV_REQUESTOR_TRUST_PROTECTED 0x00007000 | ||
| 159 | /* Requestor trust level mask */ | ||
| 160 | #define VMMDEV_REQUESTOR_TRUST_MASK 0x00007000 | ||
| 161 | |||
| 162 | /* Requestor is using the less trusted user device node (/dev/vboxuser) */ | ||
| 163 | #define VMMDEV_REQUESTOR_USER_DEVICE 0x00008000 | ||
| 164 | |||
| 105 | /** HGCM service location types. */ | 165 | /** HGCM service location types. */ |
| 106 | enum vmmdev_hgcm_service_location_type { | 166 | enum vmmdev_hgcm_service_location_type { |
| 107 | VMMDEV_HGCM_LOC_INVALID = 0, | 167 | VMMDEV_HGCM_LOC_INVALID = 0, |
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 62f6bced3a3c..afca36f53c49 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
| @@ -136,21 +136,29 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr) | |||
| 136 | 136 | ||
| 137 | void *bpf_map_area_alloc(size_t size, int numa_node) | 137 | void *bpf_map_area_alloc(size_t size, int numa_node) |
| 138 | { | 138 | { |
| 139 | /* We definitely need __GFP_NORETRY, so OOM killer doesn't | 139 | /* We really just want to fail instead of triggering OOM killer |
| 140 | * trigger under memory pressure as we really just want to | 140 | * under memory pressure, therefore we set __GFP_NORETRY to kmalloc, |
| 141 | * fail instead. | 141 | * which is used for lower order allocation requests. |
| 142 | * | ||
| 143 | * It has been observed that higher order allocation requests done by | ||
| 144 | * vmalloc with __GFP_NORETRY being set might fail due to not trying | ||
| 145 | * to reclaim memory from the page cache, thus we set | ||
| 146 | * __GFP_RETRY_MAYFAIL to avoid such situations. | ||
| 142 | */ | 147 | */ |
| 143 | const gfp_t flags = __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO; | 148 | |
| 149 | const gfp_t flags = __GFP_NOWARN | __GFP_ZERO; | ||
| 144 | void *area; | 150 | void *area; |
| 145 | 151 | ||
| 146 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { | 152 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { |
| 147 | area = kmalloc_node(size, GFP_USER | flags, numa_node); | 153 | area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags, |
| 154 | numa_node); | ||
| 148 | if (area != NULL) | 155 | if (area != NULL) |
| 149 | return area; | 156 | return area; |
| 150 | } | 157 | } |
| 151 | 158 | ||
| 152 | return __vmalloc_node_flags_caller(size, numa_node, GFP_KERNEL | flags, | 159 | return __vmalloc_node_flags_caller(size, numa_node, |
| 153 | __builtin_return_address(0)); | 160 | GFP_KERNEL | __GFP_RETRY_MAYFAIL | |
| 161 | flags, __builtin_return_address(0)); | ||
| 154 | } | 162 | } |
| 155 | 163 | ||
| 156 | void bpf_map_area_free(void *area) | 164 | void bpf_map_area_free(void *area) |
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index ce166a002d16..fd502c1f71eb 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c | |||
| @@ -212,7 +212,7 @@ struct bpf_call_arg_meta { | |||
| 212 | int access_size; | 212 | int access_size; |
| 213 | s64 msize_smax_value; | 213 | s64 msize_smax_value; |
| 214 | u64 msize_umax_value; | 214 | u64 msize_umax_value; |
| 215 | int ptr_id; | 215 | int ref_obj_id; |
| 216 | int func_id; | 216 | int func_id; |
| 217 | }; | 217 | }; |
| 218 | 218 | ||
| @@ -346,35 +346,23 @@ static bool reg_type_may_be_null(enum bpf_reg_type type) | |||
| 346 | type == PTR_TO_TCP_SOCK_OR_NULL; | 346 | type == PTR_TO_TCP_SOCK_OR_NULL; |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | static bool type_is_refcounted(enum bpf_reg_type type) | ||
| 350 | { | ||
| 351 | return type == PTR_TO_SOCKET; | ||
| 352 | } | ||
| 353 | |||
| 354 | static bool type_is_refcounted_or_null(enum bpf_reg_type type) | ||
| 355 | { | ||
| 356 | return type == PTR_TO_SOCKET || type == PTR_TO_SOCKET_OR_NULL; | ||
| 357 | } | ||
| 358 | |||
| 359 | static bool reg_is_refcounted(const struct bpf_reg_state *reg) | ||
| 360 | { | ||
| 361 | return type_is_refcounted(reg->type); | ||
| 362 | } | ||
| 363 | |||
| 364 | static bool reg_may_point_to_spin_lock(const struct bpf_reg_state *reg) | 349 | static bool reg_may_point_to_spin_lock(const struct bpf_reg_state *reg) |
| 365 | { | 350 | { |
| 366 | return reg->type == PTR_TO_MAP_VALUE && | 351 | return reg->type == PTR_TO_MAP_VALUE && |
| 367 | map_value_has_spin_lock(reg->map_ptr); | 352 | map_value_has_spin_lock(reg->map_ptr); |
| 368 | } | 353 | } |
| 369 | 354 | ||
| 370 | static bool reg_is_refcounted_or_null(const struct bpf_reg_state *reg) | 355 | static bool reg_type_may_be_refcounted_or_null(enum bpf_reg_type type) |
| 371 | { | 356 | { |
| 372 | return type_is_refcounted_or_null(reg->type); | 357 | return type == PTR_TO_SOCKET || |
| 358 | type == PTR_TO_SOCKET_OR_NULL || | ||
| 359 | type == PTR_TO_TCP_SOCK || | ||
| 360 | type == PTR_TO_TCP_SOCK_OR_NULL; | ||
| 373 | } | 361 | } |
| 374 | 362 | ||
| 375 | static bool arg_type_is_refcounted(enum bpf_arg_type type) | 363 | static bool arg_type_may_be_refcounted(enum bpf_arg_type type) |
| 376 | { | 364 | { |
| 377 | return type == ARG_PTR_TO_SOCKET; | 365 | return type == ARG_PTR_TO_SOCK_COMMON; |
| 378 | } | 366 | } |
| 379 | 367 | ||
| 380 | /* Determine whether the function releases some resources allocated by another | 368 | /* Determine whether the function releases some resources allocated by another |
| @@ -392,6 +380,12 @@ static bool is_acquire_function(enum bpf_func_id func_id) | |||
| 392 | func_id == BPF_FUNC_sk_lookup_udp; | 380 | func_id == BPF_FUNC_sk_lookup_udp; |
| 393 | } | 381 | } |
| 394 | 382 | ||
| 383 | static bool is_ptr_cast_function(enum bpf_func_id func_id) | ||
| 384 | { | ||
| 385 | return func_id == BPF_FUNC_tcp_sock || | ||
| 386 | func_id == BPF_FUNC_sk_fullsock; | ||
| 387 | } | ||
| 388 | |||
| 395 | /* string representation of 'enum bpf_reg_type' */ | 389 | /* string representation of 'enum bpf_reg_type' */ |
| 396 | static const char * const reg_type_str[] = { | 390 | static const char * const reg_type_str[] = { |
| 397 | [NOT_INIT] = "?", | 391 | [NOT_INIT] = "?", |
| @@ -466,6 +460,8 @@ static void print_verifier_state(struct bpf_verifier_env *env, | |||
| 466 | verbose(env, ",call_%d", func(env, reg)->callsite); | 460 | verbose(env, ",call_%d", func(env, reg)->callsite); |
| 467 | } else { | 461 | } else { |
| 468 | verbose(env, "(id=%d", reg->id); | 462 | verbose(env, "(id=%d", reg->id); |
| 463 | if (reg_type_may_be_refcounted_or_null(t)) | ||
| 464 | verbose(env, ",ref_obj_id=%d", reg->ref_obj_id); | ||
| 469 | if (t != SCALAR_VALUE) | 465 | if (t != SCALAR_VALUE) |
| 470 | verbose(env, ",off=%d", reg->off); | 466 | verbose(env, ",off=%d", reg->off); |
| 471 | if (type_is_pkt_pointer(t)) | 467 | if (type_is_pkt_pointer(t)) |
| @@ -2414,16 +2410,15 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 regno, | |||
| 2414 | /* Any sk pointer can be ARG_PTR_TO_SOCK_COMMON */ | 2410 | /* Any sk pointer can be ARG_PTR_TO_SOCK_COMMON */ |
| 2415 | if (!type_is_sk_pointer(type)) | 2411 | if (!type_is_sk_pointer(type)) |
| 2416 | goto err_type; | 2412 | goto err_type; |
| 2417 | } else if (arg_type == ARG_PTR_TO_SOCKET) { | 2413 | if (reg->ref_obj_id) { |
| 2418 | expected_type = PTR_TO_SOCKET; | 2414 | if (meta->ref_obj_id) { |
| 2419 | if (type != expected_type) | 2415 | verbose(env, "verifier internal error: more than one arg with ref_obj_id R%d %u %u\n", |
| 2420 | goto err_type; | 2416 | regno, reg->ref_obj_id, |
| 2421 | if (meta->ptr_id || !reg->id) { | 2417 | meta->ref_obj_id); |
| 2422 | verbose(env, "verifier internal error: mismatched references meta=%d, reg=%d\n", | 2418 | return -EFAULT; |
| 2423 | meta->ptr_id, reg->id); | 2419 | } |
| 2424 | return -EFAULT; | 2420 | meta->ref_obj_id = reg->ref_obj_id; |
| 2425 | } | 2421 | } |
| 2426 | meta->ptr_id = reg->id; | ||
| 2427 | } else if (arg_type == ARG_PTR_TO_SPIN_LOCK) { | 2422 | } else if (arg_type == ARG_PTR_TO_SPIN_LOCK) { |
| 2428 | if (meta->func_id == BPF_FUNC_spin_lock) { | 2423 | if (meta->func_id == BPF_FUNC_spin_lock) { |
| 2429 | if (process_spin_lock(env, regno, true)) | 2424 | if (process_spin_lock(env, regno, true)) |
| @@ -2740,32 +2735,38 @@ static bool check_arg_pair_ok(const struct bpf_func_proto *fn) | |||
| 2740 | return true; | 2735 | return true; |
| 2741 | } | 2736 | } |
| 2742 | 2737 | ||
| 2743 | static bool check_refcount_ok(const struct bpf_func_proto *fn) | 2738 | static bool check_refcount_ok(const struct bpf_func_proto *fn, int func_id) |
| 2744 | { | 2739 | { |
| 2745 | int count = 0; | 2740 | int count = 0; |
| 2746 | 2741 | ||
| 2747 | if (arg_type_is_refcounted(fn->arg1_type)) | 2742 | if (arg_type_may_be_refcounted(fn->arg1_type)) |
| 2748 | count++; | 2743 | count++; |
| 2749 | if (arg_type_is_refcounted(fn->arg2_type)) | 2744 | if (arg_type_may_be_refcounted(fn->arg2_type)) |
| 2750 | count++; | 2745 | count++; |
| 2751 | if (arg_type_is_refcounted(fn->arg3_type)) | 2746 | if (arg_type_may_be_refcounted(fn->arg3_type)) |
| 2752 | count++; | 2747 | count++; |
| 2753 | if (arg_type_is_refcounted(fn->arg4_type)) | 2748 | if (arg_type_may_be_refcounted(fn->arg4_type)) |
| 2754 | count++; | 2749 | count++; |
| 2755 | if (arg_type_is_refcounted(fn->arg5_type)) | 2750 | if (arg_type_may_be_refcounted(fn->arg5_type)) |
| 2756 | count++; | 2751 | count++; |
| 2757 | 2752 | ||
| 2753 | /* A reference acquiring function cannot acquire | ||
| 2754 | * another refcounted ptr. | ||
| 2755 | */ | ||
| 2756 | if (is_acquire_function(func_id) && count) | ||
| 2757 | return false; | ||
| 2758 | |||
| 2758 | /* We only support one arg being unreferenced at the moment, | 2759 | /* We only support one arg being unreferenced at the moment, |
| 2759 | * which is sufficient for the helper functions we have right now. | 2760 | * which is sufficient for the helper functions we have right now. |
| 2760 | */ | 2761 | */ |
| 2761 | return count <= 1; | 2762 | return count <= 1; |
| 2762 | } | 2763 | } |
| 2763 | 2764 | ||
| 2764 | static int check_func_proto(const struct bpf_func_proto *fn) | 2765 | static int check_func_proto(const struct bpf_func_proto *fn, int func_id) |
| 2765 | { | 2766 | { |
| 2766 | return check_raw_mode_ok(fn) && | 2767 | return check_raw_mode_ok(fn) && |
| 2767 | check_arg_pair_ok(fn) && | 2768 | check_arg_pair_ok(fn) && |
| 2768 | check_refcount_ok(fn) ? 0 : -EINVAL; | 2769 | check_refcount_ok(fn, func_id) ? 0 : -EINVAL; |
| 2769 | } | 2770 | } |
| 2770 | 2771 | ||
| 2771 | /* Packet data might have moved, any old PTR_TO_PACKET[_META,_END] | 2772 | /* Packet data might have moved, any old PTR_TO_PACKET[_META,_END] |
| @@ -2799,19 +2800,20 @@ static void clear_all_pkt_pointers(struct bpf_verifier_env *env) | |||
| 2799 | } | 2800 | } |
| 2800 | 2801 | ||
| 2801 | static void release_reg_references(struct bpf_verifier_env *env, | 2802 | static void release_reg_references(struct bpf_verifier_env *env, |
| 2802 | struct bpf_func_state *state, int id) | 2803 | struct bpf_func_state *state, |
| 2804 | int ref_obj_id) | ||
| 2803 | { | 2805 | { |
| 2804 | struct bpf_reg_state *regs = state->regs, *reg; | 2806 | struct bpf_reg_state *regs = state->regs, *reg; |
| 2805 | int i; | 2807 | int i; |
| 2806 | 2808 | ||
| 2807 | for (i = 0; i < MAX_BPF_REG; i++) | 2809 | for (i = 0; i < MAX_BPF_REG; i++) |
| 2808 | if (regs[i].id == id) | 2810 | if (regs[i].ref_obj_id == ref_obj_id) |
| 2809 | mark_reg_unknown(env, regs, i); | 2811 | mark_reg_unknown(env, regs, i); |
| 2810 | 2812 | ||
| 2811 | bpf_for_each_spilled_reg(i, state, reg) { | 2813 | bpf_for_each_spilled_reg(i, state, reg) { |
| 2812 | if (!reg) | 2814 | if (!reg) |
| 2813 | continue; | 2815 | continue; |
| 2814 | if (reg_is_refcounted(reg) && reg->id == id) | 2816 | if (reg->ref_obj_id == ref_obj_id) |
| 2815 | __mark_reg_unknown(reg); | 2817 | __mark_reg_unknown(reg); |
| 2816 | } | 2818 | } |
| 2817 | } | 2819 | } |
| @@ -2820,15 +2822,20 @@ static void release_reg_references(struct bpf_verifier_env *env, | |||
| 2820 | * resources. Identify all copies of the same pointer and clear the reference. | 2822 | * resources. Identify all copies of the same pointer and clear the reference. |
| 2821 | */ | 2823 | */ |
| 2822 | static int release_reference(struct bpf_verifier_env *env, | 2824 | static int release_reference(struct bpf_verifier_env *env, |
| 2823 | struct bpf_call_arg_meta *meta) | 2825 | int ref_obj_id) |
| 2824 | { | 2826 | { |
| 2825 | struct bpf_verifier_state *vstate = env->cur_state; | 2827 | struct bpf_verifier_state *vstate = env->cur_state; |
| 2828 | int err; | ||
| 2826 | int i; | 2829 | int i; |
| 2827 | 2830 | ||
| 2831 | err = release_reference_state(cur_func(env), ref_obj_id); | ||
| 2832 | if (err) | ||
| 2833 | return err; | ||
| 2834 | |||
| 2828 | for (i = 0; i <= vstate->curframe; i++) | 2835 | for (i = 0; i <= vstate->curframe; i++) |
| 2829 | release_reg_references(env, vstate->frame[i], meta->ptr_id); | 2836 | release_reg_references(env, vstate->frame[i], ref_obj_id); |
| 2830 | 2837 | ||
| 2831 | return release_reference_state(cur_func(env), meta->ptr_id); | 2838 | return 0; |
| 2832 | } | 2839 | } |
| 2833 | 2840 | ||
| 2834 | static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn, | 2841 | static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn, |
| @@ -3047,7 +3054,7 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn | |||
| 3047 | memset(&meta, 0, sizeof(meta)); | 3054 | memset(&meta, 0, sizeof(meta)); |
| 3048 | meta.pkt_access = fn->pkt_access; | 3055 | meta.pkt_access = fn->pkt_access; |
| 3049 | 3056 | ||
| 3050 | err = check_func_proto(fn); | 3057 | err = check_func_proto(fn, func_id); |
| 3051 | if (err) { | 3058 | if (err) { |
| 3052 | verbose(env, "kernel subsystem misconfigured func %s#%d\n", | 3059 | verbose(env, "kernel subsystem misconfigured func %s#%d\n", |
| 3053 | func_id_name(func_id), func_id); | 3060 | func_id_name(func_id), func_id); |
| @@ -3093,7 +3100,7 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn | |||
| 3093 | return err; | 3100 | return err; |
| 3094 | } | 3101 | } |
| 3095 | } else if (is_release_function(func_id)) { | 3102 | } else if (is_release_function(func_id)) { |
| 3096 | err = release_reference(env, &meta); | 3103 | err = release_reference(env, meta.ref_obj_id); |
| 3097 | if (err) { | 3104 | if (err) { |
| 3098 | verbose(env, "func %s#%d reference has not been acquired before\n", | 3105 | verbose(env, "func %s#%d reference has not been acquired before\n", |
| 3099 | func_id_name(func_id), func_id); | 3106 | func_id_name(func_id), func_id); |
| @@ -3154,8 +3161,10 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn | |||
| 3154 | 3161 | ||
| 3155 | if (id < 0) | 3162 | if (id < 0) |
| 3156 | return id; | 3163 | return id; |
| 3157 | /* For release_reference() */ | 3164 | /* For mark_ptr_or_null_reg() */ |
| 3158 | regs[BPF_REG_0].id = id; | 3165 | regs[BPF_REG_0].id = id; |
| 3166 | /* For release_reference() */ | ||
| 3167 | regs[BPF_REG_0].ref_obj_id = id; | ||
| 3159 | } else { | 3168 | } else { |
| 3160 | /* For mark_ptr_or_null_reg() */ | 3169 | /* For mark_ptr_or_null_reg() */ |
| 3161 | regs[BPF_REG_0].id = ++env->id_gen; | 3170 | regs[BPF_REG_0].id = ++env->id_gen; |
| @@ -3170,6 +3179,10 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn | |||
| 3170 | return -EINVAL; | 3179 | return -EINVAL; |
| 3171 | } | 3180 | } |
| 3172 | 3181 | ||
| 3182 | if (is_ptr_cast_function(func_id)) | ||
| 3183 | /* For release_reference() */ | ||
| 3184 | regs[BPF_REG_0].ref_obj_id = meta.ref_obj_id; | ||
| 3185 | |||
| 3173 | do_refine_retval_range(regs, fn->ret_type, func_id, &meta); | 3186 | do_refine_retval_range(regs, fn->ret_type, func_id, &meta); |
| 3174 | 3187 | ||
| 3175 | err = check_map_func_compatibility(env, meta.map_ptr, func_id); | 3188 | err = check_map_func_compatibility(env, meta.map_ptr, func_id); |
| @@ -3368,7 +3381,7 @@ do_sim: | |||
| 3368 | *dst_reg = *ptr_reg; | 3381 | *dst_reg = *ptr_reg; |
| 3369 | } | 3382 | } |
| 3370 | ret = push_stack(env, env->insn_idx + 1, env->insn_idx, true); | 3383 | ret = push_stack(env, env->insn_idx + 1, env->insn_idx, true); |
| 3371 | if (!ptr_is_dst_reg) | 3384 | if (!ptr_is_dst_reg && ret) |
| 3372 | *dst_reg = tmp; | 3385 | *dst_reg = tmp; |
| 3373 | return !ret ? -EFAULT : 0; | 3386 | return !ret ? -EFAULT : 0; |
| 3374 | } | 3387 | } |
| @@ -4665,11 +4678,19 @@ static void mark_ptr_or_null_reg(struct bpf_func_state *state, | |||
| 4665 | } else if (reg->type == PTR_TO_TCP_SOCK_OR_NULL) { | 4678 | } else if (reg->type == PTR_TO_TCP_SOCK_OR_NULL) { |
| 4666 | reg->type = PTR_TO_TCP_SOCK; | 4679 | reg->type = PTR_TO_TCP_SOCK; |
| 4667 | } | 4680 | } |
| 4668 | if (is_null || !(reg_is_refcounted(reg) || | 4681 | if (is_null) { |
| 4669 | reg_may_point_to_spin_lock(reg))) { | 4682 | /* We don't need id and ref_obj_id from this point |
| 4670 | /* We don't need id from this point onwards anymore, | 4683 | * onwards anymore, thus we should better reset it, |
| 4671 | * thus we should better reset it, so that state | 4684 | * so that state pruning has chances to take effect. |
| 4672 | * pruning has chances to take effect. | 4685 | */ |
| 4686 | reg->id = 0; | ||
| 4687 | reg->ref_obj_id = 0; | ||
| 4688 | } else if (!reg_may_point_to_spin_lock(reg)) { | ||
| 4689 | /* For not-NULL ptr, reg->ref_obj_id will be reset | ||
| 4690 | * in release_reg_references(). | ||
| 4691 | * | ||
| 4692 | * reg->id is still used by spin_lock ptr. Other | ||
| 4693 | * than spin_lock ptr type, reg->id can be reset. | ||
| 4673 | */ | 4694 | */ |
| 4674 | reg->id = 0; | 4695 | reg->id = 0; |
| 4675 | } | 4696 | } |
| @@ -4684,11 +4705,16 @@ static void mark_ptr_or_null_regs(struct bpf_verifier_state *vstate, u32 regno, | |||
| 4684 | { | 4705 | { |
| 4685 | struct bpf_func_state *state = vstate->frame[vstate->curframe]; | 4706 | struct bpf_func_state *state = vstate->frame[vstate->curframe]; |
| 4686 | struct bpf_reg_state *reg, *regs = state->regs; | 4707 | struct bpf_reg_state *reg, *regs = state->regs; |
| 4708 | u32 ref_obj_id = regs[regno].ref_obj_id; | ||
| 4687 | u32 id = regs[regno].id; | 4709 | u32 id = regs[regno].id; |
| 4688 | int i, j; | 4710 | int i, j; |
| 4689 | 4711 | ||
| 4690 | if (reg_is_refcounted_or_null(®s[regno]) && is_null) | 4712 | if (ref_obj_id && ref_obj_id == id && is_null) |
| 4691 | release_reference_state(state, id); | 4713 | /* regs[regno] is in the " == NULL" branch. |
| 4714 | * No one could have freed the reference state before | ||
| 4715 | * doing the NULL check. | ||
| 4716 | */ | ||
| 4717 | WARN_ON_ONCE(release_reference_state(state, id)); | ||
| 4692 | 4718 | ||
| 4693 | for (i = 0; i < MAX_BPF_REG; i++) | 4719 | for (i = 0; i < MAX_BPF_REG; i++) |
| 4694 | mark_ptr_or_null_reg(state, ®s[i], id, is_null); | 4720 | mark_ptr_or_null_reg(state, ®s[i], id, is_null); |
| @@ -6052,15 +6078,17 @@ static int propagate_liveness(struct bpf_verifier_env *env, | |||
| 6052 | } | 6078 | } |
| 6053 | /* Propagate read liveness of registers... */ | 6079 | /* Propagate read liveness of registers... */ |
| 6054 | BUILD_BUG_ON(BPF_REG_FP + 1 != MAX_BPF_REG); | 6080 | BUILD_BUG_ON(BPF_REG_FP + 1 != MAX_BPF_REG); |
| 6055 | /* We don't need to worry about FP liveness because it's read-only */ | 6081 | for (frame = 0; frame <= vstate->curframe; frame++) { |
| 6056 | for (i = 0; i < BPF_REG_FP; i++) { | 6082 | /* We don't need to worry about FP liveness, it's read-only */ |
| 6057 | if (vparent->frame[vparent->curframe]->regs[i].live & REG_LIVE_READ) | 6083 | for (i = frame < vstate->curframe ? BPF_REG_6 : 0; i < BPF_REG_FP; i++) { |
| 6058 | continue; | 6084 | if (vparent->frame[frame]->regs[i].live & REG_LIVE_READ) |
| 6059 | if (vstate->frame[vstate->curframe]->regs[i].live & REG_LIVE_READ) { | 6085 | continue; |
| 6060 | err = mark_reg_read(env, &vstate->frame[vstate->curframe]->regs[i], | 6086 | if (vstate->frame[frame]->regs[i].live & REG_LIVE_READ) { |
| 6061 | &vparent->frame[vstate->curframe]->regs[i]); | 6087 | err = mark_reg_read(env, &vstate->frame[frame]->regs[i], |
| 6062 | if (err) | 6088 | &vparent->frame[frame]->regs[i]); |
| 6063 | return err; | 6089 | if (err) |
| 6090 | return err; | ||
| 6091 | } | ||
| 6064 | } | 6092 | } |
| 6065 | } | 6093 | } |
| 6066 | 6094 | ||
diff --git a/kernel/cpu.c b/kernel/cpu.c index 025f419d16f6..6754f3ecfd94 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
| @@ -564,6 +564,20 @@ static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st) | |||
| 564 | cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL); | 564 | cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL); |
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | static inline bool can_rollback_cpu(struct cpuhp_cpu_state *st) | ||
| 568 | { | ||
| 569 | if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) | ||
| 570 | return true; | ||
| 571 | /* | ||
| 572 | * When CPU hotplug is disabled, then taking the CPU down is not | ||
| 573 | * possible because takedown_cpu() and the architecture and | ||
| 574 | * subsystem specific mechanisms are not available. So the CPU | ||
| 575 | * which would be completely unplugged again needs to stay around | ||
| 576 | * in the current state. | ||
| 577 | */ | ||
| 578 | return st->state <= CPUHP_BRINGUP_CPU; | ||
| 579 | } | ||
| 580 | |||
| 567 | static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st, | 581 | static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st, |
| 568 | enum cpuhp_state target) | 582 | enum cpuhp_state target) |
| 569 | { | 583 | { |
| @@ -574,8 +588,10 @@ static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st, | |||
| 574 | st->state++; | 588 | st->state++; |
| 575 | ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL); | 589 | ret = cpuhp_invoke_callback(cpu, st->state, true, NULL, NULL); |
| 576 | if (ret) { | 590 | if (ret) { |
| 577 | st->target = prev_state; | 591 | if (can_rollback_cpu(st)) { |
| 578 | undo_cpu_up(cpu, st); | 592 | st->target = prev_state; |
| 593 | undo_cpu_up(cpu, st); | ||
| 594 | } | ||
| 579 | break; | 595 | break; |
| 580 | } | 596 | } |
| 581 | } | 597 | } |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 771e93f9c43f..6f357f4fc859 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include <linux/hw_breakpoint.h> | 29 | #include <linux/hw_breakpoint.h> |
| 30 | #include <linux/cn_proc.h> | 30 | #include <linux/cn_proc.h> |
| 31 | #include <linux/compat.h> | 31 | #include <linux/compat.h> |
| 32 | #include <linux/sched/signal.h> | ||
| 32 | 33 | ||
| 33 | /* | 34 | /* |
| 34 | * Access another process' address space via ptrace. | 35 | * Access another process' address space via ptrace. |
| @@ -924,18 +925,26 @@ int ptrace_request(struct task_struct *child, long request, | |||
| 924 | ret = ptrace_setsiginfo(child, &siginfo); | 925 | ret = ptrace_setsiginfo(child, &siginfo); |
| 925 | break; | 926 | break; |
| 926 | 927 | ||
| 927 | case PTRACE_GETSIGMASK: | 928 | case PTRACE_GETSIGMASK: { |
| 929 | sigset_t *mask; | ||
| 930 | |||
| 928 | if (addr != sizeof(sigset_t)) { | 931 | if (addr != sizeof(sigset_t)) { |
| 929 | ret = -EINVAL; | 932 | ret = -EINVAL; |
| 930 | break; | 933 | break; |
| 931 | } | 934 | } |
| 932 | 935 | ||
| 933 | if (copy_to_user(datavp, &child->blocked, sizeof(sigset_t))) | 936 | if (test_tsk_restore_sigmask(child)) |
| 937 | mask = &child->saved_sigmask; | ||
| 938 | else | ||
| 939 | mask = &child->blocked; | ||
| 940 | |||
| 941 | if (copy_to_user(datavp, mask, sizeof(sigset_t))) | ||
| 934 | ret = -EFAULT; | 942 | ret = -EFAULT; |
| 935 | else | 943 | else |
| 936 | ret = 0; | 944 | ret = 0; |
| 937 | 945 | ||
| 938 | break; | 946 | break; |
| 947 | } | ||
| 939 | 948 | ||
| 940 | case PTRACE_SETSIGMASK: { | 949 | case PTRACE_SETSIGMASK: { |
| 941 | sigset_t new_set; | 950 | sigset_t new_set; |
| @@ -961,6 +970,8 @@ int ptrace_request(struct task_struct *child, long request, | |||
| 961 | child->blocked = new_set; | 970 | child->blocked = new_set; |
| 962 | spin_unlock_irq(&child->sighand->siglock); | 971 | spin_unlock_irq(&child->sighand->siglock); |
| 963 | 972 | ||
| 973 | clear_tsk_restore_sigmask(child); | ||
| 974 | |||
| 964 | ret = 0; | 975 | ret = 0; |
| 965 | break; | 976 | break; |
| 966 | } | 977 | } |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index fa79323331b2..26c8ca9bd06b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -1992,7 +1992,7 @@ static void print_bug_type(void) | |||
| 1992 | * modifying the code. @failed should be one of either: | 1992 | * modifying the code. @failed should be one of either: |
| 1993 | * EFAULT - if the problem happens on reading the @ip address | 1993 | * EFAULT - if the problem happens on reading the @ip address |
| 1994 | * EINVAL - if what is read at @ip is not what was expected | 1994 | * EINVAL - if what is read at @ip is not what was expected |
| 1995 | * EPERM - if the problem happens on writting to the @ip address | 1995 | * EPERM - if the problem happens on writing to the @ip address |
| 1996 | */ | 1996 | */ |
| 1997 | void ftrace_bug(int failed, struct dyn_ftrace *rec) | 1997 | void ftrace_bug(int failed, struct dyn_ftrace *rec) |
| 1998 | { | 1998 | { |
| @@ -2391,7 +2391,7 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable) | |||
| 2391 | return ftrace_modify_call(rec, ftrace_old_addr, ftrace_addr); | 2391 | return ftrace_modify_call(rec, ftrace_old_addr, ftrace_addr); |
| 2392 | } | 2392 | } |
| 2393 | 2393 | ||
| 2394 | return -1; /* unknow ftrace bug */ | 2394 | return -1; /* unknown ftrace bug */ |
| 2395 | } | 2395 | } |
| 2396 | 2396 | ||
| 2397 | void __weak ftrace_replace_code(int mod_flags) | 2397 | void __weak ftrace_replace_code(int mod_flags) |
| @@ -3004,7 +3004,7 @@ ftrace_allocate_pages(unsigned long num_to_init) | |||
| 3004 | int cnt; | 3004 | int cnt; |
| 3005 | 3005 | ||
| 3006 | if (!num_to_init) | 3006 | if (!num_to_init) |
| 3007 | return 0; | 3007 | return NULL; |
| 3008 | 3008 | ||
| 3009 | start_pg = pg = kzalloc(sizeof(*pg), GFP_KERNEL); | 3009 | start_pg = pg = kzalloc(sizeof(*pg), GFP_KERNEL); |
| 3010 | if (!pg) | 3010 | if (!pg) |
| @@ -4755,7 +4755,7 @@ static int | |||
| 4755 | ftrace_set_addr(struct ftrace_ops *ops, unsigned long ip, int remove, | 4755 | ftrace_set_addr(struct ftrace_ops *ops, unsigned long ip, int remove, |
| 4756 | int reset, int enable) | 4756 | int reset, int enable) |
| 4757 | { | 4757 | { |
| 4758 | return ftrace_set_hash(ops, 0, 0, ip, remove, reset, enable); | 4758 | return ftrace_set_hash(ops, NULL, 0, ip, remove, reset, enable); |
| 4759 | } | 4759 | } |
| 4760 | 4760 | ||
| 4761 | /** | 4761 | /** |
| @@ -5463,7 +5463,7 @@ void ftrace_create_filter_files(struct ftrace_ops *ops, | |||
| 5463 | 5463 | ||
| 5464 | /* | 5464 | /* |
| 5465 | * The name "destroy_filter_files" is really a misnomer. Although | 5465 | * The name "destroy_filter_files" is really a misnomer. Although |
| 5466 | * in the future, it may actualy delete the files, but this is | 5466 | * in the future, it may actually delete the files, but this is |
| 5467 | * really intended to make sure the ops passed in are disabled | 5467 | * really intended to make sure the ops passed in are disabled |
| 5468 | * and that when this function returns, the caller is free to | 5468 | * and that when this function returns, the caller is free to |
| 5469 | * free the ops. | 5469 | * free the ops. |
| @@ -5786,7 +5786,7 @@ void ftrace_module_enable(struct module *mod) | |||
| 5786 | /* | 5786 | /* |
| 5787 | * If the tracing is enabled, go ahead and enable the record. | 5787 | * If the tracing is enabled, go ahead and enable the record. |
| 5788 | * | 5788 | * |
| 5789 | * The reason not to enable the record immediatelly is the | 5789 | * The reason not to enable the record immediately is the |
| 5790 | * inherent check of ftrace_make_nop/ftrace_make_call for | 5790 | * inherent check of ftrace_make_nop/ftrace_make_call for |
| 5791 | * correct previous instructions. Making first the NOP | 5791 | * correct previous instructions. Making first the NOP |
| 5792 | * conversion puts the module to the correct state, thus | 5792 | * conversion puts the module to the correct state, thus |
diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c index dd1f43588d70..fa100ed3b4de 100644 --- a/kernel/trace/trace_dynevent.c +++ b/kernel/trace/trace_dynevent.c | |||
| @@ -74,7 +74,7 @@ int dyn_event_release(int argc, char **argv, struct dyn_event_operations *type) | |||
| 74 | static int create_dyn_event(int argc, char **argv) | 74 | static int create_dyn_event(int argc, char **argv) |
| 75 | { | 75 | { |
| 76 | struct dyn_event_operations *ops; | 76 | struct dyn_event_operations *ops; |
| 77 | int ret; | 77 | int ret = -ENODEV; |
| 78 | 78 | ||
| 79 | if (argv[0][0] == '-' || argv[0][0] == '!') | 79 | if (argv[0][0] == '-' || argv[0][0] == '!') |
| 80 | return dyn_event_release(argc, argv, NULL); | 80 | return dyn_event_release(argc, argv, NULL); |
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index ca46339f3009..795aa2038377 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c | |||
| @@ -3713,7 +3713,6 @@ static void track_data_destroy(struct hist_trigger_data *hist_data, | |||
| 3713 | struct trace_event_file *file = hist_data->event_file; | 3713 | struct trace_event_file *file = hist_data->event_file; |
| 3714 | 3714 | ||
| 3715 | destroy_hist_field(data->track_data.track_var, 0); | 3715 | destroy_hist_field(data->track_data.track_var, 0); |
| 3716 | destroy_hist_field(data->track_data.var_ref, 0); | ||
| 3717 | 3716 | ||
| 3718 | if (data->action == ACTION_SNAPSHOT) { | 3717 | if (data->action == ACTION_SNAPSHOT) { |
| 3719 | struct track_data *track_data; | 3718 | struct track_data *track_data; |
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 403c9bd90413..6a5787233113 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
| @@ -554,13 +554,15 @@ static void softlockup_start_all(void) | |||
| 554 | 554 | ||
| 555 | int lockup_detector_online_cpu(unsigned int cpu) | 555 | int lockup_detector_online_cpu(unsigned int cpu) |
| 556 | { | 556 | { |
| 557 | watchdog_enable(cpu); | 557 | if (cpumask_test_cpu(cpu, &watchdog_allowed_mask)) |
| 558 | watchdog_enable(cpu); | ||
| 558 | return 0; | 559 | return 0; |
| 559 | } | 560 | } |
| 560 | 561 | ||
| 561 | int lockup_detector_offline_cpu(unsigned int cpu) | 562 | int lockup_detector_offline_cpu(unsigned int cpu) |
| 562 | { | 563 | { |
| 563 | watchdog_disable(cpu); | 564 | if (cpumask_test_cpu(cpu, &watchdog_allowed_mask)) |
| 565 | watchdog_disable(cpu); | ||
| 564 | return 0; | 566 | return 0; |
| 565 | } | 567 | } |
| 566 | 568 | ||
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 0a105d4af166..97f59abc3e92 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c | |||
| @@ -416,8 +416,12 @@ static void rht_deferred_worker(struct work_struct *work) | |||
| 416 | else if (tbl->nest) | 416 | else if (tbl->nest) |
| 417 | err = rhashtable_rehash_alloc(ht, tbl, tbl->size); | 417 | err = rhashtable_rehash_alloc(ht, tbl, tbl->size); |
| 418 | 418 | ||
| 419 | if (!err) | 419 | if (!err || err == -EEXIST) { |
| 420 | err = rhashtable_rehash_table(ht); | 420 | int nerr; |
| 421 | |||
| 422 | nerr = rhashtable_rehash_table(ht); | ||
| 423 | err = err ?: nerr; | ||
| 424 | } | ||
| 421 | 425 | ||
| 422 | mutex_unlock(&ht->mutex); | 426 | mutex_unlock(&ht->mutex); |
| 423 | 427 | ||
diff --git a/lib/sbitmap.c b/lib/sbitmap.c index 5b382c1244ed..155fe38756ec 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c | |||
| @@ -591,6 +591,17 @@ EXPORT_SYMBOL_GPL(sbitmap_queue_wake_up); | |||
| 591 | void sbitmap_queue_clear(struct sbitmap_queue *sbq, unsigned int nr, | 591 | void sbitmap_queue_clear(struct sbitmap_queue *sbq, unsigned int nr, |
| 592 | unsigned int cpu) | 592 | unsigned int cpu) |
| 593 | { | 593 | { |
| 594 | /* | ||
| 595 | * Once the clear bit is set, the bit may be allocated out. | ||
| 596 | * | ||
| 597 | * Orders READ/WRITE on the asssociated instance(such as request | ||
| 598 | * of blk_mq) by this bit for avoiding race with re-allocation, | ||
| 599 | * and its pair is the memory barrier implied in __sbitmap_get_word. | ||
| 600 | * | ||
| 601 | * One invariant is that the clear bit has to be zero when the bit | ||
| 602 | * is in use. | ||
| 603 | */ | ||
| 604 | smp_mb__before_atomic(); | ||
| 594 | sbitmap_deferred_clear_bit(&sbq->sb, nr); | 605 | sbitmap_deferred_clear_bit(&sbq->sb, nr); |
| 595 | 606 | ||
| 596 | /* | 607 | /* |
diff --git a/mm/debug.c b/mm/debug.c index c0b31b6c3877..eee9c221280c 100644 --- a/mm/debug.c +++ b/mm/debug.c | |||
| @@ -79,7 +79,7 @@ void __dump_page(struct page *page, const char *reason) | |||
| 79 | pr_warn("ksm "); | 79 | pr_warn("ksm "); |
| 80 | else if (mapping) { | 80 | else if (mapping) { |
| 81 | pr_warn("%ps ", mapping->a_ops); | 81 | pr_warn("%ps ", mapping->a_ops); |
| 82 | if (mapping->host->i_dentry.first) { | 82 | if (mapping->host && mapping->host->i_dentry.first) { |
| 83 | struct dentry *dentry; | 83 | struct dentry *dentry; |
| 84 | dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); | 84 | dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); |
| 85 | pr_warn("name:\"%pd\" ", dentry); | 85 | pr_warn("name:\"%pd\" ", dentry); |
| @@ -168,7 +168,7 @@ void dump_mm(const struct mm_struct *mm) | |||
| 168 | mm_pgtables_bytes(mm), | 168 | mm_pgtables_bytes(mm), |
| 169 | mm->map_count, | 169 | mm->map_count, |
| 170 | mm->hiwater_rss, mm->hiwater_vm, mm->total_vm, mm->locked_vm, | 170 | mm->hiwater_rss, mm->hiwater_vm, mm->total_vm, mm->locked_vm, |
| 171 | atomic64_read(&mm->pinned_vm), | 171 | (u64)atomic64_read(&mm->pinned_vm), |
| 172 | mm->data_vm, mm->exec_vm, mm->stack_vm, | 172 | mm->data_vm, mm->exec_vm, mm->stack_vm, |
| 173 | mm->start_code, mm->end_code, mm->start_data, mm->end_data, | 173 | mm->start_code, mm->end_code, mm->start_data, mm->end_data, |
| 174 | mm->start_brk, mm->brk, mm->start_stack, | 174 | mm->start_brk, mm->brk, mm->start_stack, |
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 3e0c11f7d7a1..3ce956efa0cb 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h | |||
| @@ -163,7 +163,10 @@ static inline u8 random_tag(void) | |||
| 163 | #endif | 163 | #endif |
| 164 | 164 | ||
| 165 | #ifndef arch_kasan_set_tag | 165 | #ifndef arch_kasan_set_tag |
| 166 | #define arch_kasan_set_tag(addr, tag) ((void *)(addr)) | 166 | static inline const void *arch_kasan_set_tag(const void *addr, u8 tag) |
| 167 | { | ||
| 168 | return addr; | ||
| 169 | } | ||
| 167 | #endif | 170 | #endif |
| 168 | #ifndef arch_kasan_reset_tag | 171 | #ifndef arch_kasan_reset_tag |
| 169 | #define arch_kasan_reset_tag(addr) ((void *)(addr)) | 172 | #define arch_kasan_reset_tag(addr) ((void *)(addr)) |
diff --git a/mm/memory.c b/mm/memory.c index 47fe250307c7..ab650c21bccd 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -1549,10 +1549,12 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, | |||
| 1549 | WARN_ON_ONCE(!is_zero_pfn(pte_pfn(*pte))); | 1549 | WARN_ON_ONCE(!is_zero_pfn(pte_pfn(*pte))); |
| 1550 | goto out_unlock; | 1550 | goto out_unlock; |
| 1551 | } | 1551 | } |
| 1552 | entry = *pte; | 1552 | entry = pte_mkyoung(*pte); |
| 1553 | goto out_mkwrite; | 1553 | entry = maybe_mkwrite(pte_mkdirty(entry), vma); |
| 1554 | } else | 1554 | if (ptep_set_access_flags(vma, addr, pte, entry, 1)) |
| 1555 | goto out_unlock; | 1555 | update_mmu_cache(vma, addr, pte); |
| 1556 | } | ||
| 1557 | goto out_unlock; | ||
| 1556 | } | 1558 | } |
| 1557 | 1559 | ||
| 1558 | /* Ok, finally just insert the thing.. */ | 1560 | /* Ok, finally just insert the thing.. */ |
| @@ -1561,7 +1563,6 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, | |||
| 1561 | else | 1563 | else |
| 1562 | entry = pte_mkspecial(pfn_t_pte(pfn, prot)); | 1564 | entry = pte_mkspecial(pfn_t_pte(pfn, prot)); |
| 1563 | 1565 | ||
| 1564 | out_mkwrite: | ||
| 1565 | if (mkwrite) { | 1566 | if (mkwrite) { |
| 1566 | entry = pte_mkyoung(entry); | 1567 | entry = pte_mkyoung(entry); |
| 1567 | entry = maybe_mkwrite(pte_mkdirty(entry), vma); | 1568 | entry = maybe_mkwrite(pte_mkdirty(entry), vma); |
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f767582af4f8..0082d699be94 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
| @@ -1576,7 +1576,7 @@ static int __ref __offline_pages(unsigned long start_pfn, | |||
| 1576 | { | 1576 | { |
| 1577 | unsigned long pfn, nr_pages; | 1577 | unsigned long pfn, nr_pages; |
| 1578 | long offlined_pages; | 1578 | long offlined_pages; |
| 1579 | int ret, node; | 1579 | int ret, node, nr_isolate_pageblock; |
| 1580 | unsigned long flags; | 1580 | unsigned long flags; |
| 1581 | unsigned long valid_start, valid_end; | 1581 | unsigned long valid_start, valid_end; |
| 1582 | struct zone *zone; | 1582 | struct zone *zone; |
| @@ -1602,10 +1602,11 @@ static int __ref __offline_pages(unsigned long start_pfn, | |||
| 1602 | ret = start_isolate_page_range(start_pfn, end_pfn, | 1602 | ret = start_isolate_page_range(start_pfn, end_pfn, |
| 1603 | MIGRATE_MOVABLE, | 1603 | MIGRATE_MOVABLE, |
| 1604 | SKIP_HWPOISON | REPORT_FAILURE); | 1604 | SKIP_HWPOISON | REPORT_FAILURE); |
| 1605 | if (ret) { | 1605 | if (ret < 0) { |
| 1606 | reason = "failure to isolate range"; | 1606 | reason = "failure to isolate range"; |
| 1607 | goto failed_removal; | 1607 | goto failed_removal; |
| 1608 | } | 1608 | } |
| 1609 | nr_isolate_pageblock = ret; | ||
| 1609 | 1610 | ||
| 1610 | arg.start_pfn = start_pfn; | 1611 | arg.start_pfn = start_pfn; |
| 1611 | arg.nr_pages = nr_pages; | 1612 | arg.nr_pages = nr_pages; |
| @@ -1657,8 +1658,16 @@ static int __ref __offline_pages(unsigned long start_pfn, | |||
| 1657 | /* Ok, all of our target is isolated. | 1658 | /* Ok, all of our target is isolated. |
| 1658 | We cannot do rollback at this point. */ | 1659 | We cannot do rollback at this point. */ |
| 1659 | offline_isolated_pages(start_pfn, end_pfn); | 1660 | offline_isolated_pages(start_pfn, end_pfn); |
| 1660 | /* reset pagetype flags and makes migrate type to be MOVABLE */ | 1661 | |
| 1661 | undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE); | 1662 | /* |
| 1663 | * Onlining will reset pagetype flags and makes migrate type | ||
| 1664 | * MOVABLE, so just need to decrease the number of isolated | ||
| 1665 | * pageblocks zone counter here. | ||
| 1666 | */ | ||
| 1667 | spin_lock_irqsave(&zone->lock, flags); | ||
| 1668 | zone->nr_isolate_pageblock -= nr_isolate_pageblock; | ||
| 1669 | spin_unlock_irqrestore(&zone->lock, flags); | ||
| 1670 | |||
| 1662 | /* removal success */ | 1671 | /* removal success */ |
| 1663 | adjust_managed_page_count(pfn_to_page(start_pfn), -offlined_pages); | 1672 | adjust_managed_page_count(pfn_to_page(start_pfn), -offlined_pages); |
| 1664 | zone->present_pages -= offlined_pages; | 1673 | zone->present_pages -= offlined_pages; |
| @@ -1690,12 +1699,12 @@ static int __ref __offline_pages(unsigned long start_pfn, | |||
| 1690 | 1699 | ||
| 1691 | failed_removal_isolated: | 1700 | failed_removal_isolated: |
| 1692 | undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE); | 1701 | undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE); |
| 1702 | memory_notify(MEM_CANCEL_OFFLINE, &arg); | ||
| 1693 | failed_removal: | 1703 | failed_removal: |
| 1694 | pr_debug("memory offlining [mem %#010llx-%#010llx] failed due to %s\n", | 1704 | pr_debug("memory offlining [mem %#010llx-%#010llx] failed due to %s\n", |
| 1695 | (unsigned long long) start_pfn << PAGE_SHIFT, | 1705 | (unsigned long long) start_pfn << PAGE_SHIFT, |
| 1696 | ((unsigned long long) end_pfn << PAGE_SHIFT) - 1, | 1706 | ((unsigned long long) end_pfn << PAGE_SHIFT) - 1, |
| 1697 | reason); | 1707 | reason); |
| 1698 | memory_notify(MEM_CANCEL_OFFLINE, &arg); | ||
| 1699 | /* pushback to free area */ | 1708 | /* pushback to free area */ |
| 1700 | mem_hotplug_done(); | 1709 | mem_hotplug_done(); |
| 1701 | return ret; | 1710 | return ret; |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index af171ccb56a2..2219e747df49 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
| @@ -428,6 +428,13 @@ static inline bool queue_pages_required(struct page *page, | |||
| 428 | return node_isset(nid, *qp->nmask) == !(flags & MPOL_MF_INVERT); | 428 | return node_isset(nid, *qp->nmask) == !(flags & MPOL_MF_INVERT); |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | /* | ||
| 432 | * queue_pages_pmd() has three possible return values: | ||
| 433 | * 1 - pages are placed on the right node or queued successfully. | ||
| 434 | * 0 - THP was split. | ||
| 435 | * -EIO - is migration entry or MPOL_MF_STRICT was specified and an existing | ||
| 436 | * page was already on a node that does not follow the policy. | ||
| 437 | */ | ||
| 431 | static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, | 438 | static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, |
| 432 | unsigned long end, struct mm_walk *walk) | 439 | unsigned long end, struct mm_walk *walk) |
| 433 | { | 440 | { |
| @@ -437,7 +444,7 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, | |||
| 437 | unsigned long flags; | 444 | unsigned long flags; |
| 438 | 445 | ||
| 439 | if (unlikely(is_pmd_migration_entry(*pmd))) { | 446 | if (unlikely(is_pmd_migration_entry(*pmd))) { |
| 440 | ret = 1; | 447 | ret = -EIO; |
| 441 | goto unlock; | 448 | goto unlock; |
| 442 | } | 449 | } |
| 443 | page = pmd_page(*pmd); | 450 | page = pmd_page(*pmd); |
| @@ -454,8 +461,15 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, | |||
| 454 | ret = 1; | 461 | ret = 1; |
| 455 | flags = qp->flags; | 462 | flags = qp->flags; |
| 456 | /* go to thp migration */ | 463 | /* go to thp migration */ |
| 457 | if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) | 464 | if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { |
| 465 | if (!vma_migratable(walk->vma)) { | ||
| 466 | ret = -EIO; | ||
| 467 | goto unlock; | ||
| 468 | } | ||
| 469 | |||
| 458 | migrate_page_add(page, qp->pagelist, flags); | 470 | migrate_page_add(page, qp->pagelist, flags); |
| 471 | } else | ||
| 472 | ret = -EIO; | ||
| 459 | unlock: | 473 | unlock: |
| 460 | spin_unlock(ptl); | 474 | spin_unlock(ptl); |
| 461 | out: | 475 | out: |
| @@ -480,8 +494,10 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, | |||
| 480 | ptl = pmd_trans_huge_lock(pmd, vma); | 494 | ptl = pmd_trans_huge_lock(pmd, vma); |
| 481 | if (ptl) { | 495 | if (ptl) { |
| 482 | ret = queue_pages_pmd(pmd, ptl, addr, end, walk); | 496 | ret = queue_pages_pmd(pmd, ptl, addr, end, walk); |
| 483 | if (ret) | 497 | if (ret > 0) |
| 484 | return 0; | 498 | return 0; |
| 499 | else if (ret < 0) | ||
| 500 | return ret; | ||
| 485 | } | 501 | } |
| 486 | 502 | ||
| 487 | if (pmd_trans_unstable(pmd)) | 503 | if (pmd_trans_unstable(pmd)) |
| @@ -502,11 +518,16 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, | |||
| 502 | continue; | 518 | continue; |
| 503 | if (!queue_pages_required(page, qp)) | 519 | if (!queue_pages_required(page, qp)) |
| 504 | continue; | 520 | continue; |
| 505 | migrate_page_add(page, qp->pagelist, flags); | 521 | if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { |
| 522 | if (!vma_migratable(vma)) | ||
| 523 | break; | ||
| 524 | migrate_page_add(page, qp->pagelist, flags); | ||
| 525 | } else | ||
| 526 | break; | ||
| 506 | } | 527 | } |
| 507 | pte_unmap_unlock(pte - 1, ptl); | 528 | pte_unmap_unlock(pte - 1, ptl); |
| 508 | cond_resched(); | 529 | cond_resched(); |
| 509 | return 0; | 530 | return addr != end ? -EIO : 0; |
| 510 | } | 531 | } |
| 511 | 532 | ||
| 512 | static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask, | 533 | static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask, |
| @@ -576,7 +597,12 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end, | |||
| 576 | unsigned long endvma = vma->vm_end; | 597 | unsigned long endvma = vma->vm_end; |
| 577 | unsigned long flags = qp->flags; | 598 | unsigned long flags = qp->flags; |
| 578 | 599 | ||
| 579 | if (!vma_migratable(vma)) | 600 | /* |
| 601 | * Need check MPOL_MF_STRICT to return -EIO if possible | ||
| 602 | * regardless of vma_migratable | ||
| 603 | */ | ||
| 604 | if (!vma_migratable(vma) && | ||
| 605 | !(flags & MPOL_MF_STRICT)) | ||
| 580 | return 1; | 606 | return 1; |
| 581 | 607 | ||
| 582 | if (endvma > end) | 608 | if (endvma > end) |
| @@ -603,7 +629,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end, | |||
| 603 | } | 629 | } |
| 604 | 630 | ||
| 605 | /* queue pages from current vma */ | 631 | /* queue pages from current vma */ |
| 606 | if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) | 632 | if (flags & MPOL_MF_VALID) |
| 607 | return 0; | 633 | return 0; |
| 608 | return 1; | 634 | return 1; |
| 609 | } | 635 | } |
diff --git a/mm/migrate.c b/mm/migrate.c index ac6f4939bb59..663a5449367a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
| @@ -248,10 +248,8 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma, | |||
| 248 | pte = swp_entry_to_pte(entry); | 248 | pte = swp_entry_to_pte(entry); |
| 249 | } else if (is_device_public_page(new)) { | 249 | } else if (is_device_public_page(new)) { |
| 250 | pte = pte_mkdevmap(pte); | 250 | pte = pte_mkdevmap(pte); |
| 251 | flush_dcache_page(new); | ||
| 252 | } | 251 | } |
| 253 | } else | 252 | } |
| 254 | flush_dcache_page(new); | ||
| 255 | 253 | ||
| 256 | #ifdef CONFIG_HUGETLB_PAGE | 254 | #ifdef CONFIG_HUGETLB_PAGE |
| 257 | if (PageHuge(new)) { | 255 | if (PageHuge(new)) { |
| @@ -995,6 +993,13 @@ static int move_to_new_page(struct page *newpage, struct page *page, | |||
| 995 | */ | 993 | */ |
| 996 | if (!PageMappingFlags(page)) | 994 | if (!PageMappingFlags(page)) |
| 997 | page->mapping = NULL; | 995 | page->mapping = NULL; |
| 996 | |||
| 997 | if (unlikely(is_zone_device_page(newpage))) { | ||
| 998 | if (is_device_public_page(newpage)) | ||
| 999 | flush_dcache_page(newpage); | ||
| 1000 | } else | ||
| 1001 | flush_dcache_page(newpage); | ||
| 1002 | |||
| 998 | } | 1003 | } |
| 999 | out: | 1004 | out: |
| 1000 | return rc; | 1005 | return rc; |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 03fcf73d47da..d96ca5bc555b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
| @@ -8233,7 +8233,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, | |||
| 8233 | 8233 | ||
| 8234 | ret = start_isolate_page_range(pfn_max_align_down(start), | 8234 | ret = start_isolate_page_range(pfn_max_align_down(start), |
| 8235 | pfn_max_align_up(end), migratetype, 0); | 8235 | pfn_max_align_up(end), migratetype, 0); |
| 8236 | if (ret) | 8236 | if (ret < 0) |
| 8237 | return ret; | 8237 | return ret; |
| 8238 | 8238 | ||
| 8239 | /* | 8239 | /* |
diff --git a/mm/page_isolation.c b/mm/page_isolation.c index ce323e56b34d..019280712e1b 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c | |||
| @@ -59,7 +59,8 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_ | |||
| 59 | * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself. | 59 | * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself. |
| 60 | * We just check MOVABLE pages. | 60 | * We just check MOVABLE pages. |
| 61 | */ | 61 | */ |
| 62 | if (!has_unmovable_pages(zone, page, arg.pages_found, migratetype, flags)) | 62 | if (!has_unmovable_pages(zone, page, arg.pages_found, migratetype, |
| 63 | isol_flags)) | ||
| 63 | ret = 0; | 64 | ret = 0; |
| 64 | 65 | ||
| 65 | /* | 66 | /* |
| @@ -160,27 +161,36 @@ __first_valid_page(unsigned long pfn, unsigned long nr_pages) | |||
| 160 | return NULL; | 161 | return NULL; |
| 161 | } | 162 | } |
| 162 | 163 | ||
| 163 | /* | 164 | /** |
| 164 | * start_isolate_page_range() -- make page-allocation-type of range of pages | 165 | * start_isolate_page_range() - make page-allocation-type of range of pages to |
| 165 | * to be MIGRATE_ISOLATE. | 166 | * be MIGRATE_ISOLATE. |
| 166 | * @start_pfn: The lower PFN of the range to be isolated. | 167 | * @start_pfn: The lower PFN of the range to be isolated. |
| 167 | * @end_pfn: The upper PFN of the range to be isolated. | 168 | * @end_pfn: The upper PFN of the range to be isolated. |
| 168 | * @migratetype: migrate type to set in error recovery. | 169 | * start_pfn/end_pfn must be aligned to pageblock_order. |
| 170 | * @migratetype: Migrate type to set in error recovery. | ||
| 171 | * @flags: The following flags are allowed (they can be combined in | ||
| 172 | * a bit mask) | ||
| 173 | * SKIP_HWPOISON - ignore hwpoison pages | ||
| 174 | * REPORT_FAILURE - report details about the failure to | ||
| 175 | * isolate the range | ||
| 169 | * | 176 | * |
| 170 | * Making page-allocation-type to be MIGRATE_ISOLATE means free pages in | 177 | * Making page-allocation-type to be MIGRATE_ISOLATE means free pages in |
| 171 | * the range will never be allocated. Any free pages and pages freed in the | 178 | * the range will never be allocated. Any free pages and pages freed in the |
| 172 | * future will not be allocated again. | 179 | * future will not be allocated again. If specified range includes migrate types |
| 173 | * | 180 | * other than MOVABLE or CMA, this will fail with -EBUSY. For isolating all |
| 174 | * start_pfn/end_pfn must be aligned to pageblock_order. | 181 | * pages in the range finally, the caller have to free all pages in the range. |
| 175 | * Return 0 on success and -EBUSY if any part of range cannot be isolated. | 182 | * test_page_isolated() can be used for test it. |
| 176 | * | 183 | * |
| 177 | * There is no high level synchronization mechanism that prevents two threads | 184 | * There is no high level synchronization mechanism that prevents two threads |
| 178 | * from trying to isolate overlapping ranges. If this happens, one thread | 185 | * from trying to isolate overlapping ranges. If this happens, one thread |
| 179 | * will notice pageblocks in the overlapping range already set to isolate. | 186 | * will notice pageblocks in the overlapping range already set to isolate. |
| 180 | * This happens in set_migratetype_isolate, and set_migratetype_isolate | 187 | * This happens in set_migratetype_isolate, and set_migratetype_isolate |
| 181 | * returns an error. We then clean up by restoring the migration type on | 188 | * returns an error. We then clean up by restoring the migration type on |
| 182 | * pageblocks we may have modified and return -EBUSY to caller. This | 189 | * pageblocks we may have modified and return -EBUSY to caller. This |
| 183 | * prevents two threads from simultaneously working on overlapping ranges. | 190 | * prevents two threads from simultaneously working on overlapping ranges. |
| 191 | * | ||
| 192 | * Return: the number of isolated pageblocks on success and -EBUSY if any part | ||
| 193 | * of range cannot be isolated. | ||
| 184 | */ | 194 | */ |
| 185 | int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, | 195 | int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, |
| 186 | unsigned migratetype, int flags) | 196 | unsigned migratetype, int flags) |
| @@ -188,6 +198,7 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, | |||
| 188 | unsigned long pfn; | 198 | unsigned long pfn; |
| 189 | unsigned long undo_pfn; | 199 | unsigned long undo_pfn; |
| 190 | struct page *page; | 200 | struct page *page; |
| 201 | int nr_isolate_pageblock = 0; | ||
| 191 | 202 | ||
| 192 | BUG_ON(!IS_ALIGNED(start_pfn, pageblock_nr_pages)); | 203 | BUG_ON(!IS_ALIGNED(start_pfn, pageblock_nr_pages)); |
| 193 | BUG_ON(!IS_ALIGNED(end_pfn, pageblock_nr_pages)); | 204 | BUG_ON(!IS_ALIGNED(end_pfn, pageblock_nr_pages)); |
| @@ -196,13 +207,15 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, | |||
| 196 | pfn < end_pfn; | 207 | pfn < end_pfn; |
| 197 | pfn += pageblock_nr_pages) { | 208 | pfn += pageblock_nr_pages) { |
| 198 | page = __first_valid_page(pfn, pageblock_nr_pages); | 209 | page = __first_valid_page(pfn, pageblock_nr_pages); |
| 199 | if (page && | 210 | if (page) { |
| 200 | set_migratetype_isolate(page, migratetype, flags)) { | 211 | if (set_migratetype_isolate(page, migratetype, flags)) { |
| 201 | undo_pfn = pfn; | 212 | undo_pfn = pfn; |
| 202 | goto undo; | 213 | goto undo; |
| 214 | } | ||
| 215 | nr_isolate_pageblock++; | ||
| 203 | } | 216 | } |
| 204 | } | 217 | } |
| 205 | return 0; | 218 | return nr_isolate_pageblock; |
| 206 | undo: | 219 | undo: |
| 207 | for (pfn = start_pfn; | 220 | for (pfn = start_pfn; |
| 208 | pfn < undo_pfn; | 221 | pfn < undo_pfn; |
| @@ -2115,6 +2115,8 @@ done: | |||
| 2115 | cachep->allocflags = __GFP_COMP; | 2115 | cachep->allocflags = __GFP_COMP; |
| 2116 | if (flags & SLAB_CACHE_DMA) | 2116 | if (flags & SLAB_CACHE_DMA) |
| 2117 | cachep->allocflags |= GFP_DMA; | 2117 | cachep->allocflags |= GFP_DMA; |
| 2118 | if (flags & SLAB_CACHE_DMA32) | ||
| 2119 | cachep->allocflags |= GFP_DMA32; | ||
| 2118 | if (flags & SLAB_RECLAIM_ACCOUNT) | 2120 | if (flags & SLAB_RECLAIM_ACCOUNT) |
| 2119 | cachep->allocflags |= __GFP_RECLAIMABLE; | 2121 | cachep->allocflags |= __GFP_RECLAIMABLE; |
| 2120 | cachep->size = size; | 2122 | cachep->size = size; |
| @@ -127,7 +127,8 @@ static inline slab_flags_t kmem_cache_flags(unsigned int object_size, | |||
| 127 | 127 | ||
| 128 | 128 | ||
| 129 | /* Legal flag mask for kmem_cache_create(), for various configurations */ | 129 | /* Legal flag mask for kmem_cache_create(), for various configurations */ |
| 130 | #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \ | 130 | #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | \ |
| 131 | SLAB_CACHE_DMA32 | SLAB_PANIC | \ | ||
| 131 | SLAB_TYPESAFE_BY_RCU | SLAB_DEBUG_OBJECTS ) | 132 | SLAB_TYPESAFE_BY_RCU | SLAB_DEBUG_OBJECTS ) |
| 132 | 133 | ||
| 133 | #if defined(CONFIG_DEBUG_SLAB) | 134 | #if defined(CONFIG_DEBUG_SLAB) |
diff --git a/mm/slab_common.c b/mm/slab_common.c index 03eeb8b7b4b1..58251ba63e4a 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
| @@ -53,7 +53,7 @@ static DECLARE_WORK(slab_caches_to_rcu_destroy_work, | |||
| 53 | SLAB_FAILSLAB | SLAB_KASAN) | 53 | SLAB_FAILSLAB | SLAB_KASAN) |
| 54 | 54 | ||
| 55 | #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \ | 55 | #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \ |
| 56 | SLAB_ACCOUNT) | 56 | SLAB_CACHE_DMA32 | SLAB_ACCOUNT) |
| 57 | 57 | ||
| 58 | /* | 58 | /* |
| 59 | * Merge control. If this is set then no merging of slab caches will occur. | 59 | * Merge control. If this is set then no merging of slab caches will occur. |
| @@ -3589,6 +3589,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) | |||
| 3589 | if (s->flags & SLAB_CACHE_DMA) | 3589 | if (s->flags & SLAB_CACHE_DMA) |
| 3590 | s->allocflags |= GFP_DMA; | 3590 | s->allocflags |= GFP_DMA; |
| 3591 | 3591 | ||
| 3592 | if (s->flags & SLAB_CACHE_DMA32) | ||
| 3593 | s->allocflags |= GFP_DMA32; | ||
| 3594 | |||
| 3592 | if (s->flags & SLAB_RECLAIM_ACCOUNT) | 3595 | if (s->flags & SLAB_RECLAIM_ACCOUNT) |
| 3593 | s->allocflags |= __GFP_RECLAIMABLE; | 3596 | s->allocflags |= __GFP_RECLAIMABLE; |
| 3594 | 3597 | ||
| @@ -5679,6 +5682,8 @@ static char *create_unique_id(struct kmem_cache *s) | |||
| 5679 | */ | 5682 | */ |
| 5680 | if (s->flags & SLAB_CACHE_DMA) | 5683 | if (s->flags & SLAB_CACHE_DMA) |
| 5681 | *p++ = 'd'; | 5684 | *p++ = 'd'; |
| 5685 | if (s->flags & SLAB_CACHE_DMA32) | ||
| 5686 | *p++ = 'D'; | ||
| 5682 | if (s->flags & SLAB_RECLAIM_ACCOUNT) | 5687 | if (s->flags & SLAB_RECLAIM_ACCOUNT) |
| 5683 | *p++ = 'a'; | 5688 | *p++ = 'a'; |
| 5684 | if (s->flags & SLAB_CONSISTENCY_CHECKS) | 5689 | if (s->flags & SLAB_CONSISTENCY_CHECKS) |
diff --git a/mm/sparse.c b/mm/sparse.c index 69904aa6165b..56e057c432f9 100644 --- a/mm/sparse.c +++ b/mm/sparse.c | |||
| @@ -567,7 +567,7 @@ void online_mem_sections(unsigned long start_pfn, unsigned long end_pfn) | |||
| 567 | } | 567 | } |
| 568 | 568 | ||
| 569 | #ifdef CONFIG_MEMORY_HOTREMOVE | 569 | #ifdef CONFIG_MEMORY_HOTREMOVE |
| 570 | /* Mark all memory sections within the pfn range as online */ | 570 | /* Mark all memory sections within the pfn range as offline */ |
| 571 | void offline_mem_sections(unsigned long start_pfn, unsigned long end_pfn) | 571 | void offline_mem_sections(unsigned long start_pfn, unsigned long end_pfn) |
| 572 | { | 572 | { |
| 573 | unsigned long pfn; | 573 | unsigned long pfn; |
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c index 49a16cee2aae..420a98bf79b5 100644 --- a/net/appletalk/aarp.c +++ b/net/appletalk/aarp.c | |||
| @@ -879,15 +879,24 @@ static struct notifier_block aarp_notifier = { | |||
| 879 | 879 | ||
| 880 | static unsigned char aarp_snap_id[] = { 0x00, 0x00, 0x00, 0x80, 0xF3 }; | 880 | static unsigned char aarp_snap_id[] = { 0x00, 0x00, 0x00, 0x80, 0xF3 }; |
| 881 | 881 | ||
| 882 | void __init aarp_proto_init(void) | 882 | int __init aarp_proto_init(void) |
| 883 | { | 883 | { |
| 884 | int rc; | ||
| 885 | |||
| 884 | aarp_dl = register_snap_client(aarp_snap_id, aarp_rcv); | 886 | aarp_dl = register_snap_client(aarp_snap_id, aarp_rcv); |
| 885 | if (!aarp_dl) | 887 | if (!aarp_dl) { |
| 886 | printk(KERN_CRIT "Unable to register AARP with SNAP.\n"); | 888 | printk(KERN_CRIT "Unable to register AARP with SNAP.\n"); |
| 889 | return -ENOMEM; | ||
| 890 | } | ||
| 887 | timer_setup(&aarp_timer, aarp_expire_timeout, 0); | 891 | timer_setup(&aarp_timer, aarp_expire_timeout, 0); |
| 888 | aarp_timer.expires = jiffies + sysctl_aarp_expiry_time; | 892 | aarp_timer.expires = jiffies + sysctl_aarp_expiry_time; |
| 889 | add_timer(&aarp_timer); | 893 | add_timer(&aarp_timer); |
| 890 | register_netdevice_notifier(&aarp_notifier); | 894 | rc = register_netdevice_notifier(&aarp_notifier); |
| 895 | if (rc) { | ||
| 896 | del_timer_sync(&aarp_timer); | ||
| 897 | unregister_snap_client(aarp_dl); | ||
| 898 | } | ||
| 899 | return rc; | ||
| 891 | } | 900 | } |
| 892 | 901 | ||
| 893 | /* Remove the AARP entries associated with a device. */ | 902 | /* Remove the AARP entries associated with a device. */ |
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 795fbc6c06aa..709d2542f729 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
| @@ -1904,9 +1904,6 @@ static unsigned char ddp_snap_id[] = { 0x08, 0x00, 0x07, 0x80, 0x9B }; | |||
| 1904 | EXPORT_SYMBOL(atrtr_get_dev); | 1904 | EXPORT_SYMBOL(atrtr_get_dev); |
| 1905 | EXPORT_SYMBOL(atalk_find_dev_addr); | 1905 | EXPORT_SYMBOL(atalk_find_dev_addr); |
| 1906 | 1906 | ||
| 1907 | static const char atalk_err_snap[] __initconst = | ||
| 1908 | KERN_CRIT "Unable to register DDP with SNAP.\n"; | ||
| 1909 | |||
| 1910 | /* Called by proto.c on kernel start up */ | 1907 | /* Called by proto.c on kernel start up */ |
| 1911 | static int __init atalk_init(void) | 1908 | static int __init atalk_init(void) |
| 1912 | { | 1909 | { |
| @@ -1921,17 +1918,22 @@ static int __init atalk_init(void) | |||
| 1921 | goto out_proto; | 1918 | goto out_proto; |
| 1922 | 1919 | ||
| 1923 | ddp_dl = register_snap_client(ddp_snap_id, atalk_rcv); | 1920 | ddp_dl = register_snap_client(ddp_snap_id, atalk_rcv); |
| 1924 | if (!ddp_dl) | 1921 | if (!ddp_dl) { |
| 1925 | printk(atalk_err_snap); | 1922 | pr_crit("Unable to register DDP with SNAP.\n"); |
| 1923 | goto out_sock; | ||
| 1924 | } | ||
| 1926 | 1925 | ||
| 1927 | dev_add_pack(<alk_packet_type); | 1926 | dev_add_pack(<alk_packet_type); |
| 1928 | dev_add_pack(&ppptalk_packet_type); | 1927 | dev_add_pack(&ppptalk_packet_type); |
| 1929 | 1928 | ||
| 1930 | rc = register_netdevice_notifier(&ddp_notifier); | 1929 | rc = register_netdevice_notifier(&ddp_notifier); |
| 1931 | if (rc) | 1930 | if (rc) |
| 1932 | goto out_sock; | 1931 | goto out_snap; |
| 1932 | |||
| 1933 | rc = aarp_proto_init(); | ||
| 1934 | if (rc) | ||
| 1935 | goto out_dev; | ||
| 1933 | 1936 | ||
| 1934 | aarp_proto_init(); | ||
| 1935 | rc = atalk_proc_init(); | 1937 | rc = atalk_proc_init(); |
| 1936 | if (rc) | 1938 | if (rc) |
| 1937 | goto out_aarp; | 1939 | goto out_aarp; |
| @@ -1945,11 +1947,13 @@ out_proc: | |||
| 1945 | atalk_proc_exit(); | 1947 | atalk_proc_exit(); |
| 1946 | out_aarp: | 1948 | out_aarp: |
| 1947 | aarp_cleanup_module(); | 1949 | aarp_cleanup_module(); |
| 1950 | out_dev: | ||
| 1948 | unregister_netdevice_notifier(&ddp_notifier); | 1951 | unregister_netdevice_notifier(&ddp_notifier); |
| 1949 | out_sock: | 1952 | out_snap: |
| 1950 | dev_remove_pack(&ppptalk_packet_type); | 1953 | dev_remove_pack(&ppptalk_packet_type); |
| 1951 | dev_remove_pack(<alk_packet_type); | 1954 | dev_remove_pack(<alk_packet_type); |
| 1952 | unregister_snap_client(ddp_dl); | 1955 | unregister_snap_client(ddp_dl); |
| 1956 | out_sock: | ||
| 1953 | sock_unregister(PF_APPLETALK); | 1957 | sock_unregister(PF_APPLETALK); |
| 1954 | out_proto: | 1958 | out_proto: |
| 1955 | proto_unregister(&ddp_proto); | 1959 | proto_unregister(&ddp_proto); |
diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c index 9d34de68571b..22afa566cbce 100644 --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c | |||
| @@ -502,6 +502,7 @@ static unsigned int br_nf_pre_routing(void *priv, | |||
| 502 | nf_bridge->ipv4_daddr = ip_hdr(skb)->daddr; | 502 | nf_bridge->ipv4_daddr = ip_hdr(skb)->daddr; |
| 503 | 503 | ||
| 504 | skb->protocol = htons(ETH_P_IP); | 504 | skb->protocol = htons(ETH_P_IP); |
| 505 | skb->transport_header = skb->network_header + ip_hdr(skb)->ihl * 4; | ||
| 505 | 506 | ||
| 506 | NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb, | 507 | NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb, |
| 507 | skb->dev, NULL, | 508 | skb->dev, NULL, |
diff --git a/net/bridge/br_netfilter_ipv6.c b/net/bridge/br_netfilter_ipv6.c index 564710f88f93..e88d6641647b 100644 --- a/net/bridge/br_netfilter_ipv6.c +++ b/net/bridge/br_netfilter_ipv6.c | |||
| @@ -235,6 +235,8 @@ unsigned int br_nf_pre_routing_ipv6(void *priv, | |||
| 235 | nf_bridge->ipv6_daddr = ipv6_hdr(skb)->daddr; | 235 | nf_bridge->ipv6_daddr = ipv6_hdr(skb)->daddr; |
| 236 | 236 | ||
| 237 | skb->protocol = htons(ETH_P_IPV6); | 237 | skb->protocol = htons(ETH_P_IPV6); |
| 238 | skb->transport_header = skb->network_header + sizeof(struct ipv6hdr); | ||
| 239 | |||
| 238 | NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, state->net, state->sk, skb, | 240 | NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, state->net, state->sk, skb, |
| 239 | skb->dev, NULL, | 241 | skb->dev, NULL, |
| 240 | br_nf_pre_routing_finish_ipv6); | 242 | br_nf_pre_routing_finish_ipv6); |
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 7e71b0df1fbc..3083988ce729 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
| @@ -840,6 +840,7 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor, | |||
| 840 | size_t bytes) | 840 | size_t bytes) |
| 841 | { | 841 | { |
| 842 | struct ceph_bio_iter *it = &cursor->bio_iter; | 842 | struct ceph_bio_iter *it = &cursor->bio_iter; |
| 843 | struct page *page = bio_iter_page(it->bio, it->iter); | ||
| 843 | 844 | ||
| 844 | BUG_ON(bytes > cursor->resid); | 845 | BUG_ON(bytes > cursor->resid); |
| 845 | BUG_ON(bytes > bio_iter_len(it->bio, it->iter)); | 846 | BUG_ON(bytes > bio_iter_len(it->bio, it->iter)); |
| @@ -851,7 +852,8 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor, | |||
| 851 | return false; /* no more data */ | 852 | return false; /* no more data */ |
| 852 | } | 853 | } |
| 853 | 854 | ||
| 854 | if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done)) | 855 | if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done && |
| 856 | page == bio_iter_page(it->bio, it->iter))) | ||
| 855 | return false; /* more bytes to process in this segment */ | 857 | return false; /* more bytes to process in this segment */ |
| 856 | 858 | ||
| 857 | if (!it->iter.bi_size) { | 859 | if (!it->iter.bi_size) { |
| @@ -899,6 +901,7 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor, | |||
| 899 | size_t bytes) | 901 | size_t bytes) |
| 900 | { | 902 | { |
| 901 | struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs; | 903 | struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs; |
| 904 | struct page *page = bvec_iter_page(bvecs, cursor->bvec_iter); | ||
| 902 | 905 | ||
| 903 | BUG_ON(bytes > cursor->resid); | 906 | BUG_ON(bytes > cursor->resid); |
| 904 | BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter)); | 907 | BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter)); |
| @@ -910,7 +913,8 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor, | |||
| 910 | return false; /* no more data */ | 913 | return false; /* no more data */ |
| 911 | } | 914 | } |
| 912 | 915 | ||
| 913 | if (!bytes || cursor->bvec_iter.bi_bvec_done) | 916 | if (!bytes || (cursor->bvec_iter.bi_bvec_done && |
| 917 | page == bvec_iter_page(bvecs, cursor->bvec_iter))) | ||
| 914 | return false; /* more bytes to process in this segment */ | 918 | return false; /* more bytes to process in this segment */ |
| 915 | 919 | ||
| 916 | BUG_ON(cursor->last_piece); | 920 | BUG_ON(cursor->last_piece); |
diff --git a/net/core/devlink.c b/net/core/devlink.c index 78e22cea4cc7..da0a29f30885 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c | |||
| @@ -3897,6 +3897,11 @@ static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg, | |||
| 3897 | continue; | 3897 | continue; |
| 3898 | } | 3898 | } |
| 3899 | 3899 | ||
| 3900 | if (!devlink->ops->info_get) { | ||
| 3901 | idx++; | ||
| 3902 | continue; | ||
| 3903 | } | ||
| 3904 | |||
| 3900 | mutex_lock(&devlink->lock); | 3905 | mutex_lock(&devlink->lock); |
| 3901 | err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET, | 3906 | err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET, |
| 3902 | NETLINK_CB(cb->skb).portid, | 3907 | NETLINK_CB(cb->skb).portid, |
diff --git a/net/core/filter.c b/net/core/filter.c index f274620945ff..647c63a7b25b 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
| @@ -1796,8 +1796,6 @@ static const struct bpf_func_proto bpf_skb_pull_data_proto = { | |||
| 1796 | 1796 | ||
| 1797 | BPF_CALL_1(bpf_sk_fullsock, struct sock *, sk) | 1797 | BPF_CALL_1(bpf_sk_fullsock, struct sock *, sk) |
| 1798 | { | 1798 | { |
| 1799 | sk = sk_to_full_sk(sk); | ||
| 1800 | |||
| 1801 | return sk_fullsock(sk) ? (unsigned long)sk : (unsigned long)NULL; | 1799 | return sk_fullsock(sk) ? (unsigned long)sk : (unsigned long)NULL; |
| 1802 | } | 1800 | } |
| 1803 | 1801 | ||
| @@ -5266,7 +5264,7 @@ static const struct bpf_func_proto bpf_sk_release_proto = { | |||
| 5266 | .func = bpf_sk_release, | 5264 | .func = bpf_sk_release, |
| 5267 | .gpl_only = false, | 5265 | .gpl_only = false, |
| 5268 | .ret_type = RET_INTEGER, | 5266 | .ret_type = RET_INTEGER, |
| 5269 | .arg1_type = ARG_PTR_TO_SOCKET, | 5267 | .arg1_type = ARG_PTR_TO_SOCK_COMMON, |
| 5270 | }; | 5268 | }; |
| 5271 | 5269 | ||
| 5272 | BPF_CALL_5(bpf_xdp_sk_lookup_udp, struct xdp_buff *, ctx, | 5270 | BPF_CALL_5(bpf_xdp_sk_lookup_udp, struct xdp_buff *, ctx, |
| @@ -5407,8 +5405,6 @@ u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type, | |||
| 5407 | 5405 | ||
| 5408 | BPF_CALL_1(bpf_tcp_sock, struct sock *, sk) | 5406 | BPF_CALL_1(bpf_tcp_sock, struct sock *, sk) |
| 5409 | { | 5407 | { |
| 5410 | sk = sk_to_full_sk(sk); | ||
| 5411 | |||
| 5412 | if (sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP) | 5408 | if (sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP) |
| 5413 | return (unsigned long)sk; | 5409 | return (unsigned long)sk; |
| 5414 | 5410 | ||
| @@ -5422,6 +5418,23 @@ static const struct bpf_func_proto bpf_tcp_sock_proto = { | |||
| 5422 | .arg1_type = ARG_PTR_TO_SOCK_COMMON, | 5418 | .arg1_type = ARG_PTR_TO_SOCK_COMMON, |
| 5423 | }; | 5419 | }; |
| 5424 | 5420 | ||
| 5421 | BPF_CALL_1(bpf_get_listener_sock, struct sock *, sk) | ||
| 5422 | { | ||
| 5423 | sk = sk_to_full_sk(sk); | ||
| 5424 | |||
| 5425 | if (sk->sk_state == TCP_LISTEN && sock_flag(sk, SOCK_RCU_FREE)) | ||
| 5426 | return (unsigned long)sk; | ||
| 5427 | |||
| 5428 | return (unsigned long)NULL; | ||
| 5429 | } | ||
| 5430 | |||
| 5431 | static const struct bpf_func_proto bpf_get_listener_sock_proto = { | ||
| 5432 | .func = bpf_get_listener_sock, | ||
| 5433 | .gpl_only = false, | ||
| 5434 | .ret_type = RET_PTR_TO_SOCKET_OR_NULL, | ||
| 5435 | .arg1_type = ARG_PTR_TO_SOCK_COMMON, | ||
| 5436 | }; | ||
| 5437 | |||
| 5425 | BPF_CALL_1(bpf_skb_ecn_set_ce, struct sk_buff *, skb) | 5438 | BPF_CALL_1(bpf_skb_ecn_set_ce, struct sk_buff *, skb) |
| 5426 | { | 5439 | { |
| 5427 | unsigned int iphdr_len; | 5440 | unsigned int iphdr_len; |
| @@ -5607,6 +5620,8 @@ cg_skb_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) | |||
| 5607 | #ifdef CONFIG_INET | 5620 | #ifdef CONFIG_INET |
| 5608 | case BPF_FUNC_tcp_sock: | 5621 | case BPF_FUNC_tcp_sock: |
| 5609 | return &bpf_tcp_sock_proto; | 5622 | return &bpf_tcp_sock_proto; |
| 5623 | case BPF_FUNC_get_listener_sock: | ||
| 5624 | return &bpf_get_listener_sock_proto; | ||
| 5610 | case BPF_FUNC_skb_ecn_set_ce: | 5625 | case BPF_FUNC_skb_ecn_set_ce: |
| 5611 | return &bpf_skb_ecn_set_ce_proto; | 5626 | return &bpf_skb_ecn_set_ce_proto; |
| 5612 | #endif | 5627 | #endif |
| @@ -5702,6 +5717,8 @@ tc_cls_act_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) | |||
| 5702 | return &bpf_sk_release_proto; | 5717 | return &bpf_sk_release_proto; |
| 5703 | case BPF_FUNC_tcp_sock: | 5718 | case BPF_FUNC_tcp_sock: |
| 5704 | return &bpf_tcp_sock_proto; | 5719 | return &bpf_tcp_sock_proto; |
| 5720 | case BPF_FUNC_get_listener_sock: | ||
| 5721 | return &bpf_get_listener_sock_proto; | ||
| 5705 | #endif | 5722 | #endif |
| 5706 | default: | 5723 | default: |
| 5707 | return bpf_base_func_proto(func_id); | 5724 | return bpf_base_func_proto(func_id); |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 4ff661f6f989..f8f94303a1f5 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
| @@ -928,6 +928,8 @@ static int rx_queue_add_kobject(struct net_device *dev, int index) | |||
| 928 | if (error) | 928 | if (error) |
| 929 | return error; | 929 | return error; |
| 930 | 930 | ||
| 931 | dev_hold(queue->dev); | ||
| 932 | |||
| 931 | if (dev->sysfs_rx_queue_group) { | 933 | if (dev->sysfs_rx_queue_group) { |
| 932 | error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group); | 934 | error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group); |
| 933 | if (error) { | 935 | if (error) { |
| @@ -937,7 +939,6 @@ static int rx_queue_add_kobject(struct net_device *dev, int index) | |||
| 937 | } | 939 | } |
| 938 | 940 | ||
| 939 | kobject_uevent(kobj, KOBJ_ADD); | 941 | kobject_uevent(kobj, KOBJ_ADD); |
| 940 | dev_hold(queue->dev); | ||
| 941 | 942 | ||
| 942 | return error; | 943 | return error; |
| 943 | } | 944 | } |
| @@ -1464,6 +1465,8 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index) | |||
| 1464 | if (error) | 1465 | if (error) |
| 1465 | return error; | 1466 | return error; |
| 1466 | 1467 | ||
| 1468 | dev_hold(queue->dev); | ||
| 1469 | |||
| 1467 | #ifdef CONFIG_BQL | 1470 | #ifdef CONFIG_BQL |
| 1468 | error = sysfs_create_group(kobj, &dql_group); | 1471 | error = sysfs_create_group(kobj, &dql_group); |
| 1469 | if (error) { | 1472 | if (error) { |
| @@ -1473,7 +1476,6 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index) | |||
| 1473 | #endif | 1476 | #endif |
| 1474 | 1477 | ||
| 1475 | kobject_uevent(kobj, KOBJ_ADD); | 1478 | kobject_uevent(kobj, KOBJ_ADD); |
| 1476 | dev_hold(queue->dev); | ||
| 1477 | 1479 | ||
| 1478 | return 0; | 1480 | return 0; |
| 1479 | } | 1481 | } |
| @@ -1745,16 +1747,20 @@ int netdev_register_kobject(struct net_device *ndev) | |||
| 1745 | 1747 | ||
| 1746 | error = device_add(dev); | 1748 | error = device_add(dev); |
| 1747 | if (error) | 1749 | if (error) |
| 1748 | return error; | 1750 | goto error_put_device; |
| 1749 | 1751 | ||
| 1750 | error = register_queue_kobjects(ndev); | 1752 | error = register_queue_kobjects(ndev); |
| 1751 | if (error) { | 1753 | if (error) |
| 1752 | device_del(dev); | 1754 | goto error_device_del; |
| 1753 | return error; | ||
| 1754 | } | ||
| 1755 | 1755 | ||
| 1756 | pm_runtime_set_memalloc_noio(dev, true); | 1756 | pm_runtime_set_memalloc_noio(dev, true); |
| 1757 | 1757 | ||
| 1758 | return 0; | ||
| 1759 | |||
| 1760 | error_device_del: | ||
| 1761 | device_del(dev); | ||
| 1762 | error_put_device: | ||
| 1763 | put_device(dev); | ||
| 1758 | return error; | 1764 | return error; |
| 1759 | } | 1765 | } |
| 1760 | 1766 | ||
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index d5740bad5b18..57d84e9b7b6f 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
| @@ -436,8 +436,8 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk, | |||
| 436 | newnp->ipv6_mc_list = NULL; | 436 | newnp->ipv6_mc_list = NULL; |
| 437 | newnp->ipv6_ac_list = NULL; | 437 | newnp->ipv6_ac_list = NULL; |
| 438 | newnp->ipv6_fl_list = NULL; | 438 | newnp->ipv6_fl_list = NULL; |
| 439 | newnp->mcast_oif = inet6_iif(skb); | 439 | newnp->mcast_oif = inet_iif(skb); |
| 440 | newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; | 440 | newnp->mcast_hops = ip_hdr(skb)->ttl; |
| 441 | 441 | ||
| 442 | /* | 442 | /* |
| 443 | * No need to charge this sock to the relevant IPv6 refcnt debug socks count | 443 | * No need to charge this sock to the relevant IPv6 refcnt debug socks count |
diff --git a/net/ipv6/netfilter/ip6t_srh.c b/net/ipv6/netfilter/ip6t_srh.c index 1059894a6f4c..4cb83fb69844 100644 --- a/net/ipv6/netfilter/ip6t_srh.c +++ b/net/ipv6/netfilter/ip6t_srh.c | |||
| @@ -210,6 +210,8 @@ static bool srh1_mt6(const struct sk_buff *skb, struct xt_action_param *par) | |||
| 210 | psidoff = srhoff + sizeof(struct ipv6_sr_hdr) + | 210 | psidoff = srhoff + sizeof(struct ipv6_sr_hdr) + |
| 211 | ((srh->segments_left + 1) * sizeof(struct in6_addr)); | 211 | ((srh->segments_left + 1) * sizeof(struct in6_addr)); |
| 212 | psid = skb_header_pointer(skb, psidoff, sizeof(_psid), &_psid); | 212 | psid = skb_header_pointer(skb, psidoff, sizeof(_psid), &_psid); |
| 213 | if (!psid) | ||
| 214 | return false; | ||
| 213 | if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_PSID, | 215 | if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_PSID, |
| 214 | ipv6_masked_addr_cmp(psid, &srhinfo->psid_msk, | 216 | ipv6_masked_addr_cmp(psid, &srhinfo->psid_msk, |
| 215 | &srhinfo->psid_addr))) | 217 | &srhinfo->psid_addr))) |
| @@ -223,6 +225,8 @@ static bool srh1_mt6(const struct sk_buff *skb, struct xt_action_param *par) | |||
| 223 | nsidoff = srhoff + sizeof(struct ipv6_sr_hdr) + | 225 | nsidoff = srhoff + sizeof(struct ipv6_sr_hdr) + |
| 224 | ((srh->segments_left - 1) * sizeof(struct in6_addr)); | 226 | ((srh->segments_left - 1) * sizeof(struct in6_addr)); |
| 225 | nsid = skb_header_pointer(skb, nsidoff, sizeof(_nsid), &_nsid); | 227 | nsid = skb_header_pointer(skb, nsidoff, sizeof(_nsid), &_nsid); |
| 228 | if (!nsid) | ||
| 229 | return false; | ||
| 226 | if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_NSID, | 230 | if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_NSID, |
| 227 | ipv6_masked_addr_cmp(nsid, &srhinfo->nsid_msk, | 231 | ipv6_masked_addr_cmp(nsid, &srhinfo->nsid_msk, |
| 228 | &srhinfo->nsid_addr))) | 232 | &srhinfo->nsid_addr))) |
| @@ -233,6 +237,8 @@ static bool srh1_mt6(const struct sk_buff *skb, struct xt_action_param *par) | |||
| 233 | if (srhinfo->mt_flags & IP6T_SRH_LSID) { | 237 | if (srhinfo->mt_flags & IP6T_SRH_LSID) { |
| 234 | lsidoff = srhoff + sizeof(struct ipv6_sr_hdr); | 238 | lsidoff = srhoff + sizeof(struct ipv6_sr_hdr); |
| 235 | lsid = skb_header_pointer(skb, lsidoff, sizeof(_lsid), &_lsid); | 239 | lsid = skb_header_pointer(skb, lsidoff, sizeof(_lsid), &_lsid); |
| 240 | if (!lsid) | ||
| 241 | return false; | ||
| 236 | if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_LSID, | 242 | if (NF_SRH_INVF(srhinfo, IP6T_SRH_INV_LSID, |
| 237 | ipv6_masked_addr_cmp(lsid, &srhinfo->lsid_msk, | 243 | ipv6_masked_addr_cmp(lsid, &srhinfo->lsid_msk, |
| 238 | &srhinfo->lsid_addr))) | 244 | &srhinfo->lsid_addr))) |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 4ef4bbdb49d4..0302e0eb07af 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
| @@ -1040,14 +1040,20 @@ static struct rt6_info *ip6_create_rt_rcu(struct fib6_info *rt) | |||
| 1040 | struct rt6_info *nrt; | 1040 | struct rt6_info *nrt; |
| 1041 | 1041 | ||
| 1042 | if (!fib6_info_hold_safe(rt)) | 1042 | if (!fib6_info_hold_safe(rt)) |
| 1043 | return NULL; | 1043 | goto fallback; |
| 1044 | 1044 | ||
| 1045 | nrt = ip6_dst_alloc(dev_net(dev), dev, flags); | 1045 | nrt = ip6_dst_alloc(dev_net(dev), dev, flags); |
| 1046 | if (nrt) | 1046 | if (!nrt) { |
| 1047 | ip6_rt_copy_init(nrt, rt); | ||
| 1048 | else | ||
| 1049 | fib6_info_release(rt); | 1047 | fib6_info_release(rt); |
| 1048 | goto fallback; | ||
| 1049 | } | ||
| 1050 | 1050 | ||
| 1051 | ip6_rt_copy_init(nrt, rt); | ||
| 1052 | return nrt; | ||
| 1053 | |||
| 1054 | fallback: | ||
| 1055 | nrt = dev_net(dev)->ipv6.ip6_null_entry; | ||
| 1056 | dst_hold(&nrt->dst); | ||
| 1051 | return nrt; | 1057 | return nrt; |
| 1052 | } | 1058 | } |
| 1053 | 1059 | ||
| @@ -1096,10 +1102,6 @@ restart: | |||
| 1096 | dst_hold(&rt->dst); | 1102 | dst_hold(&rt->dst); |
| 1097 | } else { | 1103 | } else { |
| 1098 | rt = ip6_create_rt_rcu(f6i); | 1104 | rt = ip6_create_rt_rcu(f6i); |
| 1099 | if (!rt) { | ||
| 1100 | rt = net->ipv6.ip6_null_entry; | ||
| 1101 | dst_hold(&rt->dst); | ||
| 1102 | } | ||
| 1103 | } | 1105 | } |
| 1104 | 1106 | ||
| 1105 | rcu_read_unlock(); | 1107 | rcu_read_unlock(); |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 57ef69a10889..44d431849d39 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
| @@ -1110,11 +1110,11 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff * | |||
| 1110 | newnp->ipv6_fl_list = NULL; | 1110 | newnp->ipv6_fl_list = NULL; |
| 1111 | newnp->pktoptions = NULL; | 1111 | newnp->pktoptions = NULL; |
| 1112 | newnp->opt = NULL; | 1112 | newnp->opt = NULL; |
| 1113 | newnp->mcast_oif = tcp_v6_iif(skb); | 1113 | newnp->mcast_oif = inet_iif(skb); |
| 1114 | newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; | 1114 | newnp->mcast_hops = ip_hdr(skb)->ttl; |
| 1115 | newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb)); | 1115 | newnp->rcv_flowinfo = 0; |
| 1116 | if (np->repflow) | 1116 | if (np->repflow) |
| 1117 | newnp->flow_label = ip6_flowlabel(ipv6_hdr(skb)); | 1117 | newnp->flow_label = 0; |
| 1118 | 1118 | ||
| 1119 | /* | 1119 | /* |
| 1120 | * No need to charge this sock to the relevant IPv6 refcnt debug socks count | 1120 | * No need to charge this sock to the relevant IPv6 refcnt debug socks count |
diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c index dda8930f20e7..f3a8557494d6 100644 --- a/net/mpls/mpls_iptunnel.c +++ b/net/mpls/mpls_iptunnel.c | |||
| @@ -140,9 +140,15 @@ static int mpls_xmit(struct sk_buff *skb) | |||
| 140 | if (rt) | 140 | if (rt) |
| 141 | err = neigh_xmit(NEIGH_ARP_TABLE, out_dev, &rt->rt_gateway, | 141 | err = neigh_xmit(NEIGH_ARP_TABLE, out_dev, &rt->rt_gateway, |
| 142 | skb); | 142 | skb); |
| 143 | else if (rt6) | 143 | else if (rt6) { |
| 144 | err = neigh_xmit(NEIGH_ND_TABLE, out_dev, &rt6->rt6i_gateway, | 144 | if (ipv6_addr_v4mapped(&rt6->rt6i_gateway)) { |
| 145 | skb); | 145 | /* 6PE (RFC 4798) */ |
| 146 | err = neigh_xmit(NEIGH_ARP_TABLE, out_dev, &rt6->rt6i_gateway.s6_addr32[3], | ||
| 147 | skb); | ||
| 148 | } else | ||
| 149 | err = neigh_xmit(NEIGH_ND_TABLE, out_dev, &rt6->rt6i_gateway, | ||
| 150 | skb); | ||
| 151 | } | ||
| 146 | if (err) | 152 | if (err) |
| 147 | net_dbg_ratelimited("%s: packet transmission failed: %d\n", | 153 | net_dbg_ratelimited("%s: packet transmission failed: %d\n", |
| 148 | __func__, err); | 154 | __func__, err); |
diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c index 5d782445d2fc..bad17bba8ba7 100644 --- a/net/ncsi/ncsi-netlink.c +++ b/net/ncsi/ncsi-netlink.c | |||
| @@ -251,6 +251,10 @@ static int ncsi_pkg_info_all_nl(struct sk_buff *skb, | |||
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | attr = nla_nest_start(skb, NCSI_ATTR_PACKAGE_LIST); | 253 | attr = nla_nest_start(skb, NCSI_ATTR_PACKAGE_LIST); |
| 254 | if (!attr) { | ||
| 255 | rc = -EMSGSIZE; | ||
| 256 | goto err; | ||
| 257 | } | ||
| 254 | rc = ncsi_write_package_info(skb, ndp, package->id); | 258 | rc = ncsi_write_package_info(skb, ndp, package->id); |
| 255 | if (rc) { | 259 | if (rc) { |
| 256 | nla_nest_cancel(skb, attr); | 260 | nla_nest_cancel(skb, attr); |
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index d43ffb09939b..6548271209a0 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig | |||
| @@ -1007,6 +1007,7 @@ config NETFILTER_XT_TARGET_TEE | |||
| 1007 | depends on NETFILTER_ADVANCED | 1007 | depends on NETFILTER_ADVANCED |
| 1008 | depends on IPV6 || IPV6=n | 1008 | depends on IPV6 || IPV6=n |
| 1009 | depends on !NF_CONNTRACK || NF_CONNTRACK | 1009 | depends on !NF_CONNTRACK || NF_CONNTRACK |
| 1010 | depends on IP6_NF_IPTABLES || !IP6_NF_IPTABLES | ||
| 1010 | select NF_DUP_IPV4 | 1011 | select NF_DUP_IPV4 |
| 1011 | select NF_DUP_IPV6 if IP6_NF_IPTABLES | 1012 | select NF_DUP_IPV6 if IP6_NF_IPTABLES |
| 1012 | ---help--- | 1013 | ---help--- |
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index f067c6b50857..39fcc1ed18f3 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c | |||
| @@ -20,9 +20,9 @@ | |||
| 20 | #include <linux/udp.h> | 20 | #include <linux/udp.h> |
| 21 | #include <linux/tcp.h> | 21 | #include <linux/tcp.h> |
| 22 | #include <linux/netfilter.h> | 22 | #include <linux/netfilter.h> |
| 23 | #include <linux/netfilter_ipv4.h> | ||
| 24 | #include <linux/netfilter_ipv6.h> | ||
| 23 | 25 | ||
| 24 | #include <net/route.h> | ||
| 25 | #include <net/ip6_route.h> | ||
| 26 | #include <net/netfilter/nf_conntrack.h> | 26 | #include <net/netfilter/nf_conntrack.h> |
| 27 | #include <net/netfilter/nf_conntrack_core.h> | 27 | #include <net/netfilter/nf_conntrack_core.h> |
| 28 | #include <net/netfilter/nf_conntrack_expect.h> | 28 | #include <net/netfilter/nf_conntrack_expect.h> |
| @@ -871,38 +871,33 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff, | |||
| 871 | } else if (sip_external_media) { | 871 | } else if (sip_external_media) { |
| 872 | struct net_device *dev = skb_dst(skb)->dev; | 872 | struct net_device *dev = skb_dst(skb)->dev; |
| 873 | struct net *net = dev_net(dev); | 873 | struct net *net = dev_net(dev); |
| 874 | struct rtable *rt; | 874 | struct flowi fl; |
| 875 | struct flowi4 fl4 = {}; | ||
| 876 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 877 | struct flowi6 fl6 = {}; | ||
| 878 | #endif | ||
| 879 | struct dst_entry *dst = NULL; | 875 | struct dst_entry *dst = NULL; |
| 880 | 876 | ||
| 877 | memset(&fl, 0, sizeof(fl)); | ||
| 878 | |||
| 881 | switch (nf_ct_l3num(ct)) { | 879 | switch (nf_ct_l3num(ct)) { |
| 882 | case NFPROTO_IPV4: | 880 | case NFPROTO_IPV4: |
| 883 | fl4.daddr = daddr->ip; | 881 | fl.u.ip4.daddr = daddr->ip; |
| 884 | rt = ip_route_output_key(net, &fl4); | 882 | nf_ip_route(net, &dst, &fl, false); |
| 885 | if (!IS_ERR(rt)) | ||
| 886 | dst = &rt->dst; | ||
| 887 | break; | 883 | break; |
| 888 | 884 | ||
| 889 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 890 | case NFPROTO_IPV6: | 885 | case NFPROTO_IPV6: |
| 891 | fl6.daddr = daddr->in6; | 886 | fl.u.ip6.daddr = daddr->in6; |
| 892 | dst = ip6_route_output(net, NULL, &fl6); | 887 | nf_ip6_route(net, &dst, &fl, false); |
| 893 | if (dst->error) { | ||
| 894 | dst_release(dst); | ||
| 895 | dst = NULL; | ||
| 896 | } | ||
| 897 | break; | 888 | break; |
| 898 | #endif | ||
| 899 | } | 889 | } |
| 900 | 890 | ||
| 901 | /* Don't predict any conntracks when media endpoint is reachable | 891 | /* Don't predict any conntracks when media endpoint is reachable |
| 902 | * through the same interface as the signalling peer. | 892 | * through the same interface as the signalling peer. |
| 903 | */ | 893 | */ |
| 904 | if (dst && dst->dev == dev) | 894 | if (dst) { |
| 905 | return NF_ACCEPT; | 895 | bool external_media = (dst->dev == dev); |
| 896 | |||
| 897 | dst_release(dst); | ||
| 898 | if (external_media) | ||
| 899 | return NF_ACCEPT; | ||
| 900 | } | ||
| 906 | } | 901 | } |
| 907 | 902 | ||
| 908 | /* We need to check whether the registration exists before attempting | 903 | /* We need to check whether the registration exists before attempting |
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 513f93118604..ef7772e976cc 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c | |||
| @@ -2806,8 +2806,11 @@ err2: | |||
| 2806 | nf_tables_rule_release(&ctx, rule); | 2806 | nf_tables_rule_release(&ctx, rule); |
| 2807 | err1: | 2807 | err1: |
| 2808 | for (i = 0; i < n; i++) { | 2808 | for (i = 0; i < n; i++) { |
| 2809 | if (info[i].ops != NULL) | 2809 | if (info[i].ops) { |
| 2810 | module_put(info[i].ops->type->owner); | 2810 | module_put(info[i].ops->type->owner); |
| 2811 | if (info[i].ops->type->release_ops) | ||
| 2812 | info[i].ops->type->release_ops(info[i].ops); | ||
| 2813 | } | ||
| 2811 | } | 2814 | } |
| 2812 | kvfree(info); | 2815 | kvfree(info); |
| 2813 | return err; | 2816 | return err; |
diff --git a/net/netfilter/nft_objref.c b/net/netfilter/nft_objref.c index 457a9ceb46af..8dfa798ea683 100644 --- a/net/netfilter/nft_objref.c +++ b/net/netfilter/nft_objref.c | |||
| @@ -65,21 +65,34 @@ nla_put_failure: | |||
| 65 | return -1; | 65 | return -1; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | static void nft_objref_destroy(const struct nft_ctx *ctx, | 68 | static void nft_objref_deactivate(const struct nft_ctx *ctx, |
| 69 | const struct nft_expr *expr) | 69 | const struct nft_expr *expr, |
| 70 | enum nft_trans_phase phase) | ||
| 70 | { | 71 | { |
| 71 | struct nft_object *obj = nft_objref_priv(expr); | 72 | struct nft_object *obj = nft_objref_priv(expr); |
| 72 | 73 | ||
| 74 | if (phase == NFT_TRANS_COMMIT) | ||
| 75 | return; | ||
| 76 | |||
| 73 | obj->use--; | 77 | obj->use--; |
| 74 | } | 78 | } |
| 75 | 79 | ||
| 80 | static void nft_objref_activate(const struct nft_ctx *ctx, | ||
| 81 | const struct nft_expr *expr) | ||
| 82 | { | ||
| 83 | struct nft_object *obj = nft_objref_priv(expr); | ||
| 84 | |||
| 85 | obj->use++; | ||
| 86 | } | ||
| 87 | |||
| 76 | static struct nft_expr_type nft_objref_type; | 88 | static struct nft_expr_type nft_objref_type; |
| 77 | static const struct nft_expr_ops nft_objref_ops = { | 89 | static const struct nft_expr_ops nft_objref_ops = { |
| 78 | .type = &nft_objref_type, | 90 | .type = &nft_objref_type, |
| 79 | .size = NFT_EXPR_SIZE(sizeof(struct nft_object *)), | 91 | .size = NFT_EXPR_SIZE(sizeof(struct nft_object *)), |
| 80 | .eval = nft_objref_eval, | 92 | .eval = nft_objref_eval, |
| 81 | .init = nft_objref_init, | 93 | .init = nft_objref_init, |
| 82 | .destroy = nft_objref_destroy, | 94 | .activate = nft_objref_activate, |
| 95 | .deactivate = nft_objref_deactivate, | ||
| 83 | .dump = nft_objref_dump, | 96 | .dump = nft_objref_dump, |
| 84 | }; | 97 | }; |
| 85 | 98 | ||
diff --git a/net/netfilter/nft_redir.c b/net/netfilter/nft_redir.c index f8092926f704..a340cd8a751b 100644 --- a/net/netfilter/nft_redir.c +++ b/net/netfilter/nft_redir.c | |||
| @@ -233,5 +233,5 @@ module_exit(nft_redir_module_exit); | |||
| 233 | 233 | ||
| 234 | MODULE_LICENSE("GPL"); | 234 | MODULE_LICENSE("GPL"); |
| 235 | MODULE_AUTHOR("Arturo Borrero Gonzalez <arturo@debian.org>"); | 235 | MODULE_AUTHOR("Arturo Borrero Gonzalez <arturo@debian.org>"); |
| 236 | MODULE_ALIAS_NFT_AF_EXPR(AF_INET4, "redir"); | 236 | MODULE_ALIAS_NFT_AF_EXPR(AF_INET, "redir"); |
| 237 | MODULE_ALIAS_NFT_AF_EXPR(AF_INET6, "redir"); | 237 | MODULE_ALIAS_NFT_AF_EXPR(AF_INET6, "redir"); |
diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c index fa61208371f8..321a0036fdf5 100644 --- a/net/netfilter/nft_set_rbtree.c +++ b/net/netfilter/nft_set_rbtree.c | |||
| @@ -308,10 +308,6 @@ static void *nft_rbtree_deactivate(const struct net *net, | |||
| 308 | else if (d > 0) | 308 | else if (d > 0) |
| 309 | parent = parent->rb_right; | 309 | parent = parent->rb_right; |
| 310 | else { | 310 | else { |
| 311 | if (!nft_set_elem_active(&rbe->ext, genmask)) { | ||
| 312 | parent = parent->rb_left; | ||
| 313 | continue; | ||
| 314 | } | ||
| 315 | if (nft_rbtree_interval_end(rbe) && | 311 | if (nft_rbtree_interval_end(rbe) && |
| 316 | !nft_rbtree_interval_end(this)) { | 312 | !nft_rbtree_interval_end(this)) { |
| 317 | parent = parent->rb_left; | 313 | parent = parent->rb_left; |
| @@ -320,6 +316,9 @@ static void *nft_rbtree_deactivate(const struct net *net, | |||
| 320 | nft_rbtree_interval_end(this)) { | 316 | nft_rbtree_interval_end(this)) { |
| 321 | parent = parent->rb_right; | 317 | parent = parent->rb_right; |
| 322 | continue; | 318 | continue; |
| 319 | } else if (!nft_set_elem_active(&rbe->ext, genmask)) { | ||
| 320 | parent = parent->rb_left; | ||
| 321 | continue; | ||
| 323 | } | 322 | } |
| 324 | nft_rbtree_flush(net, set, rbe); | 323 | nft_rbtree_flush(net, set, rbe); |
| 325 | return rbe; | 324 | return rbe; |
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 25eeb6d2a75a..f0ec068e1d02 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
| @@ -366,7 +366,7 @@ int genl_register_family(struct genl_family *family) | |||
| 366 | start, end + 1, GFP_KERNEL); | 366 | start, end + 1, GFP_KERNEL); |
| 367 | if (family->id < 0) { | 367 | if (family->id < 0) { |
| 368 | err = family->id; | 368 | err = family->id; |
| 369 | goto errout_locked; | 369 | goto errout_free; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | err = genl_validate_assign_mc_groups(family); | 372 | err = genl_validate_assign_mc_groups(family); |
| @@ -385,6 +385,7 @@ int genl_register_family(struct genl_family *family) | |||
| 385 | 385 | ||
| 386 | errout_remove: | 386 | errout_remove: |
| 387 | idr_remove(&genl_fam_idr, family->id); | 387 | idr_remove(&genl_fam_idr, family->id); |
| 388 | errout_free: | ||
| 388 | kfree(family->attrbuf); | 389 | kfree(family->attrbuf); |
| 389 | errout_locked: | 390 | errout_locked: |
| 390 | genl_unlock_all(); | 391 | genl_unlock_all(); |
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index ae296273ce3d..17dcd0b5eb32 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c | |||
| @@ -726,6 +726,10 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, | |||
| 726 | llcp_sock->service_name = kmemdup(addr->service_name, | 726 | llcp_sock->service_name = kmemdup(addr->service_name, |
| 727 | llcp_sock->service_name_len, | 727 | llcp_sock->service_name_len, |
| 728 | GFP_KERNEL); | 728 | GFP_KERNEL); |
| 729 | if (!llcp_sock->service_name) { | ||
| 730 | ret = -ENOMEM; | ||
| 731 | goto sock_llcp_release; | ||
| 732 | } | ||
| 729 | 733 | ||
| 730 | nfc_llcp_sock_link(&local->connecting_sockets, sk); | 734 | nfc_llcp_sock_link(&local->connecting_sockets, sk); |
| 731 | 735 | ||
| @@ -745,10 +749,11 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, | |||
| 745 | return ret; | 749 | return ret; |
| 746 | 750 | ||
| 747 | sock_unlink: | 751 | sock_unlink: |
| 748 | nfc_llcp_put_ssap(local, llcp_sock->ssap); | ||
| 749 | |||
| 750 | nfc_llcp_sock_unlink(&local->connecting_sockets, sk); | 752 | nfc_llcp_sock_unlink(&local->connecting_sockets, sk); |
| 751 | 753 | ||
| 754 | sock_llcp_release: | ||
| 755 | nfc_llcp_put_ssap(local, llcp_sock->ssap); | ||
| 756 | |||
| 752 | put_dev: | 757 | put_dev: |
| 753 | nfc_put_device(dev); | 758 | nfc_put_device(dev); |
| 754 | 759 | ||
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 6679e96ab1dc..9dd158ab51b3 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
| @@ -448,6 +448,10 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, | |||
| 448 | 448 | ||
| 449 | upcall = genlmsg_put(user_skb, 0, 0, &dp_packet_genl_family, | 449 | upcall = genlmsg_put(user_skb, 0, 0, &dp_packet_genl_family, |
| 450 | 0, upcall_info->cmd); | 450 | 0, upcall_info->cmd); |
| 451 | if (!upcall) { | ||
| 452 | err = -EINVAL; | ||
| 453 | goto out; | ||
| 454 | } | ||
| 451 | upcall->dp_ifindex = dp_ifindex; | 455 | upcall->dp_ifindex = dp_ifindex; |
| 452 | 456 | ||
| 453 | err = ovs_nla_put_key(key, key, OVS_PACKET_ATTR_KEY, false, user_skb); | 457 | err = ovs_nla_put_key(key, key, OVS_PACKET_ATTR_KEY, false, user_skb); |
| @@ -460,6 +464,10 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, | |||
| 460 | 464 | ||
| 461 | if (upcall_info->egress_tun_info) { | 465 | if (upcall_info->egress_tun_info) { |
| 462 | nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_EGRESS_TUN_KEY); | 466 | nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_EGRESS_TUN_KEY); |
| 467 | if (!nla) { | ||
| 468 | err = -EMSGSIZE; | ||
| 469 | goto out; | ||
| 470 | } | ||
| 463 | err = ovs_nla_put_tunnel_info(user_skb, | 471 | err = ovs_nla_put_tunnel_info(user_skb, |
| 464 | upcall_info->egress_tun_info); | 472 | upcall_info->egress_tun_info); |
| 465 | BUG_ON(err); | 473 | BUG_ON(err); |
| @@ -468,6 +476,10 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, | |||
| 468 | 476 | ||
| 469 | if (upcall_info->actions_len) { | 477 | if (upcall_info->actions_len) { |
| 470 | nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_ACTIONS); | 478 | nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_ACTIONS); |
| 479 | if (!nla) { | ||
| 480 | err = -EMSGSIZE; | ||
| 481 | goto out; | ||
| 482 | } | ||
| 471 | err = ovs_nla_put_actions(upcall_info->actions, | 483 | err = ovs_nla_put_actions(upcall_info->actions, |
| 472 | upcall_info->actions_len, | 484 | upcall_info->actions_len, |
| 473 | user_skb); | 485 | user_skb); |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 8376bc1c1508..9419c5cf4de5 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
| @@ -1852,7 +1852,8 @@ oom: | |||
| 1852 | 1852 | ||
| 1853 | static void packet_parse_headers(struct sk_buff *skb, struct socket *sock) | 1853 | static void packet_parse_headers(struct sk_buff *skb, struct socket *sock) |
| 1854 | { | 1854 | { |
| 1855 | if (!skb->protocol && sock->type == SOCK_RAW) { | 1855 | if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) && |
| 1856 | sock->type == SOCK_RAW) { | ||
| 1856 | skb_reset_mac_header(skb); | 1857 | skb_reset_mac_header(skb); |
| 1857 | skb->protocol = dev_parse_header_protocol(skb); | 1858 | skb->protocol = dev_parse_header_protocol(skb); |
| 1858 | } | 1859 | } |
| @@ -3243,7 +3244,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol, | |||
| 3243 | } | 3244 | } |
| 3244 | 3245 | ||
| 3245 | mutex_lock(&net->packet.sklist_lock); | 3246 | mutex_lock(&net->packet.sklist_lock); |
| 3246 | sk_add_node_rcu(sk, &net->packet.sklist); | 3247 | sk_add_node_tail_rcu(sk, &net->packet.sklist); |
| 3247 | mutex_unlock(&net->packet.sklist_lock); | 3248 | mutex_unlock(&net->packet.sklist_lock); |
| 3248 | 3249 | ||
| 3249 | preempt_disable(); | 3250 | preempt_disable(); |
| @@ -4209,7 +4210,7 @@ static struct pgv *alloc_pg_vec(struct tpacket_req *req, int order) | |||
| 4209 | struct pgv *pg_vec; | 4210 | struct pgv *pg_vec; |
| 4210 | int i; | 4211 | int i; |
| 4211 | 4212 | ||
| 4212 | pg_vec = kcalloc(block_nr, sizeof(struct pgv), GFP_KERNEL); | 4213 | pg_vec = kcalloc(block_nr, sizeof(struct pgv), GFP_KERNEL | __GFP_NOWARN); |
| 4213 | if (unlikely(!pg_vec)) | 4214 | if (unlikely(!pg_vec)) |
| 4214 | goto out; | 4215 | goto out; |
| 4215 | 4216 | ||
diff --git a/net/rose/rose_subr.c b/net/rose/rose_subr.c index 7ca57741b2fb..7849f286bb93 100644 --- a/net/rose/rose_subr.c +++ b/net/rose/rose_subr.c | |||
| @@ -105,16 +105,17 @@ void rose_write_internal(struct sock *sk, int frametype) | |||
| 105 | struct sk_buff *skb; | 105 | struct sk_buff *skb; |
| 106 | unsigned char *dptr; | 106 | unsigned char *dptr; |
| 107 | unsigned char lci1, lci2; | 107 | unsigned char lci1, lci2; |
| 108 | char buffer[100]; | 108 | int maxfaclen = 0; |
| 109 | int len, faclen = 0; | 109 | int len, faclen; |
| 110 | int reserve; | ||
| 110 | 111 | ||
| 111 | len = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN + 1; | 112 | reserve = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + 1; |
| 113 | len = ROSE_MIN_LEN; | ||
| 112 | 114 | ||
| 113 | switch (frametype) { | 115 | switch (frametype) { |
| 114 | case ROSE_CALL_REQUEST: | 116 | case ROSE_CALL_REQUEST: |
| 115 | len += 1 + ROSE_ADDR_LEN + ROSE_ADDR_LEN; | 117 | len += 1 + ROSE_ADDR_LEN + ROSE_ADDR_LEN; |
| 116 | faclen = rose_create_facilities(buffer, rose); | 118 | maxfaclen = 256; |
| 117 | len += faclen; | ||
| 118 | break; | 119 | break; |
| 119 | case ROSE_CALL_ACCEPTED: | 120 | case ROSE_CALL_ACCEPTED: |
| 120 | case ROSE_CLEAR_REQUEST: | 121 | case ROSE_CLEAR_REQUEST: |
| @@ -123,15 +124,16 @@ void rose_write_internal(struct sock *sk, int frametype) | |||
| 123 | break; | 124 | break; |
| 124 | } | 125 | } |
| 125 | 126 | ||
| 126 | if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL) | 127 | skb = alloc_skb(reserve + len + maxfaclen, GFP_ATOMIC); |
| 128 | if (!skb) | ||
| 127 | return; | 129 | return; |
| 128 | 130 | ||
| 129 | /* | 131 | /* |
| 130 | * Space for AX.25 header and PID. | 132 | * Space for AX.25 header and PID. |
| 131 | */ | 133 | */ |
| 132 | skb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + 1); | 134 | skb_reserve(skb, reserve); |
| 133 | 135 | ||
| 134 | dptr = skb_put(skb, skb_tailroom(skb)); | 136 | dptr = skb_put(skb, len); |
| 135 | 137 | ||
| 136 | lci1 = (rose->lci >> 8) & 0x0F; | 138 | lci1 = (rose->lci >> 8) & 0x0F; |
| 137 | lci2 = (rose->lci >> 0) & 0xFF; | 139 | lci2 = (rose->lci >> 0) & 0xFF; |
| @@ -146,7 +148,8 @@ void rose_write_internal(struct sock *sk, int frametype) | |||
| 146 | dptr += ROSE_ADDR_LEN; | 148 | dptr += ROSE_ADDR_LEN; |
| 147 | memcpy(dptr, &rose->source_addr, ROSE_ADDR_LEN); | 149 | memcpy(dptr, &rose->source_addr, ROSE_ADDR_LEN); |
| 148 | dptr += ROSE_ADDR_LEN; | 150 | dptr += ROSE_ADDR_LEN; |
| 149 | memcpy(dptr, buffer, faclen); | 151 | faclen = rose_create_facilities(dptr, rose); |
| 152 | skb_put(skb, faclen); | ||
| 150 | dptr += faclen; | 153 | dptr += faclen; |
| 151 | break; | 154 | break; |
| 152 | 155 | ||
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c index 736aa9281100..004c762c2e8d 100644 --- a/net/rxrpc/output.c +++ b/net/rxrpc/output.c | |||
| @@ -335,7 +335,6 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb, | |||
| 335 | struct kvec iov[2]; | 335 | struct kvec iov[2]; |
| 336 | rxrpc_serial_t serial; | 336 | rxrpc_serial_t serial; |
| 337 | size_t len; | 337 | size_t len; |
| 338 | bool lost = false; | ||
| 339 | int ret, opt; | 338 | int ret, opt; |
| 340 | 339 | ||
| 341 | _enter(",{%d}", skb->len); | 340 | _enter(",{%d}", skb->len); |
| @@ -393,14 +392,14 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb, | |||
| 393 | static int lose; | 392 | static int lose; |
| 394 | if ((lose++ & 7) == 7) { | 393 | if ((lose++ & 7) == 7) { |
| 395 | ret = 0; | 394 | ret = 0; |
| 396 | lost = true; | 395 | trace_rxrpc_tx_data(call, sp->hdr.seq, serial, |
| 396 | whdr.flags, retrans, true); | ||
| 397 | goto done; | ||
| 397 | } | 398 | } |
| 398 | } | 399 | } |
| 399 | 400 | ||
| 400 | trace_rxrpc_tx_data(call, sp->hdr.seq, serial, whdr.flags, | 401 | trace_rxrpc_tx_data(call, sp->hdr.seq, serial, whdr.flags, retrans, |
| 401 | retrans, lost); | 402 | false); |
| 402 | if (lost) | ||
| 403 | goto done; | ||
| 404 | 403 | ||
| 405 | /* send the packet with the don't fragment bit set if we currently | 404 | /* send the packet with the don't fragment bit set if we currently |
| 406 | * think it's small enough */ | 405 | * think it's small enough */ |
diff --git a/net/sched/Kconfig b/net/sched/Kconfig index 1b9afdee5ba9..5c02ad97ef23 100644 --- a/net/sched/Kconfig +++ b/net/sched/Kconfig | |||
| @@ -358,8 +358,7 @@ config NET_SCH_PIE | |||
| 358 | help | 358 | help |
| 359 | Say Y here if you want to use the Proportional Integral controller | 359 | Say Y here if you want to use the Proportional Integral controller |
| 360 | Enhanced scheduler packet scheduling algorithm. | 360 | Enhanced scheduler packet scheduling algorithm. |
| 361 | For more information, please see | 361 | For more information, please see https://tools.ietf.org/html/rfc8033 |
| 362 | http://tools.ietf.org/html/draft-pan-tsvwg-pie-00 | ||
| 363 | 362 | ||
| 364 | To compile this driver as a module, choose M here: the module | 363 | To compile this driver as a module, choose M here: the module |
| 365 | will be called sch_pie. | 364 | will be called sch_pie. |
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index aecf1bf233c8..5a87e271d35a 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
| @@ -28,27 +28,10 @@ | |||
| 28 | #include <net/act_api.h> | 28 | #include <net/act_api.h> |
| 29 | #include <net/netlink.h> | 29 | #include <net/netlink.h> |
| 30 | 30 | ||
| 31 | static int tcf_action_goto_chain_init(struct tc_action *a, struct tcf_proto *tp) | ||
| 32 | { | ||
| 33 | u32 chain_index = a->tcfa_action & TC_ACT_EXT_VAL_MASK; | ||
| 34 | |||
| 35 | if (!tp) | ||
| 36 | return -EINVAL; | ||
| 37 | a->goto_chain = tcf_chain_get_by_act(tp->chain->block, chain_index); | ||
| 38 | if (!a->goto_chain) | ||
| 39 | return -ENOMEM; | ||
| 40 | return 0; | ||
| 41 | } | ||
| 42 | |||
| 43 | static void tcf_action_goto_chain_fini(struct tc_action *a) | ||
| 44 | { | ||
| 45 | tcf_chain_put_by_act(a->goto_chain); | ||
| 46 | } | ||
| 47 | |||
| 48 | static void tcf_action_goto_chain_exec(const struct tc_action *a, | 31 | static void tcf_action_goto_chain_exec(const struct tc_action *a, |
| 49 | struct tcf_result *res) | 32 | struct tcf_result *res) |
| 50 | { | 33 | { |
| 51 | const struct tcf_chain *chain = a->goto_chain; | 34 | const struct tcf_chain *chain = rcu_dereference_bh(a->goto_chain); |
| 52 | 35 | ||
| 53 | res->goto_tp = rcu_dereference_bh(chain->filter_chain); | 36 | res->goto_tp = rcu_dereference_bh(chain->filter_chain); |
| 54 | } | 37 | } |
| @@ -71,6 +54,51 @@ static void tcf_set_action_cookie(struct tc_cookie __rcu **old_cookie, | |||
| 71 | call_rcu(&old->rcu, tcf_free_cookie_rcu); | 54 | call_rcu(&old->rcu, tcf_free_cookie_rcu); |
| 72 | } | 55 | } |
| 73 | 56 | ||
| 57 | int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, | ||
| 58 | struct tcf_chain **newchain, | ||
| 59 | struct netlink_ext_ack *extack) | ||
| 60 | { | ||
| 61 | int opcode = TC_ACT_EXT_OPCODE(action), ret = -EINVAL; | ||
| 62 | u32 chain_index; | ||
| 63 | |||
| 64 | if (!opcode) | ||
| 65 | ret = action > TC_ACT_VALUE_MAX ? -EINVAL : 0; | ||
| 66 | else if (opcode <= TC_ACT_EXT_OPCODE_MAX || action == TC_ACT_UNSPEC) | ||
| 67 | ret = 0; | ||
| 68 | if (ret) { | ||
| 69 | NL_SET_ERR_MSG(extack, "invalid control action"); | ||
| 70 | goto end; | ||
| 71 | } | ||
| 72 | |||
| 73 | if (TC_ACT_EXT_CMP(action, TC_ACT_GOTO_CHAIN)) { | ||
| 74 | chain_index = action & TC_ACT_EXT_VAL_MASK; | ||
| 75 | if (!tp || !newchain) { | ||
| 76 | ret = -EINVAL; | ||
| 77 | NL_SET_ERR_MSG(extack, | ||
| 78 | "can't goto NULL proto/chain"); | ||
| 79 | goto end; | ||
| 80 | } | ||
| 81 | *newchain = tcf_chain_get_by_act(tp->chain->block, chain_index); | ||
| 82 | if (!*newchain) { | ||
| 83 | ret = -ENOMEM; | ||
| 84 | NL_SET_ERR_MSG(extack, | ||
| 85 | "can't allocate goto_chain"); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | end: | ||
| 89 | return ret; | ||
| 90 | } | ||
| 91 | EXPORT_SYMBOL(tcf_action_check_ctrlact); | ||
| 92 | |||
| 93 | struct tcf_chain *tcf_action_set_ctrlact(struct tc_action *a, int action, | ||
| 94 | struct tcf_chain *goto_chain) | ||
| 95 | { | ||
| 96 | a->tcfa_action = action; | ||
| 97 | rcu_swap_protected(a->goto_chain, goto_chain, 1); | ||
| 98 | return goto_chain; | ||
| 99 | } | ||
| 100 | EXPORT_SYMBOL(tcf_action_set_ctrlact); | ||
| 101 | |||
| 74 | /* XXX: For standalone actions, we don't need a RCU grace period either, because | 102 | /* XXX: For standalone actions, we don't need a RCU grace period either, because |
| 75 | * actions are always connected to filters and filters are already destroyed in | 103 | * actions are always connected to filters and filters are already destroyed in |
| 76 | * RCU callbacks, so after a RCU grace period actions are already disconnected | 104 | * RCU callbacks, so after a RCU grace period actions are already disconnected |
| @@ -78,13 +106,15 @@ static void tcf_set_action_cookie(struct tc_cookie __rcu **old_cookie, | |||
| 78 | */ | 106 | */ |
| 79 | static void free_tcf(struct tc_action *p) | 107 | static void free_tcf(struct tc_action *p) |
| 80 | { | 108 | { |
| 109 | struct tcf_chain *chain = rcu_dereference_protected(p->goto_chain, 1); | ||
| 110 | |||
| 81 | free_percpu(p->cpu_bstats); | 111 | free_percpu(p->cpu_bstats); |
| 82 | free_percpu(p->cpu_bstats_hw); | 112 | free_percpu(p->cpu_bstats_hw); |
| 83 | free_percpu(p->cpu_qstats); | 113 | free_percpu(p->cpu_qstats); |
| 84 | 114 | ||
| 85 | tcf_set_action_cookie(&p->act_cookie, NULL); | 115 | tcf_set_action_cookie(&p->act_cookie, NULL); |
| 86 | if (p->goto_chain) | 116 | if (chain) |
| 87 | tcf_action_goto_chain_fini(p); | 117 | tcf_chain_put_by_act(chain); |
| 88 | 118 | ||
| 89 | kfree(p); | 119 | kfree(p); |
| 90 | } | 120 | } |
| @@ -654,6 +684,10 @@ repeat: | |||
| 654 | return TC_ACT_OK; | 684 | return TC_ACT_OK; |
| 655 | } | 685 | } |
| 656 | } else if (TC_ACT_EXT_CMP(ret, TC_ACT_GOTO_CHAIN)) { | 686 | } else if (TC_ACT_EXT_CMP(ret, TC_ACT_GOTO_CHAIN)) { |
| 687 | if (unlikely(!rcu_access_pointer(a->goto_chain))) { | ||
| 688 | net_warn_ratelimited("can't go to NULL chain!\n"); | ||
| 689 | return TC_ACT_SHOT; | ||
| 690 | } | ||
| 657 | tcf_action_goto_chain_exec(a, res); | 691 | tcf_action_goto_chain_exec(a, res); |
| 658 | } | 692 | } |
| 659 | 693 | ||
| @@ -800,15 +834,6 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb) | |||
| 800 | return c; | 834 | return c; |
| 801 | } | 835 | } |
| 802 | 836 | ||
| 803 | static bool tcf_action_valid(int action) | ||
| 804 | { | ||
| 805 | int opcode = TC_ACT_EXT_OPCODE(action); | ||
| 806 | |||
| 807 | if (!opcode) | ||
| 808 | return action <= TC_ACT_VALUE_MAX; | ||
| 809 | return opcode <= TC_ACT_EXT_OPCODE_MAX || action == TC_ACT_UNSPEC; | ||
| 810 | } | ||
| 811 | |||
| 812 | struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, | 837 | struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, |
| 813 | struct nlattr *nla, struct nlattr *est, | 838 | struct nlattr *nla, struct nlattr *est, |
| 814 | char *name, int ovr, int bind, | 839 | char *name, int ovr, int bind, |
| @@ -890,10 +915,10 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, | |||
| 890 | /* backward compatibility for policer */ | 915 | /* backward compatibility for policer */ |
| 891 | if (name == NULL) | 916 | if (name == NULL) |
| 892 | err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, &a, ovr, bind, | 917 | err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, &a, ovr, bind, |
| 893 | rtnl_held, extack); | 918 | rtnl_held, tp, extack); |
| 894 | else | 919 | else |
| 895 | err = a_o->init(net, nla, est, &a, ovr, bind, rtnl_held, | 920 | err = a_o->init(net, nla, est, &a, ovr, bind, rtnl_held, |
| 896 | extack); | 921 | tp, extack); |
| 897 | if (err < 0) | 922 | if (err < 0) |
| 898 | goto err_mod; | 923 | goto err_mod; |
| 899 | 924 | ||
| @@ -907,18 +932,10 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, | |||
| 907 | if (err != ACT_P_CREATED) | 932 | if (err != ACT_P_CREATED) |
| 908 | module_put(a_o->owner); | 933 | module_put(a_o->owner); |
| 909 | 934 | ||
| 910 | if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN)) { | 935 | if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN) && |
| 911 | err = tcf_action_goto_chain_init(a, tp); | 936 | !rcu_access_pointer(a->goto_chain)) { |
| 912 | if (err) { | ||
| 913 | tcf_action_destroy_1(a, bind); | ||
| 914 | NL_SET_ERR_MSG(extack, "Failed to init TC action chain"); | ||
| 915 | return ERR_PTR(err); | ||
| 916 | } | ||
| 917 | } | ||
| 918 | |||
| 919 | if (!tcf_action_valid(a->tcfa_action)) { | ||
| 920 | tcf_action_destroy_1(a, bind); | 937 | tcf_action_destroy_1(a, bind); |
| 921 | NL_SET_ERR_MSG(extack, "Invalid control action value"); | 938 | NL_SET_ERR_MSG(extack, "can't use goto chain with NULL chain"); |
| 922 | return ERR_PTR(-EINVAL); | 939 | return ERR_PTR(-EINVAL); |
| 923 | } | 940 | } |
| 924 | 941 | ||
diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index aa5c38d11a30..3841156aa09f 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #include <net/netlink.h> | 18 | #include <net/netlink.h> |
| 19 | #include <net/pkt_sched.h> | 19 | #include <net/pkt_sched.h> |
| 20 | #include <net/pkt_cls.h> | ||
| 20 | 21 | ||
| 21 | #include <linux/tc_act/tc_bpf.h> | 22 | #include <linux/tc_act/tc_bpf.h> |
| 22 | #include <net/tc_act/tc_bpf.h> | 23 | #include <net/tc_act/tc_bpf.h> |
| @@ -278,10 +279,11 @@ static void tcf_bpf_prog_fill_cfg(const struct tcf_bpf *prog, | |||
| 278 | static int tcf_bpf_init(struct net *net, struct nlattr *nla, | 279 | static int tcf_bpf_init(struct net *net, struct nlattr *nla, |
| 279 | struct nlattr *est, struct tc_action **act, | 280 | struct nlattr *est, struct tc_action **act, |
| 280 | int replace, int bind, bool rtnl_held, | 281 | int replace, int bind, bool rtnl_held, |
| 281 | struct netlink_ext_ack *extack) | 282 | struct tcf_proto *tp, struct netlink_ext_ack *extack) |
| 282 | { | 283 | { |
| 283 | struct tc_action_net *tn = net_generic(net, bpf_net_id); | 284 | struct tc_action_net *tn = net_generic(net, bpf_net_id); |
| 284 | struct nlattr *tb[TCA_ACT_BPF_MAX + 1]; | 285 | struct nlattr *tb[TCA_ACT_BPF_MAX + 1]; |
| 286 | struct tcf_chain *goto_ch = NULL; | ||
| 285 | struct tcf_bpf_cfg cfg, old; | 287 | struct tcf_bpf_cfg cfg, old; |
| 286 | struct tc_act_bpf *parm; | 288 | struct tc_act_bpf *parm; |
| 287 | struct tcf_bpf *prog; | 289 | struct tcf_bpf *prog; |
| @@ -323,12 +325,16 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
| 323 | return ret; | 325 | return ret; |
| 324 | } | 326 | } |
| 325 | 327 | ||
| 328 | ret = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 329 | if (ret < 0) | ||
| 330 | goto release_idr; | ||
| 331 | |||
| 326 | is_bpf = tb[TCA_ACT_BPF_OPS_LEN] && tb[TCA_ACT_BPF_OPS]; | 332 | is_bpf = tb[TCA_ACT_BPF_OPS_LEN] && tb[TCA_ACT_BPF_OPS]; |
| 327 | is_ebpf = tb[TCA_ACT_BPF_FD]; | 333 | is_ebpf = tb[TCA_ACT_BPF_FD]; |
| 328 | 334 | ||
| 329 | if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf)) { | 335 | if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf)) { |
| 330 | ret = -EINVAL; | 336 | ret = -EINVAL; |
| 331 | goto out; | 337 | goto put_chain; |
| 332 | } | 338 | } |
| 333 | 339 | ||
| 334 | memset(&cfg, 0, sizeof(cfg)); | 340 | memset(&cfg, 0, sizeof(cfg)); |
| @@ -336,7 +342,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
| 336 | ret = is_bpf ? tcf_bpf_init_from_ops(tb, &cfg) : | 342 | ret = is_bpf ? tcf_bpf_init_from_ops(tb, &cfg) : |
| 337 | tcf_bpf_init_from_efd(tb, &cfg); | 343 | tcf_bpf_init_from_efd(tb, &cfg); |
| 338 | if (ret < 0) | 344 | if (ret < 0) |
| 339 | goto out; | 345 | goto put_chain; |
| 340 | 346 | ||
| 341 | prog = to_bpf(*act); | 347 | prog = to_bpf(*act); |
| 342 | 348 | ||
| @@ -350,10 +356,13 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
| 350 | if (cfg.bpf_num_ops) | 356 | if (cfg.bpf_num_ops) |
| 351 | prog->bpf_num_ops = cfg.bpf_num_ops; | 357 | prog->bpf_num_ops = cfg.bpf_num_ops; |
| 352 | 358 | ||
| 353 | prog->tcf_action = parm->action; | 359 | goto_ch = tcf_action_set_ctrlact(*act, parm->action, goto_ch); |
| 354 | rcu_assign_pointer(prog->filter, cfg.filter); | 360 | rcu_assign_pointer(prog->filter, cfg.filter); |
| 355 | spin_unlock_bh(&prog->tcf_lock); | 361 | spin_unlock_bh(&prog->tcf_lock); |
| 356 | 362 | ||
| 363 | if (goto_ch) | ||
| 364 | tcf_chain_put_by_act(goto_ch); | ||
| 365 | |||
| 357 | if (res == ACT_P_CREATED) { | 366 | if (res == ACT_P_CREATED) { |
| 358 | tcf_idr_insert(tn, *act); | 367 | tcf_idr_insert(tn, *act); |
| 359 | } else { | 368 | } else { |
| @@ -363,9 +372,13 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
| 363 | } | 372 | } |
| 364 | 373 | ||
| 365 | return res; | 374 | return res; |
| 366 | out: | ||
| 367 | tcf_idr_release(*act, bind); | ||
| 368 | 375 | ||
| 376 | put_chain: | ||
| 377 | if (goto_ch) | ||
| 378 | tcf_chain_put_by_act(goto_ch); | ||
| 379 | |||
| 380 | release_idr: | ||
| 381 | tcf_idr_release(*act, bind); | ||
| 369 | return ret; | 382 | return ret; |
| 370 | } | 383 | } |
| 371 | 384 | ||
diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c index 5d24993cccfe..32ae0cd6e31c 100644 --- a/net/sched/act_connmark.c +++ b/net/sched/act_connmark.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <net/netlink.h> | 21 | #include <net/netlink.h> |
| 22 | #include <net/pkt_sched.h> | 22 | #include <net/pkt_sched.h> |
| 23 | #include <net/act_api.h> | 23 | #include <net/act_api.h> |
| 24 | #include <net/pkt_cls.h> | ||
| 24 | #include <uapi/linux/tc_act/tc_connmark.h> | 25 | #include <uapi/linux/tc_act/tc_connmark.h> |
| 25 | #include <net/tc_act/tc_connmark.h> | 26 | #include <net/tc_act/tc_connmark.h> |
| 26 | 27 | ||
| @@ -97,13 +98,15 @@ static const struct nla_policy connmark_policy[TCA_CONNMARK_MAX + 1] = { | |||
| 97 | static int tcf_connmark_init(struct net *net, struct nlattr *nla, | 98 | static int tcf_connmark_init(struct net *net, struct nlattr *nla, |
| 98 | struct nlattr *est, struct tc_action **a, | 99 | struct nlattr *est, struct tc_action **a, |
| 99 | int ovr, int bind, bool rtnl_held, | 100 | int ovr, int bind, bool rtnl_held, |
| 101 | struct tcf_proto *tp, | ||
| 100 | struct netlink_ext_ack *extack) | 102 | struct netlink_ext_ack *extack) |
| 101 | { | 103 | { |
| 102 | struct tc_action_net *tn = net_generic(net, connmark_net_id); | 104 | struct tc_action_net *tn = net_generic(net, connmark_net_id); |
| 103 | struct nlattr *tb[TCA_CONNMARK_MAX + 1]; | 105 | struct nlattr *tb[TCA_CONNMARK_MAX + 1]; |
| 106 | struct tcf_chain *goto_ch = NULL; | ||
| 104 | struct tcf_connmark_info *ci; | 107 | struct tcf_connmark_info *ci; |
| 105 | struct tc_connmark *parm; | 108 | struct tc_connmark *parm; |
| 106 | int ret = 0; | 109 | int ret = 0, err; |
| 107 | 110 | ||
| 108 | if (!nla) | 111 | if (!nla) |
| 109 | return -EINVAL; | 112 | return -EINVAL; |
| @@ -128,7 +131,11 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, | |||
| 128 | } | 131 | } |
| 129 | 132 | ||
| 130 | ci = to_connmark(*a); | 133 | ci = to_connmark(*a); |
| 131 | ci->tcf_action = parm->action; | 134 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, |
| 135 | extack); | ||
| 136 | if (err < 0) | ||
| 137 | goto release_idr; | ||
| 138 | tcf_action_set_ctrlact(*a, parm->action, goto_ch); | ||
| 132 | ci->net = net; | 139 | ci->net = net; |
| 133 | ci->zone = parm->zone; | 140 | ci->zone = parm->zone; |
| 134 | 141 | ||
| @@ -142,15 +149,24 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, | |||
| 142 | tcf_idr_release(*a, bind); | 149 | tcf_idr_release(*a, bind); |
| 143 | return -EEXIST; | 150 | return -EEXIST; |
| 144 | } | 151 | } |
| 152 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, | ||
| 153 | extack); | ||
| 154 | if (err < 0) | ||
| 155 | goto release_idr; | ||
| 145 | /* replacing action and zone */ | 156 | /* replacing action and zone */ |
| 146 | spin_lock_bh(&ci->tcf_lock); | 157 | spin_lock_bh(&ci->tcf_lock); |
| 147 | ci->tcf_action = parm->action; | 158 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 148 | ci->zone = parm->zone; | 159 | ci->zone = parm->zone; |
| 149 | spin_unlock_bh(&ci->tcf_lock); | 160 | spin_unlock_bh(&ci->tcf_lock); |
| 161 | if (goto_ch) | ||
| 162 | tcf_chain_put_by_act(goto_ch); | ||
| 150 | ret = 0; | 163 | ret = 0; |
| 151 | } | 164 | } |
| 152 | 165 | ||
| 153 | return ret; | 166 | return ret; |
| 167 | release_idr: | ||
| 168 | tcf_idr_release(*a, bind); | ||
| 169 | return err; | ||
| 154 | } | 170 | } |
| 155 | 171 | ||
| 156 | static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a, | 172 | static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a, |
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index c79aca29505e..0c77e7bdf6d5 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #include <net/sctp/checksum.h> | 33 | #include <net/sctp/checksum.h> |
| 34 | 34 | ||
| 35 | #include <net/act_api.h> | 35 | #include <net/act_api.h> |
| 36 | #include <net/pkt_cls.h> | ||
| 36 | 37 | ||
| 37 | #include <linux/tc_act/tc_csum.h> | 38 | #include <linux/tc_act/tc_csum.h> |
| 38 | #include <net/tc_act/tc_csum.h> | 39 | #include <net/tc_act/tc_csum.h> |
| @@ -46,12 +47,13 @@ static struct tc_action_ops act_csum_ops; | |||
| 46 | 47 | ||
| 47 | static int tcf_csum_init(struct net *net, struct nlattr *nla, | 48 | static int tcf_csum_init(struct net *net, struct nlattr *nla, |
| 48 | struct nlattr *est, struct tc_action **a, int ovr, | 49 | struct nlattr *est, struct tc_action **a, int ovr, |
| 49 | int bind, bool rtnl_held, | 50 | int bind, bool rtnl_held, struct tcf_proto *tp, |
| 50 | struct netlink_ext_ack *extack) | 51 | struct netlink_ext_ack *extack) |
| 51 | { | 52 | { |
| 52 | struct tc_action_net *tn = net_generic(net, csum_net_id); | 53 | struct tc_action_net *tn = net_generic(net, csum_net_id); |
| 53 | struct tcf_csum_params *params_new; | 54 | struct tcf_csum_params *params_new; |
| 54 | struct nlattr *tb[TCA_CSUM_MAX + 1]; | 55 | struct nlattr *tb[TCA_CSUM_MAX + 1]; |
| 56 | struct tcf_chain *goto_ch = NULL; | ||
| 55 | struct tc_csum *parm; | 57 | struct tc_csum *parm; |
| 56 | struct tcf_csum *p; | 58 | struct tcf_csum *p; |
| 57 | int ret = 0, err; | 59 | int ret = 0, err; |
| @@ -87,21 +89,27 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla, | |||
| 87 | return err; | 89 | return err; |
| 88 | } | 90 | } |
| 89 | 91 | ||
| 92 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 93 | if (err < 0) | ||
| 94 | goto release_idr; | ||
| 95 | |||
| 90 | p = to_tcf_csum(*a); | 96 | p = to_tcf_csum(*a); |
| 91 | 97 | ||
| 92 | params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); | 98 | params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); |
| 93 | if (unlikely(!params_new)) { | 99 | if (unlikely(!params_new)) { |
| 94 | tcf_idr_release(*a, bind); | 100 | err = -ENOMEM; |
| 95 | return -ENOMEM; | 101 | goto put_chain; |
| 96 | } | 102 | } |
| 97 | params_new->update_flags = parm->update_flags; | 103 | params_new->update_flags = parm->update_flags; |
| 98 | 104 | ||
| 99 | spin_lock_bh(&p->tcf_lock); | 105 | spin_lock_bh(&p->tcf_lock); |
| 100 | p->tcf_action = parm->action; | 106 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 101 | rcu_swap_protected(p->params, params_new, | 107 | rcu_swap_protected(p->params, params_new, |
| 102 | lockdep_is_held(&p->tcf_lock)); | 108 | lockdep_is_held(&p->tcf_lock)); |
| 103 | spin_unlock_bh(&p->tcf_lock); | 109 | spin_unlock_bh(&p->tcf_lock); |
| 104 | 110 | ||
| 111 | if (goto_ch) | ||
| 112 | tcf_chain_put_by_act(goto_ch); | ||
| 105 | if (params_new) | 113 | if (params_new) |
| 106 | kfree_rcu(params_new, rcu); | 114 | kfree_rcu(params_new, rcu); |
| 107 | 115 | ||
| @@ -109,6 +117,12 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla, | |||
| 109 | tcf_idr_insert(tn, *a); | 117 | tcf_idr_insert(tn, *a); |
| 110 | 118 | ||
| 111 | return ret; | 119 | return ret; |
| 120 | put_chain: | ||
| 121 | if (goto_ch) | ||
| 122 | tcf_chain_put_by_act(goto_ch); | ||
| 123 | release_idr: | ||
| 124 | tcf_idr_release(*a, bind); | ||
| 125 | return err; | ||
| 112 | } | 126 | } |
| 113 | 127 | ||
| 114 | /** | 128 | /** |
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index 93da0004e9f4..e540e31069d7 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 21 | #include <net/netlink.h> | 21 | #include <net/netlink.h> |
| 22 | #include <net/pkt_sched.h> | 22 | #include <net/pkt_sched.h> |
| 23 | #include <net/pkt_cls.h> | ||
| 23 | #include <linux/tc_act/tc_gact.h> | 24 | #include <linux/tc_act/tc_gact.h> |
| 24 | #include <net/tc_act/tc_gact.h> | 25 | #include <net/tc_act/tc_gact.h> |
| 25 | 26 | ||
| @@ -57,10 +58,11 @@ static const struct nla_policy gact_policy[TCA_GACT_MAX + 1] = { | |||
| 57 | static int tcf_gact_init(struct net *net, struct nlattr *nla, | 58 | static int tcf_gact_init(struct net *net, struct nlattr *nla, |
| 58 | struct nlattr *est, struct tc_action **a, | 59 | struct nlattr *est, struct tc_action **a, |
| 59 | int ovr, int bind, bool rtnl_held, | 60 | int ovr, int bind, bool rtnl_held, |
| 60 | struct netlink_ext_ack *extack) | 61 | struct tcf_proto *tp, struct netlink_ext_ack *extack) |
| 61 | { | 62 | { |
| 62 | struct tc_action_net *tn = net_generic(net, gact_net_id); | 63 | struct tc_action_net *tn = net_generic(net, gact_net_id); |
| 63 | struct nlattr *tb[TCA_GACT_MAX + 1]; | 64 | struct nlattr *tb[TCA_GACT_MAX + 1]; |
| 65 | struct tcf_chain *goto_ch = NULL; | ||
| 64 | struct tc_gact *parm; | 66 | struct tc_gact *parm; |
| 65 | struct tcf_gact *gact; | 67 | struct tcf_gact *gact; |
| 66 | int ret = 0; | 68 | int ret = 0; |
| @@ -116,10 +118,13 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, | |||
| 116 | return err; | 118 | return err; |
| 117 | } | 119 | } |
| 118 | 120 | ||
| 121 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 122 | if (err < 0) | ||
| 123 | goto release_idr; | ||
| 119 | gact = to_gact(*a); | 124 | gact = to_gact(*a); |
| 120 | 125 | ||
| 121 | spin_lock_bh(&gact->tcf_lock); | 126 | spin_lock_bh(&gact->tcf_lock); |
| 122 | gact->tcf_action = parm->action; | 127 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 123 | #ifdef CONFIG_GACT_PROB | 128 | #ifdef CONFIG_GACT_PROB |
| 124 | if (p_parm) { | 129 | if (p_parm) { |
| 125 | gact->tcfg_paction = p_parm->paction; | 130 | gact->tcfg_paction = p_parm->paction; |
| @@ -133,9 +138,15 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, | |||
| 133 | #endif | 138 | #endif |
| 134 | spin_unlock_bh(&gact->tcf_lock); | 139 | spin_unlock_bh(&gact->tcf_lock); |
| 135 | 140 | ||
| 141 | if (goto_ch) | ||
| 142 | tcf_chain_put_by_act(goto_ch); | ||
| 143 | |||
| 136 | if (ret == ACT_P_CREATED) | 144 | if (ret == ACT_P_CREATED) |
| 137 | tcf_idr_insert(tn, *a); | 145 | tcf_idr_insert(tn, *a); |
| 138 | return ret; | 146 | return ret; |
| 147 | release_idr: | ||
| 148 | tcf_idr_release(*a, bind); | ||
| 149 | return err; | ||
| 139 | } | 150 | } |
| 140 | 151 | ||
| 141 | static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a, | 152 | static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a, |
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index 9b1f2b3990ee..31c6ffb6abe7 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include <net/net_namespace.h> | 29 | #include <net/net_namespace.h> |
| 30 | #include <net/netlink.h> | 30 | #include <net/netlink.h> |
| 31 | #include <net/pkt_sched.h> | 31 | #include <net/pkt_sched.h> |
| 32 | #include <net/pkt_cls.h> | ||
| 32 | #include <uapi/linux/tc_act/tc_ife.h> | 33 | #include <uapi/linux/tc_act/tc_ife.h> |
| 33 | #include <net/tc_act/tc_ife.h> | 34 | #include <net/tc_act/tc_ife.h> |
| 34 | #include <linux/etherdevice.h> | 35 | #include <linux/etherdevice.h> |
| @@ -469,11 +470,12 @@ static int populate_metalist(struct tcf_ife_info *ife, struct nlattr **tb, | |||
| 469 | static int tcf_ife_init(struct net *net, struct nlattr *nla, | 470 | static int tcf_ife_init(struct net *net, struct nlattr *nla, |
| 470 | struct nlattr *est, struct tc_action **a, | 471 | struct nlattr *est, struct tc_action **a, |
| 471 | int ovr, int bind, bool rtnl_held, | 472 | int ovr, int bind, bool rtnl_held, |
| 472 | struct netlink_ext_ack *extack) | 473 | struct tcf_proto *tp, struct netlink_ext_ack *extack) |
| 473 | { | 474 | { |
| 474 | struct tc_action_net *tn = net_generic(net, ife_net_id); | 475 | struct tc_action_net *tn = net_generic(net, ife_net_id); |
| 475 | struct nlattr *tb[TCA_IFE_MAX + 1]; | 476 | struct nlattr *tb[TCA_IFE_MAX + 1]; |
| 476 | struct nlattr *tb2[IFE_META_MAX + 1]; | 477 | struct nlattr *tb2[IFE_META_MAX + 1]; |
| 478 | struct tcf_chain *goto_ch = NULL; | ||
| 477 | struct tcf_ife_params *p; | 479 | struct tcf_ife_params *p; |
| 478 | struct tcf_ife_info *ife; | 480 | struct tcf_ife_info *ife; |
| 479 | u16 ife_type = ETH_P_IFE; | 481 | u16 ife_type = ETH_P_IFE; |
| @@ -531,6 +533,10 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, | |||
| 531 | } | 533 | } |
| 532 | 534 | ||
| 533 | ife = to_ife(*a); | 535 | ife = to_ife(*a); |
| 536 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 537 | if (err < 0) | ||
| 538 | goto release_idr; | ||
| 539 | |||
| 534 | p->flags = parm->flags; | 540 | p->flags = parm->flags; |
| 535 | 541 | ||
| 536 | if (parm->flags & IFE_ENCODE) { | 542 | if (parm->flags & IFE_ENCODE) { |
| @@ -563,13 +569,8 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, | |||
| 563 | if (tb[TCA_IFE_METALST]) { | 569 | if (tb[TCA_IFE_METALST]) { |
| 564 | err = nla_parse_nested(tb2, IFE_META_MAX, tb[TCA_IFE_METALST], | 570 | err = nla_parse_nested(tb2, IFE_META_MAX, tb[TCA_IFE_METALST], |
| 565 | NULL, NULL); | 571 | NULL, NULL); |
| 566 | if (err) { | 572 | if (err) |
| 567 | metadata_parse_err: | 573 | goto metadata_parse_err; |
| 568 | tcf_idr_release(*a, bind); | ||
| 569 | kfree(p); | ||
| 570 | return err; | ||
| 571 | } | ||
| 572 | |||
| 573 | err = populate_metalist(ife, tb2, exists, rtnl_held); | 574 | err = populate_metalist(ife, tb2, exists, rtnl_held); |
| 574 | if (err) | 575 | if (err) |
| 575 | goto metadata_parse_err; | 576 | goto metadata_parse_err; |
| @@ -581,21 +582,20 @@ metadata_parse_err: | |||
| 581 | * going to bail out | 582 | * going to bail out |
| 582 | */ | 583 | */ |
| 583 | err = use_all_metadata(ife, exists); | 584 | err = use_all_metadata(ife, exists); |
| 584 | if (err) { | 585 | if (err) |
| 585 | tcf_idr_release(*a, bind); | 586 | goto metadata_parse_err; |
| 586 | kfree(p); | ||
| 587 | return err; | ||
| 588 | } | ||
| 589 | } | 587 | } |
| 590 | 588 | ||
| 591 | if (exists) | 589 | if (exists) |
| 592 | spin_lock_bh(&ife->tcf_lock); | 590 | spin_lock_bh(&ife->tcf_lock); |
| 593 | ife->tcf_action = parm->action; | ||
| 594 | /* protected by tcf_lock when modifying existing action */ | 591 | /* protected by tcf_lock when modifying existing action */ |
| 592 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); | ||
| 595 | rcu_swap_protected(ife->params, p, 1); | 593 | rcu_swap_protected(ife->params, p, 1); |
| 596 | 594 | ||
| 597 | if (exists) | 595 | if (exists) |
| 598 | spin_unlock_bh(&ife->tcf_lock); | 596 | spin_unlock_bh(&ife->tcf_lock); |
| 597 | if (goto_ch) | ||
| 598 | tcf_chain_put_by_act(goto_ch); | ||
| 599 | if (p) | 599 | if (p) |
| 600 | kfree_rcu(p, rcu); | 600 | kfree_rcu(p, rcu); |
| 601 | 601 | ||
| @@ -603,6 +603,13 @@ metadata_parse_err: | |||
| 603 | tcf_idr_insert(tn, *a); | 603 | tcf_idr_insert(tn, *a); |
| 604 | 604 | ||
| 605 | return ret; | 605 | return ret; |
| 606 | metadata_parse_err: | ||
| 607 | if (goto_ch) | ||
| 608 | tcf_chain_put_by_act(goto_ch); | ||
| 609 | release_idr: | ||
| 610 | kfree(p); | ||
| 611 | tcf_idr_release(*a, bind); | ||
| 612 | return err; | ||
| 606 | } | 613 | } |
| 607 | 614 | ||
| 608 | static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind, | 615 | static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind, |
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 98f5b6ea77b4..04a0b5c61194 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c | |||
| @@ -97,7 +97,8 @@ static const struct nla_policy ipt_policy[TCA_IPT_MAX + 1] = { | |||
| 97 | 97 | ||
| 98 | static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, | 98 | static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, |
| 99 | struct nlattr *est, struct tc_action **a, | 99 | struct nlattr *est, struct tc_action **a, |
| 100 | const struct tc_action_ops *ops, int ovr, int bind) | 100 | const struct tc_action_ops *ops, int ovr, int bind, |
| 101 | struct tcf_proto *tp) | ||
| 101 | { | 102 | { |
| 102 | struct tc_action_net *tn = net_generic(net, id); | 103 | struct tc_action_net *tn = net_generic(net, id); |
| 103 | struct nlattr *tb[TCA_IPT_MAX + 1]; | 104 | struct nlattr *tb[TCA_IPT_MAX + 1]; |
| @@ -205,20 +206,20 @@ err1: | |||
| 205 | 206 | ||
| 206 | static int tcf_ipt_init(struct net *net, struct nlattr *nla, | 207 | static int tcf_ipt_init(struct net *net, struct nlattr *nla, |
| 207 | struct nlattr *est, struct tc_action **a, int ovr, | 208 | struct nlattr *est, struct tc_action **a, int ovr, |
| 208 | int bind, bool rtnl_held, | 209 | int bind, bool rtnl_held, struct tcf_proto *tp, |
| 209 | struct netlink_ext_ack *extack) | 210 | struct netlink_ext_ack *extack) |
| 210 | { | 211 | { |
| 211 | return __tcf_ipt_init(net, ipt_net_id, nla, est, a, &act_ipt_ops, ovr, | 212 | return __tcf_ipt_init(net, ipt_net_id, nla, est, a, &act_ipt_ops, ovr, |
| 212 | bind); | 213 | bind, tp); |
| 213 | } | 214 | } |
| 214 | 215 | ||
| 215 | static int tcf_xt_init(struct net *net, struct nlattr *nla, | 216 | static int tcf_xt_init(struct net *net, struct nlattr *nla, |
| 216 | struct nlattr *est, struct tc_action **a, int ovr, | 217 | struct nlattr *est, struct tc_action **a, int ovr, |
| 217 | int bind, bool unlocked, | 218 | int bind, bool unlocked, struct tcf_proto *tp, |
| 218 | struct netlink_ext_ack *extack) | 219 | struct netlink_ext_ack *extack) |
| 219 | { | 220 | { |
| 220 | return __tcf_ipt_init(net, xt_net_id, nla, est, a, &act_xt_ops, ovr, | 221 | return __tcf_ipt_init(net, xt_net_id, nla, est, a, &act_xt_ops, ovr, |
| 221 | bind); | 222 | bind, tp); |
| 222 | } | 223 | } |
| 223 | 224 | ||
| 224 | static int tcf_ipt_act(struct sk_buff *skb, const struct tc_action *a, | 225 | static int tcf_ipt_act(struct sk_buff *skb, const struct tc_action *a, |
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 6692fd054617..17cc6bd4c57c 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c | |||
| @@ -94,10 +94,12 @@ static struct tc_action_ops act_mirred_ops; | |||
| 94 | static int tcf_mirred_init(struct net *net, struct nlattr *nla, | 94 | static int tcf_mirred_init(struct net *net, struct nlattr *nla, |
| 95 | struct nlattr *est, struct tc_action **a, | 95 | struct nlattr *est, struct tc_action **a, |
| 96 | int ovr, int bind, bool rtnl_held, | 96 | int ovr, int bind, bool rtnl_held, |
| 97 | struct tcf_proto *tp, | ||
| 97 | struct netlink_ext_ack *extack) | 98 | struct netlink_ext_ack *extack) |
| 98 | { | 99 | { |
| 99 | struct tc_action_net *tn = net_generic(net, mirred_net_id); | 100 | struct tc_action_net *tn = net_generic(net, mirred_net_id); |
| 100 | struct nlattr *tb[TCA_MIRRED_MAX + 1]; | 101 | struct nlattr *tb[TCA_MIRRED_MAX + 1]; |
| 102 | struct tcf_chain *goto_ch = NULL; | ||
| 101 | bool mac_header_xmit = false; | 103 | bool mac_header_xmit = false; |
| 102 | struct tc_mirred *parm; | 104 | struct tc_mirred *parm; |
| 103 | struct tcf_mirred *m; | 105 | struct tcf_mirred *m; |
| @@ -157,18 +159,23 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, | |||
| 157 | tcf_idr_release(*a, bind); | 159 | tcf_idr_release(*a, bind); |
| 158 | return -EEXIST; | 160 | return -EEXIST; |
| 159 | } | 161 | } |
| 162 | |||
| 160 | m = to_mirred(*a); | 163 | m = to_mirred(*a); |
| 164 | if (ret == ACT_P_CREATED) | ||
| 165 | INIT_LIST_HEAD(&m->tcfm_list); | ||
| 166 | |||
| 167 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 168 | if (err < 0) | ||
| 169 | goto release_idr; | ||
| 161 | 170 | ||
| 162 | spin_lock_bh(&m->tcf_lock); | 171 | spin_lock_bh(&m->tcf_lock); |
| 163 | m->tcf_action = parm->action; | ||
| 164 | m->tcfm_eaction = parm->eaction; | ||
| 165 | 172 | ||
| 166 | if (parm->ifindex) { | 173 | if (parm->ifindex) { |
| 167 | dev = dev_get_by_index(net, parm->ifindex); | 174 | dev = dev_get_by_index(net, parm->ifindex); |
| 168 | if (!dev) { | 175 | if (!dev) { |
| 169 | spin_unlock_bh(&m->tcf_lock); | 176 | spin_unlock_bh(&m->tcf_lock); |
| 170 | tcf_idr_release(*a, bind); | 177 | err = -ENODEV; |
| 171 | return -ENODEV; | 178 | goto put_chain; |
| 172 | } | 179 | } |
| 173 | mac_header_xmit = dev_is_mac_header_xmit(dev); | 180 | mac_header_xmit = dev_is_mac_header_xmit(dev); |
| 174 | rcu_swap_protected(m->tcfm_dev, dev, | 181 | rcu_swap_protected(m->tcfm_dev, dev, |
| @@ -177,7 +184,11 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, | |||
| 177 | dev_put(dev); | 184 | dev_put(dev); |
| 178 | m->tcfm_mac_header_xmit = mac_header_xmit; | 185 | m->tcfm_mac_header_xmit = mac_header_xmit; |
| 179 | } | 186 | } |
| 187 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); | ||
| 188 | m->tcfm_eaction = parm->eaction; | ||
| 180 | spin_unlock_bh(&m->tcf_lock); | 189 | spin_unlock_bh(&m->tcf_lock); |
| 190 | if (goto_ch) | ||
| 191 | tcf_chain_put_by_act(goto_ch); | ||
| 181 | 192 | ||
| 182 | if (ret == ACT_P_CREATED) { | 193 | if (ret == ACT_P_CREATED) { |
| 183 | spin_lock(&mirred_list_lock); | 194 | spin_lock(&mirred_list_lock); |
| @@ -188,6 +199,12 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, | |||
| 188 | } | 199 | } |
| 189 | 200 | ||
| 190 | return ret; | 201 | return ret; |
| 202 | put_chain: | ||
| 203 | if (goto_ch) | ||
| 204 | tcf_chain_put_by_act(goto_ch); | ||
| 205 | release_idr: | ||
| 206 | tcf_idr_release(*a, bind); | ||
| 207 | return err; | ||
| 191 | } | 208 | } |
| 192 | 209 | ||
| 193 | static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a, | 210 | static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a, |
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 543eab9193f1..e91bb8eb81ec 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
| 22 | #include <linux/tc_act/tc_nat.h> | 22 | #include <linux/tc_act/tc_nat.h> |
| 23 | #include <net/act_api.h> | 23 | #include <net/act_api.h> |
| 24 | #include <net/pkt_cls.h> | ||
| 24 | #include <net/icmp.h> | 25 | #include <net/icmp.h> |
| 25 | #include <net/ip.h> | 26 | #include <net/ip.h> |
| 26 | #include <net/netlink.h> | 27 | #include <net/netlink.h> |
| @@ -38,10 +39,12 @@ static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { | |||
| 38 | 39 | ||
| 39 | static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | 40 | static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, |
| 40 | struct tc_action **a, int ovr, int bind, | 41 | struct tc_action **a, int ovr, int bind, |
| 41 | bool rtnl_held, struct netlink_ext_ack *extack) | 42 | bool rtnl_held, struct tcf_proto *tp, |
| 43 | struct netlink_ext_ack *extack) | ||
| 42 | { | 44 | { |
| 43 | struct tc_action_net *tn = net_generic(net, nat_net_id); | 45 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
| 44 | struct nlattr *tb[TCA_NAT_MAX + 1]; | 46 | struct nlattr *tb[TCA_NAT_MAX + 1]; |
| 47 | struct tcf_chain *goto_ch = NULL; | ||
| 45 | struct tc_nat *parm; | 48 | struct tc_nat *parm; |
| 46 | int ret = 0, err; | 49 | int ret = 0, err; |
| 47 | struct tcf_nat *p; | 50 | struct tcf_nat *p; |
| @@ -76,6 +79,9 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
| 76 | } else { | 79 | } else { |
| 77 | return err; | 80 | return err; |
| 78 | } | 81 | } |
| 82 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 83 | if (err < 0) | ||
| 84 | goto release_idr; | ||
| 79 | p = to_tcf_nat(*a); | 85 | p = to_tcf_nat(*a); |
| 80 | 86 | ||
| 81 | spin_lock_bh(&p->tcf_lock); | 87 | spin_lock_bh(&p->tcf_lock); |
| @@ -84,13 +90,18 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
| 84 | p->mask = parm->mask; | 90 | p->mask = parm->mask; |
| 85 | p->flags = parm->flags; | 91 | p->flags = parm->flags; |
| 86 | 92 | ||
| 87 | p->tcf_action = parm->action; | 93 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 88 | spin_unlock_bh(&p->tcf_lock); | 94 | spin_unlock_bh(&p->tcf_lock); |
| 95 | if (goto_ch) | ||
| 96 | tcf_chain_put_by_act(goto_ch); | ||
| 89 | 97 | ||
| 90 | if (ret == ACT_P_CREATED) | 98 | if (ret == ACT_P_CREATED) |
| 91 | tcf_idr_insert(tn, *a); | 99 | tcf_idr_insert(tn, *a); |
| 92 | 100 | ||
| 93 | return ret; | 101 | return ret; |
| 102 | release_idr: | ||
| 103 | tcf_idr_release(*a, bind); | ||
| 104 | return err; | ||
| 94 | } | 105 | } |
| 95 | 106 | ||
| 96 | static int tcf_nat_act(struct sk_buff *skb, const struct tc_action *a, | 107 | static int tcf_nat_act(struct sk_buff *skb, const struct tc_action *a, |
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index a80373878df7..287793abfaf9 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include <linux/tc_act/tc_pedit.h> | 23 | #include <linux/tc_act/tc_pedit.h> |
| 24 | #include <net/tc_act/tc_pedit.h> | 24 | #include <net/tc_act/tc_pedit.h> |
| 25 | #include <uapi/linux/tc_act/tc_pedit.h> | 25 | #include <uapi/linux/tc_act/tc_pedit.h> |
| 26 | #include <net/pkt_cls.h> | ||
| 26 | 27 | ||
| 27 | static unsigned int pedit_net_id; | 28 | static unsigned int pedit_net_id; |
| 28 | static struct tc_action_ops act_pedit_ops; | 29 | static struct tc_action_ops act_pedit_ops; |
| @@ -138,10 +139,11 @@ nla_failure: | |||
| 138 | static int tcf_pedit_init(struct net *net, struct nlattr *nla, | 139 | static int tcf_pedit_init(struct net *net, struct nlattr *nla, |
| 139 | struct nlattr *est, struct tc_action **a, | 140 | struct nlattr *est, struct tc_action **a, |
| 140 | int ovr, int bind, bool rtnl_held, | 141 | int ovr, int bind, bool rtnl_held, |
| 141 | struct netlink_ext_ack *extack) | 142 | struct tcf_proto *tp, struct netlink_ext_ack *extack) |
| 142 | { | 143 | { |
| 143 | struct tc_action_net *tn = net_generic(net, pedit_net_id); | 144 | struct tc_action_net *tn = net_generic(net, pedit_net_id); |
| 144 | struct nlattr *tb[TCA_PEDIT_MAX + 1]; | 145 | struct nlattr *tb[TCA_PEDIT_MAX + 1]; |
| 146 | struct tcf_chain *goto_ch = NULL; | ||
| 145 | struct tc_pedit_key *keys = NULL; | 147 | struct tc_pedit_key *keys = NULL; |
| 146 | struct tcf_pedit_key_ex *keys_ex; | 148 | struct tcf_pedit_key_ex *keys_ex; |
| 147 | struct tc_pedit *parm; | 149 | struct tc_pedit *parm; |
| @@ -205,6 +207,11 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, | |||
| 205 | goto out_free; | 207 | goto out_free; |
| 206 | } | 208 | } |
| 207 | 209 | ||
| 210 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 211 | if (err < 0) { | ||
| 212 | ret = err; | ||
| 213 | goto out_release; | ||
| 214 | } | ||
| 208 | p = to_pedit(*a); | 215 | p = to_pedit(*a); |
| 209 | spin_lock_bh(&p->tcf_lock); | 216 | spin_lock_bh(&p->tcf_lock); |
| 210 | 217 | ||
| @@ -214,7 +221,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, | |||
| 214 | if (!keys) { | 221 | if (!keys) { |
| 215 | spin_unlock_bh(&p->tcf_lock); | 222 | spin_unlock_bh(&p->tcf_lock); |
| 216 | ret = -ENOMEM; | 223 | ret = -ENOMEM; |
| 217 | goto out_release; | 224 | goto put_chain; |
| 218 | } | 225 | } |
| 219 | kfree(p->tcfp_keys); | 226 | kfree(p->tcfp_keys); |
| 220 | p->tcfp_keys = keys; | 227 | p->tcfp_keys = keys; |
| @@ -223,16 +230,21 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, | |||
| 223 | memcpy(p->tcfp_keys, parm->keys, ksize); | 230 | memcpy(p->tcfp_keys, parm->keys, ksize); |
| 224 | 231 | ||
| 225 | p->tcfp_flags = parm->flags; | 232 | p->tcfp_flags = parm->flags; |
| 226 | p->tcf_action = parm->action; | 233 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 227 | 234 | ||
| 228 | kfree(p->tcfp_keys_ex); | 235 | kfree(p->tcfp_keys_ex); |
| 229 | p->tcfp_keys_ex = keys_ex; | 236 | p->tcfp_keys_ex = keys_ex; |
| 230 | 237 | ||
| 231 | spin_unlock_bh(&p->tcf_lock); | 238 | spin_unlock_bh(&p->tcf_lock); |
| 239 | if (goto_ch) | ||
| 240 | tcf_chain_put_by_act(goto_ch); | ||
| 232 | if (ret == ACT_P_CREATED) | 241 | if (ret == ACT_P_CREATED) |
| 233 | tcf_idr_insert(tn, *a); | 242 | tcf_idr_insert(tn, *a); |
| 234 | return ret; | 243 | return ret; |
| 235 | 244 | ||
| 245 | put_chain: | ||
| 246 | if (goto_ch) | ||
| 247 | tcf_chain_put_by_act(goto_ch); | ||
| 236 | out_release: | 248 | out_release: |
| 237 | tcf_idr_release(*a, bind); | 249 | tcf_idr_release(*a, bind); |
| 238 | out_free: | 250 | out_free: |
diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 8271a6263824..2b8581f6ab51 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
| 22 | #include <net/act_api.h> | 22 | #include <net/act_api.h> |
| 23 | #include <net/netlink.h> | 23 | #include <net/netlink.h> |
| 24 | #include <net/pkt_cls.h> | ||
| 24 | 25 | ||
| 25 | struct tcf_police_params { | 26 | struct tcf_police_params { |
| 26 | int tcfp_result; | 27 | int tcfp_result; |
| @@ -83,10 +84,12 @@ static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = { | |||
| 83 | static int tcf_police_init(struct net *net, struct nlattr *nla, | 84 | static int tcf_police_init(struct net *net, struct nlattr *nla, |
| 84 | struct nlattr *est, struct tc_action **a, | 85 | struct nlattr *est, struct tc_action **a, |
| 85 | int ovr, int bind, bool rtnl_held, | 86 | int ovr, int bind, bool rtnl_held, |
| 87 | struct tcf_proto *tp, | ||
| 86 | struct netlink_ext_ack *extack) | 88 | struct netlink_ext_ack *extack) |
| 87 | { | 89 | { |
| 88 | int ret = 0, tcfp_result = TC_ACT_OK, err, size; | 90 | int ret = 0, tcfp_result = TC_ACT_OK, err, size; |
| 89 | struct nlattr *tb[TCA_POLICE_MAX + 1]; | 91 | struct nlattr *tb[TCA_POLICE_MAX + 1]; |
| 92 | struct tcf_chain *goto_ch = NULL; | ||
| 90 | struct tc_police *parm; | 93 | struct tc_police *parm; |
| 91 | struct tcf_police *police; | 94 | struct tcf_police *police; |
| 92 | struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; | 95 | struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; |
| @@ -128,6 +131,9 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, | |||
| 128 | tcf_idr_release(*a, bind); | 131 | tcf_idr_release(*a, bind); |
| 129 | return -EEXIST; | 132 | return -EEXIST; |
| 130 | } | 133 | } |
| 134 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 135 | if (err < 0) | ||
| 136 | goto release_idr; | ||
| 131 | 137 | ||
| 132 | police = to_police(*a); | 138 | police = to_police(*a); |
| 133 | if (parm->rate.rate) { | 139 | if (parm->rate.rate) { |
| @@ -213,12 +219,14 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, | |||
| 213 | if (new->peak_present) | 219 | if (new->peak_present) |
| 214 | police->tcfp_ptoks = new->tcfp_mtu_ptoks; | 220 | police->tcfp_ptoks = new->tcfp_mtu_ptoks; |
| 215 | spin_unlock_bh(&police->tcfp_lock); | 221 | spin_unlock_bh(&police->tcfp_lock); |
| 216 | police->tcf_action = parm->action; | 222 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 217 | rcu_swap_protected(police->params, | 223 | rcu_swap_protected(police->params, |
| 218 | new, | 224 | new, |
| 219 | lockdep_is_held(&police->tcf_lock)); | 225 | lockdep_is_held(&police->tcf_lock)); |
| 220 | spin_unlock_bh(&police->tcf_lock); | 226 | spin_unlock_bh(&police->tcf_lock); |
| 221 | 227 | ||
| 228 | if (goto_ch) | ||
| 229 | tcf_chain_put_by_act(goto_ch); | ||
| 222 | if (new) | 230 | if (new) |
| 223 | kfree_rcu(new, rcu); | 231 | kfree_rcu(new, rcu); |
| 224 | 232 | ||
| @@ -229,6 +237,9 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, | |||
| 229 | failure: | 237 | failure: |
| 230 | qdisc_put_rtab(P_tab); | 238 | qdisc_put_rtab(P_tab); |
| 231 | qdisc_put_rtab(R_tab); | 239 | qdisc_put_rtab(R_tab); |
| 240 | if (goto_ch) | ||
| 241 | tcf_chain_put_by_act(goto_ch); | ||
| 242 | release_idr: | ||
| 232 | tcf_idr_release(*a, bind); | 243 | tcf_idr_release(*a, bind); |
| 233 | return err; | 244 | return err; |
| 234 | } | 245 | } |
diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 203e399e5c85..4060b0955c97 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/tc_act/tc_sample.h> | 22 | #include <linux/tc_act/tc_sample.h> |
| 23 | #include <net/tc_act/tc_sample.h> | 23 | #include <net/tc_act/tc_sample.h> |
| 24 | #include <net/psample.h> | 24 | #include <net/psample.h> |
| 25 | #include <net/pkt_cls.h> | ||
| 25 | 26 | ||
| 26 | #include <linux/if_arp.h> | 27 | #include <linux/if_arp.h> |
| 27 | 28 | ||
| @@ -37,12 +38,13 @@ static const struct nla_policy sample_policy[TCA_SAMPLE_MAX + 1] = { | |||
| 37 | 38 | ||
| 38 | static int tcf_sample_init(struct net *net, struct nlattr *nla, | 39 | static int tcf_sample_init(struct net *net, struct nlattr *nla, |
| 39 | struct nlattr *est, struct tc_action **a, int ovr, | 40 | struct nlattr *est, struct tc_action **a, int ovr, |
| 40 | int bind, bool rtnl_held, | 41 | int bind, bool rtnl_held, struct tcf_proto *tp, |
| 41 | struct netlink_ext_ack *extack) | 42 | struct netlink_ext_ack *extack) |
| 42 | { | 43 | { |
| 43 | struct tc_action_net *tn = net_generic(net, sample_net_id); | 44 | struct tc_action_net *tn = net_generic(net, sample_net_id); |
| 44 | struct nlattr *tb[TCA_SAMPLE_MAX + 1]; | 45 | struct nlattr *tb[TCA_SAMPLE_MAX + 1]; |
| 45 | struct psample_group *psample_group; | 46 | struct psample_group *psample_group; |
| 47 | struct tcf_chain *goto_ch = NULL; | ||
| 46 | struct tc_sample *parm; | 48 | struct tc_sample *parm; |
| 47 | u32 psample_group_num; | 49 | u32 psample_group_num; |
| 48 | struct tcf_sample *s; | 50 | struct tcf_sample *s; |
| @@ -79,18 +81,21 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, | |||
| 79 | tcf_idr_release(*a, bind); | 81 | tcf_idr_release(*a, bind); |
| 80 | return -EEXIST; | 82 | return -EEXIST; |
| 81 | } | 83 | } |
| 84 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 85 | if (err < 0) | ||
| 86 | goto release_idr; | ||
| 82 | 87 | ||
| 83 | psample_group_num = nla_get_u32(tb[TCA_SAMPLE_PSAMPLE_GROUP]); | 88 | psample_group_num = nla_get_u32(tb[TCA_SAMPLE_PSAMPLE_GROUP]); |
| 84 | psample_group = psample_group_get(net, psample_group_num); | 89 | psample_group = psample_group_get(net, psample_group_num); |
| 85 | if (!psample_group) { | 90 | if (!psample_group) { |
| 86 | tcf_idr_release(*a, bind); | 91 | err = -ENOMEM; |
| 87 | return -ENOMEM; | 92 | goto put_chain; |
| 88 | } | 93 | } |
| 89 | 94 | ||
| 90 | s = to_sample(*a); | 95 | s = to_sample(*a); |
| 91 | 96 | ||
| 92 | spin_lock_bh(&s->tcf_lock); | 97 | spin_lock_bh(&s->tcf_lock); |
| 93 | s->tcf_action = parm->action; | 98 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 94 | s->rate = nla_get_u32(tb[TCA_SAMPLE_RATE]); | 99 | s->rate = nla_get_u32(tb[TCA_SAMPLE_RATE]); |
| 95 | s->psample_group_num = psample_group_num; | 100 | s->psample_group_num = psample_group_num; |
| 96 | RCU_INIT_POINTER(s->psample_group, psample_group); | 101 | RCU_INIT_POINTER(s->psample_group, psample_group); |
| @@ -100,10 +105,18 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, | |||
| 100 | s->trunc_size = nla_get_u32(tb[TCA_SAMPLE_TRUNC_SIZE]); | 105 | s->trunc_size = nla_get_u32(tb[TCA_SAMPLE_TRUNC_SIZE]); |
| 101 | } | 106 | } |
| 102 | spin_unlock_bh(&s->tcf_lock); | 107 | spin_unlock_bh(&s->tcf_lock); |
| 108 | if (goto_ch) | ||
| 109 | tcf_chain_put_by_act(goto_ch); | ||
| 103 | 110 | ||
| 104 | if (ret == ACT_P_CREATED) | 111 | if (ret == ACT_P_CREATED) |
| 105 | tcf_idr_insert(tn, *a); | 112 | tcf_idr_insert(tn, *a); |
| 106 | return ret; | 113 | return ret; |
| 114 | put_chain: | ||
| 115 | if (goto_ch) | ||
| 116 | tcf_chain_put_by_act(goto_ch); | ||
| 117 | release_idr: | ||
| 118 | tcf_idr_release(*a, bind); | ||
| 119 | return err; | ||
| 107 | } | 120 | } |
| 108 | 121 | ||
| 109 | static void tcf_sample_cleanup(struct tc_action *a) | 122 | static void tcf_sample_cleanup(struct tc_action *a) |
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index d54cb608dbaf..23c8ca5615e5 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/rtnetlink.h> | 18 | #include <linux/rtnetlink.h> |
| 19 | #include <net/netlink.h> | 19 | #include <net/netlink.h> |
| 20 | #include <net/pkt_sched.h> | 20 | #include <net/pkt_sched.h> |
| 21 | #include <net/pkt_cls.h> | ||
| 21 | 22 | ||
| 22 | #include <linux/tc_act/tc_defact.h> | 23 | #include <linux/tc_act/tc_defact.h> |
| 23 | #include <net/tc_act/tc_defact.h> | 24 | #include <net/tc_act/tc_defact.h> |
| @@ -60,14 +61,26 @@ static int alloc_defdata(struct tcf_defact *d, const struct nlattr *defdata) | |||
| 60 | return 0; | 61 | return 0; |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | static void reset_policy(struct tcf_defact *d, const struct nlattr *defdata, | 64 | static int reset_policy(struct tc_action *a, const struct nlattr *defdata, |
| 64 | struct tc_defact *p) | 65 | struct tc_defact *p, struct tcf_proto *tp, |
| 66 | struct netlink_ext_ack *extack) | ||
| 65 | { | 67 | { |
| 68 | struct tcf_chain *goto_ch = NULL; | ||
| 69 | struct tcf_defact *d; | ||
| 70 | int err; | ||
| 71 | |||
| 72 | err = tcf_action_check_ctrlact(p->action, tp, &goto_ch, extack); | ||
| 73 | if (err < 0) | ||
| 74 | return err; | ||
| 75 | d = to_defact(a); | ||
| 66 | spin_lock_bh(&d->tcf_lock); | 76 | spin_lock_bh(&d->tcf_lock); |
| 67 | d->tcf_action = p->action; | 77 | goto_ch = tcf_action_set_ctrlact(a, p->action, goto_ch); |
| 68 | memset(d->tcfd_defdata, 0, SIMP_MAX_DATA); | 78 | memset(d->tcfd_defdata, 0, SIMP_MAX_DATA); |
| 69 | nla_strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); | 79 | nla_strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); |
| 70 | spin_unlock_bh(&d->tcf_lock); | 80 | spin_unlock_bh(&d->tcf_lock); |
| 81 | if (goto_ch) | ||
| 82 | tcf_chain_put_by_act(goto_ch); | ||
| 83 | return 0; | ||
| 71 | } | 84 | } |
| 72 | 85 | ||
| 73 | static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { | 86 | static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { |
| @@ -78,10 +91,11 @@ static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { | |||
| 78 | static int tcf_simp_init(struct net *net, struct nlattr *nla, | 91 | static int tcf_simp_init(struct net *net, struct nlattr *nla, |
| 79 | struct nlattr *est, struct tc_action **a, | 92 | struct nlattr *est, struct tc_action **a, |
| 80 | int ovr, int bind, bool rtnl_held, | 93 | int ovr, int bind, bool rtnl_held, |
| 81 | struct netlink_ext_ack *extack) | 94 | struct tcf_proto *tp, struct netlink_ext_ack *extack) |
| 82 | { | 95 | { |
| 83 | struct tc_action_net *tn = net_generic(net, simp_net_id); | 96 | struct tc_action_net *tn = net_generic(net, simp_net_id); |
| 84 | struct nlattr *tb[TCA_DEF_MAX + 1]; | 97 | struct nlattr *tb[TCA_DEF_MAX + 1]; |
| 98 | struct tcf_chain *goto_ch = NULL; | ||
| 85 | struct tc_defact *parm; | 99 | struct tc_defact *parm; |
| 86 | struct tcf_defact *d; | 100 | struct tcf_defact *d; |
| 87 | bool exists = false; | 101 | bool exists = false; |
| @@ -122,27 +136,37 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
| 122 | } | 136 | } |
| 123 | 137 | ||
| 124 | d = to_defact(*a); | 138 | d = to_defact(*a); |
| 125 | ret = alloc_defdata(d, tb[TCA_DEF_DATA]); | 139 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, |
| 126 | if (ret < 0) { | 140 | extack); |
| 127 | tcf_idr_release(*a, bind); | 141 | if (err < 0) |
| 128 | return ret; | 142 | goto release_idr; |
| 129 | } | 143 | |
| 130 | d->tcf_action = parm->action; | 144 | err = alloc_defdata(d, tb[TCA_DEF_DATA]); |
| 145 | if (err < 0) | ||
| 146 | goto put_chain; | ||
| 147 | |||
| 148 | tcf_action_set_ctrlact(*a, parm->action, goto_ch); | ||
| 131 | ret = ACT_P_CREATED; | 149 | ret = ACT_P_CREATED; |
| 132 | } else { | 150 | } else { |
| 133 | d = to_defact(*a); | ||
| 134 | |||
| 135 | if (!ovr) { | 151 | if (!ovr) { |
| 136 | tcf_idr_release(*a, bind); | 152 | err = -EEXIST; |
| 137 | return -EEXIST; | 153 | goto release_idr; |
| 138 | } | 154 | } |
| 139 | 155 | ||
| 140 | reset_policy(d, tb[TCA_DEF_DATA], parm); | 156 | err = reset_policy(*a, tb[TCA_DEF_DATA], parm, tp, extack); |
| 157 | if (err) | ||
| 158 | goto release_idr; | ||
| 141 | } | 159 | } |
| 142 | 160 | ||
| 143 | if (ret == ACT_P_CREATED) | 161 | if (ret == ACT_P_CREATED) |
| 144 | tcf_idr_insert(tn, *a); | 162 | tcf_idr_insert(tn, *a); |
| 145 | return ret; | 163 | return ret; |
| 164 | put_chain: | ||
| 165 | if (goto_ch) | ||
| 166 | tcf_chain_put_by_act(goto_ch); | ||
| 167 | release_idr: | ||
| 168 | tcf_idr_release(*a, bind); | ||
| 169 | return err; | ||
| 146 | } | 170 | } |
| 147 | 171 | ||
| 148 | static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, | 172 | static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, |
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index 65879500b688..7e1d261a31d2 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <net/ip.h> | 26 | #include <net/ip.h> |
| 27 | #include <net/ipv6.h> | 27 | #include <net/ipv6.h> |
| 28 | #include <net/dsfield.h> | 28 | #include <net/dsfield.h> |
| 29 | #include <net/pkt_cls.h> | ||
| 29 | 30 | ||
| 30 | #include <linux/tc_act/tc_skbedit.h> | 31 | #include <linux/tc_act/tc_skbedit.h> |
| 31 | #include <net/tc_act/tc_skbedit.h> | 32 | #include <net/tc_act/tc_skbedit.h> |
| @@ -96,11 +97,13 @@ static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = { | |||
| 96 | static int tcf_skbedit_init(struct net *net, struct nlattr *nla, | 97 | static int tcf_skbedit_init(struct net *net, struct nlattr *nla, |
| 97 | struct nlattr *est, struct tc_action **a, | 98 | struct nlattr *est, struct tc_action **a, |
| 98 | int ovr, int bind, bool rtnl_held, | 99 | int ovr, int bind, bool rtnl_held, |
| 100 | struct tcf_proto *tp, | ||
| 99 | struct netlink_ext_ack *extack) | 101 | struct netlink_ext_ack *extack) |
| 100 | { | 102 | { |
| 101 | struct tc_action_net *tn = net_generic(net, skbedit_net_id); | 103 | struct tc_action_net *tn = net_generic(net, skbedit_net_id); |
| 102 | struct tcf_skbedit_params *params_new; | 104 | struct tcf_skbedit_params *params_new; |
| 103 | struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; | 105 | struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; |
| 106 | struct tcf_chain *goto_ch = NULL; | ||
| 104 | struct tc_skbedit *parm; | 107 | struct tc_skbedit *parm; |
| 105 | struct tcf_skbedit *d; | 108 | struct tcf_skbedit *d; |
| 106 | u32 flags = 0, *priority = NULL, *mark = NULL, *mask = NULL; | 109 | u32 flags = 0, *priority = NULL, *mark = NULL, *mask = NULL; |
| @@ -186,11 +189,14 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, | |||
| 186 | return -EEXIST; | 189 | return -EEXIST; |
| 187 | } | 190 | } |
| 188 | } | 191 | } |
| 192 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 193 | if (err < 0) | ||
| 194 | goto release_idr; | ||
| 189 | 195 | ||
| 190 | params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); | 196 | params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); |
| 191 | if (unlikely(!params_new)) { | 197 | if (unlikely(!params_new)) { |
| 192 | tcf_idr_release(*a, bind); | 198 | err = -ENOMEM; |
| 193 | return -ENOMEM; | 199 | goto put_chain; |
| 194 | } | 200 | } |
| 195 | 201 | ||
| 196 | params_new->flags = flags; | 202 | params_new->flags = flags; |
| @@ -208,16 +214,24 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, | |||
| 208 | params_new->mask = *mask; | 214 | params_new->mask = *mask; |
| 209 | 215 | ||
| 210 | spin_lock_bh(&d->tcf_lock); | 216 | spin_lock_bh(&d->tcf_lock); |
| 211 | d->tcf_action = parm->action; | 217 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 212 | rcu_swap_protected(d->params, params_new, | 218 | rcu_swap_protected(d->params, params_new, |
| 213 | lockdep_is_held(&d->tcf_lock)); | 219 | lockdep_is_held(&d->tcf_lock)); |
| 214 | spin_unlock_bh(&d->tcf_lock); | 220 | spin_unlock_bh(&d->tcf_lock); |
| 215 | if (params_new) | 221 | if (params_new) |
| 216 | kfree_rcu(params_new, rcu); | 222 | kfree_rcu(params_new, rcu); |
| 223 | if (goto_ch) | ||
| 224 | tcf_chain_put_by_act(goto_ch); | ||
| 217 | 225 | ||
| 218 | if (ret == ACT_P_CREATED) | 226 | if (ret == ACT_P_CREATED) |
| 219 | tcf_idr_insert(tn, *a); | 227 | tcf_idr_insert(tn, *a); |
| 220 | return ret; | 228 | return ret; |
| 229 | put_chain: | ||
| 230 | if (goto_ch) | ||
| 231 | tcf_chain_put_by_act(goto_ch); | ||
| 232 | release_idr: | ||
| 233 | tcf_idr_release(*a, bind); | ||
| 234 | return err; | ||
| 221 | } | 235 | } |
| 222 | 236 | ||
| 223 | static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a, | 237 | static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a, |
diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c index 7bac1d78e7a3..1d4c324d0a42 100644 --- a/net/sched/act_skbmod.c +++ b/net/sched/act_skbmod.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <linux/rtnetlink.h> | 16 | #include <linux/rtnetlink.h> |
| 17 | #include <net/netlink.h> | 17 | #include <net/netlink.h> |
| 18 | #include <net/pkt_sched.h> | 18 | #include <net/pkt_sched.h> |
| 19 | #include <net/pkt_cls.h> | ||
| 19 | 20 | ||
| 20 | #include <linux/tc_act/tc_skbmod.h> | 21 | #include <linux/tc_act/tc_skbmod.h> |
| 21 | #include <net/tc_act/tc_skbmod.h> | 22 | #include <net/tc_act/tc_skbmod.h> |
| @@ -82,11 +83,13 @@ static const struct nla_policy skbmod_policy[TCA_SKBMOD_MAX + 1] = { | |||
| 82 | static int tcf_skbmod_init(struct net *net, struct nlattr *nla, | 83 | static int tcf_skbmod_init(struct net *net, struct nlattr *nla, |
| 83 | struct nlattr *est, struct tc_action **a, | 84 | struct nlattr *est, struct tc_action **a, |
| 84 | int ovr, int bind, bool rtnl_held, | 85 | int ovr, int bind, bool rtnl_held, |
| 86 | struct tcf_proto *tp, | ||
| 85 | struct netlink_ext_ack *extack) | 87 | struct netlink_ext_ack *extack) |
| 86 | { | 88 | { |
| 87 | struct tc_action_net *tn = net_generic(net, skbmod_net_id); | 89 | struct tc_action_net *tn = net_generic(net, skbmod_net_id); |
| 88 | struct nlattr *tb[TCA_SKBMOD_MAX + 1]; | 90 | struct nlattr *tb[TCA_SKBMOD_MAX + 1]; |
| 89 | struct tcf_skbmod_params *p, *p_old; | 91 | struct tcf_skbmod_params *p, *p_old; |
| 92 | struct tcf_chain *goto_ch = NULL; | ||
| 90 | struct tc_skbmod *parm; | 93 | struct tc_skbmod *parm; |
| 91 | struct tcf_skbmod *d; | 94 | struct tcf_skbmod *d; |
| 92 | bool exists = false; | 95 | bool exists = false; |
| @@ -153,21 +156,24 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, | |||
| 153 | tcf_idr_release(*a, bind); | 156 | tcf_idr_release(*a, bind); |
| 154 | return -EEXIST; | 157 | return -EEXIST; |
| 155 | } | 158 | } |
| 159 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 160 | if (err < 0) | ||
| 161 | goto release_idr; | ||
| 156 | 162 | ||
| 157 | d = to_skbmod(*a); | 163 | d = to_skbmod(*a); |
| 158 | 164 | ||
| 159 | p = kzalloc(sizeof(struct tcf_skbmod_params), GFP_KERNEL); | 165 | p = kzalloc(sizeof(struct tcf_skbmod_params), GFP_KERNEL); |
| 160 | if (unlikely(!p)) { | 166 | if (unlikely(!p)) { |
| 161 | tcf_idr_release(*a, bind); | 167 | err = -ENOMEM; |
| 162 | return -ENOMEM; | 168 | goto put_chain; |
| 163 | } | 169 | } |
| 164 | 170 | ||
| 165 | p->flags = lflags; | 171 | p->flags = lflags; |
| 166 | d->tcf_action = parm->action; | ||
| 167 | 172 | ||
| 168 | if (ovr) | 173 | if (ovr) |
| 169 | spin_lock_bh(&d->tcf_lock); | 174 | spin_lock_bh(&d->tcf_lock); |
| 170 | /* Protected by tcf_lock if overwriting existing action. */ | 175 | /* Protected by tcf_lock if overwriting existing action. */ |
| 176 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); | ||
| 171 | p_old = rcu_dereference_protected(d->skbmod_p, 1); | 177 | p_old = rcu_dereference_protected(d->skbmod_p, 1); |
| 172 | 178 | ||
| 173 | if (lflags & SKBMOD_F_DMAC) | 179 | if (lflags & SKBMOD_F_DMAC) |
| @@ -183,10 +189,18 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, | |||
| 183 | 189 | ||
| 184 | if (p_old) | 190 | if (p_old) |
| 185 | kfree_rcu(p_old, rcu); | 191 | kfree_rcu(p_old, rcu); |
| 192 | if (goto_ch) | ||
| 193 | tcf_chain_put_by_act(goto_ch); | ||
| 186 | 194 | ||
| 187 | if (ret == ACT_P_CREATED) | 195 | if (ret == ACT_P_CREATED) |
| 188 | tcf_idr_insert(tn, *a); | 196 | tcf_idr_insert(tn, *a); |
| 189 | return ret; | 197 | return ret; |
| 198 | put_chain: | ||
| 199 | if (goto_ch) | ||
| 200 | tcf_chain_put_by_act(goto_ch); | ||
| 201 | release_idr: | ||
| 202 | tcf_idr_release(*a, bind); | ||
| 203 | return err; | ||
| 190 | } | 204 | } |
| 191 | 205 | ||
| 192 | static void tcf_skbmod_cleanup(struct tc_action *a) | 206 | static void tcf_skbmod_cleanup(struct tc_action *a) |
diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index 7c6591b991d5..d5aaf90a3971 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <net/netlink.h> | 17 | #include <net/netlink.h> |
| 18 | #include <net/pkt_sched.h> | 18 | #include <net/pkt_sched.h> |
| 19 | #include <net/dst.h> | 19 | #include <net/dst.h> |
| 20 | #include <net/pkt_cls.h> | ||
| 20 | 21 | ||
| 21 | #include <linux/tc_act/tc_tunnel_key.h> | 22 | #include <linux/tc_act/tc_tunnel_key.h> |
| 22 | #include <net/tc_act/tc_tunnel_key.h> | 23 | #include <net/tc_act/tc_tunnel_key.h> |
| @@ -210,12 +211,14 @@ static void tunnel_key_release_params(struct tcf_tunnel_key_params *p) | |||
| 210 | static int tunnel_key_init(struct net *net, struct nlattr *nla, | 211 | static int tunnel_key_init(struct net *net, struct nlattr *nla, |
| 211 | struct nlattr *est, struct tc_action **a, | 212 | struct nlattr *est, struct tc_action **a, |
| 212 | int ovr, int bind, bool rtnl_held, | 213 | int ovr, int bind, bool rtnl_held, |
| 214 | struct tcf_proto *tp, | ||
| 213 | struct netlink_ext_ack *extack) | 215 | struct netlink_ext_ack *extack) |
| 214 | { | 216 | { |
| 215 | struct tc_action_net *tn = net_generic(net, tunnel_key_net_id); | 217 | struct tc_action_net *tn = net_generic(net, tunnel_key_net_id); |
| 216 | struct nlattr *tb[TCA_TUNNEL_KEY_MAX + 1]; | 218 | struct nlattr *tb[TCA_TUNNEL_KEY_MAX + 1]; |
| 217 | struct tcf_tunnel_key_params *params_new; | 219 | struct tcf_tunnel_key_params *params_new; |
| 218 | struct metadata_dst *metadata = NULL; | 220 | struct metadata_dst *metadata = NULL; |
| 221 | struct tcf_chain *goto_ch = NULL; | ||
| 219 | struct tc_tunnel_key *parm; | 222 | struct tc_tunnel_key *parm; |
| 220 | struct tcf_tunnel_key *t; | 223 | struct tcf_tunnel_key *t; |
| 221 | bool exists = false; | 224 | bool exists = false; |
| @@ -359,6 +362,12 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, | |||
| 359 | goto release_tun_meta; | 362 | goto release_tun_meta; |
| 360 | } | 363 | } |
| 361 | 364 | ||
| 365 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 366 | if (err < 0) { | ||
| 367 | ret = err; | ||
| 368 | exists = true; | ||
| 369 | goto release_tun_meta; | ||
| 370 | } | ||
| 362 | t = to_tunnel_key(*a); | 371 | t = to_tunnel_key(*a); |
| 363 | 372 | ||
| 364 | params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); | 373 | params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); |
| @@ -366,23 +375,29 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, | |||
| 366 | NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters"); | 375 | NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters"); |
| 367 | ret = -ENOMEM; | 376 | ret = -ENOMEM; |
| 368 | exists = true; | 377 | exists = true; |
| 369 | goto release_tun_meta; | 378 | goto put_chain; |
| 370 | } | 379 | } |
| 371 | params_new->tcft_action = parm->t_action; | 380 | params_new->tcft_action = parm->t_action; |
| 372 | params_new->tcft_enc_metadata = metadata; | 381 | params_new->tcft_enc_metadata = metadata; |
| 373 | 382 | ||
| 374 | spin_lock_bh(&t->tcf_lock); | 383 | spin_lock_bh(&t->tcf_lock); |
| 375 | t->tcf_action = parm->action; | 384 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 376 | rcu_swap_protected(t->params, params_new, | 385 | rcu_swap_protected(t->params, params_new, |
| 377 | lockdep_is_held(&t->tcf_lock)); | 386 | lockdep_is_held(&t->tcf_lock)); |
| 378 | spin_unlock_bh(&t->tcf_lock); | 387 | spin_unlock_bh(&t->tcf_lock); |
| 379 | tunnel_key_release_params(params_new); | 388 | tunnel_key_release_params(params_new); |
| 389 | if (goto_ch) | ||
| 390 | tcf_chain_put_by_act(goto_ch); | ||
| 380 | 391 | ||
| 381 | if (ret == ACT_P_CREATED) | 392 | if (ret == ACT_P_CREATED) |
| 382 | tcf_idr_insert(tn, *a); | 393 | tcf_idr_insert(tn, *a); |
| 383 | 394 | ||
| 384 | return ret; | 395 | return ret; |
| 385 | 396 | ||
| 397 | put_chain: | ||
| 398 | if (goto_ch) | ||
| 399 | tcf_chain_put_by_act(goto_ch); | ||
| 400 | |||
| 386 | release_tun_meta: | 401 | release_tun_meta: |
| 387 | if (metadata) | 402 | if (metadata) |
| 388 | dst_release(&metadata->dst); | 403 | dst_release(&metadata->dst); |
diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index ac0061599225..0f40d0a74423 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/if_vlan.h> | 15 | #include <linux/if_vlan.h> |
| 16 | #include <net/netlink.h> | 16 | #include <net/netlink.h> |
| 17 | #include <net/pkt_sched.h> | 17 | #include <net/pkt_sched.h> |
| 18 | #include <net/pkt_cls.h> | ||
| 18 | 19 | ||
| 19 | #include <linux/tc_act/tc_vlan.h> | 20 | #include <linux/tc_act/tc_vlan.h> |
| 20 | #include <net/tc_act/tc_vlan.h> | 21 | #include <net/tc_act/tc_vlan.h> |
| @@ -105,10 +106,11 @@ static const struct nla_policy vlan_policy[TCA_VLAN_MAX + 1] = { | |||
| 105 | static int tcf_vlan_init(struct net *net, struct nlattr *nla, | 106 | static int tcf_vlan_init(struct net *net, struct nlattr *nla, |
| 106 | struct nlattr *est, struct tc_action **a, | 107 | struct nlattr *est, struct tc_action **a, |
| 107 | int ovr, int bind, bool rtnl_held, | 108 | int ovr, int bind, bool rtnl_held, |
| 108 | struct netlink_ext_ack *extack) | 109 | struct tcf_proto *tp, struct netlink_ext_ack *extack) |
| 109 | { | 110 | { |
| 110 | struct tc_action_net *tn = net_generic(net, vlan_net_id); | 111 | struct tc_action_net *tn = net_generic(net, vlan_net_id); |
| 111 | struct nlattr *tb[TCA_VLAN_MAX + 1]; | 112 | struct nlattr *tb[TCA_VLAN_MAX + 1]; |
| 113 | struct tcf_chain *goto_ch = NULL; | ||
| 112 | struct tcf_vlan_params *p; | 114 | struct tcf_vlan_params *p; |
| 113 | struct tc_vlan *parm; | 115 | struct tc_vlan *parm; |
| 114 | struct tcf_vlan *v; | 116 | struct tcf_vlan *v; |
| @@ -200,12 +202,16 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, | |||
| 200 | return -EEXIST; | 202 | return -EEXIST; |
| 201 | } | 203 | } |
| 202 | 204 | ||
| 205 | err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); | ||
| 206 | if (err < 0) | ||
| 207 | goto release_idr; | ||
| 208 | |||
| 203 | v = to_vlan(*a); | 209 | v = to_vlan(*a); |
| 204 | 210 | ||
| 205 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 211 | p = kzalloc(sizeof(*p), GFP_KERNEL); |
| 206 | if (!p) { | 212 | if (!p) { |
| 207 | tcf_idr_release(*a, bind); | 213 | err = -ENOMEM; |
| 208 | return -ENOMEM; | 214 | goto put_chain; |
| 209 | } | 215 | } |
| 210 | 216 | ||
| 211 | p->tcfv_action = action; | 217 | p->tcfv_action = action; |
| @@ -214,16 +220,24 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, | |||
| 214 | p->tcfv_push_proto = push_proto; | 220 | p->tcfv_push_proto = push_proto; |
| 215 | 221 | ||
| 216 | spin_lock_bh(&v->tcf_lock); | 222 | spin_lock_bh(&v->tcf_lock); |
| 217 | v->tcf_action = parm->action; | 223 | goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); |
| 218 | rcu_swap_protected(v->vlan_p, p, lockdep_is_held(&v->tcf_lock)); | 224 | rcu_swap_protected(v->vlan_p, p, lockdep_is_held(&v->tcf_lock)); |
| 219 | spin_unlock_bh(&v->tcf_lock); | 225 | spin_unlock_bh(&v->tcf_lock); |
| 220 | 226 | ||
| 227 | if (goto_ch) | ||
| 228 | tcf_chain_put_by_act(goto_ch); | ||
| 221 | if (p) | 229 | if (p) |
| 222 | kfree_rcu(p, rcu); | 230 | kfree_rcu(p, rcu); |
| 223 | 231 | ||
| 224 | if (ret == ACT_P_CREATED) | 232 | if (ret == ACT_P_CREATED) |
| 225 | tcf_idr_insert(tn, *a); | 233 | tcf_idr_insert(tn, *a); |
| 226 | return ret; | 234 | return ret; |
| 235 | put_chain: | ||
| 236 | if (goto_ch) | ||
| 237 | tcf_chain_put_by_act(goto_ch); | ||
| 238 | release_idr: | ||
| 239 | tcf_idr_release(*a, bind); | ||
| 240 | return err; | ||
| 227 | } | 241 | } |
| 228 | 242 | ||
| 229 | static void tcf_vlan_cleanup(struct tc_action *a) | 243 | static void tcf_vlan_cleanup(struct tc_action *a) |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index dc10525e90e7..99ae30c177c7 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
| @@ -367,7 +367,7 @@ static void tcf_chain_destroy(struct tcf_chain *chain, bool free_block) | |||
| 367 | struct tcf_block *block = chain->block; | 367 | struct tcf_block *block = chain->block; |
| 368 | 368 | ||
| 369 | mutex_destroy(&chain->filter_chain_lock); | 369 | mutex_destroy(&chain->filter_chain_lock); |
| 370 | kfree(chain); | 370 | kfree_rcu(chain, rcu); |
| 371 | if (free_block) | 371 | if (free_block) |
| 372 | tcf_block_destroy(block); | 372 | tcf_block_destroy(block); |
| 373 | } | 373 | } |
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index 1d2a12132abc..acc9b9da985f 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c | |||
| @@ -211,6 +211,9 @@ struct cake_sched_data { | |||
| 211 | u8 ack_filter; | 211 | u8 ack_filter; |
| 212 | u8 atm_mode; | 212 | u8 atm_mode; |
| 213 | 213 | ||
| 214 | u32 fwmark_mask; | ||
| 215 | u16 fwmark_shft; | ||
| 216 | |||
| 214 | /* time_next = time_this + ((len * rate_ns) >> rate_shft) */ | 217 | /* time_next = time_this + ((len * rate_ns) >> rate_shft) */ |
| 215 | u16 rate_shft; | 218 | u16 rate_shft; |
| 216 | ktime_t time_next_packet; | 219 | ktime_t time_next_packet; |
| @@ -258,8 +261,7 @@ enum { | |||
| 258 | CAKE_FLAG_AUTORATE_INGRESS = BIT(1), | 261 | CAKE_FLAG_AUTORATE_INGRESS = BIT(1), |
| 259 | CAKE_FLAG_INGRESS = BIT(2), | 262 | CAKE_FLAG_INGRESS = BIT(2), |
| 260 | CAKE_FLAG_WASH = BIT(3), | 263 | CAKE_FLAG_WASH = BIT(3), |
| 261 | CAKE_FLAG_SPLIT_GSO = BIT(4), | 264 | CAKE_FLAG_SPLIT_GSO = BIT(4) |
| 262 | CAKE_FLAG_FWMARK = BIT(5) | ||
| 263 | }; | 265 | }; |
| 264 | 266 | ||
| 265 | /* COBALT operates the Codel and BLUE algorithms in parallel, in order to | 267 | /* COBALT operates the Codel and BLUE algorithms in parallel, in order to |
| @@ -1543,7 +1545,7 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch, | |||
| 1543 | struct sk_buff *skb) | 1545 | struct sk_buff *skb) |
| 1544 | { | 1546 | { |
| 1545 | struct cake_sched_data *q = qdisc_priv(sch); | 1547 | struct cake_sched_data *q = qdisc_priv(sch); |
| 1546 | u32 tin; | 1548 | u32 tin, mark; |
| 1547 | u8 dscp; | 1549 | u8 dscp; |
| 1548 | 1550 | ||
| 1549 | /* Tin selection: Default to diffserv-based selection, allow overriding | 1551 | /* Tin selection: Default to diffserv-based selection, allow overriding |
| @@ -1551,14 +1553,13 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch, | |||
| 1551 | */ | 1553 | */ |
| 1552 | dscp = cake_handle_diffserv(skb, | 1554 | dscp = cake_handle_diffserv(skb, |
| 1553 | q->rate_flags & CAKE_FLAG_WASH); | 1555 | q->rate_flags & CAKE_FLAG_WASH); |
| 1556 | mark = (skb->mark & q->fwmark_mask) >> q->fwmark_shft; | ||
| 1554 | 1557 | ||
| 1555 | if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT) | 1558 | if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT) |
| 1556 | tin = 0; | 1559 | tin = 0; |
| 1557 | 1560 | ||
| 1558 | else if (q->rate_flags & CAKE_FLAG_FWMARK && /* use fw mark */ | 1561 | else if (mark && mark <= q->tin_cnt) |
| 1559 | skb->mark && | 1562 | tin = q->tin_order[mark - 1]; |
| 1560 | skb->mark <= q->tin_cnt) | ||
| 1561 | tin = q->tin_order[skb->mark - 1]; | ||
| 1562 | 1563 | ||
| 1563 | else if (TC_H_MAJ(skb->priority) == sch->handle && | 1564 | else if (TC_H_MAJ(skb->priority) == sch->handle && |
| 1564 | TC_H_MIN(skb->priority) > 0 && | 1565 | TC_H_MIN(skb->priority) > 0 && |
| @@ -2172,6 +2173,7 @@ static const struct nla_policy cake_policy[TCA_CAKE_MAX + 1] = { | |||
| 2172 | [TCA_CAKE_MPU] = { .type = NLA_U32 }, | 2173 | [TCA_CAKE_MPU] = { .type = NLA_U32 }, |
| 2173 | [TCA_CAKE_INGRESS] = { .type = NLA_U32 }, | 2174 | [TCA_CAKE_INGRESS] = { .type = NLA_U32 }, |
| 2174 | [TCA_CAKE_ACK_FILTER] = { .type = NLA_U32 }, | 2175 | [TCA_CAKE_ACK_FILTER] = { .type = NLA_U32 }, |
| 2176 | [TCA_CAKE_FWMARK] = { .type = NLA_U32 }, | ||
| 2175 | }; | 2177 | }; |
| 2176 | 2178 | ||
| 2177 | static void cake_set_rate(struct cake_tin_data *b, u64 rate, u32 mtu, | 2179 | static void cake_set_rate(struct cake_tin_data *b, u64 rate, u32 mtu, |
| @@ -2619,10 +2621,8 @@ static int cake_change(struct Qdisc *sch, struct nlattr *opt, | |||
| 2619 | } | 2621 | } |
| 2620 | 2622 | ||
| 2621 | if (tb[TCA_CAKE_FWMARK]) { | 2623 | if (tb[TCA_CAKE_FWMARK]) { |
| 2622 | if (!!nla_get_u32(tb[TCA_CAKE_FWMARK])) | 2624 | q->fwmark_mask = nla_get_u32(tb[TCA_CAKE_FWMARK]); |
| 2623 | q->rate_flags |= CAKE_FLAG_FWMARK; | 2625 | q->fwmark_shft = q->fwmark_mask ? __ffs(q->fwmark_mask) : 0; |
| 2624 | else | ||
| 2625 | q->rate_flags &= ~CAKE_FLAG_FWMARK; | ||
| 2626 | } | 2626 | } |
| 2627 | 2627 | ||
| 2628 | if (q->tins) { | 2628 | if (q->tins) { |
| @@ -2784,8 +2784,7 @@ static int cake_dump(struct Qdisc *sch, struct sk_buff *skb) | |||
| 2784 | !!(q->rate_flags & CAKE_FLAG_SPLIT_GSO))) | 2784 | !!(q->rate_flags & CAKE_FLAG_SPLIT_GSO))) |
| 2785 | goto nla_put_failure; | 2785 | goto nla_put_failure; |
| 2786 | 2786 | ||
| 2787 | if (nla_put_u32(skb, TCA_CAKE_FWMARK, | 2787 | if (nla_put_u32(skb, TCA_CAKE_FWMARK, q->fwmark_mask)) |
| 2788 | !!(q->rate_flags & CAKE_FLAG_FWMARK))) | ||
| 2789 | goto nla_put_failure; | 2788 | goto nla_put_failure; |
| 2790 | 2789 | ||
| 2791 | return nla_nest_end(skb, opts); | 2790 | return nla_nest_end(skb, opts); |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 6140471efd4b..9874e60c9b0d 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
| @@ -999,7 +999,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, | |||
| 999 | if (unlikely(addrs_size <= 0)) | 999 | if (unlikely(addrs_size <= 0)) |
| 1000 | return -EINVAL; | 1000 | return -EINVAL; |
| 1001 | 1001 | ||
| 1002 | kaddrs = vmemdup_user(addrs, addrs_size); | 1002 | kaddrs = memdup_user(addrs, addrs_size); |
| 1003 | if (unlikely(IS_ERR(kaddrs))) | 1003 | if (unlikely(IS_ERR(kaddrs))) |
| 1004 | return PTR_ERR(kaddrs); | 1004 | return PTR_ERR(kaddrs); |
| 1005 | 1005 | ||
| @@ -1007,7 +1007,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, | |||
| 1007 | addr_buf = kaddrs; | 1007 | addr_buf = kaddrs; |
| 1008 | while (walk_size < addrs_size) { | 1008 | while (walk_size < addrs_size) { |
| 1009 | if (walk_size + sizeof(sa_family_t) > addrs_size) { | 1009 | if (walk_size + sizeof(sa_family_t) > addrs_size) { |
| 1010 | kvfree(kaddrs); | 1010 | kfree(kaddrs); |
| 1011 | return -EINVAL; | 1011 | return -EINVAL; |
| 1012 | } | 1012 | } |
| 1013 | 1013 | ||
| @@ -1018,7 +1018,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, | |||
| 1018 | * causes the address buffer to overflow return EINVAL. | 1018 | * causes the address buffer to overflow return EINVAL. |
| 1019 | */ | 1019 | */ |
| 1020 | if (!af || (walk_size + af->sockaddr_len) > addrs_size) { | 1020 | if (!af || (walk_size + af->sockaddr_len) > addrs_size) { |
| 1021 | kvfree(kaddrs); | 1021 | kfree(kaddrs); |
| 1022 | return -EINVAL; | 1022 | return -EINVAL; |
| 1023 | } | 1023 | } |
| 1024 | addrcnt++; | 1024 | addrcnt++; |
| @@ -1054,7 +1054,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, | |||
| 1054 | } | 1054 | } |
| 1055 | 1055 | ||
| 1056 | out: | 1056 | out: |
| 1057 | kvfree(kaddrs); | 1057 | kfree(kaddrs); |
| 1058 | 1058 | ||
| 1059 | return err; | 1059 | return err; |
| 1060 | } | 1060 | } |
| @@ -1329,7 +1329,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk, | |||
| 1329 | if (unlikely(addrs_size <= 0)) | 1329 | if (unlikely(addrs_size <= 0)) |
| 1330 | return -EINVAL; | 1330 | return -EINVAL; |
| 1331 | 1331 | ||
| 1332 | kaddrs = vmemdup_user(addrs, addrs_size); | 1332 | kaddrs = memdup_user(addrs, addrs_size); |
| 1333 | if (unlikely(IS_ERR(kaddrs))) | 1333 | if (unlikely(IS_ERR(kaddrs))) |
| 1334 | return PTR_ERR(kaddrs); | 1334 | return PTR_ERR(kaddrs); |
| 1335 | 1335 | ||
| @@ -1349,7 +1349,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk, | |||
| 1349 | err = __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id); | 1349 | err = __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id); |
| 1350 | 1350 | ||
| 1351 | out_free: | 1351 | out_free: |
| 1352 | kvfree(kaddrs); | 1352 | kfree(kaddrs); |
| 1353 | 1353 | ||
| 1354 | return err; | 1354 | return err; |
| 1355 | } | 1355 | } |
| @@ -2920,6 +2920,9 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk, | |||
| 2920 | return 0; | 2920 | return 0; |
| 2921 | } | 2921 | } |
| 2922 | 2922 | ||
| 2923 | if (sctp_style(sk, TCP)) | ||
| 2924 | params.sack_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 2925 | |||
| 2923 | if (params.sack_assoc_id == SCTP_FUTURE_ASSOC || | 2926 | if (params.sack_assoc_id == SCTP_FUTURE_ASSOC || |
| 2924 | params.sack_assoc_id == SCTP_ALL_ASSOC) { | 2927 | params.sack_assoc_id == SCTP_ALL_ASSOC) { |
| 2925 | if (params.sack_delay) { | 2928 | if (params.sack_delay) { |
| @@ -3024,6 +3027,9 @@ static int sctp_setsockopt_default_send_param(struct sock *sk, | |||
| 3024 | return 0; | 3027 | return 0; |
| 3025 | } | 3028 | } |
| 3026 | 3029 | ||
| 3030 | if (sctp_style(sk, TCP)) | ||
| 3031 | info.sinfo_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 3032 | |||
| 3027 | if (info.sinfo_assoc_id == SCTP_FUTURE_ASSOC || | 3033 | if (info.sinfo_assoc_id == SCTP_FUTURE_ASSOC || |
| 3028 | info.sinfo_assoc_id == SCTP_ALL_ASSOC) { | 3034 | info.sinfo_assoc_id == SCTP_ALL_ASSOC) { |
| 3029 | sp->default_stream = info.sinfo_stream; | 3035 | sp->default_stream = info.sinfo_stream; |
| @@ -3081,6 +3087,9 @@ static int sctp_setsockopt_default_sndinfo(struct sock *sk, | |||
| 3081 | return 0; | 3087 | return 0; |
| 3082 | } | 3088 | } |
| 3083 | 3089 | ||
| 3090 | if (sctp_style(sk, TCP)) | ||
| 3091 | info.snd_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 3092 | |||
| 3084 | if (info.snd_assoc_id == SCTP_FUTURE_ASSOC || | 3093 | if (info.snd_assoc_id == SCTP_FUTURE_ASSOC || |
| 3085 | info.snd_assoc_id == SCTP_ALL_ASSOC) { | 3094 | info.snd_assoc_id == SCTP_ALL_ASSOC) { |
| 3086 | sp->default_stream = info.snd_sid; | 3095 | sp->default_stream = info.snd_sid; |
| @@ -3531,6 +3540,9 @@ static int sctp_setsockopt_context(struct sock *sk, char __user *optval, | |||
| 3531 | return 0; | 3540 | return 0; |
| 3532 | } | 3541 | } |
| 3533 | 3542 | ||
| 3543 | if (sctp_style(sk, TCP)) | ||
| 3544 | params.assoc_id = SCTP_FUTURE_ASSOC; | ||
| 3545 | |||
| 3534 | if (params.assoc_id == SCTP_FUTURE_ASSOC || | 3546 | if (params.assoc_id == SCTP_FUTURE_ASSOC || |
| 3535 | params.assoc_id == SCTP_ALL_ASSOC) | 3547 | params.assoc_id == SCTP_ALL_ASSOC) |
| 3536 | sp->default_rcv_context = params.assoc_value; | 3548 | sp->default_rcv_context = params.assoc_value; |
| @@ -3670,6 +3682,9 @@ static int sctp_setsockopt_maxburst(struct sock *sk, | |||
| 3670 | return 0; | 3682 | return 0; |
| 3671 | } | 3683 | } |
| 3672 | 3684 | ||
| 3685 | if (sctp_style(sk, TCP)) | ||
| 3686 | params.assoc_id = SCTP_FUTURE_ASSOC; | ||
| 3687 | |||
| 3673 | if (params.assoc_id == SCTP_FUTURE_ASSOC || | 3688 | if (params.assoc_id == SCTP_FUTURE_ASSOC || |
| 3674 | params.assoc_id == SCTP_ALL_ASSOC) | 3689 | params.assoc_id == SCTP_ALL_ASSOC) |
| 3675 | sp->max_burst = params.assoc_value; | 3690 | sp->max_burst = params.assoc_value; |
| @@ -3798,6 +3813,9 @@ static int sctp_setsockopt_auth_key(struct sock *sk, | |||
| 3798 | goto out; | 3813 | goto out; |
| 3799 | } | 3814 | } |
| 3800 | 3815 | ||
| 3816 | if (sctp_style(sk, TCP)) | ||
| 3817 | authkey->sca_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 3818 | |||
| 3801 | if (authkey->sca_assoc_id == SCTP_FUTURE_ASSOC || | 3819 | if (authkey->sca_assoc_id == SCTP_FUTURE_ASSOC || |
| 3802 | authkey->sca_assoc_id == SCTP_ALL_ASSOC) { | 3820 | authkey->sca_assoc_id == SCTP_ALL_ASSOC) { |
| 3803 | ret = sctp_auth_set_key(ep, asoc, authkey); | 3821 | ret = sctp_auth_set_key(ep, asoc, authkey); |
| @@ -3853,6 +3871,9 @@ static int sctp_setsockopt_active_key(struct sock *sk, | |||
| 3853 | if (asoc) | 3871 | if (asoc) |
| 3854 | return sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); | 3872 | return sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); |
| 3855 | 3873 | ||
| 3874 | if (sctp_style(sk, TCP)) | ||
| 3875 | val.scact_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 3876 | |||
| 3856 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | 3877 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || |
| 3857 | val.scact_assoc_id == SCTP_ALL_ASSOC) { | 3878 | val.scact_assoc_id == SCTP_ALL_ASSOC) { |
| 3858 | ret = sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); | 3879 | ret = sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); |
| @@ -3904,6 +3925,9 @@ static int sctp_setsockopt_del_key(struct sock *sk, | |||
| 3904 | if (asoc) | 3925 | if (asoc) |
| 3905 | return sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); | 3926 | return sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); |
| 3906 | 3927 | ||
| 3928 | if (sctp_style(sk, TCP)) | ||
| 3929 | val.scact_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 3930 | |||
| 3907 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | 3931 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || |
| 3908 | val.scact_assoc_id == SCTP_ALL_ASSOC) { | 3932 | val.scact_assoc_id == SCTP_ALL_ASSOC) { |
| 3909 | ret = sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); | 3933 | ret = sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); |
| @@ -3954,6 +3978,9 @@ static int sctp_setsockopt_deactivate_key(struct sock *sk, char __user *optval, | |||
| 3954 | if (asoc) | 3978 | if (asoc) |
| 3955 | return sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); | 3979 | return sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); |
| 3956 | 3980 | ||
| 3981 | if (sctp_style(sk, TCP)) | ||
| 3982 | val.scact_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 3983 | |||
| 3957 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | 3984 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || |
| 3958 | val.scact_assoc_id == SCTP_ALL_ASSOC) { | 3985 | val.scact_assoc_id == SCTP_ALL_ASSOC) { |
| 3959 | ret = sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); | 3986 | ret = sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); |
| @@ -4169,6 +4196,9 @@ static int sctp_setsockopt_default_prinfo(struct sock *sk, | |||
| 4169 | goto out; | 4196 | goto out; |
| 4170 | } | 4197 | } |
| 4171 | 4198 | ||
| 4199 | if (sctp_style(sk, TCP)) | ||
| 4200 | info.pr_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 4201 | |||
| 4172 | if (info.pr_assoc_id == SCTP_FUTURE_ASSOC || | 4202 | if (info.pr_assoc_id == SCTP_FUTURE_ASSOC || |
| 4173 | info.pr_assoc_id == SCTP_ALL_ASSOC) { | 4203 | info.pr_assoc_id == SCTP_ALL_ASSOC) { |
| 4174 | SCTP_PR_SET_POLICY(sp->default_flags, info.pr_policy); | 4204 | SCTP_PR_SET_POLICY(sp->default_flags, info.pr_policy); |
| @@ -4251,6 +4281,9 @@ static int sctp_setsockopt_enable_strreset(struct sock *sk, | |||
| 4251 | goto out; | 4281 | goto out; |
| 4252 | } | 4282 | } |
| 4253 | 4283 | ||
| 4284 | if (sctp_style(sk, TCP)) | ||
| 4285 | params.assoc_id = SCTP_FUTURE_ASSOC; | ||
| 4286 | |||
| 4254 | if (params.assoc_id == SCTP_FUTURE_ASSOC || | 4287 | if (params.assoc_id == SCTP_FUTURE_ASSOC || |
| 4255 | params.assoc_id == SCTP_ALL_ASSOC) | 4288 | params.assoc_id == SCTP_ALL_ASSOC) |
| 4256 | ep->strreset_enable = params.assoc_value; | 4289 | ep->strreset_enable = params.assoc_value; |
| @@ -4376,6 +4409,9 @@ static int sctp_setsockopt_scheduler(struct sock *sk, | |||
| 4376 | if (asoc) | 4409 | if (asoc) |
| 4377 | return sctp_sched_set_sched(asoc, params.assoc_value); | 4410 | return sctp_sched_set_sched(asoc, params.assoc_value); |
| 4378 | 4411 | ||
| 4412 | if (sctp_style(sk, TCP)) | ||
| 4413 | params.assoc_id = SCTP_FUTURE_ASSOC; | ||
| 4414 | |||
| 4379 | if (params.assoc_id == SCTP_FUTURE_ASSOC || | 4415 | if (params.assoc_id == SCTP_FUTURE_ASSOC || |
| 4380 | params.assoc_id == SCTP_ALL_ASSOC) | 4416 | params.assoc_id == SCTP_ALL_ASSOC) |
| 4381 | sp->default_ss = params.assoc_value; | 4417 | sp->default_ss = params.assoc_value; |
| @@ -4541,6 +4577,9 @@ static int sctp_setsockopt_event(struct sock *sk, char __user *optval, | |||
| 4541 | if (asoc) | 4577 | if (asoc) |
| 4542 | return sctp_assoc_ulpevent_type_set(¶m, asoc); | 4578 | return sctp_assoc_ulpevent_type_set(¶m, asoc); |
| 4543 | 4579 | ||
| 4580 | if (sctp_style(sk, TCP)) | ||
| 4581 | param.se_assoc_id = SCTP_FUTURE_ASSOC; | ||
| 4582 | |||
| 4544 | if (param.se_assoc_id == SCTP_FUTURE_ASSOC || | 4583 | if (param.se_assoc_id == SCTP_FUTURE_ASSOC || |
| 4545 | param.se_assoc_id == SCTP_ALL_ASSOC) | 4584 | param.se_assoc_id == SCTP_ALL_ASSOC) |
| 4546 | sctp_ulpevent_type_set(&sp->subscribe, | 4585 | sctp_ulpevent_type_set(&sp->subscribe, |
| @@ -9169,7 +9208,7 @@ static inline void sctp_copy_descendant(struct sock *sk_to, | |||
| 9169 | { | 9208 | { |
| 9170 | int ancestor_size = sizeof(struct inet_sock) + | 9209 | int ancestor_size = sizeof(struct inet_sock) + |
| 9171 | sizeof(struct sctp_sock) - | 9210 | sizeof(struct sctp_sock) - |
| 9172 | offsetof(struct sctp_sock, auto_asconf_list); | 9211 | offsetof(struct sctp_sock, pd_lobby); |
| 9173 | 9212 | ||
| 9174 | if (sk_from->sk_family == PF_INET6) | 9213 | if (sk_from->sk_family == PF_INET6) |
| 9175 | ancestor_size += sizeof(struct ipv6_pinfo); | 9214 | ancestor_size += sizeof(struct ipv6_pinfo); |
| @@ -9253,7 +9292,6 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk, | |||
| 9253 | * 2) Peeling off partial delivery; keep pd_lobby in new pd_lobby. | 9292 | * 2) Peeling off partial delivery; keep pd_lobby in new pd_lobby. |
| 9254 | * 3) Peeling off non-partial delivery; move pd_lobby to receive_queue. | 9293 | * 3) Peeling off non-partial delivery; move pd_lobby to receive_queue. |
| 9255 | */ | 9294 | */ |
| 9256 | skb_queue_head_init(&newsp->pd_lobby); | ||
| 9257 | atomic_set(&sctp_sk(newsk)->pd_mode, assoc->ulpq.pd_mode); | 9295 | atomic_set(&sctp_sk(newsk)->pd_mode, assoc->ulpq.pd_mode); |
| 9258 | 9296 | ||
| 9259 | if (atomic_read(&sctp_sk(oldsk)->pd_mode)) { | 9297 | if (atomic_read(&sctp_sk(oldsk)->pd_mode)) { |
diff --git a/net/socket.c b/net/socket.c index 3c176a12fe48..8255f5bda0aa 100644 --- a/net/socket.c +++ b/net/socket.c | |||
| @@ -384,6 +384,18 @@ static struct file_system_type sock_fs_type = { | |||
| 384 | * but we take care of internal coherence yet. | 384 | * but we take care of internal coherence yet. |
| 385 | */ | 385 | */ |
| 386 | 386 | ||
| 387 | /** | ||
| 388 | * sock_alloc_file - Bind a &socket to a &file | ||
| 389 | * @sock: socket | ||
| 390 | * @flags: file status flags | ||
| 391 | * @dname: protocol name | ||
| 392 | * | ||
| 393 | * Returns the &file bound with @sock, implicitly storing it | ||
| 394 | * in sock->file. If dname is %NULL, sets to "". | ||
| 395 | * On failure the return is a ERR pointer (see linux/err.h). | ||
| 396 | * This function uses GFP_KERNEL internally. | ||
| 397 | */ | ||
| 398 | |||
| 387 | struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname) | 399 | struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname) |
| 388 | { | 400 | { |
| 389 | struct file *file; | 401 | struct file *file; |
| @@ -424,6 +436,14 @@ static int sock_map_fd(struct socket *sock, int flags) | |||
| 424 | return PTR_ERR(newfile); | 436 | return PTR_ERR(newfile); |
| 425 | } | 437 | } |
| 426 | 438 | ||
| 439 | /** | ||
| 440 | * sock_from_file - Return the &socket bounded to @file. | ||
| 441 | * @file: file | ||
| 442 | * @err: pointer to an error code return | ||
| 443 | * | ||
| 444 | * On failure returns %NULL and assigns -ENOTSOCK to @err. | ||
| 445 | */ | ||
| 446 | |||
| 427 | struct socket *sock_from_file(struct file *file, int *err) | 447 | struct socket *sock_from_file(struct file *file, int *err) |
| 428 | { | 448 | { |
| 429 | if (file->f_op == &socket_file_ops) | 449 | if (file->f_op == &socket_file_ops) |
| @@ -532,11 +552,11 @@ static const struct inode_operations sockfs_inode_ops = { | |||
| 532 | }; | 552 | }; |
| 533 | 553 | ||
| 534 | /** | 554 | /** |
| 535 | * sock_alloc - allocate a socket | 555 | * sock_alloc - allocate a socket |
| 536 | * | 556 | * |
| 537 | * Allocate a new inode and socket object. The two are bound together | 557 | * Allocate a new inode and socket object. The two are bound together |
| 538 | * and initialised. The socket is then returned. If we are out of inodes | 558 | * and initialised. The socket is then returned. If we are out of inodes |
| 539 | * NULL is returned. | 559 | * NULL is returned. This functions uses GFP_KERNEL internally. |
| 540 | */ | 560 | */ |
| 541 | 561 | ||
| 542 | struct socket *sock_alloc(void) | 562 | struct socket *sock_alloc(void) |
| @@ -561,7 +581,7 @@ struct socket *sock_alloc(void) | |||
| 561 | EXPORT_SYMBOL(sock_alloc); | 581 | EXPORT_SYMBOL(sock_alloc); |
| 562 | 582 | ||
| 563 | /** | 583 | /** |
| 564 | * sock_release - close a socket | 584 | * sock_release - close a socket |
| 565 | * @sock: socket to close | 585 | * @sock: socket to close |
| 566 | * | 586 | * |
| 567 | * The socket is released from the protocol stack if it has a release | 587 | * The socket is released from the protocol stack if it has a release |
| @@ -617,6 +637,15 @@ void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags) | |||
| 617 | } | 637 | } |
| 618 | EXPORT_SYMBOL(__sock_tx_timestamp); | 638 | EXPORT_SYMBOL(__sock_tx_timestamp); |
| 619 | 639 | ||
| 640 | /** | ||
| 641 | * sock_sendmsg - send a message through @sock | ||
| 642 | * @sock: socket | ||
| 643 | * @msg: message to send | ||
| 644 | * | ||
| 645 | * Sends @msg through @sock, passing through LSM. | ||
| 646 | * Returns the number of bytes sent, or an error code. | ||
| 647 | */ | ||
| 648 | |||
| 620 | static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg) | 649 | static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg) |
| 621 | { | 650 | { |
| 622 | int ret = sock->ops->sendmsg(sock, msg, msg_data_left(msg)); | 651 | int ret = sock->ops->sendmsg(sock, msg, msg_data_left(msg)); |
| @@ -633,6 +662,18 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg) | |||
| 633 | } | 662 | } |
| 634 | EXPORT_SYMBOL(sock_sendmsg); | 663 | EXPORT_SYMBOL(sock_sendmsg); |
| 635 | 664 | ||
| 665 | /** | ||
| 666 | * kernel_sendmsg - send a message through @sock (kernel-space) | ||
| 667 | * @sock: socket | ||
| 668 | * @msg: message header | ||
| 669 | * @vec: kernel vec | ||
| 670 | * @num: vec array length | ||
| 671 | * @size: total message data size | ||
| 672 | * | ||
| 673 | * Builds the message data with @vec and sends it through @sock. | ||
| 674 | * Returns the number of bytes sent, or an error code. | ||
| 675 | */ | ||
| 676 | |||
| 636 | int kernel_sendmsg(struct socket *sock, struct msghdr *msg, | 677 | int kernel_sendmsg(struct socket *sock, struct msghdr *msg, |
| 637 | struct kvec *vec, size_t num, size_t size) | 678 | struct kvec *vec, size_t num, size_t size) |
| 638 | { | 679 | { |
| @@ -641,6 +682,19 @@ int kernel_sendmsg(struct socket *sock, struct msghdr *msg, | |||
| 641 | } | 682 | } |
| 642 | EXPORT_SYMBOL(kernel_sendmsg); | 683 | EXPORT_SYMBOL(kernel_sendmsg); |
| 643 | 684 | ||
| 685 | /** | ||
| 686 | * kernel_sendmsg_locked - send a message through @sock (kernel-space) | ||
| 687 | * @sk: sock | ||
| 688 | * @msg: message header | ||
| 689 | * @vec: output s/g array | ||
| 690 | * @num: output s/g array length | ||
| 691 | * @size: total message data size | ||
| 692 | * | ||
| 693 | * Builds the message data with @vec and sends it through @sock. | ||
| 694 | * Returns the number of bytes sent, or an error code. | ||
| 695 | * Caller must hold @sk. | ||
| 696 | */ | ||
| 697 | |||
| 644 | int kernel_sendmsg_locked(struct sock *sk, struct msghdr *msg, | 698 | int kernel_sendmsg_locked(struct sock *sk, struct msghdr *msg, |
| 645 | struct kvec *vec, size_t num, size_t size) | 699 | struct kvec *vec, size_t num, size_t size) |
| 646 | { | 700 | { |
| @@ -811,6 +865,16 @@ void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, | |||
| 811 | } | 865 | } |
| 812 | EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops); | 866 | EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops); |
| 813 | 867 | ||
| 868 | /** | ||
| 869 | * sock_recvmsg - receive a message from @sock | ||
| 870 | * @sock: socket | ||
| 871 | * @msg: message to receive | ||
| 872 | * @flags: message flags | ||
| 873 | * | ||
| 874 | * Receives @msg from @sock, passing through LSM. Returns the total number | ||
| 875 | * of bytes received, or an error. | ||
| 876 | */ | ||
| 877 | |||
| 814 | static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, | 878 | static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, |
| 815 | int flags) | 879 | int flags) |
| 816 | { | 880 | { |
| @@ -826,20 +890,21 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags) | |||
| 826 | EXPORT_SYMBOL(sock_recvmsg); | 890 | EXPORT_SYMBOL(sock_recvmsg); |
| 827 | 891 | ||
| 828 | /** | 892 | /** |
| 829 | * kernel_recvmsg - Receive a message from a socket (kernel space) | 893 | * kernel_recvmsg - Receive a message from a socket (kernel space) |
| 830 | * @sock: The socket to receive the message from | 894 | * @sock: The socket to receive the message from |
| 831 | * @msg: Received message | 895 | * @msg: Received message |
| 832 | * @vec: Input s/g array for message data | 896 | * @vec: Input s/g array for message data |
| 833 | * @num: Size of input s/g array | 897 | * @num: Size of input s/g array |
| 834 | * @size: Number of bytes to read | 898 | * @size: Number of bytes to read |
| 835 | * @flags: Message flags (MSG_DONTWAIT, etc...) | 899 | * @flags: Message flags (MSG_DONTWAIT, etc...) |
| 836 | * | 900 | * |
| 837 | * On return the msg structure contains the scatter/gather array passed in the | 901 | * On return the msg structure contains the scatter/gather array passed in the |
| 838 | * vec argument. The array is modified so that it consists of the unfilled | 902 | * vec argument. The array is modified so that it consists of the unfilled |
| 839 | * portion of the original array. | 903 | * portion of the original array. |
| 840 | * | 904 | * |
| 841 | * The returned value is the total number of bytes received, or an error. | 905 | * The returned value is the total number of bytes received, or an error. |
| 842 | */ | 906 | */ |
| 907 | |||
| 843 | int kernel_recvmsg(struct socket *sock, struct msghdr *msg, | 908 | int kernel_recvmsg(struct socket *sock, struct msghdr *msg, |
| 844 | struct kvec *vec, size_t num, size_t size, int flags) | 909 | struct kvec *vec, size_t num, size_t size, int flags) |
| 845 | { | 910 | { |
| @@ -1005,6 +1070,13 @@ static long sock_do_ioctl(struct net *net, struct socket *sock, | |||
| 1005 | * what to do with it - that's up to the protocol still. | 1070 | * what to do with it - that's up to the protocol still. |
| 1006 | */ | 1071 | */ |
| 1007 | 1072 | ||
| 1073 | /** | ||
| 1074 | * get_net_ns - increment the refcount of the network namespace | ||
| 1075 | * @ns: common namespace (net) | ||
| 1076 | * | ||
| 1077 | * Returns the net's common namespace. | ||
| 1078 | */ | ||
| 1079 | |||
| 1008 | struct ns_common *get_net_ns(struct ns_common *ns) | 1080 | struct ns_common *get_net_ns(struct ns_common *ns) |
| 1009 | { | 1081 | { |
| 1010 | return &get_net(container_of(ns, struct net, ns))->ns; | 1082 | return &get_net(container_of(ns, struct net, ns))->ns; |
| @@ -1099,6 +1171,19 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
| 1099 | return err; | 1171 | return err; |
| 1100 | } | 1172 | } |
| 1101 | 1173 | ||
| 1174 | /** | ||
| 1175 | * sock_create_lite - creates a socket | ||
| 1176 | * @family: protocol family (AF_INET, ...) | ||
| 1177 | * @type: communication type (SOCK_STREAM, ...) | ||
| 1178 | * @protocol: protocol (0, ...) | ||
| 1179 | * @res: new socket | ||
| 1180 | * | ||
| 1181 | * Creates a new socket and assigns it to @res, passing through LSM. | ||
| 1182 | * The new socket initialization is not complete, see kernel_accept(). | ||
| 1183 | * Returns 0 or an error. On failure @res is set to %NULL. | ||
| 1184 | * This function internally uses GFP_KERNEL. | ||
| 1185 | */ | ||
| 1186 | |||
| 1102 | int sock_create_lite(int family, int type, int protocol, struct socket **res) | 1187 | int sock_create_lite(int family, int type, int protocol, struct socket **res) |
| 1103 | { | 1188 | { |
| 1104 | int err; | 1189 | int err; |
| @@ -1224,6 +1309,21 @@ call_kill: | |||
| 1224 | } | 1309 | } |
| 1225 | EXPORT_SYMBOL(sock_wake_async); | 1310 | EXPORT_SYMBOL(sock_wake_async); |
| 1226 | 1311 | ||
| 1312 | /** | ||
| 1313 | * __sock_create - creates a socket | ||
| 1314 | * @net: net namespace | ||
| 1315 | * @family: protocol family (AF_INET, ...) | ||
| 1316 | * @type: communication type (SOCK_STREAM, ...) | ||
| 1317 | * @protocol: protocol (0, ...) | ||
| 1318 | * @res: new socket | ||
| 1319 | * @kern: boolean for kernel space sockets | ||
| 1320 | * | ||
| 1321 | * Creates a new socket and assigns it to @res, passing through LSM. | ||
| 1322 | * Returns 0 or an error. On failure @res is set to %NULL. @kern must | ||
| 1323 | * be set to true if the socket resides in kernel space. | ||
| 1324 | * This function internally uses GFP_KERNEL. | ||
| 1325 | */ | ||
| 1326 | |||
| 1227 | int __sock_create(struct net *net, int family, int type, int protocol, | 1327 | int __sock_create(struct net *net, int family, int type, int protocol, |
| 1228 | struct socket **res, int kern) | 1328 | struct socket **res, int kern) |
| 1229 | { | 1329 | { |
| @@ -1333,12 +1433,35 @@ out_release: | |||
| 1333 | } | 1433 | } |
| 1334 | EXPORT_SYMBOL(__sock_create); | 1434 | EXPORT_SYMBOL(__sock_create); |
| 1335 | 1435 | ||
| 1436 | /** | ||
| 1437 | * sock_create - creates a socket | ||
| 1438 | * @family: protocol family (AF_INET, ...) | ||
| 1439 | * @type: communication type (SOCK_STREAM, ...) | ||
| 1440 | * @protocol: protocol (0, ...) | ||
| 1441 | * @res: new socket | ||
| 1442 | * | ||
| 1443 | * A wrapper around __sock_create(). | ||
| 1444 | * Returns 0 or an error. This function internally uses GFP_KERNEL. | ||
| 1445 | */ | ||
| 1446 | |||
| 1336 | int sock_create(int family, int type, int protocol, struct socket **res) | 1447 | int sock_create(int family, int type, int protocol, struct socket **res) |
| 1337 | { | 1448 | { |
| 1338 | return __sock_create(current->nsproxy->net_ns, family, type, protocol, res, 0); | 1449 | return __sock_create(current->nsproxy->net_ns, family, type, protocol, res, 0); |
| 1339 | } | 1450 | } |
| 1340 | EXPORT_SYMBOL(sock_create); | 1451 | EXPORT_SYMBOL(sock_create); |
| 1341 | 1452 | ||
| 1453 | /** | ||
| 1454 | * sock_create_kern - creates a socket (kernel space) | ||
| 1455 | * @net: net namespace | ||
| 1456 | * @family: protocol family (AF_INET, ...) | ||
| 1457 | * @type: communication type (SOCK_STREAM, ...) | ||
| 1458 | * @protocol: protocol (0, ...) | ||
| 1459 | * @res: new socket | ||
| 1460 | * | ||
| 1461 | * A wrapper around __sock_create(). | ||
| 1462 | * Returns 0 or an error. This function internally uses GFP_KERNEL. | ||
| 1463 | */ | ||
| 1464 | |||
| 1342 | int sock_create_kern(struct net *net, int family, int type, int protocol, struct socket **res) | 1465 | int sock_create_kern(struct net *net, int family, int type, int protocol, struct socket **res) |
| 1343 | { | 1466 | { |
| 1344 | return __sock_create(net, family, type, protocol, res, 1); | 1467 | return __sock_create(net, family, type, protocol, res, 1); |
| @@ -3322,18 +3445,46 @@ static long compat_sock_ioctl(struct file *file, unsigned int cmd, | |||
| 3322 | } | 3445 | } |
| 3323 | #endif | 3446 | #endif |
| 3324 | 3447 | ||
| 3448 | /** | ||
| 3449 | * kernel_bind - bind an address to a socket (kernel space) | ||
| 3450 | * @sock: socket | ||
| 3451 | * @addr: address | ||
| 3452 | * @addrlen: length of address | ||
| 3453 | * | ||
| 3454 | * Returns 0 or an error. | ||
| 3455 | */ | ||
| 3456 | |||
| 3325 | int kernel_bind(struct socket *sock, struct sockaddr *addr, int addrlen) | 3457 | int kernel_bind(struct socket *sock, struct sockaddr *addr, int addrlen) |
| 3326 | { | 3458 | { |
| 3327 | return sock->ops->bind(sock, addr, addrlen); | 3459 | return sock->ops->bind(sock, addr, addrlen); |
| 3328 | } | 3460 | } |
| 3329 | EXPORT_SYMBOL(kernel_bind); | 3461 | EXPORT_SYMBOL(kernel_bind); |
| 3330 | 3462 | ||
| 3463 | /** | ||
| 3464 | * kernel_listen - move socket to listening state (kernel space) | ||
| 3465 | * @sock: socket | ||
| 3466 | * @backlog: pending connections queue size | ||
| 3467 | * | ||
| 3468 | * Returns 0 or an error. | ||
| 3469 | */ | ||
| 3470 | |||
| 3331 | int kernel_listen(struct socket *sock, int backlog) | 3471 | int kernel_listen(struct socket *sock, int backlog) |
| 3332 | { | 3472 | { |
| 3333 | return sock->ops->listen(sock, backlog); | 3473 | return sock->ops->listen(sock, backlog); |
| 3334 | } | 3474 | } |
| 3335 | EXPORT_SYMBOL(kernel_listen); | 3475 | EXPORT_SYMBOL(kernel_listen); |
| 3336 | 3476 | ||
| 3477 | /** | ||
| 3478 | * kernel_accept - accept a connection (kernel space) | ||
| 3479 | * @sock: listening socket | ||
| 3480 | * @newsock: new connected socket | ||
| 3481 | * @flags: flags | ||
| 3482 | * | ||
| 3483 | * @flags must be SOCK_CLOEXEC, SOCK_NONBLOCK or 0. | ||
| 3484 | * If it fails, @newsock is guaranteed to be %NULL. | ||
| 3485 | * Returns 0 or an error. | ||
| 3486 | */ | ||
| 3487 | |||
| 3337 | int kernel_accept(struct socket *sock, struct socket **newsock, int flags) | 3488 | int kernel_accept(struct socket *sock, struct socket **newsock, int flags) |
| 3338 | { | 3489 | { |
| 3339 | struct sock *sk = sock->sk; | 3490 | struct sock *sk = sock->sk; |
| @@ -3359,6 +3510,19 @@ done: | |||
| 3359 | } | 3510 | } |
| 3360 | EXPORT_SYMBOL(kernel_accept); | 3511 | EXPORT_SYMBOL(kernel_accept); |
| 3361 | 3512 | ||
| 3513 | /** | ||
| 3514 | * kernel_connect - connect a socket (kernel space) | ||
| 3515 | * @sock: socket | ||
| 3516 | * @addr: address | ||
| 3517 | * @addrlen: address length | ||
| 3518 | * @flags: flags (O_NONBLOCK, ...) | ||
| 3519 | * | ||
| 3520 | * For datagram sockets, @addr is the addres to which datagrams are sent | ||
| 3521 | * by default, and the only address from which datagrams are received. | ||
| 3522 | * For stream sockets, attempts to connect to @addr. | ||
| 3523 | * Returns 0 or an error code. | ||
| 3524 | */ | ||
| 3525 | |||
| 3362 | int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, | 3526 | int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, |
| 3363 | int flags) | 3527 | int flags) |
| 3364 | { | 3528 | { |
| @@ -3366,18 +3530,48 @@ int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, | |||
| 3366 | } | 3530 | } |
| 3367 | EXPORT_SYMBOL(kernel_connect); | 3531 | EXPORT_SYMBOL(kernel_connect); |
| 3368 | 3532 | ||
| 3533 | /** | ||
| 3534 | * kernel_getsockname - get the address which the socket is bound (kernel space) | ||
| 3535 | * @sock: socket | ||
| 3536 | * @addr: address holder | ||
| 3537 | * | ||
| 3538 | * Fills the @addr pointer with the address which the socket is bound. | ||
| 3539 | * Returns 0 or an error code. | ||
| 3540 | */ | ||
| 3541 | |||
| 3369 | int kernel_getsockname(struct socket *sock, struct sockaddr *addr) | 3542 | int kernel_getsockname(struct socket *sock, struct sockaddr *addr) |
| 3370 | { | 3543 | { |
| 3371 | return sock->ops->getname(sock, addr, 0); | 3544 | return sock->ops->getname(sock, addr, 0); |
| 3372 | } | 3545 | } |
| 3373 | EXPORT_SYMBOL(kernel_getsockname); | 3546 | EXPORT_SYMBOL(kernel_getsockname); |
| 3374 | 3547 | ||
| 3548 | /** | ||
| 3549 | * kernel_peername - get the address which the socket is connected (kernel space) | ||
| 3550 | * @sock: socket | ||
| 3551 | * @addr: address holder | ||
| 3552 | * | ||
| 3553 | * Fills the @addr pointer with the address which the socket is connected. | ||
| 3554 | * Returns 0 or an error code. | ||
| 3555 | */ | ||
| 3556 | |||
| 3375 | int kernel_getpeername(struct socket *sock, struct sockaddr *addr) | 3557 | int kernel_getpeername(struct socket *sock, struct sockaddr *addr) |
| 3376 | { | 3558 | { |
| 3377 | return sock->ops->getname(sock, addr, 1); | 3559 | return sock->ops->getname(sock, addr, 1); |
| 3378 | } | 3560 | } |
| 3379 | EXPORT_SYMBOL(kernel_getpeername); | 3561 | EXPORT_SYMBOL(kernel_getpeername); |
| 3380 | 3562 | ||
| 3563 | /** | ||
| 3564 | * kernel_getsockopt - get a socket option (kernel space) | ||
| 3565 | * @sock: socket | ||
| 3566 | * @level: API level (SOL_SOCKET, ...) | ||
| 3567 | * @optname: option tag | ||
| 3568 | * @optval: option value | ||
| 3569 | * @optlen: option length | ||
| 3570 | * | ||
| 3571 | * Assigns the option length to @optlen. | ||
| 3572 | * Returns 0 or an error. | ||
| 3573 | */ | ||
| 3574 | |||
| 3381 | int kernel_getsockopt(struct socket *sock, int level, int optname, | 3575 | int kernel_getsockopt(struct socket *sock, int level, int optname, |
| 3382 | char *optval, int *optlen) | 3576 | char *optval, int *optlen) |
| 3383 | { | 3577 | { |
| @@ -3400,6 +3594,17 @@ int kernel_getsockopt(struct socket *sock, int level, int optname, | |||
| 3400 | } | 3594 | } |
| 3401 | EXPORT_SYMBOL(kernel_getsockopt); | 3595 | EXPORT_SYMBOL(kernel_getsockopt); |
| 3402 | 3596 | ||
| 3597 | /** | ||
| 3598 | * kernel_setsockopt - set a socket option (kernel space) | ||
| 3599 | * @sock: socket | ||
| 3600 | * @level: API level (SOL_SOCKET, ...) | ||
| 3601 | * @optname: option tag | ||
| 3602 | * @optval: option value | ||
| 3603 | * @optlen: option length | ||
| 3604 | * | ||
| 3605 | * Returns 0 or an error. | ||
| 3606 | */ | ||
| 3607 | |||
| 3403 | int kernel_setsockopt(struct socket *sock, int level, int optname, | 3608 | int kernel_setsockopt(struct socket *sock, int level, int optname, |
| 3404 | char *optval, unsigned int optlen) | 3609 | char *optval, unsigned int optlen) |
| 3405 | { | 3610 | { |
| @@ -3420,6 +3625,17 @@ int kernel_setsockopt(struct socket *sock, int level, int optname, | |||
| 3420 | } | 3625 | } |
| 3421 | EXPORT_SYMBOL(kernel_setsockopt); | 3626 | EXPORT_SYMBOL(kernel_setsockopt); |
| 3422 | 3627 | ||
| 3628 | /** | ||
| 3629 | * kernel_sendpage - send a &page through a socket (kernel space) | ||
| 3630 | * @sock: socket | ||
| 3631 | * @page: page | ||
| 3632 | * @offset: page offset | ||
| 3633 | * @size: total size in bytes | ||
| 3634 | * @flags: flags (MSG_DONTWAIT, ...) | ||
| 3635 | * | ||
| 3636 | * Returns the total amount sent in bytes or an error. | ||
| 3637 | */ | ||
| 3638 | |||
| 3423 | int kernel_sendpage(struct socket *sock, struct page *page, int offset, | 3639 | int kernel_sendpage(struct socket *sock, struct page *page, int offset, |
| 3424 | size_t size, int flags) | 3640 | size_t size, int flags) |
| 3425 | { | 3641 | { |
| @@ -3430,6 +3646,18 @@ int kernel_sendpage(struct socket *sock, struct page *page, int offset, | |||
| 3430 | } | 3646 | } |
| 3431 | EXPORT_SYMBOL(kernel_sendpage); | 3647 | EXPORT_SYMBOL(kernel_sendpage); |
| 3432 | 3648 | ||
| 3649 | /** | ||
| 3650 | * kernel_sendpage_locked - send a &page through the locked sock (kernel space) | ||
| 3651 | * @sk: sock | ||
| 3652 | * @page: page | ||
| 3653 | * @offset: page offset | ||
| 3654 | * @size: total size in bytes | ||
| 3655 | * @flags: flags (MSG_DONTWAIT, ...) | ||
| 3656 | * | ||
| 3657 | * Returns the total amount sent in bytes or an error. | ||
| 3658 | * Caller must hold @sk. | ||
| 3659 | */ | ||
| 3660 | |||
| 3433 | int kernel_sendpage_locked(struct sock *sk, struct page *page, int offset, | 3661 | int kernel_sendpage_locked(struct sock *sk, struct page *page, int offset, |
| 3434 | size_t size, int flags) | 3662 | size_t size, int flags) |
| 3435 | { | 3663 | { |
| @@ -3443,17 +3671,30 @@ int kernel_sendpage_locked(struct sock *sk, struct page *page, int offset, | |||
| 3443 | } | 3671 | } |
| 3444 | EXPORT_SYMBOL(kernel_sendpage_locked); | 3672 | EXPORT_SYMBOL(kernel_sendpage_locked); |
| 3445 | 3673 | ||
| 3674 | /** | ||
| 3675 | * kernel_shutdown - shut down part of a full-duplex connection (kernel space) | ||
| 3676 | * @sock: socket | ||
| 3677 | * @how: connection part | ||
| 3678 | * | ||
| 3679 | * Returns 0 or an error. | ||
| 3680 | */ | ||
| 3681 | |||
| 3446 | int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) | 3682 | int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) |
| 3447 | { | 3683 | { |
| 3448 | return sock->ops->shutdown(sock, how); | 3684 | return sock->ops->shutdown(sock, how); |
| 3449 | } | 3685 | } |
| 3450 | EXPORT_SYMBOL(kernel_sock_shutdown); | 3686 | EXPORT_SYMBOL(kernel_sock_shutdown); |
| 3451 | 3687 | ||
| 3452 | /* This routine returns the IP overhead imposed by a socket i.e. | 3688 | /** |
| 3453 | * the length of the underlying IP header, depending on whether | 3689 | * kernel_sock_ip_overhead - returns the IP overhead imposed by a socket |
| 3454 | * this is an IPv4 or IPv6 socket and the length from IP options turned | 3690 | * @sk: socket |
| 3455 | * on at the socket. Assumes that the caller has a lock on the socket. | 3691 | * |
| 3692 | * This routine returns the IP overhead imposed by a socket i.e. | ||
| 3693 | * the length of the underlying IP header, depending on whether | ||
| 3694 | * this is an IPv4 or IPv6 socket and the length from IP options turned | ||
| 3695 | * on at the socket. Assumes that the caller has a lock on the socket. | ||
| 3456 | */ | 3696 | */ |
| 3697 | |||
| 3457 | u32 kernel_sock_ip_overhead(struct sock *sk) | 3698 | u32 kernel_sock_ip_overhead(struct sock *sk) |
| 3458 | { | 3699 | { |
| 3459 | struct inet_sock *inet; | 3700 | struct inet_sock *inet; |
diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c index da1a676860ca..860dcfb95ee4 100644 --- a/net/strparser/strparser.c +++ b/net/strparser/strparser.c | |||
| @@ -550,6 +550,8 @@ EXPORT_SYMBOL_GPL(strp_check_rcv); | |||
| 550 | static int __init strp_mod_init(void) | 550 | static int __init strp_mod_init(void) |
| 551 | { | 551 | { |
| 552 | strp_wq = create_singlethread_workqueue("kstrp"); | 552 | strp_wq = create_singlethread_workqueue("kstrp"); |
| 553 | if (unlikely(!strp_wq)) | ||
| 554 | return -ENOMEM; | ||
| 553 | 555 | ||
| 554 | return 0; | 556 | return 0; |
| 555 | } | 557 | } |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 228970e6e52b..187d10443a15 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
| @@ -2311,6 +2311,15 @@ out_exit: | |||
| 2311 | rpc_exit(task, status); | 2311 | rpc_exit(task, status); |
| 2312 | } | 2312 | } |
| 2313 | 2313 | ||
| 2314 | static bool | ||
| 2315 | rpc_check_connected(const struct rpc_rqst *req) | ||
| 2316 | { | ||
| 2317 | /* No allocated request or transport? return true */ | ||
| 2318 | if (!req || !req->rq_xprt) | ||
| 2319 | return true; | ||
| 2320 | return xprt_connected(req->rq_xprt); | ||
| 2321 | } | ||
| 2322 | |||
| 2314 | static void | 2323 | static void |
| 2315 | rpc_check_timeout(struct rpc_task *task) | 2324 | rpc_check_timeout(struct rpc_task *task) |
| 2316 | { | 2325 | { |
| @@ -2322,10 +2331,11 @@ rpc_check_timeout(struct rpc_task *task) | |||
| 2322 | dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); | 2331 | dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); |
| 2323 | task->tk_timeouts++; | 2332 | task->tk_timeouts++; |
| 2324 | 2333 | ||
| 2325 | if (RPC_IS_SOFTCONN(task)) { | 2334 | if (RPC_IS_SOFTCONN(task) && !rpc_check_connected(task->tk_rqstp)) { |
| 2326 | rpc_exit(task, -ETIMEDOUT); | 2335 | rpc_exit(task, -ETIMEDOUT); |
| 2327 | return; | 2336 | return; |
| 2328 | } | 2337 | } |
| 2338 | |||
| 2329 | if (RPC_IS_SOFT(task)) { | 2339 | if (RPC_IS_SOFT(task)) { |
| 2330 | if (clnt->cl_chatty) { | 2340 | if (clnt->cl_chatty) { |
| 2331 | printk(KERN_NOTICE "%s: server %s not responding, timed out\n", | 2341 | printk(KERN_NOTICE "%s: server %s not responding, timed out\n", |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 9359539907ba..732d4b57411a 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
| @@ -495,8 +495,8 @@ xs_read_stream_request(struct sock_xprt *transport, struct msghdr *msg, | |||
| 495 | int flags, struct rpc_rqst *req) | 495 | int flags, struct rpc_rqst *req) |
| 496 | { | 496 | { |
| 497 | struct xdr_buf *buf = &req->rq_private_buf; | 497 | struct xdr_buf *buf = &req->rq_private_buf; |
| 498 | size_t want, read; | 498 | size_t want, uninitialized_var(read); |
| 499 | ssize_t ret; | 499 | ssize_t uninitialized_var(ret); |
| 500 | 500 | ||
| 501 | xs_read_header(transport, buf); | 501 | xs_read_header(transport, buf); |
| 502 | 502 | ||
diff --git a/net/tipc/group.c b/net/tipc/group.c index 06fee142f09f..63f39201e41e 100644 --- a/net/tipc/group.c +++ b/net/tipc/group.c | |||
| @@ -919,6 +919,9 @@ int tipc_group_fill_sock_diag(struct tipc_group *grp, struct sk_buff *skb) | |||
| 919 | { | 919 | { |
| 920 | struct nlattr *group = nla_nest_start(skb, TIPC_NLA_SOCK_GROUP); | 920 | struct nlattr *group = nla_nest_start(skb, TIPC_NLA_SOCK_GROUP); |
| 921 | 921 | ||
| 922 | if (!group) | ||
| 923 | return -EMSGSIZE; | ||
| 924 | |||
| 922 | if (nla_put_u32(skb, TIPC_NLA_SOCK_GROUP_ID, | 925 | if (nla_put_u32(skb, TIPC_NLA_SOCK_GROUP_ID, |
| 923 | grp->type) || | 926 | grp->type) || |
| 924 | nla_put_u32(skb, TIPC_NLA_SOCK_GROUP_INSTANCE, | 927 | nla_put_u32(skb, TIPC_NLA_SOCK_GROUP_INSTANCE, |
diff --git a/net/tipc/net.c b/net/tipc/net.c index f076edb74338..7ce1e86b024f 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
| @@ -163,12 +163,9 @@ void tipc_sched_net_finalize(struct net *net, u32 addr) | |||
| 163 | 163 | ||
| 164 | void tipc_net_stop(struct net *net) | 164 | void tipc_net_stop(struct net *net) |
| 165 | { | 165 | { |
| 166 | u32 self = tipc_own_addr(net); | 166 | if (!tipc_own_id(net)) |
| 167 | |||
| 168 | if (!self) | ||
| 169 | return; | 167 | return; |
| 170 | 168 | ||
| 171 | tipc_nametbl_withdraw(net, TIPC_CFG_SRV, self, self, self); | ||
| 172 | rtnl_lock(); | 169 | rtnl_lock(); |
| 173 | tipc_bearer_stop(net); | 170 | tipc_bearer_stop(net); |
| 174 | tipc_node_stop(net); | 171 | tipc_node_stop(net); |
diff --git a/net/tipc/node.c b/net/tipc/node.c index 2dc4919ab23c..dd3b6dc17662 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
| @@ -817,10 +817,10 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id, | |||
| 817 | static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete) | 817 | static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete) |
| 818 | { | 818 | { |
| 819 | struct tipc_link_entry *le = &n->links[bearer_id]; | 819 | struct tipc_link_entry *le = &n->links[bearer_id]; |
| 820 | struct tipc_media_addr *maddr = NULL; | ||
| 820 | struct tipc_link *l = le->link; | 821 | struct tipc_link *l = le->link; |
| 821 | struct tipc_media_addr *maddr; | ||
| 822 | struct sk_buff_head xmitq; | ||
| 823 | int old_bearer_id = bearer_id; | 822 | int old_bearer_id = bearer_id; |
| 823 | struct sk_buff_head xmitq; | ||
| 824 | 824 | ||
| 825 | if (!l) | 825 | if (!l) |
| 826 | return; | 826 | return; |
| @@ -844,7 +844,8 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete) | |||
| 844 | tipc_node_write_unlock(n); | 844 | tipc_node_write_unlock(n); |
| 845 | if (delete) | 845 | if (delete) |
| 846 | tipc_mon_remove_peer(n->net, n->addr, old_bearer_id); | 846 | tipc_mon_remove_peer(n->net, n->addr, old_bearer_id); |
| 847 | tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr); | 847 | if (!skb_queue_empty(&xmitq)) |
| 848 | tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr); | ||
| 848 | tipc_sk_rcv(n->net, &le->inputq); | 849 | tipc_sk_rcv(n->net, &le->inputq); |
| 849 | } | 850 | } |
| 850 | 851 | ||
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 3274ef625dba..b542f14ed444 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
| @@ -2349,6 +2349,16 @@ static int tipc_wait_for_connect(struct socket *sock, long *timeo_p) | |||
| 2349 | return 0; | 2349 | return 0; |
| 2350 | } | 2350 | } |
| 2351 | 2351 | ||
| 2352 | static bool tipc_sockaddr_is_sane(struct sockaddr_tipc *addr) | ||
| 2353 | { | ||
| 2354 | if (addr->family != AF_TIPC) | ||
| 2355 | return false; | ||
| 2356 | if (addr->addrtype == TIPC_SERVICE_RANGE) | ||
| 2357 | return (addr->addr.nameseq.lower <= addr->addr.nameseq.upper); | ||
| 2358 | return (addr->addrtype == TIPC_SERVICE_ADDR || | ||
| 2359 | addr->addrtype == TIPC_SOCKET_ADDR); | ||
| 2360 | } | ||
| 2361 | |||
| 2352 | /** | 2362 | /** |
| 2353 | * tipc_connect - establish a connection to another TIPC port | 2363 | * tipc_connect - establish a connection to another TIPC port |
| 2354 | * @sock: socket structure | 2364 | * @sock: socket structure |
| @@ -2384,18 +2394,18 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest, | |||
| 2384 | if (!tipc_sk_type_connectionless(sk)) | 2394 | if (!tipc_sk_type_connectionless(sk)) |
| 2385 | res = -EINVAL; | 2395 | res = -EINVAL; |
| 2386 | goto exit; | 2396 | goto exit; |
| 2387 | } else if (dst->family != AF_TIPC) { | ||
| 2388 | res = -EINVAL; | ||
| 2389 | } | 2397 | } |
| 2390 | if (dst->addrtype != TIPC_ADDR_ID && dst->addrtype != TIPC_ADDR_NAME) | 2398 | if (!tipc_sockaddr_is_sane(dst)) { |
| 2391 | res = -EINVAL; | 2399 | res = -EINVAL; |
| 2392 | if (res) | ||
| 2393 | goto exit; | 2400 | goto exit; |
| 2394 | 2401 | } | |
| 2395 | /* DGRAM/RDM connect(), just save the destaddr */ | 2402 | /* DGRAM/RDM connect(), just save the destaddr */ |
| 2396 | if (tipc_sk_type_connectionless(sk)) { | 2403 | if (tipc_sk_type_connectionless(sk)) { |
| 2397 | memcpy(&tsk->peer, dest, destlen); | 2404 | memcpy(&tsk->peer, dest, destlen); |
| 2398 | goto exit; | 2405 | goto exit; |
| 2406 | } else if (dst->addrtype == TIPC_SERVICE_RANGE) { | ||
| 2407 | res = -EINVAL; | ||
| 2408 | goto exit; | ||
| 2399 | } | 2409 | } |
| 2400 | 2410 | ||
| 2401 | previous = sk->sk_state; | 2411 | previous = sk->sk_state; |
| @@ -3255,6 +3265,8 @@ static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk) | |||
| 3255 | peer_port = tsk_peer_port(tsk); | 3265 | peer_port = tsk_peer_port(tsk); |
| 3256 | 3266 | ||
| 3257 | nest = nla_nest_start(skb, TIPC_NLA_SOCK_CON); | 3267 | nest = nla_nest_start(skb, TIPC_NLA_SOCK_CON); |
| 3268 | if (!nest) | ||
| 3269 | return -EMSGSIZE; | ||
| 3258 | 3270 | ||
| 3259 | if (nla_put_u32(skb, TIPC_NLA_CON_NODE, peer_node)) | 3271 | if (nla_put_u32(skb, TIPC_NLA_CON_NODE, peer_node)) |
| 3260 | goto msg_full; | 3272 | goto msg_full; |
diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c index 4a708a4e8583..b45932d78004 100644 --- a/net/tipc/topsrv.c +++ b/net/tipc/topsrv.c | |||
| @@ -363,6 +363,7 @@ static int tipc_conn_rcv_sub(struct tipc_topsrv *srv, | |||
| 363 | struct tipc_subscription *sub; | 363 | struct tipc_subscription *sub; |
| 364 | 364 | ||
| 365 | if (tipc_sub_read(s, filter) & TIPC_SUB_CANCEL) { | 365 | if (tipc_sub_read(s, filter) & TIPC_SUB_CANCEL) { |
| 366 | s->filter &= __constant_ntohl(~TIPC_SUB_CANCEL); | ||
| 366 | tipc_conn_delete_sub(con, s); | 367 | tipc_conn_delete_sub(con, s); |
| 367 | return 0; | 368 | return 0; |
| 368 | } | 369 | } |
diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c index 77520eacee8f..989e52386c35 100644 --- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c | |||
| @@ -193,9 +193,6 @@ static void xdp_umem_unaccount_pages(struct xdp_umem *umem) | |||
| 193 | 193 | ||
| 194 | static void xdp_umem_release(struct xdp_umem *umem) | 194 | static void xdp_umem_release(struct xdp_umem *umem) |
| 195 | { | 195 | { |
| 196 | struct task_struct *task; | ||
| 197 | struct mm_struct *mm; | ||
| 198 | |||
| 199 | xdp_umem_clear_dev(umem); | 196 | xdp_umem_clear_dev(umem); |
| 200 | 197 | ||
| 201 | ida_simple_remove(&umem_ida, umem->id); | 198 | ida_simple_remove(&umem_ida, umem->id); |
| @@ -214,21 +211,10 @@ static void xdp_umem_release(struct xdp_umem *umem) | |||
| 214 | 211 | ||
| 215 | xdp_umem_unpin_pages(umem); | 212 | xdp_umem_unpin_pages(umem); |
| 216 | 213 | ||
| 217 | task = get_pid_task(umem->pid, PIDTYPE_PID); | ||
| 218 | put_pid(umem->pid); | ||
| 219 | if (!task) | ||
| 220 | goto out; | ||
| 221 | mm = get_task_mm(task); | ||
| 222 | put_task_struct(task); | ||
| 223 | if (!mm) | ||
| 224 | goto out; | ||
| 225 | |||
| 226 | mmput(mm); | ||
| 227 | kfree(umem->pages); | 214 | kfree(umem->pages); |
| 228 | umem->pages = NULL; | 215 | umem->pages = NULL; |
| 229 | 216 | ||
| 230 | xdp_umem_unaccount_pages(umem); | 217 | xdp_umem_unaccount_pages(umem); |
| 231 | out: | ||
| 232 | kfree(umem); | 218 | kfree(umem); |
| 233 | } | 219 | } |
| 234 | 220 | ||
| @@ -357,7 +343,6 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) | |||
| 357 | if (size_chk < 0) | 343 | if (size_chk < 0) |
| 358 | return -EINVAL; | 344 | return -EINVAL; |
| 359 | 345 | ||
| 360 | umem->pid = get_task_pid(current, PIDTYPE_PID); | ||
| 361 | umem->address = (unsigned long)addr; | 346 | umem->address = (unsigned long)addr; |
| 362 | umem->chunk_mask = ~((u64)chunk_size - 1); | 347 | umem->chunk_mask = ~((u64)chunk_size - 1); |
| 363 | umem->size = size; | 348 | umem->size = size; |
| @@ -373,7 +358,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) | |||
| 373 | 358 | ||
| 374 | err = xdp_umem_account_pages(umem); | 359 | err = xdp_umem_account_pages(umem); |
| 375 | if (err) | 360 | if (err) |
| 376 | goto out; | 361 | return err; |
| 377 | 362 | ||
| 378 | err = xdp_umem_pin_pages(umem); | 363 | err = xdp_umem_pin_pages(umem); |
| 379 | if (err) | 364 | if (err) |
| @@ -392,8 +377,6 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) | |||
| 392 | 377 | ||
| 393 | out_account: | 378 | out_account: |
| 394 | xdp_umem_unaccount_pages(umem); | 379 | xdp_umem_unaccount_pages(umem); |
| 395 | out: | ||
| 396 | put_pid(umem->pid); | ||
| 397 | return err; | 380 | return err; |
| 398 | } | 381 | } |
| 399 | 382 | ||
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 2554a15ecf2b..76ca30cc4791 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
| @@ -199,11 +199,8 @@ sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ | |||
| 199 | "$(if $(part-of-module),1,0)" "$(@)"; | 199 | "$(if $(part-of-module),1,0)" "$(@)"; |
| 200 | recordmcount_source := $(srctree)/scripts/recordmcount.pl | 200 | recordmcount_source := $(srctree)/scripts/recordmcount.pl |
| 201 | endif # BUILD_C_RECORDMCOUNT | 201 | endif # BUILD_C_RECORDMCOUNT |
| 202 | cmd_record_mcount = \ | 202 | cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \ |
| 203 | if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ | 203 | $(sub_cmd_record_mcount)) |
| 204 | "$(CC_FLAGS_FTRACE)" ]; then \ | ||
| 205 | $(sub_cmd_record_mcount) \ | ||
| 206 | fi | ||
| 207 | endif # CC_USING_RECORD_MCOUNT | 204 | endif # CC_USING_RECORD_MCOUNT |
| 208 | endif # CONFIG_FTRACE_MCOUNT_RECORD | 205 | endif # CONFIG_FTRACE_MCOUNT_RECORD |
| 209 | 206 | ||
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5b756278df13..a09333fd7cef 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -5977,7 +5977,7 @@ sub process { | |||
| 5977 | while ($fmt =~ /(\%[\*\d\.]*p(\w))/g) { | 5977 | while ($fmt =~ /(\%[\*\d\.]*p(\w))/g) { |
| 5978 | $specifier = $1; | 5978 | $specifier = $1; |
| 5979 | $extension = $2; | 5979 | $extension = $2; |
| 5980 | if ($extension !~ /[SsBKRraEhMmIiUDdgVCbGNOx]/) { | 5980 | if ($extension !~ /[SsBKRraEhMmIiUDdgVCbGNOxt]/) { |
| 5981 | $bad_specifier = $specifier; | 5981 | $bad_specifier = $specifier; |
| 5982 | last; | 5982 | last; |
| 5983 | } | 5983 | } |
diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci index 7395697e7f19..c9f071b0a0ab 100644 --- a/scripts/coccinelle/free/put_device.cocci +++ b/scripts/coccinelle/free/put_device.cocci | |||
| @@ -32,6 +32,7 @@ if (id == NULL || ...) { ... return ...; } | |||
| 32 | ( id | 32 | ( id |
| 33 | | (T2)dev_get_drvdata(&id->dev) | 33 | | (T2)dev_get_drvdata(&id->dev) |
| 34 | | (T3)platform_get_drvdata(id) | 34 | | (T3)platform_get_drvdata(id) |
| 35 | | &id->dev | ||
| 35 | ); | 36 | ); |
| 36 | | return@p2 ...; | 37 | | return@p2 ...; |
| 37 | ) | 38 | ) |
diff --git a/scripts/coccinelle/misc/badty.cocci b/scripts/coccinelle/misc/badty.cocci index 481cf301ccfc..08470362199c 100644 --- a/scripts/coccinelle/misc/badty.cocci +++ b/scripts/coccinelle/misc/badty.cocci | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /// Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element | 1 | /// Correct the size argument to alloc functions |
| 2 | /// | 2 | /// |
| 3 | //# This makes an effort to find cases where the argument to sizeof is wrong | 3 | //# This makes an effort to find cases where the argument to sizeof is wrong |
| 4 | //# in memory allocation functions by checking the type of the allocated memory | 4 | //# in memory allocation functions by checking the type of the allocated memory |
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index 611945611bf8..1dcfb288ee63 100644 --- a/scripts/kconfig/lxdialog/inputbox.c +++ b/scripts/kconfig/lxdialog/inputbox.c | |||
| @@ -113,7 +113,8 @@ do_resize: | |||
| 113 | case KEY_DOWN: | 113 | case KEY_DOWN: |
| 114 | break; | 114 | break; |
| 115 | case KEY_BACKSPACE: | 115 | case KEY_BACKSPACE: |
| 116 | case 127: | 116 | case 8: /* ^H */ |
| 117 | case 127: /* ^? */ | ||
| 117 | if (pos) { | 118 | if (pos) { |
| 118 | wattrset(dialog, dlg.inputbox.atr); | 119 | wattrset(dialog, dlg.inputbox.atr); |
| 119 | if (input_x == 0) { | 120 | if (input_x == 0) { |
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index a4670f4e825a..ac92c0ded6c5 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
| @@ -1048,7 +1048,7 @@ static int do_match(int key, struct match_state *state, int *ans) | |||
| 1048 | state->match_direction = FIND_NEXT_MATCH_UP; | 1048 | state->match_direction = FIND_NEXT_MATCH_UP; |
| 1049 | *ans = get_mext_match(state->pattern, | 1049 | *ans = get_mext_match(state->pattern, |
| 1050 | state->match_direction); | 1050 | state->match_direction); |
| 1051 | } else if (key == KEY_BACKSPACE || key == 127) { | 1051 | } else if (key == KEY_BACKSPACE || key == 8 || key == 127) { |
| 1052 | state->pattern[strlen(state->pattern)-1] = '\0'; | 1052 | state->pattern[strlen(state->pattern)-1] = '\0'; |
| 1053 | adj_match_dir(&state->match_direction); | 1053 | adj_match_dir(&state->match_direction); |
| 1054 | } else | 1054 | } else |
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 7be620a1fcdb..77f525a8617c 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c | |||
| @@ -439,7 +439,8 @@ int dialog_inputbox(WINDOW *main_window, | |||
| 439 | case KEY_F(F_EXIT): | 439 | case KEY_F(F_EXIT): |
| 440 | case KEY_F(F_BACK): | 440 | case KEY_F(F_BACK): |
| 441 | break; | 441 | break; |
| 442 | case 127: | 442 | case 8: /* ^H */ |
| 443 | case 127: /* ^? */ | ||
| 443 | case KEY_BACKSPACE: | 444 | case KEY_BACKSPACE: |
| 444 | if (cursor_position > 0) { | 445 | if (cursor_position > 0) { |
| 445 | memmove(&result[cursor_position-1], | 446 | memmove(&result[cursor_position-1], |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 0b0d1080b1c5..f277e116e0eb 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -639,7 +639,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
| 639 | info->sechdrs[sym->st_shndx].sh_offset - | 639 | info->sechdrs[sym->st_shndx].sh_offset - |
| 640 | (info->hdr->e_type != ET_REL ? | 640 | (info->hdr->e_type != ET_REL ? |
| 641 | info->sechdrs[sym->st_shndx].sh_addr : 0); | 641 | info->sechdrs[sym->st_shndx].sh_addr : 0); |
| 642 | crc = *crcp; | 642 | crc = TO_NATIVE(*crcp); |
| 643 | } | 643 | } |
| 644 | sym_update_crc(symname + strlen("__crc_"), mod, crc, | 644 | sym_update_crc(symname + strlen("__crc_"), mod, crc, |
| 645 | export); | 645 | export); |
diff --git a/security/Kconfig b/security/Kconfig index 1d6463fb1450..353cfef71d4e 100644 --- a/security/Kconfig +++ b/security/Kconfig | |||
| @@ -239,8 +239,46 @@ source "security/safesetid/Kconfig" | |||
| 239 | 239 | ||
| 240 | source "security/integrity/Kconfig" | 240 | source "security/integrity/Kconfig" |
| 241 | 241 | ||
| 242 | choice | ||
| 243 | prompt "First legacy 'major LSM' to be initialized" | ||
| 244 | default DEFAULT_SECURITY_SELINUX if SECURITY_SELINUX | ||
| 245 | default DEFAULT_SECURITY_SMACK if SECURITY_SMACK | ||
| 246 | default DEFAULT_SECURITY_TOMOYO if SECURITY_TOMOYO | ||
| 247 | default DEFAULT_SECURITY_APPARMOR if SECURITY_APPARMOR | ||
| 248 | default DEFAULT_SECURITY_DAC | ||
| 249 | |||
| 250 | help | ||
| 251 | This choice is there only for converting CONFIG_DEFAULT_SECURITY | ||
| 252 | in old kernel configs to CONFIG_LSM in new kernel configs. Don't | ||
| 253 | change this choice unless you are creating a fresh kernel config, | ||
| 254 | for this choice will be ignored after CONFIG_LSM has been set. | ||
| 255 | |||
| 256 | Selects the legacy "major security module" that will be | ||
| 257 | initialized first. Overridden by non-default CONFIG_LSM. | ||
| 258 | |||
| 259 | config DEFAULT_SECURITY_SELINUX | ||
| 260 | bool "SELinux" if SECURITY_SELINUX=y | ||
| 261 | |||
| 262 | config DEFAULT_SECURITY_SMACK | ||
| 263 | bool "Simplified Mandatory Access Control" if SECURITY_SMACK=y | ||
| 264 | |||
| 265 | config DEFAULT_SECURITY_TOMOYO | ||
| 266 | bool "TOMOYO" if SECURITY_TOMOYO=y | ||
| 267 | |||
| 268 | config DEFAULT_SECURITY_APPARMOR | ||
| 269 | bool "AppArmor" if SECURITY_APPARMOR=y | ||
| 270 | |||
| 271 | config DEFAULT_SECURITY_DAC | ||
| 272 | bool "Unix Discretionary Access Controls" | ||
| 273 | |||
| 274 | endchoice | ||
| 275 | |||
| 242 | config LSM | 276 | config LSM |
| 243 | string "Ordered list of enabled LSMs" | 277 | string "Ordered list of enabled LSMs" |
| 278 | default "yama,loadpin,safesetid,integrity,smack,selinux,tomoyo,apparmor" if DEFAULT_SECURITY_SMACK | ||
| 279 | default "yama,loadpin,safesetid,integrity,apparmor,selinux,smack,tomoyo" if DEFAULT_SECURITY_APPARMOR | ||
| 280 | default "yama,loadpin,safesetid,integrity,tomoyo" if DEFAULT_SECURITY_TOMOYO | ||
| 281 | default "yama,loadpin,safesetid,integrity" if DEFAULT_SECURITY_DAC | ||
| 244 | default "yama,loadpin,safesetid,integrity,selinux,smack,tomoyo,apparmor" | 282 | default "yama,loadpin,safesetid,integrity,selinux,smack,tomoyo,apparmor" |
| 245 | help | 283 | help |
| 246 | A comma-separated list of LSMs, in initialization order. | 284 | A comma-separated list of LSMs, in initialization order. |
diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c index 57cc60722dd3..efac68556b45 100644 --- a/security/yama/yama_lsm.c +++ b/security/yama/yama_lsm.c | |||
| @@ -206,7 +206,7 @@ static void yama_ptracer_del(struct task_struct *tracer, | |||
| 206 | * yama_task_free - check for task_pid to remove from exception list | 206 | * yama_task_free - check for task_pid to remove from exception list |
| 207 | * @task: task being removed | 207 | * @task: task being removed |
| 208 | */ | 208 | */ |
| 209 | void yama_task_free(struct task_struct *task) | 209 | static void yama_task_free(struct task_struct *task) |
| 210 | { | 210 | { |
| 211 | yama_ptracer_del(task, task); | 211 | yama_ptracer_del(task, task); |
| 212 | } | 212 | } |
| @@ -222,7 +222,7 @@ void yama_task_free(struct task_struct *task) | |||
| 222 | * Return 0 on success, -ve on error. -ENOSYS is returned when Yama | 222 | * Return 0 on success, -ve on error. -ENOSYS is returned when Yama |
| 223 | * does not handle the given option. | 223 | * does not handle the given option. |
| 224 | */ | 224 | */ |
| 225 | int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3, | 225 | static int yama_task_prctl(int option, unsigned long arg2, unsigned long arg3, |
| 226 | unsigned long arg4, unsigned long arg5) | 226 | unsigned long arg4, unsigned long arg5) |
| 227 | { | 227 | { |
| 228 | int rc = -ENOSYS; | 228 | int rc = -ENOSYS; |
| @@ -401,7 +401,7 @@ static int yama_ptrace_access_check(struct task_struct *child, | |||
| 401 | * | 401 | * |
| 402 | * Returns 0 if following the ptrace is allowed, -ve on error. | 402 | * Returns 0 if following the ptrace is allowed, -ve on error. |
| 403 | */ | 403 | */ |
| 404 | int yama_ptrace_traceme(struct task_struct *parent) | 404 | static int yama_ptrace_traceme(struct task_struct *parent) |
| 405 | { | 405 | { |
| 406 | int rc = 0; | 406 | int rc = 0; |
| 407 | 407 | ||
| @@ -452,7 +452,7 @@ static int yama_dointvec_minmax(struct ctl_table *table, int write, | |||
| 452 | static int zero; | 452 | static int zero; |
| 453 | static int max_scope = YAMA_SCOPE_NO_ATTACH; | 453 | static int max_scope = YAMA_SCOPE_NO_ATTACH; |
| 454 | 454 | ||
| 455 | struct ctl_path yama_sysctl_path[] = { | 455 | static struct ctl_path yama_sysctl_path[] = { |
| 456 | { .procname = "kernel", }, | 456 | { .procname = "kernel", }, |
| 457 | { .procname = "yama", }, | 457 | { .procname = "yama", }, |
| 458 | { } | 458 | { } |
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index d5b0d7ba83c4..f6ae68017608 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
| @@ -940,6 +940,28 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) | |||
| 940 | oss_frame_size = snd_pcm_format_physical_width(params_format(params)) * | 940 | oss_frame_size = snd_pcm_format_physical_width(params_format(params)) * |
| 941 | params_channels(params) / 8; | 941 | params_channels(params) / 8; |
| 942 | 942 | ||
| 943 | err = snd_pcm_oss_period_size(substream, params, sparams); | ||
| 944 | if (err < 0) | ||
| 945 | goto failure; | ||
| 946 | |||
| 947 | n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); | ||
| 948 | err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL); | ||
| 949 | if (err < 0) | ||
| 950 | goto failure; | ||
| 951 | |||
| 952 | err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS, | ||
| 953 | runtime->oss.periods, NULL); | ||
| 954 | if (err < 0) | ||
| 955 | goto failure; | ||
| 956 | |||
| 957 | snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); | ||
| 958 | |||
| 959 | err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams); | ||
| 960 | if (err < 0) { | ||
| 961 | pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err); | ||
| 962 | goto failure; | ||
| 963 | } | ||
| 964 | |||
| 943 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | 965 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS |
| 944 | snd_pcm_oss_plugin_clear(substream); | 966 | snd_pcm_oss_plugin_clear(substream); |
| 945 | if (!direct) { | 967 | if (!direct) { |
| @@ -974,27 +996,6 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) | |||
| 974 | } | 996 | } |
| 975 | #endif | 997 | #endif |
| 976 | 998 | ||
| 977 | err = snd_pcm_oss_period_size(substream, params, sparams); | ||
| 978 | if (err < 0) | ||
| 979 | goto failure; | ||
| 980 | |||
| 981 | n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); | ||
| 982 | err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL); | ||
| 983 | if (err < 0) | ||
| 984 | goto failure; | ||
| 985 | |||
| 986 | err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS, | ||
| 987 | runtime->oss.periods, NULL); | ||
| 988 | if (err < 0) | ||
| 989 | goto failure; | ||
| 990 | |||
| 991 | snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); | ||
| 992 | |||
| 993 | if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams)) < 0) { | ||
| 994 | pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err); | ||
| 995 | goto failure; | ||
| 996 | } | ||
| 997 | |||
| 998 | if (runtime->oss.trigger) { | 999 | if (runtime->oss.trigger) { |
| 999 | sw_params->start_threshold = 1; | 1000 | sw_params->start_threshold = 1; |
| 1000 | } else { | 1001 | } else { |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index f731f904e8cc..1d8452912b14 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
| @@ -1445,8 +1445,15 @@ static int snd_pcm_pause(struct snd_pcm_substream *substream, int push) | |||
| 1445 | static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) | 1445 | static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) |
| 1446 | { | 1446 | { |
| 1447 | struct snd_pcm_runtime *runtime = substream->runtime; | 1447 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 1448 | if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) | 1448 | switch (runtime->status->state) { |
| 1449 | case SNDRV_PCM_STATE_SUSPENDED: | ||
| 1449 | return -EBUSY; | 1450 | return -EBUSY; |
| 1451 | /* unresumable PCM state; return -EBUSY for skipping suspend */ | ||
| 1452 | case SNDRV_PCM_STATE_OPEN: | ||
| 1453 | case SNDRV_PCM_STATE_SETUP: | ||
| 1454 | case SNDRV_PCM_STATE_DISCONNECTED: | ||
| 1455 | return -EBUSY; | ||
| 1456 | } | ||
| 1450 | runtime->trigger_master = substream; | 1457 | runtime->trigger_master = substream; |
| 1451 | return 0; | 1458 | return 0; |
| 1452 | } | 1459 | } |
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index ee601d7f0926..c0690d1ecd55 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
| 31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
| 32 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
| 33 | #include <linux/nospec.h> | ||
| 33 | #include <sound/rawmidi.h> | 34 | #include <sound/rawmidi.h> |
| 34 | #include <sound/info.h> | 35 | #include <sound/info.h> |
| 35 | #include <sound/control.h> | 36 | #include <sound/control.h> |
| @@ -601,6 +602,7 @@ static int __snd_rawmidi_info_select(struct snd_card *card, | |||
| 601 | return -ENXIO; | 602 | return -ENXIO; |
| 602 | if (info->stream < 0 || info->stream > 1) | 603 | if (info->stream < 0 || info->stream > 1) |
| 603 | return -EINVAL; | 604 | return -EINVAL; |
| 605 | info->stream = array_index_nospec(info->stream, 2); | ||
| 604 | pstr = &rmidi->streams[info->stream]; | 606 | pstr = &rmidi->streams[info->stream]; |
| 605 | if (pstr->substream_count == 0) | 607 | if (pstr->substream_count == 0) |
| 606 | return -ENOENT; | 608 | return -ENOENT; |
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 278ebb993122..c93945917235 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c | |||
| @@ -617,13 +617,14 @@ int | |||
| 617 | snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_info *inf) | 617 | snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_info *inf) |
| 618 | { | 618 | { |
| 619 | struct seq_oss_synth *rec; | 619 | struct seq_oss_synth *rec; |
| 620 | struct seq_oss_synthinfo *info = get_synthinfo_nospec(dp, dev); | ||
| 620 | 621 | ||
| 621 | if (dev < 0 || dev >= dp->max_synthdev) | 622 | if (!info) |
| 622 | return -ENXIO; | 623 | return -ENXIO; |
| 623 | 624 | ||
| 624 | if (dp->synths[dev].is_midi) { | 625 | if (info->is_midi) { |
| 625 | struct midi_info minf; | 626 | struct midi_info minf; |
| 626 | snd_seq_oss_midi_make_info(dp, dp->synths[dev].midi_mapped, &minf); | 627 | snd_seq_oss_midi_make_info(dp, info->midi_mapped, &minf); |
| 627 | inf->synth_type = SYNTH_TYPE_MIDI; | 628 | inf->synth_type = SYNTH_TYPE_MIDI; |
| 628 | inf->synth_subtype = 0; | 629 | inf->synth_subtype = 0; |
| 629 | inf->nr_voices = 16; | 630 | inf->nr_voices = 16; |
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 29882bda7632..e1ebc6d5f382 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c | |||
| @@ -1005,7 +1005,6 @@ struct ca0132_spec { | |||
| 1005 | unsigned int scp_resp_header; | 1005 | unsigned int scp_resp_header; |
| 1006 | unsigned int scp_resp_data[4]; | 1006 | unsigned int scp_resp_data[4]; |
| 1007 | unsigned int scp_resp_count; | 1007 | unsigned int scp_resp_count; |
| 1008 | bool alt_firmware_present; | ||
| 1009 | bool startup_check_entered; | 1008 | bool startup_check_entered; |
| 1010 | bool dsp_reload; | 1009 | bool dsp_reload; |
| 1011 | 1010 | ||
| @@ -7518,7 +7517,7 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec) | |||
| 7518 | bool dsp_loaded = false; | 7517 | bool dsp_loaded = false; |
| 7519 | struct ca0132_spec *spec = codec->spec; | 7518 | struct ca0132_spec *spec = codec->spec; |
| 7520 | const struct dsp_image_seg *dsp_os_image; | 7519 | const struct dsp_image_seg *dsp_os_image; |
| 7521 | const struct firmware *fw_entry; | 7520 | const struct firmware *fw_entry = NULL; |
| 7522 | /* | 7521 | /* |
| 7523 | * Alternate firmwares for different variants. The Recon3Di apparently | 7522 | * Alternate firmwares for different variants. The Recon3Di apparently |
| 7524 | * can use the default firmware, but I'll leave the option in case | 7523 | * can use the default firmware, but I'll leave the option in case |
| @@ -7529,33 +7528,26 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec) | |||
| 7529 | case QUIRK_R3D: | 7528 | case QUIRK_R3D: |
| 7530 | case QUIRK_AE5: | 7529 | case QUIRK_AE5: |
| 7531 | if (request_firmware(&fw_entry, DESKTOP_EFX_FILE, | 7530 | if (request_firmware(&fw_entry, DESKTOP_EFX_FILE, |
| 7532 | codec->card->dev) != 0) { | 7531 | codec->card->dev) != 0) |
| 7533 | codec_dbg(codec, "Desktop firmware not found."); | 7532 | codec_dbg(codec, "Desktop firmware not found."); |
| 7534 | spec->alt_firmware_present = false; | 7533 | else |
| 7535 | } else { | ||
| 7536 | codec_dbg(codec, "Desktop firmware selected."); | 7534 | codec_dbg(codec, "Desktop firmware selected."); |
| 7537 | spec->alt_firmware_present = true; | ||
| 7538 | } | ||
| 7539 | break; | 7535 | break; |
| 7540 | case QUIRK_R3DI: | 7536 | case QUIRK_R3DI: |
| 7541 | if (request_firmware(&fw_entry, R3DI_EFX_FILE, | 7537 | if (request_firmware(&fw_entry, R3DI_EFX_FILE, |
| 7542 | codec->card->dev) != 0) { | 7538 | codec->card->dev) != 0) |
| 7543 | codec_dbg(codec, "Recon3Di alt firmware not detected."); | 7539 | codec_dbg(codec, "Recon3Di alt firmware not detected."); |
| 7544 | spec->alt_firmware_present = false; | 7540 | else |
| 7545 | } else { | ||
| 7546 | codec_dbg(codec, "Recon3Di firmware selected."); | 7541 | codec_dbg(codec, "Recon3Di firmware selected."); |
| 7547 | spec->alt_firmware_present = true; | ||
| 7548 | } | ||
| 7549 | break; | 7542 | break; |
| 7550 | default: | 7543 | default: |
| 7551 | spec->alt_firmware_present = false; | ||
| 7552 | break; | 7544 | break; |
| 7553 | } | 7545 | } |
| 7554 | /* | 7546 | /* |
| 7555 | * Use default ctefx.bin if no alt firmware is detected, or if none | 7547 | * Use default ctefx.bin if no alt firmware is detected, or if none |
| 7556 | * exists for your particular codec. | 7548 | * exists for your particular codec. |
| 7557 | */ | 7549 | */ |
| 7558 | if (!spec->alt_firmware_present) { | 7550 | if (!fw_entry) { |
| 7559 | codec_dbg(codec, "Default firmware selected."); | 7551 | codec_dbg(codec, "Default firmware selected."); |
| 7560 | if (request_firmware(&fw_entry, EFX_FILE, | 7552 | if (request_firmware(&fw_entry, EFX_FILE, |
| 7561 | codec->card->dev) != 0) | 7553 | codec->card->dev) != 0) |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 191830d4fa40..a3fb3d4c5730 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
| @@ -5688,6 +5688,8 @@ enum { | |||
| 5688 | ALC225_FIXUP_WYSE_AUTO_MUTE, | 5688 | ALC225_FIXUP_WYSE_AUTO_MUTE, |
| 5689 | ALC225_FIXUP_WYSE_DISABLE_MIC_VREF, | 5689 | ALC225_FIXUP_WYSE_DISABLE_MIC_VREF, |
| 5690 | ALC286_FIXUP_ACER_AIO_HEADSET_MIC, | 5690 | ALC286_FIXUP_ACER_AIO_HEADSET_MIC, |
| 5691 | ALC256_FIXUP_ASUS_MIC_NO_PRESENCE, | ||
| 5692 | ALC299_FIXUP_PREDATOR_SPK, | ||
| 5691 | }; | 5693 | }; |
| 5692 | 5694 | ||
| 5693 | static const struct hda_fixup alc269_fixups[] = { | 5695 | static const struct hda_fixup alc269_fixups[] = { |
| @@ -6696,6 +6698,22 @@ static const struct hda_fixup alc269_fixups[] = { | |||
| 6696 | .chained = true, | 6698 | .chained = true, |
| 6697 | .chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE | 6699 | .chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE |
| 6698 | }, | 6700 | }, |
| 6701 | [ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = { | ||
| 6702 | .type = HDA_FIXUP_PINS, | ||
| 6703 | .v.pins = (const struct hda_pintbl[]) { | ||
| 6704 | { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */ | ||
| 6705 | { } | ||
| 6706 | }, | ||
| 6707 | .chained = true, | ||
| 6708 | .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE | ||
| 6709 | }, | ||
| 6710 | [ALC299_FIXUP_PREDATOR_SPK] = { | ||
| 6711 | .type = HDA_FIXUP_PINS, | ||
| 6712 | .v.pins = (const struct hda_pintbl[]) { | ||
| 6713 | { 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */ | ||
| 6714 | { } | ||
| 6715 | } | ||
| 6716 | }, | ||
| 6699 | }; | 6717 | }; |
| 6700 | 6718 | ||
| 6701 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { | 6719 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
| @@ -6712,9 +6730,13 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 6712 | SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS), | 6730 | SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS), |
| 6713 | SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE), | 6731 | SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE), |
| 6714 | SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK), | 6732 | SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK), |
| 6733 | SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE), | ||
| 6734 | SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE), | ||
| 6735 | SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK), | ||
| 6715 | SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), | 6736 | SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), |
| 6716 | SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), | 6737 | SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), |
| 6717 | SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), | 6738 | SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), |
| 6739 | SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), | ||
| 6718 | SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC), | 6740 | SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC), |
| 6719 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), | 6741 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 6720 | SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS), | 6742 | SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS), |
| @@ -7111,6 +7133,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { | |||
| 7111 | {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"}, | 7133 | {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"}, |
| 7112 | {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"}, | 7134 | {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"}, |
| 7113 | {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-sense-combo"}, | 7135 | {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-sense-combo"}, |
| 7136 | {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"}, | ||
| 7114 | {} | 7137 | {} |
| 7115 | }; | 7138 | }; |
| 7116 | #define ALC225_STANDARD_PINS \ | 7139 | #define ALC225_STANDARD_PINS \ |
| @@ -7331,6 +7354,18 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { | |||
| 7331 | {0x14, 0x90170110}, | 7354 | {0x14, 0x90170110}, |
| 7332 | {0x1b, 0x90a70130}, | 7355 | {0x1b, 0x90a70130}, |
| 7333 | {0x21, 0x03211020}), | 7356 | {0x21, 0x03211020}), |
| 7357 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE, | ||
| 7358 | {0x12, 0x90a60130}, | ||
| 7359 | {0x14, 0x90170110}, | ||
| 7360 | {0x21, 0x03211020}), | ||
| 7361 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE, | ||
| 7362 | {0x12, 0x90a60130}, | ||
| 7363 | {0x14, 0x90170110}, | ||
| 7364 | {0x21, 0x04211020}), | ||
| 7365 | SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE, | ||
| 7366 | {0x1a, 0x90a70130}, | ||
| 7367 | {0x1b, 0x90170110}, | ||
| 7368 | {0x21, 0x03211020}), | ||
| 7334 | SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, | 7369 | SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, |
| 7335 | {0x12, 0xb7a60130}, | 7370 | {0x12, 0xb7a60130}, |
| 7336 | {0x13, 0xb8a61140}, | 7371 | {0x13, 0xb8a61140}, |
diff --git a/tools/arch/alpha/include/uapi/asm/mman.h b/tools/arch/alpha/include/uapi/asm/mman.h index c317d3e6867a..ea6a255ae61f 100644 --- a/tools/arch/alpha/include/uapi/asm/mman.h +++ b/tools/arch/alpha/include/uapi/asm/mman.h | |||
| @@ -27,8 +27,6 @@ | |||
| 27 | #define MAP_NONBLOCK 0x40000 | 27 | #define MAP_NONBLOCK 0x40000 |
| 28 | #define MAP_NORESERVE 0x10000 | 28 | #define MAP_NORESERVE 0x10000 |
| 29 | #define MAP_POPULATE 0x20000 | 29 | #define MAP_POPULATE 0x20000 |
| 30 | #define MAP_PRIVATE 0x02 | ||
| 31 | #define MAP_SHARED 0x01 | ||
| 32 | #define MAP_STACK 0x80000 | 30 | #define MAP_STACK 0x80000 |
| 33 | #define PROT_EXEC 0x4 | 31 | #define PROT_EXEC 0x4 |
| 34 | #define PROT_GROWSDOWN 0x01000000 | 32 | #define PROT_GROWSDOWN 0x01000000 |
diff --git a/tools/arch/mips/include/uapi/asm/mman.h b/tools/arch/mips/include/uapi/asm/mman.h index de2206883abc..c8acaa138d46 100644 --- a/tools/arch/mips/include/uapi/asm/mman.h +++ b/tools/arch/mips/include/uapi/asm/mman.h | |||
| @@ -28,8 +28,6 @@ | |||
| 28 | #define MAP_NONBLOCK 0x20000 | 28 | #define MAP_NONBLOCK 0x20000 |
| 29 | #define MAP_NORESERVE 0x0400 | 29 | #define MAP_NORESERVE 0x0400 |
| 30 | #define MAP_POPULATE 0x10000 | 30 | #define MAP_POPULATE 0x10000 |
| 31 | #define MAP_PRIVATE 0x002 | ||
| 32 | #define MAP_SHARED 0x001 | ||
| 33 | #define MAP_STACK 0x40000 | 31 | #define MAP_STACK 0x40000 |
| 34 | #define PROT_EXEC 0x04 | 32 | #define PROT_EXEC 0x04 |
| 35 | #define PROT_GROWSDOWN 0x01000000 | 33 | #define PROT_GROWSDOWN 0x01000000 |
diff --git a/tools/arch/parisc/include/uapi/asm/mman.h b/tools/arch/parisc/include/uapi/asm/mman.h index 1bd78758bde9..f9fd1325f5bd 100644 --- a/tools/arch/parisc/include/uapi/asm/mman.h +++ b/tools/arch/parisc/include/uapi/asm/mman.h | |||
| @@ -27,8 +27,6 @@ | |||
| 27 | #define MAP_NONBLOCK 0x20000 | 27 | #define MAP_NONBLOCK 0x20000 |
| 28 | #define MAP_NORESERVE 0x4000 | 28 | #define MAP_NORESERVE 0x4000 |
| 29 | #define MAP_POPULATE 0x10000 | 29 | #define MAP_POPULATE 0x10000 |
| 30 | #define MAP_PRIVATE 0x02 | ||
| 31 | #define MAP_SHARED 0x01 | ||
| 32 | #define MAP_STACK 0x40000 | 30 | #define MAP_STACK 0x40000 |
| 33 | #define PROT_EXEC 0x4 | 31 | #define PROT_EXEC 0x4 |
| 34 | #define PROT_GROWSDOWN 0x01000000 | 32 | #define PROT_GROWSDOWN 0x01000000 |
diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h index 8c876c166ef2..26ca425f4c2c 100644 --- a/tools/arch/powerpc/include/uapi/asm/kvm.h +++ b/tools/arch/powerpc/include/uapi/asm/kvm.h | |||
| @@ -463,10 +463,12 @@ struct kvm_ppc_cpu_char { | |||
| 463 | #define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED (1ULL << 58) | 463 | #define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED (1ULL << 58) |
| 464 | #define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF (1ULL << 57) | 464 | #define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF (1ULL << 57) |
| 465 | #define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS (1ULL << 56) | 465 | #define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS (1ULL << 56) |
| 466 | #define KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST (1ull << 54) | ||
| 466 | 467 | ||
| 467 | #define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY (1ULL << 63) | 468 | #define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY (1ULL << 63) |
| 468 | #define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR (1ULL << 62) | 469 | #define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR (1ULL << 62) |
| 469 | #define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ULL << 61) | 470 | #define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ULL << 61) |
| 471 | #define KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE (1ull << 58) | ||
| 470 | 472 | ||
| 471 | /* Per-vcpu XICS interrupt controller state */ | 473 | /* Per-vcpu XICS interrupt controller state */ |
| 472 | #define KVM_REG_PPC_ICP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c) | 474 | #define KVM_REG_PPC_ICP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c) |
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h index 6d6122524711..981ff9479648 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h | |||
| @@ -344,6 +344,7 @@ | |||
| 344 | /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ | 344 | /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ |
| 345 | #define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */ | 345 | #define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */ |
| 346 | #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ | 346 | #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ |
| 347 | #define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */ | ||
| 347 | #define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ | 348 | #define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ |
| 348 | #define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */ | 349 | #define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */ |
| 349 | #define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */ | 350 | #define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */ |
diff --git a/tools/arch/xtensa/include/uapi/asm/mman.h b/tools/arch/xtensa/include/uapi/asm/mman.h index 34dde6f44dae..f2b08c990afc 100644 --- a/tools/arch/xtensa/include/uapi/asm/mman.h +++ b/tools/arch/xtensa/include/uapi/asm/mman.h | |||
| @@ -27,8 +27,6 @@ | |||
| 27 | #define MAP_NONBLOCK 0x20000 | 27 | #define MAP_NONBLOCK 0x20000 |
| 28 | #define MAP_NORESERVE 0x0400 | 28 | #define MAP_NORESERVE 0x0400 |
| 29 | #define MAP_POPULATE 0x10000 | 29 | #define MAP_POPULATE 0x10000 |
| 30 | #define MAP_PRIVATE 0x002 | ||
| 31 | #define MAP_SHARED 0x001 | ||
| 32 | #define MAP_STACK 0x40000 | 30 | #define MAP_STACK 0x40000 |
| 33 | #define PROT_EXEC 0x4 | 31 | #define PROT_EXEC 0x4 |
| 34 | #define PROT_GROWSDOWN 0x01000000 | 32 | #define PROT_GROWSDOWN 0x01000000 |
diff --git a/tools/build/feature/test-libopencsd.c b/tools/build/feature/test-libopencsd.c index d68eb4fb40cc..2b0e02c38870 100644 --- a/tools/build/feature/test-libopencsd.c +++ b/tools/build/feature/test-libopencsd.c | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | /* | 4 | /* |
| 5 | * Check OpenCSD library version is sufficient to provide required features | 5 | * Check OpenCSD library version is sufficient to provide required features |
| 6 | */ | 6 | */ |
| 7 | #define OCSD_MIN_VER ((0 << 16) | (10 << 8) | (0)) | 7 | #define OCSD_MIN_VER ((0 << 16) | (11 << 8) | (0)) |
| 8 | #if !defined(OCSD_VER_NUM) || (OCSD_VER_NUM < OCSD_MIN_VER) | 8 | #if !defined(OCSD_VER_NUM) || (OCSD_VER_NUM < OCSD_MIN_VER) |
| 9 | #error "OpenCSD >= 0.10.0 is required" | 9 | #error "OpenCSD >= 0.11.0 is required" |
| 10 | #endif | 10 | #endif |
| 11 | 11 | ||
| 12 | int main(void) | 12 | int main(void) |
diff --git a/tools/include/uapi/asm-generic/mman-common-tools.h b/tools/include/uapi/asm-generic/mman-common-tools.h new file mode 100644 index 000000000000..af7d0d3a3182 --- /dev/null +++ b/tools/include/uapi/asm-generic/mman-common-tools.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| 2 | #ifndef __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H | ||
| 3 | #define __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H | ||
| 4 | |||
| 5 | #include <asm-generic/mman-common.h> | ||
| 6 | |||
| 7 | /* We need this because we need to have tools/include/uapi/ included in the tools | ||
| 8 | * header search path to get access to stuff that is not yet in the system's | ||
| 9 | * copy of the files in that directory, but since this cset: | ||
| 10 | * | ||
| 11 | * 746c9398f5ac ("arch: move common mmap flags to linux/mman.h") | ||
| 12 | * | ||
| 13 | * We end up making sys/mman.h, that is in the system headers, to not find the | ||
| 14 | * MAP_SHARED and MAP_PRIVATE defines because they are not anymore in our copy | ||
| 15 | * of asm-generic/mman-common.h. So we define them here and include this header | ||
| 16 | * from each of the per arch mman.h headers. | ||
| 17 | */ | ||
| 18 | #ifndef MAP_SHARED | ||
| 19 | #define MAP_SHARED 0x01 /* Share changes */ | ||
| 20 | #define MAP_PRIVATE 0x02 /* Changes are private */ | ||
| 21 | #define MAP_SHARED_VALIDATE 0x03 /* share + validate extension flags */ | ||
| 22 | #endif | ||
| 23 | #endif // __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H | ||
diff --git a/tools/include/uapi/asm-generic/mman-common.h b/tools/include/uapi/asm-generic/mman-common.h index e7ee32861d51..abd238d0f7a4 100644 --- a/tools/include/uapi/asm-generic/mman-common.h +++ b/tools/include/uapi/asm-generic/mman-common.h | |||
| @@ -15,9 +15,7 @@ | |||
| 15 | #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ | 15 | #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ |
| 16 | #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ | 16 | #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ |
| 17 | 17 | ||
| 18 | #define MAP_SHARED 0x01 /* Share changes */ | 18 | /* 0x01 - 0x03 are defined in linux/mman.h */ |
| 19 | #define MAP_PRIVATE 0x02 /* Changes are private */ | ||
| 20 | #define MAP_SHARED_VALIDATE 0x03 /* share + validate extension flags */ | ||
| 21 | #define MAP_TYPE 0x0f /* Mask for type of mapping */ | 19 | #define MAP_TYPE 0x0f /* Mask for type of mapping */ |
| 22 | #define MAP_FIXED 0x10 /* Interpret addr exactly */ | 20 | #define MAP_FIXED 0x10 /* Interpret addr exactly */ |
| 23 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ | 21 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ |
diff --git a/tools/include/uapi/asm-generic/mman.h b/tools/include/uapi/asm-generic/mman.h index 653687d9771b..36c197fc44a0 100644 --- a/tools/include/uapi/asm-generic/mman.h +++ b/tools/include/uapi/asm-generic/mman.h | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | #ifndef __ASM_GENERIC_MMAN_H | 2 | #ifndef __ASM_GENERIC_MMAN_H |
| 3 | #define __ASM_GENERIC_MMAN_H | 3 | #define __ASM_GENERIC_MMAN_H |
| 4 | 4 | ||
| 5 | #include <asm-generic/mman-common.h> | 5 | #include <asm-generic/mman-common-tools.h> |
| 6 | 6 | ||
| 7 | #define MAP_GROWSDOWN 0x0100 /* stack-like segment */ | 7 | #define MAP_GROWSDOWN 0x0100 /* stack-like segment */ |
| 8 | #define MAP_DENYWRITE 0x0800 /* ETXTBSY */ | 8 | #define MAP_DENYWRITE 0x0800 /* ETXTBSY */ |
diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h index 12cdf611d217..dee7292e1df6 100644 --- a/tools/include/uapi/asm-generic/unistd.h +++ b/tools/include/uapi/asm-generic/unistd.h | |||
| @@ -824,8 +824,17 @@ __SYSCALL(__NR_futex_time64, sys_futex) | |||
| 824 | __SYSCALL(__NR_sched_rr_get_interval_time64, sys_sched_rr_get_interval) | 824 | __SYSCALL(__NR_sched_rr_get_interval_time64, sys_sched_rr_get_interval) |
| 825 | #endif | 825 | #endif |
| 826 | 826 | ||
| 827 | #define __NR_pidfd_send_signal 424 | ||
| 828 | __SYSCALL(__NR_pidfd_send_signal, sys_pidfd_send_signal) | ||
| 829 | #define __NR_io_uring_setup 425 | ||
| 830 | __SYSCALL(__NR_io_uring_setup, sys_io_uring_setup) | ||
| 831 | #define __NR_io_uring_enter 426 | ||
| 832 | __SYSCALL(__NR_io_uring_enter, sys_io_uring_enter) | ||
| 833 | #define __NR_io_uring_register 427 | ||
| 834 | __SYSCALL(__NR_io_uring_register, sys_io_uring_register) | ||
| 835 | |||
| 827 | #undef __NR_syscalls | 836 | #undef __NR_syscalls |
| 828 | #define __NR_syscalls 424 | 837 | #define __NR_syscalls 428 |
| 829 | 838 | ||
| 830 | /* | 839 | /* |
| 831 | * 32 bit systems traditionally used different | 840 | * 32 bit systems traditionally used different |
diff --git a/tools/include/uapi/drm/i915_drm.h b/tools/include/uapi/drm/i915_drm.h index 298b2e197744..397810fa2d33 100644 --- a/tools/include/uapi/drm/i915_drm.h +++ b/tools/include/uapi/drm/i915_drm.h | |||
| @@ -1486,9 +1486,73 @@ struct drm_i915_gem_context_param { | |||
| 1486 | #define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */ | 1486 | #define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */ |
| 1487 | #define I915_CONTEXT_DEFAULT_PRIORITY 0 | 1487 | #define I915_CONTEXT_DEFAULT_PRIORITY 0 |
| 1488 | #define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */ | 1488 | #define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */ |
| 1489 | /* | ||
| 1490 | * When using the following param, value should be a pointer to | ||
| 1491 | * drm_i915_gem_context_param_sseu. | ||
| 1492 | */ | ||
| 1493 | #define I915_CONTEXT_PARAM_SSEU 0x7 | ||
| 1489 | __u64 value; | 1494 | __u64 value; |
| 1490 | }; | 1495 | }; |
| 1491 | 1496 | ||
| 1497 | /** | ||
| 1498 | * Context SSEU programming | ||
| 1499 | * | ||
| 1500 | * It may be necessary for either functional or performance reason to configure | ||
| 1501 | * a context to run with a reduced number of SSEU (where SSEU stands for Slice/ | ||
| 1502 | * Sub-slice/EU). | ||
| 1503 | * | ||
| 1504 | * This is done by configuring SSEU configuration using the below | ||
| 1505 | * @struct drm_i915_gem_context_param_sseu for every supported engine which | ||
| 1506 | * userspace intends to use. | ||
| 1507 | * | ||
| 1508 | * Not all GPUs or engines support this functionality in which case an error | ||
| 1509 | * code -ENODEV will be returned. | ||
| 1510 | * | ||
| 1511 | * Also, flexibility of possible SSEU configuration permutations varies between | ||
| 1512 | * GPU generations and software imposed limitations. Requesting such a | ||
| 1513 | * combination will return an error code of -EINVAL. | ||
| 1514 | * | ||
| 1515 | * NOTE: When perf/OA is active the context's SSEU configuration is ignored in | ||
| 1516 | * favour of a single global setting. | ||
| 1517 | */ | ||
| 1518 | struct drm_i915_gem_context_param_sseu { | ||
| 1519 | /* | ||
| 1520 | * Engine class & instance to be configured or queried. | ||
| 1521 | */ | ||
| 1522 | __u16 engine_class; | ||
| 1523 | __u16 engine_instance; | ||
| 1524 | |||
| 1525 | /* | ||
| 1526 | * Unused for now. Must be cleared to zero. | ||
| 1527 | */ | ||
| 1528 | __u32 flags; | ||
| 1529 | |||
| 1530 | /* | ||
| 1531 | * Mask of slices to enable for the context. Valid values are a subset | ||
| 1532 | * of the bitmask value returned for I915_PARAM_SLICE_MASK. | ||
| 1533 | */ | ||
| 1534 | __u64 slice_mask; | ||
| 1535 | |||
| 1536 | /* | ||
| 1537 | * Mask of subslices to enable for the context. Valid values are a | ||
| 1538 | * subset of the bitmask value return by I915_PARAM_SUBSLICE_MASK. | ||
| 1539 | */ | ||
| 1540 | __u64 subslice_mask; | ||
| 1541 | |||
| 1542 | /* | ||
| 1543 | * Minimum/Maximum number of EUs to enable per subslice for the | ||
| 1544 | * context. min_eus_per_subslice must be inferior or equal to | ||
| 1545 | * max_eus_per_subslice. | ||
| 1546 | */ | ||
| 1547 | __u16 min_eus_per_subslice; | ||
| 1548 | __u16 max_eus_per_subslice; | ||
| 1549 | |||
| 1550 | /* | ||
| 1551 | * Unused for now. Must be cleared to zero. | ||
| 1552 | */ | ||
| 1553 | __u32 rsvd; | ||
| 1554 | }; | ||
| 1555 | |||
| 1492 | enum drm_i915_oa_format { | 1556 | enum drm_i915_oa_format { |
| 1493 | I915_OA_FORMAT_A13 = 1, /* HSW only */ | 1557 | I915_OA_FORMAT_A13 = 1, /* HSW only */ |
| 1494 | I915_OA_FORMAT_A29, /* HSW only */ | 1558 | I915_OA_FORMAT_A29, /* HSW only */ |
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 3c38ac9a92a7..929c8e537a14 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h | |||
| @@ -502,16 +502,6 @@ union bpf_attr { | |||
| 502 | * Return | 502 | * Return |
| 503 | * 0 on success, or a negative error in case of failure. | 503 | * 0 on success, or a negative error in case of failure. |
| 504 | * | 504 | * |
| 505 | * int bpf_map_push_elem(struct bpf_map *map, const void *value, u64 flags) | ||
| 506 | * Description | ||
| 507 | * Push an element *value* in *map*. *flags* is one of: | ||
| 508 | * | ||
| 509 | * **BPF_EXIST** | ||
| 510 | * If the queue/stack is full, the oldest element is removed to | ||
| 511 | * make room for this. | ||
| 512 | * Return | ||
| 513 | * 0 on success, or a negative error in case of failure. | ||
| 514 | * | ||
| 515 | * int bpf_probe_read(void *dst, u32 size, const void *src) | 505 | * int bpf_probe_read(void *dst, u32 size, const void *src) |
| 516 | * Description | 506 | * Description |
| 517 | * For tracing programs, safely attempt to read *size* bytes from | 507 | * For tracing programs, safely attempt to read *size* bytes from |
| @@ -1435,14 +1425,14 @@ union bpf_attr { | |||
| 1435 | * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) | 1425 | * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx) |
| 1436 | * Description | 1426 | * Description |
| 1437 | * Equivalent to bpf_get_socket_cookie() helper that accepts | 1427 | * Equivalent to bpf_get_socket_cookie() helper that accepts |
| 1438 | * *skb*, but gets socket from **struct bpf_sock_addr** contex. | 1428 | * *skb*, but gets socket from **struct bpf_sock_addr** context. |
| 1439 | * Return | 1429 | * Return |
| 1440 | * A 8-byte long non-decreasing number. | 1430 | * A 8-byte long non-decreasing number. |
| 1441 | * | 1431 | * |
| 1442 | * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) | 1432 | * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx) |
| 1443 | * Description | 1433 | * Description |
| 1444 | * Equivalent to bpf_get_socket_cookie() helper that accepts | 1434 | * Equivalent to bpf_get_socket_cookie() helper that accepts |
| 1445 | * *skb*, but gets socket from **struct bpf_sock_ops** contex. | 1435 | * *skb*, but gets socket from **struct bpf_sock_ops** context. |
| 1446 | * Return | 1436 | * Return |
| 1447 | * A 8-byte long non-decreasing number. | 1437 | * A 8-byte long non-decreasing number. |
| 1448 | * | 1438 | * |
| @@ -2098,52 +2088,52 @@ union bpf_attr { | |||
| 2098 | * Return | 2088 | * Return |
| 2099 | * 0 on success, or a negative error in case of failure. | 2089 | * 0 on success, or a negative error in case of failure. |
| 2100 | * | 2090 | * |
| 2101 | * int bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle) | 2091 | * int bpf_rc_repeat(void *ctx) |
| 2102 | * Description | 2092 | * Description |
| 2103 | * This helper is used in programs implementing IR decoding, to | 2093 | * This helper is used in programs implementing IR decoding, to |
| 2104 | * report a successfully decoded key press with *scancode*, | 2094 | * report a successfully decoded repeat key message. This delays |
| 2105 | * *toggle* value in the given *protocol*. The scancode will be | 2095 | * the generation of a key up event for previously generated |
| 2106 | * translated to a keycode using the rc keymap, and reported as | 2096 | * key down event. |
| 2107 | * an input key down event. After a period a key up event is | ||
| 2108 | * generated. This period can be extended by calling either | ||
| 2109 | * **bpf_rc_keydown**\ () again with the same values, or calling | ||
| 2110 | * **bpf_rc_repeat**\ (). | ||
| 2111 | * | 2097 | * |
| 2112 | * Some protocols include a toggle bit, in case the button was | 2098 | * Some IR protocols like NEC have a special IR message for |
| 2113 | * released and pressed again between consecutive scancodes. | 2099 | * repeating last button, for when a button is held down. |
| 2114 | * | 2100 | * |
| 2115 | * The *ctx* should point to the lirc sample as passed into | 2101 | * The *ctx* should point to the lirc sample as passed into |
| 2116 | * the program. | 2102 | * the program. |
| 2117 | * | 2103 | * |
| 2118 | * The *protocol* is the decoded protocol number (see | ||
| 2119 | * **enum rc_proto** for some predefined values). | ||
| 2120 | * | ||
| 2121 | * This helper is only available is the kernel was compiled with | 2104 | * This helper is only available is the kernel was compiled with |
| 2122 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to | 2105 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to |
| 2123 | * "**y**". | 2106 | * "**y**". |
| 2124 | * Return | 2107 | * Return |
| 2125 | * 0 | 2108 | * 0 |
| 2126 | * | 2109 | * |
| 2127 | * int bpf_rc_repeat(void *ctx) | 2110 | * int bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle) |
| 2128 | * Description | 2111 | * Description |
| 2129 | * This helper is used in programs implementing IR decoding, to | 2112 | * This helper is used in programs implementing IR decoding, to |
| 2130 | * report a successfully decoded repeat key message. This delays | 2113 | * report a successfully decoded key press with *scancode*, |
| 2131 | * the generation of a key up event for previously generated | 2114 | * *toggle* value in the given *protocol*. The scancode will be |
| 2132 | * key down event. | 2115 | * translated to a keycode using the rc keymap, and reported as |
| 2116 | * an input key down event. After a period a key up event is | ||
| 2117 | * generated. This period can be extended by calling either | ||
| 2118 | * **bpf_rc_keydown**\ () again with the same values, or calling | ||
| 2119 | * **bpf_rc_repeat**\ (). | ||
| 2133 | * | 2120 | * |
| 2134 | * Some IR protocols like NEC have a special IR message for | 2121 | * Some protocols include a toggle bit, in case the button was |
| 2135 | * repeating last button, for when a button is held down. | 2122 | * released and pressed again between consecutive scancodes. |
| 2136 | * | 2123 | * |
| 2137 | * The *ctx* should point to the lirc sample as passed into | 2124 | * The *ctx* should point to the lirc sample as passed into |
| 2138 | * the program. | 2125 | * the program. |
| 2139 | * | 2126 | * |
| 2127 | * The *protocol* is the decoded protocol number (see | ||
| 2128 | * **enum rc_proto** for some predefined values). | ||
| 2129 | * | ||
| 2140 | * This helper is only available is the kernel was compiled with | 2130 | * This helper is only available is the kernel was compiled with |
| 2141 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to | 2131 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to |
| 2142 | * "**y**". | 2132 | * "**y**". |
| 2143 | * Return | 2133 | * Return |
| 2144 | * 0 | 2134 | * 0 |
| 2145 | * | 2135 | * |
| 2146 | * uint64_t bpf_skb_cgroup_id(struct sk_buff *skb) | 2136 | * u64 bpf_skb_cgroup_id(struct sk_buff *skb) |
| 2147 | * Description | 2137 | * Description |
| 2148 | * Return the cgroup v2 id of the socket associated with the *skb*. | 2138 | * Return the cgroup v2 id of the socket associated with the *skb*. |
| 2149 | * This is roughly similar to the **bpf_get_cgroup_classid**\ () | 2139 | * This is roughly similar to the **bpf_get_cgroup_classid**\ () |
| @@ -2159,30 +2149,12 @@ union bpf_attr { | |||
| 2159 | * Return | 2149 | * Return |
| 2160 | * The id is returned or 0 in case the id could not be retrieved. | 2150 | * The id is returned or 0 in case the id could not be retrieved. |
| 2161 | * | 2151 | * |
| 2162 | * u64 bpf_skb_ancestor_cgroup_id(struct sk_buff *skb, int ancestor_level) | ||
| 2163 | * Description | ||
| 2164 | * Return id of cgroup v2 that is ancestor of cgroup associated | ||
| 2165 | * with the *skb* at the *ancestor_level*. The root cgroup is at | ||
| 2166 | * *ancestor_level* zero and each step down the hierarchy | ||
| 2167 | * increments the level. If *ancestor_level* == level of cgroup | ||
| 2168 | * associated with *skb*, then return value will be same as that | ||
| 2169 | * of **bpf_skb_cgroup_id**\ (). | ||
| 2170 | * | ||
| 2171 | * The helper is useful to implement policies based on cgroups | ||
| 2172 | * that are upper in hierarchy than immediate cgroup associated | ||
| 2173 | * with *skb*. | ||
| 2174 | * | ||
| 2175 | * The format of returned id and helper limitations are same as in | ||
| 2176 | * **bpf_skb_cgroup_id**\ (). | ||
| 2177 | * Return | ||
| 2178 | * The id is returned or 0 in case the id could not be retrieved. | ||
| 2179 | * | ||
| 2180 | * u64 bpf_get_current_cgroup_id(void) | 2152 | * u64 bpf_get_current_cgroup_id(void) |
| 2181 | * Return | 2153 | * Return |
| 2182 | * A 64-bit integer containing the current cgroup id based | 2154 | * A 64-bit integer containing the current cgroup id based |
| 2183 | * on the cgroup within which the current task is running. | 2155 | * on the cgroup within which the current task is running. |
| 2184 | * | 2156 | * |
| 2185 | * void* get_local_storage(void *map, u64 flags) | 2157 | * void *bpf_get_local_storage(void *map, u64 flags) |
| 2186 | * Description | 2158 | * Description |
| 2187 | * Get the pointer to the local storage area. | 2159 | * Get the pointer to the local storage area. |
| 2188 | * The type and the size of the local storage is defined | 2160 | * The type and the size of the local storage is defined |
| @@ -2209,6 +2181,24 @@ union bpf_attr { | |||
| 2209 | * Return | 2181 | * Return |
| 2210 | * 0 on success, or a negative error in case of failure. | 2182 | * 0 on success, or a negative error in case of failure. |
| 2211 | * | 2183 | * |
| 2184 | * u64 bpf_skb_ancestor_cgroup_id(struct sk_buff *skb, int ancestor_level) | ||
| 2185 | * Description | ||
| 2186 | * Return id of cgroup v2 that is ancestor of cgroup associated | ||
| 2187 | * with the *skb* at the *ancestor_level*. The root cgroup is at | ||
| 2188 | * *ancestor_level* zero and each step down the hierarchy | ||
| 2189 | * increments the level. If *ancestor_level* == level of cgroup | ||
| 2190 | * associated with *skb*, then return value will be same as that | ||
| 2191 | * of **bpf_skb_cgroup_id**\ (). | ||
| 2192 | * | ||
| 2193 | * The helper is useful to implement policies based on cgroups | ||
| 2194 | * that are upper in hierarchy than immediate cgroup associated | ||
| 2195 | * with *skb*. | ||
| 2196 | * | ||
| 2197 | * The format of returned id and helper limitations are same as in | ||
| 2198 | * **bpf_skb_cgroup_id**\ (). | ||
| 2199 | * Return | ||
| 2200 | * The id is returned or 0 in case the id could not be retrieved. | ||
| 2201 | * | ||
| 2212 | * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) | 2202 | * struct bpf_sock *bpf_sk_lookup_tcp(void *ctx, struct bpf_sock_tuple *tuple, u32 tuple_size, u64 netns, u64 flags) |
| 2213 | * Description | 2203 | * Description |
| 2214 | * Look for TCP socket matching *tuple*, optionally in a child | 2204 | * Look for TCP socket matching *tuple*, optionally in a child |
| @@ -2289,6 +2279,16 @@ union bpf_attr { | |||
| 2289 | * Return | 2279 | * Return |
| 2290 | * 0 on success, or a negative error in case of failure. | 2280 | * 0 on success, or a negative error in case of failure. |
| 2291 | * | 2281 | * |
| 2282 | * int bpf_map_push_elem(struct bpf_map *map, const void *value, u64 flags) | ||
| 2283 | * Description | ||
| 2284 | * Push an element *value* in *map*. *flags* is one of: | ||
| 2285 | * | ||
| 2286 | * **BPF_EXIST** | ||
| 2287 | * If the queue/stack is full, the oldest element is | ||
| 2288 | * removed to make room for this. | ||
| 2289 | * Return | ||
| 2290 | * 0 on success, or a negative error in case of failure. | ||
| 2291 | * | ||
| 2292 | * int bpf_map_pop_elem(struct bpf_map *map, void *value) | 2292 | * int bpf_map_pop_elem(struct bpf_map *map, void *value) |
| 2293 | * Description | 2293 | * Description |
| 2294 | * Pop an element from *map*. | 2294 | * Pop an element from *map*. |
| @@ -2343,29 +2343,94 @@ union bpf_attr { | |||
| 2343 | * Return | 2343 | * Return |
| 2344 | * 0 | 2344 | * 0 |
| 2345 | * | 2345 | * |
| 2346 | * int bpf_spin_lock(struct bpf_spin_lock *lock) | ||
| 2347 | * Description | ||
| 2348 | * Acquire a spinlock represented by the pointer *lock*, which is | ||
| 2349 | * stored as part of a value of a map. Taking the lock allows to | ||
| 2350 | * safely update the rest of the fields in that value. The | ||
| 2351 | * spinlock can (and must) later be released with a call to | ||
| 2352 | * **bpf_spin_unlock**\ (\ *lock*\ ). | ||
| 2353 | * | ||
| 2354 | * Spinlocks in BPF programs come with a number of restrictions | ||
| 2355 | * and constraints: | ||
| 2356 | * | ||
| 2357 | * * **bpf_spin_lock** objects are only allowed inside maps of | ||
| 2358 | * types **BPF_MAP_TYPE_HASH** and **BPF_MAP_TYPE_ARRAY** (this | ||
| 2359 | * list could be extended in the future). | ||
| 2360 | * * BTF description of the map is mandatory. | ||
| 2361 | * * The BPF program can take ONE lock at a time, since taking two | ||
| 2362 | * or more could cause dead locks. | ||
| 2363 | * * Only one **struct bpf_spin_lock** is allowed per map element. | ||
| 2364 | * * When the lock is taken, calls (either BPF to BPF or helpers) | ||
| 2365 | * are not allowed. | ||
| 2366 | * * The **BPF_LD_ABS** and **BPF_LD_IND** instructions are not | ||
| 2367 | * allowed inside a spinlock-ed region. | ||
| 2368 | * * The BPF program MUST call **bpf_spin_unlock**\ () to release | ||
| 2369 | * the lock, on all execution paths, before it returns. | ||
| 2370 | * * The BPF program can access **struct bpf_spin_lock** only via | ||
| 2371 | * the **bpf_spin_lock**\ () and **bpf_spin_unlock**\ () | ||
| 2372 | * helpers. Loading or storing data into the **struct | ||
| 2373 | * bpf_spin_lock** *lock*\ **;** field of a map is not allowed. | ||
| 2374 | * * To use the **bpf_spin_lock**\ () helper, the BTF description | ||
| 2375 | * of the map value must be a struct and have **struct | ||
| 2376 | * bpf_spin_lock** *anyname*\ **;** field at the top level. | ||
| 2377 | * Nested lock inside another struct is not allowed. | ||
| 2378 | * * The **struct bpf_spin_lock** *lock* field in a map value must | ||
| 2379 | * be aligned on a multiple of 4 bytes in that value. | ||
| 2380 | * * Syscall with command **BPF_MAP_LOOKUP_ELEM** does not copy | ||
| 2381 | * the **bpf_spin_lock** field to user space. | ||
| 2382 | * * Syscall with command **BPF_MAP_UPDATE_ELEM**, or update from | ||
| 2383 | * a BPF program, do not update the **bpf_spin_lock** field. | ||
| 2384 | * * **bpf_spin_lock** cannot be on the stack or inside a | ||
| 2385 | * networking packet (it can only be inside of a map values). | ||
| 2386 | * * **bpf_spin_lock** is available to root only. | ||
| 2387 | * * Tracing programs and socket filter programs cannot use | ||
| 2388 | * **bpf_spin_lock**\ () due to insufficient preemption checks | ||
| 2389 | * (but this may change in the future). | ||
| 2390 | * * **bpf_spin_lock** is not allowed in inner maps of map-in-map. | ||
| 2391 | * Return | ||
| 2392 | * 0 | ||
| 2393 | * | ||
| 2394 | * int bpf_spin_unlock(struct bpf_spin_lock *lock) | ||
| 2395 | * Description | ||
| 2396 | * Release the *lock* previously locked by a call to | ||
| 2397 | * **bpf_spin_lock**\ (\ *lock*\ ). | ||
| 2398 | * Return | ||
| 2399 | * 0 | ||
| 2400 | * | ||
| 2346 | * struct bpf_sock *bpf_sk_fullsock(struct bpf_sock *sk) | 2401 | * struct bpf_sock *bpf_sk_fullsock(struct bpf_sock *sk) |
| 2347 | * Description | 2402 | * Description |
| 2348 | * This helper gets a **struct bpf_sock** pointer such | 2403 | * This helper gets a **struct bpf_sock** pointer such |
| 2349 | * that all the fields in bpf_sock can be accessed. | 2404 | * that all the fields in this **bpf_sock** can be accessed. |
| 2350 | * Return | 2405 | * Return |
| 2351 | * A **struct bpf_sock** pointer on success, or NULL in | 2406 | * A **struct bpf_sock** pointer on success, or **NULL** in |
| 2352 | * case of failure. | 2407 | * case of failure. |
| 2353 | * | 2408 | * |
| 2354 | * struct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *sk) | 2409 | * struct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *sk) |
| 2355 | * Description | 2410 | * Description |
| 2356 | * This helper gets a **struct bpf_tcp_sock** pointer from a | 2411 | * This helper gets a **struct bpf_tcp_sock** pointer from a |
| 2357 | * **struct bpf_sock** pointer. | 2412 | * **struct bpf_sock** pointer. |
| 2358 | * | ||
| 2359 | * Return | 2413 | * Return |
| 2360 | * A **struct bpf_tcp_sock** pointer on success, or NULL in | 2414 | * A **struct bpf_tcp_sock** pointer on success, or **NULL** in |
| 2361 | * case of failure. | 2415 | * case of failure. |
| 2362 | * | 2416 | * |
| 2363 | * int bpf_skb_ecn_set_ce(struct sk_buf *skb) | 2417 | * int bpf_skb_ecn_set_ce(struct sk_buf *skb) |
| 2364 | * Description | 2418 | * Description |
| 2365 | * Sets ECN of IP header to ce (congestion encountered) if | 2419 | * Set ECN (Explicit Congestion Notification) field of IP header |
| 2366 | * current value is ect (ECN capable). Works with IPv6 and IPv4. | 2420 | * to **CE** (Congestion Encountered) if current value is **ECT** |
| 2367 | * Return | 2421 | * (ECN Capable Transport). Otherwise, do nothing. Works with IPv6 |
| 2368 | * 1 if set, 0 if not set. | 2422 | * and IPv4. |
| 2423 | * Return | ||
| 2424 | * 1 if the **CE** flag is set (either by the current helper call | ||
| 2425 | * or because it was already present), 0 if it is not set. | ||
| 2426 | * | ||
| 2427 | * struct bpf_sock *bpf_get_listener_sock(struct bpf_sock *sk) | ||
| 2428 | * Description | ||
| 2429 | * Return a **struct bpf_sock** pointer in **TCP_LISTEN** state. | ||
| 2430 | * **bpf_sk_release**\ () is unnecessary and not allowed. | ||
| 2431 | * Return | ||
| 2432 | * A **struct bpf_sock** pointer on success, or **NULL** in | ||
| 2433 | * case of failure. | ||
| 2369 | */ | 2434 | */ |
| 2370 | #define __BPF_FUNC_MAPPER(FN) \ | 2435 | #define __BPF_FUNC_MAPPER(FN) \ |
| 2371 | FN(unspec), \ | 2436 | FN(unspec), \ |
| @@ -2465,7 +2530,8 @@ union bpf_attr { | |||
| 2465 | FN(spin_unlock), \ | 2530 | FN(spin_unlock), \ |
| 2466 | FN(sk_fullsock), \ | 2531 | FN(sk_fullsock), \ |
| 2467 | FN(tcp_sock), \ | 2532 | FN(tcp_sock), \ |
| 2468 | FN(skb_ecn_set_ce), | 2533 | FN(skb_ecn_set_ce), \ |
| 2534 | FN(get_listener_sock), | ||
| 2469 | 2535 | ||
| 2470 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 2536 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 2471 | * function eBPF program intends to call | 2537 | * function eBPF program intends to call |
diff --git a/tools/include/uapi/linux/fcntl.h b/tools/include/uapi/linux/fcntl.h index 6448cdd9a350..a2f8658f1c55 100644 --- a/tools/include/uapi/linux/fcntl.h +++ b/tools/include/uapi/linux/fcntl.h | |||
| @@ -41,6 +41,7 @@ | |||
| 41 | #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ | 41 | #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ |
| 42 | #define F_SEAL_GROW 0x0004 /* prevent file from growing */ | 42 | #define F_SEAL_GROW 0x0004 /* prevent file from growing */ |
| 43 | #define F_SEAL_WRITE 0x0008 /* prevent writes */ | 43 | #define F_SEAL_WRITE 0x0008 /* prevent writes */ |
| 44 | #define F_SEAL_FUTURE_WRITE 0x0010 /* prevent future writes while mapped */ | ||
| 44 | /* (1U << 31) is reserved for signed error codes */ | 45 | /* (1U << 31) is reserved for signed error codes */ |
| 45 | 46 | ||
| 46 | /* | 47 | /* |
diff --git a/tools/include/uapi/linux/mman.h b/tools/include/uapi/linux/mman.h index d0f515d53299..fc1a64c3447b 100644 --- a/tools/include/uapi/linux/mman.h +++ b/tools/include/uapi/linux/mman.h | |||
| @@ -12,6 +12,10 @@ | |||
| 12 | #define OVERCOMMIT_ALWAYS 1 | 12 | #define OVERCOMMIT_ALWAYS 1 |
| 13 | #define OVERCOMMIT_NEVER 2 | 13 | #define OVERCOMMIT_NEVER 2 |
| 14 | 14 | ||
| 15 | #define MAP_SHARED 0x01 /* Share changes */ | ||
| 16 | #define MAP_PRIVATE 0x02 /* Changes are private */ | ||
| 17 | #define MAP_SHARED_VALIDATE 0x03 /* share + validate extension flags */ | ||
| 18 | |||
| 15 | /* | 19 | /* |
| 16 | * Huge page size encoding when MAP_HUGETLB is specified, and a huge page | 20 | * Huge page size encoding when MAP_HUGETLB is specified, and a huge page |
| 17 | * size other than the default is desired. See hugetlb_encode.h. | 21 | * size other than the default is desired. See hugetlb_encode.h. |
diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 61aaacf0cfa1..5bf8e52c41fc 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | BPF_VERSION = 0 | 4 | BPF_VERSION = 0 |
| 5 | BPF_PATCHLEVEL = 0 | 5 | BPF_PATCHLEVEL = 0 |
| 6 | BPF_EXTRAVERSION = 1 | 6 | BPF_EXTRAVERSION = 2 |
| 7 | 7 | ||
| 8 | MAKEFLAGS += --no-print-directory | 8 | MAKEFLAGS += --no-print-directory |
| 9 | 9 | ||
| @@ -79,8 +79,6 @@ export prefix libdir src obj | |||
| 79 | libdir_SQ = $(subst ','\'',$(libdir)) | 79 | libdir_SQ = $(subst ','\'',$(libdir)) |
| 80 | libdir_relative_SQ = $(subst ','\'',$(libdir_relative)) | 80 | libdir_relative_SQ = $(subst ','\'',$(libdir_relative)) |
| 81 | 81 | ||
| 82 | LIB_FILE = libbpf.a libbpf.so | ||
| 83 | |||
| 84 | VERSION = $(BPF_VERSION) | 82 | VERSION = $(BPF_VERSION) |
| 85 | PATCHLEVEL = $(BPF_PATCHLEVEL) | 83 | PATCHLEVEL = $(BPF_PATCHLEVEL) |
| 86 | EXTRAVERSION = $(BPF_EXTRAVERSION) | 84 | EXTRAVERSION = $(BPF_EXTRAVERSION) |
| @@ -88,7 +86,10 @@ EXTRAVERSION = $(BPF_EXTRAVERSION) | |||
| 88 | OBJ = $@ | 86 | OBJ = $@ |
| 89 | N = | 87 | N = |
| 90 | 88 | ||
| 91 | LIBBPF_VERSION = $(BPF_VERSION).$(BPF_PATCHLEVEL).$(BPF_EXTRAVERSION) | 89 | LIBBPF_VERSION = $(BPF_VERSION).$(BPF_PATCHLEVEL).$(BPF_EXTRAVERSION) |
| 90 | |||
| 91 | LIB_TARGET = libbpf.a libbpf.so.$(LIBBPF_VERSION) | ||
| 92 | LIB_FILE = libbpf.a libbpf.so* | ||
| 92 | 93 | ||
| 93 | # Set compile option CFLAGS | 94 | # Set compile option CFLAGS |
| 94 | ifdef EXTRA_CFLAGS | 95 | ifdef EXTRA_CFLAGS |
| @@ -128,16 +129,18 @@ all: | |||
| 128 | export srctree OUTPUT CC LD CFLAGS V | 129 | export srctree OUTPUT CC LD CFLAGS V |
| 129 | include $(srctree)/tools/build/Makefile.include | 130 | include $(srctree)/tools/build/Makefile.include |
| 130 | 131 | ||
| 131 | BPF_IN := $(OUTPUT)libbpf-in.o | 132 | BPF_IN := $(OUTPUT)libbpf-in.o |
| 132 | LIB_FILE := $(addprefix $(OUTPUT),$(LIB_FILE)) | 133 | VERSION_SCRIPT := libbpf.map |
| 133 | VERSION_SCRIPT := libbpf.map | 134 | |
| 135 | LIB_TARGET := $(addprefix $(OUTPUT),$(LIB_TARGET)) | ||
| 136 | LIB_FILE := $(addprefix $(OUTPUT),$(LIB_FILE)) | ||
| 134 | 137 | ||
| 135 | GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN) | \ | 138 | GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN) | \ |
| 136 | awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {s++} END{print s}') | 139 | awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {s++} END{print s}') |
| 137 | VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so | \ | 140 | VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so | \ |
| 138 | grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l) | 141 | grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l) |
| 139 | 142 | ||
| 140 | CMD_TARGETS = $(LIB_FILE) | 143 | CMD_TARGETS = $(LIB_TARGET) |
| 141 | 144 | ||
| 142 | CXX_TEST_TARGET = $(OUTPUT)test_libbpf | 145 | CXX_TEST_TARGET = $(OUTPUT)test_libbpf |
| 143 | 146 | ||
| @@ -170,9 +173,13 @@ $(BPF_IN): force elfdep bpfdep | |||
| 170 | echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true | 173 | echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true |
| 171 | $(Q)$(MAKE) $(build)=libbpf | 174 | $(Q)$(MAKE) $(build)=libbpf |
| 172 | 175 | ||
| 173 | $(OUTPUT)libbpf.so: $(BPF_IN) | 176 | $(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION) |
| 174 | $(QUIET_LINK)$(CC) --shared -Wl,--version-script=$(VERSION_SCRIPT) \ | 177 | |
| 175 | $^ -o $@ | 178 | $(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN) |
| 179 | $(QUIET_LINK)$(CC) --shared -Wl,-soname,libbpf.so.$(VERSION) \ | ||
| 180 | -Wl,--version-script=$(VERSION_SCRIPT) $^ -o $@ | ||
| 181 | @ln -sf $(@F) $(OUTPUT)libbpf.so | ||
| 182 | @ln -sf $(@F) $(OUTPUT)libbpf.so.$(VERSION) | ||
| 176 | 183 | ||
| 177 | $(OUTPUT)libbpf.a: $(BPF_IN) | 184 | $(OUTPUT)libbpf.a: $(BPF_IN) |
| 178 | $(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^ | 185 | $(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^ |
| @@ -192,6 +199,12 @@ check_abi: $(OUTPUT)libbpf.so | |||
| 192 | exit 1; \ | 199 | exit 1; \ |
| 193 | fi | 200 | fi |
| 194 | 201 | ||
| 202 | define do_install_mkdir | ||
| 203 | if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ | ||
| 204 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ | ||
| 205 | fi | ||
| 206 | endef | ||
| 207 | |||
| 195 | define do_install | 208 | define do_install |
| 196 | if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ | 209 | if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ |
| 197 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ | 210 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ |
| @@ -200,8 +213,9 @@ define do_install | |||
| 200 | endef | 213 | endef |
| 201 | 214 | ||
| 202 | install_lib: all_cmd | 215 | install_lib: all_cmd |
| 203 | $(call QUIET_INSTALL, $(LIB_FILE)) \ | 216 | $(call QUIET_INSTALL, $(LIB_TARGET)) \ |
| 204 | $(call do_install,$(LIB_FILE),$(libdir_SQ)) | 217 | $(call do_install_mkdir,$(libdir_SQ)); \ |
| 218 | cp -fpR $(LIB_FILE) $(DESTDIR)$(libdir_SQ) | ||
| 205 | 219 | ||
| 206 | install_headers: | 220 | install_headers: |
| 207 | $(call QUIET_INSTALL, headers) \ | 221 | $(call QUIET_INSTALL, headers) \ |
| @@ -219,7 +233,7 @@ config-clean: | |||
| 219 | 233 | ||
| 220 | clean: | 234 | clean: |
| 221 | $(call QUIET_CLEAN, libbpf) $(RM) $(TARGETS) $(CXX_TEST_TARGET) \ | 235 | $(call QUIET_CLEAN, libbpf) $(RM) $(TARGETS) $(CXX_TEST_TARGET) \ |
| 222 | *.o *~ *.a *.so .*.d .*.cmd LIBBPF-CFLAGS | 236 | *.o *~ *.a *.so *.so.$(VERSION) .*.d .*.cmd LIBBPF-CFLAGS |
| 223 | $(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf | 237 | $(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf |
| 224 | 238 | ||
| 225 | 239 | ||
diff --git a/tools/lib/bpf/README.rst b/tools/lib/bpf/README.rst index 5788479384ca..cef7b77eab69 100644 --- a/tools/lib/bpf/README.rst +++ b/tools/lib/bpf/README.rst | |||
| @@ -111,6 +111,7 @@ starting from ``0.0.1``. | |||
| 111 | 111 | ||
| 112 | Every time ABI is being changed, e.g. because a new symbol is added or | 112 | Every time ABI is being changed, e.g. because a new symbol is added or |
| 113 | semantic of existing symbol is changed, ABI version should be bumped. | 113 | semantic of existing symbol is changed, ABI version should be bumped. |
| 114 | This bump in ABI version is at most once per kernel development cycle. | ||
| 114 | 115 | ||
| 115 | For example, if current state of ``libbpf.map`` is: | 116 | For example, if current state of ``libbpf.map`` is: |
| 116 | 117 | ||
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index 1b8d8cdd3575..87e3020ac1bc 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c | |||
| @@ -1602,16 +1602,12 @@ static bool btf_equal_int(struct btf_type *t1, struct btf_type *t2) | |||
| 1602 | /* Calculate type signature hash of ENUM. */ | 1602 | /* Calculate type signature hash of ENUM. */ |
| 1603 | static __u32 btf_hash_enum(struct btf_type *t) | 1603 | static __u32 btf_hash_enum(struct btf_type *t) |
| 1604 | { | 1604 | { |
| 1605 | struct btf_enum *member = (struct btf_enum *)(t + 1); | 1605 | __u32 h; |
| 1606 | __u32 vlen = BTF_INFO_VLEN(t->info); | ||
| 1607 | __u32 h = btf_hash_common(t); | ||
| 1608 | int i; | ||
| 1609 | 1606 | ||
| 1610 | for (i = 0; i < vlen; i++) { | 1607 | /* don't hash vlen and enum members to support enum fwd resolving */ |
| 1611 | h = hash_combine(h, member->name_off); | 1608 | h = hash_combine(0, t->name_off); |
| 1612 | h = hash_combine(h, member->val); | 1609 | h = hash_combine(h, t->info & ~0xffff); |
| 1613 | member++; | 1610 | h = hash_combine(h, t->size); |
| 1614 | } | ||
| 1615 | return h; | 1611 | return h; |
| 1616 | } | 1612 | } |
| 1617 | 1613 | ||
| @@ -1637,6 +1633,22 @@ static bool btf_equal_enum(struct btf_type *t1, struct btf_type *t2) | |||
| 1637 | return true; | 1633 | return true; |
| 1638 | } | 1634 | } |
| 1639 | 1635 | ||
| 1636 | static inline bool btf_is_enum_fwd(struct btf_type *t) | ||
| 1637 | { | ||
| 1638 | return BTF_INFO_KIND(t->info) == BTF_KIND_ENUM && | ||
| 1639 | BTF_INFO_VLEN(t->info) == 0; | ||
| 1640 | } | ||
| 1641 | |||
| 1642 | static bool btf_compat_enum(struct btf_type *t1, struct btf_type *t2) | ||
| 1643 | { | ||
| 1644 | if (!btf_is_enum_fwd(t1) && !btf_is_enum_fwd(t2)) | ||
| 1645 | return btf_equal_enum(t1, t2); | ||
| 1646 | /* ignore vlen when comparing */ | ||
| 1647 | return t1->name_off == t2->name_off && | ||
| 1648 | (t1->info & ~0xffff) == (t2->info & ~0xffff) && | ||
| 1649 | t1->size == t2->size; | ||
| 1650 | } | ||
| 1651 | |||
| 1640 | /* | 1652 | /* |
| 1641 | * Calculate type signature hash of STRUCT/UNION, ignoring referenced type IDs, | 1653 | * Calculate type signature hash of STRUCT/UNION, ignoring referenced type IDs, |
| 1642 | * as referenced type IDs equivalence is established separately during type | 1654 | * as referenced type IDs equivalence is established separately during type |
| @@ -1860,6 +1872,17 @@ static int btf_dedup_prim_type(struct btf_dedup *d, __u32 type_id) | |||
| 1860 | new_id = cand_node->type_id; | 1872 | new_id = cand_node->type_id; |
| 1861 | break; | 1873 | break; |
| 1862 | } | 1874 | } |
| 1875 | if (d->opts.dont_resolve_fwds) | ||
| 1876 | continue; | ||
| 1877 | if (btf_compat_enum(t, cand)) { | ||
| 1878 | if (btf_is_enum_fwd(t)) { | ||
| 1879 | /* resolve fwd to full enum */ | ||
| 1880 | new_id = cand_node->type_id; | ||
| 1881 | break; | ||
| 1882 | } | ||
| 1883 | /* resolve canonical enum fwd to full enum */ | ||
| 1884 | d->map[cand_node->type_id] = type_id; | ||
| 1885 | } | ||
| 1863 | } | 1886 | } |
| 1864 | break; | 1887 | break; |
| 1865 | 1888 | ||
| @@ -2084,15 +2107,15 @@ static int btf_dedup_is_equiv(struct btf_dedup *d, __u32 cand_id, | |||
| 2084 | return fwd_kind == real_kind; | 2107 | return fwd_kind == real_kind; |
| 2085 | } | 2108 | } |
| 2086 | 2109 | ||
| 2087 | if (cand_type->info != canon_type->info) | ||
| 2088 | return 0; | ||
| 2089 | |||
| 2090 | switch (cand_kind) { | 2110 | switch (cand_kind) { |
| 2091 | case BTF_KIND_INT: | 2111 | case BTF_KIND_INT: |
| 2092 | return btf_equal_int(cand_type, canon_type); | 2112 | return btf_equal_int(cand_type, canon_type); |
| 2093 | 2113 | ||
| 2094 | case BTF_KIND_ENUM: | 2114 | case BTF_KIND_ENUM: |
| 2095 | return btf_equal_enum(cand_type, canon_type); | 2115 | if (d->opts.dont_resolve_fwds) |
| 2116 | return btf_equal_enum(cand_type, canon_type); | ||
| 2117 | else | ||
| 2118 | return btf_compat_enum(cand_type, canon_type); | ||
| 2096 | 2119 | ||
| 2097 | case BTF_KIND_FWD: | 2120 | case BTF_KIND_FWD: |
| 2098 | return btf_equal_common(cand_type, canon_type); | 2121 | return btf_equal_common(cand_type, canon_type); |
| @@ -2103,6 +2126,8 @@ static int btf_dedup_is_equiv(struct btf_dedup *d, __u32 cand_id, | |||
| 2103 | case BTF_KIND_PTR: | 2126 | case BTF_KIND_PTR: |
| 2104 | case BTF_KIND_TYPEDEF: | 2127 | case BTF_KIND_TYPEDEF: |
| 2105 | case BTF_KIND_FUNC: | 2128 | case BTF_KIND_FUNC: |
| 2129 | if (cand_type->info != canon_type->info) | ||
| 2130 | return 0; | ||
| 2106 | return btf_dedup_is_equiv(d, cand_type->type, canon_type->type); | 2131 | return btf_dedup_is_equiv(d, cand_type->type, canon_type->type); |
| 2107 | 2132 | ||
| 2108 | case BTF_KIND_ARRAY: { | 2133 | case BTF_KIND_ARRAY: { |
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index e6ad87512519..11c25d9ea431 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
| @@ -840,12 +840,19 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags) | |||
| 840 | obj->efile.maps_shndx = idx; | 840 | obj->efile.maps_shndx = idx; |
| 841 | else if (strcmp(name, BTF_ELF_SEC) == 0) { | 841 | else if (strcmp(name, BTF_ELF_SEC) == 0) { |
| 842 | obj->btf = btf__new(data->d_buf, data->d_size); | 842 | obj->btf = btf__new(data->d_buf, data->d_size); |
| 843 | if (IS_ERR(obj->btf) || btf__load(obj->btf)) { | 843 | if (IS_ERR(obj->btf)) { |
| 844 | pr_warning("Error loading ELF section %s: %ld. Ignored and continue.\n", | 844 | pr_warning("Error loading ELF section %s: %ld. Ignored and continue.\n", |
| 845 | BTF_ELF_SEC, PTR_ERR(obj->btf)); | 845 | BTF_ELF_SEC, PTR_ERR(obj->btf)); |
| 846 | if (!IS_ERR(obj->btf)) | ||
| 847 | btf__free(obj->btf); | ||
| 848 | obj->btf = NULL; | 846 | obj->btf = NULL; |
| 847 | continue; | ||
| 848 | } | ||
| 849 | err = btf__load(obj->btf); | ||
| 850 | if (err) { | ||
| 851 | pr_warning("Error loading %s into kernel: %d. Ignored and continue.\n", | ||
| 852 | BTF_ELF_SEC, err); | ||
| 853 | btf__free(obj->btf); | ||
| 854 | obj->btf = NULL; | ||
| 855 | err = 0; | ||
| 849 | } | 856 | } |
| 850 | } else if (strcmp(name, BTF_EXT_ELF_SEC) == 0) { | 857 | } else if (strcmp(name, BTF_EXT_ELF_SEC) == 0) { |
| 851 | btf_ext_data = data; | 858 | btf_ext_data = data; |
diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c index f98ac82c9aea..8d0078b65486 100644 --- a/tools/lib/bpf/xsk.c +++ b/tools/lib/bpf/xsk.c | |||
| @@ -126,8 +126,8 @@ static void xsk_set_umem_config(struct xsk_umem_config *cfg, | |||
| 126 | cfg->frame_headroom = usr_cfg->frame_headroom; | 126 | cfg->frame_headroom = usr_cfg->frame_headroom; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | static void xsk_set_xdp_socket_config(struct xsk_socket_config *cfg, | 129 | static int xsk_set_xdp_socket_config(struct xsk_socket_config *cfg, |
| 130 | const struct xsk_socket_config *usr_cfg) | 130 | const struct xsk_socket_config *usr_cfg) |
| 131 | { | 131 | { |
| 132 | if (!usr_cfg) { | 132 | if (!usr_cfg) { |
| 133 | cfg->rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS; | 133 | cfg->rx_size = XSK_RING_CONS__DEFAULT_NUM_DESCS; |
| @@ -135,14 +135,19 @@ static void xsk_set_xdp_socket_config(struct xsk_socket_config *cfg, | |||
| 135 | cfg->libbpf_flags = 0; | 135 | cfg->libbpf_flags = 0; |
| 136 | cfg->xdp_flags = 0; | 136 | cfg->xdp_flags = 0; |
| 137 | cfg->bind_flags = 0; | 137 | cfg->bind_flags = 0; |
| 138 | return; | 138 | return 0; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | if (usr_cfg->libbpf_flags & ~XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD) | ||
| 142 | return -EINVAL; | ||
| 143 | |||
| 141 | cfg->rx_size = usr_cfg->rx_size; | 144 | cfg->rx_size = usr_cfg->rx_size; |
| 142 | cfg->tx_size = usr_cfg->tx_size; | 145 | cfg->tx_size = usr_cfg->tx_size; |
| 143 | cfg->libbpf_flags = usr_cfg->libbpf_flags; | 146 | cfg->libbpf_flags = usr_cfg->libbpf_flags; |
| 144 | cfg->xdp_flags = usr_cfg->xdp_flags; | 147 | cfg->xdp_flags = usr_cfg->xdp_flags; |
| 145 | cfg->bind_flags = usr_cfg->bind_flags; | 148 | cfg->bind_flags = usr_cfg->bind_flags; |
| 149 | |||
| 150 | return 0; | ||
| 146 | } | 151 | } |
| 147 | 152 | ||
| 148 | int xsk_umem__create(struct xsk_umem **umem_ptr, void *umem_area, __u64 size, | 153 | int xsk_umem__create(struct xsk_umem **umem_ptr, void *umem_area, __u64 size, |
| @@ -557,7 +562,9 @@ int xsk_socket__create(struct xsk_socket **xsk_ptr, const char *ifname, | |||
| 557 | } | 562 | } |
| 558 | strncpy(xsk->ifname, ifname, IFNAMSIZ); | 563 | strncpy(xsk->ifname, ifname, IFNAMSIZ); |
| 559 | 564 | ||
| 560 | xsk_set_xdp_socket_config(&xsk->config, usr_config); | 565 | err = xsk_set_xdp_socket_config(&xsk->config, usr_config); |
| 566 | if (err) | ||
| 567 | goto out_socket; | ||
| 561 | 568 | ||
| 562 | if (rx) { | 569 | if (rx) { |
| 563 | err = setsockopt(xsk->fd, SOL_XDP, XDP_RX_RING, | 570 | err = setsockopt(xsk->fd, SOL_XDP, XDP_RX_RING, |
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index c9d038f91af6..53f8be0f4a1f 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile | |||
| @@ -25,14 +25,17 @@ LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a | |||
| 25 | OBJTOOL := $(OUTPUT)objtool | 25 | OBJTOOL := $(OUTPUT)objtool |
| 26 | OBJTOOL_IN := $(OBJTOOL)-in.o | 26 | OBJTOOL_IN := $(OBJTOOL)-in.o |
| 27 | 27 | ||
| 28 | LIBELF_FLAGS := $(shell pkg-config libelf --cflags 2>/dev/null) | ||
| 29 | LIBELF_LIBS := $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) | ||
| 30 | |||
| 28 | all: $(OBJTOOL) | 31 | all: $(OBJTOOL) |
| 29 | 32 | ||
| 30 | INCLUDES := -I$(srctree)/tools/include \ | 33 | INCLUDES := -I$(srctree)/tools/include \ |
| 31 | -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ | 34 | -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ |
| 32 | -I$(srctree)/tools/objtool/arch/$(ARCH)/include | 35 | -I$(srctree)/tools/objtool/arch/$(ARCH)/include |
| 33 | WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed | 36 | WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed |
| 34 | CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) | 37 | CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) |
| 35 | LDFLAGS += -lelf $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) | 38 | LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) |
| 36 | 39 | ||
| 37 | # Allow old libelf to be used: | 40 | # Allow old libelf to be used: |
| 38 | elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) | 41 | elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) |
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 01f7555fd933..e8c9f77e9010 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
| @@ -481,8 +481,8 @@ $(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_t | |||
| 481 | mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c | 481 | mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c |
| 482 | mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh | 482 | mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh |
| 483 | 483 | ||
| 484 | $(mmap_flags_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) | 484 | $(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) |
| 485 | $(Q)$(SHELL) '$(mmap_flags_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ | 485 | $(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ |
| 486 | 486 | ||
| 487 | mount_flags_array := $(beauty_outdir)/mount_flags_array.c | 487 | mount_flags_array := $(beauty_outdir)/mount_flags_array.c |
| 488 | mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh | 488 | mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh |
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl index 2ae92fddb6d5..92ee0b4378d4 100644 --- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl | |||
| @@ -345,6 +345,10 @@ | |||
| 345 | 334 common rseq __x64_sys_rseq | 345 | 334 common rseq __x64_sys_rseq |
| 346 | # don't use numbers 387 through 423, add new calls after the last | 346 | # don't use numbers 387 through 423, add new calls after the last |
| 347 | # 'common' entry | 347 | # 'common' entry |
| 348 | 424 common pidfd_send_signal __x64_sys_pidfd_send_signal | ||
| 349 | 425 common io_uring_setup __x64_sys_io_uring_setup | ||
| 350 | 426 common io_uring_enter __x64_sys_io_uring_enter | ||
| 351 | 427 common io_uring_register __x64_sys_io_uring_register | ||
| 348 | 352 | ||
| 349 | # | 353 | # |
| 350 | # x32-specific system call numbers start at 512 to avoid cache impact | 354 | # x32-specific system call numbers start at 512 to avoid cache impact |
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh index 7b55613924de..c68ee06cae63 100755 --- a/tools/perf/check-headers.sh +++ b/tools/perf/check-headers.sh | |||
| @@ -103,7 +103,7 @@ done | |||
| 103 | # diff with extra ignore lines | 103 | # diff with extra ignore lines |
| 104 | check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' | 104 | check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' |
| 105 | check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' | 105 | check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' |
| 106 | check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common.h>"' | 106 | check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"' |
| 107 | check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' | 107 | check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' |
| 108 | 108 | ||
| 109 | # diff non-symmetric files | 109 | # diff non-symmetric files |
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index e38518cdcbc3..74ef92f1d19a 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
| @@ -107,6 +107,7 @@ import os | |||
| 107 | from PySide.QtCore import * | 107 | from PySide.QtCore import * |
| 108 | from PySide.QtGui import * | 108 | from PySide.QtGui import * |
| 109 | from PySide.QtSql import * | 109 | from PySide.QtSql import * |
| 110 | pyside_version_1 = True | ||
| 110 | from decimal import * | 111 | from decimal import * |
| 111 | from ctypes import * | 112 | from ctypes import * |
| 112 | from multiprocessing import Process, Array, Value, Event | 113 | from multiprocessing import Process, Array, Value, Event |
| @@ -1526,6 +1527,19 @@ def BranchDataPrep(query): | |||
| 1526 | " (" + dsoname(query.value(15)) + ")") | 1527 | " (" + dsoname(query.value(15)) + ")") |
| 1527 | return data | 1528 | return data |
| 1528 | 1529 | ||
| 1530 | def BranchDataPrepWA(query): | ||
| 1531 | data = [] | ||
| 1532 | data.append(query.value(0)) | ||
| 1533 | # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string | ||
| 1534 | data.append("{:>19}".format(query.value(1))) | ||
| 1535 | for i in xrange(2, 8): | ||
| 1536 | data.append(query.value(i)) | ||
| 1537 | data.append(tohex(query.value(8)).rjust(16) + " " + query.value(9) + offstr(query.value(10)) + | ||
| 1538 | " (" + dsoname(query.value(11)) + ")" + " -> " + | ||
| 1539 | tohex(query.value(12)) + " " + query.value(13) + offstr(query.value(14)) + | ||
| 1540 | " (" + dsoname(query.value(15)) + ")") | ||
| 1541 | return data | ||
| 1542 | |||
| 1529 | # Branch data model | 1543 | # Branch data model |
| 1530 | 1544 | ||
| 1531 | class BranchModel(TreeModel): | 1545 | class BranchModel(TreeModel): |
| @@ -1553,7 +1567,11 @@ class BranchModel(TreeModel): | |||
| 1553 | " AND evsel_id = " + str(self.event_id) + | 1567 | " AND evsel_id = " + str(self.event_id) + |
| 1554 | " ORDER BY samples.id" | 1568 | " ORDER BY samples.id" |
| 1555 | " LIMIT " + str(glb_chunk_sz)) | 1569 | " LIMIT " + str(glb_chunk_sz)) |
| 1556 | self.fetcher = SQLFetcher(glb, sql, BranchDataPrep, self.AddSample) | 1570 | if pyside_version_1 and sys.version_info[0] == 3: |
| 1571 | prep = BranchDataPrepWA | ||
| 1572 | else: | ||
| 1573 | prep = BranchDataPrep | ||
| 1574 | self.fetcher = SQLFetcher(glb, sql, prep, self.AddSample) | ||
| 1557 | self.fetcher.done.connect(self.Update) | 1575 | self.fetcher.done.connect(self.Update) |
| 1558 | self.fetcher.Fetch(glb_chunk_sz) | 1576 | self.fetcher.Fetch(glb_chunk_sz) |
| 1559 | 1577 | ||
| @@ -2079,14 +2097,6 @@ def IsSelectable(db, table, sql = ""): | |||
| 2079 | return False | 2097 | return False |
| 2080 | return True | 2098 | return True |
| 2081 | 2099 | ||
| 2082 | # SQL data preparation | ||
| 2083 | |||
| 2084 | def SQLTableDataPrep(query, count): | ||
| 2085 | data = [] | ||
| 2086 | for i in xrange(count): | ||
| 2087 | data.append(query.value(i)) | ||
| 2088 | return data | ||
| 2089 | |||
| 2090 | # SQL table data model item | 2100 | # SQL table data model item |
| 2091 | 2101 | ||
| 2092 | class SQLTableItem(): | 2102 | class SQLTableItem(): |
| @@ -2110,7 +2120,7 @@ class SQLTableModel(TableModel): | |||
| 2110 | self.more = True | 2120 | self.more = True |
| 2111 | self.populated = 0 | 2121 | self.populated = 0 |
| 2112 | self.column_headers = column_headers | 2122 | self.column_headers = column_headers |
| 2113 | self.fetcher = SQLFetcher(glb, sql, lambda x, y=len(column_headers): SQLTableDataPrep(x, y), self.AddSample) | 2123 | self.fetcher = SQLFetcher(glb, sql, lambda x, y=len(column_headers): self.SQLTableDataPrep(x, y), self.AddSample) |
| 2114 | self.fetcher.done.connect(self.Update) | 2124 | self.fetcher.done.connect(self.Update) |
| 2115 | self.fetcher.Fetch(glb_chunk_sz) | 2125 | self.fetcher.Fetch(glb_chunk_sz) |
| 2116 | 2126 | ||
| @@ -2154,6 +2164,12 @@ class SQLTableModel(TableModel): | |||
| 2154 | def columnHeader(self, column): | 2164 | def columnHeader(self, column): |
| 2155 | return self.column_headers[column] | 2165 | return self.column_headers[column] |
| 2156 | 2166 | ||
| 2167 | def SQLTableDataPrep(self, query, count): | ||
| 2168 | data = [] | ||
| 2169 | for i in xrange(count): | ||
| 2170 | data.append(query.value(i)) | ||
| 2171 | return data | ||
| 2172 | |||
| 2157 | # SQL automatic table data model | 2173 | # SQL automatic table data model |
| 2158 | 2174 | ||
| 2159 | class SQLAutoTableModel(SQLTableModel): | 2175 | class SQLAutoTableModel(SQLTableModel): |
| @@ -2182,8 +2198,32 @@ class SQLAutoTableModel(SQLTableModel): | |||
| 2182 | QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") | 2198 | QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") |
| 2183 | while query.next(): | 2199 | while query.next(): |
| 2184 | column_headers.append(query.value(0)) | 2200 | column_headers.append(query.value(0)) |
| 2201 | if pyside_version_1 and sys.version_info[0] == 3: | ||
| 2202 | if table_name == "samples_view": | ||
| 2203 | self.SQLTableDataPrep = self.samples_view_DataPrep | ||
| 2204 | if table_name == "samples": | ||
| 2205 | self.SQLTableDataPrep = self.samples_DataPrep | ||
| 2185 | super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) | 2206 | super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) |
| 2186 | 2207 | ||
| 2208 | def samples_view_DataPrep(self, query, count): | ||
| 2209 | data = [] | ||
| 2210 | data.append(query.value(0)) | ||
| 2211 | # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string | ||
| 2212 | data.append("{:>19}".format(query.value(1))) | ||
| 2213 | for i in xrange(2, count): | ||
| 2214 | data.append(query.value(i)) | ||
| 2215 | return data | ||
| 2216 | |||
| 2217 | def samples_DataPrep(self, query, count): | ||
| 2218 | data = [] | ||
| 2219 | for i in xrange(9): | ||
| 2220 | data.append(query.value(i)) | ||
| 2221 | # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string | ||
| 2222 | data.append("{:>19}".format(query.value(9))) | ||
| 2223 | for i in xrange(10, count): | ||
| 2224 | data.append(query.value(i)) | ||
| 2225 | return data | ||
| 2226 | |||
| 2187 | # Base class for custom ResizeColumnsToContents | 2227 | # Base class for custom ResizeColumnsToContents |
| 2188 | 2228 | ||
| 2189 | class ResizeColumnsToContentsBase(QObject): | 2229 | class ResizeColumnsToContentsBase(QObject): |
| @@ -2868,9 +2908,13 @@ class LibXED(): | |||
| 2868 | ok = self.xed_format_context(2, inst.xedp, inst.bufferp, sizeof(inst.buffer), ip, 0, 0) | 2908 | ok = self.xed_format_context(2, inst.xedp, inst.bufferp, sizeof(inst.buffer), ip, 0, 0) |
| 2869 | if not ok: | 2909 | if not ok: |
| 2870 | return 0, "" | 2910 | return 0, "" |
| 2911 | if sys.version_info[0] == 2: | ||
| 2912 | result = inst.buffer.value | ||
| 2913 | else: | ||
| 2914 | result = inst.buffer.value.decode() | ||
| 2871 | # Return instruction length and the disassembled instruction text | 2915 | # Return instruction length and the disassembled instruction text |
| 2872 | # For now, assume the length is in byte 166 | 2916 | # For now, assume the length is in byte 166 |
| 2873 | return inst.xedd[166], inst.buffer.value | 2917 | return inst.xedd[166], result |
| 2874 | 2918 | ||
| 2875 | def TryOpen(file_name): | 2919 | def TryOpen(file_name): |
| 2876 | try: | 2920 | try: |
| @@ -2886,9 +2930,14 @@ def Is64Bit(f): | |||
| 2886 | header = f.read(7) | 2930 | header = f.read(7) |
| 2887 | f.seek(pos) | 2931 | f.seek(pos) |
| 2888 | magic = header[0:4] | 2932 | magic = header[0:4] |
| 2889 | eclass = ord(header[4]) | 2933 | if sys.version_info[0] == 2: |
| 2890 | encoding = ord(header[5]) | 2934 | eclass = ord(header[4]) |
| 2891 | version = ord(header[6]) | 2935 | encoding = ord(header[5]) |
| 2936 | version = ord(header[6]) | ||
| 2937 | else: | ||
| 2938 | eclass = header[4] | ||
| 2939 | encoding = header[5] | ||
| 2940 | version = header[6] | ||
| 2892 | if magic == chr(127) + "ELF" and eclass > 0 and eclass < 3 and encoding > 0 and encoding < 3 and version == 1: | 2941 | if magic == chr(127) + "ELF" and eclass > 0 and eclass < 3 and encoding > 0 and encoding < 3 and version == 1: |
| 2893 | result = True if eclass == 2 else False | 2942 | result = True if eclass == 2 else False |
| 2894 | return result | 2943 | return result |
diff --git a/tools/perf/trace/beauty/mmap_flags.sh b/tools/perf/trace/beauty/mmap_flags.sh index 32bac9c0d694..5f5eefcb3c74 100755 --- a/tools/perf/trace/beauty/mmap_flags.sh +++ b/tools/perf/trace/beauty/mmap_flags.sh | |||
| @@ -1,15 +1,18 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: LGPL-2.1 | 2 | # SPDX-License-Identifier: LGPL-2.1 |
| 3 | 3 | ||
| 4 | if [ $# -ne 2 ] ; then | 4 | if [ $# -ne 3 ] ; then |
| 5 | [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/` | 5 | [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/` |
| 6 | linux_header_dir=tools/include/uapi/linux | ||
| 6 | header_dir=tools/include/uapi/asm-generic | 7 | header_dir=tools/include/uapi/asm-generic |
| 7 | arch_header_dir=tools/arch/${hostarch}/include/uapi/asm | 8 | arch_header_dir=tools/arch/${hostarch}/include/uapi/asm |
| 8 | else | 9 | else |
| 9 | header_dir=$1 | 10 | linux_header_dir=$1 |
| 10 | arch_header_dir=$2 | 11 | header_dir=$2 |
| 12 | arch_header_dir=$3 | ||
| 11 | fi | 13 | fi |
| 12 | 14 | ||
| 15 | linux_mman=${linux_header_dir}/mman.h | ||
| 13 | arch_mman=${arch_header_dir}/mman.h | 16 | arch_mman=${arch_header_dir}/mman.h |
| 14 | 17 | ||
| 15 | # those in egrep -vw are flags, we want just the bits | 18 | # those in egrep -vw are flags, we want just the bits |
| @@ -20,6 +23,11 @@ egrep -q $regex ${arch_mman} && \ | |||
| 20 | (egrep $regex ${arch_mman} | \ | 23 | (egrep $regex ${arch_mman} | \ |
| 21 | sed -r "s/$regex/\2 \1/g" | \ | 24 | sed -r "s/$regex/\2 \1/g" | \ |
| 22 | xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") | 25 | xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") |
| 26 | egrep -q $regex ${linux_mman} && \ | ||
| 27 | (egrep $regex ${linux_mman} | \ | ||
| 28 | egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \ | ||
| 29 | sed -r "s/$regex/\2 \1/g" | \ | ||
| 30 | xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") | ||
| 23 | ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+<uapi/asm-generic/mman.*' ${arch_mman}) && | 31 | ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+<uapi/asm-generic/mman.*' ${arch_mman}) && |
| 24 | (egrep $regex ${header_dir}/mman-common.h | \ | 32 | (egrep $regex ${header_dir}/mman-common.h | \ |
| 25 | egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \ | 33 | egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \ |
diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index ba4c623cd8de..39fe21e1cf93 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | |||
| @@ -387,6 +387,7 @@ cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder, | |||
| 387 | break; | 387 | break; |
| 388 | case OCSD_INSTR_ISB: | 388 | case OCSD_INSTR_ISB: |
| 389 | case OCSD_INSTR_DSB_DMB: | 389 | case OCSD_INSTR_DSB_DMB: |
| 390 | case OCSD_INSTR_WFI_WFE: | ||
| 390 | case OCSD_INSTR_OTHER: | 391 | case OCSD_INSTR_OTHER: |
| 391 | default: | 392 | default: |
| 392 | packet->last_instr_taken_branch = false; | 393 | packet->last_instr_taken_branch = false; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index ec78e93085de..6689378ee577 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
| @@ -231,35 +231,6 @@ void perf_evlist__set_leader(struct perf_evlist *evlist) | |||
| 231 | } | 231 | } |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | void perf_event_attr__set_max_precise_ip(struct perf_event_attr *pattr) | ||
| 235 | { | ||
| 236 | struct perf_event_attr attr = { | ||
| 237 | .type = PERF_TYPE_HARDWARE, | ||
| 238 | .config = PERF_COUNT_HW_CPU_CYCLES, | ||
| 239 | .exclude_kernel = 1, | ||
| 240 | .precise_ip = 3, | ||
| 241 | }; | ||
| 242 | |||
| 243 | event_attr_init(&attr); | ||
| 244 | |||
| 245 | /* | ||
| 246 | * Unnamed union member, not supported as struct member named | ||
| 247 | * initializer in older compilers such as gcc 4.4.7 | ||
| 248 | */ | ||
| 249 | attr.sample_period = 1; | ||
| 250 | |||
| 251 | while (attr.precise_ip != 0) { | ||
| 252 | int fd = sys_perf_event_open(&attr, 0, -1, -1, 0); | ||
| 253 | if (fd != -1) { | ||
| 254 | close(fd); | ||
| 255 | break; | ||
| 256 | } | ||
| 257 | --attr.precise_ip; | ||
| 258 | } | ||
| 259 | |||
| 260 | pattr->precise_ip = attr.precise_ip; | ||
| 261 | } | ||
| 262 | |||
| 263 | int __perf_evlist__add_default(struct perf_evlist *evlist, bool precise) | 234 | int __perf_evlist__add_default(struct perf_evlist *evlist, bool precise) |
| 264 | { | 235 | { |
| 265 | struct perf_evsel *evsel = perf_evsel__new_cycles(precise); | 236 | struct perf_evsel *evsel = perf_evsel__new_cycles(precise); |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index dcb68f34d2cd..6a94785b9100 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
| @@ -315,8 +315,6 @@ void perf_evlist__to_front(struct perf_evlist *evlist, | |||
| 315 | void perf_evlist__set_tracking_event(struct perf_evlist *evlist, | 315 | void perf_evlist__set_tracking_event(struct perf_evlist *evlist, |
| 316 | struct perf_evsel *tracking_evsel); | 316 | struct perf_evsel *tracking_evsel); |
| 317 | 317 | ||
| 318 | void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr); | ||
| 319 | |||
| 320 | struct perf_evsel * | 318 | struct perf_evsel * |
| 321 | perf_evlist__find_evsel_by_str(struct perf_evlist *evlist, const char *str); | 319 | perf_evlist__find_evsel_by_str(struct perf_evlist *evlist, const char *str); |
| 322 | 320 | ||
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 7835e05f0c0a..66d066f18b5b 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
| @@ -295,7 +295,6 @@ struct perf_evsel *perf_evsel__new_cycles(bool precise) | |||
| 295 | if (!precise) | 295 | if (!precise) |
| 296 | goto new_event; | 296 | goto new_event; |
| 297 | 297 | ||
| 298 | perf_event_attr__set_max_precise_ip(&attr); | ||
| 299 | /* | 298 | /* |
| 300 | * Now let the usual logic to set up the perf_event_attr defaults | 299 | * Now let the usual logic to set up the perf_event_attr defaults |
| 301 | * to kick in when we return and before perf_evsel__open() is called. | 300 | * to kick in when we return and before perf_evsel__open() is called. |
| @@ -305,6 +304,8 @@ new_event: | |||
| 305 | if (evsel == NULL) | 304 | if (evsel == NULL) |
| 306 | goto out; | 305 | goto out; |
| 307 | 306 | ||
| 307 | evsel->precise_max = true; | ||
| 308 | |||
| 308 | /* use asprintf() because free(evsel) assumes name is allocated */ | 309 | /* use asprintf() because free(evsel) assumes name is allocated */ |
| 309 | if (asprintf(&evsel->name, "cycles%s%s%.*s", | 310 | if (asprintf(&evsel->name, "cycles%s%s%.*s", |
| 310 | (attr.precise_ip || attr.exclude_kernel) ? ":" : "", | 311 | (attr.precise_ip || attr.exclude_kernel) ? ":" : "", |
| @@ -1083,7 +1084,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts, | |||
| 1083 | } | 1084 | } |
| 1084 | 1085 | ||
| 1085 | if (evsel->precise_max) | 1086 | if (evsel->precise_max) |
| 1086 | perf_event_attr__set_max_precise_ip(attr); | 1087 | attr->precise_ip = 3; |
| 1087 | 1088 | ||
| 1088 | if (opts->all_user) { | 1089 | if (opts->all_user) { |
| 1089 | attr->exclude_kernel = 1; | 1090 | attr->exclude_kernel = 1; |
| @@ -1749,6 +1750,59 @@ static bool ignore_missing_thread(struct perf_evsel *evsel, | |||
| 1749 | return true; | 1750 | return true; |
| 1750 | } | 1751 | } |
| 1751 | 1752 | ||
| 1753 | static void display_attr(struct perf_event_attr *attr) | ||
| 1754 | { | ||
| 1755 | if (verbose >= 2) { | ||
| 1756 | fprintf(stderr, "%.60s\n", graph_dotted_line); | ||
| 1757 | fprintf(stderr, "perf_event_attr:\n"); | ||
| 1758 | perf_event_attr__fprintf(stderr, attr, __open_attr__fprintf, NULL); | ||
| 1759 | fprintf(stderr, "%.60s\n", graph_dotted_line); | ||
| 1760 | } | ||
| 1761 | } | ||
| 1762 | |||
| 1763 | static int perf_event_open(struct perf_evsel *evsel, | ||
| 1764 | pid_t pid, int cpu, int group_fd, | ||
| 1765 | unsigned long flags) | ||
| 1766 | { | ||
| 1767 | int precise_ip = evsel->attr.precise_ip; | ||
| 1768 | int fd; | ||
| 1769 | |||
| 1770 | while (1) { | ||
| 1771 | pr_debug2("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx", | ||
| 1772 | pid, cpu, group_fd, flags); | ||
| 1773 | |||
| 1774 | fd = sys_perf_event_open(&evsel->attr, pid, cpu, group_fd, flags); | ||
| 1775 | if (fd >= 0) | ||
| 1776 | break; | ||
| 1777 | |||
| 1778 | /* | ||
| 1779 | * Do quick precise_ip fallback if: | ||
| 1780 | * - there is precise_ip set in perf_event_attr | ||
| 1781 | * - maximum precise is requested | ||
| 1782 | * - sys_perf_event_open failed with ENOTSUP error, | ||
| 1783 | * which is associated with wrong precise_ip | ||
| 1784 | */ | ||
| 1785 | if (!precise_ip || !evsel->precise_max || (errno != ENOTSUP)) | ||
| 1786 | break; | ||
| 1787 | |||
| 1788 | /* | ||
| 1789 | * We tried all the precise_ip values, and it's | ||
| 1790 | * still failing, so leave it to standard fallback. | ||
| 1791 | */ | ||
| 1792 | if (!evsel->attr.precise_ip) { | ||
| 1793 | evsel->attr.precise_ip = precise_ip; | ||
| 1794 | break; | ||
| 1795 | } | ||
| 1796 | |||
| 1797 | pr_debug2("\nsys_perf_event_open failed, error %d\n", -ENOTSUP); | ||
| 1798 | evsel->attr.precise_ip--; | ||
| 1799 | pr_debug2("decreasing precise_ip by one (%d)\n", evsel->attr.precise_ip); | ||
| 1800 | display_attr(&evsel->attr); | ||
| 1801 | } | ||
| 1802 | |||
| 1803 | return fd; | ||
| 1804 | } | ||
| 1805 | |||
| 1752 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | 1806 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, |
| 1753 | struct thread_map *threads) | 1807 | struct thread_map *threads) |
| 1754 | { | 1808 | { |
| @@ -1824,12 +1878,7 @@ retry_sample_id: | |||
| 1824 | if (perf_missing_features.sample_id_all) | 1878 | if (perf_missing_features.sample_id_all) |
| 1825 | evsel->attr.sample_id_all = 0; | 1879 | evsel->attr.sample_id_all = 0; |
| 1826 | 1880 | ||
| 1827 | if (verbose >= 2) { | 1881 | display_attr(&evsel->attr); |
| 1828 | fprintf(stderr, "%.60s\n", graph_dotted_line); | ||
| 1829 | fprintf(stderr, "perf_event_attr:\n"); | ||
| 1830 | perf_event_attr__fprintf(stderr, &evsel->attr, __open_attr__fprintf, NULL); | ||
| 1831 | fprintf(stderr, "%.60s\n", graph_dotted_line); | ||
| 1832 | } | ||
| 1833 | 1882 | ||
| 1834 | for (cpu = 0; cpu < cpus->nr; cpu++) { | 1883 | for (cpu = 0; cpu < cpus->nr; cpu++) { |
| 1835 | 1884 | ||
| @@ -1841,13 +1890,10 @@ retry_sample_id: | |||
| 1841 | 1890 | ||
| 1842 | group_fd = get_group_fd(evsel, cpu, thread); | 1891 | group_fd = get_group_fd(evsel, cpu, thread); |
| 1843 | retry_open: | 1892 | retry_open: |
| 1844 | pr_debug2("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx", | ||
| 1845 | pid, cpus->map[cpu], group_fd, flags); | ||
| 1846 | |||
| 1847 | test_attr__ready(); | 1893 | test_attr__ready(); |
| 1848 | 1894 | ||
| 1849 | fd = sys_perf_event_open(&evsel->attr, pid, cpus->map[cpu], | 1895 | fd = perf_event_open(evsel, pid, cpus->map[cpu], |
| 1850 | group_fd, flags); | 1896 | group_fd, flags); |
| 1851 | 1897 | ||
| 1852 | FD(evsel, cpu, thread) = fd; | 1898 | FD(evsel, cpu, thread) = fd; |
| 1853 | 1899 | ||
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c index 6e03db142091..872fab163585 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | |||
| @@ -251,19 +251,15 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params) | |||
| 251 | if (!(decoder->tsc_ctc_ratio_n % decoder->tsc_ctc_ratio_d)) | 251 | if (!(decoder->tsc_ctc_ratio_n % decoder->tsc_ctc_ratio_d)) |
| 252 | decoder->tsc_ctc_mult = decoder->tsc_ctc_ratio_n / | 252 | decoder->tsc_ctc_mult = decoder->tsc_ctc_ratio_n / |
| 253 | decoder->tsc_ctc_ratio_d; | 253 | decoder->tsc_ctc_ratio_d; |
| 254 | |||
| 255 | /* | ||
| 256 | * Allow for timestamps appearing to backwards because a TSC | ||
| 257 | * packet has slipped past a MTC packet, so allow 2 MTC ticks | ||
| 258 | * or ... | ||
| 259 | */ | ||
| 260 | decoder->tsc_slip = multdiv(2 << decoder->mtc_shift, | ||
| 261 | decoder->tsc_ctc_ratio_n, | ||
| 262 | decoder->tsc_ctc_ratio_d); | ||
| 263 | } | 254 | } |
| 264 | /* ... or 0x100 paranoia */ | 255 | |
| 265 | if (decoder->tsc_slip < 0x100) | 256 | /* |
| 266 | decoder->tsc_slip = 0x100; | 257 | * A TSC packet can slip past MTC packets so that the timestamp appears |
| 258 | * to go backwards. One estimate is that can be up to about 40 CPU | ||
| 259 | * cycles, which is certainly less than 0x1000 TSC ticks, but accept | ||
| 260 | * slippage an order of magnitude more to be on the safe side. | ||
| 261 | */ | ||
| 262 | decoder->tsc_slip = 0x10000; | ||
| 267 | 263 | ||
| 268 | intel_pt_log("timestamp: mtc_shift %u\n", decoder->mtc_shift); | 264 | intel_pt_log("timestamp: mtc_shift %u\n", decoder->mtc_shift); |
| 269 | intel_pt_log("timestamp: tsc_ctc_ratio_n %u\n", decoder->tsc_ctc_ratio_n); | 265 | intel_pt_log("timestamp: tsc_ctc_ratio_n %u\n", decoder->tsc_ctc_ratio_n); |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 61959aba7e27..3c520baa198c 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
| @@ -1421,6 +1421,20 @@ static void machine__set_kernel_mmap(struct machine *machine, | |||
| 1421 | machine->vmlinux_map->end = ~0ULL; | 1421 | machine->vmlinux_map->end = ~0ULL; |
| 1422 | } | 1422 | } |
| 1423 | 1423 | ||
| 1424 | static void machine__update_kernel_mmap(struct machine *machine, | ||
| 1425 | u64 start, u64 end) | ||
| 1426 | { | ||
| 1427 | struct map *map = machine__kernel_map(machine); | ||
| 1428 | |||
| 1429 | map__get(map); | ||
| 1430 | map_groups__remove(&machine->kmaps, map); | ||
| 1431 | |||
| 1432 | machine__set_kernel_mmap(machine, start, end); | ||
| 1433 | |||
| 1434 | map_groups__insert(&machine->kmaps, map); | ||
| 1435 | map__put(map); | ||
| 1436 | } | ||
| 1437 | |||
| 1424 | int machine__create_kernel_maps(struct machine *machine) | 1438 | int machine__create_kernel_maps(struct machine *machine) |
| 1425 | { | 1439 | { |
| 1426 | struct dso *kernel = machine__get_kernel(machine); | 1440 | struct dso *kernel = machine__get_kernel(machine); |
| @@ -1453,17 +1467,11 @@ int machine__create_kernel_maps(struct machine *machine) | |||
| 1453 | goto out_put; | 1467 | goto out_put; |
| 1454 | } | 1468 | } |
| 1455 | 1469 | ||
| 1456 | /* we have a real start address now, so re-order the kmaps */ | 1470 | /* |
| 1457 | map = machine__kernel_map(machine); | 1471 | * we have a real start address now, so re-order the kmaps |
| 1458 | 1472 | * assume it's the last in the kmaps | |
| 1459 | map__get(map); | 1473 | */ |
| 1460 | map_groups__remove(&machine->kmaps, map); | 1474 | machine__update_kernel_mmap(machine, addr, ~0ULL); |
| 1461 | |||
| 1462 | /* assume it's the last in the kmaps */ | ||
| 1463 | machine__set_kernel_mmap(machine, addr, ~0ULL); | ||
| 1464 | |||
| 1465 | map_groups__insert(&machine->kmaps, map); | ||
| 1466 | map__put(map); | ||
| 1467 | } | 1475 | } |
| 1468 | 1476 | ||
| 1469 | if (machine__create_extra_kernel_maps(machine, kernel)) | 1477 | if (machine__create_extra_kernel_maps(machine, kernel)) |
| @@ -1599,7 +1607,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine, | |||
| 1599 | if (strstr(kernel->long_name, "vmlinux")) | 1607 | if (strstr(kernel->long_name, "vmlinux")) |
| 1600 | dso__set_short_name(kernel, "[kernel.vmlinux]", false); | 1608 | dso__set_short_name(kernel, "[kernel.vmlinux]", false); |
| 1601 | 1609 | ||
| 1602 | machine__set_kernel_mmap(machine, event->mmap.start, | 1610 | machine__update_kernel_mmap(machine, event->mmap.start, |
| 1603 | event->mmap.start + event->mmap.len); | 1611 | event->mmap.start + event->mmap.len); |
| 1604 | 1612 | ||
| 1605 | /* | 1613 | /* |
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 6199a3174ab9..e0429f4ef335 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
| @@ -732,10 +732,20 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu) | |||
| 732 | 732 | ||
| 733 | if (!is_arm_pmu_core(name)) { | 733 | if (!is_arm_pmu_core(name)) { |
| 734 | pname = pe->pmu ? pe->pmu : "cpu"; | 734 | pname = pe->pmu ? pe->pmu : "cpu"; |
| 735 | |||
| 736 | /* | ||
| 737 | * uncore alias may be from different PMU | ||
| 738 | * with common prefix | ||
| 739 | */ | ||
| 740 | if (pmu_is_uncore(name) && | ||
| 741 | !strncmp(pname, name, strlen(pname))) | ||
| 742 | goto new_alias; | ||
| 743 | |||
| 735 | if (strcmp(pname, name)) | 744 | if (strcmp(pname, name)) |
| 736 | continue; | 745 | continue; |
| 737 | } | 746 | } |
| 738 | 747 | ||
| 748 | new_alias: | ||
| 739 | /* need type casts to override 'const' */ | 749 | /* need type casts to override 'const' */ |
| 740 | __perf_pmu__new_alias(head, NULL, (char *)pe->name, | 750 | __perf_pmu__new_alias(head, NULL, (char *)pe->name, |
| 741 | (char *)pe->desc, (char *)pe->event, | 751 | (char *)pe->desc, (char *)pe->event, |
diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h index c9433a496d54..c81fc350f7ad 100644 --- a/tools/testing/selftests/bpf/bpf_helpers.h +++ b/tools/testing/selftests/bpf/bpf_helpers.h | |||
| @@ -180,6 +180,8 @@ static struct bpf_sock *(*bpf_sk_fullsock)(struct bpf_sock *sk) = | |||
| 180 | (void *) BPF_FUNC_sk_fullsock; | 180 | (void *) BPF_FUNC_sk_fullsock; |
| 181 | static struct bpf_tcp_sock *(*bpf_tcp_sock)(struct bpf_sock *sk) = | 181 | static struct bpf_tcp_sock *(*bpf_tcp_sock)(struct bpf_sock *sk) = |
| 182 | (void *) BPF_FUNC_tcp_sock; | 182 | (void *) BPF_FUNC_tcp_sock; |
| 183 | static struct bpf_sock *(*bpf_get_listener_sock)(struct bpf_sock *sk) = | ||
| 184 | (void *) BPF_FUNC_get_listener_sock; | ||
| 183 | static int (*bpf_skb_ecn_set_ce)(void *ctx) = | 185 | static int (*bpf_skb_ecn_set_ce)(void *ctx) = |
| 184 | (void *) BPF_FUNC_skb_ecn_set_ce; | 186 | (void *) BPF_FUNC_skb_ecn_set_ce; |
| 185 | 187 | ||
diff --git a/tools/testing/selftests/bpf/prog_tests/map_lock.c b/tools/testing/selftests/bpf/prog_tests/map_lock.c index 90f8a206340a..ee99368c595c 100644 --- a/tools/testing/selftests/bpf/prog_tests/map_lock.c +++ b/tools/testing/selftests/bpf/prog_tests/map_lock.c | |||
| @@ -37,7 +37,7 @@ void test_map_lock(void) | |||
| 37 | const char *file = "./test_map_lock.o"; | 37 | const char *file = "./test_map_lock.o"; |
| 38 | int prog_fd, map_fd[2], vars[17] = {}; | 38 | int prog_fd, map_fd[2], vars[17] = {}; |
| 39 | pthread_t thread_id[6]; | 39 | pthread_t thread_id[6]; |
| 40 | struct bpf_object *obj; | 40 | struct bpf_object *obj = NULL; |
| 41 | int err = 0, key = 0, i; | 41 | int err = 0, key = 0, i; |
| 42 | void *ret; | 42 | void *ret; |
| 43 | 43 | ||
diff --git a/tools/testing/selftests/bpf/prog_tests/spinlock.c b/tools/testing/selftests/bpf/prog_tests/spinlock.c index 9a573a9675d7..114ebe6a438e 100644 --- a/tools/testing/selftests/bpf/prog_tests/spinlock.c +++ b/tools/testing/selftests/bpf/prog_tests/spinlock.c | |||
| @@ -5,7 +5,7 @@ void test_spinlock(void) | |||
| 5 | { | 5 | { |
| 6 | const char *file = "./test_spin_lock.o"; | 6 | const char *file = "./test_spin_lock.o"; |
| 7 | pthread_t thread_id[4]; | 7 | pthread_t thread_id[4]; |
| 8 | struct bpf_object *obj; | 8 | struct bpf_object *obj = NULL; |
| 9 | int prog_fd; | 9 | int prog_fd; |
| 10 | int err = 0, i; | 10 | int err = 0, i; |
| 11 | void *ret; | 11 | void *ret; |
diff --git a/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c b/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c index de1a43e8f610..37328f148538 100644 --- a/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c +++ b/tools/testing/selftests/bpf/progs/test_sock_fields_kern.c | |||
| @@ -8,38 +8,51 @@ | |||
| 8 | #include "bpf_helpers.h" | 8 | #include "bpf_helpers.h" |
| 9 | #include "bpf_endian.h" | 9 | #include "bpf_endian.h" |
| 10 | 10 | ||
| 11 | enum bpf_array_idx { | 11 | enum bpf_addr_array_idx { |
| 12 | SRV_IDX, | 12 | ADDR_SRV_IDX, |
| 13 | CLI_IDX, | 13 | ADDR_CLI_IDX, |
| 14 | __NR_BPF_ARRAY_IDX, | 14 | __NR_BPF_ADDR_ARRAY_IDX, |
| 15 | }; | ||
| 16 | |||
| 17 | enum bpf_result_array_idx { | ||
| 18 | EGRESS_SRV_IDX, | ||
| 19 | EGRESS_CLI_IDX, | ||
| 20 | INGRESS_LISTEN_IDX, | ||
| 21 | __NR_BPF_RESULT_ARRAY_IDX, | ||
| 22 | }; | ||
| 23 | |||
| 24 | enum bpf_linum_array_idx { | ||
| 25 | EGRESS_LINUM_IDX, | ||
| 26 | INGRESS_LINUM_IDX, | ||
| 27 | __NR_BPF_LINUM_ARRAY_IDX, | ||
| 15 | }; | 28 | }; |
| 16 | 29 | ||
| 17 | struct bpf_map_def SEC("maps") addr_map = { | 30 | struct bpf_map_def SEC("maps") addr_map = { |
| 18 | .type = BPF_MAP_TYPE_ARRAY, | 31 | .type = BPF_MAP_TYPE_ARRAY, |
| 19 | .key_size = sizeof(__u32), | 32 | .key_size = sizeof(__u32), |
| 20 | .value_size = sizeof(struct sockaddr_in6), | 33 | .value_size = sizeof(struct sockaddr_in6), |
| 21 | .max_entries = __NR_BPF_ARRAY_IDX, | 34 | .max_entries = __NR_BPF_ADDR_ARRAY_IDX, |
| 22 | }; | 35 | }; |
| 23 | 36 | ||
| 24 | struct bpf_map_def SEC("maps") sock_result_map = { | 37 | struct bpf_map_def SEC("maps") sock_result_map = { |
| 25 | .type = BPF_MAP_TYPE_ARRAY, | 38 | .type = BPF_MAP_TYPE_ARRAY, |
| 26 | .key_size = sizeof(__u32), | 39 | .key_size = sizeof(__u32), |
| 27 | .value_size = sizeof(struct bpf_sock), | 40 | .value_size = sizeof(struct bpf_sock), |
| 28 | .max_entries = __NR_BPF_ARRAY_IDX, | 41 | .max_entries = __NR_BPF_RESULT_ARRAY_IDX, |
| 29 | }; | 42 | }; |
| 30 | 43 | ||
| 31 | struct bpf_map_def SEC("maps") tcp_sock_result_map = { | 44 | struct bpf_map_def SEC("maps") tcp_sock_result_map = { |
| 32 | .type = BPF_MAP_TYPE_ARRAY, | 45 | .type = BPF_MAP_TYPE_ARRAY, |
| 33 | .key_size = sizeof(__u32), | 46 | .key_size = sizeof(__u32), |
| 34 | .value_size = sizeof(struct bpf_tcp_sock), | 47 | .value_size = sizeof(struct bpf_tcp_sock), |
| 35 | .max_entries = __NR_BPF_ARRAY_IDX, | 48 | .max_entries = __NR_BPF_RESULT_ARRAY_IDX, |
| 36 | }; | 49 | }; |
| 37 | 50 | ||
| 38 | struct bpf_map_def SEC("maps") linum_map = { | 51 | struct bpf_map_def SEC("maps") linum_map = { |
| 39 | .type = BPF_MAP_TYPE_ARRAY, | 52 | .type = BPF_MAP_TYPE_ARRAY, |
| 40 | .key_size = sizeof(__u32), | 53 | .key_size = sizeof(__u32), |
| 41 | .value_size = sizeof(__u32), | 54 | .value_size = sizeof(__u32), |
| 42 | .max_entries = 1, | 55 | .max_entries = __NR_BPF_LINUM_ARRAY_IDX, |
| 43 | }; | 56 | }; |
| 44 | 57 | ||
| 45 | static bool is_loopback6(__u32 *a6) | 58 | static bool is_loopback6(__u32 *a6) |
| @@ -100,18 +113,20 @@ static void tpcpy(struct bpf_tcp_sock *dst, | |||
| 100 | 113 | ||
| 101 | #define RETURN { \ | 114 | #define RETURN { \ |
| 102 | linum = __LINE__; \ | 115 | linum = __LINE__; \ |
| 103 | bpf_map_update_elem(&linum_map, &idx0, &linum, 0); \ | 116 | bpf_map_update_elem(&linum_map, &linum_idx, &linum, 0); \ |
| 104 | return 1; \ | 117 | return 1; \ |
| 105 | } | 118 | } |
| 106 | 119 | ||
| 107 | SEC("cgroup_skb/egress") | 120 | SEC("cgroup_skb/egress") |
| 108 | int read_sock_fields(struct __sk_buff *skb) | 121 | int egress_read_sock_fields(struct __sk_buff *skb) |
| 109 | { | 122 | { |
| 110 | __u32 srv_idx = SRV_IDX, cli_idx = CLI_IDX, idx; | 123 | __u32 srv_idx = ADDR_SRV_IDX, cli_idx = ADDR_CLI_IDX, result_idx; |
| 111 | struct sockaddr_in6 *srv_sa6, *cli_sa6; | 124 | struct sockaddr_in6 *srv_sa6, *cli_sa6; |
| 112 | struct bpf_tcp_sock *tp, *tp_ret; | 125 | struct bpf_tcp_sock *tp, *tp_ret; |
| 113 | struct bpf_sock *sk, *sk_ret; | 126 | struct bpf_sock *sk, *sk_ret; |
| 114 | __u32 linum, idx0 = 0; | 127 | __u32 linum, linum_idx; |
| 128 | |||
| 129 | linum_idx = EGRESS_LINUM_IDX; | ||
| 115 | 130 | ||
| 116 | sk = skb->sk; | 131 | sk = skb->sk; |
| 117 | if (!sk || sk->state == 10) | 132 | if (!sk || sk->state == 10) |
| @@ -132,14 +147,55 @@ int read_sock_fields(struct __sk_buff *skb) | |||
| 132 | RETURN; | 147 | RETURN; |
| 133 | 148 | ||
| 134 | if (sk->src_port == bpf_ntohs(srv_sa6->sin6_port)) | 149 | if (sk->src_port == bpf_ntohs(srv_sa6->sin6_port)) |
| 135 | idx = srv_idx; | 150 | result_idx = EGRESS_SRV_IDX; |
| 136 | else if (sk->src_port == bpf_ntohs(cli_sa6->sin6_port)) | 151 | else if (sk->src_port == bpf_ntohs(cli_sa6->sin6_port)) |
| 137 | idx = cli_idx; | 152 | result_idx = EGRESS_CLI_IDX; |
| 138 | else | 153 | else |
| 139 | RETURN; | 154 | RETURN; |
| 140 | 155 | ||
| 141 | sk_ret = bpf_map_lookup_elem(&sock_result_map, &idx); | 156 | sk_ret = bpf_map_lookup_elem(&sock_result_map, &result_idx); |
| 142 | tp_ret = bpf_map_lookup_elem(&tcp_sock_result_map, &idx); | 157 | tp_ret = bpf_map_lookup_elem(&tcp_sock_result_map, &result_idx); |
| 158 | if (!sk_ret || !tp_ret) | ||
| 159 | RETURN; | ||
| 160 | |||
| 161 | skcpy(sk_ret, sk); | ||
| 162 | tpcpy(tp_ret, tp); | ||
| 163 | |||
| 164 | RETURN; | ||
| 165 | } | ||
| 166 | |||
| 167 | SEC("cgroup_skb/ingress") | ||
| 168 | int ingress_read_sock_fields(struct __sk_buff *skb) | ||
| 169 | { | ||
| 170 | __u32 srv_idx = ADDR_SRV_IDX, result_idx = INGRESS_LISTEN_IDX; | ||
| 171 | struct bpf_tcp_sock *tp, *tp_ret; | ||
| 172 | struct bpf_sock *sk, *sk_ret; | ||
| 173 | struct sockaddr_in6 *srv_sa6; | ||
| 174 | __u32 linum, linum_idx; | ||
| 175 | |||
| 176 | linum_idx = INGRESS_LINUM_IDX; | ||
| 177 | |||
| 178 | sk = skb->sk; | ||
| 179 | if (!sk || sk->family != AF_INET6 || !is_loopback6(sk->src_ip6)) | ||
| 180 | RETURN; | ||
| 181 | |||
| 182 | srv_sa6 = bpf_map_lookup_elem(&addr_map, &srv_idx); | ||
| 183 | if (!srv_sa6 || sk->src_port != bpf_ntohs(srv_sa6->sin6_port)) | ||
| 184 | RETURN; | ||
| 185 | |||
| 186 | if (sk->state != 10 && sk->state != 12) | ||
| 187 | RETURN; | ||
| 188 | |||
| 189 | sk = bpf_get_listener_sock(sk); | ||
| 190 | if (!sk) | ||
| 191 | RETURN; | ||
| 192 | |||
| 193 | tp = bpf_tcp_sock(sk); | ||
| 194 | if (!tp) | ||
| 195 | RETURN; | ||
| 196 | |||
| 197 | sk_ret = bpf_map_lookup_elem(&sock_result_map, &result_idx); | ||
| 198 | tp_ret = bpf_map_lookup_elem(&tcp_sock_result_map, &result_idx); | ||
| 143 | if (!sk_ret || !tp_ret) | 199 | if (!sk_ret || !tp_ret) |
| 144 | RETURN; | 200 | RETURN; |
| 145 | 201 | ||
diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c index 38797aa627a7..23e3b314ca60 100644 --- a/tools/testing/selftests/bpf/test_btf.c +++ b/tools/testing/selftests/bpf/test_btf.c | |||
| @@ -5874,6 +5874,50 @@ const struct btf_dedup_test dedup_tests[] = { | |||
| 5874 | .dont_resolve_fwds = false, | 5874 | .dont_resolve_fwds = false, |
| 5875 | }, | 5875 | }, |
| 5876 | }, | 5876 | }, |
| 5877 | { | ||
| 5878 | .descr = "dedup: enum fwd resolution", | ||
| 5879 | .input = { | ||
| 5880 | .raw_types = { | ||
| 5881 | /* [1] fwd enum 'e1' before full enum */ | ||
| 5882 | BTF_TYPE_ENC(NAME_NTH(1), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 0), 4), | ||
| 5883 | /* [2] full enum 'e1' after fwd */ | ||
| 5884 | BTF_TYPE_ENC(NAME_NTH(1), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1), 4), | ||
| 5885 | BTF_ENUM_ENC(NAME_NTH(2), 123), | ||
| 5886 | /* [3] full enum 'e2' before fwd */ | ||
| 5887 | BTF_TYPE_ENC(NAME_NTH(3), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1), 4), | ||
| 5888 | BTF_ENUM_ENC(NAME_NTH(4), 456), | ||
| 5889 | /* [4] fwd enum 'e2' after full enum */ | ||
| 5890 | BTF_TYPE_ENC(NAME_NTH(3), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 0), 4), | ||
| 5891 | /* [5] incompatible fwd enum with different size */ | ||
| 5892 | BTF_TYPE_ENC(NAME_NTH(1), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 0), 1), | ||
| 5893 | /* [6] incompatible full enum with different value */ | ||
| 5894 | BTF_TYPE_ENC(NAME_NTH(1), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1), 4), | ||
| 5895 | BTF_ENUM_ENC(NAME_NTH(2), 321), | ||
| 5896 | BTF_END_RAW, | ||
| 5897 | }, | ||
| 5898 | BTF_STR_SEC("\0e1\0e1_val\0e2\0e2_val"), | ||
| 5899 | }, | ||
| 5900 | .expect = { | ||
| 5901 | .raw_types = { | ||
| 5902 | /* [1] full enum 'e1' */ | ||
| 5903 | BTF_TYPE_ENC(NAME_NTH(1), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1), 4), | ||
| 5904 | BTF_ENUM_ENC(NAME_NTH(2), 123), | ||
| 5905 | /* [2] full enum 'e2' */ | ||
| 5906 | BTF_TYPE_ENC(NAME_NTH(3), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1), 4), | ||
| 5907 | BTF_ENUM_ENC(NAME_NTH(4), 456), | ||
| 5908 | /* [3] incompatible fwd enum with different size */ | ||
| 5909 | BTF_TYPE_ENC(NAME_NTH(1), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 0), 1), | ||
| 5910 | /* [4] incompatible full enum with different value */ | ||
| 5911 | BTF_TYPE_ENC(NAME_NTH(1), BTF_INFO_ENC(BTF_KIND_ENUM, 0, 1), 4), | ||
| 5912 | BTF_ENUM_ENC(NAME_NTH(2), 321), | ||
| 5913 | BTF_END_RAW, | ||
| 5914 | }, | ||
| 5915 | BTF_STR_SEC("\0e1\0e1_val\0e2\0e2_val"), | ||
| 5916 | }, | ||
| 5917 | .opts = { | ||
| 5918 | .dont_resolve_fwds = false, | ||
| 5919 | }, | ||
| 5920 | }, | ||
| 5877 | 5921 | ||
| 5878 | }; | 5922 | }; |
| 5879 | 5923 | ||
diff --git a/tools/testing/selftests/bpf/test_sock_fields.c b/tools/testing/selftests/bpf/test_sock_fields.c index bc8943938bf5..dcae7f664dce 100644 --- a/tools/testing/selftests/bpf/test_sock_fields.c +++ b/tools/testing/selftests/bpf/test_sock_fields.c | |||
| @@ -16,10 +16,23 @@ | |||
| 16 | #include "cgroup_helpers.h" | 16 | #include "cgroup_helpers.h" |
| 17 | #include "bpf_rlimit.h" | 17 | #include "bpf_rlimit.h" |
| 18 | 18 | ||
| 19 | enum bpf_array_idx { | 19 | enum bpf_addr_array_idx { |
| 20 | SRV_IDX, | 20 | ADDR_SRV_IDX, |
| 21 | CLI_IDX, | 21 | ADDR_CLI_IDX, |
| 22 | __NR_BPF_ARRAY_IDX, | 22 | __NR_BPF_ADDR_ARRAY_IDX, |
| 23 | }; | ||
| 24 | |||
| 25 | enum bpf_result_array_idx { | ||
| 26 | EGRESS_SRV_IDX, | ||
| 27 | EGRESS_CLI_IDX, | ||
| 28 | INGRESS_LISTEN_IDX, | ||
| 29 | __NR_BPF_RESULT_ARRAY_IDX, | ||
| 30 | }; | ||
| 31 | |||
| 32 | enum bpf_linum_array_idx { | ||
| 33 | EGRESS_LINUM_IDX, | ||
| 34 | INGRESS_LINUM_IDX, | ||
| 35 | __NR_BPF_LINUM_ARRAY_IDX, | ||
| 23 | }; | 36 | }; |
| 24 | 37 | ||
| 25 | #define CHECK(condition, tag, format...) ({ \ | 38 | #define CHECK(condition, tag, format...) ({ \ |
| @@ -41,8 +54,16 @@ static int linum_map_fd; | |||
| 41 | static int addr_map_fd; | 54 | static int addr_map_fd; |
| 42 | static int tp_map_fd; | 55 | static int tp_map_fd; |
| 43 | static int sk_map_fd; | 56 | static int sk_map_fd; |
| 44 | static __u32 srv_idx = SRV_IDX; | 57 | |
| 45 | static __u32 cli_idx = CLI_IDX; | 58 | static __u32 addr_srv_idx = ADDR_SRV_IDX; |
| 59 | static __u32 addr_cli_idx = ADDR_CLI_IDX; | ||
| 60 | |||
| 61 | static __u32 egress_srv_idx = EGRESS_SRV_IDX; | ||
| 62 | static __u32 egress_cli_idx = EGRESS_CLI_IDX; | ||
| 63 | static __u32 ingress_listen_idx = INGRESS_LISTEN_IDX; | ||
| 64 | |||
| 65 | static __u32 egress_linum_idx = EGRESS_LINUM_IDX; | ||
| 66 | static __u32 ingress_linum_idx = INGRESS_LINUM_IDX; | ||
| 46 | 67 | ||
| 47 | static void init_loopback6(struct sockaddr_in6 *sa6) | 68 | static void init_loopback6(struct sockaddr_in6 *sa6) |
| 48 | { | 69 | { |
| @@ -93,29 +114,46 @@ static void print_tp(const struct bpf_tcp_sock *tp) | |||
| 93 | 114 | ||
| 94 | static void check_result(void) | 115 | static void check_result(void) |
| 95 | { | 116 | { |
| 96 | struct bpf_tcp_sock srv_tp, cli_tp; | 117 | struct bpf_tcp_sock srv_tp, cli_tp, listen_tp; |
| 97 | struct bpf_sock srv_sk, cli_sk; | 118 | struct bpf_sock srv_sk, cli_sk, listen_sk; |
| 98 | __u32 linum, idx0 = 0; | 119 | __u32 ingress_linum, egress_linum; |
| 99 | int err; | 120 | int err; |
| 100 | 121 | ||
| 101 | err = bpf_map_lookup_elem(linum_map_fd, &idx0, &linum); | 122 | err = bpf_map_lookup_elem(linum_map_fd, &egress_linum_idx, |
| 123 | &egress_linum); | ||
| 102 | CHECK(err == -1, "bpf_map_lookup_elem(linum_map_fd)", | 124 | CHECK(err == -1, "bpf_map_lookup_elem(linum_map_fd)", |
| 103 | "err:%d errno:%d", err, errno); | 125 | "err:%d errno:%d", err, errno); |
| 104 | 126 | ||
| 105 | err = bpf_map_lookup_elem(sk_map_fd, &srv_idx, &srv_sk); | 127 | err = bpf_map_lookup_elem(linum_map_fd, &ingress_linum_idx, |
| 106 | CHECK(err == -1, "bpf_map_lookup_elem(sk_map_fd, &srv_idx)", | 128 | &ingress_linum); |
| 129 | CHECK(err == -1, "bpf_map_lookup_elem(linum_map_fd)", | ||
| 130 | "err:%d errno:%d", err, errno); | ||
| 131 | |||
| 132 | err = bpf_map_lookup_elem(sk_map_fd, &egress_srv_idx, &srv_sk); | ||
| 133 | CHECK(err == -1, "bpf_map_lookup_elem(sk_map_fd, &egress_srv_idx)", | ||
| 134 | "err:%d errno:%d", err, errno); | ||
| 135 | err = bpf_map_lookup_elem(tp_map_fd, &egress_srv_idx, &srv_tp); | ||
| 136 | CHECK(err == -1, "bpf_map_lookup_elem(tp_map_fd, &egress_srv_idx)", | ||
| 137 | "err:%d errno:%d", err, errno); | ||
| 138 | |||
| 139 | err = bpf_map_lookup_elem(sk_map_fd, &egress_cli_idx, &cli_sk); | ||
| 140 | CHECK(err == -1, "bpf_map_lookup_elem(sk_map_fd, &egress_cli_idx)", | ||
| 107 | "err:%d errno:%d", err, errno); | 141 | "err:%d errno:%d", err, errno); |
| 108 | err = bpf_map_lookup_elem(tp_map_fd, &srv_idx, &srv_tp); | 142 | err = bpf_map_lookup_elem(tp_map_fd, &egress_cli_idx, &cli_tp); |
| 109 | CHECK(err == -1, "bpf_map_lookup_elem(tp_map_fd, &srv_idx)", | 143 | CHECK(err == -1, "bpf_map_lookup_elem(tp_map_fd, &egress_cli_idx)", |
| 110 | "err:%d errno:%d", err, errno); | 144 | "err:%d errno:%d", err, errno); |
| 111 | 145 | ||
| 112 | err = bpf_map_lookup_elem(sk_map_fd, &cli_idx, &cli_sk); | 146 | err = bpf_map_lookup_elem(sk_map_fd, &ingress_listen_idx, &listen_sk); |
| 113 | CHECK(err == -1, "bpf_map_lookup_elem(sk_map_fd, &cli_idx)", | 147 | CHECK(err == -1, "bpf_map_lookup_elem(sk_map_fd, &ingress_listen_idx)", |
| 114 | "err:%d errno:%d", err, errno); | 148 | "err:%d errno:%d", err, errno); |
| 115 | err = bpf_map_lookup_elem(tp_map_fd, &cli_idx, &cli_tp); | 149 | err = bpf_map_lookup_elem(tp_map_fd, &ingress_listen_idx, &listen_tp); |
| 116 | CHECK(err == -1, "bpf_map_lookup_elem(tp_map_fd, &cli_idx)", | 150 | CHECK(err == -1, "bpf_map_lookup_elem(tp_map_fd, &ingress_listen_idx)", |
| 117 | "err:%d errno:%d", err, errno); | 151 | "err:%d errno:%d", err, errno); |
| 118 | 152 | ||
| 153 | printf("listen_sk: "); | ||
| 154 | print_sk(&listen_sk); | ||
| 155 | printf("\n"); | ||
| 156 | |||
| 119 | printf("srv_sk: "); | 157 | printf("srv_sk: "); |
| 120 | print_sk(&srv_sk); | 158 | print_sk(&srv_sk); |
| 121 | printf("\n"); | 159 | printf("\n"); |
| @@ -124,6 +162,10 @@ static void check_result(void) | |||
| 124 | print_sk(&cli_sk); | 162 | print_sk(&cli_sk); |
| 125 | printf("\n"); | 163 | printf("\n"); |
| 126 | 164 | ||
| 165 | printf("listen_tp: "); | ||
| 166 | print_tp(&listen_tp); | ||
| 167 | printf("\n"); | ||
| 168 | |||
| 127 | printf("srv_tp: "); | 169 | printf("srv_tp: "); |
| 128 | print_tp(&srv_tp); | 170 | print_tp(&srv_tp); |
| 129 | printf("\n"); | 171 | printf("\n"); |
| @@ -132,6 +174,19 @@ static void check_result(void) | |||
| 132 | print_tp(&cli_tp); | 174 | print_tp(&cli_tp); |
| 133 | printf("\n"); | 175 | printf("\n"); |
| 134 | 176 | ||
| 177 | CHECK(listen_sk.state != 10 || | ||
| 178 | listen_sk.family != AF_INET6 || | ||
| 179 | listen_sk.protocol != IPPROTO_TCP || | ||
| 180 | memcmp(listen_sk.src_ip6, &in6addr_loopback, | ||
| 181 | sizeof(listen_sk.src_ip6)) || | ||
| 182 | listen_sk.dst_ip6[0] || listen_sk.dst_ip6[1] || | ||
| 183 | listen_sk.dst_ip6[2] || listen_sk.dst_ip6[3] || | ||
| 184 | listen_sk.src_port != ntohs(srv_sa6.sin6_port) || | ||
| 185 | listen_sk.dst_port, | ||
| 186 | "Unexpected listen_sk", | ||
| 187 | "Check listen_sk output. ingress_linum:%u", | ||
| 188 | ingress_linum); | ||
| 189 | |||
| 135 | CHECK(srv_sk.state == 10 || | 190 | CHECK(srv_sk.state == 10 || |
| 136 | !srv_sk.state || | 191 | !srv_sk.state || |
| 137 | srv_sk.family != AF_INET6 || | 192 | srv_sk.family != AF_INET6 || |
| @@ -142,7 +197,8 @@ static void check_result(void) | |||
| 142 | sizeof(srv_sk.dst_ip6)) || | 197 | sizeof(srv_sk.dst_ip6)) || |
| 143 | srv_sk.src_port != ntohs(srv_sa6.sin6_port) || | 198 | srv_sk.src_port != ntohs(srv_sa6.sin6_port) || |
| 144 | srv_sk.dst_port != cli_sa6.sin6_port, | 199 | srv_sk.dst_port != cli_sa6.sin6_port, |
| 145 | "Unexpected srv_sk", "Check srv_sk output. linum:%u", linum); | 200 | "Unexpected srv_sk", "Check srv_sk output. egress_linum:%u", |
| 201 | egress_linum); | ||
| 146 | 202 | ||
| 147 | CHECK(cli_sk.state == 10 || | 203 | CHECK(cli_sk.state == 10 || |
| 148 | !cli_sk.state || | 204 | !cli_sk.state || |
| @@ -154,21 +210,31 @@ static void check_result(void) | |||
| 154 | sizeof(cli_sk.dst_ip6)) || | 210 | sizeof(cli_sk.dst_ip6)) || |
| 155 | cli_sk.src_port != ntohs(cli_sa6.sin6_port) || | 211 | cli_sk.src_port != ntohs(cli_sa6.sin6_port) || |
| 156 | cli_sk.dst_port != srv_sa6.sin6_port, | 212 | cli_sk.dst_port != srv_sa6.sin6_port, |
| 157 | "Unexpected cli_sk", "Check cli_sk output. linum:%u", linum); | 213 | "Unexpected cli_sk", "Check cli_sk output. egress_linum:%u", |
| 214 | egress_linum); | ||
| 215 | |||
| 216 | CHECK(listen_tp.data_segs_out || | ||
| 217 | listen_tp.data_segs_in || | ||
| 218 | listen_tp.total_retrans || | ||
| 219 | listen_tp.bytes_acked, | ||
| 220 | "Unexpected listen_tp", "Check listen_tp output. ingress_linum:%u", | ||
| 221 | ingress_linum); | ||
| 158 | 222 | ||
| 159 | CHECK(srv_tp.data_segs_out != 1 || | 223 | CHECK(srv_tp.data_segs_out != 1 || |
| 160 | srv_tp.data_segs_in || | 224 | srv_tp.data_segs_in || |
| 161 | srv_tp.snd_cwnd != 10 || | 225 | srv_tp.snd_cwnd != 10 || |
| 162 | srv_tp.total_retrans || | 226 | srv_tp.total_retrans || |
| 163 | srv_tp.bytes_acked != DATA_LEN, | 227 | srv_tp.bytes_acked != DATA_LEN, |
| 164 | "Unexpected srv_tp", "Check srv_tp output. linum:%u", linum); | 228 | "Unexpected srv_tp", "Check srv_tp output. egress_linum:%u", |
| 229 | egress_linum); | ||
| 165 | 230 | ||
| 166 | CHECK(cli_tp.data_segs_out || | 231 | CHECK(cli_tp.data_segs_out || |
| 167 | cli_tp.data_segs_in != 1 || | 232 | cli_tp.data_segs_in != 1 || |
| 168 | cli_tp.snd_cwnd != 10 || | 233 | cli_tp.snd_cwnd != 10 || |
| 169 | cli_tp.total_retrans || | 234 | cli_tp.total_retrans || |
| 170 | cli_tp.bytes_received != DATA_LEN, | 235 | cli_tp.bytes_received != DATA_LEN, |
| 171 | "Unexpected cli_tp", "Check cli_tp output. linum:%u", linum); | 236 | "Unexpected cli_tp", "Check cli_tp output. egress_linum:%u", |
| 237 | egress_linum); | ||
| 172 | } | 238 | } |
| 173 | 239 | ||
| 174 | static void test(void) | 240 | static void test(void) |
| @@ -211,10 +277,10 @@ static void test(void) | |||
| 211 | err, errno); | 277 | err, errno); |
| 212 | 278 | ||
| 213 | /* Update addr_map with srv_sa6 and cli_sa6 */ | 279 | /* Update addr_map with srv_sa6 and cli_sa6 */ |
| 214 | err = bpf_map_update_elem(addr_map_fd, &srv_idx, &srv_sa6, 0); | 280 | err = bpf_map_update_elem(addr_map_fd, &addr_srv_idx, &srv_sa6, 0); |
| 215 | CHECK(err, "map_update", "err:%d errno:%d", err, errno); | 281 | CHECK(err, "map_update", "err:%d errno:%d", err, errno); |
| 216 | 282 | ||
| 217 | err = bpf_map_update_elem(addr_map_fd, &cli_idx, &cli_sa6, 0); | 283 | err = bpf_map_update_elem(addr_map_fd, &addr_cli_idx, &cli_sa6, 0); |
| 218 | CHECK(err, "map_update", "err:%d errno:%d", err, errno); | 284 | CHECK(err, "map_update", "err:%d errno:%d", err, errno); |
| 219 | 285 | ||
| 220 | /* Connect from cli_sa6 to srv_sa6 */ | 286 | /* Connect from cli_sa6 to srv_sa6 */ |
| @@ -273,9 +339,9 @@ int main(int argc, char **argv) | |||
| 273 | struct bpf_prog_load_attr attr = { | 339 | struct bpf_prog_load_attr attr = { |
| 274 | .file = "test_sock_fields_kern.o", | 340 | .file = "test_sock_fields_kern.o", |
| 275 | .prog_type = BPF_PROG_TYPE_CGROUP_SKB, | 341 | .prog_type = BPF_PROG_TYPE_CGROUP_SKB, |
| 276 | .expected_attach_type = BPF_CGROUP_INET_EGRESS, | ||
| 277 | }; | 342 | }; |
| 278 | int cgroup_fd, prog_fd, err; | 343 | int cgroup_fd, egress_fd, ingress_fd, err; |
| 344 | struct bpf_program *ingress_prog; | ||
| 279 | struct bpf_object *obj; | 345 | struct bpf_object *obj; |
| 280 | struct bpf_map *map; | 346 | struct bpf_map *map; |
| 281 | 347 | ||
| @@ -293,12 +359,24 @@ int main(int argc, char **argv) | |||
| 293 | err = join_cgroup(TEST_CGROUP); | 359 | err = join_cgroup(TEST_CGROUP); |
| 294 | CHECK(err, "join_cgroup", "err:%d errno:%d", err, errno); | 360 | CHECK(err, "join_cgroup", "err:%d errno:%d", err, errno); |
| 295 | 361 | ||
| 296 | err = bpf_prog_load_xattr(&attr, &obj, &prog_fd); | 362 | err = bpf_prog_load_xattr(&attr, &obj, &egress_fd); |
| 297 | CHECK(err, "bpf_prog_load_xattr()", "err:%d", err); | 363 | CHECK(err, "bpf_prog_load_xattr()", "err:%d", err); |
| 298 | 364 | ||
| 299 | err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_INET_EGRESS, 0); | 365 | ingress_prog = bpf_object__find_program_by_title(obj, |
| 366 | "cgroup_skb/ingress"); | ||
| 367 | CHECK(!ingress_prog, | ||
| 368 | "bpf_object__find_program_by_title(cgroup_skb/ingress)", | ||
| 369 | "not found"); | ||
| 370 | ingress_fd = bpf_program__fd(ingress_prog); | ||
| 371 | |||
| 372 | err = bpf_prog_attach(egress_fd, cgroup_fd, BPF_CGROUP_INET_EGRESS, 0); | ||
| 300 | CHECK(err == -1, "bpf_prog_attach(CPF_CGROUP_INET_EGRESS)", | 373 | CHECK(err == -1, "bpf_prog_attach(CPF_CGROUP_INET_EGRESS)", |
| 301 | "err:%d errno%d", err, errno); | 374 | "err:%d errno%d", err, errno); |
| 375 | |||
| 376 | err = bpf_prog_attach(ingress_fd, cgroup_fd, | ||
| 377 | BPF_CGROUP_INET_INGRESS, 0); | ||
| 378 | CHECK(err == -1, "bpf_prog_attach(CPF_CGROUP_INET_INGRESS)", | ||
| 379 | "err:%d errno%d", err, errno); | ||
| 302 | close(cgroup_fd); | 380 | close(cgroup_fd); |
| 303 | 381 | ||
| 304 | map = bpf_object__find_map_by_name(obj, "addr_map"); | 382 | map = bpf_object__find_map_by_name(obj, "addr_map"); |
diff --git a/tools/testing/selftests/bpf/verifier/calls.c b/tools/testing/selftests/bpf/verifier/calls.c index 4004891afa9c..f2ccae39ee66 100644 --- a/tools/testing/selftests/bpf/verifier/calls.c +++ b/tools/testing/selftests/bpf/verifier/calls.c | |||
| @@ -1940,3 +1940,28 @@ | |||
| 1940 | .errstr = "!read_ok", | 1940 | .errstr = "!read_ok", |
| 1941 | .result = REJECT, | 1941 | .result = REJECT, |
| 1942 | }, | 1942 | }, |
| 1943 | { | ||
| 1944 | "calls: cross frame pruning - liveness propagation", | ||
| 1945 | .insns = { | ||
| 1946 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_prandom_u32), | ||
| 1947 | BPF_MOV64_IMM(BPF_REG_8, 0), | ||
| 1948 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 1949 | BPF_MOV64_IMM(BPF_REG_8, 1), | ||
| 1950 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_prandom_u32), | ||
| 1951 | BPF_MOV64_IMM(BPF_REG_9, 0), | ||
| 1952 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 1953 | BPF_MOV64_IMM(BPF_REG_9, 1), | ||
| 1954 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 1955 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 1, 0, 4), | ||
| 1956 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_8, 1, 1), | ||
| 1957 | BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_2, 0), | ||
| 1958 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 1959 | BPF_EXIT_INSN(), | ||
| 1960 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 0), | ||
| 1961 | BPF_EXIT_INSN(), | ||
| 1962 | }, | ||
| 1963 | .prog_type = BPF_PROG_TYPE_SOCKET_FILTER, | ||
| 1964 | .errstr_unpriv = "function calls to other bpf functions are allowed for root only", | ||
| 1965 | .errstr = "!read_ok", | ||
| 1966 | .result = REJECT, | ||
| 1967 | }, | ||
diff --git a/tools/testing/selftests/bpf/verifier/ref_tracking.c b/tools/testing/selftests/bpf/verifier/ref_tracking.c index 3ed3593bd8b6..923f2110072d 100644 --- a/tools/testing/selftests/bpf/verifier/ref_tracking.c +++ b/tools/testing/selftests/bpf/verifier/ref_tracking.c | |||
| @@ -605,3 +605,171 @@ | |||
| 605 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | 605 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, |
| 606 | .result = ACCEPT, | 606 | .result = ACCEPT, |
| 607 | }, | 607 | }, |
| 608 | { | ||
| 609 | "reference tracking: use ptr from bpf_tcp_sock() after release", | ||
| 610 | .insns = { | ||
| 611 | BPF_SK_LOOKUP, | ||
| 612 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 613 | BPF_EXIT_INSN(), | ||
| 614 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 615 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 616 | BPF_EMIT_CALL(BPF_FUNC_tcp_sock), | ||
| 617 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 3), | ||
| 618 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 619 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 620 | BPF_EXIT_INSN(), | ||
| 621 | BPF_MOV64_REG(BPF_REG_7, BPF_REG_0), | ||
| 622 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 623 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 624 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_7, offsetof(struct bpf_tcp_sock, snd_cwnd)), | ||
| 625 | BPF_EXIT_INSN(), | ||
| 626 | }, | ||
| 627 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 628 | .result = REJECT, | ||
| 629 | .errstr = "invalid mem access", | ||
| 630 | }, | ||
| 631 | { | ||
| 632 | "reference tracking: use ptr from bpf_sk_fullsock() after release", | ||
| 633 | .insns = { | ||
| 634 | BPF_SK_LOOKUP, | ||
| 635 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 636 | BPF_EXIT_INSN(), | ||
| 637 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 638 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 639 | BPF_EMIT_CALL(BPF_FUNC_sk_fullsock), | ||
| 640 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 3), | ||
| 641 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 642 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 643 | BPF_EXIT_INSN(), | ||
| 644 | BPF_MOV64_REG(BPF_REG_7, BPF_REG_0), | ||
| 645 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 646 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 647 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_7, offsetof(struct bpf_sock, type)), | ||
| 648 | BPF_EXIT_INSN(), | ||
| 649 | }, | ||
| 650 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 651 | .result = REJECT, | ||
| 652 | .errstr = "invalid mem access", | ||
| 653 | }, | ||
| 654 | { | ||
| 655 | "reference tracking: use ptr from bpf_sk_fullsock(tp) after release", | ||
| 656 | .insns = { | ||
| 657 | BPF_SK_LOOKUP, | ||
| 658 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 659 | BPF_EXIT_INSN(), | ||
| 660 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 661 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 662 | BPF_EMIT_CALL(BPF_FUNC_tcp_sock), | ||
| 663 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 3), | ||
| 664 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 665 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 666 | BPF_EXIT_INSN(), | ||
| 667 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 668 | BPF_EMIT_CALL(BPF_FUNC_sk_fullsock), | ||
| 669 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 670 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 671 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 672 | BPF_JMP_IMM(BPF_JNE, BPF_REG_6, 0, 1), | ||
| 673 | BPF_EXIT_INSN(), | ||
| 674 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_6, offsetof(struct bpf_sock, type)), | ||
| 675 | BPF_EXIT_INSN(), | ||
| 676 | }, | ||
| 677 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 678 | .result = REJECT, | ||
| 679 | .errstr = "invalid mem access", | ||
| 680 | }, | ||
| 681 | { | ||
| 682 | "reference tracking: use sk after bpf_sk_release(tp)", | ||
| 683 | .insns = { | ||
| 684 | BPF_SK_LOOKUP, | ||
| 685 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 686 | BPF_EXIT_INSN(), | ||
| 687 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 688 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 689 | BPF_EMIT_CALL(BPF_FUNC_tcp_sock), | ||
| 690 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 3), | ||
| 691 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 692 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 693 | BPF_EXIT_INSN(), | ||
| 694 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 695 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 696 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_6, offsetof(struct bpf_sock, type)), | ||
| 697 | BPF_EXIT_INSN(), | ||
| 698 | }, | ||
| 699 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 700 | .result = REJECT, | ||
| 701 | .errstr = "invalid mem access", | ||
| 702 | }, | ||
| 703 | { | ||
| 704 | "reference tracking: use ptr from bpf_get_listener_sock() after bpf_sk_release(sk)", | ||
| 705 | .insns = { | ||
| 706 | BPF_SK_LOOKUP, | ||
| 707 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 708 | BPF_EXIT_INSN(), | ||
| 709 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 710 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 711 | BPF_EMIT_CALL(BPF_FUNC_get_listener_sock), | ||
| 712 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 3), | ||
| 713 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 714 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 715 | BPF_EXIT_INSN(), | ||
| 716 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 717 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 718 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 719 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_6, offsetof(struct bpf_sock, src_port)), | ||
| 720 | BPF_EXIT_INSN(), | ||
| 721 | }, | ||
| 722 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 723 | .result = ACCEPT, | ||
| 724 | }, | ||
| 725 | { | ||
| 726 | "reference tracking: bpf_sk_release(listen_sk)", | ||
| 727 | .insns = { | ||
| 728 | BPF_SK_LOOKUP, | ||
| 729 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 730 | BPF_EXIT_INSN(), | ||
| 731 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 732 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 733 | BPF_EMIT_CALL(BPF_FUNC_get_listener_sock), | ||
| 734 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 3), | ||
| 735 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 736 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 737 | BPF_EXIT_INSN(), | ||
| 738 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 739 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 740 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_6, offsetof(struct bpf_sock, type)), | ||
| 741 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 742 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 743 | BPF_EXIT_INSN(), | ||
| 744 | }, | ||
| 745 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 746 | .result = REJECT, | ||
| 747 | .errstr = "reference has not been acquired before", | ||
| 748 | }, | ||
| 749 | { | ||
| 750 | /* !bpf_sk_fullsock(sk) is checked but !bpf_tcp_sock(sk) is not checked */ | ||
| 751 | "reference tracking: tp->snd_cwnd after bpf_sk_fullsock(sk) and bpf_tcp_sock(sk)", | ||
| 752 | .insns = { | ||
| 753 | BPF_SK_LOOKUP, | ||
| 754 | BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), | ||
| 755 | BPF_EXIT_INSN(), | ||
| 756 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), | ||
| 757 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_0), | ||
| 758 | BPF_EMIT_CALL(BPF_FUNC_sk_fullsock), | ||
| 759 | BPF_MOV64_REG(BPF_REG_7, BPF_REG_0), | ||
| 760 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 761 | BPF_EMIT_CALL(BPF_FUNC_tcp_sock), | ||
| 762 | BPF_MOV64_REG(BPF_REG_8, BPF_REG_0), | ||
| 763 | BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 0, 3), | ||
| 764 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 765 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 766 | BPF_EXIT_INSN(), | ||
| 767 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_8, offsetof(struct bpf_tcp_sock, snd_cwnd)), | ||
| 768 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), | ||
| 769 | BPF_EMIT_CALL(BPF_FUNC_sk_release), | ||
| 770 | BPF_EXIT_INSN(), | ||
| 771 | }, | ||
| 772 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 773 | .result = REJECT, | ||
| 774 | .errstr = "invalid mem access", | ||
| 775 | }, | ||
diff --git a/tools/testing/selftests/bpf/verifier/sock.c b/tools/testing/selftests/bpf/verifier/sock.c index 0ddfdf76aba5..416436231fab 100644 --- a/tools/testing/selftests/bpf/verifier/sock.c +++ b/tools/testing/selftests/bpf/verifier/sock.c | |||
| @@ -342,7 +342,7 @@ | |||
| 342 | }, | 342 | }, |
| 343 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | 343 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, |
| 344 | .result = REJECT, | 344 | .result = REJECT, |
| 345 | .errstr = "type=sock_common expected=sock", | 345 | .errstr = "reference has not been acquired before", |
| 346 | }, | 346 | }, |
| 347 | { | 347 | { |
| 348 | "bpf_sk_release(bpf_sk_fullsock(skb->sk))", | 348 | "bpf_sk_release(bpf_sk_fullsock(skb->sk))", |
| @@ -380,5 +380,5 @@ | |||
| 380 | }, | 380 | }, |
| 381 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | 381 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, |
| 382 | .result = REJECT, | 382 | .result = REJECT, |
| 383 | .errstr = "type=tcp_sock expected=sock", | 383 | .errstr = "reference has not been acquired before", |
| 384 | }, | 384 | }, |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/bpf.json b/tools/testing/selftests/tc-testing/tc-tests/actions/bpf.json index 5970cee6d05f..b074ea9b6fe8 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/bpf.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/bpf.json | |||
| @@ -286,5 +286,30 @@ | |||
| 286 | "teardown": [ | 286 | "teardown": [ |
| 287 | "$TC action flush action bpf" | 287 | "$TC action flush action bpf" |
| 288 | ] | 288 | ] |
| 289 | }, | ||
| 290 | { | ||
| 291 | "id": "b8a1", | ||
| 292 | "name": "Replace bpf action with invalid goto_chain control", | ||
| 293 | "category": [ | ||
| 294 | "actions", | ||
| 295 | "bpf" | ||
| 296 | ], | ||
| 297 | "setup": [ | ||
| 298 | [ | ||
| 299 | "$TC actions flush action bpf", | ||
| 300 | 0, | ||
| 301 | 1, | ||
| 302 | 255 | ||
| 303 | ], | ||
| 304 | "$TC action add action bpf bytecode '1,6 0 0 4294967295' pass index 90" | ||
| 305 | ], | ||
| 306 | "cmdUnderTest": "$TC action replace action bpf bytecode '1,6 0 0 4294967295' goto chain 42 index 90 cookie c1a0c1a0", | ||
| 307 | "expExitCode": "255", | ||
| 308 | "verifyCmd": "$TC action list action bpf", | ||
| 309 | "matchPattern": "action order [0-9]*: bpf.* default-action pass.*index 90", | ||
| 310 | "matchCount": "1", | ||
| 311 | "teardown": [ | ||
| 312 | "$TC action flush action bpf" | ||
| 313 | ] | ||
| 289 | } | 314 | } |
| 290 | ] | 315 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/connmark.json b/tools/testing/selftests/tc-testing/tc-tests/actions/connmark.json index 13147a1f5731..cadde8f41fcd 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/connmark.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/connmark.json | |||
| @@ -287,5 +287,30 @@ | |||
| 287 | "teardown": [ | 287 | "teardown": [ |
| 288 | "$TC actions flush action connmark" | 288 | "$TC actions flush action connmark" |
| 289 | ] | 289 | ] |
| 290 | }, | ||
| 291 | { | ||
| 292 | "id": "c506", | ||
| 293 | "name": "Replace connmark with invalid goto chain control", | ||
| 294 | "category": [ | ||
| 295 | "actions", | ||
| 296 | "connmark" | ||
| 297 | ], | ||
| 298 | "setup": [ | ||
| 299 | [ | ||
| 300 | "$TC actions flush action connmark", | ||
| 301 | 0, | ||
| 302 | 1, | ||
| 303 | 255 | ||
| 304 | ], | ||
| 305 | "$TC actions add action connmark pass index 90" | ||
| 306 | ], | ||
| 307 | "cmdUnderTest": "$TC actions replace action connmark goto chain 42 index 90 cookie c1a0c1a0", | ||
| 308 | "expExitCode": "255", | ||
| 309 | "verifyCmd": "$TC actions get action connmark index 90", | ||
| 310 | "matchPattern": "action order [0-9]+: connmark zone 0 pass.*index 90 ref", | ||
| 311 | "matchCount": "1", | ||
| 312 | "teardown": [ | ||
| 313 | "$TC actions flush action connmark" | ||
| 314 | ] | ||
| 290 | } | 315 | } |
| 291 | ] | 316 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/csum.json b/tools/testing/selftests/tc-testing/tc-tests/actions/csum.json index a022792d392a..ddabb2fbb7c7 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/csum.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/csum.json | |||
| @@ -500,5 +500,30 @@ | |||
| 500 | "matchPattern": "^[ \t]+index [0-9]+ ref", | 500 | "matchPattern": "^[ \t]+index [0-9]+ ref", |
| 501 | "matchCount": "0", | 501 | "matchCount": "0", |
| 502 | "teardown": [] | 502 | "teardown": [] |
| 503 | }, | ||
| 504 | { | ||
| 505 | "id": "d128", | ||
| 506 | "name": "Replace csum action with invalid goto chain control", | ||
| 507 | "category": [ | ||
| 508 | "actions", | ||
| 509 | "csum" | ||
| 510 | ], | ||
| 511 | "setup": [ | ||
| 512 | [ | ||
| 513 | "$TC actions flush action csum", | ||
| 514 | 0, | ||
| 515 | 1, | ||
| 516 | 255 | ||
| 517 | ], | ||
| 518 | "$TC actions add action csum iph index 90" | ||
| 519 | ], | ||
| 520 | "cmdUnderTest": "$TC actions replace action csum iph goto chain 42 index 90 cookie c1a0c1a0", | ||
| 521 | "expExitCode": "255", | ||
| 522 | "verifyCmd": "$TC actions get action csum index 90", | ||
| 523 | "matchPattern": "action order [0-9]*: csum \\(iph\\) action pass.*index 90 ref", | ||
| 524 | "matchCount": "1", | ||
| 525 | "teardown": [ | ||
| 526 | "$TC actions flush action csum" | ||
| 527 | ] | ||
| 503 | } | 528 | } |
| 504 | ] | 529 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json index 89189a03ce3d..814b7a8a478b 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json | |||
| @@ -560,5 +560,30 @@ | |||
| 560 | "teardown": [ | 560 | "teardown": [ |
| 561 | "$TC actions flush action gact" | 561 | "$TC actions flush action gact" |
| 562 | ] | 562 | ] |
| 563 | }, | ||
| 564 | { | ||
| 565 | "id": "ca89", | ||
| 566 | "name": "Replace gact action with invalid goto chain control", | ||
| 567 | "category": [ | ||
| 568 | "actions", | ||
| 569 | "gact" | ||
| 570 | ], | ||
| 571 | "setup": [ | ||
| 572 | [ | ||
| 573 | "$TC actions flush action gact", | ||
| 574 | 0, | ||
| 575 | 1, | ||
| 576 | 255 | ||
| 577 | ], | ||
| 578 | "$TC actions add action pass random determ drop 2 index 90" | ||
| 579 | ], | ||
| 580 | "cmdUnderTest": "$TC actions replace action goto chain 42 random determ drop 5 index 90 cookie c1a0c1a0", | ||
| 581 | "expExitCode": "255", | ||
| 582 | "verifyCmd": "$TC actions list action gact", | ||
| 583 | "matchPattern": "action order [0-9]*: gact action pass.*random type determ drop val 2.*index 90 ref", | ||
| 584 | "matchCount": "1", | ||
| 585 | "teardown": [ | ||
| 586 | "$TC actions flush action gact" | ||
| 587 | ] | ||
| 563 | } | 588 | } |
| 564 | ] | 589 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/ife.json b/tools/testing/selftests/tc-testing/tc-tests/actions/ife.json index 0da3545cabdb..c13a68b98fc7 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/ife.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/ife.json | |||
| @@ -1060,5 +1060,30 @@ | |||
| 1060 | "matchPattern": "action order [0-9]*: ife encode action pipe.*allow prio.*index 4", | 1060 | "matchPattern": "action order [0-9]*: ife encode action pipe.*allow prio.*index 4", |
| 1061 | "matchCount": "0", | 1061 | "matchCount": "0", |
| 1062 | "teardown": [] | 1062 | "teardown": [] |
| 1063 | }, | ||
| 1064 | { | ||
| 1065 | "id": "a0e2", | ||
| 1066 | "name": "Replace ife encode action with invalid goto chain control", | ||
| 1067 | "category": [ | ||
| 1068 | "actions", | ||
| 1069 | "ife" | ||
| 1070 | ], | ||
| 1071 | "setup": [ | ||
| 1072 | [ | ||
| 1073 | "$TC actions flush action ife", | ||
| 1074 | 0, | ||
| 1075 | 1, | ||
| 1076 | 255 | ||
| 1077 | ], | ||
| 1078 | "$TC actions add action ife encode allow mark pass index 90" | ||
| 1079 | ], | ||
| 1080 | "cmdUnderTest": "$TC actions replace action ife encode allow mark goto chain 42 index 90 cookie c1a0c1a0", | ||
| 1081 | "expExitCode": "255", | ||
| 1082 | "verifyCmd": "$TC actions get action ife index 90", | ||
| 1083 | "matchPattern": "action order [0-9]*: ife encode action pass.*type 0[xX]ED3E .*allow mark.*index 90 ref", | ||
| 1084 | "matchCount": "1", | ||
| 1085 | "teardown": [ | ||
| 1086 | "$TC actions flush action ife" | ||
| 1087 | ] | ||
| 1063 | } | 1088 | } |
| 1064 | ] | 1089 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/mirred.json b/tools/testing/selftests/tc-testing/tc-tests/actions/mirred.json index db49fd0f8445..6e5fb3d25681 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/mirred.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/mirred.json | |||
| @@ -434,5 +434,30 @@ | |||
| 434 | "teardown": [ | 434 | "teardown": [ |
| 435 | "$TC actions flush action mirred" | 435 | "$TC actions flush action mirred" |
| 436 | ] | 436 | ] |
| 437 | }, | ||
| 438 | { | ||
| 439 | "id": "2a9a", | ||
| 440 | "name": "Replace mirred action with invalid goto chain control", | ||
| 441 | "category": [ | ||
| 442 | "actions", | ||
| 443 | "mirred" | ||
| 444 | ], | ||
| 445 | "setup": [ | ||
| 446 | [ | ||
| 447 | "$TC actions flush action mirred", | ||
| 448 | 0, | ||
| 449 | 1, | ||
| 450 | 255 | ||
| 451 | ], | ||
| 452 | "$TC actions add action mirred ingress mirror dev lo drop index 90" | ||
| 453 | ], | ||
| 454 | "cmdUnderTest": "$TC actions replace action mirred ingress mirror dev lo goto chain 42 index 90 cookie c1a0c1a0", | ||
| 455 | "expExitCode": "255", | ||
| 456 | "verifyCmd": "$TC actions get action mirred index 90", | ||
| 457 | "matchPattern": "action order [0-9]*: mirred \\(Ingress Mirror to device lo\\) drop.*index 90 ref", | ||
| 458 | "matchCount": "1", | ||
| 459 | "teardown": [ | ||
| 460 | "$TC actions flush action mirred" | ||
| 461 | ] | ||
| 437 | } | 462 | } |
| 438 | ] | 463 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/nat.json b/tools/testing/selftests/tc-testing/tc-tests/actions/nat.json index 0080dc2fd41c..bc12c1ccad30 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/nat.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/nat.json | |||
| @@ -589,5 +589,30 @@ | |||
| 589 | "teardown": [ | 589 | "teardown": [ |
| 590 | "$TC actions flush action nat" | 590 | "$TC actions flush action nat" |
| 591 | ] | 591 | ] |
| 592 | }, | ||
| 593 | { | ||
| 594 | "id": "4b12", | ||
| 595 | "name": "Replace nat action with invalid goto chain control", | ||
| 596 | "category": [ | ||
| 597 | "actions", | ||
| 598 | "nat" | ||
| 599 | ], | ||
| 600 | "setup": [ | ||
| 601 | [ | ||
| 602 | "$TC actions flush action nat", | ||
| 603 | 0, | ||
| 604 | 1, | ||
| 605 | 255 | ||
| 606 | ], | ||
| 607 | "$TC actions add action nat ingress 1.18.1.1 1.18.2.2 drop index 90" | ||
| 608 | ], | ||
| 609 | "cmdUnderTest": "$TC actions replace action nat ingress 1.18.1.1 1.18.2.2 goto chain 42 index 90 cookie c1a0c1a0", | ||
| 610 | "expExitCode": "255", | ||
| 611 | "verifyCmd": "$TC actions get action nat index 90", | ||
| 612 | "matchPattern": "action order [0-9]+: nat ingress 1.18.1.1/32 1.18.2.2 drop.*index 90 ref", | ||
| 613 | "matchCount": "1", | ||
| 614 | "teardown": [ | ||
| 615 | "$TC actions flush action nat" | ||
| 616 | ] | ||
| 592 | } | 617 | } |
| 593 | ] | 618 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/pedit.json b/tools/testing/selftests/tc-testing/tc-tests/actions/pedit.json new file mode 100644 index 000000000000..b73ceb9e28b1 --- /dev/null +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/pedit.json | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "id": "319a", | ||
| 4 | "name": "Add pedit action that mangles IP TTL", | ||
| 5 | "category": [ | ||
| 6 | "actions", | ||
| 7 | "pedit" | ||
| 8 | ], | ||
| 9 | "setup": [ | ||
| 10 | [ | ||
| 11 | "$TC actions flush action pedit", | ||
| 12 | 0, | ||
| 13 | 1, | ||
| 14 | 255 | ||
| 15 | ] | ||
| 16 | ], | ||
| 17 | "cmdUnderTest": "$TC actions add action pedit ex munge ip ttl set 10", | ||
| 18 | "expExitCode": "0", | ||
| 19 | "verifyCmd": "$TC actions ls action pedit", | ||
| 20 | "matchPattern": "action order [0-9]+: pedit action pass keys 1.*index 1 ref.*key #0 at ipv4\\+8: val 0a000000 mask 00ffffff", | ||
| 21 | "matchCount": "1", | ||
| 22 | "teardown": [ | ||
| 23 | "$TC actions flush action pedit" | ||
| 24 | ] | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | "id": "7e67", | ||
| 28 | "name": "Replace pedit action with invalid goto chain", | ||
| 29 | "category": [ | ||
| 30 | "actions", | ||
| 31 | "pedit" | ||
| 32 | ], | ||
| 33 | "setup": [ | ||
| 34 | [ | ||
| 35 | "$TC actions flush action pedit", | ||
| 36 | 0, | ||
| 37 | 1, | ||
| 38 | 255 | ||
| 39 | ], | ||
| 40 | "$TC actions add action pedit ex munge ip ttl set 10 pass index 90" | ||
| 41 | ], | ||
| 42 | "cmdUnderTest": "$TC actions replace action pedit ex munge ip ttl set 10 goto chain 42 index 90 cookie c1a0c1a0", | ||
| 43 | "expExitCode": "255", | ||
| 44 | "verifyCmd": "$TC actions ls action pedit", | ||
| 45 | "matchPattern": "action order [0-9]+: pedit action pass keys 1.*index 90 ref.*key #0 at ipv4\\+8: val 0a000000 mask 00ffffff", | ||
| 46 | "matchCount": "1", | ||
| 47 | "teardown": [ | ||
| 48 | "$TC actions flush action pedit" | ||
| 49 | ] | ||
| 50 | } | ||
| 51 | ] | ||
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json index 4086a50a670e..b8268da5adaa 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json | |||
| @@ -739,5 +739,30 @@ | |||
| 739 | "teardown": [ | 739 | "teardown": [ |
| 740 | "$TC actions flush action police" | 740 | "$TC actions flush action police" |
| 741 | ] | 741 | ] |
| 742 | }, | ||
| 743 | { | ||
| 744 | "id": "689e", | ||
| 745 | "name": "Replace police action with invalid goto chain control", | ||
| 746 | "category": [ | ||
| 747 | "actions", | ||
| 748 | "police" | ||
| 749 | ], | ||
| 750 | "setup": [ | ||
| 751 | [ | ||
| 752 | "$TC actions flush action police", | ||
| 753 | 0, | ||
| 754 | 1, | ||
| 755 | 255 | ||
| 756 | ], | ||
| 757 | "$TC actions add action police rate 3mbit burst 250k drop index 90" | ||
| 758 | ], | ||
| 759 | "cmdUnderTest": "$TC actions replace action police rate 3mbit burst 250k goto chain 42 index 90 cookie c1a0c1a0", | ||
| 760 | "expExitCode": "255", | ||
| 761 | "verifyCmd": "$TC actions get action police index 90", | ||
| 762 | "matchPattern": "action order [0-9]*: police 0x5a rate 3Mbit burst 250Kb mtu 2Kb action drop", | ||
| 763 | "matchCount": "1", | ||
| 764 | "teardown": [ | ||
| 765 | "$TC actions flush action police" | ||
| 766 | ] | ||
| 742 | } | 767 | } |
| 743 | ] | 768 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/sample.json b/tools/testing/selftests/tc-testing/tc-tests/actions/sample.json index 3aca33c00039..27f0acaed880 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/sample.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/sample.json | |||
| @@ -584,5 +584,30 @@ | |||
| 584 | "teardown": [ | 584 | "teardown": [ |
| 585 | "$TC actions flush action sample" | 585 | "$TC actions flush action sample" |
| 586 | ] | 586 | ] |
| 587 | }, | ||
| 588 | { | ||
| 589 | "id": "0a6e", | ||
| 590 | "name": "Replace sample action with invalid goto chain control", | ||
| 591 | "category": [ | ||
| 592 | "actions", | ||
| 593 | "sample" | ||
| 594 | ], | ||
| 595 | "setup": [ | ||
| 596 | [ | ||
| 597 | "$TC actions flush action sample", | ||
| 598 | 0, | ||
| 599 | 1, | ||
| 600 | 255 | ||
| 601 | ], | ||
| 602 | "$TC actions add action sample rate 1024 group 4 pass index 90" | ||
| 603 | ], | ||
| 604 | "cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 goto chain 42 index 90 cookie c1a0c1a0", | ||
| 605 | "expExitCode": "255", | ||
| 606 | "verifyCmd": "$TC actions list action sample", | ||
| 607 | "matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pass.*index 90", | ||
| 608 | "matchCount": "1", | ||
| 609 | "teardown": [ | ||
| 610 | "$TC actions flush action sample" | ||
| 611 | ] | ||
| 587 | } | 612 | } |
| 588 | ] | 613 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json b/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json index e89a7aa4012d..8e8c1ae12260 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json | |||
| @@ -126,5 +126,30 @@ | |||
| 126 | "teardown": [ | 126 | "teardown": [ |
| 127 | "" | 127 | "" |
| 128 | ] | 128 | ] |
| 129 | }, | ||
| 130 | { | ||
| 131 | "id": "b776", | ||
| 132 | "name": "Replace simple action with invalid goto chain control", | ||
| 133 | "category": [ | ||
| 134 | "actions", | ||
| 135 | "simple" | ||
| 136 | ], | ||
| 137 | "setup": [ | ||
| 138 | [ | ||
| 139 | "$TC actions flush action simple", | ||
| 140 | 0, | ||
| 141 | 1, | ||
| 142 | 255 | ||
| 143 | ], | ||
| 144 | "$TC actions add action simple sdata \"hello\" pass index 90" | ||
| 145 | ], | ||
| 146 | "cmdUnderTest": "$TC actions replace action simple sdata \"world\" goto chain 42 index 90 cookie c1a0c1a0", | ||
| 147 | "expExitCode": "255", | ||
| 148 | "verifyCmd": "$TC actions list action simple", | ||
| 149 | "matchPattern": "action order [0-9]*: Simple <hello>.*index 90 ref", | ||
| 150 | "matchCount": "1", | ||
| 151 | "teardown": [ | ||
| 152 | "$TC actions flush action simple" | ||
| 153 | ] | ||
| 129 | } | 154 | } |
| 130 | ] | 155 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/skbedit.json b/tools/testing/selftests/tc-testing/tc-tests/actions/skbedit.json index 5aaf593b914a..ecd96eda7f6a 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/skbedit.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/skbedit.json | |||
| @@ -484,5 +484,30 @@ | |||
| 484 | "teardown": [ | 484 | "teardown": [ |
| 485 | "$TC actions flush action skbedit" | 485 | "$TC actions flush action skbedit" |
| 486 | ] | 486 | ] |
| 487 | }, | ||
| 488 | { | ||
| 489 | "id": "1b2b", | ||
| 490 | "name": "Replace skbedit action with invalid goto_chain control", | ||
| 491 | "category": [ | ||
| 492 | "actions", | ||
| 493 | "skbedit" | ||
| 494 | ], | ||
| 495 | "setup": [ | ||
| 496 | [ | ||
| 497 | "$TC actions flush action skbedit", | ||
| 498 | 0, | ||
| 499 | 1, | ||
| 500 | 255 | ||
| 501 | ], | ||
| 502 | "$TC actions add action skbedit ptype host pass index 90" | ||
| 503 | ], | ||
| 504 | "cmdUnderTest": "$TC actions replace action skbedit ptype host goto chain 42 index 90 cookie c1a0c1a0", | ||
| 505 | "expExitCode": "255", | ||
| 506 | "verifyCmd": "$TC actions list action skbedit", | ||
| 507 | "matchPattern": "action order [0-9]*: skbedit ptype host pass.*index 90 ref", | ||
| 508 | "matchCount": "1", | ||
| 509 | "teardown": [ | ||
| 510 | "$TC actions flush action skbedit" | ||
| 511 | ] | ||
| 487 | } | 512 | } |
| 488 | ] | 513 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/skbmod.json b/tools/testing/selftests/tc-testing/tc-tests/actions/skbmod.json index fe3326e939c1..6eb4c4f97060 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/skbmod.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/skbmod.json | |||
| @@ -392,5 +392,30 @@ | |||
| 392 | "teardown": [ | 392 | "teardown": [ |
| 393 | "$TC actions flush action skbmod" | 393 | "$TC actions flush action skbmod" |
| 394 | ] | 394 | ] |
| 395 | }, | ||
| 396 | { | ||
| 397 | "id": "b651", | ||
| 398 | "name": "Replace skbmod action with invalid goto_chain control", | ||
| 399 | "category": [ | ||
| 400 | "actions", | ||
| 401 | "skbmod" | ||
| 402 | ], | ||
| 403 | "setup": [ | ||
| 404 | [ | ||
| 405 | "$TC actions flush action skbmod", | ||
| 406 | 0, | ||
| 407 | 1, | ||
| 408 | 255 | ||
| 409 | ], | ||
| 410 | "$TC actions add action skbmod set etype 0x1111 pass index 90" | ||
| 411 | ], | ||
| 412 | "cmdUnderTest": "$TC actions replace action skbmod set etype 0x1111 goto chain 42 index 90 cookie c1a0c1a0", | ||
| 413 | "expExitCode": "255", | ||
| 414 | "verifyCmd": "$TC actions ls action skbmod", | ||
| 415 | "matchPattern": "action order [0-9]*: skbmod pass set etype 0x1111\\s+index 90 ref", | ||
| 416 | "matchCount": "1", | ||
| 417 | "teardown": [ | ||
| 418 | "$TC actions flush action skbmod" | ||
| 419 | ] | ||
| 395 | } | 420 | } |
| 396 | ] | 421 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json b/tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json index e7e15a7336b6..28453a445fdb 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/tunnel_key.json | |||
| @@ -884,5 +884,30 @@ | |||
| 884 | "teardown": [ | 884 | "teardown": [ |
| 885 | "$TC actions flush action tunnel_key" | 885 | "$TC actions flush action tunnel_key" |
| 886 | ] | 886 | ] |
| 887 | }, | ||
| 888 | { | ||
| 889 | "id": "8242", | ||
| 890 | "name": "Replace tunnel_key set action with invalid goto chain", | ||
| 891 | "category": [ | ||
| 892 | "actions", | ||
| 893 | "tunnel_key" | ||
| 894 | ], | ||
| 895 | "setup": [ | ||
| 896 | [ | ||
| 897 | "$TC actions flush action tunnel_key", | ||
| 898 | 0, | ||
| 899 | 1, | ||
| 900 | 255 | ||
| 901 | ], | ||
| 902 | "$TC actions add action tunnel_key set src_ip 10.10.10.1 dst_ip 20.20.20.2 dst_port 3128 nocsum id 1 pass index 90" | ||
| 903 | ], | ||
| 904 | "cmdUnderTest": "$TC actions replace action tunnel_key set src_ip 10.10.10.2 dst_ip 20.20.20.1 dst_port 3129 id 2 csum goto chain 42 index 90 cookie c1a0c1a0", | ||
| 905 | "expExitCode": "255", | ||
| 906 | "verifyCmd": "$TC actions get action tunnel_key index 90", | ||
| 907 | "matchPattern": "action order [0-9]+: tunnel_key.*set.*src_ip 10.10.10.1.*dst_ip 20.20.20.2.*key_id 1.*dst_port 3128.*csum pass.*index 90 ref", | ||
| 908 | "matchCount": "1", | ||
| 909 | "teardown": [ | ||
| 910 | "$TC actions flush action tunnel_key" | ||
| 911 | ] | ||
| 887 | } | 912 | } |
| 888 | ] | 913 | ] |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json b/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json index 69ea09eefffc..cc7c7d758008 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json | |||
| @@ -688,5 +688,30 @@ | |||
| 688 | "teardown": [ | 688 | "teardown": [ |
| 689 | "$TC actions flush action vlan" | 689 | "$TC actions flush action vlan" |
| 690 | ] | 690 | ] |
| 691 | }, | ||
| 692 | { | ||
| 693 | "id": "e394", | ||
| 694 | "name": "Replace vlan push action with invalid goto chain control", | ||
| 695 | "category": [ | ||
| 696 | "actions", | ||
| 697 | "vlan" | ||
| 698 | ], | ||
| 699 | "setup": [ | ||
| 700 | [ | ||
| 701 | "$TC actions flush action vlan", | ||
| 702 | 0, | ||
| 703 | 1, | ||
| 704 | 255 | ||
| 705 | ], | ||
| 706 | "$TC actions add action vlan push id 500 pass index 90" | ||
| 707 | ], | ||
| 708 | "cmdUnderTest": "$TC actions replace action vlan push id 500 goto chain 42 index 90 cookie c1a0c1a0", | ||
| 709 | "expExitCode": "255", | ||
| 710 | "verifyCmd": "$TC actions get action vlan index 90", | ||
| 711 | "matchPattern": "action order [0-9]+: vlan.*push id 500 protocol 802.1Q priority 0 pass.*index 90 ref", | ||
| 712 | "matchCount": "1", | ||
| 713 | "teardown": [ | ||
| 714 | "$TC actions flush action vlan" | ||
| 715 | ] | ||
| 691 | } | 716 | } |
| 692 | ] | 717 | ] |
