Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2293354ybl; Thu, 15 Aug 2019 09:28:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGBwdgvNckIP+snptlPIyB/putuk0gmpCXQrnMdQxQ+f+aOJCJJJ1TQbIq75eRrVM8EhVn X-Received: by 2002:a65:4808:: with SMTP id h8mr4143583pgs.22.1565886507059; Thu, 15 Aug 2019 09:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565886507; cv=none; d=google.com; s=arc-20160816; b=VPnoMMCgEn45ISYUqwwyLkwW5qiXlJEMX3+bGDh1btMX/p6O4raHnnqDbvg71dlCor JIjzx34seG97ScBg6/1ZWFeYE4Eje+3OgB78Njf76A/5tCaCiIO1w9WSkM4Lx/IftWQj 8zwY2HFOpWsym4fNkbgMc0AauJCtxNuiJs1sM4ZcLNz5SxBpHE1IKC5LFoFZpDl3TuWC O8dblRh4V97YvzytlNy8Q9qtw6cqCWS/S+e1ATIXgbByYrdKmZ6Yp44ewPT9QQIv3x5u Im18fppWslDoj1AZwN4WJiYOYEIq5LDVMNvxjTiNpspQ2f3mQLIxOU9TeRufK4ZT7c9k wQNA== 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=clFE5sYZNO30IkQMHGjSm7EXarJB75rDZG2BmhaFWrI=; b=chKXfJmY8it6By5vL+FBqDToadZCOgjQ+8PpTLh6S53Vc3O/hWV/PUFMHBtwvSIKcL AmYyDmrAJk+0X+d+r0nUCgXOp3PQXtZCCalBkaYHnQBlqnv7SvRjnjvm1U39f/HIRhaN k8RuSh9DMSYLFxNkReAKrHuVaXlpjLSWOpLQBaAKjUmjRX7SkamjXjtUMLwyO76VS2p0 Bns8it5FDABLu5NPzxliW1IspT3Ru588Rf2jYRTS+dfHjzE5fLhAD0AIc1Ret2TkXTRs 80sv5HKBOkrBPquRgq0wrV/rsSnIgRiHwdCBiUjtbwWLPMcYg5fsFalVLqDhY5rBTIRC AmdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JW6xNW65; 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 q206si2041953pgq.483.2019.08.15.09.28.11; Thu, 15 Aug 2019 09:28: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=JW6xNW65; 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 S1732909AbfHOOUZ (ORCPT + 99 others); Thu, 15 Aug 2019 10:20:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:54828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732815AbfHOOUY (ORCPT ); Thu, 15 Aug 2019 10:20:24 -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 802822084D; Thu, 15 Aug 2019 14:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565878824; bh=8eZZYxqGdKlMwHYaUNSwYgzDgjkPy44iEuYkZcgKkD0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JW6xNW658rey32GV398pH5z6+FMCmW4s+58gMdNaHx6h2jLklbxzOp6P8fIAIXcT4 1D3ntQ5rq8rNt1sB34u2b5ynVRmyORMvn3p2vhbhOr1OQ4MZxALc8bTCwj7of6y3y+ RVLC10ay9wn/vmBf8ewOgZlDLFpH1gFByFU3lzqM= Date: Thu, 15 Aug 2019 16:20:21 +0200 From: Greg Kroah-Hartman To: Zhangfei Gao Cc: Arnd Bergmann , linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, Kenneth Lee , Zaibo Xu , Zhou Wang Subject: Re: [PATCH 2/2] uacce: add uacce module Message-ID: <20190815142021.GE23267@kroah.com> References: <1565775265-21212-1-git-send-email-zhangfei.gao@linaro.org> <1565775265-21212-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: <1565775265-21212-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 14, 2019 at 05:34:25PM +0800, Zhangfei Gao wrote: > +/* lock to protect all queues management */ > +static DECLARE_RWSEM(uacce_qs_lock); > +#define uacce_qs_rlock() down_read(&uacce_qs_lock) > +#define uacce_qs_runlock() up_read(&uacce_qs_lock) > +#define uacce_qs_wlock() down_write(&uacce_qs_lock) > +#define uacce_qs_wunlock() up_write(&uacce_qs_lock) Do not define your own locking macros. That makes the code impossible to review. And are you _sure_ you need a rw lock? You have benchmarked where it has a performance impact? > +/** > + * uacce_wake_up - Wake up the process who is waiting this queue > + * @q the accelerator queue to wake up > + */ > +void uacce_wake_up(struct uacce_queue *q) > +{ > + dev_dbg(&q->uacce->dev, "wake up\n"); ftrace is your friend, no need for any such logging lines anywhere in these files. > + wake_up_interruptible(&q->wait); > +} > +EXPORT_SYMBOL_GPL(uacce_wake_up); ... > +static struct attribute *uacce_dev_attrs[] = { > + &dev_attr_id.attr, > + &dev_attr_api.attr, > + &dev_attr_node_id.attr, > + &dev_attr_numa_distance.attr, > + &dev_attr_flags.attr, > + &dev_attr_available_instances.attr, > + &dev_attr_algorithms.attr, > + &dev_attr_qfrs_offset.attr, > + NULL, > +}; > + > +static const struct attribute_group uacce_dev_attr_group = { > + .name = UACCE_DEV_ATTRS, > + .attrs = uacce_dev_attrs, > +}; Why is your attribute group in a subdirectory? Why not in the "normal" class directory? You are adding sysfs files to the kernel without any Documentation/ABI/ entries, which is a requirement. Please fix that up for the next time you send these. > +static const struct attribute_group *uacce_dev_attr_groups[] = { > + &uacce_dev_attr_group, > + NULL > +}; > + > +static int uacce_create_chrdev(struct uacce *uacce) > +{ > + int ret; > + > + ret = idr_alloc(&uacce_idr, uacce, 0, 0, GFP_KERNEL); > + if (ret < 0) > + return ret; > + Shouldn't this function create the memory needed for this structure? You are relying ont he caller to do it for you, why? > + cdev_init(&uacce->cdev, &uacce_fops); > + uacce->dev_id = ret; > + uacce->cdev.owner = THIS_MODULE; > + device_initialize(&uacce->dev); > + uacce->dev.devt = MKDEV(MAJOR(uacce_devt), uacce->dev_id); > + uacce->dev.class = uacce_class; > + uacce->dev.groups = uacce_dev_attr_groups; > + uacce->dev.parent = uacce->pdev; > + dev_set_name(&uacce->dev, "%s-%d", uacce->drv_name, uacce->dev_id); > + ret = cdev_device_add(&uacce->cdev, &uacce->dev); > + if (ret) > + goto err_with_idr; > + > + dev_dbg(&uacce->dev, "create uacce minior=%d\n", uacce->dev_id); > + return 0; > + > +err_with_idr: > + idr_remove(&uacce_idr, uacce->dev_id); > + return ret; > +} > + > +static void uacce_destroy_chrdev(struct uacce *uacce) > +{ > + cdev_device_del(&uacce->cdev, &uacce->dev); > + idr_remove(&uacce_idr, uacce->dev_id); > +} > + > +static int uacce_default_get_available_instances(struct uacce *uacce) > +{ > + return -1; Do not make up error values, use the proper -EXXXX value instead. > +} > + > +static int uacce_default_start_queue(struct uacce_queue *q) > +{ > + dev_dbg(&q->uacce->dev, "fake start queue"); > + return 0; Why even have this function if you do not do anything in it? > +} > + > +static int uacce_dev_match(struct device *dev, void *data) > +{ > + if (dev->parent == data) > + return -EBUSY; There should be in-kernel functions for this now, no need for you to roll your own. thanks, greg k-h