summaryrefslogtreecommitdiff
path: root/drivers/media/usb/siano/smsusb.c
AgeCommit message (Collapse)Author
2019-06-11media: smsusb: better handle optional alignmentMauro Carvalho Chehab
commit a47686636d84eaec5c9c6e84bd5f96bed34d526d upstream. Most Siano devices require an alignment for the response. Changeset f3be52b0056a ("media: usb: siano: Fix general protection fault in smsusb") changed the logic with gets such aligment, but it now produces a sparce warning: drivers/media/usb/siano/smsusb.c: In function 'smsusb_init_device': drivers/media/usb/siano/smsusb.c:447:37: warning: 'in_maxp' may be used uninitialized in this function [-Wmaybe-uninitialized] 447 | dev->response_alignment = in_maxp - sizeof(struct sms_msg_hdr); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ The sparse message itself is bogus, but a broken (or fake) USB eeprom could produce a negative value for response_alignment. So, change the code in order to check if the result is not negative. Fixes: 31e0456de5be ("media: usb: siano: Fix general protection fault in smsusb") CC: <stable@vger.kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11media: usb: siano: Fix false-positive "uninitialized variable" warningAlan Stern
commit 45457c01171fd1488a7000d1751c06ed8560ee38 upstream. GCC complains about an apparently uninitialized variable recently added to smsusb_init_device(). It's a false positive, but to silence the warning this patch adds a trivial initialization. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: kbuild test robot <lkp@intel.com> CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11media: usb: siano: Fix general protection fault in smsusbAlan Stern
commit 31e0456de5be379b10fea0fa94a681057114a96e upstream. The syzkaller USB fuzzer found a general-protection-fault bug in the smsusb part of the Siano DVB driver. The fault occurs during probe because the driver assumes without checking that the device has both IN and OUT endpoints and the IN endpoint is ep1. By slightly rearranging the driver's initialization code, we can make the appropriate checks early on and thus avoid the problem. If the expected endpoints aren't present, the new code safely returns -ENODEV from the probe routine. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-and-tested-by: syzbot+53f029db71c19a47325a@syzkaller.appspotmail.com CC: <stable@vger.kernel.org> Reviewed-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-23siano: make it work again with CONFIG_VMAP_STACKMauro Carvalho Chehab
commit f9c85ee67164b37f9296eab3b754e543e4e96a1c upstream. Reported as a Kaffeine bug: https://bugs.kde.org/show_bug.cgi?id=375811 The USB control messages require DMA to work. We cannot pass a stack-allocated buffer, as it is not warranted that the stack would be into a DMA enabled area. On Kernel 4.9, the default is to not accept DMA on stack anymore on x86 architecture. On other architectures, this has been a requirement since Kernel 2.2. So, after this patch, this driver should likely work fine on all archs. Tested with USB ID 2040:5510: Hauppauge Windham Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-23[media] media_device: move allocation out of media_device_*_initMauro Carvalho Chehab
Right now, media_device_pci_init and media_device_usb_init does media_device allocation internaly. That preents its usage when the media_device struct is embedded on some other structure. Move memory allocation outside it, to make it more generic. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-23[media] media-device: move PCI/USB helper functions from v4l2-mcMauro Carvalho Chehab
Those ancillary functions could be called even when compiled without V4L2 support, as warned by ktest build robot: All errors (new ones prefixed by >>): >> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/dvb-usb/dvb-usb.ko] undefined! >> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/dvb-usb-v2/dvb_usb_v2.ko] undefined! >> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/au0828/au0828.ko] undefined! Also, there's nothing there that are specific to V4L2. So, move those ancillary functions to MC core. No functional changes. Just function rename. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-16[media] siano: use generic function to create MC deviceMauro Carvalho Chehab
Currently, it is initializing the driver name using the wrong name ("usb"). Use the generic function, as its logic works best, and avoids repeating the very same code everywhere. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-16[media] smsusb: don't sleep while atomicMauro Carvalho Chehab
smscore_getbuffer() calls internally wait_event(), with can sleep. As smsusb_onresponse() is called on interrupt context, this causes the following warning: BUG: sleeping function called from invalid context at drivers/media/common/siano/smscoreapi.c:1653 in_atomic(): 1, irqs_disabled(): 1, pid: 11084, name: systemd-udevd INFO: lockdep is turned off. irq event stamp: 0 hardirqs last enabled at (0): [< (null)>] (null) hardirqs last disabled at (0): [<ffffffff811480f7>] copy_process.part.7+0x10e7/0x56d0 softirqs last enabled at (0): [<ffffffff81148193>] copy_process.part.7+0x1183/0x56d0 softirqs last disabled at (0): [< (null)>] (null) CPU: 2 PID: 11084 Comm: systemd-udevd Tainted: G B W 4.5.0-rc3+ #47 Hardware name: /NUC5i7RYB, BIOS RYBDWi35.86A.0350.2015.0812.1722 08/12/2015 0000000000000000 ffff8803c6907a80 ffffffff81933901 ffff8802bd916000 ffff8802bd9165c8 ffff8803c6907aa8 ffffffff811c6af5 ffff8802bd916000 ffffffffa0ce9b60 0000000000000675 ffff8803c6907ae8 ffffffff811c6ce5 Call Trace: <IRQ> [<ffffffff81933901>] dump_stack+0x85/0xc4 [<ffffffff811c6af5>] ___might_sleep+0x245/0x3a0 [<ffffffff811c6ce5>] __might_sleep+0x95/0x1a0 [<ffffffffa0ce020a>] ? list_add_locked+0xca/0x140 [smsmdtv] [<ffffffffa0ce3b8d>] smscore_getbuffer+0x7d/0x120 [smsmdtv] [<ffffffff8123819d>] ? trace_hardirqs_off+0xd/0x10 [<ffffffffa0ce3b10>] ? smscore_sendrequest_and_wait.isra.5+0x120/0x120 [smsmdtv] [<ffffffffa0ce020a>] ? list_add_locked+0xca/0x140 [smsmdtv] [<ffffffffa0ce13ca>] ? smscore_putbuffer+0x3a/0x40 [smsmdtv] [<ffffffffa0d107bc>] smsusb_submit_urb+0x2ec/0x4f0 [smsusb] [<ffffffffa0d10e36>] smsusb_onresponse+0x476/0x720 [smsusb] Let's add a work queue to handle the bottom half, preventing this problem. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-01-11[media] media-device: split media initialization and registrationJavier Martinez Canillas
The media device node is registered and so made visible to user-space before entities are registered and links created which means that the media graph obtained by user-space could be only partially enumerated if that happens too early before all the graph has been created. To avoid this race condition, split the media init and registration in separate functions and only register the media device node when all the pending subdevices have been registered, either explicitly by the driver or asynchronously using v4l2_async_register_subdev(). The media_device_register() had a check for drivers not filling dev and model fields but all drivers in mainline set them and not doing it will be a driver bug so change the function return to void and add a BUG_ON() for dev being NULL instead. Also, add a media_device_cleanup() function that will destroy the graph_mutex that is initialized in media_device_init(). [mchehab@osg.samsung.com: Fix compilation if !CONFIG_MEDIA_CONTROLLER and remove two warnings added by this changeset] Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-02[media] siano: avoid a linkedit error if !MCMauro Carvalho Chehab
If the media controller (MC) is not enabled, it will compile fine, but will fail at the linkedition: ERROR: "media_device_unregister" [drivers/media/usb/siano/smsusb.ko] undefined! Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] siano: register media controller earlierMauro Carvalho Chehab
We need to initialize the media controller earlier, as the core will call the smsdvb hotplug during register time. Ok, this is an async operation, so, when the module is not loaded, the media controller works. However, if the module is already loaded, nothing will be registered at the media controller, as it will load too late. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] siano: get rid of sms_dbg parameterMauro Carvalho Chehab
All siano modules have a sms_dbg parameter. Now that we're using the standard pr_debug() macro, we can get rid of it. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] siano: get rid of sms_info()Mauro Carvalho Chehab
On most cases, sms_info() should actually be pr_debug(), but, on other places, it should be pr_info(). Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] siano: replace sms_debug() by pr_debug()Mauro Carvalho Chehab
There's no reason to use a macro here. Just replace everything, and let those debug messages to be activated via dynamic printk. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] siano: replace sms_err by pr_errMauro Carvalho Chehab
Originally, sms_err() would be also displaying the line where the error occurs, but the messages are clear enough. Also, the function is always printed. So, no need for it. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] siano: replace sms_warn() by pr_warn()Mauro Carvalho Chehab
There's no reason for a sms' own sms_warn macro. Just replace it by the standard pr_warn(). Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] siano: use pr_* print functionsMauro Carvalho Chehab
Instead of defining its own set of printk functions, let's use the common Kernel debug logic provided by pr_foo functions. As a first step, let's just define the existing macros as the Kernel ones. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26[media] siano: add support for the media controller at USB driverMauro Carvalho Chehab
Adding support for the media controller for a pure DVB device is simple: just create a struct media_device and add it to the dvb adapter. After creating all DVB devices, we need to call the DVB core, for it to create the media graph. More work is needed for pure DVB tuners, but this is hidden at the Siano driver, just like several others non-hybrid devices. So, this is streight forward. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-26[media] usb drivers: use %zu instead of %zdMauro Carvalho Chehab
size_t is unsigned. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-08-21[media] siano: add support for PCTV 77eMauro Carvalho Chehab
Add support for PCTV microStick (77e) device that uses a sms1140 chipset. Cc: stable@vger.kernel.org Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] Siano: smsusb - Add a device id for PX-S1UDSatoshi Nagahama
Add a device id to support for PX-S1UD (PLEX ISDB-T usb dongle) which has sms2270. Signed-off-by: Satoshi Nagahama <sattnag@aim.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-10-14[media] siano: Use the default firmware for StellarMauro Carvalho Chehab
The Stellar firmware load routine is different. Improve it to use the default firmware, if no modprobe parameter tells otherwise. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> Tested-by: André Roth <neolynx@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-10-14[media] siano: Fix initialization for Stellar modelsMauro Carvalho Chehab
Since kernel 3.8, the initialization for Stellar (sms1000) devices are broken. Those devices have a behaviour different than usual sms1100 and sms2270: they start with one USB ID (devices in cold state), but after firmware load, they get a different USB ID. This weren't docummented at the driver. So, the patches that added support for sms2270 broke it. Properly documment it, and provide a debug log that allows to follow all phases of the device initialization: smsusb_probe: board id=13, interface number 0 smsusb_probe: interface 0 won't be used. Expecting interface 1 to popup smsusb_probe: board id=13, interface number 1 smsusb_probe: smsusb_probe 1 smsusb_probe: endpoint 0 81 02 64 smsusb_probe: endpoint 1 02 02 64 smsusb_probe: stellar device in cold state was found at usb\4-2. smsusb1_load_firmware: sent 38144(38144) bytes, rc 0 smsusb1_load_firmware: read FW dvbt_bda_stellar_usb.inp, size=38144 smsusb_probe: stellar device now in warm state usbcore: registered new interface driver smsusb usb 4-2: USB disconnect, device number 52 usb 4-2: new full-speed USB device number 53 using uhci_hcd usb 4-2: New USB device found, idVendor=187f, idProduct=0100 usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 usb 4-2: Product: SMS DVBT-BDA Receiver usb 4-2: Manufacturer: Siano Mobile Silicon smsusb_probe: board id=1, interface number 0 smsusb_probe: smsusb_probe 0 smsusb_probe: endpoint 0 81 02 64 smsusb_probe: endpoint 1 02 02 64 smsusb_init_device: in_ep = 81, out_ep = 02 smscore_register_device: allocated 50 buffers smscore_register_device: device ffff88012a00bc00 created smsusb_init_device: smsusb_start_streaming(...). smscore_set_device_mode: set device mode to 4 smsusb1_detectmode: 4 "SMS DVBT-BDA Receiver" smsusb_sendrequest: sending MSG_SMS_INIT_DEVICE_REQ(578) size: 12 smsusb_onresponse: received MSG_SMS_INIT_DEVICE_RES(579) size: 12 smscore_set_device_mode: Success setting device mode. smscore_init_ir: IR port has not been detected smscore_start_device: device ffff88012a00bc00 started, rc 0 smsusb_init_device: device 0xffff88002cfa6000 created smsusb_probe: Device initialized with return code 0 DVB: registering new adapter (Siano Stellar Digital Receiver) usb 4-2: DVB: registering adapter 0 frontend 0 (Siano Mobile Digital MDTV Receiver)... smscore_register_client: ffff88012174a000 693 1 sms_board_dvb3_event: DVB3_EVENT_HOTPLUG smsdvb_hotplug: success smsdvb_module_init: Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> Tested-by: André Roth <neolynx@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-10-14[media] siano: Improve debug/info messagesMauro Carvalho Chehab
Some messages are not clear, some are debug data, but are shown as errors, and one message is duplicated. Cleanup that mess in order to provide a cleaner log. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> Tested-by: André Roth <neolynx@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-03-21[media] siano: remove the remaining CamelCase compliantsMauro Carvalho Chehab
Remove the remaining CamelCase checkpatch.pl compliants. There are still a few left, but those are due to USB and DVB APIs. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-21[media] siano: get rid of CammelCase from smscoreapi.hMauro Carvalho Chehab
It is almost impossible to see a compliant with checkpatch.pl on those Siano drivers, as there are simply too much violations on it. So, now that a big change was done, the better is to cleanup the checkpatch compliants. Let's first replace all CammelCase symbols found at smscoreapi.h using camel_case namespace. That removed 144 checkpatch.pl compliants on this file. Of course, the other files need to be fixed accordingly. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-21[media] siano: remove a bogus printk lineMauro Carvalho Chehab
The logic that detects the types of sms devices is bogus. It returns [ 4645.187790] smsusb_init_device: line: 372: Unspecified sms device type! For several devices, including the one I have (SMS_RIO). In a matter of fact, the right thing to do there is to print an error only if the device is really unknown (SMS_UNKNOWN_TYPE). Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-21[media] siano: split debugfs code into a separate fileMauro Carvalho Chehab
To avoid mixing two different things at the same place, move the debugfs code into a separate file. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-21[media] siano: simplify message endianness logicMauro Carvalho Chehab
Currently, every time a message is sent or received, the endiannes need to be fixed on big endian machines. This is currently done on every call to the send API, and on every msg reception logic. Instead of doing that, move it to the send/receive functions. That simplifies the logic and avoids the risk of forgetting to fix it somewhere. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-21[media] siano: add new devices to the Siano DriverMauro Carvalho Chehab
This patch is based on Doron Cohen's patches: http://patchwork.linuxtv.org/patch/7881/ http://patchwork.linuxtv.org/patch/7888/ http://patchwork.linuxtv.org/patch/7883/ It basically merges the above patches, rebasing them to the macro definitions used upstream, with are different than the ones used by them internally. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-21[media] siano: use USB endpoint descriptors for in/out endpMauro Carvalho Chehab
Instead of using hardcoded descriptors, detect them from the USB descriptors. This patch is rebased form Doron Cohen's patch: http://patchwork.linuxtv.org/patch/7883/ Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-21[media] siano: better debug send/receive messagesMauro Carvalho Chehab
Instead of printing a message for some random messages, print it for all sent/received ones. That helps a lot to debug what's going on. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-01-03Drivers: media: remove __dev* attributes.Greg Kroah-Hartman
CONFIG_HOTPLUG is going away as an option. As a result, the __dev* markings need to be removed. This change removes the use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit from these drivers. Based on patches originally written by Bill Pemberton, but redone by me in order to handle some of the coding style issues better, by hand. Cc: Bill Pemberton <wfp5p@virginia.edu> Cc: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-24Merge tag 'v3.6-rc3' into staging/for_v3.7Mauro Carvalho Chehab
Linux 3.6-rc3 * tag 'v3.6-rc3': (764 commits) Linux 3.6-rc3 task_work: add a scheduling point in task_work_run() fs: fix fs/namei.c kernel-doc warnings eventpoll: use-after-possible-free in epoll_create1() vfio: grab vfio_device reference *before* exposing the sucker via fd_install() vfio: get rid of vfio_device_put()/vfio_group_get_device* races vfio: get rid of open-coding kref_put_mutex introduce kref_put_mutex() vfio: don't dereference after kfree... fbcon: fix race condition between console lock and cursor timer (v1.1) mm: compaction: Abort async compaction if locks are contended or taking too long mm: have order > 0 compaction start near a pageblock with free pages rapidio/tsi721: fix unused variable compiler warning rapidio/tsi721: fix inbound doorbell interrupt handling drivers/rtc/rtc-rs5c348.c: fix hour decoding in 12-hour mode mm: correct page->pfmemalloc to fix deactivate_slab regression drivers/rtc/rtc-pcf2123.c: initialize dynamic sysfs attributes mm/compaction.c: fix deferring compaction mistake drivers/misc/sgi-xp/xpc_uv.c: SGI XPC fails to load when cpu 0 is out of IRQ resources string: do not export memweight() to userspace ...
2012-08-13[media] dvb-usb: move it to drivers/media/usb/dvb-usbMauro Carvalho Chehab
As media/dvb will be removed, move it to a proper place. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>