Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a06f7d9e authored by Kevin Hilman's avatar Kevin Hilman
Browse files

Merge branch 'android-3.18' of https://android.googlesource.com/kernel/common...

Merge branch 'android-3.18' of https://android.googlesource.com/kernel/common into linux-linaro-lsk-v3.18-android

* 'android-3.18' of https://android.googlesource.com/kernel/common:
  usb: gadget: fix NULL ptr derefer while symlinking PTP func
  uid_cputime: Iterates over all the threads instead of processes.
  Fix generic cgroup subsystem permission checks
  uid_cputime: fix cputime overflow
  usb:gadget:Add "state" attribute to android_device
  cpufreq_stats: fix use of cpufreq_for_each_valid_entry() iterator
  initramfs: Add skip_initramfs command line option
  cpu_power: Avoids race condition when the task exits.
  uid_cputime: Avoids double accounting of process stime, utime and cpu_power in task exit.
  Shrink ashmem directly through shmem_fallocate
parents 56f9fcf4 c44a699d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ void acct_update_power(struct task_struct *task, cputime_t cputime) {
		return;

	curr = powerstats->curr[stats->last_index];
	if (task->cpu_power != ULLONG_MAX)
		task->cpu_power += curr * cputime_to_usecs(cputime);
}
EXPORT_SYMBOL_GPL(acct_update_power);
+15 −7
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ static struct uid_entry *find_or_register_uid(uid_t uid)
static int uid_stat_show(struct seq_file *m, void *v)
{
	struct uid_entry *uid_entry;
	struct task_struct *task;
	struct task_struct *task, *temp;
	cputime_t utime;
	cputime_t stime;
	unsigned long bkt;
@@ -89,7 +89,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
	}

	read_lock(&tasklist_lock);
	for_each_process(task) {
	do_each_thread(temp, task) {
		uid_entry = find_or_register_uid(from_kuid_munged(
			current_user_ns(), task_uid(task)));
		if (!uid_entry) {
@@ -100,11 +100,16 @@ static int uid_stat_show(struct seq_file *m, void *v)
				task_uid(task)));
			return -ENOMEM;
		}
		/* if this task is exiting, we have already accounted for the
		 * time and power.
		 */
		if (task->cpu_power == ULLONG_MAX)
			continue;
		task_cputime_adjusted(task, &utime, &stime);
		uid_entry->active_utime += utime;
		uid_entry->active_stime += stime;
		uid_entry->active_power += task->cpu_power;
	}
	} while_each_thread(temp, task);
	read_unlock(&tasklist_lock);

	hash_for_each(hash_table, bkt, uid_entry, hash) {
@@ -114,9 +119,11 @@ static int uid_stat_show(struct seq_file *m, void *v)
							uid_entry->active_stime;
		unsigned long long total_power = uid_entry->power +
							uid_entry->active_power;
		seq_printf(m, "%d: %u %u %llu\n", uid_entry->uid,
						cputime_to_usecs(total_utime),
						cputime_to_usecs(total_stime),
		seq_printf(m, "%d: %llu %llu %llu\n", uid_entry->uid,
			(unsigned long long)jiffies_to_msecs(
				cputime_to_jiffies(total_utime)) * USEC_PER_MSEC,
			(unsigned long long)jiffies_to_msecs(
				cputime_to_jiffies(total_stime)) * USEC_PER_MSEC,
			total_power);
	}

@@ -211,6 +218,7 @@ static int process_notifier(struct notifier_block *self,
	uid_entry->utime += utime;
	uid_entry->stime += stime;
	uid_entry->power += task->cpu_power;
	task->cpu_power = ULLONG_MAX;

exit:
	mutex_unlock(&uid_lock);
+1 −1
Original line number Diff line number Diff line
@@ -440,7 +440,7 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
		loff_t start = range->pgstart * PAGE_SIZE;
		loff_t end = (range->pgend + 1) * PAGE_SIZE;

		do_fallocate(range->asma->file,
		range->asma->file->f_op->fallocate(range->asma->file,
				FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
				start, end - start);
		range->purged = ASHMEM_WAS_PURGED;
+70 −1
Original line number Diff line number Diff line
@@ -436,6 +436,11 @@ static int config_usb_cfg_link(
	}

	f = usb_get_function(fi);
	if (f == NULL) {
		/* Are we trying to symlink PTP without MTP function? */
		ret = -EINVAL; /* Invalid Configuration */
		goto out;
	}
	if (IS_ERR(f)) {
		ret = PTR_ERR(f);
		goto out;
@@ -1608,11 +1613,49 @@ static const struct usb_gadget_driver configfs_driver_template = {
	},
};

#ifdef CONFIG_USB_CONFIGFS_UEVENT
static ssize_t state_show(struct device *pdev, struct device_attribute *attr,
			char *buf)
{
	struct gadget_info *dev = dev_get_drvdata(pdev);
	struct usb_composite_dev *cdev;
	char *state = "DISCONNECTED";
	unsigned long flags;

	if (!dev)
		goto out;

	cdev = &dev->cdev;

	if (!cdev)
		goto out;

	spin_lock_irqsave(&cdev->lock, flags);
	if (cdev->config)
		state = "CONFIGURED";
	else if (dev->connected)
		state = "CONNECTED";
	spin_unlock_irqrestore(&cdev->lock, flags);
out:
	return sprintf(buf, "%s\n", state);
}

static DEVICE_ATTR(state, S_IRUGO, state_show, NULL);

static struct device_attribute *android_usb_attributes[] = {
	&dev_attr_state,
	NULL
};
#endif

static struct config_group *gadgets_make(
		struct config_group *group,
		const char *name)
{
	struct gadget_info *gi;
	struct device_attribute **attrs;
	struct device_attribute *attr;
	int err;

	gi = kzalloc(sizeof(*gi), GFP_KERNEL);
	if (!gi)
@@ -1658,10 +1701,19 @@ static struct config_group *gadgets_make(
				MKDEV(0, 0), NULL, "android0");
	if (IS_ERR(android_device))
		goto err;

	dev_set_drvdata(android_device, gi);

	attrs = android_usb_attributes;
	while ((attr = *attrs++)) {
		err = device_create_file(android_device, attr);
		if (err)
			goto err1;
	}
#endif

	if (!gi->composite.gadget_driver.function)
		goto err;
		goto err1;

#ifdef CONFIG_USB_OTG
	gi->otg.bLength = sizeof(struct usb_otg_descriptor);
@@ -1672,6 +1724,16 @@ static struct config_group *gadgets_make(
	config_group_init_type_name(&gi->group, name,
				&gadget_root_type);
	return &gi->group;

err1:
#ifdef CONFIG_USB_CONFIGFS_UEVENT
	attrs = android_usb_attributes;
	while ((attr = *attrs++))
		device_remove_file(android_device, attr);

	device_destroy(android_device->class,
				android_device->devt);
#endif
err:
	kfree(gi);
	return ERR_PTR(-ENOMEM);
@@ -1679,8 +1741,15 @@ err:

static void gadgets_drop(struct config_group *group, struct config_item *item)
{
	struct device_attribute **attrs;
	struct device_attribute *attr;

	config_item_put(item);

#ifdef CONFIG_USB_CONFIGFS_UEVENT
	attrs = android_usb_attributes;
	while ((attr = *attrs++))
		device_remove_file(android_device, attr);
	device_destroy(android_device->class, android_device->devt);
#endif
}
+17 −1
Original line number Diff line number Diff line
@@ -1426,8 +1426,24 @@ struct usb_function *function_alloc_mtp_ptp(struct usb_function_instance *fi,
					bool mtp_config)
{
	struct mtp_instance *fi_mtp = to_fi_mtp(fi);
	struct mtp_dev *dev = fi_mtp->dev;
	struct mtp_dev *dev;

	/*
	 * PTP piggybacks on MTP function so make sure we have
	 * created MTP function before we associate this PTP
	 * function with a gadget configuration.
	 */
	if (fi_mtp->dev == NULL) {
		pr_err("Error: Create MTP function before linking"
				" PTP function with a gadget configuration\n");
		pr_err("\t1: Delete existing PTP function if any\n");
		pr_err("\t2: Create MTP function\n");
		pr_err("\t3: Create and symlink PTP function"
				" with a gadget configuration\n");
		return NULL;
	}

	dev = fi_mtp->dev;
	dev->function.name = DRIVER_NAME;
	dev->function.strings = mtp_strings;
	if (mtp_config) {
Loading