sound/pci: fix-up sleeping paths
Subsystems (7)
PATCH 1/14 sound/pci: fix-up sleeping paths
From: Nishanth Aravamudan <[email protected]>
Jaroslav, I realize that you are not the explicit maintainer for many of these drivers, but I figured you would at least be able to {N,}ACK the changes. I tried to add any Maintainers I could find to the recipient list, and hope any I missed are on one of the two lists. I'm sorry for having put them into the same patchset, and if split patches would be preferred, I can do that.
Description: Fix-up sleeping in sound/pci. These changes fall under the following two categories:
1) Replace schedule_timeout() with msleep() to guarantee the task delays as expected. This also involved replacing/removing custom sleep functions.
2) Do not assume jiffies will only increment by one if you request a 1 jiffy sleep, i.e. use time_after/time_before in while loops.
Patch is compile-tested.
---
ac97/ac97_codec.c | 17 +++++++++-------- ali5451/ali5451.c | 4 ++-- cs46xx/cs46xx_lib.c | 15 +++++---------- ens1370.c | 12 +----------- es1968.c | 14 ++++---------- intel8x0.c | 3 +-- maestro3.c | 22 +++++++--------------- mixart/mixart.c | 4 ++-- rme9652/hdsp.c | 6 ++---- trident/trident_main.c | 3 +-- via82xx.c | 13 ++++++------- via82xx_modem.c | 13 ++++++------- ymfpci/ymfpci_main.c | 6 +++--- 13 files changed, 49 insertions(+), 83 deletions(-)
sound/pci/ac97/ac97_codec.c +9 -8
@@ -2225,6 +2225,7 @@ void snd_ac97_restore_iec958(ac97_t *ac9void snd_ac97_resume (ac97_t *ac97) {int i; +unsigned long end_time;if (ac97->bus->ops->reset) { ac97->bus->ops->reset (ac97);
@@ -2242,26 +2243,26 @@ void snd_ac97_resume(ac97_t *ac97)snd_ac97_write (ac97,AC97_POWERDOWN , ac97->regs[AC97_POWERDOWN ]);if (ac97_is_audio (ac97)) { ac97->bus->ops->write (ac97,AC97_MASTER ,0x8101 ); -for (i =HZ /10 ; i >=0 ; i--) { + end_time = jiffies +msecs_to_jiffies (100 ); +do {if (snd_ac97_read (ac97,AC97_MASTER ) =0x8101 )break ;set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (1 ); - } + }while (time_after_eq (end_time, jiffies));/* FIXME: extra delay */ ac97->bus->ops->write (ac97,AC97_MASTER ,0x8000 ); -if (snd_ac97_read (ac97,AC97_MASTER ) !=0x8000 ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /4 ); - } +if (snd_ac97_read (ac97,AC97_MASTER ) !=0x8000 ) +msleep (250 ); }else { -for (i =HZ /10 ; i >=0 ; i--) { + end_time = jiffies +msecs_to_jiffies (100 ); +do {unsigned short val =snd_ac97_read (ac97,AC97_EXTENDED_MID );if (val !=0xffff && (val &1 ) !=0 )break ;set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (1 ); - } + }while (time_after_eq (end_time, jiffies)); } __reset_ready:
sound/pci/ali5451/ali5451.c +2 -2
@@ -399,7 +399,7 @@ static int snd_ali_codec_ready( ali_t *cunsigned long end_time;unsigned int res; - end_time = jiffies +10 * (HZ >>2 ); + end_time = jiffies +10 *msecs_to_jiffies (250 ); do { res = snd_ali_5451_peek(codec,port); if (! (res & 0x8000))
@@ -422,7 +422,7 @@ static int snd_ali_stimer_ready(ali_t *c dwChk1 =snd_ali_5451_peek (codec,ALI_STIMER ); dwChk2 =snd_ali_5451_peek (codec,ALI_STIMER ); - end_time = jiffies +10 * (HZ >>2 ); + end_time = jiffies +10 *msecs_to_jiffies (250 ); do { dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); if (dwChk2 != dwChk1)
sound/pci/cs46xx/cs46xx_lib.c +5 -10
@@ -2400,8 +2400,7 @@ static void snd_cs46xx_codec_reset (ac97if ((err =snd_ac97_read (ac97,AC97_REC_GAIN )) =0x8a05 )return ; -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /100 ); +msleep (10 ); }while (time_after_eq (end_time, jiffies));snd_printk ("CS46xx secondary codec dont respond!\n" );
@@ -2435,8 +2434,7 @@ static int __devinit cs46xx_detect_codec err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97[codec]);return err; } -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ /100 ); +msleep (10 ); }snd_printdd ("snd_cs46xx: codec %d detection timeout\n" , codec);return -ENXIO ;
@@ -3018,8 +3016,7 @@ static int snd_cs46xx_chip_init(cs46xx_t/* * Wait until the PLL has stabilized. */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /10 );/* 100ms */ +msleep (100 );/* * Turn on clocking of the core so that we can setup the serial ports.
@@ -3072,8 +3069,7 @@ static int snd_cs46xx_chip_init(cs46xx_t*/ if (snd_cs46xx_peekBA0 (chip,BA0_ACSTS ) &ACSTS_CRDY ) goto ok1; -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout ((HZ +99 )/100 ); +msleep (10 ); }
@@ -3122,8 +3118,7 @@ static int snd_cs46xx_chip_init(cs46xx_t*/ if ((snd_cs46xx_peekBA0 (chip,BA0_ACISV ) & (ACISV_ISV3 |ACISV_ISV4 )) = (ACISV_ISV3 |ACISV_ISV4 )) goto ok2; -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout ((HZ +99 )/100 ); +msleep (10 ); }#ifndef CONFIG_SND_CS46XX_NEW_DSP
sound/pci/ens1370.c +1 -11
@@ -2008,21 +2008,11 @@ static int __devinit snd_ensoniq_create(if (pci->vendor = es1371_ac97_reset_hack[idx].vid && pci->device = es1371_ac97_reset_hack[idx].did && ensoniq->rev = es1371_ac97_reset_hack[idx].rev) { -unsigned long tmo; -signed long tmo2; - ensoniq->cssr |=ES_1371_ST_AC97_RST ;outl (ensoniq->cssr,ES_REG (ensoniq,STATUS ));/* need to delay around 20ms(bleech) to give some CODECs enough time to wakeup */ - tmo = jiffies + (HZ /50 ) +1 ; -while (1 ) { - tmo2 = tmo - jiffies; -if (tmo2 <=0 ) -break ; -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (tmo2); - } +msleep (20 );break ; }/* AC'97 warm reset to start the bitclk */
sound/pci/es1968.c +4 -10
@@ -664,11 +664,6 @@ inline static u16 maestro_read(es1968_treturn result; } -#define big_mdelay (msec) do {\ - set_current_state(TASK_UNINTERRUPTIBLE);\ - schedule_timeout(((msec) * HZ + 999) / 1000);\ -} while (0) -/* Wait for the codec bus to be free */ static int snd_es1968_ac97_wait (es1968_t *chip) {
@@ -1809,8 +1804,7 @@ static void __devinit es1968_measure_closnd_es1968_trigger_apu (chip, apu,ESM_APU_16BITLINEAR );do_gettimeofday (&start_time);spin_unlock_irq (&chip->reg_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /20 );/* 50 msec */ +msleep (50 );spin_lock_irq (&chip->reg_lock); offset =__apu_get_register (chip, apu,5 );do_gettimeofday (&stop_time);
@@ -2093,7 +2087,7 @@ static void snd_es1968_ac97_reset(es1968outw (0x0000 , ioaddr +0x60 );/* write 0 to gpio 0 */ udelay (20 );outw (0x0001 , ioaddr +0x60 );/* write 1 to gpio 1 */ -big_mdelay (20 ); +msleep (20 );outw (save_68 |0x1 , ioaddr +0x68 );/* now restore .. */ outw ((inw (ioaddr +0x38 ) &0xfffc ) |0x1 , ioaddr +0x38 );
@@ -2109,7 +2103,7 @@ static void snd_es1968_ac97_reset(es1968outw (0x0001 , ioaddr +0x60 );/* write 1 to gpio */ udelay (20 );outw (0x0009 , ioaddr +0x60 );/* write 9 to gpio */ -big_mdelay (500 ); +msleep (500 );//outw(inw(ioaddr + 0x38) & 0xfffc, ioaddr + 0x38); outw (inw (ioaddr +0x3a ) &0xfffc , ioaddr +0x3a );outw (inw (ioaddr +0x3c ) &0xfffc , ioaddr +0x3c );
@@ -2135,7 +2129,7 @@ static void snd_es1968_ac97_reset(es1968if (w >10000 ) {outb (inb (ioaddr +0x37 ) |0x08 , ioaddr +0x37 );/* do a software reset */ -big_mdelay (500 );/* oh my.. */ +msleep (500 );/* oh my.. */ outb (inb (ioaddr +0x37 ) & ~0x08 , ioaddr +0x37 );udelay (1 );
sound/pci/intel8x0.c +1 -2
@@ -2451,8 +2451,7 @@ static void __devinit intel8x0_measure_a }do_gettimeofday (&start_time);spin_unlock_irq (&chip->reg_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /20 ); +msleep (50 );spin_lock_irq (&chip->reg_lock);/* check the position */ pos = ichdev->fragsize1;
sound/pci/maestro3.c +7 -15
@@ -1050,11 +1050,6 @@ static struct m3_hv_quirk m3_hv_quirk_li* lowlevel functions */ -#define big_mdelay (msec) do {\ - set_current_state(TASK_UNINTERRUPTIBLE);\ - schedule_timeout(((msec) * HZ) / 1000);\ -} while (0) -inline static void snd_m3_outw (m3_t *chip,u16 value,unsigned long reg) {outw (value, chip->iobase + reg);
@@ -1096,7 +1091,7 @@ static void snd_m3_assp_write(m3_t *chipstatic void snd_m3_assp_halt (m3_t *chip) { chip->reset_state =snd_m3_inb (chip,DSP_PORT_CONTROL_REG_B ) & ~REGB_STOP_CLOCK ; -big_mdelay (10 ); +msleep (10 );snd_m3_outb (chip, chip->reset_state & ~REGB_ENABLE_RESET ,DSP_PORT_CONTROL_REG_B ); }
@@ -2080,8 +2075,7 @@ static void snd_m3_ac97_reset(m3_t *chipoutw (0 , io +GPIO_DATA );outw (dir |GPO_PRIMARY_AC97 , io +GPIO_DIRECTION ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout ((delay1 *HZ ) /1000 ); +msleep (delay1);outw (GPO_PRIMARY_AC97 , io +GPIO_DATA );udelay (5 );
@@ -2089,8 +2083,7 @@ static void snd_m3_ac97_reset(m3_t *chipoutw (IO_SRAM_ENABLE |SERIAL_AC_LINK_ENABLE , io +RING_BUS_CTRL_A );outw (~0 , io +GPIO_MASK ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout ((delay2 *HZ ) /1000 ); +msleep (delay2);if (!snd_m3_try_read_vendor (chip))break ;
@@ -2108,9 +2101,9 @@ static void snd_m3_ac97_reset(m3_t *chip*/ tmp =inw (io +RING_BUS_CTRL_A );outw (RAC_SDFS_ENABLE |LAC_SDFS_ENABLE , io +RING_BUS_CTRL_A ); -big_mdelay (20 ); +msleep (20 );outw (tmp, io +RING_BUS_CTRL_A ); -big_mdelay (50 ); +msleep (50 );#endif }
@@ -2135,8 +2128,7 @@ static int __devinit snd_m3_mixer(m3_t */* seems ac97 PCM needs initialization.. hack hack.. */ snd_ac97_write (chip->ac97,AC97_PCM ,0x8000 | (15 <<8 ) |15 ); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /10 ); +msleep (100 );snd_ac97_write (chip->ac97,AC97_PCM ,0 );memset (&id,0 ,sizeof (id));
@@ -2589,7 +2581,7 @@ static int m3_suspend(snd_card_t *card,snd_pcm_suspend_all (chip->pcm);snd_ac97_suspend (chip->ac97); -big_mdelay (10 );/* give the assp a chance to idle.. */ +msleep (10 );/* give the assp a chance to idle.. */ snd_m3_assp_halt (chip);
sound/pci/mixart/mixart.c +2 -2
@@ -445,9 +445,9 @@ static int snd_mixart_trigger(snd_pcm_sustatic int mixart_sync_nonblock_events (mixart_mgr_t *mgr) { -int timeout =HZ ; +unsigned long timeout = jiffies +HZ ;while (atomic_read (&mgr->msg_processed) >0 ) { -if (! timeout--) { +if (time_after (jiffies, timeout)) {snd_printk (KERN_ERR "mixart: cannot process nonblock events!\n" );return -EBUSY ; }
sound/pci/rme9652/hdsp.c +2 -4
@@ -678,8 +678,7 @@ static int snd_hdsp_load_firmware_from_c }if ((1000 /HZ ) <3000 ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout ((3000 *HZ +999 ) /1000 ); +ssleep (3 ); }else {mdelay (3000 ); }
@@ -5036,8 +5035,7 @@ static int __devinit snd_hdsp_create(sndif (!is_9652 && !is_9632) {/* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */ if ((1000 /HZ ) <2000 ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout ((2000 *HZ +999 ) /1000 ); +ssleep (2 ); }else {mdelay (2000 ); }
sound/pci/trident/trident_main.c +1 -2
@@ -3152,8 +3152,7 @@ static int snd_trident_gameport_open(strswitch (mode) {case GAMEPORT_MODE_COOKED :outb (GAMEPORT_MODE_ADC ,TRID_REG (chip,GAMEPORT_GCR )); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (1 +20 *HZ /1000 );/* 20msec */ +msleep (20 );return 0 ;case GAMEPORT_MODE_RAW :outb (0 ,TRID_REG (chip,GAMEPORT_GCR ));
sound/pci/via82xx.c +6 -7
@@ -547,8 +547,7 @@ static void snd_via82xx_codec_wait(ac97_int err; err =snd_via82xx_codec_ready (chip, ac97->num);/* here we need to wait fairly for long time.. */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /2 ); +msleep (500 ); } static void snd_via82xx_codec_write(ac97_t *ac97,
@@ -1847,7 +1846,7 @@ static void __devinit snd_via82xx_proc_istatic int snd_via82xx_chip_init (via82xx_t *chip) {unsigned int val; -int max_count; +unsigned long end_time;unsigned char pval;#if 0 /* broken on K7M? */
@@ -1889,14 +1888,14 @@ static int snd_via82xx_chip_init(via82xx }/* wait until codec ready */ - max_count = ((3 *HZ ) /4 ) +1 ; + end_time = jiffies +msecs_to_jiffies (750 );do {pci_read_config_byte (chip->pci,VIA_ACLINK_STAT , &pval);if (pval &VIA_ACLINK_C00_READY )/* primary codec ready */ break ;set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (1 ); - }while (--max_count >0 ); + }while (time_before (jiffies, end_time));if ((val =snd_via82xx_codec_xread (chip)) &VIA_REG_AC97_BUSY )snd_printk ("AC'97 codec is not ready [0x%x]\n" , val);
@@ -1905,7 +1904,7 @@ static int snd_via82xx_chip_init(via82xxsnd_via82xx_codec_xwrite (chip,VIA_REG_AC97_READ |VIA_REG_AC97_SECONDARY_VALID | (VIA_REG_AC97_CODEC_ID_SECONDARY <<VIA_REG_AC97_CODEC_ID_SHIFT )); - max_count = ((3 *HZ ) /4 ) +1 ; + end_time = jiffies +msecs_to_jiffies (750 );snd_via82xx_codec_xwrite (chip,VIA_REG_AC97_READ |VIA_REG_AC97_SECONDARY_VALID | (VIA_REG_AC97_CODEC_ID_SECONDARY <<VIA_REG_AC97_CODEC_ID_SHIFT ));
@@ -1916,7 +1915,7 @@ static int snd_via82xx_chip_init(via82xx }set_current_state (TASK_INTERRUPTIBLE );schedule_timeout (1 ); - }while (--max_count >0 ); + }while (time_before (jiffies, end_time));/* This is ok, the most of motherboards have only one codec */ __ac97_ok2:
sound/pci/via82xx_modem.c +6 -7
@@ -408,8 +408,7 @@ static void snd_via82xx_codec_wait(ac97_int err; err =snd_via82xx_codec_ready (chip, ac97->num);/* here we need to wait fairly for long time.. */ -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /2 ); +msleep (500 ); } static void snd_via82xx_codec_write(ac97_t *ac97,
@@ -923,7 +922,7 @@ static void __devinit snd_via82xx_proc_istatic int snd_via82xx_chip_init (via82xx_t *chip) {unsigned int val; -int max_count; +unsigned long end_time;unsigned char pval;pci_read_config_byte (chip->pci,VIA_MC97_CTRL , &pval);
@@ -962,14 +961,14 @@ static int snd_via82xx_chip_init(via82xx }/* wait until codec ready */ - max_count = ((3 *HZ ) /4 ) +1 ; + end_time = jiffies +msecs_to_jiffies (750 );do {pci_read_config_byte (chip->pci,VIA_ACLINK_STAT , &pval);if (pval &VIA_ACLINK_C00_READY )/* primary codec ready */ break ;set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (1 ); - }while (--max_count >0 ); + }while (time_before (jiffies, end_time));if ((val =snd_via82xx_codec_xread (chip)) &VIA_REG_AC97_BUSY )snd_printk ("AC'97 codec is not ready [0x%x]\n" , val);
@@ -977,7 +976,7 @@ static int snd_via82xx_chip_init(via82xxsnd_via82xx_codec_xwrite (chip,VIA_REG_AC97_READ |VIA_REG_AC97_SECONDARY_VALID | (VIA_REG_AC97_CODEC_ID_SECONDARY <<VIA_REG_AC97_CODEC_ID_SHIFT )); - max_count = ((3 *HZ ) /4 ) +1 ; + end_time = jiffies +msecs_to_jiffies (750 );snd_via82xx_codec_xwrite (chip,VIA_REG_AC97_READ |VIA_REG_AC97_SECONDARY_VALID | (VIA_REG_AC97_CODEC_ID_SECONDARY <<VIA_REG_AC97_CODEC_ID_SHIFT ));
@@ -988,7 +987,7 @@ static int snd_via82xx_chip_init(via82xx }set_current_state (TASK_INTERRUPTIBLE );schedule_timeout (1 ); - }while (--max_count >0 ); + }while (time_before (jiffies, end_time));/* This is ok, the most of motherboards have only one codec */ __ac97_ok2:
sound/pci/ymfpci/ymfpci_main.c +3 -3
@@ -84,16 +84,16 @@ static inline void snd_ymfpci_writel(ymfstatic int snd_ymfpci_codec_ready (ymfpci_t *chip,int secondary) { -signed long end_time; +unsigned long end_time;u32 reg = secondary ?YDSXGR_SECSTATUSADR :YDSXGR_PRISTATUSADR ; - end_time = (jiffies + ((3 *HZ ) /4 )) +1 ; + end_time = jiffies +msecs_to_jiffies (750 );do {if ((snd_ymfpci_readw (chip, reg) &0x8000 ) =0 )return 0 ;set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (1 ); - }while (end_time - (signed long )jiffies >=0 ); + }while (time_before (jiffies, end_time));snd_printk ("codec_ready: codec %i is not ready [0x%x]\n" , secondary,snd_ymfpci_readw (chip, reg));return -EBUSY ; }
PATCH 2/14 sound/ppc: fix-up sleeping paths
From: Nishanth Aravamudan <[email protected]>
Jaroslav, I realize that you are not the explicit maintainer for any of these drivers, but I figured you would at least be able to {N,}ACK the changes. I didn't find any entry in MAINTAINERS for ppc-specific sound drivers. If you would prefer split patches instead of the large patchset, I can do that.
Description: Fix-up sleeping in sound/ppc. Replace big_mdelay() with msleep() to guarantee the task delays as expected. This also involved replacing/removing custom sleep functions.
---
awacs.c | 6 +++--- pmac.h | 5 ----- tumbler.c | 16 ++++++++-------- 3 files changed, 11 insertions(+), 16 deletions(-)
sound/ppc/awacs.c +3 -3
@@ -103,7 +103,7 @@ static void screamer_recalibrate(pmac_tsnd_pmac_awacs_write_noreg (chip,1 , chip->awacs_reg[1 ]);if (chip->manufacturer =0x1 )/* delay for broken crystal part */ -big_mdelay (750 ); +msleep (750 );snd_pmac_awacs_write_noreg (chip,1 , chip->awacs_reg[1 ] |MASK_RECALIBRATE |MASK_CMUTE |MASK_AMUTE );snd_pmac_awacs_write_noreg (chip,1 , chip->awacs_reg[1 ]);
@@ -653,10 +653,10 @@ static void snd_pmac_awacs_resume(pmac_t {if (machine_is_compatible ("PowerBook3,1" ) ||machine_is_compatible ("PowerBook3,2" )) { -big_mdelay (100 ); +msleep (100 );snd_pmac_awacs_write_reg (chip,1 , chip->awacs_reg[1 ] & ~MASK_PAROUT ); -big_mdelay (300 ); +msleep (300 ); }awacs_restore_all_regs (chip);
sound/ppc/pmac.h +0 -5
@@ -212,9 +212,4 @@ int snd_pmac_boolean_mono_info(snd_kcontint snd_pmac_add_automute (pmac_t *chip); -#define big_mdelay (msec) do {\ - set_current_state(TASK_UNINTERRUPTIBLE);\ - schedule_timeout(((msec) * HZ + 999) / 1000);\ -} while (0) -#endif /* __PMAC_H */
sound/ppc/tumbler.c +8 -8
@@ -945,7 +945,7 @@ static void device_change_handler(void *check_mute (chip, &mix->line_mute,0 , mix->auto_mute_notify, chip->lineout_sw_ctl);if (mix->anded_reset) -big_mdelay (10 ); +msleep (10 );check_mute (chip, &mix->amp_mute,1 , mix->auto_mute_notify, chip->speaker_sw_ctl); mix->drc_enable =0 ;
@@ -954,7 +954,7 @@ static void device_change_handler(void *check_mute (chip, &mix->amp_mute,0 , mix->auto_mute_notify, chip->speaker_sw_ctl);if (mix->anded_reset) -big_mdelay (10 ); +msleep (10 );check_mute (chip, &mix->hp_mute,1 , mix->auto_mute_notify, chip->master_sw_ctl);if (mix->line_mute.addr !=0 )
@@ -1109,22 +1109,22 @@ static void tumbler_reset_audio(pmac_t *DBG ("(I) codec anded reset !\n" );write_audio_gpio (&mix->hp_mute,0 );write_audio_gpio (&mix->amp_mute,0 ); -big_mdelay (200 ); +msleep (200 );write_audio_gpio (&mix->hp_mute,1 );write_audio_gpio (&mix->amp_mute,1 ); -big_mdelay (100 ); +msleep (100 );write_audio_gpio (&mix->hp_mute,0 );write_audio_gpio (&mix->amp_mute,0 ); -big_mdelay (100 ); +msleep (100 ); }else {DBG ("(I) codec normal reset !\n" );write_audio_gpio (&mix->audio_reset,0 ); -big_mdelay (200 ); +msleep (200 );write_audio_gpio (&mix->audio_reset,1 ); -big_mdelay (100 ); +msleep (100 );write_audio_gpio (&mix->audio_reset,0 ); -big_mdelay (100 ); +msleep (100 ); } }
Re: [PATCH 2/14] sound/ppc: fix-up sleeping paths
Quoted 1 line · Nishanth Aravamudan
From: Nishanth Aravamudan <[email protected]>
<snip>
Quoted 3 lines
Description: Fix-up sleeping in
sound/ppc. Replacebig_mdelay()withmsleep()to guarantee the task delays as expected. This also involved replacing/removing custom sleep functions.
Forgot to CC: Kernel-Janitors.
Thanks,
Nish
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
PATCH 3/14 sound/usb: fix-up sleeping paths
In reply to Nishanth AravamudanFrom: Nishanth Aravamudan <[email protected]>
Jaroslav, I realize that you are not the explicit maintainer for any of these drivers, but I figured you would at least be able to {N,}ACK the changes. I didn't find any entry in MAINTAINERS for usb-specific sound drivers. If you would prefer split patches instead of the large patchset, I can do that.
Description: Fix-up sleeping in sound/usb. Replace big_mdelay() with msleep() to guarantee the task delays as expected. This also involved replacing/removing custom sleep functions.
Patch is compile-tested.
---
usbaudio.c | 4 ++-- usx2y/usX2Yhwdep.c | 3 +-- usx2y/usx2yhwdeppcm.c | 6 ++---- 3 files changed, 5 insertions(+), 8 deletions(-)
sound/usb/usbaudio.c +2 -2
@@ -790,7 +790,7 @@ static int start_urbs(snd_usb_substream_*/ static int wait_clear_urbs (snd_usb_substream_t *subs) { -int timeout =HZ ; +unsigned long end_time = jiffies +msecs_to_jiffies (1000 );unsigned int i;int alive;
@@ -810,7 +810,7 @@ static int wait_clear_urbs(snd_usb_substbreak ;set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (1 ); - }while (--timeout >0 ); + }while (time_before (jiffies, end_time));if (alive)snd_printk (KERN_ERR "timeout: still %d active urbs..\n" , alive);return 0 ;
sound/usb/usx2y/usX2Yhwdep.c +1 -2
@@ -232,8 +232,7 @@ static int snd_usX2Y_hwdep_dsp_load(snd_if (err)return err;if (dsp->index =1 ) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /4 );// give the device some time +msleep (250 );// give the device some time err =usX2Y_AsyncSeq04_init (priv);if (err) {snd_printk ("usX2Y_AsyncSeq04_init error \n" );
sound/usb/usx2y/usx2yhwdeppcm.c +2 -4
@@ -50,6 +50,7 @@Currently rawusb dma pcm buffer transport (this file) is only available to snd-usb-usx2y. */ +#include <linux/delay.h> #include "usbusx2yaudio.c" #if defined(USX2Y_NRPACKS_VARIABLE) || (!defined(USX2Y_NRPACKS_VARIABLE) && USX2Y_NRPACKS = 1)
@@ -520,11 +521,8 @@ static int snd_usX2Y_usbpcm_prepare(snd_ usX2Y->hwdep_pcm_shm->playback_iso_start =-1 ;if (atomic_read (&subs->state) < state_PREPARED) {while (usX2Y_iso_frames_per_buffer (runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) { -signed long timeout;snd_printd ("Wait: iso_frames_per_buffer=%i,captured_iso_frames=%i\n" ,usX2Y_iso_frames_per_buffer (runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames); -set_current_state (TASK_INTERRUPTIBLE ); - timeout =schedule_timeout (HZ /100 +1 ); -if (signal_pending (current)) { +if (msleep_interruptible (10 )) { err = -ERESTARTSYS ; goto up_prepare_mutex; }
Re: [PATCH 3/14] sound/usb: fix-up sleeping paths
Quoted 1 line · Nishanth Aravamudan
From: Nishanth Aravamudan <[email protected]>
<snip>
Quoted 3 lines
Description: Fix-up sleeping in
sound/usb. Replacebig_mdelay()withmsleep()to guarantee the task delays as expected. This also involved replacing/removing custom sleep functions.
Sorry, forgot to CC: Kernel-Janitors.
Thanks,
Nish
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
Quoted 1 line · Nishanth Aravamudan
From: Nishanth Aravamudan <[email protected]>
<snip>
Quoted 2 lines
Description: Fix-up sleeping in
sound/pci. These changes fall under the following two categories:
Very sorry, forgot to CC: kernel-janitors.
Thanks,
Nish
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
PATCH 7/14 mips: replace timespectojiffies() with
In reply to Nishanth AravamudanFrom: Nishanth Aravamudan <[email protected]>
Description: Replace custom timespectojiffies() function with generic standard one.
---
irixsig.c | 14 +------------- 1 files changed, 1 insertion(+), 13 deletions(-)
arch/mips/kernel/irixsig.c +1 -13
@@ -441,18 +441,6 @@ struct irix5_siginfo { } stuff; }; -static inline unsigned long timespectojiffies (struct timespec *value) -{ -unsigned long sec = (unsigned ) value->tv_sec; -long nsec = value->tv_nsec; - -if (sec > (LONG_MAX /HZ )) -return LONG_MAX ; - nsec +=1000000000L /HZ -1 ; - nsec /=1000000000L /HZ ; -return HZ * sec + nsec; -} - asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info,struct timespec *tp) {
@@ -490,7 +478,7 @@ asmlinkage int irix_sigpoll_sys(unsigned error = -EINVAL ; goto out; } - expire =timespectojiffies (tp)+(tp->tv_sec||tp->tv_nsec); + expire =timespec_to_jiffies (tp)+(tp->tv_sec||tp->tv_nsec); }while (1 ) {
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Ralf Baechle
Applied[KJ] Re: [PATCH 7/14] mips: replace timespectojiffies() with
Quoted 2 lines · Nishanth Aravamudan
Description: Replace custom
timespectojiffies()function with generic standard one.
Applied. Thanks,
Ralf
PATCH 11/14 scsi/lpfc_scsi: use msleep() instead of
In reply to Nishanth AravamudanFrom: Nishanth Aravamudan <[email protected]>
Description: Replace schedule_timeout() with msleep() to guarantee the task delays as expected.
Patch is compile-tested.
---
lpfc_scsi.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +5 -8
@@ -24,6 +24,7 @@#include <linux/pci.h> #include <linux/interrupt.h> +#include <linux/delay.h> #include <scsi/scsi.h> #include <scsi/scsi_device.h>
@@ -885,8 +886,7 @@ __lpfc_abort_handler(struct scsi_cmnd *cwhile (cmnd->host_scribble) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (LPFC_ABORT_WAIT *HZ ); +msleep (LPFC_ABORT_WAIT *1000 );spin_lock_irq (phba->host->host_lock);if (++loop_count > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT )
@@ -952,8 +952,7 @@ __lpfc_reset_lun_handler(struct scsi_cmnif (pnode->nlp_state !=NLP_STE_MAPPED_NODE ) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /2 ); +msleep (500 );spin_lock_irq (phba->host->host_lock); }if ((pnode) && (pnode->nlp_state ==NLP_STE_MAPPED_NODE ))
@@ -1011,8 +1010,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn cmnd->device->id, cmnd->device->lun, LPFC_CTX_LUN))) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (LPFC_RESET_WAIT *HZ ); +msleep (LPFC_RESET_WAIT *1000 );spin_lock_irq (phba->host->host_lock); if (++loopcnt
@@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn &phba->sli.ring[phba->sli.fcp_ring], 0, 0, LPFC_CTX_HOST))) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (LPFC_RESET_WAIT *HZ ); +msleep (LPFC_RESET_WAIT *HZ );spin_lock_irq (phba->host->host_lock); if (++loopcnt
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of
Quoted 17 lines · Nishanth Aravamudan
From: Nishanth Aravamudan <[email protected]>
Description: Replace
schedule_timeout()withmsleep()to guarantee the task delays as expected.Patch is compile-tested.
Signed-off-by Nishanth Aravamudan <[email protected]>---
lpfc_scsi.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)diff -urp
2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.cdrivers/scsi/lpfc/lpfc_scsi.c +0
-0
...
drivers/scsi/lpfc/lpfc_scsi.c __lpfc_reset_bus_handler(struct scsi_cmn · line 1111
Quoted 7 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-2@@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn &phba->sli.ring[phba->sli.fcp_ring], 0, 0, LPFC_CTX_HOST))) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (LPFC_RESET_WAIT *HZ ); +msleep (LPFC_RESET_WAIT *HZ );
^^ ??
I assume you meant 1000.
Quoted 8 lines
drivers/scsi/lpfc/lpfc_scsi.c +0
-0spin_lock_irq (phba->host->host_lock); if (++loopcnt_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of
Quoted 28 lines · Domen Puncer
Quoted 17 lines · Nishanth Aravamudan
From: Nishanth Aravamudan <[email protected]>
Description: Replace
schedule_timeout()withmsleep()to guarantee the task delays as expected.Patch is compile-tested.
Signed-off-by Nishanth Aravamudan <[email protected]>---
lpfc_scsi.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)diff -urp
2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.cdrivers/scsi/lpfc/lpfc_scsi.c +0
-0...
drivers/scsi/lpfc/lpfc_scsi.c __lpfc_reset_bus_handler(struct scsi_cmn · line 1111
Quoted 7 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-2@@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn &phba->sli.ring[phba->sli.fcp_ring], 0, 0, LPFC_CTX_HOST))) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (LPFC_RESET_WAIT *HZ ); +msleep (LPFC_RESET_WAIT *HZ );^^ ??
Quoted 1 line
I assume you meant 1000.
Gah! You are right. Fixed below. Thanks, Domen!
-Nish
Description: Replace schedule_timeout() with msleep() to guarantee the task delays as expected.
Patch is compile-tested.
---
lpfc_scsi.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +5 -8
@@ -24,6 +24,7 @@#include <linux/pci.h> #include <linux/interrupt.h> +#include <linux/delay.h> #include <scsi/scsi.h> #include <scsi/scsi_device.h>
@@ -885,8 +886,7 @@ __lpfc_abort_handler(struct scsi_cmnd *cwhile (cmnd->host_scribble) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (LPFC_ABORT_WAIT *HZ ); +msleep (LPFC_ABORT_WAIT *1000 );spin_lock_irq (phba->host->host_lock);if (++loop_count > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT )
@@ -952,8 +952,7 @@ __lpfc_reset_lun_handler(struct scsi_cmnif (pnode->nlp_state !=NLP_STE_MAPPED_NODE ) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (HZ /2 ); +msleep (500 );spin_lock_irq (phba->host->host_lock); }if ((pnode) && (pnode->nlp_state ==NLP_STE_MAPPED_NODE ))
@@ -1011,8 +1010,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn cmnd->device->id, cmnd->device->lun, LPFC_CTX_LUN))) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (LPFC_RESET_WAIT *HZ ); +msleep (LPFC_RESET_WAIT *1000 );spin_lock_irq (phba->host->host_lock); if (++loopcnt
@@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn &phba->sli.ring[phba->sli.fcp_ring], 0, 0, LPFC_CTX_HOST))) {spin_unlock_irq (phba->host->host_lock); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (LPFC_RESET_WAIT *HZ ); +msleep (LPFC_RESET_WAIT *1000 );spin_lock_irq (phba->host->host_lock); if (++loopcnt
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 12/14 scsi/osst: use msleep() instead of
In reply to Nishanth AravamudanFrom: Nishanth Aravamudan <[email protected]>
Description: Replace schedule_timeout() with msleep() to guarantee the task delays as expected.
Patch is compile-tested.
---
osst.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/scsi/osst.c +3 -6
@@ -862,8 +862,7 @@ static int osst_recover_wait_frame(struc retval =osst_write_error_recovery (STp, aSRpnt,0 );break ; } -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ /OSST_POLL_PER_SEC ); +msleep (1000 /OSST_POLL_PER_SEC ); STp->buffer->b_data = mybuf; STp->buffer->buffer_size =24 ;memset (cmd,0 ,MAX_COMMAND_SIZE );
@@ -1558,8 +1557,7 @@ static int osst_reposition_and_retry(strosst_set_frame_position (STp, aSRpnt, frame + skip,1 ); flag =0 ; attempts--; -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ /10 ); +msleep (100 ); }if (osst_get_frame_position (STp, aSRpnt) <0 ) {/* additional write error */ #if DEBUG
@@ -1620,8 +1618,7 @@ static int osst_reposition_and_retry(str debugging = 0; }#endif -set_current_state (TASK_INTERRUPTIBLE ); -schedule_timeout (HZ /10 ); +msleep (100 ); }printk (KERN_ERR "%s:E: Failed to find valid tape media\n" , name);#if DEBUG
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 13/14 scsi/qla2xxx: use msleep{,
In reply to Nishanth AravamudanFrom: Nishanth Aravamudan <[email protected]>
Description: Replace schedule_timeout() with msleep()/msleep_interruptible() as appropriate, to guarantee the task delays as expected.
Patch is compile-tested.
---
qla_os.c | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +11 -14
@@ -347,14 +347,13 @@ qc_fail_command:static int qla2x00_eh_wait_on_command (scsi_qla_host_t *ha,struct scsi_cmnd *cmd) { -#define ABORT_POLLING_PERIOD HZ -#define ABORT_WAIT_ITER ((10 * HZ) / (ABORT_POLLING_PERIOD)) +#define ABORT_POLLING_PERIOD 1000 +#define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD))unsigned long wait_iter =ABORT_WAIT_ITER ;int ret =QLA_SUCCESS ;while (CMD_SP (cmd)) { -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (ABORT_POLLING_PERIOD ); +msleep (ABORT_POLLING_PERIOD );if (--wait_iter)break ;
@@ -1693,7 +1692,7 @@ qla2x00_mem_free(scsi_qla_host_t *ha) {struct list_head *fcpl, *fcptemp;fc_port_t *fcport; -unsigned long wtime;/* max wait time if mbx cmd is busy. */ +unsigned int wtime;/* max wait time if mbx cmd is busy. */ if (ha ==NULL ) {/* error */
@@ -1702,11 +1701,9 @@ qla2x00_mem_free(scsi_qla_host_t *ha) }/* Make sure all other threads are stopped. */ - wtime =60 *HZ ; -while (ha->dpc_wait && wtime) { -set_current_state (TASK_INTERRUPTIBLE ); - wtime =schedule_timeout (wtime); - } + wtime =60 *1000 ; +while (ha->dpc_wait && wtime) + wtime =msleep_interruptible (wtime);/* free ioctl memory */ qla2x00_free_ioctl_mem (ha);
@@ -2250,15 +2247,15 @@ qla2x00_timer(scsi_qla_host_t *ha)int qla2x00_down_timeout (struct semaphore *sema,unsigned long timeout) { -const unsigned int step =HZ /10 ; +const unsigned int step =100 ;/* msecs */ +unsigned int iterations =jiffies_to_msecs (timeout)/100 ;do {if (!down_trylock (sema))return 0 ; -set_current_state (TASK_INTERRUPTIBLE ); -if (schedule_timeout (step)) +if (msleep_interruptible (step))break ; - }while ((timeout -= step) >0 ); + }while (--iterations >=0 );return -ETIMEDOUT ; }
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors