|
Lines 777-785
static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr,
Link Here
|
| 777 |
{ |
777 |
{ |
| 778 |
struct azx *chip = bus_to_azx(bus); |
778 |
struct azx *chip = bus_to_azx(bus); |
| 779 |
struct hda_bus *hbus = &chip->bus; |
779 |
struct hda_bus *hbus = &chip->bus; |
|
|
780 |
unsigned long timeout; |
| 781 |
unsigned long loopcounter; |
| 782 |
int do_poll = 0; |
| 783 |
bool warned = false; |
| 780 |
int err; |
784 |
int err; |
| 781 |
|
785 |
|
| 782 |
again: |
786 |
again: |
|
|
787 |
timeout = jiffies + msecs_to_jiffies(1000); |
| 788 |
|
| 789 |
for (loopcounter = 0;; loopcounter++) { |
| 790 |
spin_lock_irq(&bus->reg_lock); |
| 791 |
if (bus->polling_mode || do_poll) |
| 792 |
snd_hdac_bus_update_rirb(bus); |
| 793 |
if (!bus->rirb.cmds[addr]) { |
| 794 |
if (!do_poll) |
| 795 |
bus->poll_count = 0; |
| 796 |
if (res) |
| 797 |
*res = bus->rirb.res[addr]; /* the last value */ |
| 798 |
spin_unlock_irq(&bus->reg_lock); |
| 799 |
return 0; |
| 800 |
} |
| 801 |
spin_unlock_irq(&bus->reg_lock); |
| 802 |
if (time_after(jiffies, timeout)) |
| 803 |
break; |
| 804 |
#define LOOP_COUNT_MAX 3000 |
| 805 |
if (hbus->core.needs_damn_long_delay || |
| 806 |
loopcounter > LOOP_COUNT_MAX) { |
| 807 |
if (loopcounter > LOOP_COUNT_MAX && !warned) { |
| 808 |
dev_dbg_ratelimited(chip->card->dev, |
| 809 |
"too slow response, last cmd=%#08x\n", |
| 810 |
bus->last_cmd[addr]); |
| 811 |
warned = true; |
| 812 |
} |
| 813 |
msleep(2); /* temporary workaround */ |
| 814 |
} else { |
| 815 |
udelay(10); |
| 816 |
cond_resched(); |
| 817 |
} |
| 818 |
} |
| 819 |
|
| 783 |
err = snd_hdac_bus_get_response(bus, addr, res); |
820 |
err = snd_hdac_bus_get_response(bus, addr, res); |
| 784 |
if (!err) |
821 |
if (!err) |
| 785 |
return 0; |
822 |
return 0; |
|
Lines 787-792
static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr,
Link Here
|
| 787 |
if (hbus->no_response_fallback) |
824 |
if (hbus->no_response_fallback) |
| 788 |
return -EIO; |
825 |
return -EIO; |
| 789 |
|
826 |
|
|
|
827 |
if (!bus->polling_mode && bus->poll_count < 2) { |
| 828 |
dev_dbg(chip->card->dev, |
| 829 |
"azx_get_response timeout, polling the codec once: last cmd=0x%08x\n", |
| 830 |
bus->last_cmd[addr]); |
| 831 |
do_poll = 1; |
| 832 |
bus->poll_count++; |
| 833 |
goto again; |
| 834 |
} |
| 835 |
|
| 836 |
|
| 790 |
if (!bus->polling_mode) { |
837 |
if (!bus->polling_mode) { |
| 791 |
dev_warn(chip->card->dev, |
838 |
dev_warn(chip->card->dev, |
| 792 |
"azx_get_response timeout, switching to polling mode: last cmd=0x%08x\n", |
839 |
"azx_get_response timeout, switching to polling mode: last cmd=0x%08x\n", |