Re: [ 026/180] eCryptfs: Improve statfs reporting

2012-10-01 Thread Willy Tarreau
On Mon, Oct 01, 2012 at 10:46:56PM -0700, Tyler Hicks wrote:
> On 2012-10-02 00:52:23, Willy Tarreau wrote:
> > 2.6.32-longterm review patch.  If anyone has any objections, please let me 
> > know.
> 
> Hi - Please drop this patch. It incorrectly calculates f_namelen and I
> haven't had a chance to fix it yet. When I get a fix ready, I'll forward
> the corrected patch to stable@v.k.o. Thanks!

Done, thanks Tyler !

Willy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] HID: picoLCD: Remove use of deprecated function

2012-10-01 Thread Tejun Heo
On Tue, Oct 02, 2012 at 12:18:00AM +0200, Jiri Kosina wrote:
> Linus has just pulled from me, so if you could take care of this merge 
> conflict, that'd be awesome.

Will do.  Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the signal tree with the vfs tree

2012-10-01 Thread Stephen Rothwell
Hi Al,

Today's linux-next merge of the signal tree got a conflict in fs/exec.c
between commit 5b8a94d461a7 ("coredump: move core dump functionality into
its own file") from the vfs tree and commits 282124d18626 ("generic
kernel_execve()") and 38b983b3461e ("generic sys_execve()") from the signal 
tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc fs/exec.c
index 48fb26e,50a1270..000
--- a/fs/exec.c
+++ b/fs/exec.c
@@@ -1645,3 -2031,342 +1644,55 @@@ int get_dumpable(struct mm_struct *mm
  {
return __get_dumpable(mm->flags);
  }
+ 
 -static void wait_for_dump_helpers(struct file *file)
 -{
 -  struct pipe_inode_info *pipe;
 -
 -  pipe = file->f_path.dentry->d_inode->i_pipe;
 -
 -  pipe_lock(pipe);
 -  pipe->readers++;
 -  pipe->writers--;
 -
 -  while ((pipe->readers > 1) && (!signal_pending(current))) {
 -  wake_up_interruptible_sync(>wait);
 -  kill_fasync(>fasync_readers, SIGIO, POLL_IN);
 -  pipe_wait(pipe);
 -  }
 -
 -  pipe->readers--;
 -  pipe->writers++;
 -  pipe_unlock(pipe);
 -
 -}
 -
 -
 -/*
 - * umh_pipe_setup
 - * helper function to customize the process used
 - * to collect the core in userspace.  Specifically
 - * it sets up a pipe and installs it as fd 0 (stdin)
 - * for the process.  Returns 0 on success, or
 - * PTR_ERR on failure.
 - * Note that it also sets the core limit to 1.  This
 - * is a special value that we use to trap recursive
 - * core dumps
 - */
 -static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
 -{
 -  struct file *files[2];
 -  struct fdtable *fdt;
 -  struct coredump_params *cp = (struct coredump_params *)info->data;
 -  struct files_struct *cf = current->files;
 -  int err = create_pipe_files(files, 0);
 -  if (err)
 -  return err;
 -
 -  cp->file = files[1];
 -
 -  sys_close(0);
 -  fd_install(0, files[0]);
 -  spin_lock(>file_lock);
 -  fdt = files_fdtable(cf);
 -  __set_open_fd(0, fdt);
 -  __clear_close_on_exec(0, fdt);
 -  spin_unlock(>file_lock);
 -
 -  /* and disallow core files too */
 -  current->signal->rlim[RLIMIT_CORE] = (struct rlimit){1, 1};
 -
 -  return 0;
 -}
 -
 -void do_coredump(long signr, int exit_code, struct pt_regs *regs)
 -{
 -  struct core_state core_state;
 -  struct core_name cn;
 -  struct mm_struct *mm = current->mm;
 -  struct linux_binfmt * binfmt;
 -  const struct cred *old_cred;
 -  struct cred *cred;
 -  int retval = 0;
 -  int flag = 0;
 -  int ispipe;
 -  bool need_nonrelative = false;
 -  static atomic_t core_dump_count = ATOMIC_INIT(0);
 -  struct coredump_params cprm = {
 -  .signr = signr,
 -  .regs = regs,
 -  .limit = rlimit(RLIMIT_CORE),
 -  /*
 -   * We must use the same mm->flags while dumping core to avoid
 -   * inconsistency of bit flags, since this flag is not protected
 -   * by any locks.
 -   */
 -  .mm_flags = mm->flags,
 -  };
 -
 -  audit_core_dumps(signr);
 -
 -  binfmt = mm->binfmt;
 -  if (!binfmt || !binfmt->core_dump)
 -  goto fail;
 -  if (!__get_dumpable(cprm.mm_flags))
 -  goto fail;
 -
 -  cred = prepare_creds();
 -  if (!cred)
 -  goto fail;
 -  /*
 -   * We cannot trust fsuid as being the "true" uid of the process
 -   * nor do we know its entire history. We only know it was tainted
 -   * so we dump it as root in mode 2, and only into a controlled
 -   * environment (pipe handler or fully qualified path).
 -   */
 -  if (__get_dumpable(cprm.mm_flags) == SUID_DUMPABLE_SAFE) {
 -  /* Setuid core dump mode */
 -  flag = O_EXCL;  /* Stop rewrite attacks */
 -  cred->fsuid = GLOBAL_ROOT_UID;  /* Dump root private */
 -  need_nonrelative = true;
 -  }
 -
 -  retval = coredump_wait(exit_code, _state);
 -  if (retval < 0)
 -  goto fail_creds;
 -
 -  old_cred = override_creds(cred);
 -
 -  /*
 -   * Clear any false indication of pending signals that might
 -   * be seen by the filesystem code called to write the core file.
 -   */
 -  clear_thread_flag(TIF_SIGPENDING);
 -
 -  ispipe = format_corename(, signr);
 -
 -  if (ispipe) {
 -  int dump_count;
 -  char **helper_argv;
 -
 -  if (ispipe < 0) {
 -  printk(KERN_WARNING "format_corename failed\n");
 -  printk(KERN_WARNING "Aborting core\n");
 -  goto fail_corename;
 -  }
 -
 -  if (cprm.limit == 1) {
 -  /* See umh_pipe_setup() which sets RLIMIT_CORE = 1.
 -  

Re: [ 026/180] eCryptfs: Improve statfs reporting

2012-10-01 Thread Tyler Hicks
On 2012-10-02 00:52:23, Willy Tarreau wrote:
> 2.6.32-longterm review patch.  If anyone has any objections, please let me 
> know.

Hi - Please drop this patch. It incorrectly calculates f_namelen and I
haven't had a chance to fix it yet. When I get a fix ready, I'll forward
the corrected patch to stable@v.k.o. Thanks!

Tyler

> 
> --
> 
> From: Tyler Hicks 
> 
> commit 4a26620df451ad46151ad21d711ed43e963c004e upstream.
> 
> BugLink: http://bugs.launchpad.net/bugs/885744
> 
> statfs() calls on eCryptfs files returned the wrong filesystem type and,
> when using filename encryption, the wrong maximum filename length.
> 
> If mount-wide filename encryption is enabled, the cipher block size and
> the lower filesystem's max filename length will determine the max
> eCryptfs filename length. Pre-tested, known good lengths are used when
> the lower filesystem's namelen is 255 and a cipher with 8 or 16 byte
> block sizes is used. In other, less common cases, we fall back to a safe
> rounded-down estimate when determining the eCryptfs namelen.
> 
> https://launchpad.net/bugs/885744
> 
> Signed-off-by: Tyler Hicks 
> Reported-by: Kees Cook 
> Reviewed-by: Kees Cook 
> Reviewed-by: John Johansen 
> Signed-off-by: Colin Ian King 
> Acked-by: Stefan Bader 
> Signed-off-by: Tim Gardner 
> Signed-off-by: Willy Tarreau 
> ---
>  fs/ecryptfs/crypto.c  |   68 
>  fs/ecryptfs/ecryptfs_kernel.h |   11 ++
>  fs/ecryptfs/keystore.c|9 ++---
>  fs/ecryptfs/super.c   |   18 ++-
>  4 files changed, 92 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
> index 7e164bb..7786bf6 100644
> --- a/fs/ecryptfs/crypto.c
> +++ b/fs/ecryptfs/crypto.c
> @@ -2039,6 +2039,17 @@ out:
>   return;
>  }
>  
> +static size_t ecryptfs_max_decoded_size(size_t encoded_size)
> +{
> + /* Not exact; conservatively long. Every block of 4
> +  * encoded characters decodes into a block of 3
> +  * decoded characters. This segment of code provides
> +  * the caller with the maximum amount of allocated
> +  * space that @dst will need to point to in a
> +  * subsequent call. */
> + return ((encoded_size + 1) * 3) / 4;
> +}
> +
>  /**
>   * ecryptfs_decode_from_filename
>   * @dst: If NULL, this function only sets @dst_size and returns. If
> @@ -2057,13 +2068,7 @@ ecryptfs_decode_from_filename(unsigned char *dst, 
> size_t *dst_size,
>   size_t dst_byte_offset = 0;
>  
>   if (dst == NULL) {
> - /* Not exact; conservatively long. Every block of 4
> -  * encoded characters decodes into a block of 3
> -  * decoded characters. This segment of code provides
> -  * the caller with the maximum amount of allocated
> -  * space that @dst will need to point to in a
> -  * subsequent call. */
> - (*dst_size) = (((src_size + 1) * 3) / 4);
> + (*dst_size) = ecryptfs_max_decoded_size(src_size);
>   goto out;
>   }
>   while (src_byte_offset < src_size) {
> @@ -2289,3 +2294,52 @@ out_free:
>  out:
>   return rc;
>  }
> +
> +#define ENC_NAME_MAX_BLOCKLEN_8_OR_16143
> +
> +int ecryptfs_set_f_namelen(long *namelen, long lower_namelen,
> +struct ecryptfs_mount_crypt_stat *mount_crypt_stat)
> +{
> + struct blkcipher_desc desc;
> + struct mutex *tfm_mutex;
> + size_t cipher_blocksize;
> + int rc;
> +
> + if (!(mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)) {
> + (*namelen) = lower_namelen;
> + return 0;
> + }
> +
> + rc = ecryptfs_get_tfm_and_mutex_for_cipher_name(, _mutex,
> + mount_crypt_stat->global_default_fn_cipher_name);
> + if (unlikely(rc)) {
> + (*namelen) = 0;
> + return rc;
> + }
> +
> + mutex_lock(tfm_mutex);
> + cipher_blocksize = crypto_blkcipher_blocksize(desc.tfm);
> + mutex_unlock(tfm_mutex);
> +
> + /* Return an exact amount for the common cases */
> + if (lower_namelen == NAME_MAX
> + && (cipher_blocksize == 8 || cipher_blocksize == 16)) {
> + (*namelen) = ENC_NAME_MAX_BLOCKLEN_8_OR_16;
> + return 0;
> + }
> +
> + /* Return a safe estimate for the uncommon cases */
> + (*namelen) = lower_namelen;
> + (*namelen) -= ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE;
> + /* Since this is the max decoded size, subtract 1 "decoded block" len */
> + (*namelen) = ecryptfs_max_decoded_size(*namelen) - 3;
> + (*namelen) -= ECRYPTFS_TAG_70_MAX_METADATA_SIZE;
> + (*namelen) -= ECRYPTFS_FILENAME_MIN_RANDOM_PREPEND_BYTES;
> + /* Worst case is that the filename is padded nearly a full block size */
> + (*namelen) -= cipher_blocksize - 1;
> +
> + if ((*namelen) < 0)
> + (*namelen) = 0;
> +
> + return 0;
> +}
> diff --git 

Re: Re: [PATCH v3 1/3] devfreq: Core updates to support devices which can idle

2012-10-01 Thread MyungJoo Ham
> On 27 September 2012 13:50, MyungJoo Ham  wrote:
> >> Prepare devfreq core framework to support devices which
> >> can idle. When device idleness is detected perhaps through
> >> runtime-pm, need some mechanism to suspend devfreq load
> >> monitoring and resume back when device is online. Present
> >> code continues monitoring unless device is removed from
> >> devfreq core.
> >>
> >> This patch introduces following design changes,
> >>
> >> - use per device work instead of global work to monitor device
> >>   load. This enables suspend/resume of device devfreq and
> >>   reduces monitoring code complexity.
> >> - decouple delayed work based load monitoring logic from core
> >>   by introducing helpers functions to be used by governors. This
> >>   provides flexibility for governors either to use delayed work
> >>   based monitoring functions or to implement their own mechanism.
> >> - devfreq core interacts with governors via events to perform
> >>   specific actions. These events include start/stop devfreq.
> >>   This sets ground for adding suspend/resume events.
> >>
> >> The devfreq apis are not modified and are kept intact.
> >>
> >> Signed-off-by: Rajagopal Venkat 
> >
> > Hello,
> >
> >
> > I'll do more through review tomorrow (sorry, I was occuppied by
> > something other than Linux tasks for a while again); however,
> > there are two concerns in this patch.
> >
> > 1. (minor but may bothersome in some rare but not-ignorable cases)
> > Serialization issue between suspend/resume
> > functions; this may happen with some failure or interrupts while entering 
> > STR or
> > unexpected usage of the API at drivers.
> 
> Regarding the invalid usage of suspend/resume apis, we can have
> additional checks
> something like,
> 
> void devfreq_monitor_suspend(struct devfreq *devfreq)
> {
> .
> if (devfreq->stop_polling)
> return;
> ..
> }
> 
> void devfreq_monitor_resume(struct devfreq *devfreq)
> {
> .
> if (!devfreq->stop_polling)
> return;
> ..
> }
> 
> >
> >   For example, if devfreq_monitor_suspend() and devfreq_montir_resume() are 
> > called
> > almost simultaneously, we may execute 1) locked part of suspend, 2) locked 
> > part of
> > resume, 3) cancel_delayed_work_sync of suspend.
> >
> >   Then, we may have stop_polling = false w/ cancel_delayed_work_sync() in 
> > effect.
> >
> >   Let's not assume that suspend() and resume() may called almost 
> > simultaneously,
> > especially in subsystem core code.

(sorry, I missed "not be" between "may" and "called" here)

> >
> 
> These devfreq_monitor_suspend() and devfreq_monitor_resume() functions are
> executed when device idleness is detected. Perhaps,
> - using runtime-pm: the runtime_suspend() and runtime_resume() are mutually
> exclusive and is guaranteed not to run in parallel.
> - driver may have its own mechanism: in my opinion, driver should ensure
> suspend/resume are sequential even for it to know its devfreq status.
> 
> Assuming even if above sequence occurs, I don't see any problem having
> stop_polling = false w/ cancel_delayed_work_sync() in effect. Since the 
> suspend
> is the last one to complete, monitoring will not continue.

Why don't you simply extend the mutex-locked context?

I.e., 
+   mutex_lock(>lock);
+   devfreq->stop_polling = true;
+   mutex_unlock(>lock);
+   cancel_delayed_work_sync(>work);
-->
+   mutex_lock(>lock);
+   devfreq->stop_polling = true;
+   cancel_delayed_work_sync(>work);
+   mutex_unlock(>lock);

This serializes data-update and the execution based on the data-update,
resolving any inconsistency issues with the queue-status and devfreq
variable.

It doesn't have a heavy overhead to extend it and we have the
probably of inconsistency due to serialization issues.

> 
> >
> > 2. What if polling_ms = 0 w/ active governors (such as ondemand)?
> >
> >  Users may declare the initial polling_ms = 0 w/ simple-ondemand in order to
> > pause sampling at boot-time and start sampling at run-time some time later.
> >
> > It appears that this patch will start forcibly at boot-time in such a case.
> 
> Yes. This is a valid case which can be handled by
> 
>  void devfreq_monitor_start(struct devfreq *devfreq)
>  {
> INIT_DELAYED_WORK_DEFERRABLE(>work, devfreq_monitor);
> +   if (devfreq->profile->polling_ms)
> queue_delayed_work(devfreq_wq, >work,
> msecs_to_jiffies(devfreq->profile->polling_ms));
>  }


Please add the checking statement to every queue_delayed_work() statement:
resume and interval-update functions.



Cheers!
MyungJoo



Re: [PATCH v2 1/3] w1: mxc_w1: Adapt the clock name to the new clock framework

2012-10-01 Thread Evgeniy Polyakov
On Mon, Oct 01, 2012 at 02:51:44PM -0300, Fabio Estevam 
(fabio.este...@freescale.com) wrote:
> Evgeny,
> 
> Any comments, please?

I have no objections per se, but I'm hardly an expert in imx clock
framework :)

Since it is only one patch in set of 3, I suppose it will be pushed
through different tree than w1. Feel free to add my ack.

Acked-by: Evgeniy Polyakov 

-- 
Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the arm-soc tree with the spi-mb tree

