* [patch added to 3.12-stable] arm64: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO
From: Jiri Slaby @ 2016-09-22 7:11 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160922071154.1297-1-jslaby@suse.cz>
From: James Hogan <james.hogan@imgtec.com>
This patch has been added to the 3.12 stable tree. If you have any
objections, please let us know.
===============
commit 3146bc64d12377a74dbda12b96ea32da3774ae07 upstream.
AT_VECTOR_SIZE_ARCH should be defined with the maximum number of
NEW_AUX_ENT entries that ARCH_DLINFO can contain, but it wasn't defined
for arm64 at all even though ARCH_DLINFO will contain one NEW_AUX_ENT
for the VDSO address.
This shouldn't be a problem as AT_VECTOR_SIZE_BASE includes space for
AT_BASE_PLATFORM which arm64 doesn't use, but lets define it now and add
the comment above ARCH_DLINFO as found in several other architectures to
remind future modifiers of ARCH_DLINFO to keep AT_VECTOR_SIZE_ARCH up to
date.
Fixes: f668cd1673aa ("arm64: ELF definitions")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
arch/arm64/include/asm/elf.h | 1 +
arch/arm64/include/uapi/asm/auxvec.h | 2 ++
2 files changed, 3 insertions(+)
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index e7fa87f9201b..a4e1758c44dc 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -124,6 +124,7 @@ extern unsigned long randomize_et_dyn(unsigned long base);
#define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT);
+/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
#define ARCH_DLINFO \
do { \
NEW_AUX_ENT(AT_SYSINFO_EHDR, \
diff --git a/arch/arm64/include/uapi/asm/auxvec.h b/arch/arm64/include/uapi/asm/auxvec.h
index 22d6d8885854..4cf0c17787a8 100644
--- a/arch/arm64/include/uapi/asm/auxvec.h
+++ b/arch/arm64/include/uapi/asm/auxvec.h
@@ -19,4 +19,6 @@
/* vDSO location */
#define AT_SYSINFO_EHDR 33
+#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */
+
#endif
--
2.10.0
^ permalink raw reply related
* [PATCH] tty/serial: atmel: fix fractional baud rate computation
From: Uwe Kleine-König @ 2016-09-22 7:07 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921104414.16241-1-nicolas.ferre@atmel.com>
On Wed, Sep 21, 2016 at 12:44:14PM +0200, Nicolas Ferre wrote:
> From: Alexey Starikovskiy <aystarik@gmail.com>
>
> The problem with previous code was it rounded values in wrong
> place and produced wrong baud rate in some cases.
>
> Signed-off-by: Alexey Starikovskiy <aystarik@gmail.com>
> [nicolas.ferre at atmel.com: port to newer kernel and add commit log]
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/tty/serial/atmel_serial.c | 10 ++++++----
> include/linux/atmel_serial.h | 1 +
> 2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 5f550d9feed9..fd8aa1f4ba78 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2170,13 +2170,15 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
> * accurately. This feature is enabled only when using normal mode.
> * baudrate = selected clock / (8 * (2 - OVER) * (CD + FP / 8))
> * Currently, OVER is always set to 0 so we get
> - * baudrate = selected clock (16 * (CD + FP / 8))
> + * baudrate = selected clock / (16 * (CD + FP / 8))
> + * then
> + * 8 CD + FP = selected clock / (2 * baudrate)
> */
> if (atmel_port->has_frac_baudrate &&
> (mode & ATMEL_US_USMODE) == ATMEL_US_USMODE_NORMAL) {
> - div = DIV_ROUND_CLOSEST(port->uartclk, baud);
> - cd = div / 16;
> - fp = DIV_ROUND_CLOSEST(div % 16, 2);
> + div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2);
> + cd = div >> 3;
> + fp = div & ATMEL_US_FP_MASK;
given baud = 115200 and uartclk = 5414300 this results in:
div = DIV_ROUND_CLOSEST(5414300, 115200 * 2) = 23
cd = 2
fp = 7
which yields a rate of 5414300 / 46 = 117702.17. With cd = 3 and fp = 0
however the resulting rate is 5414300 / 48 = 112797.92.
Which one is better?
> } else {
> cd = uart_get_divisor(port, baud);
> }
> diff --git a/include/linux/atmel_serial.h b/include/linux/atmel_serial.h
> index f8e452aa48d7..bd2560502f3c 100644
> --- a/include/linux/atmel_serial.h
> +++ b/include/linux/atmel_serial.h
> @@ -119,6 +119,7 @@
> #define ATMEL_US_BRGR 0x20 /* Baud Rate Generator Register */
> #define ATMEL_US_CD GENMASK(15, 0) /* Clock Divider */
> #define ATMEL_US_FP_OFFSET 16 /* Fractional Part */
> +#define ATMEL_US_FP_MASK 0x7
Is there another user of this header? If not, this can be folded into
the driver.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply
* [PATCH] clocksource: bcm2835_timer: Unmap region obtained by of_iomap
From: Eric Anholt @ 2016-09-22 6:42 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1474479237-10356-1-git-send-email-arvind.yadav.cs@gmail.com>
Arvind Yadav <arvind.yadav.cs@gmail.com> writes:
> Free memory mapping, if bcm2835_timer_init is not successful.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160922/72ec6b9b/attachment.sig>
^ permalink raw reply
* [PATCH] dmaengine: edma: Rename set_bits and remove unused clear_bits helper
From: Peter Ujfalusi @ 2016-09-22 6:31 UTC (permalink / raw)
To: linux-arm-kernel
The clear_bits() helper is not used by the driver so it can be removed.
powerpc architecture defines the set_bits() in
arch/powerpc/include/asm/bitops.h which results failed compile testing on
powerpc architecture:
>> drivers/dma/edma.c:415:20: error: conflicting types for 'set_bits'
static inline void set_bits(int offset, int len, unsigned long *p)
^~~~~~~~
In file included from include/linux/bitops.h:36:0,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/kobject.h:20,
from include/linux/device.h:17,
from include/linux/dmaengine.h:20,
from drivers/dma/edma.c:16:
arch/powerpc/include/asm/bitops.h:75:14: note: previous definition of 'set_bits' was here
DEFINE_BITOP(set_bits, or, "")
^
arch/powerpc/include/asm/bitops.h:58:24: note: in definition of macro 'DEFINE_BITOP'
static __inline__ void fn(unsigned long mask, \
^~
>> drivers/dma/edma.c:421:20: error: conflicting types for 'clear_bits'
static inline void clear_bits(int offset, int len, unsigned long *p)
^~~~~~~~~~
In file included from include/linux/bitops.h:36:0,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/kobject.h:20,
from include/linux/device.h:17,
from include/linux/dmaengine.h:20,
from drivers/dma/edma.c:16:
arch/powerpc/include/asm/bitops.h:76:14: note: previous definition of 'clear_bits' was here
DEFINE_BITOP(clear_bits, andc, "")
^
arch/powerpc/include/asm/bitops.h:58:24: note: in definition of macro 'DEFINE_BITOP'
static __inline__ void fn(unsigned long mask, \
^~
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
Hi,
the eDMA/sDMA/ti-crossbar COMPILE_TEST series brought up this issue reported by
Intel kbuild test robot.
Vinod: Should I send a v4 of the COMPILE_TEST series, or is it OK if this patch
goes separately? The compile test failure should not break bisect for PPC...
Regards,
Peter
drivers/dma/edma.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index 0241f39ba64c..1f967545fb33 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -412,18 +412,12 @@ static inline void edma_param_or(struct edma_cc *ecc, int offset, int param_no,
edma_or(ecc, EDMA_PARM + offset + (param_no << 5), or);
}
-static inline void set_bits(int offset, int len, unsigned long *p)
+static inline void edma_set_bits(int offset, int len, unsigned long *p)
{
for (; len > 0; len--)
set_bit(offset + (len - 1), p);
}
-static inline void clear_bits(int offset, int len, unsigned long *p)
-{
- for (; len > 0; len--)
- clear_bit(offset + (len - 1), p);
-}
-
static void edma_assign_priority_to_queue(struct edma_cc *ecc, int queue_no,
int priority)
{
@@ -2266,7 +2260,7 @@ static int edma_probe(struct platform_device *pdev)
for (i = 0; rsv_slots[i][0] != -1; i++) {
off = rsv_slots[i][0];
ln = rsv_slots[i][1];
- set_bits(off, ln, ecc->slot_inuse);
+ edma_set_bits(off, ln, ecc->slot_inuse);
}
}
}
--
2.10.0
^ permalink raw reply related
* [PATCH 2/4] drivers: iio: ti_am335x_adc: add dma support
From: Vignesh R @ 2016-09-22 6:18 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921161134.6951-3-mugunthanvnm@ti.com>
On Wednesday 21 September 2016 09:41 PM, Mugunthan V N wrote:
> This patch adds the required pieces to ti_am335x_adc driver for
> DMA support
>
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> ---
> drivers/iio/adc/ti_am335x_adc.c | 160 ++++++++++++++++++++++++++++++++++-
> include/linux/mfd/ti_am335x_tscadc.h | 7 ++
> 2 files changed, 164 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index c3cfacca..89d0b07 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -30,10 +30,32 @@
> #include <linux/iio/buffer.h>
> #include <linux/iio/kfifo_buf.h>
>
> +#include <linux/dmaengine.h>
> +#include <linux/dma-mapping.h>
> +
> +#define DMA_BUFFER_SIZE SZ_2K
> +
> +struct tiadc_dma {
> + /* Filter function */
> + dma_filter_fn fn;
> + /* Parameter to the filter function */
> + void *param;
These will not be needed with newer APIs (see below)
> + struct dma_slave_config conf;
> + struct dma_chan *chan;
> + dma_addr_t addr;
> + dma_cookie_t cookie;
> + u8 *buf;
> + bool valid_buf_seg;
> + int buf_offset;
> + u8 fifo_thresh;
> +};
> +
> struct tiadc_device {
> struct ti_tscadc_dev *mfd_tscadc;
> + struct tiadc_dma dma;
> struct mutex fifo1_lock; /* to protect fifo access */
> int channels;
> + int total_ch_enabled;
> u8 channel_line[8];
> u8 channel_step[8];
> int buffer_en_ch_steps;
> @@ -184,6 +206,7 @@ static irqreturn_t tiadc_worker_h(int irq, void *private)
> u16 *data = adc_dev->data;
>
> fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
> +
> for (k = 0; k < fifo1count; k = k + i) {
> for (i = 0; i < (indio_dev->scan_bytes)/2; i++) {
> read = tiadc_readl(adc_dev, REG_FIFO1);
> @@ -198,6 +221,68 @@ static irqreturn_t tiadc_worker_h(int irq, void *private)
> return IRQ_HANDLED;
> }
>
> +static void tiadc_dma_rx_complete(void *param)
> +{
> + struct iio_dev *indio_dev = param;
> + struct tiadc_device *adc_dev = iio_priv(indio_dev);
> + struct tiadc_dma *dma = &adc_dev->dma;
> + u8 *data;
> + int i;
> +
> + data = dma->valid_buf_seg ? dma->buf + dma->buf_offset : dma->buf;
> + dma->valid_buf_seg = !dma->valid_buf_seg;
> +
> + for (i = 0; i < dma->buf_offset; i += indio_dev->scan_bytes) {
> + iio_push_to_buffers(indio_dev, data);
> + data += indio_dev->scan_bytes;
> + }
> +}
> +
> +static int tiadc_start_dma(struct iio_dev *indio_dev)
> +{
> + struct tiadc_device *adc_dev = iio_priv(indio_dev);
> + struct tiadc_dma *dma = &adc_dev->dma;
> + struct dma_async_tx_descriptor *desc;
> +
> + dma->valid_buf_seg = false;
> + dma->fifo_thresh = FIFO1_THRESHOLD;
> + /*
> + * Make the fifo thresh as the multiple of total number of
> + * channels enabled, so make sure that that cyclic DMA period
> + * length is also a multiple of total number of channels
> + * enabled. This ensures that no invalid data is reported
> + * to the stack via iio_push_to_buffers().
> + */
> + dma->fifo_thresh -= (dma->fifo_thresh + 1) % adc_dev->total_ch_enabled;
Can we use rounddown(FIFO1_THRESHOLD + 1, adc_dev->total_ch_enabled)?
> + dma->buf_offset = DMA_BUFFER_SIZE / 2;
> + /* Make sure that period length is multiple of fifo thresh level */
> + dma->buf_offset -= dma->buf_offset % ((dma->fifo_thresh + 1) *
> + sizeof(u16));
> +
Can we use rounddown()?
> + dma->conf.src_maxburst = dma->fifo_thresh + 1;
> + dmaengine_slave_config(dma->chan, &dma->conf);
> +
> + desc = dmaengine_prep_dma_cyclic(dma->chan, dma->addr,
> + dma->buf_offset * 2,
> + dma->buf_offset, DMA_DEV_TO_MEM,
> + DMA_PREP_INTERRUPT);
> + if (!desc)
> + return -EBUSY;
> +
> + desc->callback = tiadc_dma_rx_complete;
> + desc->callback_param = indio_dev;
> +
> + dma->cookie = dmaengine_submit(desc);
> +
> + dma_async_issue_pending(dma->chan);
> +
> + tiadc_writel(adc_dev, REG_FIFO1THR, dma->fifo_thresh);
> + tiadc_writel(adc_dev, REG_DMA1REQ, dma->fifo_thresh);
> + tiadc_writel(adc_dev, REG_DMAENABLE_SET, DMA_FIFO1);
> +
> + return 0;
> +}
> +
> static int tiadc_buffer_preenable(struct iio_dev *indio_dev)
> {
> struct tiadc_device *adc_dev = iio_priv(indio_dev);
> @@ -218,20 +303,30 @@ static int tiadc_buffer_preenable(struct iio_dev *indio_dev)
> static int tiadc_buffer_postenable(struct iio_dev *indio_dev)
> {
> struct tiadc_device *adc_dev = iio_priv(indio_dev);
> + struct tiadc_dma *dma = &adc_dev->dma;
> unsigned int enb = 0;
> u8 bit;
> + u32 irq_enable;
>
> tiadc_step_config(indio_dev);
> - for_each_set_bit(bit, indio_dev->active_scan_mask, adc_dev->channels)
> + for_each_set_bit(bit, indio_dev->active_scan_mask, adc_dev->channels) {
> enb |= (get_adc_step_bit(adc_dev, bit) << 1);
> + adc_dev->total_ch_enabled++;
> + }
> adc_dev->buffer_en_ch_steps = enb;
>
> + if (dma->chan)
> + tiadc_start_dma(indio_dev);
> +
> am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, enb);
>
> tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES
> | IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW);
> - tiadc_writel(adc_dev, REG_IRQENABLE, IRQENB_FIFO1THRES
> - | IRQENB_FIFO1OVRRUN);
> +
> + irq_enable = IRQENB_FIFO1OVRRUN;
> + if (!dma->chan)
> + irq_enable |= IRQENB_FIFO1THRES;
> + tiadc_writel(adc_dev, REG_IRQENABLE, irq_enable);
>
> return 0;
> }
> @@ -239,12 +334,18 @@ static int tiadc_buffer_postenable(struct iio_dev *indio_dev)
> static int tiadc_buffer_predisable(struct iio_dev *indio_dev)
> {
> struct tiadc_device *adc_dev = iio_priv(indio_dev);
> + struct tiadc_dma *dma = &adc_dev->dma;
> int fifo1count, i, read;
>
> tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES |
> IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW));
> am335x_tsc_se_clr(adc_dev->mfd_tscadc, adc_dev->buffer_en_ch_steps);
> adc_dev->buffer_en_ch_steps = 0;
> + adc_dev->total_ch_enabled = 0;
> + if (dma->chan) {
> + tiadc_writel(adc_dev, REG_DMAENABLE_CLEAR, 0x2);
> + dmaengine_terminate_async(dma->chan);
> + }
>
> /* Flush FIFO of leftover data in the time it takes to disable adc */
> fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
> @@ -430,6 +531,50 @@ static const struct iio_info tiadc_info = {
> .driver_module = THIS_MODULE,
> };
>
> +static bool the_no_dma_filter_fn(struct dma_chan *chan, void *param)
> +{
> + return false;
> +}
> +
> +static int tiadc_request_dma(struct platform_device *pdev,
> + struct tiadc_device *adc_dev)
> +{
> + struct tiadc_dma *dma = &adc_dev->dma;
> + dma_cap_mask_t mask;
> +
> + dma->fn = the_no_dma_filter_fn;
> +
> + /* Default slave configuration parameters */
> + dma->conf.direction = DMA_DEV_TO_MEM;
> + dma->conf.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
> + dma->conf.src_addr = adc_dev->mfd_tscadc->tscadc_phys_base + REG_FIFO1;
> +
> + dma_cap_zero(mask);
> + dma_cap_set(DMA_CYCLIC, mask);
> +
> + /* Get a channel for RX */
> + dma->chan = dma_request_slave_channel_compat(mask,
> + dma->fn, dma->param,
> + adc_dev->mfd_tscadc->dev,
> + "fifo1");
Please use dma_request_chan() API instead, this does not need
dma_filter_fn and probe defer can be handled.
> + if (!dma->chan)
> + return -ENODEV;
> +
> + /* RX buffer */
> + dma->buf = dma_alloc_coherent(dma->chan->device->dev, DMA_BUFFER_SIZE,
> + &dma->addr, GFP_KERNEL);
> + if (!dma->buf)
> + goto err;
> +
> + dev_dbg_ratelimited(adc_dev->mfd_tscadc->dev, "got dma channel\n");
Do we need _ratelimited? AFAICS, this print is called only once.
> +
> + return 0;
> +err:
> + dma_release_channel(dma->chan);
> +
> + return -ENOMEM;
> +}
> +
> static int tiadc_parse_dt(struct platform_device *pdev,
> struct tiadc_device *adc_dev)
> {
> @@ -512,8 +657,14 @@ static int tiadc_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, indio_dev);
>
> + err = tiadc_request_dma(pdev, adc_dev);
> + if (err && err != -ENODEV)
> + goto err_dma;
> +
> return 0;
>
> +err_dma:
> + iio_device_unregister(indio_dev);
> err_buffer_unregister:
> tiadc_iio_buffered_hardware_remove(indio_dev);
> err_free_channels:
> @@ -525,8 +676,11 @@ static int tiadc_remove(struct platform_device *pdev)
> {
> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> struct tiadc_device *adc_dev = iio_priv(indio_dev);
> + struct tiadc_dma *dma = &adc_dev->dma;
> u32 step_en;
>
> + if (dma->chan)
> + dma_release_channel(dma->chan);
dma_free_coherent() for dma->buf?
> iio_device_unregister(indio_dev);
> tiadc_iio_buffered_hardware_remove(indio_dev);
> tiadc_channels_remove(indio_dev);
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index e45a208..fb9dc99 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -23,6 +23,8 @@
> #define REG_IRQENABLE 0x02C
> #define REG_IRQCLR 0x030
> #define REG_IRQWAKEUP 0x034
> +#define REG_DMAENABLE_SET 0x038
> +#define REG_DMAENABLE_CLEAR 0x038
> #define REG_CTRL 0x040
> #define REG_ADCFSM 0x044
> #define REG_CLKDIV 0x04C
> @@ -36,6 +38,7 @@
> #define REG_FIFO0THR 0xE8
> #define REG_FIFO1CNT 0xF0
> #define REG_FIFO1THR 0xF4
> +#define REG_DMA1REQ 0xF8
> #define REG_FIFO0 0x100
> #define REG_FIFO1 0x200
>
> @@ -126,6 +129,10 @@
> #define FIFOREAD_DATA_MASK (0xfff << 0)
> #define FIFOREAD_CHNLID_MASK (0xf << 16)
>
> +/* DMA ENABLE/CLEAR Register */
> +#define DMA_FIFO0 BIT(0)
> +#define DMA_FIFO1 BIT(1)
> +
> /* Sequencer Status */
> #define SEQ_STATUS BIT(5)
> #define CHARGE_STEP 0x11
>
--
Regards
Vignesh
^ permalink raw reply
* [PATCH v2 5/6] misc: sram: add Atmel securam support
From: Greg Kroah-Hartman @ 2016-09-22 5:08 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921220939.27924-6-alexandre.belloni@free-electrons.com>
On Thu, Sep 22, 2016 at 12:09:38AM +0200, Alexandre Belloni wrote:
> The Atmel secure SRAM is connected to a security module and may be erased
> automatically under certain conditions. For that reason, it is necessary to
> wait for the security module to flag that SRAM accesses are allowed before
> accessing it.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> drivers/misc/sram.c | 42 +++++++++++++++++++++++++++++++++++-------
> 1 file changed, 35 insertions(+), 7 deletions(-)
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply
* [PATCH] usb: dwc3: host: inherit dma configuration from parent dev
From: Sriram Dash @ 2016-09-22 5:02 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20042182.GcPMJken6Z@wuerfel>
>From: Arnd Bergmann [mailto:arnd at arndb.de]
>On Wednesday, September 21, 2016 11:43:59 AM CEST Sriram Dash wrote:
>> >From: Arnd Bergmann [mailto:arnd at arndb.de] On Wednesday, September
>> >21, 2016 11:06:47 AM CEST Sriram Dash wrote:
>>
>> ==============================================================
>> From 8b0dea1513e9e73a11dcfa802ddc71cca11d66f8 Mon Sep 17 00:00:00 2001
>> From: Sriram Dash <sriram.dash@nxp.com>
>> Date: Wed, 21 Sep 2016 11:39:30 +0530
>> Subject: [PATCH] usb: xhci: Fix the patch inherit dma configuration
>> from parent dev
>>
>> Fixes the patch https://patchwork.kernel.org/patch/9319527/
>> ("usb: dwc3: host: inherit dma configuration from parent dev").
>>
>> Signed-off-by: Sriram Dash <sriram.dash@nxp.com>
>> ---
>> drivers/usb/host/xhci-mem.c | 12 ++++++------
>> drivers/usb/host/xhci.c | 20 ++++++++++----------
>> 2 files changed, 16 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
>> index 6afe323..79608df 100644
>> --- a/drivers/usb/host/xhci-mem.c
>> +++ b/drivers/usb/host/xhci-mem.c
>
>All the changes you did to this file seem fine, I completely missed that part.
>
>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index
>> 01d96c9..9a1ff09 100644
>> --- a/drivers/usb/host/xhci.c
>> +++ b/drivers/usb/host/xhci.c
Yes. Some sanity is required over this patch.
>> @@ -231,7 +231,7 @@ static int xhci_free_msi(struct xhci_hcd *xhci)
>> static int xhci_setup_msi(struct xhci_hcd *xhci) {
>> int ret;
>> - struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
>> + struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.sysdev);
>>
>> ret = pci_enable_msi(pdev);
>> if (ret) {
>
>This one is interesting as I stumbled over some code comment mentioning that for
>dwc3-pci, we don't support MSI. I think with this change, we /can/ actually support
>MSI, but this could be a separate patch and we'd have to test it on dwc3-pci
>hardware. Same for most of this file.
>
>> @@ -745,7 +745,7 @@ void xhci_shutdown(struct usb_hcd *hcd)
>> struct xhci_hcd *xhci = hcd_to_xhci(hcd);
>>
>> if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
>> - usb_disable_xhci_ports(to_pci_dev(hcd->self.controller));
>> + usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
>>
>> spin_lock_irq(&xhci->lock);
>> xhci_halt(xhci);
>
>This seems obviously correct, but I don't yet see why it currently works. We
>probably don't call this function on dwc3.
>
>> #ifdef CONFIG_PM
>> @@ -3605,7 +3605,7 @@ void xhci_free_dev(struct usb_hcd *hcd, struct
>usb_device *udev)
>> * if no devices remain.
>> */
>> if (xhci->quirks & XHCI_RESET_ON_RESUME)
>> - pm_runtime_put_noidle(hcd->self.controller);
>> + pm_runtime_put_noidle(hcd->self.sysdev);
>> #endif
>>
>> ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
>
>I suspect this one is wrong, based on what Felipe explained earlier:
>the power management should propagate down from the child to the parent
>device.
>
>Someone who understands this better than I do should look at it.
>
>> @@ -3745,7 +3745,7 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct
>usb_device *udev)
>> * suspend if there is a device attached.
>> */
>> if (xhci->quirks & XHCI_RESET_ON_RESUME)
>> - pm_runtime_get_noresume(hcd->self.controller);
>> + pm_runtime_get_noresume(hcd->self.sysdev);
>> #endif
>>
>>
>
>Same here.
>
>> @@ -4834,7 +4834,7 @@ int xhci_get_frame(struct usb_hcd *hcd) int
>> xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) {
>> struct xhci_hcd *xhci;
>> - struct device *dev = hcd->self.controller;
>> + struct device *dev = hcd->self.sysdev;
>> int retval;
>
>
>This one calls
>
> get_quirks(dev, xhci);
>
>not sure whether this should be called with self.controller or self.sysdev, we should
>audit every one of the callers here to be sure:
>
>drivers/usb/host/xhci-mtk.c: return xhci_gen_setup(hcd, xhci_mtk_quirks);
>drivers/usb/host/xhci-pci.c: retval = xhci_gen_setup(hcd, xhci_pci_quirks);
>drivers/usb/host/xhci-plat.c: return xhci_gen_setup(hcd, xhci_plat_quirks);
>drivers/usb/host/xhci-rcar.c: * xhci_gen_setup().
>drivers/usb/host/xhci-tegra.c: return xhci_gen_setup(hcd, tegra_xhci_quirks);
>
> Arnd
^ permalink raw reply
* [PATCH v3 7/9] dmaengine: edma: enable COMPILE_TEST
From: kbuild test robot @ 2016-09-22 4:50 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921124135.11849-8-peter.ujfalusi@ti.com>
Hi Peter,
[auto build test ERROR on linus/master]
[also build test ERROR on v4.8-rc7 next-20160921]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Peter-Ujfalusi/dmaengine-ti-drivers-enable-COMPILE_TESTing/20160921-212008
config: powerpc-allyesconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc
All errors (new ones prefixed by >>):
>> drivers/dma/edma.c:415:20: error: conflicting types for 'set_bits'
static inline void set_bits(int offset, int len, unsigned long *p)
^~~~~~~~
In file included from include/linux/bitops.h:36:0,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/kobject.h:20,
from include/linux/device.h:17,
from include/linux/dmaengine.h:20,
from drivers/dma/edma.c:16:
arch/powerpc/include/asm/bitops.h:75:14: note: previous definition of 'set_bits' was here
DEFINE_BITOP(set_bits, or, "")
^
arch/powerpc/include/asm/bitops.h:58:24: note: in definition of macro 'DEFINE_BITOP'
static __inline__ void fn(unsigned long mask, \
^~
>> drivers/dma/edma.c:421:20: error: conflicting types for 'clear_bits'
static inline void clear_bits(int offset, int len, unsigned long *p)
^~~~~~~~~~
In file included from include/linux/bitops.h:36:0,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/kobject.h:20,
from include/linux/device.h:17,
from include/linux/dmaengine.h:20,
from drivers/dma/edma.c:16:
arch/powerpc/include/asm/bitops.h:76:14: note: previous definition of 'clear_bits' was here
DEFINE_BITOP(clear_bits, andc, "")
^
arch/powerpc/include/asm/bitops.h:58:24: note: in definition of macro 'DEFINE_BITOP'
static __inline__ void fn(unsigned long mask, \
^~
vim +/set_bits +415 drivers/dma/edma.c
d9c345d1 Peter Ujfalusi 2015-10-16 409 static inline void edma_param_or(struct edma_cc *ecc, int offset, int param_no,
2b6b3b74 Peter Ujfalusi 2015-10-14 410 unsigned or)
2b6b3b74 Peter Ujfalusi 2015-10-14 411 {
2b6b3b74 Peter Ujfalusi 2015-10-14 412 edma_or(ecc, EDMA_PARM + offset + (param_no << 5), or);
2b6b3b74 Peter Ujfalusi 2015-10-14 413 }
2b6b3b74 Peter Ujfalusi 2015-10-14 414
2b6b3b74 Peter Ujfalusi 2015-10-14 @415 static inline void set_bits(int offset, int len, unsigned long *p)
2b6b3b74 Peter Ujfalusi 2015-10-14 416 {
2b6b3b74 Peter Ujfalusi 2015-10-14 417 for (; len > 0; len--)
2b6b3b74 Peter Ujfalusi 2015-10-14 418 set_bit(offset + (len - 1), p);
2b6b3b74 Peter Ujfalusi 2015-10-14 419 }
2b6b3b74 Peter Ujfalusi 2015-10-14 420
2b6b3b74 Peter Ujfalusi 2015-10-14 @421 static inline void clear_bits(int offset, int len, unsigned long *p)
2b6b3b74 Peter Ujfalusi 2015-10-14 422 {
2b6b3b74 Peter Ujfalusi 2015-10-14 423 for (; len > 0; len--)
2b6b3b74 Peter Ujfalusi 2015-10-14 424 clear_bit(offset + (len - 1), p);
:::::: The code at line 415 was first introduced by commit
:::::: 2b6b3b7420190888793c49e97276e1e73bd7eaed ARM/dmaengine: edma: Merge the two drivers under drivers/dma/
:::::: TO: Peter Ujfalusi <peter.ujfalusi@ti.com>
:::::: CC: Vinod Koul <vinod.koul@intel.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 49928 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160922/316e4457/attachment-0001.gz>
^ permalink raw reply
* [PATCH] arm: ubsan: select ARCH_HAS_UBSAN_SANITIZE_ALL
From: Seung-Woo Kim @ 2016-09-22 4:49 UTC (permalink / raw)
To: linux-arm-kernel
To enable UBSAN on arm, this patch enables ARCH_HAS_UBSAN_SANITIZE_ALL
from arm confiuration. Basic kernel bootup test is passed on arm with
CONFIG_UBSAN_SANITIZE_ALL enabled.
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
This is resend of the patch I already sent, [1], without RFC tag.
[1] https://patchwork.kernel.org/patch/9189533/
I tested kernel build and basic boot up on Exynos5422, Exynos4412 and
Exynos3250 SoC boards.
At previous time on [1], there were some build error on other systems,
but they were caused by driver bug or gcc bug. So I think UBSAN on ARM
can be re-considered.
---
arch/arm/Kconfig | 1 +
arch/arm/boot/compressed/Makefile | 1 +
arch/arm/vdso/Makefile | 1 +
3 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a9c4e48..a80f9b1 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -7,6 +7,7 @@ config ARM
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_HAS_GCOV_PROFILE_ALL
+ select ARCH_HAS_UBSAN_SANITIZE_ALL
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_USE_BUILTIN_BSWAP
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index d50430c..883374f 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -23,6 +23,7 @@ OBJS += hyp-stub.o
endif
GCOV_PROFILE := n
+UBSAN_SANITIZE := n
#
# Architecture dependencies
diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
index 59a8fa7..cb90e59 100644
--- a/arch/arm/vdso/Makefile
+++ b/arch/arm/vdso/Makefile
@@ -28,6 +28,7 @@ CFLAGS_vgettimeofday.o = -O2
# Disable gcov profiling for VDSO code
GCOV_PROFILE := n
+UBSAN_SANITIZE := n
# Force dependency
$(obj)/vdso.o : $(obj)/vdso.so
--
1.7.4.1
^ permalink raw reply related
* [PATCH 5/5] arm64: Add uprobe support
From: Pratyush Anand @ 2016-09-22 3:23 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921170403.GE12180@e104818-lin.cambridge.arm.com>
On 21/09/2016:06:04:04 PM, Catalin Marinas wrote:
> On Wed, Sep 21, 2016 at 04:30:47PM +0530, Pratyush Anand wrote:
> > On 20/09/2016:05:59:46 PM, Catalin Marinas wrote:
> > > > +int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm,
> > > > + unsigned long addr)
> > > > +{
> > > > + probe_opcode_t insn;
> > > > +
> > > > + /* TODO: Currently we do not support AARCH32 instruction probing */
> > >
> > > Is there a way to check (not necessarily in this file) that we don't
> > > probe 32-bit tasks?
> >
> > - Well, I do not have complete idea about it that, how it can be done. I think
> > we can not check that just by looking a single bit in an instruction.
> > My understanding is that, we can only know about it when we are executing the
> > instruction, by reading pstate, but that would not be useful for uprobe
> > instruction analysis.
> >
> > I hope, instruction encoding for aarch32 and aarch64 are different, and by
> > analyzing for all types of aarch32 instructions, we will be able to decide
> > that whether instruction is 32 bit trace-able or not. Accordingly, we can use
> > either BRK or BKPT instruction for breakpoint generation.
>
> We may have some unrelated instruction encoding overlapping but I
> haven't checked. I was more thinking about whether we know which task is
> being probed and check is_compat_task() or maybe using
> compat_user_mode(regs).
I had thought of this, but problem is that we might not have task in existence
when we enable uprobes. For example: Lets say we are inserting a trace probe at
offset 0x690 in a executable binary.
echo "p test:0x690" > /sys/kernel/debug/tracing/uprobe_events
echo 1 > /sys/kernel/debug/tracing/events/uprobes/enable
In the 'enable' step, it is decided that whether instruction is traceable or
not.
(1) But at this point 'test' executable might not be running.
(2) Even if it is running, is_compat_task() or compat_user_mode() might not be
usable, as they work with 'current' task.
What I was thinking that, let it go with 'TODO' as of now.
Later on, we propose some changes in core layer, so that we can read the elf
headers of executable binary. ELFCLASS will be able to tell us, whether its a 32
bit or 64 bit executable. I think, moving "struct uprobe" from
kernel/events/uprobes.c to a include/linux header file will do the job. "struct
arch_uprobe" is part of "struct uprobe". "struct arch_uprobe" is passed in
arch_uprobe_analyze_insn(). So, we can access struct uprobe's "inode" element
with this change.
~Pratyush
^ permalink raw reply
* [PATCH] arm64: Call numa_store_cpu_info() earlier.
From: Yisheng Xie @ 2016-09-22 3:04 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1474397195-16520-1-git-send-email-ddaney.cavm@gmail.com>
On 2016/9/21 2:46, David Daney wrote:
> From: David Daney <david.daney@cavium.com>
>
> Fix by moving call to numa_store_cpu_info() for all CPUs into
> smp_prepare_cpus(), which happens before wq_numa_init(). Since
> smp_store_cpu_info() now contains only a single function call,
> simplify by removing the function and out-lining its contents.
>
> Suggested-by: Robert Richter <rric@kernel.org>
> fixes: 1a2db300348b ("arm64, numa: Add NUMA support for arm64 platforms.")
> Cc: <stable@vger.kernel.org> # 4.7.x-
> Signed-off-by: David Daney <david.daney@cavium.com>
> ---
Tested-by: Yisheng Xie <xieyisheng1@huawei.com>
Thanks.
> arch/arm64/kernel/smp.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index d93d433..3ff173e 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -201,12 +201,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
> return ret;
> }
>
> -static void smp_store_cpu_info(unsigned int cpuid)
> -{
> - store_cpu_topology(cpuid);
> - numa_store_cpu_info(cpuid);
> -}
> -
> /*
> * This is the secondary CPU boot entry. We're using this CPUs
> * idle thread stack, but a set of temporary page tables.
> @@ -254,7 +248,7 @@ asmlinkage void secondary_start_kernel(void)
> */
> notify_cpu_starting(cpu);
>
> - smp_store_cpu_info(cpu);
> + store_cpu_topology(cpu);
>
> /*
> * OK, now it's safe to let the boot CPU continue. Wait for
> @@ -689,10 +683,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> {
> int err;
> unsigned int cpu;
> + unsigned int this_cpu;
>
> init_cpu_topology();
>
> - smp_store_cpu_info(smp_processor_id());
> + this_cpu = smp_processor_id();
> + store_cpu_topology(this_cpu);
> + numa_store_cpu_info(this_cpu);
>
> /*
> * If UP is mandated by "nosmp" (which implies "maxcpus=0"), don't set
> @@ -719,6 +716,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> continue;
>
> set_cpu_present(cpu, true);
> + numa_store_cpu_info(cpu);
> }
> }
>
>
^ permalink raw reply
* [PATCH v5 3/3] pci:aer: add support aer interrupt with none MSI/MSI-X/INTx mode
From: Po Liu @ 2016-09-22 2:53 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921223741.GG20006@localhost>
Hi Bjorn,
> -----Original Message-----
> From: Bjorn Helgaas [mailto:helgaas at kernel.org]
> Sent: Thursday, September 22, 2016 6:38 AM
> To: Po Liu
> Cc: linux-pci at vger.kernel.org; linux-arm-kernel at lists.infradead.org;
> linux-kernel at vger.kernel.org; devicetree at vger.kernel.org; Roy Zang; Arnd
> Bergmann; Marc Zyngier; Stuart Yoder; Leo Li; M.H. Lian; Murali
> Karicheri; Bjorn Helgaas; Shawn Guo; Mingkai Hu
> Subject: Re: [PATCH v5 3/3] pci:aer: add support aer interrupt with none
> MSI/MSI-X/INTx mode
>
> On Tue, Sep 13, 2016 at 12:40:59PM +0800, Po Liu wrote:
> > On some platforms, root port doesn't support MSI/MSI-X/INTx in RC mode.
> > When chip support the aer interrupt with none MSI/MSI-X/INTx mode,
> > maybe there is interrupt line for aer pme etc. Search the interrupt
> > number in the fdt file. Then fixup the dev->irq with it.
> >
> > Signed-off-by: Po Liu <po.liu@nxp.com>
> > ---
> > changes for v5:
> > - Add clear 'aer' interrup-names description
> >
> > .../devicetree/bindings/pci/layerscape-pci.txt | 11 +++++---
> > drivers/pci/pcie/portdrv_core.c | 31
> +++++++++++++++++++---
> > 2 files changed, 35 insertions(+), 7 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> > b/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> > index 41e9f55..101d0a7 100644
> > --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> > +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> > @@ -18,8 +18,10 @@ Required properties:
> > - reg: base addresses and lengths of the PCIe controller
> > - interrupts: A list of interrupt outputs of the controller. Must
> contain an
> > entry for each entry in the interrupt-names property.
> > -- interrupt-names: Must include the following entries:
> > - "intr": The interrupt that is asserted for controller interrupts
> > +- interrupt-names: It may be include the following entries:
> > + "aer": The interrupt that is asserted for aer interrupt
> > + "pme": The interrupt that is asserted for pme interrupt
> > + ......
> > - fsl,pcie-scfg: Must include two entries.
> > The first entry must be a link to the SCFG device node
> > The second entry must be '0' or '1' based on physical PCIe
> controller index.
> > @@ -35,8 +37,9 @@ Example:
> > reg = <0x00 0x03400000 0x0 0x00010000 /* controller
> registers */
> > 0x40 0x00000000 0x0 0x00002000>; /* configuration
> space */
> > reg-names = "regs", "config";
> > - interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>; /*
> controller interrupt */
> > - interrupt-names = "intr";
> > + interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>, /* aer
> interrupt */
> > + <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>; /* pme interrupt */
> > + interrupt-names = "aer", "pme";
> > fsl,pcie-scfg = <&scfg 0>;
> > #address-cells = <3>;
> > #size-cells = <2>;
> > diff --git a/drivers/pci/pcie/portdrv_core.c
> > b/drivers/pci/pcie/portdrv_core.c index e9270b4..7c4943d 100644
> > --- a/drivers/pci/pcie/portdrv_core.c
> > +++ b/drivers/pci/pcie/portdrv_core.c
> > @@ -16,6 +16,7 @@
> > #include <linux/slab.h>
> > #include <linux/pcieport_if.h>
> > #include <linux/aer.h>
> > +#include <linux/of_irq.h>
> >
> > #include "../pci.h"
> > #include "portdrv.h"
> > @@ -200,6 +201,28 @@ static int pcie_port_enable_msix(struct pci_dev
> > *dev, int *vectors, int mask) static int init_service_irqs(struct
> > pci_dev *dev, int *irqs, int mask) {
> > int i, irq = -1;
> > + int ret;
> > + struct device_node *np = NULL;
> > +
> > + for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++)
> > + irqs[i] = 0;
> > +
> > + if (dev->bus->dev.of_node)
> > + np = dev->bus->dev.of_node;
> > +
> > + /* If root port doesn't support MSI/MSI-X/INTx in RC mode,
> > + * request irq for aer
> > + */
> > + if (IS_ENABLED(CONFIG_OF_IRQ) && np &&
> > + (mask & PCIE_PORT_SERVICE_PME)) {
> > + ret = of_irq_get_byname(np, "aer");
> > + if (ret > 0) {
> > + irqs[PCIE_PORT_SERVICE_AER_SHIFT] = ret;
> > + if (dev->irq)
> > + irq = dev->irq;
> > + goto no_msi;
> > + }
> > + }
>
> We definitely need to solve this somehow. But this approach doesn't
> feel quite right because it's hard to map this code back to anything in
> the spec, and it uses a completely platform-dependent name ("interrupt-
> names aer") in code that is supposedly generic.
Very agree.
>
> What if we added some sort of hook that would return the IRQ? Maybe a
> pcibios_*() hook right now, with the idea of making it a pci_host_bridge
> function pointer someday?
Good idea. I'll try one version patch soon.
>
> I know the body of the hook would look a lot like what you have here,
> but at least it would be more obvious that it's platform-specific code.
>
Not agree more.
> I think your platform supports PME interrupts as well as AER, and
> they're different IRQs. So you'd probably have to do something similar
> to the pcie_port_enable_msix() interface, so you can fill in both IRQs.
>
Ok, understand.
Po
> > /*
> > * If MSI cannot be used for PCIe PME or hotplug, we have to use
> @@
> > -225,11 +248,13 @@ static int init_service_irqs(struct pci_dev *dev,
> int *irqs, int mask)
> > irq = dev->irq;
> >
> > no_msi:
> > - for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++)
> > - irqs[i] = irq;
> > + for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) {
> > + if (!irqs[i])
> > + irqs[i] = irq;
> > + }
> > irqs[PCIE_PORT_SERVICE_VC_SHIFT] = -1;
> >
> > - if (irq < 0)
> > + if (irq < 0 && irqs[PCIE_PORT_SERVICE_AER_SHIFT] < 0)
> > return -ENODEV;
> > return 0;
> > }
> > --
> > 2.1.0.27.g96db324
> >
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply
* [PATCH 2/2] musb: sunxi: Force session end on babble errors in host-mode
From: Bin Liu @ 2016-09-22 2:33 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160918165018.24547-2-hdegoede@redhat.com>
Hi,
On Sun, Sep 18, 2016 at 06:50:18PM +0200, Hans de Goede wrote:
> The sunxi musb has a bug where sometimes it will generate a babble
> error on device disconnect instead of a disconnect irq. When this
> happens the musb-controller switches from host mode to device mode
> (it clears MUSB_DEVCTL_SESSION and sets MUSB_DEVCTL_BDEVICE) and
> gets stuck in this state.
>
> Clearing this requires reporting Vbus low for 200 or more ms, but
> on some devices Vbus is simply always high (host-only mode, no Vbus
> control).
>
> This commit calls sun4i_usb_phy_force_session_end() on babble errors
> in host-mode, fixing the musb controller being stuck in this state
> on systems without Vbus control; and also fixes the need to unplug
> the usb-b -> usb-a cable to get out of this state on systems with
> Vbus control.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/usb/musb/sunxi.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
> index 1408245..5079d90 100644
> --- a/drivers/usb/musb/sunxi.c
> +++ b/drivers/usb/musb/sunxi.c
> @@ -192,8 +192,18 @@ static irqreturn_t sunxi_musb_interrupt(int irq, void *__hci)
> * normally babble never happens treat it as disconnect.
> */
> if ((musb->int_usb & MUSB_INTR_BABBLE) && is_host_active(musb)) {
musb_interrupt() handle BABBLE in host mode, and has a glue hook
musb_platform_recover() in musb_recover_from_babble().
Maybe you can use it?
> + struct sunxi_glue *glue =
> + dev_get_drvdata(musb->controller->parent);
> +
> + dev_warn(musb->controller->parent, "babble, treating as disconnect\n");
> +
> musb->int_usb &= ~MUSB_INTR_BABBLE;
> musb->int_usb |= MUSB_INTR_DISCONNECT;
> + /*
> + * Fix the musb controller sometimes getting stuck in
> + * bdevice state after a babble error.
> + */
> + sun4i_usb_phy_force_session_end(glue->phy);
As I commented in PATCH 1/2, can you somehow reuse
sun4i_usb_phy_set_mode() instead?
> }
>
> if ((musb->int_usb & MUSB_INTR_RESET) && !is_host_active(musb)) {
> --
> 2.9.3
Regards,
-Bin.
^ permalink raw reply
* [PATCH 1/2] phy-sun4i-usb: Add sun4i_usb_phy_force_session_end() function
From: Bin Liu @ 2016-09-22 2:28 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <54119844-ce99-bf8c-fc6e-09bcc7523e4d@redhat.com>
Hi,
On Wed, Sep 21, 2016 at 11:05:33AM +0300, Hans de Goede wrote:
> Hi,
>
> On 09/20/2016 07:45 AM, Kishon Vijay Abraham I wrote:
> >Hi,
> >
> >On Sunday 18 September 2016 10:20 PM, Hans de Goede wrote:
> >>The sunxi musb has a bug where sometimes it will generate a babble
> >>error on device disconnect instead of a disconnect irq. When this
> >>happens the musb-controller switches from host mode to device mode
> >>(it clears MUSB_DEVCTL_SESSION and sets MUSB_DEVCTL_BDEVICE) and
> >>gets stuck in this state.
> >>
> >>Clearing this requires reporting Vbus low for 200 or more ms, but
> >>on some devices Vbus is simply always high (host-only mode, no Vbus
> >>control). The phy-sun4i-usb code already has code to force a session
> >>end for devices without Vbus control.
> >>
> >>This commit adds a sun4i_usb_phy_force_session_end() function exporting
> >>this functionality to the sunxi-musb glue, so that it can force a session
> >>end to fixup the stuck state after a babble error.
> >>
> >>Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> >>---
> >> drivers/phy/phy-sun4i-usb.c | 11 +++++++++++
> >> include/linux/phy/phy-sun4i-usb.h | 7 +++++++
> >> 2 files changed, 18 insertions(+)
> >>
> >>diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
> >>index 43c0d98..06f4e11a 100644
> >>--- a/drivers/phy/phy-sun4i-usb.c
> >>+++ b/drivers/phy/phy-sun4i-usb.c
> >>@@ -470,6 +470,17 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled)
> >> }
> >> EXPORT_SYMBOL_GPL(sun4i_usb_phy_set_squelch_detect);
> >>
> >>+void sun4i_usb_phy_force_session_end(struct phy *_phy)
> >>+{
> >>+ struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
> >>+ struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
> >>+
> >>+ data->id_det = -1;
> >>+ data->force_session_end = true;
> >>+ queue_delayed_work(system_wq, &data->detect, 0);
> >>+}
> >>+EXPORT_SYMBOL_GPL(sun4i_usb_phy_force_session_end);
> >
> >Er.. one more export symbol :-(
>
> Yes unfortunately we need one more to work around sunxi musb / phy bugs.
Instead, can you somehow reuse sun4i_usb_phy_set_mode()?
Regards,
-Bin.
>
> >>+
> >> static const struct phy_ops sun4i_usb_phy_ops = {
> >> .init = sun4i_usb_phy_init,
> >> .exit = sun4i_usb_phy_exit,
> >>diff --git a/include/linux/phy/phy-sun4i-usb.h b/include/linux/phy/phy-sun4i-usb.h
> >>index 50aed92..3bb773f 100644
> >>--- a/include/linux/phy/phy-sun4i-usb.h
> >>+++ b/include/linux/phy/phy-sun4i-usb.h
> >>@@ -23,4 +23,11 @@
> >> */
> >> void sun4i_usb_phy_set_squelch_detect(struct phy *phy, bool enabled);
> >>
> >>+/**
> >>+ * sun4i_usb_force_session_end() - Force the current session to end
> >>+ * by reporting VBus low for 200+ ms
> >>+ * @phy: reference to a sun4i usb phy
> >>+ */
> >>+void sun4i_usb_phy_force_session_end(struct phy *phy);
> >
> >Should we include a static inline function if sun4i phy is not defined?
>
> No, we're also not doing that for the already exported
> sun4i_usb_phy_set_squelch_detect()
>
> And it is not necessary since the only caller is drivers/usb/musb/sunxi.c,
> and drivers/usb/musb/Kconfig has:
>
> config USB_MUSB_SUNXI
> tristate "Allwinner (sunxi)"
> depends on PHY_SUN4I_USB
>
> Regards,
>
> Hans
^ permalink raw reply
* [PATCHv2] arm64: Correctly bounds check virt_addr_valid
From: Kees Cook @ 2016-09-21 23:49 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1474496704-30541-1-git-send-email-labbott@redhat.com>
On Wed, Sep 21, 2016 at 3:25 PM, Laura Abbott <labbott@redhat.com> wrote:
>
> virt_addr_valid is supposed to return true if and only if virt_to_page
> returns a valid page structure. The current macro does math on whatever
> address is given and passes that to pfn_valid to verify. vmalloc and
> module addresses can happen to generate a pfn that 'happens' to be
> valid. Fix this by only performing the pfn_valid check on addresses that
> have the potential to be valid.
>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Laura Abbott <labbott@redhat.com>
> ---
> v2: Properly parenthesize macro arguments. Re-factor to common macro.
>
> Also in case it wasn't clear, there's no need to try and squeeze this
> into 4.8. Hardened usercopy should have all the checks, this is just for
> full correctness.
After this lands for 4.9, I should likely drop the checks that are in
hardened usercopy? That'll speed things up ever so slightly, and will
let us catch other architectures that have a weird
virt_addr_valid()...
-Kees
--
Kees Cook
Nexus Security
^ permalink raw reply
* [GIT PULL] few minor fixes for omap dts files for v4.9 merge window
From: Tony Lindgren @ 2016-09-21 22:49 UTC (permalink / raw)
To: linux-arm-kernel
The following changes since commit a2a2b8215621536a7620e31f36bede81bb86680b:
Merge branch 'am335x-cpufreq-regression' into omap-for-v4.9/dt-v2 (2016-09-14 16:27:28 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap tags/omap-for-v4.9/dt-pt3-signed
for you to fetch changes up to ce385a5e7a85c023af2e013101d4fe2240beec21:
ARM: dts: omap5-igep0050.dts: Use tabs for indentation (2016-09-20 11:37:50 -0700)
----------------------------------------------------------------
Few fixes for omap dts files for v4.9 merge window. Let's also add
the tilcdc quirks:
- Fix typo with recent beagleboard-x15 changes for mmc2_pins_default
- Add am335x blue-and-red-wiring quirk as specified in the binding in
Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt. Also
fix up the whitespace formatting for am335x-evmsk.
- Fix for recent igepv5 power button for GPIO_ACTIVE_LOW. Also fix
up the whitespace formatting for the button
----------------------------------------------------------------
Jyri Sarha (3):
ARM: dts: am335x-evm: Add blue-and-red-wiring -property to lcdc node
ARM: dts: am335x-evmsk: Whitespace cleanup of lcdc related nodes
ARM: dts: am335x-evmsk: Add blue-and-red-wiring -property to lcdc node
Ladislav Michl (1):
ARM: dts: omap5-igep0050.dts: Use tabs for indentation
Nishanth Menon (1):
ARM: dts: am57xx-beagle-x15-common: Fix wrong pinctrl selection for mmc2
Tony Lindgren (1):
ARM: dts: Fix igepv5 power button GPIO direction
arch/arm/boot/dts/am335x-evm.dts | 2 ++
arch/arm/boot/dts/am335x-evmsk.dts | 42 +++++++++++++------------
arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi | 2 +-
arch/arm/boot/dts/omap5-igep0050.dts | 4 +--
4 files changed, 27 insertions(+), 23 deletions(-)
^ permalink raw reply
* [PATCH V6 0/5] ECAM quirks handling for ARM64 platforms
From: Christopher Covington @ 2016-09-21 22:40 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921131107.GB10804@localhost>
Hi Bjorn,
On 09/21/2016 09:11 AM, Bjorn Helgaas wrote:
> On Tue, Sep 20, 2016 at 09:15:14PM -0400, cov at codeaurora.org wrote:
>>> diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c
>>> index eb14f74..bb3b8ad 100644
>>> --- a/drivers/acpi/pci_mcfg.c
>>> +++ b/drivers/acpi/pci_mcfg.c
>>> @@ -42,86 +42,59 @@ struct mcfg_fixup {
>>> struct resource cfgres;
>>> };
>>>
>>> -#define MCFG_DOM_ANY (-1)
>>
>> Did you delete this because there were no current users, because you'd
>> prefer users just use "-1", or for some other reason?
>
> I removed it because there were no users of it and, more importantly,
> the code doesn't implement support for it.
It looks like a stale "First match against PCI topology <domain:bus>..."
comment remains.
Thanks,
Cov
--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code
Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply
* [PATCHv2] PCI: QDF2432 32 bit config space accessors
From: Christopher Covington @ 2016-09-21 22:38 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921173129.GA20006@localhost>
The Qualcomm Technologies QDF2432 SoC does not support accesses smaller
than 32 bits to the PCI configuration space. Register the appropriate
quirk.
Signed-off-by: Christopher Covington <cov@codeaurora.org>
---
drivers/acpi/pci_mcfg.c | 8 ++++++++
drivers/pci/ecam.c | 10 ++++++++++
include/linux/pci-ecam.h | 1 +
3 files changed, 19 insertions(+)
diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c
index 245b79f..212334f 100644
--- a/drivers/acpi/pci_mcfg.c
+++ b/drivers/acpi/pci_mcfg.c
@@ -96,6 +96,14 @@ static struct mcfg_fixup mcfg_quirks[] = {
THUNDER_ECAM_MCFG(2, 12),
THUNDER_ECAM_MCFG(2, 13),
#endif
+ { "QCOM ", "QDF2432 ", 1, 0, MCFG_BUS_ANY, &pci_32b_ops },
+ { "QCOM ", "QDF2432 ", 1, 1, MCFG_BUS_ANY, &pci_32b_ops },
+ { "QCOM ", "QDF2432 ", 1, 2, MCFG_BUS_ANY, &pci_32b_ops },
+ { "QCOM ", "QDF2432 ", 1, 3, MCFG_BUS_ANY, &pci_32b_ops },
+ { "QCOM ", "QDF2432 ", 1, 4, MCFG_BUS_ANY, &pci_32b_ops },
+ { "QCOM ", "QDF2432 ", 1, 5, MCFG_BUS_ANY, &pci_32b_ops },
+ { "QCOM ", "QDF2432 ", 1, 6, MCFG_BUS_ANY, &pci_32b_ops },
+ { "QCOM ", "QDF2432 ", 1, 7, MCFG_BUS_ANY, &pci_32b_ops },
};
static char mcfg_oem_id[ACPI_OEM_ID_SIZE];
diff --git a/drivers/pci/ecam.c b/drivers/pci/ecam.c
index 43ed08d..c3b3063 100644
--- a/drivers/pci/ecam.c
+++ b/drivers/pci/ecam.c
@@ -162,3 +162,13 @@ struct pci_ecam_ops pci_generic_ecam_ops = {
.write = pci_generic_config_write,
}
};
+
+/* ops for 32 bit config space access quirk */
+struct pci_ecam_ops pci_32b_ops = {
+ .bus_shift = 20,
+ .pci_ops = {
+ .map_bus = pci_ecam_map_bus,
+ .read = pci_generic_config_read32,
+ .write = pci_generic_config_write32,
+ }
+};
diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h
index 35f0e81..a6cffb8 100644
--- a/include/linux/pci-ecam.h
+++ b/include/linux/pci-ecam.h
@@ -65,6 +65,7 @@ extern struct pci_ecam_ops pci_thunder_pem_ops;
#ifdef CONFIG_PCI_HOST_THUNDER_ECAM
extern struct pci_ecam_ops pci_thunder_ecam_ops;
#endif
+extern struct pci_ecam_ops pci_32b_ops;
#ifdef CONFIG_PCI_HOST_GENERIC
/* for DT-based PCI controllers that support ECAM */
--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora
Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply related
* [PATCH v5 3/3] pci:aer: add support aer interrupt with none MSI/MSI-X/INTx mode
From: Bjorn Helgaas @ 2016-09-21 22:37 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1473741659-17618-3-git-send-email-po.liu@nxp.com>
On Tue, Sep 13, 2016 at 12:40:59PM +0800, Po Liu wrote:
> On some platforms, root port doesn't support MSI/MSI-X/INTx in RC mode.
> When chip support the aer interrupt with none MSI/MSI-X/INTx mode,
> maybe there is interrupt line for aer pme etc. Search the interrupt
> number in the fdt file. Then fixup the dev->irq with it.
>
> Signed-off-by: Po Liu <po.liu@nxp.com>
> ---
> changes for v5:
> - Add clear 'aer' interrup-names description
>
> .../devicetree/bindings/pci/layerscape-pci.txt | 11 +++++---
> drivers/pci/pcie/portdrv_core.c | 31 +++++++++++++++++++---
> 2 files changed, 35 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt b/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> index 41e9f55..101d0a7 100644
> --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> @@ -18,8 +18,10 @@ Required properties:
> - reg: base addresses and lengths of the PCIe controller
> - interrupts: A list of interrupt outputs of the controller. Must contain an
> entry for each entry in the interrupt-names property.
> -- interrupt-names: Must include the following entries:
> - "intr": The interrupt that is asserted for controller interrupts
> +- interrupt-names: It may be include the following entries:
> + "aer": The interrupt that is asserted for aer interrupt
> + "pme": The interrupt that is asserted for pme interrupt
> + ......
> - fsl,pcie-scfg: Must include two entries.
> The first entry must be a link to the SCFG device node
> The second entry must be '0' or '1' based on physical PCIe controller index.
> @@ -35,8 +37,9 @@ Example:
> reg = <0x00 0x03400000 0x0 0x00010000 /* controller registers */
> 0x40 0x00000000 0x0 0x00002000>; /* configuration space */
> reg-names = "regs", "config";
> - interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>; /* controller interrupt */
> - interrupt-names = "intr";
> + interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>, /* aer interrupt */
> + <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>; /* pme interrupt */
> + interrupt-names = "aer", "pme";
> fsl,pcie-scfg = <&scfg 0>;
> #address-cells = <3>;
> #size-cells = <2>;
> diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
> index e9270b4..7c4943d 100644
> --- a/drivers/pci/pcie/portdrv_core.c
> +++ b/drivers/pci/pcie/portdrv_core.c
> @@ -16,6 +16,7 @@
> #include <linux/slab.h>
> #include <linux/pcieport_if.h>
> #include <linux/aer.h>
> +#include <linux/of_irq.h>
>
> #include "../pci.h"
> #include "portdrv.h"
> @@ -200,6 +201,28 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
> static int init_service_irqs(struct pci_dev *dev, int *irqs, int mask)
> {
> int i, irq = -1;
> + int ret;
> + struct device_node *np = NULL;
> +
> + for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++)
> + irqs[i] = 0;
> +
> + if (dev->bus->dev.of_node)
> + np = dev->bus->dev.of_node;
> +
> + /* If root port doesn't support MSI/MSI-X/INTx in RC mode,
> + * request irq for aer
> + */
> + if (IS_ENABLED(CONFIG_OF_IRQ) && np &&
> + (mask & PCIE_PORT_SERVICE_PME)) {
> + ret = of_irq_get_byname(np, "aer");
> + if (ret > 0) {
> + irqs[PCIE_PORT_SERVICE_AER_SHIFT] = ret;
> + if (dev->irq)
> + irq = dev->irq;
> + goto no_msi;
> + }
> + }
We definitely need to solve this somehow. But this approach doesn't
feel quite right because it's hard to map this code back to anything
in the spec, and it uses a completely platform-dependent name
("interrupt-names aer") in code that is supposedly generic.
What if we added some sort of hook that would return the IRQ? Maybe a
pcibios_*() hook right now, with the idea of making it a
pci_host_bridge function pointer someday?
I know the body of the hook would look a lot like what you have here,
but at least it would be more obvious that it's platform-specific
code.
I think your platform supports PME interrupts as well as AER, and
they're different IRQs. So you'd probably have to do something
similar to the pcie_port_enable_msix() interface, so you can fill in
both IRQs.
> /*
> * If MSI cannot be used for PCIe PME or hotplug, we have to use
> @@ -225,11 +248,13 @@ static int init_service_irqs(struct pci_dev *dev, int *irqs, int mask)
> irq = dev->irq;
>
> no_msi:
> - for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++)
> - irqs[i] = irq;
> + for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) {
> + if (!irqs[i])
> + irqs[i] = irq;
> + }
> irqs[PCIE_PORT_SERVICE_VC_SHIFT] = -1;
>
> - if (irq < 0)
> + if (irq < 0 && irqs[PCIE_PORT_SERVICE_AER_SHIFT] < 0)
> return -ENODEV;
> return 0;
> }
> --
> 2.1.0.27.g96db324
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply
* [PATCHv2] arm64: Correctly bounds check virt_addr_valid
From: Laura Abbott @ 2016-09-21 22:25 UTC (permalink / raw)
To: linux-arm-kernel
virt_addr_valid is supposed to return true if and only if virt_to_page
returns a valid page structure. The current macro does math on whatever
address is given and passes that to pfn_valid to verify. vmalloc and
module addresses can happen to generate a pfn that 'happens' to be
valid. Fix this by only performing the pfn_valid check on addresses that
have the potential to be valid.
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Laura Abbott <labbott@redhat.com>
---
v2: Properly parenthesize macro arguments. Re-factor to common macro.
Also in case it wasn't clear, there's no need to try and squeeze this
into 4.8. Hardened usercopy should have all the checks, this is just for
full correctness.
---
arch/arm64/include/asm/memory.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 31b7322..ba62df8 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -214,7 +214,7 @@ static inline void *phys_to_virt(phys_addr_t x)
#ifndef CONFIG_SPARSEMEM_VMEMMAP
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
-#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
+#define _virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
#else
#define __virt_to_pgoff(kaddr) (((u64)(kaddr) & ~PAGE_OFFSET) / PAGE_SIZE * sizeof(struct page))
#define __page_to_voff(kaddr) (((u64)(page) & ~VMEMMAP_START) * PAGE_SIZE / sizeof(struct page))
@@ -222,11 +222,15 @@ static inline void *phys_to_virt(phys_addr_t x)
#define page_to_virt(page) ((void *)((__page_to_voff(page)) | PAGE_OFFSET))
#define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START))
-#define virt_addr_valid(kaddr) pfn_valid((((u64)(kaddr) & ~PAGE_OFFSET) \
+#define _virt_addr_valid(kaddr) pfn_valid((((u64)(kaddr) & ~PAGE_OFFSET) \
+ PHYS_OFFSET) >> PAGE_SHIFT)
#endif
#endif
+#define _virt_addr_is_linear(kaddr) (((u64)(kaddr)) >= PAGE_OFFSET)
+#define virt_addr_valid(kaddr) (_virt_addr_is_linear(kaddr) && \
+ _virt_addr_valid(kaddr))
+
#include <asm-generic/memory_model.h>
#endif
--
2.7.4
^ permalink raw reply related
* [PATCH v2 5/6] misc: sram: add Atmel securam support
From: Alexandre Belloni @ 2016-09-21 22:13 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921220939.27924-6-alexandre.belloni@free-electrons.com>
Greg,
As a reminder, I think we agreed that this one could go through the at91
tree because of the dependency on patch 2/6.
I'd like to get your ack though.
On 22/09/2016 at 00:09:38 +0200, Alexandre Belloni wrote :
> The Atmel secure SRAM is connected to a security module and may be erased
> automatically under certain conditions. For that reason, it is necessary to
> wait for the security module to flag that SRAM accesses are allowed before
> accessing it.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> drivers/misc/sram.c | 42 +++++++++++++++++++++++++++++++++++-------
> 1 file changed, 35 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
> index f84b53d6ce50..b0d4dd9b0586 100644
> --- a/drivers/misc/sram.c
> +++ b/drivers/misc/sram.c
> @@ -19,12 +19,17 @@
> */
>
> #include <linux/clk.h>
> +#include <linux/delay.h>
> #include <linux/genalloc.h>
> #include <linux/io.h>
> #include <linux/list_sort.h>
> #include <linux/of_address.h>
> +#include <linux/of_device.h>
> #include <linux/platform_device.h>
> +#include <linux/regmap.h>
> #include <linux/slab.h>
> +#include <linux/mfd/syscon.h>
> +#include <soc/at91/atmel-secumod.h>
>
> #define SRAM_GRANULARITY 32
>
> @@ -334,12 +339,35 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
> return ret;
> }
>
> +static int atmel_securam_wait(void)
> +{
> + struct regmap *regmap;
> + u32 val;
> +
> + regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-secumod");
> + if (IS_ERR(regmap))
> + return -ENODEV;
> +
> + return regmap_read_poll_timeout(regmap, AT91_SECUMOD_RAMRDY, val,
> + val & AT91_SECUMOD_RAMRDY_READY,
> + 10000, 500000);
> +}
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id sram_dt_ids[] = {
> + { .compatible = "mmio-sram" },
> + { .compatible = "atmel,sama5d2-securam", .data = atmel_securam_wait },
> + {}
> +};
> +#endif
> +
> static int sram_probe(struct platform_device *pdev)
> {
> struct sram_dev *sram;
> struct resource *res;
> size_t size;
> int ret;
> + int (*init_func)(void);
>
> sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL);
> if (!sram)
> @@ -384,6 +412,13 @@ static int sram_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, sram);
>
> + init_func = of_device_get_match_data(&pdev->dev);
> + if (init_func) {
> + ret = init_func();
> + if (ret)
> + return ret;
> + }
> +
> dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
> gen_pool_size(sram->pool) / 1024, sram->virt_base);
>
> @@ -405,13 +440,6 @@ static int sram_remove(struct platform_device *pdev)
> return 0;
> }
>
> -#ifdef CONFIG_OF
> -static const struct of_device_id sram_dt_ids[] = {
> - { .compatible = "mmio-sram" },
> - {}
> -};
> -#endif
> -
> static struct platform_driver sram_driver = {
> .driver = {
> .name = "sram",
> --
> 2.9.3
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply
* [PATCH v2 6/6] ARM: dts: at91: sama5d2: Add securam node
From: Alexandre Belloni @ 2016-09-21 22:09 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921220939.27924-1-alexandre.belloni@free-electrons.com>
The sama5d2 has some static RAM that can be erased by the security module,
add its node
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/boot/dts/sama5d2.dtsi | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index 0b62bff86f49..a3653751a7d6 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -706,6 +706,11 @@
atmel,clk-output-range = <0 83000000>;
};
+ securam_clk: securam_clk {
+ #clock-cells = <0>;
+ reg = <51>;
+ };
+
i2s0_clk: i2s0_clk {
#clock-cells = <0>;
reg = <54>;
@@ -1029,6 +1034,15 @@
status = "disabled";
};
+ securam: sram at f8044000 {
+ compatible = "atmel,sama5d2-securam", "mmio-sram";
+ reg = <0xf8044000 0x1420>;
+ clocks = <&securam_clk>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges = <0 0xf8044000 0x1420>;
+ };
+
rstc at f8048000 {
compatible = "atmel,sama5d3-rstc";
reg = <0xf8048000 0x10>;
--
2.9.3
^ permalink raw reply related
* [PATCH v2 5/6] misc: sram: add Atmel securam support
From: Alexandre Belloni @ 2016-09-21 22:09 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921220939.27924-1-alexandre.belloni@free-electrons.com>
The Atmel secure SRAM is connected to a security module and may be erased
automatically under certain conditions. For that reason, it is necessary to
wait for the security module to flag that SRAM accesses are allowed before
accessing it.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/sram.c | 42 +++++++++++++++++++++++++++++++++++-------
1 file changed, 35 insertions(+), 7 deletions(-)
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index f84b53d6ce50..b0d4dd9b0586 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -19,12 +19,17 @@
*/
#include <linux/clk.h>
+#include <linux/delay.h>
#include <linux/genalloc.h>
#include <linux/io.h>
#include <linux/list_sort.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
#include <linux/slab.h>
+#include <linux/mfd/syscon.h>
+#include <soc/at91/atmel-secumod.h>
#define SRAM_GRANULARITY 32
@@ -334,12 +339,35 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
return ret;
}
+static int atmel_securam_wait(void)
+{
+ struct regmap *regmap;
+ u32 val;
+
+ regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-secumod");
+ if (IS_ERR(regmap))
+ return -ENODEV;
+
+ return regmap_read_poll_timeout(regmap, AT91_SECUMOD_RAMRDY, val,
+ val & AT91_SECUMOD_RAMRDY_READY,
+ 10000, 500000);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id sram_dt_ids[] = {
+ { .compatible = "mmio-sram" },
+ { .compatible = "atmel,sama5d2-securam", .data = atmel_securam_wait },
+ {}
+};
+#endif
+
static int sram_probe(struct platform_device *pdev)
{
struct sram_dev *sram;
struct resource *res;
size_t size;
int ret;
+ int (*init_func)(void);
sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL);
if (!sram)
@@ -384,6 +412,13 @@ static int sram_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, sram);
+ init_func = of_device_get_match_data(&pdev->dev);
+ if (init_func) {
+ ret = init_func();
+ if (ret)
+ return ret;
+ }
+
dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
gen_pool_size(sram->pool) / 1024, sram->virt_base);
@@ -405,13 +440,6 @@ static int sram_remove(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_OF
-static const struct of_device_id sram_dt_ids[] = {
- { .compatible = "mmio-sram" },
- {}
-};
-#endif
-
static struct platform_driver sram_driver = {
.driver = {
.name = "sram",
--
2.9.3
^ permalink raw reply related
* [PATCH v2 4/6] misc: sram: document new compatible
From: Alexandre Belloni @ 2016-09-21 22:09 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921220939.27924-1-alexandre.belloni@free-electrons.com>
Add atmel,sama5d2-securam to the compatible list.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/sram/sram.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sram/sram.txt b/Documentation/devicetree/bindings/sram/sram.txt
index add48f09015e..068c2c03c38f 100644
--- a/Documentation/devicetree/bindings/sram/sram.txt
+++ b/Documentation/devicetree/bindings/sram/sram.txt
@@ -4,7 +4,7 @@ Simple IO memory regions to be managed by the genalloc API.
Required properties:
-- compatible : mmio-sram
+- compatible : mmio-sram or atmel,sama5d2-securam
- reg : SRAM iomem address range
--
2.9.3
^ permalink raw reply related
* [PATCH v2 3/6] ARM: dts: at91: sama5d2: Add secumod node
From: Alexandre Belloni @ 2016-09-21 22:09 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20160921220939.27924-1-alexandre.belloni@free-electrons.com>
The sama5d2 has a security module, add its node.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/boot/dts/sama5d2.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index 353d0e5ec83b..0b62bff86f49 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -1231,6 +1231,11 @@
clocks = <&pioA_clk>;
};
+ secumod at fc040000 {
+ compatible = "atmel,sama5d2-secumod", "syscon";
+ reg = <0xfc040000 0x100>;
+ };
+
tdes at fc044000 {
compatible = "atmel,at91sam9g46-tdes";
reg = <0xfc044000 0x100>;
--
2.9.3
^ 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