6.18.32-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 156/188 fbcon: Rename struct fbcon_ops to struct fbcon_par
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit a6adbbc4c32a016146e117b1e9e5242724a75e10 ]
The type struct fbcon_ops contains fbcon state and callbacks. As the callbacks will be removed from struct fbcon_ops, rename the data type to struct fbcon_par. Also rename the variables from ops to par.
The _par postfix ("private access registers") is used throughout the fbdev subsystem for per-driver state. The fbcon pointer within struct fb_info is also named fbcon_par. Hence, the new naming fits existing practice.
v2:
- rename struct fbcon_ops to struct fbcon_par
- fix build for CONFIG_FB_TILEBITTING=n (kernel test robot)
- fix indention
Stable-dep-of: e4ef723d8975 ("fbcon: Avoid OOB font access if console rotation fails")
--- drivers/video/fbdev/core/bitblit.c | 120 ++++----- drivers/video/fbdev/core/fbcon.c | 419 +++++++++++++++----------------- drivers/video/fbdev/core/fbcon.h | 6 drivers/video/fbdev/core/fbcon_ccw.c | 146 +++++------ drivers/video/fbdev/core/fbcon_cw.c | 146 +++++------ drivers/video/fbdev/core/fbcon_rotate.c | 40 +-- drivers/video/fbdev/core/fbcon_rotate.h | 6 drivers/video/fbdev/core/fbcon_ud.c | 162 ++++++------ drivers/video/fbdev/core/softcursor.c | 20 - drivers/video/fbdev/core/tileblit.c | 28 +- 10 files changed, 541 insertions(+), 552 deletions(-)
drivers/video/fbdev/core/bitblit.c +60 -60
@@ -261,10 +261,10 @@ static void bit_cursor(struct vc_data *v int fg, int bg) {struct fb_cursor cursor; -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;unsigned short charmask = vc->vc_hi_font_mask ?0x1ff :0xff ;int w =DIV_ROUND_UP (vc->vc_font.width,8 ), c; -int y =real_y (ops->p, vc->state.y); +int y =real_y (par->p, vc->state.y);int attribute, use_sw = vc->vc_cursor_type &CUR_SW ;int err =1 ;char *src;
@@ -278,10 +278,10 @@ static void bit_cursor(struct vc_data *v attribute =get_attribute (info, c); src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height)); -if (ops->cursor_state.image.data != src || - ops->cursor_reset) { - ops->cursor_state.image.data = src; - cursor.set |=FB_CUR_SETIMAGE ; +if (par->cursor_state.image.data != src || + par->cursor_reset) { + par->cursor_state.image.data = src; + cursor.set |=FB_CUR_SETIMAGE ; }if (attribute) {
@@ -290,46 +290,46 @@ static void bit_cursor(struct vc_data *v dst =kmalloc_array (w, vc->vc_font.height,GFP_ATOMIC );if (!dst)return ; -kfree (ops->cursor_data); - ops->cursor_data = dst; +kfree (par->cursor_data); + par->cursor_data = dst;update_attr (dst, src, attribute, vc); src = dst; } -if (ops->cursor_state.image.fg_color != fg || - ops->cursor_state.image.bg_color != bg || - ops->cursor_reset) { - ops->cursor_state.image.fg_color = fg; - ops->cursor_state.image.bg_color = bg; +if (par->cursor_state.image.fg_color != fg || + par->cursor_state.image.bg_color != bg || + par->cursor_reset) { + par->cursor_state.image.fg_color = fg; + par->cursor_state.image.bg_color = bg; cursor.set |=FB_CUR_SETCMAP ; } -if ((ops->cursor_state.image.dx != (vc->vc_font.width * vc->state.x)) || - (ops->cursor_state.image.dy != (vc->vc_font.height * y)) || - ops->cursor_reset) { - ops->cursor_state.image.dx = vc->vc_font.width * vc->state.x; - ops->cursor_state.image.dy = vc->vc_font.height * y; +if ((par->cursor_state.image.dx != (vc->vc_font.width * vc->state.x)) || + (par->cursor_state.image.dy != (vc->vc_font.height * y)) || + par->cursor_reset) { + par->cursor_state.image.dx = vc->vc_font.width * vc->state.x; + par->cursor_state.image.dy = vc->vc_font.height * y; cursor.set |=FB_CUR_SETPOS ; } -if (ops->cursor_state.image.height != vc->vc_font.height || - ops->cursor_state.image.width != vc->vc_font.width || - ops->cursor_reset) { - ops->cursor_state.image.height = vc->vc_font.height; - ops->cursor_state.image.width = vc->vc_font.width; +if (par->cursor_state.image.height != vc->vc_font.height || + par->cursor_state.image.width != vc->vc_font.width || + par->cursor_reset) { + par->cursor_state.image.height = vc->vc_font.height; + par->cursor_state.image.width = vc->vc_font.width; cursor.set |=FB_CUR_SETSIZE ; } -if (ops->cursor_state.hot.x || ops->cursor_state.hot.y || - ops->cursor_reset) { - ops->cursor_state.hot.x = cursor.hot.y =0 ; +if (par->cursor_state.hot.x || par->cursor_state.hot.y || + par->cursor_reset) { + par->cursor_state.hot.x = cursor.hot.y =0 ; cursor.set |=FB_CUR_SETHOT ; }if (cursor.set &FB_CUR_SETSIZE || - vc->vc_cursor_type != ops->p->cursor_shape || - ops->cursor_state.mask ==NULL || - ops->cursor_reset) { + vc->vc_cursor_type != par->p->cursor_shape || + par->cursor_state.mask ==NULL || + par->cursor_reset) {char *mask =kmalloc_array (w, vc->vc_font.height,GFP_ATOMIC );int cur_height, size, i =0 ;u8 msk =0xff ;
@@ -337,13 +337,13 @@ static void bit_cursor(struct vc_data *vif (!mask)return ; -kfree (ops->cursor_state.mask); - ops->cursor_state.mask = mask; +kfree (par->cursor_state.mask); + par->cursor_state.mask = mask; - ops->p->cursor_shape = vc->vc_cursor_type; + par->p->cursor_shape = vc->vc_cursor_type; cursor.set |=FB_CUR_SETSHAPE ; -switch (CUR_SIZE (ops->p->cursor_shape)) { +switch (CUR_SIZE (par->p->cursor_shape)) {case CUR_NONE : cur_height =0 ;break ;
@@ -372,19 +372,19 @@ static void bit_cursor(struct vc_data *v mask[i++] = msk; } - ops->cursor_state.enable = enable && !use_sw; + par->cursor_state.enable = enable && !use_sw; cursor.image.data = src; - cursor.image.fg_color = ops->cursor_state.image.fg_color; - cursor.image.bg_color = ops->cursor_state.image.bg_color; - cursor.image.dx = ops->cursor_state.image.dx; - cursor.image.dy = ops->cursor_state.image.dy; - cursor.image.height = ops->cursor_state.image.height; - cursor.image.width = ops->cursor_state.image.width; - cursor.hot.x = ops->cursor_state.hot.x; - cursor.hot.y = ops->cursor_state.hot.y; - cursor.mask = ops->cursor_state.mask; - cursor.enable = ops->cursor_state.enable; + cursor.image.fg_color = par->cursor_state.image.fg_color; + cursor.image.bg_color = par->cursor_state.image.bg_color; + cursor.image.dx = par->cursor_state.image.dx; + cursor.image.dy = par->cursor_state.image.dy; + cursor.image.height = par->cursor_state.image.height; + cursor.image.width = par->cursor_state.image.width; + cursor.hot.x = par->cursor_state.hot.x; + cursor.hot.y = par->cursor_state.hot.y; + cursor.mask = par->cursor_state.mask; + cursor.enable = par->cursor_state.enable; cursor.image.depth =1 ; cursor.rop =ROP_XOR ;
@@ -394,31 +394,31 @@ static void bit_cursor(struct vc_data *vif (err)soft_cursor (info, &cursor); - ops->cursor_reset =0 ; + par->cursor_reset =0 ; }static int bit_update_start (struct fb_info *info) { -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;int err; - err =fb_pan_display (info, &ops->var); - ops->var.xoffset = info->var.xoffset; - ops->var.yoffset = info->var.yoffset; - ops->var.vmode = info->var.vmode; + err =fb_pan_display (info, &par->var); + par->var.xoffset = info->var.xoffset; + par->var.yoffset = info->var.yoffset; + par->var.vmode = info->var.vmode;return err; } -void fbcon_set_bitops (struct fbcon_ops *ops) +void fbcon_set_bitops (struct fbcon_par *par) { - ops->bmove = bit_bmove; - ops->clear = bit_clear; - ops->putcs = bit_putcs; - ops->clear_margins = bit_clear_margins; - ops->cursor = bit_cursor; - ops->update_start = bit_update_start; - ops->rotate_font =NULL ; + par->bmove = bit_bmove; + par->clear = bit_clear; + par->putcs = bit_putcs; + par->clear_margins = bit_clear_margins; + par->cursor = bit_cursor; + par->update_start = bit_update_start; + par->rotate_font =NULL ; -if (ops->rotate) -fbcon_set_rotate (ops); +if (par->rotate) +fbcon_set_rotate (par); }
drivers/video/fbdev/core/fbcon.c +204 -215
1,061 lines not on this page · raw message
drivers/video/fbdev/core/fbcon.h +3 -3
@@ -50,7 +50,7 @@ struct fbcon_display {const struct fb_videomode *mode; }; -struct fbcon_ops { +struct fbcon_par {void (*bmove)(struct vc_data *vc,struct fb_info *info,int sy,int sx,int dy,int dx,int height,int width); void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
@@ -185,7 +185,7 @@ static inline u_short fb_scrollmode(stru#ifdef CONFIG_FB_TILEBLITTING extern void fbcon_set_tileops (struct vc_data *vc,struct fb_info *info);#endif -extern void fbcon_set_bitops (struct fbcon_ops *ops); +extern void fbcon_set_bitops (struct fbcon_par *par);extern int soft_cursor (struct fb_info *info,struct fb_cursor *cursor);#define FBCON_ATTRIBUTE_UNDERLINE 1
@@ -224,7 +224,7 @@ static inline int get_attribute(struct f (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; })#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION -extern void fbcon_set_rotate (struct fbcon_ops *ops); +extern void fbcon_set_rotate (struct fbcon_par *par);#else #define fbcon_set_rotate (x) do {} while(0)#endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
drivers/video/fbdev/core/fbcon_ccw.c +73 -73
261 lines not on this page · raw message
drivers/video/fbdev/core/fbcon_cw.c +73 -73
261 lines not on this page · raw message
drivers/video/fbdev/core/fbcon_rotate.c +20 -20
@@ -20,32 +20,32 @@static int fbcon_rotate_font (struct fb_info *info,struct vc_data *vc) { -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;int len, err =0 ;int s_cellsize, d_cellsize, i;const u8 *src;u8 *dst; -if (vc->vc_font.data == ops->fontdata && - ops->p->con_rotate == ops->cur_rotate) +if (vc->vc_font.data == par->fontdata && + par->p->con_rotate == par->cur_rotate) goto finished; - src = ops->fontdata = vc->vc_font.data; - ops->cur_rotate = ops->p->con_rotate; + src = par->fontdata = vc->vc_font.data; + par->cur_rotate = par->p->con_rotate; len = vc->vc_font.charcount; s_cellsize = ((vc->vc_font.width +7 )/8 ) * vc->vc_font.height; d_cellsize = s_cellsize; -if (ops->rotate ==FB_ROTATE_CW || - ops->rotate ==FB_ROTATE_CCW ) +if (par->rotate ==FB_ROTATE_CW || + par->rotate ==FB_ROTATE_CCW ) d_cellsize = ((vc->vc_font.height +7 )/8 ) * vc->vc_font.width;if (info->fbops->fb_sync) info->fbops->fb_sync (info); -if (ops->fd_size < d_cellsize * len) { +if (par->fd_size < d_cellsize * len) { dst =kmalloc_array (len, d_cellsize,GFP_KERNEL );if (dst ==NULL ) {
@@ -53,15 +53,15 @@ static int fbcon_rotate_font(struct fb_i goto finished; } - ops->fd_size = d_cellsize * len; -kfree (ops->fontbuffer); - ops->fontbuffer = dst; + par->fd_size = d_cellsize * len; +kfree (par->fontbuffer); + par->fontbuffer = dst; } - dst = ops->fontbuffer; -memset (dst,0 , ops->fd_size); + dst = par->fontbuffer; +memset (dst,0 , par->fd_size); -switch (ops->rotate) { +switch (par->rotate) {case FB_ROTATE_UD :for (i = len; i--; ) { rotate_ud(src, dst, vc->vc_font.width,
@@ -93,19 +93,19 @@ finished:return err; } -void fbcon_set_rotate (struct fbcon_ops *ops) +void fbcon_set_rotate (struct fbcon_par *par) { - ops->rotate_font = fbcon_rotate_font; + par->rotate_font = fbcon_rotate_font; -switch (ops->rotate) { +switch (par->rotate) {case FB_ROTATE_CW : -fbcon_rotate_cw (ops); +fbcon_rotate_cw (par);break ;case FB_ROTATE_UD : -fbcon_rotate_ud (ops); +fbcon_rotate_ud (par);break ;case FB_ROTATE_CCW : -fbcon_rotate_ccw (ops); +fbcon_rotate_ccw (par);break ; } }
drivers/video/fbdev/core/fbcon_rotate.h +3 -3
@@ -90,7 +90,7 @@ static inline void rotate_ccw(const char } } -extern void fbcon_rotate_cw (struct fbcon_ops *ops); -extern void fbcon_rotate_ud (struct fbcon_ops *ops); -extern void fbcon_rotate_ccw (struct fbcon_ops *ops); +extern void fbcon_rotate_cw (struct fbcon_par *par); +extern void fbcon_rotate_ud (struct fbcon_par *par); +extern void fbcon_rotate_ccw (struct fbcon_par *par);#endif
drivers/video/fbdev/core/fbcon_ud.c +81 -81
291 lines not on this page · raw message
drivers/video/fbdev/core/softcursor.c +10 -10
@@ -21,7 +21,7 @@int soft_cursor (struct fb_info *info,struct fb_cursor *cursor) { -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;unsigned int scan_align = info->pixmap.scan_align -1 ;unsigned int buf_align = info->pixmap.buf_align -1 ;unsigned int i, size, dsize, s_pitch, d_pitch;
@@ -34,19 +34,19 @@ int soft_cursor(struct fb_info *info, st s_pitch = (cursor->image.width +7 ) >>3 ; dsize = s_pitch * cursor->image.height; -if (dsize +sizeof (struct fb_image ) != ops->cursor_size) { -kfree (ops->cursor_src); - ops->cursor_size = dsize +sizeof (struct fb_image ); - - ops->cursor_src =kmalloc (ops->cursor_size,GFP_ATOMIC ); -if (!ops->cursor_src) { - ops->cursor_size =0 ; +if (dsize +sizeof (struct fb_image ) != par->cursor_size) { +kfree (par->cursor_src); + par->cursor_size = dsize +sizeof (struct fb_image ); + + par->cursor_src =kmalloc (par->cursor_size,GFP_ATOMIC ); +if (!par->cursor_src) { + par->cursor_size =0 ;return -ENOMEM ; } } - src = ops->cursor_src +sizeof (struct fb_image ); - image = (struct fb_image *)ops->cursor_src; + src = par->cursor_src +sizeof (struct fb_image ); + image = (struct fb_image *)par->cursor_src; *image = cursor->image; d_pitch = (s_pitch + scan_align) & ~scan_align;
drivers/video/fbdev/core/tileblit.c +14 -14
@@ -151,34 +151,34 @@ static void tile_cursor(struct vc_data *static int tile_update_start (struct fb_info *info) { -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par;int err; - err =fb_pan_display (info, &ops->var); - ops->var.xoffset = info->var.xoffset; - ops->var.yoffset = info->var.yoffset; - ops->var.vmode = info->var.vmode; + err =fb_pan_display (info, &par->var); + par->var.xoffset = info->var.xoffset; + par->var.yoffset = info->var.yoffset; + par->var.vmode = info->var.vmode;return err; }void fbcon_set_tileops (struct vc_data *vc,struct fb_info *info) {struct fb_tilemap map; -struct fbcon_ops *ops = info->fbcon_par; +struct fbcon_par *par = info->fbcon_par; - ops->bmove = tile_bmove; - ops->clear = tile_clear; - ops->putcs = tile_putcs; - ops->clear_margins = tile_clear_margins; - ops->cursor = tile_cursor; - ops->update_start = tile_update_start; + par->bmove = tile_bmove; + par->clear = tile_clear; + par->putcs = tile_putcs; + par->clear_margins = tile_clear_margins; + par->cursor = tile_cursor; + par->update_start = tile_update_start; -if (ops->p) { +if (par->p) { map.width = vc->vc_font.width; map.height = vc->vc_font.height; map.depth =1 ; map.length = vc->vc_font.charcount; - map.data = ops->p->fontdata; + map.data = par->p->fontdata; info->tileops->fb_settile (info, &map); } }
Greg Kroah-Hartman
maintainerPATCH 157/188 fbcon: Avoid OOB font access if console rotation fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit e4ef723d8975a2694cc90733a6b888a5e2841842 ]
Clear the font buffer if the reallocation during console rotation fails in fbcon_rotate_font(). The putcs implementations for the rotated buffer will return early in this case. See [1] for an example.
Currently, fbcon_rotate_font() keeps the old buffer, which is too small for the rotated font. Printing to the rotated console with a high-enough character code will overflow the font buffer.
v2:
- fix typos in commit message
--- drivers/video/fbdev/core/fbcon_rotate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/video/fbdev/core/fbcon_rotate.c +4 -1
@@ -46,6 +46,10 @@ static int fbcon_rotate_font(struct fb_i info->fbops->fb_sync (info);if (par->fd_size < d_cellsize * len) { +kfree (par->fontbuffer); + par->fontbuffer =NULL ; + par->fd_size =0 ; + dst =kmalloc_array (len, d_cellsize,GFP_KERNEL );if (dst ==NULL ) {
@@ -54,7 +58,6 @@ static int fbcon_rotate_font(struct fb_i } par->fd_size = d_cellsize * len; -kfree (par->fontbuffer); par->fontbuffer = dst; }
Greg Kroah-Hartman
maintainerPATCH 158/188 block: fix zone write plug removal
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit b7d4ffb510373cc6ecf16022dd0e510a023034fb ]
Commit 7b295187287e ("block: Do not remove zone write plugs still in use") modified disk_should_remove_zone_wplug() to add a check on the reference count of a zone write plug to prevent removing zone write plugs from a disk hash table when the plugs are still being referenced by BIOs or requests in-flight. However, this check does not take into account that a BIO completion may happen right after its submission by a zone write plug BIO work, and before the zone write plug BIO work releases the zone write plug reference count. This situation leads to disk_should_remove_zone_wplug() returning false as in this case the zone write plug reference count is at least equal to 3. If the BIO that completes in such manner transitioned the zone to the FULL condition, the zone write plug for the FULL zone will remain in the disk hash table.
Furthermore, relying on a particular value of a zone write plug reference count to set the BLK_ZONE_WPLUG_UNHASHED flag is fragile as reading the atomic reference count and doing a comparison with some value is not overall atomic at all.
Address these issues by reworking the reference counting of zone write plugs so that removing plugs from a disk hash table can be done directly from disk_put_zone_wplug() when the last reference on a plug is dropped.
To do so, replace the function disk_remove_zone_wplug() with disk_mark_zone_wplug_dead(). This new function sets the zone write plug flag BLK_ZONE_WPLUG_DEAD (which replaces BLK_ZONE_WPLUG_UNHASHED) and drops the initial reference on the zone write plug taken when the plug was added to the disk hash table. This function is called either for zones that are empty or full, or directly in the case of a forced plug removal (e.g. when the disk hash table is being destroyed on disk removal). With this change, disk_should_remove_zone_wplug() is also removed.
disk_put_zone_wplug() is modified to call the function disk_free_zone_wplug() to remove a zone write plug from a disk hash table and free the plug structure (with a call_rcu()), when the last reference on a zone write plug is dropped. disk_free_zone_wplug() always checks that the BLK_ZONE_WPLUG_DEAD flag is set.
In order to avoid having multiple zone write plugs for the same zone in the disk hash table, disk_get_and_lock_zone_wplug() checked for the BLK_ZONE_WPLUG_UNHASHED flag. This check is removed and a check for the new BLK_ZONE_WPLUG_DEAD flag is added to blk_zone_wplug_handle_write(). With this change, we continue preventing adding multiple zone write plugs for the same zone and at the same time re-inforce checks on the user behavior by failing new incoming write BIOs targeting a zone that is marked as dead. This case can happen only if the user erroneously issues write BIOs to zones that are full, or to zones that are currently being reset or finished.
--- block/blk-zoned.c | 147 ++++++++++++++++++++---------------------------------- 1 file changed, 56 insertions(+), 91 deletions(-)
block/blk-zoned.c +56 -91
@@ -83,17 +83,17 @@ static inline unsigned int disk_zone_wpl* being executed or the zone write plug bio list is not empty. * - BLK_ZONE_WPLUG_NEED_WP_UPDATE: Indicates that we lost track of a zone * write pointer offset and need to update it. -* - BLK_ZONE_WPLUG_UNHASHED: Indicates that the zone write plug was removed -* from the disk hash table and that the initial reference to the zone -* write plug set when the plug was first added to the hash table has been -* dropped. This flag is set when a zone is reset, finished or become full, -* to prevent new references to the zone write plug to be taken for -* newly incoming BIOs. A zone write plug flagged with this flag will be -* freed once all remaining references from BIOs or functions are dropped. +* - BLK_ZONE_WPLUG_DEAD: Indicates that the zone write plug will be +* removed from the disk hash table of zone write plugs when the last +* reference on the zone write plug is dropped. If set, this flag also +* indicates that the initial extra reference on the zone write plug was +* dropped, meaning that the reference count indicates the current number of +* active users (code context or BIOs and requests in flight). This flag is +* set when a zone is reset, finished or becomes full. */ #define BLK_ZONE_WPLUG_PLUGGED (1U << 0)#define BLK_ZONE_WPLUG_NEED_WP_UPDATE (1U << 1) -#define BLK_ZONE_WPLUG_UNHASHED (1U << 2) +#define BLK_ZONE_WPLUG_DEAD (1U << 2)/** * blk_zone_cond_str - Return string XXX in BLK_ZONE_COND_XXX.
@@ -467,67 +467,42 @@ static void disk_free_zone_wplug_rcu(strmempool_free (zwplug, zwplug->disk->zone_wplugs_pool); } -static inline void disk_put_zone_wplug (struct blk_zone_wplug *zwplug) +static void disk_free_zone_wplug (struct blk_zone_wplug *zwplug) { -if (refcount_dec_and_test (&zwplug->ref)) { -WARN_ON_ONCE (!bio_list_empty (&zwplug->bio_list)); -WARN_ON_ONCE (zwplug->flags &BLK_ZONE_WPLUG_PLUGGED ); -WARN_ON_ONCE (!(zwplug->flags &BLK_ZONE_WPLUG_UNHASHED )); - -call_rcu (&zwplug->rcu_head, disk_free_zone_wplug_rcu); - } -} - -static inline bool disk_should_remove_zone_wplug (struct gendisk *disk, -struct blk_zone_wplug *zwplug) -{ -lockdep_assert_held (&zwplug->lock); - -/* If the zone write plug was already removed, we are done. */ -if (zwplug->flags &BLK_ZONE_WPLUG_UNHASHED ) -return false; +struct gendisk *disk = zwplug->disk; +unsigned long flags; -/* If the zone write plug is still plugged, it cannot be removed. */ -if (zwplug->flags &BLK_ZONE_WPLUG_PLUGGED ) -return false; +WARN_ON_ONCE (!(zwplug->flags &BLK_ZONE_WPLUG_DEAD )); +WARN_ON_ONCE (zwplug->flags &BLK_ZONE_WPLUG_PLUGGED ); +WARN_ON_ONCE (!bio_list_empty (&zwplug->bio_list)); -/* -* Completions of BIOs with blk_zone_write_plug_bio_endio() may -* happen after handling a request completion with -* blk_zone_write_plug_finish_request() (e.g. with split BIOs -* that are chained). In such case, disk_zone_wplug_unplug_bio() -* should not attempt to remove the zone write plug until all BIO -* completions are seen. Check by looking at the zone write plug -* reference count, which is 2 when the plug is unused (one reference -* taken when the plug was allocated and another reference taken by the -* caller context). -*/ -if (refcount_read (&zwplug->ref) >2 ) -return false; +spin_lock_irqsave (&disk->zone_wplugs_lock, flags); +hlist_del_init_rcu (&zwplug->node); +atomic_dec (&disk->nr_zone_wplugs); +spin_unlock_irqrestore (&disk->zone_wplugs_lock, flags); -/* We can remove zone write plugs for zones that are empty or full. */ -return !zwplug->wp_offset ||disk_zone_wplug_is_full (disk, zwplug); +call_rcu (&zwplug->rcu_head, disk_free_zone_wplug_rcu); } -static void disk_remove_zone_wplug (struct gendisk *disk, -struct blk_zone_wplug *zwplug) +static inline void disk_put_zone_wplug (struct blk_zone_wplug *zwplug) { -unsigned long flags; +if (refcount_dec_and_test (&zwplug->ref)) +disk_free_zone_wplug (zwplug); +} -/* If the zone write plug was already removed, we have nothing to do. */ -if (zwplug->flags &BLK_ZONE_WPLUG_UNHASHED ) -return ; +/* +* Flag the zone write plug as dead and drop the initial reference we got when +* the zone write plug was added to the hash table. The zone write plug will be +* unhashed when its last reference is dropped. +*/ +static void disk_mark_zone_wplug_dead (struct blk_zone_wplug *zwplug) +{ +lockdep_assert_held (&zwplug->lock); -/* -* Mark the zone write plug as unhashed and drop the extra reference we -* took when the plug was inserted in the hash table. -*/ - zwplug->flags |=BLK_ZONE_WPLUG_UNHASHED ; -spin_lock_irqsave (&disk->zone_wplugs_lock, flags); -hlist_del_init_rcu (&zwplug->node); -atomic_dec (&disk->nr_zone_wplugs); -spin_unlock_irqrestore (&disk->zone_wplugs_lock, flags); -disk_put_zone_wplug (zwplug); +if (!(zwplug->flags &BLK_ZONE_WPLUG_DEAD )) { + zwplug->flags |=BLK_ZONE_WPLUG_DEAD ; +disk_put_zone_wplug (zwplug); + } }static void blk_zone_wplug_bio_work (struct work_struct *work);
@@ -547,18 +522,7 @@ static struct blk_zone_wplug *disk_get_a again: zwplug =disk_get_zone_wplug (disk, sector);if (zwplug) { -/* -* Check that a BIO completion or a zone reset or finish -* operation has not already removed the zone write plug from -* the hash table and dropped its reference count. In such case, -* we need to get a new plug so start over from the beginning. -*/ spin_lock_irqsave (&zwplug->lock, *flags); -if (zwplug->flags &BLK_ZONE_WPLUG_UNHASHED ) { -spin_unlock_irqrestore (&zwplug->lock, *flags); -disk_put_zone_wplug (zwplug); - goto again; - }return zwplug; }
@@ -645,14 +609,8 @@ static void disk_zone_wplug_set_wp_offse zwplug->flags &= ~BLK_ZONE_WPLUG_NEED_WP_UPDATE ; zwplug->wp_offset = wp_offset;disk_zone_wplug_abort (zwplug); - -/* -* The zone write plug now has no BIO plugged: remove it from the -* hash table so that it cannot be seen. The plug will be freed -* when the last reference is dropped. -*/ -if (disk_should_remove_zone_wplug (disk, zwplug)) -disk_remove_zone_wplug (disk, zwplug); +if (!zwplug->wp_offset ||disk_zone_wplug_is_full (disk, zwplug)) +disk_mark_zone_wplug_dead (zwplug); }static unsigned int blk_zone_wp_offset (struct blk_zone *zone)
@@ -1068,6 +1026,19 @@ static bool blk_zone_wplug_handle_write(return true; } +/* +* If we got a zone write plug marked as dead, then the user is issuing +* writes to a full zone, or without synchronizing with zone reset or +* zone finish operations. In such case, fail the BIO to signal this +* invalid usage. +*/ +if (zwplug->flags &BLK_ZONE_WPLUG_DEAD ) { +spin_unlock_irqrestore (&zwplug->lock, flags); +disk_put_zone_wplug (zwplug); +bio_io_error (bio); +return true; + } +/* Indicate that this BIO is being handled using zone write plugging. */ bio_set_flag (bio,BIO_ZONE_WRITE_PLUGGING );
@@ -1136,7 +1107,7 @@ static void blk_zone_wplug_handle_native disk->disk_name, zwplug->zone_no);disk_zone_wplug_abort (zwplug); } -disk_remove_zone_wplug (disk, zwplug); +disk_mark_zone_wplug_dead (zwplug);spin_unlock_irqrestore (&zwplug->lock, flags);disk_put_zone_wplug (zwplug);
@@ -1239,14 +1210,8 @@ static void disk_zone_wplug_unplug_bio(s } zwplug->flags &= ~BLK_ZONE_WPLUG_PLUGGED ; - -/* -* If the zone is full (it was fully written or finished, or empty -* (it was reset), remove its zone write plug from the hash table. -*/ -if (disk_should_remove_zone_wplug (disk, zwplug)) -disk_remove_zone_wplug (disk, zwplug); - +if (!zwplug->wp_offset ||disk_zone_wplug_is_full (disk, zwplug)) +disk_mark_zone_wplug_dead (zwplug);spin_unlock_irqrestore (&zwplug->lock, flags); }
@@ -1457,9 +1422,9 @@ static void disk_destroy_zone_wplugs_haswhile (!hlist_empty (&disk->zone_wplugs_hash[i])) { zwplug =hlist_entry (disk->zone_wplugs_hash[i].first, struct blk_zone_wplug, node); -refcount_inc (&zwplug->ref); -disk_remove_zone_wplug (disk, zwplug); -disk_put_zone_wplug (zwplug); +spin_lock_irq (&zwplug->lock); +disk_mark_zone_wplug_dead (zwplug); +spin_unlock_irq (&zwplug->lock); } }
Greg Kroah-Hartman
maintainerPATCH 159/188 EDAC/versalnet: Fix device name memory leak
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prasanna Kumar T S M <[email protected]>
[ Upstream commit 8cf5dd235eff6008cb04c3d8064d2acfa90616f1 ]
The device name allocated via kzalloc() in init_one_mc() is assigned to dev->init_name but never freed on the normal removal path. device_register() copies init_name and then sets dev->init_name to NULL, so the name pointer becomes unreachable from the device. Thus leaking memory.
Use a stack-local char array instead of using kzalloc() for name.
--- drivers/edac/versalnet_edac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/edac/versalnet_edac.c +1 -2
@@ -765,9 +765,9 @@ static int init_versalnet(struct mc_privu32 num_chans, rank, dwidth, config;struct edac_mc_layer layers[2 ];struct mem_ctl_info *mci; +char name[32 ];struct device *dev;enum dev_type dt; -char *name;int rc, i;for (i =0 ; i <NUM_CONTROLLERS ; i++) {
@@ -814,7 +814,6 @@ static int init_versalnet(struct mc_priv dev =kzalloc (sizeof (*dev),GFP_KERNEL ); dev->release = versal_edac_release; - name =kmalloc (32 ,GFP_KERNEL );sprintf (name,"versal-net-ddrmc5-edac-%d" , i); dev->init_name = name; rc =device_register (dev);
Greg Kroah-Hartman
maintainerPATCH 160/188 papr-hvpipe: convert papr_hvpipe_dev_create_handle() to FD_PREPARE()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 6d3789d347a7af5c4b0b2da3af47b8d9da607ab2 ]
Fixes a UAF for src_info as well.
Stable-dep-of: 7a4f0846ee6c ("pseries/papr-hvpipe: Fix race with interrupt handler")
--- arch/powerpc/platforms/pseries/papr-hvpipe.c | 39 ++++++--------------------- 1 file changed, 9 insertions(+), 30 deletions(-)
arch/powerpc/platforms/pseries/papr-hvpipe.c +9 -30
@@ -484,10 +484,7 @@ static const struct file_operations paprstatic int papr_hvpipe_dev_create_handle (u32 srcID) { -struct hvpipe_source_info *src_info; -struct file *file; -long err; -int fd; + struct hvpipe_source_info *src_info __free(kfree) = NULL;spin_lock (&hvpipe_src_list_lock);/*
@@ -511,20 +508,13 @@ static int papr_hvpipe_dev_create_handle src_info->tsk = current;init_waitqueue_head (&src_info->recv_wqh); - fd =get_unused_fd_flags (O_RDONLY |O_CLOEXEC ); -if (fd <0 ) { - err = fd; - goto free_buf; - } - - file =anon_inode_getfile ("[papr-hvpipe]" , - &papr_hvpipe_handle_ops, (void *)src_info, -O_RDWR ); -if (IS_ERR (file)) { - err =PTR_ERR (file); - goto free_fd; - } +FD_PREPARE (fdf,O_RDONLY |O_CLOEXEC , +anon_inode_getfile ("[papr-hvpipe]" , &papr_hvpipe_handle_ops, + (void *)src_info,O_RDWR )); +if (fdf.err) +return fdf.err; +retain_and_null_ptr (src_info);spin_lock (&hvpipe_src_list_lock);/* * If two processes are executing ioctl() for the same
@@ -533,22 +523,11 @@ static int papr_hvpipe_dev_create_handle*/ if (hvpipe_find_source (srcID)) {spin_unlock (&hvpipe_src_list_lock); - err = -EALREADY ; - goto free_file; +return -EALREADY ; }list_add (&src_info->list, &hvpipe_src_list);spin_unlock (&hvpipe_src_list_lock); - -fd_install (fd, file); -return fd; - -free_file: -fput (file); -free_fd: -put_unused_fd (fd); -free_buf: -kfree (src_info); -return err; +return fd_publish (fdf); }/*
Re: [PATCH 6.18 160/188] papr-hvpipe: convert papr_hvpipe_dev_create_handle() to FD_PREPARE()
This fails to build:
/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/arch/powerpc/platforms/pseries/papr-hvpipe.c: In function ‘papr_hvpipe_dev_create_handle’:/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/arch/powerpc/platforms/pseries/papr-hvpipe.c:513:9: error: implicit declaration of function ‘FD_PREPARE’ [-Wimplicit-function-declaration]
513 | FD_PREPARE(fdf, O_RDONLY | O_CLOEXEC,
| ^~~~~~~~~~
/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/arch/powerpc/platforms/pseries/papr-hvpipe.c:513:20: error: ‘fdf’ undeclared (first use in this function); did you mean ‘fd’?
513 | FD_PREPARE(fdf, O_RDONLY | O_CLOEXEC,
| ^~~
| fd
/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/arch/powerpc/platforms/pseries/papr-hvpipe.c:513:20: note: each undeclared identifier is reported only once for each function it appears in
/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/arch/powerpc/platforms/pseries/papr-hvpipe.c:532:16: error: implicit declaration of function ‘fd_publish’ [-Wimplicit-function-declaration]
532 | return fd_publish(fdf);
| ^~~~~~~~~~make[6]: *** [/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/scripts/Makefile.build:287: arch/powerpc/platforms/pseries/papr-hvpipe.o] Error 1 make[5]: *** [/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/scripts/Makefile.build:544: arch/powerpc/platforms/pseries] Error 2 make[4]: *** [/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/scripts/Makefile.build:544: arch/powerpc/platforms] Error 2 make[3]: ***
[/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.32/work/linux-6.18/scripts/Makefile.build:544:arch/powerpc] Error 2
FD_PREPARE doesn't exist in 6.18, it's from:
commit 011703a9acd76edc7c85d80dbccb6e50dba53aad
Author: Christian Brauner <[email protected]> AuthorDate: Sun Nov 23 17:33:19 2025 +0100 Commit: Christian Brauner <[email protected]> CommitDate: Fri Nov 28 12:42:23 2025 +0100
file: add FD_{ADD,PREPARE}()
sam
Sasha Levin
maintainerRe: [PATCH 6.18 160/188] papr-hvpipe: convert papr_hvpipe_dev_create_handle() to FD_PREPARE()
Quoted 5 lines · Sam James
FD_PREPAREdoesn't exist in 6.18, it's from:commit
011703a9acd76edc7c85d80dbccb6e50dba53aad
Author: Christian Brauner <[email protected]>
file: add FD_{ADD,PREPARE}()
Thanks Sam. Backporting the FD_PREPARE/fd_publish primitives to 6.18 is too invasive for stable, so I've reverted both papr-hvpipe commits from pending-6.18:
- 09c15bbbed533 ("papr-hvpipe: convert papr_hvpipe_dev_create_handle()
to FD_PREPARE()")
- 6542e180fa6e1 ("pseries/papr-hvpipe: Fix race with interrupt handler")
The race fix can be reworked later without depending on FD_PREPARE if the maintainers want it in 6.18.
--
Thanks,
Sasha
Re: [PATCH 6.18 160/188] papr-hvpipe: convert papr_hvpipe_dev_create_handle() to FD_PREPARE()
Quoted 11 lines · Sasha Levin
Quoted 5 lines · Sam James
FD_PREPAREdoesn't exist in 6.18, it's from:commit
011703a9acd76edc7c85d80dbccb6e50dba53aad
Author: Christian Brauner <[email protected]>
file: add FD_{ADD,PREPARE}()Thanks Sam. Backporting the FD_PREPARE/fd_publish primitives to 6.18 is too invasive for stable, so I've reverted both papr-hvpipe commits from pending-6.18:
Quoted 6 lines
-
09c15bbbed533("papr-hvpipe: convertpapr_hvpipe_dev_create_handle()to FD_PREPARE()")-
6542e180fa6e1("pseries/papr-hvpipe: Fix race with interrupt handler")The race fix can be reworked later without depending on
FD_PREPAREif the maintainers want it in 6.18.
Thanks!
Greg Kroah-Hartman
maintainerPATCH 161/188 pseries/papr-hvpipe: Fix race with interrupt handler
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Ritesh Harjani (IBM)" <[email protected]>
[ Upstream commit 7a4f0846ee6cc8cf44ae0046ed42e3259d1dd45b ]
While executing ->ioctl handler or ->release handler, if an interrupt fires on the same cpu, then we can enter into a deadlock.
This patch fixes both these handlers to take spin_lock_irq{save|restore} versions of the lock to prevent this deadlock.
--- arch/powerpc/platforms/pseries/papr-hvpipe.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
arch/powerpc/platforms/pseries/papr-hvpipe.c +11 -9
@@ -449,13 +449,14 @@ static int papr_hvpipe_handle_release(st struct file *file) {struct hvpipe_source_info *src_info; +unsigned long flags;/* * Hold the lock, remove source from src_list, reset the * hvpipe status and release the lock to prevent any race * with message event IRQ. */ -spin_lock (&hvpipe_src_list_lock); +spin_lock_irqsave (&hvpipe_src_list_lock, flags); src_info = file->private_data;list_del (&src_info->list); file->private_data =NULL ;
@@ -466,10 +467,10 @@ static int papr_hvpipe_handle_release(st*/ if (src_info->hvpipe_status &HVPIPE_MSG_AVAILABLE ) { src_info->hvpipe_status =0 ; -spin_unlock (&hvpipe_src_list_lock); +spin_unlock_irqrestore (&hvpipe_src_list_lock, flags);hvpipe_rtas_recv_msg (NULL ,0 ); }else -spin_unlock (&hvpipe_src_list_lock); +spin_unlock_irqrestore (&hvpipe_src_list_lock, flags);kfree (src_info);return 0 ;
@@ -485,20 +486,21 @@ static const struct file_operations paprstatic int papr_hvpipe_dev_create_handle (u32 srcID) { struct hvpipe_source_info *src_info __free(kfree) = NULL; +unsigned long flags; -spin_lock (&hvpipe_src_list_lock); +spin_lock_irqsave (&hvpipe_src_list_lock, flags);/* * Do not allow more than one process communicates with * each source. */ src_info =hvpipe_find_source (srcID);if (src_info) { -spin_unlock (&hvpipe_src_list_lock); +spin_unlock_irqrestore (&hvpipe_src_list_lock, flags);pr_err ("pid(%d) is already using the source(%d)\n" , src_info->tsk->pid, srcID);return -EALREADY ; } -spin_unlock (&hvpipe_src_list_lock); +spin_unlock_irqrestore (&hvpipe_src_list_lock, flags); src_info =kzalloc (sizeof (*src_info),GFP_KERNEL_ACCOUNT );if (!src_info)
@@ -515,18 +517,18 @@ static int papr_hvpipe_dev_create_handlereturn fdf.err;retain_and_null_ptr (src_info); -spin_lock (&hvpipe_src_list_lock); +spin_lock_irqsave (&hvpipe_src_list_lock, flags);/* * If two processes are executing ioctl() for the same * source ID concurrently, prevent the second process to * acquire FD. */ if (hvpipe_find_source (srcID)) { -spin_unlock (&hvpipe_src_list_lock); +spin_unlock_irqrestore (&hvpipe_src_list_lock, flags);return -EALREADY ; }list_add (&src_info->list, &hvpipe_src_list); -spin_unlock (&hvpipe_src_list_lock); +spin_unlock_irqrestore (&hvpipe_src_list_lock, flags);return fd_publish (fdf); }
Greg Kroah-Hartman
maintainerPATCH 162/188 spi: uniphier: Simplify clock handling with devm_clk_get_enabled()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit fdca270f8f87cae2eb5b619234b9dd11a863ce6b ]
Replace devm_clk_get() followed by clk_prepare_enable() with devm_clk_get_enabled() for the clock. This removes the need for explicit clock enable and disable calls, as the managed API automatically handles clock disabling on device removal or probe failure.
Remove the now-unnecessary clk_disable_unprepare() calls from the probe error path and the remove callback. Adjust error labels accordingly.
Stable-dep-of: 0245435f7772 ("spi: uniphier: fix controller deregistration")
--- drivers/spi/spi-uniphier.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/spi/spi-uniphier.c +4 -14
@@ -666,28 +666,24 @@ static int uniphier_spi_probe(struct pla } priv->base_dma_addr = res->start; - priv->clk =devm_clk_get (&pdev->dev,NULL ); + priv->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (priv->clk)) {dev_err (&pdev->dev,"failed to get clock\n" ); ret =PTR_ERR (priv->clk); goto out_host_put; } - ret =clk_prepare_enable (priv->clk); -if (ret) - goto out_host_put; - irq =platform_get_irq (pdev,0 );if (irq <0 ) { ret = irq; - goto out_disable_clk; + goto out_host_put; } ret =devm_request_irq (&pdev->dev, irq, uniphier_spi_handler,0 ,"uniphier-spi" , priv);if (ret) {dev_err (&pdev->dev,"failed to request IRQ\n" ); - goto out_disable_clk; + goto out_host_put; }init_completion (&priv->xfer_done);
@@ -717,7 +713,7 @@ static int uniphier_spi_probe(struct plaif (IS_ERR_OR_NULL (host->dma_tx)) {if (PTR_ERR (host->dma_tx) == -EPROBE_DEFER ) { ret = -EPROBE_DEFER ; - goto out_disable_clk; + goto out_host_put; } host->dma_tx =NULL ; dma_tx_burst =INT_MAX ;
@@ -767,9 +763,6 @@ out_release_dma: host->dma_tx =NULL ; } -out_disable_clk: -clk_disable_unprepare (priv->clk); - out_host_put:spi_controller_put (host);return ret;
@@ -778,14 +771,11 @@ out_host_put:static void uniphier_spi_remove (struct platform_device *pdev) {struct spi_controller *host =platform_get_drvdata (pdev); -struct uniphier_spi_priv *priv =spi_controller_get_devdata (host);if (host->dma_tx)dma_release_channel (host->dma_tx);if (host->dma_rx)dma_release_channel (host->dma_rx); - -clk_disable_unprepare (priv->clk); }static const struct of_device_id uniphier_spi_match[] = {
Greg Kroah-Hartman
maintainerPATCH 163/188 spi: uniphier: fix controller deregistration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 0245435f777264ac45945ed2f325dd095a41d1af ]
Make sure to deregister the controller before releasing underlying resources like DMA during driver unbind.
Note that clocks were also disabled before the recent commit fdca270f8f87 ("spi: uniphier: Simplify clock handling with devm_clk_get_enabled()").
--- drivers/spi/spi-uniphier.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/spi/spi-uniphier.c +7 -1
@@ -747,7 +747,7 @@ static int uniphier_spi_probe(struct pla host->max_dma_len =min (dma_tx_burst, dma_rx_burst); - ret =devm_spi_register_controller (&pdev->dev, host); + ret =spi_register_controller (host);if (ret) goto out_release_dma;
@@ -772,10 +772,16 @@ static void uniphier_spi_remove(struct p {struct spi_controller *host =platform_get_drvdata (pdev); +spi_controller_get (host); + +spi_unregister_controller (host); +if (host->dma_tx)dma_release_channel (host->dma_tx);if (host->dma_rx)dma_release_channel (host->dma_rx); + +spi_controller_put (host); }static const struct of_device_id uniphier_spi_match[] = {
Greg Kroah-Hartman
maintainerPATCH 164/188 spi: tegra20-sflash: fix controller deregistration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit ad7310e983327f939dd6c4e801eab13238992572 ]
Make sure to deregister the controller before disabling underlying resources like clocks during driver unbind.
--- drivers/spi/spi-tegra20-sflash.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/spi/spi-tegra20-sflash.c +7 -1
@@ -506,7 +506,7 @@ static int tegra_sflash_probe(struct plapm_runtime_put (&pdev->dev); host->dev.of_node = pdev->dev.of_node; - ret =devm_spi_register_controller (&pdev->dev, host); + ret =spi_register_controller (host);if (ret <0 ) {dev_err (&pdev->dev,"can not register to host err %d\n" , ret); goto exit_pm_disable;
@@ -529,11 +529,17 @@ static void tegra_sflash_remove(struct pstruct spi_controller *host =platform_get_drvdata (pdev);struct tegra_sflash_data *tsd =spi_controller_get_devdata (host); +spi_controller_get (host); + +spi_unregister_controller (host); +free_irq (tsd->irq, tsd);pm_runtime_disable (&pdev->dev);if (!pm_runtime_status_suspended (&pdev->dev))tegra_sflash_runtime_suspend (&pdev->dev); + +spi_controller_put (host); }#ifdef CONFIG_PM_SLEEP
Greg Kroah-Hartman
maintainerPATCH 165/188 spi: tegra114: fix controller deregistration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 9c9c27ff2058142d8f800de3186d6864184958de ]
Make sure to deregister the controller before disabling underlying resources like clocks during driver unbind.
--- drivers/spi/spi-tegra114.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/spi/spi-tegra114.c +7 -1
@@ -1416,7 +1416,7 @@ static int tegra_spi_probe(struct platfo } host->dev.of_node = pdev->dev.of_node; - ret =devm_spi_register_controller (&pdev->dev, host); + ret =spi_register_controller (host);if (ret <0 ) {dev_err (&pdev->dev,"can not register to host err %d\n" , ret); goto exit_free_irq;
@@ -1442,6 +1442,10 @@ static void tegra_spi_remove(struct platstruct spi_controller *host =platform_get_drvdata (pdev);struct tegra_spi_data *tspi =spi_controller_get_devdata (host); +spi_controller_get (host); + +spi_unregister_controller (host); +free_irq (tspi->irq, tspi);if (tspi->tx_dma_chan)
@@ -1453,6 +1457,8 @@ static void tegra_spi_remove(struct platpm_runtime_disable (&pdev->dev);if (!pm_runtime_status_suspended (&pdev->dev))tegra_spi_runtime_suspend (&pdev->dev); + +spi_controller_put (host); }#ifdef CONFIG_PM_SLEEP
Greg Kroah-Hartman
maintainerPATCH 166/188 spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 1f8fd9490e3184e9a2394df2e682901a1d57ce71 ]
Replace devm_clk_get() followed by clk_prepare_enable() with devm_clk_get_enabled() for both "pclk" and "ref_clk". This removes the need for explicit clock enable and disable calls, as the managed API automatically disables the clocks on device removal or probe failure.
Remove the now-unnecessary clk_disable_unprepare() calls from the probe error paths and the remove callback. Simplify error handling by jumping directly to the remove_ctlr label.
Stable-dep-of: c9c012706c9f ("spi: zynq-qspi: fix controller deregistration")
--- drivers/spi/spi-zynq-qspi.c | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-)
drivers/spi/spi-zynq-qspi.c +6 -36
@@ -381,21 +381,10 @@ static int zynq_qspi_setup_op(struct spi {struct spi_controller *ctlr = spi->controller;struct zynq_qspi *qspi =spi_controller_get_devdata (ctlr); -int ret;if (ctlr->busy)return -EBUSY ; - ret =clk_enable (qspi->refclk); -if (ret) -return ret; - - ret =clk_enable (qspi->pclk); -if (ret) { -clk_disable (qspi->refclk); -return ret; - } -zynq_qspi_write (qspi,ZYNQ_QSPI_ENABLE_OFFSET ,ZYNQ_QSPI_ENABLE_ENABLE_MASK );
@@ -661,7 +650,7 @@ static int zynq_qspi_probe(struct platfo goto remove_ctlr; } - xqspi->pclk =devm_clk_get (&pdev->dev,"pclk" ); + xqspi->pclk =devm_clk_get_enabled (&pdev->dev,"pclk" );if (IS_ERR (xqspi->pclk)) {dev_err (&pdev->dev,"pclk clock not found.\n" ); ret =PTR_ERR (xqspi->pclk);
@@ -670,36 +659,24 @@ static int zynq_qspi_probe(struct platfoinit_completion (&xqspi->data_completion); - xqspi->refclk =devm_clk_get (&pdev->dev,"ref_clk" ); + xqspi->refclk =devm_clk_get_enabled (&pdev->dev,"ref_clk" );if (IS_ERR (xqspi->refclk)) {dev_err (&pdev->dev,"ref_clk clock not found.\n" ); ret =PTR_ERR (xqspi->refclk); goto remove_ctlr; } - ret =clk_prepare_enable (xqspi->pclk); -if (ret) { -dev_err (&pdev->dev,"Unable to enable APB clock.\n" ); - goto remove_ctlr; - } - - ret =clk_prepare_enable (xqspi->refclk); -if (ret) { -dev_err (&pdev->dev,"Unable to enable device clock.\n" ); - goto clk_dis_pclk; - } - xqspi->irq =platform_get_irq (pdev,0 );if (xqspi->irq <0 ) { ret = xqspi->irq; - goto clk_dis_all; + goto remove_ctlr; } ret =devm_request_irq (&pdev->dev, xqspi->irq, zynq_qspi_irq,0 , pdev->name, xqspi);if (ret !=0 ) { ret = -ENXIO ;dev_err (&pdev->dev,"request_irq failed\n" ); - goto clk_dis_all; + goto remove_ctlr; } ret = of_property_read_u32(np, "num-cs",
@@ -709,7 +686,7 @@ static int zynq_qspi_probe(struct platfo }else if (num_cs >ZYNQ_QSPI_MAX_NUM_CS ) { ret = -EINVAL ;dev_err (&pdev->dev,"only 2 chip selects are available\n" ); - goto clk_dis_all; + goto remove_ctlr; }else { ctlr->num_chipselect = num_cs; }
@@ -728,15 +705,11 @@ static int zynq_qspi_probe(struct platfo ret =devm_spi_register_controller (&pdev->dev, ctlr);if (ret) {dev_err (&pdev->dev,"devm_spi_register_controller failed\n" ); - goto clk_dis_all; + goto remove_ctlr; }return ret; -clk_dis_all: -clk_disable_unprepare (xqspi->refclk); -clk_dis_pclk: -clk_disable_unprepare (xqspi->pclk); remove_ctlr:spi_controller_put (ctlr);
@@ -758,9 +731,6 @@ static void zynq_qspi_remove(struct platstruct zynq_qspi *xqspi =platform_get_drvdata (pdev);zynq_qspi_write (xqspi,ZYNQ_QSPI_ENABLE_OFFSET ,0 ); - -clk_disable_unprepare (xqspi->refclk); -clk_disable_unprepare (xqspi->pclk); }static const struct of_device_id zynq_qspi_of_match[] = {
Greg Kroah-Hartman
maintainerPATCH 167/188 spi: zynq-qspi: fix controller deregistration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit c9c012706c9fa8ca6d129a9161caf92ab625a3fd ]
Make sure to deregister the controller before disabling it during driver unbind.
Note that clocks were also disabled before the recent commit 1f8fd9490e31 ("spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled()").
--- drivers/spi/spi-zynq-qspi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/spi/spi-zynq-qspi.c +11 -4
@@ -643,7 +643,7 @@ static int zynq_qspi_probe(struct platfo xqspi =spi_controller_get_devdata (ctlr); xqspi->dev = dev; -platform_set_drvdata (pdev, xqspi); +platform_set_drvdata (pdev, ctlr); xqspi->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (xqspi->regs)) { ret =PTR_ERR (xqspi->regs);
@@ -702,9 +702,9 @@ static int zynq_qspi_probe(struct platfo/* QSPI controller initializations */ zynq_qspi_init_hw (xqspi, ctlr->num_chipselect); - ret =devm_spi_register_controller (&pdev->dev, ctlr); + ret =spi_register_controller (ctlr);if (ret) { -dev_err (&pdev->dev,"devm_spi_register_controller failed\n" ); +dev_err (&pdev->dev,"failed to register controller\n" ); goto remove_ctlr; }
@@ -728,9 +728,16 @@ remove_ctlr:*/ static void zynq_qspi_remove (struct platform_device *pdev) { -struct zynq_qspi *xqspi =platform_get_drvdata (pdev); +struct spi_controller *ctlr =platform_get_drvdata (pdev); +struct zynq_qspi *xqspi =spi_controller_get_devdata (ctlr); + +spi_controller_get (ctlr); + +spi_unregister_controller (ctlr);zynq_qspi_write (xqspi,ZYNQ_QSPI_ENABLE_OFFSET ,0 ); + +spi_controller_put (ctlr); }static const struct of_device_id zynq_qspi_of_match[] = {
Greg Kroah-Hartman
maintainerPATCH 168/188 Bluetooth: hci_conn: fix potential UAF in create_big_sync
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit 0beddb0c380bed5f5b8e61ddbe14635bb73d0b41 ]
Add hci_conn_valid() check in create_big_sync() to detect stale connections before proceeding with BIG creation. Handle the resulting -ECANCELED in create_big_complete() and re-validate the connection under hci_dev_lock() before dereferencing, matching the pattern used by create_le_conn_complete() and create_pa_complete().
Keep the hci_conn object alive across the async boundary by taking a reference via hci_conn_get() when queueing create_big_sync(), and dropping it in the completion callback. The refcount and the lock are complementary: the refcount keeps the object allocated, while hci_dev_lock() serializes hci_conn_hash_del()'s list_del_rcu() on hdev->conn_hash, as required by hci_conn_del().
hci_conn_put() is called outside hci_dev_unlock() so the final put (which resolves to kfree() via bt_link_release) does not run under hdev->lock, though the release path would be safe either way.
Without this, create_big_complete() would unconditionally dereference the conn pointer on error, causing a use-after-free via hci_connect_cfm() and hci_conn_del().
--- net/bluetooth/hci_conn.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
net/bluetooth/hci_conn.c +18 -1
@@ -2113,6 +2113,9 @@ static int create_big_sync(struct hci_deu32 flags =0 ;int err; +if (!hci_conn_valid (hdev, conn)) +return -ECANCELED ; +if (qos->bcast.out.phy ==0x02 ) flags |=MGMT_ADV_FLAG_SEC_2M ;
@@ -2188,11 +2191,24 @@ static void create_big_complete(struct hbt_dev_dbg (hdev,"conn %p" , conn); +if (err == -ECANCELED ) + goto done; + +hci_dev_lock (hdev); + +if (!hci_conn_valid (hdev, conn)) + goto unlock; +if (err) {bt_dev_err (hdev,"Unable to create BIG: %d" , err);hci_connect_cfm (conn, err);hci_conn_del (conn); } + +unlock: +hci_dev_unlock (hdev); +done: +hci_conn_put (conn); } struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid,
@@ -2309,10 +2325,11 @@ struct hci_conn *hci_connect_bis(struct BT_BOUND, &data);/* Queue start periodic advertising and create BIG */ - err =hci_cmd_sync_queue (hdev, create_big_sync, conn, + err =hci_cmd_sync_queue (hdev, create_big_sync,hci_conn_get (conn), create_big_complete);if (err <0 ) {hci_conn_drop (conn); +hci_conn_put (conn);return ERR_PTR (err); }
Greg Kroah-Hartman
maintainerPATCH 169/188 sched/ext: Implement cgroup_set_idle() callback
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: zhidao su <[email protected]>
[ Upstream commit 347ed2d566dabb06c7970fff01129c4f59995ed6 ]
Implement the missing cgroup_set_idle() callback that was marked as a TODO. This allows BPF schedulers to be notified when a cgroup's idle state changes, enabling them to adjust their scheduling behavior accordingly.
The implementation follows the same pattern as other cgroup callbacks like cgroup_set_weight() and cgroup_set_bandwidth(). It checks if the BPF scheduler has implemented the callback and invokes it with the appropriate parameters.
Fixes a spelling error in the cgroup_set_bandwidth() documentation.
tj: s/scx_cgroup_rwsem/scx_cgroup_ops_rwsem/ to fix build breakage.
Stable-dep-of: 80afd4c84bc8 ("sched_ext: Read scx_root under scx_cgroup_ops_rwsem in cgroup setters")
--- include/linux/sched/ext.h | 1 + kernel/sched/ext.c | 16 +++++++++++++++- kernel/sched/ext_internal.h | 13 ++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-)
include/linux/sched/ext.h +1 -0
@@ -228,6 +228,7 @@ struct scx_task_group {u64 bw_period_us;u64 bw_quota_us;u64 bw_burst_us; +bool idle;#endif };
kernel/sched/ext.c +15 -1
@@ -3118,6 +3118,7 @@ void scx_tg_init(struct task_group *tg) tg->scx.weight =CGROUP_WEIGHT_DFL ; tg->scx.bw_period_us =default_bw_period_us (); tg->scx.bw_quota_us =RUNTIME_INF ; + tg->scx.idle = false; }int scx_tg_online (struct task_group *tg)
@@ -3266,7 +3267,18 @@ void scx_group_set_weight(struct task_grvoid scx_group_set_idle (struct task_group *tg,bool idle) { -/* TODO: Implement ops->cgroup_set_idle() */ +struct scx_sched *sch = scx_root; + +percpu_down_read (&scx_cgroup_ops_rwsem); + +if (scx_cgroup_enabled &&SCX_HAS_OP (sch, cgroup_set_idle)) +SCX_CALL_OP (sch,SCX_KF_UNLOCKED , cgroup_set_idle,NULL , +tg_cgrp (tg), idle); + +/* Update the task group's idle state */ + tg->scx.idle = idle; + +percpu_up_read (&scx_cgroup_ops_rwsem); } void scx_group_set_bandwidth(struct task_group *tg,
@@ -5125,6 +5137,7 @@ static void sched_ext_ops__cgroup_move(sstatic void sched_ext_ops__cgroup_cancel_move (struct task_struct *p,struct cgroup *from,struct cgroup *to) {}static void sched_ext_ops__cgroup_set_weight (struct cgroup *cgrp,u32 weight) {}static void sched_ext_ops__cgroup_set_bandwidth (struct cgroup *cgrp,u64 period_us,u64 quota_us,u64 burst_us) {} +static void sched_ext_ops__cgroup_set_idle (struct cgroup *cgrp,bool idle) {}#endif static void sched_ext_ops__cpu_online (s32 cpu) {}static void sched_ext_ops__cpu_offline (s32 cpu) {}
@@ -5163,6 +5176,7 @@ static struct sched_ext_ops __bpf_ops_sc .cgroup_cancel_move = sched_ext_ops__cgroup_cancel_move, .cgroup_set_weight = sched_ext_ops__cgroup_set_weight, .cgroup_set_bandwidth = sched_ext_ops__cgroup_set_bandwidth, + .cgroup_set_idle = sched_ext_ops__cgroup_set_idle, #endif .cpu_online = sched_ext_ops__cpu_online, .cpu_offline = sched_ext_ops__cpu_offline,
kernel/sched/ext_internal.h +12 -1
@@ -697,12 +697,23 @@ struct sched_ext_ops {* 2_500_000. @cgrp is entitled to 2.5 CPUs. @burst_us can be * interpreted in the same fashion and specifies how much @cgrp can * burst temporarily. The specific control mechanism and thus the -* interpretation of @period_us and burstiness is upto to the BPF +* interpretation of @period_us and burstiness is up to the BPF * scheduler. */ void (*cgroup_set_bandwidth)(struct cgroup *cgrp,u64 period_us,u64 quota_us,u64 burst_us); +/** +* @cgroup_set_idle: A cgroup's idle state is being changed +* @cgrp: cgroup whose idle state is being updated +* @idle: whether the cgroup is entering or exiting idle state +* +* Update @cgrp's idle state to @idle. This callback is invoked when +* a cgroup transitions between idle and non-idle states, allowing the +* BPF scheduler to adjust its behavior accordingly. +*/ +void (*cgroup_set_idle)(struct cgroup *cgrp,bool idle); +#endif /* CONFIG_EXT_GROUP_SCHED */ /*
Greg Kroah-Hartman
maintainerPATCH 170/188 sched_ext: Read scx_root under scx_cgroup_ops_rwsem in cgroup setters
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
[ Upstream commit 80afd4c84bc8f5e80145ce35279f5ce53f6043db ]
scx_group_set_{weight,idle,bandwidth}() cache scx_root before acquiring scx_cgroup_ops_rwsem, so the pointer can be stale by the time the op runs. If the loaded scheduler is disabled and freed (via RCU work) and another is enabled between the naked load and the rwsem acquire, the reader sees scx_cgroup_enabled=true (the new scheduler's) but dereferences the freed one
- UAF on SCX_HAS_OP(sch, ...) / SCX_CALL_OP(sch, ...).
scx_cgroup_enabled is toggled only under scx_cgroup_ops_rwsem write (scx_cgroup_{init,exit}), so reading scx_root inside the rwsem read section correlates @sch with the enabled snapshot.
--- kernel/sched/ext.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/sched/ext.c +6 -3
@@ -3251,9 +3251,10 @@ void scx_cgroup_cancel_attach(struct cgrvoid scx_group_set_weight (struct task_group *tg,unsigned long weight) { -struct scx_sched *sch = scx_root; +struct scx_sched *sch;percpu_down_read (&scx_cgroup_ops_rwsem); + sch = scx_root;if (scx_cgroup_enabled &&SCX_HAS_OP (sch, cgroup_set_weight) && tg->scx.weight != weight)
@@ -3267,9 +3268,10 @@ void scx_group_set_weight(struct task_grvoid scx_group_set_idle (struct task_group *tg,bool idle) { -struct scx_sched *sch = scx_root; +struct scx_sched *sch;percpu_down_read (&scx_cgroup_ops_rwsem); + sch = scx_root;if (scx_cgroup_enabled &&SCX_HAS_OP (sch, cgroup_set_idle)) SCX_CALL_OP(sch, SCX_KF_UNLOCKED, cgroup_set_idle, NULL,
@@ -3284,9 +3286,10 @@ void scx_group_set_idle(struct task_grouvoid scx_group_set_bandwidth (struct task_group *tg,u64 period_us,u64 quota_us,u64 burst_us) { -struct scx_sched *sch = scx_root; +struct scx_sched *sch;percpu_down_read (&scx_cgroup_ops_rwsem); + sch = scx_root; if (scx_cgroup_enabled && SCX_HAS_OP(sch, cgroup_set_bandwidth) && (tg->scx.bw_period_us != period_us ||
Greg Kroah-Hartman
maintainerPATCH 171/188 usb: dwc3: Remove of dep->regs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashanth K <[email protected]>
[ Upstream commit abdd1eef04f0cb3b1707cd1fa243d574d5e07024 ]
Remove dep->regs from struct dwc3_ep and reuse dwc->regs instead. Thus eliminating redundant iomem addresses and making register access more consistent across the driver.
Stable-dep-of: aad35f9c926e ("usb: dwc3: Move GUID programming after PHY initialization")
--- drivers/usb/dwc3/core.h | 10 ++++------ drivers/usb/dwc3/debugfs.c | 12 ++++-------- drivers/usb/dwc3/gadget.c | 12 ++++++------ drivers/usb/dwc3/gadget.h | 2 +- 4 files changed, 15 insertions(+), 21 deletions(-)
drivers/usb/dwc3/core.h +4 -6
@@ -165,10 +165,10 @@#define DWC3_DCFG1 0xc740/* DWC_usb32 only */ #define DWC3_DEP_BASE (n) (0xc800 + ((n) * 0x10)) -#define DWC3_DEPCMDPAR2 0x00 -#define DWC3_DEPCMDPAR1 0x04 -#define DWC3_DEPCMDPAR0 0x08 -#define DWC3_DEPCMD 0x0c +#define DWC3_DEPCMDPAR2 (n) (DWC3_DEP_BASE(n) + 0x00) +#define DWC3_DEPCMDPAR1 (n) (DWC3_DEP_BASE(n) + 0x04) +#define DWC3_DEPCMDPAR0 (n) (DWC3_DEP_BASE(n) + 0x08) +#define DWC3_DEPCMD (n) (DWC3_DEP_BASE(n) + 0x0c)#define DWC3_DEV_IMOD (n) (0xca00 + ((n) * 0x4))
@@ -749,8 +749,6 @@ struct dwc3_ep {struct list_head pending_list;struct list_head started_list; -void __iomem *regs; -struct dwc3_trb *trb_pool;dma_addr_t trb_pool_dma;struct dwc3 *dwc;
drivers/usb/dwc3/debugfs.c +4 -8
@@ -36,23 +36,19 @@#define dump_ep_register_set (n) \ { \ .name = "DEPCMDPAR2("__stringify(n)")", \ - .offset = DWC3_DEP_BASE(n) + \ - DWC3_DEPCMDPAR2, \ + .offset = DWC3_DEPCMDPAR2(n), \ }, \ { \ .name = "DEPCMDPAR1("__stringify(n)")", \ - .offset = DWC3_DEP_BASE(n) + \ - DWC3_DEPCMDPAR1, \ + .offset = DWC3_DEPCMDPAR1(n), \ }, \ { \ .name = "DEPCMDPAR0("__stringify(n)")", \ - .offset = DWC3_DEP_BASE(n) + \ - DWC3_DEPCMDPAR0, \ + .offset = DWC3_DEPCMDPAR0(n), \ }, \ { \ .name = "DEPCMD("__stringify(n)")", \ - .offset = DWC3_DEP_BASE(n) + \ - DWC3_DEPCMD, \ + .offset = DWC3_DEPCMD(n), \ }
drivers/usb/dwc3/gadget.c +6 -6
@@ -320,6 +320,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_int cmd_status =0 ;int ret = -EINVAL ; +u8 epnum = dep->number;/* * When operating in USB 2.0 speeds (HS/FS), if GUSB2PHYCFG.ENBLSLPM or
@@ -355,9 +356,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_* improve performance. */ if (DWC3_DEPCMD_CMD (cmd) !=DWC3_DEPCMD_UPDATETRANSFER ) { -dwc3_writel (dep->regs,DWC3_DEPCMDPAR0 , params->param0); -dwc3_writel (dep->regs,DWC3_DEPCMDPAR1 , params->param1); -dwc3_writel (dep->regs,DWC3_DEPCMDPAR2 , params->param2); +dwc3_writel (dwc->regs,DWC3_DEPCMDPAR0 (epnum), params->param0); +dwc3_writel (dwc->regs,DWC3_DEPCMDPAR1 (epnum), params->param1); +dwc3_writel (dwc->regs,DWC3_DEPCMDPAR2 (epnum), params->param2); }/*
@@ -381,7 +382,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_else cmd |=DWC3_DEPCMD_CMDACT ; -dwc3_writel (dep->regs,DWC3_DEPCMD , cmd); +dwc3_writel (dwc->regs,DWC3_DEPCMD (epnum), cmd); if (!(cmd & DWC3_DEPCMD_CMDACT) || (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_ENDTRANSFER &&
@@ -391,7 +392,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ } do { - reg = dwc3_readl(dep->regs, DWC3_DEPCMD); + reg = dwc3_readl(dwc->regs, DWC3_DEPCMD(epnum)); if (!(reg & DWC3_DEPCMD_CMDACT)) { cmd_status = DWC3_DEPCMD_STATUS(reg);
@@ -3379,7 +3380,6 @@ static int dwc3_gadget_init_endpoint(str dep->dwc = dwc; dep->number = epnum; dep->direction = direction; - dep->regs = dwc->regs +DWC3_DEP_BASE (epnum); dwc->eps[epnum] = dep; dep->combo_num =0 ; dep->start_cmd_status =0 ;
drivers/usb/dwc3/gadget.h +1 -1
@@ -132,7 +132,7 @@ static inline void dwc3_gadget_ep_get_tr {u32 res_id; - res_id =dwc3_readl (dep->regs,DWC3_DEPCMD ); + res_id =dwc3_readl (dep->dwc->regs,DWC3_DEPCMD (dep->number)); dep->resource_index =DWC3_DEPCMD_GET_RSC_IDX (res_id); }
Greg Kroah-Hartman
maintainerPATCH 172/188 usb: dwc3: Add dwc pointer to dwc3_readl/writel
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashanth K <[email protected]>
[ Upstream commit 9accc68b1cf0a2b220f51d53641128bb32598070 ]
Use dwc pointer in dwc3_readl() dwc3_writel() instead of passing the dwc->regs. This would help us access the dwc structure and log the base address in traces. There's no functional changes in this patch, just refactoring existing APIs.
Stable-dep-of: aad35f9c926e ("usb: dwc3: Move GUID programming after PHY initialization")
--- drivers/usb/dwc3/core.c | 194 ++++++++++++++++++++++----------------------- drivers/usb/dwc3/debugfs.c | 32 +++---- drivers/usb/dwc3/drd.c | 76 ++++++++--------- drivers/usb/dwc3/ep0.c | 20 ++-- drivers/usb/dwc3/gadget.c | 160 ++++++++++++++++++------------------- drivers/usb/dwc3/gadget.h | 4 drivers/usb/dwc3/io.h | 7 + drivers/usb/dwc3/ulpi.c | 10 +- 8 files changed, 253 insertions(+), 250 deletions(-)
drivers/usb/dwc3/core.c +97 -97
@@ -114,23 +114,23 @@ void dwc3_enable_susphy(struct dwc3 *dwcint i;for (i =0 ; i < dwc->num_usb3_ports; i++) { - reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (i)); + reg =dwc3_readl (dwc,DWC3_GUSB3PIPECTL (i));if (enable && !dwc->dis_u3_susphy_quirk) reg |=DWC3_GUSB3PIPECTL_SUSPHY ;else reg &= ~DWC3_GUSB3PIPECTL_SUSPHY ; -dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (i), reg); +dwc3_writel (dwc,DWC3_GUSB3PIPECTL (i), reg); }for (i =0 ; i < dwc->num_usb2_ports; i++) { - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (i)); + reg =dwc3_readl (dwc,DWC3_GUSB2PHYCFG (i));if (enable && !dwc->dis_u2_susphy_quirk) reg |=DWC3_GUSB2PHYCFG_SUSPHY ;else reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (i), reg); +dwc3_writel (dwc,DWC3_GUSB2PHYCFG (i), reg); } }
@@ -139,7 +139,7 @@ void dwc3_set_prtcap(struct dwc3 *dwc, uunsigned int hw_mode;u32 reg; - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + reg =dwc3_readl (dwc,DWC3_GCTL );/* * For DRD controllers, GUSB3PIPECTL.SUSPENDENABLE and
@@ -154,7 +154,7 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u reg &= ~(DWC3_GCTL_PRTCAPDIR (DWC3_GCTL_PRTCAP_OTG )); reg |=DWC3_GCTL_PRTCAPDIR (mode); -dwc3_writel (dwc->regs,DWC3_GCTL , reg); +dwc3_writel (dwc,DWC3_GCTL , reg); dwc->current_dr_role = mode;trace_dwc3_set_prtcap (mode);
@@ -214,9 +214,9 @@ static void __dwc3_set_mode(struct work_if (dwc->current_dr_role && ((DWC3_IP_IS (DWC3 ) || DWC3_VER_IS_PRIOR(DWC31, 190A)) && desired_dr_role !=DWC3_GCTL_PRTCAP_OTG )) { - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + reg =dwc3_readl (dwc,DWC3_GCTL ); reg |=DWC3_GCTL_CORESOFTRESET ; -dwc3_writel (dwc->regs,DWC3_GCTL , reg); +dwc3_writel (dwc,DWC3_GCTL , reg);/* * Wait for internal clocks to synchronized. DWC_usb31 and
@@ -226,9 +226,9 @@ static void __dwc3_set_mode(struct work_*/ msleep (100 ); - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + reg =dwc3_readl (dwc,DWC3_GCTL ); reg &= ~DWC3_GCTL_CORESOFTRESET ; -dwc3_writel (dwc->regs,DWC3_GCTL , reg); +dwc3_writel (dwc,DWC3_GCTL , reg); }spin_lock_irqsave (&dwc->lock, flags);
@@ -252,9 +252,9 @@ static void __dwc3_set_mode(struct work_phy_set_mode (dwc->usb3_generic_phy[i],PHY_MODE_USB_HOST );if (dwc->dis_split_quirk) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL3 ); + reg =dwc3_readl (dwc,DWC3_GUCTL3 ); reg |=DWC3_GUCTL3_SPLITDISABLE ; -dwc3_writel (dwc->regs,DWC3_GUCTL3 , reg); +dwc3_writel (dwc,DWC3_GUCTL3 , reg); } }break ;
@@ -305,11 +305,11 @@ u32 dwc3_core_fifo_space(struct dwc3_epstruct dwc3 *dwc = dep->dwc;u32 reg; -dwc3_writel (dwc->regs,DWC3_GDBGFIFOSPACE , -DWC3_GDBGFIFOSPACE_NUM (dep->number) | -DWC3_GDBGFIFOSPACE_TYPE (type)); +dwc3_writel (dwc,DWC3_GDBGFIFOSPACE , +DWC3_GDBGFIFOSPACE_NUM (dep->number) | +DWC3_GDBGFIFOSPACE_TYPE (type)); - reg =dwc3_readl (dwc->regs,DWC3_GDBGFIFOSPACE ); + reg =dwc3_readl (dwc,DWC3_GDBGFIFOSPACE );return DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE (reg); }
@@ -331,7 +331,7 @@ int dwc3_core_soft_reset(struct dwc3 *dwif (dwc->current_dr_role ==DWC3_GCTL_PRTCAP_HOST )return 0 ; - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg =dwc3_readl (dwc,DWC3_DCTL ); reg |=DWC3_DCTL_CSFTRST ; reg &= ~DWC3_DCTL_RUN_STOP ;dwc3_gadget_dctl_write_safe (dwc, reg);
@@ -346,7 +346,7 @@ int dwc3_core_soft_reset(struct dwc3 *dw retries =10 ; do { - reg = dwc3_readl(dwc->regs, DWC3_DCTL); + reg = dwc3_readl(dwc, DWC3_DCTL); if (!(reg & DWC3_DCTL_CSFTRST)) goto done;
@@ -386,12 +386,12 @@ static void dwc3_frame_length_adjustmentif (dwc->fladj ==0 )return ; - reg =dwc3_readl (dwc->regs,DWC3_GFLADJ ); + reg =dwc3_readl (dwc,DWC3_GFLADJ ); dft = reg &DWC3_GFLADJ_30MHZ_MASK ;if (dft != dwc->fladj) { reg &= ~DWC3_GFLADJ_30MHZ_MASK ; reg |=DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj; -dwc3_writel (dwc->regs,DWC3_GFLADJ , reg); +dwc3_writel (dwc,DWC3_GFLADJ , reg); } }
@@ -423,10 +423,10 @@ static void dwc3_ref_clk_period(struct dreturn ; } - reg =dwc3_readl (dwc->regs,DWC3_GUCTL ); + reg =dwc3_readl (dwc,DWC3_GUCTL ); reg &= ~DWC3_GUCTL_REFCLKPER_MASK ; reg |=FIELD_PREP (DWC3_GUCTL_REFCLKPER_MASK , period); -dwc3_writel (dwc->regs,DWC3_GUCTL , reg); +dwc3_writel (dwc,DWC3_GUCTL , reg); if (DWC3_VER_IS_PRIOR(DWC3, 250A))return ;
@@ -454,7 +454,7 @@ static void dwc3_ref_clk_period(struct d*/ decr =480000000 / rate; - reg =dwc3_readl (dwc->regs,DWC3_GFLADJ ); + reg =dwc3_readl (dwc,DWC3_GFLADJ ); reg &= ~DWC3_GFLADJ_REFCLK_FLADJ_MASK & ~DWC3_GFLADJ_240MHZDECR & ~DWC3_GFLADJ_240MHZDECR_PLS1 ;
@@ -465,7 +465,7 @@ static void dwc3_ref_clk_period(struct dif (dwc->gfladj_refclk_lpm_sel) reg |=DWC3_GFLADJ_REFCLK_LPM_SEL ; -dwc3_writel (dwc->regs,DWC3_GFLADJ , reg); +dwc3_writel (dwc,DWC3_GFLADJ , reg); }/**
@@ -568,16 +568,16 @@ int dwc3_event_buffers_setup(struct dwc3 evt = dwc->ev_buf; evt->lpos =0 ; -dwc3_writel (dwc->regs,DWC3_GEVNTADRLO (0 ), -lower_32_bits (evt->dma)); -dwc3_writel (dwc->regs,DWC3_GEVNTADRHI (0 ), -upper_32_bits (evt->dma)); -dwc3_writel (dwc->regs,DWC3_GEVNTSIZ (0 ), -DWC3_GEVNTSIZ_SIZE (evt->length)); +dwc3_writel (dwc,DWC3_GEVNTADRLO (0 ), +lower_32_bits (evt->dma)); +dwc3_writel (dwc,DWC3_GEVNTADRHI (0 ), +upper_32_bits (evt->dma)); +dwc3_writel (dwc,DWC3_GEVNTSIZ (0 ), +DWC3_GEVNTSIZ_SIZE (evt->length));/* Clear any stale event */ - reg =dwc3_readl (dwc->regs,DWC3_GEVNTCOUNT (0 )); -dwc3_writel (dwc->regs,DWC3_GEVNTCOUNT (0 ), reg); + reg =dwc3_readl (dwc,DWC3_GEVNTCOUNT (0 )); +dwc3_writel (dwc,DWC3_GEVNTCOUNT (0 ), reg);return 0 ; }
@@ -592,7 +592,7 @@ void dwc3_event_buffers_cleanup(struct d* Exynos platforms may not be able to access event buffer if the * controller failed to halt on dwc3_core_exit(). */ - reg =dwc3_readl (dwc->regs,DWC3_DSTS ); + reg =dwc3_readl (dwc,DWC3_DSTS );if (!(reg &DWC3_DSTS_DEVCTRLHLT ))return ;
@@ -600,14 +600,14 @@ void dwc3_event_buffers_cleanup(struct d evt->lpos =0 ; -dwc3_writel (dwc->regs,DWC3_GEVNTADRLO (0 ),0 ); -dwc3_writel (dwc->regs,DWC3_GEVNTADRHI (0 ),0 ); -dwc3_writel (dwc->regs,DWC3_GEVNTSIZ (0 ),DWC3_GEVNTSIZ_INTMASK +dwc3_writel (dwc,DWC3_GEVNTADRLO (0 ),0 ); +dwc3_writel (dwc,DWC3_GEVNTADRHI (0 ),0 ); +dwc3_writel (dwc,DWC3_GEVNTSIZ (0 ),DWC3_GEVNTSIZ_INTMASK |DWC3_GEVNTSIZ_SIZE (0 ));/* Clear any stale event */ - reg =dwc3_readl (dwc->regs,DWC3_GEVNTCOUNT (0 )); -dwc3_writel (dwc->regs,DWC3_GEVNTCOUNT (0 ), reg); + reg =dwc3_readl (dwc,DWC3_GEVNTCOUNT (0 )); +dwc3_writel (dwc,DWC3_GEVNTCOUNT (0 ), reg); }static void dwc3_core_num_eps (struct dwc3 *dwc)
@@ -621,18 +621,18 @@ static void dwc3_cache_hwparams(struct d {struct dwc3_hwparams *parms = &dwc->hwparams; - parms->hwparams0 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS0 ); - parms->hwparams1 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS1 ); - parms->hwparams2 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS2 ); - parms->hwparams3 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS3 ); - parms->hwparams4 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS4 ); - parms->hwparams5 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS5 ); - parms->hwparams6 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS6 ); - parms->hwparams7 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS7 ); - parms->hwparams8 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS8 ); + parms->hwparams0 =dwc3_readl (dwc,DWC3_GHWPARAMS0 ); + parms->hwparams1 =dwc3_readl (dwc,DWC3_GHWPARAMS1 ); + parms->hwparams2 =dwc3_readl (dwc,DWC3_GHWPARAMS2 ); + parms->hwparams3 =dwc3_readl (dwc,DWC3_GHWPARAMS3 ); + parms->hwparams4 =dwc3_readl (dwc,DWC3_GHWPARAMS4 ); + parms->hwparams5 =dwc3_readl (dwc,DWC3_GHWPARAMS5 ); + parms->hwparams6 =dwc3_readl (dwc,DWC3_GHWPARAMS6 ); + parms->hwparams7 =dwc3_readl (dwc,DWC3_GHWPARAMS7 ); + parms->hwparams8 =dwc3_readl (dwc,DWC3_GHWPARAMS8 );if (DWC3_IP_IS (DWC32 )) - parms->hwparams9 =dwc3_readl (dwc->regs,DWC3_GHWPARAMS9 ); + parms->hwparams9 =dwc3_readl (dwc,DWC3_GHWPARAMS9 ); }static void dwc3_config_soc_bus (struct dwc3 *dwc)
@@ -640,10 +640,10 @@ static void dwc3_config_soc_bus(struct dif (dwc->gsbuscfg0_reqinfo !=DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED ) {u32 reg; - reg =dwc3_readl (dwc->regs,DWC3_GSBUSCFG0 ); + reg =dwc3_readl (dwc,DWC3_GSBUSCFG0 ); reg &= ~DWC3_GSBUSCFG0_REQINFO (~0 ); reg |=DWC3_GSBUSCFG0_REQINFO (dwc->gsbuscfg0_reqinfo); -dwc3_writel (dwc->regs,DWC3_GSBUSCFG0 , reg); +dwc3_writel (dwc,DWC3_GSBUSCFG0 , reg); } }
@@ -667,7 +667,7 @@ static int dwc3_ss_phy_setup(struct dwc3 {u32 reg; - reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (index)); + reg =dwc3_readl (dwc,DWC3_GUSB3PIPECTL (index));/* * Make sure UX_EXIT_PX is cleared as that causes issues with some
@@ -705,7 +705,7 @@ static int dwc3_ss_phy_setup(struct dwc3if (dwc->dis_del_phy_power_chg_quirk) reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE ; -dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (index), reg); +dwc3_writel (dwc,DWC3_GUSB3PIPECTL (index), reg);return 0 ; }
@@ -714,7 +714,7 @@ static int dwc3_hs_phy_setup(struct dwc3 {u32 reg; - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (index)); + reg =dwc3_readl (dwc,DWC3_GUSB2PHYCFG (index));/* Select the HS PHY interface */ switch (DWC3_GHWPARAMS3_HSPHY_IFC (dwc->hwparams.hwparams3)) {
@@ -726,7 +726,7 @@ static int dwc3_hs_phy_setup(struct dwc3 }else if (dwc->hsphy_interface && !strncmp (dwc->hsphy_interface,"ulpi" ,4 )) { reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (index), reg); +dwc3_writel (dwc,DWC3_GUSB2PHYCFG (index), reg); }else {/* Relying on default value. */ if (!(reg &DWC3_GUSB2PHYCFG_ULPI_UTMI ))
@@ -776,7 +776,7 @@ static int dwc3_hs_phy_setup(struct dwc3if (dwc->ulpi_ext_vbus_drv) reg |=DWC3_GUSB2PHYCFG_ULPIEXTVBUSDRV ; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (index), reg); +dwc3_writel (dwc,DWC3_GUSB2PHYCFG (index), reg);return 0 ; }
@@ -989,7 +989,7 @@ static bool dwc3_core_is_valid(struct dw {u32 reg; - reg =dwc3_readl (dwc->regs,DWC3_GSNPSID ); + reg =dwc3_readl (dwc,DWC3_GSNPSID ); dwc->ip =DWC3_GSNPS_ID (reg);if (dwc->ip ==DWC4_IP ) dwc->ip =DWC32_IP ;
@@ -998,8 +998,8 @@ static bool dwc3_core_is_valid(struct dwif (DWC3_IP_IS (DWC3 )) { dwc->revision = reg; }else if (DWC3_IP_IS (DWC31 ) ||DWC3_IP_IS (DWC32 )) { - dwc->revision =dwc3_readl (dwc->regs,DWC3_VER_NUMBER ); - dwc->version_type =dwc3_readl (dwc->regs,DWC3_VER_TYPE ); + dwc->revision =dwc3_readl (dwc,DWC3_VER_NUMBER ); + dwc->version_type =dwc3_readl (dwc,DWC3_VER_TYPE ); }else {return false; }
@@ -1013,7 +1013,7 @@ static void dwc3_core_setup_global_contrunsigned int hw_mode;u32 reg; - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + reg =dwc3_readl (dwc,DWC3_GCTL ); reg &= ~DWC3_GCTL_SCALEDOWN_MASK ; hw_mode =DWC3_GHWPARAMS0_MODE (dwc->hwparams.hwparams0); power_opt =DWC3_GHWPARAMS1_EN_PWROPT (dwc->hwparams.hwparams1);
@@ -1091,7 +1091,7 @@ static void dwc3_core_setup_global_contr if (DWC3_VER_IS_PRIOR(DWC3, 190A)) reg |=DWC3_GCTL_U2RSTECN ; -dwc3_writel (dwc->regs,DWC3_GCTL , reg); +dwc3_writel (dwc,DWC3_GCTL , reg); }static int dwc3_core_get_phy (struct dwc3 *dwc);
@@ -1111,7 +1111,7 @@ static void dwc3_set_incr_burst_type(strint ret;int i; - cfg =dwc3_readl (dwc->regs,DWC3_GSBUSCFG0 ); + cfg =dwc3_readl (dwc,DWC3_GSBUSCFG0 );/* * Handle property "snps,incr-burst-type-adjustment".
@@ -1186,7 +1186,7 @@ static void dwc3_set_incr_burst_type(strbreak ; } -dwc3_writel (dwc->regs,DWC3_GSBUSCFG0 , cfg); +dwc3_writel (dwc,DWC3_GSBUSCFG0 , cfg); }static void dwc3_set_power_down_clk_scale (struct dwc3 *dwc)
@@ -1211,12 +1211,12 @@ static void dwc3_set_power_down_clk_scal* (3x or more) to be within the requirement. */ scale =DIV_ROUND_UP (clk_get_rate (dwc->susp_clk),16000 ); - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + reg =dwc3_readl (dwc,DWC3_GCTL );if ((reg &DWC3_GCTL_PWRDNSCALE_MASK ) <DWC3_GCTL_PWRDNSCALE (scale) || (reg &DWC3_GCTL_PWRDNSCALE_MASK ) >DWC3_GCTL_PWRDNSCALE (scale*3 )) { reg &= ~(DWC3_GCTL_PWRDNSCALE_MASK ); reg |=DWC3_GCTL_PWRDNSCALE (scale); -dwc3_writel (dwc->regs,DWC3_GCTL , reg); +dwc3_writel (dwc,DWC3_GCTL , reg); } }
@@ -1239,7 +1239,7 @@ static void dwc3_config_threshold(struct tx_maxburst = dwc->tx_max_burst_prd;if (rx_thr_num && rx_maxburst) { - reg =dwc3_readl (dwc->regs,DWC3_GRXTHRCFG ); + reg =dwc3_readl (dwc,DWC3_GRXTHRCFG ); reg |=DWC31_RXTHRNUMPKTSEL_PRD ; reg &= ~DWC31_RXTHRNUMPKT_PRD (~0 );
@@ -1248,11 +1248,11 @@ static void dwc3_config_threshold(struct reg &= ~DWC31_MAXRXBURSTSIZE_PRD (~0 ); reg |=DWC31_MAXRXBURSTSIZE_PRD (rx_maxburst); -dwc3_writel (dwc->regs,DWC3_GRXTHRCFG , reg); +dwc3_writel (dwc,DWC3_GRXTHRCFG , reg); }if (tx_thr_num && tx_maxburst) { - reg =dwc3_readl (dwc->regs,DWC3_GTXTHRCFG ); + reg =dwc3_readl (dwc,DWC3_GTXTHRCFG ); reg |=DWC31_TXTHRNUMPKTSEL_PRD ; reg &= ~DWC31_TXTHRNUMPKT_PRD (~0 );
@@ -1261,7 +1261,7 @@ static void dwc3_config_threshold(struct reg &= ~DWC31_MAXTXBURSTSIZE_PRD (~0 ); reg |=DWC31_MAXTXBURSTSIZE_PRD (tx_maxburst); -dwc3_writel (dwc->regs,DWC3_GTXTHRCFG , reg); +dwc3_writel (dwc,DWC3_GTXTHRCFG , reg); } }
@@ -1272,7 +1272,7 @@ static void dwc3_config_threshold(structif (DWC3_IP_IS (DWC3 )) {if (rx_thr_num && rx_maxburst) { - reg =dwc3_readl (dwc->regs,DWC3_GRXTHRCFG ); + reg =dwc3_readl (dwc,DWC3_GRXTHRCFG ); reg |=DWC3_GRXTHRCFG_PKTCNTSEL ; reg &= ~DWC3_GRXTHRCFG_RXPKTCNT (~0 );
@@ -1281,11 +1281,11 @@ static void dwc3_config_threshold(struct reg &= ~DWC3_GRXTHRCFG_MAXRXBURSTSIZE (~0 ); reg |=DWC3_GRXTHRCFG_MAXRXBURSTSIZE (rx_maxburst); -dwc3_writel (dwc->regs,DWC3_GRXTHRCFG , reg); +dwc3_writel (dwc,DWC3_GRXTHRCFG , reg); }if (tx_thr_num && tx_maxburst) { - reg =dwc3_readl (dwc->regs,DWC3_GTXTHRCFG ); + reg =dwc3_readl (dwc,DWC3_GTXTHRCFG ); reg |=DWC3_GTXTHRCFG_PKTCNTSEL ; reg &= ~DWC3_GTXTHRCFG_TXPKTCNT (~0 );
@@ -1294,11 +1294,11 @@ static void dwc3_config_threshold(struct reg &= ~DWC3_GTXTHRCFG_MAXTXBURSTSIZE (~0 ); reg |=DWC3_GTXTHRCFG_MAXTXBURSTSIZE (tx_maxburst); -dwc3_writel (dwc->regs,DWC3_GTXTHRCFG , reg); +dwc3_writel (dwc,DWC3_GTXTHRCFG , reg); } }else {if (rx_thr_num && rx_maxburst) { - reg =dwc3_readl (dwc->regs,DWC3_GRXTHRCFG ); + reg =dwc3_readl (dwc,DWC3_GRXTHRCFG ); reg |=DWC31_GRXTHRCFG_PKTCNTSEL ; reg &= ~DWC31_GRXTHRCFG_RXPKTCNT (~0 );
@@ -1307,11 +1307,11 @@ static void dwc3_config_threshold(struct reg &= ~DWC31_GRXTHRCFG_MAXRXBURSTSIZE (~0 ); reg |=DWC31_GRXTHRCFG_MAXRXBURSTSIZE (rx_maxburst); -dwc3_writel (dwc->regs,DWC3_GRXTHRCFG , reg); +dwc3_writel (dwc,DWC3_GRXTHRCFG , reg); }if (tx_thr_num && tx_maxburst) { - reg =dwc3_readl (dwc->regs,DWC3_GTXTHRCFG ); + reg =dwc3_readl (dwc,DWC3_GTXTHRCFG ); reg |=DWC31_GTXTHRCFG_PKTCNTSEL ; reg &= ~DWC31_GTXTHRCFG_TXPKTCNT (~0 );
@@ -1320,7 +1320,7 @@ static void dwc3_config_threshold(struct reg &= ~DWC31_GTXTHRCFG_MAXTXBURSTSIZE (~0 ); reg |=DWC31_GTXTHRCFG_MAXTXBURSTSIZE (tx_maxburst); -dwc3_writel (dwc->regs,DWC3_GTXTHRCFG , reg); +dwc3_writel (dwc,DWC3_GTXTHRCFG , reg); } } }
@@ -1343,7 +1343,7 @@ static int dwc3_core_init(struct dwc3 *d* Write Linux Version Code to our GUID register so it's easy to figure * out which kernel version a bug was found. */ -dwc3_writel (dwc->regs,DWC3_GUID ,LINUX_VERSION_CODE ); +dwc3_writel (dwc,DWC3_GUID ,LINUX_VERSION_CODE ); ret =dwc3_phy_setup (dwc);if (ret)
@@ -1408,9 +1408,9 @@ static int dwc3_core_init(struct dwc3 *d* DWC_usb31 controller. */ if (DWC3_VER_IS_WITHIN(DWC3, 310A, ANY)) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL2 ); + reg =dwc3_readl (dwc,DWC3_GUCTL2 ); reg |=DWC3_GUCTL2_RST_ACTBITLATER ; -dwc3_writel (dwc->regs,DWC3_GUCTL2 , reg); +dwc3_writel (dwc,DWC3_GUCTL2 , reg); }/*
@@ -1423,9 +1423,9 @@ static int dwc3_core_init(struct dwc3 *d* setting GUCTL2[19] by default; instead, use GUCTL2[19] = 0. */ if (DWC3_VER_IS(DWC3, 320A)) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL2 ); + reg =dwc3_readl (dwc,DWC3_GUCTL2 ); reg &= ~DWC3_GUCTL2_LC_TIMER ; -dwc3_writel (dwc->regs,DWC3_GUCTL2 , reg); +dwc3_writel (dwc,DWC3_GUCTL2 , reg); }/*
@@ -1438,13 +1438,13 @@ static int dwc3_core_init(struct dwc3 *d* legacy ULPI PHYs. */ if (dwc->resume_hs_terminations) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL1 ); + reg =dwc3_readl (dwc,DWC3_GUCTL1 ); reg |=DWC3_GUCTL1_RESUME_OPMODE_HS_HOST ; -dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); +dwc3_writel (dwc,DWC3_GUCTL1 , reg); } if (!DWC3_VER_IS_PRIOR(DWC3, 250A)) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL1 ); + reg =dwc3_readl (dwc,DWC3_GUCTL1 );/* * Enable hardware control of sending remote wakeup
@@ -1479,7 +1479,7 @@ static int dwc3_core_init(struct dwc3 *d reg &= ~DWC3_GUCTL1_DEV_FORCE_20_CLK_FOR_30_CLK ; } -dwc3_writel (dwc->regs,DWC3_GUCTL1 , reg); +dwc3_writel (dwc,DWC3_GUCTL1 , reg); }dwc3_config_threshold (dwc);
@@ -1494,9 +1494,9 @@ static int dwc3_core_init(struct dwc3 *dint i;for (i =0 ; i < dwc->num_usb3_ports; i++) { - reg =dwc3_readl (dwc->regs,DWC3_LLUCTL (i)); + reg =dwc3_readl (dwc,DWC3_LLUCTL (i)); reg |=DWC3_LLUCTL_FORCE_GEN1 ; -dwc3_writel (dwc->regs,DWC3_LLUCTL (i), reg); +dwc3_writel (dwc,DWC3_LLUCTL (i), reg); } }
@@ -1515,9 +1515,9 @@ static int dwc3_core_init(struct dwc3 *d* function is available only from version 1.70a. */ if (DWC3_VER_IS_WITHIN(DWC31, 170A, 180A)) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL3 ); + reg =dwc3_readl (dwc,DWC3_GUCTL3 ); reg |=DWC3_GUCTL3_USB20_RETRY_DISABLE ; -dwc3_writel (dwc->regs,DWC3_GUCTL3 , reg); +dwc3_writel (dwc,DWC3_GUCTL3 , reg); }return 0 ;
@@ -2447,9 +2447,9 @@ static int dwc3_suspend_common(struct dwint ret;if (!pm_runtime_suspended (dwc->dev) && !PMSG_IS_AUTO (msg)) { - dwc->susphy_state = (dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )) & + dwc->susphy_state = (dwc3_readl (dwc,DWC3_GUSB2PHYCFG (0 )) &DWC3_GUSB2PHYCFG_SUSPHY ) || - (dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 )) & + (dwc3_readl (dwc,DWC3_GUSB3PIPECTL (0 )) &DWC3_GUSB3PIPECTL_SUSPHY );/* * TI AM62 platform requires SUSPHY to be
@@ -2479,10 +2479,10 @@ static int dwc3_suspend_common(struct dwif (dwc->dis_u2_susphy_quirk || dwc->dis_enblslpm_quirk) {for (i =0 ; i < dwc->num_usb2_ports; i++) { - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (i)); + reg =dwc3_readl (dwc,DWC3_GUSB2PHYCFG (i)); reg |=DWC3_GUSB2PHYCFG_ENBLSLPM |DWC3_GUSB2PHYCFG_SUSPHY ; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (i), reg); +dwc3_writel (dwc,DWC3_GUSB2PHYCFG (i), reg); }/* Give some time for USB2 PHY to suspend */
@@ -2542,14 +2542,14 @@ static int dwc3_resume_common(struct dwc }/* Restore GUSB2PHYCFG bits that were modified in suspend */ for (i =0 ; i < dwc->num_usb2_ports; i++) { - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (i)); + reg =dwc3_readl (dwc,DWC3_GUSB2PHYCFG (i));if (dwc->dis_u2_susphy_quirk) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ;if (dwc->dis_enblslpm_quirk) reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM ; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (i), reg); +dwc3_writel (dwc,DWC3_GUSB2PHYCFG (i), reg); }for (i =0 ; i < dwc->num_usb2_ports; i++)
@@ -2732,9 +2732,9 @@ void dwc3_pm_complete(struct dwc3 *dwc)if (dwc->current_dr_role ==DWC3_GCTL_PRTCAP_HOST && dwc->dis_split_quirk) { - reg =dwc3_readl (dwc->regs,DWC3_GUCTL3 ); + reg =dwc3_readl (dwc,DWC3_GUCTL3 ); reg |=DWC3_GUCTL3_SPLITDISABLE ; -dwc3_writel (dwc->regs,DWC3_GUCTL3 , reg); +dwc3_writel (dwc,DWC3_GUCTL3 , reg); } }EXPORT_SYMBOL_GPL (dwc3_pm_complete);
drivers/usb/dwc3/debugfs.c +16 -16
@@ -296,14 +296,14 @@ static void dwc3_host_lsp(struct seq_fil reg =DWC3_GDBGLSPMUX_HOSTSELECT (sel); -dwc3_writel (dwc->regs,DWC3_GDBGLSPMUX , reg); - val =dwc3_readl (dwc->regs,DWC3_GDBGLSP ); +dwc3_writel (dwc,DWC3_GDBGLSPMUX , reg); + val =dwc3_readl (dwc,DWC3_GDBGLSP );seq_printf (s,"GDBGLSP[%d] = 0x%08x\n" , sel, val);if (dbc_enabled && sel <256 ) { reg |=DWC3_GDBGLSPMUX_ENDBC ; -dwc3_writel (dwc->regs,DWC3_GDBGLSPMUX , reg); - val =dwc3_readl (dwc->regs,DWC3_GDBGLSP ); +dwc3_writel (dwc,DWC3_GDBGLSPMUX , reg); + val =dwc3_readl (dwc,DWC3_GDBGLSP );seq_printf (s,"GDBGLSP_DBC[%d] = 0x%08x\n" , sel, val); } }
@@ -316,8 +316,8 @@ static void dwc3_gadget_lsp(struct seq_ffor (i =0 ; i <16 ; i++) { reg =DWC3_GDBGLSPMUX_DEVSELECT (i); -dwc3_writel (dwc->regs,DWC3_GDBGLSPMUX , reg); - reg =dwc3_readl (dwc->regs,DWC3_GDBGLSP ); +dwc3_writel (dwc,DWC3_GDBGLSPMUX , reg); + reg =dwc3_readl (dwc,DWC3_GDBGLSP );seq_printf (s,"GDBGLSP[%d] = 0x%08x\n" , i, reg); } }
@@ -335,7 +335,7 @@ static int dwc3_lsp_show(struct seq_filereturn ret;spin_lock_irqsave (&dwc->lock, flags); - reg =dwc3_readl (dwc->regs,DWC3_GSTS ); + reg =dwc3_readl (dwc,DWC3_GSTS ); current_mode =DWC3_GSTS_CURMOD (reg);switch (current_mode) {
@@ -406,7 +406,7 @@ static int dwc3_mode_show(struct seq_filreturn ret;spin_lock_irqsave (&dwc->lock, flags); - reg =dwc3_readl (dwc->regs,DWC3_GCTL ); + reg =dwc3_readl (dwc,DWC3_GCTL );spin_unlock_irqrestore (&dwc->lock, flags); mode =DWC3_GCTL_PRTCAP (reg);
@@ -478,7 +478,7 @@ static int dwc3_testmode_show(struct seqreturn ret;spin_lock_irqsave (&dwc->lock, flags); - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg =dwc3_readl (dwc,DWC3_DCTL ); reg &=DWC3_DCTL_TSTCTRL_MASK ; reg >>=1 ;spin_unlock_irqrestore (&dwc->lock, flags);
@@ -577,7 +577,7 @@ static int dwc3_link_state_show(struct sreturn ret;spin_lock_irqsave (&dwc->lock, flags); - reg =dwc3_readl (dwc->regs,DWC3_GSTS ); + reg =dwc3_readl (dwc,DWC3_GSTS );if (DWC3_GSTS_CURMOD (reg) !=DWC3_GSTS_CURMOD_DEVICE ) {seq_puts (s,"Not available\n" );spin_unlock_irqrestore (&dwc->lock, flags);
@@ -585,7 +585,7 @@ static int dwc3_link_state_show(struct sreturn 0 ; } - reg =dwc3_readl (dwc->regs,DWC3_DSTS ); + reg =dwc3_readl (dwc,DWC3_DSTS ); state =DWC3_DSTS_USBLNKST (reg); speed = reg &DWC3_DSTS_CONNECTSPD ;
@@ -639,14 +639,14 @@ static ssize_t dwc3_link_state_write(strreturn ret;spin_lock_irqsave (&dwc->lock, flags); - reg =dwc3_readl (dwc->regs,DWC3_GSTS ); + reg =dwc3_readl (dwc,DWC3_GSTS );if (DWC3_GSTS_CURMOD (reg) !=DWC3_GSTS_CURMOD_DEVICE ) {spin_unlock_irqrestore (&dwc->lock, flags);pm_runtime_put_sync (dwc->dev);return -EINVAL ; } - reg =dwc3_readl (dwc->regs,DWC3_DSTS ); + reg =dwc3_readl (dwc,DWC3_DSTS ); speed = reg &DWC3_DSTS_CONNECTSPD ; if (speed < DWC3_DSTS_SUPERSPEED &&
@@ -942,10 +942,10 @@ static int dwc3_ep_info_register_show(stspin_lock_irqsave (&dwc->lock, flags); reg =DWC3_GDBGLSPMUX_EPSELECT (dep->number); -dwc3_writel (dwc->regs,DWC3_GDBGLSPMUX , reg); +dwc3_writel (dwc,DWC3_GDBGLSPMUX , reg); - lower_32_bits =dwc3_readl (dwc->regs,DWC3_GDBGEPINFO0 ); - upper_32_bits =dwc3_readl (dwc->regs,DWC3_GDBGEPINFO1 ); + lower_32_bits =dwc3_readl (dwc,DWC3_GDBGEPINFO0 ); + upper_32_bits =dwc3_readl (dwc,DWC3_GDBGEPINFO1 ); ep_info = ((u64 )upper_32_bits <<32 ) | lower_32_bits;seq_printf (s,"0x%016llx\n" , ep_info);
drivers/usb/dwc3/drd.c +38 -38
209 lines not on this page · raw message
drivers/usb/dwc3/ep0.c +10 -10
@@ -361,7 +361,7 @@ static int dwc3_ep0_handle_status(structif ((dwc->speed ==DWC3_DSTS_SUPERSPEED ) || (dwc->speed ==DWC3_DSTS_SUPERSPEED_PLUS )) { - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg =dwc3_readl (dwc,DWC3_DCTL );if (reg &DWC3_DCTL_INITU1ENA ) usb_status |=1 <<USB_DEV_STAT_U1_ENABLED ;if (reg &DWC3_DCTL_INITU2ENA )
@@ -417,12 +417,12 @@ static int dwc3_ep0_handle_u1(struct dwcif (set && dwc->dis_u1_entry_quirk)return -EINVAL ; - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg =dwc3_readl (dwc,DWC3_DCTL );if (set) reg |=DWC3_DCTL_INITU1ENA ;else reg &= ~DWC3_DCTL_INITU1ENA ; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_writel (dwc,DWC3_DCTL , reg);return 0 ; }
@@ -441,12 +441,12 @@ static int dwc3_ep0_handle_u2(struct dwcif (set && dwc->dis_u2_entry_quirk)return -EINVAL ; - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg =dwc3_readl (dwc,DWC3_DCTL );if (set) reg |=DWC3_DCTL_INITU2ENA ;else reg &= ~DWC3_DCTL_INITU2ENA ; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_writel (dwc,DWC3_DCTL , reg);return 0 ; }
@@ -612,10 +612,10 @@ static int dwc3_ep0_set_address(struct dreturn -EINVAL ; } - reg =dwc3_readl (dwc->regs,DWC3_DCFG ); + reg =dwc3_readl (dwc,DWC3_DCFG ); reg &= ~(DWC3_DCFG_DEVADDR_MASK ); reg |=DWC3_DCFG_DEVADDR (addr); -dwc3_writel (dwc->regs,DWC3_DCFG , reg); +dwc3_writel (dwc,DWC3_DCFG , reg);if (addr)usb_gadget_set_state (dwc->gadget,USB_STATE_ADDRESS );
@@ -672,12 +672,12 @@ static int dwc3_ep0_set_config(struct dw* Enable transition to U1/U2 state when * nothing is pending from application. */ - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg =dwc3_readl (dwc,DWC3_DCTL );if (!dwc->dis_u1_entry_quirk) reg |=DWC3_DCTL_ACCEPTU1ENA ;if (!dwc->dis_u2_entry_quirk) reg |=DWC3_DCTL_ACCEPTU2ENA ; -dwc3_writel (dwc->regs,DWC3_DCTL , reg); +dwc3_writel (dwc,DWC3_DCTL , reg); }break ;
@@ -717,7 +717,7 @@ static void dwc3_ep0_set_sel_cmpl(struct dwc->u2sel =le16_to_cpu (timing.u2sel); dwc->u2pel =le16_to_cpu (timing.u2pel); - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); + reg =dwc3_readl (dwc,DWC3_DCTL );if (reg &DWC3_DCTL_INITU2ENA ) param = dwc->u2pel;if (reg &DWC3_DCTL_INITU1ENA )
drivers/usb/dwc3/gadget.c +80 -80
510 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +2 -2
@@ -132,7 +132,7 @@ static inline void dwc3_gadget_ep_get_tr {u32 res_id; - res_id =dwc3_readl (dep->dwc->regs,DWC3_DEPCMD (dep->number)); + res_id =dwc3_readl (dep->dwc,DWC3_DEPCMD (dep->number)); dep->resource_index =DWC3_DEPCMD_GET_RSC_IDX (res_id); }
@@ -147,7 +147,7 @@ static inline void dwc3_gadget_ep_get_trstatic inline void dwc3_gadget_dctl_write_safe (struct dwc3 *dwc,u32 value) { value &= ~DWC3_DCTL_ULSTCHNGREQ_MASK ; -dwc3_writel (dwc->regs,DWC3_DCTL , value); +dwc3_writel (dwc,DWC3_DCTL , value); }#endif /* __DRIVERS_USB_DWC3_GADGET_H */
drivers/usb/dwc3/io.h +5 -2
@@ -16,9 +16,10 @@#include "debug.h" #include "core.h" -static inline u32 dwc3_readl (void __iomem *base,u32 offset) +static inline u32 dwc3_readl (struct dwc3 *dwc,u32 offset) {u32 value; +void __iomem *base = dwc->regs;/* * We requested the mem region starting from the Globals address
@@ -37,8 +38,10 @@ static inline u32 dwc3_readl(void __iomereturn value; } -static inline void dwc3_writel (void __iomem *base,u32 offset,u32 value) +static inline void dwc3_writel (struct dwc3 *dwc,u32 offset,u32 value) { +void __iomem *base = dwc->regs; +/* * We requested the mem region starting from the Globals address * space, see dwc3_probe in core.c.
drivers/usb/dwc3/ulpi.c +5 -5
@@ -33,13 +33,13 @@ static int dwc3_ulpi_busyloop(struct dwcif (read) ns +=DWC3_ULPI_BASE_DELAY ; - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); + reg =dwc3_readl (dwc,DWC3_GUSB2PHYCFG (0 ));if (reg &DWC3_GUSB2PHYCFG_SUSPHY )usleep_range (1000 ,1200 );while (count--) {ndelay (ns); - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYACC (0 )); + reg =dwc3_readl (dwc,DWC3_GUSB2PHYACC (0 ));if (reg &DWC3_GUSB2PHYACC_DONE )return 0 ;cpu_relax ();
@@ -55,13 +55,13 @@ static int dwc3_ulpi_read(struct deviceint ret; reg =DWC3_GUSB2PHYACC_NEWREGREQ |DWC3_ULPI_ADDR (addr); -dwc3_writel (dwc->regs,DWC3_GUSB2PHYACC (0 ), reg); +dwc3_writel (dwc,DWC3_GUSB2PHYACC (0 ), reg); ret =dwc3_ulpi_busyloop (dwc, addr, true);if (ret)return ret; - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYACC (0 )); + reg =dwc3_readl (dwc,DWC3_GUSB2PHYACC (0 ));return DWC3_GUSB2PHYACC_DATA (reg); }
@@ -73,7 +73,7 @@ static int dwc3_ulpi_write(struct device reg =DWC3_GUSB2PHYACC_NEWREGREQ |DWC3_ULPI_ADDR (addr); reg |=DWC3_GUSB2PHYACC_WRITE | val; -dwc3_writel (dwc->regs,DWC3_GUSB2PHYACC (0 ), reg); +dwc3_writel (dwc,DWC3_GUSB2PHYACC (0 ), reg);return dwc3_ulpi_busyloop (dwc, addr, false); }
Greg Kroah-Hartman
maintainerPATCH 173/188 usb: dwc3: Move GUID programming after PHY initialization
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvarasu Ganesan <[email protected]>
[ Upstream commit aad35f9c926ec220b0742af1ada45666ae667956 ]
The Linux Version Code is currently written to the GUID register before PHY initialization. Certain PHY implementations (such as Synopsys eUSB PHY performing link_sw_reset) clear the GUID register to its default value during initialization, causing the kernel version information to be lost.
Move the GUID register programming to occur after PHY initialization completes to ensure the Linux version information persists.
--- drivers/usb/dwc3/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/dwc3/core.c +6 -6
@@ -1339,12 +1339,6 @@ static int dwc3_core_init(struct dwc3 *d hw_mode =DWC3_GHWPARAMS0_MODE (dwc->hwparams.hwparams0); -/* -* Write Linux Version Code to our GUID register so it's easy to figure -* out which kernel version a bug was found. -*/ -dwc3_writel (dwc,DWC3_GUID ,LINUX_VERSION_CODE ); - ret =dwc3_phy_setup (dwc);if (ret)return ret;
@@ -1376,6 +1370,12 @@ static int dwc3_core_init(struct dwc3 *dif (ret) goto err_exit_phy; +/* +* Write Linux Version Code to our GUID register so it's easy to figure +* out which kernel version a bug was found. +*/ +dwc3_writel (dwc,DWC3_GUID ,LINUX_VERSION_CODE ); +dwc3_core_setup_global_control (dwc);dwc3_core_num_eps (dwc);
Greg Kroah-Hartman
maintainerPATCH 174/188 btrfs: remove fs_info argument from btrfs_sysfs_add_space_info_type()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 771af6ff72e0ed0eb8bf97e5ae4fa5094e0c5d1d ]
We don't need it since we can grab fs_info from the given space_info. So remove the fs_info argument.
Stable-dep-of: a7449edf9614 ("btrfs: fix double free in create_space_info_sub_group() error path")
--- fs/btrfs/space-info.c | 4 ++-- fs/btrfs/sysfs.c | 5 ++--- fs/btrfs/sysfs.h | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-)
fs/btrfs/space-info.c +2 -2
@@ -275,7 +275,7 @@ static int create_space_info_sub_group(s sub_group->parent = parent; sub_group->subgroup_id = id; - ret =btrfs_sysfs_add_space_info_type (fs_info, sub_group); + ret =btrfs_sysfs_add_space_info_type (sub_group);if (ret) {kfree (sub_group); parent->sub_group[index] =NULL ;
@@ -309,7 +309,7 @@ static int create_space_info(struct btrf goto out_free; } - ret =btrfs_sysfs_add_space_info_type (info, space_info); + ret =btrfs_sysfs_add_space_info_type (space_info);if (ret)return ret;
fs/btrfs/sysfs.c +2 -3
@@ -1981,13 +1981,12 @@ static const char *alloc_name(struct btr* Create a sysfs entry for a space info type at path * /sys/fs/btrfs/UUID/allocation/TYPE */ -int btrfs_sysfs_add_space_info_type (struct btrfs_fs_info *fs_info, -struct btrfs_space_info *space_info) +int btrfs_sysfs_add_space_info_type (struct btrfs_space_info *space_info) {int ret; ret =kobject_init_and_add (&space_info->kobj, &space_info_ktype, - fs_info->space_info_kobj,"%s" , + space_info->fs_info->space_info_kobj,"%s" ,alloc_name (space_info));if (ret) {kobject_put (&space_info->kobj);
fs/btrfs/sysfs.h +1 -2
@@ -37,8 +37,7 @@ void __cold btrfs_exit_sysfs(void);int btrfs_sysfs_add_mounted (struct btrfs_fs_info *fs_info);void btrfs_sysfs_remove_mounted (struct btrfs_fs_info *fs_info);void btrfs_sysfs_add_block_group_type (struct btrfs_block_group *cache); -int btrfs_sysfs_add_space_info_type (struct btrfs_fs_info *fs_info, -struct btrfs_space_info *space_info); +int btrfs_sysfs_add_space_info_type (struct btrfs_space_info *space_info);void btrfs_sysfs_remove_space_info (struct btrfs_space_info *space_info);void btrfs_sysfs_update_devid (struct btrfs_device *device);
Greg Kroah-Hartman
maintainerPATCH 175/188 btrfs: fix double free in create_space_info_sub_group() error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit a7449edf96143f192606ec8647e3167e1ecbd728 ]
When kobject_init_and_add() fails, the call chain is:
create_space_info_sub_group()
-> btrfs_sysfs_add_space_info_type()
-> kobject_init_and_add()
-> failure
-> kobject_put(&sub_group->kobj)
-> space_info_release()
-> kfree(sub_group)
Then control returns to create_space_info_sub_group(), where:
btrfs_sysfs_add_space_info_type() returns error
-> kfree(sub_group)
Thus, sub_group is freed twice.
Keep parent->sub_group[index] = NULL for the failure path, but after btrfs_sysfs_add_space_info_type() has called kobject_put(), let the kobject release callback handle the cleanup.
--- fs/btrfs/space-info.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/btrfs/space-info.c +1 -3
@@ -276,10 +276,8 @@ static int create_space_info_sub_group(s sub_group->subgroup_id = id; ret =btrfs_sysfs_add_space_info_type (sub_group); -if (ret) { -kfree (sub_group); +if (ret) parent->sub_group[index] =NULL ; - }return ret; }
Greg Kroah-Hartman
maintainerPATCH 176/188 btrfs: fix btrfs_ioctl_space_info() slot_count TOCTOU which can lead to info-leak
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yochai Eisenrich <[email protected]>
[ Upstream commit 973e57c726c1f8e77259d1c8e519519f1e9aea77 ]
btrfs_ioctl_space_info() has a TOCTOU race between two passes over the block group RAID type lists. The first pass counts entries to determine the allocation size, then the second pass fills the buffer. The groups_sem rwlock is released between passes, allowing concurrent block group removal to reduce the entry count.
When the second pass fills fewer entries than the first pass counted, copy_to_user() copies the full alloc_size bytes including trailing uninitialized kmalloc bytes to userspace.
Fix by copying only total_spaces entries (the actually-filled count from the second pass) instead of alloc_size bytes, and switch to kzalloc so any future copy size mismatch cannot leak heap data.
--- fs/btrfs/ioctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/ioctl.c +3 -2
@@ -3025,7 +3025,7 @@ static long btrfs_ioctl_space_info(strucreturn -ENOMEM ; space_args.total_spaces =0 ; - dest =kmalloc (alloc_size,GFP_KERNEL ); + dest =kzalloc (alloc_size,GFP_KERNEL );if (!dest)return -ENOMEM ; dest_orig = dest;
@@ -3081,7 +3081,8 @@ static long btrfs_ioctl_space_info(struc user_dest = (struct btrfs_ioctl_space_info __user *) (arg +sizeof (struct btrfs_ioctl_space_args )); -if (copy_to_user (user_dest, dest_orig, alloc_size)) +if (copy_to_user (user_dest, dest_orig, + space_args.total_spaces *sizeof (*dest_orig))) ret = -EFAULT ;kfree (dest_orig);
Greg Kroah-Hartman
maintainerPATCH 177/188 tracing: fprobe: use rhltable for fprobe_ip_table
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Menglong Dong <[email protected]>
[ Upstream commit 0de4c70d04a46a3c266547dd4275ce25f623796a ]
For now, all the kernel functions who are hooked by the fprobe will be added to the hash table "fprobe_ip_table". The key of it is the function address, and the value of it is "struct fprobe_hlist_node".
The budget of the hash table is FPROBE_IP_TABLE_SIZE, which is 256. And this means the overhead of the hash table lookup will grow linearly if the count of the functions in the fprobe more than 256. When we try to hook all the kernel functions, the overhead will be huge.
Therefore, replace the hash table with rhltable to reduce the overhead.
Stable-dep-of: 845947aca681 ("tracing/fprobe: Remove fprobe from hash in failure path")
--- include/linux/fprobe.h | 3 kernel/trace/fprobe.c | 157 ++++++++++++++++++++++++++++--------------------- 2 files changed, 93 insertions(+), 67 deletions(-)
include/linux/fprobe.h +2 -1
@@ -7,6 +7,7 @@#include <linux/ftrace.h> #include <linux/rcupdate.h> #include <linux/refcount.h> +#include <linux/rhashtable.h> #include <linux/slab.h> struct fprobe ;
@@ -26,7 +27,7 @@ typedef void (*fprobe_exit_cb)(struct fp* @fp: The fprobe which owns this. */ struct fprobe_hlist_node { -struct hlist_node hlist; +struct rhlist_head hlist;unsigned long addr;struct fprobe *fp; };
kernel/trace/fprobe.c +91 -66
257 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 178/188 tracing: fprobe: optimization for entry only case
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Menglong Dong <[email protected]>
[ Upstream commit 2c67dc457bc67367dc8fcd8f471ce2d5bb5f7b2b ]
For now, fgraph is used for the fprobe, even if we need trace the entry only. However, the performance of ftrace is better than fgraph, and we can use ftrace_ops for this case.
Then performance of kprobe-multi increases from 54M to 69M. Before this commit:
$ ./benchs/run_bench_trigger.sh kprobe-multi kprobe-multi : 54.663 ± 0.493M/s
After this commit:
$ ./benchs/run_bench_trigger.sh kprobe-multi kprobe-multi : 69.447 ± 0.143M/s
Mitigation is disable during the bench testing above.
Stable-dep-of: 845947aca681 ("tracing/fprobe: Remove fprobe from hash in failure path")
--- kernel/trace/fprobe.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 119 insertions(+), 9 deletions(-)
kernel/trace/fprobe.c +119 -9
@@ -252,8 +252,106 @@ static inline int __fprobe_kprobe_handlereturn ret; } -static int fprobe_entry (struct ftrace_graph_ent *trace,struct fgraph_ops *gops, -struct ftrace_regs *fregs) +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS +/* ftrace_ops callback, this processes fprobes which have only entry_handler. */ +static void fprobe_ftrace_entry (unsigned long ip,unsigned long parent_ip, +struct ftrace_ops *ops,struct ftrace_regs *fregs) +{ +struct fprobe_hlist_node *node; +struct rhlist_head *head, *pos; +struct fprobe *fp; +int bit; + + bit =ftrace_test_recursion_trylock (ip, parent_ip); +if (bit <0 ) +return ; + +/* +* ftrace_test_recursion_trylock() disables preemption, but +* rhltable_lookup() checks whether rcu_read_lcok is held. +* So we take rcu_read_lock() here. +*/ +rcu_read_lock (); + head =rhltable_lookup (&fprobe_ip_table, &ip, fprobe_rht_params); + +rhl_for_each_entry_rcu (node, pos, head, hlist) { +if (node->addr != ip) +break ; + fp =READ_ONCE (node->fp); +if (unlikely (!fp ||fprobe_disabled (fp) || fp->exit_handler)) +continue ; + +if (fprobe_shared_with_kprobes (fp)) +__fprobe_kprobe_handler (ip, parent_ip, fp, fregs,NULL ); +else +__fprobe_handler (ip, parent_ip, fp, fregs,NULL ); + } +rcu_read_unlock (); +ftrace_test_recursion_unlock (bit); +} +NOKPROBE_SYMBOL (fprobe_ftrace_entry); + +static struct ftrace_ops fprobe_ftrace_ops = { + .func = fprobe_ftrace_entry, + .flags =FTRACE_OPS_FL_SAVE_REGS , +}; +static int fprobe_ftrace_active; + +static int fprobe_ftrace_add_ips (unsigned long *addrs,int num) +{ +int ret; + +lockdep_assert_held (&fprobe_mutex); + + ret =ftrace_set_filter_ips (&fprobe_ftrace_ops, addrs, num,0 ,0 ); +if (ret) +return ret; + +if (!fprobe_ftrace_active) { + ret =register_ftrace_function (&fprobe_ftrace_ops); +if (ret) { +ftrace_free_filter (&fprobe_ftrace_ops); +return ret; + } + } + fprobe_ftrace_active++; +return 0 ; +} + +static void fprobe_ftrace_remove_ips (unsigned long *addrs,int num) +{ +lockdep_assert_held (&fprobe_mutex); + + fprobe_ftrace_active--; +if (!fprobe_ftrace_active) +unregister_ftrace_function (&fprobe_ftrace_ops); +if (num) +ftrace_set_filter_ips (&fprobe_ftrace_ops, addrs, num,1 ,0 ); +} + +static bool fprobe_is_ftrace (struct fprobe *fp) +{ +return !fp->exit_handler; +} +#else +static int fprobe_ftrace_add_ips (unsigned long *addrs,int num) +{ +return -ENOENT ; +} + +static void fprobe_ftrace_remove_ips (unsigned long *addrs,int num) +{ +} + +static bool fprobe_is_ftrace (struct fprobe *fp) +{ +return false; +} +#endif + +/* fgraph_ops callback, this processes fprobes which have exit_handler. */ +static int fprobe_fgraph_entry (struct ftrace_graph_ent *trace,struct fgraph_ops *gops, +struct ftrace_regs *fregs) {unsigned long *fgraph_data =NULL ;unsigned long func = trace->func;
@@ -289,7 +387,7 @@ static int fprobe_entry(struct ftrace_grif (node->addr != func)continue ; fp =READ_ONCE (node->fp); -if (fp && !fprobe_disabled (fp)) +if (fp && !fprobe_disabled (fp) && !fprobe_is_ftrace (fp)) fp->nmissed++; }return 0 ;
@@ -309,7 +407,7 @@ static int fprobe_entry(struct ftrace_grif (node->addr != func)continue ; fp =READ_ONCE (node->fp); -if (!fp ||fprobe_disabled (fp)) +if (unlikely (!fp ||fprobe_disabled (fp) ||fprobe_is_ftrace (fp)))continue ; data_size = fp->entry_data_size;
@@ -337,7 +435,7 @@ static int fprobe_entry(struct ftrace_gr/* If any exit_handler is set, data must be used. */ return used !=0 ; } -NOKPROBE_SYMBOL (fprobe_entry); +NOKPROBE_SYMBOL (fprobe_fgraph_entry); static void fprobe_return(struct ftrace_graph_ret *trace, struct fgraph_ops *gops,
@@ -376,7 +474,7 @@ static void fprobe_return(struct ftrace_NOKPROBE_SYMBOL (fprobe_return);static struct fgraph_ops fprobe_graph_ops = { - .entryfunc = fprobe_entry, + .entryfunc = fprobe_fgraph_entry, .retfunc = fprobe_return, };static int fprobe_graph_active;
@@ -498,9 +596,14 @@ static int fprobe_module_callback(struct }while (node ==ERR_PTR (-EAGAIN ));rhashtable_walk_exit (&iter); -if (alist.index >0 ) +if (alist.index >0 ) {ftrace_set_filter_ips (&fprobe_graph_ops.ops, alist.addrs, alist.index,1 ,0 ); +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS +ftrace_set_filter_ips (&fprobe_ftrace_ops, + alist.addrs, alist.index,1 ,0 ); +#endif + }mutex_unlock (&fprobe_mutex);kfree (alist.addrs);
@@ -735,7 +838,11 @@ int register_fprobe_ips(struct fprobe *freturn ret; hlist_array = fp->hlist_array; - ret =fprobe_graph_add_ips (addrs, num); +if (fprobe_is_ftrace (fp)) + ret =fprobe_ftrace_add_ips (addrs, num); +else + ret =fprobe_graph_add_ips (addrs, num); +if (!ret) {add_fprobe_hash (fp);for (i =0 ; i < hlist_array->size; i++) {
@@ -830,7 +937,10 @@ int unregister_fprobe(struct fprobe *fp) }del_fprobe_hash (fp); -fprobe_graph_remove_ips (addrs, count); +if (fprobe_is_ftrace (fp)) +fprobe_ftrace_remove_ips (addrs, count); +else +fprobe_graph_remove_ips (addrs, count);kfree_rcu (hlist_array, rcu); fp->hlist_array =NULL ;
Greg Kroah-Hartman
maintainerPATCH 179/188 tracing/fprobe: Unregister fprobe even if memory allocation fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Masami Hiramatsu (Google)" <[email protected]>
[ Upstream commit 1aec9e5c3e31ce1e28f914427fb7f90b91d310df ]
unregister_fprobe() can fail under memory pressure because of memory allocation failure, but this maybe called from module unloading, and usually there is no way to retry it. Moreover. trace_fprobe does not check the return value.
To fix this problem, unregister fprobe and fprobe_hash_node even if working memory allocation fails.
Anyway, if the last fprobe is removed, the filter will be freed.
Stable-dep-of: 845947aca681 ("tracing/fprobe: Remove fprobe from hash in failure path")
--- kernel/trace/fprobe.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
kernel/trace/fprobe.c +15 -10
@@ -323,9 +323,10 @@ static void fprobe_ftrace_remove_ips(unslockdep_assert_held (&fprobe_mutex); fprobe_ftrace_active--; -if (!fprobe_ftrace_active) +if (!fprobe_ftrace_active) {unregister_ftrace_function (&fprobe_ftrace_ops); -if (num) +ftrace_free_filter (&fprobe_ftrace_ops); + }else if (num)ftrace_set_filter_ips (&fprobe_ftrace_ops, addrs, num,1 ,0 ); }
@@ -508,10 +509,10 @@ static void fprobe_graph_remove_ips(unsi fprobe_graph_active--;/* Q: should we unregister it ? */ -if (!fprobe_graph_active) +if (!fprobe_graph_active) {unregister_ftrace_graph (&fprobe_graph_ops); - -if (num) +ftrace_free_filter (&fprobe_graph_ops.ops); + }else if (num)ftrace_set_filter_ips (&fprobe_graph_ops.ops, addrs, num,1 ,0 ); }
@@ -924,15 +925,19 @@ int unregister_fprobe(struct fprobe *fp) hlist_array = fp->hlist_array; addrs =kcalloc (hlist_array->size,sizeof (unsigned long ),GFP_KERNEL ); -if (!addrs) { - ret = -ENOMEM ;/* TODO: Fallback to one-by-one loop */ - goto out; - } +/* +* This will remove fprobe_hash_node from the hash table even if +* memory allocation fails. However, ftrace_ops will not be updated. +* Anyway, when the last fprobe is unregistered, ftrace_ops is also +* unregistered. +*/ +if (!addrs) +pr_warn ("Failed to allocate working array. ftrace_ops may not sync.\n" );/* Remove non-synonim ips from table and hash */ count =0 ;for (i =0 ; i < hlist_array->size; i++) { -if (!delete_fprobe_node (&hlist_array->array[i])) +if (!delete_fprobe_node (&hlist_array->array[i]) && addrs) addrs[count++] = hlist_array->array[i].addr; }del_fprobe_hash (fp);
Greg Kroah-Hartman
maintainerPATCH 180/188 tracing/fprobe: Remove fprobe from hash in failure path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Masami Hiramatsu (Google)" <[email protected]>
[ Upstream commit 845947aca6814f5723ed65e556eb5ee09493f05b ]
When register_fprobe_ips() fails, it tries to remove a list of fprobe_hash_node from fprobe_ip_table, but it missed to remove fprobe itself from fprobe_table. Moreover, when removing the fprobe_hash_node which is added to rhltable once, it must use kfree_rcu() after removing from rhltable.
To fix these issues, this reuses unregister_fprobe() internal code to rollback the half-way registered fprobe.
--- kernel/trace/fprobe.c | 90 ++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 43 deletions(-)
kernel/trace/fprobe.c +47 -43
@@ -78,20 +78,27 @@ static const struct rhashtable_params fp };/* Node insertion and deletion requires the fprobe_mutex */ -static int insert_fprobe_node (struct fprobe_hlist_node *node) +static int insert_fprobe_node (struct fprobe_hlist_node *node,struct fprobe *fp) { +int ret; +lockdep_assert_held (&fprobe_mutex); -return rhltable_insert (&fprobe_ip_table, &node->hlist, fprobe_rht_params); + ret =rhltable_insert (&fprobe_ip_table, &node->hlist, fprobe_rht_params); +/* Set the fprobe pointer if insertion was successful. */ +if (!ret) +WRITE_ONCE (node->fp, fp); +return ret; }/* Return true if there are synonims */ static bool delete_fprobe_node (struct fprobe_hlist_node *node) { -lockdep_assert_held (&fprobe_mutex);bool ret; -/* Avoid double deleting */ +lockdep_assert_held (&fprobe_mutex); + +/* Avoid double deleting and non-inserted nodes */ if (READ_ONCE (node->fp) !=NULL ) {WRITE_ONCE (node->fp,NULL ); rhltable_remove(&fprobe_ip_table, &node->hlist,
@@ -748,7 +755,6 @@ static int fprobe_init(struct fprobe *fp fp->hlist_array = hlist_array; hlist_array->fp = fp;for (i =0 ; i < num; i++) { - hlist_array->array[i].fp = fp; addr =ftrace_location (addrs[i]);if (!addr) {fprobe_fail_cleanup (fp);
@@ -812,6 +818,8 @@ int register_fprobe(struct fprobe *fp, c }EXPORT_SYMBOL_GPL (register_fprobe); +static int unregister_fprobe_nolock (struct fprobe *fp); +/** * register_fprobe_ips() - Register fprobe to ftrace by address. * @fp: A fprobe data structure to be registered.
@@ -838,28 +846,25 @@ int register_fprobe_ips(struct fprobe *fif (ret)return ret; - hlist_array = fp->hlist_array;if (fprobe_is_ftrace (fp)) ret =fprobe_ftrace_add_ips (addrs, num);else ret =fprobe_graph_add_ips (addrs, num); - -if (!ret) { -add_fprobe_hash (fp); -for (i =0 ; i < hlist_array->size; i++) { - ret =insert_fprobe_node (&hlist_array->array[i]); -if (ret) -break ; - } -/* fallback on insert error */ -if (ret) { -for (i--; i >=0 ; i--) -delete_fprobe_node (&hlist_array->array[i]); - } +if (ret) { +fprobe_fail_cleanup (fp); +return ret; } -if (ret) -fprobe_fail_cleanup (fp); + hlist_array = fp->hlist_array; + ret =add_fprobe_hash (fp); +for (i =0 ; i < hlist_array->size && !ret; i++) + ret =insert_fprobe_node (&hlist_array->array[i], fp); + +if (ret) { +unregister_fprobe_nolock (fp); +/* In error case, wait for clean up safely. */ +synchronize_rcu (); + }return ret; }
@@ -903,27 +908,12 @@ bool fprobe_is_registered(struct fprobereturn true; } -/** -* unregister_fprobe() - Unregister fprobe. -* @fp: A fprobe data structure to be unregistered. -* -* Unregister fprobe (and remove ftrace hooks from the function entries). -* -* Return 0 if @fp is unregistered successfully, -errno if not. -*/ -int unregister_fprobe (struct fprobe *fp) +static int unregister_fprobe_nolock (struct fprobe *fp) { -struct fprobe_hlist *hlist_array; +struct fprobe_hlist *hlist_array = fp->hlist_array;unsigned long *addrs =NULL ; -int ret =0 , i, count; +int i, count; -mutex_lock (&fprobe_mutex); -if (!fp || !fprobe_registered (fp)) { - ret = -EINVAL ; - goto out; - } - - hlist_array = fp->hlist_array; addrs =kcalloc (hlist_array->size,sizeof (unsigned long ),GFP_KERNEL );/* * This will remove fprobe_hash_node from the hash table even if
@@ -949,12 +939,26 @@ int unregister_fprobe(struct fprobe *fp)kfree_rcu (hlist_array, rcu); fp->hlist_array =NULL ; +kfree (addrs); -out: -mutex_unlock (&fprobe_mutex); +return 0 ; +} -kfree (addrs); -return ret; +/** +* unregister_fprobe() - Unregister fprobe. +* @fp: A fprobe data structure to be unregistered. +* +* Unregister fprobe (and remove ftrace hooks from the function entries). +* +* Return 0 if @fp is unregistered successfully, -errno if not. +*/ +int unregister_fprobe (struct fprobe *fp) +{ +guard (mutex)(&fprobe_mutex); +if (!fp || !fprobe_registered (fp)) +return -EINVAL ; + +return unregister_fprobe_nolock (fp); }EXPORT_SYMBOL_GPL (unregister_fprobe);
Greg Kroah-Hartman
maintainerPATCH 181/188 batman-adv: tp_meter: fix tp_num leak on kmalloc failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit ce425dd05d0fe7594930a0fb103634f35ac47bb6 upstream.
When batadv_tp_start() or batadv_tp_init_recv() fail to allocate a new tp_vars object, the previously incremented bat_priv->tp_num counter is never decremented. This causes tp_num to drift upward on each allocation failure. Since only BATADV_TP_MAX_NUM sessions can be started and the count is never reduced for these failed allocations, it causes to an exhaustion of throughput meter sessions. In worst case, no new throughput meter session can be started until the mesh interface is removed.
The error handling must decrement tp_num releasing the lock and aborting the creation of an throughput meter session
--- net/batman-adv/tp_meter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/batman-adv/tp_meter.c +4 -1
@@ -994,6 +994,7 @@ void batadv_tp_start(struct batadv_priv tp_vars =kmalloc (sizeof (*tp_vars),GFP_ATOMIC );if (!tp_vars) { +atomic_dec (&bat_priv->tp_num);spin_unlock_bh (&bat_priv->tp_list_lock); batadv_dbg(BATADV_DBG_TP_METER, bat_priv, "Meter: %s cannot allocate list elements\n",
@@ -1366,8 +1367,10 @@ batadv_tp_init_recv(struct batadv_priv * } tp_vars =kmalloc (sizeof (*tp_vars),GFP_ATOMIC ); -if (!tp_vars) +if (!tp_vars) { +atomic_dec (&bat_priv->tp_num); goto out_unlock; + }ether_addr_copy (tp_vars->other_end, icmp->orig); tp_vars->role =BATADV_TP_RECEIVER ;
Greg Kroah-Hartman
maintainerPATCH 182/188 vsock: fix buffer size clamping order
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert Szetei <[email protected]>
commit d114bfdc9b76bf93b881e195b7ec957c14227bab upstream.
In vsock_update_buffer_size(), the buffer size was being clamped to the maximum first, and then to the minimum. If a user sets a minimum buffer size larger than the maximum, the minimum check overrides the maximum check, inverting the constraint.
This breaks the intended socket memory boundaries by allowing the vsk->buffer_size to grow beyond the configured vsk->buffer_max_size.
Fix this by checking the minimum first, and then the maximum. This ensures the buffer size never exceeds the buffer_max_size.
--- net/vmw_vsock/af_vsock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/vmw_vsock/af_vsock.c +3 -3
@@ -1846,12 +1846,12 @@ static void vsock_update_buffer_size(strconst struct vsock_transport *transport, u64 val) { - if (val > vsk->buffer_max_size) - val = vsk->buffer_max_size; - if (val < vsk->buffer_min_size) val = vsk->buffer_min_size; +if (val > vsk->buffer_max_size) + val = vsk->buffer_max_size; +if (val != vsk->buffer_size && transport && transport->notify_buffer_size) transport->notify_buffer_size (vsk, &val);
Greg Kroah-Hartman
maintainerPATCH 183/188 vsock/virtio: fix length and offset in tap skb for split packets
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Garzarella <[email protected]>
commit 5f344d809e015fba3709e5219428c00b8ac5d7df upstream.
virtio_transport_build_skb() builds a new skb to be delivered to the vsockmon tap device. To build the new skb, it uses the original skb data length as payload length, but as the comment notes, the original packet stored in the skb may have been split in multiple packets, so we need to use the length in the header, which is correctly updated before the packet is delivered to the tap, and the offset for the data.
This was also similar to what we did before commit 71dc9ec9ac7d ("virtio/vsock: replace virtio_vsock_pkt with sk_buff") where we probably missed something during the skb conversion.
Also update the comment above, which was left stale by the skb conversion and still mentioned a buffer pointer that no longer exists.
--- net/vmw_vsock/virtio_transport_common.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/vmw_vsock/virtio_transport_common.c +6 -5
@@ -169,12 +169,12 @@ static struct sk_buff *virtio_transport_struct sk_buff *skb;size_t payload_len; -/* A packet could be split to fit the RX buffer, so we can retrieve -* the payload length from the header and the buffer pointer taking -* care of the offset in the original packet. +/* A packet could be split to fit the RX buffer, so we use +* the payload length from the header, which has been updated +* by the sender to reflect the fragment size. */ pkt_hdr =virtio_vsock_hdr (pkt); - payload_len = pkt->len; + payload_len =le32_to_cpu (pkt_hdr->len); skb =alloc_skb (sizeof (*hdr) +sizeof (*pkt_hdr) + payload_len,GFP_ATOMIC );
@@ -222,7 +222,8 @@ static struct sk_buff *virtio_transport_virtio_transport_copy_nonlinear_skb (pkt, data, payload_len); }else { -skb_put_data (skb, pkt->data, payload_len); +skb_put_data (skb, pkt->data +VIRTIO_VSOCK_SKB_CB (pkt)->offset, + payload_len); } }
Greg Kroah-Hartman
maintainerPATCH 184/188 vsock/virtio: fix empty payload in tap skb for non-linear buffers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Garzarella <[email protected]>
commit 3a3e3d90cbc79600544536723911657730759af3 upstream.
For non-linear skbs, virtio_transport_build_skb() goes through virtio_transport_copy_nonlinear_skb() to copy the original payload in the new skb to be delivered to the vsockmon tap device. This manually initializes an iov_iter but does not set iov_iter.count. Since the iov_iter is zero-initialized, the copy length is zero and no payload is actually copied to the monitor interface, leaving data un-initialized.
Fix this by removing the linear vs non-linear split and using skb_copy_datagram_iter() with iov_iter_kvec() for all cases, as vhost-vsock already does. This handles both linear and non-linear skbs, properly initializes the iov_iter, and removes the now unused virtio_transport_copy_nonlinear_skb().
While touching this code, let's also check the return value of skb_copy_datagram_iter(), even though it's unlikely to fail.
--- net/vmw_vsock/virtio_transport_common.c | 40 +++++++++----------------------- 1 file changed, 12 insertions(+), 28 deletions(-)
net/vmw_vsock/virtio_transport_common.c +12 -28
@@ -139,27 +139,6 @@ static void virtio_transport_init_hdr(st hdr->fwd_cnt =cpu_to_le32 (0 ); } -static void virtio_transport_copy_nonlinear_skb (const struct sk_buff *skb, -void *dst, -size_t len) -{ -struct iov_iter iov_iter = {0 }; -struct kvec kvec; -size_t to_copy; - - kvec.iov_base = dst; - kvec.iov_len = len; - - iov_iter.iter_type =ITER_KVEC ; - iov_iter.kvec = &kvec; - iov_iter.nr_segs =1 ; - - to_copy =min_t (size_t, len, skb->len); - -skb_copy_datagram_iter (skb,VIRTIO_VSOCK_SKB_CB (skb)->offset, - &iov_iter, to_copy); -} -/* Packet capture */ static struct sk_buff *virtio_transport_build_skb (void *opaque) {
@@ -217,13 +196,18 @@ static struct sk_buff *virtio_transport_skb_put_data (skb, pkt_hdr,sizeof (*pkt_hdr));if (payload_len) { -if (skb_is_nonlinear (pkt)) { -void *data =skb_put (skb, payload_len); - -virtio_transport_copy_nonlinear_skb (pkt, data, payload_len); - }else { -skb_put_data (skb, pkt->data +VIRTIO_VSOCK_SKB_CB (pkt)->offset, - payload_len); +struct iov_iter iov_iter; +struct kvec kvec; +void *data =skb_put (skb, payload_len); + + kvec.iov_base = data; + kvec.iov_len = payload_len; +iov_iter_kvec (&iov_iter,ITER_DEST , &kvec,1 , payload_len); + +if (skb_copy_datagram_iter (pkt,VIRTIO_VSOCK_SKB_CB (pkt)->offset, + &iov_iter, payload_len)) { +kfree_skb (skb); +return NULL ; } }
Greg Kroah-Hartman
maintainerPATCH 185/188 vsock/virtio: fix potential unbounded skb queue
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 059b7dbd20a6f0c539a45ddff1573cb8946685b5 upstream.
virtio_transport_inc_rx_pkt() checks vvs->rx_bytes + len > vvs->buf_alloc.
virtio_transport_recv_enqueue() skips coalescing for packets with VIRTIO_VSOCK_SEQ_EOM.
If fed with packets with len == 0 and VIRTIO_VSOCK_SEQ_EOM, a very large number of packets can be queued because vvs->rx_bytes stays at 0.
Fix this by estimating the skb metadata size:
(Number of skbs in the queue) * SKB_TRUESIZE(0)
--- net/vmw_vsock/virtio_transport_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/vmw_vsock/virtio_transport_common.c +3 -1
@@ -429,7 +429,9 @@ static int virtio_transport_send_pkt_infstatic bool virtio_transport_inc_rx_pkt (struct virtio_vsock_sock *vvs,u32 len) { -if (vvs->buf_used + len > vvs->buf_alloc) +u64 skb_overhead = (skb_queue_len (&vvs->rx_queue) +1 ) *SKB_TRUESIZE (0 ); + +if (skb_overhead + vvs->buf_used + len > vvs->buf_alloc)return false; vvs->rx_bytes += len;
Greg Kroah-Hartman
maintainerPATCH 186/188 vsock/virtio: fix accept queue count leak on transport mismatch
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
commit 52bcb57a4e8a0865a76c587c2451906342ae1b2d upstream.
virtio_transport_recv_listen() calls sk_acceptq_added() before vsock_assign_transport(). If vsock_assign_transport() fails or selects a different transport, the error path returns without calling sk_acceptq_removed(), permanently incrementing sk_ack_backlog.
After approximately backlog+1 such failures, sk_acceptq_is_full() returns true, causing the listener to reject all new connections.
Fix by moving sk_acceptq_added() to after the transport validation, matching the pattern used by vmci_transport and hyperv_transport.
--- net/vmw_vsock/virtio_transport_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +1 -2
@@ -1530,8 +1530,6 @@ virtio_transport_recv_listen(struct sockreturn -ENOMEM ; } -sk_acceptq_added (sk); -lock_sock_nested (child,SINGLE_DEPTH_NESTING ); child->sk_state =TCP_ESTABLISHED ;
@@ -1553,6 +1551,7 @@ virtio_transport_recv_listen(struct sockreturn ret; } +sk_acceptq_added (sk);if (virtio_transport_space_update (child, skb)) child->sk_write_space (child);
Greg Kroah-Hartman
maintainerPATCH 187/188 drm/amdgpu/vcn3: Avoid overflow on msg bound check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Cheng <[email protected]>
commit e6e9faba8100628990cccd13f0f044a648c303cf upstream.
As pointed out by SDL, the previous condition may be vulnerable to overflow.
--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +3 -1
@@ -1971,6 +1971,7 @@ static int vcn_v3_0_dec_msg(struct amdgpfor (i =0 , msg = &msg[6 ]; i < num_buffers; ++i, msg +=4 ) {uint32_t offset, size, *create; +uint64_t buf_end;if (msg[0 ] !=RDECODE_MESSAGE_CREATE )continue ;
@@ -1978,7 +1979,8 @@ static int vcn_v3_0_dec_msg(struct amdgp offset = msg[1 ]; size = msg[2 ]; -if (size <4 || offset + size > end - addr) { +if (size <4 ||check_add_overflow (offset, size, &buf_end) || + buf_end > end - addr) {DRM_ERROR ("VCN message buffer exceeds BO bounds!\n" ); r = -EINVAL ; goto out;
Greg Kroah-Hartman
maintainerPATCH 188/188 drm/amdgpu/vcn4: Avoid overflow on msg bound check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Cheng <[email protected]>
commit 65bce27ea6192320448c30267ffc17ffa094e713 upstream.
As pointed out by SDL, the previous condition may be vulnerable to overflow.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +3 -1
@@ -1888,6 +1888,7 @@ static int vcn_v4_0_dec_msg(struct amdgpfor (i =0 , msg = &msg[6 ]; i < num_buffers; ++i, msg +=4 ) {uint32_t offset, size, *create; +uint64_t buf_end;if (msg[0 ] !=RDECODE_MESSAGE_CREATE )continue ;
@@ -1895,7 +1896,8 @@ static int vcn_v4_0_dec_msg(struct amdgp offset = msg[1 ]; size = msg[2 ]; -if (size <4 || offset + size > end - addr) { +if (size <4 ||check_add_overflow (offset, size, &buf_end) || + buf_end > end - addr) {DRM_ERROR ("VCN message buffer exceeds BO bounds!\n" ); r = -EINVAL ; goto out;
Build failed, you can drop the commit to build ok:
git revert 0253904dd601b15da2983297d64c106a393b3aa3.
Revert "sched_ext: Use HK_TYPE_DOMAIN_BOOT to detect isolcpus= domain isolation"
BRs
Wentao Guan
defconfigs:
https://gist.github.com/opsiff/a840ae9e3d6857f5b7bacb9cdc49f8e9
Log:kernel/sched/ext.c: In function ‘scx_enable’:kernel/sched/ext.c:4924:34: error: ‘HK_TYPE_DOMAIN_BOOT’ undeclared (first use in this function); did you mean ‘HK_TYPE_DOMAIN’?
4924 | if (housekeeping_enabled(HK_TYPE_DOMAIN_BOOT)) {
| ^~~~~~~~~~~~~~~~~~~
| HK_TYPE_DOMAINkernel/sched/ext.c:4924:34: note: each undeclared identifier is reported only once for each function it appears in
CC [M] crypto/algif_hash.o
commit 4fca0e550d506e1c95504c2d9247bc92bf621bf6
Author: Frederic Weisbecker <[email protected]> Date: Mon May 26 13:06:21 2025 +0200
sched/isolation: Save boot defined domain flags
HK_TYPE_DOMAIN will soon integrate not only boot defined isolcpus= CPUs but also cpuset isolated partitions.
Housekeeping still needs a way to record what was initially passed to isolcpus= in order to keep these CPUs isolated after a cpuset isolated partition is modified or destroyed while containing some of them.
Create a new HK_TYPE_DOMAIN_BOOT to keep track of those.
Greg KH
maintainerQuoted 37 lines · Wentao Guan
Build failed, you can drop the commit to build ok:
git revert0253904dd601b15da2983297d64c106a393b3aa3.
Revert "sched_ext: UseHK_TYPE_DOMAIN_BOOTto detect isolcpus= domain isolation"Tested-by Wentao Guan <[email protected]>BRs
Wentao Guandefconfigs:
https://gist.github.com/opsiff/a840ae9e3d6857f5b7bacb9cdc49f8e9Log:
kernel/sched/ext.c: In function ‘scx_enable’:kernel/sched/ext.c:4924:34: error: ‘HK_TYPE_DOMAIN_BOOT’ undeclared (first use in this function); did you mean ‘HK_TYPE_DOMAIN’?4924 | if (housekeeping_enabled(HK_TYPE_DOMAIN_BOOT)) { | ^~~~~~~~~~~~~~~~~~~ | HK_TYPE_DOMAIN
kernel/sched/ext.c:4924:34: note: each undeclared identifier is reported only once for each function it appears in
CC [M]crypto/algif_hash.ocommit
4fca0e550d506e1c95504c2d9247bc92bf621bf6Author: Frederic Weisbecker <[email protected]> Date: Mon May 26 13:06:21 2025 +0200sched/isolation: Save boot defined domain flags
HK_TYPE_DOMAINwill soon integrate not only boot defined isolcpus= CPUs but also cpuset isolated partitions.Housekeeping still needs a way to record what was initially passed to isolcpus= in order to keep these CPUs isolated after a cpuset isolated partition is modified or destroyed while containing some of them.
Create a new
HK_TYPE_DOMAIN_BOOTto keep track of those.
Quoted 11 lines
Signed-off-by Frederic Weisbecker <[email protected]>Reviewed-by Phil Auld <[email protected]>Reviewed-by Waiman Long <[email protected]>Cc Ingo Molnar <[email protected]>Cc Marco Crivellari <[email protected]>Cc Michal Hocko <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Tejun Heo <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Waiman Long <[email protected]>
Thanks, will go and drop this commit now.
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.32 release. There are 188 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 17 May 2026 15:46:37 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.32-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.18.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.18.32 release. There are 188 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.18.y
Best regards,
Pavel
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.32 release. There are 188 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 17 May 2026 15:46:37 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.32-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.18.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 8 lines · On Fri, 15 May 2026 17:46:57 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.18.32 release. There are 188 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 17 May 2026 15:46:37 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust x86_64, arm64 and riscv64; built-tested for loongarch64:
Via arm32 I see:
drivers/hid/hid-core.c:2050:29: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
2049 | hid_warn_ratelimited(hid, "Event data for report %d is incorrect (%d vs %ld)\n",
| ~~~
| %zu
2050 | report->id, csize, bsize);
| ^~~~~
It is also reproducible in mainline, though. Cc'ing a few folks...
Thanks!
Cheers,
Miguel
Greg KH
maintainerQuoted 17 lines · Miguel Ojeda
Quoted 8 lines · On Fri, 15 May 2026 17:46:57 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.18.32 release. There are 188 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 17 May 2026 15:46:37 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust
x86_64, arm64 and riscv64; built-tested for loongarch64:Tested-by Miguel Ojeda <[email protected]>Via arm32 I see:
Quoted 8 lines
drivers/hid/hid-core.c:2050:29: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
2049 | hid_warn_ratelimited(hid, "Event data for report %d is incorrect (%d vs %ld)\n",
| ~~~
| %zu
2050 |report->id, csize, bsize);
| ^~~~~It is also reproducible in mainline, though. Cc'ing a few folks...
bsize is size_t, so that should be %zu, right?
thanks,
greg k-h
Quoted 25 lines · Greg KH
Quoted 24 lines · Miguel Ojeda
Quoted 8 lines · On Fri, 15 May 2026 17:46:57 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.18.32 release. There are 188 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 17 May 2026 15:46:37 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust
x86_64, arm64 and riscv64; built-tested for loongarch64:Tested-by Miguel Ojeda <[email protected]>Via arm32 I see:
drivers/hid/hid-core.c:2050:29: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
2049 | hid_warn_ratelimited(hid, "Event data for report %d is incorrect (%d vs %ld)\n",
| ~~~
| %zu
2050 |report->id, csize, bsize);
| ^~~~~
Quoted 3 lines
Quoted 1 line
It is also reproducible in mainline, though. Cc'ing a few folks...
bsize is
size_t, so that should be %zu, right?
Indeed. Does not look like anyone has sent a patch yet so I will send one shortly since this is breaking i386_defconfig in my tests since -Werror is enabled by default there.
Signature · 2 lines
Cheers, Nathan
Sasha Levin
maintainerQuoted 10 lines · Miguel Ojeda
Via arm32 I see:
drivers/hid/hid-core.c:2050:29: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
2049 | hid_warn_ratelimited(hid, "Event data for report %d is incorrect (%d vs %ld)\n",
| ~~~
| %zu
2050 |report->id, csize, bsize);
| ^~~~~It is also reproducible in mainline, though. Cc'ing a few folks...
Nathan's mainline fix (4d3a2a466b8d "HID: core: Fix size_t specifier in hid_report_raw_event()") has been queued for 6.18.y and 7.0.y.
--
Thanks,
Sasha
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.32 release. There are 188 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
# Librecast Test Results
020/020 [ OK ] liblcrq
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 6.18.32-rc1-g96bfea1f1bc2 #1 SMP PREEMPT_DYNAMIC Sat May 16 09:11:39 -00 2026 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux