Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1859559ybl; Sat, 24 Aug 2019 05:54:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEn0SPDVjXYCBX7kDuktrZ1uwsDIgUe/dxuS/3haRU57JokmtupKXV14TPdBElFv/z5tQN X-Received: by 2002:aa7:90c9:: with SMTP id k9mr10221025pfk.171.1566651260780; Sat, 24 Aug 2019 05:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566651260; cv=none; d=google.com; s=arc-20160816; b=CSU1FMK/TaewmEVRvCZ9sw6kQYdtE8qPFdj/cVtviRl2WFyZBmrdOCrn6HUhlcTp+z R0lsjKWCpo90izcyIeF4qz5/giyEo7HBTsTShBC4anvrn1BZWWi3VfCnC8YgWLz2gKwR 3/OMT8kcyPosi5zg2/Qojl9h3ynVQbxz0H6qhcekVx7aAEJm6IY9InRFHRLEm4mizECw PmJM+Y75IvxHqbAWKWUALaWs3HoIoUDWZsH7zVp6P007w0RVsEaLDMf39WaMnO70I368 o8qwJFW/bxgU9mBuiT7mBa74DU245mFfNbqsxvst569LEyZdcjjnf6JBMcApt44/QrIX rGPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from:dkim-signature; bh=F/nPYFepDy0cUjW6EXTQwdfVi+FEnIDznVuIrRm/76A=; b=M4J0Pq55zGzzC5eut5GGq/A/MMm0jHS38gVOX/4ruppwGyp4JhekB0h8TRnAH7wz5C gpEHyKv3JKjuzU75r45lGCa2qMNABHVxJ8iaHm1CkD9175vpM1KXeLeWxT3rzbOjnbcc IKgXzW8idp3xYopNmZiu5plGtUSDA0hYYsMWlRUlIbXQgNo0NDRYCck7QcdGs+tmEGU4 V7V95oo59uwfN8nW9dRJVjn5oohOlYWUisNPpRazl7sHrSwSZYBPLvRoQ31/YgykHtUe rWsCQmFErODqzP6xAcqHr/1+rcZs3XmenqDqVc2O96wMOPUl9iD8P4VftsQdub7tDf78 gZDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GvW6JYBU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20si4761491plo.67.2019.08.24.05.54.05; Sat, 24 Aug 2019 05:54:20 -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=@linaro.org header.s=google header.b=GvW6JYBU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728065AbfHXMxP (ORCPT + 99 others); Sat, 24 Aug 2019 08:53:15 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43706 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727590AbfHXMxO (ORCPT ); Sat, 24 Aug 2019 08:53:14 -0400 Received: by mail-pl1-f193.google.com with SMTP id 4so7292939pld.10 for ; Sat, 24 Aug 2019 05:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=F/nPYFepDy0cUjW6EXTQwdfVi+FEnIDznVuIrRm/76A=; b=GvW6JYBUVbXc2ui2gYORsIjOTFeKIL7aFET4Fh6Q1fjGX5ma243XPCtctwoAIBRx+B HRSTGuKLsYHrtx/TJXzo+hq3zSdDEUOnHwWWzlS2hi96JavVbw5KHLfQJaY/1wDD2sfj PEf3L1nhNeLzJGbFlSCAe/dfJ3AjaU8M5vFIvWg622vjgrORIZmamtKY+rpUbhxTLeb3 X3ZxxTGW/FxrA/P+w61QkVQGFd0EZdXY9mhBzLGB4XLehU3fSTu4hB7WK+oFTD0Kv5Yk VxmuIFrkV70XEBs1VFFt69Runp3vapWFHskYnevB4alDXlmiWTkES0DGtIDn4o8yn0GE +EqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=F/nPYFepDy0cUjW6EXTQwdfVi+FEnIDznVuIrRm/76A=; b=cjQz+CVBRU1KHEKgRkYhs+iGHbRJ5hhCxO5GcFFf6dc528im3F4/zG06FrHFD70TBC dzoqOG+loeRKs5mOm5huqH7IMLFfW17jAod4Mgukkq2OkZeu7RImyIRFiuZ6hXTFm7eh jn+mpbG3y4KS3DkZujbu0l3CWko5s2l6BXQa0UawSLBAulH5SkqkjVE7AaZHHHtcoAyu kTbYzPIVDMY1Z/EF6zkEMDsdYN2uFziaTea6lSzVCn+1whKG6BMWnghmSlqUmCuF9kCm W7TSffUvhayg0tt99AFhZIsM0eReO6YMWMTYWKykee0h4nzBVNcRpPm61I8yQrlf/EFx ne6A== X-Gm-Message-State: APjAAAXoaWM6mnWG4qYDPqNWKCvKp4H5MWsv+Zz46QrlJv615dZ+G6wt PiU08LhL7dayllDhyVepVWdyWA== X-Received: by 2002:a17:902:860b:: with SMTP id f11mr9745085plo.48.1566651194290; Sat, 24 Aug 2019 05:53:14 -0700 (PDT) Received: from [192.168.11.133] (li1566-229.members.linode.com. [139.162.86.229]) by smtp.gmail.com with ESMTPSA id x9sm4493152pgp.75.2019.08.24.05.53.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Aug 2019 05:53:13 -0700 (PDT) From: zhangfei Subject: Re: [PATCH 2/2] uacce: add uacce module To: Greg Kroah-Hartman Cc: Arnd Bergmann , linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, Kenneth Lee , Zaibo Xu , Zhou Wang References: <1565775265-21212-1-git-send-email-zhangfei.gao@linaro.org> <1565775265-21212-3-git-send-email-zhangfei.gao@linaro.org> <20190815142021.GE23267@kroah.com> <5d5a6f5b.1c69fb81.9d35e.5303SMTPIN_ADDED_BROKEN@mx.google.com> <20190819102413.GB2030@kroah.com> <0f7c6241-2028-76e7-0314-8b99cd353bd6@linaro.org> <20190820143341.GB1536@kroah.com> Message-ID: <3e237a99-8832-30d5-11de-f65325195478@linaro.org> Date: Sat, 24 Aug 2019 20:53:01 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190820143341.GB1536@kroah.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/8/20 下午10:33, Greg Kroah-Hartman wrote: > On Tue, Aug 20, 2019 at 08:36:50PM +0800, zhangfei wrote: >> Hi, Greg >> >> On 2019/8/19 下午6:24, Greg Kroah-Hartman wrote: >>>>>> +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? >>>> I think you mean uacce structure here. >>>> Yes, currently we count on caller to prepare uacce structure and call >>>> uacce_register(uacce). >>>> We still think this method is simpler, prepare uacce, register uacce. >>>> And there are other system using the same method, like crypto >>>> (crypto_register_acomp), nand, etc. >>> crypto is not a subsystem to ever try to emulate :) >>> >>> You are creating a structure with a lifetime that you control, don't >>> have someone else create your memory, that's almost never what you want >>> to do. Most all driver subsystems create their own memory chunks for >>> what they need to do, it's a much better pattern. >>> >>> Especially when you get into pointer lifetime issues... >> OK, understand now, thanks for your patience. >> will use this instead. >> struct uacce_interface { >>         char name[32]; >>         unsigned int flags; >>         struct uacce_ops *ops; >> }; >> struct uacce *uacce_register(struct device *dev, struct uacce_interface >> *interface); > What? Why do you need a structure? A pointer to the name and the ops > should be all that is needed, right? We are thinking transfer structure will be more flexible. And modify api later would be difficult, requiring many drivers modify together. Currently parameters need a flag, a pointer to the name, and ops, but in case more requirement from future drivers usage. Also refer usb_register_dev, sdhci_pltfm_init etc, and the structure para can be set as static. > And 'dev' here is a pointer to the parent, right? Might want to make > that explicit in the name of the variable :) Yes, 'dev' is parent, will change to 'pdev', thanks. >>>>>> + >>>>>> +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. >>>> Sorry, do not find this function. >>>> Only find class_find_device, which still require match. >>> It is in linux-next, look there... >>> >> Suppose you mean the funcs: device_match_name, >> device_match_of_node,device_match_devt etc. >> Here we need dev->parent, there still no such func. > You should NEVER be matching on a parent. If so, your use of the driver > model is wrong :) > > Remind me to really review the use of the driver core code in your next > submission of this series please, I think it needs it. > > OK, thanks Greg.