Unverified Commit 83500aaf authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1327 Huawei BMA: To fix the bug in the iBMA driver code

parents 506ed3ba 3d016b4b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
#ifdef DRV_VERSION
#define CDEV_VERSION		MICRO_TO_STR(DRV_VERSION)
#else
#define CDEV_VERSION		"0.3.5"
#define CDEV_VERSION		"0.3.6"
#endif

#define CDEV_DEFAULT_NUM	4
+8 −6
Original line number Diff line number Diff line
@@ -667,6 +667,7 @@ static int edma_veth_copy_full_packet(struct edma_eth_dev_s *eth_dev,
				      u8 *packet, u32 len)
{
	unsigned int count = 0;
	unsigned long flags = 0;
	u8 *ptr = NULL;

	LOG(DLOG_DEBUG, "Recv full packet, len %u.", len);
@@ -674,14 +675,14 @@ static int edma_veth_copy_full_packet(struct edma_eth_dev_s *eth_dev,
	ptr = kmalloc(len, GFP_ATOMIC);
	if (ptr) {
		/* lock the queue. */
		spin_lock(&eth_dev->rx_queue_lock);
		spin_lock_irqsave(&eth_dev->rx_queue_lock, flags);

		count = edma_veth_get_ring_buf_count(eth_dev->rx_packet_head,
						     eth_dev->rx_packet_tail,
						     MAX_RXTX_PACKET_LEN);
		if (count >= (MAX_RXTX_PACKET_LEN - 1)) {
			LOG(DLOG_DEBUG, "The rx queue is full.");
			spin_unlock(&eth_dev->rx_queue_lock);
			spin_unlock_irqrestore(&eth_dev->rx_queue_lock, flags);
			kfree(ptr);
			return -EBUSY;
		}
@@ -692,7 +693,7 @@ static int edma_veth_copy_full_packet(struct edma_eth_dev_s *eth_dev,
		eth_dev->rx_packet_tail = (eth_dev->rx_packet_tail + 1) %
					   MAX_RXTX_PACKET_LEN;

		spin_unlock(&eth_dev->rx_queue_lock);
		spin_unlock_irqrestore(&eth_dev->rx_queue_lock, flags);

		return 0;
	}
@@ -1672,16 +1673,17 @@ static ssize_t cdev_copy_packet_to_user(struct edma_eth_dev_s *dev,
	unsigned char *packet = NULL;
	unsigned char *start = NULL;
	unsigned int free_packet = 0;
	unsigned long flags = 0;
	ssize_t length = (ssize_t)count;
	ssize_t left;

	LOG(DLOG_DEBUG, "rx_packet_head:%u, rx_packet_tail: %u",
	    dev->rx_packet_head, dev->rx_packet_tail);

	spin_lock(&dev->rx_queue_lock);
	spin_lock_irqsave(&dev->rx_queue_lock, flags);

	if (!cdev_check_ring_recv()) {
		spin_unlock(&dev->rx_queue_lock);
		spin_unlock_irqrestore(&dev->rx_queue_lock, flags);
		return -EAGAIN;
	}

@@ -1712,7 +1714,7 @@ static ssize_t cdev_copy_packet_to_user(struct edma_eth_dev_s *dev,
				      MAX_RXTX_PACKET_LEN;
	}

	spin_unlock(&dev->rx_queue_lock);
	spin_unlock_irqrestore(&dev->rx_queue_lock, flags);

	if (length > 0 && copy_to_user(data, start, length)) {
		LOG(DLOG_DEBUG, "Failed to copy to user, skip this message.");
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ struct bma_pci_dev_s {
#ifdef DRV_VERSION
#define BMA_VERSION MICRO_TO_STR(DRV_VERSION)
#else
#define BMA_VERSION "0.3.5"
#define BMA_VERSION "0.3.6"
#endif

#ifdef CONFIG_ARM64
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#ifdef DRV_VERSION
#define KBOX_VERSION MICRO_TO_STR(DRV_VERSION)
#else
#define KBOX_VERSION "0.3.5"
#define KBOX_VERSION "0.3.6"
#endif

#define UNUSED(x) (x = x)
+9 −1
Original line number Diff line number Diff line
@@ -87,6 +87,12 @@ u32 g_testlbk;

struct bspveth_device g_bspveth_dev = {};

/* g_shutdown_flag is used to prevent veth_shutdown_task
 * from being preempted by veth_dma_tx_timer_do_H.
 * The default value is 0.The value 1 indicates that veth_shutdown_flag cannot be preempted,
 * and the value 0 indicates that veth_shutdown_task can be preempted.
 */
static int g_shutdown_flag;
static int veth_int_handler(struct notifier_block *pthis, unsigned long ev,
			    void *unuse);

@@ -1607,6 +1613,7 @@ void veth_netdev_exit(void)
static void veth_shutdown_task(struct work_struct *work)
{
	struct net_device *netdev = g_bspveth_dev.pnetdev;
	g_shutdown_flag = 1;

	VETH_LOG(DLOG_ERROR, "veth is going down, please restart it manual\n");

@@ -1626,6 +1633,7 @@ static void veth_shutdown_task(struct work_struct *work)

		(void)veth_dmatimer_close_H();
	}
	g_shutdown_flag = 0;
}

s32 veth_netdev_init(void)
@@ -1728,7 +1736,7 @@ void veth_dma_tx_timer_do_H(unsigned long data)

	rxret = veth_dma_task_H(BSPVETH_RX);

	if (txret == BSP_ERR_AGAIN || rxret == BSP_ERR_AGAIN) {
	if ((txret == BSP_ERR_AGAIN || rxret == BSP_ERR_AGAIN) && (g_shutdown_flag == 0)) {
#ifndef USE_TASKLET
		(void)mod_timer(&g_bspveth_dev.dmatimer, jiffies_64);
#else
Loading