From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB8F7409618 for ; Wed, 3 Jun 2026 08:29:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780475347; cv=none; b=JFHzt4549j0w2SqrndNK79hvf/jRkxZ0Q5NnS/i6P2eZkFtwyahdwNDAu6B7Efyq+i/g8gkCSZgjr73bCrF3hRQ/LJJu5aHU5RPhemAYRrdVGrZpFvcf2AbkehXwhSJIZ69tQj83kl3bxMy5kQ3E7dL8WkqwdZX1U/onjHWsxWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780475347; c=relaxed/simple; bh=bloimK55FpfGsQLgS/eRSYfIoH0XLCbUnwSE5SJK4mA=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=GessjhAzB3zpHyEx1OUAmBliH8HbrgaATC7wfAwYmKTyaPrtWb1S34UeSg4WqgoytcwQlWk1Tu6rTEUBBdTsm3RtIybS7pag7Lmc2XRuETBhTMQCVYEwRnVKclu7McdeqldAGUvvJVyNCsbZx7DRjUo5NwjT24s3NKGZ0UtKliQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=EWNcTRTN; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EWNcTRTN" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-45eecb8bf67so4671403f8f.2 for ; Wed, 03 Jun 2026 01:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780475344; x=1781080144; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/UFR5yeANXS1ym7dwBfhF3G3wNluixUtSkJDeWkxZK0=; b=EWNcTRTNT7pDA05mXrH769q8zlWlrxXDTZsceI7a+eI2mwvm/CFjPvFhngCqQpnf29 srTGnAkEzRHnZOFVbZ9wDjyA7NnuXxjwwwzJwh5gpuDRaIkoiCdV5KYCK6LDcL79g08Y SVCOhIlhpcKFLOo+UZXyLH6MUeCm2tgyZiSYeiipUZ4lSA/pSGTwGXh01+fS3+O77lI6 tJ6tKef1JgE2i3o+3EH7AmaQjcwlZ75A0qToc7AlQHCAIaN8jQjoRM03pZ1nbGHiBvlD h1YRCm5+oawq2kj0/711nznw/tEUAc+0K1I0msDkv8f/ELYR8JirQYzP6dFdVWiIqIMv +E/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780475344; x=1781080144; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/UFR5yeANXS1ym7dwBfhF3G3wNluixUtSkJDeWkxZK0=; b=IbvYUrVFzEtjwpVsyE79gc0UuPuVBLVbf2QCJfrPZW3I9zUYNYK+tskPDoPTJl3bu3 LiLH+8NbUv6XRuAq8Yta+kd8J+jOt3loewslQ88K69sxGu4i3BVKt6xmlvYHikmNFCS8 IbxVn34eTRfFPSLFSd3G84pHJQJvidSarXPleJBwPVyst50bAJ1OuinA/p+hB1gzxBjt DP+xRRsF6gfchisjrr6PDW3kUvaqDh+iholGDgcfCFRFiFQWc7NwUcO+QffvMFlRc66f f710ry5U3bBE3xE07R4KnKvu3tymwsvE3Aukl7ZSNXOn53PBnffQCUe+zRSoWlAptUgx XSDA== X-Forwarded-Encrypted: i=1; AFNElJ94SHMXw9ZM+45fPS41hRgCV1mnc8hr7bBw+HSPyBW25om6pqP3gIWPtxTiaQSlsefA4iEITgD6wIkE7f0=@vger.kernel.org X-Gm-Message-State: AOJu0YzJswnEIoDsFfZIiOHkPbKtm9XrbMP5cQG7ZrPeMiWv9S3fMBth IXcBZupoSZl3xHXk31RUusK/qirByriAde6gQcu4qwreAgIZ8xjP7h/lBJ91hhKnbp0= X-Gm-Gg: Acq92OEYcUXF4SNDZYMuBdxK1Af8pvGkKEMNeEYQiHBIDxJTmITOctLf3lNqUVmBKl2 r66GYZl2d8e2BO3NVzq3XrB+PAgaxbWVcw/cia/754R+8yFp6lWn/O95900PXq0sgJGbF7W+btb m2/aOB3whKkdRzbrNEvoUFx1agC5fBZOX31AqITcSwHXyFHIW7KVOeZMisHR5JqlseGrCAsxtxa UiCkS2p6gU5gKHrfABM/sk8v+EPGwpo8FPw7igOcz0D+ExChmyogU1DhZHIegD+ZZ5dSNt3N6Cr zOn64LHdsK9YVtvw2fQ2UWOrNZCgiQiV2SaSIYAgmMfZCzWdu4Rg2xBEH3Uck0WvbaN+4fQrlHW HaRfnWlw/Oe6Io6Adeekw3LxOmr7FKoCFmN9flhujTXTcwb0xt/Yq1RLZUG6EZiNIMzFxD5YGE3 NvPAE3RXpUIT3LSWrzVyX5ugGIejaIdaUQzyaFDsKPkcJPAJjDAKLG+34lGrxUoqTuwJrivcvCZ zPuuUU70DMA/ftWYO9gdpXLEKmODBkRdRb7Rk8= X-Received: by 2002:a5d:5389:0:b0:45e:f2bd:2b16 with SMTP id ffacd0b85a97d-4602182dbb8mr2455986f8f.18.1780475344302; Wed, 03 Jun 2026 01:29:04 -0700 (PDT) Received: from localhost ([2a00:2381:fd67:101:9b1c:c9e0:4645:9af0]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f360bd6sm6191614f8f.36.2026.06.03.01.29.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jun 2026 01:29:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 03 Jun 2026 09:29:02 +0100 Message-Id: Cc: "Bartlomiej Zolnierkiewicz" , "Krzysztof Kozlowski" , "Rafael J. Wysocki" , "Daniel Lezcano" , "Zhang Rui" , "Lukasz Luba" , "Peter Griffin" , "Alim Akhtar" , "open list:SAMSUNG THERMAL DRIVER" , "moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES" , "open list" Subject: Re: [PATCH] thermal/drivers/exynos: fix clock ordering race and shared IRQ handling From: "Alexey Klimov" To: "Rosen Penev" , X-Mailer: aerc 0.20.0 References: <20260603013018.239703-1-rosenp@gmail.com> In-Reply-To: <20260603013018.239703-1-rosenp@gmail.com> On Wed Jun 3, 2026 at 2:30 AM BST, Rosen Penev wrote: > Fix two pre-existing issues in exynos_tmu_probe/remove: > > 1. Clock ordering race: The driver manually unprepares clocks in > exynos_tmu_remove() and the probe error path, but the IRQ handler and > thermal zone are devm-managed and remain active until after the manual > cleanup. If the shared IRQ fires or the thermal zone is polled in tha= t > window, clk_enable() is called on an unprepared clock, which is illega= l. > Replace devm_clk_get() + manual clk_prepare() with devm_clk_get_prepar= ed(), > and devm_clk_get() + manual clk_prepare_enable() with > devm_clk_get_enabled(), so clock unprepare is tied to the devm lifetim= e > and happens after the IRQ and thermal zone are released. Remove the > now-redundant manual cleanup from the error path and remove function. > > 2. Shared IRQ handling: The driver requests a shared IRQ (IRQF_SHARED) wi= th > NULL as the hardirq handler, causing the kernel to wake the threaded > handler for every interrupt on the shared line. The threaded handler > unconditionally returned IRQ_HANDLED without verifying that the TMU > actually generated the interrupt, which could cause other shared-IRQ > devices to be starved. Change tmu_clear_irqs to return the interrupt > status register value, and return IRQ_NONE from the handler if no TMU > interrupt was pending. > > Assisted-by: opencode:big-pickle > Signed-off-by: Rosen Penev > --- > drivers/thermal/samsung/exynos_tmu.c | 81 +++++++++------------------- > 1 file changed, 24 insertions(+), 57 deletions(-) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsu= ng/exynos_tmu.c > index 47a99b3c5395..5dc22006d7f8 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -196,7 +196,7 @@ struct exynos_tmu_data { > void (*tmu_control)(struct platform_device *pdev, bool on); > int (*tmu_read)(struct exynos_tmu_data *data); > void (*tmu_set_emulation)(struct exynos_tmu_data *data, int temp); > - void (*tmu_clear_irqs)(struct exynos_tmu_data *data); > + u32 (*tmu_clear_irqs)(struct exynos_tmu_data *data); > }; > =20 > /* > @@ -760,24 +760,28 @@ static irqreturn_t exynos_tmu_threaded_irq(int irq,= void *id) > { > struct exynos_tmu_data *data =3D id; > =20 > - thermal_zone_device_update(data->tzd, THERMAL_EVENT_UNSPECIFIED); > - > mutex_lock(&data->lock); > clk_enable(data->clk); > =20 > + if (!data->tmu_clear_irqs(data)) { > + clk_disable(data->clk); > + mutex_unlock(&data->lock); > + return IRQ_NONE; > + } > + > /* TODO: take action based on particular interrupt */ > - data->tmu_clear_irqs(data); After that change the TODO comment now feels misplaced. >From a quick glance, it seems it should be moved as well to just before if (!data->tmu_clear_irqs(data)) > =20 > + thermal_zone_device_update(data->tzd, THERMAL_EVENT_UNSPECIFIED); > + > return IRQ_HANDLED; Best regards, Alexey