[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <009c01ccb423$3d9e95c0$b8dbc140$%szyprowski@samsung.com>
Date: Tue, 06 Dec 2011 15:27:53 +0100
From: Marek Szyprowski <m.szyprowski@...sung.com>
To: 'KyongHo Cho' <pullip.cho@...sung.com>
Cc: 'Ohad Ben-Cohen' <ohad@...ery.com>,
linux-samsung-soc@...r.kernel.org,
'Russell King' <linux@....linux.org.uk>,
linux-kernel@...r.kernel.org,
'Younglak Kim' <younglak1004.kim@...sung.com>,
iommu@...ts.linux-foundation.org,
'Kukjin Kim' <kgene.kim@...sung.com>,
Sylwester Nawrocki <s.nawrocki@...sung.com>,
'Sanghyun Lee' <sanghyun75.lee@...sung.com>,
linux-arm-kernel@...ts.infradead.org
Subject: RE: [PATCH v7 2/2] iommu/exynos: Add iommu driver for Exynos Platforms
Hello,
On Tuesday, December 06, 2011 1:21 PM KyongHo Cho wrote:
> On Tue, Dec 6, 2011 at 8:48 PM, Marek Szyprowski
> <m.szyprowski@...sung.com> wrote:
> > Hello,
> >
> > I'm trying to integrate your SYSMMU driver with my DMA-mapping & IOMMU
> > API integration patches. I've noticed some issues, please see my comments below.
> >
> Thank you!
>
> > On Friday, November 18, 2011 10:48 AM KyongHo Cho wrote:
> >
> >> +
> >> +static int exynos_sysmmu_probe(struct platform_device *pdev)
> >> +{
> >> + struct resource *res, *ioarea;
> >> + int ret;
> >> + int irq;
> >> + struct device *dev;
> >> + void *sfr;
> >> + struct sysmmu_drvdata *data;
> >> + char *emsg;
> >> +
> >> + dev = &pdev->dev;
> >> +
> >> + if (dev_get_platdata(dev) == NULL) {
> >> + pr_debug("%s: No System MMU is assigned for %s.%d.\n", __func__,
> >> + pdev->name, pdev->id);
> >> + return -ENODEV;
> >> + }
> >> +
> >> + data = kzalloc(sizeof(*data), GFP_KERNEL);
> >> + if (!data) {
> >> + emsg = "Not enough memory";
> >> + ret = -ENOMEM;
> >> + goto err_alloc;
> >> + }
> >> +
> >> + data->owner = dev_get_platdata(dev);
> >> +
> >> + ret = dev_set_drvdata(dev, data);
> >> + if (ret) {
> >> + emsg = "Unable to set driver data.";
> >> + goto err_init;
> >> + }
> >> +
> >> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> + if (!res) {
> >> + emsg = "Failed probing system MMU: failed to get resource.";
> >> + goto err_init;
> >> + }
> >> +
> >> + ioarea = request_mem_region(res->start, resource_size(res),
> >> + dev_name(dev));
> >> + if (ioarea == NULL) {
> >> + emsg = "failed to request memory region.";
> >> + ret = -ENOMEM;
> >> + goto err_init;
> >> + }
> >> +
> >> + sfr = ioremap(res->start, resource_size(res));
> >> + if (!sfr) {
> >> + emsg = "failed to call ioremap().";
> >> + ret = -ENOENT;
> >> + goto err_ioremap;
> >> + }
> >> +
> >> + irq = platform_get_irq(pdev, 0);
> >> + if (irq <= 0) {
> >> + emsg = "failed to get irq resource.";
> >> + ret = irq;
> >> + goto err_irq;
> >> + }
> >> +
> >> + ret = request_irq(irq, exynos_sysmmu_irq, 0, dev_name(dev), data);
> >> + if (ret) {
> >> + emsg = "failed to request irq.";
> >> + goto err_irq;
> >> + }
> >> +
> >> + data->clk = clk_get(dev, "sysmmu");
> >> + if (IS_ERR(data->clk)) {
> >> + emsg = "failed to get clock descriptor";
> >> + ret = PTR_ERR(data->clk);
> >> + goto err_clk;
> >> + }
> >> +
> >> + data->dev = dev;
> >> + data->sfrbase = sfr;
> >> + __set_fault_handler(data, &default_fault_handler);
> >> + rwlock_init(&data->lock);
> >
> > Here is a serious problem: __set_fault_handler takes data->lock which is initialized after
> calling
> > this function.
> >
>
> Yeah, you're right. Thank you. I didn't notice it.
> I will fix it.
>
> >> +
> >> +static unsigned long *alloc_lv2entry(unsigned long *sent, unsigned long iova,
> >> + short *pgcounter)
> >> +{
> >> + if (lv1ent_fault(sent)) {
> >> + unsigned long *pent;
> >> +
> >> + pent = kzalloc(1024, GFP_KERNEL);
> >
> > I would use GFP_ATOMIC here. iommu_map() function might be called in atomic context, and
> > GFP_KERNEL here causes kernel ops/warning.
>
> I wanted to avoid to allocate memory from emergency pool.
> Do you think that it needs to allocate memory with GFP_ATOMIC flag?
Otherwise it will very hard to get it integrated with DMA mapping framework. GFP_ATOMIC
memory is allocated straight from system free lists, which are refilled on the next
non-atomic allocation if the watermark level is low enough.
It will be best if iommu_map() can be extended with allocation flags argument, so the
caller can decide if iommu driver can use GFP_ATOMIC or GFP_KERNEL depending on the context.
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists