misc: mic: Minor bug fix in 'retry' loops.
The bug would result in incorrect 'retry' value being printed in debug statements as well as dead code in mic_find_vqs(...) in drivers/misc/mic/card/mic_virtio.c. Reported-by: Michael Opdenacker <michael.opdenacker@free-electrons.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
bd6dc8f654
Коммит
9420b3485a
|
@ -154,14 +154,14 @@ static void mic_reset_inform_host(struct virtio_device *vdev)
|
||||||
{
|
{
|
||||||
struct mic_vdev *mvdev = to_micvdev(vdev);
|
struct mic_vdev *mvdev = to_micvdev(vdev);
|
||||||
struct mic_device_ctrl __iomem *dc = mvdev->dc;
|
struct mic_device_ctrl __iomem *dc = mvdev->dc;
|
||||||
int retry = 100, i;
|
int retry;
|
||||||
|
|
||||||
iowrite8(0, &dc->host_ack);
|
iowrite8(0, &dc->host_ack);
|
||||||
iowrite8(1, &dc->vdev_reset);
|
iowrite8(1, &dc->vdev_reset);
|
||||||
mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
|
mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
|
||||||
|
|
||||||
/* Wait till host completes all card accesses and acks the reset */
|
/* Wait till host completes all card accesses and acks the reset */
|
||||||
for (i = retry; i--;) {
|
for (retry = 100; retry--;) {
|
||||||
if (ioread8(&dc->host_ack))
|
if (ioread8(&dc->host_ack))
|
||||||
break;
|
break;
|
||||||
msleep(100);
|
msleep(100);
|
||||||
|
@ -310,7 +310,7 @@ static int mic_find_vqs(struct virtio_device *vdev, unsigned nvqs,
|
||||||
{
|
{
|
||||||
struct mic_vdev *mvdev = to_micvdev(vdev);
|
struct mic_vdev *mvdev = to_micvdev(vdev);
|
||||||
struct mic_device_ctrl __iomem *dc = mvdev->dc;
|
struct mic_device_ctrl __iomem *dc = mvdev->dc;
|
||||||
int i, err, retry = 100;
|
int i, err, retry;
|
||||||
|
|
||||||
/* We must have this many virtqueues. */
|
/* We must have this many virtqueues. */
|
||||||
if (nvqs > ioread8(&mvdev->desc->num_vq))
|
if (nvqs > ioread8(&mvdev->desc->num_vq))
|
||||||
|
@ -332,7 +332,7 @@ static int mic_find_vqs(struct virtio_device *vdev, unsigned nvqs,
|
||||||
* rings have been re-assigned.
|
* rings have been re-assigned.
|
||||||
*/
|
*/
|
||||||
mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
|
mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
|
||||||
for (i = retry; i--;) {
|
for (retry = 100; retry--;) {
|
||||||
if (!ioread8(&dc->used_address_updated))
|
if (!ioread8(&dc->used_address_updated))
|
||||||
break;
|
break;
|
||||||
msleep(100);
|
msleep(100);
|
||||||
|
|
|
@ -378,7 +378,7 @@ int mic_virtio_config_change(struct mic_vdev *mvdev,
|
||||||
void __user *argp)
|
void __user *argp)
|
||||||
{
|
{
|
||||||
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake);
|
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake);
|
||||||
int ret = 0, retry = 100, i;
|
int ret = 0, retry, i;
|
||||||
struct mic_bootparam *bootparam = mvdev->mdev->dp;
|
struct mic_bootparam *bootparam = mvdev->mdev->dp;
|
||||||
s8 db = bootparam->h2c_config_db;
|
s8 db = bootparam->h2c_config_db;
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ int mic_virtio_config_change(struct mic_vdev *mvdev,
|
||||||
mvdev->dc->config_change = MIC_VIRTIO_PARAM_CONFIG_CHANGED;
|
mvdev->dc->config_change = MIC_VIRTIO_PARAM_CONFIG_CHANGED;
|
||||||
mvdev->mdev->ops->send_intr(mvdev->mdev, db);
|
mvdev->mdev->ops->send_intr(mvdev->mdev, db);
|
||||||
|
|
||||||
for (i = retry; i--;) {
|
for (retry = 100; retry--;) {
|
||||||
ret = wait_event_timeout(wake,
|
ret = wait_event_timeout(wake,
|
||||||
mvdev->dc->guest_ack, msecs_to_jiffies(100));
|
mvdev->dc->guest_ack, msecs_to_jiffies(100));
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -639,7 +639,7 @@ void mic_virtio_del_device(struct mic_vdev *mvdev)
|
||||||
struct mic_vdev *tmp_mvdev;
|
struct mic_vdev *tmp_mvdev;
|
||||||
struct mic_device *mdev = mvdev->mdev;
|
struct mic_device *mdev = mvdev->mdev;
|
||||||
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake);
|
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake);
|
||||||
int i, ret, retry = 100;
|
int i, ret, retry;
|
||||||
struct mic_vqconfig *vqconfig;
|
struct mic_vqconfig *vqconfig;
|
||||||
struct mic_bootparam *bootparam = mdev->dp;
|
struct mic_bootparam *bootparam = mdev->dp;
|
||||||
s8 db;
|
s8 db;
|
||||||
|
@ -652,16 +652,16 @@ void mic_virtio_del_device(struct mic_vdev *mvdev)
|
||||||
"Requesting hot remove id %d\n", mvdev->virtio_id);
|
"Requesting hot remove id %d\n", mvdev->virtio_id);
|
||||||
mvdev->dc->config_change = MIC_VIRTIO_PARAM_DEV_REMOVE;
|
mvdev->dc->config_change = MIC_VIRTIO_PARAM_DEV_REMOVE;
|
||||||
mdev->ops->send_intr(mdev, db);
|
mdev->ops->send_intr(mdev, db);
|
||||||
for (i = retry; i--;) {
|
for (retry = 100; retry--;) {
|
||||||
ret = wait_event_timeout(wake,
|
ret = wait_event_timeout(wake,
|
||||||
mvdev->dc->guest_ack, msecs_to_jiffies(100));
|
mvdev->dc->guest_ack, msecs_to_jiffies(100));
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dev_dbg(mdev->sdev->parent,
|
dev_dbg(mdev->sdev->parent,
|
||||||
"Device id %d config_change %d guest_ack %d\n",
|
"Device id %d config_change %d guest_ack %d retry %d\n",
|
||||||
mvdev->virtio_id, mvdev->dc->config_change,
|
mvdev->virtio_id, mvdev->dc->config_change,
|
||||||
mvdev->dc->guest_ack);
|
mvdev->dc->guest_ack, retry);
|
||||||
mvdev->dc->config_change = 0;
|
mvdev->dc->config_change = 0;
|
||||||
mvdev->dc->guest_ack = 0;
|
mvdev->dc->guest_ack = 0;
|
||||||
skip_hot_remove:
|
skip_hot_remove:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче