dm: pcidev: clean up assert() for some pci devices

Tracked-On: #3252
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Shuo A Liu 2019-06-18 13:59:56 +08:00 committed by wenlingz
parent 2b3dedfb9b
commit 1b7995387d
5 changed files with 45 additions and 20 deletions

View File

@ -103,7 +103,10 @@ lpc_uart_intr_assert(void *arg)
{ {
struct lpc_uart_vdev *lpc_uart = arg; struct lpc_uart_vdev *lpc_uart = arg;
assert(lpc_uart->irq >= 0); if (lpc_uart->irq < 0) {
pr_warn("%s: Invalid irq pin lpc_uart\n", __func__);
return;
}
if (lpc_bridge) if (lpc_bridge)
vm_set_gsi_irq(lpc_bridge->vmctx, vm_set_gsi_irq(lpc_bridge->vmctx,
@ -221,7 +224,8 @@ lpc_init(struct vmctx *ctx)
iop.arg = lpc_uart; iop.arg = lpc_uart;
error = register_inout(&iop); error = register_inout(&iop);
assert(error == 0); if (error)
goto init_failed;
lpc_uart->enabled = 1; lpc_uart->enabled = 1;
} }

View File

@ -60,7 +60,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h>
#include <pthread.h> #include <pthread.h>
#include <sysexits.h> #include <sysexits.h>
#include <dlfcn.h> #include <dlfcn.h>
@ -181,7 +180,15 @@ virtio_coreu_thread(void *param)
do { do {
ret = vq_getchain(rvq, &idx, &iov, 1, NULL); ret = vq_getchain(rvq, &idx, &iov, 1, NULL);
assert(ret > 0); if (ret < 1) {
pr_err("%s: fail to getchain!\n", __func__);
return NULL;
}
if (ret != 1) {
pr_warn("%s: invalid chain!\n", __func__);
vq_relchain(rvq, idx, 0);
continue;
}
msg = (struct coreu_msg *)(iov.iov_base); msg = (struct coreu_msg *)(iov.iov_base);

View File

@ -55,7 +55,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h>
#include <pthread.h> #include <pthread.h>
#include <sysexits.h> #include <sysexits.h>
#include <dlfcn.h> #include <dlfcn.h>
@ -312,17 +311,23 @@ virtio_hdcp_talk_to_daemon(void *param)
* - avoid vring processing due to spurious wakeups * - avoid vring processing due to spurious wakeups
* - catch missing notifications before acquiring rx_mtx * - catch missing notifications before acquiring rx_mtx
*/ */
while (!vq_has_descs(rvq)) { while (!vq_has_descs(rvq))
ret = pthread_cond_wait(&vhdcp->rx_cond, &vhdcp->rx_mtx); pthread_cond_wait(&vhdcp->rx_cond, &vhdcp->rx_mtx);
assert(ret == 0);
}
vhdcp->in_progress = 1; vhdcp->in_progress = 1;
pthread_mutex_unlock(&vhdcp->rx_mtx); pthread_mutex_unlock(&vhdcp->rx_mtx);
do { do {
ret = vq_getchain(rvq, &idx, &iov, 1, NULL); ret = vq_getchain(rvq, &idx, &iov, 1, NULL);
assert(ret > 0); if (ret < 1) {
pr_err("%s: fail to getchain!\n", __func__);
return NULL;
}
if (ret > 1) {
pr_warn("%s: invalid chain!\n", __func__);
vq_relchain(rvq, idx, 0);
continue;
}
msg = (struct SocketData*)(iov.iov_base); msg = (struct SocketData*)(iov.iov_base);

View File

@ -15,7 +15,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h>
#include <pthread.h> #include <pthread.h>
#include "dm.h" #include "dm.h"
@ -374,7 +373,7 @@ virtio_ipu_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
virtio_ipu_k_stop(ipu); virtio_ipu_k_stop(ipu);
virtio_ipu_k_reset(ipu); virtio_ipu_k_reset(ipu);
ipu->vbs_k.ipu_kstatus = VIRTIO_DEV_INITIAL; ipu->vbs_k.ipu_kstatus = VIRTIO_DEV_INITIAL;
assert(ipu->vbs_k.ipu_fd >= 0); if (ipu->vbs_k.ipu_fd >= 0)
close(ipu->vbs_k.ipu_fd); close(ipu->vbs_k.ipu_fd);
ipu->vbs_k.ipu_fd = -1; ipu->vbs_k.ipu_fd = -1;
} }

View File

@ -1490,7 +1490,15 @@ vmei_proc_tx(struct virtio_mei *vmei, struct virtio_vq_info *vq)
* The first one is hdr, the second is for payload. * The first one is hdr, the second is for payload.
*/ */
n = vq_getchain(vq, &idx, iov, VMEI_TX_SEGS, NULL); n = vq_getchain(vq, &idx, iov, VMEI_TX_SEGS, NULL);
assert(n == 2); if (n != VMEI_TX_SEGS) {
if (n == -1 || n == 0)
pr_err("%s: fail to getchain!\n", __func__);
else {
pr_warn("%s: invalid chain, desc number %d!\n", __func__, n);
vq_relchain(vq, idx, 0);
}
return;
}
hdr = (struct mei_msg_hdr *)iov[0].iov_base; hdr = (struct mei_msg_hdr *)iov[0].iov_base;
data = (uint8_t *)iov[1].iov_base; data = (uint8_t *)iov[1].iov_base;
@ -1629,7 +1637,6 @@ static void *vmei_tx_thread(void *param)
if (pending_cnt == 0) { if (pending_cnt == 0) {
err = pthread_cond_wait(&vmei->tx_cond, err = pthread_cond_wait(&vmei->tx_cond,
&vmei->tx_mutex); &vmei->tx_mutex);
assert(err == 0);
if (err) if (err)
goto out; goto out;
} else { } else {
@ -1638,7 +1645,6 @@ static void *vmei_tx_thread(void *param)
err = pthread_cond_timedwait(&vmei->tx_cond, err = pthread_cond_timedwait(&vmei->tx_cond,
&vmei->tx_mutex, &vmei->tx_mutex,
&max_wait); &max_wait);
assert(err == 0 || err == ETIMEDOUT);
if (err && err != ETIMEDOUT) if (err && err != ETIMEDOUT)
goto out; goto out;
@ -1777,9 +1783,15 @@ vmei_proc_vclient_rx(struct vmei_host_client *hclient,
bool complete = true; bool complete = true;
n = vq_getchain(vq, &idx, iov, VMEI_RX_SEGS, NULL); n = vq_getchain(vq, &idx, iov, VMEI_RX_SEGS, NULL);
assert(n == VMEI_RX_SEGS); if (n != VMEI_RX_SEGS) {
if (n != VMEI_RX_SEGS) if (n == -1)
pr_err("%s: fail to getchain!\n", __func__);
else {
pr_warn("%s: invalid chain, desc number %d!\n", __func__, n);
vq_relchain(vq, idx, 0);
}
return; return;
}
len = hclient->recv_offset - hclient->recv_handled; len = hclient->recv_offset - hclient->recv_handled;
HCL_DBG(hclient, "RX: DM->UOS: off=%d len=%d\n", HCL_DBG(hclient, "RX: DM->UOS: off=%d len=%d\n",
@ -1883,7 +1895,6 @@ static void *vmei_rx_thread(void *param)
while (vmei->status != VMEI_STST_DEINIT && !vq_ring_ready(vq)) { while (vmei->status != VMEI_STST_DEINIT && !vq_ring_ready(vq)) {
err = pthread_cond_wait(&vmei->rx_cond, &vmei->rx_mutex); err = pthread_cond_wait(&vmei->rx_cond, &vmei->rx_mutex);
assert(err == 0);
if (err) if (err)
goto out; goto out;
} }
@ -1900,7 +1911,6 @@ static void *vmei_rx_thread(void *param)
err = pthread_cond_wait(&vmei->rx_cond, err = pthread_cond_wait(&vmei->rx_cond,
&vmei->rx_mutex); &vmei->rx_mutex);
assert(err == 0);
if (err || vmei->status == VMEI_STST_DEINIT) if (err || vmei->status == VMEI_STST_DEINIT)
goto out; goto out;
} }