Re: qwx: avoid dmamap_create in interrupt context

Mark Kettenis <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
> Date: Thu, 28 May 2026 18:09:33 +0200
> From: Stefan Sperling <[email protected]>
> 
> Avoid calling bus_dmamap_create() in interrupt context.
> Fixes splasserts found in my dmesg.
> 
> These maps are destroyed when the interface is put down so it seems
> the cleanup path for these maps is already correct.
> 
> ok?

ok kettenis@

> M  sys/dev/ic/qwx.c  |  12+  14-
> 
> 1 file changed, 12 insertions(+), 14 deletions(-)
> 
> commit - 0011eb694ed868029b1350be16b78dba35476655
> commit + a9d9214d750de25ef4b76cd274a323488ce6822e
> blob - 553e2b8dd4ac76e3e225558ee38039a9f5de4c00
> blob + 8e1d89bce62598a9f5bc82ea2f5ce06f8a477963
> --- sys/dev/ic/qwx.c
> +++ sys/dev/ic/qwx.c
> @@ -15278,12 +15278,7 @@ qwx_dp_rxbufs_replenish(struct qwx_softc *sc, int mac_
>  			goto fail_free_mbuf;
>  
>  		rx_data = &rx_ring->rx_data[idx];
> -		if (rx_data->map == NULL) {
> -			ret = bus_dmamap_create(sc->sc_dmat, size, 1,
> -			    size, 0, BUS_DMA_NOWAIT, &rx_data->map);
> -			if (ret)
> -				goto fail_free_mbuf;
> -		}
> +		KASSERT(rx_data->map);
>  		
>  		ret = bus_dmamap_load_mbuf(sc->sc_dmat, rx_data->map, m,
>  		    BUS_DMA_READ | BUS_DMA_NOWAIT);
> @@ -15333,7 +15328,7 @@ qwx_dp_rxdma_ring_buf_setup(struct qwx_softc *sc,
>      struct dp_rxdma_ring *rx_ring, uint32_t ringtype)
>  {
>  	struct qwx_pdev_dp *dp = &sc->pdev_dp;
> -	int num_entries;
> +	int num_entries, i;
>  
>  	num_entries = rx_ring->refill_buf_ring.size /
>  	    qwx_hal_srng_get_entrysize(sc, ringtype);
> @@ -15344,6 +15339,14 @@ qwx_dp_rxdma_ring_buf_setup(struct qwx_softc *sc,
>  	if (rx_ring->rx_data == NULL)
>  		return ENOMEM;
>  
> +	for (i = 0; i < num_entries; i++) {
> +		struct qwx_rx_data *rx_data = &rx_ring->rx_data[i];
> +
> +		if (bus_dmamap_create(sc->sc_dmat, DP_RX_BUFFER_SIZE, 1,
> +		    DP_RX_BUFFER_SIZE, 0, BUS_DMA_NOWAIT, &rx_data->map))
> +			return ENOMEM;
> +	}
> +
>  	rx_ring->bufs_max = num_entries;
>  	memset(rx_ring->freemap, 0xff, sizeof(rx_ring->freemap));
>  
> @@ -17674,13 +17677,8 @@ qwx_dp_rx_alloc_mon_status_buf(struct qwx_softc *sc,
>  	if (rx_data->m != NULL)
>  		goto fail_free_mbuf;
>  
> -	if (rx_data->map == NULL) {
> -		ret = bus_dmamap_create(sc->sc_dmat, size, 1,
> -		    size, 0, BUS_DMA_NOWAIT, &rx_data->map);
> -		if (ret)
> -			goto fail_free_mbuf;
> -	}
> -	
> +	KASSERT(rx_data->map);
> +
>  	ret = bus_dmamap_load_mbuf(sc->sc_dmat, rx_data->map, m,
>  	    BUS_DMA_READ | BUS_DMA_NOWAIT);
>  	if (ret) {
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.