2012-10-01 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the arm-soc tree got a conflict in
drivers/spi/spi-tegra.c between commit 536a53a300d0 ("spi: remove
completely broken Tegra driver") from the spi-mb tree and commit
5bd276118189 ("spi: tegra: remove support of legacy DMA driver based
access") from the arm-soc tree.

I removed the file and can carry the fix as necessary (no action is
required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/


pgpOKVz5m3Bkd.pgp
Description: PGP signature


linux-next: manual merge of the arm-soc tree with the spi-mb tree

2012-10-01 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the arm-soc tree got a conflict in
drivers/spi/Kconfig between commit 536a53a300d0 ("spi: remove completely
broken Tegra driver") from the spi-mb tree and commit 5bd276118189 ("spi:
tegra: remove support of legacy DMA driver based access") from the
arm-soc tree.

I fixed it up (by removing the SPI_TEGRA section) and can carry the fix
as necessary (no action is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/


pgpROpR5lndwI.pgp
Description: PGP signature


Re: [PATCH v3 -tip 5/5] AHCI: Support multiple MSIs

2012-10-01 Thread Ingo Molnar

* Alexander Gordeev  wrote:

> Take advantage of multiple MSIs implementation on x86 - on systems with
> IRQ remapping AHCI ports not only get assigned separate MSI vectors -
> but also separate IRQs. As result, interrupts generated by different
> ports could be serviced on different CPUs rather than on a single one.
> 
> In cases when number of allocated MSIs is less than requested the Sharing
> Last MSI mode does not get used, no matter implemented in hardware or not.
> Instead, the driver assumes the advantage of multiple MSIs is negated and
> falls back to the single MSI mode as if MRSM bit was set (some Intel chips
> implement this strategy anyway - MRSM bit gets set even if the number of
> allocated MSIs exceeds the number of implemented ports).
> 
> Signed-off-by: Alexander Gordeev 
> ---
>  drivers/ata/ahci.c|   91 --
>  drivers/ata/ahci.h|6 +++
>  drivers/ata/libahci.c |  118 
> ++---
>  3 files changed, 205 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index 7862d17..5463fcea 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -1057,6 +1057,84 @@ static inline void ahci_gtf_filter_workaround(struct 
> ata_host *host)
>  {}
>  #endif
>  
> +int ahci_init_interrupts(struct pci_dev *pdev, struct ahci_host_priv *hpriv)
> +{
> + int rc;
> + unsigned int maxvec;
> +
> + if (!(hpriv->flags & AHCI_HFLAG_NO_MSI)) {
> + rc = pci_enable_msi_block_auto(pdev, );
> + if (rc > 0) {
> + if ((rc == maxvec) || (rc == 1))
> + return rc;
> + /* assume that advantage of multipe MSIs is negated,
> +  * so fallback to single MSI mode to save resources */

Please use the customary (multi-line) comment style:

  /*
   * Comment .
   * .. goes here.
   */

specified in Documentation/CodingStyle.

> + pci_disable_msi(pdev);
> + if (!pci_enable_msi(pdev))
> + return 1;
> + }
> + }
> +
> + pci_intx(pdev, 1);
> + return 0;
> +}
> +
> +/**
> + *   ahci_host_activate - start AHCI host, request IRQs and register it
> + *   @host: target ATA host
> + *   @irq: base IRQ number to request
> + *   @n_msis: number of MSIs allocated for this host
> + *   @irq_handler: irq_handler used when requesting IRQs
> + *   @irq_flags: irq_flags used when requesting IRQs
> + *
> + *   Similar to ata_host_activate, but requests IRQs according to AHCI-1.1
> + *   when multiple MSIs were allocated. That is one MSI per port, starting
> + *   from @irq.
> + *
> + *   LOCKING:
> + *   Inherited from calling layer (may sleep).
> + *
> + *   RETURNS:
> + *   0 on success, -errno otherwise.
> + */
> +int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis)
> +{
> + int i, rc;
> +
> + /* Sharing Last Message among several ports is not supported */
> + if (n_msis < host->n_ports)
> + return -EINVAL;
> +
> + rc = ata_host_start(host);
> + if (rc)
> + return rc;
> +
> + for (i = 0; i < host->n_ports; i++) {
> + rc = devm_request_threaded_irq(host->dev,
> + irq + i, ahci_hw_interrupt, ahci_thread_fn, IRQF_SHARED,
> + dev_driver_string(host->dev), host->ports[i]);
> + if (rc)
> + goto out_free_irqs;
> + }
> +
> + for (i = 0; i < host->n_ports; i++)
> + ata_port_desc(host->ports[i], "irq %d", irq + i);
> +
> + rc = ata_host_register(host, _sht);
> + if (rc)
> + goto out_free_all_irqs;
> +
> + return 0;
> +
> +out_free_all_irqs:
> + i = host->n_ports;
> +out_free_irqs:
> + for (; i; i--)
> + devm_free_irq(host->dev, irq + i - 1, host->ports[i]);

Please test the failure path somehow - for example I'm quite 
sure that the line above is buggy and will crash/hang a real 
system: it should be host->ports[i-1].

Writing it as:

devm_free_irq(host->dev, irq + i-1, host->ports[i-1]);

would help readability as well as bit - or just:

for (i--; i >= 0; i--)
devm_free_irq(host->dev, irq + i, host->ports[i]);

(untested)

> +
> + return rc;
> +}
> +
>  static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id 
> *ent)
>  {
>   unsigned int board_id = ent->driver_data;
> @@ -1065,7 +1143,7 @@ static int ahci_init_one(struct pci_dev *pdev, const 
> struct pci_device_id *ent)
>   struct device *dev = >dev;
>   struct ahci_host_priv *hpriv;
>   struct ata_host *host;
> - int n_ports, i, rc;
> + int n_ports, n_msis, i, rc;
>   int ahci_pci_bar = AHCI_PCI_BAR_STANDARD;
>  
>   VPRINTK("ENTER\n");
> @@ -1150,11 +1228,12 @@ static int ahci_init_one(struct pci_dev *pdev, const 
> struct pci_device_id *ent)
>   

[PATCH v2] serial/arc-uart: Add new driver

2012-10-01 Thread Vineet.Gupta1
From: Vineet Gupta 

Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys)
FPGA Boards such as ARCAngel4/ML50x

v2:
* ttyARC used as device name
* Dynamic assignment of major/minor numbers.
* Ref counting tty in rx routine to prevent it from disappearing in
  case of a hangup
* set_termios fixes:
  - hardware flow control/parity are marked as unsupported
  - baud written back to termios
* cosmetics such as commenting the need for @running_on_iss, empty lines
  etc

Signed-off-by: Vineet Gupta 
---
 drivers/tty/serial/Kconfig|   25 ++
 drivers/tty/serial/Makefile   |1 +
 drivers/tty/serial/arc_uart.c |  746 +
 include/linux/serial_core.h   |3 +
 4 files changed, 775 insertions(+), 0 deletions(-)
 create mode 100644 drivers/tty/serial/arc_uart.c

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 4720b4b..af4bd69 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1360,4 +1360,29 @@ config SERIAL_EFM32_UART_CONSOLE
depends on SERIAL_EFM32_UART=y
select SERIAL_CORE_CONSOLE
 
+config SERIAL_ARC
+   bool "ARC UART driver support"
+   select SERIAL_CORE
+   default y
+   help
+ Driver for on-chip UART for ARC(Synopsys) for the legacy
+ FPGA Boards (ML50x/ARCAngel4)
+
+config SERIAL_ARC_CONSOLE
+   bool
+   select SERIAL_CORE_CONSOLE
+   depends on SERIAL_ARC=y
+   default y
+   help
+ Enable system Console on ARC UART
+
+config SERIAL_ARC_NR_PORTS
+   int 'Number of ports'
+   range 1 3
+   default 1
+   depends on SERIAL_ARC
+   help
+ Set this to the number of serial ports you want the driver
+ to support.
+
 endmenu
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index 7257c5d..2b70b5f 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -79,3 +79,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o
 obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o
 obj-$(CONFIG_SERIAL_AR933X)   += ar933x_uart.o
 obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o
+obj-$(CONFIG_SERIAL_ARC)   += arc_uart.o
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
new file mode 100644
index 000..b65bfe4
--- /dev/null
+++ b/drivers/tty/serial/arc_uart.c
@@ -0,0 +1,746 @@
+/*
+ * ARC On-Chip(fpga) UART Driver
+ *
+ * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: July 10th 2012
+ *  -Decoupled the driver from arch/arc
+ *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c)
+ *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx)
+ *
+ * Vineetg: Aug 21st 2010
+ *  -Is uart_tx_stopped() not done in tty write path as it has already been
+ *   taken care of, in serial core
+ *
+ * Vineetg: Aug 18th 2010
+ *  -New Serial Core based ARC UART driver
+ *  -Derived largely from blackfin driver albiet with some major tweaks
+ *
+ * TODO:
+ *  -check if sysreq works
+ */
+
+#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * ARC UART Hardware Specs
+ /
+#define ARC_UART_TX_FIFO_SIZE  1
+
+/*
+ * UART Register set (this is not a Standards Compliant IP)
+ * Also each reg is Word aligned, but only 8 bits wide
+ */
+#define R_ID0  0
+#define R_ID1  1
+#define R_ID2  2
+#define R_ID3  3
+#define R_DATA 4
+#define R_STS  5
+#define R_BAUDL6
+#define R_BAUDH7
+
+/* Bits for UART Status Reg (R/W) */
+#define RXIENB  0x04   /* Receive Interrupt Enable */
+#define TXIENB  0x40   /* Transmit Interrupt Enable */
+
+#define RXEMPTY 0x20   /* Receive FIFO Empty: No char receivede */
+#define TXEMPTY 0x80   /* Transmit FIFO Empty, thus char can be written into */
+
+#define RXFULL  0x08   /* Receive FIFO full */
+#define RXFULL1 0x10   /* Receive FIFO has space for 1 char (tot space=4) */
+
+#define RXFERR  0x01   /* Frame Error: Stop Bit not detected */
+#define RXOERR  0x02   /* OverFlow Err: Char recv but RXFULL still set */
+
+/* Uart bit fiddling helpers: lowest level */
+#define RBASE(uart, reg)  ((unsigned int *)uart->port.membase + reg)
+#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r))
+#define UART_REG_GET(u, r)readb(RBASE(u, r))
+
+#define UART_REG_OR(u, r, v)  UART_REG_SET(u, r, UART_REG_GET(u, r) | (v))
+#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v))
+
+/* Uart bit fiddling helpers: API level */
+#define UART_SET_DATA(uart, val)   UART_REG_SET(uart, R_DATA, val)
+#define UART_GET_DATA(uart)

Re: [PATCH v3 -tip 2/5] x86, MSI: Allocate as many multiple IRQs as requested

2012-10-01 Thread Ingo Molnar

* Alexander Gordeev  wrote:

> When multiple MSIs are enabled with pci_enable_msi_block() the number of
> allocated IRQs 'nvec' is rounded up to the nearest value of power of two.
> That could lead to a condition when number of requested and used IRQs is
> less than number of actually allocated IRQs.
> 
> This fix introduces 'msi_desc::nvec' field to address the above issue -
> when non-zero, it holds the number of allocated IRQs. Otherwise, the old
> method is used.
> 
> Signed-off-by: Alexander Gordeev 
> ---
>  arch/x86/kernel/apic/io_apic.c |   16 +++-
>  drivers/pci/msi.c  |   10 --
>  include/linux/msi.h|1 +
>  3 files changed, 16 insertions(+), 11 deletions(-)

This should be switched with the first patch: first extend the 
generic MSI code, then add x86 support for that variant.

Adding multi-MSI support in one patch then tweaking it in the 
very next patch makes little sense and cannot possibly have been 
tested much so it's a potential bisection trap.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 -tip 3/5] x86, MSI: Minor readability fixes

2012-10-01 Thread Ingo Molnar

* Alexander Gordeev  wrote:

> Signed-off-by: Alexander Gordeev 
> ---
>  arch/x86/kernel/apic/io_apic.c |6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
> index 84d632b..0489699 100644
> --- a/arch/x86/kernel/apic/io_apic.c
> +++ b/arch/x86/kernel/apic/io_apic.c
> @@ -3123,7 +3123,7 @@ static int msi_compose_msg(struct pci_dev *pdev, 
> unsigned int irq,
>  
>   if (irq_remapped(cfg)) {
>   compose_remapped_msi_msg(pdev, irq, dest, msg, hpet_id);
> - return err;
> + return 0;
>   }
>  
>   if (x2apic_enabled())
> @@ -3150,7 +3150,7 @@ static int msi_compose_msg(struct pci_dev *pdev, 
> unsigned int irq,
>   MSI_DATA_DELIVERY_LOWPRI) |
>   MSI_DATA_VECTOR(cfg->vector);
>  
> - return err;
> + return 0;
>  }
>  
>  static int
> @@ -3232,7 +3232,7 @@ int setup_msix_irqs(struct pci_dev *dev, int nvec)
>   list_for_each_entry(msidesc, >msi_list, list) {
>   irq = create_irq_nr(irq_want, node);
>   if (irq == 0)
> - return -1;
> + return -ENOSPC;
>   irq_want = irq + 1;
>   if (!irq_remapping_enabled)
>   goto no_ir;

This should be backported into earlier patches.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 -tip 1/5] x86, MSI: Support multiple MSIs in presense of IRQ remapping

2012-10-01 Thread Ingo Molnar

* Alexander Gordeev  wrote:

> The MSI specification has several constraints in comparison with MSI-X,
> most notable of them is the inability to configure MSIs independently.
> As a result, it is impossible to dispatch interrupts from different
> queues to different CPUs. This is largely devalues the support of
> multiple MSIs in SMP systems.
> 
> Also, a necessity to allocate a contiguous block of vector numbers for
> devices capable of multiple MSIs might cause a considerable pressure on
> x86 interrupt vector allocator and could lead to fragmentation of the
> interrupt vectors space.
> 
> This patch overcomes both drawbacks in presense of IRQ remapping and
> lets devices take advantage of multiple queues and per-IRQ affinity
> assignments.
> 
> Signed-off-by: Alexander Gordeev 
> ---
>  arch/x86/kernel/apic/io_apic.c |  174 +--
>  include/linux/irq.h|6 ++
>  kernel/irq/chip.c  |   30 +--
>  kernel/irq/irqdesc.c   |   31 +++
>  4 files changed, 206 insertions(+), 35 deletions(-)
> 
> diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
> index c265593..d5cb13c 100644
> --- a/arch/x86/kernel/apic/io_apic.c
> +++ b/arch/x86/kernel/apic/io_apic.c
> @@ -305,6 +305,11 @@ static int alloc_irq_from(unsigned int from, int node)
>   return irq_alloc_desc_from(from, node);
>  }
>  
> +static int alloc_irqs_from(unsigned int from, unsigned int count, int node)
> +{
> + return irq_alloc_descs_from(from, count, node);
> +}
> +
>  static void free_irq_at(unsigned int at, struct irq_cfg *cfg)
>  {
>   free_irq_cfg(at, cfg);
> @@ -2991,37 +2996,58 @@ device_initcall(ioapic_init_ops);
>  /*
>   * Dynamic irq allocate and deallocation
>   */
> -unsigned int create_irq_nr(unsigned int from, int node)
> +unsigned int __create_irqs(unsigned int from, unsigned int count, int node)
>  {
> - struct irq_cfg *cfg;
> + struct irq_cfg **cfg;
>   unsigned long flags;
> - unsigned int ret = 0;
> - int irq;
> + int irq, i;
>  
>   if (from < nr_irqs_gsi)
>   from = nr_irqs_gsi;
>  
> - irq = alloc_irq_from(from, node);
> - if (irq < 0)
> - return 0;
> - cfg = alloc_irq_cfg(irq, node);
> - if (!cfg) {
> - free_irq_at(irq, NULL);
> + cfg = kzalloc_node(count * sizeof(cfg[0]), GFP_KERNEL, node);
> + if (!cfg)
>   return 0;
> +
> + irq = alloc_irqs_from(from, count, node);
> + if (irq < 0)
> + goto out_cfgs;
> +
> + for (i = 0; i < count; i++) {
> + cfg[i] = alloc_irq_cfg(irq + i, node);
> + if (!cfg[i])
> + goto out_irqs;
>   }
>  
>   raw_spin_lock_irqsave(_lock, flags);
> - if (!__assign_irq_vector(irq, cfg, apic->target_cpus()))
> - ret = irq;
> + for (i = 0; i < count; i++)
> + if (__assign_irq_vector(irq + i, cfg[i], apic->target_cpus()))
> + goto out_vecs;
>   raw_spin_unlock_irqrestore(_lock, flags);
>  
> - if (ret) {
> - irq_set_chip_data(irq, cfg);
> - irq_clear_status_flags(irq, IRQ_NOREQUEST);
> - } else {
> - free_irq_at(irq, cfg);
> + for (i = 0; i < count; i++) {
> + irq_set_chip_data(irq + i, cfg[i]);
> + irq_clear_status_flags(irq + i, IRQ_NOREQUEST);
>   }
> - return ret;
> +
> + kfree(cfg);
> + return irq;
> +
> +out_vecs:
> + for (; i; i--)
> + __clear_irq_vector(irq + i - 1, cfg[i - 1]);
> + raw_spin_unlock_irqrestore(_lock, flags);
> +out_irqs:
> + for (i = 0; i < count; i++)
> + free_irq_at(irq + i, cfg[i]);
> +out_cfgs:
> + kfree(cfg);
> + return 0;
> +}
> +
> +unsigned int create_irq_nr(unsigned int from, int node)
> +{
> + return __create_irqs(from, 1, node);
>  }
>  
>  int create_irq(void)
> @@ -3054,6 +3080,27 @@ void destroy_irq(unsigned int irq)
>   free_irq_at(irq, cfg);
>  }
>  
> +static inline void destroy_irqs(unsigned int irq, unsigned int count)
> +{
> + unsigned int i;
> + for (i = 0; i < count; i++)

Missing newline.

> + destroy_irq(irq + i);
> +}
> +
> +static inline int
> +can_create_pow_of_two_irqs(unsigned int from, unsigned int count)
> +{
> + if ((count > 1) && (count % 2))
> + return -EINVAL;
> +
> + for (; count; count = count / 2) {
> + if (!irq_can_alloc_irqs(from, count))
> + return count;
> + }
> +
> + return -ENOSPC;
> +}
> +
>  /*
>   * MSI message composition
>   */
> @@ -3145,18 +3192,25 @@ static struct irq_chip msi_chip = {
>   .irq_retrigger  = ioapic_retrigger_irq,
>  };
>  
> -static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int 
> irq)
> +static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
> +  unsigned int irq_base, unsigned int irq_offset)

Re: [PATCH v3 -tip 5/5] AHCI: Support multiple MSIs

2012-10-01 Thread Jeff Garzik

On 10/02/2012 12:21 AM, Bjorn Helgaas wrote:

On Mon, Oct 1, 2012 at 9:04 PM, Jeff Garzik  wrote:

On 10/01/2012 04:13 AM, Alexander Gordeev wrote:


Take advantage of multiple MSIs implementation on x86 - on systems with
IRQ remapping AHCI ports not only get assigned separate MSI vectors -
but also separate IRQs. As result, interrupts generated by different
ports could be serviced on different CPUs rather than on a single one.

In cases when number of allocated MSIs is less than requested the Sharing
Last MSI mode does not get used, no matter implemented in hardware or not.
Instead, the driver assumes the advantage of multiple MSIs is negated and
falls back to the single MSI mode as if MRSM bit was set (some Intel chips
implement this strategy anyway - MRSM bit gets set even if the number of
allocated MSIs exceeds the number of implemented ports).

Signed-off-by: Alexander Gordeev 
---
   drivers/ata/ahci.c|   91 --
   drivers/ata/ahci.h|6 +++
   drivers/ata/libahci.c |  118
++---
   3 files changed, 205 insertions(+), 10 deletions(-)



Acked-by: Jeff Garzik 

Normally, this amount of changes would -really- need to go through the
libata tree.  However, given the amount of dependencies, it either needs a
merge tree or to go through the PCI tree...?

Any maintainer comments on disposition?


For what it's worth, the bulk of this change is outside PCI, so it
doesn't seem to me like it should go through the PCI tree.  I think I
did ack the part that touched PCI, and there's not much activity in
the PCI MSI area right now, so I'm fine with it going through libata
or whatever people think makes sense.


That works for me, too.  I'm ready to queue it, if libata tree is fine 
with people.


Jeff




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 00/11] x86/microcode: Early load microcode

2012-10-01 Thread Borislav Petkov
On Mon, Oct 01, 2012 at 07:37:04PM -0400, Jamie Gloudon wrote:
> On Mon, Oct 01, 2012 at 06:27:45PM +0200, Borislav Petkov wrote:
> > On Mon, Oct 01, 2012 at 12:11:51PM -0400, Jamie Gloudon wrote:
> > > Hey,
> > > 
> > >   Any chance of this getting merge for the 3.7 cycle? 
> > 
> > It is not ready yet: http://marc.info/?l=linux-kernel=134910582107898
> > 
> > Out of curiosity: why do you nee it?
> > 
> Seems like a better alternative to microcode_ctl which some distros don't
> contain.

 [ Let me reorganize the mail chain as it should be,
   without top-posting. Please try not to top-post:
   http://curl.haxx.se/mail/etiquette.html#Do_Not_Top_Post ]


Well,

if you want to reload your microcode, you shouldn't be needing
microcode_ctl (I believe this should be the case too on Intel, from
staring at the code - on AMD it works).

Basically, you simply put the microcode binaries into
/lib/firmware/{amd,intel}-ucode/ and then do as root:

$ echo 1 > /sys/devices/system/cpu/microcode/reload

That's it, no need for special tools.

-- 
Regards/Gruss,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: build failure after merge of the xen-two tree

2012-10-01 Thread Stephen Rothwell
Hi Konrad,

After merging the xen-two tree, today's linux-next build (x86_64
allmodconfig) failed like this:

arch/x86/built-in.o: In function `xen_start_kernel':
(.init.text+0xa88): undefined reference to `xen_acpi_notify_hypervisor_state'
drivers/built-in.o: In function `dbgp_reset_prep':
(.text+0x12ddeb): undefined reference to `xen_dbgp_reset_prep'
drivers/built-in.o: In function `dbgp_external_startup':
(.text+0x12e6a9): undefined reference to `xen_dbgp_external_startup'

I have used the xen-two tree from next-20121001 for today.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpHsLiEh2alQ.pgp
Description: PGP signature


Re: [PATCH v2 2/2] hwmon: (ads7828) add support for ADS7830

2012-10-01 Thread Guenter Roeck
On Mon, Oct 01, 2012 at 11:28:21PM -0400, Vivien Didelot wrote:
> Hi Guenter,
> 
Hi Vivien,

[ ... ]

> > > + } else {
> > > + dev_dbg(>dev, "doesn't look like an "
> > > + "ADS7828 compatible device\n");
> > 
> > WARNING: quoted string split across lines
> > #190: FILE: drivers/hwmon/ads7828.c:196:
> > +   dev_dbg(>dev, "doesn't look like an 
> > "
> > +   "ADS7828 compatible device\n");
> Hum ok, so the reason for that is that it breaks the ability to grep a
> string... Makes sense.
> > 
> > Better:
> > dev_dbg(>dev,
> > "doesn't look like an ADS7828 
> > compatible device\n");
> This exceeds 80 chars, but I'll find a shorter message.

That is ok nowadays if it is due to a quoted string.

Guenter 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] serial/arc-uart: Add new driver

2012-10-01 Thread Vineet Gupta
On Friday 28 September 2012 06:32 PM, Alan Cox wrote:

>> +static void
>> +arc_serial_set_termios(struct uart_port *port, struct ktermios
>> *termios,
>> +   struct ktermios *old)
>> +{
>> +struct arc_uart_port *uart = (struct arc_uart_port *)port;
>> +unsigned int baud, uartl, uarth, hw_val;
>> +unsigned long flags;
>> +
> Two things here. Firstly you want to write the actual baud back to the
> termios (tty_termios_encode_baud_rate) unless B0 is set.
>
> Secondly if you don't support hardware flow control, character size
> setting etc then you need to set those bits back so the caller knows.
> Two ways to do that. Either initialise the default termios for the tty
> type to the correct values and use tty_termios_copy_hw() or set them in
> the termios handler.

Just to give you an idea, is something on the lines of following OK for
both the above points above !

-   uart_update_timeout(port, termios->c_cflag, baud);
+   new->c_cflag &= ~(CMSPAR|CRTSCTS);  /* Don't care for
parity/flow ctrl */
+
+   if (old)
+   tty_termios_copy_hw(new, old);
+
+   /* Don't rewrite B0 */
+   if (tty_termios_baud_rate(new))
+   tty_termios_encode_baud_rate(new, baud, baud);
+
+   uart_update_timeout(port, new->c_cflag, baud);
 

Respun patch to follow shortly.

Thx,
Vineet
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: linux-next: build failure in dwarf-regs.c

2012-10-01 Thread Ian Munsie
Hey Ben,

Adding some people to CC...

Excerpts from Ben Guthro's message of 2012-10-02 11:02:59 +1000:
> I pulled the latest bits up to 797b9e5ae93270ec27a1f1ed48cd697d01b2269f -
> but am seeing the following build failure with gcc 4.6.3

Building that SHA works for me (on x86, haven't tried PPC yet)...

>  CC arch/x86/util/dwarf-regs.o

Is this correct? i.e. Are you building perf for x86?

What commandline are you using to build?

Any exported environment variables that may be relevant?

What dev libraries does perf warn is missing (Is libdw-dev among them)?

> arch/x86/util/dwarf-regs.c:72:13: error: no previous prototype for
> 'get_arch_regstr' [-Werror=missing-prototypes]

Hmmm... util/include/dwarf-regs.h not included? DWARF_SUPPORT undefined
but still building that file for some reason?

Can't see any obvious way that could happen... You didn't happen to see
an warning along the lines of 'DWARF register mappings not defined for
x86' did you?

> `/data/home/bguthro/dev/orc-newdev.git/linux/build/tools/tools/perf'

I hope the two 'tools' here is just an O= artefact?

> git blame shows that line coming in from the following changeset - though
> April is a long time ago in kernel time

Especially when it's April from two years ago...

> - so this must have come in with some other merge in this 3.7 window

Seems likely, especially as (excerpt from git diff --stat v3.6 797b9e5
-- tools/perf):

tools/perf/arch/x86/Makefile| 3 +
tools/perf/arch/x86/include/perf_regs.h | 80 +++
tools/perf/Makefile | 173 --

I see a few changes in there that may have caused this... Since I can't
reproduce this myself I can't narrow it down, so I'm adding David Ahern,
Namhyung Kim & Jiri Olsa to CC who have touched lines that look like the
might be relevant.

Ben: You should be able to narrow down the cause of the breakage a bit
more with git bisect start 797b9e5 v3.6 -- tools/perf/Makefile

Cheers,
-Ian

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] user namespace changes for v3.7

2012-10-01 Thread Eric W. Biederman

Linus,

Please pull the for-linus git tree from:

   git://git.kernel.org:/pub/scm/linux/kernel/git/ebiederm/user-namespace.git 
for-linus

   HEAD: 72235465864d84cedb2d9f26f8e1de824ee20339 userns: Convert the ufs 
filesystem to use kuid/kgid where appropriate

   The tree is against v3.6-rc1

This is a mostly modest set of changes to enable basic user namespace
support.  This allows the code to code to compile with user namespaces
enabled and removes the assumption there is only the initial user
namespace.  Everything is converted except for the most complex of the
filesystems: autofs4, 9p, afs, ceph, cifs, coda, fuse, gfs2, ncpfs, nfs,
ocfs2 and xfs as those patches need a bit more review.

The strategy is to push kuid_t and kgid_t values are far down into
subsystems and filesystems as reasonable.  Leaving the make_kuid and
from_kuid operations to happen at the edge of userspace, as the
values come off the disk, and as the values come in from the network.
Letting compile type incompatible compile errors (present when user
namespaces are enabled) guide me to find the issues.

The most tricky areas have been the places where we had an implicit
union of uid and gid values and were storing them in an unsigned int.
Those places were converted into explicit unions.   I made certain
to handle those places with simple trivial patches.

Out of that work I discovered we have generic interfaces for storing
quota by projid.  I had never heard of the project identifiers before.
Adding full user namespace support for project identifiers accounts
for most of the code size growth in my git tree.

Ultimately there will be work to relax privlige checks from
"capable(FOO)" to "ns_capable(user_ns, FOO)" where it is safe
allowing root in a user names to do those things that today we only
forbid to non-root users because it will confuse suid root applications.

While I was pushing kuid_t and kgid_t changes deep into the audit code I
made a few other cleanups. I capitalized on the fact we process netlink
messages in the context of the message sender.  I removed usage of
NETLINK_CRED, and started directly using current->tty.

Some of these patches have also made it into maintainer trees, with no
problems from identical code from different trees showing up in
linux-next.

After reading through all of this code I feel like I might be able
to win a game of kernel trivial pursuit.

Eric


Dan Carpenter (1):
  ipv6: move dereference after check in fl_free()

Eric W. Biederman (106):
  userns: Allow the usernamespace support to build after the removal of 
usbfs
  userns:  Fix link restrictions to use uid_eq
  userns: Convert net/core/scm.c to use kuids and kgids
  userns: Convert __dev_set_promiscuity to use kuids in audit logs
  userns: Convert sock_i_uid to return a kuid_t
  userns: Allow USER_NS and NET simultaneously in Kconfig
  userns: Make seq_file's user namespace accessible
  userns: Print out socket uids in a user namespace aware fashion.
  userns: Use kgids for sysctl_ping_group_range
  net ip6 flowlabel: Make owner a union of struct pid * and kuid_t
  pidns: Export free_pid_ns
  userns: Convert net/ax25 to use kuid_t where appropriate
  netlink: Make the sending netlink socket availabe in NETLINK_CB
  userns: Implement sk_user_ns
  userns: Teach inet_diag to work with user namespaces
  userns: nfnetlink_log: Report socket uids in the log sockets user 
namespace
  net sched: Pass the skb into change so it can access NETLINK_CB
  userns: Convert cls_flow to work with user namespaces enabled
  userns: Convert xt_LOG to print socket kuids and kgids as uids and gids
  userns xt_recent: Specify the owner/group of ip_list_perms in the initial 
user namespace
  userns: xt_owner: Add basic user namespace support.
  userns: Make the airo wireless driver use kuids for proc uids and gids
  userns: Convert tun/tap to use kuid and kgid where appropriate
  userns: Enable building of pf_key sockets when user namespace support is 
enabled.
  userns: Make credential debugging user namespace safe.
  userns: Convert debugfs to use kuid/kgid where appropriate.
  userns: Convert process event connector to handle kuids and kgids
  userns: Convert ipc to use kuid and kgid where appropriate
  userns: Convert drm to use kuid and kgid and struct pid where appropriate
  userns: Convert security/keys to the new userns infrastructure
  userns: net: Call key_alloc with GLOBAL_ROOT_UID, GLOBAL_ROOT_GID instead 
of 0, 0
  audit: Limit audit requests to processes in the initial pid and user 
namespaces.
  audit: Use current instead of NETLINK_CREDS() in audit_filter
  audit: kill audit_prepare_user_tty
  audit: Simply AUDIT_TTY_SET and AUDIT_TTY_GET
  audit: Properly set the origin port id of audit messages.
  audit: Remove the unused uid parameter from audit_receive_filter
  audit: Don't pass pid or 

Re: [RFC v9 PATCH 16/21] memory-hotplug: free memmap of sparse-vmemmap

2012-10-01 Thread Ni zhan Chen

On 09/05/2012 05:25 PM, we...@cn.fujitsu.com wrote:

From: Yasuaki Ishimatsu 

All pages of virtual mapping in removed memory cannot be freed, since some pages
used as PGD/PUD includes not only removed memory but also other memory. So the
patch checks whether page can be freed or not.

How to check whether page can be freed or not?
  1. When removing memory, the page structs of the revmoved memory are filled
 with 0FD.
  2. All page structs are filled with 0xFD on PT/PMD, PT/PMD can be cleared.
 In this case, the page used as PT/PMD can be freed.

Applying patch, __remove_section() of CONFIG_SPARSEMEM_VMEMMAP is integrated
into one. So __remove_section() of CONFIG_SPARSEMEM_VMEMMAP is deleted.

Note:  vmemmap_kfree() and vmemmap_free_bootmem() are not implemented for ia64,
ppc, s390, and sparc.

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
CC: Wen Congyang 
Signed-off-by: Yasuaki Ishimatsu 
---
  arch/ia64/mm/discontig.c  |8 +++
  arch/powerpc/mm/init_64.c |8 +++
  arch/s390/mm/vmem.c   |8 +++
  arch/sparc/mm/init_64.c   |8 +++
  arch/x86/mm/init_64.c |  119 +
  include/linux/mm.h|2 +
  mm/memory_hotplug.c   |   17 +--
  mm/sparse.c   |5 +-
  8 files changed, 158 insertions(+), 17 deletions(-)

diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 33943db..0d23b69 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -823,6 +823,14 @@ int __meminit vmemmap_populate(struct page *start_page,
return vmemmap_populate_basepages(start_page, size, node);
  }
  
+void vmemmap_kfree(struct page *memmap, unsigned long nr_pages)

+{
+}
+
+void vmemmap_free_bootmem(struct page *memmap, unsigned long nr_pages)
+{
+}
+
  void register_page_bootmem_memmap(unsigned long section_nr,
  struct page *start_page, unsigned long size)
  {
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 3690c44..835a2b3 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -299,6 +299,14 @@ int __meminit vmemmap_populate(struct page *start_page,
return 0;
  }
  
+void vmemmap_kfree(struct page *memmap, unsigned long nr_pages)

+{
+}
+
+void vmemmap_free_bootmem(struct page *memmap, unsigned long nr_pages)
+{
+}
+
  void register_page_bootmem_memmap(unsigned long section_nr,
  struct page *start_page, unsigned long size)
  {
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index eda55cd..4b42b0b 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -227,6 +227,14 @@ out:
return ret;
  }
  
+void vmemmap_kfree(struct page *memmap, unsigned long nr_pages)

+{
+}
+
+void vmemmap_free_bootmem(struct page *memmap, unsigned long nr_pages)
+{
+}
+
  void register_page_bootmem_memmap(unsigned long section_nr,
  struct page *start_page, unsigned long size)
  {
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index add1cc7..1384826 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2078,6 +2078,14 @@ void __meminit vmemmap_populate_print_last(void)
}
  }
  
+void vmemmap_kfree(struct page *memmap, unsigned long nr_pages)

+{
+}
+
+void vmemmap_free_bootmem(struct page *memmap, unsigned long nr_pages)
+{
+}
+
  void register_page_bootmem_memmap(unsigned long section_nr,
  struct page *start_page, unsigned long size)
  {
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0075592..4e8f8a4 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1138,6 +1138,125 @@ vmemmap_populate(struct page *start_page, unsigned long 
size, int node)
return 0;
  }
  
+#define PAGE_INUSE 0xFD

+
+unsigned long find_and_clear_pte_page(unsigned long addr, unsigned long end,
+   struct page **pp, int *page_size)
+{
+   pgd_t *pgd;
+   pud_t *pud;
+   pmd_t *pmd;
+   pte_t *pte;
+   void *page_addr;
+   unsigned long next;
+
+   *pp = NULL;
+
+   pgd = pgd_offset_k(addr);
+   if (pgd_none(*pgd))
+   return pgd_addr_end(addr, end);
+
+   pud = pud_offset(pgd, addr);
+   if (pud_none(*pud))
+   return pud_addr_end(addr, end);
+
+   if (!cpu_has_pse) {
+   next = (addr + PAGE_SIZE) & PAGE_MASK;
+   pmd = pmd_offset(pud, addr);
+   if (pmd_none(*pmd))
+   return next;
+
+   pte = pte_offset_kernel(pmd, addr);
+   if (pte_none(*pte))
+   return next;
+
+   *page_size = PAGE_SIZE;
+   *pp = pte_page(*pte);
+   } else {
+   next = pmd_addr_end(addr, end);
+
+   pmd = pmd_offset(pud, 

Re: [PATCH v3 -tip 5/5] AHCI: Support multiple MSIs

2012-10-01 Thread Bjorn Helgaas
On Mon, Oct 1, 2012 at 9:04 PM, Jeff Garzik  wrote:
> On 10/01/2012 04:13 AM, Alexander Gordeev wrote:
>>
>> Take advantage of multiple MSIs implementation on x86 - on systems with
>> IRQ remapping AHCI ports not only get assigned separate MSI vectors -
>> but also separate IRQs. As result, interrupts generated by different
>> ports could be serviced on different CPUs rather than on a single one.
>>
>> In cases when number of allocated MSIs is less than requested the Sharing
>> Last MSI mode does not get used, no matter implemented in hardware or not.
>> Instead, the driver assumes the advantage of multiple MSIs is negated and
>> falls back to the single MSI mode as if MRSM bit was set (some Intel chips
>> implement this strategy anyway - MRSM bit gets set even if the number of
>> allocated MSIs exceeds the number of implemented ports).
>>
>> Signed-off-by: Alexander Gordeev 
>> ---
>>   drivers/ata/ahci.c|   91 --
>>   drivers/ata/ahci.h|6 +++
>>   drivers/ata/libahci.c |  118
>> ++---
>>   3 files changed, 205 insertions(+), 10 deletions(-)
>
>
> Acked-by: Jeff Garzik 
>
> Normally, this amount of changes would -really- need to go through the
> libata tree.  However, given the amount of dependencies, it either needs a
> merge tree or to go through the PCI tree...?
>
> Any maintainer comments on disposition?

For what it's worth, the bulk of this change is outside PCI, so it
doesn't seem to me like it should go through the PCI tree.  I think I
did ack the part that touched PCI, and there's not much activity in
the PCI MSI area right now, so I'm fine with it going through libata
or whatever people think makes sense.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the xen-two tree with Linus' tree

2012-10-01 Thread Stephen Rothwell
Hi Konrad,

Today's linux-next merge of the xen-two tree got a conflict in
drivers/xen/Makefile between commit 9fa5780beea1 ("USB EHCI/Xen:
propagate controller reset information to hypervisor") from Linus' tree
and commit 13febc84849d ("xen: do not compile manage, balloon, pci, acpi,
pcpu and cpu_hotplug on ARM") from the xen-two tree.

I fixed it up (I am not sure exactly what it should depend on - see
below) and can carry the fix as necessary (no action is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/xen/Makefile
index a4a3cab,cd28aae..000
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@@ -4,8 -8,11 +8,12 @@@ obj-y  += xenbus
  nostackp := $(call cc-option, -fno-stack-protector)
  CFLAGS_features.o := $(nostackp)
  
+ obj-$(CONFIG_XEN_DOM0)+= $(dom0-y)
+ dom0-$(CONFIG_PCI) += pci.o
++dom0-$(CONFIG_X86) += dbgp.o
+ dom0-$(CONFIG_ACPI) += acpi.o
+ dom0-$(CONFIG_X86) += pcpu.o
  obj-$(CONFIG_BLOCK)   += biomerge.o
- obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
  obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
  obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o
  obj-$(CONFIG_XEN_SELFBALLOONING)  += xen-selfballoon.o


pgpKErJkcxuZr.pgp
Description: PGP signature


Re: [PATCH] ACPI: Add new sysfs interface to export device description

2012-10-01 Thread Len Brown
> 
> To address your comment, I was trying to differentiate between the existence 
> of the _STR method and the failure to evaluate it.
> If an STR method exists, we create the sysfs file.  If it fails to
evaluate, we will see "No Description" when we read the file.
> This would indicate that something is wrong as opposed to the system not 
> having an _STR.
> If you feel that this is unnecessary, or should be done differently let me 
> know.

This patch looks useful, and I this does seem like a logical place
to export this information.

however, I'd think that an empty attribute instead of "No description"
is sufficient to cover the case of _STR existing, but for some reason
failing to evaluate.

thanks,
Len Brown, Intel Open Source Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the xen-two tree with the arm tree

2012-10-01 Thread Stephen Rothwell
Hi Konrad,

Today's linux-next merge of the xen-two tree got a conflict in
arch/arm/Kconfig between commit bd51e2f59558 ("ARM: 7506/1: allow for
ATAGS to be configured out when DT support is selected") from the arm
tree and commit eff8d6447d5f ("xen/arm: introduce CONFIG_XEN on ARM")
from the xen-two tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc arch/arm/Kconfig
index 7df4acc,3361466..000
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@@ -1897,6 -1891,22 +1897,16 @@@ config CC_STACKPROTECTO
  neutralized via a kernel panic.
  This feature requires gcc version 4.2 or above.
  
 -config DEPRECATED_PARAM_STRUCT
 -  bool "Provide old way to pass kernel parameters"
 -  help
 -This was deprecated in 2001 and announced to live on for 5 years.
 -Some old boot loaders still use this way.
 -
+ config XEN_DOM0
+   def_bool y
+   depends on XEN
+ 
+ config XEN
+   bool "Xen guest support on ARM (EXPERIMENTAL)"
+   depends on EXPERIMENTAL && ARM && OF
+   help
+ Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.
+ 
  endmenu
  
  menu "Boot options"


pgp8dcxrcgJU7.pgp
Description: PGP signature


linux-next: manual merge of the dt-rh tree with Linus' tree

2012-10-01 Thread Stephen Rothwell
Hi Rob,

Today's linux-next merge of the dt-rh tree got a conflict in
drivers/of/base.c include/linux/of.h between commit 3296193d1421 ("dt:
introduce for_each_available_child_of_node, of_get_next_available_child")
from Linus' tree and commit 9c19761a7ecd ("dt: introduce
of_get_child_by_name to get child node by name") from the dt-rh tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/of/base.c
index 4a8d46f,e2e8136..000
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@@ -364,33 -364,29 +364,56 @@@ struct device_node *of_get_next_child(c
  EXPORT_SYMBOL(of_get_next_child);
  
  /**
 + *of_get_next_available_child - Find the next available child node
 + *@node:  parent node
 + *@prev:  previous child of the parent node, or NULL to get first
 + *
 + *  This function is like of_get_next_child(), except that it
 + *  automatically skips any disabled nodes (i.e. status = "disabled").
 + */
 +struct device_node *of_get_next_available_child(const struct device_node 
*node,
 +  struct device_node *prev)
 +{
 +  struct device_node *next;
 +
 +  read_lock(_lock);
 +  next = prev ? prev->sibling : node->child;
 +  for (; next; next = next->sibling) {
 +  if (!of_device_is_available(next))
 +  continue;
 +  if (of_node_get(next))
 +  break;
 +  }
 +  of_node_put(prev);
 +  read_unlock(_lock);
 +  return next;
 +}
 +EXPORT_SYMBOL(of_get_next_available_child);
 +
 +/**
+  *of_get_child_by_name - Find the child node by name for a given parent
+  *@node:  parent node
+  *@name:  child name to look for.
+  *
+  *  This function looks for child node for given matching name
+  *
+  *Returns a node pointer if found, with refcount incremented, use
+  *of_node_put() on it when done.
+  *Returns NULL if node is not found.
+  */
+ struct device_node *of_get_child_by_name(const struct device_node *node,
+   const char *name)
+ {
+   struct device_node *child;
+ 
+   for_each_child_of_node(node, child)
+   if (child->name && (of_node_cmp(child->name, name) == 0))
+   break;
+   return child;
+ }
+ EXPORT_SYMBOL(of_get_child_by_name);
+ 
+ /**
   *of_find_node_by_path - Find a node matching a full OF path
   *@path:  The full path to match
   *
diff --cc include/linux/of.h
index 5c7a158,fabb524..000
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@@ -190,9 -190,8 +190,11 @@@ extern struct device_node *of_get_paren
  extern struct device_node *of_get_next_parent(struct device_node *node);
  extern struct device_node *of_get_next_child(const struct device_node *node,
 struct device_node *prev);
 +extern struct device_node *of_get_next_available_child(
 +  const struct device_node *node, struct device_node *prev);
 +
+ extern struct device_node *of_get_child_by_name(const struct device_node 
*node,
+   const char *name);
  #define for_each_child_of_node(parent, child) \
for (child = of_get_next_child(parent, NULL); child != NULL; \
 child = of_get_next_child(parent, child))


pgpW37k9sBScn.pgp
Description: PGP signature


[tip:x86/acpi] ACPI: Fix build when disabled

2012-10-01 Thread tip-bot for David Rientjes
Commit-ID:  3dfd8235002727dbd759bb0f80f8ac862f392071
Gitweb: http://git.kernel.org/tip/3dfd8235002727dbd759bb0f80f8ac862f392071
Author: David Rientjes 
AuthorDate: Mon, 1 Oct 2012 20:38:47 -0700
Committer:  H. Peter Anvin 
CommitDate: Mon, 1 Oct 2012 20:41:43 -0700

ACPI: Fix build when disabled

"ACPI: Store valid ACPI tables passed via early initrd in reserved
memblock areas" breaks the build if either CONFIG_ACPI or
CONFIG_BLK_DEV_INITRD is disabled:

arch/x86/kernel/setup.c: In function 'setup_arch':
arch/x86/kernel/setup.c:944: error: implicit declaration of function 
'acpi_initrd_override'

or

arch/x86/built-in.o: In function `setup_arch':
(.init.text+0x1397): undefined reference to `initrd_start'
arch/x86/built-in.o: In function `setup_arch':
(.init.text+0x139e): undefined reference to `initrd_end'

The dummy acpi_initrd_override() function in acpi.h isn't defined without
CONFIG_ACPI and initrd_{start,end} are declared but not defined without
CONFIG_BLK_DEV_INITRD.

[ hpa: applying this as a fix, but this really should be done cleaner ]

Signed-off-by: David Rientjes 
Link: 
http://lkml.kernel.org/r/alpine.deb.2.00.1210012032470.31...@chino.kir.corp.google.com
Signed-off-by: H. Peter Anvin 
Cc: Thomas Renninger 
Cc: Len Brown 
---
 arch/x86/kernel/setup.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 764e543..bf82c1e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -941,7 +941,9 @@ void __init setup_arch(char **cmdline_p)
 
reserve_initrd();
 
+#if defined(CONFIG_ACPI) && defined(CONFIG_BLK_DEV_INITRD)
acpi_initrd_override((void *)initrd_start, initrd_end - initrd_start);
+#endif
 
reserve_crashkernel();
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: CONFIG_EXPERT is a booby trap

2012-10-01 Thread David Rientjes
On Sun, 30 Sep 2012, Tim Shepard wrote:

> And may I suggest that CONFIG_EXPERT should be factored into two
> CONFIGs, one of which makes configuration things visible, and another
> which changes the default values to something more appropriate for
> embedded systems (perhaps call it CONFIG_EMBEDDED_DEFAULTS).  That way
> you'd have to select CONFIG_EXPERT, and then select the
> CONFIG_EMBEDDED_DEFAULTS option that CONFIG_EXPERT made visible to
> actually change any configuration, and the documentation for
> CONFIG_EMBEDDED_DEFAULTS could explain that it changes defaults
> throughout the tree (and selecting CONFIG_EXPERT alone would not go off
> and muck things up with no warning).
> 

I think you can get away with changing everything that is doing "default 
!EXPERT" to do "default !EMBEDDED" since it's usually only done for things 
that are known not to be interesting for the embedded world and 
significantly increase the size of the kernel memory footprint.  What it's 
really saying is to "enable it by default on everything that doesn't need 
to make the smallest kernel possible."

Aside from that, separating CONFIG_EXPERT from CONFIG_EMBEDDED is 
something that has been discussed a few times and can be done when it 
makes clear sense and you can get consensus on the change.  We always 
accept patches.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: CONFIG_EXPERT is a booby trap

2012-10-01 Thread David Rientjes
On Mon, 1 Oct 2012, Tim Shepard wrote:

> Interestingly, of the 26 configs that use EXPERT in the default
> clause, 15 of them are in drivers/hid (see below).
> 
>   -Tim Shepard
>s...@alum.mit.edu
> 
>  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - - 
> 
> $ find . -type f -name Kconfig'*' -print | xargs fgrep default | grep EXPERT 
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/hid/Kconfig:  default !EXPERT
> ./drivers/media/common/tuners/Kconfig:  default y if !EXPERT
> ./drivers/media/common/tuners/Kconfig:  default y if EXPERT
> ./drivers/media/dvb/frontends/Kconfig:  default y if EXPERT
> ./drivers/media/video/Kconfig:  default y if !EXPERT
> ./init/Kconfig: default !EXPERT
> ./lib/Kconfig.debug:default !EXPERT
> ./net/rfkill/Kconfig:   default y if !EXPERT
> ./usr/Kconfig:  default !EXPERT
> ./usr/Kconfig:  default !EXPERT
> ./usr/Kconfig:  default !EXPERT
> ./usr/Kconfig:  default !EXPERT

I don't think selecting CONFIG_EXPERT should change whether a config 
option is enabled or disabled by default, I think it should only change 
whether certain options are available for enabling or disabling.  These do 
need care when fixing, though, and in the above circumstances you may find 
that s/EXPERT/EMBEDDED/ is the right change.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch x86/acpi] ACPI: Fix build when disabled

2012-10-01 Thread David Rientjes
"ACPI: Store valid ACPI tables passed via early initrd in reserved 
memblock areas" breaks the build if either CONFIG_ACPI or 
CONFIG_BLK_DEV_INITRD is disabled:

arch/x86/kernel/setup.c: In function 'setup_arch':
arch/x86/kernel/setup.c:944: error: implicit declaration of function 
'acpi_initrd_override'

or

arch/x86/built-in.o: In function `setup_arch':
(.init.text+0x1397): undefined reference to `initrd_start'
arch/x86/built-in.o: In function `setup_arch':
(.init.text+0x139e): undefined reference to `initrd_end'

The dummy acpi_initrd_override() function in acpi.h isn't defined without 
CONFIG_ACPI and initrd_{start,end} are declared but not defined without 
CONFIG_BLK_DEV_INITRD.

Signed-off-by: David Rientjes 
---
 arch/x86/kernel/setup.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -941,7 +941,9 @@ void __init setup_arch(char **cmdline_p)
 
reserve_initrd();
 
+#if defined(CONFIG_ACPI) && defined(CONFIG_BLK_DEV_INITRD)
acpi_initrd_override((void *)initrd_start, initrd_end - initrd_start);
+#endif
 
reserve_crashkernel();
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 3/3] tracing: Format non-nanosec times from tsc clock without a decimal point.

2012-10-01 Thread David Sharp
With the addition of the "tsc" clock, formatting timestamps to look like
fractional seconds is misleading. Mark clocks as either in nanoseconds or
not, and format non-nanosecond timestamps as decimal integers.

Tested:
$ cd /sys/kernel/debug/tracing/
$ cat trace_clock
[local] global tsc
$ echo sched_switch > set_event
$ echo 1 > tracing_enabled ; sleep 0.0005 ; echo 0 > tracing_enabled
$ cat trace
  -0 [000]  6330.52: sched_switch: prev_comm=swapper 
prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=bash next_pid=29964 
next_prio=120
   sleep-29964 [000]  6330.555628: sched_switch: prev_comm=bash 
prev_pid=29964 prev_prio=120 prev_state=S ==> next_comm=swapper next_pid=0 
next_prio=120
  ...
$ echo 1 > options/latency-format
$ cat trace
  -0   0 4104553247us+: sched_switch: prev_comm=swapper prev_pid=0 
prev_prio=120 prev_state=R ==> next_comm=bash next_pid=29964 next_prio=120
   sleep-29964   0 4104553322us+: sched_switch: prev_comm=bash prev_pid=29964 
prev_prio=120 prev_state=S ==> next_comm=swapper next_pid=0 next_prio=120
  ...
$ echo tsc > trace_clock
$ cat trace
$ echo 1 > tracing_enabled ; sleep 0.0005 ; echo 0 > tracing_enabled
$ echo 0 > options/latency-format
$ cat trace
  -0 [000] 16490053398357: sched_switch: prev_comm=swapper 
prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=bash next_pid=31128 
next_prio=120
   sleep-31128 [000] 16490053588518: sched_switch: prev_comm=bash 
prev_pid=31128 prev_prio=120 prev_state=S ==> next_comm=swapper next_pid=0 
next_prio=120
  ...
echo 1 > options/latency-format
$ cat trace
  -0   0 91557653238+: sched_switch: prev_comm=swapper prev_pid=0 
prev_prio=120 prev_state=R ==> next_comm=bash next_pid=31128 next_prio=120
   sleep-31128   0 91557843399+: sched_switch: prev_comm=bash prev_pid=31128 
prev_prio=120 prev_state=S ==> next_comm=swapper next_pid=0 next_prio=120
  ...

v2:
Move arch-specific bits out of generic code.
v4:
Fix x86_32 build due to 64-bit division.

Google-Bug-Id: 6980623
Signed-off-by: David Sharp 
Cc: Steven Rostedt 
Cc: Masami Hiramatsu 
---
 arch/x86/include/asm/trace_clock.h |2 +-
 include/linux/ftrace_event.h   |6 +++
 kernel/trace/trace.c   |   15 +-
 kernel/trace/trace.h   |4 --
 kernel/trace/trace_output.c|   81 +---
 5 files changed, 75 insertions(+), 33 deletions(-)

diff --git a/arch/x86/include/asm/trace_clock.h 
b/arch/x86/include/asm/trace_clock.h
index 7ee0d8c..45e17f5 100644
--- a/arch/x86/include/asm/trace_clock.h
+++ b/arch/x86/include/asm/trace_clock.h
@@ -9,7 +9,7 @@
 extern u64 notrace trace_clock_x86_tsc(void);
 
 # define ARCH_TRACE_CLOCKS \
-   { trace_clock_x86_tsc,  "x86-tsc" },
+   { trace_clock_x86_tsc,  "x86-tsc",  .in_ns = 0 },
 
 #endif
 
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 642928c..c760670 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -86,6 +86,12 @@ struct trace_iterator {
cpumask_var_t   started;
 };
 
+enum trace_iter_flags {
+   TRACE_FILE_LAT_FMT  = 1,
+   TRACE_FILE_ANNOTATE = 2,
+   TRACE_FILE_TIME_IN_NS   = 4,
+};
+
 
 struct trace_event;
 
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 4e26df3..cff3427 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -476,10 +476,11 @@ static const char *trace_options[] = {
 static struct {
u64 (*func)(void);
const char *name;
+   int in_ns;  /* is this clock in nanoseconds? */
 } trace_clocks[] = {
-   { trace_clock_local,"local" },
-   { trace_clock_global,   "global" },
-   { trace_clock_counter,  "counter" },
+   { trace_clock_local,"local",1 },
+   { trace_clock_global,   "global",   1 },
+   { trace_clock_counter,  "counter",  0 },
ARCH_TRACE_CLOCKS
 };
 
@@ -2425,6 +2426,10 @@ __tracing_open(struct inode *inode, struct file *file)
if (ring_buffer_overruns(iter->tr->buffer))
iter->iter_flags |= TRACE_FILE_ANNOTATE;
 
+   /* Output in nanoseconds only if we are using a clock in nanoseconds. */
+   if (trace_clocks[trace_clock_id].in_ns)
+   iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
+
/* stop the trace while dumping */
tracing_stop();
 
@@ -3324,6 +3329,10 @@ static int tracing_open_pipe(struct inode *inode, struct 
file *filp)
if (trace_flags & TRACE_ITER_LATENCY_FMT)
iter->iter_flags |= TRACE_FILE_LAT_FMT;
 
+   /* Output in nanoseconds only if we are using a clock in nanoseconds. */
+   if (trace_clocks[trace_clock_id].in_ns)
+   iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
+
iter->cpu_file = cpu_file;
iter->tr = _trace;
mutex_init(>mutex);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 55e1f7f..84fefed 100644
--- a/kernel/trace/trace.h
+++ 

[PATCH v5 2/3] tracing: Reset ring buffer when changing trace_clocks

2012-10-01 Thread David Sharp
Because the "tsc" clock isn't in nanoseconds, the ring buffer must be
reset when changing clocks so that incomparable timestamps don't end up
in the same trace.

Tested: Confirmed switching clocks resets the trace buffer.

Google-Bug-Id: 6980623
Signed-off-by: David Sharp 
Cc: Steven Rostedt 
Cc: Masami Hiramatsu 
---
 kernel/trace/trace.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 92fb08e..4e26df3 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4012,6 +4012,14 @@ static ssize_t tracing_clock_write(struct file *filp, 
const char __user *ubuf,
if (max_tr.buffer)
ring_buffer_set_clock(max_tr.buffer, trace_clocks[i].func);
 
+   /*
+* New clock may not be consistent with the previous clock.
+* Reset the buffer so that it doesn't have incomparable timestamps.
+*/
+   tracing_reset_online_cpus(_trace);
+   if (max_tr.buffer)
+   tracing_reset_online_cpus(_tr);
+
mutex_unlock(_types_lock);
 
*fpos += cnt;
-- 
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/3] tracing,x86: Add a TSC trace_clock

2012-10-01 Thread David Sharp
In order to promote interoperability between userspace tracers and ftrace,
add a trace_clock that reports raw TSC values which will then be recorded
in the ring buffer. Userspace tracers that also record TSCs are then on
exactly the same time base as the kernel and events can be unambiguously
interlaced.

Tested: Enabled a tracepoint and the "tsc" trace_clock and saw very large
timestamp values.

v2:
Move arch-specific bits out of generic code.
v3:
Rename "x86-tsc", cleanups

Google-Bug-Id: 6980623
Signed-off-by: David Sharp 
Cc: Steven Rostedt 
Cc: Masami Hiramatsu 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: "H. Peter Anvin" 
Acked-by: Ingo Molnar 
---
 arch/alpha/include/asm/trace_clock.h  |6 ++
 arch/arm/include/asm/trace_clock.h|6 ++
 arch/avr32/include/asm/trace_clock.h  |6 ++
 arch/blackfin/include/asm/trace_clock.h   |6 ++
 arch/c6x/include/asm/trace_clock.h|6 ++
 arch/cris/include/asm/trace_clock.h   |6 ++
 arch/frv/include/asm/trace_clock.h|6 ++
 arch/h8300/include/asm/trace_clock.h  |6 ++
 arch/hexagon/include/asm/trace_clock.h|6 ++
 arch/ia64/include/asm/trace_clock.h   |6 ++
 arch/m32r/include/asm/trace_clock.h   |6 ++
 arch/m68k/include/asm/trace_clock.h   |6 ++
 arch/microblaze/include/asm/trace_clock.h |6 ++
 arch/mips/include/asm/trace_clock.h   |6 ++
 arch/mn10300/include/asm/trace_clock.h|6 ++
 arch/openrisc/include/asm/trace_clock.h   |6 ++
 arch/parisc/include/asm/trace_clock.h |6 ++
 arch/powerpc/include/asm/trace_clock.h|6 ++
 arch/s390/include/asm/trace_clock.h   |6 ++
 arch/score/include/asm/trace_clock.h  |6 ++
 arch/sh/include/asm/trace_clock.h |6 ++
 arch/sparc/include/asm/trace_clock.h  |6 ++
 arch/tile/include/asm/trace_clock.h   |6 ++
 arch/um/include/asm/trace_clock.h |6 ++
 arch/unicore32/include/asm/trace_clock.h  |6 ++
 arch/x86/include/asm/trace_clock.h|   16 
 arch/x86/kernel/Makefile  |1 +
 arch/x86/kernel/trace_clock.c |   21 +
 arch/xtensa/include/asm/trace_clock.h |6 ++
 include/asm-generic/trace_clock.h |   16 
 include/linux/trace_clock.h   |2 ++
 kernel/trace/trace.c  |1 +
 32 files changed, 213 insertions(+), 0 deletions(-)
 create mode 100644 arch/alpha/include/asm/trace_clock.h
 create mode 100644 arch/arm/include/asm/trace_clock.h
 create mode 100644 arch/avr32/include/asm/trace_clock.h
 create mode 100644 arch/blackfin/include/asm/trace_clock.h
 create mode 100644 arch/c6x/include/asm/trace_clock.h
 create mode 100644 arch/cris/include/asm/trace_clock.h
 create mode 100644 arch/frv/include/asm/trace_clock.h
 create mode 100644 arch/h8300/include/asm/trace_clock.h
 create mode 100644 arch/hexagon/include/asm/trace_clock.h
 create mode 100644 arch/ia64/include/asm/trace_clock.h
 create mode 100644 arch/m32r/include/asm/trace_clock.h
 create mode 100644 arch/m68k/include/asm/trace_clock.h
 create mode 100644 arch/microblaze/include/asm/trace_clock.h
 create mode 100644 arch/mips/include/asm/trace_clock.h
 create mode 100644 arch/mn10300/include/asm/trace_clock.h
 create mode 100644 arch/openrisc/include/asm/trace_clock.h
 create mode 100644 arch/parisc/include/asm/trace_clock.h
 create mode 100644 arch/powerpc/include/asm/trace_clock.h
 create mode 100644 arch/s390/include/asm/trace_clock.h
 create mode 100644 arch/score/include/asm/trace_clock.h
 create mode 100644 arch/sh/include/asm/trace_clock.h
 create mode 100644 arch/sparc/include/asm/trace_clock.h
 create mode 100644 arch/tile/include/asm/trace_clock.h
 create mode 100644 arch/um/include/asm/trace_clock.h
 create mode 100644 arch/unicore32/include/asm/trace_clock.h
 create mode 100644 arch/x86/include/asm/trace_clock.h
 create mode 100644 arch/x86/kernel/trace_clock.c
 create mode 100644 arch/xtensa/include/asm/trace_clock.h
 create mode 100644 include/asm-generic/trace_clock.h

diff --git a/arch/alpha/include/asm/trace_clock.h 
b/arch/alpha/include/asm/trace_clock.h
new file mode 100644
index 000..f35fab8
--- /dev/null
+++ b/arch/alpha/include/asm/trace_clock.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_TRACE_CLOCK_H
+#define _ASM_TRACE_CLOCK_H
+
+#include 
+
+#endif
diff --git a/arch/arm/include/asm/trace_clock.h 
b/arch/arm/include/asm/trace_clock.h
new file mode 100644
index 000..f35fab8
--- /dev/null
+++ b/arch/arm/include/asm/trace_clock.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_TRACE_CLOCK_H
+#define _ASM_TRACE_CLOCK_H
+
+#include 
+
+#endif
diff --git a/arch/avr32/include/asm/trace_clock.h 
b/arch/avr32/include/asm/trace_clock.h
new file mode 100644
index 000..f35fab8
--- /dev/null
+++ b/arch/avr32/include/asm/trace_clock.h
@@ -0,0 +1,6 @@
+#ifndef 

Re: [PATCH v2 2/2] hwmon: (ads7828) add support for ADS7830

2012-10-01 Thread Vivien Didelot
Hi Guenter,

On Mon, 2012-10-01 at 18:20 -0700, Guenter Roeck wrote:
> On Mon, Oct 01, 2012 at 07:16:24PM -0400, Vivien Didelot wrote:
> > From: Guillaume Roguez 
> > 
> > The ADS7830 device is almost the same as the ADS7828,
> > except that it does 8-bit sampling, instead of 12-bit.
> > This patch extends the ads7828 driver to support this chip.
> > 
> > Signed-off-by: Guillaume Roguez 
> > Signed-off-by: Vivien Didelot 
> 
> Hi Guillaume,
> Hi Vivien,
> 
> couple of comments below.
> 
> > ---
> >  Documentation/hwmon/ads7828 | 12 --
> >  drivers/hwmon/Kconfig   |  7 +++---
> >  drivers/hwmon/ads7828.c | 58 
> > -
> >  3 files changed, 55 insertions(+), 22 deletions(-)
> > 
> > diff --git a/Documentation/hwmon/ads7828 b/Documentation/hwmon/ads7828
> > index 2bbebe6..4366a87 100644
> > --- a/Documentation/hwmon/ads7828
> > +++ b/Documentation/hwmon/ads7828
> > @@ -8,8 +8,15 @@ Supported chips:
> >  Datasheet: Publicly available at the Texas Instruments website :
> > http://focus.ti.com/lit/ds/symlink/ads7828.pdf
> >  
> > +  * Texas Instruments ADS7830
> > +Prefix: 'ads7830'
> > +Addresses scanned: I2C 0x48, 0x49, 0x4a, 0x4b
> > +Datasheet: Publicly available at the Texas Instruments website:
> > +   http://focus.ti.com/lit/ds/symlink/ads7830.pdf
> > +
> >  Authors:
> >  Steve Hardy 
> > +Guillaume Roguez 
> >  
> >  Module Parameters
> >  -
> > @@ -24,9 +31,10 @@ Module Parameters
> >  Description
> >  ---
> >  
> > -This driver implements support for the Texas Instruments ADS7828.
> > +This driver implements support for the Texas Instruments ADS7828, and 
> > ADS7830.
> >  
> 
> s/,//
Sounds like an abuse of the serial comma :-)
> 
> > -This device is a 12-bit 8-channel A-D converter.
> > +The ADS7828 device is a 12-bit 8-channel A/D converter, while the ADS7830 
> > does
> > +8-bit sampling.
> >  
> >  It can operate in single ended mode (8 +ve inputs) or in differential mode,
> >  where 4 differential pairs can be measured.
> > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> > index 83e3e9d..960c8c5 100644
> > --- a/drivers/hwmon/Kconfig
> > +++ b/drivers/hwmon/Kconfig
> > @@ -1060,11 +1060,12 @@ config SENSORS_ADS1015
> >   will be called ads1015.
> >  
> >  config SENSORS_ADS7828
> > -   tristate "Texas Instruments ADS7828"
> > +   tristate "Texas Instruments ADS7828 and compatibles"
> > depends on I2C
> > help
> > - If you say yes here you get support for Texas Instruments ADS7828
> > - 12-bit 8-channel ADC device.
> > + If you say yes here you get support for Texas Instruments ADS7828 and
> > + ADS7830 8-channel A/D converters. ADS7828 resolution is 12-bit, while
> > + it is 8-bit on ADS7830.
> >  
> >   This driver can also be built as a module.  If so, the module
> >   will be called ads7828.
> > diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
> > index fb3010d..91fc629 100644
> > --- a/drivers/hwmon/ads7828.c
> > +++ b/drivers/hwmon/ads7828.c
> > @@ -1,11 +1,13 @@
> >  /*
> > - * ads7828.c - lm_sensors driver for ads7828 12-bit 8-channel ADC
> > + * ads7828.c - driver for TI ADS7828 8-channel A/D converter and 
> > compatibles
> >   * (C) 2007 EADS Astrium
> >   *
> >   * This driver is based on the lm75 and other lm_sensors/hwmon drivers
> >   *
> >   * Written by Steve Hardy 
> >   *
> > + * ADS7830 support by Guillaume Roguez 
> > 
> > + *
> >   * For further information, see the Documentation/hwmon/ads7828 file.
> >   *
> >   * This program is free software; you can redistribute it and/or modify
> > @@ -41,6 +43,9 @@
> >  #define ADS7828_CMD_PD30x0C/* Internal ref ON && A/D ON */
> >  #define ADS7828_INT_VREF_MV2500/* Internal vref is 2.5V, 
> > 2500mV */
> >  
> > +/* List of supported devices */
> > +enum ads7828_chips { ads7828, ads7830 };
> > +
> >  /* Addresses to scan */
> >  static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
> > I2C_CLIENT_END };
> > @@ -53,9 +58,7 @@ module_param(se_input, bool, S_IRUGO);
> >  module_param(int_vref, bool, S_IRUGO);
> >  module_param(vref_mv, int, S_IRUGO);
> >  
> > -/* Global Variables */
> >  static u8 ads7828_cmd_byte; /* cmd byte without channel bits */
> 
> At some point we may have to look into the configuration ... using module
> parameters doesn't seem to be right here. Should be platform data or device
> tree. But that is for later ... just something to keep in mind.
> 
> > -static unsigned int ads7828_lsb_resol; /* resolution of the ADC sample lsb 
> > */
> >  
> >  /**
> >   * struct ads7828_data - client specific data
> > @@ -64,6 +67,8 @@ static unsigned int ads7828_lsb_resol; /* resolution of 
> > the ADC sample lsb */
> >   * @valid: Validity flag.
> >   * @last_updated:  Last updated time (in jiffies).
> >   * @adc_input: ADS7828_NCH samples.
> > + * 

Re: [PATCH v2] slab: Ignore internal flags in cache creation

2012-10-01 Thread David Rientjes
On Mon, 1 Oct 2012, Glauber Costa wrote:

> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 9c21725..f2682ee 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -107,6 +107,15 @@ struct kmem_cache *kmem_cache_create(const char *name, 
> size_t size, size_t align
>   if (!kmem_cache_sanity_check(name, size) == 0)
>   goto out_locked;
>  
> + /*
> +  * Some allocators will constraint the set of valid flags to a subset
> +  * of all flags. We expect them to define CACHE_CREATE_MASK in this
> +  * case, and we'll just provide them with a sanitized version of the
> +  * passed flags.
> +  */
> +#ifdef CACHE_CREATE_MASK
> + flags &= ~CACHE_CREATE_MASK;
> +#endif
>  
>   s = __kmem_cache_alias(name, size, align, flags, ctor);
>   if (s)

flags &= CACHE_CREATE_MASK

After that's done:

Acked-by: David Rientjes 

Thanks for working through this.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 -tip 5/5] AHCI: Support multiple MSIs

2012-10-01 Thread Jeff Garzik

On 10/01/2012 04:13 AM, Alexander Gordeev wrote:

Take advantage of multiple MSIs implementation on x86 - on systems with
IRQ remapping AHCI ports not only get assigned separate MSI vectors -
but also separate IRQs. As result, interrupts generated by different
ports could be serviced on different CPUs rather than on a single one.

In cases when number of allocated MSIs is less than requested the Sharing
Last MSI mode does not get used, no matter implemented in hardware or not.
Instead, the driver assumes the advantage of multiple MSIs is negated and
falls back to the single MSI mode as if MRSM bit was set (some Intel chips
implement this strategy anyway - MRSM bit gets set even if the number of
allocated MSIs exceeds the number of implemented ports).

Signed-off-by: Alexander Gordeev 
---
  drivers/ata/ahci.c|   91 --
  drivers/ata/ahci.h|6 +++
  drivers/ata/libahci.c |  118 ++---
  3 files changed, 205 insertions(+), 10 deletions(-)


Acked-by: Jeff Garzik 

Normally, this amount of changes would -really- need to go through the 
libata tree.  However, given the amount of dependencies, it either needs 
a merge tree or to go through the PCI tree...?


Any maintainer comments on disposition?

Jeff




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL 0/12] ARM: soc: updates for 3.7, first batch

2012-10-01 Thread Tony Lindgren
* Olof Johansson  [121001 19:36]:
> On Mon, Oct 01, 2012 at 07:22:34PM -0700, Linus Torvalds wrote:
> 
> > Anyway, you should double-check the merges, the "soc.h" one in
> > particular is suspect.
> 
> Yes, my bad for not remembering to move the tag forward. The patch is below.

Thanks, the current head is building just fine for omaps
with that fix.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/2] hwmon: (ads7828) driver cleanup

2012-10-01 Thread Guenter Roeck
On Mon, Oct 01, 2012 at 10:16:07PM -0400, Vivien Didelot wrote:
> Hi Guenter,
> 
[ ... ]
> > >  
> > > -/* Each client has this additional data */
> > > +/**
> > > + * struct ads7828_data - client specific data
> > > + * @hwmon_dev:   The hwmon device.
> > > + * @update_lock: Mutex protecting updates.
> > > + * @valid:   Validity flag.
> > > + * @last_updated:Last updated time (in jiffies).
> > > + * @adc_input:   ADS7828_NCH samples.
> > > + */
> > This isn't really an externally visible API, so I wonder if it provides 
> > value to
> > document it this way. No strong opinion, just wondering.
> I found the version below a bit cluttered, that's why I used the
> KernelDoc notation. Would you prefer something else, like right-aligned
> comments?

Tab aligned, maybe ? Not sure if that works out, though.

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [ 094/127] md: make sure metadata is updated when spares are activated or removed.

2012-10-01 Thread NeilBrown
On Fri, 28 Sep 2012 16:57:45 -0700 Greg Kroah-Hartman
 wrote:

> On Sat, Sep 29, 2012 at 12:51:04AM +0200, Ben Hutchings wrote:
> > On Fri, 2012-09-28 at 13:34 -0700, Greg Kroah-Hartman wrote:
> > > 3.0-stable review patch.  If anyone has any objections, please let me 
> > > know.
> > > 
> > > --
> > > 
> > > From: NeilBrown 
> > > 
> > > commit 6dafab6b1383e912cd252fa809570b484eb6e0dc upstream.
> > [...]
> > > This is suitable for -stable as out-of-data metadata could lead
> > > to data corruption.
> > > This is only relevant for 3.3 and later 9when 'replacement' as
> > > introduced.
> > [...]
> > 
> > Assuming Neil hasn't changed his mind about this, it should therefore
> > not be applied to 3.0.
> 
> Neil, is this true?
> 
> greg k-h

Yes it is true - my bad.

I should have realised that when you pointed out that the backport wasn't
clean.
The patch won't hurt 3.0, but it isn't necessary at all, so best leave it out.

Thanks,
NeilBrown



signature.asc
Description: PGP signature


[PATCH] net: ethernet: davinci_cpdma: decrease the desc count when cleaning up the remaining packets

2012-10-01 Thread Tao Hou
chan->count is used by rx channel. If the desc count is not updated by
the clean up loop in cpdma_chan_stop, the value written to the rxfree
register in cpdma_chan_start will be incorrect.

Signed-off-by: Tao Hou 
---
 drivers/net/ethernet/ti/davinci_cpdma.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c 
b/drivers/net/ethernet/ti/davinci_cpdma.c
index d15c888..4995673 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -863,6 +863,7 @@ int cpdma_chan_stop(struct cpdma_chan *chan)
 
next_dma = desc_read(desc, hw_next);
chan->head = desc_from_phys(pool, next_dma);
+   chan->count--;
chan->stats.teardown_dequeue++;
 
/* issue callback without locks held */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL 0/12] ARM: soc: updates for 3.7, first batch

2012-10-01 Thread Olof Johansson
On Mon, Oct 01, 2012 at 07:26:26PM -0700, Linus Torvalds wrote:
> On Mon, Oct 1, 2012 at 7:22 PM, Linus Torvalds
>  wrote:
> >
> > Ok, I've merged them all. As usual, my end result is slightly
> > different from yours, although the differences are pretty small.
> 
> Oh, one more thing: I suspect the OMAP_OCP2SCP config option should
> depend on CONFIG_ARM or something. Just based on the name, I assume it
> doesn't actually work on x86-64, but I see the question..

Ah, yes. It should build fine and not cause breakage, but it's largely
pointless to offer the option. Patch below.


-Olof


>From 5ae0b658cc10af29d7a0a66f2a412a754011ca0e Mon Sep 17 00:00:00 2001
From: Olof Johansson 
Date: Mon, 1 Oct 2012 19:39:33 -0700
Subject: [PATCH] drivers/bus: make ocp2scp depend on OMAP2+

No use in enabling the driver on platforms where it won't be useful.

Signed-off-by: Olof Johansson 
Cc: Tony Lindgren 
---
 drivers/bus/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
index bbec35d..0f51ed6 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -6,6 +6,7 @@ menu "Bus devices"
 
 config OMAP_OCP2SCP
tristate "OMAP OCP2SCP DRIVER"
+   depends on ARCH_OMAP2PLUS
help
  Driver to enable ocp2scp module which transforms ocp interface
  protocol to scp protocol. In OMAP4, USB PHY is connected via
-- 
1.7.10.1.488.g05fbf7a

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL 0/12] ARM: soc: updates for 3.7, first batch

2012-10-01 Thread Linus Torvalds
On Mon, Oct 1, 2012 at 7:22 PM, Linus Torvalds
 wrote:
>
> Ok, I've merged them all. As usual, my end result is slightly
> different from yours, although the differences are pretty small.

Oh, one more thing: I suspect the OMAP_OCP2SCP config option should
depend on CONFIG_ARM or something. Just based on the name, I assume it
doesn't actually work on x86-64, but I see the question..

   Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL 0/12] ARM: soc: updates for 3.7, first batch

2012-10-01 Thread Olof Johansson
Hi,

On Mon, Oct 01, 2012 at 07:22:34PM -0700, Linus Torvalds wrote:
> On Mon, Oct 1, 2012 at 4:56 PM, Olof Johansson  wrote:
> >
> > Here is the first batch of pull requests for arm-soc for this merge
> > window. Some of them are tiny, and we will probably start to combine
> > them into slightly larger misc branches in the future. I didn't do it
> > this time around since the dependencies between branches ended up quite
> > complex this time around.
> 
> Ok, I've merged them all. As usual, my end result is slightly
> different from yours, although the differences are pretty small.

Thanks!

>  - I added exynos4210-trats.dtb to the "dtb-$(CONFIG_ARCH_EXYNOS)"
> case in arch/arm/boot/dts/Makefile
>
>That seemed to be the right thing, otherwise that dtb file isn't
> actually accessed from anything. Hmm?

Hmm. I know I did that edit. I've had cases where git rerere has forgotten
about edits to "new" files that were not part of the original conflict, and
I might have replayed that merge and lost it there. Thanks for catching it.

>  - Commit dbc04161048d ("ARM: OMAP: Split plat/hardware.h, use local
> soc.h for omap2+") added the line
> 
> #include "soc.h"
> 
>to arch/arm/mach-omap2/omap_l3_noc.c, and I left it in as it moved
> into drivers/bus/.
> 
>My resolution is quite possibly wrong, but I didn't know what the
> right thing to do was. Please double-check.

I had a patch for this but I forgot to move the tag to include it, my local
branch with the resolutions has it since I used the branch head, not the tag,
to merge it.

The SHA is a55eb3ec0e38e2db17207b204c050fbcdf750abb. Or the patch is included
below if that's easier.

>  - non-semantic order/whitespace difference for
> CONFIG_CLKSRC_ARM_GENERIC in drivers/clocksource/Makefile.
>
>I didn't want to mix the generic case up with the random cases.

Yes, makes sense, thanks. I wonder if the file should be sorted to reduce
conflicts on new additions soon anyway, maybe.

> Anyway, you should double-check the merges, the "soc.h" one in
> particular is suspect.

Yes, my bad for not remembering to move the tag forward. The patch is below.

Thanks!

-Olof


>From a55eb3ec0e38e2db17207b204c050fbcdf750abb Mon Sep 17 00:00:00 2001
From: Olof Johansson 
Date: Thu, 20 Sep 2012 16:14:25 -0700
Subject: [PATCH] drivers: bus: omap_l3: fixup merge conflict resolution

This fixes a local merge conflict resolution done wrong locally in
arm-soc for-next. soc.h was added on a cleanup branch, but the driver
was moved and the header no longer needed.

Signed-off-by: Olof Johansson 
---
 arch/arm/mach-omap2/omap_l3_noc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/mach-omap2/omap_l3_noc.c 
b/arch/arm/mach-omap2/omap_l3_noc.c
index f447e02..4f8f3cf 100644
--- a/arch/arm/mach-omap2/omap_l3_noc.c
+++ b/arch/arm/mach-omap2/omap_l3_noc.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 
-#include "soc.h"
 #include "omap_l3_noc.h"
 
 /*
-- 
1.7.10.1.488.g05fbf7a

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/4] mfd: 88pm860x: use irqdomain

2012-10-01 Thread Haojian Zhuang
On Sat, Sep 29, 2012 at 7:28 AM, Samuel Ortiz  wrote:
> Hi Haojian:
>
> On Fri, Sep 21, 2012 at 06:06:51PM +0800, Haojian Zhuang wrote:
>> @@ -593,13 +610,9 @@ static int __devinit device_irq_init(struct pm860x_chip 
>> *chip,
>>   : chip->companion;
>>   unsigned char status_buf[INT_STATUS_NUM];
>>   unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
>> - int i, data, mask, ret = -EINVAL;
> That one breaks the build:
>
> drivers/mfd/88pm860x-core.c: In function ‘device_irq_init’:
> drivers/mfd/88pm860x-core.c:628:7: error: ‘i’ undeclared (first use in this
> function)
> drivers/mfd/88pm860x-core.c:628:7: note: each undeclared identifier is
> reported only once for each function it appears in
> drivers/mfd/88pm860x-core.c:629:3: error: ‘__irq’ undeclared (first use in
> this function)
> make[2]: *** [drivers/mfd/88pm860x-core.o] Error 1
>
> I removed this patchset until it builds...
>
I'm sorry for inconvenience. Now fix it.

Regards
Haojian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL 0/12] ARM: soc: updates for 3.7, first batch

2012-10-01 Thread Linus Torvalds
On Mon, Oct 1, 2012 at 4:56 PM, Olof Johansson  wrote:
>
> Here is the first batch of pull requests for arm-soc for this merge
> window. Some of them are tiny, and we will probably start to combine
> them into slightly larger misc branches in the future. I didn't do it
> this time around since the dependencies between branches ended up quite
> complex this time around.

Ok, I've merged them all. As usual, my end result is slightly
different from yours, although the differences are pretty small.

 - I added exynos4210-trats.dtb to the "dtb-$(CONFIG_ARCH_EXYNOS)"
case in arch/arm/boot/dts/Makefile

   That seemed to be the right thing, otherwise that dtb file isn't
actually accessed from anything. Hmm?

 - Commit dbc04161048d ("ARM: OMAP: Split plat/hardware.h, use local
soc.h for omap2+") added the line

#include "soc.h"

   to arch/arm/mach-omap2/omap_l3_noc.c, and I left it in as it moved
into drivers/bus/.

   My resolution is quite possibly wrong, but I didn't know what the
right thing to do was. Please double-check.

 - non-semantic order/whitespace difference for
CONFIG_CLKSRC_ARM_GENERIC in drivers/clocksource/Makefile.

   I didn't want to mix the generic case up with the random cases.

Anyway, you should double-check the merges, the "soc.h" one in
particular is suspect.

  Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mfd: 88pm860x: use irqdomain

2012-10-01 Thread Haojian Zhuang
Use irqdomain and allocating interrupts. It's necessary for supporting
DT mode.

Signed-off-by: Haojian Zhuang 
---
 drivers/mfd/88pm860x-core.c |   65 +--
 1 file changed, 38 insertions(+), 27 deletions(-)

diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index 72bf290..5b56fe8 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -520,15 +521,12 @@ static void pm860x_irq_sync_unlock(struct irq_data *data)
 
 static void pm860x_irq_enable(struct irq_data *data)
 {
-   struct pm860x_chip *chip = irq_data_get_irq_chip_data(data);
-   pm860x_irqs[data->irq - chip->irq_base].enable
-   = pm860x_irqs[data->irq - chip->irq_base].offs;
+   pm860x_irqs[data->hwirq].enable = pm860x_irqs[data->hwirq].offs;
 }
 
 static void pm860x_irq_disable(struct irq_data *data)
 {
-   struct pm860x_chip *chip = irq_data_get_irq_chip_data(data);
-   pm860x_irqs[data->irq - chip->irq_base].enable = 0;
+   pm860x_irqs[data->hwirq].enable = 0;
 }
 
 static struct irq_chip pm860x_irq_chip = {
@@ -539,6 +537,25 @@ static struct irq_chip pm860x_irq_chip = {
.irq_disable= pm860x_irq_disable,
 };
 
+static int pm860x_irq_domain_map(struct irq_domain *d, unsigned int virq,
+irq_hw_number_t hw)
+{
+   irq_set_chip_data(virq, d->host_data);
+   irq_set_chip_and_handler(virq, _irq_chip, handle_edge_irq);
+   irq_set_nested_thread(virq, 1);
+#ifdef CONFIG_ARM
+   set_irq_flags(virq, IRQF_VALID);
+#else
+   irq_set_noprobe(virq);
+#endif
+   return 0;
+}
+
+static struct irq_domain_ops pm860x_irq_domain_ops = {
+   .map= pm860x_irq_domain_map,
+   .xlate  = irq_domain_xlate_onetwocell,
+};
+
 static int __devinit device_gpadc_init(struct pm860x_chip *chip,
   struct pm860x_platform_data *pdata)
 {
@@ -593,13 +610,9 @@ static int __devinit device_irq_init(struct pm860x_chip 
*chip,
: chip->companion;
unsigned char status_buf[INT_STATUS_NUM];
unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
-   int i, data, mask, ret = -EINVAL;
-   int __irq;
-
-   if (!pdata || !pdata->irq_base) {
-   dev_warn(chip->dev, "No interrupt support on IRQ base\n");
-   return -EINVAL;
-   }
+   int data, mask, ret = -EINVAL;
+   int nr_irqs, irq_base = -1;
+   struct device_node *node = i2c->dev.of_node;
 
mask = PM8607_B0_MISC1_INV_INT | PM8607_B0_MISC1_INT_CLEAR
| PM8607_B0_MISC1_INT_MASK;
@@ -639,25 +652,23 @@ static int __devinit device_irq_init(struct pm860x_chip 
*chip,
goto out;
 
mutex_init(>irq_lock);
-   chip->irq_base = pdata->irq_base;
+
+   if (pdata && pdata->irq_base)
+   irq_base = pdata->irq_base;
+   nr_irqs = ARRAY_SIZE(pm860x_irqs);
+   chip->irq_base = irq_alloc_descs(irq_base, 0, nr_irqs, 0);
+   if (chip->irq_base < 0) {
+   dev_err(>dev, "Failed to allocate interrupts, ret:%d\n",
+   chip->irq_base);
+   ret = -EBUSY;
+   goto out;
+   }
+   irq_domain_add_legacy(node, nr_irqs, chip->irq_base, 0,
+ _irq_domain_ops, chip);
chip->core_irq = i2c->irq;
if (!chip->core_irq)
goto out;
 
-   /* register IRQ by genirq */
-   for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) {
-   __irq = i + chip->irq_base;
-   irq_set_chip_data(__irq, chip);
-   irq_set_chip_and_handler(__irq, _irq_chip,
-handle_edge_irq);
-   irq_set_nested_thread(__irq, 1);
-#ifdef CONFIG_ARM
-   set_irq_flags(__irq, IRQF_VALID);
-#else
-   irq_set_noprobe(__irq);
-#endif
-   }
-
ret = request_threaded_irq(chip->core_irq, NULL, pm860x_irq, flags | 
IRQF_ONESHOT,
   "88pm860x", chip);
if (ret) {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/2] hwmon: (ads7828) driver cleanup

2012-10-01 Thread Vivien Didelot
Hi Guenter,

On Mon, 2012-10-01 at 18:07 -0700, Guenter Roeck wrote:
> On Mon, Oct 01, 2012 at 07:16:23PM -0400, Vivien Didelot wrote:
> > * Remove unused macros;
> > * Point to the documentation;
> > * Coding Style fixes (Kernel Doc, spacing);
> > * Move driver declaration to avoid adding function prototypes.
> > 
> > Signed-off-by: Vivien Didelot 
> 
> Hi Vivien,
> 
> > ---
> >  drivers/hwmon/ads7828.c | 91 
> > +++--
> >  1 file changed, 43 insertions(+), 48 deletions(-)
> > 
> > diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
> > index bf3fdf4..fb3010d 100644
> > --- a/drivers/hwmon/ads7828.c
> > +++ b/drivers/hwmon/ads7828.c
> > @@ -6,7 +6,7 @@
> >   *
> >   * Written by Steve Hardy 
> >   *
> > - * Datasheet available at: http://focus.ti.com/lit/ds/symlink/ads7828.pdf
> > + * For further information, see the Documentation/hwmon/ads7828 file.
> >   *
> >   * This program is free software; you can redistribute it and/or modify
> >   * it under the terms of the GNU General Public License as published by
> > @@ -34,14 +34,12 @@
> >  #include 
> >  
> >  /* The ADS7828 registers */
> > -#define ADS7828_NCH 8 /* 8 channels of 12-bit A-D supported */
> > -#define ADS7828_CMD_SD_SE 0x80 /* Single ended inputs */
> > -#define ADS7828_CMD_SD_DIFF 0x00 /* Differential inputs */
> > -#define ADS7828_CMD_PD0 0x0 /* Power Down between A-D conversions */
> > -#define ADS7828_CMD_PD1 0x04 /* Internal ref OFF && A-D ON */
> > -#define ADS7828_CMD_PD2 0x08 /* Internal ref ON && A-D OFF */
> > -#define ADS7828_CMD_PD3 0x0C /* Internal ref ON && A-D ON */
> > -#define ADS7828_INT_VREF_MV 2500 /* Internal vref is 2.5V, 2500mV */
> > +#define ADS7828_NCH8   /* 8 channels supported */
> > +#define ADS7828_CMD_SD_SE  0x80/* Single ended inputs */
> > +#define ADS7828_CMD_SD_DIFF0x00/* Differential inputs */
> > +#define ADS7828_CMD_PD10x04/* Internal ref OFF && A/D ON */
> > +#define ADS7828_CMD_PD30x0C/* Internal ref ON && A/D ON */
> > +#define ADS7828_INT_VREF_MV2500/* Internal vref is 2.5V, 
> > 2500mV */
> >  
> >  /* Addresses to scan */
> >  static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
> > @@ -59,25 +57,26 @@ module_param(vref_mv, int, S_IRUGO);
> >  static u8 ads7828_cmd_byte; /* cmd byte without channel bits */
> >  static unsigned int ads7828_lsb_resol; /* resolution of the ADC sample lsb 
> > */
> >  
> > -/* Each client has this additional data */
> > +/**
> > + * struct ads7828_data - client specific data
> > + * @hwmon_dev: The hwmon device.
> > + * @update_lock:   Mutex protecting updates.
> > + * @valid: Validity flag.
> > + * @last_updated:  Last updated time (in jiffies).
> > + * @adc_input: ADS7828_NCH samples.
> > + */
> This isn't really an externally visible API, so I wonder if it provides value 
> to
> document it this way. No strong opinion, just wondering.
I found the version below a bit cluttered, that's why I used the
KernelDoc notation. Would you prefer something else, like right-aligned
comments?
> 
> >  struct ads7828_data {
> > struct device *hwmon_dev;
> > -   struct mutex update_lock; /* mutex protect updates */
> > -   char valid; /* !=0 if following fields are valid */
> > -   unsigned long last_updated; /* In jiffies */
> > -   u16 adc_input[ADS7828_NCH]; /* ADS7828_NCH 12-bit samples */
> > +   struct mutex update_lock;
> > +   char valid;
> > +   unsigned long last_updated;
> > +   u16 adc_input[ADS7828_NCH];
> >  };
> >  
> > -/* Function declaration - necessary due to function dependencies */
> > -static int ads7828_detect(struct i2c_client *client,
> > - struct i2c_board_info *info);
> > -static int ads7828_probe(struct i2c_client *client,
> > -const struct i2c_device_id *id);
> > -
> >  static inline u8 channel_cmd_byte(int ch)
> >  {
> > /* cmd byte C2,C1,C0 - see datasheet */
> > -   u8 cmd = (((ch>>1) | (ch&0x01)<<2)<<4);
> > +   u8 cmd = (((ch >> 1) | (ch & 0x01) << 2) << 4);
> > cmd |= ads7828_cmd_byte;
> > return cmd;
> >  }
> > @@ -120,9 +119,8 @@ static ssize_t show_in(struct device *dev, struct 
> > device_attribute *da,
> > ads7828_lsb_resol)/1000);
> 
> Can you fix this one as well since you are at it ? There is another one in 
> sensors_ads7828_init().
> [ Wonder why checkpatch doesn't complain about it ]
Sure.
> 
> >  }
> >  
> > -#define in_reg(offset)\
> > -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in,\
> > -   NULL, offset)
> > +#define in_reg(offset) \
> > +static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, NULL, 
> > offset)
> >  
> This causes a checkpatch error - checkpatch doesn't like the multi-line 
> macros.
My bad, I'm on a 2.6.37 box, I didn't checkout the upstream version of
checkpatch.pl too.
> 
> >  in_reg(0);
> >  in_reg(1);
> 
> Since it seems to be hardly worth 

[PATCHv2] TPM: Issue TPM_STARTUP at driver load if the TPM has not been started

2012-10-01 Thread Jason Gunthorpe
The TPM will respond to TPM_GET_CAP with TPM_ERR_INVALID_POSTINIT if
TPM_STARTUP has not been issued. Detect this and automatically
issue TPM_STARTUP.

This is for embedded applications where the kernel is the first thing
to touch the TPM.

Signed-off-by: Jason Gunthorpe 
---
 drivers/char/tpm/tpm.c |   43 +++
 drivers/char/tpm/tpm.h |6 ++
 2 files changed, 45 insertions(+), 4 deletions(-)

changes in v2: 
 - Created a tpm_startup function as per Kent's comment
 - Fixed the TPM_ST_* constants to be 16 bit
 - Provide ST_STATE and ST_DEACTIVATED constants for future users

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 817f0ee..5d79093 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -473,7 +473,7 @@ static ssize_t transmit_cmd(struct tpm_chip *chip, struct 
tpm_cmd_t *cmd,
return -EFAULT;
 
err = be32_to_cpu(cmd->header.out.return_code);
-   if (err != 0)
+   if (err != 0 && desc)
dev_err(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);
 
return err;
@@ -489,6 +489,16 @@ static const struct tpm_input_header tpm_getcap_header = {
.ordinal = TPM_ORD_GET_CAP
 };
 
+#define TPM_ORD_STARTUP cpu_to_be32(153)
+#define TPM_ST_CLEAR cpu_to_be16(1)
+#define TPM_ST_STATE cpu_to_be16(2)
+#define TPM_ST_DEACTIVATED cpu_to_be16(3)
+static const struct tpm_input_header tpm_startup_header = {
+   .tag = TPM_TAG_RQU_COMMAND,
+   .length = cpu_to_be32(12),
+   .ordinal = TPM_ORD_STARTUP
+};
+
 ssize_t tpm_getcap(struct device *dev, __be32 subcap_id, cap_t *cap,
   const char *desc)
 {
@@ -532,6 +542,15 @@ void tpm_gen_interrupt(struct tpm_chip *chip)
 }
 EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
 
+static int tpm_startup(struct tpm_chip *chip, __be16 startup_type)
+{
+   struct tpm_cmd_t start_cmd;
+   start_cmd.header.in = tpm_startup_header;
+   start_cmd.params.startup_in.startup_type = startup_type;
+   return transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
+   "attempting to start the TPM");
+}
+
 int tpm_get_timeouts(struct tpm_chip *chip)
 {
struct tpm_cmd_t tpm_cmd;
@@ -545,11 +564,27 @@ int tpm_get_timeouts(struct tpm_chip *chip)
tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
+   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, 0);
 
-   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
-   "attempting to determine the timeouts");
-   if (rc)
+   if (rc == TPM_ERR_INVALID_POSTINIT) {
+   /* The TPM is not started, we are the first to talk to it.
+  Execute a startup command. */
+   dev_info(chip->dev, "Issuing TPM_STARTUP");
+   if (tpm_startup(chip, TPM_ST_CLEAR))
+   return rc;
+
+   tpm_cmd.header.in = tpm_getcap_header;
+   tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
+   tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
+   tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
+   rc = transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE, 0);
+   }
+   if (rc) {
+   dev_err(chip->dev,
+   "A TPM error (%d) occurred attempting to determine the 
timeouts\n",
+   rc);
goto duration;
+   }
 
if (be32_to_cpu(tpm_cmd.header.out.return_code) != 0 ||
be32_to_cpu(tpm_cmd.header.out.length)
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 917f727..2d583ef 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -41,6 +41,7 @@ enum tpm_addr {
 #define TPM_WARN_DOING_SELFTEST 0x802
 #define TPM_ERR_DEACTIVATED 0x6
 #define TPM_ERR_DISABLED0x7
+#define TPM_ERR_INVALID_POSTINIT 38

 #define TPM_HEADER_SIZE10
 extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr,
@@ -269,6 +270,10 @@ struct tpm_pcrextend_in {
u8  hash[TPM_DIGEST_SIZE];
 }__attribute__((packed));
 
+struct tpm_startup_in {
+   __be16  startup_type;
+} __packed;
+
 typedef union {
struct  tpm_getcap_params_out getcap_out;
struct  tpm_readpubek_params_out readpubek_out;
@@ -277,6 +282,7 @@ typedef union {
struct  tpm_pcrread_in  pcrread_in;
struct  tpm_pcrread_out pcrread_out;
struct  tpm_pcrextend_in pcrextend_in;
+   struct tpm_startup_in startup_in;
 } tpm_cmd_params;
 
 struct tpm_cmd_t {
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/7] aoe: update aoe-internal version number to 50

2012-10-01 Thread Ed Cashin
Signed-off-by: Ed Cashin 
---
 drivers/block/aoe/aoe.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index c2bf797..d2ed7f1 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -1,5 +1,5 @@
 /* Copyright (c) 2012 Coraid, Inc.  See COPYING for GPL terms. */
-#define VERSION "49"
+#define VERSION "50"
 #define AOE_MAJOR 152
 #define DEVICE_NAME "aoe"
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/7] aoe: update documentation to better reflect aoe-plus-udev usage

2012-10-01 Thread Ed Cashin
Signed-off-by: Ed Cashin 
---
 Documentation/aoe/aoe.txt|   49 +++--
 Documentation/aoe/mkdevs.sh  |   41 ---
 Documentation/aoe/mkshelf.sh |   28 
 Documentation/aoe/status.sh  |3 ++
 4 files changed, 35 insertions(+), 86 deletions(-)
 delete mode 100644 Documentation/aoe/mkdevs.sh
 delete mode 100644 Documentation/aoe/mkshelf.sh

diff --git a/Documentation/aoe/aoe.txt b/Documentation/aoe/aoe.txt
index b3e4756..bfc9cb1 100644
--- a/Documentation/aoe/aoe.txt
+++ b/Documentation/aoe/aoe.txt
@@ -1,3 +1,8 @@
+ATA over Ethernet is a network protocol that provides simple access to
+block storage on the LAN.
+
+  http://support.coraid.com/documents/AoEr11.txt
+
 The EtherDrive (R) HOWTO for 2.6 and 3.x kernels is found at ...
 
   http://support.coraid.com/support/linux/EtherDrive-2.6-HOWTO.html
@@ -26,20 +31,12 @@ CREATING DEVICE NODES
   There is a udev-install.sh script that shows how to install these
   rules on your system.
 
-  If you are not using udev, two scripts are provided in
-  Documentation/aoe as examples of static device node creation for
-  using the aoe driver.
-
-rm -rf /dev/etherd
-sh Documentation/aoe/mkdevs.sh /dev/etherd
-
-  ... or to make just one shelf's worth of block device nodes ...
-
-sh Documentation/aoe/mkshelf.sh /dev/etherd 0
-
   There is also an autoload script that shows how to edit
   /etc/modprobe.d/aoe.conf to ensure that the aoe module is loaded when
-  necessary.
+  necessary.  Preloading the aoe module is preferable to autoloading,
+  however, because AoE discovery takes a few seconds.  It can be
+  confusing when an AoE device is not present the first time the a
+  command is run but appears a second later.
 
 USING DEVICE NODES
 
@@ -54,9 +51,9 @@ USING DEVICE NODES
   "echo > /dev/etherd/discover" tells the driver to find out what AoE
   devices are available.
 
-  These character devices may disappear and be replaced by sysfs
-  counterparts.  Using the commands in aoetools insulates users from
-  these implementation details.
+  In the future these character devices may disappear and be replaced
+  by sysfs counterparts.  Using the commands in aoetools insulates
+  users from these implementation details.
 
   The block devices are named like this:
 
@@ -79,8 +76,8 @@ USING SYSFS
   The netif attribute is the network interface on the localhost
   through which we are communicating with the remote AoE device.
 
-  There is a script in this directory that formats this information
-  in a convenient way.  Users with aoetools can use the aoe-stat
+  There is a script in this directory that formats this information in
+  a convenient way.  Users with aoetools should use the aoe-stat
   command.
 
   root@makki root# sh Documentation/aoe/status.sh 
@@ -124,3 +121,21 @@ DRIVER OPTIONS
   usage example for the module parameter.
 
 modprobe aoe_iflist="eth1 eth3"
+
+  The aoe_deadsecs module parameter determines the maximum number of
+  seconds that the driver will wait for an AoE device to provide a
+  response to an AoE command.  After aoe_deadsecs seconds have
+  elapsed, the AoE device will be marked as "down".
+
+  The aoe_maxout module parameter has a default of 128.  This is the
+  maximum number of unresponded packets that will be sent to an AoE
+  target at one time.
+
+  The aoe_dyndevs module parameter defaults to 1, meaning that the
+  driver will assign a block device minor number to a discovered AoE
+  target based on the order of its discovery.  With dynamic minor
+  device numbers in use, a greater range of AoE shelf and slot
+  addresses can be supported.  Users with udev will never have to
+  think about minor numbers.  Using aoe_dyndevs=0 allows device nodes
+  to be pre-created using a static minor-number scheme with the
+  aoe-mkshelf script in the aoetools.
diff --git a/Documentation/aoe/mkdevs.sh b/Documentation/aoe/mkdevs.sh
deleted file mode 100644
index 44c0ab7..000
--- a/Documentation/aoe/mkdevs.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-
-n_shelves=${n_shelves:-10}
-n_partitions=${n_partitions:-16}
-
-if test "$#" != "1"; then
-   echo "Usage: sh `basename $0` {dir}" 1>&2
-   echo "   n_partitions=16 sh `basename $0` {dir}" 1>&2
-   exit 1
-fi
-dir=$1
-
-MAJOR=152
-
-echo "Creating AoE devnode files in $dir ..."
-
-set -e
-
-mkdir -p $dir
-
-# (Status info is in sysfs.  See status.sh.)
-# rm -f $dir/stat
-# mknod -m 0400 $dir/stat c $MAJOR 1
-rm -f $dir/err
-mknod -m 0400 $dir/err c $MAJOR 2
-rm -f $dir/discover
-mknod -m 0200 $dir/discover c $MAJOR 3
-rm -f $dir/interfaces
-mknod -m 0200 $dir/interfaces c $MAJOR 4
-rm -f $dir/revalidate
-mknod -m 0200 $dir/revalidate c $MAJOR 5
-rm -f $dir/flush
-mknod -m 0200 $dir/flush c $MAJOR 6
-
-export n_partitions
-mkshelf=`echo $0 | sed 's!mkdevs!mkshelf!'`
-i=0
-while test $i -lt $n_shelves; do
-   sh -xc "sh $mkshelf $dir $i"
-   i=`expr $i + 1`
-done
diff 

RE: [PATCH net,1/3] hyperv: Fix the max_xfer_size in RNDIS initialization

2012-10-01 Thread Haiyang Zhang

> From: David Miller [da...@davemloft.net]
> Sent: Monday, October 01, 2012 6:39 PM
> To: Haiyang Zhang
> Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de; 
> jasow...@redhat.com; linux-kernel@vger.kernel.org; 
> de...@linuxdriverproject.org
> Subject: Re: [PATCH net,1/3] hyperv: Fix the max_xfer_size in RNDIS 
> initialization

> These patches do not apply cleanly to the current net-next tree
> which is the only place where patches should be targetted right
> now.

I will rebase the patch set to the net-next tree soon.

Thanks,
- Haiyang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/7] aoe: remove unused code

2012-10-01 Thread Ed Cashin
Signed-off-by: Ed Cashin 
---
 drivers/block/aoe/aoe.h |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 4ae2468..c2bf797 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -10,9 +10,6 @@
 #define AOE_PARTITIONS (16)
 #endif
 
-#define SYSMINOR(aoemajor, aoeminor) ((aoemajor) * NPERSHELF + (aoeminor))
-#define AOEMAJOR(sysminor) ((sysminor) / NPERSHELF)
-#define AOEMINOR(sysminor) ((sysminor) % NPERSHELF)
 #define WHITESPACE " \t\v\f\n"
 
 enum {
@@ -82,7 +79,6 @@ enum {
 
 enum {
DEFAULTBCNT = 2 * 512,  /* 2 sectors */
-   NPERSHELF = 16, /* number of slots per shelf address */
MIN_BUFS = 16,
NTARGETS = 8,
NAOEIFS = 8,
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/7] aoe: make dynamic block minor numbers the default

2012-10-01 Thread Ed Cashin
Because udev use is so widespread, making the old static mapping
the default is too conservative, given the severe limitations it
places on usable AoE addresses.  Storage virtualization and
larger shelves have made the old limitations too confining.

These changes make the dynamic block device minor numbers the
default, removing the limitations on usable AoE addresses.

The static arrangement is still available with aoe_dyndevs=0, and
the aoe-stat tool from the userland aoetools package, the user
space counterpart to the aoe driver, recognizes the case where
there is a mismatch between the minor number in sysfs and the
minor number in a special device file.

Signed-off-by: Ed Cashin 
---
 drivers/block/aoe/aoedev.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 3d494fd..90e5b53 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -19,7 +19,7 @@ static void aoedev_freedev(struct aoedev *);
 static void freetgt(struct aoedev *d, struct aoetgt *t);
 static void skbpoolfree(struct aoedev *d);
 
-static int aoe_dyndevs;
+static int aoe_dyndevs = 1;
 module_param(aoe_dyndevs, int, 0644);
 MODULE_PARM_DESC(aoe_dyndevs, "Use dynamic minor numbers for devices.");
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/7] aoe: update and specify AoE address guards and error messages

2012-10-01 Thread Ed Cashin
In general, specific is better when it comes to messages about
AoE usage problems.  Also, explicit checks for the AoE broadcast
addresses are added.

Signed-off-by: Ed Cashin 
---
 drivers/block/aoe/aoe.h|2 --
 drivers/block/aoe/aoecmd.c |   17 +++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 7b694f7..4ae2468 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -49,8 +49,6 @@ struct aoe_hdr {
__be32 tag;
 };
 
-#define AOE_MAXSHELF (0x-1)/* one less than the broadcast shelf 
address */
-
 struct aoe_atahdr {
unsigned char aflags;
unsigned char errfeat;
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 94e810c..3804a0a 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -1349,15 +1349,14 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
"Check shelf dip switches.\n");
return;
}
-   if (aoemajor > AOE_MAXSHELF) {
-   pr_info("aoe: e%ld.%d: shelf number too large\n",
+   if (aoemajor == 0x) {
+   pr_info("aoe: e%ld.%d: broadcast shelf number invalid\n",
aoemajor, (int) h->minor);
return;
}
-
-   d = aoedev_by_aoeaddr(aoemajor, h->minor, 1);
-   if (d == NULL) {
-   pr_info("aoe: device allocation failure\n");
+   if (h->minor == 0xff) {
+   pr_info("aoe: e%ld.%d: broadcast slot number invalid\n",
+   aoemajor, (int) h->minor);
return;
}
 
@@ -1365,6 +1364,12 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
if (n > aoe_maxout) /* keep it reasonable */
n = aoe_maxout;
 
+   d = aoedev_by_aoeaddr(aoemajor, h->minor, 1);
+   if (d == NULL) {
+   pr_info("aoe: device allocation failure\n");
+   return;
+   }
+
spin_lock_irqsave(>lock, flags);
 
t = gettgt(d, h->src);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/7] aoe: retain static block device numbers for backwards compatibility

2012-10-01 Thread Ed Cashin
The old mapping between AoE target shelf and slot addresses and
the block device minor number is retained as a
backwards-compatible feature, with a new "aoe_dyndevs" module
parameter available for enabling dynamic block device minor
numbers.

Signed-off-by: Ed Cashin 
---
 drivers/block/aoe/aoedev.c |   54 +--
 1 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 68a7a5a..3d494fd 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "aoe.h"
 
 static void dummy_timer(ulong);
@@ -18,6 +19,10 @@ static void aoedev_freedev(struct aoedev *);
 static void freetgt(struct aoedev *d, struct aoetgt *t);
 static void skbpoolfree(struct aoedev *d);
 
+static int aoe_dyndevs;
+module_param(aoe_dyndevs, int, 0644);
+MODULE_PARM_DESC(aoe_dyndevs, "Use dynamic minor numbers for devices.");
+
 static struct aoedev *devlist;
 static DEFINE_SPINLOCK(devlist_lock);
 
@@ -34,7 +39,7 @@ static DEFINE_SPINLOCK(used_minors_lock);
 static DECLARE_BITMAP(used_minors, N_DEVS);
 
 static int
-minor_get(ulong *minor)
+minor_get_dyn(ulong *sysminor)
 {
ulong flags;
ulong n;
@@ -48,10 +53,53 @@ minor_get(ulong *minor)
error = -1;
spin_unlock_irqrestore(_minors_lock, flags);
 
-   *minor = n * AOE_PARTITIONS;
+   *sysminor = n * AOE_PARTITIONS;
return error;
 }
 
+static int
+minor_get_static(ulong *sysminor, ulong aoemaj, int aoemin)
+{
+   ulong flags;
+   ulong n;
+   int error = 0;
+   enum {
+   /* for backwards compatibility when !aoe_dyndevs,
+* a static number of supported slots per shelf */
+   NPERSHELF = 16,
+   };
+
+   n = aoemaj * NPERSHELF + aoemin;
+   if (aoemin >= NPERSHELF || n >= N_DEVS) {
+   pr_err("aoe: %s with e%ld.%d\n",
+   "cannot use static minor device numbers",
+   aoemaj, aoemin);
+   error = -1;
+   } else {
+   spin_lock_irqsave(_minors_lock, flags);
+   if (test_bit(n, used_minors)) {
+   pr_err("aoe: %s %lu\n",
+   "existing device already has static minor 
number",
+   n);
+   error = -1;
+   } else
+   set_bit(n, used_minors);
+   spin_unlock_irqrestore(_minors_lock, flags);
+   }
+
+   *sysminor = n;
+   return error;
+}
+
+static int
+minor_get(ulong *sysminor, ulong aoemaj, int aoemin)
+{
+   if (aoe_dyndevs)
+   return minor_get_dyn(sysminor);
+   else
+   return minor_get_static(sysminor, aoemaj, aoemin);
+}
+
 static void
 minor_free(ulong minor)
 {
@@ -293,7 +341,7 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
d->ref++;
break;
}
-   if (d || !do_alloc || minor_get() < 0)
+   if (d || !do_alloc || minor_get(, maj, min) < 0)
goto out;
d = kcalloc(1, sizeof *d, GFP_ATOMIC);
if (!d)
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/7] aoe: support more AoE addresses with dynamic block device minor numbers

2012-10-01 Thread Ed Cashin
The ATA over Ethernet protocol uses a major (shelf) and
minor (slot) address to identify a particular storage target.
These changes remove an artificial limitation the aoe driver
imposes on the use of AoE addresses.  For example, without these
changes, the slot address has a maximum of 15, but users commonly
use slot numbers much greater than that.

The AoE shelf and slot address space is often used sparsely.
Instead of using a static mapping between AoE addresses and the
block device minor number, the block device minor numbers are now
allocated on demand.

Signed-off-by: Ed Cashin 
---
 drivers/block/aoe/aoe.h|6 ++--
 drivers/block/aoe/aoeblk.c |2 +-
 drivers/block/aoe/aoechr.c |2 +-
 drivers/block/aoe/aoecmd.c |   25 -
 drivers/block/aoe/aoedev.c |   86 ++--
 5 files changed, 72 insertions(+), 49 deletions(-)

diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 27d0a21..7b694f7 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -49,6 +49,8 @@ struct aoe_hdr {
__be32 tag;
 };
 
+#define AOE_MAXSHELF (0x-1)/* one less than the broadcast shelf 
address */
+
 struct aoe_atahdr {
unsigned char aflags;
unsigned char errfeat;
@@ -211,8 +213,7 @@ void aoe_ktstop(struct ktstate *k);
 
 int aoedev_init(void);
 void aoedev_exit(void);
-struct aoedev *aoedev_by_aoeaddr(int maj, int min);
-struct aoedev *aoedev_by_sysminor_m(ulong sysminor);
+struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
 void aoedev_downdev(struct aoedev *d);
 int aoedev_flush(const char __user *str, size_t size);
 void aoe_failbuf(struct aoedev *, struct buf *);
@@ -223,4 +224,3 @@ void aoenet_exit(void);
 void aoenet_xmit(struct sk_buff_head *);
 int is_aoe_netif(struct net_device *ifp);
 int set_aoe_iflist(const char __user *str, size_t size);
-
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 83160ab..00dfc50 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -249,7 +249,7 @@ aoeblk_gdalloc(void *vp)
q->queuedata = d;
d->gd = gd;
gd->major = AOE_MAJOR;
-   gd->first_minor = d->sysminor * AOE_PARTITIONS;
+   gd->first_minor = d->sysminor;
gd->fops = _bdops;
gd->private_data = d;
set_capacity(gd, d->ssize);
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index deb30c1..ed57a89 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -91,7 +91,7 @@ revalidate(const char __user *str, size_t size)
pr_err("aoe: invalid device specification %s\n", buf);
return -EINVAL;
}
-   d = aoedev_by_aoeaddr(major, minor);
+   d = aoedev_by_aoeaddr(major, minor, 0);
if (!d)
return -EINVAL;
spin_lock_irqsave(>lock, flags);
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 39dacdb..94e810c 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -1149,7 +1149,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
 
h = (struct aoe_hdr *) skb->data;
aoemajor = be16_to_cpu(get_unaligned(>major));
-   d = aoedev_by_aoeaddr(aoemajor, h->minor);
+   d = aoedev_by_aoeaddr(aoemajor, h->minor, 0);
if (d == NULL) {
snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response "
"for unknown device %d.%d\n",
@@ -1330,7 +1330,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
struct aoe_hdr *h;
struct aoe_cfghdr *ch;
struct aoetgt *t;
-   ulong flags, sysminor, aoemajor;
+   ulong flags, aoemajor;
struct sk_buff *sl;
struct sk_buff_head queue;
u16 n;
@@ -1349,18 +1349,15 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
"Check shelf dip switches.\n");
return;
}
-   if (h->minor >= NPERSHELF) {
-   pr_err("aoe: e%ld.%d %s, %d\n",
-   aoemajor, h->minor,
-   "slot number larger than the maximum",
-   NPERSHELF-1);
+   if (aoemajor > AOE_MAXSHELF) {
+   pr_info("aoe: e%ld.%d: shelf number too large\n",
+   aoemajor, (int) h->minor);
return;
}
 
-   sysminor = SYSMINOR(aoemajor, h->minor);
-   if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) {
-   printk(KERN_INFO "aoe: e%ld.%d: minor number too large\n",
-   aoemajor, (int) h->minor);
+   d = aoedev_by_aoeaddr(aoemajor, h->minor, 1);
+   if (d == NULL) {
+   pr_info("aoe: device allocation failure\n");
return;
}
 
@@ -1368,12 +1365,6 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
if (n > aoe_maxout) /* keep it reasonable */
n = aoe_maxout;
 
-   d = aoedev_by_sysminor_m(sysminor);
-   if (d == NULL) {
- 

linux-next: manual merge of the net-next tree with Linus' tree

2012-10-01 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the net-next tree got a conflict in
Documentation/feature-removal-schedule.txt between commit 9c0ece069b32
("Get rid of Documentation/feature-removal.txt") from Linus' tree and
commits 965505015bec ("netfilter: remove xt_NOTRACK") and 7b55279f6a45
("NFC: Remove the pn544 raw driver") from the net-next tree.

I removed the file and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpIigYByvmjh.pgp
Description: PGP signature


linux-next: build failure after merge of the acpi tree

2012-10-01 Thread Stephen Rothwell
Hi Len,

After merging the acpi tree, today's linux-next build (x86_64_allmodconfig)
failed like this:

drivers/usb/core/usb-acpi.c: In function 'usb_acpi_check_port_connect_type':
drivers/usb/core/usb-acpi.c:90:18: error: storage size of 'pld' isn't known

Caused by commit 05f916894a69 ("usb/acpi: Store info on device
removability") from Linus' tree interacting with commit 8ede06aba5df
("ACPI: Use ACPICA native way to decode the PLD buffer") from the acpi
tree.

I applied this merge fix that I have been applying to the usb tree (which
has now been merged by Linus).

From: Stephen Rothwell 
Date: Mon, 24 Sep 2012 16:51:38 +1000
Subject: [PATCH] usb-acpi: Comply with the ACPI API change after usb tree merge

Signed-off-by: Stephen Rothwell 
---
 drivers/usb/core/usb-acpi.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 0ef7d42..e9b159a 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -87,7 +87,7 @@ static int usb_acpi_check_port_connect_type(struct usb_device 
*hdev,
acpi_status status;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *upc;
-   struct acpi_pld pld;
+   struct acpi_pld_info *pld;
int ret = 0;
 
/*
@@ -111,13 +111,13 @@ static int usb_acpi_check_port_connect_type(struct 
usb_device *hdev,
}
 
if (upc->package.elements[0].integer.value)
-   if (pld.user_visible)
+   if (pld->user_visible)
usb_set_hub_port_connect_type(hdev, port1,
USB_PORT_CONNECT_TYPE_HOT_PLUG);
else
usb_set_hub_port_connect_type(hdev, port1,
USB_PORT_CONNECT_TYPE_HARD_WIRED);
-   else if (!pld.user_visible)
+   else if (!pld->user_visible)
usb_set_hub_port_connect_type(hdev, port1, USB_PORT_NOT_USED);
 
 out:

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpInAZvF9q1Q.pgp
Description: PGP signature


Re: [RFC v9 PATCH 01/21] memory-hotplug: rename remove_memory() to offline_memory()/offline_pages()

2012-10-01 Thread Yasuaki Ishimatsu

Hi Kosaki-san,

2012/09/29 7:15, KOSAKI Motohiro wrote:

On Thu, Sep 27, 2012 at 11:50 PM, Yasuaki Ishimatsu
 wrote:

Hi Chen,


2012/09/28 11:22, Ni zhan Chen wrote:


On 09/05/2012 05:25 PM, we...@cn.fujitsu.com wrote:


From: Yasuaki Ishimatsu 

remove_memory() only try to offline pages. It is called in two cases:
1. hot remove a memory device
2. echo offline >/sys/devices/system/memory/memoryXX/state

In the 1st case, we should also change memory block's state, and notify
the userspace that the memory block's state is changed after offlining
pages.

So rename remove_memory() to offline_memory()/offline_pages(). And in
the 1st case, offline_memory() will be used. The function
offline_memory()
is not implemented. In the 2nd case, offline_pages() will be used.



But this time there is not a function associated with add_memory.



To associate with add_memory() later, we renamed it.


Then, you introduced bisect breakage. It is definitely unacceptable.


What is "bisect breakage" meaning?

Thanks,
Yasuaki Ishimatsu



NAK.




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/2] hwmon: (ads7828) add support for ADS7830

2012-10-01 Thread Guenter Roeck
On Mon, Oct 01, 2012 at 07:16:24PM -0400, Vivien Didelot wrote:
> From: Guillaume Roguez 
> 
> The ADS7830 device is almost the same as the ADS7828,
> except that it does 8-bit sampling, instead of 12-bit.
> This patch extends the ads7828 driver to support this chip.
> 
> Signed-off-by: Guillaume Roguez 
> Signed-off-by: Vivien Didelot 

Hi Guillaume,
Hi Vivien,

couple of comments below.

> ---
>  Documentation/hwmon/ads7828 | 12 --
>  drivers/hwmon/Kconfig   |  7 +++---
>  drivers/hwmon/ads7828.c | 58 
> -
>  3 files changed, 55 insertions(+), 22 deletions(-)
> 
> diff --git a/Documentation/hwmon/ads7828 b/Documentation/hwmon/ads7828
> index 2bbebe6..4366a87 100644
> --- a/Documentation/hwmon/ads7828
> +++ b/Documentation/hwmon/ads7828
> @@ -8,8 +8,15 @@ Supported chips:
>  Datasheet: Publicly available at the Texas Instruments website :
> http://focus.ti.com/lit/ds/symlink/ads7828.pdf
>  
> +  * Texas Instruments ADS7830
> +Prefix: 'ads7830'
> +Addresses scanned: I2C 0x48, 0x49, 0x4a, 0x4b
> +Datasheet: Publicly available at the Texas Instruments website:
> +   http://focus.ti.com/lit/ds/symlink/ads7830.pdf
> +
>  Authors:
>  Steve Hardy 
> +Guillaume Roguez 
>  
>  Module Parameters
>  -
> @@ -24,9 +31,10 @@ Module Parameters
>  Description
>  ---
>  
> -This driver implements support for the Texas Instruments ADS7828.
> +This driver implements support for the Texas Instruments ADS7828, and 
> ADS7830.
>  

s/,//

> -This device is a 12-bit 8-channel A-D converter.
> +The ADS7828 device is a 12-bit 8-channel A/D converter, while the ADS7830 
> does
> +8-bit sampling.
>  
>  It can operate in single ended mode (8 +ve inputs) or in differential mode,
>  where 4 differential pairs can be measured.
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index 83e3e9d..960c8c5 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -1060,11 +1060,12 @@ config SENSORS_ADS1015
> will be called ads1015.
>  
>  config SENSORS_ADS7828
> - tristate "Texas Instruments ADS7828"
> + tristate "Texas Instruments ADS7828 and compatibles"
>   depends on I2C
>   help
> -   If you say yes here you get support for Texas Instruments ADS7828
> -   12-bit 8-channel ADC device.
> +   If you say yes here you get support for Texas Instruments ADS7828 and
> +   ADS7830 8-channel A/D converters. ADS7828 resolution is 12-bit, while
> +   it is 8-bit on ADS7830.
>  
> This driver can also be built as a module.  If so, the module
> will be called ads7828.
> diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
> index fb3010d..91fc629 100644
> --- a/drivers/hwmon/ads7828.c
> +++ b/drivers/hwmon/ads7828.c
> @@ -1,11 +1,13 @@
>  /*
> - * ads7828.c - lm_sensors driver for ads7828 12-bit 8-channel ADC
> + * ads7828.c - driver for TI ADS7828 8-channel A/D converter and compatibles
>   * (C) 2007 EADS Astrium
>   *
>   * This driver is based on the lm75 and other lm_sensors/hwmon drivers
>   *
>   * Written by Steve Hardy 
>   *
> + * ADS7830 support by Guillaume Roguez 
> 
> + *
>   * For further information, see the Documentation/hwmon/ads7828 file.
>   *
>   * This program is free software; you can redistribute it and/or modify
> @@ -41,6 +43,9 @@
>  #define ADS7828_CMD_PD3  0x0C/* Internal ref ON && A/D ON */
>  #define ADS7828_INT_VREF_MV  2500/* Internal vref is 2.5V, 2500mV */
>  
> +/* List of supported devices */
> +enum ads7828_chips { ads7828, ads7830 };
> +
>  /* Addresses to scan */
>  static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
>   I2C_CLIENT_END };
> @@ -53,9 +58,7 @@ module_param(se_input, bool, S_IRUGO);
>  module_param(int_vref, bool, S_IRUGO);
>  module_param(vref_mv, int, S_IRUGO);
>  
> -/* Global Variables */
>  static u8 ads7828_cmd_byte; /* cmd byte without channel bits */

At some point we may have to look into the configuration ... using module
parameters doesn't seem to be right here. Should be platform data or device
tree. But that is for later ... just something to keep in mind.

> -static unsigned int ads7828_lsb_resol; /* resolution of the ADC sample lsb */
>  
>  /**
>   * struct ads7828_data - client specific data
> @@ -64,6 +67,8 @@ static unsigned int ads7828_lsb_resol; /* resolution of the 
> ADC sample lsb */
>   * @valid:   Validity flag.
>   * @last_updated:Last updated time (in jiffies).
>   * @adc_input:   ADS7828_NCH samples.
> + * @lsb_resol:   Resolution of the A/D converter sample LSB.
> + * @read_channel:Function used to read a channel.
>   */
>  struct ads7828_data {
>   struct device *hwmon_dev;
> @@ -71,6 +76,8 @@ struct ads7828_data {
>   char valid;
>   unsigned long last_updated;
>   u16 adc_input[ADS7828_NCH];
> + unsigned int lsb_resol;
> + 

linux-next: manual merge of the v4l-dvb tree with Linus' tree

2012-10-01 Thread Stephen Rothwell
Hi Mauro,

Today's linux-next merge of the v4l-dvb tree got a conflict in
Documentation/feature-removal-schedule.txt between commit 9c0ece069b32
("Get rid of Documentation/feature-removal.txt") from Linus' tree and
commit 251658e5185e ("[media] Schedule removal of i.MX25 support in
mx2_camera.c") from the v4l-dvb tree.

I just removed the file and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpvifXZFAj9w.pgp
Description: PGP signature


linux-next: build failure in dwarf-regs.c

2012-10-01 Thread Ben Guthro
I pulled the latest bits up to
797b9e5ae93270ec27a1f1ed48cd697d01b2269f - but am seeing the following
build failure with gcc 4.6.3

 CC arch/x86/util/dwarf-regs.o
arch/x86/util/dwarf-regs.c:72:13: error: no previous prototype for
'get_arch_regstr' [-Werror=missing-prototypes]
cc1: all warnings being treated as errors
make[3]: *** [arch/x86/util/dwarf-regs.o] Error 1
make[3]: Leaving directory
`/data/home/bguthro/dev/orc-newdev.git/linux/build/tools/tools/perf'
make[2]: *** [build-linux-tools] Error 2
make[2]: Leaving directory `/data/home/bguthro/dev/orc-newdev.git/linux'
make[1]: *** [install-kernel] Error 2
make[1]: Leaving directory `/data/home/bguthro/dev/orc-newdev.git/orc-kernel'
make: *** [dist-kernels] Error 2


git blame shows that line coming in from the following changeset -
though April is a long time ago in kernel time - so this must have
come in with some other merge in this 3.7 window

commit cd932c593995abee1d1a8a0bfe608f7d103d87ad
Author: Ian Munsie 
Date:   Tue Apr 20 16:58:32 2010 +1000

perf: Move arch specific code into separate arch directory

The perf userspace tool included some architecture specific code to map
registers from the DWARF register number into the names used by the regs
and stack access API.

This moves the architecture specific code out into a separate
arch/x86 directory along with the infrastructure required to use it.

Signed-off-by: Ian Munsie 
Acked-by: Masami Hiramatsu 
Signed-off-by: Paul Mackerras 


Apologies to Ian, who may reciece this multiple times, as I worked out
some email bounce issues with LKML
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: linux-next: build failure after merge of the nfs tree

2012-10-01 Thread Myklebust, Trond
> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
> ow...@vger.kernel.org] On Behalf Of Stephen Rothwell
> Sent: Monday, October 01, 2012 8:39 PM
> To: Trond Myklebust
> Cc: linux-n...@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: linux-next: build failure after merge of the nfs tree
> 
> Hi Trond,
> 
> After merging the nfs tree, today's linux-next build (powerpc
> ppc64_defconfig) failed like this:
> 
> fs/nfs/callback.c: In function 'nfs_minorversion_callback_svc_setup':
> fs/nfs/callback.c:206:21: error: 'ENOTSUP' undeclared (first use in this
> function)
> 
> Caused by commit 141e1f553b6e ("NFSv4: Fix the minor version callback
> channel startup").
> 

Hi Stephen,

Thanks! We've already fixed this issue and pushed out a new tree...

Cheers
  Trond
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/2] hwmon: (ads7828) driver cleanup

2012-10-01 Thread Guenter Roeck
On Mon, Oct 01, 2012 at 07:16:23PM -0400, Vivien Didelot wrote:
> * Remove unused macros;
> * Point to the documentation;
> * Coding Style fixes (Kernel Doc, spacing);
> * Move driver declaration to avoid adding function prototypes.
> 
> Signed-off-by: Vivien Didelot 

Hi Vivien,

> ---
>  drivers/hwmon/ads7828.c | 91 
> +++--
>  1 file changed, 43 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
> index bf3fdf4..fb3010d 100644
> --- a/drivers/hwmon/ads7828.c
> +++ b/drivers/hwmon/ads7828.c
> @@ -6,7 +6,7 @@
>   *
>   * Written by Steve Hardy 
>   *
> - * Datasheet available at: http://focus.ti.com/lit/ds/symlink/ads7828.pdf
> + * For further information, see the Documentation/hwmon/ads7828 file.
>   *
>   * This program is free software; you can redistribute it and/or modify
>   * it under the terms of the GNU General Public License as published by
> @@ -34,14 +34,12 @@
>  #include 
>  
>  /* The ADS7828 registers */
> -#define ADS7828_NCH 8 /* 8 channels of 12-bit A-D supported */
> -#define ADS7828_CMD_SD_SE 0x80 /* Single ended inputs */
> -#define ADS7828_CMD_SD_DIFF 0x00 /* Differential inputs */
> -#define ADS7828_CMD_PD0 0x0 /* Power Down between A-D conversions */
> -#define ADS7828_CMD_PD1 0x04 /* Internal ref OFF && A-D ON */
> -#define ADS7828_CMD_PD2 0x08 /* Internal ref ON && A-D OFF */
> -#define ADS7828_CMD_PD3 0x0C /* Internal ref ON && A-D ON */
> -#define ADS7828_INT_VREF_MV 2500 /* Internal vref is 2.5V, 2500mV */
> +#define ADS7828_NCH  8   /* 8 channels supported */
> +#define ADS7828_CMD_SD_SE0x80/* Single ended inputs */
> +#define ADS7828_CMD_SD_DIFF  0x00/* Differential inputs */
> +#define ADS7828_CMD_PD1  0x04/* Internal ref OFF && A/D ON */
> +#define ADS7828_CMD_PD3  0x0C/* Internal ref ON && A/D ON */
> +#define ADS7828_INT_VREF_MV  2500/* Internal vref is 2.5V, 2500mV */
>  
>  /* Addresses to scan */
>  static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
> @@ -59,25 +57,26 @@ module_param(vref_mv, int, S_IRUGO);
>  static u8 ads7828_cmd_byte; /* cmd byte without channel bits */
>  static unsigned int ads7828_lsb_resol; /* resolution of the ADC sample lsb */
>  
> -/* Each client has this additional data */
> +/**
> + * struct ads7828_data - client specific data
> + * @hwmon_dev:   The hwmon device.
> + * @update_lock: Mutex protecting updates.
> + * @valid:   Validity flag.
> + * @last_updated:Last updated time (in jiffies).
> + * @adc_input:   ADS7828_NCH samples.
> + */
This isn't really an externally visible API, so I wonder if it provides value to
document it this way. No strong opinion, just wondering.

>  struct ads7828_data {
>   struct device *hwmon_dev;
> - struct mutex update_lock; /* mutex protect updates */
> - char valid; /* !=0 if following fields are valid */
> - unsigned long last_updated; /* In jiffies */
> - u16 adc_input[ADS7828_NCH]; /* ADS7828_NCH 12-bit samples */
> + struct mutex update_lock;
> + char valid;
> + unsigned long last_updated;
> + u16 adc_input[ADS7828_NCH];
>  };
>  
> -/* Function declaration - necessary due to function dependencies */
> -static int ads7828_detect(struct i2c_client *client,
> -   struct i2c_board_info *info);
> -static int ads7828_probe(struct i2c_client *client,
> -  const struct i2c_device_id *id);
> -
>  static inline u8 channel_cmd_byte(int ch)
>  {
>   /* cmd byte C2,C1,C0 - see datasheet */
> - u8 cmd = (((ch>>1) | (ch&0x01)<<2)<<4);
> + u8 cmd = (((ch >> 1) | (ch & 0x01) << 2) << 4);
>   cmd |= ads7828_cmd_byte;
>   return cmd;
>  }
> @@ -120,9 +119,8 @@ static ssize_t show_in(struct device *dev, struct 
> device_attribute *da,
>   ads7828_lsb_resol)/1000);

