mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] intel_th: Fixes for v5.19
@ 2022-07-05  8:26 Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 1/6] intel_th: Fix a resource leak in an error handling path Alexander Shishkin
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Alexander Shishkin @ 2022-07-05  8:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alexander Shishkin

Hi Greg,

Here are a few fixes I have for v5.19, among which are 3 new PCI IDs. Andy
provided his reviewed-bys. Please consider applying. Thanks!

Alexander Shishkin (4):
  intel_th: msu: Fix vmalloced buffers
  intel_th: pci: Add Meteor Lake-P support
  intel_th: pci: Add Raptor Lake-S PCH support
  intel_th: pci: Add Raptor Lake-S CPU support

Christophe JAILLET (1):
  intel_th: Fix a resource leak in an error handling path

Jiasheng Jiang (1):
  intel_th: msu-sink: Potential dereference of null pointer

 drivers/hwtracing/intel_th/msu-sink.c |  3 +++
 drivers/hwtracing/intel_th/msu.c      | 14 ++++++++++++--
 drivers/hwtracing/intel_th/pci.c      | 25 +++++++++++++++++++++++--
 3 files changed, 38 insertions(+), 4 deletions(-)

-- 
2.35.1


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

* [PATCH 1/6] intel_th: Fix a resource leak in an error handling path
  2022-07-05  8:26 [PATCH 0/6] intel_th: Fixes for v5.19 Alexander Shishkin
@ 2022-07-05  8:26 ` Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 2/6] intel_th: msu-sink: Potential dereference of null pointer Alexander Shishkin
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Alexander Shishkin @ 2022-07-05  8:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Christophe JAILLET, Alexander Shishkin, Andy Shevchenko

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

If an error occurs after calling 'pci_alloc_irq_vectors()',
'pci_free_irq_vectors()' must be called as already done in the remove
function.

Fixes: 7b7036d47c35 ("intel_th: pci: Use MSI interrupt signalling")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwtracing/intel_th/pci.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
index 7da4f298ed01..fcd0aca75007 100644
--- a/drivers/hwtracing/intel_th/pci.c
+++ b/drivers/hwtracing/intel_th/pci.c
@@ -100,8 +100,10 @@ static int intel_th_pci_probe(struct pci_dev *pdev,
 		}
 
 	th = intel_th_alloc(&pdev->dev, drvdata, resource, r);
-	if (IS_ERR(th))
-		return PTR_ERR(th);
+	if (IS_ERR(th)) {
+		err = PTR_ERR(th);
+		goto err_free_irq;
+	}
 
 	th->activate   = intel_th_pci_activate;
 	th->deactivate = intel_th_pci_deactivate;
@@ -109,6 +111,10 @@ static int intel_th_pci_probe(struct pci_dev *pdev,
 	pci_set_master(pdev);
 
 	return 0;
+
+err_free_irq:
+	pci_free_irq_vectors(pdev);
+	return err;
 }
 
 static void intel_th_pci_remove(struct pci_dev *pdev)
-- 
2.35.1


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

* [PATCH 2/6] intel_th: msu-sink: Potential dereference of null pointer
  2022-07-05  8:26 [PATCH 0/6] intel_th: Fixes for v5.19 Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 1/6] intel_th: Fix a resource leak in an error handling path Alexander Shishkin
@ 2022-07-05  8:26 ` Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 3/6] intel_th: msu: Fix vmalloced buffers Alexander Shishkin
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Alexander Shishkin @ 2022-07-05  8:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jiasheng Jiang, Alexander Shishkin, Andy Shevchenko

From: Jiasheng Jiang <jiasheng@iscas.ac.cn>

The return value of dma_alloc_coherent() needs to be checked.
To avoid use of null pointer in sg_set_buf() in case of the failure of
alloc.

