Message ID | 1659336403-2546-1-git-send-email-marge.yang@synaptics.corp-partner.google.com (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Jiri Kosina |
Headers | show |
Series | Input: HID-rmi - ignore to rmi_hid_read_block after system resumes. | expand |
Hi margeyang, https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/margeyang/Input-HID-rmi-ignore-to-rmi_hid_read_block-after-system-resumes/20220801-145006 base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next config: x86_64-randconfig-m001-20220801 (https://download.01.org/0day-ci/archive/20220814/202208142212.QB3fvm5l-lkp@intel.com/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> New smatch warnings: drivers/hid/hid-rmi.c:263 rmi_hid_read_block() error: uninitialized symbol 'ret'. vim +/ret +263 drivers/hid/hid-rmi.c 0b2c7a897378f1 Andrew Duggan 2017-01-05 188 static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr, 0b2c7a897378f1 Andrew Duggan 2017-01-05 189 void *buf, size_t len) 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 190 { 0b2c7a897378f1 Andrew Duggan 2017-01-05 191 struct rmi_data *data = container_of(xport, struct rmi_data, xport); 0b2c7a897378f1 Andrew Duggan 2017-01-05 192 struct hid_device *hdev = data->hdev; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 193 int ret; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 194 int bytes_read; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 195 int bytes_needed; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 196 int retries; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 197 int read_input_count; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 198 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 199 mutex_lock(&data->page_mutex); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 200 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 201 if (RMI_PAGE(addr) != data->page) { 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 202 ret = rmi_set_page(hdev, RMI_PAGE(addr)); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 203 if (ret < 0) 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 204 goto exit; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 205 } 30a3df7ece6145 Marge Yang 2022-08-01 206 if (ignoreonce == 1) { 30a3df7ece6145 Marge Yang 2022-08-01 207 dev_err(&hdev->dev, 30a3df7ece6145 Marge Yang 2022-08-01 208 "ignoreonce (%d)\n", 30a3df7ece6145 Marge Yang 2022-08-01 209 ignoreonce); 30a3df7ece6145 Marge Yang 2022-08-01 210 ignoreonce = 0; "ret" not initialized here. 30a3df7ece6145 Marge Yang 2022-08-01 211 goto exit; 30a3df7ece6145 Marge Yang 2022-08-01 212 } 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 213 for (retries = 5; retries > 0; retries--) { 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 214 data->writeReport[0] = RMI_READ_ADDR_REPORT_ID; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 215 data->writeReport[1] = 0; /* old 1 byte read count */ 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 216 data->writeReport[2] = addr & 0xFF; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 217 data->writeReport[3] = (addr >> 8) & 0xFF; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 218 data->writeReport[4] = len & 0xFF; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 219 data->writeReport[5] = (len >> 8) & 0xFF; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 220 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 221 set_bit(RMI_READ_REQUEST_PENDING, &data->flags); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 222 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 223 ret = rmi_write_report(hdev, data->writeReport, 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 224 data->output_report_size); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 225 if (ret != data->output_report_size) { 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 226 dev_err(&hdev->dev, 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 227 "failed to write request output report (%d)\n", 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 228 ret); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 229 goto exit; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 230 } 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 231 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 232 bytes_read = 0; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 233 bytes_needed = len; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 234 while (bytes_read < len) { 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 235 if (!wait_event_timeout(data->wait, 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 236 test_bit(RMI_READ_DATA_PENDING, &data->flags), 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 237 msecs_to_jiffies(1000))) { 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 238 hid_warn(hdev, "%s: timeout elapsed\n", 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 239 __func__); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 240 ret = -EAGAIN; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 241 break; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 242 } 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 243 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 244 read_input_count = data->readReport[1]; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 245 memcpy(buf + bytes_read, &data->readReport[2], 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 246 read_input_count < bytes_needed ? 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 247 read_input_count : bytes_needed); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 248 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 249 bytes_read += read_input_count; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 250 bytes_needed -= read_input_count; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 251 clear_bit(RMI_READ_DATA_PENDING, &data->flags); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 252 } 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 253 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 254 if (ret >= 0) { 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 255 ret = 0; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 256 break; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 257 } 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 258 } 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 259 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 260 exit: 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 261 clear_bit(RMI_READ_REQUEST_PENDING, &data->flags); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 262 mutex_unlock(&data->page_mutex); 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 @263 return ret; 9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 264 }
Hi Dan,
Thanks for your information.
I will fix it on V4 patch.
Thanks
Marge Yang
-----Original Message-----
From: Dan Carpenter <dan.carpenter@oracle.com>
Sent: Monday, August 15, 2022 4:16 PM
To: kbuild@lists.01.org; margeyang <marge.yang@synaptics.corp-partner.google.com>; dmitry.torokhov@gmail.com; linux-input@vger.kernel.org; linux-kernel@vger.kernel.org
Cc: lkp@intel.com; kbuild-all@lists.01.org; Marge Yang <Marge.Yang@tw.synaptics.com>; derek.chegn@tw.synaptcs.com; Vincent Huang <Vincent.huang@tw.synaptics.com>; Marge Yang <marge.yang@synaptics.corp-partner.google.com>
Subject: Re: [PATCH] Input: HID-rmi - ignore to rmi_hid_read_block after system resumes.
CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe.
Hi margeyang,
https://urldefense.proofpoint.com/v2/url?u=https-3A__git-2Dscm.com_docs_git-2Dformat-2Dpatch-23-5Fbase-5Ftree-5Finformation&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=ZPw8UPZC7QjdIlIk0NorBFkiiDexM8yXIDSCUXyvUoI&e= ]
url: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_intel-2Dlab-2Dlkp_linux_commits_margeyang_Input-2DHID-2Drmi-2Dignore-2Dto-2Drmi-5Fhid-5Fread-5Fblock-2Dafter-2Dsystem-2Dresumes_20220801-2D145006&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=qM9oqLWIocmeg-um8b7KrQ7lKvYhttRHtsckOGgVlpg&e=
base: https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_hid_hid.git&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=m7w3BRuQqsSi92tD7Gu4x5PdJHLoevCdc3u2UZbKD4s&e= for-next
config: x86_64-randconfig-m001-20220801 (https://urldefense.proofpoint.com/v2/url?u=https-3A__download.01.org_0day-2Dci_archive_20220814_202208142212.QB3fvm5l-2Dlkp-40intel.com_config&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=7qqbxHlAk9YvxOzNvBC00oePmwYwpvxsoq9bF7lgg3w&e= )
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/hid/hid-rmi.c:263 rmi_hid_read_block() error: uninitialized symbol 'ret'.
vim +/ret +263 drivers/hid/hid-rmi.c
0b2c7a897378f1 Andrew Duggan 2017-01-05 188 static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,
0b2c7a897378f1 Andrew Duggan 2017-01-05 189 void *buf, size_t len)
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 190 {
0b2c7a897378f1 Andrew Duggan 2017-01-05 191 struct rmi_data *data = container_of(xport, struct rmi_data, xport);
0b2c7a897378f1 Andrew Duggan 2017-01-05 192 struct hid_device *hdev = data->hdev;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 193 int ret;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 194 int bytes_read;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 195 int bytes_needed;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 196 int retries;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 197 int read_input_count;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 198
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 199 mutex_lock(&data->page_mutex);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 200
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 201 if (RMI_PAGE(addr) != data->page) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 202 ret = rmi_set_page(hdev, RMI_PAGE(addr));
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 203 if (ret < 0)
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 204 goto exit;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 205 }
30a3df7ece6145 Marge Yang 2022-08-01 206 if (ignoreonce == 1) {
30a3df7ece6145 Marge Yang 2022-08-01 207 dev_err(&hdev->dev,
30a3df7ece6145 Marge Yang 2022-08-01 208 "ignoreonce (%d)\n",
30a3df7ece6145 Marge Yang 2022-08-01 209 ignoreonce);
30a3df7ece6145 Marge Yang 2022-08-01 210 ignoreonce = 0;
"ret" not initialized here.
30a3df7ece6145 Marge Yang 2022-08-01 211 goto exit;
30a3df7ece6145 Marge Yang 2022-08-01 212 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 213 for (retries = 5; retries > 0; retries--) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 214 data->writeReport[0] = RMI_READ_ADDR_REPORT_ID;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 215 data->writeReport[1] = 0; /* old 1 byte read count */
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 216 data->writeReport[2] = addr & 0xFF;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 217 data->writeReport[3] = (addr >> 8) & 0xFF;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 218 data->writeReport[4] = len & 0xFF;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 219 data->writeReport[5] = (len >> 8) & 0xFF;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 220
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 221 set_bit(RMI_READ_REQUEST_PENDING, &data->flags);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 222
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 223 ret = rmi_write_report(hdev, data->writeReport,
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 224 data->output_report_size);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 225 if (ret != data->output_report_size) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 226 dev_err(&hdev->dev,
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 227 "failed to write request output report (%d)\n",
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 228 ret);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 229 goto exit;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 230 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 231
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 232 bytes_read = 0;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 233 bytes_needed = len;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 234 while (bytes_read < len) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 235 if (!wait_event_timeout(data->wait,
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 236 test_bit(RMI_READ_DATA_PENDING, &data->flags),
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 237 msecs_to_jiffies(1000))) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 238 hid_warn(hdev, "%s: timeout elapsed\n",
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 239 __func__);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 240 ret = -EAGAIN;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 241 break;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 242 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 243
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 244 read_input_count = data->readReport[1];
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 245 memcpy(buf + bytes_read, &data->readReport[2],
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 246 read_input_count < bytes_needed ?
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 247 read_input_count : bytes_needed);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 248
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 249 bytes_read += read_input_count;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 250 bytes_needed -= read_input_count;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 251 clear_bit(RMI_READ_DATA_PENDING, &data->flags);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 252 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 253
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 254 if (ret >= 0) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 255 ret = 0;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 256 break;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 257 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 258 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 259
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 260 exit:
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 261 clear_bit(RMI_READ_REQUEST_PENDING, &data->flags);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 262 mutex_unlock(&data->page_mutex);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 @263 return ret;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 264 }
--
0-DAY CI Kernel Test Service
https://urldefense.proofpoint.com/v2/url?u=https-3A__01.org_lkp&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=iqPMCIB5YYZdhSl4lFrcKmwdNU-RU2DL046Inhx7mPM&e=
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index 311eee599ce9..1b038f3db0f1 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c @@ -101,7 +101,7 @@ struct rmi_data { }; #define RMI_PAGE(addr) (((addr) >> 8) & 0xff) - +int ignoreonce; static int rmi_write_report(struct hid_device *hdev, u8 *report, int len); /** @@ -203,7 +203,13 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr, if (ret < 0) goto exit; } - + if (ignoreonce == 1) { + dev_err(&hdev->dev, + "ignoreonce (%d)\n", + ignoreonce); + ignoreonce = 0; + goto exit; + } for (retries = 5; retries > 0; retries--) { data->writeReport[0] = RMI_READ_ADDR_REPORT_ID; data->writeReport[1] = 0; /* old 1 byte read count */ @@ -468,7 +474,10 @@ static int rmi_post_resume(struct hid_device *hdev) ret = hid_hw_open(hdev); if (ret) return ret; - + // Avoid to read rmi_hid_read_block once after system resumes. + // The interrupt will be pulled down + // after RMI Read command(Report ID:0x0A). + ignoreonce = 1; ret = rmi_reset_attn_mode(hdev); if (ret) goto out;