mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Doug Anderson <dianders@chromium.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 3.19.y-ckt 89/92] pinctrl: Don't just pretend to protect pinctrl_maps, do it for real
Date: Tue, 26 May 2015 08:41:33 -0700	[thread overview]
Message-ID: <1432654896-28478-90-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1432654896-28478-1-git-send-email-kamal@canonical.com>

3.19.8-ckt1 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Doug Anderson <dianders@chromium.org>

commit c5272a28566b00cce79127ad382406e0a8650690 upstream.

Way back, when the world was a simpler place and there was no war, no
evil, and no kernel bugs, there was just a single pinctrl lock.  That
was how the world was when (57291ce pinctrl: core device tree mapping
table parsing support) was written.  In that case, there were
instances where the pinctrl mutex was already held when
pinctrl_register_map() was called, hence a "locked" parameter was
passed to the function to indicate that the mutex was already locked
(so we shouldn't lock it again).

A few years ago in (42fed7b pinctrl: move subsystem mutex to
pinctrl_dev struct), we switched to a separate pinctrl_maps_mutex.
...but (oops) we forgot to re-think about the whole "locked" parameter
for pinctrl_register_map().  Basically the "locked" parameter appears
to still refer to whether the bigger pinctrl_dev mutex is locked, but
we're using it to skip locks of our (now separate) pinctrl_maps_mutex.

That's kind of a bad thing(TM).  Probably nobody noticed because most
of the calls to pinctrl_register_map happen at boot time and we've got
synchronous device probing.  ...and even cases where we're
asynchronous don't end up actually hitting the race too often.  ...but
after banging my head against the wall for a bug that reproduced 1 out
of 1000 reboots and lots of looking through kgdb, I finally noticed
this.

Anyway, we can now safely remove the "locked" parameter and go back to
a war-free, evil-free, and kernel-bug-free world.

Fixes: 42fed7ba44e4 ("pinctrl: move subsystem mutex to pinctrl_dev struct")
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/pinctrl/core.c       | 10 ++++------
 drivers/pinctrl/core.h       |  2 +-
 drivers/pinctrl/devicetree.c |  2 +-
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 89dca77..18ee208 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1110,7 +1110,7 @@ void devm_pinctrl_put(struct pinctrl *p)
 EXPORT_SYMBOL_GPL(devm_pinctrl_put);
 
 int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
-			 bool dup, bool locked)
+			 bool dup)
 {
 	int i, ret;
 	struct pinctrl_maps *maps_node;
@@ -1178,11 +1178,9 @@ int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
 		maps_node->maps = maps;
 	}
 
-	if (!locked)
-		mutex_lock(&pinctrl_maps_mutex);
+	mutex_lock(&pinctrl_maps_mutex);
 	list_add_tail(&maps_node->node, &pinctrl_maps);
-	if (!locked)
-		mutex_unlock(&pinctrl_maps_mutex);
+	mutex_unlock(&pinctrl_maps_mutex);
 
 	return 0;
 }
@@ -1197,7 +1195,7 @@ int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
 int pinctrl_register_mappings(struct pinctrl_map const *maps,
 			      unsigned num_maps)
 {
-	return pinctrl_register_map(maps, num_maps, true, false);
+	return pinctrl_register_map(maps, num_maps, true);
 }
 
 void pinctrl_unregister_map(struct pinctrl_map const *map)
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 75476b3..b24ea84 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -183,7 +183,7 @@ static inline struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev,
 }
 
 int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
-			 bool dup, bool locked);
+			 bool dup);
 void pinctrl_unregister_map(struct pinctrl_map const *map);
 
 extern int pinctrl_force_sleep(struct pinctrl_dev *pctldev);
diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index eda13de..0bbf7d7 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -92,7 +92,7 @@ static int dt_remember_or_free_map(struct pinctrl *p, const char *statename,
 	dt_map->num_maps = num_maps;
 	list_add_tail(&dt_map->node, &p->dt_maps);
 
-	return pinctrl_register_map(map, num_maps, false, true);
+	return pinctrl_register_map(map, num_maps, false);
 }
 
 struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
-- 
1.9.1


  parent reply	other threads:[~2015-05-26 15:46 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26 15:40 [3.19.y-ckt stable] Linux 3.19.8-ckt1 stable review Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 01/92] ext4: allocate entire range in zero range Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 02/92] x86/microcode/intel: Guard against stack overflow in the loader Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 03/92] ASoC: tfa9879: Fix return value check in tfa9879_i2c_probe() Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 04/92] ASoC: samsung: s3c24xx-i2s: Fix return value check in s3c24xx_iis_dev_probe() Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 05/92] ASoC: dapm: Enable autodisable on SOC_DAPM_SINGLE_TLV_AUTODISABLE Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 06/92] ASoC: rt5677: add register patch for PLL Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 07/92] btrfs: unlock i_mutex after attempting to delete subvolume during send Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 08/92] ALSA: hda - Fix mute-LED fixed mode Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 09/92] ALSA: hda - Add mute-LED mode control to Thinkpad Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 10/92] arm64: dma-mapping: always clear allocated buffers Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 11/92] ALSA: emu10k1: Fix card shortname string buffer overflow Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 12/92] ALSA: emux: Fix mutex deadlock at unloading Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 13/92] drm/radeon: Use drm_calloc_ab for CS relocs Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 14/92] drm/radeon: adjust pll when audio is not enabled Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 15/92] drm/radeon: add SI DPM quirk for Sapphire R9 270 Dual-X 2G GDDR5 Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 16/92] drm/radeon: fix lockup when BOs aren't part of the VM on release Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 17/92] drm/radeon: reset BOs address after clearing it Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 18/92] drm/radeon: check new address before removing old one Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 19/92] SCSI: add 1024 max sectors black list flag Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 20/92] 3w-sas: fix command completion race Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 21/92] 3w-xxxx: " Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 22/92] 3w-9xxx: " Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 23/92] uas: Allow uas_use_uas_driver to return usb-storage flags Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 24/92] uas: Add US_FL_MAX_SECTORS_240 flag Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 25/92] uas: Set max_sectors_240 quirk for ASM1053 devices Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 26/92] usb: chipidea: otg: remove mutex unlock and lock while stop and start role Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 27/92] cdc-acm: prevent infinite loop when parsing CDC headers Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 28/92] serial: xilinx: Use platform_get_irq to get irq description structure Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 29/92] serial: of-serial: Remove device_type = "serial" registration Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 30/92] tty/serial: at91: maxburst was missing for dma transfers Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 31/92] ALSA: emux: Fix mutex deadlock in OSS emulation Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 32/92] ACPI / SBS: Enable battery manager when present Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 33/92] ALSA: emu10k1: Emu10k2 32 bit DMA mode Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 34/92] ASoC: rt5677: fixed wrong DMIC ref clock Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 35/92] rbd: end I/O the entire obj_request on error Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 36/92] ext4: fix data corruption caused by unwritten and delayed extents Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 37/92] ext4: move check under lock scope to close a race Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 38/92] powerpc/pseries: Correct cpu affinity for dlpar added cpus Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 39/92] powerpc/powernv: Restore non-volatile CRs after nap Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 40/92] efivarfs: Ensure VariableName is NUL-terminated Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 41/92] x86/efi: Store upper bits of command line buffer address in ext_cmd_line_ptr Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 42/92] blk-mq: fix race between timeout and CPU hotplug Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 43/92] blk-mq: fix CPU hotplug handling Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 44/92] writeback: use |1 instead of +1 to protect against div by zero Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 45/92] ARM: mvebu: armada-xp-openblocks-ax3-4: Disable internal RTC Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 46/92] ARM: dts: imx23-olinuxino: Fix polarity of LED GPIO Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 47/92] ARM: dts: imx23-olinuxino: Fix dr_mode of usb0 Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 48/92] ARM: dts: imx6: phyFLEX: USB VBUS control is active-high Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 49/92] ARM: dts: imx25: Add #pwm-cells to pwm4 Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 50/92] ARM: dts: imx28: Fix AUART4 TX-DMA interrupt name Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 51/92] [media] marvell-ccic: fix Y'CbCr ordering Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 52/92] gpio: sysfs: fix memory leaks and device hotplug Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 53/92] ACPI / SBS: Add 5 us delay to fix SBS hangs on MacBook Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 54/92] ACPI / PNP: add two IDs to list for PNPACPI device enumeration Kamal Mostafa
2015-05-26 15:40 ` [PATCH 3.19.y-ckt 55/92] ARM: OMAP2+: Fix omap off idle power consumption creeping up Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 56/92] ARM: dts: OMAP3-N900: Add microphone bias voltages Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 57/92] drm/radeon: disable semaphores for UVD V1 (v2) Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 58/92] x86/spinlocks: Fix regression in spinlock contention detection Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 59/92] RDMA/CMA: Canonize IPv4 on IPV6 sockets properly Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 60/92] drm/i915: Assume dual channel LVDS if pixel clock necessitates it Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 61/92] drm/i915: Add missing MacBook Pro models with dual channel LVDS Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 62/92] efi: Fix error handling in add_sysfs_runtime_map_entry() Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 63/92] Revert "dm crypt: fix deadlock when async crypto algorithm returns -EBUSY" Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 64/92] xen/events: Clear cpu_evtchn_mask before resuming Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 65/92] xen/xenbus: Update xenbus event channel on resume Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 66/92] xen/console: Update console " Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 67/92] xen/events: Set irq_info->evtchn before binding the channel to CPU in __startup_pirq() Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 68/92] mm/memory-failure: call shake_page() when error hits thp tail page Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 69/92] mm: soft-offline: fix num_poisoned_pages counting on concurrent events Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 70/92] nilfs2: fix sanity check of btree level in nilfs_btree_root_broken() Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 71/92] ocfs2: dlm: fix race between purge and get lock resource Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 72/92] drm/i915/dp: there is no audio on port A Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 73/92] drm/amdkfd: allow unregister process with queues Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 74/92] drm/radeon: fix userptr BO unpin bug v3 Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 75/92] drm/radeon: make VCE handle check more strict Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 76/92] drm/radeon: make UVD handle checking " Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 77/92] drm/radeon: more strictly validate the UVD codec Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 78/92] path_openat(): fix double fput() Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 79/92] mnt: Fix fs_fully_visible to verify the root directory is visible Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 80/92] drm: Zero out invalid vblank timestamp in drm_update_vblank_count Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 81/92] ARM: ux500: Move GPIO regulator for SD-card into board DTSs Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 82/92] ARM: ux500: Enable GPIO regulator for SD-card for HREF boards Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 83/92] ARM: ux500: Enable GPIO regulator for SD-card for snowball Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 84/92] xen-pciback: Add name prefix to global 'permissive' variable Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 85/92] mmc: core: add missing pm event in mmc_pm_notify to fix hib restore Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 86/92] ARM: dts: am57xx-beagle-x15: Fix IRQ type for mcp7941x Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 87/92] mmc: sh_mmcif: Fix timeout value for command request Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 88/92] mmc: card: Don't access RPMB partitions for normal read/write Kamal Mostafa
2015-05-26 15:41 ` Kamal Mostafa [this message]
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 90/92] arm64: add missing PAGE_ALIGN() to __dma_free() Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 91/92] vhost/scsi: potential memory corruption Kamal Mostafa
2015-05-26 15:41 ` [PATCH 3.19.y-ckt 92/92] md/raid0: fix restore to sector variable in raid0_make_request Kamal Mostafa

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1432654896-28478-90-git-send-email-kamal@canonical.com \
    --to=kamal@canonical.com \
    --cc=dianders@chromium.org \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

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

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

all inboxes | Powered by JetHome®