mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: "'KyongHo Cho'" <pullip.cho@samsung.com>
Cc: "'Ohad Ben-Cohen'" <ohad@wizery.com>,
	linux-samsung-soc@vger.kernel.org,
	"'Russell King'" <linux@arm.linux.org.uk>,
	linux-kernel@vger.kernel.org,
	"'Younglak Kim'" <younglak1004.kim@samsung.com>,
	iommu@lists.linux-foundation.org,
	"'Kukjin Kim'" <kgene.kim@samsung.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	"'Sanghyun Lee'" <sanghyun75.lee@samsung.com>,
	linux-arm-kernel@lists.infradead.org
Subject: RE: [PATCH v7 2/2] iommu/exynos: Add iommu driver for Exynos Platforms
Date: Tue, 06 Dec 2011 15:27:53 +0100	[thread overview]
Message-ID: <009c01ccb423$3d9e95c0$b8dbc140$%szyprowski@samsung.com> (raw)
In-Reply-To: <CAHQjnOM9N8zJmiNnHfrN00jbF8Wk5WwtsBsuPsC2Xv0g_O1tdA@mail.gmail.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@samsung.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




  reply	other threads:[~2011-12-06 14:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18  9:47 [PATCH v7 0/2] iommu/exynos: Add IOMMU/System MMU driver for Samsung Exynos KyongHo Cho
2011-11-18  9:47 ` [PATCH v7 1/2] ARM: EXYNOS: Change System MMU platform device definitions KyongHo Cho
2011-12-06 11:51   ` Marek Szyprowski
2011-11-18  9:47 ` [PATCH v7 2/2] iommu/exynos: Add iommu driver for Exynos Platforms KyongHo Cho
2011-12-06 11:48   ` Marek Szyprowski
2011-12-06 12:20     ` KyongHo Cho
2011-12-06 14:27       ` Marek Szyprowski [this message]
2011-12-07  8:12         ` KyongHo Cho
2011-11-23 11:46 ` [PATCH v7 0/2] iommu/exynos: Add IOMMU/System MMU driver for Samsung Exynos Joerg Roedel
2011-12-01  7:29   ` Kukjin Kim
2011-12-01 18:58     ` 'Joerg Roedel'
2011-12-02  8:43       ` Kukjin Kim
2011-12-02  8:49         ` 'Joerg Roedel'
2011-12-18 16:04           ` Kukjin Kim
2011-12-18 18:02             ` 'Joerg Roedel'
2011-12-05 15:47 ` Joerg Roedel
2011-12-05 23:24   ` Kyungmin Park
2011-12-06 12:13     ` KyongHo Cho
2011-12-06 12:47       ` Kyungmin Park
2011-12-06 12:57       ` Joerg Roedel
2011-12-06 16:23   ` Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='009c01ccb423$3d9e95c0$b8dbc140$%szyprowski@samsung.com' \
    --to=m.szyprowski@samsung.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=ohad@wizery.com \
    --cc=pullip.cho@samsung.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sanghyun75.lee@samsung.com \
    --cc=younglak1004.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®