stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 1/4] intel_th: pci: Add Comet Lake PCH-V support
       [not found] <20191217115527.74383-1-alexander.shishkin@linux.intel.com>
@ 2019-12-17 11:55 ` Alexander Shishkin
  2019-12-17 11:55 ` [GIT PULL 2/4] intel_th: pci: Add Elkhart Lake SOC support Alexander Shishkin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Alexander Shishkin @ 2019-12-17 11:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Alexander Shishkin, Andy Shevchenko, stable

This adds Intel(R) Trace Hub PCI ID for Comet Lake PCH-V.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: <stable@vger.kernel.org>
---
 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 ebf3e30e989a..4b2f37578da3 100644
--- a/drivers/hwtracing/intel_th/pci.c
+++ b/drivers/hwtracing/intel_th/pci.c
@@ -204,6 +204,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x06a6),
 		.driver_data = (kernel_ulong_t)&intel_th_2x,
 	},
+	{
+		/* Comet Lake PCH-V */
+		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa3a6),
+		.driver_data = (kernel_ulong_t)&intel_th_2x,
+	},
 	{
 		/* Ice Lake NNPI */
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x45c5),
-- 
2.24.0


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

* [GIT PULL 2/4] intel_th: pci: Add Elkhart Lake SOC support
       [not found] <20191217115527.74383-1-alexander.shishkin@linux.intel.com>
  2019-12-17 11:55 ` [GIT PULL 1/4] intel_th: pci: Add Comet Lake PCH-V support Alexander Shishkin
@ 2019-12-17 11:55 ` Alexander Shishkin
  2019-12-17 11:55 ` [GIT PULL 3/4] intel_th: Fix freeing IRQs Alexander Shishkin
  2019-12-17 11:55 ` [GIT PULL 4/4] intel_th: msu: Fix window switching without windows Alexander Shishkin
  3 siblings, 0 replies; 6+ messages in thread
From: Alexander Shishkin @ 2019-12-17 11:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Alexander Shishkin, Andy Shevchenko, stable

This adds support for Intel Trace Hub in Elkhart Lake.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: stable@vger.kernel.org
---
 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 4b2f37578da3..e9d90b53bbc4 100644
--- a/drivers/hwtracing/intel_th/pci.c
+++ b/drivers/hwtracing/intel_th/pci.c
@@ -234,6 +234,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4da6),
 		.driver_data = (kernel_ulong_t)&intel_th_2x,
 	},
+	{
+		/* Elkhart Lake */
+		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4b26),
+		.driver_data = (kernel_ulong_t)&intel_th_2x,
+	},
 	{ 0 },
 };
 
-- 
2.24.0


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

* [GIT PULL 3/4] intel_th: Fix freeing IRQs
       [not found] <20191217115527.74383-1-alexander.shishkin@linux.intel.com>
  2019-12-17 11:55 ` [GIT PULL 1/4] intel_th: pci: Add Comet Lake PCH-V support Alexander Shishkin
  2019-12-17 11:55 ` [GIT PULL 2/4] intel_th: pci: Add Elkhart Lake SOC support Alexander Shishkin
@ 2019-12-17 11:55 ` Alexander Shishkin
  2019-12-17 11:55 ` [GIT PULL 4/4] intel_th: msu: Fix window switching without windows Alexander Shishkin
  3 siblings, 0 replies; 6+ messages in thread
From: Alexander Shishkin @ 2019-12-17 11:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Alexander Shishkin, Andy Shevchenko, Ammy Yi, stable

Commit aac8da65174a ("intel_th: msu: Start handling IRQs") implicitly
relies on the use of devm_request_irq() to subsequently free the irqs on
device removal, but in case of the pci_free_irq_vectors() API, the
handlers need to be freed before it is called. Therefore, at the moment
the driver's remove path trips a BUG_ON(irq_has_action()):

> kernel BUG at drivers/pci/msi.c:375!
> invalid opcode: 0000 1 SMP
> CPU: 2 PID: 818 Comm: rmmod Not tainted 5.5.0-rc1+ #1
> RIP: 0010:free_msi_irqs+0x67/0x1c0
> pci_disable_msi+0x116/0x150
> pci_free_irq_vectors+0x1b/0x20
> intel_th_pci_remove+0x22/0x30 [intel_th_pci]
> pci_device_remove+0x3e/0xb0
> device_release_driver_internal+0xf0/0x1c0
> driver_detach+0x4c/0x8f
> bus_remove_driver+0x5c/0xd0
> driver_unregister+0x31/0x50
> pci_unregister_driver+0x40/0x90
> intel_th_pci_driver_exit+0x10/0xad6 [intel_th_pci]
> __x64_sys_delete_module+0x147/0x290
> ? exit_to_usermode_loop+0xd7/0x120
> do_syscall_64+0x57/0x1b0
> entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fix this by explicitly freeing irqs before freeing the vectors. We keep
using the devm_* variants because they are still useful in early error
paths.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Fixes: aac8da65174a ("intel_th: msu: Start handling IRQs")
Reported-by: Ammy Yi <ammy.yi@intel.com>
Tested-by: Ammy Yi <ammy.yi@intel.com>
Cc: stable@vger.kernel.org # v5.2+
---
 drivers/hwtracing/intel_th/core.c     | 7 ++++---
 drivers/hwtracing/intel_th/intel_th.h | 2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
