From nobody Tue Feb 22 21:40:03 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6C38B19D4400; Tue, 22 Feb 2022 21:40:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K3CJ32PbLz4sFt; Tue, 22 Feb 2022 21:40:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645566003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=12MMge+pq6CV1N3m4pwvPTGg0DpAWXreb3HAw2Lpv4I=; b=HuYmrLLO9FkyDwJmdOwhrjT2eYp0gASjH68fwbO8JA/k+vcoKvHeAmaLDZbviZx7Avyeju OOWJ1bmFurMJsmb9PnP3W4GcAaMX82zAofZDGbtaQYyXi4w/gcumdaQm2+LZK7OM0EC+wi 5m6IyV6jm7AUBRfxGtp8mEeqK3gutmyZyQ+mC26F6QDGlwauHN7DJbfaYJ3zhTrtqlG94l lZ+nmvOsTyC5RlMY5iM3DDSdA7W+v2ZGVXNheW7NFR6LmxlbzYH1XC421BUH+xpU6CLP8N /B5vlu5E+y4mfyat2/bg9G9SkiA7bTkKD+Jd9IPh2NgUdnCE1cOea6D/EugxKg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 330863ADD; Tue, 22 Feb 2022 21:40:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21MLe37s062420; Tue, 22 Feb 2022 21:40:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21MLe3b7062417; Tue, 22 Feb 2022 21:40:03 GMT (envelope-from git) Date: Tue, 22 Feb 2022 21:40:03 GMT Message-Id: <202202222140.21MLe3b7062417@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 78fbaa1fac26 - main - camcontrol fwdownload minor improvements List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 78fbaa1fac2677feeb2094048d77587a2ab80d11 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645566003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=12MMge+pq6CV1N3m4pwvPTGg0DpAWXreb3HAw2Lpv4I=; b=IeFOvoojfL/sIhExecw9/7xnJMoG1LdzC7pIzCEeS4UQ5t1uqos9MHZKfe3D+Pe6cLg7XL oG6Xqj3+u21Y+mJs+6V65e9V3gjTfzLKI0m54yyKO1piibrXxYKrd0YdEVSYmUbS1a+fYJ +bh2ro0PPjLv220W7AHkjT0GFWTTmoE+iggqsk5EQytVei3T4DrvdyYdQFQpbuZ4e+VUJJ SPHsBocTHTKqzgjmL7Le7GkhQNhm6mLAqjwW7Q0ufMesUh4JRFIqv5H4Sy4jAODvxwIDT+ +zPFVc6hWDCnPAN5OeVTn/i17HrplBiRiGhkT/em+HZmW9W18/ZbllbmrVSzDw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645566003; a=rsa-sha256; cv=none; b=A0HDE0+fcTOqsKyEH3KSKsyC8bmHVqsh9YT1LYYMsPxY+akW3A2IEuB4W/cxehJzbvU4Yb Ncm6/vWhSkcB8v5ASzzOh4Qqj5H6UQqxnskGXycrUtacv/SKiH3v5MOF7F53t+39r43em6 OmBBGx+pJ7QhPZ52KgVjf534vKdVHVNG9wvXW8OzoC6hXlTfjdQG8M+gs0PkfoKtAvtvGx XNYJ7ef6oSpn+0C25I0qWcUMFVnItfbValFqw42g0swxcpyl3ER98Icol/zR1x2iIAa5q3 jOAjqDQyXlIx1NiEnSUmRNZG2DJ8IPmzUbeLIxtuDgIrY19L9DES/MZUmUhN2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=78fbaa1fac2677feeb2094048d77587a2ab80d11 commit 78fbaa1fac2677feeb2094048d77587a2ab80d11 Author: Warner Losh AuthorDate: 2022-02-22 21:25:32 +0000 Commit: Warner Losh CommitDate: 2022-02-22 21:38:38 +0000 camcontrol fwdownload minor improvements Minor improvements to the fwdownload code suggested by chs@: o Print the path_id/target we're rescanning so it's not invisible o No need for XPT_GDEVLIST, all the info is filled in. Remove sending it as well as a comment related to it from a mistaken observation. libcam always fills these in properly, so use those for the ccb path/target. o Don't leak /dev/xpt fd in success cases. o Rename fw_rescan_lun to fw_rescan_target and pass sim_mode to only print path_id and target_id info. Reviewed by: chs@ Fixes: 9835900cb95bcd068774934961fb1419719d595b Sponsored by: Netflix MFC After: 1 week Differential Revision: https://reviews.freebsd.org/D34348 --- sbin/camcontrol/fwdownload.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/sbin/camcontrol/fwdownload.c b/sbin/camcontrol/fwdownload.c index 5463f4e0b52c..02b60f25df04 100644 --- a/sbin/camcontrol/fwdownload.c +++ b/sbin/camcontrol/fwdownload.c @@ -771,12 +771,15 @@ bailout: * download. */ static int -fw_rescan_lun(struct cam_device *dev, bool printerrors) +fw_rescan_target(struct cam_device *dev, bool printerrors, bool sim_mode) { union ccb ccb; int fd; - target_id_t target; - uint32_t bus; + + printf("Rescanning target %d:%d:* to pick up new fw revision / parameters.\n", + dev->path_id, dev->target_id); + if (sim_mode) + return (0); /* Can only send XPT_SCAN_TGT via /dev/xpt, not pass device in *dev */ if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) { @@ -786,24 +789,11 @@ fw_rescan_lun(struct cam_device *dev, bool printerrors) return (1); } - /* Fill in the bus and target IDs as they don't seem to be in *dev */ - bzero(&ccb, sizeof(union ccb)); - ccb.ccb_h.func_code = XPT_GDEVLIST; - strlcpy(ccb.cgdl.periph_name, dev->device_name, sizeof(ccb.cgdl.periph_name)); - ccb.cgdl.unit_number = dev->dev_unit_num; - if (cam_send_ccb(dev, &ccb) < 0) { - warn("send_ccb GDEVLIST failed\n"); - close(fd); - return (1); - } - bus = ccb.ccb_h.path_id; - target = ccb.ccb_h.target_id; - /* Rescan the target */ bzero(&ccb, sizeof(union ccb)); ccb.ccb_h.func_code = XPT_SCAN_TGT; - ccb.ccb_h.path_id = bus; - ccb.ccb_h.target_id = target; + ccb.ccb_h.path_id = dev->path_id; + ccb.ccb_h.target_id = dev->target_id; ccb.ccb_h.target_lun = CAM_LUN_WILDCARD; ccb.crcn.flags = CAM_EXPECT_INQ_CHANGE; ccb.ccb_h.pinfo.priority = 5; /* run this at a low priority */ @@ -818,8 +808,10 @@ fw_rescan_lun(struct cam_device *dev, bool printerrors) if (printerrors) cam_error_print(dev, &ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); + close(fd); return (1); } + close(fd); return (0); } @@ -976,8 +968,8 @@ bailout: if (quiet == 0) progress_complete(&progress, size - img_size); cam_freeccb(ccb); - if (retval == 0 && !sim_mode) { - fw_rescan_lun(cam_dev, printerrors); + if (retval == 0) { + fw_rescan_target(cam_dev, printerrors, sim_mode); } return (retval); }