firefly-linux-kernel-4.4.55.git
9 years agoMerge remote-tracking branch 'lsk/v3.10/topic/cpufreq' into linux-linaro-lsk
Mark Brown [Mon, 9 Mar 2015 12:27:27 +0000 (12:27 +0000)]
Merge remote-tracking branch 'lsk/v3.10/topic/cpufreq' into linux-linaro-lsk

9 years agocpufreq: Revert "cpufreq: suspend governors on system suspend/hibernate"
Mark Brown [Mon, 9 Mar 2015 12:26:45 +0000 (12:26 +0000)]
cpufreq: Revert "cpufreq: suspend governors on system suspend/hibernate"

This reverts commit adb665056afe23db0687c1d1a208806c108add08.

The commit has too many hidden dependencies to be sensibly backported.

Signed-off-by: Mark Brown <broonie@linaro.org>
9 years agocpufreq: Revert "cpufreq: Don't iterate over all CPUs when suspending and resuming...
Mark Brown [Mon, 9 Mar 2015 12:25:38 +0000 (12:25 +0000)]
cpufreq: Revert "cpufreq: Don't iterate over all CPUs when suspending and resuming governors"

This reverts commit 212df5dd3212092602119d03a2f5d3a27be77ce4.

The commit it's fixing has too many other dependencies.

Signed-off-by: Mark Brown <broonie@linaro.org>
9 years agoMerge remote-tracking branch 'lsk/v3.10/topic/coresight' into linux-linaro-lsk
Mark Brown [Tue, 3 Mar 2015 09:33:54 +0000 (09:33 +0000)]
Merge remote-tracking branch 'lsk/v3.10/topic/coresight' into linux-linaro-lsk

9 years agoMerge branch 'v3.10-backport' of http://git.linaro.org/people/mathieu.poirier/coresig...
Mark Brown [Tue, 3 Mar 2015 09:23:31 +0000 (09:23 +0000)]
Merge branch 'v3.10-backport' of git.linaro.org/people/mathieu.poirier/coresight into lsk-v3.10-coresight

9 years agocoresight: fix function etm_writel_cp14() parameter order
Kaixu Xia [Mon, 26 Jan 2015 16:22:25 +0000 (09:22 -0700)]
coresight: fix function etm_writel_cp14() parameter order

Function etm_writel_cp14() takes an offset and a value rather
than the other way around, something this patch is correcting.
The semantic remains the same since it is only a function stub.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 5fb31cd839c21130c0b2524ceb9244e98dfe10e3)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight-etm: remove check for unknown Kconfig macro
Paul Bolle [Mon, 26 Jan 2015 16:22:24 +0000 (09:22 -0700)]
coresight-etm: remove check for unknown Kconfig macro

The CoreSight ETM/PTM driver contains a check for a
CONFIG_CORESIGHT_SOURCE_ETM_DEFAULT_ENABLE macro. But there's no related
Kconfig symbol CORESIGHT_SOURCE_ETM_DEFAULT_ENABLE. Remove that check
and the single line of code it hides.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 406b9f659fbc966ab47a1fe8f5c1a2e8110483ad)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: fixing CPU hwid lookup in device tree
Mathieu Poirier [Mon, 26 Jan 2015 16:22:23 +0000 (09:22 -0700)]
coresight: fixing CPU hwid lookup in device tree

Some DT specification will represent CPU nodes with address
cells greater than one, making the current code fail.  Using
the proper retrieval helper function ensure the correct hwid
for CPUs is read properly with different address cell size.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 34a03c1d30f04ca7439c685c0ea9b7d79c353705)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: remove the unnecessary function coresight_is_bit_set()
Kaixu Xia [Mon, 26 Jan 2015 16:22:22 +0000 (09:22 -0700)]
coresight: remove the unnecessary function coresight_is_bit_set()

This function coresight_is_bit_set() isn't called, so we should
remove it.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit c4546f246636ccf4cda092bcfcafcb5f5f752ec7)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: fix the debug AMBA bus name
Kaixu Xia [Mon, 26 Jan 2015 16:22:21 +0000 (09:22 -0700)]
coresight: fix the debug AMBA bus name

The right debug AMBA bus name should be APB(Advanced Peripheral Bus),
so just fix it.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 7af8792b4d3ad94774fb40f422fa245ab3755bb4)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: remove the extra spaces
Kaixu Xia [Mon, 26 Jan 2015 16:22:20 +0000 (09:22 -0700)]
coresight: remove the extra spaces

There are some extra spaces, so just remove them from these lines.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d786a47de97fd194d6cf4f9087543119b9b330c3)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: fix the link between orphan connection and newly added device
Kaixu Xia [Mon, 26 Jan 2015 16:22:19 +0000 (09:22 -0700)]
coresight: fix the link between orphan connection and newly added device

When founding a component that has orphan connections, we should
validate if it match the newly added device. If it does not match,
only then should the @still_orphan flag should be set.

The tested result as follows.
pre:
/sys/bus/coresight/devices # echo 1 > e3c42000.etb/enable_sink
/sys/bus/coresight/devices # echo 1 > e3c7c000.ptm/enable_source
[   15.527692] Unable to handle kernel NULL pointer dereference at virtual address 00000124
[   15.555142] pgd = c2294000
[   15.564226] [00000124] *pgd=3d393831, *pte=00000000, *ppte=00000000
[   15.585391] Internal error: Oops: 817 [#1] PREEMPT SMP ARM
[   15.603807] CPU: 0 PID: 144 Comm: sh Not tainted 3.17.0-rc1-12634-g1222fe0-dirty #3
[   15.629490] task: ed3803c0 ti: c213a000 task.ti: c213a000
[   15.647627] PC is at coresight_build_paths+0x1c/0x314
[   15.664579] LR is at coresight_build_paths+0x6c/0x314
[   15.681526] pc : [<c02da20c>]    lr : [<c02da25c>]    psr: 20000013
[   15.681526] sp : c213be88  ip : c02da800  fp : 00000000
[   15.720023] r10: 00000002  r9 : ed13250c  r8 : 00000001
[   15.737549] r7 : c213bee8  r6 : ffffffea  r5 : 00000000  r4 : 00000124
[   15.759446] r3 : ed216f24  r2 : 00000001  r1 : c213bee8  r0 : 00000000
[   15.781346] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user

post:
/sys/bus/coresight/devices # echo 1 > e3c42000.etb/enable_sink
/sys/bus/coresight/devices # echo 1 > e3c7c000.ptm/enable_source
[   59.934255] coresight-etb10 e3c42000.etb: ETB enabled
[   59.951317] coresight-replicator replicator0: REPLICATOR enabled
[   59.971581] coresight-funnel e3c41000.funnel: FUNNEL inport 0 enabled
[   59.993334] coresight-etm3x e3c7c000.ptm: ETM tracing enabled

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 22394bc58543639e5135f19eee2b03d14e4a9b66)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: remove the unnecessary replicator property
Kaixu Xia [Mon, 26 Jan 2015 16:22:18 +0000 (09:22 -0700)]
coresight: remove the unnecessary replicator property

Now we use the device name to identify replicator instead
of a unique number, so just remove it.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 603101708c9c9ad2bc5a183d6d10b115738098c7)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: fix the replicator subtype value
Kaixu Xia [Mon, 26 Jan 2015 16:22:17 +0000 (09:22 -0700)]
coresight: fix the replicator subtype value

According to the classification, the type of replicator
is link, so the subtype should also be link_subtype.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 410d841a599683408a77f42f110cd17298682520)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: fixing validity check on remote device
Kaixu Xia [Fri, 9 Jan 2015 23:57:22 +0000 (16:57 -0700)]
coresight: fixing validity check on remote device

A validity check should be made on the remote device, i.e rdev,
rather than the current device.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2ccffaf92e7b7cc9dfa6c3458fc9cb151621680a)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: fix comment in of_coresight.c
Kaixu Xia [Fri, 9 Jan 2015 23:57:21 +0000 (16:57 -0700)]
coresight: fix comment in of_coresight.c

Outports is a member of the struct pdata and should be
a better choice.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f7c55298f17f0bf9d257ea7f2f15cf920248db5b)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: Fixing wrong #ifdef/#endif placement
Mathieu Poirier [Fri, 9 Jan 2015 23:57:20 +0000 (16:57 -0700)]
coresight: Fixing wrong #ifdef/#endif placement

Fixing problem reported by:
        https://lkml.org/lkml/2015/1/6/86

The #ifdef/#endif is wrong and prevents the stub of function
of_get_coresight_platform_data() from being visible when
CONFIG_OF is not defined.

Moving CONFIG_OF condition out of CONFIG_CORESIGHT, making
them both independent.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit c61c4b5dd2c6b5dbf0f7e299db1e8411ef590f5c)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: fix typo in comment in of_coresight.c
Kaixu Xia [Fri, 9 Jan 2015 23:57:19 +0000 (16:57 -0700)]
coresight: fix typo in comment in of_coresight.c

Debugfs isn't used for coresight configuration, so the corresponding
comments should be changed.

Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit ff1e33b0c16ba422e3bf3fa8cc7e89b2c958e193)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight: remove the unused macro CORESIGHT_DEBUGFS_ENTRY
Xia Kaixu [Fri, 9 Jan 2015 23:57:18 +0000 (16:57 -0700)]
coresight: remove the unused macro CORESIGHT_DEBUGFS_ENTRY

Debugfs isn't used for coresight configuration, so the macro
CORESIGHT_DEBUGFS_ENTRY is unnecessary, just remove it.

Signed-off-by: Xia Kaixu <xiakaixu@huawei.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f379984f849d729bd2eb076b633200b1c040611e)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight-etm: Fix initial trace ID value
Mathieu Poirier [Fri, 9 Jan 2015 23:57:17 +0000 (16:57 -0700)]
coresight-etm: Fix initial trace ID value

The coresight TRM specify that a component's trace ID should
be other than 0.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit b2c09284bbfe36f9ba0e3e8bec8bb3c4789b3911)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight-tpiu: use module_amba_driver to simplify the code
Wei Yongjun [Fri, 9 Jan 2015 23:57:16 +0000 (16:57 -0700)]
coresight-tpiu: use module_amba_driver to simplify the code

module_amba_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3ff7ca051a43bf2dfd1eebdd6c771c4b7a276d8e)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight-tmc: use module_amba_driver to simplify the code
Wei Yongjun [Fri, 9 Jan 2015 23:57:15 +0000 (16:57 -0700)]
coresight-tmc: use module_amba_driver to simplify the code

module_amba_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d2e580c272d19afff768b56dd0f5d2095cb5a07c)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight-funnel: use module_amba_driver to simplify the code
Wei Yongjun [Fri, 9 Jan 2015 23:57:14 +0000 (16:57 -0700)]
coresight-funnel: use module_amba_driver to simplify the code

module_amba_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit a48f52e185f7f6da2c53f8dd4efda963c32b73f1)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight-etb: use module_amba_driver to simplify the code
Wei Yongjun [Fri, 9 Jan 2015 23:57:13 +0000 (16:57 -0700)]
coresight-etb: use module_amba_driver to simplify the code

module_amba_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 52d6bbb9b06cac67ec3c016bc9758a1815022b2b)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agocoresight-etm: unlock on error paths in mode_store()
Dan Carpenter [Fri, 9 Jan 2015 23:57:12 +0000 (16:57 -0700)]
coresight-etm: unlock on error paths in mode_store()

There are some missing unlocks on the error paths.

Fixes: a939fc5a71ad ('coresight-etm: add CoreSight ETM/PTM driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6ad1095990328e7e4b3a0e260825ad4b6406785a)
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
9 years agoMerge branch 'lsk/v3.10/topic/of' into linux-linaro-lsk
Mark Brown [Sat, 21 Feb 2015 03:16:39 +0000 (12:16 +0900)]
Merge branch 'lsk/v3.10/topic/of' into linux-linaro-lsk

9 years agoi2c: Mark instantiated device nodes with OF_POPULATE
Pantelis Antoniou [Thu, 15 Jan 2015 18:33:18 +0000 (20:33 +0200)]
i2c: Mark instantiated device nodes with OF_POPULATE

Mark (and unmark) device nodes with the POPULATE flag as appropriate.
This is required to avoid multi probing when using I2C and device
overlays containing a mux.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit 6d0a0d9ad09be16e3ca676b245643945b4bff47d)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/i2c/i2c-core.c

9 years agoi2c: Mark instantiated device nodes with OF_POPULATE
Pantelis Antoniou [Thu, 15 Jan 2015 16:33:55 +0000 (18:33 +0200)]
i2c: Mark instantiated device nodes with OF_POPULATE

Mark (and unmark) device nodes with the POPULATE flag as appropriate.
This is required to avoid multi probing when using I2C and device
overlays containing a mux.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit d5285c36e6d27c1a411a3131c034641a5fa452cb)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoi2c/of: Add OF_RECONFIG notifier handler
Pantelis Antoniou [Tue, 28 Oct 2014 20:36:03 +0000 (22:36 +0200)]
i2c/of: Add OF_RECONFIG notifier handler

CONFIG_OF_DYNAMIC enables runtime changes to the device tree which in
turn may trigger addition or removal of devices from Linux. Add an
OF_RECONFIG notifier handler to receive tree change events and to
creating or destroy i2c devices as required.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[grant.likely: clean up #ifdefs and drop unneeded error handling]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Reviewed-by: Wolfram Sang <wsa@the-dreams.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: linux-i2c@vger.kernel.org
(cherry picked from commit ea7513bbc04170f1cbf42953187a4d8b731c71c4)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoi2c/of: Factor out Devicetree registration code
Pantelis Antoniou [Tue, 28 Oct 2014 20:36:02 +0000 (22:36 +0200)]
i2c/of: Factor out Devicetree registration code

Dynamically inserting i2c client device nodes requires the use
of a single device registration method. Factor out the loop body of
of_i2c_register_devices() so that it can be called for individual
device_nodes instead of for all the children of a node.

Note: The diff of this commit looks far more complicated than it
actually is due the indentation being changed for a large block of code.
When viewed using the diff -w flag to ignore whitespace changes it can
be seen that the change is actually quite simple.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[grant.likely: Made new function static and removed changes to header]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Reviewed-by: Wolfram Sang <wsa@the-dreams.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: linux-i2c@vger.kernel.org
(cherry picked from commit a430a3455f2c48995e06b359a82a1109a419e9ef)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/i2c/i2c-core.c

9 years agoi2c: move OF helpers into the core
Wolfram Sang [Thu, 11 Jul 2013 11:56:15 +0000 (12:56 +0100)]
i2c: move OF helpers into the core

I2C of helpers used to live in of_i2c.c but experience (from SPI) shows
that it is much cleaner to have this in the core. This also removes a
circular dependency between the helpers and the core, and so we can
finally register child nodes in the core instead of doing this manually
in each driver. So, fix the drivers and documentation, too.

[Modified to keep a stub device registration API exposed to drivers in
order to avoid disruption]

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit 687b81d083c082bc1e853032e3a2a54f8c251d27)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/i2c/busses/i2c-designware-platdrv.c
drivers/i2c/busses/i2c-imx.c
drivers/i2c/busses/i2c-stu300.c
drivers/i2c/busses/i2c-wmt.c
drivers/of/Kconfig
drivers/of/Makefile
drivers/staging/imx-drm/imx-tve.c
sound/soc/fsl/imx-wm8962.c

9 years agoMerge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lsk
Mark Brown [Thu, 19 Feb 2015 10:17:10 +0000 (19:17 +0900)]
Merge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lsk

Conflicts:
drivers/of/Makefile

9 years agoof/overlay: Directly include idr.h
Mark Brown [Tue, 17 Feb 2015 02:35:02 +0000 (11:35 +0900)]
of/overlay: Directly include idr.h

The overlay code uses IDRs but does not explicitly include the header
providing the interface, instead relying on an implicit inclusion. Make
the dependency implict to avoid potential future build issues if the
implicit inclusion goes away.

Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/platform: Handle of_populate drivers in notifier
Pantelis Antoniou [Tue, 16 Dec 2014 17:45:26 +0000 (19:45 +0200)]
of/platform: Handle of_populate drivers in notifier

When using overlays with drivers calling of_populate the notifier
will try to create the device twice. Using the populated bit
before proceeding protects against this.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 15204ab1ebc5aba608cd19c83c37b98438b938b0)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/overlay: Do not generate duplicate nodes
Pantelis Antoniou [Tue, 16 Dec 2014 17:45:25 +0000 (19:45 +0200)]
of/overlay: Do not generate duplicate nodes

During the course of the rewrites a bug sneaked in when dealing
with children nodes of overlays, which ends up duplicating
sub nodes.

Simply remove the duplicate traversal of child nodes to fix.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 3e7f7626fd49a9ffba8520a1a073f62929acad63)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/overlay: Introduce DT overlay support
Pantelis Antoniou [Tue, 28 Oct 2014 20:35:58 +0000 (22:35 +0200)]
of/overlay: Introduce DT overlay support

Overlays are a method to dynamically modify part of the kernel's
device tree with dynamically loaded data. Add the core functionality to
parse, apply and remove an overlay changeset. The core functionality
takes care of managing the overlay data format and performing the add
and remove. Drivers are expected to use the overlay functionality to
support custom expansion busses commonly found on consumer development
boards like the BeagleBone or Raspberry Pi.

The overlay code uses CONFIG_OF_DYNAMIC changesets to perform the low
level work of modifying the devicetree.

Documentation about internal and APIs is provided in
Documentation/devicetree/overlay-notes.txt

v2:
- Switch from __of_node_alloc() to __of_node_dup()
- Documentation fixups
- Remove 2-pass processing of properties
- Remove separate ov_lock; just use the DT mutex.
v1:
- Drop delete capability using '-' prefix. The '-' prefixed names
are valid properties and nodes and there is no need for it just yet.
- Do not update special properties - name & phandle ones.
- Change order of node attachment, so that the special property update
works.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 7518b5890d8ac366faa2326ce2356ef6392ce63d)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/Makefile

9 years agoof: Refactor __of_node_alloc() into __of_node_dup()
Grant Likely [Mon, 17 Nov 2014 22:31:32 +0000 (22:31 +0000)]
of: Refactor __of_node_alloc() into __of_node_dup()

Add a node argument to __of_node_alloc() and rename it to
__of_node_dup() so that it can also be used to duplicate a node with
its properties. This is important for the overlay code so that it can
create new nodes without using separate changeset items for every single
property.

At the same time rework the overlay code to use the new function and
drop the extra changeset items.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit e51795815ef1a7adc018cbaf05aac46e3d24eda8)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/unittest.c

9 years agoof: Use vargs in __of_node_alloc
Grant Likely [Fri, 14 Nov 2014 15:33:07 +0000 (15:33 +0000)]
of: Use vargs in __of_node_alloc

The overlay code needs to construct a new full_name from the parent name
and the node name, but the current method has to allocate and then free
an temporary string which is wasteful. Fix this problem by using vargs
to pass in a format and arguments into __of_node_alloc().

At the same time remove the allocflags argument to __of_node_alloc().
The only users all use GFP_KERNEL, so there is no need to provide it as
an option. If there is ever a need later it can be added back.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit ef8bbd73a76197cf8362a2b43aaadc5717bd0746)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/unittest.c

9 years agoof/reconfig: Add OF_DYNAMIC notifier for platform_bus_type
Pantelis Antoniou [Tue, 28 Oct 2014 20:36:01 +0000 (22:36 +0200)]
of/reconfig: Add OF_DYNAMIC notifier for platform_bus_type

Add OF notifier handler needed for creating/destroying platform devices
according to dynamic runtime changes in the DT live tree.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 801d728c10db4b28e01590b46bf1f0df930760cc)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/platform: Fix of_platform_device_destroy iteration of devices
Grant Likely [Tue, 24 Jun 2014 15:13:47 +0000 (16:13 +0100)]
of/platform: Fix of_platform_device_destroy iteration of devices

of_platform_destroy does not work properly, since the tree
population test was iterating on all devices having as its parent
the given platform device.

The check was intended to check whether any other platform or amba
devices created by of_platform_populate were still populated, but
instead checked for every kind of device. This is wrong, since platform
devices typically create a subsystem regular device and set themselves
as parents.

Instead, go ahead and call the unregister functions for any devices
created with of_platform_populate. The driver core will take care of
unbinding drivers, and drivers are responsible for getting rid of any
child devices that weren't created by of_platform_populate.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
(cherry picked from commit 75f353b61342b5847c7f6d8499fd6301dce09845)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
include/linux/of_platform.h

9 years agoof: Keep track of populated platform devices
Pawel Moll [Thu, 15 May 2014 15:55:24 +0000 (16:55 +0100)]
of: Keep track of populated platform devices

In "Device Tree powered" systems, platform devices are usually massively
populated with of_platform_populate() call, executed at some level of
initcalls, either by generic architecture or by platform-specific code.

There are situations though where certain devices must be created (and
bound with drivers) before all the others. This presents a challenge,
as devices created explicitly would be created again by
of_platform_populate().

This patch tries to solve that issue in a generic way, adding a
"populated" flag for a DT node description. Subsequent
of_platform_populate() will skip such nodes (and its children) in
a similar way to the non-available ones.

This patch also adds of_platform_depopulate() as an operation
complementary to the _populate() one. It removes a platform or an amba
device populated from the Device Tree, together with its all children
(leaving, however, devices without associated of_node untouched)
clearing the "populated" flag on the way.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit c6e126de43e7d4abfd6cf796b40589db3a046167)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/platform.c
include/linux/of_platform.h

9 years agoMerge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lsk
Mark Brown [Mon, 16 Feb 2015 07:57:48 +0000 (16:57 +0900)]
Merge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lsk

Conflicts:
arch/powerpc/kernel/prom.c
drivers/of/Kconfig
drivers/of/Makefile
drivers/of/selftest.c
include/linux/of.h

9 years agoof/reconfig: Always use the same structure for notifiers
Grant Likely [Mon, 24 Nov 2014 17:58:01 +0000 (17:58 +0000)]
of/reconfig: Always use the same structure for notifiers

The OF_RECONFIG notifier callback uses a different structure depending
on whether it is a node change or a property change. This is silly, and
not very safe. Rework the code to use the same data structure regardless
of the type of notifier.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: <linuxppc-dev@lists.ozlabs.org>
(cherry picked from commit f5242e5a883bf1c1aba6bfd87b85e7dda0e62191)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
arch/powerpc/platforms/pseries/hotplug-memory.c
include/linux/of.h

9 years agoof/reconfig: Add debug output for OF_RECONFIG notifiers
Grant Likely [Fri, 14 Nov 2014 14:34:55 +0000 (14:34 +0000)]
of/reconfig: Add debug output for OF_RECONFIG notifiers

Add some additional debug output to cover OF_RECONFIG notifier activity.
At the same time, refactor the changeset debug output to use the same
strings as the notifier debug output.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 00aa37206e1a54dae61a0dba96bf2ee0938b99d7)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/reconfig: Add of_reconfig_get_state_change() of notifier helper.
Pantelis Antoniou [Tue, 28 Oct 2014 20:33:53 +0000 (22:33 +0200)]
of/reconfig: Add of_reconfig_get_state_change() of notifier helper.

Introduce of_reconfig_get_state_change() which allows an of notifier
to query about device state changes.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit b53a2340d0d30468b7315992ba77fe188c3bc5c8)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/resolver: Switch to new local fixups format.
Pantelis Antoniou [Tue, 28 Oct 2014 20:33:49 +0000 (22:33 +0200)]
of/resolver: Switch to new local fixups format.

The original resolver format is way too cryptic, switch
to using a tree based format that gets rid of repetitions,
is more compact and readable.

At the same time, update the selftests to using the new local fixups
format.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[grant.likely: Squashed in testcase changes and merged similar functions]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit da56d04c806a3e9986c66a061d7363ca3157c37b)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/unittest-data/testcases.dts

9 years agoof: Introduce Device Tree resolve support.
Pantelis Antoniou [Fri, 4 Jul 2014 16:59:20 +0000 (19:59 +0300)]
of: Introduce Device Tree resolve support.

Introduce support for dynamic device tree resolution.
Using it, it is possible to prepare a device tree that's
been loaded on runtime to be modified and inserted at the kernel
live tree.

Export of of_resolve and bug fix of double free by
Guenter Roeck <groeck@juniper.net>

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[grant.likely: Don't need to select CONFIG_OF_DYNAMIC and CONFIG_OF_DEVICE]
[grant.likely: Don't need to depend on OF or !SPARC]
[grant.likely: Factor out duplicate code blocks into single function]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 7941b27b16e3282f6ec8817e36492f1deec753a7)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/Kconfig
drivers/of/Makefile

9 years agoof: Transactional DT support.
Pantelis Antoniou [Fri, 4 Jul 2014 16:58:49 +0000 (19:58 +0300)]
of: Transactional DT support.

Introducing DT transactional support.

A DT transaction is a method which allows one to apply changes
in the live tree, in such a way that either the full set of changes
take effect, or the state of the tree can be rolled-back to the
state it was before it was attempted. An applied transaction
can be rolled-back at any time.

Documentation is in
Documentation/devicetree/changesets.txt

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[glikely: Removed device notifiers and reworked to be more consistent]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 201c910bd6898d81d4ac6685d0f421b7e10f3c5d)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/selftest.c
drivers/of/testcase-data/testcases.dtsi
include/linux/of.h

9 years agoof: Reorder device tree changes and notifiers
Grant Likely [Wed, 16 Jul 2014 18:48:23 +0000 (12:48 -0600)]
of: Reorder device tree changes and notifiers

Currently, devicetree reconfig notifiers get emitted before the change
is applied to the tree, but that behaviour is problematic if the
receiver wants the determine the new state of the tree. The current
users don't care, but the changeset code to follow will be making
multiple changes at once. Reorder notifiers to get emitted after the
change has been applied to the tree so that callbacks see the new tree
state.

At the same time, fixup the existing callbacks to expect the new order.
There are a few callbacks that compare the old and new values of a
changed property. Put both property pointers into the of_prop_reconfig
structure.

The current notifiers also allow the notifier callback to fail and
cancel the change to the tree, but that feature isn't actually used.
It really isn't valid to ignore a tree modification provided by firmware
anyway, so remove the ability to cancel a change to the tree.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
Cc: Nathan Fontenot <nfont@austin.ibm.com>
(cherry picked from commit 259092a35c7e11f1d4616b0f5b3ba7b851fe4fa6)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: Move dynamic node fixups out of powerpc and into common code
Grant Likely [Wed, 16 Jul 2014 05:25:43 +0000 (23:25 -0600)]
of: Move dynamic node fixups out of powerpc and into common code

PowerPC does an odd thing with dynamic nodes. It uses a notifier to
catch new node additions and set some of the values like name and type.
This makes no sense since that same code can be put directly into
of_attach_node(). Besides, all dynamic node users need this, not just
powerpc. Fix this problem by moving the logic out of arch/powerpc and
into drivers/of/dynamic.c.

It is also important to remove this notifier because we want to move the
firing of notifiers from before the tree is modified to after so that
the receiver gets a consistent view of the tree, but that is
incompatible with notifiers that modify the node.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
Cc: Nathan Fontenot <nfont@austin.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
(cherry picked from commit a25095d451ece23b1fef34474f3230100db7aa05)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
arch/powerpc/kernel/prom.c

9 years agoof: Make sure attached nodes don't carry along extra children
Grant Likely [Wed, 16 Jul 2014 14:48:46 +0000 (08:48 -0600)]
of: Make sure attached nodes don't carry along extra children

The child pointer does not get cleared when attaching new nodes which
could cause the tree to be inconsistent. Clear the child pointer in
__of_attach_node() to be absolutely sure that the structure remains in a
consistent layout.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 6162dbe49a451f96431a23b4821f05e3bd925bc1)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: Make devicetree sysfs update functions consistent.
Grant Likely [Wed, 23 Jul 2014 23:05:06 +0000 (17:05 -0600)]
of: Make devicetree sysfs update functions consistent.

All of the DT modification functions are split into two parts, the first
part manipulates the DT data structure, and the second part updates
sysfs, but the code isn't very consistent about how the second half is
called. They don't all enforce the same rules about when it is valid to
update sysfs, and there isn't any clarity on locking.

The transactional DT modification feature that is coming also needs
access to these functions so that it can perform all the structure
changes together, and then all the sysfs updates as a second stage
instead of doing each one at a time.

Fix up the second have by creating a separate __of_*_sysfs() function
for each of the helpers. The new functions have consistent naming (ie.
of_node_add() becomes __of_attach_node_sysfs()) and all of them now
defer if of_init hasn't been called yet.

Callers of the new functions must hold the of_mutex to ensure there are
no race conditions with of_init(). The mutex ensures that there will
only ever be one writer to the tree at any given time. There can still
be any number of readers and the raw_spin_lock is still used to make
sure access to the data structure is still consistent.

Finally, put the function prototypes into of_private.h so they are
accessible to the transaction code.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[grant.likely: Changed suffix from _post to _sysfs to match existing code]
[grant.likely: Reorganized to eliminate trivial wrappers]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 8a2b22a2595bf89d4396530edf8388159fad9d83)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/base.c

9 years agoof: rename of_aliases_mutex to just of_mutex
Pantelis Antoniou [Fri, 4 Jul 2014 16:58:03 +0000 (19:58 +0300)]
of: rename of_aliases_mutex to just of_mutex

We're overloading usage of of_aliases_mutex for sysfs changes,
so rename to something that is more generic.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit c05aba2bd5f9dd3f363611ff844513de1341ac60)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: Create unlocked versions of node and property add/remove functions
Pantelis Antoniou [Fri, 4 Jul 2014 16:58:46 +0000 (19:58 +0300)]
of: Create unlocked versions of node and property add/remove functions

The DT overlay code will need to manipulate nodes and properties while
already holding the devicetree lock, or on nodes that are not yet
attached to the tree, but the current helper functions don't allow that.
Extract the core behaviour from the accessors and create the following
unlocked variants.

The unlocked variants require either the lock to already be held or for
the nodes to be detached from the tree. Changes to live nodes will not
get updated in sysfs, so the caller must arrange for housekeeping to
take place after dropping the lock.

The new functions are: __of_add_property(), __of_remove_property(),
__of_update_property(), __of_attach_node() and __of_detach_node().

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[Remove unnecessary diff hunks and rewrite commit text]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit d8c50088417ebf61ad8b132caad20d10f7736034)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/base.c

9 years agoof: add __of_add_property() without lock operations
Xiubo Li [Wed, 22 Jan 2014 05:57:39 +0000 (13:57 +0800)]
of: add __of_add_property() without lock operations

There two places will use the same code for adding one new property to
the DT node. Adding __of_add_property() and prepare for fixing
of_update_property()'s bug.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 62664f67775fad840cf6f68d6b5f428817bef6c5)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/base.c

9 years agoOF: Utility helper functions for dynamic nodes
Pantelis Antoniou [Fri, 4 Jul 2014 16:58:47 +0000 (19:58 +0300)]
OF: Utility helper functions for dynamic nodes

Introduce helper functions for working with the live DT tree,
all of them related to dynamically adding/removing nodes and
properties.

__of_prop_dup() copies a property dynamically
__of_node_alloc() creates an empty node

Bug fix about prop->len == 0 by Ionut Nicu <ioan.nicu.ext@nsn.com>

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[glikely: Added unittest for of_copy_property and dropped fine-grained allocations]
[glikely: removed name, type and phandle arguments from __of_node_alloc]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 698433963b98d6de7b102c242805c99fda4fa1fb)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/selftest.c

9 years agoof: Move CONFIG_OF_DYNAMIC code into a separate file
Grant Likely [Thu, 26 Jun 2014 14:40:48 +0000 (15:40 +0100)]
of: Move CONFIG_OF_DYNAMIC code into a separate file

Split the dynamic device tree code into a separate file to make it
really clear what features CONFIF_OF_DYNAMIC add to the kernel. Without
CONFIG_OF_DYNAMIC only properties can be changed, and notifiers do not
get sent. Enabling it turns on reference counting, notifiers and the
ability to add and remove nodes.

v2: Moved of_node_release() into dynamic.c

Signed-off-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: Rob Herring <robh+dt@kernel.org>
(cherry picked from commit 6afc0dc381573559251de9a8259404f49e6aed14)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/Makefile
drivers/of/base.c

9 years agoof: Introduce device tree node flag helpers.
Pantelis Antoniou [Fri, 8 Nov 2013 15:03:56 +0000 (17:03 +0200)]
of: Introduce device tree node flag helpers.

Helper functions for working with device node flags.

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 588453c69dace39351129a038dd2796608f74bb3)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: device_node kobject lifecycle fixes
Pantelis Antoniou [Fri, 13 Dec 2013 18:08:59 +0000 (20:08 +0200)]
of: device_node kobject lifecycle fixes

After the move to having device nodes be proper kobjects the lifecycle
of the node needs to be controlled better.

At first convert of_add_node() in the unflattened functions to
of_init_node() which initializes the kobject so that of_node_get/put
work correctly even before of_init is called.

Afterwards introduce of_node_is_initialized & of_node_is_attached that
query the underlying kobject about the state (attached means kobj
is visible in sysfs)

Using that make sure the lifecycle of the tree is correct at all
times.

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
[grant.likely: moved of_node_init() calls, fixed up locking, and
               dropped __of_populate() hunks]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 0829f6d1f69e4f2fae4062987ae6531a9af1a2e3)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: remove /proc/device-tree
Grant Likely [Tue, 6 Nov 2012 21:03:27 +0000 (21:03 +0000)]
of: remove /proc/device-tree

The same data is now available in sysfs, so we can remove the code
that exports it in /proc and replace it with a symlink to the sysfs
version.

Tested on versatile qemu model and mpc5200 eval board. More testing
would be appreciated.

v5: Fixed up conflicts with mainline changes

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
(cherry picked from commit 8357041a69b368991d1b04d9f1d297f8d71e1314)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
drivers/of/base.c
fs/proc/proc_devtree.c
include/linux/of.h

9 years agoof: add functions to count number of elements in a property
Heiko Stuebner [Wed, 12 Feb 2014 00:00:34 +0000 (01:00 +0100)]
of: add functions to count number of elements in a property

The need to know the number of array elements in a property is
a common pattern. To prevent duplication of open-coded implementations
add a helper static function that also centralises strict sanity
checking and DTB format details, as well as a set of wrapper functions
for u8, u16, u32 and u64.

Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Heiko Stuebner <heiko.stuebner@bqreaders.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit ad54a0cfbeb4bd4033d09017557ccbc423f9d5ff)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agofs/proc/proc_devtree.c: remove empty /proc/device-tree when no openfirmware exists.
Dave Jones [Thu, 23 Jan 2014 23:55:43 +0000 (15:55 -0800)]
fs/proc/proc_devtree.c: remove empty /proc/device-tree when no openfirmware exists.

Distribution kernels might want to build in support for /proc/device-tree
for kernels that might end up running on hardware that doesn't support
openfirmware.  This results in an empty /proc/device-tree existing.
Remove it if the OFW root node doesn't exist.

This situation actually confuses grub2, resulting in install failures.
grub2 sees the /proc/device-tree and picks the wrong install target cf.
http://bzr.savannah.gnu.org/lh/grub/trunk/grub/annotate/4300/util/grub-install.in#L311
grub should be more robust, but still, leaving an empty proc dir seems
pointless.

Addresses https://bugzilla.redhat.com/show_bug.cgi?id=818378.

Signed-off-by: Dave Jones <davej@redhat.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Josh Boyer <jwboyer@fedoraproject.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit c1d867a54d426b45da017fbe8e585f8a3064ce8d)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: Make device nodes kobjects so they show up in sysfs
Grant Likely [Thu, 20 Feb 2014 18:02:11 +0000 (18:02 +0000)]
of: Make device nodes kobjects so they show up in sysfs

Device tree nodes are already treated as objects, and we already want to
expose them to userspace which is done using the /proc filesystem today.
Right now the kernel has to do a lot of work to keep the /proc view in
sync with the in-kernel representation. If device_nodes are switched to
be kobjects then the device tree code can be a whole lot simpler. It
also turns out that switching to using /sysfs from /proc results in
smaller code and data size, and the userspace ABI won't change if
/proc/device-tree symlinks to /sys/firmware/devicetree/base.

v7: Add missing sysfs_bin_attr_init()
v6: Add __of_add_property() early init fixes from Pantelis
v5: Rename firmware/ofw to firmware/devicetree
    Fix updating property values in sysfs
v4: Fixed build error on Powerpc
    Fixed handling of dynamic nodes on powerpc
v3: Fixed handling of duplicate attribute and child node names
v2: switch to using sysfs bin_attributes which solve the problem of
    reporting incorrect property size.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
(cherry picked from commit 75b57ecf9d1d1e17d099ab13b8f48e6e038676be)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
arch/powerpc/platforms/pseries/dlpar.c

9 years agoMerge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lsk
Mark Brown [Mon, 16 Feb 2015 03:51:52 +0000 (12:51 +0900)]
Merge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lsk

Conflicts:
drivers/of/base.c
drivers/of/fdt.c

9 years agoof/irq: Pass trigger type in IRQ resource flags
Tomasz Figa [Sat, 28 Sep 2013 17:52:51 +0000 (19:52 +0200)]
of/irq: Pass trigger type in IRQ resource flags

Some drivers might rely on availability of trigger flags in IRQ
resource, for example to configure the hardware for particular interrupt
type. However current code creating IRQ resources from data in device
tree does not configure trigger flags in resulting resources.

This patch tries to solve the problem, based on the fact that
irq_of_parse_and_map() configures the trigger based on DT interrupt
specifier and IRQD_TRIGGER_* flags are consistent with IORESOURCE_IRQ_*,
and we can get correct trigger flags by calling irqd_get_trigger_type()
after mapping the interrupt.

Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
[grant.likely: Merged the two assignments to r->flags]
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 4a43d686fe336cc0e955c4400ba4d3fcff788786)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: Fix dereferencing node name in debug output to be safe
Grant Likely [Thu, 19 Sep 2013 16:01:52 +0000 (11:01 -0500)]
of: Fix dereferencing node name in debug output to be safe

Several locations in the of_address and of_irq code dereference the
full_name parameter from a device_node pointer without checking if the
pointer is valid.  This patch switches to use of_node_full_name() which
always checks the pointer.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 8804827b305dbc1c6e24f2b36f1df4a9856b80e8)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/fdt: Remove duplicate memory clearing on FDT unflattening
Grant Likely [Wed, 28 Aug 2013 20:24:17 +0000 (21:24 +0100)]
of/fdt: Remove duplicate memory clearing on FDT unflattening

Patch 9e4012752, "of: fdt: fix memory initialization for expanded DT"
fixed incomplete clearing of memory when unflattening the device tree.
However the code was already clearing some of the memory, it just wasn't
doing so for all allocations. Now that the memory is cleared right at
the point of allocation, the memset after unflatten_dt_alloc() is
redundant. Remove it.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
Acked-by: Wladislav Wiebe <wladislav.kw@gmail.com>
(cherry picked from commit 92d31610aac907c046f0e9c0f888c30415f20936)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: call __of_parse_phandle_with_args from of_parse_phandle
Stephen Warren [Wed, 14 Aug 2013 21:27:11 +0000 (15:27 -0600)]
of: call __of_parse_phandle_with_args from of_parse_phandle

The simplest case of __of_parse_phandle_with_args() now implements the
semantics of of_parse_phandle(). Rewrite of_parse_phandle() to call
__of_parse_phandle_with_args() rather than open-coding the simple case.

Optimize __of_parse_phandle_with_args() so that it doesn't call
of_find_node_by_phandle() except when it's strictly needed. This avoids
introducing too much overhead when replacing of_parse_phandle().

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 91d9942c28ee691dab47185f38b052f84db4e0f7)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: introduce of_parse_phandle_with_fixed_args
Stephen Warren [Wed, 14 Aug 2013 21:27:10 +0000 (15:27 -0600)]
of: introduce of_parse_phandle_with_fixed_args

This is identical to of_parse_phandle_with_args(), except that the
number of argument cells is fixed, rather than being parsed out of the
node referenced by each phandle.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 035fd9482274bf43858b00e0ff95179af66df8e8)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: move of_parse_phandle()
Stephen Warren [Wed, 14 Aug 2013 21:27:09 +0000 (15:27 -0600)]
of: move of_parse_phandle()

Move of_parse_phandle() after __of_parse_phandle_with_args(), since a
future patch will call __of_parse_phandle_with_args() from
of_parse_phandle(). Moving the function avoids adding a prototype. Doing
the move separately highlights the code changes separately.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 5fba49e3a8c22a7bb71c3526ec32b373b3ef32b8)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: move documentation of of_parse_phandle_with_args
Stephen Warren [Wed, 14 Aug 2013 21:27:08 +0000 (15:27 -0600)]
of: move documentation of of_parse_phandle_with_args

Commit bd69f73 "of: Create function for counting number of phandles in
a property" renamed of_parse_phandle_with_args(), and created a wrapper
function that implemented the original name. However, the documentation
of the original function was not moved, leaving it apparently documenting
the newly renamed function.

Move the documentation so that it is adjacent to the function it
documents.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit eded9dd40b1e30215ab7379dc433f3d3c662ec88)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: fdt: fix memory initialization for expanded DT
Wladislav Wiebe [Mon, 12 Aug 2013 11:06:53 +0000 (13:06 +0200)]
of: fdt: fix memory initialization for expanded DT

Already existing property flags are filled wrong for properties created from
initial FDT. This could cause problems if this DYNAMIC device-tree functions
are used later, i.e. properties are attached/detached/replaced. Simply dumping
flags from the running system show, that some initial static (not allocated via
kzmalloc()) nodes are marked as dynamic.

I putted some debug extensions to property_proc_show(..) :
..
+       if (OF_IS_DYNAMIC(pp))
+               pr_err("DEBUG: xxx : OF_IS_DYNAMIC\n");
+       if (OF_IS_DETACHED(pp))
+               pr_err("DEBUG: xxx : OF_IS_DETACHED\n");

when you operate on the nodes (e.g.: ~$ cat /proc/device-tree/*some_node*) you
will see that those flags are filled wrong, basically in most cases it will dump
a DYNAMIC or DETACHED status, which is in not true.
(BTW. this OF_IS_DETACHED is a own define for debug purposes which which just
make a test_bit(OF_DETACHED, &x->_flags)

If nodes are dynamic kernel is allowed to kfree() them. But it will crash
attempting to do so on the nodes from FDT -- they are not allocated via
kzmalloc().

Signed-off-by: Wladislav Wiebe <wladislav.kw@gmail.com>
Acked-by: Alexander Sverdlin <alexander.sverdlin@nsn.com>
Cc: stable@vger.kernel.org
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
(cherry picked from commit 9e40127526e857fa3f29d51e83277204fbdfc6ba)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoOF: Add helper for matching against linux,stdout-path
Sascha Hauer [Mon, 5 Aug 2013 12:40:44 +0000 (14:40 +0200)]
OF: Add helper for matching against linux,stdout-path

devicetrees may have a linux,stdout-path property in the chosen
node describing the console device. This adds a helper function
to match a device against this property so a driver can call
add_preferred_console for a matching device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 5c19e95216b93b0d29c6a4887e69a980edc6fc81)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof: Specify initrd location using 64-bit
Santosh Shilimkar [Mon, 1 Jul 2013 18:20:35 +0000 (14:20 -0400)]
of: Specify initrd location using 64-bit

On some PAE architectures, the entire range of physical memory could reside
outside the 32-bit limit.  These systems need the ability to specify the
initrd location using 64-bit numbers.

This patch globally modifies the early_init_dt_setup_initrd_arch() function to
use 64-bit numbers instead of the current unsigned long.

There has been quite a bit of debate about whether to use u64 or phys_addr_t.
It was concluded to stick to u64 to be consistent with rest of the device
tree code. As summarized by Geert, "The address to load the initrd is decided
by the bootloader/user and set at that point later in time. The dtb should not
be tied to the kernel you are booting"

More details on the discussion can be found here:
https://lkml.org/lkml/2013/6/20/690
https://lkml.org/lkml/2012/9/13/544

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit 374d5c9964c10373ba39bbe934f4262eb87d7114)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/irq: init struct resource to 0 in of_irq_to_resource()
Sebastian Andrzej Siewior [Thu, 18 Jul 2013 10:24:10 +0000 (12:24 +0200)]
of/irq: init struct resource to 0 in of_irq_to_resource()

It almost does not matter because most users use only the ->start member
of the struct. However if this struct is passed to a platform device
which is then added via platform_device_add() then the ->parent member is
also used.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit cf9e2368655d86cd800e4d9fe65a407b39d29373)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoof/irq: Avoid calling list_first_entry() for empty list
Axel Lin [Sun, 23 Jun 2013 07:50:07 +0000 (15:50 +0800)]
of/irq: Avoid calling list_first_entry() for empty list

list_first_entry() expects the list is not empty, we need to check if list is
empty before calling list_first_entry(). Thus use list_first_entry_or_null()
instead of list_first_entry().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit c0cdfaa0a5e7a346ac2f661f63f543cdc5f7cbbe)
Signed-off-by: Mark Brown <broonie@kernel.org>
9 years agoMerge tag 'v3.10.68' into linux-linaro-lsk
Mark Brown [Mon, 9 Feb 2015 06:11:45 +0000 (14:11 +0800)]
Merge tag 'v3.10.68' into linux-linaro-lsk

This is the 3.10.68 stable release

9 years agoLinux 3.10.68
Greg Kroah-Hartman [Fri, 6 Feb 2015 14:52:56 +0000 (06:52 -0800)]
Linux 3.10.68

9 years agotarget: Drop arbitrary maximum I/O size limit
Nicholas Bellinger [Fri, 30 Jan 2015 22:17:31 +0000 (22:17 +0000)]
target: Drop arbitrary maximum I/O size limit

commit 046ba64285a4389ae5e9a7dfa253c6bff3d7c341 upstream.

This patch drops the arbitrary maximum I/O size limit in sbc_parse_cdb(),
which currently for fabric_max_sectors is hardcoded to 8192 (4 MB for 512
byte sector devices), and for hw_max_sectors is a backend driver dependent
value.

This limit is problematic because Linux initiators have only recently
started to honor block limits MAXIMUM TRANSFER LENGTH, and other non-Linux
based initiators (eg: MSFT Fibre Channel) can also generate I/Os larger
than 4 MB in size.

Currently when this happens, the following message will appear on the
target resulting in I/Os being returned with non recoverable status:

  SCSI OP 28h with too big sectors 16384 exceeds fabric_max_sectors: 8192

Instead, drop both [fabric,hw]_max_sector checks in sbc_parse_cdb(),
and convert the existing hw_max_sectors into a purely informational
attribute used to represent the granuality that backend driver and/or
subsystem code is splitting I/Os upon.

Also, update FILEIO with an explicit FD_MAX_BYTES check in fd_execute_rw()
to deal with the one special iovec limitiation case.

v2 changes:
  - Drop hw_max_sectors check in sbc_parse_cdb()

Reported-by: Lance Gropper <lance.gropper@qosserver.com>
Reported-by: Stefan Priebe <s.priebe@profihost.ag>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoiser-target: Fix implicit termination of connections
Sagi Grimberg [Fri, 30 Jan 2015 22:17:30 +0000 (22:17 +0000)]
iser-target: Fix implicit termination of connections

commit b02efbfc9a051b41e71fe8f94ddf967260e024a6 upstream.

In situations such as bond failover, The new session establishment
implicitly invokes the termination of the old connection.

So, we don't want to wait for the old connection wait_conn to completely
terminate before we accept the new connection and post a login response.

The solution is to deffer the comp_wait completion and the conn_put to
a work so wait_conn will effectively be non-blocking (flush errors are
assumed to come very fast).

We allocate isert_release_wq with WQ_UNBOUND and WQ_UNBOUND_MAX_ACTIVE
to spread the concurrency of release works.

Reported-by: Slava Shwartsman <valyushash@gmail.com>
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoiser-target: Handle ADDR_CHANGE event for listener cm_id
Sagi Grimberg [Fri, 30 Jan 2015 22:17:29 +0000 (22:17 +0000)]
iser-target: Handle ADDR_CHANGE event for listener cm_id

commit ca6c1d82d12d8013fb75ce015900d62b9754623c upstream.

The np listener cm_id will also get ADDR_CHANGE event
upcall (in case it is bound to a specific IP). Handle
it correctly by creating a new cm_id and implicitly
destroy the old one.

Since this is the second event a listener np cm_id may
encounter, we move the np cm_id event handling to a
routine.

Squashed:

iser-target: Move cma_id setup to a function

Reported-by: Slava Shwartsman <valyushash@gmail.com>
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoiser-target: Fix connected_handler + teardown flow race
Sagi Grimberg [Fri, 30 Jan 2015 22:17:28 +0000 (22:17 +0000)]
iser-target: Fix connected_handler + teardown flow race

commit 19e2090fb246ca21b3e569ead51a6a7a1748eadd upstream.

Take isert_conn pointer from cm_id->qp->qp_context. This
will allow us to know that the cm_id context is always
the network portal. This will make the cm_id event check
(connection or network portal) more reliable.

In order to avoid a NULL dereference in cma_id->qp->qp_context
we destroy the qp after we destroy the cm_id (and make the
dereference safe). session stablishment/teardown sequences
can happen in parallel, we should take into account that
connected_handler might race with connection teardown flow.

Also, protect isert_conn->conn_device->active_qps decrement
within the error patch during QP creation failure and the
normal teardown path in isert_connect_release().

Squashed:

iser-target: Decrement completion context active_qps in error flow

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoiser-target: Parallelize CM connection establishment
Sagi Grimberg [Fri, 30 Jan 2015 22:17:27 +0000 (22:17 +0000)]
iser-target: Parallelize CM connection establishment

commit 2371e5da8cfe91443339b54444dec6254fdd6dfc upstream.

There is no point in accepting a new CM request only
when we are completely done with the last iscsi login.
Instead we accept immediately, this will also cause the
CM connection to reach connected state and the initiator
is allowed to send the first login. We mark that we got
the initial login and let iscsi layer pick it up when it
gets there.

This reduces the parallel login sequence by a factor of
more then 4 (and more for multi-login) and also prevents
the initiator (who does all logins in parallel) from
giving up on login timeout expiration.

In order to support multiple login requests sequence (CHAP)
we call isert_rx_login_req from isert_rx_completion insead
of letting isert_get_login_rx call it.

Squashed:

iser-target: Use kref_get_unless_zero in connected_handler
iser-target: Acquire conn_mutex when changing connection state
iser-target: Reject connect request in failure path

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoiser-target: Fix flush + disconnect completion handling
Sagi Grimberg [Fri, 30 Jan 2015 22:17:26 +0000 (22:17 +0000)]
iser-target: Fix flush + disconnect completion handling

commit 128e9cc84566a84146baea2335b3824288eed817 upstream.

ISER_CONN_UP state is not sufficient to know if
we should wait for completion of flush errors and
disconnected_handler event.

Instead, split it to 2 states:
- ISER_CONN_UP: Got to CM connected phase, This state
indicates that we need to wait for a CM disconnect
event before going to teardown.

- ISER_CONN_FULL_FEATURE: Got to full feature phase
after we posted login response, This state indicates
that we posted recv buffers and we need to wait for
flush completions before going to teardown.

Also avoid deffering disconnected handler to a work,
and handle it within disconnected handler.
More work here is needed to handle DEVICE_REMOVAL event
correctly (cleanup all resources).

Squashed:

iser-target: Don't deffer disconnected handler to a work

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoiscsi,iser-target: Initiate termination only once
Sagi Grimberg [Fri, 30 Jan 2015 22:17:25 +0000 (22:17 +0000)]
iscsi,iser-target: Initiate termination only once

commit 954f23722b5753305be490330cf2680b7a25f4a3 upstream.

Since commit 0fc4ea701fcf ("Target/iser: Don't put isert_conn inside
disconnected handler") we put the conn kref in isert_wait_conn, so we
need .wait_conn to be invoked also in the error path.

Introduce call to isert_conn_terminate (called under lock)
which transitions the connection state to TERMINATING and calls
rdma_disconnect. If the state is already teminating, just bail
out back (temination started).

Also, make sure to destroy the connection when getting a connect
error event if didn't get to connected (state UP). Same for the
handling of REJECTED and UNREACHABLE cma events.

Squashed:

iscsi-target: Add call to wait_conn in establishment error flow

Reported-by: Slava Shwartsman <valyushash@gmail.com>
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agovhost-scsi: Add missing virtio-scsi -> TCM attribute conversion
Nicholas Bellinger [Fri, 30 Jan 2015 22:17:24 +0000 (22:17 +0000)]
vhost-scsi: Add missing virtio-scsi -> TCM attribute conversion

commit 46243860806bdc2756f3ce8ac86b4d7c616bcd6c upstream.

While looking at hch's recent conversion to drop the MSG_*_TAG
definitions, I noticed a long standing bug in vhost-scsi where
the VIRTIO_SCSI_S_* attribute definitions where incorrectly
being passed directly into target_submit_cmd_map_sgls().

This patch adds the missing virtio-scsi to TCM/SAM task attribute
conversion.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agotcm_loop: Fix wrong I_T nexus association
Hannes Reinecke [Fri, 30 Jan 2015 22:17:23 +0000 (22:17 +0000)]
tcm_loop: Fix wrong I_T nexus association

commit 506787a2c7daed45f0a213674ca706cbc83a9089 upstream.

tcm_loop has the I_T nexus associated with the HBA. This causes
commands to become misdirected if the HBA has more than one
target portal group; any command is then being sent to the
first target portal group instead of the correct one.

The nexus needs to be associated with the target portal group
instead.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agovhost-scsi: Take configfs group dependency during VHOST_SCSI_SET_ENDPOINT
Nicholas Bellinger [Fri, 30 Jan 2015 22:17:22 +0000 (22:17 +0000)]
vhost-scsi: Take configfs group dependency during VHOST_SCSI_SET_ENDPOINT

commit ab8edab132829b26dd13db6caca3c242cce35dc1 upstream.

This patch addresses a bug where individual vhost-scsi configfs endpoint
groups can be removed from below while active exports to QEMU userspace
still exist, resulting in an OOPs.

It adds a configfs_depend_item() in vhost_scsi_set_endpoint() to obtain
an explicit dependency on se_tpg->tpg_group in order to prevent individual
vhost-scsi WWPN endpoints from being released via normal configfs methods
while an QEMU ioctl reference still exists.

Also, add matching configfs_undepend_item() in vhost_scsi_clear_endpoint()
to release the dependency, once QEMU's reference to the individual group
at /sys/kernel/config/target/vhost/$WWPN/$TPGT is released.

(Fix up vhost_scsi_clear_endpoint() error path - DanC)

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoib_isert: Add max_send_sge=2 minimum for control PDU responses
Or Gerlitz [Fri, 30 Jan 2015 22:17:21 +0000 (22:17 +0000)]
ib_isert: Add max_send_sge=2 minimum for control PDU responses

commit f57915cfa5b2b14c1cffa2e83c034f55e3f0e70d upstream.

This patch adds a max_send_sge=2 minimum in isert_conn_setup_qp()
to ensure outgoing control PDU responses with tx_desc->num_sge=2
are able to function correctly.

This addresses a bug with RDMA hardware using dev_attr.max_sge=3,
that in the original code with the ConnectX-2 work-around would
result in isert_conn->max_sge=1 being negotiated.

Originally reported by Chris with ocrdma driver.

Reported-by: Chris Moore <Chris.Moore@emulex.com>
Tested-by: Chris Moore <Chris.Moore@emulex.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoIB/isert: Adjust CQ size to HW limits
Chris Moore [Fri, 30 Jan 2015 22:17:20 +0000 (22:17 +0000)]
IB/isert: Adjust CQ size to HW limits

commit b1a5ad006b34ded9dc7ec64988deba1b3ecad367 upstream.

isert has an issue of trying to create a CQ with more CQEs than are
supported by the hardware, that currently results in failures during
isert_device creation during first session login.

This is the isert version of the patch that Minh Tran submitted for
iser, and is simple a workaround required to function with existing
ocrdma hardware.

Signed-off-by: Chris Moore <chris.moore@emulex.com>
Reviewied-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoworkqueue: fix subtle pool management issue which can stall whole worker_pool
Tejun Heo [Fri, 16 Jan 2015 19:21:16 +0000 (14:21 -0500)]
workqueue: fix subtle pool management issue which can stall whole worker_pool

commit 29187a9eeaf362d8422e62e17a22a6e115277a49 upstream.

A worker_pool's forward progress is guaranteed by the fact that the
last idle worker assumes the manager role to create more workers and
summon the rescuers if creating workers doesn't succeed in timely
manner before proceeding to execute work items.

This manager role is implemented in manage_workers(), which indicates
whether the worker may proceed to work item execution with its return
value.  This is necessary because multiple workers may contend for the
manager role, and, if there already is a manager, others should
proceed to work item execution.

Unfortunately, the function also indicates that the worker may proceed
to work item execution if need_to_create_worker() is false at the head
of the function.  need_to_create_worker() tests the following
conditions.

pending work items && !nr_running && !nr_idle

The first and third conditions are protected by pool->lock and thus
won't change while holding pool->lock; however, nr_running can change
asynchronously as other workers block and resume and while it's likely
to be zero, as someone woke this worker up in the first place, some
other workers could have become runnable inbetween making it non-zero.

If this happens, manage_worker() could return false even with zero
nr_idle making the worker, the last idle one, proceed to execute work
items.  If then all workers of the pool end up blocking on a resource
which can only be released by a work item which is pending on that
pool, the whole pool can deadlock as there's no one to create more
workers or summon the rescuers.

This patch fixes the problem by removing the early exit condition from
maybe_create_worker() and making manage_workers() return false iff
there's already another manager, which ensures that the last worker
doesn't start executing work items.

We can leave the early exit condition alone and just ignore the return
value but the only reason it was put there is because the
manage_workers() used to perform both creations and destructions of
workers and thus the function may be invoked while the pool is trying
to reduce the number of workers.  Now that manage_workers() is called
only when more workers are needed, the only case this early exit
condition is triggered is rare race conditions rendering it pointless.

Tested with simulated workload and modified workqueue code which
trigger the pool deadlock reliably without this patch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Eric Sandeen <sandeen@sandeen.net>
Link: http://lkml.kernel.org/g/54B019F4.8030009@sandeen.net
Cc: Dave Chinner <david@fromorbit.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agogpio: squelch a compiler warning
Martin Kaiser [Fri, 30 Jan 2015 14:01:29 +0000 (15:01 +0100)]
gpio: squelch a compiler warning

drivers/gpio/gpiolib-of.c: In function 'of_gpiochip_find_and_xlate':
drivers/gpio/gpiolib-of.c:51:21: warning: assignment makes integer from
pointer without a cast [enabled by default]
   gg_data->out_gpio = ERR_PTR(ret);
                     ^
this was introduced in d1c3449160df60fac4abb56f0ba0a3784305e43e

the upstream kernel changed the type of out_gpio from int to struct gpio_desc *
as part of a larger refactoring that wasn't backported

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoefi-pstore: Make efi-pstore return a unique id
Madper Xie [Fri, 29 Nov 2013 07:58:57 +0000 (15:58 +0800)]
efi-pstore: Make efi-pstore return a unique id

commit fdeadb43fdf1e7d5698c027b555c389174548e5a upstream.

Pstore fs expects that backends provide a unique id which could avoid
pstore making entries as duplication or denominating entries the same
name. So I combine the timestamp, part and count into id.

Signed-off-by: Madper Xie <cxie@redhat.com>
Cc: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: stable@vger.kernel.org
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
[hkp: Backported to 3.10: adjust context]
Signed-off-by: Hu Keping <hukeping@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agopstore/ram: avoid atomic accesses for ioremapped regions
Rob Herring [Tue, 9 Apr 2013 01:23:33 +0000 (20:23 -0500)]
pstore/ram: avoid atomic accesses for ioremapped regions

commit 0405a5cec3406f19e69da07c8111a6bf1088ac29 upstream.

For persistent RAM outside of main memory, the memory may have limitations
on supported accesses. For internal RAM on highbank platform exclusive
accesses are not supported and will hang the system. So atomic_cmpxchg
cannot be used. This commit uses spinlock protection for buffer size and
start updates on ioremapped regions instead.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Anton Vorontsov <anton@enomsg.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
[hkp: Backported to 3.10: adjust context]
Signed-off-by: HuKeping <hukeping@huawei.com>
9 years agopstore: Fix NULL pointer fault if get NULL prz in ramoops_get_next_prz
Liu ShuoX [Mon, 17 Mar 2014 20:57:49 +0000 (13:57 -0700)]
pstore: Fix NULL pointer fault if get NULL prz in ramoops_get_next_prz

commit b0aa931fb84431394d995472d0af2a6c2b61064d upstream.

ramoops_get_next_prz get the prz according the paramters. If it get a
uninitialized prz, access its members by following persistent_ram_old_size(prz)
will cause a NULL pointer crash.
Ex: if ftrace_size is 0, fprz will be NULL.

Fix it by return NULL in advance.

Signed-off-by: Liu ShuoX <shuox.liu@intel.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Cc: HuKeping <hukeping@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agopstore: skip zero size persistent ram buffer in traverse
Liu ShuoX [Mon, 17 Mar 2014 00:24:49 +0000 (11:24 +1100)]
pstore: skip zero size persistent ram buffer in traverse

commit aa9a4a1edfbd3d223af01db833da2f07850bc655 upstream.

In ramoops_pstore_read, a valid prz pointer with zero size buffer will
break traverse of all persistent ram buffers.  The latter buffer might be
lost.

Signed-off-by: Liu ShuoX <shuox.liu@intel.com>
Cc: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
Cc: Colin Cross <ccross@android.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Cc: HuKeping <hukeping@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agopstore: clarify clearing of _read_cnt in ramoops_context
Liu ShuoX [Mon, 17 Mar 2014 00:24:49 +0000 (11:24 +1100)]
pstore: clarify clearing of _read_cnt in ramoops_context

commit 57fd835385a043577457a385f28c08be693991bf upstream.

*_read_cnt in ramoops_context need to be cleared during pstore ->open to
support mutli times getting the records.  The patch added missed
ftrace_read_cnt clearing and removed duplicate clearing in ramoops_probe.

Signed-off-by: Liu ShuoX <shuox.liu@intel.com>
Cc: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
Cc: Colin Cross <ccross@android.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Cc: HuKeping <hukeping@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agopstore: d_alloc_name() doesn't return an ERR_PTR
Dan Carpenter [Wed, 14 Aug 2013 17:55:49 +0000 (10:55 -0700)]
pstore: d_alloc_name() doesn't return an ERR_PTR

commit c39524e6744284452ef45480d3153bec28960c32 upstream.

d_alloc_name() returns NULL on error.  Also I changed the error code
from -ENOSPC to -ENOMEM to reflect that we were short on RAM not disk
space.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Cc: HuKeping <hukeping@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agopstore: Fail to unlink if a driver has not defined pstore_erase
Aruna Balakrishnaiah [Tue, 25 Jun 2013 09:03:56 +0000 (14:33 +0530)]
pstore: Fail to unlink if a driver has not defined pstore_erase

commit bf2883339a33b7544b92ea465b90c3de55082032 upstream.

pstore_erase is used to erase the record from the persistent store.
So if a driver has not defined pstore_erase callback return
-EPERM instead of unlinking a file as deleting the file without
erasing its record in persistent store will give a wrong impression
to customers.

Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Cc: HuKeping <hukeping@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoARM: 8109/1: mm: Modify pte_write and pmd_write logic for LPAE
Steven Capper [Fri, 18 Jul 2014 15:16:15 +0000 (16:16 +0100)]
ARM: 8109/1: mm: Modify pte_write and pmd_write logic for LPAE

commit ded9477984690d026e46dd75e8157392cea3f13f upstream.

For LPAE, we have the following means for encoding writable or dirty
ptes:
                              L_PTE_DIRTY       L_PTE_RDONLY
    !pte_dirty && !pte_write        0               1
    !pte_dirty && pte_write         0               1
    pte_dirty && !pte_write         1               1
    pte_dirty && pte_write          1               0

So we can't distinguish between writeable clean ptes and read only
ptes. This can cause problems with ptes being incorrectly flagged as
read only when they are writeable but not dirty.

This patch renumbers L_PTE_RDONLY from AP[2] to a software bit #58,
and adds additional logic to set AP[2] whenever the pte is read only
or not dirty. That way we can distinguish between clean writeable ptes
and read only ptes.

HugeTLB pages will use this new logic automatically.

We need to add some logic to Transparent HugePages to ensure that they
correctly interpret the revised pgprot permissions (L_PTE_RDONLY has
moved and no longer matches PMD_SECT_AP2). In the process of revising
THP, the names of the PMD software bits have been prefixed with L_ to
make them easier to distinguish from their hardware bit counterparts.

Signed-off-by: Steve Capper <steve.capper@linaro.org>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
[hpy: Backported to 3.10
 - adjust the context
 - ignore change related to pmd, because 3.10 does not support HugePage ]
Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>