mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-30 10:39:04 +00:00
kernel: remove linux 4.1 support
The only target still referencing it is omap24xx, and it is marked as broken. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
b1dbe6028e
commit
b7bee2858b
@ -3,11 +3,9 @@
|
||||
LINUX_RELEASE?=1
|
||||
|
||||
LINUX_VERSION-3.18 = .43
|
||||
LINUX_VERSION-4.1 = .34
|
||||
LINUX_VERSION-4.4 = .40
|
||||
|
||||
LINUX_KERNEL_HASH-3.18.43 = 1236e8123a6ce537d5029232560966feed054ae31776fe8481dd7d18cdd5492c
|
||||
LINUX_KERNEL_HASH-4.1.34 = 412316b32b5c7a513ba3ab8e68fc443db4d9423f07b577473089def0ee7406af
|
||||
LINUX_KERNEL_HASH-4.4.40 = c4bc5ed6e73ed7393cc1b3714b822664224ab866db114eed663de1315718a4e1
|
||||
|
||||
ifdef KERNEL_PATCHVER
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,54 +0,0 @@
|
||||
From: Aaro Koskinen <aaro.koskinen@nokia.com>
|
||||
Date: Wed, 1 Jul 2015 14:54:42 +0300
|
||||
Subject: [PATCH] perf tools: Create config.detected into OUTPUT directory
|
||||
|
||||
Create config.detected into OUTPUT directory instead of source
|
||||
directory.
|
||||
|
||||
This fixes parallel builds that share the same source directory.
|
||||
|
||||
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
|
||||
Acked-by: Jiri Olsa <jolsa@kernel.org>
|
||||
Cc: Paul Mackerras <paulus@samba.org>
|
||||
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
||||
Link: http://lkml.kernel.org/r/1435751683-18500-1-git-send-email-aaro.koskinen@nokia.com
|
||||
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
|
||||
---
|
||||
|
||||
--- a/tools/build/Makefile.build
|
||||
+++ b/tools/build/Makefile.build
|
||||
@@ -25,7 +25,7 @@ build-dir := $(srctree)/tools/build
|
||||
include $(build-dir)/Build.include
|
||||
|
||||
# do not force detected configuration
|
||||
--include .config-detected
|
||||
+-include $(OUTPUT).config-detected
|
||||
|
||||
# Init all relevant variables used in build files so
|
||||
# 1) they have correct type
|
||||
--- a/tools/perf/Makefile.perf
|
||||
+++ b/tools/perf/Makefile.perf
|
||||
@@ -528,7 +528,7 @@ config-clean:
|
||||
clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean
|
||||
$(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
|
||||
$(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
|
||||
- $(Q)$(RM) .config-detected
|
||||
+ $(Q)$(RM) $(OUTPUT).config-detected
|
||||
$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32
|
||||
$(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex*
|
||||
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
|
||||
--- a/tools/perf/config/Makefile
|
||||
+++ b/tools/perf/config/Makefile
|
||||
@@ -11,9 +11,9 @@ ifneq ($(obj-perf),)
|
||||
obj-perf := $(abspath $(obj-perf))/
|
||||
endif
|
||||
|
||||
-$(shell echo -n > .config-detected)
|
||||
-detected = $(shell echo "$(1)=y" >> .config-detected)
|
||||
-detected_var = $(shell echo "$(1)=$($(1))" >> .config-detected)
|
||||
+$(shell echo -n > $(OUTPUT).config-detected)
|
||||
+detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
|
||||
+detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
|
||||
|
||||
CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
|
||||
|
@ -1,27 +0,0 @@
|
||||
From: Sergei Trofimovich <siarheit@google.com>
|
||||
Date: Sun, 19 Jul 2015 10:30:05 +0100
|
||||
Subject: [PATCH] perf tools: Fix makefile generation under dash
|
||||
|
||||
Under dash 'echo -n' yields '-n' to stdout. Use printf "" instead.
|
||||
|
||||
Signed-off-by: Sergei Trofimovich <siarheit@google.com>
|
||||
Acked-by: Ingo Molnar <mingo@kernel.org>
|
||||
Acked-by: Jiri Olsa <jolsa@kernel.org>
|
||||
Cc: Adrian Hunter <adrian.hunter@intel.com>
|
||||
Cc: Namhyung Kim <namhyung@kernel.org>
|
||||
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
||||
Link: http://lkml.kernel.org/r/1437298205-29305-1-git-send-email-siarheit@google.com
|
||||
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
|
||||
---
|
||||
|
||||
--- a/tools/perf/config/Makefile
|
||||
+++ b/tools/perf/config/Makefile
|
||||
@@ -11,7 +11,7 @@ ifneq ($(obj-perf),)
|
||||
obj-perf := $(abspath $(obj-perf))/
|
||||
endif
|
||||
|
||||
-$(shell echo -n > $(OUTPUT).config-detected)
|
||||
+$(shell printf "" > $(OUTPUT).config-detected)
|
||||
detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
|
||||
detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
|
||||
|
@ -1,686 +0,0 @@
|
||||
--- a/arch/mips/bcm47xx/Kconfig
|
||||
+++ b/arch/mips/bcm47xx/Kconfig
|
||||
@@ -4,6 +4,7 @@ config BCM47XX_SSB
|
||||
bool "SSB Support for Broadcom BCM47XX"
|
||||
select SYS_HAS_CPU_BMIPS32_3300
|
||||
select SSB
|
||||
+ select SSB_HOST_SOC
|
||||
select SSB_DRIVER_MIPS
|
||||
select SSB_DRIVER_EXTIF
|
||||
select SSB_EMBEDDED
|
||||
--- a/drivers/ssb/Kconfig
|
||||
+++ b/drivers/ssb/Kconfig
|
||||
@@ -80,6 +80,15 @@ config SSB_SDIOHOST
|
||||
|
||||
If unsure, say N
|
||||
|
||||
+config SSB_HOST_SOC
|
||||
+ bool "Support for SSB bus on SoC"
|
||||
+ depends on SSB
|
||||
+ help
|
||||
+ Host interface for a SSB directly mapped into memory. This is
|
||||
+ for some Broadcom SoCs from the BCM47xx and BCM53xx lines.
|
||||
+
|
||||
+ If unsure, say N
|
||||
+
|
||||
config SSB_SILENT
|
||||
bool "No SSB kernel messages"
|
||||
depends on SSB && EXPERT
|
||||
--- a/drivers/ssb/Makefile
|
||||
+++ b/drivers/ssb/Makefile
|
||||
@@ -5,8 +5,9 @@ ssb-$(CONFIG_SSB_SPROM) += sprom.o
|
||||
|
||||
# host support
|
||||
ssb-$(CONFIG_SSB_PCIHOST) += pci.o pcihost_wrapper.o
|
||||
-ssb-$(CONFIG_SSB_PCMCIAHOST) += pcmcia.o
|
||||
+ssb-$(CONFIG_SSB_PCMCIAHOST) += pcmcia.o bridge_pcmcia_80211.o
|
||||
ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o
|
||||
+ssb-$(CONFIG_SSB_HOST_SOC) += host_soc.o
|
||||
|
||||
# built-in drivers
|
||||
ssb-y += driver_chipcommon.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/ssb/bridge_pcmcia_80211.c
|
||||
@@ -0,0 +1,128 @@
|
||||
+/*
|
||||
+ * Broadcom 43xx PCMCIA-SSB bridge module
|
||||
+ *
|
||||
+ * Copyright (c) 2007 Michael Buesch <m@bues.ch>
|
||||
+ *
|
||||
+ * Licensed under the GNU/GPL. See COPYING for details.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/ssb/ssb.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+#include <pcmcia/cistpl.h>
|
||||
+#include <pcmcia/ciscode.h>
|
||||
+#include <pcmcia/ds.h>
|
||||
+#include <pcmcia/cisreg.h>
|
||||
+
|
||||
+#include "ssb_private.h"
|
||||
+
|
||||
+static const struct pcmcia_device_id ssb_host_pcmcia_tbl[] = {
|
||||
+ PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448),
|
||||
+ PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x476),
|
||||
+ PCMCIA_DEVICE_NULL,
|
||||
+};
|
||||
+
|
||||
+MODULE_DEVICE_TABLE(pcmcia, ssb_host_pcmcia_tbl);
|
||||
+
|
||||
+static int ssb_host_pcmcia_probe(struct pcmcia_device *dev)
|
||||
+{
|
||||
+ struct ssb_bus *ssb;
|
||||
+ int err = -ENOMEM;
|
||||
+ int res = 0;
|
||||
+
|
||||
+ ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
|
||||
+ if (!ssb)
|
||||
+ goto out_error;
|
||||
+
|
||||
+ err = -ENODEV;
|
||||
+
|
||||
+ dev->config_flags |= CONF_ENABLE_IRQ;
|
||||
+
|
||||
+ dev->resource[2]->flags |= WIN_ENABLE | WIN_DATA_WIDTH_16 |
|
||||
+ WIN_USE_WAIT;
|
||||
+ dev->resource[2]->start = 0;
|
||||
+ dev->resource[2]->end = SSB_CORE_SIZE;
|
||||
+ res = pcmcia_request_window(dev, dev->resource[2], 250);
|
||||
+ if (res != 0)
|
||||
+ goto err_kfree_ssb;
|
||||
+
|
||||
+ res = pcmcia_map_mem_page(dev, dev->resource[2], 0);
|
||||
+ if (res != 0)
|
||||
+ goto err_disable;
|
||||
+
|
||||
+ if (!dev->irq)
|
||||
+ goto err_disable;
|
||||
+
|
||||
+ res = pcmcia_enable_device(dev);
|
||||
+ if (res != 0)
|
||||
+ goto err_disable;
|
||||
+
|
||||
+ err = ssb_bus_pcmciabus_register(ssb, dev, dev->resource[2]->start);
|
||||
+ if (err)
|
||||
+ goto err_disable;
|
||||
+ dev->priv = ssb;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_disable:
|
||||
+ pcmcia_disable_device(dev);
|
||||
+err_kfree_ssb:
|
||||
+ kfree(ssb);
|
||||
+out_error:
|
||||
+ ssb_err("Initialization failed (%d, %d)\n", res, err);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static void ssb_host_pcmcia_remove(struct pcmcia_device *dev)
|
||||
+{
|
||||
+ struct ssb_bus *ssb = dev->priv;
|
||||
+
|
||||
+ ssb_bus_unregister(ssb);
|
||||
+ pcmcia_disable_device(dev);
|
||||
+ kfree(ssb);
|
||||
+ dev->priv = NULL;
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_PM
|
||||
+static int ssb_host_pcmcia_suspend(struct pcmcia_device *dev)
|
||||
+{
|
||||
+ struct ssb_bus *ssb = dev->priv;
|
||||
+
|
||||
+ return ssb_bus_suspend(ssb);
|
||||
+}
|
||||
+
|
||||
+static int ssb_host_pcmcia_resume(struct pcmcia_device *dev)
|
||||
+{
|
||||
+ struct ssb_bus *ssb = dev->priv;
|
||||
+
|
||||
+ return ssb_bus_resume(ssb);
|
||||
+}
|
||||
+#else /* CONFIG_PM */
|
||||
+# define ssb_host_pcmcia_suspend NULL
|
||||
+# define ssb_host_pcmcia_resume NULL
|
||||
+#endif /* CONFIG_PM */
|
||||
+
|
||||
+static struct pcmcia_driver ssb_host_pcmcia_driver = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .name = "ssb-pcmcia",
|
||||
+ .id_table = ssb_host_pcmcia_tbl,
|
||||
+ .probe = ssb_host_pcmcia_probe,
|
||||
+ .remove = ssb_host_pcmcia_remove,
|
||||
+ .suspend = ssb_host_pcmcia_suspend,
|
||||
+ .resume = ssb_host_pcmcia_resume,
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ * These are not module init/exit functions!
|
||||
+ * The module_pcmcia_driver() helper cannot be used here.
|
||||
+ */
|
||||
+int ssb_host_pcmcia_init(void)
|
||||
+{
|
||||
+ return pcmcia_register_driver(&ssb_host_pcmcia_driver);
|
||||
+}
|
||||
+
|
||||
+void ssb_host_pcmcia_exit(void)
|
||||
+{
|
||||
+ pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
|
||||
+}
|
||||
--- /dev/null
|
||||
+++ b/drivers/ssb/host_soc.c
|
||||
@@ -0,0 +1,173 @@
|
||||
+/*
|
||||
+ * Sonics Silicon Backplane SoC host related functions.
|
||||
+ * Subsystem core
|
||||
+ *
|
||||
+ * Copyright 2005, Broadcom Corporation
|
||||
+ * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
|
||||
+ *
|
||||
+ * Licensed under the GNU/GPL. See COPYING for details.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/ssb/ssb.h>
|
||||
+
|
||||
+#include "ssb_private.h"
|
||||
+
|
||||
+static u8 ssb_host_soc_read8(struct ssb_device *dev, u16 offset)
|
||||
+{
|
||||
+ struct ssb_bus *bus = dev->bus;
|
||||
+
|
||||
+ offset += dev->core_index * SSB_CORE_SIZE;
|
||||
+ return readb(bus->mmio + offset);
|
||||
+}
|
||||
+
|
||||
+static u16 ssb_host_soc_read16(struct ssb_device *dev, u16 offset)
|
||||
+{
|
||||
+ struct ssb_bus *bus = dev->bus;
|
||||
+
|
||||
+ offset += dev->core_index * SSB_CORE_SIZE;
|
||||
+ return readw(bus->mmio + offset);
|
||||
+}
|
||||
+
|
||||
+static u32 ssb_host_soc_read32(struct ssb_device *dev, u16 offset)
|
||||
+{
|
||||
+ struct ssb_bus *bus = dev->bus;
|
||||
+
|
||||
+ offset += dev->core_index * SSB_CORE_SIZE;
|
||||
+ return readl(bus->mmio + offset);
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_SSB_BLOCKIO
|
||||
+static void ssb_host_soc_block_read(struct ssb_device *dev, void *buffer,
|
||||
+ size_t count, u16 offset, u8 reg_width)
|
||||
+{
|
||||
+ struct ssb_bus *bus = dev->bus;
|
||||
+ void __iomem *addr;
|
||||
+
|
||||
+ offset += dev->core_index * SSB_CORE_SIZE;
|
||||
+ addr = bus->mmio + offset;
|
||||
+
|
||||
+ switch (reg_width) {
|
||||
+ case sizeof(u8): {
|
||||
+ u8 *buf = buffer;
|
||||
+
|
||||
+ while (count) {
|
||||
+ *buf = __raw_readb(addr);
|
||||
+ buf++;
|
||||
+ count--;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ case sizeof(u16): {
|
||||
+ __le16 *buf = buffer;
|
||||
+
|
||||
+ SSB_WARN_ON(count & 1);
|
||||
+ while (count) {
|
||||
+ *buf = (__force __le16)__raw_readw(addr);
|
||||
+ buf++;
|
||||
+ count -= 2;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ case sizeof(u32): {
|
||||
+ __le32 *buf = buffer;
|
||||
+
|
||||
+ SSB_WARN_ON(count & 3);
|
||||
+ while (count) {
|
||||
+ *buf = (__force __le32)__raw_readl(addr);
|
||||
+ buf++;
|
||||
+ count -= 4;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ default:
|
||||
+ SSB_WARN_ON(1);
|
||||
+ }
|
||||
+}
|
||||
+#endif /* CONFIG_SSB_BLOCKIO */
|
||||
+
|
||||
+static void ssb_host_soc_write8(struct ssb_device *dev, u16 offset, u8 value)
|
||||
+{
|
||||
+ struct ssb_bus *bus = dev->bus;
|
||||
+
|
||||
+ offset += dev->core_index * SSB_CORE_SIZE;
|
||||
+ writeb(value, bus->mmio + offset);
|
||||
+}
|
||||
+
|
||||
+static void ssb_host_soc_write16(struct ssb_device *dev, u16 offset, u16 value)
|
||||
+{
|
||||
+ struct ssb_bus *bus = dev->bus;
|
||||
+
|
||||
+ offset += dev->core_index * SSB_CORE_SIZE;
|
||||
+ writew(value, bus->mmio + offset);
|
||||
+}
|
||||
+
|
||||
+static void ssb_host_soc_write32(struct ssb_device *dev, u16 offset, u32 value)
|
||||
+{
|
||||
+ struct ssb_bus *bus = dev->bus;
|
||||
+
|
||||
+ offset += dev->core_index * SSB_CORE_SIZE;
|
||||
+ writel(value, bus->mmio + offset);
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_SSB_BLOCKIO
|
||||
+static void ssb_host_soc_block_write(struct ssb_device *dev, const void *buffer,
|
||||
+ size_t count, u16 offset, u8 reg_width)
|
||||
+{
|
||||
+ struct ssb_bus *bus = dev->bus;
|
||||
+ void __iomem *addr;
|
||||
+
|
||||
+ offset += dev->core_index * SSB_CORE_SIZE;
|
||||
+ addr = bus->mmio + offset;
|
||||
+
|
||||
+ switch (reg_width) {
|
||||
+ case sizeof(u8): {
|
||||
+ const u8 *buf = buffer;
|
||||
+
|
||||
+ while (count) {
|
||||
+ __raw_writeb(*buf, addr);
|
||||
+ buf++;
|
||||
+ count--;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ case sizeof(u16): {
|
||||
+ const __le16 *buf = buffer;
|
||||
+
|
||||
+ SSB_WARN_ON(count & 1);
|
||||
+ while (count) {
|
||||
+ __raw_writew((__force u16)(*buf), addr);
|
||||
+ buf++;
|
||||
+ count -= 2;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ case sizeof(u32): {
|
||||
+ const __le32 *buf = buffer;
|
||||
+
|
||||
+ SSB_WARN_ON(count & 3);
|
||||
+ while (count) {
|
||||
+ __raw_writel((__force u32)(*buf), addr);
|
||||
+ buf++;
|
||||
+ count -= 4;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ default:
|
||||
+ SSB_WARN_ON(1);
|
||||
+ }
|
||||
+}
|
||||
+#endif /* CONFIG_SSB_BLOCKIO */
|
||||
+
|
||||
+/* Ops for the plain SSB bus without a host-device (no PCI or PCMCIA). */
|
||||
+const struct ssb_bus_ops ssb_host_soc_ops = {
|
||||
+ .read8 = ssb_host_soc_read8,
|
||||
+ .read16 = ssb_host_soc_read16,
|
||||
+ .read32 = ssb_host_soc_read32,
|
||||
+ .write8 = ssb_host_soc_write8,
|
||||
+ .write16 = ssb_host_soc_write16,
|
||||
+ .write32 = ssb_host_soc_write32,
|
||||
+#ifdef CONFIG_SSB_BLOCKIO
|
||||
+ .block_read = ssb_host_soc_block_read,
|
||||
+ .block_write = ssb_host_soc_block_write,
|
||||
+#endif
|
||||
+};
|
||||
--- a/drivers/ssb/main.c
|
||||
+++ b/drivers/ssb/main.c
|
||||
@@ -596,166 +596,6 @@ error:
|
||||
return err;
|
||||
}
|
||||
|
||||
-static u8 ssb_ssb_read8(struct ssb_device *dev, u16 offset)
|
||||
-{
|
||||
- struct ssb_bus *bus = dev->bus;
|
||||
-
|
||||
- offset += dev->core_index * SSB_CORE_SIZE;
|
||||
- return readb(bus->mmio + offset);
|
||||
-}
|
||||
-
|
||||
-static u16 ssb_ssb_read16(struct ssb_device *dev, u16 offset)
|
||||
-{
|
||||
- struct ssb_bus *bus = dev->bus;
|
||||
-
|
||||
- offset += dev->core_index * SSB_CORE_SIZE;
|
||||
- return readw(bus->mmio + offset);
|
||||
-}
|
||||
-
|
||||
-static u32 ssb_ssb_read32(struct ssb_device *dev, u16 offset)
|
||||
-{
|
||||
- struct ssb_bus *bus = dev->bus;
|
||||
-
|
||||
- offset += dev->core_index * SSB_CORE_SIZE;
|
||||
- return readl(bus->mmio + offset);
|
||||
-}
|
||||
-
|
||||
-#ifdef CONFIG_SSB_BLOCKIO
|
||||
-static void ssb_ssb_block_read(struct ssb_device *dev, void *buffer,
|
||||
- size_t count, u16 offset, u8 reg_width)
|
||||
-{
|
||||
- struct ssb_bus *bus = dev->bus;
|
||||
- void __iomem *addr;
|
||||
-
|
||||
- offset += dev->core_index * SSB_CORE_SIZE;
|
||||
- addr = bus->mmio + offset;
|
||||
-
|
||||
- switch (reg_width) {
|
||||
- case sizeof(u8): {
|
||||
- u8 *buf = buffer;
|
||||
-
|
||||
- while (count) {
|
||||
- *buf = __raw_readb(addr);
|
||||
- buf++;
|
||||
- count--;
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
- case sizeof(u16): {
|
||||
- __le16 *buf = buffer;
|
||||
-
|
||||
- SSB_WARN_ON(count & 1);
|
||||
- while (count) {
|
||||
- *buf = (__force __le16)__raw_readw(addr);
|
||||
- buf++;
|
||||
- count -= 2;
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
- case sizeof(u32): {
|
||||
- __le32 *buf = buffer;
|
||||
-
|
||||
- SSB_WARN_ON(count & 3);
|
||||
- while (count) {
|
||||
- *buf = (__force __le32)__raw_readl(addr);
|
||||
- buf++;
|
||||
- count -= 4;
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
- default:
|
||||
- SSB_WARN_ON(1);
|
||||
- }
|
||||
-}
|
||||
-#endif /* CONFIG_SSB_BLOCKIO */
|
||||
-
|
||||
-static void ssb_ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
|
||||
-{
|
||||
- struct ssb_bus *bus = dev->bus;
|
||||
-
|
||||
- offset += dev->core_index * SSB_CORE_SIZE;
|
||||
- writeb(value, bus->mmio + offset);
|
||||
-}
|
||||
-
|
||||
-static void ssb_ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
|
||||
-{
|
||||
- struct ssb_bus *bus = dev->bus;
|
||||
-
|
||||
- offset += dev->core_index * SSB_CORE_SIZE;
|
||||
- writew(value, bus->mmio + offset);
|
||||
-}
|
||||
-
|
||||
-static void ssb_ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
|
||||
-{
|
||||
- struct ssb_bus *bus = dev->bus;
|
||||
-
|
||||
- offset += dev->core_index * SSB_CORE_SIZE;
|
||||
- writel(value, bus->mmio + offset);
|
||||
-}
|
||||
-
|
||||
-#ifdef CONFIG_SSB_BLOCKIO
|
||||
-static void ssb_ssb_block_write(struct ssb_device *dev, const void *buffer,
|
||||
- size_t count, u16 offset, u8 reg_width)
|
||||
-{
|
||||
- struct ssb_bus *bus = dev->bus;
|
||||
- void __iomem *addr;
|
||||
-
|
||||
- offset += dev->core_index * SSB_CORE_SIZE;
|
||||
- addr = bus->mmio + offset;
|
||||
-
|
||||
- switch (reg_width) {
|
||||
- case sizeof(u8): {
|
||||
- const u8 *buf = buffer;
|
||||
-
|
||||
- while (count) {
|
||||
- __raw_writeb(*buf, addr);
|
||||
- buf++;
|
||||
- count--;
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
- case sizeof(u16): {
|
||||
- const __le16 *buf = buffer;
|
||||
-
|
||||
- SSB_WARN_ON(count & 1);
|
||||
- while (count) {
|
||||
- __raw_writew((__force u16)(*buf), addr);
|
||||
- buf++;
|
||||
- count -= 2;
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
- case sizeof(u32): {
|
||||
- const __le32 *buf = buffer;
|
||||
-
|
||||
- SSB_WARN_ON(count & 3);
|
||||
- while (count) {
|
||||
- __raw_writel((__force u32)(*buf), addr);
|
||||
- buf++;
|
||||
- count -= 4;
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
- default:
|
||||
- SSB_WARN_ON(1);
|
||||
- }
|
||||
-}
|
||||
-#endif /* CONFIG_SSB_BLOCKIO */
|
||||
-
|
||||
-/* Ops for the plain SSB bus without a host-device (no PCI or PCMCIA). */
|
||||
-static const struct ssb_bus_ops ssb_ssb_ops = {
|
||||
- .read8 = ssb_ssb_read8,
|
||||
- .read16 = ssb_ssb_read16,
|
||||
- .read32 = ssb_ssb_read32,
|
||||
- .write8 = ssb_ssb_write8,
|
||||
- .write16 = ssb_ssb_write16,
|
||||
- .write32 = ssb_ssb_write32,
|
||||
-#ifdef CONFIG_SSB_BLOCKIO
|
||||
- .block_read = ssb_ssb_block_read,
|
||||
- .block_write = ssb_ssb_block_write,
|
||||
-#endif
|
||||
-};
|
||||
-
|
||||
static int ssb_fetch_invariants(struct ssb_bus *bus,
|
||||
ssb_invariants_func_t get_invariants)
|
||||
{
|
||||
@@ -876,7 +716,6 @@ int ssb_bus_pcibus_register(struct ssb_b
|
||||
|
||||
return err;
|
||||
}
|
||||
-EXPORT_SYMBOL(ssb_bus_pcibus_register);
|
||||
#endif /* CONFIG_SSB_PCIHOST */
|
||||
|
||||
#ifdef CONFIG_SSB_PCMCIAHOST
|
||||
@@ -898,7 +737,6 @@ int ssb_bus_pcmciabus_register(struct ss
|
||||
|
||||
return err;
|
||||
}
|
||||
-EXPORT_SYMBOL(ssb_bus_pcmciabus_register);
|
||||
#endif /* CONFIG_SSB_PCMCIAHOST */
|
||||
|
||||
#ifdef CONFIG_SSB_SDIOHOST
|
||||
@@ -923,13 +761,14 @@ int ssb_bus_sdiobus_register(struct ssb_
|
||||
EXPORT_SYMBOL(ssb_bus_sdiobus_register);
|
||||
#endif /* CONFIG_SSB_PCMCIAHOST */
|
||||
|
||||
+#ifdef CONFIG_SSB_HOST_SOC
|
||||
int ssb_bus_ssbbus_register(struct ssb_bus *bus, unsigned long baseaddr,
|
||||
ssb_invariants_func_t get_invariants)
|
||||
{
|
||||
int err;
|
||||
|
||||
bus->bustype = SSB_BUSTYPE_SSB;
|
||||
- bus->ops = &ssb_ssb_ops;
|
||||
+ bus->ops = &ssb_host_soc_ops;
|
||||
|
||||
err = ssb_bus_register(bus, get_invariants, baseaddr);
|
||||
if (!err) {
|
||||
@@ -939,6 +778,7 @@ int ssb_bus_ssbbus_register(struct ssb_b
|
||||
|
||||
return err;
|
||||
}
|
||||
+#endif
|
||||
|
||||
int __ssb_driver_register(struct ssb_driver *drv, struct module *owner)
|
||||
{
|
||||
@@ -1465,6 +1305,12 @@ static int __init ssb_modinit(void)
|
||||
/* don't fail SSB init because of this */
|
||||
err = 0;
|
||||
}
|
||||
+ err = ssb_host_pcmcia_init();
|
||||
+ if (err) {
|
||||
+ ssb_err("PCMCIA host initialization failed\n");
|
||||
+ /* don't fail SSB init because of this */
|
||||
+ err = 0;
|
||||
+ }
|
||||
err = ssb_gige_init();
|
||||
if (err) {
|
||||
ssb_err("SSB Broadcom Gigabit Ethernet driver initialization failed\n");
|
||||
@@ -1482,6 +1328,7 @@ fs_initcall(ssb_modinit);
|
||||
static void __exit ssb_modexit(void)
|
||||
{
|
||||
ssb_gige_exit();
|
||||
+ ssb_host_pcmcia_exit();
|
||||
b43_pci_ssb_bridge_exit();
|
||||
bus_unregister(&ssb_bustype);
|
||||
}
|
||||
--- a/drivers/ssb/pcmcia.c
|
||||
+++ b/drivers/ssb/pcmcia.c
|
||||
@@ -147,8 +147,7 @@ error:
|
||||
return err;
|
||||
}
|
||||
|
||||
-int ssb_pcmcia_switch_core(struct ssb_bus *bus,
|
||||
- struct ssb_device *dev)
|
||||
+static int ssb_pcmcia_switch_core(struct ssb_bus *bus, struct ssb_device *dev)
|
||||
{
|
||||
int err;
|
||||
|
||||
--- a/drivers/ssb/sdio.c
|
||||
+++ b/drivers/ssb/sdio.c
|
||||
@@ -200,7 +200,7 @@ out:
|
||||
}
|
||||
|
||||
/* host must be already claimed */
|
||||
-int ssb_sdio_switch_core(struct ssb_bus *bus, struct ssb_device *dev)
|
||||
+static int ssb_sdio_switch_core(struct ssb_bus *bus, struct ssb_device *dev)
|
||||
{
|
||||
u8 coreidx = dev->core_index;
|
||||
u32 sbaddr;
|
||||
--- a/drivers/ssb/ssb_private.h
|
||||
+++ b/drivers/ssb/ssb_private.h
|
||||
@@ -85,8 +85,6 @@ static inline int ssb_pci_init(struct ss
|
||||
|
||||
/* pcmcia.c */
|
||||
#ifdef CONFIG_SSB_PCMCIAHOST
|
||||
-extern int ssb_pcmcia_switch_core(struct ssb_bus *bus,
|
||||
- struct ssb_device *dev);
|
||||
extern int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
|
||||
u8 coreidx);
|
||||
extern int ssb_pcmcia_switch_segment(struct ssb_bus *bus,
|
||||
@@ -96,13 +94,10 @@ extern int ssb_pcmcia_get_invariants(str
|
||||
extern int ssb_pcmcia_hardware_setup(struct ssb_bus *bus);
|
||||
extern void ssb_pcmcia_exit(struct ssb_bus *bus);
|
||||
extern int ssb_pcmcia_init(struct ssb_bus *bus);
|
||||
+extern int ssb_host_pcmcia_init(void);
|
||||
+extern void ssb_host_pcmcia_exit(void);
|
||||
extern const struct ssb_bus_ops ssb_pcmcia_ops;
|
||||
#else /* CONFIG_SSB_PCMCIAHOST */
|
||||
-static inline int ssb_pcmcia_switch_core(struct ssb_bus *bus,
|
||||
- struct ssb_device *dev)
|
||||
-{
|
||||
- return 0;
|
||||
-}
|
||||
static inline int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
|
||||
u8 coreidx)
|
||||
{
|
||||
@@ -124,6 +119,13 @@ static inline int ssb_pcmcia_init(struct
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
+static inline int ssb_host_pcmcia_init(void)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+static inline void ssb_host_pcmcia_exit(void)
|
||||
+{
|
||||
+}
|
||||
#endif /* CONFIG_SSB_PCMCIAHOST */
|
||||
|
||||
/* sdio.c */
|
||||
@@ -132,9 +134,7 @@ extern int ssb_sdio_get_invariants(struc
|
||||
struct ssb_init_invariants *iv);
|
||||
|
||||
extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
|
||||
-extern int ssb_sdio_switch_core(struct ssb_bus *bus, struct ssb_device *dev);
|
||||
extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
|
||||
-extern int ssb_sdio_hardware_setup(struct ssb_bus *bus);
|
||||
extern void ssb_sdio_exit(struct ssb_bus *bus);
|
||||
extern int ssb_sdio_init(struct ssb_bus *bus);
|
||||
|
||||
@@ -144,19 +144,10 @@ static inline u32 ssb_sdio_scan_read32(s
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
-static inline int ssb_sdio_switch_core(struct ssb_bus *bus,
|
||||
- struct ssb_device *dev)
|
||||
-{
|
||||
- return 0;
|
||||
-}
|
||||
static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
-static inline int ssb_sdio_hardware_setup(struct ssb_bus *bus)
|
||||
-{
|
||||
- return 0;
|
||||
-}
|
||||
static inline void ssb_sdio_exit(struct ssb_bus *bus)
|
||||
{
|
||||
}
|
||||
@@ -166,6 +157,13 @@ static inline int ssb_sdio_init(struct s
|
||||
}
|
||||
#endif /* CONFIG_SSB_SDIOHOST */
|
||||
|
||||
+/**************************************************
|
||||
+ * host_soc.c
|
||||
+ **************************************************/
|
||||
+
|
||||
+#ifdef CONFIG_SSB_HOST_SOC
|
||||
+extern const struct ssb_bus_ops ssb_host_soc_ops;
|
||||
+#endif
|
||||
|
||||
/* scan.c */
|
||||
extern const char *ssb_core_name(u16 coreid);
|
@ -1,32 +0,0 @@
|
||||
--- a/include/linux/ssb/ssb.h
|
||||
+++ b/include/linux/ssb/ssb.h
|
||||
@@ -29,10 +29,13 @@ struct ssb_sprom {
|
||||
u8 il0mac[6] __aligned(sizeof(u16)); /* MAC address for 802.11b/g */
|
||||
u8 et0mac[6] __aligned(sizeof(u16)); /* MAC address for Ethernet */
|
||||
u8 et1mac[6] __aligned(sizeof(u16)); /* MAC address for 802.11a */
|
||||
+ u8 et2mac[6] __aligned(sizeof(u16)); /* MAC address for extra Ethernet */
|
||||
u8 et0phyaddr; /* MII address for enet0 */
|
||||
u8 et1phyaddr; /* MII address for enet1 */
|
||||
+ u8 et2phyaddr; /* MII address for enet2 */
|
||||
u8 et0mdcport; /* MDIO for enet0 */
|
||||
u8 et1mdcport; /* MDIO for enet1 */
|
||||
+ u8 et2mdcport; /* MDIO for enet2 */
|
||||
u16 dev_id; /* Device ID overriding e.g. PCI ID */
|
||||
u16 board_rev; /* Board revision number from SPROM. */
|
||||
u16 board_num; /* Board number from SPROM. */
|
||||
@@ -88,11 +91,14 @@ struct ssb_sprom {
|
||||
u32 ofdm5glpo; /* 5.2GHz OFDM power offset */
|
||||
u32 ofdm5gpo; /* 5.3GHz OFDM power offset */
|
||||
u32 ofdm5ghpo; /* 5.8GHz OFDM power offset */
|
||||
+ u32 boardflags;
|
||||
+ u32 boardflags2;
|
||||
+ u32 boardflags3;
|
||||
+ /* TODO: Switch all drivers to new u32 fields and drop below ones */
|
||||
u16 boardflags_lo; /* Board flags (bits 0-15) */
|
||||
u16 boardflags_hi; /* Board flags (bits 16-31) */
|
||||
u16 boardflags2_lo; /* Board flags (bits 32-47) */
|
||||
u16 boardflags2_hi; /* Board flags (bits 48-63) */
|
||||
- /* TODO store board flags in a single u64 */
|
||||
|
||||
struct ssb_sprom_core_pwr_info core_pwr_info[4];
|
||||
|
@ -1,86 +0,0 @@
|
||||
--- a/drivers/bcma/driver_gpio.c
|
||||
+++ b/drivers/bcma/driver_gpio.c
|
||||
@@ -226,6 +226,7 @@ int bcma_gpio_init(struct bcma_drv_cc *c
|
||||
chip->of_node = cc->core->dev.of_node;
|
||||
#endif
|
||||
switch (bus->chipinfo.id) {
|
||||
+ case BCMA_CHIP_ID_BCM4707:
|
||||
case BCMA_CHIP_ID_BCM5357:
|
||||
case BCMA_CHIP_ID_BCM53572:
|
||||
chip->ngpio = 32;
|
||||
@@ -235,16 +236,17 @@ int bcma_gpio_init(struct bcma_drv_cc *c
|
||||
}
|
||||
|
||||
/*
|
||||
- * On MIPS we register GPIO devices (LEDs, buttons) using absolute GPIO
|
||||
- * pin numbers. We don't have Device Tree there and we can't really use
|
||||
- * relative (per chip) numbers.
|
||||
- * So let's use predictable base for BCM47XX and "random" for all other.
|
||||
+ * Register SoC GPIO devices with absolute GPIO pin base.
|
||||
+ * On MIPS, we don't have Device Tree and we can't use relative (per chip)
|
||||
+ * GPIO numbers.
|
||||
+ * On some ARM devices, user space may want to access some system GPIO
|
||||
+ * pins directly, which is easier to do with a predictable GPIO base.
|
||||
*/
|
||||
-#if IS_BUILTIN(CONFIG_BCM47XX)
|
||||
- chip->base = bus->num * BCMA_GPIO_MAX_PINS;
|
||||
-#else
|
||||
- chip->base = -1;
|
||||
-#endif
|
||||
+ if (IS_BUILTIN(CONFIG_BCM47XX) ||
|
||||
+ cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
|
||||
+ chip->base = bus->num * BCMA_GPIO_MAX_PINS;
|
||||
+ else
|
||||
+ chip->base = -1;
|
||||
|
||||
err = bcma_gpio_irq_domain_init(cc);
|
||||
if (err)
|
||||
--- a/drivers/bcma/Kconfig
|
||||
+++ b/drivers/bcma/Kconfig
|
||||
@@ -29,12 +29,6 @@ config BCMA_HOST_PCI
|
||||
select BCMA_DRIVER_PCI
|
||||
default y
|
||||
|
||||
-config BCMA_DRIVER_PCI_HOSTMODE
|
||||
- bool "Driver for PCI core working in hostmode"
|
||||
- depends on BCMA && MIPS && BCMA_HOST_PCI
|
||||
- help
|
||||
- PCI core hostmode operation (external PCI bus).
|
||||
-
|
||||
config BCMA_HOST_SOC
|
||||
bool "Support for BCMA in a SoC"
|
||||
depends on BCMA
|
||||
@@ -61,6 +55,12 @@ config BCMA_DRIVER_PCI
|
||||
This driver is also prerequisite for a hostmode PCIe core
|
||||
support.
|
||||
|
||||
+config BCMA_DRIVER_PCI_HOSTMODE
|
||||
+ bool "Driver for PCI core working in hostmode"
|
||||
+ depends on BCMA && MIPS && BCMA_DRIVER_PCI
|
||||
+ help
|
||||
+ PCI core hostmode operation (external PCI bus).
|
||||
+
|
||||
config BCMA_DRIVER_MIPS
|
||||
bool "BCMA Broadcom MIPS core driver"
|
||||
depends on BCMA && MIPS
|
||||
--- a/include/linux/bcma/bcma_driver_pci.h
|
||||
+++ b/include/linux/bcma/bcma_driver_pci.h
|
||||
@@ -246,7 +246,18 @@ static inline void bcma_core_pci_power_s
|
||||
}
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
|
||||
extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
|
||||
extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
|
||||
+#else
|
||||
+static inline int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev)
|
||||
+{
|
||||
+ return -ENOTSUPP;
|
||||
+}
|
||||
+static inline int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
|
||||
+{
|
||||
+ return -ENOTSUPP;
|
||||
+}
|
||||
+#endif
|
||||
|
||||
#endif /* LINUX_BCMA_DRIVER_PCI_H_ */
|
@ -1,26 +0,0 @@
|
||||
commit 55acca90da52b85299c033354e51ddaa7b73e019
|
||||
Author: Hante Meuleman <meuleman@broadcom.com>
|
||||
Date: Fri Sep 18 22:08:17 2015 +0200
|
||||
|
||||
brcmfmac: Add support for the BCM4365 and BCM4366 PCIE devices.
|
||||
|
||||
This patch adds support for the BCM4365 and BCM4366 11ac Wave2
|
||||
PCIE devices.
|
||||
|
||||
Reviewed-by: Arend Van Spriel <arend@broadcom.com>
|
||||
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
|
||||
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
|
||||
Signed-off-by: Arend van Spriel <arend@broadcom.com>
|
||||
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
|
||||
|
||||
--- a/include/linux/bcma/bcma.h
|
||||
+++ b/include/linux/bcma/bcma.h
|
||||
@@ -151,6 +151,8 @@ struct bcma_host_ops {
|
||||
#define BCMA_CORE_PCIE2 0x83C /* PCI Express Gen2 */
|
||||
#define BCMA_CORE_USB30_DEV 0x83D
|
||||
#define BCMA_CORE_ARM_CR4 0x83E
|
||||
+#define BCMA_CORE_ARM_CA7 0x847
|
||||
+#define BCMA_CORE_SYS_MEM 0x849
|
||||
#define BCMA_CORE_DEFAULT 0xFFF
|
||||
|
||||
#define BCMA_MAX_NR_CORES 16
|
@ -1,49 +0,0 @@
|
||||
--- a/drivers/bcma/main.c
|
||||
+++ b/drivers/bcma/main.c
|
||||
@@ -637,11 +637,36 @@ static int bcma_device_uevent(struct dev
|
||||
core->id.rev, core->id.class);
|
||||
}
|
||||
|
||||
-static int __init bcma_modinit(void)
|
||||
+static unsigned int bcma_bus_registered;
|
||||
+
|
||||
+/*
|
||||
+ * If built-in, bus has to be registered early, before any driver calls
|
||||
+ * bcma_driver_register.
|
||||
+ * Otherwise registering driver would trigger BUG in driver_register.
|
||||
+ */
|
||||
+static int __init bcma_init_bus_register(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
+ if (bcma_bus_registered)
|
||||
+ return 0;
|
||||
+
|
||||
err = bus_register(&bcma_bus_type);
|
||||
+ if (!err)
|
||||
+ bcma_bus_registered = 1;
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+#ifndef MODULE
|
||||
+fs_initcall(bcma_init_bus_register);
|
||||
+#endif
|
||||
+
|
||||
+/* Main initialization has to be done with SPI/mtd/NAND/SPROM available */
|
||||
+static int __init bcma_modinit(void)
|
||||
+{
|
||||
+ int err;
|
||||
+
|
||||
+ err = bcma_init_bus_register();
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -660,7 +685,7 @@ static int __init bcma_modinit(void)
|
||||
|
||||
return err;
|
||||
}
|
||||
-fs_initcall(bcma_modinit);
|
||||
+module_init(bcma_modinit);
|
||||
|
||||
static void __exit bcma_modexit(void)
|
||||
{
|
@ -1,716 +0,0 @@
|
||||
--- a/drivers/bcma/driver_chipcommon.c
|
||||
+++ b/drivers/bcma/driver_chipcommon.c
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/bcma/bcma.h>
|
||||
|
||||
+static void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
|
||||
+
|
||||
static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
|
||||
u32 mask, u32 value)
|
||||
{
|
||||
@@ -113,8 +115,37 @@ int bcma_chipco_watchdog_register(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void bcma_core_chipcommon_flash_detect(struct bcma_drv_cc *cc)
|
||||
+{
|
||||
+ struct bcma_bus *bus = cc->core->bus;
|
||||
+
|
||||
+ switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
|
||||
+ case BCMA_CC_FLASHT_STSER:
|
||||
+ case BCMA_CC_FLASHT_ATSER:
|
||||
+ bcma_debug(bus, "Found serial flash\n");
|
||||
+ bcma_sflash_init(cc);
|
||||
+ break;
|
||||
+ case BCMA_CC_FLASHT_PARA:
|
||||
+ bcma_debug(bus, "Found parallel flash\n");
|
||||
+ bcma_pflash_init(cc);
|
||||
+ break;
|
||||
+ default:
|
||||
+ bcma_err(bus, "Flash type not supported\n");
|
||||
+ }
|
||||
+
|
||||
+ if (cc->core->id.rev == 38 ||
|
||||
+ bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
|
||||
+ if (cc->capabilities & BCMA_CC_CAP_NFLASH) {
|
||||
+ bcma_debug(bus, "Found NAND flash\n");
|
||||
+ bcma_nflash_init(cc);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
|
||||
{
|
||||
+ struct bcma_bus *bus = cc->core->bus;
|
||||
+
|
||||
if (cc->early_setup_done)
|
||||
return;
|
||||
|
||||
@@ -129,6 +160,12 @@ void bcma_core_chipcommon_early_init(str
|
||||
if (cc->capabilities & BCMA_CC_CAP_PMU)
|
||||
bcma_pmu_early_init(cc);
|
||||
|
||||
+ if (IS_BUILTIN(CONFIG_BCM47XX) && bus->hosttype == BCMA_HOSTTYPE_SOC)
|
||||
+ bcma_chipco_serial_init(cc);
|
||||
+
|
||||
+ if (bus->hosttype == BCMA_HOSTTYPE_SOC)
|
||||
+ bcma_core_chipcommon_flash_detect(cc);
|
||||
+
|
||||
cc->early_setup_done = true;
|
||||
}
|
||||
|
||||
@@ -185,11 +222,12 @@ u32 bcma_chipco_watchdog_timer_set(struc
|
||||
ticks = 2;
|
||||
else if (ticks > maxt)
|
||||
ticks = maxt;
|
||||
- bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
|
||||
} else {
|
||||
struct bcma_bus *bus = cc->core->bus;
|
||||
|
||||
if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4707 &&
|
||||
+ bus->chipinfo.id != BCMA_CHIP_ID_BCM47094 &&
|
||||
bus->chipinfo.id != BCMA_CHIP_ID_BCM53018)
|
||||
bcma_core_set_clockmode(cc->core,
|
||||
ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC);
|
||||
@@ -314,9 +352,9 @@ u32 bcma_chipco_gpio_pulldown(struct bcm
|
||||
return res;
|
||||
}
|
||||
|
||||
-#ifdef CONFIG_BCMA_DRIVER_MIPS
|
||||
-void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
|
||||
+static void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
|
||||
{
|
||||
+#if IS_BUILTIN(CONFIG_BCM47XX)
|
||||
unsigned int irq;
|
||||
u32 baud_base;
|
||||
u32 i;
|
||||
@@ -358,5 +396,5 @@ void bcma_chipco_serial_init(struct bcma
|
||||
ports[i].baud_base = baud_base;
|
||||
ports[i].reg_shift = 0;
|
||||
}
|
||||
+#endif /* CONFIG_BCM47XX */
|
||||
}
|
||||
-#endif /* CONFIG_BCMA_DRIVER_MIPS */
|
||||
--- a/drivers/bcma/driver_chipcommon_pmu.c
|
||||
+++ b/drivers/bcma/driver_chipcommon_pmu.c
|
||||
@@ -15,44 +15,44 @@
|
||||
|
||||
u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
|
||||
{
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
|
||||
- bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
|
||||
- return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, offset);
|
||||
+ bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_ADDR);
|
||||
+ return bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_DATA);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
|
||||
|
||||
void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
|
||||
{
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
|
||||
- bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, offset);
|
||||
+ bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_ADDR);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_DATA, value);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bcma_chipco_pll_write);
|
||||
|
||||
void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
|
||||
u32 set)
|
||||
{
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
|
||||
- bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
|
||||
- bcma_cc_maskset32(cc, BCMA_CC_PLLCTL_DATA, mask, set);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, offset);
|
||||
+ bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_ADDR);
|
||||
+ bcma_pmu_maskset32(cc, BCMA_CC_PMU_PLLCTL_DATA, mask, set);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bcma_chipco_pll_maskset);
|
||||
|
||||
void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
|
||||
u32 offset, u32 mask, u32 set)
|
||||
{
|
||||
- bcma_cc_write32(cc, BCMA_CC_CHIPCTL_ADDR, offset);
|
||||
- bcma_cc_read32(cc, BCMA_CC_CHIPCTL_ADDR);
|
||||
- bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL_DATA, mask, set);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_CHIPCTL_ADDR, offset);
|
||||
+ bcma_pmu_read32(cc, BCMA_CC_PMU_CHIPCTL_ADDR);
|
||||
+ bcma_pmu_maskset32(cc, BCMA_CC_PMU_CHIPCTL_DATA, mask, set);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bcma_chipco_chipctl_maskset);
|
||||
|
||||
void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
|
||||
u32 set)
|
||||
{
|
||||
- bcma_cc_write32(cc, BCMA_CC_REGCTL_ADDR, offset);
|
||||
- bcma_cc_read32(cc, BCMA_CC_REGCTL_ADDR);
|
||||
- bcma_cc_maskset32(cc, BCMA_CC_REGCTL_DATA, mask, set);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_REGCTL_ADDR, offset);
|
||||
+ bcma_pmu_read32(cc, BCMA_CC_PMU_REGCTL_ADDR);
|
||||
+ bcma_pmu_maskset32(cc, BCMA_CC_PMU_REGCTL_DATA, mask, set);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
|
||||
|
||||
@@ -60,18 +60,18 @@ static u32 bcma_pmu_xtalfreq(struct bcma
|
||||
{
|
||||
u32 ilp_ctl, alp_hz;
|
||||
|
||||
- if (!(bcma_cc_read32(cc, BCMA_CC_PMU_STAT) &
|
||||
+ if (!(bcma_pmu_read32(cc, BCMA_CC_PMU_STAT) &
|
||||
BCMA_CC_PMU_STAT_EXT_LPO_AVAIL))
|
||||
return 0;
|
||||
|
||||
- bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ,
|
||||
- BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT));
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_XTAL_FREQ,
|
||||
+ BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT));
|
||||
usleep_range(1000, 2000);
|
||||
|
||||
- ilp_ctl = bcma_cc_read32(cc, BCMA_CC_PMU_XTAL_FREQ);
|
||||
+ ilp_ctl = bcma_pmu_read32(cc, BCMA_CC_PMU_XTAL_FREQ);
|
||||
ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK;
|
||||
|
||||
- bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0);
|
||||
|
||||
alp_hz = ilp_ctl * 32768 / 4;
|
||||
return (alp_hz + 50000) / 100000 * 100;
|
||||
@@ -127,8 +127,8 @@ static void bcma_pmu2_pll_init0(struct b
|
||||
mask = (u32)~(BCMA_RES_4314_HT_AVAIL |
|
||||
BCMA_RES_4314_MACPHY_CLK_AVAIL);
|
||||
|
||||
- bcma_cc_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask);
|
||||
- bcma_cc_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask);
|
||||
+ bcma_pmu_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask);
|
||||
+ bcma_pmu_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask);
|
||||
bcma_wait_value(cc->core, BCMA_CLKCTLST,
|
||||
BCMA_CLKCTLST_HAVEHT, 0, 20000);
|
||||
break;
|
||||
@@ -140,7 +140,7 @@ static void bcma_pmu2_pll_init0(struct b
|
||||
|
||||
/* Flush */
|
||||
if (cc->pmu.rev >= 2)
|
||||
- bcma_cc_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
|
||||
+ bcma_pmu_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
|
||||
|
||||
/* TODO: Do we need to update OTP? */
|
||||
}
|
||||
@@ -195,9 +195,9 @@ static void bcma_pmu_resources_init(stru
|
||||
|
||||
/* Set the resource masks. */
|
||||
if (min_msk)
|
||||
- bcma_cc_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk);
|
||||
if (max_msk)
|
||||
- bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
|
||||
|
||||
/*
|
||||
* Add some delay; allow resources to come up and settle.
|
||||
@@ -269,23 +269,33 @@ static void bcma_pmu_workarounds(struct
|
||||
|
||||
void bcma_pmu_early_init(struct bcma_drv_cc *cc)
|
||||
{
|
||||
+ struct bcma_bus *bus = cc->core->bus;
|
||||
u32 pmucap;
|
||||
|
||||
- pmucap = bcma_cc_read32(cc, BCMA_CC_PMU_CAP);
|
||||
+ if (cc->core->id.rev >= 35 &&
|
||||
+ cc->capabilities_ext & BCMA_CC_CAP_EXT_AOB_PRESENT) {
|
||||
+ cc->pmu.core = bcma_find_core(bus, BCMA_CORE_PMU);
|
||||
+ if (!cc->pmu.core)
|
||||
+ bcma_warn(bus, "Couldn't find expected PMU core");
|
||||
+ }
|
||||
+ if (!cc->pmu.core)
|
||||
+ cc->pmu.core = cc->core;
|
||||
+
|
||||
+ pmucap = bcma_pmu_read32(cc, BCMA_CC_PMU_CAP);
|
||||
cc->pmu.rev = (pmucap & BCMA_CC_PMU_CAP_REVISION);
|
||||
|
||||
- bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
|
||||
- cc->pmu.rev, pmucap);
|
||||
+ bcma_debug(bus, "Found rev %u PMU (capabilities 0x%08X)\n", cc->pmu.rev,
|
||||
+ pmucap);
|
||||
}
|
||||
|
||||
void bcma_pmu_init(struct bcma_drv_cc *cc)
|
||||
{
|
||||
if (cc->pmu.rev == 1)
|
||||
- bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
|
||||
- ~BCMA_CC_PMU_CTL_NOILPONW);
|
||||
+ bcma_pmu_mask32(cc, BCMA_CC_PMU_CTL,
|
||||
+ ~BCMA_CC_PMU_CTL_NOILPONW);
|
||||
else
|
||||
- bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
|
||||
- BCMA_CC_PMU_CTL_NOILPONW);
|
||||
+ bcma_pmu_set32(cc, BCMA_CC_PMU_CTL,
|
||||
+ BCMA_CC_PMU_CTL_NOILPONW);
|
||||
|
||||
bcma_pmu_pll_init(cc);
|
||||
bcma_pmu_resources_init(cc);
|
||||
@@ -472,8 +482,8 @@ u32 bcma_pmu_get_cpu_clock(struct bcma_d
|
||||
static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
|
||||
u32 value)
|
||||
{
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, offset);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_DATA, value);
|
||||
}
|
||||
|
||||
void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid)
|
||||
@@ -497,20 +507,20 @@ void bcma_pmu_spuravoid_pllupdate(struct
|
||||
bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) ? 6 : 0;
|
||||
|
||||
/* RMW only the P1 divider */
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR,
|
||||
BCMA_CC_PMU_PLL_CTL0 + phypll_offset);
|
||||
- tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
|
||||
+ tmp = bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_DATA);
|
||||
tmp &= (~(BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK));
|
||||
tmp |= (bcm5357_bcm43236_p1div[spuravoid] << BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT);
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_DATA, tmp);
|
||||
|
||||
/* RMW only the int feedback divider */
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR,
|
||||
BCMA_CC_PMU_PLL_CTL2 + phypll_offset);
|
||||
- tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
|
||||
+ tmp = bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_DATA);
|
||||
tmp &= ~(BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK);
|
||||
tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
|
||||
- bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_DATA, tmp);
|
||||
|
||||
tmp = BCMA_CC_PMU_CTL_PLL_UPD;
|
||||
break;
|
||||
@@ -646,7 +656,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
|
||||
break;
|
||||
}
|
||||
|
||||
- tmp |= bcma_cc_read32(cc, BCMA_CC_PMU_CTL);
|
||||
- bcma_cc_write32(cc, BCMA_CC_PMU_CTL, tmp);
|
||||
+ tmp |= bcma_pmu_read32(cc, BCMA_CC_PMU_CTL);
|
||||
+ bcma_pmu_write32(cc, BCMA_CC_PMU_CTL, tmp);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bcma_pmu_spuravoid_pllupdate);
|
||||
--- a/drivers/bcma/driver_chipcommon_sflash.c
|
||||
+++ b/drivers/bcma/driver_chipcommon_sflash.c
|
||||
@@ -38,6 +38,7 @@ static const struct bcma_sflash_tbl_e bc
|
||||
{ "M25P32", 0x15, 0x10000, 64, },
|
||||
{ "M25P64", 0x16, 0x10000, 128, },
|
||||
{ "M25FL128", 0x17, 0x10000, 256, },
|
||||
+ { "MX25L25635F", 0x18, 0x10000, 512, },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
--- a/drivers/bcma/scan.c
|
||||
+++ b/drivers/bcma/scan.c
|
||||
@@ -98,6 +98,9 @@ static const struct bcma_device_id_name
|
||||
{ BCMA_CORE_SHIM, "SHIM" },
|
||||
{ BCMA_CORE_PCIE2, "PCIe Gen2" },
|
||||
{ BCMA_CORE_ARM_CR4, "ARM CR4" },
|
||||
+ { BCMA_CORE_GCI, "GCI" },
|
||||
+ { BCMA_CORE_CMEM, "CNDS DDR2/3 memory controller" },
|
||||
+ { BCMA_CORE_ARM_CA7, "ARM CA7" },
|
||||
{ BCMA_CORE_DEFAULT, "Default" },
|
||||
};
|
||||
|
||||
@@ -315,6 +318,8 @@ static int bcma_get_next_core(struct bcm
|
||||
switch (core->id.id) {
|
||||
case BCMA_CORE_4706_MAC_GBIT_COMMON:
|
||||
case BCMA_CORE_NS_CHIPCOMMON_B:
|
||||
+ case BCMA_CORE_PMU:
|
||||
+ case BCMA_CORE_GCI:
|
||||
/* Not used yet: case BCMA_CORE_OOB_ROUTER: */
|
||||
break;
|
||||
default:
|
||||
--- a/drivers/net/wireless/b43/main.c
|
||||
+++ b/drivers/net/wireless/b43/main.c
|
||||
@@ -1215,10 +1215,10 @@ void b43_wireless_core_phy_pll_reset(str
|
||||
case B43_BUS_BCMA:
|
||||
bcma_cc = &dev->dev->bdev->bus->drv_cc;
|
||||
|
||||
- bcma_cc_write32(bcma_cc, BCMA_CC_CHIPCTL_ADDR, 0);
|
||||
- bcma_cc_mask32(bcma_cc, BCMA_CC_CHIPCTL_DATA, ~0x4);
|
||||
- bcma_cc_set32(bcma_cc, BCMA_CC_CHIPCTL_DATA, 0x4);
|
||||
- bcma_cc_mask32(bcma_cc, BCMA_CC_CHIPCTL_DATA, ~0x4);
|
||||
+ bcma_cc_write32(bcma_cc, BCMA_CC_PMU_CHIPCTL_ADDR, 0);
|
||||
+ bcma_cc_mask32(bcma_cc, BCMA_CC_PMU_CHIPCTL_DATA, ~0x4);
|
||||
+ bcma_cc_set32(bcma_cc, BCMA_CC_PMU_CHIPCTL_DATA, 0x4);
|
||||
+ bcma_cc_mask32(bcma_cc, BCMA_CC_PMU_CHIPCTL_DATA, ~0x4);
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_B43_SSB
|
||||
--- a/include/linux/bcma/bcma.h
|
||||
+++ b/include/linux/bcma/bcma.h
|
||||
@@ -151,6 +151,8 @@ struct bcma_host_ops {
|
||||
#define BCMA_CORE_PCIE2 0x83C /* PCI Express Gen2 */
|
||||
#define BCMA_CORE_USB30_DEV 0x83D
|
||||
#define BCMA_CORE_ARM_CR4 0x83E
|
||||
+#define BCMA_CORE_GCI 0x840
|
||||
+#define BCMA_CORE_CMEM 0x846 /* CNDS DDR2/3 memory controller */
|
||||
#define BCMA_CORE_ARM_CA7 0x847
|
||||
#define BCMA_CORE_SYS_MEM 0x849
|
||||
#define BCMA_CORE_DEFAULT 0xFFF
|
||||
@@ -200,6 +202,7 @@ struct bcma_host_ops {
|
||||
#define BCMA_PKG_ID_BCM4707 1
|
||||
#define BCMA_PKG_ID_BCM4708 2
|
||||
#define BCMA_PKG_ID_BCM4709 0
|
||||
+#define BCMA_CHIP_ID_BCM47094 53030
|
||||
#define BCMA_CHIP_ID_BCM53018 53018
|
||||
|
||||
/* Board types (on PCI usually equals to the subsystem dev id) */
|
||||
--- a/include/linux/bcma/bcma_driver_chipcommon.h
|
||||
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
|
||||
@@ -217,6 +217,11 @@
|
||||
#define BCMA_CC_CLKDIV_JTAG_SHIFT 8
|
||||
#define BCMA_CC_CLKDIV_UART 0x000000FF
|
||||
#define BCMA_CC_CAP_EXT 0x00AC /* Capabilities */
|
||||
+#define BCMA_CC_CAP_EXT_SECI_PRESENT 0x00000001
|
||||
+#define BCMA_CC_CAP_EXT_GSIO_PRESENT 0x00000002
|
||||
+#define BCMA_CC_CAP_EXT_GCI_PRESENT 0x00000004
|
||||
+#define BCMA_CC_CAP_EXT_SECI_PUART_PRESENT 0x00000008 /* UART present */
|
||||
+#define BCMA_CC_CAP_EXT_AOB_PRESENT 0x00000040
|
||||
#define BCMA_CC_PLLONDELAY 0x00B0 /* Rev >= 4 only */
|
||||
#define BCMA_CC_FREFSELDELAY 0x00B4 /* Rev >= 4 only */
|
||||
#define BCMA_CC_SLOWCLKCTL 0x00B8 /* 6 <= Rev <= 9 only */
|
||||
@@ -351,12 +356,12 @@
|
||||
#define BCMA_CC_PMU_RES_REQTS 0x0640 /* PMU res req timer sel */
|
||||
#define BCMA_CC_PMU_RES_REQT 0x0644 /* PMU res req timer */
|
||||
#define BCMA_CC_PMU_RES_REQM 0x0648 /* PMU res req mask */
|
||||
-#define BCMA_CC_CHIPCTL_ADDR 0x0650
|
||||
-#define BCMA_CC_CHIPCTL_DATA 0x0654
|
||||
-#define BCMA_CC_REGCTL_ADDR 0x0658
|
||||
-#define BCMA_CC_REGCTL_DATA 0x065C
|
||||
-#define BCMA_CC_PLLCTL_ADDR 0x0660
|
||||
-#define BCMA_CC_PLLCTL_DATA 0x0664
|
||||
+#define BCMA_CC_PMU_CHIPCTL_ADDR 0x0650
|
||||
+#define BCMA_CC_PMU_CHIPCTL_DATA 0x0654
|
||||
+#define BCMA_CC_PMU_REGCTL_ADDR 0x0658
|
||||
+#define BCMA_CC_PMU_REGCTL_DATA 0x065C
|
||||
+#define BCMA_CC_PMU_PLLCTL_ADDR 0x0660
|
||||
+#define BCMA_CC_PMU_PLLCTL_DATA 0x0664
|
||||
#define BCMA_CC_PMU_STRAPOPT 0x0668 /* (corerev >= 28) */
|
||||
#define BCMA_CC_PMU_XTAL_FREQ 0x066C /* (pmurev >= 10) */
|
||||
#define BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK 0x00001FFF
|
||||
@@ -566,17 +571,16 @@
|
||||
* Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
|
||||
*/
|
||||
struct bcma_chipcommon_pmu {
|
||||
+ struct bcma_device *core; /* Can be separated core or just ChipCommon one */
|
||||
u8 rev; /* PMU revision */
|
||||
u32 crystalfreq; /* The active crystal frequency (in kHz) */
|
||||
};
|
||||
|
||||
-#ifdef CONFIG_BCMA_DRIVER_MIPS
|
||||
+#ifdef CONFIG_BCMA_PFLASH
|
||||
struct bcma_pflash {
|
||||
bool present;
|
||||
- u8 buswidth;
|
||||
- u32 window;
|
||||
- u32 window_size;
|
||||
};
|
||||
+#endif
|
||||
|
||||
#ifdef CONFIG_BCMA_SFLASH
|
||||
struct bcma_sflash {
|
||||
@@ -602,6 +606,7 @@ struct bcma_nflash {
|
||||
};
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_BCMA_DRIVER_MIPS
|
||||
struct bcma_serial_port {
|
||||
void *regs;
|
||||
unsigned long clockspeed;
|
||||
@@ -621,8 +626,9 @@ struct bcma_drv_cc {
|
||||
/* Fast Powerup Delay constant */
|
||||
u16 fast_pwrup_delay;
|
||||
struct bcma_chipcommon_pmu pmu;
|
||||
-#ifdef CONFIG_BCMA_DRIVER_MIPS
|
||||
+#ifdef CONFIG_BCMA_PFLASH
|
||||
struct bcma_pflash pflash;
|
||||
+#endif
|
||||
#ifdef CONFIG_BCMA_SFLASH
|
||||
struct bcma_sflash sflash;
|
||||
#endif
|
||||
@@ -630,6 +636,7 @@ struct bcma_drv_cc {
|
||||
struct bcma_nflash nflash;
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_BCMA_DRIVER_MIPS
|
||||
int nr_serial_ports;
|
||||
struct bcma_serial_port serial_ports[4];
|
||||
#endif /* CONFIG_BCMA_DRIVER_MIPS */
|
||||
@@ -663,6 +670,19 @@ struct bcma_drv_cc_b {
|
||||
#define bcma_cc_maskset32(cc, offset, mask, set) \
|
||||
bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
|
||||
|
||||
+/* PMU registers access */
|
||||
+#define bcma_pmu_read32(cc, offset) \
|
||||
+ bcma_read32((cc)->pmu.core, offset)
|
||||
+#define bcma_pmu_write32(cc, offset, val) \
|
||||
+ bcma_write32((cc)->pmu.core, offset, val)
|
||||
+
|
||||
+#define bcma_pmu_mask32(cc, offset, mask) \
|
||||
+ bcma_pmu_write32(cc, offset, bcma_pmu_read32(cc, offset) & (mask))
|
||||
+#define bcma_pmu_set32(cc, offset, set) \
|
||||
+ bcma_pmu_write32(cc, offset, bcma_pmu_read32(cc, offset) | (set))
|
||||
+#define bcma_pmu_maskset32(cc, offset, mask, set) \
|
||||
+ bcma_pmu_write32(cc, offset, (bcma_pmu_read32(cc, offset) & (mask)) | (set))
|
||||
+
|
||||
extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
|
||||
|
||||
extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
|
||||
--- a/drivers/bcma/bcma_private.h
|
||||
+++ b/drivers/bcma/bcma_private.h
|
||||
@@ -44,10 +44,6 @@ int bcma_sprom_get(struct bcma_bus *bus)
|
||||
void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
|
||||
void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
|
||||
void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
|
||||
-#ifdef CONFIG_BCMA_DRIVER_MIPS
|
||||
-void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
|
||||
-extern struct platform_device bcma_pflash_dev;
|
||||
-#endif /* CONFIG_BCMA_DRIVER_MIPS */
|
||||
|
||||
/* driver_chipcommon_b.c */
|
||||
int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
|
||||
@@ -59,6 +55,21 @@ void bcma_pmu_init(struct bcma_drv_cc *c
|
||||
u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
|
||||
u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
|
||||
|
||||
+/**************************************************
|
||||
+ * driver_chipcommon_sflash.c
|
||||
+ **************************************************/
|
||||
+
|
||||
+#ifdef CONFIG_BCMA_PFLASH
|
||||
+extern struct platform_device bcma_pflash_dev;
|
||||
+int bcma_pflash_init(struct bcma_drv_cc *cc);
|
||||
+#else
|
||||
+static inline int bcma_pflash_init(struct bcma_drv_cc *cc)
|
||||
+{
|
||||
+ bcma_err(cc->core->bus, "Parallel flash not supported\n");
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif /* CONFIG_BCMA_PFLASH */
|
||||
+
|
||||
#ifdef CONFIG_BCMA_SFLASH
|
||||
/* driver_chipcommon_sflash.c */
|
||||
int bcma_sflash_init(struct bcma_drv_cc *cc);
|
||||
--- a/drivers/bcma/driver_gpio.c
|
||||
+++ b/drivers/bcma/driver_gpio.c
|
||||
@@ -229,6 +229,7 @@ int bcma_gpio_init(struct bcma_drv_cc *c
|
||||
case BCMA_CHIP_ID_BCM4707:
|
||||
case BCMA_CHIP_ID_BCM5357:
|
||||
case BCMA_CHIP_ID_BCM53572:
|
||||
+ case BCMA_CHIP_ID_BCM47094:
|
||||
chip->ngpio = 32;
|
||||
break;
|
||||
default:
|
||||
--- a/drivers/bcma/driver_mips.c
|
||||
+++ b/drivers/bcma/driver_mips.c
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
#include <linux/bcma/bcma.h>
|
||||
|
||||
-#include <linux/mtd/physmap.h>
|
||||
-#include <linux/platform_device.h>
|
||||
#include <linux/serial.h>
|
||||
#include <linux/serial_core.h>
|
||||
#include <linux/serial_reg.h>
|
||||
@@ -32,26 +30,6 @@ enum bcma_boot_dev {
|
||||
BCMA_BOOT_DEV_NAND,
|
||||
};
|
||||
|
||||
-static const char * const part_probes[] = { "bcm47xxpart", NULL };
|
||||
-
|
||||
-static struct physmap_flash_data bcma_pflash_data = {
|
||||
- .part_probe_types = part_probes,
|
||||
-};
|
||||
-
|
||||
-static struct resource bcma_pflash_resource = {
|
||||
- .name = "bcma_pflash",
|
||||
- .flags = IORESOURCE_MEM,
|
||||
-};
|
||||
-
|
||||
-struct platform_device bcma_pflash_dev = {
|
||||
- .name = "physmap-flash",
|
||||
- .dev = {
|
||||
- .platform_data = &bcma_pflash_data,
|
||||
- },
|
||||
- .resource = &bcma_pflash_resource,
|
||||
- .num_resources = 1,
|
||||
-};
|
||||
-
|
||||
/* The 47162a0 hangs when reading MIPS DMP registers registers */
|
||||
static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
|
||||
{
|
||||
@@ -272,48 +250,11 @@ static enum bcma_boot_dev bcma_boot_dev(
|
||||
return BCMA_BOOT_DEV_SERIAL;
|
||||
}
|
||||
|
||||
-static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
|
||||
+static void bcma_core_mips_nvram_init(struct bcma_drv_mips *mcore)
|
||||
{
|
||||
struct bcma_bus *bus = mcore->core->bus;
|
||||
- struct bcma_drv_cc *cc = &bus->drv_cc;
|
||||
- struct bcma_pflash *pflash = &cc->pflash;
|
||||
enum bcma_boot_dev boot_dev;
|
||||
|
||||
- switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
|
||||
- case BCMA_CC_FLASHT_STSER:
|
||||
- case BCMA_CC_FLASHT_ATSER:
|
||||
- bcma_debug(bus, "Found serial flash\n");
|
||||
- bcma_sflash_init(cc);
|
||||
- break;
|
||||
- case BCMA_CC_FLASHT_PARA:
|
||||
- bcma_debug(bus, "Found parallel flash\n");
|
||||
- pflash->present = true;
|
||||
- pflash->window = BCMA_SOC_FLASH2;
|
||||
- pflash->window_size = BCMA_SOC_FLASH2_SZ;
|
||||
-
|
||||
- if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
|
||||
- BCMA_CC_FLASH_CFG_DS) == 0)
|
||||
- pflash->buswidth = 1;
|
||||
- else
|
||||
- pflash->buswidth = 2;
|
||||
-
|
||||
- bcma_pflash_data.width = pflash->buswidth;
|
||||
- bcma_pflash_resource.start = pflash->window;
|
||||
- bcma_pflash_resource.end = pflash->window + pflash->window_size;
|
||||
-
|
||||
- break;
|
||||
- default:
|
||||
- bcma_err(bus, "Flash type not supported\n");
|
||||
- }
|
||||
-
|
||||
- if (cc->core->id.rev == 38 ||
|
||||
- bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
|
||||
- if (cc->capabilities & BCMA_CC_CAP_NFLASH) {
|
||||
- bcma_debug(bus, "Found NAND flash\n");
|
||||
- bcma_nflash_init(cc);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
/* Determine flash type this SoC boots from */
|
||||
boot_dev = bcma_boot_dev(bus);
|
||||
switch (boot_dev) {
|
||||
@@ -337,13 +278,10 @@ static void bcma_core_mips_flash_detect(
|
||||
|
||||
void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
|
||||
{
|
||||
- struct bcma_bus *bus = mcore->core->bus;
|
||||
-
|
||||
if (mcore->early_setup_done)
|
||||
return;
|
||||
|
||||
- bcma_chipco_serial_init(&bus->drv_cc);
|
||||
- bcma_core_mips_flash_detect(mcore);
|
||||
+ bcma_core_mips_nvram_init(mcore);
|
||||
|
||||
mcore->early_setup_done = true;
|
||||
}
|
||||
--- a/drivers/bcma/host_pci.c
|
||||
+++ b/drivers/bcma/host_pci.c
|
||||
@@ -294,7 +294,7 @@ static const struct pci_device_id bcma_p
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4360) },
|
||||
- { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
|
||||
+ { PCI_DEVICE_SUB(PCI_VENDOR_ID_BROADCOM, 0x4365, PCI_VENDOR_ID_DELL, 0x0016) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a0) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) },
|
||||
--- a/drivers/bcma/Kconfig
|
||||
+++ b/drivers/bcma/Kconfig
|
||||
@@ -70,6 +70,11 @@ config BCMA_DRIVER_MIPS
|
||||
|
||||
If unsure, say N
|
||||
|
||||
+config BCMA_PFLASH
|
||||
+ bool
|
||||
+ depends on BCMA_DRIVER_MIPS
|
||||
+ default y
|
||||
+
|
||||
config BCMA_SFLASH
|
||||
bool
|
||||
depends on BCMA_DRIVER_MIPS
|
||||
--- a/drivers/bcma/Makefile
|
||||
+++ b/drivers/bcma/Makefile
|
||||
@@ -1,6 +1,7 @@
|
||||
bcma-y += main.o scan.o core.o sprom.o
|
||||
bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
|
||||
bcma-y += driver_chipcommon_b.o
|
||||
+bcma-$(CONFIG_BCMA_PFLASH) += driver_chipcommon_pflash.o
|
||||
bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o
|
||||
bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o
|
||||
bcma-$(CONFIG_BCMA_DRIVER_PCI) += driver_pci.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/bcma/driver_chipcommon_pflash.c
|
||||
@@ -0,0 +1,49 @@
|
||||
+/*
|
||||
+ * Broadcom specific AMBA
|
||||
+ * ChipCommon parallel flash
|
||||
+ *
|
||||
+ * Licensed under the GNU/GPL. See COPYING for details.
|
||||
+ */
|
||||
+
|
||||
+#include "bcma_private.h"
|
||||
+
|
||||
+#include <linux/bcma/bcma.h>
|
||||
+#include <linux/mtd/physmap.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+
|
||||
+static const char * const part_probes[] = { "bcm47xxpart", NULL };
|
||||
+
|
||||
+static struct physmap_flash_data bcma_pflash_data = {
|
||||
+ .part_probe_types = part_probes,
|
||||
+};
|
||||
+
|
||||
+static struct resource bcma_pflash_resource = {
|
||||
+ .name = "bcma_pflash",
|
||||
+ .flags = IORESOURCE_MEM,
|
||||
+};
|
||||
+
|
||||
+struct platform_device bcma_pflash_dev = {
|
||||
+ .name = "physmap-flash",
|
||||
+ .dev = {
|
||||
+ .platform_data = &bcma_pflash_data,
|
||||
+ },
|
||||
+ .resource = &bcma_pflash_resource,
|
||||
+ .num_resources = 1,
|
||||
+};
|
||||
+
|
||||
+int bcma_pflash_init(struct bcma_drv_cc *cc)
|
||||
+{
|
||||
+ struct bcma_pflash *pflash = &cc->pflash;
|
||||
+
|
||||
+ pflash->present = true;
|
||||
+
|
||||
+ if (!(bcma_read32(cc->core, BCMA_CC_FLASH_CFG) & BCMA_CC_FLASH_CFG_DS))
|
||||
+ bcma_pflash_data.width = 1;
|
||||
+ else
|
||||
+ bcma_pflash_data.width = 2;
|
||||
+
|
||||
+ bcma_pflash_resource.start = BCMA_SOC_FLASH2;
|
||||
+ bcma_pflash_resource.end = BCMA_SOC_FLASH2 + BCMA_SOC_FLASH2_SZ;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
--- a/drivers/bcma/main.c
|
||||
+++ b/drivers/bcma/main.c
|
||||
@@ -325,7 +325,7 @@ static int bcma_register_devices(struct
|
||||
bcma_register_core(bus, core);
|
||||
}
|
||||
|
||||
-#ifdef CONFIG_BCMA_DRIVER_MIPS
|
||||
+#ifdef CONFIG_BCMA_PFLASH
|
||||
if (bus->drv_cc.pflash.present) {
|
||||
err = platform_device_register(&bcma_pflash_dev);
|
||||
if (err)
|
@ -1,37 +0,0 @@
|
||||
--- a/include/linux/bcm47xx_nvram.h
|
||||
+++ b/include/linux/bcm47xx_nvram.h
|
||||
@@ -10,11 +10,17 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
+#include <linux/vmalloc.h>
|
||||
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
+#ifdef CONFIG_BCM47XX_NVRAM
|
||||
int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
|
||||
int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
|
||||
int bcm47xx_nvram_gpio_pin(const char *name);
|
||||
+char *bcm47xx_nvram_get_contents(size_t *val_len);
|
||||
+static inline void bcm47xx_nvram_release_contents(char *nvram)
|
||||
+{
|
||||
+ vfree(nvram);
|
||||
+};
|
||||
#else
|
||||
static inline int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
|
||||
{
|
||||
@@ -29,6 +35,15 @@ static inline int bcm47xx_nvram_gpio_pin
|
||||
{
|
||||
return -ENOTSUPP;
|
||||
};
|
||||
+
|
||||
+static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
|
||||
+{
|
||||
+ return NULL;
|
||||
+};
|
||||
+
|
||||
+static inline void bcm47xx_nvram_release_contents(char *nvram)
|
||||
+{
|
||||
+};
|
||||
#endif
|
||||
|
||||
#endif /* __BCM47XX_NVRAM_H */
|
@ -1,33 +0,0 @@
|
||||
From 1c8a47df36d72ace8cf78eb6c228aa0f8027d3c2 Mon Sep 17 00:00:00 2001
|
||||
From: Miklos Szeredi <miklos@szeredi.hu>
|
||||
Date: Mon, 12 Oct 2015 15:56:20 +0200
|
||||
Subject: ovl: fix open in stacked overlay
|
||||
|
||||
If two overlayfs filesystems are stacked on top of each other, then we need
|
||||
recursion in ovl_d_select_inode().
|
||||
|
||||
I guess d_backing_inode() is supposed to do that. But currently it doesn't
|
||||
and that functionality is open coded in vfs_open(). This is now copied
|
||||
into ovl_d_select_inode() to fix this regression.
|
||||
|
||||
Reported-by: Alban Crequy <alban.crequy@gmail.com>
|
||||
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
|
||||
Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay...")
|
||||
Cc: David Howells <dhowells@redhat.com>
|
||||
Cc: <stable@vger.kernel.org> # v4.2+
|
||||
---
|
||||
fs/overlayfs/inode.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
--- a/fs/overlayfs/inode.c
|
||||
+++ b/fs/overlayfs/inode.c
|
||||
@@ -383,6 +383,9 @@ struct inode *ovl_d_select_inode(struct
|
||||
ovl_path_upper(dentry, &realpath);
|
||||
}
|
||||
|
||||
+ if (realpath.dentry->d_flags & DCACHE_OP_SELECT_INODE)
|
||||
+ return realpath.dentry->d_op->d_select_inode(realpath.dentry, file_flags);
|
||||
+
|
||||
return d_backing_inode(realpath.dentry);
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
From 1ae92642e5900316011736072b4fa91710840620 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Sat, 18 Jun 2016 17:53:45 +0200
|
||||
Subject: [PATCH] ubifs: Silence error output if MS_SILENT is set
|
||||
|
||||
This change completes commit
|
||||
90bea5a3f0 ("UBIFS: respect MS_SILENT mount flag")
|
||||
which already implements support for MS_SILENT except for that one
|
||||
error message which is still being displayed despite MS_SILENT being
|
||||
set. Suppress that error message as well in case MS_SILENT is set.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
[rw: massaged commit message]
|
||||
Signed-off-by: Richard Weinberger <richard@nod.at>
|
||||
---
|
||||
fs/ubifs/super.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/fs/ubifs/super.c
|
||||
+++ b/fs/ubifs/super.c
|
||||
@@ -2104,8 +2104,9 @@ static struct dentry *ubifs_mount(struct
|
||||
*/
|
||||
ubi = open_ubi(name, UBI_READONLY);
|
||||
if (IS_ERR(ubi)) {
|
||||
- pr_err("UBIFS error (pid: %d): cannot open \"%s\", error %d",
|
||||
- current->pid, name, (int)PTR_ERR(ubi));
|
||||
+ if (!(flags & MS_SILENT))
|
||||
+ pr_err("UBIFS error (pid: %d): cannot open \"%s\", error %d",
|
||||
+ current->pid, name, (int)PTR_ERR(ubi));
|
||||
return ERR_CAST(ubi);
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
From dccbc9197d2c3614f2fd6811874e1d982e4415f0 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 19 Jul 2016 00:26:55 +0200
|
||||
Subject: [PATCH] ubifs: Silence early error messages if MS_SILENT is set
|
||||
|
||||
Probe-mounting a volume too small for UBIFS results in kernel log
|
||||
polution which might irritate users.
|
||||
Address this by silencing errors which may happen during boot if the
|
||||
rootfs is e.g. squashfs (and thus rather small) stored on a UBI volume.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Richard Weinberger <richard@nod.at>
|
||||
---
|
||||
fs/ubifs/super.c | 14 +++++++-------
|
||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/fs/ubifs/super.c
|
||||
+++ b/fs/ubifs/super.c
|
||||
@@ -516,19 +516,19 @@ static int init_constants_early(struct u
|
||||
c->max_write_shift = fls(c->max_write_size) - 1;
|
||||
|
||||
if (c->leb_size < UBIFS_MIN_LEB_SZ) {
|
||||
- ubifs_err(c, "too small LEBs (%d bytes), min. is %d bytes",
|
||||
- c->leb_size, UBIFS_MIN_LEB_SZ);
|
||||
+ ubifs_errc(c, "too small LEBs (%d bytes), min. is %d bytes",
|
||||
+ c->leb_size, UBIFS_MIN_LEB_SZ);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (c->leb_cnt < UBIFS_MIN_LEB_CNT) {
|
||||
- ubifs_err(c, "too few LEBs (%d), min. is %d",
|
||||
- c->leb_cnt, UBIFS_MIN_LEB_CNT);
|
||||
+ ubifs_errc(c, "too few LEBs (%d), min. is %d",
|
||||
+ c->leb_cnt, UBIFS_MIN_LEB_CNT);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!is_power_of_2(c->min_io_size)) {
|
||||
- ubifs_err(c, "bad min. I/O size %d", c->min_io_size);
|
||||
+ ubifs_errc(c, "bad min. I/O size %d", c->min_io_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -539,8 +539,8 @@ static int init_constants_early(struct u
|
||||
if (c->max_write_size < c->min_io_size ||
|
||||
c->max_write_size % c->min_io_size ||
|
||||
!is_power_of_2(c->max_write_size)) {
|
||||
- ubifs_err(c, "bad write buffer size %d for %d min. I/O unit",
|
||||
- c->max_write_size, c->min_io_size);
|
||||
+ ubifs_errc(c, "bad write buffer size %d for %d min. I/O unit",
|
||||
+ c->max_write_size, c->min_io_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1,505 +0,0 @@
|
||||
Subject: netfilter: conntrack: cache route for forwarded connections
|
||||
|
||||
... to avoid per-packet FIB lookup if possible.
|
||||
|
||||
The cached dst is re-used provided the input interface
|
||||
is the same as that of the previous packet in the same direction.
|
||||
|
||||
If not, the cached dst is invalidated.
|
||||
|
||||
For ipv6 we also need to store sernum, else dst_check doesn't work,
|
||||
pointed out by Eric Dumazet.
|
||||
|
||||
This should speed up forwarding when conntrack is already in use
|
||||
anyway, especially when using reverse path filtering -- active RPF
|
||||
enforces two FIB lookups for each packet.
|
||||
|
||||
Before the routing cache removal this didn't matter since RPF was performed
|
||||
only when route cache didn't yield a result; but without route cache it
|
||||
comes at higher price.
|
||||
|
||||
Julian Anastasov suggested to add NETDEV_UNREGISTER handler to
|
||||
avoid holding on to dsts of 'frozen' conntracks.
|
||||
|
||||
Signed-off-by: Florian Westphal <fw@strlen.de>
|
||||
|
||||
--- a/include/net/netfilter/nf_conntrack_extend.h
|
||||
+++ b/include/net/netfilter/nf_conntrack_extend.h
|
||||
@@ -30,6 +30,9 @@ enum nf_ct_ext_id {
|
||||
#if IS_ENABLED(CONFIG_NETFILTER_SYNPROXY)
|
||||
NF_CT_EXT_SYNPROXY,
|
||||
#endif
|
||||
+#if IS_ENABLED(CONFIG_NF_CONNTRACK_RTCACHE)
|
||||
+ NF_CT_EXT_RTCACHE,
|
||||
+#endif
|
||||
NF_CT_EXT_NUM,
|
||||
};
|
||||
|
||||
@@ -43,6 +46,7 @@ enum nf_ct_ext_id {
|
||||
#define NF_CT_EXT_TIMEOUT_TYPE struct nf_conn_timeout
|
||||
#define NF_CT_EXT_LABELS_TYPE struct nf_conn_labels
|
||||
#define NF_CT_EXT_SYNPROXY_TYPE struct nf_conn_synproxy
|
||||
+#define NF_CT_EXT_RTCACHE_TYPE struct nf_conn_rtcache
|
||||
|
||||
/* Extensions: optional stuff which isn't permanently in struct. */
|
||||
struct nf_ct_ext {
|
||||
--- /dev/null
|
||||
+++ b/include/net/netfilter/nf_conntrack_rtcache.h
|
||||
@@ -0,0 +1,34 @@
|
||||
+#include <linux/gfp.h>
|
||||
+#include <net/netfilter/nf_conntrack.h>
|
||||
+#include <net/netfilter/nf_conntrack_extend.h>
|
||||
+
|
||||
+struct dst_entry;
|
||||
+
|
||||
+struct nf_conn_dst_cache {
|
||||
+ struct dst_entry *dst;
|
||||
+ int iif;
|
||||
+#if IS_ENABLED(CONFIG_NF_CONNTRACK_IPV6)
|
||||
+ u32 cookie;
|
||||
+#endif
|
||||
+
|
||||
+};
|
||||
+
|
||||
+struct nf_conn_rtcache {
|
||||
+ struct nf_conn_dst_cache cached_dst[IP_CT_DIR_MAX];
|
||||
+};
|
||||
+
|
||||
+static inline
|
||||
+struct nf_conn_rtcache *nf_ct_rtcache_find(const struct nf_conn *ct)
|
||||
+{
|
||||
+#if IS_ENABLED(CONFIG_NF_CONNTRACK_RTCACHE)
|
||||
+ return nf_ct_ext_find(ct, NF_CT_EXT_RTCACHE);
|
||||
+#else
|
||||
+ return NULL;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+static inline int nf_conn_rtcache_iif_get(const struct nf_conn_rtcache *rtc,
|
||||
+ enum ip_conntrack_dir dir)
|
||||
+{
|
||||
+ return rtc->cached_dst[dir].iif;
|
||||
+}
|
||||
--- a/net/netfilter/Kconfig
|
||||
+++ b/net/netfilter/Kconfig
|
||||
@@ -106,6 +106,18 @@ config NF_CONNTRACK_EVENTS
|
||||
|
||||
If unsure, say `N'.
|
||||
|
||||
+config NF_CONNTRACK_RTCACHE
|
||||
+ tristate "Cache route entries in conntrack objects"
|
||||
+ depends on NETFILTER_ADVANCED
|
||||
+ depends on NF_CONNTRACK
|
||||
+ help
|
||||
+ If this option is enabled, the connection tracking code will
|
||||
+ cache routing information for each connection that is being
|
||||
+ forwarded, at a cost of 32 bytes per conntrack object.
|
||||
+
|
||||
+ To compile it as a module, choose M here. If unsure, say N.
|
||||
+ The module will be called nf_conntrack_rtcache.
|
||||
+
|
||||
config NF_CONNTRACK_TIMEOUT
|
||||
bool 'Connection tracking timeout'
|
||||
depends on NETFILTER_ADVANCED
|
||||
--- a/net/netfilter/Makefile
|
||||
+++ b/net/netfilter/Makefile
|
||||
@@ -18,6 +18,9 @@ obj-$(CONFIG_NETFILTER_NETLINK_LOG) += n
|
||||
# connection tracking
|
||||
obj-$(CONFIG_NF_CONNTRACK) += nf_conntrack.o
|
||||
|
||||
+# optional conntrack route cache extension
|
||||
+obj-$(CONFIG_NF_CONNTRACK_RTCACHE) += nf_conntrack_rtcache.o
|
||||
+
|
||||
# SCTP protocol connection tracking
|
||||
obj-$(CONFIG_NF_CT_PROTO_DCCP) += nf_conntrack_proto_dccp.o
|
||||
obj-$(CONFIG_NF_CT_PROTO_GRE) += nf_conntrack_proto_gre.o
|
||||
--- /dev/null
|
||||
+++ b/net/netfilter/nf_conntrack_rtcache.c
|
||||
@@ -0,0 +1,387 @@
|
||||
+/* route cache for netfilter.
|
||||
+ *
|
||||
+ * (C) 2014 Red Hat GmbH
|
||||
+ *
|
||||
+ * 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.
|
||||
+ */
|
||||
+
|
||||
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
+
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/netfilter.h>
|
||||
+#include <linux/skbuff.h>
|
||||
+#include <linux/stddef.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/netdevice.h>
|
||||
+#include <linux/export.h>
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+#include <net/dst.h>
|
||||
+
|
||||
+#include <net/netfilter/nf_conntrack.h>
|
||||
+#include <net/netfilter/nf_conntrack_core.h>
|
||||
+#include <net/netfilter/nf_conntrack_extend.h>
|
||||
+#include <net/netfilter/nf_conntrack_rtcache.h>
|
||||
+
|
||||
+#if IS_ENABLED(CONFIG_NF_CONNTRACK_IPV6)
|
||||
+#include <net/ip6_fib.h>
|
||||
+#endif
|
||||
+
|
||||
+static void __nf_conn_rtcache_destroy(struct nf_conn_rtcache *rtc,
|
||||
+ enum ip_conntrack_dir dir)
|
||||
+{
|
||||
+ struct dst_entry *dst = rtc->cached_dst[dir].dst;
|
||||
+
|
||||
+ dst_release(dst);
|
||||
+}
|
||||
+
|
||||
+static void nf_conn_rtcache_destroy(struct nf_conn *ct)
|
||||
+{
|
||||
+ struct nf_conn_rtcache *rtc = nf_ct_rtcache_find(ct);
|
||||
+
|
||||
+ if (!rtc)
|
||||
+ return;
|
||||
+
|
||||
+ __nf_conn_rtcache_destroy(rtc, IP_CT_DIR_ORIGINAL);
|
||||
+ __nf_conn_rtcache_destroy(rtc, IP_CT_DIR_REPLY);
|
||||
+}
|
||||
+
|
||||
+static void nf_ct_rtcache_ext_add(struct nf_conn *ct)
|
||||
+{
|
||||
+ struct nf_conn_rtcache *rtc;
|
||||
+
|
||||
+ rtc = nf_ct_ext_add(ct, NF_CT_EXT_RTCACHE, GFP_ATOMIC);
|
||||
+ if (rtc) {
|
||||
+ rtc->cached_dst[IP_CT_DIR_ORIGINAL].iif = -1;
|
||||
+ rtc->cached_dst[IP_CT_DIR_ORIGINAL].dst = NULL;
|
||||
+ rtc->cached_dst[IP_CT_DIR_REPLY].iif = -1;
|
||||
+ rtc->cached_dst[IP_CT_DIR_REPLY].dst = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static struct nf_conn_rtcache *nf_ct_rtcache_find_usable(struct nf_conn *ct)
|
||||
+{
|
||||
+ if (nf_ct_is_untracked(ct))
|
||||
+ return NULL;
|
||||
+ return nf_ct_rtcache_find(ct);
|
||||
+}
|
||||
+
|
||||
+static struct dst_entry *
|
||||
+nf_conn_rtcache_dst_get(const struct nf_conn_rtcache *rtc,
|
||||
+ enum ip_conntrack_dir dir)
|
||||
+{
|
||||
+ return rtc->cached_dst[dir].dst;
|
||||
+}
|
||||
+
|
||||
+static u32 nf_rtcache_get_cookie(int pf, const struct dst_entry *dst)
|
||||
+{
|
||||
+#if IS_ENABLED(CONFIG_NF_CONNTRACK_IPV6)
|
||||
+ if (pf == NFPROTO_IPV6) {
|
||||
+ const struct rt6_info *rt = (const struct rt6_info *)dst;
|
||||
+
|
||||
+ if (rt->rt6i_node)
|
||||
+ return (u32)rt->rt6i_node->fn_sernum;
|
||||
+ }
|
||||
+#endif
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void nf_conn_rtcache_dst_set(int pf,
|
||||
+ struct nf_conn_rtcache *rtc,
|
||||
+ struct dst_entry *dst,
|
||||
+ enum ip_conntrack_dir dir, int iif)
|
||||
+{
|
||||
+ if (rtc->cached_dst[dir].iif != iif)
|
||||
+ rtc->cached_dst[dir].iif = iif;
|
||||
+
|
||||
+ if (rtc->cached_dst[dir].dst != dst) {
|
||||
+ struct dst_entry *old;
|
||||
+
|
||||
+ dst_hold(dst);
|
||||
+
|
||||
+ old = xchg(&rtc->cached_dst[dir].dst, dst);
|
||||
+ dst_release(old);
|
||||
+
|
||||
+#if IS_ENABLED(CONFIG_NF_CONNTRACK_IPV6)
|
||||
+ if (pf == NFPROTO_IPV6)
|
||||
+ rtc->cached_dst[dir].cookie =
|
||||
+ nf_rtcache_get_cookie(pf, dst);
|
||||
+#endif
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void nf_conn_rtcache_dst_obsolete(struct nf_conn_rtcache *rtc,
|
||||
+ enum ip_conntrack_dir dir)
|
||||
+{
|
||||
+ struct dst_entry *old;
|
||||
+
|
||||
+ pr_debug("Invalidate iif %d for dir %d on cache %p\n",
|
||||
+ rtc->cached_dst[dir].iif, dir, rtc);
|
||||
+
|
||||
+ old = xchg(&rtc->cached_dst[dir].dst, NULL);
|
||||
+ dst_release(old);
|
||||
+ rtc->cached_dst[dir].iif = -1;
|
||||
+}
|
||||
+
|
||||
+static unsigned int nf_rtcache_in(const struct nf_hook_ops *ops,
|
||||
+ struct sk_buff *skb,
|
||||
+ const struct nf_hook_state *state)
|
||||
+{
|
||||
+ struct nf_conn_rtcache *rtc;
|
||||
+ enum ip_conntrack_info ctinfo;
|
||||
+ enum ip_conntrack_dir dir;
|
||||
+ struct dst_entry *dst;
|
||||
+ struct nf_conn *ct;
|
||||
+ int iif;
|
||||
+ u32 cookie;
|
||||
+
|
||||
+ if (skb_dst(skb) || skb->sk)
|
||||
+ return NF_ACCEPT;
|
||||
+
|
||||
+ ct = nf_ct_get(skb, &ctinfo);
|
||||
+ if (!ct)
|
||||
+ return NF_ACCEPT;
|
||||
+
|
||||
+ rtc = nf_ct_rtcache_find_usable(ct);
|
||||
+ if (!rtc)
|
||||
+ return NF_ACCEPT;
|
||||
+
|
||||
+ /* if iif changes, don't use cache and let ip stack
|
||||
+ * do route lookup.
|
||||
+ *
|
||||
+ * If rp_filter is enabled it might toss skb, so
|
||||
+ * we don't want to avoid these checks.
|
||||
+ */
|
||||
+ dir = CTINFO2DIR(ctinfo);
|
||||
+ iif = nf_conn_rtcache_iif_get(rtc, dir);
|
||||
+ if (state->in->ifindex != iif) {
|
||||
+ pr_debug("ct %p, iif %d, cached iif %d, skip cached entry\n",
|
||||
+ ct, iif, state->in->ifindex);
|
||||
+ return NF_ACCEPT;
|
||||
+ }
|
||||
+ dst = nf_conn_rtcache_dst_get(rtc, dir);
|
||||
+ if (dst == NULL)
|
||||
+ return NF_ACCEPT;
|
||||
+
|
||||
+ cookie = nf_rtcache_get_cookie(ops->pf, dst);
|
||||
+
|
||||
+ dst = dst_check(dst, cookie);
|
||||
+ pr_debug("obtained dst %p for skb %p, cookie %d\n", dst, skb, cookie);
|
||||
+ if (likely(dst))
|
||||
+ skb_dst_set_noref(skb, dst);
|
||||
+ else
|
||||
+ nf_conn_rtcache_dst_obsolete(rtc, dir);
|
||||
+
|
||||
+ return NF_ACCEPT;
|
||||
+}
|
||||
+
|
||||
+static unsigned int nf_rtcache_forward(const struct nf_hook_ops *ops,
|
||||
+ struct sk_buff *skb,
|
||||
+ const struct nf_hook_state *state)
|
||||
+{
|
||||
+ struct nf_conn_rtcache *rtc;
|
||||
+ enum ip_conntrack_info ctinfo;
|
||||
+ enum ip_conntrack_dir dir;
|
||||
+ struct nf_conn *ct;
|
||||
+ struct dst_entry *dst = skb_dst(skb);
|
||||
+ int iif;
|
||||
+
|
||||
+ ct = nf_ct_get(skb, &ctinfo);
|
||||
+ if (!ct)
|
||||
+ return NF_ACCEPT;
|
||||
+
|
||||
+ if (dst && dst_xfrm(dst))
|
||||
+ return NF_ACCEPT;
|
||||
+
|
||||
+ if (!nf_ct_is_confirmed(ct)) {
|
||||
+ if (WARN_ON(nf_ct_rtcache_find(ct)))
|
||||
+ return NF_ACCEPT;
|
||||
+ nf_ct_rtcache_ext_add(ct);
|
||||
+ return NF_ACCEPT;
|
||||
+ }
|
||||
+
|
||||
+ rtc = nf_ct_rtcache_find_usable(ct);
|
||||
+ if (!rtc)
|
||||
+ return NF_ACCEPT;
|
||||
+
|
||||
+ dir = CTINFO2DIR(ctinfo);
|
||||
+ iif = nf_conn_rtcache_iif_get(rtc, dir);
|
||||
+ pr_debug("ct %p, skb %p, dir %d, iif %d, cached iif %d\n",
|
||||
+ ct, skb, dir, iif, state->in->ifindex);
|
||||
+ if (likely(state->in->ifindex == iif))
|
||||
+ return NF_ACCEPT;
|
||||
+
|
||||
+ nf_conn_rtcache_dst_set(ops->pf, rtc, skb_dst(skb), dir, state->in->ifindex);
|
||||
+ return NF_ACCEPT;
|
||||
+}
|
||||
+
|
||||
+static int nf_rtcache_dst_remove(struct nf_conn *ct, void *data)
|
||||
+{
|
||||
+ struct nf_conn_rtcache *rtc = nf_ct_rtcache_find(ct);
|
||||
+ struct net_device *dev = data;
|
||||
+
|
||||
+ if (!rtc)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (dev->ifindex == rtc->cached_dst[IP_CT_DIR_ORIGINAL].iif ||
|
||||
+ dev->ifindex == rtc->cached_dst[IP_CT_DIR_REPLY].iif) {
|
||||
+ nf_conn_rtcache_dst_obsolete(rtc, IP_CT_DIR_ORIGINAL);
|
||||
+ nf_conn_rtcache_dst_obsolete(rtc, IP_CT_DIR_REPLY);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int nf_rtcache_netdev_event(struct notifier_block *this,
|
||||
+ unsigned long event, void *ptr)
|
||||
+{
|
||||
+ struct net_device *dev = netdev_notifier_info_to_dev(ptr);
|
||||
+ struct net *net = dev_net(dev);
|
||||
+
|
||||
+ if (event == NETDEV_DOWN)
|
||||
+ nf_ct_iterate_cleanup(net, nf_rtcache_dst_remove, dev, 0, 0);
|
||||
+
|
||||
+ return NOTIFY_DONE;
|
||||
+}
|
||||
+
|
||||
+static struct notifier_block nf_rtcache_notifier = {
|
||||
+ .notifier_call = nf_rtcache_netdev_event,
|
||||
+};
|
||||
+
|
||||
+static struct nf_hook_ops rtcache_ops[] = {
|
||||
+ {
|
||||
+ .hook = nf_rtcache_in,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .pf = NFPROTO_IPV4,
|
||||
+ .hooknum = NF_INET_PRE_ROUTING,
|
||||
+ .priority = NF_IP_PRI_LAST,
|
||||
+ },
|
||||
+ {
|
||||
+ .hook = nf_rtcache_forward,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .pf = NFPROTO_IPV4,
|
||||
+ .hooknum = NF_INET_FORWARD,
|
||||
+ .priority = NF_IP_PRI_LAST,
|
||||
+ },
|
||||
+#if IS_ENABLED(CONFIG_NF_CONNTRACK_IPV6)
|
||||
+ {
|
||||
+ .hook = nf_rtcache_in,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .pf = NFPROTO_IPV6,
|
||||
+ .hooknum = NF_INET_PRE_ROUTING,
|
||||
+ .priority = NF_IP_PRI_LAST,
|
||||
+ },
|
||||
+ {
|
||||
+ .hook = nf_rtcache_forward,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .pf = NFPROTO_IPV6,
|
||||
+ .hooknum = NF_INET_FORWARD,
|
||||
+ .priority = NF_IP_PRI_LAST,
|
||||
+ },
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+static struct nf_ct_ext_type rtcache_extend __read_mostly = {
|
||||
+ .len = sizeof(struct nf_conn_rtcache),
|
||||
+ .align = __alignof__(struct nf_conn_rtcache),
|
||||
+ .id = NF_CT_EXT_RTCACHE,
|
||||
+ .destroy = nf_conn_rtcache_destroy,
|
||||
+};
|
||||
+
|
||||
+static int __init nf_conntrack_rtcache_init(void)
|
||||
+{
|
||||
+ int ret = nf_ct_extend_register(&rtcache_extend);
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ pr_err("nf_conntrack_rtcache: Unable to register extension\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = nf_register_hooks(rtcache_ops, ARRAY_SIZE(rtcache_ops));
|
||||
+ if (ret < 0) {
|
||||
+ nf_ct_extend_unregister(&rtcache_extend);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = register_netdevice_notifier(&nf_rtcache_notifier);
|
||||
+ if (ret) {
|
||||
+ nf_unregister_hooks(rtcache_ops, ARRAY_SIZE(rtcache_ops));
|
||||
+ nf_ct_extend_unregister(&rtcache_extend);
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int nf_rtcache_ext_remove(struct nf_conn *ct, void *data)
|
||||
+{
|
||||
+ struct nf_conn_rtcache *rtc = nf_ct_rtcache_find(ct);
|
||||
+
|
||||
+ return rtc != NULL;
|
||||
+}
|
||||
+
|
||||
+static bool __exit nf_conntrack_rtcache_wait_for_dying(struct net *net)
|
||||
+{
|
||||
+ bool wait = false;
|
||||
+ int cpu;
|
||||
+
|
||||
+ for_each_possible_cpu(cpu) {
|
||||
+ struct nf_conntrack_tuple_hash *h;
|
||||
+ struct hlist_nulls_node *n;
|
||||
+ struct nf_conn *ct;
|
||||
+ struct ct_pcpu *pcpu = per_cpu_ptr(net->ct.pcpu_lists, cpu);
|
||||
+
|
||||
+ rcu_read_lock();
|
||||
+ spin_lock_bh(&pcpu->lock);
|
||||
+
|
||||
+ hlist_nulls_for_each_entry(h, n, &pcpu->dying, hnnode) {
|
||||
+ ct = nf_ct_tuplehash_to_ctrack(h);
|
||||
+ if (nf_ct_rtcache_find(ct) != NULL) {
|
||||
+ wait = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ spin_unlock_bh(&pcpu->lock);
|
||||
+ rcu_read_unlock();
|
||||
+ }
|
||||
+
|
||||
+ return wait;
|
||||
+}
|
||||
+
|
||||
+static void __exit nf_conntrack_rtcache_fini(void)
|
||||
+{
|
||||
+ struct net *net;
|
||||
+ int count = 0;
|
||||
+
|
||||
+ /* remove hooks so no new connections get rtcache extension */
|
||||
+ nf_unregister_hooks(rtcache_ops, ARRAY_SIZE(rtcache_ops));
|
||||
+
|
||||
+ synchronize_net();
|
||||
+
|
||||
+ unregister_netdevice_notifier(&nf_rtcache_notifier);
|
||||
+
|
||||
+ rtnl_lock();
|
||||
+
|
||||
+ /* zap all conntracks with rtcache extension */
|
||||
+ for_each_net(net)
|
||||
+ nf_ct_iterate_cleanup(net, nf_rtcache_ext_remove, NULL, 0, 0);
|
||||
+
|
||||
+ for_each_net(net) {
|
||||
+ /* .. and make sure they're gone from dying list, too */
|
||||
+ while (nf_conntrack_rtcache_wait_for_dying(net)) {
|
||||
+ msleep(200);
|
||||
+ WARN_ONCE(++count > 25, "Waiting for all rtcache conntracks to go away\n");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ rtnl_unlock();
|
||||
+ synchronize_net();
|
||||
+ nf_ct_extend_unregister(&rtcache_extend);
|
||||
+}
|
||||
+module_init(nf_conntrack_rtcache_init);
|
||||
+module_exit(nf_conntrack_rtcache_fini);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_AUTHOR("Florian Westphal <fw@strlen.de>");
|
||||
+MODULE_DESCRIPTION("Conntrack route cache extension");
|
@ -1,22 +0,0 @@
|
||||
--- a/arch/mips/boot/compressed/string.c
|
||||
+++ b/arch/mips/boot/compressed/string.c
|
||||
@@ -26,3 +26,19 @@ void *memset(void *s, int c, size_t n)
|
||||
ss[i] = c;
|
||||
return s;
|
||||
}
|
||||
+
|
||||
+void *memmove(void *__dest, __const void *__src, size_t count)
|
||||
+{
|
||||
+ unsigned char *d = __dest;
|
||||
+ const unsigned char *s = __src;
|
||||
+
|
||||
+ if (__dest == __src)
|
||||
+ return __dest;
|
||||
+
|
||||
+ if (__dest < __src)
|
||||
+ return memcpy(__dest, __src, count);
|
||||
+
|
||||
+ while (count--)
|
||||
+ d[count] = s[count];
|
||||
+ return __dest;
|
||||
+}
|
@ -1,24 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Mon, 13 Apr 2015 15:54:04 +0200
|
||||
Subject: [PATCH] bgmac: fix MAC soft-reset bit for corerev > 4
|
||||
|
||||
Only core revisions older than 4 use BGMAC_CMDCFG_SR_REV0
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/drivers/net/ethernet/broadcom/bgmac.h
|
||||
+++ b/drivers/net/ethernet/broadcom/bgmac.h
|
||||
@@ -198,9 +198,9 @@
|
||||
#define BGMAC_CMDCFG_TAI 0x00000200
|
||||
#define BGMAC_CMDCFG_HD 0x00000400 /* Set if in half duplex mode */
|
||||
#define BGMAC_CMDCFG_HD_SHIFT 10
|
||||
-#define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for other revs */
|
||||
-#define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, only for core rev 4 */
|
||||
-#define BGMAC_CMDCFG_SR(rev) ((rev == 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
|
||||
+#define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for core rev 0-3 */
|
||||
+#define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, for core rev >= 4 */
|
||||
+#define BGMAC_CMDCFG_SR(rev) ((rev >= 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0)
|
||||
#define BGMAC_CMDCFG_ML 0x00008000 /* Set to activate mac loopback mode */
|
||||
#define BGMAC_CMDCFG_AE 0x00400000
|
||||
#define BGMAC_CMDCFG_CFE 0x00800000
|
@ -1,28 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Mon, 13 Apr 2015 15:56:26 +0200
|
||||
Subject: [PATCH] bgmac: reset all 4 GMAC cores on init
|
||||
|
||||
On a BCM4709 based device, I found that GMAC cores may be enabled at
|
||||
probe time, but only become usable after a full reset.
|
||||
Disable cores before re-enabling them to ensure that they are properly
|
||||
reset.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/drivers/net/ethernet/broadcom/bgmac.c
|
||||
+++ b/drivers/net/ethernet/broadcom/bgmac.c
|
||||
@@ -1623,8 +1623,11 @@ static int bgmac_probe(struct bcma_devic
|
||||
ns_core = bcma_find_core_unit(core->bus,
|
||||
BCMA_CORE_MAC_GBIT,
|
||||
ns_gmac);
|
||||
- if (ns_core && !bcma_core_is_enabled(ns_core))
|
||||
- bcma_core_enable(ns_core, 0);
|
||||
+ if (!ns_core)
|
||||
+ continue;
|
||||
+
|
||||
+ bcma_core_disable(ns_core, 0);
|
||||
+ bcma_core_enable(ns_core, 0);
|
||||
}
|
||||
}
|
||||
|
@ -1,101 +0,0 @@
|
||||
From: Florian Westphal <fw@strlen.de>
|
||||
Date: Thu, 17 Sep 2015 11:24:48 +0100
|
||||
Subject: [PATCH] ipv6: ip6_fragment: fix headroom tests and skb leak
|
||||
|
||||
David Woodhouse reports skb_under_panic when we try to push ethernet
|
||||
header to fragmented ipv6 skbs:
|
||||
|
||||
skbuff: skb_under_panic: text:c1277f1e len:1294 put:14 head:dec98000
|
||||
data:dec97ffc tail:0xdec9850a end:0xdec98f40 dev:br-lan
|
||||
[..]
|
||||
ip6_finish_output2+0x196/0x4da
|
||||
|
||||
David further debugged this:
|
||||
[..] offending fragments were arriving here with skb_headroom(skb)==10.
|
||||
Which is reasonable, being the Solos ADSL card's header of 8 bytes
|
||||
followed by 2 bytes of PPP frame type.
|
||||
|
||||
The problem is that if netfilter ipv6 defragmentation is used, skb_cow()
|
||||
in ip6_forward will only see reassembled skb.
|
||||
|
||||
Therefore, headroom is overestimated by 8 bytes (we pulled fragment
|
||||
header) and we don't check the skbs in the frag_list either.
|
||||
|
||||
We can't do these checks in netfilter defrag since outdev isn't known yet.
|
||||
|
||||
Furthermore, existing tests in ip6_fragment did not consider the fragment
|
||||
or ipv6 header size when checking headroom of the fraglist skbs.
|
||||
|
||||
While at it, also fix a skb leak on memory allocation -- ip6_fragment
|
||||
must consume the skb.
|
||||
|
||||
I tested this e1000 driver hacked to not allocate additional headroom
|
||||
(we end up in slowpath, since LL_RESERVED_SPACE is 16).
|
||||
|
||||
If 2 bytes of headroom are allocated, fastpath is taken (14 byte
|
||||
ethernet header was pulled, so 16 byte headroom available in all
|
||||
fragments).
|
||||
|
||||
Reported-by: David Woodhouse <dwmw2@infradead.org>
|
||||
Diagnosed-by: David Woodhouse <dwmw2@infradead.org>
|
||||
Signed-off-by: Florian Westphal <fw@strlen.de>
|
||||
Closes 20532
|
||||
---
|
||||
|
||||
--- a/net/ipv6/ip6_output.c
|
||||
+++ b/net/ipv6/ip6_output.c
|
||||
@@ -587,20 +587,22 @@ int ip6_fragment(struct sock *sk, struct
|
||||
}
|
||||
mtu -= hlen + sizeof(struct frag_hdr);
|
||||
|
||||
+ hroom = LL_RESERVED_SPACE(rt->dst.dev);
|
||||
if (skb_has_frag_list(skb)) {
|
||||
int first_len = skb_pagelen(skb);
|
||||
struct sk_buff *frag2;
|
||||
|
||||
if (first_len - hlen > mtu ||
|
||||
((first_len - hlen) & 7) ||
|
||||
- skb_cloned(skb))
|
||||
+ skb_cloned(skb) ||
|
||||
+ skb_headroom(skb) < (hroom + sizeof(struct frag_hdr)))
|
||||
goto slow_path;
|
||||
|
||||
skb_walk_frags(skb, frag) {
|
||||
/* Correct geometry. */
|
||||
if (frag->len > mtu ||
|
||||
((frag->len & 7) && frag->next) ||
|
||||
- skb_headroom(frag) < hlen)
|
||||
+ skb_headroom(frag) < (hlen + hroom + sizeof(struct frag_hdr)))
|
||||
goto slow_path_clean;
|
||||
|
||||
/* Partially cloned skb? */
|
||||
@@ -617,8 +619,6 @@ int ip6_fragment(struct sock *sk, struct
|
||||
|
||||
err = 0;
|
||||
offset = 0;
|
||||
- frag = skb_shinfo(skb)->frag_list;
|
||||
- skb_frag_list_init(skb);
|
||||
/* BUILD HEADER */
|
||||
|
||||
*prevhdr = NEXTHDR_FRAGMENT;
|
||||
@@ -626,8 +626,11 @@ int ip6_fragment(struct sock *sk, struct
|
||||
if (!tmp_hdr) {
|
||||
IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
|
||||
IPSTATS_MIB_FRAGFAILS);
|
||||
- return -ENOMEM;
|
||||
+ err = -ENOMEM;
|
||||
+ goto fail;
|
||||
}
|
||||
+ frag = skb_shinfo(skb)->frag_list;
|
||||
+ skb_frag_list_init(skb);
|
||||
|
||||
__skb_pull(skb, hlen);
|
||||
fh = (struct frag_hdr *)__skb_push(skb, sizeof(struct frag_hdr));
|
||||
@@ -725,7 +728,6 @@ slow_path:
|
||||
*/
|
||||
|
||||
*prevhdr = NEXTHDR_FRAGMENT;
|
||||
- hroom = LL_RESERVED_SPACE(rt->dst.dev);
|
||||
troom = rt->dst.dev->needed_tailroom;
|
||||
|
||||
/*
|
@ -1,54 +0,0 @@
|
||||
From: David Woodhouse <dwmw2@infradead.org>
|
||||
Date: Thu, 17 Sep 2015 11:19:53 +0100
|
||||
Subject: [PATCH] solos-pci: Increase headroom on received packets
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
A comment in include/linux/skbuff.h says that:
|
||||
|
||||
* Various parts of the networking layer expect at least 32 bytes of
|
||||
* headroom, you should not reduce this.
|
||||
|
||||
This was demonstrated by a panic when handling fragmented IPv6 packets:
|
||||
http://marc.info/?l=linux-netdev&m=144236093519172&w=2
|
||||
|
||||
It's not entirely clear if that comment is still valid — and if it is,
|
||||
perhaps netif_rx() ought to be enforcing it with a warning.
|
||||
|
||||
But either way, it is rather stupid from a performance point of view
|
||||
for us to be receiving packets into a buffer which doesn't have enough
|
||||
room to prepend an Ethernet header — it means that *every* incoming
|
||||
packet is going to be need to be reallocated. So let's fix that.
|
||||
|
||||
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
|
||||
---
|
||||
|
||||
--- a/drivers/atm/solos-pci.c
|
||||
+++ b/drivers/atm/solos-pci.c
|
||||
@@ -805,7 +805,12 @@ static void solos_bh(unsigned long card_
|
||||
continue;
|
||||
}
|
||||
|
||||
- skb = alloc_skb(size + 1, GFP_ATOMIC);
|
||||
+ /* Use netdev_alloc_skb() because it adds NET_SKB_PAD of
|
||||
+ * headroom, and ensures we can route packets back out an
|
||||
+ * Ethernet interface (for example) without having to
|
||||
+ * reallocate. Adding NET_IP_ALIGN also ensures that both
|
||||
+ * PPPoATM and PPPoEoBR2684 packets end up aligned. */
|
||||
+ skb = netdev_alloc_skb_ip_align(NULL, size + 1);
|
||||
if (!skb) {
|
||||
if (net_ratelimit())
|
||||
dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n");
|
||||
@@ -869,7 +874,10 @@ static void solos_bh(unsigned long card_
|
||||
/* Allocate RX skbs for any ports which need them */
|
||||
if (card->using_dma && card->atmdev[port] &&
|
||||
!card->rx_skb[port]) {
|
||||
- struct sk_buff *skb = alloc_skb(RX_DMA_SIZE, GFP_ATOMIC);
|
||||
+ /* Unlike the MMIO case (qv) we can't add NET_IP_ALIGN
|
||||
+ * here; the FPGA can only DMA to addresses which are
|
||||
+ * aligned to 4 bytes. */
|
||||
+ struct sk_buff *skb = dev_alloc_skb(RX_DMA_SIZE);
|
||||
if (skb) {
|
||||
SKB_CB(skb)->dma_addr =
|
||||
dma_map_single(&card->dev->dev, skb->data,
|
@ -1,464 +0,0 @@
|
||||
From 0f247626cbbfa2010d2b86fdee652605e084e248 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Fri, 16 Sep 2016 16:13:48 +0200
|
||||
Subject: [PATCH] usb: core: Introduce a USB port LED trigger
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This commit adds a new trigger responsible for turning on LED when USB
|
||||
device gets connected to the selected USB port. This can can useful for
|
||||
various home routers that have USB port(s) and a proper LED telling user
|
||||
a device is connected.
|
||||
|
||||
The trigger gets its documentation file but basically it just requires
|
||||
enabling it and selecting USB ports (e.g. echo 1 > ports/usb1-1).
|
||||
|
||||
There was a long discussion on design of this driver. Its current state
|
||||
is a result of picking them most adjustable solution as others couldn't
|
||||
handle all cases.
|
||||
|
||||
1) It wasn't possible for the driver to register separated trigger for
|
||||
each USB port. Some physical USB ports are handled by more than one
|
||||
controller and so by more than one USB port. E.g. USB 2.0 physical
|
||||
port may be handled by OHCI's port and EHCI's port.
|
||||
It's also not possible to assign more than 1 trigger to a single LED
|
||||
and implementing such feature would be tricky due to syncing triggers
|
||||
and sysfs conflicts with old triggers.
|
||||
|
||||
2) Another idea was to register trigger per USB hub. This wouldn't allow
|
||||
handling devices with multiple USB LEDs and controllers (hubs)
|
||||
controlling more than 1 physical port. It's common for hubs to have
|
||||
few ports and each may have its own LED.
|
||||
|
||||
This final trigger is highly flexible. It allows selecting any USB ports
|
||||
for any LED. It was also modified (comparing to the initial version) to
|
||||
allow choosing ports rather than having user /guess/ proper names. It
|
||||
was successfully tested on SmartRG SR400ac which has 3 USB LEDs,
|
||||
2 physical ports and 3 controllers.
|
||||
|
||||
It was noted USB subsystem already has usb-gadget and usb-host triggers
|
||||
but they are pretty trivial ones. They indicate activity only and can't
|
||||
have ports specified.
|
||||
|
||||
In future it may be good idea to consider adding activity support to
|
||||
usbport as well. This should allow switching to this more generic driver
|
||||
and maybe marking old ones as obsolete.
|
||||
This can be implemented with another sysfs file for setting mode. The
|
||||
default mode wouldn't change so there won't be ABI breakage and so such
|
||||
feature can be safely implemented later.
|
||||
|
||||
There was also an idea of supporting other devices (PCI, SDIO, etc.) but
|
||||
as this driver already contains some USB specific code (and will get
|
||||
more) these should be probably separated drivers (triggers).
|
||||
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
.../ABI/testing/sysfs-class-led-trigger-usbport | 12 +
|
||||
Documentation/leds/ledtrig-usbport.txt | 41 +++
|
||||
drivers/usb/core/Kconfig | 8 +
|
||||
drivers/usb/core/Makefile | 2 +
|
||||
drivers/usb/core/ledtrig-usbport.c | 314 +++++++++++++++++++++
|
||||
5 files changed, 377 insertions(+)
|
||||
create mode 100644 Documentation/ABI/testing/sysfs-class-led-trigger-usbport
|
||||
create mode 100644 Documentation/leds/ledtrig-usbport.txt
|
||||
create mode 100644 drivers/usb/core/ledtrig-usbport.c
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/ABI/testing/sysfs-class-led-trigger-usbport
|
||||
@@ -0,0 +1,12 @@
|
||||
+What: /sys/class/leds/<led>/ports/<port>
|
||||
+Date: September 2016
|
||||
+KernelVersion: 4.9
|
||||
+Contact: linux-leds@vger.kernel.org
|
||||
+ linux-usb@vger.kernel.org
|
||||
+Description:
|
||||
+ Every dir entry represents a single USB port that can be
|
||||
+ selected for the USB port trigger. Selecting ports makes trigger
|
||||
+ observing them for any connected devices and lighting on LED if
|
||||
+ there are any.
|
||||
+ Echoing "1" value selects USB port. Echoing "0" unselects it.
|
||||
+ Current state can be also read.
|
||||
--- /dev/null
|
||||
+++ b/Documentation/leds/ledtrig-usbport.txt
|
||||
@@ -0,0 +1,41 @@
|
||||
+USB port LED trigger
|
||||
+====================
|
||||
+
|
||||
+This LED trigger can be used for signalling to the user a presence of USB device
|
||||
+in a given port. It simply turns on LED when device appears and turns it off
|
||||
+when it disappears.
|
||||
+
|
||||
+It requires selecting USB ports that should be observed. All available ones are
|
||||
+listed as separated entries in a "ports" subdirectory. Selecting is handled by
|
||||
+echoing "1" to a chosen port.
|
||||
+
|
||||
+Please note that this trigger allows selecting multiple USB ports for a single
|
||||
+LED. This can be useful in two cases:
|
||||
+
|
||||
+1) Device with single USB LED and few physical ports
|
||||
+
|
||||
+In such a case LED will be turned on as long as there is at least one connected
|
||||
+USB device.
|
||||
+
|
||||
+2) Device with a physical port handled by few controllers
|
||||
+
|
||||
+Some devices may have one controller per PHY standard. E.g. USB 3.0 physical
|
||||
+port may be handled by ohci-platform, ehci-platform and xhci-hcd. If there is
|
||||
+only one LED user will most likely want to assign ports from all 3 hubs.
|
||||
+
|
||||
+
|
||||
+This trigger can be activated from user space on led class devices as shown
|
||||
+below:
|
||||
+
|
||||
+ echo usbport > trigger
|
||||
+
|
||||
+This adds sysfs attributes to the LED that are documented in:
|
||||
+Documentation/ABI/testing/sysfs-class-led-trigger-usbport
|
||||
+
|
||||
+Example use-case:
|
||||
+
|
||||
+ echo usbport > trigger
|
||||
+ echo 1 > ports/usb1-port1
|
||||
+ echo 1 > ports/usb2-port1
|
||||
+ cat ports/usb1-port1
|
||||
+ echo 0 > ports/usb1-port1
|
||||
--- a/drivers/usb/core/Kconfig
|
||||
+++ b/drivers/usb/core/Kconfig
|
||||
@@ -84,3 +84,10 @@ config USB_OTG_FSM
|
||||
Implements OTG Finite State Machine as specified in On-The-Go
|
||||
and Embedded Host Supplement to the USB Revision 2.0 Specification.
|
||||
|
||||
+config USB_LEDS_TRIGGER_USBPORT
|
||||
+ tristate "USB port LED trigger"
|
||||
+ depends on USB && LEDS_TRIGGERS
|
||||
+ help
|
||||
+ This driver allows LEDs to be controlled by USB events. Enabling this
|
||||
+ trigger allows specifying list of USB ports that should turn on LED
|
||||
+ when some USB device gets connected.
|
||||
--- a/drivers/usb/core/Makefile
|
||||
+++ b/drivers/usb/core/Makefile
|
||||
@@ -11,3 +11,5 @@ usbcore-$(CONFIG_PCI) += hcd-pci.o
|
||||
usbcore-$(CONFIG_ACPI) += usb-acpi.o
|
||||
|
||||
obj-$(CONFIG_USB) += usbcore.o
|
||||
+
|
||||
+obj-$(CONFIG_USB_LEDS_TRIGGER_USBPORT) += ledtrig-usbport.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/usb/core/ledtrig-usbport.c
|
||||
@@ -0,0 +1,314 @@
|
||||
+/*
|
||||
+ * USB port LED trigger
|
||||
+ *
|
||||
+ * Copyright (C) 2016 Rafał Miłecki <rafal@milecki.pl>
|
||||
+ *
|
||||
+ * 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 <linux/device.h>
|
||||
+#include <linux/leds.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/usb.h>
|
||||
+
|
||||
+struct usbport_trig_data {
|
||||
+ struct led_classdev *led_cdev;
|
||||
+ struct list_head ports;
|
||||
+ struct notifier_block nb;
|
||||
+ int count; /* Amount of connected matching devices */
|
||||
+};
|
||||
+
|
||||
+struct usbport_trig_port {
|
||||
+ struct usbport_trig_data *data;
|
||||
+ struct usb_device *hub;
|
||||
+ int portnum;
|
||||
+ char *port_name;
|
||||
+ bool observed;
|
||||
+ struct device_attribute attr;
|
||||
+ struct list_head list;
|
||||
+};
|
||||
+
|
||||
+/***************************************
|
||||
+ * Helpers
|
||||
+ ***************************************/
|
||||
+
|
||||
+/**
|
||||
+ * usbport_trig_usb_dev_observed - Check if dev is connected to observed port
|
||||
+ */
|
||||
+static bool usbport_trig_usb_dev_observed(struct usbport_trig_data *usbport_data,
|
||||
+ struct usb_device *usb_dev)
|
||||
+{
|
||||
+ struct usbport_trig_port *port;
|
||||
+
|
||||
+ if (!usb_dev->parent)
|
||||
+ return false;
|
||||
+
|
||||
+ list_for_each_entry(port, &usbport_data->ports, list) {
|
||||
+ if (usb_dev->parent == port->hub &&
|
||||
+ usb_dev->portnum == port->portnum)
|
||||
+ return port->observed;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static int usbport_trig_usb_dev_check(struct usb_device *usb_dev, void *data)
|
||||
+{
|
||||
+ struct usbport_trig_data *usbport_data = data;
|
||||
+
|
||||
+ if (usbport_trig_usb_dev_observed(usbport_data, usb_dev))
|
||||
+ usbport_data->count++;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * usbport_trig_update_count - Recalculate amount of connected matching devices
|
||||
+ */
|
||||
+static void usbport_trig_update_count(struct usbport_trig_data *usbport_data)
|
||||
+{
|
||||
+ struct led_classdev *led_cdev = usbport_data->led_cdev;
|
||||
+
|
||||
+ usbport_data->count = 0;
|
||||
+ usb_for_each_dev(usbport_data, usbport_trig_usb_dev_check);
|
||||
+ led_cdev->brightness_set(led_cdev,
|
||||
+ usbport_data->count ? LED_FULL : LED_OFF);
|
||||
+}
|
||||
+
|
||||
+/***************************************
|
||||
+ * Device attr
|
||||
+ ***************************************/
|
||||
+
|
||||
+static ssize_t usbport_trig_port_show(struct device *dev,
|
||||
+ struct device_attribute *attr, char *buf)
|
||||
+{
|
||||
+ struct usbport_trig_port *port = container_of(attr,
|
||||
+ struct usbport_trig_port,
|
||||
+ attr);
|
||||
+
|
||||
+ return sprintf(buf, "%d\n", port->observed) + 1;
|
||||
+}
|
||||
+
|
||||
+static ssize_t usbport_trig_port_store(struct device *dev,
|
||||
+ struct device_attribute *attr,
|
||||
+ const char *buf, size_t size)
|
||||
+{
|
||||
+ struct usbport_trig_port *port = container_of(attr,
|
||||
+ struct usbport_trig_port,
|
||||
+ attr);
|
||||
+
|
||||
+ if (!strcmp(buf, "0") || !strcmp(buf, "0\n"))
|
||||
+ port->observed = 0;
|
||||
+ else if (!strcmp(buf, "1") || !strcmp(buf, "1\n"))
|
||||
+ port->observed = 1;
|
||||
+ else
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ usbport_trig_update_count(port->data);
|
||||
+
|
||||
+ return size;
|
||||
+}
|
||||
+
|
||||
+static struct attribute *ports_attrs[] = {
|
||||
+ NULL,
|
||||
+};
|
||||
+static const struct attribute_group ports_group = {
|
||||
+ .name = "ports",
|
||||
+ .attrs = ports_attrs,
|
||||
+};
|
||||
+
|
||||
+/***************************************
|
||||
+ * Adding & removing ports
|
||||
+ ***************************************/
|
||||
+
|
||||
+static int usbport_trig_add_port(struct usbport_trig_data *usbport_data,
|
||||
+ struct usb_device *usb_dev,
|
||||
+ const char *hub_name, int portnum)
|
||||
+{
|
||||
+ struct led_classdev *led_cdev = usbport_data->led_cdev;
|
||||
+ struct usbport_trig_port *port;
|
||||
+ size_t len;
|
||||
+ int err;
|
||||
+
|
||||
+ port = kzalloc(sizeof(*port), GFP_KERNEL);
|
||||
+ if (!port) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto err_out;
|
||||
+ }
|
||||
+
|
||||
+ port->data = usbport_data;
|
||||
+ port->hub = usb_dev;
|
||||
+ port->portnum = portnum;
|
||||
+
|
||||
+ len = strlen(hub_name) + 8;
|
||||
+ port->port_name = kzalloc(len, GFP_KERNEL);
|
||||
+ if (!port->port_name) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto err_free_port;
|
||||
+ }
|
||||
+ snprintf(port->port_name, len, "%s-port%d", hub_name, portnum);
|
||||
+
|
||||
+ port->attr.attr.name = port->port_name;
|
||||
+ port->attr.attr.mode = S_IRUSR | S_IWUSR;
|
||||
+ port->attr.show = usbport_trig_port_show;
|
||||
+ port->attr.store = usbport_trig_port_store;
|
||||
+
|
||||
+ err = sysfs_add_file_to_group(&led_cdev->dev->kobj, &port->attr.attr,
|
||||
+ ports_group.name);
|
||||
+ if (err)
|
||||
+ goto err_free_port_name;
|
||||
+
|
||||
+ list_add_tail(&port->list, &usbport_data->ports);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_free_port_name:
|
||||
+ kfree(port->port_name);
|
||||
+err_free_port:
|
||||
+ kfree(port);
|
||||
+err_out:
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int usbport_trig_add_usb_dev_ports(struct usb_device *usb_dev,
|
||||
+ void *data)
|
||||
+{
|
||||
+ struct usbport_trig_data *usbport_data = data;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 1; i <= usb_dev->maxchild; i++)
|
||||
+ usbport_trig_add_port(usbport_data, usb_dev,
|
||||
+ dev_name(&usb_dev->dev), i);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void usbport_trig_remove_port(struct usbport_trig_data *usbport_data,
|
||||
+ struct usbport_trig_port *port)
|
||||
+{
|
||||
+ struct led_classdev *led_cdev = usbport_data->led_cdev;
|
||||
+
|
||||
+ list_del(&port->list);
|
||||
+ sysfs_remove_file_from_group(&led_cdev->dev->kobj, &port->attr.attr,
|
||||
+ ports_group.name);
|
||||
+ kfree(port->port_name);
|
||||
+ kfree(port);
|
||||
+}
|
||||
+
|
||||
+static void usbport_trig_remove_usb_dev_ports(struct usbport_trig_data *usbport_data,
|
||||
+ struct usb_device *usb_dev)
|
||||
+{
|
||||
+ struct usbport_trig_port *port, *tmp;
|
||||
+
|
||||
+ list_for_each_entry_safe(port, tmp, &usbport_data->ports, list) {
|
||||
+ if (port->hub == usb_dev)
|
||||
+ usbport_trig_remove_port(usbport_data, port);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/***************************************
|
||||
+ * Init, exit, etc.
|
||||
+ ***************************************/
|
||||
+
|
||||
+static int usbport_trig_notify(struct notifier_block *nb, unsigned long action,
|
||||
+ void *data)
|
||||
+{
|
||||
+ struct usbport_trig_data *usbport_data =
|
||||
+ container_of(nb, struct usbport_trig_data, nb);
|
||||
+ struct led_classdev *led_cdev = usbport_data->led_cdev;
|
||||
+ struct usb_device *usb_dev = data;
|
||||
+ bool observed;
|
||||
+
|
||||
+ observed = usbport_trig_usb_dev_observed(usbport_data, usb_dev);
|
||||
+
|
||||
+ switch (action) {
|
||||
+ case USB_DEVICE_ADD:
|
||||
+ usbport_trig_add_usb_dev_ports(usb_dev, usbport_data);
|
||||
+ if (observed && usbport_data->count++ == 0)
|
||||
+ led_cdev->brightness_set(led_cdev, LED_FULL);
|
||||
+ return NOTIFY_OK;
|
||||
+ case USB_DEVICE_REMOVE:
|
||||
+ usbport_trig_remove_usb_dev_ports(usbport_data, usb_dev);
|
||||
+ if (observed && --usbport_data->count == 0)
|
||||
+ led_cdev->brightness_set(led_cdev, LED_OFF);
|
||||
+ return NOTIFY_OK;
|
||||
+ }
|
||||
+
|
||||
+ return NOTIFY_DONE;
|
||||
+}
|
||||
+
|
||||
+static void usbport_trig_activate(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ struct usbport_trig_data *usbport_data;
|
||||
+ int err;
|
||||
+
|
||||
+ usbport_data = kzalloc(sizeof(*usbport_data), GFP_KERNEL);
|
||||
+ if (!usbport_data)
|
||||
+ return;
|
||||
+ usbport_data->led_cdev = led_cdev;
|
||||
+
|
||||
+ /* List of ports */
|
||||
+ INIT_LIST_HEAD(&usbport_data->ports);
|
||||
+ err = sysfs_create_group(&led_cdev->dev->kobj, &ports_group);
|
||||
+ if (err)
|
||||
+ goto err_free;
|
||||
+ usb_for_each_dev(usbport_data, usbport_trig_add_usb_dev_ports);
|
||||
+
|
||||
+ /* Notifications */
|
||||
+ usbport_data->nb.notifier_call = usbport_trig_notify,
|
||||
+ led_cdev->trigger_data = usbport_data;
|
||||
+ usb_register_notify(&usbport_data->nb);
|
||||
+
|
||||
+ led_cdev->activated = true;
|
||||
+ return;
|
||||
+
|
||||
+err_free:
|
||||
+ kfree(usbport_data);
|
||||
+}
|
||||
+
|
||||
+static void usbport_trig_deactivate(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ struct usbport_trig_data *usbport_data = led_cdev->trigger_data;
|
||||
+ struct usbport_trig_port *port, *tmp;
|
||||
+
|
||||
+ if (!led_cdev->activated)
|
||||
+ return;
|
||||
+
|
||||
+ list_for_each_entry_safe(port, tmp, &usbport_data->ports, list) {
|
||||
+ usbport_trig_remove_port(usbport_data, port);
|
||||
+ }
|
||||
+
|
||||
+ usb_unregister_notify(&usbport_data->nb);
|
||||
+
|
||||
+ sysfs_remove_group(&led_cdev->dev->kobj, &ports_group);
|
||||
+
|
||||
+ kfree(usbport_data);
|
||||
+
|
||||
+ led_cdev->activated = false;
|
||||
+}
|
||||
+
|
||||
+static struct led_trigger usbport_led_trigger = {
|
||||
+ .name = "usbport",
|
||||
+ .activate = usbport_trig_activate,
|
||||
+ .deactivate = usbport_trig_deactivate,
|
||||
+};
|
||||
+
|
||||
+static int __init usbport_trig_init(void)
|
||||
+{
|
||||
+ return led_trigger_register(&usbport_led_trigger);
|
||||
+}
|
||||
+
|
||||
+static void __exit usbport_trig_exit(void)
|
||||
+{
|
||||
+ led_trigger_unregister(&usbport_led_trigger);
|
||||
+}
|
||||
+
|
||||
+module_init(usbport_trig_init);
|
||||
+module_exit(usbport_trig_exit);
|
||||
+
|
||||
+MODULE_AUTHOR("Rafał Miłecki <rafal@milecki.pl>");
|
||||
+MODULE_DESCRIPTION("USB port trigger");
|
||||
+MODULE_LICENSE("GPL v2");
|
File diff suppressed because it is too large
Load Diff
@ -1,146 +0,0 @@
|
||||
From 279c6c7fa64f5763e6b9f05e7ab3840092e702e7 Mon Sep 17 00:00:00 2001
|
||||
From: Stephen Hemminger <stephen@networkplumber.org>
|
||||
Date: Mon, 29 Jun 2015 14:57:48 -1000
|
||||
Subject: [PATCH] api: fix compatibility of linux/in.h with netinet/in.h
|
||||
|
||||
u
|
||||
This fixes breakage to iproute2 build with recent kernel headers
|
||||
caused by:
|
||||
commit a263653ed798216c0069922d7b5237ca49436007
|
||||
Author: Pablo Neira Ayuso <pablo@netfilter.org>
|
||||
Date: Wed Jun 17 10:28:27 2015 -0500
|
||||
|
||||
netfilter: don't pull include/linux/netfilter.h from netns headers
|
||||
|
||||
The issue is that definitions in linux/in.h overlap with those
|
||||
in netinet/in.h. This patch solves this by introducing the same
|
||||
mechanism as was used to solve the same problem with linux/in6.h
|
||||
|
||||
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
include/uapi/linux/in.h | 16 +++++++++++++---
|
||||
include/uapi/linux/libc-compat.h | 22 ++++++++++++++++++++++
|
||||
2 files changed, 35 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/include/uapi/linux/in.h
|
||||
+++ b/include/uapi/linux/in.h
|
||||
@@ -19,8 +19,10 @@
|
||||
#define _UAPI_LINUX_IN_H
|
||||
|
||||
#include <linux/types.h>
|
||||
+#include <linux/libc-compat.h>
|
||||
#include <linux/socket.h>
|
||||
|
||||
+#if __UAPI_DEF_IN_IPPROTO
|
||||
/* Standard well-defined IP protocols. */
|
||||
enum {
|
||||
IPPROTO_IP = 0, /* Dummy protocol for TCP */
|
||||
@@ -73,12 +75,14 @@ enum {
|
||||
#define IPPROTO_RAW IPPROTO_RAW
|
||||
IPPROTO_MAX
|
||||
};
|
||||
+#endif
|
||||
|
||||
-
|
||||
+#if __UAPI_DEF_IN_ADDR
|
||||
/* Internet address. */
|
||||
struct in_addr {
|
||||
__be32 s_addr;
|
||||
};
|
||||
+#endif
|
||||
|
||||
#define IP_TOS 1
|
||||
#define IP_TTL 2
|
||||
@@ -155,6 +159,7 @@ struct in_addr {
|
||||
|
||||
/* Request struct for multicast socket ops */
|
||||
|
||||
+#if __UAPI_DEF_IP_MREQ
|
||||
struct ip_mreq {
|
||||
struct in_addr imr_multiaddr; /* IP multicast address of group */
|
||||
struct in_addr imr_interface; /* local IP address of interface */
|
||||
@@ -206,14 +211,18 @@ struct group_filter {
|
||||
#define GROUP_FILTER_SIZE(numsrc) \
|
||||
(sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \
|
||||
+ (numsrc) * sizeof(struct __kernel_sockaddr_storage))
|
||||
+#endif
|
||||
|
||||
+#if __UAPI_DEF_IN_PKTINFO
|
||||
struct in_pktinfo {
|
||||
int ipi_ifindex;
|
||||
struct in_addr ipi_spec_dst;
|
||||
struct in_addr ipi_addr;
|
||||
};
|
||||
+#endif
|
||||
|
||||
/* Structure describing an Internet (IP) socket address. */
|
||||
+#if __UAPI_DEF_SOCKADDR_IN
|
||||
#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
|
||||
struct sockaddr_in {
|
||||
__kernel_sa_family_t sin_family; /* Address family */
|
||||
@@ -225,8 +234,9 @@ struct sockaddr_in {
|
||||
sizeof(unsigned short int) - sizeof(struct in_addr)];
|
||||
};
|
||||
#define sin_zero __pad /* for BSD UNIX comp. -FvK */
|
||||
+#endif
|
||||
|
||||
-
|
||||
+#if __UAPI_DEF_IN_CLASS
|
||||
/*
|
||||
* Definitions of the bits in an Internet address integer.
|
||||
* On subnets, host and network parts are found according
|
||||
@@ -277,7 +287,7 @@ struct sockaddr_in {
|
||||
#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
|
||||
#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
|
||||
#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
|
||||
-
|
||||
+#endif
|
||||
|
||||
/* <asm/byteorder.h> contains the htonl type stuff.. */
|
||||
#include <asm/byteorder.h>
|
||||
--- a/include/uapi/linux/libc-compat.h
|
||||
+++ b/include/uapi/linux/libc-compat.h
|
||||
@@ -56,6 +56,13 @@
|
||||
|
||||
/* GLIBC headers included first so don't define anything
|
||||
* that would already be defined. */
|
||||
+#define __UAPI_DEF_IN_ADDR 0
|
||||
+#define __UAPI_DEF_IN_IPPROTO 0
|
||||
+#define __UAPI_DEF_IN_PKTINFO 0
|
||||
+#define __UAPI_DEF_IP_MREQ 0
|
||||
+#define __UAPI_DEF_SOCKADDR_IN 0
|
||||
+#define __UAPI_DEF_IN_CLASS 0
|
||||
+
|
||||
#define __UAPI_DEF_IN6_ADDR 0
|
||||
/* The exception is the in6_addr macros which must be defined
|
||||
* if the glibc code didn't define them. This guard matches
|
||||
@@ -78,6 +85,13 @@
|
||||
/* Linux headers included first, and we must define everything
|
||||
* we need. The expectation is that glibc will check the
|
||||
* __UAPI_DEF_* defines and adjust appropriately. */
|
||||
+#define __UAPI_DEF_IN_ADDR 1
|
||||
+#define __UAPI_DEF_IN_IPPROTO 1
|
||||
+#define __UAPI_DEF_IN_PKTINFO 1
|
||||
+#define __UAPI_DEF_IP_MREQ 1
|
||||
+#define __UAPI_DEF_SOCKADDR_IN 1
|
||||
+#define __UAPI_DEF_IN_CLASS 1
|
||||
+
|
||||
#define __UAPI_DEF_IN6_ADDR 1
|
||||
/* We unconditionally define the in6_addr macros and glibc must
|
||||
* coordinate. */
|
||||
@@ -103,6 +117,14 @@
|
||||
* that we need. */
|
||||
#else /* !defined(__GLIBC__) */
|
||||
|
||||
+/* Definitions for in.h */
|
||||
+#define __UAPI_DEF_IN_ADDR 1
|
||||
+#define __UAPI_DEF_IN_IPPROTO 1
|
||||
+#define __UAPI_DEF_IN_PKTINFO 1
|
||||
+#define __UAPI_DEF_IP_MREQ 1
|
||||
+#define __UAPI_DEF_SOCKADDR_IN 1
|
||||
+#define __UAPI_DEF_IN_CLASS 1
|
||||
+
|
||||
/* Definitions for in6.h */
|
||||
#define __UAPI_DEF_IN6_ADDR 1
|
||||
#define __UAPI_DEF_IN6_ADDR_ALT 1
|
@ -1,90 +0,0 @@
|
||||
From c865f98df72112a3997b219bf711bc46c1e90706 Mon Sep 17 00:00:00 2001
|
||||
From: Linus Torvalds <torvalds@linux-foundation.org>
|
||||
Date: Thu, 13 Oct 2016 13:07:36 -0700
|
||||
Subject: [PATCH] mm: remove gup_flags FOLL_WRITE games from __get_user_pages()
|
||||
|
||||
[ Upstream commit 19be0eaffa3ac7d8eb6784ad9bdbc7d67ed8e619 ]
|
||||
|
||||
This is an ancient bug that was actually attempted to be fixed once
|
||||
(badly) by me eleven years ago in commit 4ceb5db9757a ("Fix
|
||||
get_user_pages() race for write access") but that was then undone due to
|
||||
problems on s390 by commit f33ea7f404e5 ("fix get_user_pages bug").
|
||||
|
||||
In the meantime, the s390 situation has long been fixed, and we can now
|
||||
fix it by checking the pte_dirty() bit properly (and do it better). The
|
||||
s390 dirty bit was implemented in abf09bed3cce ("s390/mm: implement
|
||||
software dirty bits") which made it into v3.9. Earlier kernels will
|
||||
have to look at the page state itself.
|
||||
|
||||
Also, the VM has become more scalable, and what used a purely
|
||||
theoretical race back then has become easier to trigger.
|
||||
|
||||
To fix it, we introduce a new internal FOLL_COW flag to mark the "yes,
|
||||
we already did a COW" rather than play racy games with FOLL_WRITE that
|
||||
is very fundamental, and then use the pte dirty flag to validate that
|
||||
the FOLL_COW flag is still valid.
|
||||
|
||||
Reported-and-tested-by: Phil "not Paul" Oester <kernel@linuxace.com>
|
||||
Acked-by: Hugh Dickins <hughd@google.com>
|
||||
Reviewed-by: Michal Hocko <mhocko@suse.com>
|
||||
Cc: Andy Lutomirski <luto@kernel.org>
|
||||
Cc: Kees Cook <keescook@chromium.org>
|
||||
Cc: Oleg Nesterov <oleg@redhat.com>
|
||||
Cc: Willy Tarreau <w@1wt.eu>
|
||||
Cc: Nick Piggin <npiggin@gmail.com>
|
||||
Cc: Greg Thelen <gthelen@google.com>
|
||||
Cc: stable@vger.kernel.org
|
||||
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
|
||||
---
|
||||
include/linux/mm.h | 1 +
|
||||
mm/gup.c | 14 ++++++++++++--
|
||||
2 files changed, 13 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/include/linux/mm.h
|
||||
+++ b/include/linux/mm.h
|
||||
@@ -2064,6 +2064,7 @@ static inline struct page *follow_page(s
|
||||
#define FOLL_NUMA 0x200 /* force NUMA hinting page fault */
|
||||
#define FOLL_MIGRATION 0x400 /* wait for page to replace migration entry */
|
||||
#define FOLL_TRIED 0x800 /* a retry, previous pass started an IO */
|
||||
+#define FOLL_COW 0x4000 /* internal GUP flag */
|
||||
|
||||
typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr,
|
||||
void *data);
|
||||
--- a/mm/gup.c
|
||||
+++ b/mm/gup.c
|
||||
@@ -32,6 +32,16 @@ static struct page *no_page_table(struct
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * FOLL_FORCE can write to even unwritable pte's, but only
|
||||
+ * after we've gone through a COW cycle and they are dirty.
|
||||
+ */
|
||||
+static inline bool can_follow_write_pte(pte_t pte, unsigned int flags)
|
||||
+{
|
||||
+ return pte_write(pte) ||
|
||||
+ ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte));
|
||||
+}
|
||||
+
|
||||
static struct page *follow_page_pte(struct vm_area_struct *vma,
|
||||
unsigned long address, pmd_t *pmd, unsigned int flags)
|
||||
{
|
||||
@@ -66,7 +76,7 @@ retry:
|
||||
}
|
||||
if ((flags & FOLL_NUMA) && pte_protnone(pte))
|
||||
goto no_page;
|
||||
- if ((flags & FOLL_WRITE) && !pte_write(pte)) {
|
||||
+ if ((flags & FOLL_WRITE) && !can_follow_write_pte(pte, flags)) {
|
||||
pte_unmap_unlock(ptep, ptl);
|
||||
return NULL;
|
||||
}
|
||||
@@ -315,7 +325,7 @@ static int faultin_page(struct task_stru
|
||||
* reCOWed by userspace write).
|
||||
*/
|
||||
if ((ret & VM_FAULT_WRITE) && !(vma->vm_flags & VM_WRITE))
|
||||
- *flags &= ~FOLL_WRITE;
|
||||
+ *flags |= FOLL_COW;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,82 +0,0 @@
|
||||
From 1e311820ec3055e3f08e687de6564692a7cec675 Mon Sep 17 00:00:00 2001
|
||||
From: Florian Fainelli <florian@openwrt.org>
|
||||
Date: Mon, 28 Jan 2013 20:06:29 +0100
|
||||
Subject: [PATCH 11/12] USB: EHCI: add ignore_oc flag to disable overcurrent
|
||||
checking
|
||||
|
||||
This patch adds an ignore_oc flag which can be set by EHCI controller
|
||||
not supporting or wanting to disable overcurrent checking. The EHCI
|
||||
platform data in include/linux/usb/ehci_pdriver.h is also augmented to
|
||||
take advantage of this new flag.
|
||||
|
||||
Signed-off-by: Florian Fainelli <florian@openwrt.org>
|
||||
---
|
||||
drivers/usb/host/ehci-hcd.c | 2 +-
|
||||
drivers/usb/host/ehci-hub.c | 4 ++--
|
||||
drivers/usb/host/ehci-platform.c | 1 +
|
||||
drivers/usb/host/ehci.h | 1 +
|
||||
include/linux/usb/ehci_pdriver.h | 1 +
|
||||
5 files changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/usb/host/ehci-hcd.c
|
||||
+++ b/drivers/usb/host/ehci-hcd.c
|
||||
@@ -638,7 +638,7 @@ static int ehci_run (struct usb_hcd *hcd
|
||||
"USB %x.%x started, EHCI %x.%02x%s\n",
|
||||
((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
|
||||
temp >> 8, temp & 0xff,
|
||||
- ignore_oc ? ", overcurrent ignored" : "");
|
||||
+ (ignore_oc || ehci->ignore_oc) ? ", overcurrent ignored" : "");
|
||||
|
||||
ehci_writel(ehci, INTR_MASK,
|
||||
&ehci->regs->intr_enable); /* Turn On Interrupts */
|
||||
--- a/drivers/usb/host/ehci-hub.c
|
||||
+++ b/drivers/usb/host/ehci-hub.c
|
||||
@@ -633,7 +633,7 @@ ehci_hub_status_data (struct usb_hcd *hc
|
||||
* always set, seem to clear PORT_OCC and PORT_CSC when writing to
|
||||
* PORT_POWER; that's surprising, but maybe within-spec.
|
||||
*/
|
||||
- if (!ignore_oc)
|
||||
+ if (!ignore_oc && !ehci->ignore_oc)
|
||||
mask = PORT_CSC | PORT_PEC | PORT_OCC;
|
||||
else
|
||||
mask = PORT_CSC | PORT_PEC;
|
||||
@@ -995,7 +995,7 @@ int ehci_hub_control(
|
||||
if (temp & PORT_PEC)
|
||||
status |= USB_PORT_STAT_C_ENABLE << 16;
|
||||
|
||||
- if ((temp & PORT_OCC) && !ignore_oc){
|
||||
+ if ((temp & PORT_OCC) && (!ignore_oc && !ehci->ignore_oc)){
|
||||
status |= USB_PORT_STAT_C_OVERCURRENT << 16;
|
||||
|
||||
/*
|
||||
--- a/drivers/usb/host/ehci-platform.c
|
||||
+++ b/drivers/usb/host/ehci-platform.c
|
||||
@@ -264,6 +264,8 @@ static int ehci_platform_probe(struct pl
|
||||
ehci->big_endian_desc = 1;
|
||||
if (pdata->big_endian_mmio)
|
||||
ehci->big_endian_mmio = 1;
|
||||
+ if (pdata->ignore_oc)
|
||||
+ ehci->ignore_oc = 1;
|
||||
|
||||
#ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
|
||||
if (ehci->big_endian_mmio) {
|
||||
--- a/drivers/usb/host/ehci.h
|
||||
+++ b/drivers/usb/host/ehci.h
|
||||
@@ -226,6 +226,7 @@ struct ehci_hcd { /* one per controlle
|
||||
unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */
|
||||
unsigned need_oc_pp_cycle:1; /* MPC834X port power */
|
||||
unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
|
||||
+ unsigned ignore_oc:1;
|
||||
|
||||
/* required for usb32 quirk */
|
||||
#define OHCI_CTRL_HCFS (3 << 6)
|
||||
--- a/include/linux/usb/ehci_pdriver.h
|
||||
+++ b/include/linux/usb/ehci_pdriver.h
|
||||
@@ -49,6 +49,7 @@ struct usb_ehci_pdata {
|
||||
unsigned no_io_watchdog:1;
|
||||
unsigned reset_on_resume:1;
|
||||
unsigned dma_mask_64:1;
|
||||
+ unsigned ignore_oc:1;
|
||||
|
||||
/* Turn on all power and clocks */
|
||||
int (*power_on)(struct platform_device *pdev);
|
@ -1,86 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Fri, 10 Apr 2015 13:35:29 +0200
|
||||
Subject: [PATCH] jffs2: use .rename2 and add RENAME_WHITEOUT support
|
||||
|
||||
It is required for renames on overlayfs
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/fs/jffs2/dir.c
|
||||
+++ b/fs/jffs2/dir.c
|
||||
@@ -35,7 +35,7 @@ static int jffs2_mkdir (struct inode *,s
|
||||
static int jffs2_rmdir (struct inode *,struct dentry *);
|
||||
static int jffs2_mknod (struct inode *,struct dentry *,umode_t,dev_t);
|
||||
static int jffs2_rename (struct inode *, struct dentry *,
|
||||
- struct inode *, struct dentry *);
|
||||
+ struct inode *, struct dentry *, unsigned int);
|
||||
|
||||
const struct file_operations jffs2_dir_operations =
|
||||
{
|
||||
@@ -57,7 +57,7 @@ const struct inode_operations jffs2_dir_
|
||||
.mkdir = jffs2_mkdir,
|
||||
.rmdir = jffs2_rmdir,
|
||||
.mknod = jffs2_mknod,
|
||||
- .rename = jffs2_rename,
|
||||
+ .rename2 = jffs2_rename,
|
||||
.get_acl = jffs2_get_acl,
|
||||
.set_acl = jffs2_set_acl,
|
||||
.setattr = jffs2_setattr,
|
||||
@@ -756,8 +756,27 @@ static int jffs2_mknod (struct inode *di
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static int jffs2_whiteout(struct inode *old_dir, struct dentry *old_dentry)
|
||||
+{
|
||||
+ struct dentry *wh;
|
||||
+ int err;
|
||||
+
|
||||
+ wh = d_alloc(old_dentry->d_parent, &old_dentry->d_name);
|
||||
+ if (!wh)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ err = jffs2_mknod(old_dir, wh, S_IFCHR | WHITEOUT_MODE,
|
||||
+ WHITEOUT_DEV);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ d_rehash(wh);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
|
||||
- struct inode *new_dir_i, struct dentry *new_dentry)
|
||||
+ struct inode *new_dir_i, struct dentry *new_dentry,
|
||||
+ unsigned int flags)
|
||||
{
|
||||
int ret;
|
||||
struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb);
|
||||
@@ -765,6 +784,9 @@ static int jffs2_rename (struct inode *o
|
||||
uint8_t type;
|
||||
uint32_t now;
|
||||
|
||||
+ if (flags & ~RENAME_WHITEOUT)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
/* The VFS will check for us and prevent trying to rename a
|
||||
* file over a directory and vice versa, but if it's a directory,
|
||||
* the VFS can't check whether the victim is empty. The filesystem
|
||||
@@ -828,9 +850,14 @@ static int jffs2_rename (struct inode *o
|
||||
if (d_is_dir(old_dentry) && !victim_f)
|
||||
inc_nlink(new_dir_i);
|
||||
|
||||
- /* Unlink the original */
|
||||
- ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i),
|
||||
- old_dentry->d_name.name, old_dentry->d_name.len, NULL, now);
|
||||
+ if (flags & RENAME_WHITEOUT)
|
||||
+ /* Replace with whiteout */
|
||||
+ ret = jffs2_whiteout(old_dir_i, old_dentry);
|
||||
+ else
|
||||
+ /* Unlink the original */
|
||||
+ ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i),
|
||||
+ old_dentry->d_name.name,
|
||||
+ old_dentry->d_name.len, NULL, now);
|
||||
|
||||
/* We don't touch inode->i_nlink */
|
||||
|
@ -1,58 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Sat, 25 Apr 2015 12:41:32 +0200
|
||||
Subject: [PATCH] jffs2: add RENAME_EXCHANGE support
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/fs/jffs2/dir.c
|
||||
+++ b/fs/jffs2/dir.c
|
||||
@@ -784,7 +784,7 @@ static int jffs2_rename (struct inode *o
|
||||
uint8_t type;
|
||||
uint32_t now;
|
||||
|
||||
- if (flags & ~RENAME_WHITEOUT)
|
||||
+ if (flags & ~(RENAME_WHITEOUT | RENAME_EXCHANGE))
|
||||
return -EINVAL;
|
||||
|
||||
/* The VFS will check for us and prevent trying to rename a
|
||||
@@ -792,7 +792,7 @@ static int jffs2_rename (struct inode *o
|
||||
* the VFS can't check whether the victim is empty. The filesystem
|
||||
* needs to do that for itself.
|
||||
*/
|
||||
- if (d_really_is_positive(new_dentry)) {
|
||||
+ if (d_really_is_positive(new_dentry) && !(flags & RENAME_EXCHANGE)) {
|
||||
victim_f = JFFS2_INODE_INFO(d_inode(new_dentry));
|
||||
if (d_is_dir(new_dentry)) {
|
||||
struct jffs2_full_dirent *fd;
|
||||
@@ -827,7 +827,7 @@ static int jffs2_rename (struct inode *o
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- if (victim_f) {
|
||||
+ if (victim_f && !(flags & RENAME_EXCHANGE)) {
|
||||
/* There was a victim. Kill it off nicely */
|
||||
if (d_is_dir(new_dentry))
|
||||
clear_nlink(d_inode(new_dentry));
|
||||
@@ -853,6 +853,12 @@ static int jffs2_rename (struct inode *o
|
||||
if (flags & RENAME_WHITEOUT)
|
||||
/* Replace with whiteout */
|
||||
ret = jffs2_whiteout(old_dir_i, old_dentry);
|
||||
+ else if (flags & RENAME_EXCHANGE)
|
||||
+ /* Replace the original */
|
||||
+ ret = jffs2_do_link(c, JFFS2_INODE_INFO(old_dir_i),
|
||||
+ d_inode(new_dentry)->i_ino, type,
|
||||
+ old_dentry->d_name.name, old_dentry->d_name.len,
|
||||
+ now);
|
||||
else
|
||||
/* Unlink the original */
|
||||
ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i),
|
||||
@@ -884,7 +890,7 @@ static int jffs2_rename (struct inode *o
|
||||
return ret;
|
||||
}
|
||||
|
||||
- if (d_is_dir(old_dentry))
|
||||
+ if (d_is_dir(old_dentry) && !(flags & RENAME_EXCHANGE))
|
||||
drop_nlink(old_dir_i);
|
||||
|
||||
new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now);
|
@ -1,54 +0,0 @@
|
||||
From: Stephen Hemminger <stephen@networkplumber.org>
|
||||
Subject: bridge: allow receiption on disabled port
|
||||
|
||||
When an ethernet device is enslaved to a bridge, and the bridge STP
|
||||
detects loss of carrier (or operational state down), then normally
|
||||
packet receiption is blocked.
|
||||
|
||||
This breaks control applications like WPA which maybe expecting to
|
||||
receive packets to negotiate to bring link up. The bridge needs to
|
||||
block forwarding packets from these disabled ports, but there is no
|
||||
hard requirement to not allow local packet delivery.
|
||||
|
||||
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
--- a/net/bridge/br_input.c
|
||||
+++ b/net/bridge/br_input.c
|
||||
@@ -211,11 +211,13 @@ EXPORT_SYMBOL_GPL(br_handle_frame_finish
|
||||
static int br_handle_local_finish(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
struct net_bridge_port *p = br_port_get_rcu(skb->dev);
|
||||
- u16 vid = 0;
|
||||
+ if (p->state != BR_STATE_DISABLED) {
|
||||
+ u16 vid = 0;
|
||||
|
||||
- /* check if vlan is allowed, to avoid spoofing */
|
||||
- if (p->flags & BR_LEARNING && br_should_learn(p, skb, &vid))
|
||||
- br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, false);
|
||||
+ /* check if vlan is allowed, to avoid spoofing */
|
||||
+ if (p->flags & BR_LEARNING && br_should_learn(p, skb, &vid))
|
||||
+ br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, false);
|
||||
+ }
|
||||
return 0; /* process further */
|
||||
}
|
||||
|
||||
@@ -289,6 +291,18 @@ rx_handler_result_t br_handle_frame(stru
|
||||
|
||||
forward:
|
||||
switch (p->state) {
|
||||
+ case BR_STATE_DISABLED:
|
||||
+ if (ether_addr_equal(p->br->dev->dev_addr, dest))
|
||||
+ skb->pkt_type = PACKET_HOST;
|
||||
+
|
||||
+ if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, NULL, skb, skb->dev, NULL,
|
||||
+ br_handle_local_finish))
|
||||
+ break;
|
||||
+
|
||||
+ BR_INPUT_SKB_CB(skb)->brdev = p->br->dev;
|
||||
+ br_pass_frame_up(skb);
|
||||
+ break;
|
||||
+
|
||||
case BR_STATE_FORWARDING:
|
||||
rhook = rcu_dereference(br_should_route_hook);
|
||||
if (rhook) {
|
@ -1,697 +0,0 @@
|
||||
From 2c58080407554e1bac8fd50d23cb02420524caed Mon Sep 17 00:00:00 2001
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Mon, 12 Aug 2013 12:50:22 +0200
|
||||
Subject: [PATCH] MIPS: partially inline dma ops
|
||||
|
||||
Several DMA ops are no-op on many platforms, and the indirection through
|
||||
the mips_dma_map_ops function table is causing the compiler to emit
|
||||
unnecessary code.
|
||||
|
||||
Inlining visibly improves network performance in my tests (on a 24Kc
|
||||
based system), and also slightly reduces code size of a few drivers.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
arch/mips/Kconfig | 4 +
|
||||
arch/mips/include/asm/dma-mapping.h | 360 +++++++++++++++++++++++++++++++++++-
|
||||
arch/mips/mm/dma-default.c | 163 ++--------------
|
||||
3 files changed, 373 insertions(+), 154 deletions(-)
|
||||
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -1571,6 +1571,7 @@ config CPU_CAVIUM_OCTEON
|
||||
select CPU_SUPPORTS_HUGEPAGES
|
||||
select USB_EHCI_BIG_ENDIAN_MMIO
|
||||
select MIPS_L1_CACHE_SHIFT_7
|
||||
+ select SYS_HAS_DMA_OPS
|
||||
help
|
||||
The Cavium Octeon processor is a highly integrated chip containing
|
||||
many ethernet hardware widgets for networking tasks. The processor
|
||||
@@ -1866,6 +1867,9 @@ config MIPS_MALTA_PM
|
||||
bool
|
||||
default y
|
||||
|
||||
+config SYS_HAS_DMA_OPS
|
||||
+ bool
|
||||
+
|
||||
#
|
||||
# CPU may reorder R->R, R->W, W->R, W->W
|
||||
# Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC
|
||||
--- a/arch/mips/include/asm/dma-mapping.h
|
||||
+++ b/arch/mips/include/asm/dma-mapping.h
|
||||
@@ -1,9 +1,16 @@
|
||||
#ifndef _ASM_DMA_MAPPING_H
|
||||
#define _ASM_DMA_MAPPING_H
|
||||
|
||||
+#include <linux/kmemcheck.h>
|
||||
+#include <linux/bug.h>
|
||||
+#include <linux/scatterlist.h>
|
||||
+#include <linux/dma-debug.h>
|
||||
+#include <linux/dma-attrs.h>
|
||||
+
|
||||
#include <asm/scatterlist.h>
|
||||
#include <asm/dma-coherence.h>
|
||||
#include <asm/cache.h>
|
||||
+#include <asm/cpu-type.h>
|
||||
#include <asm-generic/dma-coherent.h>
|
||||
|
||||
#ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */
|
||||
@@ -12,12 +19,48 @@
|
||||
|
||||
extern struct dma_map_ops *mips_dma_map_ops;
|
||||
|
||||
+void __dma_sync(struct page *page, unsigned long offset, size_t size,
|
||||
+ enum dma_data_direction direction);
|
||||
+void *mips_dma_alloc_coherent(struct device *dev, size_t size,
|
||||
+ dma_addr_t *dma_handle, gfp_t gfp,
|
||||
+ struct dma_attrs *attrs);
|
||||
+void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
|
||||
+ dma_addr_t dma_handle, struct dma_attrs *attrs);
|
||||
+
|
||||
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
|
||||
{
|
||||
+#ifdef CONFIG_SYS_HAS_DMA_OPS
|
||||
if (dev && dev->archdata.dma_ops)
|
||||
return dev->archdata.dma_ops;
|
||||
else
|
||||
return mips_dma_map_ops;
|
||||
+#else
|
||||
+ return NULL;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Warning on the terminology - Linux calls an uncached area coherent;
|
||||
+ * MIPS terminology calls memory areas with hardware maintained coherency
|
||||
+ * coherent.
|
||||
+ */
|
||||
+
|
||||
+static inline int cpu_needs_post_dma_flush(struct device *dev)
|
||||
+{
|
||||
+#ifndef CONFIG_SYS_HAS_CPU_R10000
|
||||
+ return 0;
|
||||
+#endif
|
||||
+ return !plat_device_is_coherent(dev) &&
|
||||
+ (boot_cpu_type() == CPU_R10000 ||
|
||||
+ boot_cpu_type() == CPU_R12000 ||
|
||||
+ boot_cpu_type() == CPU_BMIPS5000);
|
||||
+}
|
||||
+
|
||||
+static inline struct page *dma_addr_to_page(struct device *dev,
|
||||
+ dma_addr_t dma_addr)
|
||||
+{
|
||||
+ return pfn_to_page(
|
||||
+ plat_dma_addr_to_phys(dev, dma_addr) >> PAGE_SHIFT);
|
||||
}
|
||||
|
||||
static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
|
||||
@@ -30,12 +73,306 @@ static inline bool dma_capable(struct de
|
||||
|
||||
static inline void dma_mark_clean(void *addr, size_t size) {}
|
||||
|
||||
-#include <asm-generic/dma-mapping-common.h>
|
||||
+static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
|
||||
+ size_t size,
|
||||
+ enum dma_data_direction dir,
|
||||
+ struct dma_attrs *attrs)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+ unsigned long offset = (unsigned long)ptr & ~PAGE_MASK;
|
||||
+ struct page *page = virt_to_page(ptr);
|
||||
+ dma_addr_t addr;
|
||||
+
|
||||
+ kmemcheck_mark_initialized(ptr, size);
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops) {
|
||||
+ addr = ops->map_page(dev, page, offset, size, dir, attrs);
|
||||
+ } else {
|
||||
+ if (!plat_device_is_coherent(dev))
|
||||
+ __dma_sync(page, offset, size, dir);
|
||||
+
|
||||
+ addr = plat_map_dma_mem_page(dev, page) + offset;
|
||||
+ }
|
||||
+ debug_dma_map_page(dev, page, offset, size, dir, addr, true);
|
||||
+ return addr;
|
||||
+}
|
||||
+
|
||||
+static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
|
||||
+ size_t size,
|
||||
+ enum dma_data_direction dir,
|
||||
+ struct dma_attrs *attrs)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops) {
|
||||
+ ops->unmap_page(dev, addr, size, dir, attrs);
|
||||
+ } else {
|
||||
+ if (cpu_needs_post_dma_flush(dev))
|
||||
+ __dma_sync(dma_addr_to_page(dev, addr),
|
||||
+ addr & ~PAGE_MASK, size, dir);
|
||||
+
|
||||
+ plat_unmap_dma_mem(dev, addr, size, dir);
|
||||
+ }
|
||||
+ debug_dma_unmap_page(dev, addr, size, dir, true);
|
||||
+}
|
||||
+
|
||||
+static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
|
||||
+ int nents, enum dma_data_direction dir,
|
||||
+ struct dma_attrs *attrs)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+ int i, ents;
|
||||
+ struct scatterlist *s;
|
||||
+
|
||||
+ for_each_sg(sg, s, nents, i)
|
||||
+ kmemcheck_mark_initialized(sg_virt(s), s->length);
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops) {
|
||||
+ ents = ops->map_sg(dev, sg, nents, dir, attrs);
|
||||
+ } else {
|
||||
+ for_each_sg(sg, s, nents, i) {
|
||||
+ struct page *page = sg_page(s);
|
||||
+
|
||||
+ if (!plat_device_is_coherent(dev))
|
||||
+ __dma_sync(page, s->offset, s->length, dir);
|
||||
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
|
||||
+ s->dma_length = s->length;
|
||||
+#endif
|
||||
+ s->dma_address =
|
||||
+ plat_map_dma_mem_page(dev, page) + s->offset;
|
||||
+ }
|
||||
+ ents = nents;
|
||||
+ }
|
||||
+ debug_dma_map_sg(dev, sg, nents, ents, dir);
|
||||
+
|
||||
+ return ents;
|
||||
+}
|
||||
+
|
||||
+static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg,
|
||||
+ int nents, enum dma_data_direction dir,
|
||||
+ struct dma_attrs *attrs)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+ struct scatterlist *s;
|
||||
+ int i;
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ debug_dma_unmap_sg(dev, sg, nents, dir);
|
||||
+ if (ops) {
|
||||
+ ops->unmap_sg(dev, sg, nents, dir, attrs);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for_each_sg(sg, s, nents, i) {
|
||||
+ if (!plat_device_is_coherent(dev) && dir != DMA_TO_DEVICE)
|
||||
+ __dma_sync(sg_page(s), s->offset, s->length, dir);
|
||||
+ plat_unmap_dma_mem(dev, s->dma_address, s->length, dir);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
|
||||
+ size_t offset, size_t size,
|
||||
+ enum dma_data_direction dir)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+ dma_addr_t addr;
|
||||
+
|
||||
+ kmemcheck_mark_initialized(page_address(page) + offset, size);
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops) {
|
||||
+ addr = ops->map_page(dev, page, offset, size, dir, NULL);
|
||||
+ } else {
|
||||
+ if (!plat_device_is_coherent(dev))
|
||||
+ __dma_sync(page, offset, size, dir);
|
||||
+
|
||||
+ addr = plat_map_dma_mem_page(dev, page) + offset;
|
||||
+ }
|
||||
+ debug_dma_map_page(dev, page, offset, size, dir, addr, false);
|
||||
+
|
||||
+ return addr;
|
||||
+}
|
||||
+
|
||||
+static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
|
||||
+ size_t size, enum dma_data_direction dir)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops) {
|
||||
+ ops->unmap_page(dev, addr, size, dir, NULL);
|
||||
+ } else {
|
||||
+ if (cpu_needs_post_dma_flush(dev))
|
||||
+ __dma_sync(dma_addr_to_page(dev, addr),
|
||||
+ addr & ~PAGE_MASK, size, dir);
|
||||
+ plat_post_dma_flush(dev);
|
||||
+ plat_unmap_dma_mem(dev, addr, size, dir);
|
||||
+ }
|
||||
+ debug_dma_unmap_page(dev, addr, size, dir, false);
|
||||
+}
|
||||
+
|
||||
+static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
|
||||
+ size_t size,
|
||||
+ enum dma_data_direction dir)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops)
|
||||
+ ops->sync_single_for_cpu(dev, addr, size, dir);
|
||||
+ else if (cpu_needs_post_dma_flush(dev))
|
||||
+ __dma_sync(dma_addr_to_page(dev, addr),
|
||||
+ addr & ~PAGE_MASK, size, dir);
|
||||
+ plat_post_dma_flush(dev);
|
||||
+ debug_dma_sync_single_for_cpu(dev, addr, size, dir);
|
||||
+}
|
||||
+
|
||||
+static inline void dma_sync_single_for_device(struct device *dev,
|
||||
+ dma_addr_t addr, size_t size,
|
||||
+ enum dma_data_direction dir)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops)
|
||||
+ ops->sync_single_for_device(dev, addr, size, dir);
|
||||
+ else if (!plat_device_is_coherent(dev))
|
||||
+ __dma_sync(dma_addr_to_page(dev, addr),
|
||||
+ addr & ~PAGE_MASK, size, dir);
|
||||
+ debug_dma_sync_single_for_device(dev, addr, size, dir);
|
||||
+}
|
||||
+
|
||||
+static inline void dma_sync_single_range_for_cpu(struct device *dev,
|
||||
+ dma_addr_t addr,
|
||||
+ unsigned long offset,
|
||||
+ size_t size,
|
||||
+ enum dma_data_direction dir)
|
||||
+{
|
||||
+ const struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops)
|
||||
+ ops->sync_single_for_cpu(dev, addr + offset, size, dir);
|
||||
+ else if (cpu_needs_post_dma_flush(dev))
|
||||
+ __dma_sync(dma_addr_to_page(dev, addr + offset),
|
||||
+ (addr + offset) & ~PAGE_MASK, size, dir);
|
||||
+ debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir);
|
||||
+}
|
||||
+
|
||||
+static inline void dma_sync_single_range_for_device(struct device *dev,
|
||||
+ dma_addr_t addr,
|
||||
+ unsigned long offset,
|
||||
+ size_t size,
|
||||
+ enum dma_data_direction dir)
|
||||
+{
|
||||
+ const struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops)
|
||||
+ ops->sync_single_for_device(dev, addr + offset, size, dir);
|
||||
+ else if (!plat_device_is_coherent(dev))
|
||||
+ __dma_sync(dma_addr_to_page(dev, addr + offset),
|
||||
+ (addr + offset) & ~PAGE_MASK, size, dir);
|
||||
+ debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir);
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
|
||||
+ int nelems, enum dma_data_direction dir)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+ struct scatterlist *s;
|
||||
+ int i;
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops)
|
||||
+ ops->sync_sg_for_cpu(dev, sg, nelems, dir);
|
||||
+ else if (cpu_needs_post_dma_flush(dev)) {
|
||||
+ for_each_sg(sg, s, nelems, i)
|
||||
+ __dma_sync(sg_page(s), s->offset, s->length, dir);
|
||||
+ }
|
||||
+ plat_post_dma_flush(dev);
|
||||
+ debug_dma_sync_sg_for_cpu(dev, sg, nelems, dir);
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
|
||||
+ int nelems, enum dma_data_direction dir)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+ struct scatterlist *s;
|
||||
+ int i;
|
||||
+
|
||||
+ BUG_ON(!valid_dma_direction(dir));
|
||||
+ if (ops)
|
||||
+ ops->sync_sg_for_device(dev, sg, nelems, dir);
|
||||
+ else if (!plat_device_is_coherent(dev)) {
|
||||
+ for_each_sg(sg, s, nelems, i)
|
||||
+ __dma_sync(sg_page(s), s->offset, s->length, dir);
|
||||
+ }
|
||||
+ debug_dma_sync_sg_for_device(dev, sg, nelems, dir);
|
||||
+
|
||||
+}
|
||||
+
|
||||
+#define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL)
|
||||
+#define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL)
|
||||
+#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL)
|
||||
+#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL)
|
||||
+
|
||||
+extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
|
||||
+ void *cpu_addr, dma_addr_t dma_addr, size_t size);
|
||||
+
|
||||
+/**
|
||||
+ * dma_mmap_attrs - map a coherent DMA allocation into user space
|
||||
+ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
|
||||
+ * @vma: vm_area_struct describing requested user mapping
|
||||
+ * @cpu_addr: kernel CPU-view address returned from dma_alloc_attrs
|
||||
+ * @handle: device-view address returned from dma_alloc_attrs
|
||||
+ * @size: size of memory originally requested in dma_alloc_attrs
|
||||
+ * @attrs: attributes of mapping properties requested in dma_alloc_attrs
|
||||
+ *
|
||||
+ * Map a coherent DMA buffer previously allocated by dma_alloc_attrs
|
||||
+ * into user space. The coherent DMA buffer must not be freed by the
|
||||
+ * driver until the user space mapping has been released.
|
||||
+ */
|
||||
+static inline int
|
||||
+dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr,
|
||||
+ dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+ BUG_ON(!ops);
|
||||
+ if (ops && ops->mmap)
|
||||
+ return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs);
|
||||
+ return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size);
|
||||
+}
|
||||
+
|
||||
+#define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
|
||||
+
|
||||
+int
|
||||
+dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
|
||||
+ void *cpu_addr, dma_addr_t dma_addr, size_t size);
|
||||
+
|
||||
+static inline int
|
||||
+dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, void *cpu_addr,
|
||||
+ dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
|
||||
+{
|
||||
+ struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
+ BUG_ON(!ops);
|
||||
+ if (ops && ops->get_sgtable)
|
||||
+ return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size,
|
||||
+ attrs);
|
||||
+ return dma_common_get_sgtable(dev, sgt, cpu_addr, dma_addr, size);
|
||||
+}
|
||||
+
|
||||
+#define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, NULL)
|
||||
+
|
||||
|
||||
static inline int dma_supported(struct device *dev, u64 mask)
|
||||
{
|
||||
struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
- return ops->dma_supported(dev, mask);
|
||||
+ if (ops)
|
||||
+ return ops->dma_supported(dev, mask);
|
||||
+ return plat_dma_supported(dev, mask);
|
||||
}
|
||||
|
||||
static inline int dma_mapping_error(struct device *dev, u64 mask)
|
||||
@@ -43,7 +380,9 @@ static inline int dma_mapping_error(stru
|
||||
struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
|
||||
debug_dma_mapping_error(dev, mask);
|
||||
- return ops->mapping_error(dev, mask);
|
||||
+ if (ops)
|
||||
+ return ops->mapping_error(dev, mask);
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
@@ -54,7 +393,7 @@ dma_set_mask(struct device *dev, u64 mas
|
||||
if(!dev->dma_mask || !dma_supported(dev, mask))
|
||||
return -EIO;
|
||||
|
||||
- if (ops->set_dma_mask)
|
||||
+ if (ops && ops->set_dma_mask)
|
||||
return ops->set_dma_mask(dev, mask);
|
||||
|
||||
*dev->dma_mask = mask;
|
||||
@@ -74,7 +413,11 @@ static inline void *dma_alloc_attrs(stru
|
||||
void *ret;
|
||||
struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
|
||||
- ret = ops->alloc(dev, size, dma_handle, gfp, attrs);
|
||||
+ if (ops)
|
||||
+ ret = ops->alloc(dev, size, dma_handle, gfp, attrs);
|
||||
+ else
|
||||
+ ret = mips_dma_alloc_coherent(dev, size, dma_handle, gfp,
|
||||
+ attrs);
|
||||
|
||||
debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
|
||||
|
||||
@@ -89,7 +432,10 @@ static inline void dma_free_attrs(struct
|
||||
{
|
||||
struct dma_map_ops *ops = get_dma_ops(dev);
|
||||
|
||||
- ops->free(dev, size, vaddr, dma_handle, attrs);
|
||||
+ if (ops)
|
||||
+ ops->free(dev, size, vaddr, dma_handle, attrs);
|
||||
+ else
|
||||
+ mips_dma_free_coherent(dev, size, vaddr, dma_handle, attrs);
|
||||
|
||||
debug_dma_free_coherent(dev, size, vaddr, dma_handle);
|
||||
}
|
||||
--- a/arch/mips/mm/dma-default.c
|
||||
+++ b/arch/mips/mm/dma-default.c
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#ifdef CONFIG_DMA_MAYBE_COHERENT
|
||||
int coherentio = 0; /* User defined DMA coherency from command line. */
|
||||
-EXPORT_SYMBOL_GPL(coherentio);
|
||||
+EXPORT_SYMBOL(coherentio);
|
||||
int hw_coherentio = 0; /* Actual hardware supported DMA coherency setting. */
|
||||
|
||||
static int __init setcoherentio(char *str)
|
||||
@@ -46,35 +46,6 @@ static int __init setnocoherentio(char *
|
||||
early_param("nocoherentio", setnocoherentio);
|
||||
#endif
|
||||
|
||||
-static inline struct page *dma_addr_to_page(struct device *dev,
|
||||
- dma_addr_t dma_addr)
|
||||
-{
|
||||
- return pfn_to_page(
|
||||
- plat_dma_addr_to_phys(dev, dma_addr) >> PAGE_SHIFT);
|
||||
-}
|
||||
-
|
||||
-/*
|
||||
- * The affected CPUs below in 'cpu_needs_post_dma_flush()' can
|
||||
- * speculatively fill random cachelines with stale data at any time,
|
||||
- * requiring an extra flush post-DMA.
|
||||
- *
|
||||
- * Warning on the terminology - Linux calls an uncached area coherent;
|
||||
- * MIPS terminology calls memory areas with hardware maintained coherency
|
||||
- * coherent.
|
||||
- *
|
||||
- * Note that the R14000 and R16000 should also be checked for in this
|
||||
- * condition. However this function is only called on non-I/O-coherent
|
||||
- * systems and only the R10000 and R12000 are used in such systems, the
|
||||
- * SGI IP28 Indigo² rsp. SGI IP32 aka O2.
|
||||
- */
|
||||
-static inline int cpu_needs_post_dma_flush(struct device *dev)
|
||||
-{
|
||||
- return !plat_device_is_coherent(dev) &&
|
||||
- (boot_cpu_type() == CPU_R10000 ||
|
||||
- boot_cpu_type() == CPU_R12000 ||
|
||||
- boot_cpu_type() == CPU_BMIPS5000);
|
||||
-}
|
||||
-
|
||||
static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
|
||||
{
|
||||
gfp_t dma_flag;
|
||||
@@ -130,8 +101,9 @@ void *dma_alloc_noncoherent(struct devic
|
||||
}
|
||||
EXPORT_SYMBOL(dma_alloc_noncoherent);
|
||||
|
||||
-static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
|
||||
- dma_addr_t * dma_handle, gfp_t gfp, struct dma_attrs *attrs)
|
||||
+void *mips_dma_alloc_coherent(struct device *dev, size_t size,
|
||||
+ dma_addr_t *dma_handle, gfp_t gfp,
|
||||
+ struct dma_attrs *attrs)
|
||||
{
|
||||
void *ret;
|
||||
struct page *page = NULL;
|
||||
@@ -162,6 +134,7 @@ static void *mips_dma_alloc_coherent(str
|
||||
|
||||
return ret;
|
||||
}
|
||||
+EXPORT_SYMBOL(mips_dma_alloc_coherent);
|
||||
|
||||
|
||||
void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
|
||||
@@ -172,8 +145,8 @@ void dma_free_noncoherent(struct device
|
||||
}
|
||||
EXPORT_SYMBOL(dma_free_noncoherent);
|
||||
|
||||
-static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
|
||||
- dma_addr_t dma_handle, struct dma_attrs *attrs)
|
||||
+void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
|
||||
+ dma_addr_t dma_handle, struct dma_attrs *attrs)
|
||||
{
|
||||
unsigned long addr = (unsigned long) vaddr;
|
||||
int order = get_order(size);
|
||||
@@ -193,6 +166,7 @@ static void mips_dma_free_coherent(struc
|
||||
if (!dma_release_from_contiguous(dev, page, count))
|
||||
__free_pages(page, get_order(size));
|
||||
}
|
||||
+EXPORT_SYMBOL(mips_dma_free_coherent);
|
||||
|
||||
static inline void __dma_sync_virtual(void *addr, size_t size,
|
||||
enum dma_data_direction direction)
|
||||
@@ -221,8 +195,8 @@ static inline void __dma_sync_virtual(vo
|
||||
* If highmem is not configured then the bulk of this loop gets
|
||||
* optimized out.
|
||||
*/
|
||||
-static inline void __dma_sync(struct page *page,
|
||||
- unsigned long offset, size_t size, enum dma_data_direction direction)
|
||||
+void __dma_sync(struct page *page, unsigned long offset, size_t size,
|
||||
+ enum dma_data_direction direction)
|
||||
{
|
||||
size_t left = size;
|
||||
|
||||
@@ -251,110 +225,7 @@ static inline void __dma_sync(struct pag
|
||||
left -= len;
|
||||
} while (left);
|
||||
}
|
||||
-
|
||||
-static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
|
||||
- size_t size, enum dma_data_direction direction, struct dma_attrs *attrs)
|
||||
-{
|
||||
- if (cpu_needs_post_dma_flush(dev))
|
||||
- __dma_sync(dma_addr_to_page(dev, dma_addr),
|
||||
- dma_addr & ~PAGE_MASK, size, direction);
|
||||
- plat_post_dma_flush(dev);
|
||||
- plat_unmap_dma_mem(dev, dma_addr, size, direction);
|
||||
-}
|
||||
-
|
||||
-static int mips_dma_map_sg(struct device *dev, struct scatterlist *sg,
|
||||
- int nents, enum dma_data_direction direction, struct dma_attrs *attrs)
|
||||
-{
|
||||
- int i;
|
||||
-
|
||||
- for (i = 0; i < nents; i++, sg++) {
|
||||
- if (!plat_device_is_coherent(dev))
|
||||
- __dma_sync(sg_page(sg), sg->offset, sg->length,
|
||||
- direction);
|
||||
-#ifdef CONFIG_NEED_SG_DMA_LENGTH
|
||||
- sg->dma_length = sg->length;
|
||||
-#endif
|
||||
- sg->dma_address = plat_map_dma_mem_page(dev, sg_page(sg)) +
|
||||
- sg->offset;
|
||||
- }
|
||||
-
|
||||
- return nents;
|
||||
-}
|
||||
-
|
||||
-static dma_addr_t mips_dma_map_page(struct device *dev, struct page *page,
|
||||
- unsigned long offset, size_t size, enum dma_data_direction direction,
|
||||
- struct dma_attrs *attrs)
|
||||
-{
|
||||
- if (!plat_device_is_coherent(dev))
|
||||
- __dma_sync(page, offset, size, direction);
|
||||
-
|
||||
- return plat_map_dma_mem_page(dev, page) + offset;
|
||||
-}
|
||||
-
|
||||
-static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
|
||||
- int nhwentries, enum dma_data_direction direction,
|
||||
- struct dma_attrs *attrs)
|
||||
-{
|
||||
- int i;
|
||||
-
|
||||
- for (i = 0; i < nhwentries; i++, sg++) {
|
||||
- if (!plat_device_is_coherent(dev) &&
|
||||
- direction != DMA_TO_DEVICE)
|
||||
- __dma_sync(sg_page(sg), sg->offset, sg->length,
|
||||
- direction);
|
||||
- plat_unmap_dma_mem(dev, sg->dma_address, sg->length, direction);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-static void mips_dma_sync_single_for_cpu(struct device *dev,
|
||||
- dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
|
||||
-{
|
||||
- if (cpu_needs_post_dma_flush(dev))
|
||||
- __dma_sync(dma_addr_to_page(dev, dma_handle),
|
||||
- dma_handle & ~PAGE_MASK, size, direction);
|
||||
- plat_post_dma_flush(dev);
|
||||
-}
|
||||
-
|
||||
-static void mips_dma_sync_single_for_device(struct device *dev,
|
||||
- dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
|
||||
-{
|
||||
- if (!plat_device_is_coherent(dev))
|
||||
- __dma_sync(dma_addr_to_page(dev, dma_handle),
|
||||
- dma_handle & ~PAGE_MASK, size, direction);
|
||||
-}
|
||||
-
|
||||
-static void mips_dma_sync_sg_for_cpu(struct device *dev,
|
||||
- struct scatterlist *sg, int nelems, enum dma_data_direction direction)
|
||||
-{
|
||||
- int i;
|
||||
-
|
||||
- if (cpu_needs_post_dma_flush(dev))
|
||||
- for (i = 0; i < nelems; i++, sg++)
|
||||
- __dma_sync(sg_page(sg), sg->offset, sg->length,
|
||||
- direction);
|
||||
- plat_post_dma_flush(dev);
|
||||
-}
|
||||
-
|
||||
-static void mips_dma_sync_sg_for_device(struct device *dev,
|
||||
- struct scatterlist *sg, int nelems, enum dma_data_direction direction)
|
||||
-{
|
||||
- int i;
|
||||
-
|
||||
- if (!plat_device_is_coherent(dev))
|
||||
- for (i = 0; i < nelems; i++, sg++)
|
||||
- __dma_sync(sg_page(sg), sg->offset, sg->length,
|
||||
- direction);
|
||||
-}
|
||||
-
|
||||
-int mips_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
|
||||
-{
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-int mips_dma_supported(struct device *dev, u64 mask)
|
||||
-{
|
||||
- return plat_dma_supported(dev, mask);
|
||||
-}
|
||||
+EXPORT_SYMBOL(__dma_sync);
|
||||
|
||||
void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
|
||||
enum dma_data_direction direction)
|
||||
@@ -367,23 +238,10 @@ void dma_cache_sync(struct device *dev,
|
||||
|
||||
EXPORT_SYMBOL(dma_cache_sync);
|
||||
|
||||
-static struct dma_map_ops mips_default_dma_map_ops = {
|
||||
- .alloc = mips_dma_alloc_coherent,
|
||||
- .free = mips_dma_free_coherent,
|
||||
- .map_page = mips_dma_map_page,
|
||||
- .unmap_page = mips_dma_unmap_page,
|
||||
- .map_sg = mips_dma_map_sg,
|
||||
- .unmap_sg = mips_dma_unmap_sg,
|
||||
- .sync_single_for_cpu = mips_dma_sync_single_for_cpu,
|
||||
- .sync_single_for_device = mips_dma_sync_single_for_device,
|
||||
- .sync_sg_for_cpu = mips_dma_sync_sg_for_cpu,
|
||||
- .sync_sg_for_device = mips_dma_sync_sg_for_device,
|
||||
- .mapping_error = mips_dma_mapping_error,
|
||||
- .dma_supported = mips_dma_supported
|
||||
-};
|
||||
-
|
||||
-struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops;
|
||||
+#ifdef CONFIG_SYS_HAS_DMA_OPS
|
||||
+struct dma_map_ops *mips_dma_map_ops = NULL;
|
||||
EXPORT_SYMBOL(mips_dma_map_ops);
|
||||
+#endif
|
||||
|
||||
#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
|
||||
|
@ -1,53 +0,0 @@
|
||||
From 71a0a72456b48de972d7ed613b06a22a3aa9057f Mon Sep 17 00:00:00 2001
|
||||
From: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
Date: Sat, 26 Sep 2015 13:41:43 +0800
|
||||
Subject: [PATCH] MIPS: UAPI: Ignore __arch_swab{16,32,64} when using MIPS16
|
||||
|
||||
Some GCC versions (e.g. 4.8.3) can incorrectly inline a function with
|
||||
MIPS32 instructions into another function with MIPS16 code [1], causing
|
||||
the assembler to genereate incorrect binary code or fail right away
|
||||
complaining about unrecognized opcode.
|
||||
|
||||
In the case of __arch_swab{16,32}, when inlined by the compiler with
|
||||
flags `-mips32r2 -mips16 -Os', the assembler can fail with the following
|
||||
error.
|
||||
|
||||
{standard input}:79: Error: unrecognized opcode `wsbh $2,$2'
|
||||
|
||||
For performance concerns and to workaround the issue already existing in
|
||||
older compilers, just ignore these 2 functions when compiling with
|
||||
mips16 enabled.
|
||||
|
||||
[1] Inlining nomips16 function into mips16 function can result in
|
||||
undefined builtins, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55777
|
||||
|
||||
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
Cc: Maciej W. Rozycki <macro@linux-mips.org>
|
||||
Cc: linux-mips@linux-mips.org
|
||||
Patchwork: https://patchwork.linux-mips.org/patch/11241/
|
||||
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
|
||||
---
|
||||
arch/mips/include/uapi/asm/swab.h | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/arch/mips/include/uapi/asm/swab.h
|
||||
+++ b/arch/mips/include/uapi/asm/swab.h
|
||||
@@ -13,8 +13,9 @@
|
||||
|
||||
#define __SWAB_64_THRU_32__
|
||||
|
||||
-#if (defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \
|
||||
- defined(_MIPS_ARCH_LOONGSON3A)
|
||||
+#if !defined(__mips16) && \
|
||||
+ ((defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \
|
||||
+ defined(_MIPS_ARCH_LOONGSON3A))
|
||||
|
||||
static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
|
||||
{
|
||||
@@ -65,5 +66,5 @@ static inline __attribute_const__ __u64
|
||||
}
|
||||
#define __arch_swab64 __arch_swab64
|
||||
#endif /* __mips64 */
|
||||
-#endif /* MIPS R2 or newer or Loongson 3A */
|
||||
+#endif /* (not __mips16) and (MIPS R2 or newer or Loongson 3A) */
|
||||
#endif /* _ASM_SWAB_H */
|
@ -1,175 +0,0 @@
|
||||
From 173b0add0cff6558f950c0cb1eacfb729d482711 Mon Sep 17 00:00:00 2001
|
||||
From: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
Date: Sun, 17 May 2015 18:48:38 +0200
|
||||
Subject: [PATCH 4/8] mtd: part: add generic parsing of linux,part-probe
|
||||
|
||||
This moves the linux,part-probe device tree parsing code from
|
||||
physmap_of.c to mtdpart.c. Now all drivers can use this feature by just
|
||||
providing a reference to their device tree node in struct
|
||||
mtd_part_parser_data.
|
||||
|
||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
---
|
||||
Documentation/devicetree/bindings/mtd/nand.txt | 16 ++++++++++
|
||||
drivers/mtd/maps/physmap_of.c | 40 +-----------------------
|
||||
drivers/mtd/mtdpart.c | 43 ++++++++++++++++++++++++++
|
||||
3 files changed, 60 insertions(+), 39 deletions(-)
|
||||
|
||||
--- a/Documentation/devicetree/bindings/mtd/nand.txt
|
||||
+++ b/Documentation/devicetree/bindings/mtd/nand.txt
|
||||
@@ -12,6 +12,22 @@
|
||||
- nand-ecc-step-size: integer representing the number of data bytes
|
||||
that are covered by a single ECC step.
|
||||
|
||||
+- linux,part-probe: list of name as strings of the partition parser
|
||||
+ which should be used to parse the partition table.
|
||||
+ They will be tried in the specified ordering and
|
||||
+ the next one will be used if the previous one
|
||||
+ failed.
|
||||
+
|
||||
+ Example: linux,part-probe = "cmdlinepart", "ofpart";
|
||||
+
|
||||
+ This is also the default value, which will be used
|
||||
+ if this attribute is not specified. It could be
|
||||
+ that the flash driver in use overwrote the default
|
||||
+ value and uses some other default.
|
||||
+
|
||||
+ Possible values are: bcm47xxpart, afs, ar7part,
|
||||
+ ofoldpart, ofpart, bcm63xxpart, RedBoot, cmdlinepart
|
||||
+
|
||||
The ECC strength and ECC step size properties define the correction capability
|
||||
of a controller. Together, they say a controller can correct "{strength} bit
|
||||
errors per {size} bytes".
|
||||
--- a/drivers/mtd/maps/physmap_of.c
|
||||
+++ b/drivers/mtd/maps/physmap_of.c
|
||||
@@ -112,45 +112,9 @@ static struct mtd_info *obsolete_probe(s
|
||||
static const char * const part_probe_types_def[] = {
|
||||
"cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL };
|
||||
|
||||
-static const char * const *of_get_probes(struct device_node *dp)
|
||||
-{
|
||||
- const char *cp;
|
||||
- int cplen;
|
||||
- unsigned int l;
|
||||
- unsigned int count;
|
||||
- const char **res;
|
||||
-
|
||||
- cp = of_get_property(dp, "linux,part-probe", &cplen);
|
||||
- if (cp == NULL)
|
||||
- return part_probe_types_def;
|
||||
-
|
||||
- count = 0;
|
||||
- for (l = 0; l != cplen; l++)
|
||||
- if (cp[l] == 0)
|
||||
- count++;
|
||||
-
|
||||
- res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
|
||||
- count = 0;
|
||||
- while (cplen > 0) {
|
||||
- res[count] = cp;
|
||||
- l = strlen(cp) + 1;
|
||||
- cp += l;
|
||||
- cplen -= l;
|
||||
- count++;
|
||||
- }
|
||||
- return res;
|
||||
-}
|
||||
-
|
||||
-static void of_free_probes(const char * const *probes)
|
||||
-{
|
||||
- if (probes != part_probe_types_def)
|
||||
- kfree(probes);
|
||||
-}
|
||||
-
|
||||
static struct of_device_id of_flash_match[];
|
||||
static int of_flash_probe(struct platform_device *dev)
|
||||
{
|
||||
- const char * const *part_probe_types;
|
||||
const struct of_device_id *match;
|
||||
struct device_node *dp = dev->dev.of_node;
|
||||
struct resource res;
|
||||
@@ -310,10 +274,8 @@ static int of_flash_probe(struct platfor
|
||||
goto err_out;
|
||||
|
||||
ppdata.of_node = dp;
|
||||
- part_probe_types = of_get_probes(dp);
|
||||
- mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
|
||||
+ mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
|
||||
NULL, 0);
|
||||
- of_free_probes(part_probe_types);
|
||||
|
||||
kfree(mtd_list);
|
||||
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
+#include <linux/of.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/kconfig.h>
|
||||
|
||||
@@ -719,6 +720,40 @@ void deregister_mtd_parser(struct mtd_pa
|
||||
EXPORT_SYMBOL_GPL(deregister_mtd_parser);
|
||||
|
||||
/*
|
||||
+ * Parses the linux,part-probe device tree property.
|
||||
+ * When a non null value is returned it has to be freed with kfree() by
|
||||
+ * the caller.
|
||||
+ */
|
||||
+static const char * const *of_get_probes(struct device_node *dp)
|
||||
+{
|
||||
+ const char *cp;
|
||||
+ int cplen;
|
||||
+ unsigned int l;
|
||||
+ unsigned int count;
|
||||
+ const char **res;
|
||||
+
|
||||
+ cp = of_get_property(dp, "linux,part-probe", &cplen);
|
||||
+ if (cp == NULL)
|
||||
+ return NULL;
|
||||
+
|
||||
+ count = 0;
|
||||
+ for (l = 0; l != cplen; l++)
|
||||
+ if (cp[l] == 0)
|
||||
+ count++;
|
||||
+
|
||||
+ res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
|
||||
+ count = 0;
|
||||
+ while (cplen > 0) {
|
||||
+ res[count] = cp;
|
||||
+ l = strlen(cp) + 1;
|
||||
+ cp += l;
|
||||
+ cplen -= l;
|
||||
+ count++;
|
||||
+ }
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
* Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
|
||||
* are changing this array!
|
||||
*/
|
||||
@@ -754,6 +789,13 @@ int parse_mtd_partitions(struct mtd_info
|
||||
{
|
||||
struct mtd_part_parser *parser;
|
||||
int ret = 0;
|
||||
+ const char *const *types_of = NULL;
|
||||
+
|
||||
+ if (data && data->of_node) {
|
||||
+ types_of = of_get_probes(data->of_node);
|
||||
+ if (types_of != NULL)
|
||||
+ types = types_of;
|
||||
+ }
|
||||
|
||||
if (!types)
|
||||
types = default_mtd_part_types;
|
||||
@@ -772,6 +814,7 @@ int parse_mtd_partitions(struct mtd_info
|
||||
break;
|
||||
}
|
||||
}
|
||||
+ kfree(types_of);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Thu, 26 Nov 2015 17:03:46 +0100
|
||||
Subject: [PATCH] Revert "mtd: spi-nor: disable protection for Winbond flash at
|
||||
startup"
|
||||
|
||||
This reverts commit c6fc2171b249e73745c497b578b417a2946f1b2f.
|
||||
|
||||
This commit is breaking read access on at least s25fl064k, but also
|
||||
possibly other Spansion flash chips.
|
||||
|
||||
Any mtd read seems to succeed, but simply returns a zero-filled buffer.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/drivers/mtd/spi-nor/spi-nor.c
|
||||
+++ b/drivers/mtd/spi-nor/spi-nor.c
|
||||
@@ -1194,14 +1194,13 @@ int spi_nor_scan(struct spi_nor *nor, co
|
||||
mutex_init(&nor->lock);
|
||||
|
||||
/*
|
||||
- * Atmel, SST, Intel/Numonyx, and others serial NOR tend to power up
|
||||
- * with the software protection bits set
|
||||
+ * Atmel, SST and Intel/Numonyx serial nor tend to power
|
||||
+ * up with the software protection bits set
|
||||
*/
|
||||
|
||||
if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
|
||||
JEDEC_MFR(info) == SNOR_MFR_INTEL ||
|
||||
- JEDEC_MFR(info) == SNOR_MFR_SST ||
|
||||
- JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
|
||||
+ JEDEC_MFR(info) == SNOR_MFR_SST) {
|
||||
write_enable(nor);
|
||||
write_sr(nor, 0);
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
From 72fc448c4c970bdbba604ab340f16080b4f3bb17 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
|
||||
Date: Thu, 26 Nov 2015 08:52:09 +0100
|
||||
Subject: [PATCH] mtd: spi-nor: include mtd.h header for struct mtd_info
|
||||
definition
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
So far struct spi_nor was using just a pointer to struct mtd_info so it
|
||||
wasn't needed to have it fully defined there. After recent change we
|
||||
embed whole struct so we need to include a proper header.
|
||||
|
||||
Fixes: 1976367173a4 ("mtd: spi-nor: embed struct mtd_info within struct spi_nor")
|
||||
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
|
||||
---
|
||||
include/linux/mtd/spi-nor.h | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
--- a/include/linux/mtd/spi-nor.h
|
||||
+++ b/include/linux/mtd/spi-nor.h
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/mtd/cfi.h>
|
||||
+#include <linux/mtd/mtd.h>
|
||||
|
||||
/*
|
||||
* Manufacturer IDs
|
||||
@@ -117,8 +118,6 @@ enum spi_nor_option_flags {
|
||||
SNOR_F_USE_FSR = BIT(0),
|
||||
};
|
||||
|
||||
-struct mtd_info;
|
||||
-
|
||||
/**
|
||||
* struct spi_nor - Structure for defining a the SPI NOR layer
|
||||
* @mtd: point to a mtd_info structure
|
@ -1,33 +0,0 @@
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
|
||||
Date: Sat, 5 Dec 2015 02:03:32 +0100
|
||||
Subject: [PATCH] mtd: bcm47xxpart: limit scanned flash area on BCM47XX (MIPS)
|
||||
only
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
We allowed using bcm47xxpart on BCM5301X arch with commit:
|
||||
9e3afa5f5c7 ("mtd: bcm47xxpart: allow enabling on ARCH_BCM_5301X")
|
||||
|
||||
BCM5301X devices may contain some partitions in higher memory, e.g.
|
||||
Netgear R8000 has board_data at 0x2600000. To detect them we should
|
||||
use size limit on MIPS only.
|
||||
|
||||
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
|
||||
---
|
||||
drivers/mtd/bcm47xxpart.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/mtd/bcm47xxpart.c
|
||||
+++ b/drivers/mtd/bcm47xxpart.c
|
||||
@@ -118,8 +118,8 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
/* Parse block by block looking for magics */
|
||||
for (offset = 0; offset <= master->size - blocksize;
|
||||
offset += blocksize) {
|
||||
- /* Nothing more in higher memory */
|
||||
- if (offset >= 0x2000000)
|
||||
+ /* Nothing more in higher memory on BCM47XX (MIPS) */
|
||||
+ if (config_enabled(CONFIG_BCM47XX) && offset >= 0x2000000)
|
||||
break;
|
||||
|
||||
if (curr_part >= BCM47XXPART_MAX_PARTS) {
|
@ -1,92 +0,0 @@
|
||||
From dfe4b4c732365fc1d83c2d2fd9cc18054ae850b7 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
|
||||
Date: Sun, 6 Dec 2015 11:24:05 +0100
|
||||
Subject: [PATCH] mtd: bcm47xxpart: don't fail because of bit-flips
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Bit-flip errors may occur on NAND flashes and are harmless. Handle them
|
||||
gracefully as read content is still reliable and can be parsed.
|
||||
|
||||
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
|
||||
---
|
||||
drivers/mtd/bcm47xxpart.c | 38 ++++++++++++++++++++++----------------
|
||||
1 file changed, 22 insertions(+), 16 deletions(-)
|
||||
|
||||
--- a/drivers/mtd/bcm47xxpart.c
|
||||
+++ b/drivers/mtd/bcm47xxpart.c
|
||||
@@ -66,11 +66,13 @@ static const char *bcm47xxpart_trx_data_
|
||||
{
|
||||
uint32_t buf;
|
||||
size_t bytes_read;
|
||||
+ int err;
|
||||
|
||||
- if (mtd_read(master, offset, sizeof(buf), &bytes_read,
|
||||
- (uint8_t *)&buf) < 0) {
|
||||
- pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
|
||||
- offset);
|
||||
+ err = mtd_read(master, offset, sizeof(buf), &bytes_read,
|
||||
+ (uint8_t *)&buf);
|
||||
+ if (err && !mtd_is_bitflip(err)) {
|
||||
+ pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
|
||||
+ offset, err);
|
||||
goto out_default;
|
||||
}
|
||||
|
||||
@@ -95,6 +97,7 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
int trx_part = -1;
|
||||
int last_trx_part = -1;
|
||||
int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
|
||||
+ int err;
|
||||
|
||||
/*
|
||||
* Some really old flashes (like AT45DB*) had smaller erasesize-s, but
|
||||
@@ -128,10 +131,11 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
}
|
||||
|
||||
/* Read beginning of the block */
|
||||
- if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
|
||||
- &bytes_read, (uint8_t *)buf) < 0) {
|
||||
- pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
|
||||
- offset);
|
||||
+ err = mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
|
||||
+ &bytes_read, (uint8_t *)buf);
|
||||
+ if (err && !mtd_is_bitflip(err)) {
|
||||
+ pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
|
||||
+ offset, err);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -254,10 +258,11 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
}
|
||||
|
||||
/* Read middle of the block */
|
||||
- if (mtd_read(master, offset + 0x8000, 0x4,
|
||||
- &bytes_read, (uint8_t *)buf) < 0) {
|
||||
- pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
|
||||
- offset);
|
||||
+ err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read,
|
||||
+ (uint8_t *)buf);
|
||||
+ if (err && !mtd_is_bitflip(err)) {
|
||||
+ pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
|
||||
+ offset, err);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -277,10 +282,11 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
}
|
||||
|
||||
offset = master->size - possible_nvram_sizes[i];
|
||||
- if (mtd_read(master, offset, 0x4, &bytes_read,
|
||||
- (uint8_t *)buf) < 0) {
|
||||
- pr_err("mtd_read error while reading at offset 0x%X!\n",
|
||||
- offset);
|
||||
+ err = mtd_read(master, offset, 0x4, &bytes_read,
|
||||
+ (uint8_t *)buf);
|
||||
+ if (err && !mtd_is_bitflip(err)) {
|
||||
+ pr_err("mtd_read error while reading (offset 0x%X): %d\n",
|
||||
+ offset, err);
|
||||
continue;
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
From 9612e686b235dc9e33c8dfb5e6d2ff2b2140fb9d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
|
||||
Date: Tue, 16 Jun 2015 21:01:30 +0200
|
||||
Subject: [PATCH V2] usb: xhci: make USB_XHCI_PLATFORM selectable
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Right now xhci-plat-hcd can be built when using one of platform specific
|
||||
drivers only (mvebu/rcar). There shouldn't be such limitation as some
|
||||
platforms may not require any quirks and may want to just use a generic
|
||||
driver ("generic-xhci" / "xhci-hcd").
|
||||
|
||||
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
|
||||
---
|
||||
Greg/Mathias: I'm not sure if it's more like USB subsystem stuff or xHCI
|
||||
Could you decide which one of you could pick that, please?
|
||||
|
||||
V2: Drop useless "default n", thanks Sergei :)
|
||||
---
|
||||
drivers/usb/host/Kconfig | 9 ++++++++-
|
||||
1 file changed, 8 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/usb/host/Kconfig
|
||||
+++ b/drivers/usb/host/Kconfig
|
||||
@@ -32,7 +32,14 @@ config USB_XHCI_PCI
|
||||
default y
|
||||
|
||||
config USB_XHCI_PLATFORM
|
||||
- tristate
|
||||
+ tristate "Generic xHCI driver for a platform device"
|
||||
+ ---help---
|
||||
+ Adds an xHCI host driver for a generic platform device, which
|
||||
+ provides a memory space and an irq.
|
||||
+ It is also a prerequisite for platform specific drivers that
|
||||
+ implement some extra quirks.
|
||||
+
|
||||
+ If unsure, say N.
|
||||
|
||||
config USB_XHCI_MVEBU
|
||||
tristate "xHCI support for Marvell Armada 375/38x"
|
@ -1,232 +0,0 @@
|
||||
From 4a0e3e989d66bb7204b163d9cfaa7fa96d0f2023 Mon Sep 17 00:00:00 2001
|
||||
From: Enrico Mioso <mrkiko.rs@gmail.com>
|
||||
Date: Wed, 8 Jul 2015 13:05:57 +0200
|
||||
Subject: [PATCH] cdc_ncm: Add support for moving NDP to end of NCM frame
|
||||
|
||||
NCM specs are not actually mandating a specific position in the frame for
|
||||
the NDP (Network Datagram Pointer). However, some Huawei devices will
|
||||
ignore our aggregates if it is not placed after the datagrams it points
|
||||
to. Add support for doing just this, in a per-device configurable way.
|
||||
While at it, update NCM subdrivers, disabling this functionality in all of
|
||||
them, except in huawei_cdc_ncm where it is enabled instead.
|
||||
We aren't making any distinction between different Huawei NCM devices,
|
||||
based on what the vendor driver does. Standard NCM devices are left
|
||||
unaffected: if they are compliant, they should be always usable, still
|
||||
stay on the safe side.
|
||||
|
||||
This change has been tested and working with a Huawei E3131 device (which
|
||||
works regardless of NDP position), a Huawei E3531 (also working both
|
||||
ways) and an E3372 (which mandates NDP to be after indexed datagrams).
|
||||
|
||||
V1->V2:
|
||||
- corrected wrong NDP acronym definition
|
||||
- fixed possible NULL pointer dereference
|
||||
- patch cleanup
|
||||
V2->V3:
|
||||
- Properly account for the NDP size when writing new packets to SKB
|
||||
|
||||
Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/cdc_mbim.c | 2 +-
|
||||
drivers/net/usb/cdc_ncm.c | 61 ++++++++++++++++++++++++++++++++++++----
|
||||
drivers/net/usb/huawei_cdc_ncm.c | 7 +++--
|
||||
include/linux/usb/cdc_ncm.h | 7 ++++-
|
||||
4 files changed, 67 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/cdc_mbim.c
|
||||
+++ b/drivers/net/usb/cdc_mbim.c
|
||||
@@ -158,7 +158,7 @@ static int cdc_mbim_bind(struct usbnet *
|
||||
if (!cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting))
|
||||
goto err;
|
||||
|
||||
- ret = cdc_ncm_bind_common(dev, intf, data_altsetting);
|
||||
+ ret = cdc_ncm_bind_common(dev, intf, data_altsetting, 0);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
--- a/drivers/net/usb/cdc_ncm.c
|
||||
+++ b/drivers/net/usb/cdc_ncm.c
|
||||
@@ -685,6 +685,8 @@ static void cdc_ncm_free(struct cdc_ncm_
|
||||
ctx->tx_curr_skb = NULL;
|
||||
}
|
||||
|
||||
+ kfree(ctx->delayed_ndp16);
|
||||
+
|
||||
kfree(ctx);
|
||||
}
|
||||
|
||||
@@ -715,7 +717,7 @@ static const struct net_device_ops cdc_n
|
||||
.ndo_validate_addr = eth_validate_addr,
|
||||
};
|
||||
|
||||
-int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting)
|
||||
+int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags)
|
||||
{
|
||||
const struct usb_cdc_union_desc *union_desc = NULL;
|
||||
struct cdc_ncm_ctx *ctx;
|
||||
@@ -894,6 +896,17 @@ advance:
|
||||
/* finish setting up the device specific data */
|
||||
cdc_ncm_setup(dev);
|
||||
|
||||
+ /* Device-specific flags */
|
||||
+ ctx->drvflags = drvflags;
|
||||
+
|
||||
+ /* Allocate the delayed NDP if needed. */
|
||||
+ if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
|
||||
+ ctx->delayed_ndp16 = kzalloc(ctx->max_ndp_size, GFP_KERNEL);
|
||||
+ if (!ctx->delayed_ndp16)
|
||||
+ goto error2;
|
||||
+ dev_info(&intf->dev, "NDP will be placed at end of frame for this device.");
|
||||
+ }
|
||||
+
|
||||
/* override ethtool_ops */
|
||||
dev->net->ethtool_ops = &cdc_ncm_ethtool_ops;
|
||||
|
||||
@@ -996,8 +1009,11 @@ static int cdc_ncm_bind(struct usbnet *d
|
||||
if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM)
|
||||
return -ENODEV;
|
||||
|
||||
- /* The NCM data altsetting is fixed */
|
||||
- ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM);
|
||||
+ /* The NCM data altsetting is fixed, so we hard-coded it.
|
||||
+ * Additionally, generic NCM devices are assumed to accept arbitrarily
|
||||
+ * placed NDP.
|
||||
+ */
|
||||
+ ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM, 0);
|
||||
|
||||
/*
|
||||
* We should get an event when network connection is "connected" or
|
||||
@@ -1028,6 +1044,14 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm
|
||||
struct usb_cdc_ncm_nth16 *nth16 = (void *)skb->data;
|
||||
size_t ndpoffset = le16_to_cpu(nth16->wNdpIndex);
|
||||
|
||||
+ /* If NDP should be moved to the end of the NCM package, we can't follow the
|
||||
+ * NTH16 header as we would normally do. NDP isn't written to the SKB yet, and
|
||||
+ * the wNdpIndex field in the header is actually not consistent with reality. It will be later.
|
||||
+ */
|
||||
+ if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END)
|
||||
+ if (ctx->delayed_ndp16->dwSignature == sign)
|
||||
+ return ctx->delayed_ndp16;
|
||||
+
|
||||
/* follow the chain of NDPs, looking for a match */
|
||||
while (ndpoffset) {
|
||||
ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb->data + ndpoffset);
|
||||
@@ -1037,7 +1061,8 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm
|
||||
}
|
||||
|
||||
/* align new NDP */
|
||||
- cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max);
|
||||
+ if (!(ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END))
|
||||
+ cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max);
|
||||
|
||||
/* verify that there is room for the NDP and the datagram (reserve) */
|
||||
if ((ctx->tx_max - skb->len - reserve) < ctx->max_ndp_size)
|
||||
@@ -1050,7 +1075,11 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm
|
||||
nth16->wNdpIndex = cpu_to_le16(skb->len);
|
||||
|
||||
/* push a new empty NDP */
|
||||
- ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, ctx->max_ndp_size), 0, ctx->max_ndp_size);
|
||||
+ if (!(ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END))
|
||||
+ ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, ctx->max_ndp_size), 0, ctx->max_ndp_size);
|
||||
+ else
|
||||
+ ndp16 = ctx->delayed_ndp16;
|
||||
+
|
||||
ndp16->dwSignature = sign;
|
||||
ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16));
|
||||
return ndp16;
|
||||
@@ -1065,6 +1094,15 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev
|
||||
struct sk_buff *skb_out;
|
||||
u16 n = 0, index, ndplen;
|
||||
u8 ready2send = 0;
|
||||
+ u32 delayed_ndp_size;
|
||||
+
|
||||
+ /* When our NDP gets written in cdc_ncm_ndp(), then skb_out->len gets updated
|
||||
+ * accordingly. Otherwise, we should check here.
|
||||
+ */
|
||||
+ if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END)
|
||||
+ delayed_ndp_size = ctx->max_ndp_size;
|
||||
+ else
|
||||
+ delayed_ndp_size = 0;
|
||||
|
||||
/* if there is a remaining skb, it gets priority */
|
||||
if (skb != NULL) {
|
||||
@@ -1119,7 +1157,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev
|
||||
cdc_ncm_align_tail(skb_out, ctx->tx_modulus, ctx->tx_remainder, ctx->tx_max);
|
||||
|
||||
/* check if we had enough room left for both NDP and frame */
|
||||
- if (!ndp16 || skb_out->len + skb->len > ctx->tx_max) {
|
||||
+ if (!ndp16 || skb_out->len + skb->len + delayed_ndp_size > ctx->tx_max) {
|
||||
if (n == 0) {
|
||||
/* won't fit, MTU problem? */
|
||||
dev_kfree_skb_any(skb);
|
||||
@@ -1192,6 +1230,17 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev
|
||||
/* variables will be reset at next call */
|
||||
}
|
||||
|
||||
+ /* If requested, put NDP at end of frame. */
|
||||
+ if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
|
||||
+ nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data;
|
||||
+ cdc_ncm_align_tail(skb_out, ctx->tx_ndp_modulus, 0, ctx->tx_max);
|
||||
+ nth16->wNdpIndex = cpu_to_le16(skb_out->len);
|
||||
+ memcpy(skb_put(skb_out, ctx->max_ndp_size), ctx->delayed_ndp16, ctx->max_ndp_size);
|
||||
+
|
||||
+ /* Zero out delayed NDP - signature checking will naturally fail. */
|
||||
+ ndp16 = memset(ctx->delayed_ndp16, 0, ctx->max_ndp_size);
|
||||
+ }
|
||||
+
|
||||
/* If collected data size is less or equal ctx->min_tx_pkt
|
||||
* bytes, we send buffers as it is. If we get more data, it
|
||||
* would be more efficient for USB HS mobile device with DMA
|
||||
--- a/drivers/net/usb/huawei_cdc_ncm.c
|
||||
+++ b/drivers/net/usb/huawei_cdc_ncm.c
|
||||
@@ -73,11 +73,14 @@ static int huawei_cdc_ncm_bind(struct us
|
||||
struct usb_driver *subdriver = ERR_PTR(-ENODEV);
|
||||
int ret = -ENODEV;
|
||||
struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
|
||||
+ int drvflags = 0;
|
||||
|
||||
/* altsetting should always be 1 for NCM devices - so we hard-coded
|
||||
- * it here
|
||||
+ * it here. Some huawei devices will need the NDP part of the NCM package to
|
||||
+ * be at the end of the frame.
|
||||
*/
|
||||
- ret = cdc_ncm_bind_common(usbnet_dev, intf, 1);
|
||||
+ drvflags |= CDC_NCM_FLAG_NDP_TO_END;
|
||||
+ ret = cdc_ncm_bind_common(usbnet_dev, intf, 1, drvflags);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
--- a/include/linux/usb/cdc_ncm.h
|
||||
+++ b/include/linux/usb/cdc_ncm.h
|
||||
@@ -80,6 +80,9 @@
|
||||
#define CDC_NCM_TIMER_INTERVAL_MIN 5UL
|
||||
#define CDC_NCM_TIMER_INTERVAL_MAX (U32_MAX / NSEC_PER_USEC)
|
||||
|
||||
+/* Driver flags */
|
||||
+#define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */
|
||||
+
|
||||
#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \
|
||||
(x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)
|
||||
#define cdc_ncm_data_intf_is_mbim(x) ((x)->desc.bInterfaceProtocol == USB_CDC_MBIM_PROTO_NTB)
|
||||
@@ -103,9 +106,11 @@ struct cdc_ncm_ctx {
|
||||
|
||||
spinlock_t mtx;
|
||||
atomic_t stop;
|
||||
+ int drvflags;
|
||||
|
||||
u32 timer_interval;
|
||||
u32 max_ndp_size;
|
||||
+ struct usb_cdc_ncm_ndp16 *delayed_ndp16;
|
||||
|
||||
u32 tx_timer_pending;
|
||||
u32 tx_curr_frame_num;
|
||||
@@ -134,7 +139,7 @@ struct cdc_ncm_ctx {
|
||||
|
||||
u8 cdc_ncm_select_altsetting(struct usb_interface *intf);
|
||||
int cdc_ncm_change_mtu(struct net_device *net, int new_mtu);
|
||||
-int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting);
|
||||
+int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags);
|
||||
void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf);
|
||||
struct sk_buff *cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign);
|
||||
int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in);
|
@ -1,96 +0,0 @@
|
||||
From fe29727caa7fe434fcb3166df2a62672bc516b54 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <ynezz@true.cz>
|
||||
Date: Wed, 4 Nov 2015 16:23:37 +0100
|
||||
Subject: [PATCH 2/2] USB: qmi_wwan: Add quirk for Quectel EC20 Mini PCIe
|
||||
module
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This device has same vendor and product IDs as G2K devices, but it has
|
||||
different number of interfaces(4 vs 5) and also different interface
|
||||
layout where EC20 has QMI on interface 4 instead of 0.
|
||||
|
||||
lsusb output:
|
||||
|
||||
Bus 002 Device 003: ID 05c6:9215 Qualcomm, Inc. Acer Gobi 2000
|
||||
Device Descriptor:
|
||||
bLength 18
|
||||
bDescriptorType 1
|
||||
bcdUSB 2.00
|
||||
bDeviceClass 0 (Defined at Interface level)
|
||||
bDeviceSubClass 0
|
||||
bDeviceProtocol 0
|
||||
bMaxPacketSize0 64
|
||||
idVendor 0x05c6 Qualcomm, Inc.
|
||||
idProduct 0x9215 Acer Gobi 2000 Wireless Modem
|
||||
bcdDevice 2.32
|
||||
iManufacturer 1 Quectel
|
||||
iProduct 2 Quectel LTE Module
|
||||
iSerial 0
|
||||
bNumConfigurations 1
|
||||
Configuration Descriptor:
|
||||
bLength 9
|
||||
bDescriptorType 2
|
||||
wTotalLength 209
|
||||
bNumInterfaces 5
|
||||
bConfigurationValue 1
|
||||
iConfiguration 0
|
||||
bmAttributes 0xa0
|
||||
(Bus Powered)
|
||||
Remote Wakeup
|
||||
MaxPower 500mA
|
||||
|
||||
Signed-off-by: Petr Štetiar <ynezz@true.cz>
|
||||
---
|
||||
drivers/net/usb/qmi_wwan.c | 21 +++++++++++++++++++++
|
||||
1 file changed, 21 insertions(+)
|
||||
|
||||
--- a/drivers/net/usb/qmi_wwan.c
|
||||
+++ b/drivers/net/usb/qmi_wwan.c
|
||||
@@ -824,6 +824,7 @@ static const struct usb_device_id produc
|
||||
{QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
|
||||
{QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
|
||||
{QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
|
||||
+ {QMI_FIXED_INTF(0x05c6, 0x9215, 4)}, /* Quectel EC20 Mini PCIe */
|
||||
{QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
|
||||
{QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
|
||||
{QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
|
||||
@@ -855,10 +856,24 @@ static const struct usb_device_id produc
|
||||
};
|
||||
MODULE_DEVICE_TABLE(usb, products);
|
||||
|
||||
+static bool quectel_ec20_detected(struct usb_interface *intf)
|
||||
+{
|
||||
+ struct usb_device *dev = interface_to_usbdev(intf);
|
||||
+
|
||||
+ if (dev->actconfig &&
|
||||
+ le16_to_cpu(dev->descriptor.idVendor) == 0x05c6 &&
|
||||
+ le16_to_cpu(dev->descriptor.idProduct) == 0x9215 &&
|
||||
+ dev->actconfig->desc.bNumInterfaces == 5)
|
||||
+ return true;
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static int qmi_wwan_probe(struct usb_interface *intf,
|
||||
const struct usb_device_id *prod)
|
||||
{
|
||||
struct usb_device_id *id = (struct usb_device_id *)prod;
|
||||
+ struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
|
||||
|
||||
/* Workaround to enable dynamic IDs. This disables usbnet
|
||||
* blacklisting functionality. Which, if required, can be
|
||||
@@ -870,6 +885,12 @@ static int qmi_wwan_probe(struct usb_int
|
||||
id->driver_info = (unsigned long)&qmi_wwan_info;
|
||||
}
|
||||
|
||||
+ /* Quectel EC20 quirk where we've QMI on interface 4 instead of 0 */
|
||||
+ if (quectel_ec20_detected(intf) && desc->bInterfaceNumber == 0) {
|
||||
+ dev_dbg(&intf->dev, "Quectel EC20 quirk, skipping interface 0\n");
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
return usbnet_probe(intf, id);
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
--- a/scripts/setlocalversion
|
||||
+++ b/scripts/setlocalversion
|
||||
@@ -165,7 +165,7 @@ else
|
||||
# annotated or signed tagged state (as git describe only
|
||||
# looks at signed or annotated tags - git tag -a/-s) and
|
||||
# LOCALVERSION= is not specified
|
||||
- if test "${LOCALVERSION+set}" != "set"; then
|
||||
+ if test "${CONFIG_LOCALVERSION+set}" != "set"; then
|
||||
scm=$(scm_version --short)
|
||||
res="$res${scm:++}"
|
||||
fi
|
@ -1,14 +0,0 @@
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -612,9 +612,9 @@ include arch/$(SRCARCH)/Makefile
|
||||
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
|
||||
|
||||
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
|
||||
-KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
|
||||
+KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION) $(call cc-disable-warning,maybe-uninitialized,)
|
||||
else
|
||||
-KBUILD_CFLAGS += -O2
|
||||
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
|
||||
endif
|
||||
|
||||
# Tell gcc to never replace conditional load with a non-conditional one
|
@ -1,11 +0,0 @@
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -408,7 +408,7 @@ KBUILD_CFLAGS_KERNEL :=
|
||||
KBUILD_AFLAGS := -D__ASSEMBLY__
|
||||
KBUILD_AFLAGS_MODULE := -DMODULE
|
||||
KBUILD_CFLAGS_MODULE := -DMODULE
|
||||
-KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
|
||||
+KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds $(if $(CONFIG_PROFILING),,-s)
|
||||
|
||||
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
|
||||
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
|
@ -1,108 +0,0 @@
|
||||
--- a/scripts/kallsyms.c
|
||||
+++ b/scripts/kallsyms.c
|
||||
@@ -58,6 +58,7 @@ static struct addr_range percpu_range =
|
||||
static struct sym_entry *table;
|
||||
static unsigned int table_size, table_cnt;
|
||||
static int all_symbols = 0;
|
||||
+static int uncompressed = 0;
|
||||
static int absolute_percpu = 0;
|
||||
static char symbol_prefix_char = '\0';
|
||||
static unsigned long long kernel_start_addr = 0;
|
||||
@@ -403,6 +404,9 @@ static void write_src(void)
|
||||
|
||||
free(markers);
|
||||
|
||||
+ if (uncompressed)
|
||||
+ return;
|
||||
+
|
||||
output_label("kallsyms_token_table");
|
||||
off = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
@@ -461,6 +465,9 @@ static void *find_token(unsigned char *s
|
||||
{
|
||||
int i;
|
||||
|
||||
+ if (uncompressed)
|
||||
+ return NULL;
|
||||
+
|
||||
for (i = 0; i < len - 1; i++) {
|
||||
if (str[i] == token[0] && str[i+1] == token[1])
|
||||
return &str[i];
|
||||
@@ -533,6 +540,9 @@ static void optimize_result(void)
|
||||
{
|
||||
int i, best;
|
||||
|
||||
+ if (uncompressed)
|
||||
+ return;
|
||||
+
|
||||
/* using the '\0' symbol last allows compress_symbols to use standard
|
||||
* fast string functions */
|
||||
for (i = 255; i >= 0; i--) {
|
||||
@@ -703,7 +713,9 @@ int main(int argc, char **argv)
|
||||
} else if (strncmp(argv[i], "--page-offset=", 14) == 0) {
|
||||
const char *p = &argv[i][14];
|
||||
kernel_start_addr = strtoull(p, NULL, 16);
|
||||
- } else
|
||||
+ } else if (strcmp(argv[i], "--uncompressed") == 0)
|
||||
+ uncompressed = 1;
|
||||
+ else
|
||||
usage();
|
||||
}
|
||||
} else if (argc != 1)
|
||||
--- a/init/Kconfig
|
||||
+++ b/init/Kconfig
|
||||
@@ -1334,6 +1334,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
|
||||
the unaligned access emulation.
|
||||
see arch/parisc/kernel/unaligned.c for reference
|
||||
|
||||
+config KALLSYMS_UNCOMPRESSED
|
||||
+ bool "Keep kallsyms uncompressed"
|
||||
+ depends on KALLSYMS
|
||||
+ help
|
||||
+ Normally kallsyms contains compressed symbols (using a token table),
|
||||
+ reducing the uncompressed kernel image size. Keeping the symbol table
|
||||
+ uncompressed significantly improves the size of this part in compressed
|
||||
+ kernel images.
|
||||
+
|
||||
+ Say N unless you need compressed kernel images to be small.
|
||||
+
|
||||
config HAVE_PCSPKR_PLATFORM
|
||||
bool
|
||||
|
||||
--- a/scripts/link-vmlinux.sh
|
||||
+++ b/scripts/link-vmlinux.sh
|
||||
@@ -90,6 +90,10 @@ kallsyms()
|
||||
kallsymopt="${kallsymopt} --absolute-percpu"
|
||||
fi
|
||||
|
||||
+ if [ -n "${CONFIG_KALLSYMS_UNCOMPRESSED}" ]; then
|
||||
+ kallsymopt="${kallsymopt} --uncompressed"
|
||||
+ fi
|
||||
+
|
||||
local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
|
||||
${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
|
||||
|
||||
--- a/kernel/kallsyms.c
|
||||
+++ b/kernel/kallsyms.c
|
||||
@@ -109,6 +109,11 @@ static unsigned int kallsyms_expand_symb
|
||||
* For every byte on the compressed symbol data, copy the table
|
||||
* entry for that byte.
|
||||
*/
|
||||
+#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
|
||||
+ memcpy(result, data + 1, len - 1);
|
||||
+ result += len - 1;
|
||||
+ len = 0;
|
||||
+#endif
|
||||
while (len) {
|
||||
tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
|
||||
data++;
|
||||
@@ -141,6 +146,9 @@ tail:
|
||||
*/
|
||||
static char kallsyms_get_symbol_type(unsigned int off)
|
||||
{
|
||||
+#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
|
||||
+ return kallsyms_names[off + 1];
|
||||
+#endif
|
||||
/*
|
||||
* Get just the first code, look it up in the token table,
|
||||
* and return the first char from this token.
|
@ -1,194 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Subject: [PATCH] build: add a hack for removing non-essential module info
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
--- a/include/linux/module.h
|
||||
+++ b/include/linux/module.h
|
||||
@@ -84,9 +84,10 @@ void trim_init_extable(struct module *m)
|
||||
|
||||
/* Generic info of form tag = "info" */
|
||||
#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
|
||||
+#define MODULE_INFO_STRIP(tag, info) __MODULE_INFO_STRIP(tag, tag, info)
|
||||
|
||||
/* For userspace: you can also call me... */
|
||||
-#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
|
||||
+#define MODULE_ALIAS(_alias) MODULE_INFO_STRIP(alias, _alias)
|
||||
|
||||
/* Soft module dependencies. See man modprobe.d for details.
|
||||
* Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz")
|
||||
@@ -127,12 +128,12 @@ void trim_init_extable(struct module *m)
|
||||
* Author(s), use "Name <email>" or just "Name", for multiple
|
||||
* authors use multiple MODULE_AUTHOR() statements/lines.
|
||||
*/
|
||||
-#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
|
||||
+#define MODULE_AUTHOR(_author) MODULE_INFO_STRIP(author, _author)
|
||||
|
||||
/* What your module does. */
|
||||
-#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
|
||||
+#define MODULE_DESCRIPTION(_description) MODULE_INFO_STRIP(description, _description)
|
||||
|
||||
-#ifdef MODULE
|
||||
+#if defined(MODULE) && !defined(CONFIG_MODULE_STRIPPED)
|
||||
/* Creates an alias so file2alias.c can find device table. */
|
||||
#define MODULE_DEVICE_TABLE(type, name) \
|
||||
extern const typeof(name) __mod_##type##__##name##_device_table \
|
||||
@@ -159,7 +160,9 @@ extern const typeof(name) __mod_##type##
|
||||
*/
|
||||
|
||||
#if defined(MODULE) || !defined(CONFIG_SYSFS)
|
||||
-#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
|
||||
+#define MODULE_VERSION(_version) MODULE_INFO_STRIP(version, _version)
|
||||
+#elif defined(CONFIG_MODULE_STRIPPED)
|
||||
+#define MODULE_VERSION(_version) __MODULE_INFO_DISABLED(version)
|
||||
#else
|
||||
#define MODULE_VERSION(_version) \
|
||||
static struct module_version_attribute ___modver_attr = { \
|
||||
@@ -181,7 +184,7 @@ extern const typeof(name) __mod_##type##
|
||||
/* Optional firmware file (or files) needed by the module
|
||||
* format is simply firmware file name. Multiple firmware
|
||||
* files require multiple MODULE_FIRMWARE() specifiers */
|
||||
-#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
|
||||
+#define MODULE_FIRMWARE(_firmware) MODULE_INFO_STRIP(firmware, _firmware)
|
||||
|
||||
/* Given an address, look for it in the exception tables */
|
||||
const struct exception_table_entry *search_exception_tables(unsigned long add);
|
||||
--- a/include/linux/moduleparam.h
|
||||
+++ b/include/linux/moduleparam.h
|
||||
@@ -16,6 +16,16 @@
|
||||
/* Chosen so that structs with an unsigned long line up. */
|
||||
#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
|
||||
|
||||
+/* This struct is here for syntactic coherency, it is not used */
|
||||
+#define __MODULE_INFO_DISABLED(name) \
|
||||
+ struct __UNIQUE_ID(name) {}
|
||||
+
|
||||
+#ifdef CONFIG_MODULE_STRIPPED
|
||||
+#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO_DISABLED(name)
|
||||
+#else
|
||||
+#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO(tag, name, info)
|
||||
+#endif
|
||||
+
|
||||
#ifdef MODULE
|
||||
#define __MODULE_INFO(tag, name, info) \
|
||||
static const char __UNIQUE_ID(name)[] \
|
||||
@@ -23,8 +33,7 @@ static const char __UNIQUE_ID(name)[]
|
||||
= __stringify(tag) "=" info
|
||||
#else /* !MODULE */
|
||||
/* This struct is here for syntactic coherency, it is not used */
|
||||
-#define __MODULE_INFO(tag, name, info) \
|
||||
- struct __UNIQUE_ID(name) {}
|
||||
+#define __MODULE_INFO(tag, name, info) __MODULE_INFO_DISABLED(name)
|
||||
#endif
|
||||
#define __MODULE_PARM_TYPE(name, _type) \
|
||||
__MODULE_INFO(parmtype, name##type, #name ":" _type)
|
||||
@@ -32,7 +41,7 @@ static const char __UNIQUE_ID(name)[]
|
||||
/* One for each parameter, describing how to use it. Some files do
|
||||
multiple of these per line, so can't just use MODULE_INFO. */
|
||||
#define MODULE_PARM_DESC(_parm, desc) \
|
||||
- __MODULE_INFO(parm, _parm, #_parm ":" desc)
|
||||
+ __MODULE_INFO_STRIP(parm, _parm, #_parm ":" desc)
|
||||
|
||||
struct kernel_param;
|
||||
|
||||
--- a/init/Kconfig
|
||||
+++ b/init/Kconfig
|
||||
@@ -1998,6 +1998,13 @@ config MODULE_COMPRESS_XZ
|
||||
|
||||
endchoice
|
||||
|
||||
+config MODULE_STRIPPED
|
||||
+ bool "Reduce module size"
|
||||
+ depends on MODULES
|
||||
+ help
|
||||
+ Remove module parameter descriptions, author info, version, aliases,
|
||||
+ device tables, etc.
|
||||
+
|
||||
endif # MODULES
|
||||
|
||||
config INIT_ALL_POSSIBLE
|
||||
--- a/kernel/module.c
|
||||
+++ b/kernel/module.c
|
||||
@@ -2709,6 +2709,7 @@ static struct module *setup_load_info(st
|
||||
|
||||
static int check_modinfo(struct module *mod, struct load_info *info, int flags)
|
||||
{
|
||||
+#ifndef CONFIG_MODULE_STRIPPED
|
||||
const char *modmagic = get_modinfo(info, "vermagic");
|
||||
int err;
|
||||
|
||||
@@ -2734,6 +2735,7 @@ static int check_modinfo(struct module *
|
||||
pr_warn("%s: module is from the staging directory, the quality "
|
||||
"is unknown, you have been warned.\n", mod->name);
|
||||
}
|
||||
+#endif
|
||||
|
||||
/* Set up license info based on the info section */
|
||||
set_license(mod, get_modinfo(info, "license"));
|
||||
--- a/scripts/mod/modpost.c
|
||||
+++ b/scripts/mod/modpost.c
|
||||
@@ -1959,7 +1959,9 @@ static void read_symbols(char *modname)
|
||||
symname = remove_dot(info.strtab + sym->st_name);
|
||||
|
||||
handle_modversions(mod, &info, sym, symname);
|
||||
+#ifndef CONFIG_MODULE_STRIPPED
|
||||
handle_moddevtable(mod, &info, sym, symname);
|
||||
+#endif
|
||||
}
|
||||
if (!is_vmlinux(modname) ||
|
||||
(is_vmlinux(modname) && vmlinux_section_warnings))
|
||||
@@ -2103,7 +2105,9 @@ static void add_header(struct buffer *b,
|
||||
buf_printf(b, "#include <linux/vermagic.h>\n");
|
||||
buf_printf(b, "#include <linux/compiler.h>\n");
|
||||
buf_printf(b, "\n");
|
||||
+#ifndef CONFIG_MODULE_STRIPPED
|
||||
buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
|
||||
+#endif
|
||||
buf_printf(b, "\n");
|
||||
buf_printf(b, "__visible struct module __this_module\n");
|
||||
buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
|
||||
@@ -2120,16 +2124,20 @@ static void add_header(struct buffer *b,
|
||||
|
||||
static void add_intree_flag(struct buffer *b, int is_intree)
|
||||
{
|
||||
+#ifndef CONFIG_MODULE_STRIPPED
|
||||
if (is_intree)
|
||||
buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");
|
||||
+#endif
|
||||
}
|
||||
|
||||
static void add_staging_flag(struct buffer *b, const char *name)
|
||||
{
|
||||
+#ifndef CONFIG_MODULE_STRIPPED
|
||||
static const char *staging_dir = "drivers/staging";
|
||||
|
||||
if (strncmp(staging_dir, name, strlen(staging_dir)) == 0)
|
||||
buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
|
||||
+#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2222,11 +2230,13 @@ static void add_depends(struct buffer *b
|
||||
|
||||
static void add_srcversion(struct buffer *b, struct module *mod)
|
||||
{
|
||||
+#ifndef CONFIG_MODULE_STRIPPED
|
||||
if (mod->srcversion[0]) {
|
||||
buf_printf(b, "\n");
|
||||
buf_printf(b, "MODULE_INFO(srcversion, \"%s\");\n",
|
||||
mod->srcversion);
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
static void write_if_changed(struct buffer *b, const char *fname)
|
||||
@@ -2457,7 +2467,9 @@ int main(int argc, char **argv)
|
||||
add_staging_flag(&buf, mod->name);
|
||||
err |= add_versions(&buf, mod);
|
||||
add_depends(&buf, mod, modules);
|
||||
+#ifndef CONFIG_MODULE_STRIPPED
|
||||
add_moddevtable(&buf, mod);
|
||||
+#endif
|
||||
add_srcversion(&buf, mod);
|
||||
|
||||
sprintf(fname, "%s.mod.c", mod->name);
|
@ -1,36 +0,0 @@
|
||||
--- a/lib/vsprintf.c
|
||||
+++ b/lib/vsprintf.c
|
||||
@@ -617,8 +617,10 @@ char *symbol_string(char *buf, char *end
|
||||
struct printf_spec spec, const char *fmt)
|
||||
{
|
||||
unsigned long value;
|
||||
-#ifdef CONFIG_KALLSYMS
|
||||
char sym[KSYM_SYMBOL_LEN];
|
||||
+#ifndef CONFIG_KALLSYMS
|
||||
+ struct module *mod;
|
||||
+ int len;
|
||||
#endif
|
||||
|
||||
if (fmt[1] == 'R')
|
||||
@@ -632,15 +634,15 @@ char *symbol_string(char *buf, char *end
|
||||
sprint_symbol(sym, value);
|
||||
else
|
||||
sprint_symbol_no_offset(sym, value);
|
||||
-
|
||||
- return string(buf, end, sym, spec);
|
||||
#else
|
||||
- spec.field_width = 2 * sizeof(void *);
|
||||
- spec.flags |= SPECIAL | SMALL | ZEROPAD;
|
||||
- spec.base = 16;
|
||||
+ len = snprintf(sym, sizeof(sym), "0x%lx", value);
|
||||
|
||||
- return number(buf, end, value, spec);
|
||||
+ mod = __module_address(value);
|
||||
+ if (mod)
|
||||
+ snprintf(sym + len, sizeof(sym) - len, " [%s@%p+0x%x]",
|
||||
+ mod->name, mod->module_core, mod->core_size);
|
||||
#endif
|
||||
+ return string(buf, end, sym, spec);
|
||||
}
|
||||
|
||||
static noinline_for_stack
|
File diff suppressed because it is too large
Load Diff
@ -1,51 +0,0 @@
|
||||
--- a/tools/include/tools/be_byteshift.h
|
||||
+++ b/tools/include/tools/be_byteshift.h
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef _TOOLS_BE_BYTESHIFT_H
|
||||
#define _TOOLS_BE_BYTESHIFT_H
|
||||
|
||||
+#ifndef __linux__
|
||||
+#include "linux_types.h"
|
||||
+#endif
|
||||
+
|
||||
#include <stdint.h>
|
||||
|
||||
static inline uint16_t __get_unaligned_be16(const uint8_t *p)
|
||||
--- a/tools/include/tools/le_byteshift.h
|
||||
+++ b/tools/include/tools/le_byteshift.h
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef _TOOLS_LE_BYTESHIFT_H
|
||||
#define _TOOLS_LE_BYTESHIFT_H
|
||||
|
||||
+#ifndef __linux__
|
||||
+#include "linux_types.h"
|
||||
+#endif
|
||||
+
|
||||
#include <stdint.h>
|
||||
|
||||
static inline uint16_t __get_unaligned_le16(const uint8_t *p)
|
||||
--- /dev/null
|
||||
+++ b/tools/include/tools/linux_types.h
|
||||
@@ -0,0 +1,22 @@
|
||||
+#ifndef __LINUX_TYPES_H
|
||||
+#define __LINUX_TYPES_H
|
||||
+
|
||||
+#include <stdint.h>
|
||||
+
|
||||
+typedef uint8_t __u8;
|
||||
+typedef uint8_t __be8;
|
||||
+typedef uint8_t __le8;
|
||||
+
|
||||
+typedef uint16_t __u16;
|
||||
+typedef uint16_t __be16;
|
||||
+typedef uint16_t __le16;
|
||||
+
|
||||
+typedef uint32_t __u32;
|
||||
+typedef uint32_t __be32;
|
||||
+typedef uint32_t __le32;
|
||||
+
|
||||
+typedef uint64_t __u64;
|
||||
+typedef uint64_t __be64;
|
||||
+typedef uint64_t __le64;
|
||||
+
|
||||
+#endif
|
@ -1,11 +0,0 @@
|
||||
--- a/include/uapi/linux/spi/spidev.h
|
||||
+++ b/include/uapi/linux/spi/spidev.h
|
||||
@@ -111,7 +111,7 @@ struct spi_ioc_transfer {
|
||||
|
||||
/* not all platforms use <asm-generic/ioctl.h> or _IOC_TYPECHECK() ... */
|
||||
#define SPI_MSGSIZE(N) \
|
||||
- ((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << _IOC_SIZEBITS)) \
|
||||
+ ((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << 13)) \
|
||||
? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
|
||||
#define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)])
|
||||
|
@ -1,536 +0,0 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
use -ffunction-sections, -fdata-sections and --gc-sections
|
||||
|
||||
In combination with kernel symbol export stripping this significantly reduces
|
||||
the kernel image size. Used on both ARM and MIPS architectures.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
||||
---
|
||||
|
||||
--- a/arch/mips/Makefile
|
||||
+++ b/arch/mips/Makefile
|
||||
@@ -89,10 +89,14 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin
|
||||
#
|
||||
cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
|
||||
cflags-y += -msoft-float
|
||||
-LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
|
||||
+LDFLAGS_vmlinux += -G 0 -static -n -nostdlib --gc-sections
|
||||
KBUILD_AFLAGS_MODULE += -mlong-calls
|
||||
KBUILD_CFLAGS_MODULE += -mlong-calls
|
||||
|
||||
+ifndef CONFIG_FUNCTION_TRACER
|
||||
+KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
|
||||
+endif
|
||||
+
|
||||
#
|
||||
# pass -msoft-float to GAS if it supports it. However on newer binutils
|
||||
# (specifically newer than 2.24.51.20140728) we then also need to explicitly
|
||||
--- a/arch/mips/kernel/vmlinux.lds.S
|
||||
+++ b/arch/mips/kernel/vmlinux.lds.S
|
||||
@@ -67,7 +67,7 @@ SECTIONS
|
||||
/* Exception table for data bus errors */
|
||||
__dbe_table : {
|
||||
__start___dbe_table = .;
|
||||
- *(__dbe_table)
|
||||
+ KEEP(*(__dbe_table))
|
||||
__stop___dbe_table = .;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
.mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
|
||||
__mips_machines_start = .;
|
||||
- *(.mips.machines.init)
|
||||
+ KEEP(*(.mips.machines.init))
|
||||
__mips_machines_end = .;
|
||||
}
|
||||
|
||||
--- a/include/asm-generic/vmlinux.lds.h
|
||||
+++ b/include/asm-generic/vmlinux.lds.h
|
||||
@@ -89,7 +89,7 @@
|
||||
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
#define MCOUNT_REC() . = ALIGN(8); \
|
||||
VMLINUX_SYMBOL(__start_mcount_loc) = .; \
|
||||
- *(__mcount_loc) \
|
||||
+ KEEP(*(__mcount_loc)) \
|
||||
VMLINUX_SYMBOL(__stop_mcount_loc) = .;
|
||||
#else
|
||||
#define MCOUNT_REC()
|
||||
@@ -97,7 +97,7 @@
|
||||
|
||||
#ifdef CONFIG_TRACE_BRANCH_PROFILING
|
||||
#define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
|
||||
- *(_ftrace_annotated_branch) \
|
||||
+ KEEP(*(_ftrace_annotated_branch)) \
|
||||
VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
|
||||
#else
|
||||
#define LIKELY_PROFILE()
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
#ifdef CONFIG_PROFILE_ALL_BRANCHES
|
||||
#define BRANCH_PROFILE() VMLINUX_SYMBOL(__start_branch_profile) = .; \
|
||||
- *(_ftrace_branch) \
|
||||
+ KEEP(*(_ftrace_branch)) \
|
||||
VMLINUX_SYMBOL(__stop_branch_profile) = .;
|
||||
#else
|
||||
#define BRANCH_PROFILE()
|
||||
@@ -114,7 +114,7 @@
|
||||
#ifdef CONFIG_KPROBES
|
||||
#define KPROBE_BLACKLIST() . = ALIGN(8); \
|
||||
VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \
|
||||
- *(_kprobe_blacklist) \
|
||||
+ KEEP(*(_kprobe_blacklist)) \
|
||||
VMLINUX_SYMBOL(__stop_kprobe_blacklist) = .;
|
||||
#else
|
||||
#define KPROBE_BLACKLIST()
|
||||
@@ -123,10 +123,10 @@
|
||||
#ifdef CONFIG_EVENT_TRACING
|
||||
#define FTRACE_EVENTS() . = ALIGN(8); \
|
||||
VMLINUX_SYMBOL(__start_ftrace_events) = .; \
|
||||
- *(_ftrace_events) \
|
||||
+ KEEP(*(_ftrace_events)) \
|
||||
VMLINUX_SYMBOL(__stop_ftrace_events) = .; \
|
||||
VMLINUX_SYMBOL(__start_ftrace_enum_maps) = .; \
|
||||
- *(_ftrace_enum_map) \
|
||||
+ KEEP(*(_ftrace_enum_map)) \
|
||||
VMLINUX_SYMBOL(__stop_ftrace_enum_maps) = .;
|
||||
#else
|
||||
#define FTRACE_EVENTS()
|
||||
@@ -134,7 +134,7 @@
|
||||
|
||||
#ifdef CONFIG_TRACING
|
||||
#define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \
|
||||
- *(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
|
||||
+ KEEP(*(__trace_printk_fmt)) /* Trace_printk fmt' pointer */ \
|
||||
VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
|
||||
#define TRACEPOINT_STR() VMLINUX_SYMBOL(__start___tracepoint_str) = .; \
|
||||
*(__tracepoint_str) /* Trace_printk fmt' pointer */ \
|
||||
@@ -147,7 +147,7 @@
|
||||
#ifdef CONFIG_FTRACE_SYSCALLS
|
||||
#define TRACE_SYSCALLS() . = ALIGN(8); \
|
||||
VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \
|
||||
- *(__syscalls_metadata) \
|
||||
+ KEEP(*(__syscalls_metadata)) \
|
||||
VMLINUX_SYMBOL(__stop_syscalls_metadata) = .;
|
||||
#else
|
||||
#define TRACE_SYSCALLS()
|
||||
@@ -169,8 +169,8 @@
|
||||
#define _OF_TABLE_1(name) \
|
||||
. = ALIGN(8); \
|
||||
VMLINUX_SYMBOL(__##name##_of_table) = .; \
|
||||
- *(__##name##_of_table) \
|
||||
- *(__##name##_of_table_end)
|
||||
+ KEEP(*(__##name##_of_table)) \
|
||||
+ KEEP(*(__##name##_of_table_end))
|
||||
|
||||
#define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc)
|
||||
#define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
|
||||
@@ -184,7 +184,7 @@
|
||||
#define KERNEL_DTB() \
|
||||
STRUCT_ALIGN(); \
|
||||
VMLINUX_SYMBOL(__dtb_start) = .; \
|
||||
- *(.dtb.init.rodata) \
|
||||
+ KEEP(*(.dtb.init.rodata)) \
|
||||
VMLINUX_SYMBOL(__dtb_end) = .;
|
||||
|
||||
/* .data section */
|
||||
@@ -200,16 +200,17 @@
|
||||
/* implement dynamic printk debug */ \
|
||||
. = ALIGN(8); \
|
||||
VMLINUX_SYMBOL(__start___jump_table) = .; \
|
||||
- *(__jump_table) \
|
||||
+ KEEP(*(__jump_table)) \
|
||||
VMLINUX_SYMBOL(__stop___jump_table) = .; \
|
||||
. = ALIGN(8); \
|
||||
VMLINUX_SYMBOL(__start___verbose) = .; \
|
||||
- *(__verbose) \
|
||||
+ KEEP(*(__verbose)) \
|
||||
VMLINUX_SYMBOL(__stop___verbose) = .; \
|
||||
LIKELY_PROFILE() \
|
||||
BRANCH_PROFILE() \
|
||||
TRACE_PRINTKS() \
|
||||
- TRACEPOINT_STR()
|
||||
+ TRACEPOINT_STR() \
|
||||
+ *(.data.[a-zA-Z_]*)
|
||||
|
||||
/*
|
||||
* Data section helpers
|
||||
@@ -263,35 +264,35 @@
|
||||
/* PCI quirks */ \
|
||||
.pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
|
||||
- *(.pci_fixup_early) \
|
||||
+ KEEP(*(.pci_fixup_early)) \
|
||||
VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
|
||||
VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
|
||||
- *(.pci_fixup_header) \
|
||||
+ KEEP(*(.pci_fixup_header)) \
|
||||
VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
|
||||
VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
|
||||
- *(.pci_fixup_final) \
|
||||
+ KEEP(*(.pci_fixup_final)) \
|
||||
VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
|
||||
VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
|
||||
- *(.pci_fixup_enable) \
|
||||
+ KEEP(*(.pci_fixup_enable)) \
|
||||
VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
|
||||
VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \
|
||||
- *(.pci_fixup_resume) \
|
||||
+ KEEP(*(.pci_fixup_resume)) \
|
||||
VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \
|
||||
VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .; \
|
||||
- *(.pci_fixup_resume_early) \
|
||||
+ KEEP(*(.pci_fixup_resume_early)) \
|
||||
VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .; \
|
||||
VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .; \
|
||||
- *(.pci_fixup_suspend) \
|
||||
+ KEEP(*(.pci_fixup_suspend)) \
|
||||
VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .; \
|
||||
VMLINUX_SYMBOL(__start_pci_fixups_suspend_late) = .; \
|
||||
- *(.pci_fixup_suspend_late) \
|
||||
+ KEEP(*(.pci_fixup_suspend_late)) \
|
||||
VMLINUX_SYMBOL(__end_pci_fixups_suspend_late) = .; \
|
||||
} \
|
||||
\
|
||||
/* Built-in firmware blobs */ \
|
||||
.builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start_builtin_fw) = .; \
|
||||
- *(.builtin_fw) \
|
||||
+ KEEP(*(.builtin_fw)) \
|
||||
VMLINUX_SYMBOL(__end_builtin_fw) = .; \
|
||||
} \
|
||||
\
|
||||
@@ -300,49 +301,49 @@
|
||||
/* Kernel symbol table: Normal symbols */ \
|
||||
__ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab) = .; \
|
||||
- *(SORT(___ksymtab+*)) \
|
||||
+ KEEP(*(SORT(___ksymtab+*))) \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: GPL-only symbols */ \
|
||||
__ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
|
||||
- *(SORT(___ksymtab_gpl+*)) \
|
||||
+ KEEP(*(SORT(___ksymtab_gpl+*))) \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: Normal unused symbols */ \
|
||||
__ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
|
||||
- *(SORT(___ksymtab_unused+*)) \
|
||||
+ KEEP(*(SORT(___ksymtab_unused+*))) \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: GPL-only unused symbols */ \
|
||||
__ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
|
||||
- *(SORT(___ksymtab_unused_gpl+*)) \
|
||||
+ KEEP(*(SORT(___ksymtab_unused_gpl+*))) \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: GPL-future-only symbols */ \
|
||||
__ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
|
||||
- *(SORT(___ksymtab_gpl_future+*)) \
|
||||
+ KEEP(*(SORT(___ksymtab_gpl_future+*))) \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: Normal symbols */ \
|
||||
__kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___kcrctab) = .; \
|
||||
- *(SORT(___kcrctab+*)) \
|
||||
+ KEEP(*(SORT(___kcrctab+*))) \
|
||||
VMLINUX_SYMBOL(__stop___kcrctab) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: GPL-only symbols */ \
|
||||
__kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
|
||||
- *(SORT(___kcrctab_gpl+*)) \
|
||||
+ KEEP(*(SORT(___kcrctab_gpl+*))) \
|
||||
VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
|
||||
} \
|
||||
\
|
||||
@@ -356,14 +357,14 @@
|
||||
/* Kernel symbol table: GPL-only unused symbols */ \
|
||||
__kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \
|
||||
- *(SORT(___kcrctab_unused_gpl+*)) \
|
||||
+ KEEP(*(SORT(___kcrctab_unused_gpl+*))) \
|
||||
VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: GPL-future-only symbols */ \
|
||||
__kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
|
||||
- *(SORT(___kcrctab_gpl_future+*)) \
|
||||
+ KEEP(*(SORT(___kcrctab_gpl_future+*))) \
|
||||
VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \
|
||||
} \
|
||||
\
|
||||
@@ -382,14 +383,14 @@
|
||||
/* Built-in module parameters. */ \
|
||||
__param : AT(ADDR(__param) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___param) = .; \
|
||||
- *(__param) \
|
||||
+ KEEP(*(__param)) \
|
||||
VMLINUX_SYMBOL(__stop___param) = .; \
|
||||
} \
|
||||
\
|
||||
/* Built-in module versions. */ \
|
||||
__modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___modver) = .; \
|
||||
- *(__modver) \
|
||||
+ KEEP(*(__modver)) \
|
||||
VMLINUX_SYMBOL(__stop___modver) = .; \
|
||||
. = ALIGN((align)); \
|
||||
VMLINUX_SYMBOL(__end_rodata) = .; \
|
||||
@@ -445,7 +446,7 @@
|
||||
#define ENTRY_TEXT \
|
||||
ALIGN_FUNCTION(); \
|
||||
VMLINUX_SYMBOL(__entry_text_start) = .; \
|
||||
- *(.entry.text) \
|
||||
+ KEEP(*(.entry.text)) \
|
||||
VMLINUX_SYMBOL(__entry_text_end) = .;
|
||||
|
||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
||||
@@ -473,7 +474,7 @@
|
||||
. = ALIGN(align); \
|
||||
__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ex_table) = .; \
|
||||
- *(__ex_table) \
|
||||
+ KEEP(*(__ex_table)) \
|
||||
VMLINUX_SYMBOL(__stop___ex_table) = .; \
|
||||
}
|
||||
|
||||
@@ -489,9 +490,9 @@
|
||||
#ifdef CONFIG_CONSTRUCTORS
|
||||
#define KERNEL_CTORS() . = ALIGN(8); \
|
||||
VMLINUX_SYMBOL(__ctors_start) = .; \
|
||||
- *(.ctors) \
|
||||
+ KEEP(*(.ctors)) \
|
||||
*(SORT(.init_array.*)) \
|
||||
- *(.init_array) \
|
||||
+ KEEP(*(.init_array)) \
|
||||
VMLINUX_SYMBOL(__ctors_end) = .;
|
||||
#else
|
||||
#define KERNEL_CTORS()
|
||||
@@ -546,7 +547,7 @@
|
||||
#define SBSS(sbss_align) \
|
||||
. = ALIGN(sbss_align); \
|
||||
.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
|
||||
- *(.sbss) \
|
||||
+ *(.sbss .sbss.*) \
|
||||
*(.scommon) \
|
||||
}
|
||||
|
||||
@@ -564,7 +565,7 @@
|
||||
BSS_FIRST_SECTIONS \
|
||||
*(.bss..page_aligned) \
|
||||
*(.dynbss) \
|
||||
- *(.bss) \
|
||||
+ *(.bss .bss.*) \
|
||||
*(COMMON) \
|
||||
}
|
||||
|
||||
@@ -613,7 +614,7 @@
|
||||
. = ALIGN(8); \
|
||||
__bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___bug_table) = .; \
|
||||
- *(__bug_table) \
|
||||
+ KEEP(*(__bug_table)) \
|
||||
VMLINUX_SYMBOL(__stop___bug_table) = .; \
|
||||
}
|
||||
#else
|
||||
@@ -625,7 +626,7 @@
|
||||
. = ALIGN(4); \
|
||||
.tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__tracedata_start) = .; \
|
||||
- *(.tracedata) \
|
||||
+ KEEP(*(.tracedata)) \
|
||||
VMLINUX_SYMBOL(__tracedata_end) = .; \
|
||||
}
|
||||
#else
|
||||
@@ -642,17 +643,17 @@
|
||||
#define INIT_SETUP(initsetup_align) \
|
||||
. = ALIGN(initsetup_align); \
|
||||
VMLINUX_SYMBOL(__setup_start) = .; \
|
||||
- *(.init.setup) \
|
||||
+ KEEP(*(.init.setup)) \
|
||||
VMLINUX_SYMBOL(__setup_end) = .;
|
||||
|
||||
#define INIT_CALLS_LEVEL(level) \
|
||||
VMLINUX_SYMBOL(__initcall##level##_start) = .; \
|
||||
- *(.initcall##level##.init) \
|
||||
- *(.initcall##level##s.init) \
|
||||
+ KEEP(*(.initcall##level##.init)) \
|
||||
+ KEEP(*(.initcall##level##s.init)) \
|
||||
|
||||
#define INIT_CALLS \
|
||||
VMLINUX_SYMBOL(__initcall_start) = .; \
|
||||
- *(.initcallearly.init) \
|
||||
+ KEEP(*(.initcallearly.init)) \
|
||||
INIT_CALLS_LEVEL(0) \
|
||||
INIT_CALLS_LEVEL(1) \
|
||||
INIT_CALLS_LEVEL(2) \
|
||||
@@ -666,21 +667,21 @@
|
||||
|
||||
#define CON_INITCALL \
|
||||
VMLINUX_SYMBOL(__con_initcall_start) = .; \
|
||||
- *(.con_initcall.init) \
|
||||
+ KEEP(*(.con_initcall.init)) \
|
||||
VMLINUX_SYMBOL(__con_initcall_end) = .;
|
||||
|
||||
#define SECURITY_INITCALL \
|
||||
VMLINUX_SYMBOL(__security_initcall_start) = .; \
|
||||
- *(.security_initcall.init) \
|
||||
+ KEEP(*(.security_initcall.init)) \
|
||||
VMLINUX_SYMBOL(__security_initcall_end) = .;
|
||||
|
||||
#ifdef CONFIG_BLK_DEV_INITRD
|
||||
#define INIT_RAM_FS \
|
||||
. = ALIGN(4); \
|
||||
VMLINUX_SYMBOL(__initramfs_start) = .; \
|
||||
- *(.init.ramfs) \
|
||||
+ KEEP(*(.init.ramfs)) \
|
||||
. = ALIGN(8); \
|
||||
- *(.init.ramfs.info)
|
||||
+ KEEP(*(.init.ramfs.info))
|
||||
#else
|
||||
#define INIT_RAM_FS
|
||||
#endif
|
||||
--- a/arch/arm/Makefile
|
||||
+++ b/arch/arm/Makefile
|
||||
@@ -18,11 +18,16 @@ ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
|
||||
LDFLAGS_vmlinux += --be8
|
||||
LDFLAGS_MODULE += --be8
|
||||
endif
|
||||
+LDFLAGS_vmlinux += --gc-sections
|
||||
|
||||
OBJCOPYFLAGS :=-O binary -R .comment -S
|
||||
GZFLAGS :=-9
|
||||
#KBUILD_CFLAGS +=-pipe
|
||||
|
||||
+ifndef CONFIG_FUNCTION_TRACER
|
||||
+KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
|
||||
+endif
|
||||
+
|
||||
# Never generate .eh_frame
|
||||
KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
|
||||
|
||||
--- a/arch/arm/kernel/vmlinux.lds.S
|
||||
+++ b/arch/arm/kernel/vmlinux.lds.S
|
||||
@@ -15,13 +15,13 @@
|
||||
#define PROC_INFO \
|
||||
. = ALIGN(4); \
|
||||
VMLINUX_SYMBOL(__proc_info_begin) = .; \
|
||||
- *(.proc.info.init) \
|
||||
+ KEEP(*(.proc.info.init)) \
|
||||
VMLINUX_SYMBOL(__proc_info_end) = .;
|
||||
|
||||
#define IDMAP_TEXT \
|
||||
ALIGN_FUNCTION(); \
|
||||
VMLINUX_SYMBOL(__idmap_text_start) = .; \
|
||||
- *(.idmap.text) \
|
||||
+ KEEP(*(.idmap.text)) \
|
||||
VMLINUX_SYMBOL(__idmap_text_end) = .; \
|
||||
. = ALIGN(PAGE_SIZE); \
|
||||
VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
|
||||
@@ -102,7 +102,7 @@ SECTIONS
|
||||
_stext = .; /* Text and read-only data */
|
||||
IDMAP_TEXT
|
||||
__exception_text_start = .;
|
||||
- *(.exception.text)
|
||||
+ KEEP(*(.exception.text))
|
||||
__exception_text_end = .;
|
||||
IRQENTRY_TEXT
|
||||
TEXT_TEXT
|
||||
@@ -126,7 +126,7 @@ SECTIONS
|
||||
__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
|
||||
__start___ex_table = .;
|
||||
#ifdef CONFIG_MMU
|
||||
- *(__ex_table)
|
||||
+ KEEP(*(__ex_table))
|
||||
#endif
|
||||
__stop___ex_table = .;
|
||||
}
|
||||
@@ -138,12 +138,12 @@ SECTIONS
|
||||
. = ALIGN(8);
|
||||
.ARM.unwind_idx : {
|
||||
__start_unwind_idx = .;
|
||||
- *(.ARM.exidx*)
|
||||
+ KEEP(*(.ARM.exidx*))
|
||||
__stop_unwind_idx = .;
|
||||
}
|
||||
.ARM.unwind_tab : {
|
||||
__start_unwind_tab = .;
|
||||
- *(.ARM.extab*)
|
||||
+ KEEP(*(.ARM.extab*))
|
||||
__stop_unwind_tab = .;
|
||||
}
|
||||
#endif
|
||||
@@ -166,14 +166,14 @@ SECTIONS
|
||||
*/
|
||||
__vectors_start = .;
|
||||
.vectors 0 : AT(__vectors_start) {
|
||||
- *(.vectors)
|
||||
+ KEEP(*(.vectors))
|
||||
}
|
||||
. = __vectors_start + SIZEOF(.vectors);
|
||||
__vectors_end = .;
|
||||
|
||||
__stubs_start = .;
|
||||
.stubs 0x1000 : AT(__stubs_start) {
|
||||
- *(.stubs)
|
||||
+ KEEP(*(.stubs))
|
||||
}
|
||||
. = __stubs_start + SIZEOF(.stubs);
|
||||
__stubs_end = .;
|
||||
@@ -187,24 +187,24 @@ SECTIONS
|
||||
}
|
||||
.init.arch.info : {
|
||||
__arch_info_begin = .;
|
||||
- *(.arch.info.init)
|
||||
+ KEEP(*(.arch.info.init))
|
||||
__arch_info_end = .;
|
||||
}
|
||||
.init.tagtable : {
|
||||
__tagtable_begin = .;
|
||||
- *(.taglist.init)
|
||||
+ KEEP(*(.taglist.init))
|
||||
__tagtable_end = .;
|
||||
}
|
||||
#ifdef CONFIG_SMP_ON_UP
|
||||
.init.smpalt : {
|
||||
__smpalt_begin = .;
|
||||
- *(.alt.smp.init)
|
||||
+ KEEP(*(.alt.smp.init))
|
||||
__smpalt_end = .;
|
||||
}
|
||||
#endif
|
||||
.init.pv_table : {
|
||||
__pv_table_begin = .;
|
||||
- *(.pv_table)
|
||||
+ KEEP(*(.pv_table))
|
||||
__pv_table_end = .;
|
||||
}
|
||||
.init.data : {
|
||||
--- a/arch/arm/boot/compressed/Makefile
|
||||
+++ b/arch/arm/boot/compressed/Makefile
|
||||
@@ -107,6 +107,7 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
|
||||
ORIG_CFLAGS := $(KBUILD_CFLAGS)
|
||||
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
|
||||
endif
|
||||
+KBUILD_CFLAGS_KERNEL := $(patsubst -f%-sections,,$(KBUILD_CFLAGS_KERNEL))
|
||||
|
||||
ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
|
||||
asflags-y := -DZIMAGE
|
@ -1,88 +0,0 @@
|
||||
--- a/include/asm-generic/vmlinux.lds.h
|
||||
+++ b/include/asm-generic/vmlinux.lds.h
|
||||
@@ -54,6 +54,16 @@
|
||||
#define LOAD_OFFSET 0
|
||||
#endif
|
||||
|
||||
+#ifndef SYMTAB_KEEP
|
||||
+#define SYMTAB_KEEP KEEP(*(SORT(___ksymtab+*)))
|
||||
+#define SYMTAB_KEEP_GPL KEEP(*(SORT(___ksymtab_gpl+*)))
|
||||
+#endif
|
||||
+
|
||||
+#ifndef SYMTAB_DISCARD
|
||||
+#define SYMTAB_DISCARD
|
||||
+#define SYMTAB_DISCARD_GPL
|
||||
+#endif
|
||||
+
|
||||
#include <linux/export.h>
|
||||
|
||||
/* Align . to a 8 byte boundary equals to maximum function alignment. */
|
||||
@@ -301,14 +311,14 @@
|
||||
/* Kernel symbol table: Normal symbols */ \
|
||||
__ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab) = .; \
|
||||
- KEEP(*(SORT(___ksymtab+*))) \
|
||||
+ SYMTAB_KEEP \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: GPL-only symbols */ \
|
||||
__ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
|
||||
- KEEP(*(SORT(___ksymtab_gpl+*))) \
|
||||
+ SYMTAB_KEEP_GPL \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
|
||||
} \
|
||||
\
|
||||
@@ -370,7 +380,7 @@
|
||||
\
|
||||
/* Kernel symbol table: strings */ \
|
||||
__ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
|
||||
- *(__ksymtab_strings) \
|
||||
+ *(__ksymtab_strings+*) \
|
||||
} \
|
||||
\
|
||||
/* __*init sections */ \
|
||||
@@ -700,6 +710,8 @@
|
||||
EXIT_TEXT \
|
||||
EXIT_DATA \
|
||||
EXIT_CALL \
|
||||
+ SYMTAB_DISCARD \
|
||||
+ SYMTAB_DISCARD_GPL \
|
||||
*(.discard) \
|
||||
*(.discard.*) \
|
||||
}
|
||||
--- a/scripts/Makefile.build
|
||||
+++ b/scripts/Makefile.build
|
||||
@@ -299,7 +299,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(
|
||||
# Linker scripts preprocessor (.lds.S -> .lds)
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_cpp_lds_S = LDS $@
|
||||
- cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
|
||||
+ cmd_cpp_lds_S = $(CPP) $(EXTRA_LDSFLAGS) $(cpp_flags) -P -C -U$(ARCH) \
|
||||
-D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
|
||||
|
||||
$(obj)/%.lds: $(src)/%.lds.S FORCE
|
||||
--- a/include/linux/export.h
|
||||
+++ b/include/linux/export.h
|
||||
@@ -52,12 +52,19 @@ extern struct module __this_module;
|
||||
#define __CRC_SYMBOL(sym, sec)
|
||||
#endif
|
||||
|
||||
+#ifdef MODULE
|
||||
+#define __EXPORT_SUFFIX(sym)
|
||||
+#else
|
||||
+#define __EXPORT_SUFFIX(sym) "+" #sym
|
||||
+#endif
|
||||
+
|
||||
/* For every exported symbol, place a struct in the __ksymtab section */
|
||||
#define __EXPORT_SYMBOL(sym, sec) \
|
||||
extern typeof(sym) sym; \
|
||||
__CRC_SYMBOL(sym, sec) \
|
||||
static const char __kstrtab_##sym[] \
|
||||
- __attribute__((section("__ksymtab_strings"), aligned(1))) \
|
||||
+ __attribute__((section("__ksymtab_strings" \
|
||||
+ __EXPORT_SUFFIX(sym)), aligned(1))) \
|
||||
= VMLINUX_SYMBOL_STR(sym); \
|
||||
extern const struct kernel_symbol __ksymtab_##sym; \
|
||||
__visible const struct kernel_symbol __ksymtab_##sym \
|
@ -1,57 +0,0 @@
|
||||
From d7a3d85e08477a979933a2bb3b525a8de99543c2 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Olsa <jolsa@kernel.org>
|
||||
Date: Fri, 29 May 2015 17:42:58 +0200
|
||||
Subject: [PATCH] perf build: Do not fail on missing Build file
|
||||
|
||||
Allow nesting into directories without Build file. Currently we force
|
||||
include of the Build file, which fails the build when the Build file is
|
||||
missing.
|
||||
|
||||
We already support empty *-in.o' objects if there's nothing in the
|
||||
directory to be compiled, so we can just use it for missing Build file
|
||||
cases.
|
||||
|
||||
Also adding this case under tests.
|
||||
|
||||
Reported-by: Rabin Vincent <rabin.vincent@axis.com>
|
||||
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
|
||||
Cc: David Ahern <dsahern@gmail.com>
|
||||
Cc: Namhyung Kim <namhyung@kernel.org>
|
||||
Cc: Paul Mackerras <paulus@samba.org>
|
||||
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
|
||||
Cc: Rabin Vincent <rabin.vincent@axis.com>
|
||||
Link: http://lkml.kernel.org/r/1432914178-24086-1-git-send-email-jolsa@kernel.org
|
||||
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
|
||||
---
|
||||
tools/build/Makefile.build | 2 +-
|
||||
tools/build/tests/ex/Build | 1 +
|
||||
tools/build/tests/ex/empty2/README | 2 ++
|
||||
3 files changed, 4 insertions(+), 1 deletion(-)
|
||||
create mode 100644 tools/build/tests/ex/empty2/README
|
||||
|
||||
--- a/tools/build/Makefile.build
|
||||
+++ b/tools/build/Makefile.build
|
||||
@@ -37,7 +37,7 @@ subdir-obj-y :=
|
||||
|
||||
# Build definitions
|
||||
build-file := $(dir)/Build
|
||||
-include $(build-file)
|
||||
+-include $(build-file)
|
||||
|
||||
quiet_cmd_flex = FLEX $@
|
||||
quiet_cmd_bison = BISON $@
|
||||
--- a/tools/build/tests/ex/Build
|
||||
+++ b/tools/build/tests/ex/Build
|
||||
@@ -2,6 +2,7 @@ ex-y += ex.o
|
||||
ex-y += a.o
|
||||
ex-y += b.o
|
||||
ex-y += empty/
|
||||
+ex-y += empty2/
|
||||
|
||||
libex-y += c.o
|
||||
libex-y += d.o
|
||||
--- /dev/null
|
||||
+++ b/tools/build/tests/ex/empty2/README
|
||||
@@ -0,0 +1,2 @@
|
||||
+This directory is left intentionally without Build file
|
||||
+to test proper nesting into Build-less directories.
|
@ -1,58 +0,0 @@
|
||||
--- a/scripts/Makefile.lib
|
||||
+++ b/scripts/Makefile.lib
|
||||
@@ -324,7 +324,7 @@ cmd_bzip2 = (cat $(filter-out FORCE,$^)
|
||||
|
||||
quiet_cmd_lzma = LZMA $@
|
||||
cmd_lzma = (cat $(filter-out FORCE,$^) | \
|
||||
- lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
|
||||
+ lzma e -d20 -lc1 -lp2 -pb2 -eos -si -so && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
|
||||
(rm -f $@ ; false)
|
||||
|
||||
quiet_cmd_lzo = LZO $@
|
||||
--- a/scripts/gen_initramfs_list.sh
|
||||
+++ b/scripts/gen_initramfs_list.sh
|
||||
@@ -226,7 +226,7 @@ cpio_list=
|
||||
output="/dev/stdout"
|
||||
output_file=""
|
||||
is_cpio_compressed=
|
||||
-compr="gzip -n -9 -f"
|
||||
+compr="gzip -n -9 -f -"
|
||||
|
||||
arg="$1"
|
||||
case "$arg" in
|
||||
@@ -242,13 +242,13 @@ case "$arg" in
|
||||
output=${cpio_list}
|
||||
echo "$output_file" | grep -q "\.gz$" \
|
||||
&& [ -x "`which gzip 2> /dev/null`" ] \
|
||||
- && compr="gzip -n -9 -f"
|
||||
+ && compr="gzip -n -9 -f -"
|
||||
echo "$output_file" | grep -q "\.bz2$" \
|
||||
&& [ -x "`which bzip2 2> /dev/null`" ] \
|
||||
- && compr="bzip2 -9 -f"
|
||||
+ && compr="bzip2 -9 -f -"
|
||||
echo "$output_file" | grep -q "\.lzma$" \
|
||||
&& [ -x "`which lzma 2> /dev/null`" ] \
|
||||
- && compr="lzma -9 -f"
|
||||
+ && compr="lzma e -d20 -lc1 -lp2 -pb2 -eos -si -so"
|
||||
echo "$output_file" | grep -q "\.xz$" \
|
||||
&& [ -x "`which xz 2> /dev/null`" ] \
|
||||
&& compr="xz --check=crc32 --lzma2=dict=1MiB"
|
||||
@@ -315,7 +315,7 @@ if [ ! -z ${output_file} ]; then
|
||||
if [ "${is_cpio_compressed}" = "compressed" ]; then
|
||||
cat ${cpio_tfile} > ${output_file}
|
||||
else
|
||||
- (cat ${cpio_tfile} | ${compr} - > ${output_file}) \
|
||||
+ (cat ${cpio_tfile} | ${compr} > ${output_file}) \
|
||||
|| (rm -f ${output_file} ; false)
|
||||
fi
|
||||
[ -z ${cpio_file} ] && rm ${cpio_tfile}
|
||||
--- a/lib/decompress.c
|
||||
+++ b/lib/decompress.c
|
||||
@@ -48,6 +48,7 @@ static const struct compress_format comp
|
||||
{ {0x1f, 0x9e}, "gzip", gunzip },
|
||||
{ {0x42, 0x5a}, "bzip2", bunzip2 },
|
||||
{ {0x5d, 0x00}, "lzma", unlzma },
|
||||
+ { {0x6d, 0x00}, "lzma-openwrt", unlzma },
|
||||
{ {0xfd, 0x37}, "xz", unxz },
|
||||
{ {0x89, 0x4c}, "lzo", unlzo },
|
||||
{ {0x02, 0x21}, "lz4", unlz4 },
|
@ -1,18 +0,0 @@
|
||||
--- a/net/netfilter/Kconfig
|
||||
+++ b/net/netfilter/Kconfig
|
||||
@@ -210,7 +210,6 @@ config NF_CONNTRACK_FTP
|
||||
|
||||
config NF_CONNTRACK_H323
|
||||
tristate "H.323 protocol support"
|
||||
- depends on (IPV6 || IPV6=n)
|
||||
depends on NETFILTER_ADVANCED
|
||||
help
|
||||
H.323 is a VoIP signalling protocol from ITU-T. As one of the most
|
||||
@@ -914,7 +913,6 @@ config NETFILTER_XT_TARGET_SECMARK
|
||||
|
||||
config NETFILTER_XT_TARGET_TCPMSS
|
||||
tristate '"TCPMSS" target support'
|
||||
- depends on (IPV6 || IPV6=n)
|
||||
default m if NETFILTER_ADVANCED=n
|
||||
---help---
|
||||
This option adds a `TCPMSS' target, which allows you to alter the
|
@ -1,18 +0,0 @@
|
||||
--- a/sound/core/Kconfig
|
||||
+++ b/sound/core/Kconfig
|
||||
@@ -10,13 +10,13 @@ config SND_DMAENGINE_PCM
|
||||
tristate
|
||||
|
||||
config SND_HWDEP
|
||||
- tristate
|
||||
+ tristate "Sound hardware support"
|
||||
|
||||
config SND_RAWMIDI
|
||||
tristate
|
||||
|
||||
config SND_COMPRESS_OFFLOAD
|
||||
- tristate
|
||||
+ tristate "Compression offloading support"
|
||||
|
||||
# To be effective this also requires INPUT - users should say:
|
||||
# select SND_JACK if INPUT=y || INPUT=SND
|
@ -1,10 +0,0 @@
|
||||
--- a/drivers/crypto/Kconfig
|
||||
+++ b/drivers/crypto/Kconfig
|
||||
@@ -164,6 +164,7 @@ config CRYPTO_DEV_MV_CESA
|
||||
depends on PLAT_ORION
|
||||
select CRYPTO_ALGAPI
|
||||
select CRYPTO_AES
|
||||
+ select CRYPTO_HASH2
|
||||
select CRYPTO_BLKCIPHER2
|
||||
select CRYPTO_HASH
|
||||
help
|
@ -1,29 +0,0 @@
|
||||
--- a/drivers/ssb/Kconfig
|
||||
+++ b/drivers/ssb/Kconfig
|
||||
@@ -29,6 +29,7 @@ config SSB_SPROM
|
||||
config SSB_BLOCKIO
|
||||
bool
|
||||
depends on SSB
|
||||
+ default y
|
||||
|
||||
config SSB_PCIHOST_POSSIBLE
|
||||
bool
|
||||
@@ -49,7 +50,7 @@ config SSB_PCIHOST
|
||||
config SSB_B43_PCI_BRIDGE
|
||||
bool
|
||||
depends on SSB_PCIHOST
|
||||
- default n
|
||||
+ default y
|
||||
|
||||
config SSB_PCMCIAHOST_POSSIBLE
|
||||
bool
|
||||
--- a/drivers/bcma/Kconfig
|
||||
+++ b/drivers/bcma/Kconfig
|
||||
@@ -17,6 +17,7 @@ config BCMA
|
||||
config BCMA_BLOCKIO
|
||||
bool
|
||||
depends on BCMA
|
||||
+ default y
|
||||
|
||||
config BCMA_HOST_PCI_POSSIBLE
|
||||
bool
|
@ -1,23 +0,0 @@
|
||||
--- a/lib/Kconfig
|
||||
+++ b/lib/Kconfig
|
||||
@@ -328,16 +328,16 @@ config BCH_CONST_T
|
||||
# Textsearch support is select'ed if needed
|
||||
#
|
||||
config TEXTSEARCH
|
||||
- bool
|
||||
+ boolean "Textsearch support"
|
||||
|
||||
config TEXTSEARCH_KMP
|
||||
- tristate
|
||||
+ tristate "Textsearch KMP"
|
||||
|
||||
config TEXTSEARCH_BM
|
||||
- tristate
|
||||
+ tristate "Textsearch BM"
|
||||
|
||||
config TEXTSEARCH_FSM
|
||||
- tristate
|
||||
+ tristate "Textsearch FSM"
|
||||
|
||||
config BTREE
|
||||
bool
|
@ -1,31 +0,0 @@
|
||||
--- a/net/wireless/Kconfig
|
||||
+++ b/net/wireless/Kconfig
|
||||
@@ -191,7 +191,7 @@ config CFG80211_WEXT_EXPORT
|
||||
wext compatibility symbols to be exported.
|
||||
|
||||
config LIB80211
|
||||
- tristate
|
||||
+ tristate "LIB80211"
|
||||
default n
|
||||
help
|
||||
This options enables a library of common routines used
|
||||
@@ -200,13 +200,16 @@ config LIB80211
|
||||
Drivers should select this themselves if needed.
|
||||
|
||||
config LIB80211_CRYPT_WEP
|
||||
- tristate
|
||||
+ tristate "LIB80211_CRYPT_WEP"
|
||||
+ select LIB80211
|
||||
|
||||
config LIB80211_CRYPT_CCMP
|
||||
- tristate
|
||||
+ tristate "LIB80211_CRYPT_CCMP"
|
||||
+ select LIB80211
|
||||
|
||||
config LIB80211_CRYPT_TKIP
|
||||
- tristate
|
||||
+ tristate "LIB80211_CRYPT_TKIP"
|
||||
+ select LIB80211
|
||||
|
||||
config LIB80211_DEBUG
|
||||
bool "lib80211 debugging messages"
|
@ -1,47 +0,0 @@
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -32,7 +32,7 @@ config CRYPTO_FIPS
|
||||
this is.
|
||||
|
||||
config CRYPTO_ALGAPI
|
||||
- tristate
|
||||
+ tristate "ALGAPI"
|
||||
select CRYPTO_ALGAPI2
|
||||
help
|
||||
This option provides the API for cryptographic algorithms.
|
||||
@@ -41,7 +41,7 @@ config CRYPTO_ALGAPI2
|
||||
tristate
|
||||
|
||||
config CRYPTO_AEAD
|
||||
- tristate
|
||||
+ tristate "AEAD"
|
||||
select CRYPTO_AEAD2
|
||||
select CRYPTO_ALGAPI
|
||||
|
||||
@@ -50,7 +50,7 @@ config CRYPTO_AEAD2
|
||||
select CRYPTO_ALGAPI2
|
||||
|
||||
config CRYPTO_BLKCIPHER
|
||||
- tristate
|
||||
+ tristate "BLKCIPHER"
|
||||
select CRYPTO_BLKCIPHER2
|
||||
select CRYPTO_ALGAPI
|
||||
|
||||
@@ -61,7 +61,7 @@ config CRYPTO_BLKCIPHER2
|
||||
select CRYPTO_WORKQUEUE
|
||||
|
||||
config CRYPTO_HASH
|
||||
- tristate
|
||||
+ tristate "HASH"
|
||||
select CRYPTO_HASH2
|
||||
select CRYPTO_ALGAPI
|
||||
|
||||
@@ -70,7 +70,7 @@ config CRYPTO_HASH2
|
||||
select CRYPTO_ALGAPI2
|
||||
|
||||
config CRYPTO_RNG
|
||||
- tristate
|
||||
+ tristate "RNG"
|
||||
select CRYPTO_RNG2
|
||||
select CRYPTO_ALGAPI
|
||||
|
@ -1,22 +0,0 @@
|
||||
--- a/net/wireless/Kconfig
|
||||
+++ b/net/wireless/Kconfig
|
||||
@@ -1,5 +1,5 @@
|
||||
config WIRELESS_EXT
|
||||
- bool
|
||||
+ bool "Wireless extensions"
|
||||
|
||||
config WEXT_CORE
|
||||
def_bool y
|
||||
@@ -11,10 +11,10 @@ config WEXT_PROC
|
||||
depends on WEXT_CORE
|
||||
|
||||
config WEXT_SPY
|
||||
- bool
|
||||
+ bool "WEXT_SPY"
|
||||
|
||||
config WEXT_PRIV
|
||||
- bool
|
||||
+ bool "WEXT_PRIV"
|
||||
|
||||
config CFG80211
|
||||
tristate "cfg80211 - wireless configuration API"
|
@ -1,11 +0,0 @@
|
||||
--- a/net/netfilter/Kconfig
|
||||
+++ b/net/netfilter/Kconfig
|
||||
@@ -2,7 +2,7 @@ menu "Core Netfilter Configuration"
|
||||
depends on NET && INET && NETFILTER
|
||||
|
||||
config NETFILTER_NETLINK
|
||||
- tristate
|
||||
+ tristate "Netfilter NFNETLINK interface"
|
||||
|
||||
config NETFILTER_NETLINK_ACCT
|
||||
tristate "Netfilter NFACCT over NFNETLINK interface"
|
@ -1,87 +0,0 @@
|
||||
--- a/drivers/base/regmap/Kconfig
|
||||
+++ b/drivers/base/regmap/Kconfig
|
||||
@@ -3,29 +3,35 @@
|
||||
# subsystems should select the appropriate symbols.
|
||||
|
||||
config REGMAP
|
||||
- default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ)
|
||||
select LZO_COMPRESS
|
||||
select LZO_DECOMPRESS
|
||||
select IRQ_DOMAIN if REGMAP_IRQ
|
||||
- bool
|
||||
+ tristate "Regmap"
|
||||
|
||||
config REGMAP_AC97
|
||||
+ select REGMAP
|
||||
tristate
|
||||
|
||||
config REGMAP_I2C
|
||||
- tristate
|
||||
+ tristate "Regmap I2C"
|
||||
+ select REGMAP
|
||||
depends on I2C
|
||||
|
||||
config REGMAP_SPI
|
||||
- tristate
|
||||
+ tristate "Regmap SPI"
|
||||
+ select REGMAP
|
||||
+ depends on SPI_MASTER
|
||||
depends on SPI
|
||||
|
||||
config REGMAP_SPMI
|
||||
+ select REGMAP
|
||||
tristate
|
||||
depends on SPMI
|
||||
|
||||
config REGMAP_MMIO
|
||||
- tristate
|
||||
+ tristate "Regmap MMIO"
|
||||
+ select REGMAP
|
||||
|
||||
config REGMAP_IRQ
|
||||
+ select REGMAP
|
||||
bool
|
||||
--- a/include/linux/regmap.h
|
||||
+++ b/include/linux/regmap.h
|
||||
@@ -50,7 +50,7 @@ struct reg_default {
|
||||
unsigned int def;
|
||||
};
|
||||
|
||||
-#ifdef CONFIG_REGMAP
|
||||
+#if IS_ENABLED(CONFIG_REGMAP)
|
||||
|
||||
enum regmap_endian {
|
||||
/* Unspecified -> 0 -> Backwards compatible default */
|
||||
--- a/drivers/base/regmap/Makefile
|
||||
+++ b/drivers/base/regmap/Makefile
|
||||
@@ -1,9 +1,11 @@
|
||||
# For include/trace/define_trace.h to include trace.h
|
||||
CFLAGS_regmap.o := -I$(src)
|
||||
|
||||
-obj-$(CONFIG_REGMAP) += regmap.o regcache.o
|
||||
-obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o regcache-flat.o
|
||||
-obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
|
||||
+regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-lzo.o regcache-flat.o
|
||||
+ifdef CONFIG_DEBUG_FS
|
||||
+regmap-core-objs += regmap-debugfs.o
|
||||
+endif
|
||||
+obj-$(CONFIG_REGMAP) += regmap-core.o
|
||||
obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o
|
||||
obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
|
||||
obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o
|
||||
--- a/drivers/base/regmap/regmap.c
|
||||
+++ b/drivers/base/regmap/regmap.c
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/export.h>
|
||||
+#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/of.h>
|
||||
@@ -2631,3 +2632,5 @@ static int __init regmap_initcall(void)
|
||||
return 0;
|
||||
}
|
||||
postcore_initcall(regmap_initcall);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
@ -1,37 +0,0 @@
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -96,10 +96,10 @@ config CRYPTO_MANAGER
|
||||
|
||||
config CRYPTO_MANAGER2
|
||||
def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y)
|
||||
- select CRYPTO_AEAD2
|
||||
- select CRYPTO_HASH2
|
||||
- select CRYPTO_BLKCIPHER2
|
||||
- select CRYPTO_PCOMP2
|
||||
+ select CRYPTO_AEAD2 if !CRYPTO_MANAGER_DISABLE_TESTS
|
||||
+ select CRYPTO_HASH2 if !CRYPTO_MANAGER_DISABLE_TESTS
|
||||
+ select CRYPTO_BLKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS
|
||||
+ select CRYPTO_PCOMP2 if !CRYPTO_MANAGER_DISABLE_TESTS
|
||||
|
||||
config CRYPTO_USER
|
||||
tristate "Userspace cryptographic algorithm configuration"
|
||||
--- a/crypto/algboss.c
|
||||
+++ b/crypto/algboss.c
|
||||
@@ -248,6 +248,9 @@ static int cryptomgr_schedule_test(struc
|
||||
type = alg->cra_flags;
|
||||
|
||||
/* This piece of crap needs to disappear into per-type test hooks. */
|
||||
+#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
|
||||
+ type |= CRYPTO_ALG_TESTED;
|
||||
+#else
|
||||
if ((!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) &
|
||||
CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV) &&
|
||||
((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
|
||||
@@ -256,6 +259,7 @@ static int cryptomgr_schedule_test(struc
|
||||
(!((type ^ CRYPTO_ALG_TYPE_AEAD) & CRYPTO_ALG_TYPE_MASK) &&
|
||||
alg->cra_type == &crypto_nivaead_type && alg->cra_aead.ivsize))
|
||||
type |= CRYPTO_ALG_TESTED;
|
||||
+#endif
|
||||
|
||||
param->type = type;
|
||||
|
@ -1,34 +0,0 @@
|
||||
From 8b05e325824d3b38e52a7748b3b5dc34dc1c0f6d Mon Sep 17 00:00:00 2001
|
||||
From: David Heidelberger <david.heidelberger@ixit.cz>
|
||||
Date: Mon, 29 Jun 2015 14:37:54 +0200
|
||||
Subject: [PATCH 1/3] uapi/kernel.h: glibc specific inclusion of sysinfo.h
|
||||
|
||||
including sysinfo.h from kernel.h makes no sense whatsoever,
|
||||
but removing it breaks glibc's userspace header,
|
||||
which includes kernel.h instead of sysinfo.h from their sys/sysinfo.h.
|
||||
this seems to be a historical mistake.
|
||||
on musl, including any header that uses kernel.h directly or indirectly
|
||||
plus sys/sysinfo.h will produce a compile error due to redefinition of
|
||||
struct sysinfo from sys/sysinfo.h.
|
||||
so for now, only include it on glibc or when including from kernel
|
||||
in order not to break their headers.
|
||||
|
||||
Signed-off-by: John Spencer <maillist-linux@barfooze.de>
|
||||
Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
include/uapi/linux/kernel.h | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
--- a/include/uapi/linux/kernel.h
|
||||
+++ b/include/uapi/linux/kernel.h
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef _UAPI_LINUX_KERNEL_H
|
||||
#define _UAPI_LINUX_KERNEL_H
|
||||
|
||||
+#if defined(__KERNEL__) || defined( __GLIBC__)
|
||||
#include <linux/sysinfo.h>
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* 'kernel.h' contains some often-used function prototypes etc
|
@ -1,81 +0,0 @@
|
||||
From f972afc2509eebcb00d370256c55b112a3b5ffca Mon Sep 17 00:00:00 2001
|
||||
From: David Heidelberger <david.heidelberger@ixit.cz>
|
||||
Date: Mon, 29 Jun 2015 16:50:40 +0200
|
||||
Subject: [PATCH 2/3] uapi/libc-compat.h: do not rely on __GLIBC__
|
||||
|
||||
Musl provides the same structs as glibc, but does not provide a define to
|
||||
allow its detection. Since the absence of __GLIBC__ also can mean that it
|
||||
is included from the kernel, change the __GLIBC__ detection to
|
||||
!__KERNEL__, which should always be true when included from userspace.
|
||||
|
||||
Signed-off-by: John Spencer <maillist-linux@barfooze.de>
|
||||
Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
include/uapi/linux/libc-compat.h | 18 +++++++++---------
|
||||
1 file changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/include/uapi/linux/libc-compat.h
|
||||
+++ b/include/uapi/linux/libc-compat.h
|
||||
@@ -48,13 +48,13 @@
|
||||
#ifndef _UAPI_LIBC_COMPAT_H
|
||||
#define _UAPI_LIBC_COMPAT_H
|
||||
|
||||
-/* We have included glibc headers... */
|
||||
-#if defined(__GLIBC__)
|
||||
+/* We have included libc headers... */
|
||||
+#if !defined(__KERNEL__)
|
||||
|
||||
-/* Coordinate with glibc netinet/in.h header. */
|
||||
+/* Coordinate with libc netinet/in.h header. */
|
||||
#if defined(_NETINET_IN_H)
|
||||
|
||||
-/* GLIBC headers included first so don't define anything
|
||||
+/* LIBC headers included first so don't define anything
|
||||
* that would already be defined. */
|
||||
#define __UAPI_DEF_IN_ADDR 0
|
||||
#define __UAPI_DEF_IN_IPPROTO 0
|
||||
@@ -68,7 +68,7 @@
|
||||
* if the glibc code didn't define them. This guard matches
|
||||
* the guard in glibc/inet/netinet/in.h which defines the
|
||||
* additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
|
||||
-#if defined(__USE_MISC) || defined (__USE_GNU)
|
||||
+#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
|
||||
#define __UAPI_DEF_IN6_ADDR_ALT 0
|
||||
#else
|
||||
#define __UAPI_DEF_IN6_ADDR_ALT 1
|
||||
@@ -83,7 +83,7 @@
|
||||
#else
|
||||
|
||||
/* Linux headers included first, and we must define everything
|
||||
- * we need. The expectation is that glibc will check the
|
||||
+ * we need. The expectation is that the libc will check the
|
||||
* __UAPI_DEF_* defines and adjust appropriately. */
|
||||
#define __UAPI_DEF_IN_ADDR 1
|
||||
#define __UAPI_DEF_IN_IPPROTO 1
|
||||
@@ -93,7 +93,7 @@
|
||||
#define __UAPI_DEF_IN_CLASS 1
|
||||
|
||||
#define __UAPI_DEF_IN6_ADDR 1
|
||||
-/* We unconditionally define the in6_addr macros and glibc must
|
||||
+/* We unconditionally define the in6_addr macros and the libc must
|
||||
* coordinate. */
|
||||
#define __UAPI_DEF_IN6_ADDR_ALT 1
|
||||
#define __UAPI_DEF_SOCKADDR_IN6 1
|
||||
@@ -115,7 +115,7 @@
|
||||
/* If we did not see any headers from any supported C libraries,
|
||||
* or we are being included in the kernel, then define everything
|
||||
* that we need. */
|
||||
-#else /* !defined(__GLIBC__) */
|
||||
+#else /* defined(__KERNEL__) */
|
||||
|
||||
/* Definitions for in.h */
|
||||
#define __UAPI_DEF_IN_ADDR 1
|
||||
@@ -138,6 +138,6 @@
|
||||
/* Definitions for xattr.h */
|
||||
#define __UAPI_DEF_XATTR 1
|
||||
|
||||
-#endif /* __GLIBC__ */
|
||||
+#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* _UAPI_LIBC_COMPAT_H */
|
@ -1,67 +0,0 @@
|
||||
From fcbb6fed85ea9ff4feb4f1ebd4f0f235fdaf06b6 Mon Sep 17 00:00:00 2001
|
||||
From: David Heidelberger <david.heidelberger@ixit.cz>
|
||||
Date: Mon, 29 Jun 2015 16:53:03 +0200
|
||||
Subject: [PATCH 3/3] uapi/if_ether.h: prevent redefinition of struct ethhdr
|
||||
|
||||
Musl provides its own ethhdr struct definition. Add a guard to prevent
|
||||
its definition of the appropriate musl header has already been included.
|
||||
|
||||
Signed-off-by: John Spencer <maillist-linux@barfooze.de>
|
||||
Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
include/uapi/linux/if_ether.h | 3 +++
|
||||
include/uapi/linux/libc-compat.h | 11 +++++++++++
|
||||
2 files changed, 14 insertions(+)
|
||||
|
||||
--- a/include/uapi/linux/if_ether.h
|
||||
+++ b/include/uapi/linux/if_ether.h
|
||||
@@ -22,6 +22,7 @@
|
||||
#define _UAPI_LINUX_IF_ETHER_H
|
||||
|
||||
#include <linux/types.h>
|
||||
+#include <linux/libc-compat.h>
|
||||
|
||||
/*
|
||||
* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
|
||||
@@ -134,11 +135,13 @@
|
||||
* This is an Ethernet frame header.
|
||||
*/
|
||||
|
||||
+#if __UAPI_DEF_ETHHDR
|
||||
struct ethhdr {
|
||||
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
|
||||
unsigned char h_source[ETH_ALEN]; /* source ether addr */
|
||||
__be16 h_proto; /* packet type ID field */
|
||||
} __attribute__((packed));
|
||||
+#endif
|
||||
|
||||
|
||||
#endif /* _UAPI_LINUX_IF_ETHER_H */
|
||||
--- a/include/uapi/linux/libc-compat.h
|
||||
+++ b/include/uapi/linux/libc-compat.h
|
||||
@@ -51,6 +51,14 @@
|
||||
/* We have included libc headers... */
|
||||
#if !defined(__KERNEL__)
|
||||
|
||||
+/* musl defines the ethhdr struct itself in its netinet/if_ether.h.
|
||||
+ * Glibc just includes the kernel header and uses a different guard. */
|
||||
+#if defined(_NETINET_IF_ETHER_H)
|
||||
+#define __UAPI_DEF_ETHHDR 0
|
||||
+#else
|
||||
+#define __UAPI_DEF_ETHHDR 1
|
||||
+#endif
|
||||
+
|
||||
/* Coordinate with libc netinet/in.h header. */
|
||||
#if defined(_NETINET_IN_H)
|
||||
|
||||
@@ -117,6 +125,9 @@
|
||||
* that we need. */
|
||||
#else /* defined(__KERNEL__) */
|
||||
|
||||
+/* Definitions for if_ether.h */
|
||||
+#define __UAPI_DEF_ETHHDR 1
|
||||
+
|
||||
/* Definitions for in.h */
|
||||
#define __UAPI_DEF_IN_ADDR 1
|
||||
#define __UAPI_DEF_IN_IPPROTO 1
|
@ -1,39 +0,0 @@
|
||||
From: Mark Miller <mark@mirell.org>
|
||||
|
||||
This exposes the CONFIG_BOOT_RAW symbol in Kconfig. This is needed on
|
||||
certain Broadcom chipsets running CFE in order to load the kernel.
|
||||
|
||||
Signed-off-by: Mark Miller <mark@mirell.org>
|
||||
Acked-by: Rob Landley <rob@landley.net>
|
||||
---
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -984,9 +984,6 @@ config FW_ARC
|
||||
config ARCH_MAY_HAVE_PC_FDC
|
||||
bool
|
||||
|
||||
-config BOOT_RAW
|
||||
- bool
|
||||
-
|
||||
config CEVT_BCM1480
|
||||
bool
|
||||
|
||||
@@ -2677,6 +2674,18 @@ config USE_OF
|
||||
config BUILTIN_DTB
|
||||
bool
|
||||
|
||||
+config BOOT_RAW
|
||||
+ bool "Enable the kernel to be executed from the load address"
|
||||
+ default n
|
||||
+ help
|
||||
+ Allow the kernel to be executed from the load address for
|
||||
+ bootloaders which cannot read the ELF format. This places
|
||||
+ a jump to start_kernel at the load address.
|
||||
+
|
||||
+ If unsure, say N.
|
||||
+
|
||||
+
|
||||
+
|
||||
endmenu
|
||||
|
||||
config LOCKDEP_SUPPORT
|
@ -1,28 +0,0 @@
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -1073,6 +1073,10 @@ config SYNC_R4K
|
||||
config MIPS_MACHINE
|
||||
def_bool n
|
||||
|
||||
+config IMAGE_CMDLINE_HACK
|
||||
+ bool "OpenWrt specific image command line hack"
|
||||
+ default n
|
||||
+
|
||||
config NO_IOPORT_MAP
|
||||
def_bool n
|
||||
|
||||
--- a/arch/mips/kernel/head.S
|
||||
+++ b/arch/mips/kernel/head.S
|
||||
@@ -80,6 +80,12 @@ FEXPORT(__kernel_entry)
|
||||
j kernel_entry
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_IMAGE_CMDLINE_HACK
|
||||
+ .ascii "CMDLINE:"
|
||||
+EXPORT(__image_cmdline)
|
||||
+ .fill 0x400
|
||||
+#endif /* CONFIG_IMAGE_CMDLINE_HACK */
|
||||
+
|
||||
__REF
|
||||
|
||||
NESTED(kernel_entry, 16, sp) # kernel entry point
|
@ -1,11 +0,0 @@
|
||||
--- a/arch/mips/Makefile
|
||||
+++ b/arch/mips/Makefile
|
||||
@@ -87,7 +87,7 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin
|
||||
# machines may also. Since BFD is incredibly buggy with respect to
|
||||
# crossformat linking we rely on the elf2ecoff tool for format conversion.
|
||||
#
|
||||
-cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
|
||||
+cflags-y += -G 0 -mno-abicalls -fno-pic -pipe -mno-branch-likely
|
||||
cflags-y += -msoft-float
|
||||
LDFLAGS_vmlinux += -G 0 -static -n -nostdlib --gc-sections
|
||||
KBUILD_AFLAGS_MODULE += -mlong-calls
|
@ -1,106 +0,0 @@
|
||||
From: Manuel Lauss <manuel.lauss@gmail.com>
|
||||
Subject: [RFC PATCH v4 2/2] MIPS: make FPU emulator optional
|
||||
Date: Mon, 7 Apr 2014 12:57:04 +0200
|
||||
Message-Id: <1396868224-252888-2-git-send-email-manuel.lauss@gmail.com>
|
||||
|
||||
This small patch makes the MIPS FPU emulator optional. The kernel
|
||||
kills float-users on systems without a hardware FPU by sending a SIGILL.
|
||||
|
||||
Disabling the emulator shrinks vmlinux by about 54kBytes (32bit,
|
||||
optimizing for size).
|
||||
|
||||
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
|
||||
---
|
||||
v4: rediffed because of patch 1/2, should now work with micromips as well
|
||||
v3: updated patch description with size savings.
|
||||
v2: incorporated changes suggested by Jonas Gorski
|
||||
force the fpu emulator on for micromips: relocating the parts
|
||||
of the mmips code in the emulator to other areas would be a
|
||||
much larger change; I went the cheap route instead with this.
|
||||
|
||||
arch/mips/Kbuild | 2 +-
|
||||
arch/mips/Kconfig | 14 ++++++++++++++
|
||||
arch/mips/include/asm/fpu.h | 5 +++--
|
||||
arch/mips/include/asm/fpu_emulator.h | 15 +++++++++++++++
|
||||
4 files changed, 33 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -2669,6 +2669,20 @@ config MIPS_O32_FP64_SUPPORT
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
+config MIPS_FPU_EMULATOR
|
||||
+ bool "MIPS FPU Emulator"
|
||||
+ default y
|
||||
+ help
|
||||
+ This option lets you disable the built-in MIPS FPU (Coprocessor 1)
|
||||
+ emulator, which handles floating-point instructions on processors
|
||||
+ without a hardware FPU. It is generally a good idea to keep the
|
||||
+ emulator built-in, unless you are perfectly sure you have a
|
||||
+ complete soft-float environment. With the emulator disabled, all
|
||||
+ users of float operations will be killed with an illegal instr-
|
||||
+ uction exception.
|
||||
+
|
||||
+ Say Y, please.
|
||||
+
|
||||
config USE_OF
|
||||
bool
|
||||
select OF
|
||||
--- a/arch/mips/Makefile
|
||||
+++ b/arch/mips/Makefile
|
||||
@@ -292,7 +292,7 @@ OBJCOPYFLAGS += --remove-section=.regin
|
||||
head-y := arch/mips/kernel/head.o
|
||||
|
||||
libs-y += arch/mips/lib/
|
||||
-libs-y += arch/mips/math-emu/
|
||||
+libs-$(CONFIG_MIPS_FPU_EMULATOR) += arch/mips/math-emu/
|
||||
|
||||
# See arch/mips/Kbuild for content of core part of the kernel
|
||||
core-y += arch/mips/
|
||||
--- a/arch/mips/include/asm/fpu.h
|
||||
+++ b/arch/mips/include/asm/fpu.h
|
||||
@@ -218,8 +218,10 @@ static inline int init_fpu(void)
|
||||
/* Restore FRE */
|
||||
write_c0_config5(config5);
|
||||
enable_fpu_hazard();
|
||||
- } else
|
||||
+ } else if (IS_ENABLED(CONFIG_MIPS_FPU_EMULATOR))
|
||||
fpu_emulator_init_fpu();
|
||||
+ else
|
||||
+ ret = SIGILL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
--- a/arch/mips/include/asm/fpu_emulator.h
|
||||
+++ b/arch/mips/include/asm/fpu_emulator.h
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <asm/local.h>
|
||||
#include <asm/processor.h>
|
||||
|
||||
+#ifdef CONFIG_MIPS_FPU_EMULATOR
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
|
||||
struct mips_fpu_emulator_stats {
|
||||
@@ -66,6 +67,21 @@ extern int do_dsemulret(struct pt_regs *
|
||||
extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
|
||||
struct mips_fpu_struct *ctx, int has_fpu,
|
||||
void *__user *fault_addr);
|
||||
+#else /* no CONFIG_MIPS_FPU_EMULATOR */
|
||||
+static inline int do_dsemulret(struct pt_regs *xcp)
|
||||
+{
|
||||
+ return 0; /* 0 means error, should never get here anyway */
|
||||
+}
|
||||
+
|
||||
+static inline int fpu_emulator_cop1Handler(struct pt_regs *xcp,
|
||||
+ struct mips_fpu_struct *ctx, int has_fpu,
|
||||
+ void *__user *fault_addr)
|
||||
+{
|
||||
+ *fault_addr = NULL;
|
||||
+ return SIGILL; /* we don't speak MIPS FPU */
|
||||
+}
|
||||
+#endif /* CONFIG_MIPS_FPU_EMULATOR */
|
||||
+
|
||||
int process_fpemu_return(int sig, void __user *fault_addr,
|
||||
unsigned long fcr31);
|
||||
int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
|
@ -1,352 +0,0 @@
|
||||
--- a/arch/mips/Makefile
|
||||
+++ b/arch/mips/Makefile
|
||||
@@ -90,8 +90,13 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin
|
||||
cflags-y += -G 0 -mno-abicalls -fno-pic -pipe -mno-branch-likely
|
||||
cflags-y += -msoft-float
|
||||
LDFLAGS_vmlinux += -G 0 -static -n -nostdlib --gc-sections
|
||||
+ifdef CONFIG_64BIT
|
||||
KBUILD_AFLAGS_MODULE += -mlong-calls
|
||||
KBUILD_CFLAGS_MODULE += -mlong-calls
|
||||
+else
|
||||
+KBUILD_AFLAGS_MODULE += -mno-long-calls
|
||||
+KBUILD_CFLAGS_MODULE += -mno-long-calls
|
||||
+endif
|
||||
|
||||
ifndef CONFIG_FUNCTION_TRACER
|
||||
KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
|
||||
--- a/arch/mips/include/asm/module.h
|
||||
+++ b/arch/mips/include/asm/module.h
|
||||
@@ -11,6 +11,11 @@ struct mod_arch_specific {
|
||||
const struct exception_table_entry *dbe_start;
|
||||
const struct exception_table_entry *dbe_end;
|
||||
struct mips_hi16 *r_mips_hi16_list;
|
||||
+
|
||||
+ void *phys_plt_tbl;
|
||||
+ void *virt_plt_tbl;
|
||||
+ unsigned int phys_plt_offset;
|
||||
+ unsigned int virt_plt_offset;
|
||||
};
|
||||
|
||||
typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */
|
||||
--- a/arch/mips/kernel/module.c
|
||||
+++ b/arch/mips/kernel/module.c
|
||||
@@ -43,14 +43,221 @@ struct mips_hi16 {
|
||||
static LIST_HEAD(dbe_list);
|
||||
static DEFINE_SPINLOCK(dbe_lock);
|
||||
|
||||
-#ifdef MODULE_START
|
||||
+/*
|
||||
+ * Get the potential max trampolines size required of the init and
|
||||
+ * non-init sections. Only used if we cannot find enough contiguous
|
||||
+ * physically mapped memory to put the module into.
|
||||
+ */
|
||||
+static unsigned int
|
||||
+get_plt_size(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
|
||||
+ const char *secstrings, unsigned int symindex, bool is_init)
|
||||
+{
|
||||
+ unsigned long ret = 0;
|
||||
+ unsigned int i, j;
|
||||
+ Elf_Sym *syms;
|
||||
+
|
||||
+ /* Everything marked ALLOC (this includes the exported symbols) */
|
||||
+ for (i = 1; i < hdr->e_shnum; ++i) {
|
||||
+ unsigned int info = sechdrs[i].sh_info;
|
||||
+
|
||||
+ if (sechdrs[i].sh_type != SHT_REL
|
||||
+ && sechdrs[i].sh_type != SHT_RELA)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Not a valid relocation section? */
|
||||
+ if (info >= hdr->e_shnum)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Don't bother with non-allocated sections */
|
||||
+ if (!(sechdrs[info].sh_flags & SHF_ALLOC))
|
||||
+ continue;
|
||||
+
|
||||
+ /* If it's called *.init*, and we're not init, we're
|
||||
+ not interested */
|
||||
+ if ((strstr(secstrings + sechdrs[i].sh_name, ".init") != 0)
|
||||
+ != is_init)
|
||||
+ continue;
|
||||
+
|
||||
+ syms = (Elf_Sym *) sechdrs[symindex].sh_addr;
|
||||
+ if (sechdrs[i].sh_type == SHT_REL) {
|
||||
+ Elf_Mips_Rel *rel = (void *) sechdrs[i].sh_addr;
|
||||
+ unsigned int size = sechdrs[i].sh_size / sizeof(*rel);
|
||||
+
|
||||
+ for (j = 0; j < size; ++j) {
|
||||
+ Elf_Sym *sym;
|
||||
+
|
||||
+ if (ELF_MIPS_R_TYPE(rel[j]) != R_MIPS_26)
|
||||
+ continue;
|
||||
+
|
||||
+ sym = syms + ELF_MIPS_R_SYM(rel[j]);
|
||||
+ if (!is_init && sym->st_shndx != SHN_UNDEF)
|
||||
+ continue;
|
||||
+
|
||||
+ ret += 4 * sizeof(int);
|
||||
+ }
|
||||
+ } else {
|
||||
+ Elf_Mips_Rela *rela = (void *) sechdrs[i].sh_addr;
|
||||
+ unsigned int size = sechdrs[i].sh_size / sizeof(*rela);
|
||||
+
|
||||
+ for (j = 0; j < size; ++j) {
|
||||
+ Elf_Sym *sym;
|
||||
+
|
||||
+ if (ELF_MIPS_R_TYPE(rela[j]) != R_MIPS_26)
|
||||
+ continue;
|
||||
+
|
||||
+ sym = syms + ELF_MIPS_R_SYM(rela[j]);
|
||||
+ if (!is_init && sym->st_shndx != SHN_UNDEF)
|
||||
+ continue;
|
||||
+
|
||||
+ ret += 4 * sizeof(int);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+#ifndef MODULE_START
|
||||
+static void *alloc_phys(unsigned long size)
|
||||
+{
|
||||
+ unsigned order;
|
||||
+ struct page *page;
|
||||
+ struct page *p;
|
||||
+
|
||||
+ size = PAGE_ALIGN(size);
|
||||
+ order = get_order(size);
|
||||
+
|
||||
+ page = alloc_pages(GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN |
|
||||
+ __GFP_THISNODE, order);
|
||||
+ if (!page)
|
||||
+ return NULL;
|
||||
+
|
||||
+ split_page(page, order);
|
||||
+
|
||||
+ /* mark all pages except for the last one */
|
||||
+ for (p = page; p + 1 < page + (size >> PAGE_SHIFT); ++p)
|
||||
+ set_bit(PG_owner_priv_1, &p->flags);
|
||||
+
|
||||
+ for (p = page + (size >> PAGE_SHIFT); p < page + (1 << order); ++p)
|
||||
+ __free_page(p);
|
||||
+
|
||||
+ return page_address(page);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static void free_phys(void *ptr)
|
||||
+{
|
||||
+ struct page *page;
|
||||
+ bool free;
|
||||
+
|
||||
+ page = virt_to_page(ptr);
|
||||
+ do {
|
||||
+ free = test_and_clear_bit(PG_owner_priv_1, &page->flags);
|
||||
+ __free_page(page);
|
||||
+ page++;
|
||||
+ } while (free);
|
||||
+}
|
||||
+
|
||||
+
|
||||
void *module_alloc(unsigned long size)
|
||||
{
|
||||
+#ifdef MODULE_START
|
||||
return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END,
|
||||
GFP_KERNEL, PAGE_KERNEL, 0, NUMA_NO_NODE,
|
||||
__builtin_return_address(0));
|
||||
+#else
|
||||
+ void *ptr;
|
||||
+
|
||||
+ if (size == 0)
|
||||
+ return NULL;
|
||||
+
|
||||
+ ptr = alloc_phys(size);
|
||||
+
|
||||
+ /* If we failed to allocate physically contiguous memory,
|
||||
+ * fall back to regular vmalloc. The module loader code will
|
||||
+ * create jump tables to handle long jumps */
|
||||
+ if (!ptr)
|
||||
+ return vmalloc(size);
|
||||
+
|
||||
+ return ptr;
|
||||
+#endif
|
||||
}
|
||||
+
|
||||
+static inline bool is_phys_addr(void *ptr)
|
||||
+{
|
||||
+#ifdef CONFIG_64BIT
|
||||
+ return (KSEGX((unsigned long)ptr) == CKSEG0);
|
||||
+#else
|
||||
+ return (KSEGX(ptr) == KSEG0);
|
||||
#endif
|
||||
+}
|
||||
+
|
||||
+/* Free memory returned from module_alloc */
|
||||
+void module_memfree(void *module_region)
|
||||
+{
|
||||
+ if (is_phys_addr(module_region))
|
||||
+ free_phys(module_region);
|
||||
+ else
|
||||
+ vfree(module_region);
|
||||
+}
|
||||
+
|
||||
+static void *__module_alloc(int size, bool phys)
|
||||
+{
|
||||
+ void *ptr;
|
||||
+
|
||||
+ if (phys)
|
||||
+ ptr = kmalloc(size, GFP_KERNEL);
|
||||
+ else
|
||||
+ ptr = vmalloc(size);
|
||||
+ return ptr;
|
||||
+}
|
||||
+
|
||||
+static void __module_free(void *ptr)
|
||||
+{
|
||||
+ if (is_phys_addr(ptr))
|
||||
+ kfree(ptr);
|
||||
+ else
|
||||
+ vfree(ptr);
|
||||
+}
|
||||
+
|
||||
+int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
|
||||
+ char *secstrings, struct module *mod)
|
||||
+{
|
||||
+ unsigned int symindex = 0;
|
||||
+ unsigned int core_size, init_size;
|
||||
+ int i;
|
||||
+
|
||||
+ mod->arch.phys_plt_offset = 0;
|
||||
+ mod->arch.virt_plt_offset = 0;
|
||||
+ mod->arch.phys_plt_tbl = NULL;
|
||||
+ mod->arch.virt_plt_tbl = NULL;
|
||||
+
|
||||
+ if (IS_ENABLED(CONFIG_64BIT))
|
||||
+ return 0;
|
||||
+
|
||||
+ for (i = 1; i < hdr->e_shnum; i++)
|
||||
+ if (sechdrs[i].sh_type == SHT_SYMTAB)
|
||||
+ symindex = i;
|
||||
+
|
||||
+ core_size = get_plt_size(hdr, sechdrs, secstrings, symindex, false);
|
||||
+ init_size = get_plt_size(hdr, sechdrs, secstrings, symindex, true);
|
||||
+
|
||||
+ if ((core_size + init_size) == 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ mod->arch.phys_plt_tbl = __module_alloc(core_size + init_size, 1);
|
||||
+ if (!mod->arch.phys_plt_tbl)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ mod->arch.virt_plt_tbl = __module_alloc(core_size + init_size, 0);
|
||||
+ if (!mod->arch.virt_plt_tbl) {
|
||||
+ __module_free(mod->arch.phys_plt_tbl);
|
||||
+ mod->arch.phys_plt_tbl = NULL;
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
|
||||
int apply_r_mips_none(struct module *me, u32 *location, Elf_Addr v)
|
||||
{
|
||||
@@ -64,8 +271,39 @@ static int apply_r_mips_32_rel(struct mo
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static Elf_Addr add_plt_entry_to(unsigned *plt_offset,
|
||||
+ void *start, Elf_Addr v)
|
||||
+{
|
||||
+ unsigned *tramp = start + *plt_offset;
|
||||
+ *plt_offset += 4 * sizeof(int);
|
||||
+
|
||||
+ /* adjust carry for addiu */
|
||||
+ if (v & 0x00008000)
|
||||
+ v += 0x10000;
|
||||
+
|
||||
+ tramp[0] = 0x3c190000 | (v >> 16); /* lui t9, hi16 */
|
||||
+ tramp[1] = 0x27390000 | (v & 0xffff); /* addiu t9, t9, lo16 */
|
||||
+ tramp[2] = 0x03200008; /* jr t9 */
|
||||
+ tramp[3] = 0x00000000; /* nop */
|
||||
+
|
||||
+ return (Elf_Addr) tramp;
|
||||
+}
|
||||
+
|
||||
+static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v)
|
||||
+{
|
||||
+ if (is_phys_addr(location))
|
||||
+ return add_plt_entry_to(&me->arch.phys_plt_offset,
|
||||
+ me->arch.phys_plt_tbl, v);
|
||||
+ else
|
||||
+ return add_plt_entry_to(&me->arch.virt_plt_offset,
|
||||
+ me->arch.virt_plt_tbl, v);
|
||||
+
|
||||
+}
|
||||
+
|
||||
static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
|
||||
{
|
||||
+ u32 ofs = *location & 0x03ffffff;
|
||||
+
|
||||
if (v % 4) {
|
||||
pr_err("module %s: dangerous R_MIPS_26 REL relocation\n",
|
||||
me->name);
|
||||
@@ -73,14 +311,17 @@ static int apply_r_mips_26_rel(struct mo
|
||||
}
|
||||
|
||||
if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) {
|
||||
- printk(KERN_ERR
|
||||
- "module %s: relocation overflow\n",
|
||||
- me->name);
|
||||
- return -ENOEXEC;
|
||||
+ v = add_plt_entry(me, location, v + (ofs << 2));
|
||||
+ if (!v) {
|
||||
+ printk(KERN_ERR
|
||||
+ "module %s: relocation overflow\n", me->name);
|
||||
+ return -ENOEXEC;
|
||||
+ }
|
||||
+ ofs = 0;
|
||||
}
|
||||
|
||||
*location = (*location & ~0x03ffffff) |
|
||||
- ((*location + (v >> 2)) & 0x03ffffff);
|
||||
+ ((ofs + (v >> 2)) & 0x03ffffff);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -287,9 +528,33 @@ int module_finalize(const Elf_Ehdr *hdr,
|
||||
list_add(&me->arch.dbe_list, &dbe_list);
|
||||
spin_unlock_irq(&dbe_lock);
|
||||
}
|
||||
+
|
||||
+ /* Get rid of the fixup trampoline if we're running the module
|
||||
+ * from physically mapped address space */
|
||||
+ if (me->arch.phys_plt_offset == 0) {
|
||||
+ __module_free(me->arch.phys_plt_tbl);
|
||||
+ me->arch.phys_plt_tbl = NULL;
|
||||
+ }
|
||||
+ if (me->arch.virt_plt_offset == 0) {
|
||||
+ __module_free(me->arch.virt_plt_tbl);
|
||||
+ me->arch.virt_plt_tbl = NULL;
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
+void module_arch_freeing_init(struct module *mod)
|
||||
+{
|
||||
+ if (mod->arch.phys_plt_tbl) {
|
||||
+ __module_free(mod->arch.phys_plt_tbl);
|
||||
+ mod->arch.phys_plt_tbl = NULL;
|
||||
+ }
|
||||
+ if (mod->arch.virt_plt_tbl) {
|
||||
+ __module_free(mod->arch.virt_plt_tbl);
|
||||
+ mod->arch.virt_plt_tbl = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void module_arch_cleanup(struct module *mod)
|
||||
{
|
||||
spin_lock_irq(&dbe_lock);
|
@ -1,83 +0,0 @@
|
||||
--- a/arch/mips/include/asm/string.h
|
||||
+++ b/arch/mips/include/asm/string.h
|
||||
@@ -133,11 +133,44 @@ strncmp(__const__ char *__cs, __const__
|
||||
|
||||
#define __HAVE_ARCH_MEMSET
|
||||
extern void *memset(void *__s, int __c, size_t __count);
|
||||
+#define memset(__s, __c, len) \
|
||||
+({ \
|
||||
+ size_t __len = (len); \
|
||||
+ void *__ret; \
|
||||
+ if (__builtin_constant_p(len) && __len >= 64) \
|
||||
+ __ret = memset((__s), (__c), __len); \
|
||||
+ else \
|
||||
+ __ret = __builtin_memset((__s), (__c), __len); \
|
||||
+ __ret; \
|
||||
+})
|
||||
|
||||
#define __HAVE_ARCH_MEMCPY
|
||||
extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
|
||||
+#define memcpy(dst, src, len) \
|
||||
+({ \
|
||||
+ size_t __len = (len); \
|
||||
+ void *__ret; \
|
||||
+ if (__builtin_constant_p(len) && __len >= 64) \
|
||||
+ __ret = memcpy((dst), (src), __len); \
|
||||
+ else \
|
||||
+ __ret = __builtin_memcpy((dst), (src), __len); \
|
||||
+ __ret; \
|
||||
+})
|
||||
|
||||
#define __HAVE_ARCH_MEMMOVE
|
||||
extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
|
||||
+#define memmove(dst, src, len) \
|
||||
+({ \
|
||||
+ size_t __len = (len); \
|
||||
+ void *__ret; \
|
||||
+ if (__builtin_constant_p(len) && __len >= 64) \
|
||||
+ __ret = memmove((dst), (src), __len); \
|
||||
+ else \
|
||||
+ __ret = __builtin_memmove((dst), (src), __len); \
|
||||
+ __ret; \
|
||||
+})
|
||||
+
|
||||
+#define __HAVE_ARCH_MEMCMP
|
||||
+#define memcmp(src1, src2, len) __builtin_memcmp((src1), (src2), (len))
|
||||
|
||||
#endif /* _ASM_STRING_H */
|
||||
--- a/arch/mips/lib/Makefile
|
||||
+++ b/arch/mips/lib/Makefile
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \
|
||||
mips-atomic.o strlen_user.o strncpy_user.o \
|
||||
- strnlen_user.o uncached.o
|
||||
+ strnlen_user.o uncached.o memcmp.o
|
||||
|
||||
obj-y += iomap.o
|
||||
obj-$(CONFIG_PCI) += iomap-pci.o
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/lib/memcmp.c
|
||||
@@ -0,0 +1,22 @@
|
||||
+/*
|
||||
+ * copied from linux/lib/string.c
|
||||
+ *
|
||||
+ * Copyright (C) 1991, 1992 Linus Torvalds
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/string.h>
|
||||
+
|
||||
+#undef memcmp
|
||||
+int memcmp(const void *cs, const void *ct, size_t count)
|
||||
+{
|
||||
+ const unsigned char *su1, *su2;
|
||||
+ int res = 0;
|
||||
+
|
||||
+ for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
|
||||
+ if ((res = *su1 - *su2) != 0)
|
||||
+ break;
|
||||
+ return res;
|
||||
+}
|
||||
+EXPORT_SYMBOL(memcmp);
|
||||
+
|
@ -1,17 +0,0 @@
|
||||
Adjust highmem offset to 0x10000000 to ensure that all kmalloc allocations
|
||||
stay within the same 256M boundary. This ensures that -mlong-calls is not
|
||||
needed on systems with more than 256M RAM.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
--- a/arch/mips/include/asm/mach-generic/spaces.h
|
||||
+++ b/arch/mips/include/asm/mach-generic/spaces.h
|
||||
@@ -44,7 +44,7 @@
|
||||
* Memory above this physical address will be considered highmem.
|
||||
*/
|
||||
#ifndef HIGHMEM_START
|
||||
-#define HIGHMEM_START _AC(0x20000000, UL)
|
||||
+#define HIGHMEM_START _AC(0x10000000, UL)
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_32BIT */
|
@ -1,13 +0,0 @@
|
||||
--- a/arch/arm/kernel/module.c
|
||||
+++ b/arch/arm/kernel/module.c
|
||||
@@ -83,6 +83,10 @@ apply_relocate(Elf32_Shdr *sechdrs, cons
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
+ if ((IS_ERR_VALUE(sym->st_value) || !sym->st_value) &&
|
||||
+ ELF_ST_BIND(sym->st_info) == STB_WEAK)
|
||||
+ continue;
|
||||
+
|
||||
loc = dstsec->sh_addr + rel->r_offset;
|
||||
|
||||
switch (ELF32_R_TYPE(rel->r_info)) {
|
@ -1,31 +0,0 @@
|
||||
Upstream doesn't optimize the kernel and bootwrappers for ppc44x because
|
||||
they still want to support gcc 3.3 -- well, we don't.
|
||||
|
||||
--- a/arch/powerpc/Makefile
|
||||
+++ b/arch/powerpc/Makefile
|
||||
@@ -203,7 +203,8 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
|
||||
KBUILD_CFLAGS += -mno-sched-epilog
|
||||
endif
|
||||
|
||||
-cpu-as-$(CONFIG_4xx) += -Wa,-m405
|
||||
+cpu-as-$(CONFIG_40x) += -Wa,-m405
|
||||
+cpu-as-$(CONFIG_44x) += -Wa,-m440
|
||||
cpu-as-$(CONFIG_ALTIVEC) += -Wa,-maltivec
|
||||
cpu-as-$(CONFIG_E200) += -Wa,-me200
|
||||
|
||||
--- a/arch/powerpc/boot/Makefile
|
||||
+++ b/arch/powerpc/boot/Makefile
|
||||
@@ -48,10 +48,10 @@ BOOTCFLAGS += -I$(obj) -I$(srctree)/$(ob
|
||||
DTC_FLAGS ?= -p 1024
|
||||
|
||||
$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
|
||||
-$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
|
||||
+$(obj)/ebony.o: BOOTCFLAGS += -mcpu=440
|
||||
$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
|
||||
-$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
|
||||
-$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
|
||||
+$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=440
|
||||
+$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=440
|
||||
$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
|
||||
$(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
|
||||
$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
|
@ -1,10 +0,0 @@
|
||||
--- a/arch/powerpc/Makefile
|
||||
+++ b/arch/powerpc/Makefile
|
||||
@@ -165,7 +165,6 @@ CPP = $(CC) -E $(KBUILD_CFLAGS)
|
||||
|
||||
CHECKFLAGS += -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__
|
||||
|
||||
-KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
|
||||
|
||||
ifeq ($(CONFIG_476FPE_ERR46),y)
|
||||
KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
|
@ -1,298 +0,0 @@
|
||||
From d8582dcf1ed66eee88a11e4760f42c0d6c8822be Mon Sep 17 00:00:00 2001
|
||||
From: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
Date: Sat, 31 Jan 2015 22:26:03 +0800
|
||||
Subject: [PATCH 331/331] MIPS: kexec: Accept command line parameters from
|
||||
userspace.
|
||||
|
||||
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
---
|
||||
arch/mips/kernel/machine_kexec.c | 153 +++++++++++++++++++++++++++++++-----
|
||||
arch/mips/kernel/machine_kexec.h | 20 +++++
|
||||
arch/mips/kernel/relocate_kernel.S | 21 +++--
|
||||
3 files changed, 167 insertions(+), 27 deletions(-)
|
||||
create mode 100644 arch/mips/kernel/machine_kexec.h
|
||||
|
||||
--- a/arch/mips/kernel/machine_kexec.c
|
||||
+++ b/arch/mips/kernel/machine_kexec.c
|
||||
@@ -10,45 +10,145 @@
|
||||
#include <linux/mm.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
+#include <asm/bootinfo.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/page.h>
|
||||
-
|
||||
-extern const unsigned char relocate_new_kernel[];
|
||||
-extern const size_t relocate_new_kernel_size;
|
||||
-
|
||||
-extern unsigned long kexec_start_address;
|
||||
-extern unsigned long kexec_indirection_page;
|
||||
+#include <asm/uaccess.h>
|
||||
+#include "machine_kexec.h"
|
||||
|
||||
int (*_machine_kexec_prepare)(struct kimage *) = NULL;
|
||||
void (*_machine_kexec_shutdown)(void) = NULL;
|
||||
void (*_machine_crash_shutdown)(struct pt_regs *regs) = NULL;
|
||||
+
|
||||
#ifdef CONFIG_SMP
|
||||
void (*relocated_kexec_smp_wait) (void *);
|
||||
atomic_t kexec_ready_to_reboot = ATOMIC_INIT(0);
|
||||
#endif
|
||||
|
||||
-int
|
||||
-machine_kexec_prepare(struct kimage *kimage)
|
||||
+static void machine_kexec_print_args(void)
|
||||
{
|
||||
+ unsigned long argc = (int)kexec_args[0];
|
||||
+ int i;
|
||||
+
|
||||
+ pr_info("kexec_args[0] (argc): %lu\n", argc);
|
||||
+ pr_info("kexec_args[1] (argv): %p\n", (void *)kexec_args[1]);
|
||||
+ pr_info("kexec_args[2] (env ): %p\n", (void *)kexec_args[2]);
|
||||
+ pr_info("kexec_args[3] (desc): %p\n", (void *)kexec_args[3]);
|
||||
+
|
||||
+ for (i = 0; i < argc; i++) {
|
||||
+ pr_info("kexec_argv[%d] = %p, %s\n",
|
||||
+ i, kexec_argv[i], kexec_argv[i]);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void machine_kexec_init_argv(struct kimage *image)
|
||||
+{
|
||||
+ void __user *buf = NULL;
|
||||
+ size_t bufsz;
|
||||
+ size_t size;
|
||||
+ int i;
|
||||
+
|
||||
+ bufsz = 0;
|
||||
+ for (i = 0; i < image->nr_segments; i++) {
|
||||
+ struct kexec_segment *seg;
|
||||
+
|
||||
+ seg = &image->segment[i];
|
||||
+ if (seg->bufsz < 6)
|
||||
+ continue;
|
||||
+
|
||||
+ if (strncmp((char *) seg->buf, "kexec ", 6))
|
||||
+ continue;
|
||||
+
|
||||
+ buf = seg->buf;
|
||||
+ bufsz = seg->bufsz;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (!buf)
|
||||
+ return;
|
||||
+
|
||||
+ size = KEXEC_COMMAND_LINE_SIZE;
|
||||
+ size = min(size, bufsz);
|
||||
+ if (size < bufsz)
|
||||
+ pr_warn("kexec command line truncated to %zd bytes\n", size);
|
||||
+
|
||||
+ /* Copy to kernel space */
|
||||
+ copy_from_user(kexec_argv_buf, buf, size);
|
||||
+ kexec_argv_buf[size - 1] = 0;
|
||||
+}
|
||||
+
|
||||
+static void machine_kexec_parse_argv(struct kimage *image)
|
||||
+{
|
||||
+ char *reboot_code_buffer;
|
||||
+ int reloc_delta;
|
||||
+ char *ptr;
|
||||
+ int argc;
|
||||
+ int i;
|
||||
+
|
||||
+ ptr = kexec_argv_buf;
|
||||
+ argc = 0;
|
||||
+
|
||||
+ /*
|
||||
+ * convert command line string to array of parameters
|
||||
+ * (as bootloader does).
|
||||
+ */
|
||||
+ while (ptr && *ptr && (KEXEC_MAX_ARGC > argc)) {
|
||||
+ if (*ptr == ' ') {
|
||||
+ *ptr++ = '\0';
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ kexec_argv[argc++] = ptr;
|
||||
+ ptr = strchr(ptr, ' ');
|
||||
+ }
|
||||
+
|
||||
+ if (!argc)
|
||||
+ return;
|
||||
+
|
||||
+ kexec_args[0] = argc;
|
||||
+ kexec_args[1] = (unsigned long)kexec_argv;
|
||||
+ kexec_args[2] = 0;
|
||||
+ kexec_args[3] = 0;
|
||||
+
|
||||
+ reboot_code_buffer = page_address(image->control_code_page);
|
||||
+ reloc_delta = reboot_code_buffer - (char *)kexec_relocate_new_kernel;
|
||||
+
|
||||
+ kexec_args[1] += reloc_delta;
|
||||
+ for (i = 0; i < argc; i++)
|
||||
+ kexec_argv[i] += reloc_delta;
|
||||
+}
|
||||
+
|
||||
+int machine_kexec_prepare(struct kimage *kimage)
|
||||
+{
|
||||
+ /*
|
||||
+ * Whenever arguments passed from kexec-tools, Init the arguments as
|
||||
+ * the original ones to try avoiding booting failure.
|
||||
+ */
|
||||
+
|
||||
+ kexec_args[0] = fw_arg0;
|
||||
+ kexec_args[1] = fw_arg1;
|
||||
+ kexec_args[2] = fw_arg2;
|
||||
+ kexec_args[3] = fw_arg3;
|
||||
+
|
||||
+ machine_kexec_init_argv(kimage);
|
||||
+ machine_kexec_parse_argv(kimage);
|
||||
+
|
||||
if (_machine_kexec_prepare)
|
||||
return _machine_kexec_prepare(kimage);
|
||||
return 0;
|
||||
}
|
||||
|
||||
-void
|
||||
-machine_kexec_cleanup(struct kimage *kimage)
|
||||
+void machine_kexec_cleanup(struct kimage *kimage)
|
||||
{
|
||||
}
|
||||
|
||||
-void
|
||||
-machine_shutdown(void)
|
||||
+void machine_shutdown(void)
|
||||
{
|
||||
if (_machine_kexec_shutdown)
|
||||
_machine_kexec_shutdown();
|
||||
}
|
||||
|
||||
-void
|
||||
-machine_crash_shutdown(struct pt_regs *regs)
|
||||
+void machine_crash_shutdown(struct pt_regs *regs)
|
||||
{
|
||||
if (_machine_crash_shutdown)
|
||||
_machine_crash_shutdown(regs);
|
||||
@@ -66,10 +166,12 @@ machine_kexec(struct kimage *image)
|
||||
unsigned long *ptr;
|
||||
|
||||
reboot_code_buffer =
|
||||
- (unsigned long)page_address(image->control_code_page);
|
||||
+ (unsigned long)page_address(image->control_code_page);
|
||||
+ pr_info("reboot_code_buffer = %p\n", (void *)reboot_code_buffer);
|
||||
|
||||
kexec_start_address =
|
||||
(unsigned long) phys_to_virt(image->start);
|
||||
+ pr_info("kexec_start_address = %p\n", (void *)kexec_start_address);
|
||||
|
||||
if (image->type == KEXEC_TYPE_DEFAULT) {
|
||||
kexec_indirection_page =
|
||||
@@ -77,9 +179,19 @@ machine_kexec(struct kimage *image)
|
||||
} else {
|
||||
kexec_indirection_page = (unsigned long)&image->head;
|
||||
}
|
||||
+ pr_info("kexec_indirection_page = %p\n", (void *)kexec_indirection_page);
|
||||
|
||||
- memcpy((void*)reboot_code_buffer, relocate_new_kernel,
|
||||
- relocate_new_kernel_size);
|
||||
+ pr_info("Where is memcpy: %p\n", memcpy);
|
||||
+ pr_info("kexec_relocate_new_kernel = %p, kexec_relocate_new_kernel_end = %p\n",
|
||||
+ (void *)kexec_relocate_new_kernel, &kexec_relocate_new_kernel_end);
|
||||
+ pr_info("Copy %lu bytes from %p to %p\n", KEXEC_RELOCATE_NEW_KERNEL_SIZE,
|
||||
+ (void *)kexec_relocate_new_kernel, (void *)reboot_code_buffer);
|
||||
+ memcpy((void*)reboot_code_buffer, kexec_relocate_new_kernel,
|
||||
+ KEXEC_RELOCATE_NEW_KERNEL_SIZE);
|
||||
+
|
||||
+ pr_info("Before _print_args().\n");
|
||||
+ machine_kexec_print_args();
|
||||
+ pr_info("Before eval loop.\n");
|
||||
|
||||
/*
|
||||
* The generic kexec code builds a page list with physical
|
||||
@@ -98,15 +210,16 @@ machine_kexec(struct kimage *image)
|
||||
/*
|
||||
* we do not want to be bothered.
|
||||
*/
|
||||
+ pr_info("Before irq_disable.\n");
|
||||
local_irq_disable();
|
||||
|
||||
- printk("Will call new kernel at %08lx\n", image->start);
|
||||
- printk("Bye ...\n");
|
||||
+ pr_info("Will call new kernel at %08lx\n", image->start);
|
||||
+ pr_info("Bye ...\n");
|
||||
__flush_cache_all();
|
||||
#ifdef CONFIG_SMP
|
||||
/* All secondary cpus now may jump to kexec_wait cycle */
|
||||
relocated_kexec_smp_wait = reboot_code_buffer +
|
||||
- (void *)(kexec_smp_wait - relocate_new_kernel);
|
||||
+ (void *)(kexec_smp_wait - kexec_relocate_new_kernel);
|
||||
smp_wmb();
|
||||
atomic_set(&kexec_ready_to_reboot, 1);
|
||||
#endif
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/kernel/machine_kexec.h
|
||||
@@ -0,0 +1,20 @@
|
||||
+#ifndef _MACHINE_KEXEC_H
|
||||
+#define _MACHINE_KEXEC_H
|
||||
+
|
||||
+#ifndef __ASSEMBLY__
|
||||
+extern const unsigned char kexec_relocate_new_kernel[];
|
||||
+extern unsigned long kexec_relocate_new_kernel_end;
|
||||
+extern unsigned long kexec_start_address;
|
||||
+extern unsigned long kexec_indirection_page;
|
||||
+
|
||||
+extern char kexec_argv_buf[];
|
||||
+extern char *kexec_argv[];
|
||||
+
|
||||
+#define KEXEC_RELOCATE_NEW_KERNEL_SIZE ((unsigned long)&kexec_relocate_new_kernel_end - (unsigned long)kexec_relocate_new_kernel)
|
||||
+#endif /* !__ASSEMBLY__ */
|
||||
+
|
||||
+#define KEXEC_COMMAND_LINE_SIZE 256
|
||||
+#define KEXEC_ARGV_SIZE (KEXEC_COMMAND_LINE_SIZE / 16)
|
||||
+#define KEXEC_MAX_ARGC (KEXEC_ARGV_SIZE / sizeof(long))
|
||||
+
|
||||
+#endif
|
||||
--- a/arch/mips/kernel/relocate_kernel.S
|
||||
+++ b/arch/mips/kernel/relocate_kernel.S
|
||||
@@ -12,8 +12,9 @@
|
||||
#include <asm/mipsregs.h>
|
||||
#include <asm/stackframe.h>
|
||||
#include <asm/addrspace.h>
|
||||
+#include "machine_kexec.h"
|
||||
|
||||
-LEAF(relocate_new_kernel)
|
||||
+LEAF(kexec_relocate_new_kernel)
|
||||
PTR_L a0, arg0
|
||||
PTR_L a1, arg1
|
||||
PTR_L a2, arg2
|
||||
@@ -98,7 +99,7 @@ done:
|
||||
#endif
|
||||
/* jump to kexec_start_address */
|
||||
j s1
|
||||
- END(relocate_new_kernel)
|
||||
+ END(kexec_relocate_new_kernel)
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/*
|
||||
@@ -184,9 +185,15 @@ kexec_indirection_page:
|
||||
PTR 0
|
||||
.size kexec_indirection_page, PTRSIZE
|
||||
|
||||
-relocate_new_kernel_end:
|
||||
+kexec_argv_buf:
|
||||
+ EXPORT(kexec_argv_buf)
|
||||
+ .skip KEXEC_COMMAND_LINE_SIZE
|
||||
+ .size kexec_argv_buf, KEXEC_COMMAND_LINE_SIZE
|
||||
+
|
||||
+kexec_argv:
|
||||
+ EXPORT(kexec_argv)
|
||||
+ .skip KEXEC_ARGV_SIZE
|
||||
+ .size kexec_argv, KEXEC_ARGV_SIZE
|
||||
|
||||
-relocate_new_kernel_size:
|
||||
- EXPORT(relocate_new_kernel_size)
|
||||
- PTR relocate_new_kernel_end - relocate_new_kernel
|
||||
- .size relocate_new_kernel_size, PTRSIZE
|
||||
+kexec_relocate_new_kernel_end:
|
||||
+ EXPORT(kexec_relocate_new_kernel_end)
|
@ -1,146 +0,0 @@
|
||||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -12,6 +12,23 @@ menuconfig MTD
|
||||
|
||||
if MTD
|
||||
|
||||
+menu "OpenWrt specific MTD options"
|
||||
+
|
||||
+config MTD_ROOTFS_ROOT_DEV
|
||||
+ bool "Automatically set 'rootfs' partition to be root filesystem"
|
||||
+ default y
|
||||
+
|
||||
+config MTD_SPLIT_FIRMWARE
|
||||
+ bool "Automatically split firmware partition for kernel+rootfs"
|
||||
+ default y
|
||||
+
|
||||
+config MTD_SPLIT_FIRMWARE_NAME
|
||||
+ string "Firmware partition name"
|
||||
+ depends on MTD_SPLIT_FIRMWARE
|
||||
+ default "firmware"
|
||||
+
|
||||
+endmenu
|
||||
+
|
||||
config MTD_TESTS
|
||||
tristate "MTD tests support (DANGEROUS)"
|
||||
depends on m
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -29,11 +29,13 @@
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
+#include <linux/magic.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/kconfig.h>
|
||||
|
||||
#include "mtdcore.h"
|
||||
+#include "mtdsplit/mtdsplit.h"
|
||||
|
||||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
@@ -47,13 +49,14 @@ struct mtd_part {
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
+static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part);
|
||||
+
|
||||
/*
|
||||
* Given a pointer to the MTD object in the mtd_part structure, we can retrieve
|
||||
* the pointer to that structure with this macro.
|
||||
*/
|
||||
#define PART(x) ((struct mtd_part *)(x))
|
||||
|
||||
-
|
||||
/*
|
||||
* MTD methods which simply translate the effective address and pass through
|
||||
* to the _real_ device.
|
||||
@@ -579,8 +582,10 @@ static int mtd_add_partition_attrs(struc
|
||||
return ret;
|
||||
}
|
||||
|
||||
-int mtd_add_partition(struct mtd_info *master, const char *name,
|
||||
- long long offset, long long length)
|
||||
+
|
||||
+static int
|
||||
+__mtd_add_partition(struct mtd_info *master, const char *name,
|
||||
+ long long offset, long long length, bool dup_check)
|
||||
{
|
||||
struct mtd_partition part;
|
||||
struct mtd_part *new;
|
||||
@@ -612,6 +617,7 @@ int mtd_add_partition(struct mtd_info *m
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
add_mtd_device(&new->mtd);
|
||||
+ mtd_partition_split(master, new);
|
||||
|
||||
mtd_add_partition_attrs(new);
|
||||
|
||||
@@ -619,6 +625,12 @@ int mtd_add_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_add_partition);
|
||||
|
||||
+int mtd_add_partition(struct mtd_info *master, const char *name,
|
||||
+ long long offset, long long length)
|
||||
+{
|
||||
+ return __mtd_add_partition(master, name, offset, length, true);
|
||||
+}
|
||||
+
|
||||
int mtd_del_partition(struct mtd_info *master, int partno)
|
||||
{
|
||||
struct mtd_part *slave, *next;
|
||||
@@ -644,6 +656,35 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
+#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
|
||||
+#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
|
||||
+#else
|
||||
+#define SPLIT_FIRMWARE_NAME "unused"
|
||||
+#endif
|
||||
+
|
||||
+static void split_firmware(struct mtd_info *master, struct mtd_part *part)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
|
||||
+ int offset, int size)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part)
|
||||
+{
|
||||
+ static int rootfs_found = 0;
|
||||
+
|
||||
+ if (rootfs_found)
|
||||
+ return;
|
||||
+
|
||||
+ if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) &&
|
||||
+ config_enabled(CONFIG_MTD_SPLIT_FIRMWARE))
|
||||
+ split_firmware(master, part);
|
||||
+
|
||||
+ arch_split_mtd_part(master, part->mtd.name, part->offset,
|
||||
+ part->mtd.size);
|
||||
+}
|
||||
/*
|
||||
* This function, given a master MTD object and a partition table, creates
|
||||
* and registers slave MTD objects which are bound to the master according to
|
||||
@@ -673,6 +714,7 @@ int add_mtd_partitions(struct mtd_info *
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
add_mtd_device(&slave->mtd);
|
||||
+ mtd_partition_split(master, slave);
|
||||
mtd_add_partition_attrs(slave);
|
||||
|
||||
cur_offset = slave->offset + slave->mtd.size;
|
||||
--- a/include/linux/mtd/partitions.h
|
||||
+++ b/include/linux/mtd/partitions.h
|
||||
@@ -84,5 +84,7 @@ int mtd_add_partition(struct mtd_info *m
|
||||
long long offset, long long length);
|
||||
int mtd_del_partition(struct mtd_info *master, int partno);
|
||||
uint64_t mtd_get_device_size(const struct mtd_info *mtd);
|
||||
+extern void __weak arch_split_mtd_part(struct mtd_info *master,
|
||||
+ const char *name, int offset, int size);
|
||||
|
||||
#endif
|
@ -1,113 +0,0 @@
|
||||
From 02cff0ccaa6d364f5c1eeea83f47ac80ccc967d4 Mon Sep 17 00:00:00 2001
|
||||
From: Gabor Juhos <juhosg@openwrt.org>
|
||||
Date: Tue, 3 Sep 2013 18:11:50 +0200
|
||||
Subject: [PATCH] mtd: add support for different partition parser types
|
||||
|
||||
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
||||
---
|
||||
drivers/mtd/mtdpart.c | 56 ++++++++++++++++++++++++++++++++++++++++
|
||||
include/linux/mtd/partitions.h | 11 ++++++++
|
||||
2 files changed, 67 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -745,6 +745,30 @@ static struct mtd_part_parser *get_parti
|
||||
|
||||
#define put_partition_parser(p) do { module_put((p)->owner); } while (0)
|
||||
|
||||
+static struct mtd_part_parser *
|
||||
+get_partition_parser_by_type(enum mtd_parser_type type,
|
||||
+ struct mtd_part_parser *start)
|
||||
+{
|
||||
+ struct mtd_part_parser *p, *ret = NULL;
|
||||
+
|
||||
+ spin_lock(&part_parser_lock);
|
||||
+
|
||||
+ p = list_prepare_entry(start, &part_parsers, list);
|
||||
+ if (start)
|
||||
+ put_partition_parser(start);
|
||||
+
|
||||
+ list_for_each_entry_continue(p, &part_parsers, list) {
|
||||
+ if (p->type == type && try_module_get(p->owner)) {
|
||||
+ ret = p;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ spin_unlock(&part_parser_lock);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
void register_mtd_parser(struct mtd_part_parser *p)
|
||||
{
|
||||
spin_lock(&part_parser_lock);
|
||||
@@ -860,6 +884,38 @@ int parse_mtd_partitions(struct mtd_info
|
||||
return ret;
|
||||
}
|
||||
|
||||
+int parse_mtd_partitions_by_type(struct mtd_info *master,
|
||||
+ enum mtd_parser_type type,
|
||||
+ struct mtd_partition **pparts,
|
||||
+ struct mtd_part_parser_data *data)
|
||||
+{
|
||||
+ struct mtd_part_parser *prev = NULL;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ while (1) {
|
||||
+ struct mtd_part_parser *parser;
|
||||
+
|
||||
+ parser = get_partition_parser_by_type(type, prev);
|
||||
+ if (!parser)
|
||||
+ break;
|
||||
+
|
||||
+ ret = (*parser->parse_fn)(master, pparts, data);
|
||||
+
|
||||
+ if (ret > 0) {
|
||||
+ put_partition_parser(parser);
|
||||
+ printk(KERN_NOTICE
|
||||
+ "%d %s partitions found on MTD device %s\n",
|
||||
+ ret, parser->name, master->name);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ prev = parser;
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(parse_mtd_partitions_by_type);
|
||||
+
|
||||
int mtd_is_partition(const struct mtd_info *mtd)
|
||||
{
|
||||
struct mtd_part *part;
|
||||
--- a/include/linux/mtd/partitions.h
|
||||
+++ b/include/linux/mtd/partitions.h
|
||||
@@ -68,12 +68,17 @@ struct mtd_part_parser_data {
|
||||
* Functions dealing with the various ways of partitioning the space
|
||||
*/
|
||||
|
||||
+enum mtd_parser_type {
|
||||
+ MTD_PARSER_TYPE_DEVICE = 0,
|
||||
+};
|
||||
+
|
||||
struct mtd_part_parser {
|
||||
struct list_head list;
|
||||
struct module *owner;
|
||||
const char *name;
|
||||
int (*parse_fn)(struct mtd_info *, struct mtd_partition **,
|
||||
struct mtd_part_parser_data *);
|
||||
+ enum mtd_parser_type type;
|
||||
};
|
||||
|
||||
extern void register_mtd_parser(struct mtd_part_parser *parser);
|
||||
@@ -87,4 +92,9 @@ uint64_t mtd_get_device_size(const struc
|
||||
extern void __weak arch_split_mtd_part(struct mtd_info *master,
|
||||
const char *name, int offset, int size);
|
||||
|
||||
+int parse_mtd_partitions_by_type(struct mtd_info *master,
|
||||
+ enum mtd_parser_type type,
|
||||
+ struct mtd_partition **pparts,
|
||||
+ struct mtd_part_parser_data *data);
|
||||
+
|
||||
#endif
|
@ -1,72 +0,0 @@
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -656,6 +656,37 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
+static int
|
||||
+run_parsers_by_type(struct mtd_part *slave, enum mtd_parser_type type)
|
||||
+{
|
||||
+ struct mtd_partition *parts;
|
||||
+ int nr_parts;
|
||||
+ int i;
|
||||
+
|
||||
+ nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, &parts,
|
||||
+ NULL);
|
||||
+ if (nr_parts <= 0)
|
||||
+ return nr_parts;
|
||||
+
|
||||
+ if (WARN_ON(!parts))
|
||||
+ return 0;
|
||||
+
|
||||
+ for (i = 0; i < nr_parts; i++) {
|
||||
+ /* adjust partition offsets */
|
||||
+ parts[i].offset += slave->offset;
|
||||
+
|
||||
+ __mtd_add_partition(slave->master,
|
||||
+ parts[i].name,
|
||||
+ parts[i].offset,
|
||||
+ parts[i].size,
|
||||
+ false);
|
||||
+ }
|
||||
+
|
||||
+ kfree(parts);
|
||||
+
|
||||
+ return nr_parts;
|
||||
+}
|
||||
+
|
||||
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
|
||||
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
|
||||
#else
|
||||
@@ -664,6 +695,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
|
||||
{
|
||||
+ run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
|
||||
}
|
||||
|
||||
void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
|
||||
@@ -678,6 +710,12 @@ static void mtd_partition_split(struct m
|
||||
if (rootfs_found)
|
||||
return;
|
||||
|
||||
+ if (!strcmp(part->mtd.name, "rootfs")) {
|
||||
+ run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
|
||||
+
|
||||
+ rootfs_found = 1;
|
||||
+ }
|
||||
+
|
||||
if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) &&
|
||||
config_enabled(CONFIG_MTD_SPLIT_FIRMWARE))
|
||||
split_firmware(master, part);
|
||||
--- a/include/linux/mtd/partitions.h
|
||||
+++ b/include/linux/mtd/partitions.h
|
||||
@@ -70,6 +70,8 @@ struct mtd_part_parser_data {
|
||||
|
||||
enum mtd_parser_type {
|
||||
MTD_PARSER_TYPE_DEVICE = 0,
|
||||
+ MTD_PARSER_TYPE_ROOTFS,
|
||||
+ MTD_PARSER_TYPE_FIRMWARE,
|
||||
};
|
||||
|
||||
struct mtd_part_parser {
|
@ -1,22 +0,0 @@
|
||||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME
|
||||
depends on MTD_SPLIT_FIRMWARE
|
||||
default "firmware"
|
||||
|
||||
+source "drivers/mtd/mtdsplit/Kconfig"
|
||||
+
|
||||
endmenu
|
||||
|
||||
config MTD_TESTS
|
||||
--- a/drivers/mtd/Makefile
|
||||
+++ b/drivers/mtd/Makefile
|
||||
@@ -6,6 +6,8 @@
|
||||
obj-$(CONFIG_MTD) += mtd.o
|
||||
mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
|
||||
|
||||
+obj-$(CONFIG_MTD_SPLIT) += mtdsplit/
|
||||
+
|
||||
obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o
|
||||
obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
|
||||
obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
|
@ -1,101 +0,0 @@
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -453,14 +453,12 @@ static struct mtd_part *allocate_partiti
|
||||
if (slave->offset == MTDPART_OFS_APPEND)
|
||||
slave->offset = cur_offset;
|
||||
if (slave->offset == MTDPART_OFS_NXTBLK) {
|
||||
- slave->offset = cur_offset;
|
||||
- if (mtd_mod_by_eb(cur_offset, master) != 0) {
|
||||
- /* Round up to next erasesize */
|
||||
- slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize;
|
||||
+ /* Round up to next erasesize */
|
||||
+ slave->offset = mtd_roundup_to_eb(cur_offset, master);
|
||||
+ if (slave->offset != cur_offset)
|
||||
printk(KERN_NOTICE "Moving partition %d: "
|
||||
"0x%012llx -> 0x%012llx\n", partno,
|
||||
(unsigned long long)cur_offset, (unsigned long long)slave->offset);
|
||||
- }
|
||||
}
|
||||
if (slave->offset == MTDPART_OFS_RETAIN) {
|
||||
slave->offset = cur_offset;
|
||||
@@ -687,6 +685,17 @@ run_parsers_by_type(struct mtd_part *sla
|
||||
return nr_parts;
|
||||
}
|
||||
|
||||
+static inline unsigned long
|
||||
+mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
|
||||
+{
|
||||
+ unsigned long mask = mtd->erasesize - 1;
|
||||
+
|
||||
+ len += offset & mask;
|
||||
+ len = (len + mask) & ~mask;
|
||||
+ len -= offset & mask;
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
|
||||
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
|
||||
#else
|
||||
@@ -971,6 +980,24 @@ int mtd_is_partition(const struct mtd_in
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_is_partition);
|
||||
|
||||
+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd)
|
||||
+{
|
||||
+ if (!mtd_is_partition(mtd))
|
||||
+ return (struct mtd_info *)mtd;
|
||||
+
|
||||
+ return PART(mtd)->master;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(mtdpart_get_master);
|
||||
+
|
||||
+uint64_t mtdpart_get_offset(const struct mtd_info *mtd)
|
||||
+{
|
||||
+ if (!mtd_is_partition(mtd))
|
||||
+ return 0;
|
||||
+
|
||||
+ return PART(mtd)->offset;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(mtdpart_get_offset);
|
||||
+
|
||||
/* Returns the size of the entire flash chip */
|
||||
uint64_t mtd_get_device_size(const struct mtd_info *mtd)
|
||||
{
|
||||
--- a/include/linux/mtd/partitions.h
|
||||
+++ b/include/linux/mtd/partitions.h
|
||||
@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in
|
||||
int mtd_add_partition(struct mtd_info *master, const char *name,
|
||||
long long offset, long long length);
|
||||
int mtd_del_partition(struct mtd_info *master, int partno);
|
||||
+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd);
|
||||
+uint64_t mtdpart_get_offset(const struct mtd_info *mtd);
|
||||
uint64_t mtd_get_device_size(const struct mtd_info *mtd);
|
||||
extern void __weak arch_split_mtd_part(struct mtd_info *master,
|
||||
const char *name, int offset, int size);
|
||||
--- a/include/linux/mtd/mtd.h
|
||||
+++ b/include/linux/mtd/mtd.h
|
||||
@@ -334,6 +334,24 @@ static inline uint32_t mtd_mod_by_eb(uin
|
||||
return do_div(sz, mtd->erasesize);
|
||||
}
|
||||
|
||||
+static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd)
|
||||
+{
|
||||
+ if (mtd_mod_by_eb(sz, mtd) == 0)
|
||||
+ return sz;
|
||||
+
|
||||
+ /* Round up to next erase block */
|
||||
+ return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize;
|
||||
+}
|
||||
+
|
||||
+static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd)
|
||||
+{
|
||||
+ if (mtd_mod_by_eb(sz, mtd) == 0)
|
||||
+ return sz;
|
||||
+
|
||||
+ /* Round down to the start of the current erase block */
|
||||
+ return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize;
|
||||
+}
|
||||
+
|
||||
static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
|
||||
{
|
||||
if (mtd->writesize_shift)
|
@ -1,70 +0,0 @@
|
||||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME
|
||||
depends on MTD_SPLIT_FIRMWARE
|
||||
default "firmware"
|
||||
|
||||
+config MTD_UIMAGE_SPLIT
|
||||
+ bool "Enable split support for firmware partitions containing a uImage"
|
||||
+ depends on MTD_SPLIT_FIRMWARE
|
||||
+ default y
|
||||
+
|
||||
source "drivers/mtd/mtdsplit/Kconfig"
|
||||
|
||||
endmenu
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -696,6 +696,37 @@ mtd_pad_erasesize(struct mtd_info *mtd,
|
||||
return len;
|
||||
}
|
||||
|
||||
+#define UBOOT_MAGIC 0x27051956
|
||||
+
|
||||
+static void split_uimage(struct mtd_info *master, struct mtd_part *part)
|
||||
+{
|
||||
+ struct {
|
||||
+ __be32 magic;
|
||||
+ __be32 pad[2];
|
||||
+ __be32 size;
|
||||
+ } hdr;
|
||||
+ size_t len;
|
||||
+
|
||||
+ if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
|
||||
+ return;
|
||||
+
|
||||
+ if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC))
|
||||
+ return;
|
||||
+
|
||||
+ len = be32_to_cpu(hdr.size) + 0x40;
|
||||
+ len = mtd_pad_erasesize(master, part->offset, len);
|
||||
+ if (len + master->erasesize > part->mtd.size)
|
||||
+ return;
|
||||
+
|
||||
+ if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW))
|
||||
+ pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n");
|
||||
+ else
|
||||
+ pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n");
|
||||
+
|
||||
+ __mtd_add_partition(master, "rootfs", part->offset + len,
|
||||
+ part->mtd.size - len, false);
|
||||
+}
|
||||
+
|
||||
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
|
||||
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
|
||||
#else
|
||||
@@ -704,7 +735,14 @@ mtd_pad_erasesize(struct mtd_info *mtd,
|
||||
|
||||
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
|
||||
{
|
||||
- run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
|
||||
+ if (ret > 0)
|
||||
+ return;
|
||||
+
|
||||
+ if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
|
||||
+ split_uimage(master, part);
|
||||
}
|
||||
|
||||
void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
|
@ -1,18 +0,0 @@
|
||||
--- a/include/linux/mtd/partitions.h
|
||||
+++ b/include/linux/mtd/partitions.h
|
||||
@@ -35,6 +35,7 @@
|
||||
* Note: writeable partitions require their size and offset be
|
||||
* erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK).
|
||||
*/
|
||||
+struct mtd_info;
|
||||
|
||||
struct mtd_partition {
|
||||
const char *name; /* identifier string */
|
||||
@@ -50,7 +51,6 @@ struct mtd_partition {
|
||||
#define MTDPART_SIZ_FULL (0)
|
||||
|
||||
|
||||
-struct mtd_info;
|
||||
struct device_node;
|
||||
|
||||
/**
|
@ -1,142 +0,0 @@
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "mtdcore.h"
|
||||
#include "mtdsplit/mtdsplit.h"
|
||||
|
||||
+#define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an erase block */
|
||||
+
|
||||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
static DEFINE_MUTEX(mtd_partitions_mutex);
|
||||
@@ -235,13 +237,61 @@ static int part_erase(struct mtd_info *m
|
||||
struct mtd_part *part = PART(mtd);
|
||||
int ret;
|
||||
|
||||
+
|
||||
+ instr->partial_start = false;
|
||||
+ if (mtd->flags & MTD_ERASE_PARTIAL) {
|
||||
+ size_t readlen = 0;
|
||||
+ u64 mtd_ofs;
|
||||
+
|
||||
+ instr->erase_buf = kmalloc(part->master->erasesize, GFP_ATOMIC);
|
||||
+ if (!instr->erase_buf)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ mtd_ofs = part->offset + instr->addr;
|
||||
+ instr->erase_buf_ofs = do_div(mtd_ofs, part->master->erasesize);
|
||||
+
|
||||
+ if (instr->erase_buf_ofs > 0) {
|
||||
+ instr->addr -= instr->erase_buf_ofs;
|
||||
+ ret = mtd_read(part->master,
|
||||
+ instr->addr + part->offset,
|
||||
+ part->master->erasesize,
|
||||
+ &readlen, instr->erase_buf);
|
||||
+
|
||||
+ instr->len += instr->erase_buf_ofs;
|
||||
+ instr->partial_start = true;
|
||||
+ } else {
|
||||
+ mtd_ofs = part->offset + part->mtd.size;
|
||||
+ instr->erase_buf_ofs = part->master->erasesize -
|
||||
+ do_div(mtd_ofs, part->master->erasesize);
|
||||
+
|
||||
+ if (instr->erase_buf_ofs > 0) {
|
||||
+ instr->len += instr->erase_buf_ofs;
|
||||
+ ret = mtd_read(part->master,
|
||||
+ part->offset + instr->addr +
|
||||
+ instr->len - part->master->erasesize,
|
||||
+ part->master->erasesize, &readlen,
|
||||
+ instr->erase_buf);
|
||||
+ } else {
|
||||
+ ret = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ if (ret < 0) {
|
||||
+ kfree(instr->erase_buf);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
instr->addr += part->offset;
|
||||
ret = part->master->_erase(part->master, instr);
|
||||
if (ret) {
|
||||
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
|
||||
instr->fail_addr -= part->offset;
|
||||
instr->addr -= part->offset;
|
||||
+ if (mtd->flags & MTD_ERASE_PARTIAL)
|
||||
+ kfree(instr->erase_buf);
|
||||
}
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -249,7 +299,25 @@ void mtd_erase_callback(struct erase_inf
|
||||
{
|
||||
if (instr->mtd->_erase == part_erase) {
|
||||
struct mtd_part *part = PART(instr->mtd);
|
||||
+ size_t wrlen = 0;
|
||||
|
||||
+ if (instr->mtd->flags & MTD_ERASE_PARTIAL) {
|
||||
+ if (instr->partial_start) {
|
||||
+ part->master->_write(part->master,
|
||||
+ instr->addr, instr->erase_buf_ofs,
|
||||
+ &wrlen, instr->erase_buf);
|
||||
+ instr->addr += instr->erase_buf_ofs;
|
||||
+ } else {
|
||||
+ instr->len -= instr->erase_buf_ofs;
|
||||
+ part->master->_write(part->master,
|
||||
+ instr->addr + instr->len,
|
||||
+ instr->erase_buf_ofs, &wrlen,
|
||||
+ instr->erase_buf +
|
||||
+ part->master->erasesize -
|
||||
+ instr->erase_buf_ofs);
|
||||
+ }
|
||||
+ kfree(instr->erase_buf);
|
||||
+ }
|
||||
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
|
||||
instr->fail_addr -= part->offset;
|
||||
instr->addr -= part->offset;
|
||||
@@ -522,17 +590,20 @@ static struct mtd_part *allocate_partiti
|
||||
if ((slave->mtd.flags & MTD_WRITEABLE) &&
|
||||
mtd_mod_by_eb(slave->offset, &slave->mtd)) {
|
||||
/* Doesn't start on a boundary of major erase size */
|
||||
- /* FIXME: Let it be writable if it is on a boundary of
|
||||
- * _minor_ erase size though */
|
||||
- slave->mtd.flags &= ~MTD_WRITEABLE;
|
||||
- printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
|
||||
- part->name);
|
||||
+ slave->mtd.flags |= MTD_ERASE_PARTIAL;
|
||||
+ if (((u32) slave->mtd.size) > master->erasesize)
|
||||
+ slave->mtd.flags &= ~MTD_WRITEABLE;
|
||||
+ else
|
||||
+ slave->mtd.erasesize = slave->mtd.size;
|
||||
}
|
||||
if ((slave->mtd.flags & MTD_WRITEABLE) &&
|
||||
- mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) {
|
||||
- slave->mtd.flags &= ~MTD_WRITEABLE;
|
||||
- printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
|
||||
- part->name);
|
||||
+ mtd_mod_by_eb(slave->offset + slave->mtd.size, &slave->mtd)) {
|
||||
+ slave->mtd.flags |= MTD_ERASE_PARTIAL;
|
||||
+
|
||||
+ if ((u32) slave->mtd.size > master->erasesize)
|
||||
+ slave->mtd.flags &= ~MTD_WRITEABLE;
|
||||
+ else
|
||||
+ slave->mtd.erasesize = slave->mtd.size;
|
||||
}
|
||||
|
||||
slave->mtd.ecclayout = master->ecclayout;
|
||||
--- a/include/linux/mtd/mtd.h
|
||||
+++ b/include/linux/mtd/mtd.h
|
||||
@@ -55,6 +55,10 @@ struct erase_info {
|
||||
u_long priv;
|
||||
u_char state;
|
||||
struct erase_info *next;
|
||||
+
|
||||
+ u8 *erase_buf;
|
||||
+ u32 erase_buf_ofs;
|
||||
+ bool partial_start;
|
||||
};
|
||||
|
||||
struct mtd_erase_region_info {
|
@ -1,18 +0,0 @@
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -336,7 +336,14 @@ static int part_lock(struct mtd_info *mt
|
||||
static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
||||
{
|
||||
struct mtd_part *part = PART(mtd);
|
||||
- return part->master->_unlock(part->master, ofs + part->offset, len);
|
||||
+
|
||||
+ ofs += part->offset;
|
||||
+ if (mtd->flags & MTD_ERASE_PARTIAL) {
|
||||
+ /* round up len to next erasesize and round down offset to prev block */
|
||||
+ len = (mtd_div_by_eb(len, part->master) + 1) * part->master->erasesize;
|
||||
+ ofs &= ~(part->master->erasesize - 1);
|
||||
+ }
|
||||
+ return part->master->_unlock(part->master, ofs, len);
|
||||
}
|
||||
|
||||
static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
@ -1,30 +0,0 @@
|
||||
--- a/drivers/mtd/redboot.c
|
||||
+++ b/drivers/mtd/redboot.c
|
||||
@@ -265,14 +265,21 @@ static int parse_redboot_partitions(stru
|
||||
#endif
|
||||
names += strlen(names)+1;
|
||||
|
||||
-#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
|
||||
if(fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) {
|
||||
- i++;
|
||||
- parts[i].offset = parts[i-1].size + parts[i-1].offset;
|
||||
- parts[i].size = fl->next->img->flash_base - parts[i].offset;
|
||||
- parts[i].name = nullname;
|
||||
- }
|
||||
+ if (!strcmp(parts[i].name, "rootfs")) {
|
||||
+ parts[i].size = fl->next->img->flash_base;
|
||||
+ parts[i].size &= ~(master->erasesize - 1);
|
||||
+ parts[i].size -= parts[i].offset;
|
||||
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
|
||||
+ nrparts--;
|
||||
+ } else {
|
||||
+ i++;
|
||||
+ parts[i].offset = parts[i-1].size + parts[i-1].offset;
|
||||
+ parts[i].size = fl->next->img->flash_base - parts[i].offset;
|
||||
+ parts[i].name = nullname;
|
||||
#endif
|
||||
+ }
|
||||
+ }
|
||||
tmp_fl = fl;
|
||||
fl = fl->next;
|
||||
kfree(tmp_fl);
|
@ -1,35 +0,0 @@
|
||||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -179,6 +179,22 @@ config MTD_BCM47XX_PARTS
|
||||
This provides partitions parser for devices based on BCM47xx
|
||||
boards.
|
||||
|
||||
+config MTD_MYLOADER_PARTS
|
||||
+ tristate "MyLoader partition parsing"
|
||||
+ depends on ADM5120 || ATH25 || ATH79
|
||||
+ ---help---
|
||||
+ MyLoader is a bootloader which allows the user to define partitions
|
||||
+ in flash devices, by putting a table in the second erase block
|
||||
+ on the device, similar to a partition table. This table gives the
|
||||
+ offsets and lengths of the user defined partitions.
|
||||
+
|
||||
+ If you need code which can detect and parse these tables, and
|
||||
+ register MTD 'partitions' corresponding to each image detected,
|
||||
+ enable this option.
|
||||
+
|
||||
+ You will still need the parsing functions to be called by the driver
|
||||
+ for your particular device. It won't happen automatically.
|
||||
+
|
||||
comment "User Modules And Translation Layers"
|
||||
|
||||
#
|
||||
--- a/drivers/mtd/Makefile
|
||||
+++ b/drivers/mtd/Makefile
|
||||
@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
|
||||
obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o
|
||||
obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o
|
||||
obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o
|
||||
+obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o
|
||||
|
||||
# 'Users' - code which presents functionality to userspace.
|
||||
obj-$(CONFIG_MTD_BLKDEVS) += mtd_blkdevs.o
|
@ -1,100 +0,0 @@
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
|
||||
Date: Sat, 2 Jan 2016 01:04:52 +0100
|
||||
Subject: [PATCH] mtd: bcm47xxpart: check for bad blocks when calculating
|
||||
offsets
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
|
||||
---
|
||||
drivers/mtd/bcm47xxpart.c | 50 +++++++++++++++++++++++++++++++++++++----------
|
||||
1 file changed, 40 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/mtd/bcm47xxpart.c
|
||||
+++ b/drivers/mtd/bcm47xxpart.c
|
||||
@@ -61,6 +61,34 @@ static void bcm47xxpart_add_part(struct
|
||||
part->mask_flags = mask_flags;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Calculate real end offset (address) for a given amount of data. It checks
|
||||
+ * all blocks skipping bad ones.
|
||||
+ */
|
||||
+static size_t bcm47xxpart_real_offset(struct mtd_info *master, size_t offset,
|
||||
+ size_t bytes)
|
||||
+{
|
||||
+ size_t real_offset = offset;
|
||||
+
|
||||
+ if (mtd_block_isbad(master, real_offset))
|
||||
+ pr_warn("Base offset shouldn't be at bad block");
|
||||
+
|
||||
+ while (bytes >= master->erasesize) {
|
||||
+ bytes -= master->erasesize;
|
||||
+ real_offset += master->erasesize;
|
||||
+ while (mtd_block_isbad(master, real_offset)) {
|
||||
+ real_offset += master->erasesize;
|
||||
+
|
||||
+ if (real_offset >= master->size)
|
||||
+ return real_offset - master->erasesize;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ real_offset += bytes;
|
||||
+
|
||||
+ return real_offset;
|
||||
+}
|
||||
+
|
||||
static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master,
|
||||
size_t offset)
|
||||
{
|
||||
@@ -182,6 +210,8 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
|
||||
/* TRX */
|
||||
if (buf[0x000 / 4] == TRX_MAGIC) {
|
||||
+ uint32_t tmp;
|
||||
+
|
||||
if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
|
||||
pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
|
||||
break;
|
||||
@@ -196,18 +226,18 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
i = 0;
|
||||
/* We have LZMA loader if offset[2] points to sth */
|
||||
if (trx->offset[2]) {
|
||||
+ tmp = bcm47xxpart_real_offset(master, offset,
|
||||
+ trx->offset[i]);
|
||||
bcm47xxpart_add_part(&parts[curr_part++],
|
||||
- "loader",
|
||||
- offset + trx->offset[i],
|
||||
- 0);
|
||||
+ "loader", tmp, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (trx->offset[i]) {
|
||||
+ tmp = bcm47xxpart_real_offset(master, offset,
|
||||
+ trx->offset[i]);
|
||||
bcm47xxpart_add_part(&parts[curr_part++],
|
||||
- "linux",
|
||||
- offset + trx->offset[i],
|
||||
- 0);
|
||||
+ "linux", tmp, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -219,11 +249,11 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
if (trx->offset[i]) {
|
||||
const char *name;
|
||||
|
||||
- name = bcm47xxpart_trx_data_part_name(master, offset + trx->offset[i]);
|
||||
+ tmp = bcm47xxpart_real_offset(master, offset,
|
||||
+ trx->offset[i]);
|
||||
+ name = bcm47xxpart_trx_data_part_name(master, tmp);
|
||||
bcm47xxpart_add_part(&parts[curr_part++],
|
||||
- name,
|
||||
- offset + trx->offset[i],
|
||||
- 0);
|
||||
+ name, tmp, 0);
|
||||
i++;
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
From fd54aa583296f9adfb1f519affbc10ba521eb809 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
|
||||
Date: Wed, 28 Jan 2015 22:14:41 +0100
|
||||
Subject: [PATCH] mtd: bcm47xxpart: detect T_Meter partition
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
It can be found on many Netgear devices. It consists of many 0x30 blocks
|
||||
starting with 4D 54.
|
||||
|
||||
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
|
||||
---
|
||||
drivers/mtd/bcm47xxpart.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/bcm47xxpart.c
|
||||
+++ b/drivers/mtd/bcm47xxpart.c
|
||||
@@ -38,6 +38,7 @@
|
||||
#define NVRAM_HEADER 0x48534C46 /* FLSH */
|
||||
#define POT_MAGIC1 0x54544f50 /* POTT */
|
||||
#define POT_MAGIC2 0x504f /* OP */
|
||||
+#define T_METER_MAGIC 0x4D540000 /* MT */
|
||||
#define ML_MAGIC1 0x39685a42
|
||||
#define ML_MAGIC2 0x26594131
|
||||
#define TRX_MAGIC 0x30524448
|
||||
@@ -207,6 +208,15 @@ static int bcm47xxpart_parse(struct mtd_
|
||||
MTD_WRITEABLE);
|
||||
continue;
|
||||
}
|
||||
+
|
||||
+ /* T_Meter */
|
||||
+ if ((le32_to_cpu(buf[0x000 / 4]) & 0xFFFF0000) == T_METER_MAGIC &&
|
||||
+ (le32_to_cpu(buf[0x030 / 4]) & 0xFFFF0000) == T_METER_MAGIC &&
|
||||
+ (le32_to_cpu(buf[0x060 / 4]) & 0xFFFF0000) == T_METER_MAGIC) {
|
||||
+ bcm47xxpart_add_part(&parts[curr_part++], "T_Meter", offset,
|
||||
+ MTD_WRITEABLE);
|
||||
+ continue;
|
||||
+ }
|
||||
|
||||
/* TRX */
|
||||
if (buf[0x000 / 4] == TRX_MAGIC) {
|
@ -1,108 +0,0 @@
|
||||
--- a/drivers/mtd/devices/block2mtd.c
|
||||
+++ b/drivers/mtd/devices/block2mtd.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <linux/list.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
+#include <linux/mtd/partitions.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/mount.h>
|
||||
#include <linux/slab.h>
|
||||
@@ -218,7 +219,7 @@ static void block2mtd_free_device(struct
|
||||
|
||||
|
||||
static struct block2mtd_dev *add_device(char *devname, int erase_size,
|
||||
- int timeout)
|
||||
+ const char *mtdname, int timeout)
|
||||
{
|
||||
#ifndef MODULE
|
||||
int i;
|
||||
@@ -226,6 +227,7 @@ static struct block2mtd_dev *add_device(
|
||||
const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
|
||||
struct block_device *bdev = ERR_PTR(-ENODEV);
|
||||
struct block2mtd_dev *dev;
|
||||
+ struct mtd_partition *part;
|
||||
char *name;
|
||||
|
||||
if (!devname)
|
||||
@@ -282,13 +284,16 @@ static struct block2mtd_dev *add_device(
|
||||
|
||||
/* Setup the MTD structure */
|
||||
/* make the name contain the block device in */
|
||||
- name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
|
||||
+ if (!mtdname)
|
||||
+ mtdname = devname;
|
||||
+ name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL);
|
||||
if (!name)
|
||||
goto err_destroy_mutex;
|
||||
|
||||
+ strcpy(name, mtdname);
|
||||
dev->mtd.name = name;
|
||||
|
||||
- dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
|
||||
+ dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK & ~(erase_size - 1);
|
||||
dev->mtd.erasesize = erase_size;
|
||||
dev->mtd.writesize = 1;
|
||||
dev->mtd.writebufsize = PAGE_SIZE;
|
||||
@@ -301,7 +306,11 @@ static struct block2mtd_dev *add_device(
|
||||
dev->mtd.priv = dev;
|
||||
dev->mtd.owner = THIS_MODULE;
|
||||
|
||||
- if (mtd_device_register(&dev->mtd, NULL, 0)) {
|
||||
+ part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
|
||||
+ part->name = name;
|
||||
+ part->offset = 0;
|
||||
+ part->size = dev->mtd.size;
|
||||
+ if (mtd_device_register(&dev->mtd, part, 1)) {
|
||||
/* Device didn't get added, so free the entry */
|
||||
goto err_destroy_mutex;
|
||||
}
|
||||
@@ -309,8 +318,7 @@ static struct block2mtd_dev *add_device(
|
||||
list_add(&dev->list, &blkmtd_device_list);
|
||||
pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n",
|
||||
dev->mtd.index,
|
||||
- dev->mtd.name + strlen("block2mtd: "),
|
||||
- dev->mtd.erasesize >> 10, dev->mtd.erasesize);
|
||||
+ mtdname, dev->mtd.erasesize >> 10, dev->mtd.erasesize);
|
||||
return dev;
|
||||
|
||||
err_destroy_mutex:
|
||||
@@ -383,7 +391,7 @@ static int block2mtd_setup2(const char *
|
||||
/* 80 for device, 12 for erase size, 80 for name, 8 for timeout */
|
||||
char buf[80 + 12 + 80 + 8];
|
||||
char *str = buf;
|
||||
- char *token[2];
|
||||
+ char *token[3];
|
||||
char *name;
|
||||
size_t erase_size = PAGE_SIZE;
|
||||
unsigned long timeout = MTD_DEFAULT_TIMEOUT;
|
||||
@@ -397,7 +405,7 @@ static int block2mtd_setup2(const char *
|
||||
strcpy(str, val);
|
||||
kill_final_newline(str);
|
||||
|
||||
- for (i = 0; i < 2; i++)
|
||||
+ for (i = 0; i < 3; i++)
|
||||
token[i] = strsep(&str, ",");
|
||||
|
||||
if (str) {
|
||||
@@ -423,8 +431,10 @@ static int block2mtd_setup2(const char *
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+ if (token[2] && (strlen(token[2]) + 1 > 80))
|
||||
+ pr_err("mtd device name too long\n");
|
||||
|
||||
- add_device(name, erase_size, timeout);
|
||||
+ add_device(name, erase_size, token[2], timeout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -458,7 +468,7 @@ static int block2mtd_setup(const char *v
|
||||
|
||||
|
||||
module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
|
||||
-MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
|
||||
+MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\"");
|
||||
|
||||
static int __init block2mtd_init(void)
|
||||
{
|
@ -1,39 +0,0 @@
|
||||
--- a/drivers/mtd/devices/block2mtd.c
|
||||
+++ b/drivers/mtd/devices/block2mtd.c
|
||||
@@ -391,7 +391,7 @@ static int block2mtd_setup2(const char *
|
||||
/* 80 for device, 12 for erase size, 80 for name, 8 for timeout */
|
||||
char buf[80 + 12 + 80 + 8];
|
||||
char *str = buf;
|
||||
- char *token[3];
|
||||
+ char *token[4];
|
||||
char *name;
|
||||
size_t erase_size = PAGE_SIZE;
|
||||
unsigned long timeout = MTD_DEFAULT_TIMEOUT;
|
||||
@@ -405,7 +405,7 @@ static int block2mtd_setup2(const char *
|
||||
strcpy(str, val);
|
||||
kill_final_newline(str);
|
||||
|
||||
- for (i = 0; i < 3; i++)
|
||||
+ for (i = 0; i < 4; i++)
|
||||
token[i] = strsep(&str, ",");
|
||||
|
||||
if (str) {
|
||||
@@ -434,6 +434,9 @@ static int block2mtd_setup2(const char *
|
||||
if (token[2] && (strlen(token[2]) + 1 > 80))
|
||||
pr_err("mtd device name too long\n");
|
||||
|
||||
+ if (token[3] && kstrtoul(token[3], 0, &timeout))
|
||||
+ pr_err("invalid timeout\n");
|
||||
+
|
||||
add_device(name, erase_size, token[2], timeout);
|
||||
|
||||
return 0;
|
||||
@@ -468,7 +471,7 @@ static int block2mtd_setup(const char *v
|
||||
|
||||
|
||||
module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
|
||||
-MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\"");
|
||||
+MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>[,<timeout>]]]\"");
|
||||
|
||||
static int __init block2mtd_init(void)
|
||||
{
|
@ -1,37 +0,0 @@
|
||||
---
|
||||
drivers/mtd/nand/plat_nand.c | 13 ++++++++++++-
|
||||
include/linux/mtd/nand.h | 1 +
|
||||
2 files changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/include/linux/mtd/nand.h
|
||||
+++ b/include/linux/mtd/nand.h
|
||||
@@ -865,6 +865,7 @@ struct platform_nand_chip {
|
||||
unsigned int options;
|
||||
unsigned int bbt_options;
|
||||
const char **part_probe_types;
|
||||
+ int (*chip_fixup)(struct mtd_info *mtd);
|
||||
};
|
||||
|
||||
/* Keep gcc happy */
|
||||
--- a/drivers/mtd/nand/plat_nand.c
|
||||
+++ b/drivers/mtd/nand/plat_nand.c
|
||||
@@ -90,7 +90,18 @@ static int plat_nand_probe(struct platfo
|
||||
}
|
||||
|
||||
/* Scan to find existence of the device */
|
||||
- if (nand_scan(&data->mtd, pdata->chip.nr_chips)) {
|
||||
+ if (nand_scan_ident(&data->mtd, pdata->chip.nr_chips, NULL)) {
|
||||
+ err = -ENXIO;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (pdata->chip.chip_fixup) {
|
||||
+ err = pdata->chip.chip_fixup(&data->mtd);
|
||||
+ if (err)
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (nand_scan_tail(&data->mtd)) {
|
||||
err = -ENXIO;
|
||||
goto out;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
--- a/drivers/mtd/nand/nand_ecc.c
|
||||
+++ b/drivers/mtd/nand/nand_ecc.c
|
||||
@@ -507,7 +507,7 @@ int __nand_correct_data(unsigned char *b
|
||||
return 1; /* error in ECC data; no action needed */
|
||||
|
||||
pr_err("%s: uncorrectable ECC error\n", __func__);
|
||||
- return -1;
|
||||
+ return -EBADMSG;
|
||||
}
|
||||
EXPORT_SYMBOL(__nand_correct_data);
|
||||
|
@ -1,11 +0,0 @@
|
||||
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||
@@ -809,7 +809,7 @@ static int get_chip(struct map_info *map
|
||||
return 0;
|
||||
|
||||
case FL_ERASING:
|
||||
- if (!cfip || !(cfip->EraseSuspend & (0x1|0x2)) ||
|
||||
+ if (1 /* no suspend */ || !cfip || !(cfip->EraseSuspend & (0x1|0x2)) ||
|
||||
!(mode == FL_READY || mode == FL_POINT ||
|
||||
(mode == FL_WRITING && (cfip->EraseSuspend & 0x2))))
|
||||
goto sleep;
|
@ -1,18 +0,0 @@
|
||||
From: George Kashperko <george@znau.edu.ua>
|
||||
|
||||
Issue map read after Write Buffer Load command to ensure chip is ready
|
||||
to receive data.
|
||||
Signed-off-by: George Kashperko <george@znau.edu.ua>
|
||||
---
|
||||
drivers/mtd/chips/cfi_cmdset_0002.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||
@@ -1830,6 +1830,7 @@ static int __xipram do_write_buffer(stru
|
||||
|
||||
/* Write Buffer Load */
|
||||
map_write(map, CMD(0x25), cmd_adr);
|
||||
+ (void) map_read(map, cmd_adr);
|
||||
|
||||
chip->state = FL_WRITING_TO_BUFFER;
|
||||
|
@ -1,14 +0,0 @@
|
||||
Disable software protection bits for Macronix flashes.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
--- a/drivers/mtd/spi-nor/spi-nor.c
|
||||
+++ b/drivers/mtd/spi-nor/spi-nor.c
|
||||
@@ -1200,6 +1200,7 @@ int spi_nor_scan(struct spi_nor *nor, co
|
||||
|
||||
if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
|
||||
JEDEC_MFR(info) == SNOR_MFR_INTEL ||
|
||||
+ JEDEC_MFR(info) == SNOR_MFR_MACRONIX ||
|
||||
JEDEC_MFR(info) == SNOR_MFR_SST) {
|
||||
write_enable(nor);
|
||||
write_sr(nor, 0);
|
@ -1,26 +0,0 @@
|
||||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/kconfig.h>
|
||||
+#include <linux/root_dev.h>
|
||||
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
@@ -448,6 +449,15 @@ int add_mtd_device(struct mtd_info *mtd)
|
||||
of this try_ nonsense, and no bitching about it
|
||||
either. :) */
|
||||
__module_get(THIS_MODULE);
|
||||
+
|
||||
+ if (!strcmp(mtd->name, "rootfs") &&
|
||||
+ config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
|
||||
+ ROOT_DEV == 0) {
|
||||
+ pr_notice("mtd: device %d (%s) set to be root filesystem\n",
|
||||
+ mtd->index, mtd->name);
|
||||
+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
|
||||
fail_added:
|
@ -1,76 +0,0 @@
|
||||
From 8a52e4100d7c3a4a1dfddfa02b8864a9b0068c13 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Sat, 17 May 2014 03:36:18 +0200
|
||||
Subject: [PATCH 1/5] ubi: auto-attach mtd device named "ubi" or "data" on boot
|
||||
To: openwrt-devel@lists.openwrt.org
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/mtd/ubi/build.c | 36 ++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 36 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/ubi/build.c
|
||||
+++ b/drivers/mtd/ubi/build.c
|
||||
@@ -1221,6 +1221,49 @@ static struct mtd_info * __init open_mtd
|
||||
return mtd;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * This function tries attaching mtd partitions named either "ubi" or "data"
|
||||
+ * during boot.
|
||||
+ */
|
||||
+static void __init ubi_auto_attach(void)
|
||||
+{
|
||||
+ int err;
|
||||
+ struct mtd_info *mtd;
|
||||
+
|
||||
+ /* try attaching mtd device named "ubi" or "data" */
|
||||
+ mtd = open_mtd_device("ubi");
|
||||
+ if (IS_ERR(mtd))
|
||||
+ mtd = open_mtd_device("data");
|
||||
+
|
||||
+ if (!IS_ERR(mtd)) {
|
||||
+ size_t len;
|
||||
+ char magic[4];
|
||||
+
|
||||
+ /* check for a valid ubi magic */
|
||||
+ err = mtd_read(mtd, 0, 4, &len, (void *) magic);
|
||||
+ if (!err && len == 4 && strncmp(magic, "UBI#", 4)) {
|
||||
+ pr_err("UBI error: no valid UBI magic found inside mtd%d", mtd->index);
|
||||
+ put_mtd_device(mtd);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* auto-add only media types where UBI makes sense */
|
||||
+ if (mtd->type == MTD_NANDFLASH ||
|
||||
+ mtd->type == MTD_NORFLASH ||
|
||||
+ mtd->type == MTD_DATAFLASH ||
|
||||
+ mtd->type == MTD_MLCNANDFLASH) {
|
||||
+ mutex_lock(&ubi_devices_mutex);
|
||||
+ pr_notice("UBI: auto-attach mtd%d", mtd->index);
|
||||
+ err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 0, 0);
|
||||
+ mutex_unlock(&ubi_devices_mutex);
|
||||
+ if (err < 0) {
|
||||
+ pr_err("UBI error: cannot attach mtd%d", mtd->index);
|
||||
+ put_mtd_device(mtd);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int __init ubi_init(void)
|
||||
{
|
||||
int err, i, k;
|
||||
@@ -1313,6 +1356,12 @@ static int __init ubi_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
+ /* auto-attach mtd devices only if built-in to the kernel and no ubi.mtd
|
||||
+ * parameter was given */
|
||||
+ if (config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
|
||||
+ !ubi_is_module() && !mtd_devs)
|
||||
+ ubi_auto_attach();
|
||||
+
|
||||
err = ubiblock_init();
|
||||
if (err) {
|
||||
pr_err("UBI error: block: cannot initialize, error %d", err);
|
@ -1,69 +0,0 @@
|
||||
From 0f3966579815f889bb2fcb4846152c35f65e79c4 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Thu, 15 May 2014 21:06:33 +0200
|
||||
Subject: [PATCH 2/5] ubi: auto-create ubiblock device for rootfs
|
||||
To: openwrt-devel@lists.openwrt.org
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/mtd/ubi/block.c | 42 ++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 42 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/ubi/block.c
|
||||
+++ b/drivers/mtd/ubi/block.c
|
||||
@@ -616,6 +616,44 @@ static void __init ubiblock_create_from_
|
||||
}
|
||||
}
|
||||
|
||||
+#define UBIFS_NODE_MAGIC 0x06101831
|
||||
+static inline int ubi_vol_is_ubifs(struct ubi_volume_desc *desc)
|
||||
+{
|
||||
+ int ret;
|
||||
+ uint32_t magic_of, magic;
|
||||
+ ret = ubi_read(desc, 0, (char *)&magic_of, 0, 4);
|
||||
+ if (ret)
|
||||
+ return 0;
|
||||
+ magic = le32_to_cpu(magic_of);
|
||||
+ return magic == UBIFS_NODE_MAGIC;
|
||||
+}
|
||||
+
|
||||
+static void __init ubiblock_create_auto_rootfs(void)
|
||||
+{
|
||||
+ int ubi_num, ret, is_ubifs;
|
||||
+ struct ubi_volume_desc *desc;
|
||||
+ struct ubi_volume_info vi;
|
||||
+
|
||||
+ for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++) {
|
||||
+ desc = ubi_open_volume_nm(ubi_num, "rootfs", UBI_READONLY);
|
||||
+ if (IS_ERR(desc))
|
||||
+ continue;
|
||||
+
|
||||
+ ubi_get_volume_info(desc, &vi);
|
||||
+ is_ubifs = ubi_vol_is_ubifs(desc);
|
||||
+ ubi_close_volume(desc);
|
||||
+ if (is_ubifs)
|
||||
+ break;
|
||||
+
|
||||
+ ret = ubiblock_create(&vi);
|
||||
+ if (ret)
|
||||
+ pr_err("UBI error: block: can't add '%s' volume, err=%d\n",
|
||||
+ vi.name, ret);
|
||||
+ /* always break if we get here */
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void ubiblock_remove_all(void)
|
||||
{
|
||||
struct ubiblock *next;
|
||||
@@ -646,6 +684,10 @@ int __init ubiblock_init(void)
|
||||
*/
|
||||
ubiblock_create_from_param();
|
||||
|
||||
+ /* auto-attach "rootfs" volume if existing and non-ubifs */
|
||||
+ if (config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV))
|
||||
+ ubiblock_create_auto_rootfs();
|
||||
+
|
||||
/*
|
||||
* Block devices are only created upon user requests, so we ignore
|
||||
* existing volumes.
|
@ -1,54 +0,0 @@
|
||||
From eea9e1785e4c05c2a3444506aabafa0ae958538f Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Sat, 17 May 2014 03:35:02 +0200
|
||||
Subject: [PATCH 4/5] try auto-mounting ubi0:rootfs in init/do_mounts.c
|
||||
To: openwrt-devel@lists.openwrt.org
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
init/do_mounts.c | 26 +++++++++++++++++++++++++-
|
||||
1 file changed, 25 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/init/do_mounts.c
|
||||
+++ b/init/do_mounts.c
|
||||
@@ -438,7 +438,28 @@ retry:
|
||||
out:
|
||||
put_page(page);
|
||||
}
|
||||
-
|
||||
+
|
||||
+static int __init mount_ubi_rootfs(void)
|
||||
+{
|
||||
+ int flags = MS_SILENT;
|
||||
+ int err, tried = 0;
|
||||
+
|
||||
+ while (tried < 2) {
|
||||
+ err = do_mount_root("ubi0:rootfs", "ubifs", flags, \
|
||||
+ root_mount_data);
|
||||
+ switch (err) {
|
||||
+ case -EACCES:
|
||||
+ flags |= MS_RDONLY;
|
||||
+ tried++;
|
||||
+ break;
|
||||
+ default:
|
||||
+ return err;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return -EINVAL;
|
||||
+}
|
||||
+
|
||||
#ifdef CONFIG_ROOT_NFS
|
||||
|
||||
#define NFSROOT_TIMEOUT_MIN 5
|
||||
@@ -532,6 +553,10 @@ void __init mount_root(void)
|
||||
change_floppy("root floppy");
|
||||
}
|
||||
#endif
|
||||
+#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
|
||||
+ if (!mount_ubi_rootfs())
|
||||
+ return;
|
||||
+#endif
|
||||
#ifdef CONFIG_BLOCK
|
||||
create_dev("/dev/root", ROOT_DEV);
|
||||
mount_block_root("/dev/root", root_mountflags);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user