diff mbox series

[v1,3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag

Message ID 20181106120528.30342-4-bgodavar@codeaurora.org (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show
Series [v1,1/4] Bluetooth: hci_qca: use wait_until_sent() for power pulses | expand

Commit Message

Balakrishna Godavarthi Nov. 6, 2018, 12:05 p.m. UTC
During hci down we are sending reset command to chip, which
is not required for wcn3990, as hdev->shutdown() will turn off the
regulators.

Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
---
 drivers/bluetooth/hci_qca.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Marcel Holtmann Nov. 6, 2018, 12:33 p.m. UTC | #1
Hi Balakrishna,

> During hci down we are sending reset command to chip, which
> is not required for wcn3990, as hdev->shutdown() will turn off the
> regulators.
> 
> Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
> ---
> drivers/bluetooth/hci_qca.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 8301663f0004..97b57e0f4725 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
> 		 */
> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
> 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
> +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
> 		hu->hdev->shutdown = qca_power_off;
> 		ret = qca_wcn3990_init(hu);
> 		if (ret)

I am pretty certain that you didn’t want this quirk:

        /* When this quirk is set, the HCI Reset command is send when            
         * closing the transport instead of when opening it.

This quirk is for Bluetooth 1.0b devices where the HCI_Reset behavior was not clear or for devices that actually misbehave with the initial HCI_Reset.

In addition, you commit message is totally misleading. That is not what is happening with this quirk.

Regards

Marcel
Balakrishna Godavarthi Nov. 6, 2018, 12:44 p.m. UTC | #2
Hi Marcel,

On 2018-11-06 18:03, Marcel Holtmann wrote:
> Hi Balakrishna,
> 
>> During hci down we are sending reset command to chip, which
>> is not required for wcn3990, as hdev->shutdown() will turn off the
>> regulators.
>> 
>> Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
>> ---
>> drivers/bluetooth/hci_qca.c | 1 +
>> 1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>> index 8301663f0004..97b57e0f4725 100644
>> --- a/drivers/bluetooth/hci_qca.c
>> +++ b/drivers/bluetooth/hci_qca.c
>> @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
>> 		 */
>> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
>> 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
>> +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
>> 		hu->hdev->shutdown = qca_power_off;
>> 		ret = qca_wcn3990_init(hu);
>> 		if (ret)
> 
> I am pretty certain that you didn’t want this quirk:
> 
>         /* When this quirk is set, the HCI Reset command is send when
> 
>          * closing the transport instead of when opening it.
> 
> This quirk is for Bluetooth 1.0b devices where the HCI_Reset behavior
> was not clear or for devices that actually misbehave with the initial
> HCI_Reset.
> 
> In addition, you commit message is totally misleading. That is not
> what is happening with this quirk.
> 
> Regards
> 
> Marcel

My intention was reset command is not required when we do an hci down.
this is because of hdev->shutdown will turn off the regulators.
It is like turning off the chip. sending reset command after turning off 
the chip is not required.

I understand the usage of the quirk, will update the commit text.
Marcel Holtmann Nov. 6, 2018, 1:02 p.m. UTC | #3
Hi Balakrishna,

>>> During hci down we are sending reset command to chip, which
>>> is not required for wcn3990, as hdev->shutdown() will turn off the
>>> regulators.
>>> Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
>>> ---
>>> drivers/bluetooth/hci_qca.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>>> index 8301663f0004..97b57e0f4725 100644
>>> --- a/drivers/bluetooth/hci_qca.c
>>> +++ b/drivers/bluetooth/hci_qca.c
>>> @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
>>> 		 */
>>> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
>>> 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
>>> +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
>>> 		hu->hdev->shutdown = qca_power_off;
>>> 		ret = qca_wcn3990_init(hu);
>>> 		if (ret)
>> I am pretty certain that you didn’t want this quirk:
>>        /* When this quirk is set, the HCI Reset command is send when
>>         * closing the transport instead of when opening it.
>> This quirk is for Bluetooth 1.0b devices where the HCI_Reset behavior
>> was not clear or for devices that actually misbehave with the initial
>> HCI_Reset.
>> In addition, you commit message is totally misleading. That is not
>> what is happening with this quirk.
>> Regards
>> Marcel
> 
> My intention was reset command is not required when we do an hci down.
> this is because of hdev->shutdown will turn off the regulators.
> It is like turning off the chip. sending reset command after turning off the chip is not required.
> 
> I understand the usage of the quirk, will update the commit text.

you are papering over the issue. Actually hci_serdev.c:hci_uart_register_device() is the culprit with the legacy code copied over from hci_ldisc.c:hci_uart_register_dev(). I think there is no point doing all this legacy line discipline quirk handling until it is really needed. The serdev drivers are all for recent hardware.

That said, having moved over to a btuart.c approach and killed the whole hci_serdev.c thing would have been a lot better here. You will keep running in weird situations where 18 year old code keeps surprising you.

Regards

Marcel
Balakrishna Godavarthi Nov. 6, 2018, 1:14 p.m. UTC | #4
Hi Marcel,

On 2018-11-06 18:32, Marcel Holtmann wrote:
> Hi Balakrishna,
> 
>>>> During hci down we are sending reset command to chip, which
>>>> is not required for wcn3990, as hdev->shutdown() will turn off the
>>>> regulators.
>>>> Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
>>>> ---
>>>> drivers/bluetooth/hci_qca.c | 1 +
>>>> 1 file changed, 1 insertion(+)
>>>> diff --git a/drivers/bluetooth/hci_qca.c 
>>>> b/drivers/bluetooth/hci_qca.c
>>>> index 8301663f0004..97b57e0f4725 100644
>>>> --- a/drivers/bluetooth/hci_qca.c
>>>> +++ b/drivers/bluetooth/hci_qca.c
>>>> @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
>>>> 		 */
>>>> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
>>>> 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
>>>> +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
>>>> 		hu->hdev->shutdown = qca_power_off;
>>>> 		ret = qca_wcn3990_init(hu);
>>>> 		if (ret)
>>> I am pretty certain that you didn’t want this quirk:
>>>        /* When this quirk is set, the HCI Reset command is send when
>>>         * closing the transport instead of when opening it.
>>> This quirk is for Bluetooth 1.0b devices where the HCI_Reset behavior
>>> was not clear or for devices that actually misbehave with the initial
>>> HCI_Reset.
>>> In addition, you commit message is totally misleading. That is not
>>> what is happening with this quirk.
>>> Regards
>>> Marcel
>> 
>> My intention was reset command is not required when we do an hci down.
>> this is because of hdev->shutdown will turn off the regulators.
>> It is like turning off the chip. sending reset command after turning 
>> off the chip is not required.
>> 
>> I understand the usage of the quirk, will update the commit text.
> 
> you are papering over the issue. Actually
> hci_serdev.c:hci_uart_register_device() is the culprit with the legacy
> code copied over from hci_ldisc.c:hci_uart_register_dev(). I think
> there is no point doing all this legacy line discipline quirk handling
> until it is really needed. The serdev drivers are all for recent
> hardware.
> 
> That said, having moved over to a btuart.c approach and killed the
> whole hci_serdev.c thing would have been a lot better here. You will
> keep running in weird situations where 18 year old code keeps
> surprising you.

[Bala]: even i feel the same. they are lot such kind of HACK's we need 
to do with current arch.
         when can we expect btuart.c merged to bt-next. i think having 
btuart will helps us to have the control of
         vendor porto's call's like in btusb.c

> 
> Regards
> 
> Marcel
Balakrishna Godavarthi Nov. 6, 2018, 1:36 p.m. UTC | #5
Hi Marcel,

On 2018-11-06 18:44, Balakrishna Godavarthi wrote:
> Hi Marcel,
> 
> On 2018-11-06 18:32, Marcel Holtmann wrote:
>> Hi Balakrishna,
>> 
>>>>> During hci down we are sending reset command to chip, which
>>>>> is not required for wcn3990, as hdev->shutdown() will turn off the
>>>>> regulators.
>>>>> Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
>>>>> ---
>>>>> drivers/bluetooth/hci_qca.c | 1 +
>>>>> 1 file changed, 1 insertion(+)
>>>>> diff --git a/drivers/bluetooth/hci_qca.c 
>>>>> b/drivers/bluetooth/hci_qca.c
>>>>> index 8301663f0004..97b57e0f4725 100644
>>>>> --- a/drivers/bluetooth/hci_qca.c
>>>>> +++ b/drivers/bluetooth/hci_qca.c
>>>>> @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
>>>>> 		 */
>>>>> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
>>>>> 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
>>>>> +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
>>>>> 		hu->hdev->shutdown = qca_power_off;
>>>>> 		ret = qca_wcn3990_init(hu);
>>>>> 		if (ret)
>>>> I am pretty certain that you didn’t want this quirk:
>>>>        /* When this quirk is set, the HCI Reset command is send when
>>>>         * closing the transport instead of when opening it.
>>>> This quirk is for Bluetooth 1.0b devices where the HCI_Reset 
>>>> behavior
>>>> was not clear or for devices that actually misbehave with the 
>>>> initial
>>>> HCI_Reset.
>>>> In addition, you commit message is totally misleading. That is not
>>>> what is happening with this quirk.
>>>> Regards
>>>> Marcel
>>> 
>>> My intention was reset command is not required when we do an hci 
>>> down.
>>> this is because of hdev->shutdown will turn off the regulators.
>>> It is like turning off the chip. sending reset command after turning 
>>> off the chip is not required.
>>> 
>>> I understand the usage of the quirk, will update the commit text.
>> 
>> you are papering over the issue. Actually
>> hci_serdev.c:hci_uart_register_device() is the culprit with the legacy
>> code copied over from hci_ldisc.c:hci_uart_register_dev(). I think
>> there is no point doing all this legacy line discipline quirk handling
>> until it is really needed. The serdev drivers are all for recent
>> hardware.
>> 
>> That said, having moved over to a btuart.c approach and killed the
>> whole hci_serdev.c thing would have been a lot better here. You will
>> keep running in weird situations where 18 year old code keeps
>> surprising you.
> 
> [Bala]: even i feel the same. they are lot such kind of HACK's we need
> to do with current arch.
>         when can we expect btuart.c merged to bt-next. i think having
> btuart will helps us to have the control of
>         vendor porto's call's like in btusb.c
> 
>> 
>> Regards
>> 
>> Marcel

I need some clarification, do you expect some thing like this 
https://github.com/torvalds/linux/blob/master/drivers/bluetooth/btmtkuart.c 
for Qualcomm BT chip too.
it looks it is completely avoided hci_serdev.c interface.
Matthias Kaehlcke Nov. 14, 2018, 2:14 a.m. UTC | #6
On Tue, Nov 06, 2018 at 06:44:07PM +0530, Balakrishna Godavarthi wrote:
> Hi Marcel,
> 
> On 2018-11-06 18:32, Marcel Holtmann wrote:
> > Hi Balakrishna,
> > 
> > > > > During hci down we are sending reset command to chip, which
> > > > > is not required for wcn3990, as hdev->shutdown() will turn off the
> > > > > regulators.
> > > > > Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
> > > > > ---
> > > > > drivers/bluetooth/hci_qca.c | 1 +
> > > > > 1 file changed, 1 insertion(+)
> > > > > diff --git a/drivers/bluetooth/hci_qca.c
> > > > > b/drivers/bluetooth/hci_qca.c
> > > > > index 8301663f0004..97b57e0f4725 100644
> > > > > --- a/drivers/bluetooth/hci_qca.c
> > > > > +++ b/drivers/bluetooth/hci_qca.c
> > > > > @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
> > > > > 		 */
> > > > > 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
> > > > > 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
> > > > > +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);

This patch doesn't apply cleanly against bluetooth-next, looks like
you have the unrelated "Bluetooth: hci_qca: Set
HCI_QUIRK_USE_BDADDR_PROPERTY for wcn3990"
(https://lore.kernel.org/patchwork/patch/1004372/) in your tree.

> > > > > 		hu->hdev->shutdown = qca_power_off;
> > > > > 		ret = qca_wcn3990_init(hu);
> > > > > 		if (ret)
> > > > I am pretty certain that you didn’t want this quirk:
> > > >        /* When this quirk is set, the HCI Reset command is send when
> > > >         * closing the transport instead of when opening it.
> > > > This quirk is for Bluetooth 1.0b devices where the HCI_Reset behavior
> > > > was not clear or for devices that actually misbehave with the initial
> > > > HCI_Reset.
> > > > In addition, you commit message is totally misleading. That is not
> > > > what is happening with this quirk.
> > > > Regards
> > > > Marcel
> > > 
> > > My intention was reset command is not required when we do an hci down.
> > > this is because of hdev->shutdown will turn off the regulators.
> > > It is like turning off the chip. sending reset command after turning
> > > off the chip is not required.
> > > 
> > > I understand the usage of the quirk, will update the commit text.
> > 
> > you are papering over the issue. Actually
> > hci_serdev.c:hci_uart_register_device() is the culprit with the legacy
> > code copied over from hci_ldisc.c:hci_uart_register_dev(). I think
> > there is no point doing all this legacy line discipline quirk handling
> > until it is really needed. The serdev drivers are all for recent
> > hardware.
> > 
> > That said, having moved over to a btuart.c approach and killed the
> > whole hci_serdev.c thing would have been a lot better here. You will
> > keep running in weird situations where 18 year old code keeps
> > surprising you.
> 
> [Bala]: even i feel the same. they are lot such kind of HACK's we need to do
> with current arch.
>         when can we expect btuart.c merged to bt-next. i think having btuart
> will helps us to have the control of
>         vendor porto's call's like in btusb.c

btuart was initially part of the 'add support for Bluetooth on MT7622
SoC' series (https://lore.kernel.org/patchwork/patch/960806/), but was
dropped with v6
(https://lore.kernel.org/patchwork/project/lkml/list/?series=360046)
upon Marcel's request: 'Frankly I prefer to keep the btuart.c driver
for drivers that really just use H:4 as transport protocol. If the
protocol is only H:4 alike and has extra headers, then it should be a
separate driver.' (https://lore.kernel.org/patchwork/patch/960806/#1148426).

Cheers

Matthias
Balakrishna Godavarthi Nov. 14, 2018, 6:50 a.m. UTC | #7
Hi Matthias,

On 2018-11-14 07:44, Matthias Kaehlcke wrote:
> On Tue, Nov 06, 2018 at 06:44:07PM +0530, Balakrishna Godavarthi wrote:
>> Hi Marcel,
>> 
>> On 2018-11-06 18:32, Marcel Holtmann wrote:
>> > Hi Balakrishna,
>> >
>> > > > > During hci down we are sending reset command to chip, which
>> > > > > is not required for wcn3990, as hdev->shutdown() will turn off the
>> > > > > regulators.
>> > > > > Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
>> > > > > ---
>> > > > > drivers/bluetooth/hci_qca.c | 1 +
>> > > > > 1 file changed, 1 insertion(+)
>> > > > > diff --git a/drivers/bluetooth/hci_qca.c
>> > > > > b/drivers/bluetooth/hci_qca.c
>> > > > > index 8301663f0004..97b57e0f4725 100644
>> > > > > --- a/drivers/bluetooth/hci_qca.c
>> > > > > +++ b/drivers/bluetooth/hci_qca.c
>> > > > > @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
>> > > > > 		 */
>> > > > > 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
>> > > > > 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
>> > > > > +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
> 
> This patch doesn't apply cleanly against bluetooth-next, looks like
> you have the unrelated "Bluetooth: hci_qca: Set
> HCI_QUIRK_USE_BDADDR_PROPERTY for wcn3990"
> (https://lore.kernel.org/patchwork/patch/1004372/) in your tree.
> 
[Bala]: this patch is on top of 
https://lore.kernel.org/patchwork/patch/1004372/.
         will remove the dependency and update the patch.

>> > > > > 		hu->hdev->shutdown = qca_power_off;
>> > > > > 		ret = qca_wcn3990_init(hu);
>> > > > > 		if (ret)
>> > > > I am pretty certain that you didn’t want this quirk:
>> > > >        /* When this quirk is set, the HCI Reset command is send when
>> > > >         * closing the transport instead of when opening it.
>> > > > This quirk is for Bluetooth 1.0b devices where the HCI_Reset behavior
>> > > > was not clear or for devices that actually misbehave with the initial
>> > > > HCI_Reset.
>> > > > In addition, you commit message is totally misleading. That is not
>> > > > what is happening with this quirk.
>> > > > Regards
>> > > > Marcel
>> > >
>> > > My intention was reset command is not required when we do an hci down.
>> > > this is because of hdev->shutdown will turn off the regulators.
>> > > It is like turning off the chip. sending reset command after turning
>> > > off the chip is not required.
>> > >
>> > > I understand the usage of the quirk, will update the commit text.
>> >
>> > you are papering over the issue. Actually
>> > hci_serdev.c:hci_uart_register_device() is the culprit with the legacy
>> > code copied over from hci_ldisc.c:hci_uart_register_dev(). I think
>> > there is no point doing all this legacy line discipline quirk handling
>> > until it is really needed. The serdev drivers are all for recent
>> > hardware.
>> >
>> > That said, having moved over to a btuart.c approach and killed the
>> > whole hci_serdev.c thing would have been a lot better here. You will
>> > keep running in weird situations where 18 year old code keeps
>> > surprising you.
>> 
>> [Bala]: even i feel the same. they are lot such kind of HACK's we need 
>> to do
>> with current arch.
>>         when can we expect btuart.c merged to bt-next. i think having 
>> btuart
>> will helps us to have the control of
>>         vendor porto's call's like in btusb.c
> 
> btuart was initially part of the 'add support for Bluetooth on MT7622
> SoC' series (https://lore.kernel.org/patchwork/patch/960806/), but was
> dropped with v6
> (https://lore.kernel.org/patchwork/project/lkml/list/?series=360046)
> upon Marcel's request: 'Frankly I prefer to keep the btuart.c driver
> for drivers that really just use H:4 as transport protocol. If the
> protocol is only H:4 alike and has extra headers, then it should be a
> separate driver.' 
> (https://lore.kernel.org/patchwork/patch/960806/#1148426).
> 
> Cheers
> 
> Matthias

[Bala]: currently our main moto is to make this driver to be stable for 
both rome and wcn3990.
         we will look into working on btuart.c type driver for future 
qualcomm BT devices.
Marcel Holtmann Nov. 14, 2018, 7:48 a.m. UTC | #8
Hi Balakrishna,

>>>>>> During hci down we are sending reset command to chip, which
>>>>>> is not required for wcn3990, as hdev->shutdown() will turn off the
>>>>>> regulators.
>>>>>> Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
>>>>>> ---
>>>>>> drivers/bluetooth/hci_qca.c | 1 +
>>>>>> 1 file changed, 1 insertion(+)
>>>>>> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>>>>>> index 8301663f0004..97b57e0f4725 100644
>>>>>> --- a/drivers/bluetooth/hci_qca.c
>>>>>> +++ b/drivers/bluetooth/hci_qca.c
>>>>>> @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
>>>>>> 		 */
>>>>>> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
>>>>>> 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
>>>>>> +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
>>>>>> 		hu->hdev->shutdown = qca_power_off;
>>>>>> 		ret = qca_wcn3990_init(hu);
>>>>>> 		if (ret)
>>>>> I am pretty certain that you didn’t want this quirk:
>>>>>       /* When this quirk is set, the HCI Reset command is send when
>>>>>        * closing the transport instead of when opening it.
>>>>> This quirk is for Bluetooth 1.0b devices where the HCI_Reset behavior
>>>>> was not clear or for devices that actually misbehave with the initial
>>>>> HCI_Reset.
>>>>> In addition, you commit message is totally misleading. That is not
>>>>> what is happening with this quirk.
>>>>> Regards
>>>>> Marcel
>>>> My intention was reset command is not required when we do an hci down.
>>>> this is because of hdev->shutdown will turn off the regulators.
>>>> It is like turning off the chip. sending reset command after turning off the chip is not required.
>>>> I understand the usage of the quirk, will update the commit text.
>>> you are papering over the issue. Actually
>>> hci_serdev.c:hci_uart_register_device() is the culprit with the legacy
>>> code copied over from hci_ldisc.c:hci_uart_register_dev(). I think
>>> there is no point doing all this legacy line discipline quirk handling
>>> until it is really needed. The serdev drivers are all for recent
>>> hardware.
>>> That said, having moved over to a btuart.c approach and killed the
>>> whole hci_serdev.c thing would have been a lot better here. You will
>>> keep running in weird situations where 18 year old code keeps
>>> surprising you.
>> [Bala]: even i feel the same. they are lot such kind of HACK's we need
>> to do with current arch.
>>        when can we expect btuart.c merged to bt-next. i think having
>> btuart will helps us to have the control of
>>        vendor porto's call's like in btusb.c
>>> Regards
>>> Marcel
> 
> I need some clarification, do you expect some thing like this https://github.com/torvalds/linux/blob/master/drivers/bluetooth/btmtkuart.c for Qualcomm BT chip too.
> it looks it is completely avoided hci_serdev.c interface.

you tell me actually. Are you using the H:4 transport or do you have an extra protocol layer / framing below it. If you do, then use your own driver, but if the transport is H:4 with vendor packets and vendor setup, then btuart.c (which is not yet upstream) should be your target.

For the MTK hardware it was obvious that it was better served as a separate driver. For QCA serial it really depends on how much extra protocol you have to run. So this might be an exercise in trying QCA serial as a separate driver and then go from there.

It is clear that the baggage from hci_ldisc.c etc is in the way for serdev based systems.

Regards

Marcel
Balakrishna Godavarthi Nov. 14, 2018, 1:37 p.m. UTC | #9
Hi Marcel,

On 2018-11-14 13:18, Marcel Holtmann wrote:
> Hi Balakrishna,
> 
>>>>>>> During hci down we are sending reset command to chip, which
>>>>>>> is not required for wcn3990, as hdev->shutdown() will turn off 
>>>>>>> the
>>>>>>> regulators.
>>>>>>> Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
>>>>>>> ---
>>>>>>> drivers/bluetooth/hci_qca.c | 1 +
>>>>>>> 1 file changed, 1 insertion(+)
>>>>>>> diff --git a/drivers/bluetooth/hci_qca.c 
>>>>>>> b/drivers/bluetooth/hci_qca.c
>>>>>>> index 8301663f0004..97b57e0f4725 100644
>>>>>>> --- a/drivers/bluetooth/hci_qca.c
>>>>>>> +++ b/drivers/bluetooth/hci_qca.c
>>>>>>> @@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)
>>>>>>> 		 */
>>>>>>> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
>>>>>>> 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
>>>>>>> +		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
>>>>>>> 		hu->hdev->shutdown = qca_power_off;
>>>>>>> 		ret = qca_wcn3990_init(hu);
>>>>>>> 		if (ret)
>>>>>> I am pretty certain that you didn’t want this quirk:
>>>>>>       /* When this quirk is set, the HCI Reset command is send 
>>>>>> when
>>>>>>        * closing the transport instead of when opening it.
>>>>>> This quirk is for Bluetooth 1.0b devices where the HCI_Reset 
>>>>>> behavior
>>>>>> was not clear or for devices that actually misbehave with the 
>>>>>> initial
>>>>>> HCI_Reset.
>>>>>> In addition, you commit message is totally misleading. That is not
>>>>>> what is happening with this quirk.
>>>>>> Regards
>>>>>> Marcel
>>>>> My intention was reset command is not required when we do an hci 
>>>>> down.
>>>>> this is because of hdev->shutdown will turn off the regulators.
>>>>> It is like turning off the chip. sending reset command after 
>>>>> turning off the chip is not required.
>>>>> I understand the usage of the quirk, will update the commit text.
>>>> you are papering over the issue. Actually
>>>> hci_serdev.c:hci_uart_register_device() is the culprit with the 
>>>> legacy
>>>> code copied over from hci_ldisc.c:hci_uart_register_dev(). I think
>>>> there is no point doing all this legacy line discipline quirk 
>>>> handling
>>>> until it is really needed. The serdev drivers are all for recent
>>>> hardware.
>>>> That said, having moved over to a btuart.c approach and killed the
>>>> whole hci_serdev.c thing would have been a lot better here. You will
>>>> keep running in weird situations where 18 year old code keeps
>>>> surprising you.
>>> [Bala]: even i feel the same. they are lot such kind of HACK's we 
>>> need
>>> to do with current arch.
>>>        when can we expect btuart.c merged to bt-next. i think having
>>> btuart will helps us to have the control of
>>>        vendor porto's call's like in btusb.c
>>>> Regards
>>>> Marcel
>> 
>> I need some clarification, do you expect some thing like this 
>> https://github.com/torvalds/linux/blob/master/drivers/bluetooth/btmtkuart.c 
>> for Qualcomm BT chip too.
>> it looks it is completely avoided hci_serdev.c interface.
> 
> you tell me actually. Are you using the H:4 transport or do you have
> an extra protocol layer / framing below it. If you do, then use your
> own driver, but if the transport is H:4 with vendor packets and vendor
> setup, then btuart.c (which is not yet upstream) should be your
> target.
> 
> For the MTK hardware it was obvious that it was better served as a
> separate driver. For QCA serial it really depends on how much extra
> protocol you have to run. So this might be an exercise in trying QCA
> serial as a separate driver and then go from there.
> 
> It is clear that the baggage from hci_ldisc.c etc is in the way for
> serdev based systems.
> 
> Regards
> 
> Marcel

[Bala]:
     From my experience of serdev and ldisc, I prefer to go as MTK, here 
are the reasons
     1.If btuart maintains same generic way as hci_serdev, hardware 
vendors will not have control on of
       port opening and close. Because qca want to close port when we do 
hci down where as hci_serdev it is not possible to do.
       This is an important feature for power saving of the device.
    2. I think btuart will have common recv_handle to handle all the 
received data irrespective to the vendors.
       but in our case,  we will receive debug logs as ACL packet which 
is not possible to bypass as diagnostic packet.

      The same with the susb system restart events too. So, I feel that 
having an different driver as same as MTK will help us.
diff mbox series

Patch

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 8301663f0004..97b57e0f4725 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1190,6 +1190,7 @@  static int qca_setup(struct hci_uart *hu)
 		 */
 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
 		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
+		clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
 		hu->hdev->shutdown = qca_power_off;
 		ret = qca_wcn3990_init(hu);
 		if (ret)