All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>,
	linux-usb@vger.kernel.org, x86@kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v4 1/4] usb: dbc: early driver for xhci debug capability
Date: Wed, 9 Nov 2016 10:23:05 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1611091015170.3501@nanos> (raw)
In-Reply-To: <1477976354-13291-2-git-send-email-baolu.lu@linux.intel.com>

On Tue, 1 Nov 2016, Lu Baolu wrote:
> +static int __init xdbc_init(void)
> +{
...
> +	base = ioremap_nocache(xdbc.xhci_start, xdbc.xhci_length);
> +	if (!base) {
> +		xdbc_trace("failed to remap the io address\n");
> +		ret = -ENOMEM;
> +		goto free_and_quit;
> +	}
> +
> +	early_iounmap(xdbc.xhci_base, xdbc.xhci_length);
> +	xdbc_trace("early mapped IO address released\n");
> +
> +	xdbc.xhci_base = base;
> +	offset = xhci_find_next_ext_cap(xdbc.xhci_base, 0, XHCI_EXT_CAPS_DEBUG);
> +	xdbc.xdbc_reg = (struct xdbc_regs __iomem *)(xdbc.xhci_base + offset);

This is broken. What prevents that 

     - a printk is in progress on another cpu?

     - a printk happens between the unmap and storing the new base ?

Nothing AFAICT. So this needs to be done in a safe way. And just making it

	oldbase = xdbc.xhci_base;
	base = ioremap(....);
	xdbc.xhci_base = base;
	early_iounmap(oldbase);

does not work either because the compiler can rightfully cache
xdbc.xhci_base in the write related functions. The same issue with
xdbc.xdbc_reg.

Thanks,

	tglx

  reply	other threads:[~2016-11-09  9:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-01  4:59 [PATCH v4 0/4] usb: early: add support for early printk through USB3 debug port Lu Baolu
2016-11-01  4:59 ` [PATCH v4 1/4] usb: dbc: early driver for xhci debug capability Lu Baolu
2016-11-09  9:23   ` Thomas Gleixner [this message]
2016-11-10  1:13     ` Lu Baolu
2016-11-09  9:37   ` Thomas Gleixner
2016-11-10  1:20     ` Lu Baolu
2016-11-10  8:56       ` Thomas Gleixner
2016-11-10 11:44         ` Peter Zijlstra
2016-11-11  4:33           ` Lu Baolu
2016-11-11 12:28             ` Peter Zijlstra
2016-11-12  7:35               ` Lu Baolu
2016-11-12 11:32                 ` Thomas Gleixner
2016-11-11  2:24         ` Lu Baolu
2016-11-11  2:49           ` Lu Baolu
2016-11-01  4:59 ` [PATCH v4 2/4] x86: add support for earlyprintk via USB3 debug port Lu Baolu
2016-11-01  4:59 ` [PATCH v4 3/4] usb: serial: usb_debug: add support for dbc debug device Lu Baolu
2016-11-01  4:59 ` [PATCH v4 4/4] usb: doc: add document for USB3 debug port usage Lu Baolu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1611091015170.3501@nanos \
    --to=tglx@linutronix.de \
    --cc=baolu.lu@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.