Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1010876ybl; Wed, 28 Aug 2019 08:23:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVNWpyzfu6TsPjxQ7+Fw5B9Zs/SYPDwvrM2BwUlVGGVve0XtNmAXJdVmRsTynAmUrbYg02 X-Received: by 2002:a17:90a:a105:: with SMTP id s5mr4744935pjp.51.1567005807467; Wed, 28 Aug 2019 08:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567005807; cv=none; d=google.com; s=arc-20160816; b=djjnF3grDHmql42gketqdHN53Qn4x17GTmOTm8k+8KlBO8HuJhW6+8tc98nvKHE/n0 Kr+sKNk0ZbMHpUDXsLtdS7vpLtLd+eh6OeshWcZMACIDMnCf3crhWJwJ33BGdnx0AoPn kyJ1VCFIxPiRv8P7Ld52qbH9zi1n1N6EByInAhjusINXMZK2UZSknE/7D2UbEBieycGV 4fOFyvzZNtcmlqPLDlBANFWzwBStC6QwGkBUMC+RLG4KaYxSutkKFQROndp/E6DfX2TN jqFxpgw35FA+x6+rZxUEE/mUgoIOzV3fbzqcVUF1R19mvej4OZK3xHwru78FQXV6PR2b DOVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0i9i3gQumHOrNoZGUSa7qi85E+KdFiGyMgZ49VXWJ0Y=; b=uv6kZIiYk8c5dkzYSdz9sp7rdW7VWUkESNtdMKYq3cRXqRXUQnvT4ir7BxBuxQneAN dXkwcUgal90Za43PKXtOfTQ18EBNJ2+r7r92Vlehx3n1fEg0rT69wu1ouzNZyn8i9snR JbEAxsm/0zv2IT3AP+3waKtf4aReVnHIZoZ28kjNsSrV1HSH9/DQrqxMmND1ZzMO0RE2 aMUfgr+lvC8pzq+H4Paup5LbUPsZSZo+fKlliXaXiwAXxwO8HLIy+4pZ0xHUlW+s4QfN s2n/spI/uDx3PQXzjqqVHaRSN64LmkOc1+bWQD2OabR0ZRYfxRTQ9Ex9BiRJyA/hqtJP 7ETg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LRnwzFqe; 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 g8si2061239pjp.57.2019.08.28.08.23.11; Wed, 28 Aug 2019 08:23:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=LRnwzFqe; 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 S1726534AbfH1PWF (ORCPT + 99 others); Wed, 28 Aug 2019 11:22:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:60194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726440AbfH1PWE (ORCPT ); Wed, 28 Aug 2019 11:22:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1D8E122CED; Wed, 28 Aug 2019 15:22:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567005723; bh=ZJhc4Bf5xGC50rybksdzOKNk41SFLjFvVE7vxDePzbM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LRnwzFqeI14acCU9fWPLHIN5Uv+JP94U+v5H1SosVPVcOju1qL7QqnmbuhxXFlWAh xmX6PlsOABM4P5p/1fD1aH+L8FKCvW2zx3ZFGOZUDqKAWlbue93u0yu/whus7FlAdz 3JGqIAHgRxw0FvAIBccauvHCwOOm4VC63xVxvvkk= Date: Wed, 28 Aug 2019 17:22:01 +0200 From: Greg Kroah-Hartman To: Zhangfei Gao Cc: Arnd Bergmann , jonathan.cameron@huawei.com, kenneth-lee-2012@foxmail.com, Wangzhou , linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, Kenneth Lee , Zaibo Xu Subject: Re: [PATCH v2 2/2] uacce: add uacce driver Message-ID: <20190828152201.GA10163@kroah.com> References: <1566998876-31770-1-git-send-email-zhangfei.gao@linaro.org> <1566998876-31770-3-git-send-email-zhangfei.gao@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1566998876-31770-3-git-send-email-zhangfei.gao@linaro.org> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 28, 2019 at 09:27:56PM +0800, Zhangfei Gao wrote: > +struct uacce { > + const char *drv_name; > + const char *algs; > + const char *api_ver; > + unsigned int flags; > + unsigned long qf_pg_start[UACCE_QFRT_MAX]; > + struct uacce_ops *ops; > + struct device *pdev; > + bool is_vf; > + u32 dev_id; > + struct cdev cdev; > + struct device dev; > + void *priv; > + atomic_t state; > + int prot; > + struct mutex q_lock; > + struct list_head qs; > +}; At a quick glance, this problem really stood out to me. You CAN NOT have two different objects within a structure that have different lifetime rules and reference counts. You do that here with both a 'struct cdev' and a 'struct device'. Pick one or the other, but never both. I would recommend using a 'struct device' and then a 'struct cdev *'. That way you get the advantage of using the driver model properly, and then just adding your char device node pointer to "the side" which interacts with this device. Then you might want to call this "struct uacce_device" :) thanks, greg k-h