mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@debian.org>
To: Matthew Wilcox <willy@debian.org>,
	Linus Torvalds <torvalds@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] expand_resource
Date: Tue, 30 Sep 2003 23:14:11 +0100	[thread overview]
Message-ID: <20030930221411.GF24824@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20030930222708.A10154@flint.arm.linux.org.uk>

On Tue, Sep 30, 2003 at 10:27:08PM +0100, Russell King wrote:
> On Tue, Sep 30, 2003 at 10:04:10PM +0100, Matthew Wilcox wrote:
> > +/*
> > + * Expand an existing resource by size amount.
> > + */
> > +int expand_resource(struct resource *res, unsigned long size,
> > +			   unsigned long align)
> > +{
> 
> Could we have the kerneldoc stuff added to this function?

Certainly.  Rather than answering your question below directly,
let's see if the kerneldoc answers it (and if not, then the kerneldoc
needs to be made clearer).

/**
 * expand_resource - Expand an existing resource
 * @res: Resource already linked into the resource tree.
 * @size: Amount of additional space requested below @res.
 * @align: Required alignment of new space.
 *
 * This function is intended to be called when we need more space
 * below an existing resource than currently exists.  The @size and
 * @align parameters describe the requirements of the child resource,
 * not the parent.  Note that this call does not attempt to expand
 * the parent of @res as that might require reprogramming devices.
 * If a caller would like this behaviour, they must handle the recursion.
 */

> My main
> question though is - what is the intended purpose of "align" ?  As
> it is implemented, it seems to have a weird behaviour:
> 
> - if we expand the "end" of the resource, we round it towards an
>   address which is a multiple of align, but "start" may not be
>   a multiple of align.
> - if we expand "start", we round it down towards a multiple of
>   align.  However, "end" may not be a multiple of align.
> 
> This may actually be of use to PCMCIA IO space handling - we only
> have two windows, but we may need to expand them if we have a multi-
> function card if we have more than 2 areas to map.  In this case,
> we'd need to know whether "start" was expanded or "end" was expanded
> since we can't change the use of the already-allocated resource.

Heh, this sounds almost identical to the PARISC problem.  I knew other
users would come out of the woodwork if I sent the patch ;-)  We also
need to know whether the start or end was changed to reprogram the
parent device -- see the caller in drivers/parisc/ccio-dma.c:

        if (expand_resource(parent, size, align) != 0) {
                printk(KERN_ERR "Unable to expand %s window by 0x%lx\n",
                       parent->name, size);
                return;
        }
        __raw_writel(((parent->start)>>16) | 0xffff0000,
                     (unsigned long)&(ioc->ioc_hpa->io_io_low));
        __raw_writel(((parent->end)>>16) | 0xffff0000,
                     (unsigned long)&(ioc->ioc_hpa->io_io_high));

> It may make sense to do something more generic, like:
> 
> int adjust_resource(struct resource *res, unsigned long start,
> 		    unsigned long end);
> 
> so that the caller knows what he's requesting and knows whether that
> change succeeded or failed.  However, it is something I'd need to
> look deeper into when I have more time available to look at such
> stuff, so please don't take the above as a well thought-out solution.

I don't like that.  It puts more work into the caller, but doesn't
seem to simplify the _resource function.

-- 
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk

  reply	other threads:[~2003-09-30 22:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-30 21:04 Matthew Wilcox
2003-09-30 21:27 ` Russell King
2003-09-30 22:14   ` Matthew Wilcox [this message]
2003-09-30 22:33     ` Russell King
2003-10-01 14:25       ` Matthew Wilcox
2003-10-01 17:50         ` Matthias Urlichs

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=20030930221411.GF24824@parcelfarce.linux.theplanet.co.uk \
    --to=willy@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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

Powered by JetHome