|
Lines 792-812
static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr,
Link Here
|
| 792 |
struct hda_bus *hbus = &chip->bus; |
792 |
struct hda_bus *hbus = &chip->bus; |
| 793 |
unsigned long timeout; |
793 |
unsigned long timeout; |
| 794 |
unsigned long loopcounter; |
794 |
unsigned long loopcounter; |
| 795 |
int do_poll = 0; |
795 |
wait_queue_entry_t wait; |
| 796 |
bool warned = false; |
796 |
bool warned = false; |
| 797 |
|
797 |
|
|
|
798 |
init_wait_entry(&wait, 0); |
| 798 |
again: |
799 |
again: |
| 799 |
timeout = jiffies + msecs_to_jiffies(1000); |
800 |
timeout = jiffies + msecs_to_jiffies(1000); |
| 800 |
|
801 |
|
| 801 |
for (loopcounter = 0;; loopcounter++) { |
802 |
for (loopcounter = 0;; loopcounter++) { |
| 802 |
spin_lock_irq(&bus->reg_lock); |
803 |
spin_lock_irq(&bus->reg_lock); |
| 803 |
if (bus->polling_mode || do_poll) |
804 |
if (!bus->polling_mode) |
|
|
805 |
prepare_to_wait(&bus->rirb_wq, &wait, |
| 806 |
TASK_UNINTERRUPTIBLE); |
| 807 |
if (bus->polling_mode) |
| 804 |
snd_hdac_bus_update_rirb(bus); |
808 |
snd_hdac_bus_update_rirb(bus); |
| 805 |
if (!bus->rirb.cmds[addr]) { |
809 |
if (!bus->rirb.cmds[addr]) { |
| 806 |
if (!do_poll) |
|
|
| 807 |
bus->poll_count = 0; |
| 808 |
if (res) |
810 |
if (res) |
| 809 |
*res = bus->rirb.res[addr]; /* the last value */ |
811 |
*res = bus->rirb.res[addr]; /* the last value */ |
|
|
812 |
if (!bus->polling_mode) |
| 813 |
finish_wait(&bus->rirb_wq, &wait); |
| 810 |
spin_unlock_irq(&bus->reg_lock); |
814 |
spin_unlock_irq(&bus->reg_lock); |
| 811 |
return 0; |
815 |
return 0; |
| 812 |
} |
816 |
} |
|
Lines 814-820
static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr,
Link Here
|
| 814 |
if (time_after(jiffies, timeout)) |
818 |
if (time_after(jiffies, timeout)) |
| 815 |
break; |
819 |
break; |
| 816 |
#define LOOP_COUNT_MAX 3000 |
820 |
#define LOOP_COUNT_MAX 3000 |
| 817 |
if (hbus->needs_damn_long_delay || |
821 |
if (!bus->polling_mode) { |
|
|
822 |
schedule_timeout(msecs_to_jiffies(2)); |
| 823 |
} else if (hbus->needs_damn_long_delay || |
| 818 |
loopcounter > LOOP_COUNT_MAX) { |
824 |
loopcounter > LOOP_COUNT_MAX) { |
| 819 |
if (loopcounter > LOOP_COUNT_MAX && !warned) { |
825 |
if (loopcounter > LOOP_COUNT_MAX && !warned) { |
| 820 |
dev_dbg_ratelimited(chip->card->dev, |
826 |
dev_dbg_ratelimited(chip->card->dev, |
|
Lines 829-847
static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr,
Link Here
|
| 829 |
} |
835 |
} |
| 830 |
} |
836 |
} |
| 831 |
|
837 |
|
|
|
838 |
if (!bus->polling_mode) |
| 839 |
finish_wait(&bus->rirb_wq, &wait); |
| 840 |
|
| 832 |
if (hbus->no_response_fallback) |
841 |
if (hbus->no_response_fallback) |
| 833 |
return -EIO; |
842 |
return -EIO; |
| 834 |
|
843 |
|
| 835 |
if (!bus->polling_mode && bus->poll_count < 2) { |
|
|
| 836 |
dev_dbg(chip->card->dev, |
| 837 |
"azx_get_response timeout, polling the codec once: last cmd=0x%08x\n", |
| 838 |
bus->last_cmd[addr]); |
| 839 |
do_poll = 1; |
| 840 |
bus->poll_count++; |
| 841 |
goto again; |
| 842 |
} |
| 843 |
|
| 844 |
|
| 845 |
if (!bus->polling_mode) { |
844 |
if (!bus->polling_mode) { |
| 846 |
dev_warn(chip->card->dev, |
845 |
dev_warn(chip->card->dev, |
| 847 |
"azx_get_response timeout, switching to polling mode: last cmd=0x%08x\n", |
846 |
"azx_get_response timeout, switching to polling mode: last cmd=0x%08x\n", |