From owner-svn-src-head@freebsd.org Thu Nov 26 16:39:57 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 868E5468A01; Thu, 26 Nov 2020 16:39:57 +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 4Chk4s3R3Yz4j84; Thu, 26 Nov 2020 16:39:57 +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 5E3A926266; Thu, 26 Nov 2020 16:39:57 +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 0AQGdvdX075107; Thu, 26 Nov 2020 16:39:57 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AQGdv3b075106; Thu, 26 Nov 2020 16:39:57 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011261639.0AQGdv3b075106@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Thu, 26 Nov 2020 16:39:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368059 - head/sys/cam/mmc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/cam/mmc X-SVN-Commit-Revision: 368059 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.34 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: Thu, 26 Nov 2020 16:39:57 -0000 Author: manu Date: Thu Nov 26 16:39:56 2020 New Revision: 368059 URL: https://svnweb.freebsd.org/changeset/base/368059 Log: mmccam: We can't sleep during sdda_add_part so use M_NOWAIT Reviewed by: kibab Differential Revision: https://reviews.freebsd.org/D25947 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c ============================================================================== --- head/sys/cam/mmc/mmc_da.c Thu Nov 26 16:36:50 2020 (r368058) +++ head/sys/cam/mmc/mmc_da.c Thu Nov 26 16:39:56 2020 (r368059) @@ -202,7 +202,7 @@ static inline bool sdda_get_read_only(struct cam_perip static uint32_t mmc_get_spec_vers(struct cam_periph *periph); static uint64_t mmc_get_media_size(struct cam_periph *periph); static uint32_t mmc_get_cmd6_timeout(struct cam_periph *periph); -static void sdda_add_part(struct cam_periph *periph, u_int type, +static bool sdda_add_part(struct cam_periph *periph, u_int type, const char *name, u_int cnt, off_t media_size, bool ro); static struct periph_driver sddadriver = @@ -1502,10 +1502,11 @@ finish_hs_tests: sdda_process_mmc_partitions(periph, start_ccb); } else if (mmcp->card_features & CARD_FEATURE_SD20) { /* For SD[HC] cards, just add one partition that is the whole card */ - sdda_add_part(periph, 0, "sdda", + if (sdda_add_part(periph, 0, "sdda", periph->unit_number, mmc_get_media_size(periph), - sdda_get_read_only(periph, start_ccb)); + sdda_get_read_only(periph, start_ccb)) == false) + return; softc->part_curr = 0; } cam_periph_hold(periph, PRIBIO|PCATCH); @@ -1521,7 +1522,7 @@ finish_hs_tests: AC_ADVINFO_CHANGED, sddaasync, periph, periph->path); } -static void +static bool sdda_add_part(struct cam_periph *periph, u_int type, const char *name, u_int cnt, off_t media_size, bool ro) { @@ -1536,7 +1537,11 @@ sdda_add_part(struct cam_periph *periph, u_int type, c ro ? "(read-only)" : "")); part = sc->part[type] = malloc(sizeof(*part), M_DEVBUF, - M_WAITOK | M_ZERO); + M_NOWAIT | M_ZERO); + if (part == NULL) { + printf("Cannot add partition for sdda\n"); + return (false); + } part->cnt = cnt; part->type = type; @@ -1554,7 +1559,7 @@ sdda_add_part(struct cam_periph *periph, u_int type, c /* TODO: Create device, assign IOCTL handler */ CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Don't know what to do with RPMB partitions yet\n")); - return; + return (false); } bioq_init(&part->bio_queue); @@ -1620,11 +1625,13 @@ sdda_add_part(struct cam_periph *periph, u_int type, c xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); - return; + return (false); } disk_create(part->disk, DISK_VERSION); cam_periph_lock(periph); cam_periph_unhold(periph); + + return (true); } /*