2023-04-05 15:46:46

by William Breathitt Gray

[permalink] [raw]
Subject: [PATCH v6 0/3] Migrate the PCIe-IDIO-24 and WS16C48 GPIO drivers to the regmap API

Changes in v6:
- Wrap lines to 80 characters rather than 100 for set_type_config()
- Remove regmap_config max_register lines as superfluous
- Enable use_raw_spinlock to prevent deadlocks when running -rt kernels
- Check regmap_update_bit() ret value before goto exit_unlock
- Rename exit_early label to the more descriptive exit_unlock
- Add sparse annotations for lock acquire/release in
ws16c48_handle_pre_irq() and ws16c48_handle_post_irq()
- Explicitly add 0 to WS16C48_ENAB in ws16c48_irq_init_hw() for sake of
symmetry to match the other WS16C48_ENAB operations
Changes in v5:
- Refactor for map parameter removal from handle_mask_sync()
- Cleanups and line wrappings to 100 characters rather than 80
- Adjust to change mutex/spinlock_t type locks to raw_spin_lock_t type
- Remove pex8311_intcsr table configurations as superfluous
- Adjust to set pex8311_intcsr_regmap_config reg_base to
PLX_PEX8311_PCI_LCS_INTCSR
- Rename PAGE_FIELD_PAGE_* defines to POL_PAGE, ENAB_PAGE, and
INT_ID_PAGE
Changes in v4:
- Allocate idio24gpio before using it in idio_24_probe()
Changes in v3:
- Drop map from set_type_config() parameter list; regmap can be passed
by irq_drv_data instead
- Adjust idio_24_set_type_config() for parameter list
- Add mutex to prevent clobbering the COS_ENABLE register when masking
IRQ and setting their type configuration
Changes in v2:
- Simplify PCIe-IDIO-24 register offset defines to remove superfluous
arithmetic
- Check for NULL pointer after chip->irq_drv_data allocation
- Set gpio_regmap drvdata and use gpio_regmap_get_drvdata() to get the
regmap in idio_24_reg_map_xlate()

The regmap API supports IO port accessors so we can take advantage of
regmap abstractions rather than handling access to the device registers
directly in the driver.

A patch to pass irq_drv_data as a parameter for struct regmap_irq_chip
set_type_config() is included. This is needed by the
idio_24_set_type_config() and ws16c48_set_type_config() callbacks in
order to update the type configuration on their respective devices.

This patchset depends on the "Drop map from handle_mask_sync()
parameters" patchset [0].

[0] https://lore.kernel.org/all/[email protected]/

William Breathitt Gray (3):
regmap: Pass irq_drv_data as a parameter for set_type_config()
gpio: pcie-idio-24: Migrate to the regmap API
gpio: ws16c48: Migrate to the regmap API

drivers/base/regmap/regmap-irq.c | 8 +-
drivers/gpio/Kconfig | 6 +
drivers/gpio/gpio-pcie-idio-24.c | 677 +++++++++++--------------------
drivers/gpio/gpio-ws16c48.c | 552 +++++++++----------------
include/linux/regmap.h | 6 +-
5 files changed, 447 insertions(+), 802 deletions(-)


base-commit: 7b59bdbc3965ca8add53e084af394c13a2be22a8
prerequisite-patch-id: cd19046150b7cff1be4ac7152198777aa960a3df
prerequisite-patch-id: bd3e3830d9ce4f3876a77483364d7190b7fdffa7
--
2.39.2


2023-04-05 15:46:48

by William Breathitt Gray

[permalink] [raw]
Subject: [PATCH v6 1/3] regmap: Pass irq_drv_data as a parameter for set_type_config()

Allow the struct regmap_irq_chip set_type_config() callback to access
irq_drv_data by passing it as a parameter.

Signed-off-by: William Breathitt Gray <[email protected]>
---
Changes in v6:
- Wrap lines to 80 characters rather than 100
Changes in v5:
- Wrap lines to 100 characters rather than 80
Changes in v4: none
Changes in v3:
- Drop map from set_type_config() parameter list; regmap can be passed
by irq_drv_data instead
Changes in v2: none

