dmaengine: ste_dma40: fix unneeded variable warning
Subsystems (8)
Sasha Levin
maintainerPATCH 8/12 i2c: rcar: avoid race when unregistering slave client
In reply to Sasha LevinFrom: Wolfram Sang <[email protected]>
[ Upstream commit 7b814d852af6944657c2961039f404c4490771c0 ]
After we disabled interrupts, there might still be an active one running. Sync before clearing the pointer to the slave device.
--- drivers/i2c/busses/i2c-rcar.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-rcar.c +7 -4
@@ -144,6 +144,7 @@ struct rcar_i2c_priv {enum dma_data_direction dma_direction;struct reset_control *rstc; +int irq; };#define rcar_i2c_priv_to_dev (p) ((p)->adap.dev.parent)
@@ -813,9 +814,11 @@ static int rcar_unreg_slave(struct i2c_client *slave)WARN_ON (!priv->slave); +/* disable irqs and ensure none is running before clearing ptr */ rcar_i2c_write (priv,ICSIER ,0 );rcar_i2c_write (priv,ICSCR ,0 ); +synchronize_irq (priv->irq); priv->slave =NULL ;pm_runtime_put (rcar_i2c_priv_to_dev (priv));
@@ -866,7 +869,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)struct i2c_adapter *adap;struct device *dev = &pdev->dev;struct i2c_timings i2c_t; -int irq, ret; +int ret; priv =devm_kzalloc (dev,sizeof (struct rcar_i2c_priv ),GFP_KERNEL );if (!priv)
@@ -927,10 +930,10 @@ static int rcar_i2c_probe(struct platform_device *pdev)pm_runtime_put (dev); - irq =platform_get_irq (pdev,0 ); - ret =devm_request_irq (dev, irq, rcar_i2c_irq,0 ,dev_name (dev), priv); + priv->irq =platform_get_irq (pdev,0 ); + ret =devm_request_irq (dev, priv->irq, rcar_i2c_irq,0 ,dev_name (dev), priv);if (ret <0 ) { -dev_err (dev,"cannot get irq %d\n" , irq); +dev_err (dev,"cannot get irq %d\n" , priv->irq); goto out_pm_disable; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/12 i2c: emev2: avoid race when unregistering slave client
In reply to Sasha LevinFrom: Wolfram Sang <[email protected]>
[ Upstream commit d7437fc0d8291181debe032671a289b6bd93f46f ]
After we disabled interrupts, there might still be an active one running. Sync before clearing the pointer to the slave device.
--- drivers/i2c/busses/i2c-emev2.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-emev2.c +12 -4
@@ -72,6 +72,7 @@ struct em_i2c_device {struct completion msg_done;struct clk *sclk;struct i2c_client *slave; +int irq; };static inline void em_clear_set_bit (struct em_i2c_device *priv,u8 clear,u8 set,u8 reg)
@@ -342,6 +343,12 @@ static int em_i2c_unreg_slave(struct i2c_client *slave)writeb (0 , priv->base +I2C_OFS_SVA0 ); +/* +* Wait for interrupt to finish. New slave irqs cannot happen because we +* cleared the slave address and, thus, only extension codes will be +* detected which do not use the slave ptr. +*/ +synchronize_irq (priv->irq); priv->slave =NULL ;return 0 ;
@@ -358,7 +365,7 @@ static int em_i2c_probe(struct platform_device *pdev) {struct em_i2c_device *priv;struct resource *r; -int irq, ret; +int ret; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );if (!priv)
@@ -393,8 +400,8 @@ static int em_i2c_probe(struct platform_device *pdev)em_i2c_reset (&priv->adap); - irq =platform_get_irq (pdev,0 ); - ret =devm_request_irq (&pdev->dev, irq, em_i2c_irq_handler,0 , + priv->irq =platform_get_irq (pdev,0 ); + ret =devm_request_irq (&pdev->dev, priv->irq, em_i2c_irq_handler,0 ,"em_i2c" , priv);if (ret) goto err_clk;
@@ -404,7 +411,8 @@ static int em_i2c_probe(struct platform_device *pdev)if (ret) goto err_clk; -dev_info (&pdev->dev,"Added i2c controller %d, irq %d\n" , priv->adap.nr, irq); +dev_info (&pdev->dev,"Added i2c controller %d, irq %d\n" , priv->adap.nr, + priv->irq);return 0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/12 iio: adc: max9611: Fix temperature reading in probe
In reply to Sasha LevinFrom: Jacopo Mondi <[email protected]>
[ Upstream commit b9ddd5091160793ee9fac10da765cf3f53d2aaf0 ]
The max9611 driver reads the die temperature at probe time to validate the communication channel. Use the actual read value to perform the test instead of the read function return value, which was mistakenly used so far.
The temperature reading test was only successful because the 0 return value is in the range of supported temperatures.
--- drivers/iio/adc/max9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/max9611.c +1 -1
@@ -484,7 +484,7 @@ static int max9611_init(struct max9611_dev *max9611)if (ret)return ret; - regval = ret &MAX9611_TEMP_MASK ; + regval &=MAX9611_TEMP_MASK ; if ((regval > MAX9611_TEMP_MAX_POS && regval < MAX9611_TEMP_MIN_NEG) ||
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/12 iommu/dma: Handle SG length overflow better
In reply to Sasha LevinFrom: Robin Murphy <[email protected]>
[ Upstream commit ab2cbeb0ed301a9f0460078e91b09f39958212ef ]
Since scatterlist dimensions are all unsigned ints, in the relatively rare cases where a device's max_segment_size is set to UINT_MAX, then the "cur_len + s_length <= max_len" check in __finalise_sg() will always return true. As a result, the corner case of such a device mapping an excessively large scatterlist which is mergeable to or beyond a total length of 4GB can lead to overflow and a bogus truncated dma_length in the resulting segment.
As we already assume that any single segment must be no longer than max_len to begin with, this can easily be addressed by reshuffling the comparison.
--- drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +1 -1
@@ -684,7 +684,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,* - and wouldn't make the resulting output segment too long */ if (cur_len && !s_iova_off && (dma_addr & seg_mask) && - (cur_len + s_length <= max_len)) { + (max_len - cur_len >= s_length)) {/* ...then concatenate it with the previous one */ cur_len += s_length; }else {
Signature · 6 lines
2.20.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Sasha Levin
maintainerPATCH 1/12 dmaengine: ste_dma40: fix unneeded variable warning
From: Arnd Bergmann <[email protected]>
[ Upstream commit 5d6fb560729a5d5554e23db8d00eb57cd0021083 ]
clang-9 points out that there are two variables that depending on the configuration may only be used in an ARRAY_SIZE() expression but not referenced:
drivers/dma/ste_dma40.c:145:12: error: variable 'd40_backup_regs' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
static u32 d40_backup_regs[] = {
^drivers/dma/ste_dma40.c:214:12: error: variable 'd40_backup_regs_chan' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static u32 d40_backup_regs_chan[] = {
Mark these __maybe_unused to shut up the warning.
--- drivers/dma/ste_dma40.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/ste_dma40.c +2 -2
@@ -142,7 +142,7 @@ enum d40_events {* when the DMA hw is powered off. * TODO: Add save/restore of D40_DREG_GCC on dma40 v3 or later, if that works. */ -static u32 d40_backup_regs[] = { +static __maybe_unused u32 d40_backup_regs[] = {D40_DREG_LCPA ,D40_DREG_LCLA ,D40_DREG_PRMSE ,
@@ -211,7 +211,7 @@ static u32 d40_backup_regs_v4b[] = {#define BACKUP_REGS_SZ_V4B ARRAY_SIZE(d40_backup_regs_v4b) -static u32 d40_backup_regs_chan[] = { +static __maybe_unused u32 d40_backup_regs_chan[] = {D40_CHAN_REG_SSCFG ,D40_CHAN_REG_SSELT ,D40_CHAN_REG_SSPTR ,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/12 usb: gadget: mass_storage: Fix races between fsg_disable and fsg_set_alt
From: Benjamin Herrenschmidt <[email protected]>
[ Upstream commit 4a56a478a525d6427be90753451c40e1327caa1a ]
If fsg_disable() and fsg_set_alt() are called too closely to each other (for example due to a quick reset/reconnect), what can happen is that fsg_set_alt sets common->new_fsg from an interrupt while handle_exception is trying to process the config change caused by fsg_disable():
fsg_disable()
...
handle_exception()
sets state back to FSG_STATE_NORMAL hasn't yet called do_set_interface() or is inside it.
---> interrupt
fsg_set_alt sets common->new_fsg queues a new FSG_STATE_CONFIG_CHANGE
<---
Now, the first handle_exception can "see" the updated new_fsg, treats it as if it was a fsg_set_alt() response, call usb_composite_setup_continue() etc...
But then, the thread sees the second FSG_STATE_CONFIG_CHANGE, and goes back down the same path, wipes and reattaches a now active fsg, and .. calls usb_composite_setup_continue() which at this point is wrong.
Not only we get a backtrace, but I suspect the second set_interface wrecks some state causing the host to get upset in my case.
This fixes it by replacing "new_fsg" by a "state argument" (same principle) which is set in the same lock section as the state update, and retrieved similarly.
That way, there is never any discrepancy between the dequeued state and the observed value of it. We keep the ability to have the latest reconfig operation take precedence, but we guarantee that once "dequeued" the argument (new_fsg) will not be clobbered by any new event.
--- drivers/usb/gadget/function/f_mass_storage.c | 28 +++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/usb/gadget/function/f_mass_storage.c +18 -10
@@ -261,7 +261,7 @@ struct fsg_common;struct fsg_common {struct usb_gadget *gadget;struct usb_composite_dev *cdev; -struct fsg_dev *fsg, *new_fsg; +struct fsg_dev *fsg;wait_queue_head_t io_wait;wait_queue_head_t fsg_wait;
@@ -290,6 +290,7 @@ struct fsg_common {unsigned int bulk_out_maxpacket;enum fsg_state state;/* For exception handling */ unsigned int exception_req_tag; +void *exception_arg;enum data_direction data_dir;u32 data_size;
@@ -393,7 +394,8 @@ static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)/* These routines may be called in process context or in_irq */ -static void raise_exception (struct fsg_common *common,enum fsg_state new_state) +static void __raise_exception (struct fsg_common *common,enum fsg_state new_state, +void *arg) {unsigned long flags;
@@ -406,6 +408,7 @@ static void raise_exception(struct fsg_common *common, enum fsg_state new_state)if (common->state <= new_state) { common->exception_req_tag = common->ep0_req_tag; common->state = new_state; + common->exception_arg = arg;if (common->thread_task)send_sig_info (SIGUSR1 ,SEND_SIG_FORCED , common->thread_task);
@@ -413,6 +416,10 @@ static void raise_exception(struct fsg_common *common, enum fsg_state new_state)spin_unlock_irqrestore (&common->lock, flags); } +static void raise_exception (struct fsg_common *common,enum fsg_state new_state) +{ +__raise_exception (common, new_state,NULL ); +}/*-------------------------------------------------------------------------*/
@@ -2287,16 +2294,16 @@ static int do_set_interface(struct fsg_common *common, struct fsg_dev *new_fsg)static int fsg_set_alt (struct usb_function *f,unsigned intf,unsigned alt) {struct fsg_dev *fsg =fsg_from_func (f); - fsg->common->new_fsg = fsg; -raise_exception (fsg->common,FSG_STATE_CONFIG_CHANGE ); + +__raise_exception (fsg->common,FSG_STATE_CONFIG_CHANGE , fsg);return USB_GADGET_DELAYED_STATUS ; }static void fsg_disable (struct usb_function *f) {struct fsg_dev *fsg =fsg_from_func (f); - fsg->common->new_fsg =NULL ; -raise_exception (fsg->common,FSG_STATE_CONFIG_CHANGE ); + +__raise_exception (fsg->common,FSG_STATE_CONFIG_CHANGE ,NULL ); }
@@ -2309,6 +2316,7 @@ static void handle_exception(struct fsg_common *common)enum fsg_state old_state;struct fsg_lun *curlun;unsigned int exception_req_tag; +struct fsg_dev *new_fsg;/* * Clear the existing signals. Anything but SIGUSR1 is converted
@@ -2362,6 +2370,7 @@ static void handle_exception(struct fsg_common *common) common->next_buffhd_to_fill = &common->buffhds[0 ]; common->next_buffhd_to_drain = &common->buffhds[0 ]; exception_req_tag = common->exception_req_tag; + new_fsg = common->exception_arg; old_state = common->state; common->state =FSG_STATE_NORMAL ;
@@ -2415,8 +2424,8 @@ static void handle_exception(struct fsg_common *common)break ;case FSG_STATE_CONFIG_CHANGE : -do_set_interface (common, common->new_fsg); -if (common->new_fsg) +do_set_interface (common, new_fsg); +if (new_fsg)usb_composite_setup_continue (common->cdev);break ;
@@ -3007,8 +3016,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)DBG (fsg,"unbind\n" );if (fsg->common->fsg == fsg) { - fsg->common->new_fsg =NULL ; -raise_exception (fsg->common,FSG_STATE_CONFIG_CHANGE ); +__raise_exception (fsg->common,FSG_STATE_CONFIG_CHANGE ,NULL );/* FIXME: make interruptible or killable somehow? */ wait_event (common->fsg_wait, common->fsg != fsg); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/12 drm/ast: Fixed reboot test may cause system hanged
In reply to Sasha LevinFrom: "Y.C. Chen" <[email protected]>
[ Upstream commit 05b439711f6ff8700e8660f97a1179650778b9cb ]
There is another thread still access standard VGA I/O while loading drm driver. Disable standard VGA I/O decode to avoid this issue.
--- drivers/gpu/drm/ast/ast_main.c | 5 ++++- drivers/gpu/drm/ast/ast_mode.c | 2 +- drivers/gpu/drm/ast/ast_post.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_main.c +4 -1
@@ -131,8 +131,8 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)/* Enable extended register access */ -ast_enable_mmio (dev);ast_open_key (ast); +ast_enable_mmio (dev);/* Find out whether P2A works or whether to use device-tree */ ast_detect_config_mode (dev, &scu_rev);
@@ -576,6 +576,9 @@ void ast_driver_unload(struct drm_device *dev) {struct ast_private *ast = dev->dev_private; +/* enable standard VGA decode */ +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0xa1 ,0x04 ); +ast_release_firmware (dev);kfree (ast->dp501_fw_addr);ast_mode_fini (dev);
drivers/gpu/drm/ast/ast_mode.c +1 -1
@@ -600,7 +600,7 @@ static int ast_crtc_mode_set(struct drm_crtc *crtc,return -EINVAL ;ast_open_key (ast); -ast_set_index_reg_mask (ast,AST_IO_CRTC_PORT ,0xa1 ,0xff ,0x04 ); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0xa1 ,0x06 );ast_set_std_reg (crtc, adjusted_mode, &vbios_mode);ast_set_crtc_reg (crtc, adjusted_mode, &vbios_mode);
drivers/gpu/drm/ast/ast_post.c +1 -1
@@ -46,7 +46,7 @@ void ast_enable_mmio(struct drm_device *dev) {struct ast_private *ast = dev->dev_private; -ast_set_index_reg_mask (ast,AST_IO_CRTC_PORT ,0xa1 ,0xff ,0x04 ); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0xa1 ,0x06 ); }
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 11/12 usb: host: fotg2: restart hcd after port reset
In reply to Sasha LevinFrom: Hans Ulli Kroll <[email protected]>
[ Upstream commit 777758888ffe59ef754cc39ab2f275dc277732f4 ]
On the Gemini SoC the FOTG2 stalls after port reset so restart the HCD after each port reset.
--- drivers/usb/host/fotg210-hcd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/host/fotg210-hcd.c +4 -0
@@ -1652,6 +1652,10 @@ static int fotg210_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,/* see what we found out */ temp =check_reset_complete (fotg210, wIndex, status_reg,fotg210_readl (fotg210, status_reg)); + +/* restart schedule */ + fotg210->command |=CMD_RUN ; +fotg210_writel (fotg210, fotg210->command, &fotg210->regs->command); }if (!(temp & (PORT_RESUME |PORT_RESET ))) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/12 tools: hv: fix KVP and VSS daemons exit code
In reply to Sasha LevinFrom: Adrian Vladu <[email protected]>
[ Upstream commit b0995156071b0ff29a5902964a9dc8cfad6f81c0 ]
HyperV KVP and VSS daemons should exit with 0 when the '--help' or '-h' flags are used.
--- tools/hv/hv_kvp_daemon.c | 2 ++ tools/hv/hv_vss_daemon.c | 2 ++ 2 files changed, 4 insertions(+)
tools/hv/hv_kvp_daemon.c +2 -0
@@ -1380,6 +1380,8 @@ int main(int argc, char *argv[]) daemonize =0 ;break ;case 'h' : +print_usage (argv); +exit (0 );default :print_usage (argv);exit (EXIT_FAILURE );
tools/hv/hv_vss_daemon.c +2 -0
@@ -172,6 +172,8 @@ int main(int argc, char *argv[]) daemonize =0 ;break ;case 'h' : +print_usage (argv); +exit (0 );default :print_usage (argv);exit (EXIT_FAILURE );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/12 xen/blkback: fix memory leaks
In reply to Sasha LevinFrom: Wenwen Wang <[email protected]>
[ Upstream commit ae78ca3cf3d9e9f914bfcd0bc5c389ff18b9c2e0 ]
In read_per_ring_refs(), after 'req' and related memory regions are allocated, xen_blkif_map() is invoked to map the shared frame, irq, and etc. However, if this mapping process fails, no cleanup is performed, leading to memory leaks. To fix this issue, invoke the cleanup before returning the error.
--- drivers/block/xen-blkback/xenbus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/xen-blkback/xenbus.c +3 -3
@@ -973,6 +973,7 @@ static int read_per_ring_refs(struct xen_blkif_ring *ring, const char *dir) } blkif->nr_ring_pages = nr_grefs; + err = -ENOMEM ;for (i =0 ; i < nr_grefs *XEN_BLKIF_REQS_PER_PAGE ; i++) { req =kzalloc (sizeof (*req),GFP_KERNEL );if (!req)
@@ -995,7 +996,7 @@ static int read_per_ring_refs(struct xen_blkif_ring *ring, const char *dir) err =xen_blkif_map (ring, ring_ref, nr_grefs, evtchn);if (err) {xenbus_dev_fatal (dev, err,"mapping ring-ref port %u" , evtchn); -return err; + goto fail; }return 0 ;
@@ -1015,8 +1016,7 @@ static int read_per_ring_refs(struct xen_blkif_ring *ring, const char *dir) }kfree (req); } -return -ENOMEM ; - +return err; }static int connect_ring (struct backend_info *be)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/12 usb: gadget: composite: Clear "suspended" on reset/disconnect
In reply to Sasha LevinFrom: Benjamin Herrenschmidt <[email protected]>
[ Upstream commit 602fda17c7356bb7ae98467d93549057481d11dd ]
In some cases, one can get out of suspend with a reset or a disconnect followed by a reconnect. Previously we would leave a stale suspended flag set.
--- drivers/usb/gadget/composite.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/composite.c +1 -0
@@ -2008,6 +2008,7 @@ void composite_disconnect(struct usb_gadget *gadget)* disconnect callbacks? */ spin_lock_irqsave (&cdev->lock, flags); + cdev->suspended =0 ;if (cdev->config)reset_config (cdev);if (cdev->driver->disconnect)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/12 auxdisplay: panel: need to delete scan_timer when misc_register fails in panel_attach
In reply to Sasha LevinFrom: zhengbin <[email protected]>
[ Upstream commit b33d567560c1aadf3033290d74d4fd67af47aa61 ]
In panel_attach, if misc_register fails, we need to delete scan_timer, which was setup in keypad_init->init_scan_timer.
--- drivers/auxdisplay/panel.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/auxdisplay/panel.c +2 -0
@@ -1622,6 +1622,8 @@ static void panel_attach(struct parport *port)return ; err_lcd_unreg: +if (scan_timer.function) +del_timer_sync (&scan_timer);if (lcd.enabled)charlcd_unregister (lcd.charlcd); err_unreg_device:
Signature · 1 line
2.20.1