[PATCH 04/11] PCI: Improve Resizable BAR functions kernel doc

Ilpo Järvinen posted 11 patches 3 weeks ago
There is a newer version of this series
[PATCH 04/11] PCI: Improve Resizable BAR functions kernel doc
Posted by Ilpo Järvinen 3 weeks ago
Fix the copy-pasted errors in the Resizable BAR handling functions
kernel doc and generally improve wording choices.

Fix the formatting errors of the Return: line.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/pci/rebar.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/rebar.c b/drivers/pci/rebar.c
index 020ed7a1b3aa..64315dd8b6bb 100644
--- a/drivers/pci/rebar.c
+++ b/drivers/pci/rebar.c
@@ -58,8 +58,9 @@ void pci_rebar_init(struct pci_dev *pdev)
  * @bar: BAR to find
  *
  * Helper to find the position of the ctrl register for a BAR.
- * Returns -ENOTSUPP if resizable BARs are not supported at all.
- * Returns -ENOENT if no ctrl register for the BAR could be found.
+ *
+ * Return: %-ENOTSUPP if resizable BARs are not supported at all,
+ *	   %-ENOENT if no ctrl register for the BAR could be found.
  */
 static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
 {
@@ -92,12 +93,15 @@ static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
 }
 
 /**
- * pci_rebar_get_possible_sizes - get possible sizes for BAR
+ * pci_rebar_get_possible_sizes - get possible sizes for Resizable BAR
  * @pdev: PCI device
  * @bar: BAR to query
  *
  * Get the possible sizes of a resizable BAR as bitmask defined in the spec
- * (bit 0=1MB, bit 31=128TB). Returns 0 if BAR isn't resizable.
+ * (bit 0=1MB, bit 31=128TB).
+ *
+ * Return: A bitmask of possible sizes (0=1MB, 31=128TB), or %0 if BAR isn't
+ *	   resizable.
  */
 u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
 {
@@ -121,12 +125,14 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
 EXPORT_SYMBOL(pci_rebar_get_possible_sizes);
 
 /**
- * pci_rebar_get_current_size - get the current size of a BAR
+ * pci_rebar_get_current_size - get the current size of a Resizable BAR
  * @pdev: PCI device
- * @bar: BAR to set size to
+ * @bar: BAR to get the size from
  *
- * Read the size of a BAR from the resizable BAR config.
- * Returns size if found or negative error code.
+ * Reads the current size of a BAR from the Resizable BAR config.
+ *
+ * Return: BAR Size if @bar is resizable (bit 0=1MB, bit 31=128TB), or
+ *	   negative on error.
  */
 int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
 {
@@ -142,13 +148,14 @@ int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
 }
 
 /**
- * pci_rebar_set_size - set a new size for a BAR
+ * pci_rebar_set_size - set a new size for a Resizable BAR
  * @pdev: PCI device
  * @bar: BAR to set size to
- * @size: new size as defined in the spec (0=1MB, 31=128TB)
+ * @size: new size as defined in the PCIe spec (0=1MB, 31=128TB)
  *
  * Set the new size of a BAR as defined in the spec.
- * Returns zero if resizing was successful, error code otherwise.
+ *
+ * Return: %0 if resizing was successful, or negative on error.
  */
 int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size)
 {
-- 
2.39.5

Re: [PATCH 04/11] PCI: Improve Resizable BAR functions kernel doc
Posted by Randy Dunlap 2 weeks, 6 days ago
Hi,

On 9/11/25 12:55 AM, Ilpo Järvinen wrote:
> Fix the copy-pasted errors in the Resizable BAR handling functions
> kernel doc and generally improve wording choices.
> 
> Fix the formatting errors of the Return: line.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  drivers/pci/rebar.c | 29 ++++++++++++++++++-----------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pci/rebar.c b/drivers/pci/rebar.c
> index 020ed7a1b3aa..64315dd8b6bb 100644
> --- a/drivers/pci/rebar.c
> +++ b/drivers/pci/rebar.c
> @@ -58,8 +58,9 @@ void pci_rebar_init(struct pci_dev *pdev)
>   * @bar: BAR to find
>   *
>   * Helper to find the position of the ctrl register for a BAR.
> - * Returns -ENOTSUPP if resizable BARs are not supported at all.
> - * Returns -ENOENT if no ctrl register for the BAR could be found.
> + *
> + * Return: %-ENOTSUPP if resizable BARs are not supported at all,
> + *	   %-ENOENT if no ctrl register for the BAR could be found.

These 2 lines will run together in the (html) output. They could be
made "prettier" (IMO) into a 2-item list if you choose:

 * Return:
 * * %-ENOTSUPP if resizable BARs are not supported at all
 * * %-ENOENT if no ctrl register for the BAR could be found


>   */
>  static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
>  {

-- 
~Randy

Re: [PATCH 04/11] PCI: Improve Resizable BAR functions kernel doc
Posted by Christian König 3 weeks ago
On 11.09.25 09:55, Ilpo Järvinen wrote:
> Fix the copy-pasted errors in the Resizable BAR handling functions
> kernel doc and generally improve wording choices.
> 
> Fix the formatting errors of the Return: line.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  drivers/pci/rebar.c | 29 ++++++++++++++++++-----------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pci/rebar.c b/drivers/pci/rebar.c
> index 020ed7a1b3aa..64315dd8b6bb 100644
> --- a/drivers/pci/rebar.c
> +++ b/drivers/pci/rebar.c
> @@ -58,8 +58,9 @@ void pci_rebar_init(struct pci_dev *pdev)
>   * @bar: BAR to find
>   *
>   * Helper to find the position of the ctrl register for a BAR.
> - * Returns -ENOTSUPP if resizable BARs are not supported at all.
> - * Returns -ENOENT if no ctrl register for the BAR could be found.
> + *
> + * Return: %-ENOTSUPP if resizable BARs are not supported at all,
> + *	   %-ENOENT if no ctrl register for the BAR could be found.
>   */
>  static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
>  {
> @@ -92,12 +93,15 @@ static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
>  }
>  
>  /**
> - * pci_rebar_get_possible_sizes - get possible sizes for BAR
> + * pci_rebar_get_possible_sizes - get possible sizes for Resizable BAR
>   * @pdev: PCI device
>   * @bar: BAR to query
>   *
>   * Get the possible sizes of a resizable BAR as bitmask defined in the spec
> - * (bit 0=1MB, bit 31=128TB). Returns 0 if BAR isn't resizable.
> + * (bit 0=1MB, bit 31=128TB).
> + *
> + * Return: A bitmask of possible sizes (0=1MB, 31=128TB), or %0 if BAR isn't
> + *	   resizable.
>   */
>  u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
>  {
> @@ -121,12 +125,14 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
>  EXPORT_SYMBOL(pci_rebar_get_possible_sizes);
>  
>  /**
> - * pci_rebar_get_current_size - get the current size of a BAR
> + * pci_rebar_get_current_size - get the current size of a Resizable BAR
>   * @pdev: PCI device
> - * @bar: BAR to set size to
> + * @bar: BAR to get the size from
>   *
> - * Read the size of a BAR from the resizable BAR config.
> - * Returns size if found or negative error code.
> + * Reads the current size of a BAR from the Resizable BAR config.
> + *
> + * Return: BAR Size if @bar is resizable (bit 0=1MB, bit 31=128TB), or

This is a bit misleading since there is no mask returned but rather the order or in other words which bit of the mask was used.

Regards,
Christian.

> + *	   negative on error.
>   */
>  int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
>  {
> @@ -142,13 +148,14 @@ int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
>  }
>  
>  /**
> - * pci_rebar_set_size - set a new size for a BAR
> + * pci_rebar_set_size - set a new size for a Resizable BAR
>   * @pdev: PCI device
>   * @bar: BAR to set size to
> - * @size: new size as defined in the spec (0=1MB, 31=128TB)
> + * @size: new size as defined in the PCIe spec (0=1MB, 31=128TB)
>   *
>   * Set the new size of a BAR as defined in the spec.
> - * Returns zero if resizing was successful, error code otherwise.
> + *
> + * Return: %0 if resizing was successful, or negative on error.
>   */
>  int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size)
>  {

Re: [PATCH 04/11] PCI: Improve Resizable BAR functions kernel doc
Posted by Ilpo Järvinen 3 weeks ago
On Thu, 11 Sep 2025, Christian König wrote:

> On 11.09.25 09:55, Ilpo Järvinen wrote:
> > Fix the copy-pasted errors in the Resizable BAR handling functions
> > kernel doc and generally improve wording choices.
> > 
> > Fix the formatting errors of the Return: line.
> > 
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> > ---
> >  drivers/pci/rebar.c | 29 ++++++++++++++++++-----------
> >  1 file changed, 18 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/pci/rebar.c b/drivers/pci/rebar.c
> > index 020ed7a1b3aa..64315dd8b6bb 100644
> > --- a/drivers/pci/rebar.c
> > +++ b/drivers/pci/rebar.c
> > @@ -58,8 +58,9 @@ void pci_rebar_init(struct pci_dev *pdev)
> >   * @bar: BAR to find
> >   *
> >   * Helper to find the position of the ctrl register for a BAR.
> > - * Returns -ENOTSUPP if resizable BARs are not supported at all.
> > - * Returns -ENOENT if no ctrl register for the BAR could be found.
> > + *
> > + * Return: %-ENOTSUPP if resizable BARs are not supported at all,
> > + *	   %-ENOENT if no ctrl register for the BAR could be found.
> >   */
> >  static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
> >  {
> > @@ -92,12 +93,15 @@ static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
> >  }
> >  
> >  /**
> > - * pci_rebar_get_possible_sizes - get possible sizes for BAR
> > + * pci_rebar_get_possible_sizes - get possible sizes for Resizable BAR
> >   * @pdev: PCI device
> >   * @bar: BAR to query
> >   *
> >   * Get the possible sizes of a resizable BAR as bitmask defined in the spec
> > - * (bit 0=1MB, bit 31=128TB). Returns 0 if BAR isn't resizable.
> > + * (bit 0=1MB, bit 31=128TB).
> > + *
> > + * Return: A bitmask of possible sizes (0=1MB, 31=128TB), or %0 if BAR isn't
> > + *	   resizable.
> >   */
> >  u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
> >  {
> > @@ -121,12 +125,14 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
> >  EXPORT_SYMBOL(pci_rebar_get_possible_sizes);
> >  
> >  /**
> > - * pci_rebar_get_current_size - get the current size of a BAR
> > + * pci_rebar_get_current_size - get the current size of a Resizable BAR
> >   * @pdev: PCI device
> > - * @bar: BAR to set size to
> > + * @bar: BAR to get the size from
> >   *
> > - * Read the size of a BAR from the resizable BAR config.
> > - * Returns size if found or negative error code.
> > + * Reads the current size of a BAR from the Resizable BAR config.
> > + *
> > + * Return: BAR Size if @bar is resizable (bit 0=1MB, bit 31=128TB), or
> 
> This is a bit misleading since there is no mask returned but rather the 
> order or in other words which bit of the mask was used. 

Thanks for noticing this. I'll removed "bit" x2 from it, does that fully 
address your concern?

-- 
 i.

> > + *	   negative on error.
> >   */
> >  int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
> >  {
> > @@ -142,13 +148,14 @@ int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
> >  }
> >  
> >  /**
> > - * pci_rebar_set_size - set a new size for a BAR
> > + * pci_rebar_set_size - set a new size for a Resizable BAR
> >   * @pdev: PCI device
> >   * @bar: BAR to set size to
> > - * @size: new size as defined in the spec (0=1MB, 31=128TB)
> > + * @size: new size as defined in the PCIe spec (0=1MB, 31=128TB)
> >   *
> >   * Set the new size of a BAR as defined in the spec.
> > - * Returns zero if resizing was successful, error code otherwise.
> > + *
> > + * Return: %0 if resizing was successful, or negative on error.
> >   */
> >  int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size)
> >  {
> 
Re: [PATCH 04/11] PCI: Improve Resizable BAR functions kernel doc
Posted by Christian König 3 weeks ago
On 11.09.25 10:59, Ilpo Järvinen wrote:
> On Thu, 11 Sep 2025, Christian König wrote:
> 
>> On 11.09.25 09:55, Ilpo Järvinen wrote:
>>> Fix the copy-pasted errors in the Resizable BAR handling functions
>>> kernel doc and generally improve wording choices.
>>>
>>> Fix the formatting errors of the Return: line.
>>>
>>> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
>>> ---
>>>  drivers/pci/rebar.c | 29 ++++++++++++++++++-----------
>>>  1 file changed, 18 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/pci/rebar.c b/drivers/pci/rebar.c
>>> index 020ed7a1b3aa..64315dd8b6bb 100644
>>> --- a/drivers/pci/rebar.c
>>> +++ b/drivers/pci/rebar.c
>>> @@ -58,8 +58,9 @@ void pci_rebar_init(struct pci_dev *pdev)
>>>   * @bar: BAR to find
>>>   *
>>>   * Helper to find the position of the ctrl register for a BAR.
>>> - * Returns -ENOTSUPP if resizable BARs are not supported at all.
>>> - * Returns -ENOENT if no ctrl register for the BAR could be found.
>>> + *
>>> + * Return: %-ENOTSUPP if resizable BARs are not supported at all,
>>> + *	   %-ENOENT if no ctrl register for the BAR could be found.
>>>   */
>>>  static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
>>>  {
>>> @@ -92,12 +93,15 @@ static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
>>>  }
>>>  
>>>  /**
>>> - * pci_rebar_get_possible_sizes - get possible sizes for BAR
>>> + * pci_rebar_get_possible_sizes - get possible sizes for Resizable BAR
>>>   * @pdev: PCI device
>>>   * @bar: BAR to query
>>>   *
>>>   * Get the possible sizes of a resizable BAR as bitmask defined in the spec
>>> - * (bit 0=1MB, bit 31=128TB). Returns 0 if BAR isn't resizable.
>>> + * (bit 0=1MB, bit 31=128TB).
>>> + *
>>> + * Return: A bitmask of possible sizes (0=1MB, 31=128TB), or %0 if BAR isn't
>>> + *	   resizable.
>>>   */
>>>  u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
>>>  {
>>> @@ -121,12 +125,14 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
>>>  EXPORT_SYMBOL(pci_rebar_get_possible_sizes);
>>>  
>>>  /**
>>> - * pci_rebar_get_current_size - get the current size of a BAR
>>> + * pci_rebar_get_current_size - get the current size of a Resizable BAR
>>>   * @pdev: PCI device
>>> - * @bar: BAR to set size to
>>> + * @bar: BAR to get the size from
>>>   *
>>> - * Read the size of a BAR from the resizable BAR config.
>>> - * Returns size if found or negative error code.
>>> + * Reads the current size of a BAR from the Resizable BAR config.
>>> + *
>>> + * Return: BAR Size if @bar is resizable (bit 0=1MB, bit 31=128TB), or
>>
>> This is a bit misleading since there is no mask returned but rather the 
>> order or in other words which bit of the mask was used. 
> 
> Thanks for noticing this. I'll removed "bit" x2 from it, does that fully 
> address your concern?

That works for me, yes.

Regards,
Christian.

>