From owner-svn-src-head@freebsd.org Wed Jul 22 18:30:19 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 12CD035B9C4; Wed, 22 Jul 2020 18:30:19 +0000 (UTC) (envelope-from manu@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BBkXp6lgWz4YWl; Wed, 22 Jul 2020 18:30:18 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C7011B9B3; Wed, 22 Jul 2020 18:30:18 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06MIUIZt064436; Wed, 22 Jul 2020 18:30:18 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06MIUIQQ064434; Wed, 22 Jul 2020 18:30:18 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202007221830.06MIUIQQ064434@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Wed, 22 Jul 2020 18:30:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363425 - in head/sys: cam/mmc dev/sdhci X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: in head/sys: cam/mmc dev/sdhci X-SVN-Commit-Revision: 363425 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2020 18:30:19 -0000 Author: manu Date: Wed Jul 22 18:30:17 2020 New Revision: 363425 URL: https://svnweb.freebsd.org/changeset/base/363425 Log: mmccam: Add a generic mmccam_start_discovery function This is a generic function start a scan request for the given cam_sim. Other driver can now just use this function to request a new rescan. Submitted by: kibab Modified: head/sys/cam/mmc/mmc_all.h head/sys/cam/mmc/mmc_xpt.c head/sys/dev/sdhci/sdhci.c Modified: head/sys/cam/mmc/mmc_all.h ============================================================================== --- head/sys/cam/mmc/mmc_all.h Wed Jul 22 18:21:37 2020 (r363424) +++ head/sys/cam/mmc/mmc_all.h Wed Jul 22 18:30:17 2020 (r363425) @@ -64,6 +64,7 @@ #ifndef CAM_MMC_ALL_H #define CAM_MMC_ALL_H +#include #include #include @@ -72,5 +73,6 @@ struct ccb_pathinq; struct cam_sim; void mmc_path_inq(struct ccb_pathinq *cpi, const char *hba, const struct cam_sim *sim, size_t maxio); +void mmccam_start_discovery(struct cam_sim *sim); #endif Modified: head/sys/cam/mmc/mmc_xpt.c ============================================================================== --- head/sys/cam/mmc/mmc_xpt.c Wed Jul 22 18:21:37 2020 (r363424) +++ head/sys/cam/mmc/mmc_xpt.c Wed Jul 22 18:30:17 2020 (r363425) @@ -404,6 +404,29 @@ mmc_announce_periph(struct cam_periph *periph) printf("XPT info: CLK %04X, ...\n", cts.proto_specific.mmc.ios.clock); } +void +mmccam_start_discovery(struct cam_sim *sim) { + union ccb *ccb; + uint32_t pathid; + + pathid = cam_sim_path(sim); + ccb = xpt_alloc_ccb_nowait(); + if (ccb == NULL) { + return; + } + + /* + * We create a rescan request for BUS:0:0, since the card + * will be at lun 0. + */ + if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid, + /* target */ 0, /* lun */ 0) != CAM_REQ_CMP) { + xpt_free_ccb(ccb); + return; + } + xpt_rescan(ccb); +} + /* This func is called per attached device :-( */ void mmc_print_ident(struct mmc_params *ident_data) Modified: head/sys/dev/sdhci/sdhci.c ============================================================================== --- head/sys/dev/sdhci/sdhci.c Wed Jul 22 18:21:37 2020 (r363424) +++ head/sys/dev/sdhci/sdhci.c Wed Jul 22 18:30:17 2020 (r363425) @@ -626,29 +626,8 @@ sdhci_card_task(void *arg, int pending __unused) slot_printf(slot, "Card inserted\n"); #ifdef MMCCAM slot->card_present = 1; - union ccb *ccb; - uint32_t pathid; - pathid = cam_sim_path(slot->sim); - ccb = xpt_alloc_ccb_nowait(); - if (ccb == NULL) { - slot_printf(slot, "Unable to alloc CCB for rescan\n"); - SDHCI_UNLOCK(slot); - return; - } - - /* - * We create a rescan request for BUS:0:0, since the card - * will be at lun 0. - */ - if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid, - /* target */ 0, /* lun */ 0) != CAM_REQ_CMP) { - slot_printf(slot, "Unable to create path for rescan\n"); - SDHCI_UNLOCK(slot); - xpt_free_ccb(ccb); - return; - } + mmccam_start_discovery(slot->sim); SDHCI_UNLOCK(slot); - xpt_rescan(ccb); #else d = slot->dev = device_add_child(slot->bus, "mmc", -1); SDHCI_UNLOCK(slot); @@ -672,29 +651,8 @@ sdhci_card_task(void *arg, int pending __unused) slot->dev = NULL; #ifdef MMCCAM slot->card_present = 0; - union ccb *ccb; - uint32_t pathid; - pathid = cam_sim_path(slot->sim); - ccb = xpt_alloc_ccb_nowait(); - if (ccb == NULL) { - slot_printf(slot, "Unable to alloc CCB for rescan\n"); - SDHCI_UNLOCK(slot); - return; - } - - /* - * We create a rescan request for BUS:0:0, since the card - * will be at lun 0. - */ - if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid, - /* target */ 0, /* lun */ 0) != CAM_REQ_CMP) { - slot_printf(slot, "Unable to create path for rescan\n"); - SDHCI_UNLOCK(slot); - xpt_free_ccb(ccb); - return; - } + mmccam_start_discovery(slot->sim); SDHCI_UNLOCK(slot); - xpt_rescan(ccb); #else slot->intmask &= ~sdhci_tuning_intmask(slot); WR4(slot, SDHCI_INT_ENABLE, slot->intmask);