[PATCH] staging: media:lirc: Added a newline character after declaration
Added a newline character to remove a coding style warning detected by checkpatch. The warning is given below: drivers/staging/media/lirc/lirc_serial.c:1169: WARNING: quoted string split across lines Signed-off-by: Aparna Karuthodi kdasapa...@gmail.com --- drivers/staging/media/lirc/lirc_serial.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c index 19628d0..628577f 100644 --- a/drivers/staging/media/lirc/lirc_serial.c +++ b/drivers/staging/media/lirc/lirc_serial.c @@ -1165,7 +1165,7 @@ module_init(lirc_serial_init_module); module_exit(lirc_serial_exit_module); MODULE_DESCRIPTION(Infra-red receiver driver for serial ports.); -MODULE_AUTHOR(Ralph Metzler, Trent Piepho, Ben Pfaff, +MODULE_AUTHOR(Ralph Metzler, Trent Piepho, Ben Pfaff,\n Christoph Bartelmus, Andrei Tanas); MODULE_LICENSE(GPL); -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] staging: media:lirc: Added a newline character after declaration
On Wed, Aug 12, 2015 at 08:41:42PM +0530, Aparna Karuthodi wrote: Added a newline character to remove a coding style warning detected by checkpatch. The warning is given below: drivers/staging/media/lirc/lirc_serial.c:1169: WARNING: quoted string split across lines Signed-off-by: Aparna Karuthodi kdasapa...@gmail.com --- drivers/staging/media/lirc/lirc_serial.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c index 19628d0..628577f 100644 --- a/drivers/staging/media/lirc/lirc_serial.c +++ b/drivers/staging/media/lirc/lirc_serial.c @@ -1165,7 +1165,7 @@ module_init(lirc_serial_init_module); module_exit(lirc_serial_exit_module); MODULE_DESCRIPTION(Infra-red receiver driver for serial ports.); -MODULE_AUTHOR(Ralph Metzler, Trent Piepho, Ben Pfaff, +MODULE_AUTHOR(Ralph Metzler, Trent Piepho, Ben Pfaff,\n Christoph Bartelmus, Andrei Tanas); No, you just changed the way this string looks, that's not ok at all. This is fine the way it is, you can ignore it. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] [media] m2m: fix bad unlock balance
Hi, On 12 August 2015 at 13:42, Marek Szyprowski m.szyprow...@samsung.com wrote: Hello Hans, I'm sorry for a delay. Once again I've been busy with some other internal stuff. On 2015-07-28 11:02, Hans Verkuil wrote: Kamil, Marek, Why does v4l2_m2m_poll unlock and lock in that function? I've checked the code and indeed the poll_wait() function doesn't do anything that should not be done with queue mutex being taken. I don't remember if it was always like that. You are right that the unlocklock code should be removed. Zahari is right that the locking is unbalanced, but I don't see the reason for the unlock/lock sequence in the first place. I'm wondering if that shouldn't just be removed. Am I missing something? Instead, I would expect to see a spin_lock_irqsave(src/dst_q-done_lock, flags) around the list_empty(src/dst_q-done_list) calls. Indeed, that's another thing that should be fixed in this function. I looks that commit c16218402a000bb25c1277c43ae98c11bcb59bd1 ([media] videobuf2: return -EPIPE from DQBUF after the last buffer) is the root cause of both issues (unballanced locking and lack of spinlock protection), while the unnecessary queue unlock/lock sequence was there from the beginning. I am all with Marek on this. Unlock/lock was there from the beginning, it is not necessary. I agree also that spin_lock/unlock should be added for the list_empty call. [snip] Best wishes, Kamil -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 07/16] media: get rid of unused extra_links param on media_entity_init()
Currently, media_entity_init() creates an array with the links, allocated at init time. It provides a parameter (extra_links) that would allocate more links than the current needs, but this is not used by any driver. As we want to be able to do dynamic link allocation/removal, we'll need to change the implementation of the links. So, before doing that, let's first remove that extra unused parameter, in order to cleanup the interface first. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/Documentation/media-framework.txt b/Documentation/media-framework.txt index f552a75c0e70..2cc6019f7147 100644 --- a/Documentation/media-framework.txt +++ b/Documentation/media-framework.txt @@ -104,7 +104,7 @@ although drivers can allocate entities directly. Drivers initialize entities by calling media_entity_init(struct media_entity *entity, u16 num_pads, - struct media_pad *pads, u16 extra_links); + struct media_pad *pads); The media_entity name, type, flags, revision and group_id fields can be initialized before or after calling media_entity_init. Entities embedded in diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 75d5c18d689a..109cc3792534 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt @@ -300,7 +300,7 @@ calling media_entity_init(): struct media_pad *pads = my_sd-pads; int err; - err = media_entity_init(sd-entity, npads, pads, 0); + err = media_entity_init(sd-entity, npads, pads); The pads array must have been previously initialized. There is no need to manually set the struct media_entity type and name fields, but the revision @@ -700,7 +700,7 @@ calling media_entity_init(): struct media_pad *pad = my_vdev-pad; int err; - err = media_entity_init(vdev-entity, 1, pad, 0); + err = media_entity_init(vdev-entity, 1, pad); The pads array must have been previously initialized. There is no need to manually set the struct media_entity type and name fields. diff --git a/Documentation/zh_CN/video4linux/v4l2-framework.txt b/Documentation/zh_CN/video4linux/v4l2-framework.txt index 2b828e631e31..ff815cb92031 100644 --- a/Documentation/zh_CN/video4linux/v4l2-framework.txt +++ b/Documentation/zh_CN/video4linux/v4l2-framework.txt @@ -295,7 +295,7 @@ owner ??? i2c ? struct media_pad *pads = my_sd-pads; int err; - err = media_entity_init(sd-entity, npads, pads, 0); + err = media_entity_init(sd-entity, npads, pads); pads media_entity ??? type ??? name revision ? @@ -602,7 +602,7 @@ v4l2_file_operations file_operations ??? struct media_pad *pad = my_vdev-pad; int err; - err = media_entity_init(vdev-entity, 1, pad, 0); + err = media_entity_init(vdev-entity, 1, pad); pads ?? media_entity ??? type ??? name ?? diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 13bb57f0457f..2fdcbb5f000a 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -249,7 +249,7 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, } if (npads) - ret = media_entity_init(dvbdev-entity, npads, dvbdev-pads, 0); + ret = media_entity_init(dvbdev-entity, npads, dvbdev-pads); if (!ret) ret = media_device_register_entity(dvbdev-adapter-mdev, dvbdev-entity); diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index 69094ab047b1..39d6ee681aeb 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c @@ -1158,7 +1158,7 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id * state-rgb_quantization_range_ctrl-is_private = true; state-pad.flags = MEDIA_PAD_FL_SINK; - err = media_entity_init(sd-entity, 1, state-pad, 0); + err = media_entity_init(sd-entity, 1, state-pad); if (err) goto err_hdl; diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index c70ababce954..5f76997f6e07 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -512,7 +512,7 @@ static int adp1653_probe(struct i2c_client *client, if (ret) goto free_and_quit; - ret = media_entity_init(flash-subdev.entity, 0, NULL, 0); + ret = media_entity_init(flash-subdev.entity, 0, NULL); if (ret 0) goto free_and_quit; diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index
[PATCH RFC v3 09/16] media: use media_graph_obj for link endpoints
As we'll need to create links between entities and interfaces, we need to identify the link endpoints by the media_graph_obj. Please note that, while we're now using graph_obj to reference the link endpoints, we're still assuming that all endpoints are pads at the existing drivers. This is true for all existing links, so no problems are expected so far. Yet, as we introduce links between entities and interfaces, we may need to change some existing code to work with links that aren't pad to pad. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 842b9c8f80c6..3c97ebdf9f2a 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -635,6 +635,8 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) for (i = 0; i entity-num_links; i++) { link = entity-links[i]; + if (link-port1.type != MEDIA_GRAPH_PAD) + continue; if (link-sink-entity == entity) { found_link = link; n_links++; @@ -665,6 +667,8 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) int flags = 0; link = source-links[i]; + if (link-port1.type != MEDIA_GRAPH_PAD) + continue; sink = link-sink-entity; if (sink == entity) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index a95ca981aabb..b4bd718ad736 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -155,6 +155,10 @@ static long __media_device_enum_links(struct media_device *mdev, list_for_each_entry(ent_link, entity-links, list) { struct media_link_desc link; + /* Only PAD to PAD links should be enumerated with legacy API */ + if (ent_link-port0-type != MEDIA_GRAPH_PAD || + ent_link-port1-type != MEDIA_GRAPH_PAD) + continue; /* Ignore backlinks. */ if (ent_link-source-entity != entity) continue; diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 333c49aa0974..fc2e4886c830 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -121,6 +121,10 @@ EXPORT_SYMBOL_GPL(media_entity_cleanup); static struct media_entity * media_entity_other(struct media_entity *entity, struct media_link *link) { + /* For now, we only do graph traversal with PADs */ + if (link-port0-type != MEDIA_GRAPH_PAD || + link-port1-type != MEDIA_GRAPH_PAD) + return NULL; if (link-source-entity == entity) return link-sink-entity; else @@ -217,6 +221,10 @@ media_entity_graph_walk_next(struct media_entity_graph *graph) /* Get the entity in the other end of the link . */ next = media_entity_other(entity, link); + if (!next) { + list_rotate_left(link_top(graph)); + continue; + } if (WARN_ON(next-id = MEDIA_ENTITY_ENUM_MAX_ID)) return NULL; @@ -285,8 +293,14 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, bitmap_fill(has_no_links, entity-num_pads); list_for_each_entry(link, entity-links, list) { - struct media_pad *pad = link-sink-entity == entity - ? link-sink : link-source; + struct media_pad *pad; + + /* For now, ignore interface-entity links */ + if (link-port0-type != MEDIA_GRAPH_PAD) + continue; + + pad = link-sink-entity == entity + ? link-sink : link-source; /* Mark that a pad is connected by a link. */ bitmap_clear(has_no_links, pad-index, 1); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 403019035424..a6464499902e 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -43,6 +43,17 @@ enum media_graph_type { MEDIA_GRAPH_LINK, }; +/** + * enum media_graph_link_dir - direction of a link + * + * @MEDIA_LINK_DIR_BIDIRECTIONAL Link is bidirectional + * @MEDIA_LINK_DIR_PORT0_TO_PORT1 Link is unidirectional, + * from port 0 to port 1 + */ +enum media_graph_link_dir { + MEDIA_LINK_DIR_BIDIRECTIONAL, + MEDIA_LINK_DIR_PORT0_TO_PORT1, +}; /* Structs to represent the objects that belong to a media graph */ @@ -71,16 +82,25 @@ struct media_pipeline { };
[PATCH RFC v3 02/16] media: Add a common embeed struct for all media graph objects
Due to the MC API proposed changes, we'll need to: - have an unique object ID for all graph objects; - be able to dynamically create/remove objects; - be able to group objects; - keep the object in memory until we stop use it. Due to that, create a struct media_graph_obj and put there the common elements that all media objects will have in common. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 0c003d817493..051aa3f8bbfe 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -28,10 +28,50 @@ #include linux/list.h #include linux/media.h +/* Enums used internally at the media controller to represent graphs */ + +/** + * enum media_graph_type - type of a graph element + * + * @MEDIA_GRAPH_ENTITY:Identify a media entity + * @MEDIA_GRAPH_PAD: Identify a media PAD + * @MEDIA_GRAPH_LINK: Identify a media link + */ +enum media_graph_type { + MEDIA_GRAPH_ENTITY, + MEDIA_GRAPH_PAD, + MEDIA_GRAPH_LINK, +}; + + +/* Structs to represent the objects that belong to a media graph */ + +/** + * struct media_graph_obj - Define a graph object. + * + * @list: List of media graph objects + * @obj_id:Non-zero object ID identifier. The ID should be unique + * inside a media_device + * @type: Type of the graph object + * @mdev: Media device that contains the object + * object before stopping using it + * + * All elements on the media graph should have this struct embedded + */ +struct media_graph_obj { + struct list_headlist; + struct list_headgroup; + u32 obj_id; + enum media_graph_type type; + struct media_device *mdev; +}; + + struct media_pipeline { }; struct media_link { + struct media_graph_obj graph_obj; struct media_pad *source; /* Source pad */ struct media_pad *sink; /* Sink pad */ struct media_link *reverse; /* Link in the reverse direction */ @@ -39,6 +79,7 @@ struct media_link { }; struct media_pad { + struct media_graph_obj graph_obj; struct media_entity *entity;/* Entity this pad belongs to */ u16 index; /* Pad index in the entity pads array */ unsigned long flags;/* Pad flags (MEDIA_PAD_FL_*) */ @@ -61,6 +102,7 @@ struct media_entity_operations { }; struct media_entity { + struct media_graph_obj graph_obj; struct list_head list; struct media_device *parent;/* Media device this entity belongs to*/ u32 id; /* Entity ID, unique in the parent media -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 05/16] media: initialize PAD objects
PAD embedded objects also need to be initialized. Those are currently created via media_entity_init() and, once created, never change. While this will likely change in the future, for now we can just initialize those objects once, when registering the entity. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 960a4e30c68d..56724f7853bf 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -430,6 +430,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister); int __must_check media_device_register_entity(struct media_device *mdev, struct media_entity *entity) { + int i; + /* Warn if we apparently re-register an entity */ WARN_ON(entity-parent != NULL); entity-parent = mdev; @@ -438,6 +440,11 @@ int __must_check media_device_register_entity(struct media_device *mdev, /* Initialize media_graph_obj embedded at the entity */ graph_obj_init(mdev, MEDIA_GRAPH_ENTITY, entity-graph_obj); + /* Initialize objects at the pads */ + for (i = 0; entity-num_pads; i++) + graph_obj_init(mdev, MEDIA_GRAPH_PAD, + entity-pads[i].graph_obj); + /* * FIXME: should it use the unique object ID or would it * break support on the legacy MC API? @@ -462,6 +469,7 @@ EXPORT_SYMBOL_GPL(media_device_register_entity); */ void media_device_unregister_entity(struct media_entity *entity) { + int i; struct media_device *mdev = entity-parent; if (mdev == NULL) @@ -469,6 +477,8 @@ void media_device_unregister_entity(struct media_entity *entity) spin_lock(mdev-lock); graph_obj_remove(entity-graph_obj); + for (i = 0; entity-num_pads; i++) + graph_obj_remove(entity-pads[i].graph_obj); list_del(entity-list); spin_unlock(mdev-lock); entity-parent = NULL; -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 06/16] media: initialize the graph object inside the media links
When a new link is created, we need to initialize the object inside it. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 56724f7853bf..9fb3f8958265 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -479,6 +479,8 @@ void media_device_unregister_entity(struct media_entity *entity) graph_obj_remove(entity-graph_obj); for (i = 0; entity-num_pads; i++) graph_obj_remove(entity-pads[i].graph_obj); + for (i = 0; entity-num_links; i++) + graph_obj_remove(entity-links[i].graph_obj); list_del(entity-list); spin_unlock(mdev-lock); entity-parent = NULL; diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 19ad316f2f33..6985d5c53632 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -469,6 +469,10 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) entity-links = links; } + /* Initialize graph object embedded at the new link */ + graph_obj_init(entity-parent, MEDIA_GRAPH_LINK, + entity-links[entity-num_links].graph_obj); + return entity-links[entity-num_links++]; } -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 10/16] media: rename link source/sink to pad0_source/pad1_sink
Change the internal namespace for links between two pads to have the pad there. We're also numbering it, as a common constructor is to do things like: if (link-port1.type != MEDIA_GRAPH_PAD) continue; if (link-pad1_sink-entity == entity) /* do something */ by preserving the number, we keep consistency between port1 and pad1_sink, and port0 and pad0_source. This was generated via this script: for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,link-sink,link-pad1_sink,g; s,link-source,link-pad0_source,g; $i a mv a $i; done Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 3c97ebdf9f2a..e673f6f7c398 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -637,7 +637,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) link = entity-links[i]; if (link-port1.type != MEDIA_GRAPH_PAD) continue; - if (link-sink-entity == entity) { + if (link-pad1_sink-entity == entity) { found_link = link; n_links++; if (link-flags MEDIA_LNK_FL_ENABLED) @@ -660,7 +660,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) return -EINVAL; } - source = found_link-source-entity; + source = found_link-pad0_source-entity; fepriv-pipe_start_entity = source; for (i = 0; i source-num_links; i++) { struct media_entity *sink; @@ -669,7 +669,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) link = source-links[i]; if (link-port1.type != MEDIA_GRAPH_PAD) continue; - sink = link-sink-entity; + sink = link-pad1_sink-entity; if (sink == entity) flags = MEDIA_LNK_FL_ENABLED; diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index b4bd718ad736..2c29c4600c3a 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -160,13 +160,13 @@ static long __media_device_enum_links(struct media_device *mdev, ent_link-port1-type != MEDIA_GRAPH_PAD) continue; /* Ignore backlinks. */ - if (ent_link-source-entity != entity) + if (ent_link-pad0_source-entity != entity) continue; memset(link, 0, sizeof(link)); - media_device_kpad_to_upad(ent_link-source, + media_device_kpad_to_upad(ent_link-pad0_source, link.source); - media_device_kpad_to_upad(ent_link-sink, + media_device_kpad_to_upad(ent_link-pad1_sink, link.sink); link.flags = ent_link-flags; if (copy_to_user(ulink, link, sizeof(*ulink))) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index fc2e4886c830..aafa1119fba7 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -125,10 +125,10 @@ media_entity_other(struct media_entity *entity, struct media_link *link) if (link-port0-type != MEDIA_GRAPH_PAD || link-port1-type != MEDIA_GRAPH_PAD) return NULL; - if (link-source-entity == entity) - return link-sink-entity; + if (link-pad0_source-entity == entity) + return link-pad1_sink-entity; else - return link-source-entity; + return link-pad0_source-entity; } /* push an entity to traversal stack */ @@ -299,8 +299,8 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, if (link-port0-type != MEDIA_GRAPH_PAD) continue; - pad = link-sink-entity == entity - ? link-sink : link-source; + pad = link-pad1_sink-entity == entity + ? link-pad1_sink : link-pad0_source; /* Mark that a pad is connected by a link. */ bitmap_clear(has_no_links, pad-index, 1); @@ -318,7 +318,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, * Link validation will only take place for * sink ends of the link that are enabled. */ - if (link-sink != pad || +
Re: RFC: prepare for struct scatterlist entries without page backing
Hi, On Wed, Aug 12, 2015 at 10:42 PM, Boaz Harrosh b...@plexistor.com wrote: On 08/12/2015 10:05 AM, Christoph Hellwig wrote: It turns out most DMA mapping implementation can handle SGLs without page structures with some fairly simple mechanical work. Most of it is just about consistently using sg_phys. For implementations that need to flush caches we need a new helper that skips these cache flushes if a entry doesn't have a kernel virtual address. However the ccio (parisc) and sba_iommu (parisc ia64) IOMMUs seem to be operate mostly on virtual addresses. It's a fairly odd concept that I don't fully grasp, so I'll need some help with those if we want to bring this forward. Additional this series skips ARM entirely for now. The reason is that most arm implementations of the .map_sg operation just iterate over all entries and call -map_page for it, which means we'd need to convert those to a -map_pfn similar to Dan's previous approach. [snip] It is a bit of work but is worth while, and accelerating tremendously lots of workloads. Not like this abomination which only branches things more and more, and making things fatter and slower. As a random guy reading a big bunch of patches on code I know almost nothing about, parts of this comment really resonated with me: overall, we seem to be adding a lot of if statements to code that appears to be in a hot path. I.e. ~90% of this patch set seems to be just mechanically dropping BUG_ON()s and converting open coded stuff to use accessor functions (which should be macros or get inlined, right?) - and the remaining bit is not flushing if we don't have a physical page somewhere. Would it make sense to split this patch set into a few bits: one to drop all the useless BUG_ON()s, one to convert all the open coded stuff to accessor functions, then another to do the actual page-less sg stuff? Thanks, -- Julian Calaby Email: julian.cal...@gmail.com Profile: http://www.google.com/profiles/julian.calaby/ -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 08/16] media: convert links from array to list
Using memory realloc to increase the size of an array is complex and makes harder to remove links. Also, by embedding the link inside an array at the entity makes harder to change the code to add interfaces, as interfaces will also need to use links. So, convert the links from arrays to lists. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 9fb3f8958265..a95ca981aabb 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -25,6 +25,7 @@ #include linux/ioctl.h #include linux/media.h #include linux/types.h +#include linux/slab.h #include media/media-device.h #include media/media-devnode.h @@ -148,22 +149,22 @@ static long __media_device_enum_links(struct media_device *mdev, } if (links-links) { - struct media_link_desc __user *ulink; - unsigned int l; + struct media_link *ent_link; + struct media_link_desc __user *ulink = links-links; - for (l = 0, ulink = links-links; l entity-num_links; l++) { + list_for_each_entry(ent_link, entity-links, list) { struct media_link_desc link; /* Ignore backlinks. */ - if (entity-links[l].source-entity != entity) + if (ent_link-source-entity != entity) continue; memset(link, 0, sizeof(link)); - media_device_kpad_to_upad(entity-links[l].source, + media_device_kpad_to_upad(ent_link-source, link.source); - media_device_kpad_to_upad(entity-links[l].sink, + media_device_kpad_to_upad(ent_link-sink, link.sink); - link.flags = entity-links[l].flags; + link.flags = ent_link-flags; if (copy_to_user(ulink, link, sizeof(*ulink))) return -EFAULT; ulink++; @@ -471,6 +472,7 @@ void media_device_unregister_entity(struct media_entity *entity) { int i; struct media_device *mdev = entity-parent; + struct media_link *link, *tmp; if (mdev == NULL) return; @@ -479,8 +481,11 @@ void media_device_unregister_entity(struct media_entity *entity) graph_obj_remove(entity-graph_obj); for (i = 0; entity-num_pads; i++) graph_obj_remove(entity-pads[i].graph_obj); - for (i = 0; entity-num_links; i++) - graph_obj_remove(entity-links[i].graph_obj); + list_for_each_entry_safe(link, tmp, entity-links, list) { + graph_obj_remove(link-graph_obj); + list_del(link-list); + kfree(link); + } list_del(entity-list); spin_unlock(mdev-lock); entity-parent = NULL; diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index e8451a4a403b..333c49aa0974 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -76,14 +76,6 @@ void graph_obj_remove(struct media_graph_obj *gobj) * use cases the entity driver can guess the number of links which can safely * be assumed to be equal to or larger than the number of pads. * - * For those reasons the links array can be preallocated based on the entity - * driver guess and will be reallocated later if extra links need to be - * created. - * - * This function allocates a links array with enough space to hold at least - * 'num_pads' + 'extra_links' elements. The media_entity::max_links field will - * be set to the number of allocated elements. - * * The pads array is managed by the entity driver and passed to * media_entity_init() where its pointer will be stored in the entity structure. */ @@ -91,21 +83,14 @@ int media_entity_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads) { - struct media_link *links; - unsigned int max_links = num_pads; unsigned int i; - links = kzalloc(max_links * sizeof(links[0]), GFP_KERNEL); - if (links == NULL) - return -ENOMEM; - entity-group_id = 0; - entity-max_links = max_links; entity-num_links = 0; entity-num_backlinks = 0; entity-num_pads = num_pads; entity-pads = pads; - entity-links = links; + INIT_LIST_HEAD(entity-links); for (i = 0; i num_pads; i++) { pads[i].entity = entity; @@ -119,7 +104,13 @@ EXPORT_SYMBOL_GPL(media_entity_init); void media_entity_cleanup(struct media_entity *entity) { - kfree(entity-links); + struct media_link *link, *tmp; + + list_for_each_entry_safe(link, tmp, entity-links, list) { +
Re: [PATCH RFC v3 14/16] media: add a generic function to remove a link
On Wed, Aug 12, 2015 at 2:14 PM, Mauro Carvalho Chehab mche...@osg.samsung.com wrote: Removing a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com One thing to think about is whether or not we need some kind of callback mechanism to alert the entity on the other side of the link and other entities associated with the media device when a link is removed. This patch is fine for now and we can enhance it as and when we have the need for such notifications. -- Shuah diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index b8991d38c565..f43af2fda306 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -484,6 +484,12 @@ static struct media_link *__media_create_link(struct media_device *mdev, return link; } +static void __media_remove_link(struct media_link *link) +{ + list_del(link-list); + kfree(link); +} + static void __media_entity_remove_link(struct media_entity *entity, struct media_link *link) { @@ -509,11 +515,9 @@ static void __media_entity_remove_link(struct media_entity *entity, break; /* Remove the remote link */ - list_del(rlink-list); - kfree(rlink); + __media_remove_link(rlink); } - list_del(link-list); - kfree(link); + __media_remove_link(link); } int -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: dvb_usb_af9015: command failed=1 _ kernel = 4.1.x
On 11.08.2015 00:40, Antti Palosaari wrote: On 08/11/2015 12:46 AM, poma wrote: Furthermore, to fix this issue - AF9015 DVB-T USB2.0 stick brokenness - is the responsibility of developers. I am here only proven tester. I hope we understand each other, and this problem will be resolved in good faith. Your patches are implemented wrong. Talk about deflecting. The patch that you called my is nothing but two reverted commitas: - 02f9cf96df57575acea2e6eb4041e9f3ecd32548 [media] [PATH,2/2] mxl5007 move loop_thru to attach - fe4860af002a4516dd878f7297b61e186c475b35 [media] [PATH,1/2] mxl5007 move reset to attach Besides the author, Jose Alberto Reguero does not oppose to revert them, due to the trouble they cause. When I added mxl5007t support to that driver it was DigitalNow TinyTwin v2 I had. The rest mxl5007t dual devices using reference design IDs went to same due to reason driver detects used tuner. My device is still working fine, which means your device has different wiring. As 2nd tuner attach fails it means there is communication loss to tuner. Which means tuner is most likely hold in a reset attach time or there is some I2C gating which prevents communication. Patches you sent will introduce another issue. For dual tuner configuration there could be antenna wired from tuner chip to another. After that patch you will lose antenna signal from 2nd tuner on cases where tuner antenna wire is loop through master tuner to slave. So fix it correctly. Find out reason there is communication loss to 2nd tuner on attach time. I cannot do much as I simply don't have such hardware. And I really do not care to take any responsibility when that kind of issues happens - it is not my job to bough every single device from the market in able to test and fix every hardware combination. Antti You very well know that I am not a developer, Therefore I believe this above what you write is addressed to yourself, after all *you* are a developer, a capable one, right. Are you? -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC v3 14/16] media: add a generic function to remove a link
Em Wed, 12 Aug 2015 14:45:52 -0600 Shuah Khan shuahk...@gmail.com escreveu: On Wed, Aug 12, 2015 at 2:14 PM, Mauro Carvalho Chehab mche...@osg.samsung.com wrote: Removing a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com One thing to think about is whether or not we need some kind of callback mechanism to alert the entity on the other side of the link and other entities associated with the media device when a link is removed. This patch is fine for now and we can enhance it as and when we have the need for such notifications. Well, now, all elements of the graph are of the type media_graph_obj. One of the things it is stored there is the media_device. It would be very easy to add a notify function[1] that would call a callback when a new object is created or removed. A single callback function could be used for any topology change. So, I think that it is now simpler to track topology changes than before ;) [1] Actually, I would implement a list with notification callbacks as more than one driver may want to be notified about topology changes. Regards, Mauro -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 11/16] media: rename the function that create pad links
Now that a link can be either between two different graph objects, we'll need to add more functions to create links. So, rename the existing one that create links only between two pads as media_create_pad_link(). No functional changes. This patch was created via this shell script: for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,media_entity_create_link,media_create_pad_link,g $i a mv a $i; done Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 2fdcbb5f000a..65f59f2124b4 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -412,16 +412,16 @@ void dvb_create_media_graph(struct dvb_adapter *adap) } if (tuner fe) - media_entity_create_link(tuner, 0, fe, 0, 0); + media_create_pad_link(tuner, 0, fe, 0, 0); if (fe demux) - media_entity_create_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED); + media_create_pad_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED); if (demux dvr) - media_entity_create_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED); + media_create_pad_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED); if (demux ca) - media_entity_create_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED); + media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED); } EXPORT_SYMBOL_GPL(dvb_create_media_graph); #endif diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index 6d167428727d..c81bfbfea32f 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1482,11 +1482,11 @@ static int s5c73m3_oif_registered(struct v4l2_subdev *sd) return ret; } - ret = media_entity_create_link(state-sensor_sd.entity, + ret = media_create_pad_link(state-sensor_sd.entity, S5C73M3_ISP_PAD, state-oif_sd.entity, OIF_ISP_PAD, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); - ret = media_entity_create_link(state-sensor_sd.entity, + ret = media_create_pad_link(state-sensor_sd.entity, S5C73M3_JPEG_PAD, state-oif_sd.entity, OIF_JPEG_PAD, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 30a9ca62e034..d3bff30bcb6f 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -1756,7 +1756,7 @@ static int s5k5baf_registered(struct v4l2_subdev *sd) v4l2_err(sd, failed to register subdev %s\n, state-cis_sd.name); else - ret = media_entity_create_link(state-cis_sd.entity, PAD_CIS, + ret = media_create_pad_link(state-cis_sd.entity, PAD_CIS, state-sd.entity, PAD_CIS, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 308613ea0aed..5aa49eb393a9 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2495,7 +2495,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) return rval; } - rval = media_entity_create_link(this-sd.entity, + rval = media_create_pad_link(this-sd.entity, this-source_pad, last-sd.entity, last-sink_pad, @@ -2503,7 +2503,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) MEDIA_LNK_FL_IMMUTABLE); if (rval) { dev_err(client-dev, - media_entity_create_link failed\n); + media_create_pad_link failed\n); return rval; } diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index aafa1119fba7..03c0ebdd8026 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -479,7 +479,7 @@ static void __media_entity_remove_link(struct media_entity *entity, struct media_link *link); int -media_entity_create_link(struct media_entity *source, u16 source_pad, +media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags) { struct media_link *link; @@ -517,7 +517,7 @@
[PATCH RFC v3 12/16] media: move __media_entity_remove_link to avoid prototype
As we need __media_entity_remove_link() earlier, move it to happen earlier, to avoid needing to have a function prototype. No functional changes. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 03c0ebdd8026..eafd26a741e5 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -476,7 +476,36 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) } static void __media_entity_remove_link(struct media_entity *entity, - struct media_link *link); + struct media_link *link) +{ + struct media_link *rlink, *tmp; + struct media_entity *remote; + unsigned int r = 0; + + if (link-pad0_source-entity == entity) + remote = link-pad1_sink-entity; + else + remote = link-pad0_source-entity; + + list_for_each_entry_safe(rlink, tmp, remote-links, list) { + if (rlink != link-reverse) { + r++; + continue; + } + + if (link-pad0_source-entity == entity) + remote-num_backlinks--; + + if (--remote-num_links == 0) + break; + + /* Remove the remote link */ + list_del(rlink-list); + kfree(rlink); + } + list_del(link-list); + kfree(link); +} int media_create_pad_link(struct media_entity *source, u16 source_pad, @@ -519,38 +548,6 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, } EXPORT_SYMBOL_GPL(media_create_pad_link); -static void __media_entity_remove_link(struct media_entity *entity, - struct media_link *link) -{ - struct media_link *rlink, *tmp; - struct media_entity *remote; - unsigned int r = 0; - - if (link-pad0_source-entity == entity) - remote = link-pad1_sink-entity; - else - remote = link-pad0_source-entity; - - list_for_each_entry_safe(rlink, tmp, remote-links, list) { - if (rlink != link-reverse) { - r++; - continue; - } - - if (link-pad0_source-entity == entity) - remote-num_backlinks--; - - if (--remote-num_links == 0) - break; - - /* Remove the remote link */ - list_del(rlink-list); - kfree(rlink); - } - list_del(link-list); - kfree(link); -} - void __media_entity_remove_links(struct media_entity *entity) { struct media_link *link, *tmp; -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 16/16] media: add functions to allow creating interfaces
Interfaces are different than entities: they represent a Kernel-userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function. Let's distinguish them by creating a separate structure to store the interfaces. Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index c3bc8a6f660b..8cd529d3180a 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -733,3 +733,59 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) } EXPORT_SYMBOL_GPL(media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create(struct media_device *mdev, + u32 major, u32 minor, + gfp_t gfp_flags) +{ + struct media_intf_devnode *devnode; + + devnode = kzalloc(sizeof(*devnode), gfp_flags); + if (!devnode) + return NULL; + + devnode-major = major; + devnode-minor = minor; + INIT_LIST_HEAD(devnode-intf.entity_links); + + graph_obj_init(mdev, MEDIA_GRAPH_INTF_DEVNODE, + devnode-intf.graph_obj); + + return devnode; +} +EXPORT_SYMBOL_GPL(media_devnode_create); + +void media_devnode_remove(struct media_intf_devnode *devnode) +{ + graph_obj_remove(devnode-intf.graph_obj); + kfree(devnode); +} +EXPORT_SYMBOL_GPL(media_devnode_remove); + +struct media_link *media_create_intf_link(struct media_entity *entity, + struct media_graph_obj *gobj, + u32 flags) +{ + struct media_link *link; + + /* Only accept links between entity==interface */ + if (gobj-type != MEDIA_GRAPH_INTF_DEVNODE) + return NULL; + + link = __media_create_link(entity-parent, + MEDIA_LINK_DIR_BIDIRECTIONAL, + entity-graph_obj, + gobj, + flags, entity-intf_links); + if (link == NULL) + return NULL; + + /* Create the link at the interface */ + list_add(gobj_to_interface(gobj)-entity_links, link-list); + + return link; +} +EXPORT_SYMBOL_GPL(media_create_intf_link); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index e63e402ca6d1..80df883cb336 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -36,11 +36,14 @@ * @MEDIA_GRAPH_ENTITY:Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media PAD * @MEDIA_GRAPH_LINK: Identify a media link + * @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via + * a device node */ enum media_graph_type { MEDIA_GRAPH_ENTITY, MEDIA_GRAPH_PAD, MEDIA_GRAPH_LINK, + MEDIA_GRAPH_INTF_DEVNODE, }; /** @@ -145,7 +148,9 @@ struct media_entity { u16 num_backlinks; /* Number of backlinks */ struct media_pad *pads; /* Pads array (num_pads elements) */ - struct list_head links; /* Links list */ + struct list_head links; /* PAD links list */ + + struct list_head intf_links;/* Interface links list */ const struct media_entity_operations *ops; /* Entity operations */ @@ -170,6 +175,30 @@ struct media_entity { } info; }; +/** + * struct media_intf_devnode - Define a Kernel API interface + * + * @graph_obj: embedded graph object + * @ent_links: List of links pointing to graph entities + */ +struct media_interface { + struct media_graph_obj graph_obj; + struct list_headentity_links; +}; + +/** + * struct media_intf_devnode - Define a Kernel API interface via a device node + * + * @intf: embedded interface object + * @major: Major number of a device node + * @minor: Minor number of a device node + */ +struct media_intf_devnode { + struct media_interface intf; + u32 major; + u32 minor; +}; + static inline u32 media_entity_type(struct media_entity *entity) { return entity-type MEDIA_ENT_TYPE_MASK; @@ -202,6 +231,9 @@ struct media_entity_graph { #define gobj_to_pad(gobj) \ container_of(gobj, struct media_pad, graph_obj) +#define gobj_to_interface(gobj) \ + container_of(gobj, struct media_interface, graph_obj) + void graph_obj_init(struct media_device *mdev, enum media_graph_type type,
[PATCH RFC v3 15/16] media: rename media_entity_remove_foo functions
As entities will also have links to interfaces, we need to rename the existing functions that remove links, to avoid namespace collision and confusion. No functional changes. The rename was made by this script: for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,media_entity_remove,media_remove_pad,g $i a mv a $i; done Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index f43af2fda306..c3bc8a6f660b 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -490,7 +490,7 @@ static void __media_remove_link(struct media_link *link) kfree(link); } -static void __media_entity_remove_link(struct media_entity *entity, +static void __media_remove_pad_link(struct media_entity *entity, struct media_link *link) { struct media_link *rlink, *tmp; @@ -548,7 +548,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, sink-pads[sink_pad].graph_obj, flags, sink-links); if (backlink == NULL) { - __media_entity_remove_link(source, link); + __media_remove_pad_link(source, link); return -ENOMEM; } @@ -561,29 +561,29 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, } EXPORT_SYMBOL_GPL(media_create_pad_link); -void __media_entity_remove_links(struct media_entity *entity) +void __media_remove_pad_links(struct media_entity *entity) { struct media_link *link, *tmp; list_for_each_entry_safe(link, tmp, entity-links, list) - __media_entity_remove_link(entity, link); + __media_remove_pad_link(entity, link); entity-num_links = 0; entity-num_backlinks = 0; } -EXPORT_SYMBOL_GPL(__media_entity_remove_links); +EXPORT_SYMBOL_GPL(__media_remove_pad_links); -void media_entity_remove_links(struct media_entity *entity) +void media_remove_pad_links(struct media_entity *entity) { /* Do nothing if the entity is not registered. */ if (entity-parent == NULL) return; mutex_lock(entity-parent-graph_mutex); - __media_entity_remove_links(entity); + __media_remove_pad_links(entity); mutex_unlock(entity-parent-graph_mutex); } -EXPORT_SYMBOL_GPL(media_entity_remove_links); +EXPORT_SYMBOL_GPL(media_remove_pad_links); static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) { diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 5b0a30b9252b..bbec6d87f5f8 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -285,7 +285,7 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd) #if defined(CONFIG_MEDIA_CONTROLLER) if (v4l2_dev-mdev) { - media_entity_remove_links(sd-entity); + media_remove_pad_links(sd-entity); media_device_unregister_entity(sd-entity); } #endif diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 8400c517ff1f..e63e402ca6d1 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -213,8 +213,8 @@ void media_entity_cleanup(struct media_entity *entity); int media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags); -void __media_entity_remove_links(struct media_entity *entity); -void media_entity_remove_links(struct media_entity *entity); +void __media_remove_pad_links(struct media_entity *entity); +void media_remove_pad_links(struct media_entity *entity); int __media_entity_setup_link(struct media_link *link, u32 flags); int media_entity_setup_link(struct media_link *link, u32 flags); -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 13/16] media: make the internal function to create links more generic
In preparation to add a public function to add links, let's make the internal function that creates link more generic. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index eafd26a741e5..b8991d38c565 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -457,7 +457,12 @@ EXPORT_SYMBOL_GPL(media_entity_put); * Links management */ -static struct media_link *media_entity_add_link(struct media_entity *entity) +static struct media_link *__media_create_link(struct media_device *mdev, + enum media_graph_link_dir dir, + struct media_graph_obj *port0, + struct media_graph_obj *port1, + u32 flags, + struct list_head *list) { struct media_link *link; @@ -465,12 +470,16 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) if (link == NULL) return NULL; + link-dir = dir; + link-port0 = port0; + link-port1 = port1; + link-flags = flags; + INIT_LIST_HEAD(link-list); - list_add(entity-links, link-list); + list_add(list, link-list); /* Initialize graph object embedded at the new link */ - graph_obj_init(entity-parent, MEDIA_GRAPH_LINK, - link-graph_obj); + graph_obj_init(mdev, MEDIA_GRAPH_LINK, link-graph_obj); return link; } @@ -509,7 +518,7 @@ static void __media_entity_remove_link(struct media_entity *entity, int media_create_pad_link(struct media_entity *source, u16 source_pad, -struct media_entity *sink, u16 sink_pad, u32 flags) + struct media_entity *sink, u16 sink_pad, u32 flags) { struct media_link *link; struct media_link *backlink; @@ -518,27 +527,27 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, BUG_ON(source_pad = source-num_pads); BUG_ON(sink_pad = sink-num_pads); - link = media_entity_add_link(source); + link = __media_create_link(source-parent, + MEDIA_LINK_DIR_PORT0_TO_PORT1, + source-pads[source_pad].graph_obj, + sink-pads[sink_pad].graph_obj, + flags, source-links); if (link == NULL) return -ENOMEM; - link-pad0_source = source-pads[source_pad]; - link-pad1_sink = sink-pads[sink_pad]; - link-flags = flags; - /* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ - backlink = media_entity_add_link(sink); + backlink = __media_create_link(sink-parent, + MEDIA_LINK_DIR_PORT0_TO_PORT1, + source-pads[source_pad].graph_obj, + sink-pads[sink_pad].graph_obj, + flags, sink-links); if (backlink == NULL) { __media_entity_remove_link(source, link); return -ENOMEM; } - backlink-pad0_source = source-pads[source_pad]; - backlink-pad1_sink = sink-pads[sink_pad]; - backlink-flags = flags; - link-reverse = backlink; backlink-reverse = link; -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 04/16] media: ensure that entities will have an object ID
All objects need an object ID. However, as v4l2 subdevs embeed entities internally, the code needs to manually check if the entity objects were not properly initialized and do it at entity register time. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index e627b0b905ad..960a4e30c68d 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -435,6 +435,13 @@ int __must_check media_device_register_entity(struct media_device *mdev, entity-parent = mdev; spin_lock(mdev-lock); + /* Initialize media_graph_obj embedded at the entity */ + graph_obj_init(mdev, MEDIA_GRAPH_ENTITY, entity-graph_obj); + + /* +* FIXME: should it use the unique object ID or would it +* break support on the legacy MC API? +*/ if (entity-id == 0) entity-id = mdev-entity_id++; else @@ -461,6 +468,7 @@ void media_device_unregister_entity(struct media_entity *entity) return; spin_lock(mdev-lock); + graph_obj_remove(entity-graph_obj); list_del(entity-list); spin_unlock(mdev-lock); entity-parent = NULL; -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 00/16] Changes on MC core due to MC workshop discussion
This is the third version of an initial set of patches showing the approach I'm taking in order to fulfill all the MC needs that was discussed on the 3 day MC summit in Helsinki. This version comes with the changes requested at the ML: - added unions at links for source/port0/entity and sink/port1/interface. That avoided adding macros to get the pad from the graph_obj on most places; - removed a wrong initialization for the reserse link at the pad create link function; - merged a fixup patch that was sent in separate by mistake on the previous series. = The goal of this patchset is: 1) to create a common struct that will be embedded on all internal structs that represents the comon data that will be used by all kinds of objects; 2) to have an unique object ID for each object in the graph. The object ID will be needed by the userspace API in the future, as discussed during the MC workshop; 3) to create objects to represent Kernel-userspace interfaces; 4) to extend the link support to allow linking interfaces to entities. On version 2, I removed the kref, as some people at the #v4l channel are not convinced about its need. So, let's postpone such discussion when we start introducing patches that will actually do dynamic object removal in runtime. As suggested, I'll be sending incremental patches and avoiding to do a large set of changes into one changeset series. That basically means that those patches aren't tested yet (except for compilation tests). Along this patch series, I'll be calling object as any symbol that belongs to a media graph, like processing entities, connectors, links, pads, interfaces. As said on the goals of this RFC, on version 2 of this patch series, we're coming with the new concept: interfaces. An interface is a graph object that does the interaction between Kernelspace === Userspace. While the code written for interface creation and interface==entity link is generic, currently I added support only for the type of interface currently used at the existing MC graphs: device node interfaces. We should add other types of interfaces in a future patchset. For example, we need to add support for network interfaces in order to fulfill the needs of the DVB subsystem. We'll also need to add support for sysfs interfaces in order to support IIO and remote controllers. Those API changes are aligned with the RFC for the userspace API proposed by Hans Verkuil: http://www.spinics.net/lists/linux-media/msg92166.html The only difference is that I'm using a single counter to generate an unique object ID, while Hans proposal is to use one per object type. As explained on my comments on the last patch series, the rationale is to simply simplify the code, helping to make the internal API changes clearer. We can change this latter before adding support for the userspace API. I suspect that we'll also need another type to represent groups of objects, but this will be covered on future patches if/when needed. No userspace API changes here, just changes at the internal structs that contains the media graph objects and some new helper functions. === Future work === I think that, after changing the MC core to support the new proposed API, a next step would be to simplify the internal representation of the media objects, in order to make it easier to be reused on other subsystems like IIO and to spend less memory. With that regards, I think that we can get rid of some fields at the existing structures: struct media_link.reverse - Currently we create two copies of the same link, in order to use at the graph traversal. I think we can remove it and use just one copy; struct media_entity - well, there are several things that we can get hid there: - parent - we're already storing it at the objects; - id - we have already an unique ID at the objects; - type - this should be replaced by properties; - revision - not used, afaikt; - group_id - groups should really be a new object type that will have the list of object IDs that belong to the group. - num_links/num_backlinks - those are used only at the userspace interface, but we need to track link creation/removal just to feed those things. I would remove those and add a logic at media_device.c to count; - num_pads - if we convert pads to lists (with seems to be the best thing, as not all entities need pads), then we can get rid of this too; - union info - this should be retrieved via the interface, and not via the entity. Yet, the above are suggestions for some future next steps. I won't probably address the above, except if needed in order to support the DVB or ALSA needs. Mauro Carvalho Chehab (16): media: Add some fields to store graph objects media: Add a common embeed struct for all media graph objects media: add functions to inialize media_graph_obj
[PATCH RFC v3 14/16] media: add a generic function to remove a link
Removing a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index b8991d38c565..f43af2fda306 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -484,6 +484,12 @@ static struct media_link *__media_create_link(struct media_device *mdev, return link; } +static void __media_remove_link(struct media_link *link) +{ + list_del(link-list); + kfree(link); +} + static void __media_entity_remove_link(struct media_entity *entity, struct media_link *link) { @@ -509,11 +515,9 @@ static void __media_entity_remove_link(struct media_entity *entity, break; /* Remove the remote link */ - list_del(rlink-list); - kfree(rlink); + __media_remove_link(rlink); } - list_del(link-list); - kfree(link); + __media_remove_link(link); } int -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 03/16] media: add functions to inialize media_graph_obj
We need to initialize the common media_graph_obj that it is now embedded inside each media controller object. Latter patches will use those functions to ensure that the object will be properly initialized. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 4d8e01c7b1b2..19ad316f2f33 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -27,6 +27,44 @@ #include media/media-device.h /** + * graph_obj_init - Initialize a graph object + * + * @mdev: Pointer to the media_device that contains the object + * @type: Type of the object + * @gobj: Pointer to the object + * + * This routine initializes the embedded struct media_graph_obj inside a + * media graph object. It is called automatically if media_*_create() + * calls are used. However, if the object (entity, link, pad, interface) + * is embedded on some other object, this function should be called before + * registering the object at the media controller. + */ +void graph_obj_init(struct media_device *mdev, + enum media_graph_type type, + struct media_graph_obj *gobj) +{ + INIT_LIST_HEAD(gobj-list); + + list_add_tail(gobj-list, mdev-object_list); + gobj-obj_id = atomic_inc_return(mdev-last_obj_id); + gobj-type = type; + gobj-mdev = mdev; +} + +/** + * graph_obj_remove - Stop using a graph object on a media device + * + * @graph_obj: Pointer to the object + * + * This is called at media_device_unregister_*() routines, and removes a + * graph object from the mdev object lists. + */ +void graph_obj_remove(struct media_graph_obj *gobj) +{ + list_del(gobj-list); +} + +/** * media_entity_init - Initialize a media entity * * @num_pads: Total number of sink and source pads. diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 051aa3f8bbfe..738e1d5d25dc 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -168,6 +168,14 @@ struct media_entity_graph { int top; }; +#define gobj_to_entity(gobj) \ + container_of(gobj, struct media_entity, graph_obj) + +void graph_obj_init(struct media_device *mdev, + enum media_graph_type type, + struct media_graph_obj *gobj); +void graph_obj_remove(struct media_graph_obj *gobj); + int media_entity_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads, u16 extra_links); void media_entity_cleanup(struct media_entity *entity); -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC v3 01/16] media: Add some fields to store graph objects
We'll need unique IDs for graph objects and a way to associate them with the media interface. So, add an atomic var to be used to create unique IDs and a list to store such objects. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 7b39440192d6..e627b0b905ad 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -396,6 +396,10 @@ int __must_check __media_device_register(struct media_device *mdev, return ret; } + /* Initialize media graph object list and ID */ + atomic_set(mdev-last_obj_id, 0); + INIT_LIST_HEAD(mdev-object_list); + return 0; } EXPORT_SYMBOL_GPL(__media_device_register); diff --git a/include/media/media-device.h b/include/media/media-device.h index 6e6db78f1ee2..a9d546716e49 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -78,6 +78,10 @@ struct media_device { int (*link_notify)(struct media_link *link, u32 flags, unsigned int notification); + + /* Used by media_graph stuff */ + atomic_t last_obj_id; + struct list_head object_list; }; /* Supported link_notify @notification values. */ -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC v3 14/16] media: add a generic function to remove a link
On 08/12/2015 02:52 PM, Mauro Carvalho Chehab wrote: Em Wed, 12 Aug 2015 14:45:52 -0600 Shuah Khan shuahk...@gmail.com escreveu: On Wed, Aug 12, 2015 at 2:14 PM, Mauro Carvalho Chehab mche...@osg.samsung.com wrote: Removing a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com One thing to think about is whether or not we need some kind of callback mechanism to alert the entity on the other side of the link and other entities associated with the media device when a link is removed. This patch is fine for now and we can enhance it as and when we have the need for such notifications. Well, now, all elements of the graph are of the type media_graph_obj. One of the things it is stored there is the media_device. It would be very easy to add a notify function[1] that would call a callback when a new object is created or removed. A single callback function could be used for any topology change. So, I think that it is now simpler to track topology changes than before ;) [1] Actually, I would implement a list with notification callbacks as more than one driver may want to be notified about topology changes. Right. It has to be a list as opposed to a single call. -- Shuah -- Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) shua...@osg.samsung.com | (970) 217-8978 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
cron job: media_tree daily build: ERRORS
This message is generated daily by a cron job that builds media_tree for the kernels and architectures in the list below. Results of the daily build of media_tree: date: Thu Aug 13 04:00:15 CEST 2015 git branch: test git hash: 2696f495bdc046d84da6c909a1e7f535138a2a62 gcc version:i686-linux-gcc (GCC) 5.1.0 sparse version: v0.5.0-51-ga53cea2 smatch version: 0.4.1-3153-g7d56ab3 host hardware: x86_64 host os:4.0.0-3.slh.1-amd64 linux-git-arm-at91: OK linux-git-arm-davinci: OK linux-git-arm-exynos: OK linux-git-arm-mx: OK linux-git-arm-omap: OK linux-git-arm-omap1: OK linux-git-arm-pxa: OK linux-git-blackfin-bf561: WARNINGS linux-git-i686: OK linux-git-m32r: OK linux-git-mips: OK linux-git-powerpc64: OK linux-git-sh: OK linux-git-x86_64: WARNINGS linux-2.6.32.27-i686: WARNINGS linux-2.6.33.7-i686: WARNINGS linux-2.6.34.7-i686: WARNINGS linux-2.6.35.9-i686: WARNINGS linux-2.6.36.4-i686: WARNINGS linux-2.6.37.6-i686: WARNINGS linux-2.6.38.8-i686: WARNINGS linux-2.6.39.4-i686: WARNINGS linux-3.0.60-i686: WARNINGS linux-3.1.10-i686: ERRORS linux-3.2.37-i686: ERRORS linux-3.3.8-i686: ERRORS linux-3.4.27-i686: WARNINGS linux-3.5.7-i686: WARNINGS linux-3.6.11-i686: WARNINGS linux-3.7.4-i686: WARNINGS linux-3.8-i686: WARNINGS linux-3.9.2-i686: WARNINGS linux-3.10.1-i686: OK linux-3.11.1-i686: OK linux-3.12.23-i686: OK linux-3.13.11-i686: OK linux-3.14.9-i686: OK linux-3.15.2-i686: OK linux-3.16.7-i686: OK linux-3.17.8-i686: OK linux-3.18.7-i686: OK linux-3.19-i686: OK linux-4.0-i686: OK linux-4.1.1-i686: OK linux-4.2-rc1-i686: OK linux-2.6.32.27-x86_64: WARNINGS linux-2.6.33.7-x86_64: WARNINGS linux-2.6.34.7-x86_64: WARNINGS linux-2.6.35.9-x86_64: WARNINGS linux-2.6.36.4-x86_64: WARNINGS linux-2.6.37.6-x86_64: WARNINGS linux-2.6.38.8-x86_64: WARNINGS linux-2.6.39.4-x86_64: WARNINGS linux-3.0.60-x86_64: WARNINGS linux-3.1.10-x86_64: ERRORS linux-3.2.37-x86_64: ERRORS linux-3.3.8-x86_64: ERRORS linux-3.4.27-x86_64: WARNINGS linux-3.5.7-x86_64: WARNINGS linux-3.6.11-x86_64: WARNINGS linux-3.7.4-x86_64: WARNINGS linux-3.8-x86_64: WARNINGS linux-3.9.2-x86_64: WARNINGS linux-3.10.1-x86_64: OK linux-3.11.1-x86_64: ERRORS linux-3.12.23-x86_64: ERRORS linux-3.13.11-x86_64: ERRORS linux-3.14.9-x86_64: ERRORS linux-3.15.2-x86_64: ERRORS linux-3.16.7-x86_64: ERRORS linux-3.17.8-x86_64: ERRORS linux-3.18.7-x86_64: ERRORS linux-3.19-x86_64: ERRORS linux-4.0-x86_64: ERRORS linux-4.1.1-x86_64: ERRORS linux-4.2-rc1-x86_64: OK apps: OK spec-git: OK sparse: WARNINGS smatch: ERRORS Detailed results are available here: http://www.xs4all.nl/~hverkuil/logs/Thursday.log Full logs are available here: http://www.xs4all.nl/~hverkuil/logs/Thursday.tar.bz2 The Media Infrastructure API from this daily build is here: http://www.xs4all.nl/~hverkuil/spec/media.html -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 16/31] s390: handle page-less SG entries
Use sg_phys() instead of page_to_phys(sg_page(sg)) so that we don't require a page structure for all DMA memory. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/s390/pci/pci_dma.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index 6fd8d58..aae5a47 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -272,14 +272,13 @@ int dma_set_mask(struct device *dev, u64 mask) } EXPORT_SYMBOL_GPL(dma_set_mask); -static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, -unsigned long offset, size_t size, +static dma_addr_t s390_dma_map_phys(struct device *dev, unsigned long pa, +size_t size, enum dma_data_direction direction, struct dma_attrs *attrs) { struct zpci_dev *zdev = get_zdev(to_pci_dev(dev)); unsigned long nr_pages, iommu_page_index; - unsigned long pa = page_to_phys(page) + offset; int flags = ZPCI_PTE_VALID; dma_addr_t dma_addr; @@ -301,7 +300,7 @@ static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, if (!dma_update_trans(zdev, pa, dma_addr, size, flags)) { atomic64_add(nr_pages, zdev-mapped_pages); - return dma_addr + (offset ~PAGE_MASK); + return dma_addr + (pa ~PAGE_MASK); } out_free: @@ -312,6 +311,16 @@ out_err: return DMA_ERROR_CODE; } +static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, +unsigned long offset, size_t size, +enum dma_data_direction direction, +struct dma_attrs *attrs) +{ + unsigned long pa = page_to_phys(page) + offset; + + return s390_dma_map_phys(dev, pa, size, direction, attrs); +} + static void s390_dma_unmap_pages(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction, struct dma_attrs *attrs) @@ -384,8 +393,7 @@ static int s390_dma_map_sg(struct device *dev, struct scatterlist *sg, int i; for_each_sg(sg, s, nr_elements, i) { - struct page *page = sg_page(s); - s-dma_address = s390_dma_map_pages(dev, page, s-offset, + s-dma_address = s390_dma_map_phys(dev, sg_phys(s), s-length, dir, NULL); if (!dma_mapping_error(dev, s-dma_address)) { s-dma_length = s-length; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 17/31] ia64/sba_iommu: remove sba_sg_address
Signed-off-by: Christoph Hellwig h...@lst.de --- arch/ia64/hp/common/sba_iommu.c | 22 ++ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index 344387a..9e5aa8e 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c @@ -248,8 +248,6 @@ static int reserve_sba_gart = 1; static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t); static SBA_INLINE void sba_free_range(struct ioc *, dma_addr_t, size_t); -#define sba_sg_address(sg) sg_virt((sg)) - #ifdef FULL_VALID_PDIR static u64 prefetch_spill_page; #endif @@ -397,7 +395,7 @@ sba_dump_sg( struct ioc *ioc, struct scatterlist *startsg, int nents) while (nents-- 0) { printk(KERN_DEBUG %d : DMA %08lx/%05x CPU %p\n, nents, startsg-dma_address, startsg-dma_length, - sba_sg_address(startsg)); + sg_virt(startsg)); startsg = sg_next(startsg); } } @@ -409,7 +407,7 @@ sba_check_sg( struct ioc *ioc, struct scatterlist *startsg, int nents) int the_nents = nents; while (the_nents-- 0) { - if (sba_sg_address(the_sg) == 0x0UL) + if (sg_virt(the_sg) == 0x0UL) sba_dump_sg(NULL, startsg, nents); the_sg = sg_next(the_sg); } @@ -1243,11 +1241,11 @@ sba_fill_pdir( if (dump_run_sg) printk( %2d : %08lx/%05x %p\n, nents, startsg-dma_address, cnt, - sba_sg_address(startsg)); + sg_virt(startsg)); #else DBG_RUN_SG( %d : %08lx/%05x %p\n, nents, startsg-dma_address, cnt, - sba_sg_address(startsg)); + sg_virt(startsg)); #endif /* ** Look for the start of a new DMA stream @@ -1267,7 +1265,7 @@ sba_fill_pdir( ** Look for a VCONTIG chunk */ if (cnt) { - unsigned long vaddr = (unsigned long) sba_sg_address(startsg); + unsigned long vaddr = (unsigned long) sg_virt(startsg); ASSERT(pdirp); /* Since multiple Vcontig blocks could make up @@ -1335,7 +1333,7 @@ sba_coalesce_chunks(struct ioc *ioc, struct device *dev, int idx; while (nents 0) { - unsigned long vaddr = (unsigned long) sba_sg_address(startsg); + unsigned long vaddr = (unsigned long) sg_virt(startsg); /* ** Prepare for first/next DMA stream @@ -1380,7 +1378,7 @@ sba_coalesce_chunks(struct ioc *ioc, struct device *dev, ** ** append the next transaction? */ - vaddr = (unsigned long) sba_sg_address(startsg); + vaddr = (unsigned long) sg_virt(startsg); if (vcontig_end == vaddr) { vcontig_len += startsg-length; @@ -1479,7 +1477,7 @@ static int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, if (likely((ioc-dma_mask ~to_pci_dev(dev)-dma_mask) == 0)) { for_each_sg(sglist, sg, nents, filled) { sg-dma_length = sg-length; - sg-dma_address = virt_to_phys(sba_sg_address(sg)); + sg-dma_address = virt_to_phys(sg_virt(sg)); } return filled; } @@ -1487,7 +1485,7 @@ static int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, /* Fast path single entry scatterlists. */ if (nents == 1) { sglist-dma_length = sglist-length; - sglist-dma_address = sba_map_single_attrs(dev, sba_sg_address(sglist), sglist-length, dir, attrs); + sglist-dma_address = sba_map_single_attrs(dev, sg_virt(sglist), sglist-length, dir, attrs); return 1; } @@ -1563,7 +1561,7 @@ static void sba_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist, #endif DBG_RUN_SG(%s() START %d entries, %p,%x\n, - __func__, nents, sba_sg_address(sglist), sglist-length); + __func__, nents, sg_virt(sglist), sglist-length); #ifdef ASSERT_PDIR_SANITY ioc = GET_IOC(dev); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] horus3a: fix compiler warning
Shut up this compiler warning that I get during the daily build: horus3a.c: In function 'horus3a_set_params': horus3a.c:308:24: warning: 'rolloff' may be used uninitialized in this function [-Wmaybe-uninitialized] symbol_rate * (100 + rolloff), 20) + 5; ^ Signed-off-by: Hans Verkuil hans.verk...@cisco.com diff --git a/drivers/media/dvb-frontends/horus3a.c b/drivers/media/dvb-frontends/horus3a.c index 5074305..000606a 100644 --- a/drivers/media/dvb-frontends/horus3a.c +++ b/drivers/media/dvb-frontends/horus3a.c @@ -285,6 +285,7 @@ static int horus3a_set_params(struct dvb_frontend *fe) rolloff = 20; break; case ROLLOFF_AUTO: + default: dev_err(priv-i2c-dev, horus3a: auto roll-off is not supported\n); return -EINVAL; -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 18/31] nios2: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/nios2/mm/dma-mapping.c | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/arch/nios2/mm/dma-mapping.c b/arch/nios2/mm/dma-mapping.c index ac5da75..1a0a68d 100644 --- a/arch/nios2/mm/dma-mapping.c +++ b/arch/nios2/mm/dma-mapping.c @@ -64,13 +64,11 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(!valid_dma_direction(direction)); for_each_sg(sg, sg, nents, i) { - void *addr; - - addr = sg_virt(sg); - if (addr) { - __dma_sync_for_device(addr, sg-length, direction); - sg-dma_address = sg_phys(sg); + if (sg_has_page(sg)) { + __dma_sync_for_device(sg_virt(sg), sg-length, + direction); } + sg-dma_address = sg_phys(sg); } return nents; @@ -113,9 +111,8 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, return; for_each_sg(sg, sg, nhwentries, i) { - addr = sg_virt(sg); - if (addr) - __dma_sync_for_cpu(addr, sg-length, direction); + if (sg_has_page(sg)) + __dma_sync_for_cpu(sg_virt(sg), sg-length, direction); } } EXPORT_SYMBOL(dma_unmap_sg); @@ -166,8 +163,10 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, BUG_ON(!valid_dma_direction(direction)); /* Make sure that gcc doesn't leave the empty loop body. */ - for_each_sg(sg, sg, nelems, i) - __dma_sync_for_cpu(sg_virt(sg), sg-length, direction); + for_each_sg(sg, sg, nelems, i) { + if (sg_has_page(sg)) + __dma_sync_for_cpu(sg_virt(sg), sg-length, direction); + } } EXPORT_SYMBOL(dma_sync_sg_for_cpu); @@ -179,8 +178,10 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, BUG_ON(!valid_dma_direction(direction)); /* Make sure that gcc doesn't leave the empty loop body. */ - for_each_sg(sg, sg, nelems, i) - __dma_sync_for_device(sg_virt(sg), sg-length, direction); - + for_each_sg(sg, sg, nelems, i) { + if (sg_has_page(sg)) + __dma_sync_for_device(sg_virt(sg), sg-length, + direction); + } } EXPORT_SYMBOL(dma_sync_sg_for_device); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[GIT PULL FOR v4.3] OMAP3 ISP changes
Hi Mauro, The following changes since commit 2696f495bdc046d84da6c909a1e7f535138a2a62: [media] Staging: media: lirc: use USB API functions rather than constants (2015-08-11 18:00:30 -0300) are available in the git repository at: git://linuxtv.org/pinchartl/media.git omap3isp/next for you to fetch changes up to 32b7a848266fcf5c2c087106fd001abbac0405ee: v4l: omap3isp: Drop platform data support (2015-08-12 10:39:46 +0300) Laurent Pinchart (1): v4l: omap3isp: Drop platform data support drivers/media/platform/Kconfig | 2 +- drivers/media/platform/omap3isp/isp.c | 133 --- drivers/media/platform/omap3isp/isp.h | 7 +- drivers/media/platform/omap3isp/ispcsiphy.h | 2 +- drivers/media/platform/omap3isp/ispvideo.c | 9 +- .../media/platform/omap3isp}/omap3isp.h | 42 ++-- 6 files changed, 34 insertions(+), 161 deletions(-) rename {include/media = drivers/media/platform/omap3isp}/omap3isp.h (77%) -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC: prepare for struct scatterlist entries without page backing
Dan Williams started to look into addressing I/O to and from Persistent Memory in his series from June: http://thread.gmane.org/gmane.linux.kernel.cross-arch/27944 I've started looking into DMA mapping of these SGLs specifically instead of the map_pfn method in there. In addition to supporting NVDIMM backed I/O I also suspect this would be highly useful for media drivers that go through nasty hoops to be able to DMA from/to their ioremapped regions, with vb2_dc_get_userptr in drivers/media/v4l2-core/videobuf2-dma-contig.c being a prime example for the unsafe hacks currently used. It turns out most DMA mapping implementation can handle SGLs without page structures with some fairly simple mechanical work. Most of it is just about consistently using sg_phys. For implementations that need to flush caches we need a new helper that skips these cache flushes if a entry doesn't have a kernel virtual address. However the ccio (parisc) and sba_iommu (parisc ia64) IOMMUs seem to be operate mostly on virtual addresses. It's a fairly odd concept that I don't fully grasp, so I'll need some help with those if we want to bring this forward. Additional this series skips ARM entirely for now. The reason is that most arm implementations of the .map_sg operation just iterate over all entries and call -map_page for it, which means we'd need to convert those to a -map_pfn similar to Dan's previous approach. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/31] dma-debug: handle page-less SG entries
Use sg_pfn to get a the PFN and skip checks that require a kernel virtual address. Signed-off-by: Christoph Hellwig h...@lst.de --- lib/dma-debug.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/dma-debug.c b/lib/dma-debug.c index dace71f..a215a80 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c @@ -1368,7 +1368,7 @@ void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, entry-type = dma_debug_sg; entry-dev= dev; - entry-pfn= page_to_pfn(sg_page(s)); + entry-pfn= sg_pfn(s); entry-offset = s-offset, entry-size = sg_dma_len(s); entry-dev_addr = sg_dma_address(s); @@ -1376,7 +1376,7 @@ void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, entry-sg_call_ents = nents; entry-sg_mapped_ents = mapped_ents; - if (!PageHighMem(sg_page(s))) { + if (sg_has_page(s) !PageHighMem(sg_page(s))) { check_for_stack(dev, sg_virt(s)); check_for_illegal_area(dev, sg_virt(s), sg_dma_len(s)); } @@ -1419,7 +1419,7 @@ void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, struct dma_debug_entry ref = { .type = dma_debug_sg, .dev= dev, - .pfn= page_to_pfn(sg_page(s)), + .pfn= sg_pfn(s), .offset = s-offset, .dev_addr = sg_dma_address(s), .size = sg_dma_len(s), @@ -1580,7 +1580,7 @@ void debug_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, struct dma_debug_entry ref = { .type = dma_debug_sg, .dev= dev, - .pfn= page_to_pfn(sg_page(s)), + .pfn= sg_pfn(s), .offset = s-offset, .dev_addr = sg_dma_address(s), .size = sg_dma_len(s), @@ -1613,7 +1613,7 @@ void debug_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, struct dma_debug_entry ref = { .type = dma_debug_sg, .dev= dev, - .pfn= page_to_pfn(sg_page(s)), + .pfn= sg_pfn(s), .offset = s-offset, .dev_addr = sg_dma_address(s), .size = sg_dma_len(s), -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 01/31] scatterlist: add sg_pfn and sg_has_page helpers
Signed-off-by: Christoph Hellwig h...@lst.de --- include/linux/scatterlist.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 9b1ef0c..b1056bf 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -230,6 +230,16 @@ static inline dma_addr_t sg_phys(struct scatterlist *sg) return page_to_phys(sg_page(sg)) + sg-offset; } +static inline unsigned long sg_pfn(struct scatterlist *sg) +{ + return page_to_pfn(sg_page(sg)); +} + +static inline bool sg_has_page(struct scatterlist *sg) +{ + return true; +} + /** * sg_virt - Return virtual address of an sg entry * @sg: SG entry -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02/31] scatterlist: use sg_phys()
From: Dan Williams dan.j.willi...@intel.com Coccinelle cleanup to replace open coded sg to physical address translations. This is in preparation for introducing scatterlists that reference __pfn_t. // sg_phys.cocci: convert usage page_to_phys(sg_page(sg)) to sg_phys(sg) // usage: make coccicheck COCCI=sg_phys.cocci MODE=patch virtual patch @@ struct scatterlist *sg; @@ - page_to_phys(sg_page(sg)) + sg-offset + sg_phys(sg) @@ struct scatterlist *sg; @@ - page_to_phys(sg_page(sg)) + sg_phys(sg) PAGE_MASK Signed-off-by: Dan Williams dan.j.willi...@intel.com --- arch/arm/mm/dma-mapping.c| 2 +- arch/microblaze/kernel/dma.c | 3 +-- drivers/iommu/intel-iommu.c | 4 ++-- drivers/iommu/iommu.c| 2 +- drivers/staging/android/ion/ion_chunk_heap.c | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index cba12f3..3d3d6aa 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1520,7 +1520,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, return -ENOMEM; for (count = 0, s = sg; count (size PAGE_SHIFT); s = sg_next(s)) { - phys_addr_t phys = page_to_phys(sg_page(s)); + phys_addr_t phys = sg_phys(s) PAGE_MASK; unsigned int len = PAGE_ALIGN(s-offset + s-length); if (!is_coherent diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c index bf4dec2..c89da63 100644 --- a/arch/microblaze/kernel/dma.c +++ b/arch/microblaze/kernel/dma.c @@ -61,8 +61,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, /* FIXME this part of code is untested */ for_each_sg(sgl, sg, nents, i) { sg-dma_address = sg_phys(sg); - __dma_sync(page_to_phys(sg_page(sg)) + sg-offset, - sg-length, direction); + __dma_sync(sg_phys(sg), sg-length, direction); } return nents; diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 0649b94..3541d65 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -2097,7 +2097,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn, sg_res = aligned_nrpages(sg-offset, sg-length); sg-dma_address = ((dma_addr_t)iov_pfn VTD_PAGE_SHIFT) + sg-offset; sg-dma_length = sg-length; - pteval = page_to_phys(sg_page(sg)) | prot; + pteval = (sg_phys(sg) PAGE_MASK) | prot; phys_pfn = pteval VTD_PAGE_SHIFT; } @@ -3623,7 +3623,7 @@ static int intel_nontranslate_map_sg(struct device *hddev, for_each_sg(sglist, sg, nelems, i) { BUG_ON(!sg_page(sg)); - sg-dma_address = page_to_phys(sg_page(sg)) + sg-offset; + sg-dma_address = sg_phys(sg); sg-dma_length = sg-length; } return nelems; diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f286090..049df49 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1408,7 +1408,7 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, min_pagesz = 1 __ffs(domain-ops-pgsize_bitmap); for_each_sg(sg, s, nents, i) { - phys_addr_t phys = page_to_phys(sg_page(s)) + s-offset; + phys_addr_t phys = sg_phys(s); /* * We are mapping on IOMMU page boundaries, so offset within diff --git a/drivers/staging/android/ion/ion_chunk_heap.c b/drivers/staging/android/ion/ion_chunk_heap.c index 5474615..f7b6ef9 100644 --- a/drivers/staging/android/ion/ion_chunk_heap.c +++ b/drivers/staging/android/ion/ion_chunk_heap.c @@ -81,7 +81,7 @@ static int ion_chunk_heap_allocate(struct ion_heap *heap, err: sg = table-sgl; for (i -= 1; i = 0; i--) { - gen_pool_free(chunk_heap-pool, page_to_phys(sg_page(sg)), + gen_pool_free(chunk_heap-pool, sg_phys(sg) PAGE_MASK, sg-length); sg = sg_next(sg); } @@ -109,7 +109,7 @@ static void ion_chunk_heap_free(struct ion_buffer *buffer) DMA_BIDIRECTIONAL); for_each_sg(table-sgl, sg, table-nents, i) { - gen_pool_free(chunk_heap-pool, page_to_phys(sg_page(sg)), + gen_pool_free(chunk_heap-pool, sg_phys(sg) PAGE_MASK, sg-length); } chunk_heap-allocated -= allocated_size; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at
[PATCH 04/31] x86/pci-nommu: handle page-less SG entries
Just remove a BUG_ON, the code handles them just fine as-is. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/x86/kernel/pci-nommu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c index da15918..a218059 100644 --- a/arch/x86/kernel/pci-nommu.c +++ b/arch/x86/kernel/pci-nommu.c @@ -63,7 +63,6 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg, WARN_ON(nents == 0 || sg[0].length == 0); for_each_sg(sg, s, nents, i) { - BUG_ON(!sg_page(s)); s-dma_address = sg_phys(s); if (!check_addr(map_sg, hwdev, s-dma_address, s-length)) return 0; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[GIT PULL FOR v4.3] MC core bugfix
Hi Mauro, The following changes since commit 2696f495bdc046d84da6c909a1e7f535138a2a62: [media] Staging: media: lirc: use USB API functions rather than constants (2015-08-11 18:00:30 -0300) are available in the git repository at: git://linuxtv.org/pinchartl/media.git v4l2/next for you to fetch changes up to ab25def6e98d8a16105ab34bb1fc7b80f4b2dff5: media: Correctly notify about the failed pipeline validation (2015-08-12 10:57:05 +0300) Sakari Ailus (1): media: Correctly notify about the failed pipeline validation drivers/media/media-entity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: TW686x
Hi Ezequiel, OTOH I don't see any reason preventing you from sending a pull request for the inclusion of the TW686x driver, Mauro could merge this stuff then (assuming it's ready). You don't have to wait for me and a driver doesn't need to be a single patch from a single person. -- Krzysztof Hałasa Przemysłowy Instytut Automatyki i Pomiarów PIAP Al. Jerozolimskie 202, 02-486 Warszawa -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 25/31] frv: handle page-less SG entries
Only call kmap_atomic_primary when the SG entry is mapped into kernel virtual space. XXX: the code already looks odd due to the lack of pairing between kmap_atomic_primary and kunmap_atomic_primary. Does it work either before or after this patch? Signed-off-by: Christoph Hellwig h...@lst.de --- arch/frv/mb93090-mb00/pci-dma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/frv/mb93090-mb00/pci-dma.c b/arch/frv/mb93090-mb00/pci-dma.c index 4d1f01d..77b3a1c 100644 --- a/arch/frv/mb93090-mb00/pci-dma.c +++ b/arch/frv/mb93090-mb00/pci-dma.c @@ -63,6 +63,9 @@ int dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, dampr2 = __get_DAMPR(2); for_each_sg(sglist, sg, nents, i) { + if (!sg_has_page(sg)) + continue; + vaddr = kmap_atomic_primary(sg_page(sg)); frv_dcache_writeback((unsigned long) vaddr, -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 26/31] openrisc: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/openrisc/kernel/dma.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c index 0b77ddb..94ed052 100644 --- a/arch/openrisc/kernel/dma.c +++ b/arch/openrisc/kernel/dma.c @@ -184,8 +184,13 @@ or1k_map_sg(struct device *dev, struct scatterlist *sg, int i; for_each_sg(sg, s, nents, i) { - s-dma_address = or1k_map_page(dev, sg_page(s), s-offset, - s-length, dir, NULL); + if (sg_has_page(s)) { + s-dma_address = or1k_map_page(dev, sg_page(s), + s-offset, s-length, dir, + NULL); + } else { + s-dma_address = sg_phys(s); + } } return nents; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 28/31] powerpc: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page(). Signed-off-by: Christoph Hellwig h...@lst.de --- arch/powerpc/kernel/dma.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 35e4dcc..cece40b 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -135,7 +135,10 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, for_each_sg(sgl, sg, nents, i) { sg-dma_address = sg_phys(sg) + get_dma_offset(dev); sg-dma_length = sg-length; - __dma_sync_page(sg_page(sg), sg-offset, sg-length, direction); + if (sg_has_page(sg)) { + __dma_sync_page(sg_page(sg), sg-offset, sg-length, + direction); + } } return nents; @@ -200,7 +203,10 @@ static inline void dma_direct_sync_sg(struct device *dev, int i; for_each_sg(sgl, sg, nents, i) - __dma_sync_page(sg_page(sg), sg-offset, sg-length, direction); + if (sg_has_page(sg)) { + __dma_sync_page(sg_page(sg), sg-offset, sg-length, + direction); + } } static inline void dma_direct_sync_single(struct device *dev, -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06/31] alpha/pci-noop: handle page-less SG entries
Use sg_phys() instead of virt_to_phys(sg_virt(sg)) so that we don't require a kernel virtual address. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/alpha/kernel/pci-noop.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c index df24b76..7319151 100644 --- a/arch/alpha/kernel/pci-noop.c +++ b/arch/alpha/kernel/pci-noop.c @@ -145,11 +145,7 @@ static int alpha_noop_map_sg(struct device *dev, struct scatterlist *sgl, int ne struct scatterlist *sg; for_each_sg(sgl, sg, nents, i) { - void *va; - - BUG_ON(!sg_page(sg)); - va = sg_virt(sg); - sg_dma_address(sg) = (dma_addr_t)virt_to_phys(va); + sg_dma_address(sg) = (dma_addr_t)sg_phys(sg); sg_dma_len(sg) = sg-length; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 07/31] alpha/pci_iommu: handle page-less SG entries
Use sg_phys() instead of virt_to_phys(sg_virt(sg)) so that we don't require a kernel virtual address, and switch a few debug printfs to print physical instead of virtual addresses. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/alpha/kernel/pci_iommu.c | 36 +++- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c index eddee77..5d46b49 100644 --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c @@ -248,20 +248,17 @@ static int pci_dac_dma_supported(struct pci_dev *dev, u64 mask) until either pci_unmap_single or pci_dma_sync_single is performed. */ static dma_addr_t -pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size, +pci_map_single_1(struct pci_dev *pdev, unsigned long paddr, size_t size, int dac_allowed) { struct pci_controller *hose = pdev ? pdev-sysdata : pci_isa_hose; dma_addr_t max_dma = pdev ? pdev-dma_mask : ISA_DMA_MASK; struct pci_iommu_arena *arena; long npages, dma_ofs, i; - unsigned long paddr; dma_addr_t ret; unsigned int align = 0; struct device *dev = pdev ? pdev-dev : NULL; - paddr = __pa(cpu_addr); - #if !DEBUG_NODIRECT /* First check to see if we can use the direct map window. */ if (paddr + size + __direct_map_base - 1 = max_dma @@ -269,7 +266,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size, ret = paddr + __direct_map_base; DBGA2(pci_map_single: [%p,%zx] - direct %llx from %pf\n, - cpu_addr, size, ret, __builtin_return_address(0)); + paddr, size, ret, __builtin_return_address(0)); return ret; } @@ -280,7 +277,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size, ret = paddr + alpha_mv.pci_dac_offset; DBGA2(pci_map_single: [%p,%zx] - DAC %llx from %pf\n, - cpu_addr, size, ret, __builtin_return_address(0)); + paddr, size, ret, __builtin_return_address(0)); return ret; } @@ -309,15 +306,15 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size, return 0; } + offset = paddr ~PAGE_MASK; paddr = PAGE_MASK; for (i = 0; i npages; ++i, paddr += PAGE_SIZE) arena-ptes[i + dma_ofs] = mk_iommu_pte(paddr); - ret = arena-dma_base + dma_ofs * PAGE_SIZE; - ret += (unsigned long)cpu_addr ~PAGE_MASK; + ret = arena-dma_base + dma_ofs * PAGE_SIZE + offset; DBGA2(pci_map_single: [%p,%zx] np %ld - sg %llx from %pf\n, - cpu_addr, size, npages, ret, __builtin_return_address(0)); + paddr, size, npages, ret, __builtin_return_address(0)); return ret; } @@ -357,7 +354,7 @@ static dma_addr_t alpha_pci_map_page(struct device *dev, struct page *page, BUG_ON(dir == PCI_DMA_NONE); dac_allowed = pdev ? pci_dac_dma_supported(pdev, pdev-dma_mask) : 0; - return pci_map_single_1(pdev, (char *)page_address(page) + offset, + return pci_map_single_1(pdev, page_to_phys(page) + offset, size, dac_allowed); } @@ -453,7 +450,7 @@ try_again: } memset(cpu_addr, 0, size); - *dma_addrp = pci_map_single_1(pdev, cpu_addr, size, 0); + *dma_addrp = pci_map_single_1(pdev, __pa(cpu_addr), size, 0); if (*dma_addrp == 0) { free_pages((unsigned long)cpu_addr, order); if (alpha_mv.mv_pci_tbi || (gfp GFP_DMA)) @@ -497,9 +494,6 @@ static void alpha_pci_free_coherent(struct device *dev, size_t size, Write dma_length of each leader with the combined lengths of the mergable followers. */ -#define SG_ENT_VIRT_ADDRESS(SG) (sg_virt((SG))) -#define SG_ENT_PHYS_ADDRESS(SG) __pa(SG_ENT_VIRT_ADDRESS(SG)) - static void sg_classify(struct device *dev, struct scatterlist *sg, struct scatterlist *end, int virt_ok) @@ -512,13 +506,13 @@ sg_classify(struct device *dev, struct scatterlist *sg, struct scatterlist *end, leader = sg; leader_flag = 0; leader_length = leader-length; - next_paddr = SG_ENT_PHYS_ADDRESS(leader) + leader_length; + next_paddr = sg_phys(leader) + leader_length; /* we will not marge sg without device. */ max_seg_size = dev ? dma_get_max_seg_size(dev) : 0; for (++sg; sg end; ++sg) { unsigned long addr, len; - addr = SG_ENT_PHYS_ADDRESS(sg); + addr = sg_phys(sg); len = sg-length; if (leader_length + len max_seg_size) @@ -555,7 +549,7 @@ sg_fill(struct device *dev, struct scatterlist *leader, struct scatterlist *end, struct scatterlist *out, struct pci_iommu_arena *arena,
[PATCH 21/31] blackfin: handle page-less SG entries
Switch from sg_virt to sg_phys as blackfin like all nommu architectures has a 1:1 virtual to physical mapping. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/blackfin/kernel/dma-mapping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c index df437e5..e2c4d1a 100644 --- a/arch/blackfin/kernel/dma-mapping.c +++ b/arch/blackfin/kernel/dma-mapping.c @@ -120,7 +120,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg_list, int nents, int i; for_each_sg(sg_list, sg, nents, i) { - sg-dma_address = (dma_addr_t) sg_virt(sg); + sg-dma_address = sg_phys(sg); __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction); } @@ -135,7 +135,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg_list, int i; for_each_sg(sg_list, sg, nelems, i) { - sg-dma_address = (dma_addr_t) sg_virt(sg); + sg-dma_address = sg_phys(sg); __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction); } } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 22/31] metag: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page(). Signed-off-by: Christoph Hellwig h...@lst.de --- arch/metag/include/asm/dma-mapping.h | 22 -- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/metag/include/asm/dma-mapping.h b/arch/metag/include/asm/dma-mapping.h index eb5cdec..2ae9057 100644 --- a/arch/metag/include/asm/dma-mapping.h +++ b/arch/metag/include/asm/dma-mapping.h @@ -55,10 +55,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, WARN_ON(nents == 0 || sglist[0].length == 0); for_each_sg(sglist, sg, nents, i) { - BUG_ON(!sg_page(sg)); - sg-dma_address = sg_phys(sg); - dma_sync_for_device(sg_virt(sg), sg-length, direction); + if (sg_has_page(sg)) + dma_sync_for_device(sg_virt(sg), sg-length, direction); } return nents; @@ -94,10 +93,9 @@ dma_unmap_sg(struct device *dev, struct scatterlist *sglist, int nhwentries, WARN_ON(nhwentries == 0 || sglist[0].length == 0); for_each_sg(sglist, sg, nhwentries, i) { - BUG_ON(!sg_page(sg)); - sg-dma_address = sg_phys(sg); - dma_sync_for_cpu(sg_virt(sg), sg-length, direction); + if (sg_has_page(sg)) + dma_sync_for_cpu(sg_virt(sg), sg-length, direction); } } @@ -140,8 +138,10 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sglist, int nelems, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nelems, i) - dma_sync_for_cpu(sg_virt(sg), sg-length, direction); + for_each_sg(sglist, sg, nelems, i) { + if (sg_has_page(sg)) + dma_sync_for_cpu(sg_virt(sg), sg-length, direction); + } } static inline void @@ -151,8 +151,10 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nelems, i) - dma_sync_for_device(sg_virt(sg), sg-length, direction); + for_each_sg(sglist, sg, nelems, i) { + if (sg_has_page(sg)) + dma_sync_for_device(sg_virt(sg), sg-length, direction); + } } static inline int -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 23/31] sh: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page(). Signed-off-by: Christoph Hellwig h...@lst.de --- arch/sh/kernel/dma-nommu.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/sh/kernel/dma-nommu.c b/arch/sh/kernel/dma-nommu.c index 5b0bfcd..3b64dc7 100644 --- a/arch/sh/kernel/dma-nommu.c +++ b/arch/sh/kernel/dma-nommu.c @@ -33,9 +33,8 @@ static int nommu_map_sg(struct device *dev, struct scatterlist *sg, WARN_ON(nents == 0 || sg[0].length == 0); for_each_sg(sg, s, nents, i) { - BUG_ON(!sg_page(s)); - - dma_cache_sync(dev, sg_virt(s), s-length, dir); + if (sg_has_page(s)) + dma_cache_sync(dev, sg_virt(s), s-length, dir); s-dma_address = sg_phys(s); s-dma_length = s-length; @@ -57,8 +56,10 @@ static void nommu_sync_sg(struct device *dev, struct scatterlist *sg, struct scatterlist *s; int i; - for_each_sg(sg, s, nelems, i) - dma_cache_sync(dev, sg_virt(s), s-length, dir); + for_each_sg(sg, s, nelems, i) { + if (sg_has_page(s)) + dma_cache_sync(dev, sg_virt(s), s-length, dir); + } } #endif -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 24/31] xtensa: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page(). Signed-off-by: Christoph Hellwig h...@lst.de --- arch/xtensa/include/asm/dma-mapping.h | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/xtensa/include/asm/dma-mapping.h b/arch/xtensa/include/asm/dma-mapping.h index 1f5f6dc..262a1d1 100644 --- a/arch/xtensa/include/asm/dma-mapping.h +++ b/arch/xtensa/include/asm/dma-mapping.h @@ -61,10 +61,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, BUG_ON(direction == DMA_NONE); for_each_sg(sglist, sg, nents, i) { - BUG_ON(!sg_page(sg)); - sg-dma_address = sg_phys(sg); - consistent_sync(sg_virt(sg), sg-length, direction); + if (sg_has_page(sg)) + consistent_sync(sg_virt(sg), sg-length, direction); } return nents; @@ -131,8 +130,10 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sglist, int nelems, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nelems, i) - consistent_sync(sg_virt(sg), sg-length, dir); + for_each_sg(sglist, sg, nelems, i) { + if (sg_has_page(sg)) + consistent_sync(sg_virt(sg), sg-length, dir); + } } static inline void @@ -142,8 +143,10 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nelems, i) - consistent_sync(sg_virt(sg), sg-length, dir); + for_each_sg(sglist, sg, nelems, i) { + if (sg_has_page(sg)) + consistent_sync(sg_virt(sg), sg-length, dir); + } } static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 19/31] arc: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/arc/include/asm/dma-mapping.h | 26 +++--- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/arc/include/asm/dma-mapping.h b/arch/arc/include/asm/dma-mapping.h index 2d28ba9..42eb526 100644 --- a/arch/arc/include/asm/dma-mapping.h +++ b/arch/arc/include/asm/dma-mapping.h @@ -108,9 +108,13 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, struct scatterlist *s; int i; - for_each_sg(sg, s, nents, i) - s-dma_address = dma_map_page(dev, sg_page(s), s-offset, - s-length, dir); + for_each_sg(sg, s, nents, i) { + if (sg_has_page(s)) { + _dma_cache_sync((unsigned long)sg_virt(s), s-length, + dir); + } + s-dma_address = sg_phys(s); + } return nents; } @@ -163,8 +167,12 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sglist, int nelems, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nelems, i) - _dma_cache_sync((unsigned int)sg_virt(sg), sg-length, dir); + for_each_sg(sglist, sg, nelems, i) { + if (sg_has_page(sg)) { + _dma_cache_sync((unsigned int)sg_virt(sg), sg-length, + dir); + } + } } static inline void @@ -174,8 +182,12 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nelems, i) - _dma_cache_sync((unsigned int)sg_virt(sg), sg-length, dir); + for_each_sg(sglist, sg, nelems, i) { + if (sg_has_page(sg)) { + _dma_cache_sync((unsigned int)sg_virt(sg), sg-length, + dir); + } + } } static inline int dma_supported(struct device *dev, u64 dma_mask) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 20/31] avr32: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly, bypassing the noop page_to_bus. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/avr32/include/asm/dma-mapping.h | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/avr32/include/asm/dma-mapping.h b/arch/avr32/include/asm/dma-mapping.h index ae7ac92..a662ce2 100644 --- a/arch/avr32/include/asm/dma-mapping.h +++ b/arch/avr32/include/asm/dma-mapping.h @@ -216,11 +216,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, struct scatterlist *sg; for_each_sg(sglist, sg, nents, i) { - char *virt; - - sg-dma_address = page_to_bus(sg_page(sg)) + sg-offset; - virt = sg_virt(sg); - dma_cache_sync(dev, virt, sg-length, direction); + sg-dma_address = sg_phys(sg); + if (sg_has_page(sg)) + dma_cache_sync(dev, sg_virt(sg), sg-length, direction); } return nents; @@ -328,8 +326,10 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nents, i) - dma_cache_sync(dev, sg_virt(sg), sg-length, direction); + for_each_sg(sglist, sg, nents, i) { + if (sg_has_page(sg)) + dma_cache_sync(dev, sg_virt(sg), sg-length, direction); + } } /* Now for the API extensions over the pci_ one */ -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 10/31] powerpc/iommu: handle page-less SG entries
For the iommu offset we just need and offset into the page. Calculate that using the physical address instead of using the virtual address so that we don't require a virtual mapping. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/powerpc/kernel/iommu.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index a8e3490..0f52e40 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -457,7 +457,7 @@ int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl, max_seg_size = dma_get_max_seg_size(dev); for_each_sg(sglist, s, nelems, i) { - unsigned long vaddr, npages, entry, slen; + unsigned long paddr, npages, entry, slen; slen = s-length; /* Sanity check */ @@ -466,22 +466,22 @@ int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl, continue; } /* Allocate iommu entries for that segment */ - vaddr = (unsigned long) sg_virt(s); - npages = iommu_num_pages(vaddr, slen, IOMMU_PAGE_SIZE(tbl)); + paddr = sg_phys(s); + npages = iommu_num_pages(paddr, slen, IOMMU_PAGE_SIZE(tbl)); align = 0; if (tbl-it_page_shift PAGE_SHIFT slen = PAGE_SIZE - (vaddr ~PAGE_MASK) == 0) + (paddr ~PAGE_MASK) == 0) align = PAGE_SHIFT - tbl-it_page_shift; entry = iommu_range_alloc(dev, tbl, npages, handle, mask tbl-it_page_shift, align); - DBG( - vaddr: %lx, size: %lx\n, vaddr, slen); + DBG( - paddr: %lx, size: %lx\n, paddr, slen); /* Handle failure */ if (unlikely(entry == DMA_ERROR_CODE)) { if (printk_ratelimit()) dev_info(dev, iommu_alloc failed, tbl %p -vaddr %lx npages %lu\n, tbl, vaddr, +paddr %lx npages %lu\n, tbl, paddr, npages); goto failure; } @@ -496,7 +496,7 @@ int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl, /* Insert into HW table */ build_fail = tbl-it_ops-set(tbl, entry, npages, - vaddr IOMMU_PAGE_MASK(tbl), + paddr IOMMU_PAGE_MASK(tbl), direction, attrs); if(unlikely(build_fail)) goto failure; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 14/31] sparc32/io-unit: handle page-less SG entries
For the iommu offset we just need and offset into the page. Calculate that using the physical address instead of using the virtual address so that we don't require a virtual mapping. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/sparc/mm/io-unit.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c index f311bf2..82f97ae 100644 --- a/arch/sparc/mm/io-unit.c +++ b/arch/sparc/mm/io-unit.c @@ -91,13 +91,14 @@ static int __init iounit_init(void) subsys_initcall(iounit_init); /* One has to hold iounit-lock to call this */ -static unsigned long iounit_get_area(struct iounit_struct *iounit, unsigned long vaddr, int size) +static dma_addr_t iounit_get_area(struct iounit_struct *iounit, + unsigned long paddr, int size) { int i, j, k, npages; - unsigned long rotor, scan, limit; + unsigned long rotor, scan, limit, dma_addr; iopte_t iopte; -npages = ((vaddr ~PAGE_MASK) + size + (PAGE_SIZE-1)) PAGE_SHIFT; +npages = ((paddr ~PAGE_MASK) + size + (PAGE_SIZE-1)) PAGE_SHIFT; /* A tiny bit of magic ingredience :) */ switch (npages) { @@ -106,7 +107,7 @@ static unsigned long iounit_get_area(struct iounit_struct *iounit, unsigned long default: i = 0x0213; break; } - IOD((iounit_get_area(%08lx,%d[%d])=, vaddr, size, npages)); + IOD((iounit_get_area(%08lx,%d[%d])=, paddr, size, npages)); next: j = (i 15); rotor = iounit-rotor[j - 1]; @@ -121,7 +122,7 @@ nexti: scan = find_next_zero_bit(iounit-bmap, limit, scan); } i = 4; if (!(i 15)) - panic(iounit_get_area: Couldn't find free iopte slots for (%08lx,%d)\n, vaddr, size); + panic(iounit_get_area: Couldn't find free iopte slots for (%08lx,%d)\n, paddr, size); goto next; } for (k = 1, scan++; k npages; k++) @@ -129,14 +130,14 @@ nexti:scan = find_next_zero_bit(iounit-bmap, limit, scan); goto nexti; iounit-rotor[j - 1] = (scan limit) ? scan : iounit-limit[j - 1]; scan -= npages; - iopte = MKIOPTE(__pa(vaddr PAGE_MASK)); - vaddr = IOUNIT_DMA_BASE + (scan PAGE_SHIFT) + (vaddr ~PAGE_MASK); + iopte = MKIOPTE(paddr PAGE_MASK); + dma_addr = IOUNIT_DMA_BASE + (scan PAGE_SHIFT) + (paddr ~PAGE_MASK); for (k = 0; k npages; k++, iopte = __iopte(iopte_val(iopte) + 0x100), scan++) { set_bit(scan, iounit-bmap); sbus_writel(iopte, iounit-page_table[scan]); } - IOD((%08lx\n, vaddr)); - return vaddr; + IOD((%08lx\n, dma_addr)); + return dma_addr; } static __u32 iounit_get_scsi_one(struct device *dev, char *vaddr, unsigned long len) @@ -145,7 +146,7 @@ static __u32 iounit_get_scsi_one(struct device *dev, char *vaddr, unsigned long unsigned long ret, flags; spin_lock_irqsave(iounit-lock, flags); - ret = iounit_get_area(iounit, (unsigned long)vaddr, len); + ret = iounit_get_area(iounit, virt_to_phys(vaddr), len); spin_unlock_irqrestore(iounit-lock, flags); return ret; } @@ -159,7 +160,7 @@ static void iounit_get_scsi_sgl(struct device *dev, struct scatterlist *sg, int spin_lock_irqsave(iounit-lock, flags); while (sz != 0) { --sz; - sg-dma_address = iounit_get_area(iounit, (unsigned long) sg_virt(sg), sg-length); + sg-dma_address = iounit_get_area(iounit, sg_phys(sg), sg-length); sg-dma_length = sg-length; sg = sg_next(sg); } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 11/31] sparc/iommu: handle page-less SG entries
Use sg_phys() instead of __pa(sg_virt(sg)) so that we don't require a kernel virtual address. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/sparc/kernel/iommu.c| 2 +- arch/sparc/kernel/iommu_common.h | 4 +--- arch/sparc/kernel/pci_sun4v.c| 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c index 5320689..2ad89d2 100644 --- a/arch/sparc/kernel/iommu.c +++ b/arch/sparc/kernel/iommu.c @@ -486,7 +486,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist, continue; } /* Allocate iommu entries for that segment */ - paddr = (unsigned long) SG_ENT_PHYS_ADDRESS(s); + paddr = sg_phys(s); npages = iommu_num_pages(paddr, slen, IO_PAGE_SIZE); entry = iommu_tbl_range_alloc(dev, iommu-tbl, npages, handle, (unsigned long)(-1), 0); diff --git a/arch/sparc/kernel/iommu_common.h b/arch/sparc/kernel/iommu_common.h index b40cec2..8e2c211 100644 --- a/arch/sparc/kernel/iommu_common.h +++ b/arch/sparc/kernel/iommu_common.h @@ -33,15 +33,13 @@ */ #define IOMMU_PAGE_SHIFT 13 -#define SG_ENT_PHYS_ADDRESS(SG)(__pa(sg_virt((SG - static inline int is_span_boundary(unsigned long entry, unsigned long shift, unsigned long boundary_size, struct scatterlist *outs, struct scatterlist *sg) { - unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs); + unsigned long paddr = sg_phys(outs); int nr = iommu_num_pages(paddr, outs-dma_length + sg-length, IO_PAGE_SIZE); diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index d2fe57d..a7a6e41 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c @@ -370,7 +370,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist, continue; } /* Allocate iommu entries for that segment */ - paddr = (unsigned long) SG_ENT_PHYS_ADDRESS(s); + paddr = sg_phys(s); npages = iommu_num_pages(paddr, slen, IO_PAGE_SIZE); entry = iommu_tbl_range_alloc(dev, iommu-tbl, npages, handle, (unsigned long)(-1), 0); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 12/31] mn10300: handle page-less SG entries
Just remove a BUG_ON, the code handles them just fine as-is. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/mn10300/include/asm/dma-mapping.h | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/mn10300/include/asm/dma-mapping.h b/arch/mn10300/include/asm/dma-mapping.h index a18abfc..b1b1050 100644 --- a/arch/mn10300/include/asm/dma-mapping.h +++ b/arch/mn10300/include/asm/dma-mapping.h @@ -57,11 +57,8 @@ int dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, BUG_ON(!valid_dma_direction(direction)); WARN_ON(nents == 0 || sglist[0].length == 0); - for_each_sg(sglist, sg, nents, i) { - BUG_ON(!sg_page(sg)); - + for_each_sg(sglist, sg, nents, i) sg-dma_address = sg_phys(sg); - } mn10300_dcache_flush_inv(); return nents; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09/31] ia64/pci_dma: handle page-less SG entries
Use sg_phys() instead of virt_to_phys(sg_virt(sg)) so that we don't require a kernel virtual address. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/ia64/sn/pci/pci_dma.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c index d0853e8..8f713c8 100644 --- a/arch/ia64/sn/pci/pci_dma.c +++ b/arch/ia64/sn/pci/pci_dma.c @@ -18,9 +18,6 @@ #include asm/sn/pcidev.h #include asm/sn/sn_sal.h -#define SG_ENT_VIRT_ADDRESS(sg)(sg_virt((sg))) -#define SG_ENT_PHYS_ADDRESS(SG)virt_to_phys(SG_ENT_VIRT_ADDRESS(SG)) - /** * sn_dma_supported - test a DMA mask * @dev: device to test @@ -291,7 +288,7 @@ static int sn_dma_map_sg(struct device *dev, struct scatterlist *sgl, */ for_each_sg(sgl, sg, nhwentries, i) { dma_addr_t dma_addr; - phys_addr = SG_ENT_PHYS_ADDRESS(sg); + phys_addr = sg_phys(sg); if (dmabarr) dma_addr = provider-dma_map_consistent(pdev, phys_addr, -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/31] x86/pci-calgary: handle page-less SG entries
For the iommu offset we just need and offset into the page. Calculate that using the physical address instead of using the virtual address so that we don't require a virtual mapping. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/x86/kernel/pci-calgary_64.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c index 0497f71..8f1581d 100644 --- a/arch/x86/kernel/pci-calgary_64.c +++ b/arch/x86/kernel/pci-calgary_64.c @@ -368,16 +368,14 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg, { struct iommu_table *tbl = find_iommu_table(dev); struct scatterlist *s; - unsigned long vaddr; + unsigned long paddr; unsigned int npages; unsigned long entry; int i; for_each_sg(sg, s, nelems, i) { - BUG_ON(!sg_page(s)); - - vaddr = (unsigned long) sg_virt(s); - npages = iommu_num_pages(vaddr, s-length, PAGE_SIZE); + paddr = sg_phys(s); + npages = iommu_num_pages(paddr, s-length, PAGE_SIZE); entry = iommu_range_alloc(dev, tbl, npages); if (entry == DMA_ERROR_CODE) { @@ -389,7 +387,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg, s-dma_address = (entry PAGE_SHIFT) | s-offset; /* insert into HW table */ - tce_build(tbl, entry, npages, vaddr PAGE_MASK, dir); + tce_build(tbl, entry, npages, paddr PAGE_MASK, dir); s-dma_length = s-length; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 15/31] sparc32/iommu: handle page-less SG entries
Pass a PFN to iommu_get_one instad of calculating it locall from a page structure so that we don't need pages for every address we can DMA to or from. Also further restrict the cache flushing as we now have a non-highmem way of not kernel virtual mapped physical addresses. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/sparc/mm/iommu.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c index 491511d..3ed53d7 100644 --- a/arch/sparc/mm/iommu.c +++ b/arch/sparc/mm/iommu.c @@ -174,7 +174,7 @@ static void iommu_flush_iotlb(iopte_t *iopte, unsigned int niopte) } } -static u32 iommu_get_one(struct device *dev, struct page *page, int npages) +static u32 iommu_get_one(struct device *dev, unsigned long pfn, int npages) { struct iommu_struct *iommu = dev-archdata.iommu; int ioptex; @@ -183,7 +183,7 @@ static u32 iommu_get_one(struct device *dev, struct page *page, int npages) int i; /* page color = pfn of page */ - ioptex = bit_map_string_get(iommu-usemap, npages, page_to_pfn(page)); + ioptex = bit_map_string_get(iommu-usemap, npages, pfn); if (ioptex 0) panic(iommu out); busa0 = iommu-start + (ioptex PAGE_SHIFT); @@ -192,11 +192,11 @@ static u32 iommu_get_one(struct device *dev, struct page *page, int npages) busa = busa0; iopte = iopte0; for (i = 0; i npages; i++) { - iopte_val(*iopte) = MKIOPTE(page_to_pfn(page), IOPERM); + iopte_val(*iopte) = MKIOPTE(pfn, IOPERM); iommu_invalidate_page(iommu-regs, busa); busa += PAGE_SIZE; iopte++; - page++; + pfn++; } iommu_flush_iotlb(iopte0, npages); @@ -214,7 +214,7 @@ static u32 iommu_get_scsi_one(struct device *dev, char *vaddr, unsigned int len) off = (unsigned long)vaddr ~PAGE_MASK; npages = (off + len + PAGE_SIZE-1) PAGE_SHIFT; page = virt_to_page((unsigned long)vaddr PAGE_MASK); - busa = iommu_get_one(dev, page, npages); + busa = iommu_get_one(dev, page_to_pfn(page), npages); return busa + off; } @@ -243,7 +243,7 @@ static void iommu_get_scsi_sgl_gflush(struct device *dev, struct scatterlist *sg while (sz != 0) { --sz; n = (sg-length + sg-offset + PAGE_SIZE-1) PAGE_SHIFT; - sg-dma_address = iommu_get_one(dev, sg_page(sg), n) + sg-offset; + sg-dma_address = iommu_get_one(dev, sg_pfn(sg), n) + sg-offset; sg-dma_length = sg-length; sg = sg_next(sg); } @@ -264,7 +264,8 @@ static void iommu_get_scsi_sgl_pflush(struct device *dev, struct scatterlist *sg * XXX Is this a good assumption? * XXX What if someone else unmaps it here and races us? */ - if ((page = (unsigned long) page_address(sg_page(sg))) != 0) { + if (sg_has_page(sg) + (page = (unsigned long) page_address(sg_page(sg))) != 0) { for (i = 0; i n; i++) { if (page != oldpage) { /* Already flushed? */ flush_page_for_dma(page); @@ -274,7 +275,7 @@ static void iommu_get_scsi_sgl_pflush(struct device *dev, struct scatterlist *sg } } - sg-dma_address = iommu_get_one(dev, sg_page(sg), n) + sg-offset; + sg-dma_address = iommu_get_one(dev, sg_pfn(sg), n) + sg-offset; sg-dma_length = sg-length; sg = sg_next(sg); } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 08/31] c6x: handle page-less SG entries
Use sg_phys() instead of virt_to_phys(sg_virt(sg)) so that we don't require a kernel virtual address. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/c6x/kernel/dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/c6x/kernel/dma.c b/arch/c6x/kernel/dma.c index ab7b12d..79cae03 100644 --- a/arch/c6x/kernel/dma.c +++ b/arch/c6x/kernel/dma.c @@ -68,8 +68,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sglist, int i; for_each_sg(sglist, sg, nents, i) - sg-dma_address = dma_map_single(dev, sg_virt(sg), sg-length, -dir); + sg-dma_address = sg_phys(sg); debug_dma_map_sg(dev, sglist, nents, nents, dir); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 13/31] sparc/ldc: handle page-less SG entries
Use sg_phys(sg) PAGE_MASK instead of page_to_pfn(sg_page(sg)) PAGE_SHIFT to get at the page-aligned physical address ofa SG entry, so that we don't require a page backing for SG entries. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/sparc/kernel/ldc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c index 1ae5eb1..0a29974 100644 --- a/arch/sparc/kernel/ldc.c +++ b/arch/sparc/kernel/ldc.c @@ -2051,7 +2051,7 @@ static void fill_cookies(struct cookie_state *sp, unsigned long pa, static int sg_count_one(struct scatterlist *sg) { - unsigned long base = page_to_pfn(sg_page(sg)) PAGE_SHIFT; + unsigned long base = sg_phys(sg) PAGE_MASK; long len = sg-length; if ((sg-offset | len) (8UL - 1)) @@ -2114,7 +2114,7 @@ int ldc_map_sg(struct ldc_channel *lp, state.nc = 0; for_each_sg(sg, s, num_sg, i) { - fill_cookies(state, page_to_pfn(sg_page(s)) PAGE_SHIFT, + fill_cookies(state, sg_phys(s) PAGE_MASK, s-offset, s-length); } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 30/31] intel-iommu: handle page-less SG entries
Just remove a BUG_ON, the code handles them just fine as-is. Signed-off-by: Christoph Hellwig h...@lst.de --- drivers/iommu/intel-iommu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 3541d65..ae10573 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -3622,7 +3622,6 @@ static int intel_nontranslate_map_sg(struct device *hddev, struct scatterlist *sg; for_each_sg(sglist, sg, nelems, i) { - BUG_ON(!sg_page(sg)); sg-dma_address = sg_phys(sg); sg-dma_length = sg-length; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 29/31] parisc: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/parisc/kernel/pci-dma.c | 29 ++--- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c index b9402c9..6cad0e0 100644 --- a/arch/parisc/kernel/pci-dma.c +++ b/arch/parisc/kernel/pci-dma.c @@ -483,11 +483,13 @@ static int pa11_dma_map_sg(struct device *dev, struct scatterlist *sglist, int n BUG_ON(direction == DMA_NONE); for_each_sg(sglist, sg, nents, i) { - unsigned long vaddr = (unsigned long)sg_virt(sg); - - sg_dma_address(sg) = (dma_addr_t) virt_to_phys(vaddr); + sg_dma_address(sg) = sg_phys(sg); sg_dma_len(sg) = sg-length; - flush_kernel_dcache_range(vaddr, sg-length); + + if (sg_has_page(sg)) { + flush_kernel_dcache_range((unsigned long)sg_virt(sg), + sg-length); + } } return nents; } @@ -504,9 +506,10 @@ static void pa11_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, in /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ - for_each_sg(sglist, sg, nents, i) - flush_kernel_vmap_range(sg_virt(sg), sg-length); - return; + for_each_sg(sglist, sg, nents, i) { + if (sg_has_page(sg)) + flush_kernel_vmap_range(sg_virt(sg), sg-length); + } } static void pa11_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, unsigned long offset, size_t size, enum dma_data_direction direction) @@ -530,8 +533,10 @@ static void pa11_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sgl /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ - for_each_sg(sglist, sg, nents, i) - flush_kernel_vmap_range(sg_virt(sg), sg-length); + for_each_sg(sglist, sg, nents, i) { + if (sg_has_page(sg)) + flush_kernel_vmap_range(sg_virt(sg), sg-length); + } } static void pa11_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int nents, enum dma_data_direction direction) @@ -541,8 +546,10 @@ static void pa11_dma_sync_sg_for_device(struct device *dev, struct scatterlist * /* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ - for_each_sg(sglist, sg, nents, i) - flush_kernel_vmap_range(sg_virt(sg), sg-length); + for_each_sg(sglist, sg, nents, i) { + if (sg_has_page(sg)) + flush_kernel_vmap_range(sg_virt(sg), sg-length); + } } struct hppa_dma_ops pcxl_dma_ops = { -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 27/31] mips: handle page-less SG entries
Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly. To do this consolidate the two platform callouts using pages and virtual addresses into a single one using a physical address. Signed-off-by: Christoph Hellwig h...@lst.de --- arch/mips/bmips/dma.c | 9 ++-- arch/mips/include/asm/mach-ath25/dma-coherence.h | 10 ++--- arch/mips/include/asm/mach-bmips/dma-coherence.h | 4 ++-- .../include/asm/mach-cavium-octeon/dma-coherence.h | 11 ++ arch/mips/include/asm/mach-generic/dma-coherence.h | 12 +++ arch/mips/include/asm/mach-ip27/dma-coherence.h| 16 +++--- arch/mips/include/asm/mach-ip32/dma-coherence.h| 19 +++- arch/mips/include/asm/mach-jazz/dma-coherence.h| 11 +++--- .../include/asm/mach-loongson64/dma-coherence.h| 16 +++--- arch/mips/mm/dma-default.c | 25 -- 10 files changed, 37 insertions(+), 96 deletions(-) diff --git a/arch/mips/bmips/dma.c b/arch/mips/bmips/dma.c index 04790f4..13fc891 100644 --- a/arch/mips/bmips/dma.c +++ b/arch/mips/bmips/dma.c @@ -52,14 +52,9 @@ static dma_addr_t bmips_phys_to_dma(struct device *dev, phys_addr_t pa) return pa; } -dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size) +dma_addr_t plat_map_dma_mem(struct device *dev, phys_addr_t phys, size_t size) { - return bmips_phys_to_dma(dev, virt_to_phys(addr)); -} - -dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page) -{ - return bmips_phys_to_dma(dev, page_to_phys(page)); + return bmips_phys_to_dma(dev, phys); } unsigned long plat_dma_addr_to_phys(struct device *dev, dma_addr_t dma_addr) diff --git a/arch/mips/include/asm/mach-ath25/dma-coherence.h b/arch/mips/include/asm/mach-ath25/dma-coherence.h index d5defdd..4330de6 100644 --- a/arch/mips/include/asm/mach-ath25/dma-coherence.h +++ b/arch/mips/include/asm/mach-ath25/dma-coherence.h @@ -31,15 +31,9 @@ static inline dma_addr_t ath25_dev_offset(struct device *dev) } static inline dma_addr_t -plat_map_dma_mem(struct device *dev, void *addr, size_t size) +plat_map_dma_mem(struct device *dev, phys_addr_t phys, size_t size) { - return virt_to_phys(addr) + ath25_dev_offset(dev); -} - -static inline dma_addr_t -plat_map_dma_mem_page(struct device *dev, struct page *page) -{ - return page_to_phys(page) + ath25_dev_offset(dev); + return phys + ath25_dev_offset(dev); } static inline unsigned long diff --git a/arch/mips/include/asm/mach-bmips/dma-coherence.h b/arch/mips/include/asm/mach-bmips/dma-coherence.h index d29781f..1b9a7f4 100644 --- a/arch/mips/include/asm/mach-bmips/dma-coherence.h +++ b/arch/mips/include/asm/mach-bmips/dma-coherence.h @@ -21,8 +21,8 @@ struct device; -extern dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size); -extern dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page); +extern dma_addr_t plat_map_dma_mem(struct device *dev, phys_addr_t phys, + size_t size); extern unsigned long plat_dma_addr_to_phys(struct device *dev, dma_addr_t dma_addr); diff --git a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h index 460042e..d0988c7 100644 --- a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +++ b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h @@ -19,15 +19,8 @@ struct device; extern void octeon_pci_dma_init(void); -static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, - size_t size) -{ - BUG(); - return 0; -} - -static inline dma_addr_t plat_map_dma_mem_page(struct device *dev, - struct page *page) +static inline dma_addr_t plat_map_dma_mem(struct device *dev, phys_addr_t phys, + size_t size) { BUG(); return 0; diff --git a/arch/mips/include/asm/mach-generic/dma-coherence.h b/arch/mips/include/asm/mach-generic/dma-coherence.h index 0f8a354..2dfb133 100644 --- a/arch/mips/include/asm/mach-generic/dma-coherence.h +++ b/arch/mips/include/asm/mach-generic/dma-coherence.h @@ -11,16 +11,10 @@ struct device; -static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, - size_t size) +static inline dma_addr_t plat_map_dma_mem(struct device *dev, phys_addr_t phys, + size_t size) { - return virt_to_phys(addr); -} - -static inline dma_addr_t plat_map_dma_mem_page(struct device *dev, - struct page *page) -{ - return page_to_phys(page); + return phys; } static inline unsigned long plat_dma_addr_to_phys(struct device *dev, diff --git a/arch/mips/include/asm/mach-ip27/dma-coherence.h b/arch/mips/include/asm/mach-ip27/dma-coherence.h index 1daa644..2578b9d 100644 --- a/arch/mips/include/asm/mach-ip27/dma-coherence.h +++
[PATCH 31/31] dma-mapping-common: skip kmemleak checks for page-less SG entries
Signed-off-by: Christoph Hellwig h...@lst.de --- include/asm-generic/dma-mapping-common.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h index 940d5ec..afc3eaf 100644 --- a/include/asm-generic/dma-mapping-common.h +++ b/include/asm-generic/dma-mapping-common.h @@ -51,8 +51,10 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int i, ents; struct scatterlist *s; - for_each_sg(sg, s, nents, i) - kmemcheck_mark_initialized(sg_virt(s), s-length); + for_each_sg(sg, s, nents, i) { + if (sg_has_page(s)) + kmemcheck_mark_initialized(sg_virt(s), s-length); + } BUG_ON(!valid_dma_direction(dir)); ents = ops-map_sg(dev, sg, nents, dir, attrs); BUG_ON(ents 0); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] media: videobuf2-dc: set properly dma_max_segment_size
If device has no DMA max_seg_size set, we assume that there is no limit and it is safe to force it to use DMA_BIT_MASK(32) as max_seg_size to let DMA-mapping API always create contiguous mappings in DMA address space. This is essential for all devices, which use dma-contig videobuf2 memory allocator. Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com --- Changelog: v2: - set max segment size only if a new dma params structure has been allocated, as suggested by Laurent Pinchart --- drivers/media/v4l2-core/videobuf2-dma-contig.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 94c1e64..455e925 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c @@ -862,6 +862,21 @@ EXPORT_SYMBOL_GPL(vb2_dma_contig_memops); void *vb2_dma_contig_init_ctx(struct device *dev) { struct vb2_dc_conf *conf; + int err; + + /* +* if device has no max_seg_size set, we assume that there is no limit +* and force it to DMA_BIT_MASK(32) to always use contiguous mappings +* in DMA address space +*/ + if (!dev-dma_parms) { + dev-dma_parms = kzalloc(sizeof(*dev-dma_parms), GFP_KERNEL); + if (!dev-dma_parms) + return ERR_PTR(-ENOMEM); + err = dma_set_max_seg_size(dev, DMA_BIT_MASK(32)); + if (err) + return ERR_PTR(err); + } conf = kzalloc(sizeof *conf, GFP_KERNEL); if (!conf) -- 1.9.2 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 19/31] arc: handle page-less SG entries
On Wednesday 12 August 2015 12:39 PM, Christoph Hellwig wrote: Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly. Signed-off-by: Christoph Hellwig h...@lst.de With a minor nit below. Acked-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/include/asm/dma-mapping.h | 26 +++--- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/arc/include/asm/dma-mapping.h b/arch/arc/include/asm/dma-mapping.h index 2d28ba9..42eb526 100644 --- a/arch/arc/include/asm/dma-mapping.h +++ b/arch/arc/include/asm/dma-mapping.h @@ -108,9 +108,13 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, struct scatterlist *s; int i; - for_each_sg(sg, s, nents, i) - s-dma_address = dma_map_page(dev, sg_page(s), s-offset, -s-length, dir); + for_each_sg(sg, s, nents, i) { + if (sg_has_page(s)) { + _dma_cache_sync((unsigned long)sg_virt(s), s-length, + dir); + } + s-dma_address = sg_phys(s); + } return nents; } @@ -163,8 +167,12 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sglist, int nelems, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nelems, i) - _dma_cache_sync((unsigned int)sg_virt(sg), sg-length, dir); + for_each_sg(sglist, sg, nelems, i) { + if (sg_has_page(sg)) { + _dma_cache_sync((unsigned int)sg_virt(sg), sg-length, + dir); + } + } } static inline void @@ -174,8 +182,12 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nelems, i) - _dma_cache_sync((unsigned int)sg_virt(sg), sg-length, dir); + for_each_sg(sglist, sg, nelems, i) { + if (sg_has_page(sg)) { + _dma_cache_sync((unsigned int)sg_virt(sg), sg-length, + dir); For consistency, could u please fix the left alignment of @dir above - another tab perhaps ? + } + } } static inline int dma_supported(struct device *dev, u64 dma_mask) -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 20/31] avr32: handle page-less SG entries
Around Wed 12 Aug 2015 09:05:39 +0200 or thereabout, Christoph Hellwig wrote: Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly, bypassing the noop page_to_bus. Signed-off-by: Christoph Hellwig h...@lst.de Acked-by: Hans-Christian Egtvedt egtv...@samfundet.no --- arch/avr32/include/asm/dma-mapping.h | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/avr32/include/asm/dma-mapping.h b/arch/avr32/include/asm/dma-mapping.h index ae7ac92..a662ce2 100644 --- a/arch/avr32/include/asm/dma-mapping.h +++ b/arch/avr32/include/asm/dma-mapping.h @@ -216,11 +216,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, struct scatterlist *sg; for_each_sg(sglist, sg, nents, i) { - char *virt; - - sg-dma_address = page_to_bus(sg_page(sg)) + sg-offset; - virt = sg_virt(sg); - dma_cache_sync(dev, virt, sg-length, direction); + sg-dma_address = sg_phys(sg); + if (sg_has_page(sg)) + dma_cache_sync(dev, sg_virt(sg), sg-length, direction); } return nents; @@ -328,8 +326,10 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sglist, int i; struct scatterlist *sg; - for_each_sg(sglist, sg, nents, i) - dma_cache_sync(dev, sg_virt(sg), sg-length, direction); + for_each_sg(sglist, sg, nents, i) { + if (sg_has_page(sg)) + dma_cache_sync(dev, sg_virt(sg), sg-length, direction); + } } /* Now for the API extensions over the pci_ one */ -- mvh Hans-Christian Egtvedt -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 30/31] intel-iommu: handle page-less SG entries
On Wed, 2015-08-12 at 09:05 +0200, Christoph Hellwig wrote: Just remove a BUG_ON, the code handles them just fine as-is. Signed-off-by: Christoph Hellwig h...@lst.de Acked-by: David Woodhouse david.woodho...@intel.com -- David WoodhouseOpen Source Technology Centre david.woodho...@intel.com Intel Corporation smime.p7s Description: S/MIME cryptographic signature
Re: [PATCH] Staging: media/bcm2048: Fix line over 80 characters warning as detected by checkpatch.pl
On Wednesday 12 August 2015 11:12:49 Shah, Yash (Y.) wrote: From: Yash Shah ysh...@visteon.com Fix line over 80 characters warning as detected by checkpatch.pl Signed-off-by: Yash Shah ysh...@visteon.com --- drivers/staging/media/bcm2048/radio-bcm2048.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index 8bc68e2..d36350e 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -2243,7 +2243,8 @@ static ssize_t bcm2048_fops_read(struct file *file, char __user *buf, tmpbuf[i] = bdev-rds_info.radio_text[bdev-rd_index+i+2]; tmpbuf[i+1] = bdev-rds_info.radio_text[bdev-rd_index+i+1]; - tmpbuf[i+2] = (bdev-rds_info.radio_text[bdev-rd_index + i] 0xf0) 4; + tmpbuf[i+2] = (bdev-rds_info.radio_text[bdev-rd_index + i] + 0xf0) 4; if ((bdev-rds_info.radio_text[bdev-rd_index+i] BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE) tmpbuf[i+2] |= 0x80; Hi! I think that code after this change is less readable as before. -- Pali Rohár pali.ro...@gmail.com -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 29/31] parisc: handle page-less SG entries
On Wed, Aug 12, 2015 at 12:05 AM, Christoph Hellwig h...@lst.de wrote: Make all cache invalidation conditional on sg_has_page() and use sg_phys to get the physical address directly. So this worries me a bit (I'm just reacting to one random patch in the series). The reason? I think this wants a big honking comment somewhere saying non-sg_page accesses are not necessarily cache coherent). Now, I don't think that's _wrong_, but it's an important distinction: if you look up pages in the page tables directly, there's a very subtle difference between then saving just the pfn and saving the struct page of the result. On sane architectures, this whole cache flushing thing doesn't matter. Which just means that it's going to be even more subtle on the odd broken ones.. I'm assuming that anybody who wants to use the page-less scatter-gather lists always does so on memory that isn't actually virtually mapped at all, or only does so on sane architectures that are cache coherent at a physical level, but I'd like that assumption *documented* somewhere. (And maybe it is, and I just didn't get to that patch yet) Linus -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 31/31] dma-mapping-common: skip kmemleak checks for page-less SG entries
Christoph, On 12 August 2015 at 08:05, Christoph Hellwig h...@lst.de wrote: Signed-off-by: Christoph Hellwig h...@lst.de --- include/asm-generic/dma-mapping-common.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h index 940d5ec..afc3eaf 100644 --- a/include/asm-generic/dma-mapping-common.h +++ b/include/asm-generic/dma-mapping-common.h @@ -51,8 +51,10 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int i, ents; struct scatterlist *s; - for_each_sg(sg, s, nents, i) - kmemcheck_mark_initialized(sg_virt(s), s-length); + for_each_sg(sg, s, nents, i) { + if (sg_has_page(s)) + kmemcheck_mark_initialized(sg_virt(s), s-length); + } Just a nitpick for the subject, it should say kmemcheck rather than kmemleak (different features ;)). -- Catalin -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] v4l2grab: print function name and ioctl number on failure
This makes the failure error message a little more useful. Signed-off-by: Baruch Siach bar...@tkos.co.il --- contrib/test/v4l2grab.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/test/v4l2grab.c b/contrib/test/v4l2grab.c index 3e1be3de6353..778c51cc391a 100644 --- a/contrib/test/v4l2grab.c +++ b/contrib/test/v4l2grab.c @@ -43,7 +43,8 @@ static void xioctl(int fh, unsigned long int request, void *arg) } while (r == -1 ((errno == EINTR) || (errno == EAGAIN))); if (r == -1) { - fprintf(stderr, error %d, %s\n, errno, strerror(errno)); + fprintf(stderr, %s(%lu): error %d, %s\n, __func__, + _IOC_NR(request), errno, strerror(errno)); exit(EXIT_FAILURE); } } -- 2.5.0 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RFC: prepare for struct scatterlist entries without page backing
On Wed, 2015-08-12 at 09:05 +0200, Christoph Hellwig wrote: Dan Williams started to look into addressing I/O to and from Persistent Memory in his series from June: http://thread.gmane.org/gmane.linux.kernel.cross-arch/27944 I've started looking into DMA mapping of these SGLs specifically instead of the map_pfn method in there. In addition to supporting NVDIMM backed I/O I also suspect this would be highly useful for media drivers that go through nasty hoops to be able to DMA from/to their ioremapped regions, with vb2_dc_get_userptr in drivers/media/v4l2-core/videobuf2-dma-contig.c being a prime example for the unsafe hacks currently used. It turns out most DMA mapping implementation can handle SGLs without page structures with some fairly simple mechanical work. Most of it is just about consistently using sg_phys. For implementations that need to flush caches we need a new helper that skips these cache flushes if a entry doesn't have a kernel virtual address. However the ccio (parisc) and sba_iommu (parisc ia64) IOMMUs seem to be operate mostly on virtual addresses. It's a fairly odd concept that I don't fully grasp, so I'll need some help with those if we want to bring this forward. I can explain that. I think this doesn't apply to ia64 because it's cache is PIPT, but on parisc, we have a VIPT cache. On normal physically indexed architectures, when the iommu sees a DMA transfer to/from physical memory, it also notifies the CPU to flush the internal CPU caches of those lines. This is usually an interlocking step of the transfer to make sure the page is coherent before transfer to/from the device (it's why the ia32 for instance is a coherent architecture). Because the system is physically indexed, there's no need to worry about aliases. On Virtually Indexed systems, like parisc, there is an aliasing problem. The CCIO iommu unit (and all other iommu systems on parisc) have what's called a local coherence index (LCI). You program it as part of the IOMMU page table and it tells the system which Virtual line in the cache to flush as part of the IO transaction, thus still ensuring cache coherence. That's why we have to know the virtual as well as physical addresses for the page. The problem we have in Linux is that we have two virtual addresses, which are often incoherent aliases: the user virtual address and a kernel virtual address but we can only make the page coherent with a single alias (only one LCI). The way I/O on Linux currently works is that get_user_pages actually flushes the user virtual address, so that's expected to be coherent, so the address we program into the VCI is the kernel virtual address. Usually nothing in the kernel has ever touched the page, so there's nothing to flush, but we do it just in case. In theory, for these non kernel page backed SG entries, we can make the process more efficient by not flushing in gup and instead programming the user virtual address into the local coherence index. However, simply zeroing the LCI will also work (except that poor VI zero line will get flushed repeatedly, so it's probably best to pick a known untouched line in the kernel). James -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 31/31] dma-mapping-common: skip kmemleak checks for page-less SG entries
On Wed, Aug 12, 2015 at 12:05 AM, Christoph Hellwig h...@lst.de wrote: + for_each_sg(sg, s, nents, i) { + if (sg_has_page(s)) + kmemcheck_mark_initialized(sg_virt(s), s-length); + } [ Again, I'm responding to one random patch - this pattern was in other patches too. ] A question: do we actually expect to mix page-less and pageful SG entries in the same SG list? How does that happen? (I'm not saying it can't, I'm just wondering where people expect this to happen). IOW, maybe it would be valid to have a rule saying a SG list is either all pageful or pageless, never mixed, and then have the if statement outside the loop rather than inside. Linus -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] [media] m2m: fix bad unlock balance
Hello Hans, I'm sorry for a delay. Once again I've been busy with some other internal stuff. On 2015-07-28 11:02, Hans Verkuil wrote: Kamil, Marek, Why does v4l2_m2m_poll unlock and lock in that function? I've checked the code and indeed the poll_wait() function doesn't do anything that should not be done with queue mutex being taken. I don't remember if it was always like that. You are right that the unlocklock code should be removed. Zahari is right that the locking is unbalanced, but I don't see the reason for the unlock/lock sequence in the first place. I'm wondering if that shouldn't just be removed. Am I missing something? Instead, I would expect to see a spin_lock_irqsave(src/dst_q-done_lock, flags) around the list_empty(src/dst_q-done_list) calls. Indeed, that's another thing that should be fixed in this function. I looks that commit c16218402a000bb25c1277c43ae98c11bcb59bd1 ([media] videobuf2: return -EPIPE from DQBUF after the last buffer) is the root cause of both issues (unballanced locking and lack of spinlock protection), while the unnecessary queue unlock/lock sequence was there from the beginning. Regards, Hans On 07/08/2015 03:37 PM, Zahari Doychev wrote: This commit fixes bad unlock balance when polling. v4l2_m2m_poll is called with mutex hold but the function releases the mutex and returns. This leads to the bad unlock because after the call of v4l2_m2m_poll in v4l2_m2m_fop_poll the mutex is again unlocked. This patch makes sure that the v4l2_m2m_poll returns always with balanced locks. [ 144.990873] = [ 144.995584] [ BUG: bad unlock balance detected! ] [ 145.000301] 4.1.0-00137-ga105070 #98 Tainted: GW [ 145.006140] - [ 145.010851] demux:sink/487 is trying to release lock (dev-dev_mutex) at: [ 145.017785] [808cc578] mutex_unlock+0x18/0x1c [ 145.022322] but there are no more locks to release! [ 145.027205] [ 145.027205] other info that might help us debug this: [ 145.033741] no locks held by demux:sink/487. [ 145.038015] [ 145.038015] stack backtrace: [ 145.042385] CPU: 2 PID: 487 Comm: demux:sink Tainted: GW 4.1.0-00137-ga105070 #98 [ 145.051089] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) [ 145.057622] Backtrace: [ 145.060102] [80014a4c] (dump_backtrace) from [80014cc4] (show_stack+0x20/0x24) [ 145.067679] r6:80cedf78 r5: r4: r3: [ 145.073421] [80014ca4] (show_stack) from [808c61e0] (dump_stack+0x8c/0xa4) [ 145.080661] [808c6154] (dump_stack) from [80072b64] (print_unlock_imbalance_bug+0xb8/0xe8) [ 145.089277] r6:808cc578 r5:ac6cd050 r4:ac38e400 r3:0001 [ 145.095020] [80072aac] (print_unlock_imbalance_bug) from [80077db4] (lock_release+0x1a4/0x250) [ 145.103983] r6:808cc578 r5:ac6cd050 r4:ac38e400 r3: [ 145.109728] [80077c10] (lock_release) from [808cc470] (__mutex_unlock_slowpath+0xc4/0x1b4) [ 145.118344] r9:acb27a41 r8: r7:81553814 r6:808cc578 r5:60030013 r4:ac6cd01c [ 145.126190] [808cc3ac] (__mutex_unlock_slowpath) from [808cc578] (mutex_unlock+0x18/0x1c) [ 145.134720] r7: r6:aced7cd4 r5:0041 r4:acb87800 [ 145.140468] [808cc560] (mutex_unlock) from [805a98b8] (v4l2_m2m_fop_poll+0x5c/0x64) [ 145.148494] [805a985c] (v4l2_m2m_fop_poll) from [805955a0] (v4l2_poll+0x6c/0xa0) [ 145.156243] r6:aced7bec r5: r4:ac6cc380 r3:805a985c [ 145.161991] [80595534] (v4l2_poll) from [80156edc] (do_sys_poll+0x230/0x4c0) [ 145.169391] r5: r4:aced7be4 [ 145.173013] [80156cac] (do_sys_poll) from [801574a8] (SyS_ppoll+0x1d4/0x1fc) [ 145.180414] r10: r9:aced6000 r8: r7: r6:75c04538 r5:0002 [ 145.188338] r4: [ 145.190906] [801572d4] (SyS_ppoll) from [800108c0] (ret_fast_syscall+0x0/0x54) [ 145.198481] r8:80010aa4 r7:0150 r6:75c04538 r5:0002 r4:0008 Signed-off-by: Zahari Doychev zahari.doyc...@linux.com --- drivers/media/v4l2-core/v4l2-mem2mem.c | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index dc853e5..5392fb4 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -583,16 +583,8 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, if (list_empty(src_q-done_list)) poll_wait(file, src_q-done_wq, wait); - if (list_empty(dst_q-done_list)) { - /* -* If the last buffer was dequeued from the capture queue, -* return immediately. DQBUF will return -EPIPE. -*/ - if (dst_q-last_buffer_dequeued) - return rc | POLLIN | POLLRDNORM; - + if (list_empty(dst_q-done_list) !dst_q-last_buffer_dequeued) poll_wait(file, dst_q-done_wq, wait); - } if
[PATCH] Staging: media/bcm2048: Fix line over 80 characters warning as detected by checkpatch.pl
From: Yash Shah ysh...@visteon.com Fix line over 80 characters warning as detected by checkpatch.pl Signed-off-by: Yash Shah ysh...@visteon.com --- drivers/staging/media/bcm2048/radio-bcm2048.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index 8bc68e2..d36350e 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -2243,7 +2243,8 @@ static ssize_t bcm2048_fops_read(struct file *file, char __user *buf, tmpbuf[i] = bdev-rds_info.radio_text[bdev-rd_index+i+2]; tmpbuf[i+1] = bdev-rds_info.radio_text[bdev-rd_index+i+1]; - tmpbuf[i+2] = (bdev-rds_info.radio_text[bdev-rd_index + i] 0xf0) 4; + tmpbuf[i+2] = (bdev-rds_info.radio_text[bdev-rd_index + i] + 0xf0) 4; if ((bdev-rds_info.radio_text[bdev-rd_index+i] BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE) tmpbuf[i+2] |= 0x80; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 16/31] s390: handle page-less SG entries
On Wed, 12 Aug 2015, Christoph Hellwig wrote: Use sg_phys() instead of page_to_phys(sg_page(sg)) so that we don't require a page structure for all DMA memory. Signed-off-by: Christoph Hellwig h...@lst.de Acked-by: Sebastian Ott seb...@linux.vnet.ibm.com --- arch/s390/pci/pci_dma.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index 6fd8d58..aae5a47 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -272,14 +272,13 @@ int dma_set_mask(struct device *dev, u64 mask) } EXPORT_SYMBOL_GPL(dma_set_mask); -static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, - unsigned long offset, size_t size, +static dma_addr_t s390_dma_map_phys(struct device *dev, unsigned long pa, + size_t size, enum dma_data_direction direction, struct dma_attrs *attrs) { struct zpci_dev *zdev = get_zdev(to_pci_dev(dev)); unsigned long nr_pages, iommu_page_index; - unsigned long pa = page_to_phys(page) + offset; int flags = ZPCI_PTE_VALID; dma_addr_t dma_addr; @@ -301,7 +300,7 @@ static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, if (!dma_update_trans(zdev, pa, dma_addr, size, flags)) { atomic64_add(nr_pages, zdev-mapped_pages); - return dma_addr + (offset ~PAGE_MASK); + return dma_addr + (pa ~PAGE_MASK); } out_free: @@ -312,6 +311,16 @@ out_err: return DMA_ERROR_CODE; } +static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, + unsigned long offset, size_t size, + enum dma_data_direction direction, + struct dma_attrs *attrs) +{ + unsigned long pa = page_to_phys(page) + offset; + + return s390_dma_map_phys(dev, pa, size, direction, attrs); +} + static void s390_dma_unmap_pages(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction, struct dma_attrs *attrs) @@ -384,8 +393,7 @@ static int s390_dma_map_sg(struct device *dev, struct scatterlist *sg, int i; for_each_sg(sg, s, nr_elements, i) { - struct page *page = sg_page(s); - s-dma_address = s390_dma_map_pages(dev, page, s-offset, + s-dma_address = s390_dma_map_phys(dev, sg_phys(s), s-length, dir, NULL); if (!dma_mapping_error(dev, s-dma_address)) { s-dma_length = s-length; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RFC: prepare for struct scatterlist entries without page backing
On 08/12/2015 10:05 AM, Christoph Hellwig wrote: Dan Williams started to look into addressing I/O to and from Persistent Memory in his series from June: http://thread.gmane.org/gmane.linux.kernel.cross-arch/27944 I've started looking into DMA mapping of these SGLs specifically instead of the map_pfn method in there. In addition to supporting NVDIMM backed I/O I also suspect this would be highly useful for media drivers that go through nasty hoops to be able to DMA from/to their ioremapped regions, with vb2_dc_get_userptr in drivers/media/v4l2-core/videobuf2-dma-contig.c being a prime example for the unsafe hacks currently used. The support I have suggested and submitted for zone-less sections. (In my add_persistent_memory() patchset) Would work perfectly well and transparent for all such multimedia cases. (All hacks removed). In fact I have loaded pmem (with-pages) on a VRAM a few times and it is great easy fun. (I wanted to experiment with cached memory over a pcie) It turns out most DMA mapping implementation can handle SGLs without page structures with some fairly simple mechanical work. Most of it is just about consistently using sg_phys. For implementations that need to flush caches we need a new helper that skips these cache flushes if a entry doesn't have a kernel virtual address. However the ccio (parisc) and sba_iommu (parisc ia64) IOMMUs seem to be operate mostly on virtual addresses. It's a fairly odd concept that I don't fully grasp, so I'll need some help with those if we want to bring this forward. Additional this series skips ARM entirely for now. The reason is that most arm implementations of the .map_sg operation just iterate over all entries and call -map_page for it, which means we'd need to convert those to a -map_pfn similar to Dan's previous approach. All this endless work for nothing more than uglyfing the Kernel, and It will never end. When a real and fully working solution is right here for more then a year. If you are really up for a deep audit and a mammoth testing effort, why not do a more worthy, and order of magnitude smaller work and support 2M and 1G variable sized pages. All the virtual-vs-phisical-vs-caching just works. Most of the core work is there. Block layer and lots of other subsytems already support sending a single page-pointer with bvec_offset bvec_len bigger then 4K. Other system will be small fixes sprinkled around but not at all this endless stream of subsystem after another of patches. And for why. The novelty of pages is the section object, the section is reached from page* from virtual as well as physical planes. And is a center that translate from all plains to all plains. You keep this concept only make 2M-page sections and 1G-page sections. It is a bit of work but is worth while, and accelerating tremendously lots of workloads. Not like this abomination which only branches things more and more, and making things fatter and slower. It all feels like a typhoon, the inertia of tones and tons of men hours work, in a huge wave. How will you ever stop such a rushing mass. I'm trying to dock under but, surly it makes me sad. Thanks Boaz -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] tc358743: don't use variable length array for I2C writes
On 08/11/2015 05:18 PM, Mauro Carvalho Chehab wrote: drivers/media/i2c/tc358743.c:148:19: warning: Variable length array is used. As the maximum size is 1026, we can't use dynamic var, as it would otherwise spend 1056 bytes of the stack at i2c_wr() function. So, allocate a buffer with the allowed maximum size together with the state var. Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index 2e926317d7e9..fe42c9a1cb78 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -59,6 +59,9 @@ MODULE_LICENSE(GPL); #define EDID_NUM_BLOCKS_MAX 8 #define EDID_BLOCK_SIZE 128 +/* Max transfer size done by I2C transfer functions */ +#define MAX_XFER_SIZE (EDID_NUM_BLOCKS_MAX * EDID_BLOCK_SIZE + 2) + static const struct v4l2_dv_timings_cap tc358743_timings_cap = { .type = V4L2_DV_BT_656_1120, /* keep this initialization for compatibility with GCC 4.4.6 */ @@ -94,6 +97,9 @@ struct tc358743_state { /* edid */ u8 edid_blocks_written; + /* used by i2c_wr() */ + u8 wr_data[MAX_XFER_SIZE]; + struct v4l2_dv_timings timings; u32 mbus_fmt_code; @@ -143,9 +149,13 @@ static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n) { struct tc358743_state *state = to_state(sd); struct i2c_client *client = state-i2c_client; + u8 *data = state-wr_data; int err, i; struct i2c_msg msg; - u8 data[2 + n]; + + if ((2 + n) sizeof(state-wr_data)) + v4l2_warn(sd, i2c wr reg=%04x: len=%d is too big!\n, + reg, 2 + n); msg.addr = client-addr; msg.buf = data; Acked-by: Mats Randgaard matra...@cisco.com -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Staging: media/bcm2048: Fix line over 80 characters warning as detected by checkpatch.pl
On Wed, Aug 12, 2015 at 1:19 PM, Pali Rohár pali.ro...@gmail.com wrote: On Wednesday 12 August 2015 11:12:49 Shah, Yash (Y.) wrote: From: Yash Shah ysh...@visteon.com Fix line over 80 characters warning as detected by checkpatch.pl Signed-off-by: Yash Shah ysh...@visteon.com --- drivers/staging/media/bcm2048/radio-bcm2048.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index 8bc68e2..d36350e 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -2243,7 +2243,8 @@ static ssize_t bcm2048_fops_read(struct file *file, char __user *buf, tmpbuf[i] = bdev-rds_info.radio_text[bdev-rd_index+i+2]; tmpbuf[i+1] = bdev-rds_info.radio_text[bdev-rd_index+i+1]; - tmpbuf[i+2] = (bdev-rds_info.radio_text[bdev-rd_index + i] 0xf0) 4; + tmpbuf[i+2] = (bdev-rds_info.radio_text[bdev-rd_index + i] + 0xf0) 4; if ((bdev-rds_info.radio_text[bdev-rd_index+i] BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE) tmpbuf[i+2] |= 0x80; Hi! I think that code after this change is less readable as before. I agree. I would do something about 'bdev-rds_info.radio_text' instead and shorten all three lines. Frans -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RFC: prepare for struct scatterlist entries without page backing
On Wed, Aug 12, 2015 at 10:00 AM, James Bottomley james.bottom...@hansenpartnership.com wrote: On Wed, 2015-08-12 at 09:05 +0200, Christoph Hellwig wrote: ... However the ccio (parisc) and sba_iommu (parisc ia64) IOMMUs seem to be operate mostly on virtual addresses. It's a fairly odd concept that I don't fully grasp, so I'll need some help with those if we want to bring this forward. James explained the primary function of IOMMUs on parisc (DMA-Cache coherency) much better than I ever could. Three more observations: 1) the IOMMU can be bypassed by 64-bit DMA devices on IA64. 2) IOMMU enables 32-bit DMA devices to reach 32-bit physical memory and thus avoiding bounce buffers. parisc and older IA-64 have some 32-bit PCI devices - e.g. IDE boot HDD. 3) IOMMU acts as a proxy for IO devices by fetching cachelines of data for PA-RISC systems whose memory controllers ONLY serve cacheline sized transactions. ie. 32-bit DMA results in the IOMMU fetching the cacheline and updating just the 32-bits in a DMA cache coherent fashion. Bonus thought: 4) IOMMU can improve DMA performance in some cases using hints provided by the OS (e.g. prefetching DMA data or using READ_CURRENT bus transactions instead of normal memory fetches.) cheers, grant -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html