6.6.33-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 498/744 PCI/EDR: Align EDR_PORT_DPC_ENABLE_DSM with PCI Firmware r3.3
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuppuswamy Sathyanarayanan <[email protected]>
[ Upstream commit f24ba846133d0edec785ac6430d4daf6e9c93a09 ]
The "Downstream Port Containment related Enhancements" ECN of Jan 28, 2019 (document 12888 below), defined the EDR_PORT_DPC_ENABLE_DSM function with Revision ID 5 with Arg3 being an integer. But when the ECN was integrated into PCI Firmware r3.3, sec 4.6.12, it was defined as Revision ID 6 with Arg3 being a package containing an integer.
The implementation in acpi_enable_dpc() supplies a package as Arg3 (arg4 in the code), but it previously specified Revision ID 5. Align this with PCI Firmware r3.3 by using Revision ID 6.
If firmware implemented per the ECN, its Revision 5 function would receive a package as Arg3 when it expects an integer, so acpi_enable_dpc() would likely fail. If such firmware exists and lacks a Revision 6 function that expects a package, we may have to add support for Revision 5.
--- drivers/pci/pcie/edr.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/pci/pcie/edr.c +4 -9
@@ -32,10 +32,10 @@ static int acpi_enable_dpc(struct pci_dev *pdev)int status =0 ;/* -* Behavior when calling unsupported _DSM functions is undefined, -* so check whether EDR_PORT_DPC_ENABLE_DSM is supported. +* Per PCI Firmware r3.3, sec 4.6.12, EDR_PORT_DPC_ENABLE_DSM is +* optional. Return success if it's not implemented. */ -if (!acpi_check_dsm (adev->handle, &pci_acpi_dsm_guid,5 , +if (!acpi_check_dsm (adev->handle, &pci_acpi_dsm_guid,6 ,1ULL <<EDR_PORT_DPC_ENABLE_DSM ))return 0 ;
@@ -46,12 +46,7 @@ static int acpi_enable_dpc(struct pci_dev *pdev) argv4.package.count =1 ; argv4.package.elements = &req; -/* -* Per Downstream Port Containment Related Enhancements ECN to PCI -* Firmware Specification r3.2, sec 4.6.12, EDR_PORT_DPC_ENABLE_DSM is -* optional. Return success if it's not implemented. -*/ - obj =acpi_evaluate_dsm (adev->handle, &pci_acpi_dsm_guid,5 , + obj =acpi_evaluate_dsm (adev->handle, &pci_acpi_dsm_guid,6 ,EDR_PORT_DPC_ENABLE_DSM , &argv4);if (!obj)return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 499/744 PCI/EDR: Align EDR_PORT_LOCATE_DSM with PCI Firmware r3.3
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuppuswamy Sathyanarayanan <[email protected]>
[ Upstream commit e2e78a294a8a863898b781dbcf90e087eda3155d ]
The "Downstream Port Containment related Enhancements" ECN of Jan 28, 2019 (document 12888 below), defined the EDR_PORT_LOCATE_DSM function with Revision ID 5 with a return value encoding (Bits 2:0 = Function, Bits 7:3 = Device, Bits 15:8 = Bus). When the ECN was integrated into PCI Firmware r3.3, sec 4.6.13, Bit 31 was added to indicate success or failure.
Check Bit 31 for failure in acpi_dpc_port_get().
--- drivers/pci/pcie/edr.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/pci/pcie/edr.c +13 -2
@@ -80,8 +80,9 @@ static struct pci_dev *acpi_dpc_port_get(struct pci_dev *pdev)u16 port;/* -* Behavior when calling unsupported _DSM functions is undefined, -* so check whether EDR_PORT_DPC_ENABLE_DSM is supported. +* If EDR_PORT_LOCATE_DSM is not implemented under the target of +* EDR, the target is the port that experienced the containment +* event (PCI Firmware r3.3, sec 4.6.13). */ if (!acpi_check_dsm (adev->handle, &pci_acpi_dsm_guid,5 ,1ULL <<EDR_PORT_LOCATE_DSM ))
@@ -98,6 +99,16 @@ static struct pci_dev *acpi_dpc_port_get(struct pci_dev *pdev)return NULL ; } +/* +* Bit 31 represents the success/failure of the operation. If bit +* 31 is set, the operation failed. +*/ +if (obj->integer.value &BIT (31 )) { +ACPI_FREE (obj); +pci_err (pdev,"Locate Port _DSM failed\n" ); +return NULL ; + } +/* * Firmware returns DPC port BDF details in following format: * 15:8 = bus
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 500/744 f2fs: Clean up errors in segment.h
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: KaiLong Wang <[email protected]>
[ Upstream commit 37768434b7a7d00ac5a08b2c1d31aa7aaa0846a0 ]
Fix the following errors reported by checkpatch:
ERROR: spaces required around that ':' (ctx:VxW)
Stable-dep-of: aa4074e8fec4 ("f2fs: fix block migration when section is not aligned to pow2")
--- fs/f2fs/segment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/segment.h +2 -2
@@ -108,11 +108,11 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, ((sbi)->segs_per_sec - ((sbi)->unusable_blocks_per_sec >>\ (sbi)->log_blocks_per_seg))#define GET_SEC_FROM_SEG (sbi, segno) \ - (((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec) + (((segno) == -1) ? -1 : (segno) / (sbi)->segs_per_sec)#define GET_SEG_FROM_SEC (sbi, secno) \ ((secno) * (sbi)->segs_per_sec)#define GET_ZONE_FROM_SEC (sbi, secno) \ - (((secno) == -1) ? -1: (secno) / (sbi)->secs_per_zone) + (((secno) == -1) ? -1 : (secno) / (sbi)->secs_per_zone)#define GET_ZONE_FROM_SEG (sbi, segno) \ GET_ZONE_FROM_SEC(sbi, GET_SEC_FROM_SEG(sbi, segno))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 501/744 f2fs: support printk_ratelimited() in f2fs_printk()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit b1c9d3f833ba60a288db111d7fe38edfeb9b8fbb ]
This patch supports using printk_ratelimited() in f2fs_printk(), and wrap ratelimited f2fs_printk() into f2fs_{err,warn,info}_ratelimited(), then, use these new helps to clean up codes.
Stable-dep-of: aa4074e8fec4 ("f2fs: fix block migration when section is not aligned to pow2")
--- fs/f2fs/compress.c | 10 +++++----- fs/f2fs/dir.c | 5 ++--- fs/f2fs/f2fs.h | 40 +++++++++++++++++++++++----------------- fs/f2fs/super.c | 11 ++++++++--- 4 files changed, 38 insertions(+), 28 deletions(-)
fs/f2fs/compress.c +5 -5
@@ -512,8 +512,8 @@ static int lzorle_compress_pages(struct compress_ctx *cc) ret =lzorle1x_1_compress (cc->rbuf, cc->rlen, cc->cbuf->cdata, &cc->clen, cc->private);if (ret !=LZO_E_OK ) { -printk_ratelimited ("%sF2FS-fs (%s): lzo-rle compress failed, ret:%d\n" , -KERN_ERR ,F2FS_I_SB (cc->inode)->sb->s_id, ret); +f2fs_err_ratelimited (F2FS_I_SB (cc->inode), +"lzo-rle compress failed, ret:%d" , ret);return -EIO ; }return 0 ;
@@ -780,9 +780,9 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)if (provided != calculated) {if (!is_inode_flag_set (dic->inode,FI_COMPRESS_CORRUPT )) {set_inode_flag (dic->inode,FI_COMPRESS_CORRUPT ); -printk_ratelimited ( -"%sF2FS-fs (%s): checksum invalid, nid = %lu, %x vs %x" , -KERN_INFO , sbi->sb->s_id, dic->inode->i_ino, +f2fs_info_ratelimited (sbi, +"checksum invalid, nid = %lu, %x vs %x" , + dic->inode->i_ino, provided, calculated); }set_sbi_flag (sbi,SBI_NEED_FSCK );
fs/f2fs/dir.c +2 -3
@@ -996,9 +996,8 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, de = &d->dentry[bit_pos];if (de->name_len ==0 ) {if (found_valid_dirent || !bit_pos) { -printk_ratelimited ( -"%sF2FS-fs (%s): invalid namelen(0), ino:%u, run fsck to fix." , -KERN_WARNING , sbi->sb->s_id, +f2fs_warn_ratelimited (sbi, +"invalid namelen(0), ino:%u, run fsck to fix." ,le32_to_cpu (de->ino));set_sbi_flag (sbi,SBI_NEED_FSCK ); }
fs/f2fs/f2fs.h +23 -17
@@ -1808,6 +1808,27 @@ struct f2fs_sb_info {#endif }; +__printf(3, 4) +void f2fs_printk (struct f2fs_sb_info *sbi,bool limit_rate,const char *fmt, ...); + +#define f2fs_err (sbi, fmt, ...) \ + f2fs_printk(sbi, false, KERN_ERR fmt, ##__VA_ARGS__) +#define f2fs_warn (sbi, fmt, ...) \ + f2fs_printk(sbi, false, KERN_WARNING fmt, ##__VA_ARGS__) +#define f2fs_notice (sbi, fmt, ...) \ + f2fs_printk(sbi, false, KERN_NOTICE fmt, ##__VA_ARGS__) +#define f2fs_info (sbi, fmt, ...) \ + f2fs_printk(sbi, false, KERN_INFO fmt, ##__VA_ARGS__) +#define f2fs_debug (sbi, fmt, ...) \ + f2fs_printk(sbi, false, KERN_DEBUG fmt, ##__VA_ARGS__) + +#define f2fs_err_ratelimited (sbi, fmt, ...) \ + f2fs_printk(sbi, true, KERN_ERR fmt, ##__VA_ARGS__) +#define f2fs_warn_ratelimited (sbi, fmt, ...) \ + f2fs_printk(sbi, true, KERN_WARNING fmt, ##__VA_ARGS__) +#define f2fs_info_ratelimited (sbi, fmt, ...) \ + f2fs_printk(sbi, true, KERN_INFO fmt, ##__VA_ARGS__) +#ifdef CONFIG_F2FS_FAULT_INJECTION #define time_to_inject (sbi, type) __time_to_inject(sbi, type, __func__, \ __builtin_return_address(0))
@@ -1825,9 +1846,8 @@ static inline bool __time_to_inject(struct f2fs_sb_info *sbi, int type,atomic_inc (&ffi->inject_ops);if (atomic_read (&ffi->inject_ops) >= ffi->inject_rate) {atomic_set (&ffi->inject_ops,0 ); -printk_ratelimited ("%sF2FS-fs (%s) : inject %s in %s of %pS\n" , -KERN_INFO , sbi->sb->s_id, f2fs_fault_name[type], - func, parent_func); +f2fs_info_ratelimited (sbi,"inject %s in %s of %pS" , + f2fs_fault_name[type], func, parent_func);return true; }return false;
@@ -2321,20 +2341,6 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,return -ENOSPC ; } -__printf(2, 3) -void f2fs_printk (struct f2fs_sb_info *sbi,const char *fmt, ...); - -#define f2fs_err (sbi, fmt, ...) \ - f2fs_printk(sbi, KERN_ERR fmt, ##__VA_ARGS__) -#define f2fs_warn (sbi, fmt, ...) \ - f2fs_printk(sbi, KERN_WARNING fmt, ##__VA_ARGS__) -#define f2fs_notice (sbi, fmt, ...) \ - f2fs_printk(sbi, KERN_NOTICE fmt, ##__VA_ARGS__) -#define f2fs_info (sbi, fmt, ...) \ - f2fs_printk(sbi, KERN_INFO fmt, ##__VA_ARGS__) -#define f2fs_debug (sbi, fmt, ...) \ - f2fs_printk(sbi, KERN_DEBUG fmt, ##__VA_ARGS__) -#define PAGE_PRIVATE_GET_FUNC (name, flagname) \ static inline bool page_private_##name(struct page *page) \ { \
fs/f2fs/super.c +8 -3
@@ -248,7 +248,8 @@ static match_table_t f2fs_tokens = { {Opt_err, NULL}, }; -void f2fs_printk (struct f2fs_sb_info *sbi,const char *fmt, ...) +void f2fs_printk (struct f2fs_sb_info *sbi,bool limit_rate, +const char *fmt, ...) {struct va_format vaf;va_list args;
@@ -259,8 +260,12 @@ void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...) level =printk_get_level (fmt); vaf.fmt =printk_skip_level (fmt); vaf.va = &args; -printk ("%c%cF2FS-fs (%s): %pV\n" , -KERN_SOH_ASCII , level, sbi->sb->s_id, &vaf); +if (limit_rate) +printk_ratelimited ("%c%cF2FS-fs (%s): %pV\n" , +KERN_SOH_ASCII , level, sbi->sb->s_id, &vaf); +else +printk ("%c%cF2FS-fs (%s): %pV\n" , +KERN_SOH_ASCII , level, sbi->sb->s_id, &vaf);va_end (args); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 502/744 f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
[ Upstream commit a60108f7dfb5867da1ad9c777d2fbbe47e4dbdd7 ]
No functional change.
Stable-dep-of: aa4074e8fec4 ("f2fs: fix block migration when section is not aligned to pow2")
--- fs/f2fs/checkpoint.c | 10 ++-- fs/f2fs/debug.c | 6 +-- fs/f2fs/f2fs.h | 21 +++++---- fs/f2fs/file.c | 16 +++---- fs/f2fs/gc.c | 40 ++++++++-------- fs/f2fs/node.c | 4 +- fs/f2fs/node.h | 4 +- fs/f2fs/recovery.c | 2 +- fs/f2fs/segment.c | 110 +++++++++++++++++++++---------------------- fs/f2fs/segment.h | 44 +++++++++-------- fs/f2fs/super.c | 8 ++-- fs/f2fs/sysfs.c | 6 +-- 12 files changed, 135 insertions(+), 136 deletions(-)
fs/f2fs/checkpoint.c +5 -5
@@ -889,7 +889,7 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi, cp_blocks =le32_to_cpu (cp_block->cp_pack_total_block_count); -if (cp_blocks > sbi->blocks_per_seg || cp_blocks <=F2FS_CP_PACKS ) { +if (cp_blocks >BLKS_PER_SEG (sbi) || cp_blocks <=F2FS_CP_PACKS ) {f2fs_warn (sbi,"invalid cp_pack_total_block_count:%u" ,le32_to_cpu (cp_block->cp_pack_total_block_count)); goto invalid_cp;
@@ -1324,7 +1324,7 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)if (cpc->reason &CP_UMOUNT ) {if (le32_to_cpu (ckpt->cp_pack_total_block_count) + -NM_I (sbi)->nat_bits_blocks > sbi->blocks_per_seg) { +NM_I (sbi)->nat_bits_blocks >BLKS_PER_SEG (sbi)) {clear_ckpt_flags (sbi,CP_NAT_BITS_FLAG );f2fs_notice (sbi,"Disable nat_bits due to no space" ); } else if (!is_set_ckpt_flags(sbi, CP_NAT_BITS_FLAG) &&
@@ -1527,7 +1527,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) cp_ver |= ((__u64 )crc32 <<32 ); *(__le64 *)nm_i->nat_bits =cpu_to_le64 (cp_ver); - blk = start_blk + sbi->blocks_per_seg - nm_i->nat_bits_blocks; + blk = start_blk +BLKS_PER_SEG (sbi) - nm_i->nat_bits_blocks;for (i =0 ; i < nm_i->nat_bits_blocks; i++)f2fs_update_meta_page (sbi, nm_i->nat_bits + (i <<F2FS_BLKSIZE_BITS ), blk + i);
@@ -1731,9 +1731,9 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi) im->ino_num =0 ; } - sbi->max_orphans = (sbi->blocks_per_seg -F2FS_CP_PACKS - + sbi->max_orphans = (BLKS_PER_SEG (sbi) -F2FS_CP_PACKS -NR_CURSEG_PERSIST_TYPE -__cp_payload (sbi)) * -F2FS_ORPHANS_PER_BLOCK ; +F2FS_ORPHANS_PER_BLOCK ; }int __init f2fs_create_checkpoint_caches (void )
fs/f2fs/debug.c +3 -3
@@ -41,7 +41,7 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi) total_vblocks =0 ; blks_per_sec =CAP_BLKS_PER_SEC (sbi); hblks_per_sec = blks_per_sec /2 ; -for (segno =0 ; segno <MAIN_SEGS (sbi); segno += sbi->segs_per_sec) { +for (segno =0 ; segno <MAIN_SEGS (sbi); segno +=SEGS_PER_SEC (sbi)) { vblocks =get_valid_blocks (sbi, segno, true); dist =abs (vblocks - hblks_per_sec); bimodal += dist * dist;
@@ -135,7 +135,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) si->cur_ckpt_time = sbi->cprc_info.cur_time; si->peak_ckpt_time = sbi->cprc_info.peak_time;spin_unlock (&sbi->cprc_info.stat_lock); - si->total_count = (int )sbi->user_block_count / sbi->blocks_per_seg; + si->total_count = (int )sbi->user_block_count /BLKS_PER_SEG (sbi); si->rsvd_segs =reserved_segments (sbi); si->overp_segs =overprovision_segments (sbi); si->valid_count =valid_user_blocks (sbi);
@@ -208,7 +208,7 @@ static void update_general_status(struct f2fs_sb_info *sbi)if (!blks)continue ; -if (blks == sbi->blocks_per_seg) +if (blks ==BLKS_PER_SEG (sbi)) si->full_seg[type]++;else si->dirty_seg[type]++;
fs/f2fs/f2fs.h +13 -8
@@ -1808,6 +1808,14 @@ struct f2fs_sb_info {#endif }; +/* Definitions to access f2fs_sb_info */ +#define BLKS_PER_SEG (sbi) \ + ((sbi)->blocks_per_seg) +#define BLKS_PER_SEC (sbi) \ + ((sbi)->segs_per_sec << (sbi)->log_blocks_per_seg) +#define SEGS_PER_SEC (sbi) \ + ((sbi)->segs_per_sec) + __printf(3, 4)void f2fs_printk (struct f2fs_sb_info *sbi,bool limit_rate,const char *fmt, ...);
@@ -2513,11 +2521,8 @@ static inline int get_dirty_pages(struct inode *inode)static inline int get_blocktype_secs (struct f2fs_sb_info *sbi,int block_type) { -unsigned int pages_per_sec = sbi->segs_per_sec * sbi->blocks_per_seg; -unsigned int segs = (get_pages (sbi, block_type) + pages_per_sec -1 ) >> - sbi->log_blocks_per_seg; - -return segs / sbi->segs_per_sec; +return div_u64 (get_pages (sbi, block_type) +BLKS_PER_SEC (sbi) -1 , +BLKS_PER_SEC (sbi)); }static inline block_t valid_user_blocks (struct f2fs_sb_info *sbi)
@@ -2581,7 +2586,7 @@ static inline block_t __start_cp_addr(struct f2fs_sb_info *sbi)block_t start_addr =le32_to_cpu (F2FS_RAW_SUPER (sbi)->cp_blkaddr);if (sbi->cur_cp_pack ==2 ) - start_addr += sbi->blocks_per_seg; + start_addr +=BLKS_PER_SEG (sbi);return start_addr; }
@@ -2590,7 +2595,7 @@ static inline block_t __start_cp_next_addr(struct f2fs_sb_info *sbi)block_t start_addr =le32_to_cpu (F2FS_RAW_SUPER (sbi)->cp_blkaddr);if (sbi->cur_cp_pack ==1 ) - start_addr += sbi->blocks_per_seg; + start_addr +=BLKS_PER_SEG (sbi);return start_addr; }
@@ -3463,7 +3468,7 @@ static inline __le32 *get_dnode_addr(struct inode *inode, sizeof((f2fs_inode)->field)) \ <= (F2FS_OLD_ATTRIBUTE_SIZE + (extra_isize))) \ -#define __is_large_section (sbi) ((sbi)->segs_per_sec > 1) +#define __is_large_section (sbi) (SEGS_PER_SEC(sbi) > 1)#define __is_meta_io (fio) (PAGE_TYPE_OF_BIO((fio)->type) == META)
fs/f2fs/file.c +7 -9
@@ -2578,7 +2578,6 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, .m_may_create = false };struct extent_info ei = {};pgoff_t pg_start, pg_end, next_pgofs; -unsigned int blk_per_seg = sbi->blocks_per_seg;unsigned int total =0 , sec_num;block_t blk_end =0 ;bool fragmented = false;
@@ -2687,7 +2686,8 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,set_inode_flag (inode,FI_SKIP_WRITES ); idx = map.m_lblk; -while (idx < map.m_lblk + map.m_len && cnt < blk_per_seg) { +while (idx < map.m_lblk + map.m_len && + cnt <BLKS_PER_SEG (sbi)) {struct page *page; page =f2fs_get_lock_data_page (inode, idx, true);
@@ -2707,7 +2707,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, map.m_lblk = idx; check: -if (map.m_lblk < pg_end && cnt < blk_per_seg) +if (map.m_lblk < pg_end && cnt <BLKS_PER_SEG (sbi)) goto do_map;clear_inode_flag (inode,FI_SKIP_WRITES );
@@ -2977,8 +2977,8 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)if (!f2fs_is_multi_device (sbi) || sbi->s_ndevs -1 <= range.dev_num ||__is_large_section (sbi)) { -f2fs_warn (sbi,"Can't flush %u in %d for segs_per_sec %u != 1" , - range.dev_num, sbi->s_ndevs, sbi->segs_per_sec); +f2fs_warn (sbi,"Can't flush %u in %d for SEGS_PER_SEC %u != 1" , + range.dev_num, sbi->s_ndevs,SEGS_PER_SEC (sbi));return -EINVAL ; }
@@ -4078,7 +4078,6 @@ static int f2fs_ioc_decompress_file(struct file *filp)struct f2fs_sb_info *sbi =F2FS_I_SB (inode);struct f2fs_inode_info *fi =F2FS_I (inode);pgoff_t page_idx =0 , last_idx; -unsigned int blk_per_seg = sbi->blocks_per_seg;int cluster_size = fi->i_cluster_size;int count, ret;
@@ -4120,7 +4119,7 @@ static int f2fs_ioc_decompress_file(struct file *filp)if (ret <0 )break ; -if (get_dirty_pages (inode) >= blk_per_seg) { +if (get_dirty_pages (inode) >=BLKS_PER_SEG (sbi)) { ret =filemap_fdatawrite (inode->i_mapping);if (ret <0 )break ;
@@ -4155,7 +4154,6 @@ static int f2fs_ioc_compress_file(struct file *filp)struct inode *inode =file_inode (filp);struct f2fs_sb_info *sbi =F2FS_I_SB (inode);pgoff_t page_idx =0 , last_idx; -unsigned int blk_per_seg = sbi->blocks_per_seg;int cluster_size =F2FS_I (inode)->i_cluster_size;int count, ret;
@@ -4196,7 +4194,7 @@ static int f2fs_ioc_compress_file(struct file *filp)if (ret <0 )break ; -if (get_dirty_pages (inode) >= blk_per_seg) { +if (get_dirty_pages (inode) >=BLKS_PER_SEG (sbi)) { ret =filemap_fdatawrite (inode->i_mapping);if (ret <0 )break ;
fs/f2fs/gc.c +20 -20
@@ -259,7 +259,7 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type, p->ofs_unit =1 ; }else { p->gc_mode =select_gc_type (sbi, gc_type); - p->ofs_unit = sbi->segs_per_sec; + p->ofs_unit =SEGS_PER_SEC (sbi);if (__is_large_section (sbi)) { p->dirty_bitmap = dirty_i->dirty_secmap; p->max_search = count_bits(p->dirty_bitmap,
@@ -282,7 +282,8 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,/* let's select beginning hot/small space first in no_heap mode*/ if (f2fs_need_rand_seg (sbi)) - p->offset =get_random_u32_below (MAIN_SECS (sbi) * sbi->segs_per_sec); + p->offset =get_random_u32_below (MAIN_SECS (sbi) * +SEGS_PER_SEC (sbi));else if (test_opt (sbi,NOHEAP ) && (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) p->offset =0 ;
@@ -295,13 +296,13 @@ static unsigned int get_max_cost(struct f2fs_sb_info *sbi, {/* SSR allocates in a segment unit */ if (p->alloc_mode ==SSR ) -return sbi->blocks_per_seg; +return BLKS_PER_SEG (sbi);else if (p->alloc_mode ==AT_SSR )return UINT_MAX ;/* LFS */ if (p->gc_mode ==GC_GREEDY ) -return 2 * sbi->blocks_per_seg * p->ofs_unit; +return 2 *BLKS_PER_SEG (sbi) * p->ofs_unit;else if (p->gc_mode ==GC_CB )return UINT_MAX ;else if (p->gc_mode ==GC_AT )
@@ -496,9 +497,9 @@ static void add_victim_entry(struct f2fs_sb_info *sbi,return ; } -for (i =0 ; i < sbi->segs_per_sec; i++) +for (i =0 ; i <SEGS_PER_SEC (sbi); i++) mtime +=get_seg_entry (sbi, start + i)->mtime; - mtime =div_u64 (mtime, sbi->segs_per_sec); + mtime =div_u64 (mtime,SEGS_PER_SEC (sbi));/* Handle if the system time has changed by the user */ if (mtime < sit_i->min_mtime)
@@ -599,7 +600,6 @@ static void atssr_lookup_victim(struct f2fs_sb_info *sbi,unsigned long long age;unsigned long long max_mtime = sit_i->dirty_max_mtime;unsigned long long min_mtime = sit_i->dirty_min_mtime; -unsigned int seg_blocks = sbi->blocks_per_seg;unsigned int vblocks; unsigned int dirty_threshold = max(am->max_candidate_count, am->candidate_ratio *
@@ -629,7 +629,7 @@ static void atssr_lookup_victim(struct f2fs_sb_info *sbi,f2fs_bug_on (sbi, !vblocks);/* rare case */ -if (vblocks == seg_blocks) +if (vblocks ==BLKS_PER_SEG (sbi)) goto skip_node; iter++;
@@ -755,7 +755,7 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,int ret =0 ;mutex_lock (&dirty_i->seglist_lock); - last_segment =MAIN_SECS (sbi) * sbi->segs_per_sec; + last_segment =MAIN_SECS (sbi) *SEGS_PER_SEC (sbi); p.alloc_mode = alloc_mode; p.age = age;
@@ -896,7 +896,7 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,else sm->last_victim[p.gc_mode] = segno + p.ofs_unit; sm->last_victim[p.gc_mode] %= - (MAIN_SECS (sbi) * sbi->segs_per_sec); + (MAIN_SECS (sbi) *SEGS_PER_SEC (sbi));break ; } }
@@ -1678,7 +1678,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,struct f2fs_summary_block *sum;struct blk_plug plug;unsigned int segno = start_segno; -unsigned int end_segno = start_segno + sbi->segs_per_sec; +unsigned int end_segno = start_segno +SEGS_PER_SEC (sbi);int seg_freed =0 , migrated =0 ;unsigned char type =IS_DATASEG (get_seg_entry (sbi, segno)->type) ?SUM_TYPE_DATA :SUM_TYPE_NODE ;
@@ -1686,7 +1686,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,int submitted =0 ;if (__is_large_section (sbi)) - end_segno =rounddown (end_segno, sbi->segs_per_sec); + end_segno =rounddown (end_segno,SEGS_PER_SEC (sbi));/* * zone-capacity can be less than zone-size in zoned devices,
@@ -1694,7 +1694,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,* calculate the end segno in the zone which can be garbage collected */ if (f2fs_sb_has_blkzoned (sbi)) - end_segno -= sbi->segs_per_sec - + end_segno -=SEGS_PER_SEC (sbi) -f2fs_usable_segs_in_sec (sbi, segno);sanity_check_seg_type (sbi,get_seg_entry (sbi, segno)->type);
@@ -1991,7 +1991,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,/* Force block allocation for GC */ MAIN_SECS (sbi) -= secs; - start =MAIN_SECS (sbi) * sbi->segs_per_sec; + start =MAIN_SECS (sbi) *SEGS_PER_SEC (sbi); end =MAIN_SEGS (sbi) -1 ;mutex_lock (&DIRTY_I (sbi)->seglist_lock);
@@ -2009,7 +2009,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ -for (segno = start; segno <= end; segno += sbi->segs_per_sec) { +for (segno = start; segno <= end; segno +=SEGS_PER_SEC (sbi)) {struct gc_inode_list gc_list = { .ilist =LIST_HEAD_INIT (gc_list.ilist), .iroot =RADIX_TREE_INIT (gc_list.iroot,GFP_NOFS ),
@@ -2053,7 +2053,7 @@ static void update_sb_metadata(struct f2fs_sb_info *sbi, int secs)int segment_count;int segment_count_main;long long block_count; -int segs = secs * sbi->segs_per_sec; +int segs = secs *SEGS_PER_SEC (sbi);f2fs_down_write (&sbi->sb_lock);
@@ -2066,7 +2066,7 @@ static void update_sb_metadata(struct f2fs_sb_info *sbi, int secs) raw_sb->segment_count =cpu_to_le32 (segment_count + segs); raw_sb->segment_count_main =cpu_to_le32 (segment_count_main + segs); raw_sb->block_count =cpu_to_le64 (block_count + - (long long )segs * sbi->blocks_per_seg); + (long long )(segs << sbi->log_blocks_per_seg));if (f2fs_is_multi_device (sbi)) {int last_dev = sbi->s_ndevs -1 ; int dev_segs =
@@ -2081,8 +2081,8 @@ static void update_sb_metadata(struct f2fs_sb_info *sbi, int secs)static void update_fs_metadata (struct f2fs_sb_info *sbi,int secs) { -int segs = secs * sbi->segs_per_sec; -long long blks = (long long )segs * sbi->blocks_per_seg; +int segs = secs *SEGS_PER_SEC (sbi); +long long blks = (long long )segs << sbi->log_blocks_per_seg;long long user_block_count =le64_to_cpu (F2FS_CKPT (sbi)->user_block_count);
@@ -2124,7 +2124,7 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)int last_dev = sbi->s_ndevs -1 ;__u64 last_segs =FDEV (last_dev).total_segments; -if (block_count + last_segs * sbi->blocks_per_seg <= +if (block_count + (last_segs << sbi->log_blocks_per_seg) <= old_block_count)return -EINVAL ; }
fs/f2fs/node.c +2 -2
@@ -2849,7 +2849,7 @@ int f2fs_restore_node_summary(struct f2fs_sb_info *sbi,int i, idx, last_offset, nrpages;/* scan the node segment */ - last_offset = sbi->blocks_per_seg; + last_offset =BLKS_PER_SEG (sbi); addr =START_BLOCK (sbi, segno); sum_entry = &sum->entries[0 ];
@@ -3166,7 +3166,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)if (!is_set_ckpt_flags (sbi,CP_NAT_BITS_FLAG ))return 0 ; - nat_bits_addr =__start_cp_addr (sbi) + sbi->blocks_per_seg - + nat_bits_addr =__start_cp_addr (sbi) +BLKS_PER_SEG (sbi) - nm_i->nat_bits_blocks;for (i =0 ; i < nm_i->nat_bits_blocks; i++) {struct page *page;
fs/f2fs/node.h +2 -2
@@ -208,10 +208,10 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start) block_addr = (pgoff_t)(nm_i->nat_blkaddr + (block_off <<1 ) - - (block_off & (sbi->blocks_per_seg -1 ))); + (block_off & (BLKS_PER_SEG (sbi) -1 )));if (f2fs_test_bit (block_off, nm_i->nat_bitmap)) - block_addr += sbi->blocks_per_seg; + block_addr +=BLKS_PER_SEG (sbi);return block_addr; }
fs/f2fs/recovery.c +1 -1
@@ -354,7 +354,7 @@ static unsigned int adjust_por_ra_blocks(struct f2fs_sb_info *sbi,if (blkaddr +1 == next_blkaddr) ra_blocks = min_t(unsigned int, RECOVERY_MAX_RA_BLOCKS, ra_blocks *2 ); -else if (next_blkaddr % sbi->blocks_per_seg) +else if (next_blkaddr %BLKS_PER_SEG (sbi)) ra_blocks = max_t(unsigned int, RECOVERY_MIN_RA_BLOCKS, ra_blocks /2 );return ra_blocks;
fs/f2fs/segment.c +54 -56
309 lines not on this page · raw message
fs/f2fs/segment.h +21 -23
106 lines not on this page · raw message
fs/f2fs/super.c +4 -4
@@ -3701,7 +3701,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) } main_segs =le32_to_cpu (raw_super->segment_count_main); - blocks_per_seg = sbi->blocks_per_seg; + blocks_per_seg =BLKS_PER_SEG (sbi);for (i =0 ; i <NR_CURSEG_NODE_TYPE ; i++) { if (le32_to_cpu(ckpt->cur_node_segno[i]) >= main_segs ||
@@ -3814,8 +3814,8 @@ static void init_sb_info(struct f2fs_sb_info *sbi) sbi->secs_per_zone =le32_to_cpu (raw_super->secs_per_zone); sbi->total_sections =le32_to_cpu (raw_super->section_count); sbi->total_node_count = - (le32_to_cpu (raw_super->segment_count_nat) /2 ) - * sbi->blocks_per_seg *NAT_ENTRY_PER_BLOCK ; + ((le32_to_cpu (raw_super->segment_count_nat) /2 ) * +NAT_ENTRY_PER_BLOCK ) << sbi->log_blocks_per_seg;F2FS_ROOT_INO (sbi) =le32_to_cpu (raw_super->root_ino);F2FS_NODE_INO (sbi) =le32_to_cpu (raw_super->node_ino);F2FS_META_INO (sbi) =le32_to_cpu (raw_super->meta_ino);
@@ -3824,7 +3824,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi) sbi->next_victim_seg[BG_GC ] =NULL_SEGNO ; sbi->next_victim_seg[FG_GC ] =NULL_SEGNO ; sbi->max_victim_search =DEF_MAX_VICTIM_SEARCH ; - sbi->migration_granularity = sbi->segs_per_sec; + sbi->migration_granularity =SEGS_PER_SEC (sbi); sbi->seq_file_ra_mul =MIN_RA_MUL ; sbi->max_fragment_chunk =DEF_FRAGMENT_SIZE ; sbi->max_fragment_hole =DEF_FRAGMENT_SIZE ;
fs/f2fs/sysfs.c +3 -3
@@ -466,8 +466,8 @@ static ssize_t __sbi_store(struct f2fs_attr *a,spin_lock (&sbi->stat_lock);if (t > (unsigned long )(sbi->user_block_count -F2FS_OPTION (sbi).root_reserved_blocks - - sbi->blocks_per_seg * -SM_I (sbi)->additional_reserved_segments)) { + (SM_I (sbi)->additional_reserved_segments << + sbi->log_blocks_per_seg))) {spin_unlock (&sbi->stat_lock);return -EINVAL ; }
@@ -517,7 +517,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a, }if (!strcmp (a->attr.name,"migration_granularity" )) { -if (t ==0 || t > sbi->segs_per_sec) +if (t ==0 || t >SEGS_PER_SEC (sbi))return -EINVAL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 503/744 f2fs: separate f2fs_gc_range() to use GC for a range
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 2f0209f579d12bd0ea43a01a8696e30a8eeec1da ]
Make f2fs_gc_range() an extenal function to use it for GC for a range.
Stable-dep-of: aa4074e8fec4 ("f2fs: fix block migration when section is not aligned to pow2")
--- fs/f2fs/gc.c | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-)
fs/f2fs/gc.c +28 -21
@@ -1980,10 +1980,34 @@ void f2fs_build_gc_manager(struct f2fs_sb_info *sbi)init_atgc_management (sbi); } +static int f2fs_gc_range (struct f2fs_sb_info *sbi, +unsigned int start_seg,unsigned int end_seg,bool dry_run) +{ +unsigned int segno; + +for (segno = start_seg; segno <= end_seg; segno +=SEGS_PER_SEC (sbi)) { +struct gc_inode_list gc_list = { + .ilist =LIST_HEAD_INIT (gc_list.ilist), + .iroot =RADIX_TREE_INIT (gc_list.iroot,GFP_NOFS ), + }; + +do_garbage_collect (sbi, segno, &gc_list,FG_GC , true); +put_gc_inode (&gc_list); + +if (!dry_run &&get_valid_blocks (sbi, segno, true)) +return -EAGAIN ; + +if (fatal_signal_pending (current)) +return -ERESTARTSYS ; + } + +return 0 ; +} +static int free_segment_range (struct f2fs_sb_info *sbi, -unsigned int secs,bool gc_only) +unsigned int secs,bool dry_run) { -unsigned int segno, next_inuse, start, end; +unsigned int next_inuse, start, end;struct cp_control cpc = {CP_RESIZE ,0 ,0 ,0 };int gc_mode, gc_type;int err =0 ;
@@ -2009,25 +2033,8 @@ static int free_segment_range(struct f2fs_sb_info *sbi,f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ -for (segno = start; segno <= end; segno +=SEGS_PER_SEC (sbi)) { -struct gc_inode_list gc_list = { - .ilist =LIST_HEAD_INIT (gc_list.ilist), - .iroot =RADIX_TREE_INIT (gc_list.iroot,GFP_NOFS ), - }; - -do_garbage_collect (sbi, segno, &gc_list,FG_GC , true); -put_gc_inode (&gc_list); - -if (!gc_only &&get_valid_blocks (sbi, segno, true)) { - err = -EAGAIN ; - goto out; - } -if (fatal_signal_pending (current)) { - err = -ERESTARTSYS ; - goto out; - } - } -if (gc_only) + err =f2fs_gc_range (sbi, start, end, dry_run); +if (err || dry_run) goto out;stat_inc_cp_call_count (sbi,TOTAL_CALL );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 504/744 f2fs: kill heap-based allocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
[ Upstream commit 4e0197f9932f70cc7be8744aa0ed4dd9b5d97d85 ]
No one uses this feature. Let's kill it.
Stable-dep-of: aa4074e8fec4 ("f2fs: fix block migration when section is not aligned to pow2")
--- Documentation/filesystems/f2fs.rst | 4 +-- fs/f2fs/gc.c | 5 ++- fs/f2fs/segment.c | 54 ++++-------------------------- fs/f2fs/segment.h | 10 ------ fs/f2fs/super.c | 9 +---- 5 files changed, 11 insertions(+), 71 deletions(-)
Documentation/filesystems/f2fs.rst +1 -3
@@ -126,9 +126,7 @@ norecovery Disable the roll-forward recovery routine, mounted read- discard/nodiscard Enable/disable real-time discard in f2fs, if discard is enabled, f2fs will issue discard/TRIM commands when a segment is cleaned. -no_heap Disable heap-style segment allocation which finds free - segments for data from the beginning of main area, while - for node from the end of main area. +heap/no_heap Deprecated. nouser_xattr Disable Extended User Attributes. Note: xattr is enabled by default if CONFIG_F2FS_FS_XATTR is selected. noacl Disable POSIX Access Control List. Note: acl is enabled
fs/f2fs/gc.c +2 -3
@@ -280,12 +280,11 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type, p->max_search > sbi->max_victim_search) p->max_search = sbi->max_victim_search; -/* let's select beginning hot/small space first in no_heap mode*/ +/* let's select beginning hot/small space first. */ if (f2fs_need_rand_seg (sbi)) p->offset =get_random_u32_below (MAIN_SECS (sbi) *SEGS_PER_SEC (sbi)); -else if (test_opt (sbi,NOHEAP ) && - (type ==CURSEG_HOT_DATA ||IS_NODESEG (type))) +else if (type ==CURSEG_HOT_DATA ||IS_NODESEG (type)) p->offset =0 ;else p->offset =SIT_I (sbi)->last_victim[p->gc_mode];
fs/f2fs/segment.c +7 -47
103 lines not on this page · raw message
fs/f2fs/segment.h +0 -10
@@ -136,16 +136,6 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,#define SECTOR_TO_BLOCK (sectors) \ ((sectors) >> F2FS_LOG_SECTORS_PER_BLOCK) -/* -* indicate a block allocation direction: RIGHT and LEFT. -* RIGHT means allocating new sections towards the end of volume. -* LEFT means the opposite direction. -*/ -enum { -ALLOC_RIGHT =0 , -ALLOC_LEFT -}; -/* * In the victim_sel_policy->alloc_mode, there are three block allocation modes. * LFS writes data sequentially with cleaning operations.
fs/f2fs/super.c +1 -8
@@ -759,10 +759,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)clear_opt (sbi,DISCARD );break ;case Opt_noheap: -set_opt (sbi,NOHEAP ); -break ;case Opt_heap: -clear_opt (sbi,NOHEAP ); +f2fs_warn (sbi,"heap/no_heap options were deprecated" );break ;#ifdef CONFIG_F2FS_FS_XATTR case Opt_user_xattr:
@@ -2013,10 +2011,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) }else {seq_puts (seq,",nodiscard" ); } -if (test_opt (sbi,NOHEAP )) -seq_puts (seq,",no_heap" ); -else -seq_puts (seq,",heap" );#ifdef CONFIG_F2FS_FS_XATTR if (test_opt (sbi,XATTR_USER ))seq_puts (seq,",user_xattr" );
@@ -2196,7 +2190,6 @@ static void default_options(struct f2fs_sb_info *sbi, bool remount)set_opt (sbi,INLINE_XATTR );set_opt (sbi,INLINE_DATA );set_opt (sbi,INLINE_DENTRY ); -set_opt (sbi,NOHEAP );set_opt (sbi,MERGE_CHECKPOINT );F2FS_OPTION (sbi).unusable_cap =0 ; sbi->sb->s_flags |=SB_LAZYTIME ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 505/744 f2fs: support file pinning for zoned devices
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 9703d69d9d153bb230711d0d577454552aeb13d4 ]
Support file pinning with conventional storage area for zoned devices
Stable-dep-of: aa4074e8fec4 ("f2fs: fix block migration when section is not aligned to pow2")
--- fs/f2fs/data.c | 58 ++++++++++++++++++++++++++------------- fs/f2fs/f2fs.h | 17 +++++++++++- fs/f2fs/file.c | 24 ++++++++++++----- fs/f2fs/gc.c | 14 +++++++--- fs/f2fs/segment.c | 69 +++++++++++++++++++++++++++++++++++++++++------ fs/f2fs/segment.h | 10 +++++++ 6 files changed, 154 insertions(+), 38 deletions(-)
fs/f2fs/data.c +39 -19
@@ -3905,25 +3905,34 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk,unsigned int blkofs;unsigned int blk_per_sec =BLKS_PER_SEC (sbi);unsigned int secidx = start_blk / blk_per_sec; -unsigned int end_sec = secidx + blkcnt / blk_per_sec; +unsigned int end_sec;int ret =0 ; +if (!blkcnt) +return 0 ; + end_sec = secidx + (blkcnt -1 ) / blk_per_sec; +f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping);set_inode_flag (inode,FI_ALIGNED_WRITE );set_inode_flag (inode,FI_OPU_WRITE ); -for (; secidx < end_sec; secidx++) { +for (; secidx <= end_sec; secidx++) { +unsigned int blkofs_end = secidx == end_sec ? + (blkcnt -1 ) % blk_per_sec : blk_per_sec -1 ; +f2fs_down_write (&sbi->pin_sem); -f2fs_lock_op (sbi); -f2fs_allocate_new_section (sbi,CURSEG_COLD_DATA_PINNED , false); -f2fs_unlock_op (sbi); + ret =f2fs_allocate_pinning_section (sbi); +if (ret) { +f2fs_up_write (&sbi->pin_sem); +break ; + }set_inode_flag (inode,FI_SKIP_WRITES ); -for (blkofs =0 ; blkofs < blk_per_sec; blkofs++) { +for (blkofs =0 ; blkofs <= blkofs_end; blkofs++) {struct page *page;unsigned int blkidx = secidx * blk_per_sec + blkofs;
@@ -4012,27 +4021,34 @@ static int check_swap_activate(struct swap_info_struct *sis, nr_pblocks = map.m_len;if ((pblock -SM_I (sbi)->main_blkaddr) & sec_blks_mask || - nr_pblocks & sec_blks_mask) { + nr_pblocks & sec_blks_mask || + !f2fs_valid_pinned_area (sbi, pblock)) { +bool last_extent = false; + not_aligned++; nr_pblocks =roundup (nr_pblocks, blks_per_sec);if (cur_lblock + nr_pblocks > sis->max) nr_pblocks -= blks_per_sec; +/* this extent is last one */ if (!nr_pblocks) { -/* this extent is last one */ - nr_pblocks = map.m_len; -f2fs_warn (sbi,"Swapfile: last extent is not aligned to section" ); - goto next; + nr_pblocks = last_lblock - cur_lblock; + last_extent = true; } ret =f2fs_migrate_blocks (inode, cur_lblock, nr_pblocks); -if (ret) +if (ret) { +if (ret == -ENOENT ) + ret = -EINVAL ; goto out; - goto retry; + } + +if (!last_extent) + goto retry; } -next: +if (cur_lblock + nr_pblocks >= sis->max) nr_pblocks = sis->max - cur_lblock;
@@ -4070,17 +4086,17 @@ static int f2fs_swap_activate(struct swap_info_struct *sis, struct file *file, sector_t *span) {struct inode *inode =file_inode (file); +struct f2fs_sb_info *sbi =F2FS_I_SB (inode);int ret;if (!S_ISREG (inode->i_mode))return -EINVAL ; -if (f2fs_readonly (F2FS_I_SB (inode)->sb)) +if (f2fs_readonly (sbi->sb))return -EROFS ; -if (f2fs_lfs_mode (F2FS_I_SB (inode))) { -f2fs_err (F2FS_I_SB (inode), -"Swapfile not supported in LFS mode" ); +if (f2fs_lfs_mode (sbi) && !f2fs_sb_has_blkzoned (sbi)) { +f2fs_err (sbi,"Swapfile not supported in LFS mode" );return -EINVAL ; }
@@ -4093,13 +4109,17 @@ static int f2fs_swap_activate(struct swap_info_struct *sis, struct file *file,f2fs_precache_extents (inode); + ret =filemap_fdatawrite (inode->i_mapping); +if (ret <0 ) +return ret; + ret =check_swap_activate (sis, file, span);if (ret <0 )return ret;stat_inc_swapfile_inode (inode);set_inode_flag (inode,FI_PIN_FILE ); -f2fs_update_time (F2FS_I_SB (inode),REQ_TIME ); +f2fs_update_time (sbi,REQ_TIME );return ret; }
fs/f2fs/f2fs.h +16 -1
@@ -3704,7 +3704,8 @@ void f2fs_get_new_segment(struct f2fs_sb_info *sbi, unsigned int *newseg, bool new_sec, int dir);void f2fs_allocate_segment_for_resize (struct f2fs_sb_info *sbi,int type,unsigned int start,unsigned int end); -void f2fs_allocate_new_section (struct f2fs_sb_info *sbi,int type,bool force); +int f2fs_allocate_new_section (struct f2fs_sb_info *sbi,int type,bool force); +int f2fs_allocate_pinning_section (struct f2fs_sb_info *sbi);void f2fs_allocate_new_segments (struct f2fs_sb_info *sbi);int f2fs_trim_fs (struct f2fs_sb_info *sbi,struct fstrim_range *range); bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi,
@@ -3880,6 +3881,9 @@ void f2fs_stop_gc_thread(struct f2fs_sb_info *sbi);block_t f2fs_start_bidx_of_node (unsigned int node_ofs,struct inode *inode);int f2fs_gc (struct f2fs_sb_info *sbi,struct f2fs_gc_control *gc_control);void f2fs_build_gc_manager (struct f2fs_sb_info *sbi); +int f2fs_gc_range (struct f2fs_sb_info *sbi, +unsigned int start_seg,unsigned int end_seg, +bool dry_run,unsigned int dry_run_sections);int f2fs_resize_fs (struct file *filp,__u64 block_count);int __init f2fs_create_garbage_collection_cache (void );void f2fs_destroy_garbage_collection_cache (void );
@@ -4536,6 +4540,17 @@ static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi)return F2FS_OPTION (sbi).fs_mode ==FS_MODE_LFS ; } +static inline bool f2fs_valid_pinned_area (struct f2fs_sb_info *sbi, +block_t blkaddr) +{ +if (f2fs_sb_has_blkzoned (sbi)) { +int devi =f2fs_target_device_index (sbi, blkaddr); + +return !bdev_is_zoned (FDEV (devi).bdev); + } +return true; +} +static inline bool f2fs_low_mem_mode (struct f2fs_sb_info *sbi) {return F2FS_OPTION (sbi).memory_mode ==MEMORY_MODE_LOW ;
fs/f2fs/file.c +18 -6
@@ -1729,9 +1729,11 @@ static int f2fs_expand_inode_data(struct inode *inode, loff_t offset,f2fs_down_write (&sbi->pin_sem); -f2fs_lock_op (sbi); -f2fs_allocate_new_section (sbi,CURSEG_COLD_DATA_PINNED , false); -f2fs_unlock_op (sbi); + err =f2fs_allocate_pinning_section (sbi); +if (err) { +f2fs_up_write (&sbi->pin_sem); + goto out_err; + } map.m_seg_type =CURSEG_COLD_DATA_PINNED ; err =f2fs_map_blocks (inode, &map,F2FS_GET_BLOCK_PRE_DIO );
@@ -3184,6 +3186,7 @@ int f2fs_pin_file_control(struct inode *inode, bool inc)static int f2fs_ioc_set_pin_file (struct file *filp,unsigned long arg) {struct inode *inode =file_inode (filp); +struct f2fs_sb_info *sbi =F2FS_I_SB (inode);__u32 pin;int ret =0 ;
@@ -3193,7 +3196,7 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)if (!S_ISREG (inode->i_mode))return -EINVAL ; -if (f2fs_readonly (F2FS_I_SB (inode)->sb)) +if (f2fs_readonly (sbi->sb))return -EROFS ; ret =mnt_want_write_file (filp);
@@ -3206,9 +3209,18 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)clear_inode_flag (inode,FI_PIN_FILE );f2fs_i_gc_failures_write (inode,0 ); goto done; + }else if (f2fs_is_pinned_file (inode)) { + goto done; } -if (f2fs_should_update_outplace (inode,NULL )) { +if (f2fs_sb_has_blkzoned (sbi) &&F2FS_HAS_BLOCKS (inode)) { + ret = -EFBIG ; + goto out; + } + +/* Let's allow file pinning on zoned device. */ +if (!f2fs_sb_has_blkzoned (sbi) && +f2fs_should_update_outplace (inode,NULL )) { ret = -EINVAL ; goto out; }
@@ -3230,7 +3242,7 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)set_inode_flag (inode,FI_PIN_FILE ); ret =F2FS_I (inode)->i_gc_failures[GC_FAILURE_PIN ]; done: -f2fs_update_time (F2FS_I_SB (inode),REQ_TIME ); +f2fs_update_time (sbi,REQ_TIME ); out:inode_unlock (inode);mnt_drop_write_file (filp);
fs/f2fs/gc.c +10 -4
@@ -1979,10 +1979,12 @@ void f2fs_build_gc_manager(struct f2fs_sb_info *sbi)init_atgc_management (sbi); } -static int f2fs_gc_range (struct f2fs_sb_info *sbi, -unsigned int start_seg,unsigned int end_seg,bool dry_run) +int f2fs_gc_range (struct f2fs_sb_info *sbi, +unsigned int start_seg,unsigned int end_seg, +bool dry_run,unsigned int dry_run_sections) {unsigned int segno; +unsigned int gc_secs = dry_run_sections;for (segno = start_seg; segno <= end_seg; segno +=SEGS_PER_SEC (sbi)) { struct gc_inode_list gc_list = {
@@ -1990,11 +1992,15 @@ static int f2fs_gc_range(struct f2fs_sb_info *sbi, .iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS), }; -do_garbage_collect (sbi, segno, &gc_list,FG_GC , true); +do_garbage_collect (sbi, segno, &gc_list,FG_GC , + dry_run_sections ==0 );put_gc_inode (&gc_list);if (!dry_run &&get_valid_blocks (sbi, segno, true))return -EAGAIN ; +if (dry_run && dry_run_sections && + !get_valid_blocks (sbi, segno, true) && --gc_secs ==0 ) +break ;if (fatal_signal_pending (current))return -ERESTARTSYS ;
@@ -2032,7 +2038,7 @@ static int free_segment_range(struct f2fs_sb_info *sbi,f2fs_allocate_segment_for_resize (sbi, type, start, end);/* do GC to move out valid blocks in the range */ - err =f2fs_gc_range (sbi, start, end, dry_run); + err =f2fs_gc_range (sbi, start, end, dry_run,0 );if (err || dry_run) goto out;
fs/f2fs/segment.c +61 -8
135 lines not on this page · raw message
fs/f2fs/segment.h +10 -0
@@ -956,3 +956,13 @@ static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force) dcc->discard_wake = true;wake_up_interruptible_all (&dcc->discard_wait_queue); } + +static inline unsigned int first_zoned_segno (struct f2fs_sb_info *sbi) +{ +int devi; + +for (devi =0 ; devi < sbi->s_ndevs; devi++) +if (bdev_is_zoned (FDEV (devi).bdev)) +return GET_SEGNO (sbi,FDEV (devi).start_blk); +return 0 ; +}
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 506/744 f2fs: fix block migration when section is not aligned to pow2
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wu Bo <[email protected]>
[ Upstream commit aa4074e8fec4d2e686daee627fcafb3503efe365 ]
As for zoned-UFS, f2fs section size is forced to zone size. And zone size may not aligned to pow2.
--- fs/f2fs/data.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
fs/f2fs/data.c +8 -9
@@ -3974,15 +3974,14 @@ static int check_swap_activate(struct swap_info_struct *sis,struct address_space *mapping = swap_file->f_mapping;struct inode *inode = mapping->host;struct f2fs_sb_info *sbi =F2FS_I_SB (inode); -sector_t cur_lblock; -sector_t last_lblock; -sector_t pblock; -sector_t lowest_pblock =-1 ; -sector_t highest_pblock =0 ; +block_t cur_lblock; +block_t last_lblock; +block_t pblock; +block_t lowest_pblock =-1 ; +block_t highest_pblock =0 ;int nr_extents =0 ; -unsigned long nr_pblocks; +unsigned int nr_pblocks;unsigned int blks_per_sec =BLKS_PER_SEC (sbi); -unsigned int sec_blks_mask =BLKS_PER_SEC (sbi) -1 ;unsigned int not_aligned =0 ;int ret =0 ;
@@ -4020,8 +4019,8 @@ static int check_swap_activate(struct swap_info_struct *sis, pblock = map.m_pblk; nr_pblocks = map.m_len; -if ((pblock -SM_I (sbi)->main_blkaddr) & sec_blks_mask || - nr_pblocks & sec_blks_mask || +if ((pblock -SM_I (sbi)->main_blkaddr) % blks_per_sec || + nr_pblocks % blks_per_sec || !f2fs_valid_pinned_area (sbi, pblock)) {bool last_extent = false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 507/744 perf ui browser: Avoid SEGV on title
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 90f01afb0dfafbc9b094bb61e61a4ac297d9d0d2 ]
If the title is NULL then it can lead to a SEGV.
--- tools/perf/ui/browser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/ui/browser.c +1 -1
@@ -203,7 +203,7 @@ void ui_browser__refresh_dimensions(struct ui_browser *browser)void ui_browser__handle_resize (struct ui_browser *browser) {ui__refresh_dimensions (false); -ui_browser__show (browser, browser->title, ui_helpline__current); +ui_browser__show (browser, browser->title ?:"" , ui_helpline__current);ui_browser__refresh (browser); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 508/744 perf report: Avoid SEGV in report__setup_sample_type()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 45b4f402a6b782352c4bafcff682bfb01da9ca05 ]
In some cases evsel->name is lazily initialized in evsel__name(). If not initialized passing NULL to strstr() leads to a SEGV.
--- tools/perf/builtin-report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-report.c +1 -1
@@ -426,7 +426,7 @@ static int report__setup_sample_type(struct report *rep)* compatibility, set the bit if it's an old perf data file. */ evlist__for_each_entry (session->evlist, evsel) { -if (strstr (evsel->name,"arm_spe" ) && +if (strstr (evsel__name (evsel),"arm_spe" ) && !(sample_type &PERF_SAMPLE_DATA_SRC )) { evsel->core.attr.sample_type |=PERF_SAMPLE_DATA_SRC ; sample_type |=PERF_SAMPLE_DATA_SRC ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 509/744 perf thread: Fixes to thread__new() related to initializing comm
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 3536c2575e88a890cf696b4ccd3da36bc937853b ]
Freeing the thread on failure won't work with reference count checking, use thread__delete().
Don't allocate the comm_str, use a stack allocation instead.
--- tools/perf/util/thread.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
tools/perf/util/thread.c +5 -9
@@ -39,12 +39,13 @@ int thread__init_maps(struct thread *thread, struct machine *machine)struct thread *thread__new (pid_t pid,pid_t tid) { -char *comm_str; -struct comm *comm;RC_STRUCT (thread) *_thread =zalloc (sizeof (*_thread));struct thread *thread;if (ADD_RC_CHK (thread, _thread) !=NULL ) { +struct comm *comm; +char comm_str[32 ]; +thread__set_pid (thread, pid);thread__set_tid (thread, tid);thread__set_ppid (thread,-1 );
@@ -56,13 +57,8 @@ struct thread *thread__new(pid_t pid, pid_t tid)init_rwsem (thread__namespaces_lock (thread));init_rwsem (thread__comm_lock (thread)); - comm_str =malloc (32 ); -if (!comm_str) - goto err_thread; - -snprintf (comm_str,32 ,":%d" , tid); +snprintf (comm_str,sizeof (comm_str),":%d" , tid); comm =comm__new (comm_str,0 , false); -free (comm_str);if (!comm) goto err_thread;
@@ -76,7 +72,7 @@ struct thread *thread__new(pid_t pid, pid_t tid)return thread; err_thread: -free (thread); +thread__delete (thread);return NULL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 510/744 perf maps: Move symbol maps functions to maps.c
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 0f6ab6a3fb7e380a1277f8288f315724ed517114 ]
Move the find and certain other symbol maps__* functions to maps.c for better abstraction.
Stable-dep-of: 25626e19ae6d ("perf symbols: Fix ownership of string in dso__load_vmlinux()")
--- tools/perf/util/maps.c | 238 +++++++++++++++++++++++++++++++++++++ tools/perf/util/maps.h | 12 ++ tools/perf/util/symbol.c | 248 --------------------------------------- tools/perf/util/symbol.h | 1 - 4 files changed, 250 insertions(+), 249 deletions(-)
tools/perf/util/maps.c +238 -0
@@ -475,3 +475,241 @@ struct map_rb_node *map_rb_node__next(struct map_rb_node *node) return rb_entry(next, struct map_rb_node, rb_node); } + +static int map__strcmp (const void *a,const void *b) +{ +const struct map *map_a = *(const struct map **)a; +const struct map *map_b = *(const struct map **)b; +const struct dso *dso_a =map__dso (map_a); +const struct dso *dso_b =map__dso (map_b); +int ret =strcmp (dso_a->short_name, dso_b->short_name); + +if (ret ==0 && map_a != map_b) { +/* +* Ensure distinct but name equal maps have an order in part to +* aid reference counting. +*/ + ret = (int )map__start (map_a) - (int )map__start (map_b); +if (ret ==0 ) + ret = (int )((intptr_t )map_a - (intptr_t )map_b); + } + +return ret; +} + +static int map__strcmp_name (const void *name,const void *b) +{ +const struct dso *dso =map__dso (*(const struct map **)b); + +return strcmp (name, dso->short_name); +} + +void __maps__sort_by_name (struct maps *maps) +{ +qsort (maps__maps_by_name (maps),maps__nr_maps (maps),sizeof (struct map *), map__strcmp); +} + +static int map__groups__sort_by_name_from_rbtree (struct maps *maps) +{ +struct map_rb_node *rb_node; +struct map **maps_by_name =realloc (maps__maps_by_name (maps), +maps__nr_maps (maps) *sizeof (struct map *)); +int i =0 ; + +if (maps_by_name ==NULL ) +return -1 ; + +up_read (maps__lock (maps)); +down_write (maps__lock (maps)); + +RC_CHK_ACCESS (maps)->maps_by_name = maps_by_name; +RC_CHK_ACCESS (maps)->nr_maps_allocated =maps__nr_maps (maps); + +maps__for_each_entry (maps, rb_node) + maps_by_name[i++] =map__get (rb_node->map); + +__maps__sort_by_name (maps); + +up_write (maps__lock (maps)); +down_read (maps__lock (maps)); + +return 0 ; +} + +static struct map *__maps__find_by_name (struct maps *maps,const char *name) +{ +struct map **mapp; + +if (maps__maps_by_name (maps) ==NULL && +map__groups__sort_by_name_from_rbtree (maps)) +return NULL ; + + mapp =bsearch (name,maps__maps_by_name (maps),maps__nr_maps (maps), +sizeof (*mapp), map__strcmp_name); +if (mapp) +return *mapp; +return NULL ; +} + +struct map *maps__find_by_name (struct maps *maps,const char *name) +{ +struct map_rb_node *rb_node; +struct map *map; + +down_read (maps__lock (maps)); + + +if (RC_CHK_ACCESS (maps)->last_search_by_name) { +const struct dso *dso =map__dso (RC_CHK_ACCESS (maps)->last_search_by_name); + +if (strcmp (dso->short_name, name) ==0 ) { + map =RC_CHK_ACCESS (maps)->last_search_by_name; + goto out_unlock; + } + } +/* +* If we have maps->maps_by_name, then the name isn't in the rbtree, +* as maps->maps_by_name mirrors the rbtree when lookups by name are +* made. +*/ + map =__maps__find_by_name (maps, name); +if (map ||maps__maps_by_name (maps) !=NULL ) + goto out_unlock; + +/* Fallback to traversing the rbtree... */ +maps__for_each_entry (maps, rb_node) { +struct dso *dso; + + map = rb_node->map; + dso =map__dso (map); +if (strcmp (dso->short_name, name) ==0 ) { +RC_CHK_ACCESS (maps)->last_search_by_name = map; + goto out_unlock; + } + } + map =NULL ; + +out_unlock: +up_read (maps__lock (maps)); +return map; +} + +void maps__fixup_end (struct maps *maps) +{ +struct map_rb_node *prev =NULL , *curr; + +down_write (maps__lock (maps)); + +maps__for_each_entry (maps, curr) { +if (prev !=NULL && !map__end (prev->map)) +map__set_end (prev->map,map__start (curr->map)); + + prev = curr; + } + +/* +* We still haven't the actual symbols, so guess the +* last map final address. +*/ +if (curr && !map__end (curr->map)) +map__set_end (curr->map, ~0ULL ); + +up_write (maps__lock (maps)); +} + +/* +* Merges map into maps by splitting the new map within the existing map +* regions. +*/ +int maps__merge_in (struct maps *kmaps,struct map *new_map) +{ +struct map_rb_node *rb_node; +LIST_HEAD (merged); +int err =0 ; + +maps__for_each_entry (kmaps, rb_node) { +struct map *old_map = rb_node->map; + +/* no overload with this one */ +if (map__end (new_map) <map__start (old_map) || +map__start (new_map) >=map__end (old_map)) +continue ; + +if (map__start (new_map) <map__start (old_map)) { +/* +* |new...... +* |old.... +*/ +if (map__end (new_map) <map__end (old_map)) { +/* +* |new......| -> |new..| +* |old....| -> |old....| +*/ +map__set_end (new_map,map__start (old_map)); + }else { +/* +* |new.............| -> |new..| |new..| +* |old....| -> |old....| +*/ +struct map_list_node *m =map_list_node__new (); + +if (!m) { + err = -ENOMEM ; + goto out; + } + + m->map =map__clone (new_map); +if (!m->map) { +free (m); + err = -ENOMEM ; + goto out; + } + +map__set_end (m->map,map__start (old_map)); +list_add_tail (&m->node, &merged); +map__add_pgoff (new_map,map__end (old_map) -map__start (new_map)); +map__set_start (new_map,map__end (old_map)); + } + }else { +/* +* |new...... +* |old.... +*/ +if (map__end (new_map) <map__end (old_map)) { +/* +* |new..| -> x +* |old.........| -> |old.........| +*/ +map__put (new_map); + new_map =NULL ; +break ; + }else { +/* +* |new......| -> |new...| +* |old....| -> |old....| +*/ +map__add_pgoff (new_map,map__end (old_map) -map__start (new_map)); +map__set_start (new_map,map__end (old_map)); + } + } + } + +out: +while (!list_empty (&merged)) { +struct map_list_node *old_node; + + old_node = list_entry(merged.next, struct map_list_node, node); +list_del_init (&old_node->node); +if (!err) + err =maps__insert (kmaps, old_node->map); +map__put (old_node->map); +free (old_node); + } + +if (new_map) { +if (!err) + err =maps__insert (kmaps, new_map); +map__put (new_map); + } +return err; +}
tools/perf/util/maps.h +12 -0
@@ -21,6 +21,16 @@ struct map_rb_node {struct map *map; }; +struct map_list_node { +struct list_head node; +struct map *map; +}; + +static inline struct map_list_node *map_list_node__new (void ) +{ +return malloc (sizeof (struct map_list_node )); +} +struct map_rb_node *maps__first (struct maps *maps);struct map_rb_node *map_rb_node__next (struct map_rb_node *node);struct map_rb_node *maps__find_node (struct maps *maps,struct map *map);
@@ -133,4 +143,6 @@ int maps__merge_in(struct maps *kmaps, struct map *new_map);void __maps__sort_by_name (struct maps *maps); +void maps__fixup_end (struct maps *maps); +#endif // __PERF_MAPS_H
tools/perf/util/symbol.c +0 -248
278 lines not on this page · raw message
tools/perf/util/symbol.h +0 -1
@@ -189,7 +189,6 @@ void __symbols__insert(struct rb_root_cached *symbols, struct symbol *sym,void symbols__insert (struct rb_root_cached *symbols,struct symbol *sym);void symbols__fixup_duplicate (struct rb_root_cached *symbols);void symbols__fixup_end (struct rb_root_cached *symbols,bool is_kallsyms); -void maps__fixup_end (struct maps *maps);typedef int (*mapfn_t )(u64 start,u64 len,u64 pgoff,void *data); int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 511/744 perf symbols: Fix ownership of string in dso__load_vmlinux()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit 25626e19ae6df34f336f235b6b3dbd1b566d2738 ]
The linked commit updated dso__load_vmlinux() to call dso__set_long_name() before loading the symbols. Loading the symbols may not succeed but dso__set_long_name() takes ownership of the string. The two callers of this function free the string themselves on failure cases, resulting in the following error:
$ perf record -- ls $ perf report
free(): double free detected in tcache 2
Fix it by always taking ownership of the string, even on failure. This means the string is either freed at the very first early exit condition, or later when the dso is deleted or the long name is replaced. Now no special return value is needed to signify that the caller needs to free the string.
--- tools/perf/util/symbol.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/perf/util/symbol.c +8 -3
@@ -1935,6 +1935,10 @@ int dso__load(struct dso *dso, struct map *map)return ret; } +/* +* Always takes ownership of vmlinux when vmlinux_allocated == true, even if +* it returns an error. +*/ int dso__load_vmlinux (struct dso *dso,struct map *map,const char *vmlinux,bool vmlinux_allocated) {
@@ -1953,8 +1957,11 @@ int dso__load_vmlinux(struct dso *dso, struct map *map,else symtab_type =DSO_BINARY_TYPE__VMLINUX ; -if (symsrc__init (&ss, dso, symfs_vmlinux, symtab_type)) +if (symsrc__init (&ss, dso, symfs_vmlinux, symtab_type)) { +if (vmlinux_allocated) +free ((char *) vmlinux);return -1 ; + }/* * dso__load_sym() may copy 'dso' which will result in the copies having
@@ -1997,7 +2004,6 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map) err =dso__load_vmlinux (dso, map, filename, true);if (err >0 ) goto out; -free (filename); } out:return err;
@@ -2149,7 +2155,6 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map) err =dso__load_vmlinux (dso, map, filename, true);if (err >0 )return err; -free (filename); }if (!symbol_conf.ignore_vmlinux && vmlinux_path !=NULL ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 512/744 f2fs: compress: fix to update i_compr_blocks correctly
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 186e7d71534df4589405925caca5597af7626c12 ]
Previously, we account reserved blocks and compressed blocks into @compr_blocks, then, f2fs_i_compr_blocks_update(,compr_blocks) will update i_compr_blocks incorrectly, fix it.
Meanwhile, for the case all blocks in cluster were reserved, fix to update dn->ofs_in_node correctly.
--- fs/f2fs/file.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
fs/f2fs/file.c +14 -7
@@ -3622,7 +3622,8 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count,while (count) {int compr_blocks =0 ; -blkcnt_t reserved; +blkcnt_t reserved =0 ; +blkcnt_t to_reserved;int ret;for (i =0 ; i < cluster_size; i++) {
@@ -3642,20 +3643,26 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count,* fails in release_compress_blocks(), so NEW_ADDR * is a possible case. */ -if (blkaddr ==NEW_ADDR || -__is_valid_data_blkaddr (blkaddr)) { +if (blkaddr ==NEW_ADDR ) { + reserved++; +continue ; + } +if (__is_valid_data_blkaddr (blkaddr)) { compr_blocks++;continue ; } } - reserved = cluster_size - compr_blocks; + to_reserved = cluster_size - compr_blocks - reserved;/* for the case all blocks in cluster were reserved */ -if (reserved ==1 ) +if (to_reserved ==1 ) { + dn->ofs_in_node += cluster_size; goto next; + } - ret =inc_valid_block_count (sbi, dn->inode, &reserved, false); + ret =inc_valid_block_count (sbi, dn->inode, + &to_reserved, false);if (unlikely (ret))return ret;
@@ -3666,7 +3673,7 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count,f2fs_i_compr_blocks_update (dn->inode, compr_blocks, true); - *reserved_blocks += reserved; + *reserved_blocks += to_reserved; next: count -= cluster_size; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 513/744 f2fs: deprecate io_bits
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
[ Upstream commit 87161a2b0aed9e9b614bbf6fe8697ad560ceb0cb ]
Let's deprecate an unused io_bits feature to save CPU cycles and memory.
Stable-dep-of: 043c832371cd ("f2fs: compress: fix error path of inc_valid_block_count()")
--- Documentation/filesystems/f2fs.rst | 2 - fs/f2fs/data.c | 73 +------------------------ fs/f2fs/f2fs.h | 25 ++------- fs/f2fs/file.c | 2 - fs/f2fs/gc.c | 10 +--- fs/f2fs/segment.c | 9 +-- fs/f2fs/super.c | 88 +----------------------------- include/linux/f2fs_fs.h | 6 -- 8 files changed, 10 insertions(+), 205 deletions(-)
Documentation/filesystems/f2fs.rst +0 -2
@@ -226,8 +226,6 @@ mode=%s Control block allocation mode which supports "adaptive" option for more randomness. Please, use these options for your experiments and we strongly recommend to re-format the filesystem after using these options. -io_bits=%u Set the bit size of write IO requests. It should be set - with "mode=lfs". usrquota Enable plain user disk quota accounting. grpquota Enable plain group disk quota accounting. prjquota Enable plain project quota accounting.
fs/f2fs/data.c +2 -71
114 lines not on this page · raw message
fs/f2fs/f2fs.h +5 -20
@@ -147,7 +147,6 @@ struct f2fs_rwsem {struct f2fs_mount_info {unsigned int opt; -int write_io_size_bits;/* Write IO size bits */ block_t root_reserved_blocks;/* root reserved blocks */ kuid_t s_resuid;/* reserved blocks for uid */ kgid_t s_resgid;/* reserved blocks for gid */
@@ -1109,6 +1108,7 @@ enum count_type {* ... Only can be used with META. */ #define PAGE_TYPE_OF_BIO (type) ((type) > META ? META : (type)) +#define PAGE_TYPE_ON_MAIN (type) ((type) == DATA || (type) == NODE)enum page_type {DATA =0 ,NODE =1 ,/* should not change this */
@@ -1203,7 +1203,6 @@ struct f2fs_io_info { unsigned int submitted:1; /* indicate IO submission */ unsigned int in_list:1; /* indicate fio is in io_list */ unsigned int is_por:1; /* indicate IO is from recovery or not */ - unsigned int retry:1; /* need to reallocate block address */ unsigned int encrypted:1; /* indicate file is encrypted */ unsigned int post_read:1; /* require post read */enum iostat_type io_type;/* io type */
@@ -1404,18 +1403,16 @@ static inline void f2fs_clear_bit(unsigned int nr, char *addr);* Layout A: lowest bit should be 1 * | bit0 = 1 | bit1 | bit2 | ... | bit MAX | private data .... | * bit 0 PAGE_PRIVATE_NOT_POINTER -* bit 1 PAGE_PRIVATE_DUMMY_WRITE -* bit 2 PAGE_PRIVATE_ONGOING_MIGRATION -* bit 3 PAGE_PRIVATE_INLINE_INODE -* bit 4 PAGE_PRIVATE_REF_RESOURCE -* bit 5- f2fs private data +* bit 1 PAGE_PRIVATE_ONGOING_MIGRATION +* bit 2 PAGE_PRIVATE_INLINE_INODE +* bit 3 PAGE_PRIVATE_REF_RESOURCE +* bit 4- f2fs private data * * Layout B: lowest bit should be 0 * page.private is a wrapped pointer. */ enum {PAGE_PRIVATE_NOT_POINTER ,/* private contains non-pointer data */ -PAGE_PRIVATE_DUMMY_WRITE ,/* data page for padding aligned IO */ PAGE_PRIVATE_ONGOING_MIGRATION ,/* data page which is on-going migrating */ PAGE_PRIVATE_INLINE_INODE ,/* inode page contains inline data */ PAGE_PRIVATE_REF_RESOURCE ,/* dirty page has referenced resources */
@@ -1562,7 +1559,6 @@ struct f2fs_sb_info {struct f2fs_bio_info *write_io[NR_PAGE_TYPE ];/* for write bios */ /* keep migration IO order for LFS mode */ struct f2fs_rwsem io_order_lock; -mempool_t *write_io_dummy;/* Dummy pages */ pgoff_t page_eio_ofs[NR_PAGE_TYPE ];/* EIO page offset */ int page_eio_cnt[NR_PAGE_TYPE ];/* EIO count */
@@ -2306,10 +2302,6 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,if (!__allow_reserved_blocks (sbi, inode, true)) avail_user_block_count -=F2FS_OPTION (sbi).root_reserved_blocks; -if (F2FS_IO_ALIGNED (sbi)) - avail_user_block_count -= sbi->blocks_per_seg * -SM_I (sbi)->additional_reserved_segments; -if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) {if (avail_user_block_count > sbi->unusable_block_count) avail_user_block_count -= sbi->unusable_block_count;
@@ -2377,17 +2369,14 @@ static inline void clear_page_private_##name(struct page *page) \PAGE_PRIVATE_GET_FUNC (nonpointer,NOT_POINTER );PAGE_PRIVATE_GET_FUNC (inline,INLINE_INODE );PAGE_PRIVATE_GET_FUNC (gcing,ONGOING_MIGRATION ); -PAGE_PRIVATE_GET_FUNC (dummy,DUMMY_WRITE );PAGE_PRIVATE_SET_FUNC (reference,REF_RESOURCE );PAGE_PRIVATE_SET_FUNC (inline,INLINE_INODE );PAGE_PRIVATE_SET_FUNC (gcing,ONGOING_MIGRATION ); -PAGE_PRIVATE_SET_FUNC (dummy,DUMMY_WRITE );PAGE_PRIVATE_CLEAR_FUNC (reference,REF_RESOURCE );PAGE_PRIVATE_CLEAR_FUNC (inline,INLINE_INODE );PAGE_PRIVATE_CLEAR_FUNC (gcing,ONGOING_MIGRATION ); -PAGE_PRIVATE_CLEAR_FUNC (dummy,DUMMY_WRITE );static inline unsigned long get_page_private_data (struct page *page) {
@@ -2640,10 +2629,6 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,if (!__allow_reserved_blocks (sbi, inode, false)) valid_block_count +=F2FS_OPTION (sbi).root_reserved_blocks; -if (F2FS_IO_ALIGNED (sbi)) - valid_block_count += sbi->blocks_per_seg * -SM_I (sbi)->additional_reserved_segments; - user_block_count = sbi->user_block_count;if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) user_block_count -= sbi->unusable_block_count;
fs/f2fs/file.c +0 -2
@@ -813,8 +813,6 @@ static bool f2fs_force_buffered_io(struct inode *inode, int rw)*/ if (f2fs_sb_has_blkzoned (sbi) && (rw ==WRITE ))return true; -if (f2fs_lfs_mode (sbi) && rw ==WRITE &&F2FS_IO_ALIGNED (sbi)) -return true;if (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))return true;
fs/f2fs/gc.c +1 -9
@@ -1183,7 +1183,6 @@ static int ra_data_block(struct inode *inode, pgoff_t index) .op_flags = 0, .encrypted_page = NULL, .in_list = 0, - .retry = 0, };int err;
@@ -1272,7 +1271,6 @@ static int move_data_block(struct inode *inode, block_t bidx, .op_flags = 0, .encrypted_page = NULL, .in_list = 0, - .retry = 0, };struct dnode_of_data dn;struct f2fs_summary sum;
@@ -1392,18 +1390,12 @@ static int move_data_block(struct inode *inode, block_t bidx, fio.op_flags =REQ_SYNC ; fio.new_blkaddr = newaddr;f2fs_submit_page_write (&fio); -if (fio.retry) { - err = -EAGAIN ; -if (PageWriteback (fio.encrypted_page)) -end_page_writeback (fio.encrypted_page); - goto put_page_out; - }f2fs_update_iostat (fio.sbi,NULL ,FS_GC_DATA_IO ,F2FS_BLKSIZE );f2fs_update_data_blkaddr (&dn, newaddr);set_inode_flag (inode,FI_APPEND_WRITE ); -put_page_out: +f2fs_put_page (fio.encrypted_page,1 ); recover_block:if (err)
fs/f2fs/segment.c +1 -8
@@ -3517,9 +3517,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,if (fio) {struct f2fs_bio_info *io; -if (F2FS_IO_ALIGNED (sbi)) - fio->retry =0 ; -INIT_LIST_HEAD (&fio->list); fio->in_list =1 ; io = sbi->write_io[fio->type] + fio->temp;
@@ -3567,7 +3564,7 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)if (keep_order)f2fs_down_read (&fio->sbi->io_order_lock); -reallocate: +f2fs_allocate_data_block (fio->sbi, fio->page, fio->old_blkaddr, &fio->new_blkaddr, sum, type, fio);if (GET_SEGNO (fio->sbi, fio->old_blkaddr) !=NULL_SEGNO )
@@ -3575,10 +3572,6 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)/* writeout dirty page into bdev */ f2fs_submit_page_write (fio); -if (fio->retry) { - fio->old_blkaddr = fio->new_blkaddr; - goto reallocate; - }f2fs_update_device_state (fio->sbi, fio->ino, fio->new_blkaddr,1 );
fs/f2fs/super.c +1 -87
169 lines not on this page · raw message
include/linux/f2fs_fs.h +0 -6
@@ -41,12 +41,6 @@#define F2FS_ENC_UTF8_12_1 1 -#define F2FS_IO_SIZE (sbi) BIT(F2FS_OPTION(sbi).write_io_size_bits)/* Blocks */ -#define F2FS_IO_SIZE_KB (sbi) BIT(F2FS_OPTION(sbi).write_io_size_bits + 2)/* KB */ -#define F2FS_IO_SIZE_BITS (sbi) (F2FS_OPTION(sbi).write_io_size_bits)/* power of 2 */ -#define F2FS_IO_SIZE_MASK (sbi) (F2FS_IO_SIZE(sbi) - 1) -#define F2FS_IO_ALIGNED (sbi) (F2FS_IO_SIZE(sbi) > 1) -/* This flag is used by node and meta inodes, and by recovery */ #define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 514/744 f2fs: introduce get_available_block_count() for cleanup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 0f1c6ede6da9f7c5dd7380b74a64850298279168 ]
There are very similar codes in inc_valid_block_count() and inc_valid_node_count() which is used for available user block count calculation.
This patch introduces a new helper get_available_block_count() to include those common codes, and used it to clean up codes.
Stable-dep-of: 043c832371cd ("f2fs: compress: fix error path of inc_valid_block_count()")
--- fs/f2fs/f2fs.h | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-)
fs/f2fs/f2fs.h +27 -22
@@ -2271,6 +2271,27 @@ static inline bool __allow_reserved_blocks(struct f2fs_sb_info *sbi,return false; } +static inline unsigned int get_available_block_count (struct f2fs_sb_info *sbi, +struct inode *inode,bool cap) +{ +block_t avail_user_block_count; + + avail_user_block_count = sbi->user_block_count - + sbi->current_reserved_blocks; + +if (!__allow_reserved_blocks (sbi, inode, cap)) + avail_user_block_count -=F2FS_OPTION (sbi).root_reserved_blocks; + +if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) { +if (avail_user_block_count > sbi->unusable_block_count) + avail_user_block_count -= sbi->unusable_block_count; +else + avail_user_block_count =0 ; + } + +return avail_user_block_count; +} +static inline void f2fs_i_blocks_write (struct inode *,block_t ,bool ,bool );static inline int inc_valid_block_count (struct f2fs_sb_info *sbi,struct inode *inode,blkcnt_t *count,bool partial)
@@ -2296,18 +2317,8 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,spin_lock (&sbi->stat_lock); sbi->total_valid_block_count += (block_t)(*count); - avail_user_block_count = sbi->user_block_count - - sbi->current_reserved_blocks; + avail_user_block_count =get_available_block_count (sbi, inode, true); -if (!__allow_reserved_blocks (sbi, inode, true)) - avail_user_block_count -=F2FS_OPTION (sbi).root_reserved_blocks; - -if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) { -if (avail_user_block_count > sbi->unusable_block_count) - avail_user_block_count -= sbi->unusable_block_count; -else - avail_user_block_count =0 ; - }if (unlikely (sbi->total_valid_block_count > avail_user_block_count)) {if (!partial) {spin_unlock (&sbi->stat_lock);
@@ -2603,7 +2614,8 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi, struct inode *inode, bool is_inode) {block_t valid_block_count; -unsigned int valid_node_count, user_block_count; +unsigned int valid_node_count; +unsigned int avail_user_block_count;int err;if (is_inode) {
@@ -2623,17 +2635,10 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,spin_lock (&sbi->stat_lock); - valid_block_count = sbi->total_valid_block_count + - sbi->current_reserved_blocks +1 ; - -if (!__allow_reserved_blocks (sbi, inode, false)) - valid_block_count +=F2FS_OPTION (sbi).root_reserved_blocks; - - user_block_count = sbi->user_block_count; -if (unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) - user_block_count -= sbi->unusable_block_count; + valid_block_count = sbi->total_valid_block_count +1 ; + avail_user_block_count =get_available_block_count (sbi, inode, false); -if (unlikely (valid_block_count > user_block_count)) { +if (unlikely (valid_block_count > avail_user_block_count)) {spin_unlock (&sbi->stat_lock); goto enospc; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 515/744 f2fs: compress: fix error path of inc_valid_block_count()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 043c832371cd9023fbd725138ddc6c7f288dc469 ]
If inc_valid_block_count() can not allocate all requested blocks, it needs to release block count in .total_valid_block_count and resevation blocks in inode.
--- fs/f2fs/f2fs.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
fs/f2fs/f2fs.h +8 -7
@@ -2296,7 +2296,7 @@ static inline void f2fs_i_blocks_write(struct inode *, block_t, bool, bool);static inline int inc_valid_block_count (struct f2fs_sb_info *sbi,struct inode *inode,blkcnt_t *count,bool partial) { -blkcnt_t diff =0 , release =0 ; +long long diff =0 , release =0 ;block_t avail_user_block_count;int ret;
@@ -2316,26 +2316,27 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,percpu_counter_add (&sbi->alloc_valid_block_count, (*count));spin_lock (&sbi->stat_lock); - sbi->total_valid_block_count += (block_t)(*count); - avail_user_block_count =get_available_block_count (sbi, inode, true); -if (unlikely (sbi->total_valid_block_count > avail_user_block_count)) { + avail_user_block_count =get_available_block_count (sbi, inode, true); + diff = (long long )sbi->total_valid_block_count + *count - + avail_user_block_count; +if (unlikely (diff >0 )) {if (!partial) {spin_unlock (&sbi->stat_lock); + release = *count; goto enospc; } - - diff = sbi->total_valid_block_count - avail_user_block_count;if (diff > *count) diff = *count; *count -= diff; release = diff; - sbi->total_valid_block_count -= diff;if (!*count) {spin_unlock (&sbi->stat_lock); goto enospc; } } + sbi->total_valid_block_count += (block_t)(*count); +spin_unlock (&sbi->stat_lock);if (unlikely (release)) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 516/744 f2fs: compress: fix to cover {reserve,release}_compress_blocks() w/ cp_rwsem lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 0a4ed2d97cb6d044196cc3e726b6699222b41019 ]
It needs to cover {reserve,release}_compress_blocks() w/ cp_rwsem lock to avoid racing with checkpoint, otherwise, filesystem metadata including blkaddr in dnode, inode fields and .total_valid_block_count may be corrupted after SPO case.
--- fs/f2fs/file.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/f2fs/file.c +10 -0
@@ -3547,9 +3547,12 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)struct dnode_of_data dn;pgoff_t end_offset, count; +f2fs_lock_op (sbi); +set_new_dnode (&dn, inode,NULL ,NULL ,0 ); ret =f2fs_get_dnode_of_data (&dn, page_idx,LOOKUP_NODE );if (ret) { +f2fs_unlock_op (sbi);if (ret == -ENOENT ) { page_idx =f2fs_get_next_page_offset (&dn, page_idx);
@@ -3567,6 +3570,8 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)f2fs_put_dnode (&dn); +f2fs_unlock_op (sbi); +if (ret <0 )break ;
@@ -3719,9 +3724,12 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)struct dnode_of_data dn;pgoff_t end_offset, count; +f2fs_lock_op (sbi); +set_new_dnode (&dn, inode,NULL ,NULL ,0 ); ret =f2fs_get_dnode_of_data (&dn, page_idx,LOOKUP_NODE );if (ret) { +f2fs_unlock_op (sbi);if (ret == -ENOENT ) { page_idx =f2fs_get_next_page_offset (&dn, page_idx);
@@ -3739,6 +3747,8 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)f2fs_put_dnode (&dn); +f2fs_unlock_op (sbi); +if (ret <0 )break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 517/744 f2fs: fix to release node block count in error path of f2fs_new_node_page()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 0fa4e57c1db263effd72d2149d4e21da0055c316 ]
It missed to call dec_valid_node_count() to release node block count in error path, fix it.
--- fs/f2fs/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/node.c +1 -1
@@ -1319,6 +1319,7 @@ struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs) }if (unlikely (new_ni.blk_addr !=NULL_ADDR )) { err = -EFSCORRUPTED ; +dec_valid_node_count (sbi, dn->inode, !ofs);set_sbi_flag (sbi,SBI_NEED_FSCK );f2fs_handle_error (sbi,ERROR_INVALID_BLKADDR ); goto fail;
@@ -1345,7 +1346,6 @@ struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)if (ofs ==0 )inc_valid_inode_count (sbi);return page; - fail:clear_node_page_dirty (page);f2fs_put_page (page,1 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 518/744 f2fs: compress: dont allow unaligned truncation on released compress inode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 29ed2b5dd521ce7c5d8466cd70bf0cc9d07afeee ]
f2fs image may be corrupted after below testcase:
- mkfs.f2fs -O extra_attr,compression -f /dev/vdb
- mount /dev/vdb /mnt/f2fs
- touch /mnt/f2fs/file
- f2fs_io setflags compression /mnt/f2fs/file
- dd if=/dev/zero of=/mnt/f2fs/file bs=4k count=4
- f2fs_io release_cblocks /mnt/f2fs/file
- truncate -s 8192 /mnt/f2fs/file
- umount /mnt/f2fs
- fsck.f2fs /dev/vdb
[ASSERT] (fsck_chk_inode_blk:1256) --> ino: 0x5 has i_blocks: 0x00000002, but has 0x3 blocks
[FSCK] valid_block_count matching with CP [Fail] [0x4, 0x5]
[FSCK] other corrupted bugs [Fail]
The reason is: partial truncation assume compressed inode has reserved blocks, after partial truncation, valid block count may change w/o .i_blocks and .total_valid_block_count update, result in corruption.
This patch only allow cluster size aligned truncation on released compress inode for fixing.
--- fs/f2fs/file.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/f2fs/file.c +8 -3
@@ -929,9 +929,14 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ATTR_GID | ATTR_TIMES_SET))))return -EPERM ; -if ((attr->ia_valid &ATTR_SIZE ) && - !f2fs_is_compress_backend_ready (inode)) -return -EOPNOTSUPP ; +if ((attr->ia_valid &ATTR_SIZE )) { +if (!f2fs_is_compress_backend_ready (inode)) +return -EOPNOTSUPP ; +if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED ) && + !IS_ALIGNED (attr->ia_size, +F2FS_BLK_TO_BYTES (F2FS_I (inode)->i_cluster_size))) +return -EINVAL ; + } err =setattr_prepare (idmap, dentry, attr);if (err)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 519/744 serial: sh-sci: protect invalidating RXDMA on shutdown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit aae20f6e34cd0cbd67a1d0e5877561c40109a81b ]
The to-be-fixed commit removed locking when invalidating the DMA RX descriptors on shutdown. It overlooked that there is still a rx_timer running which may still access the protected data. So, re-add the locking.
--- drivers/tty/serial/sh-sci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/sh-sci.c +5 -0
@@ -1272,9 +1272,14 @@ static void sci_dma_rx_chan_invalidate(struct sci_port *s)static void sci_dma_rx_release (struct sci_port *s) {struct dma_chan *chan = s->chan_rx_saved; +struct uart_port *port = &s->port; +unsigned long flags; +uart_port_lock_irqsave (port, &flags); s->chan_rx_saved =NULL ;sci_dma_rx_chan_invalidate (s); +uart_port_unlock_irqrestore (port, flags); +dmaengine_terminate_sync (chan);dma_free_coherent (chan->device->dev, s->buf_len_rx *2 , s->rx_buf[0 ],sg_dma_address (&s->sg_rx[0 ]));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 520/744 libsubcmd: Fix parse-options memory leak
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 230a7a71f92212e723fa435d4ca5922de33ec88a ]
If a usage string is built in parse_options_subcommand, also free it.
--- tools/lib/subcmd/parse-options.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/lib/subcmd/parse-options.c +5 -3
@@ -633,11 +633,10 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o const char *const subcommands[], const char *usagestr[], int flags) { struct parse_opt_ctx_t ctx; +char *buf =NULL ;/* build usage string if it's not provided */ if (subcommands && !usagestr[0 ]) { -char *buf =NULL ; -astrcatf (&buf,"%s %s [<options>] {" , subcmd_config.exec_name, argv[0 ]);for (int i =0 ; subcommands[i]; i++) {
@@ -679,7 +678,10 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *oastrcatf (&error_buf,"unknown switch `%c'" , *ctx.opt);usage_with_options (usagestr, options); } - +if (buf) { + usagestr[0 ] =NULL ; +free (buf); + }return parse_options_end (&ctx); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 521/744 perf daemon: Fix file leak in daemon_session__control
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samasth Norway Ananda <[email protected]>
[ Upstream commit 09541603462c399c7408d50295db99b4b8042eaa ]
The open() function returns -1 on error.
The 'control' and 'ack' file descriptors are both initialized with open() and further validated with 'if' statement.
'if (!control)' would evaluate to 'true' if returned value on error were '0' but it is actually '-1'.
--- tools/perf/builtin-daemon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-daemon.c +2 -2
@@ -523,7 +523,7 @@ static int daemon_session__control(struct daemon_session *session, session->base, SESSION_CONTROL); control =open (control_path,O_WRONLY |O_NONBLOCK ); -if (!control) +if (control <0 )return -1 ;if (do_ack) {
@@ -532,7 +532,7 @@ static int daemon_session__control(struct daemon_session *session, session->base, SESSION_ACK); ack =open (ack_path,O_RDONLY ,O_NONBLOCK ); -if (!ack) { +if (ack <0 ) {close (control);return -1 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 522/744 f2fs: fix to add missing iput() in gc_data_segment()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit a798ff17cd2dabe47d5d4ed3d509631793c36e19 ]
During gc_data_segment(), if inode state is abnormal, it missed to call iput(), fix it.
--- fs/f2fs/gc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/f2fs/gc.c +7 -2
@@ -1551,10 +1551,15 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,int err; inode =f2fs_iget (sb, dni.ino); -if (IS_ERR (inode) ||is_bad_inode (inode) || -special_file (inode->i_mode)) +if (IS_ERR (inode))continue ; +if (is_bad_inode (inode) || +special_file (inode->i_mode)) { +iput (inode); +continue ; + } + err =f2fs_gc_pinned_control (inode, gc_type, segno);if (err == -EAGAIN ) {iput (inode);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 523/744 usb: fotg210: Add missing kernel doc description
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 4b653e82ae18f2dc91c7132b54f5785c4d56bab4 ]
kernel-doc validator is not happy:
warning: Function parameter or struct member 'fotg' not described in 'fotg210_vbus'
Add missing description.
--- drivers/usb/fotg210/fotg210-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/fotg210/fotg210-core.c +1 -0
@@ -95,6 +95,7 @@ static int fotg210_gemini_init(struct fotg210 *fotg, struct resource *res,/** * fotg210_vbus() - Called by gadget driver to enable/disable VBUS +* @fotg: pointer to a private fotg210 object * @enable: true to enable VBUS, false to disable VBUS */ void fotg210_vbus (struct fotg210 *fotg,bool enable)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 524/744 perf stat: Dont display metric header for non-leader uncore events
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 193a9e30207f54777ff42d0d8be8389edc522277 ]
On an Intel tigerlake laptop a metric like:
{
"BriefDescription": "Test",
"MetricExpr": "imc_free_running@data_read@ + imc_free_running@data_write@",
"MetricGroup": "Test",
"MetricName": "Test",
"ScaleUnit": "6.103515625e-5MiB"
},Will have 4 events:
uncore_imc_free_running_0/data_read/
uncore_imc_free_running_0/data_write/
uncore_imc_free_running_1/data_read/
uncore_imc_free_running_1/data_write/
If aggregration is disabled with metric-only 2 column headers are needed:
$ perf stat -M test --metric-only -A -a sleep 1
Performance counter stats for 'system wide':
MiB Test MiB Test
CPU0 1821.0 1820.5
But when not, the counts aggregated in the metric leader and only 1 column should be shown:
$ perf stat -M test --metric-only -a sleep 1 Performance counter stats for 'system wide':
MiB Test
5909.4
1.001258915 seconds time elapsedAchieve this by skipping events that aren't metric leaders when printing column headers and aggregation isn't disabled.
The bug is long standing, the fixes tag is set to a refactor as that is as far back as is reasonable to backport.
--- tools/perf/util/stat-display.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/stat-display.c +3 -0
@@ -1207,6 +1207,9 @@ static void print_metric_headers(struct perf_stat_config *config,/* Print metrics headers only */ evlist__for_each_entry (evlist, counter) { +if (config->aggr_mode !=AGGR_NONE && counter->metric_leader != counter) +continue ; + os.evsel = counter; perf_stat__print_shadow_stats(config, counter, 0,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 525/744 perf test: Add a test for strcmp_cpuid_str() expression
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit a1ebf7718ee31501d2d2ee3af1716e0084c81926 ]
Test that the new expression builtin returns a match when the current escaped CPU ID is given, and that it doesn't match when "0x0" is given.
The CPU ID in test__expr() has to be changed to perf_pmu__getcpuid() which returns the CPU ID string, rather than the raw CPU ID that get_cpuid() returns because that can't be used with strcmp_cpuid_str(). It doesn't affect the is_intel test because both versions contain "Intel".
Stable-dep-of: d9c5f5f94c2d ("perf pmu: Count sys and cpuid JSON events separately")
--- tools/perf/tests/expr.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
tools/perf/tests/expr.c +27 -4
@@ -9,6 +9,7 @@#include <math.h> #include <stdlib.h> #include <string.h> +#include <string2.h> #include <linux/zalloc.h> static int test_ids_union (void )
@@ -74,10 +75,13 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_uint ret;struct expr_parse_ctx *ctx;bool is_intel = false; -char buf[128 ]; +char strcmp_cpuid_buf[256 ]; +struct perf_pmu *pmu =pmu__find_core_pmu (); +char *cpuid =perf_pmu__getcpuid (pmu); +char *escaped_cpuid1, *escaped_cpuid2; -if (!get_cpuid (buf,sizeof (buf))) - is_intel =strstr (buf,"Intel" ) !=NULL ; +TEST_ASSERT_VAL ("get_cpuid" , cpuid); + is_intel =strstr (cpuid,"Intel" ) !=NULL ;TEST_ASSERT_EQUAL ("ids_union" ,test_ids_union (),0 );
@@ -257,9 +261,28 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_uTEST_ASSERT_VAL ("source count" ,hashmap__size (ctx->ids) ==1 );TEST_ASSERT_VAL ("source count" ,hashmap__find (ctx->ids,"EVENT1" , &val_ptr)); + +/* Test no cpuid match */ + ret =test (ctx,"strcmp_cpuid_str(0x0)" ,0 ); + +/* +* Test cpuid match with current cpuid. Special chars have to be +* escaped. +*/ + escaped_cpuid1 =strreplace_chars ('-' , cpuid,"\\-" ); +free (cpuid); + escaped_cpuid2 =strreplace_chars (',' , escaped_cpuid1,"\\," ); +free (escaped_cpuid1); + escaped_cpuid1 =strreplace_chars ('=' , escaped_cpuid2,"\\=" ); +free (escaped_cpuid2); +scnprintf (strcmp_cpuid_buf,sizeof (strcmp_cpuid_buf), +"strcmp_cpuid_str(%s)" , escaped_cpuid1); +free (escaped_cpuid1); + ret |=test (ctx, strcmp_cpuid_buf,1 ); +/* has_event returns 1 when an event exists. */ expr__add_id_val (ctx,strdup ("cycles" ),2 ); - ret =test (ctx,"has_event(cycles)" ,1 ); + ret |=test (ctx,"has_event(cycles)" ,1 );expr__ctx_free (ctx);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 526/744 perf pmu: Move pmu__find_core_pmu() to pmus.c
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
[ Upstream commit 3d0f5f456a5786573ba6a3358178c8db580e4b85 ]
pmu__find_core_pmu() more logically belongs in pmus.c because it iterates over all PMUs, so move it to pmus.c
At the same time rename it to perf_pmus__find_core_pmu() to match the naming convention in this file.
list_prepare_entry() can't be used in perf_pmus__scan_core() anymore now that it's called from the same compilation unit. This is with -O2 (specifically -O1 -ftree-vrp -finline-functions -finline-small-functions) which allow the bounds of the array access to be determined at compile time. list_prepare_entry() subtracts the offset of the 'list' member in struct perf_pmu from &core_pmus, which isn't a struct perf_pmu. The compiler sees that pmu results in &core_pmus - 8 and refuses to compile. At runtime this works because list_for_each_entry_continue() always adds the offset back again before dereferencing ->next, but it's technically undefined behavior. With -fsanitize=undefined an additional warning is generated.
Using list_first_entry_or_null() to get the first entry here avoids doing &core_pmus - 8 but has the same result and fixes both the compile warning and the undefined behavior warning. There are other uses of list_prepare_entry() in pmus.c, but the compiler doesn't seem to be able to see that they can also be called with &core_pmus, so I won't change any at this time.
Stable-dep-of: d9c5f5f94c2d ("perf pmu: Count sys and cpuid JSON events separately")
--- tools/perf/arch/arm64/util/pmu.c | 6 +++--- tools/perf/tests/expr.c | 2 +- tools/perf/util/expr.c | 2 +- tools/perf/util/pmu.c | 17 ----------------- tools/perf/util/pmu.h | 2 +- tools/perf/util/pmus.c | 20 +++++++++++++++++++- 6 files changed, 25 insertions(+), 24 deletions(-)
tools/perf/arch/arm64/util/pmu.c +3 -3
@@ -10,7 +10,7 @@const struct pmu_metrics_table *pmu_metrics_table__find (void ) { -struct perf_pmu *pmu =pmu__find_core_pmu (); +struct perf_pmu *pmu =perf_pmus__find_core_pmu ();if (pmu)return perf_pmu__find_metrics_table (pmu);
@@ -20,7 +20,7 @@ const struct pmu_metrics_table *pmu_metrics_table__find(void)const struct pmu_events_table *pmu_events_table__find (void ) { -struct perf_pmu *pmu =pmu__find_core_pmu (); +struct perf_pmu *pmu =perf_pmus__find_core_pmu ();if (pmu)return perf_pmu__find_events_table (pmu);
@@ -32,7 +32,7 @@ double perf_pmu__cpu_slots_per_cycle(void) {char path[PATH_MAX ];unsigned long long slots =0 ; -struct perf_pmu *pmu =pmu__find_core_pmu (); +struct perf_pmu *pmu =perf_pmus__find_core_pmu ();if (pmu) { perf_pmu__pathname_scnprintf(path, sizeof(path),
tools/perf/tests/expr.c +1 -1
@@ -76,7 +76,7 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_ustruct expr_parse_ctx *ctx;bool is_intel = false;char strcmp_cpuid_buf[256 ]; -struct perf_pmu *pmu =pmu__find_core_pmu (); +struct perf_pmu *pmu =perf_pmus__find_core_pmu ();char *cpuid =perf_pmu__getcpuid (pmu);char *escaped_cpuid1, *escaped_cpuid2;
tools/perf/util/expr.c +1 -1
@@ -527,7 +527,7 @@ double expr__strcmp_cpuid_str(const struct expr_parse_ctx *ctx __maybe_unused, bool compute_ids __maybe_unused, const char *test_id) { double ret; -struct perf_pmu *pmu =pmu__find_core_pmu (); +struct perf_pmu *pmu =perf_pmus__find_core_pmu ();char *cpuid =perf_pmu__getcpuid (pmu);if (!cpuid)
tools/perf/util/pmu.c +0 -17
@@ -2058,20 +2058,3 @@ void perf_pmu__delete(struct perf_pmu *pmu)zfree (&pmu->id);free (pmu); } - -struct perf_pmu *pmu__find_core_pmu (void ) -{ -struct perf_pmu *pmu =NULL ; - -while ((pmu =perf_pmus__scan_core (pmu))) { -/* -* The cpumap should cover all CPUs. Otherwise, some CPUs may -* not support some events or have different event IDs. -*/ -if (RC_CHK_ACCESS (pmu->cpus)->nr !=cpu__max_cpu ().cpu) -return NULL ; - -return pmu; - } -return NULL ; -}
tools/perf/util/pmu.h +1 -1
@@ -264,6 +264,6 @@ int perf_pmu__pathname_fd(int dirfd, const char *pmu_name, const char *filename,struct perf_pmu *perf_pmu__lookup (struct list_head *pmus,int dirfd,const char *lookup_name);struct perf_pmu *perf_pmu__create_placeholder_core_pmu (struct list_head *core_pmus);void perf_pmu__delete (struct perf_pmu *pmu); -struct perf_pmu *pmu__find_core_pmu (void ); +struct perf_pmu *perf_pmus__find_core_pmu (void );#endif /* __PMU_H */
tools/perf/util/pmus.c +19 -1
@@ -10,6 +10,7 @@#include <pthread.h> #include <string.h> #include <unistd.h> +#include "cpumap.h" #include "debug.h" #include "evsel.h" #include "pmus.h"
@@ -268,7 +269,7 @@ struct perf_pmu *perf_pmus__scan_core(struct perf_pmu *pmu) {if (!pmu) {pmu_read_sysfs (/*core_only=*/ true); - pmu =list_prepare_entry (pmu, &core_pmus, list); +return list_first_entry_or_null (&core_pmus,typeof (*pmu), list); }list_for_each_entry_continue (pmu, &core_pmus, list)return pmu;
@@ -592,3 +593,20 @@ struct perf_pmu *evsel__find_pmu(const struct evsel *evsel) }return pmu; } + +struct perf_pmu *perf_pmus__find_core_pmu (void ) +{ +struct perf_pmu *pmu =NULL ; + +while ((pmu =perf_pmus__scan_core (pmu))) { +/* +* The cpumap should cover all CPUs. Otherwise, some CPUs may +* not support some events or have different event IDs. +*/ +if (RC_CHK_ACCESS (pmu->cpus)->nr !=cpu__max_cpu ().cpu) +return NULL ; + +return pmu; + } +return NULL ; +}
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 527/744 perf pmu: "Compat" supports regular expression matching identifiers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jing Zhang <[email protected]>
[ Upstream commit 2879ff36f5ed80deec5f9d82a7a4107f2347630e ]
The jevent "Compat" is used for uncore PMU alias or metric definitions.
The same PMU driver has different PMU identifiers due to different hardware versions and types, but they may have some common PMU event. Since a Compat value can only match one identifier, when adding the same event alias to PMUs with different identifiers, each identifier needs to be defined once, which is not streamlined enough.
So let "Compat" support using regular expression to match identifiers for uncore PMU alias. For example, if the "Compat" value is set to "43401|43c01", it would be able to match PMU identifiers such as "43401" or "43c01", which correspond to CMN600_r0p0 or CMN700_r0p0.
Stable-dep-of: d9c5f5f94c2d ("perf pmu: Count sys and cpuid JSON events separately")
--- tools/perf/util/pmu.c | 27 +++++++++++++++++++++++++-- tools/perf/util/pmu.h | 1 + 2 files changed, 26 insertions(+), 2 deletions(-)
tools/perf/util/pmu.c +25 -2
@@ -28,6 +28,7 @@#include "strbuf.h" #include "fncache.h" #include "util/evsel_config.h" +#include <regex.h> struct perf_pmu perf_pmu__fake = { .name ="fake" ,
@@ -874,6 +875,28 @@ static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)return res; } +bool pmu_uncore_identifier_match (const char *compat,const char *id) +{ +regex_t re; +regmatch_t pmatch[1 ]; +int match; + +if (regcomp (&re, compat,REG_EXTENDED ) !=0 ) { +/* Warn unable to generate match particular string. */ +pr_info ("Invalid regular expression %s\n" , compat); +return false; + } + + match = !regexec (&re, id,1 , pmatch,0 ); +if (match) { +/* Ensure a full match. */ + match = pmatch[0 ].rm_so ==0 && (size_t )pmatch[0 ].rm_eo ==strlen (id); + } +regfree (&re); + +return match; +} +static int pmu_add_cpu_aliases_map_callback (const struct pmu_event *pe,const struct pmu_events_table *table__maybe_unused ,void *vdata)
@@ -914,8 +937,8 @@ static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe,if (!pe->compat || !pe->pmu)return 0 ; -if (!strcmp (pmu->id, pe->compat) && -pmu_uncore_alias_match (pe->pmu, pmu->name)) { +if (pmu_uncore_alias_match (pe->pmu, pmu->name) && +pmu_uncore_identifier_match (pe->compat, pmu->id)) { perf_pmu__new_alias(pmu, pe->name, pe->desc,
tools/perf/util/pmu.h +1 -0
@@ -240,6 +240,7 @@ void pmu_add_cpu_aliases_table(struct perf_pmu *pmu,char *perf_pmu__getcpuid (struct perf_pmu *pmu);const struct pmu_events_table *pmu_events_table__find (void );const struct pmu_metrics_table *pmu_metrics_table__find (void ); +bool pmu_uncore_identifier_match (const char *compat,const char *id);int perf_pmu__convert_scale (const char *scale,char **end,double *sval);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 528/744 perf tools: Use pmus to describe type from attribute
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 7093882067e2e2f88d3449c35c5f0f3f566c8a26 ]
When dumping a perf_event_attr, use pmus to find the PMU and its name by the type number. This allows dynamically added PMUs to be described.
Before:
$ perf stat -vv -e data_read true
...
perf_event_attr:
type 24
size 136
config 0x20ff
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
exclude_guest 1
...After:
$ perf stat -vv -e data_read true
...
perf_event_attr:
type 24 (uncore_imc_free_running_0)
size 136
config 0x20ff
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
exclude_guest 1
...However, it also means that when we have a PMU name we prefer it to a hard coded name:
Before:
$ perf stat -vv -e faults true
...
perf_event_attr:
type 1 (PERF_TYPE_SOFTWARE)
size 136
config 0x2 (PERF_COUNT_SW_PAGE_FAULTS)
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
enable_on_exec 1
exclude_guest 1
...After:
$ perf stat -vv -e faults true
...
perf_event_attr:
type 1 (software)
size 136
config 0x2 (PERF_COUNT_SW_PAGE_FAULTS)
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
enable_on_exec 1
exclude_guest 1
...It feels more consistent to do this, rather than only prefer a PMU name when a hard coded name isn't available.
Stable-dep-of: d9c5f5f94c2d ("perf pmu: Count sys and cpuid JSON events separately")
--- tools/perf/util/perf_event_attr_fprintf.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
tools/perf/util/perf_event_attr_fprintf.c +11 -5
@@ -7,6 +7,8 @@#include <linux/types.h> #include <linux/perf_event.h> #include "util/evsel_fprintf.h" +#include "util/pmu.h" +#include "util/pmus.h" #include "trace-event.h" struct bit_names {
@@ -74,9 +76,12 @@ static void __p_read_format(char *buf, size_t size, u64 value) }#define ENUM_ID_TO_STR_CASE (x) case x: return (#x); -static const char *stringify_perf_type_id (u64 value) +static const char *stringify_perf_type_id (struct perf_pmu *pmu,u32 type) { -switch (value) { +if (pmu) +return pmu->name; + +switch (type) { ENUM_ID_TO_STR_CASE(PERF_TYPE_HARDWARE) ENUM_ID_TO_STR_CASE(PERF_TYPE_SOFTWARE) ENUM_ID_TO_STR_CASE(PERF_TYPE_TRACEPOINT)
@@ -174,9 +179,9 @@ do { \#define print_id_unsigned (_s) PRINT_ID(_s, "%"PRIu64)#define print_id_hex (_s) PRINT_ID(_s, "%#"PRIx64) -static void __p_type_id (char *buf,size_t size,u64 value) +static void __p_type_id (struct perf_pmu *pmu,char *buf,size_t size,u64 value) { -print_id_unsigned (stringify_perf_type_id (value)); +print_id_unsigned (stringify_perf_type_id (pmu, value)); }static void __p_config_hw_id (char *buf,size_t size,u64 value)
@@ -245,7 +250,7 @@ static void __p_config_id(char *buf, size_t size, u32 type, u64 value)#define p_sample_type (val) __p_sample_type(buf, BUF_SIZE, val)#define p_branch_sample_type (val) __p_branch_sample_type(buf, BUF_SIZE, val)#define p_read_format (val) __p_read_format(buf, BUF_SIZE, val) -#define p_type_id (val) __p_type_id(buf, BUF_SIZE, val) +#define p_type_id (val) __p_type_id(pmu, buf, BUF_SIZE, val)#define p_config_id (val) __p_config_id(buf, BUF_SIZE, attr->type, val)#define PRINT_ATTRn (_n, _f, _p, _a) \
@@ -261,6 +266,7 @@ do { \int perf_event_attr__fprintf (FILE *fp,struct perf_event_attr *attr,attr__fprintf_f attr__fprintf,void *priv) { +struct perf_pmu *pmu =perf_pmus__find_by_type (attr->type);char buf[BUF_SIZE ];int ret =0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 529/744 perf tools: Add/use PMU reverse lookup from config to name
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 67ee8e71daabb8632931b7559e5c8a4b69a427f8 ]
Add perf_pmu__name_from_config that does a reverse lookup from a config number to an alias name. The lookup is expensive as the config is computed for every alias by filling in a perf_event_attr, but this is only done when verbose output is enabled. The lookup also only considers config, and not config1, config2 or config3.
An example of the output:
$ perf stat -vv -e data_read true
...
perf_event_attr:
type 24 (uncore_imc_free_running_0)
size 136
config 0x20ff (data_read)
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
exclude_guest 1
...Committer notes:
Fix the python binding build by adding dummies for not strictly needed perf_pmu__name_from_config() and perf_pmus__find_by_type().
Stable-dep-of: d9c5f5f94c2d ("perf pmu: Count sys and cpuid JSON events separately")
--- tools/perf/util/perf_event_attr_fprintf.c | 10 ++++++++-- tools/perf/util/pmu.c | 18 ++++++++++++++++++ tools/perf/util/pmu.h | 1 + tools/perf/util/python.c | 10 ++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-)
tools/perf/util/perf_event_attr_fprintf.c +8 -2
@@ -221,8 +221,14 @@ static void __p_config_tracepoint_id(char *buf, size_t size, u64 value) }#endif -static void __p_config_id (char *buf,size_t size,u32 type,u64 value) +static void __p_config_id (struct perf_pmu *pmu,char *buf,size_t size,u32 type,u64 value) { +const char *name =perf_pmu__name_from_config (pmu, value); + +if (name) { +print_id_hex (name); +return ; + }switch (type) {case PERF_TYPE_HARDWARE :return __p_config_hw_id (buf, size, value);
@@ -251,7 +257,7 @@ static void __p_config_id(char *buf, size_t size, u32 type, u64 value)#define p_branch_sample_type (val) __p_branch_sample_type(buf, BUF_SIZE, val)#define p_read_format (val) __p_read_format(buf, BUF_SIZE, val)#define p_type_id (val) __p_type_id(pmu, buf, BUF_SIZE, val) -#define p_config_id (val) __p_config_id(buf, BUF_SIZE, attr->type, val) +#define p_config_id (val) __p_config_id(pmu, buf, BUF_SIZE, attr->type, val)#define PRINT_ATTRn (_n, _f, _p, _a) \ do { \
tools/perf/util/pmu.c +18 -0
@@ -2081,3 +2081,21 @@ void perf_pmu__delete(struct perf_pmu *pmu)zfree (&pmu->id);free (pmu); } + +const char *perf_pmu__name_from_config (struct perf_pmu *pmu,u64 config) +{ +struct perf_pmu_alias *event; + +if (!pmu) +return NULL ; + +pmu_add_cpu_aliases (pmu); +list_for_each_entry (event, &pmu->aliases, list) { +struct perf_event_attr attr = {.config =0 ,}; +int ret =perf_pmu__config (pmu, &attr, &event->terms,NULL ); + +if (ret ==0 && config == attr.config) +return event->name; + } +return NULL ; +}
tools/perf/util/pmu.h +1 -0
@@ -266,5 +266,6 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const charstruct perf_pmu *perf_pmu__create_placeholder_core_pmu (struct list_head *core_pmus);void perf_pmu__delete (struct perf_pmu *pmu);struct perf_pmu *perf_pmus__find_core_pmu (void ); +const char *perf_pmu__name_from_config (struct perf_pmu *pmu,u64 config);#endif /* __PMU_H */
tools/perf/util/python.c +10 -0
@@ -103,6 +103,16 @@ int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,return EOF ; } +const char *perf_pmu__name_from_config (struct perf_pmu *pmu__maybe_unused ,u64 config__maybe_unused ) +{ +return NULL ; +} + +struct perf_pmu *perf_pmus__find_by_type (unsigned int type__maybe_unused ) +{ +return NULL ; +} +int perf_pmus__num_core_pmus (void ) {return 1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 530/744 perf pmu: Assume sysfs events are always the same case
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 7b6dd7a923281a7ccb980a0f768d6926721eb3cc ]
Perf event names aren't case sensitive. For sysfs events the entire directory of events is read then iterated comparing names in a case insensitive way, most often to see if an event is present.
Consider:
$ perf stat -e inst_retired.any true
The event inst_retired.any may be present in any PMU, so every PMU's sysfs events are loaded and then searched with strcasecmp to see if any match. This event is only present on the cpu PMU as a JSON event so a lot of events were loaded from sysfs unnecessarily just to prove an event didn't exist there.
This change avoids loading all the events by assuming sysfs event names are always either lower or uppercase. It uses file exists and only loads the events when the desired event is present.
For the example above, the number of openat calls measured by 'perf trace' on a tigerlake laptop goes from 325 down to 255. The reduction will be larger for machines with many PMUs, particularly replicated uncore PMUs.
Ensure pmu_aliases_parse() is called before all uses of the aliases list, but remove some "pmu->sysfs_aliases_loaded" tests as they are now part of the function.
Stable-dep-of: d9c5f5f94c2d ("perf pmu: Count sys and cpuid JSON events separately")
--- tools/perf/util/pmu.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-)
tools/perf/util/pmu.c +26 -5
@@ -425,9 +425,30 @@ static struct perf_pmu_alias *perf_pmu__find_alias(struct perf_pmu *pmu, {struct perf_pmu_alias *alias; -if (load && !pmu->sysfs_aliases_loaded) -pmu_aliases_parse (pmu); +if (load && !pmu->sysfs_aliases_loaded) { +bool has_sysfs_event; +char event_file_name[FILENAME_MAX +8 ]; +/* +* Test if alias/event 'name' exists in the PMU's sysfs/events +* directory. If not skip parsing the sysfs aliases. Sysfs event +* name must be all lower or all upper case. +*/ +scnprintf (event_file_name,sizeof (event_file_name),"events/%s" , name); +for (size_t i =7 , n =7 +strlen (name); i < n; i++) + event_file_name[i] =tolower (event_file_name[i]); + + has_sysfs_event =perf_pmu__file_exists (pmu, event_file_name); +if (!has_sysfs_event) { +for (size_t i =7 , n =7 +strlen (name); i < n; i++) + event_file_name[i] =toupper (event_file_name[i]); + + has_sysfs_event =perf_pmu__file_exists (pmu, event_file_name); + } +if (has_sysfs_event) +pmu_aliases_parse (pmu); + + }list_for_each_entry (alias, &pmu->aliases, list) {if (!strcasecmp (alias->name, name))return alias;
@@ -1627,9 +1648,7 @@ size_t perf_pmu__num_events(struct perf_pmu *pmu) {size_t nr; -if (!pmu->sysfs_aliases_loaded) -pmu_aliases_parse (pmu); - +pmu_aliases_parse (pmu); nr = pmu->sysfs_aliases;if (pmu->cpu_aliases_added)
@@ -1688,6 +1707,7 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, bool skip_duplicate_pmus,struct strbuf sb;strbuf_init (&sb,/*hint=*/ 0 ); +pmu_aliases_parse (pmu);pmu_add_cpu_aliases (pmu);list_for_each_entry (event, &pmu->aliases, list) {size_t buf_used;
@@ -2089,6 +2109,7 @@ const char *perf_pmu__name_from_config(struct perf_pmu *pmu, u64 config)if (!pmu)return NULL ; +pmu_aliases_parse (pmu);pmu_add_cpu_aliases (pmu);list_for_each_entry (event, &pmu->aliases, list) {struct perf_event_attr attr = {.config =0 ,};
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 531/744 perf pmu: Count sys and cpuid JSON events separately
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit d9c5f5f94c2d356fdf3503f7fcaf254512bc032d ]
Sys events are eagerly loaded as each event has a compat option that may mean the event is or isn't associated with the PMU.
These shouldn't be counted as loaded_json_events as that is used for JSON events matching the CPUID that may or may not have been loaded. The mismatch causes issues on ARM64 that uses sys events.
--- tools/perf/util/pmu.c | 70 ++++++++++++++++++++++++++++++------------- tools/perf/util/pmu.h | 6 ++-- 2 files changed, 53 insertions(+), 23 deletions(-)
tools/perf/util/pmu.c +49 -21
@@ -36,6 +36,18 @@ struct perf_pmu perf_pmu__fake = {#define UNIT_MAX_LEN 31/* max length for event unit name */ +enum event_source { +/* An event loaded from /sys/devices/<pmu>/events. */ +EVENT_SRC_SYSFS , +/* An event loaded from a CPUID matched json file. */ +EVENT_SRC_CPU_JSON , +/* +* An event loaded from a /sys/devices/<pmu>/identifier matched json +* file. +*/ +EVENT_SRC_SYS_JSON , +}; +/** * struct perf_pmu_alias - An event either read from sysfs or builtin in * pmu-events.c, created by parsing the pmu-events json files.
@@ -521,7 +533,7 @@ static int update_alias(const struct pmu_event *pe,static int perf_pmu__new_alias (struct perf_pmu *pmu,const char *name,const char *desc,const char *val,FILE *val_fd, -const struct pmu_event *pe) +const struct pmu_event *pe,enum event_source src) {struct perf_pmu_alias *alias;int ret;
@@ -573,25 +585,30 @@ static int perf_pmu__new_alias(struct perf_pmu *pmu, const char *name, }snprintf (alias->unit,sizeof (alias->unit),"%s" , unit); } -if (!pe) { -/* Update an event from sysfs with json data. */ -struct update_alias_data data = { - .pmu = pmu, - .alias = alias, - }; - +switch (src) { +default : +case EVENT_SRC_SYSFS : alias->from_sysfs = true;if (pmu->events_table) { +/* Update an event from sysfs with json data. */ +struct update_alias_data data = { + .pmu = pmu, + .alias = alias, + };if (pmu_events_table__find_event (pmu->events_table, pmu, name, update_alias, &data) ==0 ) - pmu->loaded_json_aliases++; + pmu->cpu_json_aliases++; } - } - -if (!pe) pmu->sysfs_aliases++; -else - pmu->loaded_json_aliases++; +break ; +case EVENT_SRC_CPU_JSON : + pmu->cpu_json_aliases++; +break ; +case EVENT_SRC_SYS_JSON : + pmu->sys_json_aliases++; +break ; + + }list_add_tail (&alias->list, &pmu->aliases);return 0 ; }
@@ -667,7 +684,8 @@ static int pmu_aliases_parse(struct perf_pmu *pmu) }if (perf_pmu__new_alias (pmu, name,/*desc=*/ NULL , -/*val=*/ NULL , file,/*pe=*/ NULL ) <0 ) +/*val=*/ NULL , file,/*pe=*/ NULL , +EVENT_SRC_SYSFS ) <0 )pr_debug ("Cannot set up %s\n" , name);fclose (file); }
@@ -924,7 +942,8 @@ static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe, {struct perf_pmu *pmu = vdata; -perf_pmu__new_alias (pmu, pe->name, pe->desc, pe->event,/*val_fd=*/ NULL , pe); +perf_pmu__new_alias (pmu, pe->name, pe->desc, pe->event,/*val_fd=*/ NULL , + pe,EVENT_SRC_CPU_JSON );return 0 ; }
@@ -959,13 +978,14 @@ static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe,return 0 ;if (pmu_uncore_alias_match (pe->pmu, pmu->name) && -pmu_uncore_identifier_match (pe->compat, pmu->id)) { +pmu_uncore_identifier_match (pe->compat, pmu->id)) {perf_pmu__new_alias (pmu, pe->name, pe->desc, pe->event,/*val_fd=*/ NULL , - pe); + pe, +EVENT_SRC_SYS_JSON ); }return 0 ;
@@ -1055,6 +1075,12 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char pmu->id =pmu_id (name); pmu->max_precise =pmu_max_precise (dirfd, pmu); pmu->events_table =perf_pmu__find_events_table (pmu); +/* +* Load the sys json events/aliases when loading the PMU as each event +* may have a different compat regular expression. We therefore can't +* know the number of sys json events/aliases without computing the +* regular expressions for them all. +*/ pmu_add_sys_aliases (pmu);list_add_tail (&pmu->list, pmus);
@@ -1649,12 +1675,14 @@ size_t perf_pmu__num_events(struct perf_pmu *pmu)size_t nr;pmu_aliases_parse (pmu); - nr = pmu->sysfs_aliases; + nr = pmu->sysfs_aliases + pmu->sys_json_aliases;;if (pmu->cpu_aliases_added) - nr += pmu->loaded_json_aliases; + nr += pmu->cpu_json_aliases;else if (pmu->events_table) - nr +=pmu_events_table__num_events (pmu->events_table, pmu) - pmu->loaded_json_aliases; + nr +=pmu_events_table__num_events (pmu->events_table, pmu) - pmu->cpu_json_aliases; +else +assert (pmu->cpu_json_aliases ==0 );return pmu->selectable ? nr +1 : nr; }
tools/perf/util/pmu.h +4 -2
@@ -120,8 +120,10 @@ struct perf_pmu {const struct pmu_events_table *events_table;/** @sysfs_aliases: Number of sysfs aliases loaded. */ uint32_t sysfs_aliases; -/** @sysfs_aliases: Number of json event aliases loaded. */ -uint32_t loaded_json_aliases; +/** @cpu_json_aliases: Number of json event aliases loaded specific to the CPUID. */ +uint32_t cpu_json_aliases; +/** @sys_json_aliases: Number of json event aliases loaded matching the PMU's identifier. */ +uint32_t sys_json_aliases;/** @sysfs_aliases_loaded: Are sysfs aliases loaded from disk? */ bool sysfs_aliases_loaded;/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 532/744 LoongArch: Fix callchain parse error with kernel tracepoint events again
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit d6af2c76399f98444a5b4de96baf4b362d9f102b ]
With commit d3119bc985fb645 ("LoongArch: Fix callchain parse error with kernel tracepoint events"), perf can parse kernel callchain, but not complete and sometimes maybe error. The reason is LoongArch's unwinders (guess, prologue and orc) don't really need fp (i.e., regs[22]), and they use sp (i.e., regs[3]) as the frame address rather than the current stack pointer.
Fix that by removing the assignment of regs[22], and instead assign the __builtin_frame_address(0) to regs[3].
Without fix:
Children Self Command Shared Object Symbol
........ ........ ............. ................. ................
33.91% 33.91% swapper [kernel.vmlinux] [k] __schedule
|
|--33.04%--__schedule
|
--0.87%--__arch_cpu_idle
__scheduleWith this fix:
Children Self Command Shared Object Symbol
........ ........ ............. ................. ................
31.16% 31.16% swapper [kernel.vmlinux] [k] __schedule
|
|--20.63%--smpboot_entry
| cpu_startup_entry
| schedule_idle
| __schedule
|
--10.53%--start_kernel
cpu_startup_entry
schedule_idle
__schedule--- arch/loongarch/include/asm/perf_event.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/loongarch/include/asm/perf_event.h +1 -2
@@ -13,8 +13,7 @@#define perf_arch_fetch_caller_regs (regs, __ip) { \ (regs)->csr_era = (__ip); \ - (regs)->regs[3] = current_stack_pointer; \ - (regs)->regs[22] = (unsigned long) __builtin_frame_address(0); \ + (regs)->regs[3] = (unsigned long) __builtin_frame_address(0); \ }#endif /* __LOONGARCH_PERF_EVENT_H__ */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 533/744 s390/vdso64: filter out munaligned-symbols flag for vdso
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumanth Korikkar <[email protected]>
[ Upstream commit 8192a1b3807510d0ed5be1f8988c08f8d41cced9 ]
Gcc recently implemented an optimization [1] for loading symbols without explicit alignment, aligning with the IBM Z ELF ABI. This ABI mandates symbols to reside on a 2-byte boundary, enabling the use of the larl instruction. However, kernel linker scripts may still generate unaligned symbols. To address this, a new -munaligned-symbols option has been introduced [2] in recent gcc versions.
[1] https://gcc.gnu.org/pipermail/gcc-patches/2023-June/622872.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2023-August/625986.html
However, when -munaligned-symbols is used in vdso code, it leads to the following compilation error:.data.rel.ro.local' referenced in section .text' of arch/s390/kernel/vdso64/vdso64_generic.o: defined in discarded section `.data.rel.ro.local' of arch/s390/kernel/vdso64/vdso64_generic.o
vdso linker script discards .data section to make it lightweight. However, -munaligned-symbols in vdso object files references literal pool and accesses _vdso_data. Hence, compile vdso code without -munaligned-symbols. This means in the future, vdso code should deal with alignment of newly introduced unaligned linker symbols.
Stable-dep-of: 10f705253651 ("s390/vdso: Generate unwind information for C modules")
--- arch/s390/kernel/vdso64/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/s390/kernel/vdso64/Makefile +1 -0
@@ -25,6 +25,7 @@ KBUILD_AFLAGS_64 += -m64 KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_64 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_64)) +KBUILD_CFLAGS_64 := $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_64)) KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin ldflags-y := -shared -soname=linux-vdso64.so.1 \ --hash-style=both --build-id=sha1 -T
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 534/744 s390/vdso: Generate unwind information for C modules
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Remus <[email protected]>
[ Upstream commit 10f70525365146046dddcc3d36bfaea2aee0376a ]
GDB fails to unwind vDSO functions with error message "PC not saved", for instance when stepping through gettimeofday().
Add -fasynchronous-unwind-tables to CFLAGS to generate .eh_frame DWARF unwind information for the vDSO C modules.
--- arch/s390/kernel/vdso32/Makefile | 3 ++- arch/s390/kernel/vdso64/Makefile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/s390/kernel/vdso32/Makefile +2 -1
@@ -20,7 +20,8 @@ KBUILD_AFLAGS_32 += -m31 -s KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_32 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_32)) -KBUILD_CFLAGS_32 += -m31 -fPIC -shared -fno-common -fno-builtin +KBUILD_CFLAGS_32 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_32)) +KBUILD_CFLAGS_32 += -m31 -fPIC -shared -fno-common -fno-builtin -fasynchronous-unwind-tables LDFLAGS_vdso32.so.dbg += -shared -soname=linux-vdso32.so.1 \ --hash-style=both --build-id=sha1 -melf_s390 -T
arch/s390/kernel/vdso64/Makefile +2 -1
@@ -26,7 +26,8 @@ KBUILD_AFLAGS_64 += -m64 KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_64 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_64)) KBUILD_CFLAGS_64 := $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_64)) -KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin +KBUILD_CFLAGS_64 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_64)) +KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin -fasynchronous-unwind-tables ldflags-y := -shared -soname=linux-vdso64.so.1 \ --hash-style=both --build-id=sha1 -T
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 535/744 kbuild: unify vdso_install rules
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit 56769ba4b297a629148eb24d554aef72d1ddfd9e ]
Currently, there is no standard implementation for vdso_install, leading to various issues:
1. Code duplication
Many architectures duplicate similar code just for copying files to the install destination.
Some architectures (arm, sparc, x86) create build-id symlinks, introducing more code duplication.
2. Unintended updates of in-tree build artifacts
The vdso_install rule depends on the vdso files to install. It may update in-tree build artifacts. This can be problematic, as explained in commit 19514fc665ff ("arm, kbuild: make "make install" not depend on vmlinux").
3. Broken code in some architectures
Makefile code is often copied from one architecture to another without proper adaptation.
'make vdso_install' for parisc does not work.
'make vdso_install' for s390 installs vdso64, but not vdso32.
To address these problems, this commit introduces a generic vdso_install rule.
Architectures that support vdso_install need to define vdso-install-y in arch/*/Makefile. vdso-install-y lists the files to install.
For example, arch/x86/Makefile looks like this:
vdso-install-$(CONFIG_X86_64) += arch/x86/entry/vdso/vdso64.so.dbg vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdsox32.so.dbg vdso-install-$(CONFIG_X86_32) += arch/x86/entry/vdso/vdso32.so.dbg vdso-install-$(CONFIG_IA32_EMULATION) += arch/x86/entry/vdso/vdso32.so.dbg
These files will be installed to $(MODLIB)/vdso/ with the .dbg suffix, if exists, stripped away.
vdso-install-y can optionally take the second field after the colon separator. This is needed because some architectures install a vdso file as a different base name.
The following is a snippet from arch/arm64/Makefile.
vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso.so.dbg:vdso32.so
This will rename vdso.so.dbg to vdso32.so during installation. If such architectures change their implementation so that the base names match, this workaround will go away.
Stable-dep-of: fc2f5f10f9bc ("s390/vdso: Create .build-id links for unstripped vdso files")
--- Makefile | 9 ++++++ arch/arm/Makefile | 7 +--- arch/arm/vdso/Makefile | 25 -------------- arch/arm64/Makefile | 9 ++---- arch/arm64/kernel/vdso/Makefile | 10 ------ arch/arm64/kernel/vdso32/Makefile | 10 ------ arch/loongarch/Makefile | 4 +-- arch/loongarch/vdso/Makefile | 10 ------ arch/parisc/Makefile | 8 ++--- arch/riscv/Makefile | 9 ++---- arch/riscv/kernel/compat_vdso/Makefile | 10 ------ arch/riscv/kernel/vdso/Makefile | 10 ------ arch/s390/Makefile | 6 ++-- arch/s390/kernel/vdso32/Makefile | 10 ------ arch/s390/kernel/vdso64/Makefile | 10 ------ arch/sparc/Makefile | 5 ++- arch/sparc/vdso/Makefile | 27 ---------------- arch/x86/Makefile | 7 ++-- arch/x86/entry/vdso/Makefile | 27 ---------------- scripts/Makefile.vdsoinst | 45 ++++++++++++++++++++++++++ 20 files changed, 73 insertions(+), 185 deletions(-) create mode 100644 scripts/Makefile.vdsoinst
Makefile +9 -0
@@ -1317,6 +1317,14 @@ scripts_unifdef: scripts_basic quiet_cmd_install = INSTALL $(INSTALL_PATH) cmd_install = unset sub_make_done; $(srctree)/scripts/install.sh +# --------------------------------------------------------------------------- +# vDSO install + +PHONY += vdso_install +vdso_install: export INSTALL_FILES = $(vdso-install-y) +vdso_install: + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst + # --------------------------------------------------------------------------- # Tools
@@ -1560,6 +1568,7 @@ help: @echo '* vmlinux - Build the bare kernel' @echo '* modules - Build all modules' @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' + @echo ' vdso_install - Install unstripped vdso to INSTALL_MOD_PATH (default: /)' @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[ois] - Build specified target only' @echo ' dir/file.ll - Build the LLVM assembly file'
arch/arm/Makefile +1 -6
@@ -304,11 +304,7 @@ $(INSTALL_TARGETS): KBUILD_IMAGE = $(boot)/$(patsubst %install,%Image,$@) $(INSTALL_TARGETS): $(call cmd,install) -PHONY += vdso_install -vdso_install: -ifeq ($(CONFIG_VDSO),y) - $(Q)$(MAKE) $(build)=arch/arm/vdso $@ -endif +vdso-install-$(CONFIG_VDSO) += arch/arm/vdso/vdso.so.dbg # My testing targets (bypasses dependencies) bp:; $(Q)$(MAKE) $(build)=$(boot) $(boot)/bootpImage
@@ -331,7 +327,6 @@ define archhelp echo ' Install using (your) ~/bin/$(INSTALLKERNEL) or' echo ' (distribution) /sbin/$(INSTALLKERNEL) or' echo ' install to $$(INSTALL_PATH) and run lilo' - echo ' vdso_install - Install unstripped vdso.so to $$(INSTALL_MOD_PATH)/vdso' echo echo ' multi_v7_lpae_defconfig - multi_v7_defconfig with CONFIG_ARM_LPAE enabled' endef
arch/arm/vdso/Makefile +0 -25
@@ -63,28 +63,3 @@ quiet_cmd_vdsold_and_vdso_check = LD $@ quiet_cmd_vdsomunge = MUNGE $@ cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@ - -# -# Install the unstripped copy of vdso.so.dbg. If our toolchain -# supports build-id, install .build-id links as well. -# -# Cribbed from arch/x86/vdso/Makefile. -# -quiet_cmd_vdso_install = INSTALL $< -define cmd_vdso_install - cp $< "$(MODLIB)/vdso/vdso.so"; \ - if readelf -n $< | grep -q 'Build ID'; then \ - buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ - first=`echo $$buildid | cut -b-2`; \ - last=`echo $$buildid | cut -b3-`; \ - mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ - ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ - fi -endef - -$(MODLIB)/vdso: FORCE - @mkdir -p $(MODLIB)/vdso - -PHONY += vdso_install -vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso - $(call cmd,vdso_install)
arch/arm64/Makefile +3 -6
@@ -169,12 +169,6 @@ install: KBUILD_IMAGE := $(boot)/Image install zinstall: $(call cmd,install) -PHONY += vdso_install -vdso_install: - $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ - $(if $(CONFIG_COMPAT_VDSO), \ - $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@) - archprepare: $(Q)$(MAKE) $(build)=arch/arm64/tools kapi ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
@@ -205,6 +199,9 @@ ifdef CONFIG_COMPAT_VDSO endif endif +vdso-install-y += arch/arm64/kernel/vdso/vdso.so.dbg +vdso-install-$(CONFIG_COMPAT_VDSO) += arch/arm64/kernel/vdso32/vdso.so.dbg:vdso32.so + include $(srctree)/scripts/Makefile.defconf PHONY += virtconfig
arch/arm64/kernel/vdso/Makefile +0 -10
@@ -78,13 +78,3 @@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE # Actual build commands quiet_cmd_vdsold_and_vdso_check = LD $@ cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check) - -# Install commands for the unstripped file -quiet_cmd_vdso_install = INSTALL $@ - cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/$@ - -vdso.so: $(obj)/vdso.so.dbg - @mkdir -p $(MODLIB)/vdso - $(call cmd,vdso_install) - -vdso_install: vdso.so
arch/arm64/kernel/vdso32/Makefile +0 -10
@@ -172,13 +172,3 @@ gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh quiet_cmd_vdsosym = VDSOSYM $@ # The AArch64 nm should be able to read an AArch32 binary cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ - -# Install commands for the unstripped file -quiet_cmd_vdso_install = INSTALL32 $@ - cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/vdso32.so - -vdso.so: $(obj)/vdso.so.dbg - @mkdir -p $(MODLIB)/vdso - $(call cmd,vdso_install) - -vdso_install: vdso.so
arch/loongarch/Makefile +1 -3
@@ -136,9 +136,7 @@ vdso_prepare: prepare0 $(Q)$(MAKE) $(build)=arch/loongarch/vdso include/generated/vdso-offsets.h endif -PHONY += vdso_install -vdso_install: - $(Q)$(MAKE) $(build)=arch/loongarch/vdso $@ +vdso-install-y += arch/loongarch/vdso/vdso.so.dbg all: $(notdir $(KBUILD_IMAGE))
arch/loongarch/vdso/Makefile +0 -10
@@ -84,13 +84,3 @@ $(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE obj-y += vdso.o $(obj)/vdso.o : $(obj)/vdso.so - -# install commands for the unstripped file -quiet_cmd_vdso_install = INSTALL $@ - cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/$@ - -vdso.so: $(obj)/vdso.so.dbg - @mkdir -p $(MODLIB)/vdso - $(call cmd,vdso_install) - -vdso_install: vdso.so
arch/parisc/Makefile +2 -6
@@ -177,12 +177,8 @@ vdso_prepare: prepare0 $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 include/generated/vdso32-offsets.h endif -PHONY += vdso_install - -vdso_install: - $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso $@ - $(if $(CONFIG_COMPAT_VDSO), \ - $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 $@) +vdso-install-y += arch/parisc/kernel/vdso32/vdso32.so +vdso-install-$(CONFIG_64BIT) += arch/parisc/kernel/vdso64/vdso64.so install: KBUILD_IMAGE := vmlinux zinstall: KBUILD_IMAGE := vmlinuz
arch/riscv/Makefile +3 -6
@@ -130,12 +130,6 @@ endif libs-y += arch/riscv/lib/ libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a -PHONY += vdso_install -vdso_install: - $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@ - $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \ - $(build)=arch/riscv/kernel/compat_vdso compat_$@) - ifeq ($(KBUILD_EXTMOD),) ifeq ($(CONFIG_MMU),y) prepare: vdso_prepare
@@ -147,6 +141,9 @@ vdso_prepare: prepare0 endif endif +vdso-install-y += arch/riscv/kernel/vdso/vdso.so.dbg +vdso-install-$(CONFIG_COMPAT) += arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg:../compat_vdso/compat_vdso.so + ifneq ($(CONFIG_XIP_KERNEL),y) ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy) KBUILD_IMAGE := $(boot)/loader.bin
arch/riscv/kernel/compat_vdso/Makefile +0 -10
@@ -76,13 +76,3 @@ quiet_cmd_compat_vdsold = VDSOLD $@ # actual build commands quiet_cmd_compat_vdsoas = VDSOAS $@ cmd_compat_vdsoas = $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c -o $@ $< - -# install commands for the unstripped file -quiet_cmd_compat_vdso_install = INSTALL $@ - cmd_compat_vdso_install = cp $(obj)/[email protected] $(MODLIB)/compat_vdso/$@ - -compat_vdso.so: $(obj)/compat_vdso.so.dbg - @mkdir -p $(MODLIB)/compat_vdso - $(call cmd,compat_vdso_install) - -compat_vdso_install: compat_vdso.so
arch/riscv/kernel/vdso/Makefile +0 -10
@@ -73,13 +73,3 @@ quiet_cmd_vdsold = VDSOLD $@ cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o [email protected] && \ $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) [email protected] $@ && \ rm [email protected] - -# install commands for the unstripped file -quiet_cmd_vdso_install = INSTALL $@ - cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/$@ - -vdso.so: $(obj)/vdso.so.dbg - @mkdir -p $(MODLIB)/vdso - $(call cmd,vdso_install) - -vdso_install: vdso.so
arch/s390/Makefile +3 -3
@@ -138,9 +138,6 @@ bzImage: vmlinux zfcpdump: $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ -vdso_install: - $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@ - archheaders: $(Q)$(MAKE) $(build)=$(syscalls) uapi
@@ -160,6 +157,9 @@ vdso_prepare: prepare0 $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \ $(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h) +vdso-install-y += arch/s390/kernel/vdso64/vdso64.so.dbg +vdso-install-$(CONFIG_COMPAT) += arch/s390/kernel/vdso32/vdso32.so.dbg + ifdef CONFIG_EXPOLINE_EXTERN modules_prepare: expoline_prepare expoline_prepare: scripts
arch/s390/kernel/vdso32/Makefile +0 -10
@@ -62,16 +62,6 @@ quiet_cmd_vdso32as = VDSO32A $@ quiet_cmd_vdso32cc = VDSO32C $@ cmd_vdso32cc = $(CC) $(c_flags) -c -o $@ $< -# install commands for the unstripped file -quiet_cmd_vdso_install = INSTALL $@ - cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/$@ - -vdso32.so: $(obj)/vdso32.so.dbg - @mkdir -p $(MODLIB)/vdso - $(call cmd,vdso_install) - -vdso_install: vdso32.so - # Generate VDSO offsets using helper script gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh quiet_cmd_vdsosym = VDSOSYM $@
arch/s390/kernel/vdso64/Makefile +0 -10
@@ -72,16 +72,6 @@ quiet_cmd_vdso64as = VDSO64A $@ quiet_cmd_vdso64cc = VDSO64C $@ cmd_vdso64cc = $(CC) $(c_flags) -c -o $@ $< -# install commands for the unstripped file -quiet_cmd_vdso_install = INSTALL $@ - cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/$@ - -vdso64.so: $(obj)/vdso64.so.dbg - @mkdir -p $(MODLIB)/vdso - $(call cmd,vdso_install) - -vdso_install: vdso64.so - # Generate VDSO offsets using helper script gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh quiet_cmd_vdsosym = VDSOSYM $@
arch/sparc/Makefile +2 -3
@@ -76,9 +76,8 @@ install: archheaders: $(Q)$(MAKE) $(build)=arch/sparc/kernel/syscalls all -PHONY += vdso_install -vdso_install: - $(Q)$(MAKE) $(build)=arch/sparc/vdso $@ +vdso-install-$(CONFIG_SPARC64) += arch/sparc/vdso/vdso64.so.dbg +vdso-install-$(CONFIG_COMPAT) += arch/sparc/vdso/vdso32.so.dbg # This is the image used for packaging KBUILD_IMAGE := $(boot)/zImage
arch/sparc/vdso/Makefile +0 -27
@@ -116,30 +116,3 @@ quiet_cmd_vdso = VDSO $@ VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic GCOV_PROFILE := n - -# -# Install the unstripped copies of vdso*.so. If our toolchain supports -# build-id, install .build-id links as well. -# -quiet_cmd_vdso_install = INSTALL $(@:install_%=%) -define cmd_vdso_install - cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \ - if readelf -n $< |grep -q 'Build ID'; then \ - buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ - first=`echo $$buildid | cut -b-2`; \ - last=`echo $$buildid | cut -b3-`; \ - mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ - ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ - fi -endef - -vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%) - -$(MODLIB)/vdso: FORCE - @mkdir -p $(MODLIB)/vdso - -$(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE - $(call cmd,vdso_install) - -PHONY += vdso_install $(vdso_img_insttargets) -vdso_install: $(vdso_img_insttargets) FORCE
arch/x86/Makefile +4 -3
@@ -291,9 +291,10 @@ PHONY += install install: $(call cmd,install) -PHONY += vdso_install -vdso_install: - $(Q)$(MAKE) $(build)=arch/x86/entry/vdso $@ +vdso-install-$(CONFIG_X86_64) += arch/x86/entry/vdso/vdso64.so.dbg +vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdsox32.so.dbg +vdso-install-$(CONFIG_X86_32) += arch/x86/entry/vdso/vdso32.so.dbg +vdso-install-$(CONFIG_IA32_EMULATION) += arch/x86/entry/vdso/vdso32.so.dbg archprepare: checkbin checkbin:
arch/x86/entry/vdso/Makefile +0 -27
@@ -190,31 +190,4 @@ GCOV_PROFILE := n quiet_cmd_vdso_and_check = VDSO $@ cmd_vdso_and_check = $(cmd_vdso); $(cmd_vdso_check) -# -# Install the unstripped copies of vdso*.so. If our toolchain supports -# build-id, install .build-id links as well. -# -quiet_cmd_vdso_install = INSTALL $(@:install_%=%) -define cmd_vdso_install - cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \ - if readelf -n $< |grep -q 'Build ID'; then \ - buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \ - first=`echo $$buildid | cut -b-2`; \ - last=`echo $$buildid | cut -b3-`; \ - mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \ - ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \ - fi -endef - -vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%) - -$(MODLIB)/vdso: FORCE - @mkdir -p $(MODLIB)/vdso - -$(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso - $(call cmd,vdso_install) - -PHONY += vdso_install $(vdso_img_insttargets) -vdso_install: $(vdso_img_insttargets) - clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so*
scripts/Makefile.vdsoinst new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 536/744 kbuild: fix build ID symlinks to installed debug VDSO files
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit c1a8627164dbe8b92958aea10c7c0848105a3d7f ]
Commit 56769ba4b297 ("kbuild: unify vdso_install rules") accidentally dropped the '.debug' suffix from the build ID symlinks.
Stable-dep-of: fc2f5f10f9bc ("s390/vdso: Create .build-id links for unstripped vdso files")
--- scripts/Makefile.vdsoinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.vdsoinst +1 -1
@@ -22,7 +22,7 @@ $$(dest): $$(src) FORCE # Some architectures create .build-id symlinks ifneq ($(filter arm sparc x86, $(SRCARCH)),) -link := $(install-dir)/.build-id/$$(shell $(READELF) -n $$(src) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') +link := $(install-dir)/.build-id/$$(shell $(READELF) -n $$(src) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p').debug __default: $$(link) $$(link): $$(dest) FORCE
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 537/744 s390/vdso: Create .build-id links for unstripped vdso files
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Remus <[email protected]>
[ Upstream commit fc2f5f10f9bc5e58d38e9fda7dae107ac04a799f ]
Citing Andy Lutomirski from commit dda1e95cee38 ("x86/vdso: Create .build-id links for unstripped vdso files"):
"With this change, doing 'make vdso_install' and telling gdb:
set debug-file-directory /lib/modules/KVER/vdso
will enable vdso debugging with symbols. This is useful for testing, but kernel RPM builds will probably want to manually delete these symlinks or otherwise do something sensible when they strip the vdso/*.so files."
--- scripts/Makefile.vdsoinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.vdsoinst +1 -1
@@ -21,7 +21,7 @@ $$(dest): $$(src) FORCE $$(call cmd,install) # Some architectures create .build-id symlinks -ifneq ($(filter arm sparc x86, $(SRCARCH)),) +ifneq ($(filter arm s390 sparc x86, $(SRCARCH)),) link := $(install-dir)/.build-id/$$(shell $(READELF) -n $$(src) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p').debug __default: $$(link)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 538/744 s390/vdso: Use standard stack frame layout
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 185445c7c137822ad856aae91a41e199370cb534 ]
By default user space is compiled with standard stack frame layout and not with the packed stack layout. The vdso code however inherited the -mpacked-stack compiler option from the kernel. Remove this option to make sure the vdso is compiled with standard stack frame layout.
This makes sure that the stack frame backchain location for vdso generated stack frames is the same like for calling code (if compiled with default options). This allows to manually walk stack frames without DWARF information, like the kernel is doing it e.g. with arch_stack_walk_user().
--- arch/s390/kernel/vdso32/Makefile | 1 + arch/s390/kernel/vdso64/Makefile | 1 + 2 files changed, 2 insertions(+)
arch/s390/kernel/vdso32/Makefile +1 -0
@@ -19,6 +19,7 @@ KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) KBUILD_AFLAGS_32 += -m31 -s KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) +KBUILD_CFLAGS_32 := $(filter-out -mpacked-stack,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_32 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 += -m31 -fPIC -shared -fno-common -fno-builtin -fasynchronous-unwind-tables
arch/s390/kernel/vdso64/Makefile +1 -0
@@ -24,6 +24,7 @@ KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS)) KBUILD_AFLAGS_64 += -m64 KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) +KBUILD_CFLAGS_64 := $(filter-out -mpacked-stack,$(KBUILD_CFLAGS_64)) KBUILD_CFLAGS_64 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_64)) KBUILD_CFLAGS_64 := $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_64)) KBUILD_CFLAGS_64 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_64))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 539/744 s390/ipl: Fix incorrect initialization of len fields in nvme reipl block
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Egorenkov <[email protected]>
[ Upstream commit 9c922b73acaf39f867668d9cbe5dc69c23511f84 ]
Use correct symbolic constants IPL_BP_NVME_LEN and IPL_BP0_NVME_LEN to initialize nvme reipl block when 'scp_data' sysfs attribute is being updated. This bug had not been detected before because the corresponding fcp and nvme symbolic constants are equal.
--- arch/s390/kernel/ipl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kernel/ipl.c +2 -2
@@ -962,8 +962,8 @@ static ssize_t reipl_nvme_scpdata_write(struct file *filp, struct kobject *kobj, scpdata_len += padding; } - reipl_block_nvme->hdr.len =IPL_BP_FCP_LEN + scpdata_len; - reipl_block_nvme->nvme.len =IPL_BP0_FCP_LEN + scpdata_len; + reipl_block_nvme->hdr.len =IPL_BP_NVME_LEN + scpdata_len; + reipl_block_nvme->nvme.len =IPL_BP0_NVME_LEN + scpdata_len; reipl_block_nvme->nvme.scp_data_len = scpdata_len;return count;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 540/744 s390/ipl: Fix incorrect initialization of nvme dump block
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Egorenkov <[email protected]>
[ Upstream commit 7faacaeaf6ce12fae78751de5ad869d8f1e1cd7a ]
Initialize the correct fields of the nvme dump block.
This bug had not been detected before because first, the fcp and nvme fields of struct ipl_parameter_block are part of the same union and, therefore, overlap in memory and second, they are identical in structure and size.
--- arch/s390/kernel/ipl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kernel/ipl.c +3 -3
@@ -1858,9 +1858,9 @@ static int __init dump_nvme_init(void) } dump_block_nvme->hdr.len =IPL_BP_NVME_LEN ; dump_block_nvme->hdr.version =IPL_PARM_BLOCK_VERSION ; - dump_block_nvme->fcp.len =IPL_BP0_NVME_LEN ; - dump_block_nvme->fcp.pbt =IPL_PBT_NVME ; - dump_block_nvme->fcp.opt =IPL_PB0_NVME_OPT_DUMP ; + dump_block_nvme->nvme.len =IPL_BP0_NVME_LEN ; + dump_block_nvme->nvme.pbt =IPL_PBT_NVME ; + dump_block_nvme->nvme.opt =IPL_PB0_NVME_OPT_DUMP ; dump_capabilities |=DUMP_TYPE_NVME ;return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 541/744 s390/boot: Remove alt_stfle_fac_list from decompressor
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Schnelle <[email protected]>
[ Upstream commit e7dec0b7926f3cd493c697c4c389df77e8e8a34c ]
It is nowhere used in the decompressor, therefore remove it.
--- arch/s390/boot/startup.c | 1 - arch/s390/kernel/setup.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
arch/s390/boot/startup.c +0 -1
@@ -31,7 +31,6 @@ unsigned long __bootdata_preserved(max_mappable);unsigned long __bootdata (ident_map_size );u64 __bootdata_preserved (stfle_fac_list [16 ]); -u64 __bootdata_preserved (alt_stfle_fac_list [16 ]);struct oldmem_data __bootdata_preserved (oldmem_data );struct machine_info machine;
arch/s390/kernel/setup.c +1 -1
@@ -155,7 +155,7 @@ unsigned int __bootdata_preserved(zlib_dfltcc_support);EXPORT_SYMBOL (zlib_dfltcc_support);u64 __bootdata_preserved (stfle_fac_list [16 ]);EXPORT_SYMBOL (stfle_fac_list); -u64 __bootdata_preserved (alt_stfle_fac_list [16 ]); +u64 alt_stfle_fac_list[16 ];struct oldmem_data __bootdata_preserved (oldmem_data );unsigned long VMALLOC_START ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 542/744 dt-bindings: PCI: rockchip,rk3399-pcie: Add missing maxItems to ep-gpios
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 52d06636a4ae4db24ebfe23fae7a525f7e983604 ]
Properties with GPIOs should define number of actual GPIOs, so add missing maxItems to ep-gpios. Otherwise multiple GPIOs could be provided which is not a true hardware description.
--- Documentation/devicetree/bindings/pci/rockchip,rk3399-pcie.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/pci/rockchip,rk3399-pcie.yaml +1 -0
@@ -37,6 +37,7 @@ properties: description: This property is needed if using 24MHz OSC for RC's PHY. ep-gpios: + maxItems: 1 description: pre-reset GPIO vpcie12v-supply:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 543/744 gpiolib: acpi: Fix failed in acpi_gpiochip_find() by adding parent node match
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Devyn Liu <[email protected]>
[ Upstream commit adbc49a5a8c6fcf7be154c2e30213bbf472940da ]
Previous patch modified the standard used by acpi_gpiochip_find() to match device nodes. Using the device node set in gc->gpiodev->d- ev instead of gc->parent.
However, there is a situation in gpio-dwapb where the GPIO device driver will set gc->fwnode for each port corresponding to a child node under a GPIO device, so gc->gpiodev->dev will be assigned the value of each child node in gpiochip_add_data().
gpio-dwapb.c:
128,31 static int dwapb_gpio_add_port(struct dwapb_gpio *gpio,
struct dwapb_port_property *pp, unsigned int offs);
port->gc.fwnode = pp->fwnode;
693,39 static int dwapb_gpio_probe;
err = dwapb_gpio_add_port(gpio, &pdata->properties[i], i);
When other drivers request GPIO pin resources through the GPIO device node provided by ACPI (corresponding to the parent node), the change of the matching object to gc->gpiodev->dev in acpi_gpiochip_find() only allows finding the value of each port (child node), resulting in a failed request.
Reapply the condition of using gc->parent for match in acpi_gpio- chip_find() in the code can compatible with the problem of gpio-dwapb, and will not affect the two cases mentioned in the patch:
1. There is no setting for gc->fwnode.
2. The case that depends on using gc->fwnode for match.
--- drivers/gpio/gpiolib-acpi.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib-acpi.c +18 -1
@@ -128,7 +128,24 @@ static bool acpi_gpio_deferred_req_irqs_done;static int acpi_gpiochip_find (struct gpio_chip *gc,void *data) { -return device_match_acpi_handle (&gc->gpiodev->dev, data); +/* First check the actual GPIO device */ +if (device_match_acpi_handle (&gc->gpiodev->dev, data)) +return true; + +/* +* When the ACPI device is artificially split to the banks of GPIOs, +* where each of them is represented by a separate GPIO device, +* the firmware node of the physical device may not be shared among +* the banks as they may require different values for the same property, +* e.g., number of GPIOs in a certain bank. In such case the ACPI handle +* of a GPIO device is NULL and can not be used. Hence we have to check +* the parent device to be sure that there is no match before bailing +* out. +*/ +if (gc->parent) +return device_match_acpi_handle (gc->parent, data); + +return false; }/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 544/744 drm/amd/display: Remove pixle rate limit for subvp
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alvin Lee <[email protected]>
[ Upstream commit 340383c734f8a4e1663d26356b35fd8050851168 ]
Subvp bugs related to 8K60 have been fixed, so remove the limit that blocks 8K60 timings from enabling SubVP.
Stable-dep-of: cf8c498694a4 ("drm/amd/display: Revert Remove pixle rate limit for subvp")
--- drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +0 -1
@@ -697,7 +697,6 @@ static bool dcn32_assign_subvp_pipe(struct dc *dc,* - Not TMZ surface */ if (pipe->plane_state && !pipe->top_pipe && !dcn32_is_center_timing(pipe) && - !(pipe->stream->timing.pix_clk_100hz / 10000 > DCN3_2_MAX_SUBVP_PIXEL_RATE_MHZ) && (!dcn32_is_psr_capable(pipe) || (context->stream_count == 1 && dc->caps.dmub_caps.subvp_psr)) && pipe->stream->mall_stream_config.type == SUBVP_NONE && (refresh_rate < 120 || dcn32_allow_subvp_high_refresh_rate(dc, context, pipe)) &&
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 545/744 drm/amd/display: Revert Remove pixle rate limit for subvp
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenjing Liu <[email protected]>
[ Upstream commit cf8c498694a443e28dc1222f3ab94677114a4724 ]
This reverts commit 340383c734f8 ("drm/amd/display: Remove pixle rate limit for subvp")
[why]
The original commit causes a regression when subvp is applied on ODM required 8k60hz timing. The display shows black screen on boot. The issue can be recovered with hotplug. It also causes MPO to fail. We will temprarily revert this commit and investigate the root cause further.
--- drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +1 -0
@@ -697,6 +697,7 @@ static bool dcn32_assign_subvp_pipe(struct dc *dc,* - Not TMZ surface */ if (pipe->plane_state && !pipe->top_pipe && !dcn32_is_center_timing(pipe) && + !(pipe->stream->timing.pix_clk_100hz / 10000 > DCN3_2_MAX_SUBVP_PIXEL_RATE_MHZ) && (!dcn32_is_psr_capable(pipe) || (context->stream_count == 1 && dc->caps.dmub_caps.subvp_psr)) && pipe->stream->mall_stream_config.type == SUBVP_NONE && (refresh_rate < 120 || dcn32_allow_subvp_high_refresh_rate(dc, context, pipe)) &&
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 546/744 eventfs: Do not differentiate the toplevel events directory
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit d53891d348ac3eceaf48f4732a1f4f5c0e0a55ce ]
The toplevel events directory is really no different than the events directory of instances. Having the two be different caused inconsistencies and made it harder to fix the permissions bugs.
Make all events directories act the same.
--- fs/tracefs/event_inode.c | 29 ++++++++--------------------- fs/tracefs/internal.h | 7 +++---- 2 files changed, 11 insertions(+), 25 deletions(-)
fs/tracefs/event_inode.c +8 -21
@@ -57,7 +57,6 @@ enum {EVENTFS_SAVE_MODE =BIT (16 ),EVENTFS_SAVE_UID =BIT (17 ), EVENTFS_SAVE_GID = BIT(18), - EVENTFS_TOPLEVEL = BIT(19), };#define EVENTFS_MODE_MASK (EVENTFS_SAVE_MODE - 1)
@@ -182,14 +181,10 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,return ret; } -static void update_top_events_attr (struct eventfs_inode *ei,struct super_block *sb) +static void update_events_attr (struct eventfs_inode *ei,struct super_block *sb) {struct inode *root; -/* Only update if the "events" was on the top level */ -if (!ei || !(ei->attr.mode &EVENTFS_TOPLEVEL )) -return ; -/* Get the tracefs root inode. */ root =d_inode (sb->s_root); ei->attr.uid = root->i_uid;
@@ -202,10 +197,10 @@ static void set_top_events_ownership(struct inode *inode)struct eventfs_inode *ei = ti->private;/* The top events directory doesn't get automatically updated */ -if (!ei || !ei->is_events || !(ei->attr.mode &EVENTFS_TOPLEVEL )) +if (!ei || !ei->is_events)return ; -update_top_events_attr (ei, inode->i_sb); +update_events_attr (ei, inode->i_sb);if (!(ei->attr.mode &EVENTFS_SAVE_UID )) inode->i_uid = ei->attr.uid;
@@ -234,7 +229,7 @@ static int eventfs_permission(struct mnt_idmap *idmap,return generic_permission (idmap, inode, mask); } -static const struct inode_operations eventfs_root_dir_inode_operations = { +static const struct inode_operations eventfs_dir_inode_operations = { .lookup = eventfs_root_lookup, .setattr = eventfs_set_attr, .getattr = eventfs_get_attr,
@@ -302,7 +297,7 @@ static struct eventfs_inode *eventfs_find_events(struct dentry *dentry)// Walk upwards until you find the events inode }while (!ei->is_events); -update_top_events_attr (ei, dentry->d_sb); +update_events_attr (ei, dentry->d_sb);return ei; }
@@ -406,7 +401,7 @@ static struct dentry *lookup_dir_entry(struct dentry *dentry,update_inode_attr (dentry, inode, &ei->attr,S_IFDIR |S_IRWXU |S_IRUGO |S_IXUGO ); - inode->i_op = &eventfs_root_dir_inode_operations; + inode->i_op = &eventfs_dir_inode_operations; inode->i_fop = &eventfs_file_operations;/* All directories will have the same inode number */
@@ -755,14 +750,6 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry uid =d_inode (dentry->d_parent)->i_uid; gid =d_inode (dentry->d_parent)->i_gid; -/* -* If the events directory is of the top instance, then parent -* is NULL. Set the attr.mode to reflect this and its permissions will -* default to the tracefs root dentry. -*/ -if (!parent) - ei->attr.mode =EVENTFS_TOPLEVEL ; -/* This is used as the default ownership of the files and directories */ ei->attr.uid = uid; ei->attr.gid = gid;
@@ -771,13 +758,13 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentryINIT_LIST_HEAD (&ei->list); ti =get_tracefs (inode); - ti->flags |=TRACEFS_EVENT_INODE |TRACEFS_EVENT_TOP_INODE ; + ti->flags |=TRACEFS_EVENT_INODE ; ti->private = ei; inode->i_mode =S_IFDIR |S_IRWXU |S_IRUGO |S_IXUGO ; inode->i_uid = uid; inode->i_gid = gid; - inode->i_op = &eventfs_root_dir_inode_operations; + inode->i_op = &eventfs_dir_inode_operations; inode->i_fop = &eventfs_file_operations; dentry->d_fsdata =get_ei (ei);
fs/tracefs/internal.h +3 -4
@@ -4,10 +4,9 @@enum {TRACEFS_EVENT_INODE =BIT (1 ), -TRACEFS_EVENT_TOP_INODE =BIT (2 ), -TRACEFS_GID_PERM_SET =BIT (3 ), -TRACEFS_UID_PERM_SET =BIT (4 ), -TRACEFS_INSTANCE_INODE =BIT (5 ), +TRACEFS_GID_PERM_SET =BIT (2 ), +TRACEFS_UID_PERM_SET =BIT (3 ), +TRACEFS_INSTANCE_INODE =BIT (4 ), };struct tracefs_inode {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 547/744 iio: accel: mxc4005: allow module autoloading via OF compatible
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
[ Upstream commit 4d7c16d08d248952c116f2eb9b7b5abc43a19688 ]
Add OF device table with compatible strings to allow automatic module loading.
Stable-dep-of: 6b8cffdc4a31 ("iio: accel: mxc4005: Reset chip on probe() and resume()")
--- drivers/iio/accel/mxc4005.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/iio/accel/mxc4005.c +8 -0
@@ -486,6 +486,13 @@ static const struct acpi_device_id mxc4005_acpi_match[] = { };MODULE_DEVICE_TABLE (acpi, mxc4005_acpi_match); +static const struct of_device_id mxc4005_of_match[] = { + { .compatible ="memsic,mxc4005" , }, + { .compatible ="memsic,mxc6655" , }, + { }, +}; +MODULE_DEVICE_TABLE (of, mxc4005_of_match); +static const struct i2c_device_id mxc4005_id[] = { {"mxc4005" ,0 }, {"mxc6655" ,0 },
@@ -497,6 +504,7 @@ static struct i2c_driver mxc4005_driver = { .driver = { .name = MXC4005_DRV_NAME, .acpi_match_table = ACPI_PTR(mxc4005_acpi_match), + .of_match_table = mxc4005_of_match, }, .probe = mxc4005_probe, .id_table = mxc4005_id,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 548/744 iio: accel: mxc4005: Reset chip on probe() and resume()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit 6b8cffdc4a31e4a72f75ecd1bc13fbf0dafee390 ]
On some designs the chip is not properly reset when powered up at boot or after a suspend/resume cycle.
Use the sw-reset feature to ensure that the chip is in a clean state after probe() / resume() and in the case of resume() restore the settings (scale, trigger-enabled).
--- drivers/iio/accel/mxc4005.c | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
drivers/iio/accel/mxc4005.c +68 -0
@@ -5,6 +5,7 @@* Copyright (c) 2014, Intel Corporation. */ +#include <linux/delay.h> #include <linux/module.h> #include <linux/i2c.h> #include <linux/iio/iio.h>
@@ -36,6 +37,7 @@#define MXC4005_REG_INT_CLR1 0x01#define MXC4005_REG_INT_CLR1_BIT_DRDYC 0x01 +#define MXC4005_REG_INT_CLR1_SW_RST 0x10#define MXC4005_REG_CONTROL 0x0D#define MXC4005_REG_CONTROL_MASK_FSR GENMASK(6, 5)
@@ -43,6 +45,9 @@#define MXC4005_REG_DEVICE_ID 0x0E +/* Datasheet does not specify a reset time, this is a conservative guess */ +#define MXC4005_RESET_TIME_US 2000 +enum mxc4005_axis {AXIS_X ,AXIS_Y ,
@@ -66,6 +71,8 @@ struct mxc4005_data {s64 timestamp__aligned(8) ; } scan;bool trigger_enabled; +unsigned int control; +unsigned int int_mask1; };/*
@@ -349,6 +356,7 @@ static int mxc4005_set_trigger_state(struct iio_trigger *trig,return ret; } + data->int_mask1 = val; data->trigger_enabled = state;mutex_unlock (&data->mutex);
@@ -384,6 +392,13 @@ static int mxc4005_chip_init(struct mxc4005_data *data)dev_dbg (data->dev,"MXC4005 chip id %02x\n" , reg); + ret =regmap_write (data->regmap,MXC4005_REG_INT_CLR1 , +MXC4005_REG_INT_CLR1_SW_RST ); +if (ret <0 ) +return dev_err_probe (data->dev, ret,"resetting chip\n" ); + +fsleep (MXC4005_RESET_TIME_US ); + ret =regmap_write (data->regmap,MXC4005_REG_INT_MASK0 ,0 );if (ret <0 )return dev_err_probe (data->dev, ret,"writing INT_MASK0\n" );
@@ -479,6 +494,58 @@ static int mxc4005_probe(struct i2c_client *client)return devm_iio_device_register (&client->dev, indio_dev); } +static int mxc4005_suspend (struct device *dev) +{ +struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct mxc4005_data *data =iio_priv (indio_dev); +int ret; + +/* Save control to restore it on resume */ + ret =regmap_read (data->regmap,MXC4005_REG_CONTROL , &data->control); +if (ret <0 ) +dev_err (data->dev,"failed to read reg_control\n" ); + +return ret; +} + +static int mxc4005_resume (struct device *dev) +{ +struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct mxc4005_data *data =iio_priv (indio_dev); +int ret; + + ret =regmap_write (data->regmap,MXC4005_REG_INT_CLR1 , +MXC4005_REG_INT_CLR1_SW_RST ); +if (ret) { +dev_err (data->dev,"failed to reset chip: %d\n" , ret); +return ret; + } + +fsleep (MXC4005_RESET_TIME_US ); + + ret =regmap_write (data->regmap,MXC4005_REG_CONTROL , data->control); +if (ret) { +dev_err (data->dev,"failed to restore control register\n" ); +return ret; + } + + ret =regmap_write (data->regmap,MXC4005_REG_INT_MASK0 ,0 ); +if (ret) { +dev_err (data->dev,"failed to restore interrupt 0 mask\n" ); +return ret; + } + + ret =regmap_write (data->regmap,MXC4005_REG_INT_MASK1 , data->int_mask1); +if (ret) { +dev_err (data->dev,"failed to restore interrupt 1 mask\n" ); +return ret; + } + +return 0 ; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(mxc4005_pm_ops, mxc4005_suspend, mxc4005_resume); +static const struct acpi_device_id mxc4005_acpi_match[] = { {"MXC4005" ,0 }, {"MXC6655" ,0 },
@@ -505,6 +572,7 @@ static struct i2c_driver mxc4005_driver = { .name = MXC4005_DRV_NAME, .acpi_match_table = ACPI_PTR(mxc4005_acpi_match), .of_match_table = mxc4005_of_match, + .pm = pm_sleep_ptr(&mxc4005_pm_ops), }, .probe = mxc4005_probe, .id_table = mxc4005_id,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 549/744 misc/pvpanic: deduplicate common code
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit c1426d392aebc51da4944d950d89e483e43f6f14 ]
pvpanic-mmio.c and pvpanic-pci.c share a lot of code. Refactor it into pvpanic.c where it doesn't have to be kept in sync manually and where the core logic can be understood more easily.
No functional change.
Stable-dep-of: ee59be35d7a8 ("misc/pvpanic-pci: register attributes via pci_driver")
--- drivers/misc/pvpanic/pvpanic-mmio.c | 58 +--------------------- drivers/misc/pvpanic/pvpanic-pci.c | 58 +--------------------- drivers/misc/pvpanic/pvpanic.c | 76 ++++++++++++++++++++++++++++- drivers/misc/pvpanic/pvpanic.h | 10 +--- 4 files changed, 80 insertions(+), 122 deletions(-)
drivers/misc/pvpanic/pvpanic-mmio.c +2 -56
@@ -24,52 +24,9 @@ MODULE_AUTHOR("Hu Tao <[email protected]>");MODULE_DESCRIPTION ("pvpanic-mmio device driver" );MODULE_LICENSE ("GPL" ); -static ssize_t capability_show (struct device *dev,struct device_attribute *attr,char *buf) -{ -struct pvpanic_instance *pi =dev_get_drvdata (dev); - -return sysfs_emit (buf,"%x\n" , pi->capability); -} -static DEVICE_ATTR_RO (capability); - -static ssize_t events_show (struct device *dev,struct device_attribute *attr,char *buf) -{ -struct pvpanic_instance *pi =dev_get_drvdata (dev); - -return sysfs_emit (buf,"%x\n" , pi->events); -} - -static ssize_t events_store (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) -{ -struct pvpanic_instance *pi =dev_get_drvdata (dev); -unsigned int tmp; -int err; - - err =kstrtouint (buf,16 , &tmp); -if (err) -return err; - -if ((tmp & pi->capability) != tmp) -return -EINVAL ; - - pi->events = tmp; - -return count; -} -static DEVICE_ATTR_RW (events); - -static struct attribute *pvpanic_mmio_dev_attrs[] = { - &dev_attr_capability.attr, - &dev_attr_events.attr, -NULL -}; -ATTRIBUTE_GROUPS (pvpanic_mmio_dev); -static int pvpanic_mmio_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct pvpanic_instance *pi;struct resource *res;void __iomem *base;
@@ -92,18 +49,7 @@ static int pvpanic_mmio_probe(struct platform_device *pdev)return -EINVAL ; } - pi =devm_kmalloc (dev,sizeof (*pi),GFP_KERNEL ); -if (!pi) -return -ENOMEM ; - - pi->base = base; - pi->capability =PVPANIC_PANICKED |PVPANIC_CRASH_LOADED ; - -/* initialize capability by RDPT */ - pi->capability &=ioread8 (base); - pi->events = pi->capability; - -return devm_pvpanic_probe (dev, pi); +return devm_pvpanic_probe (dev, base); }static const struct of_device_id pvpanic_mmio_match[] = {
@@ -123,7 +69,7 @@ static struct platform_driver pvpanic_mmio_driver = { .name = "pvpanic-mmio", .of_match_table = pvpanic_mmio_match, .acpi_match_table = pvpanic_device_ids, - .dev_groups = pvpanic_mmio_dev_groups, + .dev_groups = pvpanic_dev_groups, }, .probe = pvpanic_mmio_probe, };
drivers/misc/pvpanic/pvpanic-pci.c +2 -56
78 lines not on this page · raw message
drivers/misc/pvpanic/pvpanic.c +74 -2
97 lines not on this page · raw message
drivers/misc/pvpanic/pvpanic.h +2 -8
@@ -8,13 +8,7 @@#ifndef PVPANIC_H_ #define PVPANIC_H_ -struct pvpanic_instance { -void __iomem *base; -unsigned int capability; -unsigned int events; -struct list_head list; -}; - -int devm_pvpanic_probe (struct device *dev,struct pvpanic_instance *pi); +int devm_pvpanic_probe (struct device *dev,void __iomem *base); +extern const struct attribute_group *pvpanic_dev_groups[];#endif /* PVPANIC_H_ */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 550/744 misc/pvpanic-pci: register attributes via pci_driver
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit ee59be35d7a8be7fcaa2d61fb89734ab5c25e4ee ]
In __pci_register_driver(), the pci core overwrites the dev_groups field of the embedded struct device_driver with the dev_groups from the outer struct pci_driver unconditionally.
Set dev_groups in the pci_driver to make sure it is used.
This was broken since the introduction of pvpanic-pci.
--- drivers/misc/pvpanic/pvpanic-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/misc/pvpanic/pvpanic-pci.c +1 -3
@@ -48,8 +48,6 @@ static struct pci_driver pvpanic_pci_driver = { .name = "pvpanic-pci", .id_table = pvpanic_pci_id_tbl, .probe = pvpanic_pci_probe, - .driver = { - .dev_groups = pvpanic_dev_groups, - }, + .dev_groups = pvpanic_dev_groups, };module_pci_driver (pvpanic_pci_driver);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 551/744 serial: sc16is7xx: replace hardcoded divisor value with BIT() macro
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 2e57cefc4477659527f7adab1f87cdbf60ef1ae6 ]
To better show why the limit is what it is, since we have only 16 bits for the divisor.
Stable-dep-of: 8492bd91aa05 ("serial: sc16is7xx: fix bug in sc16is7xx_set_baud() when using prescaler")
--- drivers/tty/serial/sc16is7xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sc16is7xx.c +1 -1
@@ -489,7 +489,7 @@ static int sc16is7xx_set_baud(struct uart_port *port, int baud)u8 prescaler =0 ;unsigned long clk = port->uartclk, div = clk /16 / baud; -if (div >0xffff ) { +if (div >=BIT (16 )) { prescaler =SC16IS7XX_MCR_CLKSEL_BIT ; div /=4 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 552/744 serial: sc16is7xx: fix bug in sc16is7xx_set_baud() when using prescaler
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 8492bd91aa055907c67ef04f2b56f6dadd1f44bf ]
When using a high speed clock with a low baud rate, the 4x prescaler is automatically selected if required. In that case, sc16is7xx_set_baud() properly configures the chip registers, but returns an incorrect baud rate by not taking into account the prescaler value. This incorrect baud rate is then fed to uart_update_timeout().
For example, with an input clock of 80MHz, and a selected baud rate of 50, sc16is7xx_set_baud() will return 200 instead of 50.
Fix this by first changing the prescaler variable to hold the selected prescaler value instead of the MCR bitfield. Then properly take into account the selected prescaler value in the return value computation.
Also add better documentation about the divisor value computation.
--- drivers/tty/serial/sc16is7xx.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/tty/serial/sc16is7xx.c +18 -5
@@ -482,16 +482,28 @@ static bool sc16is7xx_regmap_noinc(struct device *dev, unsigned int reg)return reg ==SC16IS7XX_RHR_REG ; } +/* +* Configure programmable baud rate generator (divisor) according to the +* desired baud rate. +* +* From the datasheet, the divisor is computed according to: +* +* XTAL1 input frequency +* ----------------------- +* prescaler +* divisor = --------------------------- +* baud-rate x sampling-rate +*/ static int sc16is7xx_set_baud (struct uart_port *port,int baud) {struct sc16is7xx_one *one =to_sc16is7xx_one (port, port);u8 lcr; -u8 prescaler =0 ; +unsigned int prescaler =1 ;unsigned long clk = port->uartclk, div = clk /16 / baud;if (div >=BIT (16 )) { - prescaler =SC16IS7XX_MCR_CLKSEL_BIT ; - div /=4 ; + prescaler =4 ; + div /= prescaler; }/* In an amazing feat of design, the Enhanced Features Register shares
@@ -528,9 +540,10 @@ static int sc16is7xx_set_baud(struct uart_port *port, int baud)mutex_unlock (&one->efr_lock); +/* If bit MCR_CLKSEL is set, the divide by 4 prescaler is activated. */ sc16is7xx_port_update (port,SC16IS7XX_MCR_REG ,SC16IS7XX_MCR_CLKSEL_BIT , - prescaler); + prescaler ==1 ?0 :SC16IS7XX_MCR_CLKSEL_BIT );/* Open the LCR divisors for configuration */ sc16is7xx_port_write(port, SC16IS7XX_LCR_REG,
@@ -545,7 +558,7 @@ static int sc16is7xx_set_baud(struct uart_port *port, int baud)/* Put LCR back to the normal mode */ sc16is7xx_port_write (port,SC16IS7XX_LCR_REG , lcr); -return DIV_ROUND_CLOSEST (clk /16 , div); +return DIV_ROUND_CLOSEST ((clk / prescaler) /16 , div); } static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 553/744 eventfs: Create eventfs_root_inode to store dentry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit c3137ab6318d56370dd5541ebf027ddfc0c8557c ]
Only the root "events" directory stores a dentry. There's no reason to hold a dentry pointer for every eventfs_inode as it is never set except for the root "events" eventfs_inode.
Create a eventfs_root_inode structure that holds the events_dir dentry. The "events" eventfs_inode *is* special, let it have its own descriptor.
Stable-dep-of: b63db58e2fa5 ("eventfs/tracing: Add callback for release of an eventfs_inode")
--- fs/tracefs/event_inode.c | 65 +++++++++++++++++++++++++++++++++------- fs/tracefs/internal.h | 2 -- 2 files changed, 55 insertions(+), 12 deletions(-)
fs/tracefs/event_inode.c +55 -10
@@ -35,6 +35,17 @@ static DEFINE_MUTEX(eventfs_mutex);/* Choose something "unique" ;-) */ #define EVENTFS_FILE_INODE_INO 0x12c4e37 +struct eventfs_root_inode { +struct eventfs_inode ei; +struct dentry *events_dir; +}; + +static struct eventfs_root_inode *get_root_inode (struct eventfs_inode *ei) +{ +WARN_ON_ONCE (!ei->is_events); + return container_of(ei, struct eventfs_root_inode, ei); +} +/* Just try to make something consistent and unique */ static int eventfs_dir_ino (struct eventfs_inode *ei) {
@@ -72,12 +83,18 @@ enum {static void release_ei (struct kref *ref) { struct eventfs_inode *ei = container_of(ref, struct eventfs_inode, kref); +struct eventfs_root_inode *rei;WARN_ON_ONCE (!ei->is_freed);kfree (ei->entry_attrs);kfree_const (ei->name); -kfree_rcu (ei, rcu); +if (ei->is_events) { + rei =get_root_inode (ei); +kfree_rcu (rei, ei.rcu); + }else { +kfree_rcu (ei, rcu); + } }static inline void put_ei (struct eventfs_inode *ei)
@@ -418,19 +435,43 @@ static struct dentry *lookup_dir_entry(struct dentry *dentry,return NULL ; } +static inline struct eventfs_inode *init_ei (struct eventfs_inode *ei,const char *name) +{ + ei->name =kstrdup_const (name,GFP_KERNEL ); +if (!ei->name) +return NULL ; +kref_init (&ei->kref); +return ei; +} +static inline struct eventfs_inode *alloc_ei (const char *name) {struct eventfs_inode *ei =kzalloc (sizeof (*ei),GFP_KERNEL ); +struct eventfs_inode *result;if (!ei)return NULL ; - ei->name =kstrdup_const (name,GFP_KERNEL ); -if (!ei->name) { + result =init_ei (ei, name); +if (!result)kfree (ei); + +return result; +} + +static inline struct eventfs_inode *alloc_root_ei (const char *name) +{ +struct eventfs_root_inode *rei =kzalloc (sizeof (*rei),GFP_KERNEL ); +struct eventfs_inode *ei; + +if (!rei)return NULL ; - } -kref_init (&ei->kref); + + rei->ei.is_events =1 ; + ei =init_ei (&rei->ei, name); +if (!ei) +kfree (rei); +return ei; }
@@ -719,6 +760,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry int size, void *data) { struct dentry *dentry = tracefs_start_creating(name, parent); +struct eventfs_root_inode *rei;struct eventfs_inode *ei;struct tracefs_inode *ti;struct inode *inode;
@@ -731,7 +773,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentryif (IS_ERR (dentry))return ERR_CAST (dentry); - ei =alloc_ei (name); + ei =alloc_root_ei (name);if (!ei) goto fail;
@@ -740,10 +782,11 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry goto fail;// Note: we have a ref to the dentry from tracefs_start_creating() - ei->events_dir = dentry; + rei =get_root_inode (ei); + rei->events_dir = dentry; + ei->entries = entries; ei->nr_entries = size; - ei->is_events =1 ; ei->data = data;/* Save the ownership of this directory */
@@ -846,13 +889,15 @@ void eventfs_remove_dir(struct eventfs_inode *ei)*/ void eventfs_remove_events_dir (struct eventfs_inode *ei) { +struct eventfs_root_inode *rei;struct dentry *dentry; - dentry = ei->events_dir; + rei =get_root_inode (ei); + dentry = rei->events_dir;if (!dentry)return ; - ei->events_dir =NULL ; + rei->events_dir =NULL ;eventfs_remove_dir (ei);/*
fs/tracefs/internal.h +0 -2
@@ -39,7 +39,6 @@ struct eventfs_attr {* @children: link list into the child eventfs_inode * @entries: the array of entries representing the files in the directory * @name: the name of the directory to create -* @events_dir: the dentry of the events directory * @entry_attrs: Saved mode and ownership of the @d_children * @data: The private data to pass to the callbacks * @attr: Saved mode and ownership of eventfs_inode itself
@@ -57,7 +56,6 @@ struct eventfs_inode {struct list_head children;const struct eventfs_entry *entries;const char *name; -struct dentry *events_dir;struct eventfs_attr *entry_attrs;void *data;struct eventfs_attr attr;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 554/744 eventfs/tracing: Add callback for release of an eventfs_inode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit b63db58e2fa5d6963db9c45df88e60060f0ff35f ]
Synthetic events create and destroy tracefs files when they are created and removed. The tracing subsystem has its own file descriptor representing the state of the events attached to the tracefs files. There's a race between the eventfs files and this file descriptor of the tracing system where the following can cause an issue:
With two scripts 'A' and 'B' doing:
Script 'A':
echo "hello int aaa" > /sys/kernel/tracing/synthetic_events while :
do
echo 0 > /sys/kernel/tracing/events/synthetic/hello/enable
done
Script 'B':
echo > /sys/kernel/tracing/synthetic_events
Script 'A' creates a synthetic event "hello" and then just writes zero into its enable file.
Script 'B' removes all synthetic events (including the newly created "hello" event).
What happens is that the opening of the "enable" file has:
{
struct trace_event_file *file = inode->i_private;
int ret;
ret = tracing_check_open_get_tr(file->tr);[..]
But deleting the events frees the "file" descriptor, and a "use after free" happens with the dereference at "file->tr".
The file descriptor does have a reference counter, but there needs to be a way to decrement it from the eventfs when the eventfs_inode is removed that represents this file descriptor.
Add an optional "release" callback to the eventfs_entry array structure, that gets called when the eventfs file is about to be removed. This allows for the creating on the eventfs file to increment the tracing file descriptor ref counter. When the eventfs file is deleted, it can call the release function that will call the put function for the tracing file descriptor.
This will protect the tracing file from being freed while a eventfs file that references it is being opened.
--- fs/tracefs/event_inode.c | 23 +++++++++++++++++++++-- include/linux/tracefs.h | 3 +++ kernel/trace/trace_events.c | 12 ++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-)
fs/tracefs/event_inode.c +21 -2
@@ -83,10 +83,17 @@ enum {static void release_ei (struct kref *ref) { struct eventfs_inode *ei = container_of(ref, struct eventfs_inode, kref); +const struct eventfs_entry *entry;struct eventfs_root_inode *rei;WARN_ON_ONCE (!ei->is_freed); +for (int i =0 ; i < ei->nr_entries; i++) { + entry = &ei->entries[i]; +if (entry->release) + entry->release (entry->name, ei->data); + } +kfree (ei->entry_attrs);kfree_const (ei->name);if (ei->is_events) {
@@ -111,6 +118,18 @@ static inline void free_ei(struct eventfs_inode *ei) } } +/* +* Called when creation of an ei fails, do not call release() functions. +*/ +static inline void cleanup_ei (struct eventfs_inode *ei) +{ +if (ei) { +/* Set nr_entries to 0 to prevent release() function being called */ + ei->nr_entries =0 ; +free_ei (ei); + } +} +static inline struct eventfs_inode *get_ei (struct eventfs_inode *ei) {if (ei)
@@ -737,7 +756,7 @@ struct eventfs_inode *eventfs_create_dir(const char *name, struct eventfs_inode/* Was the parent freed? */ if (list_empty (&ei->list)) { -free_ei (ei); +cleanup_ei (ei); ei =NULL ; }return ei;
@@ -830,7 +849,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentryreturn ei; fail: -free_ei (ei); +cleanup_ei (ei);tracefs_failed_creating (dentry);return ERR_PTR (-ENOMEM ); }
include/linux/tracefs.h +3 -0
@@ -62,6 +62,8 @@ struct eventfs_file;typedef int (*eventfs_callback )(const char *name,umode_t *mode,void **data,const struct file_operations **fops); +typedef void (*eventfs_release )(const char *name,void *data); +/** * struct eventfs_entry - dynamically created eventfs file call back handler * @name: Then name of the dynamic file in an eventfs directory
@@ -72,6 +74,7 @@ typedef int (*eventfs_callback)(const char *name, umode_t *mode, void **data,struct eventfs_entry {const char *name;eventfs_callback callback; +eventfs_release release; };struct eventfs_inode ;
kernel/trace/trace_events.c +12 -0
@@ -2518,6 +2518,14 @@ static int event_callback(const char *name, umode_t *mode, void **data,return 0 ; } +/* The file is incremented on creation and freeing the enable file decrements it */ +static void event_release (const char *name,void *data) +{ +struct trace_event_file *file = data; + +event_file_put (file); +} +static int event_create_dir (struct eventfs_inode *parent,struct trace_event_file *file) {
@@ -2532,6 +2540,7 @@ event_create_dir(struct eventfs_inode *parent, struct trace_event_file *file) { .name = "enable", .callback = event_callback, + .release = event_release, }, { .name = "filter",
@@ -2600,6 +2609,9 @@ event_create_dir(struct eventfs_inode *parent, struct trace_event_file *file)return ret; } +/* Gets decremented on freeing of the "enable" file */ +event_file_get (file); +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 555/744 eventfs: Free all of the eventfs_inode after RCU
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit ee4e0379475e4fe723986ae96293e465014fa8d9 ]
The freeing of eventfs_inode via a kfree_rcu() callback. But the content of the eventfs_inode was being freed after the last kref. This is dangerous, as changes are being made that can access the content of an eventfs_inode from an RCU loop.
Instead of using kfree_rcu() use call_rcu() that calls a function to do all the freeing of the eventfs_inode after a RCU grace period has expired.
--- fs/tracefs/event_inode.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
fs/tracefs/event_inode.c +16 -9
@@ -72,6 +72,21 @@ enum {#define EVENTFS_MODE_MASK (EVENTFS_SAVE_MODE - 1) +static void free_ei_rcu (struct rcu_head *rcu) +{ + struct eventfs_inode *ei = container_of(rcu, struct eventfs_inode, rcu); +struct eventfs_root_inode *rei; + +kfree (ei->entry_attrs); +kfree_const (ei->name); +if (ei->is_events) { + rei =get_root_inode (ei); +kfree (rei); + }else { +kfree (ei); + } +} +/* * eventfs_inode reference count management. *
@@ -84,7 +99,6 @@ static void release_ei(struct kref *ref) { struct eventfs_inode *ei = container_of(ref, struct eventfs_inode, kref);const struct eventfs_entry *entry; -struct eventfs_root_inode *rei;WARN_ON_ONCE (!ei->is_freed);
@@ -94,14 +108,7 @@ static void release_ei(struct kref *ref) entry->release (entry->name, ei->data); } -kfree (ei->entry_attrs); -kfree_const (ei->name); -if (ei->is_events) { - rei =get_root_inode (ei); -kfree_rcu (rei, ei.rcu); - }else { -kfree_rcu (ei, rcu); - } +call_rcu (&ei->rcu, free_ei_rcu); }static inline void put_ei (struct eventfs_inode *ei)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 556/744 eventfs: Have "events" directory get permissions from its parent
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit d57cf30c4c07837799edec949102b0adf58bae79 ]
The events directory gets its permissions from the root inode. But this can cause an inconsistency if the instances directory changes its permissions, as the permissions of the created directories under it should inherit the permissions of the instances directory when directories under it are created.
Currently the behavior is:
# cd /sys/kernel/tracing # chgrp 1002 instances # mkdir instances/foo # ls -l instances/foo [..] -r--r----- 1 root lkp 0 May 1 18:55 buffer_total_size_kb -rw-r----- 1 root lkp 0 May 1 18:55 current_tracer -rw-r----- 1 root lkp 0 May 1 18:55 error_log drwxr-xr-x 1 root root 0 May 1 18:55 events --w------- 1 root lkp 0 May 1 18:55 free_buffer drwxr-x--- 2 root lkp 0 May 1 18:55 options drwxr-x--- 10 root lkp 0 May 1 18:55 per_cpu -rw-r----- 1 root lkp 0 May 1 18:55 set_event
All the files and directories under "foo" has the "lkp" group except the "events" directory. That's because its getting its default value from the mount point instead of its parent.
Have the "events" directory make its default value based on its parent's permissions. That now gives:
# ls -l instances/foo [..] -rw-r----- 1 root lkp 0 May 1 21:16 buffer_subbuf_size_kb -r--r----- 1 root lkp 0 May 1 21:16 buffer_total_size_kb -rw-r----- 1 root lkp 0 May 1 21:16 current_tracer -rw-r----- 1 root lkp 0 May 1 21:16 error_log drwxr-xr-x 1 root lkp 0 May 1 21:16 events --w------- 1 root lkp 0 May 1 21:16 free_buffer drwxr-x--- 2 root lkp 0 May 1 21:16 options drwxr-x--- 10 root lkp 0 May 1 21:16 per_cpu -rw-r----- 1 root lkp 0 May 1 21:16 set_event
--- fs/tracefs/event_inode.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
fs/tracefs/event_inode.c +24 -6
@@ -37,6 +37,7 @@ static DEFINE_MUTEX(eventfs_mutex);struct eventfs_root_inode {struct eventfs_inode ei; +struct inode *parent_inode;struct dentry *events_dir; };
@@ -226,12 +227,23 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,static void update_events_attr (struct eventfs_inode *ei,struct super_block *sb) { -struct inode *root; +struct eventfs_root_inode *rei; +struct inode *parent; + + rei =get_root_inode (ei); + +/* Use the parent inode permissions unless root set its permissions */ + parent = rei->parent_inode; -/* Get the tracefs root inode. */ - root =d_inode (sb->s_root); - ei->attr.uid = root->i_uid; - ei->attr.gid = root->i_gid; +if (rei->ei.attr.mode &EVENTFS_SAVE_UID ) + ei->attr.uid = rei->ei.attr.uid; +else + ei->attr.uid = parent->i_uid; + +if (rei->ei.attr.mode &EVENTFS_SAVE_GID ) + ei->attr.gid = rei->ei.attr.gid; +else + ei->attr.gid = parent->i_gid; }static void set_top_events_ownership (struct inode *inode)
@@ -810,6 +822,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry// Note: we have a ref to the dentry from tracefs_start_creating() rei =get_root_inode (ei); rei->events_dir = dentry; + rei->parent_inode =d_inode (dentry->d_sb->s_root); ei->entries = entries; ei->nr_entries = size;
@@ -819,10 +832,15 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry uid =d_inode (dentry->d_parent)->i_uid; gid =d_inode (dentry->d_parent)->i_gid; -/* This is used as the default ownership of the files and directories */ ei->attr.uid = uid; ei->attr.gid = gid; +/* +* When the "events" directory is created, it takes on the +* permissions of its parent. But can be reset on remount. +*/ + ei->attr.mode |=EVENTFS_SAVE_UID |EVENTFS_SAVE_GID ; +INIT_LIST_HEAD (&ei->children);INIT_LIST_HEAD (&ei->list);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 557/744 dt-bindings: adc: axi-adc: update bindings for backend framework
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sa <[email protected]>
[ Upstream commit a032b921bdeba2274866daafc8e791edd609eb13 ]
'adi,adc-dev' is now deprecated and must not be used anymore. Hence, also remove it from being required.
The reason why it's being deprecated is because the axi-adc CORE is now an IIO service provider hardware (IIO backends) for consumers to make use of. Before, the logic with 'adi,adc-dev' was the opposite (it was kind of consumer referencing other nodes/devices) and that proved to be wrong and to not scale.
Now, IIO consumers of this hardware are expected to reference it using the io-backends property. Hence, the new '#io-backend-cells' is being added so the device is easily identified as a provider.
Stable-dep-of: 19fb11d7220b ("dt-bindings: adc: axi-adc: add clocks property")
--- .../devicetree/bindings/iio/adc/adi,axi-adc.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml +5 -3
@@ -39,12 +39,15 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle description: A reference to a the actual ADC to which this FPGA ADC interfaces to. + deprecated: true + + '#io-backend-cells': + const: 0 required: - compatible - dmas - reg - - adi,adc-dev additionalProperties: false
@@ -55,7 +58,6 @@ examples: reg = <0x44a00000 0x10000>; dmas = <&rx_dma 0>; dma-names = "rx"; - - adi,adc-dev = <&spi_adc>; + #io-backend-cells = <0>; }; ...
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 558/744 dt-bindings: adc: axi-adc: add clocks property
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sa <[email protected]>
[ Upstream commit 19fb11d7220b8abc016aa254dc7e6d9f2d49b178 ]
Add a required clock property as we can't access the device registers if the AXI bus clock is not properly enabled.
Note this clock is a very fundamental one that is typically enabled pretty early during boot. Independently of that, we should really rely on it to be enabled.
--- Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml +5 -0
@@ -28,6 +28,9 @@ properties: reg: maxItems: 1 + clocks: + maxItems: 1 + dmas: maxItems: 1
@@ -48,6 +51,7 @@ required: - compatible - dmas - reg + - clocks additionalProperties: false
@@ -58,6 +62,7 @@ examples: reg = <0x44a00000 0x10000>; dmas = <&rx_dma 0>; dma-names = "rx"; + clocks = <&axi_clk>; #io-backend-cells = <0>; }; ...
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 559/744 Input: ims-pcu - fix printf string overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit bf32bceedd0453c70d9d022e2e29f98e446d7161 ]
clang warns about a string overflow in this driver
drivers/input/misc/ims-pcu.c:1802:2: error: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 12 [-Werror,-Wformat-truncation] drivers/input/misc/ims-pcu.c:1814:2: error: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 12 [-Werror,-Wformat-truncation]
Make the buffer a little longer to ensure it always fits.
--- drivers/input/misc/ims-pcu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/misc/ims-pcu.c +2 -2
@@ -42,8 +42,8 @@ struct ims_pcu_backlight {#define IMS_PCU_PART_NUMBER_LEN 15#define IMS_PCU_SERIAL_NUMBER_LEN 8#define IMS_PCU_DOM_LEN 8 -#define IMS_PCU_FW_VERSION_LEN (9 + 1) -#define IMS_PCU_BL_VERSION_LEN (9 + 1) +#define IMS_PCU_FW_VERSION_LEN 16 +#define IMS_PCU_BL_VERSION_LEN 16#define IMS_PCU_BL_RESET_REASON_LEN (2 + 1)#define IMS_PCU_PCU_B_DEVICE_ID 5
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 560/744 mmc: sdhci_am654: Add tuning algorithm for delay chain
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit 6231d99dd4119312ad41abf9383e18fec66cbe4b ]
Currently the sdhci_am654 driver only supports one tuning algorithm which should be used only when DLL is enabled. The ITAPDLY is selected from the largest passing window and the buffer is viewed as a circular buffer.
The new algorithm should be used when the delay chain is enabled. The ITAPDLY is selected from the largest passing window and the buffer is not viewed as a circular buffer.
This implementation is based off of the following paper: [1].
Also add support for multiple failing windows.
[1] https://www.ti.com/lit/an/spract9/spract9.pdf
--- drivers/mmc/host/sdhci_am654.c | 112 +++++++++++++++++++++++++++------ 1 file changed, 92 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci_am654.c +92 -20
@@ -150,10 +150,17 @@ struct sdhci_am654_data {int strb_sel;u32 flags;u32 quirks; +bool dll_enable;#define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0) }; +struct window { +u8 start; +u8 end; +u8 length; +}; +struct sdhci_am654_driver_data {const struct sdhci_pltfm_data *pdata;u32 flags;
@@ -295,10 +302,13 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)regmap_update_bits (sdhci_am654->base,PHY_CTRL4 , mask, val); -if (timing >MMC_TIMING_UHS_SDR25 && clock >=CLOCK_TOO_SLOW_HZ ) +if (timing >MMC_TIMING_UHS_SDR25 && clock >=CLOCK_TOO_SLOW_HZ ) {sdhci_am654_setup_dll (host, clock); -else + sdhci_am654->dll_enable = true; + }else {sdhci_am654_setup_delay_chain (sdhci_am654, timing); + sdhci_am654->dll_enable = false; + }regmap_update_bits (sdhci_am654->base,PHY_CTRL5 ,CLKBUFSEL_MASK , sdhci_am654->clkbuf_sel);
@@ -416,39 +426,101 @@ static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)return 0 ; } -#define ITAP_MAX 32 +#define ITAPDLY_LENGTH 32 +#define ITAPDLY_LAST_INDEX (ITAPDLY_LENGTH - 1) + +static u32 sdhci_am654_calculate_itap (struct sdhci_host *host,struct window + *fail_window,u8 num_fails,bool circular_buffer) +{ +u8 itap =0 , start_fail =0 , end_fail =0 , pass_length =0 ; +u8 first_fail_start =0 , last_fail_end =0 ; +struct device *dev =mmc_dev (host->mmc); +struct window pass_window = {0 ,0 ,0 }; +int prev_fail_end =-1 ; +u8 i; + +if (!num_fails) +return ITAPDLY_LAST_INDEX >>1 ; + +if (fail_window->length ==ITAPDLY_LENGTH ) { +dev_err (dev,"No passing ITAPDLY, return 0\n" ); +return 0 ; + } + + first_fail_start = fail_window->start; + last_fail_end = fail_window[num_fails -1 ].end; + +for (i =0 ; i < num_fails; i++) { + start_fail = fail_window[i].start; + end_fail = fail_window[i].end; + pass_length = start_fail - (prev_fail_end +1 ); + +if (pass_length > pass_window.length) { + pass_window.start = prev_fail_end +1 ; + pass_window.length = pass_length; + } + prev_fail_end = end_fail; + } + +if (!circular_buffer) + pass_length =ITAPDLY_LAST_INDEX - last_fail_end; +else + pass_length =ITAPDLY_LAST_INDEX - last_fail_end + first_fail_start; + +if (pass_length > pass_window.length) { + pass_window.start = last_fail_end +1 ; + pass_window.length = pass_length; + } + +if (!circular_buffer) + itap = pass_window.start + (pass_window.length >>1 ); +else + itap = (pass_window.start + (pass_window.length >>1 )) %ITAPDLY_LENGTH ; + +return (itap >ITAPDLY_LAST_INDEX ) ?ITAPDLY_LAST_INDEX >>1 : itap; +} +static int sdhci_am654_platform_execute_tuning (struct sdhci_host *host,u32 opcode) {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_am654_data *sdhci_am654 =sdhci_pltfm_priv (pltfm_host); -int cur_val, prev_val =1 , fail_len =0 , pass_window =0 , pass_len; -u32 itap; +struct window fail_window[ITAPDLY_LENGTH ]; +u8 curr_pass, itap; +u8 fail_index =0 ; +u8 prev_pass =1 ; + +memset (fail_window,0 ,sizeof (fail_window));/* Enable ITAPDLY */ regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPDLYENA_MASK ,1 <<ITAPDLYENA_SHIFT ); -for (itap =0 ; itap <ITAP_MAX ; itap++) { +for (itap =0 ; itap <ITAPDLY_LENGTH ; itap++) {sdhci_am654_write_itapdly (sdhci_am654, itap); - cur_val = !mmc_send_tuning (host->mmc, opcode,NULL ); -if (cur_val && !prev_val) - pass_window = itap; + curr_pass = !mmc_send_tuning (host->mmc, opcode,NULL ); -if (!cur_val) - fail_len++; +if (!curr_pass && prev_pass) + fail_window[fail_index].start = itap; - prev_val = cur_val; +if (!curr_pass) { + fail_window[fail_index].end = itap; + fail_window[fail_index].length++; + } + +if (curr_pass && !prev_pass) + fail_index++; + + prev_pass = curr_pass; } -/* -* Having determined the length of the failing window and start of -* the passing window calculate the length of the passing window and -* set the final value halfway through it considering the range as a -* circular buffer -*/ - pass_len =ITAP_MAX - fail_len; - itap = (pass_window + (pass_len >>1 )) %ITAP_MAX ; + +if (fail_window[fail_index].length !=0 ) + fail_index++; + + itap =sdhci_am654_calculate_itap (host, fail_window, fail_index, + sdhci_am654->dll_enable); +sdhci_am654_write_itapdly (sdhci_am654, itap);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 561/744 mmc: sdhci_am654: Write ITAPDLY for DDR52 timing
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit d465234493bb6ad1b9c10a0c9ef9881b8d85081a ]
For DDR52 timing, DLL is enabled but tuning is not carried out, therefore the ITAPDLY value in PHY CTRL 4 register is not correct. Fix this by writing ITAPDLY after enabling DLL.
--- drivers/mmc/host/sdhci_am654.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci_am654.c +1 -0
@@ -305,6 +305,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)if (timing >MMC_TIMING_UHS_SDR25 && clock >=CLOCK_TOO_SLOW_HZ ) {sdhci_am654_setup_dll (host, clock); sdhci_am654->dll_enable = true; +sdhci_am654_write_itapdly (sdhci_am654, sdhci_am654->itap_del_sel[timing]); }else {sdhci_am654_setup_delay_chain (sdhci_am654, timing); sdhci_am654->dll_enable = false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 562/744 mmc: sdhci_am654: Drop lookup for deprecated ti,otap-del-sel
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh Raghavendra <[email protected]>
[ Upstream commit 5cb2f9286a31f33dc732c57540838ad9339393ab ]
ti,otap-del-sel has been deprecated since v5.7 and there are no users of this property and no documentation in the DT bindings either. Drop the fallback code looking for this property, this makes sdhci_am654_get_otap_delay() much easier to read as all the TAP values can be handled via a single iterator loop.
Stable-dep-of: 387c1bf7dce0 ("mmc: sdhci_am654: Add OTAP/ITAP delay enable")
--- drivers/mmc/host/sdhci_am654.c | 37 ++++++---------------------------- 1 file changed, 6 insertions(+), 31 deletions(-)
drivers/mmc/host/sdhci_am654.c +6 -31
@@ -141,7 +141,6 @@ static const struct timing_data td[] = {struct sdhci_am654_data {struct regmap *base; -bool legacy_otapdly;int otap_del_sel[ARRAY_SIZE (td)];int itap_del_sel[ARRAY_SIZE (td)];int clkbuf_sel;
@@ -279,11 +278,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)sdhci_set_clock (host, clock);/* Setup DLL Output TAP delay */ -if (sdhci_am654->legacy_otapdly) - otap_del_sel = sdhci_am654->otap_del_sel[0 ]; -else - otap_del_sel = sdhci_am654->otap_del_sel[timing]; - + otap_del_sel = sdhci_am654->otap_del_sel[timing]; otap_del_ena = (timing >MMC_TIMING_UHS_SDR25 ) ?1 :0 ; mask =OTAPDLYENA_MASK |OTAPDLYSEL_MASK ;
@@ -325,10 +320,7 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,u32 mask, val;/* Setup DLL Output TAP delay */ -if (sdhci_am654->legacy_otapdly) - otap_del_sel = sdhci_am654->otap_del_sel[0 ]; -else - otap_del_sel = sdhci_am654->otap_del_sel[timing]; + otap_del_sel = sdhci_am654->otap_del_sel[timing]; mask =OTAPDLYENA_MASK |OTAPDLYSEL_MASK ; val = (0x1 << OTAPDLYENA_SHIFT) |
@@ -650,32 +642,15 @@ static int sdhci_am654_get_otap_delay(struct sdhci_host *host,int i;int ret; - ret =device_property_read_u32 (dev, td[MMC_TIMING_LEGACY ].otap_binding, - &sdhci_am654->otap_del_sel[MMC_TIMING_LEGACY ]); -if (ret) { -/* -* ti,otap-del-sel-legacy is mandatory, look for old binding -* if not found. -*/ - ret =device_property_read_u32 (dev,"ti,otap-del-sel" , - &sdhci_am654->otap_del_sel[0 ]); -if (ret) { -dev_err (dev,"Couldn't find otap-del-sel\n" ); - -return ret; - } - -dev_info (dev,"Using legacy binding ti,otap-del-sel\n" ); - sdhci_am654->legacy_otapdly = true; - -return 0 ; - } -for (i =MMC_TIMING_LEGACY ; i <=MMC_TIMING_MMC_HS400 ; i++) { ret =device_property_read_u32 (dev, td[i].otap_binding, &sdhci_am654->otap_del_sel[i]);if (ret) { +if (i ==MMC_TIMING_LEGACY ) { +dev_err (dev,"Couldn't find mandatory ti,otap-del-sel-legacy\n" ); +return ret; + }dev_dbg (dev,"Couldn't find %s\n" , td[i].otap_binding);/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 563/744 mmc: sdhci_am654: Add OTAP/ITAP delay enable
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit 387c1bf7dce0dfea02080c8bdb066b5209e92155 ]
Currently the OTAP/ITAP delay enable functionality is incorrect in the am654_set_clock function. The OTAP delay is not enabled when timing < SDR25 bus speed mode. The ITAP delay is not enabled for timings that do not carry out tuning.
Add this OTAP/ITAP delay functionality according to the datasheet
[1] OTAPDLYENA and ITAPDLYENA for MMC0.
[1] https://www.ti.com/lit/ds/symlink/am62p.pdf
--- drivers/mmc/host/sdhci_am654.c | 40 ++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-)
drivers/mmc/host/sdhci_am654.c +26 -14
@@ -143,6 +143,7 @@ struct sdhci_am654_data {struct regmap *base;int otap_del_sel[ARRAY_SIZE (td)];int itap_del_sel[ARRAY_SIZE (td)]; +u32 itap_del_ena[ARRAY_SIZE (td)];int clkbuf_sel;int trm_icp;int drv_strength;
@@ -239,11 +240,13 @@ static void sdhci_am654_setup_dll(struct sdhci_host *host, unsigned int clock) }static void sdhci_am654_write_itapdly (struct sdhci_am654_data *sdhci_am654, -u32 itapdly) +u32 itapdly,u32 enable) {/* Set ITAPCHGWIN before writing to ITAPDLY */ regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPCHGWIN_MASK ,1 <<ITAPCHGWIN_SHIFT ); +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPDLYENA_MASK , + enable <<ITAPDLYENA_SHIFT );regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPDLYSEL_MASK , itapdly <<ITAPDLYSEL_SHIFT );regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPCHGWIN_MASK ,0 );
@@ -260,8 +263,8 @@ static void sdhci_am654_setup_delay_chain(struct sdhci_am654_data *sdhci_am654, mask =SELDLYTXCLK_MASK |SELDLYRXCLK_MASK ;regmap_update_bits (sdhci_am654->base,PHY_CTRL5 , mask, val); -sdhci_am654_write_itapdly (sdhci_am654, - sdhci_am654->itap_del_sel[timing]); +sdhci_am654_write_itapdly (sdhci_am654, sdhci_am654->itap_del_sel[timing], + sdhci_am654->itap_del_ena[timing]); }static void sdhci_am654_set_clock (struct sdhci_host *host,unsigned int clock)
@@ -270,7 +273,6 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)struct sdhci_am654_data *sdhci_am654 =sdhci_pltfm_priv (pltfm_host);unsigned char timing = host->mmc->ios.timing;u32 otap_del_sel; -u32 otap_del_ena;u32 mask, val;regmap_update_bits (sdhci_am654->base,PHY_CTRL1 ,ENDLL_MASK ,0 );
@@ -279,10 +281,9 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)/* Setup DLL Output TAP delay */ otap_del_sel = sdhci_am654->otap_del_sel[timing]; - otap_del_ena = (timing >MMC_TIMING_UHS_SDR25 ) ?1 :0 ; mask =OTAPDLYENA_MASK |OTAPDLYSEL_MASK ; - val = (otap_del_ena <<OTAPDLYENA_SHIFT ) | + val = (0x1 <<OTAPDLYENA_SHIFT ) | (otap_del_sel <<OTAPDLYSEL_SHIFT );/* Write to STRBSEL for HS400 speed mode */
@@ -300,7 +301,8 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)if (timing >MMC_TIMING_UHS_SDR25 && clock >=CLOCK_TOO_SLOW_HZ ) {sdhci_am654_setup_dll (host, clock); sdhci_am654->dll_enable = true; -sdhci_am654_write_itapdly (sdhci_am654, sdhci_am654->itap_del_sel[timing]); +sdhci_am654_write_itapdly (sdhci_am654, sdhci_am654->itap_del_sel[timing], + sdhci_am654->itap_del_ena[timing]); }else {sdhci_am654_setup_delay_chain (sdhci_am654, timing); sdhci_am654->dll_enable = false;
@@ -317,6 +319,7 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,struct sdhci_am654_data *sdhci_am654 =sdhci_pltfm_priv (pltfm_host);unsigned char timing = host->mmc->ios.timing;u32 otap_del_sel; +u32 itap_del_ena;u32 mask, val;/* Setup DLL Output TAP delay */
@@ -325,6 +328,12 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host, mask =OTAPDLYENA_MASK |OTAPDLYSEL_MASK ; val = (0x1 <<OTAPDLYENA_SHIFT ) | (otap_del_sel <<OTAPDLYSEL_SHIFT ); + + itap_del_ena = sdhci_am654->itap_del_ena[timing]; + + mask |=ITAPDLYENA_MASK ; + val |= (itap_del_ena <<ITAPDLYENA_SHIFT ); +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 , mask, val); regmap_update_bits(sdhci_am654->base, PHY_CTRL5, CLKBUFSEL_MASK,
@@ -478,6 +487,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_am654_data *sdhci_am654 =sdhci_pltfm_priv (pltfm_host); +unsigned char timing = host->mmc->ios.timing;struct window fail_window[ITAPDLY_LENGTH ];u8 curr_pass, itap;u8 fail_index =0 ;
@@ -486,11 +496,10 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,memset (fail_window,0 ,sizeof (fail_window));/* Enable ITAPDLY */ -regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPDLYENA_MASK , -1 <<ITAPDLYENA_SHIFT ); + sdhci_am654->itap_del_ena[timing] =0x1 ;for (itap =0 ; itap <ITAPDLY_LENGTH ; itap++) { -sdhci_am654_write_itapdly (sdhci_am654, itap); +sdhci_am654_write_itapdly (sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]); curr_pass = !mmc_send_tuning (host->mmc, opcode,NULL );
@@ -514,7 +523,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, itap =sdhci_am654_calculate_itap (host, fail_window, fail_index, sdhci_am654->dll_enable); -sdhci_am654_write_itapdly (sdhci_am654, itap); +sdhci_am654_write_itapdly (sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);return 0 ; }
@@ -663,9 +672,12 @@ static int sdhci_am654_get_otap_delay(struct sdhci_host *host, host->mmc->caps2 &= ~td[i].capability; } -if (td[i].itap_binding) -device_property_read_u32 (dev, td[i].itap_binding, - &sdhci_am654->itap_del_sel[i]); +if (td[i].itap_binding) { + ret =device_property_read_u32 (dev, td[i].itap_binding, + &sdhci_am654->itap_del_sel[i]); +if (!ret) + sdhci_am654->itap_del_ena[i] =0x1 ; + } }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 564/744 mmc: sdhci_am654: Add ITAPDLYSEL in sdhci_j721e_4bit_set_clock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit 9dff65bb5e09903c27d9cff947dff4d22b6ea6a1 ]
Add ITAPDLYSEL to sdhci_j721e_4bit_set_clock function. This allows to set the correct ITAPDLY for timings that do not carry out tuning.
--- drivers/mmc/host/sdhci_am654.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci_am654.c +9 -3
@@ -320,6 +320,7 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,unsigned char timing = host->mmc->ios.timing;u32 otap_del_sel;u32 itap_del_ena; +u32 itap_del_sel;u32 mask, val;/* Setup DLL Output TAP delay */
@@ -329,13 +330,18 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host, val = (0x1 <<OTAPDLYENA_SHIFT ) | (otap_del_sel <<OTAPDLYSEL_SHIFT ); +/* Setup Input TAP delay */ itap_del_ena = sdhci_am654->itap_del_ena[timing]; + itap_del_sel = sdhci_am654->itap_del_sel[timing]; - mask |=ITAPDLYENA_MASK ; - val |= (itap_del_ena <<ITAPDLYENA_SHIFT ); + mask |=ITAPDLYENA_MASK |ITAPDLYSEL_MASK ; + val |= (itap_del_ena <<ITAPDLYENA_SHIFT ) | + (itap_del_sel <<ITAPDLYSEL_SHIFT ); +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPCHGWIN_MASK , +1 <<ITAPCHGWIN_SHIFT );regmap_update_bits (sdhci_am654->base,PHY_CTRL4 , mask, val); - +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPCHGWIN_MASK ,0 );regmap_update_bits (sdhci_am654->base,PHY_CTRL5 ,CLKBUFSEL_MASK , sdhci_am654->clkbuf_sel);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 565/744 mmc: sdhci_am654: Fix ITAPDLY for HS400 timing
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit d3182932bb070e7518411fd165e023f82afd7d25 ]
While STRB is currently used for DATA and CRC responses, the CMD responses from the device to the host still require ITAPDLY for HS400 timing.
Currently what is stored for HS400 is the ITAPDLY from High Speed mode which is incorrect. The ITAPDLY for HS400 speed mode should be the same as ITAPDLY as HS200 timing after tuning is executed. Add the functionality to save ITAPDLY from HS200 tuning and save as HS400 ITAPDLY.
--- drivers/mmc/host/sdhci_am654.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/mmc/host/sdhci_am654.c +9 -0
@@ -301,6 +301,12 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)if (timing >MMC_TIMING_UHS_SDR25 && clock >=CLOCK_TOO_SLOW_HZ ) {sdhci_am654_setup_dll (host, clock); sdhci_am654->dll_enable = true; + +if (timing ==MMC_TIMING_MMC_HS400 ) { + sdhci_am654->itap_del_ena[timing] =0x1 ; + sdhci_am654->itap_del_sel[timing] = sdhci_am654->itap_del_sel[timing -1 ]; + } +sdhci_am654_write_itapdly (sdhci_am654, sdhci_am654->itap_del_sel[timing], sdhci_am654->itap_del_ena[timing]); }else {
@@ -531,6 +537,9 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,sdhci_am654_write_itapdly (sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]); +/* Save ITAPDLY */ + sdhci_am654->itap_del_sel[timing] = itap; +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 566/744 Input: pm8xxx-vibrator - correct VIB_MAX_LEVELS calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fenglin Wu <[email protected]>
[ Upstream commit 48c0687a322d54ac7e7a685c0b6db78d78f593af ]
The output voltage is inclusive hence the max level calculation is off-by-one-step. Correct it.
iWhile we are at it also add a define for the step size instead of using the magic value.
--- drivers/input/misc/pm8xxx-vibrator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/input/misc/pm8xxx-vibrator.c +4 -3
@@ -13,7 +13,8 @@#define VIB_MAX_LEVEL_mV (3100)#define VIB_MIN_LEVEL_mV (1200) -#define VIB_MAX_LEVELS (VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV) +#define VIB_PER_STEP_mV (100) +#define VIB_MAX_LEVELS (VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV + VIB_PER_STEP_mV)#define MAX_FF_SPEED 0xff
@@ -117,10 +118,10 @@ static void pm8xxx_work_handler(struct work_struct *work) vib->active = true; vib->level = ((VIB_MAX_LEVELS * vib->speed) /MAX_FF_SPEED ) + VIB_MIN_LEVEL_mV; - vib->level /=100 ; + vib->level /= VIB_PER_STEP_mV; }else { vib->active = false; - vib->level = VIB_MIN_LEVEL_mV /100 ; + vib->level = VIB_MIN_LEVEL_mV / VIB_PER_STEP_mV; }pm8xxx_vib_set (vib, vib->active);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 567/744 media: v4l2-subdev: Document and enforce .s_stream() requirements
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
[ Upstream commit 009905ec50433259c05f474251000b040098564e ]
The subdev .s_stream() operation must not be called to start an already started subdev, or stop an already stopped one. This requirement has never been formally documented. Fix it, and catch possible offenders with a WARN_ON() in the call_s_stream() wrapper.
Stable-dep-of: f2bf6cd8f447 ("media: v4l: Don't turn on privacy LED if streamon fails")
--- drivers/media/v4l2-core/v4l2-subdev.c | 17 ++++++++++++++++- include/media/v4l2-subdev.h | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-subdev.c +16 -1
@@ -359,6 +359,18 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) {int ret; +/* +* The .s_stream() operation must never be called to start or stop an +* already started or stopped subdev. Catch offenders but don't return +* an error yet to avoid regressions. +* +* As .s_stream() is mutually exclusive with the .enable_streams() and +* .disable_streams() operation, we can use the enabled_streams field +* to store the subdev streaming state. +*/ +if (WARN_ON (!!sd->enabled_streams == !!enable)) +return 0 ; +#if IS_REACHABLE (CONFIG_LEDS_CLASS )if (!IS_ERR_OR_NULL (sd->privacy_led)) {if (enable)
@@ -372,9 +384,12 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable)if (!enable && ret <0 ) {dev_warn (sd->dev,"disabling streaming failed (%d)\n" , ret); -return 0 ; + ret =0 ; } +if (!ret) + sd->enabled_streams = enable ?BIT (0 ) :0 ; +return ret; }
include/media/v4l2-subdev.h +3 -1
@@ -446,7 +446,9 @@ enum v4l2_subdev_pre_streamon_flags {* @s_stream: start (enabled == 1) or stop (enabled == 0) streaming on the * sub-device. Failure on stop will remove any resources acquired in * streaming start, while the error code is still returned by the driver. -* Also see call_s_stream wrapper in v4l2-subdev.c. +* The caller shall track the subdev state, and shall not start or stop an +* already started or stopped subdev. Also see call_s_stream wrapper in +* v4l2-subdev.c. * * @g_pixelaspect: callback to return the pixelaspect ratio. *
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 568/744 media: v4l: Dont turn on privacy LED if streamon fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
[ Upstream commit f2bf6cd8f44781349620e30a0af8987fe9af008f ]
Turn on the privacy LED only if streamon succeeds. This can be done after enabling streaming on the sensor.
--- drivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/media/v4l2-core/v4l2-subdev.c +12 -10
@@ -371,15 +371,6 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable)if (WARN_ON (!!sd->enabled_streams == !!enable))return 0 ; -#if IS_REACHABLE (CONFIG_LEDS_CLASS ) -if (!IS_ERR_OR_NULL (sd->privacy_led)) { -if (enable) -led_set_brightness (sd->privacy_led, - sd->privacy_led->max_brightness); -else -led_set_brightness (sd->privacy_led,0 ); - } -#endif ret = sd->ops->video->s_stream (sd, enable);if (!enable && ret <0 ) {
@@ -387,9 +378,20 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) ret =0 ; } -if (!ret) +if (!ret) { sd->enabled_streams = enable ?BIT (0 ) :0 ; +#if IS_REACHABLE (CONFIG_LEDS_CLASS ) +if (!IS_ERR_OR_NULL (sd->privacy_led)) { +if (enable) +led_set_brightness (sd->privacy_led, + sd->privacy_led->max_brightness); +else +led_set_brightness (sd->privacy_led,0 ); + } +#endif + } +return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 569/744 media: ov2680: Clear the ret variable on success
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit 49a9bad83b4ab5dac1d7aba2615c77978bcf3984 ]
Since commit 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint property verification") even when the correct 'link-frequencies' property is passed in the devicetree, the driver fails to probe:
ov2680 1-0036: probe with driver ov2680 failed with error -22
The reason is that the variable 'ret' may contain the -EINVAL value from a previous assignment:
ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
&rate);
Fix the problem by clearing 'ret' on the successful path.
Tested on imx7s-warp board with the following devicetree:
port {
ov2680_to_mipi: endpoint {
remote-endpoint = <&mipi_from_sensor>;
clock-lanes = <0>;
data-lanes = <1>;
link-frequencies = /bits/ 64 <330000000>;
};
};Stable-dep-of: 24034af644fc ("media: ov2680: Do not fail if data-lanes property is absent")
--- drivers/media/i2c/ov2680.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/ov2680.c +1 -0
@@ -1123,6 +1123,7 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor) goto out_free_bus_cfg; } + ret =0 ; out_free_bus_cfg:v4l2_fwnode_endpoint_free (&bus_cfg);return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 570/744 media: ov2680: Allow probing if link-frequencies is absent
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit fd2e66abd729dae5809dbb41c6c52a6931cfa6bb ]
Since commit 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint property verification") the ov2680 no longer probes on a imx7s-warp7:
ov2680 1-0036: error -EINVAL: supported link freq 330000000 not found ov2680 1-0036: probe with driver ov2680 failed with error -22
As the 'link-frequencies' property is not mandatory, allow the probe to succeed by skipping the link-frequency verification when the property is absent.
Stable-dep-of: 24034af644fc ("media: ov2680: Do not fail if data-lanes property is absent")
--- drivers/media/i2c/ov2680.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/i2c/ov2680.c +7 -2
@@ -1111,18 +1111,23 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor) goto out_free_bus_cfg; } +if (!bus_cfg.nr_of_link_frequencies) { +dev_warn (dev,"Consider passing 'link-frequencies' in DT\n" ); + goto skip_link_freq_validation; + } +for (i =0 ; i < bus_cfg.nr_of_link_frequencies; i++)if (bus_cfg.link_frequencies[i] == sensor->link_freq[0 ])break ; -if (bus_cfg.nr_of_link_frequencies ==0 || - bus_cfg.nr_of_link_frequencies == i) { +if (bus_cfg.nr_of_link_frequencies == i) { ret =dev_err_probe (dev, -EINVAL ,"supported link freq %lld not found\n" , sensor->link_freq[0 ]); goto out_free_bus_cfg; } +skip_link_freq_validation: ret =0 ; out_free_bus_cfg:v4l2_fwnode_endpoint_free (&bus_cfg);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 571/744 media: ov2680: Do not fail if data-lanes property is absent
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit 24034af644fc01126bec9850346a06ef1450181f ]
Since commit 63b0cd30b78e ("media: ov2680: Add bus-cfg / endpoint property verification") the ov2680 driver no longer probes when the 'data-lanes' property is absent.
The OV2680 sensor has only one data lane, so there is no need for describing it the devicetree.
Remove the unnecessary data-lanes property check.
--- drivers/media/i2c/ov2680.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/media/i2c/ov2680.c +0 -7
@@ -1104,13 +1104,6 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor) sensor->pixel_rate = sensor->link_freq[0 ] *2 ;do_div (sensor->pixel_rate,10 ); -/* Verify bus cfg */ -if (bus_cfg.bus.mipi_csi2.num_data_lanes !=1 ) { - ret =dev_err_probe (dev, -EINVAL , -"only a 1-lane CSI2 config is supported" ); - goto out_free_bus_cfg; - } -if (!bus_cfg.nr_of_link_frequencies) {dev_warn (dev,"Consider passing 'link-frequencies' in DT\n" ); goto skip_link_freq_validation;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 572/744 drm/msm/dsi: Print dual-DSI-adjusted pclk instead of original mode pclk
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marijn Suijten <[email protected]>
[ Upstream commit f12e0e12524a34bf145f7b80122e653ffe3d130a ]
When dual-DSI (bonded DSI) was added in commit ed9976a09b48 ("drm/msm/dsi: adjust dsi timing for dual dsi mode") some DBG() prints were not updated, leading to print the original mode->clock rather than the adjusted (typically the mode clock divided by two, though more recently also adjusted for DSC compression) msm_host->pixel_clk_rate which is passed to clk_set_rate() just below. Fix that by printing the actual pixel_clk_rate that is being set.
Patchwork: https://patchwork.freedesktop.org/patch/589896/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +5 -5
@@ -366,8 +366,8 @@ int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host) {int ret; -DBG ("Set clk rates: pclk=%d, byteclk=%lu" , - msm_host->mode->clock, msm_host->byte_clk_rate); +DBG ("Set clk rates: pclk=%lu, byteclk=%lu" , + msm_host->pixel_clk_rate, msm_host->byte_clk_rate); ret =dev_pm_opp_set_rate (&msm_host->pdev->dev, msm_host->byte_clk_rate);
@@ -440,9 +440,9 @@ int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host) {int ret; -DBG ("Set clk rates: pclk=%d, byteclk=%lu, esc_clk=%lu, dsi_src_clk=%lu" , - msm_host->mode->clock, msm_host->byte_clk_rate, - msm_host->esc_clk_rate, msm_host->src_clk_rate); +DBG ("Set clk rates: pclk=%lu, byteclk=%lu, esc_clk=%lu, dsi_src_clk=%lu" , + msm_host->pixel_clk_rate, msm_host->byte_clk_rate, + msm_host->esc_clk_rate, msm_host->src_clk_rate); ret =clk_set_rate (msm_host->byte_clk, msm_host->byte_clk_rate);if (ret) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 573/744 drm/msm/dpu: Always flush the slave INTF on the CTL
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marijn Suijten <[email protected]>
[ Upstream commit 2b938c3ab0a69ec6ea587bbf6fc2aec3db4a8736 ]
As we can clearly see in a downstream kernel [1], flushing the slave INTF is skipped /only if/ the PPSPLIT topology is active.
However, when DPU was originally submitted to mainline PPSPLIT was no longer part of it (seems to have been ripped out before submission), but this clause was incorrectly ported from the original SDE driver. Given that there is no support for PPSPLIT (currently), flushing the slave INTF should /never/ be skipped (as the if (ppsplit && !master) goto skip; clause downstream never becomes true).
Patchwork: https://patchwork.freedesktop.org/patch/589901/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c +0 -3
@@ -449,9 +449,6 @@ static void dpu_encoder_phys_cmd_enable_helper(_dpu_encoder_phys_cmd_pingpong_config (phys_enc); -if (!dpu_encoder_phys_cmd_is_master (phys_enc)) -return ; - ctl = phys_enc->hw_ctl; ctl->ops.update_pending_flush_intf (ctl, phys_enc->hw_intf->idx); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 574/744 drm/mediatek: dp: Fix mtk_dp_aux_transfer return value
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wojciech Macek <[email protected]>
[ Upstream commit 8431fff9e0f3fc1c5844cf99a73b49b63ceed481 ]
In case there is no DP device attached to the port the transfer function should return IO error, similar to what other drivers do.
In case EAGAIN is returned then any read from /dev/drm_dp_aux device ends up in an infinite loop as the upper layers constantly repeats the transfer request.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dp.c +1 -1
@@ -2080,7 +2080,7 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux,if (mtk_dp->bridge.type != DRM_MODE_CONNECTOR_eDP && !mtk_dp->train_info.cable_plugged_in) { - ret = -EAGAIN ; + ret = -EIO ; goto err; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 575/744 drm/meson: gate px_clk when setting rate
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Armstrong <[email protected]>
[ Upstream commit 5c9837374ecf55a1fa3b7622d365a0456960270f ]
Disable the px_clk when setting the rate to recover a fully configured and correctly reset VCLK clock tree after the rate is set.
--- drivers/gpu/drm/meson/meson_dw_mipi_dsi.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/meson/meson_dw_mipi_dsi.c +7 -0
@@ -95,6 +95,7 @@ static int dw_mipi_dsi_phy_init(void *priv_data)return ret; } +clk_disable_unprepare (mipi_dsi->px_clk); ret =clk_set_rate (mipi_dsi->px_clk, mipi_dsi->mode->clock *1000 );if (ret) {
@@ -103,6 +104,12 @@ static int dw_mipi_dsi_phy_init(void *priv_data)return ret; } + ret =clk_prepare_enable (mipi_dsi->px_clk); +if (ret) { +dev_err (mipi_dsi->dev,"Failed to enable DSI Pixel clock (ret %d)\n" , ret); +return ret; + } +switch (mipi_dsi->dsi_device->format) {case MIPI_DSI_FMT_RGB888 : dpi_data_format =DPI_COLOR_24BIT ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 576/744 um: Fix return value in ubd_init()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
[ Upstream commit 31a5990ed253a66712d7ddc29c92d297a991fdf2 ]
When kmalloc_array() fails to allocate memory, the ubd_init() should return -ENOMEM instead of -1. So, fix it.
--- arch/um/drivers/ubd_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/um/drivers/ubd_kern.c +2 -2
@@ -1099,7 +1099,7 @@ static int __init ubd_init(void)if (irq_req_buffer ==NULL ) {printk (KERN_ERR "Failed to initialize ubd buffering\n" ); -return -1 ; +return -ENOMEM ; } io_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE, sizeof(struct io_thread_req *),
@@ -1110,7 +1110,7 @@ static int __init ubd_init(void)if (io_req_buffer ==NULL ) {printk (KERN_ERR "Failed to initialize ubd buffering\n" ); -return -1 ; +return -ENOMEM ; }platform_driver_register (&ubd_driver);mutex_lock (&ubd_lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 577/744 um: Add winch to winch_handlers before registering winch IRQ
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roberto Sassu <[email protected]>
[ Upstream commit a0fbbd36c156b9f7b2276871d499c9943dfe5101 ]
Registering a winch IRQ is racy, an interrupt may occur before the winch is added to the winch_handlers list.
If that happens, register_winch_irq() adds to that list a winch that is scheduled to be (or has already been) freed, causing a panic later in winch_cleanup().
Avoid the race by adding the winch to the winch_handlers list before registering the IRQ, and rolling back if um_request_irq() fails.
--- arch/um/drivers/line.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/um/drivers/line.c +8 -6
@@ -673,24 +673,26 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_port *port, goto cleanup; } - *winch = ((struct winch ) { .list =LIST_HEAD_INIT (winch->list), - .fd = fd, + *winch = ((struct winch ) { .fd = fd, .tty_fd = tty_fd, .pid = pid, .port = port, .stack = stack }); +spin_lock (&winch_handler_lock); +list_add (&winch->list, &winch_handlers); +spin_unlock (&winch_handler_lock); +if (um_request_irq (WINCH_IRQ , fd,IRQ_READ , winch_interrupt,IRQF_SHARED ,"winch" , winch) <0 ) {printk (KERN_ERR "register_winch_irq - failed to register " "IRQ\n" ); +spin_lock (&winch_handler_lock); +list_del (&winch->list); +spin_unlock (&winch_handler_lock); goto out_free; } -spin_lock (&winch_handler_lock); -list_add (&winch->list, &winch_handlers); -spin_unlock (&winch_handler_lock); -return ; out_free:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 578/744 um: vector: fix bpfflash parameter evaluation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 584ed2f76ff5fe360d87a04d17b6520c7999e06b ]
With W=1 the build complains about a pointer compared to zero, clearly the result should've been compared.
--- arch/um/drivers/vector_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/drivers/vector_kern.c +1 -1
@@ -141,7 +141,7 @@ static bool get_bpf_flash(struct arglist *def)if (allow !=NULL ) {if (kstrtoul (allow,10 , &result) ==0 ) -return (allow >0 ); +return result >0 ; }return false; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 579/744 fs/ntfs3: Check folio pointer for NULL
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit 1cd6c96219c429ebcfa8e79a865277376c563803 ]
It can be NULL if bmap is called.
--- fs/ntfs3/inode.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
fs/ntfs3/inode.c +11 -6
@@ -571,13 +571,18 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,clear_buffer_uptodate (bh);if (is_resident (ni)) { -ni_lock (ni); - err =attr_data_read_resident (ni, &folio->page); -ni_unlock (ni); - -if (!err) -set_buffer_uptodate (bh); + bh->b_blocknr =RESIDENT_LCN ; bh->b_size = block_size; +if (!folio) { + err =0 ; + }else { +ni_lock (ni); + err =attr_data_read_resident (ni, &folio->page); +ni_unlock (ni); + +if (!err) +set_buffer_uptodate (bh); + }return err; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 580/744 fs/ntfs3: Use 64 bit variable to avoid 32 bit overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit e931f6b630ffb22d66caab202a52aa8cbb10c649 ]
For example, in the expression:
vbo = 2 * vbo + skip
--- fs/ntfs3/fslog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ntfs3/fslog.c +2 -1
@@ -1184,7 +1184,8 @@ static int read_log_page(struct ntfs_log *log, u32 vbo,static int log_read_rst (struct ntfs_log *log,bool first,struct restart_info *info) { -u32 skip, vbo; +u32 skip; +u64 vbo;struct RESTART_HDR *r_page =NULL ;/* Determine which restart area we are looking for. */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 581/744 fs/ntfs3: Use variable length array instead of fixed size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit 1997cdc3e727526aa5d84b32f7cbb3f56459b7ef ]
Should fix smatch warning:
ntfs_set_label() error: __builtin_memcpy() 'uni->name' too small (20 vs 256)
--- fs/ntfs3/ntfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/ntfs.h +1 -1
@@ -59,7 +59,7 @@ struct GUID {struct cpu_str {u8 len;u8 unused; -u16 name[10 ]; +u16 name[]; };struct le_str {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 582/744 drm/msm/dpu: remove irq_idx argument from IRQ callbacks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit e75e45c25b66ae9a78fa2476df0bf99ad80f33f9 ]
There is no point in passing the IRQ index to IRQ callbacks, no function uses that. Drop it at last.
Patchwork: https://patchwork.freedesktop.org/patch/550925/
Stable-dep-of: 530f272053a5 ("drm/msm/dpu: Add callback function pointer check before its call")
--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.h | 2 +- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 4 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 2 +- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 8 ++++---- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 4 ++-- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 16 +++++----------- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 4 ++-- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h | 2 +- 8 files changed, 18 insertions(+), 24 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.h +1 -1
@@ -53,7 +53,7 @@ u32 dpu_core_irq_read(int dpu_core_irq_register_callback (struct dpu_kms *dpu_kms,int irq_idx, -void (*irq_cb)(void *arg,int irq_idx), +void (*irq_cb)(void *arg),void *irq_arg);/**
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -2
@@ -358,7 +358,7 @@ static int dpu_encoder_helper_wait_event_timeout(int32_t drm_id,int dpu_encoder_helper_wait_for_irq (struct dpu_encoder_phys *phys_enc,int irq, -void (*func)(void *arg,int irq_idx), +void (*func)(void *arg),struct dpu_encoder_wait_info *wait_info) {u32 irq_status;
@@ -405,7 +405,7 @@ int dpu_encoder_helper_wait_for_irq(struct dpu_encoder_phys *phys_enc, phys_enc->hw_pp->idx -PINGPONG_0 , atomic_read(wait_info->atomic_cnt));local_irq_save (flags); -func (phys_enc, irq); +func (phys_enc);local_irq_restore (flags); ret =0 ; }else {
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +1 -1
@@ -365,7 +365,7 @@ void dpu_encoder_helper_report_irq_timeout(struct dpu_encoder_phys *phys_enc,*/ int dpu_encoder_helper_wait_for_irq (struct dpu_encoder_phys *phys_enc,int irq, -void (*func)(void *arg,int irq_idx), +void (*func)(void *arg),struct dpu_encoder_wait_info *wait_info);/**
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c +4 -4
@@ -76,7 +76,7 @@ static void _dpu_encoder_phys_cmd_update_intf_cfg( phys_enc->hw_intf->ops.program_intf_cmd_cfg (phys_enc->hw_intf, &cmd_mode_cfg); } -static void dpu_encoder_phys_cmd_pp_tx_done_irq (void *arg,int irq_idx) +static void dpu_encoder_phys_cmd_pp_tx_done_irq (void *arg) {struct dpu_encoder_phys *phys_enc = arg;unsigned long lock_flags;
@@ -103,7 +103,7 @@ static void dpu_encoder_phys_cmd_pp_tx_done_irq(void *arg, int irq_idx)DPU_ATRACE_END ("pp_done_irq" ); } -static void dpu_encoder_phys_cmd_te_rd_ptr_irq (void *arg,int irq_idx) +static void dpu_encoder_phys_cmd_te_rd_ptr_irq (void *arg) {struct dpu_encoder_phys *phys_enc = arg;struct dpu_encoder_phys_cmd *cmd_enc;
@@ -126,7 +126,7 @@ static void dpu_encoder_phys_cmd_te_rd_ptr_irq(void *arg, int irq_idx)DPU_ATRACE_END ("rd_ptr_irq" ); } -static void dpu_encoder_phys_cmd_ctl_start_irq (void *arg,int irq_idx) +static void dpu_encoder_phys_cmd_ctl_start_irq (void *arg) {struct dpu_encoder_phys *phys_enc = arg;
@@ -139,7 +139,7 @@ static void dpu_encoder_phys_cmd_ctl_start_irq(void *arg, int irq_idx)DPU_ATRACE_END ("ctl_start_irq" ); } -static void dpu_encoder_phys_cmd_underrun_irq (void *arg,int irq_idx) +static void dpu_encoder_phys_cmd_underrun_irq (void *arg) {struct dpu_encoder_phys *phys_enc = arg;
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +2 -2
@@ -300,7 +300,7 @@ static void dpu_encoder_phys_vid_setup_timing_engine(programmable_fetch_config (phys_enc, &timing_params); } -static void dpu_encoder_phys_vid_vblank_irq (void *arg,int irq_idx) +static void dpu_encoder_phys_vid_vblank_irq (void *arg) {struct dpu_encoder_phys *phys_enc = arg;struct dpu_hw_ctl *hw_ctl;
@@ -337,7 +337,7 @@ static void dpu_encoder_phys_vid_vblank_irq(void *arg, int irq_idx)DPU_ATRACE_END ("vblank_irq" ); } -static void dpu_encoder_phys_vid_underrun_irq (void *arg,int irq_idx) +static void dpu_encoder_phys_vid_underrun_irq (void *arg) {struct dpu_encoder_phys *phys_enc = arg;
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +5 -11
@@ -345,7 +345,11 @@ static void dpu_encoder_phys_wb_setup( } -static void _dpu_encoder_phys_wb_frame_done_helper (void *arg) +/** +* dpu_encoder_phys_wb_done_irq - writeback interrupt handler +* @arg: Pointer to writeback encoder +*/ +static void dpu_encoder_phys_wb_done_irq (void *arg) {struct dpu_encoder_phys *phys_enc = arg;struct dpu_encoder_phys_wb *wb_enc =to_dpu_encoder_phys_wb (phys_enc);
@@ -371,16 +375,6 @@ static void _dpu_encoder_phys_wb_frame_done_helper(void *arg)wake_up_all (&phys_enc->pending_kickoff_wq); } -/** -* dpu_encoder_phys_wb_done_irq - writeback interrupt handler -* @arg: Pointer to writeback encoder -* @irq_idx: interrupt index -*/ -static void dpu_encoder_phys_wb_done_irq (void *arg,int irq_idx) -{ -_dpu_encoder_phys_wb_frame_done_helper (arg); -} -/** * dpu_encoder_phys_wb_irq_ctrl - irq control of WB * @phys: Pointer to physical encoder
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c +2 -2
@@ -217,7 +217,7 @@ static void dpu_core_irq_callback_handler(struct dpu_kms *dpu_kms, int irq_idx)/* * Perform registered function callback */ - dpu_kms->hw_intr->irq_tbl[irq_idx].cb (dpu_kms->hw_intr->irq_tbl[irq_idx].arg, irq_idx); + dpu_kms->hw_intr->irq_tbl[irq_idx].cb (dpu_kms->hw_intr->irq_tbl[irq_idx].arg); }irqreturn_t dpu_core_irq (struct msm_kms *kms)
@@ -507,7 +507,7 @@ void dpu_hw_intr_destroy(struct dpu_hw_intr *intr) }int dpu_core_irq_register_callback (struct dpu_kms *dpu_kms,int irq_idx, -void (*irq_cb)(void *arg,int irq_idx), +void (*irq_cb)(void *arg),void *irq_arg) {unsigned long irq_flags;
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h +1 -1
@@ -58,7 +58,7 @@ struct dpu_hw_intr {const struct dpu_intr_reg *intr_set;struct { -void (*cb)(void *arg,int irq_idx); +void (*cb)(void *arg);void *arg;atomic_t count; } irq_tbl[];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 583/744 drm/msm/dpu: extract dpu_core_irq_is_valid() helper
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit a65264833690d1280b901e3fe8e2825a44b3502c ]
In preparation to reworking IRQ indices, move irq_idx validation to a separate helper.
Patchwork: https://patchwork.freedesktop.org/patch/550929/
Stable-dep-of: 530f272053a5 ("drm/msm/dpu: Add callback function pointer check before its call")
--- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c +11 -11
@@ -200,6 +200,12 @@ static const struct dpu_intr_reg dpu_intr_set_7xxx[] = {#define DPU_IRQ_REG (irq_idx) (irq_idx / 32)#define DPU_IRQ_MASK (irq_idx) (BIT(irq_idx % 32)) +static inline bool dpu_core_irq_is_valid (struct dpu_hw_intr *intr, +int irq_idx) +{ +return irq_idx >=0 && irq_idx < intr->total_irqs; +} +/** * dpu_core_irq_callback_handler - dispatch core interrupts * @dpu_kms: Pointer to DPU's KMS structure
@@ -291,7 +297,7 @@ static int dpu_hw_intr_enable_irq_locked(struct dpu_hw_intr *intr, int irq_idx)if (!intr)return -EINVAL ; -if (irq_idx <0 || irq_idx >= intr->total_irqs) { +if (!dpu_core_irq_is_valid (intr, irq_idx)) {pr_err ("invalid IRQ index: [%d]\n" , irq_idx);return -EINVAL ; }
@@ -344,7 +350,7 @@ static int dpu_hw_intr_disable_irq_locked(struct dpu_hw_intr *intr, int irq_idx)if (!intr)return -EINVAL ; -if (irq_idx <0 || irq_idx >= intr->total_irqs) { +if (!dpu_core_irq_is_valid (intr, irq_idx)) {pr_err ("invalid IRQ index: [%d]\n" , irq_idx);return -EINVAL ; }
@@ -429,13 +435,7 @@ u32 dpu_core_irq_read(struct dpu_kms *dpu_kms, int irq_idx)if (!intr)return 0 ; -if (irq_idx <0 ) { -DPU_ERROR ("[%pS] invalid irq_idx=%d\n" , -__builtin_return_address (0 ), irq_idx); -return 0 ; - } - -if (irq_idx <0 || irq_idx >= intr->total_irqs) { +if (!dpu_core_irq_is_valid (intr, irq_idx)) {pr_err ("invalid IRQ index: [%d]\n" , irq_idx);return 0 ; }
@@ -518,7 +518,7 @@ int dpu_core_irq_register_callback(struct dpu_kms *dpu_kms, int irq_idx,return -EINVAL ; } -if (irq_idx <0 || irq_idx >= dpu_kms->hw_intr->total_irqs) { +if (!dpu_core_irq_is_valid (dpu_kms->hw_intr, irq_idx)) {DPU_ERROR ("invalid IRQ index: [%d]\n" , irq_idx);return -EINVAL ; }
@@ -555,7 +555,7 @@ int dpu_core_irq_unregister_callback(struct dpu_kms *dpu_kms, int irq_idx)unsigned long irq_flags;int ret; -if (irq_idx <0 || irq_idx >= dpu_kms->hw_intr->total_irqs) { +if (!dpu_core_irq_is_valid (dpu_kms->hw_intr, irq_idx)) {DPU_ERROR ("invalid IRQ index: [%d]\n" , irq_idx);return -EINVAL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 584/744 drm/msm/dpu: add helper to get IRQ-related data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit ea4842ed62f3556cf0a90f19d911ee03a4d0c844 ]
In preparation to reworking IRQ indices, move irq_tbl access to a separate helper.
Patchwork: https://patchwork.freedesktop.org/patch/550931/
Stable-dep-of: 530f272053a5 ("drm/msm/dpu: Add callback function pointer check before its call")
--- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 48 +++++++++++++------ .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h | 12 +++-- 2 files changed, 41 insertions(+), 19 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c +34 -14
@@ -206,6 +206,12 @@ static inline bool dpu_core_irq_is_valid(struct dpu_hw_intr *intr,return irq_idx >=0 && irq_idx < intr->total_irqs; } +static inline struct dpu_hw_intr_entry *dpu_core_irq_get_entry (struct dpu_hw_intr *intr, +int irq_idx) +{ +return &intr->irq_tbl[irq_idx]; +} +/** * dpu_core_irq_callback_handler - dispatch core interrupts * @dpu_kms: Pointer to DPU's KMS structure
@@ -213,17 +219,19 @@ static inline bool dpu_core_irq_is_valid(struct dpu_hw_intr *intr,*/ static void dpu_core_irq_callback_handler (struct dpu_kms *dpu_kms,int irq_idx) { +struct dpu_hw_intr_entry *irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, irq_idx); +VERB ("irq_idx=%d\n" , irq_idx); -if (!dpu_kms->hw_intr->irq_tbl[irq_idx].cb) +if (!irq_entry->cb)DRM_ERROR ("no registered cb, idx:%d\n" , irq_idx); -atomic_inc (&dpu_kms->hw_intr->irq_tbl[irq_idx].count); +atomic_inc (&irq_entry->count);/* * Perform registered function callback */ - dpu_kms->hw_intr->irq_tbl[irq_idx].cb (dpu_kms->hw_intr->irq_tbl[irq_idx].arg); + irq_entry->cb (irq_entry->arg); }irqreturn_t dpu_core_irq (struct msm_kms *kms)
@@ -510,6 +518,7 @@ int dpu_core_irq_register_callback(struct dpu_kms *dpu_kms, int irq_idx,void (*irq_cb)(void *arg), void *irq_arg) { + struct dpu_hw_intr_entry *irq_entry;unsigned long irq_flags;int ret;
@@ -527,15 +536,16 @@ int dpu_core_irq_register_callback(struct dpu_kms *dpu_kms, int irq_idx,spin_lock_irqsave (&dpu_kms->hw_intr->irq_lock, irq_flags); -if (unlikely (WARN_ON (dpu_kms->hw_intr->irq_tbl[irq_idx].cb))) { + irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, irq_idx); +if (unlikely (WARN_ON (irq_entry->cb))) {spin_unlock_irqrestore (&dpu_kms->hw_intr->irq_lock, irq_flags);return -EBUSY ; }trace_dpu_core_irq_register_callback (irq_idx, irq_cb); - dpu_kms->hw_intr->irq_tbl[irq_idx].arg = irq_arg; - dpu_kms->hw_intr->irq_tbl[irq_idx].cb = irq_cb; + irq_entry->arg = irq_arg; + irq_entry->cb = irq_cb; ret = dpu_hw_intr_enable_irq_locked( dpu_kms->hw_intr,
@@ -552,6 +562,7 @@ int dpu_core_irq_register_callback(struct dpu_kms *dpu_kms, int irq_idx,int dpu_core_irq_unregister_callback (struct dpu_kms *dpu_kms,int irq_idx) { +struct dpu_hw_intr_entry *irq_entry;unsigned long irq_flags;int ret;
@@ -570,8 +581,9 @@ int dpu_core_irq_unregister_callback(struct dpu_kms *dpu_kms, int irq_idx)DPU_ERROR ("Fail to disable IRQ for irq_idx:%d: %d\n" , irq_idx, ret); - dpu_kms->hw_intr->irq_tbl[irq_idx].cb =NULL ; - dpu_kms->hw_intr->irq_tbl[irq_idx].arg =NULL ; + irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, irq_idx); + irq_entry->cb =NULL ; + irq_entry->arg =NULL ;spin_unlock_irqrestore (&dpu_kms->hw_intr->irq_lock, irq_flags);
@@ -584,14 +596,16 @@ int dpu_core_irq_unregister_callback(struct dpu_kms *dpu_kms, int irq_idx)static int dpu_debugfs_core_irq_show (struct seq_file *s,void *v) {struct dpu_kms *dpu_kms = s->private; +struct dpu_hw_intr_entry *irq_entry;unsigned long irq_flags;int i, irq_count;void *cb;for (i =0 ; i < dpu_kms->hw_intr->total_irqs; i++) {spin_lock_irqsave (&dpu_kms->hw_intr->irq_lock, irq_flags); - irq_count =atomic_read (&dpu_kms->hw_intr->irq_tbl[i].count); - cb = dpu_kms->hw_intr->irq_tbl[i].cb; + irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, i); + irq_count =atomic_read (&irq_entry->count); + cb = irq_entry->cb;spin_unlock_irqrestore (&dpu_kms->hw_intr->irq_lock, irq_flags);if (irq_count || cb)
@@ -614,6 +628,7 @@ void dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms,void dpu_core_irq_preinstall (struct msm_kms *kms) {struct dpu_kms *dpu_kms =to_dpu_kms (kms); +struct dpu_hw_intr_entry *irq_entry;int i;pm_runtime_get_sync (&dpu_kms->pdev->dev);
@@ -621,22 +636,27 @@ void dpu_core_irq_preinstall(struct msm_kms *kms)dpu_disable_all_irqs (dpu_kms);pm_runtime_put_sync (&dpu_kms->pdev->dev); -for (i =0 ; i < dpu_kms->hw_intr->total_irqs; i++) -atomic_set (&dpu_kms->hw_intr->irq_tbl[i].count,0 ); +for (i =0 ; i < dpu_kms->hw_intr->total_irqs; i++) { + irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, i); +atomic_set (&irq_entry->count,0 ); + } }void dpu_core_irq_uninstall (struct msm_kms *kms) {struct dpu_kms *dpu_kms =to_dpu_kms (kms); +struct dpu_hw_intr_entry *irq_entry;int i;if (!dpu_kms->hw_intr)return ;pm_runtime_get_sync (&dpu_kms->pdev->dev); -for (i =0 ; i < dpu_kms->hw_intr->total_irqs; i++) -if (dpu_kms->hw_intr->irq_tbl[i].cb) +for (i =0 ; i < dpu_kms->hw_intr->total_irqs; i++) { + irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, i); +if (irq_entry->cb)DPU_ERROR ("irq_idx=%d still enabled/registered\n" , i); + }dpu_clear_irqs (dpu_kms);dpu_disable_all_irqs (dpu_kms);
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h +7 -5
@@ -38,6 +38,12 @@ enum dpu_hw_intr_reg {#define DPU_IRQ_IDX (reg_idx, offset) (reg_idx * 32 + offset) +struct dpu_hw_intr_entry { +void (*cb)(void *arg); +void *arg; +atomic_t count; +}; +/** * struct dpu_hw_intr: hw interrupts handling data structure * @hw: virtual address mapping
@@ -57,11 +63,7 @@ struct dpu_hw_intr {unsigned long irq_mask;const struct dpu_intr_reg *intr_set; -struct { -void (*cb)(void *arg); -void *arg; -atomic_t count; - } irq_tbl[]; +struct dpu_hw_intr_entry irq_tbl[]; };/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 585/744 drm/msm/dpu: make the irq table size static
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 56acb1b620e263d3fed8f11f71bf2ab7ce1cae5b ]
The size of the irq table is static, it has MDP_INTR_MAX * 32 interrupt entries. Provide the fixed length and drop struct_size() statement.
Patchwork: https://patchwork.freedesktop.org/patch/550927/
Stable-dep-of: 530f272053a5 ("drm/msm/dpu: Add callback function pointer check before its call")
--- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 26 ++++++++----------- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h | 6 ++--- 2 files changed, 14 insertions(+), 18 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c +11 -15
@@ -200,10 +200,9 @@ static const struct dpu_intr_reg dpu_intr_set_7xxx[] = {#define DPU_IRQ_REG (irq_idx) (irq_idx / 32)#define DPU_IRQ_MASK (irq_idx) (BIT(irq_idx % 32)) -static inline bool dpu_core_irq_is_valid (struct dpu_hw_intr *intr, -int irq_idx) +static inline bool dpu_core_irq_is_valid (int irq_idx) { -return irq_idx >=0 && irq_idx < intr->total_irqs; +return irq_idx >=0 && irq_idx <DPU_NUM_IRQS ; } static inline struct dpu_hw_intr_entry *dpu_core_irq_get_entry(struct dpu_hw_intr *intr,
@@ -305,7 +304,7 @@ static int dpu_hw_intr_enable_irq_locked(struct dpu_hw_intr *intr, int irq_idx)if (!intr)return -EINVAL ; -if (!dpu_core_irq_is_valid (intr, irq_idx)) { +if (!dpu_core_irq_is_valid (irq_idx)) {pr_err ("invalid IRQ index: [%d]\n" , irq_idx);return -EINVAL ; }
@@ -358,7 +357,7 @@ static int dpu_hw_intr_disable_irq_locked(struct dpu_hw_intr *intr, int irq_idx)if (!intr)return -EINVAL ; -if (!dpu_core_irq_is_valid (intr, irq_idx)) { +if (!dpu_core_irq_is_valid (irq_idx)) {pr_err ("invalid IRQ index: [%d]\n" , irq_idx);return -EINVAL ; }
@@ -443,7 +442,7 @@ u32 dpu_core_irq_read(struct dpu_kms *dpu_kms, int irq_idx)if (!intr)return 0 ; -if (!dpu_core_irq_is_valid (intr, irq_idx)) { +if (!dpu_core_irq_is_valid (irq_idx)) {pr_err ("invalid IRQ index: [%d]\n" , irq_idx);return 0 ; }
@@ -470,13 +469,12 @@ struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr, const struct dpu_mdss_cfg *m) {struct dpu_hw_intr *intr; -int nirq =MDP_INTR_MAX *32 ;unsigned int i;if (!addr || !m)return ERR_PTR (-EINVAL ); - intr =kzalloc (struct_size (intr, irq_tbl, nirq),GFP_KERNEL ); + intr =kzalloc (sizeof (*intr),GFP_KERNEL );if (!intr)return ERR_PTR (-ENOMEM );
@@ -487,8 +485,6 @@ struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr, intr->hw.blk_addr = addr + m->mdp[0 ].base; - intr->total_irqs = nirq; - intr->irq_mask =BIT (MDP_SSPP_TOP0_INTR ) |BIT (MDP_SSPP_TOP0_INTR2 ) |BIT (MDP_SSPP_TOP0_HIST_INTR );
@@ -527,7 +523,7 @@ int dpu_core_irq_register_callback(struct dpu_kms *dpu_kms, int irq_idx,return -EINVAL ; } -if (!dpu_core_irq_is_valid (dpu_kms->hw_intr, irq_idx)) { +if (!dpu_core_irq_is_valid (irq_idx)) {DPU_ERROR ("invalid IRQ index: [%d]\n" , irq_idx);return -EINVAL ; }
@@ -566,7 +562,7 @@ int dpu_core_irq_unregister_callback(struct dpu_kms *dpu_kms, int irq_idx)unsigned long irq_flags;int ret; -if (!dpu_core_irq_is_valid (dpu_kms->hw_intr, irq_idx)) { +if (!dpu_core_irq_is_valid (irq_idx)) {DPU_ERROR ("invalid IRQ index: [%d]\n" , irq_idx);return -EINVAL ; }
@@ -601,7 +597,7 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v)int i, irq_count;void *cb; -for (i =0 ; i < dpu_kms->hw_intr->total_irqs; i++) { +for (i =0 ; i <DPU_NUM_IRQS ; i++) {spin_lock_irqsave (&dpu_kms->hw_intr->irq_lock, irq_flags); irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, i); irq_count =atomic_read (&irq_entry->count);
@@ -636,7 +632,7 @@ void dpu_core_irq_preinstall(struct msm_kms *kms)dpu_disable_all_irqs (dpu_kms);pm_runtime_put_sync (&dpu_kms->pdev->dev); -for (i =0 ; i < dpu_kms->hw_intr->total_irqs; i++) { +for (i =0 ; i <DPU_NUM_IRQS ; i++) { irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, i);atomic_set (&irq_entry->count,0 ); }
@@ -652,7 +648,7 @@ void dpu_core_irq_uninstall(struct msm_kms *kms)return ;pm_runtime_get_sync (&dpu_kms->pdev->dev); -for (i =0 ; i < dpu_kms->hw_intr->total_irqs; i++) { +for (i =0 ; i <DPU_NUM_IRQS ; i++) { irq_entry =dpu_core_irq_get_entry (dpu_kms->hw_intr, i);if (irq_entry->cb)DPU_ERROR ("irq_idx=%d still enabled/registered\n" , i);
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h +3 -3
@@ -38,6 +38,8 @@ enum dpu_hw_intr_reg {#define DPU_IRQ_IDX (reg_idx, offset) (reg_idx * 32 + offset) +#define DPU_NUM_IRQS (MDP_INTR_MAX * 32) +struct dpu_hw_intr_entry {void (*cb)(void *arg);void *arg;
@@ -50,7 +52,6 @@ struct dpu_hw_intr_entry {* @ops: function pointer mapping for IRQ handling * @cache_irq_mask: array of IRQ enable masks reg storage created during init * @save_irq_status: array of IRQ status reg storage created during init -* @total_irqs: total number of irq_idx mapped in the hw_interrupts * @irq_lock: spinlock for accessing IRQ resources * @irq_cb_tbl: array of IRQ callbacks */
@@ -58,12 +59,11 @@ struct dpu_hw_intr {struct dpu_hw_blk_reg_map hw;u32 cache_irq_mask[MDP_INTR_MAX ];u32 *save_irq_status; -u32 total_irqs;spinlock_t irq_lock;unsigned long irq_mask;const struct dpu_intr_reg *intr_set; -struct dpu_hw_intr_entry irq_tbl[]; +struct dpu_hw_intr_entry irq_tbl[DPU_NUM_IRQS ]; };/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 586/744 drm/msm/dpu: stop using raw IRQ indices in the kernel output
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 6893199183f836e1ff452082f0f9d068364b2f17 ]
In preparation to reworking IRQ indcies, stop using raw IRQ indices in kernel output (both printk and debugfs). Instead use a pair of register index and bit. This corresponds closer to the values in HW catalog.
Patchwork: https://patchwork.freedesktop.org/patch/550933/
Stable-dep-of: 530f272053a5 ("drm/msm/dpu: Add callback function pointer check before its call")
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 26 +++++----- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 51 +++++++++++-------- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h | 2 + 3 files changed, 46 insertions(+), 33 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +13 -13
@@ -357,7 +357,7 @@ static int dpu_encoder_helper_wait_event_timeout(int32_t drm_id, u32 irq_idx, struct dpu_encoder_wait_info *info);int dpu_encoder_helper_wait_for_irq (struct dpu_encoder_phys *phys_enc, -int irq, +int irq_idx,void (*func)(void *arg),struct dpu_encoder_wait_info *wait_info) {
@@ -372,36 +372,36 @@ int dpu_encoder_helper_wait_for_irq(struct dpu_encoder_phys *phys_enc,/* return EWOULDBLOCK since we know the wait isn't necessary */ if (phys_enc->enable_state ==DPU_ENC_DISABLED ) { -DRM_ERROR ("encoder is disabled id=%u, callback=%ps, irq=%d\n" , +DRM_ERROR ("encoder is disabled id=%u, callback=%ps, IRQ=[%d, %d]\n" ,DRMID (phys_enc->parent), func, - irq); +DPU_IRQ_REG (irq_idx),DPU_IRQ_BIT (irq_idx));return -EWOULDBLOCK ; } -if (irq <0 ) { +if (irq_idx <0 ) {DRM_DEBUG_KMS ("skip irq wait id=%u, callback=%ps\n" ,DRMID (phys_enc->parent), func);return 0 ; } -DRM_DEBUG_KMS ("id=%u, callback=%ps, irq=%d, pp=%d, pending_cnt=%d\n" , +DRM_DEBUG_KMS ("id=%u, callback=%ps, IRQ=[%d, %d], pp=%d, pending_cnt=%d\n" ,DRMID (phys_enc->parent), func, - irq, phys_enc->hw_pp->idx -PINGPONG_0 , +DPU_IRQ_REG (irq_idx),DPU_IRQ_BIT (irq_idx), phys_enc->hw_pp->idx -PINGPONG_0 ,atomic_read (wait_info->atomic_cnt)); ret =dpu_encoder_helper_wait_event_timeout (DRMID (phys_enc->parent), - irq, + irq_idx, wait_info);if (ret <=0 ) { - irq_status =dpu_core_irq_read (phys_enc->dpu_kms, irq); + irq_status =dpu_core_irq_read (phys_enc->dpu_kms, irq_idx);if (irq_status) {unsigned long flags; -DRM_DEBUG_KMS ("irq not triggered id=%u, callback=%ps, irq=%d, pp=%d, atomic_cnt=%d\n" , +DRM_DEBUG_KMS ("IRQ=[%d, %d] not triggered id=%u, callback=%ps, pp=%d, atomic_cnt=%d\n" , +DPU_IRQ_REG (irq_idx),DPU_IRQ_BIT (irq_idx),DRMID (phys_enc->parent), func, - irq, phys_enc->hw_pp->idx -PINGPONG_0 ,atomic_read (wait_info->atomic_cnt));local_irq_save (flags);
@@ -410,16 +410,16 @@ int dpu_encoder_helper_wait_for_irq(struct dpu_encoder_phys *phys_enc, ret =0 ; }else { ret = -ETIMEDOUT ; -DRM_DEBUG_KMS ("irq timeout id=%u, callback=%ps, irq=%d, pp=%d, atomic_cnt=%d\n" , +DRM_DEBUG_KMS ("IRQ=[%d, %d] timeout id=%u, callback=%ps, pp=%d, atomic_cnt=%d\n" , +DPU_IRQ_REG (irq_idx),DPU_IRQ_BIT (irq_idx),DRMID (phys_enc->parent), func, - irq, phys_enc->hw_pp->idx -PINGPONG_0 ,atomic_read (wait_info->atomic_cnt)); } }else { ret =0 ;trace_dpu_enc_irq_wait_success (DRMID (phys_enc->parent), - func, irq, + func, irq_idx, phys_enc->hw_pp->idx -PINGPONG_0 ,atomic_read (wait_info->atomic_cnt)); }
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c +31 -20
141 lines not on this page · raw message
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h +2 -0
@@ -37,6 +37,8 @@ enum dpu_hw_intr_reg {#define MDP_INTFn_INTR (intf) (MDP_INTF0_INTR + (intf - INTF_0))#define DPU_IRQ_IDX (reg_idx, offset) (reg_idx * 32 + offset) +#define DPU_IRQ_REG (irq_idx) (irq_idx / 32) +#define DPU_IRQ_BIT (irq_idx) (irq_idx % 32)#define DPU_NUM_IRQS (MDP_INTR_MAX * 32)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 587/744 drm/msm/dpu: Add callback function pointer check before its call
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Mishin <[email protected]>
[ Upstream commit 530f272053a5e72243a9cb07bb1296af6c346002 ]
In dpu_core_irq_callback_handler() callback function pointer is compared to NULL, but then callback function is unconditionally called by this pointer. Fix this bug by adding conditional return.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Patchwork: https://patchwork.freedesktop.org/patch/588237/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c +3 -1
@@ -221,9 +221,11 @@ static void dpu_core_irq_callback_handler(struct dpu_kms *dpu_kms, int irq_idx)VERB ("IRQ=[%d, %d]\n" ,DPU_IRQ_REG (irq_idx),DPU_IRQ_BIT (irq_idx)); -if (!irq_entry->cb) +if (!irq_entry->cb) {DRM_ERROR ("no registered cb, IRQ=[%d, %d]\n" ,DPU_IRQ_REG (irq_idx),DPU_IRQ_BIT (irq_idx)); +return ; + }atomic_inc (&irq_entry->count);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 588/744 drm/bridge: tc358775: fix support for jeida-18 and jeida-24
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Walle <[email protected]>
[ Upstream commit 30ea09a182cb37c4921b9d477ed18107befe6d78 ]
The bridge always uses 24bpp internally. Therefore, for jeida-18 mapping we need to discard the lowest two bits for each channel and thus starting with LV_[RGB]2. jeida-24 has the same mapping but uses four lanes instead of three, with the forth pair transmitting the lowest two bits of each channel. Thus, the mapping between jeida-18 and jeida-24 is actually the same, except that one channel is turned off (by selecting the RGB666 format in VPCTRL).
While at it, remove the bogus comment about the hardware default because the default is overwritten in any case.
Tested with a jeida-18 display (Evervision VGG644804).
--- drivers/gpu/drm/bridge/tc358775.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/gpu/drm/bridge/tc358775.c +9 -12
@@ -454,10 +454,6 @@ static void tc_bridge_enable(struct drm_bridge *bridge)dev_dbg (tc->dev,"bus_formats %04x bpc %d\n" , connector->display_info.bus_formats[0 ], tc->bpc); -/* -* Default hardware register settings of tc358775 configured -* with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format -*/ if (connector->display_info.bus_formats[0 ] ==MEDIA_BUS_FMT_RGB888_1X7X4_SPWG ) {/* VESA-24 */
@@ -468,14 +464,15 @@ static void tc_bridge_enable(struct drm_bridge *bridge)d2l_write (tc->i2c,LV_MX1619 ,LV_MX (LVI_B6 ,LVI_B7 ,LVI_B1 ,LVI_B2 ));d2l_write (tc->i2c,LV_MX2023 ,LV_MX (LVI_B3 ,LVI_B4 ,LVI_B5 ,LVI_L0 ));d2l_write (tc->i2c,LV_MX2427 ,LV_MX (LVI_HS ,LVI_VS ,LVI_DE ,LVI_R6 )); - }else {/* MEDIA_BUS_FMT_RGB666_1X7X3_SPWG - JEIDA-18 */ -d2l_write (tc->i2c,LV_MX0003 ,LV_MX (LVI_R0 ,LVI_R1 ,LVI_R2 ,LVI_R3 )); -d2l_write (tc->i2c,LV_MX0407 ,LV_MX (LVI_R4 ,LVI_L0 ,LVI_R5 ,LVI_G0 )); -d2l_write (tc->i2c,LV_MX0811 ,LV_MX (LVI_G1 ,LVI_G2 ,LVI_L0 ,LVI_L0 )); -d2l_write (tc->i2c,LV_MX1215 ,LV_MX (LVI_G3 ,LVI_G4 ,LVI_G5 ,LVI_B0 )); -d2l_write (tc->i2c,LV_MX1619 ,LV_MX (LVI_L0 ,LVI_L0 ,LVI_B1 ,LVI_B2 )); -d2l_write (tc->i2c,LV_MX2023 ,LV_MX (LVI_B3 ,LVI_B4 ,LVI_B5 ,LVI_L0 )); -d2l_write (tc->i2c,LV_MX2427 ,LV_MX (LVI_HS ,LVI_VS ,LVI_DE ,LVI_L0 )); + }else { +/* JEIDA-18 and JEIDA-24 */ +d2l_write (tc->i2c,LV_MX0003 ,LV_MX (LVI_R2 ,LVI_R3 ,LVI_R4 ,LVI_R5 )); +d2l_write (tc->i2c,LV_MX0407 ,LV_MX (LVI_R6 ,LVI_R1 ,LVI_R7 ,LVI_G2 )); +d2l_write (tc->i2c,LV_MX0811 ,LV_MX (LVI_G3 ,LVI_G4 ,LVI_G0 ,LVI_G1 )); +d2l_write (tc->i2c,LV_MX1215 ,LV_MX (LVI_G5 ,LVI_G6 ,LVI_G7 ,LVI_B2 )); +d2l_write (tc->i2c,LV_MX1619 ,LV_MX (LVI_B0 ,LVI_B1 ,LVI_B3 ,LVI_B4 )); +d2l_write (tc->i2c,LV_MX2023 ,LV_MX (LVI_B5 ,LVI_B6 ,LVI_B7 ,LVI_L0 )); +d2l_write (tc->i2c,LV_MX2427 ,LV_MX (LVI_HS ,LVI_VS ,LVI_DE ,LVI_R0 )); }d2l_write (tc->i2c,VFUEN ,VFUEN_EN );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 589/744 media: stk1160: fix bounds checking in stk1160_copy_video()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit faa4364bef2ec0060de381ff028d1d836600a381 ]
The subtract in this condition is reversed. The ->length is the length of the buffer. The ->bytesused is how many bytes we have copied thus far. When the condition is reversed that means the result of the subtraction is always negative but since it's unsigned then the result is a very high positive value. That means the overflow check is never true.
Additionally, the ->bytesused doesn't actually work for this purpose because we're not writing to "buf->mem + buf->bytesused". Instead, the math to calculate the destination where we are writing is a bit involved. You calculate the number of full lines already written, multiply by two, skip a line if necessary so that we start on an odd numbered line, and add the offset into the line.
To fix this buffer overflow, just take the actual destination where we are writing, if the offset is already out of bounds print an error and return. Otherwise, write up to buf->length bytes.
--- drivers/media/usb/stk1160/stk1160-video.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/media/usb/stk1160/stk1160-video.c +15 -5
@@ -99,7 +99,7 @@ void stk1160_buffer_done(struct stk1160 *dev)static inline void stk1160_copy_video (struct stk1160 *dev,u8 *src,int len) { -int linesdone, lineoff, lencopy; +int linesdone, lineoff, lencopy, offset;int bytesperline = dev->width *2 ;struct stk1160_buffer *buf = dev->isoc_ctl.buf;u8 *dst = buf->mem;
@@ -139,8 +139,13 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len)* Check if we have enough space left in the buffer. * In that case, we force loop exit after copy. */ -if (lencopy > buf->bytesused - buf->length) { - lencopy = buf->bytesused - buf->length; + offset = dst - (u8 *)buf->mem; +if (offset > buf->length) { +dev_warn_ratelimited (dev->dev,"out of bounds offset\n" ); +return ; + } +if (lencopy > buf->length - offset) { + lencopy = buf->length - offset; remain = lencopy; }
@@ -182,8 +187,13 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len)* Check if we have enough space left in the buffer. * In that case, we force loop exit after copy. */ -if (lencopy > buf->bytesused - buf->length) { - lencopy = buf->bytesused - buf->length; + offset = dst - (u8 *)buf->mem; +if (offset > buf->length) { +dev_warn_ratelimited (dev->dev,"offset out of bounds\n" ); +return ; + } +if (lencopy > buf->length - offset) { + lencopy = buf->length - offset; remain = lencopy; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 590/744 Input: cyapa - add missing input core locking to suspend/resume functions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 7b4e0b39182cf5e677c1fc092a3ec40e621c25b6 ]
Grab input->mutex during suspend/resume functions like it is done in other input drivers. This fixes the following warning during system suspend/resume cycle on Samsung Exynos5250-based Snow Chromebook:
------------[ cut here ]------------ WARNING: CPU: 1 PID: 1680 at drivers/input/input.c:2291 input_device_enabled+0x68/0x6c Modules linked in: ... CPU: 1 PID: 1680 Comm: kworker/u4:12 Tainted: G W 6.6.0-rc5-next-20231009 #14109 Hardware name: Samsung Exynos (Flattened Device Tree) Workqueue: events_unbound async_run_entry_fn unwind_backtrace from show_stack+0x10/0x14 show_stack from dump_stack_lvl+0x58/0x70 dump_stack_lvl from __warn+0x1a8/0x1cc __warn from warn_slowpath_fmt+0x18c/0x1b4 warn_slowpath_fmt from input_device_enabled+0x68/0x6c input_device_enabled from cyapa_gen3_set_power_mode+0x13c/0x1dc cyapa_gen3_set_power_mode from cyapa_reinitialize+0x10c/0x15c cyapa_reinitialize from cyapa_resume+0x48/0x98 cyapa_resume from dpm_run_callback+0x90/0x298 dpm_run_callback from device_resume+0xb4/0x258 device_resume from async_resume+0x20/0x64 async_resume from async_run_entry_fn+0x40/0x15c async_run_entry_fn from process_scheduled_works+0xbc/0x6a8 process_scheduled_works from worker_thread+0x188/0x454 worker_thread from kthread+0x108/0x140 kthread from ret_from_fork+0x14/0x28 Exception stack(0xf1625fb0 to 0xf1625ff8) ... ---[ end trace 0000000000000000 ]--- ... ------------[ cut here ]------------ WARNING: CPU: 1 PID: 1680 at drivers/input/input.c:2291 input_device_enabled+0x68/0x6c Modules linked in: ... CPU: 1 PID: 1680 Comm: kworker/u4:12 Tainted: G W 6.6.0-rc5-next-20231009 #14109 Hardware name: Samsung Exynos (Flattened Device Tree) Workqueue: events_unbound async_run_entry_fn unwind_backtrace from show_stack+0x10/0x14 show_stack from dump_stack_lvl+0x58/0x70 dump_stack_lvl from __warn+0x1a8/0x1cc __warn from warn_slowpath_fmt+0x18c/0x1b4 warn_slowpath_fmt from input_device_enabled+0x68/0x6c input_device_enabled from cyapa_gen3_set_power_mode+0x13c/0x1dc cyapa_gen3_set_power_mode from cyapa_reinitialize+0x10c/0x15c cyapa_reinitialize from cyapa_resume+0x48/0x98 cyapa_resume from dpm_run_callback+0x90/0x298 dpm_run_callback from device_resume+0xb4/0x258 device_resume from async_resume+0x20/0x64 async_resume from async_run_entry_fn+0x40/0x15c async_run_entry_fn from process_scheduled_works+0xbc/0x6a8 process_scheduled_works from worker_thread+0x188/0x454 worker_thread from kthread+0x108/0x140 kthread from ret_from_fork+0x14/0x28 Exception stack(0xf1625fb0 to 0xf1625ff8) ... ---[ end trace 0000000000000000 ]---
--- drivers/input/mouse/cyapa.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/input/mouse/cyapa.c +11 -1
@@ -1356,10 +1356,16 @@ static int cyapa_suspend(struct device *dev)u8 power_mode;int error; - error =mutex_lock_interruptible (&cyapa->state_sync_lock); + error =mutex_lock_interruptible (&cyapa->input->mutex);if (error)return error; + error =mutex_lock_interruptible (&cyapa->state_sync_lock); +if (error) { +mutex_unlock (&cyapa->input->mutex); +return error; + } +/* * Runtime PM is enable only when device is in operational mode and * users in use, so need check it before disable it to
@@ -1394,6 +1400,8 @@ static int cyapa_suspend(struct device *dev) cyapa->irq_wake = (enable_irq_wake (client->irq) ==0 );mutex_unlock (&cyapa->state_sync_lock); +mutex_unlock (&cyapa->input->mutex); +return 0 ; }
@@ -1403,6 +1411,7 @@ static int cyapa_resume(struct device *dev)struct cyapa *cyapa =i2c_get_clientdata (client);int error; +mutex_lock (&cyapa->input->mutex);mutex_lock (&cyapa->state_sync_lock);if (device_may_wakeup (dev) && cyapa->irq_wake) {
@@ -1421,6 +1430,7 @@ static int cyapa_resume(struct device *dev)enable_irq (client->irq);mutex_unlock (&cyapa->state_sync_lock); +mutex_unlock (&cyapa->input->mutex);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 591/744 drm/amdgpu: init microcode chip name from ip versions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Le Ma <[email protected]>
[ Upstream commit 92ed1e9cd5f6cc4f8c9a9ba6c4d2d2bbc6221296 ]
To adapt to different gc versions in gfx_v9_4_3.c file.
Stable-dep-of: acce6479e30f ("drm/amdgpu: Fix buffer size in gfx_v9_4_3_init_ cp_compute_microcode() and rlc_microcode()")
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +4 -4
@@ -425,16 +425,16 @@ static int gfx_v9_4_3_init_cp_compute_microcode(struct amdgpu_device *adev,static int gfx_v9_4_3_init_microcode (struct amdgpu_device *adev) { -const char *chip_name; +char ucode_prefix[30 ];int r; - chip_name ="gc_9_4_3" ; +amdgpu_ucode_ip_version_decode (adev,GC_HWIP , ucode_prefix,sizeof (ucode_prefix)); - r =gfx_v9_4_3_init_rlc_microcode (adev, chip_name); + r =gfx_v9_4_3_init_rlc_microcode (adev, ucode_prefix);if (r)return r; - r =gfx_v9_4_3_init_cp_compute_microcode (adev, chip_name); + r =gfx_v9_4_3_init_cp_compute_microcode (adev, ucode_prefix);if (r)return r;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 592/744 drm/amdgpu: Fix buffer size in gfx_v9_4_3_init_ cp_compute_microcode() and rlc_microcode()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit acce6479e30f73ab0872e93a75aed1fb791d04ec ]
The function gfx_v9_4_3_init_microcode in gfx_v9_4_3.c was generating about potential truncation of output when using the snprintf function. The issue was due to the size of the buffer 'ucode_prefix' being too small to accommodate the maximum possible length of the string being written into it.
The string being written is "amdgpu/%s_mec.bin" or "amdgpu/%s_rlc.bin", where %s is replaced by the value of 'chip_name'. The length of this string without the %s is 16 characters. The warning message indicated that 'chip_name' could be up to 29 characters long, resulting in a total of 45 characters, which exceeds the buffer size of 30 characters.
To resolve this issue, the size of the 'ucode_prefix' buffer has been reduced from 30 to 15. This ensures that the maximum possible length of the string being written into the buffer will not exceed its size, thus preventing potential buffer overflow and truncation issues.
Fixes the below with gcc W=1:drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c: In function ‘gfx_v9_4_3_early_init’:drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:379:52: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
379 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name);
| ^~
......
439 | r = gfx_v9_4_3_init_rlc_microcode(adev, ucode_prefix);
| ~~~~~~~~~~~~drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:379:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 30
379 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:413:52: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
413 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
| ^~
......
443 | r = gfx_v9_4_3_init_cp_compute_microcode(adev, ucode_prefix);
| ~~~~~~~~~~~~drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:413:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 30
413 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
@@ -425,7 +425,7 @@ static int gfx_v9_4_3_init_cp_compute_microcode(struct amdgpu_device *adev,static int gfx_v9_4_3_init_microcode (struct amdgpu_device *adev) { -char ucode_prefix[30 ]; +char ucode_prefix[15 ];int r;amdgpu_ucode_ip_version_decode (adev,GC_HWIP , ucode_prefix,sizeof (ucode_prefix));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 593/744 media: mediatek: vcodec: add encoder power management helper functions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Irui Wang <[email protected]>
[ Upstream commit 3568cb6556695af163e930a75b1ed8f6dfa848ba ]
Remove PM functions at start/stop streaming, add PM helper functions to get PM before encoding frame start and put PM after encoding frame done. Meanwhile, remove unnecessary clock operations.
Stable-dep-of: c28d4921a1e3 ("media: mediatek: vcodec: fix possible unbalanced PM counter")
--- .../mediatek/vcodec/encoder/mtk_vcodec_enc.c | 21 +++---------------- .../vcodec/encoder/mtk_vcodec_enc_pm.c | 18 ++++++++++++++++ .../vcodec/encoder/mtk_vcodec_enc_pm.h | 3 ++- .../mediatek/vcodec/encoder/venc_drv_if.c | 8 ++----- 4 files changed, 25 insertions(+), 25 deletions(-)
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c +3 -18
@@ -866,7 +866,7 @@ static int vb2ops_venc_start_streaming(struct vb2_queue *q, unsigned int count) {struct mtk_vcodec_enc_ctx *ctx =vb2_get_drv_priv (q);struct venc_enc_param param; -int ret, pm_ret; +int ret;int i;/* Once state turn into MTK_STATE_ABORT, we need stop_streaming
@@ -886,18 +886,12 @@ static int vb2ops_venc_start_streaming(struct vb2_queue *q, unsigned int count)return 0 ; } - ret =pm_runtime_resume_and_get (&ctx->dev->plat_dev->dev); -if (ret <0 ) { -mtk_v4l2_venc_err (ctx,"pm_runtime_resume_and_get fail %d" , ret); - goto err_start_stream; - } -mtk_venc_set_param (ctx, ¶m); ret =venc_if_set_param (ctx,VENC_SET_PARAM_ENC , ¶m);if (ret) {mtk_v4l2_venc_err (ctx,"venc_if_set_param failed=%d" , ret); ctx->state =MTK_STATE_ABORT ; - goto err_set_param; + goto err_start_stream; } ctx->param_change =MTK_ENCODE_PARAM_NONE ;
@@ -910,18 +904,13 @@ static int vb2ops_venc_start_streaming(struct vb2_queue *q, unsigned int count)if (ret) {mtk_v4l2_venc_err (ctx,"venc_if_set_param failed=%d" , ret); ctx->state =MTK_STATE_ABORT ; - goto err_set_param; + goto err_start_stream; } ctx->state =MTK_STATE_HEADER ; }return 0 ; -err_set_param: - pm_ret =pm_runtime_put (&ctx->dev->plat_dev->dev); -if (pm_ret <0 ) -mtk_v4l2_venc_err (ctx,"pm_runtime_put fail %d" , pm_ret); - err_start_stream:for (i =0 ; i < q->num_buffers; ++i) {struct vb2_buffer *buf =vb2_get_buffer (q, i);
@@ -1004,10 +993,6 @@ static void vb2ops_venc_stop_streaming(struct vb2_queue *q)if (ret)mtk_v4l2_venc_err (ctx,"venc_if_deinit failed=%d" , ret); - ret =pm_runtime_put (&ctx->dev->plat_dev->dev); -if (ret <0 ) -mtk_v4l2_venc_err (ctx,"pm_runtime_put fail %d" , ret); - ctx->state =MTK_STATE_FREE ; }
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_pm.c +18 -0
@@ -58,6 +58,24 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_enc_dev *mtkdev)return 0 ; } +void mtk_vcodec_enc_pw_on (struct mtk_vcodec_pm *pm) +{ +int ret; + + ret =pm_runtime_resume_and_get (pm->dev); +if (ret) +dev_err (pm->dev,"pm_runtime_resume_and_get fail: %d" , ret); +} + +void mtk_vcodec_enc_pw_off (struct mtk_vcodec_pm *pm) +{ +int ret; + + ret =pm_runtime_put (pm->dev); +if (ret && ret != -EAGAIN ) +dev_err (pm->dev,"pm_runtime_put fail %d" , ret); +} +void mtk_vcodec_enc_clock_on (struct mtk_vcodec_pm *pm) {struct mtk_vcodec_clk *enc_clk = &pm->venc_clk;
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_pm.h +2 -1
@@ -10,7 +10,8 @@#include "mtk_vcodec_enc_drv.h" int mtk_vcodec_init_enc_clk (struct mtk_vcodec_enc_dev *dev); - +void mtk_vcodec_enc_pw_on (struct mtk_vcodec_pm *pm); +void mtk_vcodec_enc_pw_off (struct mtk_vcodec_pm *pm);void mtk_vcodec_enc_clock_on (struct mtk_vcodec_pm *pm);void mtk_vcodec_enc_clock_off (struct mtk_vcodec_pm *pm);
drivers/media/platform/mediatek/vcodec/encoder/venc_drv_if.c +2 -6
@@ -32,9 +32,7 @@ int venc_if_init(struct mtk_vcodec_enc_ctx *ctx, unsigned int fourcc) }mtk_venc_lock (ctx); -mtk_vcodec_enc_clock_on (&ctx->dev->pm); ret = ctx->enc_if->init (ctx); -mtk_vcodec_enc_clock_off (&ctx->dev->pm);mtk_venc_unlock (ctx);return ret;
@@ -46,9 +44,7 @@ int venc_if_set_param(struct mtk_vcodec_enc_ctx *ctx,int ret =0 ;mtk_venc_lock (ctx); -mtk_vcodec_enc_clock_on (&ctx->dev->pm); ret = ctx->enc_if->set_param (ctx->drv_handle, type, in); -mtk_vcodec_enc_clock_off (&ctx->dev->pm);mtk_venc_unlock (ctx);return ret;
@@ -68,10 +64,12 @@ int venc_if_encode(struct mtk_vcodec_enc_ctx *ctx, ctx->dev->curr_ctx = ctx;spin_unlock_irqrestore (&ctx->dev->irqlock, flags); +mtk_vcodec_enc_pw_on (&ctx->dev->pm);mtk_vcodec_enc_clock_on (&ctx->dev->pm); ret = ctx->enc_if->encode (ctx->drv_handle, opt, frm_buf, bs_buf, result);mtk_vcodec_enc_clock_off (&ctx->dev->pm); +mtk_vcodec_enc_pw_off (&ctx->dev->pm);spin_lock_irqsave (&ctx->dev->irqlock, flags); ctx->dev->curr_ctx =NULL ;
@@ -89,9 +87,7 @@ int venc_if_deinit(struct mtk_vcodec_enc_ctx *ctx)return 0 ;mtk_venc_lock (ctx); -mtk_vcodec_enc_clock_on (&ctx->dev->pm); ret = ctx->enc_if->deinit (ctx->drv_handle); -mtk_vcodec_enc_clock_off (&ctx->dev->pm);mtk_venc_unlock (ctx); ctx->drv_handle =NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 594/744 media: mediatek: vcodec: fix possible unbalanced PM counter
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugen Hristev <[email protected]>
[ Upstream commit c28d4921a1e3ce0a0374b7e9d68593be8802c42a ]
It is possible that mtk_vcodec_enc_pw_on fails, and in that scenario the PM counter is not incremented, and subsequent call to mtk_vcodec_enc_pw_off decrements the counter, leading to a PM imbalance. Fix by bailing out of venc_if_encode in the case when mtk_vcodec_enc_pw_on fails.
--- .../platform/mediatek/vcodec/encoder/mtk_vcodec_enc_pm.c | 4 +++- .../platform/mediatek/vcodec/encoder/mtk_vcodec_enc_pm.h | 2 +- drivers/media/platform/mediatek/vcodec/encoder/venc_drv_if.c | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-)
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_pm.c +3 -1
@@ -58,13 +58,15 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_enc_dev *mtkdev)return 0 ; } -void mtk_vcodec_enc_pw_on (struct mtk_vcodec_pm *pm) +int mtk_vcodec_enc_pw_on (struct mtk_vcodec_pm *pm) {int ret; ret =pm_runtime_resume_and_get (pm->dev);if (ret)dev_err (pm->dev,"pm_runtime_resume_and_get fail: %d" , ret); + +return ret; }void mtk_vcodec_enc_pw_off (struct mtk_vcodec_pm *pm)
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_pm.h +1 -1
@@ -10,7 +10,7 @@#include "mtk_vcodec_enc_drv.h" int mtk_vcodec_init_enc_clk (struct mtk_vcodec_enc_dev *dev); -void mtk_vcodec_enc_pw_on (struct mtk_vcodec_pm *pm); +int mtk_vcodec_enc_pw_on (struct mtk_vcodec_pm *pm);void mtk_vcodec_enc_pw_off (struct mtk_vcodec_pm *pm);void mtk_vcodec_enc_clock_on (struct mtk_vcodec_pm *pm);void mtk_vcodec_enc_clock_off (struct mtk_vcodec_pm *pm);
drivers/media/platform/mediatek/vcodec/encoder/venc_drv_if.c +4 -1
@@ -64,7 +64,9 @@ int venc_if_encode(struct mtk_vcodec_enc_ctx *ctx, ctx->dev->curr_ctx = ctx;spin_unlock_irqrestore (&ctx->dev->irqlock, flags); -mtk_vcodec_enc_pw_on (&ctx->dev->pm); + ret =mtk_vcodec_enc_pw_on (&ctx->dev->pm); +if (ret) + goto venc_if_encode_pw_on_err;mtk_vcodec_enc_clock_on (&ctx->dev->pm); ret = ctx->enc_if->encode (ctx->drv_handle, opt, frm_buf, bs_buf, result);
@@ -75,6 +77,7 @@ int venc_if_encode(struct mtk_vcodec_enc_ctx *ctx, ctx->dev->curr_ctx =NULL ;spin_unlock_irqrestore (&ctx->dev->irqlock, flags); +venc_if_encode_pw_on_err:mtk_venc_unlock (ctx);return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 595/744 tools/arch/x86/intel_sdsi: Fix maximum meter bundle length
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David E. Box <[email protected]>
[ Upstream commit a66f962f67ebbbdf7c82c6652180930c0169cf13 ]
The maximum number of bundles in the meter certificate was set to 8 which is much less than the maximum. Instead, since the bundles appear at the end of the file, set it based on the remaining file size from the bundle start position.
--- tools/arch/x86/intel_sdsi/intel_sdsi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
tools/arch/x86/intel_sdsi/intel_sdsi.c +8 -4
@@ -43,7 +43,6 @@#define METER_CERT_MAX_SIZE 4096#define STATE_MAX_NUM_LICENSES 16#define STATE_MAX_NUM_IN_BUNDLE (uint32_t)8 -#define METER_MAX_NUM_BUNDLES 8#define __round_mask (x, y) ((__typeof__(x))((y) - 1))#define round_up (x, y) ((((x) - 1) | __round_mask(x, y)) + 1)
@@ -167,6 +166,11 @@ struct bundle_encoding_counter {uint32_t encoding;uint32_t counter; }; +#define METER_BUNDLE_SIZE sizeof(struct bundle_encoding_counter) +#define BUNDLE_COUNT (length) ((length) / METER_BUNDLE_SIZE) +#define METER_MAX_NUM_BUNDLES \ + ((METER_CERT_MAX_SIZE - sizeof(struct meter_certificate)) / \ + sizeof(struct bundle_encoding_counter))struct sdsi_dev {struct sdsi_regs regs;
@@ -386,9 +390,9 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s)return -1 ; } -if (mc->bundle_length >METER_MAX_NUM_BUNDLES *8 ) { -fprintf (stderr,"More than %d bundles: %d\n" , -METER_MAX_NUM_BUNDLES , mc->bundle_length /8 ); +if (mc->bundle_length >METER_MAX_NUM_BUNDLES *METER_BUNDLE_SIZE ) { +fprintf (stderr,"More than %ld bundles: actual %ld\n" , +METER_MAX_NUM_BUNDLES ,BUNDLE_COUNT (mc->bundle_length));return -1 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 596/744 tools/arch/x86/intel_sdsi: Fix meter_show display
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David E. Box <[email protected]>
[ Upstream commit 76f2bc17428c890754d11aa6aea14b332ba130c5 ]
Fixes sdsi_meter_cert_show() to correctly decode and display the meter certificate output. Adds and displays a missing version field, displays the ASCII name of the signature, and fixes the print alignment.
--- tools/arch/x86/intel_sdsi/intel_sdsi.c | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-)
tools/arch/x86/intel_sdsi/intel_sdsi.c +19 -10
@@ -153,11 +153,12 @@ struct bundle_encoding { };struct meter_certificate { -uint32_t block_signature; -uint32_t counter_unit; +uint32_t signature; +uint32_t version;uint64_t ppin; +uint32_t counter_unit;uint32_t bundle_length; -uint32_t reserved; +uint64_t reserved;uint32_t mmrc_encoding;uint32_t mmrc_counter; };
@@ -338,6 +339,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s)uint32_t count =0 ;FILE *cert_ptr;int ret, size; +char name[4 ]; ret =sdsi_update_registers (s);if (ret)
@@ -379,12 +381,19 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s)printf ("\n" );printf ("Meter certificate for device %s\n" , s->dev_name);printf ("\n" ); -printf ("Block Signature: 0x%x\n" , mc->block_signature); -printf ("Count Unit: %dms\n" , mc->counter_unit); -printf ("PPIN: 0x%lx\n" , mc->ppin); -printf ("Feature Bundle Length: %d\n" , mc->bundle_length); -printf ("MMRC encoding: %d\n" , mc->mmrc_encoding); -printf ("MMRC counter: %d\n" , mc->mmrc_counter); + +get_feature (mc->signature, name); +printf ("Signature: %.4s\n" , name); + +printf ("Version: %d\n" , mc->version); +printf ("Count Unit: %dms\n" , mc->counter_unit); +printf ("PPIN: 0x%lx\n" , mc->ppin); +printf ("Feature Bundle Length: %d\n" , mc->bundle_length); + +get_feature (mc->mmrc_encoding, name); +printf ("MMRC encoding: %.4s\n" , name); + +printf ("MMRC counter: %d\n" , mc->mmrc_counter);if (mc->bundle_length %8 ) {fprintf (stderr,"Invalid bundle length\n" );return -1 ;
@@ -398,7 +407,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) bec = (void *)(mc) +sizeof (mc); -printf ("Number of Feature Counters: %d\n" , mc->bundle_length /8 ); +printf ("Number of Feature Counters: %ld\n" ,BUNDLE_COUNT (mc->bundle_length));while (count++ < mc->bundle_length /8 ) {char feature[5 ];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 597/744 tools/arch/x86/intel_sdsi: Fix meter_certificate decoding
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David E. Box <[email protected]>
[ Upstream commit 09d70ded6c566fd00886be32c26d0b2004ef239c ]
Fix errors in the calculation of the start position of the counters and in the display loop. While here, use a #define for the bundle count and size.
--- tools/arch/x86/intel_sdsi/intel_sdsi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/arch/x86/intel_sdsi/intel_sdsi.c +4 -3
@@ -394,7 +394,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s)printf ("MMRC encoding: %.4s\n" , name);printf ("MMRC counter: %d\n" , mc->mmrc_counter); -if (mc->bundle_length %8 ) { +if (mc->bundle_length %METER_BUNDLE_SIZE ) {fprintf (stderr,"Invalid bundle length\n" );return -1 ; }
@@ -405,15 +405,16 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s)return -1 ; } - bec = (void *)(mc) +sizeof (mc); + bec = (struct bundle_encoding_counter *)(mc +1 );printf ("Number of Feature Counters: %ld\n" ,BUNDLE_COUNT (mc->bundle_length)); -while (count++ < mc->bundle_length /8 ) { +while (count <BUNDLE_COUNT (mc->bundle_length)) {char feature[5 ]; feature[4 ] ='\0' ;get_feature (bec[count].encoding, feature);printf (" %s: %d\n" , feature, bec[count].counter); + ++count; }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 598/744 platform/x86: thinkpad_acpi: Take hotkey_mutex during hotkey_exit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit e397c564298c2e91aea3887990da8e8eddb65277 ]
hotkey_exit() already takes the mutex around the hotkey_poll_stop_sync() call, but not around the other calls.
commit 38831eaf7d4c ("platform/x86: thinkpad_acpi: use lockdep annotations") has added lockdep_assert_held() checks to various hotkey functions.
These lockdep_assert_held() checks fail causing WARN() backtraces in dmesg due to missing locking in hotkey_exit(), fix this.
--- drivers/platform/x86/thinkpad_acpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +3 -2
@@ -3042,10 +3042,9 @@ static void tpacpi_send_radiosw_update(void)static void hotkey_exit (void ) { -#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL mutex_lock (&hotkey_mutex); +#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL hotkey_poll_stop_sync (); -mutex_unlock (&hotkey_mutex);#endif dbg_printk (TPACPI_DBG_EXIT |TPACPI_DBG_HKEY ,"restoring original HKEY status and mask\n" );
@@ -3055,6 +3054,8 @@ static void hotkey_exit(void) hotkey_mask_set(hotkey_orig_mask)) | hotkey_status_set(false)) != 0)pr_err ("failed to restore hot key mask to BIOS defaults\n" ); + +mutex_unlock (&hotkey_mutex); }static void __init hotkey_unmap (const unsigned int scancode)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 599/744 media: flexcop-usb: fix sanity check of bNumEndpoints
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dongliang Mu <[email protected]>
[ Upstream commit f62dc8f6bf82d1b307fc37d8d22cc79f67856c2f ]
Commit d725d20e81c2 ("media: flexcop-usb: sanity checking of endpoint type ") adds a sanity check for endpoint[1], but fails to modify the sanity check of bNumEndpoints.
Fix this by modifying the sanity check of bNumEndpoints to 2.
--- drivers/media/usb/b2c2/flexcop-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/b2c2/flexcop-usb.c +1 -1
@@ -515,7 +515,7 @@ static int flexcop_usb_init(struct flexcop_usb *fc_usb) alt = fc_usb->uintf->cur_altsetting; -if (alt->desc.bNumEndpoints <1 ) +if (alt->desc.bNumEndpoints <2 )return -ENODEV ;if (!usb_endpoint_is_isoc_in (&alt->endpoint[0 ].desc))return -ENODEV ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 600/744 powerpc/pseries: Add failure related checks for h_get_mpp and h_get_ppp
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shrikanth Hegde <[email protected]>
[ Upstream commit 6d4341638516bf97b9a34947e0bd95035a8230a5 ]
Couple of Minor fixes:
- hcall return values are long. Fix that for h_get_mpp, h_get_ppp and parse_ppp_data
- If hcall fails, values set should be at-least zero. It shouldn't be uninitialized values. Fix that for h_get_mpp and h_get_ppp
--- arch/powerpc/include/asm/hvcall.h | 2 +- arch/powerpc/platforms/pseries/lpar.c | 6 +++--- arch/powerpc/platforms/pseries/lparcfg.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/hvcall.h +1 -1
@@ -540,7 +540,7 @@ struct hvcall_mpp_data {unsigned long backing_mem; }; -int h_get_mpp (struct hvcall_mpp_data *); +long h_get_mpp (struct hvcall_mpp_data *mpp_data);struct hvcall_mpp_x_data {unsigned long coalesced_bytes;
arch/powerpc/platforms/pseries/lpar.c +3 -3
@@ -1886,10 +1886,10 @@ notrace void __trace_hcall_exit(long opcode, long retval, unsigned long *retbuf)* h_get_mpp * H_GET_MPP hcall returns info in 7 parms */ -int h_get_mpp (struct hvcall_mpp_data *mpp_data) +long h_get_mpp (struct hvcall_mpp_data *mpp_data) { -int rc; -unsigned long retbuf[PLPAR_HCALL9_BUFSIZE ]; +unsigned long retbuf[PLPAR_HCALL9_BUFSIZE ] = {0 }; +long rc; rc =plpar_hcall9 (H_GET_MPP , retbuf);
arch/powerpc/platforms/pseries/lparcfg.c +3 -3
@@ -113,8 +113,8 @@ struct hvcall_ppp_data {*/ static unsigned int h_get_ppp (struct hvcall_ppp_data *ppp_data) { -unsigned long rc; -unsigned long retbuf[PLPAR_HCALL9_BUFSIZE ]; +unsigned long retbuf[PLPAR_HCALL9_BUFSIZE ] = {0 }; +long rc; rc =plpar_hcall9 (H_GET_PPP , retbuf);
@@ -193,7 +193,7 @@ static void parse_ppp_data(struct seq_file *m)struct hvcall_ppp_data ppp_data;struct device_node *root;const __be32 *perf_level; -int rc; +long rc; rc =h_get_ppp (&ppp_data);if (rc)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 601/744 um: Fix the -Wmissing-prototypes warning for __switch_mm
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiwei Bie <[email protected]>
[ Upstream commit 2cbade17b18c0f0fd9963f26c9fc9b057eb1cb3a ]
The __switch_mm function is defined in the user code, and is called by the kernel code. It should be declared in a shared header.
--- arch/um/include/asm/mmu.h | 2 -- arch/um/include/shared/skas/mm_id.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
arch/um/include/asm/mmu.h +0 -2
@@ -15,8 +15,6 @@ typedef struct mm_context {struct page *stub_pages[2 ]; } mm_context_t; -extern void __switch_mm (struct mm_id * mm_idp); -/* Avoid tangled inclusion with asm/ldt.h */ extern long init_new_ldt (struct mm_context *to_mm,struct mm_context *from_mm);extern void free_ldt (struct mm_context *mm);
arch/um/include/shared/skas/mm_id.h +2 -0
@@ -15,4 +15,6 @@ struct mm_id { int kill; }; +void __switch_mm (struct mm_id *mm_idp); +#endif
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 602/744 um: Fix the -Wmissing-prototypes warning for get_thread_reg
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiwei Bie <[email protected]>
[ Upstream commit 3144013e48f4f6e5127223c4ebc488016815dedb ]
The get_thread_reg function is defined in the user code, and is called by the kernel code. It should be declared in a shared header.
--- arch/um/include/asm/processor-generic.h | 1 - arch/x86/um/shared/sysdep/archsetjmp.h | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
arch/um/include/asm/processor-generic.h +0 -1
@@ -95,7 +95,6 @@ extern struct cpuinfo_um boot_cpu_data;#define current_cpu_data boot_cpu_data#define cache_line_size () (boot_cpu_data.cache_alignment) -extern unsigned long get_thread_reg (int reg,jmp_buf *buf);#define KSTK_REG (tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf)extern unsigned long __get_wchan (struct task_struct *p);
arch/x86/um/shared/sysdep/archsetjmp.h +7 -0
@@ -1,6 +1,13 @@/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __X86_UM_SYSDEP_ARCHSETJMP_H +#define __X86_UM_SYSDEP_ARCHSETJMP_H +#ifdef __i386__#include "archsetjmp_32.h" #else #include "archsetjmp_64.h" #endif + +unsigned long get_thread_reg (int reg,jmp_buf *buf); + +#endif /* __X86_UM_SYSDEP_ARCHSETJMP_H */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 603/744 um: Fix the declaration of kasan_map_memory
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiwei Bie <[email protected]>
[ Upstream commit 6a85e34c4d07d2ec0c153067baff338ac0db55ca ]
Make it match its definition (size_t vs unsigned long). And declare it in a shared header to fix the -Wmissing-prototypes warning, as it is defined in the user code and called in the kernel code.
--- arch/um/include/asm/kasan.h | 1 - arch/um/include/shared/kern_util.h | 2 ++ arch/um/os-Linux/mem.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
arch/um/include/asm/kasan.h +0 -1
@@ -24,7 +24,6 @@#ifdef CONFIG_KASAN void kasan_init (void ); -void kasan_map_memory (void *start,unsigned long len);extern int kasan_um_is_ready;#ifdef CONFIG_STATIC_LINK
arch/um/include/shared/kern_util.h +2 -0
@@ -67,4 +67,6 @@ extern void fatal_sigsegv(void) __attribute__ ((noreturn));void um_idle_sleep (void ); +void kasan_map_memory (void *start,size_t len); +#endif
arch/um/os-Linux/mem.c +1 -0
@@ -15,6 +15,7 @@#include <sys/vfs.h> #include <linux/magic.h> #include <init.h> +#include <kern_util.h> #include <os.h> /*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 604/744 cxl/trace: Correct DPA field masks for general_media & dram events
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 2042d11cb57b7e0cbda7910e5ff80e9e8bf0ae17 ]
The length of Physical Address in General Media and DRAM event records is 64-bit, so the field mask for extracting the DPA should be 64-bit also, otherwise the trace event reports DPA's with the upper 32 bits of a DPA address masked off. If users do DPA-to-HPA translations this could lead to incorrect page retirement decisions.
Use GENMASK_ULL() for CXL_DPA_MASK to get all the DPA address bits.
Tidy up CXL_DPA_FLAGS_MASK by using GENMASK() to only mask the exact flag bits.
These bits are defined as part of the event record physical address descriptions of General Media and DRAM events in CXL Spec 3.1 Section 8.2.9.2 Events.
--- drivers/cxl/core/trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cxl/core/trace.h +2 -2
@@ -252,8 +252,8 @@ TRACE_EVENT(cxl_generic_event,* DRAM Event Record * CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 */ -#define CXL_DPA_FLAGS_MASK 0x3F -#define CXL_DPA_MASK (~CXL_DPA_FLAGS_MASK) +#define CXL_DPA_FLAGS_MASK GENMASK(1, 0) +#define CXL_DPA_MASK GENMASK_ULL(63, 6)#define CXL_DPA_VOLATILE BIT(0)#define CXL_DPA_NOT_REPAIRABLE BIT(1)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 605/744 cxl/region: Fix cxlr_pmem leaks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Zhijian <[email protected]>
[ Upstream commit 1c987cf22d6b65ade46145c03eef13f0e3e81d83 ]
Before this error path, cxlr_pmem pointed to a kzalloc() memory, free it to avoid this memory leaking.
--- drivers/cxl/core/region.c | 1 + 1 file changed, 1 insertion(+)
drivers/cxl/core/region.c +1 -0
@@ -2549,6 +2549,7 @@ static struct cxl_pmem_region *cxl_pmem_region_alloc(struct cxl_region *cxlr)if (i ==0 ) { cxl_nvb =cxl_find_nvdimm_bridge (cxlmd);if (!cxl_nvb) { +kfree (cxlr_pmem); cxlr_pmem =ERR_PTR (-ENODEV ); goto out; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 606/744 media: sunxi: a83-mips-csi2: also select GENERIC_PHY
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 8237026159cb6760ad22e28d57b9a1c53b612d3a ]
When selecting GENERIC_PHY_MIPI_DPHY, also select GENERIC_PHY to prevent kconfig warnings:
WARNING: unmet direct dependencies detected for GENERIC_PHY_MIPI_DPHY
Depends on [n]: GENERIC_PHY [=n]
Selected by [y]:
- VIDEO_SUN8I_A83T_MIPI_CSI2 [=y] && MEDIA_SUPPORT [=y] && MEDIA_PLATFORM_SUPPORT [=y] && MEDIA_PLATFORM_DRIVERS [=y] && V4L_PLATFORM_DRIVERS [=y] && VIDEO_DEV [=y] && (ARCH_SUNXI || COMPILE_TEST [=y]) && PM [=y] && COMMON_CLK [=y] && RESET_CONTROLLER [=y]
--- drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Kconfig +1 -0
@@ -8,6 +8,7 @@ config VIDEO_SUN8I_A83T_MIPI_CSI2 select VIDEO_V4L2_SUBDEV_API select V4L2_FWNODE select REGMAP_MMIO + select GENERIC_PHY select GENERIC_PHY_MIPI_DPHY help Support for the Allwinner A83T MIPI CSI-2 controller and D-PHY.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 607/744 media: cec: cec-adap: always cancel work in cec_transmit_msg_fh
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 9fe2816816a3c765dff3b88af5b5c3d9bbb911ce ]
Do not check for !data->completed, just always call cancel_delayed_work_sync(). This fixes a small race condition.
--- drivers/media/cec/core/cec-adap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/cec/core/cec-adap.c +1 -2
@@ -909,8 +909,7 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,*/ mutex_unlock (&adap->lock);wait_for_completion_killable (&data->c); -if (!data->completed) -cancel_delayed_work_sync (&data->work); +cancel_delayed_work_sync (&data->work);mutex_lock (&adap->lock);/* Cancel the transmit if it was interrupted */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 608/744 media: cec: cec-api: add locking in cec_release()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 42bcaacae924bf18ae387c3f78c202df0b739292 ]
When cec_release() uses fh->msgs it has to take fh->lock, otherwise the list can get corrupted.
--- drivers/media/cec/core/cec-api.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/cec/core/cec-api.c +3 -0
@@ -664,6 +664,8 @@ static int cec_release(struct inode *inode, struct file *filp)list_del_init (&data->xfer_list); }mutex_unlock (&adap->lock); + +mutex_lock (&fh->lock);while (!list_empty (&fh->msgs)) {struct cec_msg_entry *entry = list_first_entry(&fh->msgs, struct cec_msg_entry, list);
@@ -681,6 +683,7 @@ static int cec_release(struct inode *inode, struct file *filp)kfree (entry); } } +mutex_unlock (&fh->lock);kfree (fh);cec_put_device (devnode);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 609/744 media: cec: core: avoid recursive cec_claim_log_addrs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 47c82aac10a6954d68f29f10d9758d016e8e5af1 ]
Keep track if cec_claim_log_addrs() is running, and return -EBUSY if it is when calling CEC_ADAP_S_LOG_ADDRS.
This prevents a case where cec_claim_log_addrs() could be called while it was still in progress.
--- drivers/media/cec/core/cec-adap.c | 6 +++++- drivers/media/cec/core/cec-api.c | 2 +- include/media/cec.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/media/cec/core/cec-adap.c +5 -1
@@ -1547,9 +1547,12 @@ static int cec_config_thread_func(void *arg)*/ static void cec_claim_log_addrs (struct cec_adapter *adap,bool block) { -if (WARN_ON (adap->is_configuring || adap->is_configured)) +if (WARN_ON (adap->is_claiming_log_addrs || + adap->is_configuring || adap->is_configured))return ; + adap->is_claiming_log_addrs = true; +init_completion (&adap->config_completion);/* Ready to kick off the thread */
@@ -1564,6 +1567,7 @@ static void cec_claim_log_addrs(struct cec_adapter *adap, bool block)wait_for_completion (&adap->config_completion);mutex_lock (&adap->lock); } + adap->is_claiming_log_addrs = false; }/*
drivers/media/cec/core/cec-api.c +1 -1
@@ -178,7 +178,7 @@ static long cec_adap_s_log_addrs(struct cec_adapter *adap, struct cec_fh *fh,CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU |CEC_LOG_ADDRS_FL_CDC_ONLY ;mutex_lock (&adap->lock); -if (!adap->is_configuring && +if (!adap->is_claiming_log_addrs && !adap->is_configuring && (!log_addrs.num_log_addrs || !adap->is_configured) && !cec_is_busy (adap, fh)) { err =__cec_s_log_addrs (adap, &log_addrs, block);
include/media/cec.h +1 -0
@@ -247,6 +247,7 @@ struct cec_adapter {u16 phys_addr;bool needs_hpd;bool is_enabled; +bool is_claiming_log_addrs;bool is_configuring;bool must_reconfigure;bool is_configured;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 610/744 media: cec: core: avoid confusing "transmit timed out" message
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit cbe499977bc36fedae89f0a0d7deb4ccde9798fe ]
If, when waiting for a transmit to finish, the wait is interrupted, then you might get a "transmit timed out" message, even though the transmit was interrupted and did not actually time out.
Set transmit_in_progress_aborted to true if the wait_for_completion_killable() call was interrupted and ensure that the transmit is properly marked as ABORTED.
--- drivers/media/cec/core/cec-adap.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/media/cec/core/cec-adap.c +14 -1
@@ -490,6 +490,15 @@ int cec_thread_func(void *_adap) goto unlock; } +if (adap->transmit_in_progress && + adap->transmit_in_progress_aborted) { +if (adap->transmitting) +cec_data_cancel (adap->transmitting, +CEC_TX_STATUS_ABORTED ,0 ); + adap->transmit_in_progress = false; + adap->transmit_in_progress_aborted = false; + goto unlock; + }if (adap->transmit_in_progress && timeout) {/* * If we timeout, then log that. Normally this does
@@ -744,6 +753,7 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, {struct cec_data *data;bool is_raw =msg_is_raw (msg); +int err;if (adap->devnode.unregistered)return -ENODEV ;
@@ -908,10 +918,13 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,* Release the lock and wait, retake the lock afterwards. */ mutex_unlock (&adap->lock); -wait_for_completion_killable (&data->c); + err =wait_for_completion_killable (&data->c);cancel_delayed_work_sync (&data->work);mutex_lock (&adap->lock); +if (err) + adap->transmit_in_progress_aborted = true; +/* Cancel the transmit if it was interrupted */ if (!data->completed) {if (data->msg.tx_status &CEC_TX_STATUS_OK )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 611/744 Revert "drm/bridge: ti-sn65dsi83: Fix enable error path"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
[ Upstream commit ad81feb5b6f1f5461641706376dcf7a9914ed2e7 ]
This reverts commit 8a91b29f1f50ce7742cdbe5cf11d17f128511f3f.
The regulator_disable() added by the original commit solves one kind of regulator imbalance but adds another one as it allows the regulator to be disabled one more time than it is enabled in the following scenario:
1. Start video pipeline -> sn65dsi83_atomic_pre_enable -> regulator_enable
2. PLL lock fails -> regulator_disable
3. Stop video pipeline -> sn65dsi83_atomic_disable -> regulator_disable
The reason is clear from the code flow, which looks like this (after removing unrelated code):
static void sn65dsi83_atomic_pre_enable()
{
regulator_enable(ctx->vcc); if (PLL failed locking) {
regulator_disable(ctx->vcc); <---- added by patch being reverted
return;
}}
static void sn65dsi83_atomic_disable()
{
regulator_disable(ctx->vcc);
}The use case for introducing the additional regulator_disable() was removing the module for debugging (see link below for the discussion). If the module is removed after a .atomic_pre_enable, i.e. with an active pipeline from the DRM point of view, .atomic_disable is not called and thus the regulator would not be disabled.
According to the discussion however there is no actual use case for removing the module with an active pipeline, except for debugging/development.
On the other hand, the occurrence of a PLL lock failure is possible due to any physical reason (e.g. a temporary hardware failure for electrical reasons) so handling it gracefully should be supported. As there is no way for .atomic[_pre]_enable to report an error to the core, the only clean way to support it is calling regulator_disabled() only in .atomic_disable, unconditionally, as it was before.
--- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +0 -1
@@ -478,7 +478,6 @@ static void sn65dsi83_atomic_pre_enable(struct drm_bridge *bridge,dev_err (ctx->dev,"failed to lock PLL, ret=%i\n" , ret);/* On failure, disable PLL again and exit. */ regmap_write (ctx->regmap,REG_RC_PLL_EN ,0x00 ); -regulator_disable (ctx->vcc);return ; }
Signature · 1 line
2.43.0