index 0dfd97bbde9e..ca232ec565e8 100644
--- a/drivers/hwtracing/intel_th/core.c
+++ b/drivers/hwtracing/intel_th/core.c
@@ -834,9 +834,6 @@ static irqreturn_t intel_th_irq(int irq, void *data)
 			ret |= d->irq(th->thdev[i]);
 	}
 
-	if (ret == IRQ_NONE)
-		pr_warn_ratelimited("nobody cared for irq\n");
-
 	return ret;
 }
 
@@ -887,6 +884,7 @@ intel_th_alloc(struct device *dev, struct intel_th_drvdata *drvdata,
 
 			if (th->irq == -1)
 				th->irq = devres[r].start;
+			th->num_irqs++;
 			break;
 		default:
 			dev_warn(dev, "Unknown resource type %lx\n",
@@ -940,6 +938,9 @@ void intel_th_free(struct intel_th *th)
 
 	th->num_thdevs = 0;
 
+	for (i = 0; i < th->num_irqs; i++)
+		devm_free_irq(th->dev, th->irq + i, th);
+
 	pm_runtime_get_sync(th->dev);
 	pm_runtime_forbid(th->dev);
 
diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h
index 0df480072b6c..6f4f5486fe6d 100644
--- a/drivers/hwtracing/intel_th/intel_th.h
+++ b/drivers/hwtracing/intel_th/intel_th.h
@@ -261,6 +261,7 @@ enum th_mmio_idx {
  * @num_thdevs:	number of devices in the @thdev array
  * @num_resources:	number of resources in the @resource array
  * @irq:	irq number
+ * @num_irqs:	number of IRQs is use
  * @id:		this Intel TH controller's device ID in the system
  * @major:	device node major for output devices
  */
@@ -277,6 +278,7 @@ struct intel_th {
 	unsigned int		num_thdevs;
 	unsigned int		num_resources;
 	int			irq;
+	int			num_irqs;
 
 	int			id;
 	int			major;
-- 
2.24.0


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

* [GIT PULL 4/4] intel_th: msu: Fix window switching without windows
       [not found] <20191217115527.74383-1-alexander.shishkin@linux.intel.com>
                   ` (2 preceding siblings ...)
  2019-12-17 11:55 ` [GIT PULL 3/4] intel_th: Fix freeing IRQs Alexander Shishkin
@ 2019-12-17 11:55 ` Alexander Shishkin
  2019-12-17 12:06   ` Greg Kroah-Hartman
  3 siblings, 1 reply; 6+ messages in thread
From: Alexander Shishkin @ 2019-12-17 11:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Alexander Shishkin, Andy Shevchenko, Ammy Yi, stable

Commit 6cac7866c2741 ("intel_th: msu: Add a sysfs attribute to trigger
window switch") adds a NULL pointer dereference in the case when there are
no windows allocated:

> BUG: kernel NULL pointer dereference, address: 0000000000000000
> #PF: supervisor read access in kernel mode
> #PF: error_code(0x0000) - not-present page
> PGD 0 P4D 0
> Oops: 0000 1 SMP
> CPU: 5 PID: 1110 Comm: bash Not tainted 5.5.0-rc1+ #1
> RIP: 0010:msc_win_switch+0xa/0x80 [intel_th_msu]
> Call Trace:
> ? win_switch_store+0x9b/0xc0 [intel_th_msu]
> dev_attr_store+0x17/0x30
> sysfs_kf_write+0x3e/0x50
> kernfs_fop_write+0xda/0x1b0
> __vfs_write+0x1b/0x40
> vfs_write+0xb9/0x1a0
> ksys_write+0x67/0xe0
> __x64_sys_write+0x1a/0x20
> do_syscall_64+0x57/0x1d0
> entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fix that by disallowing window switching with multiwindow buffers without
windows.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 6cac7866c2741 ("intel_th: msu: Add a sysfs attribute to trigger window switch")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: Ammy Yi <ammy.yi@intel.com>
Tested-by: Ammy Yi <ammy.yi@intel.com>
Cc: stable@vger.kernel.org # v5.2+
---
 drivers/hwtracing/intel_th/msu.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index 6d240dfae9d9..8e48c7458aa3 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1676,10 +1676,13 @@ static int intel_th_msc_init(struct msc *msc)
 	return 0;
 }
 
-static void msc_win_switch(struct msc *msc)
+static int msc_win_switch(struct msc *msc)
 {
 	struct msc_window *first;
 
+	if (list_empty(&msc->win_list))
+		return -EINVAL;
+
 	first = list_first_entry(&msc->win_list, struct msc_window, entry);
 
 	if (msc_is_last_win(msc->cur_win))
@@ -1691,6 +1694,8 @@ static void msc_win_switch(struct msc *msc)
 	msc->base_addr = msc_win_base_dma(msc->cur_win);
 
 	intel_th_trace_switch(msc->thdev);
+
+	return 0;
 }
 
 /**
@@ -2025,16 +2030,15 @@ win_switch_store(struct device *dev, struct device_attribute *attr,
 	if (val != 1)
 		return -EINVAL;
 
+	ret = -EINVAL;
 	mutex_lock(&msc->buf_mutex);
 	/*
 	 * Window switch can only happen in the "multi" mode.
 	 * If a external buffer is engaged, they have the full
 	 * control over window switching.
 	 */
-	if (msc->mode != MSC_MODE_MULTI || msc->mbuf)
-		ret = -ENOTSUPP;
-	else
-		msc_win_switch(msc);
+	if (msc->mode == MSC_MODE_MULTI && !msc->mbuf)
+		ret = msc_win_switch(msc);
 	mutex_unlock(&msc->buf_mutex);
 
 	return ret ? ret : size;
-- 
2.24.0


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

* Re: [GIT PULL 4/4] intel_th: msu: Fix window switching without windows
  2019-12-17 11:55 ` [GIT PULL 4/4] intel_th: msu: Fix window switching without windows Alexander Shishkin
@ 2019-12-17 12:06   ` Greg Kroah-Hartman
  2019-12-17 23:51     ` Stephen Rothwell
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2019-12-17 12:06 UTC (permalink / raw)
  To: Alexander Shishkin; +Cc: linux-kernel, Andy Shevchenko, Ammy Yi, stable

On Tue, Dec 17, 2019 at 01:55:27PM +0200, Alexander Shishkin wrote:
> Commit 6cac7866c2741 ("intel_th: msu: Add a sysfs attribute to trigger
> window switch") adds a NULL pointer dereference in the case when there are
> no windows allocated:

Commit ids should only be specified in 12 digits, not 13 :)


> 
> > BUG: kernel NULL pointer dereference, address: 0000000000000000
> > #PF: supervisor read access in kernel mode
> > #PF: error_code(0x0000) - not-present page
> > PGD 0 P4D 0
> > Oops: 0000 1 SMP
> > CPU: 5 PID: 1110 Comm: bash Not tainted 5.5.0-rc1+ #1
> > RIP: 0010:msc_win_switch+0xa/0x80 [intel_th_msu]
> > Call Trace:
> > ? win_switch_store+0x9b/0xc0 [intel_th_msu]
> > dev_attr_store+0x17/0x30
> > sysfs_kf_write+0x3e/0x50
> > kernfs_fop_write+0xda/0x1b0
> > __vfs_write+0x1b/0x40
> > vfs_write+0xb9/0x1a0
> > ksys_write+0x67/0xe0
> > __x64_sys_write+0x1a/0x20
> > do_syscall_64+0x57/0x1d0
> > entry_SYSCALL_64_after_hwframe+0x44/0xa9
> 
> Fix that by disallowing window switching with multiwindow buffers without
> windows.
> 
> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Fixes: 6cac7866c2741 ("intel_th: msu: Add a sysfs attribute to trigger window switch")

Same here.

I can go edit it by hand...


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

* Re: [GIT PULL 4/4] intel_th: msu: Fix window switching without windows
  2019-12-17 12:06   ` Greg Kroah-Hartman
@ 2019-12-17 23:51     ` Stephen Rothwell
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Rothwell @ 2019-12-17 23:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alexander Shishkin, linux-kernel, Andy Shevchenko, Ammy Yi, stable

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

Hi Greg,

On Tue, 17 Dec 2019 13:06:29 +0100 Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
>
> On Tue, Dec 17, 2019 at 01:55:27PM +0200, Alexander Shishkin wrote:
> > Commit 6cac7866c2741 ("intel_th: msu: Add a sysfs attribute to trigger
> > window switch") adds a NULL pointer dereference in the case when there are
> > no windows allocated:  
> 
> Commit ids should only be specified in 12 digits, not 13 :)

It is possible that 13 digits may be necessary to be unambiguous within
a git repo.  In fact, as we continue with a single git repo (Linus'), at
some point 13 digits will become normal.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2019-12-17 23:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20191217115527.74383-1-alexander.shishkin@linux.intel.com>
2019-12-17 11:55 ` [GIT PULL 1/4] intel_th: pci: Add Comet Lake PCH-V support Alexander Shishkin
2019-12-17 11:55 ` [GIT PULL 2/4] intel_th: pci: Add Elkhart Lake SOC support Alexander Shishkin
2019-12-17 11:55 ` [GIT PULL 3/4] intel_th: Fix freeing IRQs Alexander Shishkin
2019-12-17 11:55 ` [GIT PULL 4/4] intel_th: msu: Fix window switching without windows Alexander Shishkin
2019-12-17 12:06   ` Greg Kroah-Hartman
2019-12-17 23:51     ` Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).