linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pkshih <pkshih@realtek.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>,
	Brian Norris <briannorris@chromium.org>
Cc: "kvalo@codeaurora.org" <kvalo@codeaurora.org>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH 04/24] rtw89: add debug files
Date: Tue, 13 Jul 2021 11:26:26 +0000	[thread overview]
Message-ID: <bfc00689c551406a88f77bf424aabba0@realtek.com> (raw)
In-Reply-To: <20210713045022.bki4tlcxnm3pwqdv@pengutronix.de>



> -----Original Message-----
> From: Oleksij Rempel [mailto:o.rempel@pengutronix.de]
> Sent: Tuesday, July 13, 2021 12:50 PM
> To: Brian Norris
> Cc: Pkshih; kvalo@codeaurora.org; linux-wireless@vger.kernel.org
> Subject: Re: [PATCH 04/24] rtw89: add debug files
> 
> On Mon, Jul 12, 2021 at 06:57:37PM -0700, Brian Norris wrote:
> > On Mon, Jul 5, 2021 at 1:59 AM Pkshih <pkshih@realtek.com> wrote:
> > > > -----Original Message-----
> > > > From: Oleksij Rempel [mailto:o.rempel@pengutronix.de]
> >
> > > > Based on this and other part of this driver I would recommend to use
> > > > regmap. It will provide to additional interface for the register
> > > > access. And typically for the network devices we have an ethtool
> > > > interface for that.
> > > >
> > >
> > > Could I know the 'regmap' you mentioned?
> >
> > include/linux/regmap.h
> > drivers/base/regmap/
> >
> > It's a driver framework and API for abstracting register accesses,
> > whether they are accessed directly via MMIO, or behind some kind of
> > indirect bus (I2C, SPI, etc.). It also happens to have its own debugfs
> > operators for doing various kinds of register get/set/dump. So if you
> > can successfully teach your driver to use it, then you don't need to
> > implement your own debugfs files for it.

Thanks for the information. I'll study to see if it is possible to use
regmap.

> >
> > I've only ever used regmap with Device Tree systems (which can more
> > easily specify syscon nodes, etc. -- see
> > Documentation/devicetree/bindings/regmap/regmap.txt). I'm totally
> > unfamiliar how to use this with ACPI (which I'm sure you want to
> > support). I'm sure it's possible somehow.
> >
> > FWIW, search engines turn up a few basic articles about it, if you
> > find its documentation or code examples too sparse:
> >
> https://www.collabora.com/news-and-blog/blog/2020/05/27/using-regmaps-to-make-linux-drivers-more-g
> eneric/
> 
> There are not ACPI specific register accesses in this driver. It is
> using simple readl/writel for the PCI accesses.
> 
> This driver would need to use devm_regmap_init() and register own
> regmap_bus. I motivate to use it not only to cover debugfs use case:
> 
> 1. Current driver implements only PCI access, but potentially wont to
> support SDIO and USB buses:
> 	drivers/net/wireless/realtek/rtw89/core.h
> 	enum rtw89_hci_type {
> 		RTW89_HCI_TYPE_PCIE,
> 		RTW89_HCI_TYPE_USB,
> 		RTW89_HCI_TYPE_SDIO,
> 	};
> 
> 
> SDIO and USB buses may return error on any access. So, driver
> should test if return value is error on every access. regmap read/write
> functions separate error value from actual register read value and
> motivate to handle errors in the driver. Suddenly not every mainline driver is
> doing it.

I know there are many changes if this driver supports SDIO and USB; not only
IO error but also running context. However, it is hard to me to imagine 
how to solve these problems before starting to implement.

I'll prepare my knowledge of regmap in advance.

> 
> 2. Current driver implements patter based error detection for the PCI
> bus:
> 
> 	static u32 rtw89_pci_ops_read32_cmac(struct rtw89_dev *rtwdev, u32 addr)
> 	{
> 		struct rtw89_pci *rtwpci = (struct rtw89_pci *)rtwdev->priv;
> 		u32 val = readl(rtwpci->mmap + addr);
> 		int count;
> 
> 		for (count = 0; ; count++) {
> 			if (val != RTW89_R32_DEAD)
> 				return val;
> 			if (count >= MAC_REG_POOL_COUNT) {
> 				rtw89_warn(rtwdev, "addr %#x = %#x\n", addr, val);
> 				return RTW89_R32_DEAD;
> 			}
> 			rtw89_pci_ops_write32(rtwdev, R_AX_CK_EN, B_AX_CMAC_ALLCKEN);
> 			val = readl(rtwpci->mmap + addr);
> 		}
> 
> 		return val;
> 	}
> 

This isn't due to PCI bus error. Instead, this is because driver and firmware
can read the same register simultaneously, so we retry to get correct value.

> and handle this patter only in one place:
> 	....
> 	int rtw89_mac_check_mac_en(struct rtw89_dev *rtwdev, u8 mac_idx,
> 				   enum rtw89_mac_hwmod_sel sel)
> 	{
> 		....
> 		r_val = rtw89_read32(rtwdev, R_AX_SYS_ISO_CTRL_EXTEND);
> 
> 		....
> 
> 		if (r_val == RTW89_R32_EA || r_val == RTW89_R32_DEAD ||
> 		    (val & r_val) != val)
> 			return -EFAULT;
> 
> 		return 0;
> 	}
> 
> potentially this should be done on every read attempt for the PCI, and
> on every read/write for SDIO and USB buses.

The checking statement is not to check if reading error, but check if a certain
MAC function block is power-on or not.

> 
> 3. This driver has traces of watchdog support on the firmware side, so
> potentially, firmware can return error on any access if it was reset by
> the watchdog.

Firmware can't know if driver access error. It only detects hardware abnormal, and
send error code to driver to reset hardware, even do reconnection.

This depends on the frequency it happens. The user experience would be better
if we do softly reset, like we retry reading mentioned in 2. 

> 
> 4. regmap provide a way to define support register ranges and will warn
> if calculated register offset goes outside of this range.

Got it.

> 
> 5. regamp is endianness aware and will help to make this driver work
> properly on big-endian systems.
> 

As I know, the result of register access is CPU order; there's no endian issue.

In this driver, we must consider the endian of exchange between driver/firmware,
and we write these codes carefully with le32 type and le_xxx API, like le32_set_bits().
I think this driver can run on big-endian machines.

--
Ping-Ke


  reply	other threads:[~2021-07-13 11:26 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18  6:46 [PATCH 00/24] rtw89: add Realtek 802.11ax driver Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 01/24] rtw89: add CAM files Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 02/24] rtw89: add BT coexistence files Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 03/24] rtw89: add core and trx files Ping-Ke Shih
2021-07-09 17:32   ` Oleksij Rempel
2021-07-12  6:23     ` Pkshih
2021-07-15 18:57   ` Brian Norris
2021-07-16  2:00     ` Pkshih
2021-06-18  6:46 ` [PATCH 04/24] rtw89: add debug files Ping-Ke Shih
2021-07-02  7:23   ` Oleksij Rempel
2021-07-02 17:08     ` Brian Norris
2021-07-02 17:57       ` Oleksij Rempel
2021-07-02 18:38         ` Brian Norris
2021-07-02 19:32           ` Oleksij Rempel
2021-07-02 20:00             ` Brian Norris
2021-07-03  4:15               ` Oleksij Rempel
2021-07-13  1:40                 ` Brian Norris
2021-07-05  8:58           ` Pkshih
2021-07-05  9:09             ` Oleksij Rempel
2021-07-05  8:08         ` Kalle Valo
2021-07-05  9:23           ` Oleksij Rempel
2021-07-05  8:58     ` Pkshih
2021-07-13  1:57       ` Brian Norris
2021-07-13  4:50         ` Oleksij Rempel
2021-07-13 11:26           ` Pkshih [this message]
2021-06-18  6:46 ` [PATCH 05/24] rtw89: add efuse files Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 06/24] rtw89: add files to download and communicate with firmware Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 07/24] rtw89: add MAC files Ping-Ke Shih
2021-07-09 17:38   ` Oleksij Rempel
2021-07-09 18:16     ` Johannes Berg
2021-07-10  4:58       ` Oleksij Rempel
2021-07-12  1:51         ` Pkshih
2021-07-12  6:23     ` Pkshih
2021-06-18  6:46 ` [PATCH 08/24] rtw89: implement mac80211 ops Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 09/24] rtw89: add pci files Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 10/24] rtw89: add phy files Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 11/24] rtw89: define register names Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 12/24] rtw89: add regulatory support Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 13/24] rtw89: 8852a: add 8852a specific files Ping-Ke Shih
2021-07-10  5:27   ` Oleksij Rempel
2021-07-12  6:24     ` Pkshih
2021-06-18  6:46 ` [PATCH 14/24] rtw89: 8852a: add 8852a RFK files Ping-Ke Shih
2021-07-09 17:41   ` Oleksij Rempel
2021-07-12  6:23     ` Pkshih
2021-07-15  3:33     ` Pkshih
2021-07-15  3:59       ` Oleksij Rempel
2021-06-18  6:46 ` [PATCH 15/24] rtw89: 8852a: add 8852a RFK tables Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 16/24] rtw89: 8852a: add 8852a tables (1 of 5) Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 17/24] rtw89: 8852a: add 8852a tables (2 " Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 18/24] rtw89: 8852a: add 8852a tables (3 " Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 19/24] rtw89: 8852a: add 8852a tables (4 " Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 20/24] rtw89: 8852a: add 8852a tables (5 " Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 21/24] rtw89: add ser to recover error reported by firmware Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 22/24] rtw89: add PS files Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 23/24] rtw89: add SAR files Ping-Ke Shih
2021-06-18  6:46 ` [PATCH 24/24] rtw89: add Kconfig and Makefile Ping-Ke Shih
2021-06-19  3:18   ` kernel test robot
2021-06-25  8:54     ` Pkshih
2021-06-19  3:18   ` kernel test robot
2021-06-18  7:11 ` [PATCH 00/24] rtw89: add Realtek 802.11ax driver Pkshih
2021-06-23  6:29 ` Aaron Ma
2021-06-30  4:52   ` Aaron Ma

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=bfc00689c551406a88f77bf424aabba0@realtek.com \
    --to=pkshih@realtek.com \
    --cc=briannorris@chromium.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=o.rempel@pengutronix.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).