* V4L/ARM: videobuf-dma-contig no longer works on my ARM machine
From: Janusz Krzysztofik @ 2011-04-09 15:10 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20110409071624.GE5573@n2100.arm.linux.org.uk>
(CC: Jiri Slaby, the author of the problematic change; truncate subject)
On Sat, 09 Apr 2011, at 09:16:24, Russell King - ARM Linux wrote:
> On Sat, Apr 09, 2011 at 03:33:39AM +0200, Janusz Krzysztofik wrote:
> > Since there were no actual problems reported before, I suppose the
> > old code, which was passing to remap_pfn_range() a physical page
> > number calculated from dma_alloc_coherent() privided dma_handle,
> > worked correctly on all platforms actually using
> > videobud-dma-config. Now, on my ARM machine, a completely
> > different, then completely wrong physical address, calculated as
> > virt_to_phys(dma_alloc_coherent()), is used instead of the
> > dma_handle, which causes the machine to hang.
>
> virt_to_phys(dma_alloc_coherent()) is and always has been invalid,
> and will break on several architectures apart from ARM.
Hi Russell,
Thanks for confirmation.
For now, I have two working, but not very elegant, solutions:
1. For architectures which provide dma_mmap_coherent() (only ARM for
now), use it instead of remap_pfn_range(). However, this requires
setting vma->vm_pgoff to 0 before calling dma_mmap_coherent(). I don't
really understand what this vma->vm_pgoff business is all about, I've
only verified that:
a) a non-zero value, comming with any but the first buffer, for a reason
not quite clear to me, breaks comparison of the requested vma size,
calculated as:
(vma->vm_end - vma->vm_start) >> PAGE_SHIFT
with the just allocated arm_vmregion avaliable space, calculated as:
((c->vm-end - c->vm_start) >> PAGE_SHIFT) - vma->vm_pgoff
b) vma->vm_pgoff is overwriten, for a reason not quite clear to me, by
remap_pfn_range() called from dma_mmap_coherent(), so first resetting
its value to 0 should not affect anything else but dma_mmap_coherent().
If someone can explain me how this vm_pgoff handling inconsistency
should be fixed without dirty hacks, I can try to implement it.
2. Use depreciated bus_to_virt(dma_handle) instead of mem->vaddr, like
this:
remap_pfn_range(...,
PFN_DOWN(virt_to_phys(bus_to_virt(dma_handle))), ...)
If 1. is acceppted, then 2. may still be considered for architectures
which neither support virt_to_phys(dma_alloc_coherent()) nor provide
their own dma_mmap_coherent() implementation.
Thanks,
Janusz
^ permalink raw reply
* Re: Using of RAID10,offset for faster writes
From: Keld Jørn Simonsen @ 2011-04-09 15:05 UTC (permalink / raw)
To: David Brown; +Cc: linux-raid
In-Reply-To: <inphu9$5kl$1@dough.gmane.org>
On Sat, Apr 09, 2011 at 02:03:21PM +0200, David Brown wrote:
> During a discussion about RAID in another context (a Linux newsgroup), I
> began thinking about the speeds of the different RAID10 layouts for
> different usages. RAID10,far is often the fastest choice for general
> use - you get striped reads for large reads, and access times are good
> because you can get the data from either disk. The disadvantage is that
> writes involve a lot of extra head movement, as you need copies of the
> data on two widely separated areas on the each disk. But for general
> use, you read a lot more often than you write, so the tradeoff is worth it.
>
> In the discussion we were looking particularly at swap space on RAID.
> This is a usage that requires a lot of writing, especially small writes.
> Using the RAID10,offset layout should give you most of the benefits of
> RAID10,far when it comes to reading - you don't get quite as efficient
> block reads for large reads, but you can still do a lot of striping in
> the reads. And writes will involve far less head movement, and so
> should complete faster.
>
> Has anyone tried this, or done any benchmarking?
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Some tests indicate that the theoretical slower writing speed of
raid10,far tends to be minimized by the elevator algoritm for the disk.
Writes are normally just delivered to the kernel in-core buffers, and
then every 30 secs or so flushed to the disk. The elevator orders this
writing to minimize head movement. So there is almost no penalty for
writes for raid10,far.
Anyway, for swapping the paetition siz is normally quite small, say 2 to
10 GB, and head movement is thus quite small.
Tests show that raid10,offset does not really stripe sequential reads.
Anyway it would be interesting to see tests on swapping on rid10,offset
vs raid10,far. I am not sure how to test it. But it could be load times
for eg. openoffice in a swapped state - loading a big app is one of the
areas where you would notice the speed most in a user environment. Tht
could be the reading test. For the writing test, one could operate with
a rather small swap partition, and then load a lot of big apps.
Best regards
Keld
^ permalink raw reply
* [PATCH] ASoC: sn95031: decorate function with __devexit_p()
From: Lu Guanqun @ 2011-04-09 15:03 UTC (permalink / raw)
To: ALSA, Lu Guanqun
Cc: Koul Vinod, Takashi Iwai, Liam Girdwood, Harsha Priya, Mark Brown
According to the comments in include/linux/init.h:
"Pointers to __devexit functions must use __devexit_p(function_name), the
wrapper will insert either the function_name or NULL, depending on the config
options."
Fix this issue in codecs sn95031.
Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
---
sound/soc/codecs/sn95031.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c
index 569555f..f70977d 100644
--- a/sound/soc/codecs/sn95031.c
+++ b/sound/soc/codecs/sn95031.c
@@ -918,7 +918,7 @@ static struct platform_driver sn95031_codec_driver = {
.owner = THIS_MODULE,
},
.probe = sn95031_device_probe,
- .remove = sn95031_device_remove,
+ .remove = __devexit_p(sn95031_device_remove),
};
static int __init sn95031_init(void)
^ permalink raw reply related
* [Qemu-devel] [PATCH] ppc: remove a write-only variable
From: Blue Swirl @ 2011-04-09 14:56 UTC (permalink / raw)
To: qemu-devel, Alexander Graf
Remove a write-only variable, spotted by GCC 4.6.0:
/src/qemu/hw/ppc.c: In function 'power7_set_irq':
/src/qemu/hw/ppc.c:255:9: error: variable 'cur_level' set but not used
[-Werror=unused-but-set-variable]
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
hw/ppc.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/hw/ppc.c b/hw/ppc.c
index dabb816..1873328 100644
--- a/hw/ppc.c
+++ b/hw/ppc.c
@@ -252,11 +252,9 @@ void ppc970_irq_init (CPUState *env)
static void power7_set_irq (void *opaque, int pin, int level)
{
CPUState *env = opaque;
- int cur_level;
LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
env, pin, level);
- cur_level = (env->irq_input_state >> pin) & 1;
switch (pin) {
case POWER7_INPUT_INT:
--
1.7.2.5
^ permalink raw reply related
* Re: Preferred way for rt-linux using git
From: Niccolò Belli @ 2011-04-09 14:56 UTC (permalink / raw)
To: linux-rt-users@vger.kernel.org
In-Reply-To: <4DA05A89.9080008@osadl.org>
Il 09/04/2011 15:09, Carsten Emde ha scritto:
> Have you ever tried to backport the required drivers to 2.6.33? We did
> it with a number of recent kernel components; was not too difficult.
> Which drivers do you need?
Uhm... I fear it will not be simple, among other things I will have to
backport i2c, sata3, maybe ethernet and above all the whole intel
graphic stack from 2.6.40 aka intel drm git branch (hoping it will solve
the graphic corruption problems I have with 2.6.38 and 2.6.39-rc1). I
really hope rt will find its way into mainline, everything will be much
more simple.
Darkbasic
^ permalink raw reply
* Re: Confused over packfile and index design
From: Shawn Pearce @ 2011-04-09 14:45 UTC (permalink / raw)
To: Steven E. Harris; +Cc: git
In-Reply-To: <m28vvj7b0d.fsf@Spindle.sehlabs.com>
On Sat, Apr 9, 2011 at 10:30, Steven E. Harris <seh@panix.com> wrote:
> Shawn Pearce <spearce@spearce.org> writes:
>> Its meant to tell us how many bytes to malloc() in order to hold the
>> result of the libz inflate() call when the object is being read from
>> the packfile. That way we don't under or over allocate the result
>> buffer.
>
> Does Git always inflate the objects into an in-memory buffer?
Yes.
> As the
> size of these objects can be very large (given the variable-length size
> encoding), is there any provision to inflate the object to a temporary
> file?
Not currently. If you don't have enough memory for the malloc() buffer
of a big object, Git dies with an out of memory error.
--
Shawn.
^ permalink raw reply
* Re: [PATCH 1/2] mtd-utils: improve simple_strtoX usage commentary
From: Artem Bityutskiy @ 2011-04-09 14:39 UTC (permalink / raw)
To: Mike Frysinger; +Cc: MTD list
In-Reply-To: <BANLkTi=NSasDOP=xSxD3zxQNCQEOc1dV6w@mail.gmail.com>
On Fri, 2011-04-08 at 12:20 -0400, Mike Frysinger wrote:
> On Fri, Apr 8, 2011 at 11:07, Artem Bityutskiy wrote:
> > + * num = simple_strtoul(str, &error);
> > + * if (error || !is_valid_number(num))
> > + * error_happened();
>
> when i read this, it makes me think there is a "is_valid_number()"
> function i should be calling.
>
> maybe something like:
> if (error || ... number is out of range for your need ...)
> -mike
I'll do this and push this out, thanks for review!
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply
* Re: [PATCH v4] Retry Large Buffer Allocations
From: Artem Bityutskiy @ 2011-04-09 14:39 UTC (permalink / raw)
To: Ben Gardiner; +Cc: linux-mtd, Grant Erickson, Jarkko Lavinen, Bastian.Ruppert
In-Reply-To: <BANLkTik0LfxcfridxFAGtm2KYpwngvokSQ@mail.gmail.com>
On Fri, 2011-04-08 at 10:45 -0400, Ben Gardiner wrote:
> Hi Grant, Artem
>
> Thanks for this fix!
>
> On Thu, Apr 7, 2011 at 1:40 PM, Grant Erickson <marathon96@gmail.com> wrote:
> > When handling user space read or write requests via mtd_{read,write}
> > or JFFS2 medium scan requests, exponentially back off on the size of
> > the requested kernel transfer buffer until it succeeds or until the
> > requested transfer buffer size falls below the page size.
> >
> > This helps ensure the operation can succeed under low-memory,
> > highly-fragmented situations albeit somewhat more slowly.
> >
> > v2: Incorporated coding style and comment feedback from Artem.
> > v3: Incorporated more feedback from Artem. Retargeted patch against
> > l2-mtd-2.6.
> > v4: Incorporated feedback from Artem about compilation on 64-bit
> > architectures.
> >
> > Signed-off-by: Grant Erickson <marathon96@gmail.com>
>
> I tested this on da850evm by cherry-picking commit
> 64542ac252d378dc7a1122064821a884e85a9954 from
> git://git.infradead.org/users/dedekind/l2-mtd-2.6.git.
Grant sent an updated patch-set and added your Tested-by. However, there
were several conflicts which I had to. If you could test the final
patches again - that'd be great! They are in the same l2-mtd-2.6.git
tree:
8fa3c20 JFFS2: retry large buffer allocations
88ab142 mtd: mtdchar: retry large buffer allocations
99815a5 mtd: create function to perform large allocations
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply
* Re: [PATCH v5 3/3] JFFS2: Retry Large Buffer Allocations
From: Artem Bityutskiy @ 2011-04-09 14:38 UTC (permalink / raw)
To: Grant Erickson; +Cc: Jarkko Lavinen, linux-mtd
In-Reply-To: <1302277894-26132-4-git-send-email-marathon96@gmail.com>
On Fri, 2011-04-08 at 08:51 -0700, Grant Erickson wrote:
> Replace direct call to kmalloc for a potentially large, contiguous
> buffer allocation with one to mtd_kmalloc_up_to which helps ensure the
> operation can succeed under low-memory, highly- fragmented situations
> albeit somewhat more slowly.
>
> Signed-off-by: Grant Erickson <marathon96@gmail.com>
> Tested-by: Ben Gardiner <bengardiner at nanometrics.ca>
Note, I killed this Tested-by because Ben did not test the JFFS2 part.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply
* Re: platform_driver/of_platform_driver compile warning in fsldma.c
From: Kumar Gala @ 2011-04-09 14:40 UTC (permalink / raw)
To: Ira W. Snyder; +Cc: Linuxppc-dev list
In-Reply-To: <20110408153246.GA13834@ovro.caltech.edu>
On Apr 8, 2011, at 10:32 AM, Ira W. Snyder wrote:
> On Fri, Apr 08, 2011 at 04:12:13AM -0500, Kumar Gala wrote:
>> Grant,
>>=20
>> I'm being lazy, can you give any quick insight on the following =
compile warning:
>>=20
>> drivers/dma/fsldma.c:1457:2: warning: initialization from =
incompatible pointer type
>> drivers/dma/fsldma.c: In function 'fsldma_init':
>> drivers/dma/fsldma.c:1468:2: warning: passing argument 1 of =
'platform_driver_register' from incompatible pointer type
>> include/linux/platform_device.h:124:12: note: expected 'struct =
platform_driver *' but argument is of type 'struct of_platform_driver *'
>> drivers/dma/fsldma.c: In function 'fsldma_exit':
>> drivers/dma/fsldma.c:1473:2: warning: passing argument 1 of =
'platform_driver_unregister' from incompatible pointer type
>> include/linux/platform_device.h:125:13: note: expected 'struct =
platform_driver *' but argument is of type 'struct of_platform_driver *'
>>=20
>=20
> The "struct of_platform_driver" needs to be changed to a
> "struct platform_driver". Just remove the "of_" prefix, the structure
> initialization is correct. I sent a patch for this yesterday to LKML. =
The
> title is: fsldma: fix build warning caused by of_platform_device =
changes
>=20
> Ira
Ira, thanks. Hopefully it will get picked up. If not let me know.
- k=
^ permalink raw reply
* Re: 4-disk raid5 with 2 disks going bad: best way to proceed?
From: rob pfile @ 2011-04-09 14:39 UTC (permalink / raw)
To: NeilBrown; +Cc: linux-raid
In-Reply-To: <20110408221046.2aa5e685@notabene.brown>
On Apr 8, 2011, at 5:10 AM, NeilBrown wrote:
> When a device gives a hard read error md/raid always calculates the correct
> data from other devices (Assuming that parity is correct) and writes it out.
> It does this for check and for repair and for normal IO.
>
> I am no expert on SMART however if there are no reallocated sectors then
> maybe what happened is that whenever md wrote to a bad sector, the drive
> determined that the media there was still usable and wrote the data there.
> But that is just a guess.
>
excellent, thanks. this probably explains why the errors seem to be migrating around the disk - perhaps the ones that are getting corrected/rewritten are effectively being 'refreshed' and sectors that are sitting around unread for a while are rotting.
i ran another check, and this time saw several read errors on one of the bad disks, but not on the other. strangely, i did not see raid correcting these sectors. i wonder if this means they eventually returned good data. does md/raid try more than once in the face of a hard error before correcting from parity?
given that i have backups, i decided to just fail out the disk that was still giving errors. the raid is rebuilding now, and in 20h or so i'll know if i'm out of the woods. i think i'll probably also replace the other flaky disk, even though it's SMART status now looks pretty clean.
===
update: bad news... a *different* drive in the array threw a read error while rebuilding. i wonder if my controller or enclosure might be bad, since 3 out of 4 disks have exhibited random problems (and no reallocated sectors).
anyway, now the raid is up, but in a degraded state. what i want to do is bring the array back to a clean state with 3 drives and restart the rebuild onto the new disk and see what happens. how do i get the "failed" disk back into "active sync" state? mdadm --manage /dev/md1 --add /dev/sdi1 returns "device busy", and --assemble won't take --assume-clean as an argument. do i have to stop and re-start the array? a little scared to do that.
thanks,
rob
^ permalink raw reply
* Re: [PATCH 1/5 V2]arch:common:Makefile Remove unused config in the Makefile.
From: Justin P. Mattock @ 2011-04-09 14:38 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Uwe Kleine-König, trivial, linux-kernel, linux-arm-kernel
In-Reply-To: <20110408191257.GB5573@n2100.arm.linux.org.uk>
On 04/08/2011 12:12 PM, Russell King - ARM Linux wrote:
> On Fri, Apr 08, 2011 at 08:38:52AM -0700, Justin P. Mattock wrote:
>> alright I read up and sent this to the address listed on that
>> page(patches@arm.linux.org.uk) if it is incorrect let me know and I will
>> resend so that I get things correct..
>
> It appears to have arrived properly and looks fine, so... thanks.
> I'll be queuing up some stuff this weekend.
>
pretty cool patch system...
cheers,
Justin P. Mattock
^ permalink raw reply
* [PATCH 1/5 V2]arch:common:Makefile Remove unused config in the Makefile.
From: Justin P. Mattock @ 2011-04-09 14:38 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20110408191257.GB5573@n2100.arm.linux.org.uk>
On 04/08/2011 12:12 PM, Russell King - ARM Linux wrote:
> On Fri, Apr 08, 2011 at 08:38:52AM -0700, Justin P. Mattock wrote:
>> alright I read up and sent this to the address listed on that
>> page(patches at arm.linux.org.uk) if it is incorrect let me know and I will
>> resend so that I get things correct..
>
> It appears to have arrived properly and looks fine, so... thanks.
> I'll be queuing up some stuff this weekend.
>
pretty cool patch system...
cheers,
Justin P. Mattock
^ permalink raw reply
* Re: [PATCH 0/1] v2: Update ncurses
From: Tom Rini @ 2011-04-09 14:34 UTC (permalink / raw)
To: Saul Wold; +Cc: Patches and discussions about the oe-core layer
In-Reply-To: <4D9FCF5D.8060202@linux.intel.com>
On 04/08/2011 08:15 PM, Saul Wold wrote:
>
> Tom,
>
> I think your patch introduced the following problem when building
> qemux86 world build.
>
> ERROR: -------------------
> ERROR: ncurses-tools is listed in PACKAGES multiple times, this leads to
> packaging errors.
> ERROR: Please fix the metadata/report this as bug to OE bugtracker.
> ERROR: -------------------
> ERROR: -------------------
> ERROR: ncurses-terminfo is listed in PACKAGES multiple times, this leads
> to packaging errors.
> ERROR: Please fix the metadata/report this as bug to OE bugtracker.
> ERROR: -------------------
I've been testing with meta-angstrom. How do I get a poky setup (where
I assume you see this) similarly?
--
Tom Rini
Mentor Graphics Corporation
^ permalink raw reply
* [PATCH 2/2] kvm tools: Remove unnecessary goto label out_unlock
From: Asias He @ 2011-04-09 14:35 UTC (permalink / raw)
To: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar; +Cc: kvm, Asias He
In-Reply-To: <1302359725-6457-1-git-send-email-asias.hejun@gmail.com>
There is only one switch in virtio_blk_pci_io_out and
virtio_blk_pci_io_in. No need to use goto, just use break is fine.
Signed-off-by: Asias He <asias.hejun@gmail.com>
---
tools/kvm/virtio-blk.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/tools/kvm/virtio-blk.c b/tools/kvm/virtio-blk.c
index 79f27c1..06e58bc 100644
--- a/tools/kvm/virtio-blk.c
+++ b/tools/kvm/virtio-blk.c
@@ -81,7 +81,7 @@ static bool virtio_blk_pci_io_in(struct kvm *self, uint16_t port, void *data, in
break;
case VIRTIO_PCI_GUEST_FEATURES:
ret = false;
- goto out_unlock;
+ break;
case VIRTIO_PCI_QUEUE_PFN:
ioport__write32(data, blk_device.vqs[blk_device.queue_selector].pfn);
break;
@@ -91,7 +91,7 @@ static bool virtio_blk_pci_io_in(struct kvm *self, uint16_t port, void *data, in
case VIRTIO_PCI_QUEUE_SEL:
case VIRTIO_PCI_QUEUE_NOTIFY:
ret = false;
- goto out_unlock;
+ break;
case VIRTIO_PCI_STATUS:
ioport__write8(data, blk_device.status);
break;
@@ -104,10 +104,8 @@ static bool virtio_blk_pci_io_in(struct kvm *self, uint16_t port, void *data, in
break;
default:
ret = virtio_blk_pci_io_device_specific_in(data, offset, size, count);
- goto out_unlock;
};
-out_unlock:
mutex_unlock(&blk_device.mutex);
return ret;
@@ -220,10 +218,8 @@ static bool virtio_blk_pci_io_out(struct kvm *self, uint16_t port, void *data, i
break;
default:
ret = false;
- goto out_unlock;
};
-out_unlock:
mutex_unlock(&blk_device.mutex);
return ret;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 1/2] kvm tools: Make virtio console device code thread-safe
From: Asias He @ 2011-04-09 14:35 UTC (permalink / raw)
To: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar; +Cc: kvm, Asias He
In preparation for threaded execution, make the virtio console device
code safe by introducing a per-device mutex.
Signed-off-by: Asias He <asias.hejun@gmail.com>
---
tools/kvm/virtio-console.c | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/tools/kvm/virtio-console.c b/tools/kvm/virtio-console.c
index fd79c61..a140aea 100644
--- a/tools/kvm/virtio-console.c
+++ b/tools/kvm/virtio-console.c
@@ -5,6 +5,7 @@
#include "kvm/ioport.h"
#include "kvm/util.h"
#include "kvm/term.h"
+#include "kvm/mutex.h"
#include "kvm/kvm.h"
#include "kvm/pci.h"
@@ -29,6 +30,8 @@
#define PCI_VIRTIO_CONSOLE_DEVNUM 2
struct console_device {
+ pthread_mutex_t mutex;
+
struct virt_queue vqs[VIRTIO_CONSOLE_NUM_QUEUES];
struct virtio_console_config console_config;
uint32_t host_features;
@@ -39,6 +42,8 @@ struct console_device {
};
static struct console_device console_device = {
+ .mutex = PTHREAD_MUTEX_INITIALIZER,
+
.console_config = {
.cols = 80,
.rows = 24,
@@ -59,6 +64,8 @@ void virtio_console__inject_interrupt(struct kvm *self)
uint16_t head;
int len;
+ mutex_lock(&console_device.mutex);
+
vq = &console_device.vqs[VIRTIO_CONSOLE_RX_QUEUE];
if (term_readable(CONSOLE_VIRTIO) && virt_queue__available(vq)) {
@@ -67,6 +74,8 @@ void virtio_console__inject_interrupt(struct kvm *self)
virt_queue__set_used_elem(vq, head, len);
kvm__irq_line(self, VIRTIO_CONSOLE_IRQ, 1);
}
+
+ mutex_unlock(&console_device.mutex);
}
static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long offset, int size, uint32_t count)
@@ -87,13 +96,17 @@ static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long o
static bool virtio_console_pci_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
{
unsigned long offset = port - IOPORT_VIRTIO_CONSOLE;
+ bool ret = true;
+
+ mutex_lock(&console_device.mutex);
switch (offset) {
case VIRTIO_PCI_HOST_FEATURES:
ioport__write32(data, console_device.host_features);
break;
case VIRTIO_PCI_GUEST_FEATURES:
- return false;
+ ret = false;
+ break;
case VIRTIO_PCI_QUEUE_PFN:
ioport__write32(data, console_device.vqs[console_device.queue_selector].pfn);
break;
@@ -102,7 +115,8 @@ static bool virtio_console_pci_io_in(struct kvm *self, uint16_t port, void *data
break;
case VIRTIO_PCI_QUEUE_SEL:
case VIRTIO_PCI_QUEUE_NOTIFY:
- return false;
+ ret = false;
+ break;
case VIRTIO_PCI_STATUS:
ioport__write8(data, console_device.status);
break;
@@ -114,10 +128,12 @@ static bool virtio_console_pci_io_in(struct kvm *self, uint16_t port, void *data
ioport__write16(data, console_device.config_vector);
break;
default:
- return virtio_console_pci_io_device_specific_in(data, offset, size, count);
+ ret = virtio_console_pci_io_device_specific_in(data, offset, size, count);
};
- return true;
+ mutex_unlock(&console_device.mutex);
+
+ return ret;
}
static void virtio_console_handle_callback(struct kvm *self, uint16_t queue_index)
@@ -145,6 +161,7 @@ static void virtio_console_handle_callback(struct kvm *self, uint16_t queue_inde
static bool virtio_console_pci_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
{
unsigned long offset = port - IOPORT_VIRTIO_CONSOLE;
+ bool ret = true;
switch (offset) {
case VIRTIO_PCI_GUEST_FEATURES:
@@ -182,10 +199,11 @@ static bool virtio_console_pci_io_out(struct kvm *self, uint16_t port, void *dat
case VIRTIO_MSI_QUEUE_VECTOR:
break;
default:
- return false;
+ ret = false;
};
- return true;
+ mutex_unlock(&console_device.mutex);
+ return ret;
}
static struct ioport_operations virtio_console_io_ops = {
--
1.7.4.1
^ permalink raw reply related
* Re: [PATCH] add proper variable quoting to grub-mkconfig_lib (Debian bug #612417)
From: Alexander Kurtz @ 2011-04-09 14:32 UTC (permalink / raw)
To: The development of GNU GRUB
In-Reply-To: <4D9F1141.7090504@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 318 bytes --]
Am Freitag, den 08.04.2011, 15:44 +0200 schrieb Vladimir 'φ-coder/phcoder' Serbinenko:
> The (big) patch is mostly fine except:
> -Please don't add brances where not needed
> -Please don't add quoting to constants like x since x or "x" are
> strictly identical.
Better now?
Best regards
Alexander Kurtz
[-- Attachment #1.2: quote-big-adjusted.patch --]
[-- Type: text/x-patch, Size: 6205 bytes --]
diff -Naur bazaar/util/grub-mkconfig_lib.in big-adjusted/util/grub-mkconfig_lib.in
--- bazaar/util/grub-mkconfig_lib.in 2011-04-08 18:17:27.789166000 +0200
+++ big-adjusted/util/grub-mkconfig_lib.in 2011-04-09 15:23:57.974913718 +0200
@@ -16,19 +16,19 @@
transform="@program_transform_name@"
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-datarootdir=@datarootdir@
-datadir=@datadir@
-bindir=@bindir@
-sbindir=@sbindir@
-pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+datarootdir="@datarootdir@"
+datadir="@datadir@"
+bindir="@bindir@"
+sbindir="@sbindir@"
+pkgdatadir="${datadir}/`echo "@PACKAGE_TARNAME@" | sed "${transform}"`"
if test "x$grub_probe" = x; then
- grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
+ grub_probe="${sbindir}/`echo grub-probe | sed "${transform}"`"
fi
if test "x$grub_mkrelpath" = x; then
- grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
+ grub_mkrelpath="${bindir}/`echo grub-mkrelpath | sed "${transform}"`"
fi
if $(which gettext >/dev/null 2>/dev/null) ; then
@@ -44,20 +44,20 @@
make_system_path_relative_to_its_root ()
{
- ${grub_mkrelpath} $1
+ "${grub_mkrelpath}" "$1"
}
is_path_readable_by_grub ()
{
- path=$1
+ path="$1"
# abort if path doesn't exist
- if test -e $path ; then : ;else
+ if test -e "$path" ; then : ;else
return 1
fi
# abort if file is in a filesystem we can't read
- if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else
+ if "${grub_probe}" -t fs "$path" > /dev/null 2>&1 ; then : ; else
return 1
fi
@@ -72,24 +72,24 @@
convert_system_path_to_grub_path ()
{
- path=$1
+ path="$1"
grub_warn "convert_system_path_to_grub_path() is deprecated. Use prepare_grub_to_access_device() instead."
# abort if GRUB can't access the path
- if is_path_readable_by_grub ${path} ; then : ; else
+ if is_path_readable_by_grub "${path}" ; then : ; else
return 1
fi
- if drive=`${grub_probe} -t drive $path` ; then : ; else
+ if drive="`"${grub_probe}" -t drive "$path"`" ; then : ; else
return 1
fi
- if relative_path=`make_system_path_relative_to_its_root $path` ; then : ; else
+ if relative_path="`make_system_path_relative_to_its_root "$path"`" ; then : ; else
return 1
fi
- echo ${drive}${relative_path}
+ echo "${drive}${relative_path}"
}
save_default_entry ()
@@ -103,15 +103,15 @@
prepare_grub_to_access_device ()
{
- device=$1
+ device="$1"
# Abstraction modules aren't auto-loaded.
- abstraction="`${grub_probe} --device ${device} --target=abstraction`"
+ abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
for module in ${abstraction} ; do
echo "insmod ${module}"
done
- partmap="`${grub_probe} --device ${device} --target=partmap`"
+ partmap="`"${grub_probe}" --device "${device}" --target=partmap`"
for module in ${partmap} ; do
case "${module}" in
netbsd | openbsd)
@@ -121,15 +121,15 @@
esac
done
- fs="`${grub_probe} --device ${device} --target=fs`"
+ fs="`"${grub_probe}" --device "${device}" --target=fs`"
for module in ${fs} ; do
echo "insmod ${module}"
done
# If there's a filesystem UUID that GRUB is capable of identifying, use it;
# otherwise set root as per value in device.map.
- echo "set root='`${grub_probe} --device ${device} --target=drive`'"
- if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then
+ echo "set root='`"${grub_probe}" --device "${device}" --target=drive`'"
+ if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then
echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}"
fi
}
@@ -149,21 +149,21 @@
version_test_numeric ()
{
- local a=$1
- local cmp=$2
- local b=$3
+ local a="$1"
+ local cmp="$2"
+ local b="$3"
if [ "$a" = "$b" ] ; then
- case $cmp in
+ case "$cmp" in
ge|eq|le) return 0 ;;
gt|lt) return 1 ;;
esac
fi
if [ "$cmp" = "lt" ] ; then
- c=$a
- a=$b
- b=$c
+ c="$a"
+ a="$b"
+ b="$c"
fi
- if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
+ if (echo "$a" ; echo "$b") | sort -n | head -n 1 | grep -qx "$b" ; then
return 0
else
return 1
@@ -172,25 +172,25 @@
version_test_gt ()
{
- local a=`echo $1 | sed -e "s/[^-]*-//"`
- local b=`echo $2 | sed -e "s/[^-]*-//"`
+ local a="`echo "$1" | sed -e "s/[^-]*-//"`"
+ local b="`echo "$2" | sed -e "s/[^-]*-//"`"
local cmp=gt
if [ "x$b" = "x" ] ; then
return 0
fi
- case $a:$b in
+ case "$a:$b" in
*.old:*.old) ;;
- *.old:*) a=`echo -n $a | sed -e s/\.old$//` ; cmp=gt ;;
- *:*.old) b=`echo -n $b | sed -e s/\.old$//` ; cmp=ge ;;
+ *.old:*) a="`echo -n "$a" | sed -e 's/\.old$//'`" ; cmp=gt ;;
+ *:*.old) b="`echo -n "$b" | sed -e 's/\.old$//'`" ; cmp=ge ;;
esac
- version_test_numeric $a $cmp $b
- return $?
+ version_test_numeric "$a" "$cmp" "$b"
+ return "$?"
}
version_find_latest ()
{
local a=""
- for i in $@ ; do
+ for i in "$@" ; do
if version_test_gt "$i" "$a" ; then
a="$i"
fi
@@ -202,7 +202,7 @@
# printf; so this turns ' into \'. Note that you must use the output of
# this function in a printf format string.
gettext_quoted () {
- $gettext "$@" | sed "s/'/'\\\\\\\\''/g"
+ "$gettext" "$@" | sed "s/'/'\\\\\\\\''/g"
}
# Run the first argument through gettext_quoted, and then pass that and all
@@ -211,13 +211,13 @@
gettext_printf () {
local format="$1"
shift
- printf "$(gettext_quoted "$format")" "$@"
+ printf "`gettext_quoted "$format"`" "$@"
}
uses_abstraction () {
- device=$1
+ device="$1"
- abstraction="`${grub_probe} --device ${device} --target=abstraction`"
+ abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
for module in ${abstraction}; do
if test "x${module}" = "x$2"; then
return 0
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply
* Re: [PATCH v5 0/3] Retry Large Buffer Allocations
From: Artem Bityutskiy @ 2011-04-09 14:28 UTC (permalink / raw)
To: Grant Erickson; +Cc: Jarkko Lavinen, linux-mtd
In-Reply-To: <1302277894-26132-1-git-send-email-marathon96@gmail.com>
On Fri, 2011-04-08 at 08:51 -0700, Grant Erickson wrote:
> When handling user space read or write requests via mtd_{read,write}
> or JFFS2 medium scan requests, the operations can fail because the
> code backing these operations frequently requests large (128 KiB),
> contiguous blocks of memory using kmalloc.
Thanks, pushed the series to l2-mtd-2.6.git.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply
* Re: Re: [Xen-users] Nested Virtualisation question
From: Keir Fraser @ 2011-04-09 14:31 UTC (permalink / raw)
To: Jeroen Groenewegen van der Weyden
Cc: xen-devel@lists.xensource.com, Dong, Eddie
In-Reply-To: <4DA06008.2060700@grosc.com>
On 09/04/2011 14:32, "Jeroen Groenewegen van der Weyden"
<groen692@grosc.com> wrote:
> I'm now testing on a intel q9450, which does not seem to have this. I
> will move my testing to a intel e5645 which seems to have this capability.
>
> Question then is, when will the intel support be implemented? is there
> commitment from some developer? is there a roadmap planned. in short
> what is the story here.
It has been implemented already, for example see a previous patchset
submission:
http://xen.1045712.n5.nabble.com/PATCH-00-16-Nested-virtualization-for-VMX-t
d2808075.html
It just needs updating to development tip, and in particular sync'ing with
the nestedhvm common bits that got applied last week. Someone from Intel
would have to speak for how long it will take to schedule and do that work,
but I would guess we're talking weeks, rather than days or months.
-- Keir
> mfg,
> Jeroen
>
> Op 9-4-2011 13:15, Keir Fraser schreef:
>> On 09/04/2011 11:18, "Jeroen Groenewegen van der Weyden"
>> <groen692@grosc.com> wrote:
>>
>>> The HAP is default set to one, I check this also with a dry run.
>>> Please confirm all this support just amd, because I only have Intel
>>> overhere.
>> Well, quite apart from being AMD only right now (Intel patches have been
>> posted in the past, but they're not in tree yet, and I very much doubt old
>> patches would directly apply to our current development tree), I'm also
>> pretty sure that your machine doesn't support Intel EPT -- if the processor
>> can't support HAP then we silently discard that configuration request when
>> creating a domain. That's why you get error 22 (EINVAL). But even if you did
>> have Intel EPT, because Intel's nested virt patches aren't in tree yet you'd
>> just get error 95 (EOPNOTSUPP) instead!
>>
>> By the way you can tell if your system supports EPT by grepping in 'xm
>> dmesg' output (i.e., Xen's boot log) for a line stating "Extended Page
>> Tables (EPT)".
>>
>> -- Keir
>>
>>> mfg,
>>> Jeroen
>>>
>>> Op 9-4-2011 8:22, Keir Fraser schreef:
>>>> On 09/04/2011 06:07, "Jeroen Groenewegen van der Weyden"
>>>> <groen692@grosc.com> wrote:
>>>>
>>>>> The result with c/s23197
>>>>>
>>>>> Regular domain now start, en stop normaly, (xl seems to have a problem
>>>>> though, after domain closes a domain null remains in de xl list/ xmdoe
>>>>> not have this.)
>>>>> for nestedVM I added the "nestedhvm=1" in the config file of the domain.
>>>>> but the domain does not start because of "invalid argument"
>>>> NestedHVM currently requires you to be using an AMD processor with hardware
>>>> nested paging (known as HAP by Xen). Most likely you need to add hap=1 to
>>>> your config file (and hope your processor supports it).
>>>>
>>>> -- Keir
>>>>
>>>>> +++++++++ beging console
>>>>> hydra:/etc/xen/vm # xm create groscNestedVM
>>>>> Using config file "./groscNestedVM".
>>>>> Error: (22, 'Invalid argument')
>>>>> +++++++++ end console
>>>>>
>>>>> +++++++++ begin xend.log
>>>>> hydra:/etc/xen/vm # tail /var/log/xen/xend.log
>>>>> dominfo = XendDomainInfo.create(config)
>>>>> File "/usr/lib64/python2.7/site-packages/xen/xend/XendDomainInfo.py",
>>>>> line 106, in create
>>>>> vm.start()
>>>>> File "/usr/lib64/python2.7/site-packages/xen/xend/XendDomainInfo.py",
>>>>> line 473, in start
>>>>> XendTask.log_progress(0, 30, self._constructDomain)
>>>>> File "/usr/lib64/python2.7/site-packages/xen/xend/XendTask.py", line
>>>>> 209, in log_progress
>>>>> retval = func(*args, **kwds)
>>>>> File "/usr/lib64/python2.7/site-packages/xen/xend/XendDomainInfo.py",
>>>>> line 2598, in _constructDomain
>>>>> xc.hvm_set_param(self.domid, HVM_PARAM_NESTEDHVM, long(nestedhvm))
>>>>> Error: (22, 'Invalid argument')
>>>>> +++++++++++ end xend.log
>>>>>
>>>>>
>>>>> Op 7-4-2011 12:29, Tim Deegan schreef:
>>>>>> At 08:14 +0100 on 07 Apr (1302164093), Keir Fraser wrote:
>>>>>>> On 07/04/2011 08:09, "Keir Fraser"<keir.xen@gmail.com> wrote:
>>>>>>>> Probably the same as this, happening often in the automated tests:
>>>>>>> Likely reason: nestedhvm_vcpu_initialise() being called unconditionally
>>>>>>> in
>>>>>>> hvm_vcpu_initialise() even though nestedhvm has not been configured for
>>>>>>> this
>>>>>>> domain. This then fails because there is no nestedhvm handler for Intel
>>>>>>> yet.
>>>>>> This bug should be fixed by 23175:e5a750d1bf9b, arriving at a staging
>>>>>> tree near you at any moment.
>>>>>>
>>>>>>> And beyond that it's most likely an issue of a broken failure path, or a
>>>>>>> problem in the HAP code with cleaning up a half-created guest.
>>>>>> This one I'll look into now.
>>>>>>
>>>>>> Tim.
>>>>>>
>>>>>>
>>>>
>>
>>
>
^ permalink raw reply
* Re: Confused over packfile and index design
From: Steven E. Harris @ 2011-04-09 14:30 UTC (permalink / raw)
To: git
In-Reply-To: <BANLkTikXcvRf1bLJXFOHBcGcN-B0m_xSnw@mail.gmail.com>
Shawn Pearce <spearce@spearce.org> writes:
> Then remaining bytes are shoved into a libz inflate() routine until
> libz says the stream is over. As Peff mentioned elsewhere in the
> thread, libz maintains its own markers and checksum to know when the
> object's stream is over.
Ah, so even though you as the caller don't know how much data to feed to
libz, so long as you continue feeding it until it signals completion, it
will figure it out and tell you how much data it needed after all.
> As a safety measure, the inflated length from the object header is
> checked against the number of bytes returned by libz. Any remaining
> data that libz didn't consume is the next object's header and data.
I see. This means that it's the packed object's "job" -- or, rather, the
job of the parser for the packed object -- to determine the payload
length. If the data was not compressed, then perhaps the deflated size
indicated in the header could provide sufficient framing, but for now we
don't need to worry about such flexibility.
[...]
> Its meant to tell us how many bytes to malloc() in order to hold the
> result of the libz inflate() call when the object is being read from
> the packfile. That way we don't under or over allocate the result
> buffer.
Does Git always inflate the objects into an in-memory buffer? As the
size of these objects can be very large (given the variable-length size
encoding), is there any provision to inflate the object to a temporary
file?
--
Steven E. Harris
^ permalink raw reply
* [GIT PULL] MTD fixes for 2.6.39
From: Artem Bityutskiy @ 2011-04-09 14:30 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Artem Bityutskiy, David Woodhouse, linux-kernel
Hi Linus,
dwmw2 is still off duty, so I'm taiking care of MTD so far.
Here are several bug-fixes which make Atmel NAND driver work again, plus
one compilation warning fix for mtdswap. Please, pull.
The following changes since commit 0ce790e7d736cedc563e1fb4e998babf5a4dbc3d:
Linux 2.6.39-rc1 (2011-03-29 12:09:47 -0700)
are available in the git repository at:
git://git.infradead.org/mtd-2.6.git master
Hong Xu (2):
mtd: atmel_nand: fix support for CPUs that do not support DMA access
mtd: atmel_nand: use CPU I/O when buffer is in vmalloc(ed) region
Nicolas Ferre (2):
mtd: atmel_nand: trivial: change DMA usage information trace
mtd: atmel_nand: modify test case for using DMA operations
Randy Dunlap (1):
mtd: mtdswap: fix printk format warning
drivers/mtd/mtdswap.c | 2 +-
drivers/mtd/nand/atmel_nand.c | 32 ++++++++++++--------------------
2 files changed, 13 insertions(+), 21 deletions(-)
--
Artem.
^ permalink raw reply
* Re: Test vhost-net !!
From: Asdo @ 2011-04-09 14:25 UTC (permalink / raw)
To: jean-philippe.menil; +Cc: Onkar Mahajan, kvm
In-Reply-To: <4D9D68E7.2010206@univ-nantes.fr>
On 04/07/2011 09:33 AM, Jean-Philippe Menil wrote:
> Le 07/04/2011 09:18, Onkar Mahajan a écrit :
>> Hi ,
>> How do I test if vhost-net is actually enabled and working ? Hi,
>> ...
>
> you must modprobe the vhost_net module on your host:
> ...
> and you need to pass "vhost-on" on your command line:
> http://www.linux-kvm.org/page/VhostNet
> ...
> Regards.
>
Are you really able to make vhost_net work?
I compiled from source KVM 0.13.0 and recently also 0.14.0 on intel xeon
54xx and 56xx, on newly installed Ubuntu with vanilla kernel 2.6.37, and
when I tried to enable vhost_net (modprobe the module then restart KVM)
the emulation was going 100x slower than normal, so I had to disable it.
See my old message in this ML "vhost disables kvm acceleration"
What did you do to make it work? Did you compile KVM from sources? On
what kernel? AMD or Intel?
Also, are you not using libvirt maybe?
Thank you
^ permalink raw reply
* Re: map domU pages in dom0
From: david @ 2011-04-09 14:20 UTC (permalink / raw)
To: xen-devel
In-Reply-To: <4D9EA390.5080907@gmx.at>
On 04/08/2011 07:56 AM, david wrote:
> On 04/03/2011 09:55 PM, Keir Fraser wrote:
>> On 03/04/2011 20:42, "david"<david_n@gmx.at> wrote:
>>
>>> Hi there,
>>>
>>> it is possible to map memory pages from domU domains in dom0 writeable
>>> in an easy way?
>>
>> Link with libxenctrl, #include<xenctrl.h> and use one of
>> xc_map_foreign_{range,pages,bulk}(). You can find examples of their use
>> throughout the tools/ directory in xen-unstable.hg repository.
>
> Thanks for the hint, that's exactly what I'm looking for.
so, now I can map pages read/writeable ascending except the pages with
page no. 160 to 191 (from about 131000 mapped pages). Do you have any
idea why? Do you know where I can find a good documentation about memory
mgmt in xen?
greets
david
>
>>
>> -- Keir
>>
>>> greets,
>>> david
>>>
>>> _______________________________________________
>>> Xen-devel mailing list
>>> Xen-devel@lists.xensource.com
>>> http://lists.xensource.com/xen-devel
>>
>>
>>
>
^ permalink raw reply
* [PATCH] [v2] Nios2: Add Altera TSE MAC driver
From: franck.jullien @ 2011-04-09 14:08 UTC (permalink / raw)
To: barebox
In-Reply-To: <1302358087-9756-1-git-send-email-franck.jullien@gmail.com>
From: Franck JULLIEN <franck.jullien@gmail.com>
Add Altera Triple Speed Ethernet driver
Signed-off-by: Franck JULLIEN <franck.jullien@gmail.com>
---
drivers/net/Kconfig | 16 ++
drivers/net/Makefile | 5 +-
drivers/net/altera_tse.c | 620 ++++++++++++++++++++++++++++++++++++++++++++++
drivers/net/altera_tse.h | 313 +++++++++++++++++++++++
4 files changed, 952 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/altera_tse.c
create mode 100644 drivers/net/altera_tse.h
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 6479417..19e35db 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -84,6 +84,22 @@ config DRIVER_NET_TAP
bool "tap Ethernet driver"
depends on LINUX
+config DRIVER_NET_TSE
+ depends on NIOS2
+ bool "Altera TSE ethernet driver"
+ select MIIDEV
+ help
+ This option enables support for the Altera TSE MAC.
+
+config TSE_USE_DEDICATED_DESC_MEM
+ depends on DRIVER_NET_TSE
+ bool "Altera TSE uses dedicated descriptor memory"
+ help
+ This option tells the TSE driver to use an onchip memory
+ to store SGDMA descriptors. Descriptor memory is not
+ reserved with a malloc but directly mapped to the memory
+ address (defined in config.h)
+
source "drivers/net/usb/Kconfig"
endmenu
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 96d3d32..f02618b 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -1,7 +1,7 @@
-obj-$(CONFIG_DRIVER_NET_CS8900) += cs8900.o
+obj-$(CONFIG_DRIVER_NET_CS8900) += cs8900.o
obj-$(CONFIG_DRIVER_NET_SMC911X) += smc911x.o
obj-$(CONFIG_DRIVER_NET_SMC91111) += smc91111.o
-obj-$(CONFIG_DRIVER_NET_DM9000) += dm9000.o
+obj-$(CONFIG_DRIVER_NET_DM9000) += dm9000.o
obj-$(CONFIG_DRIVER_NET_NETX) += netx_eth.o
obj-$(CONFIG_DRIVER_NET_AT91_ETHER) += at91_ether.o
obj-$(CONFIG_DRIVER_NET_MPC5200) += fec_mpc5200.o
@@ -11,3 +11,4 @@ obj-$(CONFIG_DRIVER_NET_MACB) += macb.o
obj-$(CONFIG_DRIVER_NET_TAP) += tap.o
obj-$(CONFIG_MIIDEV) += miidev.o
obj-$(CONFIG_NET_USB) += usb/
+obj-$(CONFIG_DRIVER_NET_TSE) += altera_tse.o
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
new file mode 100644
index 0000000..2687377
--- /dev/null
+++ b/drivers/net/altera_tse.c
@@ -0,0 +1,620 @@
+/*
+ * Altera TSE Network driver
+ *
+ * Copyright (C) 2008 Altera Corporation.
+ * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
+ * Copyright (C) 2011 Franck JULLIEN, <elec4fun@gmail.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <net.h>
+#include <miidev.h>
+#include <init.h>
+#include <clock.h>
+#include <linux/mii.h>
+
+#include <asm/io.h>
+#include <asm/dma-mapping.h>
+
+#include "altera_tse.h"
+
+/* This is a generic routine that the SGDMA mode-specific routines
+ * call to populate a descriptor.
+ * arg1 :pointer to first SGDMA descriptor.
+ * arg2 :pointer to next SGDMA descriptor.
+ * arg3 :Address to where data to be written.
+ * arg4 :Address from where data to be read.
+ * arg5 :no of byte to transaction.
+ * arg6 :variable indicating to generate start of packet or not
+ * arg7 :read fixed
+ * arg8 :write fixed
+ * arg9 :read burst
+ * arg10 :write burst
+ * arg11 :atlantic_channel number
+ */
+static void alt_sgdma_construct_descriptor_burst(
+ struct alt_sgdma_descriptor *desc,
+ struct alt_sgdma_descriptor *next,
+ uint32_t *read_addr,
+ uint32_t *write_addr,
+ uint16_t length_or_eop,
+ uint8_t generate_eop,
+ uint8_t read_fixed,
+ uint8_t write_fixed_or_sop,
+ uint8_t read_burst,
+ uint8_t write_burst,
+ uint8_t atlantic_channel)
+{
+ uint32_t temp;
+
+ /*
+ * Mark the "next" descriptor as "not" owned by hardware. This prevents
+ * The SGDMA controller from continuing to process the chain. This is
+ * done as a single IO write to bypass cache, without flushing
+ * the entire descriptor, since only the 8-bit descriptor status must
+ * be flushed.
+ */
+ if (!next)
+ printf("Next descriptor not defined!!\n");
+
+ temp = readb(&next->descriptor_control);
+ writeb(temp & ~ALT_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK,
+ &next->descriptor_control);
+
+ writel((uint32_t)read_addr, &desc->source);
+ writel((uint32_t)write_addr, &desc->destination);
+ writel((uint32_t)next, &desc->next);
+
+ writel(0, &desc->source_pad);
+ writel(0, &desc->destination_pad);
+ writel(0, &desc->next_pad);
+ writew(length_or_eop, &desc->bytes_to_transfer);
+ writew(0, &desc->actual_bytes_transferred);
+ writeb(0, &desc->descriptor_status);
+
+ /* SGDMA burst not currently supported */
+ writeb(0, &desc->read_burst);
+ writeb(0, &desc->write_burst);
+
+ /*
+ * Set the descriptor control block as follows:
+ * - Set "owned by hardware" bit
+ * - Optionally set "generate EOP" bit
+ * - Optionally set the "read from fixed address" bit
+ * - Optionally set the "write to fixed address bit (which serves
+ * serves as a "generate SOP" control bit in memory-to-stream mode).
+ * - Set the 4-bit atlantic channel, if specified
+ *
+ * Note this step is performed after all other descriptor information
+ * has been filled out so that, if the controller already happens to be
+ * pointing at this descriptor, it will not run (via the "owned by
+ * hardware" bit) until all other descriptor has been set up.
+ */
+
+ writeb((ALT_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK) |
+ (generate_eop ? ALT_SGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_MSK : 0) |
+ (read_fixed ? ALT_SGDMA_DESCRIPTOR_CONTROL_READ_FIXED_ADDRESS_MSK : 0) |
+ (write_fixed_or_sop ? ALT_SGDMA_DESCRIPTOR_CONTROL_WRITE_FIXED_ADDRESS_MSK : 0) |
+ (atlantic_channel ? ((atlantic_channel & 0x0F) << 3) : 0),
+ &desc->descriptor_control);
+}
+
+static int alt_sgdma_do_sync_transfer(struct alt_sgdma_registers *dev,
+ struct alt_sgdma_descriptor *desc)
+{
+ uint32_t temp;
+ uint64_t start;
+ uint64_t tout;
+
+ /* Wait for any pending transfers to complete */
+ tout = ALT_TSE_SGDMA_BUSY_WATCHDOG_TOUT * MSECOND;
+
+ start = get_time_ns();
+
+ while (readl(&dev->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
+ if (is_timeout(start, tout)) {
+ debug("Timeout waiting sgdma in do sync!\n");
+ break;
+ }
+ }
+
+ /*
+ * Clear any (previous) status register information
+ * that might occlude our error checking later.
+ */
+ writel(0xFF, &dev->status);
+
+ /* Point the controller at the descriptor */
+ writel((uint32_t)desc, &dev->next_descriptor_pointer);
+ debug("next desc in sgdma 0x%x\n", (uint32_t)dev->next_descriptor_pointer);
+
+ /*
+ * Set up SGDMA controller to:
+ * - Disable interrupt generation
+ * - Run once a valid descriptor is written to controller
+ * - Stop on an error with any particular descriptor
+ */
+ writel(ALT_SGDMA_CONTROL_RUN_MSK | ALT_SGDMA_CONTROL_STOP_DMA_ER_MSK,
+ &dev->control);
+
+ /* Wait for the descriptor (chain) to complete */
+ debug("wait for sgdma....");
+ start = get_time_ns();
+
+ while (readl(&dev->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
+ if (is_timeout(start, tout)) {
+ debug("Timeout waiting sgdma in do sync!\n");
+ break;
+ }
+ }
+
+ debug("done\n");
+
+ /* Clear Run */
+ temp = readl(&dev->control);
+ writel(temp & ~ALT_SGDMA_CONTROL_RUN_MSK, &dev->control);
+
+ /* Get & clear status register contents */
+ debug("tx sgdma status = 0x%x", readl(&dev->status));
+ writel(0xFF, &dev->status);
+
+ return 0;
+}
+
+static int alt_sgdma_do_async_transfer(struct alt_sgdma_registers *dev,
+ struct alt_sgdma_descriptor *desc)
+{
+ uint64_t start;
+ uint64_t tout;
+
+ /* Wait for any pending transfers to complete */
+ tout = ALT_TSE_SGDMA_BUSY_WATCHDOG_TOUT * MSECOND;
+
+ start = get_time_ns();
+
+ while (readl(&dev->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
+ if (is_timeout(start, tout)) {
+ debug("Timeout waiting sgdma in do async!\n");
+ break;
+ }
+ }
+
+ /*
+ * Clear any (previous) status register information
+ * that might occlude our error checking later.
+ */
+ writel(0xFF, &dev->status);
+
+ /* Point the controller at the descriptor */
+ writel((uint32_t)desc, &dev->next_descriptor_pointer);
+
+ /*
+ * Set up SGDMA controller to:
+ * - Disable interrupt generation
+ * - Run once a valid descriptor is written to controller
+ * - Stop on an error with any particular descriptor
+ */
+ writel(ALT_SGDMA_CONTROL_RUN_MSK | ALT_SGDMA_CONTROL_STOP_DMA_ER_MSK,
+ &dev->control);
+
+ return 0;
+}
+
+static int tse_get_ethaddr(struct eth_device *edev, unsigned char *m)
+{
+ /* There is no eeprom */
+ return -1;
+}
+
+static int tse_set_ethaddr(struct eth_device *edev, unsigned char *m)
+{
+ struct altera_tse_priv *priv = edev->priv;
+ struct alt_tse_mac *mac_dev = priv->mac_dev;
+
+ debug("Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n",
+ m[0], m[1], m[2], m[3], m[4], m[5]);
+
+ writel(m[3] << 24 | m[2] << 16 | m[1] << 8 | m[0], &mac_dev->mac_addr_0);
+ writel((m[5] << 8 | m[4]) & 0xFFFF, &mac_dev->mac_addr_1);
+
+ return 0;
+}
+
+static int tse_phy_read(struct mii_device *mdev, int phy_addr, int reg)
+{
+ struct eth_device *edev = mdev->edev;
+ struct alt_tse_mac *mac_dev;
+ uint32_t *mdio_regs;
+
+ mac_dev = (struct alt_tse_mac *)edev->iobase;
+ writel(phy_addr, &mac_dev->mdio_phy1_addr);
+
+ mdio_regs = (uint32_t *)&mac_dev->mdio_phy1;
+
+ return readl(&mdio_regs[reg]) & 0xFFFF;
+}
+
+static int tse_phy_write(struct mii_device *mdev, int phy_addr, int reg, int val)
+{
+ struct eth_device *edev = mdev->edev;
+ struct alt_tse_mac *mac_dev;
+ uint32_t *mdio_regs;
+
+ mac_dev = (struct alt_tse_mac *)edev->iobase;
+ writel(phy_addr, &mac_dev->mdio_phy1_addr);
+
+ mdio_regs = (uint32_t *)&mac_dev->mdio_phy1;
+
+ writel((uint32_t)val, &mdio_regs[reg]);
+
+ return 0;
+}
+
+static void tse_reset(struct eth_device *edev)
+{
+ /* stop sgdmas, disable tse receive */
+ struct altera_tse_priv *priv = edev->priv;
+ struct alt_tse_mac *mac_dev = priv->mac_dev;
+ struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx;
+ struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx;
+ struct alt_sgdma_descriptor *rx_desc = (struct alt_sgdma_descriptor *)&priv->rx_desc[0];
+ struct alt_sgdma_descriptor *tx_desc = (struct alt_sgdma_descriptor *)&priv->tx_desc[0];
+ uint64_t start;
+ uint64_t tout;
+
+ tout = ALT_TSE_SGDMA_BUSY_WATCHDOG_TOUT * MSECOND;
+
+ /* clear rx desc & wait for sgdma to complete */
+ writeb(0, &rx_desc->descriptor_control);
+ writel(0, &rx_sgdma->control);
+
+ writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &rx_sgdma->control);
+ writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &rx_sgdma->control);
+ mdelay(100);
+
+ start = get_time_ns();
+
+ while (readl(&rx_sgdma->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
+ if (is_timeout(start, tout)) {
+ printf("Timeout waiting for rx sgdma!\n");
+ writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &rx_sgdma->control);
+ writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &rx_sgdma->control);
+ break;
+ }
+ }
+
+ /* clear tx desc & wait for sgdma to complete */
+ writeb(0, &tx_desc->descriptor_control);
+ writel(0, &tx_sgdma->control);
+
+ writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control);
+ writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control);
+ mdelay(100);
+
+ start = get_time_ns();
+
+ while (readl(&tx_sgdma->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
+ if (is_timeout(start, tout)) {
+ printf("Timeout waiting for tx sgdma!\n");
+ writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control);
+ writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control);
+ break;
+ }
+ }
+
+ /* reset the mac */
+ writel(ALTERA_TSE_CMD_TX_ENA_MSK | ALTERA_TSE_CMD_RX_ENA_MSK |
+ ALTERA_TSE_CMD_SW_RESET_MSK, &mac_dev->command_config);
+
+ start = get_time_ns();
+ tout = ALT_TSE_SW_RESET_WATCHDOG_TOUT * MSECOND;
+
+ while (readl(&mac_dev->command_config) & ALTERA_TSE_CMD_SW_RESET_MSK) {
+ if (is_timeout(start, tout)) {
+ printf("TSEMAC SW reset bit never cleared!\n");
+ break;
+ }
+ }
+}
+
+static int tse_eth_open(struct eth_device *edev)
+{
+ struct altera_tse_priv *priv = edev->priv;
+
+ miidev_wait_aneg(priv->miidev);
+ miidev_print_status(priv->miidev);
+
+ return 0;
+}
+
+static int tse_eth_send(struct eth_device *edev, void *packet, int length)
+{
+
+ struct altera_tse_priv *priv = edev->priv;
+ struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx;
+ struct alt_sgdma_descriptor *tx_desc = (struct alt_sgdma_descriptor *)priv->tx_desc;
+
+ struct alt_sgdma_descriptor *tx_desc_cur = (struct alt_sgdma_descriptor *)&tx_desc[0];
+
+ flush_dcache_range((uint32_t)packet, (uint32_t)packet + length);
+ alt_sgdma_construct_descriptor_burst(
+ (struct alt_sgdma_descriptor *)&tx_desc[0],
+ (struct alt_sgdma_descriptor *)&tx_desc[1],
+ (uint32_t *)packet, /* read addr */
+ (uint32_t *)0, /* */
+ length, /* length or EOP ,will change for each tx */
+ 0x1, /* gen eop */
+ 0x0, /* read fixed */
+ 0x1, /* write fixed or sop */
+ 0x0, /* read burst */
+ 0x0, /* write burst */
+ 0x0 /* channel */
+ );
+
+ alt_sgdma_do_sync_transfer(tx_sgdma, tx_desc_cur);
+
+ return 0;;
+}
+
+static void tse_eth_halt(struct eth_device *edev)
+{
+ struct altera_tse_priv *priv = edev->priv;
+ struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx;
+ struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx;
+
+ writel(0, &rx_sgdma->control); /* Stop the controller and reset settings */
+ writel(0, &tx_sgdma->control); /* Stop the controller and reset settings */
+}
+
+static int tse_eth_rx(struct eth_device *edev)
+{
+ uint16_t packet_length = 0;
+
+ struct altera_tse_priv *priv = edev->priv;
+ struct alt_sgdma_descriptor *rx_desc = (struct alt_sgdma_descriptor *)priv->rx_desc;
+ struct alt_sgdma_descriptor *rx_desc_cur = &rx_desc[0];
+ struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx;
+
+ if (rx_desc_cur->descriptor_status &
+ ALT_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK) {
+
+ packet_length = rx_desc->actual_bytes_transferred;
+ net_receive(NetRxPackets[0], packet_length);
+
+ /* Clear Run */
+ rx_sgdma->control = (rx_sgdma->control & (~ALT_SGDMA_CONTROL_RUN_MSK));
+
+ /* start descriptor again */
+ flush_dcache_range((uint32_t)(NetRxPackets[0]), (uint32_t)(NetRxPackets[0]) + PKTSIZE);
+ alt_sgdma_construct_descriptor_burst(
+ (struct alt_sgdma_descriptor *)&rx_desc[0],
+ (struct alt_sgdma_descriptor *)&rx_desc[1],
+ (uint32_t)0x0, /* read addr */
+ (uint32_t *)NetRxPackets[0], /* */
+ 0x0, /* length or EOP */
+ 0x0, /* gen eop */
+ 0x0, /* read fixed */
+ 0x0, /* write fixed or sop */
+ 0x0, /* read burst */
+ 0x0, /* write burst */
+ 0x0 /* channel */
+ );
+
+ /* setup the sgdma */
+ alt_sgdma_do_async_transfer(priv->sgdma_rx, &rx_desc[0]);
+ }
+
+ return 0;
+}
+
+static char *get_phy_name(uint32_t phy_ID)
+{
+ uint8_t i = 0;
+
+ while (phy_name_table[i].phy_ID != 0) {
+ if (phy_name_table[i].phy_ID == phy_ID)
+ return phy_name_table[i].name;
+ i++;
+ }
+
+ return "unknown";
+}
+
+static int check_phy_address(struct eth_device *edev)
+{
+ struct altera_tse_priv *priv = edev->priv;
+ uint8_t mii_bus_scan = 0;
+ uint8_t current_mii_address = 1;
+ uint32_t phy_reg;
+ uint32_t phy_ID;
+
+ if ((priv->miidev)->address < 0)
+ mii_bus_scan = 1;
+ else
+ current_mii_address = (priv->miidev)->address;
+
+ do {
+ /* Grab the bits from PHYIR1, and put them in the upper half */
+ phy_reg = tse_phy_read(priv->miidev, current_mii_address, MII_PHYSID1);
+ phy_ID = (phy_reg & 0xffff) << 16;
+
+ /* Grab the bits from PHYIR2, and put them in the lower half */
+ phy_reg = tse_phy_read(priv->miidev, current_mii_address, MII_PHYSID2);
+ phy_ID |= (phy_reg & 0xffff);
+
+ if (phy_ID != 0xffffffff) {
+ printf("PHY (%s) found at address %d\n", get_phy_name(phy_ID), current_mii_address);
+ (priv->miidev)->address = current_mii_address;
+ return 0;
+ }
+
+ current_mii_address++;
+
+ } while (current_mii_address < 32 && mii_bus_scan);
+
+ return -1;
+}
+
+
+static int tse_init_dev(struct eth_device *edev)
+{
+ struct altera_tse_priv *priv = edev->priv;
+ struct alt_tse_mac *mac_dev = priv->mac_dev;
+ struct alt_sgdma_descriptor *tx_desc = priv->tx_desc;
+ struct alt_sgdma_descriptor *rx_desc = priv->rx_desc;
+ struct alt_sgdma_descriptor *rx_desc_cur;
+
+ rx_desc_cur = (struct alt_sgdma_descriptor *)&rx_desc[0];
+
+ tse_reset(edev);
+
+ /* need to create sgdma */
+ alt_sgdma_construct_descriptor_burst(
+ (struct alt_sgdma_descriptor *)&tx_desc[0],
+ (struct alt_sgdma_descriptor *)&tx_desc[1],
+ (uint32_t *)NULL, /* read addr */
+ (uint32_t *)0, /* */
+ 0, /* length or EOP ,will change for each tx */
+ 0x1, /* gen eop */
+ 0x0, /* read fixed */
+ 0x1, /* write fixed or sop */
+ 0x0, /* read burst */
+ 0x0, /* write burst */
+ 0x0 /* channel */
+ );
+
+ flush_dcache_range((uint32_t)(NetRxPackets[0]), (uint32_t)(NetRxPackets[0]) + PKTSIZE);
+ alt_sgdma_construct_descriptor_burst(
+ (struct alt_sgdma_descriptor *)&rx_desc[0],
+ (struct alt_sgdma_descriptor *)&rx_desc[1],
+ (uint32_t)0x0, /* read addr */
+ (uint32_t *)NetRxPackets[0], /* */
+ 0x0, /* length or EOP */
+ 0x0, /* gen eop */
+ 0x0, /* read fixed */
+ 0x0, /* write fixed or sop */
+ 0x0, /* read burst */
+ 0x0, /* write burst */
+ 0x0 /* channel */
+ );
+
+ /* start rx async transfer */
+ alt_sgdma_do_async_transfer(priv->sgdma_rx, rx_desc_cur);
+
+ /* Initialize MAC registers */
+ writel(PKTSIZE, &mac_dev->max_frame_length);
+
+ /* NO Shift */
+ writel(0, &mac_dev->rx_cmd_stat);
+ writel(0, &mac_dev->tx_cmd_stat);
+
+ /* enable MAC */
+ writel(ALTERA_TSE_CMD_TX_ENA_MSK | ALTERA_TSE_CMD_RX_ENA_MSK, &mac_dev->command_config);
+
+ miidev_restart_aneg(priv->miidev);
+
+ return 0;
+}
+
+static int tse_probe(struct device_d *dev)
+{
+ struct altera_tse_priv *priv;
+ struct mii_device *miidev;
+ struct eth_device *edev;
+ struct alt_sgdma_descriptor *rx_desc;
+ struct alt_sgdma_descriptor *tx_desc;
+#ifndef CONFIG_TSE_USE_DEDICATED_DESC_MEM
+ uint32_t dma_handle;
+#endif
+ edev = xzalloc(sizeof(struct eth_device) + sizeof(struct altera_tse_priv));
+ miidev = xzalloc(sizeof(struct mii_device));
+
+ dev->type_data = edev;
+ edev->priv = (struct altera_tse_priv *)(edev + 1);
+
+ edev->iobase = dev->map_base;
+
+ priv = edev->priv;
+
+ edev->init = tse_init_dev;
+ edev->open = tse_eth_open;
+ edev->send = tse_eth_send;
+ edev->recv = tse_eth_rx;
+ edev->halt = tse_eth_halt;
+ edev->get_ethaddr = tse_get_ethaddr;
+ edev->set_ethaddr = tse_set_ethaddr;
+
+#ifdef CONFIG_TSE_USE_DEDICATED_DESC_MEM
+ tx_desc = (struct alt_sgdma_descriptor *)NIOS_SOPC_TSE_DESC_MEM_BASE;
+ rx_desc = tx_desc + 2;
+#else
+ tx_desc = dma_alloc_coherent(sizeof(*tx_desc) * (3 + PKTBUFSRX), &dma_handle);
+ rx_desc = tx_desc + 2;
+
+ if (!tx_desc) {
+ free(edev);
+ free(miidev);
+ return 0;
+ }
+#endif
+
+ memset(rx_desc, 0, (sizeof *rx_desc) * (PKTBUFSRX + 1));
+ memset(tx_desc, 0, (sizeof *tx_desc) * 2);
+
+ priv->mac_dev = (struct alt_tse_mac *)dev->map_base;
+ priv->sgdma_rx = (struct alt_sgdma_registers *)NIOS_SOPC_SGDMA_RX_BASE;
+ priv->sgdma_tx = (struct alt_sgdma_registers *)NIOS_SOPC_SGDMA_TX_BASE;
+ priv->rx_desc = rx_desc;
+ priv->tx_desc = tx_desc;
+
+ priv->miidev = miidev;
+
+ miidev->read = tse_phy_read;
+ miidev->write = tse_phy_write;
+ miidev->flags = 0;
+ miidev->edev = edev;
+
+ if (dev->platform_data != NULL)
+ miidev->address = *((int8_t *)(dev->platform_data));
+ else
+ miidev->address = -1;
+
+ if (!check_phy_address(edev))
+ mii_register(miidev);
+ else
+ printf("Couldn't find any PHY...\n");
+
+ return eth_register(edev);
+}
+
+static struct driver_d altera_tse_driver = {
+ .name = "altera_tse",
+ .probe = tse_probe,
+};
+
+static int tse_init(void)
+{
+ register_driver(&altera_tse_driver);
+ return 0;
+}
+
+device_initcall(tse_init);
+
diff --git a/drivers/net/altera_tse.h b/drivers/net/altera_tse.h
new file mode 100644
index 0000000..49af916
--- /dev/null
+++ b/drivers/net/altera_tse.h
@@ -0,0 +1,313 @@
+/*
+ * Altera 10/100/1000 triple speed ethernet mac
+ *
+ * Copyright (C) 2008 Altera Corporation.
+ * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
+ * Copyright (C) 2011 Franck JULLIEN <elec4fun@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef _ALTERA_TSE_H_
+#define _ALTERA_TSE_H_
+
+struct phy_id_name {
+ uint32_t phy_ID;
+ char *name;
+};
+
+static struct phy_id_name phy_name_table[] = {
+ { 0x20005C90, "DP83848C" },
+ { 0, 0}
+};
+
+/* SGDMA Stuff */
+#define ALT_SGDMA_STATUS_ERROR_MSK (0x00000001)
+#define ALT_SGDMA_STATUS_EOP_ENCOUNTERED_MSK (0x00000002)
+#define ALT_SGDMA_STATUS_DESC_COMPLETED_MSK (0x00000004)
+#define ALT_SGDMA_STATUS_CHAIN_COMPLETED_MSK (0x00000008)
+#define ALT_SGDMA_STATUS_BUSY_MSK (0x00000010)
+
+#define ALT_SGDMA_CONTROL_IE_ERROR_MSK (0x00000001)
+#define ALT_SGDMA_CONTROL_IE_EOP_ENCOUNTERED_MSK (0x00000002)
+#define ALT_SGDMA_CONTROL_IE_DESC_COMPLETED_MSK (0x00000004)
+#define ALT_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK (0x00000008)
+#define ALT_SGDMA_CONTROL_IE_GLOBAL_MSK (0x00000010)
+#define ALT_SGDMA_CONTROL_RUN_MSK (0x00000020)
+#define ALT_SGDMA_CONTROL_STOP_DMA_ER_MSK (0x00000040)
+#define ALT_SGDMA_CONTROL_IE_MAX_DESC_PROCESSED_MSK (0x00000080)
+#define ALT_SGDMA_CONTROL_MAX_DESC_PROCESSED_MSK (0x0000FF00)
+#define ALT_SGDMA_CONTROL_SOFTWARERESET_MSK (0x00010000)
+#define ALT_SGDMA_CONTROL_PARK_MSK (0x00020000)
+#define ALT_SGDMA_CONTROL_CLEAR_INTERRUPT_MSK (0x80000000)
+
+#define ALTERA_TSE_SGDMA_INTR_MASK (ALT_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK \
+ | ALT_SGDMA_STATUS_DESC_COMPLETED_MSK \
+ | ALT_SGDMA_CONTROL_IE_GLOBAL_MSK)
+
+/*
+ * Descriptor control bit masks & offsets
+ *
+ * Note: The control byte physically occupies bits [31:24] in memory.
+ * The following bit-offsets are expressed relative to the LSB of
+ * the control register bitfield.
+ */
+#define ALT_SGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_MSK (0x00000001)
+#define ALT_SGDMA_DESCRIPTOR_CONTROL_READ_FIXED_ADDRESS_MSK (0x00000002)
+#define ALT_SGDMA_DESCRIPTOR_CONTROL_WRITE_FIXED_ADDRESS_MSK (0x00000004)
+#define ALT_SGDMA_DESCRIPTOR_CONTROL_ATLANTIC_CHANNEL_MSK (0x00000008)
+#define ALT_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK (0x00000080)
+
+/*
+ * Descriptor status bit masks & offsets
+ *
+ * Note: The status byte physically occupies bits [23:16] in memory.
+ * The following bit-offsets are expressed relative to the LSB of
+ * the status register bitfield.
+ */
+#define ALT_SGDMA_DESCRIPTOR_STATUS_E_CRC_MSK (0x00000001)
+#define ALT_SGDMA_DESCRIPTOR_STATUS_E_PARITY_MSK (0x00000002)
+#define ALT_SGDMA_DESCRIPTOR_STATUS_E_OVERFLOW_MSK (0x00000004)
+#define ALT_SGDMA_DESCRIPTOR_STATUS_E_SYNC_MSK (0x00000008)
+#define ALT_SGDMA_DESCRIPTOR_STATUS_E_UEOP_MSK (0x00000010)
+#define ALT_SGDMA_DESCRIPTOR_STATUS_E_MEOP_MSK (0x00000020)
+#define ALT_SGDMA_DESCRIPTOR_STATUS_E_MSOP_MSK (0x00000040)
+#define ALT_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK (0x00000080)
+#define ALT_SGDMA_DESCRIPTOR_STATUS_ERROR_MSK (0x0000007F)
+
+/*
+ * The SGDMA controller buffer descriptor allocates
+ * 64 bits for each address. To support ANSI C, the
+ * struct implementing a descriptor places 32-bits
+ * of padding directly above each address; each pad must
+ * be cleared when initializing a descriptor.
+ */
+
+/*
+ * Buffer Descriptor data structure
+ *
+ */
+struct alt_sgdma_descriptor {
+ unsigned int *source; /* the address of data to be read. */
+ unsigned int source_pad;
+
+ unsigned int *destination; /* the address to write data */
+ unsigned int destination_pad;
+
+ unsigned int *next; /* the next descriptor in the list. */
+ unsigned int next_pad;
+
+ unsigned short bytes_to_transfer; /* the number of bytes to transfer */
+ unsigned char read_burst;
+ unsigned char write_burst;
+
+ unsigned short actual_bytes_transferred;/* bytes transferred by DMA */
+ unsigned char descriptor_status;
+ unsigned char descriptor_control;
+
+} __attribute__ ((packed, aligned(1)));
+
+/* SG-DMA Control/Status Slave registers map */
+
+struct alt_sgdma_registers {
+ unsigned int status;
+ unsigned int status_pad[3];
+ unsigned int control;
+ unsigned int control_pad[3];
+ unsigned int next_descriptor_pointer;
+ unsigned int descriptor_pad[3];
+};
+
+/* TSE Stuff */
+#define ALTERA_TSE_CMD_TX_ENA_MSK (0x00000001)
+#define ALTERA_TSE_CMD_RX_ENA_MSK (0x00000002)
+#define ALTERA_TSE_CMD_XON_GEN_MSK (0x00000004)
+#define ALTERA_TSE_CMD_ETH_SPEED_MSK (0x00000008)
+#define ALTERA_TSE_CMD_PROMIS_EN_MSK (0x00000010)
+#define ALTERA_TSE_CMD_PAD_EN_MSK (0x00000020)
+#define ALTERA_TSE_CMD_CRC_FWD_MSK (0x00000040)
+#define ALTERA_TSE_CMD_PAUSE_FWD_MSK (0x00000080)
+#define ALTERA_TSE_CMD_PAUSE_IGNORE_MSK (0x00000100)
+#define ALTERA_TSE_CMD_TX_ADDR_INS_MSK (0x00000200)
+#define ALTERA_TSE_CMD_HD_ENA_MSK (0x00000400)
+#define ALTERA_TSE_CMD_EXCESS_COL_MSK (0x00000800)
+#define ALTERA_TSE_CMD_LATE_COL_MSK (0x00001000)
+#define ALTERA_TSE_CMD_SW_RESET_MSK (0x00002000)
+#define ALTERA_TSE_CMD_MHASH_SEL_MSK (0x00004000)
+#define ALTERA_TSE_CMD_LOOPBACK_MSK (0x00008000)
+/* Bits (18:16) = address select */
+#define ALTERA_TSE_CMD_TX_ADDR_SEL_MSK (0x00070000)
+#define ALTERA_TSE_CMD_MAGIC_ENA_MSK (0x00080000)
+#define ALTERA_TSE_CMD_SLEEP_MSK (0x00100000)
+#define ALTERA_TSE_CMD_WAKEUP_MSK (0x00200000)
+#define ALTERA_TSE_CMD_XOFF_GEN_MSK (0x00400000)
+#define ALTERA_TSE_CMD_CNTL_FRM_ENA_MSK (0x00800000)
+#define ALTERA_TSE_CMD_NO_LENGTH_CHECK_MSK (0x01000000)
+#define ALTERA_TSE_CMD_ENA_10_MSK (0x02000000)
+#define ALTERA_TSE_CMD_RX_ERR_DISC_MSK (0x04000000)
+/* Bits (30..27) reserved */
+#define ALTERA_TSE_CMD_CNT_RESET_MSK (0x80000000)
+
+#define ALTERA_TSE_TX_CMD_STAT_TX_SHIFT16 (0x00040000)
+#define ALTERA_TSE_TX_CMD_STAT_OMIT_CRC (0x00020000)
+
+#define ALTERA_TSE_RX_CMD_STAT_RX_SHIFT16 (0x02000000)
+
+#define ALT_TSE_SW_RESET_WATCHDOG_CNTR 10000
+#define ALT_TSE_SGDMA_BUSY_WATCHDOG_CNTR 90000000
+
+#define ALT_TSE_SW_RESET_WATCHDOG_TOUT 1 /* ms */
+#define ALT_TSE_SGDMA_BUSY_WATCHDOG_TOUT 5 /* ms */
+
+struct alt_tse_mdio {
+ unsigned int control; /*PHY device operation control register */
+ unsigned int status; /*PHY device operation status register */
+ unsigned int phy_id1; /*Bits 31:16 of PHY identifier. */
+ unsigned int phy_id2; /*Bits 15:0 of PHY identifier. */
+ unsigned int auto_negotiation_advertisement;
+ unsigned int remote_partner_base_page_ability;
+
+ unsigned int reg6;
+ unsigned int reg7;
+ unsigned int reg8;
+ unsigned int reg9;
+ unsigned int rega;
+ unsigned int regb;
+ unsigned int regc;
+ unsigned int regd;
+ unsigned int rege;
+ unsigned int regf;
+ unsigned int reg10;
+ unsigned int reg11;
+ unsigned int reg12;
+ unsigned int reg13;
+ unsigned int reg14;
+ unsigned int reg15;
+ unsigned int reg16;
+ unsigned int reg17;
+ unsigned int reg18;
+ unsigned int reg19;
+ unsigned int reg1a;
+ unsigned int reg1b;
+ unsigned int reg1c;
+ unsigned int reg1d;
+ unsigned int reg1e;
+ unsigned int reg1f;
+};
+
+/* MAC register Space */
+
+struct alt_tse_mac {
+ unsigned int megacore_revision;
+ unsigned int scratch_pad;
+ unsigned int command_config;
+ unsigned int mac_addr_0;
+ unsigned int mac_addr_1;
+ unsigned int max_frame_length;
+ unsigned int pause_quanta;
+ unsigned int rx_sel_empty_threshold;
+ unsigned int rx_sel_full_threshold;
+ unsigned int tx_sel_empty_threshold;
+ unsigned int tx_sel_full_threshold;
+ unsigned int rx_almost_empty_threshold;
+ unsigned int rx_almost_full_threshold;
+ unsigned int tx_almost_empty_threshold;
+ unsigned int tx_almost_full_threshold;
+ unsigned int mdio_phy0_addr;
+ unsigned int mdio_phy1_addr;
+
+ /* only if 100/1000 BaseX PCS, reserved otherwise */
+ unsigned int reservedx44[5];
+
+ unsigned int reg_read_access_status;
+ unsigned int min_tx_ipg_length;
+
+ /* IEEE 802.3 oEntity Managed Object Support */
+ unsigned int aMACID_1; /*The MAC addresses */
+ unsigned int aMACID_2;
+ unsigned int aFramesTransmittedOK;
+ unsigned int aFramesReceivedOK;
+ unsigned int aFramesCheckSequenceErrors;
+ unsigned int aAlignmentErrors;
+ unsigned int aOctetsTransmittedOK;
+ unsigned int aOctetsReceivedOK;
+
+ /* IEEE 802.3 oPausedEntity Managed Object Support */
+ unsigned int aTxPAUSEMACCtrlFrames;
+ unsigned int aRxPAUSEMACCtrlFrames;
+
+ /* IETF MIB (MIB-II) Object Support */
+ unsigned int ifInErrors;
+ unsigned int ifOutErrors;
+ unsigned int ifInUcastPkts;
+ unsigned int ifInMulticastPkts;
+ unsigned int ifInBroadcastPkts;
+ unsigned int ifOutDiscards;
+ unsigned int ifOutUcastPkts;
+ unsigned int ifOutMulticastPkts;
+ unsigned int ifOutBroadcastPkts;
+
+ /* IETF RMON MIB Object Support */
+ unsigned int etherStatsDropEvent;
+ unsigned int etherStatsOctets;
+ unsigned int etherStatsPkts;
+ unsigned int etherStatsUndersizePkts;
+ unsigned int etherStatsOversizePkts;
+ unsigned int etherStatsPkts64Octets;
+ unsigned int etherStatsPkts65to127Octets;
+ unsigned int etherStatsPkts128to255Octets;
+ unsigned int etherStatsPkts256to511Octets;
+ unsigned int etherStatsPkts512to1023Octets;
+ unsigned int etherStatsPkts1024to1518Octets;
+
+ unsigned int etherStatsPkts1519toXOctets;
+ unsigned int etherStatsJabbers;
+ unsigned int etherStatsFragments;
+
+ unsigned int reservedxE4;
+
+ /*FIFO control register. */
+ unsigned int tx_cmd_stat;
+ unsigned int rx_cmd_stat;
+
+ unsigned int ipaccTxConf;
+ unsigned int ipaccRxConf;
+ unsigned int ipaccRxStat;
+ unsigned int ipaccRxStatSum;
+
+ /*Multicast address resolution table */
+ unsigned int hash_table[64];
+
+ /*Registers 0 to 31 within PHY device 0/1 */
+ struct alt_tse_mdio mdio_phy0;
+ struct alt_tse_mdio mdio_phy1;
+
+ /*4 Supplemental MAC Addresses */
+ unsigned int supp_mac_addr_0_0;
+ unsigned int supp_mac_addr_0_1;
+ unsigned int supp_mac_addr_1_0;
+ unsigned int supp_mac_addr_1_1;
+ unsigned int supp_mac_addr_2_0;
+ unsigned int supp_mac_addr_2_1;
+ unsigned int supp_mac_addr_3_0;
+ unsigned int supp_mac_addr_3_1;
+
+ unsigned int reservedx320[56];
+};
+
+struct altera_tse_priv {
+ struct alt_tse_mac *mac_dev;
+ struct alt_sgdma_registers *sgdma_rx;
+ struct alt_sgdma_registers *sgdma_tx;
+ unsigned int rx_sgdma_irq;
+ unsigned int tx_sgdma_irq;
+ unsigned int has_descriptor_mem;
+ unsigned int descriptor_mem_base;
+ unsigned int descriptor_mem_size;
+ struct alt_sgdma_descriptor *rx_desc;
+ struct alt_sgdma_descriptor *tx_desc;
+ struct mii_device *miidev;
+};
+
+#endif /* _ALTERA_TSE_H_ */
--
1.7.0.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH] [v2] Nios2: Add Altera TSE MAC driver
From: franck.jullien @ 2011-04-09 14:08 UTC (permalink / raw)
To: barebox
From: Franck JULLIEN <franck.jullien@gmail.com>
This version includes Sascha's remarks:
* tse_eth_halt stops and reset the DMA controllers
* the driver uses mii generic functions
* the phy address can be passed via platform_data
* tse_get_ethaddr has been cleared (there is no eeprom thing to set the MAC
address at startup).
I added a phy_id to phy name function. May be that we could put this (and
associated structure) in miidev.c / mii.h.
Franck JULLIEN (1):
[v2] Nios2: Add Altera TSE MAC driver
drivers/net/Kconfig | 16 ++
drivers/net/Makefile | 5 +-
drivers/net/altera_tse.c | 620 ++++++++++++++++++++++++++++++++++++++++++++++
drivers/net/altera_tse.h | 313 +++++++++++++++++++++++
4 files changed, 952 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/altera_tse.c
create mode 100644 drivers/net/altera_tse.h
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.