regulator: bd70528: Fix off-by-one for buck123 .n_voltages setting
Subsystems (10)
Sasha Levin
maintainerPATCH 6/15 pinctrl: ralink: rt2880: avoid to error in calls is pin is already enabled
In reply to Sasha LevinFrom: Sergio Paracuellos <[email protected]>
[ Upstream commit eb367d875f94a228c17c8538e3f2efcf2eb07ead ]
In 'rt2880_pmx_group_enable' driver is printing an error and returning -EBUSY if a pin has been already enabled. This begets anoying messages in the caller when this happens like the following:
rt2880-pinmux pinctrl: pcie is already enabled
mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
To avoid this just print the already enabled message in the pinctrl driver and return 0 instead to not confuse the user with a real bad problem.
--- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +1 -1
@@ -127,7 +127,7 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev,if (p->groups[group].enabled) {dev_err (p->dev,"%s is already enabled\n" , p->groups[group].name); -return -EBUSY ; +return 0 ; } p->groups[group].enabled =1 ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 7/15 drm/sun4i: dw-hdmi: Make HDMI PHY into a platform device
In reply to Sasha LevinFrom: Saravana Kannan <[email protected]>
[ Upstream commit 9bf3797796f570b34438235a6a537df85832bdad ]
On sunxi boards that use HDMI output, HDMI device probe keeps being avoided indefinitely with these repeated messages in dmesg:
platform 1ee0000.hdmi: probe deferral - supplier 1ef0000.hdmi-phy
not ready
There's a fwnode_link being created with fw_devlink=on between hdmi and hdmi-phy nodes, because both nodes have 'compatible' property set.
Fw_devlink code assumes that nodes that have compatible property set will also have a device associated with them by some driver eventually. This is not the case with the current sun8i-hdmi driver.
This commit makes sun8i-hdmi-phy into a proper platform device and fixes the display pipeline probe on sunxi boards that use HDMI.
More context: https://lkml.org/lkml/2021/5/16/203
--- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 31 ++++++++++++++++--- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h | 5 ++-- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 41 ++++++++++++++++++++++---- 3 files changed, 66 insertions(+), 11 deletions(-)
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +27 -4
@@ -211,7 +211,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, goto err_disable_clk_tmds; } - ret =sun8i_hdmi_phy_probe (hdmi, phy_node); + ret =sun8i_hdmi_phy_get (hdmi, phy_node);of_node_put (phy_node);if (ret) {dev_err (dev,"Couldn't get the HDMI PHY\n" );
@@ -244,7 +244,6 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, cleanup_encoder:drm_encoder_cleanup (encoder); -sun8i_hdmi_phy_remove (hdmi); err_disable_clk_tmds:clk_disable_unprepare (hdmi->clk_tmds); err_assert_ctrl_reset:
@@ -265,7 +264,6 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,struct sun8i_dw_hdmi *hdmi =dev_get_drvdata (dev);dw_hdmi_unbind (hdmi->hdmi); -sun8i_hdmi_phy_remove (hdmi);clk_disable_unprepare (hdmi->clk_tmds);reset_control_assert (hdmi->rst_ctrl);gpiod_set_value (hdmi->ddc_en,0 );
@@ -322,7 +320,32 @@ static struct platform_driver sun8i_dw_hdmi_pltfm_driver = { .of_match_table = sun8i_dw_hdmi_dt_ids, }, }; -module_platform_driver (sun8i_dw_hdmi_pltfm_driver); + +static int __init sun8i_dw_hdmi_init (void ) +{ +int ret; + + ret =platform_driver_register (&sun8i_dw_hdmi_pltfm_driver); +if (ret) +return ret; + + ret =platform_driver_register (&sun8i_hdmi_phy_driver); +if (ret) { +platform_driver_unregister (&sun8i_dw_hdmi_pltfm_driver); +return ret; + } + +return ret; +} + +static void __exit sun8i_dw_hdmi_exit(void) +{ +platform_driver_unregister (&sun8i_dw_hdmi_pltfm_driver); +platform_driver_unregister (&sun8i_hdmi_phy_driver); +} + +module_init (sun8i_dw_hdmi_init); +module_exit (sun8i_dw_hdmi_exit);MODULE_AUTHOR ("Jernej Skrabec <[email protected]>" );MODULE_DESCRIPTION ("Allwinner DW HDMI bridge" );
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +3 -2
@@ -194,14 +194,15 @@ struct sun8i_dw_hdmi {struct gpio_desc *ddc_en; }; +extern struct platform_driver sun8i_hdmi_phy_driver; +static inline struct sun8i_dw_hdmi *encoder_to_sun8i_dw_hdmi (struct drm_encoder *encoder) { return container_of(encoder, struct sun8i_dw_hdmi, encoder); } -int sun8i_hdmi_phy_probe (struct sun8i_dw_hdmi *hdmi,struct device_node *node); -void sun8i_hdmi_phy_remove (struct sun8i_dw_hdmi *hdmi); +int sun8i_hdmi_phy_get (struct sun8i_dw_hdmi *hdmi,struct device_node *node);void sun8i_hdmi_phy_init (struct sun8i_hdmi_phy *phy); void sun8i_hdmi_phy_set_ops(struct sun8i_hdmi_phy *phy,
drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +36 -5
72 lines not on this page · raw message
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 12/15 radeon: use memcpy_to/fromio for UVD fw upload
In reply to Sasha LevinFrom: Chen Li <[email protected]>
[ Upstream commit ab8363d3875a83f4901eb1cc00ce8afd24de6c85 ]
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is radeon_uvd_resume.
As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commit ba0b2275a678 ("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +2 -2
@@ -286,7 +286,7 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;
@@ -294,7 +294,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
Signature · 6 lines
2.30.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 1/15 regulator: bd70528: Fix off-by-one for buck123 .n_voltages setting
From: Axel Lin <[email protected]>
[ Upstream commit 0514582a1a5b4ac1a3fd64792826d392d7ae9ddc ]
The valid selectors for bd70528 bucks are 0 ~ 0xf, so the .n_voltages should be 16 (0x10). Use 0x10 to make it consistent with BD70528_LDO_VOLTS. Also remove redundant defines for BD70528_BUCK_VOLTS.
--- include/linux/mfd/rohm-bd70528.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
include/linux/mfd/rohm-bd70528.h +1 -3
@@ -25,9 +25,7 @@ struct bd70528_data {struct mutex rtc_timer_lock; }; -#define BD70528_BUCK_VOLTS 17 -#define BD70528_BUCK_VOLTS 17 -#define BD70528_BUCK_VOLTS 17 +#define BD70528_BUCK_VOLTS 0x10#define BD70528_LDO_VOLTS 0x20#define BD70528_REG_BUCK1_EN 0x0F
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 2/15 ASoC: rt5659: Fix the lost powers for the HDA header
From: Jack Yu <[email protected]>
[ Upstream commit 6308c44ed6eeadf65c0a7ba68d609773ed860fbb ]
The power of "LDO2", "MICBIAS1" and "Mic Det Power" were powered off after the DAPM widgets were added, and these powers were set by the JD settings "RT5659_JD_HDA_HEADER" in the probe function. In the codec probe function, these powers were ignored to prevent them controlled by DAPM.
Message-Id: <[email protected]>
--- sound/soc/codecs/rt5659.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
sound/soc/codecs/rt5659.c +21 -5
@@ -2470,13 +2470,18 @@ static int set_dmic_power(struct snd_soc_dapm_widget *w,return 0 ; } -static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { +static const struct snd_soc_dapm_widget rt5659_particular_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("LDO2" ,RT5659_PWR_ANLG_3 ,RT5659_PWR_LDO2_BIT ,0 ,NULL ,0 ), -SND_SOC_DAPM_SUPPLY ("PLL" ,RT5659_PWR_ANLG_3 ,RT5659_PWR_PLL_BIT ,0 , -NULL ,0 ), +SND_SOC_DAPM_SUPPLY ("MICBIAS1" ,RT5659_PWR_ANLG_2 ,RT5659_PWR_MB1_BIT , +0 ,NULL ,0 ),SND_SOC_DAPM_SUPPLY ("Mic Det Power" ,RT5659_PWR_VOL ,RT5659_PWR_MIC_DET_BIT ,0 ,NULL ,0 ), +}; + +static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { +SND_SOC_DAPM_SUPPLY ("PLL" ,RT5659_PWR_ANLG_3 ,RT5659_PWR_PLL_BIT ,0 , +NULL ,0 ),SND_SOC_DAPM_SUPPLY ("Mono Vref" ,RT5659_PWR_ANLG_1 ,RT5659_PWR_VREF3_BIT ,0 ,NULL ,0 ),
@@ -2501,8 +2506,6 @@ static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { RT5659_ADC_MONO_R_ASRC_SFT, 0, NULL, 0),/* Input Side */ -SND_SOC_DAPM_SUPPLY ("MICBIAS1" ,RT5659_PWR_ANLG_2 ,RT5659_PWR_MB1_BIT , -0 ,NULL ,0 ),SND_SOC_DAPM_SUPPLY ("MICBIAS2" ,RT5659_PWR_ANLG_2 ,RT5659_PWR_MB2_BIT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("MICBIAS3", RT5659_PWR_ANLG_2, RT5659_PWR_MB3_BIT,
@@ -3697,10 +3700,23 @@ static int rt5659_set_bias_level(struct snd_soc_component *component,static int rt5659_probe (struct snd_soc_component *component) { +struct snd_soc_dapm_context *dapm = +snd_soc_component_get_dapm (component);struct rt5659_priv *rt5659 =snd_soc_component_get_drvdata (component); rt5659->component = component; +switch (rt5659->pdata.jd_src) { +case RT5659_JD_HDA_HEADER : +break ; + +default : +snd_soc_dapm_new_controls (dapm, + rt5659_particular_dapm_widgets, +ARRAY_SIZE (rt5659_particular_dapm_widgets)); +break ; + } +return 0 ; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 3/15 NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error.
In reply to Sasha LevinFrom: Dai Ngo <[email protected]>
[ Upstream commit f8849e206ef52b584cd9227255f4724f0cc900bb ]
Currently if __nfs4_proc_set_acl fails with NFS4ERR_BADOWNER it re-enables the idmapper by clearing NFS_CAP_UIDGID_NOMAP before retrying again. The NFS_CAP_UIDGID_NOMAP remains cleared even if the retry fails. This causes problem for subsequent setattr requests for v4 server that does not have idmapping configured.
This patch modifies nfs4_proc_set_acl to detect NFS4ERR_BADOWNER and NFS4ERR_BADNAME and skips the retry, since the kernel isn't involved in encoding the ACEs, and return -EINVAL.
Steps to reproduce the problem:
# mount -o vers=4.1,sec=sys server:/export/test /tmp/mnt # touch /tmp/mnt/file1 # chown 99 /tmp/mnt/file1 # nfs4_setfacl -a A::[email protected]:wrtncy /tmp/mnt/file1 Failed setxattr operation: Invalid argument # chown 99 /tmp/mnt/file1 chown: changing ownership of ‘/tmp/mnt/file1’: Invalid argument # umount /tmp/mnt # mount -o vers=4.1,sec=sys server:/export/test /tmp/mnt # chown 99 /tmp/mnt/file1 #
v2: detect NFS4ERR_BADOWNER and NFS4ERR_BADNAME and skip retry
in nfs4_proc_set_acl.
--- fs/nfs/nfs4proc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/nfs/nfs4proc.c +8 -0
@@ -5795,6 +5795,14 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflendo { err =__nfs4_proc_set_acl (inode, buf, buflen);trace_nfs4_set_acl (inode, err); +if (err == -NFS4ERR_BADOWNER || err == -NFS4ERR_BADNAME ) { +/* +* no need to retry since the kernel +* isn't involved in encoding the ACEs. +*/ + err = -EINVAL ; +break ; + } err =nfs4_handle_exception (NFS_SERVER (inode), err, &exception); }while (exception.retry);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 4/15 spi: stm32-qspi: Always wait BUSY bit to be cleared in stm32_qspi_wait_cmd()
In reply to Sasha LevinFrom: Patrice Chotard <[email protected]>
[ Upstream commit d38fa9a155b2829b7e2cfcf8a4171b6dd3672808 ]
In U-boot side, an issue has been encountered when QSPI source clock is running at low frequency (24 MHz for example), waiting for TCF bit to be set didn't ensure that all data has been send out the FIFO, we should also wait that BUSY bit is cleared.
To prevent similar issue in kernel driver, we implement similar behavior by always waiting BUSY bit to be cleared.
--- drivers/spi/spi-stm32-qspi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-stm32-qspi.c +4 -1
@@ -291,7 +291,7 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi,int err =0 ;if (!op->data.nbytes) -return stm32_qspi_wait_nobusy (qspi); + goto wait_nobusy;if (readl_relaxed (qspi->io_base +QSPI_SR ) &SR_TCF ) goto out;
@@ -312,6 +312,9 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, out:/* clear flags */ writel_relaxed (FCR_CTCF |FCR_CTEF , qspi->io_base +QSPI_FCR ); +wait_nobusy: +if (!err) + err =stm32_qspi_wait_nobusy (qspi);return err; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 5/15 NFSv4: Fix second deadlock in nfs4_evict_inode()
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
[ Upstream commit c3aba897c6e67fa464ec02b1f17911577d619713 ]
If the inode is being evicted but has to return a layout first, then that too can cause a deadlock in the corner case where the server reboots.
--- fs/nfs/nfs4proc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +7 -2
@@ -9340,15 +9340,20 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) &task_setup_data.rpc_client, &msg);dprintk ("--> %s\n" , __func__); + lrp->inode =nfs_igrab_and_active (lrp->args.inode);if (!sync) { - lrp->inode =nfs_igrab_and_active (lrp->args.inode);if (!lrp->inode) {nfs4_layoutreturn_release (lrp);return -EAGAIN ; } task_setup_data.flags |=RPC_TASK_ASYNC ; } -nfs4_init_sequence (&lrp->args.seq_args, &lrp->res.seq_res,1 ,0 ); +if (!lrp->inode) +nfs4_init_sequence (&lrp->args.seq_args, &lrp->res.seq_res,1 , +1 ); +else +nfs4_init_sequence (&lrp->args.seq_args, &lrp->res.seq_res,1 , +0 ); task =rpc_run_task (&task_setup_data);if (IS_ERR (task))return PTR_ERR (task);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 8/15 scsi: core: Fix error handling of scsi_host_alloc()
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 66a834d092930cf41d809c0e989b13cd6f9ca006 ]
After device is initialized via device_initialize(), or its name is set via dev_set_name(), the device has to be freed via put_device(). Otherwise device name will be leaked because it is allocated dynamically in dev_set_name().
Fix the leak by replacing kfree() with put_device(). Since scsi_host_dev_release() properly handles IDA and kthread removal, remove special-casing these from the error handling as well.
--- drivers/scsi/hosts.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/scsi/hosts.c +13 -10
@@ -389,8 +389,10 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)mutex_init (&shost->scan_mutex); index =ida_simple_get (&host_index_ida,0 ,0 ,GFP_KERNEL ); -if (index <0 ) - goto fail_kfree; +if (index <0 ) { +kfree (shost); +return NULL ; + } shost->host_no = index; shost->dma_channel =0xff ;
@@ -482,7 +484,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)shost_printk (KERN_WARNING , shost,"error handler thread failed to spawn, error = %ld\n" ,PTR_ERR (shost->ehandler)); - goto fail_index_remove; + goto fail; } shost->tmf_work_q = alloc_workqueue("scsi_tmf_%d",
@@ -491,17 +493,18 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)if (!shost->tmf_work_q) {shost_printk (KERN_WARNING , shost,"failed to create tmf workq\n" ); - goto fail_kthread; + goto fail; }scsi_proc_hostdir_add (shost->hostt);return shost; + fail: +/* +* Host state is still SHOST_CREATED and that is enough to release +* ->shost_gendev. scsi_host_dev_release() will free +* dev_name(&shost->shost_dev). +*/ +put_device (&shost->shost_gendev); - fail_kthread: -kthread_stop (shost->ehandler); - fail_index_remove: -ida_simple_remove (&host_index_ida, shost->host_no); - fail_kfree: -kfree (shost);return NULL ; }EXPORT_SYMBOL (scsi_host_alloc);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 9/15 scsi: core: Fix failure handling of scsi_add_host_with_dma()
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 3719f4ff047e20062b8314c23ec3cab84d74c908 ]
When scsi_add_host_with_dma() returns failure, the caller will call scsi_host_put(shost) to release everything allocated for this host instance. Consequently we can't also free allocated stuff in scsi_add_host_with_dma(), otherwise we will end up with a double free.
Strictly speaking, host resource allocations should have been done in scsi_host_alloc(). However, the allocations may need information which is not yet provided by the driver when that function is called. So leave the allocations where they are but rely on host device's release handler to free resources.
--- drivers/scsi/hosts.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/scsi/hosts.c +6 -8
@@ -275,23 +275,22 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, shost->work_q_name);if (!shost->work_q) { error = -EINVAL ; - goto out_free_shost_data; + goto out_del_dev; } } error =scsi_sysfs_add_host (shost);if (error) - goto out_destroy_host; + goto out_del_dev;scsi_proc_host_add (shost);scsi_autopm_put_host (shost);return error; - out_destroy_host: -if (shost->work_q) -destroy_workqueue (shost->work_q); - out_free_shost_data: -kfree (shost->shost_data); +/* +* Any host allocation in this function will be freed in +* scsi_host_dev_release(). +*/ out_del_dev:device_del (&shost->shost_dev); out_del_gendev:
@@ -301,7 +300,6 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,pm_runtime_disable (&shost->shost_gendev);pm_runtime_set_suspended (&shost->shost_gendev);pm_runtime_put_noidle (&shost->shost_gendev); -scsi_mq_destroy_tags (shost); fail:return error; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 10/15 scsi: core: Put .shost_dev in failure path if host state changes to RUNNING
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 11714026c02d613c30a149c3f4c4a15047744529 ]
scsi_host_dev_release() only frees dev_name when host state is SHOST_CREATED. After host state has changed to SHOST_RUNNING, scsi_host_dev_release() no longer cleans up.
Fix this by doing a put_device(&shost->shost_dev) in the failure path when host state is SHOST_RUNNING. Move get_device(&shost->shost_gendev) before device_add(&shost->shost_dev) so that scsi_host_cls_release() can do a put on this reference.
--- drivers/scsi/hosts.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/hosts.c +6 -2
@@ -253,12 +253,11 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,device_enable_async_suspend (&shost->shost_dev); +get_device (&shost->shost_gendev); error =device_add (&shost->shost_dev);if (error) goto out_del_gendev; -get_device (&shost->shost_gendev); -if (shost->transportt->host_size) { shost->shost_data =kzalloc (shost->transportt->host_size,GFP_KERNEL );
@@ -294,6 +293,11 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, out_del_dev:device_del (&shost->shost_dev); out_del_gendev: +/* +* Host state is SHOST_RUNNING so we have to explicitly release +* ->shost_dev. +*/ +put_device (&shost->shost_dev);device_del (&shost->shost_gendev); out_disable_runtime_pm:device_disable_async_suspend (&shost->shost_gendev);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 11/15 scsi: core: Only put parent device if host state differs from SHOST_CREATED
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 1e0d4e6225996f05271de1ebcb1a7c9381af0b27 ]
get_device(shost->shost_gendev.parent) is called after host state has switched to SHOST_RUNNING. scsi_host_dev_release() shouldn't release the parent device if host state is still SHOST_CREATED.
--- drivers/scsi/hosts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hosts.c +1 -1
@@ -344,7 +344,7 @@ static void scsi_host_dev_release(struct device *dev)ida_simple_remove (&host_index_ida, shost->host_no); -if (parent) +if (shost->shost_state !=SHOST_CREATED )put_device (parent);kfree (shost); }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 13/15 kvm: avoid speculation-based attacks from out-of-range memslot accesses
In reply to Sasha LevinFrom: Paolo Bonzini <[email protected]>
[ Upstream commit da27a83fd6cc7780fea190e1f5c19e87019da65c ]
KVM's mechanism for accessing guest memory translates a guest physical address (gpa) to a host virtual address using the right-shifted gpa (also known as gfn) and a struct kvm_memory_slot. The translation is performed in __gfn_to_hva_memslot using the following formula:
hva = slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE
It is expected that gfn falls within the boundaries of the guest's physical memory. However, a guest can access invalid physical addresses in such a way that the gfn is invalid.
__gfn_to_hva_memslot is called from kvm_vcpu_gfn_to_hva_prot, which first retrieves a memslot through __gfn_to_memslot. While __gfn_to_memslot does check that the gfn falls within the boundaries of the guest's physical memory or not, a CPU can speculate the result of the check and continue execution speculatively using an illegal gfn. The speculation can result in calculating an out-of-bounds hva. If the resulting host virtual address is used to load another guest physical address, this is effectively a Spectre gadget consisting of two consecutive reads, the second of which is data dependent on the first.
Right now it's not clear if there are any cases in which this is exploitable. One interesting case was reported by the original author of this patch, and involves visiting guest page tables on x86. Right now these are not vulnerable because the hva read goes through get_user(), which contains an LFENCE speculation barrier. However, there are patches in progress for x86 uaccess.h to mask kernel addresses instead of using LFENCE; once these land, a guest could use speculation to read from the VMM's ring 3 address space. Other architectures such as ARM already use the address masking method, and would be susceptible to this same kind of data-dependent access gadgets. Therefore, this patch proactively protects from these attacks by masking out-of-bounds gfns in __gfn_to_hva_memslot, which blocks speculation of invalid hvas.
Sean Christopherson noted that this patch does not cover kvm_read_guest_offset_cached. This however is limited to a few bytes past the end of the cache, and therefore it is unlikely to be useful in the context of building a chain of data dependent accesses.
--- include/linux/kvm_host.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
include/linux/kvm_host.h +9 -1
@@ -1045,7 +1045,15 @@ __gfn_to_memslot(struct kvm_memslots *slots, gfn_t gfn)static inline unsigned long __gfn_to_hva_memslot (struct kvm_memory_slot *slot,gfn_t gfn) { -return slot->userspace_addr + (gfn - slot->base_gfn) *PAGE_SIZE ; +/* +* The index was checked originally in search_memslots. To avoid +* that a malicious guest builds a Spectre gadget out of e.g. page +* table walks, do not let the processor speculate loads outside +* the guest's registered memslots. +*/ +unsigned long offset =array_index_nospec (gfn - slot->base_gfn, + slot->npages); +return slot->userspace_addr + offset *PAGE_SIZE ; }static inline int memslot_id (struct kvm *kvm,gfn_t gfn)
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 14/15 kvm: fix previous commit for 32-bit builds
In reply to Sasha LevinFrom: Paolo Bonzini <[email protected]>
[ Upstream commit 4422829e8053068e0225e4d0ef42dc41ea7c9ef5 ]
array_index_nospec does not work for uint64_t on 32-bit builds. However, the size of a memory slot must be less than 20 bits wide on those system, since the memory slot must fit in the user address space. So just store it in an unsigned long.
--- include/linux/kvm_host.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/kvm_host.h +2 -2
@@ -1051,8 +1051,8 @@ __gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn)* table walks, do not let the processor speculate loads outside * the guest's registered memslots. */ -unsigned long offset =array_index_nospec (gfn - slot->base_gfn, - slot->npages); +unsigned long offset = gfn - slot->base_gfn; + offset =array_index_nospec (offset, slot->npages);return slot->userspace_addr + offset *PAGE_SIZE ; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 15/15 hwmon: (scpi-hwmon) shows the negative temperature properly
In reply to Sasha LevinFrom: Riwen Lu <[email protected]>
[ Upstream commit 78d13552346289bad4a9bf8eabb5eec5e5a321a5 ]
The scpi hwmon shows the sub-zero temperature in an unsigned integer, which would confuse the users when the machine works in low temperature environment. This shows the sub-zero temperature in an signed value and users can get it properly from sensors.
--- drivers/hwmon/scpi-hwmon.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/hwmon/scpi-hwmon.c +9 -0
@@ -99,6 +99,15 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf)scpi_scale_reading (&value, sensor); +/* +* Temperature sensor values are treated as signed values based on +* observation even though that is not explicitly specified, and +* because an unsigned u64 temperature does not really make practical +* sense especially when the temperature is below zero degrees Celsius. +*/ +if (sensor->info.class ==TEMPERATURE ) +return sprintf (buf,"%lld\n" , (s64 )value); +return sprintf (buf,"%llu\n" , value); }
Signature · 1 line
2.30.2
Re: [PATCH AUTOSEL 5.4 07/15] drm/sun4i: dw-hdmi: Make HDMI PHY into a platform device
In reply to Sasha LevinQuoted 11 lines · Sasha Levin
From: Saravana Kannan <[email protected]>
[ Upstream commit
9bf3797796f570b34438235a6a537df85832bdad]On sunxi boards that use HDMI output, HDMI device probe keeps being avoided indefinitely with these repeated messages in dmesg:
platform 1ee0000.hdmi: probe deferral - supplier 1ef0000.hdmi-phy
not ready
Quoted 8 lines
There's a
fwnode_linkbeing created with fw_devlink=on between hdmi and hdmi-phy nodes, because both nodes have 'compatible' property set.
Fw_devlinkcode assumes that nodes that have compatible property set will also have a device associated with them by some driver eventually. This is not the case with the current sun8i-hdmi driver.
fw_devlink isn't present in 5.4 or earlier. So technically this patch isn't needed.
-Saravana
Quoted 186 lines
This commit makes sun8i-hdmi-phy into a proper platform device and fixes the display pipeline probe on sunxi boards that use HDMI.
More context: https://lkml.org/lkml/2021/5/16/203
Signed-off-by Saravana Kannan <[email protected]>Signed-off-by Ondrej Jirman <[email protected]>Tested-by Andre Przywara <[email protected]>Signed-off-by Maxime Ripard <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 31 ++++++++++++++++--- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h | 5 ++-- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 41 ++++++++++++++++++++++---- 3 files changed, 66 insertions(+), 11 deletions(-)drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +27
-4@@ -211,7 +211,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, goto err_disable_clk_tmds; } - ret =sun8i_hdmi_phy_probe (hdmi, phy_node); + ret =sun8i_hdmi_phy_get (hdmi, phy_node);of_node_put (phy_node);if (ret) {dev_err (dev,"Couldn't get the HDMI PHY\n" );@@ -244,7 +244,6 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, cleanup_encoder:drm_encoder_cleanup (encoder); -sun8i_hdmi_phy_remove (hdmi); err_disable_clk_tmds:clk_disable_unprepare (hdmi->clk_tmds); err_assert_ctrl_reset:@@ -265,7 +264,6 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,struct sun8i_dw_hdmi *hdmi =dev_get_drvdata (dev);dw_hdmi_unbind (hdmi->hdmi); -sun8i_hdmi_phy_remove (hdmi);clk_disable_unprepare (hdmi->clk_tmds);reset_control_assert (hdmi->rst_ctrl);gpiod_set_value (hdmi->ddc_en,0 );@@ -322,7 +320,32 @@ static struct platform_driver sun8i_dw_hdmi_pltfm_driver = { .of_match_table = sun8i_dw_hdmi_dt_ids, }, }; -module_platform_driver (sun8i_dw_hdmi_pltfm_driver); + +static int __init sun8i_dw_hdmi_init (void ) +{ +int ret; + + ret =platform_driver_register (&sun8i_dw_hdmi_pltfm_driver); +if (ret) +return ret; + + ret =platform_driver_register (&sun8i_hdmi_phy_driver); +if (ret) { +platform_driver_unregister (&sun8i_dw_hdmi_pltfm_driver); +return ret; + } + +return ret; +} + +static void __exit sun8i_dw_hdmi_exit(void) +{ +platform_driver_unregister (&sun8i_dw_hdmi_pltfm_driver); +platform_driver_unregister (&sun8i_hdmi_phy_driver); +} + +module_init (sun8i_dw_hdmi_init); +module_exit (sun8i_dw_hdmi_exit);MODULE_AUTHOR ("Jernej Skrabec <[email protected]>" );MODULE_DESCRIPTION ("Allwinner DW HDMI bridge" );drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +3
-2@@ -194,14 +194,15 @@ struct sun8i_dw_hdmi {struct gpio_desc *ddc_en; }; +extern struct platform_driver sun8i_hdmi_phy_driver; +static inline struct sun8i_dw_hdmi *encoder_to_sun8i_dw_hdmi (struct drm_encoder *encoder) { return container_of(encoder, struct sun8i_dw_hdmi, encoder); } -int sun8i_hdmi_phy_probe (struct sun8i_dw_hdmi *hdmi,struct device_node *node); -void sun8i_hdmi_phy_remove (struct sun8i_dw_hdmi *hdmi); +int sun8i_hdmi_phy_get (struct sun8i_dw_hdmi *hdmi,struct device_node *node);void sun8i_hdmi_phy_init (struct sun8i_hdmi_phy *phy); void sun8i_hdmi_phy_set_ops(struct sun8i_hdmi_phy *phy,drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +36
-6@@ -5,6 +5,7 @@#include <linux/delay.h> #include <linux/of_address.h> +#include <linux/of_platform.h> #include "sun8i_dw_hdmi.h" @@ -596,10 +597,30 @@ static const struct of_device_id sun8i_hdmi_phy_of_table[] = { {/* sentinel */ } }; -int sun8i_hdmi_phy_probe (struct sun8i_dw_hdmi *hdmi,struct device_node *node) +int sun8i_hdmi_phy_get (struct sun8i_dw_hdmi *hdmi,struct device_node *node) +{ +struct platform_device *pdev =of_find_device_by_node (node); +struct sun8i_hdmi_phy *phy; + +if (!pdev) +return -EPROBE_DEFER ; + + phy =platform_get_drvdata (pdev); +if (!phy) +return -EPROBE_DEFER ; + + hdmi->phy = phy; + +put_device (&pdev->dev); + +return 0 ; +} + +static int sun8i_hdmi_phy_probe (struct platform_device *pdev) {const struct of_device_id *match; -struct device *dev = hdmi->dev; +struct device *dev = &pdev->dev; +struct device_node *node = dev->of_node;struct sun8i_hdmi_phy *phy;struct resource res;void __iomem *regs;@@ -703,7 +724,7 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)clk_prepare_enable (phy->clk_phy); } - hdmi->phy = phy; +platform_set_drvdata (pdev, phy);return 0 ;@@ -727,9 +748,9 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)return ret; } -void sun8i_hdmi_phy_remove (struct sun8i_dw_hdmi *hdmi) +static int sun8i_hdmi_phy_remove (struct platform_device *pdev) { -struct sun8i_hdmi_phy *phy = hdmi->phy; +struct sun8i_hdmi_phy *phy =platform_get_drvdata (pdev);clk_disable_unprepare (phy->clk_mod);clk_disable_unprepare (phy->clk_bus);@@ -743,4 +764,14 @@ void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi)clk_put (phy->clk_pll1);clk_put (phy->clk_mod);clk_put (phy->clk_bus); +return 0 ; } + +struct platform_driver sun8i_hdmi_phy_driver = { + .probe = sun8i_hdmi_phy_probe, + .remove = sun8i_hdmi_phy_remove, + .driver = { + .name ="sun8i-hdmi-phy" , + .of_match_table = sun8i_hdmi_phy_of_table, + }, +}; --2.30.2
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.4 07/15] drm/sun4i: dw-hdmi: Make HDMI PHY into a platform device
Quoted 15 lines · Saravana Kannan
Quoted 14 lines · Sasha Levin
From: Saravana Kannan <[email protected]>
[ Upstream commit
9bf3797796f570b34438235a6a537df85832bdad]On sunxi boards that use HDMI output, HDMI device probe keeps being avoided indefinitely with these repeated messages in dmesg:
platform 1ee0000.hdmi: probe deferral - supplier 1ef0000.hdmi-phy
not readyThere's a
fwnode_linkbeing created with fw_devlink=on between hdmi and hdmi-phy nodes, because both nodes have 'compatible' property set.
Quoted 8 lines
Quoted 5 lines
Fw_devlinkcode assumes that nodes that have compatible property set will also have a device associated with them by some driver eventually. This is not the case with the current sun8i-hdmi driver.
fw_devlinkisn't present in 5.4 or earlier. So technically this patch isn't needed.
I'll drop it from <=5.4, thanks!
Signature · 2 lines
Thanks, Sasha