drivers/base/regmap/regmap-irq.c | 8 +++++---
include/linux/regmap.h | 6 ++++--
2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index ff6b585b9049..362926d155a4 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -328,8 +328,8 @@ static int regmap_irq_set_type(struct irq_data *data, unsigned int type)
}

if (d->chip->set_type_config) {
- ret = d->chip->set_type_config(d->config_buf, type,
- irq_data, reg);
+ ret = d->chip->set_type_config(d->config_buf, type, irq_data,
+ reg, d->chip->irq_drv_data);
if (ret)
return ret;
}
@@ -653,13 +653,15 @@ EXPORT_SYMBOL_GPL(regmap_irq_get_irq_reg_linear);
* @type: The requested IRQ type.
* @irq_data: The IRQ being configured.
* @idx: Index of the irq's config registers within each array `buf[i]`
+ * @irq_drv_data: Driver specific IRQ data
*
* This is a &struct regmap_irq_chip->set_type_config callback suitable for
* chips with one config register. Register values are updated according to
* the &struct regmap_irq_type data associated with an IRQ.
*/
int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type,
- const struct regmap_irq *irq_data, int idx)
+ const struct regmap_irq *irq_data,
+ int idx, void *irq_drv_data)
{
const struct regmap_irq_type *t = &irq_data->type;

diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 8d9d601da782..18311c12c44a 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1651,7 +1651,8 @@ struct regmap_irq_chip {
int (*set_type_virt)(unsigned int **buf, unsigned int type,
unsigned long hwirq, int reg);
int (*set_type_config)(unsigned int **buf, unsigned int type,
- const struct regmap_irq *irq_data, int idx);
+ const struct regmap_irq *irq_data, int idx,
+ void *irq_drv_data);
unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
unsigned int base, int index);
void *irq_drv_data;
@@ -1660,7 +1661,8 @@ struct regmap_irq_chip {
unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data,
unsigned int base, int index);
int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type,
- const struct regmap_irq *irq_data, int idx);
+ const struct regmap_irq *irq_data,
+ int idx, void *irq_drv_data);

int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
int irq_base, const struct regmap_irq_chip *chip,
--
2.39.2

2023-04-05 16:14:21

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v6 0/3] Migrate the PCIe-IDIO-24 and WS16C48 GPIO drivers to the regmap API

On Wed, Apr 05, 2023 at 11:45:41AM -0400, William Breathitt Gray wrote:
> Changes in v6:
> - Wrap lines to 80 characters rather than 100 for set_type_config()
> - Remove regmap_config max_register lines as superfluous
> - Enable use_raw_spinlock to prevent deadlocks when running -rt kernels
> - Check regmap_update_bit() ret value before goto exit_unlock
> - Rename exit_early label to the more descriptive exit_unlock
> - Add sparse annotations for lock acquire/release in
> ws16c48_handle_pre_irq() and ws16c48_handle_post_irq()
> - Explicitly add 0 to WS16C48_ENAB in ws16c48_irq_init_hw() for sake of
> symmetry to match the other WS16C48_ENAB operations
> Changes in v5:
> - Refactor for map parameter removal from handle_mask_sync()
> - Cleanups and line wrappings to 100 characters rather than 80
> - Adjust to change mutex/spinlock_t type locks to raw_spin_lock_t type
> - Remove pex8311_intcsr table configurations as superfluous
> - Adjust to set pex8311_intcsr_regmap_config reg_base to
> PLX_PEX8311_PCI_LCS_INTCSR
> - Rename PAGE_FIELD_PAGE_* defines to POL_PAGE, ENAB_PAGE, and
> INT_ID_PAGE
> Changes in v4:
> - Allocate idio24gpio before using it in idio_24_probe()
> Changes in v3:
> - Drop map from set_type_config() parameter list; regmap can be passed
> by irq_drv_data instead
> - Adjust idio_24_set_type_config() for parameter list
> - Add mutex to prevent clobbering the COS_ENABLE register when masking
> IRQ and setting their type configuration
> Changes in v2:
> - Simplify PCIe-IDIO-24 register offset defines to remove superfluous
> arithmetic
> - Check for NULL pointer after chip->irq_drv_data allocation
> - Set gpio_regmap drvdata and use gpio_regmap_get_drvdata() to get the
> regmap in idio_24_reg_map_xlate()
>
> The regmap API supports IO port accessors so we can take advantage of
> regmap abstractions rather than handling access to the device registers
> directly in the driver.
>
> A patch to pass irq_drv_data as a parameter for struct regmap_irq_chip
> set_type_config() is included. This is needed by the
> idio_24_set_type_config() and ws16c48_set_type_config() callbacks in
> order to update the type configuration on their respective devices.
>
> This patchset depends on the "Drop map from handle_mask_sync()
> parameters" patchset [0].
>
> [0] https://lore.kernel.org/all/[email protected]/

Looks good to me now.
Reviewed-by: Andy Shevchenko <[email protected]>

It might be that regmap locks are unnecessary, but as far as I understood
dropping them would require more intrusion into the regmap APIs along with
GPIO regmap implementation.

> William Breathitt Gray (3):
> regmap: Pass irq_drv_data as a parameter for set_type_config()
> gpio: pcie-idio-24: Migrate to the regmap API
> gpio: ws16c48: Migrate to the regmap API
>
> drivers/base/regmap/regmap-irq.c | 8 +-
> drivers/gpio/Kconfig | 6 +
> drivers/gpio/gpio-pcie-idio-24.c | 677 +++++++++++--------------------
> drivers/gpio/gpio-ws16c48.c | 552 +++++++++----------------
> include/linux/regmap.h | 6 +-
> 5 files changed, 447 insertions(+), 802 deletions(-)
>
>
> base-commit: 7b59bdbc3965ca8add53e084af394c13a2be22a8
> prerequisite-patch-id: cd19046150b7cff1be4ac7152198777aa960a3df
> prerequisite-patch-id: bd3e3830d9ce4f3876a77483364d7190b7fdffa7
> --
> 2.39.2
>

--
With Best Regards,
Andy Shevchenko


2023-04-05 21:08:39

by Mark Brown

[permalink] [raw]
Subject: Re: (subset) [PATCH v6 0/3] Migrate the PCIe-IDIO-24 and WS16C48 GPIO drivers to the regmap API

On Wed, 05 Apr 2023 11:45:41 -0400, William Breathitt Gray wrote:
> Changes in v6:
> - Wrap lines to 80 characters rather than 100 for set_type_config()
> - Remove regmap_config max_register lines as superfluous
> - Enable use_raw_spinlock to prevent deadlocks when running -rt kernels
> - Check regmap_update_bit() ret value before goto exit_unlock
> - Rename exit_early label to the more descriptive exit_unlock
> - Add sparse annotations for lock acquire/release in
> ws16c48_handle_pre_irq() and ws16c48_handle_post_irq()
> - Explicitly add 0 to WS16C48_ENAB in ws16c48_irq_init_hw() for sake of
> symmetry to match the other WS16C48_ENAB operations
> Changes in v5:
> - Refactor for map parameter removal from handle_mask_sync()
> - Cleanups and line wrappings to 100 characters rather than 80
> - Adjust to change mutex/spinlock_t type locks to raw_spin_lock_t type
> - Remove pex8311_intcsr table configurations as superfluous
> - Adjust to set pex8311_intcsr_regmap_config reg_base to
> PLX_PEX8311_PCI_LCS_INTCSR
> - Rename PAGE_FIELD_PAGE_* defines to POL_PAGE, ENAB_PAGE, and
> INT_ID_PAGE
> Changes in v4:
> - Allocate idio24gpio before using it in idio_24_probe()
> Changes in v3:
> - Drop map from set_type_config() parameter list; regmap can be passed
> by irq_drv_data instead
> - Adjust idio_24_set_type_config() for parameter list
> - Add mutex to prevent clobbering the COS_ENABLE register when masking
> IRQ and setting their type configuration
> Changes in v2:
> - Simplify PCIe-IDIO-24 register offset defines to remove superfluous
> arithmetic
> - Check for NULL pointer after chip->irq_drv_data allocation
> - Set gpio_regmap drvdata and use gpio_regmap_get_drvdata() to get the
> regmap in idio_24_reg_map_xlate()
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/3] regmap: Pass irq_drv_data as a parameter for set_type_config()
commit: 7697c64b9e4908196f0ae68aa6d423dd40607973

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

2023-04-06 17:25:58

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v6 1/3] regmap: Pass irq_drv_data as a parameter for set_type_config()

