From patchwork Mon Apr 20 16:02:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 215911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1C46C3A5A0 for ; Mon, 20 Apr 2020 16:05:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8F2B2078E for ; Mon, 20 Apr 2020 16:05:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="NJFlOeC1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729969AbgDTQFV (ORCPT ); Mon, 20 Apr 2020 12:05:21 -0400 Received: from mail-mw2nam10on2061.outbound.protection.outlook.com ([40.107.94.61]:6055 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727913AbgDTQDk (ORCPT ); Mon, 20 Apr 2020 12:03:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fM9T+kjmFfjsNZFmkpef8NEKC07aoPShtinvYCnU6g1U1nCePLYow/9DeAGQGZcDNcrtUscZE/ATrJpJ5chG9wt8E+/D//AYJkBpsSOBaNwn5pV2plfvUyb8TUIq5jND2G+y30iY/b1TiDzA8asxonFwFzd7AiCHGOOh+ZioWvQgCWXVlHbyf0KZRwd5SdmBdDo+FhJJCtjE9KaqxsuA/wG/qXpF9wDCWq/v5iQN7NxOxR/+hm/2c/kOAmOXvRn/Bo3Nz3blt0Ryt0/2bx0i75fpL0KdJOwW4t7tyt2dRfnldlXzfvZ9NJoGnhWbtV+x2TT5YNgG0gZLd6VfWtXnWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CIIn5gYo1S799Alx1I75/HyBqK+b319EaTF5oWsSuvE=; b=WKvvGxAs4iQu0jS4lEOsOR4Tu4DCma//eajwSnrgQ/NDlDNaWOp+pYjxweQl7P9evZ7NBVTHPzdjN9qPySG4oHFiLg6/T+hYkEvWcOtB6A4/wlHj7qHGTuSmlxFpyF48ijv3kItPZqsP8nHLPGfzlrtrV/ROT8tRUM7T3eokzafKLq8jVTknyK4USUV7lf2fE9QrGHK4G6MZY8++XK7iE6ga+KdWJ/Ns987G8L2eZ87w0kE3MSz12Ov9FZfxXNNnVFKHSY6kFLdQIddd/8iy9hAN2IkBxLEH+UX9xTJIGA5xgxmH3sbDn6pyun4GxCiELHg1AsPnn07MrlbwwJfEAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CIIn5gYo1S799Alx1I75/HyBqK+b319EaTF5oWsSuvE=; b=NJFlOeC1oX9Mg/yb5+lj/DypON1j4q/xNV38KGRGzTVI5emoyW0KAUX7OkmY/42wW9kC7b6VVKwTV53vK+nC32p+jTnMNrWkuHz87EGxDM/54KeuSX8OpiYfson5uZJ1AyqkRwPiXIQ0kbegoMt7FQi766c4hxqUVGuy8gYPPtM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; Received: from MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) by MWHSPR00MB249.namprd11.prod.outlook.com (2603:10b6:300:68::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.25; Mon, 20 Apr 2020 16:03:36 +0000 Received: from MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::81d5:b62b:3770:ffbe]) by MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::81d5:b62b:3770:ffbe%10]) with mapi id 15.20.2921.030; Mon, 20 Apr 2020 16:03:36 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 04/16] staging: wfx: handle firmware events synchronously Date: Mon, 20 Apr 2020 18:02:59 +0200 Message-Id: <20200420160311.57323-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200420160311.57323-1-Jerome.Pouiller@silabs.com> References: <20200420160311.57323-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: DM6PR07CA0065.namprd07.prod.outlook.com (2603:10b6:5:74::42) To MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by DM6PR07CA0065.namprd07.prod.outlook.com (2603:10b6:5:74::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.26 via Frontend Transport; Mon, 20 Apr 2020 16:03:34 +0000 X-Mailer: git-send-email 2.26.1 X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f8861646-f92a-4d90-24d2-08d7e544622d X-MS-TrafficTypeDiagnostic: MWHSPR00MB249: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-Forefront-PRVS: 03793408BA X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1775.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(136003)(366004)(376002)(396003)(39850400004)(346002)(8676002)(7696005)(52116002)(6666004)(4326008)(8936002)(81156014)(66556008)(66476007)(66946007)(36756003)(186003)(54906003)(16526019)(107886003)(478600001)(2906002)(316002)(66574012)(1076003)(86362001)(6486002)(2616005)(5660300002); DIR:OUT; SFP:1101; Received-SPF: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YaGM8pVWOxodsGmkdMrwGD2HipmWxdbbexGUzeIEodp8wEmVriCJH/tWdc10ZrBTJvyjd1ge7eYik1eOe5TApQByj7qkgjQOW6Uz/WVfxfy2Iw0voRMdN21HX5wjLuXRKG7hMmwdoQlnpU6DVEfhYR+i75xHM7oDTgGEBYjbRUua3zxdikfWZjbQO2mnUmVSV5XBJNlsCqC0iCKfMePfujZw15na7gbw67fJYLQTDFKQAENLtAd0l8EdI5Ie1Ad/AywIDV4lwmQLw+cd162vqr5y33c36tHDpLBScvxwfs+dH1wiAVVC+Z9N4ZacvX7itUVANmzajJP7htHFFvdyWWl6NzdWNW/5KjZe2ENQKf5xKliQ+JI+zkACdXuMBHAGSPf1Ei9c9KhB0+bJowJtbuxIVDvyFuOhihsNwukX41Tzw7hESUdgdWreLsMT99vv X-MS-Exchange-AntiSpam-MessageData: MmPoeFnbIsY3torCWje4nyQFOkdwKvRKY0+ncTQd1OGHgma35CEcS/KjTkWcQWne8mpHdmTltxEBkHC8Gpge2X0YaPA9TQ1K5mtmw/iPSLlaTMxY+QzR2mWefI/BPxq/gJPGwn6xaou7aW9EHOEG4/H01Kh1WJ/5hofcmCwLjPtHoZdYPi2bh1ZAHRGsCnMBr7vfD2fJJQHS6aJfsi2AeWi3Z+D5shHP5JfGHHQkz7iKsExf8TiZBUxmvDIuhswltGnr+xuOxtdm+TYu0fmxKtpjHhKdOh0wIW/WWaVeUt6jbS7yv+IfzJy5/r+yCnJyYahh6GEMKwBmzXh/y5o1z8UtRS4He6++SziJn+Irq3sbxUQA0k1NJrkCSg56PLCtmy6ymnn4DNDeGl865ecV2QiYNkNpnYJEpZGEkKaFUr0VFRmcFCLranzFCaLH1MaMQXuaaJQkK/iA4tSjLtv2FJ2CIwBgkgeMDSeF2ibWkbDDRvXU3zxXj6w9fxlGSqiKPV5xPs6vU67n1DjeJst7n1zg3RejHjhD5dS8H9QcUqs/3/U9Yku/Wjdnye7v0YHEKvb1id2ueFvr3xFWN51u0tksIGvoYaZ6t//CBQp2WV7Ua58Gk0617umYYTaYNLSxtrs7pk+VyF8AKP+zV916YOpt3BprhA0jKmUDtWXIoMTgrPqSyTwE/4dyotv6FXgiqgAUcLArQg7K7NuxNXjF0UE5D7uvwPmaQKNgJpUg18jQabRUczq0ZvkHuY5gf2WrujJdmioifXqViIQE+9y3EdYWEZb/VMpyqAnmdf841IWIUVXTOYSwyH2dCFGIey8FNfC/hQOUlUoHIU9Qn0XxYAdL6w+bt5WZoUyN0c17lyA= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8861646-f92a-4d90-24d2-08d7e544622d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2020 16:03:36.7285 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: s9gJBSYMaeYAJQKgVLAOl80YyRVxFcrvBxeWhxX5JXPIKDC5Eai5yJhmCY56uf2FJzwLsSKxBAhXxn71XCIWEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHSPR00MB249 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller Currently, events from firmware are handled in a work queue with a complex event queue mechanism. It is probably overkill since there is only two events to handle: bss_loss and CQM events. Handling these events synchronously is sufficient. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_rx.c | 39 +++++++++++--------- drivers/staging/wfx/sta.c | 70 +----------------------------------- drivers/staging/wfx/sta.h | 6 +--- drivers/staging/wfx/wfx.h | 4 --- 4 files changed, 24 insertions(+), 95 deletions(-) diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 33c22c5d629d..b8d570256498 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -158,26 +158,31 @@ static int hif_event_indication(struct wfx_dev *wdev, { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); const struct hif_ind_event *body = buf; - struct wfx_hif_event *event; - int first; - WARN_ON(!wvif); - if (!wvif) + if (!wvif) { + dev_warn(wdev->dev, "received event for non-existent vif\n"); return 0; + } - event = kzalloc(sizeof(*event), GFP_KERNEL); - if (!event) - return -ENOMEM; - - memcpy(&event->evt, body, sizeof(struct hif_ind_event)); - spin_lock(&wvif->event_queue_lock); - first = list_empty(&wvif->event_queue); - list_add_tail(&event->link, &wvif->event_queue); - spin_unlock(&wvif->event_queue_lock); - - if (first) - schedule_work(&wvif->event_handler_work); - + switch (body->event_id) { + case HIF_EVENT_IND_RCPI_RSSI: + wfx_event_report_rssi(wvif, body->event_data.rcpi_rssi); + break; + case HIF_EVENT_IND_BSSLOST: + schedule_delayed_work(&wvif->beacon_loss_work, 0); + break; + case HIF_EVENT_IND_BSSREGAINED: + cancel_delayed_work(&wvif->beacon_loss_work); + dev_dbg(wdev->dev, "ignore BSSREGAINED indication\n"); + break; + case HIF_EVENT_IND_PS_MODE_ERROR: + dev_warn(wdev->dev, "error while processing power save request\n"); + break; + default: + dev_warn(wdev->dev, "unhandled event indication: %.2x\n", + body->event_id); + break; + } return 0; } diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 2253ec2bdbf3..a0c841658a0b 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -38,27 +38,6 @@ u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates) return ret; } -static void __wfx_free_event_queue(struct list_head *list) -{ - struct wfx_hif_event *event, *tmp; - - list_for_each_entry_safe(event, tmp, list, link) { - list_del(&event->link); - kfree(event); - } -} - -static void wfx_free_event_queue(struct wfx_vif *wvif) -{ - LIST_HEAD(list); - - spin_lock(&wvif->event_queue_lock); - list_splice_init(&wvif->event_queue, &list); - spin_unlock(&wvif->event_queue_lock); - - __wfx_free_event_queue(&list); -} - static void wfx_filter_beacon(struct wfx_vif *wvif, bool filter_beacon) { const struct hif_ie_table_entry filter_ies[] = { @@ -269,7 +248,7 @@ int wfx_set_rts_threshold(struct ieee80211_hw *hw, u32 value) /* WSM callbacks */ -static void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi) +void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi) { /* RSSI: signed Q8.0, RCPI: unsigned Q7.1 * RSSI = RCPI / 2 - 110 @@ -296,44 +275,6 @@ static void wfx_beacon_loss_work(struct work_struct *work) msecs_to_jiffies(bss_conf->beacon_int)); } -static void wfx_event_handler_work(struct work_struct *work) -{ - struct wfx_vif *wvif = - container_of(work, struct wfx_vif, event_handler_work); - struct wfx_hif_event *event; - - LIST_HEAD(list); - - spin_lock(&wvif->event_queue_lock); - list_splice_init(&wvif->event_queue, &list); - spin_unlock(&wvif->event_queue_lock); - - list_for_each_entry(event, &list, link) { - switch (event->evt.event_id) { - case HIF_EVENT_IND_BSSLOST: - schedule_delayed_work(&wvif->beacon_loss_work, 0); - break; - case HIF_EVENT_IND_BSSREGAINED: - cancel_delayed_work(&wvif->beacon_loss_work); - break; - case HIF_EVENT_IND_RCPI_RSSI: - wfx_event_report_rssi(wvif, - event->evt.event_data.rcpi_rssi); - break; - case HIF_EVENT_IND_PS_MODE_ERROR: - dev_warn(wvif->wdev->dev, - "error while processing power save request\n"); - break; - default: - dev_warn(wvif->wdev->dev, - "unhandled event indication: %.2x\n", - event->evt.event_id); - break; - } - } - __wfx_free_event_queue(&list); -} - // Call it with wdev->conf_mutex locked static void wfx_do_unjoin(struct wfx_vif *wvif) { @@ -351,9 +292,6 @@ static void wfx_do_unjoin(struct wfx_vif *wvif) wfx_tx_policy_init(wvif); if (wvif_count(wvif->wdev) <= 1) hif_set_block_ack_policy(wvif, 0xFF, 0xFF); - wfx_free_event_queue(wvif); - cancel_work_sync(&wvif->event_handler_work); - wfx_tx_unlock(wvif->wdev); cancel_delayed_work_sync(&wvif->beacon_loss_work); } @@ -844,10 +782,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) wvif->wep_default_key_id = -1; INIT_WORK(&wvif->wep_key_work, wfx_wep_key_work); - spin_lock_init(&wvif->event_queue_lock); - INIT_LIST_HEAD(&wvif->event_queue); - INIT_WORK(&wvif->event_handler_work, wfx_event_handler_work); - init_completion(&wvif->set_pm_mode_complete); complete(&wvif->set_pm_mode_complete); INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work); @@ -904,9 +838,7 @@ void wfx_remove_interface(struct ieee80211_hw *hw, /* FIXME: In add to reset MAC address, try to reset interface */ hif_set_macaddr(wvif, NULL); - wfx_free_event_queue(wvif); cancel_delayed_work_sync(&wvif->beacon_loss_work); - wdev->vif[wvif->id] = NULL; wvif->vif = NULL; diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index 6d7734c65902..767b794fa398 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -23,11 +23,6 @@ enum wfx_state { WFX_STATE_AP, }; -struct wfx_hif_event { - struct list_head link; - struct hif_ind_event evt; -}; - struct wfx_sta_priv { int link_id; int vif_id; @@ -79,6 +74,7 @@ void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, // WSM Callbacks void wfx_suspend_resume_mc(struct wfx_vif *wvif, enum sta_notify_cmd cmd); +void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi); // Other Helpers u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates); diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 5484e7c64c3c..913b80d024a3 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -98,10 +98,6 @@ struct wfx_vif { struct ieee80211_scan_request *scan_req; struct completion set_pm_mode_complete; - - struct list_head event_queue; - spinlock_t event_queue_lock; - struct work_struct event_handler_work; }; static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id)