mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [GIT PULL 0/2] stm class/intel_th: Fixes for v4.17
@ 2018-05-24  8:27 Alexander Shishkin
  2018-05-24  8:27 ` [GIT PULL 1/2] stm class: Use vmalloc for the master map Alexander Shishkin
  2018-05-24  8:27 ` [GIT PULL 2/2] intel_th: Use correct device when freeing buffers Alexander Shishkin
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Shishkin @ 2018-05-24  8:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alexander Shishkin

Hi Greg,

These are 2 fixes I have for this release cycle, pretty straightforward.
Static checkers approve. Individual patches follow. Please consider pulling
or applying. Thanks!

The following changes since commit 60cc43fc888428bb2f18f08997432d426a243338:

  Linux 4.17-rc1 (2018-04-15 18:24:20 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm.git tags/stm-intel_th-fixes-for-greg-20180524

for you to fetch changes up to 3ce35db3ff05400e5676d0155cf261cc6bd3d351:

  intel_th: Use correct device when freeing buffers (2018-05-24 10:55:03 +0300)

----------------------------------------------------------------
stm class/intel_th: Fixes for v4.17-rc1

These are 2 fixes, both backportable to stable:
  * stm master array allocation moved to vmalloc
  * intel_th/msu dma buffer deallocation fix.

----------------------------------------------------------------
Alexander Shishkin (2):
      stm class: Use vmalloc for the master map
      intel_th: Use correct device when freeing buffers

 drivers/hwtracing/intel_th/msu.c | 6 +++---
 drivers/hwtracing/stm/core.c     | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.17.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [GIT PULL 1/2] stm class: Use vmalloc for the master map
  2018-05-24  8:27 [GIT PULL 0/2] stm class/intel_th: Fixes for v4.17 Alexander Shishkin
@ 2018-05-24  8:27 ` Alexander Shishkin
  2018-05-24  8:27 ` [GIT PULL 2/2] intel_th: Use correct device when freeing buffers Alexander Shishkin
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Shishkin @ 2018-05-24  8:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alexander Shishkin, stable

Fengguang is running into a warning from the buddy allocator:

> swapper/0: page allocation failure: order:9, mode:0x14040c0(GFP_KERNEL|__GFP_COMP), nodemask=(null)
> CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.17.0-rc1 #262
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
> Call Trace:
...
>  __kmalloc+0x14b/0x180: ____cache_alloc at mm/slab.c:3127
>  stm_register_device+0xf3/0x5c0: stm_register_device at drivers/hwtracing/stm/core.c:695
...

Which is basically a result of the stm class trying to allocate ~512kB
for the dummy_stm with its default parameters. There's no reason, however,
for it not to be vmalloc()ed instead, which is what this patch does.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
CC: stable@vger.kernel.org # v4.4+
---
 drivers/hwtracing/stm/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 05386b76465e..657badb479a5 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -674,7 +674,7 @@ static void stm_device_release(struct device *dev)
 {
 	struct stm_device *stm = to_stm_device(dev);
 
-	kfree(stm);
+	vfree(stm);
 }
 
 int stm_register_device(struct device *parent, struct stm_data *stm_data,
@@ -691,7 +691,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
 		return -EINVAL;
 
 	nmasters = stm_data->sw_end - stm_data->sw_start + 1;
-	stm = kzalloc(sizeof(*stm) + nmasters * sizeof(void *), GFP_KERNEL);
+	stm = vzalloc(sizeof(*stm) + nmasters * sizeof(void *));
 	if (!stm)
 		return -ENOMEM;
 
@@ -744,7 +744,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
 	/* matches device_initialize() above */
 	put_device(&stm->dev);
 err_free:
-	kfree(stm);
+	vfree(stm);
 
 	return err;
 }
-- 
2.17.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [GIT PULL 2/2] intel_th: Use correct device when freeing buffers
  2018-05-24  8:27 [GIT PULL 0/2] stm class/intel_th: Fixes for v4.17 Alexander Shishkin
  2018-05-24  8:27 ` [GIT PULL 1/2] stm class: Use vmalloc for the master map Alexander Shishkin
@ 2018-05-24  8:27 ` Alexander Shishkin
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Shishkin @ 2018-05-24  8:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alexander Shishkin, stable

Commit d5c435df4a890 ("intel_th: msu: Use the real device in case of IOMMU
domain allocation") changes dma buffer allocation to use the actual
underlying device, but forgets to change the deallocation path, which leads
to (if you've got CAP_SYS_RAWIO):

> # echo 0,0 > /sys/bus/intel_th/devices/0-msc0/nr_pages
> ------------[ cut here ]------------
> kernel BUG at ../linux/drivers/iommu/intel-iommu.c:3670!
> CPU: 3 PID: 231 Comm: sh Not tainted 4.17.0-rc1+ #2729
> RIP: 0010:intel_unmap+0x11e/0x130
...
> Call Trace:
>  intel_free_coherent+0x3e/0x60
>  msc_buffer_win_free+0x100/0x160 [intel_th_msu]

This patch fixes the buffer deallocation code to use the correct device.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: d5c435df4a890 ("intel_th: msu: Use the real device in case of IOMMU domain allocation")
Reported-by: Baofeng Tian <baofeng.tian@intel.com>
CC: stable@vger.kernel.org # v4.14+
---
 drivers/hwtracing/intel_th/msu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index ede388309376..634f58042c77 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -733,8 +733,8 @@ static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks)
 		/* Reset the page to write-back before releasing */
 		set_memory_wb((unsigned long)win->block[i].bdesc, 1);
 #endif
-		dma_free_coherent(msc_dev(msc), size, win->block[i].bdesc,
-				  win->block[i].addr);
+		dma_free_coherent(msc_dev(msc)->parent->parent, size,
+				  win->block[i].bdesc, win->block[i].addr);
 	}
 	kfree(win);
 
@@ -769,7 +769,7 @@ static void msc_buffer_win_free(struct msc *msc, struct msc_window *win)
 		/* Reset the page to write-back before releasing */
 		set_memory_wb((unsigned long)win->block[i].bdesc, 1);
 #endif
-		dma_free_coherent(msc_dev(win->msc), PAGE_SIZE,
+		dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE,
 				  win->block[i].bdesc, win->block[i].addr);
 	}
 
-- 
2.17.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-24  8:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-24  8:27 [GIT PULL 0/2] stm class/intel_th: Fixes for v4.17 Alexander Shishkin
2018-05-24  8:27 ` [GIT PULL 1/2] stm class: Use vmalloc for the master map Alexander Shishkin
2018-05-24  8:27 ` [GIT PULL 2/2] intel_th: Use correct device when freeing buffers Alexander Shishkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®