mbox series

[v4,0/7] PCI: Remove pcim_iounmap_regions()

Message ID 20240827185616.45094-1-pstanner@redhat.com
Headers show
Series PCI: Remove pcim_iounmap_regions() | expand

Message

Philipp Stanner Aug. 27, 2024, 6:56 p.m. UTC
OK, so unfortunately it seems very challenging to reconcile the merge
conflict pointed up by Serge between net-next and pci-devres regarding
"ethernet: stmicro": A patch that applies to the net-next tree does not
apply anymore to pci-devres (and vice versa).

So I actually think that it would be best if we just drop the portation
of "ethernet: stmicro" for now and port it as the last user in v6.13.

That should then be trivial.

Changes in v4:
  - Drop the "ethernet: stmicro: [...] patch since it doesn't apply to
    net-next, and making it apply to that prevents it from being
    applyable to PCI ._. (Serge, me)
  - Instead, deprecate pcim_iounmap_regions() and keep "ethernet:
    stimicro" as the last user for now. Perform the deprecation in the
    series' first patch. Remove the Reviewed-by's givin so far to that
    patch.
  - ethernet: cavium: Use PTR_ERR_OR_ZERO(). (Andy)
  - vdpa: solidrun (Bugfix) Correct wrong printf string (was "psnet" instead of
    "snet"). (Christophe)
  - vdpa: solidrun (Bugfix): Add missing blank line. (Andy)
  - vdpa: solidrun (Portation): Use PTR_ERR_OR_ZERO(). (Andy)
  - Apply Reviewed-by's from Andy and Xu Yilun.

Changes in v3:
  - fpga/dfl-pci.c: remove now surplus wrapper around
    pcim_iomap_region(). (Andy)
  - block: mtip32xx: remove now surplus label. (Andy)
  - vdpa: solidrun: Bugfix: Include forgotten place where stack UB
    occurs. (Andy, Christophe)
  - Some minor wording improvements in commit messages. (Me)

Changes in v2:
  - Add a fix for the UB stack usage bug in vdap/solidrun. Separate
    patch, put stable kernel on CC. (Christophe, Andy).
  - Drop unnecessary pcim_release_region() in mtip32xx (Andy)
  - Consequently, drop patch "PCI: Make pcim_release_region() a public
    function", since there's no user anymore. (obsoletes the squash
    requested by Damien).
  - vdap/solidrun:
    • make 'i' an 'unsigned short' (Andy, me)
    • Use 'continue' to simplify loop (Andy)
    • Remove leftover blank line
  - Apply given Reviewed- / acked-bys (Andy, Damien, Bartosz)


Important things first:
This series is based on [1] and [2] which Bjorn Helgaas has currently
queued for v6.12 in the PCI tree.

This series shall remove pcim_iounmap_regions() in order to make way to
remove its brother, pcim_iomap_regions().

@Bjorn: Feel free to squash the PCI commits.

Regards,
P.

[1] https://lore.kernel.org/all/20240729093625.17561-4-pstanner@redhat.com/
[2] https://lore.kernel.org/all/20240807083018.8734-2-pstanner@redhat.com/

Philipp Stanner (7):
  PCI: Deprecate pcim_iounmap_regions()
  fpga/dfl-pci.c: Replace deprecated PCI functions
  block: mtip32xx: Replace deprecated PCI functions
  gpio: Replace deprecated PCI functions
  ethernet: cavium: Replace deprecated PCI functions
  vdpa: solidrun: Fix UB bug with devres
  vdap: solidrun: Replace deprecated PCI functions

 drivers/block/mtip32xx/mtip32xx.c             | 16 +++--
 drivers/fpga/dfl-pci.c                        | 16 ++---
 drivers/gpio/gpio-merrifield.c                | 14 ++---
 .../net/ethernet/cavium/common/cavium_ptp.c   |  6 +-
 drivers/pci/devres.c                          |  8 ++-
 drivers/vdpa/solidrun/snet_main.c             | 59 ++++++++-----------
 include/linux/pci.h                           |  1 +
 7 files changed, 51 insertions(+), 69 deletions(-)

Comments

Philipp Stanner Aug. 27, 2024, 7:01 p.m. UTC | #1
PS:
This series's title should now obviously be "*Mostly* Remove
pcim_iounmap_regions()".

On Tue, 2024-08-27 at 20:56 +0200, Philipp Stanner wrote:
> OK, so unfortunately it seems very challenging to reconcile the merge
> conflict pointed up by Serge between net-next and pci-devres
> regarding
> "ethernet: stmicro": A patch that applies to the net-next tree does
> not
> apply anymore to pci-devres (and vice versa).
> 
> So I actually think that it would be best if we just drop the
> portation
> of "ethernet: stmicro" for now and port it as the last user in v6.13.
> 
> That should then be trivial.
> 
> Changes in v4:
>   - Drop the "ethernet: stmicro: [...] patch since it doesn't apply
> to
>     net-next, and making it apply to that prevents it from being
>     applyable to PCI ._. (Serge, me)
>   - Instead, deprecate pcim_iounmap_regions() and keep "ethernet:
>     stimicro" as the last user for now. Perform the deprecation in
> the
>     series' first patch. Remove the Reviewed-by's givin so far to
> that
>     patch.
>   - ethernet: cavium: Use PTR_ERR_OR_ZERO(). (Andy)
>   - vdpa: solidrun (Bugfix) Correct wrong printf string (was "psnet"
> instead of
>     "snet"). (Christophe)
>   - vdpa: solidrun (Bugfix): Add missing blank line. (Andy)
>   - vdpa: solidrun (Portation): Use PTR_ERR_OR_ZERO(). (Andy)
>   - Apply Reviewed-by's from Andy and Xu Yilun.
> 
> Changes in v3:
>   - fpga/dfl-pci.c: remove now surplus wrapper around
>     pcim_iomap_region(). (Andy)
>   - block: mtip32xx: remove now surplus label. (Andy)
>   - vdpa: solidrun: Bugfix: Include forgotten place where stack UB
>     occurs. (Andy, Christophe)
>   - Some minor wording improvements in commit messages. (Me)
> 
> Changes in v2:
>   - Add a fix for the UB stack usage bug in vdap/solidrun. Separate
>     patch, put stable kernel on CC. (Christophe, Andy).
>   - Drop unnecessary pcim_release_region() in mtip32xx (Andy)
>   - Consequently, drop patch "PCI: Make pcim_release_region() a
> public
>     function", since there's no user anymore. (obsoletes the squash
>     requested by Damien).
>   - vdap/solidrun:
>     • make 'i' an 'unsigned short' (Andy, me)
>     • Use 'continue' to simplify loop (Andy)
>     • Remove leftover blank line
>   - Apply given Reviewed- / acked-bys (Andy, Damien, Bartosz)
> 
> 
> Important things first:
> This series is based on [1] and [2] which Bjorn Helgaas has currently
> queued for v6.12 in the PCI tree.
> 
> This series shall remove pcim_iounmap_regions() in order to make way
> to
> remove its brother, pcim_iomap_regions().
> 
> @Bjorn: Feel free to squash the PCI commits.
> 
> Regards,
> P.
> 
> [1]
> https://lore.kernel.org/all/20240729093625.17561-4-pstanner@redhat.com/
> [2]
> https://lore.kernel.org/all/20240807083018.8734-2-pstanner@redhat.com/
> 
> Philipp Stanner (7):
>   PCI: Deprecate pcim_iounmap_regions()
>   fpga/dfl-pci.c: Replace deprecated PCI functions
>   block: mtip32xx: Replace deprecated PCI functions
>   gpio: Replace deprecated PCI functions
>   ethernet: cavium: Replace deprecated PCI functions
>   vdpa: solidrun: Fix UB bug with devres
>   vdap: solidrun: Replace deprecated PCI functions
> 
>  drivers/block/mtip32xx/mtip32xx.c             | 16 +++--
>  drivers/fpga/dfl-pci.c                        | 16 ++---
>  drivers/gpio/gpio-merrifield.c                | 14 ++---
>  .../net/ethernet/cavium/common/cavium_ptp.c   |  6 +-
>  drivers/pci/devres.c                          |  8 ++-
>  drivers/vdpa/solidrun/snet_main.c             | 59 ++++++++---------
> --
>  include/linux/pci.h                           |  1 +
>  7 files changed, 51 insertions(+), 69 deletions(-)
>
Jens Axboe Aug. 27, 2024, 7:05 p.m. UTC | #2
On 8/27/24 12:56 PM, Philipp Stanner wrote:
> pcim_iomap_regions() and pcim_iomap_table() have been deprecated by the
> PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate
> pcim_iomap_table(), pcim_iomap_regions_request_all()").
> 
> In mtip32xx, these functions can easily be replaced by their respective
> successors, pcim_request_region() and pcim_iomap(). Moreover, the
> driver's calls to pcim_iounmap_regions() in probe()'s error path and in
> remove() are not necessary. Cleanup can be performed by PCI devres
> automatically.
> 
> Replace pcim_iomap_regions() and pcim_iomap_table().
> 
> Remove the calls to pcim_iounmap_regions().

Looks fine to me - since it depends on other trees, feel free to take it
through those:

Reviewed-by: Jens Axboe <axboe@kernel.dk>
Philipp Stanner Aug. 28, 2024, 6:56 a.m. UTC | #3
On Tue, 2024-08-27 at 20:56 +0200, Philipp Stanner wrote:
> pcim_iomap_regions() and pcim_iomap_table() have been deprecated by
> the PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate
> pcim_iomap_table(), pcim_iomap_regions_request_all()").
> 
> Furthermore, the driver contains an unneeded call to
> pcim_iounmap_regions() in its probe() function's error unwind path.
> 
> Replace the deprecated PCI functions with pcim_iomap_region().
> 
> Remove the unnecessary call to pcim_iounmap_regions().
> 
> Signed-off-by: Philipp Stanner <pstanner@redhat.com>
> ---
>  drivers/net/ethernet/cavium/common/cavium_ptp.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cavium/common/cavium_ptp.c
> b/drivers/net/ethernet/cavium/common/cavium_ptp.c
> index 9fd717b9cf69..914ccc8eaf5e 100644
> --- a/drivers/net/ethernet/cavium/common/cavium_ptp.c
> +++ b/drivers/net/ethernet/cavium/common/cavium_ptp.c
> @@ -239,12 +239,11 @@ static int cavium_ptp_probe(struct pci_dev
> *pdev,
>  	if (err)
>  		goto error_free;
>  
> -	err = pcim_iomap_regions(pdev, 1 << PCI_PTP_BAR_NO,
> pci_name(pdev));
> +	clock->reg_base = pcim_iomap_region(pdev, PCI_PTP_BAR_NO,
> pci_name(pdev));
> +	err = PTR_ERR_OR_ZERO(clock->reg_base);
>  	if (err)
>  		goto error_free;
>  
> -	clock->reg_base = pcim_iomap_table(pdev)[PCI_PTP_BAR_NO];
> -
>  	spin_lock_init(&clock->spin_lock);
>  
>  	cc = &clock->cycle_counter;
> @@ -292,7 +291,6 @@ static int cavium_ptp_probe(struct pci_dev *pdev,
>  	clock_cfg = readq(clock->reg_base + PTP_CLOCK_CFG);
>  	clock_cfg &= ~PTP_CLOCK_CFG_PTP_EN;
>  	writeq(clock_cfg, clock->reg_base + PTP_CLOCK_CFG);
> -	pcim_iounmap_regions(pdev, 1 << PCI_PTP_BAR_NO);

I think I removed that by accident – thinking about it, we should not
remove it since the driver later returns 0 from its probe(). So we
should not keep blocking the region.

Has to be addressed in v5.

P.

>  
>  error_free:
>  	devm_kfree(dev, clock);
Philipp Stanner Aug. 28, 2024, 7:10 a.m. UTC | #4
On Tue, 2024-08-27 at 13:05 -0600, Jens Axboe wrote:
> On 8/27/24 12:56 PM, Philipp Stanner wrote:
> > pcim_iomap_regions() and pcim_iomap_table() have been deprecated by
> > the
> > PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate
> > pcim_iomap_table(), pcim_iomap_regions_request_all()").
> > 
> > In mtip32xx, these functions can easily be replaced by their
> > respective
> > successors, pcim_request_region() and pcim_iomap(). Moreover, the
> > driver's calls to pcim_iounmap_regions() in probe()'s error path
> > and in
> > remove() are not necessary. Cleanup can be performed by PCI devres
> > automatically.
> > 
> > Replace pcim_iomap_regions() and pcim_iomap_table().
> > 
> > Remove the calls to pcim_iounmap_regions().
> 
> Looks fine to me - since it depends on other trees, feel free to take
> it
> through those:
> 
> Reviewed-by: Jens Axboe <axboe@kernel.dk>

Thank you for the review.

I have to provide a v5 because of an issue in another patch. While I'm
at it, I'd modify this patch here so that the comment above
pcim_request_region() is descriptive of the actual events:

-	/* Map BAR5 to memory. */
+	/* Request BAR5. */


I'd keep your Reviewed-by if that's OK. It's the only change I'd do.

Regards,
P.
Jens Axboe Aug. 28, 2024, 2:49 p.m. UTC | #5
On 8/28/24 1:10 AM, Philipp Stanner wrote:
> On Tue, 2024-08-27 at 13:05 -0600, Jens Axboe wrote:
>> On 8/27/24 12:56 PM, Philipp Stanner wrote:
>>> pcim_iomap_regions() and pcim_iomap_table() have been deprecated by
>>> the
>>> PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate
>>> pcim_iomap_table(), pcim_iomap_regions_request_all()").
>>>
>>> In mtip32xx, these functions can easily be replaced by their
>>> respective
>>> successors, pcim_request_region() and pcim_iomap(). Moreover, the
>>> driver's calls to pcim_iounmap_regions() in probe()'s error path
>>> and in
>>> remove() are not necessary. Cleanup can be performed by PCI devres
>>> automatically.
>>>
>>> Replace pcim_iomap_regions() and pcim_iomap_table().
>>>
>>> Remove the calls to pcim_iounmap_regions().
>>
>> Looks fine to me - since it depends on other trees, feel free to take
>> it
>> through those:
>>
>> Reviewed-by: Jens Axboe <axboe@kernel.dk>
> 
> Thank you for the review.
> 
> I have to provide a v5 because of an issue in another patch. While I'm
> at it, I'd modify this patch here so that the comment above
> pcim_request_region() is descriptive of the actual events:
> 
> -	/* Map BAR5 to memory. */
> +	/* Request BAR5. */
> 
> 
> I'd keep your Reviewed-by if that's OK. It's the only change I'd do.

That's fine.