Fixes: f220df66f676 ("intel_th: msu-sink: An example msu buffer "sink"")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwtracing/intel_th/msu-sink.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/hwtracing/intel_th/msu-sink.c b/drivers/hwtracing/intel_th/msu-sink.c
index 2c7f5116be12..891b28ea25fe 100644
--- a/drivers/hwtracing/intel_th/msu-sink.c
+++ b/drivers/hwtracing/intel_th/msu-sink.c
@@ -71,6 +71,9 @@ static int msu_sink_alloc_window(void *data, struct sg_table **sgt, size_t size)
 		block = dma_alloc_coherent(priv->dev->parent->parent,
 					   PAGE_SIZE, &sg_dma_address(sg_ptr),
 					   GFP_KERNEL);
+		if (!block)
+			return -ENOMEM;
+
 		sg_set_buf(sg_ptr, block, PAGE_SIZE);
 	}
 
-- 
2.35.1


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

* [PATCH 3/6] intel_th: msu: Fix vmalloced buffers
  2022-07-05  8:26 [PATCH 0/6] intel_th: Fixes for v5.19 Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 1/6] intel_th: Fix a resource leak in an error handling path Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 2/6] intel_th: msu-sink: Potential dereference of null pointer Alexander Shishkin
@ 2022-07-05  8:26 ` Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 4/6] intel_th: pci: Add Meteor Lake-P support Alexander Shishkin
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Alexander Shishkin @ 2022-07-05  8:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alexander Shishkin, Andy Shevchenko

After commit f5ff79fddf0e ("dma-mapping: remove CONFIG_DMA_REMAP") there's
a chance of DMA buffer getting allocated via vmalloc(), which messes up
the mmapping code:

> RIP: msc_mmap_fault [intel_th_msu]
> Call Trace:
>  <TASK>
>  __do_fault
>  do_fault
...

Fix this by accounting for vmalloc possibility.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Fixes: ba39bd830605 ("intel_th: msu: Switch over to scatterlist")
---
 drivers/hwtracing/intel_th/msu.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index 70a07b4e9967..6c8215a47a60 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1067,6 +1067,16 @@ msc_buffer_set_uc(struct msc *msc) {}
 static inline void msc_buffer_set_wb(struct msc *msc) {}
 #endif /* CONFIG_X86 */
 
+static struct page *msc_sg_page(struct scatterlist *sg)
+{
+	void *addr = sg_virt(sg);
+
+	if (is_vmalloc_addr(addr))
+		return vmalloc_to_page(addr);
+
+	return sg_page(sg);
+}
+
 /**
  * msc_buffer_win_alloc() - alloc a window for a multiblock mode
  * @msc:	MSC device
@@ -1137,7 +1147,7 @@ static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win)
 	int i;
 
 	for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) {
-		struct page *page = sg_page(sg);
+		struct page *page = msc_sg_page(sg);
 
 		page->mapping = NULL;
 		dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE,
@@ -1401,7 +1411,7 @@ static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff)
 	pgoff -= win->pgoff;
 
 	for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) {
-		struct page *page = sg_page(sg);
+		struct page *page = msc_sg_page(sg);
 		size_t pgsz = PFN_DOWN(sg->length);
 
 		if (pgoff < pgsz)
-- 
2.35.1


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

* [PATCH 4/6] intel_th: pci: Add Meteor Lake-P support
  2022-07-05  8:26 [PATCH 0/6] intel_th: Fixes for v5.19 Alexander Shishkin
                   ` (2 preceding siblings ...)
  2022-07-05  8:26 ` [PATCH 3/6] intel_th: msu: Fix vmalloced buffers Alexander Shishkin
@ 2022-07-05  8:26 ` Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 5/6] intel_th: pci: Add Raptor Lake-S PCH support Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 6/6] intel_th: pci: Add Raptor Lake-S CPU support Alexander Shishkin
  5 siblings, 0 replies; 7+ messages in thread
From: Alexander Shishkin @ 2022-07-05  8:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alexander Shishkin, Andy Shevchenko

Add support for the Trace Hub in Meteor Lake-P.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwtracing/intel_th/pci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
index fcd0aca75007..41a31c7f505f 100644
--- a/drivers/hwtracing/intel_th/pci.c
+++ b/drivers/hwtracing/intel_th/pci.c
@@ -284,6 +284,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x54a6),
 		.driver_data = (kernel_ulong_t)&intel_th_2x,
 	},
+	{
+		/* Meteor Lake-P */
+		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x7e24),
+		.driver_data = (kernel_ulong_t)&intel_th_2x,
+	},
 	{
 		/* Alder Lake CPU */
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x466f),
-- 
2.35.1


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

* [PATCH 5/6] intel_th: pci: Add Raptor Lake-S PCH support
  2022-07-05  8:26 [PATCH 0/6] intel_th: Fixes for v5.19 Alexander Shishkin
                   ` (3 preceding siblings ...)
  2022-07-05  8:26 ` [PATCH 4/6] intel_th: pci: Add Meteor Lake-P support Alexander Shishkin
@ 2022-07-05  8:26 ` Alexander Shishkin
  2022-07-05  8:26 ` [PATCH 6/6] intel_th: pci: Add Raptor Lake-S CPU support Alexander Shishkin
  5 siblings, 0 replies; 7+ messages in thread
From: Alexander Shishkin @ 2022-07-05  8:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alexander Shishkin, Andy Shevchenko

Add support for the Trace Hub in Raptor Lake-S PCH.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwtracing/intel_th/pci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
index 41a31c7f505f..5b6da26f1b63 100644
--- a/drivers/hwtracing/intel_th/pci.c
+++ b/drivers/hwtracing/intel_th/pci.c
@@ -289,6 +289,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x7e24),
 		.driver_data = (kernel_ulong_t)&intel_th_2x,
 	},
+	{
+		/* Raptor Lake-S */
+		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x7a26),
+		.driver_data = (kernel_ulong_t)&intel_th_2x,
+	},
 	{
 		/* Alder Lake CPU */
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x466f),
-- 
2.35.1


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

* [PATCH 6/6] intel_th: pci: Add Raptor Lake-S CPU support
  2022-07-05  8:26 [PATCH 0/6] intel_th: Fixes for v5.19 Alexander Shishkin
                   ` (4 preceding siblings ...)
  2022-07-05  8:26 ` [PATCH 5/6] intel_th: pci: Add Raptor Lake-S PCH support Alexander Shishkin
@ 2022-07-05  8:26 ` Alexander Shishkin
  5 siblings, 0 replies; 7+ messages in thread
From: Alexander Shishkin @ 2022-07-05  8:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alexander Shishkin, Andy Shevchenko

Add support for the Trace Hub in Raptor Lake-S CPU.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwtracing/intel_th/pci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
index 5b6da26f1b63..147d338c191e 100644
--- a/drivers/hwtracing/intel_th/pci.c
+++ b/drivers/hwtracing/intel_th/pci.c
@@ -294,6 +294,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x7a26),
 		.driver_data = (kernel_ulong_t)&intel_th_2x,
 	},
+	{
+		/* Raptor Lake-S CPU */
+		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa76f),
+		.driver_data = (kernel_ulong_t)&intel_th_2x,
+	},
 	{
 		/* Alder Lake CPU */
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x466f),
-- 
2.35.1


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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-05  8:26 [PATCH 0/6] intel_th: Fixes for v5.19 Alexander Shishkin
2022-07-05  8:26 ` [PATCH 1/6] intel_th: Fix a resource leak in an error handling path Alexander Shishkin
2022-07-05  8:26 ` [PATCH 2/6] intel_th: msu-sink: Potential dereference of null pointer Alexander Shishkin
2022-07-05  8:26 ` [PATCH 3/6] intel_th: msu: Fix vmalloced buffers Alexander Shishkin
2022-07-05  8:26 ` [PATCH 4/6] intel_th: pci: Add Meteor Lake-P support Alexander Shishkin
2022-07-05  8:26 ` [PATCH 5/6] intel_th: pci: Add Raptor Lake-S PCH support Alexander Shishkin
2022-07-05  8:26 ` [PATCH 6/6] intel_th: pci: Add Raptor Lake-S CPU support 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®