lkml.org 
[lkml]   [2009]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 19/21] amd64_edac: add debugging/testing code
On Tue, 28 Apr 2009 17:06:11 +0200
Borislav Petkov <borislav.petkov@amd.com> wrote:

> From: Doug Thompson <dougthompson@xmission.com>
>
> This is for dumping different registers and testing the address mapping
> logic using the ECC syndromes.
>
>
> ...
>
> +static ssize_t amd64_nbea_store(struct mem_ctl_info *mci,
> + const char *data, size_t count)
> +{
> + struct amd64_pvt *pvt = mci->pvt_info;
> + unsigned long long value;
> + int rc;
> +
> + rc = strict_strtoull(data, 16, &value);
> + if (rc != -EINVAL) {
> + debugf0("%s() received NBEA= 0x%llx\n", __func__, value);
> +
> + /* place the value into the virtual error packet */
> + pvt->ctl_error_info.nbeal = (u32) value;
> + value >>= 32;
> + pvt->ctl_error_info.nbeah = (u32) value;
> +
> + /* Process the Mapping request */
> + /* TODO: Add race preventation */
> + amd64_process_error_info(mci, &pvt->ctl_error_info, 1);
> +
> + return count;
> + }
> + return 0;

I think we want to return `rc' here, not zero?

> +}
> +
> +/*
> + * amd64_nbea_show
> + *
> + * display back what the last NBEA address was written
> + */
> +static ssize_t amd64_nbea_show(struct mem_ctl_info *mci, char *data)
> +{
> + struct amd64_pvt *pvt = mci->pvt_info;
> + u64 value;
> +
> + value = pvt->ctl_error_info.nbeah;
> + value <<= 32;
> + value |= pvt->ctl_error_info.nbeal;
> +
> + return sprintf(data, "%lx\n", (unsigned long) value);

fyi, you could simply do

return sprintf(data, "%llx\n", value);

here (and in all the other places). `u64' will always be implemented
as `unsigned long long' on this architecture. One day _all_ 64-bit
architectures will use ull for u64 and zillions of these typecasts will
no longer be needed. You'll be safe preparing for that day in this
driver ;)

> +}
> +
> +/*
> + * amd64_nbsl_store
> + *
> + * accept and store the NBSL value user desires
> + */
> +static ssize_t amd64_nbsl_store(struct mem_ctl_info *mci,
> + const char *data, size_t count)
> +{
> + struct amd64_pvt *pvt = mci->pvt_info;
> + unsigned long value;
> + int rc;
> +
> + rc = strict_strtoul(data, 16, &value);
> + if (rc != -EINVAL) {
> + debugf0("%s() received NBSL= 0x%lx\n", __func__, value);
> +
> + /* place the NBSL value into the virtual error packet */
> + pvt->ctl_error_info.nbsl = (u32) value;
> +
> + return count;
> + }
> + return 0;

Again, this should report the error.

> +}
> +
>
> ...
>
> +/*
> + * amd64_nbsh_store
> + *
> + * accept and store the NBSH value user desires
> + */
> +static ssize_t amd64_nbsh_store(struct mem_ctl_info *mci,
> + const char *data, size_t count)
> +{
> + struct amd64_pvt *pvt = mci->pvt_info;
> + unsigned long value;
> + int rc;
> +
> + rc = strict_strtoul(data, 16, &value);
> + if (rc != -EINVAL) {
> + debugf0("%s() received NBSL= 0x%lx\n", __func__, value);
> +
> + /* place the NBSL value into the virtual error packet */
> + pvt->ctl_error_info.nbsh = (u32) value;
> +
> + return count;
> + }

Many instances...

> + return 0;
> +}
> +
>
> ...
>
> +static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data)
> +{
> + u64 hole_base = 0;
> + u64 hole_offset = 0;
> + u64 hole_size = 0;
> +
> + amd64_get_dram_hole_info(mci, &hole_base, &hole_offset, &hole_size);
> +
> + return sprintf(data, "%lx %lx %lx\n",
> + (long unsigned int) hole_base,
> + (long unsigned int) hole_offset,
> + (long unsigned int) hole_size);

hm, odd. We'd normally use plain old `unsigned long' here. But as
mentioned above, we can remove these casts.

> +}
>
> ...
>



\
 
 \ /
  Last update: 2009-04-28 20:37    [W:0.171 / U:8.296 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site