5.4.75-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 122/214 btrfs: qgroup: fix wrong qgroup metadata reserve for delayed inode
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit b4c5d8fdfff3e2b6c4fa4a5043e8946dff500f8c upstream.
For delayed inode facility, qgroup metadata is reserved for it, and later freed.
However we're freeing more bytes than we reserved. In btrfs_delayed_inode_reserve_metadata():
num_bytes = btrfs_calc_metadata_size(fs_info, 1);
...
ret = btrfs_qgroup_reserve_meta_prealloc(root,
fs_info->nodesize, true);
...
if (!ret) {
node->bytes_reserved = num_bytes;But in btrfs_delayed_inode_release_metadata():
if (qgroup_free) btrfs_qgroup_free_meta_prealloc(node->root, node->bytes_reserved); else btrfs_qgroup_convert_reserved_meta(node->root, node->bytes_reserved);
This means, we're always releasing more qgroup metadata rsv than we have reserved.
This won't trigger selftest warning, as btrfs qgroup metadata rsv has extra protection against cases like quota enabled half-way.
But we still need to fix this problem any way.
This patch will use the same num_bytes for qgroup metadata rsv so we could handle it correctly.
--- fs/btrfs/delayed-inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/delayed-inode.c +1 -2
@@ -627,8 +627,7 @@ static int btrfs_delayed_inode_reserve_m*/ if (!src_rsv || (!trans->bytes_reserved && src_rsv->type !=BTRFS_BLOCK_RSV_DELALLOC )) { - ret =btrfs_qgroup_reserve_meta_prealloc (root, - fs_info->nodesize, true); + ret =btrfs_qgroup_reserve_meta_prealloc (root, num_bytes, true);if (ret <0 )return ret; ret = btrfs_block_rsv_add(root, dst_rsv, num_bytes,
Greg Kroah-Hartman
maintainerPATCH 71/214 drm/amd/display: HDMI remote sink need mode validation for Linux
In reply to Greg Kroah-HartmanFrom: Fangzhi Zuo <[email protected]>
[ Upstream commit 95d620adb48f7728e67d82f56f756e8d451cf8d2 ]
[Why]
Currently mode validation is bypassed if remote sink exists. That leads to mode set issue when a BW bottle neck exists in the link path, e.g., a DP-to-HDMI converter that only supports HDMI 1.4.
Any invalid mode passed to Linux user space will cause the modeset failure due to limitation of Linux user space implementation.
[How]
Mode validation is skipped only if in edid override. For real remote sink, clock limit check should be done for HDMI remote sink.
Have HDMI related remote sink going through mode validation to elimiate modes which pixel clock exceeds BW limitation.
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +1 -1
@@ -2268,7 +2268,7 @@ enum dc_status dc_link_validate_mode_timing(/* A hack to avoid failing any modes for EDID override feature on * topology change such as lower quality cable for DP or different dongle */ -if (link->remote_sinks[0 ]) +if (link->remote_sinks[0 ] && link->remote_sinks[0 ]->sink_signal ==SIGNAL_TYPE_VIRTUAL )return DC_OK ;/* Passive Dongle */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 80/214 drivers: watchdog: rdc321x_wdt: Fix race condition bugs
In reply to Greg Kroah-HartmanFrom: Madhuparna Bhowmik <[email protected]>
[ Upstream commit 4b2e7f99cdd314263c9d172bc17193b8b6bba463 ]
In rdc321x_wdt_probe(), rdc321x_wdt_device.queue is initialized after misc_register(), hence if ioctl is called before its initialization which can call rdc321x_wdt_start() function, it will see an uninitialized value of rdc321x_wdt_device.queue, hence initialize it before misc_register().
Also, rdc321x_wdt_device.default_ticks is accessed in reset() function called from write callback, thus initialize it before misc_register().
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/watchdog/rdc321x_wdt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/watchdog/rdc321x_wdt.c +2 -3
@@ -230,6 +230,8 @@ static int rdc321x_wdt_probe(struct platform_device *pdev) rdc321x_wdt_device.sb_pdev = pdata->sb_pdev; rdc321x_wdt_device.base_reg = r->start; + rdc321x_wdt_device.queue =0 ; + rdc321x_wdt_device.default_ticks = ticks; err =misc_register (&rdc321x_wdt_misc);if (err <0 ) {
@@ -244,14 +246,11 @@ static int rdc321x_wdt_probe(struct platform_device *pdev) rdc321x_wdt_device.base_reg, RDC_WDT_RST);init_completion (&rdc321x_wdt_device.stop); - rdc321x_wdt_device.queue =0 ;clear_bit (0 , &rdc321x_wdt_device.inuse);timer_setup (&rdc321x_wdt_device.timer, rdc321x_wdt_trigger,0 ); - rdc321x_wdt_device.default_ticks = ticks; -dev_info (&pdev->dev,"watchdog init success\n" );return 0 ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 111/214 ACPI / extlog: Check for RDMSR failure
In reply to Greg Kroah-HartmanFrom: Ben Hutchings <[email protected]>
commit 7cecb47f55e00282f972a1e0b09136c8cd938221 upstream.
extlog_init() uses rdmsrl() to read an MSR, which on older CPUs provokes a error message at boot:
unchecked MSR access error: RDMSR from 0x179 at rIP: 0xcd047307 (native_read_msr+0x7/0x40)
Use rdmsrl_safe() instead, and return -ENODEV if it fails.
--- drivers/acpi/acpi_extlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/acpi_extlog.c +3 -3
@@ -223,9 +223,9 @@ static int __init extlog_init(void)u64 cap;int rc; -rdmsrl (MSR_IA32_MCG_CAP , cap); - -if (!(cap &MCG_ELOG_P ) || !extlog_get_l1addr ()) +if (rdmsrl_safe (MSR_IA32_MCG_CAP , &cap) || + !(cap &MCG_ELOG_P ) || + !extlog_get_l1addr ())return -ENODEV ;if (edac_get_report_status () ==EDAC_REPORTING_FORCE ) {
Greg Kroah-Hartman
maintainerPATCH 78/214 asm-generic/io.h: Fix !CONFIG_GENERIC_IOMAP pci_iounmap() implementation
In reply to Greg Kroah-HartmanFrom: Lorenzo Pieralisi <[email protected]>
[ Upstream commit f5810e5c329238b8553ebd98b914bdbefd8e6737 ]
For arches that do not select CONFIG_GENERIC_IOMAP, the current pci_iounmap() function does nothing causing obvious memory leaks for mapped regions that are backed by MMIO physical space.
In order to detect if a mapped pointer is IO vs MMIO, a check must made available to the pci_iounmap() function so that it can actually detect whether the pointer has to be unmapped.
In configurations where CONFIG_HAS_IOPORT_MAP && !CONFIG_GENERIC_IOMAP, a mapped port is detected using an ioport_map() stub defined in asm-generic/io.h.
Use the same logic to implement a stub (ie __pci_ioport_unmap()) that detects if the passed in pointer in pci_iounmap() is IO vs MMIO to iounmap conditionally and call it in pci_iounmap() fixing the issue.
Leave __pci_ioport_unmap() as a NOP for all other config options.
--- include/asm-generic/io.h | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-)
include/asm-generic/io.h +27 -12
@@ -887,18 +887,6 @@ static inline void iowrite64_rep(volatile void __iomem *addr,#include <linux/vmalloc.h> #define __io_virt (x) ((void __force *)(x)) -#ifndef CONFIG_GENERIC_IOMAP -struct pci_dev ; -extern void __iomem *pci_iomap (struct pci_dev *dev,int bar,unsigned long max); - -#ifndef pci_iounmap -#define pci_iounmap pci_iounmap -static inline void pci_iounmap (struct pci_dev *dev,void __iomem *p) -{ -} -#endif -#endif /* CONFIG_GENERIC_IOMAP */ -/* * Change virtual addresses to physical addresses and vv. * These are pretty trivial
@@ -1013,6 +1001,16 @@ static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) port &=IO_SPACE_LIMIT ; return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; } +#define __pci_ioport_unmap __pci_ioport_unmap +static inline void __pci_ioport_unmap (void __iomem *p) +{ +uintptr_t start = (uintptr_t )PCI_IOBASE ; +uintptr_t addr = (uintptr_t ) p; + +if (addr >= start && addr < start +IO_SPACE_LIMIT ) +return ; +iounmap (p); +}#endif #ifndef ioport_unmap
@@ -1027,6 +1025,23 @@ extern void ioport_unmap(void __iomem *p);#endif /* CONFIG_GENERIC_IOMAP */ #endif /* CONFIG_HAS_IOPORT_MAP */ +#ifndef CONFIG_GENERIC_IOMAP +struct pci_dev ; +extern void __iomem *pci_iomap (struct pci_dev *dev,int bar,unsigned long max); + +#ifndef __pci_ioport_unmap +static inline void __pci_ioport_unmap (void __iomem *p) {} +#endif + +#ifndef pci_iounmap +#define pci_iounmap pci_iounmap +static inline void pci_iounmap (struct pci_dev *dev,void __iomem *p) +{ +__pci_ioport_unmap (p); +} +#endif +#endif /* CONFIG_GENERIC_IOMAP */ +/* * Convert a virtual cached pointer to an uncached pointer */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 76/214 rpmsg: glink: Use complete_all for open states
In reply to Greg Kroah-HartmanFrom: Chris Lew <[email protected]>
[ Upstream commit 4fcdaf6e28d11e2f3820d54dd23cd12a47ddd44e ]
The open_req and open_ack completion variables are the state variables to represet a remote channel as open. Use complete_all so there are no races with waiters and using completion_done.
--- drivers/rpmsg/qcom_glink_native.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rpmsg/qcom_glink_native.c +3 -3
@@ -970,7 +970,7 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid)return -EINVAL ; } -complete (&channel->open_ack); +complete_all (&channel->open_ack);return 0 ; }
@@ -1178,7 +1178,7 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev)__be32 *val = defaults;int size; -if (glink->intentless) +if (glink->intentless || !completion_done (&channel->open_ack))return 0 ; prop =of_find_property (np,"qcom,intents" ,NULL );
@@ -1413,7 +1413,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid, channel->rcid = ret;spin_unlock_irqrestore (&glink->idr_lock, flags); -complete (&channel->open_req); +complete_all (&channel->open_req);if (create_device) { rpdev =kzalloc (sizeof (*rpdev),GFP_KERNEL );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 77/214 clk: ti: clockdomain: fix static checker warning
In reply to Greg Kroah-HartmanFrom: Tero Kristo <[email protected]>
[ Upstream commit b7a7943fe291b983b104bcbd2f16e8e896f56590 ]
Fix a memory leak induced by not calling clk_put after doing of_clk_get.
--- drivers/clk/ti/clockdomain.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/ti/clockdomain.c +2 -0
@@ -146,10 +146,12 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)if (!omap2_clk_is_hw_omap (clk_hw)) {pr_warn ("can't setup clkdm for basic clk %s\n" ,__clk_get_name (clk)); +clk_put (clk);continue ; }to_clk_hw_omap (clk_hw)->clkdm_name = clkdm_name;omap2_init_clk_clkdm (clk_hw); +clk_put (clk); } }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 79/214 net: 9p: initialize sun_server.sun_path to have addrs value only when addr is valid
In reply to Greg Kroah-HartmanFrom: Anant Thazhemadam <[email protected]>
[ Upstream commit 7ca1db21ef8e0e6725b4d25deed1ca196f7efb28 ]
In p9_fd_create_unix, checking is performed to see if the addr (passed as an argument) is NULL or not.
However, no check is performed to see if addr is a valid address, i.e., it doesn't entirely consist of only 0's.
The initialization of sun_server.sun_path to be equal to this faulty addr value leads to an uninitialized variable, as detected by KMSAN. Checking for this (faulty addr) and returning a negative error number appropriately, resolves this issue.
--- net/9p/trans_fd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/9p/trans_fd.c +1 -1
@@ -1023,7 +1023,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args) csocket =NULL ; -if (addr ==NULL ) +if (!addr || !strlen (addr))return -EINVAL ;if (strlen (addr) >=UNIX_PATH_MAX ) {
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 75/214 bnxt_en: Log unknown link speed appropriately.
In reply to Greg Kroah-HartmanFrom: Michael Chan <[email protected]>
[ Upstream commit 8eddb3e7ce124dd6375d3664f1aae13873318b0f ]
If the VF virtual link is set to always enabled, the speed may be unknown when the physical link is down. The driver currently logs the link speed as 4294967295 Mbps which is SPEED_UNKNOWN. Modify the link up log message as "speed unknown" which makes more sense.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -1
@@ -8375,6 +8375,11 @@ static void bnxt_report_link(struct bnxt *bp)u16 fec;netif_carrier_on (bp->dev); + speed =bnxt_fw_to_ethtool_speed (bp->link_info.link_speed); +if (speed ==SPEED_UNKNOWN ) { +netdev_info (bp->dev,"NIC Link is Up, speed unknown\n" ); +return ; + }if (bp->link_info.duplex ==BNXT_LINK_DUPLEX_FULL ) duplex ="full" ;else
@@ -8387,7 +8392,6 @@ static void bnxt_report_link(struct bnxt *bp) flow_ctrl ="ON - receive" ; else flow_ctrl ="none" ; - speed =bnxt_fw_to_ethtool_speed (bp->link_info.link_speed);netdev_info (bp->dev,"NIC Link is Up, %u Mbps %s duplex, Flow control: %s\n" , speed, duplex, flow_ctrl);if (bp->flags &BNXT_FLAG_EEE_CAP )
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 109/214 NFS: fix nfs_path in case of a rename retry
In reply to Greg Kroah-HartmanFrom: Ashish Sangwan <[email protected]>
commit 247db73560bc3e5aef6db50c443c3c0db115bc93 upstream.
We are generating incorrect path in case of rename retry because we are restarting from wrong dentry. We should restart from the dentry which was received in the call to nfs_path.
--- fs/nfs/namespace.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/nfs/namespace.c +8 -4
@@ -31,9 +31,9 @@ int nfs_mountpoint_expiry_timeout = 500/* * nfs_path - reconstruct the path given an arbitrary dentry * @base - used to return pointer to the end of devname part of path -* @dentry - pointer to dentry +* @dentry_in - pointer to dentry * @buffer - result buffer -* @buflen - length of buffer +* @buflen_in - length of buffer * @flags - options (see below) * * Helper function for constructing the server pathname
@@ -48,15 +48,19 @@ int nfs_mountpoint_expiry_timeout = 500* the original device (export) name * (if unset, the original name is returned verbatim) */ -char *nfs_path (char **p,struct dentry *dentry,char *buffer,ssize_t buflen, -unsigned flags) +char *nfs_path (char **p,struct dentry *dentry_in,char *buffer, +ssize_t buflen_in,unsigned flags) {char *end;int namelen;unsigned seq;const char *base; +struct dentry *dentry; +ssize_t buflen; rename_retry: + buflen = buflen_in; + dentry = dentry_in; end = buffer+buflen; *--end ='\0' ; buflen--;
Greg Kroah-Hartman
maintainerPATCH 110/214 ACPI: button: fix handling lid state changes when input device closed
In reply to Greg Kroah-HartmanFrom: [email protected] <[email protected]>
commit 21988a8e51479ceffe7b0568b170effabb708dfe upstream.
The original intent of 84d3f6b76447 was to delay evaluating lid state until all drivers have been loaded, with input device being opened from userspace serving as a signal for this condition. Let's ensure that state updates happen even if userspace closed (or in the future inhibited) input device.
Note that if we go through suspend/resume cycle we assume the system has been fully initialized even if LID input device has not been opened yet.
This has a side-effect of fixing access to input->users outside of input->mutex protections by the way of eliminating said accesses and using driver private flag.
--- drivers/acpi/button.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/acpi/button.c +7 -6
@@ -136,6 +136,7 @@ struct acpi_button {int last_state;ktime_t last_time;bool suspended; +bool lid_state_initialized; };static BLOCKING_NOTIFIER_HEAD (acpi_lid_notifier);
@@ -391,6 +392,8 @@ static int acpi_lid_update_state(structstatic void acpi_lid_initialize_state (struct acpi_device *device) { +struct acpi_button *button =acpi_driver_data (device); +switch (lid_init_state) {case ACPI_BUTTON_LID_INIT_OPEN : (void )acpi_lid_notify_state (device,1 );
@@ -402,13 +405,14 @@ static void acpi_lid_initialize_state(stdefault :break ; } + + button->lid_state_initialized = true; }static void acpi_button_notify (struct acpi_device *device,u32 event) {struct acpi_button *button =acpi_driver_data (device);struct input_dev *input; -int users;switch (event) {case ACPI_FIXED_HARDWARE_EVENT :
@@ -417,10 +421,7 @@ static void acpi_button_notify(struct accase ACPI_BUTTON_NOTIFY_STATUS : input = button->input;if (button->type ==ACPI_BUTTON_TYPE_LID ) { -mutex_lock (&button->input->mutex); - users = button->input->users; -mutex_unlock (&button->input->mutex); -if (users) +if (button->lid_state_initialized)acpi_lid_update_state (device, true); }else {int keycode;
@@ -465,7 +466,7 @@ static int acpi_button_resume(struct devstruct acpi_button *button =acpi_driver_data (device); button->suspended = false; -if (button->type ==ACPI_BUTTON_TYPE_LID && button->input->users) { +if (button->type ==ACPI_BUTTON_TYPE_LID ) { button->last_state = !!acpi_lid_evaluate_state (device); button->last_time =ktime_get ();acpi_lid_initialize_state (device);
Greg Kroah-Hartman
maintainerPATCH 108/214 fs: Dont invalidate page buffers in block_write_full_page()
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 6dbf7bb555981fb5faf7b691e8f6169fc2b2e63b upstream.
If block_write_full_page() is called for a page that is beyond current inode size, it will truncate page buffers for the page and return 0. This logic has been added in 2.5.62 in commit 81eb69062588 ("fix ext3 BUG due to race with truncate") in history.git tree to fix a problem with ext3 in data=ordered mode. This particular problem doesn't exist anymore because ext3 is long gone and ext4 handles ordered data differently. Also normally buffers are invalidated by truncate code and there's no need to specially handle this in ->writepage() code.
This invalidation of page buffers in block_write_full_page() is causing issues to filesystems (e.g. ext4 or ocfs2) when block device is shrunk under filesystem's hands and metadata buffers get discarded while being tracked by the journalling layer. Although it is obviously "not supported" it can cause kernel crashes like:
[ 7986.689400] BUG: unable to handle kernel NULL pointer dereference at +0000000000000008 [ 7986.697197] PGD 0 P4D 0 [ 7986.699724] Oops: 0002 [#1] SMP PTI [ 7986.703200] CPU: 4 PID: 203778 Comm: jbd2/dm-3-8 Kdump: loaded Tainted: G +O --------- - - 4.18.0-147.5.0.5.h126.eulerosv2r9.x86_64 #1 [ 7986.716438] Hardware name: Huawei RH2288H V3/BC11HGSA0, BIOS 1.57 08/11/2015 [ 7986.723462] RIP: 0010:jbd2_journal_grab_journal_head+0x1b/0x40 [jbd2] ... [ 7986.810150] Call Trace: [ 7986.812595] __jbd2_journal_insert_checkpoint+0x23/0x70 [jbd2] [ 7986.818408] jbd2_journal_commit_transaction+0x155f/0x1b60 [jbd2] [ 7986.836467] kjournald2+0xbd/0x270 [jbd2]
which is not great. The crash happens because bh->b_private is suddently NULL although BH_JBD flag is still set (this is because block_invalidatepage() cleared BH_Mapped flag and subsequent bh lookup found buffer without BH_Mapped set, called init_page_buffers() which has rewritten bh->b_private). So just remove the invalidation in block_write_full_page().
Note that the buffer cache invalidation when block device changes size is already careful to avoid similar problems by using invalidate_mapping_pages() which skips busy buffers so it was only this odd block_write_full_page() behavior that could tear down bdev buffers under filesystem's hands.
--- fs/buffer.c | 16 ---------------- 1 file changed, 16 deletions(-)
fs/buffer.c +0 -16
@@ -2739,16 +2739,6 @@ int nobh_writepage(struct page *page, ge/* Is the page fully outside i_size? (truncate in progress) */ offset = i_size & (PAGE_SIZE -1 );if (page->index >= end_index+1 || !offset) { -/* -* The page may have dirty, unmapped buffers. For example, -* they may have been added in ext3_writepage(). Make them -* freeable here, so the page does not leak. -*/ -#if 0 -/* Not really sure about this - do we need this ? */ -if (page->mapping->a_ops->invalidatepage) - page->mapping->a_ops->invalidatepage (page, offset); -#endif unlock_page (page);return 0 ;/* don't care */ }
@@ -2943,12 +2933,6 @@ int block_write_full_page(struct page *p/* Is the page fully outside i_size? (truncate in progress) */ offset = i_size & (PAGE_SIZE -1 );if (page->index >= end_index+1 || !offset) { -/* -* The page may have dirty, unmapped buffers. For example, -* they may have been added in ext3_writepage(). Make them -* freeable here, so the page does not leak. -*/ -do_invalidatepage (page,0 ,PAGE_SIZE );unlock_page (page);return 0 ;/* don't care */ }
Greg Kroah-Hartman
maintainerPATCH 107/214 media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit 93df48d37c3f03886d84831992926333e7810640 upstream.
uvc_ctrl_add_info() calls uvc_ctrl_get_flags() which will override the fixed-up flags set by uvc_ctrl_fixup_xu_info().
uvc_ctrl_init_xu_ctrl() already calls uvc_ctrl_get_flags() before calling uvc_ctrl_add_info(), so the uvc_ctrl_get_flags() call in uvc_ctrl_add_info() is not necessary for xu ctrls.
This commit moves the uvc_ctrl_get_flags() call for normal controls from uvc_ctrl_add_info() to uvc_ctrl_init_ctrl(), so that we no longer call uvc_ctrl_get_flags() twice for xu controls and so that we no longer override the fixed-up flags set by uvc_ctrl_fixup_xu_info().
This fixes the xu motor controls not working properly on a Logitech 046d:08cc, and presumably also on the other Logitech models which have a quirk for this in the uvc_ctrl_fixup_xu_info() function.
--- drivers/media/usb/uvc/uvc_ctrl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +7 -7
@@ -2033,13 +2033,6 @@ static int uvc_ctrl_add_info(struct uvc_ goto done; } -/* -* Retrieve control flags from the device. Ignore errors and work with -* default flag values from the uvc_ctrl array when the device doesn't -* properly implement GET_INFO on standard controls. -*/ -uvc_ctrl_get_flags (dev, ctrl, &ctrl->info); - ctrl->initialized =1 ; uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
@@ -2262,6 +2255,13 @@ static void uvc_ctrl_init_ctrl(struct uvif (uvc_entity_match_guid (ctrl->entity, info->entity) && ctrl->index == info->index) {uvc_ctrl_add_info (dev, ctrl, info); +/* +* Retrieve control flags from the device. Ignore errors +* and work with default flag values from the uvc_ctrl +* array when the device doesn't properly implement +* GET_INFO on standard controls. +*/ +uvc_ctrl_get_flags (dev, ctrl, &ctrl->info);break ; } }
Greg Kroah-Hartman
maintainerPATCH 106/214 leds: bcm6328, bcm6358: use devres LED registering function
In reply to Greg Kroah-HartmanFrom: Marek Behún <[email protected]>
commit ff5c89d44453e7ad99502b04bf798a3fc32c758b upstream.
These two drivers do not provide remove method and use devres for allocation of other resources, yet they use led_classdev_register instead of the devres variant, devm_led_classdev_register.
Fix this.
--- drivers/leds/leds-bcm6328.c | 2 +- drivers/leds/leds-bcm6358.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-bcm6328.c +1 -1
@@ -332,7 +332,7 @@ static int bcm6328_led(struct device *de led->cdev.brightness_set = bcm6328_led_set; led->cdev.blink_set = bcm6328_blink_set; - rc =led_classdev_register (dev, &led->cdev); + rc =devm_led_classdev_register (dev, &led->cdev);if (rc <0 )return rc;
drivers/leds/leds-bcm6358.c +1 -1
@@ -137,7 +137,7 @@ static int bcm6358_led(struct device *de led->cdev.brightness_set = bcm6358_led_set; - rc =led_classdev_register (dev, &led->cdev); + rc =devm_led_classdev_register (dev, &led->cdev);if (rc <0 )return rc;
Greg Kroah-Hartman
maintainerPATCH 104/214 spi: sprd: Release DMA channel also on probe deferral
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 687a2e76186dcfa42f22c14b655c3fb159839e79 upstream.
If dma_request_chan() for TX channel fails with EPROBE_DEFER, the RX channel would not be released and on next re-probe it would be requested second time.
--- drivers/spi/spi-sprd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-sprd.c +1 -1
@@ -563,11 +563,11 @@ static int sprd_spi_dma_request(struct s ss->dma.dma_chan[SPRD_SPI_TX ] =dma_request_chan (ss->dev,"tx_chn" );if (IS_ERR_OR_NULL (ss->dma.dma_chan[SPRD_SPI_TX ])) { +dma_release_channel (ss->dma.dma_chan[SPRD_SPI_RX ]);if (PTR_ERR (ss->dma.dma_chan[SPRD_SPI_TX ]) == -EPROBE_DEFER )return PTR_ERR (ss->dma.dma_chan[SPRD_SPI_TX ]);dev_err (ss->dev,"request TX DMA channel failed!\n" ); -dma_release_channel (ss->dma.dma_chan[SPRD_SPI_RX ]);return PTR_ERR (ss->dma.dma_chan[SPRD_SPI_TX ]); }
Greg Kroah-Hartman
maintainerPATCH 105/214 extcon: ptn5150: Fix usage of atomic GPIO with sleeping GPIO chips
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 6aaad58c872db062f7ea2761421ca748bd0931cc upstream.
The driver uses atomic version of gpiod_set_value() without any real reason. It is called in a workqueue under mutex so it could sleep there. Changing it to "can_sleep" flavor allows to use the driver with all GPIO chips.
--- drivers/extcon/extcon-ptn5150.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/extcon/extcon-ptn5150.c +4 -4
@@ -127,7 +127,7 @@ static void ptn5150_irq_work(struct workcase PTN5150_DFP_ATTACHED :extcon_set_state_sync (info->edev,EXTCON_USB_HOST , false); -gpiod_set_value (info->vbus_gpiod,0 ); +gpiod_set_value_cansleep (info->vbus_gpiod,0 );extcon_set_state_sync (info->edev,EXTCON_USB , true);break ;
@@ -138,9 +138,9 @@ static void ptn5150_irq_work(struct work PTN5150_REG_CC_VBUS_DETECTION_MASK) >> PTN5150_REG_CC_VBUS_DETECTION_SHIFT);if (vbus) -gpiod_set_value (info->vbus_gpiod,0 ); +gpiod_set_value_cansleep (info->vbus_gpiod,0 );else -gpiod_set_value (info->vbus_gpiod,1 ); +gpiod_set_value_cansleep (info->vbus_gpiod,1 );extcon_set_state_sync (info->edev,EXTCON_USB_HOST , true);
@@ -156,7 +156,7 @@ static void ptn5150_irq_work(struct work EXTCON_USB_HOST, false);extcon_set_state_sync (info->edev,EXTCON_USB , false); -gpiod_set_value (info->vbus_gpiod,0 ); +gpiod_set_value_cansleep (info->vbus_gpiod,0 ); } }
Greg Kroah-Hartman
maintainerPATCH 103/214 perf/x86/amd/ibs: Fix raw sample data accumulation
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit 36e1be8ada994d509538b3b1d0af8b63c351e729 upstream.
Neither IbsBrTarget nor OPDATA4 are populated in IBS Fetch mode. Don't accumulate them into raw sample user data in that case.
Also, in Fetch mode, add saving the IBS Fetch Control Extended MSR.
Technically, there is an ABI change here with respect to the IBS raw sample data format, but I don't see any perf driver version information being included in perf.data file headers, but, existing users can detect whether the size of the sample record has reduced by 8 bytes to determine whether the IBS driver has this fix.
--- arch/x86/events/amd/ibs.c | 26 ++++++++++++++++---------- arch/x86/include/asm/msr-index.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-)
arch/x86/events/amd/ibs.c +16 -10
@@ -636,18 +636,24 @@ fail: perf_ibs->offset_max, offset + 1); }while (offset < offset_max); +/* +* Read IbsBrTarget, IbsOpData4, and IbsExtdCtl separately +* depending on their availability. +* Can't add to offset_max as they are staggered +*/ if (event->attr.sample_type &PERF_SAMPLE_RAW ) { -/* -* Read IbsBrTarget and IbsOpData4 separately -* depending on their availability. -* Can't add to offset_max as they are staggered -*/ -if (ibs_caps &IBS_CAPS_BRNTRGT ) { -rdmsrl (MSR_AMD64_IBSBRTARGET , *buf++); - size++; +if (perf_ibs == &perf_ibs_op) { +if (ibs_caps &IBS_CAPS_BRNTRGT ) { +rdmsrl (MSR_AMD64_IBSBRTARGET , *buf++); + size++; + } +if (ibs_caps &IBS_CAPS_OPDATA4 ) { +rdmsrl (MSR_AMD64_IBSOPDATA4 , *buf++); + size++; + } } -if (ibs_caps &IBS_CAPS_OPDATA4 ) { -rdmsrl (MSR_AMD64_IBSOPDATA4 , *buf++); +if (perf_ibs == &perf_ibs_fetch && (ibs_caps &IBS_CAPS_FETCHCTLEXTD )) { +rdmsrl (MSR_AMD64_ICIBSEXTDCTL , *buf++); size++; } }
arch/x86/include/asm/msr-index.h +1 -0
@@ -432,6 +432,7 @@#define MSR_AMD64_IBSOP_REG_MASK ((1UL<<MSR_AMD64_IBSOP_REG_COUNT)-1)#define MSR_AMD64_IBSCTL 0xc001103a#define MSR_AMD64_IBSBRTARGET 0xc001103b +#define MSR_AMD64_ICIBSEXTDCTL 0xc001103c#define MSR_AMD64_IBSOPDATA4 0xc001103d#define MSR_AMD64_IBS_REG_COUNT_MAX 8/* includes MSR_AMD64_IBSBRTARGET */ #define MSR_AMD64_SEV 0xc0010131
Greg Kroah-Hartman
maintainerPATCH 102/214 perf/x86/amd/ibs: Dont include randomized bits in get_ibs_op_count()
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit 680d69635005ba0e58fe3f4c52fc162b8fc743b0 upstream.
get_ibs_op_count() adds hardware's current count (IbsOpCurCnt) bits to its count regardless of hardware's valid status.
According to the PPR for AMD Family 17h Model 31h B0 55803 Rev 0.54, if the counter rolls over, valid status is set, and the lower 7 bits of IbsOpCurCnt are randomized by hardware.
Don't include those bits in the driver's event count.
--- arch/x86/events/amd/ibs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/events/amd/ibs.c +8 -4
@@ -335,11 +335,15 @@ static u64 get_ibs_op_count(u64 config) {u64 count =0 ; +/* +* If the internal 27-bit counter rolled over, the count is MaxCnt +* and the lower 7 bits of CurCnt are randomized. +* Otherwise CurCnt has the full 27-bit current counter value. +*/ if (config &IBS_OP_VAL ) - count += (config &IBS_OP_MAX_CNT ) <<4 ;/* cnt rolled over */ - -if (ibs_caps &IBS_CAPS_RDWROPCNT ) - count += (config &IBS_OP_CUR_CNT ) >>32 ; + count = (config &IBS_OP_MAX_CNT ) <<4 ; +else if (ibs_caps &IBS_CAPS_RDWROPCNT ) + count = (config &IBS_OP_CUR_CNT ) >>32 ;return count; }
Greg Kroah-Hartman
maintainerPATCH 74/214 md/bitmap: md_bitmap_get_counter returns wrong blocks
In reply to Greg Kroah-HartmanFrom: Zhao Heming <[email protected]>
[ Upstream commit d837f7277f56e70d82b3a4a037d744854e62f387 ]
md_bitmap_get_counter() has code:
```
if (bitmap->bp[page].hijacked ||
bitmap->bp[page].map == NULL)
csize = ((sector_t)1) << (bitmap->chunkshift +
PAGE_COUNTER_SHIFT - 1);
```The minus 1 is wrong, this branch should report 2048 bits of space. With "-1" action, this only report 1024 bit of space.
This bug code returns wrong blocks, but it doesn't inflence bitmap logic:
1. Most callers focus this function return value (the counter of offset), not the parameter blocks.
2. The bug is only triggered when hijacked is true or map is NULL. the hijacked true condition is very rare.
the "map == null" only true when array is creating or resizing.
3. Even the caller gets wrong blocks, current code makes caller just to call md_bitmap_get_counter() one more time.
--- drivers/md/md-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md-bitmap.c +1 -1
@@ -1372,7 +1372,7 @@ __acquires(bitmap->lock)if (bitmap->bp[page].hijacked || bitmap->bp[page].map ==NULL ) csize = ((sector_t )1 ) << (bitmap->chunkshift + -PAGE_COUNTER_SHIFT -1 ); +PAGE_COUNTER_SHIFT );else csize = ((sector_t )1 ) << bitmap->chunkshift; *blocks = csize - (offset & (csize -1 ));
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 99/214 seccomp: Make duplicate listener detection non-racy
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
commit dfe719fef03d752f1682fa8aeddf30ba501c8555 upstream.
Currently, init_listener() tries to prevent adding a filter with SECCOMP_FILTER_FLAG_NEW_LISTENER if one of the existing filters already has a listener. However, this check happens without holding any lock that would prevent another thread from concurrently installing a new filter (potentially with a listener) on top of the ones we already have.
Theoretically, this is also a data race: The plain load from current->seccomp.filter can race with concurrent writes to the same location.
Fix it by moving the check into the region that holds the siglock to guard against concurrent TSYNC.
(The "Fixes" tag points to the commit that introduced the theoretical data race; concurrent installation of another filter with TSYNC only became possible later, in commit 51891498f2da ("seccomp: allow TSYNC and USER_NOTIF together").)
--- kernel/seccomp.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-)
kernel/seccomp.c +31 -7
@@ -1219,13 +1219,7 @@ static const struct file_operations seccstatic struct file *init_listener (struct seccomp_filter *filter) { -struct file *ret =ERR_PTR (-EBUSY ); -struct seccomp_filter *cur; - -for (cur = current->seccomp.filter; cur; cur = cur->prev) { -if (cur->notif) - goto out; - } +struct file *ret; ret =ERR_PTR (-ENOMEM ); filter->notif =kzalloc (sizeof (*(filter->notif)),GFP_KERNEL );
@@ -1252,6 +1246,31 @@ out:return ret; } +/* +* Does @new_child have a listener while an ancestor also has a listener? +* If so, we'll want to reject this filter. +* This only has to be tested for the current process, even in the TSYNC case, +* because TSYNC installs @child with the same parent on all threads. +* Note that @new_child is not hooked up to its parent at this point yet, so +* we use current->seccomp.filter. +*/ +static bool has_duplicate_listener (struct seccomp_filter *new_child) +{ +struct seccomp_filter *cur; + +/* must be protected against concurrent TSYNC */ +lockdep_assert_held (¤t->sighand->siglock); + +if (!new_child->notif) +return false; +for (cur = current->seccomp.filter; cur; cur = cur->prev) { +if (cur->notif) +return true; + } + +return false; +} +/** * seccomp_set_mode_filter: internal function for setting seccomp filter * @flags: flags to change filter behavior
@@ -1321,6 +1340,11 @@ static long seccomp_set_mode_filter(unsiif (!seccomp_may_assign_mode (seccomp_mode)) goto out; +if (has_duplicate_listener (prepared)) { + ret = -EBUSY ; + goto out; + } + ret =seccomp_attach_filter (flags, prepared);if (ret) goto out;
Greg Kroah-Hartman
maintainerPATCH 100/214 selftests/x86/fsgsbase: Test PTRACE_PEEKUSER for GSBASE with invalid LDT GS
In reply to Greg Kroah-HartmanFrom: Andy Lutomirski <[email protected]>
commit 1b9abd1755ad947d7c9913e92e7837b533124c90 upstream.
This tests commit:
8ab49526b53d ("x86/fsgsbase/64: Fix NULL deref in 86_fsgsbase_read_task")
Unpatched kernels will OOPS.
--- tools/testing/selftests/x86/fsgsbase.c | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
tools/testing/selftests/x86/fsgsbase.c +65 -0
@@ -442,6 +442,68 @@ static void test_unexpected_base(void)#define USER_REGS_OFFSET (r) offsetof(struct user_regs_struct, r) +static void test_ptrace_write_gs_read_base (void ) +{ +int status; +pid_t child =fork (); + +if (child <0 ) +err (1 ,"fork" ); + +if (child ==0 ) { +printf ("[RUN]\tPTRACE_POKE GS, read GSBASE back\n" ); + +printf ("[RUN]\tARCH_SET_GS to 1\n" ); +if (syscall (SYS_arch_prctl,ARCH_SET_GS ,1 ) !=0 ) +err (1 ,"ARCH_SET_GS" ); + +if (ptrace (PTRACE_TRACEME ,0 ,NULL ,NULL ) !=0 ) +err (1 ,"PTRACE_TRACEME" ); + +raise (SIGTRAP ); +_exit (0 ); + } + +wait (&status); + +if (WSTOPSIG (status) ==SIGTRAP ) { +unsigned long base; +unsigned long gs_offset =USER_REGS_OFFSET (gs); +unsigned long base_offset =USER_REGS_OFFSET (gs_base); + +/* Read the initial base. It should be 1. */ + base =ptrace (PTRACE_PEEKUSER , child, base_offset,NULL ); +if (base ==1 ) { +printf ("[OK]\tGSBASE started at 1\n" ); + }else { + nerrs++; +printf ("[FAIL]\tGSBASE started at 0x%lx\n" , base); + } + +printf ("[RUN]\tSet GS = 0x7, read GSBASE\n" ); + +/* Poke an LDT selector into GS. */ +if (ptrace (PTRACE_POKEUSER , child, gs_offset,0x7 ) !=0 ) +err (1 ,"PTRACE_POKEUSER" ); + +/* And read the base. */ + base =ptrace (PTRACE_PEEKUSER , child, base_offset,NULL ); + +if (base ==0 || base ==1 ) { +printf ("[OK]\tGSBASE reads as 0x%lx with invalid GS\n" , base); + }else { + nerrs++; +printf ("[FAIL]\tGSBASE=0x%lx (should be 0 or 1)\n" , base); + } + } + +ptrace (PTRACE_CONT , child,NULL ,NULL ); + +wait (&status); +if (!WIFEXITED (status)) +printf ("[WARN]\tChild didn't exit cleanly.\n" ); +} +static void test_ptrace_write_gsbase (void ) {int status;
@@ -511,6 +573,9 @@ int main() shared_scratch =mmap (NULL ,4096 ,PROT_READ |PROT_WRITE ,MAP_ANONYMOUS |MAP_SHARED ,-1 ,0 ); +/* Do these tests before we have an LDT. */ +test_ptrace_write_gs_read_base (); +/* Probe FSGSBASE */ sethandler (SIGILL , sigill,0 );if (sigsetjmp (jmpbuf,1 ) ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 97/214 mmc: sdhci: Add LTR support for some Intel BYT based controllers
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 46f4a69ec8ed6ab9f6a6172afe50df792c8bc1b6 upstream.
Some Intel BYT based host controllers support the setting of latency tolerance. Accordingly, implement the PM QoS ->set_latency_tolerance() callback. The raw register values are also exposed via debugfs.
Intel EHL controllers require this support.
--- drivers/mmc/host/sdhci-pci-core.c | 154 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+)
drivers/mmc/host/sdhci-pci-core.c +154 -0
@@ -24,6 +24,8 @@#include <linux/iopoll.h> #include <linux/gpio.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> +#include <linux/debugfs.h> #include <linux/mmc/slot-gpio.h> #include <linux/mmc/sdhci-pci-data.h> #include <linux/acpi.h>
@@ -520,6 +522,8 @@ struct intel_host {bool rpm_retune_ok;u32 glk_rx_ctrl1;u32 glk_tun_val; +u32 active_ltr; +u32 idle_ltr; }; static const guid_t intel_dsm_guid =
@@ -764,6 +768,108 @@ static int intel_execute_tuning(struct mreturn 0 ; } +#define INTEL_ACTIVELTR 0x804 +#define INTEL_IDLELTR 0x808 + +#define INTEL_LTR_REQ BIT(15) +#define INTEL_LTR_SCALE_MASK GENMASK(11, 10) +#define INTEL_LTR_SCALE_1US (2 << 10) +#define INTEL_LTR_SCALE_32US (3 << 10) +#define INTEL_LTR_VALUE_MASK GENMASK(9, 0) + +static void intel_cache_ltr (struct sdhci_pci_slot *slot) +{ +struct intel_host *intel_host =sdhci_pci_priv (slot); +struct sdhci_host *host = slot->host; + + intel_host->active_ltr =readl (host->ioaddr +INTEL_ACTIVELTR ); + intel_host->idle_ltr =readl (host->ioaddr +INTEL_IDLELTR ); +} + +static void intel_ltr_set (struct device *dev,s32 val) +{ +struct sdhci_pci_chip *chip =dev_get_drvdata (dev); +struct sdhci_pci_slot *slot = chip->slots[0 ]; +struct intel_host *intel_host =sdhci_pci_priv (slot); +struct sdhci_host *host = slot->host; +u32 ltr; + +pm_runtime_get_sync (dev); + +/* +* Program latency tolerance (LTR) accordingly what has been asked +* by the PM QoS layer or disable it in case we were passed +* negative value or PM_QOS_LATENCY_ANY. +*/ + ltr =readl (host->ioaddr +INTEL_ACTIVELTR ); + +if (val ==PM_QOS_LATENCY_ANY || val <0 ) { + ltr &= ~INTEL_LTR_REQ ; + }else { + ltr |=INTEL_LTR_REQ ; + ltr &= ~INTEL_LTR_SCALE_MASK ; + ltr &= ~INTEL_LTR_VALUE_MASK ; + +if (val >INTEL_LTR_VALUE_MASK ) { + val >>=5 ; +if (val >INTEL_LTR_VALUE_MASK ) + val =INTEL_LTR_VALUE_MASK ; + ltr |=INTEL_LTR_SCALE_32US | val; + }else { + ltr |=INTEL_LTR_SCALE_1US | val; + } + } + +if (ltr == intel_host->active_ltr) + goto out; + +writel (ltr, host->ioaddr +INTEL_ACTIVELTR ); +writel (ltr, host->ioaddr +INTEL_IDLELTR ); + +/* Cache the values into lpss structure */ +intel_cache_ltr (slot); +out: +pm_runtime_put_autosuspend (dev); +} + +static bool intel_use_ltr (struct sdhci_pci_chip *chip) +{ +switch (chip->pdev->device) { +case PCI_DEVICE_ID_INTEL_BYT_EMMC : +case PCI_DEVICE_ID_INTEL_BYT_EMMC2 : +case PCI_DEVICE_ID_INTEL_BYT_SDIO : +case PCI_DEVICE_ID_INTEL_BYT_SD : +case PCI_DEVICE_ID_INTEL_BSW_EMMC : +case PCI_DEVICE_ID_INTEL_BSW_SDIO : +case PCI_DEVICE_ID_INTEL_BSW_SD : +return false; +default : +return true; + } +} + +static void intel_ltr_expose (struct sdhci_pci_chip *chip) +{ +struct device *dev = &chip->pdev->dev; + +if (!intel_use_ltr (chip)) +return ; + + dev->power.set_latency_tolerance = intel_ltr_set; +dev_pm_qos_expose_latency_tolerance (dev); +} + +static void intel_ltr_hide (struct sdhci_pci_chip *chip) +{ +struct device *dev = &chip->pdev->dev; + +if (!intel_use_ltr (chip)) +return ; + +dev_pm_qos_hide_latency_tolerance (dev); + dev->power.set_latency_tolerance =NULL ; +} +static void byt_probe_slot (struct sdhci_pci_slot *slot) {struct mmc_host_ops *ops = &slot->host->mmc_host_ops;
@@ -778,6 +884,43 @@ static void byt_probe_slot(struct sdhci_ ops->start_signal_voltage_switch = intel_start_signal_voltage_switch;device_property_read_u32 (dev,"max-frequency" , &mmc->f_max); + +if (!mmc->slotno) { + slot->chip->slots[mmc->slotno] = slot; +intel_ltr_expose (slot->chip); + } +} + +static void byt_add_debugfs (struct sdhci_pci_slot *slot) +{ +struct intel_host *intel_host =sdhci_pci_priv (slot); +struct mmc_host *mmc = slot->host->mmc; +struct dentry *dir = mmc->debugfs_root; + +if (!intel_use_ltr (slot->chip)) +return ; + +debugfs_create_x32 ("active_ltr" ,0444 , dir, &intel_host->active_ltr); +debugfs_create_x32 ("idle_ltr" ,0444 , dir, &intel_host->idle_ltr); + +intel_cache_ltr (slot); +} + +static int byt_add_host (struct sdhci_pci_slot *slot) +{ +int ret =sdhci_add_host (slot->host); + +if (!ret) +byt_add_debugfs (slot); +return ret; +} + +static void byt_remove_slot (struct sdhci_pci_slot *slot,int dead) +{ +struct mmc_host *mmc = slot->host->mmc; + +if (!mmc->slotno) +intel_ltr_hide (slot->chip); }static int byt_emmc_probe_slot (struct sdhci_pci_slot *slot)
@@ -859,6 +1002,8 @@ static int glk_emmc_add_host(struct sdhcif (ret) goto cleanup; +byt_add_debugfs (slot); +return 0 ; cleanup:
@@ -1036,6 +1181,8 @@ static const struct sdhci_pci_fixes sdhc#endif .allow_runtime_pm = true, .probe_slot = byt_emmc_probe_slot, + .add_host = byt_add_host, + .remove_slot = byt_remove_slot, .quirks =SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | SDHCI_QUIRK_NO_LED, .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
@@ -1049,6 +1196,7 @@ static const struct sdhci_pci_fixes sdhc .allow_runtime_pm = true, .probe_slot = glk_emmc_probe_slot, .add_host = glk_emmc_add_host, + .remove_slot = byt_remove_slot, #ifdef CONFIG_PM_SLEEP .suspend = sdhci_cqhci_suspend, .resume = sdhci_cqhci_resume,
@@ -1079,6 +1227,8 @@ static const struct sdhci_pci_fixes sdhc SDHCI_QUIRK2_PRESET_VALUE_BROKEN, .allow_runtime_pm = true, .probe_slot = ni_byt_sdio_probe_slot, + .add_host = byt_add_host, + .remove_slot = byt_remove_slot, .ops = &sdhci_intel_byt_ops, .priv_size = sizeof(struct intel_host), };
@@ -1096,6 +1246,8 @@ static const struct sdhci_pci_fixes sdhc SDHCI_QUIRK2_PRESET_VALUE_BROKEN, .allow_runtime_pm = true, .probe_slot = byt_sdio_probe_slot, + .add_host = byt_add_host, + .remove_slot = byt_remove_slot, .ops = &sdhci_intel_byt_ops, .priv_size = sizeof(struct intel_host), };
@@ -1115,6 +1267,8 @@ static const struct sdhci_pci_fixes sdhc .allow_runtime_pm = true, .own_cd_for_runtime_pm = true, .probe_slot = byt_sd_probe_slot, + .add_host = byt_add_host, + .remove_slot = byt_remove_slot, .ops = &sdhci_intel_byt_ops, .priv_size = sizeof(struct intel_host), };
Greg Kroah-Hartman
maintainerPATCH 98/214 mmc: sdhci-acpi: AMDI0040: Set SDHCI_QUIRK2_PRESET_VALUE_BROKEN
In reply to Greg Kroah-HartmanFrom: Raul E Rangel <[email protected]>
commit f23cc3ba491af77395cea3f9d51204398729f26b upstream.
This change fixes HS400 tuning for devices with invalid presets.
SDHCI presets are not currently used for eMMC HS/HS200/HS400, but are used for DDR52. The HS400 retuning sequence is:
HS400->DDR52->HS->HS200->Perform Tuning->HS->HS400
This means that when HS400 tuning happens, we transition through DDR52 for a very brief period. This causes presets to be enabled unintentionally and stay enabled when transitioning back to HS200 or HS400. Some firmware has invalid presets, so we end up with driver strengths that can cause I/O problems.
--- drivers/mmc/host/sdhci-acpi.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/mmc/host/sdhci-acpi.c +37 -0
@@ -658,6 +658,43 @@ static int sdhci_acpi_emmc_amd_probe_slo (host->mmc->caps & MMC_CAP_1_8V_DDR)) host->mmc->caps2 =MMC_CAP2_HS400_1_8V ; +/* +* There are two types of presets out in the wild: +* 1) Default/broken presets. +* These presets have two sets of problems: +* a) The clock divisor for SDR12, SDR25, and SDR50 is too small. +* This results in clock frequencies that are 2x higher than +* acceptable. i.e., SDR12 = 25 MHz, SDR25 = 50 MHz, SDR50 = +* 100 MHz.x +* b) The HS200 and HS400 driver strengths don't match. +* By default, the SDR104 preset register has a driver strength of +* A, but the (internal) HS400 preset register has a driver +* strength of B. As part of initializing HS400, HS200 tuning +* needs to be performed. Having different driver strengths +* between tuning and operation is wrong. It results in different +* rise/fall times that lead to incorrect sampling. +* 2) Firmware with properly initialized presets. +* These presets have proper clock divisors. i.e., SDR12 => 12MHz, +* SDR25 => 25 MHz, SDR50 => 50 MHz. Additionally the HS200 and +* HS400 preset driver strengths match. +* +* Enabling presets for HS400 doesn't work for the following reasons: +* 1) sdhci_set_ios has a hard coded list of timings that are used +* to determine if presets should be enabled. +* 2) sdhci_get_preset_value is using a non-standard register to +* read out HS400 presets. The AMD controller doesn't support this +* non-standard register. In fact, it doesn't expose the HS400 +* preset register anywhere in the SDHCI memory map. This results +* in reading a garbage value and using the wrong presets. +* +* Since HS400 and HS200 presets must be identical, we could +* instead use the the SDR104 preset register. +* +* If the above issues are resolved we could remove this quirk for +* firmware that that has valid presets (i.e., SDR12 <= 12 MHz). +*/ + host->quirks2 |=SDHCI_QUIRK2_PRESET_VALUE_BROKEN ; + host->mmc_host_ops.select_drive_strength = amd_select_drive_strength; host->mmc_host_ops.set_ios = amd_set_ios; host->mmc_host_ops.execute_tuning = amd_sdhci_execute_tuning;
Greg Kroah-Hartman
maintainerPATCH 92/214 ARM: dts: s5pv210: remove dedicated audio-subsystem node
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 6c17a2974abf68a58517f75741b15c4aba42b4b8 ]
The 'audio-subsystem' node is an artificial creation, not representing real hardware. The hardware is described by its nodes - AUDSS clock controller and I2S0.
Remove the 'audio-subsystem' node along with its undocumented compatible to fix dtbs_check warnings like:
audio-subsystem: $nodename:0: 'audio-subsystem' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$'
--- arch/arm/boot/dts/s5pv210.dtsi | 65 +++++++++++++++------------------- 1 file changed, 29 insertions(+), 36 deletions(-)
arch/arm/boot/dts/s5pv210.dtsi +29 -36
@@ -211,43 +211,36 @@ status = "disabled"; }; - audio-subsystem { - compatible = "samsung,s5pv210-audss", "simple-bus"; - #address-cells = <1>; - #size-cells = <1>; - ranges; - - clk_audss: clock-controller@eee10000 { - compatible = "samsung,s5pv210-audss-clock"; - reg = <0xeee10000 0x1000>; - clock-names = "hclk", "xxti", - "fout_epll", - "sclk_audio0"; - clocks = <&clocks DOUT_HCLKP>, <&xxti>, - <&clocks FOUT_EPLL>, - <&clocks SCLK_AUDIO0>; - #clock-cells = <1>; - }; + clk_audss: clock-controller@eee10000 { + compatible = "samsung,s5pv210-audss-clock"; + reg = <0xeee10000 0x1000>; + clock-names = "hclk", "xxti", + "fout_epll", + "sclk_audio0"; + clocks = <&clocks DOUT_HCLKP>, <&xxti>, + <&clocks FOUT_EPLL>, + <&clocks SCLK_AUDIO0>; + #clock-cells = <1>; + }; - i2s0: i2s@eee30000 { - compatible = "samsung,s5pv210-i2s"; - reg = <0xeee30000 0x1000>; - interrupt-parent = <&vic2>; - interrupts = <16>; - dma-names = "rx", "tx", "tx-sec"; - dmas = <&pdma1 9>, <&pdma1 10>, <&pdma1 11>; - clock-names = "iis", - "i2s_opclk0", - "i2s_opclk1"; - clocks = <&clk_audss CLK_I2S>, - <&clk_audss CLK_I2S>, - <&clk_audss CLK_DOUT_AUD_BUS>; - samsung,idma-addr = <0xc0010000>; - pinctrl-names = "default"; - pinctrl-0 = <&i2s0_bus>; - #sound-dai-cells = <0>; - status = "disabled"; - }; + i2s0: i2s@eee30000 { + compatible = "samsung,s5pv210-i2s"; + reg = <0xeee30000 0x1000>; + interrupt-parent = <&vic2>; + interrupts = <16>; + dma-names = "rx", "tx", "tx-sec"; + dmas = <&pdma1 9>, <&pdma1 10>, <&pdma1 11>; + clock-names = "iis", + "i2s_opclk0", + "i2s_opclk1"; + clocks = <&clk_audss CLK_I2S>, + <&clk_audss CLK_I2S>, + <&clk_audss CLK_DOUT_AUD_BUS>; + samsung,idma-addr = <0xc0010000>; + pinctrl-names = "default"; + pinctrl-0 = <&i2s0_bus>; + #sound-dai-cells = <0>; + status = "disabled"; }; i2s1: i2s@e2100000 {
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 88/214 memory: emif: Remove bogus debugfs error handling
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit fd22781648080cc400772b3c68aa6b059d2d5420 ]
Callers are generally not supposed to check the return values from debugfs functions. Debugfs functions never return NULL so this error handling will never trigger. (Historically debugfs functions used to return a mix of NULL and error pointers but it was eventually deemed too complicated for something which wasn't intended to be used in normal situations).
Delete all the error handling.
--- drivers/memory/emif.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-)
drivers/memory/emif.c +5 -28
@@ -163,35 +163,12 @@ static const struct file_operations emif_mr4_fops = { static int __init_or_module emif_debugfs_init(struct emif_data *emif) { -struct dentry *dentry; -int ret; - - dentry =debugfs_create_dir (dev_name (emif->dev),NULL ); -if (!dentry) { - ret = -ENOMEM ; - goto err0; - } - emif->debugfs_root = dentry; - - dentry =debugfs_create_file ("regcache_dump" ,S_IRUGO , - emif->debugfs_root, emif, &emif_regdump_fops); -if (!dentry) { - ret = -ENOMEM ; - goto err1; - } - - dentry =debugfs_create_file ("mr4" ,S_IRUGO , - emif->debugfs_root, emif, &emif_mr4_fops); -if (!dentry) { - ret = -ENOMEM ; - goto err1; - } - + emif->debugfs_root =debugfs_create_dir (dev_name (emif->dev),NULL ); +debugfs_create_file ("regcache_dump" ,S_IRUGO , emif->debugfs_root, emif, + &emif_regdump_fops); +debugfs_create_file ("mr4" ,S_IRUGO , emif->debugfs_root, emif, + &emif_mr4_fops);return 0 ; -err1: -debugfs_remove_recursive (emif->debugfs_root); -err0: -return ret; } static void __exit emif_debugfs_exit(struct emif_data *emif)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 90/214 ARM: dts: s5pv210: move fixed clocks under root node
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit d38cae370e5f2094cbc38db3082b8e9509ae52ce ]
The fixed clocks are kept under dedicated 'external-clocks' node, thus a fake 'reg' was added. This is not correct with dtschema as fixed-clock binding does not have a 'reg' property. Moving fixed clocks out of 'soc' to root node fixes multiple dtbs_check warnings:
external-clocks: $nodename:0: 'external-clocks' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$'
external-clocks: #size-cells:0:0: 0 is not one of [1, 2]
external-clocks: oscillator@0:reg:0: [0] is too short
external-clocks: oscillator@1:reg:0: [1] is too short
external-clocks: 'ranges' is a required property
oscillator@0: 'reg' does not match any of the regexes: 'pinctrl-[0-9]+'
--- arch/arm/boot/dts/s5pv210.dtsi | 36 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 22 deletions(-)
arch/arm/boot/dts/s5pv210.dtsi +14 -22
@@ -52,34 +52,26 @@ }; }; + xxti: oscillator-0 { + compatible = "fixed-clock"; + clock-frequency = <0>; + clock-output-names = "xxti"; + #clock-cells = <0>; + }; + + xusbxti: oscillator-1 { + compatible = "fixed-clock"; + clock-frequency = <0>; + clock-output-names = "xusbxti"; + #clock-cells = <0>; + }; + soc { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges; - external-clocks { - compatible = "simple-bus"; - #address-cells = <1>; - #size-cells = <0>; - - xxti: oscillator@0 { - compatible = "fixed-clock"; - reg = <0>; - clock-frequency = <0>; - clock-output-names = "xxti"; - #clock-cells = <0>; - }; - - xusbxti: oscillator@1 { - compatible = "fixed-clock"; - reg = <1>; - clock-frequency = <0>; - clock-output-names = "xusbxti"; - #clock-cells = <0>; - }; - }; - onenand: onenand@b0600000 { compatible = "samsung,s5pv210-onenand"; reg = <0xb0600000 0x2000>,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 82/214 KVM: PPC: Book3S HV: Do not allocate HPT for a nested guest
In reply to Greg Kroah-HartmanFrom: Fabiano Rosas <[email protected]>
[ Upstream commit 05e6295dc7de859c9d56334805485c4d20bebf25 ]
The current nested KVM code does not support HPT guests. This is informed/enforced in some ways:
- Hosts < P9 will not be able to enable the nested HV feature;
- The nested hypervisor MMU capabilities will not contain KVM_CAP_PPC_MMU_HASH_V3;
- QEMU reflects the MMU capabilities in the 'ibm,arch-vec-5-platform-support' device-tree property;
- The nested guest, at 'prom_parse_mmu_model' ignores the 'disable_radix' kernel command line option if HPT is not supported;
- The KVM_PPC_CONFIGURE_V3_MMU ioctl will fail if trying to use HPT.
There is, however, still a way to start a HPT guest by using max-compat-cpu=power8 at the QEMU machine options. This leads to the guest being set to use hash after QEMU calls the KVM_PPC_ALLOCATE_HTAB ioctl.
With the guest set to hash, the nested hypervisor goes through the entry path that has no knowledge of nesting (kvmppc_run_vcpu) and crashes when it tries to execute an hypervisor-privileged (mtspr HDEC) instruction at __kvmppc_vcore_entry:
root@L1:~ $ qemu-system-ppc64 -machine pseries,max-cpu-compat=power8 ...
<snip>
[ 538.543303] CPU: 83 PID: 25185 Comm: CPU 0/KVM Not tainted 5.9.0-rc4 #1
[ 538.543355] NIP: c00800000753f388 LR: c00800000753f368 CTR: c0000000001e5ec0
[ 538.543417] REGS: c0000013e91e33b0 TRAP: 0700 Not tainted (5.9.0-rc4)
[ 538.543470] MSR: 8000000002843033 <SF,VEC,VSX,FP,ME,IR,DR,RI,LE> CR: 22422882 XER: 20040000
[ 538.543546] CFAR: c00800000753f4b0 IRQMASK: 3
GPR00: c0080000075397a0 c0000013e91e3640 c00800000755e600 0000000080000000
GPR04: 0000000000000000 c0000013eab19800 c000001394de0000 00000043a054db72
GPR08: 00000000003b1652 0000000000000000 0000000000000000 c0080000075502e0
GPR12: c0000000001e5ec0 c0000007ffa74200 c0000013eab19800 0000000000000008
GPR16: 0000000000000000 c00000139676c6c0 c000000001d23948 c0000013e91e38b8
GPR20: 0000000000000053 0000000000000000 0000000000000001 0000000000000000
GPR24: 0000000000000001 0000000000000001 0000000000000000 0000000000000001
GPR28: 0000000000000001 0000000000000053 c0000013eab19800 0000000000000001
[ 538.544067] NIP [c00800000753f388] __kvmppc_vcore_entry+0x90/0x104 [kvm_hv]
[ 538.544121] LR [c00800000753f368] __kvmppc_vcore_entry+0x70/0x104 [kvm_hv]
[ 538.544173] Call Trace:
[ 538.544196] [c0000013e91e3640] [c0000013e91e3680] 0xc0000013e91e3680 (unreliable)
[ 538.544260] [c0000013e91e3820] [c0080000075397a0] kvmppc_run_core+0xbc8/0x19d0 [kvm_hv]
[ 538.544325] [c0000013e91e39e0] [c00800000753d99c] kvmppc_vcpu_run_hv+0x404/0xc00 [kvm_hv]
[ 538.544394] [c0000013e91e3ad0] [c0080000072da4fc] kvmppc_vcpu_run+0x34/0x48 [kvm]
[ 538.544472] [c0000013e91e3af0] [c0080000072d61b8] kvm_arch_vcpu_ioctl_run+0x310/0x420 [kvm]
[ 538.544539] [c0000013e91e3b80] [c0080000072c7450] kvm_vcpu_ioctl+0x298/0x778 [kvm]
[ 538.544605] [c0000013e91e3ce0] [c0000000004b8c2c] sys_ioctl+0x1dc/0xc90
[ 538.544662] [c0000013e91e3dc0] [c00000000002f9a4] system_call_exception+0xe4/0x1c0
[ 538.544726] [c0000013e91e3e20] [c00000000000d140] system_call_common+0xf0/0x27c
[ 538.544787] Instruction dump:
[ 538.544821] f86d1098 60000000 60000000 48000099 e8ad0fe8 e8c500a0 e9264140 75290002
[ 538.544886] 7d1602a6 7cec42a6 40820008 7d0807b4 <7d164ba6> 7d083a14 f90d10a0 480104fd
[ 538.544953] ---[ end trace 74423e2b948c2e0c ]---This patch makes the KVM_PPC_ALLOCATE_HTAB ioctl fail when running in the nested hypervisor, causing QEMU to abort.
--- arch/powerpc/kvm/book3s_hv.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/powerpc/kvm/book3s_hv.c +6 -0
@@ -5191,6 +5191,12 @@ static long kvm_arch_vm_ioctl_hv(struct file *filp,case KVM_PPC_ALLOCATE_HTAB : {u32 htab_order; +/* If we're a nested hypervisor, we currently only support radix */ +if (kvmhv_on_pseries ()) { + r = -EOPNOTSUPP ; +break ; + } + r = -EFAULT ;if (get_user (htab_order, (u32 __user *)argp))break ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 83/214 gfs2: use-after-free in sysfs deregistration
In reply to Greg Kroah-HartmanFrom: Jamie Iles <[email protected]>
[ Upstream commit c2a04b02c060c4858762edce4674d5cba3e5a96f ]
syzkaller found the following splat with CONFIG_DEBUG_KOBJECT_RELEASE=y:
Read of size 1 at addr ffff000028e896b8 by task kworker/1:2/228 CPU: 1 PID: 228 Comm: kworker/1:2 Tainted: G S 5.9.0-rc8+ #101 Hardware name: linux,dummy-virt (DT) Workqueue: events kobject_delayed_cleanup Call trace: dump_backtrace+0x0/0x4d8 show_stack+0x34/0x48 dump_stack+0x174/0x1f8 print_address_description.constprop.0+0x5c/0x550 kasan_report+0x13c/0x1c0 __asan_report_load1_noabort+0x34/0x60 memcmp+0xd0/0xd8 gfs2_uevent+0xc4/0x188 kobject_uevent_env+0x54c/0x1240 kobject_uevent+0x2c/0x40 __kobject_del+0x190/0x1d8 kobject_delayed_cleanup+0x2bc/0x3b8 process_one_work+0x96c/0x18c0 worker_thread+0x3f0/0xc30 kthread+0x390/0x498 ret_from_fork+0x10/0x18 Allocated by task 1110: kasan_save_stack+0x28/0x58 __kasan_kmalloc.isra.0+0xc8/0xe8 kasan_kmalloc+0x10/0x20 kmem_cache_alloc_trace+0x1d8/0x2f0 alloc_super+0x64/0x8c0 sget_fc+0x110/0x620 get_tree_bdev+0x190/0x648 gfs2_get_tree+0x50/0x228 vfs_get_tree+0x84/0x2e8 path_mount+0x1134/0x1da8 do_mount+0x124/0x138 __arm64_sys_mount+0x164/0x238 el0_svc_common.constprop.0+0x15c/0x598 do_el0_svc+0x60/0x150 el0_svc+0x34/0xb0 el0_sync_handler+0xc8/0x5b4 el0_sync+0x15c/0x180 Freed by task 228: kasan_save_stack+0x28/0x58 kasan_set_track+0x28/0x40 kasan_set_free_info+0x24/0x48 __kasan_slab_free+0x118/0x190 kasan_slab_free+0x14/0x20 slab_free_freelist_hook+0x6c/0x210 kfree+0x13c/0x460
Use the same pattern as f2fs + ext4 where the kobject destruction must complete before allowing the FS itself to be freed. This means that we need an explicit free_sbd in the callers.
--- fs/gfs2/incore.h | 1 + fs/gfs2/ops_fstype.c | 22 +++++----------------- fs/gfs2/super.c | 1 + fs/gfs2/sys.c | 5 ++++- 4 files changed, 11 insertions(+), 18 deletions(-)
fs/gfs2/incore.h +1 -0
@@ -694,6 +694,7 @@ struct gfs2_sbd {struct super_block *sd_vfs;struct gfs2_pcpu_lkstats __percpu *sd_lkstats;struct kobject sd_kobj; +struct completion sd_kobj_unregister;unsigned long sd_flags;/* SDF_... */ struct gfs2_sb_host sd_sb;
fs/gfs2/ops_fstype.c +5 -17
@@ -1094,26 +1094,14 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc) } error =init_names (sdp, silent); -if (error) { -/* In this case, we haven't initialized sysfs, so we have to -manually free the sdp. */ -free_sbd (sdp); - sb->s_fs_info =NULL ; -return error; - } +if (error) + goto fail_free;snprintf (sdp->sd_fsname,sizeof (sdp->sd_fsname),"%s" , sdp->sd_table_name); error =gfs2_sys_fs_add (sdp); -/* -* If we hit an error here, gfs2_sys_fs_add will have called function -* kobject_put which causes the sysfs usage count to go to zero, which -* causes sysfs to call function gfs2_sbd_release, which frees sdp. -* Subsequent error paths here will call gfs2_sys_fs_del, which also -* kobject_put to free sdp. -*/ if (error) -return error; + goto fail_free;gfs2_create_debugfs_file (sdp);
@@ -1210,9 +1198,9 @@ fail_lm:gfs2_lm_unmount (sdp); fail_debug:gfs2_delete_debugfs_file (sdp); -/* gfs2_sys_fs_del must be the last thing we do, since it causes -* sysfs to call function gfs2_sbd_release, which frees sdp. */ gfs2_sys_fs_del (sdp); +fail_free: +free_sbd (sdp); sb->s_fs_info =NULL ;return error; }
fs/gfs2/super.c +1 -0
@@ -695,6 +695,7 @@ restart:/* At this point, we're through participating in the lockspace */ gfs2_sys_fs_del (sdp); +free_sbd (sdp); }/**
fs/gfs2/sys.c +4 -1
@@ -302,7 +302,7 @@ static void gfs2_sbd_release(struct kobject *kobj) { struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); -free_sbd (sdp); +complete (&sdp->sd_kobj_unregister); }static struct kobj_type gfs2_ktype = {
@@ -652,6 +652,7 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)sprintf (ro,"RDONLY=%d" ,sb_rdonly (sb));sprintf (spectator,"SPECTATOR=%d" , sdp->sd_args.ar_spectator ?1 :0 ); +init_completion (&sdp->sd_kobj_unregister); sdp->sd_kobj.kset = gfs2_kset; error =kobject_init_and_add (&sdp->sd_kobj, &gfs2_ktype,NULL ,"%s" , sdp->sd_table_name);
@@ -682,6 +683,7 @@ fail_tune: fail_reg:fs_err (sdp,"error %d adding sysfs files\n" , error);kobject_put (&sdp->sd_kobj); +wait_for_completion (&sdp->sd_kobj_unregister); sb->s_fs_info =NULL ;return error; }
@@ -692,6 +694,7 @@ void gfs2_sys_fs_del(struct gfs2_sbd *sdp)sysfs_remove_group (&sdp->sd_kobj, &tune_group);sysfs_remove_group (&sdp->sd_kobj, &lock_module_group);kobject_put (&sdp->sd_kobj); +wait_for_completion (&sdp->sd_kobj_unregister); } static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 30/214 f2fs: handle errors of f2fs_get_meta_page_nofail
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 86f33603f8c51537265ff7ac0320638fd2cbdb1b ]
First problem is we hit BUG_ON() in f2fs_get_sum_page given EIO on f2fs_get_meta_page_nofail().
Quick fix was not to give any error with infinite loop, but syzbot caught a case where it goes to that loop from fuzzed image. In turned out we abused f2fs_get_meta_page_nofail() like in the below call stack.
- f2fs_fill_super
- f2fs_build_segment_manager
- build_sit_entries
- get_current_sit_page
INFO: task syz-executor178:6870 can't die for more than 143 seconds.
task:syz-executor178 state:R
stack:26960 pid: 6870 ppid: 6869 flags:0x00004006
Call Trace:
Showing all locks held in the system:
1 lock held by khungtaskd/1179:
#0: ffffffff8a554da0 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x53/0x260 kernel/locking/lockdep.c:6242
1 lock held by systemd-journal/3920:
1 lock held by in:imklog/6769:
#0: ffff88809eebc130 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xe9/0x100 fs/file.c:930
1 lock held by syz-executor178/6870:
#0: ffff8880925120e0 (&type->s_umount_key#47/1){+.+.}-{3:3}, at: alloc_super+0x201/0xaf0 fs/super.c:229Actually, we didn't have to use _nofail in this case, since we could return error to mount(2) already with the error handler.
As a result, this patch tries to 1) remove _nofail callers as much as possible,
2) deal with error case in last remaining caller, f2fs_get_sum_page().
--- fs/f2fs/checkpoint.c | 2 +- fs/f2fs/f2fs.h | 2 +- fs/f2fs/node.c | 2 +- fs/f2fs/segment.c | 12 +++++++++--- 4 files changed, 12 insertions(+), 6 deletions(-)
fs/f2fs/checkpoint.c +1 -1
@@ -108,7 +108,7 @@ struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)return __get_meta_page (sbi, index, true); } -struct page *f2fs_get_meta_page_nofail (struct f2fs_sb_info *sbi,pgoff_t index) +struct page *f2fs_get_meta_page_retry (struct f2fs_sb_info *sbi,pgoff_t index) {struct page *page;int count =0 ;
fs/f2fs/f2fs.h +1 -1
@@ -3149,7 +3149,7 @@ enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi,void f2fs_stop_checkpoint (struct f2fs_sb_info *sbi,bool end_io);struct page *f2fs_grab_meta_page (struct f2fs_sb_info *sbi,pgoff_t index);struct page *f2fs_get_meta_page (struct f2fs_sb_info *sbi,pgoff_t index); -struct page *f2fs_get_meta_page_nofail (struct f2fs_sb_info *sbi,pgoff_t index); +struct page *f2fs_get_meta_page_retry (struct f2fs_sb_info *sbi,pgoff_t index);struct page *f2fs_get_tmp_page (struct f2fs_sb_info *sbi,pgoff_t index);bool f2fs_is_valid_blkaddr (struct f2fs_sb_info *sbi,block_t blkaddr,int type);
fs/f2fs/node.c +1 -1
@@ -109,7 +109,7 @@ static void clear_node_page_dirty(struct page *page)static struct page *get_current_nat_page (struct f2fs_sb_info *sbi,nid_t nid) { -return f2fs_get_meta_page_nofail (sbi,current_nat_addr (sbi, nid)); +return f2fs_get_meta_page (sbi,current_nat_addr (sbi, nid)); }static struct page *get_next_nat_page (struct f2fs_sb_info *sbi,nid_t nid)
fs/f2fs/segment.c +9 -3
@@ -2310,7 +2310,9 @@ int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra)*/ struct page *f2fs_get_sum_page (struct f2fs_sb_info *sbi,unsigned int segno) { -return f2fs_get_meta_page_nofail (sbi,GET_SUM_BLOCK (sbi, segno)); +if (unlikely (f2fs_cp_error (sbi))) +return ERR_PTR (-EIO ); +return f2fs_get_meta_page_retry (sbi,GET_SUM_BLOCK (sbi, segno)); } void f2fs_update_meta_page(struct f2fs_sb_info *sbi,
@@ -2582,7 +2584,11 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)__next_free_blkoff (sbi, curseg,0 ); sum_page =f2fs_get_sum_page (sbi, new_segno); -f2fs_bug_on (sbi,IS_ERR (sum_page)); +if (IS_ERR (sum_page)) { +/* GC won't be able to use stale summary pages by cp_error */ +memset (curseg->sum_blk,0 ,SUM_ENTRY_SIZE ); +return ; + } sum_node = (struct f2fs_summary_block *)page_address (sum_page);memcpy (curseg->sum_blk, sum_node,SUM_ENTRY_SIZE );f2fs_put_page (sum_page,1 );
@@ -3713,7 +3719,7 @@ int f2fs_lookup_journal_in_cursum(struct f2fs_journal *journal, int type,static struct page *get_current_sit_page (struct f2fs_sb_info *sbi,unsigned int segno) { -return f2fs_get_meta_page_nofail (sbi,current_sit_addr (sbi, segno)); +return f2fs_get_meta_page (sbi,current_sit_addr (sbi, segno)); } static struct page *get_next_sit_page(struct f2fs_sb_info *sbi,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 38/214 drm/brige/megachips: Add checking if ge_b850v3_lvds_init() is working correctly
In reply to Greg Kroah-HartmanFrom: Nadezda Lutovinova <[email protected]>
[ Upstream commit f688a345f0d7a6df4dd2aeca8e4f3c05e123a0ee ]
If ge_b850v3_lvds_init() does not allocate memory for ge_b850v3_lvds_ptr, then a null pointer dereference is accessed.
The patch adds checking of the return value of ge_b850v3_lvds_init().
Found by Linux Driver Verification project (linuxtesting.org).
--- .../gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +10 -2
@@ -295,8 +295,12 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client *stdp4028_i2c, const struct i2c_device_id *id) {struct device *dev = &stdp4028_i2c->dev; +int ret; + + ret =ge_b850v3_lvds_init (dev); -ge_b850v3_lvds_init (dev); +if (ret) +return ret; ge_b850v3_lvds_ptr->stdp4028_i2c = stdp4028_i2c;i2c_set_clientdata (stdp4028_i2c, ge_b850v3_lvds_ptr);
@@ -354,8 +358,12 @@ static int stdp2690_ge_b850v3_fw_probe(struct i2c_client *stdp2690_i2c, const struct i2c_device_id *id) {struct device *dev = &stdp2690_i2c->dev; +int ret; + + ret =ge_b850v3_lvds_init (dev); -ge_b850v3_lvds_init (dev); +if (ret) +return ret; ge_b850v3_lvds_ptr->stdp2690_i2c = stdp2690_i2c;i2c_set_clientdata (stdp2690_i2c, ge_b850v3_lvds_ptr);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 36/214 ath10k: start recovery process when payload length exceeds max htc length for sdio
In reply to Greg Kroah-HartmanFrom: Wen Gong <[email protected]>
[ Upstream commit 2fd3c8f34d08af0a6236085f9961866ad92ef9ec ]
When simulate random transfer fail for sdio write and read, it happened "payload length exceeds max htc length" and recovery later sometimes.
Test steps:
1. Add config and update kernel:CONFIG_FAIL_MMC_REQUEST=yCONFIG_FAULT_INJECTION=yCONFIG_FAULT_INJECTION_DEBUG_FS=y
2. Run simulate fail:
cd /sys/kernel/debug/mmc1/fail_mmc_request
echo 10 > probability
echo 10 > times # repeat until hitting issues
3. It happened payload length exceeds max htc length.
[ 199.935506] ath10k_sdio mmc1:0001:1: payload length 57005 exceeds max htc length: 4088 .... [ 264.990191] ath10k_sdio mmc1:0001:1: payload length 57005 exceeds max htc length: 4088
4. after some time, such as 60 seconds, it start recovery which triggered by wmi command timeout for periodic scan.
[ 269.229232] ieee80211 phy0: Hardware restart was requested [ 269.734693] ath10k_sdio mmc1:0001:1: device successfully recovered
The simulate fail of sdio is not a real sdio transter fail, it only set an error status in mmc_should_fail_request after the transfer end, actually the transfer is success, then sdio_io_rw_ext_helper will return error status and stop transfer the left data. For example, the really RX len is 286 bytes, then it will split to 2 blocks in sdio_io_rw_ext_helper, one is 256 bytes, left is 30 bytes, if the first 256 bytes get an error status by mmc_should_fail_request,then the left 30 bytes will not read in this RX operation. Then when the next RX arrive, the left 30 bytes will be considered as the header of the read, the top 4 bytes of the 30 bytes will be considered as lookaheads, but actually the 4 bytes is not the lookaheads, so the len from this lookaheads is not correct, it exceeds max htc length 4088 sometimes. When happened exceeds, the buffer chain is not matched between firmware and ath10k, then it need to start recovery ASAP. Recently then recovery will be started by wmi command timeout, but it will be long time later, for example, it is 60+ seconds later from the periodic scan, if it does not have periodic scan, it will be longer.
Start recovery when it happened "payload length exceeds max htc length" will be reasonable.
This patch only effect sdio chips.
Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029.
--- drivers/net/wireless/ath/ath10k/sdio.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath10k/sdio.c +4 -0
@@ -550,6 +550,10 @@ static int ath10k_sdio_mbox_rx_alloc(struct ath10k *ar,le16_to_cpu (htc_hdr->len), ATH10K_HTC_MBOX_MAX_PAYLOAD_LENGTH); ret = -ENOMEM ; + +queue_work (ar->workqueue, &ar->restart_work); +ath10k_warn (ar,"exceeds length, start recovery\n" ); + goto err; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 66/214 brcmfmac: Fix warning message after dongle setup failed
In reply to Greg Kroah-HartmanFrom: Wright Feng <[email protected]>
[ Upstream commit 6aa5a83a7ed8036c1388a811eb8bdfa77b21f19c ]
Brcmfmac showed warning message in fweh.c when checking the size of event queue which is not initialized. Therefore, we only cancel the worker and reset event handler only when it is initialized.
[ 145.505899] brcmfmac 0000:02:00.0: brcmf_pcie_setup: Dongle setup [ 145.929970] ------------[ cut here ]------------ [ 145.929994] WARNING: CPU: 0 PID: 288 at drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c:312 brcmf_fweh_detach+0xbc/0xd0 [brcmfmac] ... [ 145.930029] Call Trace: [ 145.930036] brcmf_detach+0x77/0x100 [brcmfmac] [ 145.930043] brcmf_pcie_remove+0x79/0x130 [brcmfmac] [ 145.930046] pci_device_remove+0x39/0xc0 [ 145.930048] device_release_driver_internal+0x141/0x200 [ 145.930049] device_release_driver+0x12/0x20 [ 145.930054] brcmf_pcie_setup+0x101/0x3c0 [brcmfmac] [ 145.930060] brcmf_fw_request_done+0x11d/0x1f0 [brcmfmac] [ 145.930062] ? lock_timer_base+0x7d/0xa0 [ 145.930063] ? internal_add_timer+0x1f/0xa0 [ 145.930064] ? add_timer+0x11a/0x1d0 [ 145.930066] ? __kmalloc_track_caller+0x18c/0x230 [ 145.930068] ? kstrdup_const+0x23/0x30 [ 145.930069] ? add_dr+0x46/0x80 [ 145.930070] ? devres_add+0x3f/0x50 [ 145.930072] ? usermodehelper_read_unlock+0x15/0x20 [ 145.930073] ? _request_firmware+0x288/0xa20 [ 145.930075] request_firmware_work_func+0x36/0x60 [ 145.930077] process_one_work+0x144/0x360 [ 145.930078] worker_thread+0x4d/0x3c0 [ 145.930079] kthread+0x112/0x150 [ 145.930080] ? rescuer_thread+0x340/0x340 [ 145.930081] ? kthread_park+0x60/0x60 [ 145.930083] ret_from_fork+0x25/0x30
--- .../net/wireless/broadcom/brcm80211/brcmfmac/fweh.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c +6 -4
@@ -304,10 +304,12 @@ void brcmf_fweh_detach(struct brcmf_pub *drvr) {struct brcmf_fweh_info *fweh = &drvr->fweh; -/* cancel the worker */ -cancel_work_sync (&fweh->event_work); -WARN_ON (!list_empty (&fweh->event_q)); -memset (fweh->evt_handler,0 ,sizeof (fweh->evt_handler)); +/* cancel the worker if initialized */ +if (fweh->event_work.func) { +cancel_work_sync (&fweh->event_work); +WARN_ON (!list_empty (&fweh->event_q)); +memset (fweh->evt_handler,0 ,sizeof (fweh->evt_handler)); + } }/**
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 35/214 video: fbdev: pvr2fb: initialize variables
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit 8e1ba47c60bcd325fdd097cd76054639155e5d2e ]
clang static analysis reports this repesentative error
pvr2fb.c:1049:2: warning: 1st function call argument
is an uninitialized value [core.CallAndMessage]
if (*cable_arg)
^~~~~~~~~~~~~~~Problem is that cable_arg depends on the input loop to set the cable_arg[0]. If it does not, then some random value from the stack is used.
A similar problem exists for output_arg.
So initialize cable_arg and output_arg.
--- drivers/video/fbdev/pvr2fb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/pvr2fb.c +2 -0
@@ -1016,6 +1016,8 @@ static int __init pvr2fb_setup(char *options)if (!options || !*options)return 0 ; + cable_arg[0 ] = output_arg[0 ] =0 ; +while ((this_opt =strsep (&options,"," ))) {if (!*this_opt)continue ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 69/214 ACPI: HMAT: Fix handling of changes from ACPI 6.2 to ACPI 6.3
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
[ Upstream commit 2c5b9bde95c96942f2873cea6ef383c02800e4a8 ]
In ACPI 6.3, the Memory Proximity Domain Attributes Structure changed substantially. One of those changes was that the flag for "Memory Proximity Domain field is valid" was deprecated.
This was because the field "Proximity Domain for the Memory" became a required field and hence having a validity flag makes no sense.
So the correct logic is to always assume the field is there. Current code assumes it never is.
--- drivers/acpi/hmat/hmat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/hmat/hmat.c +2 -1
@@ -403,7 +403,8 @@ static int __init hmat_parse_proximity_domain(union acpi_subtable_headers *headepr_info ("HMAT: Memory Flags:%04x Processor Domain:%d Memory Domain:%d\n" , p->flags, p->processor_PD, p->memory_PD); -if (p->flags &ACPI_HMAT_MEMORY_PD_VALID && hmat_revision ==1 ) { +if ((hmat_revision ==1 && p->flags &ACPI_HMAT_MEMORY_PD_VALID ) || + hmat_revision >1 ) { target =find_mem_target (p->memory_PD);if (!target) {pr_debug ("HMAT: Memory Domain missing from SRAT\n" );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 68/214 bus/fsl_mc: Do not rely on caller to provide non NULL mc_io
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
[ Upstream commit 5026cf605143e764e1785bbf9158559d17f8d260 ]
Before destroying the mc_io, check first that it was allocated.
--- drivers/bus/fsl-mc/mc-io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/bus/fsl-mc/mc-io.c +6 -1
@@ -129,7 +129,12 @@ error_destroy_mc_io:*/ void fsl_destroy_mc_io (struct fsl_mc_io *mc_io) { -struct fsl_mc_device *dpmcp_dev = mc_io->dpmcp_dev; +struct fsl_mc_device *dpmcp_dev; + +if (!mc_io) +return ; + + dpmcp_dev = mc_io->dpmcp_dev;if (dpmcp_dev)fsl_mc_io_unset_dpmcp (mc_io);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 67/214 drivers/net/wan/hdlc_fr: Correctly handle special skb->protocol values
In reply to Greg Kroah-HartmanFrom: Xie He <[email protected]>
[ Upstream commit 8306266c1d51aac9aa7aa907fe99032a58c6382c ]
The fr_hard_header function is used to prepend the header to skbs before transmission. It is used in 3 situations:
1) When a control packet is generated internally in this driver;
2) When a user sends an skb on an Ethernet-emulating PVC device;
3) When a user sends an skb on a normal PVC device.
These 3 situations need to be handled differently by fr_hard_header. Different headers should be prepended to the skb in different situations.
Currently fr_hard_header distinguishes these 3 situations using skb->protocol. For situation 1 and 2, a special skb->protocol value will be assigned before calling fr_hard_header, so that it can recognize these 2 situations. All skb->protocol values other than these special ones are treated by fr_hard_header as situation 3.
However, it is possible that in situation 3, the user sends an skb with one of the special skb->protocol values. In this case, fr_hard_header would incorrectly treat it as situation 1 or 2.
This patch tries to solve this issue by using skb->dev instead of skb->protocol to distinguish between these 3 situations. For situation 1, skb->dev would be NULL; for situation 2, skb->dev->type would be ARPHRD_ETHER; and for situation 3, skb->dev->type would be ARPHRD_DLCI.
This way fr_hard_header would be able to distinguish these 3 situations correctly regardless what skb->protocol value the user tries to use in situation 3.
--- drivers/net/wan/hdlc_fr.c | 98 ++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 47 deletions(-)
drivers/net/wan/hdlc_fr.c +51 -47
@@ -273,63 +273,69 @@ static inline struct net_device **get_dev_p(struct pvc_device *pvc,static int fr_hard_header (struct sk_buff **skb_p,u16 dlci) { -u16 head_len;struct sk_buff *skb = *skb_p; -switch (skb->protocol) { -case cpu_to_be16 (NLPID_CCITT_ANSI_LMI ): - head_len =4 ; -skb_push (skb, head_len); - skb->data[3 ] =NLPID_CCITT_ANSI_LMI ; -break ; - -case cpu_to_be16 (NLPID_CISCO_LMI ): - head_len =4 ; -skb_push (skb, head_len); - skb->data[3 ] =NLPID_CISCO_LMI ; -break ; - -case cpu_to_be16 (ETH_P_IP ): - head_len =4 ; -skb_push (skb, head_len); - skb->data[3 ] =NLPID_IP ; -break ; - -case cpu_to_be16 (ETH_P_IPV6 ): - head_len =4 ; -skb_push (skb, head_len); - skb->data[3 ] =NLPID_IPV6 ; -break ; - -case cpu_to_be16 (ETH_P_802_3 ): - head_len =10 ; -if (skb_headroom (skb) < head_len) { -struct sk_buff *skb2 =skb_realloc_headroom (skb, - head_len); +if (!skb->dev) {/* Control packets */ +switch (dlci) { +case LMI_CCITT_ANSI_DLCI : +skb_push (skb,4 ); + skb->data[3 ] =NLPID_CCITT_ANSI_LMI ; +break ; + +case LMI_CISCO_DLCI : +skb_push (skb,4 ); + skb->data[3 ] =NLPID_CISCO_LMI ; +break ; + +default : +return -EINVAL ; + } + + }else if (skb->dev->type ==ARPHRD_DLCI ) { +switch (skb->protocol) { +case htons (ETH_P_IP ): +skb_push (skb,4 ); + skb->data[3 ] =NLPID_IP ; +break ; + +case htons (ETH_P_IPV6 ): +skb_push (skb,4 ); + skb->data[3 ] =NLPID_IPV6 ; +break ; + +default : +skb_push (skb,10 ); + skb->data[3 ] =FR_PAD ; + skb->data[4 ] =NLPID_SNAP ; +/* OUI 00-00-00 indicates an Ethertype follows */ + skb->data[5 ] =0x00 ; + skb->data[6 ] =0x00 ; + skb->data[7 ] =0x00 ; +/* This should be an Ethertype: */ + *(__be16 *)(skb->data +8 ) = skb->protocol; + } + + }else if (skb->dev->type ==ARPHRD_ETHER ) { +if (skb_headroom (skb) <10 ) { +struct sk_buff *skb2 =skb_realloc_headroom (skb,10 );if (!skb2)return -ENOBUFS ;dev_kfree_skb (skb); skb = *skb_p = skb2; } -skb_push (skb, head_len); +skb_push (skb,10 ); skb->data[3 ] =FR_PAD ; skb->data[4 ] =NLPID_SNAP ; - skb->data[5 ] =FR_PAD ; +/* OUI 00-80-C2 stands for the 802.1 organization */ + skb->data[5 ] =0x00 ; skb->data[6 ] =0x80 ; skb->data[7 ] =0xC2 ; +/* PID 00-07 stands for Ethernet frames without FCS */ skb->data[8 ] =0x00 ; - skb->data[9 ] =0x07 ;/* bridged Ethernet frame w/out FCS */ -break ; + skb->data[9 ] =0x07 ; -default : - head_len =10 ; -skb_push (skb, head_len); - skb->data[3 ] =FR_PAD ; - skb->data[4 ] =NLPID_SNAP ; - skb->data[5 ] =FR_PAD ; - skb->data[6 ] =FR_PAD ; - skb->data[7 ] =FR_PAD ; - *(__be16 *)(skb->data +8 ) = skb->protocol; + }else { +return -EINVAL ; }dlci_to_q922 (skb->data, dlci);
@@ -425,8 +431,8 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)skb_put (skb, pad);memset (skb->data + len,0 , pad); } - skb->protocol =cpu_to_be16 (ETH_P_802_3 ); } + skb->dev = dev;if (!fr_hard_header (&skb, pvc->dlci)) { dev->stats.tx_bytes += skb->len; dev->stats.tx_packets++;
@@ -494,10 +500,8 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)memset (skb->data,0 , len);skb_reserve (skb,4 );if (lmi ==LMI_CISCO ) { - skb->protocol =cpu_to_be16 (NLPID_CISCO_LMI );fr_hard_header (&skb,LMI_CISCO_DLCI ); }else { - skb->protocol =cpu_to_be16 (NLPID_CCITT_ANSI_LMI );fr_hard_header (&skb,LMI_CCITT_ANSI_DLCI ); } data =skb_tail_pointer (skb);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 63/214 can: flexcan: disable clocks during stop mode
In reply to Greg Kroah-HartmanFrom: Joakim Zhang <[email protected]>
[ Upstream commit 02f71c6605e1f8259c07f16178330db766189a74 ]
Disable clocks while CAN core is in stop mode.
--- drivers/net/can/flexcan.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/net/can/flexcan.c +20 -10
@@ -1703,8 +1703,6 @@ static int __maybe_unused flexcan_suspend(struct device *device) err =flexcan_chip_disable (priv);if (err)return err; - - err =pm_runtime_force_suspend (device); }netif_stop_queue (dev);netif_device_detach (dev);
@@ -1730,10 +1728,6 @@ static int __maybe_unused flexcan_resume(struct device *device)if (err)return err; }else { - err =pm_runtime_force_resume (device); -if (err) -return err; - err =flexcan_chip_enable (priv); } }
@@ -1764,8 +1758,16 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device)struct net_device *dev =dev_get_drvdata (device);struct flexcan_priv *priv =netdev_priv (dev); -if (netif_running (dev) &&device_may_wakeup (device)) -flexcan_enable_wakeup_irq (priv, true); +if (netif_running (dev)) { +int err; + +if (device_may_wakeup (device)) +flexcan_enable_wakeup_irq (priv, true); + + err =pm_runtime_force_suspend (device); +if (err) +return err; + }return 0 ; }
@@ -1775,8 +1777,16 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device)struct net_device *dev =dev_get_drvdata (device);struct flexcan_priv *priv =netdev_priv (dev); -if (netif_running (dev) &&device_may_wakeup (device)) -flexcan_enable_wakeup_irq (priv, false); +if (netif_running (dev)) { +int err; + + err =pm_runtime_force_resume (device); +if (err) +return err; + +if (device_may_wakeup (device)) +flexcan_enable_wakeup_irq (priv, false); + }return 0 ; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 62/214 arm64/mm: return cpu_all_mask when node is NUMA_NO_NODE
In reply to Greg Kroah-HartmanFrom: Zhengyuan Liu <[email protected]>
[ Upstream commit a194c5f2d2b3a05428805146afcabe5140b5d378 ]
The @node passed to cpumask_of_node() can be NUMA_NO_NODE, in that case it will trigger the following WARN_ON(node >= nr_node_ids) due to mismatched data types of @node and @nr_node_ids. Actually we should return cpu_all_mask just like most other architectures do if passed NUMA_NO_NODE.
Also add a similar check to the inline cpumask_of_node() in numa.h.
--- arch/arm64/include/asm/numa.h | 3 +++ arch/arm64/mm/numa.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-)
arch/arm64/include/asm/numa.h +3 -0
@@ -25,6 +25,9 @@ const struct cpumask *cpumask_of_node(int node);/* Returns a pointer to the cpumask of CPUs on Node 'node'. */ static inline const struct cpumask *cpumask_of_node (int node) { +if (node ==NUMA_NO_NODE ) +return cpu_all_mask; +return node_to_cpumask_map[node]; }#endif
arch/arm64/mm/numa.c +5 -1
@@ -46,7 +46,11 @@ EXPORT_SYMBOL(node_to_cpumask_map);*/ const struct cpumask *cpumask_of_node (int node) { -if (WARN_ON (node >= nr_node_ids)) + +if (node ==NUMA_NO_NODE ) +return cpu_all_mask; + +if (WARN_ON (node <0 || node >= nr_node_ids))return cpu_none_mask;if (WARN_ON (node_to_cpumask_map[node] ==NULL ))
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 57/214 USB: adutux: fix debugging
In reply to Greg Kroah-HartmanFrom: Oliver Neukum <[email protected]>
[ Upstream commit c56150c1bc8da5524831b1dac2eec3c67b89f587 ]
Handling for removal of the controller was missing at one place. Add it.
--- drivers/usb/misc/adutux.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/misc/adutux.c +1 -0
@@ -209,6 +209,7 @@ static void adu_interrupt_out_callback(struct urb *urb)if (status !=0 ) {if ((status != -ENOENT ) && + (status != -ESHUTDOWN ) && (status != -ECONNRESET )) { dev_dbg(&dev->udev->dev, "%s :nonzero status received: %d\n", __func__,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 51/214 bpf: Permit map_ptr arithmetic with opcode add and offset 0
In reply to Greg Kroah-HartmanFrom: Yonghong Song <[email protected]>
[ Upstream commit 7c6967326267bd5c0dded0a99541357d70dd11ac ]
Commit 41c48f3a98231 ("bpf: Support access
to bpf map fields") added support to access map fields with CORE support. For example,
struct bpf_map {
__u32 max_entries;
} __attribute__((preserve_access_index));
struct bpf_array {
struct bpf_map map;
__u32 elem_size;
} __attribute__((preserve_access_index));
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 4);
__type(key, __u32);
__type(value, __u32);
} m_array SEC(".maps");
SEC("cgroup_skb/egress")
int cg_skb(void *ctx)
{
struct bpf_array *array = (struct bpf_array *)&m_array;
/* .. array->map.max_entries .. */
}In kernel, bpf_htab has similar structure,
struct bpf_htab {
struct bpf_map map;
...
}In the above cg_skb(), to access array->map.max_entries, with CORE, the clang will generate two builtin's.
base = &m_array;
/* access array.map */
map_addr = __builtin_preserve_struct_access_info(base, 0, 0);
/* access array.map.max_entries */
max_entries_addr = __builtin_preserve_struct_access_info(map_addr, 0, 0);
max_entries = *max_entries_addr;In the current llvm, if two builtin's are in the same function or
in the same function after inlining, the compiler is smart enough to chain them together and generates like below:
base = &m_array;
max_entries = *(base + reloc_offset); /* reloc_offset = 0 in this case */
and we are fine.
But if we force no inlining for one of functions in test_map_ptr() selftest, e.g., check_default(), the above two __builtin_preserve_* will be in two different functions. In this case, we will have code like:
func check_hash():
reloc_offset_map = 0;
base = &m_array;
map_base = base + reloc_offset_map;
check_default(map_base, ...)
func check_default(map_base, ...):
max_entries = *(map_base + reloc_offset_max_entries);In kernel, map_ptr (CONST_PTR_TO_MAP) does not allow any arithmetic.
The above "map_base = base + reloc_offset_map" will trigger a verifier failure.
; VERIFY(check_default(&hash->map, map));
0: (18) r7 = 0xffffb4fe8018a004
2: (b4) w1 = 110
3: (63) *(u32 *)(r7 +0) = r1
R1_w=invP110 R7_w=map_value(id=0,off=4,ks=4,vs=8,imm=0) R10=fp0
; VERIFY_TYPE(BPF_MAP_TYPE_HASH, check_hash);
4: (18) r1 = 0xffffb4fe8018a000
6: (b4) w2 = 1
7: (63) *(u32 *)(r1 +0) = r2
R1_w=map_value(id=0,off=0,ks=4,vs=8,imm=0) R2_w=invP1 R7_w=map_value(id=0,off=4,ks=4,vs=8,imm=0) R10=fp0
8: (b7) r2 = 0
9: (18) r8 = 0xffff90bcb500c000
11: (18) r1 = 0xffff90bcb500c000
13: (0f) r1 += r2
R1 pointer arithmetic on map_ptr prohibited
To fix the issue, let us permit map_ptr + 0 arithmetic which will result in exactly the same map_ptr.
--- kernel/bpf/verifier.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/bpf/verifier.c +4 -0
@@ -4427,6 +4427,10 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, dst, reg_type_str[ptr_reg->type]);return -EACCES ;case CONST_PTR_TO_MAP : +/* smin_val represents the known value */ +if (known && smin_val ==0 && opcode ==BPF_ADD ) +break ; +/* fall-through */ case PTR_TO_PACKET_END :case PTR_TO_SOCKET :case PTR_TO_SOCKET_OR_NULL :
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 52/214 media: uvcvideo: Fix dereference of out-of-bound list iterator
In reply to Greg Kroah-HartmanFrom: Daniel W. S. Almeida <[email protected]>
[ Upstream commit f875bcc375c738bf2f599ff2e1c5b918dbd07c45 ]
Fixes the following coccinelle report:
drivers/media/usb/uvc/uvc_ctrl.c:1860:5-11:
ERROR: invalid reference to the index variable of the iterator on line 1854
by adding a boolean variable to check if the loop has found the
Found using - Coccinelle (http://coccinelle.lip6.fr)
[Replace cursor variable with bool found]
--- drivers/media/usb/uvc/uvc_ctrl.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +9 -4
@@ -1848,30 +1848,35 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain, {struct uvc_entity *entity;struct uvc_control *ctrl; -unsigned int i, found =0 ; +unsigned int i; +bool found;u32 reqflags;u16 size;u8 *data =NULL ;int ret;/* Find the extension unit. */ + found = false;list_for_each_entry (entity, &chain->entities, chain) {if (UVC_ENTITY_TYPE (entity) ==UVC_VC_EXTENSION_UNIT && - entity->id == xqry->unit) + entity->id == xqry->unit) { + found = true;break ; + } } -if (entity->id != xqry->unit) { +if (!found) {uvc_trace (UVC_TRACE_CONTROL ,"Extension unit %u not found.\n" , xqry->unit);return -ENOENT ; }/* Find the control and perform delayed initialization if needed. */ + found = false;for (i =0 ; i < entity->ncontrols; ++i) { ctrl = &entity->controls[i];if (ctrl->index == xqry->selector -1 ) { - found =1 ; + found = true;break ; } }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 32/214 NFS4: Fix oops when copy_file_range is attempted with NFS4.0 source
In reply to Greg Kroah-HartmanFrom: Dave Wysochanski <[email protected]>
[ Upstream commit d8a6ad913c286d4763ae20b14c02fe6f39d7cd9f ]
The following oops is seen during xfstest/565 when the 'test' (source of the copy) is NFS4.0 and 'scratch' (destination) is NFS4.2
[ 59.692458] run fstests generic/565 at 2020-08-01 05:50:35 [ 60.613588] BUG: kernel NULL pointer dereference, address: 0000000000000008 [ 60.624970] #PF: supervisor read access in kernel mode [ 60.627671] #PF: error_code(0x0000) - not-present page [ 60.630347] PGD 0 P4D 0 [ 60.631853] Oops: 0000 [#1] SMP PTI [ 60.634086] CPU: 6 PID: 2828 Comm: xfs_io Kdump: loaded Not tainted 5.8.0-rc3 #1 [ 60.637676] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 [ 60.639901] RIP: 0010:nfs4_check_serverowner_major_id+0x5/0x30 [nfsv4] [ 60.642719] Code: 89 ff e8 3e b3 b8 e1 e9 71 fe ff ff 41 bc da d8 ff ff e9 c3 fe ff ff e8 e9 9d 08 e2 66 0f 1f 84 00 00 00 00 00 66 66 66 66 90 <8b> 57 08 31 c0 3b 56 08 75 12 48 83 c6 0c 48 83 c7 0c e8 c4 97 bb [ 60.652629] RSP: 0018:ffffc265417f7e10 EFLAGS: 00010287 [ 60.655379] RAX: ffffa0664b066400 RBX: 0000000000000000 RCX: 0000000000000001 [ 60.658754] RDX: ffffa066725fb000 RSI: ffffa066725fd000 RDI: 0000000000000000 [ 60.662292] RBP: 0000000000020000 R08: 0000000000020000 R09: 0000000000000000 [ 60.666189] R10: 0000000000000003 R11: 0000000000000000 R12: ffffa06648258d00 [ 60.669914] R13: 0000000000000000 R14: 0000000000000000 R15: ffffa06648258100 [ 60.673645] FS: 00007faa9fb35800(0000) GS:ffffa06677d80000(0000) knlGS:0000000000000000 [ 60.677698] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 60.680773] CR2: 0000000000000008 CR3: 0000000203f14000 CR4: 00000000000406e0 [ 60.684476] Call Trace: [ 60.685809] nfs4_copy_file_range+0xfc/0x230 [nfsv4] [ 60.688704] vfs_copy_file_range+0x2ee/0x310 [ 60.691104] __x64_sys_copy_file_range+0xd6/0x210 [ 60.693527] do_syscall_64+0x4d/0x90 [ 60.695512] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 60.698006] RIP: 0033:0x7faa9febc1bd
--- fs/nfs/nfs4file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/nfs4file.c +2 -1
@@ -138,7 +138,8 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in,/* Only offload copy if superblock is the same */ if (file_inode (file_in)->i_sb !=file_inode (file_out)->i_sb)return -EXDEV ; -if (!nfs_server_capable (file_inode (file_out),NFS_CAP_COPY )) +if (!nfs_server_capable (file_inode (file_out),NFS_CAP_COPY ) || + !nfs_server_capable (file_inode (file_in),NFS_CAP_COPY ))return -EOPNOTSUPP ;if (file_inode (file_in) ==file_inode (file_out))return -EOPNOTSUPP ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 47/214 arm64: topology: Stop using MPIDR for topology information
In reply to Greg Kroah-HartmanFrom: Valentin Schneider <[email protected]>
[ Upstream commit 3102bc0e6ac752cc5df896acb557d779af4d82a1 ]
In the absence of ACPI or DT topology data, we fallback to haphazardly decoding *something* out of MPIDR. Sadly, the contents of that register are mostly unusable due to the implementation leniancy and things like Aff0 having to be capped to 15 (despite being encoded on 8 bits).
Consider a simple system with a single package of 32 cores, all under the same LLC. We ought to be shoving them in the same core_sibling mask, but MPIDR is going to look like:
| CPU | 0 | ... | 15 | 16 | ... | 31 | |------+---+-----+----+----+-----+----+ | Aff0 | 0 | ... | 15 | 0 | ... | 15 | | Aff1 | 0 | ... | 0 | 1 | ... | 1 | | Aff2 | 0 | ... | 0 | 0 | ... | 0 |
Which will eventually yield
core_sibling(0-15) == 0-15
core_sibling(16-31) == 16-31
NUMA woes
=========
If we try to play games with this and set up NUMA boundaries within those groups of 16 cores via e.g. QEMU:
# Node0: 0-9; Node1: 10-19
$ qemu-system-aarch64 <blah> \
-smp 20 -numa node,cpus=0-9,nodeid=0 -numa node,cpus=10-19,nodeid=1The scheduler's MC domain (all CPUs with same LLC) is going to be built via
arch_topology.c::cpu_coregroup_mask()
In there we try to figure out a sensible mask out of the topology information we have. In short, here we'll pick the smallest of NUMA or core sibling mask.
node_mask(CPU9) == 0-9
core_sibling(CPU9) == 0-15
MC mask for CPU9 will thus be 0-9, not a problem.
node_mask(CPU10) == 10-19
core_sibling(CPU10) == 0-15
MC mask for CPU10 will thus be 10-19, not a problem.
node_mask(CPU16) == 10-19
core_sibling(CPU16) == 16-19
MC mask for CPU16 will thus be 16-19... Uh oh. CPUs 16-19 are in two different unique MC spans, and the scheduler has no idea what to make of that. That triggers the WARN_ON() added by commit
ccf74128d66c ("sched/topology: Assert non-NUMA topology masks don't (partially) overlap")
Fixing MPIDR-derived topology
=============================
We could try to come up with some cleverer scheme to figure out which of the available masks to pick, but really if one of those masks resulted from MPIDR then it should be discarded because it's bound to be bogus.
I was hoping to give MPIDR a chance for SMT, to figure out which threads are in the same core using Aff1-3 as core ID, but Sudeep and Robin pointed out to me that there are systems out there where *all* cores have non-zero values in their higher affinity fields (e.g. RK3288 has "5" in all of its cores' MPIDR.Aff1), which would expose a bogus core ID to userspace.
Stop using MPIDR for topology information. When no other source of topology information is available, mark each CPU as its own core and its NUMA node as its LLC domain.
--- arch/arm64/kernel/topology.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
arch/arm64/kernel/topology.c +17 -15
@@ -35,21 +35,23 @@ void store_cpu_topology(unsigned int cpuid)if (mpidr &MPIDR_UP_BITMASK )return ; -/* Create cpu topology mapping based on MPIDR. */ -if (mpidr &MPIDR_MT_BITMASK ) { -/* Multiprocessor system : Multi-threads per core */ - cpuid_topo->thread_id =MPIDR_AFFINITY_LEVEL (mpidr,0 ); - cpuid_topo->core_id =MPIDR_AFFINITY_LEVEL (mpidr,1 ); - cpuid_topo->package_id =MPIDR_AFFINITY_LEVEL (mpidr,2 ) | -MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<8 ; - }else { -/* Multiprocessor system : Single-thread per core */ - cpuid_topo->thread_id =-1 ; - cpuid_topo->core_id =MPIDR_AFFINITY_LEVEL (mpidr,0 ); - cpuid_topo->package_id =MPIDR_AFFINITY_LEVEL (mpidr,1 ) | -MPIDR_AFFINITY_LEVEL (mpidr,2 ) <<8 | -MPIDR_AFFINITY_LEVEL (mpidr,3 ) <<16 ; - } +/* +* This would be the place to create cpu topology based on MPIDR. +* +* However, it cannot be trusted to depict the actual topology; some +* pieces of the architecture enforce an artificial cap on Aff0 values +* (e.g. GICv3's ICC_SGI1R_EL1 limits it to 15), leading to an +* artificial cycling of Aff1, Aff2 and Aff3 values. IOW, these end up +* having absolutely no relationship to the actual underlying system +* topology, and cannot be reasonably used as core / package ID. +* +* If the MT bit is set, Aff0 *could* be used to define a thread ID, but +* we still wouldn't be able to obtain a sane core ID. This means we +* need to entirely ignore MPIDR for any topology deduction. +*/ + cpuid_topo->thread_id =-1 ; + cpuid_topo->core_id = cpuid; + cpuid_topo->package_id =cpu_to_node (cpuid); pr_debug("CPU%u: cluster %d core %d thread %d mpidr %#016llx\n", cpuid, cpuid_topo->package_id, cpuid_topo->core_id,
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 49/214 ia64: kprobes: Use generic kretprobe trampoline handler
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit e792ff804f49720ce003b3e4c618b5d996256a18 ]
Use the generic kretprobe trampoline handler. Don't use framepointer verification.
--- arch/ia64/kernel/kprobes.c | 77 +------------------------------------- 1 file changed, 2 insertions(+), 75 deletions(-)
arch/ia64/kernel/kprobes.c +2 -75
@@ -396,83 +396,9 @@ static void kretprobe_trampoline(void) { } -/* -* At this point the target function has been tricked into -* returning into our trampoline. Lookup the associated instance -* and then: -* - call the handler function -* - cleanup by marking the instance as unused -* - long jump back to the original return address -*/ int __kprobes trampoline_probe_handler (struct kprobe *p,struct pt_regs *regs) { -struct kretprobe_instance *ri =NULL ; -struct hlist_head *head, empty_rp; -struct hlist_node *tmp; -unsigned long flags, orig_ret_address =0 ; -unsigned long trampoline_address = - ((struct fnptr *)kretprobe_trampoline)->ip; - -INIT_HLIST_HEAD (&empty_rp); -kretprobe_hash_lock (current, &head, &flags); - -/* -* It is possible to have multiple instances associated with a given -* task either because an multiple functions in the call path -* have a return probe installed on them, and/or more than one return -* return probe was registered for a target function. -* -* We can handle this because: -* - instances are always inserted at the head of the list -* - when multiple return probes are registered for the same -* function, the first instance's ret_addr will point to the -* real return address, and all the rest will point to -* kretprobe_trampoline -*/ -hlist_for_each_entry_safe (ri, tmp, head, hlist) { -if (ri->task != current) -/* another task is sharing our hash bucket */ -continue ; - - orig_ret_address = (unsigned long )ri->ret_addr; -if (orig_ret_address != trampoline_address) -/* -* This is the real return address. Any other -* instances associated with this task are for -* other calls deeper on the call stack -*/ -break ; - } - - regs->cr_iip = orig_ret_address; - -hlist_for_each_entry_safe (ri, tmp, head, hlist) { -if (ri->task != current) -/* another task is sharing our hash bucket */ -continue ; - -if (ri->rp && ri->rp->handler) - ri->rp->handler (ri, regs); - - orig_ret_address = (unsigned long )ri->ret_addr; -recycle_rp_inst (ri, &empty_rp); - -if (orig_ret_address != trampoline_address) -/* -* This is the real return address. Any other -* instances associated with this task are for -* other calls deeper on the call stack -*/ -break ; - } -kretprobe_assert (ri, orig_ret_address, trampoline_address); - -kretprobe_hash_unlock (current, &flags); - -hlist_for_each_entry_safe (ri, tmp, &empty_rp, hlist) { -hlist_del (&ri->hlist); -kfree (ri); - } + regs->cr_iip =__kretprobe_trampoline_handler (regs, kretprobe_trampoline,NULL );/* * By returning a non-zero value, we are telling * kprobe_handler() that we don't want the post_handler
@@ -485,6 +411,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs) { ri->ret_addr = (kprobe_opcode_t *)regs->b0; + ri->fp =NULL ;/* Replace the return addr with trampoline addr */ regs->b0 = ((struct fnptr *)kretprobe_trampoline)->ip;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 42/214 usb: typec: tcpm: During PR_SWAP, source caps should be sent only after tSwapSourceStart
In reply to Greg Kroah-HartmanFrom: Badhri Jagan Sridharan <[email protected]>
[ Upstream commit 6bbe2a90a0bb4af8dd99c3565e907fe9b5e7fd88 ]
The patch addresses the compliance test failures while running TD.PD.CP.E3, TD.PD.CP.E4, TD.PD.CP.E5 of the "Deterministic PD Compliance MOI" test plan published in https://www.usb.org/usbc.
For a product to be Type-C compliant, it's expected that these tests are run on usb.org certified Type-C compliance tester as mentioned in
https://www.usb.org/usbc.
The purpose of the tests TD.PD.CP.E3, TD.PD.CP.E4, TD.PD.CP.E5 is to verify the PR_SWAP response of the device. While doing so, the test asserts that Source Capabilities message is NOT received from the test device within tSwapSourceStart min (20 ms) from the time the last bit of GoodCRC corresponding to the RS_RDY message sent by the UUT was sent. If it does then the test fails.
This is in line with the requirements from the USB Power Delivery Specification Revision 3.0, Version 1.2:
"6.6.8.1 SwapSourceStartTimer
The SwapSourceStartTimer Shall be used by the new Source, after a Power Role Swap or Fast Role Swap, to ensure that it does not send Source_Capabilities Message before the new Sink is ready to receive theSource_Capabilities Message. The new Source Shall Not send the Source_Capabilities Message earlier than tSwapSourceStart after the last bit of the EOP of GoodCRC Message sent in response to the PS_RDY Message sent by the new Source indicating that its power supply is ready."
The patch makes sure that TCPM does not send the Source_Capabilities Message within tSwapSourceStart(20ms) by transitioning into SRC_STARTUP only after tSwapSourceStart(20ms).
--- drivers/usb/typec/tcpm/tcpm.c | 2 +- include/linux/usb/pd.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -3482,7 +3482,7 @@ static void run_state_machine(struct tcpm_port *port)*/ tcpm_set_pwr_role (port,TYPEC_SOURCE );tcpm_pd_send_control (port,PD_CTRL_PS_RDY ); -tcpm_set_state (port,SRC_STARTUP ,0 ); +tcpm_set_state (port,SRC_STARTUP ,PD_T_SWAP_SRC_START );break ;case VCONN_SWAP_ACCEPT :
include/linux/usb/pd.h +1 -0
@@ -442,6 +442,7 @@ static inline unsigned int rdo_max_power(u32 rdo)#define PD_T_ERROR_RECOVERY 100/* minimum 25 is insufficient */ #define PD_T_SRCSWAPSTDBY 625/* Maximum of 650ms */ #define PD_T_NEWSRC 250/* Maximum of 275ms */ +#define PD_T_SWAP_SRC_START 20/* Minimum of 20ms */ #define PD_T_DRP_TRY 100/* 75 - 150 ms */ #define PD_T_DRP_TRYWAIT 600/* 400 - 800 ms */
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 46/214 drm/bridge/synopsys: dsi: add support for non-continuous HS clock
In reply to Greg Kroah-HartmanFrom: Antonio Borneo <[email protected]>
[ Upstream commit c6d94e37bdbb6dfe7e581e937a915ab58399b8a5 ]
Current code enables the HS clock when video mode is started or to send out a HS command, and disables the HS clock to send out a LP command. This is not what DSI spec specify.
Enable HS clock either in command and in video mode. Set automatic HS clock management for panels and devices that support non-continuous HS clock.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +7 -2
@@ -365,7 +365,6 @@ static void dw_mipi_message_config(struct dw_mipi_dsi *dsi,if (lpm) val |=CMD_MODE_ALL_LP ; -dsi_write (dsi,DSI_LPCLK_CTRL , lpm ?0 :PHY_TXREQUESTCLKHS );dsi_write (dsi,DSI_CMD_MODE_CFG , val); }
@@ -541,16 +540,22 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)static void dw_mipi_dsi_set_mode (struct dw_mipi_dsi *dsi,unsigned long mode_flags) { +u32 val; +dsi_write (dsi,DSI_PWR_UP ,RESET );if (mode_flags &MIPI_DSI_MODE_VIDEO ) {dsi_write (dsi,DSI_MODE_CFG ,ENABLE_VIDEO_MODE );dw_mipi_dsi_video_mode_config (dsi); -dsi_write (dsi,DSI_LPCLK_CTRL ,PHY_TXREQUESTCLKHS ); }else {dsi_write (dsi,DSI_MODE_CFG ,ENABLE_CMD_MODE ); } + val =PHY_TXREQUESTCLKHS ; +if (dsi->mode_flags &MIPI_DSI_CLOCK_NON_CONTINUOUS ) + val |=AUTO_CLKLANE_CTRL ; +dsi_write (dsi,DSI_LPCLK_CTRL , val); +dsi_write (dsi,DSI_PWR_UP ,POWERUP ); }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 45/214 mmc: via-sdmmc: Fix data race bug
In reply to Greg Kroah-HartmanFrom: Madhuparna Bhowmik <[email protected]>
[ Upstream commit 87d7ad089b318b4f319bf57f1daa64eb6d1d10ad ]
via_save_pcictrlreg() should be called with host->lock held as it writes to pm_pcictrl_reg, otherwise there can be a race condition between via_sd_suspend() and via_sdc_card_detect(). The same pattern is used in the function via_reset_pcictrl() as well, where via_save_pcictrlreg() is called with host->lock held.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/mmc/host/via-sdmmc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/via-sdmmc.c +3 -0
@@ -1259,11 +1259,14 @@ static void via_init_sdc_pm(struct via_crdr_mmc_host *host)static int via_sd_suspend (struct pci_dev *pcidev,pm_message_t state) {struct via_crdr_mmc_host *host; +unsigned long flags; host =pci_get_drvdata (pcidev); +spin_lock_irqsave (&host->lock, flags);via_save_pcictrlreg (host);via_save_sdcreg (host); +spin_unlock_irqrestore (&host->lock, flags);pci_save_state (pcidev);pci_enable_wake (pcidev,pci_choose_state (pcidev, state),0 );
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 44/214 media: imx274: fix frame interval handling
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 49b20d981d723fae5a93843c617af2b2c23611ec ]
1) the numerator and/or denominator might be 0, in that case fall back to the default frame interval. This is per the spec and this caused a v4l2-compliance failure.
2) the updated frame interval wasn't returned in the s_frame_interval subdev op.
--- drivers/media/i2c/imx274.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/media/i2c/imx274.c +5 -3
@@ -1235,6 +1235,8 @@ static int imx274_s_frame_interval(struct v4l2_subdev *sd, ret =imx274_set_frame_interval (imx274, fi->interval);if (!ret) { + fi->interval = imx274->frame_interval; +/* * exposure time range is decided by frame interval * need to update it after frame interval changes
@@ -1730,9 +1732,9 @@ static int imx274_set_frame_interval(struct stimx274 *priv, __func__, frame_interval.numerator, frame_interval.denominator); -if (frame_interval.numerator ==0 ) { - err = -EINVAL ; - goto fail; +if (frame_interval.numerator ==0 || frame_interval.denominator ==0 ) { + frame_interval.denominator =IMX274_DEF_FRAME_RATE ; + frame_interval.numerator =1 ; } req_frame_rate = (u32)(frame_interval.denominator
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 9/214 xen/pciback: use lateeoi irq binding
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit c2711441bc961b37bba0615dd7135857d189035f upstream.
In order to reduce the chance for the system becoming unresponsive due to event storms triggered by a misbehaving pcifront use the lateeoi irq binding for pciback and unmask the event channel only just before leaving the event handling function.
Restructure the handling to support that scheme. Basically an event can come in for two reasons: either a normal request for a pciback action, which is handled in a worker, or in case the guest has finished an AER request which was requested by pciback.
When an AER request is issued to the guest and a normal pciback action is currently active issue an EOI early in order to be able to receive another event when the AER request has been finished by the guest.
Let the worker processing the normal requests run until no further request is pending, instead of starting a new worker ion that case. Issue the EOI only just before leaving the worker.
This scheme allows to drop calling the generic function xen_pcibk_test_and_schedule_op() after processing of any request as the handling of both request types is now separated more cleanly.
This is part of XSA-332.
--- drivers/xen/xen-pciback/pci_stub.c | 14 ++++----- drivers/xen/xen-pciback/pciback.h | 12 +++++++- drivers/xen/xen-pciback/pciback_ops.c | 48 ++++++++++++++++++++++++++-------- drivers/xen/xen-pciback/xenbus.c | 2 - 4 files changed, 56 insertions(+), 20 deletions(-)
drivers/xen/xen-pciback/pci_stub.c +7 -7
@@ -733,10 +733,17 @@ static pci_ers_result_t common_process(swmb ();notify_remote_via_irq (pdev->evtchn_irq); +/* Enable IRQ to signal "request done". */ +xen_pcibk_lateeoi (pdev,0 ); + ret =wait_event_timeout (xen_pcibk_aer_wait_queue, !(test_bit (_XEN_PCIB_active, (unsigned long *) &sh_info->flags)),300 *HZ ); +/* Enable IRQ for pcifront request if not already active. */ +if (!test_bit (_PDEVF_op_active, &pdev->flags)) +xen_pcibk_lateeoi (pdev,0 ); +if (!ret) {if (test_bit (_XEN_PCIB_active, (unsigned long *)&sh_info->flags)) {
@@ -750,13 +757,6 @@ static pci_ers_result_t common_process(s }clear_bit (_PCIB_op_pending, (unsigned long *)&pdev->flags); -if (test_bit (_XEN_PCIF_active, - (unsigned long *)&sh_info->flags)) { -dev_dbg (&psdev->dev->dev, -"schedule pci_conf service in " DRV_NAME "\n" ); -xen_pcibk_test_and_schedule_op (psdev->pdev); - } - res = (pci_ers_result_t )aer_op->err;return res; }
drivers/xen/xen-pciback/pciback.h +10 -2
@@ -14,6 +14,7 @@#include <linux/spinlock.h> #include <linux/workqueue.h> #include <linux/atomic.h> +#include <xen/events.h> #include <xen/interface/io/pciif.h> #define DRV_NAME "xen-pciback"
@@ -27,6 +28,8 @@ struct pci_dev_entry {#define PDEVF_op_active (1<<(_PDEVF_op_active))#define _PCIB_op_pending (1)#define PCIB_op_pending (1<<(_PCIB_op_pending)) +#define _EOI_pending (2) +#define EOI_pending (1<<(_EOI_pending))struct xen_pcibk_device {void *pci_dev_data;
@@ -182,12 +185,17 @@ static inline void xen_pcibk_release_devirqreturn_t xen_pcibk_handle_event (int irq,void *dev_id);void xen_pcibk_do_op (struct work_struct *data); +static inline void xen_pcibk_lateeoi (struct xen_pcibk_device *pdev, +unsigned int eoi_flag) +{ +if (test_and_clear_bit (_EOI_pending, &pdev->flags)) +xen_irq_lateeoi (pdev->evtchn_irq, eoi_flag); +} +int xen_pcibk_xenbus_register (void );void xen_pcibk_xenbus_unregister (void );extern int verbose_request; - -void xen_pcibk_test_and_schedule_op (struct xen_pcibk_device *pdev);#endif /* Handles shared IRQs that can to device domain and control domain. */
drivers/xen/xen-pciback/pciback_ops.c +38 -10
90 lines not on this page · raw message
drivers/xen/xen-pciback/xenbus.c +1 -1
@@ -123,7 +123,7 @@ static int xen_pcibk_do_attach(struct xe pdev->sh_info = vaddr; - err =bind_interdomain_evtchn_to_irqhandler ( + err =bind_interdomain_evtchn_to_irqhandler_lateeoi ( pdev->xdev->otherend_id, remote_evtchn, xen_pcibk_handle_event,0 ,DRV_NAME , pdev);if (err <0 ) {
Greg Kroah-Hartman
maintainerPATCH 8/214 xen/pvcallsback: use lateeoi irq binding
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit c8d647a326f06a39a8e5f0f1af946eacfa1835f8 upstream.
In order to reduce the chance for the system becoming unresponsive due to event storms triggered by a misbehaving pvcallsfront use the lateeoi irq binding for pvcallsback and unmask the event channel only after handling all write requests, which are the ones coming in via an irq.
This requires modifying the logic a little bit to not require an event for each write request, but to keep the ioworker running until no further data is found on the ring page to be processed.
This is part of XSA-332.
--- drivers/xen/pvcalls-back.c | 76 +++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 30 deletions(-)
drivers/xen/pvcalls-back.c +46 -30
@@ -66,6 +66,7 @@ struct sock_mapping {atomic_t write;atomic_t io;atomic_t release; +atomic_t eoi;void (*saved_data_ready)(struct sock *sk);struct pvcalls_ioworker ioworker; };
@@ -87,7 +88,7 @@ static int pvcalls_back_release_active(sstruct pvcalls_fedata *fedata, struct sock_mapping *map); -static void pvcalls_conn_back_read (void *opaque) +static bool pvcalls_conn_back_read (void *opaque) {struct sock_mapping *map = (struct sock_mapping *)opaque;struct msghdr msg;
@@ -107,17 +108,17 @@ static void pvcalls_conn_back_read(voidvirt_mb ();if (error) -return ; +return false; size =pvcalls_queued (prod, cons, array_size);if (size >= array_size) -return ; +return false;spin_lock_irqsave (&map->sock->sk->sk_receive_queue.lock, flags);if (skb_queue_empty (&map->sock->sk->sk_receive_queue)) {atomic_set (&map->read,0 );spin_unlock_irqrestore (&map->sock->sk->sk_receive_queue.lock, flags); -return ; +return true; }spin_unlock_irqrestore (&map->sock->sk->sk_receive_queue.lock, flags); wanted = array_size - size;
@@ -141,7 +142,7 @@ static void pvcalls_conn_back_read(void ret =inet_recvmsg (map->sock, &msg, wanted,MSG_DONTWAIT );WARN_ON (ret > wanted);if (ret == -EAGAIN )/* shouldn't happen */ -return ; +return true;if (!ret) ret = -ENOTCONN ;spin_lock_irqsave (&map->sock->sk->sk_receive_queue.lock, flags);
@@ -160,10 +161,10 @@ static void pvcalls_conn_back_read(voidvirt_wmb ();notify_remote_via_irq (map->irq); -return ; +return true; } -static void pvcalls_conn_back_write (struct sock_mapping *map) +static bool pvcalls_conn_back_write (struct sock_mapping *map) {struct pvcalls_data_intf *intf = map->ring;struct pvcalls_data *data = &map->data;
@@ -180,7 +181,7 @@ static void pvcalls_conn_back_write(stru array_size =XEN_FLEX_RING_SIZE (map->ring_order); size =pvcalls_queued (prod, cons, array_size);if (size ==0 ) -return ; +return false;memset (&msg,0 ,sizeof (msg)); msg.msg_flags |=MSG_DONTWAIT ;
@@ -198,12 +199,11 @@ static void pvcalls_conn_back_write(struatomic_set (&map->write,0 ); ret =inet_sendmsg (map->sock, &msg, size); -if (ret == -EAGAIN || (ret >=0 && ret < size)) { +if (ret == -EAGAIN ) {atomic_inc (&map->write);atomic_inc (&map->io); +return true; } -if (ret == -EAGAIN ) -return ;/* write the data, then update the indexes */ virt_wmb ();
@@ -216,9 +216,13 @@ static void pvcalls_conn_back_write(stru }/* update the indexes, then notify the other end */ virt_wmb (); -if (prod != cons + ret) +if (prod != cons + ret) {atomic_inc (&map->write); +atomic_inc (&map->io); + }notify_remote_via_irq (map->irq); + +return true; }static void pvcalls_back_ioworker (struct work_struct *work)
@@ -227,6 +231,7 @@ static void pvcalls_back_ioworker(struct struct pvcalls_ioworker, register_work); struct sock_mapping *map = container_of(ioworker, struct sock_mapping, ioworker); +unsigned int eoi_flags =XEN_EOI_FLAG_SPURIOUS ;while (atomic_read (&map->io) >0 ) {if (atomic_read (&map->release) >0 ) {
@@ -234,10 +239,18 @@ static void pvcalls_back_ioworker(structreturn ; } -if (atomic_read (&map->read) >0 ) -pvcalls_conn_back_read (map); -if (atomic_read (&map->write) >0 ) -pvcalls_conn_back_write (map); +if (atomic_read (&map->read) >0 && +pvcalls_conn_back_read (map)) + eoi_flags =0 ; +if (atomic_read (&map->write) >0 && +pvcalls_conn_back_write (map)) + eoi_flags =0 ; + +if (atomic_read (&map->eoi) >0 && !atomic_read (&map->write)) { +atomic_set (&map->eoi,0 ); +xen_irq_lateeoi (map->irq, eoi_flags); + eoi_flags =XEN_EOI_FLAG_SPURIOUS ; + }atomic_dec (&map->io); }
@@ -334,12 +347,9 @@ static struct sock_mapping *pvcalls_new_ goto out; map->bytes = page; - ret =bind_interdomain_evtchn_to_irqhandler (fedata->dev->otherend_id, - evtchn, - pvcalls_back_conn_event, -0 , -"pvcalls-backend" , - map); + ret =bind_interdomain_evtchn_to_irqhandler_lateeoi ( + fedata->dev->otherend_id, evtchn, + pvcalls_back_conn_event,0 ,"pvcalls-backend" , map);if (ret <0 ) goto out; map->irq = ret;
@@ -873,15 +883,18 @@ static irqreturn_t pvcalls_back_event(in {struct xenbus_device *dev = dev_id;struct pvcalls_fedata *fedata =NULL ; +unsigned int eoi_flags =XEN_EOI_FLAG_SPURIOUS ; -if (dev ==NULL ) -return IRQ_HANDLED ; +if (dev) { + fedata =dev_get_drvdata (&dev->dev); +if (fedata) { +pvcalls_back_work (fedata); + eoi_flags =0 ; + } + } - fedata =dev_get_drvdata (&dev->dev); -if (fedata ==NULL ) -return IRQ_HANDLED ; +xen_irq_lateeoi (irq, eoi_flags); -pvcalls_back_work (fedata);return IRQ_HANDLED ; }
@@ -891,12 +904,15 @@ static irqreturn_t pvcalls_back_conn_evestruct pvcalls_ioworker *iow;if (map ==NULL || map->sock ==NULL || map->sock->sk ==NULL || - map->sock->sk->sk_user_data != map) + map->sock->sk->sk_user_data != map) { +xen_irq_lateeoi (irq,0 );return IRQ_HANDLED ; + } iow = &map->ioworker;atomic_inc (&map->write); +atomic_inc (&map->eoi);atomic_inc (&map->io);queue_work (iow->wq, &iow->register_work);
@@ -931,7 +947,7 @@ static int backend_connect(struct xenbus goto error; } - err =bind_interdomain_evtchn_to_irq (dev->otherend_id, evtchn); + err =bind_interdomain_evtchn_to_irq_lateeoi (dev->otherend_id, evtchn);if (err <0 ) goto error; fedata->irq = err;
Greg Kroah-Hartman
maintainerPATCH 7/214 xen/scsiback: use lateeoi irq binding
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit 86991b6e7ea6c613b7692f65106076943449b6b7 upstream.
In order to reduce the chance for the system becoming unresponsive due to event storms triggered by a misbehaving scsifront use the lateeoi irq binding for scsiback and unmask the event channel only just before leaving the event handling function.
In case of a ring protocol error don't issue an EOI in order to avoid the possibility to use that for producing an event storm. This at once will result in no further call of scsiback_irq_fn(), so the ring_error struct member can be dropped and scsiback_do_cmd_fn() can signal the protocol error via a negative return value.
This is part of XSA-332.
--- drivers/xen/xen-scsiback.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/xen/xen-scsiback.c +13 -10
@@ -91,7 +91,6 @@ struct vscsibk_info {unsigned int irq;struct vscsiif_back_ring ring; -int ring_error;spinlock_t ring_lock;atomic_t nr_unreplied_reqs;
@@ -722,7 +721,8 @@ static struct vscsibk_pend *prepare_pendreturn pending_req; } -static int scsiback_do_cmd_fn (struct vscsibk_info *info) +static int scsiback_do_cmd_fn (struct vscsibk_info *info, +unsigned int *eoi_flags) {struct vscsiif_back_ring *ring = &info->ring;struct vscsiif_request ring_req;
@@ -739,11 +739,12 @@ static int scsiback_do_cmd_fn(struct vsc rc = ring->rsp_prod_pvt;pr_warn ("Dom%d provided bogus ring requests (%#x - %#x = %u). Halting ring processing\n" , info->domid, rp, rc, rp - rc); - info->ring_error =1 ; -return 0 ; +return -EINVAL ; }while ((rc != rp)) { + *eoi_flags &= ~XEN_EOI_FLAG_SPURIOUS ; +if (RING_REQUEST_CONS_OVERFLOW (ring, rc))break ;
@@ -802,13 +803,16 @@ static int scsiback_do_cmd_fn(struct vscstatic irqreturn_t scsiback_irq_fn (int irq,void *dev_id) {struct vscsibk_info *info = dev_id; +int rc; +unsigned int eoi_flags =XEN_EOI_FLAG_SPURIOUS ; -if (info->ring_error) -return IRQ_HANDLED ; - -while (scsiback_do_cmd_fn (info)) +while ((rc =scsiback_do_cmd_fn (info, &eoi_flags)) >0 )cond_resched (); +/* In case of a ring error we keep the event channel masked. */ +if (!rc) +xen_irq_lateeoi (irq, eoi_flags); +return IRQ_HANDLED ; }
@@ -829,7 +833,7 @@ static int scsiback_init_sring(struct vs sring = (struct vscsiif_sring *)area;BACK_RING_INIT (&info->ring, sring,PAGE_SIZE ); - err =bind_interdomain_evtchn_to_irq (info->domid, evtchn); + err =bind_interdomain_evtchn_to_irq_lateeoi (info->domid, evtchn);if (err <0 ) goto unmap_page;
@@ -1252,7 +1256,6 @@ static int scsiback_probe(struct xenbus_ info->domid = dev->otherend_id;spin_lock_init (&info->ring_lock); - info->ring_error =0 ;atomic_set (&info->nr_unreplied_reqs,0 );init_waitqueue_head (&info->waiting_to_free); info->dev = dev;
Greg Kroah-Hartman
maintainerPATCH 41/214 media: platform: Improve queue set up flow for bug fixing
In reply to Greg Kroah-HartmanFrom: Xia Jiang <[email protected]>
[ Upstream commit 5095a6413a0cf896ab468009b6142cb0fe617e66 ]
Add checking created buffer size follow in mtk_jpeg_queue_setup().
--- drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +7 -0
@@ -571,6 +571,13 @@ static int mtk_jpeg_queue_setup(struct vb2_queue *q,if (!q_data)return -EINVAL ; +if (*num_planes) { +for (i =0 ; i < *num_planes; i++) +if (sizes[i] < q_data->sizeimage[i]) +return -EINVAL ; +return 0 ; + } + *num_planes = q_data->fmt->colplanes;for (i =0 ; i < q_data->fmt->colplanes; i++) { sizes[i] = q_data->sizeimage[i];
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 40/214 media: videodev2.h: RGB BT2020 and HSV are always full range
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit b305dfe2e93434b12d438434461b709641f62af4 ]
The default RGB quantization range for BT.2020 is full range (just as for all the other RGB pixel encodings), not limited range.
Update the V4L2_MAP_QUANTIZATION_DEFAULT macro and documentation accordingly.
Also mention that HSV is always full range and cannot be limited range.
When RGB BT2020 was introduced in V4L2 it was not clear whether it should be limited or full range, but full range is the right (and consistent) choice.
--- .../media/uapi/v4l/colorspaces-defs.rst | 9 ++++----- .../media/uapi/v4l/colorspaces-details.rst | 5 ++--- include/uapi/linux/videodev2.h | 17 ++++++++--------- 3 files changed, 14 insertions(+), 17 deletions(-)
Documentation/media/uapi/v4l/colorspaces-defs.rst +4 -5
@@ -36,8 +36,7 @@ whole range, 0-255, dividing the angular value by 1.41. The enum :c:type:`v4l2_hsv_encoding` specifies which encoding is used. .. note:: The default R'G'B' quantization is full range for all - colorspaces except for BT.2020 which uses limited range R'G'B' - quantization. + colorspaces. HSV formats are always full range. .. tabularcolumns:: |p{6.7cm}|p{10.8cm}|
@@ -169,8 +168,8 @@ whole range, 0-255, dividing the angular value by 1.41. The enum - Details * - ``V4L2_QUANTIZATION_DEFAULT`` - Use the default quantization encoding as defined by the - colorspace. This is always full range for R'G'B' (except for the - BT.2020 colorspace) and HSV. It is usually limited range for Y'CbCr. + colorspace. This is always full range for R'G'B' and HSV. + It is usually limited range for Y'CbCr. * - ``V4L2_QUANTIZATION_FULL_RANGE`` - Use the full range quantization encoding. I.e. the range [0…1] is mapped to [0…255] (with possible clipping to [1…254] to avoid the
@@ -180,4 +179,4 @@ whole range, 0-255, dividing the angular value by 1.41. The enum * - ``V4L2_QUANTIZATION_LIM_RANGE`` - Use the limited range quantization encoding. I.e. the range [0…1] is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to - [16…240]. + [16…240]. Limited Range cannot be used with HSV.
Documentation/media/uapi/v4l/colorspaces-details.rst +2 -3
@@ -377,9 +377,8 @@ Colorspace BT.2020 (V4L2_COLORSPACE_BT2020) The :ref:`itu2020` standard defines the colorspace used by Ultra-high definition television (UHDTV). The default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is -``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited -range (!), and so is the default Y'CbCr quantization. The chromaticities -of the primary colors and the white reference are: +``V4L2_YCBCR_ENC_BT2020``. The default Y'CbCr quantization is limited range. +The chromaticities of the primary colors and the white reference are:
include/uapi/linux/videodev2.h +8 -9
@@ -371,9 +371,9 @@ enum v4l2_hsv_encoding {enum v4l2_quantization {/* -* The default for R'G'B' quantization is always full range, except -* for the BT2020 colorspace. For Y'CbCr the quantization is always -* limited range, except for COLORSPACE_JPEG: this is full range. +* The default for R'G'B' quantization is always full range. +* For Y'CbCr the quantization is always limited range, except +* for COLORSPACE_JPEG: this is full range. */ V4L2_QUANTIZATION_DEFAULT =0 ,V4L2_QUANTIZATION_FULL_RANGE =1 ,
@@ -382,14 +382,13 @@ enum v4l2_quantization {/* * Determine how QUANTIZATION_DEFAULT should map to a proper quantization. -* This depends on whether the image is RGB or not, the colorspace and the -* Y'CbCr encoding. +* This depends on whether the image is RGB or not, the colorspace. +* The Y'CbCr encoding is not used anymore, but is still there for backwards +* compatibility. */ #define V4L2_MAP_QUANTIZATION_DEFAULT (is_rgb_or_hsv, colsp, ycbcr_enc) \ - (((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \ - V4L2_QUANTIZATION_LIM_RANGE : \ - (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \ - V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)) + (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \ + V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)/* * Deprecated names for opRGB colorspace (IEC 61966-2-5)
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 5/214 xen/blkback: use lateeoi irq binding
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit 01263a1fabe30b4d542f34c7e2364a22587ddaf2 upstream.
In order to reduce the chance for the system becoming unresponsive due to event storms triggered by a misbehaving blkfront use the lateeoi irq binding for blkback and unmask the event channel only after processing all pending requests.
As the thread processing requests is used to do purging work in regular intervals an EOI may be sent only after having received an event. If there was no pending I/O request flag the EOI as spurious.
This is part of XSA-332.
--- drivers/block/xen-blkback/blkback.c | 22 +++++++++++++++++----- drivers/block/xen-blkback/xenbus.c | 5 ++--- 2 files changed, 19 insertions(+), 8 deletions(-)
drivers/block/xen-blkback/blkback.c +17 -5
@@ -202,7 +202,7 @@ static inline void shrink_free_pagepool(#define vaddr (page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page))) -static int do_block_io_op (struct xen_blkif_ring *ring); +static int do_block_io_op (struct xen_blkif_ring *ring,unsigned int *eoi_flags);static int dispatch_rw_block_io (struct xen_blkif_ring *ring,struct blkif_request *req,struct pending_req *pending_req);
@@ -615,6 +615,8 @@ int xen_blkif_schedule(void *arg)struct xen_vbd *vbd = &blkif->vbd;unsigned long timeout;int ret; +bool do_eoi; +unsigned int eoi_flags =XEN_EOI_FLAG_SPURIOUS ;set_freezable ();while (!kthread_should_stop ()) {
@@ -639,16 +641,23 @@ int xen_blkif_schedule(void *arg)if (timeout ==0 ) goto purge_gnt_list; + do_eoi = ring->waiting_reqs; + ring->waiting_reqs =0 ;smp_mb ();/* clear flag *before* checking for work */ - ret =do_block_io_op (ring); + ret =do_block_io_op (ring, &eoi_flags);if (ret >0 ) ring->waiting_reqs =1 ;if (ret == -EACCES )wait_event_interruptible (ring->shutdown_wq,kthread_should_stop ()); +if (do_eoi && !ring->waiting_reqs) { +xen_irq_lateeoi (ring->irq, eoi_flags); + eoi_flags |=XEN_EOI_FLAG_SPURIOUS ; + } + purge_gnt_list:if (blkif->vbd.feature_gnt_persistent &&time_after (jiffies, ring->next_lru)) {
@@ -1121,7 +1130,7 @@ static void end_block_io_op(struct bio ** and transmute it to the block API to hand it over to the proper block disk. */ static int -__do_block_io_op (struct xen_blkif_ring *ring) +__do_block_io_op (struct xen_blkif_ring *ring,unsigned int *eoi_flags) {union blkif_back_rings *blk_rings = &ring->blk_rings;struct blkif_request req;
@@ -1144,6 +1153,9 @@ __do_block_io_op(struct xen_blkif_ring *if (RING_REQUEST_CONS_OVERFLOW (&blk_rings->common, rc))break ; +/* We've seen a request, so clear spurious eoi flag. */ + *eoi_flags &= ~XEN_EOI_FLAG_SPURIOUS ; +if (kthread_should_stop ()) { more_to_do =1 ;break ;
@@ -1202,13 +1214,13 @@ done: }static int -do_block_io_op (struct xen_blkif_ring *ring) +do_block_io_op (struct xen_blkif_ring *ring,unsigned int *eoi_flags) {union blkif_back_rings *blk_rings = &ring->blk_rings;int more_to_do; do { - more_to_do = __do_block_io_op(ring); + more_to_do = __do_block_io_op(ring, eoi_flags); if (more_to_do) break;
drivers/block/xen-blkback/xenbus.c +2 -3
@@ -229,9 +229,8 @@ static int xen_blkif_map(struct xen_blkiBUG (); } - err =bind_interdomain_evtchn_to_irqhandler (blkif->domid, evtchn, - xen_blkif_be_int,0 , -"blkif-backend" , ring); + err =bind_interdomain_evtchn_to_irqhandler_lateeoi (blkif->domid, + evtchn, xen_blkif_be_int,0 ,"blkif-backend" , ring);if (err <0 ) {xenbus_unmap_ring_vfree (blkif->be->dev, ring->blk_ring); ring->blk_rings.common.sring =NULL ;
Greg Kroah-Hartman
maintainerPATCH 4/214 xen/events: add a new "late EOI" evtchn framework
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit 54c9de89895e0a36047fcc4ae754ea5b8655fb9d upstream.
In order to avoid tight event channel related IRQ loops add a new framework of "late EOI" handling: the IRQ the event channel is bound to will be masked until the event has been handled and the related driver is capable to handle another event. The driver is responsible for unmasking the event channel via the new function xen_irq_lateeoi().
This is similar to binding an event channel to a threaded IRQ, but without having to structure the driver accordingly.
In order to support a future special handling in case a rogue guest is sending lots of unsolicited events, add a flag to xen_irq_lateeoi() which can be set by the caller to indicate the event was a spurious one.
This is part of XSA-332.
--- drivers/xen/events/events_base.c | 151 ++++++++++++++++++++++++++++++++++----- include/xen/events.h | 29 ++++++- 2 files changed, 159 insertions(+), 21 deletions(-)
drivers/xen/events/events_base.c +134 -17
@@ -112,6 +112,7 @@ static bool (*pirq_needs_eoi)(unsigned istatic struct irq_info *legacy_info_ptrs[NR_IRQS_LEGACY ];static struct irq_chip xen_dynamic_chip; +static struct irq_chip xen_lateeoi_chip;static struct irq_chip xen_percpu_chip;static struct irq_chip xen_pirq_chip;static void enable_dynirq (struct irq_data *data);
@@ -396,6 +397,33 @@ void notify_remote_via_irq(int irq) }EXPORT_SYMBOL_GPL (notify_remote_via_irq); +static void xen_irq_lateeoi_locked (struct irq_info *info) +{ +evtchn_port_t evtchn; + + evtchn = info->evtchn; +if (!VALID_EVTCHN (evtchn)) +return ; + +unmask_evtchn (evtchn); +} + +void xen_irq_lateeoi (unsigned int irq,unsigned int eoi_flags) +{ +struct irq_info *info; +unsigned long flags; + +read_lock_irqsave (&evtchn_rwlock, flags); + + info =info_for_irq (irq); + +if (info) +xen_irq_lateeoi_locked (info); + +read_unlock_irqrestore (&evtchn_rwlock, flags); +} +EXPORT_SYMBOL_GPL (xen_irq_lateeoi); +static void xen_irq_init (unsigned irq) {struct irq_info *info;
@@ -867,7 +895,7 @@ int xen_pirq_from_irq(unsigned irq) }EXPORT_SYMBOL_GPL (xen_pirq_from_irq); -int bind_evtchn_to_irq (unsigned int evtchn) +static int bind_evtchn_to_irq_chip (evtchn_port_t evtchn,struct irq_chip *chip) {int irq;int ret;
@@ -884,7 +912,7 @@ int bind_evtchn_to_irq(unsigned int evtcif (irq <0 ) goto out; -irq_set_chip_and_handler_name (irq, &xen_dynamic_chip, +irq_set_chip_and_handler_name (irq, chip, handle_edge_irq,"event" ); ret =xen_irq_info_evtchn_setup (irq, evtchn);
@@ -905,8 +933,19 @@ out:return irq; } + +int bind_evtchn_to_irq (evtchn_port_t evtchn) +{ +return bind_evtchn_to_irq_chip (evtchn, &xen_dynamic_chip); +}EXPORT_SYMBOL_GPL (bind_evtchn_to_irq); +int bind_evtchn_to_irq_lateeoi (evtchn_port_t evtchn) +{ +return bind_evtchn_to_irq_chip (evtchn, &xen_lateeoi_chip); +} +EXPORT_SYMBOL_GPL (bind_evtchn_to_irq_lateeoi); +static int bind_ipi_to_irq (unsigned int ipi,unsigned int cpu) {struct evtchn_bind_ipi bind_ipi;
@@ -948,8 +987,9 @@ static int bind_ipi_to_irq(unsigned intreturn irq; } -int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, -unsigned int remote_port) +static int bind_interdomain_evtchn_to_irq_chip (unsigned int remote_domain, +evtchn_port_t remote_port, +struct irq_chip *chip) {struct evtchn_bind_interdomain bind_interdomain;int err;
@@ -960,10 +1000,26 @@ int bind_interdomain_evtchn_to_irq(unsig err =HYPERVISOR_event_channel_op (EVTCHNOP_bind_interdomain, &bind_interdomain); -return err ? :bind_evtchn_to_irq (bind_interdomain.local_port); +return err ? :bind_evtchn_to_irq_chip (bind_interdomain.local_port, + chip); +} + +int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, +evtchn_port_t remote_port) +{ +return bind_interdomain_evtchn_to_irq_chip (remote_domain, remote_port, + &xen_dynamic_chip); }EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irq); +int bind_interdomain_evtchn_to_irq_lateeoi (unsigned int remote_domain, +evtchn_port_t remote_port) +{ +return bind_interdomain_evtchn_to_irq_chip (remote_domain, remote_port, + &xen_lateeoi_chip); +} +EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irq_lateeoi); +static int find_virq (unsigned int virq,unsigned int cpu) {struct evtchn_status status;
@@ -1059,14 +1115,15 @@ static void unbind_from_irq(unsigned intmutex_unlock (&irq_mapping_update_lock); } -int bind_evtchn_to_irqhandler (unsigned int evtchn, -irq_handler_t handler, -unsigned long irqflags, -const char *devname,void *dev_id) +static int bind_evtchn_to_irqhandler_chip (evtchn_port_t evtchn, +irq_handler_t handler, +unsigned long irqflags, +const char *devname,void *dev_id, +struct irq_chip *chip) {int irq, retval; - irq =bind_evtchn_to_irq (evtchn); + irq =bind_evtchn_to_irq_chip (evtchn, chip);if (irq <0 )return irq; retval =request_irq (irq, handler, irqflags, devname, dev_id);
@@ -1077,18 +1134,38 @@ int bind_evtchn_to_irqhandler(unsigned ireturn irq; } + +int bind_evtchn_to_irqhandler (evtchn_port_t evtchn, +irq_handler_t handler, +unsigned long irqflags, +const char *devname,void *dev_id) +{ +return bind_evtchn_to_irqhandler_chip (evtchn, handler, irqflags, + devname, dev_id, + &xen_dynamic_chip); +}EXPORT_SYMBOL_GPL (bind_evtchn_to_irqhandler); -int bind_interdomain_evtchn_to_irqhandler (unsigned int remote_domain, -unsigned int remote_port, -irq_handler_t handler, -unsigned long irqflags, -const char *devname, -void *dev_id) +int bind_evtchn_to_irqhandler_lateeoi (evtchn_port_t evtchn, +irq_handler_t handler, +unsigned long irqflags, +const char *devname,void *dev_id) +{ +return bind_evtchn_to_irqhandler_chip (evtchn, handler, irqflags, + devname, dev_id, + &xen_lateeoi_chip); +} +EXPORT_SYMBOL_GPL (bind_evtchn_to_irqhandler_lateeoi); + +static int bind_interdomain_evtchn_to_irqhandler_chip ( +unsigned int remote_domain,evtchn_port_t remote_port, +irq_handler_t handler,unsigned long irqflags, +const char *devname,void *dev_id,struct irq_chip *chip) {int irq, retval; - irq =bind_interdomain_evtchn_to_irq (remote_domain, remote_port); + irq =bind_interdomain_evtchn_to_irq_chip (remote_domain, remote_port, + chip);if (irq <0 )return irq;
@@ -1100,8 +1177,33 @@ int bind_interdomain_evtchn_to_irqhandlereturn irq; } + +int bind_interdomain_evtchn_to_irqhandler (unsigned int remote_domain, +evtchn_port_t remote_port, +irq_handler_t handler, +unsigned long irqflags, +const char *devname, +void *dev_id) +{ +return bind_interdomain_evtchn_to_irqhandler_chip (remote_domain, + remote_port, handler, irqflags, devname, + dev_id, &xen_dynamic_chip); +}EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irqhandler); +int bind_interdomain_evtchn_to_irqhandler_lateeoi (unsigned int remote_domain, +evtchn_port_t remote_port, +irq_handler_t handler, +unsigned long irqflags, +const char *devname, +void *dev_id) +{ +return bind_interdomain_evtchn_to_irqhandler_chip (remote_domain, + remote_port, handler, irqflags, devname, + dev_id, &xen_lateeoi_chip); +} +EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irqhandler_lateeoi); +int bind_virq_to_irqhandler (unsigned int virq,unsigned int cpu,irq_handler_t handler,unsigned long irqflags,const char *devname,void *dev_id)
@@ -1642,6 +1744,21 @@ static struct irq_chip xen_dynamic_chip .irq_mask_ack = mask_ack_dynirq, .irq_set_affinity = set_affinity_irq, + .irq_retrigger = retrigger_dynirq, +}; + +static struct irq_chip xen_lateeoi_chip__read_mostly = { +/* The chip name needs to contain "xen-dyn" for irqbalance to work. */ + .name ="xen-dyn-lateeoi" , + + .irq_disable = disable_dynirq, + .irq_mask = disable_dynirq, + .irq_unmask = enable_dynirq, + + .irq_ack = mask_ack_dynirq, + .irq_mask_ack = mask_ack_dynirq, + + .irq_set_affinity = set_affinity_irq, .irq_retrigger = retrigger_dynirq, };
include/xen/events.h +25 -4
@@ -14,11 +14,16 @@unsigned xen_evtchn_nr_channels (void ); -int bind_evtchn_to_irq (unsigned int evtchn); -int bind_evtchn_to_irqhandler (unsigned int evtchn, +int bind_evtchn_to_irq (evtchn_port_t evtchn); +int bind_evtchn_to_irq_lateeoi (evtchn_port_t evtchn); +int bind_evtchn_to_irqhandler (evtchn_port_t evtchn,irq_handler_t handler,unsigned long irqflags,const char *devname,void *dev_id); +int bind_evtchn_to_irqhandler_lateeoi (evtchn_port_t evtchn, +irq_handler_t handler, +unsigned long irqflags,const char *devname, +void *dev_id);int bind_virq_to_irq (unsigned int virq,unsigned int cpu,bool percpu); int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, irq_handler_t handler,
@@ -31,13 +36,21 @@ int bind_ipi_to_irqhandler(enum ipi_vectconst char *devname, void *dev_id);int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, -unsigned int remote_port); +evtchn_port_t remote_port); +int bind_interdomain_evtchn_to_irq_lateeoi (unsigned int remote_domain, +evtchn_port_t remote_port);int bind_interdomain_evtchn_to_irqhandler (unsigned int remote_domain, -unsigned int remote_port, +evtchn_port_t remote_port,irq_handler_t handler,unsigned long irqflags,const char *devname,void *dev_id); +int bind_interdomain_evtchn_to_irqhandler_lateeoi (unsigned int remote_domain, +evtchn_port_t remote_port, +irq_handler_t handler, +unsigned long irqflags, +const char *devname, +void *dev_id);/* * Common unbind function for all event sources. Takes IRQ to unbind from.
@@ -46,6 +59,14 @@ int bind_interdomain_evtchn_to_irqhandle*/ void unbind_from_irqhandler (unsigned int irq,void *dev_id); +/* +* Send late EOI for an IRQ bound to an event channel via one of the *_lateeoi +* functions above. +*/ +void xen_irq_lateeoi (unsigned int irq,unsigned int eoi_flags); +/* Signal an event was spurious, i.e. there was no action resulting from it. */ +#define XEN_EOI_FLAG_SPURIOUS 0x00000001 +#define XEN_IRQ_PRIORITY_MAX EVTCHN_FIFO_PRIORITY_MAX#define XEN_IRQ_PRIORITY_DEFAULT EVTCHN_FIFO_PRIORITY_DEFAULT#define XEN_IRQ_PRIORITY_MIN EVTCHN_FIFO_PRIORITY_MIN
Greg Kroah-Hartman
maintainerPATCH 25/214 f2fs: add trace exit in exception path
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit 9b66482282888d02832b7d90239e1cdb18e4b431 ]
Missing the trace exit in f2fs_sync_dirty_inodes
--- fs/f2fs/checkpoint.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +5 -1
@@ -1044,8 +1044,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)get_pages (sbi, is_dir ? F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA)); retry: -if (unlikely (f2fs_cp_error (sbi))) +if (unlikely (f2fs_cp_error (sbi))) { +trace_f2fs_sync_dirty_inodes_exit (sbi->sb, is_dir, +get_pages (sbi, is_dir ? +F2FS_DIRTY_DENTS :F2FS_DIRTY_DATA ));return -EIO ; + }spin_lock (&sbi->inode_lock[type]);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 24/214 sparc64: remove mm_cpumask clearing to fix kthread_use_mm race
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
[ Upstream commit bafb056ce27940c9994ea905336aa8f27b4f7275 ]
The de facto (and apparently uncommented) standard for using an mm had, thanks to this code in sparc if nothing else, been that you must have a reference on mm_users *and that reference must have been obtained with mmget()*, i.e., from a thread with a reference to mm_users that had used the mm.
The introduction of mmget_not_zero() in commit d2005e3f41d4 ("userfaultfd: don't pin the user memory in userfaultfd_file_create()") allowed mm_count holders to aoperate on user mappings asynchronously from the actual threads using the mm, but they were not to load those mappings into their TLB (i.e., walking vmas and page tables is okay, kthread_use_mm() is not).
io_uring 2b188cc1bb857 ("Add io_uring IO interface") added code which does a kthread_use_mm() from a mmget_not_zero() refcount.
The problem with this is code which previously assumed mm == current->mm and mm->mm_users == 1 implies the mm will remain single-threaded at least until this thread creates another mm_users reference, has now broken.
arch/sparc/kernel/smp_64.c:
if (atomic_read(&mm->mm_users) == 1) {
cpumask_copy(mm_cpumask(mm), cpumask_of(cpu));
goto local_flush_and_out;
}vs fs/io_uring.c
if (unlikely(!(ctx->flags & IORING_SETUP_SQPOLL) ||
!mmget_not_zero(ctx->sqo_mm)))
return -EFAULT;
kthread_use_mm(ctx->sqo_mm);mmget_not_zero() could come in right after the mm_users == 1 test, then kthread_use_mm() which sets its CPU in the mm_cpumask. That update could be lost if cpumask_copy() occurs afterward.
I propose we fix this by allowing mmget_not_zero() to be a first-class reference, and not have this obscure undocumented and unchecked restriction.
The basic fix for sparc64 is to remove its mm_cpumask clearing code. The optimisation could be effectively restored by sending IPIs to mm_cpumask members and having them remove themselves from mm_cpumask. This is more tricky so I leave it as an exercise for someone with a sparc64 SMP. powerpc has a (currently similarly broken) example.
--- arch/sparc/kernel/smp_64.c | 65 ++++++++------------------------------ 1 file changed, 14 insertions(+), 51 deletions(-)
arch/sparc/kernel/smp_64.c +14 -51
@@ -1039,38 +1039,9 @@ void smp_fetch_global_pmu(void)* are flush_tlb_*() routines, and these run after flush_cache_*() * which performs the flushw. * -* The SMP TLB coherency scheme we use works as follows: -* -* 1) mm->cpu_vm_mask is a bit mask of which cpus an address -* space has (potentially) executed on, this is the heuristic -* we use to avoid doing cross calls. -* -* Also, for flushing from kswapd and also for clones, we -* use cpu_vm_mask as the list of cpus to make run the TLB. -* -* 2) TLB context numbers are shared globally across all processors -* in the system, this allows us to play several games to avoid -* cross calls. -* -* One invariant is that when a cpu switches to a process, and -* that processes tsk->active_mm->cpu_vm_mask does not have the -* current cpu's bit set, that tlb context is flushed locally. -* -* If the address space is non-shared (ie. mm->count == 1) we avoid -* cross calls when we want to flush the currently running process's -* tlb state. This is done by clearing all cpu bits except the current -* processor's in current->mm->cpu_vm_mask and performing the -* flush locally only. This will force any subsequent cpus which run -* this task to flush the context from the local tlb if the process -* migrates to another cpu (again). -* -* 3) For shared address spaces (threads) and swapping we bite the -* bullet for most cases and perform the cross call (but only to -* the cpus listed in cpu_vm_mask). -* -* The performance gain from "optimizing" away the cross call for threads is -* questionable (in theory the big win for threads is the massive sharing of -* address space state across processors). +* mm->cpu_vm_mask is a bit mask of which cpus an address +* space has (potentially) executed on, this is the heuristic +* we use to limit cross calls. */ /* This currently is only used by the hugetlb arch pre-fault
@@ -1080,18 +1051,13 @@ void smp_fetch_global_pmu(void)void smp_flush_tlb_mm (struct mm_struct *mm) {u32 ctx =CTX_HWBITS (mm->context); -int cpu =get_cpu (); -if (atomic_read (&mm->mm_users) ==1 ) { -cpumask_copy (mm_cpumask (mm),cpumask_of (cpu)); - goto local_flush_and_out; - } +get_cpu ();smp_cross_call_masked (&xcall_flush_tlb_mm, ctx,0 ,0 ,mm_cpumask (mm)); -local_flush_and_out:__flush_tlb_mm (ctx,SECONDARY_CONTEXT );put_cpu ();
@@ -1114,17 +1080,15 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long {u32 ctx =CTX_HWBITS (mm->context);struct tlb_pending_info info; -int cpu =get_cpu (); + +get_cpu (); info.ctx = ctx; info.nr = nr; info.vaddrs = vaddrs; -if (mm == current->mm &&atomic_read (&mm->mm_users) ==1 ) -cpumask_copy (mm_cpumask (mm),cpumask_of (cpu)); -else -smp_call_function_many (mm_cpumask (mm), tlb_pending_func, - &info,1 ); +smp_call_function_many (mm_cpumask (mm), tlb_pending_func, + &info,1 );__flush_tlb_pending (ctx, nr, vaddrs);
@@ -1134,14 +1098,13 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned longvoid smp_flush_tlb_page (struct mm_struct *mm,unsigned long vaddr) {unsigned long context =CTX_HWBITS (mm->context); -int cpu =get_cpu (); -if (mm == current->mm &&atomic_read (&mm->mm_users) ==1 ) -cpumask_copy (mm_cpumask (mm),cpumask_of (cpu)); -else -smp_cross_call_masked (&xcall_flush_tlb_page, - context, vaddr,0 , -mm_cpumask (mm)); +get_cpu (); + +smp_cross_call_masked (&xcall_flush_tlb_page, + context, vaddr,0 , +mm_cpumask (mm)); +__flush_tlb_page (context, vaddr);put_cpu ();
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 22/214 mm: fix exec activate_mm vs TLB shootdown and lazy tlb switching race
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
[ Upstream commit d53c3dfb23c45f7d4f910c3a3ca84bf0a99c6143 ]
Reading and modifying current->mm and current->active_mm and switching mm should be done with irqs off, to prevent races seeing an intermediate state.
This is similar to commit 38cf307c1f20 ("mm: fix kthread_use_mm() vs TLB invalidate"). At exec-time when the new mm is activated, the old one should usually be single-threaded and no longer used, unless something else is holding an mm_users reference (which may be possible).
Absent other mm_users, there is also a race with preemption and lazy tlb switching. Consider the kernel_execve case where the current thread is using a lazy tlb active mm:
call_usermodehelper()
kernel_execve()
old_mm = current->mm;
active_mm = current->active_mm;
*** preempt *** --------------------> schedule()
prev->active_mm = NULL;
mmdrop(prev active_mm);
...
<-------------------- schedule()
current->mm = mm;
current->active_mm = mm;
if (!old_mm)
mmdrop(active_mm);If we switch back to the kernel thread from a different mm, there is a double free of the old active_mm, and a missing free of the new one.
Closing this race only requires interrupts to be disabled while ->mm and ->active_mm are being switched, but the TLB problem requires also holding interrupts off over activate_mm. Unfortunately not all archs can do that yet, e.g., arm defers the switch if irqs are disabled and expects finish_arch_post_lock_switch() to be called to complete the flush; um takes a blocking lock in activate_mm().
So as a first step, disable interrupts across the mm/active_mm updates to close the lazy tlb preempt race, and provide an arch option to extend that to activate_mm which allows architectures doing IPI based TLB shootdowns to close the second race.
This is a bit ugly, but in the interest of fixing the bug and backporting before all architectures are converted this is a compromise.
--- arch/Kconfig | 7 +++++++ fs/exec.c | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)
arch/Kconfig +7 -0
@@ -405,6 +405,13 @@ config MMU_GATHER_NO_RANGE config HAVE_MMU_GATHER_NO_GATHER bool +config ARCH_WANT_IRQS_OFF_ACTIVATE_MM + bool + help + Temporary select until all architectures can be converted to have + irqs disabled over activate_mm. Architectures that do IPI based TLB + shootdowns should enable this. + config ARCH_HAVE_NMI_SAFE_CMPXCHG bool
fs/exec.c +15 -2
@@ -1044,11 +1044,24 @@ static int exec_mmap(struct mm_struct *mm) }task_lock (tsk); - active_mm = tsk->active_mm;membarrier_exec_mmap (mm); - tsk->mm = mm; + +local_irq_disable (); + active_mm = tsk->active_mm; tsk->active_mm = mm; + tsk->mm = mm; +/* +* This prevents preemption while active_mm is being loaded and +* it and mm are being updated, which could cause problems for +* lazy tlb mm refcounting when these are updated by context +* switches. Not all architectures can handle irqs off over +* activate_mm yet. +*/ +if (!IS_ENABLED (CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM )) +local_irq_enable ();activate_mm (active_mm, mm); +if (IS_ENABLED (CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM )) +local_irq_enable (); tsk->mm->vmacache_seqnum =0 ;vmacache_flush (tsk);task_unlock (tsk);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 20/214 futex: Fix incorrect should_fail_futex() handling
In reply to Greg Kroah-HartmanFrom: Mateusz Nosek <[email protected]>
[ Upstream commit 921c7ebd1337d1a46783d7e15a850e12aed2eaa0 ]
If should_futex_fail() returns true in futex_wake_pi(), then the 'ret' variable is set to -EFAULT and then immediately overwritten. So the failure injection is non-functional.
Fix it by actually leaving the function and returning -EFAULT.
The Fixes tag is kinda blury because the initial commit which introduced failure injection was already sloppy, but the below mentioned commit broke it completely.
[ tglx: Massaged changelog ]
--- kernel/futex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/futex.c +3 -1
@@ -1594,8 +1594,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_*/ newval =FUTEX_WAITERS |task_pid_vnr (new_owner); -if (unlikely (should_fail_futex (true))) +if (unlikely (should_fail_futex (true))) { ret = -EFAULT ; + goto out_unlock; + } ret =cmpxchg_futex_value_locked (&curval, uaddr, uval, newval);if (!ret && (curval != uval)) {
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 18/214 RDMA/qedr: Fix memory leak in iWARP CM
In reply to Greg Kroah-HartmanFrom: Alok Prasad <[email protected]>
[ Upstream commit a2267f8a52eea9096861affd463f691be0f0e8c9 ]
Fixes memory leak in iWARP CM
--- drivers/infiniband/hw/qedr/qedr_iw_cm.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/qedr/qedr_iw_cm.c +1 -0
@@ -727,6 +727,7 @@ int qedr_iw_destroy_listen(struct iw_cm_id *cm_id) listener->qed_handle); cm_id->rem_ref (cm_id); +kfree (listener);return rc; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 15/214 firmware: arm_scmi: Add missing Rx size re-initialisation
In reply to Greg Kroah-HartmanFrom: Sudeep Holla <[email protected]>
[ Upstream commit 9724722fde8f9bbd2b87340f00b9300c9284001e ]
Few commands provide the list of description partially and require to be called consecutively until all the descriptors are fetched completely. In such cases, we don't release the buffers and reuse them for consecutive transmits.
However, currently we don't reset the Rx size which will be set as per the response for the last transmit. This may result in incorrect response size being interpretted as the firmware may repond with size greater than the one set but we read only upto the size set by previous response.
Let us reset the receive buffer size to max possible in such cases as we don't know the exact size of the response.
--- drivers/firmware/arm_scmi/base.c | 2 ++ drivers/firmware/arm_scmi/clock.c | 2 ++ drivers/firmware/arm_scmi/common.h | 2 ++ drivers/firmware/arm_scmi/driver.c | 8 ++++++++ drivers/firmware/arm_scmi/perf.c | 2 ++ drivers/firmware/arm_scmi/sensors.c | 2 ++ 6 files changed, 18 insertions(+)
drivers/firmware/arm_scmi/base.c +2 -0
@@ -173,6 +173,8 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle, protocols_imp[tot_num_ret + loop] = *(list + loop); tot_num_ret += loop_num_ret; + +scmi_reset_rx_to_maxsz (handle, t); }while (loop_num_ret);scmi_xfer_put (handle, t);
drivers/firmware/arm_scmi/clock.c +2 -0
@@ -177,6 +177,8 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id, } tot_rate_cnt += num_returned; + +scmi_reset_rx_to_maxsz (handle, t);/* * check for both returned and remaining to avoid infinite * loop due to buggy firmware
drivers/firmware/arm_scmi/common.h +2 -0
@@ -103,6 +103,8 @@ int scmi_do_xfer_with_response(const struct scmi_handle *h, struct scmi_xfer *xfer);int scmi_xfer_get_init (const struct scmi_handle *h,u8 msg_id,u8 prot_id,size_t tx_size,size_t rx_size,struct scmi_xfer **p); +void scmi_reset_rx_to_maxsz (const struct scmi_handle *handle, +struct scmi_xfer *xfer);int scmi_handle_put (const struct scmi_handle *handle);struct scmi_handle *scmi_handle_get (struct device *dev);void scmi_set_handle (struct scmi_device *scmi_dev);
drivers/firmware/arm_scmi/driver.c +8 -0
@@ -481,6 +481,14 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer)return ret; } +void scmi_reset_rx_to_maxsz (const struct scmi_handle *handle, +struct scmi_xfer *xfer) +{ +struct scmi_info *info =handle_to_scmi_info (handle); + + xfer->rx.len = info->desc->max_msg_size; +} +#define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC)/**
drivers/firmware/arm_scmi/perf.c +2 -0
@@ -281,6 +281,8 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain, } tot_opp_cnt += num_returned; + +scmi_reset_rx_to_maxsz (handle, t);/* * check for both returned and remaining to avoid infinite * loop due to buggy firmware
drivers/firmware/arm_scmi/sensors.c +2 -0
@@ -154,6 +154,8 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle, } desc_index += num_returned; + +scmi_reset_rx_to_maxsz (handle, t);/* * check for both returned and remaining to avoid infinite * loop due to buggy firmware
Signature · 1 line
2.27.0
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.75 release. There are 214 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 05 Nov 2020 20:29:58 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.75-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.4:
15 builds: 15 pass, 0 fail
26 boots: 26 pass, 0 fail
56 tests: 56 pass, 0 failLinux version: 5.4.75-rc1-g1b513bf28609
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra210-p3450-0000,
tegra30-cardhu-a04Jon
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.75 release. There are 214 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 05 Nov 2020 20:29:58 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.75-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 5.4.75-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-5.4.y
git commit: 1b513bf286096f9c66fc386cdc5e038980db8863
git describe: v5.4.74-215-g1b513bf28609
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.4.y/build/v5.4.74-215-g1b513bf28609
No regressions (compared to build v5.4.74)
No fixes (compared to build v5.4.74)
Ran 37086 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c
- hi6220-hikey
- i386
- juno-r2
- juno-r2-compat
- nxp-ls2088-kasan
- qemu-arm64-kasan
- qemu-x86_64-kasan
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15
- x86
- x86-kasan
Test Suites
-----------
* build
* igt-gpu-tools
* install-android-platform-tools-r2600
* kselftest
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-controllers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-sched-tests
* ltp-syscalls-tests
* ltp-tracing-tests
* perf
* v4l2-compliance
* ltp-cve-tests
* ltp-hugetlb-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-securebits-tests
* network-basic-tests
* ltp-open-posix-tests
* kvm-unit-tests
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.75 release. There are 214 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 05 Nov 2020 20:29:58 +0000. Anything received after that time might be too late.
All sparc images fail to build.
Building sparc32:defconfig ... failed
--------------
Error log:
<stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp] In file included from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from include/linux/io.h:13,
from include/linux/irq.h:20,
from include/asm-generic/hardirq.h:13,
from arch/sparc/include/asm/hardirq_32.h:11,
from arch/sparc/include/asm/hardirq.h:7,
from include/linux/hardirq.h:9,
from include/linux/interrupt.h:11,
from include/linux/kernel_stat.h:9,
from arch/sparc/kernel/irq_32.c:15:include/asm-generic/io.h: In function '__pci_ioport_unmap':include/asm-generic/io.h:1012:2: error: implicit declaration of function 'iounmap'; did you mean 'ioremap'?
Guenter
Greg Kroah-Hartman
maintainerQuoted 27 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.75 release. There are 214 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 05 Nov 2020 20:29:58 +0000. Anything received after that time might be too late.
All sparc images fail to build.
Building sparc32:defconfig ... failed
--------------
Error log:
<stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp] In file included fromarch/sparc/include/asm/io_32.h:14,from arch/sparc/include/asm/io.h:7, from include/linux/io.h:13, from include/linux/irq.h:20, from include/asm-generic/hardirq.h:13, from arch/sparc/include/asm/hardirq_32.h:11, from arch/sparc/include/asm/hardirq.h:7, from include/linux/hardirq.h:9, from include/linux/interrupt.h:11, from include/linux/kernel_stat.h:9, from arch/sparc/kernel/irq_32.c:15:
Quoted 2 lines
include/asm-generic/io.h: In function '__pci_ioport_unmap':include/asm-generic/io.h:1012:2: error: implicit declaration of function 'iounmap'; did you mean 'ioremap'?
Thanks, I'll go drop f5810e5c3292 ("asm-generic/io.h: Fix !CONFIG_GENERIC_IOMAP pci_iounmap() implementation") which seems to be causing this.
Sasha, any reason you only added it to the 5.4 and 4.14 queues and not 5.9 and 4.19?
thanks,
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.75 release. There are 214 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 05 Nov 2020 20:29:58 +0000. Anything received after that time might be too late.
Build results:
total: 157 pass: 150 fail: 7 Failed builds: <all sparc> Qemu test results: total: 426 pass: 394 fail: 32
Failed tests:
<all sparc>
Guenter