Can you fix this one as well since you are at it ? There is another one in 
sensors_ads7828_init().
[ Wonder why checkpatch doesn't complain about it ]

>  }
>  
> -#define in_reg(offset)\
> -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in,\
> - NULL, offset)
> +#define in_reg(offset) \
> +static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, NULL, offset)
>  
This causes a checkpatch error - checkpatch doesn't like the multi-line macros.

>  in_reg(0);
>  in_reg(1);

Since it seems to be hardly worth it anyway (yes, I know there are 8 of them),
would be great if you can just get rid of the macro and just use
static SENSOR_DEVICE_ATTR(in[1-8]_input, ...)
instead.

> @@ -158,25 +156,6 @@ static int ads7828_remove(struct i2c_client *client)
>   return 0;
>  }
>  
> -static const struct i2c_device_id ads7828_id[] = {
> - { "ads7828", 0 },
> - { }
> -};
> -MODULE_DEVICE_TABLE(i2c, ads7828_id);
> -
> -/* This is the driver that will be inserted */
> -static struct i2c_driver ads7828_driver = {
> - 

Re: [PATCH 10/36] AArch64: MMU definitions

2012-10-01 Thread Jon Masters
On 07/06/2012 05:05 PM, Catalin Marinas wrote:

> +/*
> + * PAGE_OFFSET - the virtual address of the start of the kernel image.
> + * VA_BITS - the maximum number of bits for virtual addresses.
> + * TASK_SIZE - the maximum size of a user space task.
> + * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
> + * The module space lives between the addresses given by TASK_SIZE
> + * and PAGE_OFFSET - it must be within 128MB of the kernel text.
> + */
> +#define PAGE_OFFSET  UL(0xffc0)
> +#define MODULES_END  (PAGE_OFFSET)
> +#define MODULES_VADDR(MODULES_END - SZ_64M)
> +#define VA_BITS  (39)
> +#define TASK_SIZE_64 (UL(1) << VA_BITS)

Pedantic nit pick. Shouldn't that "it must be within 128MB of the kernel
text" be "within 128MB of the *end* of the kernel text"? The point being
that on AArch64 unconditional branches are encoded as imm26+1 (27 bits)
and so you're going with -64MB to ensure that you're within the range.

Jon.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [REGRESSION] nfsd crashing with 3.6.0-rc7 on PowerPC

2012-10-01 Thread Benjamin Herrenschmidt
On Mon, 2012-10-01 at 16:03 +0200, Alexander Graf wrote:
> Phew. Here we go :). It looks to be more of a PPC specific problem than it 
> appeared as at first:

Ok, so I suspect the problem is the pushing down of the locks which
breaks with iommu backends that have a separate flush callback. In
that case, the flush moves out of the allocator lock.

Now we do call flush before we return, still, but it becomes racy
I suspect, but somebody needs to give it a closer look. I'm hoping
Anton or Nish will later today.

Cheers,
Ben.

> 
> b4c3a8729ae57b4f84d661e16a192f828eca1d03 is first bad commit
> commit b4c3a8729ae57b4f84d661e16a192f828eca1d03
> Author: Anton Blanchard 
> Date:   Thu Jun 7 18:14:48 2012 +
> 
> powerpc/iommu: Implement IOMMU pools to improve multiqueue adapter 
> performance
> 
> At the moment all queues in a multiqueue adapter will serialise
> against the IOMMU table lock. This is proving to be a big issue,
> especially with 10Gbit ethernet.
> 
> This patch creates 4 pools and tries to spread the load across
> them. If the table is under 1GB in size we revert back to the
> original behaviour of 1 pool and 1 largealloc pool.
> 
> We create a hash to map CPUs to pools. Since we prefer interrupts to
> be affinitised to primary CPUs, without some form of hashing we are
> very likely to end up using the same pool. As an example, POWER7
> has 4 way SMT and with 4 pools all primary threads will map to the
> same pool.
> 
> The largealloc pool is reduced from 1/2 to 1/4 of the space to
> partially offset the overhead of breaking the table up into pools.
> 
> Some performance numbers were obtained with a Chelsio T3 adapter on
> two POWER7 boxes, running a 100 session TCP round robin test.
> 
> Performance improved 69% with this patch applied.
> 
> Signed-off-by: Anton Blanchard 
> Signed-off-by: Benjamin Herrenschmidt 
> 
> :04 04 039ae3cbdcfded9c6b13e58a3fc67609f1b587b0 
> 6755a8c4a690cc80dcf834d1127f21db925476d6 March
> 
> 
> Alex


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 10/10] bug.h: Add gcc 4.2+ versions of BUILD_BUG_ON_* macros

2012-10-01 Thread Michel Lespinasse
On Fri, Sep 28, 2012 at 4:20 PM, Daniel Santos  wrote:
> BUILD_BUG_ON42(arg)
> BUILD_BUG_ON_CONST42(arg)
>
> Prior to gcc 4.2, the optimizer was unable to determine that many
> constant values stored in structs were indeed compile-time constants and
> optimize them out.  Sometimes, it will find an intergral value to be a
> compile-time constant, but fail to perform a bit-wise AND at
> compile-time.  These two macros provide a mechanism to perform these
> build-time checks, but not break on older compilers where we already
> know they can't be checked at compile time.
>
> For specific details, consult the doc comments for BUILD_BUG_ON_CONST.
> These macros are used in the generic rbtree code.

I think the names are quite confusing. BUILD_BUG_ON_NON_CONST42 sounds
like it's checking if 42 is a constant.

The name probably shouldn't mention what compiler versions support
this check, but instead it should hint as to when you should use this
instead of BUILD_BUG_ON_CONST ? Maybe BUILD_BUG_ON_CONST_DEREF or
something (I'm pretty bad with names too :)

-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 8/10] bug.h: Make BUILD_BUG_ON generate compile-time error

2012-10-01 Thread Michel Lespinasse
On Fri, Sep 28, 2012 at 4:20 PM, Daniel Santos  wrote:
> Negative sized arrays wont create a compile-time error in some cases
> starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced
> the error function attribute that will.  This patch modifies
> BUILD_BUG_ON to behave like BUILD_BUG already does, using the error
> function attribute so that you don't have to build the entire kernel to
> discover that you have a problem, and then enjoy trying to track it down
> from a link-time error.

Few other alternatives I've seen used in other projects (from memory,
so I may have gotten the details wrong):

1) if (condition) { __asm__(".error \"Some error message\""); }
2) switch (0) {
case 0: break;
case !condition: break;
}
(fails to compile if !condition evaluates to 0)

If you can get the first suggestion to work it'd be nice, as you could
get some descriptive error message (you can add the line number there
too).

-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC, PATCH] Extensible AIO interface

2012-10-01 Thread Kent Overstreet
On Mon, Oct 01, 2012 at 04:44:39PM -0700, Zach Brown wrote:
> And what about duplicate instances of a given attribute id?  Use the
> first?  The last?  Error?  Depends on the id?

I thought of a better idea, instead of explicitly checking for
disallowed dups:

We want to return -ENOTHANDLED for not handled attributes anyways, so
let's just do that for dups - that'll catch erronious usage just fine
and a generic mechanism's better than a one off hack any day.

This does mean we can't punt on return values, which isn't a bad thing.

Also, if we've got duplicate attributes userspace needs to be able to
figure out which return value was for which attribute.

Two possibilities: one, return values come out in the same order
attributes went in. That'd work, but I dislike the subtlety and I expect
it'd be a pain for userspace.

Instead, let's just stick a u64 cookie in the attribute and include that
in the return, just like we do everywhere else.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 1/3] tracing,x86: add a TSC trace_clock

2012-10-01 Thread Steven Rostedt
On Mon, 2012-10-01 at 17:33 -0700, David Sharp wrote:

> > Unfortunately this isn't enough. You need to add a stub in all
> > arch/*/include/asm/ directories. That has:
> 
> Oh really? Okay. Sorry, I really don't know the mechanics of the arch
> trees. I'll work on that now, and then send you a new series since I
> forgot to send out my last update.

It's a good idea to cross compile archs, especially if you make any
change that affects archs (like this one did).

Just use ktest.pl. You can download the cross tools at:

  http://kernel.org/pub/tools/crosstool/files/bin/x86_64/

And you can use the example config file in:

  tools/testing/ktest/examples/crosstests.conf

That's basically the test I use to test cross compiling of other archs.

-- Steve


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: build failure after merge of the nfs tree

2012-10-01 Thread Stephen Rothwell
Hi Trond,

After merging the nfs tree, today's linux-next build (powerpc
ppc64_defconfig) failed like this:

fs/nfs/callback.c: In function 'nfs_minorversion_callback_svc_setup':
fs/nfs/callback.c:206:21: error: 'ENOTSUP' undeclared (first use in this 
function)

Caused by commit 141e1f553b6e ("NFSv4: Fix the minor version callback
channel startup").

I have used the nfs tree from next-20121001 for today.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgp6YF9wfQdMY.pgp
Description: PGP signature


Re: [RFC v9 PATCH 06/21] memory-hotplug: export the function acpi_bus_remove()

2012-10-01 Thread Ni zhan Chen

On 09/05/2012 05:25 PM, we...@cn.fujitsu.com wrote:

From: Wen Congyang 

The function acpi_bus_remove() can remove a acpi device from acpi device.


IIUC, s/acpi device/acpi bus

  
When a acpi device is removed, we need to call this function to remove

the acpi device from acpi bus. So export this function.

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
CC: Yasuaki Ishimatsu 
Signed-off-by: Wen Congyang 
---
  drivers/acpi/scan.c |3 ++-
  include/acpi/acpi_bus.h |1 +
  2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index d1ecca2..1cefc34 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1224,7 +1224,7 @@ static int acpi_device_set_context(struct acpi_device 
*device)
return -ENODEV;
  }
  
-static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)

+int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
  {
if (!dev)
return -EINVAL;
@@ -1246,6 +1246,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int 
rmdevice)
  
  	return 0;

  }
+EXPORT_SYMBOL(acpi_bus_remove);
  
  static int acpi_add_single_object(struct acpi_device **child,

  acpi_handle handle, int type,
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index bde976e..2ccf109 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -360,6 +360,7 @@ bool acpi_bus_power_manageable(acpi_handle handle);
  bool acpi_bus_can_wakeup(acpi_handle handle);
  int acpi_power_resource_register_device(struct device *dev, acpi_handle 
handle);
  void acpi_power_resource_unregister_device(struct device *dev, acpi_handle 
handle);
+int acpi_bus_remove(struct acpi_device *dev, int rmdevice);
  #ifdef CONFIG_ACPI_PROC_EVENT
  int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int 
data);
  int acpi_bus_generate_proc_event4(const char *class, const char *bid, u8 
type, int data);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ARM: hw_breakpoint: Clear breakpoints before enabling monitor mode

2012-10-01 Thread Stephen Boyd
On 09/24/12 10:19, Will Deacon wrote:
> Ok, I've pushed a bunch of patches to my hw-breakpoint branch (head commit
> 55cb726797c7). I'll post them to the list after the merge window, but please
> do take them for a spin if you get a chance.
>

Forgot to reply here. Took them for a spin last week with that commit.
No more boot hangs but I can't say much else beyond that. When you post
to the list I'll add my tested-by.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 1/3] tracing,x86: add a TSC trace_clock

2012-10-01 Thread David Sharp
On Fri, Sep 28, 2012 at 8:15 PM, Steven Rostedt  wrote:
> On Thu, 2012-09-20 at 15:52 -0700, David Sharp wrote:
>
>> diff --git a/include/asm-generic/trace_clock.h 
>> b/include/asm-generic/trace_clock.h
>> new file mode 100644
>> index 000..6726f1b
>> --- /dev/null
>> +++ b/include/asm-generic/trace_clock.h
>> @@ -0,0 +1,16 @@
>> +#ifndef _ASM_GENERIC_TRACE_CLOCK_H
>> +#define _ASM_GENERIC_TRACE_CLOCK_H
>> +/*
>> + * Arch-specific trace clocks.
>> + */
>> +
>> +/*
>> + * Additional trace clocks added to the trace_clocks
>> + * array in kernel/trace/trace.c
>> + * None if the architecture has not defined it.
>> + */
>> +#ifndef ARCH_TRACE_CLOCKS
>> +# define ARCH_TRACE_CLOCKS
>> +#endif
>> +
>> +#endif  /* _ASM_GENERIC_TRACE_CLOCK_H */
>
> Unfortunately this isn't enough. You need to add a stub in all
> arch/*/include/asm/ directories. That has:

Oh really? Okay. Sorry, I really don't know the mechanics of the arch
trees. I'll work on that now, and then send you a new series since I
forgot to send out my last update.

>
> --- trace_clock.h:
> #ifndef _ASM_TRACE_CLOCK_H
> #define _ASM_TRACE_CLOCK_H
>
> #include 
>
> #endif
> ---
>
>
> Because running this against my cross-compile test, failed on all archs
> but x86.
>
> -- Steve
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] [PATCH] x86: Don't clobber top of pt_regs in nested NMI

2012-10-01 Thread Salman Qazi
The nested NMI modifies the place (instruction, flags and stack)
that the first NMI will iret to.  However, the copy of registers
modified is exactly the one that is the part of pt_regs in
the first NMI.  This can change the behaviour of the first NMI.

In particular, Google's arch_trigger_all_cpu_backtrace handler
also prints regions of memory surrounding addresses appearing in
registers.  This results in handled exceptions, after which nested NMIs
start coming in.  These nested NMIs change the value of registers
in pt_regs.  This can cause the original NMI handler to produce
incorrect output.

We solve this problem by interchanging the position of the preserved
copy of the iret registers ("saved") and the copy subject to being
trampled by nested NMI ("copied").

Signed-off-by: Salman Qazi 
---
 arch/x86/kernel/entry_64.S |   41 +++--
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 44531ac..b5d6e43 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1739,9 +1739,10 @@ nested_nmi:
 
 1:
/* Set up the interrupted NMIs stack to jump to repeat_nmi */
-   leaq -6*8(%rsp), %rdx
+   leaq -1*8(%rsp), %rdx
movq %rdx, %rsp
-   CFI_ADJUST_CFA_OFFSET 6*8
+   CFI_ADJUST_CFA_OFFSET 1*8
+   leaq -10*8(%rsp), %rdx
pushq_cfi $__KERNEL_DS
pushq_cfi %rdx
pushfq_cfi
@@ -1749,8 +1750,8 @@ nested_nmi:
pushq_cfi $repeat_nmi
 
/* Put stack back */
-   addq $(11*8), %rsp
-   CFI_ADJUST_CFA_OFFSET -11*8
+   addq $(6*8), %rsp
+   CFI_ADJUST_CFA_OFFSET -6*8
 
 nested_nmi_out:
popq_cfi %rdx
@@ -1776,18 +1777,18 @@ first_nmi:
 * +-+
 * | NMI executing variable  |
 * +-+
-* | Saved SS|
-* | Saved Return RSP|
-* | Saved RFLAGS|
-* | Saved CS|
-* | Saved RIP   |
-* +-+
 * | copied SS   |
 * | copied Return RSP   |
 * | copied RFLAGS   |
 * | copied CS   |
 * | copied RIP  |
 * +-+
+* | Saved SS|
+* | Saved Return RSP|
+* | Saved RFLAGS|
+* | Saved CS|
+* | Saved RIP   |
+* +-+
 * | pt_regs |
 * +-+
 *
@@ -1803,9 +1804,14 @@ first_nmi:
/* Set the NMI executing variable on the stack. */
pushq_cfi $1
 
+   /*
+* Leave room for the "copied" frame
+*/
+   subq $(5*8), %rsp
+
/* Copy the stack frame to the Saved frame */
.rept 5
-   pushq_cfi 6*8(%rsp)
+   pushq_cfi 11*8(%rsp)
.endr
CFI_DEF_CFA_OFFSET SS+8-RIP
 
@@ -1826,12 +1832,15 @@ repeat_nmi:
 * is benign for the non-repeat case, where 1 was pushed just above
 * to this very stack slot).
 */
-   movq $1, 5*8(%rsp)
+   movq $1, 10*8(%rsp)
 
/* Make another copy, this one may be modified by nested NMIs */
+   addq $(10*8), %rsp
.rept 5
-   pushq_cfi 4*8(%rsp)
+   pushq_cfi -6*8(%rsp)
.endr
+   subq $(5*8), %rsp
+
CFI_DEF_CFA_OFFSET SS+8-RIP
 end_repeat_nmi:
 
@@ -1882,8 +1891,12 @@ nmi_swapgs:
SWAPGS_UNSAFE_STACK
 nmi_restore:
RESTORE_ALL 8
+
+   /* Pop the extra iret frame */
+   addq $(5*8), %rsp
+
/* Clear the NMI executing stack variable */
-   movq $0, 10*8(%rsp)
+   movq $0, 5*8(%rsp)
jmp irq_return
CFI_ENDPROC
 END(nmi)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 05/49] audit: add a new "type" field to audit_names struct

2012-10-01 Thread Jeff Layton
For now, we just have two possibilities:

UNKNOWN: for a new audit_names record that we don't know anything about yet
NORMAL: for everything else

In later patches, we'll add other types so we can distinguish and update
records created under different circumstances.

Signed-off-by: Jeff Layton 
---
 include/linux/audit.h |  5 +
 kernel/auditsc.c  | 15 ++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 2d8b761..48c49eb 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -450,6 +450,11 @@ struct audit_field {
 extern int __init audit_register_class(int class, unsigned *list);
 extern int audit_classify_syscall(int abi, unsigned syscall);
 extern int audit_classify_arch(int arch);
+
+/* audit_names->type values */
+#defineAUDIT_TYPE_UNKNOWN  0   /* we don't know yet */
+#define AUDIT_TYPE_NORMAL  1   /* a "normal" audit record */
+
 #ifdef CONFIG_AUDITSYSCALL
 /* These are defined in auditsc.c */
/* Public API */
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index ff58089..bd11d09 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -120,6 +120,7 @@ struct audit_names {
struct audit_cap_data fcap;
unsigned intfcap_ver;
int name_len;   /* number of name's characters to log */
+   unsigned char   type;   /* record type */
boolname_put;   /* call __putname() for this name */
/*
 * This was an allocated audit_names and not from the array of
@@ -2009,7 +2010,8 @@ retry:
 #endif
 }
 
-static struct audit_names *audit_alloc_name(struct audit_context *context)
+static struct audit_names *audit_alloc_name(struct audit_context *context,
+   unsigned char type)
 {
struct audit_names *aname;
 
@@ -2024,6 +2026,7 @@ static struct audit_names *audit_alloc_name(struct 
audit_context *context)
}
 
aname->ino = (unsigned long)-1;
+   aname->type = type;
list_add_tail(>list, >names_list);
 
context->name_count++;
@@ -2054,7 +2057,7 @@ void __audit_getname(const char *name)
return;
}
 
-   n = audit_alloc_name(context);
+   n = audit_alloc_name(context, AUDIT_TYPE_UNKNOWN);
if (!n)
return;
 
@@ -2171,12 +2174,13 @@ void __audit_inode(const char *name, const struct 
dentry *dentry)
 
 out_alloc:
/* unable to find the name from a previous getname() */
-   n = audit_alloc_name(context);
+   n = audit_alloc_name(context, AUDIT_TYPE_NORMAL);
if (!n)
return;
 out:
handle_path(dentry);
audit_copy_inode(n, dentry, inode);
+   n->type = AUDIT_TYPE_NORMAL;
 }
 
 /**
@@ -2233,6 +2237,7 @@ void __audit_inode_child(const struct inode *parent,
audit_copy_inode(n, dentry, inode);
else
n->ino = (unsigned long)-1;
+   n->type = AUDIT_TYPE_NORMAL;
found_child = n->name;
goto add_names;
}
@@ -2240,14 +2245,14 @@ void __audit_inode_child(const struct inode *parent,
 
 add_names:
if (!found_parent) {
-   n = audit_alloc_name(context);
+   n = audit_alloc_name(context, AUDIT_TYPE_NORMAL);
if (!n)
return;
audit_copy_inode(n, NULL, parent);
}
 
if (!found_child) {
-   n = audit_alloc_name(context);
+   n = audit_alloc_name(context, AUDIT_TYPE_NORMAL);
if (!n)
return;
 
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 06/49] audit: set the name_len in audit_inode for parent lookups

2012-10-01 Thread Jeff Layton
Currently, this gets set mostly by happenstance when we call into
audit_inode_child. While that might be a little more efficient, it seems
wrong. If the syscall ends up failing before audit_inode_child ever gets
called, then you'll have an audit_names record that shows the full path
but has the parent inode info attached.

Fix this by passing in a parent flag when we call audit_inode that gets
set to the value of LOOKUP_PARENT. We can then fix up the pathname for
the audit entry correctly from the get-go.

While we're at it, clean up the no-op macro for audit_inode in the
!CONFIG_AUDITSYSCALL case.

Signed-off-by: Jeff Layton 
---
 fs/namei.c| 14 +++---
 fs/open.c |  4 ++--
 fs/xattr.c|  8 
 include/linux/audit.h | 13 -
 ipc/mqueue.c  |  8 
 kernel/audit.h|  1 +
 kernel/auditfilter.c  | 30 ++
 kernel/auditsc.c  | 41 +
 8 files changed, 85 insertions(+), 34 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index d43..6c9d86d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1977,7 +1977,7 @@ static int do_path_lookup(int dfd, const char *name,
retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd);
 
if (likely(!retval))
-   audit_inode(name, nd->path.dentry);
+   audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
return retval;
 }
 
@@ -2652,7 +2652,7 @@ static int do_last(struct nameidata *nd, struct path 
*path,
error = complete_walk(nd);
if (error)
return error;
-   audit_inode(pathname, nd->path.dentry);
+   audit_inode(pathname, nd->path.dentry, 0);
if (open_flag & O_CREAT) {
error = -EISDIR;
goto out;
@@ -2662,7 +2662,7 @@ static int do_last(struct nameidata *nd, struct path 
*path,
error = complete_walk(nd);
if (error)
return error;
-   audit_inode(pathname, dir);
+   audit_inode(pathname, dir, 0);
goto finish_open;
}
 
@@ -2691,7 +2691,7 @@ static int do_last(struct nameidata *nd, struct path 
*path,
if (error)
return error;
 
-   audit_inode(pathname, dir);
+   audit_inode(pathname, dir, 0);
error = -EISDIR;
/* trailing slashes? */
if (nd->last.name[nd->last.len])
@@ -2721,7 +2721,7 @@ retry_lookup:
!S_ISREG(file->f_path.dentry->d_inode->i_mode))
will_truncate = false;
 
-   audit_inode(pathname, file->f_path.dentry);
+   audit_inode(pathname, file->f_path.dentry, 0);
goto opened;
}
 
@@ -2738,7 +2738,7 @@ retry_lookup:
 * create/update audit record if it already exists.
 */
if (path->dentry->d_inode)
-   audit_inode(pathname, path->dentry);
+   audit_inode(pathname, path->dentry, 0);
 
/*
 * If atomic_open() acquired write access it is dropped now due to
@@ -2803,7 +2803,7 @@ finish_lookup:
error = -ENOTDIR;
if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup)
goto out;
-   audit_inode(pathname, nd->path.dentry);
+   audit_inode(pathname, nd->path.dentry, 0);
 finish_open:
if (!S_ISREG(nd->inode->i_mode))
will_truncate = false;
diff --git a/fs/open.c b/fs/open.c
index e1f2cdb..ec06921 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -481,7 +481,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
 
file = fget(fd);
if (file) {
-   audit_inode(NULL, file->f_path.dentry);
+   audit_inode(NULL, file->f_path.dentry, 0);
err = chmod_common(>f_path, mode);
fput(file);
}
@@ -594,7 +594,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, 
gid_t, group)
if (error)
goto out_fput;
dentry = file->f_path.dentry;
-   audit_inode(NULL, dentry);
+   audit_inode(NULL, dentry, 0);
error = chown_common(>f_path, user, group);
mnt_drop_write_file(file);
 out_fput:
diff --git a/fs/xattr.c b/fs/xattr.c
index 4d45b71..588455b 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -408,7 +408,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, 
name,
if (!f)
return error;
dentry = f->f_path.dentry;
-   audit_inode(NULL, dentry);
+   audit_inode(NULL, dentry, 0);
error = mnt_want_write_file(f);
if (!error) {
error = setxattr(dentry, name, value, size, flags);
@@ -502,7 +502,7 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, 
name,
f = fget_light(fd, _needed);
if (!f)
   

[PATCH v7 07/49] audit: remove dirlen argument to audit_compare_dname_path

2012-10-01 Thread Jeff Layton
All the callers set this to NULL now.

Signed-off-by: Jeff Layton 
---
 kernel/audit.h   | 3 +--
 kernel/audit_watch.c | 2 +-
 kernel/auditfilter.c | 6 +-
 kernel/auditsc.c | 4 ++--
 4 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/kernel/audit.h b/kernel/audit.h
index 276ca88..ee31316 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -77,8 +77,7 @@ static inline int audit_hash_ino(u32 ino)
 extern int audit_match_class(int class, unsigned syscall);
 extern int audit_comparator(const u32 left, const u32 op, const u32 right);
 extern int parent_len(const char *path);
-extern int audit_compare_dname_path(const char *dname, const char *path,
-   int *dirlen);
+extern int audit_compare_dname_path(const char *dname, const char *path);
 extern struct sk_buff *audit_make_reply(int pid, int seq, int type,
 int done, int multi,
 const void *payload, int size);
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index 3823281..b6a873a 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -265,7 +265,7 @@ static void audit_update_watch(struct audit_parent *parent,
/* Run all of the watches on this parent looking for the one that
 * matches the given dname */
