* [RFC PATCH 1/3] dt-bindings: pinctrl: sunxi: document new generic binding
From: André Przywara @ 2017-12-06 0:55 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <CACRpkdZ70a7Vk1QPFhkms6ucWmSH6rOUD9_J0h=NjhK+vfXNAA@mail.gmail.com>
Hi Linus,
thanks for the reply!
On 01/12/17 09:56, Linus Walleij wrote:
> On Fri, Nov 24, 2017 at 6:19 PM, Andre Przywara <andre.przywara@arm.com> wrote:
>
>> Conceptually I consider the DT being
>> part of the firmware,
>
> As it is a subset of open firmware it is obviously firmware.
>
>> so one trust level above the kernel.
>
> We are several kernel developers who don't trust firmware one
> bit. Several disasters in ACPI has made me ever more convinced
> that firmware should be trusted less than kernel code.
I know what you mean, check commit acd316248205 ;-)
But in the Allwinner case all the firmware is open source, and even
controlled by the community (ATF & U-Boot). This is even more true for
the DT. Allwinner came up with their own DT, but since it uses
completely non-standard bindings, we don't use it at all.
So I don't consider firmware this dark, evil and unhackable blob that
many people see in it. Instead it is a good opportunity to separate very
tedious machine-specific parts from the kernel (think of PSCI).
> But this is all very academic.
I agree!
>>> Also, device tree bindings are not documentation for how to write a
>>> driver. They are not a replacement for hardware documentation. Nobody
>>> should be expected to be able to write an OS driver solely based on a
>>> device tree binding. Device tree bindings are more of a configuration
>>> interface specification for OS drivers.
>>
>> Yes, but together with the hardware docs you should be able to write a
>> driver. And here you can't, because you are missing the strings. So a
>> BSD developer has to look at Linux code.
>
> This is a fair point. It appears in several drivers.
>
> BSD or even Windows (would they use DT) would have to sit in the
> back seat just like Linux has been doing for years when it comes
> to the hopeless Windowsisms in the x86 BIOSes. I suspect some
> Windows on ARM is already experiencing this, but in the ACPI world,
> where, incidentally, the servers were being deployed for Linux first
> and Windows had to follow their example. I bet they have been
> swearing a lot in Redmond about that.
On the other hand a lot of the ACPI tables have been either taken from
x86 or designed also with Windows in mind. And frankly, my sympathy for
MS is quite limited in this respect ;-)
> In general it's one of these areas where we can not be utopian about the
> hardware descriptions, just fail gracefully in different ways.
>
> I usually try to keep the IETF motto "rough consensus and running
> code" in mind. I don't know if it helps in this discussion though.
>
>>> So that's about 40% of the kernel image. Code really is no good without
>>> data to process.
>>
>> But how much of this is SoC specific configuration data? How much is it
>> in x86? Yes, historically we had and have a lot of configuration data in
>> ARM kernels. But that doesn't mean that we have to continue with this or
>> even increase the share.
>
> What people have been doing is trying to have better Kconfig setups
> and compile it out by doing kernel modules. It is a bit hopeless with
> pin controllers: almost all of them have to be built in. And if they come
> with a lot of data, yeah there you have a real good point.
>
> It would be sad if the ARMv7 multiboot or Aarch64 kernel just grows
> so that we can't use it but have to go back to shipping board-specific
> kernels with a huge bunch of stuff compiled out.
>
> I was hoping Moore's law would save us here :/
>
> An option that has been discussed is better used of __initdata
> and similar tags, especially with built-in drivers. Sadly, this is
> hurt by another snag: the compiler or linker file or whatever it is,
> is preventing us from discarding any strings from the kernel.
> And pin controllers tend to stack up a lot of these.
>
> This is really sucky and something we should solve in general.
> I'm not smart enough to tackle any of these problems myself, just
> to see them and "Oh that's bad. Very bad."
I am sure one can find clever hac^Wsolutions for this problem, but I was
wondering if a new approach - like putting the per machine data actually
in DT - isn't the smarter way.
Hence my suggestion with this driver: we *need* the DT anyway to assign
pins to devices, so why not just add the few bytes *there*, which allows
us to have a more or less "data-less" DT driver?
>From what I learned the pinctrl subsystem seems to predates the ARM DT
endeavor, so many design decisions probably didn't consider DT as a
possible solution in the first way. And this is fine, because this is
how it was back then. But it doesn't mean it has to stay this way. And I
carefully thought of solving this problem without alienating existing
users and developers - by keeping the driver and staying compatible with
the existing binding and the DTs.
>>> The majority of the improvements over the years have been achieved by
>>> moving drivers out of arch/arm and moving board files to DT. The goal
>>> was never to get rid of all data.
>>
>> Sure, not all data. But if we have the relatively easy opportunity to
>> avoid further addition of data, we should do it, I believe.
>> This significantly reduces the amount of kernel code we need to add to
>> support new SoCs.
>
> This is the core of your argument as I perceive it: get rid of data
> from the kernel, because it is growing wild.
Yes, this, but also to avoid replicating data in other DT consumers. I
very much like the idea of the DT describing the hardware, but I am a
bit afraid we loose many good opportunities by treating the DT more like
a "Linux config file" or an external Linux board file.
So I wanted to propose a way where we simplify DT usage in other
systems, while still keeping the Linux driver intact.
> It is a valid cause. Just
> has to be weighed with other stuff, like maintainability, debuggability,
> maintainers viewpoint. ...
So to keep Maxime happy I actually designed this "driver" more like a
shim: to generate the table the current driver expects from the DT, and
actually not touching the existing driver at all.
So maintainability should actually be less of a concern: the driver will
just work with whatever one throws at it from the DT side, without
requiring frequent changes or additions.
In the moment we still need to write, review and merge *data* files for
each new SoC. And as I mentioned before, Allwinner decided to push for
new, slightly different chips every few months, so there will be more to
come. With at least the pinctrl driver out of the way we have one
problem less to worry about.
Cheers,
Andre.
^ permalink raw reply
* [PATCH v9 3/5] perf utils: use pmu->is_uncore to detect PMU UNCORE devices
From: Jin, Yao @ 2017-12-06 0:30 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205184242.GA19952@kernel.org>
On 12/6/2017 2:42 AM, Arnaldo Carvalho de Melo wrote:
> Em Tue, Dec 05, 2017 at 08:35:22PM +0800, Jin, Yao escreveu:
>> A quick test with the new patch 'fix_json_v9_2.patch' shows it working.
>
> I'll take this as a Tested-by: you, ok?
>
Hi Arnaldo,
I didn't do a full test for this patch and for the whole patch series.
I just do a quick test and it shows that the regression issue which was
found in 'perf stat --per-thread' test case is disappear.
If you think it's enough for adding Tested-by, that's fine for me. :)
Thanks
Jin Yao
>> See the log:
>>
>> root at skl:/tmp# perf stat --per-thread -p 10322 -M CPI,IPC
>> ^C
>> Performance counter stats for process id '10322':
>>
>> vmstat-10322 1,879,654 inst_retired.any #
>> 0.8 CPI
>> vmstat-10322 1,565,807 cycles
>> vmstat-10322 1,879,654 inst_retired.any #
>> 1.2 IPC
>> vmstat-10322 1,565,807 cpu_clk_unhalted.thread
>>
>> 2.850291804 seconds time elapsed
>>
>> Thanks for fixing it quickly.
>>
>> Thanks
>> Jin Yao
>>
>> On 12/5/2017 3:23 PM, Jin, Yao wrote:
>>> Hi,
>>>
>>> I applied the diff but it's failed.
>>>
>>> jinyao at skl:~/skl-ws/perf-dev/lck-4594/src$ patch -p1 < 1.pat
>>> patching file tools/perf/util/pmu.c
>>> patch: **** malformed patch at line 41: *head, struct perf_pmu *pmu)
>>>
>>> Could you send the patch as attachment to me in another mail thread?
>>>
>>> to yao.jin at linux.intel.com
>>> cc yao.jin at intel.com
>>>
>>> Thanks
>>> Jin Yao
>>>
>>> On 12/5/2017 3:12 PM, Ganapatrao Kulkarni wrote:
>>>> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
>>>> index 5ad8a18..57e38fd 100644
>>>> --- a/tools/perf/util/pmu.c
>>>> +++ b/tools/perf/util/pmu.c
>>>> @@ -538,6 +538,34 @@ static bool pmu_is_uncore(const char *name)
>>>> ? }
>>>>
>>>> ? /*
>>>> + *? PMU CORE devices have different name other than cpu in sysfs on some
>>>> + *? platforms. looking for possible sysfs files to identify as core
>>>> device.
>>>> + */
>>>> +static int is_pmu_core(const char *name)
>>>> +{
>>>> + struct stat st;
>>>> + char path[PATH_MAX];
>>>> + const char *sysfs = sysfs__mountpoint();
>>>> +
>>>> + if (!sysfs)
>>>> + return 0;
>>>> +
>>>> + /* Look for cpu sysfs (x86 and others) */
>>>> + scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu", sysfs);
>>>> + if ((stat(path, &st) == 0) &&
>>>> + (strncmp(name, "cpu", strlen("cpu")) == 0))
>>>> + return 1;
>>>> +
>>>> + /* Look for cpu sysfs (specific to arm) */
>>>> + scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/cpus",
>>>> + sysfs, name);
>>>> + if (stat(path, &st) == 0)
>>>> + return 1;
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +/*
>>>> ?? * Return the CPU id as a raw string.
>>>> ?? *
>>>> ?? * Each architecture should provide a more precise id string that
>>>> @@ -641,7 +669,7 @@ static void pmu_add_cpu_aliases(struct list_head
>>>> *head, struct perf_pmu *pmu)
>>>> ?? break;
>>>> ?? }
>>>>
>>>> - if (pmu->is_uncore) {
>>>> + if (!is_pmu_core(name)) {
>>>> ?? /* check for uncore devices */
>>>> ?? if (pe->pmu == NULL)
>>>> ?? continue;
^ permalink raw reply
* [PATCH] arm64: dts: rockchip: limit rk3328-rock64 gmac speed to 100MBit for now
From: Heiko Stuebner @ 2017-12-06 0:14 UTC (permalink / raw)
To: linux-arm-kernel
It looks like either the current kernel or the hardware has reliability
issues when the gmac is actually running at 1GBit. In my test-case
it is not able to boot on a nfsroot at this speed, as the system
will always lose the connection to the nfs-server during boot, before
reaching any login prompt and not recover from this.
So until this is solved, limit the speed to 100MBit as with this the
nfsroot survives stress tests like an apt-get upgrade without problems.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
arch/arm64/boot/dts/rockchip/rk3328-rock64.dts | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
index d4f80786e7c2..3890468678ce 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
@@ -132,6 +132,8 @@
assigned-clocks = <&cru SCLK_MAC2IO>, <&cru SCLK_MAC2IO_EXT>;
assigned-clock-parents = <&gmac_clkin>, <&gmac_clkin>;
clock_in_out = "input";
+ /* shows instability at 1GBit right now */
+ max-speed = <100>;
phy-supply = <&vcc_io>;
phy-mode = "rgmii";
pinctrl-names = "default";
--
2.14.2
^ permalink raw reply related
* [PATCH v3 3/3] staging: vc04_services: Use __func__
From: Genki Sky @ 2017-12-06 0:09 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <cover.1512518762.git.sky@genki.is>
This was found using checkpatch.pl's EMBEDDED_FUNCTION_NAME warning.
It is easier to be consistent and always use __func__ instead of having
to remember to update any hardcoded references to the original name.
Signed-off-by: Genki Sky <sky@genki.is>
---
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index 5ddea4f54bf7..6c4d8b4c7cd9 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -618,8 +618,8 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
struct mmal_msg_context *msg_context;
u32 handle;
- pr_debug("buffer_to_host_cb: instance:%p msg:%p msg_len:%d\n",
- instance, msg, msg_len);
+ pr_debug("%s: instance:%p msg:%p msg_len:%d\n",
+ __func__, instance, msg, msg_len);
if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) {
handle = msg->u.buffer_from_host.drvbuf.client_context;
--
2.15.1
^ permalink raw reply related
* [PATCH v3 1/3] staging: vc04_services: Join multiline dereferences
From: Genki Sky @ 2017-12-06 0:09 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <cover.1512518762.git.sky@genki.is>
This was found using checkpatch.pl's MULTILINE_DEREFERENCE warning.
Putting the dereference onto one line makes them easier to read,
especially when part of a larger expression (in this case, function
arguments and ternary operator), and when the dereferences are short
(as they are here).
Signed-off-by: Genki Sky <sky@genki.is>
---
.../vc04_services/bcm2835-camera/bcm2835-camera.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
index d8766b166675..4ed3b449f97f 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -328,11 +328,9 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
pr_debug("Grab another frame");
vchiq_mmal_port_parameter_set(
instance,
- dev->capture.
- camera_port,
+ dev->capture.camera_port,
MMAL_PARAMETER_CAPTURE,
- &dev->capture.
- frame_count,
+ &dev->capture.frame_count,
sizeof(dev->capture.frame_count));
}
} else {
@@ -368,11 +366,9 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
"Grab another frame as buffer has EOS");
vchiq_mmal_port_parameter_set(
instance,
- dev->capture.
- camera_port,
+ dev->capture.camera_port,
MMAL_PARAMETER_CAPTURE,
- &dev->capture.
- frame_count,
+ &dev->capture.frame_count,
sizeof(dev->capture.frame_count));
}
} else {
@@ -1194,8 +1190,8 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev,
port->current_buffer.size =
(f->fmt.pix.sizeimage <
(100 << 10))
- ? (100 << 10) : f->fmt.pix.
- sizeimage;
+ ? (100 << 10)
+ : f->fmt.pix.sizeimage;
}
v4l2_dbg(1, bcm2835_v4l2_debug,
&dev->v4l2_dev,
--
2.15.1
^ permalink raw reply related
* [PATCH v3 2/3] staging: vc04_services: Unsplit user-visible strings
From: Genki Sky @ 2017-12-06 0:09 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <cover.1512518762.git.sky@genki.is>
This was found using checkpatch.pl's SPLIT_STRING warning. While joining
these strings makes for long lines, the kernel codebase consistently
does it this way to make user-visible strings easier to grep for.
Signed-off-by: Genki Sky <sky@genki.is>
---
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 7 +++----
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 3 +--
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
index 4ed3b449f97f..e26895dc052e 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
@@ -347,8 +347,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
timestamp = ktime_add_us(dev->capture.kernel_start_ts,
runtime_us);
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
- "Convert start time %llu and %llu "
- "with offset %llu to %llu\n",
+ "Convert start time %llu and %llu with offset %llu to %llu\n",
ktime_to_ns(dev->capture.kernel_start_ts),
dev->capture.vc_start_timestamp, pts,
ktime_to_ns(timestamp));
@@ -532,8 +531,8 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
vchiq_mmal_port_enable(dev->instance, dev->capture.port, buffer_cb);
if (ret) {
v4l2_err(&dev->v4l2_dev,
- "Failed to enable capture port - error %d. "
- "Disabling camera port again\n", ret);
+ "Failed to enable capture port - error %d. Disabling camera port again\n",
+ ret);
vchiq_mmal_port_disable(dev->instance,
dev->capture.camera_port);
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index 6ea7fb0ea50e..5ddea4f54bf7 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -1360,8 +1360,7 @@ static int port_action_handle(struct vchiq_mmal_instance *instance,
ret = -rmsg->u.port_action_reply.status;
- pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)" \
- " connect component:0x%x connect port:%d\n",
+ pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n",
__func__,
ret, port->component->handle, port->handle,
port_action_type_names[action_type],
--
2.15.1
^ permalink raw reply related
* [PATCH v3 0/3] staging: vc04_services: Fix small style issues
From: Genki Sky @ 2017-12-06 0:09 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
This is v3 of a patch series to fix some checkpatch.pl warnings in
drivers/staging/vc04_services/bcm2835-camera/*
Changes from v2 [2]:
- Provide more detailed description in commit messages
Changes from v1 [1]:
- Split single patch into multiple patches
- Remove reference to eudyptula in commit message
[1]: https://lkml.kernel.org/r/30cc7b48def470f1bec8d8d255044f4f220531ee.1512368114.git.sky at genki.is
[2]: https://lkml.kernel.org/r/cover.1512441073.git.sky at genki.is
[ aside: this is for task-10 of http://eudyptula-challenge.org/ ]
Genki Sky (3):
staging: vc04_services: Join multiline dereferences
staging: vc04_services: Unsplit user-visible strings
staging: vc04_services: Use __func__
.../vc04_services/bcm2835-camera/bcm2835-camera.c | 23 +++++++++-------------
.../vc04_services/bcm2835-camera/mmal-vchiq.c | 7 +++----
2 files changed, 12 insertions(+), 18 deletions(-)
--
2.15.1
^ permalink raw reply
* [kernel-hardening][PATCH v3 0/3] arm: Makes ptdump resuable and add WX page checking
From: Laura Abbott @ 2017-12-05 23:54 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171204142458.GA3325@pjb1027-Latitude-E5410>
On 12/04/2017 06:24 AM, Jinbum Park wrote:
> Hi,
>
> Page table dumping code for arm64-x86 is reusable,
> and they have function for WX page checking.
> But arm doesn't have that.
>
> This path series are to makes ptdump reusable,
> and add WX page checking for arm.
> This is heavily based on arm64 version.
>
> v2 :
> Fix a sender name of mail header, there was an mistake.
> (from "jinb.park" to Jinbum Park)
> Contents of patch-set are perfectly same.
>
> v3 :
> Take advantage of the existing pg_level and bits arrays
> to check ro, nx prot.
>
> jinb.park (3):
> arm: mm: dump: make page table dumping reusable
> arm: mm: dump: make the page table dumping seq_file optional
> arm: mm: dump: add checking for writable and executable pages
>
> arch/arm/Kconfig.debug | 33 +++++++++-
> arch/arm/include/asm/ptdump.h | 56 ++++++++++++++++
> arch/arm/mm/Makefile | 3 +-
> arch/arm/mm/dump.c | 144 +++++++++++++++++++++++++++++-------------
> arch/arm/mm/init.c | 2 +
> arch/arm/mm/ptdump_debugfs.c | 34 ++++++++++
> 6 files changed, 226 insertions(+), 46 deletions(-)
> create mode 100644 arch/arm/include/asm/ptdump.h
> create mode 100644 arch/arm/mm/ptdump_debugfs.c
>
This detects the issue fixed by 400eeffaffc7 ("ARM: 8722/1: mm:
make STRICT_KERNEL_RWX effective for LPAE"). I'll give it another
test after the next version.
Thanks,
Laura
^ permalink raw reply
* [kernel-hardening][PATCH v3 3/3] arm: mm: dump: add checking for writable and executable pages
From: Laura Abbott @ 2017-12-05 23:51 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171204142709.GA3376@pjb1027-Latitude-E5410>
On 12/04/2017 06:27 AM, Jinbum Park wrote:
> Page mappings with full RWX permissions are a security risk.
> x86, arm64 has an option to walk the page tables
> and dump any bad pages.
>
> (1404d6f13e47
> ("arm64: dump: Add checking for writable and exectuable pages"))
> Add a similar implementation for arm.
>
> Signed-off-by: Jinbum Park <jinb.park7@gmail.com>
> ---
> v3: Reuse pg_level, prot_bits to check ro, nx prot.
>
> arch/arm/Kconfig.debug | 27 +++++++++++++++++++++++
> arch/arm/include/asm/ptdump.h | 8 +++++++
> arch/arm/mm/dump.c | 51 +++++++++++++++++++++++++++++++++++++++++++
> arch/arm/mm/init.c | 2 ++
> 4 files changed, 88 insertions(+)
>
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index e7b94db..78a6470 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -20,6 +20,33 @@ config ARM_PTDUMP_DEBUGFS
> kernel.
> If in doubt, say "N"
>
> +config DEBUG_WX
> + bool "Warn on W+X mappings at boot"
> + select ARM_PTDUMP_CORE
> + ---help---
> + Generate a warning if any W+X mappings are found at boot.
> +
> + This is useful for discovering cases where the kernel is leaving
> + W+X mappings after applying NX, as such mappings are a security risk.
> +
> + Look for a message in dmesg output like this:
> +
> + arm/mm: Checked W+X mappings: passed, no W+X pages found.
> +
> + or like this, if the check failed:
> +
> + arm/mm: Checked W+X mappings: FAILED, <N> W+X pages found.
> +
> + Note that even if the check fails, your kernel is possibly
> + still fine, as W+X mappings are not a security hole in
> + themselves, what they do is that they make the exploitation
> + of other unfixed kernel bugs easier.
> +
> + There is no runtime or memory usage effect of this option
> + once the kernel has booted up - it's a one time check.
> +
> + If in doubt, say "Y".
> +
> # RMK wants arm kernels compiled with frame pointers or stack unwinding.
> # If you know what you are doing and are willing to live without stack
> # traces, you can get a slightly smaller kernel by setting this option to
> diff --git a/arch/arm/include/asm/ptdump.h b/arch/arm/include/asm/ptdump.h
> index 3a6c0b7..b6a0162 100644
> --- a/arch/arm/include/asm/ptdump.h
> +++ b/arch/arm/include/asm/ptdump.h
> @@ -43,6 +43,14 @@ static inline int ptdump_debugfs_register(struct ptdump_info *info,
> }
> #endif /* CONFIG_ARM_PTDUMP_DEBUGFS */
>
> +void ptdump_check_wx(void);
> +
> #endif /* CONFIG_ARM_PTDUMP_CORE */
>
> +#ifdef CONFIG_DEBUG_WX
> +#define debug_checkwx() ptdump_check_wx()
> +#else
> +#define debug_checkwx() do { } while (0)
> +#endif
> +
> #endif /* __ASM_PTDUMP_H */
> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
> index 43a2bee..3e2e6f0 100644
> --- a/arch/arm/mm/dump.c
> +++ b/arch/arm/mm/dump.c
> @@ -52,6 +52,8 @@ struct pg_state {
> unsigned long start_address;
> unsigned level;
> u64 current_prot;
> + bool check_wx;
> + unsigned long wx_pages;
> const char *current_domain;
> };
>
> @@ -194,6 +196,8 @@ struct pg_level {
> const struct prot_bits *bits;
> size_t num;
> u64 mask;
> + const struct prot_bits *ro_bit;
> + const struct prot_bits *nx_bit;
> };
>
> static struct pg_level pg_level[] = {
> @@ -203,9 +207,17 @@ struct pg_level {
> }, { /* pmd */
> .bits = section_bits,
> .num = ARRAY_SIZE(section_bits),
> + #ifdef CONFIG_ARM_LPAE
> + .ro_bit = section_bits + 1,
> + #else
> + .ro_bit = section_bits,
> + #endif
> + .nx_bit = section_bits + ARRAY_SIZE(section_bits) - 2,
> }, { /* pte */
> .bits = pte_bits,
> .num = ARRAY_SIZE(pte_bits),
> + .ro_bit = pte_bits + 1,
> + .nx_bit = pte_bits + 2,
> },
> };
>
This is better but the addition offset from the array is still
prone to breakage if we add entries. Maybe something like this
on top of yours:
diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index 3e2e6f06e4d9..572cbc4dc247 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -62,6 +62,8 @@ struct prot_bits {
u64 val;
const char *set;
const char *clear;
+ bool ro_bit;
+ bool x_bit;
};
static const struct prot_bits pte_bits[] = {
@@ -75,11 +77,13 @@ static const struct prot_bits pte_bits[] = {
.val = L_PTE_RDONLY,
.set = "ro",
.clear = "RW",
+ .ro_bit = true,
}, {
.mask = L_PTE_XN,
.val = L_PTE_XN,
.set = "NX",
.clear = "x ",
+ .x_bit = true,
}, {
.mask = L_PTE_SHARED,
.val = L_PTE_SHARED,
@@ -143,11 +147,13 @@ static const struct prot_bits section_bits[] = {
.val = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
.set = "ro",
.clear = "RW",
+ .ro_bit = true,
#elif __LINUX_ARM_ARCH__ >= 6
{
.mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
.val = PMD_SECT_APX | PMD_SECT_AP_WRITE,
.set = " ro",
+ .ro_bit = true,
}, {
.mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
.val = PMD_SECT_AP_WRITE,
@@ -166,6 +172,7 @@ static const struct prot_bits section_bits[] = {
.mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
.val = 0,
.set = " ro",
+ .ro_bit = true,
}, {
.mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
.val = PMD_SECT_AP_WRITE,
@@ -184,6 +191,7 @@ static const struct prot_bits section_bits[] = {
.val = PMD_SECT_XN,
.set = "NX",
.clear = "x ",
+ .x_bit = true,
}, {
.mask = PMD_SECT_S,
.val = PMD_SECT_S,
@@ -207,17 +215,9 @@ static struct pg_level pg_level[] = {
}, { /* pmd */
.bits = section_bits,
.num = ARRAY_SIZE(section_bits),
- #ifdef CONFIG_ARM_LPAE
- .ro_bit = section_bits + 1,
- #else
- .ro_bit = section_bits,
- #endif
- .nx_bit = section_bits + ARRAY_SIZE(section_bits) - 2,
}, { /* pte */
.bits = pte_bits,
.num = ARRAY_SIZE(pte_bits),
- .ro_bit = pte_bits + 1,
- .nx_bit = pte_bits + 2,
},
};
@@ -410,8 +410,13 @@ static void ptdump_initialize(void)
for (i = 0; i < ARRAY_SIZE(pg_level); i++)
if (pg_level[i].bits)
- for (j = 0; j < pg_level[i].num; j++)
+ for (j = 0; j < pg_level[i].num; j++) {
pg_level[i].mask |= pg_level[i].bits[j].mask;
+ if (pg_level[i].bits[j].ro_bit)
+ pg_level[i].ro_bit = &pg_level[i].bits[j];
+ if (pg_level[i].bits[j].x_bit)
+ pg_level[i].nx_bit = &pg_level[i].bits[j];
+ }
address_markers[2].start_address = VMALLOC_START;
}
> @@ -226,6 +238,23 @@ static void dump_prot(struct pg_state *st, const struct prot_bits *bits, size_t
> }
> }
>
> +static void note_prot_wx(struct pg_state *st, unsigned long addr)
> +{
> + if (!st->check_wx)
> + return;
> + if ((st->current_prot & pg_level[st->level].ro_bit->mask) ==
> + pg_level[st->level].ro_bit->val)
> + return;
> + if ((st->current_prot & pg_level[st->level].nx_bit->mask) ==
> + pg_level[st->level].nx_bit->val)
> + return;
> +
> + WARN_ONCE(1, "arm/mm: Found insecure W+X mapping at address %p/%pS\n",
> + (void *)st->start_address, (void *)st->start_address);
> +
With the new %p hashing, printing just %p is not useful, so just drop
it and just have the %pS.
Thanks,
Laura
^ permalink raw reply related
* [PATCH v4] usb: xhci: allow imod-interval to be configurable
From: Adam Wallis @ 2017-12-05 23:50 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <f5ca26d2-9432-2ae3-7501-5b3dcf1e1486@linux.intel.com>
Rob,
On 12/5/2017 3:48 AM, Mathias Nyman wrote:
> On 05.12.2017 04:54, Adam Wallis wrote:
>> On 12/4/2017 9:15 PM, Chunfeng Yun wrote:
>>> On Mon, 2017-12-04 at 09:27 -0500, Adam Wallis wrote:
>>>> The xHCI driver currently has the IMOD set to 160, which
[..]
>
> If Rob Acks this version I'll apply it and remove that blank line.
>
> -Mathias
>
Let me know if you have any other issues with this patch, otherwise with your
ACK, we are done.
Thanks
Adam
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
Adam Wallis
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
^ permalink raw reply
* [PATCH] clk: Manage proper runtime PM state in clk_change_rate()
From: Stephen Boyd @ 2017-12-05 23:26 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171130121451.6710-1-m.szyprowski@samsung.com>
On 11/30, Marek Szyprowski wrote:
> clk_change_rate() propagates rate change down to all its children. Such
> operation requires managing proper runtime PM state of each child, what
> was missing. Add needed calls to clk_pm_runtime*() to ensure that
> set_rate() clock callback is called on runtime active clock.
>
> This fixes following issue found on Exynos5433 TM2 board with devfreq
> enabled:
>
> Synchronous External Abort: synchronous external abort (0x96000210) at 0xffffff80093f5600
> Internal error: : 96000210 [#1] PREEMPT SMP
> Modules linked in:
> CPU: 0 PID: 5 Comm: kworker/u16:0 Not tainted 4.15.0-rc1-next-20171129+ #4
> Hardware name: Samsung TM2 board (DT)
> Workqueue: devfreq_wq devfreq_monitor
> task: ffffffc0ca96b600 task.stack: ffffff80093a8000
> pstate: a0000085 (NzCv daIf -PAN -UAO)
> pc : clk_divider_set_rate+0x54/0x118
> lr : clk_divider_set_rate+0x44/0x118
> ...
> Process kworker/u16:0 (pid: 5, stack limit = 0xffffff80093a8000)
> Call trace:
> clk_divider_set_rate+0x54/0x118
> clk_change_rate+0xfc/0x4e0
> clk_change_rate+0x1f0/0x4e0
> clk_change_rate+0x1f0/0x4e0
> clk_change_rate+0x1f0/0x4e0
> clk_core_set_rate_nolock+0x138/0x148
> clk_set_rate+0x28/0x50
> exynos_bus_passive_target+0x6c/0x11c
> update_devfreq_passive+0x58/0xb4
> devfreq_passive_notifier_call+0x50/0x5c
> notifier_call_chain+0x4c/0x88
> __srcu_notifier_call_chain+0x54/0x80
> srcu_notifier_call_chain+0x14/0x1c
> update_devfreq+0x100/0x1b4
> devfreq_monitor+0x2c/0x88
> process_one_work+0x148/0x3d8
> worker_thread+0x13c/0x3f8
> kthread+0x100/0x12c
> ret_from_fork+0x10/0x18
>
> Reported-by: Chanwoo Choi <cw00.choi@samsung.com>
> Fixes: 9a34b45397e5 ("clk: Add support for runtime PM")
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
Applied to clk-fixes
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply
* [PATCH v4 02/10] pinctrl: axp209: add pinctrl features
From: kbuild test robot @ 2017-12-05 23:21 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <71c9da94df2a5938cb8c092e40f8e36eec0b01c3.1512135804.git-series.quentin.schulz@free-electrons.com>
Hi Quentin,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on pinctrl/devel]
[also build test ERROR on v4.15-rc2 next-20171205]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Quentin-Schulz/pinctrl-move-gpio-axp209-to-pinctrl/20171204-050707
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: i386-randconfig-h1-12060258 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
>> drivers//pinctrl/pinctrl-axp209.c:290:21: error: 'pinconf_generic_dt_node_to_map_group' undeclared here (not in a function)
.dt_node_to_map = pinconf_generic_dt_node_to_map_group,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers//pinctrl/pinctrl-axp209.c:291:18: error: 'pinconf_generic_dt_free_map' undeclared here (not in a function)
.dt_free_map = pinconf_generic_dt_free_map,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/pinconf_generic_dt_node_to_map_group +290 drivers//pinctrl/pinctrl-axp209.c
288
289 static const struct pinctrl_ops axp20x_pctrl_ops = {
> 290 .dt_node_to_map = pinconf_generic_dt_node_to_map_group,
> 291 .dt_free_map = pinconf_generic_dt_free_map,
292 .get_groups_count = axp20x_groups_cnt,
293 .get_group_name = axp20x_group_name,
294 .get_group_pins = axp20x_group_pins,
295 };
296
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 28831 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171206/d4447d00/attachment-0001.gz>
^ permalink raw reply
* [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC
From: Vasily Khoruzhick @ 2017-12-05 23:17 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205080444.zo2rlusqpjyraqcw@flea.lan>
On Tue, Dec 5, 2017 at 12:04 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Sun, Dec 03, 2017 at 12:41:52PM -0800, Vasily Khoruzhick wrote:
>> Digital part of audio codec block in the A64 is very similar to what
>> is used by the A33(sun8i) devices. However, it uses different LRCK
>> divider.
>>
>> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
>
> What makes it impossible to derive from the sample rate and number of
> channels?
It's BCLK / LRCK ratio as per A64 user manual, so it doesn't depend on
sample rate. BSP driver always uses a fixed value of 64 here.
> Have you tried other sampling rates?
I tried speaker-test with a number of sampling rates and had no
issues. I couldn't try it in mono, since sun4i-i2s supports minimum of
2 channels.
>
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
^ permalink raw reply
* [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
From: Vasily Khoruzhick @ 2017-12-05 23:04 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205080149.2siofhpynfrvnoiq@flea.lan>
On Tue, Dec 5, 2017 at 12:01 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi,
>
> On Sun, Dec 03, 2017 at 11:34:06PM -0800, Vasily Khoruzhick wrote:
>> I'd keep it sun50i_a64_acodec_i2s, since other 3 I2S modules aren't
>> compatible with this one, but similar to H3.
>
> Please don't top-post.
>
> What are those differences?
Different registers and their locations. Compare quirks for
sun50i_a64_acodec_i2s and sun8i_h3_i2s fro details.
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
^ permalink raw reply
* [PATCH v6 6/8] KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs
From: Yury Norov @ 2017-12-05 22:39 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <3cd51419-cd43-998d-f801-407b805eb9a2@arm.com>
On Tue, Dec 05, 2017 at 04:47:46PM +0000, Marc Zyngier wrote:
> On 05/12/17 15:03, Yury Norov wrote:
> > On Mon, Dec 04, 2017 at 09:05:04PM +0100, Christoffer Dall wrote:
> >> From: Christoffer Dall <christoffer.dall@linaro.org>
> >>
> >> For mapped IRQs (with the HW bit set in the LR) we have to follow some
> >> rules of the architecture. One of these rules is that VM must not be
> >> allowed to deactivate a virtual interrupt with the HW bit set unless the
> >> physical interrupt is also active.
> >>
> >> This works fine when injecting mapped interrupts, because we leave it up
> >> to the injector to either set EOImode==1 or manually set the active
> >> state of the physical interrupt.
> >>
> >> However, the guest can set virtual interrupt to be pending or active by
> >> writing to the virtual distributor, which could lead to deactivating a
> >> virtual interrupt with the HW bit set without the physical interrupt
> >> being active.
> >>
> >> We could set the physical interrupt to active whenever we are about to
> >> enter the VM with a HW interrupt either pending or active, but that
> >> would be really slow, especially on GICv2. So we take the long way
> >> around and do the hard work when needed, which is expected to be
> >> extremely rare.
> >>
> >> When the VM sets the pending state for a HW interrupt on the virtual
> >> distributor we set the active state on the physical distributor, because
> >> the virtual interrupt can become active and then the guest can
> >> deactivate it.
> >>
> >> When the VM clears the pending state we also clear it on the physical
> >> side, because the injector might otherwise raise the interrupt. We also
> >> clear the physical active state when the virtual interrupt is not
> >> active, since otherwise a SPEND/CPEND sequence from the guest would
> >> prevent signaling of future interrupts.
> >>
> >> Changing the state of mapped interrupts from userspace is not supported,
> >> and it's expected that userspace unmaps devices from VFIO before
> >> attempting to set the interrupt state, because the interrupt state is
> >> driven by hardware.
> >>
> >> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
> >> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> >> ---
> >> virt/kvm/arm/vgic/vgic-mmio.c | 71 +++++++++++++++++++++++++++++++++++++++----
> >> virt/kvm/arm/vgic/vgic.c | 7 +++++
> >> virt/kvm/arm/vgic/vgic.h | 1 +
> >> 3 files changed, 73 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c
> >> index 747b0a3b4784..8d173d99a7a4 100644
> >> --- a/virt/kvm/arm/vgic/vgic-mmio.c
> >> +++ b/virt/kvm/arm/vgic/vgic-mmio.c
> >> @@ -16,6 +16,7 @@
> >> #include <linux/kvm.h>
> >> #include <linux/kvm_host.h>
> >> #include <kvm/iodev.h>
> >> +#include <kvm/arm_arch_timer.h>
> >> #include <kvm/arm_vgic.h>
> >>
> >> #include "vgic.h"
> >> @@ -143,10 +144,22 @@ static struct kvm_vcpu *vgic_get_mmio_requester_vcpu(void)
> >> return vcpu;
> >> }
> >>
> >> +/* Must be called with irq->irq_lock held */
> >
> > Instead of enforcing this rule in comment, you can enforce it in code:
> >
> > BUG_ON(!spin_is_locked(irq->irq_lock))
>
> Are we going to litter the kernel with such assertions? I don't think
> that's a valuable thing to do.
That's what I agree - BUG-ifiyng is somewhat debugging technique and
should be avoided in release code. But as I can see, in kvm code BUG()s
are widely used:
$ find . -name "*.c" | xargs grep -w 'BUG\|BUG_ON' | grep kvm | wc -l
155
So I tuned my littering detector. :)
In this patchset new BUG()s are added in patches 4 and 6. In patch 6
BUG() has meaning of TODO:
+ if (vintid == vcpu_vtimer(vcpu)->irq.irq)
+ timer = vcpu_vtimer(vcpu);
+ else
+ BUG(); /* We only map the vtimer so far */
+
Which is far from original purpose of BUG().
If you think that BUG() is not OK in this case (and I agree with it),
I think they should be also removed from patches 4 and 6. 6 - for sure.
Yury
^ permalink raw reply
* [PATCH v1 6/6] ARM: dts: imx7s: add usb hsic phy domain
From: tyler at opensourcefoundries.com @ 2017-12-05 22:27 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205222707.11302-1-tyler@opensourcefoundries.com>
From: Tyler Baker <tyler@opensourcefoundries.com>
The GPCv2 driver should control the MIPI, PCIe,
and USB HSIC PHY regulators. Add the USB HSIC
power domain to the GPC node.
Signed-off-by: Tyler Baker <tyler@opensourcefoundries.com>
---
arch/arm/boot/dts/imx7s.dtsi | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 151ab34..9626a3e 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -602,6 +602,12 @@
reg = <IMX7_POWER_DOMAIN_PCIE_PHY>;
power-supply = <®_1p0d>;
};
+ pgc_usb_hsic_phy: pgc-usb-hsic-phy-domain {
+ #power-domain-cells = <0>;
+
+ reg = <IMX7_POWER_DOMAIN_USB_HSIC_PHY>;
+ power-supply = <®_1p2>;
+ };
};
};
};
--
2.9.3
^ permalink raw reply related
* [PATCH v1 5/6] ARM: dts: imx7d-sbc-iot: enable PCIe peripheral
From: tyler at opensourcefoundries.com @ 2017-12-05 22:27 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205222707.11302-1-tyler@opensourcefoundries.com>
From: Tyler Baker <tyler@opensourcefoundries.com>
Add a PCIe device tree node to enable PCIe support.
Signed-off-by: Tyler Baker <tyler@opensourcefoundries.com>
---
arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts b/arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts
index 67aa4b7..7f45fa2 100644
--- a/arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts
+++ b/arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts
@@ -79,6 +79,12 @@
>;
};
+ pinctrl_pcie: pciegrp {
+ fsl,pins = <
+ MX7D_PAD_EPDC_BDR1__GPIO2_IO29 0x34 /* PCIe RST */
+ >;
+ };
+
pinctrl_uart2: uart2grp {
fsl,pins = <
MX7D_PAD_LCD_ENABLE__UART2_DCE_TX 0x79 /* P7-12 */
@@ -119,6 +125,13 @@
};
};
+&pcie {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_pcie>;
+ reset-gpio = <&gpio2 29 GPIO_ACTIVE_LOW>;
+ status = "okay";
+};
+
&uart2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart2>;
--
2.9.3
^ permalink raw reply related
* [PATCH v1 4/6] ARM: dts: imx7s: add node and supplies for vdd1p2
From: tyler at opensourcefoundries.com @ 2017-12-05 22:27 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205222707.11302-1-tyler@opensourcefoundries.com>
From: Tyler Baker <tyler@opensourcefoundries.com>
Add the regulator nodes and supplies for vdd1p2. This regulator is
used to power the GPC and USB HSIC PHY.
Signed-off-by: Tyler Baker <tyler@opensourcefoundries.com>
---
arch/arm/boot/dts/imx7s.dtsi | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 7b85659..151ab34 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -522,6 +522,20 @@
anatop-max-voltage = <1200000>;
anatop-enable-bit = <0>;
};
+
+ reg_1p2: regulator-vdd1p2 at 220 {
+ compatible = "fsl,anatop-regulator";
+ regulator-name = "vdd1p2";
+ regulator-min-microvolt = <1100000>;
+ regulator-max-microvolt = <1300000>;
+ anatop-reg-offset = <0x220>;
+ anatop-vol-bit-shift = <8>;
+ anatop-vol-bit-width = <5>;
+ anatop-min-bit-val = <8>;
+ anatop-min-voltage = <1100000>;
+ anatop-max-voltage = <1300000>;
+ anatop-enable-bit = <0>;
+ };
};
snvs: snvs at 30370000 {
@@ -578,7 +592,7 @@
#interrupt-cells = <3>;
interrupt-parent = <&intc>;
#power-domain-cells = <1>;
-
+ vcc-supply = <®_1p2>;
pgc {
#address-cells = <1>;
#size-cells = <0>;
@@ -961,6 +975,7 @@
compatible = "usb-nop-xceiv";
clocks = <&clks IMX7D_USB_HSIC_ROOT_CLK>;
clock-names = "main_clk";
+ vcc-supply = <®_1p2>;
};
usdhc1: usdhc at 30b40000 {
--
2.9.3
^ permalink raw reply related
* [PATCH v1 3/6] ARM: dts: imx7s: add dma support
From: tyler at opensourcefoundries.com @ 2017-12-05 22:27 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205222707.11302-1-tyler@opensourcefoundries.com>
From: Tyler Baker <tyler@opensourcefoundries.com>
Enable dma on all SPI interfaces.
Signed-off-by: Tyler Baker <tyler@opensourcefoundries.com>
---
arch/arm/boot/dts/imx7s.dtsi | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 82ad26e..7b85659 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -700,6 +700,8 @@
clocks = <&clks IMX7D_ECSPI1_ROOT_CLK>,
<&clks IMX7D_ECSPI1_ROOT_CLK>;
clock-names = "ipg", "per";
+ dmas = <&sdma 0 7 1>, <&sdma 1 7 2>;
+ dma-names = "rx", "tx";
status = "disabled";
};
@@ -712,6 +714,8 @@
clocks = <&clks IMX7D_ECSPI2_ROOT_CLK>,
<&clks IMX7D_ECSPI2_ROOT_CLK>;
clock-names = "ipg", "per";
+ dmas = <&sdma 2 7 1>, <&sdma 3 7 2>;
+ dma-names = "rx", "tx";
status = "disabled";
};
@@ -724,6 +728,8 @@
clocks = <&clks IMX7D_ECSPI3_ROOT_CLK>,
<&clks IMX7D_ECSPI3_ROOT_CLK>;
clock-names = "ipg", "per";
+ dmas = <&sdma 4 7 1>, <&sdma 5 7 2>;
+ dma-names = "rx", "tx";
status = "disabled";
};
--
2.9.3
^ permalink raw reply related
* [PATCH v1 2/6] ARM: dts: imx7d-cl-som: add nodes for usbh, and usbotg2
From: tyler at opensourcefoundries.com @ 2017-12-05 22:27 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205222707.11302-1-tyler@opensourcefoundries.com>
From: Tyler Baker <tyler@opensourcefoundries.com>
Add device tree nodes for the USB hub, and USB OTG. i2c2 on this
platform supports low state retention power state so lets use it.
Signed-off-by: Tyler Baker <tyler@opensourcefoundries.com>
---
arch/arm/boot/dts/imx7d-cl-som-imx7.dts | 34 ++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/arch/arm/boot/dts/imx7d-cl-som-imx7.dts b/arch/arm/boot/dts/imx7d-cl-som-imx7.dts
index ae45af1..49bd371 100644
--- a/arch/arm/boot/dts/imx7d-cl-som-imx7.dts
+++ b/arch/arm/boot/dts/imx7d-cl-som-imx7.dts
@@ -30,6 +30,16 @@
gpio = <&gpio1 5 GPIO_ACTIVE_HIGH>;
enable-active-high;
};
+
+ reg_usbh_nreset: regulator-vbus {
+ compatible = "regulator-fixed";
+ regulator-name = "usb_host_nreset";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ gpio = <&pca9555 6 GPIO_ACTIVE_HIGH>;
+ enable-active-high;
+ regulator-always-on;
+ };
};
&cpu0 {
@@ -199,6 +209,16 @@
status = "okay";
};
+&usbotg2 {
+ dr_mode = "host";
+ status = "okay";
+};
+
+&usbh {
+ vbus-supply = <®_usbh_nreset>;
+ status = "okay";
+};
+
&usdhc3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc3>;
@@ -247,13 +267,6 @@
>;
};
- pinctrl_i2c2: i2c2grp {
- fsl,pins = <
- MX7D_PAD_I2C2_SDA__I2C2_SDA 0x4000007f
- MX7D_PAD_I2C2_SCL__I2C2_SCL 0x4000007f
- >;
- };
-
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX 0x79
@@ -284,4 +297,11 @@
MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5 0x14 /* OTG PWREN */
>;
};
+
+ pinctrl_i2c2: i2c2grp {
+ fsl,pins = <
+ MX7D_PAD_LPSR_GPIO1_IO07__I2C2_SDA 0x4000000f
+ MX7D_PAD_LPSR_GPIO1_IO06__I2C2_SCL 0x4000000f
+ >;
+ };
};
--
2.9.3
^ permalink raw reply related
* [PATCH v1 1/6] ARM: dts: imx7d-sbc-iot: add initial iot gateway dts
From: tyler at opensourcefoundries.com @ 2017-12-05 22:27 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20171205222707.11302-1-tyler@opensourcefoundries.com>
From: Tyler Baker <tyler@opensourcefoundries.com>
The Compulab IoT Gateway is based on an NXP i.MX7D, dual core
Cortex-A7 clocking at 1GHz. It supports up to 2GB of DDR3,
and 32GB of eMMC flash. Onboard, there are two gigabit
ethernet controllers, 4 x USB2, RS485, and CAN.
This platform is based on the imx7d-cl-som-imx7 module but
includes a baseboard with additional peripherals
which is what this device tree is meant to describe.
This work has been derrived from the Compulab Linux sources
based on v4.1.
Signed-off-by: Tyler Baker <tyler@opensourcefoundries.com>
Signed-off-by: Ilya Ledvich <ilya@compulab.co.il>
---
arch/arm/boot/dts/Makefile | 1 +
arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts | 156 +++++++++++++++++++++++++++++++
2 files changed, 157 insertions(+)
create mode 100644 arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index d0381e9..0334137 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -515,6 +515,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-nitrogen7.dtb \
imx7d-pico.dtb \
imx7d-sbc-imx7.dtb \
+ imx7d-sbc-iot-imx7.dtb \
imx7d-sdb.dtb \
imx7d-sdb-sht11.dtb \
imx7s-colibri-eval-v3.dtb \
diff --git a/arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts b/arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts
new file mode 100644
index 0000000..67aa4b7
--- /dev/null
+++ b/arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts
@@ -0,0 +1,156 @@
+/*
+ * Support for CompuLab SBC-IOT-iMX7 Single Board Computer
+ *
+ * Copyright (C) 2017 CompuLab Ltd. - http://www.compulab.co.il/
+ * Author: Ilya Ledvich <ilya@compulab.co.il>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "imx7d-cl-som-imx7.dts"
+
+/ {
+ model = "CompuLab SBC-IOT-iMX7";
+ compatible = "compulab,sbc-iot-imx7", "compulab,cl-som-imx7", "fsl,imx7d";
+};
+
+&ecspi3 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_ecspi3 &pinctrl_ecspi3_cs>;
+ cs-gpios = <&gpio4 11 0>;
+ status = "okay";
+};
+
+&i2c3 {
+ clock-frequency = <100000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c3>;
+ status = "okay";
+};
+
+&i2c4 {
+ clock-frequency = <100000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c4>;
+ status = "okay";
+
+ eeprom_iot at 54 {
+ compatible = "atmel,24c08";
+ reg = <0x54>;
+ pagesize = <16>;
+ };
+};
+
+&iomuxc {
+ pinctrl_xpen: xpengrp {
+ fsl,pins = <
+ MX7D_PAD_LCD_DATA13__GPIO3_IO18 0x34 /* P7-4 - gpio82 */
+ MX7D_PAD_LCD_DATA12__GPIO3_IO17 0x34 /* P7-5 - gpio81 */
+ >;
+ };
+
+ pinctrl_ecspi3: ecspi3grp {
+ fsl,pins = <
+ MX7D_PAD_I2C1_SDA__ECSPI3_MOSI 0xf /* P7-8 */
+ MX7D_PAD_I2C1_SCL__ECSPI3_MISO 0xf /* P7-7 */
+ MX7D_PAD_I2C2_SCL__ECSPI3_SCLK 0xf /* P7-6 */
+ >;
+ };
+
+ pinctrl_ecspi3_cs: ecspi3_cs_grp {
+ fsl,pins = <
+ MX7D_PAD_I2C2_SDA__GPIO4_IO11 0x34 /* P7-9 */
+ >;
+ };
+
+ pinctrl_i2c3: i2c3grp {
+ fsl,pins = <
+ MX7D_PAD_GPIO1_IO09__I2C3_SDA 0x4000000f /* P7-3 */
+ MX7D_PAD_GPIO1_IO08__I2C3_SCL 0x4000000f /* P7-2 */
+ >;
+ };
+
+ pinctrl_i2c4: i2c4grp {
+ fsl,pins = <
+ MX7D_PAD_GPIO1_IO11__I2C4_SDA 0x4000000f
+ MX7D_PAD_GPIO1_IO10__I2C4_SCL 0x4000000f
+ >;
+ };
+
+ pinctrl_uart2: uart2grp {
+ fsl,pins = <
+ MX7D_PAD_LCD_ENABLE__UART2_DCE_TX 0x79 /* P7-12 */
+ MX7D_PAD_LCD_CLK__UART2_DCE_RX 0x79 /* P7-13 */
+ MX7D_PAD_LCD_VSYNC__UART2_DCE_CTS 0x79 /* P7-11 */
+ MX7D_PAD_LCD_HSYNC__UART2_DCE_RTS 0x79 /* P7-10 */
+ >;
+ };
+
+ pinctrl_uart5: uart5grp {
+ fsl,pins = <
+ MX7D_PAD_I2C4_SDA__UART5_DCE_TX 0x79 /* RS232-TX */
+ MX7D_PAD_I2C4_SCL__UART5_DCE_RX 0x79 /* RS232-RX */
+ MX7D_PAD_I2C3_SDA__UART5_DCE_RTS 0x79 /* RS232-RTS */
+ MX7D_PAD_I2C3_SCL__UART5_DCE_CTS 0x79 /* RS232-CTS */
+ >;
+ };
+
+ pinctrl_uart7: uart7grp {
+ fsl,pins = <
+ MX7D_PAD_ECSPI2_MOSI__UART7_DCE_TX 0x79 /* R485-TX */
+ MX7D_PAD_ECSPI2_SCLK__UART7_DCE_RX 0x79 /* R485-RX */
+ MX7D_PAD_ECSPI2_SS0__UART7_DCE_CTS 0x79 /* R485-CTS */
+ MX7D_PAD_ECSPI2_MISO__UART7_DCE_RTS 0x79 /* R485-TTS */
+ >;
+ };
+
+ pinctrl_usdhc1: usdhc1grp {
+ fsl,pins = <
+ MX7D_PAD_SD1_CMD__SD1_CMD 0x59
+ MX7D_PAD_SD1_CLK__SD1_CLK 0x19
+ MX7D_PAD_SD1_DATA0__SD1_DATA0 0x59
+ MX7D_PAD_SD1_DATA1__SD1_DATA1 0x59
+ MX7D_PAD_SD1_DATA2__SD1_DATA2 0x59
+ MX7D_PAD_SD1_DATA3__SD1_DATA3 0x59
+ MX7D_PAD_SD1_CD_B__GPIO5_IO0 0x59 /* CD */
+ >;
+ };
+};
+
+&uart2 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_uart2>;
+ assigned-clocks = <&clks IMX7D_UART2_ROOT_SRC>;
+ assigned-clock-parents = <&clks IMX7D_OSC_24M_CLK>;
+ uart-has-rtscts;
+ status = "okay";
+};
+
+&uart5 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_uart5>;
+ assigned-clocks = <&clks IMX7D_UART5_ROOT_SRC>;
+ assigned-clock-parents = <&clks IMX7D_PLL_SYS_MAIN_240M_CLK>;
+ uart-has-rtscts;
+ status = "okay";
+};
+
+&uart7 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_uart7>;
+ assigned-clocks = <&clks IMX7D_UART7_ROOT_SRC>;
+ assigned-clock-parents = <&clks IMX7D_PLL_SYS_MAIN_240M_CLK>;
+ uart-has-rtscts;
+ status = "okay";
+};
+
+&usdhc1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_usdhc1>;
+ cd-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
+ wp-gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;
+ enable-sdio-wakeup;
+ status = "okay";
+};
--
2.9.3
^ permalink raw reply related
* [PATCH v1 0/6] ARM: dts: introduce Compulab IoT Gateway
From: tyler at opensourcefoundries.com @ 2017-12-05 22:27 UTC (permalink / raw)
To: linux-arm-kernel
From: Tyler Baker <tyler@opensourcefoundries.com>
The Compulab IoT Gateway is based on an NXP i.MX7D, dual core
Cortex-A7 clocking at 1GHz. It supports up to 2GB of DDR3,
and 32GB of eMMC flash. Onboard, there are two gigabit
ethernet controllers, 4 x USB2, RS485, and CAN.
It uses the same SoM as the cl-som-imx7, but includes a baseboard
with additional I/O.
Compulab has provided patches for this platform based on v4.1.
I've used these patches as reference to get things working on tip.
Changes for v1 (Requested by Fabio)
* Squashed the dts build into the initial patch
* Dropped the phy refclk patch from this series, submitting to PCI list
* Removed fsl,spi-num-chipselects property
* Removed LCD and DVI nodes, will follow up with a later series
* s/fsl,uart-has-rtscts/uart-has-rtscts/g
* Fixed regulator usage inside of simple-bus
The entire series is based on v4.15-rc2.
Tyler Baker (6):
ARM: dts: imx7d-sbc-iot: add initial iot gateway dts
ARM: dts: imx7d-cl-som: add nodes for usbh, and usbotg2
ARM: dts: imx7s: add dma support
ARM: dts: imx7s: add node and supplies for vdd1p2
ARM: dts: imx7d-sbc-iot: enable PCIe peripheral
ARM: dts: imx7s: add usb hsic phy domain
arch/arm/boot/dts/Makefile | 1 +
arch/arm/boot/dts/imx7d-cl-som-imx7.dts | 34 +++++--
arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts | 169 +++++++++++++++++++++++++++++++
arch/arm/boot/dts/imx7s.dtsi | 29 +++++-
4 files changed, 225 insertions(+), 8 deletions(-)
create mode 100644 arch/arm/boot/dts/imx7d-sbc-iot-imx7.dts
--
2.9.3
^ permalink raw reply
* [PATCH] ACPI / GED: unregister interrupts during shutdown
From: Rafael J. Wysocki @ 2017-12-05 22:18 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1512507705-2411-1-git-send-email-okaya@codeaurora.org>
On Tue, Dec 5, 2017 at 10:01 PM, Sinan Kaya <okaya@codeaurora.org> wrote:
> Some GED interrupts could be pending by the time we are doing a reboot.
>
> Even though GED driver uses devm_request_irq() to register the interrupt
> handler, the handler is not being freed on time during a shutdown since
> the driver is missing a shutdown callback.
>
> If the ACPI handler is no longer available, this causes an interrupt
> storm and delays shutdown.
>
> Register a shutdown callback and manually free the interrupts.
>
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
> drivers/acpi/evged.c | 36 +++++++++++++++++++++++++++++++++---
> 1 file changed, 33 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/evged.c b/drivers/acpi/evged.c
> index 46f0603..dde50ea 100644
> --- a/drivers/acpi/evged.c
> +++ b/drivers/acpi/evged.c
> @@ -1,7 +1,7 @@
> /*
> * Generic Event Device for ACPI.
> *
> - * Copyright (c) 2016, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
Why are you changing this?
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License version 2 and
> @@ -49,6 +49,11 @@
>
> #define MODULE_NAME "acpi-ged"
>
> +struct acpi_ged_device {
> + struct device *dev;
> + struct list_head event_list;
> +};
> +
> struct acpi_ged_event {
> struct list_head node;
> struct device *dev;
> @@ -76,7 +81,8 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
> unsigned int irq;
> unsigned int gsi;
> unsigned int irqflags = IRQF_ONESHOT;
> - struct device *dev = context;
> + struct acpi_ged_device *geddev = context;
> + struct device *dev = geddev->dev;
> acpi_handle handle = ACPI_HANDLE(dev);
> acpi_handle evt_handle;
> struct resource r;
> @@ -122,29 +128,53 @@ static acpi_status acpi_ged_request_interrupt(struct acpi_resource *ares,
> return AE_ERROR;
> }
>
> + dev_info(dev, "GED listening GSI %u @ IRQ %u\n", gsi, irq);
Why dev_info()?
> + list_add_tail(&event->node, &geddev->event_list);
> return AE_OK;
> }
>
> static int ged_probe(struct platform_device *pdev)
> {
> + struct acpi_ged_device *geddev;
> acpi_status acpi_ret;
>
> + geddev = devm_kzalloc(&pdev->dev, sizeof(*geddev), GFP_KERNEL);
> + if (!geddev)
> + return -ENOMEM;
> +
> + geddev->dev = &pdev->dev;
> + INIT_LIST_HEAD(&geddev->event_list);
> acpi_ret = acpi_walk_resources(ACPI_HANDLE(&pdev->dev), "_CRS",
> - acpi_ged_request_interrupt, &pdev->dev);
> + acpi_ged_request_interrupt, geddev);
> if (ACPI_FAILURE(acpi_ret)) {
> dev_err(&pdev->dev, "unable to parse the _CRS record\n");
> return -EINVAL;
> }
> + platform_set_drvdata(pdev, geddev);
>
> return 0;
> }
>
> +static void ged_remove(struct platform_device *pdev)
> +{
> + struct acpi_ged_device *geddev = platform_get_drvdata(pdev);
> + struct acpi_ged_event *event, *next;
> +
> + list_for_each_entry_safe(event, next, &geddev->event_list, node) {
> + devm_free_irq(geddev->dev, event->irq, event);
> + list_del(&event->node);
> + dev_info(geddev->dev, "GED releasing GSI %u @ IRQ %u\n",
> + event->gsi, event->irq);
dev_dbg() and that if you really need it.
> + }
> +}
> +
> static const struct acpi_device_id ged_acpi_ids[] = {
> {"ACPI0013"},
> {},
> };
>
> static struct platform_driver ged_driver = {
> + .shutdown = ged_remove,
That ged_remove really should be called ged_shutdown. It is confusing
as is, because there is a ->remove callback in the structure too.
> .probe = ged_probe,
> .driver = {
> .name = MODULE_NAME,
> --
Overall, it looks like we should just unbind the driver from all
devices on shutdown.
Thanks,
Rafael
^ permalink raw reply
* [PATCH 12/12] firmware: arm_scpi: improve info message for pre-1.0 firmware
From: Heiner Kallweit @ 2017-12-05 22:17 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <99220c79-8b35-2978-11d1-6d101ccb6772@gmail.com>
On legacy pre-1.0 firmware versions so far the following message is
printed which may cause some confusion:
SCP Protocol 0.0 Firmware 0.0.0 version
Therefore replace the message with the following if firmware doesn't
provide usable version information:
SCP Protocol legacy pre-1.0 firmware
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/firmware/arm_scpi.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index bc7055a6..6d7a6c0a 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -1005,12 +1005,21 @@ static int scpi_probe(struct platform_device *pdev)
return ret;
}
- dev_info(dev, "SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n",
- FIELD_GET(PROTO_REV_MAJOR_MASK, scpi_info->protocol_version),
- FIELD_GET(PROTO_REV_MINOR_MASK, scpi_info->protocol_version),
- FIELD_GET(FW_REV_MAJOR_MASK, scpi_info->firmware_version),
- FIELD_GET(FW_REV_MINOR_MASK, scpi_info->firmware_version),
- FIELD_GET(FW_REV_PATCH_MASK, scpi_info->firmware_version));
+ if (scpi_info->is_legacy && !scpi_info->protocol_version &&
+ !scpi_info->firmware_version)
+ dev_info(dev, "SCP Protocol legacy pre-1.0 firmware\n");
+ else
+ dev_info(dev, "SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n",
+ FIELD_GET(PROTO_REV_MAJOR_MASK,
+ scpi_info->protocol_version),
+ FIELD_GET(PROTO_REV_MINOR_MASK,
+ scpi_info->protocol_version),
+ FIELD_GET(FW_REV_MAJOR_MASK,
+ scpi_info->firmware_version),
+ FIELD_GET(FW_REV_MINOR_MASK,
+ scpi_info->firmware_version),
+ FIELD_GET(FW_REV_PATCH_MASK,
+ scpi_info->firmware_version));
scpi_info->scpi_ops = &scpi_ops;
ret = devm_device_add_groups(dev, versions_groups);
--
2.15.1
^ permalink raw reply related
* [PATCH 11/12] firmware: arm_scpi: use FIELD_GET/_PREP to simplify macro definitions
From: Heiner Kallweit @ 2017-12-05 22:17 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <99220c79-8b35-2978-11d1-6d101ccb6772@gmail.com>
Macro definitions can be simplified by making use of the FIELD_GET/_PREP
bitfield macros.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/firmware/arm_scpi.c | 38 +++++++++++++++-----------------------
1 file changed, 15 insertions(+), 23 deletions(-)
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 5695b1f4..bc7055a6 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -46,27 +46,19 @@
#include <linux/sort.h>
#include <linux/spinlock.h>
-#define CMD_ID_SHIFT 0
-#define CMD_ID_MASK 0x7f
-#define CMD_TOKEN_ID_SHIFT 8
-#define CMD_TOKEN_ID_MASK 0xff
-#define CMD_DATA_SIZE_SHIFT 16
-#define CMD_DATA_SIZE_MASK 0x1ff
-#define CMD_LEGACY_DATA_SIZE_SHIFT 20
-#define CMD_LEGACY_DATA_SIZE_MASK 0x1ff
-#define PACK_SCPI_CMD(cmd_id, tx_sz) \
- ((((cmd_id) & CMD_ID_MASK) << CMD_ID_SHIFT) | \
- (((tx_sz) & CMD_DATA_SIZE_MASK) << CMD_DATA_SIZE_SHIFT))
-#define ADD_SCPI_TOKEN(cmd, token) \
- ((cmd) |= (((token) & CMD_TOKEN_ID_MASK) << CMD_TOKEN_ID_SHIFT))
-#define PACK_LEGACY_SCPI_CMD(cmd_id, tx_sz) \
- ((((cmd_id) & CMD_ID_MASK) << CMD_ID_SHIFT) | \
- (((tx_sz) & CMD_LEGACY_DATA_SIZE_MASK) << CMD_LEGACY_DATA_SIZE_SHIFT))
-
-#define CMD_SIZE(cmd) (((cmd) >> CMD_DATA_SIZE_SHIFT) & CMD_DATA_SIZE_MASK)
-#define CMD_LEGACY_SIZE(cmd) (((cmd) >> CMD_LEGACY_DATA_SIZE_SHIFT) & \
- CMD_LEGACY_DATA_SIZE_MASK)
-#define CMD_UNIQ_MASK (CMD_TOKEN_ID_MASK << CMD_TOKEN_ID_SHIFT | CMD_ID_MASK)
+#define CMD_ID_MASK GENMASK(6, 0)
+#define CMD_TOKEN_ID_MASK GENMASK(15, 8)
+#define CMD_DATA_SIZE_MASK GENMASK(24, 16)
+#define CMD_LEGACY_DATA_SIZE_MASK GENMASK(28, 20)
+#define PACK_SCPI_CMD(cmd_id, tx_sz) \
+ (FIELD_PREP(CMD_ID_MASK, cmd_id) | \
+ FIELD_PREP(CMD_DATA_SIZE_MASK, tx_sz))
+#define PACK_LEGACY_SCPI_CMD(cmd_id, tx_sz) \
+ (FIELD_PREP(CMD_ID_MASK, cmd_id) | \
+ FIELD_PREP(CMD_LEGACY_DATA_SIZE_MASK, tx_sz))
+
+#define CMD_SIZE(cmd) FIELD_GET(CMD_DATA_SIZE_MASK, cmd)
+#define CMD_UNIQ_MASK (CMD_TOKEN_ID_MASK | CMD_ID_MASK)
#define CMD_XTRACT_UNIQ(cmd) ((cmd) & CMD_UNIQ_MASK)
#define SCPI_SLOT 0
@@ -412,7 +404,7 @@ static void scpi_process_cmd(struct scpi_chan *ch, u32 cmd)
} else {
struct scpi_shared_mem __iomem *mem = ch->rx_payload;
- len = min(match->rx_len, CMD_SIZE(cmd));
+ len = min_t(unsigned int, match->rx_len, CMD_SIZE(cmd));
match->status = ioread32(&mem->status);
memcpy_fromio(match->rx_buf, mem->payload, len);
@@ -454,7 +446,7 @@ static void scpi_tx_prepare(struct mbox_client *c, void *msg)
if (t->rx_buf) {
if (!(++ch->token))
++ch->token;
- ADD_SCPI_TOKEN(t->cmd, ch->token);
+ t->cmd |= FIELD_PREP(CMD_TOKEN_ID_MASK, ch->token);
spin_lock_irqsave(&ch->rx_lock, flags);
list_add_tail(&t->node, &ch->rx_pending);
spin_unlock_irqrestore(&ch->rx_lock, flags);
--
2.15.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox