clk: jz4740: Add TCU clock
Subsystems (7)
Sasha Levin
maintainerPATCH 1/9 clk: jz4740: Add TCU clock
From: Paul Cercueil <[email protected]>
[ Upstream commit 73dd11dc1a883d4c994d729dc9984f4890001157 ]
Add the missing TCU clock to the list of clocks supplied by the CGU for the JZ4740 SoC.
--- drivers/clk/ingenic/jz4740-cgu.c | 6 ++++++ include/dt-bindings/clock/jz4740-cgu.h | 1 + 2 files changed, 7 insertions(+)
drivers/clk/ingenic/jz4740-cgu.c +6 -0
@@ -211,6 +211,12 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = { .parents = { JZ4740_CLK_EXT, -1, -1, -1 }, .gate = { CGU_REG_CLKGR, 5 }, }, + + [JZ4740_CLK_TCU] = { +"tcu" ,CGU_CLK_GATE , + .parents = { JZ4740_CLK_EXT, -1, -1, -1 }, + .gate = { CGU_REG_CLKGR, 1 }, + }, };static void __init jz4740_cgu_init (struct device_node *np)
include/dt-bindings/clock/jz4740-cgu.h +1 -0
@@ -33,5 +33,6 @@#define JZ4740_CLK_ADC 19#define JZ4740_CLK_I2C 20#define JZ4740_CLK_AIC 21 +#define JZ4740_CLK_TCU 22#endif /* __DT_BINDINGS_CLOCK_JZ4740_CGU_H__ */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/9 HID: apple: Fix stuck function keys when using FN
From: Joao Moreno <[email protected]>
[ Upstream commit aec256d0ecd561036f188dbc8fa7924c47a9edfd ]
This fixes an issue in which key down events for function keys would be repeatedly emitted even after the user has raised the physical key. For example, the driver fails to emit the F5 key up event when going through the following steps:
- fnmode=1: hold FN, hold F5, release FN, release F5
- fnmode=2: hold F5, hold FN, release F5, release FN
The repeated F5 key down events can be easily verified using xev.
--- drivers/hid/hid-apple.c | 49 +++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-)
drivers/hid/hid-apple.c +28 -21
@@ -55,7 +55,6 @@ MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\")struct apple_sc {unsigned long quirks;unsigned int fn_on; - DECLARE_BITMAP(pressed_fn, KEY_CNT); DECLARE_BITMAP(pressed_numlock, KEY_CNT); };
@@ -182,6 +181,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, {struct apple_sc *asc =hid_get_drvdata (hid);const struct apple_key_translation *trans, *table; +bool do_translate; +u16 code =0 ;if (usage->code ==KEY_FN ) { asc->fn_on = !!value;
@@ -190,8 +191,6 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, }if (fnmode) { -int do_translate; -if (hid->product >=USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && hid->product <=USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS ) table = macbookair_fn_keys;
@@ -203,25 +202,33 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, trans =apple_find_translation (table, usage->code);if (trans) { -if (test_bit (usage->code, asc->pressed_fn)) - do_translate =1 ; -else if (trans->flags &APPLE_FLAG_FKEY ) - do_translate = (fnmode ==2 && asc->fn_on) || - (fnmode ==1 && !asc->fn_on); -else - do_translate = asc->fn_on; - -if (do_translate) { -if (value) -set_bit (usage->code, asc->pressed_fn); -else -clear_bit (usage->code, asc->pressed_fn); - -input_event (input, usage->type, trans->to, - value); - -return 1 ; +if (test_bit (trans->from, input->key)) + code = trans->from; +else if (test_bit (trans->to, input->key)) + code = trans->to; + +if (!code) { +if (trans->flags &APPLE_FLAG_FKEY ) { +switch (fnmode) { +case 1 : + do_translate = !asc->fn_on; +break ; +case 2 : + do_translate = asc->fn_on; +break ; +default : +/* should never happen */ + do_translate = false; + } + }else { + do_translate = asc->fn_on; + } + + code = do_translate ? trans->to : trans->from; } + +input_event (input, usage->type, code, value); +return 1 ; } if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/9 ARM: 8898/1: mm: Don't treat faults reported from cache maintenance as writes
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit 834020366da9ab3fb87d1eb9a3160eb22dbed63a ]
Translation faults arising from cache maintenance instructions are rather unhelpfully reported with an FSR value where the WnR field is set to 1, indicating that the faulting access was a write. Since cache maintenance instructions on 32-bit ARM do not require any particular permissions, this can cause our private 'cacheflush' system call to fail spuriously if a translation fault is generated due to page aging when targetting a read-only VMA.
In this situation, we will return -EFAULT to userspace, although this is unfortunately suppressed by the popular '__builtin___clear_cache()' intrinsic provided by GCC, which returns void.
Although it's tempting to write this off as a userspace issue, we can actually do a little bit better on CPUs that support LPAE, even if the short-descriptor format is in use. On these CPUs, cache maintenance faults additionally set the CM field in the FSR, which we can use to suppress the write permission checks in the page fault handler and succeed in performing cache maintenance to read-only areas even in the presence of a translation fault.
--- arch/arm/mm/fault.c | 4 ++-- arch/arm/mm/fault.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/mm/fault.c +2 -2
@@ -211,7 +211,7 @@ static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma) {unsigned int mask =VM_READ |VM_WRITE |VM_EXEC ; -if (fsr &FSR_WRITE ) +if ((fsr &FSR_WRITE ) && !(fsr &FSR_CM )) mask =VM_WRITE ;if (fsr &FSR_LNX_PF ) mask =VM_EXEC ;
@@ -281,7 +281,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)if (user_mode (regs)) flags |=FAULT_FLAG_USER ; -if (fsr &FSR_WRITE ) +if ((fsr &FSR_WRITE ) && !(fsr &FSR_CM )) flags |=FAULT_FLAG_WRITE ;/*
arch/arm/mm/fault.h +1 -0
@@ -5,6 +5,7 @@* Fault status register encodings. We steal bit 31 for our own purposes. */ #define FSR_LNX_PF (1 << 31) +#define FSR_CM (1 << 13)#define FSR_WRITE (1 << 11)#define FSR_FS4 (1 << 10)#define FSR_FS3_0 (15)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/9 fat: work around race with userspace's read via blockdev while mounting
In reply to Sasha LevinFrom: OGAWA Hirofumi <[email protected]>
[ Upstream commit 07bfa4415ab607e459b69bd86aa7e7602ce10b4f ]
If userspace reads the buffer via blockdev while mounting, sb_getblk()+modify can race with buffer read via blockdev.
For example,
FS userspace
bh = sb_getblk()
modify bh->b_data
read
ll_rw_block(bh)
fill bh->b_data by on-disk data
/* lost modified data by FS */
set_buffer_uptodate(bh)
set_buffer_uptodate(bh)Userspace should not use the blockdev while mounting though, the udev seems to be already doing this. Although I think the udev should try to avoid this, workaround the race by small overhead.
--- fs/fat/dir.c | 13 +++++++++++-- fs/fat/fatent.c | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-)
fs/fat/dir.c +11 -2
@@ -1097,8 +1097,11 @@ static int fat_zeroed_cluster(struct inode *dir, sector_t blknr, int nr_used, err = -ENOMEM ; goto error; } +/* Avoid race with userspace read via bdev */ +lock_buffer (bhs[n]);memset (bhs[n]->b_data,0 , sb->s_blocksize);set_buffer_uptodate (bhs[n]); +unlock_buffer (bhs[n]);mark_buffer_dirty_inode (bhs[n], dir); n++;
@@ -1155,6 +1158,8 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec *ts)fat_time_unix2fat (sbi, ts, &time, &date, &time_cs); de = (struct msdos_dir_entry *)bhs[0 ]->b_data; +/* Avoid race with userspace read via bdev */ +lock_buffer (bhs[0 ]);/* filling the new directory slots ("." and ".." entries) */ memcpy (de[0 ].name,MSDOS_DOT ,MSDOS_NAME );memcpy (de[1 ].name,MSDOS_DOTDOT ,MSDOS_NAME );
@@ -1177,6 +1182,7 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec *ts) de[0 ].size = de[1 ].size =0 ;memset (de +2 ,0 , sb->s_blocksize -2 *sizeof (*de));set_buffer_uptodate (bhs[0 ]); +unlock_buffer (bhs[0 ]);mark_buffer_dirty_inode (bhs[0 ], dir); err =fat_zeroed_cluster (dir, blknr,1 , bhs,MAX_BUF_PER_PAGE );
@@ -1234,11 +1240,14 @@ static int fat_add_new_entries(struct inode *dir, void *slots, int nr_slots,/* fill the directory entry */ copy =min (size, sb->s_blocksize); +/* Avoid race with userspace read via bdev */ +lock_buffer (bhs[n]);memcpy (bhs[n]->b_data, slots, copy); - slots += copy; - size -= copy;set_buffer_uptodate (bhs[n]); +unlock_buffer (bhs[n]);mark_buffer_dirty_inode (bhs[n], dir); + slots += copy; + size -= copy;if (!size)break ; n++;
fs/fat/fatent.c +3 -0
@@ -389,8 +389,11 @@ static int fat_mirror_bhs(struct super_block *sb, struct buffer_head **bhs, err = -ENOMEM ; goto error; } +/* Avoid race with userspace read via bdev */ +lock_buffer (c_bh);memcpy (c_bh->b_data, bhs[n]->b_data, sb->s_blocksize);set_buffer_uptodate (c_bh); +unlock_buffer (c_bh);mark_buffer_dirty_inode (c_bh, sbi->fat_inode);if (sb->s_flags &MS_SYNCHRONOUS ) err =sync_dirty_buffer (c_bh);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/9 hypfs: Fix error number left in struct pointer member
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit b54c64f7adeb241423cd46598f458b5486b0375e ]
In hypfs_fill_super(), if hypfs_create_update_file() fails, sbi->update_file is left holding an error number. This is passed to hypfs_kill_super() which doesn't check for this.
Fix this by not setting sbi->update_value until after we've checked for error.
--- arch/s390/hypfs/inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/s390/hypfs/inode.c +5 -4
@@ -267,7 +267,7 @@ static int hypfs_show_options(struct seq_file *s, struct dentry *root)static int hypfs_fill_super (struct super_block *sb,void *data,int silent) {struct inode *root_inode; -struct dentry *root_dentry; +struct dentry *root_dentry, *update_file;int rc =0 ;struct hypfs_sb_info *sbi;
@@ -298,9 +298,10 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent) rc =hypfs_diag_create_files (root_dentry);if (rc)return rc; - sbi->update_file =hypfs_create_update_file (root_dentry); -if (IS_ERR (sbi->update_file)) -return PTR_ERR (sbi->update_file); + update_file =hypfs_create_update_file (root_dentry); +if (IS_ERR (update_file)) +return PTR_ERR (update_file); + sbi->update_file = update_file;hypfs_update_update (sb);pr_info ("Hypervisor filesystem mounted\n" );return 0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/9 ocfs2: wait for recovering done after direct unlock request
In reply to Sasha LevinFrom: Changwei Ge <[email protected]>
[ Upstream commit 0a3775e4f883912944481cf2ef36eb6383a9cc74 ]
There is a scenario causing ocfs2 umount hang when multiple hosts are rebooting at the same time.
NODE1 NODE2 NODE3
send unlock requset to NODE2
dies
become recovery master recover NODE2
find NODE2 dead
mark resource RECOVERING
directly remove lock from grant list
calculate usage but RECOVERING marked
**miss the window of purging
clear RECOVERING
To reproduce this issue, crash a host and then umount ocfs2 from another node.
To solve this, just let unlock progress wait for recovery done.
--- fs/ocfs2/dlm/dlmunlock.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
fs/ocfs2/dlm/dlmunlock.c +19 -4
@@ -105,7 +105,8 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,enum dlm_status status;int actions =0 ;int in_use; -u8 owner; +u8 owner; +int recovery_wait =0 ;mlog (0 ,"master_node = %d, valblk = %d\n" , master_node, flags &LKM_VALBLK );
@@ -208,9 +209,12 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, }if (flags &LKM_CANCEL ) lock->cancel_pending =0 ; -else - lock->unlock_pending =0 ; - +else { +if (!lock->unlock_pending) + recovery_wait =1 ; +else + lock->unlock_pending =0 ; + } }/* get an extra ref on lock. if we are just switching
@@ -244,6 +248,17 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,spin_unlock (&res->spinlock);wake_up (&res->wq); +if (recovery_wait) { +spin_lock (&res->spinlock); +/* Unlock request will directly succeed after owner dies, +* and the lock is already removed from grant list. We have to +* wait for RECOVERING done or we miss the chance to purge it +* since the removement is much faster than RECOVERING proc. +*/ +__dlm_wait_on_lockres_flags (res,DLM_LOCK_RES_RECOVERING ); +spin_unlock (&res->spinlock); + } +/* let the caller's final dlm_lock_put handle the actual kfree */ if (actions &DLM_UNLOCK_FREE_LOCK ) {/* this should always be coupled with list removal */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/9 kmemleak: increase DEBUG_KMEMLEAK_EARLY_LOG_SIZE default to 16K
In reply to Sasha LevinFrom: Nicolas Boichat <[email protected]>
[ Upstream commit b751c52bb587ae66f773b15204ef7a147467f4c7 ]
The current default value (400) is too low on many systems (e.g. some ARM64 platform takes up 1000+ entries).
syzbot uses 16000 as default value, and has proved to be enough on beefy configurations, so let's pick that value.
This consumes more RAM on boot (each entry is 160 bytes, so in total ~2.5MB of RAM), but the memory would later be freed (early_log is __initdata).
--- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
@@ -521,7 +521,7 @@ config DEBUG_KMEMLEAK_EARLY_LOG_SIZE int "Maximum kmemleak early log entries" depends on DEBUG_KMEMLEAK range 200 40000 - default 400 + default 16000 help Kmemleak must track all the memory allocations to avoid reporting false positives. Since memory may be allocated or
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/9 security: smack: Fix possible null-pointer dereferences in smack_socket_sock_rcv_skb()
In reply to Sasha LevinFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit 3f4287e7d98a2954f20bf96c567fdffcd2b63eb9 ]
In smack_socket_sock_rcv_skb(), there is an if statement on line 3920 to check whether skb is NULL:
if (skb && skb->secmark != 0)
This check indicates skb can be NULL in some cases.
But on lines 3931 and 3932, skb is used:
ad.a.u.net->netif = skb->skb_iif;
ipv6_skb_to_auditdata(skb, &ad.a, NULL);Thus, possible null-pointer dereferences may occur when skb is NULL.
To fix these possible bugs, an if statement is added to check skb.
These bugs are found by a static analysis tool STCheck written by us.
--- security/smack/smack_lsm.c | 2 ++ 1 file changed, 2 insertions(+)
security/smack/smack_lsm.c +2 -0
@@ -3986,6 +3986,8 @@ static int smack_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) skp =smack_ipv6host_label (&sadd);if (skp ==NULL ) skp = smack_net_ambient; +if (skb ==NULL ) +break ;#ifdef CONFIG_AUDIT smk_ad_init_net (&ad, __func__,LSM_AUDIT_DATA_NET , &net); ad.a.u.net->family = sk->sk_family;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/9 mfd: intel-lpss: Remove D3cold delay
In reply to Sasha LevinFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit 76380a607ba0b28627c9b4b55cd47a079a59624b ]
Goodix touchpad may drop its first couple input events when i2c-designware-platdrv and intel-lpss it connects to took too long to runtime resume from runtime suspended state.
This issue happens becuase the touchpad has a rather small buffer to store up to 13 input events, so if the host doesn't read those events in time (i.e. runtime resume takes too long), events are dropped from the touchpad's buffer.
The bottleneck is D3cold delay it waits when transitioning from D3cold to D0, hence remove the delay to make the resume faster. I've tested some systems with intel-lpss and haven't seen any regression.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202683
--- drivers/mfd/intel-lpss-pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/intel-lpss-pci.c +2 -0
@@ -38,6 +38,8 @@ static int intel_lpss_pci_probe(struct pci_dev *pdev, info->mem = &pdev->resource[0 ]; info->irq = pdev->irq; + pdev->d3cold_delay =0 ; +/* Probably it is enough to set this for iDMA capable devices only */ pci_set_master (pdev);
Signature · 1 line
2.20.1