linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"rtl8821cerfe2@gmail.com" <rtl8821cerfe2@gmail.com>
Cc: "Larry.Finger@lwfinger.net" <Larry.Finger@lwfinger.net>,
	"s.l-h@gmx.de" <s.l-h@gmx.de>,
	"chewitt@libreelec.tv" <chewitt@libreelec.tv>
Subject: Re: [PATCH v3 11/12] wifi: rtlwifi: Add rtl8192du/sw.{c,h}
Date: Fri, 22 Mar 2024 06:04:42 +0000	[thread overview]
Message-ID: <f86a40493745a53ff73083f87b3e8fae215eac77.camel@realtek.com> (raw)
In-Reply-To: <2eb79c8c-cf2c-4696-b958-e8d961628e17@gmail.com>

On Wed, 2024-03-20 at 21:43 +0200, Bitterblue Smith wrote:
> 
> These contain the new module's entry point.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> ---
> v3:
>  - Add USB ID 2001:330c found by Zenm Chen.
> 
> v2:
>  - Patch is new in v2, split from patch 3/3 in v1.
> ---
>  .../wireless/realtek/rtlwifi/rtl8192du/sw.c   | 312 ++++++++++++++++++
>  .../wireless/realtek/rtlwifi/rtl8192du/sw.h   |  12 +
>  2 files changed, 324 insertions(+)
>  create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
>  create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.h
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
> new file mode 100644
> index 000000000000..6d7f40e7add5
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
> @@ -0,0 +1,312 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright(c) 2009-2012  Realtek Corporation.*/
> +
> +#include "../wifi.h"
> +#include "../core.h"
> +#include "../usb.h"
> +#include "../base.h"
> +#include "../rtl8192d/reg.h"
> +#include "../rtl8192d/def.h"
> +#include "../rtl8192d/fw_common.h"
> +#include "../rtl8192d/hw_common.h"
> +#include "../rtl8192d/phy_common.h"
> +#include "../rtl8192d/trx_common.h"
> +#include "phy.h"
> +#include "dm.h"
> +#include "fw.h"
> +#include "hw.h"
> +#include "sw.h"
> +#include "trx.h"
> +#include "led.h"
> +
> +#include <linux/module.h>
> +
> +static int rtl92du_init_sw_vars(struct ieee80211_hw *hw)
> +{
> +       const char *fw_name = "rtlwifi/rtl8192dufw.bin";
> +       struct rtl_priv *rtlpriv = rtl_priv(hw);
> +       int err;
> +
> +       rtlpriv->dm.dm_initialgain_enable = true;
> +       rtlpriv->dm.dm_flag = 0;
> +       rtlpriv->dm.disable_framebursting = false;
> +       rtlpriv->dm.thermalvalue = 0;
> +       rtlpriv->dm.useramask = true;
> +
> +       /* dual mac */
> +       if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G)
> +               rtlpriv->phy.current_channel = 36;
> +       else
> +               rtlpriv->phy.current_channel = 1;
> +
> +       if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY)
> +               rtlpriv->rtlhal.disable_amsdu_8k = true;
> +
> +       /* for LPS & IPS */
> +       rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps;
> +       rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
> +       rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
> +       if (!rtlpriv->psc.inactiveps)
> +               pr_info("Inactive Power Save off (module option)\n");
> +
> +       /* for early mode */
> +       rtlpriv->rtlhal.earlymode_enable = false;
> +
> +       /* for firmware buf */
> +       rtlpriv->rtlhal.pfirmware = kmalloc(0x8000, GFP_KERNEL);
> +       if (!rtlpriv->rtlhal.pfirmware) {
> +               pr_err("Can't alloc buffer for fw\n");

WARNING: Possible unnecessary 'out of memory' message
#75: FILE: drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c:58:
+	if (!rtlpriv->rtlhal.pfirmware) {
+		pr_err("Can't alloc buffer for fw\n");

> +               return 1;

returning standard error number will be better, but others have been
there....

> +       }
> +
> +       rtlpriv->max_fw_size = 0x8000;
> +       pr_info("Driver for Realtek RTL8192DU WLAN interface\n");
> +       pr_info("Loading firmware file %s\n", fw_name);
> +
> +       /* request fw */
> +       err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
> +                                     rtlpriv->io.dev, GFP_KERNEL, hw,
> +                                     rtl_fw_cb);
> +       if (err) {
> +               pr_err("Failed to request firmware!\n");
> +               kfree(rtlpriv->rtlhal.pfirmware);
> +               rtlpriv->rtlhal.pfirmware = NULL;
> +               return 1;
> +       }
> +
> +       return 0;
> +}
> +
> +static void rtl92du_deinit_sw_vars(struct ieee80211_hw *hw)
> +{
> +       struct rtl_priv *rtlpriv = rtl_priv(hw);
> +
> +       kfree(rtlpriv->rtlhal.pfirmware);
> +       rtlpriv->rtlhal.pfirmware = NULL;
> +}
> +
> +static struct rtl_hal_ops rtl8192du_hal_ops = {

static const (also below tables)

[...]

> +
> +MODULE_AUTHOR("lizhaoming      <chaoming_li@realsil.com.cn>");
> +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
> +MODULE_AUTHOR("Larry Finger    <Larry.Finger@lwfinger.net>");

Author should be you. 

> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("Realtek 8192DU 802.11an Dual Mac USB wireless");
> +MODULE_FIRMWARE("rtlwifi/rtl8192dufw.bin");

Normally, we put MODULE_xxx at bottom of files.

> +
> +module_param_named(swenc, rtl92du_mod_params.sw_crypto, bool, 0444);
> +module_param_named(debug_level, rtl92du_mod_params.debug_level, int, 0644);
> +module_param_named(ips, rtl92du_mod_params.inactiveps, bool, 0444);
> +module_param_named(swlps, rtl92du_mod_params.swctrl_lps, bool, 0444);
> +module_param_named(debug_mask, rtl92du_mod_params.debug_mask, ullong, 0644);
> +MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
> +MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 0)\n");
> +MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
> +MODULE_PARM_DESC(debug_level, "Set debug level (0-5) (default 0)");
> +MODULE_PARM_DESC(debug_mask, "Set debug mask (default 0)");
> +
> +/* Add global mutex to solve the problem that
> + * dual mac register operation on the same time
> + */

I see the reason now, it seems work.

> +DEFINE_MUTEX(globalmutex_power);
> +DEFINE_MUTEX(globalmutex_for_fwdownload);
> +DEFINE_MUTEX(globalmutex_for_power_and_efuse);
> +DEFINE_MUTEX(globalmutex_for_mac0_2g_mac1_5g);

The consumers of globalmutex_for_mac0_2g_mac1_5g are complex. Why do they
check mutex_is_locked()? Race conditions between two instances?


> +
> +#define USB_VENDOR_ID_REALTEK          0x0bda
> +
> +static const struct usb_device_id rtl8192d_usb_ids[] = {
> +       {RTL_USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8193, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8194, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8111, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x0193, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8171, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(USB_VENDOR_ID_REALTEK, 0xe194, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x2019, 0xab2c, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x2019, 0xab2d, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x2019, 0x4903, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x2019, 0x4904, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x07b8, 0x8193, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x20f4, 0x664b, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x04dd, 0x954f, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x04dd, 0x96a6, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x050d, 0x110a, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x050d, 0x1105, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x050d, 0x120a, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x1668, 0x8102, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x0930, 0x0a0a, rtl92du_hal_cfg)},
> +       {RTL_USB_DEVICE(0x2001, 0x330c, rtl92du_hal_cfg)},
> +       {}
> +};
> +
> +MODULE_DEVICE_TABLE(usb, rtl8192d_usb_ids);
> +
> +static int rtl8192du_probe(struct usb_interface *intf,
> +                          const struct usb_device_id *id)
> +{
> +       return rtl_usb_probe(intf, id, &rtl92du_hal_cfg);
> +}
> +
> +static struct usb_driver rtl8192du_driver = {
> +       .name = "rtl8192du",
> +       .probe = rtl8192du_probe,
> +       .disconnect = rtl_usb_disconnect,
> +       .id_table = rtl8192d_usb_ids,
> +       .disable_hub_initiated_lpm = 1,
> +};
> +
> +module_usb_driver(rtl8192du_driver);
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.h
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.h
> new file mode 100644
> index 000000000000..364d9a471dc0
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Copyright(c) 2009-2012  Realtek Corporation.*/
> +
> +#ifndef __RTL92DE_SW_H__
> +#define __RTL92DE_SW_H__

8192DU

> +
> +extern struct mutex globalmutex_power;
> +extern struct mutex globalmutex_for_fwdownload;
> +extern struct mutex globalmutex_for_power_and_efuse;
> +extern struct mutex globalmutex_for_mac0_2g_mac1_5g;
> +
> +#endif
> --
> 2.43.2

  reply	other threads:[~2024-03-22  6:05 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 19:32 [PATCH v3 00/12] wifi: rtlwifi: Add new rtl8192du driver Bitterblue Smith
2024-03-20 19:33 ` [PATCH v3 01/12] wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power Bitterblue Smith
2024-03-22  1:25   ` Ping-Ke Shih
2024-03-20 19:34 ` [PATCH v3 02/12] wifi: rtlwifi: Move code from rtl8192de to rtl8192d-common Bitterblue Smith
2024-03-22  2:14   ` Ping-Ke Shih
2024-03-26 13:02     ` Bitterblue Smith
2024-03-20 19:35 ` [PATCH v3 03/12] wifi: rtlwifi: Adjust rtl8192d-common for USB Bitterblue Smith
2024-03-22  3:41   ` Ping-Ke Shih
2024-03-20 19:36 ` [PATCH v3 04/12] wifi: rtlwifi: Add rtl8192du/table.{c,h} Bitterblue Smith
2024-03-22  3:46   ` Ping-Ke Shih
2024-03-26 17:30     ` Bitterblue Smith
2024-03-27  9:18       ` Kalle Valo
2024-03-27  9:30         ` Ping-Ke Shih
2024-03-27 12:36           ` Bitterblue Smith
2024-03-27 12:42             ` Ping-Ke Shih
2024-03-27 12:53             ` Kalle Valo
2024-03-27 16:34           ` Jeff Johnson
2024-03-20 19:37 ` [PATCH v3 05/12] wifi: rtlwifi: Add rtl8192du/hw.{c,h} Bitterblue Smith
2024-03-22  4:02   ` Ping-Ke Shih
2024-03-20 19:38 ` [PATCH v3 06/12] wifi: rtlwifi: Add rtl8192du/phy.{c,h} Bitterblue Smith
2024-03-22  5:22   ` Ping-Ke Shih
2024-03-26 22:13     ` Bitterblue Smith
2024-03-27  1:19       ` Ping-Ke Shih
2024-03-20 19:39 ` [PATCH v3 07/12] wifi: rtlwifi: Add rtl8192du/trx.{c,h} Bitterblue Smith
2024-03-22  5:32   ` Ping-Ke Shih
2024-03-20 19:40 ` [PATCH v3 08/12] wifi: rtlwifi: Add rtl8192du/rf.{c,h} Bitterblue Smith
2024-03-22  5:35   ` Ping-Ke Shih
2024-03-20 19:41 ` [PATCH v3 09/12] wifi: rtlwifi: Add rtl8192du/fw.{c,h} and rtl8192du/led.{c,h} Bitterblue Smith
2024-03-22  5:42   ` Ping-Ke Shih
2024-03-20 19:42 ` [PATCH v3 10/12] wifi: rtlwifi: Add rtl8192du/dm.{c,h} Bitterblue Smith
2024-03-22  5:48   ` Ping-Ke Shih
2024-03-20 19:43 ` [PATCH v3 11/12] wifi: rtlwifi: Add rtl8192du/sw.{c,h} Bitterblue Smith
2024-03-22  6:04   ` Ping-Ke Shih [this message]
2024-03-27 14:07     ` Bitterblue Smith
2024-03-27 18:48       ` Kalle Valo
2024-03-27 22:53         ` Bitterblue Smith
2024-03-28  1:46           ` Ping-Ke Shih
2024-03-28 13:31             ` Bitterblue Smith
2024-03-29  0:34               ` Ping-Ke Shih
2024-03-31 18:48                 ` Bitterblue Smith
2024-04-01  1:21                   ` Ping-Ke Shih
2024-04-07 12:03                     ` Bitterblue Smith
2024-04-08  2:45                       ` Ping-Ke Shih
2024-04-08  9:01                         ` Bitterblue Smith
2024-04-09  0:27                           ` Ping-Ke Shih
2024-04-09 11:16                             ` Bitterblue Smith
2024-03-28  1:49       ` Ping-Ke Shih
2024-03-20 19:44 ` [PATCH v3 12/12] wifi: rtlwifi: Enable the new rtl8192du driver Bitterblue Smith
2024-03-22  6:06   ` Ping-Ke Shih
2024-03-21  1:10 ` [PATCH v3 00/12] wifi: rtlwifi: Add " Stefan Lippers-Hollmann
2024-03-22  6:13 ` [PATCH v3 01/12] wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f86a40493745a53ff73083f87b3e8fae215eac77.camel@realtek.com \
    --to=pkshih@realtek.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=chewitt@libreelec.tv \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rtl8821cerfe2@gmail.com \
    --cc=s.l-h@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).