linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: block: save return value of pci_find_capability() in u8
@ 2020-12-06 19:43 Puranjay Mohan
  2020-12-06 23:08 ` Chaitanya Kulkarni
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Puranjay Mohan @ 2020-12-06 19:43 UTC (permalink / raw)
  To: Damien.LeMoal, linux-block, bjorn, linux-pci; +Cc: Puranjay Mohan

Callers of pci_find_capability should save the return value in u8.
change type of variables from int to u8 to match the specification.

Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
---
 drivers/block/mtip32xx/mtip32xx.c | 2 +-
 drivers/block/skd_main.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 153e2cdecb4d..da57d37c6d20 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3936,7 +3936,7 @@ static DEFINE_HANDLER(7);
 
 static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
 {
-	int pos;
+	u8 pos;
 	unsigned short pcie_dev_ctrl;
 
 	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index a962b4551bed..16d59569129b 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -3136,7 +3136,7 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
 
 static char *skd_pci_info(struct skd_device *skdev, char *str)
 {
-	int pcie_reg;
+	u8 pcie_reg;
 
 	strcpy(str, "PCIe (");
 	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
-- 
2.27.0


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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-06 19:43 [PATCH] drivers: block: save return value of pci_find_capability() in u8 Puranjay Mohan
@ 2020-12-06 23:08 ` Chaitanya Kulkarni
  2020-12-07  1:26   ` Bjorn Helgaas
  2020-12-07  2:25 ` Damien Le Moal
  2020-12-07 14:52 ` Christoph Hellwig
  2 siblings, 1 reply; 13+ messages in thread
From: Chaitanya Kulkarni @ 2020-12-06 23:08 UTC (permalink / raw)
  To: Puranjay Mohan, Damien Le Moal, linux-block, bjorn, linux-pci

On 12/6/20 11:45, Puranjay Mohan wrote:
> Callers of pci_find_capability should save the return value in u8.
> change type of variables from int to u8 to match the specification.

I did not understand this, pci_find_capability() does not return u8. 

what is it that we are achieving by changing the variable type ?

This patch will probably also generate type mismatch warning with

certain static analyzers.

> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
> ---
>  drivers/block/mtip32xx/mtip32xx.c | 2 +-
>  drivers/block/skd_main.c          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
> index 153e2cdecb4d..da57d37c6d20 100644
> --- a/drivers/block/mtip32xx/mtip32xx.c
> +++ b/drivers/block/mtip32xx/mtip32xx.c
> @@ -3936,7 +3936,7 @@ static DEFINE_HANDLER(7);
>  
>  static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
>  {
> -	int pos;
> +	u8 pos;
>  	unsigned short pcie_dev_ctrl;
>  
>  	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
> index a962b4551bed..16d59569129b 100644
> --- a/drivers/block/skd_main.c
> +++ b/drivers/block/skd_main.c
> @@ -3136,7 +3136,7 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
>  
>  static char *skd_pci_info(struct skd_device *skdev, char *str)
>  {
> -	int pcie_reg;
> +	u8 pcie_reg;
>  
>  	strcpy(str, "PCIe (");
>  	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);



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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-06 23:08 ` Chaitanya Kulkarni
@ 2020-12-07  1:26   ` Bjorn Helgaas
  2020-12-07  1:30     ` Damien Le Moal
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2020-12-07  1:26 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: Puranjay Mohan, Damien Le Moal, linux-block, bjorn, linux-pci

On Sun, Dec 06, 2020 at 11:08:14PM +0000, Chaitanya Kulkarni wrote:
> On 12/6/20 11:45, Puranjay Mohan wrote:
> > Callers of pci_find_capability should save the return value in u8.
> > change type of variables from int to u8 to match the specification.
> 
> I did not understand this, pci_find_capability() does not return u8. 
> 
> what is it that we are achieving by changing the variable type ?
> 
> This patch will probably also generate type mismatch warning with
> 
> certain static analyzers.

There's a patch pending via the PCI tree to change the return type to
u8.  We can do one of:

  - Ignore this.  It only changes something on the stack, so no real
    space saving and there's no problem assigning the u8 return value
    to the "int".

  - The maintainer could ack it and I could merge it via the PCI tree
    so it happens in the correct order (after the interface change).

  - The PCI core interface change will be merged for v5.11, so we
    could hold this until v5.12.

I don't really have a preference.  The only place there would really
be a benefit would be if we store the return value in a struct, where
we could potentially save three bytes.

Bjorn

> > Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
> > ---
> >  drivers/block/mtip32xx/mtip32xx.c | 2 +-
> >  drivers/block/skd_main.c          | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
> > index 153e2cdecb4d..da57d37c6d20 100644
> > --- a/drivers/block/mtip32xx/mtip32xx.c
> > +++ b/drivers/block/mtip32xx/mtip32xx.c
> > @@ -3936,7 +3936,7 @@ static DEFINE_HANDLER(7);
> >  
> >  static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
> >  {
> > -	int pos;
> > +	u8 pos;
> >  	unsigned short pcie_dev_ctrl;
> >  
> >  	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
> > diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
> > index a962b4551bed..16d59569129b 100644
> > --- a/drivers/block/skd_main.c
> > +++ b/drivers/block/skd_main.c
> > @@ -3136,7 +3136,7 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
> >  
> >  static char *skd_pci_info(struct skd_device *skdev, char *str)
> >  {
> > -	int pcie_reg;
> > +	u8 pcie_reg;
> >  
> >  	strcpy(str, "PCIe (");
> >  	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
> 
> 

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-07  1:26   ` Bjorn Helgaas
@ 2020-12-07  1:30     ` Damien Le Moal
  2020-12-07 18:38       ` Jens Axboe
  2020-12-07  1:48     ` Chaitanya Kulkarni
  2020-12-07 16:17     ` Ben Dooks
  2 siblings, 1 reply; 13+ messages in thread
From: Damien Le Moal @ 2020-12-07  1:30 UTC (permalink / raw)
  To: Bjorn Helgaas, Chaitanya Kulkarni
  Cc: Puranjay Mohan, linux-block, bjorn, linux-pci, Jens Axboe

On 2020/12/07 10:26, Bjorn Helgaas wrote:
> On Sun, Dec 06, 2020 at 11:08:14PM +0000, Chaitanya Kulkarni wrote:
>> On 12/6/20 11:45, Puranjay Mohan wrote:
>>> Callers of pci_find_capability should save the return value in u8.
>>> change type of variables from int to u8 to match the specification.
>>
>> I did not understand this, pci_find_capability() does not return u8. 
>>
>> what is it that we are achieving by changing the variable type ?
>>
>> This patch will probably also generate type mismatch warning with
>>
>> certain static analyzers.
> 
> There's a patch pending via the PCI tree to change the return type to
> u8.  We can do one of:
> 
>   - Ignore this.  It only changes something on the stack, so no real
>     space saving and there's no problem assigning the u8 return value
>     to the "int".
> 
>   - The maintainer could ack it and I could merge it via the PCI tree
>     so it happens in the correct order (after the interface change).

That works for me. But this driver changes generally go through Jens block tree.

Jens,

Is this OK with you if Bjorn takes the patch through the PCI tree ?

> 
>   - The PCI core interface change will be merged for v5.11, so we
>     could hold this until v5.12.
> 
> I don't really have a preference.  The only place there would really
> be a benefit would be if we store the return value in a struct, where
> we could potentially save three bytes.
> 
> Bjorn
> 
>>> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
>>> ---
>>>  drivers/block/mtip32xx/mtip32xx.c | 2 +-
>>>  drivers/block/skd_main.c          | 2 +-
>>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
>>> index 153e2cdecb4d..da57d37c6d20 100644
>>> --- a/drivers/block/mtip32xx/mtip32xx.c
>>> +++ b/drivers/block/mtip32xx/mtip32xx.c
>>> @@ -3936,7 +3936,7 @@ static DEFINE_HANDLER(7);
>>>  
>>>  static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
>>>  {
>>> -	int pos;
>>> +	u8 pos;
>>>  	unsigned short pcie_dev_ctrl;
>>>  
>>>  	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
>>> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
>>> index a962b4551bed..16d59569129b 100644
>>> --- a/drivers/block/skd_main.c
>>> +++ b/drivers/block/skd_main.c
>>> @@ -3136,7 +3136,7 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
>>>  
>>>  static char *skd_pci_info(struct skd_device *skdev, char *str)
>>>  {
>>> -	int pcie_reg;
>>> +	u8 pcie_reg;
>>>  
>>>  	strcpy(str, "PCIe (");
>>>  	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
>>
>>
> 


-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-07  1:26   ` Bjorn Helgaas
  2020-12-07  1:30     ` Damien Le Moal
@ 2020-12-07  1:48     ` Chaitanya Kulkarni
  2020-12-07 16:17     ` Ben Dooks
  2 siblings, 0 replies; 13+ messages in thread
From: Chaitanya Kulkarni @ 2020-12-07  1:48 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Puranjay Mohan, Damien Le Moal, linux-block, bjorn, linux-pci

Bjorn,
On 12/6/20 17:26, Bjorn Helgaas wrote:
> There's a patch pending via the PCI tree to change the return type to
> u8.  We can do one of:
I did not know about the pending patch, if that is going to change the
return

type then this patch makes sense.

>
>   - Ignore this.  It only changes something on the stack, so no real
>     space saving and there's no problem assigning the u8 return value
>     to the "int".
>   - The maintainer could ack it and I could merge it via the PCI tree
>     so it happens in the correct order (after the interface change).
If we want it in 5.11 then I think PCI tree is a right way go about it.
>   - The PCI core interface change will be merged for v5.11, so we
>     could hold this until v5.12.
> I don't really have a preference.  The only place there would really
> be a benefit would be if we store the return value in a struct, where
> we could potentially save three bytes.
Totally agree.
> Bjorn

Whoever is going to apply please add :-

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>



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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-06 19:43 [PATCH] drivers: block: save return value of pci_find_capability() in u8 Puranjay Mohan
  2020-12-06 23:08 ` Chaitanya Kulkarni
@ 2020-12-07  2:25 ` Damien Le Moal
  2020-12-07 14:52 ` Christoph Hellwig
  2 siblings, 0 replies; 13+ messages in thread
From: Damien Le Moal @ 2020-12-07  2:25 UTC (permalink / raw)
  To: Puranjay Mohan, linux-block, bjorn, linux-pci

On 2020/12/07 4:43, Puranjay Mohan wrote:
> Callers of pci_find_capability should save the return value in u8.
> change type of variables from int to u8 to match the specification.
> 
> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
> ---
>  drivers/block/mtip32xx/mtip32xx.c | 2 +-
>  drivers/block/skd_main.c          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
> index 153e2cdecb4d..da57d37c6d20 100644
> --- a/drivers/block/mtip32xx/mtip32xx.c
> +++ b/drivers/block/mtip32xx/mtip32xx.c
> @@ -3936,7 +3936,7 @@ static DEFINE_HANDLER(7);
>  
>  static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
>  {
> -	int pos;
> +	u8 pos;
>  	unsigned short pcie_dev_ctrl;
>  
>  	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
> index a962b4551bed..16d59569129b 100644
> --- a/drivers/block/skd_main.c
> +++ b/drivers/block/skd_main.c
> @@ -3136,7 +3136,7 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
>  
>  static char *skd_pci_info(struct skd_device *skdev, char *str)
>  {
> -	int pcie_reg;
> +	u8 pcie_reg;
>  
>  	strcpy(str, "PCIe (");
>  	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
> 

Acked-by: Damien Le Moal <damien.lemoal@wdc.com>

-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-06 19:43 [PATCH] drivers: block: save return value of pci_find_capability() in u8 Puranjay Mohan
  2020-12-06 23:08 ` Chaitanya Kulkarni
  2020-12-07  2:25 ` Damien Le Moal
@ 2020-12-07 14:52 ` Christoph Hellwig
  2020-12-07 16:04   ` Bjorn Helgaas
  2020-12-07 17:53   ` Puranjay Mohan
  2 siblings, 2 replies; 13+ messages in thread
From: Christoph Hellwig @ 2020-12-07 14:52 UTC (permalink / raw)
  To: Puranjay Mohan; +Cc: Damien.LeMoal, linux-block, bjorn, linux-pci

Can we take a step back?  I think in general drivers should not bother
with pci_find_capability.  Both mtip32xx and skd want to find out if
the devices are PCIe devices, skd then just prints the link speed for
which we have much better helpers, mtip32xx than messes with DEVCTL
which seems actively dangerous to me.

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-07 14:52 ` Christoph Hellwig
@ 2020-12-07 16:04   ` Bjorn Helgaas
  2020-12-07 17:53   ` Puranjay Mohan
  1 sibling, 0 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2020-12-07 16:04 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Puranjay Mohan, Damien.LeMoal, linux-block, bjorn, linux-pci

On Mon, Dec 07, 2020 at 02:52:58PM +0000, Christoph Hellwig wrote:
> Can we take a step back?  I think in general drivers should not bother
> with pci_find_capability.  Both mtip32xx and skd want to find out if
> the devices are PCIe devices, skd then just prints the link speed for
> which we have much better helpers, mtip32xx than messes with DEVCTL
> which seems actively dangerous to me.

Yes, that's a much better idea.  Plus it would be a much more
interesting mentorship project.

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-07  1:26   ` Bjorn Helgaas
  2020-12-07  1:30     ` Damien Le Moal
  2020-12-07  1:48     ` Chaitanya Kulkarni
@ 2020-12-07 16:17     ` Ben Dooks
  2 siblings, 0 replies; 13+ messages in thread
From: Ben Dooks @ 2020-12-07 16:17 UTC (permalink / raw)
  To: Bjorn Helgaas, Chaitanya Kulkarni
  Cc: Puranjay Mohan, Damien Le Moal, linux-block, bjorn, linux-pci

On 07/12/2020 01:26, Bjorn Helgaas wrote:
> On Sun, Dec 06, 2020 at 11:08:14PM +0000, Chaitanya Kulkarni wrote:
>> On 12/6/20 11:45, Puranjay Mohan wrote:
>>> Callers of pci_find_capability should save the return value in u8.
>>> change type of variables from int to u8 to match the specification.the com
>>
>> I did not understand this, pci_find_capability() does not return u8.
>>
>> what is it that we are achieving by changing the variable type ?
>>
>> This patch will probably also generate type mismatch warning with
>>
>> certain static analyzers.
> 
> There's a patch pending via the PCI tree to change the return type to
> u8.  We can do one of:
> 
>    - Ignore this.  It only changes something on the stack, so no real
>      space saving and there's no problem assigning the u8 return value
>      to the "int".

I seem to remember some compilers would emit a sequence to constrain the
result to a valid char, but that looks like it is fixed in gcc-9 if the
input was also u8

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-07 14:52 ` Christoph Hellwig
  2020-12-07 16:04   ` Bjorn Helgaas
@ 2020-12-07 17:53   ` Puranjay Mohan
  2020-12-07 18:07     ` Keith Busch
  1 sibling, 1 reply; 13+ messages in thread
From: Puranjay Mohan @ 2020-12-07 17:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Damien.LeMoal, linux-block, Bjorn Helgaas, Linux PCI

On Mon, Dec 7, 2020 at 8:23 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> Can we take a step back?  I think in general drivers should not bother
> with pci_find_capability.  Both mtip32xx and skd want to find out if
> the devices are PCIe devices, skd then just prints the link speed for
> which we have much better helpers, mtip32xx than messes with DEVCTL
> which seems actively dangerous to me.

The skd driver uses pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
to check if the device is PCIe, it can use pci_is_pcie() to do that.
After that it uses pci_read_config_word(skdev->pdev, pcie_reg,
&pcie_lstat); to read the Link Status Register, I think
it should use pcie_capability_read_word(skdev->pdev, PCI_EXP_LNKSTA,
&pcie_lstat);

Please let me know if the above changes are correct so I may send a patch.
-- 
Thanks and Regards

Yours Truly,

Puranjay Mohan

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-07 17:53   ` Puranjay Mohan
@ 2020-12-07 18:07     ` Keith Busch
  2020-12-07 18:35       ` Puranjay Mohan
  0 siblings, 1 reply; 13+ messages in thread
From: Keith Busch @ 2020-12-07 18:07 UTC (permalink / raw)
  To: Puranjay Mohan
  Cc: Christoph Hellwig, Damien.LeMoal, linux-block, Bjorn Helgaas, Linux PCI

On Mon, Dec 07, 2020 at 11:23:03PM +0530, Puranjay Mohan wrote:
> On Mon, Dec 7, 2020 at 8:23 PM Christoph Hellwig <hch@infradead.org> wrote:
> >
> > Can we take a step back?  I think in general drivers should not bother
> > with pci_find_capability.  Both mtip32xx and skd want to find out if
> > the devices are PCIe devices, skd then just prints the link speed for
> > which we have much better helpers, mtip32xx than messes with DEVCTL
> > which seems actively dangerous to me.
> 
> The skd driver uses pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
> to check if the device is PCIe, it can use pci_is_pcie() to do that.
> After that it uses pci_read_config_word(skdev->pdev, pcie_reg,
> &pcie_lstat); to read the Link Status Register, I think
> it should use pcie_capability_read_word(skdev->pdev, PCI_EXP_LNKSTA,
> &pcie_lstat);
> 
> Please let me know if the above changes are correct so I may send a patch.

You just want to print the current link speed, right? Does
skdev->pdev->bus->cur_bus_speed provide what you need?

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-07 18:07     ` Keith Busch
@ 2020-12-07 18:35       ` Puranjay Mohan
  0 siblings, 0 replies; 13+ messages in thread
From: Puranjay Mohan @ 2020-12-07 18:35 UTC (permalink / raw)
  To: Keith Busch
  Cc: Christoph Hellwig, Damien.LeMoal, linux-block, Bjorn Helgaas, Linux PCI

On Mon, Dec 7, 2020 at 11:37 PM Keith Busch <kbusch@kernel.org> wrote:
>
> On Mon, Dec 07, 2020 at 11:23:03PM +0530, Puranjay Mohan wrote:
> > On Mon, Dec 7, 2020 at 8:23 PM Christoph Hellwig <hch@infradead.org> wrote:
> > >
> > > Can we take a step back?  I think in general drivers should not bother
> > > with pci_find_capability.  Both mtip32xx and skd want to find out if
> > > the devices are PCIe devices, skd then just prints the link speed for
> > > which we have much better helpers, mtip32xx than messes with DEVCTL
> > > which seems actively dangerous to me.
> >
> > The skd driver uses pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
> > to check if the device is PCIe, it can use pci_is_pcie() to do that.
> > After that it uses pci_read_config_word(skdev->pdev, pcie_reg,
> > &pcie_lstat); to read the Link Status Register, I think
> > it should use pcie_capability_read_word(skdev->pdev, PCI_EXP_LNKSTA,
> > &pcie_lstat);
> >
> > Please let me know if the above changes are correct so I may send a patch.
>
> You just want to print the current link speed, right? Does
> skdev->pdev->bus->cur_bus_speed provide what you need?

After discussing with Bjorn, we concluded that we don't need to print
the speed as it is already printed by the PCI core for every device.
PCI core calls __pcie_print_link_status() for every device, and hence
the skd_pci_info() is redundant and can be removed?


-- 
Thanks and Regards

Yours Truly,

Puranjay Mohan

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

* Re: [PATCH] drivers: block: save return value of pci_find_capability() in u8
  2020-12-07  1:30     ` Damien Le Moal
@ 2020-12-07 18:38       ` Jens Axboe
  0 siblings, 0 replies; 13+ messages in thread
From: Jens Axboe @ 2020-12-07 18:38 UTC (permalink / raw)
  To: Damien Le Moal, Bjorn Helgaas, Chaitanya Kulkarni
  Cc: Puranjay Mohan, linux-block, bjorn, linux-pci

On 12/6/20 6:30 PM, Damien Le Moal wrote:
> On 2020/12/07 10:26, Bjorn Helgaas wrote:
>> On Sun, Dec 06, 2020 at 11:08:14PM +0000, Chaitanya Kulkarni wrote:
>>> On 12/6/20 11:45, Puranjay Mohan wrote:
>>>> Callers of pci_find_capability should save the return value in u8.
>>>> change type of variables from int to u8 to match the specification.
>>>
>>> I did not understand this, pci_find_capability() does not return u8. 
>>>
>>> what is it that we are achieving by changing the variable type ?
>>>
>>> This patch will probably also generate type mismatch warning with
>>>
>>> certain static analyzers.
>>
>> There's a patch pending via the PCI tree to change the return type to
>> u8.  We can do one of:
>>
>>   - Ignore this.  It only changes something on the stack, so no real
>>     space saving and there's no problem assigning the u8 return value
>>     to the "int".
>>
>>   - The maintainer could ack it and I could merge it via the PCI tree
>>     so it happens in the correct order (after the interface change).
> 
> That works for me. But this driver changes generally go through Jens block tree.
> 
> Jens,
> 
> Is this OK with you if Bjorn takes the patch through the PCI tree ?

Yep that's fine, if that makes it easier to handle.

-- 
Jens Axboe


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

end of thread, other threads:[~2020-12-07 18:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-06 19:43 [PATCH] drivers: block: save return value of pci_find_capability() in u8 Puranjay Mohan
2020-12-06 23:08 ` Chaitanya Kulkarni
2020-12-07  1:26   ` Bjorn Helgaas
2020-12-07  1:30     ` Damien Le Moal
2020-12-07 18:38       ` Jens Axboe
2020-12-07  1:48     ` Chaitanya Kulkarni
2020-12-07 16:17     ` Ben Dooks
2020-12-07  2:25 ` Damien Le Moal
2020-12-07 14:52 ` Christoph Hellwig
2020-12-07 16:04   ` Bjorn Helgaas
2020-12-07 17:53   ` Puranjay Mohan
2020-12-07 18:07     ` Keith Busch
2020-12-07 18:35       ` Puranjay Mohan

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