Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp418655ybm; Tue, 26 May 2020 21:36:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8eo1n9uYKiecYio0WaHyr3FJ+CqQVIhMFGlPILytcdCMp65Otnit4sQKMtiQDriyuy61I X-Received: by 2002:a05:600c:2614:: with SMTP id h20mr2410355wma.155.1590554198162; Tue, 26 May 2020 21:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590554198; cv=none; d=google.com; s=arc-20160816; b=ThTYrKeG3LJWndahSGnnE979LcylWgb3HgrwIvfc0+s7r5AWct/R93vkRQ5Sd5ZG67 +AUvnb32deF6GPjbbiZaUc34E2IyN1qpaJAqui/XG95NCMR/cPXrjL7VMDkpVXFBP2Kd DVvF3AcaUn9P3di2CS+BrFn2I6VZ4SlodK4azGnqpqSXcY/8U4ricIUUCm9B5/6VCrud yQlBT+MUEwHWoCblLlKFRwotkmzu2YpgsBba6o/OLaThkHB5pFr/m3bhBsTEowWqvBqo zSwpgJfKO5gM/WgOI1xsGg3ezwBr5HdfzpgmzUtKIs3Xpi/EEXmkJHKjl1Qg0L6OeX19 vAYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=YaLjPcSfIGjeXsxNRxJYxq5PIRurQHe+sHMb1HbpNqE=; b=GyKFsxJltWpGisRvyWwArEQW2V7XX4YNcL6hKhpCDZDBECLcjpKNdUdZqV3aDc/iAB W62U2+9vTqwvMWYWjv2/0ZwQNJYUqa9XG8ynw+GK4hVn7LxnrILu7AEJhxHNBa0W8v7c jBWRiI51IEcuxhWKJexiEsc8WzF7Y+vzP+MwSXfUhvUu0CARvYGptwymnJkqMb5QNI72 84lvKyWql9VZhrA7IIL0Zx3tn7wWkIPpgJtAbaWV6LQrFq2T6E7zqF/t/wWqwj4k7VuB tdH7fqn78Fqo6LkBY5GOhImQj8f3TA+v0FWWt3+BkHqVWqWYzwEX6jAeH7917XjG5PeY l6SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=D7QwxQvI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m30si1135006edb.193.2020.05.26.21.36.15; Tue, 26 May 2020 21:36:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=D7QwxQvI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728257AbgE0BQc (ORCPT + 99 others); Tue, 26 May 2020 21:16:32 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:57754 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727937AbgE0BQc (ORCPT ); Tue, 26 May 2020 21:16:32 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 04R1GUbm093022; Tue, 26 May 2020 20:16:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1590542190; bh=YaLjPcSfIGjeXsxNRxJYxq5PIRurQHe+sHMb1HbpNqE=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=D7QwxQvI4mWsmsEqjEAoTQozZj4ML/fZ6w9wuvRxqoH3WYQ7+PRgi2m9R9ypPzeuN smCNq/6pRllEq8X+20mADyFmNpoVN8IyGWjHECdzSV8NI+PMy/JxOV3C6VuqpyGXlH +/p2I0rp8lOHKe4Dhxs6w6kvhL6XTeUiCsB/I3Vw= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 04R1GU96045204; Tue, 26 May 2020 20:16:30 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 26 May 2020 20:16:30 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Tue, 26 May 2020 20:16:30 -0500 Received: from [10.250.38.163] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 04R1GTSS001014; Tue, 26 May 2020 20:16:29 -0500 Subject: Re: [RFC] power: supply: bq27xxx_battery: Fix polling interval after re-bind To: Krzysztof Kozlowski , =?UTF-8?Q?Pali_Roh=c3=a1r?= , Sebastian Reichel , Anton Vorontsov , , CC: References: <20200525113220.369-1-krzk@kernel.org> From: "Andrew F. Davis" Message-ID: <65ccf383-85a3-3ccd-f38c-e92ddae8fe1e@ti.com> Date: Tue, 26 May 2020 21:16:28 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200525113220.369-1-krzk@kernel.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/25/20 7:32 AM, Krzysztof Kozlowski wrote: > This reverts commit 8cfaaa811894a3ae2d7360a15a6cfccff3ebc7db. > > If device was unbound and bound, the polling interval would be set to 0. > This is both unexpected and messes up with other bq27xxx devices (if > more than one battery device is used). > > This reset of polling interval was added in commit 8cfaaa811894 > ("bq27x00_battery: Fix OOPS caused by unregistring bq27x00 driver") > stating that power_supply_unregister() calls get_property(). However in > Linux kernel v3.1 and newer, such call trace does not exist. > Unregistering power supply does not call get_property() on unregistered > power supply. > > Fixes: 8cfaaa811894 ("bq27x00_battery: Fix OOPS caused by unregistring bq27x00 driver") > Cc: > Signed-off-by: Krzysztof Kozlowski > > --- > > I really could not identify the issue being fixed in offending commit > 8cfaaa811894 ("bq27x00_battery: Fix OOPS caused by unregistring bq27x00 > driver"), therefore maybe I missed here something important. > > Please share your thoughts on this. I'm having a hard time finding the OOPS also. Maybe there is a window where the poll function is running or about to run where cancel_delayed_work_sync() is called and cancels the work, only to have an interrupt or late get_property call in to the poll function and re-schedule it. What we really need is to do is look at how we are handling the polling function. It gets called from the workqueue, from a threaded interrupt context, and from a power supply framework callback, possibly all at the same time. Sometimes its protected by a lock, sometimes not. Updating the device's cached data should always be locked. What's more is the poll function is self-arming, so if we call cancel_delayed_work_sync() (remove it from the work queue then then wait for it to finish if running), are we sure it wont have just re-arm itself? We should make the only way we call the poll function be through the work queue, (plus make sure all accesses to the cache are locked). Andrew > --- > drivers/power/supply/bq27xxx_battery.c | 8 -------- > 1 file changed, 8 deletions(-) > > diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c > index 942c92127b6d..4c94ee72de95 100644 > --- a/drivers/power/supply/bq27xxx_battery.c > +++ b/drivers/power/supply/bq27xxx_battery.c > @@ -1905,14 +1905,6 @@ EXPORT_SYMBOL_GPL(bq27xxx_battery_setup); > > void bq27xxx_battery_teardown(struct bq27xxx_device_info *di) > { > - /* > - * power_supply_unregister call bq27xxx_battery_get_property which > - * call bq27xxx_battery_poll. > - * Make sure that bq27xxx_battery_poll will not call > - * schedule_delayed_work again after unregister (which cause OOPS). > - */ > - poll_interval = 0; > - > cancel_delayed_work_sync(&di->work); > > power_supply_unregister(di->bat); >