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

View File

@ -60,7 +60,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <pthread.h>
#include <sysexits.h>
#include <dlfcn.h>
@ -181,7 +180,15 @@ virtio_coreu_thread(void *param)
do {
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);

View File

@ -55,7 +55,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <pthread.h>
#include <sysexits.h>
#include <dlfcn.h>
@ -312,17 +311,23 @@ virtio_hdcp_talk_to_daemon(void *param)
* - avoid vring processing due to spurious wakeups
* - catch missing notifications before acquiring rx_mtx
*/
while (!vq_has_descs(rvq)) {
ret = pthread_cond_wait(&vhdcp->rx_cond, &vhdcp->rx_mtx);
assert(ret == 0);
}
while (!vq_has_descs(rvq))
pthread_cond_wait(&vhdcp->rx_cond, &vhdcp->rx_mtx);
vhdcp->in_progress = 1;
pthread_mutex_unlock(&vhdcp->rx_mtx);
do {
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);

View File

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

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.
*/
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;
data = (uint8_t *)iov[1].iov_base;
@ -1629,7 +1637,6 @@ static void *vmei_tx_thread(void *param)
if (pending_cnt == 0) {
err = pthread_cond_wait(&vmei->tx_cond,
&vmei->tx_mutex);
assert(err == 0);
if (err)
goto out;
} else {
@ -1638,7 +1645,6 @@ static void *vmei_tx_thread(void *param)
err = pthread_cond_timedwait(&vmei->tx_cond,
&vmei->tx_mutex,
&max_wait);
assert(err == 0 || err == ETIMEDOUT);
if (err && err != ETIMEDOUT)
goto out;
@ -1777,9 +1783,15 @@ vmei_proc_vclient_rx(struct vmei_host_client *hclient,
bool complete = true;
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;
}
len = hclient->recv_offset - hclient->recv_handled;
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)) {
err = pthread_cond_wait(&vmei->rx_cond, &vmei->rx_mutex);
assert(err == 0);
if (err)
goto out;
}
@ -1900,7 +1911,6 @@ static void *vmei_rx_thread(void *param)
err = pthread_cond_wait(&vmei->rx_cond,
&vmei->rx_mutex);
assert(err == 0);
if (err || vmei->status == VMEI_STST_DEINIT)
goto out;
}