As noted in commit 84b40e3b57ee ("serial: 8250: omap: Disable DMA for
console UART"), UART console lines use low-level PIO only access functions
which will conflict with use of the line when DMA is enabled, e.g. when
the console line is also used for systemd messages. So disable DMA
support for UART console lines.
Fixes: https://patchwork.kernel.org/patch/10929511/
Reported-by: Michael Rodin <mrodin(a)de.adit-jv.com>
Tested-by: Eugeniu Rosca <erosca(a)de.adit-jv.com>
Reviewed-by: Simon Horman <horms+renesas(a)verge.net.au>
Reviewed-by: Wolfram Sang <wsa+renesas(a)sang-engineering.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: George G. Davis <george_davis(a)mentor.com>
---
v2: Clarify comment regarding DMA support on kernel console,
add {Tested,Reviewed}-by:, and Cc: linux-stable lines.
---
drivers/tty/serial/sh-sci.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 3cd139752d3f..abc705716aa0 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1557,6 +1557,13 @@ static void sci_request_dma(struct uart_port *port)
dev_dbg(port->dev, "%s: port %d\n", __func__, port->line);
+ /*
+ * DMA on console may interfere with Kernel log messages which use
+ * plain putchar(). So, simply don't use it with a console.
+ */
+ if (uart_console(port))
+ return;
+
if (!port->dev->of_node)
return;
--
2.7.4
On Thu, Apr 25, 2019 at 06:05:36PM +0200, Johan Hovold wrote:
> Fix two long-standing bugs which could potentially lead to memory
> corruption or leave the port throttled until it is reopened (on weakly
> ordered systems), respectively, when read-URB completion races with
> unthrottle().
>
> First, the URB must not be marked as free before processing is complete
> to prevent it from being submitted by unthrottle() on another CPU.
>
> CPU 1 CPU 2
> ================ ================
> complete() unthrottle()
> process_urb();
> smp_mb__before_atomic();
> set_bit(i, free); if (test_and_clear_bit(i, free))
> submit_urb();
>
> Second, the URB must be marked as free before checking the throttled
> flag to prevent unthrottle() on another CPU from failing to observe that
> the URB needs to be submitted if complete() sees that the throttled flag
> is set.
>
> CPU 1 CPU 2
> ================ ================
> complete() unthrottle()
> set_bit(i, free); throttled = 0;
> smp_mb__after_atomic(); smp_mb();
> if (throttled) if (test_and_clear_bit(i, free))
> return; submit_urb();
>
> Note that test_and_clear_bit() only implies barriers when the test is
> successful. To handle the case where the URB is still in use an explicit
> barrier needs to be added to unthrottle() for the second race condition.
>
> Fixes: d83b405383c9 ("USB: serial: add support for multiple read urbs")
> Signed-off-by: Johan Hovold <johan(a)kernel.org>
Greg, I noticed you added a stable tag to the corresponding cdc-acm fix
and think I should have added on one from the start to this one as well.
Would you mind queuing this one up for stable?
Upstream commit 3f5edd58d040bfa4b74fb89bc02f0bc6b9cd06ab.
Thanks,
Johan
On Mon, 29 Apr 2019 16:01:29 +1000
Alexey Kardashevskiy <aik(a)ozlabs.ru> wrote:
> On 20/04/2019 01:34, Greg Kurz wrote:
> > Since 902bdc57451c, get_pci_dev() calls pci_get_domain_bus_and_slot(). This
> > has the effect of incrementing the reference count of the PCI device, as
> > explained in drivers/pci/search.c:
> >
> > * Given a PCI domain, bus, and slot/function number, the desired PCI
> > * device is located in the list of PCI devices. If the device is
> > * found, its reference count is increased and this function returns a
> > * pointer to its data structure. The caller must decrement the
> > * reference count by calling pci_dev_put(). If no device is found,
> > * %NULL is returned.
> >
> > Nothing was done to call pci_dev_put() and the reference count of GPU and
> > NPU PCI devices rockets up.
> >
> > A natural way to fix this would be to teach the callers about the change,
> > so that they call pci_dev_put() when done with the pointer. This turns
> > out to be quite intrusive, as it affects many paths in npu-dma.c,
> > pci-ioda.c and vfio_pci_nvlink2.c.
>
>
> afaict this referencing is only done to protect the current traverser
> and what you've done is actually a natural way (and the generic
> pci_get_dev_by_id() does exactly the same), although this looks a bit weird.
>
Not exactly the same: pci_get_dev_by_id() always increment the refcount
of the returned PCI device. The refcount is only decremented when this
device is passed to pci_get_dev_by_id() to continue searching.
That means that the users of the PCI device pointer returned by
pci_get_dev_by_id() or its exported variants pci_get_subsys(),
pci_get_device() and pci_get_class() do handle the refcount. They
all pass the pointer to pci_dev_put() or continue the search,
which calls pci_dev_put() internally.
Direct and indirect callers of get_pci_dev() don't care for the
refcount at all unless I'm missing something.
>
> > Also, the issue appeared in 4.16 and
> > some affected code got moved around since then: it would be problematic
> > to backport the fix to stable releases.
> >
> > All that code never cared for reference counting anyway. Call pci_dev_put()
> > from get_pci_dev() to revert to the previous behavior.
> >> Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev
> from pci_dn")
> > Cc: stable(a)vger.kernel.org # v4.16
> > Signed-off-by: Greg Kurz <groug(a)kaod.org>
> > ---
> > arch/powerpc/platforms/powernv/npu-dma.c | 15 ++++++++++++++-
> > 1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
> > index e713ade30087..d8f3647e8fb2 100644
> > --- a/arch/powerpc/platforms/powernv/npu-dma.c
> > +++ b/arch/powerpc/platforms/powernv/npu-dma.c
> > @@ -31,9 +31,22 @@ static DEFINE_SPINLOCK(npu_context_lock);
> > static struct pci_dev *get_pci_dev(struct device_node *dn)
> > {
> > struct pci_dn *pdn = PCI_DN(dn);
> > + struct pci_dev *pdev;
> >
> > - return pci_get_domain_bus_and_slot(pci_domain_nr(pdn->phb->bus),
> > + pdev = pci_get_domain_bus_and_slot(pci_domain_nr(pdn->phb->bus),
> > pdn->busno, pdn->devfn);
> > +
> > + /*
> > + * pci_get_domain_bus_and_slot() increased the reference count of
> > + * the PCI device, but callers don't need that actually as the PE
> > + * already holds a reference to the device.
>
> Imho this would be just enough.
>
> Anyway,
>
> Reviewed-by: Alexey Kardashevskiy <aik(a)ozlabs.ru>
>
Thanks !
I now realize that I forgot to add the --cc option for stable on my stgit
command line :-\.
Cc'ing now.
>
> How did you find it? :)
>
While reading code to find some inspiration for OpenCAPI passthrough. :)
I saw the following in vfio_pci_ibm_npu2_init():
if (!pnv_pci_get_gpu_dev(vdev->pdev))
return -ENODEV;
and simply followed the function calls.
>
> > Since callers aren't
> > + * aware of the reference count change, call pci_dev_put() now to
> > + * avoid leaks.
> > + */
> > + if (pdev)
> > + pci_dev_put(pdev);
> > +
> > + return pdev;
> > }
> >
> > /* Given a NPU device get the associated PCI device. */
> >
>
Dear Stable Team,
Request for inclusion into the stable branches of Linux. This change
went into 4.20 but 4.19 is the LTS release that many of the Linux
Vendors are rebasing on. Hence, it'd be nice to see this part of the LTS
releases, at least 4.19.
The current code fails to run on amd64 because of hardcoded reference to
i386
Signed-off-by: Ritesh Raj Sarraf <rrs(a)researchut.com>
Signed-off-by: Richard Weinberger <richard(a)nod.at>
---
arch/um/drivers/port_user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index 9a8e1b64c22e..5f56d11b886f 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -168,7 +168,7 @@ int port_connection(int fd, int *socket, int *pid_out)
{
int new, err;
char *argv[] = { "/usr/sbin/in.telnetd", "-L",
- "/usr/lib/uml/port-helper", NULL };
+ OS_LIB_PATH "/uml/port-helper", NULL };
struct port_pre_exec_data data;
new = accept(fd, NULL, 0);
--
2.20.1