Hi Paolo, > On 5/13/25 7:31 AM, Lukasz Majewski wrote: > >> On 5/4/25 4:55 PM, Lukasz Majewski wrote: > >>> + /* This does 16 byte alignment, exactly what we > >>> need. > >>> + * The packet length includes FCS, but we don't > >>> want to > >>> + * include that when passing upstream as it > >>> messes up > >>> + * bridging applications. > >>> + */ > >>> + skb = netdev_alloc_skb(pndev, pkt_len + > >>> NET_IP_ALIGN); > >>> + if (unlikely(!skb)) { > >>> + dev_dbg(&fep->pdev->dev, > >>> + "%s: Memory squeeze, dropping > >>> packet.\n", > >>> + pndev->name); > >>> + pndev->stats.rx_dropped++; > >>> + goto err_mem; > >>> + } else { > >>> + skb_reserve(skb, NET_IP_ALIGN); > >>> + skb_put(skb, pkt_len); /* Make room > >>> */ > >>> + skb_copy_to_linear_data(skb, data, > >>> pkt_len); > >>> + skb->protocol = eth_type_trans(skb, > >>> pndev); > >>> + napi_gro_receive(&fep->napi, skb); > >>> + } > >>> + > >>> + bdp->cbd_bufaddr = > >>> dma_map_single(&fep->pdev->dev, data, > >>> + > >>> bdp->cbd_datlen, > >>> + > >>> DMA_FROM_DEVICE); > >>> + if (unlikely(dma_mapping_error(&fep->pdev->dev, > >>> + > >>> bdp->cbd_bufaddr))) { > >>> + dev_err(&fep->pdev->dev, > >>> + "Failed to map descriptor rx > >>> buffer\n"); > >>> + pndev->stats.rx_errors++; > >>> + pndev->stats.rx_dropped++; > >>> + dev_kfree_skb_any(skb); > >>> + goto err_mem; > >>> + } > >> > >> This is doing the mapping and ev. dropping the skb _after_ pushing > >> the skb up the stack, you must attempt the mapping first. > > > > I've double check it - the code seems to be correct. > > > > This code is a part of mtip_switch_rx() function, which handles > > receiving data. > > > > First, on probe, the initial dma memory is mapped for MTIP received > > data. > > > > When we receive data, it is processed and afterwards it is "pushed" > > up to the network stack. > > > > As a last step we do map memory for next, incoming data and leave > > the function. > > > > Hence, IMHO, the order is OK and this part shall be left as is. > > First thing first, I'm sorry for lagging behind. This fell outside my > radar. Let's keep the conversation on the new patch version, it should > help me to avoid repeating this mistake. +1 > > /P > Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de