All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] Bluetooth: btintel_pcie: Set MAC_INIT in get_mac_access()
@ 2026-10-30 14:29 Kiran K
  2026-10-30 16:42 ` [v1] " bluez.test.bot
  2026-10-30 18:44 ` [PATCH v1] " Paul Menzel
  0 siblings, 2 replies; 3+ messages in thread
From: Kiran K @ 2026-10-30 14:29 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: chethan.tumkur.narayan, chandrashekar.devegowda, Kiran K

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.

Fixes: b9465e6670a2 ("Bluetooth: btintel_pcie: Read hardware exception data")
Assisted-by: Copilot:Gemini 4 Argon
Signed-off-by: Kiran K <kiran.k@intel.com>
---
 drivers/bluetooth/btintel_pcie.c | 31 ++++++-------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 7d84c8106cf1..025c4c64d020 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -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)
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [v1] Bluetooth: btintel_pcie: Set MAC_INIT in get_mac_access()
  2026-10-30 14:29 [PATCH v1] Bluetooth: btintel_pcie: Set MAC_INIT in get_mac_access() Kiran K
@ 2026-10-30 16:42 ` bluez.test.bot
  2026-10-30 18:44 ` [PATCH v1] " Paul Menzel
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-10-30 16:42 UTC (permalink / raw)
  To: linux-bluetooth, kiran.k

[-- Attachment #1: Type: text/plain, Size: 1021 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] Bluetooth: btintel_pcie: Set MAC_INIT in get_mac_access()
  2026-10-30 14:29 [PATCH v1] Bluetooth: btintel_pcie: Set MAC_INIT in get_mac_access() Kiran K
  2026-10-30 16:42 ` [v1] " bluez.test.bot
@ 2026-10-30 18:44 ` Paul Menzel
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Menzel @ 2026-10-30 18:44 UTC (permalink / raw)
  To: Kiran K; +Cc: linux-bluetooth, chethan.tumkur.narayan, chandrashekar.devegowda

Dear Kiran,


Thank you for your patch.

Am 30.10.26 um 15:29 schrieb Kiran K:
> Every caller that read device memory had to call
> btintel_pcie_mac_init() before btintel_pcie_get_mac_access().

I’d use present tense: Currently, every caller reading device memory has 
to call …

> Fold the MAC_INIT handling into btintel_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.

> 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.

I’d make it two commits.

> Fixes: b9465e6670a2 ("Bluetooth: btintel_pcie: Read hardware exception data")
> Assisted-by: Copilot:Gemini 4 Argon
> Signed-off-by: Kiran K <kiran.k@intel.com>
> ---
>   drivers/bluetooth/btintel_pcie.c | 31 ++++++-------------------------
>   1 file changed, 6 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
> index 7d84c8106cf1..025c4c64d020 100644
> --- a/drivers/bluetooth/btintel_pcie.c
> +++ b/drivers/bluetooth/btintel_pcie.c
> @@ -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)


Kind regards,

Paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-30 18:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 14:29 [PATCH v1] Bluetooth: btintel_pcie: Set MAC_INIT in get_mac_access() Kiran K
2026-10-30 16:42 ` [v1] " bluez.test.bot
2026-10-30 18:44 ` [PATCH v1] " Paul Menzel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.