All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 09/55] vmdk: Fix use of uninitialised value
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>

In error cases, cid is never set.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vmdk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 6be592f..6cdbfb7 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -208,7 +208,7 @@ static void vmdk_free_last_extent(BlockDriverState *bs)
 static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
 {
     char desc[DESC_SIZE];
-    uint32_t cid;
+    uint32_t cid = 0;
     const char *p_name, *cid_str;
     size_t cid_str_size;
     BDRVVmdkState *s = bs->opaque;
-- 
1.7.6.4

^ permalink raw reply related

* [Qemu-devel] [PATCH 07/55] qcow: Fix bdrv_write_compressed error handling
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/qcow.c |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index ab36b29..35e21eb 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -736,8 +736,6 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
         return -EINVAL;
 
     out_buf = g_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
-    if (!out_buf)
-        return -1;
 
     /* best compression, small window, no zlib header */
     memset(&strm, 0, sizeof(strm));
@@ -745,8 +743,8 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
                        Z_DEFLATED, -12,
                        9, Z_DEFAULT_STRATEGY);
     if (ret != 0) {
-        g_free(out_buf);
-        return -1;
+        ret = -EINVAL;
+        goto fail;
     }
 
     strm.avail_in = s->cluster_size;
@@ -756,9 +754,9 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
 
     ret = deflate(&strm, Z_FINISH);
     if (ret != Z_STREAM_END && ret != Z_OK) {
-        g_free(out_buf);
         deflateEnd(&strm);
-        return -1;
+        ret = -EINVAL;
+        goto fail;
     }
     out_len = strm.next_out - out_buf;
 
@@ -766,19 +764,29 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
 
     if (ret != Z_STREAM_END || out_len >= s->cluster_size) {
         /* could not compress: write normal cluster */
-        bdrv_write(bs, sector_num, buf, s->cluster_sectors);
+        ret = bdrv_write(bs, sector_num, buf, s->cluster_sectors);
+        if (ret < 0) {
+            goto fail;
+        }
     } else {
         cluster_offset = get_cluster_offset(bs, sector_num << 9, 2,
                                             out_len, 0, 0);
+        if (cluster_offset == 0) {
+            ret = -EIO;
+            goto fail;
+        }
+
         cluster_offset &= s->cluster_offset_mask;
-        if (bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len) != out_len) {
-            g_free(out_buf);
-            return -1;
+        ret = bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len);
+        if (ret < 0) {
+            goto fail;
         }
     }
 
+    ret = 0;
+fail:
     g_free(out_buf);
-    return 0;
+    return ret;
 }
 
 static coroutine_fn int qcow_co_flush(BlockDriverState *bs)
-- 
1.7.6.4

^ permalink raw reply related

* [Qemu-devel] [PATCH 06/55] block: Fix bdrv_open use after free
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>

tmp_filename was used outside the block it was defined in, i.e. after it went
out of scope. Move its declaration to the top level.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block.c b/block.c
index f86984f..d5ec0be 100644
--- a/block.c
+++ b/block.c
@@ -571,6 +571,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
               BlockDriver *drv)
 {
     int ret;
+    char tmp_filename[PATH_MAX];
 
     if (flags & BDRV_O_SNAPSHOT) {
         BlockDriverState *bs1;
@@ -578,7 +579,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
         int is_protocol = 0;
         BlockDriver *bdrv_qcow2;
         QEMUOptionParameter *options;
-        char tmp_filename[PATH_MAX];
         char backing_filename[PATH_MAX];
 
         /* if snapshot, we create a temporary backing file and open it
-- 
1.7.6.4

^ permalink raw reply related

* [Qemu-devel] [PATCH 05/55] block: Remove dead code
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/block.c b/block.c
index 70aab63..f86984f 100644
--- a/block.c
+++ b/block.c
@@ -2028,11 +2028,7 @@ const char *bdrv_get_encrypted_filename(BlockDriverState *bs)
 void bdrv_get_backing_filename(BlockDriverState *bs,
                                char *filename, int filename_size)
 {
-    if (!bs->backing_file) {
-        pstrcpy(filename, filename_size, "");
-    } else {
-        pstrcpy(filename, filename_size, bs->backing_file);
-    }
+    pstrcpy(filename, filename_size, bs->backing_file);
 }
 
 int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
-- 
1.7.6.4

^ permalink raw reply related

* [Qemu-devel] [PATCH 04/55] qcow2: fix some errors and typo in qcow2.txt
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 docs/specs/qcow2.txt |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/specs/qcow2.txt b/docs/specs/qcow2.txt
index 8fc3cb2..e792953 100644
--- a/docs/specs/qcow2.txt
+++ b/docs/specs/qcow2.txt
@@ -108,8 +108,8 @@ as follows:
 
     refcount_block_entries = (cluster_size / sizeof(uint16_t))
 
-    refcount_block_index = (offset / cluster_size) % refcount_table_entries
-    refcount_table_index = (offset / cluster_size) / refcount_table_entries
+    refcount_block_index = (offset / cluster_size) % refcount_block_entries
+    refcount_table_index = (offset / cluster_size) / refcount_block_entries
 
     refcount_block = load_cluster(refcount_table[refcount_table_index]);
     return refcount_block[refcount_block_index];
@@ -211,7 +211,7 @@ switch the active L1 table, so that a different set of host clusters are
 exposed to the guest.
 
 When creating a snapshot, the L1 table should be copied and the refcount of all
-L2 tables and clusters reachable form this L1 table must be increased, so that
+L2 tables and clusters reachable from this L1 table must be increased, so that
 a write causes a COW and isn't visible in other snapshots.
 
 When loading a snapshot, bit 63 of all entries in the new active L1 table and
-- 
1.7.6.4

^ permalink raw reply related

* [Qemu-devel] [PATCH 03/55] Teach block/vdi about "discarded" (no longer allocated) blocks
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>

From: Eric Sunshine <sunshine@sunshineco.com>

An entry in the VDI block map will hold an offset to the actual block if
the block is allocated, or one of two specially-interpreted values if
not allocated. Using VirtualBox terminology, value VDI_IMAGE_BLOCK_FREE
(0xffffffff) represents a never-allocated block (semantically arbitrary
content).  VDI_IMAGE_BLOCK_ZERO (0xfffffffe) represents a "discarded"
block (semantically zero-filled).  block/vdi knows only about
VDI_IMAGE_BLOCK_FREE.  Teach it about VDI_IMAGE_BLOCK_ZERO.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vdi.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 883046d..523a640 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -114,8 +114,13 @@ void uuid_unparse(const uuid_t uu, char *out);
  */
 #define VDI_TEXT "<<< QEMU VM Virtual Disk Image >>>\n"
 
-/* Unallocated blocks use this index (no need to convert endianness). */
-#define VDI_UNALLOCATED UINT32_MAX
+/* A never-allocated block; semantically arbitrary content. */
+#define VDI_UNALLOCATED 0xffffffffU
+
+/* A discarded (no longer allocated) block; semantically zero-filled. */
+#define VDI_DISCARDED   0xfffffffeU
+
+#define VDI_IS_ALLOCATED(X) ((X) < VDI_DISCARDED)
 
 #if !defined(CONFIG_UUID)
 void uuid_generate(uuid_t out)
@@ -307,10 +312,10 @@ static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res)
     /* Check block map and value of blocks_allocated. */
     for (block = 0; block < s->header.blocks_in_image; block++) {
         uint32_t bmap_entry = le32_to_cpu(s->bmap[block]);
-        if (bmap_entry != VDI_UNALLOCATED) {
+        if (VDI_IS_ALLOCATED(bmap_entry)) {
             if (bmap_entry < s->header.blocks_in_image) {
                 blocks_allocated++;
-                if (bmap[bmap_entry] == VDI_UNALLOCATED) {
+                if (!VDI_IS_ALLOCATED(bmap[bmap_entry])) {
                     bmap[bmap_entry] = bmap_entry;
                 } else {
                     fprintf(stderr, "ERROR: block index %" PRIu32
@@ -472,7 +477,7 @@ static int vdi_is_allocated(BlockDriverState *bs, int64_t sector_num,
         n_sectors = nb_sectors;
     }
     *pnum = n_sectors;
-    return bmap_entry != VDI_UNALLOCATED;
+    return VDI_IS_ALLOCATED(bmap_entry);
 }
 
 static void vdi_aio_cancel(BlockDriverAIOCB *blockacb)
@@ -603,7 +608,7 @@ static void vdi_aio_read_cb(void *opaque, int ret)
     /* prepare next AIO request */
     acb->n_sectors = n_sectors;
     bmap_entry = le32_to_cpu(s->bmap[block_index]);
-    if (bmap_entry == VDI_UNALLOCATED) {
+    if (!VDI_IS_ALLOCATED(bmap_entry)) {
         /* Block not allocated, return zeros, no need to wait. */
         memset(acb->buf, 0, n_sectors * SECTOR_SIZE);
         ret = vdi_schedule_bh(vdi_aio_rw_bh, acb);
@@ -685,7 +690,7 @@ static void vdi_aio_write_cb(void *opaque, int ret)
         if (acb->header_modified) {
             VdiHeader *header = acb->block_buffer;
             logout("now writing modified header\n");
-            assert(acb->bmap_first != VDI_UNALLOCATED);
+            assert(VDI_IS_ALLOCATED(acb->bmap_first));
             *header = s->header;
             vdi_header_to_le(header);
             acb->header_modified = 0;
@@ -699,7 +704,7 @@ static void vdi_aio_write_cb(void *opaque, int ret)
                 goto done;
             }
             return;
-        } else if (acb->bmap_first != VDI_UNALLOCATED) {
+        } else if (VDI_IS_ALLOCATED(acb->bmap_first)) {
             /* One or more new blocks were allocated. */
             uint64_t offset;
             uint32_t bmap_first;
@@ -749,7 +754,7 @@ static void vdi_aio_write_cb(void *opaque, int ret)
     /* prepare next AIO request */
     acb->n_sectors = n_sectors;
     bmap_entry = le32_to_cpu(s->bmap[block_index]);
-    if (bmap_entry == VDI_UNALLOCATED) {
+    if (!VDI_IS_ALLOCATED(bmap_entry)) {
         /* Allocate new block and write to it. */
         uint64_t offset;
         uint8_t *block;
-- 
1.7.6.4

^ permalink raw reply related

* [Qemu-devel] [PATCH 01/55] iSCSI block driver
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>

From: Ronnie Sahlberg <ronniesahlberg@gmail.com>

This provides built-in support for iSCSI to QEMU.

This has the advantage that the iSCSI devices need not be made visible to the host, which is useful if you have very many virtual machines and very many iscsi devices.
It also has the benefit that non-root users of QEMU can access iSCSI devices across the network without requiring root privilege on the host.

This driver interfaces with the multiplatform posix library for iscsi initiator/client access to iscsi devices hosted at
    git://github.com/sahlberg/libiscsi.git

The patch adds the driver to interface with the iscsi library.
It also updated the configure script to
* by default, probe is libiscsi is available and if so, build
  qemu against libiscsi.
* --enable-libiscsi
  Force a build against libiscsi. If libiscsi is not available
  the build will fail.
* --disable-libiscsi
  Do not link against libiscsi, even if it is available.

When linked with libiscsi, qemu gains support to access iscsi resources such as disks and cdrom directly, without having to make the devices visible to the host.

You can specify devices using a iscsi url of the form :
iscsi://[<username>[:<password>@]]<host>[:<port]/<target-iqn-name>/<lun>
When using authentication, the password can optionally be set with
LIBISCSI_CHAP_PASSWORD="password" to avoid it showing up in the process list

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 Makefile.objs |    1 +
 block/iscsi.c |  591 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure     |   31 +++
 trace-events  |    6 +
 4 files changed, 629 insertions(+), 0 deletions(-)
 create mode 100644 block/iscsi.c

diff --git a/Makefile.objs b/Makefile.objs
index 01587c8..d18417c 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -36,6 +36,7 @@ block-nested-y += qed-check.o
 block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o
 block-nested-$(CONFIG_WIN32) += raw-win32.o
 block-nested-$(CONFIG_POSIX) += raw-posix.o
+block-nested-$(CONFIG_LIBISCSI) += iscsi.o
 block-nested-$(CONFIG_CURL) += curl.o
 block-nested-$(CONFIG_RBD) += rbd.o
 
diff --git a/block/iscsi.c b/block/iscsi.c
new file mode 100644
index 0000000..938c568
--- /dev/null
+++ b/block/iscsi.c
@@ -0,0 +1,591 @@
+/*
+ * QEMU Block driver for iSCSI images
+ *
+ * Copyright (c) 2010-2011 Ronnie Sahlberg <ronniesahlberg@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "config-host.h"
+
+#include <poll.h>
+#include "qemu-common.h"
+#include "qemu-error.h"
+#include "block_int.h"
+#include "trace.h"
+
+#include <iscsi/iscsi.h>
+#include <iscsi/scsi-lowlevel.h>
+
+
+typedef struct IscsiLun {
+    struct iscsi_context *iscsi;
+    int lun;
+    int block_size;
+    unsigned long num_blocks;
+} IscsiLun;
+
+typedef struct IscsiAIOCB {
+    BlockDriverAIOCB common;
+    QEMUIOVector *qiov;
+    QEMUBH *bh;
+    IscsiLun *iscsilun;
+    struct scsi_task *task;
+    uint8_t *buf;
+    int status;
+    int canceled;
+    size_t read_size;
+    size_t read_offset;
+} IscsiAIOCB;
+
+struct IscsiTask {
+    IscsiLun *iscsilun;
+    BlockDriverState *bs;
+    int status;
+    int complete;
+};
+
+static void
+iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data,
+                    void *private_data)
+{
+}
+
+static void
+iscsi_aio_cancel(BlockDriverAIOCB *blockacb)
+{
+    IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
+    IscsiLun *iscsilun = acb->iscsilun;
+
+    acb->common.cb(acb->common.opaque, -ECANCELED);
+    acb->canceled = 1;
+
+    /* send a task mgmt call to the target to cancel the task on the target */
+    iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+                                     iscsi_abort_task_cb, NULL);
+
+    /* then also cancel the task locally in libiscsi */
+    iscsi_scsi_task_cancel(iscsilun->iscsi, acb->task);
+}
+
+static AIOPool iscsi_aio_pool = {
+    .aiocb_size         = sizeof(IscsiAIOCB),
+    .cancel             = iscsi_aio_cancel,
+};
+
+
+static void iscsi_process_read(void *arg);
+static void iscsi_process_write(void *arg);
+
+static int iscsi_process_flush(void *arg)
+{
+    IscsiLun *iscsilun = arg;
+
+    return iscsi_queue_length(iscsilun->iscsi) > 0;
+}
+
+static void
+iscsi_set_events(IscsiLun *iscsilun)
+{
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+
+    qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), iscsi_process_read,
+                           (iscsi_which_events(iscsi) & POLLOUT)
+                           ? iscsi_process_write : NULL,
+                           iscsi_process_flush, NULL, iscsilun);
+}
+
+static void
+iscsi_process_read(void *arg)
+{
+    IscsiLun *iscsilun = arg;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+
+    iscsi_service(iscsi, POLLIN);
+    iscsi_set_events(iscsilun);
+}
+
+static void
+iscsi_process_write(void *arg)
+{
+    IscsiLun *iscsilun = arg;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+
+    iscsi_service(iscsi, POLLOUT);
+    iscsi_set_events(iscsilun);
+}
+
+
+static int
+iscsi_schedule_bh(QEMUBHFunc *cb, IscsiAIOCB *acb)
+{
+    acb->bh = qemu_bh_new(cb, acb);
+    if (!acb->bh) {
+        error_report("oom: could not create iscsi bh");
+        return -EIO;
+    }
+
+    qemu_bh_schedule(acb->bh);
+    return 0;
+}
+
+static void
+iscsi_readv_writev_bh_cb(void *p)
+{
+    IscsiAIOCB *acb = p;
+
+    qemu_bh_delete(acb->bh);
+
+    if (acb->canceled == 0) {
+        acb->common.cb(acb->common.opaque, acb->status);
+    }
+
+    qemu_aio_release(acb);
+}
+
+
+static void
+iscsi_aio_write10_cb(struct iscsi_context *iscsi, int status,
+                     void *command_data, void *opaque)
+{
+    IscsiAIOCB *acb = opaque;
+
+    trace_iscsi_aio_write10_cb(iscsi, status, acb, acb->canceled);
+
+    g_free(acb->buf);
+
+    if (acb->canceled != 0) {
+        qemu_aio_release(acb);
+        scsi_free_scsi_task(acb->task);
+        acb->task = NULL;
+        return;
+    }
+
+    acb->status = 0;
+    if (status < 0) {
+        error_report("Failed to write10 data to iSCSI lun. %s",
+                     iscsi_get_error(iscsi));
+        acb->status = -EIO;
+    }
+
+    iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb);
+    scsi_free_scsi_task(acb->task);
+    acb->task = NULL;
+}
+
+static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun)
+{
+    return sector * BDRV_SECTOR_SIZE / iscsilun->block_size;
+}
+
+static BlockDriverAIOCB *
+iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
+                 QEMUIOVector *qiov, int nb_sectors,
+                 BlockDriverCompletionFunc *cb,
+                 void *opaque)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+    IscsiAIOCB *acb;
+    size_t size;
+    int fua = 0;
+
+    /* set FUA on writes when cache mode is write through */
+    if (!(bs->open_flags & BDRV_O_CACHE_WB)) {
+        fua = 1;
+    }
+
+    acb = qemu_aio_get(&iscsi_aio_pool, bs, cb, opaque);
+    trace_iscsi_aio_writev(iscsi, sector_num, nb_sectors, opaque, acb);
+
+    acb->iscsilun = iscsilun;
+    acb->qiov     = qiov;
+
+    acb->canceled   = 0;
+
+    /* XXX we should pass the iovec to write10 to avoid the extra copy */
+    /* this will allow us to get rid of 'buf' completely */
+    size = nb_sectors * BDRV_SECTOR_SIZE;
+    acb->buf = g_malloc(size);
+    qemu_iovec_to_buffer(acb->qiov, acb->buf);
+    acb->task = iscsi_write10_task(iscsi, iscsilun->lun, acb->buf, size,
+                              sector_qemu2lun(sector_num, iscsilun),
+                              fua, 0, iscsilun->block_size,
+                              iscsi_aio_write10_cb, acb);
+    if (acb->task == NULL) {
+        error_report("iSCSI: Failed to send write10 command. %s",
+                     iscsi_get_error(iscsi));
+        g_free(acb->buf);
+        qemu_aio_release(acb);
+        return NULL;
+    }
+
+    iscsi_set_events(iscsilun);
+
+    return &acb->common;
+}
+
+static void
+iscsi_aio_read10_cb(struct iscsi_context *iscsi, int status,
+                    void *command_data, void *opaque)
+{
+    IscsiAIOCB *acb = opaque;
+
+    trace_iscsi_aio_read10_cb(iscsi, status, acb, acb->canceled);
+
+    if (acb->canceled != 0) {
+        qemu_aio_release(acb);
+        scsi_free_scsi_task(acb->task);
+        acb->task = NULL;
+        return;
+    }
+
+    acb->status = 0;
+    if (status != 0) {
+        error_report("Failed to read10 data from iSCSI lun. %s",
+                     iscsi_get_error(iscsi));
+        acb->status = -EIO;
+    }
+
+    iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb);
+    scsi_free_scsi_task(acb->task);
+    acb->task = NULL;
+}
+
+static BlockDriverAIOCB *
+iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
+                QEMUIOVector *qiov, int nb_sectors,
+                BlockDriverCompletionFunc *cb,
+                void *opaque)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+    IscsiAIOCB *acb;
+    size_t qemu_read_size, lun_read_size;
+    int i;
+
+    qemu_read_size = BDRV_SECTOR_SIZE * (size_t)nb_sectors;
+
+    acb = qemu_aio_get(&iscsi_aio_pool, bs, cb, opaque);
+    trace_iscsi_aio_readv(iscsi, sector_num, nb_sectors, opaque, acb);
+
+    acb->iscsilun = iscsilun;
+    acb->qiov     = qiov;
+
+    acb->canceled    = 0;
+    acb->read_size   = qemu_read_size;
+    acb->buf         = NULL;
+
+    /* If LUN blocksize is bigger than BDRV_BLOCK_SIZE a read from QEMU
+     * may be misaligned to the LUN, so we may need to read some extra
+     * data.
+     */
+    acb->read_offset = 0;
+    if (iscsilun->block_size > BDRV_SECTOR_SIZE) {
+        uint64_t bdrv_offset = BDRV_SECTOR_SIZE * sector_num;
+
+        acb->read_offset  = bdrv_offset % iscsilun->block_size;
+    }
+
+    lun_read_size  = (qemu_read_size + iscsilun->block_size
+                     + acb->read_offset - 1)
+                     / iscsilun->block_size * iscsilun->block_size;
+    acb->task = iscsi_read10_task(iscsi, iscsilun->lun,
+                             sector_qemu2lun(sector_num, iscsilun),
+                             lun_read_size, iscsilun->block_size,
+                             iscsi_aio_read10_cb, acb);
+    if (acb->task == NULL) {
+        error_report("iSCSI: Failed to send read10 command. %s",
+                     iscsi_get_error(iscsi));
+        qemu_aio_release(acb);
+        return NULL;
+    }
+
+    for (i = 0; i < acb->qiov->niov; i++) {
+        scsi_task_add_data_in_buffer(acb->task,
+                acb->qiov->iov[i].iov_len,
+                acb->qiov->iov[i].iov_base);
+    }
+
+    iscsi_set_events(iscsilun);
+
+    return &acb->common;
+}
+
+
+static void
+iscsi_synccache10_cb(struct iscsi_context *iscsi, int status,
+                     void *command_data, void *opaque)
+{
+    IscsiAIOCB *acb = opaque;
+
+    if (acb->canceled != 0) {
+        qemu_aio_release(acb);
+        scsi_free_scsi_task(acb->task);
+        acb->task = NULL;
+        return;
+    }
+
+    acb->status = 0;
+    if (status < 0) {
+        error_report("Failed to sync10 data on iSCSI lun. %s",
+                     iscsi_get_error(iscsi));
+        acb->status = -EIO;
+    }
+
+    iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb);
+    scsi_free_scsi_task(acb->task);
+    acb->task = NULL;
+}
+
+static BlockDriverAIOCB *
+iscsi_aio_flush(BlockDriverState *bs,
+                BlockDriverCompletionFunc *cb, void *opaque)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+    IscsiAIOCB *acb;
+
+    acb = qemu_aio_get(&iscsi_aio_pool, bs, cb, opaque);
+
+    acb->iscsilun = iscsilun;
+    acb->canceled   = 0;
+
+    acb->task = iscsi_synchronizecache10_task(iscsi, iscsilun->lun,
+                                         0, 0, 0, 0,
+                                         iscsi_synccache10_cb,
+                                         acb);
+    if (acb->task == NULL) {
+        error_report("iSCSI: Failed to send synchronizecache10 command. %s",
+                     iscsi_get_error(iscsi));
+        qemu_aio_release(acb);
+        return NULL;
+    }
+
+    iscsi_set_events(iscsilun);
+
+    return &acb->common;
+}
+
+static int64_t
+iscsi_getlength(BlockDriverState *bs)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    int64_t len;
+
+    len  = iscsilun->num_blocks;
+    len *= iscsilun->block_size;
+
+    return len;
+}
+
+static void
+iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status,
+                        void *command_data, void *opaque)
+{
+    struct IscsiTask *itask = opaque;
+    struct scsi_readcapacity10 *rc10;
+    struct scsi_task *task = command_data;
+
+    if (status != 0) {
+        error_report("iSCSI: Failed to read capacity of iSCSI lun. %s",
+                     iscsi_get_error(iscsi));
+        itask->status   = 1;
+        itask->complete = 1;
+        scsi_free_scsi_task(task);
+        return;
+    }
+
+    rc10 = scsi_datain_unmarshall(task);
+    if (rc10 == NULL) {
+        error_report("iSCSI: Failed to unmarshall readcapacity10 data.");
+        itask->status   = 1;
+        itask->complete = 1;
+        scsi_free_scsi_task(task);
+        return;
+    }
+
+    itask->iscsilun->block_size = rc10->block_size;
+    itask->iscsilun->num_blocks = rc10->lba;
+    itask->bs->total_sectors = (uint64_t)rc10->lba *
+                               rc10->block_size / BDRV_SECTOR_SIZE ;
+
+    itask->status   = 0;
+    itask->complete = 1;
+    scsi_free_scsi_task(task);
+}
+
+
+static void
+iscsi_connect_cb(struct iscsi_context *iscsi, int status, void *command_data,
+                 void *opaque)
+{
+    struct IscsiTask *itask = opaque;
+    struct scsi_task *task;
+
+    if (status != 0) {
+        itask->status   = 1;
+        itask->complete = 1;
+        return;
+    }
+
+    task = iscsi_readcapacity10_task(iscsi, itask->iscsilun->lun, 0, 0,
+                                   iscsi_readcapacity10_cb, opaque);
+    if (task == NULL) {
+        error_report("iSCSI: failed to send readcapacity command.");
+        itask->status   = 1;
+        itask->complete = 1;
+        return;
+    }
+}
+
+/*
+ * We support iscsi url's on the form
+ * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
+ */
+static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = NULL;
+    struct iscsi_url *iscsi_url = NULL;
+    struct IscsiTask task;
+    int ret;
+
+    if ((BDRV_SECTOR_SIZE % 512) != 0) {
+        error_report("iSCSI: Invalid BDRV_SECTOR_SIZE. "
+                     "BDRV_SECTOR_SIZE(%lld) is not a multiple "
+                     "of 512", BDRV_SECTOR_SIZE);
+        return -EINVAL;
+    }
+
+    memset(iscsilun, 0, sizeof(IscsiLun));
+
+    /* Should really append the KVM name after the ':' here */
+    iscsi = iscsi_create_context("iqn.2008-11.org.linux-kvm:");
+    if (iscsi == NULL) {
+        error_report("iSCSI: Failed to create iSCSI context.");
+        ret = -ENOMEM;
+        goto failed;
+    }
+
+    iscsi_url = iscsi_parse_full_url(iscsi, filename);
+    if (iscsi_url == NULL) {
+        error_report("Failed to parse URL : %s %s", filename,
+                     iscsi_get_error(iscsi));
+        ret = -EINVAL;
+        goto failed;
+    }
+
+    if (iscsi_set_targetname(iscsi, iscsi_url->target)) {
+        error_report("iSCSI: Failed to set target name.");
+        ret = -EINVAL;
+        goto failed;
+    }
+
+    if (iscsi_url->user != NULL) {
+        ret = iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user,
+                                              iscsi_url->passwd);
+        if (ret != 0) {
+            error_report("Failed to set initiator username and password");
+            ret = -EINVAL;
+            goto failed;
+        }
+    }
+    if (iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL) != 0) {
+        error_report("iSCSI: Failed to set session type to normal.");
+        ret = -EINVAL;
+        goto failed;
+    }
+
+    iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
+
+    task.iscsilun = iscsilun;
+    task.status = 0;
+    task.complete = 0;
+    task.bs = bs;
+
+    iscsilun->iscsi = iscsi;
+    iscsilun->lun   = iscsi_url->lun;
+
+    if (iscsi_full_connect_async(iscsi, iscsi_url->portal, iscsi_url->lun,
+                                 iscsi_connect_cb, &task)
+        != 0) {
+        error_report("iSCSI: Failed to start async connect.");
+        ret = -EINVAL;
+        goto failed;
+    }
+
+    while (!task.complete) {
+        iscsi_set_events(iscsilun);
+        qemu_aio_wait();
+    }
+    if (task.status != 0) {
+        error_report("iSCSI: Failed to connect to LUN : %s",
+                     iscsi_get_error(iscsi));
+        ret = -EINVAL;
+        goto failed;
+    }
+
+    if (iscsi_url != NULL) {
+        iscsi_destroy_url(iscsi_url);
+    }
+    return 0;
+
+failed:
+    if (iscsi_url != NULL) {
+        iscsi_destroy_url(iscsi_url);
+    }
+    if (iscsi != NULL) {
+        iscsi_destroy_context(iscsi);
+    }
+    memset(iscsilun, 0, sizeof(IscsiLun));
+    return ret;
+}
+
+static void iscsi_close(BlockDriverState *bs)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+
+    qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), NULL, NULL, NULL, NULL, NULL);
+    iscsi_destroy_context(iscsi);
+    memset(iscsilun, 0, sizeof(IscsiLun));
+}
+
+static BlockDriver bdrv_iscsi = {
+    .format_name     = "iscsi",
+    .protocol_name   = "iscsi",
+
+    .instance_size   = sizeof(IscsiLun),
+    .bdrv_file_open  = iscsi_open,
+    .bdrv_close      = iscsi_close,
+
+    .bdrv_getlength  = iscsi_getlength,
+
+    .bdrv_aio_readv  = iscsi_aio_readv,
+    .bdrv_aio_writev = iscsi_aio_writev,
+    .bdrv_aio_flush  = iscsi_aio_flush,
+};
+
+static void iscsi_block_init(void)
+{
+    bdrv_register(&bdrv_iscsi);
+}
+
+block_init(iscsi_block_init);
diff --git a/configure b/configure
index 4f87e0a..3009bbc 100755
--- a/configure
+++ b/configure
@@ -182,6 +182,7 @@ usb_redir=""
 opengl=""
 zlib="yes"
 guest_agent="yes"
+libiscsi=""
 
 # parse CC options first
 for opt do
@@ -657,6 +658,10 @@ for opt do
   ;;
   --enable-spice) spice="yes"
   ;;
+  --disable-libiscsi) libiscsi="no"
+  ;;
+  --enable-libiscsi) libiscsi="yes"
+  ;;
   --enable-profiler) profiler="yes"
   ;;
   --enable-cocoa)
@@ -1046,6 +1051,8 @@ echo "                           Default:trace-<pid>"
 echo "  --disable-spice          disable spice"
 echo "  --enable-spice           enable spice"
 echo "  --enable-rbd             enable building the rados block device (rbd)"
+echo "  --disable-libiscsi       disable iscsi support"
+echo "  --enable-libiscsi        enable iscsi support"
 echo "  --disable-smartcard      disable smartcard support"
 echo "  --enable-smartcard       enable smartcard support"
 echo "  --disable-smartcard-nss  disable smartcard nss support"
@@ -2335,6 +2342,25 @@ if compile_prog "" "" ; then
 fi
 
 ##########################################
+# Do we have libiscsi
+if test "$libiscsi" != "no" ; then
+  cat > $TMPC << EOF
+#include <iscsi/iscsi.h>
+int main(void) { iscsi_create_context(""); return 0; }
+EOF
+  if compile_prog "-Werror" "-liscsi" ; then
+    libiscsi="yes"
+    LIBS="$LIBS -liscsi"
+  else
+    if test "$libiscsi" = "yes" ; then
+      feature_not_found "libiscsi"
+    fi
+    libiscsi="no"
+  fi
+fi
+
+
+##########################################
 # Do we need librt
 cat > $TMPC <<EOF
 #include <signal.h>
@@ -2744,6 +2770,7 @@ echo "xfsctl support    $xfs"
 echo "nss used          $smartcard_nss"
 echo "usb net redir     $usb_redir"
 echo "OpenGL support    $opengl"
+echo "libiscsi support  $libiscsi"
 echo "build guest agent $guest_agent"
 
 if test "$sdl_too_old" = "yes"; then
@@ -3042,6 +3069,10 @@ if test "$opengl" = "yes" ; then
   echo "CONFIG_OPENGL=y" >> $config_host_mak
 fi
 
+if test "$libiscsi" = "yes" ; then
+  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
+fi
+
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
   echo "CONFIG_BSD=y" >> $config_host_mak
diff --git a/trace-events b/trace-events
index 820b1d6..a888055 100644
--- a/trace-events
+++ b/trace-events
@@ -505,6 +505,12 @@ escc_sunkbd_event_out(int ch) "Translated keycode %2.2x"
 escc_kbd_command(int val) "Command %d"
 escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=%01x"
 
+# block/iscsi.c
+iscsi_aio_write10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+iscsi_aio_writev(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"
+iscsi_aio_read10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+iscsi_aio_readv(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"
+
 # hw/esp.c
 esp_raise_irq(void) "Raise IRQ"
 esp_lower_irq(void) "Lower IRQ"
-- 
1.7.6.4

^ permalink raw reply related

* [Qemu-devel] [PATCH 02/55] Documentation: Add iSCSI section
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>

From: Ronnie Sahlberg <ronniesahlberg@gmail.com>

Add new section for device URL syntax for special files and describe the iSCSI
URL with examples

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-options.hx |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 5d2a776..424bae9 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -148,6 +148,9 @@ Define a new drive. Valid options are:
 This option defines which disk image (@pxref{disk_images}) to use with
 this drive. If the filename contains comma, you must double it
 (for instance, "file=my,,file" to use file "my,file").
+
+Special files such as iSCSI devices can be specified using protocol
+specific URLs. See the section for "Device URL Syntax" for more information.
 @item if=@var{interface}
 This option defines on which type on interface the drive is connected.
 Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
@@ -1718,6 +1721,45 @@ ETEXI
 
 DEFHEADING()
 
+STEXI
+DEFHEADING(Device URL Syntax:)
+
+In addition to using normal file images for the emulated storage devices,
+QEMU can also use networked resources such as iSCSI devices. These are
+specified using a special URL syntax.
+
+@table @option
+@item iSCSI
+iSCSI support allows QEMU to access iSCSI resources directly and use as
+images for the guest storage. Both disk and cdrom images are supported.
+
+Syntax for specifying iSCSI LUNs is
+``iscsi://<target-ip>[:<port>]/<target-iqn>/<lun>''
+
+Example (without authentication):
+@example
+qemu -cdrom iscsi://192.0.2.1/iqn.2001-04.com.example/2 \
+--drive file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
+@end example
+
+Example (CHAP username/password via URL):
+@example
+qemu --drive file=iscsi://user%password@@192.0.2.1/iqn.2001-04.com.example/1
+@end example
+
+Example (CHAP username/password via environment variables):
+@example
+LIBISCSI_CHAP_USERNAME="user" \
+LIBISCSI_CHAP_PASSWORD="password" \
+qemu --drive file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
+@end example
+
+iSCSI support is an optional feature of QEMU and only available when
+compiled and linked against libiscsi.
+
+@end table
+ETEXI
+
 DEFHEADING(Bluetooth(R) options:)
 
 DEF("bt", HAS_ARG, QEMU_OPTION_bt, \
-- 
1.7.6.4

^ permalink raw reply related

* [Qemu-devel] [PULL 00/55] Block patches
From: Kevin Wolf @ 2011-10-31 13:29 UTC (permalink / raw)
  To: anthony; +Cc: kwolf, qemu-devel

The following changes since commit b5a12aa204f842c8010ac9d2e4b115114dbf09f0:

  Merge branch 'rth/vis2' of git://repo.or.cz/qemu/rth (2011-10-27 20:27:07 +0000)

are available in the git repository at:

  git://repo.or.cz/qemu/kevin.git for-anthony

Dong Xu Wang (1):
      block: fix qcow2_co_flush deadlock

Eric Sunshine (1):
      Teach block/vdi about "discarded" (no longer allocated) blocks

Kevin Wolf (7):
      block: Remove dead code
      block: Fix bdrv_open use after free
      qcow: Fix bdrv_write_compressed error handling
      ide: Fix off-by-one error in array index check
      vmdk: Fix use of uninitialised value
      vmdk: Improve error handling
      vmdk: Fix possible segfaults

Paolo Bonzini (38):
      scsi: pass correct sense code for ENOMEDIUM
      atapi/scsi: unify definitions for MMC
      atapi: move GESN definitions to scsi-defs.h
      atapi: cleanup/fix mode sense results
      scsi: notify the device when unit attention is reported
      scsi-disk: report media changed via unit attention sense codes
      scsi-disk: fix coding style issues (braces)
      scsi-disk: add stubs for more MMC commands
      scsi-disk: store valid mode pages in a table
      atapi/scsi-disk: make mode page values coherent between the two
      scsi-disk: support DVD profile in GET CONFIGURATION
      scsi-disk: support READ DVD STRUCTURE
      scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION
      scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)
      qdev: switch children device list to QTAILQ
      scsi: remove devs array from SCSIBus
      scsi: implement REPORT LUNS for arbitrary LUNs
      scsi: allow arbitrary LUNs
      scsi: add channel to addressing
      scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0
      scsi-disk: fix retrying a flush
      scsi-generic: drop SCSIGenericState
      scsi-generic: remove scsi_req_fixup
      scsi-generic: check ioctl statuses when SG_IO succeeds
      scsi-generic: look at host status
      scsi-generic: snoop READ CAPACITY commands to get block size
      scsi-disk: do not duplicate BlockDriverState member
      scsi-disk: remove cluster_size
      scsi-disk: small clean up to INQUIRY
      scsi: move max_lba to SCSIDevice
      scsi: make reqops const
      scsi: export scsi_generic_reqops
      scsi: pass cdb to alloc_req
      scsi: do not call transfer_data after canceling a request
      scsi-disk: bump SCSIRequest reference count until aio completion runs
      scsi-generic: bump SCSIRequest reference count until aio completion runs
      scsi: push request restart to SCSIDevice
      scsi-disk: add scsi-block for device passthrough

Ronnie Sahlberg (4):
      iSCSI block driver
      Documentation: Add iSCSI section
      Documentation: Describe NBD URL syntax
      Documentation: Add syntax for using sheepdog devices

Stefan Hajnoczi (3):
      qemu-io: delete bs instead of leaking it
      block: set bs->read_only before .bdrv_open()
      block: reinitialize across bdrv_close()/bdrv_open()

Zhi Yong Wu (1):
      qcow2: fix some errors and typo in qcow2.txt

 Makefile.objs        |    1 +
 block.c              |   18 +-
 block/iscsi.c        |  591 ++++++++++++++++++++++++++++++++++++
 block/qcow.c         |   30 ++-
 block/qcow2.c        |    2 +
 block/vdi.c          |   23 +-
 block/vmdk.c         |   30 ++-
 configure            |   31 ++
 docs/specs/qcow2.txt |    6 +-
 hw/acpi_piix4.c      |    4 +-
 hw/esp.c             |   16 +-
 hw/i2c.c             |    2 +-
 hw/ide/atapi.c       |  119 +++-----
 hw/ide/core.c        |    6 +-
 hw/ide/internal.h    |   71 +-----
 hw/ide/macio.c       |    2 +-
 hw/intel-hda.c       |    6 +-
 hw/lsi53c895a.c      |   30 +-
 hw/qdev.c            |   24 +-
 hw/qdev.h            |    4 +-
 hw/s390-virtio-bus.c |    4 +-
 hw/scsi-bus.c        |  279 +++++++++++++----
 hw/scsi-defs.h       |   90 ++++++
 hw/scsi-disk.c       |  824 +++++++++++++++++++++++++++++++++++++-------------
 hw/scsi-generic.c    |  201 ++++++-------
 hw/scsi.h            |   39 ++-
 hw/spapr_vio.c       |    6 +-
 hw/spapr_vscsi.c     |   54 +++-
 hw/ssi.c             |    6 +-
 hw/usb-msd.c         |    8 +-
 qemu-io.c            |    5 +-
 qemu-options.hx      |   90 ++++++
 trace-events         |    7 +
 33 files changed, 1979 insertions(+), 650 deletions(-)
 create mode 100644 block/iscsi.c

^ permalink raw reply

* [GIT] pull request for x86 platform drivers tree
From: Matthew Garrett @ 2011-10-31 13:24 UTC (permalink / raw)
  To: torvalds; +Cc: platform-driver-x86

Hi Linus,

Misc set of updates for the x86 platform driver tree. Nothing terribly 
exciting here this time around, but some nice fixes for various things 
and support for a wider range of Toshibas.

The following changes since commit c3b92c8787367a8bb53d57d9789b558f1295cc96:

  Linux 3.1 (2011-10-24 09:10:05 +0200)

are available in the git repository at:
  git://cavan.codon.org.uk/platform-drivers-x86.git for_linus

AceLan Kao (1):
      dell-laptop: support Synaptics/Alps touchpad led

Andy Ross (4):
      asus-laptop: Platform detection for Pegatron Lucid
      asus-laptop: Pegatron Lucid ALS sensor
      asus-laptop: allow boot time control of Pegatron ALS sensor
      asus-laptop: Pegatron Lucid accelerometer

Anisse Astier (2):
      asus-laptop: pega_accel - Report accelerometer orientation change through udev
      asus-laptop: Add rfkill support for Pegatron Lucid tablet

Axel Lin (3):
      platform-drivers-x86: eeepc-laptop: fix wrong test for successful registered led_classdev
      platform-drivers-x86: asus-wmi: fix resource leak in asus_wmi_led_exit
      platform-drivers-x86: asus-laptop: fix wrong test for successful registered led_classdev

Corentin Chary (2):
      asus-laptop: hide leds on Pegatron Lucid
      asus-laptop: fix module description

David Herrmann (1):
      Platform: Fix error path in samsung-laptop init

Dmitry Torokhov (1):
      WMI: properly cleanup devices to avoid crashes

Ike Panhc (6):
      MAINTAINERS: add new entry for ideapad-laptop
      ideapad: define vpc commands
      ideapad: change parameter of ideapad_sync_rfk_state
      ideapad: add event for Novo key
      ideapad: add debugfs support
      ideapad: remove sysfs node for cfg

Jason Stubbs (3):
      platform: samsung_laptop: fix samsung brightness min/max calculations
      Platform: Brightness quirk for samsung laptop driver
      Platform: Samsung laptop DMI info for NC210/NC110

John Serock (1):
      Platform: Detect samsung laptop quirk when initial level is zero

Kirill A. Shutemov (1):
      intel_scu_ipcutil: fix major device number handling

Lee, Chun-Yi (4):
      acer-wmi: check wireless capability flag before register rfkill
      acer-wmi: add ACER_WMID_v2 interface flag to represent new notebooks
      acer-wmi: check the existence of internal wireless device when set capability
      acer-wmi: replaced the hard coded bitmap by the communication devices bitmap from SMBIOS

Manuel Lauss (1):
      topstar-latop: ignore 0x82 event

Raul Gutierrez Segales (1):
      Platform: fix samsung-laptop DMI identification for N220 model

Rene Bollford (1):
      ideapad: Check if acpi already handle backlight power to avoid a page fault

Seth Forshee (7):
      toshiba_acpi: Convert to use acpi_driver
      toshiba_acpi: Fix up return codes
      toshiba_acpi: Use handle for HCI calls
      toshiba_acpi: Support SPFC as an HCI method
      toshiba_acpi: Don't add devices for unsupported features
      toshiba_acpi: Initialize brightness in backlight device
      acer-wmi: Add wireless quirk for Lenovo 3000 N200

Smelov Andrey (1):
      Platform: samsung_laptop: samsung backlight for R528/R728

Stefan Beller (1):
      platform: samsung_laptop: add dmi information for Samsung R700 laptops

Takashi Iwai (2):
      hp_accel: Add a new PNP id
      hp_accel: Add axis-mapping for HP ProBook / EliteBook

Tommaso Massimi (1):
      Platform: samsung_laptop: add support for X520 machines.

Yong Zhang (1):
      sony-laptop:irq: Remove IRQF_DISABLED

 Documentation/ABI/testing/debugfs-ideapad          |   19 +
 .../ABI/testing/sysfs-platform-ideapad-laptop      |   15 -
 MAINTAINERS                                        |    7 +
 drivers/platform/x86/Kconfig                       |   19 +-
 drivers/platform/x86/acer-wmi.c                    |  488 ++++++++-------
 drivers/platform/x86/asus-laptop.c                 |  378 +++++++++++-
 drivers/platform/x86/asus-wmi.c                    |    4 +-
 drivers/platform/x86/dell-laptop.c                 |   84 +++
 drivers/platform/x86/eeepc-laptop.c                |    2 +-
 drivers/platform/x86/hp_accel.c                    |    5 +
 drivers/platform/x86/ideapad-laptop.c              |  251 +++++++-
 drivers/platform/x86/intel_scu_ipcutil.c           |    8 +-
 drivers/platform/x86/samsung-laptop.c              |  107 +++-
 drivers/platform/x86/sony-laptop.c                 |    2 +-
 drivers/platform/x86/topstar-laptop.c              |    1 +
 drivers/platform/x86/toshiba_acpi.c                |  641 +++++++++++---------
 drivers/platform/x86/wmi.c                         |    6 +-
 17 files changed, 1422 insertions(+), 615 deletions(-)
 create mode 100644 Documentation/ABI/testing/debugfs-ideapad

-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply

* Re: [PATCH 04/14] KVM: PPC: e500: MMU API
From: Avi Kivity @ 2011-10-31 13:24 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kvm-ppc, kvm list, Marcelo Tosatti, Scott Wood
In-Reply-To: <1320047596-20577-5-git-send-email-agraf@suse.de>

On 10/31/2011 09:53 AM, Alexander Graf wrote:
> From: Scott Wood <scottwood@freescale.com>
>
> This implements a shared-memory API for giving host userspace access to
> the guest's TLB.
>
>
> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
> index 7945b0b..ab1136f 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -1383,6 +1383,38 @@ The following flags are defined:
>  If datamatch flag is set, the event will be signaled only if the written value
>  to the registered address is equal to datamatch in struct kvm_ioeventfd.
>  
> +4.59 KVM_DIRTY_TLB
> +
> +Capability: KVM_CAP_SW_TLB
> +Architectures: ppc
> +Type: vcpu ioctl
> +Parameters: struct kvm_dirty_tlb (in)
> +Returns: 0 on success, -1 on error
> +
> +struct kvm_dirty_tlb {
> +	__u64 bitmap;
> +	__u32 num_dirty;
> +};

This is not 32/64 bit safe.  e500 is 32-bit only, yes? but what if
someone wants to emulate an e500 on a ppc64?  maybe it's better to add
padding here.

Another alternative is to drop the num_dirty field (and let the kernel
compute it instead, shouldn't take long?), and have the third argument
to ioctl() reference the bitmap directly.

> +
> +This must be called whenever userspace has changed an entry in the shared
> +TLB, prior to calling KVM_RUN on the associated vcpu.
> +
> +The "bitmap" field is the userspace address of an array.  This array
> +consists of a number of bits, equal to the total number of TLB entries as
> +determined by the last successful call to KVM_CONFIG_TLB, rounded up to the
> +nearest multiple of 64.
> +
> +Each bit corresponds to one TLB entry, ordered the same as in the shared TLB
> +array.
> +
> +The array is little-endian: the bit 0 is the least significant bit of the
> +first byte, bit 8 is the least significant bit of the second byte, etc.
> +This avoids any complications with differing word sizes.

And people say little/big endian is just a matter of taste.

> +
> +The "num_dirty" field is a performance hint for KVM to determine whether it
> +should skip processing the bitmap and just invalidate everything.  It must
> +be set to the number of set bits in the bitmap.
> +
>  4.62 KVM_CREATE_SPAPR_TCE
>  
>  Capability: KVM_CAP_SPAPR_TCE
> @@ -1700,3 +1732,45 @@ HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
>  HTAB invisible to the guest.
>  
>  When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
> +
> +6.3 KVM_CAP_SW_TLB
> +
> +Architectures: ppc
> +Parameters: args[0] is the address of a struct kvm_config_tlb
> +Returns: 0 on success; -1 on error
> +
> +struct kvm_config_tlb {
> +	__u64 params;
> +	__u64 array;
> +	__u32 mmu_type;
> +	__u32 array_len;
> +};

Would it not be simpler to use args[0-3] for this, instead of yet
another indirection?

> +
> +Configures the virtual CPU's TLB array, establishing a shared memory area
> +between userspace and KVM.  The "params" and "array" fields are userspace
> +addresses of mmu-type-specific data structures.  The "array_len" field is an
> +safety mechanism, and should be set to the size in bytes of the memory that
> +userspace has reserved for the array.  It must be at least the size dictated
> +by "mmu_type" and "params".
> +
> +While KVM_RUN is active, the shared region is under control of KVM.  Its
> +contents are undefined, and any modification by userspace results in
> +boundedly undefined behavior.
> +
> +On return from KVM_RUN, the shared region will reflect the current state of
> +the guest's TLB.  If userspace makes any changes, it must call KVM_DIRTY_TLB
> +to tell KVM which entries have been changed, prior to calling KVM_RUN again
> +on this vcpu.

We already have another mechanism for such shared memory,
mmap(vcpu_fd).  x86 uses it for the coalesced mmio region as well as the
traditional kvm_run area.  Please consider using it.


> +
> +For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
> + - The "params" field is of type "struct kvm_book3e_206_tlb_params".
> + - The "array" field points to an array of type "struct
> +   kvm_book3e_206_tlb_entry".
> + - The array consists of all entries in the first TLB, followed by all
> +   entries in the second TLB.
> + - Within a TLB, entries are ordered first by increasing set number.  Within a
> +   set, entries are ordered by way (increasing ESEL).
> + - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
> +   where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
> + - The tsize field of mas1 shall be set to 4K on TLB0, even though the
> +   hardware ignores this value for TLB0.

Holy shit.

> @@ -95,6 +90,9 @@ struct kvmppc_vcpu_e500 {
>  	u32 tlb1cfg;
>  	u64 mcar;
>  
> +	struct page **shared_tlb_pages;
> +	int num_shared_tlb_pages;
> +

I missed the requirement that things be page aligned.

If you use mmap(vcpu_fd) this becomes simpler; you can use
get_free_pages() and have a single pointer.  You can also use vmap() on
this array (but get_free_pages() is faster).


-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply

* Re: [PATCH 04/14] KVM: PPC: e500: MMU API
From: Avi Kivity @ 2011-10-31 13:24 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kvm-ppc, kvm list, Marcelo Tosatti, Scott Wood
In-Reply-To: <1320047596-20577-5-git-send-email-agraf@suse.de>

On 10/31/2011 09:53 AM, Alexander Graf wrote:
> From: Scott Wood <scottwood@freescale.com>
>
> This implements a shared-memory API for giving host userspace access to
> the guest's TLB.
>
>
> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
> index 7945b0b..ab1136f 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -1383,6 +1383,38 @@ The following flags are defined:
>  If datamatch flag is set, the event will be signaled only if the written value
>  to the registered address is equal to datamatch in struct kvm_ioeventfd.
>  
> +4.59 KVM_DIRTY_TLB
> +
> +Capability: KVM_CAP_SW_TLB
> +Architectures: ppc
> +Type: vcpu ioctl
> +Parameters: struct kvm_dirty_tlb (in)
> +Returns: 0 on success, -1 on error
> +
> +struct kvm_dirty_tlb {
> +	__u64 bitmap;
> +	__u32 num_dirty;
> +};

This is not 32/64 bit safe.  e500 is 32-bit only, yes? but what if
someone wants to emulate an e500 on a ppc64?  maybe it's better to add
padding here.

Another alternative is to drop the num_dirty field (and let the kernel
compute it instead, shouldn't take long?), and have the third argument
to ioctl() reference the bitmap directly.

> +
> +This must be called whenever userspace has changed an entry in the shared
> +TLB, prior to calling KVM_RUN on the associated vcpu.
> +
> +The "bitmap" field is the userspace address of an array.  This array
> +consists of a number of bits, equal to the total number of TLB entries as
> +determined by the last successful call to KVM_CONFIG_TLB, rounded up to the
> +nearest multiple of 64.
> +
> +Each bit corresponds to one TLB entry, ordered the same as in the shared TLB
> +array.
> +
> +The array is little-endian: the bit 0 is the least significant bit of the
> +first byte, bit 8 is the least significant bit of the second byte, etc.
> +This avoids any complications with differing word sizes.

And people say little/big endian is just a matter of taste.

> +
> +The "num_dirty" field is a performance hint for KVM to determine whether it
> +should skip processing the bitmap and just invalidate everything.  It must
> +be set to the number of set bits in the bitmap.
> +
>  4.62 KVM_CREATE_SPAPR_TCE
>  
>  Capability: KVM_CAP_SPAPR_TCE
> @@ -1700,3 +1732,45 @@ HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
>  HTAB invisible to the guest.
>  
>  When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
> +
> +6.3 KVM_CAP_SW_TLB
> +
> +Architectures: ppc
> +Parameters: args[0] is the address of a struct kvm_config_tlb
> +Returns: 0 on success; -1 on error
> +
> +struct kvm_config_tlb {
> +	__u64 params;
> +	__u64 array;
> +	__u32 mmu_type;
> +	__u32 array_len;
> +};

Would it not be simpler to use args[0-3] for this, instead of yet
another indirection?

> +
> +Configures the virtual CPU's TLB array, establishing a shared memory area
> +between userspace and KVM.  The "params" and "array" fields are userspace
> +addresses of mmu-type-specific data structures.  The "array_len" field is an
> +safety mechanism, and should be set to the size in bytes of the memory that
> +userspace has reserved for the array.  It must be at least the size dictated
> +by "mmu_type" and "params".
> +
> +While KVM_RUN is active, the shared region is under control of KVM.  Its
> +contents are undefined, and any modification by userspace results in
> +boundedly undefined behavior.
> +
> +On return from KVM_RUN, the shared region will reflect the current state of
> +the guest's TLB.  If userspace makes any changes, it must call KVM_DIRTY_TLB
> +to tell KVM which entries have been changed, prior to calling KVM_RUN again
> +on this vcpu.

We already have another mechanism for such shared memory,
mmap(vcpu_fd).  x86 uses it for the coalesced mmio region as well as the
traditional kvm_run area.  Please consider using it.


> +
> +For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
> + - The "params" field is of type "struct kvm_book3e_206_tlb_params".
> + - The "array" field points to an array of type "struct
> +   kvm_book3e_206_tlb_entry".
> + - The array consists of all entries in the first TLB, followed by all
> +   entries in the second TLB.
> + - Within a TLB, entries are ordered first by increasing set number.  Within a
> +   set, entries are ordered by way (increasing ESEL).
> + - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
> +   where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
> + - The tsize field of mas1 shall be set to 4K on TLB0, even though the
> +   hardware ignores this value for TLB0.

Holy shit.

> @@ -95,6 +90,9 @@ struct kvmppc_vcpu_e500 {
>  	u32 tlb1cfg;
>  	u64 mcar;
>  
> +	struct page **shared_tlb_pages;
> +	int num_shared_tlb_pages;
> +

I missed the requirement that things be page aligned.

If you use mmap(vcpu_fd) this becomes simpler; you can use
get_free_pages() and have a single pointer.  You can also use vmap() on
this array (but get_free_pages() is faster).


-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply

* [U-Boot] [PATCH 4/4] PXA: Adapt Voipac PXA270 to OneNAND SPL
From: Marek Vasut @ 2011-10-31 13:23 UTC (permalink / raw)
  To: u-boot
In-Reply-To: <1320067393-18822-1-git-send-email-marek.vasut@gmail.com>

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
---
 board/vpac270/Makefile    |    6 ++
 board/vpac270/onenand.c   |  136 +++++++++++++++++++++++++++++++++++++++++++++
 board/vpac270/vpac270.c   |    2 +
 include/configs/vpac270.h |   25 +++++++--
 4 files changed, 164 insertions(+), 5 deletions(-)
 create mode 100644 board/vpac270/onenand.c

diff --git a/board/vpac270/Makefile b/board/vpac270/Makefile
index b5c60fd..f25822f 100644
--- a/board/vpac270/Makefile
+++ b/board/vpac270/Makefile
@@ -23,7 +23,13 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
+ifndef	CONFIG_SPL_BUILD
 COBJS	:= vpac270.o
+endif
+
+ifdef	CONFIG_SPL_BUILD
+COBJS	:= onenand.o
+endif
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
diff --git a/board/vpac270/onenand.c b/board/vpac270/onenand.c
new file mode 100644
index 0000000..50de2ab
--- /dev/null
+++ b/board/vpac270/onenand.c
@@ -0,0 +1,136 @@
+/*
+ * Voipac PXA270 OneNAND SPL
+ *
+ * Copyright (C) 2011 Marek Vasut <marek.vasut@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 <config.h>
+#include <asm/io.h>
+#include <onenand_uboot.h>
+
+extern void pxa_dram_init(void);
+
+inline void spl_copy_self(void)
+{
+	extern uint32_t _end;
+	struct spl_onenand_data data;
+	uint32_t page;
+	uint32_t total_bytes = (uint32_t)&_end - CONFIG_SPL_TEXT_BASE;
+	uint32_t total_pages;
+	uint8_t *addr = (uint8_t *)CONFIG_SPL_TEXT_BASE;
+	int ret;
+
+	spl_onenand_get_geometry(&data);
+
+	/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */
+	total_pages = total_bytes >> 11;
+	if (data.pagesize == 4096)
+		total_pages >>= 1;
+
+	for (page = 0; page <= total_pages; page++) {
+		ret = spl_onenand_read_page(0, page, addr, data.pagesize);
+		if (ret)
+			total_pages++;
+		else
+			addr += data.pagesize;
+	}
+}
+
+inline void spl_copy_uboot(void)
+{
+	uint8_t *addr = (uint8_t *)CONFIG_SYS_TEXT_BASE;
+	struct spl_onenand_data data;
+	uint32_t total_pages;
+	uint32_t block;
+	uint32_t page, rpage;
+	int ret;
+
+	spl_onenand_get_geometry(&data);
+
+	/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */
+	total_pages = CONFIG_SPL_ONENAND_LOAD_SIZE >> 11;
+	page = CONFIG_SPL_ONENAND_LOAD_ADDR >> 11;
+	if (data.pagesize == 4096) {
+		total_pages >>= 1;
+		page >>= 1;
+	}
+
+	for (; page <= total_pages; page++) {
+		block = page >> 6;
+		rpage = page & 0xff;
+		ret = spl_onenand_read_page(block, rpage, addr, data.pagesize);
+		if (ret)
+			total_pages++;
+		else
+			addr += data.pagesize;
+	}
+}
+
+inline void board_init_f(unsigned long unused)
+{
+	uint32_t tmp;
+
+	asm volatile("mov %0, pc" : "=r"(tmp));
+	tmp >>= 24;
+
+	/* The code runs from OneNAND RAM, copy SPL to SRAM and execute it. */
+	if (tmp == 0) {
+		spl_copy_self();
+		asm volatile("mov pc, %0" : : "r"(CONFIG_SPL_TEXT_BASE));
+	}
+
+	/* Hereby, the code runs from (S)RAM, copy U-Boot and execute it. */
+	arch_cpu_init();
+	pxa_dram_init();
+	spl_copy_uboot();
+	asm volatile("mov pc, %0" : : "r"(CONFIG_SYS_TEXT_BASE));
+
+	for (;;)
+		;
+}
+
+inline void board_init_r(gd_t *id, ulong dest_addr)
+{
+	for (;;)
+		;
+}
+
+inline int printf(const char *fmt, ...)
+{
+	return 0;
+}
+
+inline void __coloured_LED_init(void) {}
+inline void __red_LED_on(void) {}
+void coloured_LED_init(void)
+	__attribute__((weak, alias("__coloured_LED_init")));
+void red_LED_on(void)
+	__attribute__((weak, alias("__red_LED_on")));
+void hang(void) __attribute__ ((noreturn));
+void hang(void)
+{
+	for (;;)
+		;
+}
+
+inline void icache_disable(void) {}
+inline void dcache_disable(void) {}
diff --git a/board/vpac270/vpac270.c b/board/vpac270/vpac270.c
index 43bbdff..f146009 100644
--- a/board/vpac270/vpac270.c
+++ b/board/vpac270/vpac270.c
@@ -56,7 +56,9 @@ struct serial_device *default_serial_console(void)
 extern void pxa_dram_init(void);
 int dram_init(void)
 {
+#ifndef	CONFIG_ONENAND
 	pxa_dram_init();
+#endif
 	gd->ram_size = PHYS_SDRAM_1_SIZE;
 	return 0;
 }
diff --git a/include/configs/vpac270.h b/include/configs/vpac270.h
index 9db4d99..d43ff47 100644
--- a/include/configs/vpac270.h
+++ b/include/configs/vpac270.h
@@ -27,7 +27,17 @@
  */
 #define	CONFIG_PXA27X		1	/* Marvell PXA270 CPU */
 #define	CONFIG_VPAC270		1	/* Voipac PXA270 board */
-#define	CONFIG_SYS_TEXT_BASE	0x0
+#define	CONFIG_SYS_TEXT_BASE	0xa0000000
+
+#ifdef	CONFIG_ONENAND
+#define	CONFIG_SPL
+#define	CONFIG_SPL_ONENAND_SUPPORT
+#define	CONFIG_SPL_ONENAND_LOAD_ADDR	0x2000
+#define	CONFIG_SPL_ONENAND_LOAD_SIZE	\
+	(512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
+#define	CONFIG_SPL_TEXT_BASE	0x5c000000
+#define	CONFIG_SPL_LDSCRIPT	"board/vpac270/u-boot-spl.lds"
+#endif
 
 /*
  * Environment settings
@@ -46,12 +56,19 @@
 		"bootm 0xa4000000; "					\
 	"fi; "								\
 	"bootm 0x60000;"
+
+#define	CONFIG_EXTRA_ENV_SETTINGS					\
+	"update_onenand="						\
+		"onenand erase 0x0 0x80000 ; "				\
+		"onenand write 0xa0000000 0x0 0x80000"
+
 #define	CONFIG_BOOTARGS			"console=tty0 console=ttyS0,115200"
 #define	CONFIG_TIMESTAMP
 #define	CONFIG_BOOTDELAY		2	/* Autoboot delay */
 #define	CONFIG_CMDLINE_TAG
 #define	CONFIG_SETUP_MEMORY_TAGS
 #define	CONFIG_LZMA			/* LZMA compression support */
+#define	CONFIG_OF_LIBFDT
 
 /*
  * Serial Console Configuration
@@ -179,16 +196,14 @@
 #define	CONFIG_SYS_MEMTEST_END		0xa0800000	/* 4 ... 8 MB in DRAM */
 
 #define	CONFIG_SYS_LOAD_ADDR		PHYS_SDRAM_1
-#define	CONFIG_SYS_IPL_LOAD_ADDR	(0x5c000000)
 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
-#define	CONFIG_SYS_INIT_SP_ADDR		\
-	(PHYS_SDRAM_1 + GENERATED_GBL_DATA_SIZE + 2048)
+#define	CONFIG_SYS_INIT_SP_ADDR		0x5c010000
 
 /*
  * NOR FLASH
  */
 #define	CONFIG_SYS_MONITOR_BASE		0x0
-#define	CONFIG_SYS_MONITOR_LEN		0x40000
+#define	CONFIG_SYS_MONITOR_LEN		0x80000
 #define	CONFIG_ENV_ADDR			\
 			(CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
 #define	CONFIG_ENV_SIZE			0x4000
-- 
1.7.6.3

^ permalink raw reply related

* Re: [Xenomai-help] configuring user-space xenomai 2.6
From: Łukasz Sacha @ 2011-10-31 13:23 UTC (permalink / raw)
  To: xenomai
In-Reply-To: <4EAE9EDE.5030501@domain.hid>

I used the toolchain from codesourcery
(http://www.codesourcery.com/sgpp/lite/arm/portal/package3696/public/arm-none-linux-gnueabi/arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2).
The one downloaded from the ubuntu repos behaves the same way.
--
Łukasz Dragilla Sacha



On Mon, Oct 31, 2011 at 14:13, Gilles Chanteperdrix
<gilles.chanteperdrix@xenomai.org> wrote:
> On 10/31/2011 01:52 PM, Łukasz Sacha wrote:
>> This is the line configure generated to test whether compiler works:
>> arm-none-linux-gnueabi-gcc –march=armv4t –mtune=arm920t -o conftest
>> -march=armv4t -march=armv4t conftest.c
>> (notice tripple  -march=armv4t)
>>
>> when I execute it it gives me:
>> arm-none-linux-gnueabi-gcc: –march=armv4t: No such file or directory
>> arm-none-linux-gnueabi-gcc: –mtune=arm920t: No such file or directory
>> arm-none-linux-gnueabi-gcc: conftest.c: No such file or directory
>> arm-none-linux-gnueabi-gcc: no input files
>>
>> However with a single  -march=armv4t it doesn't work either.
>> luke@domain.hid$
>> arm-none-linux-gnueabi-gcc -march=armv4t –mtune=arm920t -o conftest
>> conftest.c
>> arm-none-linux-gnueabi-gcc: –mtune=arm920t: No such file or directory
>> arm-none-linux-gnueabi-gcc: conftest.c: No such file or directory
>> arm-none-linux-gnueabi-gcc: no input files
>>
>> .. which is strange, because arm-none-linux-gnueabi-gcc --help tells
>> me all the options are ok:
>> "Options starting with -g, -f, -m, -O, -W, or --param are automatically
>>  passed on to the various sub-processes invoked by arm-none-linux-gnueabi-gcc."
>>
>> Seems -mtune is not recognized by some subprocess, but which and why?
>>
>> cheers :)
>
> Strange toolchain. I use codesourcery toolchain and never observed such
> behaviour. You should make sure the toolchain you use works before
> trying and compiling xenomai.
>
> --
>                                                                Gilles.
>
>


^ permalink raw reply

* [U-Boot] [PATCH 3/4] OneNAND: Add simple OneNAND SPL
From: Marek Vasut @ 2011-10-31 13:23 UTC (permalink / raw)
  To: u-boot
In-Reply-To: <1320067393-18822-1-git-send-email-marek.vasut@gmail.com>

This introduces small OneNAND loader, fitting into 1kB of space (smallest
possible OneNAND RAM size). Some devices equipped with such crappy chips will
use this.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Scott Wood <scottwood@freescale.com>
---
 drivers/mtd/onenand/Makefile      |    4 +
 drivers/mtd/onenand/onenand_spl.c |  130 +++++++++++++++++++++++++++++++++++++
 include/onenand_uboot.h           |   18 +++++
 spl/Makefile                      |    1 +
 4 files changed, 153 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/onenand/onenand_spl.c

diff --git a/drivers/mtd/onenand/Makefile b/drivers/mtd/onenand/Makefile
index b984bd4..b090d40 100644
--- a/drivers/mtd/onenand/Makefile
+++ b/drivers/mtd/onenand/Makefile
@@ -25,8 +25,12 @@ include $(TOPDIR)/config.mk
 
 LIB	:= $(obj)libonenand.o
 
+ifndef	CONFIG_SPL_BUILD
 COBJS-$(CONFIG_CMD_ONENAND)	:= onenand_uboot.o onenand_base.o onenand_bbt.o
 COBJS-$(CONFIG_SAMSUNG_ONENAND)	+= samsung.o
+else
+COBJS-y				:= onenand_spl.o
+endif
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/mtd/onenand/onenand_spl.c b/drivers/mtd/onenand/onenand_spl.c
new file mode 100644
index 0000000..5429972
--- /dev/null
+++ b/drivers/mtd/onenand/onenand_spl.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
+ *
+ * Based on code:
+ *	Copyright (C) 2005-2009 Samsung Electronics
+ *	Kyungmin Park <kyungmin.park@samsung.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 <asm/io.h>
+#include <linux/mtd/onenand_regs.h>
+#include <onenand_uboot.h>
+
+inline uint16_t onenand_readw(uint32_t addr)
+{
+	return readw(CONFIG_SYS_ONENAND_BASE + addr);
+}
+
+inline void onenand_writew(uint16_t value, uint32_t addr)
+{
+	writew(value, CONFIG_SYS_ONENAND_BASE + addr);
+}
+
+
+#define	onenand_block_address(block)		(block)
+#define	onenand_sector_address(page)		(page << 2)
+#define	onenand_buffer_address()		((1 << 3) << 8)
+#define	onenand_bufferram_address(block)	(0)
+
+void spl_onenand_get_geometry(struct spl_onenand_data *data)
+{
+	uint32_t tmp;
+	uint32_t dev_id, density;
+
+	/* Default geometry -- 2048b page, 128k erase block. */
+	data->pagesize = 2048;
+	data->erasesize = 0x20000;
+
+	tmp = onenand_readw(ONENAND_REG_TECHNOLOGY);
+	if (tmp)
+		goto dev_4k;
+
+	dev_id = onenand_readw(ONENAND_REG_DEVICE_ID);
+	density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT;
+	density &= ONENAND_DEVICE_DENSITY_MASK;
+
+	if (density < ONENAND_DEVICE_DENSITY_4Gb)
+		return;
+
+	if (dev_id & ONENAND_DEVICE_IS_DDP)
+		return;
+
+	/* 4k device geometry -- 4096b page, 256k erase block. */
+dev_4k:
+	data->pagesize = 4096;
+	data->erasesize = 0x40000;
+}
+
+int spl_onenand_read_page(uint32_t block, uint32_t page,
+				uint8_t *buf, int pagesize)
+{
+	const uint32_t addr = CONFIG_SYS_ONENAND_BASE + ONENAND_DATARAM;
+	uint32_t offset;
+
+	onenand_writew(onenand_block_address(block),
+			ONENAND_REG_START_ADDRESS1);
+
+	onenand_writew(onenand_bufferram_address(block),
+			ONENAND_REG_START_ADDRESS2);
+
+	onenand_writew(onenand_sector_address(page),
+			ONENAND_REG_START_ADDRESS8);
+
+	onenand_writew(onenand_buffer_address(),
+			ONENAND_REG_START_BUFFER);
+
+	onenand_writew(ONENAND_INT_CLEAR, ONENAND_REG_INTERRUPT);
+
+	onenand_writew(ONENAND_CMD_READ, ONENAND_REG_COMMAND);
+
+	while (!(onenand_readw(ONENAND_REG_INTERRUPT) & ONENAND_INT_READ))
+		continue;
+
+	/* Check for invalid block mark */
+	if (page < 2 && (onenand_readw(ONENAND_SPARERAM) != 0xffff))
+		return 1;
+
+	for (offset = 0; offset < pagesize; offset++)
+		buf[offset] = readb(addr + offset);
+
+	return 0;
+}
+
+int spl_onenand_read_block(uint32_t block, uint8_t *buf, uint32_t *read)
+{
+	struct spl_onenand_data data;
+	uint32_t page;
+	int ret;
+
+	spl_onenand_get_geometry(&data);
+
+	for (page = 0; page < ONENAND_PAGES_PER_BLOCK; page++) {
+		ret = spl_onenand_read_page(block, page, buf, data.pagesize);
+		if (ret)
+			return ret;
+		buf += data.pagesize;
+	}
+
+	*read = ((block * ONENAND_PAGES_PER_BLOCK) + page) * data.pagesize;
+
+	return 0;
+}
diff --git a/include/onenand_uboot.h b/include/onenand_uboot.h
index 92279d5..66828ce 100644
--- a/include/onenand_uboot.h
+++ b/include/onenand_uboot.h
@@ -16,6 +16,8 @@
 
 #include <linux/types.h>
 
+#ifndef	CONFIG_SPL_BUILD
+
 /* Forward declarations */
 struct mtd_info;
 struct mtd_oob_ops;
@@ -52,4 +54,20 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,
 extern void s3c64xx_onenand_init(struct mtd_info *);
 extern void s3c64xx_set_width_regs(struct onenand_chip *);
 
+#else
+
+#define ONENAND_PAGES_PER_BLOCK		64
+
+struct spl_onenand_data {
+	uint32_t	pagesize;
+	uint32_t	erasesize;
+};
+
+void spl_onenand_get_geometry(struct spl_onenand_data *data);
+int spl_onenand_read_page(uint32_t block, uint32_t page,
+				uint8_t *buf, int pagesize);
+int spl_onenand_read_block(uint32_t block, uint8_t *buf, uint32_t *read);
+
+#endif
+
 #endif /* __UBOOT_ONENAND_H */
diff --git a/spl/Makefile b/spl/Makefile
index ed1f770..d4184ac 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -54,6 +54,7 @@ LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o
 LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
 LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o
 LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
+LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
 LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o
 
 ifeq ($(SOC),omap3)
-- 
1.7.6.3

^ permalink raw reply related

* [U-Boot] [PATCH 2/4] PXA: Rework start.S to be closer to other ARMs
From: Marek Vasut @ 2011-10-31 13:23 UTC (permalink / raw)
  To: u-boot
In-Reply-To: <1320067393-18822-1-git-send-email-marek.vasut@gmail.com>

The start.S on PXA was very obscure. This reworks it back to be close to arm1136
start.S and others.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
---
 arch/arm/cpu/pxa/cpu.c   |   16 ++
 arch/arm/cpu/pxa/start.S |  382 ++++++++++++++++-----------------------------
 2 files changed, 152 insertions(+), 246 deletions(-)

diff --git a/arch/arm/cpu/pxa/cpu.c b/arch/arm/cpu/pxa/cpu.c
index df351c7..c48b2ef 100644
--- a/arch/arm/cpu/pxa/cpu.c
+++ b/arch/arm/cpu/pxa/cpu.c
@@ -328,3 +328,19 @@ void i2c_clk_enable(void)
 	writel(readl(CKEN) | CKEN14_I2C, CKEN);
 #endif
 }
+
+void reset_cpu(ulong ignored) __attribute__((noreturn));
+
+void reset_cpu(ulong ignored)
+{
+	uint32_t tmp;
+
+	setbits_le32(OWER, OWER_WME);
+
+	tmp = readl(OSCR);
+	tmp += 0x1000;
+	writel(tmp, OSMR3);
+
+	for (;;)
+		;
+}
diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S
index 6191a73..46f7ac0 100644
--- a/arch/arm/cpu/pxa/start.S
+++ b/arch/arm/cpu/pxa/start.S
@@ -1,14 +1,20 @@
 /*
- *  armboot - Startup Code for XScale
+ *  armboot - Startup Code for XScale CPU-core
  *
  *  Copyright (C) 1998	Dan Malek <dmalek@jlc.net>
  *  Copyright (C) 1999	Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
  *  Copyright (C) 2000	Wolfgang Denk <wd@denx.de>
  *  Copyright (C) 2001	Alex Zuepke <azu@sysgo.de>
+ *  Copyright (C) 2001	Marius Groger <mag@sysgo.de>
+ *  Copyright (C) 2002	Alex Zupke <azu@sysgo.de>
+ *  Copyright (C) 2002	Gary Jennejohn <garyj@denx.de>
  *  Copyright (C) 2002	Kyle Harris <kharris@nexus-tech.net>
- *  Copyright (C) 2003	Robert Schwebel <r.schwebel@pengutronix.de>
  *  Copyright (C) 2003	Kai-Uwe Bloem <kai-uwe.bloem@auerswald.de>
- *  Copyright (c) 2010	Marek Vasut <marek.vasut@gmail.com>
+ *  Copyright (C) 2003	Kshitij <kshitij@ti.com>
+ *  Copyright (C) 2003	Richard Woodruff <r-woodruff2@ti.com>
+ *  Copyright (C) 2003	Robert Schwebel <r.schwebel@pengutronix.de>
+ *  Copyright (C) 2004	Texas Instruments <r-woodruff2@ti.com>
+ *  Copyright (C) 2010	Marek Vasut <marek.vasut@gmail.com>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -32,15 +38,6 @@
 #include <asm-offsets.h>
 #include <config.h>
 #include <version.h>
-#include <asm/arch/pxa-regs.h>
-
-/* takes care the CP15 update has taken place */
-.macro CPWAIT reg
-mrc  p15,0,\reg,c2,c0,0
-mov  \reg,\reg
-sub  pc,pc,#4
-.endm
-
 .globl _start
 _start: b	reset
 #ifdef CONFIG_SPL_BUILD
@@ -77,26 +74,38 @@ _data_abort:		.word data_abort
 _not_used:		.word not_used
 _irq:			.word irq
 _fiq:			.word fiq
+_pad:			.word 0x12345678 /* now 16*4=64 */
 #endif	/* CONFIG_SPL_BUILD */
+.global _end_vect
+_end_vect:
 
 	.balignl 16,0xdeadbeef
-
-
 /*
+ *************************************************************************
+ *
  * Startup Code (reset vector)
  *
- * do important init only if we don't start from RAM!
- * - relocate armboot to RAM
- * - setup stack
- * - jump to second stage
+ * do important init only if we don't start from memory!
+ * setup Memory and board specific bits prior to relocation.
+ * relocate armboot to ram
+ * setup stack
+ *
+ *************************************************************************
  */
 
 .globl _TEXT_BASE
 _TEXT_BASE:
+#ifdef	CONFIG_SPL_BUILD
+	.word	CONFIG_SPL_TEXT_BASE
+#else
 	.word	CONFIG_SYS_TEXT_BASE
+#endif
 
 /*
  * These are defined in the board-specific linker script.
+ * Subtracting _start from them lets the linker put their
+ * relative position in the executable instead of leaving
+ * them null.
  */
 .globl _bss_start_ofs
 _bss_start_ofs:
@@ -120,9 +129,8 @@ IRQ_STACK_START:
 .globl FIQ_STACK_START
 FIQ_STACK_START:
 	.word 0x0badc0de
-#endif /* CONFIG_USE_IRQ */
+#endif
 
-#ifndef CONFIG_SPL_BUILD
 /* IRQ stack memory (calculated at run-time) + 8 bytes */
 .globl IRQ_STACK_START_IN
 IRQ_STACK_START_IN:
@@ -141,91 +149,15 @@ reset:
 	orr	r0,r0,#0xd3
 	msr	cpsr,r0
 
-	/*
-	 * Enable MMU to use DCache as DRAM
-	 */
-	/* Domain access -- enable for all CPs */
-	ldr	r0, =0x0000ffff
-	mcr	p15, 0, r0, c3, c0, 0
-
-	/* Point TTBR to MMU table */
-	ldr	r0, =mmu_table
-	adr	r2, _start
-	orr	r0, r2
-	mcr	p15, 0, r0, c2, c0, 0
-
-/* !!! Hereby, check if the code is running from SRAM !!! */
-/* If the code is running from SRAM, alias SRAM to 0x0 to simulate NOR. The code
- * is linked to 0x0 too, so this makes things easier. */
-	cmp	r2, #0x5c000000
-
-	ldreq	r1, [r0]
-	orreq	r1, r2
-	streq	r1, [r0]
-
-	/* Kick in MMU, ICache, DCache, BTB */
-	mrc	p15, 0, r0, c1, c0, 0
-	bic	r0, #0x1b00
-	bic	r0, #0x0087
-	orr	r0, #0x1800
-	orr	r0, #0x0005
-	mcr	p15, 0, r0, c1, c0, 0
-	CPWAIT	r0
-
-	/* Unlock Icache, Dcache */
-	mcr	p15, 0, r0, c9, c1, 1
-	mcr	p15, 0, r0, c9, c2, 1
-
-	/* Flush Icache, Dcache, BTB */
-	mcr	p15, 0, r0, c7, c7, 0
-
-	/* Unlock I-TLB, D-TLB */
-	mcr	p15, 0, r0, c10, c4, 1
-	mcr	p15, 0, r0, c10, c8, 1
-
-	/* Flush TLB */
-	mcr	p15, 0, r0, c8, c7, 0
-	/* Allocate 4096 bytes of Dcache as RAM */
-
-	/* Drain pending loads and stores */
-	mcr	p15, 0, r0, c7, c10, 4
-
-	mov	r4, #0x00
-	mov	r5, #0x00
-	mov	r2, #0x01
-	mcr	p15, 0, r0, c9, c2, 0
-	CPWAIT	r0
-
-	/* 128 lines reserved (128 x 32bytes = 4096 bytes total) */
-	mov	r0, #128
-	mov	r1, #0xa0000000
-alloc:
-	mcr	p15, 0, r1, c7, c2, 5
-	/* Drain pending loads and stores */
-	mcr	p15, 0, r0, c7, c10, 4
-	strd	r4, [r1], #8
-	strd	r4, [r1], #8
-	strd	r4, [r1], #8
-	strd	r4, [r1], #8
-	subs	r0, #0x01
-	bne	alloc
-	/* Drain pending loads and stores */
-	mcr	p15, 0, r0, c7, c10, 4
-	mov	r2, #0x00
-	mcr	p15, 0, r2, c9, c2, 0
-	CPWAIT	r0
-
-	/* Jump to 0x0 ( + offset) if running from SRAM */
-	adr	r0, zerojmp
-	bic	r0, #0x5c000000
-	mov	pc, r0
-zerojmp:
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+	bl  cpu_init_crit
+#endif
 
 /* Set stackpointer in internal RAM to call board_init_f */
 call_board_init_f:
 	ldr	sp, =(CONFIG_SYS_INIT_SP_ADDR)
 	bic	sp, sp, #7 /* 8-byte alignment for ABI compliance */
-	ldr	r0,=0x00000000
+	ldr	r0, =0x00000000
 	bl	board_init_f
 
 /*------------------------------------------------------------------------------*/
@@ -254,13 +186,11 @@ stack_setup:
 	ldr	r3, _bss_start_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
-	stmfd sp!, {r0-r12}
 copy_loop:
-	ldmia	r0!, {r3-r5, r7-r11}	/* copy from source address [r0]    */
-	stmia	r1!, {r3-r5, r7-r11}	/* copy to   target address [r1]    */
+	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
+	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */
 	cmp	r0, r2			/* until source end address [r2]    */
 	blo	copy_loop
-	ldmfd sp!, {r0-r12}
 
 #ifndef CONFIG_SPL_BUILD
 	/*
@@ -275,13 +205,13 @@ copy_loop:
 	ldr	r3, _rel_dyn_end_ofs	/* r3 <- rel dyn end ofs */
 	add	r3, r3, r0		/* r3 <- rel dyn end in FLASH */
 fixloop:
-	ldr	r0, [r2]	/* r0 <- location to fix up, IN FLASH! */
-	add	r0, r9		/* r0 <- location to fix up in RAM */
+	ldr	r0, [r2]		/* r0 <- location to fix up, IN FLASH! */
+	add	r0, r0, r9		/* r0 <- location to fix up in RAM */
 	ldr	r1, [r2, #4]
 	and	r7, r1, #0xff
-	cmp	r7, #23		/* relative fixup? */
+	cmp	r7, #23			/* relative fixup? */
 	beq	fixrel
-	cmp	r7, #2		/* absolute fixup? */
+	cmp	r7, #2			/* absolute fixup? */
 	beq	fixabs
 	/* ignore unknown type of fixup */
 	b	fixnext
@@ -298,10 +228,10 @@ fixrel:
 	add	r1, r1, r9
 fixnext:
 	str	r1, [r0]
-	add	r2, r2, #8	/* each rel.dyn entry is 8 bytes */
+	add	r2, r2, #8		/* each rel.dyn entry is 8 bytes */
 	cmp	r2, r3
 	blo	fixloop
-#endif	/* #ifndef CONFIG_SPL_BUILD */
+#endif
 
 clear_bss:
 #ifndef CONFIG_SPL_BUILD
@@ -322,15 +252,16 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
  * We are done. Do not return, instead branch to second part of board
  * initialization, now running from RAM.
  */
-#ifdef CONFIG_ONENAND_IPL
-	ldr     r0, _start_oneboot_ofs
+#ifdef CONFIG_ONENAND_SPL
+	ldr     r0, _onenand_boot_ofs
 	mov	pc, r0
 
-_start_oneboot_ofs
-	: .word start_oneboot
+_onenand_boot_ofs:
+	.word onenand_boot
 #else
+jump_2_ram:
 	ldr	r0, _board_init_r_ofs
-	adr	r1, _start
+	ldr     r1, _TEXT_BASE
 	add	lr, r0, r1
 	add	lr, lr, r9
 	/* setup parameters for board_init_r */
@@ -341,7 +272,7 @@ _start_oneboot_ofs
 
 _board_init_r_ofs:
 	.word board_init_r - _start
-#endif	/* CONFIG_ONENAND_IPL */
+#endif
 
 _rel_dyn_start_ofs:
 	.word __rel_dyn_start - _start
@@ -350,42 +281,49 @@ _rel_dyn_end_ofs:
 _dynsym_start_ofs:
 	.word __dynsym_start - _start
 
-#else /* CONFIG_SPL_BUILD */
-
-/****************************************************************************/
-/*									    */
-/* the actual reset code for OneNAND IPL				    */
-/*									    */
-/****************************************************************************/
-
-#ifndef	CONFIG_PXA27X
-#error OneNAND IPL is not supported on PXA25x and 26x due to lack of SRAM
-#endif
-
-reset:
-	/* Set CPU to SVC32 mode */
-	mrs	r0,cpsr
-	bic	r0,r0,#0x1f
-	orr	r0,r0,#0x13
-	msr	cpsr,r0
-
-	/* Point stack@the end of SRAM and leave 32 words for abort-stack */
-	ldr	sp, =0x5c03ff80
+/*
+ *************************************************************************
+ *
+ * CPU_init_critical registers
+ *
+ * setup important registers
+ * setup memory timing
+ *
+ *************************************************************************
+ */
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+cpu_init_crit:
+	/*
+	 * flush v4 I/D caches
+	 */
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c7, 0	/* Invalidate I+D+BTB caches */
+	mcr	p15, 0, r0, c8, c7, 0	/* Invalidate Unified TLB */
 
-	/* Start OneNAND IPL */
-	ldr	pc, =start_oneboot
+	/*
+	 * disable MMU stuff and caches
+	 */
+	mrc	p15, 0, r0, c1, c0, 0
+	bic	r0, r0, #0x00002300	@ clear bits 13, 9:8 (--V- --RS)
+	bic	r0, r0, #0x00000087	@ clear bits 7, 2:0 (B--- -CAM)
+	orr	r0, r0, #0x00000002	@ set bit 2 (A) Align
+	orr	r0, r0, #0x00001000	@ set bit 12 (I) I-Cache
+	mcr	p15, 0, r0, c1, c0, 0
 
-#endif /* CONFIG_SPL_BUILD */
+	mov	pc, lr		/* back to my caller */
+#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
 
 #ifndef CONFIG_SPL_BUILD
-/****************************************************************************/
-/*									    */
-/* Interrupt handling							    */
-/*									    */
-/****************************************************************************/
-
-/* IRQ stack frame							    */
-
+/*
+ *************************************************************************
+ *
+ * Interrupt handling
+ *
+ *************************************************************************
+ */
+@
+@ IRQ stack frame.
+@
 #define S_FRAME_SIZE	72
 
 #define S_OLD_R0	68
@@ -409,37 +347,36 @@ reset:
 #define S_R0		0
 
 #define MODE_SVC 0x13
+#define I_BIT	 0x80
 
-	/* use bad_save_user_regs for abort/prefetch/undef/swi ...	    */
+/*
+ * use bad_save_user_regs for abort/prefetch/undef/swi ...
+ * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling
+ */
 
 	.macro	bad_save_user_regs
-	sub	sp, sp, #S_FRAME_SIZE
-	stmia	sp, {r0 - r12}			/* Calling r0-r12	    */
-	add	r8, sp, #S_PC
+	sub	sp, sp, #S_FRAME_SIZE		@ carve out a frame on current user stack
+	stmia	sp, {r0 - r12}			@ Save user registers (now in svc mode) r0-r12
 
-	ldr	r2, IRQ_STACK_START_IN
-	ldmia	r2, {r2 - r4}			/* get pc, cpsr, old_r0	    */
-	add	r0, sp, #S_FRAME_SIZE		/* restore sp_SVC	    */
+	ldr	r2, IRQ_STACK_START_IN		@ set base 2 words into abort stack
+	ldmia	r2, {r2 - r3}			@ get values for "aborted" pc and cpsr (into parm regs)
+	add	r0, sp, #S_FRAME_SIZE		@ grab pointer to old stack
 
 	add	r5, sp, #S_SP
 	mov	r1, lr
-	stmia	r5, {r0 - r4}			/* save sp_SVC, lr_SVC, pc, cpsr, old_r */
-	mov	r0, sp
+	stmia	r5, {r0 - r3}			@ save sp_SVC, lr_SVC, pc, cpsr
+	mov	r0, sp				@ save current stack into r0 (param register)
 	.endm
 
-
-	/* use irq_save_user_regs / irq_restore_user_regs for		     */
-	/* IRQ/FIQ handling						     */
-
 	.macro	irq_save_user_regs
 	sub	sp, sp, #S_FRAME_SIZE
-	stmia	sp, {r0 - r12}			/* Calling r0-r12	     */
-	add	r8, sp, #S_PC
-	stmdb	r8, {sp, lr}^			/* Calling SP, LR	     */
-	str	lr, [r8, #0]			/* Save calling PC	     */
+	stmia	sp, {r0 - r12}			@ Calling r0-r12
+	add	r8, sp, #S_PC			@ !!!! R8 NEEDS to be saved !!!! a reserved stack spot would be good.
+	stmdb	r8, {sp, lr}^			@ Calling SP, LR
+	str	lr, [r8, #0]			@ Save calling PC
 	mrs	r6, spsr
-	str	r6, [r8, #4]			/* Save CPSR		     */
-	str	r0, [r8, #8]			/* Save OLD_R0		     */
+	str	r6, [r8, #4]			@ Save CPSR
+	str	r0, [r8, #8]			@ Save OLD_R0
 	mov	r0, sp
 	.endm
 
@@ -452,16 +389,28 @@ reset:
 	.endm
 
 	.macro get_bad_stack
-	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack
+	ldr	r13, IRQ_STACK_START_IN		@ setup our mode stack (enter in banked mode)
 
-	str	lr, [r13]			@ save caller lr / spsr
-	mrs	lr, spsr
-	str	lr, [r13, #4]
+	str	lr, [r13]			@ save caller lr in position 0 of saved stack
+	mrs	lr, spsr			@ get the spsr
+	str	lr, [r13, #4]			@ save spsr in position 1 of saved stack
 
 	mov	r13, #MODE_SVC			@ prepare SVC-Mode
-	msr	spsr_c, r13
-	mov	lr, pc
-	movs	pc, lr
+	@ msr	spsr_c, r13
+	msr	spsr, r13			@ switch modes, make sure moves will execute
+	mov	lr, pc				@ capture return pc
+	movs	pc, lr				@ jump to next instruction & switch modes.
+	.endm
+
+	.macro get_bad_stack_swi
+	sub	r13, r13, #4			@ space on current stack for scratch reg.
+	str	r0, [r13]			@ save R0's value.
+	ldr	r0, IRQ_STACK_START_IN		@ get data regions start
+	str	lr, [r0]			@ save caller lr in position 0 of saved stack
+	mrs	r0, spsr			@ get the spsr
+	str	lr, [r0, #4]			@ save spsr in position 1 of saved stack
+	ldr	r0, [r13]			@ restore r0
+	add	r13, r13, #4			@ pop stack entry
 	.endm
 
 	.macro get_irq_stack			@ setup IRQ stack
@@ -471,21 +420,17 @@ reset:
 	.macro get_fiq_stack			@ setup FIQ stack
 	ldr	sp, FIQ_STACK_START
 	.endm
-#endif	/* CONFIG_SPL_BUILD
-
-
-/****************************************************************************/
-/*									    */
-/* exception handlers							    */
-/*									    */
-/****************************************************************************/
+#endif	/* CONFIG_SPL_BUILD */
 
+/*
+ * exception handlers
+ */
 #ifdef CONFIG_SPL_BUILD
 	.align	5
 do_hang:
-	ldr	sp, _TEXT_BASE			/* use 32 words abort stack */
+	ldr	sp, _TEXT_BASE			/* use 32 words about stack */
 	bl	hang				/* hang and never return */
-#else
+#else	/* !CONFIG_SPL_BUILD */
 	.align	5
 undefined_instruction:
 	get_bad_stack
@@ -494,7 +439,7 @@ undefined_instruction:
 
 	.align	5
 software_interrupt:
-	get_bad_stack
+	get_bad_stack_swi
 	bad_save_user_regs
 	bl	do_software_interrupt
 
@@ -528,11 +473,12 @@ irq:
 	.align	5
 fiq:
 	get_fiq_stack
-	irq_save_user_regs		/* someone ought to write a more    */
-	bl	do_fiq			/* effiction fiq_save_user_regs	    */
+	/* someone ought to write a more effiction fiq_save_user_regs */
+	irq_save_user_regs
+	bl	do_fiq
 	irq_restore_user_regs
 
-#else /* !CONFIG_USE_IRQ */
+#else
 
 	.align	5
 irq:
@@ -545,63 +491,7 @@ fiq:
 	get_bad_stack
 	bad_save_user_regs
 	bl	do_fiq
-#endif	/* CONFIG_SPL_BUILD */
-#endif /* CONFIG_USE_IRQ */
-
-/****************************************************************************/
-/*									    */
-/* Reset function: the PXA250 doesn't have a reset function, so we have to  */
-/* perform a watchdog timeout for a soft reset.				    */
-/*									    */
-/****************************************************************************/
-/* Operating System Timer */
-.align	5
-.globl reset_cpu
-
-	/* FIXME: this code is PXA250 specific. How is this handled on	    */
-	/*	  other XScale processors?				    */
-
-reset_cpu:
-
-	/* We set OWE:WME (watchdog enable) and wait until timeout happens  */
 
-	ldr	r0, =OWER
-	ldr	r1, [r0]
-	orr	r1, r1, #0x0001			/* bit0: WME		    */
-	str	r1, [r0]
-
-	/* OS timer does only wrap every 1165 seconds, so we have to set    */
-	/* the match register as well.					    */
-
-	ldr	r0, =OSCR
-	ldr	r1, [r0]			/* read OS timer	    */
-	add	r1, r1, #0x800			/* let OSMR3 match after    */
-	add	r1, r1, #0x800			/* 4096*(1/3.6864MHz)=1ms   */
-	ldr	r0, =OSMR3
-	str	r1, [r0]
-
-reset_endless:
-
-	b	reset_endless
-
-#ifndef CONFIG_SPL_BUILD
-.section .mmudata, "a"
-	.align	14
-	.globl	mmu_table
-mmu_table:
-	/* 0x00000000 - 0xa0000000 : 1:1, uncached mapping */
-	.set	__base, 0
-	.rept	0xa00
-	.word	(__base << 20) | 0xc12
-	.set	__base, __base + 1
-	.endr
-
-	/* 0xa0000000 - 0xa0100000 : 1:1, cached mapping */
-	.word	(0xa00 << 20) | 0x1c1e
-
-	.set	__base, 0xa01
-	.rept	0x1000 - 0xa01
-	.word	(__base << 20) | 0xc12
-	.set	__base, __base + 1
-	.endr
+#endif
+	.align 5
 #endif	/* CONFIG_SPL_BUILD */
-- 
1.7.6.3

^ permalink raw reply related

* [U-Boot] [PATCH 1/4] PXA: Drop Voipac PXA270 OneNAND IPL
From: Marek Vasut @ 2011-10-31 13:23 UTC (permalink / raw)
  To: u-boot
In-Reply-To: <1320067393-18822-1-git-send-email-marek.vasut@gmail.com>

This OneNAND IPL will be replaced by OneNAND SPL.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
---
 onenand_ipl/board/vpac270/Makefile           |   79 --------------------------
 onenand_ipl/board/vpac270/config.mk          |    1 -
 onenand_ipl/board/vpac270/u-boot.onenand.lds |   51 -----------------
 onenand_ipl/board/vpac270/vpac270.c          |   42 --------------
 4 files changed, 0 insertions(+), 173 deletions(-)
 delete mode 100644 onenand_ipl/board/vpac270/Makefile
 delete mode 100644 onenand_ipl/board/vpac270/config.mk
 delete mode 100644 onenand_ipl/board/vpac270/u-boot.onenand.lds
 delete mode 100644 onenand_ipl/board/vpac270/vpac270.c

diff --git a/onenand_ipl/board/vpac270/Makefile b/onenand_ipl/board/vpac270/Makefile
deleted file mode 100644
index f850ddd..0000000
--- a/onenand_ipl/board/vpac270/Makefile
+++ /dev/null
@@ -1,79 +0,0 @@
-
-include $(TOPDIR)/config.mk
-include $(TOPDIR)/board/$(BOARDDIR)/config.mk
-
-LDSCRIPT= $(TOPDIR)/onenand_ipl/board/$(BOARDDIR)/u-boot.onenand.lds
-LDFLAGS	= -Bstatic -T $(onenandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS)
-AFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_ONENAND_IPL
-CFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_ONENAND_IPL
-OBJCFLAGS += --gap-fill=0x00
-
-SOBJS	+= start.o
-COBJS	:= vpac270.o
-COBJS	+= onenand_read.o
-COBJS	+= onenand_boot.o
-
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
-__OBJS	:= $(SOBJS) $(COBJS)
-LNDIR	:= $(OBJTREE)/onenand_ipl/board/$(BOARDDIR)
-
-onenandobj	:= $(OBJTREE)/onenand_ipl/
-
-ALL	= $(onenandobj)onenand-ipl $(onenandobj)onenand-ipl.bin $(onenandobj)onenand-ipl-2k.bin
-
-all:	$(obj).depend $(ALL)
-
-$(onenandobj)onenand-ipl-2k.bin:	$(onenandobj)onenand-ipl
-	$(OBJCOPY) ${OBJCFLAGS} --pad-to=0x0800 -O binary $< $@
-
-$(onenandobj)onenand-ipl.bin:	$(onenandobj)onenand-ipl
-	$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
-
-$(onenandobj)onenand-ipl:	$(OBJS) $(onenandobj)u-boot.lds
-	cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
-		-Map $@.map -o $@
-
-$(onenandobj)u-boot.lds:	$(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
-
-# create symbolic links from common files
-
-# from cpu directory
-$(obj)start.S:
-	@rm -f $@
-	ln -s $(SRCTREE)/$(CPUDIR)/start.S $@
-
-# from onenand_ipl directory
-$(obj)onenand_ipl.h:
-	@rm -f $@
-	ln -s $(SRCTREE)/onenand_ipl/onenand_ipl.h $@
-
-$(obj)onenand_boot.c:	$(obj)onenand_ipl.h
-	@rm -f $@
-	ln -s $(SRCTREE)/onenand_ipl/onenand_boot.c $@
-
-$(obj)onenand_read.c:	$(obj)onenand_ipl.h
-	@rm -f $@
-	ln -s $(SRCTREE)/onenand_ipl/onenand_read.c $@
-
-ifneq ($(OBJTREE), $(SRCTREE))
-$(obj)vpac270.c:
-	@rm -f $@
-	ln -s $(SRCTREE)/onenand_ipl/board/$(BOARDDIR)/vpac270.c $@
-endif
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)$.c
-	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/onenand_ipl/board/vpac270/config.mk b/onenand_ipl/board/vpac270/config.mk
deleted file mode 100644
index 752836d..0000000
--- a/onenand_ipl/board/vpac270/config.mk
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_SYS_TEXT_BASE = 0x5c03fc00
diff --git a/onenand_ipl/board/vpac270/u-boot.onenand.lds b/onenand_ipl/board/vpac270/u-boot.onenand.lds
deleted file mode 100644
index b5b2646..0000000
--- a/onenand_ipl/board/vpac270/u-boot.onenand.lds
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
- *
- * 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
- */
-
-OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
-OUTPUT_ARCH(arm)
-ENTRY(_start)
-SECTIONS
-{
-	. = 0x00000000;
-
-	. = ALIGN(4);
-	.text      :
-	{
-	  start.o	(.text)
-	  *(.text)
-	}
-
-	. = ALIGN(4);
-	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
-
-	. = ALIGN(4);
-	.data : { *(.data) }
-
-	. = ALIGN(4);
-	.got : { *(.got) }
-
-	. = ALIGN(4);
-	__bss_start = .;
-	.bss : { *(.bss) . = ALIGN(4); }
-	__bss_end__ = .;
-}
diff --git a/onenand_ipl/board/vpac270/vpac270.c b/onenand_ipl/board/vpac270/vpac270.c
deleted file mode 100644
index a1eb331..0000000
--- a/onenand_ipl/board/vpac270/vpac270.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * (C) Copyright 2004
- * Robert Whaley, Applied Data Systems, Inc. rwhaley at applieddata.net
- *
- * (C) Copyright 2002
- * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
- *
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * 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 <asm/arch/hardware.h>
-
-int board_init (void)
-{
-	return 0;
-}
-
-int s_init(int skip)
-{
-	return 0;
-}
-- 
1.7.6.3

^ permalink raw reply related

* [U-Boot] [PATCH 0/4] Voipac PXA270 OneNAND SPL
From: Marek Vasut @ 2011-10-31 13:23 UTC (permalink / raw)
  To: u-boot

Convert OneNAND IPL to SPL framework and make Voipac PXA270 board use it.

This series triggers some checkpatch warnings:
* Warnings in start.S due to length of line. Since I reused the start.S from
  other CPU (arm1136), I'd rather investigate if it'd be possible to create one
  common start.S for armv5?
* Warnings due to used externs. pxa_dram_init() will be cleaned up in a
  subsequent series in all boards.

Marek Vasut (4):
  PXA: Drop Voipac PXA270 OneNAND IPL
  PXA: Rework start.S to be closer to other ARMs
  OneNAND: Add simple OneNAND SPL
  PXA: Adapt Voipac PXA270 to OneNAND SPL

 arch/arm/cpu/pxa/cpu.c                       |   16 +
 arch/arm/cpu/pxa/start.S                     |  382 +++++++++-----------------
 board/vpac270/Makefile                       |    6 +
 board/vpac270/onenand.c                      |  136 +++++++++
 board/vpac270/vpac270.c                      |    2 +
 drivers/mtd/onenand/Makefile                 |    4 +
 drivers/mtd/onenand/onenand_spl.c            |  130 +++++++++
 include/configs/vpac270.h                    |   25 ++-
 include/onenand_uboot.h                      |   18 ++
 onenand_ipl/board/vpac270/Makefile           |   79 ------
 onenand_ipl/board/vpac270/config.mk          |    1 -
 onenand_ipl/board/vpac270/u-boot.onenand.lds |   51 ----
 onenand_ipl/board/vpac270/vpac270.c          |   42 ---
 spl/Makefile                                 |    1 +
 14 files changed, 469 insertions(+), 424 deletions(-)
 create mode 100644 board/vpac270/onenand.c
 create mode 100644 drivers/mtd/onenand/onenand_spl.c
 delete mode 100644 onenand_ipl/board/vpac270/Makefile
 delete mode 100644 onenand_ipl/board/vpac270/config.mk
 delete mode 100644 onenand_ipl/board/vpac270/u-boot.onenand.lds
 delete mode 100644 onenand_ipl/board/vpac270/vpac270.c

Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>

-- 
1.7.6.3

^ permalink raw reply

* Re: [GIT PULL] Queue free fix (was Re: [PATCH] block: Free queue resources at blk_release_queue())
From: Mike Snitzer @ 2011-10-31 13:21 UTC (permalink / raw)
  To: James Bottomley
  Cc: Heiko Carstens, Jun'ichi Nomura, Steffen Maier,
	linux-scsi@vger.kernel.org, Jens Axboe, Hannes Reinecke,
	Linux Kernel, Alan Stern, Thadeu Lima de Souza Cascardo,
	Taraka R. Bodireddy, Seshagiri N. Ippili,
	Manvanthara B. Puttashankar, Jeff Moyer, Shaohua Li, gmuelas
In-Reply-To: <1320057746.2964.1.camel@dabdike>

On Mon, Oct 31 2011 at  6:42am -0400,
James Bottomley <James.Bottomley@HansenPartnership.com> wrote:

> On Mon, 2011-10-31 at 11:05 +0100, Heiko Carstens wrote:
> > On Tue, Oct 18, 2011 at 11:29:40AM -0500, James Bottomley wrote:
> > > On Tue, 2011-10-18 at 17:45 +0200, Heiko Carstens wrote:
> > > > On Tue, Oct 18, 2011 at 10:31:20PM +0900, Jun'ichi Nomura wrote:
> > > > > On 10/17/11 23:06, James Bottomley wrote:
> > > > > > On Mon, 2011-10-17 at 17:46 +0900, Jun'ichi Nomura wrote:
> > > > > >> On 10/15/11 01:03, James Bottomley wrote:
> > > > > >>> On Thu, 2011-10-13 at 15:09 +0200, Steffen Maier wrote:
> > > > > >>>> Initially, we encountered use-after-free bugs in
> > > > > >>>> scsi_print_command / scsi_dispatch_cmd
> > > > > >>>> http://marc.info/?l=linux-scsi&m=130824013229933&w=2
> > > > > >>
> > > > > >> It is interesting that both this and the older report
> > > > > >> got oopsed in scsi_log_send(), while there are other
> > > > > >> dereferences of 'cmd' around scsi_dispatch_cmd().
> > > > > >> Are there any reason they are special? Just by accident?
> > > > > > 
> > > > > > Right, that's why it looks like the command area got freed rather than
> > > > > > the command pointer was bogus (6b is a poison free pattern).  Perhaps if
> > > > > > the reporter could pin down the failing source line, we'd know better
> > > > > > what was going on?
> > > > > 
> > > > > Yeah, that might be useful.
> > > > 
> > > > The struct scsi_cmnd that was passed to scsi_log_send() was already freed
> > > > (contents completely 6b6b6b...).
> > > > Since SLUB debugging was turned on we can see that it was freed from
> > > > __scsi_put_command(). Not too much of a surprise.
> > > 
> > > But it does tell us the put must be racing with dispatch, since
> > > dereferencing the command to find the device worked higher up in
> > > scsi_dispatch_cmd().
> > > 
> > > There is one way to invalidate the theory that we cloned something with
> > > an attached command, and that's to put 
> > > 
> > > BUG_ON(rq->special)
> > > 
> > > in blk_insert_cloned_request().  I think we're careful about clearing
> > > it, so it should work (perhaps a warn on just in case).
> > 
> > It _looks_ like we do not hit the BUG_ON() that. This time we get this instead:
> > 
> > [ 4024.937870] Unable to handle kernel pointer dereference at virtual kernel address 000003e004d41000
> > [ 4024.937886] Oops: 0011 [#1] PREEMPT SMP DEBUG_PAGEALLOC
> > [ 4024.937899] Modules linked in: dm_round_robin sunrpc ipv6 qeth_l2 binfmt_misc dm_multipath scsi_dh dm_mod qeth ccwgroup [las
> > t unloaded: scsi_wait_scan]
> > [ 4024.937925] CPU: 1 Not tainted 3.0.7-50.x.20111021-s390xdefault #1
> > [ 4024.937930] Process ksoftirqd/1 (pid: 1942, task: 0000000079c6c750, ksp: 0000000073adfc50)
> > [ 4024.937936] Krnl PSW : 0704000180000000 000003e00126263a (dm_softirq_done+0x72/0x140 [dm_mod])
> > [ 4024.937959]            R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:0 CC:0 PM:0 EA:3
> > [ 4024.937966] Krnl GPRS: 000000007b9156b0 000003e004d41100 000000000e14b600 000000000000006d
> > [ 4024.937971]            00000000715332b0 000000000c140ce8 000000000090d2ef 0000000000000005
> > [ 4024.937977]            0000000000000001 0000000000000101 000000000c140d00 0000000000000000
> > [ 4024.937983]            000003e001260000 000003e00126f098 0000000073adfd08 0000000073adfcb8
> > [ 4024.938001] Krnl Code: 000003e00126262a: f0a0000407f1        srp     4(11,%r0),2033,0
> > [ 4024.938009]            000003e001262630: e31050080004        lg      %r1,8(%r5)
> > [ 4024.938017]            000003e001262636: 58b05180            l       %r11,384(%r5)
> > [ 4024.938024]           >000003e00126263a: e31010080004        lg      %r1,8(%r1)
> > [ 4024.938031]            000003e001262640: e31010500004        lg      %r1,80(%r1)
> > [ 4024.938038]            000003e001262646: b9020011            ltgr    %r1,%r1
> > [ 4024.938045]            000003e00126264a: a784ffdf            brc     8,3e001262608
> > [ 4024.938053]            000003e00126264e: e32050080004        lg      %r2,8(%r5)
> > [ 4024.938060] Call Trace:
> > [ 4024.938063] ([<070000000040716c>] 0x70000000040716c)
> > [ 4024.938069]  [<000000000040d29c>] blk_done_softirq+0xd4/0xf0
> > [ 4024.938080]  [<00000000001587c2>] __do_softirq+0xda/0x398
> > [ 4024.938088]  [<0000000000158ba0>] run_ksoftirqd+0x120/0x23c
> > [ 4024.938095]  [<000000000017c2aa>] kthread+0xa6/0xb0
> > [ 4024.938102]  [<000000000061970e>] kernel_thread_starter+0x6/0xc
> > [ 4024.938112]  [<0000000000619708>] kernel_thread_starter+0x0/0xc
> > [ 4024.938118] INFO: lockdep is turned off.
> > [ 4024.938121] Last Breaking-Event-Address:
> > [ 4024.938124]  [<000003e001262600>] dm_softirq_done+0x38/0x140 [dm_mod]
> > [ 4024.938135]  
> > [ 4024.938139] Kernel panic - not syncing: Fatal exception in interrupt
> > [ 4024.938144] CPU: 1 Tainted: G      D     3.0.7-50.x.20111021-s390xdefault #1
> > [ 4024.938150] Process ksoftirqd/1 (pid: 1942, task: 0000000079c6c750, ksp: 0000000073adfc50)
> > [ 4024.938155] 0000000073adf958 0000000073adf8d8 0000000000000002 0000000000000000 
> > [ 4024.938164]        0000000073adf978 0000000073adf8f0 0000000073adf8f0 000000000061386a 
> > [ 4024.938174]        0000000000000000 0000000000000000 0000000000000005 0000000000100ec6 
> > [ 4024.938184]        000000000000000d 000000000000000c 0000000073adf940 0000000000000000 
> > [ 4024.938194]        0000000000000000 0000000000100a18 0000000073adf8d8 0000000073adf918 
> > [ 4024.938205] Call Trace:
> > [ 4024.938208] ([<0000000000100926>] show_trace+0xee/0x144)
> > [ 4024.938216]  [<0000000000613694>] panic+0xb0/0x234
> > [ 4024.938224]  [<0000000000100ec6>] die+0x15a/0x168
> > [ 4024.938230]  [<000000000011fb9e>] do_no_context+0xba/0xf8
> > [ 4024.938306]  [<000000000061c074>] do_dat_exception+0x378/0x3e4
> > [ 4024.938314]  [<0000000000619e02>] pgm_exit+0x0/0x4
> > [ 4024.938319]  [<000003e00126263a>] dm_softirq_done+0x72/0x140 [dm_mod]
> > [ 4024.938329] ([<070000000040716c>] 0x70000000040716c)
> > [ 4024.938334]  [<000000000040d29c>] blk_done_softirq+0xd4/0xf0
> > [ 4024.938341]  [<00000000001587c2>] __do_softirq+0xda/0x398
> > [ 4024.938347]  [<0000000000158ba0>] run_ksoftirqd+0x120/0x23c
> > [ 4024.938354]  [<000000000017c2aa>] kthread+0xa6/0xb0
> > [ 4024.938360]  [<000000000061970e>] kernel_thread_starter+0x6/0xc
> > [ 4024.938366]  [<0000000000619708>] kernel_thread_starter+0x0/0xc
> > [ 4024.938373] INFO: lockdep is turned off.
> > 
> > So we thought we might as well upgrade to 3.1 but immediately got a
> > 
> > kernel BUG at block/blk-flush.c:323!
> > 
> > which was handled here https://lkml.org/lkml/2011/10/4/105 and
> > here https://lkml.org/lkml/2011/10/12/408 .
> > 
> > But no patches for that one went upstream AFAICS.
> 
> Well, all I can say is "hm".  You put only a BUG_ON() in the code, which
> wasn't triggered, but now we get a completely different oops.  However,
> I think it does point to the dm barrier handling code.  Can you turn off
> barriers and see if all oopses go away?

There are two 3.1-stable fixes from Jeff Moyer that Jens staged for
Linus to pick up (but seems Jens hasn't sent his 3.2 pull to Linus yet):

http://git.kernel.dk/?p=linux-block.git;a=commit;h=8f02b3a09b1b7d2a4d24b8cd7008f2a441f19a14
http://git.kernel.dk/?p=linux-block.git;a=commit;h=f26d8f0562da76731cb049943a0e9d9fa81d946a

^ permalink raw reply

* [PATCH v2] kdump: Add udev events for memory online/offline
From: Michael Holzheu @ 2011-10-31 13:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Heiko Carstens, Kay Sievers, kexec, linux-kernel, Dave Hansen,
	Eric W. Biederman, schwidefsky, Vivek Goyal
In-Reply-To: <20111028154630.77c7b96c.akpm@linux-foundation.org>

On Fri, 2011-10-28 at 15:46 -0700, Andrew Morton wrote:
> On Thu, 27 Oct 2011 11:32:45 +0200

[snip]

> I think a safer place from which to send the uevent is
> memory_block_change_state() or even memory_block_action().  Because if
> either of those functions later gets new callers, those callers might
> forget to send the uevent?

Ok fine. I put the code into memory_block_change_state(). This also has
the advantage that we are serialized by "mem->state_mutex". Not sure if
we need that, but for CPU hotplug the udev events are also serialized
with a lock. See  "drivers/base/cpu.c" -> cpu_hotplug_driver_lock()

Do you think the following patch is acceptable?
---
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>

Currently no udev events for memory hotplug "online" and "offline" are
generated:

# udevadm monitor
# echo offline > /sys/devices/system/memory/memory4/state
==> No event

When kdump is loaded, kexec detects the current memory configuration and
stores it in the pre-allocated ELF core header. Therefore, for kdump it is
necessary to reload the kdump kernel with kexec when the memory
configuration changes (e.g. for online/offline hotplug memory).

In order to do this automatically, udev rules should be used. This kernel
patch adds udev events for "online" and "offline". Together with this kernel
patch, the following udev rules for online/offline have to be added to
"/etc/udev/rules.d/98-kexec.rules":

SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/etc/init.d/kdump restart"
SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/etc/init.d/kdump restart"

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
 drivers/base/memory.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -291,11 +291,22 @@ static int memory_block_change_state(str
 
 	ret = memory_block_action(mem->start_section_nr, to_state);
 
-	if (ret)
+	if (ret) {
 		mem->state = from_state_req;
-	else
-		mem->state = to_state;
+		goto out;
+	}
 
+	mem->state = to_state;
+	switch (mem->state) {
+	case MEM_OFFLINE:
+		kobject_uevent(&mem->sysdev.kobj, KOBJ_OFFLINE);
+		break;
+	case MEM_ONLINE:
+		kobject_uevent(&mem->sysdev.kobj, KOBJ_ONLINE);
+		break;
+	default:
+		break;
+	}
 out:
 	mutex_unlock(&mem->state_mutex);
 	return ret;



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply

* [PATCH v2] kdump: Add udev events for memory online/offline
From: Michael Holzheu @ 2011-10-31 13:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Heiko Carstens, Vivek Goyal, Eric W. Biederman, schwidefsky,
	kexec, linux-kernel, Kay Sievers, Dave Hansen
In-Reply-To: <20111028154630.77c7b96c.akpm@linux-foundation.org>

On Fri, 2011-10-28 at 15:46 -0700, Andrew Morton wrote:
> On Thu, 27 Oct 2011 11:32:45 +0200

[snip]

> I think a safer place from which to send the uevent is
> memory_block_change_state() or even memory_block_action().  Because if
> either of those functions later gets new callers, those callers might
> forget to send the uevent?

Ok fine. I put the code into memory_block_change_state(). This also has
the advantage that we are serialized by "mem->state_mutex". Not sure if
we need that, but for CPU hotplug the udev events are also serialized
with a lock. See  "drivers/base/cpu.c" -> cpu_hotplug_driver_lock()

Do you think the following patch is acceptable?
---
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>

Currently no udev events for memory hotplug "online" and "offline" are
generated:

# udevadm monitor
# echo offline > /sys/devices/system/memory/memory4/state
==> No event

When kdump is loaded, kexec detects the current memory configuration and
stores it in the pre-allocated ELF core header. Therefore, for kdump it is
necessary to reload the kdump kernel with kexec when the memory
configuration changes (e.g. for online/offline hotplug memory).

In order to do this automatically, udev rules should be used. This kernel
patch adds udev events for "online" and "offline". Together with this kernel
patch, the following udev rules for online/offline have to be added to
"/etc/udev/rules.d/98-kexec.rules":

SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/etc/init.d/kdump restart"
SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/etc/init.d/kdump restart"

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
 drivers/base/memory.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -291,11 +291,22 @@ static int memory_block_change_state(str
 
 	ret = memory_block_action(mem->start_section_nr, to_state);
 
-	if (ret)
+	if (ret) {
 		mem->state = from_state_req;
-	else
-		mem->state = to_state;
+		goto out;
+	}
 
+	mem->state = to_state;
+	switch (mem->state) {
+	case MEM_OFFLINE:
+		kobject_uevent(&mem->sysdev.kobj, KOBJ_OFFLINE);
+		break;
+	case MEM_ONLINE:
+		kobject_uevent(&mem->sysdev.kobj, KOBJ_ONLINE);
+		break;
+	default:
+		break;
+	}
 out:
 	mutex_unlock(&mem->state_mutex);
 	return ret;



^ permalink raw reply

* Re: NFS4ERR_STALE_CLIENTID loop
From: David Flynn @ 2011-10-31 13:21 UTC (permalink / raw)
  To: Chuck Lever; +Cc: David Flynn, Myklebust, Trond, J. Bruce Fields, linux-nfs
In-Reply-To: <6FEDF9D0-B059-4580-931C-7EBBD1F8C8EA@oracle.com>

* Chuck Lever (chuck.lever@oracle.com) wrote:
> David, what would help immensely is if you can find a reliable way of
> reproducing this.  So far we have been unable to find a reproducer.

While i've managed to have problems with individual machines, that seem
to fail at some random point of their own choosing, the most reliable
way to produce problem for us to have a number of nodes updating various
RRD files frequently.

Given that i haven't found a reliable and short method for reproducing
it either, if we were to re-run the known case and capture all network
traffic, would you be able to extract the relevant detail to generate a
simulation?

Regards,

..david

^ permalink raw reply

* [GIT PULL] arch/microblaze changes for 3.2
From: Michal Simek @ 2011-10-31 13:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML

Hi Linus,

please pull the following changes.

Thanks,
Michal

The following changes since commit e9308cfd5ab4ade3d81cf591c7599c3a05a21b04:
   Linus Torvalds (1):
         Merge branch 'gpio/merge' of git://git.secretlab.ca/git/linux-2.6

are available in the git repository at:

   git://git.monstr.eu/linux-2.6-microblaze.git next

Edgar E. Iglesias (2):
       microblaze: Switch ELF_ARCH code to 189
       microblaze: Raise SIGFPE/FPE_INTDIV for div by zero

Eli Billauer (2):
       microblaze: Moved __dma_sync() to dma-mapping.h
       microblaze: Added DMA sync operations

Michal Simek (11):
       microblaze: Clear top bit from cnt32_to_63
       microblaze: Change label name in copy_tofrom_user
       microblaze: Separate fixup section definition
       microblaze: Change label names - copy_tofrom_user
       microblaze: Simplify logic for unaligned byte copying
       microblaze: Add loop unrolling for PAGE in copy_tofrom_user
       microblaze: Fix access_ok macro
       microblaze: Add PVR for Microblaze v8.20.a
       microblaze: Add __ucmpdi2() helper function
       microblaze: Remove NET_IP_ALIGN from system.h
       microblaze: Use delay slot in __strnlen_user, __strncpy_user

Peter Zijlstra (1):
       microblaze: Remove __ARCH_WANT_INTERRUPTS_ON_CTXSW usage

  arch/microblaze/include/asm/dma-mapping.h |   20 ++++-
  arch/microblaze/include/asm/elf.h         |    8 +-
  arch/microblaze/include/asm/system.h      |    9 --
  arch/microblaze/include/asm/uaccess.h     |    2 +-
  arch/microblaze/kernel/cpu/cpuinfo.c      |    1 +
  arch/microblaze/kernel/dma.c              |   82 +++++++++++++++-----
  arch/microblaze/kernel/exceptions.c       |    2 +-
  arch/microblaze/kernel/process.c          |    1 +
  arch/microblaze/kernel/ptrace.c           |    2 +-
  arch/microblaze/kernel/timer.c            |    3 +-
  arch/microblaze/lib/Makefile              |    1 +
  arch/microblaze/lib/uaccess_old.S         |  123 +++++++++++++++++++++++++----
  arch/microblaze/lib/ucmpdi2.c             |   20 +++++
  13 files changed, 220 insertions(+), 54 deletions(-)
  create mode 100644 arch/microblaze/lib/ucmpdi2.c


-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

^ permalink raw reply

* [PATCH V2 2/2] ahci_platform: add suspend & resume support
From: JiSheng Zhang @ 2011-10-31 13:20 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-ide, avorontsov, linux-pm, linux-kernel


Signed-off-by: JiSheng Zhang <jszhang3@gmail.com>
---
 drivers/ata/ahci_platform.c |   52 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 45edba9..b8ffc02 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -202,11 +202,63 @@ static int __devexit ahci_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int ahci_suspend(struct device *dev)
+{
+	struct ata_host *host = dev_get_drvdata(dev);
+	struct ahci_host_priv *hpriv = host->private_data;
+	void __iomem *mmio = hpriv->mmio;
+	u32 ctl;
+
+	/* AHCI spec rev1.1 section 8.3.3:
+	 * Software must disable interrupts prior to requesting a
+	 * transition of the HBA to D3 state.
+	 */
+	ctl = readl(mmio + HOST_CTL);
+	ctl &= ~HOST_IRQ_EN;
+	writel(ctl, mmio + HOST_CTL);
+	readl(mmio + HOST_CTL); /* flush */
+
+	return ata_host_suspend(host, PMSG_SUSPEND);
+}
+
+static int ahci_resume(struct device *dev)
+{
+	struct ahci_platform_data *pdata = dev_get_platdata(dev);
+	struct ata_host *host = dev_get_drvdata(dev);
+	struct ahci_host_priv *hpriv = host->private_data;
+	int rc;
+
+	if (pdata && pdata->init) {
+		rc = pdata->init(dev, hpriv->mmio);
+		if (rc)
+			return rc;
+	}
+
+	rc = ahci_reset_controller(host);
+	if (rc)
+		return rc;
+
+	ahci_init_controller(host);
+	ata_host_resume(host);
+
+	return 0;
+}
+
+static const struct dev_pm_ops ahci_pm_ops = {
+	.suspend	= ahci_suspend,
+	.resume		= ahci_resume,
+};
+#endif
+
 static struct platform_driver ahci_driver = {
 	.remove = __devexit_p(ahci_remove),
 	.driver = {
 		.name = "ahci",
 		.owner = THIS_MODULE,
+#ifdef CONFIG_PM
+		.pm	= &ahci_pm_ops,
+#endif
 	},
 	.id_table	= ahci_devtype,
 };
-- 
1.7.6.3

^ permalink raw reply related

* Re: [Xenomai-help] configuring user-space xenomai 2.6
From: Patrice Kadionik @ 2011-10-31 13:20 UTC (permalink / raw)
  To: xenomai
In-Reply-To: <4EAE9EDE.5030501@domain.hid>

Le 31/10/2011 14:13, Gilles Chanteperdrix a écrit :

Hi,

You have perhaps followed this tutorial for mini2440 (I've worked on 
this board in july ;-) ): 
http://code.google.com/p/friendlyarm/wiki/Linux_Tutorial

Please try to unset  CC and CROSS_COMPILE.

Pat.


> On 10/31/2011 01:52 PM, Łukasz Sacha wrote:
>> This is the line configure generated to test whether compiler works:
>> arm-none-linux-gnueabi-gcc –march=armv4t –mtune=arm920t -o conftest
>> -march=armv4t -march=armv4t conftest.c
>> (notice tripple  -march=armv4t)
>>
>> when I execute it it gives me:
>> arm-none-linux-gnueabi-gcc: –march=armv4t: No such file or directory
>> arm-none-linux-gnueabi-gcc: –mtune=arm920t: No such file or directory
>> arm-none-linux-gnueabi-gcc: conftest.c: No such file or directory
>> arm-none-linux-gnueabi-gcc: no input files
>>
>> However with a single  -march=armv4t it doesn't work either.
>> luke@domain.hid$
>> arm-none-linux-gnueabi-gcc -march=armv4t –mtune=arm920t -o conftest
>> conftest.c
>> arm-none-linux-gnueabi-gcc: –mtune=arm920t: No such file or directory
>> arm-none-linux-gnueabi-gcc: conftest.c: No such file or directory
>> arm-none-linux-gnueabi-gcc: no input files
>>
>> .. which is strange, because arm-none-linux-gnueabi-gcc --help tells
>> me all the options are ok:
>> "Options starting with -g, -f, -m, -O, -W, or --param are automatically
>>   passed on to the various sub-processes invoked by arm-none-linux-gnueabi-gcc."
>>
>> Seems -mtune is not recognized by some subprocess, but which and why?
>>
>> cheers :)
> Strange toolchain. I use codesourcery toolchain and never observed such
> behaviour. You should make sure the toolchain you use works before
> trying and compiling xenomai.
>


-- 
Patrice Kadionik. F6KQH / F4CUQ
-----------

+----------------------------------------------------------------------+
+"Tout doit etre aussi simple que possible, pas seulement plus simple" +
+----------------------------------------------------------------------+
+ Patrice Kadionik             http://www.enseirb-matmeca.fr/~kadionik +
+ IMS Laboratory               http://www.ims-bordeaux.fr/             +
+ ENSEIRB-MATMECA              http://www.enseirb-matmeca.fr           +
+ PO BOX 99                    fax   : +33 5.56.37.20.23               +
+ 33402 TALENCE Cedex          voice : +33 5.56.84.23.47               +
+ FRANCE                                                               +
+----------------------------------------------------------------------+



^ permalink raw reply


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.