linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Allow syscon to use spinlocks with regmap fast_io
@ 2022-04-04  8:47 AngeloGioacchino Del Regno
  2022-04-04  8:47 ` [PATCH v2 1/2] mfd: syscon: Allow using " AngeloGioacchino Del Regno
  2022-04-04  8:47 ` [PATCH v2 2/2] dt-bindings: mfd: syscon: Add support for regmap fast-io AngeloGioacchino Del Regno
  0 siblings, 2 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-04-04  8:47 UTC (permalink / raw)
  To: lee.jones
  Cc: robh+dt, krzk+dt, arnd, matthias.bgg, devicetree, linux-kernel,
	nfraprado, kernel, krzysztof.kozlowski,
	AngeloGioacchino Del Regno

This series adds support for enabling the regmap's fast_io configuration
option for SoCs featuring very fast MMIO operations, for which mutexes
are introducing a lot of overhead / latency.

This has been tested locally on some MediaTek Chromebooks (but, of course,
that requires devicetree patches that are not included in this series).

Changes in v2:
- Reworded dt-bindings fast-io description to remove references
  to regmap, making it generic, as per Krzysztof's suggestion.

AngeloGioacchino Del Regno (2):
  mfd: syscon: Allow using spinlocks with regmap fast_io
  dt-bindings: mfd: syscon: Add support for regmap fast-io

 Documentation/devicetree/bindings/mfd/syscon.yaml | 15 +++++++++++++++
 drivers/mfd/syscon.c                              |  4 ++++
 2 files changed, 19 insertions(+)

-- 
2.35.1


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

* [PATCH v2 1/2] mfd: syscon: Allow using spinlocks with regmap fast_io
  2022-04-04  8:47 [PATCH v2 0/2] Allow syscon to use spinlocks with regmap fast_io AngeloGioacchino Del Regno
@ 2022-04-04  8:47 ` AngeloGioacchino Del Regno
  2022-04-04  8:47 ` [PATCH v2 2/2] dt-bindings: mfd: syscon: Add support for regmap fast-io AngeloGioacchino Del Regno
  1 sibling, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-04-04  8:47 UTC (permalink / raw)
  To: lee.jones
  Cc: robh+dt, krzk+dt, arnd, matthias.bgg, devicetree, linux-kernel,
	nfraprado, kernel, krzysztof.kozlowski,
	AngeloGioacchino Del Regno

On at least some SoCs accessing MMIO regions is very fast and in some
cases acquiring a mutex for every IO operation brings a significant
overhead: this is also the rationale of regmap's fast_io configuration
parameter, which makes it switch to using a spinlock instead.

Since the typical use-case for syscon is to give access to misc system
registers (not representing any specific type of device) to one or more
other drivers, and since this is done via regmap anyway, allow such
devices to let syscon configure regmap with fast_io enabled and to let
this happen, add a Devicetree property "fast-io": when this is found,
syscon will set '.fast_io = true' in the regmap config.

Of course, it makes little sense to do that if a syscon node declares
a phandle to a hardware spinlock provider node, so we check for this
property only if no hwlock is present.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/mfd/syscon.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 191fdb87c424..3fcd9afdb9ef 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -101,6 +101,10 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
 		}
 	}
 
+	/* Checking for fast-io makes sense only if not using hwspinlock */
+	if (!syscon_config.use_hwlock && of_property_read_bool(np, "fast-io"))
+		syscon_config.fast_io = true;
+
 	syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", np,
 				       (u64)res.start);
 	syscon_config.reg_stride = reg_io_width;
-- 
2.35.1


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

* [PATCH v2 2/2] dt-bindings: mfd: syscon: Add support for regmap fast-io
  2022-04-04  8:47 [PATCH v2 0/2] Allow syscon to use spinlocks with regmap fast_io AngeloGioacchino Del Regno
  2022-04-04  8:47 ` [PATCH v2 1/2] mfd: syscon: Allow using " AngeloGioacchino Del Regno
@ 2022-04-04  8:47 ` AngeloGioacchino Del Regno
  2022-04-04  8:55   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-04-04  8:47 UTC (permalink / raw)
  To: lee.jones
  Cc: robh+dt, krzk+dt, arnd, matthias.bgg, devicetree, linux-kernel,
	nfraprado, kernel, krzysztof.kozlowski,
	AngeloGioacchino Del Regno

The syscon driver now enables the .fast_io regmap configuration when
the 'fast-io' property is found in a syscon node.

Keeping in mind that, in regmap, fast_io is checked only if we are
not using hardware spinlocks, allow the fast-io property only if
there is no hwlocks reference (and vice-versa).

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 Documentation/devicetree/bindings/mfd/syscon.yaml | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/syscon.yaml b/Documentation/devicetree/bindings/mfd/syscon.yaml
index 13baa452cc9d..621b0983b115 100644
--- a/Documentation/devicetree/bindings/mfd/syscon.yaml
+++ b/Documentation/devicetree/bindings/mfd/syscon.yaml
@@ -83,11 +83,26 @@ properties:
     $ref: /schemas/types.yaml#/definitions/uint32
     enum: [1, 2, 4, 8]
 
+  fast-io:
+    description:
+      Indicates that this bus has a very fast IO, for which
+      different locking methods should be used to reduce
+      overhead (e.g. spinlock instead of mutex).
+    type: boolean
+
   hwlocks:
     maxItems: 1
     description:
       Reference to a phandle of a hardware spinlock provider node.
 
+if:
+  required:
+    - hwlocks
+then:
+  not:
+    required:
+      - fast-io
+
 required:
   - compatible
   - reg
-- 
2.35.1


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

* Re: [PATCH v2 2/2] dt-bindings: mfd: syscon: Add support for regmap fast-io
  2022-04-04  8:47 ` [PATCH v2 2/2] dt-bindings: mfd: syscon: Add support for regmap fast-io AngeloGioacchino Del Regno
@ 2022-04-04  8:55   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-04-04  8:55 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, lee.jones
  Cc: robh+dt, krzk+dt, arnd, matthias.bgg, devicetree, linux-kernel,
	nfraprado, kernel

On 04/04/2022 10:47, AngeloGioacchino Del Regno wrote:
> The syscon driver now enables the .fast_io regmap configuration when
> the 'fast-io' property is found in a syscon node.
> 
> Keeping in mind that, in regmap, fast_io is checked only if we are
> not using hardware spinlocks, allow the fast-io property only if
> there is no hwlocks reference (and vice-versa).
> 

Please do not send a v2 yet, because we did not finish the discussion
from v1.

Best regards,
Krzysztof

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

end of thread, other threads:[~2022-04-04  8:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04  8:47 [PATCH v2 0/2] Allow syscon to use spinlocks with regmap fast_io AngeloGioacchino Del Regno
2022-04-04  8:47 ` [PATCH v2 1/2] mfd: syscon: Allow using " AngeloGioacchino Del Regno
2022-04-04  8:47 ` [PATCH v2 2/2] dt-bindings: mfd: syscon: Add support for regmap fast-io AngeloGioacchino Del Regno
2022-04-04  8:55   ` Krzysztof Kozlowski

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