Index | Thread | Search

From:
Jonathan Matthew <jonathan@d14n.org>
Subject:
Re: iavf patch [3/4]: PCI bus error handling
To:
Yuichiro NAITO <naito.yuichiro@gmail.com>
Cc:
tech@openbsd.org
Date:
Wed, 21 May 2025 22:47:51 +1000

Download raw body.

Thread
On Fri, Feb 07, 2025 at 04:25:29PM +0900, Yuichiro NAITO wrote:
> This patch is the same as the following mail.
> 
> https://marc.info/?l=openbsd-tech&m=172723210819245&w=2
> 
> Now, We have support of i440fx chipset emulation on QEMU.
> However, I think we need to catch up with an error case
> while the iavf driver attaches.

Thanks.  I looked at some other iavf drivers and realised this
is necessary for any setup, as the link state event can arrive
at any time, so I've committed this patch.

> 
> OK?
> 
> diff --git a/sys/dev/pci/if_iavf.c b/sys/dev/pci/if_iavf.c
> index 38f3cce26b6..204dbfc2637 100644
> --- a/sys/dev/pci/if_iavf.c
> +++ b/sys/dev/pci/if_iavf.c
> @@ -616,6 +616,7 @@ struct iavf_softc {
>  	uint32_t		 sc_major_ver;
>  	uint32_t		 sc_minor_ver;
>  
> +	int			 sc_if_attached;
>  	int			 sc_got_vf_resources;
>  	int			 sc_got_irq_map;
>  	uint32_t		 sc_vf_id;
> @@ -1078,6 +1079,7 @@ iavf_attach(struct device *parent, struct device *self, void *aux)
>  
>  	if_attach_queues(ifp, iavf_nqueues(sc));
>  	if_attach_iqueues(ifp, iavf_nqueues(sc));
> +	sc->sc_if_attached++;
>  
>  	iavf_intr_enable(sc);
>  
> @@ -1627,7 +1629,8 @@ iavf_reset(void *xsc)
>  	link_state = ifp->if_link_state;
>  	if (ifp->if_link_state != LINK_STATE_DOWN) {
>  		ifp->if_link_state = LINK_STATE_DOWN;
> -		if_link_state_change(ifp);
> +		if (sc->sc_if_attached)
> +			if_link_state_change(ifp);
>  	}
>  
>  	up = 0;
> 
> -- 
> Yuichiro NAITO (naito.yuichiro@gmail.com)
>