list_for_each_entry_safe(owatch, nextw, >watches, wlist) {
-   if (audit_compare_dname_path(dname, owatch->path, NULL))
+   if (audit_compare_dname_path(dname, owatch->path))
continue;
 
/* If the update involves invalidating rules, do the inode-based
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 29b167b..f9c48d0 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1230,8 +1230,7 @@ int parent_len(const char *path)
 
 /* Compare given dentry name with last component in given path,
  * return of 0 indicates a match. */
-int audit_compare_dname_path(const char *dname, const char *path,
-int *dirlen)
+int audit_compare_dname_path(const char *dname, const char *path)
 {
int dlen, plen;
const char *p;
@@ -1260,9 +1259,6 @@ int audit_compare_dname_path(const char *dname, const 
char *path,
p++;
}
 
-   /* return length of path's directory component */
-   if (dirlen)
-   *dirlen = p - path;
return strncmp(p, dname, dlen);
 }
 
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 011e923..b03ef6a 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -2236,7 +2236,7 @@ void __audit_inode_child(const struct inode *parent,
continue;
 
if (n->ino == parent->i_ino &&
-   !audit_compare_dname_path(dname, n->name, NULL)) {
+   !audit_compare_dname_path(dname, n->name)) {
found_parent = n->name;
goto add_names;
}
@@ -2249,7 +2249,7 @@ void __audit_inode_child(const struct inode *parent,
 
/* strcmp() is the more likely scenario */
if (!strcmp(dname, n->name) ||
-!audit_compare_dname_path(dname, n->name, NULL)) {
+!audit_compare_dname_path(dname, n->name)) {
if (inode)
audit_copy_inode(n, dentry, inode);
else
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 08/49] audit: make audit_compare_dname_path use parent_len helper

2012-10-01 Thread Jeff Layton
From: Eric Paris 

Signed-off-by: Eric Paris 
---
 kernel/auditfilter.c | 27 +++
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index f9c48d0..f47ba18 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1232,32 +1232,19 @@ int parent_len(const char *path)
  * return of 0 indicates a match. */
 int audit_compare_dname_path(const char *dname, const char *path)
 {
-   int dlen, plen;
+   int dlen, pathlen, parentlen;
const char *p;
 
-   if (!dname || !path)
-   return 1;
-
dlen = strlen(dname);
-   plen = strlen(path);
-   if (plen < dlen)
+   pathlen = strlen(path);
+   if (pathlen < dlen)
return 1;
 
-   /* disregard trailing slashes */
-   p = path + plen - 1;
-   while ((*p == '/') && (p > path))
-   p--;
-
-   /* find last path component */
-   p = p - dlen + 1;
-   if (p < path)
+   parentlen = parent_len(path);
+   if (pathlen - parentlen != dlen)
return 1;
-   else if (p > path) {
-   if (*--p != '/')
-   return 1;
-   else
-   p++;
-   }
+
+   p = path + parentlen;
 
return strncmp(p, dname, dlen);
 }
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 09/49] audit: optimize audit_compare_dname_path

2012-10-01 Thread Jeff Layton
In the cases where we already know the length of the parent, pass it as
a parm so we don't need to recompute it. In the cases where we don't
know the length, pass in AUDIT_NAME_FULL (-1) to indicate that it should
be determined.

Signed-off-by: Jeff Layton 
---
 kernel/audit.h   |  5 -
 kernel/audit_watch.c |  3 ++-
 kernel/auditfilter.c | 16 +++-
 kernel/auditsc.c |  8 +++-
 4 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/kernel/audit.h b/kernel/audit.h
index ee31316..34af33c 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -74,10 +74,13 @@ static inline int audit_hash_ino(u32 ino)
return (ino & (AUDIT_INODE_BUCKETS-1));
 }
 
+/* Indicates that audit should log the full pathname. */
+#define AUDIT_NAME_FULL -1
+
 extern int audit_match_class(int class, unsigned syscall);
 extern int audit_comparator(const u32 left, const u32 op, const u32 right);
 extern int parent_len(const char *path);
-extern int audit_compare_dname_path(const char *dname, const char *path);
+extern int audit_compare_dname_path(const char *dname, const char *path, int 
plen);
 extern struct sk_buff *audit_make_reply(int pid, int seq, int type,
 int done, int multi,
 const void *payload, int size);
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index b6a873a..f8e9353 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -265,7 +265,8 @@ static void audit_update_watch(struct audit_parent *parent,
/* Run all of the watches on this parent looking for the one that
 * matches the given dname */
list_for_each_entry_safe(owatch, nextw, >watches, wlist) {
-   if (audit_compare_dname_path(dname, owatch->path))
+   if (audit_compare_dname_path(dname, owatch->path,
+AUDIT_NAME_FULL))
continue;
 
/* If the update involves invalidating rules, do the inode-based
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index f47ba18..1e0899d 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1228,11 +1228,17 @@ int parent_len(const char *path)
return p - path;
 }
 
-/* Compare given dentry name with last component in given path,
- * return of 0 indicates a match. */
-int audit_compare_dname_path(const char *dname, const char *path)
+/**
+ * audit_compare_dname_path - compare given dentry name with last component in
+ *   given path. Return of 0 indicates a match.
+ * @dname: dentry name that we're comparing
+ * @path:  full pathname that we're comparing
+ * @parentlen: length of the parent if known. Passing in AUDIT_NAME_FULL
+ * here indicates that we must compute this value.
+ */
+int audit_compare_dname_path(const char *dname, const char *path, int 
parentlen)
 {
-   int dlen, pathlen, parentlen;
+   int dlen, pathlen;
const char *p;
 
dlen = strlen(dname);
@@ -1240,7 +1246,7 @@ int audit_compare_dname_path(const char *dname, const 
char *path)
if (pathlen < dlen)
return 1;
 
-   parentlen = parent_len(path);
+   parentlen = parentlen == AUDIT_NAME_FULL ? parent_len(path) : parentlen;
if (pathlen - parentlen != dlen)
return 1;
 
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index b03ef6a..52d1f0f 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -81,9 +81,6 @@
  * a name dynamically and also add those to the list anchored by names_list. */
 #define AUDIT_NAMES5
 
-/* Indicates that audit should log the full pathname. */
-#define AUDIT_NAME_FULL -1
-
 /* no execve audit message should be longer than this (userspace limits) */
 #define MAX_EXECVE_AUDIT_LEN 7500
 
@@ -2236,7 +2233,7 @@ void __audit_inode_child(const struct inode *parent,
continue;
 
if (n->ino == parent->i_ino &&
-   !audit_compare_dname_path(dname, n->name)) {
+   !audit_compare_dname_path(dname, n->name, n->name_len)) {
found_parent = n->name;
goto add_names;
}
@@ -2249,7 +2246,8 @@ void __audit_inode_child(const struct inode *parent,
 
/* strcmp() is the more likely scenario */
if (!strcmp(dname, n->name) ||
-!audit_compare_dname_path(dname, n->name)) {
+   !audit_compare_dname_path(dname, n->name,
+   AUDIT_NAME_FULL)) {
if (inode)
audit_copy_inode(n, dentry, inode);
else
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at 

[PATCH v7 10/49] audit: overhaul __audit_inode_child to accomodate retrying

2012-10-01 Thread Jeff Layton
In order to accomodate retrying path-based syscalls, we need to add a
new "type" argument to audit_inode_child. This will tell us whether
we're looking for a child entry that represents a create or a delete.

If we find a parent, don't automatically assume that we need to create a
new entry. Instead, use the information we have to try to find an
existing entry first. Update it if one is found and create a new one if
not.

Signed-off-by: Jeff Layton 
---
 fs/btrfs/ioctl.c |  2 +-
 fs/namei.c   |  2 +-
 include/linux/audit.h| 12 ++
 include/linux/fsnotify.h |  8 +++
 kernel/auditsc.c | 57 +---
 5 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7e78d47..45f987b 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -614,7 +614,7 @@ static int btrfs_may_delete(struct inode *dir,struct dentry 
*victim,int isdir)
return -ENOENT;
 
BUG_ON(victim->d_parent->d_inode != dir);
-   audit_inode_child(dir, victim);
+   audit_inode_child(dir, victim, AUDIT_TYPE_CHILD_DELETE);
 
error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
if (error)
diff --git a/fs/namei.c b/fs/namei.c
index 6c9d86d..64f7350 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2180,7 +2180,7 @@ static int may_delete(struct inode *dir,struct dentry 
*victim,int isdir)
return -ENOENT;
 
BUG_ON(victim->d_parent->d_inode != dir);
-   audit_inode_child(dir, victim);
+   audit_inode_child(dir, victim, AUDIT_TYPE_CHILD_DELETE);
 
error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
if (error)
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 155524b..0f7284a 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -455,6 +455,8 @@ extern int audit_classify_arch(int arch);
 #defineAUDIT_TYPE_UNKNOWN  0   /* we don't know yet */
 #define AUDIT_TYPE_NORMAL  1   /* a "normal" audit record */
 #define AUDIT_TYPE_PARENT  2   /* a parent audit record */
+#define AUDIT_TYPE_CHILD_DELETE 3  /* a child being deleted */
+#define AUDIT_TYPE_CHILD_CREATE 4  /* a child being created */
 
 #ifdef CONFIG_AUDITSYSCALL
 /* These are defined in auditsc.c */
@@ -470,7 +472,8 @@ extern void audit_putname(const char *name);
 extern void __audit_inode(const char *name, const struct dentry *dentry,
unsigned int parent);
 extern void __audit_inode_child(const struct inode *parent,
-   const struct dentry *dentry);
+   const struct dentry *dentry,
+   const unsigned char type);
 extern void __audit_seccomp(unsigned long syscall, long signr, int code);
 extern void __audit_ptrace(struct task_struct *t);
 
@@ -511,9 +514,10 @@ static inline void audit_inode(const char *name, const 
struct dentry *dentry,
__audit_inode(name, dentry, parent);
 }
 static inline void audit_inode_child(const struct inode *parent,
-const struct dentry *dentry) {
+const struct dentry *dentry,
+const unsigned char type) {
if (unlikely(!audit_dummy_context()))
-   __audit_inode_child(parent, dentry);
+   __audit_inode_child(parent, dentry, type);
 }
 void audit_core_dumps(long signr);
 
@@ -641,7 +645,7 @@ extern int audit_signals;
 #define __audit_inode(n,d,p) do { ; } while (0)
 #define __audit_inode_child(p,d) do { ; } while (0)
 #define audit_inode(n,d,p) do { ; } while (0)
-#define audit_inode_child(p,d) do { ; } while (0)
+#define audit_inode_child(p,d,t) do { ; } while (0)
 #define audit_core_dumps(i) do { ; } while (0)
 #define audit_seccomp(i,s,c) do { ; } while (0)
 #define auditsc_get_stamp(c,t,s) (0)
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 9c28471..0fbfb46 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -109,7 +109,7 @@ static inline void fsnotify_move(struct inode *old_dir, 
struct inode *new_dir,
 
if (source)
fsnotify(source, FS_MOVE_SELF, moved->d_inode, 
FSNOTIFY_EVENT_INODE, NULL, 0);
-   audit_inode_child(new_dir, moved);
+   audit_inode_child(new_dir, moved, AUDIT_TYPE_CHILD_CREATE);
 }
 
 /*
@@ -155,7 +155,7 @@ static inline void fsnotify_inoderemove(struct inode *inode)
  */
 static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
 {
-   audit_inode_child(inode, dentry);
+   audit_inode_child(inode, dentry, AUDIT_TYPE_CHILD_CREATE);
 
fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, 
dentry->d_name.name, 0);
 }
@@ -168,7 +168,7 @@ static inline void fsnotify_create(struct inode *inode, 
struct dentry *dentry)
 static inline void fsnotify_link(struct inode *dir, struct inode *inode, 

Re: [PATCH] extcon: adc-jack: Fix checking return value of request_any_context_irq

2012-10-01 Thread Chanwoo Choi
On 09/28/2012 08:36 AM, Axel Lin wrote:

> On failure, request_any_context_irq() returns a negative value.
> On success, it returns either IRQC_IS_HARDIRQ or IRQC_IS_NESTED.
> 
> Also ensure adc_jack_probe() return 0 on success.
> 
> Signed-off-by: Axel Lin 
> ---

Applied, thanks.

I applied two patch from Axel Lin at extcon git-tree and
you can check it after some hours.
-
http://git.infradead.org/users/kmpark/linux-samsung/shortlog/refs/heads/extcon-for-next

Thank you,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 11/49] vfs: allocate page instead of names_cache buffer in mount_block_root

2012-10-01 Thread Jeff Layton
First, it's incorrect to call putname() after __getname_gfp() since the
bare __getname_gfp() call skips the auditing code, while putname()
doesn't.

mount_block_root allocates a PATH_MAX buffer via __getname_gfp, and then
calls get_fs_names to fill the buffer. That function can call
get_filesystem_list which assumes that that buffer is a full page in
size. On arches where PAGE_SIZE != 4k, then this could potentially
overrun.

In practice, it's hard to imagine the list of filesystem names even
approaching 4k, but it's best to be safe. Just allocate a page for this
purpose instead.

With this, we can also remove the __getname_gfp() definition since there
are no more callers.

Signed-off-by: Jeff Layton 
---
 include/linux/fs.h | 3 +--
 init/do_mounts.c   | 7 ---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index aa11047..69513a7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2221,8 +2221,7 @@ extern void __init vfs_caches_init(unsigned long);
 
 extern struct kmem_cache *names_cachep;
 
-#define __getname_gfp(gfp) kmem_cache_alloc(names_cachep, (gfp))
-#define __getname()__getname_gfp(GFP_KERNEL)
+#define __getname()kmem_cache_alloc(names_cachep, GFP_KERNEL)
 #define __putname(name)kmem_cache_free(names_cachep, (void 
*)(name))
 #ifndef CONFIG_AUDITSYSCALL
 #define putname(name)   __putname(name)
diff --git a/init/do_mounts.c b/init/do_mounts.c
index d3f0aee..f8a6642 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -353,8 +353,9 @@ static int __init do_mount_root(char *name, char *fs, int 
flags, void *data)
 
 void __init mount_block_root(char *name, int flags)
 {
-   char *fs_names = __getname_gfp(GFP_KERNEL
-   | __GFP_NOTRACK_FALSE_POSITIVE);
+   struct page *page = alloc_page(GFP_KERNEL |
+   __GFP_NOTRACK_FALSE_POSITIVE);
+   char *fs_names = page_address(page);
char *p;
 #ifdef CONFIG_BLOCK
char b[BDEVNAME_SIZE];
@@ -406,7 +407,7 @@ retry:
 #endif
panic("VFS: Unable to mount root fs on %s", b);
 out:
-   putname(fs_names);
+   put_page(page);
 }
  
 #ifdef CONFIG_ROOT_NFS
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 12/49] vfs: make dir_name arg to do_mount a const char *

2012-10-01 Thread Jeff Layton
Nothing changes it, so it should be safe to do.

Signed-off-by: Jeff Layton 
---
 fs/namespace.c | 2 +-
 include/linux/fs.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 4d31f73..8e52b1c 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2185,7 +2185,7 @@ int copy_mount_string(const void __user *data, char 
**where)
  * Therefore, if this magic number is present, it carries no information
  * and must be discarded.
  */
-long do_mount(char *dev_name, char *dir_name, char *type_page,
+long do_mount(char *dev_name, const char *dir_name, char *type_page,
  unsigned long flags, void *data_page)
 {
struct path path;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 69513a7..b6ce6fc 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2072,7 +2072,7 @@ extern struct vfsmount *kern_mount_data(struct 
file_system_type *, void *data);
 extern void kern_unmount(struct vfsmount *mnt);
 extern int may_umount_tree(struct vfsmount *);
 extern int may_umount(struct vfsmount *);
-extern long do_mount(char *, char *, char *, unsigned long, void *);
+extern long do_mount(char *, const char *, char *, unsigned long, void *);
 extern struct vfsmount *collect_mounts(struct path *);
 extern void drop_collected_mounts(struct vfsmount *);
 extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 13/49] acct: constify the name arg to acct_on

2012-10-01 Thread Jeff Layton
Signed-off-by: Jeff Layton 
---
 kernel/acct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/acct.c b/kernel/acct.c
index 02e6167..e97d159 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -193,7 +193,7 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, 
struct file *file,
}
 }
 
-static int acct_on(char *name)
+static int acct_on(const char *name)
 {
struct file *file;
struct vfsmount *mnt;
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 14/49] vfs: define getname_info struct and have getname() return it

2012-10-01 Thread Jeff Layton
getname() is intended to copy pathname strings from userspace into a
kernel buffer. The result is just a string in kernel space. It would
however be quite helpful to be able to attach some ancillary info to
the string.

For instance, we could attach some audit-related info to reduce the
amount of audit-related processing needed. When auditing is enabled,
we could also call getname() on the string more than once and not
need to recopy it from userspace.

This patchset converts the getname()/putname() interfaces to return
a struct instead of a string. For now, the struct just tracks the
string in kernel space and the original userland pointer for it.

Later, we'll add other information to the struct as it becomes
convenient.

Signed-off-by: Jeff Layton 
---
 arch/alpha/kernel/osf_sys.c |  16 ++---
 arch/avr32/kernel/process.c |   4 +-
 arch/blackfin/kernel/process.c  |   4 +-
 arch/cris/arch-v10/kernel/process.c |   4 +-
 arch/cris/arch-v32/kernel/process.c |   4 +-
 arch/h8300/kernel/process.c |   4 +-
 arch/hexagon/kernel/syscall.c   |   4 +-
 arch/ia64/kernel/process.c  |   4 +-
 arch/m32r/kernel/process.c  |   4 +-
 arch/microblaze/kernel/sys_microblaze.c |   4 +-
 arch/mips/kernel/linux32.c  |   4 +-
 arch/mips/kernel/syscall.c  |   4 +-
 arch/openrisc/kernel/process.c  |   4 +-
 arch/parisc/hpux/fs.c   |   4 +-
 arch/parisc/kernel/process.c|   4 +-
 arch/parisc/kernel/sys_parisc32.c   |   4 +-
 arch/score/kernel/sys_score.c   |   4 +-
 arch/sh/kernel/process_32.c |   4 +-
 arch/sh/kernel/process_64.c |   4 +-
 arch/tile/kernel/process.c  |   8 +--
 arch/unicore32/kernel/sys.c |   4 +-
 arch/xtensa/kernel/process.c|   4 +-
 fs/compat.c |  12 ++--
 fs/exec.c   |  13 ++--
 fs/filesystems.c|   4 +-
 fs/namei.c  | 113 +++-
 fs/namespace.c  |   4 +-
 fs/open.c   |   4 +-
 fs/quota/quota.c|   4 +-
 include/linux/audit.h   |   8 ++-
 include/linux/fs.h  |  14 +++-
 ipc/mqueue.c|  13 ++--
 kernel/acct.c   |   4 +-
 kernel/auditsc.c|  86 +---
 mm/swapfile.c   |  11 ++--
 35 files changed, 218 insertions(+), 176 deletions(-)

diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index bc1acdd..b3f41e8 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -452,7 +452,7 @@ osf_ufs_mount(char *dirname, struct ufs_args __user *args, 
int flags)
 {
int retval;
struct cdfs_args tmp;
-   char *devname;
+   struct getname_info *devname;
 
retval = -EFAULT;
if (copy_from_user(, args, sizeof(tmp)))
@@ -461,7 +461,7 @@ osf_ufs_mount(char *dirname, struct ufs_args __user *args, 
int flags)
retval = PTR_ERR(devname);
if (IS_ERR(devname))
goto out;
-   retval = do_mount(devname, dirname, "ext2", flags, NULL);
+   retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
putname(devname);
  out:
return retval;
@@ -472,7 +472,7 @@ osf_cdfs_mount(char *dirname, struct cdfs_args __user 
*args, int flags)
 {
int retval;
struct cdfs_args tmp;
-   char *devname;
+   struct getname_info *devname;
 
retval = -EFAULT;
if (copy_from_user(, args, sizeof(tmp)))
@@ -481,7 +481,7 @@ osf_cdfs_mount(char *dirname, struct cdfs_args __user 
*args, int flags)
retval = PTR_ERR(devname);
if (IS_ERR(devname))
goto out;
-   retval = do_mount(devname, dirname, "iso9660", flags, NULL);
+   retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
putname(devname);
  out:
return retval;
@@ -502,7 +502,7 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const 
char __user *, path,
int, flag, void __user *, data)
 {
int retval;
-   char *name;
+   struct getname_info *name;
 
name = getname(path);
retval = PTR_ERR(name);
@@ -510,13 +510,13 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const 
char __user *, path,
goto out;
switch (typenr) {
case 1:
-   retval = osf_ufs_mount(name, data, flag);
+   retval = osf_ufs_mount(name->name, data, flag);
break;
case 6:
-   retval = osf_cdfs_mount(name, data, flag);
+   retval = osf_cdfs_mount(name->name, data, flag);
break;
case 9:
-   retval = osf_procfs_mount(name, data, flag);
+   retval = 

[PATCH v7 15/49] audit: allow audit code to satisfy getname requests from its names_list

2012-10-01 Thread Jeff Layton
Currently, if we call getname() on a userland string more than once,
we'll get multiple copies of the string and multiple audit_names
records.

Add a function that will allow the audit_names code to satisfy getname
requests using info from the audit_names list, avoiding a new allocation
and audit_names records.

Signed-off-by: Jeff Layton 
---
 fs/namei.c|  4 
 include/linux/audit.h |  8 
 kernel/auditsc.c  | 23 +++
 3 files changed, 35 insertions(+)

diff --git a/fs/namei.c b/fs/namei.c
index 60db390..01a2dd18 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -130,6 +130,10 @@ getname_flags(const char __user *filename, int flags, int 
*empty)
char *kname;
int len;
 
+   result = audit_reusename(filename);
+   if (result)
+   return result;
+
/* FIXME: create dedicated slabcache? */
result = kzalloc(sizeof(*result), GFP_KERNEL);
if (unlikely(!result))
diff --git a/include/linux/audit.h b/include/linux/audit.h
index d361921..ea58de3 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -469,6 +469,7 @@ extern void __audit_syscall_entry(int arch,
  int major, unsigned long a0, unsigned long a1,
  unsigned long a2, unsigned long a3);
 extern void __audit_syscall_exit(int ret_success, long ret_value);
+extern struct getname_info *__audit_reusename(const __user char *uptr);
 extern void __audit_getname(struct getname_info *ginfo);
 extern void audit_putname(struct getname_info *ginfo);
 extern void __audit_inode(const char *name, const struct dentry *dentry,
@@ -505,6 +506,12 @@ static inline void audit_syscall_exit(void *pt_regs)
__audit_syscall_exit(success, return_code);
}
 }
+static inline struct getname_info *audit_reusename(const __user char *name)
+{
+   if (unlikely(!audit_dummy_context()))
+   return __audit_reusename(name);
+   return NULL;
+}
 static inline void audit_getname(struct getname_info *name)
 {
if (unlikely(!audit_dummy_context()))
@@ -642,6 +649,7 @@ extern int audit_signals;
 #define audit_syscall_entry(ta,a,b,c,d,e) do { ; } while (0)
 #define audit_syscall_exit(r) do { ; } while (0)
 #define audit_dummy_context() 1
+#define audit_reusename(g) ({ NULL; })
 #define audit_getname(n) do { ; } while (0)
 #define audit_putname(n) do { ; } while (0)
 #define __audit_inode(n,d,p) do { ; } while (0)
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 0ba346b..89974ca 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -2035,6 +2035,29 @@ static struct audit_names *audit_alloc_name(struct 
audit_context *context,
 }
 
 /**
+ * audit_reusename - fill out getname_info with info from existing entry
+ * @uptr: userland ptr to pathname
+ *
+ * Search the audit_names list for the current audit context. If there is an
+ * existing entry with a matching "uptr" then return the getname_info
+ * associated with that audit_name. If not, return NULL.
+ */
+struct getname_info *
+__audit_reusename(const __user char *uptr)
+{
+   struct audit_context *context = current->audit_context;
+   struct audit_names *n;
+
+   list_for_each_entry(n, >names_list, list) {
+   if (!n->ginfo)
+   continue;
+   if (n->ginfo->uptr == uptr)
+   return n->ginfo;
+   }
+   return NULL;
+}
+
+/**
  * audit_getname - add a name to the list
  * @name: name to add
  *
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 16/49] vfs: turn do_path_lookup into wrapper around getname_info variant

2012-10-01 Thread Jeff Layton
...and make the user_path callers use that variant instead.

Signed-off-by: Jeff Layton 
---
 fs/namei.c | 30 +++---
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 01a2dd18..5e31fbb 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1993,20 +1993,30 @@ static int path_lookupat(int dfd, const char *name,
return err;
 }
 
-static int do_path_lookup(int dfd, const char *name,
+static int ginfo_lookup(int dfd, struct getname_info *ginfo,
unsigned int flags, struct nameidata *nd)
 {
-   int retval = path_lookupat(dfd, name, flags | LOOKUP_RCU, nd);
+   int retval = path_lookupat(dfd, ginfo->name, flags | LOOKUP_RCU, nd);
if (unlikely(retval == -ECHILD))
-   retval = path_lookupat(dfd, name, flags, nd);
+   retval = path_lookupat(dfd, ginfo->name, flags, nd);
if (unlikely(retval == -ESTALE))
-   retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd);
+   retval = path_lookupat(dfd, ginfo->name,
+   flags | LOOKUP_REVAL, nd);
 
if (likely(!retval))
-   audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
+   audit_inode(ginfo->name, nd->path.dentry,
+   flags & LOOKUP_PARENT);
return retval;
 }
 
+static int do_path_lookup(int dfd, const char *name,
+   unsigned int flags, struct nameidata *nd)
+{
+   struct getname_info ginfo = { .name = name };
+
+   return ginfo_lookup(dfd, , flags, nd);
+}
+
 /* does lookup, returns the object with parent locked */
 struct dentry *kern_path_locked(const char *name, struct path *path)
 {
@@ -2130,7 +2140,7 @@ int user_path_at_empty(int dfd, const char __user *name, 
unsigned flags,
 
BUG_ON(flags & LOOKUP_PARENT);
 
-   err = do_path_lookup(dfd, tmp->name, flags, );
+   err = ginfo_lookup(dfd, tmp, flags, );
putname(tmp);
if (!err)
*path = nd.path;
@@ -2144,6 +2154,12 @@ int user_path_at(int dfd, const char __user *name, 
unsigned flags,
return user_path_at_empty(dfd, name, flags, path, NULL);
 }
 
+/*
+ * NB: most callers don't do anything directly with the reference to the
+ * to ginfo, but the nd->last pointer points into the name string
+ * allocated by getname. So we must hold the reference to it until all
+ * path-walking is complete.
+ */
 static struct getname_info *
 user_path_parent(int dfd, const char __user *path, struct nameidata *nd)
 {
@@ -2153,7 +2169,7 @@ user_path_parent(int dfd, const char __user *path, struct 
nameidata *nd)
if (IS_ERR(s))
return s;
 
-   error = do_path_lookup(dfd, s->name, LOOKUP_PARENT, nd);
+   error = ginfo_lookup(dfd, s, LOOKUP_PARENT, nd);
if (error) {
putname(s);
return ERR_PTR(error);
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] The nested NMI modifies the place (instruction, flags and stack)

2012-10-01 Thread Salman Qazi
that the first NMI will iret to.  However, the copy of registers
modified is exactly the one that is the part of pt_regs in
the first NMI.  This can change the behaviour of the first NMI.

In particular, Google's arch_trigger_all_cpu_backtrace handler
also prints regions of memory surrounding addresses appearing in
registers.  This results in handled exceptions, after which nested NMIs
start coming in.  These nested NMIs change the value of registers
in pt_regs.  This can cause the original NMI handler to produce
incorrect output.

We solve this problem by interchanging the position of the preserved
copy of the iret registers ("saved") and the copy subject to being
trampled by nested NMI ("copied").

Signed-off-by: Salman Qazi 
---
 arch/x86/kernel/entry_64.S |   41 +++--
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 44531ac..b5d6e43 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1739,9 +1739,10 @@ nested_nmi:
 
 1:
/* Set up the interrupted NMIs stack to jump to repeat_nmi */
-   leaq -6*8(%rsp), %rdx
+   leaq -1*8(%rsp), %rdx
movq %rdx, %rsp
-   CFI_ADJUST_CFA_OFFSET 6*8
+   CFI_ADJUST_CFA_OFFSET 1*8
+   leaq -10*8(%rsp), %rdx
pushq_cfi $__KERNEL_DS
pushq_cfi %rdx
pushfq_cfi
@@ -1749,8 +1750,8 @@ nested_nmi:
pushq_cfi $repeat_nmi
 
/* Put stack back */
-   addq $(11*8), %rsp
-   CFI_ADJUST_CFA_OFFSET -11*8
+   addq $(6*8), %rsp
+   CFI_ADJUST_CFA_OFFSET -6*8
 
 nested_nmi_out:
popq_cfi %rdx
@@ -1776,18 +1777,18 @@ first_nmi:
 * +-+
 * | NMI executing variable  |
 * +-+
-* | Saved SS|
-* | Saved Return RSP|
-* | Saved RFLAGS|
-* | Saved CS|
-* | Saved RIP   |
-* +-+
 * | copied SS   |
 * | copied Return RSP   |
 * | copied RFLAGS   |
 * | copied CS   |
 * | copied RIP  |
 * +-+
+* | Saved SS|
+* | Saved Return RSP|
+* | Saved RFLAGS|
+* | Saved CS|
+* | Saved RIP   |
+* +-+
 * | pt_regs |
 * +-+
 *
@@ -1803,9 +1804,14 @@ first_nmi:
/* Set the NMI executing variable on the stack. */
pushq_cfi $1
 
+   /*
+* Leave room for the "copied" frame
+*/
+   subq $(5*8), %rsp
+
/* Copy the stack frame to the Saved frame */
.rept 5
-   pushq_cfi 6*8(%rsp)
+   pushq_cfi 11*8(%rsp)
.endr
CFI_DEF_CFA_OFFSET SS+8-RIP
 
@@ -1826,12 +1832,15 @@ repeat_nmi:
 * is benign for the non-repeat case, where 1 was pushed just above
 * to this very stack slot).
 */
-   movq $1, 5*8(%rsp)
+   movq $1, 10*8(%rsp)
 
/* Make another copy, this one may be modified by nested NMIs */
+   addq $(10*8), %rsp
.rept 5
-   pushq_cfi 4*8(%rsp)
+   pushq_cfi -6*8(%rsp)
.endr
+   subq $(5*8), %rsp
+
CFI_DEF_CFA_OFFSET SS+8-RIP
 end_repeat_nmi:
 
@@ -1882,8 +1891,12 @@ nmi_swapgs:
SWAPGS_UNSAFE_STACK
 nmi_restore:
RESTORE_ALL 8
+
+   /* Pop the extra iret frame */
+   addq $(5*8), %rsp
+
/* Clear the NMI executing stack variable */
-   movq $0, 10*8(%rsp)
+   movq $0, 5*8(%rsp)
jmp irq_return
CFI_ENDPROC
 END(nmi)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 17/49] vfs: make path_openat take a getname_info pointer

2012-10-01 Thread Jeff Layton
...and fix up the callers. For do_file_open_root, just declare a
getname_info on the stack and fill out the .name field. For
do_filp_open, make it also take a getname_info pointer, and fix up its
callers to call it appropriately.

For filp_open, add a variant that takes a getname_info pointer and turn
filp_open into a wrapper around it.

Signed-off-by: Jeff Layton 
---
 fs/exec.c  |  5 +++--
 fs/internal.h  |  4 ++--
 fs/namei.c | 28 +++-
 fs/open.c  | 33 +
 include/linux/fs.h |  1 +
 kernel/acct.c  |  6 +++---
 mm/swapfile.c  |  4 ++--
 7 files changed, 55 insertions(+), 26 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index 222e282..77ea602 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -126,7 +126,7 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
if (IS_ERR(tmp))
goto out;
 
-   file = do_filp_open(AT_FDCWD, tmp->name, _flags, LOOKUP_FOLLOW);
+   file = do_filp_open(AT_FDCWD, tmp, _flags, LOOKUP_FOLLOW);
putname(tmp);
error = PTR_ERR(file);
if (IS_ERR(file))
@@ -761,13 +761,14 @@ struct file *open_exec(const char *name)
 {
struct file *file;
int err;
+   struct getname_info tmp = { .name = name };
static const struct open_flags open_exec_flags = {
.open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC,
.acc_mode = MAY_EXEC | MAY_OPEN,
.intent = LOOKUP_OPEN
};
 
-   file = do_filp_open(AT_FDCWD, name, _exec_flags, LOOKUP_FOLLOW);
+   file = do_filp_open(AT_FDCWD, , _exec_flags, LOOKUP_FOLLOW);
if (IS_ERR(file))
goto out;
 
diff --git a/fs/internal.h b/fs/internal.h
index 371bcc4..ddc0d2c 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -97,8 +97,8 @@ struct open_flags {
int acc_mode;
int intent;
 };
-extern struct file *do_filp_open(int dfd, const char *pathname,
-   const struct open_flags *op, int lookup_flags);
+extern struct file *do_filp_open(int dfd, struct getname_info *ginfo,
+   const struct open_flags *op, int flags);
 extern struct file *do_file_open_root(struct dentry *, struct vfsmount *,
const char *, const struct open_flags *, int lookup_flags);
 
diff --git a/fs/namei.c b/fs/namei.c
index 5e31fbb..048373c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2667,7 +2667,7 @@ out_dput:
  */
 static int do_last(struct nameidata *nd, struct path *path,
   struct file *file, const struct open_flags *op,
-  int *opened, const char *pathname)
+  int *opened, struct getname_info *ginfo)
 {
struct dentry *dir = nd->path.dentry;
int open_flag = op->open_flag;
@@ -2679,6 +2679,7 @@ static int do_last(struct nameidata *nd, struct path 
*path,
struct path save_parent = { .dentry = NULL, .mnt = NULL };
bool retried = false;
int error;
+   const char *pathname = ginfo->name;
 
nd->flags &= ~LOOKUP_PARENT;
nd->flags |= op->intent;
@@ -2913,7 +2914,7 @@ stale_open:
goto retry_lookup;
 }
 
-static struct file *path_openat(int dfd, const char *pathname,
+static struct file *path_openat(int dfd, struct getname_info *ginfo,
struct nameidata *nd, const struct open_flags *op, int flags)
 {
struct file *base = NULL;
@@ -2928,16 +2929,16 @@ static struct file *path_openat(int dfd, const char 
*pathname,
 
file->f_flags = op->open_flag;
 
-   error = path_init(dfd, pathname, flags | LOOKUP_PARENT, nd, );
+   error = path_init(dfd, ginfo->name, flags | LOOKUP_PARENT, nd, );
if (unlikely(error))
goto out;
 
current->total_link_count = 0;
-   error = link_path_walk(pathname, nd);
+   error = link_path_walk(ginfo->name, nd);
if (unlikely(error))
goto out;
 
-   error = do_last(nd, , file, op, , pathname);
+   error = do_last(nd, , file, op, , ginfo);
while (unlikely(error > 0)) { /* trailing symlink */
struct path link = path;
void *cookie;
@@ -2955,7 +2956,7 @@ static struct file *path_openat(int dfd, const char 
*pathname,
error = follow_link(, nd, );
if (unlikely(error))
break;
-   error = do_last(nd, , file, op, , pathname);
+   error = do_last(nd, , file, op, , ginfo);
put_link(nd, , cookie);
}
 out:
@@ -2979,17 +2980,17 @@ out:
return file;
 }
 
-struct file *do_filp_open(int dfd, const char *pathname,
+struct file *do_filp_open(int dfd, struct getname_info *ginfo,
const struct open_flags *op, int flags)
 {
struct nameidata nd;
struct file *filp;
 
-   filp = path_openat(dfd, pathname, , op, flags | LOOKUP_RCU);
+   filp = path_openat(dfd, ginfo, , op, flags | LOOKUP_RCU);
if 

[PATCH v7 18/49] audit: make audit_inode take getname_info

2012-10-01 Thread Jeff Layton
Keep a pointer to the audit_names "slot" in getname_info.

Have all of the audit_inode callers pass a getname_info ponter to
audit_inode instead of a string pointer. If the aname field is already
populated, then we can skip walking the list altogether and just use it
directly.

Signed-off-by: Jeff Layton 
---
 fs/namei.c| 16 +++-
 include/linux/audit.h | 10 +-
 include/linux/fs.h|  6 --
 ipc/mqueue.c  |  4 ++--
 kernel/auditsc.c  | 29 +
 5 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 048373c..5e2f5ae 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2004,8 +2004,7 @@ static int ginfo_lookup(int dfd, struct getname_info 
*ginfo,
flags | LOOKUP_REVAL, nd);
 
if (likely(!retval))
-   audit_inode(ginfo->name, nd->path.dentry,
-   flags & LOOKUP_PARENT);
+   audit_inode(ginfo, nd->path.dentry, flags & LOOKUP_PARENT);
return retval;
 }
 
@@ -2679,7 +2678,6 @@ static int do_last(struct nameidata *nd, struct path 
*path,
struct path save_parent = { .dentry = NULL, .mnt = NULL };
bool retried = false;
int error;
-   const char *pathname = ginfo->name;
 
nd->flags &= ~LOOKUP_PARENT;
nd->flags |= op->intent;
@@ -2695,7 +2693,7 @@ static int do_last(struct nameidata *nd, struct path 
*path,
error = complete_walk(nd);
if (error)
return error;
-   audit_inode(pathname, nd->path.dentry, 0);
+   audit_inode(ginfo, nd->path.dentry, 0);
if (open_flag & O_CREAT) {
error = -EISDIR;
goto out;
@@ -2705,7 +2703,7 @@ static int do_last(struct nameidata *nd, struct path 
*path,
error = complete_walk(nd);
if (error)
return error;
-   audit_inode(pathname, dir, 0);
+   audit_inode(ginfo, dir, 0);
goto finish_open;
}
 
@@ -2734,7 +2732,7 @@ static int do_last(struct nameidata *nd, struct path 
*path,
if (error)
return error;
 
-   audit_inode(pathname, dir, 0);
+   audit_inode(ginfo, dir, 0);
error = -EISDIR;
/* trailing slashes? */
if (nd->last.name[nd->last.len])
@@ -2764,7 +2762,7 @@ retry_lookup:
!S_ISREG(file->f_path.dentry->d_inode->i_mode))
will_truncate = false;
 
-   audit_inode(pathname, file->f_path.dentry, 0);
+   audit_inode(ginfo, file->f_path.dentry, 0);
goto opened;
}
 
@@ -2781,7 +2779,7 @@ retry_lookup:
 * create/update audit record if it already exists.
 */
if (path->dentry->d_inode)
-   audit_inode(pathname, path->dentry, 0);
+   audit_inode(ginfo, path->dentry, 0);
 
/*
 * If atomic_open() acquired write access it is dropped now due to
@@ -2846,7 +2844,7 @@ finish_lookup:
error = -ENOTDIR;
if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup)
goto out;
-   audit_inode(pathname, nd->path.dentry, 0);
+   audit_inode(ginfo, nd->path.dentry, 0);
 finish_open:
if (!S_ISREG(nd->inode->i_mode))
will_truncate = false;
diff --git a/include/linux/audit.h b/include/linux/audit.h
index ea58de3..481cf75 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -472,7 +472,7 @@ extern void __audit_syscall_exit(int ret_success, long 
ret_value);
 extern struct getname_info *__audit_reusename(const __user char *uptr);
 extern void __audit_getname(struct getname_info *ginfo);
 extern void audit_putname(struct getname_info *ginfo);
-extern void __audit_inode(const char *name, const struct dentry *dentry,
+extern void __audit_inode(struct getname_info *ginfo, const struct dentry 
*dentry,
unsigned int parent);
 extern void __audit_inode_child(const struct inode *parent,
const struct dentry *dentry,
@@ -517,10 +517,10 @@ static inline void audit_getname(struct getname_info 
*name)
if (unlikely(!audit_dummy_context()))
__audit_getname(name);
 }
-static inline void audit_inode(const char *name, const struct dentry *dentry,
+static inline void audit_inode(struct getname_info *ginfo, const struct dentry 
*dentry,
unsigned int parent) {
if (unlikely(!audit_dummy_context()))
-   __audit_inode(name, dentry, parent);
+   __audit_inode(ginfo, dentry, parent);
 }
 static inline void audit_inode_child(const struct inode *parent,
 const struct dentry *dentry,
@@ -652,9 +652,9 @@ 

[PATCH v7 19/49] vfs: embed getname_info inside of names_cache allocation if possible

2012-10-01 Thread Jeff Layton
In the common case where a name is much smaller than PATH_MAX, an extra
allocation for struct getname_info is unnecessary. Before allocating a
separate one, try to embed the getname_info inside the buffer first. If
it turns out that that's not long enough, then fall back to allocating a
separate getname_info struct and redoing the copy.

Signed-off-by: Jeff Layton 
---
 fs/namei.c | 69 ++
 include/linux/fs.h |  1 +
 2 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 5e2f5ae..48cb4aa 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -119,40 +119,69 @@
  */
 void final_putname(struct getname_info *ginfo)
 {
-   __putname(ginfo->name);
-   kfree(ginfo);
+   if (ginfo->separate) {
+   __putname(ginfo->name);
+   kfree(ginfo);
+   } else {
+   __putname(ginfo);
+   }
 }
 
+#define EMBEDDED_NAME_MAX  (PATH_MAX - sizeof(struct getname_info))
+
 static struct getname_info *
 getname_flags(const char __user *filename, int flags, int *empty)
 {
struct getname_info *result, *err;
-   char *kname;
int len;
+   long max;
+   char *kname;
 
result = audit_reusename(filename);
if (result)
return result;
 
-   /* FIXME: create dedicated slabcache? */
-   result = kzalloc(sizeof(*result), GFP_KERNEL);
+   result = __getname();
if (unlikely(!result))
return ERR_PTR(-ENOMEM);
 
-   kname = __getname();
-   if (unlikely(!kname)) {
-   err = ERR_PTR(-ENOMEM);
-   goto error_free_ginfo;
-   }
-
+   /*
+* First, try to embed the getname_info inside the names_cache
+* allocation
+*/
+   kname = (char *)result + sizeof(*result);
result->name = kname;
-   result->uptr = filename;
-   len = strncpy_from_user(kname, filename, PATH_MAX);
+   result->separate = false;
+   max = EMBEDDED_NAME_MAX;
+
+recopy:
+   len = strncpy_from_user(kname, filename, max);
if (unlikely(len < 0)) {
err = ERR_PTR(len);
goto error;
}
 
+   /*
+* Uh-oh. We have a name that's approaching PATH_MAX. Allocate a
+* separate getname_info struct so we can dedicate the entire
+* names_cache allocation for the pathname, and re-do the copy from
+* userland.
+*/
+   if (len == EMBEDDED_NAME_MAX && max == EMBEDDED_NAME_MAX) {
+   kname = (char *)result;
+
+   result = kzalloc(sizeof(*result), GFP_KERNEL);
+   if (!result) {
+   err = ERR_PTR(-ENOMEM);
+   result = (struct getname_info *)kname;
+   goto error;
+   }
+   result->name = kname;
+   result->separate = true;
+   max = PATH_MAX;
+   goto recopy;
+   }
+
/* The empty path is special. */
if (unlikely(!len)) {
if (empty)
@@ -163,15 +192,15 @@ getname_flags(const char __user *filename, int flags, int 
*empty)
}
 
err = ERR_PTR(-ENAMETOOLONG);
-   if (likely(len < PATH_MAX)) {
-   audit_getname(result);
-   return result;
-   }
+   if (unlikely(len >= PATH_MAX))
+   goto error;
+
+   result->uptr = filename;
+   audit_getname(result);
+   return result;
 
 error:
-   __putname(kname);
-error_free_ginfo:
-   kfree(result);
+   final_putname(result);
return err;
 }
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4ce38f2..a3c2c17 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2194,6 +2194,7 @@ struct getname_info {
const char  *name;  /* pointer to actual string */
const __user char   *uptr;  /* original userland pointer */
struct audit_names  *aname;
+   boolseparate; /* should "name" be freed? */
 };
 
 extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 20/49] vfs: unexport getname and putname symbols

2012-10-01 Thread Jeff Layton
I see no callers in module code.

Signed-off-by: Jeff Layton 
---
 fs/namei.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 48cb4aa..d3f8998 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -209,7 +209,6 @@ getname(const char __user * filename)
 {
return getname_flags(filename, 0, NULL);
 }
-EXPORT_SYMBOL(getname);
 
 void putname(struct getname_info *ginfo)
 {
@@ -219,7 +218,6 @@ void putname(struct getname_info *ginfo)
 #endif
final_putname(ginfo);
 }
-EXPORT_SYMBOL(putname);
 
 static int check_acl(struct inode *inode, int mask)
 {
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 21/49] vfs: add a retry_estale helper function to handle retries on ESTALE

2012-10-01 Thread Jeff Layton
This function is expected to be called from path-based syscalls to help
them decide whether to try the lookup and call again in the event that
they got an -ESTALE return back on an earier try.

Currently, we only retry the call once on an ESTALE error, but in the
event that we decide that that's not enough in the future, we should be
able to change the logic in this helper without too much effort.

Signed-off-by: Jeff Layton 
---
 include/linux/fs.h | 21 +
 1 file changed, 21 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index a3c2c17..78e8639 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2221,6 +2221,27 @@ extern int finish_open(struct file *file, struct dentry 
*dentry,
int *opened);
 extern int finish_no_open(struct file *file, struct dentry *dentry);
 
+/**
+ * retry_estale - determine whether the caller should retry an operation
+ *
+ * @error: the error we'll be returning
+ * @try: number of retries already performed
+ *
+ * Check to see if the error code was -ESTALE, and then determine whether
+ * to retry the call based on the number of retries so far. Currently, we only
+ * retry the call once.
+ *
+ * Returns true if the caller should try again.
+ */
+static inline bool
+retry_estale(const long error, const unsigned int try)
+{
+   if (likely(error != -ESTALE))
+   return false;
+
+   return !try;
+}
+
 /* fs/ioctl.c */
 
 extern int ioctl_preallocate(struct file *filp, void __user *argp);
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 22/49] vfs: make fstatat retry on ESTALE errors from getattr call

2012-10-01 Thread Jeff Layton
Signed-off-by: Jeff Layton 
---
 fs/stat.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/stat.c b/fs/stat.c
index 4078022..7f1602a 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -74,7 +74,8 @@ int vfs_fstatat(int dfd, const char __user *filename, struct 
kstat *stat,
 {
struct path path;
int error = -EINVAL;
-   int lookup_flags = 0;
+   unsigned int try = 0;
+   unsigned int lookup_flags = 0;
 
if ((flag & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT |
  AT_EMPTY_PATH)) != 0)
@@ -85,12 +86,15 @@ int vfs_fstatat(int dfd, const char __user *filename, 
struct kstat *stat,
if (flag & AT_EMPTY_PATH)
lookup_flags |= LOOKUP_EMPTY;
 
-   error = user_path_at(dfd, filename, lookup_flags, );
-   if (error)
-   goto out;
+   do {
+   error = user_path_at(dfd, filename, lookup_flags, );
+   if (error)
+   break;
 
-   error = vfs_getattr(path.mnt, path.dentry, stat);
-   path_put();
+   error = vfs_getattr(path.mnt, path.dentry, stat);
+   path_put();
+   lookup_flags |= LOOKUP_REVAL;
+   } while (retry_estale(error, try++));
 out:
return error;
 }
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 23/49] vfs: fix readlinkat to retry on ESTALE

2012-10-01 Thread Jeff Layton
Signed-off-by: Jeff Layton 
---
 fs/stat.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/stat.c b/fs/stat.c
index 7f1602a..ede71cb 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -300,14 +300,21 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user 
*, pathname,
struct path path;
int error;
int empty = 0;
+   unsigned int try = 0;
+   unsigned int lookup_flags = LOOKUP_EMPTY;
 
if (bufsiz <= 0)
return -EINVAL;
 
-   error = user_path_at_empty(dfd, pathname, LOOKUP_EMPTY, , );
-   if (!error) {
-   struct inode *inode = path.dentry->d_inode;
+   do {
+   struct inode *inode;
+
+   error = user_path_at_empty(dfd, pathname, lookup_flags,
+  , );
+   if (error)
+   break;
 
+   inode = path.dentry->d_inode;
error = empty ? -ENOENT : -EINVAL;
if (inode->i_op->readlink) {
error = security_inode_readlink(path.dentry);
@@ -318,7 +325,8 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user *, 
pathname,
}
}
path_put();
-   }
+   lookup_flags |= LOOKUP_REVAL;
+   } while (retry_estale(error, try++));
return error;
 }
 
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 24/49] vfs: add new "reval" argument to kern_path_create and user_path_create

2012-10-01 Thread Jeff Layton
...for now, all of the callers pass in "false". Eventually, we'll set
that to "true" when we retry the lookup after getting back an ESTALE on
a call.

While we're at it, change the is_dir arg to a bool since that's how it's
used currently.

Signed-off-by: Jeff Layton 
---
 arch/powerpc/platforms/cell/spufs/syscalls.c |  2 +-
 drivers/base/devtmpfs.c  |  7 ---
 fs/namei.c   | 23 +++
 fs/ocfs2/refcounttree.c  |  3 ++-
 include/linux/namei.h|  4 ++--
 net/unix/af_unix.c   |  2 +-
 6 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c 
b/arch/powerpc/platforms/cell/spufs/syscalls.c
index 5b7d8ff..cb4acc7 100644
--- a/arch/powerpc/platforms/cell/spufs/syscalls.c
+++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
@@ -66,7 +66,7 @@ static long do_spu_create(const char __user *pathname, 
unsigned int flags,
struct dentry *dentry;
int ret;
 
-   dentry = user_path_create(AT_FDCWD, pathname, , 1);
+   dentry = user_path_create(AT_FDCWD, pathname, , true, false);
ret = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
ret = spufs_create(, dentry, flags, mode, neighbor);
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index deb4a45..2124437 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -148,7 +148,7 @@ static int dev_mkdir(const char *name, umode_t mode)
struct path path;
int err;
 
-   dentry = kern_path_create(AT_FDCWD, name, , 1);
+   dentry = kern_path_create(AT_FDCWD, name, , true, false);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
 
@@ -193,10 +193,11 @@ static int handle_create(const char *nodename, umode_t 
mode, struct device *dev)
struct path path;
int err;
 
-   dentry = kern_path_create(AT_FDCWD, nodename, , 0);
+   dentry = kern_path_create(AT_FDCWD, nodename, , false, false);
if (dentry == ERR_PTR(-ENOENT)) {
create_path(nodename);
-   dentry = kern_path_create(AT_FDCWD, nodename, , 0);
+   dentry = kern_path_create(AT_FDCWD, nodename, ,
+   false, false);
}
if (IS_ERR(dentry))
return PTR_ERR(dentry);
diff --git a/fs/namei.c b/fs/namei.c
index d3f8998..6c75fc1 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3042,12 +3042,18 @@ struct file *do_file_open_root(struct dentry *dentry, 
struct vfsmount *mnt,
return file;
 }
 
-struct dentry *kern_path_create(int dfd, const char *pathname, struct path 
*path, int is_dir)
+struct dentry *kern_path_create(int dfd, const char *pathname, struct path 
*path, bool is_dir, bool reval)
 {
struct dentry *dentry = ERR_PTR(-EEXIST);
struct nameidata nd;
int err2;
-   int error = do_path_lookup(dfd, pathname, LOOKUP_PARENT, );
+   int error;
+   unsigned int lookup_flags = LOOKUP_PARENT;
+
+   if (reval)
+   lookup_flags |= LOOKUP_REVAL;
+
+   error = do_path_lookup(dfd, pathname, lookup_flags, );
if (error)
return ERR_PTR(error);
 
@@ -3111,13 +3117,14 @@ void done_path_create(struct path *path, struct dentry 
*dentry)
 }
 EXPORT_SYMBOL(done_path_create);
 
-struct dentry *user_path_create(int dfd, const char __user *pathname, struct 
path *path, int is_dir)
+struct dentry *user_path_create(int dfd, const char __user *pathname,
+   struct path *path, bool is_dir, bool reval)
 {
struct getname_info *tmp = getname(pathname);
struct dentry *res;
if (IS_ERR(tmp))
return ERR_CAST(tmp);
-   res = kern_path_create(dfd, tmp->name, path, is_dir);
+   res = kern_path_create(dfd, tmp->name, path, is_dir, reval);
putname(tmp);
return res;
 }
@@ -3178,7 +3185,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, 
filename, umode_t, mode,
if (error)
return error;
 
-   dentry = user_path_create(dfd, filename, , 0);
+   dentry = user_path_create(dfd, filename, , false, false);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
 
@@ -3240,7 +3247,7 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, 
pathname, umode_t, mode)
struct path path;
int error;
 
-   dentry = user_path_create(dfd, pathname, , 1);
+   dentry = user_path_create(dfd, pathname, , true, false);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
 
@@ -3516,7 +3523,7 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
if (IS_ERR(from))
return PTR_ERR(from);
 
-   dentry = user_path_create(newdfd, newname, , 0);
+   dentry = user_path_create(newdfd, newname, , false, false);
error = PTR_ERR(dentry);

[PATCH v7 25/49] vfs: fix mknodat to retry on ESTALE errors

2012-10-01 Thread Jeff Layton
Signed-off-by: Jeff Layton 
---
 fs/namei.c | 43 +--
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 6c75fc1..ac62973 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3180,34 +3180,41 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, 
filename, umode_t, mode,
struct dentry *dentry;
struct path path;
int error;
+   unsigned int try = 0;
 
error = may_mknod(mode);
if (error)
return error;
 
-   dentry = user_path_create(dfd, filename, , false, false);
-   if (IS_ERR(dentry))
-   return PTR_ERR(dentry);
+   do {
+   dentry = user_path_create(dfd, filename, , false, try);
+   if (IS_ERR(dentry))
+   return PTR_ERR(dentry);
 
-   if (!IS_POSIXACL(path.dentry->d_inode))
-   mode &= ~current_umask();
-   error = security_path_mknod(, dentry, mode, dev);
-   if (error)
-   goto out;
-   switch (mode & S_IFMT) {
-   case 0: case S_IFREG:
-   error = 
vfs_create(path.dentry->d_inode,dentry,mode,true);
+   if (!IS_POSIXACL(path.dentry->d_inode))
+   mode &= ~current_umask();
+   error = security_path_mknod(, dentry, mode, dev);
+   if (error)
+   goto out;
+   switch (mode & S_IFMT) {
+   case 0:
+   case S_IFREG:
+   error = vfs_create(path.dentry->d_inode, dentry,
+   mode, true);
break;
-   case S_IFCHR: case S_IFBLK:
-   error = vfs_mknod(path.dentry->d_inode,dentry,mode,
+   case S_IFCHR:
+   case S_IFBLK:
+   error = vfs_mknod(path.dentry->d_inode, dentry, mode,
new_decode_dev(dev));
break;
-   case S_IFIFO: case S_IFSOCK:
-   error = vfs_mknod(path.dentry->d_inode,dentry,mode,0);
-   break;
-   }
+   case S_IFIFO:
+   case S_IFSOCK:
+   error = vfs_mknod(path.dentry->d_inode, dentry,
+   mode, 0);
+   }
 out:
-   done_path_create(, dentry);
+   done_path_create(, dentry);
+   } while (retry_estale(error, try++));
return error;
 }
 
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 26/49] vfs: fix mkdir to retry on ESTALE errors

2012-10-01 Thread Jeff Layton
Signed-off-by: Jeff Layton 
---
 fs/namei.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index ac62973..dd1d519 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3253,17 +3253,20 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, 
pathname, umode_t, mode)
struct dentry *dentry;
struct path path;
int error;
+   unsigned int try = 0;
 
-   dentry = user_path_create(dfd, pathname, , true, false);
-   if (IS_ERR(dentry))
-   return PTR_ERR(dentry);
+   do {
+   dentry = user_path_create(dfd, pathname, , true, false);
+   if (IS_ERR(dentry))
+   return PTR_ERR(dentry);
 
-   if (!IS_POSIXACL(path.dentry->d_inode))
-   mode &= ~current_umask();
-   error = security_path_mkdir(, dentry, mode);
-   if (!error)
-   error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
-   done_path_create(, dentry);
+   if (!IS_POSIXACL(path.dentry->d_inode))
+   mode &= ~current_umask();
+   error = security_path_mkdir(, dentry, mode);
+   if (!error)
+   error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
+   done_path_create(, dentry);
+   } while (retry_estale(error, try++));
return error;
 }
 
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 27/49] vfs: fix symlinkat to retry on ESTALE errors

2012-10-01 Thread Jeff Layton
Signed-off-by: Jeff Layton 
---
 fs/namei.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index dd1d519..fb9d36f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3528,21 +3528,25 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
struct getname_info *from;
struct dentry *dentry;
struct path path;
+   unsigned int try = 0;
 
from = getname(oldname);
if (IS_ERR(from))
return PTR_ERR(from);
 
-   dentry = user_path_create(newdfd, newname, , false, false);
-   error = PTR_ERR(dentry);
-   if (IS_ERR(dentry))
-   goto out_putname;
+   do {
+   dentry = user_path_create(newdfd, newname, , false, false);
+   if (IS_ERR(dentry)) {
+   error = PTR_ERR(dentry);
+   break;
+   }
 
-   error = security_path_symlink(, dentry, from->name);
-   if (!error)
-   error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
-   done_path_create(, dentry);
-out_putname:
+   error = security_path_symlink(, dentry, from->name);
+   if (!error)
+   error = vfs_symlink(path.dentry->d_inode, dentry,
+   from->name);
+   done_path_create(, dentry);
+   } while (retry_estale(error, try++));
putname(from);
return error;
 }
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >