Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3007151iog; Mon, 27 Jun 2022 07:21:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vFXnGUZyWEYNa4NwHuoYAz6kK7CAVPL6ETOoieqZbpz0ZFSGq+b8Kl9wXZP5V0J11bmbEN X-Received: by 2002:a17:902:ed89:b0:168:a7d0:ddf1 with SMTP id e9-20020a170902ed8900b00168a7d0ddf1mr15027236plj.38.1656339690494; Mon, 27 Jun 2022 07:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656339690; cv=none; d=google.com; s=arc-20160816; b=MJF9mYqr3cpTpOGSy8QB0Hqc4l3Srw93MjZA9QXadDc6i4eC5UGrBuxRChni9t7eHQ Jybklo19U5i0nPsNkA37tuNbVz5Lbp3oQNvN/FviwaBeTqxilXfHK2P4rtxtjPmT+71y op+nH2Fy6Jd1C9fbi8+Obz2jsQQ5JJpmePvSwy2i0LsAAfjmx0LdYfL26Qj95hn+A6uu s2iJx8VQZbw+n/fEia5Ze49EZDmpEBeKEaPWCfzlaqM6m9voZuoyHQJAS7fso1M603HL U+eRVwwmHypf8xZfGECPBDDFxhwu9KA/sZSp1lir2u6RmVrC2dmBQmXkD2wN+GkYbQcQ 4WcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=/1pEyyNCsqbdIDyIk4tQ2++JMSyF3lNesIio8vbDJJ0=; b=SoyVrWeiV+lG127IYtYES4WOJkq0kwErnFgGB3JitfHJVKWjaDBTw8pNS2aKa7aUx6 4twO0Kp+uN8Pp+cXn3RxC89wnYhyVHjsML1n2FCqOXYpNCcwNBh+Q4JSpwSwt8f88kPD Xv/gM/YrrSjP/KEwBN1pCLO6YghFQxHl9dnUwMKl58u9ND44I9J38cP45AjXt0qEyfSp NoXSwX8TfjAVJuNznie3iSnmTPWO6CgBgDN1KJpXyds52gfTjQI3B1Y1NGDwBn6YI67d Chn102u1ZyLhYfRCvf4N5x6nQ4aFJd9F4LxsekJ7hzpKFVvYoxhMqDJuNxwl9LnG37rw E5xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRygcjE1; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a170902848600b0016a1ef12873si12733610plo.76.2022.06.27.07.21.04; Mon, 27 Jun 2022 07:21:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRygcjE1; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234176AbiF0OPB (ORCPT + 99 others); Mon, 27 Jun 2022 10:15:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236203AbiF0OOy (ORCPT ); Mon, 27 Jun 2022 10:14:54 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D42F513EBC for ; Mon, 27 Jun 2022 07:14:50 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id k14so8301981plh.4 for ; Mon, 27 Jun 2022 07:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=/1pEyyNCsqbdIDyIk4tQ2++JMSyF3lNesIio8vbDJJ0=; b=vRygcjE1RbBzh8t5qstRzPJBuA1Uzs5Ezt/4rabDxNmeFtrfbNKOe1BHEnCROyXVJj 1lR3ZhoD1OnFXkKOjqQFZHTC+f97zivXNQL3w1MyS6XrsqatKybpSDIJmXmHKtiurwyv JQOM85TSdoojed5yzS59daVmnUmU+1SqLjmuI2a3p9XsAcSivCNNKjUKegZ+TUgTb797 xT9BHQIcZfprUIqB8cJ6EHJ8F1mpxlsupp2mq+EuLInHcsbSvBRua4jtiVwMBYxsH5zV HxibyIbmUZ+bPudanwAHAR+1IFSkwnhD4qB7GFKUWZ+ZKiMT2GlQq0zYUTNTUz9nxCrQ Vtug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=/1pEyyNCsqbdIDyIk4tQ2++JMSyF3lNesIio8vbDJJ0=; b=lwhF1zZZvXA//+rmV6RnnPCYxCmy7Ry42CMJl28Sp02BAx0FUkjupzsfiSjapj7g4V xYzHKE303zmQFZSkOT92dm4PyAYFcGk44MJR11ZJu1ZUNaDHuhfJhokVMvCdha5bnjem MidHzaM3RXjwekrJwiMrDHM/1D5xhsIk4YKlT4zJY1KFE9OftPWRbx/wf/j/IjHxr5+W LIBM5bgmXZWXQKtkodCwkaOiCDJAuSC+B2mI7iVTvGQnzdJ1kWX2DoRA2z9WZrnWVox9 RKiSP7C1hAT4qirqzsoMHJM0AkgWG/wX7AEjwFuXr60x4JQKuH4624EDzkeGDtzGg+aD JXOg== X-Gm-Message-State: AJIora/am2tEZ22ROMdEef7qEcT1XjdvmLmt0CiqsIKQsCbQcF4yIIts N4htDbGc7tZnqcQmx3ePrYjCHA== X-Received: by 2002:a17:902:8644:b0:168:fe0e:f92d with SMTP id y4-20020a170902864400b00168fe0ef92dmr14615111plt.23.1656339290034; Mon, 27 Jun 2022 07:14:50 -0700 (PDT) Received: from [10.176.0.6] ([199.101.192.171]) by smtp.gmail.com with ESMTPSA id g29-20020aa79f1d000000b0051c4f6d2d95sm7440786pfr.106.2022.06.27.07.14.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Jun 2022 07:14:49 -0700 (PDT) Subject: Re: [PATCH v2 1/2] uacce: Handle parent driver module removal To: Greg Kroah-Hartman Cc: Arnd Bergmann , Herbert Xu , jean-philippe , Wangzhou , Jonathan Cameron , acc@openeuler.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux.dev, Yang Shen References: <20220624142122.30528-1-zhangfei.gao@linaro.org> <20220624142122.30528-2-zhangfei.gao@linaro.org> From: Zhangfei Gao Message-ID: <9ab01d6b-76c2-885c-2827-57912dee62e0@linaro.org> Date: Mon, 27 Jun 2022 22:14:29 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2022/6/27 下午9:21, Greg Kroah-Hartman wrote: > On Fri, Jun 24, 2022 at 10:21:21PM +0800, Zhangfei Gao wrote: >> Change cdev owner to parent driver owner, which blocks rmmod parent >> driver module once fd is opened. >> >> Signed-off-by: Yang Shen >> Signed-off-by: Zhangfei Gao >> --- >> drivers/misc/uacce/uacce.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c >> index 281c54003edc..f82f2dd30e76 100644 >> --- a/drivers/misc/uacce/uacce.c >> +++ b/drivers/misc/uacce/uacce.c >> @@ -484,7 +484,7 @@ int uacce_register(struct uacce_device *uacce) >> return -ENOMEM; >> >> uacce->cdev->ops = &uacce_fops; >> - uacce->cdev->owner = THIS_MODULE; >> + uacce->cdev->owner = uacce->parent->driver->owner; > What if parent is not set? What if parent does not have a driver set to > it yet? Why would a device's parent module control the lifespan of this > child device's cdev? Have used try_module_get(uacce->parent->driver->owner) in open, and module_put in release. Seems same issue. > > This feels wrong and like a layering violation here. > > If a parent's module is unloaded, then invalidate the cdev for the > device when you tear it down before the module is unloaded. Yes, make sense. > > Yes, the interaction between the driver model and a cdev is messy, and > always tricky (see the recent ksummit discussion about this again, and > last year's discussion), but that does not mean you should add laying > violations like this to the codebase. Please fix this properly. Thanks Greg Yes, I was in hesitation whether adding the patch 1, but it looks very simple. In fact, the patch 2 can cover both removing device and rmmod parent driver module. We can just keep patch 2. Thanks