Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp708200imu; Thu, 13 Dec 2018 03:08:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/WlvFbhZPvBM5J/HTA9+Sy2Q4gSfNdXph42AooVuDBrcps/pxDihZHW2LJhg3HN0qdXPx/A X-Received: by 2002:a63:ac1a:: with SMTP id v26mr21832673pge.293.1544699330752; Thu, 13 Dec 2018 03:08:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544699330; cv=none; d=google.com; s=arc-20160816; b=HIYG03UhYbvqizRjZogOATvjbX4/idrh0yD3JO9SZSTXXFbslnLCFM1e37ynCqNE++ WnQrC73FfQcQq4Jx3pguUda3XiGh5ucDWXey7HV+EZ4gD09J9UYb+AGyZP2MWgt1p9NH JFPPBzXJkD8widxtJVv2sXg5NvHp8FM7aKVnoD1DMdNB1LlfK1+MInxdUyi9+p/D+QYL 1tyYAXb9sFPTmJq8fut5oGy2ktJLHtQeiqKy1gKKbc7xq1K6WHs3FrhEn1qs3ifHW1eR lfxtphCMlYPqFOpGtNdiEvWuBvAD/5XA+lzbWIEsgZp3Wy2bWSORY/3OkPYEuqnxM6qV 8MIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=bIxCMHuiYc5qOlbaPnyB1gC09TvtDkrA2eXRBKRDiBE=; b=uyJuE4ZsVRiP1Eng7L8MTY9+fAxzAkh1UxJH24RmpvCoXlalIH3BKVC2dwmyv3D1/9 8p/3v3Ojx28i3uG8sAvsGSzZRCHaxizMWMy4S7dEzEcMMvBYRRHUyrFX9yK8WyWsznfG qQch1OlYBk85jJkEch0uh/5RZHFIdNhZ8yIwDLn/9EHCdOVnMFhjbMt7YTpqf0d5/LER hsYwi3oaqzz2SKaV18gTmKg8qw3w+T4Xl5ntF0nK9F62gwIAQs+f/o+QAHVRopBKeF2x oxnePznRy0N5LSOyIRJWaV2Q19Vmuc3uKRYYGVpUFWQeJ6V4Xa3ip+dkESL87lNv4Jgn B7hw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92si1332700plw.158.2018.12.13.03.08.29; Thu, 13 Dec 2018 03:08:50 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728715AbeLMLFs (ORCPT + 99 others); Thu, 13 Dec 2018 06:05:48 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:35988 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727871AbeLMLFs (ORCPT ); Thu, 13 Dec 2018 06:05:48 -0500 Received: by mail-ot1-f65.google.com with SMTP id k98so1525515otk.3 for ; Thu, 13 Dec 2018 03:05:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bIxCMHuiYc5qOlbaPnyB1gC09TvtDkrA2eXRBKRDiBE=; b=YK40Gc7pZIQ8eyRzSW3wOzADVOHkCrraC85F6WA5K2SWY2GG9g8TCQFconZeuti1Kd /HETZ0g9ErQtc1oZnP5oD3j7fExUrTAc+NASyNEvzWu3afMku/6PsF6k5Xyt+jVL+Noz TQBR6tv+VT2Kjsy9BZyplBvKfX85rvd2MX+7WCBmaOKuWTxKV1EHx9o5AVjyObqjeIbK DUSenPPWcyidMysLVmDqzsrlFUQgaqfuy4UMWSwOL1W+lma6UsjkFy2DPmxn6um4nGKz c2a55LNv9BrmaTuFH59KTfXUJA49JfWLZTF4iSFSqTKMW5tnWCMqMpHBJkeNjFtvMdlb tMzQ== X-Gm-Message-State: AA+aEWafvijh18pxxnQABajHH9YVPr07BeC/L3NcSNQvWaet+K+fIwjH DP0zXx41aEpUFF1McEIwc99EQW9iSQZe5MbsUKs= X-Received: by 2002:a9d:7f0d:: with SMTP id j13mr15612608otq.119.1544699147720; Thu, 13 Dec 2018 03:05:47 -0800 (PST) MIME-Version: 1.0 References: <20181210084653.7268-1-daniel.vetter@ffwll.ch> <20181213095814.GC21184@phenom.ffwll.local> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 13 Dec 2018 12:05:36 +0100 Message-ID: Subject: Re: [PATCH] drivers/base: use a worker for sysfs unbind To: Daniel Vetter Cc: Linux Kernel Mailing List , dri-devel , ramalingam.c@intel.com, Greg Kroah-Hartman , Daniel Vetter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 13, 2018 at 11:23 AM Rafael J. Wysocki wrote: > > On Thu, Dec 13, 2018 at 10:58 AM Daniel Vetter wrote: [cut] > > > > - Most of these issues are never visible in normal usage, since normally > > driver bind/unbind is done from a kthread or model_load/unload, neither > > of which is running in the context of that kernfs mutex kernfs_fop_write > > holds. That's why I think the task work is the best solution, since it > > changes the locking context of the unbind sysfs to match the locking > > context of module unload and hotunplug. > > I think that using a task work here makes sense. There is a drawback, > which is that the original sysfs write will not wait for the driver to > actually be released before returning to user space AFAICS, but that > probably isn't a big deal. > > Also please note that the patch changes the code flow slightly, > because passing a non-NULL parent pointer to > device_release_driver_internal() potentially has side effects, but > that should not be a big deal either. > > > Unfortunately that trick doesn't work for the bind sysfs file, since that way we can't thread the errno value back to userspace. > > Right. That is unless we wait for the operation to complete and check > the error left behind by it. That should be doable, but somewhat > complicated. That said I'm not really sure if propagating the error to user space in this case should be expected. The interface could be defined as asynchronous to begin with a separate way for user space to check the status if necessary. Changing that now may not be practical, though.