Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1641030ybb; Thu, 2 Apr 2020 04:53:07 -0700 (PDT) X-Google-Smtp-Source: APiQypJ3kuqNGx8CNy1yKJTU70AtFsfQiYSREs49f2AbK+pHikSAROGIJyvtvFYxKOk3G0hoenbF X-Received: by 2002:a05:6808:b1a:: with SMTP id s26mr1793368oij.150.1585828387057; Thu, 02 Apr 2020 04:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585828387; cv=none; d=google.com; s=arc-20160816; b=I+tKPrDadgatXn6Wiy2mPBa49hh9+gQPOIxQg1zilHWfDjDTkFxU3Iv5yJ+pTV8Ru+ iv512anrj/C4XXyqAyGl/FQPTySZacU+NHxRddYy8dUreIgw9ny5vvfEETf9+uiHwkUL rNQwliy6hI9NrPTPYUhLu+xOu0EZanOwkfK0xFZxwRvUfDUeVVudeylWayDq3TYJyezH bGL4IS1B9h7GSsmuc5kl+dgyNcgMQTa/Cpkj5nO/5B4qc2Z5JyRGqldEjBaGNWHyOsJW iXwRb+joGHwGyWHTTUdAKsoRBKqk2ade00JnYtP5aqSl1GWGC00+HbyKIGtC072WjmEP Xyhg== 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:ironport-sdr:ironport-sdr; bh=6Y8UcZTENKOXiWaKvYFseCmxfyiTn6l7syUqQvXlVb0=; b=VkkhFC7/VtIDL+1HuA+p1oxqZ51pdJdQaZESYfm4O3h1ertxTNEFOGbMLsiCEU1OJf u+qbBnUErj5iJ5jEOHLgubfODrvbYSMvR0wIUPalFIIzjwgUP1JALeLTZ9JZgRZL+lqr mZ+Ny07CbkplIAs3rOPimePobtr6GRXzawAbF/Ym7aFJMZjKHLKrnYCOQNGhci8sSeRu 2R9yGbKTfjJey1mOJP/wduDKz74vCOVX/3y87wQIHJS4FHW9FH3KHmrcQOOmOxIPobvX juMZoEfpJxnr9wqfIC1/TsP4XxCvS/+UCho4D8uzAWGbq2tSs+8pbj1bZ4az1pYko/kb qe0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si2468636oiy.229.2020.04.02.04.52.53; Thu, 02 Apr 2020 04:53:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388154AbgDBLuQ (ORCPT + 99 others); Thu, 2 Apr 2020 07:50:16 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:64559 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388083AbgDBLuQ (ORCPT ); Thu, 2 Apr 2020 07:50:16 -0400 IronPort-SDR: SbbNl2N12bSYPZWnMDk0yxWwbBZqH6aaN1I7kB4GLMt2USpxslzkrQE9ftQHDzM1oAxBrxRLLW jg1lXvvxvyhsWQS2vyp4RrR/BSYSsk8uIjCYOpejfB/ZS8+AfKO2scROdAmi/VQm6p44OmnTFt jzSZNm7/xbb4TF2hLdp7A/w0hJF5X2boA/Ae+Pw8ZnKbQmJExdfT6rNqYXtFxqmmQKuMg25UV2 Vj4otcQeG1os9yYNRLb2dWo/8VYlXj7RIKRSIy+7lqz7hBLCV+HvlwkzwNpSESX56DA0GKRxUn Bs4= X-IronPort-AV: E=Sophos;i="5.72,335,1580803200"; d="scan'208";a="47374305" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 02 Apr 2020 03:50:15 -0800 IronPort-SDR: qvBE1jSXKRmivofT4+aNFf3EBsCI4gHJeLrn3ZhUVCG5wZJQv5ylbJIznpGSCfVTDb8FeY2aSx xh95mFBiVwftQsZG7wm1xnQ7AqGmQg4pbOAoUht+cyDl4Ffg1JhpBFdpbLYNOUpJ1K+AbfuUGp 1QItNNX2fdusTe6+l9Z8InBRjmDTUC4kvByzNlKgRlNWF2q8+kZqoJayGOFGxrCxHSKUO6Pz4Y pW66TSysSlaLOr+twMp4fkEISwS2hmmGLx1zy91YHowXbfJMiUySFefycZuAEOC7K/jt0ULWYa ct4= Subject: Re: [PATCH v10 54/55] Input: atmel_mxt_ts: Implement synchronization during various operation To: Dmitry Osipenko , , , , , CC: , , , References: <20200331105051.58896-1-jiada_wang@mentor.com> <20200331105051.58896-55-jiada_wang@mentor.com> From: "Wang, Jiada" Message-ID: Date: Thu, 2 Apr 2020 20:50:09 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: svr-orw-mbx-08.mgc.mentorg.com (147.34.90.208) To svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry On 2020/04/02 1:04, Dmitry Osipenko wrote: > 31.03.2020 13:50, Jiada Wang пишет: >> From: Sanjeev Chugh >> >> There could be scope of race conditions when sysfs is being handled >> and at the same time, device removal is occurring. For example, >> we don't want the device removal to begin if the Atmel device >> cfg update is going on or firmware update is going on. In such >> cases, wait for device update to be completed before the removal >> continues. >> >> Thread Thread 2: >> ========================= ========================= >> mxt_update_fw_store() mxt_remove() >> mutex_lock(&data->lock) ... >> mxt_initialize() //Tries to acquire lock >> request_firmware_nowait() mutex_lock(&data->lock) >> ... ==>waits for lock() >> ... . >> ... . >> mutex_unlock(&data->lock) . >> //Gets lock and proceeds >> mxt_free_input_device(); >> ... >> mutex_unlock(&data->lock) >> //Frees atmel driver data >> kfree(data) >> >> If the request_firmware_nowait() completes after the driver removal, >> and callback is triggered. But kernel crashes since the module is >> already removed. >> >> This commit adds state machine to serialize such scenarios. > > Won't it be easier to bump driver's module use-count by __module_get() > while firmware is updating? Or remove sysfs during of mxt_remove()? > thanks for your inspiration, I will replace state machine with module use-count. Thanks, Jiada