* [PATCH RESEND] ARM: AM43XX: Select OMAP_INTERCONNECT in Kconfig
From: Tony Lindgren @ 2016-11-07 23:20 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161019204412.18607-1-d-gerlach@ti.com>
* Dave Gerlach <d-gerlach@ti.com> [161019 13:45]:
> AM437x makes use of the omap_l3_noc driver so explicitly select
> OMAP_INTERCONNECT in the Kconfig for SOC_AM43XX to ensure it gets enabled
> for AM43XX only builds.
Applying into omap-for-v4.9/fixes thanks.
Tony
^ permalink raw reply
* [PATCH v2 1/6] pinctrl-aspeed-g5: Never set SCU90[6]
From: Andrew Jeffery @ 2016-11-07 22:42 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <CACRpkdbH8eubEHwHCsdJsmqVp3hkBW4vb5DCHvJxz+tyfFqbKQ@mail.gmail.com>
On Mon, 2016-11-07 at 10:34 +0100, Linus Walleij wrote:
> > On Thu, Nov 3, 2016 at 11:59 PM, Joel Stanley <joel@jms.id.au> wrote:
>
> > In the future I think we should send fixes separately from the rest of
> > the series, so it's clear to Linus where we expect patches to end up.
> >
> > Perhaps Linus can share his preference with us?
>
> Just make it clear to me where the patch is headed, if it is
> a fix or a new feature.
>
> Also mixing stuff in big series is of course problematic because
> all the CC:in on MFD patches and whatnot that I don't apply
> makes the picture blurry, but sometimes it is anyways needed
> for context so it is a soft requirement.
Context was my concern here and I would otherwise have split the rest
of the patches along mfd/pinctrl boundaries. I felt the situation was
odd enough to warrant presenting the full picture.
Andrew
>
> Yours,
> Linus Walleij
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161108/472a2ae8/attachment.sig>
^ permalink raw reply
* [PATCH 01/30] usb: dwc2: Deprecate g-use-dma binding
From: John Youn @ 2016-11-07 22:39 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <cover.1478558343.git.johnyoun@synopsys.com>
Add a vendor prefix and make the name more consistent by renaming it to
"snps,gadget-dma-enable".
Signed-off-by: John Youn <johnyoun@synopsys.com>
---
Documentation/devicetree/bindings/usb/dwc2.txt | 5 ++++-
arch/arm/boot/dts/rk3036.dtsi | 2 +-
arch/arm/boot/dts/rk3288.dtsi | 2 +-
arch/arm/boot/dts/rk3xxx.dtsi | 2 +-
arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 2 +-
arch/arm64/boot/dts/rockchip/rk3368.dtsi | 2 +-
drivers/usb/dwc2/params.c | 9 ++++++++-
drivers/usb/dwc2/pci.c | 2 +-
8 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt
index 9472111..389a461 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -26,11 +26,14 @@ Refer to phy/phy-bindings.txt for generic phy consumer properties
- dr_mode: shall be one of "host", "peripheral" and "otg"
Refer to usb/generic.txt
- snps,host-dma-disable: disable host DMA mode.
-- g-use-dma: enable dma usage in gadget driver.
+- snps,gadget-dma-enable: enable gadget DMA mode.
- g-rx-fifo-size: size of rx fifo size in gadget mode.
- g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode.
- g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget mode.
+Deprecated properties:
+- g-use-dma: Use "snps,gadget-dma-enable" instead.
+
Example:
usb at 101c0000 {
diff --git a/arch/arm/boot/dts/rk3036.dtsi b/arch/arm/boot/dts/rk3036.dtsi
index a935523..2604d2d 100644
--- a/arch/arm/boot/dts/rk3036.dtsi
+++ b/arch/arm/boot/dts/rk3036.dtsi
@@ -204,7 +204,7 @@
g-np-tx-fifo-size = <16>;
g-rx-fifo-size = <275>;
g-tx-fifo-size = <256 128 128 64 64 32>;
- g-use-dma;
+ snps,gadget-dma-enable;
status = "disabled";
};
diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 17ec2e2..c0db4ae 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -596,7 +596,7 @@
g-np-tx-fifo-size = <16>;
g-rx-fifo-size = <275>;
g-tx-fifo-size = <256 128 128 64 64 32>;
- g-use-dma;
+ snps,gadget-dma-enable;
phys = <&usbphy0>;
phy-names = "usb2-phy";
status = "disabled";
diff --git a/arch/arm/boot/dts/rk3xxx.dtsi b/arch/arm/boot/dts/rk3xxx.dtsi
index e15beb3..c96d622 100644
--- a/arch/arm/boot/dts/rk3xxx.dtsi
+++ b/arch/arm/boot/dts/rk3xxx.dtsi
@@ -181,7 +181,7 @@
g-np-tx-fifo-size = <16>;
g-rx-fifo-size = <275>;
g-tx-fifo-size = <256 128 128 64 64 32>;
- g-use-dma;
+ snps,gadget-dma-enable;
phys = <&usbphy0>;
phy-names = "usb2-phy";
status = "disabled";
diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
index 17839db..fe441f7 100644
--- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
@@ -747,7 +747,7 @@
clocks = <&sys_ctrl HI6220_USBOTG_HCLK>;
clock-names = "otg";
dr_mode = "otg";
- g-use-dma;
+ snps,gadget-dma-enable;
g-rx-fifo-size = <512>;
g-np-tx-fifo-size = <128>;
g-tx-fifo-size = <128 128 128 128 128 128>;
diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
index 0fcb214..6b44544 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
@@ -537,7 +537,7 @@
g-np-tx-fifo-size = <16>;
g-rx-fifo-size = <275>;
g-tx-fifo-size = <256 128 128 64 64 32>;
- g-use-dma;
+ snps,gadget-dma-enable;
status = "disabled";
};
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 2eb79e8..aeece91 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -1161,10 +1161,17 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
(hsotg->dr_mode == USB_DR_MODE_OTG)) {
dev_dbg(hsotg->dev, "Setting peripheral device properties\n");
- dwc2_set_param_bool(hsotg, &p->g_dma, true, "g-use-dma",
+ dwc2_set_param_bool(hsotg, &p->g_dma, true,
+ "snps,gadget-dma-enable",
false, false,
dma_capable);
+ /* Check the deprecated property. */
+ if (!p->g_dma)
+ dwc2_set_param_bool(hsotg, &p->g_dma, true, "g-use-dma",
+ false, false,
+ dma_capable);
+
/*
* The values for g_rx_fifo_size (2048) and
* g_np_tx_fifo_size (1024) come from the legacy s3c
diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index b3f3b58..46a9d2b 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -67,7 +67,7 @@ static int dwc2_pci_quirks(struct pci_dev *pdev, struct platform_device *dwc2)
if (pdev->vendor == PCI_VENDOR_ID_SYNOPSYS &&
pdev->device == PCI_PRODUCT_ID_HAPS_HSOTG) {
struct property_entry properties[] = {
- PROPERTY_ENTRY_BOOL("g-use-dma"),
+ PROPERTY_ENTRY_BOOL("snps,gadget-dma-enable"),
{ },
};
--
2.10.0
^ permalink raw reply related
* [PATCH 00/30] usb: dwc2: Gadget descriptor DMA and IOT
From: John Youn @ 2016-11-07 22:39 UTC (permalink / raw)
To: linux-arm-kernel
This series implements gadget-side descriptor DMA for the DWC_hsotg
controller.
It also includes support for DWC USB IOT controllers which use the
descriptor DMA mode of operation exclusively. These are two new
device-only USB controller IPs based on DWC_hsotg.
Tested on HAPS platform with:
* HSOTG IP version 3.30a
* FS/LS IOT IP version 1.00a
* HS IOT IP version 1.00a
This series should be applied on top of:
http://marc.info/?l=linux-usb&m=147822095118860&w=2
Regards,
John
John Youn (2):
usb: dwc2: Deprecate g-use-dma binding
usb: dwc2: Enable gadget DDMA by default for HAPS
Vahram Aharonyan (25):
usb: dwc2: Update DMA descriptor structure
usb: dwc2: gadget: Add descriptor DMA binding
usb: dwc2: gadget: Add DMA descriptor status quadlet fields
usb: dwc2: gadget: Enable BNA interrupt in descriptor DMA mode
usb: dwc2: gadget: Add DMA descriptor chains for EP 0
usb: dwc2: host: Rename MAX_DMA_DESC_SIZE to HOST_DMA_NBYTES_LIMIT
usb: dwc2: gadget: Transfer length limit checking for DDMA
usb: dwc2: gadget: Add DDMA chain pointers to dwc2_hsotg_ep structure
usb: dwc2: gadget: Add DDMA chain fill and parse functions
usb: dwc2: gadget: EP 0 specific DDMA programming
usb: dwc2: gadget: DDMA transfer start and complete
usb: dwc2: gadget: Fixes for StsPhseRcvd interrupt
usb: dwc2: gadget: Start DDMA IN status phase in StsPhseRcvd handler
usb: dwc2: gadget: Enable descriptor DMA mode
usb: dwc2: gadget: Add DDMA isoc related fields to dwc2_hsotg_ep
usb: dwc2: gadget: Fill isoc descriptor and start transfer in DDMA
usb: dwc2: gadget: Add completions for DDMA isoc transfers
usb: dwc2: gadget: In DDMA keep incompISOOUT and incompISOIN masked
usb: dwc2: gadget: Add start and complete calls for DDMA ISOC
usb: dwc2: gadget: Adjust ISOC OUT request's actual len for DDMA
usb: dwc2: gadget: Adjustments in debug prints
usb: dwc2: gadget: For DDMA parse setup only after SetUp interrupt
usb: dwc2: gadget: Correct dwc2_hsotg_ep_stop_xfr() function
usb: dwc2: gadget: Disable enabled HW endpoint in
dwc2_hsotg_ep_disable
usb: dwc2: Add support of dedicated full-speed PHY interface
Vardan Mikayelyan (3):
usb: dwc2: gadget: Add IOT device IDs, configure core accordingly
usb: dwc2: gadget: Program ep0_mps for LS
usb: dwc2: gadget: Add new core parameter for low speed
Documentation/devicetree/bindings/usb/dwc2.txt | 6 +-
arch/arm/boot/dts/rk3036.dtsi | 2 +-
arch/arm/boot/dts/rk3288.dtsi | 2 +-
arch/arm/boot/dts/rk3xxx.dtsi | 2 +-
arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 2 +-
arch/arm64/boot/dts/rockchip/rk3368.dtsi | 2 +-
drivers/usb/dwc2/core.h | 48 ++
drivers/usb/dwc2/gadget.c | 978 ++++++++++++++++++++++---
drivers/usb/dwc2/hcd.c | 12 +-
drivers/usb/dwc2/hcd.h | 2 +-
drivers/usb/dwc2/hcd_ddma.c | 52 +-
drivers/usb/dwc2/hw.h | 48 +-
drivers/usb/dwc2/params.c | 42 +-
drivers/usb/dwc2/pci.c | 3 +-
14 files changed, 1039 insertions(+), 162 deletions(-)
--
2.10.0
^ permalink raw reply
* [RFC PATCH v2 1/1] PCI/ACPI: xgene: Add ECAM quirk for X-Gene PCIe controller
From: Bjorn Helgaas @ 2016-11-07 22:38 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <CADaLND=xjHkt1yuT+1_P8Ppbrjn+cyKrLEOb_yJNzSWFPcZZJg@mail.gmail.com>
On Wed, Nov 02, 2016 at 01:54:44PM -0700, Duc Dang wrote:
> On Wed, Nov 2, 2016 at 9:53 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Tue, Oct 25, 2016 at 06:24:32PM -0700, Duc Dang wrote:
> > > PCIe controllers in X-Gene SoCs is not ECAM compliant: software
> > > needs to configure additional controller's register to address
> > > device at bus:dev:function.
> > >
> > > This patch depends on "ECAM quirks handling for ARM64 platforms"
> > > series (http://www.spinics.net/lists/arm-kernel/msg530692.html,
> > > the series was also modified by Bjorn) to address the limitation
> > > above for X-Gene PCIe controller.
> > >
> > > The quirk will only be applied for X-Gene PCIe MCFG table with
> > > OEM revison 1, 2, 3 or 4 (PCIe controller v1 and v2 on X-Gene SoCs).
> >
> > The quirks here contain some hard-coded address space consumed by
> > ECAM. The ECAM quirk itself is not a generic description of that
> > address space in the sense of a PCI BAR or an ACPI _CRS method, i.e.,
> > the quirk description is not enough to keep other parts of the kernel
> > from treating the address space as "available".
>
> Your concern here is the controller register region that I declared as
> hard-coded array of resource (xgene_vx_csr_res) is not owned by the
> root bridge? So unlike DT case where kernel discovers and knows
> exactly who owns this resource (and we can also use
> platform_get_resource to get the resource); in ACPI case with ECAM
> quirk, kernel knows who requests this resource but does not know who
> owns it? Do I understand correctly?
I think so. MCFG tells the PCI bridge driver where the ECAM space is.
But the ACPI core itself doesn't look at MCFG, so it doesn't know that
space is occupied, and it could potentially assign that space to some
other device, which would cause a conflict.
> > Can you add a note here in the changelog about how you are describing
> > this space generically? The standard solution is a PNP0C02 device
> > with _CRS that describes it.
> >
> > It would be ideal if you could open a bugzilla at bugzilla.kernel.org
> > and attach there a dmesg log, /proc/iomem contents, and DSDT. This
> > would show both the generic PNP0C02 piece and the ECAM quirk piece.
>
> We don't have PNP0C02 device in our ACPI Table. Do you want me add a
> PNP0C02 device into our firmware and check/document the difference in
> /proc/iomem output?
Yes, you should have a PNP0C02 device and its _CRS should describe the
ECAM space. _CRS is generic (not device-specific), and it's what
tells the ACPI core that the space is already in use.
If you already had a PNP0C02 device, you could make a quirk similar to
quirk_amd_mmconfig_area() to add things to its _CRS.
But I think you have firmware in the field that does not have a
PNP0C02 device at all, and that's harder to fix because you would need
to add some sort of fake device.
Rafael, do you have any ideas about this? I can imagine something
like the following, but I don't know what cans of worms it might open:
struct pnp_protocol pnpquirk_protocol = {
.name = "Plug and Play Quirks",
};
void quirk()
{
struct pnp_dev *dev;
struct resource res;
ret = pnp_register_protocol(&pnpquirk_protocol);
if (ret)
return;
dev = pnp_alloc_dev(&pnpquirk_protocol, 0, "PNP0C02");
if (!dev)
return;
res.start = XX; /* ECAM start */
res.end = YY; /* ECAM end */
res.flags = IORESOURCE_MEM;
pnp_add_resource(dev, &res);
dev->active = 1;
pnp_add_device(dev);
dev_info(&dev->dev, "fabricated device to reserve ECAM space %pR\n", &res);
}
> > BTW, I did refresh and re-push the pci/ecam-v6 branch where I'm
> > collecting this stuff, so if you want to rebase your patch on top of
> > that and test it, that would be great.
>
> Thanks, I will definitely do that.
> >
> > > Signed-off-by: Duc Dang <dhdang@apm.com>
> > > ---
> > > v2 changes:
> > > 1. Get rid of pci-xgene-ecam.c file and fold quirk code into pci-xgene.c
> > > 2. Redefine fixup array for X-Gene
> > > 3. Use devm_ioremap_resource to map csr_base
> > >
> > > drivers/acpi/pci_mcfg.c | 30 ++++++++
> > > drivers/pci/host/pci-xgene.c | 165 ++++++++++++++++++++++++++++++++++++++++++-
> > > include/linux/pci-ecam.h | 5 ++
> > > 3 files changed, 197 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c
> > > index bb2c508..9dfc937 100644
> > > --- a/drivers/acpi/pci_mcfg.c
> > > +++ b/drivers/acpi/pci_mcfg.c
> > > @@ -96,6 +96,36 @@ struct mcfg_fixup {
> > > THUNDER_ECAM_MCFG(2, 12),
> > > THUNDER_ECAM_MCFG(2, 13),
> > > #endif
> > > +#ifdef CONFIG_PCI_XGENE
> > > +#define XGENE_V1_ECAM_MCFG(rev, seg) \
> > > + {"APM ", "XGENE ", rev, seg, MCFG_BUS_ANY, \
> > > + &xgene_v1_pcie_ecam_ops }
> > > +#define XGENE_V2_1_ECAM_MCFG(rev, seg) \
> > > + {"APM ", "XGENE ", rev, seg, MCFG_BUS_ANY, \
> > > + &xgene_v2_1_pcie_ecam_ops }
> > > +#define XGENE_V2_2_ECAM_MCFG(rev, seg) \
> > > + {"APM ", "XGENE ", rev, seg, MCFG_BUS_ANY, \
> > > + &xgene_v2_2_pcie_ecam_ops }
> > > +
> > > + /* X-Gene SoC with v1 PCIe controller */
> > > + XGENE_V1_ECAM_MCFG(1, 0),
> > > + XGENE_V1_ECAM_MCFG(1, 1),
> > > + XGENE_V1_ECAM_MCFG(1, 2),
> > > + XGENE_V1_ECAM_MCFG(1, 3),
> > > + XGENE_V1_ECAM_MCFG(1, 4),
> > > + XGENE_V1_ECAM_MCFG(2, 0),
> > > + XGENE_V1_ECAM_MCFG(2, 1),
> > > + XGENE_V1_ECAM_MCFG(2, 2),
> > > + XGENE_V1_ECAM_MCFG(2, 3),
> > > + XGENE_V1_ECAM_MCFG(2, 4),
> > > + /* X-Gene SoC with v2.1 PCIe controller */
> > > + XGENE_V2_1_ECAM_MCFG(3, 0),
> > > + XGENE_V2_1_ECAM_MCFG(3, 1),
> > > + /* X-Gene SoC with v2.2 PCIe controller */
> > > + XGENE_V2_2_ECAM_MCFG(4, 0),
> > > + XGENE_V2_2_ECAM_MCFG(4, 1),
> > > + XGENE_V2_2_ECAM_MCFG(4, 2),
> > > +#endif
> > > };
> > >
> > > static char mcfg_oem_id[ACPI_OEM_ID_SIZE];
> > > diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
> > > index 1de23d7..d6aa642 100644
> > > --- a/drivers/pci/host/pci-xgene.c
> > > +++ b/drivers/pci/host/pci-xgene.c
> > > @@ -27,6 +27,8 @@
> > > #include <linux/of_irq.h>
> > > #include <linux/of_pci.h>
> > > #include <linux/pci.h>
> > > +#include <linux/pci-acpi.h>
> > > +#include <linux/pci-ecam.h>
> > > #include <linux/platform_device.h>
> > > #include <linux/slab.h>
> > >
> > > @@ -64,6 +66,7 @@
> > > /* PCIe IP version */
> > > #define XGENE_PCIE_IP_VER_UNKN 0
> > > #define XGENE_PCIE_IP_VER_1 1
> > > +#define XGENE_PCIE_IP_VER_2 2
> > >
> > > struct xgene_pcie_port {
> > > struct device_node *node;
> > > @@ -97,7 +100,15 @@ static inline u32 pcie_bar_low_val(u32 addr, u32 flags)
> > > */
> > > static void __iomem *xgene_pcie_get_cfg_base(struct pci_bus *bus)
> > > {
> > > - struct xgene_pcie_port *port = bus->sysdata;
> > > + struct pci_config_window *cfg;
> > > + struct xgene_pcie_port *port;
> > > +
> > > + if (acpi_disabled)
> > > + port = bus->sysdata;
> > > + else {
> > > + cfg = bus->sysdata;
> > > + port = cfg->priv;
> > > + }
> > >
> > > if (bus->number >= (bus->primary + 1))
> > > return port->cfg_base + AXI_EP_CFG_ACCESS;
> > > @@ -111,10 +122,18 @@ static void __iomem *xgene_pcie_get_cfg_base(struct pci_bus *bus)
> > > */
> > > static void xgene_pcie_set_rtdid_reg(struct pci_bus *bus, uint devfn)
> > > {
> > > - struct xgene_pcie_port *port = bus->sysdata;
> > > + struct pci_config_window *cfg;
> > > + struct xgene_pcie_port *port;
> > > unsigned int b, d, f;
> > > u32 rtdid_val = 0;
> > >
> > > + if (acpi_disabled)
> > > + port = bus->sysdata;
> > > + else {
> > > + cfg = bus->sysdata;
> > > + port = cfg->priv;
> > > + }
> > > +
> > > b = bus->number;
> > > d = PCI_SLOT(devfn);
> > > f = PCI_FUNC(devfn);
> > > @@ -158,7 +177,15 @@ static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
> > > static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,
> > > int where, int size, u32 *val)
> > > {
> > > - struct xgene_pcie_port *port = bus->sysdata;
> > > + struct pci_config_window *cfg;
> > > + struct xgene_pcie_port *port;
> > > +
> > > + if (acpi_disabled)
> > > + port = bus->sysdata;
> > > + else {
> > > + cfg = bus->sysdata;
> > > + port = cfg->priv;
> > > + }
> > >
> > > if (pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val) !=
> > > PCIBIOS_SUCCESSFUL)
> > > @@ -189,6 +216,138 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,
> > > .write = pci_generic_config_write32,
> > > };
> > >
> > > +#ifdef CONFIG_ACPI
> > > +static struct resource xgene_v1_csr_res[] = {
> > > + [0] = DEFINE_RES_MEM(0x1f2b0000UL, SZ_64K),
> > > + [1] = DEFINE_RES_MEM(0x1f2c0000UL, SZ_64K),
> > > + [2] = DEFINE_RES_MEM(0x1f2d0000UL, SZ_64K),
> > > + [3] = DEFINE_RES_MEM(0x1f500000UL, SZ_64K),
> > > + [4] = DEFINE_RES_MEM(0x1f510000UL, SZ_64K),
> > > +};
> > > +
> > > +static int xgene_v1_pcie_ecam_init(struct pci_config_window *cfg)
> > > +{
> > > + struct acpi_device *adev = to_acpi_device(cfg->parent);
> > > + struct acpi_pci_root *root = acpi_driver_data(adev);
> > > + struct device *dev = cfg->parent;
> > > + struct xgene_pcie_port *port;
> > > + struct resource *csr;
> > > +
> > > + port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> > > + if (!port)
> > > + return -ENOMEM;
> > > +
> > > + csr = &xgene_v1_csr_res[root->segment];
> > > + port->csr_base = devm_ioremap_resource(dev, csr);
> > > + if (IS_ERR(port->csr_base)) {
> > > + kfree(port);
> > > + return -ENOMEM;
> > > + }
> > > +
> > > + port->cfg_base = cfg->win;
> > > + port->version = XGENE_PCIE_IP_VER_1;
> > > +
> > > + cfg->priv = port;
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +struct pci_ecam_ops xgene_v1_pcie_ecam_ops = {
> > > + .bus_shift = 16,
> > > + .init = xgene_v1_pcie_ecam_init,
> > > + .pci_ops = {
> > > + .map_bus = xgene_pcie_map_bus,
> > > + .read = xgene_pcie_config_read32,
> > > + .write = pci_generic_config_write,
> > > + }
> > > +};
> > > +
> > > +static struct resource xgene_v2_1_csr_res[] = {
> > > + [0] = DEFINE_RES_MEM(0x1f2b0000UL, SZ_64K),
> > > + [1] = DEFINE_RES_MEM(0x1f2c0000UL, SZ_64K),
> > > +};
> > > +
> > > +static int xgene_v2_1_pcie_ecam_init(struct pci_config_window *cfg)
> > > +{
> > > + struct acpi_device *adev = to_acpi_device(cfg->parent);
> > > + struct acpi_pci_root *root = acpi_driver_data(adev);
> > > + struct device *dev = cfg->parent;
> > > + struct xgene_pcie_port *port;
> > > + struct resource *csr;
> > > +
> > > + port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> > > + if (!port)
> > > + return -ENOMEM;
> > > +
> > > + csr = &xgene_v2_1_csr_res[root->segment];
> > > + port->csr_base = devm_ioremap_resource(dev, csr);
> > > + if (IS_ERR(port->csr_base)) {
> > > + kfree(port);
> > > + return -ENOMEM;
> > > + }
> > > +
> > > + port->cfg_base = cfg->win;
> > > + port->version = XGENE_PCIE_IP_VER_2;
> > > +
> > > + cfg->priv = port;
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +struct pci_ecam_ops xgene_v2_1_pcie_ecam_ops = {
> > > + .bus_shift = 16,
> > > + .init = xgene_v2_1_pcie_ecam_init,
> > > + .pci_ops = {
> > > + .map_bus = xgene_pcie_map_bus,
> > > + .read = xgene_pcie_config_read32,
> > > + .write = pci_generic_config_write,
> > > + }
> > > +};
> > > +
> > > +static struct resource xgene_v2_2_csr_res[] = {
> > > + [0] = DEFINE_RES_MEM(0x1f2b0000UL, SZ_64K),
> > > + [1] = DEFINE_RES_MEM(0x1f500000UL, SZ_64K),
> > > + [2] = DEFINE_RES_MEM(0x1f2d0000UL, SZ_64K),
> > > +};
> > > +
> > > +static int xgene_v2_2_pcie_ecam_init(struct pci_config_window *cfg)
> > > +{
> > > + struct acpi_device *adev = to_acpi_device(cfg->parent);
> > > + struct acpi_pci_root *root = acpi_driver_data(adev);
> > > + struct device *dev = cfg->parent;
> > > + struct xgene_pcie_port *port;
> > > + struct resource *csr;
> > > +
> > > + port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> > > + if (!port)
> > > + return -ENOMEM;
> > > +
> > > + csr = &xgene_v2_2_csr_res[root->segment];
> > > + port->csr_base = devm_ioremap_resource(dev, csr);
> > > + if (IS_ERR(port->csr_base)) {
> > > + kfree(port);
> > > + return -ENOMEM;
> > > + }
> > > +
> > > + port->cfg_base = cfg->win;
> > > + port->version = XGENE_PCIE_IP_VER_2;
> > > +
> > > + cfg->priv = port;
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +struct pci_ecam_ops xgene_v2_2_pcie_ecam_ops = {
> > > + .bus_shift = 16,
> > > + .init = xgene_v2_2_pcie_ecam_init,
> > > + .pci_ops = {
> > > + .map_bus = xgene_pcie_map_bus,
> > > + .read = xgene_pcie_config_read32,
> > > + .write = pci_generic_config_write,
> > > + }
> > > +};
> > > +#endif
> > > +
> > > static u64 xgene_pcie_set_ib_mask(struct xgene_pcie_port *port, u32 addr,
> > > u32 flags, u64 size)
> > > {
> > > diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h
> > > index 35f0e81..40da3e7 100644
> > > --- a/include/linux/pci-ecam.h
> > > +++ b/include/linux/pci-ecam.h
> > > @@ -65,6 +65,11 @@ void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn,
> > > #ifdef CONFIG_PCI_HOST_THUNDER_ECAM
> > > extern struct pci_ecam_ops pci_thunder_ecam_ops;
> > > #endif
> > > +#ifdef CONFIG_PCI_XGENE
> > > +extern struct pci_ecam_ops xgene_v1_pcie_ecam_ops;
> > > +extern struct pci_ecam_ops xgene_v2_1_pcie_ecam_ops;
> > > +extern struct pci_ecam_ops xgene_v2_2_pcie_ecam_ops;
> > > +#endif
> > >
> > > #ifdef CONFIG_PCI_HOST_GENERIC
> > > /* for DT-based PCI controllers that support ECAM */
> > > --
> > > 1.9.1
> > >
> Regards,
> Duc Dang.
^ permalink raw reply
* [PATCH v5 1/7] drm: sunxi: Add a basic DRM driver for Allwinner DE2
From: Maxime Ripard @ 2016-11-07 22:37 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161028193420.0f7dc67ea1042ff72b09b701@free.fr>
Hi,
On Fri, Oct 28, 2016 at 07:34:20PM +0200, Jean-Francois Moine wrote:
> On Fri, 28 Oct 2016 00:03:16 +0200
> Maxime Ripard <maxime.ripard@free-electrons.com> wrote:
>
> > On Tue, Oct 25, 2016 at 04:14:41PM +0200, Jean-Francois Moine wrote:
> > > > > +Display controller
> > > > > +==================
> > > > > +
> > > > > +Required properties:
> > > > > +
> > > > > +- compatible: value should be one of the following
> > > > > + "allwinner,sun8i-a83t-display-engine"
> > > > > + "allwinner,sun8i-h3-display-engine"
> > > > > +
> > > > > +- clocks: must include clock specifiers corresponding to entries in the
> > > > > + clock-names property.
> > > > > +
> > > > > +- clock-names: must contain
> > > > > + "gate": for DE activation
> > > > > + "clock": DE clock
> > > >
> > > > We've been calling them bus and mod.
> > >
> > > I can understand "bus" (which is better than "apb"), but why "mod"?
> >
> > Allwinner has been calling the clocks that are supposed to generate
> > the external signals (depending on where you were looking) module or
> > mod clocks (which is also why we have mod in the clock
> > compatibles). The module 1 clocks being used for the audio and the
> > module 0 for the rest (SPI, MMC, NAND, display, etc.)
>
> I did not find any 'module' in the H3 documentation.
> So, is it really a good name?
It's true that they use it less nowadays, but they still do,
ie. https://github.com/allwinner-zh/linux-3.4-sunxi/blob/master/drivers/clk/sunxi/clk-sun8iw7.c#L513
And we have to remain consistent anyway.
> > > > > +
> > > > > +- resets: phandle to the reset of the device
> > > > > +
> > > > > +- ports: phandle's to the LCD ports
> > > >
> > > > Please use the OF graph.
> > >
> > > These ports are references to the graph of nodes. See
> > > http://www.kernelhub.org/?msg=911825&p=2
> >
> > In an OF-graph, your phandle to the LCD controller would be replaced
> > by an output endpoint.
>
> This is the DE controller. There is no endpoint link at this level.
The display engine definitely has an endpoint: the TCON.
> The Device Engine just handles the planes of the LCDs, but, indeed,
> the LCDs must know about the DE and the DE must know about the LCDs.
> There are 2 ways to realize this knowledge in the DT:
> 1) either the DE has one or two phandle's to the LCDs,
> 2) or the LCDs have a phandle to the DE.
>
> I chose the 1st way, the DE ports pointing to the endpoint of the LCDs
> which is part of the video link (OF-graph LCD <-> connector).
> It would be possible to have phandles to the LCDs themselves, but this
> asks for more code.
>
> The second way is also possible, but it also complexifies a bit the
> exchanges DE <-> LCD.
I'm still not sure how it would complexify anything, and why you can't
use the display graph to model the relation between the display engine
and the TCON (and why you want to use a generic property that refers
to the of-graph while it really isn't).
> > > > > +void de2_disable_vblank(struct drm_device *drm, unsigned crtc)
> > > > > +{
> > > > > + struct priv *priv = drm->dev_private;
> > > > > + struct lcd *lcd = priv->lcds[crtc];
> > > > > +
> > > > > + tcon_write(lcd->mmio, gint0,
> > > > > + tcon_read(lcd->mmio, gint0) &
> > > > > + ~TCON_GINT0_TCON1_Vb_Int_En);
> > > > > +}
> > > > > +
> > > > > +/* panel functions */
> > > >
> > > > Panel functions? In the CRTC driver?
> > >
> > > Yes, dumb panel.
> >
> > What do you mean by that? Using a Parallel/RGB interface?
>
> Sorry, I though this was a well-known name. The 'dump panel' was used
> in the documentation of my previous ARM machine as the video frame sent
> to the HDMI controller. 'video_frame' is OK for you?
If it's the frame sent to the encoder, then it would be the CRTC by
DRM's nomenclature.
> > > > > +static const struct {
> > > > > + char chan;
> > > > > + char layer;
> > > > > + char pipe;
> > > > > +} plane2layer[DE2_N_PLANES] = {
> > > > > + [DE2_PRIMARY_PLANE] = {0, 0, 0},
> > > > > + [DE2_CURSOR_PLANE] = {1, 0, 1},
> > > > > + [DE2_VI_PLANE] = {0, 1, 0},
> > > > > +};
> > > >
> > > > Comments?
> > >
> > > This
> > > primary plane is channel 0 (VI), layer 0, pipe 0
> > > cursor plane is channel 1 (UI), layer 0, pipe 1
> > > overlay plane is channel 0 (VI), layer 1, pipe 0
> > > or the full explanation:
> > > Constraints:
> > > The VI channels can do RGB or YUV, while UI channels can do RGB
> > > only.
> > > The LCD 0 has 1 VI channel and 4 UI channels, while
> > > LCD 1 has only 1 VI channel and 1 UI channel.
> > > The cursor must go to a channel bigger than the primary channel,
> > > otherwise it is not transparent.
> > > First try:
> > > Letting the primary plane (usually RGB) in the 2nd channel (UI),
> > > as this is done in the legacy driver, asks for the cursor to go
> > > to the next channel (UI), but this one does not exist in LCD1.
> > > Retained layout:
> > > So, we must use only 2 channels for the same behaviour on LCD0
> > > (H3) and LCD1 (A83T)
> > > The retained combination is:
> > > - primary plane in the first channel (VI),
> > > - cursor plane inthe 2nd channel (UI), and
> > > - overlay plane in the 1st channel (VI).
> > >
> > > Note that there could be 3 overlay planes (a channel has 4
> > > layers), but I am not sure that the A83T or the H3 could
> > > support 3 simultaneous video streams...
> >
> > Do you know if the pipe works in the old display engine?
> >
> > Especially about the two-steps composition that wouldn't allow you to
> > have alpha on all the planes?
> >
> > If it is similar, I think hardcoding the pipe number is pretty bad,
> > because that would restrict the combination of planes and formats,
> > while some other might have worked.
>
> From what I understood about the DE2, the pipes just define the priority
> of the overlay channels (one pipe for one channel).
> With the cursor constraint, there must be at least 2 channels in
> order (primary, cursor). Then, with these 2 channels/pipes, there can be
> 6 so-called overlay planes (3 RGB/YUV and 3 RGB only).
> Enabling the pipes 2 and 3 (LCD 0 only) would offer 8 more planes, but
> RGB only. Then, it might be useful to have dynamic pipes.
That's very valuable (and definitely should go into a comment),
thanks!
I still believe that's it should be into a (simple at first)
atomic_check. That would be easier to extend and quite easy to
document and get simply by looking at the code.
> > > > > +static int __init de2_drm_init(void)
> > > > > +{
> > > > > + int ret;
> > > > > +
> > > > > +/* uncomment to activate the drm traces at startup time */
> > > > > +/* drm_debug = DRM_UT_CORE | DRM_UT_DRIVER | DRM_UT_KMS |
> > > > > + DRM_UT_PRIME | DRM_UT_ATOMIC; */
> > > >
> > > > That's useless.
> > >
> > > Right, but it seems that some people don't know how to debug a DRM
> > > driver. This is only a reminder.
> > >
> > > > > + DRM_DEBUG_DRIVER("\n");
> > > > > +
> > > > > + ret = platform_driver_register(&de2_lcd_platform_driver);
> > > > > + if (ret < 0)
> > > > > + return ret;
> > > > > +
> > > > > + ret = platform_driver_register(&de2_drm_platform_driver);
> > > > > + if (ret < 0)
> > > > > + platform_driver_unregister(&de2_lcd_platform_driver);
> > > > > +
> > > > > + return ret;
> > > > > +}
> > > >
> > > > And that really shouldn't be done that way.
> > >
> > > May you explain?
> >
> > This goes against the whole idea of the device and driver
> > model. Drivers should only register themselves, device should be
> > created by buses (or by using some external components if the bus
> > can't: DT, ACPI, etc.). If there's a match, you get probed.
> >
> > A driver that creates its own device just to probe itself violates
> > that.
>
> In this function (module init), there is no driver yet.
> The module contains 2 drivers: the DE (planes) and the LCD (CRTC),
> and there is no macro to handle such modules.
Ah, yes, my bad. I thought you were registering a device and a
driver. Still this is a very unusual pattern. Why do you need to split
the two? Can't you just merge them?
> > > > > +int de2_plane_init(struct drm_device *drm, struct lcd *lcd)
> > > > > +{
> > > > > + int ret, possible_crtcs = 1 << lcd->crtc_idx;
> > > > > +
> > > > > + ret = de2_one_plane_init(drm, &lcd->planes[DE2_PRIMARY_PLANE],
> > > > > + DRM_PLANE_TYPE_PRIMARY, possible_crtcs,
> > > > > + ui_formats, ARRAY_SIZE(ui_formats));
> > > > > + if (ret >= 0)
> > > > > + ret = de2_one_plane_init(drm, &lcd->planes[DE2_CURSOR_PLANE],
> > > > > + DRM_PLANE_TYPE_CURSOR, possible_crtcs,
> > > > > + ui_formats, ARRAY_SIZE(ui_formats));
> > > >
> > > > Nothing looks really special about that cursor plane. Any reasion not
> > > > to make it an overlay?
> > >
> > > As explained above (channel/layer/pipe plane definitions), the cursor
> > > cannot go in a channel lower or equal to the one of the primary plane.
> > > Then, it must be known and, so, have an explicit plane.
> >
> > If you were to make it a plane, you could use atomic_check to check
> > this and make sure this doesn't happen. And you would gain a generic
> > plane that can be used for other purposes if needed.
>
> The function drm_crtc_init_with_planes() offers a cursor plane for free.
> On the other side, having 6 overlay planes is more than the SoCs can
> support.
It's not really for free, it costs you a generic plane that could
definitely be used for something else and cannot anymore because
they've been hardcoded to a cursor.
And having a camera, the VPU or even an application directly output
directly into one of these planes seems a much better use of a generic
plane than a cursor.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161107/1138769a/attachment.sig>
^ permalink raw reply
* [PATCH 2/8] ARM64: dts: meson-gxl: Add pinctrl nodes
From: Kevin Hilman @ 2016-11-07 22:30 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1477932286-27482-3-git-send-email-narmstrong@baylibre.com>
Neil Armstrong <narmstrong@baylibre.com> writes:
> Add pinctrl nodes and pin definitions for Amlogic Meson GXL.
>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
> arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 168 +++++++++++++++++++++++++++++
> 1 file changed, 168 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
> index 13b10ee..ce7f550 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
> +++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
> @@ -42,7 +42,175 @@
> */
>
> #include "meson-gx.dtsi"
> +#include <dt-bindings/gpio/meson-gxl-gpio.h>
Oops, this has a dependency on the patch going through the pinctrl tree,
which causes probelems we like to avoid in the arm-soc tree.
For now, I've changed this to use the GXBB include since the values used
are the same, but we can fix this for good in v4.10-rc, after the GXL
pinctrl changes are merged.
Kevin
[1] [PATCH] pinctrl: meson: Add GXL pinctrl definitions
> / {
> compatible = "amlogic,meson-gxl";
> };
> +
> +&aobus {
> + pinctrl_aobus: pinctrl at 14 {
> + compatible = "amlogic,meson-gxl-aobus-pinctrl";
> + #address-cells = <2>;
> + #size-cells = <2>;
> + ranges;
> +
> + gpio_ao: bank at 14 {
> + reg = <0x0 0x00014 0x0 0x8>,
> + <0x0 0x0002c 0x0 0x4>,
> + <0x0 0x00024 0x0 0x8>;
> + reg-names = "mux", "pull", "gpio";
> + gpio-controller;
> + #gpio-cells = <2>;
> + };
> +
> + uart_ao_a_pins: uart_ao_a {
> + mux {
> + groups = "uart_tx_ao_a", "uart_rx_ao_a";
> + function = "uart_ao";
> + };
> + };
> +
> + remote_input_ao_pins: remote_input_ao {
> + mux {
> + groups = "remote_input_ao";
> + function = "remote_input_ao";
> + };
> + };
> + };
> +};
> +
> +&periphs {
> + pinctrl_periphs: pinctrl at 4b0 {
> + compatible = "amlogic,meson-gxl-periphs-pinctrl";
> + #address-cells = <2>;
> + #size-cells = <2>;
> + ranges;
> +
> + gpio: bank at 4b0 {
> + reg = <0x0 0x004b0 0x0 0x28>,
> + <0x0 0x004e8 0x0 0x14>,
> + <0x0 0x00120 0x0 0x14>,
> + <0x0 0x00430 0x0 0x40>;
> + reg-names = "mux", "pull", "pull-enable", "gpio";
> + gpio-controller;
> + #gpio-cells = <2>;
> + };
> +
> + emmc_pins: emmc {
> + mux {
> + groups = "emmc_nand_d07",
> + "emmc_cmd",
> + "emmc_clk",
> + "emmc_ds";
> + function = "emmc";
> + };
> + };
> +
> + sdcard_pins: sdcard {
> + mux {
> + groups = "sdcard_d0",
> + "sdcard_d1",
> + "sdcard_d2",
> + "sdcard_d3",
> + "sdcard_cmd",
> + "sdcard_clk";
> + function = "sdcard";
> + };
> + };
> +
> + sdio_pins: sdio {
> + mux {
> + groups = "sdio_d0",
> + "sdio_d1",
> + "sdio_d2",
> + "sdio_d3",
> + "sdio_cmd",
> + "sdio_clk";
> + function = "sdio";
> + };
> + };
> +
> + sdio_irq_pins: sdio_irq {
> + mux {
> + groups = "sdio_irq";
> + function = "sdio";
> + };
> + };
> +
> + uart_a_pins: uart_a {
> + mux {
> + groups = "uart_tx_a",
> + "uart_rx_a";
> + function = "uart_a";
> + };
> + };
> +
> + uart_b_pins: uart_b {
> + mux {
> + groups = "uart_tx_b",
> + "uart_rx_b";
> + function = "uart_b";
> + };
> + };
> +
> + uart_c_pins: uart_c {
> + mux {
> + groups = "uart_tx_c",
> + "uart_rx_c";
> + function = "uart_c";
> + };
> + };
> +
> + i2c_a_pins: i2c_a {
> + mux {
> + groups = "i2c_sck_a",
> + "i2c_sda_a";
> + function = "i2c_a";
> + };
> + };
> +
> + i2c_b_pins: i2c_b {
> + mux {
> + groups = "i2c_sck_b",
> + "i2c_sda_b";
> + function = "i2c_b";
> + };
> + };
> +
> + i2c_c_pins: i2c_c {
> + mux {
> + groups = "i2c_sck_c",
> + "i2c_sda_c";
> + function = "i2c_c";
> + };
> + };
> +
> + eth_pins: eth_c {
> + mux {
> + groups = "eth_mdio",
> + "eth_mdc",
> + "eth_clk_rx_clk",
> + "eth_rx_dv",
> + "eth_rxd0",
> + "eth_rxd1",
> + "eth_rxd2",
> + "eth_rxd3",
> + "eth_rgmii_tx_clk",
> + "eth_tx_en",
> + "eth_txd0",
> + "eth_txd1",
> + "eth_txd2",
> + "eth_txd3";
> + function = "eth";
> + };
> + };
> +
> + pwm_e_pins: pwm_e {
> + mux {
> + groups = "pwm_e";
> + function = "pwm_e";
> + };
> + };
> + };
> +};
^ permalink raw reply
* [PATCH v4 2/2] ARM: at91: pm: switch to the PIE infrastructure
From: Alexandre Belloni @ 2016-11-07 22:24 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161107222458.15732-1-alexandre.belloni@free-electrons.com>
Using the PIE infrastructure allows to write the whole suspend/resume
functions in C instead of assembly.
The only remaining assembly instruction is wfi for armv5
It makes the code shorter and clearer.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/mach-at91/Kconfig | 1 +
arch/arm/mach-at91/Makefile | 2 +-
arch/arm/mach-at91/pm.c | 31 ++--
arch/arm/mach-at91/pm/.gitignore | 2 +
arch/arm/mach-at91/pm/Makefile | 3 +
arch/arm/mach-at91/pm/atmel_pm.c | 97 +++++++++++
arch/arm/mach-at91/pm_suspend.S | 338 ---------------------------------------
7 files changed, 114 insertions(+), 360 deletions(-)
create mode 100644 arch/arm/mach-at91/pm/.gitignore
create mode 100644 arch/arm/mach-at91/pm/Makefile
create mode 100644 arch/arm/mach-at91/pm/atmel_pm.c
delete mode 100644 arch/arm/mach-at91/pm_suspend.S
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 841e924143f9..cecb20efbf3c 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -5,6 +5,7 @@ menuconfig ARCH_AT91
select GPIOLIB
select PINCTRL
select SOC_BUS
+ select PIE
if ARCH_AT91
config SOC_SAMA5D2
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index c5bbf8bb8c0f..062336de4f66 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_SOC_SAMA5) += sama5.o
# Power Management
obj-$(CONFIG_PM) += pm.o
-obj-$(CONFIG_PM) += pm_suspend.o
+obj-$(CONFIG_PM) += pm/
ifeq ($(CONFIG_CPU_V7),y)
AFLAGS_pm_suspend.o := -march=armv7-a
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index b4332b727e9c..f0a3eee73b86 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -21,6 +21,7 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/of_address.h>
+#include <linux/pie.h>
#include <linux/platform_device.h>
#include <linux/platform_data/atmel.h>
#include <linux/io.h>
@@ -57,6 +58,8 @@ static struct {
void __iomem *at91_ramc_base[2];
+static struct pie_chunk *atmel_pm_pie;
+
static int at91_pm_valid_state(suspend_state_t state)
{
switch (state) {
@@ -134,10 +137,6 @@ EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
static void (*at91_suspend_sram_fn)(void __iomem *pmc, void __iomem *ramc0,
void __iomem *ramc1, int memctrl);
-extern void at91_pm_suspend_in_sram(void __iomem *pmc, void __iomem *ramc0,
- void __iomem *ramc1, int memctrl);
-extern u32 at91_pm_suspend_in_sram_sz;
-
static void at91_pm_suspend(suspend_state_t state)
{
unsigned int pm_data = at91_pm_data.memctrl;
@@ -371,11 +370,12 @@ static void at91sam9_idle(void)
cpu_do_idle();
}
+extern void atmel_pm_suspend(void __iomem *pmc, void __iomem *ramc0,
+ void __iomem *ramc1, int memctrl);
+
static void __init at91_pm_sram_init(void)
{
struct gen_pool *sram_pool;
- phys_addr_t sram_pbase;
- unsigned long sram_base;
struct device_node *node;
struct platform_device *pdev = NULL;
@@ -398,23 +398,12 @@ static void __init at91_pm_sram_init(void)
return;
}
- sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
- if (!sram_base) {
- pr_warn("%s: unable to alloc sram!\n", __func__);
+ atmel_pm_pie = pie_load_sections(sram_pool, atmel_pm,
+ arch_arm_mach_at91_pm);
+ if (IS_ERR(atmel_pm_pie))
return;
- }
-
- sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
- at91_suspend_sram_fn = __arm_ioremap_exec(sram_pbase,
- at91_pm_suspend_in_sram_sz, false);
- if (!at91_suspend_sram_fn) {
- pr_warn("SRAM: Could not map\n");
- return;
- }
- /* Copy the pm suspend handler to SRAM */
- at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
- &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
+ at91_suspend_sram_fn = fn_to_pie(atmel_pm_pie, atmel_pm_suspend);
}
static const struct of_device_id atmel_pmc_ids[] __initconst = {
diff --git a/arch/arm/mach-at91/pm/.gitignore b/arch/arm/mach-at91/pm/.gitignore
new file mode 100644
index 000000000000..1cb8879eb0bf
--- /dev/null
+++ b/arch/arm/mach-at91/pm/.gitignore
@@ -0,0 +1,2 @@
+*.lds*
+*.syms
diff --git a/arch/arm/mach-at91/pm/Makefile b/arch/arm/mach-at91/pm/Makefile
new file mode 100644
index 000000000000..c12d54862c10
--- /dev/null
+++ b/arch/arm/mach-at91/pm/Makefile
@@ -0,0 +1,3 @@
+PIE_NAME := atmel_pm
+
+include arch/arm/pie/Makefile.pie
diff --git a/arch/arm/mach-at91/pm/atmel_pm.c b/arch/arm/mach-at91/pm/atmel_pm.c
new file mode 100644
index 000000000000..7f391addd2da
--- /dev/null
+++ b/arch/arm/mach-at91/pm/atmel_pm.c
@@ -0,0 +1,97 @@
+#include <linux/io.h>
+#include <linux/clk/at91_pmc.h>
+#include <linux/mfd/syscon/atmel-mc.h>
+#include <linux/pie.h>
+#include "../pm.h"
+
+#define SRAMC_SELF_FRESH_ACTIVE 0x01
+#define SRAMC_SELF_FRESH_EXIT 0x00
+
+static void at91_sramc_self_refresh(unsigned int is_active,
+ unsigned int memtype,
+ void __iomem *sdramc_base,
+ void __iomem *sdramc_base1)
+{
+ static unsigned int lpr, mdr, lpr1, mdr1;
+
+ switch (memtype) {
+ case AT91_MEMCTRL_MC:
+ /*
+ * at91rm9200 Memory controller
+ */
+ if (is_active)
+ __raw_writel(1, sdramc_base + AT91_MC_SDRAMC_SRR);
+ break;
+
+ case AT91_MEMCTRL_DDRSDR:
+ if (is_active) {
+ mdr = __raw_readl(sdramc_base + AT91_DDRSDRC_MDR);
+ lpr = __raw_readl(sdramc_base + AT91_DDRSDRC_LPR);
+
+ if ((mdr & AT91_DDRSDRC_MD) == AT91_DDRSDRC_MD_LOW_POWER_DDR)
+ __raw_writel((mdr & ~AT91_DDRSDRC_MD) |
+ AT91_DDRSDRC_MD_DDR2, sdramc_base +
+ AT91_DDRSDRC_MDR);
+ __raw_writel((lpr & ~AT91_DDRSDRC_LPCB) |
+ AT91_DDRSDRC_LPCB_SELF_REFRESH, sdramc_base
+ + AT91_DDRSDRC_LPR);
+
+ if (sdramc_base1) {
+ mdr1 = __raw_readl(sdramc_base1 + AT91_DDRSDRC_MDR);
+ lpr1 = __raw_readl(sdramc_base1 + AT91_DDRSDRC_LPR);
+ if ((mdr1 & AT91_DDRSDRC_MD) == AT91_DDRSDRC_MD_LOW_POWER_DDR)
+ __raw_writel((mdr1 & ~AT91_DDRSDRC_MD) |
+ AT91_DDRSDRC_MD_DDR2,
+ sdramc_base1 +
+ AT91_DDRSDRC_MDR);
+ __raw_writel((lpr1 & ~AT91_DDRSDRC_LPCB) |
+ AT91_DDRSDRC_LPCB_SELF_REFRESH,
+ sdramc_base1 + AT91_DDRSDRC_LPR);
+ }
+ } else {
+ __raw_writel(mdr, sdramc_base + AT91_DDRSDRC_MDR);
+ __raw_writel(lpr, sdramc_base + AT91_DDRSDRC_LPR);
+ if (sdramc_base1) {
+ __raw_writel(mdr, sdramc_base1 + AT91_DDRSDRC_MDR);
+ __raw_writel(lpr, sdramc_base1 + AT91_DDRSDRC_LPR);
+ }
+ }
+ break;
+
+ case AT91_MEMCTRL_SDRAMC:
+ if (is_active) {
+ lpr = __raw_readl(sdramc_base + AT91_SDRAMC_LPR);
+
+ __raw_writel((lpr & ~AT91_SDRAMC_LPCB) |
+ AT91_SDRAMC_LPCB_SELF_REFRESH, sdramc_base
+ + AT91_SDRAMC_LPR);
+ } else {
+ __raw_writel(lpr, sdramc_base + AT91_SDRAMC_LPR);
+ }
+ break;
+ }
+}
+
+void atmel_pm_suspend(void __iomem *pmc, void __iomem *ramc0,
+ void __iomem *ramc1, int memctrl)
+{
+ int memtype, pm_mode;
+
+ memtype = memctrl & AT91_PM_MEMTYPE_MASK;
+ pm_mode = (memctrl >> AT91_PM_MODE_OFFSET) & AT91_PM_MODE_MASK;
+
+ dsb();
+
+ at91_sramc_self_refresh(1, memtype, ramc0, ramc1);
+
+#if defined(CONFIG_CPU_V7)
+ dsb();
+ wfi();
+#else
+ asm volatile ("mcr p15, 0, %0, c7, c0, 4" \
+ : : "r" (0) : "memory");
+#endif
+
+ at91_sramc_self_refresh(0, memtype, ramc0, ramc1);
+}
+EXPORT_PIE_SYMBOL(atmel_pm_suspend);
diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S
deleted file mode 100644
index a25defda3d22..000000000000
--- a/arch/arm/mach-at91/pm_suspend.S
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * arch/arm/mach-at91/pm_slow_clock.S
- *
- * Copyright (C) 2006 Savin Zlobec
- *
- * AT91SAM9 support:
- * Copyright (C) 2007 Anti Sullin <anti.sullin@artecdesign.ee
- *
- * 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/linkage.h>
-#include <linux/clk/at91_pmc.h>
-#include "pm.h"
-
-#define SRAMC_SELF_FRESH_ACTIVE 0x01
-#define SRAMC_SELF_FRESH_EXIT 0x00
-
-pmc .req r0
-tmp1 .req r4
-tmp2 .req r5
-
-/*
- * Wait until master clock is ready (after switching master clock source)
- */
- .macro wait_mckrdy
-1: ldr tmp1, [pmc, #AT91_PMC_SR]
- tst tmp1, #AT91_PMC_MCKRDY
- beq 1b
- .endm
-
-/*
- * Wait until master oscillator has stabilized.
- */
- .macro wait_moscrdy
-1: ldr tmp1, [pmc, #AT91_PMC_SR]
- tst tmp1, #AT91_PMC_MOSCS
- beq 1b
- .endm
-
-/*
- * Wait until PLLA has locked.
- */
- .macro wait_pllalock
-1: ldr tmp1, [pmc, #AT91_PMC_SR]
- tst tmp1, #AT91_PMC_LOCKA
- beq 1b
- .endm
-
-/*
- * Put the processor to enter the idle state
- */
- .macro at91_cpu_idle
-
-#if defined(CONFIG_CPU_V7)
- mov tmp1, #AT91_PMC_PCK
- str tmp1, [pmc, #AT91_PMC_SCDR]
-
- dsb
-
- wfi @ Wait For Interrupt
-#else
- mcr p15, 0, tmp1, c7, c0, 4
-#endif
-
- .endm
-
- .text
-
- .arm
-
-/*
- * void at91_pm_suspend_in_sram(void __iomem *pmc, void __iomem *sdramc,
- * void __iomem *ramc1, int memctrl)
- * @input param:
- * @r0: base address of AT91_PMC
- * @r1: base address of SDRAM Controller (SDRAM, DDRSDR, or AT91_SYS)
- * @r2: base address of second SDRAM Controller or 0 if not present
- * @r3: pm information
- */
-/* at91_pm_suspend_in_sram must be 8-byte aligned per the requirements of fncpy() */
- .align 3
-ENTRY(at91_pm_suspend_in_sram)
- /* Save registers on stack */
- stmfd sp!, {r4 - r12, lr}
-
- /* Drain write buffer */
- mov tmp1, #0
- mcr p15, 0, tmp1, c7, c10, 4
-
- str r0, .pmc_base
- str r1, .sramc_base
- str r2, .sramc1_base
-
- and r0, r3, #AT91_PM_MEMTYPE_MASK
- str r0, .memtype
-
- lsr r0, r3, #AT91_PM_MODE_OFFSET
- and r0, r0, #AT91_PM_MODE_MASK
- str r0, .pm_mode
-
- /* Active the self-refresh mode */
- mov r0, #SRAMC_SELF_FRESH_ACTIVE
- bl at91_sramc_self_refresh
-
- ldr r0, .pm_mode
- tst r0, #AT91_PM_SLOW_CLOCK
- beq skip_disable_main_clock
-
- ldr pmc, .pmc_base
-
- /* Save Master clock setting */
- ldr tmp1, [pmc, #AT91_PMC_MCKR]
- str tmp1, .saved_mckr
-
- /*
- * Set the Master clock source to slow clock
- */
- bic tmp1, tmp1, #AT91_PMC_CSS
- str tmp1, [pmc, #AT91_PMC_MCKR]
-
- wait_mckrdy
-
- /* Save PLLA setting and disable it */
- ldr tmp1, [pmc, #AT91_CKGR_PLLAR]
- str tmp1, .saved_pllar
-
- mov tmp1, #AT91_PMC_PLLCOUNT
- orr tmp1, tmp1, #(1 << 29) /* bit 29 always set */
- str tmp1, [pmc, #AT91_CKGR_PLLAR]
-
- /* Turn off the main oscillator */
- ldr tmp1, [pmc, #AT91_CKGR_MOR]
- bic tmp1, tmp1, #AT91_PMC_MOSCEN
- orr tmp1, tmp1, #AT91_PMC_KEY
- str tmp1, [pmc, #AT91_CKGR_MOR]
-
-skip_disable_main_clock:
- ldr pmc, .pmc_base
-
- /* Wait for interrupt */
- at91_cpu_idle
-
- ldr r0, .pm_mode
- tst r0, #AT91_PM_SLOW_CLOCK
- beq skip_enable_main_clock
-
- ldr pmc, .pmc_base
-
- /* Turn on the main oscillator */
- ldr tmp1, [pmc, #AT91_CKGR_MOR]
- orr tmp1, tmp1, #AT91_PMC_MOSCEN
- orr tmp1, tmp1, #AT91_PMC_KEY
- str tmp1, [pmc, #AT91_CKGR_MOR]
-
- wait_moscrdy
-
- /* Restore PLLA setting */
- ldr tmp1, .saved_pllar
- str tmp1, [pmc, #AT91_CKGR_PLLAR]
-
- tst tmp1, #(AT91_PMC_MUL & 0xff0000)
- bne 3f
- tst tmp1, #(AT91_PMC_MUL & ~0xff0000)
- beq 4f
-3:
- wait_pllalock
-4:
-
- /*
- * Restore master clock setting
- */
- ldr tmp1, .saved_mckr
- str tmp1, [pmc, #AT91_PMC_MCKR]
-
- wait_mckrdy
-
-skip_enable_main_clock:
- /* Exit the self-refresh mode */
- mov r0, #SRAMC_SELF_FRESH_EXIT
- bl at91_sramc_self_refresh
-
- /* Restore registers, and return */
- ldmfd sp!, {r4 - r12, pc}
-ENDPROC(at91_pm_suspend_in_sram)
-
-/*
- * void at91_sramc_self_refresh(unsigned int is_active)
- *
- * @input param:
- * @r0: 1 - active self-refresh mode
- * 0 - exit self-refresh mode
- * register usage:
- * @r1: memory type
- * @r2: base address of the sram controller
- */
-
-ENTRY(at91_sramc_self_refresh)
- ldr r1, .memtype
- ldr r2, .sramc_base
-
- cmp r1, #AT91_MEMCTRL_MC
- bne ddrc_sf
-
- /*
- * at91rm9200 Memory controller
- */
-
- /*
- * For exiting the self-refresh mode, do nothing,
- * automatically exit the self-refresh mode.
- */
- tst r0, #SRAMC_SELF_FRESH_ACTIVE
- beq exit_sramc_sf
-
- /* Active SDRAM self-refresh mode */
- mov r3, #1
- str r3, [r2, #AT91_MC_SDRAMC_SRR]
- b exit_sramc_sf
-
-ddrc_sf:
- cmp r1, #AT91_MEMCTRL_DDRSDR
- bne sdramc_sf
-
- /*
- * DDR Memory controller
- */
- tst r0, #SRAMC_SELF_FRESH_ACTIVE
- beq ddrc_exit_sf
-
- /* LPDDR1 --> force DDR2 mode during self-refresh */
- ldr r3, [r2, #AT91_DDRSDRC_MDR]
- str r3, .saved_sam9_mdr
- bic r3, r3, #~AT91_DDRSDRC_MD
- cmp r3, #AT91_DDRSDRC_MD_LOW_POWER_DDR
- ldreq r3, [r2, #AT91_DDRSDRC_MDR]
- biceq r3, r3, #AT91_DDRSDRC_MD
- orreq r3, r3, #AT91_DDRSDRC_MD_DDR2
- streq r3, [r2, #AT91_DDRSDRC_MDR]
-
- /* Active DDRC self-refresh mode */
- ldr r3, [r2, #AT91_DDRSDRC_LPR]
- str r3, .saved_sam9_lpr
- bic r3, r3, #AT91_DDRSDRC_LPCB
- orr r3, r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH
- str r3, [r2, #AT91_DDRSDRC_LPR]
-
- /* If using the 2nd ddr controller */
- ldr r2, .sramc1_base
- cmp r2, #0
- beq no_2nd_ddrc
-
- ldr r3, [r2, #AT91_DDRSDRC_MDR]
- str r3, .saved_sam9_mdr1
- bic r3, r3, #~AT91_DDRSDRC_MD
- cmp r3, #AT91_DDRSDRC_MD_LOW_POWER_DDR
- ldreq r3, [r2, #AT91_DDRSDRC_MDR]
- biceq r3, r3, #AT91_DDRSDRC_MD
- orreq r3, r3, #AT91_DDRSDRC_MD_DDR2
- streq r3, [r2, #AT91_DDRSDRC_MDR]
-
- /* Active DDRC self-refresh mode */
- ldr r3, [r2, #AT91_DDRSDRC_LPR]
- str r3, .saved_sam9_lpr1
- bic r3, r3, #AT91_DDRSDRC_LPCB
- orr r3, r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH
- str r3, [r2, #AT91_DDRSDRC_LPR]
-
-no_2nd_ddrc:
- b exit_sramc_sf
-
-ddrc_exit_sf:
- /* Restore MDR in case of LPDDR1 */
- ldr r3, .saved_sam9_mdr
- str r3, [r2, #AT91_DDRSDRC_MDR]
- /* Restore LPR on AT91 with DDRAM */
- ldr r3, .saved_sam9_lpr
- str r3, [r2, #AT91_DDRSDRC_LPR]
-
- /* If using the 2nd ddr controller */
- ldr r2, .sramc1_base
- cmp r2, #0
- ldrne r3, .saved_sam9_mdr1
- strne r3, [r2, #AT91_DDRSDRC_MDR]
- ldrne r3, .saved_sam9_lpr1
- strne r3, [r2, #AT91_DDRSDRC_LPR]
-
- b exit_sramc_sf
-
- /*
- * SDRAMC Memory controller
- */
-sdramc_sf:
- tst r0, #SRAMC_SELF_FRESH_ACTIVE
- beq sdramc_exit_sf
-
- /* Active SDRAMC self-refresh mode */
- ldr r3, [r2, #AT91_SDRAMC_LPR]
- str r3, .saved_sam9_lpr
- bic r3, r3, #AT91_SDRAMC_LPCB
- orr r3, r3, #AT91_SDRAMC_LPCB_SELF_REFRESH
- str r3, [r2, #AT91_SDRAMC_LPR]
-
-sdramc_exit_sf:
- ldr r3, .saved_sam9_lpr
- str r3, [r2, #AT91_SDRAMC_LPR]
-
-exit_sramc_sf:
- mov pc, lr
-ENDPROC(at91_sramc_self_refresh)
-
-.pmc_base:
- .word 0
-.sramc_base:
- .word 0
-.sramc1_base:
- .word 0
-.memtype:
- .word 0
-.pm_mode:
- .word 0
-.saved_mckr:
- .word 0
-.saved_pllar:
- .word 0
-.saved_sam9_lpr:
- .word 0
-.saved_sam9_lpr1:
- .word 0
-.saved_sam9_mdr:
- .word 0
-.saved_sam9_mdr1:
- .word 0
-
-ENTRY(at91_pm_suspend_in_sram_sz)
- .word .-at91_pm_suspend_in_sram
--
2.10.2
^ permalink raw reply related
* [PATCH v4 1/2] ARM: PIE infrastructure
From: Alexandre Belloni @ 2016-11-07 22:24 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161107222458.15732-1-alexandre.belloni@free-electrons.com>
Add support for embedding position independent executables (PIE) in the
kernel. Those PIEs can then be loaded into memory allocated using genalloc.
For example, this allows running code from SRAM which is usually needed for
suspend/resume or to change the DDR timings. That code is usually written
in assembly and can now be developed in C.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/Kconfig | 2 +
arch/arm/Makefile | 1 +
arch/arm/pie/Kconfig | 8 +++
arch/arm/pie/Makefile | 1 +
arch/arm/pie/Makefile.pie | 86 +++++++++++++++++++++++++++
arch/arm/pie/lib/empty.c | 15 +++++
arch/arm/pie/pie.c | 97 ++++++++++++++++++++++++++++++
arch/arm/pie/pie.lds.S | 40 +++++++++++++
include/linux/pie.h | 146 ++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 396 insertions(+)
create mode 100644 arch/arm/pie/Kconfig
create mode 100644 arch/arm/pie/Makefile
create mode 100644 arch/arm/pie/Makefile.pie
create mode 100644 arch/arm/pie/lib/empty.c
create mode 100644 arch/arm/pie/pie.c
create mode 100644 arch/arm/pie/pie.lds.S
create mode 100644 include/linux/pie.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b5d529fdffab..aba849d7a7cf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -2209,3 +2209,5 @@ endif
source "lib/Kconfig"
source "arch/arm/kvm/Kconfig"
+
+source "arch/arm/pie/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 6be9ee148b78..9acb9581853a 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -282,6 +282,7 @@ core-$(CONFIG_VFP) += arch/arm/vfp/
core-$(CONFIG_XEN) += arch/arm/xen/
core-$(CONFIG_KVM_ARM_HOST) += arch/arm/kvm/
core-$(CONFIG_VDSO) += arch/arm/vdso/
+core-$(CONFIG_PIE) += arch/arm/pie/
# If we have a machine-specific directory, then include it in the build.
core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/
diff --git a/arch/arm/pie/Kconfig b/arch/arm/pie/Kconfig
new file mode 100644
index 000000000000..d76122140561
--- /dev/null
+++ b/arch/arm/pie/Kconfig
@@ -0,0 +1,8 @@
+config PIE
+ bool
+ help
+ This option adds support for embedding position indepentant (PIE)
+ executables into the kernel. The PIEs can then be copied into
+ genalloc regions such as SRAM and executed. Some platforms require
+ this for suspend/resume support.
+
diff --git a/arch/arm/pie/Makefile b/arch/arm/pie/Makefile
new file mode 100644
index 000000000000..d1a6a823e431
--- /dev/null
+++ b/arch/arm/pie/Makefile
@@ -0,0 +1 @@
+obj-y += pie.o
diff --git a/arch/arm/pie/Makefile.pie b/arch/arm/pie/Makefile.pie
new file mode 100644
index 000000000000..4125da72bcaa
--- /dev/null
+++ b/arch/arm/pie/Makefile.pie
@@ -0,0 +1,86 @@
+obj-y := pie.bin.elf
+
+# Report unresolved symbol references
+ldflags-y += --no-undefined
+# Delete all temporary local symbols
+ldflags-y += -X
+
+GCOV_PROFILE := n
+
+KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
+
+ifeq ($(CONFIG_FUNCTION_TRACER),y)
+ORIG_CFLAGS := $(KBUILD_CFLAGS)
+KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
+endif
+
+# Reset objcopy flags
+OBJCOPYFLAGS =
+
+$(obj)/empty.o: arch/arm/pie/lib/empty.c FORCE
+ $(call if_changed_rule,cc_o_c)
+
+# Reference gcc builtins for use in PIE with __pie_
+$(obj)/pie_rename.syms: $(obj)/empty.o
+ @$(NM) $^ | awk '{if ($$3) print $$3,"__pie_"$(PIE_NAME)$$3}' > $@
+
+# For embedding address of the symbols copied from the PIE into the kernel
+$(obj)/pie.syms: $(obj)/pie.elf
+ @$(NM) $^ | awk '{if ($$3 && $$2 == toupper($$2)) print $$3,"=","0x"$$1";"}' > $@
+
+# Collect together the libpie objects
+LDFLAGS_libpie_stage1.o += -r
+
+$(obj)/libpie_stage1.o: $(obj)/empty.o
+ $(call if_changed,ld)
+
+# Rename the libpie gcc builtins with a __pie_ prefix
+OBJCOPYFLAGS_libpie_stage2.o += --redefine-syms=$(obj)/pie_rename.syms
+
+$(obj)/libpie_stage2.o: $(obj)/libpie_stage1.o
+ $(call if_changed,objcopy)
+
+CFLAGS_$(PIE_NAME).o += -fPIE
+
+OBJCOPYFLAGS_pie_stage1.o += --redefine-syms=$(obj)/pie_rename.syms
+$(obj)/pie_stage1.o: $(obj)/$(PIE_NAME).o $(obj)/pie_rename.syms
+ $(call if_changed,objcopy)
+
+LDFLAGS_pie_stage2.o += -r
+
+$(obj)/pie_stage2.o: $(obj)/pie_stage1.o $(obj)/libpie_stage2.o
+ $(call if_changed,ld)
+
+SEDFLAGS_lds = s/PIE_NAME/$(PIE_NAME)/
+$(obj)/pie.lds.S: arch/arm/pie/pie.lds.S
+ @sed "$(SEDFLAGS_lds)" < $< > $@
+
+# Create the position independent executable
+LDFLAGS_pie.elf += -Bstatic -T $(obj)/pie.lds
+
+$(obj)/pie.elf: $(obj)/pie_stage2.o $(obj)/pie.lds
+ $(call if_changed,ld)
+
+# Create binary data for the kernel
+OBJCOPYFLAGS_pie.bin += -O binary
+
+$(obj)/pie.bin: $(obj)/pie.elf
+ $(call if_changed,objcopy)
+
+# Import the data into the kernel
+ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
+OBJCOPYFLAGS_pie.bin.o += -B $(ARCH) -I binary -O elf32-bigarm
+else
+OBJCOPYFLAGS_pie.bin.o += -B $(ARCH) -I binary -O elf32-littlearm
+endif
+
+$(obj)/pie.al.c: $(obj)/pie.elf
+ @$(OBJDUMP) -h --section .text $^ | awk '{sub(/2\*\*/,"(1 << ",$$7);if ($$2 == ".text") print "unsigned int __pie_$(PIE_NAME)_align = "$$7");"}' > $@
+
+$(obj)/pie.bin.o: $(obj)/pie.bin
+ $(call if_changed,objcopy)
+
+LDFLAGS_pie.bin.elf += --just-symbols=$(obj)/pie.syms -r
+$(obj)/pie.bin.elf: $(obj)/pie.bin.o $(obj)/pie.al.o $(obj)/pie.syms
+ $(call if_changed,ld)
+
diff --git a/arch/arm/pie/lib/empty.c b/arch/arm/pie/lib/empty.c
new file mode 100644
index 000000000000..9a6d54956379
--- /dev/null
+++ b/arch/arm/pie/lib/empty.c
@@ -0,0 +1,15 @@
+void __div0(void)
+{
+};
+
+void __aeabi_unwind_cpp_pr0(void)
+{
+};
+
+void __aeabi_unwind_cpp_pr1(void)
+{
+};
+
+void __aeabi_unwind_cpp_pr2(void)
+{
+};
diff --git a/arch/arm/pie/pie.c b/arch/arm/pie/pie.c
new file mode 100644
index 000000000000..b32aa4cb11a8
--- /dev/null
+++ b/arch/arm/pie/pie.c
@@ -0,0 +1,97 @@
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/genalloc.h>
+#include <linux/pie.h>
+#include <asm/cacheflush.h>
+
+struct pie_chunk {
+ struct gen_pool *pool;
+ unsigned long addr;
+ unsigned int align_offset;
+ size_t sz;
+};
+
+struct pie_chunk *__pie_load_data(struct gen_pool *pool, void *code_start,
+ void *code_end, unsigned int align)
+{
+ struct pie_chunk *chunk;
+ unsigned long offset;
+ int ret;
+ size_t code_sz;
+ unsigned long base;
+ phys_addr_t pbase;
+
+ chunk = kzalloc(sizeof(*chunk), GFP_KERNEL);
+ if (!chunk) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ code_sz = code_end - code_start;
+ chunk->pool = pool;
+ chunk->sz = code_sz;
+
+ base = gen_pool_alloc(pool, chunk->sz + align);
+ if (!base) {
+ ret = -ENOMEM;
+ goto err_free;
+ }
+
+ pbase = gen_pool_virt_to_phys(pool, base);
+ chunk->addr = (unsigned long)__arm_ioremap_exec(pbase, code_sz, false);
+ if (!chunk->addr) {
+ ret = -ENOMEM;
+ goto err_remap;
+ }
+
+ chunk->align_offset = chunk->addr % align;
+ chunk->addr += chunk->align_offset;
+
+ memcpy((char *)chunk->addr, code_start, code_sz);
+ flush_icache_range(chunk->addr, chunk->addr + code_sz);
+
+ offset = gen_pool_virt_to_phys(pool, chunk->addr);
+
+ return chunk;
+
+err_remap:
+ gen_pool_free(chunk->pool, chunk->addr, chunk->sz);
+
+err_free:
+ kfree(chunk);
+err:
+ return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(__pie_load_data);
+
+phys_addr_t pie_to_phys(struct pie_chunk *chunk, unsigned long addr)
+{
+ return gen_pool_virt_to_phys(chunk->pool, addr);
+}
+EXPORT_SYMBOL_GPL(pie_to_phys);
+
+void __iomem *__kern_to_pie(struct pie_chunk *chunk, void *ptr)
+{
+ uintptr_t offset = (uintptr_t)ptr;
+
+ if (offset >= chunk->sz)
+ return NULL;
+ else
+ return (void *)(chunk->addr + offset);
+}
+EXPORT_SYMBOL_GPL(__kern_to_pie);
+
+void pie_free(struct pie_chunk *chunk)
+{
+ gen_pool_free(chunk->pool, chunk->addr, chunk->sz);
+ kfree(chunk);
+}
+EXPORT_SYMBOL_GPL(pie_free);
diff --git a/arch/arm/pie/pie.lds.S b/arch/arm/pie/pie.lds.S
new file mode 100644
index 000000000000..e640c93f5bc8
--- /dev/null
+++ b/arch/arm/pie/pie.lds.S
@@ -0,0 +1,40 @@
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+
+#include <linux/export.h>
+
+SECTIONS
+{
+ /* Don't need unwind tables */
+ /DISCARD/ : {
+ *(.ARM.exidx*)
+ *(.ARM.extab*)
+ *(.comment)
+ }
+
+ . = 0x0;
+
+ ____pie_PIE_NAME_start : {
+ VMLINUX_SYMBOL(__pie_PIE_NAME_start) = .;
+ }
+
+ .text : {
+ . = ALIGN(4);
+ KEEP(*(.text))
+ }
+
+ .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) }
+ . = ALIGN(4);
+
+ .data : {
+ *(SORT_BY_ALIGNMENT(.data*))
+ . = ALIGN(4);
+
+ *(SORT_BY_ALIGNMENT(.bss*))
+ . = ALIGN(4);
+ }
+
+ ____pie_PIE_NAME_end : {
+ VMLINUX_SYMBOL(__pie_PIE_NAME_end) = .;
+ }
+}
diff --git a/include/linux/pie.h b/include/linux/pie.h
new file mode 100644
index 000000000000..cec58384dda2
--- /dev/null
+++ b/include/linux/pie.h
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2013 Texas Instruments, Inc.
+ * Russ Dill <russ.dill@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#ifndef _LINUX_PIE_H
+#define _LINUX_PIE_H
+
+#include <linux/kernel.h>
+#include <linux/err.h>
+
+#include <asm/fncpy.h>
+#include <linux/bug.h>
+
+struct gen_pool;
+struct pie_chunk;
+
+#ifdef CONFIG_PIE
+
+/**
+ * __pie_load_data - load and fixup PIE code from kernel data
+ * @pool: pool to allocate memory from and copy code into
+ * @start: virtual start address in kernel of chunk specific code
+ * @end: virtual end address in kernel of chunk specific code
+ * @phys: %true to fixup to physical address of destination, %false to
+ * fixup to virtual address of destination
+ *
+ * Returns 0 on success, -EERROR otherwise
+ */
+struct pie_chunk *__pie_load_data(struct gen_pool *pool, void *start, void *end,
+ unsigned int align);
+
+/**
+ * pie_to_phys - translate a virtual PIE address into a physical one
+ * @chunk: identifier returned by pie_load_sections
+ * @addr: virtual address within pie chunk
+ *
+ * Returns physical address on success, -1 otherwise
+ */
+phys_addr_t pie_to_phys(struct pie_chunk *chunk, unsigned long addr);
+
+void __iomem *__kern_to_pie(struct pie_chunk *chunk, void *ptr);
+
+/**
+ * pie_free - free the pool space used by an pie chunk
+ * @chunk: identifier returned by pie_load_sections
+ */
+void pie_free(struct pie_chunk *chunk);
+
+#define __pie_load_sections(pool, name, folder) ({ \
+ extern char _binary_##folder##_pie_bin_start[]; \
+ extern char __pie_##name##_start[]; \
+ extern char __pie_##name##_end[]; \
+ extern unsigned int __pie_##name##_align; \
+ char *start = _binary_##folder##_pie_bin_start + \
+ (unsigned long)__pie_##name##_start; \
+ char *end = _binary_##folder##_pie_bin_start + \
+ (unsigned long)__pie_##name##_end; \
+ __pie_load_data(pool, start, end, __pie_##name##_align); \
+})
+
+/*
+ * Required for any symbol within an PIE section that is referenced by the
+ * kernel
+ */
+#define EXPORT_PIE_SYMBOL(sym) extern typeof(sym) sym __weak
+
+#else
+
+static inline struct pie_chunk *__pie_load_data(struct gen_pool *pool,
+ void *start, void *end,
+ unsigned int algin)
+{
+ return ERR_PTR(-EINVAL);
+}
+
+static inline phys_addr_t pie_to_phys(struct pie_chunk *chunk,
+ unsigned long addr)
+{
+ return -1;
+}
+
+static inline void __iomem *__kern_to_pie(struct pie_chunk *chunk, void *ptr)
+{
+ return NULL;
+}
+
+static inline void pie_free(struct pie_chunk *chunk)
+{
+}
+
+#define __pie_load_sections(pool, name, folder, phys) ({ ERR_PTR(-EINVAL); })
+
+#endif
+
+/**
+ * pie_load_sections - load and fixup sections associated with the given name
+ * @pool: pool to allocate memory from and copy code into
+ * fixup to virtual address of destination
+ * @name: the name given to __pie() and __pie_data() when marking
+ * data and code
+ *
+ * Returns 0 on success, -EERROR otherwise
+ */
+#define pie_load_sections(pool, name, folder) ({ \
+ __pie_load_sections(pool, name, folder); \
+})
+
+/**
+ * kern_to_pie - convert a kernel symbol to the virtual address of where
+ * that symbol is loaded into the given PIE chunk.
+ *
+ * @chunk: identifier returned by pie_load_sections
+ * @p: symbol to convert
+ *
+ * Return type is the same as type passed
+ */
+#define kern_to_pie(chunk, p) ({ \
+ void *__ptr = (void *)(p); \
+ typeof(p) __result = (typeof(p))__kern_to_pie(chunk, __ptr); \
+ __result; \
+})
+
+/**
+ * kern_to_fn - convert a kernel function symbol to the virtual address of where
+ * that symbol is loaded into the given PIE chunk
+ *
+ * @chunk: identifier returned by pie_load_sections
+ * @funcp: function to convert
+ *
+ * Return type is the same as type passed
+ */
+#define fn_to_pie(chunk, funcp) ({ \
+ uintptr_t __kern_addr, __pie_addr; \
+ \
+ __kern_addr = (uintptr_t)funcp; \
+ __pie_addr = kern_to_pie(chunk, __kern_addr); \
+ \
+ (typeof(&funcp))(__pie_addr); \
+})
+
+#endif
--
2.10.2
^ permalink raw reply related
* [PATCH v4 0/2] ARM: Embedding Position Independent Executables
From: Alexandre Belloni @ 2016-11-07 22:24 UTC (permalink / raw)
To: linux-arm-kernel
This series introduces Position Independent Executables (PIEs) for the
ARM architecture.
The main goal is to avoid having to write low level code in assembly as
this is currently the case for suspend/resume. Multiple platforms will
benefit from this infrastructure: at91, rockchip, am335x.
It would also be beneficial for the LPDDR support on at91 to avoid
having the handle the DDR controller from 4 different drivers.
Russell, do you see any remaining issues with the current approach?
Changes in v4:
- rebased on v4.9-rc1
- Fixed an issue with the alignment reported by Mylene
Changes in v3:
- rebased on v4.8-rc1
Changes in v2:
- handle big endian
- handle gcov and ftrace by disabling them before compilling the PIE
- Get the alignment from the original ELF to ensure the PIE is
properly aligned in SRAM.
- stop using fncpy
- rebased on v4.7-rc1
Alexandre Belloni (2):
ARM: PIE infrastructure
ARM: at91: pm: switch to the PIE infrastructure
arch/arm/Kconfig | 2 +
arch/arm/Makefile | 1 +
arch/arm/mach-at91/Kconfig | 1 +
arch/arm/mach-at91/Makefile | 2 +-
arch/arm/mach-at91/pm.c | 31 ++--
arch/arm/mach-at91/pm/.gitignore | 2 +
arch/arm/mach-at91/pm/Makefile | 3 +
arch/arm/mach-at91/pm/atmel_pm.c | 97 +++++++++++
arch/arm/mach-at91/pm_suspend.S | 338 ---------------------------------------
arch/arm/pie/Kconfig | 8 +
arch/arm/pie/Makefile | 1 +
arch/arm/pie/Makefile.pie | 86 ++++++++++
arch/arm/pie/lib/empty.c | 15 ++
arch/arm/pie/pie.c | 97 +++++++++++
arch/arm/pie/pie.lds.S | 40 +++++
include/linux/pie.h | 146 +++++++++++++++++
16 files changed, 510 insertions(+), 360 deletions(-)
create mode 100644 arch/arm/mach-at91/pm/.gitignore
create mode 100644 arch/arm/mach-at91/pm/Makefile
create mode 100644 arch/arm/mach-at91/pm/atmel_pm.c
delete mode 100644 arch/arm/mach-at91/pm_suspend.S
create mode 100644 arch/arm/pie/Kconfig
create mode 100644 arch/arm/pie/Makefile
create mode 100644 arch/arm/pie/Makefile.pie
create mode 100644 arch/arm/pie/lib/empty.c
create mode 100644 arch/arm/pie/pie.c
create mode 100644 arch/arm/pie/pie.lds.S
create mode 100644 include/linux/pie.h
--
2.10.2
^ permalink raw reply
* [PATCH 2/2] ARM64: configs: Add Platform MHU in defconfig
From: Kevin Hilman @ 2016-11-07 22:06 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1478164284-24958-3-git-send-email-narmstrong@baylibre.com>
Neil Armstrong <narmstrong@baylibre.com> writes:
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
> arch/arm64/configs/defconfig | 1 +
> 1 file changed, 1 insertion(+)
Applied.
Kevin
^ permalink raw reply
* [PATCH 3/3] ARM64: dts: marvell: Fixup memory DT warning for Armada 37xx
From: Gregory CLEMENT @ 2016-11-07 21:41 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161107214128.18401-1-gregory.clement@free-electrons.com>
memory has a reg property so the unit name should contain an address.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm64/boot/dts/marvell/armada-3720-db.dts | 2 +-
arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/boot/dts/marvell/armada-3720-db.dts b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
index 1372e9a6aaa4..a260ae25b658 100644
--- a/arch/arm64/boot/dts/marvell/armada-3720-db.dts
+++ b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
@@ -56,7 +56,7 @@
stdout-path = "serial0:115200n8";
};
- memory {
+ memory at 0 {
device_type = "memory";
reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
};
diff --git a/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts b/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts
index eadd5993c7bd..83178d909fc2 100644
--- a/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts
+++ b/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts
@@ -55,7 +55,7 @@
stdout-path = "serial0:115200n8";
};
- memory {
+ memory at 0 {
device_type = "memory";
reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
};
--
2.10.1
^ permalink raw reply related
* [PATCH 2/3] arm64: dts: marvell: Fixup config-space DT warning For Armada 7K/8K
From: Gregory CLEMENT @ 2016-11-07 21:41 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161107214128.18401-1-gregory.clement@free-electrons.com>
config-space has a ranges property so the unit name should contain an
address.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm64/boot/dts/marvell/armada-ap806.dtsi | 2 +-
arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi | 2 +-
arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
index 7b6136182ad0..a749ba2edec4 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
@@ -71,7 +71,7 @@
interrupt-parent = <&gic>;
ranges;
- config-space {
+ config-space at f0000000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
index e5e3ed678b6f..607e9a3ef834 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
@@ -52,7 +52,7 @@
interrupt-parent = <&gic>;
ranges;
- config-space {
+ config-space at f2000000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
index 842fb333285c..88e74069c666 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
@@ -52,7 +52,7 @@
interrupt-parent = <&gic>;
ranges;
- config-space {
+ config-space at f4000000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
--
2.10.1
^ permalink raw reply related
* [PATCH 1/3] arm64: dts: marvell: Fixup internal-regs DT warning for Armada 37xx
From: Gregory CLEMENT @ 2016-11-07 21:41 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161107214128.18401-1-gregory.clement@free-electrons.com>
internal-regs has a ranges property so the unit name should contain an
address.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
index c4762538ec01..f1596daa2bc7 100644
--- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
@@ -91,7 +91,7 @@
#size-cells = <2>;
ranges;
- internal-regs {
+ internal-regs at d0000000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
--
2.10.1
^ permalink raw reply related
* [PATCH 0/3] Various ARM64 Armada DT warning fixup
From: Gregory CLEMENT @ 2016-11-07 21:41 UTC (permalink / raw)
To: linux-arm-kernel
Following the series sent for Armada 370/XP, this patchset fixes up
various warning from the DT compiler when using the flag W=1 with
make.
Being a fresh new port, the arm64 we did a better job for dt than for
the arm32 so there is only a few patches needed.
Gregory
Gregory CLEMENT (3):
arm64: dts: marvell: Fixup internal-regs DT warning for Armada 37xx
arm64: dts: marvell: Fixup config-space DT warning For Armada 7K/8K
ARM64: dts: marvell: Fixup memory DT warning for Armada 37xx
arch/arm64/boot/dts/marvell/armada-3720-db.dts | 2 +-
arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts | 2 +-
arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 2 +-
arch/arm64/boot/dts/marvell/armada-ap806.dtsi | 2 +-
arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi | 2 +-
arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
--
2.10.1
^ permalink raw reply
* [PATCH 0/3] Add memremap executable mapping and extend drivers/misc/sram.c
From: Dave Gerlach @ 2016-11-07 21:34 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161107174309.GC2428@atomide.com>
On 11/07/2016 11:43 AM, Tony Lindgren wrote:
> * Russell King - ARM Linux <linux@armlinux.org.uk> [161107 04:05]:
>> On Thu, Oct 27, 2016 at 01:56:09PM -0500, Dave Gerlach wrote:
>>> There are several instances when one would want to execute out of on-chip
>>> SRAM, such as PM code on ARM platforms, so once again revisiting this
>>> series to allow that in a generic manner. Seems that having a solution for
>>> allowing SRAM to be mapped as executable will help clean up PM code on several
>>> ARM platforms that are using ARM internal __arm_ioremap_exec API
>>> and also open the door for PM support on new platforms like TI AM335x and
>>> AM437x. This was last sent as RFC here [1] and based on comments from Russell
>>> King and Arnd Bergmann has been rewritten to use memremap API rather than
>>> ioremap API, as executable iomem does not really make sense.
>>
>> This is better, as it avoids the issue that I pointed out last time
>> around, but I'm still left wondering about the approach.
>>
>> Sure, having executable SRAM mappings sounds nice and easy, but we're
>> creating WX mappings. Folk have spent a while improving the security of
>> the kernel by ensuring that there are no WX mappings, and this series
>> reintroduces them. The sad thing is that any WX mapping which appears
>> at a known address can be exploited.
>>
>> "A known address" can be something that appears to be random, but ends
>> up being the same across the same device type... or can be discovered
>> by some means. Eg, consider if the WX mapping is dynamically allocated,
>> but occurs at exactly the same point at boot - and if this happens with
>> android phones, consider how many of those are out there. Or if the
>> address of the WX mapping is available via some hardware register.
>> Or...
>>
>> See Kees Cook's slides at last years kernel summit -
>> https://outflux.net/slides/2015/ks/security.pdf
>>
>> So, I think avoiding WX mappings - mappings should be either W or X but
>> not both simultaneously (see page 19.)
>>
>> I guess what I'm angling at is that we don't want memremap_exec(), but
>> we need an API which changes the permissions of a SRAM mapping between
>> allowing writes and allowing execution.
>
> That should work just fine. So first copy the code to SRAM,
> then set it read-only and exectuable. Note that we need to
> restore the state of SRAM every time when returning from
> off mode during idle on some SoCs.
Thanks for all the comments. This seems like a reasonable concern. I do
agree that we would need to be able to briefly restore write permission
for things like Tony has described.
In fact, I suppose we would need this ability for every copy so that we
switch from exec to write and do the copy, then switch back to read-only
executable. We have situations where we copy multiple things, from
drivers that don't necessarily have knowledge of one another to the SRAM
space at different times.
Any opinions on where this API should live?
Regards,
Dave
>
> Regards,
>
> Tony
>
^ permalink raw reply
* [GIT PULL] ARM: OXNAS SoC updates for 4.10
From: Olof Johansson @ 2016-11-07 21:26 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1305c61f-b1ef-7caf-7788-67e2b907e873@baylibre.com>
On Mon, Oct 31, 2016 at 10:52:53AM +0100, Neil Armstrong wrote:
> Dear arm-soc maintainers,
>
> The following changes since commit 1001354ca34179f3db924eb66672442a173147dc:
>
> Linux 4.9-rc1 (2016-10-15 12:17:50 -0700)
>
> are available in the git repository at:
>
> https://github.com/OXNAS/linux.git tags/oxnas-arm-soc-for-4.10
>
> for you to fetch changes up to b3cdb3c5ef514687891f03442f2677850340bcfa:
>
> ARM: oxnas: Add OX820 config and makefile entry (2016-10-31 10:41:33 +0100)
>
> ----------------------------------------------------------------
> - Add SMP support for the Oxford Semiconductor OX820 SoC
> from http://lkml.kernel.org/r/20161021085848.1754-1-narmstrong at baylibre.com
>
> ----------------------------------------------------------------
> Neil Armstrong (2):
> ARM: oxnas: Add OX820 SMP support
> ARM: oxnas: Add OX820 config and makefile entry
Hi Neil,
Sorry for being picky here, please be patient with us. :-)
Overall comments on this patch set:
1) Copyrights seem to be a bit varied. All 3 new source files have
different copyright holders. Only one has yours, one is from 2003, one
is also from 2013. Is this expected? Seems like it's worth mentioning
in commit messages at least.
2) Please remove the linux/arch/... lines from the top of the files. It's
something we've been trying to remove for a while and don't want to
introduce more occurrances of.
I'd say (2) is fine to do incremental, but please provide clarification on (1).
I could just add that to the merge commit message so don't respin the branch
yet, depending on what we hear back!
> arch/arm/Makefile | 1 +
> arch/arm/mach-oxnas/Kconfig | 30 +++++++++++++++++++---------
> arch/arm/mach-oxnas/Makefile | 2 ++
> arch/arm/mach-oxnas/headsmp.S | 28 ++++++++++++++++++++++++++
> arch/arm/mach-oxnas/hotplug.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> arch/arm/mach-oxnas/platsmp.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Git tip: If you redirect the output to a file (or pipe through cat), the
diffstat will be limited to 80 characters and look better in email.
Thanks,
-Olof
^ permalink raw reply
* [v15, 3/7] powerpc/fsl: move mpc85xx.h to include/linux/fsl
From: Arnd Bergmann @ 2016-11-07 21:20 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <DB6PR0401MB2536B1B2E6AC36BDC8FC540DF8AE0@DB6PR0401MB2536.eurprd04.prod.outlook.com>
On Monday, October 31, 2016 9:35:33 AM CET Y.B. Lu wrote:
> >
> > I don't see any of the contents of this header referenced by the soc
> > driver any more. I think you can just drop this patch.
> >
>
> [Lu Yangbo-B47093] This header file was included by guts.c.
> The guts driver used macro SVR_MAJ/SVR_MIN for calculation.
>
> This header file was for powerpc arch before. And this patch is to made it as
> common header file for both ARM and PPC.
> Sooner or later this is needed.
Let's discuss it once we actually need the header then, ok?
Arnd
^ permalink raw reply
* [PATCH] ARM: zx: Fix error handling
From: Olof Johansson @ 2016-11-07 21:18 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161030081010.14735-1-christophe.jaillet@wanadoo.fr>
On Sun, Oct 30, 2016 at 09:10:10AM +0100, Christophe JAILLET wrote:
> 'devm_ioremap_resource()' returns an error pointer in case of error, not
> NULL. So test it with IS_ERR.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> 'return -EIO;' could also be turned into 'return PTR_ERR(pcubase);' in
> order to propagate the error value.
Applied to fixes-non-critical. Thanks!
-Olof
^ permalink raw reply
* [PATCH] ARM: spear: Fix error handling
From: Olof Johansson @ 2016-11-07 21:16 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161029135839.6388-1-christophe.jaillet@wanadoo.fr>
On Sat, Oct 29, 2016 at 03:58:39PM +0200, Christophe JAILLET wrote:
> 'clk_get_sys()' returns an error pointer in case of error, not NULL. So
> test it with IS_ERR.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Applied to fixes-non-critical, thanks.
-Olof
^ permalink raw reply
* [PATCH RFC 4/7] ASoC: samsung: i2s: Do not use platform_data for DMA parameters
From: Arnd Bergmann @ 2016-11-07 21:14 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <c4388f30-702b-895b-5280-6fabf8e7bfe1@samsung.com>
On Monday, November 7, 2016 5:02:54 PM CET Sylwester Nawrocki wrote:
> On 11/05/2016 12:29 AM, Arnd Bergmann wrote:
> > On Friday 04 November 2016, Sylwester Nawrocki wrote:
> >> > - ret = samsung_asoc_dma_platform_register(&pdev->dev, pri_dai->filter,
> >> > + ret = samsung_asoc_dma_platform_register(&pdev->dev, NULL,
> >> > NULL, NULL);
> >
> > If we remove the filter argument from every caller here, maybe we should also
> > change the prototype to not expect those three NULL arguments any more.
>
> There is one occurrence where the third argument needs to be not NULL.
> I'm planning to modify sound/sound/samsung/i2s.c so there is no need
> to create another platform device just for the overlay DAI, afterwards
> the above function could be simplified.
Ok, sounds good.
Arnd
^ permalink raw reply
* [PATCH] arm64: mm: Fix memmap to be initialized for the entire section
From: Will Deacon @ 2016-11-07 21:05 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161028091905.GM22012@rric.localdomain>
On Fri, Oct 28, 2016 at 11:19:05AM +0200, Robert Richter wrote:
> On 27.10.16 17:01:36, Will Deacon wrote:
> > It feels to me like NOMAP memory is a new type
> > of memory where there *is* a struct page, but it shouldn't be used for
> > anything.
>
> IMO, a NOMAP page should just be handled like a reserved page except
> that the page is marked reserved. See free_low_memory_core_early().
> Thus, NOMAP pages are not in the free pages list or set to reserved.
> It is simply not available for mapping at all. Isn't that exactly what
> it should be?
>
> I also did not yet understand the benefit of the differentiation
> between NOMAP and reserved and the original motivation for its
> implementation. I looked through the mail threads but could not find
> any hint. The only difference I see now is that it is not listed as a
> reserved page, but as long as it is not freed it should behave the
> same. I remember the case to handle memory different (coherency,
> etc.), but are not sure here. Ard, could you explain this?
>
> > I don't think pfn_valid can describe that, given the way it's
> > currently used, and flipping the logic is just likely to move the problem
> > elsewhere.
> >
> > What options do we have for fixing this in the NUMA code?
>
> Out of my mind:
>
> 1) Treat NOMAP pages same as reserved pages (my patch).
Just to reiterate here, but your patch as it stands will break other parts
of the kernel. For example, acpi_os_ioremap relies on being able to ioremap
these regions afaict.
I think any solution involving pfn_valid is just going to move the crash
around.
Will
^ permalink raw reply
* [PATCH v2] iommu/arm-smmu: Fix out-of-bounds dereference
From: Will Deacon @ 2016-11-07 20:43 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <3e31e04e167e2b12fc814c22a0b6902bd4f926f2.1478543109.git.robin.murphy@arm.com>
On Mon, Nov 07, 2016 at 06:25:09PM +0000, Robin Murphy wrote:
> When we iterate a master's config entries, what we generally care
> about is the entry's stream map index, rather than the entry index
> itself, so it's nice to have the iterator automatically assign the
> former from the latter. Unfortunately, booting with KASAN reveals
> the oversight that using a simple comma operator results in the
> entry index being dereferenced before being checked for validity,
> so we always access one element past the end of the fwspec array.
>
> Flip things around so that the check always happens before the index
> may be dereferenced.
>
> Fixes: adfec2e709d2 ("iommu/arm-smmu: Convert to iommu_fwspec")
> Reported-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/iommu/arm-smmu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> index f86683eec446..786d33900382 100644
> --- a/drivers/iommu/arm-smmu.c
> +++ b/drivers/iommu/arm-smmu.c
> @@ -324,8 +324,10 @@ struct arm_smmu_master_cfg {
> #define INVALID_SMENDX -1
> #define __fwspec_cfg(fw) ((struct arm_smmu_master_cfg *)fw->iommu_priv)
> #define fwspec_smmu(fw) (__fwspec_cfg(fw)->smmu)
> +#define fwspec_smendx(fw, i) \
> + (i >= fw->num_ids ? INVALID_SMENDX : __fwspec_cfg(fw)->smendx[i])
> #define for_each_cfg_sme(fw, i, idx) \
> - for (i = 0; idx = __fwspec_cfg(fw)->smendx[i], i < fw->num_ids; ++i)
> + for (i = 0; idx = fwspec_smendx(fw, i), i < fw->num_ids; ++i)
That's certainly more readable:
Acked-by: Will Deacon <will.deacon@arm.com>
Joerg, if you haven't sent your fixes pull yet, please could you add this on
top? Otherwise, I'll queue it for 4.10, given that I think this only causes
a KASAN splat (the out-of-bounds read isn't ever used for anything).
Will
^ permalink raw reply
* [PATCH v3 10/10] ARM: dts: da850: add usb device node
From: Axel Haslam @ 2016-11-07 20:39 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161107203948.28324-1-ahaslam@baylibre.com>
This adds the ohci device node for the da850 soc.
It also enables it for the omapl138 hawk board.
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
arch/arm/boot/dts/da850-lcdk.dts | 8 ++++++++
arch/arm/boot/dts/da850.dtsi | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/arch/arm/boot/dts/da850-lcdk.dts b/arch/arm/boot/dts/da850-lcdk.dts
index 7b8ab21..aaf533e 100644
--- a/arch/arm/boot/dts/da850-lcdk.dts
+++ b/arch/arm/boot/dts/da850-lcdk.dts
@@ -86,6 +86,14 @@
};
};
+&usb_phy {
+ status = "okay";
+};
+
+&ohci {
+ status = "okay";
+};
+
&serial2 {
pinctrl-names = "default";
pinctrl-0 = <&serial2_rxtx_pins>;
diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 2534aab..50e86da 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -405,6 +405,14 @@
>;
status = "disabled";
};
+ ohci: usb at 0225000 {
+ compatible = "ti,da830-ohci";
+ reg = <0x225000 0x1000>;
+ interrupts = <59>;
+ phys = <&usb_phy 1>;
+ phy-names = "usb-phy";
+ status = "disabled";
+ };
gpio: gpio at 226000 {
compatible = "ti,dm6441-gpio";
gpio-controller;
--
2.10.1
^ permalink raw reply related
* [PATCH v3 09/10] USB: ohci: da8xx: Allow probing from DT
From: Axel Haslam @ 2016-11-07 20:39 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20161107203948.28324-1-ahaslam@baylibre.com>
This adds the compatible string to the ohci driver
to be able to probe from DT
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
drivers/usb/host/ohci-da8xx.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 83b182e..bbfe342 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -321,6 +321,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
/*-------------------------------------------------------------------------*/
+#ifdef CONFIG_OF
+static const struct of_device_id da8xx_ohci_ids[] = {
+ { .compatible = "ti,da830-ohci" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, da8xx_ohci_ids);
+#endif
static int ohci_da8xx_probe(struct platform_device *pdev)
{
@@ -472,6 +479,7 @@ static struct platform_driver ohci_hcd_da8xx_driver = {
#endif
.driver = {
.name = DRV_NAME,
+ .of_match_table = of_match_ptr(da8xx_ohci_ids),
},
};
--
2.10.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox