* [PATCH REPOST 2/7] kbuild: fixdep: support concatenated dep files
2013-03-21 18:23 [PATCH REPOST 1/7] kbuild: create an "include chroot" for DT bindings Stephen Warren
@ 2013-03-21 18:23 ` Stephen Warren
2013-03-28 18:00 ` Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 3/7] kbuild: cmd_dtc_cpp: extract deps from both gcc -E and dtc Stephen Warren
` (4 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Stephen Warren @ 2013-03-21 18:23 UTC (permalink / raw)
To: Michal Marek, Grant Likely, Rob Herring
Cc: arm, Shawn Guo, Hiroshi Doyu, linux-kbuild, devicetree-discuss,
linux-kernel, linux-arm-kernel, Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
The current use-case for fixdep is: a source file is run through a single
processing step, which creates a single dependency file as a side-effect,
which fixdep transforms into the file used by the kernel build process.
In order to transparently run the C pre-processor on device-tree files,
we wish to run both gcc -E and dtc on a source file in a single rule.
This generates two dependency files, which must be transformed together
into the file used by the kernel build process. This change modifies
fixdep so it can process the concatenation of multiple separate input
dependency files, and produce a correct unified output.
The code changes have the slight benefit of transforming the loop in
parse_dep_file() into more of a lexer/tokenizer, with the loop body being
more of a parser. Previously, some of this logic was mixed together
before the loop. I also added some comments, which I hope are useful.
Benchmarking shows that on a cross-compiled ARM tegra_defconfig build,
there is less than 0.5 seconds speed decrease with this change, on top
of a build time of ~2m24s. This is probably within the noise.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
scripts/basic/fixdep.c | 93 +++++++++++++++++++++++++++++++-----------------
1 file changed, 61 insertions(+), 32 deletions(-)
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 7f6425e..078fe1d 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -320,49 +320,78 @@ static void parse_dep_file(void *map, size_t len)
char *end = m + len;
char *p;
char s[PATH_MAX];
- int first;
-
- p = strchr(m, ':');
- if (!p) {
- fprintf(stderr, "fixdep: parse error\n");
- exit(1);
- }
- memcpy(s, m, p-m); s[p-m] = 0;
- m = p+1;
+ int is_target;
+ int saw_any_target = 0;
+ int is_first_dep = 0;
clear_config();
- first = 1;
while (m < end) {
+ /* Skip any "white space" */
while (m < end && (*m == ' ' || *m == '\\' || *m == '\n'))
m++;
+ /* Find next "white space" */
p = m;
- while (p < end && *p != ' ') p++;
- if (p == end) {
- do p--; while (!isalnum(*p));
+ while (p < end && *p != ' ' && *p != '\\' && *p != '\n')
p++;
+ /* Is the token we found a target name? */
+ is_target = (*(p-1) == ':');
+ /* Don't write any target names into the dependency file */
+ if (is_target) {
+ /* The /next/ file is the first dependency */
+ is_first_dep = 1;
+ } else {
+ /* Save this token/filename */
+ memcpy(s, m, p-m);
+ s[p - m] = 0;
+
+ /* Ignore certain dependencies */
+ if (strrcmp(s, "include/generated/autoconf.h") &&
+ strrcmp(s, "arch/um/include/uml-config.h") &&
+ strrcmp(s, "include/linux/kconfig.h") &&
+ strrcmp(s, ".ver")) {
+ /*
+ * Do not list the source file as dependency,
+ * so that kbuild is not confused if a .c file
+ * is rewritten into .S or vice versa. Storing
+ * it in source_* is needed for modpost to
+ * compute srcversions.
+ */
+ if (is_first_dep) {
+ /*
+ * If processing the concatenation of
+ * multiple dependency files, only
+ * process the first target name, which
+ * will be the original source name,
+ * and ignore any other target names,
+ * which will be intermediate temporary
+ * files.
+ */
+ if (!saw_any_target) {
+ saw_any_target = 1;
+ printf("source_%s := %s\n\n",
+ target, s);
+ printf("deps_%s := \\\n",
+ target);
+ }
+ is_first_dep = 0;
+ } else
+ printf(" %s \\\n", s);
+ do_config_file(s);
+ }
}
- memcpy(s, m, p-m); s[p-m] = 0;
- if (strrcmp(s, "include/generated/autoconf.h") &&
- strrcmp(s, "arch/um/include/uml-config.h") &&
- strrcmp(s, "include/linux/kconfig.h") &&
- strrcmp(s, ".ver")) {
- /*
- * Do not list the source file as dependency, so that
- * kbuild is not confused if a .c file is rewritten
- * into .S or vice versa. Storing it in source_* is
- * needed for modpost to compute srcversions.
- */
- if (first) {
- printf("source_%s := %s\n\n", target, s);
- printf("deps_%s := \\\n", target);
- } else
- printf(" %s \\\n", s);
- do_config_file(s);
- }
- first = 0;
+ /*
+ * Start searching for next token immediately after the first
+ * "whitespace" character that follows this token.
+ */
m = p + 1;
}
+
+ if (!saw_any_target) {
+ fprintf(stderr, "fixdep: parse error; no targets found\n");
+ exit(1);
+ }
+
printf("\n%s: $(deps_%s)\n\n", target, target);
printf("$(deps_%s):\n", target);
}
--
1.7.10.4
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH REPOST 2/7] kbuild: fixdep: support concatenated dep files
2013-03-21 18:23 ` [PATCH REPOST 2/7] kbuild: fixdep: support concatenated dep files Stephen Warren
@ 2013-03-28 18:00 ` Stephen Warren
0 siblings, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2013-03-28 18:00 UTC (permalink / raw)
To: Michal Marek, Grant Likely, Rob Herring
Cc: arm, Shawn Guo, Hiroshi Doyu, linux-kbuild, devicetree-discuss,
linux-kernel, linux-arm-kernel, Stephen Warren
On 03/21/2013 12:23 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> The current use-case for fixdep is: a source file is run through a single
> processing step, which creates a single dependency file as a side-effect,
> which fixdep transforms into the file used by the kernel build process.
>
> In order to transparently run the C pre-processor on device-tree files,
> we wish to run both gcc -E and dtc on a source file in a single rule.
> This generates two dependency files, which must be transformed together
> into the file used by the kernel build process. This change modifies
> fixdep so it can process the concatenation of multiple separate input
> dependency files, and produce a correct unified output.
>
> The code changes have the slight benefit of transforming the loop in
> parse_dep_file() into more of a lexer/tokenizer, with the loop body being
> more of a parser. Previously, some of this logic was mixed together
> before the loop. I also added some comments, which I hope are useful.
>
> Benchmarking shows that on a cross-compiled ARM tegra_defconfig build,
> there is less than 0.5 seconds speed decrease with this change, on top
> of a build time of ~2m24s. This is probably within the noise.
Marek, do patches 2, 3, and 4 in this series look good to you from a
kbuild perspective?
I'm hoping that you can review/ack those 3 patches for kbuild, and that
Grant will review/ack the whole series, and then the series can be
merged via arm-soc for 3.10.
Let me know if you need me to repost the series again in case it's
fallen out of your inbox.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH REPOST 3/7] kbuild: cmd_dtc_cpp: extract deps from both gcc -E and dtc
2013-03-21 18:23 [PATCH REPOST 1/7] kbuild: create an "include chroot" for DT bindings Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 2/7] kbuild: fixdep: support concatenated dep files Stephen Warren
@ 2013-03-21 18:23 ` Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 4/7] kbuild: always run gcc -E on *.dts, remove cmd_dtc_cpp Stephen Warren
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2013-03-21 18:23 UTC (permalink / raw)
To: Michal Marek, Grant Likely, Rob Herring
Cc: arm, Shawn Guo, Hiroshi Doyu, linux-kbuild, devicetree-discuss,
linux-kernel, linux-arm-kernel, Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
Prior to this change, when compiling *.dts to *.dtb, the dependency
output from dtc would be used, and when compiling *.dtsp to *.dtb, the
dependency output from gcc -E alone would be used, despite dtc also
being invoked (on a temporary file that was guaranteed to have no
dependencies).
With this change, when compiling *.dtsp to *.dtb, the dependency files
from both gcc -E and dtc are used. This will allow cmd_dtc_cpp to
replace cmd_dtc in a future change. In turn, that will allow the C pre-
processor to be run transparently on *.dts, without the need to a
separate rule or file extension to trigger it.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
scripts/Makefile.lib | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index af35521..6104335 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -156,7 +156,7 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
ld_flags = $(LDFLAGS) $(ldflags-y)
-dtc_cpp_flags = -Wp,-MD,$(depfile) -nostdinc \
+dtc_cpp_flags = -Wp,-MD,$(depfile).pre -nostdinc \
-I$(srctree)/arch/$(SRCARCH)/boot/dts \
-I$(srctree)/arch/$(SRCARCH)/boot/dts/include \
-undef -D__DTS__
@@ -278,7 +278,8 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts)
quiet_cmd_dtc_cpp = DTC+CPP $@
cmd_dtc_cpp = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
- $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $(dtc-tmp)
+ $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile).dtc $(dtc-tmp) ; \
+ cat $(depfile).pre $(depfile).dtc > $(depfile)
$(obj)/%.dtb: $(src)/%.dtsp FORCE
$(call if_changed_dep,dtc_cpp)
--
1.7.10.4
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH REPOST 4/7] kbuild: always run gcc -E on *.dts, remove cmd_dtc_cpp
2013-03-21 18:23 [PATCH REPOST 1/7] kbuild: create an "include chroot" for DT bindings Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 2/7] kbuild: fixdep: support concatenated dep files Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 3/7] kbuild: cmd_dtc_cpp: extract deps from both gcc -E and dtc Stephen Warren
@ 2013-03-21 18:23 ` Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 5/7] ARM: dt: add header to define GPIO flags Stephen Warren
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2013-03-21 18:23 UTC (permalink / raw)
To: Michal Marek, Grant Likely, Rob Herring
Cc: arm, Shawn Guo, Hiroshi Doyu, linux-kbuild, devicetree-discuss,
linux-kernel, linux-arm-kernel, Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
Replace cmd_dtc with cmd_dtc_cpp, and delete the latter.
Previously, a special file extension (.dtsp) was required to trigger
the C pre-processor to run on device tree files. This was ugly. Now that
previous changes have enhanced cmd_dtc_cpp to collect dependency
information from both gcc -E and dtc, we can transparently run the pre-
processor on all device tree files, irrespective of whether they
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
scripts/Makefile.lib | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 6104335..ee5cfc4 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -269,21 +269,15 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
$(call cmd,dt_S_dtb)
quiet_cmd_dtc = DTC $@
-cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $<
+cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
+ $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile).dtc $(dtc-tmp) ; \
+ cat $(depfile).pre $(depfile).dtc > $(depfile)
$(obj)/%.dtb: $(src)/%.dts FORCE
$(call if_changed_dep,dtc)
dtc-tmp = $(subst $(comma),_,$(dot-target).dts)
-quiet_cmd_dtc_cpp = DTC+CPP $@
-cmd_dtc_cpp = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
- $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile).dtc $(dtc-tmp) ; \
- cat $(depfile).pre $(depfile).dtc > $(depfile)
-
-$(obj)/%.dtb: $(src)/%.dtsp FORCE
- $(call if_changed_dep,dtc_cpp)
-
# Bzip2
# ---------------------------------------------------------------------------
--
1.7.10.4
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH REPOST 5/7] ARM: dt: add header to define GPIO flags
2013-03-21 18:23 [PATCH REPOST 1/7] kbuild: create an "include chroot" for DT bindings Stephen Warren
` (2 preceding siblings ...)
2013-03-21 18:23 ` [PATCH REPOST 4/7] kbuild: always run gcc -E on *.dts, remove cmd_dtc_cpp Stephen Warren
@ 2013-03-21 18:23 ` Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 6/7] ARM: dt: add header to define IRQ flags Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 7/7] ARM: dt: create a DT header for the GIC Stephen Warren
5 siblings, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2013-03-21 18:23 UTC (permalink / raw)
To: Michal Marek, Grant Likely, Rob Herring
Cc: arm, Shawn Guo, Hiroshi Doyu, linux-kbuild, devicetree-discuss,
linux-kernel, linux-arm-kernel, Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
Many GPIO device tree bindings use the same flags. Create a header to
define those.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: Moved header. Added include guard.
---
include/dt-bindings/gpio/gpio.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 include/dt-bindings/gpio/gpio.h
diff --git a/include/dt-bindings/gpio/gpio.h b/include/dt-bindings/gpio/gpio.h
new file mode 100644
index 0000000..e6b1e0a
--- /dev/null
+++ b/include/dt-bindings/gpio/gpio.h
@@ -0,0 +1,15 @@
+/*
+ * This header provides constants for most GPIO bindings.
+ *
+ * Most GPIO bindings include a flags cell as part of the GPIO specifier.
+ * In most cases, the format of the flags cell uses the standard values
+ * defined in this header.
+ */
+
+#ifndef _DT_BINDINGS_GPIO_GPIO_H
+#define _DT_BINDINGS_GPIO_GPIO_H
+
+#define GPIO_ACTIVE_HIGH 0
+#define GPIO_ACTIVE_LOW 1
+
+#endif
--
1.7.10.4
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH REPOST 6/7] ARM: dt: add header to define IRQ flags
2013-03-21 18:23 [PATCH REPOST 1/7] kbuild: create an "include chroot" for DT bindings Stephen Warren
` (3 preceding siblings ...)
2013-03-21 18:23 ` [PATCH REPOST 5/7] ARM: dt: add header to define GPIO flags Stephen Warren
@ 2013-03-21 18:23 ` Stephen Warren
2013-03-21 18:23 ` [PATCH REPOST 7/7] ARM: dt: create a DT header for the GIC Stephen Warren
5 siblings, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2013-03-21 18:23 UTC (permalink / raw)
To: Michal Marek, Grant Likely, Rob Herring
Cc: arm, Shawn Guo, Hiroshi Doyu, linux-kbuild, devicetree-discuss,
linux-kernel, linux-arm-kernel, Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
Many IRQ device tree bindings use the same flags. Create a header to
define those.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: Moved header. Added include guard.
---
include/dt-bindings/interrupt-controller/irq.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 include/dt-bindings/interrupt-controller/irq.h
diff --git a/include/dt-bindings/interrupt-controller/irq.h b/include/dt-bindings/interrupt-controller/irq.h
new file mode 100644
index 0000000..33a1003
--- /dev/null
+++ b/include/dt-bindings/interrupt-controller/irq.h
@@ -0,0 +1,19 @@
+/*
+ * This header provides constants for most IRQ bindings.
+ *
+ * Most IRQ bindings include a flags cell as part of the IRQ specifier.
+ * In most cases, the format of the flags cell uses the standard values
+ * defined in this header.
+ */
+
+#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_IRQ_H
+#define _DT_BINDINGS_INTERRUPT_CONTROLLER_IRQ_H
+
+#define IRQ_TYPE_NONE 0
+#define IRQ_TYPE_EDGE_RISING 1
+#define IRQ_TYPE_EDGE_FALLING 2
+#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
+#define IRQ_TYPE_LEVEL_HIGH 4
+#define IRQ_TYPE_LEVEL_LOW 8
+
+#endif
--
1.7.10.4
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH REPOST 7/7] ARM: dt: create a DT header for the GIC
2013-03-21 18:23 [PATCH REPOST 1/7] kbuild: create an "include chroot" for DT bindings Stephen Warren
` (4 preceding siblings ...)
2013-03-21 18:23 ` [PATCH REPOST 6/7] ARM: dt: add header to define IRQ flags Stephen Warren
@ 2013-03-21 18:23 ` Stephen Warren
5 siblings, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2013-03-21 18:23 UTC (permalink / raw)
To: Michal Marek, Grant Likely, Rob Herring
Cc: arm, Shawn Guo, Hiroshi Doyu, linux-kbuild, devicetree-discuss,
linux-kernel, linux-arm-kernel, Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
The ARM GIC binding defines a few custom cells and flags for its IRQ
specifier. Provide names for those.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: Moved header. Added include guard.
---
include/dt-bindings/interrupt-controller/arm-gic.h | 22 ++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 include/dt-bindings/interrupt-controller/arm-gic.h
diff --git a/include/dt-bindings/interrupt-controller/arm-gic.h b/include/dt-bindings/interrupt-controller/arm-gic.h
new file mode 100644
index 0000000..1ea1b70
--- /dev/null
+++ b/include/dt-bindings/interrupt-controller/arm-gic.h
@@ -0,0 +1,22 @@
+/*
+ * This header provides constants for the ARM GIC.
+ */
+
+#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_ARM_GIC_H
+#define _DT_BINDINGS_INTERRUPT_CONTROLLER_ARM_GIC_H
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/* interrupt specific cell 0 */
+
+#define GIC_SPI 0
+#define GIC_PPI 1
+
+/*
+ * Interrupt specifier cell 2.
+ * The flaggs in irq.h are valid, plus those below.
+ */
+#define GIC_CPU_MASK_RAW(x) ((x) << 8)
+#define GIC_CPU_MASK_SIMPLE(num) GIC_CPU_MASK_RAW((1 << (num)) - 1)
+
+#endif
--
1.7.10.4
^ permalink raw reply [flat|nested] 8+ messages in thread