]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sunvdc: Do not spin in an infinite loop when vio_ldc_send() returns EAGAIN
authorYoung Xiao <YangX92@hotmail.com>
Wed, 28 Nov 2018 12:36:39 +0000 (12:36 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 18:46:00 +0000 (19:46 +0100)
[ Upstream commit a11f6ca9aef989b56cd31ff4ee2af4fb31a172ec ]

__vdc_tx_trigger should only loop on EAGAIN a finite
number of times.

See commit adddc32d6fde ("sunvnet: Do not spin in an
infinite loop when vio_ldc_send() returns EAGAIN") for detail.

Signed-off-by: Young Xiao <YangX92@hotmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/sunvdc.c

index ad9749463d4fa9a382afa7f24587bbbe3a2efcc9..ed4d6276e94f389af7c485b5ea195f9cae766609 100644 (file)
@@ -41,6 +41,8 @@ MODULE_VERSION(DRV_MODULE_VERSION);
 #define WAITING_FOR_GEN_CMD    0x04
 #define WAITING_FOR_ANY                -1
 
+#define        VDC_MAX_RETRIES 10
+
 static struct workqueue_struct *sunvdc_wq;
 
 struct vdc_req_entry {
@@ -427,6 +429,7 @@ static int __vdc_tx_trigger(struct vdc_port *port)
                .end_idx                = dr->prod,
        };
        int err, delay;
+       int retries = 0;
 
        hdr.seq = dr->snd_nxt;
        delay = 1;
@@ -439,6 +442,8 @@ static int __vdc_tx_trigger(struct vdc_port *port)
                udelay(delay);
                if ((delay <<= 1) > 128)
                        delay = 128;
+               if (retries++ > VDC_MAX_RETRIES)
+                       break;
        } while (err == -EAGAIN);
 
        if (err == -ENOTCONN)