* re: mwifiex: add firmware dump feature for PCIe
@ 2014-04-23 14:30 Dan Carpenter
2014-04-23 21:37 ` Bing Zhao
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2014-04-23 14:30 UTC (permalink / raw)
To: akarwar; +Cc: linux-wireless
Hello Amitkumar Karwar,
The patch e050c76fcf49: "mwifiex: add firmware dump feature for PCIe"
from Apr 17, 2014, leads to the following static checker warning:
drivers/net/wireless/mwifiex/pcie.c:2252 mwifiex_pcie_fw_dump_work()
error: we previously assumed 'adapter' could be null (see line 2251)
drivers/net/wireless/mwifiex/pcie.c
2228 /* This function dump firmware memory to file */
2229 static void mwifiex_pcie_fw_dump_work(struct work_struct *work)
2230 {
2231 struct mwifiex_adapter *adapter =
2232 container_of(work, struct mwifiex_adapter, iface_work);
2233 unsigned int reg, reg_start, reg_end;
2234 u8 *dbg_ptr;
2235 struct timeval t;
2236 u8 dump_num = 0, idx, i, read_reg, doneflag = 0;
2237 enum rdwr_status stat;
2238 u32 memory_size;
2239 u8 filename[MAX_FULL_NAME_LEN];
2240 mm_segment_t fs;
2241 loff_t pos;
2242 u8 *end_ptr;
2243 u8 *name_prefix = "/var/log/fw_dump_";
2244 struct memory_type_mapping mem_type_mapping_tbl[] = {
2245 {"ITCM", NULL, NULL, 0xF0},
2246 {"DTCM", NULL, NULL, 0xF1},
2247 {"SQRAM", NULL, NULL, 0xF2},
2248 {"IRAM", NULL, NULL, 0xF3},
2249 };
2250
2251 if (!adapter) {
^^^^^^^
Check.
2252 dev_err(adapter->dev, "Could not dump firmwware info\n");
^^^^^^^^^^^^
Dereference.
2253 return;
2254 }
The main question is why are we writing to /var and /tmp anyway instead
of putting this in debugfs or sysfs?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: mwifiex: add firmware dump feature for PCIe
2014-04-23 14:30 mwifiex: add firmware dump feature for PCIe Dan Carpenter
@ 2014-04-23 21:37 ` Bing Zhao
2014-04-23 21:47 ` Dan Carpenter
2014-04-24 8:50 ` Kalle Valo
0 siblings, 2 replies; 4+ messages in thread
From: Bing Zhao @ 2014-04-23 21:37 UTC (permalink / raw)
To: Dan Carpenter, Amitkumar Karwar; +Cc: linux-wireless@vger.kernel.org
Hi Dan,
> Hello Amitkumar Karwar,
>
> The patch e050c76fcf49: "mwifiex: add firmware dump feature for PCIe"
> from Apr 17, 2014, leads to the following static checker warning:
>
> drivers/net/wireless/mwifiex/pcie.c:2252 mwifiex_pcie_fw_dump_work()
> error: we previously assumed 'adapter' could be null (see line 2251)
Thanks for reporting this error.
>
> drivers/net/wireless/mwifiex/pcie.c
> 2228 /* This function dump firmware memory to file */
> 2229 static void mwifiex_pcie_fw_dump_work(struct work_struct *work)
> 2230 {
> 2231 struct mwifiex_adapter *adapter =
> 2232 container_of(work, struct mwifiex_adapter, iface_work);
> 2233 unsigned int reg, reg_start, reg_end;
> 2234 u8 *dbg_ptr;
> 2235 struct timeval t;
> 2236 u8 dump_num = 0, idx, i, read_reg, doneflag = 0;
> 2237 enum rdwr_status stat;
> 2238 u32 memory_size;
> 2239 u8 filename[MAX_FULL_NAME_LEN];
> 2240 mm_segment_t fs;
> 2241 loff_t pos;
> 2242 u8 *end_ptr;
> 2243 u8 *name_prefix = "/var/log/fw_dump_";
> 2244 struct memory_type_mapping mem_type_mapping_tbl[] = {
> 2245 {"ITCM", NULL, NULL, 0xF0},
> 2246 {"DTCM", NULL, NULL, 0xF1},
> 2247 {"SQRAM", NULL, NULL, 0xF2},
> 2248 {"IRAM", NULL, NULL, 0xF3},
> 2249 };
> 2250
> 2251 if (!adapter) {
> ^^^^^^^
> Check.
>
> 2252 dev_err(adapter->dev, "Could not dump firmwware info\n");
> ^^^^^^^^^^^^
> Dereference.
You are right, adapter is NULL here. I will send a patch to fix it.
>
> 2253 return;
> 2254 }
>
> The main question is why are we writing to /var and /tmp anyway instead
> of putting this in debugfs or sysfs?
AFAIK, the debugfs or sysfs cannot store/hold the files we retrieve from firmware at the scene. We write fw_dump files to rootfs so that the files are stored even if the system reboots due to hung_task timeout.
Thanks,
Bing
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: mwifiex: add firmware dump feature for PCIe
2014-04-23 21:37 ` Bing Zhao
@ 2014-04-23 21:47 ` Dan Carpenter
2014-04-24 8:50 ` Kalle Valo
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-04-23 21:47 UTC (permalink / raw)
To: Bing Zhao; +Cc: Amitkumar Karwar, linux-wireless@vger.kernel.org
On Wed, Apr 23, 2014 at 02:37:09PM -0700, Bing Zhao wrote:
>
> AFAIK, the debugfs or sysfs cannot store/hold the files we retrieve
> from firmware at the scene. We write fw_dump files to rootfs so that
> the files are stored even if the system reboots due to hung_task
> timeout.
Ah. Gotcha.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mwifiex: add firmware dump feature for PCIe
2014-04-23 21:37 ` Bing Zhao
2014-04-23 21:47 ` Dan Carpenter
@ 2014-04-24 8:50 ` Kalle Valo
1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2014-04-24 8:50 UTC (permalink / raw)
To: Bing Zhao; +Cc: Dan Carpenter, Amitkumar Karwar, linux-wireless@vger.kernel.org
Bing Zhao <bzhao@marvell.com> writes:
>> The main question is why are we writing to /var and /tmp anyway instead
>> of putting this in debugfs or sysfs?
IMHO no sane wifi driver should _ever_ write anything to a file system.
That's just evil.
> AFAIK, the debugfs or sysfs cannot store/hold the files we retrieve
> from firmware at the scene. We write fw_dump files to rootfs so that
> the files are stored even if the system reboots due to hung_task
> timeout.
Can't you have a user space tool reading the sysfs file and store the
file permanently? That way kernel is not involved in file system access
at all.
--
Kalle Valo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-24 8:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-23 14:30 mwifiex: add firmware dump feature for PCIe Dan Carpenter
2014-04-23 21:37 ` Bing Zhao
2014-04-23 21:47 ` Dan Carpenter
2014-04-24 8:50 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox