Bluetooth: btintel_pcie: Set MAC_INIT in get_mac_access()
PATCH 1/1 Bluetooth: btintel_pcie: Set MAC_INIT in get_mac_access()
Every caller that read device memory had to call btintel_pcie_mac_init() before btintel_pcie_get_mac_access(). Fold the MAC_INIT handling into btintel_pcie_get_mac_access() and drop the separate helper along with its three call sites.
Unlike btintel_pcie_mac_init(), which also modified FUNC_ENA, FUNC_INIT, BUS_MASTER_DISCON, and SW_RESET, leave those bits untouched as they are not needed for MAC access. Set only MAC_INIT and MAC_ACCESS_REQ with a single register write when either bit is not already set.
--- drivers/bluetooth/btintel_pcie.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-)
drivers/bluetooth/btintel_pcie.c +6 -25
@@ -989,31 +989,18 @@ static int btintel_pcie_reset_bt(struct btintel_pcie_data *data)return reg ==0 ?0 : -ENODEV ; } -static void btintel_pcie_mac_init (struct btintel_pcie_data *data) -{ -u32 reg; - -/* Set MAC_INIT bit to start primary bootloader */ - reg =btintel_pcie_rd_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG ); - reg &= ~(BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_INIT | -BTINTEL_PCIE_CSR_FUNC_CTRL_BUS_MASTER_DISCON | -BTINTEL_PCIE_CSR_FUNC_CTRL_SW_RESET ); - reg |= (BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_ENA | -BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT ); -btintel_pcie_wr_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG , reg); -} -static int btintel_pcie_get_mac_access (struct btintel_pcie_data *data) { -u32 reg; +u32 reg, val;int retry =15 ; +const u32 req =BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT | +BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ ; reg =btintel_pcie_rd_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG ); -if (!(reg &BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ )) { - reg |=BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ ; -btintel_pcie_wr_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG , reg); - } + val = reg | req; +if (val != reg) +btintel_pcie_wr_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG , val); do { reg = btintel_pcie_rd_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG);
@@ -1951,8 +1938,6 @@ static int btintel_parse_mbox_tlv(struct btintel_pcie_data *data)if (!buffer)return -ENOMEM ; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buffer, tbl_addr, buffer_len);if (err)
@@ -2643,8 +2628,6 @@ static void btintel_pcie_read_hwexp(struct btintel_pcie_data *data)if (!buf) goto exit_on_error; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buf, addr, len);if (err) goto exit_on_error;
@@ -2732,8 +2715,6 @@ static int btintel_pcie_dump_fwtrigger_event(struct btintel_pcie_data *data)if (!buf)return -ENOMEM ; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buf, data->debug_evt_addr, len);if (err)
Signature · 1 line
2.54.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1197196/
---Test result---
Test Summary:
CheckPatch PASS 0.94 seconds VerifyFixes PASS 0.93 seconds VerifySignedoff PASS 14.61 seconds GitLint PASS 2.08 seconds SubjectPrefix PASS 0.13 seconds BuildKernel PASS 31.97 seconds CheckAllWarning PASS 36.57 seconds CheckSparse PASS 39.58 seconds BuildKernel32 PASS 32.23 seconds CheckKernelLLVM PASS 36.08 seconds TestRunnerSetup PASS 765.49 seconds IncrementalBuild PASS 30.37 seconds
https://github.com/bluez/bluetooth-next/pull/1030
---
Regards,
Linux Bluetooth
Dear Kiran,
Thank you for your patch.
Am 30.10.26 um 15:29 schrieb Kiran K:
Quoted 2 lines
Every caller that read device memory had to call
btintel_pcie_mac_init()beforebtintel_pcie_get_mac_access().
I’d use present tense: Currently, every caller reading device memory has to call …
Quoted 2 lines
Fold the
MAC_INIThandling intobtintel_pcie_get_mac_access()and drop the separate helper along with its three call sites.
From the diff, it’s not clear, why moving it to btintel_pcie_mac_init() does not change behavior.
Quoted 4 lines
Unlike
btintel_pcie_mac_init(), which also modifiedFUNC_ENA,FUNC_INIT,BUS_MASTER_DISCON, andSW_RESET, leave those bits untouched as they are not needed for MAC access. Set onlyMAC_INITandMAC_ACCESS_REQwith a single register write when either bit is not already set.
I’d make it two commits.
Quoted 68 lines
Fixes b9465e6670a2 ("Bluetooth: btintel_pcie: Read hardware exception data")Assisted-by Copilot:Gemini 4 ArgonSigned-off-by Kiran K <[email protected]>--- drivers/bluetooth/btintel_pcie.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-)drivers/bluetooth/btintel_pcie.c +6
-23@@ -989,31 +989,18 @@ static int btintel_pcie_reset_bt(struct btintel_pcie_data *data)return reg ==0 ?0 : -ENODEV ; } -static void btintel_pcie_mac_init (struct btintel_pcie_data *data) -{ -u32 reg; - -/* Set MAC_INIT bit to start primary bootloader */ - reg =btintel_pcie_rd_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG ); - reg &= ~(BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_INIT | -BTINTEL_PCIE_CSR_FUNC_CTRL_BUS_MASTER_DISCON | -BTINTEL_PCIE_CSR_FUNC_CTRL_SW_RESET ); - reg |= (BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_ENA | -BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT ); -btintel_pcie_wr_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG , reg); -} -static int btintel_pcie_get_mac_access (struct btintel_pcie_data *data) { -u32 reg; +u32 reg, val;int retry =15 ; +const u32 req =BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT | +BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ ; reg =btintel_pcie_rd_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG ); -if (!(reg &BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ )) { - reg |=BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ ; -btintel_pcie_wr_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG , reg); - } + val = reg | req; +if (val != reg) +btintel_pcie_wr_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG , val); do { reg = btintel_pcie_rd_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG);@@ -1951,8 +1938,6 @@ static int btintel_parse_mbox_tlv(struct btintel_pcie_data *data)if (!buffer)return -ENOMEM ; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buffer, tbl_addr, buffer_len);if (err)@@ -2643,8 +2628,6 @@ static void btintel_pcie_read_hwexp(struct btintel_pcie_data *data)if (!buf) goto exit_on_error; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buf, addr, len);if (err) goto exit_on_error;
drivers/bluetooth/btintel_pcie.c static int btintel_pcie_dump_fwtrigger_event(struct btintel_pcie_data *data) · line 2720
Quoted 8 lines
drivers/bluetooth/btintel_pcie.c +0
-2@@ -2732,8 +2715,6 @@ static int btintel_pcie_dump_fwtrigger_event(struct btintel_pcie_data *data)if (!buf)return -ENOMEM ; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buf, data->debug_evt_addr, len);if (err)
Kind regards,
Paul
Hi Paul,
Thanks for your comments.
Quoted 6 lines
Subject: Re: [PATCH v1] Bluetooth:
btintel_pcie: SetMAC_INITinget_mac_access()Dear Kiran,
Quoted 7 lines
Thank you for your patch.
Am 30.10.26 um 15:29 schrieb Kiran K:
Quoted 2 lines
Every caller that read device memory had to call
btintel_pcie_mac_init()beforebtintel_pcie_get_mac_access().I’d use present tense: Currently, every caller reading device memory has to call
Ack.
Quoted 7 lines
…
Quoted 2 lines
Fold the
MAC_INIThandling intobtintel_pcie_get_mac_access()and drop the separate helper along with its three call sites.From the diff, it’s not clear, why moving it to
btintel_pcie_mac_init()does not change behavior.
As for the other bits ( FUNC_ENA , FUNC_INIT , BUS_MASTER_DISCON , and SW_RESET ), only MAC_INIT and MAC_ACCESS_REQ in the function control register need to be programmed to acquire MAC access. btintel_pcie_mac_init() was incorrectly programming those additional bits-which are not relevant to MAC access-though doing so did not cause any observed side effects. I will clarify this in the v2 commit message.
Quoted 9 lines
Quoted 3 lines
Unlike
btintel_pcie_mac_init(), which also modifiedFUNC_ENA,FUNC_INIT,BUS_MASTER_DISCON, andSW_RESET, leave those bitsuntouched
Quoted 2 lines
as they are not needed for MAC access. Set only
MAC_INITandMAC_ACCESS_REQwith a single register write when either bit is not alreadyset.
I’d make it two commits.
Sure, I will split this into two patches in v2:
1. Drop the unnecessary bit modifications.
2. Fold MAC_INIT into btintel_pcie_get_mac_access() and remove btintel_pcie_mac_init().
Quoted 92 lines
drivers/bluetooth/btintel_pcie.c static int btintel_pcie_reset_bt(struct
Quoted 15 lines
Fixes b9465e6670a2 ("Bluetooth: btintel_pcie: Read hardware exceptiondata")
Assisted-by Copilot:Gemini 4 ArgonSigned-off-by Kiran K <[email protected]>--- drivers/bluetooth/btintel_pcie.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-)drivers/bluetooth/btintel_pcie.c +0
-0@@ -989,31 +989,18 @@ static int btintel_pcie_reset_bt(struct
btintel_pcie_data*data)drivers/bluetooth/btintel_pcie.c static int btintel_pcie_reset_bt(struct btintel_pcie_data *data)
Quoted 8 lines
drivers/bluetooth/btintel_pcie.c +0
-5return reg ==0 ?0 : -ENODEV ; } -static void btintel_pcie_mac_init(struct btintel_pcie_data *data) -{ -u32 reg; - -/* Set MAC_INIT bit to start primary bootloader */ - reg = btintel_pcie_rd_reg32(data,
BTINTEL_PCIE_CSR_FUNC_CTRL_REG);drivers/bluetooth/btintel_pcie.c static int btintel_pcie_reset_bt(struct btintel_pcie_data *data) · line 1005
Quoted 2 lines
drivers/bluetooth/btintel_pcie.c +0
-2- reg &= ~(BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_INIT | -
BTINTEL_PCIE_CSR_FUNC_CTRL_BUS_MASTER_DISCON|Quoted 5 lines
drivers/bluetooth/btintel_pcie.c +0
-5- BTINTEL_PCIE_CSR_FUNC_CTRL_SW_RESET); - reg |= (BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_ENA | -BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT ); -btintel_pcie_wr_reg32 (data,BTINTEL_PCIE_CSR_FUNC_CTRL_REG , reg); -}drivers/bluetooth/btintel_pcie.c static int btintel_pcie_reset_bt(struct btintel_pcie_data *data)
Quoted 10 lines
drivers/bluetooth/btintel_pcie.c +3
-2-static int btintel_pcie_get_mac_access (struct btintel_pcie_data *data) { -u32 reg; +u32 reg, val;int retry =15 ; +const u32 req =BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT | +BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ ; reg = btintel_pcie_rd_reg32(data,
BTINTEL_PCIE_CSR_FUNC_CTRL_REG);drivers/bluetooth/btintel_pcie.c static int btintel_pcie_reset_bt(struct btintel_pcie_data *data)
Quoted 4 lines
drivers/bluetooth/btintel_pcie.c +0
-3-if (!(reg &BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ )) { - reg |=BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ ; - btintel_pcie_wr_reg32(data,
BTINTEL_PCIE_CSR_FUNC_CTRL_REG, reg);drivers/bluetooth/btintel_pcie.c static int btintel_pcie_reset_bt(struct btintel_pcie_data *data)
Quoted 4 lines
drivers/bluetooth/btintel_pcie.c +3
-1- } + val = reg | req; +if (val != reg) + btintel_pcie_wr_reg32(data,
BTINTEL_PCIE_CSR_FUNC_CTRL_REG, val);drivers/bluetooth/btintel_pcie.c static int btintel_pcie_reset_bt(struct · line 1004
Quoted 3 lines
drivers/bluetooth/btintel_pcie.c +0
-0do { reg = btintel_pcie_rd_reg32(data,
BTINTEL_PCIE_CSR_FUNC_CTRL_REG);drivers/bluetooth/btintel_pcie.c static int btintel_parse_mbox_tlv(struct
Quoted 1 line
drivers/bluetooth/btintel_pcie.c +0
-0@@ -1951,8 +1938,6 @@ static int btintel_parse_mbox_tlv(struct
btintel_pcie_data*data)drivers/bluetooth/btintel_pcie.c static void btintel_pcie_read_hwexp(struct
Quoted 9 lines
drivers/bluetooth/btintel_pcie.c +0
-2if (!buffer)return -ENOMEM ; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buffer, tbl_addr, buffer_len);if (err)@@ -2643,8 +2628,6 @@ static void btintel_pcie_read_hwexp(struct
btintel_pcie_data*data)drivers/bluetooth/btintel_pcie.c static int
Quoted 9 lines
drivers/bluetooth/btintel_pcie.c +0
-2if (!buf) goto exit_on_error; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buf, addr, len);if (err) goto exit_on_error;@@ -2732,8 +2715,6 @@ static int
btintel_pcie_dump_fwtrigger_event(struct btintel_pcie_data *data)drivers/bluetooth/btintel_pcie.c static int btintel_pcie_dump_fwtrigger_event(struct btintel_pcie_data *data) · line 2720
Quoted 8 lines
drivers/bluetooth/btintel_pcie.c +0
-2if (!buf)return -ENOMEM ; -btintel_pcie_mac_init (data); - err =btintel_pcie_read_device_mem (data, buf, data->debug_evt_addr, len);if (err)Kind regards,
Quoted 1 line
Paul
Thanks,
Kiran