From patchwork Sun Sep 27 19:49:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 11802471 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFB1192C for ; Sun, 27 Sep 2020 19:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8465723A53 for ; Sun, 27 Sep 2020 19:59:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="P+aP2GF7"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9iuCsE2W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbgI0T7i (ORCPT ); Sun, 27 Sep 2020 15:59:38 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:40792 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbgI0T6D (ORCPT ); Sun, 27 Sep 2020 15:58:03 -0400 Message-Id: <20200927194922.444952084@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1601236658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=rVcs4xyNsZ3B1RNOlCmgCHrKkmEQ7KBjYPLrc7hX0OM=; b=P+aP2GF7vFpvtjuxSOhnGOx5VKGfmgDyoWP+aYtjk+E4j5QR85SJbH0RvEO2TEYfSXNZde LH8htefcBkwQMMGsPRzvzl0aW2kq0kDu4/dCa0QxKRU+qfJioVR4cbmEutXWugxbCl3GLA LM64MD3HlulB0peOdhgWz4jWk8odxkKl6F9/rYCcRh64zgwPY6L5KKa1gWLwFq8OukZVlL nFGIQxs6jGOwsN7hDS0U2YTqo0ckaMc7WGyAMElofzlN5vuu/jtGB4hIdzH58Ype7BA1l7 6OaHTbtTvyAUAuMszdCFi4rbo9hWanEt8I92TGo6Fsr9CaCm4S3BYMXj8+17sA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1601236658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=rVcs4xyNsZ3B1RNOlCmgCHrKkmEQ7KBjYPLrc7hX0OM=; b=9iuCsE2W9cE1a4r2PyxLkUtHyC4zrJ8k7En+qtSH6f0oI2SrDUw6QOJqMyRyM2DiCqigCt DTntnxOadEMTUXBw== Date: Sun, 27 Sep 2020 21:49:12 +0200 From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Linus Torvalds , Paul McKenney , Matthew Wilcox , Sebastian Andrzej Siewior , Arend van Spriel , Franky Lin , Hante Meuleman , Chi-Hsien Lin , Wright Feng , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, netdev@vger.kernel.org, Christian Benvenuti , Govindarajulu Varadarajan <_govind@gmx.com>, Dave Miller , Jonathan Corbet , Mauro Carvalho Chehab , linux-doc@vger.kernel.org, Luc Van Oostenryck , Jay Cliburn , Chris Snook , Vishal Kulkarni , Jeff Kirsher , intel-wired-lan@lists.osuosl.org, Shannon Nelson , Pensando Drivers , Andrew Lunn , Heiner Kallweit , Russell King , Thomas Bogendoerfer , Solarflare linux maintainers , Edward Cree , Martin Habets , Jon Mason , Daniel Drake , Ulrich Kunitz , linux-usb@vger.kernel.org, Greg Kroah-Hartman , Stanislav Yakovlev , Stanislaw Gruszka , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Jouni Malinen , Amitkumar Karwar , Ganapathi Bhat , Xinming Hu , libertas-dev@lists.infradead.org, Pascal Terjan , Ping-Ke Shih Subject: [patch 26/35] net: brcmfmac: Convey allocation mode as argument References: <20200927194846.045411263@linutronix.de> MIME-Version: 1.0 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sebastian Andrzej Siewior The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be seperated or the context be conveyed in an argument passed by the caller, which usually knows the context. brcmf_fweh_process_event() uses in_interrupt() to select the allocation mode GFP_KERNEL/GFP_ATOMIC. Aside of the above reasons this check is incomplete as it cannot detect contexts which just have preemption or interrupts disabled. All callchains leading to brcmf_fweh_process_event() can clearly identify the calling context. Convey a 'gfp' argument through the callchains and let the callers hand in the appropriate GFP mode. This has also the advantage that any change of execution context or preemption/interrupt state in these callchains will be detected by the memory allocator for all GFP_KERNEL allocations. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner Cc: Arend van Spriel Cc: Franky Lin Cc: Hante Meuleman Cc: Chi-Hsien Lin Cc: Wright Feng Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com Cc: brcm80211-dev-list@cypress.com Cc: netdev@vger.kernel.org --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 5 +++-- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 11 ++++++----- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c | 8 ++------ drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h | 7 ++++--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | 2 +- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 8 ++++---- drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 2 +- 7 files changed, 21 insertions(+), 22 deletions(-) --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h @@ -249,9 +249,10 @@ int brcmf_bus_reset(struct brcmf_bus *bu */ /* Receive frame for delivery to OS. Callee disposes of rxp. */ -void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp, bool handle_event); +void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp, bool handle_event, + gfp_t gfp); /* Receive async event packet from firmware. Callee disposes of rxp. */ -void brcmf_rx_event(struct device *dev, struct sk_buff *rxp); +void brcmf_rx_event(struct device *dev, struct sk_buff *rxp, gfp_t gfp); int brcmf_alloc(struct device *dev, struct brcmf_mp_device *settings); /* Indication from bus module regarding presence/insertion of dongle. */ --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -489,7 +489,8 @@ static int brcmf_rx_hdrpull(struct brcmf return 0; } -void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event) +void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event, + gfp_t gfp) { struct brcmf_if *ifp; struct brcmf_bus *bus_if = dev_get_drvdata(dev); @@ -506,13 +507,13 @@ void brcmf_rx_frame(struct device *dev, /* Process special event packets */ if (handle_event) brcmf_fweh_process_skb(ifp->drvr, skb, - BCMILCP_SUBTYPE_VENDOR_LONG); - + BCMILCP_SUBTYPE_VENDOR_LONG, + gfp); brcmf_netif_rx(ifp, skb); } } -void brcmf_rx_event(struct device *dev, struct sk_buff *skb) +void brcmf_rx_event(struct device *dev, struct sk_buff *skb, gfp_t gfp) { struct brcmf_if *ifp; struct brcmf_bus *bus_if = dev_get_drvdata(dev); @@ -523,7 +524,7 @@ void brcmf_rx_event(struct device *dev, if (brcmf_rx_hdrpull(drvr, skb, &ifp)) return; - brcmf_fweh_process_skb(ifp->drvr, skb, 0); + brcmf_fweh_process_skb(ifp->drvr, skb, 0, gfp); brcmu_pkt_buf_free_skb(skb); } --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c @@ -387,12 +387,11 @@ int brcmf_fweh_activate_events(struct br */ void brcmf_fweh_process_event(struct brcmf_pub *drvr, struct brcmf_event *event_packet, - u32 packet_len) + u32 packet_len, gfp_t gfp) { enum brcmf_fweh_event_code code; struct brcmf_fweh_info *fweh = &drvr->fweh; struct brcmf_fweh_queue_item *event; - gfp_t alloc_flag = GFP_KERNEL; void *data; u32 datalen; @@ -411,10 +410,7 @@ void brcmf_fweh_process_event(struct brc datalen + sizeof(*event_packet) > packet_len) return; - if (in_interrupt()) - alloc_flag = GFP_ATOMIC; - - event = kzalloc(sizeof(*event) + datalen, alloc_flag); + event = kzalloc(sizeof(*event) + datalen, gfp); if (!event) return; --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h @@ -319,11 +319,12 @@ void brcmf_fweh_unregister(struct brcmf_ int brcmf_fweh_activate_events(struct brcmf_if *ifp); void brcmf_fweh_process_event(struct brcmf_pub *drvr, struct brcmf_event *event_packet, - u32 packet_len); + u32 packet_len, gfp_t gfp); void brcmf_fweh_p2pdev_setup(struct brcmf_if *ifp, bool ongoing); static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr, - struct sk_buff *skb, u16 stype) + struct sk_buff *skb, u16 stype, + gfp_t gfp) { struct brcmf_event *event_packet; u16 subtype, usr_stype; @@ -354,7 +355,7 @@ static inline void brcmf_fweh_process_sk if (usr_stype != BCMILCP_BCM_SUBTYPE_EVENT) return; - brcmf_fweh_process_event(drvr, event_packet, skb->len + ETH_HLEN); + brcmf_fweh_process_event(drvr, event_packet, skb->len + ETH_HLEN, gfp); } #endif /* FWEH_H_ */ --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c @@ -1128,7 +1128,7 @@ static void brcmf_msgbuf_process_event(s skb->protocol = eth_type_trans(skb, ifp->ndev); - brcmf_fweh_process_skb(ifp->drvr, skb, 0); + brcmf_fweh_process_skb(ifp->drvr, skb, 0, GFP_KERNEL); exit: brcmu_pkt_buf_free_skb(skb); --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -1701,10 +1701,10 @@ static u8 brcmf_sdio_rxglom(struct brcmf pfirst->prev); skb_unlink(pfirst, &bus->glom); if (brcmf_sdio_fromevntchan(&dptr[SDPCM_HWHDR_LEN])) - brcmf_rx_event(bus->sdiodev->dev, pfirst); + brcmf_rx_event(bus->sdiodev->dev, pfirst, GFP_KERNEL); else brcmf_rx_frame(bus->sdiodev->dev, pfirst, - false); + false, GFP_KERNEL); bus->sdcnt.rxglompkts++; } @@ -2035,10 +2035,10 @@ static uint brcmf_sdio_readframes(struct if (pkt->len == 0) brcmu_pkt_buf_free_skb(pkt); else if (rd->channel == SDPCM_EVENT_CHANNEL) - brcmf_rx_event(bus->sdiodev->dev, pkt); + brcmf_rx_event(bus->sdiodev->dev, pkt, GFP_KERNEL); else brcmf_rx_frame(bus->sdiodev->dev, pkt, - false); + false, GFP_KERNEL); /* prepare the descriptor for the next read */ rd->len = rd->len_nxtfrm << 4; --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -532,7 +532,7 @@ static void brcmf_usb_rx_complete(struct if (devinfo->bus_pub.state == BRCMFMAC_USB_STATE_UP || devinfo->bus_pub.state == BRCMFMAC_USB_STATE_SLEEP) { skb_put(skb, urb->actual_length); - brcmf_rx_frame(devinfo->dev, skb, true); + brcmf_rx_frame(devinfo->dev, skb, true, GFP_ATOMIC); brcmf_usb_rx_refill(devinfo, req); usb_mark_last_busy(urb->dev); } else {