From: Chris Wright Subject: Re: [PATCH 14/15] [swiotlb] Move initialization (swiotlb_init) and its friends in swiotlb-default.c Date: Tue, 19 Jan 2010 10:55:19 -0800 Message-ID: <20100119185519.GE3204@sequoia.sous-sol.org> References: <1263510064-16788-8-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-9-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-10-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-11-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-12-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-13-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-14-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-15-git-send-email-konrad.wilk@oracle.com> <20100115021453.GH6021@sequoia.sous-sol.org> <20100119174510.GM11986@phenom.dumpdata.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20100119174510.GM11986@phenom.dumpdata.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Konrad Rzeszutek Wilk Cc: fujita.tomonori@lab.ntt.co.jp, jeremy@goop.org, xen-devel@lists.xensource.com, Ian.Campbell@eu.citrix.com, joerg.roedel@amd.com, Chris Wright , iommu@lists.linux-foundation.org, dwmw2@infradead.org, alex.williamson@hp.com List-Id: xen-devel@lists.xenproject.org * Konrad Rzeszutek Wilk (konrad.wilk@oracle.com) wrote: > > > +void __init > > > +swiotlb_init(int verbose) > > > +{ > > > + swiotlb_register_engine(&swiotlb_ops); > > > + swiotlb_init_with_default_size(&swiotlb_ops, 64 * (1<<20), > > > + verbose); /* default to 64MB */ > > > +} > > > > I'd expect the swiotlb-default file to have only private impl. of the > > swiotlb_engine. Shouldn't this and the init stay in swiotlb.c? Also, > > Hmm, were you thinking that it might make sense to pass in > a swiotlb_ops to swiotlb_init so that it can make the right assignments? Yeah, something like that. > The reason why I stuck here was that the swiotlb_ops needed to be > visible to this function, and having it in swiotlb.c would mean it must > now include the header definition for swiotlb-defualt.h. And part of that need is because the allocator (effectively common/global) is writing to impl. private data, like ->nslabs. But if you move that back, then this may not be an issue. > > would you ever call swiotlb_init w/out register_engine, why not move > > register to the swiotlb_init? > > In essence combine swiotlb_register_engine with swiotlb_init_with_default_size? Yep. > There would still be a need for late call mechanism. > Perhaps having two variants of swiotlb_init?: swiotlb_early_init(struct > swiotlb_engine *swiotlb_ops) and swiotlb_late_init(struct swiotlb_engine > *swiotlb_ops)? That's basically what we have now, swiotlb{,_late}_init_with_default_size, so seems reasonable to me. > Or perhaps just pass in an argument: swiotlb_init(int late)? > > Furthermore have this new swiotlb_init detect if some of the fields > (start ,end, overflow_buffer) have been allocated and if so skip the > default allocation altogether? That would keep the allocate, ->release, allocate cycle from happening (which seems odd when it's the same sizes and same core allocation). Part of why I thought there was too much moved into the impl. private engine structure. thanks, -chris