linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
To: Anton Blanchard <anton@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2] powerpc/powernv: Platform dump interface
Date: Wed, 12 Feb 2014 20:31:26 +0530	[thread overview]
Message-ID: <52FB8CC6.2010005@linux.vnet.ibm.com> (raw)
In-Reply-To: <20140209082034.0329833d@kryten>

On 02/09/2014 02:50 AM, Anton Blanchard wrote:
>
> Hi Vasant,
>
>> +static void free_dump_sg_list(struct opal_sg_list *list)
>> +{
>> +	struct opal_sg_list *sg1;
>> +	while (list) {
>> +		sg1 = list->next;
>> +		kfree(list);
>> +		list = sg1;
>> +	}
>> +	list = NULL;
>> +}
>> +
>> +/*
>> + * Build dump buffer scatter gather list
>> + */
>> +static struct opal_sg_list *dump_data_to_sglist(void)
>> +{
>> +	struct opal_sg_list *sg1, *list = NULL;
>> +	void *addr;
>> +	int64_t size;
>> +
>> +	addr = dump_record.buffer;
>> +	size = dump_record.size;
>> +
>> +	sg1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
>> +	if (!sg1)
>> +		goto nomem;
>> +
>> +	list = sg1;
>> +	sg1->num_entries = 0;
>> +	while (size > 0) {
>> +		/* Translate virtual address to physical address */
>> +		sg1->entry[sg1->num_entries].data =
>> +			(void *)(vmalloc_to_pfn(addr) << PAGE_SHIFT);
>> +
>> +		if (size > PAGE_SIZE)
>> +			sg1->entry[sg1->num_entries].length =
>> PAGE_SIZE;
>> +		else
>> +			sg1->entry[sg1->num_entries].length = size;
>> +
>> +		sg1->num_entries++;
>> +		if (sg1->num_entries >= SG_ENTRIES_PER_NODE) {
>> +			sg1->next = kzalloc(PAGE_SIZE, GFP_KERNEL);
>> +			if (!sg1->next)
>> +				goto nomem;
>> +
>> +			sg1 = sg1->next;
>> +			sg1->num_entries = 0;
>> +		}
>> +		addr += PAGE_SIZE;
>> +		size -= PAGE_SIZE;
>> +	}
>> +	return list;
>> +
>> +nomem:
>> +	pr_err("%s : Failed to allocate memory\n", __func__);
>> +	free_dump_sg_list(list);
>> +	return NULL;
>> +}
>> +
>> +/*
>> + * Translate sg list address to absolute
>> + */
>> +static void sglist_to_phy_addr(struct opal_sg_list *list)
>> +{
>> +	struct opal_sg_list *sg, *next;
>> +
>> +	for (sg = list; sg; sg = next) {
>> +		next = sg->next;
>> +		/* Don't translate NULL pointer for last entry */
>> +		if (sg->next)
>> +			sg->next = (struct opal_sg_list
>> *)__pa(sg->next);
>> +		else
>> +			sg->next = NULL;
>> +
>> +		/* Convert num_entries to length */
>> +		sg->num_entries =
>> +			sg->num_entries * sizeof(struct
>> opal_sg_entry) + 16;
>> +	}
>> +}
>> +
>> +static void free_dump_data_buf(void)
>> +{
>> +	vfree(dump_record.buffer);
>> +	dump_record.size = 0;
>> +}
>

Anton,

> This looks identical to the code in opal-flash.c. Considering how
> complicated it is, can we put it somewhere common?

Thanks for the review.. Will look into it next week.

-Vasant

>
> Anton
>

  reply	other threads:[~2014-02-12 15:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-16 12:16 [PATCH v2] powerpc/powernv: Platform dump interface Vasant Hegde
2014-02-08 21:20 ` Anton Blanchard
2014-02-12 15:01   ` Vasant Hegde [this message]
2014-03-25  5:52     ` Anton Blanchard
2014-03-26 14:14       ` Vasant Hegde
2014-02-21  0:15 ` [PATCH v2] powernv: don't attempt to refetch the FSP dump until the user has explicitly acked it Stewart Smith
2014-02-21  2:52   ` Michael Neuling
2014-02-21  3:34     ` Stewart Smith
  -- strict thread matches above, loose matches on Subject: below --
2014-02-25  1:58 [PATCH] powerpc/powernv Platform dump interface Stewart Smith
2014-02-26  5:42 ` [PATCH v2] " Stewart Smith

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=52FB8CC6.2010005@linux.vnet.ibm.com \
    --to=hegdevasant@linux.vnet.ibm.com \
    --cc=anton@samba.org \
    --cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).