Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'net-6.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Paolo Abeni:
"Including fixes from Bluetooth.

Current release - new code bugs:

- eth:
- txgbe: fix the issue of TX failure
- ngbe: specify IRQ vector when the number of VFs is 7

Previous releases - regressions:

- sched: always pass notifications when child class becomes empty

- ipv4: fix stat increase when udp early demux drops the packet

- bluetooth: prevent unintended pause by checking if advertising is active

- virtio: fix error reporting in virtqueue_resize

- eth:
- virtio-net:
- ensure the received length does not exceed allocated size
- fix the xsk frame's length check
- lan78xx: fix WARN in __netif_napi_del_locked on disconnect

Previous releases - always broken:

- bluetooth: mesh: check instances prior disabling advertising

- eth:
- idpf: convert control queue mutex to a spinlock
- dpaa2: fix xdp_rxq_info leak
- amd-xgbe: align CL37 AN sequence as per databook"

* tag 'net-6.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (38 commits)
vsock/vmci: Clear the vmci transport packet properly when initializing it
dt-bindings: net: sophgo,sg2044-dwmac: Drop status from the example
net: ngbe: specify IRQ vector when the number of VFs is 7
net: wangxun: revert the adjustment of the IRQ vector sequence
net: txgbe: request MISC IRQ in ndo_open
virtio_net: Enforce minimum TX ring size for reliability
virtio_net: Cleanup '2+MAX_SKB_FRAGS'
virtio_ring: Fix error reporting in virtqueue_resize
virtio-net: xsk: rx: fix the frame's length check
virtio-net: use the check_mergeable_len helper
virtio-net: remove redundant truesize check with PAGE_SIZE
virtio-net: ensure the received length does not exceed allocated size
net: ipv4: fix stat increase when udp early demux drops the packet
net: libwx: fix the incorrect display of the queue number
amd-xgbe: do not double read link status
net/sched: Always pass notifications when child class becomes empty
nui: Fix dma_mapping_error() check
rose: fix dangling neighbour pointers in rose_rt_device_down()
enic: fix incorrect MTU comparison in enic_change_mtu()
amd-xgbe: align CL37 AN sequence as per databook
...

+494 -296
+2 -1
Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
··· 80 80 interrupt-parent = <&intc>; 81 81 interrupts = <296 IRQ_TYPE_LEVEL_HIGH>; 82 82 interrupt-names = "macirq"; 83 + phy-handle = <&phy0>; 84 + phy-mode = "rgmii-id"; 83 85 resets = <&rst 30>; 84 86 reset-names = "stmmaceth"; 85 87 snps,multicast-filter-bins = <0>; ··· 93 91 snps,mtl-rx-config = <&gmac0_mtl_rx_setup>; 94 92 snps,mtl-tx-config = <&gmac0_mtl_tx_setup>; 95 93 snps,axi-config = <&gmac0_stmmac_axi_setup>; 96 - status = "disabled"; 97 94 98 95 gmac0_mtl_rx_setup: rx-queues-config { 99 96 snps,rx-queues-to-use = <8>;
+3 -1
Documentation/networking/tls.rst
··· 16 16 Creating a TLS connection 17 17 ------------------------- 18 18 19 - First create a new TCP socket and set the TLS ULP. 19 + First create a new TCP socket and once the connection is established set the 20 + TLS ULP. 20 21 21 22 .. code-block:: c 22 23 23 24 sock = socket(AF_INET, SOCK_STREAM, 0); 25 + connect(sock, addr, addrlen); 24 26 setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls")); 25 27 26 28 Setting the TLS ULP allows us to set/get TLS socket options. Currently
+1 -1
Documentation/process/maintainer-netdev.rst
··· 312 312 (as of patchwork 2.2.2). 313 313 314 314 Co-posting selftests 315 - -------------------- 315 + ~~~~~~~~~~~~~~~~~~~~ 316 316 317 317 Selftests should be part of the same series as the code changes. 318 318 Specifically for fixes both code change and related test should go into
+7 -3
MAINTAINERS
··· 15550 15550 MELLANOX ETHERNET DRIVER (mlx5e) 15551 15551 M: Saeed Mahameed <saeedm@nvidia.com> 15552 15552 M: Tariq Toukan <tariqt@nvidia.com> 15553 + M: Mark Bloch <mbloch@nvidia.com> 15553 15554 L: netdev@vger.kernel.org 15554 15555 S: Maintained 15555 15556 W: https://www.nvidia.com/networking/ ··· 15620 15619 M: Saeed Mahameed <saeedm@nvidia.com> 15621 15620 M: Leon Romanovsky <leonro@nvidia.com> 15622 15621 M: Tariq Toukan <tariqt@nvidia.com> 15622 + M: Mark Bloch <mbloch@nvidia.com> 15623 15623 L: netdev@vger.kernel.org 15624 15624 L: linux-rdma@vger.kernel.org 15625 15625 S: Maintained ··· 21200 21198 L: netdev@vger.kernel.org 21201 21199 L: linux-renesas-soc@vger.kernel.org 21202 21200 S: Maintained 21203 - F: Documentation/devicetree/bindings/net/renesas,r9a09g057-gbeth.yaml 21201 + F: Documentation/devicetree/bindings/net/renesas,rzv2h-gbeth.yaml 21204 21202 F: drivers/net/ethernet/stmicro/stmmac/dwmac-renesas-gbeth.c 21205 21203 21206 21204 RENESAS RZ/V2H(P) USB2PHY PORT RESET DRIVER ··· 22588 22586 F: drivers/misc/sgi-xp/ 22589 22587 22590 22588 SHARED MEMORY COMMUNICATIONS (SMC) SOCKETS 22589 + M: D. Wythe <alibuda@linux.alibaba.com> 22590 + M: Dust Li <dust.li@linux.alibaba.com> 22591 + M: Sidraya Jayagond <sidraya@linux.ibm.com> 22591 22592 M: Wenjia Zhang <wenjia@linux.ibm.com> 22592 - M: Jan Karcher <jaka@linux.ibm.com> 22593 - R: D. Wythe <alibuda@linux.alibaba.com> 22593 + R: Mahanta Jambigi <mjambigi@linux.ibm.com> 22594 22594 R: Tony Lu <tonylu@linux.alibaba.com> 22595 22595 R: Wen Gu <guwen@linux.alibaba.com> 22596 22596 L: linux-rdma@vger.kernel.org
+2
drivers/net/ethernet/amd/xgbe/xgbe-common.h
··· 1269 1269 #define MDIO_VEND2_CTRL1_SS13 BIT(13) 1270 1270 #endif 1271 1271 1272 + #define XGBE_VEND2_MAC_AUTO_SW BIT(9) 1273 + 1272 1274 /* MDIO mask values */ 1273 1275 #define XGBE_AN_CL73_INT_CMPLT BIT(0) 1274 1276 #define XGBE_AN_CL73_INC_LINK BIT(1)
+13
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
··· 266 266 reg |= MDIO_VEND2_CTRL1_AN_RESTART; 267 267 268 268 XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_CTRL1, reg); 269 + 270 + reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL); 271 + reg |= XGBE_VEND2_MAC_AUTO_SW; 272 + XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg); 269 273 } 270 274 271 275 static void xgbe_an37_restart(struct xgbe_prv_data *pdata) ··· 898 894 899 895 netif_dbg(pdata, link, pdata->netdev, "CL37 AN (%s) initialized\n", 900 896 (pdata->an_mode == XGBE_AN_MODE_CL37) ? "BaseX" : "SGMII"); 897 + 898 + reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_CTRL1); 899 + reg &= ~MDIO_AN_CTRL1_ENABLE; 900 + XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_CTRL1, reg); 901 + 901 902 } 902 903 903 904 static void xgbe_an73_init(struct xgbe_prv_data *pdata) ··· 1304 1295 1305 1296 pdata->phy.link = pdata->phy_if.phy_impl.link_status(pdata, 1306 1297 &an_restart); 1298 + /* bail out if the link status register read fails */ 1299 + if (pdata->phy.link < 0) 1300 + return; 1301 + 1307 1302 if (an_restart) { 1308 1303 xgbe_phy_config_aneg(pdata); 1309 1304 goto adjust_link;
+15 -9
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
··· 2746 2746 static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart) 2747 2747 { 2748 2748 struct xgbe_phy_data *phy_data = pdata->phy_data; 2749 - unsigned int reg; 2750 - int ret; 2749 + int reg, ret; 2751 2750 2752 2751 *an_restart = 0; 2753 2752 ··· 2780 2781 return 0; 2781 2782 } 2782 2783 2783 - /* Link status is latched low, so read once to clear 2784 - * and then read again to get current state 2784 + reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); 2785 + if (reg < 0) 2786 + return reg; 2787 + 2788 + /* Link status is latched low so that momentary link drops 2789 + * can be detected. If link was already down read again 2790 + * to get the latest state. 2785 2791 */ 2786 - reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); 2787 - reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); 2792 + 2793 + if (!pdata->phy.link && !(reg & MDIO_STAT1_LSTATUS)) { 2794 + reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); 2795 + if (reg < 0) 2796 + return reg; 2797 + } 2788 2798 2789 2799 if (pdata->en_rx_adap) { 2790 2800 /* if the link is available and adaptation is done, ··· 2812 2804 xgbe_phy_set_mode(pdata, phy_data->cur_mode); 2813 2805 } 2814 2806 2815 - /* check again for the link and adaptation status */ 2816 - reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1); 2817 - if ((reg & MDIO_STAT1_LSTATUS) && pdata->rx_adapt_done) 2807 + if (pdata->rx_adapt_done) 2818 2808 return 1; 2819 2809 } else if (reg & MDIO_STAT1_LSTATUS) 2820 2810 return 1;
+2 -2
drivers/net/ethernet/amd/xgbe/xgbe.h
··· 183 183 #define XGBE_LINK_TIMEOUT 5 184 184 #define XGBE_KR_TRAINING_WAIT_ITER 50 185 185 186 - #define XGBE_SGMII_AN_LINK_STATUS BIT(1) 186 + #define XGBE_SGMII_AN_LINK_DUPLEX BIT(1) 187 187 #define XGBE_SGMII_AN_LINK_SPEED (BIT(2) | BIT(3)) 188 188 #define XGBE_SGMII_AN_LINK_SPEED_10 0x00 189 189 #define XGBE_SGMII_AN_LINK_SPEED_100 0x04 190 190 #define XGBE_SGMII_AN_LINK_SPEED_1000 0x08 191 - #define XGBE_SGMII_AN_LINK_DUPLEX BIT(4) 191 + #define XGBE_SGMII_AN_LINK_STATUS BIT(4) 192 192 193 193 /* ECC correctable error notification window (seconds) */ 194 194 #define XGBE_ECC_LIMIT 60
+57 -22
drivers/net/ethernet/atheros/atlx/atl1.c
··· 1861 1861 break; 1862 1862 } 1863 1863 1864 - buffer_info->alloced = 1; 1865 - buffer_info->skb = skb; 1866 - buffer_info->length = (u16) adapter->rx_buffer_len; 1867 1864 page = virt_to_page(skb->data); 1868 1865 offset = offset_in_page(skb->data); 1869 1866 buffer_info->dma = dma_map_page(&pdev->dev, page, offset, 1870 1867 adapter->rx_buffer_len, 1871 1868 DMA_FROM_DEVICE); 1869 + if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { 1870 + kfree_skb(skb); 1871 + adapter->soft_stats.rx_dropped++; 1872 + break; 1873 + } 1874 + 1875 + buffer_info->alloced = 1; 1876 + buffer_info->skb = skb; 1877 + buffer_info->length = (u16)adapter->rx_buffer_len; 1878 + 1872 1879 rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma); 1873 1880 rfd_desc->buf_len = cpu_to_le16(adapter->rx_buffer_len); 1874 1881 rfd_desc->coalese = 0; ··· 2190 2183 return 0; 2191 2184 } 2192 2185 2193 - static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb, 2194 - struct tx_packet_desc *ptpd) 2186 + static bool atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb, 2187 + struct tx_packet_desc *ptpd) 2195 2188 { 2196 2189 struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; 2197 2190 struct atl1_buffer *buffer_info; ··· 2201 2194 unsigned int nr_frags; 2202 2195 unsigned int f; 2203 2196 int retval; 2197 + u16 first_mapped; 2204 2198 u16 next_to_use; 2205 2199 u16 data_len; 2206 2200 u8 hdr_len; ··· 2209 2201 buf_len -= skb->data_len; 2210 2202 nr_frags = skb_shinfo(skb)->nr_frags; 2211 2203 next_to_use = atomic_read(&tpd_ring->next_to_use); 2204 + first_mapped = next_to_use; 2212 2205 buffer_info = &tpd_ring->buffer_info[next_to_use]; 2213 2206 BUG_ON(buffer_info->skb); 2214 2207 /* put skb in last TPD */ ··· 2225 2216 buffer_info->dma = dma_map_page(&adapter->pdev->dev, page, 2226 2217 offset, hdr_len, 2227 2218 DMA_TO_DEVICE); 2219 + if (dma_mapping_error(&adapter->pdev->dev, buffer_info->dma)) 2220 + goto dma_err; 2228 2221 2229 2222 if (++next_to_use == tpd_ring->count) 2230 2223 next_to_use = 0; ··· 2253 2242 page, offset, 2254 2243 buffer_info->length, 2255 2244 DMA_TO_DEVICE); 2245 + if (dma_mapping_error(&adapter->pdev->dev, 2246 + buffer_info->dma)) 2247 + goto dma_err; 2256 2248 if (++next_to_use == tpd_ring->count) 2257 2249 next_to_use = 0; 2258 2250 } ··· 2268 2254 buffer_info->dma = dma_map_page(&adapter->pdev->dev, page, 2269 2255 offset, buf_len, 2270 2256 DMA_TO_DEVICE); 2257 + if (dma_mapping_error(&adapter->pdev->dev, buffer_info->dma)) 2258 + goto dma_err; 2271 2259 if (++next_to_use == tpd_ring->count) 2272 2260 next_to_use = 0; 2273 2261 } ··· 2293 2277 buffer_info->dma = skb_frag_dma_map(&adapter->pdev->dev, 2294 2278 frag, i * ATL1_MAX_TX_BUF_LEN, 2295 2279 buffer_info->length, DMA_TO_DEVICE); 2280 + if (dma_mapping_error(&adapter->pdev->dev, 2281 + buffer_info->dma)) 2282 + goto dma_err; 2296 2283 2297 2284 if (++next_to_use == tpd_ring->count) 2298 2285 next_to_use = 0; ··· 2304 2285 2305 2286 /* last tpd's buffer-info */ 2306 2287 buffer_info->skb = skb; 2288 + 2289 + return true; 2290 + 2291 + dma_err: 2292 + while (first_mapped != next_to_use) { 2293 + buffer_info = &tpd_ring->buffer_info[first_mapped]; 2294 + dma_unmap_page(&adapter->pdev->dev, 2295 + buffer_info->dma, 2296 + buffer_info->length, 2297 + DMA_TO_DEVICE); 2298 + buffer_info->dma = 0; 2299 + 2300 + if (++first_mapped == tpd_ring->count) 2301 + first_mapped = 0; 2302 + } 2303 + return false; 2307 2304 } 2308 2305 2309 2306 static void atl1_tx_queue(struct atl1_adapter *adapter, u16 count, ··· 2390 2355 2391 2356 len = skb_headlen(skb); 2392 2357 2393 - if (unlikely(skb->len <= 0)) { 2394 - dev_kfree_skb_any(skb); 2395 - return NETDEV_TX_OK; 2396 - } 2358 + if (unlikely(skb->len <= 0)) 2359 + goto drop_packet; 2397 2360 2398 2361 nr_frags = skb_shinfo(skb)->nr_frags; 2399 2362 for (f = 0; f < nr_frags; f++) { ··· 2404 2371 if (mss) { 2405 2372 if (skb->protocol == htons(ETH_P_IP)) { 2406 2373 proto_hdr_len = skb_tcp_all_headers(skb); 2407 - if (unlikely(proto_hdr_len > len)) { 2408 - dev_kfree_skb_any(skb); 2409 - return NETDEV_TX_OK; 2410 - } 2374 + if (unlikely(proto_hdr_len > len)) 2375 + goto drop_packet; 2376 + 2411 2377 /* need additional TPD ? */ 2412 2378 if (proto_hdr_len != len) 2413 2379 count += (len - proto_hdr_len + ··· 2438 2406 } 2439 2407 2440 2408 tso = atl1_tso(adapter, skb, ptpd); 2441 - if (tso < 0) { 2442 - dev_kfree_skb_any(skb); 2443 - return NETDEV_TX_OK; 2444 - } 2409 + if (tso < 0) 2410 + goto drop_packet; 2445 2411 2446 2412 if (!tso) { 2447 2413 ret_val = atl1_tx_csum(adapter, skb, ptpd); 2448 - if (ret_val < 0) { 2449 - dev_kfree_skb_any(skb); 2450 - return NETDEV_TX_OK; 2451 - } 2414 + if (ret_val < 0) 2415 + goto drop_packet; 2452 2416 } 2453 2417 2454 - atl1_tx_map(adapter, skb, ptpd); 2418 + if (!atl1_tx_map(adapter, skb, ptpd)) 2419 + goto drop_packet; 2420 + 2455 2421 atl1_tx_queue(adapter, count, ptpd); 2456 2422 atl1_update_mailbox(adapter); 2423 + return NETDEV_TX_OK; 2424 + 2425 + drop_packet: 2426 + adapter->soft_stats.tx_errors++; 2427 + dev_kfree_skb_any(skb); 2457 2428 return NETDEV_TX_OK; 2458 2429 } 2459 2430
+2 -2
drivers/net/ethernet/cisco/enic/enic_main.c
··· 1864 1864 if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic)) 1865 1865 return -EOPNOTSUPP; 1866 1866 1867 - if (netdev->mtu > enic->port_mtu) 1867 + if (new_mtu > enic->port_mtu) 1868 1868 netdev_warn(netdev, 1869 1869 "interface MTU (%d) set higher than port MTU (%d)\n", 1870 - netdev->mtu, enic->port_mtu); 1870 + new_mtu, enic->port_mtu); 1871 1871 1872 1872 return _enic_change_mtu(netdev, new_mtu); 1873 1873 }
+24 -2
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
··· 3939 3939 MEM_TYPE_PAGE_ORDER0, NULL); 3940 3940 if (err) { 3941 3941 dev_err(dev, "xdp_rxq_info_reg_mem_model failed\n"); 3942 + xdp_rxq_info_unreg(&fq->channel->xdp_rxq); 3942 3943 return err; 3943 3944 } 3944 3945 ··· 4433 4432 return -EINVAL; 4434 4433 } 4435 4434 if (err) 4436 - return err; 4435 + goto out; 4437 4436 } 4438 4437 4439 4438 err = dpni_get_qdid(priv->mc_io, 0, priv->mc_token, 4440 4439 DPNI_QUEUE_TX, &priv->tx_qdid); 4441 4440 if (err) { 4442 4441 dev_err(dev, "dpni_get_qdid() failed\n"); 4443 - return err; 4442 + goto out; 4444 4443 } 4445 4444 4446 4445 return 0; 4446 + 4447 + out: 4448 + while (i--) { 4449 + if (priv->fq[i].type == DPAA2_RX_FQ && 4450 + xdp_rxq_info_is_reg(&priv->fq[i].channel->xdp_rxq)) 4451 + xdp_rxq_info_unreg(&priv->fq[i].channel->xdp_rxq); 4452 + } 4453 + return err; 4447 4454 } 4448 4455 4449 4456 /* Allocate rings for storing incoming frame descriptors */ ··· 4834 4825 } 4835 4826 } 4836 4827 4828 + static void dpaa2_eth_free_rx_xdp_rxq(struct dpaa2_eth_priv *priv) 4829 + { 4830 + int i; 4831 + 4832 + for (i = 0; i < priv->num_fqs; i++) { 4833 + if (priv->fq[i].type == DPAA2_RX_FQ && 4834 + xdp_rxq_info_is_reg(&priv->fq[i].channel->xdp_rxq)) 4835 + xdp_rxq_info_unreg(&priv->fq[i].channel->xdp_rxq); 4836 + } 4837 + } 4838 + 4837 4839 static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) 4838 4840 { 4839 4841 struct device *dev; ··· 5048 5028 free_percpu(priv->percpu_stats); 5049 5029 err_alloc_percpu_stats: 5050 5030 dpaa2_eth_del_ch_napi(priv); 5031 + dpaa2_eth_free_rx_xdp_rxq(priv); 5051 5032 err_bind: 5052 5033 dpaa2_eth_free_dpbps(priv); 5053 5034 err_dpbp_setup: ··· 5101 5080 free_percpu(priv->percpu_extras); 5102 5081 5103 5082 dpaa2_eth_del_ch_napi(priv); 5083 + dpaa2_eth_free_rx_xdp_rxq(priv); 5104 5084 dpaa2_eth_free_dpbps(priv); 5105 5085 dpaa2_eth_free_dpio(priv); 5106 5086 dpaa2_eth_free_dpni(priv);
+11 -12
drivers/net/ethernet/intel/idpf/idpf_controlq.c
··· 96 96 */ 97 97 static void idpf_ctlq_shutdown(struct idpf_hw *hw, struct idpf_ctlq_info *cq) 98 98 { 99 - mutex_lock(&cq->cq_lock); 99 + spin_lock(&cq->cq_lock); 100 100 101 101 /* free ring buffers and the ring itself */ 102 102 idpf_ctlq_dealloc_ring_res(hw, cq); ··· 104 104 /* Set ring_size to 0 to indicate uninitialized queue */ 105 105 cq->ring_size = 0; 106 106 107 - mutex_unlock(&cq->cq_lock); 108 - mutex_destroy(&cq->cq_lock); 107 + spin_unlock(&cq->cq_lock); 109 108 } 110 109 111 110 /** ··· 172 173 173 174 idpf_ctlq_init_regs(hw, cq, is_rxq); 174 175 175 - mutex_init(&cq->cq_lock); 176 + spin_lock_init(&cq->cq_lock); 176 177 177 178 list_add(&cq->cq_list, &hw->cq_list_head); 178 179 ··· 271 272 int err = 0; 272 273 int i; 273 274 274 - mutex_lock(&cq->cq_lock); 275 + spin_lock(&cq->cq_lock); 275 276 276 277 /* Ensure there are enough descriptors to send all messages */ 277 278 num_desc_avail = IDPF_CTLQ_DESC_UNUSED(cq); ··· 331 332 wr32(hw, cq->reg.tail, cq->next_to_use); 332 333 333 334 err_unlock: 334 - mutex_unlock(&cq->cq_lock); 335 + spin_unlock(&cq->cq_lock); 335 336 336 337 return err; 337 338 } ··· 363 364 if (*clean_count > cq->ring_size) 364 365 return -EBADR; 365 366 366 - mutex_lock(&cq->cq_lock); 367 + spin_lock(&cq->cq_lock); 367 368 368 369 ntc = cq->next_to_clean; 369 370 ··· 396 397 397 398 cq->next_to_clean = ntc; 398 399 399 - mutex_unlock(&cq->cq_lock); 400 + spin_unlock(&cq->cq_lock); 400 401 401 402 /* Return number of descriptors actually cleaned */ 402 403 *clean_count = i; ··· 434 435 if (*buff_count > 0) 435 436 buffs_avail = true; 436 437 437 - mutex_lock(&cq->cq_lock); 438 + spin_lock(&cq->cq_lock); 438 439 439 440 if (tbp >= cq->ring_size) 440 441 tbp = 0; ··· 523 524 wr32(hw, cq->reg.tail, cq->next_to_post); 524 525 } 525 526 526 - mutex_unlock(&cq->cq_lock); 527 + spin_unlock(&cq->cq_lock); 527 528 528 529 /* return the number of buffers that were not posted */ 529 530 *buff_count = *buff_count - i; ··· 551 552 u16 i; 552 553 553 554 /* take the lock before we start messing with the ring */ 554 - mutex_lock(&cq->cq_lock); 555 + spin_lock(&cq->cq_lock); 555 556 556 557 ntc = cq->next_to_clean; 557 558 ··· 613 614 614 615 cq->next_to_clean = ntc; 615 616 616 - mutex_unlock(&cq->cq_lock); 617 + spin_unlock(&cq->cq_lock); 617 618 618 619 *num_q_msg = i; 619 620 if (*num_q_msg == 0)
+1 -1
drivers/net/ethernet/intel/idpf/idpf_controlq_api.h
··· 99 99 100 100 enum idpf_ctlq_type cq_type; 101 101 int q_id; 102 - struct mutex cq_lock; /* control queue lock */ 102 + spinlock_t cq_lock; /* control queue lock */ 103 103 /* used for interrupt processing */ 104 104 u16 next_to_use; 105 105 u16 next_to_clean;
+2 -2
drivers/net/ethernet/intel/idpf/idpf_ethtool.c
··· 47 47 struct idpf_vport_user_config_data *user_config; 48 48 49 49 if (!idpf_is_cap_ena_all(np->adapter, IDPF_RSS_CAPS, IDPF_CAP_RSS)) 50 - return -EOPNOTSUPP; 50 + return 0; 51 51 52 52 user_config = &np->adapter->vport_config[np->vport_idx]->user_config; 53 53 ··· 66 66 struct idpf_vport_user_config_data *user_config; 67 67 68 68 if (!idpf_is_cap_ena_all(np->adapter, IDPF_RSS_CAPS, IDPF_CAP_RSS)) 69 - return -EOPNOTSUPP; 69 + return 0; 70 70 71 71 user_config = &np->adapter->vport_config[np->vport_idx]->user_config; 72 72
+8 -4
drivers/net/ethernet/intel/idpf/idpf_lib.c
··· 2314 2314 struct idpf_adapter *adapter = hw->back; 2315 2315 size_t sz = ALIGN(size, 4096); 2316 2316 2317 - mem->va = dma_alloc_coherent(&adapter->pdev->dev, sz, 2318 - &mem->pa, GFP_KERNEL); 2317 + /* The control queue resources are freed under a spinlock, contiguous 2318 + * pages will avoid IOMMU remapping and the use vmap (and vunmap in 2319 + * dma_free_*() path. 2320 + */ 2321 + mem->va = dma_alloc_attrs(&adapter->pdev->dev, sz, &mem->pa, 2322 + GFP_KERNEL, DMA_ATTR_FORCE_CONTIGUOUS); 2319 2323 mem->size = sz; 2320 2324 2321 2325 return mem->va; ··· 2334 2330 { 2335 2331 struct idpf_adapter *adapter = hw->back; 2336 2332 2337 - dma_free_coherent(&adapter->pdev->dev, mem->size, 2338 - mem->va, mem->pa); 2333 + dma_free_attrs(&adapter->pdev->dev, mem->size, 2334 + mem->va, mem->pa, DMA_ATTR_FORCE_CONTIGUOUS); 2339 2335 mem->size = 0; 2340 2336 mem->va = NULL; 2341 2337 mem->pa = 0;
+10
drivers/net/ethernet/intel/igc/igc_main.c
··· 7115 7115 adapter->port_num = hw->bus.func; 7116 7116 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); 7117 7117 7118 + /* Disable ASPM L1.2 on I226 devices to avoid packet loss */ 7119 + if (igc_is_device_id_i226(hw)) 7120 + pci_disable_link_state(pdev, PCIE_LINK_STATE_L1_2); 7121 + 7118 7122 err = pci_save_state(pdev); 7119 7123 if (err) 7120 7124 goto err_ioremap; ··· 7504 7500 pci_enable_wake(pdev, PCI_D3hot, 0); 7505 7501 pci_enable_wake(pdev, PCI_D3cold, 0); 7506 7502 7503 + if (igc_is_device_id_i226(hw)) 7504 + pci_disable_link_state(pdev, PCIE_LINK_STATE_L1_2); 7505 + 7507 7506 if (igc_init_interrupt_scheme(adapter, true)) { 7508 7507 netdev_err(netdev, "Unable to allocate memory for queues\n"); 7509 7508 return -ENOMEM; ··· 7631 7624 7632 7625 pci_enable_wake(pdev, PCI_D3hot, 0); 7633 7626 pci_enable_wake(pdev, PCI_D3cold, 0); 7627 + 7628 + if (igc_is_device_id_i226(hw)) 7629 + pci_disable_link_state_locked(pdev, PCIE_LINK_STATE_L1_2); 7634 7630 7635 7631 /* In case of PCI error, adapter loses its HW address 7636 7632 * so we should re-assign it here.
+30 -1
drivers/net/ethernet/sun/niu.c
··· 3336 3336 3337 3337 addr = np->ops->map_page(np->device, page, 0, 3338 3338 PAGE_SIZE, DMA_FROM_DEVICE); 3339 - if (!addr) { 3339 + if (np->ops->mapping_error(np->device, addr)) { 3340 3340 __free_page(page); 3341 3341 return -ENOMEM; 3342 3342 } ··· 6676 6676 len = skb_headlen(skb); 6677 6677 mapping = np->ops->map_single(np->device, skb->data, 6678 6678 len, DMA_TO_DEVICE); 6679 + if (np->ops->mapping_error(np->device, mapping)) 6680 + goto out_drop; 6679 6681 6680 6682 prod = rp->prod; 6681 6683 ··· 6719 6717 mapping = np->ops->map_page(np->device, skb_frag_page(frag), 6720 6718 skb_frag_off(frag), len, 6721 6719 DMA_TO_DEVICE); 6720 + if (np->ops->mapping_error(np->device, mapping)) 6721 + goto out_unmap; 6722 6722 6723 6723 rp->tx_buffs[prod].skb = NULL; 6724 6724 rp->tx_buffs[prod].mapping = mapping; ··· 6744 6740 6745 6741 out: 6746 6742 return NETDEV_TX_OK; 6743 + 6744 + out_unmap: 6745 + while (i--) { 6746 + const skb_frag_t *frag; 6747 + 6748 + prod = PREVIOUS_TX(rp, prod); 6749 + frag = &skb_shinfo(skb)->frags[i]; 6750 + np->ops->unmap_page(np->device, rp->tx_buffs[prod].mapping, 6751 + skb_frag_size(frag), DMA_TO_DEVICE); 6752 + } 6753 + 6754 + np->ops->unmap_single(np->device, rp->tx_buffs[rp->prod].mapping, 6755 + skb_headlen(skb), DMA_TO_DEVICE); 6747 6756 6748 6757 out_drop: 6749 6758 rp->tx_errors++; ··· 9661 9644 dma_unmap_single(dev, dma_address, size, direction); 9662 9645 } 9663 9646 9647 + static int niu_pci_mapping_error(struct device *dev, u64 addr) 9648 + { 9649 + return dma_mapping_error(dev, addr); 9650 + } 9651 + 9664 9652 static const struct niu_ops niu_pci_ops = { 9665 9653 .alloc_coherent = niu_pci_alloc_coherent, 9666 9654 .free_coherent = niu_pci_free_coherent, ··· 9673 9651 .unmap_page = niu_pci_unmap_page, 9674 9652 .map_single = niu_pci_map_single, 9675 9653 .unmap_single = niu_pci_unmap_single, 9654 + .mapping_error = niu_pci_mapping_error, 9676 9655 }; 9677 9656 9678 9657 static void niu_driver_version(void) ··· 10042 10019 /* Nothing to do. */ 10043 10020 } 10044 10021 10022 + static int niu_phys_mapping_error(struct device *dev, u64 dma_address) 10023 + { 10024 + return false; 10025 + } 10026 + 10045 10027 static const struct niu_ops niu_phys_ops = { 10046 10028 .alloc_coherent = niu_phys_alloc_coherent, 10047 10029 .free_coherent = niu_phys_free_coherent, ··· 10054 10026 .unmap_page = niu_phys_unmap_page, 10055 10027 .map_single = niu_phys_map_single, 10056 10028 .unmap_single = niu_phys_unmap_single, 10029 + .mapping_error = niu_phys_mapping_error, 10057 10030 }; 10058 10031 10059 10032 static int niu_of_probe(struct platform_device *op)
+4
drivers/net/ethernet/sun/niu.h
··· 2879 2879 #define NEXT_TX(tp, index) \ 2880 2880 (((index) + 1) < (tp)->pending ? ((index) + 1) : 0) 2881 2881 2882 + #define PREVIOUS_TX(tp, index) \ 2883 + (((index) - 1) >= 0 ? ((index) - 1) : (((tp)->pending) - 1)) 2884 + 2882 2885 static inline u32 niu_tx_avail(struct tx_ring_info *tp) 2883 2886 { 2884 2887 return (tp->pending - ··· 3143 3140 enum dma_data_direction direction); 3144 3141 void (*unmap_single)(struct device *dev, u64 dma_address, 3145 3142 size_t size, enum dma_data_direction direction); 3143 + int (*mapping_error)(struct device *dev, u64 dma_address); 3146 3144 }; 3147 3145 3148 3146 struct niu_link_config {
+18 -9
drivers/net/ethernet/wangxun/libwx/wx_lib.c
··· 1705 1705 1706 1706 clear_bit(WX_FLAG_FDIR_HASH, wx->flags); 1707 1707 1708 + wx->ring_feature[RING_F_FDIR].indices = 1; 1708 1709 /* Use Flow Director in addition to RSS to ensure the best 1709 1710 * distribution of flows across cores, even when an FDIR flow 1710 1711 * isn't matched. ··· 1747 1746 */ 1748 1747 static int wx_acquire_msix_vectors(struct wx *wx) 1749 1748 { 1750 - struct irq_affinity affd = { .pre_vectors = 1 }; 1749 + struct irq_affinity affd = { .post_vectors = 1 }; 1751 1750 int nvecs, i; 1752 1751 1753 1752 /* We start by asking for one vector per queue pair */ ··· 1784 1783 return nvecs; 1785 1784 } 1786 1785 1787 - wx->msix_entry->entry = 0; 1788 - wx->msix_entry->vector = pci_irq_vector(wx->pdev, 0); 1789 1786 nvecs -= 1; 1790 1787 for (i = 0; i < nvecs; i++) { 1791 1788 wx->msix_q_entries[i].entry = i; 1792 - wx->msix_q_entries[i].vector = pci_irq_vector(wx->pdev, i + 1); 1789 + wx->msix_q_entries[i].vector = pci_irq_vector(wx->pdev, i); 1793 1790 } 1794 1791 1795 1792 wx->num_q_vectors = nvecs; 1793 + 1794 + wx->msix_entry->entry = nvecs; 1795 + wx->msix_entry->vector = pci_irq_vector(wx->pdev, nvecs); 1796 + 1797 + if (test_bit(WX_FLAG_IRQ_VECTOR_SHARED, wx->flags)) { 1798 + wx->msix_entry->entry = 0; 1799 + wx->msix_entry->vector = pci_irq_vector(wx->pdev, 0); 1800 + wx->msix_q_entries[0].entry = 0; 1801 + wx->msix_q_entries[0].vector = pci_irq_vector(wx->pdev, 1); 1802 + } 1796 1803 1797 1804 return 0; 1798 1805 } ··· 2300 2291 2301 2292 if (direction == -1) { 2302 2293 /* other causes */ 2294 + if (test_bit(WX_FLAG_IRQ_VECTOR_SHARED, wx->flags)) 2295 + msix_vector = 0; 2303 2296 msix_vector |= WX_PX_IVAR_ALLOC_VAL; 2304 2297 index = 0; 2305 2298 ivar = rd32(wx, WX_PX_MISC_IVAR); ··· 2310 2299 wr32(wx, WX_PX_MISC_IVAR, ivar); 2311 2300 } else { 2312 2301 /* tx or rx causes */ 2313 - if (!(wx->mac.type == wx_mac_em && wx->num_vfs == 7)) 2314 - msix_vector += 1; /* offset for queue vectors */ 2315 2302 msix_vector |= WX_PX_IVAR_ALLOC_VAL; 2316 2303 index = ((16 * (queue & 1)) + (8 * direction)); 2317 2304 ivar = rd32(wx, WX_PX_IVAR(queue >> 1)); ··· 2348 2339 2349 2340 itr_reg |= WX_PX_ITR_CNT_WDIS; 2350 2341 2351 - wr32(wx, WX_PX_ITR(v_idx + 1), itr_reg); 2342 + wr32(wx, WX_PX_ITR(v_idx), itr_reg); 2352 2343 } 2353 2344 2354 2345 /** ··· 2401 2392 wx_write_eitr(q_vector); 2402 2393 } 2403 2394 2404 - wx_set_ivar(wx, -1, 0, 0); 2395 + wx_set_ivar(wx, -1, 0, v_idx); 2405 2396 if (pdev->msix_enabled) 2406 - wr32(wx, WX_PX_ITR(0), 1950); 2397 + wr32(wx, WX_PX_ITR(v_idx), 1950); 2407 2398 } 2408 2399 EXPORT_SYMBOL(wx_configure_vectors); 2409 2400
+4
drivers/net/ethernet/wangxun/libwx/wx_sriov.c
··· 64 64 wr32m(wx, WX_PSR_VM_CTL, WX_PSR_VM_CTL_POOL_MASK, 0); 65 65 wx->ring_feature[RING_F_VMDQ].offset = 0; 66 66 67 + clear_bit(WX_FLAG_IRQ_VECTOR_SHARED, wx->flags); 67 68 clear_bit(WX_FLAG_SRIOV_ENABLED, wx->flags); 68 69 /* Disable VMDq flag so device will be set in NM mode */ 69 70 if (wx->ring_feature[RING_F_VMDQ].limit == 1) ··· 78 77 79 78 set_bit(WX_FLAG_SRIOV_ENABLED, wx->flags); 80 79 dev_info(&wx->pdev->dev, "SR-IOV enabled with %d VFs\n", num_vfs); 80 + 81 + if (num_vfs == 7 && wx->mac.type == wx_mac_em) 82 + set_bit(WX_FLAG_IRQ_VECTOR_SHARED, wx->flags); 81 83 82 84 /* Enable VMDq flag so device will be set in VM mode */ 83 85 set_bit(WX_FLAG_VMDQ_ENABLED, wx->flags);
+2 -1
drivers/net/ethernet/wangxun/libwx/wx_type.h
··· 1191 1191 WX_FLAG_VMDQ_ENABLED, 1192 1192 WX_FLAG_VLAN_PROMISC, 1193 1193 WX_FLAG_SRIOV_ENABLED, 1194 + WX_FLAG_IRQ_VECTOR_SHARED, 1194 1195 WX_FLAG_FDIR_CAPABLE, 1195 1196 WX_FLAG_FDIR_HASH, 1196 1197 WX_FLAG_FDIR_PERFECT, ··· 1344 1343 }; 1345 1344 1346 1345 #define WX_INTR_ALL (~0ULL) 1347 - #define WX_INTR_Q(i) BIT((i) + 1) 1346 + #define WX_INTR_Q(i) BIT((i)) 1348 1347 1349 1348 /* register operations */ 1350 1349 #define wr32(a, reg, value) writel((value), ((a)->hw_addr + (reg)))
+2 -2
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
··· 161 161 if (queues) 162 162 wx_intr_enable(wx, NGBE_INTR_ALL); 163 163 else 164 - wx_intr_enable(wx, NGBE_INTR_MISC); 164 + wx_intr_enable(wx, NGBE_INTR_MISC(wx)); 165 165 } 166 166 167 167 /** ··· 286 286 * for queue. But when num_vfs == 7, vector[1] is assigned to vf6. 287 287 * Misc and queue should reuse interrupt vector[0]. 288 288 */ 289 - if (wx->num_vfs == 7) 289 + if (test_bit(WX_FLAG_IRQ_VECTOR_SHARED, wx->flags)) 290 290 err = request_irq(wx->msix_entry->vector, 291 291 ngbe_misc_and_queue, 0, netdev->name, wx); 292 292 else
+1 -1
drivers/net/ethernet/wangxun/ngbe/ngbe_type.h
··· 87 87 #define NGBE_PX_MISC_IC_TIMESYNC BIT(11) /* time sync */ 88 88 89 89 #define NGBE_INTR_ALL 0x1FF 90 - #define NGBE_INTR_MISC BIT(0) 90 + #define NGBE_INTR_MISC(A) BIT((A)->msix_entry->entry) 91 91 92 92 #define NGBE_PHY_CONFIG(reg_offset) (0x14000 + ((reg_offset) * 4)) 93 93 #define NGBE_CFG_LAN_SPEED 0x14440
+1
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
··· 294 294 wx_fc_enable(wx, tx_pause, rx_pause); 295 295 296 296 txgbe_reconfig_mac(wx); 297 + txgbe_enable_sec_tx_path(wx); 297 298 298 299 txcfg = rd32(wx, TXGBE_AML_MAC_TX_CFG); 299 300 txcfg &= ~TXGBE_AML_MAC_TX_CFG_SPEED_MASK;
+4 -4
drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c
··· 31 31 wr32(wx, WX_PX_MISC_IEN, misc_ien); 32 32 33 33 /* unmask interrupt */ 34 - wx_intr_enable(wx, TXGBE_INTR_MISC); 34 + wx_intr_enable(wx, TXGBE_INTR_MISC(wx)); 35 35 if (queues) 36 36 wx_intr_enable(wx, TXGBE_INTR_QALL(wx)); 37 37 } ··· 78 78 free_irq(wx->msix_q_entries[vector].vector, 79 79 wx->q_vector[vector]); 80 80 } 81 - wx_reset_interrupt_capability(wx); 82 81 return err; 83 82 } 84 83 ··· 131 132 txgbe->eicr = eicr; 132 133 if (eicr & TXGBE_PX_MISC_IC_VF_MBOX) { 133 134 wx_msg_task(txgbe->wx); 134 - wx_intr_enable(wx, TXGBE_INTR_MISC); 135 + wx_intr_enable(wx, TXGBE_INTR_MISC(wx)); 135 136 } 136 137 return IRQ_WAKE_THREAD; 137 138 } ··· 183 184 nhandled++; 184 185 } 185 186 186 - wx_intr_enable(wx, TXGBE_INTR_MISC); 187 + wx_intr_enable(wx, TXGBE_INTR_MISC(wx)); 187 188 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); 188 189 } 189 190 ··· 210 211 free_irq(txgbe->link_irq, txgbe); 211 212 free_irq(txgbe->misc.irq, txgbe); 212 213 txgbe_del_irq_domain(txgbe); 214 + txgbe->wx->misc_irq_domain = false; 213 215 } 214 216 215 217 int txgbe_setup_misc_irq(struct txgbe *txgbe)
+10 -12
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
··· 458 458 459 459 wx_configure(wx); 460 460 461 - err = txgbe_request_queue_irqs(wx); 461 + err = txgbe_setup_misc_irq(wx->priv); 462 462 if (err) 463 463 goto err_free_resources; 464 + 465 + err = txgbe_request_queue_irqs(wx); 466 + if (err) 467 + goto err_free_misc_irq; 464 468 465 469 /* Notify the stack of the actual queue counts. */ 466 470 err = netif_set_real_num_tx_queues(netdev, wx->num_tx_queues); ··· 483 479 484 480 err_free_irq: 485 481 wx_free_irq(wx); 482 + err_free_misc_irq: 483 + txgbe_free_misc_irq(wx->priv); 484 + wx_reset_interrupt_capability(wx); 486 485 err_free_resources: 487 486 wx_free_resources(wx); 488 487 err_reset: ··· 526 519 wx_ptp_stop(wx); 527 520 txgbe_down(wx); 528 521 wx_free_irq(wx); 522 + txgbe_free_misc_irq(wx->priv); 529 523 wx_free_resources(wx); 530 524 txgbe_fdir_filter_exit(wx); 531 525 wx_control_hw(wx, false); ··· 572 564 int txgbe_setup_tc(struct net_device *dev, u8 tc) 573 565 { 574 566 struct wx *wx = netdev_priv(dev); 575 - struct txgbe *txgbe = wx->priv; 576 567 577 568 /* Hardware has to reinitialize queues and interrupts to 578 569 * match packet buffer alignment. Unfortunately, the ··· 582 575 else 583 576 txgbe_reset(wx); 584 577 585 - txgbe_free_misc_irq(txgbe); 586 578 wx_clear_interrupt_scheme(wx); 587 579 588 580 if (tc) ··· 590 584 netdev_reset_tc(dev); 591 585 592 586 wx_init_interrupt_scheme(wx); 593 - txgbe_setup_misc_irq(txgbe); 594 587 595 588 if (netif_running(dev)) 596 589 txgbe_open(dev); ··· 887 882 888 883 txgbe_init_fdir(txgbe); 889 884 890 - err = txgbe_setup_misc_irq(txgbe); 891 - if (err) 892 - goto err_release_hw; 893 - 894 885 err = txgbe_init_phy(txgbe); 895 886 if (err) 896 - goto err_free_misc_irq; 887 + goto err_release_hw; 897 888 898 889 err = register_netdev(netdev); 899 890 if (err) ··· 917 916 918 917 err_remove_phy: 919 918 txgbe_remove_phy(txgbe); 920 - err_free_misc_irq: 921 - txgbe_free_misc_irq(txgbe); 922 919 err_release_hw: 923 920 wx_clear_interrupt_scheme(wx); 924 921 wx_control_hw(wx, false); ··· 956 957 unregister_netdev(netdev); 957 958 958 959 txgbe_remove_phy(txgbe); 959 - txgbe_free_misc_irq(txgbe); 960 960 wx_free_isb_resources(wx); 961 961 962 962 pci_release_selected_regions(pdev,
+2 -2
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
··· 302 302 #define TXGBE_DEFAULT_RX_WORK 128 303 303 #endif 304 304 305 - #define TXGBE_INTR_MISC BIT(0) 306 - #define TXGBE_INTR_QALL(A) GENMASK((A)->num_q_vectors, 1) 305 + #define TXGBE_INTR_MISC(A) BIT((A)->num_q_vectors) 306 + #define TXGBE_INTR_QALL(A) (TXGBE_INTR_MISC(A) - 1) 307 307 308 308 #define TXGBE_MAX_EITR GENMASK(11, 3) 309 309
-2
drivers/net/usb/lan78xx.c
··· 4567 4567 if (!dev) 4568 4568 return; 4569 4569 4570 - netif_napi_del(&dev->napi); 4571 - 4572 4570 udev = interface_to_usbdev(intf); 4573 4571 net = dev->net; 4574 4572
+70 -41
drivers/net/virtio_net.c
··· 778 778 return (unsigned long)mrg_ctx & ((1 << MRG_CTX_HEADER_SHIFT) - 1); 779 779 } 780 780 781 + static int check_mergeable_len(struct net_device *dev, void *mrg_ctx, 782 + unsigned int len) 783 + { 784 + unsigned int headroom, tailroom, room, truesize; 785 + 786 + truesize = mergeable_ctx_to_truesize(mrg_ctx); 787 + headroom = mergeable_ctx_to_headroom(mrg_ctx); 788 + tailroom = headroom ? sizeof(struct skb_shared_info) : 0; 789 + room = SKB_DATA_ALIGN(headroom + tailroom); 790 + 791 + if (len > truesize - room) { 792 + pr_debug("%s: rx error: len %u exceeds truesize %lu\n", 793 + dev->name, len, (unsigned long)(truesize - room)); 794 + DEV_STATS_INC(dev, rx_length_errors); 795 + return -1; 796 + } 797 + 798 + return 0; 799 + } 800 + 781 801 static struct sk_buff *virtnet_build_skb(void *buf, unsigned int buflen, 782 802 unsigned int headroom, 783 803 unsigned int len) ··· 1104 1084 * Since most packets only take 1 or 2 ring slots, stopping the queue 1105 1085 * early means 16 slots are typically wasted. 1106 1086 */ 1107 - if (sq->vq->num_free < 2+MAX_SKB_FRAGS) { 1087 + if (sq->vq->num_free < MAX_SKB_FRAGS + 2) { 1108 1088 struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum); 1109 1089 1110 1090 netif_tx_stop_queue(txq); ··· 1136 1116 } else if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) { 1137 1117 /* More just got used, free them then recheck. */ 1138 1118 free_old_xmit(sq, txq, false); 1139 - if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) { 1119 + if (sq->vq->num_free >= MAX_SKB_FRAGS + 2) { 1140 1120 netif_start_subqueue(dev, qnum); 1141 1121 u64_stats_update_begin(&sq->stats.syncp); 1142 1122 u64_stats_inc(&sq->stats.wake); ··· 1147 1127 } 1148 1128 } 1149 1129 1130 + /* Note that @len is the length of received data without virtio header */ 1150 1131 static struct xdp_buff *buf_to_xdp(struct virtnet_info *vi, 1151 - struct receive_queue *rq, void *buf, u32 len) 1132 + struct receive_queue *rq, void *buf, 1133 + u32 len, bool first_buf) 1152 1134 { 1153 1135 struct xdp_buff *xdp; 1154 1136 u32 bufsize; 1155 1137 1156 1138 xdp = (struct xdp_buff *)buf; 1157 1139 1158 - bufsize = xsk_pool_get_rx_frame_size(rq->xsk_pool) + vi->hdr_len; 1140 + /* In virtnet_add_recvbuf_xsk, we use part of XDP_PACKET_HEADROOM for 1141 + * virtio header and ask the vhost to fill data from 1142 + * hard_start + XDP_PACKET_HEADROOM - vi->hdr_len 1143 + * The first buffer has virtio header so the remaining region for frame 1144 + * data is 1145 + * xsk_pool_get_rx_frame_size() 1146 + * While other buffers than the first one do not have virtio header, so 1147 + * the maximum frame data's length can be 1148 + * xsk_pool_get_rx_frame_size() + vi->hdr_len 1149 + */ 1150 + bufsize = xsk_pool_get_rx_frame_size(rq->xsk_pool); 1151 + if (!first_buf) 1152 + bufsize += vi->hdr_len; 1159 1153 1160 1154 if (unlikely(len > bufsize)) { 1161 1155 pr_debug("%s: rx error: len %u exceeds truesize %u\n", ··· 1294 1260 1295 1261 u64_stats_add(&stats->bytes, len); 1296 1262 1297 - xdp = buf_to_xdp(vi, rq, buf, len); 1263 + xdp = buf_to_xdp(vi, rq, buf, len, false); 1298 1264 if (!xdp) 1299 1265 goto err; 1300 1266 ··· 1392 1358 1393 1359 u64_stats_add(&stats->bytes, len); 1394 1360 1395 - xdp = buf_to_xdp(vi, rq, buf, len); 1361 + xdp = buf_to_xdp(vi, rq, buf, len, true); 1396 1362 if (!xdp) 1397 1363 return; 1398 1364 ··· 1831 1797 * across multiple buffers (num_buf > 1), and we make sure buffers 1832 1798 * have enough headroom. 1833 1799 */ 1834 - static struct page *xdp_linearize_page(struct receive_queue *rq, 1800 + static struct page *xdp_linearize_page(struct net_device *dev, 1801 + struct receive_queue *rq, 1835 1802 int *num_buf, 1836 1803 struct page *p, 1837 1804 int offset, ··· 1852 1817 memcpy(page_address(page) + page_off, page_address(p) + offset, *len); 1853 1818 page_off += *len; 1854 1819 1820 + /* Only mergeable mode can go inside this while loop. In small mode, 1821 + * *num_buf == 1, so it cannot go inside. 1822 + */ 1855 1823 while (--*num_buf) { 1856 1824 unsigned int buflen; 1857 1825 void *buf; 1826 + void *ctx; 1858 1827 int off; 1859 1828 1860 - buf = virtnet_rq_get_buf(rq, &buflen, NULL); 1829 + buf = virtnet_rq_get_buf(rq, &buflen, &ctx); 1861 1830 if (unlikely(!buf)) 1862 1831 goto err_buf; 1863 1832 1864 1833 p = virt_to_head_page(buf); 1865 1834 off = buf - page_address(p); 1835 + 1836 + if (check_mergeable_len(dev, ctx, buflen)) { 1837 + put_page(p); 1838 + goto err_buf; 1839 + } 1866 1840 1867 1841 /* guard against a misconfigured or uncooperative backend that 1868 1842 * is sending packet larger than the MTU. ··· 1961 1917 headroom = vi->hdr_len + header_offset; 1962 1918 buflen = SKB_DATA_ALIGN(GOOD_PACKET_LEN + headroom) + 1963 1919 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); 1964 - xdp_page = xdp_linearize_page(rq, &num_buf, page, 1920 + xdp_page = xdp_linearize_page(dev, rq, &num_buf, page, 1965 1921 offset, header_offset, 1966 1922 &tlen); 1967 1923 if (!xdp_page) ··· 2170 2126 struct virtnet_rq_stats *stats) 2171 2127 { 2172 2128 struct virtio_net_hdr_mrg_rxbuf *hdr = buf; 2173 - unsigned int headroom, tailroom, room; 2174 - unsigned int truesize, cur_frag_size; 2175 2129 struct skb_shared_info *shinfo; 2176 2130 unsigned int xdp_frags_truesz = 0; 2131 + unsigned int truesize; 2177 2132 struct page *page; 2178 2133 skb_frag_t *frag; 2179 2134 int offset; ··· 2215 2172 page = virt_to_head_page(buf); 2216 2173 offset = buf - page_address(page); 2217 2174 2218 - truesize = mergeable_ctx_to_truesize(ctx); 2219 - headroom = mergeable_ctx_to_headroom(ctx); 2220 - tailroom = headroom ? sizeof(struct skb_shared_info) : 0; 2221 - room = SKB_DATA_ALIGN(headroom + tailroom); 2222 - 2223 - cur_frag_size = truesize; 2224 - xdp_frags_truesz += cur_frag_size; 2225 - if (unlikely(len > truesize - room || cur_frag_size > PAGE_SIZE)) { 2175 + if (check_mergeable_len(dev, ctx, len)) { 2226 2176 put_page(page); 2227 - pr_debug("%s: rx error: len %u exceeds truesize %lu\n", 2228 - dev->name, len, (unsigned long)(truesize - room)); 2229 - DEV_STATS_INC(dev, rx_length_errors); 2230 2177 goto err; 2231 2178 } 2179 + 2180 + truesize = mergeable_ctx_to_truesize(ctx); 2181 + xdp_frags_truesz += truesize; 2232 2182 2233 2183 frag = &shinfo->frags[shinfo->nr_frags++]; 2234 2184 skb_frag_fill_page_desc(frag, page, offset, len); ··· 2288 2252 */ 2289 2253 if (!xdp_prog->aux->xdp_has_frags) { 2290 2254 /* linearize data for XDP */ 2291 - xdp_page = xdp_linearize_page(rq, num_buf, 2255 + xdp_page = xdp_linearize_page(vi->dev, rq, num_buf, 2292 2256 *page, offset, 2293 2257 XDP_PACKET_HEADROOM, 2294 2258 len); ··· 2436 2400 struct sk_buff *head_skb, *curr_skb; 2437 2401 unsigned int truesize = mergeable_ctx_to_truesize(ctx); 2438 2402 unsigned int headroom = mergeable_ctx_to_headroom(ctx); 2439 - unsigned int tailroom = headroom ? sizeof(struct skb_shared_info) : 0; 2440 - unsigned int room = SKB_DATA_ALIGN(headroom + tailroom); 2441 2403 2442 2404 head_skb = NULL; 2443 2405 u64_stats_add(&stats->bytes, len - vi->hdr_len); 2444 2406 2445 - if (unlikely(len > truesize - room)) { 2446 - pr_debug("%s: rx error: len %u exceeds truesize %lu\n", 2447 - dev->name, len, (unsigned long)(truesize - room)); 2448 - DEV_STATS_INC(dev, rx_length_errors); 2407 + if (check_mergeable_len(dev, ctx, len)) 2449 2408 goto err_skb; 2450 - } 2451 2409 2452 2410 if (unlikely(vi->xdp_enabled)) { 2453 2411 struct bpf_prog *xdp_prog; ··· 2476 2446 u64_stats_add(&stats->bytes, len); 2477 2447 page = virt_to_head_page(buf); 2478 2448 2479 - truesize = mergeable_ctx_to_truesize(ctx); 2480 - headroom = mergeable_ctx_to_headroom(ctx); 2481 - tailroom = headroom ? sizeof(struct skb_shared_info) : 0; 2482 - room = SKB_DATA_ALIGN(headroom + tailroom); 2483 - if (unlikely(len > truesize - room)) { 2484 - pr_debug("%s: rx error: len %u exceeds truesize %lu\n", 2485 - dev->name, len, (unsigned long)(truesize - room)); 2486 - DEV_STATS_INC(dev, rx_length_errors); 2449 + if (check_mergeable_len(dev, ctx, len)) 2487 2450 goto err_skb; 2488 - } 2489 2451 2452 + truesize = mergeable_ctx_to_truesize(ctx); 2490 2453 curr_skb = virtnet_skb_append_frag(head_skb, curr_skb, page, 2491 2454 buf, len, truesize); 2492 2455 if (!curr_skb) ··· 3021 2998 free_old_xmit(sq, txq, !!budget); 3022 2999 } while (unlikely(!virtqueue_enable_cb_delayed(sq->vq))); 3023 3000 3024 - if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS) { 3001 + if (sq->vq->num_free >= MAX_SKB_FRAGS + 2) { 3025 3002 if (netif_tx_queue_stopped(txq)) { 3026 3003 u64_stats_update_begin(&sq->stats.syncp); 3027 3004 u64_stats_inc(&sq->stats.wake); ··· 3218 3195 else 3219 3196 free_old_xmit(sq, txq, !!budget); 3220 3197 3221 - if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS) { 3198 + if (sq->vq->num_free >= MAX_SKB_FRAGS + 2) { 3222 3199 if (netif_tx_queue_stopped(txq)) { 3223 3200 u64_stats_update_begin(&sq->stats.syncp); 3224 3201 u64_stats_inc(&sq->stats.wake); ··· 3503 3480 u32 ring_num) 3504 3481 { 3505 3482 int qindex, err; 3483 + 3484 + if (ring_num <= MAX_SKB_FRAGS + 2) { 3485 + netdev_err(vi->dev, "tx size (%d) cannot be smaller than %d\n", 3486 + ring_num, MAX_SKB_FRAGS + 2); 3487 + return -EINVAL; 3488 + } 3506 3489 3507 3490 qindex = sq - vi->sq; 3508 3491
+6 -2
drivers/virtio/virtio_ring.c
··· 2797 2797 void (*recycle_done)(struct virtqueue *vq)) 2798 2798 { 2799 2799 struct vring_virtqueue *vq = to_vvq(_vq); 2800 - int err; 2800 + int err, err_reset; 2801 2801 2802 2802 if (num > vq->vq.num_max) 2803 2803 return -E2BIG; ··· 2819 2819 else 2820 2820 err = virtqueue_resize_split(_vq, num); 2821 2821 2822 - return virtqueue_enable_after_reset(_vq); 2822 + err_reset = virtqueue_enable_after_reset(_vq); 2823 + if (err_reset) 2824 + return err_reset; 2825 + 2826 + return err; 2823 2827 } 2824 2828 EXPORT_SYMBOL_GPL(virtqueue_resize); 2825 2829
+3 -1
lib/test_objagg.c
··· 899 899 int err; 900 900 901 901 stats = objagg_hints_stats_get(objagg_hints); 902 - if (IS_ERR(stats)) 902 + if (IS_ERR(stats)) { 903 + *errmsg = "objagg_hints_stats_get() failed."; 903 904 return PTR_ERR(stats); 905 + } 904 906 err = __check_expect_stats(stats, expect_stats, errmsg); 905 907 objagg_stats_put(stats); 906 908 return err;
-36
net/bluetooth/hci_event.c
··· 2150 2150 return rp->status; 2151 2151 } 2152 2152 2153 - static u8 hci_cc_set_ext_adv_param(struct hci_dev *hdev, void *data, 2154 - struct sk_buff *skb) 2155 - { 2156 - struct hci_rp_le_set_ext_adv_params *rp = data; 2157 - struct hci_cp_le_set_ext_adv_params *cp; 2158 - struct adv_info *adv_instance; 2159 - 2160 - bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); 2161 - 2162 - if (rp->status) 2163 - return rp->status; 2164 - 2165 - cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS); 2166 - if (!cp) 2167 - return rp->status; 2168 - 2169 - hci_dev_lock(hdev); 2170 - hdev->adv_addr_type = cp->own_addr_type; 2171 - if (!cp->handle) { 2172 - /* Store in hdev for instance 0 */ 2173 - hdev->adv_tx_power = rp->tx_power; 2174 - } else { 2175 - adv_instance = hci_find_adv_instance(hdev, cp->handle); 2176 - if (adv_instance) 2177 - adv_instance->tx_power = rp->tx_power; 2178 - } 2179 - /* Update adv data as tx power is known now */ 2180 - hci_update_adv_data(hdev, cp->handle); 2181 - 2182 - hci_dev_unlock(hdev); 2183 - 2184 - return rp->status; 2185 - } 2186 - 2187 2153 static u8 hci_cc_read_rssi(struct hci_dev *hdev, void *data, 2188 2154 struct sk_buff *skb) 2189 2155 { ··· 4130 4164 HCI_CC(HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS, 4131 4165 hci_cc_le_read_num_adv_sets, 4132 4166 sizeof(struct hci_rp_le_read_num_supported_adv_sets)), 4133 - HCI_CC(HCI_OP_LE_SET_EXT_ADV_PARAMS, hci_cc_set_ext_adv_param, 4134 - sizeof(struct hci_rp_le_set_ext_adv_params)), 4135 4167 HCI_CC_STATUS(HCI_OP_LE_SET_EXT_ADV_ENABLE, 4136 4168 hci_cc_le_set_ext_adv_enable), 4137 4169 HCI_CC_STATUS(HCI_OP_LE_SET_ADV_SET_RAND_ADDR,
+138 -89
net/bluetooth/hci_sync.c
··· 1205 1205 sizeof(cp), &cp, HCI_CMD_TIMEOUT); 1206 1206 } 1207 1207 1208 + static int 1209 + hci_set_ext_adv_params_sync(struct hci_dev *hdev, struct adv_info *adv, 1210 + const struct hci_cp_le_set_ext_adv_params *cp, 1211 + struct hci_rp_le_set_ext_adv_params *rp) 1212 + { 1213 + struct sk_buff *skb; 1214 + 1215 + skb = __hci_cmd_sync(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(*cp), 1216 + cp, HCI_CMD_TIMEOUT); 1217 + 1218 + /* If command return a status event, skb will be set to -ENODATA */ 1219 + if (skb == ERR_PTR(-ENODATA)) 1220 + return 0; 1221 + 1222 + if (IS_ERR(skb)) { 1223 + bt_dev_err(hdev, "Opcode 0x%4.4x failed: %ld", 1224 + HCI_OP_LE_SET_EXT_ADV_PARAMS, PTR_ERR(skb)); 1225 + return PTR_ERR(skb); 1226 + } 1227 + 1228 + if (skb->len != sizeof(*rp)) { 1229 + bt_dev_err(hdev, "Invalid response length for 0x%4.4x: %u", 1230 + HCI_OP_LE_SET_EXT_ADV_PARAMS, skb->len); 1231 + kfree_skb(skb); 1232 + return -EIO; 1233 + } 1234 + 1235 + memcpy(rp, skb->data, sizeof(*rp)); 1236 + kfree_skb(skb); 1237 + 1238 + if (!rp->status) { 1239 + hdev->adv_addr_type = cp->own_addr_type; 1240 + if (!cp->handle) { 1241 + /* Store in hdev for instance 0 */ 1242 + hdev->adv_tx_power = rp->tx_power; 1243 + } else if (adv) { 1244 + adv->tx_power = rp->tx_power; 1245 + } 1246 + } 1247 + 1248 + return rp->status; 1249 + } 1250 + 1251 + static int hci_set_ext_adv_data_sync(struct hci_dev *hdev, u8 instance) 1252 + { 1253 + DEFINE_FLEX(struct hci_cp_le_set_ext_adv_data, pdu, data, length, 1254 + HCI_MAX_EXT_AD_LENGTH); 1255 + u8 len; 1256 + struct adv_info *adv = NULL; 1257 + int err; 1258 + 1259 + if (instance) { 1260 + adv = hci_find_adv_instance(hdev, instance); 1261 + if (!adv || !adv->adv_data_changed) 1262 + return 0; 1263 + } 1264 + 1265 + len = eir_create_adv_data(hdev, instance, pdu->data, 1266 + HCI_MAX_EXT_AD_LENGTH); 1267 + 1268 + pdu->length = len; 1269 + pdu->handle = adv ? adv->handle : instance; 1270 + pdu->operation = LE_SET_ADV_DATA_OP_COMPLETE; 1271 + pdu->frag_pref = LE_SET_ADV_DATA_NO_FRAG; 1272 + 1273 + err = __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_ADV_DATA, 1274 + struct_size(pdu, data, len), pdu, 1275 + HCI_CMD_TIMEOUT); 1276 + if (err) 1277 + return err; 1278 + 1279 + /* Update data if the command succeed */ 1280 + if (adv) { 1281 + adv->adv_data_changed = false; 1282 + } else { 1283 + memcpy(hdev->adv_data, pdu->data, len); 1284 + hdev->adv_data_len = len; 1285 + } 1286 + 1287 + return 0; 1288 + } 1289 + 1290 + static int hci_set_adv_data_sync(struct hci_dev *hdev, u8 instance) 1291 + { 1292 + struct hci_cp_le_set_adv_data cp; 1293 + u8 len; 1294 + 1295 + memset(&cp, 0, sizeof(cp)); 1296 + 1297 + len = eir_create_adv_data(hdev, instance, cp.data, sizeof(cp.data)); 1298 + 1299 + /* There's nothing to do if the data hasn't changed */ 1300 + if (hdev->adv_data_len == len && 1301 + memcmp(cp.data, hdev->adv_data, len) == 0) 1302 + return 0; 1303 + 1304 + memcpy(hdev->adv_data, cp.data, sizeof(cp.data)); 1305 + hdev->adv_data_len = len; 1306 + 1307 + cp.length = len; 1308 + 1309 + return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_ADV_DATA, 1310 + sizeof(cp), &cp, HCI_CMD_TIMEOUT); 1311 + } 1312 + 1313 + int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance) 1314 + { 1315 + if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) 1316 + return 0; 1317 + 1318 + if (ext_adv_capable(hdev)) 1319 + return hci_set_ext_adv_data_sync(hdev, instance); 1320 + 1321 + return hci_set_adv_data_sync(hdev, instance); 1322 + } 1323 + 1208 1324 int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance) 1209 1325 { 1210 1326 struct hci_cp_le_set_ext_adv_params cp; 1327 + struct hci_rp_le_set_ext_adv_params rp; 1211 1328 bool connectable; 1212 1329 u32 flags; 1213 1330 bdaddr_t random_addr; ··· 1433 1316 cp.secondary_phy = HCI_ADV_PHY_1M; 1434 1317 } 1435 1318 1436 - err = __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS, 1437 - sizeof(cp), &cp, HCI_CMD_TIMEOUT); 1319 + err = hci_set_ext_adv_params_sync(hdev, adv, &cp, &rp); 1320 + if (err) 1321 + return err; 1322 + 1323 + /* Update adv data as tx power is known now */ 1324 + err = hci_set_ext_adv_data_sync(hdev, cp.handle); 1438 1325 if (err) 1439 1326 return err; 1440 1327 ··· 1943 1822 sizeof(cp), &cp, HCI_CMD_TIMEOUT); 1944 1823 } 1945 1824 1946 - static int hci_set_ext_adv_data_sync(struct hci_dev *hdev, u8 instance) 1947 - { 1948 - DEFINE_FLEX(struct hci_cp_le_set_ext_adv_data, pdu, data, length, 1949 - HCI_MAX_EXT_AD_LENGTH); 1950 - u8 len; 1951 - struct adv_info *adv = NULL; 1952 - int err; 1953 - 1954 - if (instance) { 1955 - adv = hci_find_adv_instance(hdev, instance); 1956 - if (!adv || !adv->adv_data_changed) 1957 - return 0; 1958 - } 1959 - 1960 - len = eir_create_adv_data(hdev, instance, pdu->data, 1961 - HCI_MAX_EXT_AD_LENGTH); 1962 - 1963 - pdu->length = len; 1964 - pdu->handle = adv ? adv->handle : instance; 1965 - pdu->operation = LE_SET_ADV_DATA_OP_COMPLETE; 1966 - pdu->frag_pref = LE_SET_ADV_DATA_NO_FRAG; 1967 - 1968 - err = __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_ADV_DATA, 1969 - struct_size(pdu, data, len), pdu, 1970 - HCI_CMD_TIMEOUT); 1971 - if (err) 1972 - return err; 1973 - 1974 - /* Update data if the command succeed */ 1975 - if (adv) { 1976 - adv->adv_data_changed = false; 1977 - } else { 1978 - memcpy(hdev->adv_data, pdu->data, len); 1979 - hdev->adv_data_len = len; 1980 - } 1981 - 1982 - return 0; 1983 - } 1984 - 1985 - static int hci_set_adv_data_sync(struct hci_dev *hdev, u8 instance) 1986 - { 1987 - struct hci_cp_le_set_adv_data cp; 1988 - u8 len; 1989 - 1990 - memset(&cp, 0, sizeof(cp)); 1991 - 1992 - len = eir_create_adv_data(hdev, instance, cp.data, sizeof(cp.data)); 1993 - 1994 - /* There's nothing to do if the data hasn't changed */ 1995 - if (hdev->adv_data_len == len && 1996 - memcmp(cp.data, hdev->adv_data, len) == 0) 1997 - return 0; 1998 - 1999 - memcpy(hdev->adv_data, cp.data, sizeof(cp.data)); 2000 - hdev->adv_data_len = len; 2001 - 2002 - cp.length = len; 2003 - 2004 - return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_ADV_DATA, 2005 - sizeof(cp), &cp, HCI_CMD_TIMEOUT); 2006 - } 2007 - 2008 - int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance) 2009 - { 2010 - if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) 2011 - return 0; 2012 - 2013 - if (ext_adv_capable(hdev)) 2014 - return hci_set_ext_adv_data_sync(hdev, instance); 2015 - 2016 - return hci_set_adv_data_sync(hdev, instance); 2017 - } 2018 - 2019 1825 int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, 2020 1826 bool force) 2021 1827 { ··· 2018 1970 static int hci_clear_adv_sync(struct hci_dev *hdev, struct sock *sk, bool force) 2019 1971 { 2020 1972 struct adv_info *adv, *n; 2021 - int err = 0; 2022 1973 2023 1974 if (ext_adv_capable(hdev)) 2024 1975 /* Remove all existing sets */ 2025 - err = hci_clear_adv_sets_sync(hdev, sk); 2026 - if (ext_adv_capable(hdev)) 2027 - return err; 1976 + return hci_clear_adv_sets_sync(hdev, sk); 2028 1977 2029 1978 /* This is safe as long as there is no command send while the lock is 2030 1979 * held. ··· 2049 2004 static int hci_remove_adv_sync(struct hci_dev *hdev, u8 instance, 2050 2005 struct sock *sk) 2051 2006 { 2052 - int err = 0; 2007 + int err; 2053 2008 2054 2009 /* If we use extended advertising, instance has to be removed first. */ 2055 2010 if (ext_adv_capable(hdev)) 2056 - err = hci_remove_ext_adv_instance_sync(hdev, instance, sk); 2057 - if (ext_adv_capable(hdev)) 2058 - return err; 2011 + return hci_remove_ext_adv_instance_sync(hdev, instance, sk); 2059 2012 2060 2013 /* This is safe as long as there is no command send while the lock is 2061 2014 * held. ··· 2152 2109 int hci_disable_advertising_sync(struct hci_dev *hdev) 2153 2110 { 2154 2111 u8 enable = 0x00; 2155 - int err = 0; 2156 2112 2157 2113 /* If controller is not advertising we are done. */ 2158 2114 if (!hci_dev_test_flag(hdev, HCI_LE_ADV)) 2159 2115 return 0; 2160 2116 2161 2117 if (ext_adv_capable(hdev)) 2162 - err = hci_disable_ext_adv_instance_sync(hdev, 0x00); 2163 - if (ext_adv_capable(hdev)) 2164 - return err; 2118 + return hci_disable_ext_adv_instance_sync(hdev, 0x00); 2165 2119 2166 2120 return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_ADV_ENABLE, 2167 2121 sizeof(enable), &enable, HCI_CMD_TIMEOUT); ··· 2520 2480 { 2521 2481 int err; 2522 2482 int old_state; 2483 + 2484 + /* If controller is not advertising we are done. */ 2485 + if (!hci_dev_test_flag(hdev, HCI_LE_ADV)) 2486 + return 0; 2523 2487 2524 2488 /* If already been paused there is nothing to do. */ 2525 2489 if (hdev->advertising_paused) ··· 6321 6277 struct hci_conn *conn) 6322 6278 { 6323 6279 struct hci_cp_le_set_ext_adv_params cp; 6280 + struct hci_rp_le_set_ext_adv_params rp; 6324 6281 int err; 6325 6282 bdaddr_t random_addr; 6326 6283 u8 own_addr_type; ··· 6363 6318 if (err) 6364 6319 return err; 6365 6320 6366 - err = __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS, 6367 - sizeof(cp), &cp, HCI_CMD_TIMEOUT); 6321 + err = hci_set_ext_adv_params_sync(hdev, NULL, &cp, &rp); 6322 + if (err) 6323 + return err; 6324 + 6325 + /* Update adv data as tx power is known now */ 6326 + err = hci_set_ext_adv_data_sync(hdev, cp.handle); 6368 6327 if (err) 6369 6328 return err; 6370 6329
+24 -1
net/bluetooth/mgmt.c
··· 1080 1080 struct mgmt_mesh_tx *mesh_tx; 1081 1081 1082 1082 hci_dev_clear_flag(hdev, HCI_MESH_SENDING); 1083 - hci_disable_advertising_sync(hdev); 1083 + if (list_empty(&hdev->adv_instances)) 1084 + hci_disable_advertising_sync(hdev); 1084 1085 mesh_tx = mgmt_mesh_next(hdev, NULL); 1085 1086 1086 1087 if (mesh_tx) ··· 2154 2153 else 2155 2154 hci_dev_clear_flag(hdev, HCI_MESH); 2156 2155 2156 + hdev->le_scan_interval = __le16_to_cpu(cp->period); 2157 + hdev->le_scan_window = __le16_to_cpu(cp->window); 2158 + 2157 2159 len -= sizeof(*cp); 2158 2160 2159 2161 /* If filters don't fit, forward all adv pkts */ ··· 2171 2167 { 2172 2168 struct mgmt_cp_set_mesh *cp = data; 2173 2169 struct mgmt_pending_cmd *cmd; 2170 + __u16 period, window; 2174 2171 int err = 0; 2175 2172 2176 2173 bt_dev_dbg(hdev, "sock %p", sk); ··· 2182 2177 MGMT_STATUS_NOT_SUPPORTED); 2183 2178 2184 2179 if (cp->enable != 0x00 && cp->enable != 0x01) 2180 + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER, 2181 + MGMT_STATUS_INVALID_PARAMS); 2182 + 2183 + /* Keep allowed ranges in sync with set_scan_params() */ 2184 + period = __le16_to_cpu(cp->period); 2185 + 2186 + if (period < 0x0004 || period > 0x4000) 2187 + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER, 2188 + MGMT_STATUS_INVALID_PARAMS); 2189 + 2190 + window = __le16_to_cpu(cp->window); 2191 + 2192 + if (window < 0x0004 || window > 0x4000) 2193 + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER, 2194 + MGMT_STATUS_INVALID_PARAMS); 2195 + 2196 + if (window > period) 2185 2197 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER, 2186 2198 MGMT_STATUS_INVALID_PARAMS); 2187 2199 ··· 6454 6432 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, 6455 6433 MGMT_STATUS_NOT_SUPPORTED); 6456 6434 6435 + /* Keep allowed ranges in sync with set_mesh() */ 6457 6436 interval = __le16_to_cpu(cp->interval); 6458 6437 6459 6438 if (interval < 0x0004 || interval > 0x4000)
+4 -3
net/ipv4/ip_input.c
··· 319 319 const struct sk_buff *hint) 320 320 { 321 321 const struct iphdr *iph = ip_hdr(skb); 322 - int err, drop_reason; 323 322 struct rtable *rt; 323 + int drop_reason; 324 324 325 325 if (ip_can_use_hint(skb, iph, hint)) { 326 326 drop_reason = ip_route_use_hint(skb, iph->daddr, iph->saddr, ··· 345 345 break; 346 346 case IPPROTO_UDP: 347 347 if (READ_ONCE(net->ipv4.sysctl_udp_early_demux)) { 348 - err = udp_v4_early_demux(skb); 349 - if (unlikely(err)) 348 + drop_reason = udp_v4_early_demux(skb); 349 + if (unlikely(drop_reason)) 350 350 goto drop_error; 351 + drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; 351 352 352 353 /* must reload iph, skb->head might have changed */ 353 354 iph = ip_hdr(skb);
+4 -11
net/rose/rose_route.c
··· 497 497 t = rose_node; 498 498 rose_node = rose_node->next; 499 499 500 - for (i = 0; i < t->count; i++) { 500 + for (i = t->count - 1; i >= 0; i--) { 501 501 if (t->neighbour[i] != s) 502 502 continue; 503 503 504 504 t->count--; 505 505 506 - switch (i) { 507 - case 0: 508 - t->neighbour[0] = t->neighbour[1]; 509 - fallthrough; 510 - case 1: 511 - t->neighbour[1] = t->neighbour[2]; 512 - break; 513 - case 2: 514 - break; 515 - } 506 + memmove(&t->neighbour[i], &t->neighbour[i + 1], 507 + sizeof(t->neighbour[0]) * 508 + (t->count - i)); 516 509 } 517 510 518 511 if (t->count <= 0)
+5 -14
net/sched/sch_api.c
··· 780 780 781 781 void qdisc_tree_reduce_backlog(struct Qdisc *sch, int n, int len) 782 782 { 783 - bool qdisc_is_offloaded = sch->flags & TCQ_F_OFFLOADED; 784 783 const struct Qdisc_class_ops *cops; 785 784 unsigned long cl; 786 785 u32 parentid; 787 786 bool notify; 788 787 int drops; 789 788 790 - if (n == 0 && len == 0) 791 - return; 792 789 drops = max_t(int, n, 0); 793 790 rcu_read_lock(); 794 791 while ((parentid = sch->parent)) { ··· 794 797 795 798 if (sch->flags & TCQ_F_NOPARENT) 796 799 break; 797 - /* Notify parent qdisc only if child qdisc becomes empty. 798 - * 799 - * If child was empty even before update then backlog 800 - * counter is screwed and we skip notification because 801 - * parent class is already passive. 802 - * 803 - * If the original child was offloaded then it is allowed 804 - * to be seem as empty, so the parent is notified anyway. 805 - */ 806 - notify = !sch->q.qlen && !WARN_ON_ONCE(!n && 807 - !qdisc_is_offloaded); 800 + /* Notify parent qdisc only if child qdisc becomes empty. */ 801 + notify = !sch->q.qlen; 808 802 /* TODO: perform the search on a per txq basis */ 809 803 sch = qdisc_lookup_rcu(qdisc_dev(sch), TC_H_MAJ(parentid)); 810 804 if (sch == NULL) { ··· 804 816 } 805 817 cops = sch->ops->cl_ops; 806 818 if (notify && cops->qlen_notify) { 819 + /* Note that qlen_notify must be idempotent as it may get called 820 + * multiple times. 821 + */ 807 822 cl = cops->find(sch, parentid); 808 823 cops->qlen_notify(sch, cl); 809 824 }
+2 -2
net/vmw_vsock/vmci_transport.c
··· 119 119 u16 proto, 120 120 struct vmci_handle handle) 121 121 { 122 + memset(pkt, 0, sizeof(*pkt)); 123 + 122 124 /* We register the stream control handler as an any cid handle so we 123 125 * must always send from a source address of VMADDR_CID_ANY 124 126 */ ··· 133 131 pkt->type = type; 134 132 pkt->src_port = src->svm_port; 135 133 pkt->dst_port = dst->svm_port; 136 - memset(&pkt->proto, 0, sizeof(pkt->proto)); 137 - memset(&pkt->_reserved2, 0, sizeof(pkt->_reserved2)); 138 134 139 135 switch (pkt->type) { 140 136 case VMCI_TRANSPORT_PACKET_TYPE_INVALID: