Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4798001imm; Mon, 15 Oct 2018 23:28:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV63W2jZlDdHcrzemp2HqSyQDKpRKWeUy/hzsTLrJjFXrZ43+b56jqV5mMXj2buCJpD7rjFQl X-Received: by 2002:a17:902:b092:: with SMTP id p18-v6mr19232354plr.124.1539671297523; Mon, 15 Oct 2018 23:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539671297; cv=none; d=google.com; s=arc-20160816; b=u3AJijZapBb+xZiuaHWSX/EGD8NYHXJdVl+BQuzJfJm7jJlMT91D26CvsMne31BFav dugIqkYKtO4uxvoRhQi9lyRKsWCVgpTRX2AaGkIvZhJHuvfhJmTXI1gGINIj9S6lr6qJ im78GHwbxSVIBl4kfecwWZP1IxKCpfKjW3e4MA9Yl617LiB9aKdmHD4gvUiYHIjnLcb9 9/qv31mbgjtlbXoyURYPBmHhRy1vUaPbRwqDJ8zeuLYv3hOO6fBVCLkVOSPp72TH+IC6 /4oACoD2PvYPdfJ0MRpG5EOrnYjFAlD3YlCepITntYRdngvbxVMDhNz/Etc/zwQ1LGjR hIiw== 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=QWhRolkdwneY9yUlxDqxd0I4vtWHUwhPi/lLF+juej4=; b=nKEEOmz5jqqDVihpVIlvMeE90ITEx3bRL6Xvpefk/ef/DZhSg1rDoNQhtASckByHMB Y15yZz1guG/TXbmXjmT2UVe0JPHLNy2bu6EDV4Cu+1GcqOXe8TB7Ney0fWJlA4PZ3lIE faizyTSCyx2AU0DKVouWjV4OVgu4sQFMYbIMwkNUugvLxWmMt7NhbK12lczAtclBLDBH 0UHGVk846A8BBa+d2ra03kb5VC9tsnPsUGb2f+pccVIvleacIQ0MJAT0x7gtrlRl7Ncs sLfGQHFStTqzAnhKvf/KtoPFRICggC3XaeoV1IXa4H4LTLueQlgwswnuVCrpWI3rVQVt H9Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d22wxBkn; 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 202-v6si13639643pfz.227.2018.10.15.23.28.02; Mon, 15 Oct 2018 23:28:17 -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=d22wxBkn; 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 S1727351AbeJPOQR (ORCPT + 99 others); Tue, 16 Oct 2018 10:16:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:40882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727093AbeJPOQR (ORCPT ); Tue, 16 Oct 2018 10:16:17 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 7A9F4208B3; Tue, 16 Oct 2018 06:27:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539671244; bh=NaN9aAokQaczPfGn05CUFy8guXpRqzf7zL8yQzcBaRY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d22wxBknidUycQgLi8A2S02+noUTQjTDyKmqKPxKWRI5iEGkNyVWXJX/39DXgLP7k lPlIGyACxbOKiS+JyevsPq+S5HqhBqcSWQUGuf8Yn4rl6A0mQ/wmkiC/CcgPkvUStZ Eke+0blaaqidLm5C7DtYvw2y/r+sL1AyLhRuNvAE= Date: Tue, 16 Oct 2018 08:27:21 +0200 From: Greg KH To: Roman Kiryanov Cc: linux-kernel@vger.kernel.org, Todd Kjos Subject: Re: [PATCH v3 06/15] platform: goldfish: pipe: Move memory allocation from probe to init Message-ID: <20181016062721.GA882@kroah.com> References: <20181003171720.169953-1-rkir@google.com> <20181003171720.169953-6-rkir@google.com> <20181015183458.GA28454@kroah.com> <20181015185611.GA5201@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 15, 2018 at 12:06:12PM -0700, Roman Kiryanov wrote: > > > probe does not know what memory to allocate. We have several versions > > > of the driver (with different init) and different versions allocate > > > different state. > > > > I only see one driver here. > > It will be added in "PATCH v3 15/15". There will be two init functions > allocating different states. I think we are getting our terms confused here. "init" usually means module_init(), is that what you are referring to here? probe means when your bus-specific driver's probe function is called because the kernel recognizes your hardware as being present. At module_init time, you should do nothing except register your bus specific driver. At probe time, allocate memory all you want, that is the correct point in time to do it. So yes, if you have two separate drivers, you will have two separate init functions, but both of them should just register the bus specific driver. > > Why does probe not know what to allocate? That is exactly when the > > device is bound to the driver, you have _way_ more information than you > > do at init time. > > We have two versions of the driver. Probe asks for the version and > calls the init function for this version. > I don't want probe to know everything about all versions. Why would your probe function know, or care, about versions? That's up to the driver core. How is your probe function learning about the "version" to use here? > > > >, not init time as what > > > > happens if the hardware is not present yet your driver is loaded? > > > > > > init will have to rollback what it allocated. > > > > But those resources it will sit there wasted until unload happens. And > > unload _never_ happens on a system unless you are a developer working on > > the module. > > If probe fails I expect the kernel to release all resources. Is this > not the case? You have to clean up after your probe function failing before you return from it. thanks, greg k-h