lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHQjnOOpaoVAA8RWrYE5yy0eUN=rWLxZ9XEHZR8ajP_AUeOw8Q@mail.gmail.com>
Date:	Wed, 7 Dec 2011 17:12:04 +0900
From:	KyongHo Cho <pullip.cho@...sung.com>
To:	Marek Szyprowski <m.szyprowski@...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

2011/12/6 Marek Szyprowski <m.szyprowski@...sung.com>:
> 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.
>
Understood.
I will change GFP_KERNEL to GFP_ATOMIC in the next patch.
I think it is not good idea to make iommu_map() allocate 2nd level page table
from a specific physical memory pool.

BTW, what about using GFP_KERNEL without __GFP_WAIT?
Then, iommu_map() will fail if there is not enough memory.

Thanks.

KyongHo.
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