Re: [PATCH net-next v10 3/5] net: rnpgbe: Add basic mbx ops support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>  struct mucse_mbx_info {
> +	struct mucse_mbx_stats stats;
> +	u32 timeout;
> +	u32 usec_delay;
> +	u16 size;
> +	u16 fw_req;
> +	u16 fw_ack;
> +	/* lock for only one use mbx */
> +	struct mutex lock;
>  	/* fw <--> pf mbx */
>  	u32 fw_pf_shm_base;
>  	u32 pf2fw_mbox_ctrl;

> +/**
> + * mucse_obtain_mbx_lock_pf - Obtain mailbox lock
> + * @hw: pointer to the HW structure
> + *
> + * This function maybe used in an irq handler.
> + *
> + * Return: 0 if we obtained the mailbox lock or else -EIO
> + **/
> +static int mucse_obtain_mbx_lock_pf(struct mucse_hw *hw)
> +{
> +	struct mucse_mbx_info *mbx = &hw->mbx;
> +	int try_cnt = 5000;
> +	u32 reg;
> +
> +	reg = PF2FW_MBOX_CTRL(mbx);
> +	while (try_cnt-- > 0) {
> +		mbx_ctrl_wr32(mbx, reg, MBOX_PF_HOLD);
> +		/* force write back before check */
> +		wmb();
> +		if (mbx_ctrl_rd32(mbx, reg) & MBOX_PF_HOLD)
> +			return 0;
> +		udelay(100);
> +	}
> +	return -EIO;
> +}

If there is a function which obtains a lock, there is normally a
function which releases a lock. But i don't see it.

> +void mucse_init_mbx_params_pf(struct mucse_hw *hw)
> +{
> +	struct mucse_mbx_info *mbx = &hw->mbx;
> +
> +	mbx->usec_delay = 100;
> +	mbx->timeout = (4 * USEC_PER_SEC) / mbx->usec_delay;
> +	mbx->stats.msgs_tx = 0;
> +	mbx->stats.msgs_rx = 0;
> +	mbx->stats.reqs = 0;
> +	mbx->stats.acks = 0;
> +	mbx->size = MUCSE_MAILBOX_BYTES;
> +	mutex_init(&mbx->lock);

And this mutex never seems to be used anywhere. What is it supposed to
be protecting?

    Andrew

---
pw-bot: cr




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux