int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) { /* transition the BO to a domain - * just validate the BO into a certain domain */ struct radeon_device *rdev = dev->dev_private; struct drm_radeon_gem_set_domain *args = data; struct drm_gem_object *gobj; struct radeon_bo *robj; int r; /* for now if someone requests domain CPU - * just make sure the buffer is finished with */ rw_enter_read(&rdev->exclusive_lock); /* just do a BO wait for now */ gobj = drm_gem_object_lookup(dev, filp, args->handle); if (gobj == NULL) { rw_exit_read(&rdev->exclusive_lock); return -ENOENT; } robj = gem_to_radeon_bo(gobj); r = radeon_gem_set_domain(gobj, args->read_domains, args->write_domain); drm_gem_object_unreference_unlocked(gobj); rw_exit_read(&rdev->exclusive_lock); r = radeon_gem_handle_lockup(robj->rdev, r); return r; }
int radeon_gem_create_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) { struct radeon_device *rdev = dev->dev_private; struct drm_radeon_gem_create *args = data; struct drm_gem_object *gobj; uint32_t handle; int r; rw_enter_read(&rdev->exclusive_lock); /* create a gem object to contain this object in */ args->size = roundup(args->size, PAGE_SIZE); r = radeon_gem_object_create(rdev, args->size, args->alignment, args->initial_domain, false, false, &gobj); if (r) { rw_exit_read(&rdev->exclusive_lock); r = radeon_gem_handle_lockup(rdev, r); return r; } r = drm_gem_handle_create(filp, gobj, &handle); /* drop reference from allocate - handle holds it now */ drm_gem_object_unreference_unlocked(gobj); if (r) { rw_exit_read(&rdev->exclusive_lock); r = radeon_gem_handle_lockup(rdev, r); return r; } args->handle = handle; rw_exit_read(&rdev->exclusive_lock); return 0; }
int safte_bio_blink(struct safte_softc *sc, struct bioc_blink *blink) { struct safte_writebuf_cmd cmd; struct safte_slotop *op; int slot; int flags; int wantblink; switch (blink->bb_status) { case BIOC_SBBLINK: wantblink = 1; break; case BIOC_SBUNBLINK: wantblink = 0; break; default: return (EINVAL); } rw_enter_read(&sc->sc_lock); for (slot = 0; slot < sc->sc_nslots; slot++) { if (sc->sc_slots[slot] == blink->bb_target) break; } rw_exit_read(&sc->sc_lock); if (slot >= sc->sc_nslots) return (ENODEV); op = malloc(sizeof(struct safte_slotop), M_TEMP, 0); memset(op, 0, sizeof(struct safte_slotop)); op->opcode = SAFTE_WRITE_SLOTOP; op->slot = slot; op->flags |= wantblink ? SAFTE_SLOTOP_IDENTIFY : 0; memset(&cmd, 0, sizeof(cmd)); cmd.opcode = WRITE_BUFFER; cmd.flags |= SAFTE_WR_MODE; cmd.length = htobe16(sizeof(struct safte_slotop)); flags = SCSI_DATA_OUT; #ifndef SCSIDEBUG flags |= SCSI_SILENT; #endif if (cold) flags |= SCSI_AUTOCONF; if (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd, sizeof(cmd), (u_char *)op, sizeof(struct safte_slotop), 2, 30000, NULL, flags) != 0) { free(op, M_TEMP); return (EIO); } free(op, M_TEMP); return (0); }
static int pty_isfree(int minor) { int isfree; rw_enter_read(&pt_softc_lock); isfree = pty_isfree_locked(minor); rw_exit_read(&pt_softc_lock); return(isfree); }
dev_t pty_getfree(void) { int i; rw_enter_read(&pt_softc_lock); for (i = 0; i < npty; i++) { if (pty_isfree_locked(i)) break; } rw_exit_read(&pt_softc_lock); return (makedev(pts_major, i)); }
int radeon_ttm_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, vm_page_t *pps, int npages, int centeridx, vm_fault_t fault_type, vm_prot_t access_type, int flags) { struct ttm_buffer_object *bo; struct radeon_device *rdev; int r; bo = (struct ttm_buffer_object *)ufi->entry->object.uvm_obj; rdev = radeon_get_rdev(bo->bdev); rw_enter_read(&rdev->pm.mclk_lock); r = ttm_vm_ops->pgo_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags); rw_exit_read(&rdev->pm.mclk_lock); return r; }
int safte_bio_blink(struct safte_softc *sc, struct bioc_blink *blink) { struct safte_writebuf_cmd *cmd; struct safte_slotop *op; struct scsi_xfer *xs; int error, slot, flags = 0, wantblink; switch (blink->bb_status) { case BIOC_SBBLINK: wantblink = 1; break; case BIOC_SBUNBLINK: wantblink = 0; break; default: return (EINVAL); } rw_enter_read(&sc->sc_lock); for (slot = 0; slot < sc->sc_nslots; slot++) { if (sc->sc_slots[slot] == blink->bb_target) break; } rw_exit_read(&sc->sc_lock); if (slot >= sc->sc_nslots) return (ENODEV); op = dma_alloc(sizeof(*op), PR_WAITOK | PR_ZERO); op->opcode = SAFTE_WRITE_SLOTOP; op->slot = slot; op->flags |= wantblink ? SAFTE_SLOTOP_IDENTIFY : 0; if (cold) flags |= SCSI_AUTOCONF; xs = scsi_xs_get(sc->sc_link, flags | SCSI_DATA_OUT | SCSI_SILENT); if (xs == NULL) { dma_free(op, sizeof(*op)); return (ENOMEM); } xs->cmdlen = sizeof(*cmd); xs->data = (void *)op; xs->datalen = sizeof(*op); xs->retries = 2; xs->timeout = 30000; cmd = (struct safte_writebuf_cmd *)xs->cmd; cmd->opcode = WRITE_BUFFER; cmd->flags |= SAFTE_WR_MODE; cmd->length = htobe16(sizeof(struct safte_slotop)); error = scsi_xs_sync(xs); scsi_xs_put(xs); if (error != 0) { error = EIO; } dma_free(op, sizeof(*op)); return (error); }