On Wed, Apr 05, 2023 at 11:45:42AM -0400, William Breathitt Gray wrote:
> Allow the struct regmap_irq_chip set_type_config() callback to access
> irq_drv_data by passing it as a parameter.

The following changes since commit e8d018dd0257f744ca50a729e3d042cf2ec9da65:

Linux 6.3-rc3 (2023-03-19 13:27:55 -0700)

are available in the Git repository at:

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/regmap-set-type-irq-drv-data

for you to fetch changes up to 7697c64b9e4908196f0ae68aa6d423dd40607973:

regmap: Pass irq_drv_data as a parameter for set_type_config() (2023-04-05 17:19:24 +0100)

----------------------------------------------------------------
regmap: Pass irq_drv_data as a parameter for set_type_config()

Allow callbacks to access irq_drv_data.

----------------------------------------------------------------
William Breathitt Gray (1):
regmap: Pass irq_drv_data as a parameter for set_type_config()

drivers/base/regmap/regmap-irq.c | 8 +++++---
include/linux/regmap.h | 6 ++++--
2 files changed, 9 insertions(+), 5 deletions(-)


Attachments:
(No filename) (1.10 kB)
signature.asc (499.00 B)
Download all attachments

2023-04-07 10:19:11

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v6 1/3] regmap: Pass irq_drv_data as a parameter for set_type_config()

On Thu, Apr 6, 2023 at 7:23 PM Mark Brown <[email protected]> wrote:
>
> On Wed, Apr 05, 2023 at 11:45:42AM -0400, William Breathitt Gray wrote:
> > Allow the struct regmap_irq_chip set_type_config() callback to access
> > irq_drv_data by passing it as a parameter.
>
> The following changes since commit e8d018dd0257f744ca50a729e3d042cf2ec9da65:
>
> Linux 6.3-rc3 (2023-03-19 13:27:55 -0700)
>
> are available in the Git repository at:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/regmap-set-type-irq-drv-data
>
> for you to fetch changes up to 7697c64b9e4908196f0ae68aa6d423dd40607973:
>
> regmap: Pass irq_drv_data as a parameter for set_type_config() (2023-04-05 17:19:24 +0100)
>
> ----------------------------------------------------------------
> regmap: Pass irq_drv_data as a parameter for set_type_config()
>
> Allow callbacks to access irq_drv_data.
>
> ----------------------------------------------------------------
> William Breathitt Gray (1):
> regmap: Pass irq_drv_data as a parameter for set_type_config()
>
> drivers/base/regmap/regmap-irq.c | 8 +++++---
> include/linux/regmap.h | 6 ++++--
> 2 files changed, 9 insertions(+), 5 deletions(-)

Pulled Mark's tag and applied the two remaining patches, thanks!

Bart

2023-04-07 11:41:02

by William Breathitt Gray

[permalink] [raw]
Subject: Re: [PATCH v6 1/3] regmap: Pass irq_drv_data as a parameter for set_type_config()

On Fri, Apr 07, 2023 at 12:17:31PM +0200, Bartosz Golaszewski wrote:
> On Thu, Apr 6, 2023 at 7:23 PM Mark Brown <[email protected]> wrote:
> >
> > On Wed, Apr 05, 2023 at 11:45:42AM -0400, William Breathitt Gray wrote:
> > > Allow the struct regmap_irq_chip set_type_config() callback to access
> > > irq_drv_data by passing it as a parameter.
> >
> > The following changes since commit e8d018dd0257f744ca50a729e3d042cf2ec9da65:
> >
> > Linux 6.3-rc3 (2023-03-19 13:27:55 -0700)
> >
> > are available in the Git repository at:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/regmap-set-type-irq-drv-data
> >
> > for you to fetch changes up to 7697c64b9e4908196f0ae68aa6d423dd40607973:
> >
> > regmap: Pass irq_drv_data as a parameter for set_type_config() (2023-04-05 17:19:24 +0100)
> >
> > ----------------------------------------------------------------
> > regmap: Pass irq_drv_data as a parameter for set_type_config()
> >
> > Allow callbacks to access irq_drv_data.
> >
> > ----------------------------------------------------------------
> > William Breathitt Gray (1):
> > regmap: Pass irq_drv_data as a parameter for set_type_config()
> >
> > drivers/base/regmap/regmap-irq.c | 8 +++++---
> > include/linux/regmap.h | 6 ++++--
> > 2 files changed, 9 insertions(+), 5 deletions(-)
>
> Pulled Mark's tag and applied the two remaining patches, thanks!
>
> Bart

Bart, the two remaining patches still depend on the handle_mask_sync
change descripted in the cover patch [0].

Mark, are you able to Ack those patches or alternatively provide an
immutable branch with them? We need the handle_mask_sync change as well
for the idio-16 migration patchset [1].

William Breathitt Gray

[0] https://lore.kernel.org/all/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/


Attachments:
(No filename) (1.91 kB)
signature.asc (235.00 B)
Download all attachments

2023-04-07 11:46:05

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v6 1/3] regmap: Pass irq_drv_data as a parameter for set_type_config()

On Fri, Apr 07, 2023 at 07:39:58AM -0400, William Breathitt Gray wrote:
> On Fri, Apr 07, 2023 at 12:17:31PM +0200, Bartosz Golaszewski wrote:

> Bart, the two remaining patches still depend on the handle_mask_sync
> change descripted in the cover patch [0].

> Mark, are you able to Ack those patches or alternatively provide an
> immutable branch with them? We need the handle_mask_sync change as well
> for the idio-16 migration patchset [1].

I don't have those patches, I presume I was expecting some
change. Please resend.


Attachments:
(No filename) (542.00 B)
signature.asc (499.00 B)
Download all attachments

2023-04-07 11:52:22

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v6 1/3] regmap: Pass irq_drv_data as a parameter for set_type_config()

On Fri, Apr 7, 2023 at 1:40 PM William Breathitt Gray
<[email protected]> wrote:
>
> On Fri, Apr 07, 2023 at 12:17:31PM +0200, Bartosz Golaszewski wrote:
> > On Thu, Apr 6, 2023 at 7:23 PM Mark Brown <[email protected]> wrote:
> > >
> > > On Wed, Apr 05, 2023 at 11:45:42AM -0400, William Breathitt Gray wrote:
> > > > Allow the struct regmap_irq_chip set_type_config() callback to access
> > > > irq_drv_data by passing it as a parameter.
> > >
> > > The following changes since commit e8d018dd0257f744ca50a729e3d042cf2ec9da65:
> > >
> > > Linux 6.3-rc3 (2023-03-19 13:27:55 -0700)
> > >
> > > are available in the Git repository at:
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/regmap-set-type-irq-drv-data
> > >
> > > for you to fetch changes up to 7697c64b9e4908196f0ae68aa6d423dd40607973:
> > >
> > > regmap: Pass irq_drv_data as a parameter for set_type_config() (2023-04-05 17:19:24 +0100)
> > >
> > > ----------------------------------------------------------------
> > > regmap: Pass irq_drv_data as a parameter for set_type_config()
> > >
> > > Allow callbacks to access irq_drv_data.
> > >
> > > ----------------------------------------------------------------
> > > William Breathitt Gray (1):
> > > regmap: Pass irq_drv_data as a parameter for set_type_config()
> > >
> > > drivers/base/regmap/regmap-irq.c | 8 +++++---
> > > include/linux/regmap.h | 6 ++++--
> > > 2 files changed, 9 insertions(+), 5 deletions(-)
> >
> > Pulled Mark's tag and applied the two remaining patches, thanks!
> >
> > Bart
>
> Bart, the two remaining patches still depend on the handle_mask_sync
> change descripted in the cover patch [0].
>
> Mark, are you able to Ack those patches or alternatively provide an
> immutable branch with them? We need the handle_mask_sync change as well
> for the idio-16 migration patchset [1].
>
> William Breathitt Gray
>
> [0] https://lore.kernel.org/all/[email protected]/
> [1] https://lore.kernel.org/all/[email protected]/

Ok, I'll back them out.

Bart

2023-04-10 22:16:38

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v6 0/3] Migrate the PCIe-IDIO-24 and WS16C48 GPIO drivers to the regmap API

On Wed, Apr 5, 2023 at 5:45 PM William Breathitt Gray
<[email protected]> wrote:

> Changes in v6:

Excellent and persevere work,
Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij