tools: iio: replace seekdir() in iio_generic_buffer
Subsystems (9)
Sasha Levin
maintainerPATCH 1/15 tools: iio: replace seekdir() in iio_generic_buffer
From: Petre Rodan <[email protected]>
[ Upstream commit 4e6500bfa053dc133021f9c144261b77b0ba7dc8 ]
Replace seekdir() with rewinddir() in order to fix a localized glibc bug.
One of the glibc patches that stable Gentoo is using causes an improper directory stream positioning bug on 32bit arm. That in turn ends up as a floating point exception in iio_generic_buffer.
The attached patch provides a fix by using an equivalent function which should not cause trouble for other distros and is easier to reason about in general as it obviously always goes back to to the start.
https://sourceware.org/bugzilla/show_bug.cgi?id=31212
--- tools/iio/iio_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/iio/iio_utils.c +1 -1
@@ -376,7 +376,7 @@ int build_channel_array(const char *device_dir, int buffer_idx, goto error_close_dir; } -seekdir (dp,0 ); +rewinddir (dp);while (ent =readdir (dp), ent) {if (strcmp (ent->d_name +strlen (ent->d_name) -strlen ("_en" ),"_en" ) ==0 ) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/15 usb: storage: sddr55: fix sloppy typing in sddr55_{read|write}_data()
From: Karina Yankevich <[email protected]>
[ Upstream commit d6429a3555fb29f380c5841a12f5ac3f7444af03 ]
In sddr55_{read|write}_data(), the address variables are needlessly typed as *unsigned long* -- which is 32-bit type on the 32-bit arches and 64-bit type on the 64-bit arches; those variables' value should fit into just 3 command bytes and consists of 10-bit block # (or at least the max block # seems to be 1023) and 4-/5-bit page # within a block, so 32-bit *unsigned* *int* type should be more than enough...
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
[Sergey: rewrote the patch subject/description]
--- drivers/usb/storage/sddr55.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/storage/sddr55.c +2 -2
@@ -196,7 +196,7 @@ static int sddr55_read_data(struct us_data *us,unsigned char *buffer;unsigned int pba; -unsigned long address; +unsigned int address;unsigned short pages;unsigned int len, offset;
@@ -316,7 +316,7 @@ static int sddr55_write_data(struct us_data *us,unsigned int pba;unsigned int new_pba; -unsigned long address; +unsigned int address;unsigned short pages;int i;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/15 bus: mhi: host: Add MHI_PM_SYS_ERR_FAIL state
In reply to Sasha LevinFrom: Jeffrey Hugo <[email protected]>
[ Upstream commit bce3f770684cc1d91ff9edab431b71ac991faf29 ]
When processing a SYSERR, if the device does not respond to the MHI_RESET from the host, the host will be stuck in a difficult to recover state. The host will remain in MHI_PM_SYS_ERR_PROCESS and not clean up the host channels. Clients will not be notified of the SYSERR via the destruction of their channel devices, which means clients may think that the device is still up. Subsequent SYSERR events such as a device fatal error will not be processed as the state machine cannot transition from PROCESS back to DETECT. The only way to recover from this is to unload the mhi module (wipe the state machine state) or for the mhi controller to initiate SHUTDOWN.
This issue was discovered by stress testing soc_reset events on AIC100 via the sysfs node.
soc_reset is processed entirely in hardware. When the register write hits the endpoint hardware, it causes the soc to reset without firmware involvement. In stress testing, there is a rare race where soc_reset N will cause the soc to reset and PBL to signal SYSERR (fatal error). If soc_reset N+1 is triggered before PBL can process the MHI_RESET from the host, then the soc will reset again, and re-run PBL from the beginning. This will cause PBL to lose all state. PBL will be waiting for the host to respond to the new syserr, but host will be stuck expecting the previous MHI_RESET to be processed.
Additionally, the AMSS EE firmware (QSM) was hacked to synthetically reproduce the issue by simulating a FW hang after the QSM issued a SYSERR. In this case, soc_reset would not recover the device.
For this failure case, to recover the device, we need a state similar to PROCESS, but can transition to DETECT. There is not a viable existing state to use. POR has the needed transitions, but assumes the device is in a good state and could allow the host to attempt to use the device. Allowing PROCESS to transition to DETECT invites the possibility of parallel SYSERR processing which could get the host and device out of sync.
Thus, invent a new state - MHI_PM_SYS_ERR_FAIL
This essentially a holding state. It allows us to clean up the host elements that are based on the old state of the device (channels), but does not allow us to directly advance back to an operational state. It does allow the detection and processing of another SYSERR which may recover the device, or allows the controller to do a clean shutdown.
--- drivers/bus/mhi/host/init.c | 1 + drivers/bus/mhi/host/internal.h | 9 ++++++--- drivers/bus/mhi/host/pm.c | 20 +++++++++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-)
drivers/bus/mhi/host/init.c +1 -0
@@ -62,6 +62,7 @@ static const char * const mhi_pm_state_str[] = { [MHI_PM_STATE_FW_DL_ERR] = "Firmware Download Error", [MHI_PM_STATE_SYS_ERR_DETECT] = "SYS ERROR Detect", [MHI_PM_STATE_SYS_ERR_PROCESS] = "SYS ERROR Process", + [MHI_PM_STATE_SYS_ERR_FAIL] = "SYS ERROR Failure", [MHI_PM_STATE_SHUTDOWN_PROCESS] = "SHUTDOWN Process", [MHI_PM_STATE_LD_ERR_FATAL_DETECT] = "Linkdown or Error Fatal Detect", };
drivers/bus/mhi/host/internal.h +6 -3
@@ -88,6 +88,7 @@ enum mhi_pm_state {MHI_PM_STATE_FW_DL_ERR ,MHI_PM_STATE_SYS_ERR_DETECT ,MHI_PM_STATE_SYS_ERR_PROCESS , +MHI_PM_STATE_SYS_ERR_FAIL ,MHI_PM_STATE_SHUTDOWN_PROCESS ,MHI_PM_STATE_LD_ERR_FATAL_DETECT ,MHI_PM_STATE_MAX
@@ -104,14 +105,16 @@ enum mhi_pm_state {#define MHI_PM_FW_DL_ERR BIT(7)#define MHI_PM_SYS_ERR_DETECT BIT(8)#define MHI_PM_SYS_ERR_PROCESS BIT(9) -#define MHI_PM_SHUTDOWN_PROCESS BIT(10) +#define MHI_PM_SYS_ERR_FAIL BIT(10) +#define MHI_PM_SHUTDOWN_PROCESS BIT(11)/* link not accessible */ -#define MHI_PM_LD_ERR_FATAL_DETECT BIT(11) +#define MHI_PM_LD_ERR_FATAL_DETECT BIT(12)#define MHI_REG_ACCESS_VALID (pm_state) ((pm_state & (MHI_PM_POR | MHI_PM_M0 | \ MHI_PM_M2 | MHI_PM_M3_ENTER | MHI_PM_M3_EXIT | \ MHI_PM_SYS_ERR_DETECT | MHI_PM_SYS_ERR_PROCESS | \ - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_FW_DL_ERR))) + MHI_PM_SYS_ERR_FAIL | MHI_PM_SHUTDOWN_PROCESS | \ + MHI_PM_FW_DL_ERR)))#define MHI_PM_IN_ERROR_STATE (pm_state) (pm_state >= MHI_PM_FW_DL_ERR)#define MHI_PM_IN_FATAL_STATE (pm_state) (pm_state == MHI_PM_LD_ERR_FATAL_DETECT)#define MHI_DB_ACCESS_VALID (mhi_cntrl) (mhi_cntrl->pm_state & mhi_cntrl->db_access)
drivers/bus/mhi/host/pm.c +17 -3
@@ -36,7 +36,10 @@* M0 <--> M0 * M0 -> FW_DL_ERR * M0 -> M3_ENTER -> M3 -> M3_EXIT --> M0 -* L1: SYS_ERR_DETECT -> SYS_ERR_PROCESS --> POR +* L1: SYS_ERR_DETECT -> SYS_ERR_PROCESS +* SYS_ERR_PROCESS -> SYS_ERR_FAIL +* SYS_ERR_FAIL -> SYS_ERR_DETECT +* SYS_ERR_PROCESS --> POR * L2: SHUTDOWN_PROCESS -> LD_ERR_FATAL_DETECT * SHUTDOWN_PROCESS -> DISABLE * L3: LD_ERR_FATAL_DETECT <--> LD_ERR_FATAL_DETECT
@@ -93,7 +96,12 @@ static const struct mhi_pm_transitions dev_state_transitions[] = { }, {MHI_PM_SYS_ERR_PROCESS , -MHI_PM_POR |MHI_PM_SHUTDOWN_PROCESS | +MHI_PM_POR |MHI_PM_SYS_ERR_FAIL |MHI_PM_SHUTDOWN_PROCESS | +MHI_PM_LD_ERR_FATAL_DETECT + }, + { +MHI_PM_SYS_ERR_FAIL , +MHI_PM_SYS_ERR_DETECT |MHI_PM_SHUTDOWN_PROCESS |MHI_PM_LD_ERR_FATAL_DETECT },/* L2 States */
@@ -624,7 +632,13 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl) !in_reset, timeout);if (!ret || in_reset) {dev_err (dev,"Device failed to exit MHI Reset state\n" ); - goto exit_sys_error_transition; +write_lock_irq (&mhi_cntrl->pm_lock); + cur_state =mhi_tryset_pm_state (mhi_cntrl, +MHI_PM_SYS_ERR_FAIL ); +write_unlock_irq (&mhi_cntrl->pm_lock); +/* Shutdown may have occurred, otherwise cleanup now */ +if (cur_state !=MHI_PM_SYS_ERR_FAIL ) + goto exit_sys_error_transition; }/*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/15 usb: gadget: uvc: mark incomplete frames with UVC_STREAM_ERR
In reply to Sasha LevinFrom: Michael Grzeschik <[email protected]>
[ Upstream commit 2a3b7af120477d0571b815ccb8600cafd5ebf02f ]
If an frame was transmitted incomplete to the host, we set the UVC_STREAM_ERR bit in the header for the last request that is going to be queued. This way the host will know that it should drop the frame instead of trying to display the corrupted content.
--- drivers/usb/gadget/function/uvc_video.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/function/uvc_video.c +3 -0
@@ -35,6 +35,9 @@ uvc_video_encode_header(struct uvc_video *video, struct uvc_buffer *buf, data[1 ] =UVC_STREAM_EOH | video->fid; +if (video->queue.flags &UVC_QUEUE_DROP_INCOMPLETE ) + data[1 ] |=UVC_STREAM_ERR ; +if (video->queue.buf_used ==0 && ts.tv_sec) {/* dwClockFrequency is 48 MHz */ u32 pts = ((u64 )ts.tv_sec *USEC_PER_SEC + ts.tv_nsec /NSEC_PER_USEC ) *48 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/15 usb: typec: ucsi: Limit read size on v1.2
In reply to Sasha LevinFrom: Abhishek Pandit-Subedi <[email protected]>
[ Upstream commit b3db266fb031fba88c423d4bb8983a73a3db6527 ]
Between UCSI 1.2 and UCSI 2.0, the size of the MESSAGE_IN region was increased from 16 to 256. In order to avoid overflowing reads for older systems, add a mechanism to use the read UCSI version to truncate read sizes on UCSI v1.2.
--- drivers/usb/typec/ucsi/ucsi.c | 26 ++++++++++++++++++++++++-- drivers/usb/typec/ucsi/ucsi.h | 11 +++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +24 -2
@@ -36,6 +36,19 @@*/ #define UCSI_SWAP_TIMEOUT_MS 5000 +static int ucsi_read_message_in (struct ucsi *ucsi,void *buf, +size_t buf_size) +{ +/* +* Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the +* reads here. +*/ +if (ucsi->version <=UCSI_VERSION_1_2 ) + buf_size =clamp (buf_size,0 ,16 ); + +return ucsi->ops->read (ucsi,UCSI_MESSAGE_IN , buf, buf_size); +} +static int ucsi_acknowledge_command (struct ucsi *ucsi) {u64 ctrl;
@@ -72,7 +85,7 @@ static int ucsi_read_error(struct ucsi *ucsi)if (ret <0 )return ret; - ret = ucsi->ops->read (ucsi,UCSI_MESSAGE_IN , &error,sizeof (error)); + ret =ucsi_read_message_in (ucsi, &error,sizeof (error));if (ret)return ret;
@@ -170,7 +183,7 @@ int ucsi_send_command(struct ucsi *ucsi, u64 command, length = ret;if (data) { - ret = ucsi->ops->read (ucsi,UCSI_MESSAGE_IN , data, size); + ret =ucsi_read_message_in (ucsi, data, size);if (ret) goto out; }
@@ -1403,6 +1416,15 @@ int ucsi_register(struct ucsi *ucsi)if (!ucsi->version)return -ENODEV ; +/* +* Version format is JJ.M.N (JJ = Major version, M = Minor version, +* N = sub-minor version). +*/ +dev_dbg (ucsi->dev,"Registered UCSI interface with version %x.%x.%x" , +UCSI_BCD_GET_MAJOR (ucsi->version), +UCSI_BCD_GET_MINOR (ucsi->version), +UCSI_BCD_GET_SUBMINOR (ucsi->version)); +queue_delayed_work (system_long_wq, &ucsi->work,0 );return 0 ;
drivers/usb/typec/ucsi/ucsi.h +11 -0
@@ -22,6 +22,17 @@ struct ucsi_altmode;#define UCSI_CONTROL 8#define UCSI_MESSAGE_IN 16#define UCSI_MESSAGE_OUT 32 +#define UCSIv2_MESSAGE_OUT 272 + +/* UCSI versions */ +#define UCSI_VERSION_1_2 0x0120 +#define UCSI_VERSION_2_0 0x0200 +#define UCSI_VERSION_2_1 0x0210 +#define UCSI_VERSION_3_0 0x0300 + +#define UCSI_BCD_GET_MAJOR (_v_) (((_v_) >> 8) & 0xFF) +#define UCSI_BCD_GET_MINOR (_v_) (((_v_) >> 4) & 0x0F) +#define UCSI_BCD_GET_SUBMINOR (_v_) ((_v_) & 0x0F)/* Command Status and Connector Change Indication (CCI) bits */ #define UCSI_CCI_CONNECTOR (_c_) (((_c_) & GENMASK(7, 1)) >> 1)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/15 thunderbolt: Keep the domain powered when USB4 port is in redrive mode
In reply to Sasha LevinFrom: Mika Westerberg <[email protected]>
[ Upstream commit a75e0684efe567ae5f6a8e91a8360c4c1773cf3a ]
If a DiplayPort cable is directly connected to the host routers USB4 port, there is no tunnel involved but the port is in "redrive" mode meaning that it is re-driving the DisplayPort signals from its DisplayPort source. In this case we need to keep the domain powered on otherwise once the domain enters D3cold the connected monitor blanks too.
Since this happens only on Intel Barlow Ridge add a quirk that takes runtime PM reference if we detect that the USB4 port entered redrive mode (and release it once it exits the mode).
--- drivers/thunderbolt/quirks.c | 14 +++++++++++ drivers/thunderbolt/tb.c | 49 +++++++++++++++++++++++++++++++++++- drivers/thunderbolt/tb.h | 4 +++ 3 files changed, 66 insertions(+), 1 deletion(-)
drivers/thunderbolt/quirks.c +14 -0
@@ -42,6 +42,12 @@ static void quirk_usb3_maximum_bandwidth(struct tb_switch *sw) } } +static void quirk_block_rpm_in_redrive (struct tb_switch *sw) +{ + sw->quirks |=QUIRK_KEEP_POWER_IN_DP_REDRIVE ; +tb_sw_dbg (sw,"preventing runtime PM in DP redrive mode\n" ); +} +struct tb_quirk {u16 hw_vendor_id;u16 hw_device_id;
@@ -85,6 +91,14 @@ static const struct tb_quirk tb_quirks[] = { quirk_usb3_maximum_bandwidth }, {0x8087 ,PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_40G_BRIDGE ,0x0000 ,0x0000 , quirk_usb3_maximum_bandwidth }, +/* +* Block Runtime PM in DP redrive mode for Intel Barlow Ridge host +* controllers. +*/ + { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI, 0x0000, 0x0000, + quirk_block_rpm_in_redrive }, + { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI, 0x0000, 0x0000, + quirk_block_rpm_in_redrive },/* * CLx is not supported on AMD USB4 Yellow Carp and Pink Sardine platforms. */
drivers/thunderbolt/tb.c +48 -1
67 lines not on this page · raw message
drivers/thunderbolt/tb.h +4 -0
@@ -27,6 +27,8 @@#define QUIRK_FORCE_POWER_LINK_CONTROLLER BIT(0)/* Disable CLx if not supported */ #define QUIRK_NO_CLX BIT(1) +/* Need to keep power on while USB4 port is in redrive mode */ +#define QUIRK_KEEP_POWER_IN_DP_REDRIVE BIT(2)/** * struct tb_nvm - Structure holding NVM information
@@ -254,6 +256,7 @@ struct tb_switch {* DMA paths through this port. * @max_bw: Maximum possible bandwidth through this adapter if set to * non-zero. +* @redrive: For DP IN, if true the adapter is in redrive mode. * * In USB4 terminology this structure represents an adapter (protocol or * lane adapter).
@@ -280,6 +283,7 @@ struct tb_port {unsigned int ctl_credits;unsigned int dma_credits;unsigned int max_bw; +bool redrive; };/**
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/15 usb: typec: tcpci: add generic tcpci fallback compatible
In reply to Sasha LevinFrom: Marco Felsch <[email protected]>
[ Upstream commit 8774ea7a553e2aec323170d49365b59af0a2b7e0 ]
The driver already support the tcpci binding for the i2c_device_id so add the support for the of_device_id too.
--- drivers/usb/typec/tcpm/tcpci.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci.c +1 -0
@@ -875,6 +875,7 @@ MODULE_DEVICE_TABLE(i2c, tcpci_id);#ifdef CONFIG_OF static const struct of_device_id tcpci_of_match[] = { { .compatible ="nxp,ptn5110" , }, + { .compatible ="tcpci" , }, {}, };MODULE_DEVICE_TABLE (of, tcpci_of_match);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/15 usb: sl811-hcd: only defined function checkdone if QUIRK2 is defined
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit 12f371e2b6cb4b79c788f1f073992e115f4ca918 ]
Function checkdone is only required if QUIRK2 is defined, so add appropriate #if / #endif around the function.
Cleans up clang scan build warning:drivers/usb/host/sl811-hcd.c:588:18: warning: unused function 'checkdone' [-Wunused-function]
--- drivers/usb/host/sl811-hcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/sl811-hcd.c +2 -0
@@ -585,6 +585,7 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank)finish_request (sl811, ep, urb, urbstat); } +#ifdef QUIRK2 static inline u8 checkdone (struct sl811 *sl811) {u8 ctl;
@@ -616,6 +617,7 @@ static inline u8 checkdone(struct sl811 *sl811)#endif return irqstat; } +#endif static irqreturn_t sl811h_irq (struct usb_hcd *hcd) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/15 thermal/of: Assume polling-delay(-passive) 0 when absent
In reply to Sasha LevinFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 488164006a281986d95abbc4b26e340c19c4c85b ]
Currently, thermal zones associated with providers that have interrupts for signaling hot/critical trips are required to set a polling-delay of 0 to indicate no polling. This feels a bit backwards.
Change the code such that "no polling delay" also means "no polling".
--- drivers/thermal/thermal_of.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/thermal/thermal_of.c +8 -4
@@ -337,14 +337,18 @@ static int thermal_of_monitor_init(struct device_node *np, int *delay, int *pdelint ret; ret =of_property_read_u32 (np,"polling-delay-passive" , pdelay); -if (ret <0 ) { -pr_err ("%pOFn: missing polling-delay-passive property\n" , np); +if (ret == -EINVAL ) { + *pdelay =0 ; + }else if (ret <0 ) { +pr_err ("%pOFn: Couldn't get polling-delay-passive: %d\n" , np, ret);return ret; } ret =of_property_read_u32 (np,"polling-delay" , delay); -if (ret <0 ) { -pr_err ("%pOFn: missing polling-delay property\n" , np); +if (ret == -EINVAL ) { + *delay =0 ; + }else if (ret <0 ) { +pr_err ("%pOFn: Couldn't get polling-delay: %d\n" , np, ret);return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/15 ASoC: soc-core.c: Skip dummy codec when adding platforms
In reply to Sasha LevinFrom: Chancel Liu <[email protected]>
[ Upstream commit 23fb6bc2696119391ec3a92ccaffe50e567c515e ]
When pcm_runtime is adding platform components it will scan all registered components. In case of DPCM FE/BE some DAI links will configure dummy platform. However both dummy codec and dummy platform are using "snd-soc-dummy" as component->name. Dummy codec should be skipped when adding platforms otherwise there'll be overflow and UBSAN complains.
--- sound/soc/soc-core.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/soc-core.c +3 -0
@@ -1020,6 +1020,9 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card,if (!snd_soc_is_matching_component (platform, component))continue ; +if (snd_soc_component_is_dummy (component) && component->num_dai) +continue ; +snd_soc_rtd_add_component (rtd, component); } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/15 x86/xen: attempt to inflate the memory balloon on PVH
In reply to Sasha LevinFrom: Roger Pau Monne <[email protected]>
[ Upstream commit 38620fc4e8934f1801c7811ef39a041914ac4c1d ]
When running as PVH or HVM Linux will use holes in the memory map as scratch space to map grants, foreign domain pages and possibly miscellaneous other stuff. However the usage of such memory map holes for Xen purposes can be problematic. The request of holesby Xen happen quite early in the kernel boot process (grant table setup already uses scratch map space), and it's possible that by then not all devices have reclaimed their MMIO space. It's not unlikely for chunks of Xen scratch map space to end up using PCI bridge MMIO window memory, which (as expected) causes quite a lot of issues in the system.
At least for PVH dom0 we have the possibility of using regions marked as UNUSABLE in the e820 memory map. Either if the region is UNUSABLE in the native memory map, or it has been converted into UNUSABLE in order to hide RAM regions from dom0, the second stage translation page-tables can populate those areas without issues.
PV already has this kind of logic, where the balloon driver is inflated at boot. Re-use the current logic in order to also inflate it when running as PVH. onvert UNUSABLE regions up to the ratio specified in EXTRA_MEM_RATIO to RAM, while reserving them using xen_add_extra_mem() (which is also moved so it's no longer tied to CONFIG_PV).
[jgross: fixed build for CONFIG_PVH without CONFIG_XEN_PVH]
--- arch/x86/include/asm/xen/hypervisor.h | 5 ++ arch/x86/platform/pvh/enlighten.c | 3 ++ arch/x86/xen/enlighten.c | 32 +++++++++++++ arch/x86/xen/enlighten_pvh.c | 68 +++++++++++++++++++++++++++ arch/x86/xen/setup.c | 44 ----------------- arch/x86/xen/xen-ops.h | 14 ++++++ drivers/xen/balloon.c | 2 - 7 files changed, 122 insertions(+), 46 deletions(-)
arch/x86/include/asm/xen/hypervisor.h +5 -0
@@ -59,6 +59,11 @@ void xen_arch_unregister_cpu(int num);#ifdef CONFIG_PVH void __init xen_pvh_init (struct boot_params *boot_params);void __init mem_map_via_hcall (struct boot_params *boot_params_p); +#ifdef CONFIG_XEN_PVH +void __init xen_reserve_extra_memory (struct boot_params *bootp); +#else +static inline void xen_reserve_extra_memory (struct boot_params *bootp) { } +#endif #endif #endif /* _ASM_X86_XEN_HYPERVISOR_H */
arch/x86/platform/pvh/enlighten.c +3 -0
@@ -74,6 +74,9 @@ static void __init init_pvh_bootparams(bool xen_guest) }else xen_raw_printk ("Warning: Can fit ISA range into e820\n" ); +if (xen_guest) +xen_reserve_extra_memory (&pvh_bootparams); + pvh_bootparams.hdr.cmd_line_ptr = pvh_start_info.cmdline_paddr;
arch/x86/xen/enlighten.c +32 -0
@@ -6,6 +6,7 @@#include <linux/console.h> #include <linux/cpu.h> #include <linux/kexec.h> +#include <linux/memblock.h> #include <linux/slab.h> #include <linux/panic_notifier.h>
@@ -350,3 +351,34 @@ void xen_arch_unregister_cpu(int num) }EXPORT_SYMBOL (xen_arch_unregister_cpu);#endif + +/* Amount of extra memory space we add to the e820 ranges */ +struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS ]__initdata ; + +void __init xen_add_extra_mem (unsigned long start_pfn,unsigned long n_pfns) +{ +unsigned int i; + +/* +* No need to check for zero size, should happen rarely and will only +* write a new entry regarded to be unused due to zero size. +*/ +for (i =0 ; i <XEN_EXTRA_MEM_MAX_REGIONS ; i++) { +/* Add new region. */ +if (xen_extra_mem[i].n_pfns ==0 ) { + xen_extra_mem[i].start_pfn = start_pfn; + xen_extra_mem[i].n_pfns = n_pfns; +break ; + } +/* Append to existing region. */ +if (xen_extra_mem[i].start_pfn + xen_extra_mem[i].n_pfns == + start_pfn) { + xen_extra_mem[i].n_pfns += n_pfns; +break ; + } + } +if (i ==XEN_EXTRA_MEM_MAX_REGIONS ) +printk (KERN_WARNING "Warning: not enough extra memory regions\n" ); + +memblock_reserve (PFN_PHYS (start_pfn),PFN_PHYS (n_pfns)); +}
arch/x86/xen/enlighten_pvh.c +68 -0
77 lines not on this page · raw message
arch/x86/xen/setup.c +0 -44
62 lines not on this page · raw message
arch/x86/xen/xen-ops.h +14 -0
@@ -162,4 +162,18 @@ void xen_hvm_post_suspend(int suspend_cancelled);static inline void xen_hvm_post_suspend (int suspend_cancelled) {}#endif +/* +* The maximum amount of extra memory compared to the base size. The +* main scaling factor is the size of struct page. At extreme ratios +* of base:extra, all the base memory can be filled with page +* structures for the extra memory, leaving no space for anything +* else. +* +* 10x seems like a reasonable balance between scaling flexibility and +* leaving a practically usable system. +*/ +#define EXTRA_MEM_RATIO (10) + +void xen_add_extra_mem (unsigned long start_pfn,unsigned long n_pfns); +#endif /* XEN_OPS_H */
drivers/xen/balloon.c +0 -2
@@ -691,7 +691,6 @@ EXPORT_SYMBOL(xen_free_ballooned_pages);static void __init balloon_add_regions (void ) { -#if defined(CONFIG_XEN_PV )unsigned long start_pfn, pages;unsigned long pfn, extra_pfn_end;unsigned int i;
@@ -715,7 +714,6 @@ static void __init balloon_add_regions(void) balloon_stats.total_pages += extra_pfn_end - start_pfn; } -#endif }static int __init balloon_init (void )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/15 fbdev: viafb: fix typo in hw_bitblt_1 and hw_bitblt_2
In reply to Sasha LevinFrom: Aleksandr Burakov <[email protected]>
[ Upstream commit bc87bb342f106a0402186bcb588fcbe945dced4b ]
There are some actions with value 'tmp' but 'dst_addr' is checked instead. It is obvious that a copy-paste error was made here and the value of variable 'tmp' should be checked here.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/video/fbdev/via/accel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/via/accel.c +2 -2
@@ -115,7 +115,7 @@ static int hw_bitblt_1(void __iomem *engine, u8 op, u32 width, u32 height,if (op !=VIA_BITBLT_FILL ) { tmp = src_mem ?0 : src_addr; -if (dst_addr &0xE0000007 ) { +if (tmp &0xE0000007 ) {printk (KERN_WARNING "hw_bitblt_1: Unsupported source " "address %X\n" , tmp);return -EINVAL ;
@@ -260,7 +260,7 @@ static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height,writel (tmp, engine +0x18 ); tmp = src_mem ?0 : src_addr; -if (dst_addr &0xE0000007 ) { +if (tmp &0xE0000007 ) {printk (KERN_WARNING "hw_bitblt_2: Unsupported source " "address %X\n" , tmp);return -EINVAL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/15 io_uring: clear opcode specific data for an early failure
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit e21e1c45e1fe2e31732f40256b49c04e76a17cee ]
If failure happens before the opcode prep handler is called, ensure that we clear the opcode specific area of the request, which holds data specific to that request type. This prevents errors where opcode handlers either don't get to clear per-request private data since prep isn't even called.
--- io_uring/io_uring.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
io_uring/io_uring.c +16 -9
@@ -1992,6 +1992,13 @@ static void io_init_req_drain(struct io_kiocb *req) } } +static __cold int io_init_fail_req (struct io_kiocb *req,int err) +{ +/* ensure per-opcode data is cleared if we fail before prep */ +memset (&req->cmd.data,0 ,sizeof (req->cmd.data)); +return err; +} + static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, const struct io_uring_sqe *sqe) __must_hold(&ctx->uring_lock)
@@ -2012,29 +2019,29 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,if (unlikely (opcode >=IORING_OP_LAST )) { req->opcode =0 ; -return -EINVAL ; +return io_init_fail_req (req, -EINVAL ); } def = &io_op_defs[opcode];if (unlikely (sqe_flags & ~SQE_COMMON_FLAGS )) {/* enforce forwards compatibility on users */ if (sqe_flags & ~SQE_VALID_FLAGS ) -return -EINVAL ; +return io_init_fail_req (req, -EINVAL );if (sqe_flags &IOSQE_BUFFER_SELECT ) {if (!def->buffer_select) -return -EOPNOTSUPP ; +return io_init_fail_req (req, -EOPNOTSUPP ); req->buf_index =READ_ONCE (sqe->buf_group); }if (sqe_flags &IOSQE_CQE_SKIP_SUCCESS ) ctx->drain_disabled = true;if (sqe_flags &IOSQE_IO_DRAIN ) {if (ctx->drain_disabled) -return -EOPNOTSUPP ; +return io_init_fail_req (req, -EOPNOTSUPP );io_init_req_drain (req); } }if (unlikely (ctx->restricted || ctx->drain_active || ctx->drain_next)) {if (ctx->restricted && !io_check_restriction (ctx, req, sqe_flags)) -return -EACCES ; +return io_init_fail_req (req, -EACCES );/* knock it to the slow queue path, will be drained there */ if (ctx->drain_active) req->flags |=REQ_F_FORCE_ASYNC ;
@@ -2047,9 +2054,9 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, }if (!def->ioprio && sqe->ioprio) -return -EINVAL ; +return io_init_fail_req (req, -EINVAL );if (!def->iopoll && (ctx->flags &IORING_SETUP_IOPOLL )) -return -EINVAL ; +return io_init_fail_req (req, -EINVAL );if (def->needs_file) {struct io_submit_state *state = &ctx->submit_state;
@@ -2073,12 +2080,12 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, req->creds =xa_load (&ctx->personalities, personality);if (!req->creds) -return -EINVAL ; +return io_init_fail_req (req, -EINVAL );get_cred (req->creds); ret =security_uring_override_creds (req->creds);if (ret) {put_cred (req->creds); -return ret; +return io_init_fail_req (req, ret); } req->flags |=REQ_F_CREDS ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 14/15 drivers/nvme: Add quirks for device 126f:2262
In reply to Sasha LevinFrom: "Jiawei Fu (iBug)" <[email protected]>
[ Upstream commit e89086c43f0500bc7c4ce225495b73b8ce234c1f ]
This commit adds NVME_QUIRK_NO_DEEPEST_PS and NVME_QUIRK_BOGUS_NID for device [126f:2262], which appears to be a generic VID:PID pair used for many SSDs based on the Silicon Motion SM2262/SM2262EN controller.
Two of my SSDs with this VID:PID pair exhibit the same behavior:
* They frequently have trouble exiting the deepest power state (5), resulting in the entire disk unresponsive.
Verified by setting nvme_core.default_ps_max_latency_us=10000 and observing them behaving normally.
* They produce all-zero nguid and eui64 with nvme id-ns command.
The offending products are:
* HP SSD EX950 1TB
* HIKVISION C2000Pro 2TB
--- drivers/nvme/host/pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/nvme/host/pci.c +3 -0
@@ -3471,6 +3471,9 @@ static const struct pci_device_id nvme_id_table[] = { NVME_QUIRK_BOGUS_NID, }, { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ .driver_data = NVME_QUIRK_BOGUS_NID, }, + { PCI_DEVICE(0x126f, 0x2262), /* Silicon Motion generic */ + .driver_data = NVME_QUIRK_NO_DEEPEST_PS | + NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST | NVME_QUIRK_BOGUS_NID, },
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 15/15 fbmon: prevent division by zero in fb_videomode_from_videomode()
In reply to Sasha LevinFrom: Roman Smirnov <[email protected]>
[ Upstream commit c2d953276b8b27459baed1277a4fdd5dd9bd4126 ]
The expression htotal * vtotal can have a zero value on overflow. It is necessary to prevent division by zero like in fb_var_to_videomode().
Found by Linux Verification Center (linuxtesting.org) with Svace.
--- drivers/video/fbdev/core/fbmon.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/video/fbdev/core/fbmon.c +4 -3
@@ -1311,7 +1311,7 @@ int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var, struct fb_infint fb_videomode_from_videomode (const struct videomode *vm,struct fb_videomode *fbmode) { -unsigned int htotal, vtotal; +unsigned int htotal, vtotal, total; fbmode->xres = vm->hactive; fbmode->left_margin = vm->hback_porch;
@@ -1344,8 +1344,9 @@ int fb_videomode_from_videomode(const struct videomode *vm, vtotal = vm->vactive + vm->vfront_porch + vm->vback_porch + vm->vsync_len;/* prevent division by zero */ -if (htotal && vtotal) { - fbmode->refresh = vm->pixelclock / (htotal * vtotal); + total = htotal * vtotal; +if (total) { + fbmode->refresh = vm->pixelclock / total;/* a mode must have htotal and vtotal != 0 or it is invalid */ }else { fbmode->refresh =0 ;
Signature · 1 line
2.43.0